--- image.module 2004-10-02 22:01:56.000000000 +0200 +++ image.module.php 2004-10-08 13:55:33.000000000 +0200 @@ -157,6 +157,7 @@ $output .= form_select(t("Personal Image Galleries"), "image_personal_gallery", variable_get("image_personal_gallery", "1"), array("1" => "enabled", "0" => "disabled"), t("Activate/deactivate personal image galleries site-wide. When enabled you can use the \"has personal image gallery\" permission to control which roles have personal galleries.")); if (variable_get("image_personal_gallery", "1") == "1") { + $output .= form_select(t("Personal Images in shared Gallery"), "image_personal_shared", variable_get("image_personal_shared","0"), array("1" => "show", "0" => "hide"), t("Shows or hides personal images in shared Galleries.")); $output .= form_textfield(t("Personal Gallery Picture Limit"), "image_personal_gallery_max_num", variable_get("image_personal_gallery_max_num", "50"), 5, 255, t("Set how many pictures users are allowed.")); $output .= form_select(t("Personal Gallery Picture Limit Per Role"), "image_personal_gallery_role", variable_get("image_personal_gallery_role", "0"), array("0" => "disabled", "1" => "enabled"), t("Enabling this will allow for setting a maximum number of pictures per role.")); @@ -259,8 +260,8 @@ $links[] = l(t("%t image gallery", array("%t" => $term->name)), "image/tid/" . $term->tid, array("title" => t("View %t image gallery.", array("%t" => $terms->name)))); - $sql = "SELECT n.nid, n.title, n.teaser, n.body, i.thumb_path FROM {node} n, {term_node} t, {image} i WHERE n.nid = t.nid AND n.nid = i.nid AND i.personal = 0 AND n.moderate = 0"; - if (isset($term->tid)) { + $sql = "SELECT n.nid, n.title, n.teaser, n.body, i.thumb_path FROM {node} n, {term_node} t, {image} i WHERE n.nid = t.nid AND n.nid = i.nid AND n.moderate = 0"._image_personal_shared(); + if (isset($term->tid)) { $sql .= " AND t.tid = " . $term->tid; } $sql .= " ORDER BY "._image_get_thumb_order(); @@ -424,7 +425,7 @@ } if (_image_can_personal() && user_access("create images")) { - $output .= form_select(t("Personal"), "personal", $node->personal, array("0" => "disabled", "1" => "enabled"), t("A personal image can only be seen in the user's image gallery.")); + $output .= form_select(t("Personal"), "personal", $node->personal, array("0" => "disabled", "1" => "enabled"), t("A personal image can (only) be seen in the user's image gallery.")); } $output .= form_hidden("existing", $node->existing); @@ -1312,8 +1313,7 @@ $subalbums = _image_album_properties($subalbums); $thumb_num = variable_get("image_gallery_thumb_rows", "5") * variable_get("image_gallery_thumb_cols", "3"); - $sql = "SELECT n.nid, n.title, n.teaser, n.body, i.thumb_path FROM {node} n, {term_node} t, {image} i WHERE n.nid = t.nid AND n.nid = i.nid AND t.tid = '". $tid ."' AND i.personal = 0 AND n.moderate = 0 AND n.status = 1 ORDER BY ". _image_get_thumb_order(); - + $sql = "SELECT n.nid, n.title, n.teaser, n.body, i.thumb_path FROM {node} n, {term_node} t, {image} i WHERE n.nid = t.nid AND n.nid = i.nid AND t.tid = '". $tid ."' AND n.moderate = 0 AND n.status = 1"._image_personal_shared()." ORDER BY "._image_get_thumb_order(); $result = pager_query($sql, $thumb_num, 0); while ($image = db_fetch_object($result)) { $images[] = $image; @@ -1388,17 +1388,17 @@ foreach ($children as $term) { $terms[] = $term->tid; } - $result = db_query("SELECT COUNT(*) AS c FROM {term_node} t, {node} n, {image} i WHERE t.nid = n.nid AND i.nid = n.nid AND t.tid IN (". implode(",", $terms) .") AND i.personal = 0 AND n.moderate = 0 AND n.status = 1"); + $result = db_query("SELECT COUNT(*) AS c FROM {term_node} t, {node} n, {image} i WHERE t.nid = n.nid AND i.nid = n.nid AND t.tid IN (". implode(",", $terms) .") AND n.moderate = 0 AND n.status = 1"._image_personal_shared()); while ($term = db_fetch_object($result)) { $albums[$term_id]->image_count = $term->c; } - $last_update = db_fetch_object(db_query_range("SELECT n.created, i.thumb_path FROM {node} n INNER JOIN {image} i ON n.nid = i.nid INNER JOIN {term_node} t ON n.nid = t.nid WHERE t.tid IN (". implode(",", $terms) .") AND n.type = 'image' AND i.personal = 0 AND n.moderate = 0 ORDER BY n.created DESC", 0, 1)); + $last_update = db_fetch_object(db_query_range("SELECT n.created, i.thumb_path FROM {node} n INNER JOIN {image} i ON n.nid = i.nid INNER JOIN {term_node} t ON n.nid = t.nid WHERE t.tid IN (". implode(",", $terms) .") AND n.type = 'image' AND n.moderate = 0"._image_personal_shared()."ORDER BY n.created DESC", 0, 1)); $albums[$term_id]->last_updated = $last_update->created; $albums[$term_id]->thumb = $last_update->thumb_path; if (variable_get("image_gallery_thumb", "last") == "random") { - $random = db_fetch_object(db_query_range("SELECT i.thumb_path FROM {node} n INNER JOIN {image} i ON n.nid = i.nid INNER JOIN {term_node} t ON n.nid = t.nid WHERE t.tid IN (".implode(",", $terms).") AND n.type = 'image' AND i.personal = 0 AND n.moderate = 0 AND n.status = 1 ORDER BY RAND()", 0, 1)); + $random = db_fetch_object(db_query_range("SELECT i.thumb_path FROM {node} n INNER JOIN {image} i ON n.nid = i.nid INNER JOIN {term_node} t ON n.nid = t.nid WHERE t.tid IN (".implode(",", $terms).") AND n.type = 'image' AND n.moderate = 0 AND n.status = 1"._image_personal_shared()."ORDER BY RAND()", 0, 1)); $albums[$term_id]->thumb = $random->thumb_path; } } @@ -1855,5 +1855,14 @@ return $result; } } +/** + * returns " AND i.personal = 0" if shared personal images are off, otherwise " " + */ +function _image_personal_shared() { + if (variable_get("image_personal_shared", "0") == "0") { + $result = " AND i.personal = 0 "; + } else { $result = " "; } + return $result; +} ?>