Exemplo n.º 1
0
 /**
  * Before-save callback.
  *
  * @return boolean Returns false if parent beforeSave() returns false,
  * otherwise returns true.
  * @since 0.1.0
  */
 public function beforeSave()
 {
     if (!parent::beforeSave()) {
         return false;
     }
     if (!empty($this->newPassword)) {
         $this->password = sha1($this->newPassword);
     }
     return true;
 }
Exemplo n.º 2
0
 /**
  * Before-save callback, used to strip tags from content.
  *
  * @return boolean False if parent beforeSave() failed, true otherwise.
  * @since 0.1.0
  */
 public function beforeSave()
 {
     if (!parent::beforeSave()) {
         return false;
     }
     return true;
 }
Exemplo n.º 3
0
 /**
  * Simple wrapper around parent `setAndSave()` that invalidates cache on
  * save.
  *
  * @param array $attributes Attributes to be saved.
  *
  * @return bool True on success, false otherwise.
  * @since 0.1.0
  */
 public function setAndSave(array $attributes)
 {
     if (parent::setAndSave($attributes)) {
         \Yii::app()->cacheHelper->invalidatePostsCache();
         return true;
     }
     return false;
 }
Exemplo n.º 4
0
 /**
  * Returns all public attributes of post.
  *
  * @return array Public attributes.
  * @since 0.1.0
  */
 public function getPublicAttributes()
 {
     $attrs = parent::getPublicAttributes();
     $attrs['content'] = $this->rendered;
     if (isset($attrs['author'])) {
         unset($attrs['user_id']);
     }
     if (isset($attrs['category'])) {
         unset($attrs['category_id']);
     }
     return $attrs;
 }