예제 #1
0
파일: message.php 프로젝트: neevan1e/Done
 function save()
 {
     $this->import_parameters();
     $this->load_library('htmlpurifier-4.5.0-lite/library/HTMLPurifier.auto');
     $config = HTMLPurifier_Config::createDefault();
     $purifier = new HTMLPurifier($config);
     $message = $purifier->purify(html_entity_decode($this->message));
     $this->set('message', $message);
     $reference_object = new $this->reference_object($this->reference_id);
     //if the message is being created for an object other than a project, then the project id will be retrieved from
     //the actual object
     //if the message is being posted on a project, then the project id is the messages reference_id
     if ($this->reference_object != 'project') {
         $project_id = isset($reference_object->project_id) ? $reference_object->project_id : false;
     } else {
         $project_id = $this->reference_id;
     }
     if ($project_id) {
         $this->set('project_id', $project_id);
     }
     if (isset($reference_object->client_id)) {
         $this->set('client_id', $reference_object->client_id);
     }
     $this->set('user_id', current_user()->id);
     //these two parameters shouldn't be set yet (they are set when we log activity which happens after the save),
     //but let's just make sure
     $this->unset_param('linked_object');
     $this->unset_param('linked_object_title');
     $result = parent::save();
     ActivityManager::message_created($this);
     return $result;
 }