コード例 #1
0
    /**
     * {@inheritdoc}
     */
    public function get_template_side($module_id)
    {
        $style_count = 0;
        $style_select = '';
        $sql = 'SELECT style_id, style_name
			FROM ' . STYLES_TABLE . '
			WHERE style_active = 1
			ORDER BY LOWER(style_name) ASC';
        $result = $this->db->sql_query($sql, 3600);
        while ($row = $this->db->sql_fetchrow($result)) {
            $style = $this->request->variable('style', 0);
            if (!empty($style)) {
                $url = str_replace('style=' . $style, 'style=' . $row['style_id'], $this->modules_helper->route('board3_portal_controller'));
            } else {
                $url = $this->modules_helper->route('board3_portal_controller') . '?style=' . $row['style_id'];
            }
            ++$style_count;
            $style_select .= '<option value="' . $url . '"' . ($row['style_id'] == $this->user->style['style_id'] ? ' selected="selected"' : '') . '>' . utf8_htmlspecialchars($row['style_name']) . '</option>';
        }
        $this->db->sql_freeresult($result);
        if (strlen($style_select)) {
            $this->template->assign_var('STYLE_SELECT', $style_select);
        }
        // Assign specific vars
        $this->template->assign_vars(array('S_STYLE_OPTIONS' => $this->config['override_user_style'] || $style_count < 2 ? '' : $style_select));
        return 'stylechanger_side.html';
    }
コード例 #2
0
ファイル: donation.php プロジェクト: alhitary/Board3-Portal
 /**
  * Create select box for attachment filetype
  *
  * @param mixed $value Value of input
  * @param string $key Key name
  * @param int $module_id Module ID
  *
  * @return string Forum select box HTML
  */
 public function select_currency($value, $key, $module_id)
 {
     $currencies = $selected = array();
     foreach ($this->currencies as $currency) {
         $currencies[] = array('title' => $this->user->lang($currency), 'value' => $currency);
         if ($currency === $this->config['board3_pay_default_' . $module_id]) {
             $selected[] = $currency;
         }
     }
     return $this->helper->generate_select_box($key, $currencies, $selected);
 }
コード例 #3
0
    /**
     * Create select box for attachment filetype
     *
     * @param mixed $value Value of input
     * @param string $key Key name
     * @param int $module_id Module ID
     *
     * @return string Forum select box HTML
     */
    public function select_filetype($value, $key, $module_id)
    {
        $extensions = array();
        // Get extensions
        $sql = 'SELECT *
			FROM ' . EXTENSIONS_TABLE . '
			ORDER BY extension ASC';
        $result = $this->db->sql_query($sql);
        while ($row = $this->db->sql_fetchrow($result)) {
            $extensions[] = array('value' => $row['extension'], 'title' => $row['extension']);
        }
        $this->db->sql_freeresult($result);
        $selected = $this->get_selected_filetypes($module_id);
        return $this->helper->generate_select_box($key, $extensions, $selected, true);
    }
コード例 #4
0
 /**
  * Get posts defined by type and other settings
  *
  * @param string $forum_from Forums from which the posts should be retrieved
  * @param bool $permissions Whether permissions should be taken into account
  * 					during retrieval
  * @param int $number_of_posts Number of posts to get
  * @param int $text_length Length the text should be shortened to
  * @param int $time The amount of days ago the posts could have been posted
  * @param string $type Type of posts to get
  * @param int $start At which position the query should start
  * @param bool $invert Whether the permissions should be inverted
  *
  * @return array An array containing the posts that were retrieved from the database
  */
 public function get_posts($forum_from, $permissions, $number_of_posts, $text_length, $time, $type, $start = 0, $invert = false)
 {
     $posts = array();
     $post_time = $this->get_setting_based_data($time == 0, '', 'AND t.topic_time > ' . (time() - $time * 86400));
     $forum_from = $this->get_setting_based_data(strpos($forum_from, ',') !== false, explode(',', $forum_from), $this->get_setting_based_data($forum_from != '', array($forum_from), array()));
     $topic_icons = array(0);
     $have_icons = 0;
     $this->global_id = 0;
     $this->type = $type;
     $this->reset_constraints();
     // Get disallowed forums
     $disallow_access = $this->modules_helper->get_disallowed_forums($permissions);
     // Set forums that should be excluded or included
     if (!$this->set_forum_constraints($forum_from, $disallow_access, $invert)) {
         return array();
     }
     // Get SQL constraints
     $this->get_type_constraints();
     // Get global forum ID for announcements
     if (!$this->get_global_id()) {
         return array();
     }
     $result = $this->run_sql_query($post_time, $number_of_posts, $start);
     $i = 0;
     // Fill posts array
     while ($row = $this->db->sql_fetchrow($result)) {
         $this->fill_posts_array($row, $text_length, $i, $have_icons, $posts, $topic_icons);
         ++$i;
     }
     $this->db->sql_freeresult($result);
     $posts['topic_icons'] = $this->get_setting_based_data(max($topic_icons) > 0 && $have_icons, true, false);
     $posts['topic_count'] = $i;
     if ($this->global_id < 1) {
         return array();
     } else {
         return $posts;
     }
 }
コード例 #5
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';
    }
コード例 #6
0
ファイル: news.php プロジェクト: sgtevmckay/Board3-Portal
    /**
     * {@inheritdoc}
     */
    public function get_template_center($module_id)
    {
        $news = $this->request->variable('news_' . $module_id, -1);
        $news = $news > $this->config['board3_number_of_news_' . $module_id] - 1 ? -1 : $news;
        $this->user->add_lang('viewforum');
        $start = $this->request->variable('np_' . $module_id, 0);
        $start = $start < 0 ? 0 : $start;
        $total_news = 1;
        // Fetch news from portal functions.php with check if "read full" is requested.
        $portal_news_length = $news < 0 && !$this->config['board3_news_style_' . $module_id] ? $this->config['board3_news_length_' . $module_id] : 0;
        $this->fetch_posts->set_module_id($module_id);
        $fetch_news = $this->fetch_posts->get_posts($this->config['board3_news_forum_' . $module_id], $this->config['board3_news_permissions_' . $module_id], $this->config['board3_number_of_news_' . $module_id], $portal_news_length, 0, $this->config['board3_show_all_news_' . $module_id] ? 'news_all' : 'news', $start, (bool) $this->config['board3_news_exclude_' . $module_id]);
        $topic_icons = false;
        if (!empty($fetch_news['topic_icons'])) {
            $topic_icons = true;
        }
        // Standard news row
        $news_row = array('S_NEWEST_OR_FIRST' => $this->config['board3_news_show_last_' . $module_id] ? $this->user->lang['JUMP_NEWEST'] : $this->user->lang['JUMP_FIRST'], 'POSTED_BY_TEXT' => $this->config['board3_news_show_last_' . $module_id] ? $this->user->lang['LAST_POST'] : $this->user->lang['POSTED'], 'S_DISPLAY_NEWS_RVS' => $this->config['board3_show_news_replies_views_' . $module_id] ? true : false, 'S_TOPIC_ICONS' => $topic_icons, 'MODULE_ID' => $module_id);
        // Any news present? If not terminate it here.
        if (sizeof($fetch_news) == 0) {
            // Create standard news row
            $this->template->assign_block_vars('news', $news_row);
            $this->template->assign_block_vars('news.news_row', array('S_NO_TOPICS' => true, 'S_NOT_LAST' => false));
        } else {
            // Count number of posts for news archive, considering if permission check is dis- or enabled.
            if ($this->config['board3_news_archive_' . $module_id]) {
                $permissions = $this->config['board3_news_permissions_' . $module_id];
                $forum_from = $this->config['board3_news_forum_' . $module_id];
                $forum_from = strpos($forum_from, ',') !== false ? explode(',', $forum_from) : ($forum_from != '' ? array($forum_from) : array());
                $str_where = '';
                // Get disallowed forums
                $disallow_access = $this->modules_helper->get_disallowed_forums($permissions);
                if ($this->config['board3_news_exclude_' . $module_id] == true) {
                    $disallow_access = array_merge($disallow_access, $forum_from);
                    $forum_from = array();
                }
                if (sizeof($forum_from)) {
                    $disallow_access = array_diff($forum_from, $disallow_access);
                    if (!sizeof($disallow_access)) {
                        return array();
                    }
                    foreach ($disallow_access as $acc_id) {
                        $acc_id = (int) $acc_id;
                        $str_where .= "forum_id = {$acc_id} OR ";
                    }
                } else {
                    foreach ($disallow_access as $acc_id) {
                        $acc_id = (int) $acc_id;
                        $str_where .= "forum_id <> {$acc_id} AND ";
                    }
                }
                $str_where = strlen($str_where) > 0 ? 'AND (' . trim(substr($str_where, 0, -4)) . ')' : '';
                $topic_type = $this->config['board3_show_all_news_' . $module_id] ? '(topic_type <> ' . POST_ANNOUNCE . ') AND (topic_type <> ' . POST_GLOBAL . ')' : 'topic_type = ' . POST_NORMAL;
                $sql = 'SELECT COUNT(topic_id) AS num_topics
					FROM ' . TOPICS_TABLE . '
					WHERE ' . $topic_type . '
						AND topic_visibility = ' . ITEM_APPROVED . '
						AND topic_moved_id = 0
						' . $str_where;
                $result = $this->db->sql_query($sql, 300);
                $total_news = (int) $this->db->sql_fetchfield('num_topics');
                $this->db->sql_freeresult($result);
            }
            $topic_tracking_info = get_portal_tracking_info($fetch_news);
            // Create pagination if necessary
            if ($this->config['board3_news_archive_' . $module_id]) {
                $pagination = generate_portal_pagination($this->modules_helper->route('board3_portal_controller'), $total_news, $this->config['board3_number_of_news_' . $module_id], $start, $this->config['board3_show_all_news_' . $module_id] ? 'news_all' : 'news', $module_id);
            }
            if ($this->config['board3_number_of_news_' . $module_id] != 0 && $this->config['board3_news_archive_' . $module_id]) {
                $news_row = array_merge($news_row, array('NP_PAGINATION' => !empty($pagination) ? $pagination : '', 'TOTAL_NEWS' => $total_news == 1 ? sprintf($this->user->lang['VIEW_FORUM_TOPICS'][1], $total_news) : sprintf($this->user->lang['VIEW_FORUM_TOPICS'][2], $total_news), 'NP_PAGE_NUMBER' => $this->pagination->on_page($total_news, $this->config['board3_number_of_news_' . $module_id], $start)));
            }
            // Create standard news row
            $this->template->assign_block_vars('news', $news_row);
            // Show the news overview
            if ($news < 0) {
                $count = $fetch_news['topic_count'];
                for ($i = 0; $i < $count; $i++) {
                    if (isset($fetch_news[$i]['striped']) && $fetch_news[$i]['striped'] == true) {
                        $open_bracket = '[ ';
                        $close_bracket = ' ]';
                        $read_full = $this->user->lang['READ_FULL'];
                    } else {
                        $open_bracket = '';
                        $close_bracket = '';
                        $read_full = '';
                    }
                    // unread?
                    $forum_id = $fetch_news[$i]['forum_id'];
                    $topic_id = $fetch_news[$i]['topic_id'];
                    $unread_topic = isset($topic_tracking_info[$topic_id]) && $fetch_news[$i]['topic_last_post_time'] > $topic_tracking_info[$topic_id] ? true : false;
                    $read_full_url = $this->request->is_set('np_' . $module_id) ? "np_{$module_id}={$start}&amp;news_{$module_id}={$i}#n_{$module_id}_{$i}" : "news_{$module_id}={$i}#n_{$module_id}_{$i}";
                    $view_topic_url = append_sid("{$this->phpbb_root_path}viewtopic.{$this->php_ext}", 'f=' . ($fetch_news[$i]['forum_id'] ? $fetch_news[$i]['forum_id'] : $forum_id) . '&amp;t=' . $topic_id);
                    $replies = $this->auth->acl_get('m_approve', $forum_id) ? $fetch_news[$i]['topic_replies_real'] : $fetch_news[$i]['topic_replies'];
                    switch ($fetch_news[$i]['topic_type']) {
                        case POST_STICKY:
                            $folder = 'sticky_read';
                            $folder_new = 'sticky_unread';
                            break;
                        case POST_ANNOUNCE:
                            $folder = 'announce_read';
                            $folder_new = 'announce_unread';
                            break;
                        default:
                            $folder = 'topic_read';
                            $folder_new = 'topic_unread';
                            if ($this->config['hot_threshold'] && $replies >= $this->config['hot_threshold'] && $fetch_news[$i]['topic_status'] != ITEM_LOCKED) {
                                $folder .= '_hot';
                                $folder_new .= '_hot';
                            }
                            break;
                    }
                    if ($fetch_news[$i]['topic_status'] == ITEM_LOCKED) {
                        $folder .= '_locked';
                        $folder_new .= '_locked';
                    }
                    if ($fetch_news[$i]['topic_posted']) {
                        $folder .= '_mine';
                        $folder_new .= '_mine';
                    }
                    $folder_img = $unread_topic ? $folder_new : $folder;
                    $folder_alt = $unread_topic ? 'NEW_POSTS' : ($fetch_news[$i]['topic_status'] == ITEM_LOCKED ? 'TOPIC_LOCKED' : 'NO_NEW_POSTS');
                    // Grab icons
                    $icons = $this->cache->obtain_icons();
                    $this->template->assign_block_vars('news.news_row', array('ATTACH_ICON_IMG' => $fetch_news[$i]['attachment'] && $this->config['allow_attachments'] ? $this->user->img('icon_topic_attach', $this->user->lang['TOTAL_ATTACHMENTS']) : '', 'FORUM_NAME' => $forum_id ? $fetch_news[$i]['forum_name'] : '', 'TITLE' => $fetch_news[$i]['topic_title'], 'POSTER' => $fetch_news[$i]['username'], 'POSTER_FULL' => $fetch_news[$i]['username_full'], 'USERNAME_FULL_LAST' => $fetch_news[$i]['username_full_last'], 'U_USER_PROFILE' => ($fetch_news[$i]['user_type'] == USER_NORMAL || $fetch_news[$i]['user_type'] == USER_FOUNDER) && $fetch_news[$i]['user_id'] != ANONYMOUS ? append_sid("{$this->phpbb_root_path}memberlist.{$this->php_ext}", 'mode=viewprofile&amp;u=' . $fetch_news[$i]['user_id']) : '', 'TIME' => $fetch_news[$i]['topic_time'], 'LAST_POST_TIME' => $this->user->format_date($fetch_news[$i]['topic_last_post_time']), 'TEXT' => $fetch_news[$i]['post_text'], 'REPLIES' => $fetch_news[$i]['topic_replies'], 'TOPIC_VIEWS' => $fetch_news[$i]['topic_views'], 'N_ID' => $i, 'TOPIC_FOLDER_IMG' => $this->user->img($folder_img, $folder_alt), 'TOPIC_IMG_STYLE' => $folder_img, 'TOPIC_FOLDER_IMG_SRC' => $this->user->img($folder_img, $folder_alt, false, '', 'src'), 'TOPIC_FOLDER_IMG_ALT' => $this->user->lang[$folder_alt], 'TOPIC_ICON_IMG' => !empty($icons[$fetch_news[$i]['icon_id']]) ? $icons[$fetch_news[$i]['icon_id']]['img'] : '', 'TOPIC_ICON_IMG_WIDTH' => !empty($icons[$fetch_news[$i]['icon_id']]) ? $icons[$fetch_news[$i]['icon_id']]['width'] : '', 'TOPIC_ICON_IMG_HEIGHT' => !empty($icons[$fetch_news[$i]['icon_id']]) ? $icons[$fetch_news[$i]['icon_id']]['height'] : '', 'FOLDER_IMG' => $this->user->img('topic_read', 'NO_NEW_POSTS'), 'U_VIEWFORUM' => append_sid("{$this->phpbb_root_path}viewforum.{$this->php_ext}", 'f=' . $fetch_news[$i]['forum_id']), 'U_LAST_COMMENTS' => append_sid("{$this->phpbb_root_path}viewtopic.{$this->php_ext}", 'f=' . $fetch_news[$i]['forum_id'] . '&amp;t=' . $fetch_news[$i]['topic_id'] . '&amp;p=' . $fetch_news[$i]['topic_last_post_id'] . '#p' . $fetch_news[$i]['topic_last_post_id']), 'U_VIEW_COMMENTS' => append_sid("{$this->phpbb_root_path}viewtopic.{$this->php_ext}", 'f=' . $fetch_news[$i]['forum_id'] . '&amp;t=' . $fetch_news[$i]['topic_id']), 'U_VIEW_UNREAD' => append_sid("{$this->phpbb_root_path}viewtopic.{$this->php_ext}", 'f=' . $fetch_news[$i]['forum_id'] . '&amp;t=' . $fetch_news[$i]['topic_id'] . '&amp;view=unread#unread'), 'U_POST_COMMENT' => append_sid("{$this->phpbb_root_path}posting.{$this->php_ext}", 'mode=reply&amp;f=' . $fetch_news[$i]['forum_id'] . '&amp;t=' . $fetch_news[$i]['topic_id']), 'U_READ_FULL' => $this->modules_helper->route('board3_portal_controller') . '?' . $read_full_url, 'L_READ_FULL' => $read_full, 'OPEN' => $open_bracket, 'CLOSE' => $close_bracket, 'S_NOT_LAST' => $i < sizeof($fetch_news) - 1 ? true : false, 'S_POLL' => $fetch_news[$i]['poll'], 'S_UNREAD_INFO' => $unread_topic, 'S_HAS_ATTACHMENTS' => !empty($fetch_news[$i]['attachments']) ? true : false));
                    // Assign pagination
                    $this->pagination->generate_template_pagination($view_topic_url, 'news.news_row.pagination', 'start', $fetch_news[$i]['topic_replies'] + 1, $this->config['posts_per_page'], 1);
                    if (!empty($fetch_news[$i]['attachments'])) {
                        foreach ($fetch_news[$i]['attachments'] as $attachment) {
                            $this->template->assign_block_vars('news.news_row.attachment', array('DISPLAY_ATTACHMENT' => $attachment));
                        }
                    }
                }
            } else {
                $i = $news;
                $forum_id = $fetch_news[$i]['forum_id'];
                $topic_id = $fetch_news[$i]['topic_id'];
                $unread_topic = isset($topic_tracking_info[$topic_id]) && $fetch_news[$i]['topic_last_post_time'] > $topic_tracking_info[$topic_id] ? true : false;
                $open_bracket = '[ ';
                $close_bracket = ' ]';
                $read_full = $this->user->lang['BACK'];
                $read_full_url = $this->request->is_set('np_' . $module_id) ? $this->modules_helper->route('board3_portal_controller') . "?np_{$module_id}={$start}#n_{$module_id}_{$i}" : $this->modules_helper->route('board3_portal_controller') . "#n_{$module_id}_{$i}";
                $view_topic_url = append_sid("{$this->phpbb_root_path}viewtopic.{$this->php_ext}", 'f=' . ($fetch_news[$i]['forum_id'] ? $fetch_news[$i]['forum_id'] : $forum_id) . '&amp;t=' . $topic_id);
                $this->template->assign_block_vars('news.news_row', array('ATTACH_ICON_IMG' => $fetch_news[$i]['attachment'] && $this->config['allow_attachments'] ? $this->user->img('icon_topic_attach', $this->user->lang['TOTAL_ATTACHMENTS']) : '', 'FORUM_NAME' => $forum_id ? $fetch_news[$i]['forum_name'] : '', 'TITLE' => $fetch_news[$i]['topic_title'], 'POSTER' => $fetch_news[$i]['username'], 'POSTER_FULL' => $fetch_news[$i]['username_full'], 'TIME' => $fetch_news[$i]['topic_time'], 'TEXT' => $fetch_news[$i]['post_text'], 'REPLIES' => $fetch_news[$i]['topic_replies'], 'TOPIC_VIEWS' => $fetch_news[$i]['topic_views'], 'N_ID' => $i, 'U_VIEWFORUM' => append_sid("{$this->phpbb_root_path}viewforum.{$this->php_ext}", 'f=' . $fetch_news[$i]['forum_id']), 'U_LAST_COMMENTS' => append_sid("{$this->phpbb_root_path}viewtopic.{$this->php_ext}", 'p=' . $fetch_news[$i]['topic_last_post_id'] . '#p' . $fetch_news[$i]['topic_last_post_id']), 'U_VIEW_COMMENTS' => append_sid("{$this->phpbb_root_path}viewtopic.{$this->php_ext}", 'f=' . $fetch_news[$i]['forum_id'] . '&amp;t=' . $fetch_news[$i]['topic_id']), 'U_POST_COMMENT' => append_sid("{$this->phpbb_root_path}posting.{$this->php_ext}", 'mode=reply&amp;f=' . $fetch_news[$i]['forum_id'] . '&amp;t=' . $fetch_news[$i]['topic_id']), 'S_POLL' => $fetch_news[$i]['poll'], 'S_UNREAD_INFO' => $unread_topic, 'U_READ_FULL' => $read_full_url, 'L_READ_FULL' => $read_full, 'OPEN' => $open_bracket, 'CLOSE' => $close_bracket, 'S_HAS_ATTACHMENTS' => !empty($fetch_news[$i]['attachments']) ? true : false));
                $this->pagination->generate_template_pagination($view_topic_url, 'news.news_row.pagination', 'start', $fetch_news[$i]['topic_replies'] + 1, $this->config['posts_per_page'], 1);
                if (!empty($fetch_news[$i]['attachments'])) {
                    foreach ($fetch_news[$i]['attachments'] as $attachment) {
                        $this->template->assign_block_vars('news.news_row.attachment', array('DISPLAY_ATTACHMENT' => $attachment));
                    }
                }
            }
        }
        $this->template->assign_vars(array('NEWEST_POST_IMG' => $this->user->img('icon_topic_newest', 'VIEW_NEWEST_POST'), 'READ_POST_IMG' => $this->user->img('icon_topic_latest', 'VIEW_LATEST_POST'), 'GOTO_PAGE_IMG' => $this->user->img('icon_post_target', 'GOTO_PAGE')));
        if ($this->config['board3_news_style_' . $module_id]) {
            return 'news_compact_center.html';
        } else {
            return 'news_center.html';
        }
    }
コード例 #7
0
ファイル: calendar.php プロジェクト: alhitary/Board3-Portal
 /**
  * {@inheritdoc}
  */
 public function get_template_side($module_id)
 {
     $portal_config = obtain_portal_config();
     // 0 = Sunday first - 1 = Monday first. ;-)
     if ($this->config['board3_sunday_first_' . $module_id]) {
         $this->mini_cal_fdow = 0;
     } else {
         $this->mini_cal_fdow = 1;
     }
     // get the calendar month
     $this->mini_cal_month = 0;
     if ($this->request->is_set('m' . $module_id)) {
         $this->mini_cal_month = $this->request->variable('m' . $module_id, 0);
     }
     // initialise some variables
     $this->time = $this->user->create_datetime();
     $now = phpbb_gmgetdate($this->time->getTimestamp() + $this->time->getOffset());
     $today_timestamp = $now[0];
     $mini_cal_today = date('Ymd', $today_timestamp);
     $this->stamp = (int) $today_timestamp;
     $s_cal_month = $this->mini_cal_month != 0 ? $this->mini_cal_month . ' month' : $mini_cal_today;
     $this->get_month($s_cal_month);
     $mini_cal_count = $this->mini_cal_fdow;
     $mini_cal_this_year = $this->dateYYYY;
     $mini_cal_this_month = $this->dateMM;
     $mini_cal_month_days = $this->daysMonth;
     // output our general calendar bits
     $down = $this->mini_cal_month - 1;
     $up = $this->mini_cal_month + 1;
     $prev_month = '<a href="' . $this->modules_helper->route('board3_portal_controller') . "?m{$module_id}={$down}#minical{$module_id}" . '" rel="nofollow"><span class="portal-arrow-left-icon" title="' . $this->user->lang['VIEW_PREVIOUS_MONTH'] . '"></span></a>';
     $next_month = '<a href="' . $this->modules_helper->route('board3_portal_controller') . "?m{$module_id}={$up}#minical{$module_id}" . '" rel="nofollow"><span class="portal-arrow-right-icon" title="' . $this->user->lang['VIEW_NEXT_MONTH'] . '"></span></a>';
     $this->template->assign_block_vars('minical', array('S_SUNDAY_FIRST' => $this->config['board3_sunday_first_' . $module_id] ? true : false, 'L_MINI_CAL_MONTH' => ($this->config['board3_long_month_' . $module_id] ? $this->user->lang['mini_cal']['long_month'][$this->day[0][1]] : $this->user->lang['mini_cal']['month'][$this->day[0][1]]) . " " . $this->day[0][2], 'L_MINI_CAL_SUN' => '<span style="color: ' . $this->config['board3_calendar_sunday_color_' . $module_id] . ';">' . $this->user->lang['mini_cal']['day'][1] . '</span>', 'L_MINI_CAL_MON' => $this->user->lang['mini_cal']['day'][2], 'L_MINI_CAL_TUE' => $this->user->lang['mini_cal']['day'][3], 'L_MINI_CAL_WED' => $this->user->lang['mini_cal']['day'][4], 'L_MINI_CAL_THU' => $this->user->lang['mini_cal']['day'][5], 'L_MINI_CAL_FRI' => $this->user->lang['mini_cal']['day'][6], 'L_MINI_CAL_SAT' => $this->user->lang['mini_cal']['day'][7], 'U_PREV_MONTH' => $prev_month, 'U_NEXT_MONTH' => $next_month, 'S_DISPLAY_EVENTS' => $this->config['board3_display_events_' . $module_id] ? true : false, 'MODULE_ID' => $module_id));
     // output the days for the current month
     for ($i = 0; $i < $mini_cal_month_days;) {
         // is this the first day of the week?
         if ($mini_cal_count == $this->mini_cal_fdow) {
             $this->template->assign_block_vars('minical.mini_cal_row', array('MODULE_ID' => $module_id));
         }
         // is this a valid weekday?
         if ($mini_cal_count == $this->day[$i][3]) {
             $mini_cal_this_day = $this->day[$i][0];
             $d_mini_cal_today = $mini_cal_this_year . ($mini_cal_this_month <= 9 ? '0' . $mini_cal_this_month : $mini_cal_this_month) . ($mini_cal_this_day <= 9 ? '0' . $mini_cal_this_day : $mini_cal_this_day);
             $mini_cal_day = $mini_cal_today == $d_mini_cal_today ? '<span style="font-weight: bold; color: ' . $this->config['board3_calendar_today_color_' . $module_id] . ';">' . $mini_cal_this_day . '</span>' : $mini_cal_this_day;
             $this->template->assign_block_vars('minical.mini_cal_row.mini_cal_days', array('MINI_CAL_DAY' => $mini_cal_count == 0 ? '<span style="color: ' . $this->config['board3_calendar_sunday_color_' . $module_id] . ';">' . $mini_cal_day . '</span>' : $mini_cal_day));
             $i++;
         } else {
             $this->template->assign_block_vars('minical.mini_cal_row.mini_cal_days', array('MINI_CAL_DAY' => ' '));
         }
         // is this the last day of the week?
         if ($mini_cal_count == self::DAYS_PER_WEEK) {
             // if so then reset the count
             $mini_cal_count = 0;
         } else {
             // otherwise increment the count
             $mini_cal_count++;
         }
     }
     // fill table with empty strings
     while ($mini_cal_count <= self::DAYS_PER_WEEK) {
         $this->template->assign_block_vars('minical.mini_cal_row.mini_cal_days', array('MINI_CAL_DAY' => ' '));
         $mini_cal_count++;
     }
     /*
      * Let's start displaying the events
      * make sure we only display events in the future
      */
     $events = json_decode($portal_config['board3_calendar_events_' . $module_id], true);
     if (!empty($events) && $this->config['board3_display_events_' . $module_id]) {
         $time_ary = array();
         // we sort the $events array by the start time
         foreach ($events as $key => $cur_event) {
             $time_ary[$key] = $cur_event['start_time'];
         }
         array_multisort($time_ary, SORT_NUMERIC, $events);
         $groups_ary = get_user_groups();
         foreach ($events as $key => $cur_event) {
             if ($cur_event['start_time'] + $this->time->getOffset() >= $today_timestamp || $cur_event['end_time'] + $this->time->getOffset() >= $today_timestamp || $cur_event['start_time'] + $this->time->getOffset() + self::TIME_DAY >= $today_timestamp && $cur_event['all_day']) {
                 $cur_permissions = explode(',', $cur_event['permission']);
                 $permission_check = array_intersect($groups_ary, $cur_permissions);
                 if (!empty($permission_check) || $cur_event['permission'] == '') {
                     // check if this is an external link
                     if (isset($cur_event['url']) && strpos($cur_event['url'], generate_board_url()) === false) {
                         $is_external = true;
                     } else {
                         $is_external = false;
                     }
                     /**
                      * Current events
                      *
                      * Events are treated as current if the following is met:
                      * - We have an all day event and the start of that event is less than 1 day (86400 seconds) away
                      * - We have a normal event with a start that is less then 1 day away and that hasn't ended yet
                      */
                     if ($cur_event['start_time'] + $this->time->getOffset() - $today_timestamp <= self::TIME_DAY && $cur_event['all_day'] || $cur_event['start_time'] + $this->time->getOffset() - $today_timestamp <= self::TIME_DAY && $cur_event['end_time'] + $this->time->getOffset() >= $today_timestamp) {
                         $this->template->assign_block_vars('minical.cur_events', array('EVENT_URL' => isset($cur_event['url']) && $cur_event['url'] != '' ? $this->validate_url($cur_event['url']) : '', 'EVENT_TITLE' => $cur_event['title'], 'START_TIME' => $this->user->format_date($cur_event['start_time']), 'END_TIME' => !empty($cur_event['end_time']) ? $this->user->format_date($cur_event['end_time']) : false, 'EVENT_DESC' => isset($cur_event['desc']) && $cur_event['desc'] != '' ? $cur_event['desc'] : '', 'ALL_DAY' => $cur_event['all_day'] ? true : false, 'MODULE_ID' => $module_id, 'EVENT_URL_NEW_WINDOW' => $is_external && $this->config['board3_events_url_new_window_' . $module_id] ? true : false));
                     } else {
                         $this->template->assign_block_vars('minical.upcoming_events', array('EVENT_URL' => isset($cur_event['url']) && $cur_event['url'] != '' ? $this->validate_url($cur_event['url']) : '', 'EVENT_TITLE' => $cur_event['title'], 'START_TIME' => $this->user->format_date($cur_event['start_time']), 'END_TIME' => !$cur_event['all_day'] ? $this->user->format_date($cur_event['end_time']) : '', 'EVENT_DESC' => isset($cur_event['desc']) && $cur_event['desc'] != '' ? $cur_event['desc'] : '', 'ALL_DAY' => $cur_event['start_time'] - $cur_event['end_time'] == 1 ? true : false, 'MODULE_ID' => $module_id, 'EVENT_URL_NEW_WINDOW' => $is_external && $this->config['board3_events_url_new_window_' . $module_id] ? true : false));
                     }
                 }
             }
         }
     }
     return 'calendar_side.html';
 }