Verzeichnisstruktur phpBB-3.1.0
- Veröffentlicht
- 27.10.2014
So funktioniert es
|
Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück |
Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis. |
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
approve_post.php
001 <?php
002 /**
003 *
004 * This file is part of the phpBB Forum Software package.
005 *
006 * @copyright (c) phpBB Limited <https://www.phpbb.com>
007 * @license GNU General Public License, version 2 (GPL-2.0)
008 *
009 * For full copyright and license information, please see
010 * the docs/CREDITS.txt file.
011 *
012 */
013
014 namespace phpbb\notification\type;
015
016 /**
017 * Post approved notifications class
018 * This class handles notifications for posts when they are approved (to their authors)
019 */
020
021 class approve_post extends \phpbb\notification\type\post
022 {
023 /**
024 * Get notification type name
025 *
026 * @return string
027 */
028 public function get_type()
029 {
030 return 'notification.type.approve_post';
031 }
032
033 /**
034 * Language key used to output the text
035 *
036 * @var string
037 */
038 protected $language_key = 'NOTIFICATION_POST_APPROVED';
039
040 /**
041 * Inherit notification read status from post.
042 *
043 * @var bool
044 */
045 protected $inherit_read_status = false;
046
047 /**
048 * Notification option data (for outputting to the user)
049 *
050 * @var bool|array False if the service should use it's default data
051 * Array of data (including keys 'id', 'lang', and 'group')
052 */
053 public static $notification_option = array(
054 'id' => 'moderation_queue',
055 'lang' => 'NOTIFICATION_TYPE_MODERATION_QUEUE',
056 'group' => 'NOTIFICATION_GROUP_POSTING',
057 );
058
059 /**
060 * Is available
061 */
062 public function is_available()
063 {
064 return !$this->auth->acl_get('m_approve');
065 }
066
067 /**
068 * Find the users who want to receive notifications
069 *
070 * @param array $post Data from submit_post
071 * @param array $options Options for finding users for notification
072 *
073 * @return array
074 */
075 public function find_users_for_notification($post, $options = array())
076 {
077 $options = array_merge(array(
078 'ignore_users' => array(),
079 ), $options);
080
081 $users = array();
082 $users[$post['poster_id']] = array('');
083
084 return $this->get_authorised_recipients(array_keys($users), $post['forum_id'], array_merge($options, array(
085 'item_type' => self::$notification_option['id'],
086 )));
087 }
088
089 /**
090 * Pre create insert array function
091 * This allows you to perform certain actions, like run a query
092 * and load data, before create_insert_array() is run. The data
093 * returned from this function will be sent to create_insert_array().
094 *
095 * @param array $post Post data from submit_post
096 * @param array $notify_users Notify users list
097 * Formated from find_users_for_notification()
098 * @return array Whatever you want to send to create_insert_array().
099 */
100 public function pre_create_insert_array($post, $notify_users)
101 {
102 // In the parent class, this is used to check if the post is already
103 // read by a user and marks the notification read if it was marked read.
104 // Returning an empty array in effect, forces it to be marked as unread
105 // (and also saves a query)
106 return array();
107 }
108
109 /**
110 * Function for preparing the data for insertion in an SQL query
111 * (The service handles insertion)
112 *
113 * @param array $post Data from submit_post
114 * @param array $pre_create_data Data from pre_create_insert_array()
115 *
116 * @return array Array of data ready to be inserted into the database
117 */
118 public function create_insert_array($post, $pre_create_data = array())
119 {
120 $this->set_data('post_subject', $post['post_subject']);
121
122 $data = parent::create_insert_array($post, $pre_create_data);
123
124 $this->notification_time = $data['notification_time'] = time();
125
126 return $data;
127 }
128
129 /**
130 * Get email template
131 *
132 * @return string|bool
133 */
134 public function get_email_template()
135 {
136 return 'post_approved';
137 }
138
139 /**
140 * {inheritDoc}
141 */
142 public function get_redirect_url()
143 {
144 return $this->get_url();
145 }
146 }
147