public static function AddMessageToThread($caller, $userConnected, $currentDiscussion, $dataPost) { $manager = $caller->managers()->getManagerOf('DiscussionContent'); $discussion_person = \Applications\PMTool\Helpers\CommonHelper::FindObjectByIntValue(intval($userConnected->user_id()), 'user_id', $currentDiscussion[\Library\Enums\SessionKeys::DiscussionPeople]); $discussion_content = new \Applications\PMTool\Models\Dao\Discussion_content(); $discussion_content->setDiscussion_person_id($discussion_person->discussion_person_id()); $discussion_content->setDiscussion_content_message($dataPost['discussion_content_message']); $discussion_content_id = $manager->add($discussion_content); self::GetDiscussionThread($caller, $currentDiscussion); return $discussion_content_id; }
public function executeSendMessage(\Library\HttpRequest $rq) { $result = $this->InitResponseWS(); // Init result $currentSessionTask = \Applications\PMTool\Helpers\TaskHelper::GetCurrentSessionTask($this->user()); //Prepare data object $userConnected = \Applications\PMTool\Helpers\UserHelper::GetUserConnectedSession($this->user()); $currentDiscussion = \Applications\PMTool\Helpers\DiscussionHelper::GetCurrentDiscussion($this->user); if ($currentDiscussion) { $dataPost = $this->dataPost(); $discussion_content_id = \Applications\PMTool\Helpers\DiscussionHelper::AddMessageToThread($this, $userConnected, $currentDiscussion, $dataPost); //here goes mail sending... if ($discussion_content_id > 0) { $result['success'] = true; $discussion_content = new \Applications\PMTool\Models\Dao\Discussion_content(); $discussion_content->setDiscussion_content_id($discussion_content_id); $manager = $this->managers()->getManagerOf('DiscussionContent'); $discussion_content = $manager->selectMany($discussion_content, 'discussion_content_id'); $userTypeObject = $this->user->getAttribute(\Library\Enums\SessionKeys::UserTypeObject); if ($this->user->getUserType() == 'pm_id') { $discussion_content[0]->user_name = $userTypeObject->pm_name(); } else { if ($this->user->getUserType() == 'technician_id') { $discussion_content[0]->user_name = $userTypeObject->technician_name(); } else { if ($this->user->getUserType() == 'service_id') { $discussion_content[0]->user_name = $userTypeObject->service_name(); } } } $result['data'] = $discussion_content[0]; } else { $result['succes'] = false; } } else { $result['success'] = false; $result['data'] = ''; } $this->SendResponseWS($result, array("resx_file" => \Applications\PMTool\Resources\Enums\ResxFileNameKeys::ActiveTask, "resx_key" => $this->action(), "step" => $result['success'] ? "success" : "error")); }