Spamworldpro Mini Shell
Spamworldpro


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/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/palandch/www/core/model/modx/processors/security/access/policy/create.class.php
<?php
/**
 * Create an access policy.
 *
 * @param string $name The name of the policy.
 * @param string $description (optional) A short description
 * @param integer $parent (optional) A parent policy
 * @param string $class
 * @param json $data The JSON-encoded policy data
 *
 * @package modx
 * @subpackage processors.security.access.policy
 */

class modAccessPolicyCreateProcessor extends modObjectCreateProcessor {
    public $classKey = 'modAccessPolicy';
    public $languageTopics = array('policy');
    public $permission = 'policy_new';
    public $objectType = 'policy';
    
    public function beforeSet() {
        $name = $this->getProperty('name');
        if (empty($name)) {
            $this->addFieldError('name',$this->modx->lexicon('policy_err_name_ns'));
        }

        if ($this->doesAlreadyExist(array('name' => $name))) {
            $this->addFieldError('name',$this->modx->lexicon('policy_err_ae',array('name' => $name)));
        }

        return parent::beforeSet();
    }

    public function beforeSave() {
        /** @var modAccessPolicyTemplate $template */
        $template = $this->modx->getObject('modAccessPolicyTemplate',$this->getProperty('template'));
        if (empty($template)) {
            return $this->addFieldError('template',$this->modx->lexicon('policy_template_err_nf'));
        } else {
            $permissions = $template->getMany('Permissions');
            $permList = array();
            /** @var modAccessPermission $permission */
            foreach ($permissions as $permission) {
                $permList[$permission->get('name')] = true;
            }
            $this->object->set('data',$permList);
        }
        return parent::beforeSave();
    }
}
return 'modAccessPolicyCreateProcessor';

Spamworldpro Mini