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