- Wed Mar 14, 2018 12:18 pm
#813667
I am creating a new user via the REST API. Is there a way to set the user's Default Main Menu Option when creating the user in REST? Thanks.
$userId = '92729925059e5652bebac55017512865';
$defaultMenu = 'PM_CASES';
$defaultCasesMenu = 'CASES_SENT';
$url = "/api/1.0/workflow/extrarest/user/$userId/config";
$aVars = array(
'default_lang' => 'el',
'default_menu' => $defaultMenu,
'default_cases_menu' => $defaultCasesMenu
);
$oRet = pmRestRequest('PUT', $url, $aVars, $oToken->access_token);
var_dump($oRet);
/**
* Update user configuration stored in a serialized array in CONFIGURATION.CFG_VALUE.
*
* @url PUT /user/:usr_uid/config
* @access protected
*
* @param string $usr_uid User's unique ID. {@from path}{@min 32}{@max 32}
* @param string $default_lang Default interface language in 'xx' or 'xx-CC' format.
* {@from body} {@pattern /^[a-z]{2,3}([\-_][A-Z]{2})?$/}
* @param string $default_menu Default main menu: '' (default for role), PM_CASES=Home, PM_FACTORY=Designer, PM_SETUP=Admin
* {@from body} {@choice PM_CASES,PM_FACTORY,PM_SETUP,PM_DASHBOARD,}
* @param string $default_cases_menu Default Cases submenu: ''=default Inbox, CASES_SENT=participated, CASES_SELFSERVICE=unassigned, CASES_SEARCH=advanced search, CASES_TO_REVISE=review, CASES_FOLDERS=Documents
* {@from body} {@choice CASES_START_CASE,CASES_INBOX,CASES_DRAFT,CASES_SENT,CASES_SELFSERVICE,CASES_PAUSED,CASES_SEARCH,CASES_TO_REVISE,CASES_TO_REASSIGN,CASES_FOLDERS,}
*
* @return array An array holding the updated user configuration.
*
* @author Amos Batto <amos@processmaker.com>
* @copyright Public Domain
*/
public function putUserConfig($usr_uid, $default_lang=null, $default_menu=null, $default_cases_menu=null)
{
try {
$rbac = \RBAC::getSingleton();
$rbac->initRBAC();
if ($rbac->verifyUserId($usr_uid) != 1) {
throw new \Exception("User with ID '$usr_uid' does not exist.");
}
if ($this->userCanAccess('PM_USERS') == 0) {
throw new \Exception("Logged-in user lacks the PM_USERS permission in role.");
}
$g = new \G();
$g->loadClass('configuration');
$oConf = new \Configurations();
$oConf->loadConfig($x, 'USER_PREFERENCES', '', '', $usr_uid, '' );
//set user configuration:
if (isset($default_lang)) {
$oConf->aConfig['DEFAULT_LANG'] = $default_lang;
}
if (isset($default_menu)) {
$oConf->aConfig['DEFAULT_MENU'] = $default_menu;
}
if (isset($default_cases_menu)) {
$oConf->aConfig['DEFAULT_CASES_MENU'] = $default_cases_menu;
}
//update configuration:
$oConf->saveConfig('USER_PREFERENCES', '', '', $usr_uid);
$oConf->loadConfig($y, 'USER_PREFERENCES', '', '', $usr_uid, '');
return $oConf->aConfig;
}
catch (\Exception $e) {
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
}
}
/**
* Get user configuration stored in a serialized array in CONFIGURATION.CFG_VALUE.
*
* @url GET /user/:usr_uid/config
* @access protected
*
* @param string $usr_uid User's unique ID. {@from path}{@min 32}{@max 32}
*
* @return array An array holding the user configuration.
*
* @author Amos Batto <amos@processmaker.com>
* @copyright Public Domain
*/
public function getUserConfig($usr_uid) {
try {
$rbac = \RBAC::getSingleton();
$rbac->initRBAC();
if ($rbac->verifyUserId($usr_uid) != 1) {
throw new \Exception("User with ID '$usr_uid' does not exist.");
}
if ($this->userCanAccess('PM_USERS') == 0) {
throw new \Exception("Logged-in user lacks the PM_USERS permission in role.");
}
$g = new \G();
$g->loadClass('configuration');
$oConf = new \Configurations();
$oConf->loadConfig($x, 'USER_PREFERENCES', '', '', $usr_uid, '' );
return $oConf->aConfig;
}
catch (\Exception $e) {
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
}
}
DO we have to pay tax for trade https://www.getfir[…]
https://www.facebook.com/sammosquitozapper https:[…]
Are you looking for a simple method to import EML […]