/**
     * Overrides xPDOObject::save to fire modX-specific events
     *
     * {@inheritDoc}
     */
    public function save($cacheFlag = null) {
        $isNew = $this->isNew();
        
        if ($this->xpdo instanceof modX) {
            $this->xpdo->invokeEvent('OnCategoryBeforeSave',array(
                'mode' => $isNew ? modSystemEvent::MODE_NEW : modSystemEvent::MODE_UPD,
                'category' => &$this,
                'cacheFlag' => $cacheFlag,
            ));
        }
        $saved = parent :: save($cacheFlag);

        /* if a new board */
        if ($saved && $isNew) {
            $this->buildClosure();
        }
        /* if parent changed on existing object, rebuild closure table */
        if (!$isNew && $this->_parentChanged) {
            $this->rebuildClosure();
        }

        if ($saved && $this->xpdo instanceof modX) {
            $this->xpdo->invokeEvent('OnCategorySave',array(
                'mode' => $isNew ? modSystemEvent::MODE_NEW : modSystemEvent::MODE_UPD,
                'category' => &$this,
                'cacheFlag' => $cacheFlag,
            ));
        }

        return $saved;
    }
 /**
  * Overrides xPDOObject::save to cache the actionMap.
  *
  * {@inheritdoc}
  */
 public function save($cacheFlag = null)
 {
     $saved = parent::save($cacheFlag);
     if ($saved && empty($this->xpdo->config[xPDO::OPT_SETUP])) {
         $this->rebuildCache();
     }
     return $saved;
 }
 /**
  * Overrides xPDOObject::save to fire modX-specific events.
  *
  * {@inheritDoc}
  */
 public function save($cacheFlag = null)
 {
     $isNew = $this->isNew();
     if ($this->xpdo instanceof modX) {
         $this->xpdo->invokeEvent('OnResourceGroupBeforeSave', array('mode' => $isNew ? modSystemEvent::MODE_NEW : modSystemEvent::MODE_UPD, 'resourceGroup' => &$this, 'cacheFlag' => $cacheFlag));
     }
     $saved = parent::save($cacheFlag);
     /* invoke post-save events */
     if ($saved && $this->xpdo instanceof modX) {
         $this->xpdo->invokeEvent('OnResourceGroupSave', array('mode' => $isNew ? modSystemEvent::MODE_NEW : modSystemEvent::MODE_UPD, 'resourceGroup' => &$this, 'cacheFlag' => $cacheFlag));
     }
     return $saved;
 }
 public function save($cacheFlag = null)
 {
     $this->tag = trim($this->tag);
     if (!$this->tag) {
         $this->xpdo->log(xPDO::LOG_LEVEL_ERROR, "[- " . __CLASS__ . " -]. Column tag can not be empty");
         return false;
     }
     if (!$this->Topic) {
         $this->xpdo->log(xPDO::LOG_LEVEL_WARN, "[- " . __CLASS__ . " -]. Topic required");
         return false;
     }
     return parent::save($cacheFlag);
 }
 /**
  * Overridden to handle changes to content managed in an external file.
  *
  * {@inheritdoc}
  */
 public function save($cacheFlag = null)
 {
     if (!$this->getOption(xPDO::OPT_SETUP)) {
         if ($this->staticSourceChanged()) {
             $staticContent = $this->getFileContent();
             if ($staticContent !== $this->get('content')) {
                 if ($this->isStaticSourceMutable() && $staticContent === '') {
                     $this->setDirty('content');
                 } else {
                     $this->setContent($staticContent);
                 }
             }
             unset($staticContent);
         }
         $staticContentChanged = $this->staticContentChanged();
         if ($staticContentChanged && !$this->isStaticSourceMutable()) {
             $this->setContent($this->getFileContent());
             $staticContentChanged = false;
         }
     }
     $saved = parent::save($cacheFlag);
     if (!$this->getOption(xPDO::OPT_SETUP)) {
         if ($saved && $staticContentChanged) {
             $saved = $this->setFileContent($this->get('content'));
         }
     }
     return $saved;
 }
 /**
  * Persist new or changed modResource instances to the database container.
  *
  * {@inheritdoc}
  *
  * If the modResource is new, the createdon and createdby fields will be set
  * using the current time and user authenticated in the context.
  *
  * If uri is empty or uri_overridden is not set and something has been changed which
  * might affect the Resource's uri, it is (re-)calculated using getAliasPath(). This
  * can be forced recursively by setting refreshURIs to true before calling save().
  */
 public function save($cacheFlag= null) {
     if ($this->isNew()) {
         if (!$this->get('createdon')) $this->set('createdon', time());
         if (!$this->get('createdby') && $this->xpdo instanceof modX) $this->set('createdby', $this->xpdo->getLoginUserID());
     }
     $refreshChildURIs = false;
     if ($this->xpdo instanceof modX && $this->xpdo->getOption('friendly_urls')) {
         $refreshChildURIs = ($this->get('refreshURIs') || $this->isDirty('alias') || $this->isDirty('parent') || $this->isDirty('context_key'));
         if ($this->get('uri') == '' || (!$this->get('uri_override') && ($this->isDirty('uri_override') || $this->isDirty('content_type') || $this->isDirty('isfolder') || $refreshChildURIs))) {
             $this->set('uri', $this->getAliasPath($this->get('alias')));
         }
     }
     $rt= parent :: save($cacheFlag);
     if ($rt && $refreshChildURIs) {
         $this->xpdo->call('modResource', 'refreshURIs', array(
             &$this->xpdo,
             $this->get('id'),
         ));
     }
     return $rt;
 }
 /**
  * Override xPDOObject::save to clear the sources cache on save
  *
  * @param boolean $cacheFlag
  * @return boolean
  */
 public function save($cacheFlag = null)
 {
     $saved = parent::save($cacheFlag);
     if ($saved) {
         $this->clearCache();
     }
     return $saved;
 }
 /**
  * Persist new or changed modResource instances to the database container.
  *
  * {@inheritdoc}
  *
  * If the modResource is new, the createdon and createdby fields will be set
  * using the current time and user authenticated in the context.
  */
 public function save($cacheFlag = null)
 {
     if ($this->_new) {
         if (!$this->get('createdon')) {
             $this->set('createdon', time());
         }
         if (!$this->get('createdby') && $this->xpdo instanceof modX) {
             $this->set('createdby', $this->xpdo->getLoginUserID());
         }
     }
     $rt = parent::save($cacheFlag);
     return $rt;
 }
 /**
  * Overridden to handle changes to content managed in an external file.
  *
  * {@inheritdoc}
  */
 public function save($cacheFlag = null)
 {
     $staticContentChange = $this->isStatic() && $this->isDirty('content');
     $saved = parent::save($cacheFlag);
     if ($saved && $staticContentChange) {
         $saved = $this->setFileContent($this->get('content'));
     }
     return $saved;
 }