Example #1
0
    protected function _view_home()
    {
        global $core, $bio;
        $v = $this->__(array('alias', 't' => 0, 'p' => 0));
        if (!f($v['alias'])) {
            _fatal();
        }
        $v['field'] = !is_numb($v['alias']) ? 'alias' : 'id';
        $sql = 'SELECT *
			FROM _events
			WHERE event_?? = ?';
        if (!($event = _fieldrow(sql_filter($sql, $v['field'], $v['alias'])))) {
            _fatal();
        }
        if ($v['field'] == 'id' && f($event['event_alias'])) {
            redirect(_link($this->m(), $event['event_alias']) . _linkp(array('t' => $v['t'], 'p' => $v['p']), true));
        }
        // Get images
        $sql = 'SELECT *
			FROM _events_images
			WHERE image_event = ?
			ORDER BY image ASC
			LIMIT ??, ??';
        $event_images = _rowset(sql_filter($sql, $event['event_id'], $v['t'], $core->v('thumbs_per_page')));
        foreach ($event_images as $i => $row) {
            if (!$i) {
                _style('thumbnails', _pagination(_link($this->m(), $event['event_alias']), 't:%d', $event['event_images'], $core->v('thumbs_per_page'), $v['t']));
            }
            _style('thumbnails.row', array('U_THUMBNAIL' => _lib(w(LIB_EVENT . ' thumbnail ' . $event['event_id'], $row['image'], 'jpg')), 'U_IMAGE' => _lib(w(LIB_EVENT . ' gallery ' . $event['event_id'], $row['image'], 'jpg')), 'V_FOOTER' => $row['image_footer']));
        }
        if (is_ghost()) {
            return;
        }
        // Statistics
        if (!$v['t'] && !$bio->v('auth_founder')) {
            $this->_stats_store();
        }
        $is_future = $row['event_end'] > time() ? true : false;
        if (!$is_future) {
            // Star for favourites
            if (!($star_type = $core->cache_load('star_type'))) {
                $sql = 'SELECT type_id, type_name
					FROM _events_star_type
					ORDER BY type_order';
                $types = $core->cache_store('star_type', _rowset($sql, 'type_id', 'type_name'));
            }
            $i = 0;
            foreach ($types as $type_id => $type_name) {
                if (!$i) {
                    _style('star_type');
                }
                _style('star_type.row', array('TYPE_ID' => $type_id, 'TYPE_NAME' => $type_name));
                $i++;
            }
        } else {
            $sql = 'SELECT *
				FROM _events_reviews r, _bio b
				WHERE r.review_event = ?
					AND r.review_uid = b.bio_id
				ORDER BY r.review_avg
				LIMIT 0, 5';
            $reviews = _rowset(sql_filter($sql, $event['event_id']), 'review_id');
            $sql = 'SELECT *
				FROM _events_reviews_rate r, _events_reviews_fields f
				WHERE r.rate_review IN (??)
					AND r.rate_field = f.field_id
				ORDER BY f.field_order';
            $reviews_rate = _rowset(sql_filter($sql, _implode(',', array_keys($reviews))), 'rate_review', false, true);
            $i = 0;
            foreach ($reviews as $row) {
                if (!$i) {
                    _style('reviews');
                }
                _style('reviews.row', array('REVIEW_CONTENT' => $row['review_content'], 'REVIEW_' => $row['review_']));
                if (isset($reviews_rate[$row['review_id']])) {
                    foreach ($reviews_rate[$row['review_id']] as $j => $rate) {
                        if (!$j) {
                            _style('reviews.row.rate');
                        }
                        _style('reviews.row.rate.field', array('FIELD' => $rate['field_name'], 'RATE' => $rate['rate_value']));
                    }
                }
                $i++;
            }
        }
        // Who attend
        $sql = 'SELECT at.type_id, at.type_name_next, at.type_name_prev, b.bio_alias, b.bio_name, b.bio_avatar, b.bio_avatar_up
			FROM _events_attend a, _events_attend_type at, _bio b
			WHERE a.attend_event = ?
				AND a.attend_type = at.type_id
				AND a.attend_uid = b.bio_id
			ORDER BY a.attend_time';
        $attend = _rowset(sql_filter($sql, $event['event_id']), 'type_id', false, true);
        $i = 0;
        foreach ($attend as $type_name => $rows) {
            if (!$i) {
                _style('attend');
            }
            $type_name = $is_future ? 'next' : 'prev';
            _style('attend.type', array('TYPE_NAME' => $rows[0]['type_name_' . $type_name]));
            foreach ($rows as $row) {
                _style('attend.type.row', array('BIO_NAME' => $row['bio_name'], 'BIO_AVATAR' => _avatar($row)));
            }
            $i++;
        }
        // Messages
        $ref = _link('events', $event['event_alias']);
        if ($event['event_publish']) {
            if ($event['event_comments']) {
                $sql = 'SELECT c.comment_id, c.comment_time, c.comment_text, b.bio_id, b.bio_alias, b.bio_name, b.bio_avatar, b.bio_avatar_up
					FROM _events_comments c, _bio b
					WHERE c.comment_event = ?
						AND c.comment_active = ?
						AND c.comment_bio = b.bio_id
					ORDER BY c.comment_time DESC
					LIMIT ??, ??';
                $comments = _rowset(sql_filter($sql, $event['event_id'], 1, $v['p'], $core->v('events_comments')));
                foreach ($comments as $i => $row) {
                    if (!$i) {
                        _style('comment_area', _pagination(_link($this->m(), array($event['event_alias'], $v['t'], 's%d')), $topic_data['topic_replies'] + 1, $core->v('posts_per_page'), $start));
                    }
                    _style('comment_area.row', array('BIO_ALIAS' => _link_bio($row['bio_alias']), 'BIO_NAME' => $row['bio_name'], 'BIO_AVATAR' => _avatar($row), 'COMMENT_ID' => $row['comment_id'], 'COMMENT_TIME' => _format_date($row['comment_time']), 'COMMENT_TEXT' => _message($row['comment_text'])));
                }
            }
            _style('comment_publish', array('U_PUBLISH' => _link()));
        }
        //
        if ($event['event_posts']) {
            $reply = array('ref' => $ref, 'start' => $v['p'], 'start_f' => 's', 'rows' => $event['event_posts'], 'rows_page' => $core->v('s_posts'), 'block' => 'posts', 'sql' => 'SELECT p.post_id, p.post_time, p.post_text, b.bio_id, b.bio_alias, b.bio_name, b.bio_avatar, b.bio_avatar_up, b.bio_sig
					FROM _events_posts p, _bio b
					WHERE p.post_event = ?
						AND p.post_active = 1 
						AND p.post_uid = b.bio_id
					ORDER BY p.post_time DESC
					LIMIT {START}, {ROWS_PAGE}');
            $reply['sql'] = sql_filter($reply['sql'], $event['event_id']);
            $this->_replies($reply);
        }
        v_style(_vs(array('SUBJECT' => $event['event_subject'], 'IMAGES' => $event['event_images'], 'START' => _format_date($event['event_start'], 'd F Y'), 'END' => _format_date($event['event_end'], 'd F Y'), 'COMMENTS' => $event['event_posts']), 'event'));
        return;
    }
Example #2
0
    public function home()
    {
        global $core, $bio;
        $page = 15;
        $today = _htimestamp('md');
        _pre($bio->v('is_bio'), true);
        _style('status_post');
        // Friends birthday
        if ($bio->v('auth_member')) {
            $sql = "SELECT bio_id, bio_alias, bio_name\r\n\t\t\t\tFROM _bio\r\n\t\t\t\tWHERE bio_id IN (\r\n\t\t\t\t\t\tSELECT fan_of\r\n\t\t\t\t\t\tFROM _bio_fans\r\n\t\t\t\t\t\tWHERE fan_assoc = ?\r\n\t\t\t\t\t)\r\n\t\t\t\t\tAND bio_active = ?\r\n\t\t\t\t\tAND bio_birth LIKE '%??'\r\n\t\t\t\tORDER BY bio_name";
            $birthday = _rowset(sql_filter($sql, $bio->v('bio_id'), 1, $today));
        } else {
            $sql = "SELECT bio_id, bio_alias, bio_name, bio_avatar, bio_avatar_up\r\n\t\t\t\tFROM _bio\r\n\t\t\t\tWHERE bio_level = ?\r\n\t\t\t\t\tAND bio_birth LIKE '%??'\r\n\t\t\t\tORDER BY bio_name";
            $birthday = _rowset(sql_filter($sql, 1, $today));
        }
        foreach ($birthday as $i => $row) {
            if (!$i) {
                _style('birthday');
            }
            _style('birthday.row', array('A' => _a($row), 'NAME' => $row['bio_name'], 'AVATAR' => _avatar($row)));
        }
        // Board topics
        if ($bio->v('auth_member')) {
            $sql = 'SELECT t.topic_id, t.topic_alias, t.topic_title, h.highlight_class
				FROM _board_topics t
				INNER JOIN _board_forums f ON f.forum_id = t.topic_forum
				LEFT JOIN _board_highlight h ON t.topic_highlight = h.highlight_id
				RIGHT JOIN _board_disallow d ON t.topic_id = d.disallow_topic AND d.disallow_bio = ?
				WHERE t.topic_show = ?
				ORDER BY t.topic_shine DESC, t.topic_time DESC
				LIMIT ??';
            $topics = _rowset(sql_filter($sql, $bio->v('bio_id'), 1, 10));
        } else {
            $sql = 'SELECT t.topic_id, t.topic_alias, t.topic_title, h.highlight_class
				FROM _board_topics t
				INNER JOIN _board_forums f ON f.forum_id = t.topic_forum
				LEFT JOIN _board_highlight h ON t.topic_highlight = h.highlight_id
				WHERE t.topic_show = ?
				ORDER BY t.topic_shine DESC, t.topic_time DESC
				LIMIT ??';
            $topics = _rowset(sql_filter($sql, 1, 10));
        }
        foreach ($topics as $i => $row) {
            if (!$i) {
                _style('board_topics');
            }
            _style('board_topics.row', _vs(array('ID' => $row['topic_id'], 'TITLE' => $row['topic_title'], 'CLASS' => $row['highlight_class']), 'TOPIC'));
        }
        if ($bio->v('auth_member')) {
            // Messages
            $sql = 'SELECT *
				FROM _bio_messages
				INNER JOIN _bio ON message_from = bio_id
				INNER JOIN _bio_messages_type ON message_type = type_id
				WHERE message_to = ?
					AND message_active = ?
				ORDER BY message_time DESC';
            $messages = _rowset(sql_filter($sql, $bio->v('bio_id'), 1));
            foreach ($messages as $i => $row) {
                if (!$i) {
                    _style('messages');
                }
                _style('messages.row', array('U_MESSAGE' => _link(), '' => ''));
            }
            // Friend requests
            $sql = 'SELECT b.bio_alias, b.bio_name
				FROM _bio_friends
				INNER JOIN _bio ON friend_assoc = bio_id
				WHERE friend_bio = ?
					AND friend_pending = ?
				ORDER BY friend_time DESC';
            $requests = _rowset(sql_filter($sql, $bio->v('bio_id'), 1));
            foreach ($requests as $i => $row) {
                if (!$i) {
                    _style('friend_request');
                }
                _style('friend_request.row', array('U_APPROVE' => _link('home', array('x1' => 'friend', 'x2' => 'approve', 'a' => $row['bio_alias'])), 'U_DENY' => _link('home', array('x1' => 'friend', 'x2' => 'deny', 'a' => $row['bio_alias'])), 'A' => _a($row), 'BIO_NAME' => $row['bio_name']));
            }
        }
        // Banners
        $this->announce('home');
        return;
    }
Example #3
0
    protected function _corp_home()
    {
        $sql = 'SELECT *
			FROM _groups
			WHERE group_special = ?
			ORDER BY group_order';
        $groups = sql_rowset(sql_filter($sql, 1));
        $sql = 'SELECT g.group_id, b.bio_alias, b.bio_name, b.bio_firstname, b.bio_lastname, b.bio_life, b.bio_avatar, b.bio_avatar_up
			FROM _groups g, _group_joint j, _bio b
			WHERE g.group_id = j.joint_group
				AND j.joint_bio = b.bio_id
			ORDER BY j.joint_order, b.bio_alias';
        $members = sql_rowset($sql, 'group_id', false, true);
        $i = 0;
        foreach ($groups as $row) {
            if (!isset($members[$row->group_id])) {
                continue;
            }
            if (!$i) {
                _style('groups');
            }
            _style('groups.list', array('GROUP_NAME' => $row->group_name));
            foreach ($members[$row->group_id] as $row2) {
                _style('groups.list.member', _vs(array('LINK' => _link_bio($row2->bio_alias), 'NAME' => $row2->bio_name, 'REALNAME' => _fullname($row2), 'BIO' => _message($row2->bio_life), 'AVATAR' => _avatar($row2))), 'USER');
            }
            $i++;
        }
        if ($corp = $this->page_query('corp')) {
            v_style(array('CORP_CONTENT' => _message($corp->page_content)));
        }
        return;
    }