Can now set rating/external source while uploading via the bookmarklets.
This commit is contained in:
parent
913bb09cc6
commit
cd11e75e40
@ -177,6 +177,13 @@ abstract class DataHandlerExtension implements Extension {
|
||||
$iae = new ImageAdditionEvent($event->user, $image);
|
||||
send_event($iae);
|
||||
$event->image_id = $iae->image->id;
|
||||
|
||||
// Rating Stuff.
|
||||
if(file_exists("ext/rating") && !empty($event->metadata['rating'])){
|
||||
global $database;
|
||||
$rating = $event->metadata['rating'];
|
||||
$database->Execute("UPDATE images SET rating=? WHERE id=?", array($rating, $event->image_id));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -173,7 +173,35 @@ class Upload implements Extension {
|
||||
if(!empty($_GET['tags']) && $_GET['tags'] != "null") {
|
||||
$tags = Tag::explode($_GET['tags']);
|
||||
}
|
||||
$ok = $this->try_transload($url, $tags, $url);
|
||||
|
||||
|
||||
|
||||
// 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);
|
||||
$this->theme->display_upload_status($page, $ok);
|
||||
}
|
||||
else
|
||||
@ -250,7 +278,7 @@ class Upload implements Extension {
|
||||
}
|
||||
}
|
||||
|
||||
private function try_upload($file, $tags, $source, $replace='') {
|
||||
private function try_upload($file, $tags, $rating, $source, $replace='') {
|
||||
global $page;
|
||||
global $config;
|
||||
global $user;
|
||||
@ -296,13 +324,18 @@ class Upload implements Extension {
|
||||
return $ok;
|
||||
}
|
||||
|
||||
private function try_transload($url, $tags, $source, $replace='') {
|
||||
private function try_transload($url, $tags, $rating, $source, $replace='') {
|
||||
global $page;
|
||||
global $config;
|
||||
|
||||
$ok = true;
|
||||
|
||||
if(empty($source)) $source = $url;
|
||||
//Allows external source to be set.
|
||||
if(!empty($_GET['source'])){
|
||||
$source = $_GET['source'];
|
||||
}else{
|
||||
$source = $url;
|
||||
}
|
||||
|
||||
// PHP falls back to system default if /tmp fails, can't we just
|
||||
// use the system default to start with? :-/
|
||||
@ -363,6 +396,11 @@ class Upload implements Extension {
|
||||
$metadata['tags'] = $tags;
|
||||
$metadata['source'] = $source;
|
||||
|
||||
/* check for rating > adds to metadata if it has */
|
||||
if($config->get_string("transload_engine", "none") != "none" && file_exists("ext/rating") && !empty($_GET['rating'])){
|
||||
$metadata['rating'] = $rating;
|
||||
}
|
||||
|
||||
/* check if we have been given an image ID to replace */
|
||||
if (!empty($replace)) {
|
||||
$metadata['replace'] = $replace;
|
||||
|
Loading…
x
Reference in New Issue
Block a user