From ffc2a27135f82983c9ae531f161a0a64898d1b83 Mon Sep 17 00:00:00 2001 From: Hector Cortez Date: Mon, 2 Apr 2012 19:17:57 -0400 Subject: [PATCH] BUG 8863 Migrate the User Profile interface from master branch version SOLVED. - Migrate the User Profile interface from master branch version - User Profile ExtJS migrated from the master branch. --- workflow/engine/methods/users/myInfo.php | 159 +-- workflow/engine/methods/users/usersAjax.php | 515 ++++++++ workflow/engine/methods/users/usersEdit.php | 19 + workflow/engine/methods/users/usersGroups.php | 6 +- workflow/engine/methods/users/usersInit.php | 35 + workflow/engine/methods/users/usersNew.php | 20 + workflow/engine/templates/users/users.js | 1052 +++++++++++++++++ workflow/engine/templates/users/usersList.js | 25 +- workflow/engine/templates/users/usersLoad.php | 42 + .../engine/templates/users/usersReload.php | 20 + 10 files changed, 1731 insertions(+), 162 deletions(-) create mode 100644 workflow/engine/methods/users/usersAjax.php create mode 100644 workflow/engine/methods/users/usersEdit.php create mode 100644 workflow/engine/methods/users/usersInit.php create mode 100644 workflow/engine/methods/users/usersNew.php create mode 100644 workflow/engine/templates/users/users.js create mode 100644 workflow/engine/templates/users/usersLoad.php create mode 100644 workflow/engine/templates/users/usersReload.php diff --git a/workflow/engine/methods/users/myInfo.php b/workflow/engine/methods/users/myInfo.php index beac8fe17..608201655 100755 --- a/workflow/engine/methods/users/myInfo.php +++ b/workflow/engine/methods/users/myInfo.php @@ -22,157 +22,16 @@ * Coral Gables, FL, 33134, USA, or email info@colosa.com. * */ -try { - global $RBAC; - switch ($RBAC->userCanAccess('PM_LOGIN')){ - case -1: - G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels'); - G::header('location: ../login/login'); - die; - break; - case -2: - G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_SYSTEM', 'error', 'labels'); - G::header('location: ../login/login'); - die; - break; - } - // deprecated the class XmlForm_Field_Image is currently part of the class.xmlform.php package - // the use of the external xmlfield_Image is highly discouraged - if (!class_exists('XmlForm_Field_Image')){ - G::LoadClass('xmlfield_Image'); - } -// G::LoadClass('xmlfield_Department'); - require_once 'classes/model/Users.php'; - require_once 'classes/model/Department.php'; - unset($_SESSION['CURRENT_USER']); - $oUser = new Users(); - $aFields = $oUser->load($_SESSION['USER_LOGGED']); - $aFields['USR_PASSWORD'] = '********'; - $aFields['MESSAGE0'] = G::LoadTranslation('ID_USER_REGISTERED') . '!'; - $aFields['MESSAGE1'] = G::LoadTranslation('ID_MSG_ERROR_USR_USERNAME'); - $aFields['MESSAGE2'] = G::LoadTranslation('ID_MSG_ERROR_DUE_DATE'); - $aFields['MESSAGE3'] = G::LoadTranslation('ID_NEW_PASS_SAME_OLD_PASS'); - $aFields['MESSAGE4'] = G::LoadTranslation('ID_MSG_ERROR_USR_FIRSTNAME'); - $aFields['MESSAGE5'] = G::LoadTranslation('ID_MSG_ERROR_USR_LASTNAME'); - $aFields['NO_RESUME'] = G::LoadTranslation('ID_NO_RESUME'); - $aFields['START_DATE'] = date('Y-m-d'); - $aFields['END_DATE'] = date('Y-m-d', mktime(0, 0, 0, date('m'), date('d'), date('Y') + 5)); - $aFields['RANDOM'] = rand(); - - //getting the user and department - $oDepInfo = new Department(); - $oUser = UsersPeer::retrieveByPk( $aFields['USR_REPORTS_TO'] ); - if ( is_object($oUser) && get_class ($oUser) == 'Users' ) { - $userFields = $oUser->toArray(BasePeer::TYPE_FIELDNAME); - $aFields['USR_REPORTS_TO'] = $userFields['USR_FIRSTNAME'] . ' ' . $userFields['USR_LASTNAME']; - try { - $depFields = $oDepInfo->load($userFields['DEP_UID'] ); - $aFields['USR_REPORTS_TO'] .= " (" . $depFields['DEPO_TITLE'] . ")"; - } - catch( Exception $e ) { - } - } - else{ - $aFields['USR_REPORTS_TO'] = ' '; - } - - try { - $depFields = $oDepInfo->load($aFields['DEP_UID']); - $aFields['USR_DEPARTMENT'] = $depFields['DEPO_TITLE']; - } - catch( Exception $e ) { - $oUser = UsersPeer::retrieveByPk( $_SESSION['USER_LOGGED'] ); - $oUser->setDepUid( '' ); - $aFields['USR_DEPARTMENT'] = ' '; - } - - $G_MAIN_MENU = 'processmaker'; + $G_MAIN_MENU = 'processmaker'; + $G_ID_MENU_SELECTED = 'MY_ACCOUNT'; + $G_PUBLISH = new Publisher (); - $G_ID_MENU_SELECTED = 'MY_ACCOUNT'; - $G_PUBLISH = new Publisher; - - - #verifying if it has any preferences on the configurations table - G::loadClass('configuration'); - $oConf = new Configurations; - $oConf->loadConfig($x, 'USER_PREFERENCES','','',$_SESSION['USER_LOGGED'],''); - - if( sizeof($oConf->Fields) > 0){ #this user has a configuration record - $aFields['PREF_DEFAULT_LANG'] = $oConf->aConfig['DEFAULT_LANG']; - $aFields['PREF_DEFAULT_MENUSELECTED'] = isset($oConf->aConfig['DEFAULT_MENU']) ? $oConf->aConfig['DEFAULT_MENU']: ''; - $aFields['PREF_DEFAULT_CASES_MENUSELECTED'] = isset($oConf->aConfig['DEFAULT_CASES_MENU']) ? $oConf->aConfig['DEFAULT_CASES_MENU']: ''; - } else { - switch($RBAC->aUserInfo['PROCESSMAKER']['ROLE']['ROL_CODE']){ - case 'PROCESSMAKER_ADMIN': - $aFields['PREF_DEFAULT_MENUSELECTED'] = 'PM_USERS'; - break; - - case 'PROCESSMAKER_OPERATOR': - $aFields['PREF_DEFAULT_MENUSELECTED'] = 'PM_CASES'; - break; - - } - $aFields['PREF_DEFAULT_LANG'] = SYS_LANG; + if ( isset($_GET['type']) ){ + $G_PUBLISH->AddContent('view', 'users/usersReload'); + G::RenderPage( "publishBlank", "blank"); } - $rows[] = Array('id'=>'char', 'name'=>'char'); - - - foreach($RBAC->aUserInfo['PROCESSMAKER']['PERMISSIONS'] as $permission){ - - switch($permission['PER_CODE']){ - case 'PM_USERS': - $rows[] = Array('id'=>'PM_USERS', 'name'=>strtoupper(G::LoadTranslation('ID_USERS'))); - break; - case 'PM_CASES': - $rows[] = Array('id'=>'PM_CASES', 'name'=>strtoupper(G::LoadTranslation('ID_CASES'))); - break; - case 'PM_FACTORY': - $rows[] = Array('id'=>'PM_FACTORY', 'name'=>strtoupper(G::LoadTranslation('ID_APPLICATIONS'))); - break; - case 'PM_DASHBOARD': - $rows[] = Array('id'=>'PM_DASHBOARD', 'name'=>strtoupper(G::LoadTranslation('ID_DASHBOARD'))); - break; - case 'PM_SETUP': - $rows[] = Array('id'=>'PM_SETUP', 'name'=>strtoupper(G::LoadTranslation('ID_SETUP'))); - break; - } + else { + $G_PUBLISH->AddContent('view', 'users/usersLoad'); + G::RenderPage( "publish" ); } - - global $G_TMP_MENU; - $oMenu = new Menu(); - $oMenu->load('cases'); - - $rowsCasesMenu[] = Array('id'=>'char', 'name'=>'char'); - - foreach($oMenu->Id as $i=>$item){ - if( $oMenu->Types[$i] != 'blockHeader' ){ - $rowsCasesMenu[] = Array('id'=>$item, 'name'=>$oMenu->Labels[$i]); - } - } - - //G::pr($rows); die; - global $_DBArray; - $_DBArray['menutab'] = $rows; - $_SESSION['_DBArray'] = $_DBArray; - $_DBArray['CASES_MENU'] = $rowsCasesMenu; - $_SESSION['_DBArray'] = $_DBArray; - - G::LoadClass('ArrayPeer'); - $oCriteria = new Criteria('dbarray'); - $oCriteria->setDBArrayTable('menutab'); - $oCriteria2 = new Criteria('dbarray'); - $oCriteria2->setDBArrayTable('CASES_MENU'); - - if ($RBAC->userCanAccess('PM_EDITPERSONALINFO') == 1) { //he has permitions for edit his profile - $G_PUBLISH->AddContent('xmlform', 'xmlform', 'users/myInfoView.xml', '', $aFields); - } else { //he has not permitions for edit his profile, so just view mode will be displayed - $G_PUBLISH->AddContent('xmlform', 'xmlform', 'users/myInfoView2.xml', '', $aFields); - } - - G::RenderPage('publish'); -} -catch (Exception $oException) { - die($oException->getMessage()); -} -?> \ No newline at end of file diff --git a/workflow/engine/methods/users/usersAjax.php b/workflow/engine/methods/users/usersAjax.php new file mode 100644 index 000000000..314a959f6 --- /dev/null +++ b/workflow/engine/methods/users/usersAjax.php @@ -0,0 +1,515 @@ +add(IsoCountryPeer::IC_UID, NULL, Criteria::ISNOTNULL); + + $countries = IsoCountryPeer::doSelect($c); + foreach ( $countries as $rowid => $row ) { + $oData[] = Array('IC_UID'=>$row->getICUid(),'IC_NAME'=>$row->getICName()); + } + print(G::json_encode($oData)); + break; + + case 'stateList' : + require_once ("classes/model/IsoSubdivision.php"); + $c = new Criteria(); + $country = $_POST['IC_UID']; + $c->add(IsoSubdivisionPeer::IC_UID, $country, Criteria::EQUAL); + $locations = IsoSubdivisionPeer::doSelect($c); + + foreach( $locations as $rowid => $row ) { + if (($row->getISUid() != '') && ($row->getISName() != '')) + $oData[] = Array('IS_UID' => $row->getISUid(), 'IS_NAME' => $row->getISName()); + } + print(G::json_encode($oData)); + break; + + case 'locationList' : + require_once ("classes/model/IsoLocation.php"); + $c = new Criteria(); + $country = $_POST['IC_UID']; + $state = $_POST['IS_UID']; + $c->add(IsoLocationPeer::IC_UID, $country, Criteria::EQUAL); + $c->add(IsoLocationPeer::IS_UID, $state, Criteria::EQUAL); + $locations = IsoLocationPeer::doSelect($c); + + foreach ( $locations as $rowid => $row ) { + if (($row->getILUid() != '') && ($row->getILName() != '')) + $oData[] = Array('IL_UID' => $row->getILUid(), 'IL_NAME' => $row->getILName()); + } + print(G::json_encode($oData)); + break; + case 'usersList' : + require_once 'classes/model/Users.php'; + $oCriteria = new Criteria(); + $oCriteria->addSelectColumn(UsersPeer::USR_UID); + $oCriteria->addSelectColumn(UsersPeer::USR_USERNAME); + $oCriteria->addSelectColumn(UsersPeer::USR_FIRSTNAME); + $oCriteria->addSelectColumn(UsersPeer::USR_LASTNAME); + $oCriteria->addSelectColumn(UsersPeer::USR_EMAIL); + $oCriteria->add(UsersPeer::USR_STATUS,'ACTIVE'); + $oDataset = UsersPeer::doSelectRS($oCriteria); + $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); + + G::loadClass('configuration'); + $oConf = new Configurations; + $oConf->loadConfig($obj, 'ENVIRONMENT_SETTINGS',''); + + $defaultOption = isset($oConf->aConfig['format']) ? $oConf->aConfig['format'] : ''; + + $aUserInfo = array(); + while ( $oDataset->next()) { + $aRow1 = $oDataset->getRow(); + + $infoUser = G::getFormatUserList($defaultOption,$aRow1); + $aUserInfo[] = array( + 'USR_UID' => $aRow1['USR_UID'], + 'USER_FULLNAME' => $infoUser + ); + } + print(G::json_encode($aUserInfo)); + + break; + + case 'availableCalendars' : + G::LoadClass ( 'calendar' ); + $calendar = new Calendar ( ); + $calendarObj = $calendar->getCalendarList ( true, true ); + $oData[] = array('CALENDAR_UID' => '', 'CALENDAR_NAME' => '- None -'); + foreach ( $calendarObj ['array'] as $rowid => $row ) { + if ($rowid > 0) + $oData[] = array('CALENDAR_UID' => $row['CALENDAR_UID'], 'CALENDAR_NAME' => $row['CALENDAR_NAME']); + } + print(G::json_encode($oData)); + break; + case 'rolesList': + require_once PATH_RBAC."model/Roles.php"; + $roles = new Roles(); + $rolesData = $roles->getAllRoles(); + foreach( $rolesData as $rowid => $row ) { + $oData[] = array('ROL_UID' => $row['ROL_CODE'],'ROL_CODE' => $row['ROL_CODE']); + } + print(G::json_encode($oData)); + break; + case 'saveUser' : + try { + $form = $_POST; + + if ( isset($_POST['USR_UID'])) { + $form['USR_UID'] = $_POST['USR_UID']; + } + else { + $form['USR_UID'] = ''; + } +/* + if ( isset($_FILES['USR_RESUME']['name']) ) { + if ($_FILES['USR_RESUME']['tmp_name'] != '') { + $form['USR_RESUME'] = $_FILES['USR_RESUME']['name']; + } + else { + $form['USR_RESUME'] = ''; + } + } +*/ + if (!isset($form['USR_NEW_PASS'])) { + $form['USR_NEW_PASS'] = ''; + } + if ($form['USR_NEW_PASS'] != '') { + $form['USR_PASSWORD'] = md5($form['USR_NEW_PASS']); + } + if (!isset($form['USR_CITY'])) { + $form['USR_CITY'] = ''; + } + if (!isset($form['USR_LOCATION'])) { + $form['USR_LOCATION'] = ''; + } + if (!isset($form['USR_AUTH_USER_DN'])) { + $form['USR_AUTH_USER_DN'] = ''; + } + + if ($form['USR_UID'] == '') { + $aData['USR_USERNAME'] = $form['USR_USERNAME']; + $aData['USR_PASSWORD'] = $form['USR_PASSWORD']; + $aData['USR_FIRSTNAME'] = $form['USR_FIRSTNAME']; + $aData['USR_LASTNAME'] = $form['USR_LASTNAME']; + $aData['USR_EMAIL'] = $form['USR_EMAIL']; + $aData['USR_DUE_DATE'] = $form['USR_DUE_DATE']; + $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'] = $form['USR_AUTH_USER_DN']; + //fixing bug in inactive user when the admin create a new user. + $statusWF = $form['USR_STATUS']; + $aData['USR_STATUS'] = $form['USR_STATUS'] == 'ACTIVE' ? 1 : 0; + $sUserUID = $RBAC->createUser($aData, $form['USR_ROLE'] ); + $aData['USR_STATUS'] = $statusWF; + $aData['USR_UID'] = $sUserUID; + $aData['USR_PASSWORD'] = md5($sUserUID);//fake :p + $aData['USR_COUNTRY'] = $form['USR_COUNTRY']; + $aData['USR_CITY'] = $form['USR_CITY']; + $aData['USR_LOCATION'] = $form['USR_LOCATION']; + $aData['USR_ADDRESS'] = $form['USR_ADDRESS']; + $aData['USR_PHONE'] = $form['USR_PHONE']; + $aData['USR_ZIP_CODE'] = $form['USR_ZIP_CODE']; + $aData['USR_POSITION'] = $form['USR_POSITION']; +// $aData['USR_RESUME'] = $form['USR_RESUME']; + $aData['USR_ROLE'] = $form['USR_ROLE']; + $aData['USR_REPLACED_BY'] = $form['USR_REPLACED_BY']; + + require_once 'classes/model/Users.php'; + $oUser = new Users(); + $oUser->create($aData); + + if ($_FILES['USR_PHOTO']['error'] != 1) { + //print (PATH_IMAGES_ENVIRONMENT_USERS); + if ($_FILES['USR_PHOTO']['tmp_name'] != '') { + G::uploadFile($_FILES['USR_PHOTO']['tmp_name'], PATH_IMAGES_ENVIRONMENT_USERS, $sUserUID . '.gif'); + } + } + else { + $result->success = false; + $result->fileError = true; + print(G::json_encode($result)); + die; + } +/* + if ($_FILES['USR_RESUME']['error'] != 1) { + if ($_FILES['USR_RESUME']['tmp_name'] != '') { + G::uploadFile($_FILES['USR_RESUME']['tmp_name'], PATH_IMAGES_ENVIRONMENT_FILES . $sUserUID . '/', $_FILES['USR_RESUME']['name']); + } + } + else { + $result->success = false; + $result->fileError = true; + print(G::json_encode($result)); + die; + } +*/ + } + else { + + $aData['USR_UID'] = $form['USR_UID']; + $aData['USR_USERNAME'] = $form['USR_USERNAME']; + + if (isset($form['USR_PASSWORD'])) { + + if ($form['USR_PASSWORD'] != '') { + $aData['USR_PASSWORD'] = $form['USR_PASSWORD']; + require_once 'classes/model/UsersProperties.php'; + $oUserProperty = new UsersProperties(); + $aUserProperty = $oUserProperty->loadOrCreateIfNotExists($form['USR_UID'], array('USR_PASSWORD_HISTORY' => serialize(array(md5($form['USR_PASSWORD']))))); + + $memKey = 'rbacSession' . session_id(); + $memcache = & PMmemcached::getSingleton(defined('SYS_SYS') ? SYS_SYS : ''); + if ( ($RBAC->aUserInfo = $memcache->get($memKey)) === false ) { + $RBAC->loadUserRolePermission($RBAC->sSystem, $_SESSION['USER_LOGGED'] ); + $memcache->set( $memKey, $RBAC->aUserInfo, PMmemcached::EIGHT_HOURS ); + } + if( $RBAC->aUserInfo[ 'PROCESSMAKER' ]['ROLE']['ROL_CODE']=='PROCESSMAKER_ADMIN'){ + $aUserProperty['USR_LAST_UPDATE_DATE'] = date('Y-m-d H:i:s'); + $aUserProperty['USR_LOGGED_NEXT_TIME'] = 1; + $oUserProperty->update($aUserProperty); + } + + $aErrors = $oUserProperty->validatePassword($form['USR_NEW_PASS'], $aUserProperty['USR_LAST_UPDATE_DATE'], 0); + + + if (count($aErrors) > 0) { + $sDescription = G::LoadTranslation('ID_POLICY_ALERT').':,'; + foreach ($aErrors as $sError) { + switch ($sError) { + case 'ID_PPP_MINIMUN_LENGTH': + $sDescription .= ' - ' . G::LoadTranslation($sError).': ' . PPP_MINIMUN_LENGTH . ','; + break; + case 'ID_PPP_MAXIMUN_LENGTH': + $sDescription .= ' - ' . G::LoadTranslation($sError).': ' . PPP_MAXIMUN_LENGTH . ','; + break; + case 'ID_PPP_EXPIRATION_IN': + $sDescription .= ' - ' . G::LoadTranslation($sError).' ' . PPP_EXPIRATION_IN . ' ' . G::LoadTranslation('ID_DAYS') . ','; + break; + default: + $sDescription .= ' - ' . G::LoadTranslation($sError).','; + break; + } + } + $sDescription .= ''.G::LoadTranslation('ID_PLEASE_CHANGE_PASSWORD_POLICY'); + $result->success = false; + $result->msg = $sDescription; + print(G::json_encode($result)); + die; + + + } + $aHistory = unserialize($aUserProperty['USR_PASSWORD_HISTORY']); + if (!is_array($aHistory)) { + $aHistory = array(); + } + if (!defined('PPP_PASSWORD_HISTORY')) { + define('PPP_PASSWORD_HISTORY', 0); + } + if (PPP_PASSWORD_HISTORY > 0) { + //it's looking a password igual into aHistory array that was send for post in md5 way + $c = 0; + $sw = 1; + while (count($aHistory) >= 1 && count($aHistory) > $c && $sw ){ + if (strcmp(trim($aHistory[$c]), trim($form['USR_PASSWORD'])) == 0){ + $sw = 0; + } + $c++; + } + if ($sw == 0) { + $sDescription = G::LoadTranslation('ID_POLICY_ALERT').':

'; + $sDescription .= ' - ' . G::LoadTranslation('PASSWORD_HISTORY').': ' . PPP_PASSWORD_HISTORY . '
'; + $sDescription .= '
' . G::LoadTranslation('ID_PLEASE_CHANGE_PASSWORD_POLICY').''; + G::SendMessageText($sDescription, 'warning'); + G::header('Location: ' . $_SERVER['HTTP_REFERER']); + die; + } + + if (count($aHistory) >= PPP_PASSWORD_HISTORY) { + $sLastPassw = array_shift($aHistory); + } + $aHistory[] = $form['USR_PASSWORD']; + } + $aUserProperty['USR_LAST_UPDATE_DATE'] = date('Y-m-d H:i:s'); + $aUserProperty['USR_LOGGED_NEXT_TIME'] = 1; + $aUserProperty['USR_PASSWORD_HISTORY'] = serialize($aHistory); + $oUserProperty->update($aUserProperty); + } + } + $aData['USR_FIRSTNAME'] = $form['USR_FIRSTNAME']; + $aData['USR_LASTNAME'] = $form['USR_LASTNAME']; + $aData['USR_EMAIL'] = $form['USR_EMAIL']; + $aData['USR_DUE_DATE'] = $form['USR_DUE_DATE']; + $aData['USR_UPDATE_DATE'] = date('Y-m-d H:i:s'); + if (isset($form['USR_STATUS'])) { + $aData['USR_STATUS'] = $form['USR_STATUS']; + } + if (isset($form['USR_ROLE'])) { + $RBAC->updateUser($aData, $form['USR_ROLE']); + } + else { + $RBAC->updateUser($aData); + } + $aData['USR_COUNTRY'] = $form['USR_COUNTRY']; + $aData['USR_CITY'] = $form['USR_CITY']; + $aData['USR_LOCATION'] = $form['USR_LOCATION']; + $aData['USR_ADDRESS'] = $form['USR_ADDRESS']; + $aData['USR_PHONE'] = $form['USR_PHONE']; + $aData['USR_ZIP_CODE'] = $form['USR_ZIP_CODE']; + $aData['USR_POSITION'] = $form['USR_POSITION']; +/* + if ($form['USR_RESUME'] != '') { + $aData['USR_RESUME'] = $form['USR_RESUME']; + } +*/ + if (isset($form['USR_ROLE'])) { + $aData['USR_ROLE'] = $form['USR_ROLE']; + } + + if(isset($form['USR_REPLACED_BY'])){ + $aData['USR_REPLACED_BY'] = $form['USR_REPLACED_BY']; + } + if(isset($form['USR_AUTH_USER_DN'])){ + $aData['USR_AUTH_USER_DN'] = $form['USR_AUTH_USER_DN']; + } + + require_once 'classes/model/Users.php'; + $oUser = new Users(); + $oUser->update($aData); + if ($_FILES['USR_PHOTO']['error'] != 1) { + if ($_FILES['USR_PHOTO']['tmp_name'] != '') { + $aAux = explode('.', $_FILES['USR_PHOTO']['name']); + G::uploadFile($_FILES['USR_PHOTO']['tmp_name'], PATH_IMAGES_ENVIRONMENT_USERS, $aData['USR_UID'] . '.' . $aAux[1]); + G::resizeImage(PATH_IMAGES_ENVIRONMENT_USERS . $aData['USR_UID'] . '.' . $aAux[1], 96, 96, PATH_IMAGES_ENVIRONMENT_USERS . $aData['USR_UID'] . '.gif'); + } + } + else { + $result->success = false; + $result->fileError = true; + print(G::json_encode($result)); + die; + } +/* + if ($_FILES['USR_RESUME']['error'] != 1) { + if ($_FILES['USR_RESUME']['tmp_name'] != '') { + G::uploadFile($_FILES['USR_RESUME']['tmp_name'], PATH_IMAGES_ENVIRONMENT_FILES . $aData['USR_UID'] . '/', $_FILES['USR_RESUME']['name']); + } + } + else { + $result->success = false; + $result->fileError = true; + print(G::json_encode($result)); + die; + } +*/ + /* Saving preferences */ + $def_lang = $form['PREF_DEFAULT_LANG']; + $def_menu = $form['PREF_DEFAULT_MENUSELECTED']; + $def_cases_menu = $form['PREF_DEFAULT_CASES_MENUSELECTED']; + + G::loadClass('configuration'); + + $oConf = new Configurations; + $aConf = Array( + 'DEFAULT_LANG' => $def_lang, + 'DEFAULT_MENU' => $def_menu, + 'DEFAULT_CASES_MENU' => $def_cases_menu + ); + + /*UPDATING SESSION VARIABLES*/ + $aUser = $RBAC->userObj->load($_SESSION['USER_LOGGED']); + //$_SESSION['USR_FULLNAME'] = $aUser['USR_FIRSTNAME'] . ' ' . $aUser['USR_LASTNAME']; + + $oConf->aConfig = $aConf; + $oConf->saveConfig('USER_PREFERENCES', '', '',$_SESSION['USER_LOGGED']); + + } + + if ( $_SESSION['USER_LOGGED'] == $form['USR_UID'] ) { + /* UPDATING SESSION VARIABLES */ + $aUser = $RBAC->userObj->load($_SESSION['USER_LOGGED']); + $_SESSION['USR_FULLNAME'] = $aUser['USR_FIRSTNAME'] . ' ' . $aUser['USR_LASTNAME']; + } + + + //Save Calendar assigment + if ((isset($form['USR_CALENDAR']))) { + //Save Calendar ID for this user + G::LoadClass("calendar"); + $calendarObj = new Calendar(); + $calendarObj->assignCalendarTo($aData['USR_UID'], $form['USR_CALENDAR'], 'USER'); + } + $result->success = true; + print(G::json_encode($result)); + }catch (Exception $e) { + $result->success = false; + $result->error = $e->getMessage(); + print(G::json_encode($result)); + } + break; + + case 'userData': + require_once 'classes/model/Users.php'; + $_SESSION['CURRENT_USER'] = $_POST['USR_UID']; + $oUser = new Users(); + $aFields = $oUser->loadDetailed($_POST['USR_UID']); + + //Load Calendar options and falue for this user + G::LoadClass ( 'calendar' ); + $calendar = new Calendar ( ); + $calendarInfo = $calendar->getCalendarFor ( $_POST['USR_UID'], $_POST['USR_UID'], $_POST['USR_UID'] ); + //If the function returns a DEFAULT calendar it means that this object doesn't have assigned any calendar + $aFields ['USR_CALENDAR'] = $calendarInfo ['CALENDAR_APPLIED'] != 'DEFAULT' ? $calendarInfo ['CALENDAR_UID'] : ""; + + #verifying if it has any preferences on the configurations table + G::loadClass('configuration'); + $oConf = new Configurations; + $oConf->loadConfig($x, 'USER_PREFERENCES', '', '', $_SESSION['USER_LOGGED'], ''); + + $aFields['PREF_DEFAULT_MENUSELECTED']=''; + $aFields['PREF_DEFAULT_CASES_MENUSELECTED']=''; + if( sizeof($oConf->Fields) > 0){ #this user has a configuration record + $aFields['PREF_DEFAULT_LANG'] = $oConf->aConfig['DEFAULT_LANG']; + $aFields['PREF_DEFAULT_MENUSELECTED'] = isset($oConf->aConfig['DEFAULT_MENU']) ? $oConf->aConfig['DEFAULT_MENU']: ''; + $aFields['PREF_DEFAULT_CASES_MENUSELECTED'] = isset($oConf->aConfig['DEFAULT_CASES_MENU']) ? $oConf->aConfig['DEFAULT_CASES_MENU']: ''; + } else { + switch($RBAC->aUserInfo['PROCESSMAKER']['ROLE']['ROL_CODE']){ + case 'PROCESSMAKER_ADMIN': + $aFields['PREF_DEFAULT_MENUSELECTED'] = 'PM_SETUP'; + break; + + case 'PROCESSMAKER_OPERATOR': + $aFields['PREF_DEFAULT_MENUSELECTED'] = 'PM_CASES'; + break; + + } + $aFields['PREF_DEFAULT_LANG'] = SYS_LANG; + } + if ($aFields['USR_REPLACED_BY'] != ''){ + $user = new Users(); + $u = $user->load($aFields['USR_REPLACED_BY']); + $c = new Configurations(); + $replaced_by = $c->usersNameFormat($u['USR_USERNAME'], $u['USR_FIRSTNAME'], $u['USR_LASTNAME']); + }else{ + $replaced_by = ''; + } + $aFields['REPLACED_NAME'] = $replaced_by; + if ($aFields['PREF_DEFAULT_MENUSELECTED'] != ''){ + $menuSelected = ''; + foreach ( $RBAC->aUserInfo['PROCESSMAKER']['PERMISSIONS'] as $permission ) { + if($aFields['PREF_DEFAULT_MENUSELECTED']==$permission['PER_CODE']){ + switch($permission['PER_CODE']){ + case 'PM_USERS' : + case 'PM_SETUP' : + + $menuSelected = strtoupper(G::LoadTranslation('ID_SETUP')); + break; + case 'PM_CASES' : + $menuSelected = strtoupper(G::LoadTranslation('ID_CASES')); + break; + case 'PM_FACTORY' : + $menuSelected = strtoupper(G::LoadTranslation('ID_APPLICATIONS')); + break; + } + } + } + } + $aFields['MENUSELECTED_NAME'] = $menuSelected; + $oMenu = new Menu(); + $oMenu->load('cases'); + if ($aFields['PREF_DEFAULT_CASES_MENUSELECTED'] != ''){ + foreach($oMenu->Id as $i => $item){ + + if ($aFields['PREF_DEFAULT_CASES_MENUSELECTED'] == $item) + $casesMenuSelected =$oMenu->Labels[$i]; + } + } + else { + $casesMenuSelected = ''; + } + $aFields['CASES_MENUSELECTED_NAME'] = $casesMenuSelected; + + $result->success = true; + $result->user = $aFields; + + print(G::json_encode($result)); + break; + + case 'defaultMainMenuOptionList'; + foreach($RBAC->aUserInfo['PROCESSMAKER']['PERMISSIONS'] as $permission){ + switch($permission['PER_CODE']){ + case 'PM_USERS': + case 'PM_SETUP': + $rows[] = Array('id'=>'PM_SETUP', 'name'=>strtoupper(G::LoadTranslation('ID_SETUP'))); + break; + case 'PM_CASES': + $rows[] = Array('id'=>'PM_CASES', 'name'=>strtoupper(G::LoadTranslation('ID_CASES'))); + break; + case 'PM_FACTORY': + $rows[] = Array('id'=>'PM_FACTORY', 'name'=>strtoupper(G::LoadTranslation('ID_APPLICATIONS'))); + break; + } + } + print(G::json_encode($rows)); + break; + case 'defaultCasesMenuOptionList'; + + $oMenu = new Menu(); + $oMenu->load('cases'); + + foreach($oMenu->Id as $i=>$item){ + if( $oMenu->Types[$i] != 'blockHeader' ){ + $rowsCasesMenu[] = Array('id'=>$item, 'name' => $oMenu->Labels[$i]); + } + } + print(G::json_encode($rowsCasesMenu)); + break; + +} diff --git a/workflow/engine/methods/users/usersEdit.php b/workflow/engine/methods/users/usersEdit.php new file mode 100644 index 000000000..e2fcaa8e7 --- /dev/null +++ b/workflow/engine/methods/users/usersEdit.php @@ -0,0 +1,19 @@ +addExtJsScript('users/users', true ); //adding a javascript file .js +$oHeadPublisher->assign('USR_UID', $_GET['USR_UID']); +$oHeadPublisher->assign('MAX_FILES_SIZE', ' (' . $UPLOAD_MAX_SIZE . ') '); +G::RenderPage('publish', 'extJs'); diff --git a/workflow/engine/methods/users/usersGroups.php b/workflow/engine/methods/users/usersGroups.php index af18c975b..0a0489960 100755 --- a/workflow/engine/methods/users/usersGroups.php +++ b/workflow/engine/methods/users/usersGroups.php @@ -85,9 +85,11 @@ $users['CURRENT_TAB'] = $ctab; $oHeadPublisher =& headPublisher::getSingleton(); $oHeadPublisher->addExtJsScript('users/usersGroups', false); //adding a javascript file .js -$oHeadPublisher->addContent('users/usersGroups'); //adding a html file .html. +// $oHeadPublisher->addContent('users/usersGroups'); //adding a html file .html. $oHeadPublisher->assign('USERS', $users); -$oHeadPublisher->assign('hasAuthPerm', ($RBAC->userCanAccess('PM_SETUP_ADVANCE') == 1)); +if ($ctab == 2) { + $oHeadPublisher->assign('hasAuthPerm', ($RBAC->userCanAccess('PM_SETUP_ADVANCE') == 1)); +} G::RenderPage('publish', 'extJs'); \ No newline at end of file diff --git a/workflow/engine/methods/users/usersInit.php b/workflow/engine/methods/users/usersInit.php new file mode 100644 index 000000000..e600ca611 --- /dev/null +++ b/workflow/engine/methods/users/usersInit.php @@ -0,0 +1,35 @@ +load($_SESSION['USER_LOGGED']); + +if ($RBAC->userCanAccess('PM_EDITPERSONALINFO') == 1) { //he has permitions for edit his profile + $canEdit = false; +} else { //he has not permitions for edit his profile, so just view mode will be displayed + $canEdit = true; +} + +//calculating the max upload file size; +$POST_MAX_SIZE = ini_get('post_max_size'); +$mul = substr($POST_MAX_SIZE, -1); +$mul = ($mul == 'M' ? 1048576 : ($mul == 'K' ? 1024 : ($mul == 'G' ? 1073741824 : 1))); +$postMaxSize = (int)$POST_MAX_SIZE * $mul; + +$UPLOAD_MAX_SIZE = ini_get('upload_max_filesize'); +$mul = substr($UPLOAD_MAX_SIZE, -1); +$mul = ($mul == 'M' ? 1048576 : ($mul == 'K' ? 1024 : ($mul == 'G' ? 1073741824 : 1))); +$uploadMaxSize = (int)$UPLOAD_MAX_SIZE * $mul; + +if ( $postMaxSize < $uploadMaxSize ) $uploadMaxSize = $postMaxSize; + +$oHeadPublisher =& headPublisher::getSingleton(); +$oHeadPublisher->addExtJsScript('users/users', true ); //adding a javascript file .js +// $oHeadPublisher->addContent('users/users'); //adding a html file .html. +$oHeadPublisher->assign('USR_UID', $aFields['USR_UID']); +$oHeadPublisher->assign('infoMode', true); +$oHeadPublisher->assign('canEdit', $canEdit); +$oHeadPublisher->assign('MAX_FILES_SIZE', ' (' . $UPLOAD_MAX_SIZE . ') '); +G::RenderPage('publish', 'extJs'); diff --git a/workflow/engine/methods/users/usersNew.php b/workflow/engine/methods/users/usersNew.php new file mode 100644 index 000000000..f74cf1e3a --- /dev/null +++ b/workflow/engine/methods/users/usersNew.php @@ -0,0 +1,20 @@ +addExtJsScript('users/users', true ); //adding a javascript file .js +$oHeadPublisher->assign('USR_UID', ''); +$oHeadPublisher->assign('MAX_FILES_SIZE', ' (' . $UPLOAD_MAX_SIZE . ') '); +G::RenderPage('publish', 'extJs'); diff --git a/workflow/engine/templates/users/users.js b/workflow/engine/templates/users/users.js new file mode 100644 index 000000000..c8018bb16 --- /dev/null +++ b/workflow/engine/templates/users/users.js @@ -0,0 +1,1052 @@ +var storelocation; +var comboLocation; +var storeCountry; +var frmDetails; +var allowBlackStatus; +var displayPreferences; +var passwordFields; +var box; +var infoMode; +var global = {}; +var readMode; +var canEdit = true; +//var rendeToPage='document.body'; +global.IC_UID = ''; +global.IS_UID = ''; +global.USR_FIRSTNAME = ''; +global.aux = ''; +Ext.onReady(function() { + Ext.state.Manager.setProvider(new Ext.state.CookieProvider()); + Ext.QuickTips.init(); + + box = new Ext.BoxComponent({ + width : 100, + height : 80, + fieldLabel : ' ', + labelSeparator : ' ', + autoEl : { + tag : 'img', + src : 'users_ViewPhotoGrid?h=' + Math.random() +'&pUID=' + USR_UID + '', + align : 'left' + } + + }); + + //EDIT MODE + if (USR_UID != '') { + allowBlackStatus = true; + + box.setVisible(true); + box.enable(); + + // INFO MODE + if (infoMode) { + displayPreferences = 'display:block;'; + loadUserView(); + readMode = true; + box.setVisible(false); + box.disable(); + + } + else + { + displayPreferences = 'display:none;'; + loadUserData(); + readMode = false; + canEdit = false; + } + + } + else { + allowBlackStatus=false; + box.setVisible(false); + box.disable(); + displayPreferences = 'display:none;'; + readMode = false; + canEdit = false; + } + + + profileFields = new Ext.form.FieldSet({ + title : _('ID_PROFILE'), + items : [ + box, + { + xtype : 'fileuploadfield', + id : 'USR_PHOTO', + emptyText : _('ID_PLEASE_SELECT_PHOTO'), + fieldLabel : _('ID_PHOTO'), + name : 'USR_PHOTO', + buttonText : '', + width : 260, + buttonCfg : { + iconCls : 'upload-icon' + } + + },{ + xtype : 'label', + id : 'lblMaxFileSize', + fieldLabel : _('ID_MAX_FILE_SIZE'), + text : MAX_FILES_SIZE, + width : 400 + + } +/* + ,{ + xtype: 'fileuploadfield', + id: 'USR_RESUME', + emptyText: _('ID_PLEASE_SELECT_FILE'), + fieldLabel: _('ID_RESUME'), + name: 'USR_RESUME', + buttonText: '', + width: 260, + buttonCfg:{ + iconCls: 'upload-icon' + } + } +*/ + + ] + }); + storeCountry = new Ext.data.Store( { + proxy : new Ext.data.HttpProxy( { + url : 'usersAjax', + method : 'POST' + }), + reader : new Ext.data.JsonReader( { + fields : [ { + name : 'IC_UID' + }, { + name : 'IC_NAME' + } ] + }) + }); + comboCountry = new Ext.form.ComboBox({ + fieldLabel : _('ID_COUNTRY'), + hiddenName : 'USR_COUNTRY', + id : 'USR_COUNTRY', + store : storeCountry, + valueField : 'IC_UID', + displayField : 'IC_NAME', + triggerAction : 'all', + emptyText : _('ID_SELECT'), + selectOnFocus : true, + width : 180, + autocomplete : true, + typeAhead : true, + mode : 'local', + listeners : { + select : function(combo,record,index){ + global.IC_UID = this.getValue(); + comboRegion.store.removeAll(); + comboLocation.store.removeAll(); + comboRegion.clearValue(); + storeRegion.load({ + params : { + action : 'stateList', + IC_UID : global.IC_UID + } + }); + comboLocation.setValue(''); + comboRegion.store.on('load',function(store) { + comboRegion.setValue(''); + }); + } + } + }); + storeCountry.load({ + params : {"action" : "countryList"} + }); + + storeRegion = new Ext.data.Store( { + proxy : new Ext.data.HttpProxy( { + url : 'usersAjax', + method : 'POST' + }), + reader : new Ext.data.JsonReader( { + fields : [ { + name : 'IS_UID' + }, { + name : 'IS_NAME' + } ] + }) + }); + comboRegion = new Ext.form.ComboBox({ + fieldLabel : _('ID_STATE_REGION'), + hiddenName : 'USR_REGION', + id : 'USR_REGION', + store : storeRegion, + valueField : 'IS_UID', + displayField : 'IS_NAME', + triggerAction : 'all', + emptyText : _('ID_SELECT'), + selectOnFocus : true, + width : 180, + autocomplete : true, + typeAhead : true, + mode : 'local', + listeners : { + select : function(combo, record, index) { + global.IS_UID = this.getValue(); + comboLocation.enable(); + comboLocation.clearValue(); + storelocation.load({ + params : { + action : 'locationList', + IC_UID : global.IC_UID, + IS_UID : global.IS_UID + } + }); + comboLocation.store.on('load', function(store) { + comboLocation.setValue(''); + }); + } + } + }); + + storelocation = new Ext.data.Store( { + proxy : new Ext.data.HttpProxy( { + url : 'usersAjax', + method : 'POST' + }), + reader : new Ext.data.JsonReader( { + fields : [ { + name : 'IL_UID' + }, { + name : 'IL_NAME' + } ] + }) + }); + comboLocation = new Ext.form.ComboBox({ + fieldLabel : _('ID_LOCATION'), + hiddenName : 'USR_LOCATION', + id : 'USR_LOCATION', + store : storelocation, + valueField : 'IL_UID', + displayField : 'IL_NAME', + triggerAction : 'all', + emptyText : TRANSLATIONS.ID_SELECT, + width : 180, + autocomplete : true, + typeAhead : true, + mode : 'local' + + }); + + comboReplacedBy = new Ext.form.ComboBox({ + fieldLabel : _('ID_REPLACED_BY'), + hiddenName : 'USR_REPLACED_BY', + id : 'USR_REPLACED_BY', + store : new Ext.data.Store( { + proxy : new Ext.data.HttpProxy( { + url : 'usersAjax', + method : 'POST' + }), + baseParams : {action : 'usersList'}, + reader : new Ext.data.JsonReader( { + fields : [ { + name : 'USR_UID' + }, { + name : 'USER_FULLNAME' + } ] + }), + autoLoad:true + }), + valueField : 'USR_UID', + displayField : 'USER_FULLNAME', + emptyText : TRANSLATIONS.ID_SELECT, + width : 180, + selectOnFocus : true, + editable : false, + triggerAction: 'all', + mode: 'local' + + }); + + + dateField = new Ext.form.DateField({ + id : 'USR_DUE_DATE', + fieldLabel : _('ID_EXPIRATION_DATE'), + format : 'Y-m-d', + editable : false, + readOnly : readMode, + width : 120, + value : (new Date().add(Date.YEAR, 1)).format('Y-m-d') + }); + + + comboCalendar = new Ext.form.ComboBox({ + fieldLabel : _('ID_CALENDAR'), + hiddenName : 'USR_CALENDAR', + id : 'USR_CALENDAR', + readOnly : readMode, + store : new Ext.data.Store( { + proxy : new Ext.data.HttpProxy( { + url : 'usersAjax', + method : 'POST' + }), + baseParams : {action : 'availableCalendars'}, + reader : new Ext.data.JsonReader( { + fields : [ { + name : 'CALENDAR_UID' + }, { + name : 'CALENDAR_NAME' + } ] + }), + autoLoad : true + }), + + valueField : 'CALENDAR_UID', + displayField : 'CALENDAR_NAME', + emptyText : TRANSLATIONS.ID_SELECT, + width : 180, + selectOnFocus : true, + editable : false, + allowBlank : false, + triggerAction : 'all', + mode : 'local' + + }); + comboCalendar.store.on('load', function(store) { + comboCalendar.setValue(store.getAt(0).get('CALENDAR_UID')); + }); + + var status = new Ext.data.SimpleStore({ + fields : ['USR_STATUS', 'status'], + data : [['ACTIVE', 'ACTIVE'], ['INACTIVE', 'INACTIVE'], ['VACATION', 'ON VACATION']] + }); + comboStatus = new Ext.form.ComboBox({ + xtype : 'combo', + name : 'status', + fieldLabel : _('ID_STATUS'), + hiddenName : 'USR_STATUS', + id : 'USR_STATUS', + mode : 'local', + store : status, + displayField : 'status', + valueField : 'USR_STATUS', + width : 120, + typeAhead : true, + triggerAction : 'all', + editable : false, + value : 'ACTIVE', + readOnly : readMode + }); + + + comboRole = new Ext.form.ComboBox({ + fieldLabel : _('ID_ROLE'), + hiddenName : 'USR_ROLE', + id : 'USR_ROLE', + readOnly : readMode, + store : new Ext.data.Store( { + proxy : new Ext.data.HttpProxy( { + url : 'usersAjax', + method : 'POST' + }), + baseParams : {action : 'rolesList'}, + reader : new Ext.data.JsonReader( { + fields : [ { + name : 'ROL_UID' + }, { + name : 'ROL_CODE' + } ] + }), + autoLoad : true + }), + + valueField : 'ROL_UID', + displayField : 'ROL_CODE', + emptyText : TRANSLATIONS.ID_SELECT, + width : 260, + selectOnFocus : true, + editable : false, + allowBlank : false, + triggerAction : 'all', + mode : 'local' + + + }); + comboRole.store.on('load',function(store) { + comboRole.setValue(store.getAt(0).get('ROL_UID')); + }) + + informationFields = new Ext.form.FieldSet({ + title : _('ID_PERSONAL_INFORMATION'), + items : [ + { + id : 'USR_FIRSTNAME', + fieldLabel : _('ID_FIRSTNAME'), + xtype : 'textfield', + width : 260, + allowBlank : false + }, + { + id : 'USR_LASTNAME', + fieldLabel : _('ID_LASTNAME'), + xtype : 'textfield', + width : 260, + allowBlank : false + }, + { + id : 'USR_USERNAME', + fieldLabel : _('ID_USER_ID'), + xtype : 'textfield', + width : 260, + allowBlank : false + }, + { + id : 'USR_EMAIL', + fieldLabel : _('ID_EMAIL'), + vtype : 'email', + xtype : 'textfield', + width : 260, + allowBlank : false + }, + { + xtype : 'textarea', + name : 'USR_ADDRESS', + fieldLabel : _('ID_ADDRESS'), + labelSeparator : '', + height : 50, + width : 260 + }, + { + id : 'USR_ZIP_CODE', + fieldLabel : _('ID_ZIP_CODE'), + xtype : 'textfield', + width : 260 + }, + comboCountry, + comboRegion, + comboLocation, + { + id : 'USR_PHONE', + fieldLabel : _('ID_PHONE'), + xtype : 'textfield', + width : 260 + }, + { + id : 'USR_POSITION', + fieldLabel : _('ID_POSITION'), + xtype : 'textfield', + width : 260 + }, + comboReplacedBy, + dateField, + comboCalendar, + comboStatus, + comboRole + + ] + }); + passwordFields = new Ext.form.FieldSet({ + title : _('ID_CHANGE_PASSWORD'), + items : [ + { + id : 'USR_NEW_PASS', + fieldLabel : _('ID_NEW_PASSWORD'), + xtype : 'textfield', + inputType : 'password', + width : 260, + allowBlank : allowBlackStatus + }, + { + id : 'USR_CNF_PASS', + fieldLabel : _('ID_CONFIRM_PASSWORD'), + xtype : 'textfield', + inputType : 'password', + width : 260, + allowBlank : allowBlackStatus + } + + ] + }); + + comboDefaultMainMenuOption = new Ext.form.ComboBox({ + fieldLabel : _('ID_DEFAULT_MAIN_MENU_OPTION'), + hiddenName : 'PREF_DEFAULT_MENUSELECTED', + id : 'PREF_DEFAULT_MENUSELECTED', + store : new Ext.data.Store( { + proxy : new Ext.data.HttpProxy( { + url : 'usersAjax', + method : 'POST' + }), + baseParams : {action : 'defaultMainMenuOptionList'}, + reader : new Ext.data.JsonReader( { + fields : [ { + name : 'id' + }, { + name : 'name' + } ] + }), + autoLoad : true + }), + valueField : 'id', + displayField : 'name', + emptyText : TRANSLATIONS.ID_SELECT, + width : 260, + selectOnFocus : true, + editable : false, + triggerAction : 'all', + mode : 'local' + }); + comboDefaultMainMenuOption.store.on('load',function(store) { + comboDefaultMainMenuOption.setValue(store.getAt(0).get('id')); + }); + comboDefaultCasesMenuOption = new Ext.form.ComboBox({ + fieldLabel : _('ID_DEFAULT_CASES_MENU_OPTION'), + hiddenName : 'PREF_DEFAULT_CASES_MENUSELECTED', + id : 'PREF_DEFAULT_CASES_MENUSELECTED', + store : new Ext.data.Store( { + proxy : new Ext.data.HttpProxy( { + url : 'usersAjax', + method : 'POST' + }), + baseParams : {action : 'defaultCasesMenuOptionList'}, + reader : new Ext.data.JsonReader( { + fields : [ { + name : 'id' + }, { + name : 'name' + } ] + }), + autoLoad : true + }), + valueField : 'id', + displayField : 'name', + emptyText : TRANSLATIONS.ID_SELECT, + width : 260, + selectOnFocus : true, + editable : false, + triggerAction : 'all', + mode : 'local' + }); + comboDefaultCasesMenuOption.store.on('load',function(store) { + comboDefaultCasesMenuOption.setValue(store.getAt(0).get('id')); + }); + + preferencesFields = new Ext.form.FieldSet({ + title : _('ID_PREFERENCES'), + // for display or not a preferences FieldSet + style : displayPreferences, + items : [{ + xtype : 'hidden', + name : 'PREF_DEFAULT_LANG', + value : '' + }, + comboDefaultMainMenuOption, + comboDefaultCasesMenuOption + ] + }); + + frmDetails = new Ext.FormPanel({ + id : 'frmDetails', + labelWidth : 250, + labelAlign :'right', + autoScroll : true, + fileUpload : true, + width : 800, + bodyStyle : 'padding:10px', + waitMsgTarget : true, + frame : true, + defaults : { + anchor : '100%', + allowBlank : false, + resizable : true, + msgTarget : 'side', + align : 'center' + }, + items : [ + informationFields, + passwordFields, + profileFields, + preferencesFields + ], + buttons : [ + { + text : _('ID_SAVE'), + handler: saveUser + + + }, + { + text : _('ID_CANCEL'), + handler : function(){ + if (!infoMode) { + location.href = 'users_List'; + } + else{ + frmDetails.hide(); + frmSumary.show(); + } + //location.href = 'users_List'; + } + //hidden:readMode + } + ] + + }); + + + //USERS SUMMARY + box2 = new Ext.BoxComponent({ + width: 100, + height: 80, + fieldLabel : ' ', + labelSeparator : ' ', + autoEl : { + tag : 'img', + src : 'users_ViewPhotoGrid?h=' + Math.random() +'&pUID=' + USR_UID + '', + align : 'left'} + }); + profileFields2 = new Ext.form.FieldSet({ + title : _('ID_PROFILE'), + items : [ + box2 + ] + }); + informationFields2 = new Ext.form.FieldSet({ + title : _('ID_PERSONAL_INFORMATION'), + items : [ + { + id : 'USR_FIRSTNAME2', + fieldLabel : _('ID_FIRSTNAME'), + xtype : 'label', + width : 260 + }, + { + id : 'USR_LASTNAME2', + fieldLabel : _('ID_LASTNAME'), + xtype : 'label', + width : 260 + }, + { + id : 'USR_USERNAME2', + fieldLabel : _('ID_USER_ID'), + xtype : 'label', + width : 260 + }, + { + id : 'USR_EMAIL2', + fieldLabel : _('ID_EMAIL'), + xtype : 'label', + width : 260 + }, + { + xtype : 'label', + id : 'USR_ADDRESS2', + fieldLabel : _('ID_ADDRESS'), + width : 260 + }, + { + id : 'USR_ZIP_CODE2', + fieldLabel : _('ID_ZIP_CODE'), + xtype : 'label', + width : 260 + }, + { + id : 'USR_COUNTRY2', + fieldLabel : _('ID_COUNTRY'), + xtype : 'label', + width : 260 + }, + { + id : 'USR_CITY2', + fieldLabel : _('ID_STATE_REGION'), + xtype : 'label', + width : 260 + }, + { + id : 'USR_LOCATION2', + fieldLabel : _('ID_LOCATION'), + xtype : 'label', + width : 260 + }, + { + id : 'USR_PHONE2', + fieldLabel : _('ID_PHONE'), + xtype : 'label', + width : 260 + }, + { + id : 'USR_POSITION2', + fieldLabel : _('ID_POSITION'), + xtype : 'label', + width : 260 + }, + { + id : 'USR_REPLACED_BY2', + fieldLabel : _('ID_REPLACED_BY'), + xtype : 'label', + width : 260 + }, + { + id : 'USR_DUE_DATE2', + fieldLabel : _('ID_EXPIRATION_DATE'), + xtype : 'label', + width : 260 + }, + { + id : 'USR_CALENDAR2', + fieldLabel : _('ID_CALENDAR'), + xtype : 'label', + width : 260 + }, + { + id : 'USR_STATUS2', + fieldLabel : _('ID_STATUS'), + xtype : 'label', + width : 260 + }, + { + id : 'USR_ROLE2', + fieldLabel : _('ID_ROLE'), + xtype : 'label', + width : 260 + } + + ] + }); + passwordFields2 = new Ext.form.FieldSet({ + title : _('ID_PASSWORD'), + items : [ + { + id : 'USR_PASSWORD2', + fieldLabel : _('ID_PASSWORD'), + xtype : 'label', + width : 260, + text : ' *******************' + } + ] + }); + preferencesFields2 = new Ext.form.FieldSet({ + title : _('ID_PREFERENCES'), + // for display or not a preferences FieldSet + style : displayPreferences, + items : [ + { + id : 'PREF_DEFAULT_MAIN_MENU_OPTION2', + fieldLabel : _('ID_DEFAULT_MAIN_MENU_OPTION'), + xtype : 'label', + width : 260 + }, + { + id : 'PREF_DEFAULT_CASES_MENUSELECTED2', + fieldLabel : _('ID_DEFAULT_CASES_MENU_OPTION'), + xtype : 'label', + width : 260 + } + ] + }); + + frmSumary = new Ext.FormPanel({ + id : 'frmSumary', + labelWidth : 320, + labelAlign : 'right', + autoScroll : true, + fileUpload : true, + width : 800, + //height:1000, + bodyStyle : 'padding:10px', + waitMsgTarget : true, + frame : true, + items : [ + box2, + //profileFields2, + informationFields2, + //passwordFields2, + preferencesFields2 + ], + buttons : [ + { + text : _('ID_EDIT'), + handler : editUser, + hidden : canEdit + } + + ] + + }); + + if (infoMode) { + document.body.appendChild(defineUserPanel()); + frmSumary.render('users-panel'); + } + else { + frmDetails.render(document.body); + } + +}); + +function defineUserPanel() +{ + + var isIE = ( navigator.userAgent.indexOf('MSIE')>0 ) ? true : false; + var eDivPanel = document.createElement("div"); + var eDivUsersPanel = document.createElement("div"); + eDivPanel.setAttribute('id', 'panel'); + eDivUsersPanel.setAttribute('id', 'users-panel'); + if (isIE) { + eDivPanel.style.setAttribute('text-align','center'); + eDivPanel.style.setAttribute('margin','0px 0px'); + eDivUsersPanel.style.setAttribute('width','800px'); + eDivUsersPanel.style.setAttribute('margin','0px auto'); + eDivUsersPanel.style.setAttribute('text-align','left'); + } + else { + eDivPanel.style.setProperty('text-align','center',null); + eDivPanel.style.setProperty('margin','0px 0px',null); + eDivUsersPanel.style.setProperty('width','800px',null); + eDivUsersPanel.style.setProperty('margin','0px auto',null); + eDivUsersPanel.style.setProperty('text-align','left',null); + } + eDivPanel.appendChild(eDivUsersPanel); + return eDivPanel; +} + +function editUser() +{ + document.body.appendChild(defineUserPanel()); + frmDetails.render('users-panel'); + + frmSumary.hide(); + frmDetails.show(); +} +function saveUser() +{ + + var newPass = frmDetails.getForm().findField('USR_NEW_PASS').getValue(); + var confPass = frmDetails.getForm().findField('USR_CNF_PASS').getValue(); + if (confPass === newPass) { + Ext.getCmp('frmDetails').getForm().submit( { + + url : 'usersAjax', + params : { + action : 'saveUser', + USR_UID : USR_UID, + USR_CITY : global.IS_UID + }, + waitMsg : _('ID_SAVING_PROCESS'), + timeout : 36000, + success : function(obj, resp) { + if (!infoMode) { + location.href = 'users_List'; + } + else { + location.href = '../users/myInfo?type=reload'; + } + + }, + failure : function(obj, resp) { + if (typeof resp.result == "undefined") + { + Ext.Msg.alert( _('ID_ERROR'),_('ID_SOME_FIELDS_REQUIRED')); + } + else{ + if (resp.result.msg){ + var message = resp.result.msg.split(','); + Ext.Msg.alert( _('ID_WARNING'), ''+message[0]+'

'+message[1]+'

'+message[2]); + } + if (resp.result.fileError) { + Ext.Msg.alert( _('ID_ERROR'),_('ID_FILE_TOO_BIG')); + } + if (resp.result.error) { + Ext.Msg.alert( _('ID_ERROR'), resp.result.error); + } + } + + } + }); + } + else + Ext.Msg.alert( _('ID_ERROR'), _('ID_PASSWORDS_DONT_MATCH')); +} + + +// Load data for Edit mode +function loadUserData() +{ + Ext.Ajax.request({ + url : 'usersAjax', + params : { + 'action' : 'userData', + USR_UID : USR_UID + }, + waitMsg : _('ID_UPLOADING_PROCESS_FILE'), + success : function(r,o){ + var data = Ext.util.JSON.decode(r.responseText); + + Ext.getCmp('frmDetails').getForm().setValues({ + USR_FIRSTNAME : data.user.USR_FIRSTNAME, + USR_LASTNAME : data.user.USR_LASTNAME, + USR_USERNAME : data.user.USR_USERNAME, + USR_EMAIL : data.user.USR_EMAIL, + USR_ADDRESS : data.user.USR_ADDRESS, + USR_ZIP_CODE : data.user.USR_ZIP_CODE, + USR_PHONE : data.user.USR_PHONE, + USR_POSITION : data.user.USR_POSITION, + USR_DUE_DATE : data.user.USR_DUE_DATE, + USR_STATUS : data.user.USR_STATUS + }) + + + storeCountry.load({ + params : { + action : 'countryList' + } + }); + + storeRegion.load({ + params : { + action : 'stateList', + IC_UID : data.user.USR_COUNTRY + } + }); + + storelocation.load({ + params : { + action : 'locationList', + IC_UID : data.user.USR_COUNTRY, + IS_UID : data.user.USR_CITY + } + }); + comboCountry.store.on('load',function(store) { + comboCountry.setValue(data.user.USR_COUNTRY); + }); + global.IC_UID = data.user.USR_COUNTRY; + + comboRegion.store.on('load',function(store) { + comboRegion.setValue(data.user.USR_CITY); + }); + + global.IS_UID = data.user.USR_CITY; + comboLocation.store.on('load',function(store) { + comboLocation.setValue(data.user.USR_LOCATION); + }); + + comboReplacedBy.store.on('load',function(store) { + comboReplacedBy.setValue(data.user.USR_REPLACED_BY); + }); + comboRole.store.on('load',function(store) { + comboRole.setValue(data.user.USR_ROLE); + }); + comboCalendar.store.on('load',function(store) { + comboCalendar.setValue(data.user.USR_CALENDAR); + }); + + }, + + failure : function(r, o) { + //viewport.getEl().unmask(); + } + }); +} +// Load data for Edit mode +function loadUserView() +{ + Ext.Ajax.request({ + url : 'usersAjax', + params : { + 'action' : 'userData', + USR_UID : USR_UID + }, + waitMsg : _('ID_UPLOADING_PROCESS_FILE'), + success : function(r,o){ + var data = Ext.util.JSON.decode(r.responseText); + + Ext.getCmp('frmDetails').getForm().setValues({ + USR_FIRSTNAME : data.user.USR_FIRSTNAME, + USR_LASTNAME : data.user.USR_LASTNAME, + USR_USERNAME : data.user.USR_USERNAME, + USR_EMAIL : data.user.USR_EMAIL, + USR_ADDRESS : data.user.USR_ADDRESS, + USR_ZIP_CODE : data.user.USR_ZIP_CODE, + USR_PHONE : data.user.USR_PHONE, + USR_POSITION : data.user.USR_POSITION, + USR_DUE_DATE : data.user.USR_DUE_DATE, + USR_STATUS : data.user.USR_STATUS + }); + Ext.getCmp('USR_FIRSTNAME2').setText(data.user.USR_FIRSTNAME); + Ext.getCmp('USR_LASTNAME2').setText(data.user.USR_LASTNAME); + Ext.getCmp('USR_USERNAME2').setText(data.user.USR_USERNAME); + Ext.getCmp('USR_EMAIL2').setText(data.user.USR_EMAIL); + Ext.getCmp('USR_ADDRESS2').setText(data.user.USR_ADDRESS); + Ext.getCmp('USR_ZIP_CODE2').setText(data.user.USR_ZIP_CODE); + + Ext.getCmp('USR_COUNTRY2').setText(data.user.USR_COUNTRY_NAME); + Ext.getCmp('USR_CITY2').setText(data.user.USR_CITY_NAME); + Ext.getCmp('USR_LOCATION2').setText(data.user.USR_LOCATION_NAME); + + Ext.getCmp('USR_PHONE2').setText(data.user.USR_PHONE); + Ext.getCmp('USR_POSITION2').setText(data.user.USR_POSITION); + Ext.getCmp('USR_REPLACED_BY2').setText(data.user.REPLACED_NAME); + Ext.getCmp('USR_DUE_DATE2').setText(data.user.USR_DUE_DATE); + Ext.getCmp('USR_STATUS2').setText(data.user.USR_STATUS); + Ext.getCmp('USR_ROLE2').setText(data.user.USR_ROLE); + + + Ext.getCmp('PREF_DEFAULT_MAIN_MENU_OPTION2').setText(data.user.MENUSELECTED_NAME); + Ext.getCmp('PREF_DEFAULT_CASES_MENUSELECTED2').setText(data.user.CASES_MENUSELECTED_NAME); + + storeCountry.load({ + params : { + action : 'countryList' + } + }); + + storeRegion.load({ + params : { + action : 'stateList', + IC_UID : data.user.USR_COUNTRY + } + }); + + storelocation.load({ + params : { + action : 'locationList', + IC_UID : data.user.USR_COUNTRY, + IS_UID : data.user.USR_CITY + } + }); + comboCountry.store.on('load',function(store) { + comboCountry.setValue(data.user.USR_COUNTRY); + }); + global.IC_UID = data.user.USR_COUNTRY; + + comboRegion.store.on('load',function(store) { + comboRegion.setValue(data.user.USR_CITY); + }); + + global.IS_UID = data.user.USR_CITY; + comboLocation.store.on('load',function(store) { + comboLocation.setValue(data.user.USR_LOCATION); + }); + + comboReplacedBy.store.on('load',function(store) { + comboReplacedBy.setValue(data.user.USR_REPLACED_BY); + }); + comboRole.store.on('load',function(store) { + comboRole.setValue(data.user.USR_ROLE); + }); + comboCalendar.store.on('load',function(store) { + comboCalendar.setValue(data.user.USR_CALENDAR); + }); + + //for preferences on the configurations table + comboDefaultMainMenuOption.store.on('load',function(store) { + comboDefaultMainMenuOption.setValue(data.user.PREF_DEFAULT_MENUSELECTED); + }); + comboDefaultCasesMenuOption.store.on('load',function(store) { + //comboDefaultCasesMenuOption.setValue(''); + comboDefaultCasesMenuOption.setValue(data.user.PREF_DEFAULT_CASES_MENUSELECTED); + }); + }, + failure:function(r,o) { + //viewport.getEl().unmask(); + } + }); + +} + + diff --git a/workflow/engine/templates/users/usersList.js b/workflow/engine/templates/users/usersList.js index 5e14ebeff..8491c80ea 100755 --- a/workflow/engine/templates/users/usersList.js +++ b/workflow/engine/templates/users/usersList.js @@ -116,10 +116,15 @@ Ext.onReady(function(){ text: _('ID_SEARCH'), handler: DoSearch }); - - contextMenu = new Ext.menu.Menu({ - items: [editButton, deleteButton,'-',groupsButton,'-',authenticationButton,'-',summaryButton] - }); + + contextMenuConfig = new Array(); + contextMenuConfig.push(editButton); + contextMenuConfig.push(deleteButton); + contextMenuConfig.push('-'); + contextMenuConfig.push(groupsButton); + contextMenuConfig.push('-'); + contextMenuConfig.push(summaryButton); + contextMenu = new Ext.menu.Menu(contextMenuConfig); searchText = new Ext.form.TextField ({ id: 'searchTxt', @@ -154,7 +159,7 @@ Ext.onReady(function(){ deleteButton.enable(); groupsButton.enable(); //reassignButton.enable(); - authenticationButton.enable(); + // authenticationButton.enable(); summaryButton.enable(); }, rowdeselect: function(sm){ @@ -162,7 +167,7 @@ Ext.onReady(function(){ deleteButton.disable(); groupsButton.disable(); //reassignButton.disable(); - authenticationButton.disable(); + //authenticationButton.disable(); summaryButton.disable(); } } @@ -300,10 +305,10 @@ Ext.onReady(function(){ store: store, cm: cmodel, sm: smodel, - tbar: [newButton, '-',summaryButton,'-', editButton, deleteButton,/*'-',groupsButton,'-',authenticationButton,*/ {xtype: 'tbfill'},_('ID_AUTH_SOURCES')+': ',comboAuthSources,'-', searchText,clearTextButton,searchButton], + tbar: [newButton, '-',summaryButton,'-', editButton, deleteButton, '-', groupsButton, /* '-',authenticationButton, */ {xtype: 'tbfill'}, /* _('ID_AUTH_SOURCES')+': ',comboAuthSources,'-', */ searchText,clearTextButton,searchButton], bbar: bbarpaging, listeners: { - rowdblclick: SummaryTabOpen + rowdblclick : EditUserAction }, view: new Ext.grid.GroupingView({ forceFit:true, @@ -349,7 +354,7 @@ DoNothing = function(){}; //Open New User Form NewUserAction = function(){ - location.href = 'users_New'; + location.href = 'usersNew'; }; //Delete User Action @@ -415,7 +420,7 @@ SummaryTabOpen = function(){ EditUserAction = function(){ var uid = infoGrid.getSelectionModel().getSelected(); if (uid) { - location.href = 'users_Edit?USR_UID=' + uid.data.USR_UID+'&USR_AUTH_SOURCE=' + uid.data.USR_AUTH_SOURCE; + location.href = 'usersEdit?USR_UID=' + uid.data.USR_UID+'&USR_AUTH_SOURCE=' + uid.data.USR_AUTH_SOURCE; } }; diff --git a/workflow/engine/templates/users/usersLoad.php b/workflow/engine/templates/users/usersLoad.php new file mode 100644 index 000000000..00511e2bd --- /dev/null +++ b/workflow/engine/templates/users/usersLoad.php @@ -0,0 +1,42 @@ + + + + + + + \ No newline at end of file diff --git a/workflow/engine/templates/users/usersReload.php b/workflow/engine/templates/users/usersReload.php new file mode 100644 index 000000000..22b7c6fed --- /dev/null +++ b/workflow/engine/templates/users/usersReload.php @@ -0,0 +1,20 @@ + + + + + + + \ No newline at end of file