[ Index ]

PHP Cross Reference of phpBB-3.3.0-deutsch

title

Body

[close]

/phpbb/notification/type/ -> group_request.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  class group_request extends \phpbb\notification\type\base
  17  {
  18      /**
  19      * {@inheritdoc}
  20      */
  21  	public function get_type()
  22      {
  23          return 'notification.type.group_request';
  24      }
  25  
  26      /**
  27      * {@inheritdoc}
  28      */
  29      static public $notification_option = array(
  30          'lang'    => 'NOTIFICATION_TYPE_GROUP_REQUEST',
  31      );
  32  
  33      /** @var \phpbb\user_loader */
  34      protected $user_loader;
  35  
  36  	public function set_user_loader(\phpbb\user_loader $user_loader)
  37      {
  38          $this->user_loader = $user_loader;
  39      }
  40  
  41      /**
  42      * {@inheritdoc}
  43      */
  44  	public function is_available()
  45      {
  46          // Leader of any groups?
  47          $sql = 'SELECT group_id
  48              FROM ' . USER_GROUP_TABLE . '
  49              WHERE user_id = ' . (int) $this->user->data['user_id'] . '
  50                  AND group_leader = 1';
  51          $result = $this->db->sql_query_limit($sql, 1);
  52          $row = $this->db->sql_fetchrow($result);
  53          $this->db->sql_freeresult($result);
  54  
  55          return (!empty($row)) ? true : false;
  56      }
  57  
  58      /**
  59      * {@inheritdoc}
  60      */
  61  	static public function get_item_id($group)
  62      {
  63          return (int) $group['user_id'];
  64      }
  65  
  66      /**
  67      * {@inheritdoc}
  68      */
  69  	static public function get_item_parent_id($group)
  70      {
  71          // Group id is the parent
  72          return (int) $group['group_id'];
  73      }
  74  
  75      /**
  76      * {@inheritdoc}
  77      */
  78  	public function find_users_for_notification($group, $options = array())
  79      {
  80          $options = array_merge(array(
  81              'ignore_users'        => array(),
  82          ), $options);
  83  
  84          $sql = 'SELECT user_id
  85              FROM ' . USER_GROUP_TABLE . '
  86              WHERE group_leader = 1
  87                  AND group_id = ' . (int) $group['group_id'];
  88          $result = $this->db->sql_query($sql);
  89  
  90          $user_ids = array();
  91          while ($row = $this->db->sql_fetchrow($result))
  92          {
  93              $user_ids[] = (int) $row['user_id'];
  94          }
  95          $this->db->sql_freeresult($result);
  96  
  97          $this->user_loader->load_users($user_ids);
  98  
  99          return $this->check_user_notification_options($user_ids, $options);
 100      }
 101  
 102      /**
 103      * {@inheritdoc}
 104      */
 105  	public function get_avatar()
 106      {
 107          return $this->user_loader->get_avatar($this->item_id, false, true);
 108      }
 109  
 110      /**
 111      * {@inheritdoc}
 112      */
 113  	public function get_title()
 114      {
 115          $username = $this->user_loader->get_username($this->item_id, 'no_profile');
 116  
 117          return $this->language->lang('NOTIFICATION_GROUP_REQUEST', $username, $this->get_data('group_name'));
 118      }
 119  
 120      /**
 121      * {@inheritdoc}
 122      */
 123  	public function get_email_template()
 124      {
 125          return 'group_request';
 126      }
 127  
 128      /**
 129      * {@inheritdoc}
 130      */
 131  	public function get_email_template_variables()
 132      {
 133          $user_data = $this->user_loader->get_user($this->item_id);
 134  
 135          return array(
 136              'GROUP_NAME'                   => htmlspecialchars_decode($this->get_data('group_name')),
 137              'REQUEST_USERNAME'                => htmlspecialchars_decode($user_data['username']),
 138  
 139              'U_PENDING'                      => generate_board_url() . "/ucp.{$this->php_ext}?i=groups&mode=manage&action=list&g={$this->item_parent_id}",
 140              'U_GROUP'                    => generate_board_url() . "/memberlist.{$this->php_ext}?mode=group&g={$this->item_parent_id}",
 141          );
 142      }
 143  
 144      /**
 145      * {@inheritdoc}
 146      */
 147  	public function get_url()
 148      {
 149          return append_sid($this->phpbb_root_path . 'ucp.' . $this->php_ext, "i=groups&mode=manage&action=list&g={$this->item_parent_id}");
 150      }
 151  
 152      /**
 153      * {@inheritdoc}
 154      */
 155  	public function users_to_query()
 156      {
 157          return array($this->item_id);
 158      }
 159  
 160      /**
 161      * {@inheritdoc}
 162      */
 163  	public function create_insert_array($group, $pre_create_data = array())
 164      {
 165          $this->set_data('group_name', $group['group_name']);
 166  
 167          parent::create_insert_array($group, $pre_create_data);
 168      }
 169  }


Generated: Tue Apr 7 19:44:41 2020 Cross-referenced by PHPXref 0.7.1