[ Index ]

PHP Cross Reference of phpBB-3.3.14-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          return $this->get_authorised_recipients(array($post['poster_id']), $post['forum_id'], array_merge($options, array(
  82              'item_type'        => static::$notification_option['id'],
  83          )));
  84      }
  85  
  86      /**
  87      * Pre create insert array function
  88      * This allows you to perform certain actions, like run a query
  89      * and load data, before create_insert_array() is run. The data
  90      * returned from this function will be sent to create_insert_array().
  91      *
  92      * @param array $post Post data from submit_post
  93      * @param array $notify_users Notify users list
  94      *         Formatted from find_users_for_notification()
  95      * @return array Whatever you want to send to create_insert_array().
  96      */
  97  	public function pre_create_insert_array($post, $notify_users)
  98      {
  99          // In the parent class, this is used to check if the post is already
 100          // read by a user and marks the notification read if it was marked read.
 101          // Returning an empty array in effect, forces it to be marked as unread
 102          // (and also saves a query)
 103          return array();
 104      }
 105  
 106      /**
 107      * {@inheritdoc}
 108      */
 109  	public function create_insert_array($post, $pre_create_data = array())
 110      {
 111          $this->set_data('post_subject', $post['post_subject']);
 112  
 113          parent::create_insert_array($post, $pre_create_data);
 114  
 115          $this->notification_time = time();
 116      }
 117  
 118      /**
 119      * {@inheritdoc}
 120      */
 121  	public function get_insert_array()
 122      {
 123          $data = parent::get_insert_array();
 124          $data['notification_time'] = $this->notification_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  }


Generated: Mon Nov 25 19:05:08 2024 Cross-referenced by PHPXref 0.7.1