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);
}
Esempio n. 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);
 }