[ Index ]

PHP Cross Reference of phpBB-3.2.8-deutsch

title

Body

[close]

/phpbb/notification/type/ -> approve_post.php (source)

   1  <?php
   2  /**
   3  *
   4  * This file is part of the phpBB Forum Software package.
   5  *
   6  * @copyright (c) phpBB Limited <https://www.phpbb.com>
   7  * @license GNU General Public License, version 2 (GPL-2.0)
   8  *
   9  * For full copyright and license information, please see
  10  * the docs/CREDITS.txt file.
  11  *
  12  */
  13  
  14  namespace phpbb\notification\type;
  15  
  16  /**
  17  * Post approved notifications class
  18  * This class handles notifications for posts when they are approved (to their authors)
  19  */
  20  
  21  class approve_post extends \phpbb\notification\type\post
  22  {
  23      /**
  24      * Get notification type name
  25      *
  26      * @return string
  27      */
  28  	public function get_type()
  29      {
  30          return 'notification.type.approve_post';
  31      }
  32  
  33      /**
  34      * Language key used to output the text
  35      *
  36      * @var string
  37      */
  38      protected $language_key = 'NOTIFICATION_POST_APPROVED';
  39  
  40      /**
  41      * Inherit notification read status from post.
  42      *
  43      * @var bool
  44      */
  45      protected $inherit_read_status = false;
  46  
  47      /**
  48      * Notification option data (for outputting to the user)
  49      *
  50      * @var bool|array False if the service should use it's default data
  51      *                     Array of data (including keys 'id', 'lang', and 'group')
  52      */
  53      static public $notification_option = array(
  54          'id'    => 'moderation_queue',
  55          'lang'    => 'NOTIFICATION_TYPE_MODERATION_QUEUE',
  56          'group'    => 'NOTIFICATION_GROUP_POSTING',
  57      );
  58  
  59      /**
  60      * Is available
  61      */
  62  	public function is_available()
  63      {
  64          return !$this->auth->acl_get('m_approve');
  65      }
  66  
  67      /**
  68      * Find the users who want to receive notifications
  69      *
  70      * @param array $post Data from submit_post
  71      * @param array $options Options for finding users for notification
  72      *
  73      * @return array
  74      */
  75  	public function find_users_for_notification($post, $options = array())
  76      {
  77          $options = array_merge(array(
  78              'ignore_users'        => array(),
  79          ), $options);
  80  
  81          $users = array();
  82          $users[$post['poster_id']] = $this->notification_manager->get_default_methods();
  83  
  84          return $this->get_authorised_recipients(array_keys($users), $post['forum_id'], array_merge($options, array(
  85              'item_type'        => static::$notification_option['id'],
  86          )));
  87      }
  88  
  89      /**
  90      * Pre create insert array function
  91      * This allows you to perform certain actions, like run a query
  92      * and load data, before create_insert_array() is run. The data
  93      * returned from this function will be sent to create_insert_array().
  94      *
  95      * @param array $post Post data from submit_post
  96      * @param array $notify_users Notify users list
  97      *         Formated from find_users_for_notification()
  98      * @return array Whatever you want to send to create_insert_array().
  99      */
 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      * {@inheritdoc}
 111      */
 112  	public function create_insert_array($post, $pre_create_data = array())
 113      {
 114          $this->set_data('post_subject', $post['post_subject']);
 115  
 116          parent::create_insert_array($post, $pre_create_data);
 117  
 118          $this->notification_time = time();
 119      }
 120  
 121      /**
 122      * {@inheritdoc}
 123      */
 124  	public function get_insert_array()
 125      {
 126          $data = parent::get_insert_array();
 127          $data['notification_time'] = $this->notification_time;
 128  
 129          return $data;
 130      }
 131  
 132      /**
 133      * Get email template
 134      *
 135      * @return string|bool
 136      */
 137  	public function get_email_template()
 138      {
 139          return 'post_approved';
 140      }
 141  
 142      /**
 143      * {inheritDoc}
 144      */
 145  	public function get_redirect_url()
 146      {
 147          return $this->get_url();
 148      }
 149  }


Generated: Sat Oct 26 11:28:42 2019 Cross-referenced by PHPXref 0.7.1