remove a whole load of event->user variables that weren't used -- things should be using global user
This commit is contained in:
parent
f3aad43fa3
commit
7dd929e5a8
@ -140,6 +140,8 @@ abstract class FormatterExtension extends Extension {
|
|||||||
*/
|
*/
|
||||||
abstract class DataHandlerExtension extends Extension {
|
abstract class DataHandlerExtension extends Extension {
|
||||||
public function onDataUpload(DataUploadEvent $event) {
|
public function onDataUpload(DataUploadEvent $event) {
|
||||||
|
global $user;
|
||||||
|
|
||||||
if($this->supported_ext($event->type) && $this->check_contents($event->tmpname)) {
|
if($this->supported_ext($event->type) && $this->check_contents($event->tmpname)) {
|
||||||
if(!move_upload_to_archive($event)) return;
|
if(!move_upload_to_archive($event)) return;
|
||||||
send_event(new ThumbnailGenerationEvent($event->hash, $event->type));
|
send_event(new ThumbnailGenerationEvent($event->hash, $event->type));
|
||||||
@ -178,15 +180,14 @@ abstract class DataHandlerExtension extends Extension {
|
|||||||
if(is_null($image)) {
|
if(is_null($image)) {
|
||||||
throw new UploadException("Data handler failed to create image object from data");
|
throw new UploadException("Data handler failed to create image object from data");
|
||||||
}
|
}
|
||||||
$iae = new ImageAdditionEvent($event->user, $image);
|
$iae = new ImageAdditionEvent($image);
|
||||||
send_event($iae);
|
send_event($iae);
|
||||||
$event->image_id = $iae->image->id;
|
$event->image_id = $iae->image->id;
|
||||||
|
|
||||||
// Rating Stuff.
|
// Rating Stuff.
|
||||||
if(!empty($event->metadata['rating'])){
|
if(!empty($event->metadata['rating'])){
|
||||||
global $user;
|
|
||||||
$rating = $event->metadata['rating'];
|
$rating = $event->metadata['rating'];
|
||||||
send_event(new RatingSetEvent($image, $user, $rating));
|
send_event(new RatingSetEvent($image, $rating));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Locked Stuff.
|
// Locked Stuff.
|
||||||
|
@ -49,7 +49,6 @@ class BulkAdd extends Extension {
|
|||||||
private function add_image($tmpname, $filename, $tags) {
|
private function add_image($tmpname, $filename, $tags) {
|
||||||
assert(file_exists($tmpname));
|
assert(file_exists($tmpname));
|
||||||
|
|
||||||
global $user;
|
|
||||||
$pathinfo = pathinfo($filename);
|
$pathinfo = pathinfo($filename);
|
||||||
if(!array_key_exists('extension', $pathinfo)) {
|
if(!array_key_exists('extension', $pathinfo)) {
|
||||||
throw new UploadException("File has no extension");
|
throw new UploadException("File has no extension");
|
||||||
@ -58,7 +57,7 @@ class BulkAdd extends Extension {
|
|||||||
$metadata['extension'] = $pathinfo['extension'];
|
$metadata['extension'] = $pathinfo['extension'];
|
||||||
$metadata['tags'] = $tags;
|
$metadata['tags'] = $tags;
|
||||||
$metadata['source'] = null;
|
$metadata['source'] = null;
|
||||||
$event = new DataUploadEvent($user, $tmpname, $metadata);
|
$event = new DataUploadEvent($tmpname, $metadata);
|
||||||
send_event($event);
|
send_event($event);
|
||||||
if($event->image_id == -1) {
|
if($event->image_id == -1) {
|
||||||
throw new UploadException("File type not recognised");
|
throw new UploadException("File type not recognised");
|
||||||
|
@ -227,7 +227,7 @@ class DanbooruApi extends Extension {
|
|||||||
//log_debug("danbooru_api", "upload($filename): fileinfo(".var_export($fileinfo,TRUE)."), metadata(".var_export($metadata,TRUE).")...");
|
//log_debug("danbooru_api", "upload($filename): fileinfo(".var_export($fileinfo,TRUE)."), metadata(".var_export($metadata,TRUE).")...");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$nevent = new DataUploadEvent($user, $file, $metadata);
|
$nevent = new DataUploadEvent($file, $metadata);
|
||||||
//log_debug("danbooru_api", "send_event(".var_export($nevent,TRUE).")");
|
//log_debug("danbooru_api", "send_event(".var_export($nevent,TRUE).")");
|
||||||
send_event($nevent);
|
send_event($nevent);
|
||||||
// If it went ok, grab the id for the newly uploaded image and pass it in the header
|
// If it went ok, grab the id for the newly uploaded image and pass it in the header
|
||||||
|
@ -16,7 +16,7 @@ class IcoFileHandler extends Extension {
|
|||||||
if(is_null($image)) {
|
if(is_null($image)) {
|
||||||
throw new UploadException("Icon handler failed to create image object from data");
|
throw new UploadException("Icon handler failed to create image object from data");
|
||||||
}
|
}
|
||||||
$iae = new ImageAdditionEvent($event->user, $image);
|
$iae = new ImageAdditionEvent($image);
|
||||||
send_event($iae);
|
send_event($iae);
|
||||||
$event->image_id = $iae->image->id;
|
$event->image_id = $iae->image->id;
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ class SVGFileHandler extends Extension {
|
|||||||
if(is_null($image)) {
|
if(is_null($image)) {
|
||||||
throw new UploadException("SVG handler failed to create image object from data");
|
throw new UploadException("SVG handler failed to create image object from data");
|
||||||
}
|
}
|
||||||
$iae = new ImageAdditionEvent($event->user, $image);
|
$iae = new ImageAdditionEvent($image);
|
||||||
send_event($iae);
|
send_event($iae);
|
||||||
$event->image_id = $iae->image->id;
|
$event->image_id = $iae->image->id;
|
||||||
}
|
}
|
||||||
|
@ -20,12 +20,10 @@ class ImageAdditionEvent extends Event {
|
|||||||
* this new image.
|
* this new image.
|
||||||
*
|
*
|
||||||
* @sa TagSetEvent
|
* @sa TagSetEvent
|
||||||
* @param $user The user adding the image
|
|
||||||
* @param $image The new image to add.
|
* @param $image The new image to add.
|
||||||
*/
|
*/
|
||||||
public function ImageAdditionEvent(User $user, Image $image) {
|
public function ImageAdditionEvent(Image $image) {
|
||||||
$this->image = $image;
|
$this->image = $image;
|
||||||
$this->user = $user;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -296,7 +294,7 @@ class ImageIO extends Extension {
|
|||||||
$merged = array_merge($image->get_tag_array(), $existing->get_tag_array());
|
$merged = array_merge($image->get_tag_array(), $existing->get_tag_array());
|
||||||
send_event(new TagSetEvent($existing, $merged));
|
send_event(new TagSetEvent($existing, $merged));
|
||||||
if(isset($_GET['rating']) && isset($_GET['update']) && class_exists("Ratings")){
|
if(isset($_GET['rating']) && isset($_GET['update']) && class_exists("Ratings")){
|
||||||
send_event(new RatingSetEvent($existing, $user, $_GET['rating']));
|
send_event(new RatingSetEvent($existing, $_GET['rating']));
|
||||||
}
|
}
|
||||||
if(isset($_GET['source']) && isset($_GET['update'])){
|
if(isset($_GET['source']) && isset($_GET['update'])){
|
||||||
send_event(new SourceSetEvent($existing, $_GET['source']));
|
send_event(new SourceSetEvent($existing, $_GET['source']));
|
||||||
|
@ -20,9 +20,10 @@ class LiveFeed extends Extension {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function onImageAddition($event) {
|
public function onImageAddition($event) {
|
||||||
|
global $user;
|
||||||
$this->msg(
|
$this->msg(
|
||||||
make_http(make_link("post/view/".$event->image->id))." - ".
|
make_http(make_link("post/view/".$event->image->id))." - ".
|
||||||
"new post by ".$event->user->name
|
"new post by ".$user->name
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -34,9 +35,10 @@ class LiveFeed extends Extension {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function onCommentPosting($event) {
|
public function onCommentPosting($event) {
|
||||||
|
global $user;
|
||||||
$this->msg(
|
$this->msg(
|
||||||
make_http(make_link("post/view/".$event->image_id))." - ".
|
make_http(make_link("post/view/".$event->image_id))." - ".
|
||||||
$event->user->name . ": " . str_replace("\n", " ", $event->comment)
|
$user->name . ": " . str_replace("\n", " ", $event->comment)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ class Oekaki extends Extension {
|
|||||||
$metadata['extension'] = $pathinfo['extension'];
|
$metadata['extension'] = $pathinfo['extension'];
|
||||||
$metadata['tags'] = 'oekaki tagme';
|
$metadata['tags'] = 'oekaki tagme';
|
||||||
$metadata['source'] = null;
|
$metadata['source'] = null;
|
||||||
$event = new DataUploadEvent($user, $tmpname, $metadata);
|
$event = new DataUploadEvent($tmpname, $metadata);
|
||||||
send_event($event);
|
send_event($event);
|
||||||
if($event->image_id == -1) {
|
if($event->image_id == -1) {
|
||||||
throw new UploadException("File type not recognised");
|
throw new UploadException("File type not recognised");
|
||||||
|
@ -8,12 +8,11 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
class RatingSetEvent extends Event {
|
class RatingSetEvent extends Event {
|
||||||
var $image, $user, $rating;
|
var $image, $rating;
|
||||||
|
|
||||||
public function RatingSetEvent(Image $image, User $user, $rating) {
|
public function RatingSetEvent(Image $image, /*char*/ $rating) {
|
||||||
assert(in_array($rating, array("s", "q", "e", "u")));
|
assert(in_array($rating, array("s", "q", "e", "u")));
|
||||||
$this->image = $image;
|
$this->image = $image;
|
||||||
$this->user = $user;
|
|
||||||
$this->rating = $rating;
|
$this->rating = $rating;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -89,7 +88,7 @@ class Ratings extends Extension {
|
|||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
if($this->can_rate() && isset($_POST["rating"])) {
|
if($this->can_rate() && isset($_POST["rating"])) {
|
||||||
send_event(new RatingSetEvent($event->image, $user, $_POST['rating']));
|
send_event(new RatingSetEvent($event->image, $_POST['rating']));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -138,7 +137,7 @@ class Ratings extends Extension {
|
|||||||
reset($images); // rewind to first element in array.
|
reset($images); // rewind to first element in array.
|
||||||
|
|
||||||
foreach($images as $image) {
|
foreach($images as $image) {
|
||||||
send_event(new RatingSetEvent($image, $user, $_POST['rating']));
|
send_event(new RatingSetEvent($image, $_POST['rating']));
|
||||||
}
|
}
|
||||||
$n += 100;
|
$n += 100;
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
* Occurs when some data is being uploaded.
|
* Occurs when some data is being uploaded.
|
||||||
*/
|
*/
|
||||||
class DataUploadEvent extends Event {
|
class DataUploadEvent extends Event {
|
||||||
var $user, $tmpname, $metadata, $hash, $type, $image_id = -1;
|
var $tmpname, $metadata, $hash, $type, $image_id = -1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Some data is being uploaded.
|
* Some data is being uploaded.
|
||||||
@ -19,10 +19,9 @@ class DataUploadEvent extends Event {
|
|||||||
* @param $tmpname The temporary file used for upload.
|
* @param $tmpname The temporary file used for upload.
|
||||||
* @param $metadata Info about the file, should contain at least "filename", "extension", "tags" and "source".
|
* @param $metadata Info about the file, should contain at least "filename", "extension", "tags" and "source".
|
||||||
*/
|
*/
|
||||||
public function DataUploadEvent(User $user, /*string*/ $tmpname, /*array*/ $metadata) {
|
public function DataUploadEvent(/*string*/ $tmpname, /*array*/ $metadata) {
|
||||||
assert(file_exists($tmpname));
|
assert(file_exists($tmpname));
|
||||||
|
|
||||||
$this->user = $user;
|
|
||||||
$this->tmpname = $tmpname;
|
$this->tmpname = $tmpname;
|
||||||
|
|
||||||
$this->metadata = $metadata;
|
$this->metadata = $metadata;
|
||||||
@ -289,7 +288,7 @@ class Upload extends Extension {
|
|||||||
$metadata['replace'] = $replace;
|
$metadata['replace'] = $replace;
|
||||||
}
|
}
|
||||||
|
|
||||||
$event = new DataUploadEvent($user, $file['tmp_name'], $metadata);
|
$event = new DataUploadEvent($file['tmp_name'], $metadata);
|
||||||
send_event($event);
|
send_event($event);
|
||||||
if($event->image_id == -1) {
|
if($event->image_id == -1) {
|
||||||
throw new UploadException("File type not recognised");
|
throw new UploadException("File type not recognised");
|
||||||
@ -376,7 +375,7 @@ class Upload extends Extension {
|
|||||||
$metadata['replace'] = $replace;
|
$metadata['replace'] = $replace;
|
||||||
}
|
}
|
||||||
|
|
||||||
$event = new DataUploadEvent($user, $tmp_filename, $metadata);
|
$event = new DataUploadEvent($tmp_filename, $metadata);
|
||||||
try {
|
try {
|
||||||
send_event($event);
|
send_event($event);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user