本文整理汇总了PHP中erLhcoreClassModelUser::saveThis方法的典型用法代码示例。如果您正苦于以下问题:PHP erLhcoreClassModelUser::saveThis方法的具体用法?PHP erLhcoreClassModelUser::saveThis怎么用?PHP erLhcoreClassModelUser::saveThis使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类erLhcoreClassModelUser
的用法示例。
在下文中一共展示了erLhcoreClassModelUser::saveThis方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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');
}
}