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/element/propertyset/ |
<?php /** * Updates a property set * * @package modx * @subpackage processors.element.propertyset */ class modPropertySetUpdateProcessor extends modObjectUpdateProcessor { public $classKey = 'modPropertySet'; public $languageTopics = array('propertyset','category'); public $permission = 'save_propertyset'; public $objectType = 'propertyset'; public function beforeSet() { $name = $this->getProperty('name'); if ($this->alreadyExists($name)) { $this->addFieldError('name',$this->modx->lexicon('propertyset_err_ns_name')); } $name = $this->stripInvalidCharacters($name); $this->setProperty('name',$name); $category = $this->getProperty('category'); if (!empty($category)) { /** @var modCategory $category */ $category = $this->modx->getObject('modCategory',$category); if (empty($category)) { $this->addFieldError('category',$this->modx->lexicon('category_err_nf')); } } else { $this->setProperty('category',0); } return parent::beforeSet(); } public function stripInvalidCharacters($name) { $invalidCharacters = array('!','@','?','`','&','&'); $name = str_replace($invalidCharacters,'',$name); return $name; } public function alreadyExists($name) { return $this->modx->getCount($this->classKey,array( 'name' => $name, 'id:!=' => $this->getProperty('id'), )) > 0; } } return 'modPropertySetUpdateProcessor';