diff --git a/core/extension.class.php b/core/extension.class.php index 7906822b..4571b1c0 100644 --- a/core/extension.class.php +++ b/core/extension.class.php @@ -179,11 +179,17 @@ abstract class DataHandlerExtension implements Extension { $event->image_id = $iae->image->id; // Rating Stuff. - if(file_exists("ext/rating") && !empty($event->metadata['rating'])){ + if(!empty($event->metadata['rating'])){ global $database; $rating = $event->metadata['rating']; $database->Execute("UPDATE images SET rating=? WHERE id=?", array($rating, $event->image_id)); } + + // Locked Stuff. + if(!empty($event->metadata['locked'])){ + $locked = $event->metadata['locked']; + send_event(new LockSetEvent($image, !empty($locked))); + } } } diff --git a/ext/upload/main.php b/ext/upload/main.php index fd8e5e6a..36e0914c 100644 --- a/ext/upload/main.php +++ b/ext/upload/main.php @@ -173,35 +173,8 @@ class Upload implements Extension { if(!empty($_GET['tags']) && $_GET['tags'] != "null") { $tags = Tag::explode($_GET['tags']); } - - - - // Checks if url contains rating, also checks if the rating extension is enabled. - if($config->get_string("transload_engine", "none") != "none" && file_exists("ext/rating") && !empty($_GET['rating'])) { - $rating = strtolower($_GET['rating']); - // There must be a less messy way to do this.. - if($rating !== "") { - if($rating == "s" || $rating == "safe" || $rating == "q" || $rating == "questionable" || $rating == "e" || $rating == "explicit") { - if($rating == "s" || $rating == "safe" || $rating == "q" || $rating == "questionable") { - if($rating == "s" || $rating == "safe") { - $rating = "s"; - }else{ - $rating = "q"; - } - }else{ - $rating = "e"; - } - }else{ - $rating = "u"; - } - }else{ - $rating = "u"; - } - }else{ - $rating = ""; - } - - $ok = $this->try_transload($url, $tags, $rating, $url); + + $ok = $this->try_transload($url, $tags, $url); $this->theme->display_upload_status($page, $ok); } else @@ -278,7 +251,7 @@ class Upload implements Extension { } } - private function try_upload($file, $tags, $rating, $source, $replace='') { + private function try_upload($file, $tags, $source, $replace='') { global $page; global $config; global $user; @@ -324,9 +297,10 @@ class Upload implements Extension { return $ok; } - private function try_transload($url, $tags, $rating, $source, $replace='') { + private function try_transload($url, $tags, $source, $replace='') { global $page; global $config; + global $user; $ok = true; @@ -336,6 +310,41 @@ class Upload implements Extension { }else{ $source = $url; } + + // Checks if user is admin > check if you want locked. + if($user->is_admin()){ + // There must be a less messy way to do this.. + if($_GET['locked'] == "y" || $_GET['locked'] == "yes" || $_GET['locked'] == "true" || $_GET['locked'] == "on" || $_GET['locked'] == "n" || $_GET['locked'] == "no" || $_GET['locked'] == "false" || $_GET['locked'] == "off"){ + if($_GET['locked'] == "y" || $_GET['locked'] == "yes" || $_GET['locked'] == "true" || $_GET['locked'] == "on"){ + $locked = "on"; + } + } + } + + // Checks if url contains rating, also checks if the rating extension is enabled. + if($config->get_string("transload_engine", "none") != "none" && file_exists("ext/rating") && !empty($_GET['rating'])) { + $rating = strtolower($_GET['rating']); + // There REALLY must be a less messy way to do this.. + if($rating !== "") { + if($rating == "s" || $rating == "safe" || $rating == "q" || $rating == "questionable" || $rating == "e" || $rating == "explicit") { + if($rating == "s" || $rating == "safe" || $rating == "q" || $rating == "questionable") { + if($rating == "s" || $rating == "safe") { + $rating = "s"; + }else{ + $rating = "q"; + } + }else{ + $rating = "e"; + } + }else{ + $rating = "u"; + } + }else{ + $rating = "u"; + } + }else{ + $rating = ""; + } // PHP falls back to system default if /tmp fails, can't we just // use the system default to start with? :-/ @@ -396,8 +405,13 @@ class Upload implements Extension { $metadata['tags'] = $tags; $metadata['source'] = $source; + /* check for locked > adds to metadata if it has */ + if(!empty($locked)){ + $metadata['locked'] = $locked; + } + /* check for rating > adds to metadata if it has */ - if($config->get_string("transload_engine", "none") != "none" && file_exists("ext/rating") && !empty($_GET['rating'])){ + if(!empty($rating)){ $metadata['rating'] = $rating; }