/** * Builds a page with form for upload translation file. * * @param Request $request Incoming request. * @return string Rendered page content. */ public function showFormAction(Request $request) { $operator = $this->getOperator(); $target = $request->request->get('target'); if (!preg_match("/^[\\w-]{2,5}\$/", $target)) { $target = get_current_locale(); } $override = (bool) $request->request->get('override', false); $page = array('errors' => $request->attributes->get('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)); } $page['stored'] = $request->query->has('stored'); $page['localesList'] = $locales_list; $page['formtarget'] = $target; $page['formoverride'] = $override; $page['title'] = getlocal('Translations import'); $page['menuid'] = 'translation'; $page = array_merge($page, prepare_menu($operator)); $page['tabs'] = $this->buildTabs($request); return $this->render('translation_import', $page); }
/** * Builds a page with members edit form. * * @param Request $request Incoming request. * @return string Rendered page content. * @throws NotFoundException If the operator's group with specified ID is * not found in the system. */ public function showFormAction(Request $request) { $operator = $this->getOperator(); $group_id = $request->attributes->getInt('group_id'); $page = array('groupid' => $group_id, 'errors' => $request->attributes->get('errors', array())); $operators = get_operators_list(); $group = group_by_id($group_id); // Check if the group exists if (!$group) { throw new NotFoundException('The group is not found.'); } $page['formop'] = array(); $page['currentgroup'] = $group ? htmlspecialchars($group['vclocalname']) : ''; // Get list of group's members $checked_operators = get_group_members($group_id); // Prepare the list of all operators $page['operators'] = array(); foreach ($operators as $op) { $op['vclocalename'] = $op['vclocalename']; $op['vclogin'] = $op['vclogin']; $op['checked'] = in_array($op['operatorid'], $checked_operators); $page['operators'][] = $op; } // Set other values and render the page $page['stored'] = $request->query->get('stored'); $page['title'] = getlocal('Members'); $page['menuid'] = 'groups'; $page = array_merge($page, prepare_menu($operator)); $page['tabs'] = $this->buildTabs($request); return $this->render('group_members', $page); }
/** * Builds a page with form for features system settings. * * @param Request $request Incoming request. * @return string Rendered page content. */ public function showFormAction(Request $request) { $operator = $this->getOperator(); $page = array( 'agentId' => '', 'errors' => array(), ); // Load all needed options and fill form with them. $options = $this->getOptionsList(); foreach ($options as $opt) { $page['form' . $opt] = (Settings::get($opt) == '1'); } $page['canmodify'] = is_capable(CAN_ADMINISTRATE, $operator); $page['stored'] = $request->query->get('stored'); $page['title'] = getlocal('Messenger settings'); $page['menuid'] = 'settings'; $page = array_merge($page, prepare_menu($operator)); $page['tabs'] = $this->buildTabs($request); $this->getAssetManager()->attachJs('js/compiled/features.js'); return $this->render('settings_features', $page); }
/** * Builds a page with form for edit operator's groups. * * @param Request $request Incoming request. * @return string Rendered page content. * @throws NotFoundException If the operator with specified ID is not found * in the system. */ public function showFormAction(Request $request) { $operator = $this->getOperator(); $operator_in_isolation = in_isolation($operator); $op_id = $request->attributes->getInt('operator_id'); // Check if the target user exists $op = operator_by_id($op_id); if (!$op) { throw new NotFoundException('The operator is not found.'); } $page = array('opid' => $op_id, 'errors' => array()); $groups = $operator_in_isolation ? get_groups_for_operator($operator) : get_all_groups(); $can_modify = is_capable(CAN_ADMINISTRATE, $operator); $page['currentop'] = $op ? get_operator_name($op) . ' (' . $op['vclogin'] . ')' : getlocal('-not found-'); $page['canmodify'] = $can_modify ? '1' : ''; // Get IDs of groups the operator belongs to. $checked_groups = array(); if ($op) { $checked_groups = get_operator_group_ids($op_id); } // Get all available groups $page['groups'] = array(); foreach ($groups as $group) { $group['vclocalname'] = $group['vclocalname']; $group['vclocaldescription'] = $group['vclocaldescription']; $group['checked'] = in_array($group['groupid'], $checked_groups); $page['groups'][] = $group; } $page['stored'] = $request->query->has('stored'); $page['title'] = getlocal('Operator groups'); $page['menuid'] = $operator['operatorid'] == $op_id ? 'profile' : 'operators'; $page = array_merge($page, prepare_menu($operator)); $page['tabs'] = $this->buildTabs($request); return $this->render('operator_groups', $page); }
/** * Builds a page with form for edit operator's permissions. * * @param Request $request Incoming request. * @return string Rendered page content. * @throws NotFoundException If the operator with specified ID is not found * in the system. */ public function showFormAction(Request $request) { $operator = $this->getOperator(); $op_id = $request->attributes->get('operator_id'); $page = array('opid' => $op_id, 'canmodify' => is_capable(CAN_ADMINISTRATE, $operator) ? '1' : '', 'errors' => array()); $op = operator_by_id($op_id); if (!$op) { throw new NotFoundException('The operator is not found.'); } // Check if the target operator exists $page['currentop'] = $op ? get_operator_name($op) . ' (' . $op['vclogin'] . ')' : getlocal('-not found-'); // Build list of permissions which belongs to the target operator. $checked_permissions = array(); foreach (permission_ids() as $perm => $id) { if (is_capable($perm, $op)) { $checked_permissions[] = $id; } } // Build list of all available permissions $page['permissionsList'] = array(); foreach (get_permission_list() as $perm) { $perm['checked'] = in_array($perm['id'], $checked_permissions); $page['permissionsList'][] = $perm; } $page['stored'] = $request->query->has('stored'); $page['title'] = getlocal('Permissions'); $page['menuid'] = $operator['operatorid'] == $op_id ? 'profile' : 'operators'; $page = array_merge($page, prepare_menu($operator)); $page['tabs'] = $this->buildTabs($request); return $this->render('operator_permissions', $page); }
/** * Builds a page with form for performance system settings. * * @param Request $request Incoming request. * @return string Rendered page content. */ public function showFormAction(Request $request) { $operator = $this->getOperator(); $page = array('agentId' => '', 'errors' => $request->attributes->get('errors', array())); // Load settings from the database $options = array('online_timeout', 'connection_timeout', 'updatefrequency_operator', 'updatefrequency_chat', 'max_connections_from_one_host', 'updatefrequency_tracking', 'visitors_limit', 'invitation_lifetime', 'tracking_lifetime', 'thread_lifetime', 'max_uploaded_file_size'); $params = array(); foreach ($options as $opt) { $params[$opt] = Settings::get($opt); } // Build form values $form = $request->request; $page['formonlinetimeout'] = $form->get('onlinetimeout', $params['online_timeout']); $page['formconnectiontimeout'] = $form->get('connectiontimeout', $params['connection_timeout']); $page['formfrequencyoperator'] = $form->get('frequencyoperator', $params['updatefrequency_operator']); $page['formfrequencychat'] = $form->get('frequencychat', $params['updatefrequency_chat']); $page['formonehostconnections'] = $form->get('onehostconnections', $params['max_connections_from_one_host']); $page['formthreadlifetime'] = $form->get('threadlifetime', $params['thread_lifetime']); $page['formmaxuploadedfilesize'] = $form->get('maxuploadedfilesize', $params['max_uploaded_file_size']); if (Settings::get('enabletracking')) { $page['formfrequencytracking'] = $form->get('frequencytracking', $params['updatefrequency_tracking']); $page['formvisitorslimit'] = $form->get('visitorslimit', $params['visitors_limit']); $page['forminvitationlifetime'] = $form->get('invitationlifetime', $params['invitation_lifetime']); $page['formtrackinglifetime'] = $form->get('trackinglifetime', $params['tracking_lifetime']); } $page['enabletracking'] = Settings::get('enabletracking'); $page['stored'] = $request->query->get('stored'); $page['title'] = getlocal("Messenger settings"); $page['menuid'] = "settings"; $page = array_merge($page, prepare_menu($operator)); $page['tabs'] = $this->buildTabs($request); return $this->render('settings_performance', $page); }
/** * Generates a page with awaiting visitors. * * @param Request $request * @return string Rendered page content */ public function indexAction(Request $request) { $operator = $this->getOperator(); // Operator becomes online as soon as he open "operator/users" page notify_operator_alive($operator['operatorid'], 0); $operator['istatus'] = 0; $this->getAuthenticationManager()->setOperator($operator); $_SESSION[SESSION_PREFIX . "operatorgroups"] = get_operator_groups_list($operator['operatorid']); $page = array(); $page['havemenu'] = !$request->query->has('nomenu'); $page['showonline'] = (Settings::get('showonlineoperators') == '1'); $page['showvisitors'] = (Settings::get('enabletracking') == '1'); $page['title'] = getlocal("List of visitors waiting"); $page['menuid'] = "users"; $page = array_merge($page, prepare_menu($operator)); // Attach files of the client side application and start it $this->getAssetManager()->attachJs('js/compiled/users_app.js'); $this->getAssetManager()->attachJs( $this->startJsApplication($request, $operator), \Mibew\Asset\AssetManagerInterface::INLINE, 1000 ); return $this->render('users', $page); }
/** * Generates list of all locales in the system. * * @param Request $request Incoming request. * @return string Rendered page content. */ public function indexAction(Request $request) { $operator = $this->getOperator(); $page = array( // Use errors list stored in the request. We need to do so to have // an ability to pass the request from other actions. 'errors' => $request->attributes->get('errors', array()), ); $fs_locales = discover_locales(); $available_locales = get_available_locales(); $locales_list = array(); foreach ($fs_locales as $locale) { $locales_list[] = array( 'code' => $locale, 'name' => $this->getLocaleName($locale), 'isDisabled' => !in_array($locale, $available_locales), ); } $page['localesList'] = $locales_list; $page['title'] = getlocal('Locales'); $page['menuid'] = 'translation'; $page = array_merge($page, prepare_menu($operator)); $page['tabs'] = $this->buildTabs($request); return $this->render('locales', $page); }
/** * Generates list of all available groups. * * @param Request $request Incoming request. * @return string Rendered page content. */ public function indexAction(Request $request) { $operator = $this->getOperator(); $page = array('errors' => array()); $sort_by = $request->query->get('sortby'); if (!in_array($sort_by, array('name', 'lastseen', 'weight'))) { $sort_by = 'name'; } $sort['by'] = $sort_by; $sort['desc'] = $request->query->get('sortdirection', 'desc') == 'desc'; // Load and prepare groups $groups = get_sorted_groups($sort); foreach ($groups as &$group) { $group['vclocalname'] = $group['vclocalname']; $group['vclocaldescription'] = $group['vclocaldescription']; $group['isOnline'] = group_is_online($group); $group['isAway'] = group_is_away($group); $group['lastTimeOnline'] = time() - ($group['ilastseen'] ? $group['ilastseen'] : time()); $group['inumofagents'] = $group['inumofagents']; } unset($group); // Set values that are needed to build sorting block. $page['groups'] = $groups; $page['formsortby'] = $sort['by']; $page['formsortdirection'] = $sort['desc'] ? 'desc' : 'asc'; $page['canmodify'] = is_capable(CAN_ADMINISTRATE, $operator); $page['availableOrders'] = array(array('id' => 'name', 'name' => getlocal('Name')), array('id' => 'lastseen', 'name' => getlocal('Last active')), array('id' => 'weight', 'name' => getlocal('Weight'))); $page['availableDirections'] = array(array('id' => 'desc', 'name' => getlocal('descending')), array('id' => 'asc', 'name' => getlocal('ascending'))); // Set other variables and render the response. $page['title'] = getlocal('Groups'); $page['menuid'] = 'groups'; $page = array_merge($page, prepare_menu($operator)); $this->getAssetManager()->attachJs('js/compiled/groups.js'); return $this->render('groups', $page); }
/** * Renders operator's home page. * * @param Request $request Incoming request * @return string Rendered page content. */ public function dashboardAction(Request $request) { $operator = $this->getOperator(); $is_online = is_operator_online($operator['operatorid']); $page = array('version' => MIBEW_VERSION, 'localeLinks' => get_locale_links(), 'needUpdate' => version_compare(Settings::get('dbversion'), MIBEW_VERSION, '<'), 'profilePage' => $this->generateUrl('operator_edit', array('operator_id' => $operator['operatorid'])), 'isOnline' => $is_online, 'warnOffline' => true, 'title' => getlocal('Home'), 'menuid' => 'main'); $page = array_merge($page, prepare_menu($operator)); return $this->render('index', $page); }
/** * Generates list of all plugins in the system. * * @param Request $request Incoming request. * @return string Rendered page content. */ public function indexAction(Request $request) { $page = array('errors' => $request->attributes->get('errors', array())); $page['plugins'] = $this->buildPluginsList(); $page['title'] = getlocal('Plugins'); $page['menuid'] = 'plugins'; $page = array_merge($page, prepare_menu($this->getOperator())); $this->getAssetManager()->attachJs('js/compiled/plugins.js'); return $this->render('plugins', $page); }
/** * Builds a page with form for add/edit group. * * @param Request $request Incoming request. * @return string Rendered page content. * @throws NotFoundException If the operator's group with specified ID is * not found in the system. */ public function showFormAction(Request $request) { $operator = $this->getOperator(); $group_id = $request->attributes->getInt('group_id'); $page = array('gid' => false, 'errors' => $request->attributes->get('errors', array())); if ($group_id) { // Check if the group exisits $group = group_by_id($group_id); if (!$group) { throw new NotFoundException('The group is not found.'); } // Set form values $page['formname'] = $group['vclocalname']; $page['formdescription'] = $group['vclocaldescription']; $page['formcommonname'] = $group['vccommonname']; $page['formcommondescription'] = $group['vccommondescription']; $page['formemail'] = $group['vcemail']; $page['formweight'] = $group['iweight']; $page['formparentgroup'] = $group['parent']; $page['grid'] = $group['groupid']; $page['formtitle'] = $group['vctitle']; $page['formchattitle'] = $group['vcchattitle']; $page['formhosturl'] = $group['vchosturl']; $page['formlogo'] = $group['vclogo']; } // Override group's fields from the request if it's needed. This // case will take place when save handler fails. if ($request->isMethod('POST')) { $page['formname'] = $request->request->get('name'); $page['formdescription'] = $request->request->get('description'); $page['formcommonname'] = $request->request->get('commonname'); $page['formcommondescription'] = $request->request->get('commondescription'); $page['formemail'] = $request->request->get('email'); $page['formweight'] = $request->request->get('weight'); $page['formparentgroup'] = $request->request->get('parentgroup'); $page['formtitle'] = $request->request->get('title'); $page['formchattitle'] = $request->request->get('chattitle'); $page['formhosturl'] = $request->request->get('hosturl'); $page['formlogo'] = $request->request->get('logo'); } // Set other page variables and render the template. $page['stored'] = $request->query->has('stored'); $page['availableParentGroups'] = get_available_parent_groups($group_id); $page['formaction'] = $request->getBaseUrl() . $request->getPathInfo(); $page['title'] = getlocal('Group details'); $page['menuid'] = 'groups'; $page = array_merge($page, prepare_menu($operator)); $page['tabs'] = $this->buildTabs($request); $this->getAssetManager()->attachJs('js/compiled/group.js'); return $this->render('group_edit', $page); }
/** * Builds a page with form for common system settings. * * @param Request $request Incoming request. * @return string Rendered page content. */ public function showFormAction(Request $request) { $operator = $this->getOperator(); $page = array('agentId' => '', 'errors' => $request->attributes->get('errors', array())); // Load settings values from the database $options = array('email', 'title', 'logo', 'hosturl', 'usernamepattern', 'chattitle', 'geolink', 'geolinkparams', 'sendmessagekey', 'cron_key', 'left_messages_locale'); $params = array(); foreach ($options as $opt) { $params[$opt] = Settings::get($opt); } // Set form values $form = $request->request; $page['formemail'] = $form->get('email', $params['email']); $page['formleftmessageslocale'] = $form->get('leftmessageslocale', $params['left_messages_locale']); $page['formtitle'] = $form->get('title', $params['title']); $page['formlogo'] = $form->get('logo', $params['logo']); $page['formhosturl'] = $form->get('hosturl', $params['hosturl']); $page['formgeolink'] = $form->get('geolink', $params['geolink']); $page['formgeolinkparams'] = $form->get('geolinkparams', $params['geolinkparams']); $page['formusernamepattern'] = $form->get('usernamepattern', $params['usernamepattern']); $page['formchatstyle'] = $form->get('chatstyle', ChatStyle::getDefaultStyle()); $page['formpagestyle'] = $form->get('pagestyle', PageStyle::getDefaultStyle()); $page['formchattitle'] = $form->get('chattitle', $params['chattitle']); $page['formsendmessagekey'] = $form->get('sendmessagekey', $params['sendmessagekey']); $page['formcronkey'] = $form->get('cronkey', $params['cron_key']); if (Settings::get('enabletracking')) { $page['forminvitationstyle'] = $form->get('invitationstyle', InvitationStyle::getDefaultStyle()); $page['availableInvitationStyles'] = InvitationStyle::getAvailableStyles(); } $page['availableLocales'] = get_available_locales(); $page['availableChatStyles'] = ChatStyle::getAvailableStyles(); $page['availablePageStyles'] = PageStyle::getAvailableStyles(); $page['chatStylePreviewPath'] = $this->generateUrl('style_preview', array('type' => 'chat')); $page['pageStylePreviewPath'] = $this->generateUrl('style_preview', array('type' => 'page')); $page['invitationStylePreviewPath'] = $this->generateUrl('style_preview', array('type' => 'invitation')); $page['stored'] = $request->query->has('stored'); $page['enabletracking'] = Settings::get('enabletracking'); $page['cron_path'] = $this->generateUrl('cron', array('cron_key' => $params['cron_key']), UrlGeneratorInterface::ABSOLUTE_URL); $page['title'] = getlocal('Messenger settings'); $page['menuid'] = 'settings'; $page = array_merge($page, prepare_menu($operator)); $page['tabs'] = $this->buildTabs($request); return $this->render('settings_common', $page); }
/** * Generates a page with statistics info. * * @param Request $request * @return string Rendered page content */ public function indexAction(Request $request) { $operator = $this->getOperator(); $statistics_type = $request->attributes->get('type'); $page = array(); $page['operator'] = get_operator_name($operator); $page['availableDays'] = range(1, 31); $page['availableMonth'] = get_month_selection(time() - 400 * 24 * 60 * 60, time() + 50 * 24 * 60 * 60); $page['showresults'] = false; $page['type'] = $statistics_type; $page['showbydate'] = $statistics_type == self::TYPE_BY_DATE; $page['showbyagent'] = $statistics_type == self::TYPE_BY_OPERATOR; $page['showbypage'] = $statistics_type == self::TYPE_BY_PAGE; $cron_uri = $this->generateUrl('cron', array('cron_key' => Settings::get('cron_key')), UrlGeneratorInterface::ABSOLUTE_URL); $page['pageDescription'] = getlocal('From this page you can generate a variety of usage reports. Last time statistics was calculated {0}. You can calculate it <a href="{1}" target="_blank">manually</a>.', array(date_to_text(Settings::get('_last_cron_run')), $cron_uri)); $page['show_invitations_info'] = (bool) Settings::get('enabletracking'); $page['errors'] = array(); // Get and validate time interval $time_interval = $this->extractTimeInterval($request); $start = $time_interval['start']; $end = $time_interval['end']; if ($start > $end) { $page['errors'][] = getlocal('You have selected From date after Till date'); } $page = array_merge($page, set_form_date($start, 'start'), set_form_date($end - 24 * 60 * 60, 'end')); // Get statistics info if ($statistics_type == self::TYPE_BY_DATE) { $statistics = get_by_date_statistics($start, $end); $page['reportByDate'] = $statistics['records']; $page['reportByDateTotal'] = $statistics['total']; } elseif ($statistics_type == self::TYPE_BY_OPERATOR) { $page['reportByAgent'] = get_by_operator_statistics($start, $end); } elseif ($statistics_type == self::TYPE_BY_PAGE) { $page['reportByPage'] = get_by_page_statistics($start, $end); } $page['showresults'] = count($page['errors']) == 0; $page['title'] = getlocal("Statistics"); $page['menuid'] = "statistics"; $page = array_merge($page, prepare_menu($operator)); $page['tabs'] = $this->buildTabs($request); return $this->render('statistics', $page); }
/** * Builds a page with form for edit operator's avatar. * * @param Request $request incoming request. * @return string Rendered page content. * @throws NotFoundException If the operator with specified ID is not found * in the system. */ public function showFormAction(Request $request) { $operator = $this->getOperator(); $op_id = $request->attributes->get('operator_id'); $page = array('opid' => $op_id, 'errors' => $request->attributes->get('errors', array())); $can_modify = $op_id == $operator['operatorid'] && is_capable(CAN_MODIFYPROFILE, $operator) || is_capable(CAN_ADMINISTRATE, $operator); // Try to load the target operator. $op = operator_by_id($op_id); if (!$op) { throw new NotFoundException('The operator is not found'); } $page['avatar'] = $op['vcavatar'] ? $this->asset($op['vcavatar']) : ''; $page['currentop'] = $op ? get_operator_name($op) . ' (' . $op['vclogin'] . ')' : getlocal('-not found-'); $page['canmodify'] = $can_modify ? '1' : ''; $page['title'] = getlocal('Upload photo'); $page['menuid'] = $operator['operatorid'] == $op_id ? 'profile' : 'operators'; $page = array_merge($page, prepare_menu($operator)); $page['tabs'] = $this->buildTabs($request); return $this->render('operator_avatar', $page); }
/** * Builds a page with form for mail template settings. * * @param Request $request Incoming request. * @return string Rendered page content. */ public function showEditFormAction(Request $request) { $operator = $this->getOperator(); $lang = $this->extractLocale($request); $template_name = $request->attributes->get('name'); $page = array('errors' => $request->attributes->get('errors', array())); $template = MailTemplate::loadByName($template_name, $lang); if (!$template) { throw new NotFoundException('The template is not found'); } // Use values from the request or the default ones if they are not // available. $page['formsubject'] = $request->request->get('subject', $template->subject); $page['formbody'] = $request->request->get('body', $template->body); $page['formname'] = $template_name; $page['formlang'] = $lang; $page['formaction'] = $this->generateUrl('mail_template_edit', array('name' => $template_name)); $page['title'] = getlocal('Mail templates'); $page['menuid'] = 'mail_templates'; $page = array_merge($page, prepare_menu($operator)); return $this->render('mail_template_edit', $page); }
/** * Generates a page with style preview. * * @param Request $request Incoming request. * @return string Rendered page content. */ public function previewAction(Request $request) { $operator = $this->getOperator(); $class_name = $this->resolveClassName($request->attributes->get('type')); $style_list = call_user_func($class_name . '::getAvailableStyles'); $preview = $request->query->get('preview'); if (!in_array($preview, $style_list)) { $style_names = array_keys($style_list); $preview = $style_list[$style_names[0]]; } $style = new $class_name($preview); $screenshots = $this->buildScreenshotList($style); $page['formpreview'] = $preview; $page['formaction'] = $request->getBaseUrl() . $request->getPathInfo(); $page['availablePreviews'] = $style_list; $page['screenshotsList'] = $screenshots; $page['title'] = getlocal('Site style'); $page['menuid'] = 'styles'; $page = array_merge($page, prepare_menu($operator)); $page['tabs'] = $this->buildTabs($request); return $this->render('style_preview', $page); }
/** * Generates "about" page. * * @param Request $request * @return string Rendered page content */ public function indexAction(Request $request) { $page = array_merge( array( 'localizations' => get_available_locales(), 'phpVersion' => phpversion(), 'extensions' => $this->getExtensionsInfo(), 'version' => MIBEW_VERSION, 'title' => getlocal('About'), 'menuid' => 'about', ), prepare_menu($this->getOperator()) ); $this->getAssetManager()->attachJs('js/compiled/about.js'); $this->getAssetManager()->attachJs( 'https://mibew.org/api/updates', AssetManagerInterface::ABSOLUTE_URL ); return $this->render('about', $page); }
/** * Generates list of all operators in the system. * * @param Request $request Incoming request. * @return string Rendered page content. */ public function indexAction(Request $request) { $operator = $this->getOperator(); $page = array('errors' => $request->attributes->get('errors', array())); $sort['by'] = $request->query->get('sortby'); if (!in_array($sort['by'], array('login', 'commonname', 'localename', 'lastseen'))) { $sort['by'] = 'login'; } $sort['desc'] = $request->query->get('sortdirection', 'desc') == 'desc'; $page['formsortby'] = $sort['by']; $page['formsortdirection'] = $sort['desc'] ? 'desc' : 'asc'; $list_options['sort'] = $sort; if (in_isolation($operator)) { $list_options['isolated_operator_id'] = $operator['operatorid']; } $operators_list = get_operators_list($list_options); // Prepare operator to render in template foreach ($operators_list as &$item) { $item['vclogin'] = $item['vclogin']; $item['vclocalename'] = $item['vclocalename']; $item['vccommonname'] = $item['vccommonname']; $item['isAvailable'] = operator_is_available($item); $item['isAway'] = operator_is_away($item); $item['lastTimeOnline'] = time() - $item['time']; $item['isDisabled'] = operator_is_disabled($item); } unset($item); $page['allowedAgents'] = $operators_list; $page['canmodify'] = is_capable(CAN_ADMINISTRATE, $operator); $page['availableOrders'] = array(array('id' => 'login', 'name' => getlocal('Login')), array('id' => 'localename', 'name' => getlocal('Name')), array('id' => 'commonname', 'name' => getlocal('International name')), array('id' => 'lastseen', 'name' => getlocal('Last active'))); $page['availableDirections'] = array(array('id' => 'desc', 'name' => getlocal('descending')), array('id' => 'asc', 'name' => getlocal('ascending'))); $page['title'] = getlocal('Operators'); $page['menuid'] = 'operators'; $page = array_merge($page, prepare_menu($operator)); $this->getAssetManager()->attachJs('js/compiled/operators.js'); return $this->render('operators', $page); }
$page['locale'] = verifyparam("lang", "/^[\\w-]{2,5}\$/", ""); $page['groupid'] = ""; if ($settings['enablegroups'] == '1') { $page['groupid'] = verifyparam("group", "/^\\d{0,10}\$/"); } } if (isset($_POST['message'])) { $message = getparam('message'); if (!$message) { $errors[] = no_field("form.field.message"); } if (count($errors) == 0) { if ($stringid) { save_message($stringid, $message); } else { add_message($page['locale'], $page['groupid'], $message); } $page['saved'] = true; prepare_menu($operator, false); start_html_output(); require '../view/cannededit.php'; exit; } } $page['saved'] = false; $page['key'] = $stringid; $page['formmessage'] = topage($message); prepare_menu($operator, false); start_html_output(); require '../view/cannededit.php'; exit;
/** * Generates "about" page. * * @param Request $request * @return string Rendered page content */ public function indexAction(Request $request) { $page = array_merge(array('localizations' => get_available_locales(), 'phpVersion' => phpversion(), 'extensions' => $this->getExtensionsInfo(), 'version' => MIBEW_VERSION, 'title' => getlocal('About'), 'menuid' => 'about', 'availableUpdates' => $this->getAvailableUpdates()), prepare_menu($this->getOperator())); return $this->render('about', $page); }
/** * Builds a page with form for add/edit operator. * * @param Request $request Incoming request. * @return string Rendered page content. * @throws NotFoundException If the operator with specified ID is not found * in the system. */ public function showFormAction(Request $request) { $operator = $this->getOperator(); $page = array('opid' => false, 'errors' => $request->attributes->get('errors', array())); $op_id = false; if ($request->attributes->has('operator_id')) { // Load and validate an operator to edit $op_id = $request->attributes->getInt('operator_id'); $op = operator_by_id($op_id); if (!$op) { throw new NotFoundException('The operator is not found.'); } // Show an error if the admin password hasn't been set yet. $no_password = check_password_hash($operator['vclogin'], '', $operator['vcpassword']) && !$request->query->has('stored'); if ($no_password) { $page['errors'][] = getlocal('No Password set for the Administrator'); } $page['formlogin'] = $op['vclogin']; $page['formname'] = $op['vclocalename']; $page['formemail'] = $op['vcemail']; $page['formcommonname'] = $op['vccommonname']; $page['formcode'] = $op['code']; $page['opid'] = $op['operatorid']; } // Override group's fields from the request if it's needed. This // case will take place when a save handler fails and passes the request // to this action. if ($request->isMethod('POST')) { // The login field can be disabled in the form. In that case it will // not has a value. Thus we should override login field only when it // is set. if ($request->request->has('login')) { $page['formlogin'] = $request->request->get('login'); } $page['formname'] = $request->request->get('name'); $page['formemail'] = $request->request->get('email'); $page['formcommonname'] = $request->request->get('commonname'); $page['formcode'] = $request->request->get('code'); } $can_modify = $op_id == $operator['operatorid'] && is_capable(CAN_MODIFYPROFILE, $operator) || is_capable(CAN_ADMINISTRATE, $operator); $page['stored'] = $request->query->has('stored'); $page['canmodify'] = $can_modify ? '1' : ''; // The login cannot be changed for existing operators because it will // make the stored password hash invalid. $page['canchangelogin'] = is_capable(CAN_ADMINISTRATE, $operator) && !$op_id; $page['title'] = getlocal('Operator details'); $page['menuid'] = $op_id == $operator['operatorid'] ? 'profile' : 'operators'; $page['requirePassword'] = !$op_id; $page['formaction'] = $request->getBaseUrl() . $request->getPathInfo(); $page = array_merge($page, prepare_menu($operator)); $page['tabs'] = $this->buildTabs($request); return $this->render('operator_edit', $page); }
/** * Generates a page with Mibew button code form. * * @param Request $request Incoming request * @return Response Rendered content of the page. */ public function generateAction(Request $request) { $operator = $this->getOperator(); $page = array('errors' => array()); $image_locales_map = $this->getImageLocalesMap(MIBEW_FS_ROOT . '/locales'); $image = $request->query->get('i', 'mibew'); if (!isset($image_locales_map[$image])) { $page['errors'][] = 'Unknown image: ' . $image; $avail = array_keys($image_locales_map); $image = $avail[0]; } $image_locales = $image_locales_map[$image]; $style_list = ChatStyle::getAvailableStyles(); $style_list[''] = getlocal('-from general settings-'); $style = $request->query->get('style', ''); if ($style && !in_array($style, $style_list)) { $style = ''; } $invitation_style_list = InvitationStyle::getAvailableStyles(); $invitation_style_list[''] = getlocal('-from general settings-'); $invitation_style = $request->query->get('invitationstyle', ''); if ($invitation_style && !in_array($invitation_style, $invitation_style_list)) { $invitation_style = ''; } $locales_list = get_available_locales(); $group_id = $request->query->getInt('group'); if ($group_id && !group_by_id($group_id)) { $page['errors'][] = getlocal("No such group"); $group_id = false; } $show_host = $request->query->get('hostname') == 'on'; $force_secure = $request->query->get('secure') == 'on'; $mod_security = $request->query->get('modsecurity') == 'on'; $force_windows = $request->query->get('forcewindows') == 'on'; $code_type = $request->query->get('codetype', 'button'); if (!in_array($code_type, array('button', 'operator_code', 'text_link'))) { throw new BadRequestException('Wrong value of "codetype" param.'); } $lang = $request->query->get('lang', ''); if (!preg_match("/^[\\w-]{2,5}\$/", $lang)) { $lang = ''; } $operator_code = $code_type == 'operator_code'; $generate_button = $code_type == 'button'; $button_generator_options = array('chat_style' => $style, 'group_id' => $group_id, 'show_host' => $show_host, 'force_secure' => $force_secure, 'mod_security' => $mod_security, 'prefer_iframe' => !$force_windows); if ($operator_code) { $button_generator = new OperatorCodeFieldGenerator($this->getRouter(), $this->getAssetManager()->getUrlGenerator(), $button_generator_options); } elseif ($generate_button) { // Make sure locale exists if (!$lang || !in_array($lang, $image_locales)) { $lang = in_array(get_current_locale(), $image_locales) ? get_current_locale() : $image_locales[0]; } $button_generator = new ImageButtonGenerator($this->getRouter(), $this->getAssetManager()->getUrlGenerator(), $button_generator_options); // Set generator-specific options $button_generator->setOption('image', $image); } else { // Make sure locale exists if (!$lang || !in_array($lang, $locales_list)) { $lang = in_array(get_current_locale(), $locales_list) ? get_current_locale() : $locales_list[0]; } $button_generator = new TextButtonGenerator($this->getRouter(), $this->getAssetManager()->getUrlGenerator(), $button_generator_options); // Set generator-specific options $button_generator->setOption('caption', getlocal('Click to chat')); } // Set verified locale code to a button generator $button_generator->setOption('locale', $lang); $page['buttonCode'] = $button_generator->generate(); $page['availableImages'] = array_keys($image_locales_map); $page['availableLocales'] = $generate_button ? $image_locales : $locales_list; $page['availableChatStyles'] = $style_list; $page['availableInvitationStyles'] = $invitation_style_list; $page['groups'] = $this->getGroupsList(); $page['availableCodeTypes'] = array('button' => getlocal('button'), 'operator_code' => getlocal('operator code field'), 'text_link' => getlocal('text link')); $page['formgroup'] = $group_id; $page['formstyle'] = $style; $page['forminvitationstyle'] = $invitation_style; $page['formimage'] = $image; $page['formlang'] = $lang; $page['formhostname'] = $show_host; $page['formsecure'] = $force_secure; $page['formmodsecurity'] = $mod_security; $page['formcodetype'] = $code_type; $page['formforcewindows'] = $force_windows; $page['enabletracking'] = Settings::get('enabletracking'); $page['operator_code'] = $operator_code; $page['generateButton'] = $generate_button; $page['title'] = getlocal("Button HTML code generation"); $page['menuid'] = "getcode"; $page = array_merge($page, prepare_menu($operator)); return $this->render('button_code', $page); }
/** * Processes submitting of the forms which is generated in * {@link \Mibew\Controller\CannedMessageController::showEditFormAction()} * method. * * @param Request $request * @return string Rendered page content */ public function submitEditFormAction(Request $request) { csrf_check_token($request); $operator = $this->getOperator(); $message_id = $request->attributes->getInt('message_id'); $errors = array(); $title = $request->request->get('title'); if (!$title) { $errors[] = no_field("Title"); } $message = $request->request->get('message'); if (!$message) { $errors[] = no_field("Message"); } if (count($errors) != 0) { $request->attributes->set('errors', $errors); // The form should be rebuild. Invoke appropriate action. return $this->showEditFormAction($request); } if ($message_id) { save_canned_message($message_id, $title, $message); } else { $locale = $this->extractLocale($request); $group_id = $this->extractGroupId($request); add_canned_message($locale, $group_id, $title, $message); } $page['saved'] = true; $page = array_merge($page, prepare_menu($operator, false)); return $this->render('canned_message_edit', $page); }
/** * Processes submitting of the form which is generated in * {@link \Mibew\Controller\TranslateController::showEditFormAction()} * method. * * @param Request $request Incoming request. * @return string Rendered page content. */ public function submitEditFormAction(Request $request) { csrf_check_token($request); $operator = $this->getOperator(); $errors = array(); $string_id = $request->attributes->get('string_id'); $string = $this->loadString($string_id); if (!$string) { throw new NotFoundException('The string is not found.'); } $target = $string['locale']; $translation = $request->request->get('translation'); if (!$translation) { $errors[] = no_field("Translation"); } if (count($errors) != 0) { $request->attributes->set('errors', $errors); // The form should be rebuild. Invoke appropriate action. return $this->showEditFormAction($request); } save_message($target, $string['source'], $translation); // Remove cached client side translations. $this->getCache()->getItem('translation/js/' . $target)->clear(); $page['saved'] = true; $page['title'] = getlocal("Translations"); $page = array_merge($page, prepare_menu($operator, false)); return $this->render('translation_edit', $page); }
/** * Builds locale edit page. * * @param Request $request Incoming request. * @return string Rendered page content. * @throws NotFoundException If the locale with specified code is not found * in the system. */ public function showEditFormAction(Request $request) { $page = array('errors' => $request->attributes->get('errors', array())); $locale = $request->attributes->get('locale'); // Check if locale exists and enabled. if (!in_array($locale, get_available_locales())) { throw new NotFoundException(); } $info = get_locale_info($locale); $page['formtimelocale'] = $info['time_locale']; $page['formdateformatfull'] = $info['date_format']['full']; $page['formdateformatdate'] = $info['date_format']['date']; $page['formdateformattime'] = $info['date_format']['time']; // Override fields from the request if it's needed. This case will take // place when a save handler fails and passes the request to this // action. if ($request->isMethod('POST')) { $page['formtimelocale'] = $request->request->get('timelocale'); $page['formdateformatfull'] = $request->request->get('dateformatfull'); $page['formdateformatdate'] = $request->request->get('dateformatdate'); $page['formdateformattime'] = $request->request->get('dateformattime'); } $page['stored'] = $request->query->has('stored'); $page['title'] = getlocal('Locale details'); $page['menuid'] = 'translation'; $page['formaction'] = $request->getBaseUrl() . $request->getPathInfo(); $page = array_merge($page, prepare_menu($this->getOperator())); $page['tabs'] = $this->buildTabs($request); return $this->render('locale_edit', $page); }
/** * Processes submitting of the form which is generated in * {@link \Mibew\Controller\BanController::showEditFormAction()} method. * * @param Request $request Incoming request. * @return string Rendered page content. * @throws NotFoundException If the ban with specified ID is not found in * the system. */ public function submitEditFormAction(Request $request) { csrf_check_token($request); $operator = $this->getOperator(); $errors = array(); $page = array('banId' => '', 'saved' => false); // Get form fields and validate them $ban_id = $request->attributes->getInt('ban_id'); $address = $request->request->get('address'); $days = $request->request->get('days'); $comment = $request->request->get('comment'); if (!$address) { $errors[] = no_field('Visitor\'s Address'); } if (!preg_match("/^\\d+\$/", $days)) { $errors[] = wrong_field('Days'); } if (!$comment) { $errors[] = no_field('Comment'); } // Check if the ban already exists in the database $existing_ban = Ban::loadByAddress($address); $ban_duplicate = !$ban_id && $existing_ban || $ban_id && $existing_ban && $ban_id != $existing_ban->id; if ($ban_duplicate) { $ban_url = $this->generateUrl('ban_edit', array('ban_id' => $existing_ban->id)); $errors[] = getlocal('The specified address is already in use. Click <a href="{1}">here</a> if you want to edit it.', array($address, $ban_url)); } if (count($errors) != 0) { $request->attributes->set('errors', $errors); // The form should be rebuild. Invoke appropriate action. return $this->showEditFormAction($request); } // Save ban into the database if (!$ban_id) { $ban = new Ban(); $ban->created = time(); } else { $ban = Ban::load($ban_id); if (!$ban) { throw new NotFoundException('The ban is not found.'); } } $ban->till = time() + $days * 24 * 60 * 60; $ban->address = $address; $ban->comment = $comment; $ban->save(); // Rerender the form page $page['saved'] = true; $page['address'] = $address; $page['title'] = getlocal('Block address'); $page = array_merge($page, prepare_menu($operator, false)); return $this->render('ban', $page); }
} if ($show == 'redirect' || $show == 'redirected' || $show == 'agentchat' || $show == 'agentrochat') { setup_chatview_for_operator(array('threadid' => 0, 'userName' => getstring("chat.default.username"), 'remote' => "1.2.3.4", 'agentId' => 1, 'groupid' => 0, 'userid' => 'visitor1', 'locale' => $current_locale, 'ltoken' => $show == 'agentrochat' ? 124 : 123), array('operatorid' => $show == 'agentrochat' ? 2 : 1)); if ($show == 'redirect') { setup_redirect_links(0, $show == 'agentrochat' ? 124 : 123); } elseif ($show == 'redirected') { $page['message'] = getlocal2("chat.redirected.content", array("Administrator")); } $page['redirectLink'] = "{$webimroot}/operator/themes.php?preview={$preview}&show=redirect"; expand("../styles", "{$preview}", "{$show}.tpl"); exit; } $templateList = array(array('label' => getlocal("page.preview.userchat"), 'id' => 'chat', 'h' => 480, 'w' => 640), array('label' => getlocal("page.preview.chatsimple"), 'id' => 'chatsimple', 'h' => 480, 'w' => 640), array('label' => getlocal("page.preview.nochat"), 'id' => 'nochat', 'h' => 480, 'w' => 640), array('label' => getlocal("page.preview.survey"), 'id' => 'survey', 'h' => 480, 'w' => 640), array('label' => getlocal("page.preview.leavemessage"), 'id' => 'leavemessage', 'h' => 480, 'w' => 640), array('label' => getlocal("page.preview.leavemessagesent"), 'id' => 'leavemessagesent', 'h' => 480, 'w' => 640), array('label' => getlocal("page.preview.mail"), 'id' => 'mail', 'h' => 254, 'w' => 603), array('label' => getlocal("page.preview.mailsent"), 'id' => 'mailsent', 'h' => 254, 'w' => 603), array('label' => getlocal("page.preview.redirect"), 'id' => 'redirect', 'h' => 480, 'w' => 640), array('label' => getlocal("page.preview.redirected"), 'id' => 'redirected', 'h' => 480, 'w' => 640), array('label' => getlocal("page.preview.agentchat"), 'id' => 'agentchat', 'h' => 480, 'w' => 640), array('label' => getlocal("page.preview.agentrochat"), 'id' => 'agentrochat', 'h' => 480, 'w' => 640), array('label' => getlocal("page.preview.error"), 'id' => 'error', 'h' => 480, 'w' => 640)); $template = verifyparam("template", "/^\\w+\$/", "chat"); $page['formpreview'] = $preview; $page['formtemplate'] = $template; $page['canshowerrors'] = $template == 'leavemessage' || $template == 'mail' || $template == 'all'; $page['formshowerr'] = $showerrors; $page['availablePreviews'] = $stylelist; $page['availableTemplates'] = array("chat", "chatsimple", "nochat", "survey", "leavemessage", "leavemessagesent", "mail", "mailsent", "redirect", "redirected", "agentchat", "agentrochat", "error", "all"); $page['showlink'] = "{$webimroot}/operator/themes.php?preview={$preview}&" . ($showerrors ? "showerr=on&" : "") . "show="; $page['previewList'] = array(); foreach ($templateList as $tpl) { if ($tpl['id'] == $template || $template == 'all') { $page['previewList'][] = $tpl; } } prepare_menu($operator); start_html_output(); setup_settings_tabs(3); require '../view/themes.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); }