Merge pull request #395 from victorsl/BUG-4119
BUG 4119 "Need web service for updating user accounts" SOLVED
This commit is contained in:
@@ -1034,6 +1034,7 @@ function WSAssignUserToGroup($userId, $groupId)
|
||||
|
||||
return $fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* @method
|
||||
*
|
||||
@@ -1048,9 +1049,9 @@ function WSAssignUserToGroup($userId, $groupId)
|
||||
* @param string(32) | $firstname | Firstname of the new user | The first name(s) of the new user, which can be up to 50 characters long.
|
||||
* @param string(32) | $lastname | Lastname of the new user | The last name(s) of the new user, which can be up to 50 characters long.
|
||||
* @param string(32) | $email | Email the new user | The e-mail of the new user, which can be up to 100 characters long.
|
||||
* @param string(32) | $role | Rol of the new user | The role of the new user, such as 'PROCESSMAKER_ADMIN' and 'PROCESSMAKER_OPERATOR'.
|
||||
* @param string(32) | $dueDate=null | Expiration date | Optional parameter. The expiration date must be a string in the format 'yyyy-mm-dd'.
|
||||
* @param string(32) | $status=null | Status of the new user | Optional parameter. The user's status, such as 'ACTIVE', 'INACTIVE' or 'VACATION'.
|
||||
* @param string(32) | $role | Rol of the new user | The role of the new user, such as "PROCESSMAKER_ADMIN" and "PROCESSMAKER_OPERATOR".
|
||||
* @param string(32) | $dueDate=null | Expiration date | Optional parameter. The expiration date must be a string in the format "yyyy-mm-dd".
|
||||
* @param string(32) | $status=null | Status of the new user | Optional parameter. The user's status, such as "ACTIVE", "INACTIVE" or "VACATION".
|
||||
* @return array | $fields | WS array | A WS Response associative array.
|
||||
*
|
||||
*/
|
||||
@@ -1059,6 +1060,7 @@ function WSCreateUser($userId, $password, $firstname, $lastname, $email, $role,
|
||||
$client = WSOpen();
|
||||
|
||||
$sessionId = $_SESSION["WS_SESSION_ID"];
|
||||
|
||||
$params = array(
|
||||
"sessionId" => $sessionId,
|
||||
"userId" => $userId,
|
||||
@@ -1079,6 +1081,65 @@ function WSCreateUser($userId, $password, $firstname, $lastname, $email, $role,
|
||||
|
||||
return $fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* @method
|
||||
*
|
||||
* Update an user in ProcessMaker.
|
||||
*
|
||||
* @name WSUpdateUser
|
||||
* @label WS Update User
|
||||
* @link http://wiki.processmaker.com/index.php/ProcessMaker_Functions#WSUpdateUser.28.29
|
||||
*
|
||||
* @param string(32) | $userUid | User UID | The user UID.
|
||||
* @param string(32) | $userName | User ID | The username for the user.
|
||||
* @param string(32) | $firstName=null | Firstname of the user | Optional parameter. The first name of the user, which can be up to 50 characters long.
|
||||
* @param string(32) | $lastName=null | Lastname of the user | Optional parameter. The last name of the user, which can be up to 50 characters long.
|
||||
* @param string(32) | $email=null | Email the user | Optional parameter. The email of the user, which can be up to 100 characters long.
|
||||
* @param string(32) | $dueDate=null | Expiration date | Optional parameter. The expiration date must be a string in the format "yyyy-mm-dd".
|
||||
* @param string(32) | $status=null | Status of the user | Optional parameter. The user's status, such as "ACTIVE", "INACTIVE" or "VACATION".
|
||||
* @param string(32) | $role=null | Rol of the user | The role of the user such as "PROCESSMAKER_ADMIN" or "PROCESSMAKER_OPERATOR".
|
||||
* @param string(32) | $password=null | Password of the user | The password of the user, which can be up to 32 characters long.
|
||||
* @return array | $fields | WS array | A WS Response associative array.
|
||||
*
|
||||
*/
|
||||
function WSUpdateUser(
|
||||
$userUid,
|
||||
$userName,
|
||||
$firstName=null,
|
||||
$lastName=null,
|
||||
$email=null,
|
||||
$dueDate=null,
|
||||
$status=null,
|
||||
$role=null,
|
||||
$password=null
|
||||
) {
|
||||
$client = WSOpen();
|
||||
|
||||
$sessionId = $_SESSION["WS_SESSION_ID"];
|
||||
|
||||
$params = array(
|
||||
"sessionId" => $sessionId,
|
||||
"userUid" => $userUid,
|
||||
"userName" => $userName,
|
||||
"firstName" => $firstName,
|
||||
"lastName" => $lastName,
|
||||
"email" => $email,
|
||||
"dueDate" => $dueDate,
|
||||
"status" => $status,
|
||||
"role" => $role,
|
||||
"password" => $password
|
||||
);
|
||||
|
||||
$result = $client->__soapCall("updateUser", array($params));
|
||||
|
||||
$fields["status_code"] = $result->status_code;
|
||||
$fields["message"] = $result->message;
|
||||
$fields["time_stamp"] = $result->timestamp;
|
||||
|
||||
return $fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* @method
|
||||
*
|
||||
@@ -1679,6 +1740,7 @@ function PMFAssignUserToGroup($userId, $groupId)
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @method
|
||||
*
|
||||
@@ -1693,9 +1755,9 @@ function PMFAssignUserToGroup($userId, $groupId)
|
||||
* @param string(32) | $firstname | Firstname of the new user | The first name of the user, which can be up to 50 characters long.
|
||||
* @param string(32) | $lastname | Lastname of the new user | The last name of the user, which can be up to 50 characters long.
|
||||
* @param string(32) | $email | Email the new user | The email of the new user, which can be up to 100 characters long.
|
||||
* @param string(32) | $role | Rol of the new user | The role of the new user such as 'PROCESSMAKER_ADMIN' or 'PROCESSMAKER_OPERATOR'.
|
||||
* @param string(32) | $dueDate=null | Expiration date | Optional parameter. The expiration date must be a string in the format 'yyyy-mm-dd'.
|
||||
* @param string(32) | $status=null | Status of the new user | Optional parameter. The user's status, such as 'ACTIVE', 'INACTIVE' or 'VACATION'.
|
||||
* @param string(32) | $role | Rol of the new user | The role of the new user such as "PROCESSMAKER_ADMIN" or "PROCESSMAKER_OPERATOR".
|
||||
* @param string(32) | $dueDate=null | Expiration date | Optional parameter. The expiration date must be a string in the format "yyyy-mm-dd".
|
||||
* @param string(32) | $status=null | Status of the new user | Optional parameter. The user's status, such as "ACTIVE", "INACTIVE" or "VACATION".
|
||||
* @return int | $result | Result of the creation | Returns 1 if the new user was created successfully; otherwise, returns 0 if an error occurred.
|
||||
*
|
||||
*/
|
||||
@@ -1712,6 +1774,51 @@ function PMFCreateUser($userId, $password, $firstname, $lastname, $email, $role,
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @method
|
||||
*
|
||||
* Update a user with the given data.
|
||||
*
|
||||
* @name PMFUpdateUser
|
||||
* @label PMF Update User
|
||||
* @link http://wiki.processmaker.com/index.php/ProcessMaker_Functions#PMFUpdateUser.28.29
|
||||
*
|
||||
* @param string(32) | $userUid | User UID | The user UID.
|
||||
* @param string(32) | $userName | User ID | The username for the user.
|
||||
* @param string(32) | $firstName=null | Firstname of the user | Optional parameter. The first name of the user, which can be up to 50 characters long.
|
||||
* @param string(32) | $lastName=null | Lastname of the user | Optional parameter. The last name of the user, which can be up to 50 characters long.
|
||||
* @param string(32) | $email=null | Email the user | Optional parameter. The email of the user, which can be up to 100 characters long.
|
||||
* @param string(32) | $dueDate=null | Expiration date | Optional parameter. The expiration date must be a string in the format "yyyy-mm-dd".
|
||||
* @param string(32) | $status=null | Status of the user | Optional parameter. The user's status, such as "ACTIVE", "INACTIVE" or "VACATION".
|
||||
* @param string(32) | $role=null | Rol of the user | The role of the user such as "PROCESSMAKER_ADMIN" or "PROCESSMAKER_OPERATOR".
|
||||
* @param string(32) | $password=null | Password of the user | The password of the user, which can be up to 32 characters long.
|
||||
* @return int | $result | Result of the update | Returns 1 if the user is updated successfully; otherwise, returns 0 if an error occurred.
|
||||
*
|
||||
*/
|
||||
function PMFUpdateUser(
|
||||
$userUid,
|
||||
$userName,
|
||||
$firstName=null,
|
||||
$lastName=null,
|
||||
$email=null,
|
||||
$dueDate=null,
|
||||
$status=null,
|
||||
$role=null,
|
||||
$password=null
|
||||
) {
|
||||
G::LoadClass("wsBase");
|
||||
|
||||
$ws = new wsBase();
|
||||
$result = $ws->updateUser($userUid, $userName, $firstName, $lastName, $email, $dueDate, $status, $role, $password);
|
||||
|
||||
if ($result->status_code == 0) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @method
|
||||
*
|
||||
|
||||
@@ -921,92 +921,68 @@ class wsBase
|
||||
}
|
||||
|
||||
/**
|
||||
* creates a new user
|
||||
* Create an new user
|
||||
* @param string sessionId : The session ID.
|
||||
* @param string userId : The username for the new user.
|
||||
* @param string firstname : The user's first name.
|
||||
* @param string lastname : The user's last name.
|
||||
* @param string userName : The username for the new user.
|
||||
* @param string firstName : The user's first name.
|
||||
* @param string lastName : The user's last name.
|
||||
* @param string email : The user's email address.
|
||||
* @param string role : The user's role, such as 'PROCESSMAKER_ADMIN' or 'PROCESSMAKER_OPERATOR'.
|
||||
* @param string password : The user's password such as 'Be@gle2'(It will be automatically encrypted
|
||||
* @param string role : The user's role, such as "PROCESSMAKER_ADMIN" or "PROCESSMAKER_OPERATOR".
|
||||
* @param string password : The user's password such as "Be@gle2" (It will be automatically encrypted
|
||||
* with an MD5 hash).
|
||||
* @param string dueDate : Optional parameter. The expiration date must be a string in the format 'yyyy-mm-dd'.
|
||||
* @param string status : Optional parameter. The user's status, such as 'ACTIVE', 'INACTIVE' or 'VACATION'.
|
||||
* @param string dueDate : Optional parameter. The expiration date must be a string in the format "yyyy-mm-dd".
|
||||
* @param string status : Optional parameter. The user's status, such as "ACTIVE", "INACTIVE" or "VACATION".
|
||||
* @return $result will return an object
|
||||
*/
|
||||
public function createUser($userId, $firstname, $lastname, $email, $role, $password, $dueDate=null, $status=null)
|
||||
public function createUser($userName, $firstName, $lastName, $email, $role, $password, $dueDate=null, $status=null)
|
||||
{
|
||||
try {
|
||||
if ($userId == '') {
|
||||
$result = new wsCreateUserResponse(25, G::loadTranslation ('ID_USERNAME_REQUIRED'));
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
if ($password == '') {
|
||||
$result = new wsCreateUserResponse(26, G::loadTranslation ('ID_PASSWD_REQUIRED'));
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
if ($firstname == '') {
|
||||
$result = new wsCreateUserResponse(27, G::loadTranslation ('ID_MSG_ERROR_USR_FIRSTNAME'));
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
if (strlen($password) > 20) {
|
||||
$result = new wsCreateUserResponse(28, G::loadTranslation ('ID_PASSWORD_SURPRASES'), '');
|
||||
return $result;
|
||||
}
|
||||
|
||||
global $RBAC;
|
||||
|
||||
$RBAC->initRBAC();
|
||||
|
||||
$user = $RBAC->verifyUser($userId);
|
||||
if ($user == 1) {
|
||||
$data['USER_ID'] = $userId;
|
||||
$result = new wsCreateUserResponse(
|
||||
7,
|
||||
G::loadTranslation('ID_USERNAME_ALREADY_EXISTS', SYS_LANG, $data),
|
||||
''
|
||||
if (empty($userName)) {
|
||||
$result = new wsCreateUserResponse(25, G::loadTranslation("ID_USERNAME_REQUIRED"), null);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
if (empty($firstName)) {
|
||||
$result = new wsCreateUserResponse(27, G::loadTranslation("ID_MSG_ERROR_USR_FIRSTNAME"), null);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
if (empty($password)) {
|
||||
$result = new wsCreateUserResponse(26, G::loadTranslation("ID_PASSWD_REQUIRED"), null);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
$mktimeDueDate = 0;
|
||||
|
||||
if (!empty($dueDate)) {
|
||||
if (!preg_match("/^(\d{4})-(\d{2})-(\d{2})$/", $dueDate, $arrayMatch)) {
|
||||
$result = new wsCreateUserResponse(-1, G::loadTranslation("ID_INVALID_DATA") . " $dueDate", null);
|
||||
|
||||
return $result;
|
||||
} else {
|
||||
$mktimeDueDate = mktime(
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
intval($arrayMatch[2]),
|
||||
intval($arrayMatch[3]),
|
||||
intval($arrayMatch[1])
|
||||
);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
$rol = $RBAC->loadById($role);
|
||||
|
||||
if (is_array($rol)) {
|
||||
$strRole = $rol['ROL_CODE'];
|
||||
} else {
|
||||
$very_rol = $RBAC->verifyByCode($role);
|
||||
|
||||
if ($very_rol == 0) {
|
||||
$data['ROLE'] = $role;
|
||||
$result = new wsResponse(6, G::loadTranslation('ID_INVALID_ROLE', SYS_LANG, $data));
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
$strRole = $role;
|
||||
}
|
||||
|
||||
if ($dueDate != null) {
|
||||
if (!preg_match("/^(\d{4})-(\d{2})-(\d{2})$/", $dueDate, $matches)) {
|
||||
$result = new wsCreateUserResponse(5, G::loadTranslation("ID_INVALID_DATA") . ", $dueDate");
|
||||
|
||||
return $result;
|
||||
} else {
|
||||
$mktimeDueDate = mktime(0, 0, 0, intval($matches[2]), intval($matches[3]), intval($matches[1]));
|
||||
}
|
||||
} else {
|
||||
$mktimeDueDate = mktime(0, 0, 0, date("m"), date("d"), date("Y") + 1);
|
||||
}
|
||||
|
||||
if ($status != null) {
|
||||
if (!empty($status)) {
|
||||
if ($status != "ACTIVE" && $status != "INACTIVE" && $status != "VACATION") {
|
||||
$result = new wsCreateUserResponse(5, G::loadTranslation("ID_INVALID_DATA") . ", $status");
|
||||
$result = new wsCreateUserResponse(-1, G::loadTranslation("ID_INVALID_DATA") . " $status", null);
|
||||
|
||||
return $result;
|
||||
}
|
||||
@@ -1014,51 +990,277 @@ class wsBase
|
||||
$status = "ACTIVE";
|
||||
}
|
||||
|
||||
$aData['USR_USERNAME'] = $userId;
|
||||
$aData['USR_PASSWORD'] = md5($password);
|
||||
$aData['USR_FIRSTNAME'] = $firstname;
|
||||
$aData['USR_LASTNAME'] = $lastname;
|
||||
$aData['USR_EMAIL'] = $email;
|
||||
$aData['USR_DUE_DATE'] = $mktimeDueDate;
|
||||
$aData['USR_CREATE_DATE'] = date('Y-m-d H:i:s');
|
||||
$aData['USR_UPDATE_DATE'] = date('Y-m-d H:i:s');
|
||||
$aData['USR_BIRTHDAY'] = date('Y-m-d');
|
||||
$aData['USR_AUTH_USER_DN'] = '';
|
||||
$aData['USR_STATUS'] = ($status == 'ACTIVE')? 1 : 0;
|
||||
$arrayRole = $RBAC->loadById($role);
|
||||
$strRole = null;
|
||||
|
||||
$sUserUID = $RBAC->createUser($aData, $strRole);
|
||||
if (is_array($arrayRole)) {
|
||||
$strRole = $arrayRole["ROL_CODE"];
|
||||
} else {
|
||||
$strRole = $role;
|
||||
|
||||
$aData['USR_STATUS'] = $status;
|
||||
$aData['USR_UID'] = $sUserUID;
|
||||
$aData['USR_PASSWORD'] = md5($sUserUID);
|
||||
$aData['USR_COUNTRY'] = '';
|
||||
$aData['USR_CITY'] = '';
|
||||
$aData['USR_LOCATION'] = '';
|
||||
$aData['USR_ADDRESS'] = '';
|
||||
$aData['USR_PHONE'] = '';
|
||||
$aData['USR_ZIP_CODE'] = '';
|
||||
$aData['USR_POSITION'] = '';
|
||||
//$aData['USR_RESUME']
|
||||
$aData['USR_ROLE'] = $strRole ;
|
||||
//$aData['USR_REPLACED_BY']
|
||||
if ($RBAC->verifyByCode($role) == 0) {
|
||||
$data = array();
|
||||
$data["ROLE"] = $role;
|
||||
|
||||
$oUser = new Users();
|
||||
$oUser->create($aData);
|
||||
$result = new wsCreateUserResponse(6, G::loadTranslation("ID_INVALID_ROLE", SYS_LANG, $data), null);
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
if (strlen($password) > 20) {
|
||||
$result = new wsCreateUserResponse(-1, G::loadTranslation("ID_PASSWORD_SURPRASES"), null);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
if ($RBAC->verifyUser($userName) == 1) {
|
||||
$data = array();
|
||||
$data["USER_ID"] = $userName;
|
||||
|
||||
$result = new wsCreateUserResponse(
|
||||
7,
|
||||
G::loadTranslation("ID_USERNAME_ALREADY_EXISTS", SYS_LANG, $data),
|
||||
null
|
||||
);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
//Set fields
|
||||
$arrayData = array();
|
||||
|
||||
$arrayData["USR_USERNAME"] = $userName;
|
||||
$arrayData["USR_PASSWORD"] = md5($password);
|
||||
$arrayData["USR_FIRSTNAME"] = $firstName;
|
||||
$arrayData["USR_LASTNAME"] = $lastName;
|
||||
$arrayData["USR_EMAIL"] = $email;
|
||||
$arrayData["USR_DUE_DATE"] = $mktimeDueDate;
|
||||
$arrayData["USR_CREATE_DATE"] = date("Y-m-d H:i:s");
|
||||
$arrayData["USR_UPDATE_DATE"] = date("Y-m-d H:i:s");
|
||||
$arrayData["USR_BIRTHDAY"] = date("Y-m-d");
|
||||
$arrayData["USR_AUTH_USER_DN"] = "";
|
||||
$arrayData["USR_STATUS"] = ($status == "ACTIVE")? 1 : 0;
|
||||
|
||||
$userUid = $RBAC->createUser($arrayData, $strRole);
|
||||
|
||||
$arrayData["USR_UID"] = $userUid;
|
||||
$arrayData["USR_STATUS"] = $status;
|
||||
//$arrayData["USR_PASSWORD"] = md5($userUid);
|
||||
$arrayData["USR_COUNTRY"] = "";
|
||||
$arrayData["USR_CITY"] = "";
|
||||
$arrayData["USR_LOCATION"] = "";
|
||||
$arrayData["USR_ADDRESS"] = "";
|
||||
$arrayData["USR_PHONE"] = "";
|
||||
$arrayData["USR_ZIP_CODE"] = "";
|
||||
$arrayData["USR_POSITION"] = "";
|
||||
//$arrayData["USR_RESUME"]
|
||||
$arrayData["USR_ROLE"] = $strRole ;
|
||||
//$arrayData["USR_REPLACED_BY"]
|
||||
|
||||
$user = new Users();
|
||||
$user->create($arrayData);
|
||||
|
||||
//Response
|
||||
$data = array();
|
||||
$data["FIRSTNAME"] = $firstName;
|
||||
$data["LASTNAME"] = $lastName;
|
||||
$data["USER_ID"] = $userName;
|
||||
|
||||
$res = new wsResponse(0, G::loadTranslation("ID_USER_CREATED_SUCCESSFULLY", SYS_LANG, $data));
|
||||
|
||||
$data['FIRSTNAME'] = $firstname;
|
||||
$data['LASTNAME'] = $lastname;
|
||||
$data['USER_ID'] = $userId;
|
||||
$res = new wsResponse(0, G::loadTranslation('ID_USER_CREATED_SUCCESSFULLY', SYS_LANG, $data));
|
||||
$result = array(
|
||||
'status_code' => $res->status_code,
|
||||
'message' => $res->message,
|
||||
'userUID' => $sUserUID,
|
||||
'timestamp' => $res->timestamp
|
||||
"status_code" => $res->status_code,
|
||||
"message" => $res->message,
|
||||
"userUID" => $userUid,
|
||||
"timestamp" => $res->timestamp
|
||||
);
|
||||
|
||||
return $result;
|
||||
} catch (Exception $e) {
|
||||
$result = wsCreateUserResponse(100 , $e->getMessage(), '');
|
||||
$result = wsCreateUserResponse(100 , $e->getMessage(), null);
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update user
|
||||
* @param string userUid : The user UID.
|
||||
* @param string userName : The username for the user.
|
||||
* @param string firstName : Optional parameter. The user's first name.
|
||||
* @param string lastName : Optional parameter. The user's last name.
|
||||
* @param string email : Optional parameter. The user's email address.
|
||||
* @param string dueDate : Optional parameter. The expiration date must be a string in the format "yyyy-mm-dd".
|
||||
* @param string status : Optional parameter. The user's status, such as "ACTIVE", "INACTIVE" or "VACATION".
|
||||
* @param string role : Optional parameter. The user's role, such
|
||||
* as "PROCESSMAKER_ADMIN" or "PROCESSMAKER_OPERATOR".
|
||||
* @param string password : Optional parameter. The user's password such as "Be@gle2" (It will be automatically
|
||||
* encrypted with an MD5 hash).
|
||||
* @return $result will return an object
|
||||
*/
|
||||
public function updateUser(
|
||||
$userUid,
|
||||
$userName,
|
||||
$firstName=null,
|
||||
$lastName=null,
|
||||
$email=null,
|
||||
$dueDate=null,
|
||||
$status=null,
|
||||
$role=null,
|
||||
$password=null
|
||||
) {
|
||||
try {
|
||||
global $RBAC;
|
||||
|
||||
$RBAC->initRBAC();
|
||||
|
||||
if (empty($userUid)) {
|
||||
$result = new wsResponse(25, G::LoadTranslation("ID_REQUIRED_FIELD") . " userUid");
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
if (empty($userName)) {
|
||||
$result = new wsResponse(25, G::LoadTranslation("ID_USERNAME_REQUIRED"));
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
if ($RBAC->verifyUserId($userUid) == 0) {
|
||||
$result = new wsResponse(3, G::loadTranslation("ID_USER_NOT_REGISTERED_SYSTEM"));
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
$mktimeDueDate = 0;
|
||||
|
||||
if (!empty($dueDate)) {
|
||||
if (!preg_match("/^(\d{4})-(\d{2})-(\d{2})$/", $dueDate, $arrayMatch)) {
|
||||
$result = new wsResponse(-1, G::LoadTranslation("ID_INVALID_DATA") . " $dueDate");
|
||||
|
||||
return $result;
|
||||
} else {
|
||||
$mktimeDueDate = mktime(
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
intval($arrayMatch[2]),
|
||||
intval($arrayMatch[3]),
|
||||
intval($arrayMatch[1])
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($status)) {
|
||||
if ($status != "ACTIVE" && $status != "INACTIVE" && $status != "VACATION") {
|
||||
$result = new wsResponse(-1, G::LoadTranslation("ID_INVALID_DATA") . " $status");
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
$strRole = null;
|
||||
|
||||
if (!empty($role)) {
|
||||
$arrayRole = $RBAC->loadById($role);
|
||||
|
||||
if (is_array($arrayRole)) {
|
||||
$strRole = $arrayRole["ROL_CODE"];
|
||||
} else {
|
||||
$strRole = $role;
|
||||
|
||||
if ($RBAC->verifyByCode($role) == 0) {
|
||||
$data = array();
|
||||
$data["ROLE"] = $role;
|
||||
|
||||
$result = new wsResponse(6, G::LoadTranslation("ID_INVALID_ROLE", SYS_LANG, $data));
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($password) && strlen($password) > 20) {
|
||||
$result = new wsResponse(-1, G::LoadTranslation("ID_PASSWORD_SURPRASES"));
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
$criteria = new Criteria();
|
||||
$criteria->addSelectColumn(UsersPeer::USR_UID);
|
||||
$criteria->add(UsersPeer::USR_USERNAME, $userName);
|
||||
$criteria->add(UsersPeer::USR_UID, $userUid, Criteria::NOT_EQUAL);
|
||||
$rs = UsersPeer::doSelectRS($criteria);
|
||||
|
||||
if ($rs->next()) {
|
||||
$data = array();
|
||||
$data["USER_ID"] = $userName;
|
||||
|
||||
$result = new wsResponse(7, G::LoadTranslation("ID_USERNAME_ALREADY_EXISTS", SYS_LANG, $data));
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
//Set fields
|
||||
$arrayData = array();
|
||||
|
||||
$arrayData["USR_UID"] = $userUid;
|
||||
$arrayData["USR_USERNAME"] = $userName;
|
||||
|
||||
if (!empty($firstName)) {
|
||||
$arrayData["USR_FIRSTNAME"] = $firstName;
|
||||
}
|
||||
|
||||
if (!empty($lastName)) {
|
||||
$arrayData["USR_LASTNAME"] = $lastName;
|
||||
}
|
||||
|
||||
if (!empty($email)) {
|
||||
$arrayData["USR_EMAIL"] = $email;
|
||||
}
|
||||
|
||||
if ($mktimeDueDate != 0) {
|
||||
$arrayData["USR_DUE_DATE"] = $mktimeDueDate;
|
||||
}
|
||||
|
||||
$arrayData["USR_UPDATE_DATE"] = date("Y-m-d H:i:s");
|
||||
|
||||
if (!empty($status)) {
|
||||
$arrayData["USR_STATUS"] = $status;
|
||||
}
|
||||
|
||||
if ($strRole != null) {
|
||||
$arrayData["USR_ROLE"] = $strRole;
|
||||
}
|
||||
|
||||
if (!empty($password)) {
|
||||
$arrayData["USR_PASSWORD"] = md5($password);
|
||||
}
|
||||
|
||||
//Update user
|
||||
if ($strRole != null) {
|
||||
$RBAC->updateUser($arrayData, $strRole);
|
||||
} else {
|
||||
$RBAC->updateUser($arrayData);
|
||||
}
|
||||
|
||||
$user = new Users();
|
||||
$user->update($arrayData);
|
||||
|
||||
//Response
|
||||
//$res = new wsResponse(0, G::LoadTranslation("ID_OBJECT_UPDATE"));
|
||||
$res = new wsResponse(0, G::LoadTranslation("ID_UPDATED_SUCCESSFULLY"));
|
||||
|
||||
$result = array(
|
||||
"status_code" => $res->status_code,
|
||||
"message" => $res->message,
|
||||
"timestamp" => $res->timestamp
|
||||
);
|
||||
|
||||
return $result;
|
||||
} catch (Exception $e) {
|
||||
$result = wsResponse(100, $e->getMessage());
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -198,6 +198,31 @@
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
<xs:element name="updateUserRequest">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="sessionId" type="xs:string"/>
|
||||
<xs:element name="userUid" type="xs:string"/>
|
||||
<xs:element name="userName" type="xs:string"/>
|
||||
<xs:element name="firstName" minOccurs="0" maxOccurs="unbounded" type="xs:string"/>
|
||||
<xs:element name="lastName" minOccurs="0" maxOccurs="unbounded" type="xs:string"/>
|
||||
<xs:element name="email" minOccurs="0" maxOccurs="unbounded" type="xs:string"/>
|
||||
<xs:element name="dueDate" minOccurs="0" maxOccurs="unbounded" type="xs:string"/>
|
||||
<xs:element name="status" minOccurs="0" maxOccurs="unbounded" type="xs:string"/>
|
||||
<xs:element name="role" minOccurs="0" maxOccurs="unbounded" type="xs:string"/>
|
||||
<xs:element name="password" minOccurs="0" maxOccurs="unbounded" type="xs:string"/>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
<xs:element name="updateUserResponse">
|
||||
<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:element name="createGroupRequest">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
@@ -761,6 +786,12 @@
|
||||
<message name="createUserResponse">
|
||||
<part name="parameters" element="xs0:createUserResponse"/>
|
||||
</message>
|
||||
<message name="updateUserRequest">
|
||||
<part name="parameters" element="xs0:updateUserRequest"/>
|
||||
</message>
|
||||
<message name="updateUserResponse">
|
||||
<part name="parameters" element="xs0:updateUserResponse"/>
|
||||
</message>
|
||||
<message name="createGroupRequest">
|
||||
<part name="parameters" element="xs0:createGroupRequest"/>
|
||||
</message>
|
||||
@@ -922,6 +953,10 @@
|
||||
<input message="xs0:createUserRequest"/>
|
||||
<output message="xs0:createUserResponse"/>
|
||||
</operation>
|
||||
<operation name="updateUser">
|
||||
<input message="xs0:updateUserRequest"/>
|
||||
<output message="xs0:updateUserResponse"/>
|
||||
</operation>
|
||||
<operation name="createGroup">
|
||||
<input message="xs0:createGroupRequest"/>
|
||||
<output message="xs0:createGroupResponse"/>
|
||||
@@ -1103,6 +1138,15 @@
|
||||
<soap12:body use="literal"/>
|
||||
</output>
|
||||
</operation>
|
||||
<operation name="updateUser">
|
||||
<soap12:operation soapAction="urn:updateUser" soapActionRequired="true" style="document"/>
|
||||
<input>
|
||||
<soap12:body use="literal"/>
|
||||
</input>
|
||||
<output>
|
||||
<soap12:body use="literal"/>
|
||||
</output>
|
||||
</operation>
|
||||
<operation name="createGroup">
|
||||
<soap12:operation soapAction="urn:createGroup" soapActionRequired="true" style="document"/>
|
||||
<input>
|
||||
|
||||
@@ -810,6 +810,37 @@ function CreateUser($params)
|
||||
return $res;
|
||||
}
|
||||
|
||||
function updateUser($params)
|
||||
{
|
||||
$result = isValidSession($params->sessionId);
|
||||
|
||||
if ($result->status_code != 0) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
if (ifPermission($params->sessionId, "PM_USERS") == 0) {
|
||||
$result = new wsResponse(2, "You do not have privileges");
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
$ws = new wsBase();
|
||||
|
||||
$result = $ws->updateUser(
|
||||
$params->userUid,
|
||||
$params->userName,
|
||||
((isset($params->firstName))? $params->firstName : null),
|
||||
((isset($params->lastName))? $params->lastName : null),
|
||||
((isset($params->email))? $params->email : null),
|
||||
((isset($params->dueDate))? $params->dueDate : null),
|
||||
((isset($params->status))? $params->status : null),
|
||||
((isset($params->role))? $params->role : null),
|
||||
((isset($params->password))? $params->password : null)
|
||||
);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
function CreateGroup($params)
|
||||
{
|
||||
$vsResult = isValidSession($params->sessionId);
|
||||
@@ -1062,6 +1093,7 @@ $server->addFunction("AssignUserToDepartment");
|
||||
$server->addFunction("CreateGroup");
|
||||
$server->addFunction("CreateDepartment");
|
||||
$server->addFunction("CreateUser");
|
||||
$server->addFunction("updateUser");
|
||||
$server->addFunction("getCaseInfo");
|
||||
$server->addFunction("TaskList");
|
||||
$server->addFunction("TaskCase");
|
||||
|
||||
Reference in New Issue
Block a user