Exemplo n.º 1
0
 /**
  * Saves the current activity.
  * @param  boolean $check_notify
  * @return string|bool ID of the new post or false
  */
 public function save($check_notify = false)
 {
     $isUpdate = !(empty($this->id) || $this->new_with_id);
     $this->data = $this->getDataArray();
     $this->data = $this->processDataWithHtmlPurifier($this->activity_type, $this->data);
     if ($this->activity_type == 'post' || $this->activity_type == 'attach') {
         if (!isset($this->data['object']) && !empty($this->parent_type)) {
             $parent = BeanFactory::retrieveBean($this->parent_type, $this->parent_id);
             if ($parent && !is_null($parent->id)) {
                 $this->data['object'] = ActivityQueueManager::getBeanAttributes($parent);
             } else {
                 $this->data['module'] = $this->parent_type;
             }
         }
         if (!$isUpdate) {
             $this->processEmbed();
         }
     }
     $this->data = $this->getDataString();
     $this->last_comment = $this->last_comment_bean->toJson();
     $return = parent::save($check_notify);
     if (($this->activity_type === 'post' || $this->activity_type === 'attach') && !$isUpdate) {
         $this->processPostSubscription();
         $this->processPostTags();
     }
     return $return;
 }