Esempio n. 1
0
 public static function getDepartmentLimitation()
 {
     $currentUser = erLhcoreClassUser::instance();
     $LimitationDepartament = '';
     $userData = $currentUser->getUserData(true);
     if ($userData->all_departments == 0) {
         $userDepartaments = erLhcoreClassUserDep::getUserDepartaments($currentUser->getUserID());
         if (count($userDepartaments) == 0) {
             return false;
         }
         $LimitationDepartament = '(lh_transfer.dep_id IN (' . implode(',', $userDepartaments) . '))';
         return $LimitationDepartament;
     }
     return true;
 }
 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');
     }
 }
 public static function getOnlineOperators($currentUser, $canListOnlineUsersAll = false)
 {
     $LimitationDepartament = '';
     $userData = $currentUser->getUserData(true);
     $filter = array();
     if ($userData->all_departments == 0 && $canListOnlineUsersAll == false) {
         $userDepartaments = erLhcoreClassUserDep::getUserDepartaments($currentUser->getUserID());
         if (count($userDepartaments) == 0) {
             return array();
         }
         $index = array_search(-1, $userDepartaments);
         if ($index !== false) {
             unset($userDepartaments[$index]);
         }
         $filter['customfilter'][] = '(dep_id IN (' . implode(',', $userDepartaments) . ') OR user_id = ' . $currentUser->getUserID() . ')';
     }
     $filter['filtergt']['last_activity'] = time() - 120;
     $filter['limit'] = 10;
     $filter['sort'] = 'last_activity DESC';
     $filter['groupby'] = 'user_id';
     return self::getList($filter);
 }
if ($showDepartmentsStats == true) {
    /**
     * Departments stats
     * */
    $limitList = is_numeric($Params['user_parameters_unordered']['limitd']) ? (int) $Params['user_parameters_unordered']['limitd'] : 10;
    $filter = array('ignore_fields' => erLhcoreClassChat::$chatListIgnoreField);
    $filter['limit'] = $limitList;
    if (is_array($Params['user_parameters_unordered']['departmentd']) && !empty($Params['user_parameters_unordered']['departmentd'])) {
        erLhcoreClassChat::validateFilterIn($Params['user_parameters_unordered']['departmentd']);
        $filter['filterin']['id'] = $Params['user_parameters_unordered']['departmentd'];
    }
    // Add permission check if operator does not have permission to see all departments stats
    if ($showDepartmentsStatsAll === false) {
        $userData = $currentUser->getUserData(true);
        if ($userData->all_departments == 0) {
            $userDepartaments = erLhcoreClassUserDep::getUserDepartaments($currentUser->getUserID());
            if (!empty($userDepartaments)) {
                if (isset($filter['filterin']['id'])) {
                    $validDepartments = array_intersect($userDepartaments, $filter['filterin']['id']);
                    if (!empty($validDepartments)) {
                        $filter['filterin']['id'] = $validDepartments;
                    } else {
                        $filter['filterin']['id'] = array(-1);
                    }
                } else {
                    $filter['filterin']['id'] = $userDepartaments;
                }
            } else {
                $filter['filterin']['id'] = array(-1);
                // No departments
            }
Esempio n. 5
0
 public static function hasAccessToRead($chat)
 {
     $currentUser = erLhcoreClassUser::instance();
     $userData = $currentUser->getUserData(true);
     if ($userData->all_departments == 0) {
         /*
          * --From now permission is strictly by assigned department, not by chat owner
          *
          * Finally decided to keep this check, it allows more advance permissions configuration
          * */
         if ($chat->user_id == $currentUser->getUserID()) {
             return true;
         }
         $userDepartaments = erLhcoreClassUserDep::getUserDepartaments($currentUser->getUserID());
         if (count($userDepartaments) == 0) {
             return false;
         }
         if (in_array($chat->dep_id, $userDepartaments)) {
             if ($currentUser->hasAccessTo('lhchat', 'allowopenremotechat') == true) {
                 return true;
             } elseif ($chat->user_id == 0 || $chat->user_id == $currentUser->getUserID()) {
                 return true;
             }
             return false;
         }
         return false;
     }
     return true;
 }
Esempio n. 6
0
 public static function getSession()
 {
     if (!isset(self::$persistentSession)) {
         self::$persistentSession = new ezcPersistentSession(ezcDbInstance::get(), new ezcPersistentCodeManager('./pos/lhdepartament'));
     }
     return self::$persistentSession;
 }
?>
</h5>
	
		<?php 
if (isset($account_updated_departaments) && $account_updated_departaments == 'done') {
    $msg = erTranslationClassLhTranslation::getInstance()->getTranslation('user/account', 'Account updated');
    ?>
			<?php 
    include erLhcoreClassDesign::designtpl('lhkernel/alert_success.tpl.php');
    ?>
		<?php 
}
?>
		
		<?php 
$userDepartaments = erLhcoreClassUserDep::getUserDepartaments($user->id);
?>
		
		<form action="<?php 
echo erLhcoreClassDesign::baseurl('user/edit');
?>
/<?php 
echo $user->id;
?>
#departments" method="post">
		
			<?php 
include erLhcoreClassDesign::designtpl('lhkernel/csfr_token.tpl.php');
?>
		
		    <label><input type="checkbox" value="on" name="all_departments" <?php 
 public function getFields()
 {
     $currentUser = erLhcoreClassUser::instance();
     $userDepartments = erLhcoreClassUserDep::parseUserDepartmetnsForFilter($currentUser->getUserID());
     return array('name' => array('type' => 'text', 'trans' => erTranslationClassLhTranslation::getInstance()->getTranslation('abstract/proactivechatinvitation', 'Name for personal purposes'), 'required' => true, 'validation_definition' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw')), 'operator_name' => array('type' => 'text', 'trans' => erTranslationClassLhTranslation::getInstance()->getTranslation('abstract/proactivechatinvitation', 'Operator name'), 'required' => false, 'hidden' => true, 'validation_definition' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw')), 'position' => array('type' => 'text', 'trans' => erTranslationClassLhTranslation::getInstance()->getTranslation('abstract/proactivechatinvitation', 'Position'), 'required' => true, 'hidden' => true, 'validation_definition' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw')), 'siteaccess' => array('type' => 'text', 'trans' => erTranslationClassLhTranslation::getInstance()->getTranslation('abstract/proactivechatinvitation', 'Language, leave empty for all. E.g lit, rus, ger etc...'), 'required' => false, 'hidden' => true, 'validation_definition' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw')), 'time_on_site' => array('type' => 'text', 'trans' => erTranslationClassLhTranslation::getInstance()->getTranslation('abstract/proactivechatinvitation', 'Time on site in seconds'), 'required' => false, 'hidden' => true, 'validation_definition' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'int')), 'pageviews' => array('type' => 'text', 'trans' => erTranslationClassLhTranslation::getInstance()->getTranslation('abstract/proactivechatinvitation', 'Pageviews'), 'required' => false, 'validation_definition' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw')), 'referrer' => array('type' => 'text', 'trans' => erTranslationClassLhTranslation::getInstance()->getTranslation('abstract/proactivechatinvitation', 'Referrer domain without www, E.g google keyword will match any of google domain'), 'required' => false, 'hidden' => true, 'validation_definition' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw')), 'hide_after_ntimes' => array('type' => 'text', 'trans' => erTranslationClassLhTranslation::getInstance()->getTranslation('abstract/proactivechatinvitation', 'How many times user show invitation, 0 - untill users closes it, > 0 limits.'), 'required' => false, 'hidden' => true, 'validation_definition' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'int')), 'requires_email' => array('type' => 'checkbox', 'trans' => erTranslationClassLhTranslation::getInstance()->getTranslation('abstract/proactivechatinvitation', 'Requires e-mail'), 'required' => false, 'validation_definition' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'boolean')), 'requires_username' => array('type' => 'checkbox', 'trans' => erTranslationClassLhTranslation::getInstance()->getTranslation('abstract/proactivechatinvitation', 'Requires name'), 'required' => false, 'validation_definition' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'boolean')), 'requires_phone' => array('type' => 'checkbox', 'trans' => erTranslationClassLhTranslation::getInstance()->getTranslation('abstract/proactivechatinvitation', 'Requires phone'), 'required' => false, 'validation_definition' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'boolean')), 'show_random_operator' => array('type' => 'checkbox', 'trans' => erTranslationClassLhTranslation::getInstance()->getTranslation('abstract/proactivechatinvitation', 'Show random operator profile'), 'required' => false, 'hidden' => true, 'validation_definition' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'boolean')), 'operator_ids' => array('type' => 'text', 'trans' => erTranslationClassLhTranslation::getInstance()->getTranslation('abstract/proactivechatinvitation', 'Enter operators IDs from whom random operator should be shown, separated by comma'), 'required' => false, 'hidden' => true, 'validation_definition' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'string')), 'identifier' => array('type' => 'text', 'trans' => erTranslationClassLhTranslation::getInstance()->getTranslation('abstract/proactivechatinvitation', 'Identifier, for what identifier this message should be shown, leave empty for all'), 'required' => false, 'hidden' => true, 'validation_definition' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'string')), 'tag' => array('type' => 'text', 'trans' => erTranslationClassLhTranslation::getInstance()->getTranslation('abstract/proactivechatinvitation', 'Tag'), 'required' => false, 'hidden' => true, 'validation_definition' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'string')), 'dep_id' => array('type' => 'combobox', 'trans' => erTranslationClassLhTranslation::getInstance()->getTranslation('abstract/proactivechatinvitation', 'Department'), 'required' => false, 'hidden' => true, 'source' => 'erLhcoreClassModelDepartament::getList', 'hide_optional' => $userDepartments !== true, 'params_call' => $userDepartments === true ? array() : array('filterin' => array('id' => $userDepartments)), 'validation_definition' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'int')), 'executed_times' => array('type' => 'none', 'hide_edit' => true, 'trans' => erTranslationClassLhTranslation::getInstance()->getTranslation('abstract/proactivechatinvitation', 'Matched times'), 'required' => false, 'validation_definition' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw')), 'message' => array('type' => 'textarea', 'trans' => erTranslationClassLhTranslation::getInstance()->getTranslation('abstract/proactivechatinvitation', 'Message to user'), 'required' => true, 'hidden' => true, 'validation_definition' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw')), 'message_returning' => array('type' => 'textarea', 'trans' => erTranslationClassLhTranslation::getInstance()->getTranslation('abstract/proactivechatinvitation', 'Message to returning user'), 'required' => false, 'hidden' => true, 'validation_definition' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw')), 'message_returning_nick' => array('type' => 'text', 'trans' => erTranslationClassLhTranslation::getInstance()->getTranslation('abstract/proactivechatinvitation', 'Nick which will be used if we cannot determine returning user name'), 'required' => false, 'hidden' => true, 'validation_definition' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw')), 'wait_message' => array('type' => 'text', 'trans' => erTranslationClassLhTranslation::getInstance()->getTranslation('abstract/proactivechatinvitation', 'Wait message. Visible then users starts chat and is waiting for someone to accept a chat.'), 'required' => false, 'hidden' => true, 'validation_definition' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw')), 'wait_timeout' => array('type' => 'text', 'trans' => erTranslationClassLhTranslation::getInstance()->getTranslation('abstract/proactivechatinvitation', 'Wait timeout. Time in seconds before timeout message is shown.'), 'required' => false, 'hidden' => true, 'validation_definition' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw')), 'timeout_message' => array('type' => 'text', 'trans' => erTranslationClassLhTranslation::getInstance()->getTranslation('abstract/proactivechatinvitation', 'Show visitor this message then wait timeout passes.'), 'required' => false, 'hidden' => true, 'validation_definition' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw')), 'repeat_number' => array('type' => 'text', 'trans' => erTranslationClassLhTranslation::getInstance()->getTranslation('abstract/proactivechatinvitation', 'How many times repeat message?'), 'required' => true, 'hidden' => true, 'validation_definition' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'int', array('min_range' => 1))));
 }
 /**
  * 
  * @param erLhcoreClassModelChat $chat
  * 
  * @return boolean
  */
 public static function hasAccessToRead(erLhcoreClassModelChat $chat)
 {
     if (self::$apiKey->user->all_departments == 0) {
         if ($chat->user_id == self::$apiKey->user->id) {
             return true;
         }
         $userDepartaments = erLhcoreClassUserDep::getUserDepartaments(self::$apiKey->user->id);
         if (count($userDepartaments) == 0) {
             return false;
         }
         if (in_array($chat->dep_id, $userDepartaments)) {
             if (self::hasAccessTo('lhchat', 'allowopenremotechat') == true || $chat->status == erLhcoreClassModelChat::STATUS_OPERATORS_CHAT) {
                 return true;
             } elseif ($chat->user_id == 0 || $chat->user_id == self::$apiKey->user->id) {
                 return true;
             }
             return false;
         }
         return false;
     }
     return true;
 }
Esempio n. 10
0
    }
    $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));
Esempio n. 11
0
        $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));
Esempio n. 12
0
    $chat->status_sub = erLhcoreClassModelChat::STATUS_SUB_OWNER_CHANGED;
    $chat->user_typing_txt = (string) $chat->user . ' ' . htmlspecialchars_decode(erTranslationClassLhTranslation::getInstance()->getTranslation('chat/accepttrasnfer', 'has joined the chat!'), ENT_QUOTES);
    $chat->user_typing = time();
    // Change department if user cannot read current department, so chat appears in right menu
    $filter = erLhcoreClassUserDep::parseUserDepartmetnsForFilter($currentUser->getUserID());
    if ($filter !== true && !in_array($chat->dep_id, $filter)) {
        $dep_id = erLhcoreClassUserDep::getDefaultUserDepartment();
        if ($dep_id > 0) {
            $chat->dep_id = $dep_id;
            $chat->status_sub = erLhcoreClassModelChat::STATUS_SUB_OWNER_CHANGED;
        }
    }
}
if (!erLhcoreClassChat::hasAccessToRead($chat)) {
    if ($currentUser->getUserID() == $chatTransfer->transfer_to_user_id) {
        $dep_id = erLhcoreClassUserDep::getDefaultUserDepartment();
        if ($dep_id > 0) {
            $chat->dep_id = $dep_id;
            $chat->status_sub = erLhcoreClassModelChat::STATUS_SUB_OWNER_CHANGED;
        }
    } else {
        exit;
        // User does not have permission to assign chat to himself
    }
}
// All ok, we can make changes
erLhcoreClassChat::getSession()->update($chat);
erLhcoreClassTransfer::getSession()->delete($chatTransfer);
if ($Params['user_parameters_unordered']['postaction'] == 'singlewindow') {
    erLhcoreClassModule::redirect('chat/single/' . $chat->id);
    exit;
Esempio n. 13
0
$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();
Esempio n. 14
0
?>
</h5>
	
		<?php 
if (isset($account_updated_departaments) && $account_updated_departaments == 'done') {
    $msg = erTranslationClassLhTranslation::getInstance()->getTranslation('user/account', 'Account updated');
    ?>
			<?php 
    include erLhcoreClassDesign::designtpl('lhkernel/alert_success.tpl.php');
    ?>
		<?php 
}
?>
		
		<?php 
$userDepartaments = erLhcoreClassUserDep::getUserDepartamentsIndividual($user->id);
$userDepartamentsGroup = erLhcoreClassModelDepartamentGroupUser::getUserGroupsIds($user->id);
?>
		
		<form action="<?php 
echo erLhcoreClassDesign::baseurl('user/edit');
?>
/<?php 
echo $user->id;
?>
#departments" method="post">
		
		    <?php 
include erLhcoreClassDesign::designtpl('lhuser/account/departments_assignment.tpl.php');
?>
		    
Esempio n. 15
0
    }
    $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();
Esempio n. 16
0
     $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"])) {
Esempio n. 17
0
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept');
header('Content-Type: application/json');
try {
    erLhcoreClassRestAPIHandler::validateRequest();
    if (isset($_GET['user_id']) && is_numeric($_GET['user_id'])) {
        $userData = erLhcoreClassModelUser::fetch((int) $_GET['user_id']);
    } elseif (isset($_GET['username']) && !empty($_GET['username'])) {
        $userData = erLhcoreClassModelUser::findOne(array('filter' => array('username' => $_GET['username'])));
    } elseif (isset($_GET['email']) && !empty($_GET['email'])) {
        $userData = erLhcoreClassModelUser::findOne(array('filter' => array('email' => $_GET['email'])));
    }
    if (!$userData instanceof erLhcoreClassModelUser) {
        throw new Exception('User could not be found!');
    }
    if ($_GET['status'] == 'true') {
        $userData->hide_online = 0;
        $text = 'flash_on';
    } else {
        $text = 'flash_off';
        $userData->hide_online = 1;
    }
    $userData->operation_admin .= "\$('#online-offline-user').text('" . $text . "');";
    erLhcoreClassUser::getSession()->update($userData);
    erLhcoreClassUserDep::setHideOnlineStatus($userData);
    erLhcoreClassRestAPIHandler::outputResponse(array('offline' => $userData->hide_online));
    erLhcoreClassChatEventDispatcher::getInstance()->dispatch('chat.operator_status_changed', array('user' => &$userData, 'reason' => 'rest_api'));
} catch (Exception $e) {
    echo json_encode(array('error' => true, 'result' => $e->getMessage()));
}
exit;
Esempio n. 18
0
<?php

$tpl = erLhcoreClassTemplate::getInstance('lhdepartament/edit.tpl.php');
$Departament = erLhcoreClassDepartament::getSession()->load('erLhcoreClassModelDepartament', (int) $Params['user_parameters']['departament_id']);
$userDepartments = true;
/**
 * Append user departments filter
 * */
if ($currentUser->hasAccessTo('lhdepartment', 'manageall') !== true) {
    $userDepartments = erLhcoreClassUserDep::parseUserDepartmetnsForFilter($currentUser->getUserID());
    if ($userDepartments !== true) {
        if (!in_array($Departament->id, $userDepartments)) {
            erLhcoreClassModule::redirect('departament/departaments');
            exit;
        }
    }
}
if (isset($_POST['Cancel_departament'])) {
    erLhcoreClassModule::redirect('departament/departaments');
    exit;
}
if (isset($_POST['Delete_departament'])) {
    if (!isset($_POST['csfr_token']) || !$currentUser->validateCSFRToken($_POST['csfr_token']) || !$currentUser->hasAccessTo('lhdepartament', 'delete') || !$Departament->can_delete) {
        erLhcoreClassModule::redirect('departament/departaments');
        exit;
    }
    $Departament->removeThis();
    erLhcoreClassModule::redirect('departament/departaments');
    exit;
}
if (isset($_POST['Update_departament']) || isset($_POST['Save_departament'])) {
 /**
  * Handlers requests like
  *
  * May 08 23:02:11 [Warning] [default] [default] {"action":"ping","user":"******"}
  * May 08 23:02:14 [Warning] [default] [default] {"action":"disconnect","user":"******","server":"xmpp.livehelperchat.com"}
  * May 08 23:21:52 [Warning] [default] [default] {"action":"connect","user":"******","server":"xmpp.livehelperchat.com"}
  */
 public static function handleOperatorPing($jsonContent)
 {
     $params = json_decode($jsonContent, true);
     $xmppService = erLhcoreClassModule::getExtensionInstance('erLhcoreClassExtensionXmppservice');
     // If ping just update last action
     if ($params['action'] == 'ping') {
         // Parse user parts
         $userParts = self::parseXMPPUser($params['user']);
         // Fetches user id by xmpp username
         $userId = self::getUserIDByXMPPUsername($userParts['xmppuser']);
         // Updates last activity
         if (is_numeric($userId)) {
             self::updateActivityByUserId($userId, time() + $xmppService->settings['append_time']);
         } else {
             throw new Exception("Could not find LHC user by user - " . $userParts['xmppuser']);
         }
     } elseif ($params['action'] == 'disconnect' || $params['action'] == 'connect') {
         // Fetches user id by xmpp username
         $userId = self::getUserIDByXMPPUsername($params['user'] . '@' . $params['server']);
         // Updates last activity to zero
         if (is_numeric($userId)) {
             self::updateActivityByUserId($userId, $params['action'] == 'connect' ? time() + $xmppService->settings['append_time'] : 0);
             if ($params['action'] == 'connect') {
                 $userData = erLhcoreClassModelUser::fetch($userId);
                 if ($userData instanceof erLhcoreClassModelUser && $userData->hide_online == 1) {
                     $userData->hide_online = 0;
                     erLhcoreClassUser::getSession()->update($userData);
                     erLhcoreClassUserDep::setHideOnlineStatus($userData);
                 }
             }
         } else {
             throw new Exception("Could not find LHC user by user - " . $params['user'] . '@' . $params['server']);
         }
     }
     return true;
 }