function main() { // Only registered users can go beyond this point if (!$this->user->data['is_registered']) { if ($this->user->data['is_bot']) { redirect(append_sid("{$this->phpbb_root_path}index.{$this->phpEx}")); } login_box('', $this->user->lang['LOGIN_INFO']); } $adm_points = $this->request->variable('adm_points', false); $u_id = $this->request->variable('user_id', 0); $post_id = $this->request->variable('post_id', 0); if (empty($u_id)) { $message = $this->user->lang['EDIT_NO_ID_SPECIFIED'] . '<br /><br /><a href="' . $this->helper->route('dmzx_ultimatepoints_controller', array('mode' => 'bank_edit')) . '">« ' . $this->user->lang['BACK_TO_PREV'] . '</a>'; trigger_error($message); } $user_id = $u_id; add_form_key('bank_edit'); if ($adm_points != false && ($this->auth->acl_get('a_') || $this->auth->acl_get('m_chg_bank'))) { $this->template->assign_block_vars('administer_bank', array()); $submit = isset($_POST['submit']) ? true : false; if ($submit) { if (!check_form_key('bank_edit')) { trigger_error('FORM_INVALID'); } $new_points = round($this->request->variable('points', 0.0), 2); $this->functions_points->set_bank($u_id, $new_points); $sql_array = array('SELECT' => 'user_id, username, user_points, user_colour', 'FROM' => array(USERS_TABLE => 'u'), 'WHERE' => 'user_id = ' . (int) $u_id); $sql = $this->db->sql_build_query('SELECT', $sql_array); $result = $this->db->sql_query($sql); $points_user = $this->db->sql_fetchrow($result); // Add logs $this->log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_MOD_BANK', false, array($points_user['username'])); $message = $post_id ? sprintf($this->user->lang['EDIT_P_RETURN_POST'], '<a href="' . append_sid("{$this->phpbb_root_path}viewtopic.{$this->phpEx}", "p=" . $post_id) . '">', '</a>') : sprintf($this->user->lang['EDIT_P_RETURN_INDEX'], '<a href="' . append_sid("{$this->phpbb_root_path}index.{$this->phpEx}") . '">', '</a>'); trigger_error(sprintf($this->user->lang['EDIT_POINTS_SET'], $this->config['points_name']) . $message); } else { $sql_array = array('SELECT' => 'u.user_id, u.username, u.user_points, u.user_colour, b.holding', 'FROM' => array(USERS_TABLE => 'u'), 'LEFT_JOIN' => array(array('FROM' => array($this->points_bank_table => 'b'), 'ON' => 'u.user_id = b.user_id')), 'WHERE' => 'u.user_id = ' . (int) $u_id); $sql = $this->db->sql_build_query('SELECT', $sql_array); $result = $this->db->sql_query($sql); $row = $this->db->sql_fetchrow($result); if (empty($u_id)) { $message = $this->user->lang['EDIT_USER_NOT_EXIST'] . '<br /><br /><a href="' . $this->helper->route('dmzx_ultimatepoints_controller', array('mode' => 'bank_edit')) . '">« ' . $this->user->lang['BACK_TO_PREV'] . '</a>'; trigger_error($message); } $hidden_fields = build_hidden_fields(array('user_id' => $u_id, 'post_id' => $post_id)); $this->template->assign_vars(array('USER_NAME' => get_username_string('full', $u_id, $row['username'], $row['user_colour']), 'BANK_POINTS' => sprintf($this->functions_points->number_format_points($row['holding'])), 'POINTS_NAME' => $this->config['points_name'], 'CURRENT_VALUE' => $row['holding'], 'L_POINTS_MODIFY' => sprintf($this->user->lang['EDIT_BANK_MODIFY'], $this->config['points_name']), 'L_P_BANK_TITLE' => sprintf($this->user->lang['EDIT_P_BANK_TITLE'], $this->config['points_name']), 'L_USERNAME' => $this->user->lang['USERNAME'], 'L_SET_AMOUNT' => $this->user->lang['EDIT_SET_AMOUNT'], 'U_USER_LINK' => append_sid("{$this->phpbb_root_path}memberlist.{$this->phpEx}", "mode=viewprofile&u=" . $u_id), 'S_ACTION' => $this->helper->route('dmzx_ultimatepoints_controller', array('mode' => 'bank_edit', 'adm_points' => '1')), 'S_HIDDEN_FIELDS' => $hidden_fields)); } } // Generate the page page_header($this->user->lang['EDIT_POINTS_ADMIN']); // Generate the page template $this->template->set_filenames(array('body' => 'points/points_bank_edit.html')); page_footer(); }