BUG 7752 "No webservice to add notes" SOLVED
- New feature - Web Services for add case note - Added functions "PMFAddCaseNote, WSAddCaseNote" in "class.pmFunctions.php" - Added function "addCaseNote" in "class.wsBase.php" - Added functionality for applications using Web Services * Available from version 2.0.46
This commit is contained in:
@@ -1290,6 +1290,49 @@ function WSUnpauseCase ($caseUid, $delIndex, $userUid)
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @method Add case note.
|
||||
*
|
||||
* @name WSAddCaseNote
|
||||
* @label WS Add case note
|
||||
* @link http://wiki.processmaker.com/index.php/ProcessMaker_Functions#WSAddCaseNote.28.29
|
||||
*
|
||||
* @param string(32) | $caseUid | ID of the case | The unique ID of the case.
|
||||
* @param string(32) | $processUid | ID of the process | The unique ID of the process.
|
||||
* @param string(32) | $taskUid | ID of the task | The unique ID of the task.
|
||||
* @param string(32) | $userUid | ID user | The unique ID of the user who will add note case.
|
||||
* @param string | $note | Note of the case | Note of the case.
|
||||
* @param int | $sendMail = 1 | Send mail | Optional parameter. If set to 1, will send an email to all participants in the case.
|
||||
* @return array | $response | WS array | A WS Response associative array.
|
||||
*
|
||||
*/
|
||||
function WSAddCaseNote($caseUid, $processUid, $taskUid, $userUid, $note, $sendMail = 1)
|
||||
{
|
||||
$client = WSOpen();
|
||||
|
||||
$sessionId = $_SESSION["WS_SESSION_ID"];
|
||||
|
||||
$params = array(
|
||||
"sessionId" => $sessionId,
|
||||
"caseUid" => $caseUid,
|
||||
"processUid" => $processUid,
|
||||
"taskUid" => $taskUid,
|
||||
"userUid" => $userUid,
|
||||
"note" => $note,
|
||||
"sendMail" => $sendMail
|
||||
);
|
||||
|
||||
$result = $client->__soapCall("addCaseNote", array($params));
|
||||
|
||||
$response = array();
|
||||
$response["status_code"] = $result->status_code;
|
||||
$response["message"] = $result->message;
|
||||
$response["time_stamp"] = $result->timestamp;
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
@@ -2421,3 +2464,33 @@ function PMFUnpauseCase ($caseUid, $delIndex, $userUid)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @method Add case note.
|
||||
*
|
||||
* @name PMFAddCaseNote
|
||||
* @label PMF Add case note
|
||||
*
|
||||
* @param string(32) | $caseUid | ID of the case | The unique ID of the case.
|
||||
* @param string(32) | $processUid | ID of the process | The unique ID of the process.
|
||||
* @param string(32) | $taskUid | ID of the task | The unique ID of the task.
|
||||
* @param string(32) | $userUid | ID user | The unique ID of the user who will add note case.
|
||||
* @param string | $note | Note of the case | Note of the case.
|
||||
* @param int | $sendMail = 1 | Send mail | Optional parameter. If set to 1, will send an email to all participants in the case.
|
||||
* @return int | $result | Result of the add case note | Returns 1 if the note has been added to the case.; otherwise, returns 0 if an error occurred.
|
||||
*
|
||||
*/
|
||||
function PMFAddCaseNote($caseUid, $processUid, $taskUid, $userUid, $note, $sendMail = 1)
|
||||
{
|
||||
G::LoadClass("wsBase");
|
||||
|
||||
$ws = new wsBase();
|
||||
$result = $ws->addCaseNote($caseUid, $processUid, $taskUid, $userUid, $note, $sendMail);
|
||||
|
||||
if ($result->status_code == 0) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@ require_once ("classes/model/AppCacheView.php");
|
||||
require_once ("classes/model/AppDelegation.php");
|
||||
require_once ("classes/model/AppDocument.php");
|
||||
require_once ("classes/model/AppDelay.php");
|
||||
require_once ("classes/model/AppNotes.php");
|
||||
require_once ("classes/model/AppThread.php");
|
||||
require_once ("classes/model/Department.php");
|
||||
require_once ("classes/model/Dynaform.php");
|
||||
@@ -3026,5 +3027,75 @@ class wsBase
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add case note
|
||||
*
|
||||
* @param string caseUid : ID of the case.
|
||||
* @param string processUid : ID of the process.
|
||||
* @param string taskUid : ID of the task.
|
||||
* @param string userUid : The unique ID of the user who will add note case.
|
||||
* @param string note : Note of the case.
|
||||
* @param int sendMail : Optional parameter. If set to 1, will send an email to all participants in the case.
|
||||
* @return $result will return an object
|
||||
*/
|
||||
public function addCaseNote($caseUid, $processUid, $taskUid, $userUid, $note, $sendMail = 1)
|
||||
{
|
||||
try {
|
||||
if (empty($caseUid)) {
|
||||
$result = new wsResponse(100, G::LoadTranslation("ID_REQUIRED_FIELD") . " caseUid");
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
if (empty($processUid)) {
|
||||
$result = new wsResponse(100, G::LoadTranslation("ID_REQUIRED_FIELD") . " processUid");
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
if (empty($taskUid)) {
|
||||
$result = new wsResponse(100, G::LoadTranslation("ID_REQUIRED_FIELD") . " taskUid");
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
if (empty($userUid)) {
|
||||
$result = new wsResponse(100, G::LoadTranslation("ID_REQUIRED_FIELD") . " userUid");
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
if (empty($note)) {
|
||||
$result = new wsResponse(100, G::LoadTranslation("ID_REQUIRED_FIELD") . " note");
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
$case = new Cases();
|
||||
|
||||
$respView = $case->getAllObjectsFrom($processUid, $caseUid, $taskUid, $userUid, "VIEW");
|
||||
$respBlock = $case->getAllObjectsFrom($processUid, $caseUid, $taskUid, $userUid, "BLOCK");
|
||||
|
||||
if ($respView["CASES_NOTES"] == 0 && $respBlock["CASES_NOTES"] == 0) {
|
||||
$result = new wsResponse(100, G::LoadTranslation("ID_CASES_NOTES_NO_PERMISSIONS"));
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
//Add note case
|
||||
$appNote = new AppNotes();
|
||||
$response = $appNote->addCaseNote($caseUid, $userUid, $note, $sendMail);
|
||||
|
||||
//Response
|
||||
$result = new wsResponse(0, G::LoadTranslation("ID_COMMAND_EXECUTED_SUCCESSFULLY"));
|
||||
|
||||
return $result;
|
||||
} catch (Exception $e) {
|
||||
$result = new wsResponse(100, $e->getMessage());
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -235,5 +235,30 @@ class AppNotes extends BaseAppNotes
|
||||
throw $oException;
|
||||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
$noteRecipientsList[] = $key;
|
||||
}
|
||||
|
||||
$noteRecipients = implode(",", $noteRecipientsList);
|
||||
$note = stripslashes($note);
|
||||
|
||||
$this->sendNoteNotification($applicationUid, $userUid, $note, $noteRecipients);
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -73,6 +73,8 @@ class AppProxy extends HttpProxyController
|
||||
*/
|
||||
function postNote ($httpData)
|
||||
{
|
||||
require_once ("classes/model/AppNotes.php");
|
||||
|
||||
//extract(getExtJSParams());
|
||||
if (isset( $httpData->appUid ) && trim( $httpData->appUid ) != "") {
|
||||
$appUid = $httpData->appUid;
|
||||
@@ -85,43 +87,23 @@ class AppProxy extends HttpProxyController
|
||||
}
|
||||
|
||||
$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);
|
||||
|
||||
//Add note case
|
||||
$appNote = new AppNotes();
|
||||
$response = $appNote->addCaseNote($appUid, $usrUid, $noteContent, intval($httpData->swSendMail));
|
||||
|
||||
//Send the response to client
|
||||
@ini_set( 'implicit_flush', 1 );
|
||||
@ini_set("implicit_flush", 1);
|
||||
ob_start();
|
||||
echo G::json_encode( $result );
|
||||
echo G::json_encode($response);
|
||||
@ob_flush();
|
||||
@flush();
|
||||
@ob_end_flush();
|
||||
ob_implicit_flush(1);
|
||||
|
||||
//Send notification in background
|
||||
if (intval( $httpData->swSendMail ) == 1) {
|
||||
G::LoadClass( "case" );
|
||||
|
||||
$oCase = new Cases();
|
||||
|
||||
$p = $oCase->getUsersParticipatedInCase( $appUid );
|
||||
$noteRecipientsList = array ();
|
||||
|
||||
foreach ($p["array"] as $key => $userParticipated) {
|
||||
$noteRecipientsList[] = $key;
|
||||
}
|
||||
|
||||
$noteRecipients = implode( ",", $noteRecipientsList );
|
||||
$noteContent = stripslashes( $noteContent );
|
||||
|
||||
$appNotes->sendNoteNotification( $appUid, $usrUid, $noteContent, $noteRecipients );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -871,6 +871,28 @@
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
<xs:element name="addCaseNoteRequest">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="sessionId" type="xs:string"/>
|
||||
<xs:element name="caseUid" type="xs:string"/>
|
||||
<xs:element name="processUid" type="xs:string"/>
|
||||
<xs:element name="taskUid" type="xs:string"/>
|
||||
<xs:element name="userUid" type="xs:string"/>
|
||||
<xs:element name="note" type="xs:string"/>
|
||||
<xs:element name="sendMail" minOccurs="0" maxOccurs="unbounded" type="xs:integer"/>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
<xs:element name="addCaseNoteResponse">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="status_code" type="xs:integer"/>
|
||||
<xs:element name="message" type="xs:string"/>
|
||||
<xs:element name="timestamp" type="xs:string"/>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:schema>
|
||||
</types>
|
||||
|
||||
@@ -1099,6 +1121,12 @@
|
||||
<message name="unpauseCaseResponse">
|
||||
<part name="parameters" element="xs0:unpauseCaseResponse"/>
|
||||
</message>
|
||||
<message name="addCaseNoteRequest">
|
||||
<part name="parameters" element="xs0:addCaseNoteRequest"/>
|
||||
</message>
|
||||
<message name="addCaseNoteResponse">
|
||||
<part name="parameters" element="xs0:addCaseNoteResponse"/>
|
||||
</message>
|
||||
|
||||
<portType name="ProcessMakerServiceSoap">
|
||||
<operation name="login">
|
||||
@@ -1261,6 +1289,10 @@
|
||||
<input message="xs0:unpauseCaseRequest"/>
|
||||
<output message="xs0:unpauseCaseResponse"/>
|
||||
</operation>
|
||||
<operation name="addCaseNote">
|
||||
<input message="xs0:addCaseNoteRequest"/>
|
||||
<output message="xs0:addCaseNoteResponse"/>
|
||||
</operation>
|
||||
</portType>
|
||||
|
||||
<binding name="ProcessMakerServiceSoap" type="xs0:ProcessMakerServiceSoap">
|
||||
@@ -1625,6 +1657,15 @@
|
||||
<soap12:body use="literal"/>
|
||||
</output>
|
||||
</operation>
|
||||
<operation name="addCaseNote">
|
||||
<soap12:operation soapAction="urn:addCaseNote" soapActionRequired="true" style="document"/>
|
||||
<input>
|
||||
<soap12:body use="literal"/>
|
||||
</input>
|
||||
<output>
|
||||
<soap12:body use="literal"/>
|
||||
</output>
|
||||
</operation>
|
||||
</binding>
|
||||
|
||||
<service name="ProcessMakerService">
|
||||
|
||||
@@ -1190,6 +1190,33 @@ function unpauseCase ($params)
|
||||
return $result;
|
||||
}
|
||||
|
||||
function addCaseNote($params)
|
||||
{
|
||||
$result = isValidSession($params->sessionId);
|
||||
|
||||
if ($result->status_code != 0) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
if (ifPermission($params->sessionId, "PM_CASES") == 0) {
|
||||
$result = new wsResponse(2, "You do not have privileges");
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
$ws = new wsBase();
|
||||
$result = $ws->addCaseNote(
|
||||
$params->caseUid,
|
||||
$params->processUid,
|
||||
$params->taskUid,
|
||||
$params->userUid,
|
||||
$params->note,
|
||||
(isset($params->sendMail))? $params->sendMail : 1
|
||||
);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
$server = new SoapServer($wsdl);
|
||||
|
||||
$server->addFunction("Login");
|
||||
@@ -1233,5 +1260,6 @@ $server->addFunction("deleteCase");
|
||||
$server->addFunction("cancelCase");
|
||||
$server->addFunction("pauseCase");
|
||||
$server->addFunction("unpauseCase");
|
||||
$server->addFunction("addCaseNote");
|
||||
$server->handle();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user