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/resource/event/ |
<?php /** * Update a resource from the site schedule grid. * * @param json $data A JSON array of data to update with. * * @package modx * @subpackage processors.resource.event */ class modResourceEventUpdateFromGrid extends modProcessor { /** @var modResource $resource */ public $resource; public function checkPermissions() { return $this->modx->hasPermission('save_document'); } public function getLanguageTopics() { return array('resource'); } public function initialize() { $data = $this->getProperty('data'); if (empty($data)) return $this->modx->lexicon('resource_err_ns'); $data = $this->modx->fromJSON($data); if (empty($data) || empty($data['id'])) return $this->modx->lexicon('resource_err_ns'); $this->setProperties($data); $this->resource = $this->modx->getObject('modResource',$data['id']); if (empty($this->resource)) return $this->modx->lexicon('resource_err_nf'); return true; } public function process() { if (!$this->validate()) { return $this->failure(); } $this->resource->fromArray($this->getProperties()); if ($this->resource->save() === false) { return $this->failure($this->modx->lexicon('resource_err_save')); } return $this->success(); } public function validate() { $publishDate = $this->getProperty('pub_date'); if (empty($publishDate)) { $this->setProperty('pub_date',strftime('%Y-%m-%d',strtotime($publishDate))); } $unPublishDate = $this->getProperty('unpub_date'); if (empty($unPublishDate)) { $this->setProperty('unpub_date',strftime('%Y-%m-%d',strtotime($unPublishDate))); } return true; } } return 'modResourceEventUpdateFromGrid';