Пример #1
0
 public static function setupSMTP(PHPMailer &$phpMailer)
 {
     // Allow extension override mail settings
     $response = erLhcoreClassChatEventDispatcher::getInstance()->dispatch('chatmail.setup_smtp', array('phpmailer' => &$phpMailer));
     if ($response !== false && isset($response['status']) && $response['status'] == erLhcoreClassChatEventDispatcher::STOP_WORKFLOW) {
         return;
     }
     $smtpData = erLhcoreClassModelChatConfig::fetch('smtp_data');
     $data = (array) $smtpData->data;
     if (isset($data['sender']) && $data['sender'] != '') {
         $phpMailer->Sender = $data['sender'];
     }
     if ($phpMailer->From == 'root@localhost') {
         $phpMailer->From = $data['default_from'];
     }
     if ($phpMailer->FromName == 'Root User') {
         $phpMailer->FromName = $data['default_from_name'];
     }
     if (isset($data['use_smtp']) && $data['use_smtp'] == 1) {
         $phpMailer->IsSMTP();
         $phpMailer->Host = $data['host'];
         $phpMailer->Port = $data['port'];
         if ($data['username'] != '' && $data['password'] != '') {
             $phpMailer->Username = $data['username'];
             $phpMailer->Password = $data['password'];
             $phpMailer->SMTPAuth = true;
             $phpMailer->From = isset($data['default_from']) ? $data['default_from'] : $data['username'];
         } else {
             $phpMailer->From = '';
         }
     }
 }
Пример #2
0
 public static function translate($access_token, $word, $from, $to)
 {
     $url = 'http://api.microsofttranslator.com/V2/Http.svc/Translate?text=' . urlencode($word) . '&from=' . $from . '&to=' . $to;
     if (empty($word)) {
         throw new Exception(erTranslationClassLhTranslation::getInstance()->getTranslation('chat/translation', 'Missing text to translate'));
     }
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, $url);
     curl_setopt($ch, CURLOPT_HTTPHEADER, array('Authorization:bearer ' . $access_token));
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
     curl_setopt($ch, CURLOPT_TIMEOUT, 5);
     curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
     curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
     $rsp = curl_exec($ch);
     if (strpos($rsp, '<string') === false) {
         throw new Exception($rsp);
     }
     $errors = array();
     erLhcoreClassChatEventDispatcher::getInstance()->dispatch('translate.after_bing_translate', array('word' => &$word, 'errors' => &$errors));
     if (!empty($errors)) {
         throw new Exception(erTranslationClassLhTranslation::getInstance()->getTranslation('chat/translation', 'Could not translate') . ' - ' . implode('; ', $errors));
     }
     preg_match_all('/<string (.*?)>(.*?)<\\/string>/s', $rsp, $matches);
     return htmlspecialchars_decode($matches[2][0]);
 }
 static function getInstance()
 {
     if (self::$evenDispather == NULL) {
         self::$evenDispather = new self();
     }
     return self::$evenDispather;
 }
 public function run()
 {
     include 'extension/nodejshelper/design/nodejshelpertheme/tpl/pagelayouts/parts/nodejshelper_config.tpl.php';
     $this->settings = $nodeJsHelperSettings;
     if ($this->settings['use_publish_notifications'] == true) {
         include_once 'extension/nodejshelper/vendor/predis-1.0.0/autoload.php';
         $dispatcher = erLhcoreClassChatEventDispatcher::getInstance();
         // On what events should NodeJS listening operators be notified
         $dispatcher->listen('chat.sync_back_office', array($this, 'notifyBackOfficeOperators'));
         $dispatcher->listen('chat.chat_started', array($this, 'notifyBackOfficeOperators'));
         $dispatcher->listen('chat.data_changed', array($this, 'notifyBackOfficeOperators'));
         $dispatcher->listen('chat.unread_chat', array($this, 'notifyBackOfficeOperatorsDelay'));
         $dispatcher->listen('chat.data_changed_auto_assign', array($this, 'notifyBackOfficeOperators'));
         $dispatcher->listen('chat.data_changed_assigned_department', array($this, 'notifyBackOfficeOperators'));
         $dispatcher->listen('chat.close', array($this, 'notifyBackOfficeOperators'));
         $dispatcher->listen('chat.delete', array($this, 'notifyBackOfficeOperators'));
         $dispatcher->listen('chat.user_reopened', array($this, 'notifyBackOfficeOperators'));
         $dispatcher->listen('chat.chat_transfer_accepted', array($this, 'notifyBackOfficeOperators'));
         $dispatcher->listen('chat.chat_transfered', array($this, 'notifyBackOfficeOperators'));
         $dispatcher->listen('chat.sync_back_office', array($this, 'notifyBackOfficeOperators'));
         // Listed for desktop client events
         $dispatcher->listen('chat.desktop_client_admin_msg', array($this, 'notifyUserNewMessage'));
         $dispatcher->listen('chat.desktop_client_closed', array($this, 'notifyUserNewMessage'));
         $dispatcher->listen('chat.desktop_client_deleted', array($this, 'notifyUserNewMessage'));
         $dispatcher->listen('chat.messages_added_passive', array($this, 'notifyUserNewMessage'));
         $dispatcher->listen('chat.data_changed_chat', array($this, 'dataChangedChat'));
         $dispatcher->listen('chat.nodjshelper_notify_delay', array($this, 'notifyBackOfficeOperatorsDelay'));
     }
 }
 public function run()
 {
     $this->registerAutoload();
     $dispatcher = erLhcoreClassChatEventDispatcher::getInstance();
     $this->settings = (include 'extension/singlesignon/settings/settings.ini.php');
     // Attatch event listeners
     $dispatcher->listen('chat.close', array($this, 'chatClosed'));
 }
Пример #6
0
 public function getModuleTranslations()
 {
     /**
      * Get's executed before permissions check. It can redirect to frontpage throw permission exception etc
      * */
     erLhcoreClassChatEventDispatcher::getInstance()->dispatch('feature.can_use_forms', array());
     return array('path' => array('url' => erLhcoreClassDesign::baseurl('form/index'), 'title' => erTranslationClassLhTranslation::getInstance()->getTranslation('browseoffer/index', 'Form')), 'permission_delete' => array('module' => 'lhform', 'function' => 'delete_fm'), 'permission' => array('module' => 'lhform', 'function' => 'manage_fm'), 'name' => erTranslationClassLhTranslation::getInstance()->getTranslation('abstract/browserofferinvitation', 'Forms list'));
 }
 public function getModuleTranslations()
 {
     /**
      * Get's executed before permissions check. It can redirect to frontpage throw permission exception etc
      * */
     erLhcoreClassChatEventDispatcher::getInstance()->dispatch('feature.can_use_proactive', array());
     return array('can_use' => $can_use, 'permission_delete' => array('module' => 'lhchat', 'function' => 'administrateinvitations'), 'permission' => array('module' => 'lhchat', 'function' => 'administrateinvitations'), 'name' => erTranslationClassLhTranslation::getInstance()->getTranslation('abstract/proactivechatinvitation', 'Pro active chat invitations'));
 }
 public function getModuleTranslations()
 {
     $metaData = array('permission_delete' => array('module' => 'lhchat', 'function' => 'administrateresponder'), 'permission' => array('module' => 'lhchat', 'function' => 'administrateresponder'), 'name' => erTranslationClassLhTranslation::getInstance()->getTranslation('abstract/proactivechatinvitation', 'Auto responder'));
     /**
      * Get's executed before permissions check. It can redirect to frontpage throw permission exception etc
      * */
     erLhcoreClassChatEventDispatcher::getInstance()->dispatch('feature.can_use_autoresponder', array('object_meta_data' => &$metaData));
     return $metaData;
 }
 public function getModuleTranslations()
 {
     $metaData = array('permission_delete' => array('module' => 'lhsurvey', 'function' => 'manage_survey'), 'permission' => array('module' => 'lhsurvey', 'function' => 'manage_survey'), 'name' => erTranslationClassLhTranslation::getInstance()->getTranslation('abstract/survey', 'Survey'));
     /**
      * Get's executed before permissions check. It can redirect to frontpage throw permission exception etc
      * */
     erLhcoreClassChatEventDispatcher::getInstance()->dispatch('feature.can_use_survey', array('object_meta_data' => &$metaData));
     return $metaData;
 }
 public function getModuleTranslations()
 {
     $metaData = array('path' => array('url' => erLhcoreClassDesign::baseurl('restapi/index'), 'title' => erTranslationClassLhTranslation::getInstance()->getTranslation('theme/index', 'Rest API')), 'permission_delete' => array('module' => 'lhrestapi', 'function' => 'use_admin'), 'permission' => array('module' => 'lhrestapi', 'function' => 'use_admin'), 'name' => erTranslationClassLhTranslation::getInstance()->getTranslation('abstract/product', 'API Key'));
     /**
      * Get's executed before permissions check. It can redirect to frontpage throw permission exception etc
      * */
     erLhcoreClassChatEventDispatcher::getInstance()->dispatch('feature.can_use_product', array('object_meta_data' => &$metaData));
     return $metaData;
 }
 public function getModuleTranslations()
 {
     $metaData = array('path' => array('url' => erLhcoreClassDesign::baseurl('browseoffer/index'), 'title' => erTranslationClassLhTranslation::getInstance()->getTranslation('browseoffer/index', 'Browse offers')), 'permission_delete' => array('module' => 'lhbrowseoffer', 'function' => 'manage_bo'), 'permission' => array('module' => 'lhbrowseoffer', 'function' => 'manage_bo'), 'name' => erTranslationClassLhTranslation::getInstance()->getTranslation('abstract/browserofferinvitation', 'Browser offer invitations'));
     /**
      * Get's executed before permissions check. It can redirect to frontpage throw permission exception etc
      * */
     erLhcoreClassChatEventDispatcher::getInstance()->dispatch('feature.can_use_browse_offers', array('object_meta_data' => &$metaData));
     return $metaData;
 }
 public static function addPageView(erLhcoreClassModelChatOnlineUser $onlineUser)
 {
     $item = new self();
     $item->chat_id = $onlineUser->chat_id;
     $item->online_user_id = $onlineUser->id;
     $item->vtime = time();
     $item->page = $_SERVER['HTTP_REFERER'];
     erLhcoreClassChat::getSession()->save($item);
     erLhcoreClassChatEventDispatcher::getInstance()->dispatch('onlinefootprint.created', array('item' => &$item));
 }
Пример #13
0
 public static function validateAdminTheme(erLhAbstractModelAdminTheme &$clickform)
 {
     $definition = array('Name' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw'), 'header_content' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw'), 'header_css' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw'), 'static_content_name' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw', null, FILTER_REQUIRE_ARRAY), 'static_content_hash' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw', null, FILTER_REQUIRE_ARRAY), 'static_js_content_name' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw', null, FILTER_REQUIRE_ARRAY), 'static_js_content_hash' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw', null, FILTER_REQUIRE_ARRAY), 'static_css_content_name' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw', null, FILTER_REQUIRE_ARRAY), 'static_css_content_hash' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw', null, FILTER_REQUIRE_ARRAY));
     $form = new ezcInputForm(INPUT_POST, $definition);
     $Errors = array();
     $currentUser = erLhcoreClassUser::instance();
     if (!isset($_POST['csfr_token']) || !$currentUser->validateCSFRToken($_POST['csfr_token'])) {
         $Errors[] = erTranslationClassLhTranslation::getInstance()->getTranslation('icclicktocallform/form', 'Invalid CSRF token!');
     }
     if (!$form->hasValidData('Name') || $form->Name == '') {
         $Errors['Name'] = erTranslationClassLhTranslation::getInstance()->getTranslation('icclicktocallform/form', 'Please enter a name');
     } else {
         $clickform->name = $form->Name;
     }
     if ($form->hasValidData('header_content')) {
         $clickform->header_content = $form->header_content;
     }
     if ($form->hasValidData('header_css')) {
         $clickform->header_css = $form->header_css;
     }
     $resourcesArray = array('static_content', 'static_js_content', 'static_css_content');
     $supportedExtensions = array('zip', 'doc', 'docx', 'ttf', 'pdf', 'xls', 'ico', 'gif', 'xlsx', 'jpg', 'jpeg', 'png', 'bmp', 'rar', '7z', 'css', 'js', 'eot', 'woff', 'woff2', 'svg');
     // Validate resources
     foreach ($resourcesArray as $resource) {
         if ($form->hasValidData($resource . '_hash') && !empty($form->{$resource . '_hash'})) {
             $customFields = $currentStaticResources = $clickform->{$resource . '_array'};
             foreach ($form->{$resource . '_hash'} as $key => $customFieldType) {
                 if (!erLhcoreClassSearchHandler::isFile($resource . '_file_' . $key, $supportedExtensions) && !isset($currentStaticResources[$key]['file'])) {
                     $Errors[$resource . '_file_' . $key] = erTranslationClassLhTranslation::getInstance()->getTranslation('icclicktocallform/form', 'File not chosen for') . (isset($form->{$resource . '_name'}[$key]) ? ' - ' . htmlspecialchars($form->{$resource . '_name'}[$key]) : '');
                 }
             }
             // If there is no errors upload files
             if (empty($Errors)) {
                 foreach ($form->{$resource . '_hash'} as $key => $customFieldType) {
                     $customFields[$key]['name'] = $form->{$resource . '_name'}[$key];
                     $customFields[$key]['hash'] = $key;
                     if (erLhcoreClassSearchHandler::isFile($resource . '_file_' . $key, $supportedExtensions)) {
                         // Check there is already uploaded file and remove it
                         $clickform->removeResource($resource, $key);
                         // Store new file if required
                         $dir = 'var/storageadmintheme/' . date('Y') . 'y/' . date('m') . '/' . date('d') . '/' . $clickform->id . '/';
                         erLhcoreClassChatEventDispatcher::getInstance()->dispatch('admintheme.filedir', array('dir' => &$dir, 'storage_id' => $clickform->id));
                         erLhcoreClassFileUpload::mkdirRecursive($dir);
                         $customFields[$key]['file'] = erLhcoreClassSearchHandler::moveUploadedFile($resource . '_file_' . $key, $dir . '/', '.');
                         $customFields[$key]['file_dir'] = $dir;
                     }
                 }
                 $clickform->{$resource} = json_encode($customFields, JSON_HEX_APOS);
             }
         } else {
             $clickform->{$resource} = '';
         }
     }
     return $Errors;
 }
 public function removeThis()
 {
     if (file_exists($this->file_path_server)) {
         unlink($this->file_path_server);
     }
     if ($this->file_path != '') {
         erLhcoreClassFileUpload::removeRecursiveIfEmpty('var/', str_replace('var/', '', $this->file_path));
     }
     erLhcoreClassChatEventDispatcher::getInstance()->dispatch('file.remove_file', array('chat_file' => &$this));
     erLhcoreClassChat::getSession()->delete($this);
 }
Пример #15
0
 public static function validateSurvey(erLhAbstractModelSurveyItem &$surveyItem, erLhAbstractModelSurvey $survey)
 {
     include erLhcoreClassDesign::designtpl('lhsurvey/forms/fields_names.tpl.php');
     $definition = array();
     for ($i = 0; $i < 16; $i++) {
         foreach ($sortOptions as $keyOption => $sortOption) {
             if ($survey->{$keyOption . '_pos'} == $i && $survey->{$keyOption . '_enabled'}) {
                 if ($sortOption['type'] == 'stars') {
                     $definition[$sortOption['field'] . 'Evaluate'] = new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'int', array('min_range' => 1, 'max_range' => $survey->{$sortOption}['field']));
                 } elseif ($sortOption['type'] == 'question') {
                     $definition[$sortOption['field'] . 'Question'] = new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw');
                 } elseif ($sortOption['type'] == 'question_options') {
                     $definition[$sortOption['field'] . 'EvaluateOption'] = new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'int', array('min_range' => 1));
                 }
             }
         }
     }
     $form = new ezcInputForm(INPUT_POST, $definition);
     $Errors = array();
     for ($i = 0; $i < 16; $i++) {
         foreach ($sortOptions as $keyOption => $sortOption) {
             if ($survey->{$keyOption . '_pos'} == $i && $survey->{$keyOption . '_enabled'}) {
                 if ($sortOption['type'] == 'stars') {
                     if (!$form->hasValidData($sortOption['field'] . 'Evaluate')) {
                         if ($survey->{$keyOption . '_req'} == 1) {
                             $Errors[] = '"' . htmlspecialchars(trim($survey->{$keyOption . '_title'})) . '" : ' . erTranslationClassLhTranslation::getInstance()->getTranslation('chat/startchat', 'is required');
                         }
                     } else {
                         $surveyItem->{$sortOption['field']} = $form->{$sortOption['field'] . 'Evaluate'};
                     }
                 } elseif ($sortOption['type'] == 'question') {
                     if (!$form->hasValidData($sortOption['field'] . 'Question') || $form->{$sortOption['field'] . 'Question'} == '' && $survey->{$keyOption . '_req'} == 1) {
                         // @todo Make possible to choose field type in the future
                         $Errors[] = '"' . htmlspecialchars(trim($survey->{$keyOption})) . '" : ' . erTranslationClassLhTranslation::getInstance()->getTranslation('chat/startchat', 'is required');
                     } else {
                         $surveyItem->{$sortOption['field']} = $form->{$sortOption['field'] . 'Question'};
                     }
                 } elseif ($sortOption['type'] == 'question_options') {
                     if (!$form->hasValidData($sortOption['field'] . 'EvaluateOption')) {
                         if ($survey->{$keyOption . '_req'} == 1) {
                             $Errors[] = '"' . htmlspecialchars(trim($survey->{$sortOption['field']})) . '" : ' . erTranslationClassLhTranslation::getInstance()->getTranslation('chat/startchat', 'is required');
                         }
                     } else {
                         $surveyItem->{$sortOption['field']} = $form->{$sortOption['field'] . 'EvaluateOption'};
                     }
                 }
             }
         }
     }
     erLhcoreClassChatEventDispatcher::getInstance()->dispatch('survey.validate', array('survey' => &$survey, 'survey_item' => &$surveyItem, 'errors' => &$Errors));
     return $Errors;
 }
Пример #16
0
 public static function validateSurvey(erLhAbstractModelSurveyItem &$surveyItem, erLhAbstractModelSurvey $survey)
 {
     $definition = array('StarsValue' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'int', array('min_range' => 1, 'max_range' => $survey->max_stars)));
     $form = new ezcInputForm(INPUT_POST, $definition);
     $Errors = array();
     if (!$form->hasValidData('StarsValue')) {
         $Errors[] = erTranslationClassLhTranslation::getInstance()->getTranslation('chat/startchat', 'Please choose a star');
     } else {
         $surveyItem->stars = $form->StarsValue;
     }
     erLhcoreClassChatEventDispatcher::getInstance()->dispatch('survey.validate', array('survey' => &$survey, 'errors' => &$Errors));
     return $Errors;
 }
Пример #17
0
 public function run()
 {
     $dispatcher = erLhcoreClassChatEventDispatcher::getInstance();
     /**
      * We listen to all events, but check is done only in even method. This way we save 1 disk call for configuraiton file read.
      * */
     /**
      * User events
      */
     $dispatcher->listen('chat.close', array($this, 'chatClosed'));
     $dispatcher->listen('chat.chat_started', array($this, 'chatCreated'));
     $dispatcher->listen('chat.chat_offline_request', array($this, 'chatOfflineRequest'));
 }
 public static function validateCannedMessage(erLhcoreClassModelCannedMsg &$cannedMessage, $userDepartments)
 {
     $definition = array('Message' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw'), 'FallbackMessage' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw'), 'Title' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw'), 'ExplainHover' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw'), 'Position' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'int', array('min_range' => 0)), 'Delay' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'int', array('min_range' => 0)), 'DepartmentID' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'int', array('min_range' => 1)), 'AutoSend' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'boolean'));
     $form = new ezcInputForm(INPUT_POST, $definition);
     $Errors = array();
     if (!$form->hasValidData('Message') || $form->Message == '') {
         $Errors[] = erTranslationClassLhTranslation::getInstance()->getTranslation('chat/cannedmsg', 'Please enter a canned message');
     } else {
         $cannedMessage->msg = $form->Message;
     }
     if ($form->hasValidData('FallbackMessage')) {
         $cannedMessage->fallback_msg = $form->FallbackMessage;
     }
     if ($form->hasValidData('Title')) {
         $cannedMessage->title = $form->Title;
     }
     if ($form->hasValidData('ExplainHover')) {
         $cannedMessage->explain = $form->ExplainHover;
     }
     if ($form->hasValidData('AutoSend') && $form->AutoSend == true) {
         $cannedMessage->auto_send = 1;
     } else {
         $cannedMessage->auto_send = 0;
     }
     if ($form->hasValidData('Position')) {
         $cannedMessage->position = $form->Position;
     }
     if ($form->hasValidData('Delay')) {
         $cannedMessage->delay = $form->Delay;
     }
     if ($form->hasValidData('DepartmentID')) {
         $cannedMessage->department_id = $form->DepartmentID;
         if ($userDepartments !== true) {
             if (!in_array($cannedMessage->department_id, $userDepartments)) {
                 $Errors[] = erTranslationClassLhTranslation::getInstance()->getTranslation('chat/cannedmsg', 'Please choose a department');
             }
         }
     } else {
         $response = erLhcoreClassChatEventDispatcher::getInstance()->dispatch('chat.validate_canned_msg_user_departments', array('canned_msg' => &$cannedMessage, 'errors' => &$Errors));
         // Perhaps extension did some internal validation and we don't need anymore validate internaly
         if ($response === false) {
             // User has to choose a department
             if ($userDepartments !== true) {
                 $Errors[] = erTranslationClassLhTranslation::getInstance()->getTranslation('chat/cannedmsg', 'Please choose a department');
             } else {
                 $cannedMessage->department_id = 0;
             }
         }
     }
     return $Errors;
 }
 public function deletePhoto($attr)
 {
     if ($this->{$attr} != '') {
         if (file_exists($this->{$attr . '_path'} . $this->{$attr})) {
             unlink($this->{$attr . '_path'} . $this->{$attr});
         }
         if ($this->{$attr . '_path'} != '') {
             erLhcoreClassFileUpload::removeRecursiveIfEmpty('var/storagetheme/', str_replace('var/storagetheme/', '', $this->{$attr . '_path'}));
         }
         erLhcoreClassChatEventDispatcher::getInstance()->dispatch('theme.edit.remove_' . $attr, array('theme' => &$this, 'path_attr' => $attr . '_path', 'name' => $this->{$attr}));
         $this->{$attr} = '';
         $this->{$attr . '_path'} = '';
     }
 }
Пример #20
0
 public static function translate($apiKey, $word, $from, $to)
 {
     $url = "https://www.googleapis.com/language/translate/v2?key={$apiKey}&q=" . urlencode($word) . "&source={$from}&target={$to}";
     $rsp = self::executeRequest($url);
     $data = json_decode($rsp, true);
     if (isset($data['data']['translations'][0]['translatedText'])) {
         $errors = array();
         erLhcoreClassChatEventDispatcher::getInstance()->dispatch('translate.after_google_translate', array('word' => &$word, 'errors' => &$errors));
         if (!empty($errors)) {
             throw new Exception(erTranslationClassLhTranslation::getInstance()->getTranslation('chat/translation', 'Could not translate') . ' - ' . implode('; ', $errors));
         }
         return htmlspecialchars_decode($data['data']['translations'][0]['translatedText']);
     }
     throw new Exception(erTranslationClassLhTranslation::getInstance()->getTranslation('chat/translation', 'Could not translate') . ' - ' . $rsp);
 }
 public function movePhoto($attr, $isLocal = false, $localFile = false)
 {
     $this->deletePhoto($attr);
     if ($this->id != null) {
         $dir = 'var/storagetheme/' . date('Y') . 'y/' . date('m') . '/' . date('d') . '/' . $this->id . '/';
         erLhcoreClassChatEventDispatcher::getInstance()->dispatch('theme.edit.' . $attr . '_path', array('dir' => &$dir, 'storage_id' => $this->id));
         erLhcoreClassFileUpload::mkdirRecursive($dir);
         if ($isLocal == false) {
             $this->{$attr} = erLhcoreClassSearchHandler::moveUploadedFile('AbstractInput_' . $attr, $dir . '/', '.');
         } else {
             $this->{$attr} = erLhcoreClassSearchHandler::moveLocalFile($localFile, $dir . '/', '.');
         }
         $this->{$attr . '_path'} = $dir;
     } else {
         $this->{$attr . '_pending'} = true;
     }
 }
 public function removeInstanceData()
 {
     foreach (erLhAbstractModelFormCollected::getList(array('limit' => 1000000)) as $item) {
         $item->removeThis();
     }
     foreach (erLhAbstractModelWidgetTheme::getList(array('limit' => 1000000)) as $item) {
         $item->removeThis();
     }
     foreach (erLhcoreClassChat::getList(array('limit' => 1000000)) as $item) {
         $item->removeThis();
     }
     foreach (erLhcoreClassChat::getList(array('limit' => 1000000), 'erLhcoreClassModelChatFile', 'lh_chat_file') as $item) {
         $item->removeThis();
     }
     foreach (erLhcoreClassModelUser::getUserList(array('limit' => 1000000)) as $item) {
         $item->removeFile();
     }
     // Dispatch event for extensions
     erLhcoreClassChatEventDispatcher::getInstance()->dispatch('instance.destroyed', array('instance' => $this));
     return true;
 }
Пример #23
0
 /**
  * Constructor
  *
  * @param $file string the file name you want to load
  */
 function erLhcoreClassTemplate($file = null)
 {
     $cfg = erConfigClassLhConfig::getInstance();
     $this->cacheEnabled = $cfg->getSetting('site', 'templatecache');
     $this->templatecompile = $cfg->getSetting('site', 'templatecompile');
     if (!is_null($file)) {
         $this->file = $file;
     }
     erLhcoreClassChatEventDispatcher::getInstance()->dispatch('tpl.new', array('tpl' => &$this));
     $cacheObj = CSCacheAPC::getMem();
     if (($this->cacheTemplates = $cacheObj->restore('templateCacheArray_version_' . $cacheObj->getCacheVersion('site_version'))) === false) {
         try {
             $this->cacheWriter = new erLhcoreClassCacheStorage('cache/cacheconfig/');
         } catch (Exception $e) {
             $instance = erLhcoreClassSystem::instance();
             if ($instance->SiteAccess != 'site_admin') {
                 // Perhaps user opened site without installing it first?
                 if ($cfg->getSetting('site', 'installed') == false) {
                     header('Location: ' . erLhcoreClassDesign::baseurldirect('site_admin/install/install'));
                     exit;
                 }
                 header('HTTP/1.1 503 Service Temporarily Unavailable');
                 header('Status: 503 Service Temporarily Unavailable');
                 echo "<h1>Make sure cache/cacheconfig is writable by application</h1>";
                 exit;
             } else {
                 throw $e;
             }
         }
         if (($this->cacheTemplates = $this->cacheWriter->restore('templateCache')) == false) {
             try {
                 $this->cacheWriter->store('templateCache', array());
                 $this->cacheTemplates = array();
             } catch (Exception $e) {
                 // Do nothing
             }
             $cacheObj->store('templateCacheArray_version_' . $cacheObj->getCacheVersion('site_version'), array());
         }
     }
 }
 public function removeFile()
 {
     if ($this->filename != '' || $this->filename != '') {
         if (file_exists($this->filepath . $this->filename)) {
             unlink($this->filepath . $this->filename);
         }
         if ($this->filepath != '') {
             erLhcoreClassFileUpload::removeRecursiveIfEmpty('var/userphoto/', str_replace('var/userphoto/', '', $this->filepath));
         }
         erLhcoreClassChatEventDispatcher::getInstance()->dispatch('user.remove_photo', array('user' => &$this));
         $this->filepath = '';
         $this->filename = '';
         $this->saveThis();
     }
 }
Пример #25
0
<?php

$faq = new erLhcoreClassModelFaq();
$response = erLhcoreClassChatEventDispatcher::getInstance()->dispatch('faq.new', array('faq' => $faq));
$tpl = erLhcoreClassTemplate::getInstance('lhfaq/new.tpl.php');
if (isset($_POST['Save'])) {
    if (!isset($_POST['csfr_token']) || !$currentUser->validateCSFRToken($_POST['csfr_token'])) {
        erLhcoreClassModule::redirect();
        exit;
    }
    $Errors = erLhcoreClassFaq::validateFaq($faq);
    if (count($Errors) == 0) {
        $faq->saveThis();
        erLhcoreClassChatEventDispatcher::getInstance()->dispatch('faq.created', array('faq' => &$faq));
        erLhcoreClassModule::redirect('faq/list');
        exit;
    } else {
        $tpl->set('errors', $Errors);
    }
}
if (isset($_POST['Cancel'])) {
    erLhcoreClassModule::redirect('faq/list');
    exit;
}
$tpl->set('faq', $faq);
$Result['content'] = $tpl->fetch();
$Result['path'] = array(array('url' => erLhcoreClassDesign::baseurl('faq/list'), 'title' => erTranslationClassLhTranslation::getInstance()->getTranslation('faq/list', 'FAQ')), array('title' => erTranslationClassLhTranslation::getInstance()->getTranslation('faq/new', 'New question')));
Пример #26
0
<?php

$currentUser = erLhcoreClassUser::instance();
$userData = $currentUser->getUserData(true);
if ($Params['user_parameters']['status'] == 'false') {
    $userData->invisible_mode = 0;
} else {
    $userData->invisible_mode = 1;
}
erLhcoreClassChatEventDispatcher::getInstance()->dispatch('chat.operator_visibility_changed', array('user' => &$userData, 'reason' => 'user_action'));
erLhcoreClassUser::getSession()->update($userData);
exit;
Пример #27
0
             $imgData['restore_image'] = $data['restore_image_data'];
             unset($data['restore_image_data']);
         }
         if (isset($data['minimize_image_data'])) {
             $imgData['minimize_image'] = $data['minimize_image_data'];
             unset($data['minimize_image_data']);
         }
         try {
             $widgetTheme->setState($data);
             $widgetTheme->saveThis();
             foreach ($imgData as $attr => $dataImage) {
                 $imgDataItem = base64_decode($dataImage);
                 if ($imgDataItem !== false) {
                     $dir = 'var/tmpfiles/';
                     $fileName = 'data.' . $data[$attr . '_data_ext'];
                     erLhcoreClassChatEventDispatcher::getInstance()->dispatch('theme.temppath', array('dir' => &$dir));
                     erLhcoreClassFileUpload::mkdirRecursive($dir);
                     $imgPath = $dir . $fileName;
                     file_put_contents($imgPath, $imgDataItem);
                     if (erLhcoreClassImageConverter::isPhotoLocal($imgPath)) {
                         $widgetTheme->movePhoto($attr, true, $imgPath);
                     }
                 }
             }
             $widgetTheme->updateThis();
         } catch (Exception $e) {
             $tpl->set('errors', array(erTranslationClassLhTranslation::getInstance()->getTranslation('theme/import', 'Could not import a new theme!')));
         }
     }
     $tpl->set('updated', true);
 } else {
Пример #28
0
<?php

$Question = erLhcoreClassModelQuestion::fetch((int) $Params['user_parameters']['id']);
$response = erLhcoreClassChatEventDispatcher::getInstance()->dispatch('questionary.edit', array('questionary' => $Question));
$tpl = erLhcoreClassTemplate::getInstance('lhquestionary/edit.tpl.php');
$validTabs = array('answers', 'voting');
$tab = in_array((string) $Params['user_parameters_unordered']['tab'], $validTabs) ? (string) $Params['user_parameters_unordered']['tab'] : '';
$tpl->set('tab', $tab);
if (isset($_POST['CancelAction'])) {
    erLhcoreClassModule::redirect('questionary/list');
    exit;
}
if (isset($_POST['UpdateAction']) || isset($_POST['SaveAction'])) {
    $definition = array('Question' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw'), 'QuestionIntro' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw'), 'Location' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw'), 'Active' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'boolean'), 'Priority' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'int'), 'Revote' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'int'));
    if (!isset($_POST['csfr_token']) || !$currentUser->validateCSFRToken($_POST['csfr_token'])) {
        erLhcoreClassModule::redirect();
        exit;
    }
    $form = new ezcInputForm(INPUT_POST, $definition);
    $Errors = array();
    if (!$form->hasValidData('Question') || $form->Question == '') {
        $Errors[] = erTranslationClassLhTranslation::getInstance()->getTranslation('questionary/edit', 'Please enter a question!');
    }
    if ($form->hasValidData('QuestionIntro')) {
        $Question->question_intro = $form->QuestionIntro;
    }
    if ($form->hasValidData('Location')) {
        $Question->location = $form->Location;
    } else {
        $Question->location = '';
    }
Пример #29
0
        $Errors[] = 'Please enter valid date';
    }
    if ($form->hasValidData('AttrInt1')) {
        $Instance->attr_int_1 = $form->AttrInt1;
    }
    if ($form->hasValidData('AttrInt2')) {
        $Instance->attr_int_2 = $form->AttrInt2;
    }
    if ($form->hasValidData('AttrInt3')) {
        $Instance->attr_int_3 = $form->AttrInt3;
    }
    if (!isset($_POST['csfr_token']) || !$currentUser->validateCSFRToken($_POST['csfr_token'])) {
        erLhcoreClassModule::redirect('instance/list');
        exit;
    }
    if (count($Errors) == 0) {
        $Instance->saveThis();
        if (isset($_POST['Save_departament'])) {
            erLhcoreClassModule::redirect('instance/list');
            exit;
        } else {
            $tpl->set('updated', true);
        }
    } else {
        $tpl->set('errors', $Errors);
    }
}
erLhcoreClassChatEventDispatcher::getInstance()->dispatch('instance.editinstance', array('instance' => &$Instance));
$tpl->set('instance', $Instance);
$Result['content'] = $tpl->fetch();
$Result['path'] = array(array('url' => erLhcoreClassDesign::baseurl('system/configuration'), 'title' => erTranslationClassLhTranslation::getInstance()->getTranslation('department/edit', 'System configuration')), array('url' => erLhcoreClassDesign::baseurl('instance/list'), 'title' => erTranslationClassLhTranslation::getInstance()->getTranslation('instance/edit', 'Instances')), array('title' => erTranslationClassLhTranslation::getInstance()->getTranslation('instance/edit', 'Edit instance') . ' - ' . $Instance->address));
Пример #30
0
 } else {
     if ((string) $Params['user_parameters_unordered']['hash'] != '') {
         list($chatID, $hash) = explode('_', $Params['user_parameters_unordered']['hash']);
         $chat = erLhcoreClassModelChat::fetch($chatID);
     }
 }
 erLhcoreClassChat::setTimeZoneByChat($chat);
 if ($chat->hash == $hash) {
     $survey = erLhAbstractModelSurvey::fetch($Params['user_parameters_unordered']['survey']);
     if ($survey instanceof erLhAbstractModelSurvey) {
         $surveyItem = erLhAbstractModelSurveyItem::getInstance($chat, $survey);
         if (isset($_POST['Vote'])) {
             $errors = erLhcoreClassSurveyValidator::validateSurvey($surveyItem, $survey);
             if (empty($errors)) {
                 $surveyItem->saveOrUpdate();
                 erLhcoreClassChatEventDispatcher::getInstance()->dispatch('survey.filled', array('chat' => &$chat, 'survey' => $survey, 'survey_item' => &$surveyItem));
                 $tpl->set('just_stored', true);
             } else {
                 $tpl->set('errors', $errors);
             }
         }
         $tpl->set('chat', $chat);
         $tpl->set('survey', $survey);
         $tpl->set('survey_item', $surveyItem);
         $Result['chat'] = $chat;
     } else {
         $tpl->setFile('lhchat/errors/surveynotexists.tpl.php');
     }
 } else {
     $tpl->setFile('lhchat/errors/chatnotexists.tpl.php');
 }