/** * Generates list of available canned messages. * * @param Request $request * @return string Rendered page content */ public function indexAction(Request $request) { $operator = $this->getOperator(); $page = array('errors' => array()); // Build list of available locales $all_locales = get_available_locales(); $locales_with_label = array(); foreach ($all_locales as $id) { $locale_info = get_locale_info($id); $locales_with_label[] = array('id' => $id, 'name' => $locale_info ? $locale_info['name'] : $id); } $page['locales'] = $locales_with_label; // Get selected locale, if any. $lang = $this->extractLocale($request); if (!$lang) { $lang = in_array(get_current_locale(), $all_locales) ? get_current_locale() : $all_locales[0]; } // Get selected group ID, if any. $group_id = $this->extractGroupId($request); if ($group_id) { $group = group_by_id($group_id); if (!$group) { $page['errors'][] = getlocal('No such group'); $group_id = false; } } // Build list of available groups $all_groups = in_isolation($operator) ? get_groups_for_operator($operator) : get_all_groups(); $page['groups'] = array(); $page['groups'][] = array('groupid' => '', 'vclocalname' => getlocal('-all operators-'), 'level' => 0); foreach ($all_groups as $g) { $page['groups'][] = $g; } // Get messages and setup pagination $canned_messages = load_canned_messages($lang, $group_id); foreach ($canned_messages as &$message) { $message['vctitle'] = $message['vctitle']; $message['vcvalue'] = $message['vcvalue']; } unset($message); $pagination = setup_pagination($canned_messages); $page['pagination'] = $pagination['info']; $page['pagination.items'] = $pagination['items']; // Buil form values $page['formlang'] = $lang; $page['formgroup'] = $group_id; // Set other needed page values and render the response $page['title'] = getlocal('Canned Messages'); $page['menuid'] = 'canned'; $page = array_merge($page, prepare_menu($operator)); return $this->render('canned_messages', $page); }
/** * Generates list of all localization constants in the system. * * @param Request $request Incoming request. * @return string Rendered page content. */ public function indexAction(Request $request) { $operator = $this->getOperator(); $target = $request->query->get('target'); if (!preg_match("/^[\\w-]{2,5}\$/", $target)) { $target = get_current_locale(); } $page = array('localeName' => $this->getLocaleName($target), 'errors' => array()); // Load list of all available locales. $locales_list = array(); $all_locales = get_available_locales(); foreach ($all_locales as $loc) { $locales_list[] = array('id' => $loc, 'name' => $this->getLocaleName($loc)); } // Prepare localization constants to display. $strings = $this->loadStrings($target); foreach ($strings as $key => $item) { $strings[$key] = array('id' => $item['translationid'], 'source' => htmlentities($item['source']), 'translation' => empty($item['translation']) ? "<font color=\"#c13030\"><b>absent</b></font>" : htmlspecialchars($item['translation'])); } // Sort localization constants in the specified order. $order = $request->query->get('sort'); if (!in_array($order, array('source', 'translation'))) { $order = 'source'; } if ($order == 'source') { usort($strings, function ($a, $b) { return strcmp($a['source'], $b['source']); }); } elseif ($order == 'translation') { usort($strings, function ($a, $b) { return strcmp($a['translation'], $b['translation']); }); } $pagination = setup_pagination($strings, 100); $page['pagination'] = $pagination['info']; $page['pagination.items'] = $pagination['items']; $page['formtarget'] = $target; $page['availableLocales'] = $locales_list; $page['availableOrders'] = array(array('id' => 'source', 'name' => getlocal('Source string')), array('id' => 'translation', 'name' => getlocal('Translation'))); $page['formsort'] = $order; $page['title'] = getlocal('Translations'); $page['menuid'] = 'translation'; $page = array_merge($page, prepare_menu($operator)); $page['tabs'] = $this->buildTabs($request); return $this->render('translations', $page); }
/** * Generates list of all banned visitors in the system. * * @param Request $request Incoming request. * @return string Rendered page content. */ public function indexAction(Request $request) { $operator = $this->getOperator(); $page = array('errors' => array()); // Prepare list of all banned visitors $blocked_list = array(); foreach (Ban::all() as $ban) { $blocked_list[] = array('banid' => $ban->id, 'created' => $ban->created, 'till' => $ban->till, 'address' => $ban->address, 'comment' => $ban->comment); } $page['title'] = getlocal('Ban List'); $page['menuid'] = 'bans'; $pagination = setup_pagination($blocked_list); $page['pagination'] = $pagination['info']; $page['pagination.items'] = $pagination['items']; $page = array_merge($page, prepare_menu($operator)); $this->getAssetManager()->attachJs('js/compiled/bans.js'); return $this->render('bans', $page); }
function setupPage($list, $action, $idfield, $valuefield) { global $token, $threadid, $TML; $pagination = setup_pagination($list); if (!empty($pagination)) { $page = array(); $page['pagination'] = $pagination['pagination']; $page['pagination_items'] = $pagination['pagination_items']; $page['params'] = array('thread' => $threadid, 'token' => $token); $TML->assign('pagination', generate_pagination($page['pagination'])); } $out = array(); if (!empty($page['pagination_items'])) { foreach ($page['pagination_items'] as $v) { $page['params']['nextoperatorid'] = $v[$idfield]; $params = array('servlet_root' => WEBIM_ROOT, 'servlet' => '/operator/redirect.php', 'path_vars' => $page['params']); $href = generate_get($params); $value = $v[$valuefield]; $out[] = '<li><a href="' . $href . '" title="' . $value . '">' . $value . '</a></li>'; } } return $out; }
$allgroups = get_all_groups($link); mysql_close($link); $page['groups'] = array(); $page['groups'][] = array('groupid' => '', 'vclocalname' => getlocal("page.gen_button.default_group")); foreach ($allgroups as $g) { $page['groups'][] = $g; } } # delete if (isset($_GET['act']) && $_GET['act'] == 'delete') { $key = isset($_GET['key']) ? $_GET['key'] : ""; if (!preg_match("/^\\d+\$/", $key)) { $errors[] = "Wrong key"; } if (count($errors) == 0) { $link = connect(); perform_query("delete from {$mysqlprefix}chatresponses where id = {$key}", $link); mysql_close($link); header("Location: {$webimroot}/operator/canned.php?lang={$lang}&group={$groupid}"); exit; } } # get messages $messages = load_canned_messages($lang, $groupid); setup_pagination($messages); # form values $page['formlang'] = $lang; $page['formgroup'] = $groupid; prepare_menu($operator); start_html_output(); require '../view/canned.php';
require_once '../libs/pagination.php'; $operator = check_login(); loadsettings(); $page = array(); setlocale(LC_TIME, getstring("time.locale")); $userid = ""; if (isset($_GET['userid'])) { $userid = verifyparam("userid", "/^.{0,63}\$/", ""); } function threads_by_userid($userid) { global $mysqlprefix; if ($userid == "") { return null; } $link = connect(); $query = sprintf("select unix_timestamp(dtmcreated) as created, unix_timestamp(dtmmodified) as modified, " . " threadid, remote, agentName, userName " . "from {$mysqlprefix}chatthread " . "where userid=\"{$userid}\" order by created DESC", $userid); $result = mysql_query($query, $link) or die(' Query failed: ' . mysql_error($link)); $foundThreads = array(); while ($thread = mysql_fetch_array($result, MYSQL_ASSOC)) { $foundThreads[] = $thread; } mysql_free_result($result); mysql_close($link); return $foundThreads; } $found = threads_by_userid($userid); prepare_menu($operator); setup_pagination($found, 6); start_html_output(); require '../view/userhistory.php';
require_once '../classes/models/generic/class.mapperfactory.php'; $operator = Operator::getInstance()->GetLoggedOperator(); $errors = array(); $banMapper = MapperFactory::getMapper('Ban'); if (!empty($_GET['act']) && $_GET['act'] == 'delete') { $banId = isset($_GET['id']) ? $_GET['id'] : ''; if (!preg_match("/^\\d+\$/", $banId)) { $errors[] = 'Wrong argument'; } if (count($errors) == 0) { $banMapper->delete($banId); header('Location: ' . WEBIM_ROOT . '/operator/blocked.php'); exit; } } $blockedList = $banMapper->getAll(); foreach ($blockedList as $k => $v) { $blockedList[$k]['till'] = date(getDateTimeFormat(), $v['till']); } require_once dirname(__FILE__) . '/inc/admin_prolog_after.php'; $TML = new SmartyClass($TITLE_KEY); if (!empty($blockedList)) { $pagination = setup_pagination($blockedList); $tmlPage['pagination'] = $pagination['pagination']; $tmlPage['pagination_items'] = $pagination['pagination_items']; $TML->assign('pagination', generate_pagination($tmlPage['pagination'])); $TML->assign('page_settings', $tmlPage); } $TML->assign('errors', $errors); $TML->display('blocked_visitors.tpl'); require_once dirname(__FILE__) . '/inc/admin_epilog.php';
$allkeys = array_diff($allkeys, load_idlist('level1'), load_idlist('level2')); } } } foreach ($allkeys as $key) { if ($key != 'output_charset') { $tsource = htmlspecialchars($lang1[$key]); if (isset($lang2[$key])) { $value = htmlspecialchars($lang2[$key]); if (get_auxiliary($lang2[$key]) != get_auxiliary($lang1[$key])) { $value = "<font color=\"#6030c1\"><b>{$value}</b></font> <strong>(wrong formatting)</strong>"; } } else { $value = "<font color=\"#c13030\"><b>absent</b></font>"; } $result[] = array('id' => $key, 'l1' => $tsource, 'l2' => $value); } } $order = verifyparam("sort", "/^(id|l1)\$/", "id"); usort($result, "compare_localization_by_{$order}"); setup_pagination($result, 100); $page['formtarget'] = $target; $page['formsource'] = $source; $page['availableLocales'] = $localesList; $page['availableOrders'] = array(array("id" => "id", "name" => getlocal("translate.sort.key")), array("id" => "l1", "name" => getlocal("translate.sort.lang"))); $page['formsort'] = $order; $page['showOptions'] = array(array("id" => "all", "name" => getlocal("translate.show.all")), array("id" => "s1", "name" => getlocal("translate.show.forvisitor")), array("id" => "s2", "name" => getlocal("translate.show.foroperator")), array("id" => "s3", "name" => getlocal("translate.show.foradmin"))); $page['formshow'] = $show; prepare_menu($operator); start_html_output(); require '../view/translatelist.php';
/** * Generates a page with a user history. * * @param Request $request * @return string Rendered page content */ public function userAction(Request $request) { $operator = $this->getOperator(); $user_id = $request->attributes->get('user_id', ''); $page = array(); if (!empty($user_id)) { $db = Database::getInstance(); $query = "SELECT {thread}.* " . "FROM {thread} " . "WHERE userid=:user_id " . "AND (invitationstate = :invitation_accepted " . "OR invitationstate = :invitation_not_invited) " . "ORDER BY dtmcreated DESC"; $found = $db->query($query, array(':user_id' => $user_id, ':invitation_accepted' => Thread::INVITATION_ACCEPTED, ':invitation_not_invited' => Thread::INVITATION_NOT_INVITED), array('return_rows' => Database::RETURN_ALL_ROWS)); } else { $found = null; } $page = array_merge($page, prepare_menu($operator)); // Setup pagination $pagination = setup_pagination($found, 6); $page['pagination'] = $pagination['info']; $page['pagination.items'] = $pagination['items']; if (!empty($page['pagination.items'])) { foreach ($page['pagination.items'] as $key => $item) { $thread = Thread::createFromDbInfo($item); $page['pagination.items'][$key] = array('threadId' => $thread->id, 'userName' => $thread->userName, 'userAddress' => get_user_addr($thread->remote), 'agentName' => $thread->agentName, 'chatTime' => $thread->modified - $thread->created, 'chatCreated' => $thread->created); } } $page['title'] = getlocal("Visit history"); $page['menuid'] = "history"; return $this->render('history_user', $page); }
* Данный файл является частью проекта Веб Мессенджер. * * Все права защищены. (c) 2005-2009 ООО "ТОП". * Данное программное обеспечение и все сопутствующие материалы * предоставляются на условиях лицензии, доступной по адресу * http://webim.ru/license.html * */ require_once '../classes/functions.php'; require_once '../classes/class.thread.php'; require_once '../classes/class.pagination.php'; require_once '../classes/class.smartyclass.php'; require_once '../classes/class.visitsession.php'; $operator = Operator::getInstance()->GetLoggedOperator(); $TML = new SmartyClass(); $items_per_page = verify_param("items", "/^\\d{1,3}\$/", DEFAULT_ITEMS_PER_PAGE); $visitsessionid = verify_param("visitsessionid", "/^\\d{0,63}\\.?\\d{0,63}\$/", ""); $threadid = verify_param("threadid", "/^\\d{1,8}\$/", ""); $found = Thread::getInstance()->GetThreadsByVisitSessionID($visitsessionid); $tmlPage = array(); if ($found) { $pagination = setup_pagination($found); $tmlPage['pagination'] = $pagination['pagination']; $tmlPage['pagination_items'] = $pagination['pagination_items']; $TML->assign('pagination', generate_pagination($tmlPage['pagination'])); for ($i = 0; $i < count($tmlPage['pagination_items']); $i++) { $tmlPage['pagination_items'][$i]['diff'] = webim_date_diff($tmlPage['pagination_items'][$i]['modified'] - $tmlPage['pagination_items'][$i]['created']); } } $TML->assign('page_settings', $tmlPage); $TML->display('visit_info.tpl');