<?php

$tpl = erLhcoreClassTemplate::getInstance('lhchatarchive/listarchivechats.tpl.php');
$archive = erLhcoreClassModelChatArchiveRange::fetch($Params['user_parameters']['id']);
if (isset($_GET['doSearch'])) {
    $filterParams = erLhcoreClassSearchHandler::getParams(array('module' => 'chat', 'module_file' => 'chat_search', 'format_filter' => true, 'use_override' => true, 'uparams' => $Params['user_parameters_unordered']));
    $filterParams['is_search'] = true;
} else {
    $filterParams = erLhcoreClassSearchHandler::getParams(array('module' => 'chat', 'module_file' => 'chat_search', 'format_filter' => true, 'uparams' => $Params['user_parameters_unordered']));
    $filterParams['is_search'] = false;
}
$append = erLhcoreClassSearchHandler::getURLAppendFromInput($filterParams['input_form']);
// Set correct archive tables
$archive->setArchiveTables();
$pages = new lhPaginator();
$pages->serverURL = erLhcoreClassDesign::baseurl('chatarchive/listarchivechats') . '/' . $archive->id . $append;
$pages->items_total = erLhcoreClassChat::getCount($filterParams['filter'], erLhcoreClassModelChatArchiveRange::$archiveTable);
$pages->setItemsPerPage(2);
$pages->paginate();
$items = array();
if ($pages->items_total > 0) {
    try {
        $items = erLhcoreClassChat::getList(array_merge(array('offset' => $pages->low, 'limit' => $pages->items_per_page, 'sort' => 'id ASC'), $filterParams['filter']), 'erLhcoreClassModelChatArchive', erLhcoreClassModelChatArchiveRange::$archiveTable);
    } catch (Exception $e) {
        print_r($e->getMessage());
    }
}
$filterParams['input_form']->form_action = erLhcoreClassDesign::baseurl('chatarchive/listarchivechats') . '/' . $archive->id;
$tpl->set('input', $filterParams['input_form']);
$tpl->set('items', $items);
$tpl->set('archive', $archive);
Exemplo n.º 2
0
<?php

if (!isset($_SERVER['HTTP_X_CSRFTOKEN']) || !$currentUser->validateCSFRToken($_SERVER['HTTP_X_CSRFTOKEN'])) {
    echo json_encode(array('error' => 'true', 'result' => 'Invalid CSFR Token'));
    exit;
}
$archive = new erLhcoreClassModelChatArchiveRange();
$definition = array('id' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'int', array('min_range' => 1)));
$form = new ezcInputForm(INPUT_POST, $definition);
$Errors = array();
if (!$form->hasValidData('id')) {
    echo json_encode(array('error' => 'true', 'result' => 'Invalid archive ID'));
    exit;
} else {
    $archiveChat = erLhcoreClassModelChatArchiveRange::fetch($form->id);
    $status = $archiveChat->process();
    $tpl = erLhcoreClassTemplate::getInstance('lhchatarchive/archivechats.tpl.php');
    $tpl->set('status', $status);
    $tpl->set('archive', $archiveChat);
    $status['result'] = $tpl->fetch();
    echo json_encode($status);
}
exit;
 public function __get($var)
 {
     switch ($var) {
         case 'range_from_front':
             if ($this->range_from != 0) {
                 return date(erLhcoreClassModule::$dateFormat, $this->range_from);
             }
             return '';
             break;
         case 'range_to_front':
             if ($this->range_to != 0) {
                 return date(erLhcoreClassModule::$dateFormat, $this->range_to);
             }
             return '';
             break;
         case 'potential_chats_count':
             $this->potential_chats_count = erLhcoreClassChat::getCount(array('filterlt' => array('time' => $this->range_to), 'filtergt' => array('time' => $this->range_from)));
             return $this->potential_chats_count;
             break;
         case 'chats_in_archive':
             $this->chats_in_archive = 0;
             if ($this->id > 0) {
                 self::$archiveTable = "lh_chat_archive_{$this->id}";
                 self::$archiveMsgTable = "lh_chat_archive_msg_{$this->id}";
                 $this->chats_in_archive = erLhcoreClassChat::getCount(array(), self::$archiveTable);
             }
             return $this->chats_in_archive;
             break;
         case 'messages_in_archive':
             $this->messages_in_archive = 0;
             if ($this->id > 0) {
                 self::$archiveTable = "lh_chat_archive_{$this->id}";
                 self::$archiveMsgTable = "lh_chat_archive_msg_{$this->id}";
                 $this->messages_in_archive = erLhcoreClassChat::getCount(array(), self::$archiveMsgTable);
             }
             return $this->messages_in_archive;
             break;
         default:
             break;
     }
 }
Exemplo n.º 4
0
<?php

if (!isset($_SERVER['HTTP_X_CSRFTOKEN']) || !$currentUser->validateCSFRToken($_SERVER['HTTP_X_CSRFTOKEN'])) {
    echo json_encode(array('error' => 'true', 'result' => 'Invalid CSFR Token'));
    exit;
}
$archive = new erLhcoreClassModelChatArchiveRange();
$definition = array('RangeFrom' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'string'), 'RangeTo' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'string'));
$form = new ezcInputForm(INPUT_POST, $definition);
$Errors = array();
if (!$form->hasValidData('RangeFrom') || $form->RangeFrom == '') {
    $Errors[] = erTranslationClassLhTranslation::getInstance()->getTranslation('departament/edit', 'Please enter a valid from date range!');
} else {
    $range = explode('-', $form->RangeFrom);
    if (checkdate($range[1], $range[2], $range[0])) {
        $archive->range_from = mktime(0, 0, 0, $range[1], $range[2], $range[0]);
    } else {
        $Errors[] = erTranslationClassLhTranslation::getInstance()->getTranslation('departament/edit', 'Please enter a valid from date range!');
    }
}
if (!$form->hasValidData('RangeTo') || $form->RangeTo == '') {
    $Errors[] = erTranslationClassLhTranslation::getInstance()->getTranslation('departament/edit', 'Please enter a valid to date range!');
} else {
    $range = explode('-', $form->RangeTo);
    if (checkdate($range[1], $range[2], $range[0])) {
        $archive->range_to = mktime(0, 0, 0, $range[1], $range[2], $range[0]);
    } else {
        $Errors[] = erTranslationClassLhTranslation::getInstance()->getTranslation('departament/edit', 'Please enter a valid to date range!');
    }
}
if (count($Errors) == 0) {