config = $config; $this->template = $template; $this->user = $user; $this->db = $db; $this->request = $request; $this->user_config_keys = $user_config_keys; } /** * Display the options a user can configure for this extension * * @param $u_action */ public function display_options($u_action) { add_form_key('ucp_mchat'); $error = array(); if ($this->request->is_set_post('submit')) { if (!check_form_key('ucp_mchat')) { $error[] = 'FORM_INVALID'; } if (empty($error)) { $data = array(); foreach ($this->user_config_keys as $config_key) { $data[$config_key] = $this->request->variable($config_key, (int) $this->user->data[$config_key]); } $sql = 'UPDATE ' . USERS_TABLE . ' SET ' . $this->db->sql_build_array('UPDATE', $data) . ' WHERE user_id = ' . (int) $this->user->data['user_id']; $this->db->sql_query($sql); meta_refresh(3, $u_action); $message = $this->user->lang('PROFILE_UPDATED') . '

' . $this->user->lang('RETURN_UCP', '', ''); trigger_error($message); } // Replace "error" strings with their real, localised form $error = array_map(array($this->user, 'lang'), $error); } foreach ($this->user_config_keys as $config_key) { $this->template->assign_var(strtoupper($config_key), $this->user->data[$config_key]); } $this->template->assign_vars(array( 'ERROR' => sizeof($error) ? implode('
', $error) : '', 'S_UCP_ACTION' => $u_action, 'S_MCHAT_TOPICS' => $this->config['mchat_new_posts_edit'] || $this->config['mchat_new_posts_quote'] || $this->config['mchat_new_posts_reply'] || $this->config['mchat_new_posts_topic'], 'S_MCHAT_INDEX' => $this->config['mchat_on_index'], 'S_MCHAT_INDEX_STATS' => $this->config['mchat_stats_index'], 'S_MCHAT_AVATARS' => $this->config['mchat_avatars'], )); } }