本文整理汇总了PHP中erLhcoreClassUserDep::addUserDepartaments方法的典型用法代码示例。如果您正苦于以下问题:PHP erLhcoreClassUserDep::addUserDepartaments方法的具体用法?PHP erLhcoreClassUserDep::addUserDepartaments怎么用?PHP erLhcoreClassUserDep::addUserDepartaments使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类erLhcoreClassUserDep
的用法示例。
在下文中一共展示了erLhcoreClassUserDep::addUserDepartaments方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loginBySSO
public static function loginBySSO($params)
{
$settings = (include 'extension/singlesignon/settings/settings.ini.php');
// Try to find operator by our logins
if (isset($params[$settings['attr_map']['username']][0])) {
$username = $params[$settings['attr_map']['username']][0];
if (erLhcoreClassModelUser::userExists($username)) {
$user = array_shift(erLhcoreClassModelUser::getUserList(array('limit' => 1, 'filter' => array('username'))));
erLhcoreClassUser::instance()->setLoggedUser($user->id);
} else {
$user = new erLhcoreClassModelUser();
foreach ($settings['attr_map'] as $attr => $ssoAttr) {
$user->{$attr} = $params[$settings['attr_map'][$attr]][0];
}
foreach ($settings['default_attributes'] as $attr => $value) {
$user->{$attr} = $value;
}
$user->password = sha1(erLhcoreClassModelForgotPassword::randomPassword() . rand(0, 1000) . microtime());
$user->saveThis();
// Set that users sees all pending chats
erLhcoreClassModelUserSetting::setSetting('show_all_pending', 1, $user->id);
// Set default departments
erLhcoreClassUserDep::addUserDepartaments($settings['default_departments'], $user->id, $user);
// Cleanup if previously existed
erLhcoreClassModelGroupUser::removeUserFromGroups($user->id);
// Assign user to default group
foreach ($settings['default_user_groups'] as $group_id) {
$groupUser = new erLhcoreClassModelGroupUser();
$groupUser->group_id = $group_id;
$groupUser->user_id = $user->id;
$groupUser->saveThis();
}
erLhcoreClassUser::instance()->setLoggedUser($user->id);
}
return true;
} else {
throw new Exception('Username field not found');
}
}
示例2: array
}
$tpl->set('account_updated', 'done');
$tpl->set('tab', 'tab_pending');
}
if (isset($_POST['UpdateDepartaments_account'])) {
if (!isset($_POST['csfr_token']) || !$currentUser->validateCSFRToken($_POST['csfr_token'])) {
erLhcoreClassModule::redirect('user/userlist');
exit;
}
$globalDepartament = array();
if (isset($_POST['all_departments']) && $_POST['all_departments'] == 'on') {
$UserData->all_departments = 1;
$globalDepartament[] = 0;
} else {
$UserData->all_departments = 0;
$globalDepartament[] = -1;
}
erLhcoreClassUser::getSession()->update($UserData);
if (isset($_POST['UserDepartament']) && count($_POST['UserDepartament']) > 0) {
$globalDepartament = array_merge($_POST['UserDepartament'], $globalDepartament);
}
if (count($globalDepartament) > 0) {
erLhcoreClassUserDep::addUserDepartaments($globalDepartament, $Params['user_parameters']['user_id'], $UserData);
} else {
erLhcoreClassUserDep::addUserDepartaments(array(), $Params['user_parameters']['user_id'], $UserData);
}
$tpl->set('account_updated_departaments', 'done');
}
$tpl->set('user', $UserData);
$Result['content'] = $tpl->fetch();
$Result['path'] = array(array('url' => erLhcoreClassDesign::baseurl('system/configuration'), 'title' => erTranslationClassLhTranslation::getInstance()->getTranslation('user/edit', 'System configuration')), array('url' => erLhcoreClassDesign::baseurl('user/userlist'), 'title' => erTranslationClassLhTranslation::getInstance()->getTranslation('user/edit', 'Users')), array('title' => erTranslationClassLhTranslation::getInstance()->getTranslation('user/edit', 'User edit') . ' - ' . $UserData->name . ' ' . $UserData->surname));
示例3: array_merge
$UserData->all_departments = 1;
$globalDepartament[] = 0;
} else {
$UserData->all_departments = 0;
}
if (count($Errors) == 0) {
$UserData->setPassword($form->Password);
$UserData->email = $form->Email;
$UserData->name = $form->Name;
$UserData->username = $form->Username;
erLhcoreClassUser::getSession()->save($UserData);
if (isset($_POST['UserDepartament']) && count($_POST['UserDepartament']) > 0) {
$globalDepartament = array_merge($_POST['UserDepartament'], $globalDepartament);
}
if (count($globalDepartament) > 0) {
erLhcoreClassUserDep::addUserDepartaments($globalDepartament, $UserData->id, $UserData);
}
erLhcoreClassModelGroupUser::removeUserFromGroups($UserData->id);
foreach ($UserData->user_groups_id as $group_id) {
$groupUser = new erLhcoreClassModelGroupUser();
$groupUser->group_id = $group_id;
$groupUser->user_id = $UserData->id;
$groupUser->saveThis();
}
// Store photo
if (isset($_FILES["UserPhoto"]) && is_uploaded_file($_FILES["UserPhoto"]["tmp_name"]) && $_FILES["UserPhoto"]["error"] == 0 && erLhcoreClassImageConverter::isPhoto('UserPhoto')) {
$dir = 'var/userphoto/' . date('Y') . 'y/' . date('m') . '/' . date('d') . '/' . $UserData->id . '/';
erLhcoreClassChatEventDispatcher::getInstance()->dispatch('user.edit.photo_path', array('dir' => &$dir, 'storage_id' => $UserData->id));
erLhcoreClassFileUpload::mkdirRecursive($dir);
$file = qqFileUploader::upload($_FILES, 'UserPhoto', $dir);
if (empty($file["errors"])) {
示例4: array
}
$globalDepartament = array();
if (isset($_POST['all_departments']) && $_POST['all_departments'] == 'on') {
$UserData->all_departments = 1;
$globalDepartament[] = 0;
} else {
$UserData->all_departments = 0;
}
erLhcoreClassUser::getSession()->update($UserData);
if (isset($_POST['UserDepartament']) && count($_POST['UserDepartament']) > 0) {
$globalDepartament = array_merge($_POST['UserDepartament'], $globalDepartament);
}
if (count($globalDepartament) > 0) {
erLhcoreClassUserDep::addUserDepartaments($globalDepartament, false, $UserData);
} else {
erLhcoreClassUserDep::addUserDepartaments(array(), false, $UserData);
}
$tpl->set('account_updated_departaments', 'done');
$tpl->set('tab', 'tab_departments');
}
// If already set during account update
if (!isset($UserData)) {
$UserData = $currentUser->getUserData();
}
$tpl->set('editdepartaments', $allowEditDepartaments);
$tpl->set('user', $UserData);
if (erLhcoreClassUser::instance()->hasAccessTo('lhuser', 'personalcannedmsg')) {
/**
* Canned messages part
* */
$cannedMessage = new erLhcoreClassModelCannedMsg();
示例5: array
$tpl->set('errors', $Errors);
}
}
if (isset($_POST['UpdatePending_account'])) {
if (!isset($_POST['csfr_token']) || !$currentUser->validateCSFRToken($_POST['csfr_token'])) {
erLhcoreClassModule::redirect('user/edit', '/' . $UserData->id);
exit;
}
$showAllPending = erLhcoreClassUserValidator::validateShowAllPendingOption();
erLhcoreClassModelUserSetting::setSetting('show_all_pending', $showAllPending, $UserData->id);
$tpl->set('account_updated', 'done');
$tpl->set('tab', 'tab_pending');
}
if (isset($_POST['UpdateDepartaments_account'])) {
if (!isset($_POST['csfr_token']) || !$currentUser->validateCSFRToken($_POST['csfr_token'])) {
erLhcoreClassModule::redirect('user/edit', '/' . $UserData->id);
exit;
}
$globalDepartament = erLhcoreClassUserValidator::validateDepartments($UserData, array('all_departments_0_global_value' => -1));
erLhcoreClassUser::getSession()->update($UserData);
if (count($globalDepartament) > 0) {
erLhcoreClassUserDep::addUserDepartaments($globalDepartament, $UserData->id, $UserData);
} else {
erLhcoreClassUserDep::addUserDepartaments(array(), $UserData->id, $UserData);
}
$tpl->set('account_updated_departaments', 'done');
}
$tpl->set('user', $UserData);
$Result['content'] = $tpl->fetch();
$Result['path'] = array(array('url' => erLhcoreClassDesign::baseurl('system/configuration'), 'title' => erTranslationClassLhTranslation::getInstance()->getTranslation('user/edit', 'System configuration')), array('url' => erLhcoreClassDesign::baseurl('user/userlist'), 'title' => erTranslationClassLhTranslation::getInstance()->getTranslation('user/edit', 'Users')), array('title' => erTranslationClassLhTranslation::getInstance()->getTranslation('user/edit', 'User edit') . ' - ' . $UserData->name . ' ' . $UserData->surname));
erLhcoreClassChatEventDispatcher::getInstance()->dispatch('user.edit_path', array('result' => &$Result));
示例6: isset
$userDepartamentsGroup = isset($_POST['UserDepartamentGroup']) ? $_POST['UserDepartamentGroup'] : array();
$userParams = array('show_all_pending' => 1, 'global_departament' => array());
$tpl->set('tab', $Params['user_parameters_unordered']['tab'] == 'canned' ? 'tab_canned' : '');
if (isset($_POST['Update_account'])) {
if (!isset($_POST['csfr_token']) || !$currentUser->validateCSFRToken($_POST['csfr_token'])) {
erLhcoreClassModule::redirect('user/new');
exit;
}
$Errors = erLhcoreClassUserValidator::validateUserNew($UserData, $userParams);
if (count($Errors) == 0) {
try {
$db = ezcDbInstance::get();
$db->beginTransaction();
erLhcoreClassUser::getSession()->save($UserData);
if (count($userParams['global_departament']) > 0) {
erLhcoreClassUserDep::addUserDepartaments($userParams['global_departament'], $UserData->id, $UserData);
}
$UserData->setUserGroups();
$userPhotoErrors = erLhcoreClassUserValidator::validateUserPhoto($UserData);
if ($userPhotoErrors !== false && count($userPhotoErrors) == 0) {
$UserData->saveThis();
}
erLhcoreClassModelDepartamentGroupUser::addUserDepartmentGroups($UserData, erLhcoreClassUserValidator::validateDepartmentsGroup($UserData));
erLhcoreClassModelUserSetting::setSetting('show_all_pending', $userParams['show_all_pending'], $UserData->id);
erLhcoreClassChatEventDispatcher::getInstance()->dispatch('user.user_created', array('userData' => &$UserData, 'password' => $UserData->password_front));
$db->commit();
erLhcoreClassModule::redirect('user/userlist');
exit;
} catch (Exception $e) {
$tpl->set('errors', array($e->getMessage()));
$UserData->removeFile();