BUG 9291 "Creating user via web services - no option to set..." SOLVED
- Creating user via web services, no option to set expiry date - Create user via web services, can now be set parameters: expiry date and status (in the functions: createUser, WSCreateUser and PMFCreateUser) - These changes in functions must be documented in the wiki.processmaker.com
This commit is contained in:
@@ -1040,21 +1040,27 @@ function WSAssignUserToGroup($userId, $groupId)
|
|||||||
* @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) | $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) | $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) | $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.
|
* @return array | $fields | WS array | A WS Response associative array.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function WSCreateUser($userId, $password, $firstname, $lastname, $email, $role)
|
function WSCreateUser($userId, $password, $firstname, $lastname, $email, $role, $dueDate=null, $status=null)
|
||||||
{
|
{
|
||||||
$client = WSOpen();
|
$client = WSOpen();
|
||||||
|
|
||||||
$sessionId = $_SESSION["WS_SESSION_ID"];
|
$sessionId = $_SESSION["WS_SESSION_ID"];
|
||||||
$params = array("sessionId" => $sessionId,
|
$params = array(
|
||||||
|
"sessionId" => $sessionId,
|
||||||
"userId" => $userId,
|
"userId" => $userId,
|
||||||
"firstname" => $firstname,
|
"firstname" => $firstname,
|
||||||
"lastname" => $lastname,
|
"lastname" => $lastname,
|
||||||
"email" => $email,
|
"email" => $email,
|
||||||
"role" => $role,
|
"role" => $role,
|
||||||
"password" => $password);
|
"password" => $password,
|
||||||
|
"dueDate" => $dueDate,
|
||||||
|
"status" => $status
|
||||||
|
);
|
||||||
|
|
||||||
$result = $client->__soapCall("CreateUser", array($params));
|
$result = $client->__soapCall("CreateUser", array($params));
|
||||||
|
|
||||||
@@ -1679,14 +1685,17 @@ function PMFAssignUserToGroup($userId, $groupId)
|
|||||||
* @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) | $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) | $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) | $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.
|
* @return int | $result | Result of the creation | Returns 1 if the new user was created successfully; otherwise, returns 0 if an error occurred.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function PMFCreateUser($userId, $password, $firstname, $lastname, $email, $role)
|
function PMFCreateUser($userId, $password, $firstname, $lastname, $email, $role, $dueDate=null, $status=null)
|
||||||
{
|
{
|
||||||
G::LoadClass('wsBase');
|
G::LoadClass('wsBase');
|
||||||
$ws = new wsBase ();
|
|
||||||
$result = $ws->createUser($userId, $firstname, $lastname, $email, $role, $password);
|
$ws = new wsBase();
|
||||||
|
$result = $ws->createUser($userId, $firstname, $lastname, $email, $role, $password, $dueDate, $status);
|
||||||
|
|
||||||
if ($result->status_code == 0) {
|
if ($result->status_code == 0) {
|
||||||
return 1;
|
return 1;
|
||||||
@@ -2094,4 +2103,3 @@ function PMFGetCaseNotes ($applicationID, $type='array', $userUid='')
|
|||||||
$response = Cases::getCaseNotes($applicationID, $type, $userUid);
|
$response = Cases::getCaseNotes($applicationID, $type, $userUid);
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -922,7 +922,7 @@ class wsBase
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* creates a new user
|
* creates a new user
|
||||||
* @param string sessionId : The session ID
|
* @param string sessionId : The session ID.
|
||||||
* @param string userId : The username for the new user.
|
* @param string userId : The username for the new user.
|
||||||
* @param string firstname : The user's first name.
|
* @param string firstname : The user's first name.
|
||||||
* @param string lastname : The user's last name.
|
* @param string lastname : The user's last name.
|
||||||
@@ -930,9 +930,11 @@ class wsBase
|
|||||||
* @param string role : The user's role, such as 'PROCESSMAKER_ADMIN' or 'PROCESSMAKER_OPERATOR'.
|
* @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 password : The user's password such as 'Be@gle2'(It will be automatically encrypted
|
||||||
* with an MD5 hash).
|
* 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'.
|
||||||
* @return $result will return an object
|
* @return $result will return an object
|
||||||
*/
|
*/
|
||||||
public function createUser($userId, $firstname, $lastname, $email, $role, $password)
|
public function createUser($userId, $firstname, $lastname, $email, $role, $password, $dueDate=null, $status=null)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
if ($userId == '') {
|
if ($userId == '') {
|
||||||
@@ -990,21 +992,45 @@ class wsBase
|
|||||||
$strRole = $role;
|
$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 ($status != "ACTIVE" && $status != "INACTIVE" && $status != "VACATION") {
|
||||||
|
$result = new wsCreateUserResponse(5, G::loadTranslation("ID_INVALID_DATA") . ", $status");
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$status = "ACTIVE";
|
||||||
|
}
|
||||||
|
|
||||||
$aData['USR_USERNAME'] = $userId;
|
$aData['USR_USERNAME'] = $userId;
|
||||||
$aData['USR_PASSWORD'] = md5($password);
|
$aData['USR_PASSWORD'] = md5($password);
|
||||||
$aData['USR_FIRSTNAME'] = $firstname;
|
$aData['USR_FIRSTNAME'] = $firstname;
|
||||||
$aData['USR_LASTNAME'] = $lastname;
|
$aData['USR_LASTNAME'] = $lastname;
|
||||||
$aData['USR_EMAIL'] = $email;
|
$aData['USR_EMAIL'] = $email;
|
||||||
$aData['USR_DUE_DATE'] = mktime(0, 0, 0, date("m"), date("d"), date("Y") + 1);
|
$aData['USR_DUE_DATE'] = $mktimeDueDate;
|
||||||
$aData['USR_CREATE_DATE'] = date('Y-m-d H:i:s');
|
$aData['USR_CREATE_DATE'] = date('Y-m-d H:i:s');
|
||||||
$aData['USR_UPDATE_DATE'] = date('Y-m-d H:i:s');
|
$aData['USR_UPDATE_DATE'] = date('Y-m-d H:i:s');
|
||||||
$aData['USR_STATUS'] = 1;
|
$aData['USR_BIRTHDAY'] = date('Y-m-d');
|
||||||
|
$aData['USR_AUTH_USER_DN'] = '';
|
||||||
|
$aData['USR_STATUS'] = ($status == 'ACTIVE')? 1 : 0;
|
||||||
|
|
||||||
$sUserUID = $RBAC->createUser($aData, $strRole );
|
$sUserUID = $RBAC->createUser($aData, $strRole);
|
||||||
|
|
||||||
|
$aData['USR_STATUS'] = $status;
|
||||||
$aData['USR_UID'] = $sUserUID;
|
$aData['USR_UID'] = $sUserUID;
|
||||||
$aData['USR_PASSWORD'] = md5($sUserUID);
|
$aData['USR_PASSWORD'] = md5($sUserUID);
|
||||||
$aData['USR_STATUS'] = 'ACTIVE';
|
|
||||||
$aData['USR_COUNTRY'] = '';
|
$aData['USR_COUNTRY'] = '';
|
||||||
$aData['USR_CITY'] = '';
|
$aData['USR_CITY'] = '';
|
||||||
$aData['USR_LOCATION'] = '';
|
$aData['USR_LOCATION'] = '';
|
||||||
@@ -1012,9 +1038,9 @@ class wsBase
|
|||||||
$aData['USR_PHONE'] = '';
|
$aData['USR_PHONE'] = '';
|
||||||
$aData['USR_ZIP_CODE'] = '';
|
$aData['USR_ZIP_CODE'] = '';
|
||||||
$aData['USR_POSITION'] = '';
|
$aData['USR_POSITION'] = '';
|
||||||
$aData['USR_RESUME'] = '';
|
//$aData['USR_RESUME']
|
||||||
$aData['USR_BIRTHDAY'] = date('Y-m-d');
|
|
||||||
$aData['USR_ROLE'] = $strRole ;
|
$aData['USR_ROLE'] = $strRole ;
|
||||||
|
//$aData['USR_REPLACED_BY']
|
||||||
|
|
||||||
$oUser = new Users();
|
$oUser = new Users();
|
||||||
$oUser->create($aData);
|
$oUser->create($aData);
|
||||||
|
|||||||
@@ -183,6 +183,8 @@
|
|||||||
<xs:element name="email" type="xs:string"/>
|
<xs:element name="email" type="xs:string"/>
|
||||||
<xs:element name="role" type="xs:string"/>
|
<xs:element name="role" type="xs:string"/>
|
||||||
<xs:element name="password" type="xs:string"/>
|
<xs:element name="password" 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:sequence>
|
</xs:sequence>
|
||||||
</xs:complexType>
|
</xs:complexType>
|
||||||
</xs:element>
|
</xs:element>
|
||||||
|
|||||||
@@ -701,9 +701,19 @@ function CreateUser($params)
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
$ws = new wsBase ();
|
$ws = new wsBase();
|
||||||
$res = $ws->createUser( $params->userId, $params->firstname,
|
|
||||||
$params->lastname, $params->email, $params->role, $params->password);
|
$res = $ws->createUser(
|
||||||
|
$params->userId,
|
||||||
|
$params->firstname,
|
||||||
|
$params->lastname,
|
||||||
|
$params->email,
|
||||||
|
$params->role,
|
||||||
|
$params->password,
|
||||||
|
((isset($params->dueDate))? $params->dueDate : null),
|
||||||
|
((isset($params->status))? $params->status : null)
|
||||||
|
);
|
||||||
|
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -923,4 +933,3 @@ $server->addFunction("importProcessFromLibrary");
|
|||||||
$server->addFunction("removeUserFromGroup");
|
$server->addFunction("removeUserFromGroup");
|
||||||
$server->addFunction("getCaseNotes");
|
$server->addFunction("getCaseNotes");
|
||||||
$server->handle();
|
$server->handle();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user