[ Index ]

PHP Cross Reference of phpBB-3.1.12-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      public static $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']] = array('');
  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      * 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  }


Generated: Thu Jan 11 00:25:41 2018 Cross-referenced by PHPXref 0.7.1