diff options
| author | Nathan Guse <nathaniel.guse@gmail.com> | 2012-09-15 12:00:03 -0500 |
|---|---|---|
| committer | Nathan Guse <nathaniel.guse@gmail.com> | 2012-09-15 12:00:03 -0500 |
| commit | 9c54465a1331216be1e3369346921dee9148e590 (patch) | |
| tree | 2a24a84fa24c83f12f43717c494c3d86a0196412 /phpBB/includes/notifications | |
| parent | a1e2fb93add6cf6ff0c83879b347d1780411a335 (diff) | |
| download | forums-9c54465a1331216be1e3369346921dee9148e590.tar forums-9c54465a1331216be1e3369346921dee9148e590.tar.gz forums-9c54465a1331216be1e3369346921dee9148e590.tar.bz2 forums-9c54465a1331216be1e3369346921dee9148e590.tar.xz forums-9c54465a1331216be1e3369346921dee9148e590.zip | |
[ticket/11103] Starting approve_post type notification
PHPBB3-11103
Diffstat (limited to 'phpBB/includes/notifications')
| -rw-r--r-- | phpBB/includes/notifications/type/approve_post.php | 114 |
1 files changed, 114 insertions, 0 deletions
diff --git a/phpBB/includes/notifications/type/approve_post.php b/phpBB/includes/notifications/type/approve_post.php new file mode 100644 index 0000000000..9724916a0e --- /dev/null +++ b/phpBB/includes/notifications/type/approve_post.php @@ -0,0 +1,114 @@ +<?php +/** +* +* @package notifications +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* +*/ + +use Symfony\Component\DependencyInjection\ContainerBuilder; + +/** +* @ignore +*/ +if (!defined('IN_PHPBB')) +{ + exit; +} + +/** +* Post notifications class +* This class handles notifications for replies to a topic +* +* @package notifications +*/ +class phpbb_notifications_type_approve_post extends phpbb_notifications_type_post +{ + /** + * Email template to use to send notifications + * + * @var string + */ + public $email_template = 'post_approved'; + + /** + * Language key used to output the text + * + * @var string + */ + protected $language_key = 'NOTIFICATION_POST'; + + /** + * Get the type of notification this is + * phpbb_notifications_type_ + */ + public static function get_item_type() + { + return 'approve_post'; + } + + /** + * Find the users who want to receive notifications + * + * @param ContainerBuilder $phpbb_container + * @param array $post Data from + * + * @return array + */ + public static function find_users_for_notification(ContainerBuilder $phpbb_container, $post) + { + $users = array(); + + /* todo + * find what type of notification they'd like to receive + */ + $users[$post['poster_id']] = array(''); + + $auth_read = $phpbb_container->get('auth')->acl_get_list(array_keys($users), 'f_read', $post['forum_id']); + + if (empty($auth_read)) + { + return array(); + } + + $notify_users = array(); + + foreach ($auth_read[$post['forum_id']]['f_read'] as $user_id) + { + $notify_users[$user_id] = $users[$user_id]; + } + + return $notify_users; + } + + /** + * Get email template variables + * + * @return array + */ + public function get_email_template_variables() + { + return array( + 'POST_SUBJECT' => htmlspecialchars_decode(censor_text($this->get_data('post_subject'))), + + 'U_VIEW_POST' => generate_board_url() . "/viewtopic.{$this->php_ext}?p={$this->item_id}#p{$this->item_id}", + 'U_VIEW_TOPIC' => generate_board_url() . "/viewtopic.{$this->php_ext}?f={$this->get_data('forum_id')}&t={$this->item_parent_id}", + ); + } + + /** + * Function for preparing the data for insertion in an SQL query + * (The service handles insertion) + * + * @param array $post Data from submit_post + * + * @return array Array of data ready to be inserted into the database + */ + public function create_insert_array($post) + { + $this->set_data('post_subject', $post['post_subject']); + + return parent::create_insert_array($post); + } +} |
