function postNote($httpData)
{
    //extract(getExtJSParams());
    $appUid = isset($httpData->appUid) ? $httpData->appUid : '';
    $usrUid = isset($httpData->usrUid) ? $httpData->usrUid : '';
    require_once "classes/model/AppNotes.php";
    $appNotes = new AppNotes();
    $noteContent = addslashes($httpData->noteText);
    $result = $appNotes->postNewNote($appUid, $usrUid, $noteContent, false);
    //return true;
    //die();
    //send the response to client
    @ini_set('implicit_flush', 1);
    ob_start();
    //echo G::json_encode($result);
    @ob_flush();
    @flush();
    @ob_end_flush();
    ob_implicit_flush(1);
    //return true;
    //send notification in background
    $noteRecipientsList = array();
    G::LoadClass('case');
    $oCase = new Cases();
    $p = $oCase->getUsersParticipatedInCase($appUid);
    foreach ($p['array'] as $key => $userParticipated) {
        $noteRecipientsList[] = $key;
    }
    $noteRecipients = implode(",", $noteRecipientsList);
    $appNotes->sendNoteNotification($appUid, $usrUid, $noteContent, $noteRecipients);
}
Exemple #2
0
 /**
  * post Note Action
  * @param string $httpData->appUid (optional, if it is not passed try use $_SESSION['APPLICATION'])
  * @return array containg the case notes
  */
 function postNote($httpData)
 {
     //extract(getExtJSParams());
     if (isset($httpData->appUid) && trim($httpData->appUid) != "") {
         $appUid = $httpData->appUid;
     } else {
         $appUid = $_SESSION['APPLICATION'];
     }
     if (!isset($appUid)) {
         throw new Exception('Can\'t resolve the Apllication ID for this request.');
     }
     $usrUid = isset($_SESSION['USER_LOGGED']) ? $_SESSION['USER_LOGGED'] : "";
     require_once "classes/model/AppNotes.php";
     $appNotes = new AppNotes();
     $noteContent = addslashes($httpData->noteText);
     $result = $appNotes->postNewNote($appUid, $usrUid, $noteContent, false);
     // Disabling the controller response because we handle a special behavior
     $this->setSendResponse(false);
     //send the response to client
     @ini_set('implicit_flush', 1);
     ob_start();
     echo G::json_encode($result);
     @ob_flush();
     @flush();
     @ob_end_flush();
     ob_implicit_flush(1);
     //send notification in background
     $noteRecipientsList = array();
     G::LoadClass('case');
     $oCase = new Cases();
     $p = $oCase->getUsersParticipatedInCase($appUid);
     foreach ($p['array'] as $key => $userParticipated) {
         $noteRecipientsList[] = $key;
     }
     $noteRecipients = implode(",", $noteRecipientsList);
     $appNotes->sendNoteNotification($appUid, $usrUid, $noteContent, $noteRecipients);
 }
Exemple #3
0
 public function addCaseNote($applicationUid, $userUid, $note, $sendMail)
 {
     $response = $this->postNewNote($applicationUid, $userUid, $note, false);
     if ($sendMail == 1) {
         G::LoadClass("case");
         $case = new Cases();
         $p = $case->getUsersParticipatedInCase($applicationUid);
         $noteRecipientsList = array();
         foreach ($p["array"] as $key => $userParticipated) {
             if ($key != '') {
                 $noteRecipientsList[] = $key;
             }
         }
         $noteRecipients = implode(",", $noteRecipientsList);
         $note = stripslashes($note);
         $this->sendNoteNotification($applicationUid, $userUid, $note, $noteRecipients);
     }
     return $response;
 }
Exemple #4
0
 function postNewNote($appUid, $usrUid, $noteContent, $notify = true, $noteAvalibility = "PUBLIC", $noteRecipients = "", $noteType = "USER", $noteDate = "now")
 {
     $this->setAppUid($appUid);
     $this->setUsrUid($usrUid);
     $this->setNoteDate($noteDate);
     $this->setNoteContent($noteContent);
     $this->setNoteType($noteType);
     $this->setNoteAvailability($noteAvalibility);
     $this->setNoteOriginObj('');
     $this->setNoteAffectedObj1('');
     $this->setNoteAffectedObj2('');
     $this->setNoteRecipients($noteRecipients);
     if ($this->validate()) {
         // we save it, since we get no validation errors, or do whatever else you like.
         $res = $this->save();
         $msg = '';
     } else {
         // Something went wrong. We can now get the validationFailures and handle them.
         $msg = '';
         $validationFailuresArray = $this->getValidationFailures();
         foreach ($validationFailuresArray as $objValidationFailure) {
             $msg .= $objValidationFailure->getMessage() . "<br/>";
         }
         //return array ( 'codError' => -100, 'rowsAffected' => 0, 'message' => $msg );
     }
     if ($msg != "") {
         $response['success'] = 'failure';
         $response['message'] = $msg;
     } else {
         $response['success'] = 'success';
         $response['message'] = 'Saved...';
     }
     if ($notify) {
         if ($noteRecipients == "") {
             $noteRecipientsA = array();
             G::LoadClass('case');
             $oCase = new Cases();
             $p = $oCase->getUsersParticipatedInCase($appUid);
             foreach ($p['array'] as $key => $userParticipated) {
                 $noteRecipientsA[] = $key;
             }
             $noteRecipients = implode(",", $noteRecipientsA);
         }
         $this->sendNoteNotification($appUid, $usrUid, $noteContent, $noteRecipients);
     }
     return $response;
 }