Please rate how useful you found this document: 
No votes yet

User Functions

PMFCreateUser()

PMFCreateUser() creates a new user with the given data.

int PMFCreateUser(string username, string password, string firstname, string lastname, string email, string role, string dueDate = null, string $status = null)

Parameters:

  • string username: The username of the new user.
  • string password: The password of the new user, which can be up to 32 characters long. For more information, see Customizing Authentication.
  • string firstname: The first name of the user, which can be up to 50 characters long.
  • string lastname: The last name of the user, which can be up to 50 characters long.
  • string email: The email of the new user, which can be up to 100 characters long.
  • string role: The role of the new user can be the roleCode such as 'PROCESSMAKER_ADMIN', 'PROCESSMAKER_OPERATOR', 'PROCESSMAKER_MANAGER' or the roleUid that is a unique UID of 32 characters long.
  • string dueDate: Optional. The date in 'YYYY-MM-DD' format when the user's account will become inactive. If not included, then set to December 31 of the next year by default.
  • string status: Optional. The status of the user, which can be 'ACTIVE' (default), 'INACTIVE', or 'VACATION'. If set to 'INACTIVE' or 'VACATION', the user can't be designated to work on tasks in cases.

Return Value:

  • Returns 1 if the new user was created successfully; otherwise, returns 0 if an error occurred.

Example 1:

$var = PMFCreateUser('jsmith', 'PaSsWoRd', 'John', 'Smith', 'jsmith@company.com', 'PROCESSMAKER_OPERATOR');
if ($var == 0)
    @@result = 'not created';
else
    @@result = 'created';

Example 2:

PMFCreateUser() does not set all the available properties for a user. The following example shows how to use the Users::create() method to set the rest of the user's properties.

$username = 'daniela';
@%result = PMFCreateUser($username, 'sample', 'Daniela', 'Baker', 'daniela@example.com',
   'PROCESSMAKER_OPERATOR', '2018-12-31', 'ACTIVE');
if (@%result) {
   require_once 'classes/model/Users.php';
   $u = new Users();
   $aUser = $u->loadByUsernameInArray($username);
   $aUser = $u->load($aUser['USR_UID']);
   $aUser['USR_COUNTRY']      = 'US';   //United States
   $aUser['USR_CITY']         = 'NY';   //New York
   $aUser['USR_LOCATION']     = 'BUF';  //Buffalo
   $aUser['USR_ADDRESS']      = "371 Everest Ave\nClearview NC";
   $aUser['USR_PHONE']        = '1-374-234-2322';
   $aUser['USR_ZIP_CODE']     = '46135';
   $aUser['USR_POSITION']     = 'Chief Accountant';
   $aReplaced = $u->loadByUsernameInArray('dsmith');
   $aUser['USR_REPLACED_BY']  = $aReplaced['USR_UID'];
   $aUser["USR_UX"] = "SWITCHABLE";
   //$aUser["USR_COST_BY_HOUR"] = 20.00;  //enterprise edition only
   //$aUser["USR_UNIT_COST"] = "hours";  //enterprise edition only
   //$aUser["USR_TIME_ZONE"] = 'America/New_York'; //enterprise edition only
   //$aUser["USR_DEFAULT_LANG"] = 'es'; //enterprise edition only
   @@res = $u->create($aUser);
}

PMFInformationUser()

PMFInformationUser() retrieves information about a specified user.

array PMFInformationUser(string $userUID)

Parameters:

  • string USER_ID: The user's unique ID, which can be found in the following ways:

Return Value:

An associative array with the following keys:

array(
'username', The username, which must be unique.
'firstname', The user's first name (maximum of 50 characters).
'lastname', The user's last name (maximum of 50 characters).
'mail', The user's email address (maximum of 100 characters).
'address', The user's address (maximum of 255 characters).
'zipcode', The user's zip or postal code (maximum of 16 characters).
'country', The user's country.
'state', The user's state, province or region.
'location', The user's location.
'phone', The user's phone number (maximum of 24 characters).
'cellular', The user's cellular phone number (maximum of 24 characters).
'birthday', The user's birthday in "YYYY-MM-DD" format. Ex: "1970-11-24"
'position', The user's position.
'replacedby', The unique ID of the user who will replace the user, when his/her status changes to INACTIVE or VACATION.
'replacedbyfullname', The first and last name of the of the user who will replace the user, when his/her status changes to INACTIVE or VACATION.

Note: This element is only defined if ['replacedby'] is not an empty string.

'duedate', Date when the user account will expire in 'YYYY-MM-DD' format. Ex: "2020-12-31"
'calendar', The unique ID of the user's calendar.
'calendarname', The name of the user's calendar.

Note: This element is only defined if ['calendar'] is not an empty string.

'status', The user's status, which can be: ACTIVE, INACTIVE or VACATION.
'department', The unique ID of the user's department.
'departmentname', The name of the user's department.

Note: This element is only defined if ['department'] is not an empty string.

'reportsto', The unique ID of the user's supervisor in the department. Use the PMFInformationUser() function a second time to get his/her name.
'userexperience', The User Experience setting, which can be: NORMAL, SINGLE (for a single application), SIMPLIFIED (for mobile interfaces), or SWITCHABLE (to be able to change between the normal and the simplified interfaces).
'photo' The path where the user's photo file is stored on the ProcessMaker server at:
<INSTALL-DIRECTORY>/shared/sites/<WORKSPACE>/usersPhotographies/<USER-UID>.gif
For example:
/opt/processmaker/shared/sites/workflow/usersPhotographies/9108004215481b57a6e38b3002299563.gif
The URL to access the user's photo would be:
http://<IP-ADDRESS>/sys<WORKSPACE/<LANG>/<SKIN>/users/users_ViewPhotoGrid?pUID=<USER-UID>
For example:
http://example.com/sysworkflow/en/neoclassic/users/users_ViewPhotoGrid?pUID=9108004215481b57a6e38b3002299563
Note: The extension of the photo file is always renamed as .gif, even if the file is JPEG or PNG, which can cause problems displaying the image in some web browsers because the file extension doesn't match the file type. The finfo_file() function can be used to check whether the MIME file type is "image/png", "image/jpeg" or "image/gif".
)

For example:

array(
    "username"          => "Eve",
    "firstname"         => "Jones",
    "lastname"          => "ejones",
    "mail"              => "eve@example.com",
    "address"           => "235 W. Oak Av.",
    "zipcode"           => "81643",
    "country"           => "United States",
    "state"             => "Florida",
    "location"          => "Miami Lakes",
    "phone"             => "1-317-453-8776",
    "fax"               => "1-305-402-0282",
    "cellular"          => "1-305-675-1400",
    "birthday"          => "1980-02-25",
    "position"          => "Accountant",
    "replacedby"        => "22515138055fc47dcf0d786050067981",
    "replacedbyfullname"=> "Bob Smith",
    "duedate"           => "2020-01-01",
    "calendar"          => "16215376855fc5e051e7499057282210"
    "calendarname"      => "Florida Calendar"
    "status"            => "ACTIVE",
    "department"        => "79557529255fc48a94665a1003191338",
    "departmentname"    => "Accounting",
    "reportsto"         => "14944204555fc4860983227093956871",
    "userexperience"    => "NORMAL",
    "photo"             => "/opt/pm3.1/shared/sites/workflow/usersPhotographies/63431366054f5d20ec91ce1029282852.gif"
)

Example getting a phone number:

Look up the phone number of the user currently logged in and assign it to a case variable named @@Phone, which will be displayed in a subsequent Dynaform field:

$aUser = PMFInformationUser(@@USER_LOGGED);
@@Phone = $aUser['phone'];

Example getting an address:

Look up the address of a user whose username is "jdoe" and assign it to the @@Address variable, which will be displayed in a textarea associated with that variable in a subsequent Dynaform. The address is a US style address.

$username = 'jdoe';
$result = executeQuery("SELECT USR_UID FROM USERS WHERE USR_USERNAME='$username' ");
if (is_array($result) and count($result) > 0) {
   $aUser = PMFInformationUser( $result[1]['USR_UID'] );
   @@Address = $aUser['address'] .
      (empty($aUser['location']) ? '' : "\n" . $aUser['location'] .', '. $aUser['state'] .' '. $aUser['zipcode']) .
      ($aUser['country'] == 'United States' or empty($aUser['country']) ? '' : $aUser['country']);
}

Example showing user information in a grid:

Create a Dynaform with a grid. When dropping the Grid element, create a new variable named userInformation that is associated to the grid.

Add the following controls inside the grid:

Save the changes and close the Dynaform. Then, create a trigger with the following parameters:

@@userInformation = array();
@@userInformation[1] = PMFInformationUser('50125991157c071f6d684f8088171283');

Where:

  • @@userInformation[1]: Name of the grid where the information will be displayed. Moreover, the grid name is defined as [1] because the return value is a grid and it has to start on 1 to display information in the corresponding fields.

Set the above trigger to fire before the Dynaform. While running a case, the user's information will be displayed in the grid:

Also, this function can be created by using the Trigger Wizard:

Example showing a group of users in a grid:

This example shows a grid in a Dynaform that lists information about the users in a group named Managers.

First, create a Dynaform with a grid. When dropping the Grid element, create a new variable named listGroup that is associated to the grid.

Add the following controls inside the grid:

After that, create the following trigger, which will use the executeQuery() function to look up the members of the group named Managers. It then loops through the list of users and looks up information about each user, then adds it to an array named "ListGroup", which will be displayed in the grid. Remember that grids are stored as an associative array of associative arrays, where the outer array is numbered, starting from 1 for each row in the array, and the keys in the inner array are the fields in the grid:

$query = "SELECT U.USR_UID
          FROM GROUPWF
          LEFT JOIN GROUP_USER GU  ON (GROUPWF.GRP_UID = GU.GRP_UID)
          LEFT JOIN USERS U ON (U.USR_UID = GU.USR_UID)
          WHERE U.USR_STATUS='ACTIVE' AND GROUPWF.GRP_TITLE = 'Managers'"
;
$aUsers = executeQuery($query);

if (is_array($aUsers) and count($aUsers) > 0) {
    for ($i = 1; $i <= count($aUsers); $i++) {
      @@listGroup[$i] = PMFInformationUser($aUsers[$i]['USR_UID']);
    }
}

While running a case, the information about the Managers group members will be displayed in the grid:

Example looking up information about the Supervisor:

The following trigger code retrieves information about the user currently logged in and then looks up information about the user's supervisor, whose unique ID is listed in the 'reportsto' key of the array. It also uses the executeQuery() function to look up the name of the department in the DEPARTMENT table. The trigger then uses the G:SendMessageText() function to display a message in the next screen telling the user to contact his/her supervisor:

$aUser = PMFInformationUser(@@USER_LOGGED);
$g = new G();
if (($aUser['reportsto'])!=NULL) {
    $aSuper = PMFInformationUser($aUser['reportsto']);

    $aDept = executeQuery("SELECT DEP_UID FROM DEPARTMENT WHERE DEP_TITLE = '{$aSuper['department']}'");

    $msg = "Please contact your supervisor {$aSuper['firstname']} {$aSuper['lastname']} " .
      "({$aSuper['mail']}) of the {$aDept[1]['CON_VALUE']} Department for authorization of this decision.";

    $g->SendMessageText($msg, "WARNING");
}
else {
    $g->SendMessageText("You do not have authorization for this decision, ".
      "because it needs a supervisor's approval, but you don't have a supervisor.", "ERROR");
}

Note that the PHP variables inserted in the $msg string are enclosed in {...} (curly brackets) so that they can access the array's key correctly.

Example getting a Calendar, Replaced By User, or Department safely:

PMFInformationUser() defines ['calendarname'], ['departmentname'], and ['replacebyfullname'] if ['calendar'], ['department'], and ['replacedby'] are not empty strings, respectively. Also PMFInformationUser() doesn't return the user's role and so internal functions have to be used to get the role. Currently, the user has to use this code to get a Calendar, Replaced By User, or Department safely:

$aUser = PMFInformationUser(@@USER_LOGGED);
@@calendarName = empty($aUser['calendar']) ?  '' : $aUser['calendarname'];
@@deptName = empty($aUser['department']) ? '' :  $aUser['departmentname'];
@@replacedName =  empty($aUser['replacedby']) ? '' : $aUser['replacedbyfullname'];

Note: Because there is no ProcessMaker function to get the role, instead the Users::Load() function can be used to get the user's role, as shown in the following example:

$u = new Users();
$aUserInfo = $u->Load(@@USER_LOGGED);
$role = $aUserInfo["USR_ROLE"];

PMFNewUser()

Available Version: As of ProcessMaker 3.7.0

PMFNewUser() creates a new user and returns a value array that includes the user UID. This function is useful for plugins, triggers, script tasks, and to receive this important information for other procedures such as assigning a user to a group.

int PMFCreateUser(string username, string password, string firstname, string lastname, string email, string role, string dueDate = null, string $status = null, string $group = null)

Parameters:

  • string username: The username of the new user. It is a required parameter.
  • string password: The password of the new user, which can be up to 32 characters long. For more information, see Customizing Authentication. It is a required parameter.
  • string firstname: The first name of the user, which can be up to 50 characters long. It is a required parameter.
  • string lastname: The last name of the user, which can be up to 50 characters long. It is a required parameter.
  • string email: The email of the new user, which can be up to 100 characters long. It is a required parameter.
  • string role: The role of the new user can be the roleCode such as PROCESSMAKER_ADMIN, PROCESSMAKER_OPERATOR, PROCESSMAKER_MANAGER or the roleUid that is a unique UID of 32 characters long.
  • string dueDate: Optional. The date in YYYY-MM-DD format when the user's account will become inactive. If not included, then set to December 31 of the next year by default.
  • string status: Optional. The status of the user, which can be ACTIVE (default), INACTIVE, or VACATION. If set to INACTIVE or VACATION, the user can not be designated to work on tasks in cases.
  • string group: Optional. Valid groups for the new user.

Return Value Array:

array(
'userUid', The UID of the ProcessMaker user.
'userId', The ID of the ProcessMaker user.
'username', The user name.
'password', The user password.
'firstname', The user first name.
'lastname', The user last name.
'email', The user email address.
'role', The user role.
'dueDate', Date when the user account will become inactive in the 'YYYY-MM-DD' format. If it is not configured, by default, the array displays December 31 of the next year.
'status', The user status: ACTIVE, INACTIVE or VACATION.
'groupUid', The UID of the ProcessMaker Group if the group was configured previously.
)

PMFRoleList()

PMFRoleList() returns a list of all the roles in the current workspace.

array PMFRoleList(void)

Parameters:

  • None.

Return Value:

  • This function returns an array of roles, with the following structure:
[0] array ( associative array ( [string guid] [string name] ) ) ...

Where:

  • string guid: The unique ID of a role.
  • string name: The name of a role.

Example:

$aRoles = PMFRoleList();

//Counting in the array starts from 1
@@RoleName = $aRoles[1]['name'];

PMFUpdateUser()

PMFUpdateUser() updates a specified user's information.

int PMFUpdateUser(string userUID, string userName, string firstName = null, string lastName = null, string email = null, string dueDate = null, string status = null, string role = null, password = null)

Parameters:

  • string userUID: The unique ID of the user whose information will be updated.
  • string userName: The username of the user.
  • string firstname: Optional. The first name of the user, which can be up to 50 characters long.
  • string lastname: Optional. The last name of the user, which can be up to 50 characters long.
  • string email: Optional. The email of the user, which can be up to 100 characters long.
  • string dueDate: Optional. The expiration date of the user's account, which must be a string in the format "YYYY-MM-DD".
  • string status: Optional. The user's status, which can be 'ACTIVE', 'INACTIVE' or 'VACATION'.
  • string role: Optional. The role of the new user can be the roleCode such as 'PROCESSMAKER_ADMIN', 'PROCESSMAKER_OPERATOR', 'PROCESSMAKER_MANAGER' or the roleUid that is a unique UID of 32 characters long.
  • string password: Optional. The password of the user, which can be up to 32 characters long. For more information, see Customizing Authentication.

Return Value:

  • Returns 1 if the user has been successfully updated; otherwise, returns 0 if an error occurred.

Example:

@@return = PMFUpdateUser(@@USER_LOGGED, 'jdoe', 'John', 'Doe', 'jdoe@example.com', '2020-12-31', 'ACTIVE', 'PROCESSMAKER_OPERATOR', 'p4ssw0rd');

PMFUserList()

PMFUserList() returns a list of users whose status is set to "ACTIVE" in the current workspace.

array PMFUserList(void)

Parameters:

None.

Return Value:

An array of users, with the following structure:

[0] array ( associative array ( [string guid] [string name] ) ) ...

Where:

  • string guid: The unique ID of a user.
  • string name: The username of a user.

Example:

@@GRID_USERS = PMFUserList();

userInfo()

userInfo() in version 3.X is an alias for the PMFInformationUser() function.

array userInfo(string USER_ID)