Example #1
0
 /**
  * After Saving of comments, fire an activity
  *
  * @return type
  */
 protected function afterSave()
 {
     // flush the cache
     $this->flushCache();
     $activity = Activity::CreateForContent($this);
     $activity->type = "CommentCreated";
     $activity->module = "comment";
     $activity->save();
     $activity->fire();
     // Send Notifications
     NewCommentNotification::fire($this);
     AlsoCommentedNotification::fire($this);
     return parent::afterSave();
 }
Example #2
0
 /**
  * Before Delete, remove LikeCount (Cache) of target object.
  * Remove activity
  */
 protected function beforeDelete()
 {
     Yii::app()->cache->delete('likes_' . $this->object_model . "_" . $this->object_id);
     // Delete Activity
     // Currently we need to delete this manually, because the activity object is NOT bound to the Like
     // Instead is it bound to the Like Target (This should changed)
     $activity = Activity::model()->findByAttributes(array('type' => 'Interest', 'module' => 'like', 'object_model' => $this->object_model, 'object_id' => $this->object_id, 'created_by' => $this->created_by));
     if ($activity) {
         $activity->delete();
     }
     Notification::remove('Interest', $this->id);
     return parent::beforeDelete();
 }
Example #3
0
 /**
  * After Saving of comments, fire an activity
  *
  * @return type
  */
 protected function afterSave()
 {
     // flush the cache
     $this->flushCache();
     $activity = Activity::CreateForContent($this);
     $activity->type = "CommentCreated";
     $activity->module = "comment";
     $activity->save();
     $activity->fire();
     // Handle mentioned users
     // Execute before NewCommentNotification to avoid double notification when mentioned.
     UserMentioning::parse($this, $this->message);
     if ($this->isNewRecord) {
         // Send Notifications
         NewCommentNotification::fire($this);
     }
     return parent::afterSave();
 }
 /**
  * Before Delete, remove FavoritesCount (Cache) of target object.
  */
 protected function beforeDelete()
 {
     Yii::app()->cache->delete('favorites_' . $this->object_model . "_" . $this->object_id);
     return parent::beforeDelete();
 }
Example #5
0
 public function save($runValidation = true, $attributes = null)
 {
     if (!self::HasValidExtension($this->file_name)) {
         return false;
     }
     return parent::save($runValidation, $attributes);
 }