Server : Apache System : Linux indy02.toastserver.com 3.10.0-962.3.2.lve1.5.85.el7.x86_64 #1 SMP Thu Apr 18 15:18:36 UTC 2024 x86_64 User : palandch ( 1163) PHP Version : 7.1.33 Disable Function : NONE Directory : /home/palandch/www/core/model/modx/processors/security/access/policy/template/ |
<?php /** * Import a policy template. * * @package modx * @subpackage processors.security.access.policy.template */ class modAccessPolicyTemplateImportProcessor extends modObjectImportProcessor { public $objectType = 'policy_template'; public $classKey = 'modAccessPolicyTemplate'; public $permission = 'policy_template_view'; public $languageTopics = array('policy'); public function beforeSave() { /** @var modAccessPolicyTemplate $template */ $this->object->set('description',(string)$this->xml->description); $this->object->set('lexicon',(string)$this->xml->lexicon); $this->setTemplateGroup(); $this->addPermissions(); return parent::beforeSave(); } public function setTemplateGroup() { /** @var modAccessPolicyTemplateGroup $templateGroup */ $templateGroup = $this->modx->getObject('modAccessPolicyTemplateGroup',array('name' => (string)$this->xml->template_group)); if ($templateGroup) { $this->object->set('template_group',$templateGroup->get('id')); } else { $this->object->set('template_group',1); } } public function addPermissions() { $permissions = array(); foreach ($this->xml->permissions->permission as $permissionXml) { /** @var modAccessPermission $permission */ $permission = $this->modx->newObject('modAccessPermission'); $permission->set('name',(string)$permissionXml->name); $permission->set('description',(string)$permissionXml->description); $permission->set('value',(string)$permissionXml->value); $permissions[] = $permission; } $this->object->addMany($permissions); } } return 'modAccessPolicyTemplateImportProcessor';