Exemple #1
0
 /**
  * @return mixed
  */
 public function setFieldDefaults()
 {
     $set = parent::setFieldDefaults();
     // Ticket properties
     $properties = $this->modx->context->key == 'mgr' ? $this->getProperty('properties') : $this->parentResource->getProperties();
     $this->unsetProperty('properties');
     // Define introtext
     $introtext = $this->getProperty('introtext');
     if (empty($introtext)) {
         $introtext = $this->object->getIntroText($this->getProperty('content'), false);
     }
     if (empty($properties['disable_jevix'])) {
         $introtext = $this->object->Jevix($introtext);
     }
     $createdon = time();
     // Redefine main parameters if we are not in the manager
     if ($this->modx->context->key == 'mgr') {
         $template = $this->getProperty('template');
         $hidemenu = $this->getProperty('hidemenu');
         $show_in_tree = $this->getProperty('show_in_tree');
         $createdby = $this->getProperty('createdby');
         $published = $this->getProperty('published');
         $publishedon = $this->getProperty('publishedon', $createdon);
         $publishedby = $this->getProperty('publishedby', $createdby);
     } else {
         $template = $properties['template'];
         $hidemenu = $properties['hidemenu'];
         $show_in_tree = $properties['show_in_tree'];
         $createdby = $this->modx->user->id;
         $published = $this->_published;
         $publishedon = $this->_published ? $createdon : 0;
         $publishedby = $this->modx->user->id;
     }
     if (empty($template)) {
         $template = $this->modx->context->getOption('tickets.default_template', $this->modx->context->getOption('default_template'));
     }
     $tmp = array('disable_jevix' => !empty($properties['disable_jevix']), 'process_tags' => !empty($properties['process_tags']));
     if (empty($published)) {
         $tmp['was_published'] = false;
     } else {
         $this->_sendEmails = true;
     }
     // Set properties
     $this->setProperties(array('class_key' => 'Ticket', 'published' => $published, 'createdby' => $createdby, 'createdon' => $createdon, 'publishedby' => $publishedby, 'publishedon' => $publishedon, 'syncsite' => 0, 'template' => $template, 'introtext' => $introtext, 'hidemenu' => $hidemenu, 'show_in_tree' => $show_in_tree, 'properties' => array('tickets' => $tmp)));
     return $set;
 }