本文整理汇总了PHP中erLhcoreClassChatEventDispatcher::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP erLhcoreClassChatEventDispatcher::getInstance方法的具体用法?PHP erLhcoreClassChatEventDispatcher::getInstance怎么用?PHP erLhcoreClassChatEventDispatcher::getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类erLhcoreClassChatEventDispatcher
的用法示例。
在下文中一共展示了erLhcoreClassChatEventDispatcher::getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: translate
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]);
}
示例2: setupSMTP
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 = '';
}
}
}
示例3: run
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'));
}
}
示例4: run
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'));
}
示例5: getModuleTranslations
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'));
}
示例6: getModuleTranslations
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'));
}
示例7: getModuleTranslations
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;
}
示例8: getModuleTranslations
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;
}
示例9: addPageView
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));
}
示例10: validateAdminTheme
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;
}
示例11: removeThis
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);
}
示例12: validateSurvey
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;
}
示例13: run
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'));
}
示例14: validateSurvey
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;
}
示例15: validateCannedMessage
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;
}