BUG 0000 Movig old notes proxy controller to appProxy.php

This commit is contained in:
Erik Amaru Ortiz
2011-09-21 12:48:55 -04:00
parent 412f887dec
commit c88e462b6f
3 changed files with 99 additions and 102 deletions

View File

@@ -8,6 +8,97 @@
class AppProxy extends HttpProxyController
{
/**
* Get Notes List
* @param int $httpData->start
* @param int $httpData->limit
* @param string $httpData->appUid (optionalif it is not passed try use $_SESSION['APPLICATION'])
* @return array containg the case notes
*/
function getNotesList($httpData)
{
require_once ( "classes/model/AppNotes.php" );
$appUid = null;
if (isset($httpData->appUid) && trim($httpData->appUid) != "") {
$appUid = $httpData->appUid;
}
else {
if (isset($_SESSION['APPLICATION'])) {
$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'] : "";
$appNotes = new AppNotes();
$response = $appNotes->getNotesList($appUid, $usrUid, $httpData->start, $httpData->limit);
return $response['array'];
}
/**
* 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);
}
/**
* request to open the case summary
* @param string $httpData->appUid
* @param string $httpData->delIndex
* @return object bool $result->succes, string $result->message(is an exception was thrown), string $result->dynUid
*/
function requestOpenSummary($httpData)
{
global $RBAC;
@@ -42,6 +133,12 @@ class AppProxy extends HttpProxyController
$_SESSION['_processData'] = $processData;
}
/**
* get the case summary data
* @param string $httpData->appUid
* @param string $httpData->delIndex
* @return array containg the case summary data
*/
function getSummary($httpData)
{
$labels = array();

View File

@@ -1,100 +0,0 @@
<?php
/**
* Case HttpProxyController
*/
class caseProxy extends HttpProxyController
{
function sendJsonResultGeneric($response, $callback)
{
header("Content-Type: application/json");
$finalResponse = json_encode($response);
if ($callback != '') {
print $callback . "($finalResponse);";
} else {
print $finalResponse;
}
}
/**
* Get Notes List
* @param int $httpData->start
* @param int $httpData->limit
* @param string $httpData->appUid (optionalif it is not passed try use $_SESSION['APPLICATION'])
* @return array containg the case notes
*/
function getNotesList($httpData)
{
require_once ( "classes/model/AppNotes.php" );
$appUid = null;
if (isset($httpData->appUid) && trim($httpData->appUid) != "") {
$appUid = $httpData->appUid;
}
else {
if (isset($_SESSION['APPLICATION'])) {
$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'] : "";
$appNotes = new AppNotes();
$response = $appNotes->getNotesList($appUid, $usrUid, $httpData->start, $httpData->limit);
return $response['array'];
}
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);
}
}

View File

@@ -13,7 +13,7 @@ function openCaseNotesWindow(appUid,modalSw){
var loadSize=10;
var storeNotes = new Ext.data.JsonStore({
url : '../caseProxy/getNotesList?appUid='+appUid,
url : '../appProxy/getNotesList?appUid='+appUid,
root: 'notes',
totalProperty: 'totalCount',
fields: ['USR_USERNAME','USR_FIRSTNAME','USR_LASTNAME','USR_FULL_NAME','NOTE_DATE','NOTE_CONTENT'],
@@ -219,7 +219,7 @@ caseNotesWindow = new Ext.Window({
Ext.getCmp('caseNoteText').reset();
statusBarMessage( _('ID_CASES_NOTE_POSTING'), true);
Ext.Ajax.request({
url : '../caseProxy/postNote' ,
url : '../appProxy/postNote' ,
params : {
appUid:appUid,
noteText:noteText