Esempio n. 1
0
 /**
  * @return bool|null|string
  */
 public function beforeSet()
 {
     $this->_published = $this->getProperty('published', null);
     if ($this->_published && !$this->modx->hasPermission('ticket_publish')) {
         return $this->modx->lexicon('ticket_err_publish');
     }
     if ($this->object->createdby != $this->modx->user->id && !$this->modx->hasPermission('edit_document')) {
         return $this->modx->lexicon('ticket_err_wrong_user');
     }
     // Required fields
     $requiredFields = $this->getProperty('requiredFields', array('parent', 'pagetitle', 'content'));
     foreach ($requiredFields as $field) {
         $value = trim($this->getProperty($field));
         if (empty($value) && $this->modx->context->key != 'mgr') {
             $this->addFieldError($field, $this->modx->lexicon('field_required'));
         } else {
             $this->setProperty($field, $value);
         }
     }
     $content = $this->getProperty('content');
     $length = mb_strlen(strip_tags($content), $this->modx->getOption('modx_charset', null, 'UTF-8', true));
     $max = $this->modx->getOption('tickets.ticket_max_cut', null, 1000, true);
     if (empty($content) && $this->modx->context->key != 'mgr') {
         return $this->modx->lexicon('ticket_err_empty');
     } elseif ($this->modx->context->key != 'mgr' && !preg_match('#<cut\\b.*?>#', $content) && $length > $max) {
         return $this->modx->lexicon('ticket_err_cut', array('length' => $length, 'max_cut' => $max));
     }
     $set = parent::beforeSet();
     if ($this->hasErrors()) {
         return $this->modx->lexicon('ticket_err_form');
     }
     $this->setFieldDefault();
     return $set;
 }
Esempio n. 2
0
 public function beforeSet()
 {
     # $this->setDefaultProperties(array(
     #     "context_key"   => $this->object->context_key,
     #     "pagetitle"   => $this->object->pagetitle,
     #     "alias"   => $this->object->alias,
     # ));
     $this->setDefaultProperties($this->object->toArray());
     return parent::beforeSet();
 }
Esempio n. 3
0
 /**
  * @return array|string
  */
 public function beforeSet()
 {
     foreach (array('description', 'introtext', 'content') as $key) {
         if ($field = $this->getProperty($key, false)) {
             $field = base64_decode($field);
             $this->setProperty($key, $field);
         }
     }
     foreach (array('createdon', 'publishedon', 'pub_date', 'unpub_date') as $key) {
         if ($field = $this->getProperty($key, false)) {
             $this->setProperty($key, date('Y-m-d H:i:s', strtotime($field)));
         }
     }
     return parent::beforeSet();
 }
Esempio n. 4
0
 public function beforeSet()
 {
     $this->setProperty('clearCache', true);
     return parent::beforeSet();
 }
Esempio n. 5
0
 /** {inheritDoc} */
 public function beforeSet()
 {
     $this->setProperties(array('isfolder' => 1));
     return parent::beforeSet();
 }
Esempio n. 6
0
 /**
  * @return bool|string
  */
 public function beforeSet()
 {
     $this->setProperties(array('isfolder' => 1, 'hide_children_in_tree' => 0));
     $this->handleProperties();
     return parent::beforeSet();
 }