[ Index ]

PHP Cross Reference of phpBB-3.1.10-deutsch

title

Body

[close]

/phpbb/ -> permissions.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;
  15  
  16  class permissions
  17  {
  18      /**
  19      * Event dispatcher object
  20      * @var \phpbb\event\dispatcher_interface
  21      */
  22      protected $dispatcher;
  23  
  24      /**
  25      * User object
  26      * @var \phpbb\user
  27      */
  28      protected $user;
  29  
  30      /**
  31      * Constructor
  32      *
  33      * @param    \phpbb\event\dispatcher_interface    $phpbb_dispatcher    Event dispatcher
  34      * @param    \phpbb\user                $user                User Object
  35      */
  36  	public function __construct(\phpbb\event\dispatcher_interface $phpbb_dispatcher, \phpbb\user $user)
  37      {
  38          $this->dispatcher = $phpbb_dispatcher;
  39          $this->user = $user;
  40  
  41          $categories = $this->categories;
  42          $types = $this->types;
  43          $permissions = $this->permissions;
  44  
  45          /**
  46          * Allows to specify additional permission categories, types and permissions
  47          *
  48          * @event core.permissions
  49          * @var    array    types            Array with permission types (a_, u_, m_, etc.)
  50          * @var    array    categories        Array with permission categories (pm, post, settings, misc, etc.)
  51          * @var    array    permissions        Array with permissions. Each Permission has the following layout:
  52          *        '<type><permission>' => array(
  53          *            'lang'    => 'Language Key with a Short description', // Optional, if not set,
  54          *                        // the permissions identifier '<type><permission>' is used with
  55          *                        // all uppercase.
  56          *            'cat'    => 'Identifier of the category, the permission should be displayed in',
  57          *        ),
  58          *        Example:
  59          *        'u_viewprofile' => array(
  60          *            'lang'    => 'ACL_U_VIEWPROFILE',
  61          *            'cat'    => 'profile',
  62          *        ),
  63          * @since 3.1.0-a1
  64          */
  65          $vars = array('types', 'categories', 'permissions');
  66          extract($phpbb_dispatcher->trigger_event('core.permissions', compact($vars)));
  67  
  68          $this->categories = $categories;
  69          $this->types = $types;
  70          $this->permissions = $permissions;
  71      }
  72  
  73      /**
  74      * Returns an array with all the permission categories (pm, post, settings, misc, etc.)
  75      *
  76      * @return    array    Layout: cat-identifier => Language key
  77      */
  78  	public function get_categories()
  79      {
  80          return $this->categories;
  81      }
  82  
  83      /**
  84      * Returns the language string of a permission category
  85      *
  86      * @param    string    $category    Identifier of the category
  87      * @return    string        Language string
  88      */
  89  	public function get_category_lang($category)
  90      {
  91          return $this->user->lang($this->categories[$category]);
  92      }
  93  
  94      /**
  95      * Returns an array with all the permission types (a_, u_, m_, etc.)
  96      *
  97      * @return    array    Layout: type-identifier => Language key
  98      */
  99  	public function get_types()
 100      {
 101          return $this->types;
 102      }
 103  
 104      /**
 105      * Returns the language string of a permission type
 106      *
 107      * @param    string    $type    Identifier of the type
 108      * @param    mixed    $scope    Scope of the type (should be 'global', 'local' or false)
 109      * @return    string    Language string
 110      */
 111  	public function get_type_lang($type, $scope = false)
 112      {
 113          if ($scope && isset($this->types[$scope][$type]))
 114          {
 115              $lang_key = $this->types[$scope][$type];
 116          }
 117          else if (isset($this->types[$type]))
 118          {
 119              $lang_key = $this->types[$type];
 120          }
 121          else
 122          {
 123              $lang_key = 'ACL_TYPE_' . strtoupper(($scope) ? $scope . '_' . $type : $type);
 124          }
 125  
 126          return $this->user->lang($lang_key);
 127      }
 128  
 129      /**
 130      * Returns an array with all the permissions.
 131      * Each Permission has the following layout:
 132      *    '<type><permission>' => array(
 133      *        'lang'    => 'Language Key with a Short description', // Optional, if not set,
 134      *                    // the permissions identifier '<type><permission>' is used with
 135      *                    // all uppercase.
 136      *        'cat'    => 'Identifier of the category, the permission should be displayed in',
 137      *    ),
 138      *    Example:
 139      *    'u_viewprofile' => array(
 140      *        'lang'    => 'ACL_U_VIEWPROFILE',
 141      *        'cat'    => 'profile',
 142      *    ),
 143      *
 144      * @return    array
 145      */
 146  	public function get_permissions()
 147      {
 148          return $this->permissions;
 149      }
 150  
 151      /**
 152      * Returns the category of a permission
 153      *
 154      * @param    string    $permission    Identifier of the permission
 155      * @return    string        Returns the category identifier of the permission
 156      */
 157  	public function get_permission_category($permission)
 158      {
 159          return (isset($this->permissions[$permission]['cat'])) ? $this->permissions[$permission]['cat'] : 'misc';
 160      }
 161  
 162      /**
 163      * Checks if a category has been defined
 164      *
 165      * @param    string    $category    Identifier of the category
 166      * @return    bool    True if the category is defined, false otherwise
 167      */
 168  	public function category_defined($category)
 169      {
 170          return isset($this->categories[$category]);
 171      }
 172  
 173      /**
 174      * Checks if a permission has been defined
 175      *
 176      * @param    string    $permission    Identifier of the permission
 177      * @return    bool    True if the permission is defined, false otherwise
 178      */
 179  	public function permission_defined($permission)
 180      {
 181          return isset($this->permissions[$permission]);
 182      }
 183  
 184      /**
 185      * Returns the language string of a permission
 186      *
 187      * @param    string    $permission    Identifier of the permission
 188      * @return    string    Language string
 189      */
 190  	public function get_permission_lang($permission)
 191      {
 192          return (isset($this->permissions[$permission]['lang'])) ? $this->user->lang($this->permissions[$permission]['lang']) : $this->user->lang('ACL_' . strtoupper($permission));
 193      }
 194  
 195      protected $types = array(
 196          'u_'            => 'ACL_TYPE_U_',
 197          'a_'            => 'ACL_TYPE_A_',
 198          'm_'            => 'ACL_TYPE_M_',
 199          'f_'            => 'ACL_TYPE_F_',
 200          'global'        => array(
 201              'm_'            => 'ACL_TYPE_GLOBAL_M_',
 202          ),
 203      );
 204  
 205      protected $categories = array(
 206          'actions'        => 'ACL_CAT_ACTIONS',
 207          'content'        => 'ACL_CAT_CONTENT',
 208          'forums'        => 'ACL_CAT_FORUMS',
 209          'misc'            => 'ACL_CAT_MISC',
 210          'permissions'    => 'ACL_CAT_PERMISSIONS',
 211          'pm'            => 'ACL_CAT_PM',
 212          'polls'            => 'ACL_CAT_POLLS',
 213          'post'            => 'ACL_CAT_POST',
 214          'post_actions'    => 'ACL_CAT_POST_ACTIONS',
 215          'posting'        => 'ACL_CAT_POSTING',
 216          'profile'        => 'ACL_CAT_PROFILE',
 217          'settings'        => 'ACL_CAT_SETTINGS',
 218          'topic_actions'    => 'ACL_CAT_TOPIC_ACTIONS',
 219          'user_group'    => 'ACL_CAT_USER_GROUP',
 220      );
 221  
 222      protected $permissions = array(
 223          // User Permissions
 224          'u_viewprofile'    => array('lang' => 'ACL_U_VIEWPROFILE', 'cat' => 'profile'),
 225          'u_chgname'        => array('lang' => 'ACL_U_CHGNAME', 'cat' => 'profile'),
 226          'u_chgpasswd'    => array('lang' => 'ACL_U_CHGPASSWD', 'cat' => 'profile'),
 227          'u_chgemail'    => array('lang' => 'ACL_U_CHGEMAIL', 'cat' => 'profile'),
 228          'u_chgavatar'    => array('lang' => 'ACL_U_CHGAVATAR', 'cat' => 'profile'),
 229          'u_chggrp'        => array('lang' => 'ACL_U_CHGGRP', 'cat' => 'profile'),
 230          'u_chgprofileinfo'    => array('lang' => 'ACL_U_CHGPROFILEINFO', 'cat' => 'profile'),
 231  
 232          'u_attach'        => array('lang' => 'ACL_U_ATTACH', 'cat' => 'post'),
 233          'u_download'    => array('lang' => 'ACL_U_DOWNLOAD', 'cat' => 'post'),
 234          'u_savedrafts'    => array('lang' => 'ACL_U_SAVEDRAFTS', 'cat' => 'post'),
 235          'u_chgcensors'    => array('lang' => 'ACL_U_CHGCENSORS', 'cat' => 'post'),
 236          'u_sig'            => array('lang' => 'ACL_U_SIG', 'cat' => 'post'),
 237  
 238          'u_sendpm'        => array('lang' => 'ACL_U_SENDPM', 'cat' => 'pm'),
 239          'u_masspm'        => array('lang' => 'ACL_U_MASSPM', 'cat' => 'pm'),
 240          'u_masspm_group'=> array('lang' => 'ACL_U_MASSPM_GROUP', 'cat' => 'pm'),
 241          'u_readpm'        => array('lang' => 'ACL_U_READPM', 'cat' => 'pm'),
 242          'u_pm_edit'        => array('lang' => 'ACL_U_PM_EDIT', 'cat' => 'pm'),
 243          'u_pm_delete'    => array('lang' => 'ACL_U_PM_DELETE', 'cat' => 'pm'),
 244          'u_pm_forward'    => array('lang' => 'ACL_U_PM_FORWARD', 'cat' => 'pm'),
 245          'u_pm_emailpm'    => array('lang' => 'ACL_U_PM_EMAILPM', 'cat' => 'pm'),
 246          'u_pm_printpm'    => array('lang' => 'ACL_U_PM_PRINTPM', 'cat' => 'pm'),
 247          'u_pm_attach'    => array('lang' => 'ACL_U_PM_ATTACH', 'cat' => 'pm'),
 248          'u_pm_download'    => array('lang' => 'ACL_U_PM_DOWNLOAD', 'cat' => 'pm'),
 249          'u_pm_bbcode'    => array('lang' => 'ACL_U_PM_BBCODE', 'cat' => 'pm'),
 250          'u_pm_smilies'    => array('lang' => 'ACL_U_PM_SMILIES', 'cat' => 'pm'),
 251          'u_pm_img'        => array('lang' => 'ACL_U_PM_IMG', 'cat' => 'pm'),
 252          'u_pm_flash'    => array('lang' => 'ACL_U_PM_FLASH', 'cat' => 'pm'),
 253  
 254          'u_sendemail'    => array('lang' => 'ACL_U_SENDEMAIL', 'cat' => 'misc'),
 255          'u_sendim'        => array('lang' => 'ACL_U_SENDIM', 'cat' => 'misc'),
 256          'u_ignoreflood'    => array('lang' => 'ACL_U_IGNOREFLOOD', 'cat' => 'misc'),
 257          'u_hideonline'    => array('lang' => 'ACL_U_HIDEONLINE', 'cat' => 'misc'),
 258          'u_viewonline'    => array('lang' => 'ACL_U_VIEWONLINE', 'cat' => 'misc'),
 259          'u_search'        => array('lang' => 'ACL_U_SEARCH', 'cat' => 'misc'),
 260  
 261          // Forum Permissions
 262          'f_list'        => array('lang' => 'ACL_F_LIST', 'cat' => 'actions'),
 263          'f_read'        => array('lang' => 'ACL_F_READ', 'cat' => 'actions'),
 264          'f_search'        => array('lang' => 'ACL_F_SEARCH', 'cat' => 'actions'),
 265          'f_subscribe'    => array('lang' => 'ACL_F_SUBSCRIBE', 'cat' => 'actions'),
 266          'f_print'        => array('lang' => 'ACL_F_PRINT', 'cat' => 'actions'),
 267          'f_email'        => array('lang' => 'ACL_F_EMAIL', 'cat' => 'actions'),
 268          'f_bump'        => array('lang' => 'ACL_F_BUMP', 'cat' => 'actions'),
 269          'f_user_lock'    => array('lang' => 'ACL_F_USER_LOCK', 'cat' => 'actions'),
 270          'f_download'    => array('lang' => 'ACL_F_DOWNLOAD', 'cat' => 'actions'),
 271          'f_report'        => array('lang' => 'ACL_F_REPORT', 'cat' => 'actions'),
 272  
 273          'f_post'        => array('lang' => 'ACL_F_POST', 'cat' => 'post'),
 274          'f_sticky'        => array('lang' => 'ACL_F_STICKY', 'cat' => 'post'),
 275          'f_announce'    => array('lang' => 'ACL_F_ANNOUNCE', 'cat' => 'post'),
 276          'f_reply'        => array('lang' => 'ACL_F_REPLY', 'cat' => 'post'),
 277          'f_edit'        => array('lang' => 'ACL_F_EDIT', 'cat' => 'post'),
 278          'f_delete'        => array('lang' => 'ACL_F_DELETE', 'cat' => 'post'),
 279          'f_softdelete'    => array('lang' => 'ACL_F_SOFTDELETE', 'cat' => 'post'),
 280          'f_ignoreflood' => array('lang' => 'ACL_F_IGNOREFLOOD', 'cat' => 'post'),
 281          'f_postcount'    => array('lang' => 'ACL_F_POSTCOUNT', 'cat' => 'post'),
 282          'f_noapprove'    => array('lang' => 'ACL_F_NOAPPROVE', 'cat' => 'post'),
 283  
 284          'f_attach'        => array('lang' => 'ACL_F_ATTACH', 'cat' => 'content'),
 285          'f_icons'        => array('lang' => 'ACL_F_ICONS', 'cat' => 'content'),
 286          'f_bbcode'        => array('lang' => 'ACL_F_BBCODE', 'cat' => 'content'),
 287          'f_flash'        => array('lang' => 'ACL_F_FLASH', 'cat' => 'content'),
 288          'f_img'            => array('lang' => 'ACL_F_IMG', 'cat' => 'content'),
 289          'f_sigs'        => array('lang' => 'ACL_F_SIGS', 'cat' => 'content'),
 290          'f_smilies'        => array('lang' => 'ACL_F_SMILIES', 'cat' => 'content'),
 291  
 292          'f_poll'        => array('lang' => 'ACL_F_POLL', 'cat' => 'polls'),
 293          'f_vote'        => array('lang' => 'ACL_F_VOTE', 'cat' => 'polls'),
 294          'f_votechg'        => array('lang' => 'ACL_F_VOTECHG', 'cat' => 'polls'),
 295  
 296          // Moderator Permissions
 297          'm_edit'        => array('lang' => 'ACL_M_EDIT', 'cat' => 'post_actions'),
 298          'm_delete'        => array('lang' => 'ACL_M_DELETE', 'cat' => 'post_actions'),
 299          'm_approve'        => array('lang' => 'ACL_M_APPROVE', 'cat' => 'post_actions'),
 300          'm_report'        => array('lang' => 'ACL_M_REPORT', 'cat' => 'post_actions'),
 301          'm_chgposter'    => array('lang' => 'ACL_M_CHGPOSTER', 'cat' => 'post_actions'),
 302          'm_info'        => array('lang' => 'ACL_M_INFO', 'cat' => 'post_actions'),
 303          'm_softdelete'    => array('lang' => 'ACL_M_SOFTDELETE', 'cat' => 'post_actions'),
 304  
 305          'm_move'    => array('lang' => 'ACL_M_MOVE', 'cat' => 'topic_actions'),
 306          'm_lock'    => array('lang' => 'ACL_M_LOCK', 'cat' => 'topic_actions'),
 307          'm_split'    => array('lang' => 'ACL_M_SPLIT', 'cat' => 'topic_actions'),
 308          'm_merge'    => array('lang' => 'ACL_M_MERGE', 'cat' => 'topic_actions'),
 309  
 310          'm_warn'        => array('lang' => 'ACL_M_WARN', 'cat' => 'misc'),
 311          'm_pm_report'    => array('lang' => 'ACL_M_PM_REPORT', 'cat' => 'misc'),
 312          'm_ban'            => array('lang' => 'ACL_M_BAN', 'cat' => 'misc'),
 313  
 314          // Admin Permissions
 315          'a_board'        => array('lang' => 'ACL_A_BOARD', 'cat' => 'settings'),
 316          'a_server'        => array('lang' => 'ACL_A_SERVER', 'cat' => 'settings'),
 317          'a_jabber'        => array('lang' => 'ACL_A_JABBER', 'cat' => 'settings'),
 318          'a_phpinfo'        => array('lang' => 'ACL_A_PHPINFO', 'cat' => 'settings'),
 319  
 320          'a_forum'        => array('lang' => 'ACL_A_FORUM', 'cat' => 'forums'),
 321          'a_forumadd'    => array('lang' => 'ACL_A_FORUMADD', 'cat' => 'forums'),
 322          'a_forumdel'    => array('lang' => 'ACL_A_FORUMDEL', 'cat' => 'forums'),
 323          'a_prune'        => array('lang' => 'ACL_A_PRUNE', 'cat' => 'forums'),
 324  
 325          'a_icons'        => array('lang' => 'ACL_A_ICONS', 'cat' => 'posting'),
 326          'a_words'        => array('lang' => 'ACL_A_WORDS', 'cat' => 'posting'),
 327          'a_bbcode'        => array('lang' => 'ACL_A_BBCODE', 'cat' => 'posting'),
 328          'a_attach'        => array('lang' => 'ACL_A_ATTACH', 'cat' => 'posting'),
 329  
 330          'a_user'        => array('lang' => 'ACL_A_USER', 'cat' => 'user_group'),
 331          'a_userdel'        => array('lang' => 'ACL_A_USERDEL', 'cat' => 'user_group'),
 332          'a_group'        => array('lang' => 'ACL_A_GROUP', 'cat' => 'user_group'),
 333          'a_groupadd'    => array('lang' => 'ACL_A_GROUPADD', 'cat' => 'user_group'),
 334          'a_groupdel'    => array('lang' => 'ACL_A_GROUPDEL', 'cat' => 'user_group'),
 335          'a_ranks'        => array('lang' => 'ACL_A_RANKS', 'cat' => 'user_group'),
 336          'a_profile'        => array('lang' => 'ACL_A_PROFILE', 'cat' => 'user_group'),
 337          'a_names'        => array('lang' => 'ACL_A_NAMES', 'cat' => 'user_group'),
 338          'a_ban'            => array('lang' => 'ACL_A_BAN', 'cat' => 'user_group'),
 339  
 340          'a_viewauth'    => array('lang' => 'ACL_A_VIEWAUTH', 'cat' => 'permissions'),
 341          'a_authgroups'    => array('lang' => 'ACL_A_AUTHGROUPS', 'cat' => 'permissions'),
 342          'a_authusers'    => array('lang' => 'ACL_A_AUTHUSERS', 'cat' => 'permissions'),
 343          'a_fauth'        => array('lang' => 'ACL_A_FAUTH', 'cat' => 'permissions'),
 344          'a_mauth'        => array('lang' => 'ACL_A_MAUTH', 'cat' => 'permissions'),
 345          'a_aauth'        => array('lang' => 'ACL_A_AAUTH', 'cat' => 'permissions'),
 346          'a_uauth'        => array('lang' => 'ACL_A_UAUTH', 'cat' => 'permissions'),
 347          'a_roles'        => array('lang' => 'ACL_A_ROLES', 'cat' => 'permissions'),
 348          'a_switchperm'    => array('lang' => 'ACL_A_SWITCHPERM', 'cat' => 'permissions'),
 349  
 350          'a_styles'        => array('lang' => 'ACL_A_STYLES', 'cat' => 'misc'),
 351          'a_extensions'    => array('lang' => 'ACL_A_EXTENSIONS', 'cat' => 'misc'),
 352          'a_viewlogs'    => array('lang' => 'ACL_A_VIEWLOGS', 'cat' => 'misc'),
 353          'a_clearlogs'    => array('lang' => 'ACL_A_CLEARLOGS', 'cat' => 'misc'),
 354          'a_modules'        => array('lang' => 'ACL_A_MODULES', 'cat' => 'misc'),
 355          'a_language'    => array('lang' => 'ACL_A_LANGUAGE', 'cat' => 'misc'),
 356          'a_email'        => array('lang' => 'ACL_A_EMAIL', 'cat' => 'misc'),
 357          'a_bots'        => array('lang' => 'ACL_A_BOTS', 'cat' => 'misc'),
 358          'a_reasons'        => array('lang' => 'ACL_A_REASONS', 'cat' => 'misc'),
 359          'a_backup'        => array('lang' => 'ACL_A_BACKUP', 'cat' => 'misc'),
 360          'a_search'        => array('lang' => 'ACL_A_SEARCH', 'cat' => 'misc'),
 361      );
 362  }


Generated: Sun Feb 19 19:52:41 2017 Cross-referenced by PHPXref 0.7.1