Пример #1
0
 /**
  * After find callback
  * Set user_role_id to the guest user_role_id after find (instead of during save or beforeSave)
  * because we don't want to force a user_role_id to be set.  We'd rather that null means it is
  * a menu available to, but not necessarily the one returned to everyone.
  * 
  * @return array
  */
 public function afterFind($results, $primary = false)
 {
     for ($i = 0; $i < count($results); $i++) {
         if ($results[$i][$this->alias]['user_role_id'] === null) {
             $results[$i][$this->alias]['user_role_id'] = __SYSTEM_GUESTS_USER_ROLE_ID;
         }
     }
     return parent::afterFind($results, $primary);
 }
Пример #2
0
 /**
  * Save all override
  */
 public function saveAll($data = null, $options = array())
 {
     $data = $this->_cleanData($data);
     $this->create();
     if (parent::saveAll($data, $options)) {
         return true;
     } else {
         throw new Exception(ZuhaInflector::invalidate($this->invalidFields()));
     }
 }
Пример #3
0
 /**
  * After save callback
  * 
  */
 public function afterSave($created)
 {
     // then write the js file here.
     if ($this->_jsFile($this->data['WebpageJs']['name'], $this->data['WebpageJs']['content'])) {
         // then write it to settings for easy retrieval by the default layout
         if ($this->_updateSettings()) {
             return true;
         } else {
             throw new Exception(__('webpages', 'Javascript settings update failed'));
         }
     } else {
         throw new Exception(__('webpages', 'Javascript file write failed'));
     }
     return parent::afterSave($created);
 }
Пример #4
0
 /**
  * After save callback
  * 
  */
 public function afterSave($created)
 {
     // then write the css file here.
     if ($this->_cssFile($this->data['WebpageCss']['name'], $this->data['WebpageCss']['content'])) {
         // then write it to settings for easy retrieval by the default layout
         if ($this->_updateSettings()) {
             return true;
         } else {
             throw new Exception(__('Css file save failed'));
         }
     } else {
         // roll back, there was a problem
         throw new Exception(__('Css file write failed.'));
     }
     return parent::afterSave($created);
 }
Пример #5
0
 /**
  * Save All
  * 
  * @param array $data
  * @param array $options
  * @return array
  */
 public function saveAll($data = null, $options = array())
 {
     $data = $this->cleanInputData($data);
     // this has to be here (don't try putting it in beforeValidate() and beforeSave() again)
     if (parent::saveAll($data, $options)) {
         return true;
     } else {
         throw new Exception(ZuhaInflector::invalidate($this->invalidFields()));
     }
 }