/** * Display the user ranks page * * @return \Symfony\Component\HttpFoundation\Response A Symfony Response object * @access public */ public function display($name) { // Get the rank details $sql = 'SELECT * FROM ' . RANKS_TABLE . ' ORDER BY rank_special DESC, rank_min ASC, rank_title ASC'; $result = $this->db->sql_query($sql); while ($row = $this->db->sql_fetchrow($result)) { if ($this->config['userranks_special'] || $this->config['userranks_special_admin'] && $this->auth->acl_get('a_') || !$this->config['userranks_special'] && !$row['rank_special']) { $rank_row = array('S_RANK_IMAGE' => $row['rank_image'] ? true : false, 'S_SPECIAL_RANK' => $row['rank_special'] ? true : false, 'RANK_IMAGE' => $this->path_helper->get_web_root_path() . $this->config['ranks_path'] . '/' . $row['rank_image'], 'RANK_TITLE' => $row['rank_title'], 'MIN_POSTS' => $row['rank_min']); $this->template->assign_block_vars('ranks', $rank_row); // Are we displaying members? if ($this->config['userranks_members'] || $this->config['userranks_members_admin'] && $this->auth->acl_get('a_')) { $rank_users = $this->get_user_rank_data($row['rank_id']); if (sizeof($rank_users) > 0) { foreach ($rank_users as $row_rank) { $this->template->assign_block_vars('ranks.rank_member', array('MEMBERS' => get_username_string('full', $row_rank['user_id'], $row_rank['username'], $row_rank['user_colour']))); } } else { $this->template->assign_block_vars('ranks.rank_member', array('MEMBERS' => $this->user->lang('NO_MEMBERS'))); } } } } $this->db->sql_freeresult($result); // Assign breadcrumb template vars for the user ranks page $this->template->assign_block_vars('navlinks', array('U_VIEW_FORUM' => $this->helper->route('david63_userranks_main_controller', array('name' => 'ranks')), 'FORUM_NAME' => $this->user->lang('USER_RANKS'))); // Send all data to the template file return $this->helper->render('user_ranks.html', $name); }
/** * Constructor * * @param \phpbb\path_helper $path_helper Path helper object * @param \phpbb\template\template $template Template object * @param \phpbb\template\context $template_context Template context object */ public function __construct(\phpbb\path_helper $path_helper, \phpbb\template\template $template, \phpbb\template\context $template_context) { $this->template = $template; $this->template_context = $template_context; $this->asset_path = $path_helper->get_web_root_path(); $this->scripts = array('js' => array(), 'css' => array()); }
/** * Constructor * * @param driver_interface $cache Cache service * @param config $config Installer config handler * @param path_helper $path_helper Path helper */ public function __construct(driver_interface $cache, config $config, path_helper $path_helper) { $this->cache = $cache; $this->install_config = $config; $this->installer_modules = null; $this->web_root = $path_helper->get_web_root_path(); }
/** * Constructor * * @param driver_interface $cache Cache service * @param config $config Installer config handler * @param path_helper $path_helper Path helper * @param container_factory $container Container */ public function __construct(driver_interface $cache, config $config, path_helper $path_helper, container_factory $container) { $this->cache = $cache; $this->install_config = $config; $this->container_factory = $container; $this->installer_modules = null; $this->web_root = $path_helper->get_web_root_path(); $this->purge_cache_before = false; }
/** * Constructor * * @param \phpbb\config\config $phpbb_config The phpBB configuration * @param \phpbb\path_helper $path_helper phpBB path helper * @param \phpbb\extension\manager $extension_manager phpBB extension manager * @param \Twig_LoaderInterface $loader Twig loader interface * @param array $options Array of options to pass to Twig */ public function __construct($phpbb_config, \phpbb\path_helper $path_helper, \phpbb\extension\manager $extension_manager = null, \Twig_LoaderInterface $loader = null, $options = array()) { $this->phpbb_config = $phpbb_config; $this->phpbb_path_helper = $path_helper; $this->extension_manager = $extension_manager; $this->phpbb_root_path = $this->phpbb_path_helper->get_phpbb_root_path(); $this->web_root_path = $this->phpbb_path_helper->get_web_root_path(); return parent::__construct($loader, $options); }
public function submit() { // Subscriptions if (!$this->attention_id) { $u_view = $this->controller_helper->route('phpbb.titania.manage.attention.redirect', array('type' => $this->attention_type, 'id' => $this->attention_object_id)); $email_vars = array('NAME' => $this->attention_title, 'U_VIEW' => $this->path_helper->strip_url_params($u_view, 'sid')); $this->subscriptions->send_notifications(TITANIA_ATTENTION, 0, 'subscribe_notify', $email_vars, $this->attention_poster_id); } parent::submit(); }
/** * Constructor * * @param \phpbb\config\config $phpbb_config The phpBB configuration * @param \phpbb\filesystem\filesystem $filesystem * @param \phpbb\path_helper $path_helper phpBB path helper * @param \Symfony\Component\DependencyInjection\ContainerInterface $container The dependency injection container * @param string $cache_path The path to the cache directory * @param \phpbb\extension\manager $extension_manager phpBB extension manager * @param \Twig_LoaderInterface $loader Twig loader interface * @param array $options Array of options to pass to Twig */ public function __construct(\phpbb\config\config $phpbb_config, \phpbb\filesystem\filesystem $filesystem, \phpbb\path_helper $path_helper, \Symfony\Component\DependencyInjection\ContainerInterface $container, $cache_path, \phpbb\extension\manager $extension_manager = null, \Twig_LoaderInterface $loader = null, $options = array()) { $this->phpbb_config = $phpbb_config; $this->filesystem = $filesystem; $this->phpbb_path_helper = $path_helper; $this->extension_manager = $extension_manager; $this->container = $container; $this->phpbb_root_path = $this->phpbb_path_helper->get_phpbb_root_path(); $this->web_root_path = $this->phpbb_path_helper->get_web_root_path(); $options = array_merge(array('cache' => defined('IN_INSTALL') ? false : $cache_path, 'debug' => false, 'auto_reload' => (bool) $this->phpbb_config['load_tplcompile'], 'autoescape' => false), $options); return parent::__construct($loader, $options); }
/** * Assign global template vars, based on the ACP config of the extension */ public function global_style_append() { $pbwow_config = $this->pbwow_config; if (isset($pbwow_config) && is_array($pbwow_config)) { extract($pbwow_config); } else { return; } $tpl_vars = array(); $body_class = ' pbwow-ext'; // Logo if ($logo_enable && isset($logo_src) && isset($logo_size_width) && isset($logo_size_height) && $logo_size_width > 1 && $logo_size_height > 1) { $tpl_vars += array('S_PBLOGO' => true, 'PBLOGO_SRC' => $this->path_helper->update_web_root_path($this->root_path . html_entity_decode($logo_src)), 'PBLOGO_WIDTH' => $logo_size_width, 'PBLOGO_HEIGHT' => $logo_size_height, 'PBLOGO_WIDTH_MOB' => floor($logo_size_width * 0.8), 'PBLOGO_HEIGHT_MOB' => floor($logo_size_height * 0.8), 'PBLOGO_MARGINS' => $logo_margins); if (isset($logo_margins) && strlen($logo_margins) > 0) { $tpl_vars += array('PBLOGO_MARGINS' => $logo_margins); } } // Top-bar if ($topbar_enable && isset($topbar_code)) { $tpl_vars += array('TOPBAR_CODE' => str_replace('&', '&', html_entity_decode($topbar_code))); $body_class .= ' topbar'; if ($topbar_fixed) { $tpl_vars += array('S_TOPBAR_FIXED' => true); $body_class .= ' topbar-fixed'; } } // Video BG if ($videobg_enable) { $tpl_vars += array('S_VIDEOBG' => true); $body_class .= ' videobg'; if ($videobg_allpages) { $tpl_vars += array('S_VIDEOBG_ALL' => true); $body_class .= ' videobg-all'; } } // Fixed BG if ($fixedbg) { $tpl_vars += array('S_FIXEDBG' => true); $body_class .= ' fixedbg'; if ($topbar_enable && !$topbar_fixed) { // if we don't do this, scrolling down will look weird $body_class .= ' topbar-fixed'; } } // Misc $tpl_vars += array('HEADERLINKS_CODE' => $headerlinks_enable && isset($headerlinks_code) ? str_replace('&', '&', html_entity_decode($headerlinks_code)) : false, 'ADS_INDEX_CODE' => $ads_index_enable && isset($ads_index_code) ? str_replace('&', '&', html_entity_decode($ads_index_code)) : false, 'S_PBWOW_AVATARS' => isset($avatars_enable) ? $avatars_enable : false, 'S_SMALL_RANKS' => isset($smallranks_enable) && $this->avatars_enabled ? $smallranks_enable : false); // Assign vars $this->template->assign_vars($tpl_vars); $this->template->append_var('BODY_CLASS', $body_class); }
/** * Constructor * * @param \phpbb\config\config $config Config object * @param \phpbb\controller\helper $helper Controller helper object * @param \phpbb\cache\service $cache Cache object * @param \phpbb\db\driver\driver $db Database object * @param \phpbb\template\template $template Template object * @param \phpbb\user $user User object * @param string $flags_table Name of the table used to store flag data * @param \phpbb\extension\manager $ext_manager Extension manager object * @param \phpbb\path_helper $path_helper Path helper object */ public function __construct(\phpbb\config\config $config, \phpbb\controller\helper $helper, \phpbb\cache\service $cache, \phpbb\db\driver\driver_interface $db, \phpbb\template\template $template, \phpbb\user $user, $flags_table, \phpbb\extension\manager $ext_manager, \phpbb\path_helper $path_helper) { $this->config = $config; $this->helper = $helper; $this->cache = $cache; $this->db = $db; $this->template = $template; $this->user = $user; $this->flags_table = $flags_table; $this->ext_manager = $ext_manager; $this->path_helper = $path_helper; $this->ext_path = $this->ext_manager->get_extension_path('rmcgirr83/nationalflags', true); $this->ext_path_web = $this->path_helper->update_web_root_path($this->ext_path); }
/** * Assign global template variables * * @return null */ public function assign_global_vars() { $this->generate_breadcrumbs(array('CUSTOMISATION_DATABASE' => $this->controller_helper->route('phpbb.titania.index'))); $u_my_contribs = $u_manage = false; if ($this->user->data['is_registered'] && !$this->user->data['is_bot']) { $u_my_contribs = $this->controller_helper->route('phpbb.titania.author', array('author' => urlencode($this->user->data['username_clean']), 'page' => 'contributions')); } $manageable_types = $this->types->find_authed(); if (!empty($manageable_types) || $this->auth->acl_get('u_titania_mod_contrib_mod') || $this->auth->acl_get('u_titania_mod_post_mod')) { $u_manage = $this->controller_helper->route('phpbb.titania.manage'); } $web_root_path = $this->path_helper->get_web_root_path(); $style_path = $web_root_path . 'ext/phpbb/titania/styles/' . rawurlencode($this->user->style['style_path']) . '/'; $this->template->assign_vars(array('T_TITANIA_TEMPLATE_PATH' => $style_path . 'template', 'T_TITANIA_THEME_PATH' => $style_path . 'theme', 'T_TITANIA_IMAGES_PATH' => $web_root_path . 'images', 'T_TITANIA_ASSETS_PATH' => $web_root_path . 'ext/phpbb/titania/assets', 'TITANIA_ROOT_PATH' => $web_root_path, 'U_MANAGE' => $u_manage, 'U_MY_CONTRIBUTIONS' => $u_my_contribs, 'U_ALL_SUPPORT' => $this->controller_helper->route('phpbb.titania.support'), 'U_TITANIA_INDEX' => $this->controller_helper->route('phpbb.titania.index'), 'U_TITANIA_FAQ' => $this->controller_helper->route('phpbb.titania.faq'), 'S_IN_TITANIA' => true)); }
/** * Constructor * * @param template $template * @param user $user * @param db_driver $db * @param auth $auth * @param request $request * @param helper $helper * @param db $config * @param manager $ext_manager * @param path_helper $path_helper * @param Container $container * @param string $table_prefix * @param string $root_path * @param string $php_ext */ public function __construct(template $template, user $user, db_driver $db, auth $auth, request $request, helper $helper, db $config, manager $ext_manager, path_helper $path_helper, Container $container, $table_prefix, $root_path, $php_ext) { $this->template = $template; $this->user = $user; $this->db = $db; $this->auth = $auth; $this->request = $request; $this->helper = $helper; $this->config = $config; $this->root_path = $root_path; $this->php_ext = $php_ext; $this->ext_manager = $ext_manager; $this->path_helper = $path_helper; $this->container = $container; $this->table_prefix = $table_prefix; $this->user->add_lang('posting'); $this->user->add_lang_ext('spaceace/ajaxchat', 'ajax_chat'); // sets desired status times $this->times = ['online' => $this->config['status_online_chat'], 'idle' => $this->config['status_idle_chat'], 'offline' => $this->config['status_offline_chat']]; //set delay for each status $this->delay = ['online' => $this->config['delay_online_chat'], 'idle' => $this->config['delay_idle_chat'], 'offline' => $this->config['delay_offline_chat']]; if (!defined('CHAT_TABLE')) { $chat_table = $this->table_prefix . 'ajax_chat'; define('CHAT_TABLE', $chat_table); } if (!defined('CHAT_SESSIONS_TABLE')) { $chat_session_table = $this->table_prefix . 'ajax_chat_sessions'; define('CHAT_SESSIONS_TABLE', $chat_session_table); } include $this->root_path . 'includes/functions_posting.' . $this->php_ext; include $this->root_path . 'includes/functions_display.' . $this->php_ext; $this->ext_path = $this->ext_manager->get_extension_path('spaceace/ajaxchat', true); $this->ext_path_web = $this->path_helper->update_web_root_path($this->ext_path); $this->post = $this->request->get_super_global(\phpbb\request\request_interface::POST); }
/** * Build pagination and send to template * $this->url_location and $this->url_parameters will over-ride the settings given here for $page, $params. * The reason is that the place that calls build_pagination is typically in a completely different area, in an area that can't say for certain the correct URL (other than the current page) * * @param string $page path/page to be used in pagination url * @param array $params to be used in pagination url * @return $this */ public function build_pagination($page, $params = array()) { if ($this->url_location) { $page = $this->url_location; } if ($this->url_parameters) { $params = $this->url_parameters; } // Spring cleaning unset($params[$this->start_name], $params[$this->limit_name], $params[$this->sort_key_name], $params[$this->sort_dir_name]); // Add the limit to the URL if required if ($this->limit != $this->default_limit) { $params[$this->limit_name] = $this->limit; } // Don't include the sort key/dir in the sort action url $sort_url = $this->path_helper->append_url_params($page, $params); // Add the sort key to the URL if required if ($this->sort_key != $this->default_sort_key) { $params[$this->sort_key_name] = $this->sort_key; } // Add the sort dir to the URL if required if ($this->sort_dir != $this->default_sort_dir) { $params[$this->sort_dir_name] = $this->sort_dir; } $pagination_url = $this->path_helper->append_url_params($page, $params); $this->pagination->generate_template_pagination($pagination_url, $this->template_block, 'start', $this->total, $this->limit, $this->start); if ($this->template_block == 'pagination') { $this->template->assign_vars(array($this->template_vars['S_SORT_ACTION'] => $sort_url, $this->template_vars['S_PAGINATION_ACTION'] => $pagination_url, $this->template_vars['S_NUM_POSTS'] => $this->total, $this->template_vars['S_SELECT_SORT_KEY'] => $this->get_sort_key_list(), $this->template_vars['S_SELECT_SORT_DIR'] => $this->get_sort_dir_list(), $this->template_vars['SORT_KEYS_NAME'] => $this->sort_key_name, $this->template_vars['SORT_DIR_NAME'] => $this->sort_dir_name, $this->template_vars['TOTAL_ITEMS'] => $this->total, $this->template_vars['TOTAL_RESULTS'] => $this->user->lang($this->result_lang, $this->total))); } return $this; }
/** * Get a list of all users on the board that can be mentioned. Keys are the usernames utf8_cleaned. * Data is cached after the first call. * * @param string|bool $query_string False, if all users should be retrieved. Otherwise a string wich should be searched for. * @return array Array containing data of all users */ public function get_userlist($query_string = false) { // If we need the complete list and it is cached, we can return it. if ($query_string == false && self::$user_list) { return self::$user_list; } $cache_time = 300; $sql_ary = array('SELECT' => '*', 'FROM' => array(USERS_TABLE => 'u'), 'WHERE' => 'user_posts >= ' . $this->config['wolfsblvt.mentions.min_posts_suggest'] . ' AND user_type <> ' . USER_IGNORE, 'ORDER_BY' => 'username'); if ($query_string) { $escaped_query_string_clean = $this->db->sql_escape(utf8_clean_string($query_string)); $query_string['WHERE'] .= ' username_clean ' . $this->db->sql_like_expression($escaped_query_string_clean . $this->db->get_any_char()); } $sql = $this->db->sql_build_query('SELECT', $sql_ary); $result = $this->db->sql_query($sql, $cache_time); $user_list = array(); while ($row = $this->db->sql_fetchrow($result)) { $user_data = array('name' => $row['username'], 'user_id' => $row['user_id'], 'posts' => $row['user_posts'], 'colour' => $row['user_colour'], 'avatar' => phpbb_get_user_avatar($row), 'username_full' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']), 'username_no_profile' => get_username_string('no_profile', $row['user_id'], $row['username'], $row['user_colour'])); if ($user_data['avatar'] == '') { $default_avatar_url = $this->path_helper->get_web_root_path() . $this->ext_root_path . '/styles/' . $this->user->style['style_path'] . '/theme' . '/images/no_avatar.gif'; // Check if file exists, otherwise take from "/all" folder. The administrator hasn't chosen a specific no_avatar avatar for this style then if (!file_exists($default_avatar_url)) { $default_avatar_url = $this->path_helper->get_web_root_path() . $this->ext_root_path . '/styles/all/theme' . '/images/no_avatar.gif'; } $user_data['avatar'] = '<img src="' . $default_avatar_url . '" width="100" height="100" alt="' . $this->user->lang['USER_AVATAR'] . '">'; } $user_list[$row['username_clean']] = $user_data; } $this->db->sql_freeresult($result); // If we have the complete list, we can cache it. if ($query_string == false) { self::$user_list = $user_list; } return $user_list; }
/** * Assign module's template vars * * @param array $row Database row of module * @param mixed $template_module Template data as returned by module * * @return null */ public function assign_module_vars($row, $template_module) { if (is_array($template_module)) { $this->template->assign_block_vars('modules_' . $this->portal_columns->number_to_string($row['module_column']), array('TEMPLATE_FILE' => $this->parse_template_file($template_module['template']), 'IMAGE_SRC' => $this->path_helper->get_web_root_path() . ltrim($this->root_path . 'styles/all/theme/images/portal/' . $template_module['image_src'], './'), 'TITLE' => $template_module['title'], 'CODE' => $template_module['code'], 'MODULE_ID' => $row['module_id'], 'IMAGE_WIDTH' => $row['module_image_width'], 'IMAGE_HEIGHT' => $row['module_image_height'])); } else { $this->template->assign_block_vars('modules_' . $this->portal_columns->number_to_string($row['module_column']), array('TEMPLATE_FILE' => $this->parse_template_file($template_module), 'IMAGE_SRC' => $this->path_helper->get_web_root_path() . ltrim($this->root_path . 'styles/all/theme/images/portal/' . $row['module_image_src'], './'), 'IMAGE_WIDTH' => $row['module_image_width'], 'IMAGE_HEIGHT' => $row['module_image_height'], 'MODULE_ID' => $row['module_id'], 'TITLE' => isset($this->user->lang[$row['module_name']]) ? $this->user->lang[$row['module_name']] : utf8_normalize_nfc($row['module_name']))); } }
public function acp_manage_group_display_form($event) { $data = $event['group_row']; $data['group_usermap_marker'] = isset($data['group_usermap_marker']) ? $data['group_usermap_marker'] : ''; $data['group_usermap_legend'] = isset($data['group_usermap_legend']) ? $data['group_usermap_legend'] : ''; $path = $this->path_helper->update_web_root_path($this->phpbb_extension_manager->get_extension_path('tas2580/usermap', true) . 'marker/groups/'); $this->template->assign_vars(array('USERMAP_MARKER' => !empty($data['group_usermap_marker']) ? $path . $data['group_usermap_marker'] : $this->path_helper->update_web_root_path($this->phpbb_root_path . '/images/') . 'spacer.gif', 'USERMAP_MARKER_PATH' => $path, 'USERMAP_OPTIONS' => $this->marker_image_select($data['group_usermap_marker'], 'marker/groups/'), 'USERMAP_LEGEND' => $data['group_usermap_legend'])); }
/** * Constructor. * * @param \phpbb\path_helper $path_helper * @param \phpbb\config\config $config * @param \phpbb\user $user * @param \phpbb\template\context $context template context * @param \phpbb\extension\manager $extension_manager extension manager, if null then template events will not be invoked */ public function __construct(\phpbb\path_helper $path_helper, $config, $user, \phpbb\template\context $context, \phpbb\extension\manager $extension_manager = null) { $this->path_helper = $path_helper; $this->phpbb_root_path = $path_helper->get_phpbb_root_path(); $this->php_ext = $path_helper->get_php_ext(); $this->config = $config; $this->user = $user; $this->context = $context; $this->extension_manager = $extension_manager; $this->cachepath = $this->phpbb_root_path . 'cache/twig/'; // Initiate the loader, __main__ namespace paths will be setup later in set_style_names() $loader = new \phpbb\template\twig\loader(''); $this->twig = new \phpbb\template\twig\environment( $this->config, $this->path_helper, $this->extension_manager, $loader, array( 'cache' => (defined('IN_INSTALL')) ? false : $this->cachepath, 'debug' => defined('DEBUG'), 'auto_reload' => (bool) $this->config['load_tplcompile'], 'autoescape' => false, ) ); $this->twig->addExtension( new \phpbb\template\twig\extension( $this->context, $this->user ) ); $lexer = new \phpbb\template\twig\lexer($this->twig); $this->twig->setLexer($lexer); // Add admin namespace if ($this->path_helper->get_adm_relative_path() !== null && is_dir($this->phpbb_root_path . $this->path_helper->get_adm_relative_path() . 'style/')) { $this->twig->getLoader()->setPaths($this->phpbb_root_path . $this->path_helper->get_adm_relative_path() . 'style/', 'admin'); } }
/** * Set default template variables * * @param string $page_title Title of the page * @param bool $selected_language True to enable language selector it, false otherwise */ protected function page_header($page_title, $selected_language = false) { // Path to templates $paths = array($this->phpbb_root_path . 'install/update/new/adm/', $this->phpbb_admin_path); $paths = array_filter($paths, 'is_dir'); $path = array_shift($paths); $path = substr($path, strlen($this->phpbb_root_path)); $this->template->assign_vars(array('L_CHANGE' => $this->language->lang('CHANGE'), 'L_COLON' => $this->language->lang('COLON'), 'L_INSTALL_PANEL' => $this->language->lang('INSTALL_PANEL'), 'L_SELECT_LANG' => $this->language->lang('SELECT_LANG'), 'L_SKIP' => $this->language->lang('SKIP'), 'PAGE_TITLE' => $this->language->lang($page_title), 'T_IMAGE_PATH' => $this->path_helper->get_web_root_path() . $path . 'images/', 'T_JQUERY_LINK' => $this->path_helper->get_web_root_path() . $path . '../assets/javascript/jquery.min.js', 'T_TEMPLATE_PATH' => $this->path_helper->get_web_root_path() . $path . 'style/', 'T_ASSETS_PATH' => $this->path_helper->get_web_root_path() . $path . '../assets/', 'S_CONTENT_DIRECTION' => $this->language->lang('DIRECTION'), 'S_CONTENT_FLOW_BEGIN' => $this->language->lang('DIRECTION') === 'ltr' ? 'left' : 'right', 'S_CONTENT_FLOW_END' => $this->language->lang('DIRECTION') === 'ltr' ? 'right' : 'left', 'S_CONTENT_ENCODING' => 'UTF-8', 'S_LANG_SELECT' => $selected_language, 'S_USER_LANG' => $this->language->lang('USER_LANG'))); $this->render_navigation(); }
/** * Constructor. * * @param \phpbb\path_helper $path_helper * @param \phpbb\config\config $config * @param \phpbb\template\context $context template context * @param \phpbb\template\twig\environment $twig_environment * @param string $cache_path * @param \phpbb\user|null $user * @param array|\ArrayAccess $extensions * @param \phpbb\extension\manager $extension_manager extension manager, if null then template events will not be invoked */ public function __construct(\phpbb\path_helper $path_helper, $config, \phpbb\template\context $context, \phpbb\template\twig\environment $twig_environment, $cache_path, \phpbb\user $user = null, $extensions = array(), \phpbb\extension\manager $extension_manager = null) { $this->path_helper = $path_helper; $this->phpbb_root_path = $path_helper->get_phpbb_root_path(); $this->php_ext = $path_helper->get_php_ext(); $this->config = $config; $this->user = $user; $this->context = $context; $this->extension_manager = $extension_manager; $this->cachepath = $cache_path; $this->twig = $twig_environment; foreach ($extensions as $extension) { $this->twig->addExtension($extension); } // Add admin namespace if ($this->path_helper->get_adm_relative_path() !== null && is_dir($this->phpbb_root_path . $this->path_helper->get_adm_relative_path() . 'style/')) { $this->twig->getLoader()->setPaths($this->phpbb_root_path . $this->path_helper->get_adm_relative_path() . 'style/', 'admin'); } }
/** * get portal root * * @return link */ public function get_portal_link() { //var_dump('helper.php > get_portal_link()'); if (strpos($this->user->data['session_page'], '/portal') === false) { $portal_link = $this->controller_helper->route('phpbbireland_portal_controller'); } else { $portal_link = $this->path_helper->remove_web_root_path($this->controller_helper->route('phpbbireland_portal_controller')); } return $portal_link; }
/** * {@inheritdoc} */ public function get_template_side($module_id) { if (!function_exists('get_user_rank')) { include $this->phpbb_root_path . 'includes/functions_display.' . $this->php_ext; } if ($this->user->data['is_registered']) { // // + new posts since last visit & you post number // $ex_fid_ary = array_unique(array_merge(array_keys($this->auth->acl_getf('!f_read', true)), array_keys($this->auth->acl_getf('!f_search', true)))); if ($this->auth->acl_get('m_approve')) { $m_approve_fid_sql = ''; } else { if ($this->auth->acl_getf_global('m_approve')) { $m_approve_fid_ary = array_diff(array_keys($this->auth->acl_getf('!m_approve', true)), $ex_fid_ary); $m_approve_fid_sql = ' AND (p.post_visibility = 1' . (sizeof($m_approve_fid_ary) ? ' OR ' . $this->db->sql_in_set('p.forum_id', $m_approve_fid_ary, true) : '') . ')'; } else { $m_approve_fid_sql = ' AND p.post_visibility = 1'; } } $sql = 'SELECT COUNT(DISTINCT t.topic_id) as total FROM ' . TOPICS_TABLE . ' t WHERE t.topic_last_post_time > ' . (int) $this->user->data['user_lastvisit'] . ' AND t.topic_moved_id = 0 ' . str_replace(array('p.', 'post_'), array('t.', 'topic_'), $m_approve_fid_sql) . ' ' . (sizeof($ex_fid_ary) ? 'AND ' . $this->db->sql_in_set('t.forum_id', $ex_fid_ary, true) : ''); $result = $this->db->sql_query($sql, 600); $new_posts_count = (int) $this->db->sql_fetchfield('total'); $this->db->sql_freeresult($result); // unread posts $sql_where = 'AND t.topic_moved_id = 0 ' . str_replace(array('p.', 'post_'), array('t.', 'topic_'), $m_approve_fid_sql) . ' ' . (sizeof($ex_fid_ary) ? 'AND ' . $this->db->sql_in_set('t.forum_id', $ex_fid_ary, true) : ''); $unread_list = get_unread_topics($this->user->data['user_id'], $sql_where, 'ORDER BY t.topic_id DESC'); $unread_posts_count = sizeof($unread_list); // Get user avatar and rank $user_id = $this->user->data['user_id']; $username = $this->user->data['username']; $colour = $this->user->data['user_colour']; $avatar_img = phpbb_get_avatar(\phpbb\avatar\manager::clean_row($this->user->data, 'user'), 'USER_AVATAR'); $rank_title = $rank_img = $rank_img_src = ''; \get_user_rank($this->user->data['user_rank'], $this->user->data['user_posts'], $rank_title, $rank_img, $rank_img_src); // Assign specific vars $this->template->assign_vars(array('L_NEW_POSTS' => $this->user->lang['SEARCH_NEW'] . ' (' . $new_posts_count . ')', 'L_SELF_POSTS' => $this->user->lang['SEARCH_SELF'] . ' (' . $this->user->data['user_posts'] . ')', 'L_UNREAD_POSTS' => $this->user->lang['SEARCH_UNREAD'] . ' (' . $unread_posts_count . ')', 'B3P_AVATAR_IMG' => $avatar_img, 'B3P_RANK_TITLE' => $rank_title, 'B3P_RANK_IMG' => $rank_img, 'RANK_IMG_SRC' => $rank_img_src, 'USERNAME_FULL' => get_username_string('full', $user_id, $username, $colour), 'U_VIEW_PROFILE' => get_username_string('profile', $user_id, $username, $colour), 'U_NEW_POSTS' => append_sid("{$this->phpbb_root_path}search.{$this->php_ext}", 'search_id=newposts'), 'U_SELF_POSTS' => append_sid("{$this->phpbb_root_path}search.{$this->php_ext}", 'search_id=egosearch'), 'U_UNREAD_POSTS' => append_sid("{$this->phpbb_root_path}search.{$this->php_ext}", 'search_id=unreadposts'), 'U_UM_BOOKMARKS' => $this->config['allow_bookmarks'] ? append_sid("{$this->phpbb_root_path}ucp.{$this->php_ext}", 'i=main&mode=bookmarks') : '', 'U_UM_MAIN_SUBSCRIBED' => append_sid("{$this->phpbb_root_path}ucp.{$this->php_ext}", 'i=main&mode=subscribed'), 'U_UM_MCP' => $this->auth->acl_get('m_') || $this->auth->acl_getf_global('m_') ? append_sid("{$this->phpbb_root_path}mcp.{$this->php_ext}", 'i=main&mode=front', true, $this->user->session_id) : '', 'S_DISPLAY_SUBSCRIPTIONS' => $this->config['allow_topic_notify'] || $this->config['allow_forum_notify'] ? true : false)); return 'user_menu_side.html'; } else { /* * Assign specific vars * Need to remove web root path as ucp.php will do the * redirect */ $this->template->assign_vars(array('U_PORTAL_REDIRECT' => $this->path_helper->remove_web_root_path($this->controller_helper->route('board3_portal_controller')), 'S_DISPLAY_FULL_LOGIN' => true, 'S_AUTOLOGIN_ENABLED' => $this->config['allow_autologin'] ? true : false, 'S_LOGIN_ACTION' => append_sid("{$this->phpbb_root_path}ucp.{$this->php_ext}", 'mode=login'), 'S_SHOW_REGISTER' => $this->config['board3_user_menu_register_' . $module_id] ? true : false)); return 'login_box_side.html'; } }
public function add_thing() { if (!$this->auth->acl_get('u_usermap_add_thing')) { trigger_error('NOT_AUTHORISED'); } include $this->phpbb_root_path . 'includes/functions_posting.' . $this->php_ext; include $this->phpbb_root_path . 'includes/functions_display.' . $this->php_ext; $bbcode_status = $this->config['tas2580_usermap_allow_bbcode']; $url_status = $this->config['tas2580_usermap_allow_urls']; $img_status = $this->config['tas2580_usermap_allow_img']; $flash_status = $this->config['tas2580_usermap_allow_flash']; $smilies_status = $this->config['tas2580_usermap_allow_smilies']; $marker = ''; $this->user->add_lang('posting'); $submit = $this->request->is_set_post('submit'); if ($submit) { $title = $this->request->variable('title', '', true); $message = $this->request->variable('message', '', true); $marker = $this->request->variable('marker', '', true); $data = array('lon' => (double) substr($this->request->variable('lon', ''), 0, 10), 'lat' => (double) substr($this->request->variable('lat', ''), 0, 10)); $validate_array = array('lon' => array('match', false, self::REGEX_LON), 'lat' => array('match', false, self::REGEX_LAT)); if (!function_exists('validate_data')) { include $this->phpbb_root_path . 'includes/functions_user.' . $this->php_ext; } $error = validate_data($data, $validate_array); if (utf8_clean_string($title) === '') { $error[] = $this->user->lang['EMPTY_SUBJECT']; } if (utf8_clean_string($message) === '') { $error[] = $this->user->lang['TOO_FEW_CHARS']; } if (empty($marker)) { $error[] = $this->user->lang['NEED_MARKER']; } if (sizeof($error)) { $this->template->assign_vars(array('ERROR' => implode('<br />', $error), 'TITLE' => $title, 'MESSAGE' => $message)); } else { generate_text_for_storage($message, $uid, $bitfield, $options, $bbcode_status, $url_status, $smilies_status); $sql_data = array('thing_title' => $title, 'thing_text' => $message, 'bbcode_uid' => $uid, 'bbcode_bitfield' => $bitfield, 'thing_lat' => $data['lat'], 'thing_lon' => $data['lon'], 'thing_marker' => $marker, 'thing_user_id' => $this->user->data['user_id']); $sql = 'INSERT INTO ' . $this->things_table . ' ' . $this->db->sql_build_array('INSERT', $sql_data); $this->db->sql_query($sql); $thing_id = $this->db->sql_nextid(); trigger_error($this->user->lang['THING_ADDED'] . '<br /><br />' . '<a href="' . $this->helper->route('tas2580_usermap_thing', array('id' => $thing_id)) . '">' . $this->user->lang['BACK_TO_THING'] . '</a><br /><br />' . '<a href="' . $this->helper->route('tas2580_usermap_index', array()) . '">' . $this->user->lang['BACK_TO_USERMAP'] . '</a>'); } } $path = $this->path_helper->update_web_root_path($this->phpbb_extension_manager->get_extension_path('tas2580/usermap', true) . 'marker/things'); generate_smilies('inline', 0); display_custom_bbcodes(); $s_hidden_fields = build_hidden_fields(array('lon' => $this->request->variable('lon', ''), 'lat' => $this->request->variable('lat', ''))); $this->template->assign_vars(array('TITLE' => $this->request->variable('title', '', true), 'MESSAGE' => $this->request->variable('message', '', true), 'MARKER_OPTIONS' => $this->marker_image_select($marker, 'marker/things/'), 'USERMAP_MARKER_PATH' => $path, 'S_BBCODE_ALLOWED' => $bbcode_status, 'S_LINKS_ALLOWED' => $url_status, 'S_BBCODE_IMG' => $img_status, 'S_BBCODE_FLASH' => $flash_status, 'S_BBCODE_QUOTE' => 1, 'BBCODE_STATUS' => $bbcode_status ? sprintf($this->user->lang['BBCODE_IS_ON'], '<a href="' . append_sid("{$this->phpbb_root_path}faq.{$this->php_ext}", 'mode=bbcode') . '">', '</a>') : sprintf($this->user->lang['BBCODE_IS_OFF'], '<a href="' . append_sid("{$this->phpbb_root_path}faq.{$this->php_ext}", 'mode=bbcode') . '">', '</a>'), 'IMG_STATUS' => $img_status ? $this->user->lang['IMAGES_ARE_ON'] : $this->user->lang['IMAGES_ARE_OFF'], 'FLASH_STATUS' => $flash_status ? $this->user->lang['FLASH_IS_ON'] : $this->user->lang['FLASH_IS_OFF'], 'SMILIES_STATUS' => $smilies_status ? $this->user->lang['SMILIES_ARE_ON'] : $this->user->lang['SMILIES_ARE_OFF'], 'URL_STATUS' => $bbcode_status && $url_status ? $this->user->lang['URL_IS_ON'] : $this->user->lang['URL_IS_OFF'], 'S_HIDDEN_FIELDS' => $s_hidden_fields, 'FORM_TITLE' => $this->user->lang('ADD_THING', $this->user->lang($this->config['tas2580_usermap_thing_name'])))); return $this->helper->render('usermap_thing_form.html', $this->user->lang('ADD_THING', $this->user->lang($this->config['tas2580_usermap_thing_name']))); }
/** * {@inheritdoc} */ public function render_update_file_status($status_array) { $this->template->assign_vars(array('T_IMAGE_PATH' => $this->path_helper->get_web_root_path() . 'adm/images/')); foreach ($status_array as $block => $list) { foreach ($list as $filename) { $dirname = dirname($filename); $this->template->assign_block_vars($block, array('STATUS' => $block, 'FILENAME' => $filename, 'DIR_PART' => !empty($dirname) && $dirname !== '.' ? dirname($filename) . '/' : false, 'FILE_PART' => basename($filename))); } } $this->template->set_filenames(array('file_status' => 'installer_update_file_status.html')); $this->file_status = $this->template->assign_display('file_status'); }
/** * Add portal link if user is authed to see it * * @return null */ public function add_portal_link() { if (!$this->has_portal_access()) { return; } if (strpos($this->controller_helper->get_current_url(), '/portal') === false) { $portal_link = $this->controller_helper->route('board3_portal_controller'); $this->check_portal_all(); } else { $portal_link = $this->path_helper->remove_web_root_path($this->controller_helper->route('board3_portal_controller')); } $this->template->assign_vars(array('U_PORTAL' => $portal_link)); }
public function index() { if (!$this->auth->acl_get('u_usermap_view')) { trigger_error('NOT_AUTHORISED'); } $this->template->assign_block_vars('navlinks', array('FORUM_NAME' => $this->user->lang('USERMAP_TITLE'), 'U_VIEW_FORUM' => $this->helper->route('tas2580_usermap_index', array()))); $sql = 'SELECT group_id, group_name, group_usermap_marker, group_type, group_colour FROM ' . GROUPS_TABLE . "\n\t\t\tWHERE group_usermap_marker != ''\n\t\t\tORDER BY group_name"; $result = $this->db->sql_query($sql); while ($row = $this->db->sql_fetchrow($result)) { $group_name = $row['group_type'] == GROUP_SPECIAL ? $this->user->lang('G_' . $row['group_name']) : $row['group_name']; $colour_text = $row['group_colour'] ? ' style="color:#' . $row['group_colour'] . '"' : ''; if ($row['group_name'] == 'BOTS' || $this->user->data['user_id'] != ANONYMOUS && !$this->auth->acl_get('u_viewprofile')) { $legend = '<span' . $colour_text . '>' . $group_name . '</span>'; } else { $legend = '<a' . $colour_text . ' href="' . append_sid("{$this->phpbb_root_path}memberlist.{$this->php_ext}", 'mode=group&g=' . $row['group_id']) . '">' . $group_name . '</a>'; } $this->template->assign_block_vars('group_list', array('GROUP_ID' => $row['group_id'], 'GROUP_NAME' => $legend, 'ALT' => $group_name, 'MARKER' => $row['group_usermap_marker'])); } $this->template->assign_vars(array('USERMAP_CONTROLS' => 'true', 'S_IN_USERMAP' => true, 'USERMAP_LON' => empty($this->config['tas2580_usermap_lon']) ? 0 : $this->config['tas2580_usermap_lon'], 'USERMAP_LAT' => empty($this->config['tas2580_usermap_lat']) ? 0 : $this->config['tas2580_usermap_lat'], 'USERMAP_ZOOM' => (int) $this->config['tas2580_usermap_zoom'], 'MARKER_PATH' => $this->path_helper->update_web_root_path($this->phpbb_extension_manager->get_extension_path('tas2580/usermap', true) . 'marker'), 'A_USERMAP_ADD' => $this->user->data['user_id'] != ANONYMOUS && $this->auth->acl_get('u_usermap_add'), 'A_USERMAP_SEARCH' => $this->auth->acl_get('u_usermap_search'), 'S_CAN_ADD' => empty($this->user->data['user_usermap_lon']) || empty($this->user->data['user_usermap_lat']), 'U_SET_POSITON' => $this->helper->route('tas2580_usermap_position', array()), 'U_GET_MARKER' => $this->helper->route('tas2580_usermap_get_marker', array()), 'MAP_TYPE' => $this->config['tas2580_usermap_map_type'], 'GOOGLE_API_KEY' => $this->config['tas2580_usermap_google_api_key'], 'U_USERMAP_SEARCH' => $this->helper->route('tas2580_usermap_search', array()), 'L_MENU_SEARCH' => $this->user->lang('MENU_SEARCH', $this->config['tas2580_usermap_search_distance']))); return $this->helper->render('usermap_body.html', $this->user->lang('USERMAP_TITLE')); }
public function __construct(\phpbb\path_helper $path_helper, $config, $user, \phpbb\template\context $context, \phpbb\extension\manager $extension_manager = null) { $this->path_helper = $path_helper; $this->phpbb_root_path = $path_helper->get_phpbb_root_path(); $this->php_ext = $path_helper->get_php_ext(); $this->config = $config; $this->user = $user; $this->context = $context; $this->extension_manager = $extension_manager; $this->cachepath = $this->phpbb_root_path . 'cache/twig/'; // Initiate the loader, __main__ namespace paths will be setup later in set_style_names() $loader = new \phpbb\template\twig\loader(''); $this->twig = new \phpbb\template\twig\environment($this->config, $this->path_helper, $this->extension_manager, $loader, array('cache' => defined('IN_INSTALL') ? false : $this->cachepath, 'debug' => defined('DEBUG'), 'auto_reload' => (bool) $this->config['load_tplcompile'], 'autoescape' => false)); $this->twig->addExtension(new \phpbb\template\twig\extension($this->context, $this->user)); // Initialize Gantry. $style = 'gantry'; $this->gantry = (require_once $this->phpbb_root_path . "styles/{$style}/gantry.php"); $this->gantry['streams']; $this->gantry['theme']->add_to_twig($this->twig); if (defined('ADMIN_START')) { // We are in admin. define('GANTRYADMIN_PATH', GANTRY5_ROOT . '/ext/rockettheme/gantry'); $this->gantry['admin.theme'] = function () { return new \Gantry\Admin\Theme(GANTRYADMIN_PATH); }; // Boot the service. $this->gantry['admin.theme']; } // Initialize lexer. $lexer = new \phpbb\template\twig\lexer($this->twig); $this->twig->setLexer($lexer); // Add admin namespace if ($this->path_helper->get_adm_relative_path() !== null && is_dir($this->phpbb_root_path . $this->path_helper->get_adm_relative_path() . 'style/')) { $this->twig->getLoader()->setPaths($this->phpbb_root_path . $this->path_helper->get_adm_relative_path() . 'style/', 'admin'); } }
/** * Run tool. * * @param bool|false $from_file Rebuild packages using composer.json's * from the revision zip files * @param bool|false $force Force tool to run if a build is already * in progress * @param ProgressHelper|null $progress * @return array */ public function run($from_file = false, $force = false, $progress = null) { $this->repo->prepare_build_dir($force); $batch = $this->get_batch($from_file); $group_count = $group = 1; $last_type = $last_contrib = ''; $packages = array(); foreach ($batch as $contrib_id => $revisions) { $added = false; foreach ($revisions as $index => $revision) { if ($from_file) { $revision = $this->rebuild_from_file($revision); } if ($progress) { $progress->advance(); } if (!$revision['revision_composer_json']) { unset($batch[$contrib_id][$index]); continue; } $added = true; if ($last_type != $revision['contrib_type']) { $group_count = $group = 1; } $last_type = $revision['contrib_type']; $download_url = $this->path_helper->strip_url_params($this->controller_helper->route('phpbb.titania.download', array('id' => (int) $revision['attachment_id'])), 'sid'); $contrib_url = $this->path_helper->strip_url_params($this->controller_helper->route('phpbb.titania.contrib', array('contrib_type' => $this->types->get($revision['contrib_type'])->url, 'contrib_name' => $revision['contrib_name_clean'])), 'sid'); $packages = $this->repo->set_release($packages, $revision['revision_composer_json'], $download_url, $contrib_url); unset($batch[$contrib_id][$index]); } if (!$added) { continue; } if ($group_count % 50 === 0) { $this->dump_include($last_type, $group, $packages); $group_count = 0; $group++; $packages = array(); } $group_count++; } if (!empty($packages)) { $this->dump_include($last_type, $group, $packages); } $this->repo->deploy_build(); return $this->get_result('COMPOSER_PACKAGES_REBUILT', $this->get_total(), false); }
/** * Add map to users profile * * @param object $event The event object * @return null * @access public */ public function memberlist_view_profile($event) { if ($this->config['tas2580_usermap_map_in_viewprofile'] == 0) { return false; } $data = $event['member']; $this->user->add_lang_ext('tas2580/usermap', 'controller'); $distance = $this->get_distance($this->user->data['user_usermap_lon'], $this->user->data['user_usermap_lat'], $data['user_usermap_lon'], $data['user_usermap_lat']); // Center the map to user $this->template->assign_vars(array('S_IN_USERMAP' => true, 'USERMAP_CONTROLS' => 'false', 'USERNAME' => get_username_string('full', $data['user_id'], $data['username'], $data['user_colour']), 'USERMAP_LON' => $data['user_usermap_lon'], 'USERMAP_LAT' => $data['user_usermap_lat'], 'USERMAP_ZOOM' => (int) 10, 'DISTANCE' => $distance, 'MARKER_PATH' => $this->path_helper->update_web_root_path($this->phpbb_extension_manager->get_extension_path('tas2580/usermap', true) . 'marker'), 'MAP_TYPE' => $this->config['tas2580_usermap_map_type'], 'GOOGLE_API_KEY' => $this->config['tas2580_usermap_google_api_key'])); $sql = 'SELECT group_id, group_usermap_marker FROM ' . GROUPS_TABLE . ' WHERE group_id = ' . (int) $data['group_id']; $result = $this->db->sql_query($sql); $row = $this->db->sql_fetchrow($result); $this->template->assign_vars(array('USERMAP_MARKER' => $row['group_usermap_marker'])); }
/** * Constructor * * @param \phpbb\cache\service $cache Cache object * @param \phpbb\config\config $config Config object * @param \phpbb\db\driver\driver_interface $db Database object * @param \phpbb\pagination $pagination Pagination object * @param \phpbb\controller\helper $helper Controller helper object * @param \phpbb\request\request $request Request object * @param \phpbb\template\template $template Template object * @param \phpbb\user $user User object * @param \phpbb\log $log Log object * @param \phpbb\extension\manager $ext_manager Extension manager object * @param \phpbb\path_helper $path_helper Path helper object * @param string $root_path phpBB root path * @param string $php_ext phpEx * @param string $flags_table Name of the table used to store flag data * @param \rmcgirr83\nationalflags\core\nationalflags $functions Functions for the extension * @return \rmcgirr83\nationalflags\controller\admin_controller * @access public */ public function __construct(\phpbb\cache\service $cache, \phpbb\config\config $config, \phpbb\db\driver\driver_interface $db, \phpbb\pagination $pagination, \phpbb\controller\helper $helper, \phpbb\request\request $request, \phpbb\template\template $template, \phpbb\user $user, \phpbb\log\log $log, \phpbb\extension\manager $ext_manager, \phpbb\path_helper $path_helper, $root_path, $php_ext, $flags_table, \rmcgirr83\nationalflags\core\nationalflags $functions) { $this->cache = $cache; $this->config = $config; $this->db = $db; $this->pagination = $pagination; $this->helper = $helper; $this->request = $request; $this->template = $template; $this->user = $user; $this->log = $log; $this->ext_manager = $ext_manager; $this->path_helper = $path_helper; $this->root_path = $root_path; $this->php_ext = $php_ext; $this->flags_table = $flags_table; $this->functions = $functions; $this->ext_path = $this->ext_manager->get_extension_path('rmcgirr83/nationalflags', true); $this->ext_path_web = $this->path_helper->update_web_root_path($this->ext_path); }
/** * Display the main index page. * * @return \Symfony\Component\HttpFoundation\Response */ public function display_index($branch) { $this->set_branch($branch); $title = $this->user->lang('CUSTOMISATION_DATABASE'); $sort = $this->list_contributions('', self::ALL_CONTRIBS, ''); $this->params = $this->get_params($sort); $this->display->assign_global_vars(); if ($this->request->is_ajax()) { return $this->get_ajax_response($title, $sort); } $this->display->display_categories(self::ALL_CONTRIBS, 'categories', false, true, $this->params); // Mark all contribs read if ($this->request->variable('mark', '') == 'contribs') { $this->tracking->track(TITANIA_CONTRIB, self::ALL_CONTRIBS); } $this->template->assign_vars(array('CATEGORY_ID' => self::ALL_CONTRIBS, 'U_CREATE_CONTRIBUTION' => $this->get_create_contrib_url(), 'U_MARK_FORUMS' => $this->path_helper->append_url_params($this->helper->get_current_url(), array('mark' => 'contribs')), 'L_MARK_FORUMS_READ' => $this->user->lang['MARK_CONTRIBS_READ'], 'U_ALL_CONTRIBUTIONS' => $this->get_index_url($this->params), 'S_DISPLAY_SEARCHBOX' => true, 'S_SEARCHBOX_ACTION' => $this->helper->route('phpbb.titania.search.contributions.results'))); $this->assign_sorting($sort); $this->assign_branches(); return $this->helper->render('index_body.html', $title); }
/** * Shorten the amount of code required for some places * * @param mixed $object_type * @param mixed $object_id * @param mixed $url * @param string $lang_key Language key to use in link */ public function handle_subscriptions($object_type, $object_id, $url, $lang_key = 'SUBSCRIBE') { if (!$this->user->data['is_registered']) { // Cannot currently handle non-registered users return; } $action = $this->request->variable('subscribe', ''); $action = in_array($action, array('subscribe', 'unsubscribe')) ? $action : false; $hash = $this->request->variable('hash', ''); if ($action && check_link_hash($hash, $action)) { $this->{$action}($object_type, $object_id); } $is_subscribed = $this->is_subscribed($object_type, $object_id); $action = 'subscribe'; if ($is_subscribed) { $action = 'unsubscribe'; $lang_key = 'UN' . $lang_key; } $params = array('subscribe' => $action, 'hash' => generate_link_hash($action)); $this->template->assign_vars(array('IS_SUBSCRIBED' => $is_subscribed, 'U_SUBSCRIBE' => $this->path_helper->append_url_params($url, $params), 'L_SUBSCRIBE_TYPE' => $this->user->lang($lang_key))); }