Exemplo n.º 1
0
    /**
     * Register custom CSS/JS for the page
     *
     * @return void
     */
    public function loadCustomCssJs()
    {
        $html = $this->head['html'];
        parent::loadCustomCssJs();
        $this->head['html'] = $html;
        if (is_null($this->resourceArray['properties'])) {
            $this->resourceArray['properties'] = array();
        }
        $this->resourceArray['properties']['tickets'] = $this->resource->getProperties('tickets');
        $this->resourceArray['properties']['ratings'] = $this->resource->getProperties('ratings');
        $this->resourceArray['syncsite'] = 0;
        /** @var Tickets $Tickets */
        $Tickets = $this->modx->getService('Tickets');
        $Tickets->loadManagerFiles($this, array('config' => true, 'utils' => true, 'css' => true, 'section' => true));
        $this->addLastJavascript($Tickets->config['jsUrl'] . 'mgr/section/create.js');
        $ready = array('xtype' => 'tickets-page-section-create', 'record' => $this->resourceArray, 'publish_document' => (int) $this->canPublish, 'canSave' => (int) $this->canSave, 'show_tvs' => (int) (!empty($this->tvCounts)), 'mode' => 'create');
        $this->addHtml('
		<script type="text/javascript">
		// <![CDATA[
		MODx.config.publish_document = ' . (int) $this->canPublish . ';
		MODx.onDocFormRender = "' . $this->onDocFormRender . '";
		MODx.ctx = "' . $this->ctx . '";
		Ext.onReady(function() {
			MODx.load(' . $this->modx->toJSON($ready) . ');
		});
		// ]]>
		</script>');
    }
Exemplo n.º 2
0
 /**
  * @return mixed
  */
 public function afterSave()
 {
     if ($this->object->alias == 'empty') {
         $this->object->set('alias', $this->object->id);
         $this->object->save();
     }
     // Updating resourceMap before OnDocSaveForm event
     $results = $this->modx->cacheManager->generateContext($this->object->context_key);
     if (isset($results['resourceMap'])) {
         $this->modx->context->resourceMap = $results['resourceMap'];
     }
     if (isset($results['aliasMap'])) {
         $this->modx->context->aliasMap = $results['aliasMap'];
     }
     $this->handleProperties();
     return parent::afterSave();
 }
Exemplo n.º 3
0
 /**
  * @return bool|null|string
  */
 public function checkParentPermissions()
 {
     $parent = null;
     $parentId = intval($this->getProperty('parent'));
     if ($parentId > 0) {
         $sections = $this->getProperty('sections');
         if (!empty($sections) && !in_array($parentId, $sections)) {
             return $this->modx->lexicon('ticket_err_wrong_parent');
         }
         $this->parentResource = $this->modx->getObject('TicketsSection', $parentId);
         if ($this->parentResource) {
             if ($this->parentResource->get('class_key') != 'TicketsSection') {
                 return $this->modx->lexicon('ticket_err_wrong_parent');
             } elseif (!$this->parentResource->checkPolicy('section_add_children')) {
                 return $this->modx->lexicon('ticket_err_wrong_parent');
             }
         } else {
             return $this->modx->lexicon('resource_err_nfs', array('id' => $parentId));
         }
     } else {
         return $this->modx->lexicon('ticket_err_access_denied');
     }
     return true;
 }