コード例 #1
0
ファイル: link_us.php プロジェクト: alhitary/Board3-Portal
 /**
  * {@inheritdoc}
  */
 public function get_template_side($module_id)
 {
     //doing the easy way ;)
     $u_link = generate_board_url();
     // Assign specific vars
     $this->template->assign_vars(array('LINK_US_TXT' => sprintf($this->user->lang['LINK_US_TXT'], $this->config['sitename']), 'U_LINK_US' => '<a href="' . $u_link . '" ' . ($this->config['site_desc'] ? 'title="' . $this->config['site_desc'] . '"' : '') . '>' . ($this->config['sitename'] ? $this->config['sitename'] : $u_link) . '</a>'));
     return 'link_us_side.html';
 }
コード例 #2
0
ファイル: forumlist.php プロジェクト: alhitary/Board3-Portal
 /**
  * {@inheritdoc}
  */
 public function get_template_center($module_id)
 {
     if (!function_exists('display_forums')) {
         include $this->phpbb_root_path . 'includes/functions_display.' . $this->php_ext;
     }
     \display_forums('', $this->config['load_moderators'], false);
     $this->template->assign_vars(array('FORUM_IMG' => $this->user->img('forum_read', 'NO_NEW_POSTS'), 'FORUM_NEW_IMG' => $this->user->img('forum_unread', 'NEW_POSTS'), 'FORUM_LOCKED_IMG' => $this->user->img('forum_read_locked', 'NO_NEW_POSTS_LOCKED'), 'FORUM_NEW_LOCKED_IMG' => $this->user->img('forum_unread_locked', 'NO_NEW_POSTS_LOCKED'), 'U_MARK_FORUMS' => $this->user->data['is_registered'] || $this->config['load_anon_lastread'] ? append_sid("{$this->phpbb_root_path}index.{$this->php_ext}", 'hash=' . generate_link_hash('global') . '&mark=forums') : '', 'U_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) : ''));
     return 'forumlist.html';
 }
コード例 #3
0
ファイル: helper.php プロジェクト: alhitary/Board3-Portal
 /**
  * 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'])));
     }
 }
コード例 #4
0
ファイル: friends.php プロジェクト: alhitary/Board3-Portal
    /**
     * {@inheritdoc}
     */
    public function get_template_side($module_id)
    {
        $s_display_friends = false;
        // Output listing of friends online
        $update_time = $this->config['load_online_time'] * 60;
        $sql = $this->db->sql_build_query('SELECT_DISTINCT', array('SELECT' => 'u.user_id, u.username, u.username_clean, u.user_colour, u.user_allow_viewonline, MAX(s.session_time) as online_time, MIN(s.session_viewonline) AS viewonline', 'FROM' => array(USERS_TABLE => 'u', ZEBRA_TABLE => 'z'), 'LEFT_JOIN' => array(array('FROM' => array(SESSIONS_TABLE => 's'), 'ON' => 's.session_user_id = z.zebra_id')), 'WHERE' => 'z.user_id = ' . $this->user->data['user_id'] . '
				AND z.friend = 1
				AND u.user_id = z.zebra_id', 'GROUP_BY' => 'z.zebra_id, u.user_id, u.username, u.username_clean, u.user_allow_viewonline, u.user_colour', 'ORDER_BY' => 'u.username_clean ASC'));
        $result = $this->db->sql_query_limit($sql, $this->config['board3_max_online_friends_' . $module_id]);
        while ($row = $this->db->sql_fetchrow($result)) {
            $which = time() - $update_time < $row['online_time'] && ($row['viewonline'] || $this->auth->acl_get('u_viewonline')) ? 'online' : 'offline';
            $s_display_friends = $row['user_id'] ? true : false;
            $this->template->assign_block_vars("b3p_friends_{$which}", array('USER_ID' => $row['user_id'], 'U_PROFILE' => get_username_string('profile', $row['user_id'], $row['username'], $row['user_colour']), 'USER_COLOUR' => get_username_string('colour', $row['user_id'], $row['username'], $row['user_colour']), 'USERNAME' => get_username_string('username', $row['user_id'], $row['username'], $row['user_colour']), 'USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour'])));
        }
        $this->db->sql_freeresult($result);
        // Assign specific vars
        $this->template->assign_vars(array('S_DISPLAY_FRIENDS' => $s_display_friends));
        return 'friends_side.html';
    }
コード例 #5
0
    /**
     * {@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'] . '&nbsp;(' . $new_posts_count . ')', 'L_SELF_POSTS' => $this->user->lang['SEARCH_SELF'] . '&nbsp;(' . $this->user->data['user_posts'] . ')', 'L_UNREAD_POSTS' => $this->user->lang['SEARCH_UNREAD'] . '&nbsp;(' . $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&amp;mode=bookmarks') : '', 'U_UM_MAIN_SUBSCRIBED' => append_sid("{$this->phpbb_root_path}ucp.{$this->php_ext}", 'i=main&amp;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&amp;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';
        }
    }
コード例 #6
0
ファイル: main.php プロジェクト: phpbbireland/portal
 public function assign_images($assign_user_buttons, $assign_post_buttons)
 {
     // may extend to add portal images //
     $this->template->assign_vars(array('REPORTED_IMG' => $this->user->img('icon_topic_reported', 'POST_REPORTED')));
     if ($assign_user_buttons) {
         $this->template->assign_vars(array('PROFILE_IMG' => $this->user->img('icon_user_profile', 'READ_PROFILE'), 'SEARCH_IMG' => $this->user->img('icon_user_search', 'SEARCH_USER_POSTS'), 'PM_IMG' => $this->user->img('icon_contact_pm', 'SEND_PRIVATE_MESSAGE'), 'EMAIL_IMG' => $this->user->img('icon_contact_email', 'SEND_EMAIL'), 'WWW_IMG' => $this->user->img('icon_contact_www', 'VISIT_WEBSITE'), 'ICQ_IMG' => $this->user->img('icon_contact_icq', 'ICQ'), 'AIM_IMG' => $this->user->img('icon_contact_aim', 'AIM'), 'MSN_IMG' => $this->user->img('icon_contact_msnm', 'MSNM'), 'YIM_IMG' => $this->user->img('icon_contact_yahoo', 'YIM'), 'JABBER_IMG' => $this->user->img('icon_contact_jabber', 'JABBER')));
     }
     if ($assign_post_buttons) {
         $this->template->assign_vars(array('QUOTE_IMG' => $this->user->img('icon_post_quote', 'REPLY_WITH_QUOTE'), 'EDIT_IMG' => $this->user->img('icon_post_edit', 'EDIT_POST'), 'DELETE_IMG' => $this->user->img('icon_post_delete', 'DELETE_POST'), 'INFO_IMG' => $this->user->img('icon_post_info', 'VIEW_INFO'), 'REPORT_IMG' => $this->user->img('icon_post_report', 'REPORT_POST'), 'WARN_IMG' => $this->user->img('icon_user_warn', 'WARN_USER')));
     }
 }
コード例 #7
0
ファイル: welcome.php プロジェクト: alhitary/Board3-Portal
 /**
  * Manage welcome message
  *
  * @param mixed $value Value of input
  * @param string $key Key name
  * @param int $module_id Module ID
  *
  * @return null
  */
 public function manage_welcome($value, $key, $module_id)
 {
     $action = $this->request->is_set_post('reset') ? 'reset' : '';
     $action = $this->request->is_set_post('submit') ? 'save' : $action;
     $action = $this->request->is_set_post('preview') ? 'preview' : $action;
     $portal_config = obtain_portal_config();
     $u_action = append_sid('index.' . $this->php_ext, 'i=-board3-portal-acp-portal_module&amp;mode=config&amp;module_id=' . $module_id);
     switch ($action) {
         // Save changes
         case 'save':
             if (!check_form_key('acp_portal')) {
                 trigger_error($this->user->lang['FORM_INVALID'] . adm_back_link($u_action), E_USER_WARNING);
             }
             $welcome_message = $this->request->variable('welcome_message', '', true);
             $uid = $bitfield = $flags = '';
             generate_text_for_storage($welcome_message, $uid, $bitfield, $flags, true, true, true);
             // first check for obvious errors, we don't want to waste server resources
             if (empty($welcome_message)) {
                 trigger_error($this->user->lang['ACP_PORTAL_WELCOME_MESSAGE_SHORT'] . adm_back_link($u_action), E_USER_WARNING);
             }
             // set_portal_config will take care of escaping the welcome message
             set_portal_config('board3_welcome_message_' . $module_id, $welcome_message);
             $this->config->set('board3_welcome_message_uid_' . $module_id, $uid);
             $this->config->set('board3_welcome_message_bitfield_' . $module_id, $bitfield);
             break;
         case 'preview':
             $welcome_message = $text = $this->request->variable('welcome_message', '', true);
             $bbcode_options = OPTION_FLAG_BBCODE + OPTION_FLAG_SMILIES + OPTION_FLAG_LINKS;
             $uid = isset($this->config['board3_welcome_message_uid_' . $module_id]) ? $this->config['board3_welcome_message_uid_' . $module_id] : '';
             $bitfield = isset($this->config['board3_welcome_message_bitfield_' . $module_id]) ? $this->config['board3_welcome_message_bitfield_' . $module_id] : '';
             $options = OPTION_FLAG_BBCODE + OPTION_FLAG_SMILIES + OPTION_FLAG_LINKS;
             generate_text_for_storage($text, $uid, $bitfield, $options, true, true, true);
             $text = generate_text_for_display($text, $uid, $bitfield, $options);
             $this->template->assign_vars(array('PREVIEW_TEXT' => $text, 'S_PREVIEW' => true));
             // Edit or add menu item
         // Edit or add menu item
         case 'reset':
         default:
             if (!isset($welcome_message)) {
                 $welcome_message = generate_text_for_edit($portal_config['board3_welcome_message_' . $module_id], $this->config['board3_welcome_message_uid_' . $module_id], '');
             }
             $this->template->assign_vars(array('WELCOME_MESSAGE' => is_array($welcome_message) ? $welcome_message['text'] : $welcome_message, 'U_ACTION' => $u_action, 'S_EDIT' => true, 'S_LINKS_ALLOWED' => true, 'S_BBCODE_IMG' => true, 'S_BBCODE_FLASH' => true, 'S_BBCODE_QUOTE' => true, 'S_BBCODE_ALLOWED' => true, 'MAX_FONT_SIZE' => (int) $this->config['max_post_font_size']));
             if (!function_exists('display_forums')) {
                 include $this->phpbb_root_path . 'includes/functions_display.' . $this->php_ext;
             }
             // Build custom bbcodes array
             display_custom_bbcodes();
             $this->user->add_lang('posting');
             break;
     }
 }
コード例 #8
0
ファイル: helper.php プロジェクト: phpbbireland/portal
 /**
  * Main block/module processing... grab all valid blocks and generate template etc
  *
  * @return null
  */
 public function generate_all_block()
 {
     ///var_dump('helper.php > generate_all_block()');
     global $db, $k_config, $request;
     $id = $request->variable('style', 0);
     if ($id) {
         return;
     }
     $page = '';
     $blocks_width = $this->config['blocks_width'];
     $blocks_enabled = $this->config['blocks_enabled'];
     $block_cache_time = $k_config['k_block_cache_time_default'];
     $use_block_cookies = isset($k_config['use_block_cookies']) ? $k_config['use_block_cookies'] : 0;
     if (!$blocks_enabled) {
         $this->template->assign_vars(array('PORTAL_MESSAGE' => $this->user->lang('BLOCKS_DISABLED')));
     }
     $this->includes_path = $this->phpbb_root_path . 'ext/phpbbireland/portal/includes/';
     include_once $this->includes_path . 'sgp_functions.' . $this->php_ext;
     $func = new \phpbbireland\portal\includes\func();
     $func->process_block_modules();
 }
コード例 #9
0
    /**
     * {@inheritdoc}
     */
    public function get_template_side($module_id)
    {
        switch ($this->db->get_sql_layer()) {
            case 'postgres':
                $sql = 'SELECT *
				FROM ' . USERS_TABLE . '
				WHERE user_type <> ' . USER_IGNORE . '
				AND user_type <> ' . USER_INACTIVE . '
				ORDER BY RANDOM()';
                break;
            case 'mssql':
            case 'mssql_odbc':
                $sql = 'SELECT *
				FROM ' . USERS_TABLE . '
				WHERE user_type <> ' . USER_IGNORE . '
				AND user_type <> ' . USER_INACTIVE . '
				ORDER BY NEWID()';
                break;
            default:
                $sql = 'SELECT *
				FROM ' . USERS_TABLE . '
				WHERE user_type <> ' . USER_IGNORE . '
				AND user_type <> ' . USER_INACTIVE . '
				ORDER BY RAND()';
                break;
        }
        $result = $this->db->sql_query_limit($sql, 1);
        $row = $this->db->sql_fetchrow($result);
        $avatar_img = phpbb_get_avatar(\phpbb\avatar\manager::clean_row($row, 'user'), 'USER_AVATAR');
        $rank_title = $rank_img = $rank_img_src = '';
        get_user_rank($row['user_rank'], $row['user_posts'], $rank_title, $rank_img, $rank_img_src);
        $username = $row['username'];
        $user_id = (int) $row['user_id'];
        $colour = $row['user_colour'];
        $this->template->assign_block_vars('random_member', array('USERNAME_FULL' => get_username_string('full', $user_id, $username, $colour), 'USERNAME' => get_username_string('username', $user_id, $username, $colour), 'USER_COLOR' => get_username_string('colour', $user_id, $username, $colour), 'U_VIEW_PROFILE' => get_username_string('profile', $user_id, $username, $colour), 'RANK_TITLE' => $rank_title, 'RANK_IMG' => $rank_img, 'RANK_IMG_SRC' => $rank_img_src, 'USER_POSTS' => (int) $row['user_posts'], 'AVATAR_IMG' => $avatar_img, 'JOINED' => $this->user->format_date($row['user_regdate'])));
        $this->db->sql_freeresult($result);
        return 'random_member_side.html';
    }
コード例 #10
0
ファイル: poll.php プロジェクト: alhitary/Board3-Portal
    /**
     * Parse template variables for module
     *
     * @param int $module_id	Module ID
     * @param string $type	Module type (center or side)
     *
     * @return string HTML filename
     */
    protected function parse_template($module_id, $type = '')
    {
        $this->user->add_lang('viewtopic');
        // check if we need to include the bbcode class
        if (!class_exists('bbcode')) {
            include $this->phpbb_root_path . 'includes/bbcode.' . $this->php_ext;
        }
        $view = $this->request->variable('view', '');
        $update = $this->request->variable('update', false);
        $poll_view = $this->request->variable('polls', '');
        $poll_view_ar = strpos($poll_view, ',') !== false ? explode(',', $poll_view) : ($poll_view != '' ? array($poll_view) : array());
        if ($update && $this->config['board3_poll_allow_vote_' . $module_id]) {
            $up_topic_id = $this->request->variable('t', 0);
            $up_forum_id = $this->request->variable('f', 0);
            $voted_id = $this->request->variable('vote_id', array('' => 0));
            $cur_voted_id = array();
            if ($this->user->data['is_registered']) {
                $sql = 'SELECT poll_option_id
					FROM ' . POLL_VOTES_TABLE . '
					WHERE topic_id = ' . (int) $up_topic_id . '
						AND vote_user_id = ' . (int) $this->user->data['user_id'];
                $result = $this->db->sql_query($sql);
                while ($row = $this->db->sql_fetchrow($result)) {
                    $cur_voted_id[] = $row['poll_option_id'];
                }
                $this->db->sql_freeresult($result);
            } else {
                // Cookie based guest tracking ... I don't like this but hum ho
                // it's oft requested. This relies on "nice" users who don't feel
                // the need to delete cookies to mess with results.
                if ($this->request->is_set($this->config['cookie_name'] . '_poll_' . $up_topic_id, \phpbb\request\request_interface::COOKIE)) {
                    $cur_voted_id = explode(',', $this->request->variable($this->config['cookie_name'] . '_poll_' . $up_topic_id, '', true, \phpbb\request\request_interface::COOKIE));
                    $cur_voted_id = array_map('intval', $cur_voted_id);
                }
            }
            $sql = 'SELECT t.poll_length, t.poll_start, t.poll_vote_change, t.topic_status, f.forum_status, t.poll_max_options
				FROM ' . TOPICS_TABLE . ' t, ' . FORUMS_TABLE . " f\n\t\t\t\tWHERE t.forum_id = f.forum_id\n\t\t\t\t\tAND t.topic_id = " . (int) $up_topic_id . "\n\t\t\t\t\tAND t.forum_id = " . (int) $up_forum_id;
            $result = $this->db->sql_query_limit($sql, 1);
            $topic_data = $this->db->sql_fetchrow($result);
            $this->db->sql_freeresult($result);
            $s_can_up_vote = (!sizeof($cur_voted_id) && $this->auth->acl_get('f_vote', $up_forum_id) || $this->auth->acl_get('f_votechg', $up_forum_id) && $topic_data['poll_vote_change']) && ($topic_data['poll_length'] != 0 && $topic_data['poll_start'] + $topic_data['poll_length'] > time() || $topic_data['poll_length'] == 0) && $topic_data['topic_status'] != ITEM_LOCKED && $topic_data['forum_status'] != ITEM_LOCKED ? true : false;
            if ($s_can_up_vote) {
                $redirect_url = $this->modules_helper->route('board3_portal_controller');
                if (!sizeof($voted_id) || sizeof($voted_id) > $topic_data['poll_max_options'] || in_array(VOTE_CONVERTED, $cur_voted_id)) {
                    meta_refresh(5, $redirect_url);
                    if (!sizeof($voted_id)) {
                        $message = 'NO_VOTE_OPTION';
                    } else {
                        if (sizeof($voted_id) > $topic_data['poll_max_options']) {
                            $message = 'TOO_MANY_VOTE_OPTIONS';
                        } else {
                            $message = 'VOTE_CONVERTED';
                        }
                    }
                    $message = $this->user->lang[$message] . '<br /><br />' . sprintf($this->user->lang['RETURN_PORTAL'], '<a href="' . $redirect_url . '">', '</a>');
                    trigger_error($message);
                }
                foreach ($voted_id as $option) {
                    if (in_array($option, $cur_voted_id)) {
                        continue;
                    }
                    $sql = 'UPDATE ' . POLL_OPTIONS_TABLE . '
						SET poll_option_total = poll_option_total + 1
						WHERE poll_option_id = ' . (int) $option . '
							AND topic_id = ' . (int) $up_topic_id;
                    $this->db->sql_query($sql);
                    if ($this->user->data['is_registered']) {
                        $sql_ary = array('topic_id' => (int) $up_topic_id, 'poll_option_id' => (int) $option, 'vote_user_id' => (int) $this->user->data['user_id'], 'vote_user_ip' => (string) $this->user->ip);
                        $sql = 'INSERT INTO ' . POLL_VOTES_TABLE . ' ' . $this->db->sql_build_array('INSERT', $sql_ary);
                        $this->db->sql_query($sql);
                    }
                }
                foreach ($cur_voted_id as $option) {
                    if (!in_array($option, $voted_id)) {
                        $sql = 'UPDATE ' . POLL_OPTIONS_TABLE . '
							SET poll_option_total = poll_option_total - 1
							WHERE poll_option_id = ' . (int) $option . '
								AND topic_id = ' . (int) $up_topic_id;
                        $this->db->sql_query($sql);
                        if ($this->user->data['is_registered']) {
                            $sql = 'DELETE FROM ' . POLL_VOTES_TABLE . '
								WHERE topic_id = ' . (int) $up_topic_id . '
									AND poll_option_id = ' . (int) $option . '
									AND vote_user_id = ' . (int) $this->user->data['user_id'];
                            $this->db->sql_query($sql);
                        }
                    }
                }
                if ($this->user->data['user_id'] == ANONYMOUS && !$this->user->data['is_bot']) {
                    $this->user->set_cookie('poll_' . $up_topic_id, implode(',', $voted_id), time() + 31536000);
                }
                $sql = 'UPDATE ' . TOPICS_TABLE . '
					SET poll_last_vote = ' . time() . '
					WHERE topic_id = ' . (int) $up_topic_id;
                //, topic_last_post_time = ' . time() . " -- for bumping topics with new votes, ignore for now
                $this->db->sql_query($sql);
                meta_refresh(5, $redirect_url);
                trigger_error($this->user->lang['VOTE_SUBMITTED'] . '<br /><br />' . sprintf($this->user->lang['RETURN_PORTAL'], '<a href="' . $redirect_url . '">', '</a>'));
            }
        }
        $poll_forums = false;
        // Get readable forums
        $forum_list = array_unique(array_keys($this->auth->acl_getf('f_read', true)));
        if ($this->config['board3_poll_topic_id_' . $module_id] !== '') {
            $poll_forums_config = explode(',', $this->config['board3_poll_topic_id_' . $module_id]);
            if ($this->config['board3_poll_exclude_id_' . $module_id]) {
                $forum_list = array_unique(array_diff($forum_list, $poll_forums_config));
            } else {
                $forum_list = array_unique(array_intersect($poll_forums_config, $forum_list));
            }
        }
        $where = '';
        if (sizeof($forum_list)) {
            $poll_forums = true;
            $where = 'AND ' . $this->db->sql_in_set('t.forum_id', $forum_list);
        }
        if ($this->config['board3_poll_hide_' . $module_id]) {
            $portal_poll_hide = 'AND (t.poll_start + t.poll_length > ' . time() . ' OR t.poll_length = 0)';
        } else {
            $portal_poll_hide = '';
        }
        if ($poll_forums === true) {
            $sql = 'SELECT t.poll_title, t.poll_start, t.topic_id,  t.topic_first_post_id, t.forum_id, t.poll_length, t.poll_vote_change, t.poll_max_options, t.topic_status, f.forum_status, p.bbcode_bitfield, p.bbcode_uid
				FROM ' . TOPICS_TABLE . ' t, ' . POSTS_TABLE . ' p, ' . FORUMS_TABLE . " f\n\t\t\t\tWHERE t.forum_id = f.forum_id\n\t\t\t\t\tAND t.topic_visibility = 1\n\t\t\t\t\tAND t.poll_start > 0\n\t\t\t\t\t{$where}\n\t\t\t\t\tAND t.topic_moved_id = 0\n\t\t\t\t\tAND p.post_id = t.topic_first_post_id\n\t\t\t\t\t{$portal_poll_hide}\n\t\t\t\tORDER BY t.poll_start DESC";
            $limit = isset($this->config['board3_poll_limit_' . $module_id]) ? $this->config['board3_poll_limit_' . $module_id] : 3;
            $result = $this->db->sql_query_limit($sql, $limit);
            $has_poll = false;
            if ($result) {
                while ($data = $this->db->sql_fetchrow($result)) {
                    $has_poll = true;
                    $poll_has_options = false;
                    $topic_id = (int) $data['topic_id'];
                    $forum_id = (int) $data['forum_id'];
                    $cur_voted_id = array();
                    if ($this->config['board3_poll_allow_vote_' . $module_id]) {
                        if ($this->user->data['is_registered']) {
                            $vote_sql = 'SELECT poll_option_id
								FROM ' . POLL_VOTES_TABLE . '
								WHERE topic_id = ' . (int) $topic_id . '
									AND vote_user_id = ' . (int) $this->user->data['user_id'];
                            $vote_result = $this->db->sql_query($vote_sql);
                            while ($row = $this->db->sql_fetchrow($vote_result)) {
                                $cur_voted_id[] = $row['poll_option_id'];
                            }
                            $this->db->sql_freeresult($vote_result);
                        } else {
                            // Cookie based guest tracking ... I don't like this but hum ho
                            // it's oft requested. This relies on "nice" users who don't feel
                            // the need to delete cookies to mess with results.
                            if ($this->request->is_set($this->config['cookie_name'] . '_poll_' . $topic_id, \phpbb\request\request_interface::COOKIE)) {
                                $cur_voted_id = explode(',', $this->request->variable($this->config['cookie_name'] . '_poll_' . $topic_id, 0, false, true));
                                $cur_voted_id = array_map('intval', $cur_voted_id);
                            }
                        }
                        $s_can_vote = (!sizeof($cur_voted_id) && $this->auth->acl_get('f_vote', $forum_id) || $this->auth->acl_get('f_votechg', $forum_id) && $data['poll_vote_change']) && ($data['poll_length'] != 0 && $data['poll_start'] + $data['poll_length'] > time() || $data['poll_length'] == 0) && $data['topic_status'] != ITEM_LOCKED && $data['forum_status'] != ITEM_LOCKED ? true : false;
                    } else {
                        $s_can_vote = false;
                    }
                    $s_display_results = !$s_can_vote || $s_can_vote && sizeof($cur_voted_id) || $view == 'viewpoll' && in_array($topic_id, $poll_view_ar) ? true : false;
                    $poll_sql = 'SELECT po.poll_option_id, po.poll_option_text, po.poll_option_total
						FROM ' . POLL_OPTIONS_TABLE . ' po
						WHERE po.topic_id = ' . (int) $topic_id . '
						ORDER BY po.poll_option_id';
                    $poll_result = $this->db->sql_query($poll_sql);
                    $poll_total_votes = 0;
                    $poll_data = array();
                    if ($poll_result) {
                        while ($polls_data = $this->db->sql_fetchrow($poll_result)) {
                            $poll_has_options = true;
                            $poll_data[] = $polls_data;
                            $poll_total_votes += $polls_data['poll_option_total'];
                        }
                    }
                    $this->db->sql_freeresult($poll_result);
                    $make_poll_view = array();
                    if (in_array($topic_id, $poll_view_ar) === false) {
                        $make_poll_view[] = $topic_id;
                        $make_poll_view = array_merge($poll_view_ar, $make_poll_view);
                    }
                    $poll_view_str = urlencode(implode(',', $make_poll_view));
                    $portalpoll_url = $this->modules_helper->route('board3_portal_controller') . "?polls={$poll_view_str}";
                    $portalvote_url = $this->modules_helper->route('board3_portal_controller') . "?f={$forum_id}&amp;t={$topic_id}";
                    $viewtopic_url = append_sid("{$this->phpbb_root_path}viewtopic.{$this->php_ext}", "f={$forum_id}&amp;t={$topic_id}");
                    $poll_end = $data['poll_length'] + $data['poll_start'];
                    // Parse BBCode title
                    if ($data['bbcode_bitfield']) {
                        $poll_bbcode = new \bbcode();
                    } else {
                        $poll_bbcode = false;
                    }
                    $data['poll_title'] = censor_text($data['poll_title']);
                    if ($poll_bbcode !== false) {
                        $poll_bbcode->bbcode_second_pass($data['poll_title'], $data['bbcode_uid'], $data['bbcode_bitfield']);
                    }
                    $data['poll_title'] = bbcode_nl2br($data['poll_title']);
                    $data['poll_title'] = smiley_text($data['poll_title']);
                    unset($poll_bbcode);
                    $this->template->assign_block_vars($type !== '' ? 'poll_' . $type : 'poll', array('S_POLL_HAS_OPTIONS' => $poll_has_options, 'POLL_QUESTION' => $data['poll_title'], 'U_POLL_TOPIC' => append_sid($this->phpbb_root_path . 'viewtopic.' . $this->php_ext, 't=' . $topic_id . '&amp;f=' . $forum_id), 'POLL_LENGTH' => $data['poll_length'], 'TOPIC_ID' => $topic_id, 'TOTAL_VOTES' => $poll_total_votes, 'L_MAX_VOTES' => $this->user->lang('MAX_OPTIONS_SELECT', $data['poll_max_options']), 'L_POLL_LENGTH' => $data['poll_length'] ? sprintf($this->user->lang[$poll_end > time() ? 'POLL_RUN_TILL' : 'POLL_ENDED_AT'], $this->user->format_date($poll_end)) : '', 'S_CAN_VOTE' => $s_can_vote, 'S_DISPLAY_RESULTS' => $s_display_results, 'S_IS_MULTI_CHOICE' => $data['poll_max_options'] > 1 ? true : false, 'S_POLL_ACTION' => $portalvote_url, 'U_VIEW_RESULTS' => $portalpoll_url . '&amp;view=viewpoll#viewpoll', 'U_VIEW_TOPIC' => $viewtopic_url));
                    foreach ($poll_data as $pd) {
                        $option_pct = $poll_total_votes > 0 ? $pd['poll_option_total'] / $poll_total_votes : 0;
                        $option_pct_txt = sprintf("%.1d%%", round($option_pct * 100));
                        // Parse BBCode option text
                        if ($data['bbcode_bitfield']) {
                            $poll_bbcode = new \bbcode();
                        } else {
                            $poll_bbcode = false;
                        }
                        $pd['poll_option_text'] = censor_text($pd['poll_option_text']);
                        if ($poll_bbcode !== false) {
                            $poll_bbcode->bbcode_second_pass($pd['poll_option_text'], $data['bbcode_uid'], $data['bbcode_bitfield']);
                        }
                        $pd['poll_option_text'] = bbcode_nl2br($pd['poll_option_text']);
                        $pd['poll_option_text'] = smiley_text($pd['poll_option_text']);
                        unset($poll_bbcode);
                        $this->template->assign_block_vars(($type !== '' ? 'poll_' . $type : 'poll') . '.poll_option', array('POLL_OPTION_ID' => $pd['poll_option_id'], 'POLL_OPTION_CAPTION' => $pd['poll_option_text'], 'POLL_OPTION_RESULT' => $pd['poll_option_total'], 'POLL_OPTION_PERCENT' => $option_pct_txt, 'POLL_OPTION_PCT' => round($option_pct * 100), 'POLL_OPTION_IMG' => $this->user->img('poll_center', $option_pct_txt, round($option_pct * 35) . 'px'), 'POLL_OPTION_VOTED' => in_array($pd['poll_option_id'], $cur_voted_id) ? true : false));
                    }
                }
            }
            $this->db->sql_freeresult($result);
            $this->template->assign_vars(array('S_HAS_POLL' => $has_poll, 'POLL_LEFT_CAP_IMG' => $this->user->img('poll_left'), 'POLL_RIGHT_CAP_IMG' => $this->user->img('poll_right')));
        }
        return ($type !== '' ? 'poll_' . $type : 'poll_center') . '.html';
    }
コード例 #11
0
ファイル: Trader.php プロジェクト: vidakk/trader
 public function viewUserFeedbackAction()
 {
     // Trigger an error if user does not have view feedback permissions
     if (!$this->manager->hasViewFeedbackPermission()) {
         trigger_error($this->user->lang('E_CANNOT_VIEW_FEEDBACK'));
     }
     $user_id = $this->request->variable('u', 0);
     $tab = $this->request->variable('tab', 'all');
     $start = $this->request->variable('start', 0);
     $is_edit_mod = $this->isEditMod();
     $action = $this->request->variable('action', 'list');
     if ($action == 'list') {
         $valid_tabs = array('all' => RatingsManager::TAB_TYPE_ALL, 'buy' => RatingsManager::TOPIC_TYPE_BUY, 'sell' => RatingsManager::TOPIC_TYPE_SELL, 'trade' => RatingsManager::TOPIC_TYPE_TRADE, 'left' => RatingsManager::TAB_TYPE_LEFT);
         if (!isset($valid_tabs[$tab])) {
             $tab = 'all';
         }
         if (!$user_id) {
             trigger_error("No user provided - cannot display Trader Feedback");
         }
         $user_page_row = $this->fetch_user_row($this->db, $user_id);
         if (!$user_page_row) {
             trigger_error("Could not find specified user!");
         }
         $trader_stats = $this->manager->getUserFeedbackStats($user_id, true);
         if (!$trader_stats) {
             trigger_error("Feedback Statistics could not be retrieved");
         }
         if ($tab == 'buy') {
             $filter = $valid_tabs['sell'];
         } else {
             if ($tab == 'sell') {
                 $filter = $valid_tabs['buy'];
             } else {
                 $filter = $valid_tabs[$tab];
             }
         }
         // stores the number of total feedbacks that are filtered on a given tab - for pagination purposes
         // this number is updated by reference by the call to the manager
         $num_feedbacks = 0;
         $feedbacks = $this->manager->get_users_feedback($start, self::NUM_PER_PAGE, $user_id, $filter, $is_edit_mod, $num_feedbacks);
         if ($this->user->data['user_timezone']) {
             $timezone = new \DateTimeZone($this->user->data['user_timezone']);
         } else {
             $timezone = new \DateTimeZone($this->config['board_timezone']);
         }
         foreach ($feedbacks as $key => $feedback) {
             // fetch the appropriate user's information based on the selected tab
             // if the tab is 'Left for Others' we need to use the to_user_id (the recipient)
             if ($tab == "left") {
                 $user_row = $this->fetch_user_row($this->db, $feedback['to_user_id']);
                 $view_feedback_url = $this->helper->route('rfd_trader_view', array('u' => $feedback['to_user_id']));
             } else {
                 $user_row = $this->fetch_user_row($this->db, $feedback['from_user_id']);
                 $view_feedback_url = $this->helper->route('rfd_trader_view', array('u' => $feedback['from_user_id']));
             }
             $feedback['U_VIEW_FEEDBACK'] = $view_feedback_url;
             $feedback['table_username'] = $user_row['username'];
             $feedback['table_user_trader_rating'] = $user_row['user_trader_positive'] - $user_row['user_trader_negative'];
             $feedback['show_left_for_others'] = $tab == "left";
             $comments = $this->manager->getLatestFeedbackComment($feedback['feedback_id']);
             if ($comments) {
                 $feedback['short_comment'] = $comments['short_comment'];
                 if ($is_edit_mod || $feedback['from_user_id'] == $this->user->data['user_id'] || $feedback['to_user_id'] == $this->user->data['user_id']) {
                     $feedback['long_comment'] = $comments['long_comment'];
                 }
             }
             if ($is_edit_mod || $this->canEditFeedback($feedback['date_created'], $feedback['from_user_id'])) {
                 $edit_feedback_url = $this->helper->route('rfd_trader_edit_feedback', array('feedback_id' => $feedback['feedback_id'], 'u' => $user_id));
                 $feedback['U_EDIT_FEEDBACK'] = $edit_feedback_url;
             }
             if ($this->canReplyToFeedback($feedback['from_user_id'], $feedback['to_user_id'], $feedback['topic_id'])) {
                 $feedback['U_REPLY_FEEDBACK'] = $this->helper->route('rfd_trader_feedback', array('reply_id' => $feedback['feedback_id'], 'u' => $user_id));
             }
             $has_open_report = $this->manager->has_open_report($feedback['feedback_id']);
             // Show report button if the feedback is for the current user viewing the page
             if ($feedback['to_user_id'] == $this->user->data['user_id'] && !$has_open_report) {
                 $feedback['U_REPORT_FEEDBACK'] = append_sid(generate_board_url() . '/trader/view-feedback/?action=report&amp;id=' . $feedback['feedback_id']);
             }
             $feedback['topic_url'] = append_sid(generate_board_url() . "/viewtopic.php?t=" . $feedback['topic_id']);
             $feedback['date_created'] = new \DateTime('@' . $feedback['date_created']);
             $feedback['date_created']->setTimezone($timezone);
             $feedbacks[$key] = $feedback;
         }
         $trader_username_full = get_username_string('full', $user_page_row['user_id'], $user_page_row['username'], $user_page_row['user_colour']);
         $this->template->assign_vars(array('TRADER_USERNAME_FULL' => $trader_username_full, 'TRADER_USERNAME' => $user_page_row['username'], 'U_TRADER_PROFILE' => append_sid("{$this->phpbb_root_path}memberlist.{$this->phpEx}", 'mode=viewprofile&amp;u=' . $user_page_row['user_id']), 'trader_stats' => $trader_stats, 'recent_feedback' => $this->manager->getRecentUserFeedbackCounts($user_id), 'U_ACTION_TAB_ALL' => $this->helper->route("rfd_trader_view", array('u' => $user_id, 'tab' => 'all')), 'U_ACTION_TAB_BUY' => $this->helper->route("rfd_trader_view", array('u' => $user_id, 'tab' => 'buy')), 'U_ACTION_TAB_SELL' => $this->helper->route("rfd_trader_view", array('u' => $user_id, 'tab' => 'sell')), 'U_ACTION_TAB_TRADE' => $this->helper->route("rfd_trader_view", array('u' => $user_id, 'tab' => 'trade')), 'U_ACTION_TAB_LEFT' => $this->helper->route("rfd_trader_view", array('u' => $user_id, 'tab' => 'left')), 'CURRENT_TAB' => $tab, 'feedbacks' => $feedbacks, 'TOTAL_FEEDBACKS' => $num_feedbacks));
         $base_url = $this->helper->route('rfd_trader_view', array('u' => $user_id));
         $this->pagination->generate_template_pagination($base_url, 'pagination', 'start', $num_feedbacks, self::NUM_PER_PAGE, $start);
     } else {
         if ($action == 'report') {
             $this->report_feedback_action($this->request, $this->user);
         } else {
             trigger_error("Unknown Action!");
         }
     }
     return $this->helper->render('view_user_feedback.html', $this->user->lang['TRADER_FEEDBACK_FOR'] . '&nbsp;' . $user_page_row['username']);
 }
コード例 #12
0
ファイル: recent.php プロジェクト: alhitary/Board3-Portal
    /**
     * {@inheritdoc}
     */
    public function get_template_center($module_id)
    {
        //
        // Exclude forums
        //
        $sql_where = '';
        if ($this->config['board3_recent_forum_' . $module_id] > 0) {
            $exclude_forums = explode(',', $this->config['board3_recent_forum_' . $module_id]);
            $sql_where = ' AND ' . $this->db->sql_in_set('forum_id', array_map('intval', $exclude_forums), $this->config['board3_recent_exclude_forums_' . $module_id] ? true : false);
        }
        // Get a list of forums the user cannot read
        $forum_ary = array_unique(array_keys($this->auth->acl_getf('!f_read', true)));
        // Determine first forum the user is able to read (must not be a category)
        $sql = 'SELECT forum_id
			FROM ' . FORUMS_TABLE . '
			WHERE forum_type = ' . FORUM_POST;
        $forum_sql = '';
        if (sizeof($forum_ary)) {
            $sql .= ' AND ' . $this->db->sql_in_set('forum_id', $forum_ary, true);
            $forum_sql = ' AND ' . $this->db->sql_in_set('t.forum_id', $forum_ary, true);
        }
        $result = $this->db->sql_query_limit($sql, 1, 0, 600);
        $g_forum_id = (int) $this->db->sql_fetchfield('forum_id');
        $this->db->sql_freeresult($result);
        //
        // Recent announcements
        //
        $sql = 'SELECT topic_title, forum_id, topic_id
			FROM ' . TOPICS_TABLE . ' t
			WHERE topic_status <> ' . FORUM_LINK . '
				AND topic_visibility = ' . ITEM_APPROVED . '
				AND (topic_type = ' . POST_ANNOUNCE . ' OR topic_type = ' . POST_GLOBAL . ')
				AND topic_moved_id = 0
				' . $sql_where . $forum_sql . '
			ORDER BY topic_time DESC';
        $result = $this->db->sql_query_limit($sql, $this->config['board3_max_topics_' . $module_id], 0, 30);
        while (($row = $this->db->sql_fetchrow($result)) && $row['topic_title']) {
            // auto auth
            if ($this->auth->acl_get('f_read', $row['forum_id']) || $row['forum_id'] == '0') {
                $this->template->assign_block_vars('latest_announcements', array('TITLE' => character_limit($row['topic_title'], $this->config['board3_recent_title_limit_' . $module_id]), 'FULL_TITLE' => censor_text($row['topic_title']), 'U_VIEW_TOPIC' => append_sid("{$this->phpbb_root_path}viewtopic.{$this->php_ext}", 'f=' . ($row['forum_id'] == 0 ? $g_forum_id : $row['forum_id']) . '&amp;t=' . $row['topic_id'])));
            }
        }
        $this->db->sql_freeresult($result);
        //
        // Recent hot topics
        //
        $sql = 'SELECT topic_title, forum_id, topic_id
			FROM ' . TOPICS_TABLE . ' t
			WHERE topic_visibility = ' . ITEM_APPROVED . '
				AND topic_posts_approved >' . $this->config['hot_threshold'] . '
				AND topic_moved_id = 0
				' . $sql_where . $forum_sql . '
			ORDER BY topic_time DESC';
        $result = $this->db->sql_query_limit($sql, $this->config['board3_max_topics_' . $module_id], 0, 30);
        while (($row = $this->db->sql_fetchrow($result)) && $row['topic_title']) {
            // auto auth
            if ($this->auth->acl_get('f_read', $row['forum_id']) || $row['forum_id'] == '0') {
                $this->template->assign_block_vars('latest_hot_topics', array('TITLE' => character_limit($row['topic_title'], $this->config['board3_recent_title_limit_' . $module_id]), 'FULL_TITLE' => censor_text($row['topic_title']), 'U_VIEW_TOPIC' => append_sid("{$this->phpbb_root_path}viewtopic.{$this->php_ext}", 'f=' . ($row['forum_id'] == 0 ? $g_forum_id : $row['forum_id']) . '&amp;t=' . $row['topic_id'])));
            }
        }
        $this->db->sql_freeresult($result);
        //
        // Recent topic (only show normal topic)
        //
        $sql = 'SELECT topic_title, forum_id, topic_id
			FROM ' . TOPICS_TABLE . ' t
			WHERE topic_status <> ' . ITEM_MOVED . '
				AND topic_visibility = ' . ITEM_APPROVED . '
				AND topic_type = ' . POST_NORMAL . '
				AND topic_moved_id = 0
				' . $sql_where . $forum_sql . '
			ORDER BY topic_time DESC';
        $result = $this->db->sql_query_limit($sql, $this->config['board3_max_topics_' . $module_id], 0, 30);
        while (($row = $this->db->sql_fetchrow($result)) && $row['topic_title']) {
            // auto auth
            if ($this->auth->acl_get('f_read', $row['forum_id']) || $row['forum_id'] == '0') {
                $this->template->assign_block_vars('latest_topics', array('TITLE' => character_limit($row['topic_title'], $this->config['board3_recent_title_limit_' . $module_id]), 'FULL_TITLE' => censor_text($row['topic_title']), 'U_VIEW_TOPIC' => append_sid("{$this->phpbb_root_path}viewtopic.{$this->php_ext}", 'f=' . $row['forum_id'] . '&amp;t=' . $row['topic_id'])));
            }
        }
        $this->db->sql_freeresult($result);
        return 'recent_center.html';
    }
コード例 #13
0
ファイル: custom.php プロジェクト: alhitary/Board3-Portal
    /**
     * Manage custom module
     *
     * @param mixed $value Value of input
     * @param string $key Key name
     * @param int $module_id Module ID
     *
     * @return null
     */
    public function manage_custom($value, $key, $module_id)
    {
        $action = $this->request->is_set_post('reset') ? 'reset' : '';
        $action = $this->request->is_set_post('submit') ? 'save' : $action;
        $action = $this->request->is_set_post('preview') ? 'preview' : $action;
        $portal_config = obtain_portal_config();
        $u_action = append_sid('index.' . $this->php_ext, 'i=-board3-portal-acp-portal_module&amp;mode=config&amp;module_id=' . $module_id);
        switch ($action) {
            // Save changes
            case 'save':
                if (!check_form_key('acp_portal')) {
                    trigger_error($this->user->lang['FORM_INVALID'] . adm_back_link($u_action), E_USER_WARNING);
                }
                $custom_code = $this->request->variable('custom_code', '', true);
                $custom_bbcode = $this->request->variable('custom_use_bbcode', 1);
                // default to BBCode
                $custom_permission = $this->request->variable('permission-setting', array(0 => ''));
                $custom_title = $this->request->variable('module_name', '', true);
                $custom_image_src = $this->request->variable('module_image', '', true);
                $groups_ary = array();
                $uid = $bitfield = $flags = '';
                if ($custom_bbcode) {
                    generate_text_for_storage($custom_code, $uid, $bitfield, $flags, true, true, true);
                }
                // first check for obvious errors, we don't want to waste server resources
                if (empty($custom_code)) {
                    trigger_error($this->user->lang['ACP_PORTAL_CUSTOM_CODE_SHORT'] . adm_back_link($u_action), E_USER_WARNING);
                }
                // get groups and check if the selected groups actually exist
                $sql = 'SELECT group_id
						FROM ' . GROUPS_TABLE . '
						ORDER BY group_id ASC';
                $result = $this->db->sql_query($sql);
                while ($row = $this->db->sql_fetchrow($result)) {
                    $groups_ary[] = $row['group_id'];
                }
                $this->db->sql_freeresult($result);
                $custom_permission = array_intersect($custom_permission, $groups_ary);
                $custom_permission = implode(',', $custom_permission);
                if (isset($this->user->lang[$custom_title])) {
                    $log_title = $this->user->lang[$custom_title];
                } else {
                    $log_title = $custom_title;
                }
                $this->log->add('admin', $this->user->data['user_id'], $this->user->data['user_ip'], 'LOG_PORTAL_CONFIG', false, array($this->user->lang['PORTAL_CUSTOM'] . ':&nbsp;' . $log_title));
                // set_portal_config will take care of escaping the welcome message
                set_portal_config('board3_custom_' . $module_id . '_code', $custom_code);
                $this->config->set('board3_custom_' . $module_id . '_bbcode', $custom_bbcode);
                $this->config->set('board3_custom_' . $module_id . '_title', $custom_title);
                $this->config->set('board3_custom_' . $module_id . '_image_src', $custom_image_src);
                $this->config->set('board3_custom_' . $module_id . '_uid', $uid);
                $this->config->set('board3_custom_' . $module_id . '_bitfield', $bitfield);
                $this->config->set('board3_custom_' . $module_id . '_permission', $custom_permission);
                //trigger_error($this->user->lang['CONFIG_UPDATED'] . adm_back_link(($module_id) ? append_sid("{$phpbb_admin_path}index.$phpEx", 'i=portal&mode=modules') : $u_action));
                break;
            case 'preview':
                $custom_code = $text = $this->request->variable('custom_code', '', true);
                $custom_bbcode = $this->request->variable('custom_use_bbcode', 1);
                // default to BBCode
                $custom_permission = $this->request->variable('permission-setting', array(0 => ''));
                $custom_title = $this->request->variable('module_name', '', true);
                $custom_image_src = $this->request->variable('module_image', '', true);
                $groups_ary = array();
                // first check for obvious errors, we don't want to waste server resources
                if (empty($custom_code)) {
                    trigger_error($this->user->lang['ACP_PORTAL_CUSTOM_CODE_SHORT'] . adm_back_link($u_action), E_USER_WARNING);
                }
                if ($custom_bbcode) {
                    $bbcode_options = OPTION_FLAG_BBCODE + OPTION_FLAG_SMILIES + OPTION_FLAG_LINKS;
                    $uid = isset($this->config['board3_custom_' . $module_id . '_uid']) ? $this->config['board3_custom_' . $module_id . '_uid'] : '';
                    $bitfield = isset($this->config['board3_custom_' . $module_id . '_bitfield']) ? $this->config['board3_custom_' . $module_id . '_bitfield'] : '';
                    $options = OPTION_FLAG_BBCODE + OPTION_FLAG_SMILIES + OPTION_FLAG_LINKS;
                    generate_text_for_storage($text, $uid, $bitfield, $options, true, true, true);
                    $text = generate_text_for_display($text, $uid, $bitfield, $options);
                } else {
                    $text = htmlspecialchars_decode($text, ENT_QUOTES);
                }
                $this->template->assign_vars(array('PREVIEW_TEXT' => $text, 'S_PREVIEW' => true));
                // get groups and check if the selected groups actually exist
                $sql = 'SELECT group_id
						FROM ' . GROUPS_TABLE . '
						ORDER BY group_id ASC';
                $result = $this->db->sql_query($sql);
                while ($row = $this->db->sql_fetchrow($result)) {
                    $groups_ary[] = $row['group_id'];
                }
                $this->db->sql_freeresult($result);
                $temp_permissions = array_intersect($custom_permission, $groups_ary);
                // Edit or add menu item
            // Edit or add menu item
            case 'reset':
            default:
                if (!isset($custom_code)) {
                    $custom_code = generate_text_for_edit($portal_config['board3_custom_' . $module_id . '_code'], $this->config['board3_custom_' . $module_id . '_uid'], '');
                }
                $this->template->assign_vars(array('CUSTOM_CODE' => is_array($custom_code) ? $custom_code['text'] : $custom_code, 'CUSTOM_USE_BBCODE' => isset($custom_bbcode) ? $custom_bbcode : ($this->config['board3_custom_' . $module_id . '_bbcode'] != '' ? $this->config['board3_custom_' . $module_id . '_bbcode'] : true), 'U_ACTION' => $u_action, 'S_EDIT' => true, 'S_LINKS_ALLOWED' => true, 'S_BBCODE_IMG' => true, 'S_BBCODE_FLASH' => true, 'S_BBCODE_QUOTE' => true, 'S_BBCODE_ALLOWED' => true, 'MAX_FONT_SIZE' => (int) $this->config['max_post_font_size']));
                $groups_ary = isset($temp_permissions) ? $temp_permissions : (isset($this->config['board3_custom_' . $module_id . '_permission']) ? explode(',', $this->config['board3_custom_' . $module_id . '_permission']) : array());
                // get group info from database and assign the block vars
                $sql = 'SELECT group_id, group_name 
						FROM ' . GROUPS_TABLE . '
						ORDER BY group_id ASC';
                $result = $this->db->sql_query($sql);
                while ($row = $this->db->sql_fetchrow($result)) {
                    $this->template->assign_block_vars('permission_setting', array('SELECTED' => in_array($row['group_id'], $groups_ary) ? true : false, 'GROUP_NAME' => isset($this->user->lang['G_' . $row['group_name']]) ? $this->user->lang['G_' . $row['group_name']] : $row['group_name'], 'GROUP_ID' => $row['group_id']));
                }
                $this->db->sql_freeresult($result);
                if (!function_exists('display_forums')) {
                    include $this->phpbb_root_path . 'includes/functions_display.' . $this->php_ext;
                }
                // Build custom bbcodes array
                display_custom_bbcodes();
                $this->user->add_lang('posting');
                break;
        }
    }