From c78dbd2eea2dae14b076d8d800474c8715982277 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 9 Oct 2015 09:45:28 +0200 Subject: [ticket/14168] Add attachment manager service PHPBB3-14168 --- phpBB/phpbb/attachment/manager.php | 99 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 phpBB/phpbb/attachment/manager.php (limited to 'phpBB/phpbb/attachment/manager.php') diff --git a/phpBB/phpbb/attachment/manager.php b/phpBB/phpbb/attachment/manager.php new file mode 100644 index 0000000000..0aeadf3e3e --- /dev/null +++ b/phpBB/phpbb/attachment/manager.php @@ -0,0 +1,99 @@ + + * @license GNU General Public License, version 2 (GPL-2.0) + * + * For full copyright and license information, please see + * the docs/CREDITS.txt file. + * + */ + +namespace phpbb\attachment; + +/** + * Attachment manager + */ +class manager +{ + /** @var delete Attachment delete class */ + protected $delete; + + /** @var resync Attachment resync class */ + protected $resync; + + /** @var upload Attachment upload class */ + protected $upload; + + /** + * Constructor for attachment manager + * + * @param delete $delete Attachment delete class + * @param resync $resync Attachment resync class + * @param upload $upload Attachment upload class + */ + public function __construct(delete $delete, resync $resync, upload $upload) + { + $this->delete = $delete; + $this->resync = $resync; + $this->upload = $upload; + } + + /** + * Wrapper method for deleting attachments + * + * @param string $mode can be: post|message|topic|attach|user + * @param mixed $ids can be: post_ids, message_ids, topic_ids, attach_ids, user_ids + * @param bool $resync set this to false if you are deleting posts or topics + * + * @return int|bool Number of deleted attachments or false if something + * went wrong during attachment deletion + */ + public function delete($mode, $id, $resync = true) + { + $this->delete->delete($mode, $id, $resync); + } + + /** + * Wrapper method for deleting attachments from filesystem + * + * @param string $filename Filename of attachment + * @param string $mode Delete mode + * @param bool $entry_removed Whether entry was removed. Defaults to false + * @return bool True if file was removed, false if not + */ + public function unlink($filename, $mode = 'file', $entry_removed = false) + { + $this->delete->unlink_attachment($filename, $mode, $entry_removed); + } + + /** + * Wrapper method for resyncing specified type + * + * @param string $type Type of resync + * @param array $ids IDs to resync + */ + public function resync($type, $ids) + { + $this->resync->resync($type, $ids); + } + + /** + * Wrapper method for uploading attachment + * + * @param string $form_name The form name of the file upload input + * @param int $forum_id The id of the forum + * @param bool $local Whether the file is local or not + * @param string $local_storage The path to the local file + * @param bool $is_message Whether it is a PM or not + * @param array $local_filedata An file data object created for the local file + * + * @return object filespec + */ + public function upload($form_name, $forum_id, $local = false, $local_storage = '', $is_message = false, $local_filedata = []) + { + $this->upload->upload($form_name, $forum_id, $local, $local_storage, $is_message, $local_filedata); + } +} -- cgit v1.2.1 From 53008c87828746c316019e758641a2a4e37f522b Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 9 Oct 2015 12:14:19 +0200 Subject: [ticket/14168] Fix tabs in manager and add test file PHPBB3-14168 --- phpBB/phpbb/attachment/manager.php | 142 ++++++++++++++++++------------------- 1 file changed, 71 insertions(+), 71 deletions(-) (limited to 'phpBB/phpbb/attachment/manager.php') diff --git a/phpBB/phpbb/attachment/manager.php b/phpBB/phpbb/attachment/manager.php index 0aeadf3e3e..414a8edfdd 100644 --- a/phpBB/phpbb/attachment/manager.php +++ b/phpBB/phpbb/attachment/manager.php @@ -18,82 +18,82 @@ namespace phpbb\attachment; */ class manager { - /** @var delete Attachment delete class */ - protected $delete; + /** @var delete Attachment delete class */ + protected $delete; - /** @var resync Attachment resync class */ - protected $resync; + /** @var resync Attachment resync class */ + protected $resync; - /** @var upload Attachment upload class */ - protected $upload; + /** @var upload Attachment upload class */ + protected $upload; - /** - * Constructor for attachment manager - * - * @param delete $delete Attachment delete class - * @param resync $resync Attachment resync class - * @param upload $upload Attachment upload class - */ - public function __construct(delete $delete, resync $resync, upload $upload) - { - $this->delete = $delete; - $this->resync = $resync; - $this->upload = $upload; - } + /** + * Constructor for attachment manager + * + * @param delete $delete Attachment delete class + * @param resync $resync Attachment resync class + * @param upload $upload Attachment upload class + */ + public function __construct(delete $delete, resync $resync, upload $upload) + { + $this->delete = $delete; + $this->resync = $resync; + $this->upload = $upload; + } - /** - * Wrapper method for deleting attachments - * - * @param string $mode can be: post|message|topic|attach|user - * @param mixed $ids can be: post_ids, message_ids, topic_ids, attach_ids, user_ids - * @param bool $resync set this to false if you are deleting posts or topics - * - * @return int|bool Number of deleted attachments or false if something - * went wrong during attachment deletion - */ - public function delete($mode, $id, $resync = true) - { - $this->delete->delete($mode, $id, $resync); - } + /** + * Wrapper method for deleting attachments + * + * @param string $mode can be: post|message|topic|attach|user + * @param mixed $ids can be: post_ids, message_ids, topic_ids, attach_ids, user_ids + * @param bool $resync set this to false if you are deleting posts or topics + * + * @return int|bool Number of deleted attachments or false if something + * went wrong during attachment deletion + */ + public function delete($mode, $id, $resync = true) + { + return $this->delete->delete($mode, $id, $resync); + } - /** - * Wrapper method for deleting attachments from filesystem - * - * @param string $filename Filename of attachment - * @param string $mode Delete mode - * @param bool $entry_removed Whether entry was removed. Defaults to false - * @return bool True if file was removed, false if not - */ - public function unlink($filename, $mode = 'file', $entry_removed = false) - { - $this->delete->unlink_attachment($filename, $mode, $entry_removed); - } + /** + * Wrapper method for deleting attachments from filesystem + * + * @param string $filename Filename of attachment + * @param string $mode Delete mode + * @param bool $entry_removed Whether entry was removed. Defaults to false + * @return bool True if file was removed, false if not + */ + public function unlink($filename, $mode = 'file', $entry_removed = false) + { + return $this->delete->unlink_attachment($filename, $mode, $entry_removed); + } - /** - * Wrapper method for resyncing specified type - * - * @param string $type Type of resync - * @param array $ids IDs to resync - */ - public function resync($type, $ids) - { - $this->resync->resync($type, $ids); - } + /** + * Wrapper method for resyncing specified type + * + * @param string $type Type of resync + * @param array $ids IDs to resync + */ + public function resync($type, $ids) + { + $this->resync->resync($type, $ids); + } - /** - * Wrapper method for uploading attachment - * - * @param string $form_name The form name of the file upload input - * @param int $forum_id The id of the forum - * @param bool $local Whether the file is local or not - * @param string $local_storage The path to the local file - * @param bool $is_message Whether it is a PM or not - * @param array $local_filedata An file data object created for the local file - * - * @return object filespec - */ - public function upload($form_name, $forum_id, $local = false, $local_storage = '', $is_message = false, $local_filedata = []) - { - $this->upload->upload($form_name, $forum_id, $local, $local_storage, $is_message, $local_filedata); - } + /** + * Wrapper method for uploading attachment + * + * @param string $form_name The form name of the file upload input + * @param int $forum_id The id of the forum + * @param bool $local Whether the file is local or not + * @param string $local_storage The path to the local file + * @param bool $is_message Whether it is a PM or not + * @param array $local_filedata An file data object created for the local file + * + * @return object filespec + */ + public function upload($form_name, $forum_id, $local = false, $local_storage = '', $is_message = false, $local_filedata = []) + { + return $this->upload->upload($form_name, $forum_id, $local, $local_storage, $is_message, $local_filedata); + } } -- cgit v1.2.1 From a0167ad41037d7fe9214ca36c4c7097177361a6b Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 9 Oct 2015 14:35:40 +0200 Subject: [ticket/14168] Fix docblock in manager PHPBB3-14168 --- phpBB/phpbb/attachment/manager.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/phpbb/attachment/manager.php') diff --git a/phpBB/phpbb/attachment/manager.php b/phpBB/phpbb/attachment/manager.php index 414a8edfdd..9dcd3c5c92 100644 --- a/phpBB/phpbb/attachment/manager.php +++ b/phpBB/phpbb/attachment/manager.php @@ -51,9 +51,9 @@ class manager * @return int|bool Number of deleted attachments or false if something * went wrong during attachment deletion */ - public function delete($mode, $id, $resync = true) + public function delete($mode, $ids, $resync = true) { - return $this->delete->delete($mode, $id, $resync); + return $this->delete->delete($mode, $ids, $resync); } /** -- cgit v1.2.1 From bb2634b5e5bdee53118eff8cdba3fea73932ff47 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 12 Oct 2015 12:11:26 +0200 Subject: [ticket/14168] Correctly state return type of upload and upload_attachment PHPBB3-14168 --- phpBB/phpbb/attachment/manager.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/attachment/manager.php') diff --git a/phpBB/phpbb/attachment/manager.php b/phpBB/phpbb/attachment/manager.php index 9dcd3c5c92..3c47171b2f 100644 --- a/phpBB/phpbb/attachment/manager.php +++ b/phpBB/phpbb/attachment/manager.php @@ -90,7 +90,7 @@ class manager * @param bool $is_message Whether it is a PM or not * @param array $local_filedata An file data object created for the local file * - * @return object filespec + * @return array File data array */ public function upload($form_name, $forum_id, $local = false, $local_storage = '', $is_message = false, $local_filedata = []) { -- cgit v1.2.1