/** * Add a secret token to the form (requires the S_FORM_TOKEN template variable) * @param string $form_name The name of the form; has to match the name used in check_form_key, otherwise no restrictions apply */ public function get_form_key($form_name) { add_form_key($form_name); $rootref = $this->template_context->get_root_ref(); $s_form_token = $rootref['S_FORM_TOKEN']; return $s_form_token; }
/** * Enable confirmation */ public function page_footer($event) { $rootref =& $this->template_context->get_root_ref(); foreach (array('FORUMS', 'TOPICS') as $target) { if (!empty($rootref['U_MARK_' . $target])) { $this->user->add_lang_ext('kasimi/markreadconfirm', 'common'); $this->template->assign_vars(array('MARKREADCONFIRM' => true, 'MARKREADCONFIRM_TARGET' => strtolower($target), 'MARKREADCONFIRM_LANG' => $this->user->lang('MARKREADCONFIRM_' . $target))); break; } } }
/** * Updates the template data by inserting the (possibly selected) 'Created time' <option> into the $select tag right after the 'Post time' <option> * * @param string $template_select_key_var * @param string $sort_key * @param bool $template_select_dir_var * @param bool $sort_dir */ protected function inject_created_time_select_option($template_select_key_var, $sort_key, $template_select_dir_var = false, $sort_dir = false) { $rootref =& $this->template_context->get_root_ref(); $select = $rootref[$template_select_key_var]; // Insert 'Created time' $this->user->add_lang_ext('kasimi/sorttopics', 'common'); $new_option = '<option value="c">' . $this->user->lang('SORTTOPICS_CREATED_TIME') . '</option>'; $select = preg_replace("/(value=\"t\".*?<\\/option>)/su", "\$1" . $new_option, $select); // Fix selection $select = $this->set_selected($select, $sort_key); $rootref[$template_select_key_var] = $select; if ($template_select_dir_var !== false && $sort_dir !== false) { $rootref[$template_select_dir_var] = $this->set_selected($rootref[$template_select_dir_var], $sort_dir); } }
/** * {@inheritdoc} */ public function display(array $settings, $edit_mode = false) { $data = $this->context->get_data_ref(); if (!empty($data['.'][0]['TOTAL_USERS_ONLINE'])) { $l_online_users = $data['.'][0]['TOTAL_USERS_ONLINE']; $online_userlist = $data['.'][0]['LOGGED_IN_USER_LIST']; $l_online_record = $data['.'][0]['RECORD_USERS']; } else { $item_id = 0; $item = 'forum'; $online_users = obtain_users_online($item_id, $item); $user_online_strings = obtain_users_online_string($online_users, $item_id, $item); $l_online_users = $user_online_strings['l_online_users']; $online_userlist = $user_online_strings['online_userlist']; $l_online_record = $this->user->lang('RECORD_ONLINE_USERS', (int) $this->config['record_online_users'], $this->user->format_date($this->config['record_online_date'], false, true)); } $this->ptemplate->assign_vars(array('TOTAL_USERS_ONLINE' => $l_online_users, 'LOGGED_IN_USER_LIST' => $online_userlist, 'RECORD_USERS' => $l_online_record, 'U_VIEWONLINE' => $this->_get_viewonline_url())); unset($data); return array('title' => 'WHO_IS_ONLINE', 'content' => $this->ptemplate->render_view('blitze/sitemaker', 'blocks/whois.html', 'whois_block')); }
/** * Get output for a language variable (L_FOO, LA_FOO) * * This function checks to see if the language var was outputted to $context * (e.g. in the ACP, L_TITLE) * If not, we return the result of $user->lang() * * @return string */ function lang() { $args = func_get_args(); $key = $args[0]; $context = $this->context->get_data_ref(); $context_vars = $context['.'][0]; if (isset($context_vars['L_' . $key])) { return $context_vars['L_' . $key]; } // LA_ is transformed into lang(\'$1\')|escape('js'), so we should not // need to check for it return call_user_func_array(array($this->language, 'lang'), $args); }
/** * Apply custom sorting to SQL query * * @param $event */ public function viewforum_get_topic_ids_data($event) { $this->sort_options_source = 'default'; $this->custom_sort_key = $this->user->data['user_topic_sortby_type']; $this->custom_sort_dir = $this->user->data['user_topic_sortby_dir']; if ($event['forum_data']['sort_topics_by'] != $this->default_sort_by) { // Forum-specific sorting $this->sort_options_source = 'forum'; $this->custom_sort_key = $event['forum_data']['sort_topics_by']; $this->custom_sort_dir = $event['forum_data']['sort_topics_order']; } else { if ($this->user->data['is_registered'] && $this->config['kasimi.sorttopics.ucp_enabled'] && $this->user->data['sort_topics_by_created_time']) { // UCP-specific sorting by created time $this->sort_options_source = 'ucp'; $this->custom_sort_key = 'c'; } } // Temporary sorting if the user used the options at the bottom of viewforum if ($this->request->is_set('sk')) { $this->sort_options_source = 'request'; $this->custom_sort_key = $this->request->variable('sk', $this->custom_sort_key); $this->custom_sort_dir = $this->request->variable('sd', $this->custom_sort_dir); } $this->inject_created_time_select_option('S_SELECT_SORT_KEY', $this->custom_sort_key, 'S_SELECT_SORT_DIR', $this->custom_sort_dir); // Bail out if we don't need to adjust sorting if ($this->custom_sort_key == $this->sort_key && $this->custom_sort_dir == $this->sort_dir) { return; } // This forum requires custom topic sorting, let's get our hands dirty $sort_by_sql = array('a' => 't.topic_first_poster_name', 't' => array('t.topic_last_post_time', 't.topic_last_post_id'), 'c' => array('t.topic_time', 't.topic_id'), 'r' => $this->auth->acl_get('m_approve', $event['forum_data']['forum_id']) ? 't.topic_posts_approved + t.topic_posts_unapproved + t.topic_posts_softdeleted' : 't.topic_posts_approved', 's' => 't.topic_title', 'v' => 't.topic_views'); $store_reverse = $event['store_reverse']; if ($store_reverse) { $direction = $this->custom_sort_dir == 'd' ? 'ASC' : 'DESC'; } else { $direction = $this->custom_sort_dir == 'd' ? 'DESC' : 'ASC'; } if (is_array($sort_by_sql[$this->custom_sort_key])) { $sql_sort_order = implode(' ' . $direction . ', ', $sort_by_sql[$this->custom_sort_key]) . ' ' . $direction; } else { $sql_sort_order = $sort_by_sql[$this->custom_sort_key] . ' ' . $direction; } $sql_ary = $event['sql_ary']; $sql_ary['ORDER_BY'] = 't.topic_type ' . (!$store_reverse ? 'DESC' : 'ASC') . ', ' . $sql_sort_order; $event['sql_sort_order'] = $sql_sort_order; $event['sql_ary'] = $sql_ary; $rootref =& $this->template_context->get_root_ref(); if ($this->sort_options_source == 'request' && $this->custom_sort_key == 'c') { $rootref['U_VIEW_FORUM'] .= '&sk=c'; } }
/** * {@inheritdoc} */ public function alter_block_array($blockname, array $vararray, $key = false, $mode = 'insert') { return $this->context->alter_block_array($blockname, $vararray, $key, $mode); }