BUG 8596 "Web Services needs a userInfo() function" SOLVED

- New feature
- Web Services for getting information of user
- Added functions "PMFInformationUser, WSInformationUser" in "class.pmFunctions.php"
- Added function "informationUser" in "class.wsBase.php"
- Added functionality for applications using Web Services
* Available from version 2.0.46
This commit is contained in:
Victor Saisa Lopez
2012-11-15 12:56:33 -04:00
parent 520baa83f2
commit ebd1a4747c
4 changed files with 237 additions and 62 deletions

View File

@@ -87,19 +87,13 @@ function getCurrentTime ()
* @label User Info
* @link http://wiki.processmaker.com/index.php/ProcessMaker_Functions#userInfo.28.29
*
* @param string(32) | $user_id | User ID | The user unique ID
* @return array | $userInfo | User Info | An associative array with Information
* @param string(32) | $userUid | User ID | The user unique ID
* @return array | $info | User Info | An associative array with Information
*
*/
function userInfo ($user_uid)
function userInfo($userUid)
{
try {
require_once 'classes/model/Users.php';
$oUser = new Users();
return $oUser->getAllInformation( $user_uid );
} catch (Exception $oException) {
throw $oException;
}
return PMFInformationUser($userUid);
}
/**
@@ -1107,6 +1101,40 @@ function WSUpdateUser ($userUid, $userName, $firstName = null, $lastName = null,
return $fields;
}
/**
*
* @method Retrieves information about a user with a given ID.
*
* @name WSInformationUser
* @label WS Information User
* @link http://wiki.processmaker.com/index.php/ProcessMaker_Functions#WSInformationUser.28.29
*
* @param string(32) | $userUid | User UID | The user UID.
* @return array | $response | WS array | A WS Response associative array.
*
*/
function WSInformationUser($userUid)
{
$client = WSOpen();
$sessionId = $_SESSION["WS_SESSION_ID"];
$params = array(
"sessionId" => $sessionId,
"userUid" => $userUid
);
$result = $client->__soapCall("informationUser", array($params));
$response = array();
$response["status_code"] = $result->status_code;
$response["message"] = $result->message;
$response["time_stamp"] = $result->timestamp;
$response["info"] = (isset($result->info))? $result->info : null;
return $response;
}
/**
*
* @method Returns the unique ID for the current active session.
@@ -1851,6 +1879,34 @@ function PMFUpdateUser ($userUid, $userName, $firstName = null, $lastName = null
}
}
/**
*
* @method Retrieves information about a user with a given ID.
*
* @name PMFInformationUser
* @label PMF Information User
* @link http://wiki.processmaker.com/index.php/ProcessMaker_Functions#PMFInformationUser.28.29
*
* @param string(32) | $userUid | User UID | The user UID.
* @return array | $info | Information of user | An associative array with Information.
*
*/
function PMFInformationUser($userUid)
{
G::LoadClass("wsBase");
$ws = new wsBase();
$result = $ws->informationUser($userUid);
$info = array();
if ($result->status_code == 0 && isset($result->info)) {
$info = $result->info;
}
return $info;
}
/**
*
* @method Creates a random string of letters and/or numbers of a specified length,which

View File

@@ -1217,7 +1217,41 @@ class wsBase
return $result;
} catch (Exception $e) {
$result = wsResponse( 100, $e->getMessage() );
$result = new wsResponse(100, $e->getMessage());
return $result;
}
}
/**
* Information User
* @param string userUid : The user UID.
* @return $result will return an object
*/
public function informationUser($userUid)
{
try {
if (empty($userUid)) {
$result = new wsResponse(100, G::LoadTranslation("ID_REQUIRED_FIELD") . " userUid");
return $result;
}
$user = new Users();
$userInfo = $user->getAllInformation($userUid);
//Response
$res = new wsResponse(0, G::LoadTranslation("ID_COMMAND_EXECUTED_SUCCESSFULLY"));
$result = new stdClass();
$result->status_code = $res->status_code;
$result->message = $res->message;
$result->timestamp = $res->timestamp;
$result->info = $userInfo;
return $result;
} catch (Exception $e) {
$result = new wsResponse(100, $e->getMessage());
return $result;
}
@@ -1648,7 +1682,7 @@ class wsBase
$this->originalValues['INDEX'] = $_SESSION['INDEX'];
unset( $_SESSION['INDEX'] );
}
if (isset( $_SESSION['USER_LOGGED'] )) {
$this->originalValues['USER_LOGGED'] = $_SESSION['USER_LOGGED'];
unset( $_SESSION['USER_LOGGED'] );
@@ -1664,7 +1698,7 @@ class wsBase
unset( $_SESSION['STEP_POSITION'] );
}
}
/**
* restore the Session variables with values of $originalValues array, if this is set.
*
@@ -1696,7 +1730,7 @@ class wsBase
$_SESSION['USR_USERNAME'] = $this->originalValues['USR_USERNAME'];
unset( $this->originalValues['USR_USERNAME']);
}
if (isset( $this->originalValues['USER_LOGGED'] )) {
$_SESSION['USER_LOGGED'] = $this->originalValues['USER_LOGGED'];
unset( $this->originalValues['USER_LOGGED']);
@@ -1720,9 +1754,9 @@ class wsBase
public function newCase ($processId, $userId, $taskId, $variables)
{
try {
$this->saveTemporarySessionVars();
$Fields = array ();
if (is_array( $variables ) && count( $variables ) > 0) {
@@ -1796,7 +1830,7 @@ class wsBase
$up_case = $oCase->updateCase( $caseId, $oldFields );
$this->restoreSessionVars();
$result = new wsResponse( 0, G::loadTranslation( 'ID_STARTED_SUCCESSFULLY' ) );
$result->caseId = $caseId;
$result->caseNumber = $caseNr;
@@ -2839,7 +2873,7 @@ class wsBase
return $result;
} catch (Exception $e) {
$result = wsResponse( 100, $e->getMessage() );
$result = new wsResponse(100, $e->getMessage());
return $result;
}
@@ -2885,7 +2919,7 @@ class wsBase
return $result;
} catch (Exception $e) {
$result = wsResponse( 100, $e->getMessage() );
$result = new wsResponse(100, $e->getMessage());
return $result;
}
@@ -2941,7 +2975,7 @@ class wsBase
return $result;
} catch (Exception $e) {
$result = wsResponse( 100, $e->getMessage() );
$result = new wsResponse(100, $e->getMessage());
return $result;
}
@@ -2987,7 +3021,7 @@ class wsBase
return $result;
} catch (Exception $e) {
$result = wsResponse( 100, $e->getMessage() );
$result = new wsResponse(100, $e->getMessage());
return $result;
}