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/resourcegroup/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/palandch/www/core/model/modx/processors/security/resourcegroup/update.class.php
<?php
/**
 * Update a resource group
 *
 * @package modx
 * @subpackage processors.security.resourcegroup
 */
class modResourceGroupUpdateProcessor extends modProcessor {
    /** @var modResourceGroup $resourceGroup */
    public $resourceGroup;

    public function checkPermissions() {
        return $this->modx->hasPermission('resourcegroup_save');
    }
    public function getLanguageTopics() {
        return array('user','access');
    }

    public function initialize() {
        $id = $this->getProperty('id',false);
        if (empty($id)) return $this->modx->lexicon('resource_group_err_ns');
        $this->resourceGroup = $this->modx->getObject('modResourceGroup',$id);
        if (empty($this->resourceGroup)) return $this->modx->lexicon('resource_group_err_nf');
        return true;
    }

    public function process() {
        if (!$this->validate()) {
            return $this->failure();
        }
        
        $this->resourceGroup->fromArray($this->getProperties());
        if ($this->resourceGroup->save() == false) {
            return $this->failure($this->modx->lexicon('resource_group_err_save'));
        }
        
        $this->logManagerAction();
        return $this->success('',$this->resourceGroup);
    }

    /**
     * Validate the form
     * @return boolean
     */
    public function validate() {
        $name = $this->getProperty('name');
        if (empty($name)) $this->addFieldError('name',$this->modx->lexicon('resource_group_err_ns_name'));

        if ($this->alreadyExists($name)) {
            $this->addFieldError('name',$this->modx->lexicon('resource_group_err_ae'));
        }

        return !$this->hasErrors();
    }

    /**
     * Check if a Resource Group already exists with that name
     * @param string $name
     * @return boolean
     */
    public function alreadyExists($name) {
        return $this->modx->getCount('modResourceGroup',array(
            'name' => $name,
            'id:!=' => $this->resourceGroup->get('id'),
        )) > 0;
    }

    /**
     * Log the manager action
     * 
     * @return void
     */
    public function logManagerAction() {
        $this->modx->logManagerAction('update_resource_group','modResourceGroup',$this->resourceGroup->get('id'));
    }
}
return 'modResourceGroupUpdateProcessor';

Spamworldpro Mini