/** * Custom logic code here for setting placeholders, etc * @param array $scriptProperties * @return mixed */ public function process(array $scriptProperties = array()) { if (empty($this->template)) { return $this->failure($this->modx->lexicon('policy_template_err_nf')); } $placeholders = array(); /* get permissions */ $this->templateArray = $this->template->toArray(); $c = $this->modx->newQuery('modAccessPermission'); $c->sortby('name', 'ASC'); $permissions = $this->template->getMany('Permissions', $c); /** @var modAccessPermission $permission */ foreach ($permissions as $permission) { $desc = $permission->get('description'); if (!empty($this->templateArray['lexicon'])) { if (strpos($this->templateArray['lexicon'], ':') !== false) { $this->modx->lexicon->load($this->templateArray['lexicon']); } else { $this->modx->lexicon->load('core:' . $this->templateArray['lexicon']); } $desc = $this->modx->lexicon($desc); } $this->templateArray['permissions'][] = array($permission->get('name'), $permission->get('description'), $desc, $permission->get('value')); } $placeholders['template'] = $this->templateArray; return $placeholders; }
public function addTemplatePermissions(modAccessPolicyTemplate $template) { $this->xml->startElement('permissions'); $permissions = $template->getMany('Permissions'); /** @var modAccessPermission $permission */ foreach ($permissions as $permission) { $this->xml->startElement('permission'); $this->xml->writeElement('name', $permission->get('name')); $this->xml->writeElement('description', $permission->get('description')); $this->xml->writeElement('value', $permission->get('value')); $this->xml->endElement(); } $this->xml->endElement(); }
public function logManagerAction(modAccessPolicyTemplate $template) { $this->modx->logManagerAction('remove_policy_template', 'modAccessPolicyTemplate', $template->get('id')); }