<?php

$response = erLhcoreClassChatEventDispatcher::getInstance()->dispatch('chat.newcannedmsg', array());
$tpl = erLhcoreClassTemplate::getInstance('lhchat/newcannedmsg.tpl.php');
$CannedMessage = new erLhcoreClassModelCannedMsg();
/**
 * Append user departments filter
 * */
$userDepartments = erLhcoreClassUserDep::parseUserDepartmetnsForFilter($currentUser->getUserID());
if (isset($_POST['Cancel_action'])) {
    erLhcoreClassModule::redirect('chat/cannedmsg');
    exit;
}
if (isset($_POST['Save_action'])) {
    $Errors = erLhcoreClassAdminChatValidatorHelper::validateCannedMessage($CannedMessage, $userDepartments);
    if (count($Errors) == 0) {
        $CannedMessage->saveThis();
        erLhcoreClassChatEventDispatcher::getInstance()->dispatch('chat.newcannedmsg', array('msg' => &$CannedMessage));
        erLhcoreClassModule::redirect('chat/cannedmsg');
        exit;
    } else {
        $tpl->set('errors', $Errors);
    }
}
$tpl->set('canned_message', $CannedMessage);
$tpl->set('limitDepartments', $userDepartments !== true ? array('filterin' => array('id' => $userDepartments)) : array());
$Result['content'] = $tpl->fetch();
$Result['path'] = array(array('url' => erLhcoreClassDesign::baseurl('system/configuration'), 'title' => erTranslationClassLhTranslation::getInstance()->getTranslation('chat/cannedmsg', 'System configuration')), array('url' => erLhcoreClassDesign::baseurl('chat/cannedmsg'), 'title' => erTranslationClassLhTranslation::getInstance()->getTranslation('chat/cannedmsg', 'Canned messages')), array('title' => erTranslationClassLhTranslation::getInstance()->getTranslation('chat/cannedmsg', 'New canned message')));
erLhcoreClassChatEventDispatcher::getInstance()->dispatch('chat.newcannedmsg_path', array('result' => &$Result));
Beispiel #2
0
  * Canned messages part
  * */
 $cannedMessage = new erLhcoreClassModelCannedMsg();
 if (is_numeric($Params['user_parameters_unordered']['msg']) && $Params['user_parameters_unordered']['action'] == '') {
     $cannedMessage = erLhcoreClassModelCannedMsg::fetch($Params['user_parameters_unordered']['msg']);
     if ($cannedMessage->user_id != $UserData->id) {
         erLhcoreClassModule::redirect('user/account', '#canned');
         exit;
     }
 }
 if (isset($_POST['Cancel_canned_action'])) {
     erLhcoreClassModule::redirect('user/account', '#canned');
     exit;
 }
 if (isset($_POST['Save_canned_action'])) {
     $Errors = erLhcoreClassAdminChatValidatorHelper::validateCannedMessage($cannedMessage, true);
     if (count($Errors) == 0) {
         $cannedMessage->user_id = $UserData->id;
         $cannedMessage->saveThis();
         $tpl->set('updated_canned', true);
     } else {
         $tpl->set('errors_canned', $Errors);
     }
     $tpl->set('tab', 'tab_canned');
 }
 /**
  * Delete canned message
  * */
 if (is_numeric($Params['user_parameters_unordered']['msg']) && $Params['user_parameters_unordered']['action'] == 'delete') {
     if (!$currentUser->validateCSFRToken($Params['user_parameters_unordered']['csfr'])) {
         die('Invalid CSRF Token');
<?php

$tpl = erLhcoreClassTemplate::getInstance('lhchat/startchatformsettings.tpl.php');
$startData = erLhcoreClassModelChatConfig::fetch('start_chat_data');
$data = (array) $startData->data;
if (isset($_POST['CancelConfig'])) {
    erLhcoreClassModule::redirect('system/configuration');
    exit;
}
if (isset($_POST['UpdateConfig']) || isset($_POST['SaveConfig'])) {
    if (!isset($_POST['csfr_token']) || !$currentUser->validateCSFRToken($_POST['csfr_token'])) {
        erLhcoreClassModule::redirect('chat/startchatformsettings');
        exit;
    }
    $Errors = erLhcoreClassAdminChatValidatorHelper::validateStartChatForm($data);
    if (count($Errors) == 0) {
        $startData->value = serialize($data);
        $startData->saveThis();
        $tpl->set('updated', true);
        // Cleanup cache to recompile templates etc.
        $CacheManager = erConfigClassLhCacheConfig::getInstance();
        $CacheManager->expireCache();
        if (isset($_POST['SaveConfig'])) {
            erLhcoreClassModule::redirect('system/configuration');
            exit;
        }
    } else {
        $tpl->set('errors', $Errors);
    }
}
$tpl->set('start_chat_data', $data);