/** * 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); }
public function main($id, $mode) { switch ($mode) { case 'settings': $data = array('user_ajax_chat_view' => $this->request->variable('user_ajax_chat_view', (bool) $this->user->data['user_ajax_chat_view']), 'user_ajax_chat_avatars' => $this->request->variable('user_ajax_chat_avatars', (bool) $this->user->data['user_ajax_chat_avatars']), 'user_ajax_chat_position' => $this->request->variable('user_ajax_chat_position', (bool) $this->user->data['user_ajax_chat_position']), 'user_ajax_chat_sound' => $this->request->variable('user_ajax_chat_sound', (bool) $this->user->data['user_ajax_chat_sound']), 'user_ajax_chat_avatar_hover' => $this->request->variable('user_ajax_chat_avatar_hover', (bool) $this->user->data['user_ajax_chat_avatar_hover']), 'user_ajax_chat_onlinelist' => $this->request->variable('user_ajax_chat_onlinelist', (bool) $this->user->data['user_ajax_chat_onlinelist'])); $error = array(); $submit = $this->request->variable('submit', false, false, \phpbb\request\request_interface::POST); add_form_key('ucp_ajax_chat'); $post = $this->request->get_super_global(\phpbb\request\request_interface::POST); if ($submit) { if (!check_form_key('ucp_ajax_chat')) { $error[] = 'FORM_INVALID'; } if (!sizeof($error)) { $sql_ary = array('user_ajax_chat_view' => $post['ajax_chat_view'], 'user_ajax_chat_avatars' => $post['ajax_chat_avatars'], 'user_ajax_chat_position' => $post['ajax_chat_position'], 'user_ajax_chat_sound' => $post['ajax_chat_sound'], 'user_ajax_chat_avatar_hover' => $post['ajax_chat_avatar_hover'], 'user_ajax_chat_onlinelist' => $post['ajax_chat_onlinelist']); if (sizeof($sql_ary)) { $sql = 'UPDATE ' . USERS_TABLE . ' SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . ' WHERE user_id = ' . (int) $this->user->data['user_id']; $this->db->sql_query($sql); } meta_refresh(3, $this->u_action); $message = $this->user->lang['PROFILE_UPDATED'] . '<br /><br />' . sprintf($this->user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>'); trigger_error($message); } // Replace "error" strings with their real, localised form $error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error); } $this->template->assign_vars(array('ERROR' => sizeof($error) ? implode('<br />', $error) : '', 'S_AJAX_CHAT_VIEW' => $data['user_ajax_chat_view'], 'S_AJAX_CHAT_AVATARS' => $data['user_ajax_chat_avatars'], 'S_AJAX_CHAT_POSITION' => $data['user_ajax_chat_position'], 'S_AJAX_CHAT_SOUND' => $data['user_ajax_chat_sound'], 'S_AJAX_CHAT_AVATAR_HOVER' => $data['user_ajax_chat_avatar_hover'], 'S_AJAX_CHAT_ONLINELIST' => $data['user_ajax_chat_onlinelist'])); break; } $this->template->assign_vars(array('L_TITLE' => $this->user->lang['USER_AJAXCHAT_SETTINGS'], 'S_UCP_ACTION' => $this->u_action)); // Set desired template $this->tpl_name = 'ucp_ajax_chat'; $this->page_title = 'USER_AJAXCHAT_SETTINGS'; }