Example #1
0
 /**
  * GetAddonPermissions
  * Gets permissions from enabled and active addons.
  * This is used by the main application to work out which permissions to show and which permissions are allowed to be used.
  * Only enabled addons are included in the new permissions.
  *
  * @param EventData_IEM_USERAPI_GETPERMISSIONTYPES $data The original addon permissions. This is passed in by reference as an object so just add the new permissions to the original data.
  *
  * @uses GetAvailableAddons
  * @uses RegisterAddonPermissions
  *
  * @return Void Returns nothing, the data is passed in by reference so new permissions are just added to it straight away.
  *
  * @uses EventData_IEM_USERAPI_GETPERMISSIONTYPES
  */
 static function GetAddonPermissions(EventData_IEM_USERAPI_GETPERMISSIONTYPES $data)
 {
     $self = new self();
     $addons = $self->GetAvailableAddons();
     foreach ($addons as $addon_id => $details) {
         if (!$details['enabled']) {
             continue;
         }
         require_once $self->addon_base_directory . $addon_id . '/' . $addon_id . '.php';
         /**
          * call the "RegisterMenuItems" static method in the subclasses
          * That adds an item to self::$menuItems for us to then use.
          */
         $class_name = 'Addons_' . $addon_id;
         if (method_exists($class_name, 'RegisterAddonPermissions')) {
             call_user_func(array($class_name, 'RegisterAddonPermissions'));
         }
     }
     unset($self);
     $data->extra_permissions = array_merge($data->extra_permissions, self::$userPermissions);
 }