Example #1
0
 /**
  * Get all permissions.
  *
  * @return array
  */
 public function getAllPermissions()
 {
     $options = array();
     $collection = WorkflowModel::findAll();
     if ($collection) {
         foreach ($collection as $workflow) {
             $permissions = deserialize($workflow->permissions, true);
             foreach ($permissions as $permission) {
                 $workflow = $workflow->label ? $workflow->label . ' [' . $workflow->name . ']' : $workflow->name;
                 $name = $workflow->name . ':' . $permission['name'];
                 $options[$workflow][$name] = $permission['label'] ?: $permission['name'];
             }
         }
     }
     return $options;
 }
Example #2
0
 /**
  * Initialize role translations.
  *
  * @return void
  *
  * @SuppressWarnings(PHPMD.Superglobals)
  */
 private function initializePermissionTranslations()
 {
     $workflows = WorkflowModel::findAll();
     if (!$workflows) {
         return;
     }
     while ($workflows->next()) {
         $permissions = deserialize($workflows->permissions, true);
         foreach ($permissions as $permission) {
             $name = $workflows->name . ':' . $permission['name'];
             // only set if not already set. allow to customize permission labels by language files
             if (!isset($GLOBALS['TL_LANG']['workflow_permissions'][$name])) {
                 $GLOBALS['TL_LANG']['workflow_permissions'][$name] = $permission['label'] ?: $permission['name'];
             }
         }
         $GLOBALS['TL_LANG']['workflow_permissions'][$workflows->name . ':be_admin'] = $GLOBALS['TL_LANG']['workflow_permissions']['be_admin'];
         $GLOBALS['TL_LANG']['workflow_permissions'][$workflows->name . ':fe_guest'] = $GLOBALS['TL_LANG']['workflow_permissions']['fe_guest'];
     }
 }