Exemplo n.º 1
0
    public function home()
    {
        global $core, $bio;
        $v = $this->__(array_merge(w('a r'), _array_keys(w('s'), 0)));
        if (!empty($v->a)) {
        }
        if (!empty($v->r)) {
            $sql = 'SELECT *
				FROM _objects o, _objects_type t, _bio b, _objects_rel_assoc ra, _objects_rel_type rt
				WHERE t.type_alias = ?
					AND rt.type_alias = ?
					AND o.object_bio = b.bio_id
					AND ra.assoc_object = o.object_id
					AND ra.assoc_rel_type = rt.type_id
				ORDER BY o.object_time
				LIMIT ??, ??';
            $news = sql_rowset(sql_filter($sql, 'news', $v->r, $v->s, $core->v('objects_per_page')));
            $sql = 'SELECT COUNT(object_id) AS total
				FROM _objects o, _objects_type t, _objects_rel_assoc ra, _objects_rel_type rt
				WHERE t.type_alias = ?
					AND rt.type_alias = ?
					AND ra.assoc_object = o.object_id
					AND ra.assoc_rel_type = rt.type_id';
            $news_total = sql_field(sql_filter($sql, 'news', $v->r), 'total', 0);
        } else {
            $sql = 'SELECT *
				FROM _objects o, _objects_type t, _bio b
				WHERE t.type_alias = ?
					AND o.object_type = t.type_id
					AND o.object_bio = b.bio_id
				ORDER BY o.object_time
				LIMIT ??, ??';
            $news = sql_rowset(sql_filter($sql, 'news', $v->s, $core->v('objects_per_page')));
            $sql = 'SELECT COUNT(object_id) AS total
				FROM _objects o, _objects_type t
				WHERE t.type_alias = ?
					AND o.object_type = t.type_id';
            $news_total = sql_field(sql_filter($sql, 'news'), 'total', 0);
        }
        foreach ($news as $i => $row) {
            if (!$i) {
                _style('news', _pagination(_link('news'), 's:%d', $news_total + 1, $core->v('objects_per_page'), $v->s));
            }
            $_row = array('ID' => $row->object_id, 'BIO' => $row->object_bio, 'SUBJECT' => $row->object_subject, 'CONTENT' => _message($row->object_content), 'TIME' => $bio->format_date($row->object_time));
            _style('news.row', array_merge($_row, $this->_profile($row)));
        }
        $sql = 'SELECT *
			FROM _objects_rel_type
			ORDER BY type_alias';
        $rel_type = sql_rowset($sql);
        foreach ($rel_type as $i => $row) {
            if (!$i) {
                _style('rel_type', array('NEWS_URL' => _link('news')));
            }
            $row->type_alias = _link('news', array('r' => $row->type_alias));
            _style('rel_type.row', $row);
        }
        return;
    }
Exemplo n.º 2
0
    public function home()
    {
        global $user;
        $v = $this->__(array('ssid', 'code', 'view', 'e', 'f', 'a' => 0, 'offset' => 0));
        $total = 0;
        $per_page = 15;
        $sql = $sql_total = $sql_where = '';
        if ($v['view'] == 'search') {
            if (!f($v['ssid'])) {
                _fatal();
            }
            $cached = sql_cache('', $v['ssid']);
            $sql_total = $cached['query'];
            $sql = $sql_total . ' LIMIT {v_limit_start}, {v_limit_end}';
            $v['a_view'] = array('mode_alias' => 'search', 'mode_name' => 'Buscar', 'mode_sql' => $sql, 'mode_sql_total' => $sql_total);
        } else {
            $modes = $this->init_mode();
            $v['view'] = isset($modes[$v['view']]) ? $v['view'] : 'all';
            $v['a_view'] = $modes[$v['view']];
            if ($v['a_view']['mode_alias'] == 'all' && $user->v('user_type') != U_FOUNDER) {
                $sql = 'SELECT *
					FROM _groups_members
					WHERE member_uid = ?';
                if (!($row = _fieldrow(sql_filter($sql, $user->v('user_id'))))) {
                    redirect(_link($this->m(), array('view' => 'own')));
                }
            }
        }
        $filter_uid = $user->v('user_id');
        if (f($v['f'])) {
            $sql = 'SELECT user_id
				FROM _members
				WHERE user_username = ?';
            $filter_uid = _field(sql_filter($sql, $v['f']), 'user_id', $filter_uid);
        }
        $status_alias = $this->init_status_list('status_alias', 'status_id');
        if ($v['e'] == 'table') {
            $v['a_view']['mode_sql'] = str_replace('LIMIT {v_limit_start}, {v_limit_end}', '', $v['a_view']['mode_sql']);
        }
        $v_sql = array('userid' => $filter_uid, 'group' => $user->auth_groups(), 'limit_start' => $v['offset'], 'limit_end' => $per_page, 'closed' => $status_alias['closed']);
        $tickets_sql = _template_query($v['a_view']['mode_sql'], $v_sql);
        $tickets_sql_total = _template_query($v['a_view']['mode_sql_total'], $v_sql);
        if (!f($tickets_sql) || !f($tickets_sql_total)) {
            _fatal();
        }
        if ($row = _fieldrow($tickets_sql_total)) {
            $total = isset($row['total']) ? $row['total'] : _numrows($row);
        }
        if ($tickets = _rowset($tickets_sql)) {
            $groups = $user->_groups();
            $status_list = $this->init_status_list();
            if ($v['e'] == 'table') {
                $sql_tickets = preg_replace('#^SELECT (.*?)[\\n]#is', 'SELECT ticket_id' . "\n", $tickets_sql);
                //
                // Assignees
                $sql = 'SELECT a.assign_ticket, m.user_firstname, m.user_lastname
					FROM _tickets_assign a, _members m
					WHERE a.assign_ticket IN (' . $sql_tickets . ')
						AND a.user_id = m.user_id
					ORDER BY a.assign_ticket';
                $tech_assoc = _rowset($sql, 'assign_ticket', false, true);
                //_pre($tech_assoc, true);
                //
                // Notes
                $sql = 'SELECT m.user_id, m.user_firstname, m.user_lastname, n.ticket_id, n.note_text, n.note_time, n.note_cc
					FROM _members m, _tickets_notes n
					WHERE n.ticket_id IN (' . $sql_tickets . ')
						AND n.user_id = m.user_id
					ORDER BY n.ticket_id, n.note_time';
                $notes_assoc = _rowset($sql, 'ticket_id', false, true);
                @set_time_limit(0);
                //
                // Include the PHPExcel classes
                require_once XFS . 'core/excel/PHPExcel.php';
                require_once XFS . 'core/excel/PHPExcel/Writer/Excel5.php';
                require_once XFS . 'core/css.php';
                $phpcss = new phpcss();
                $phpcss->parse('./style/css/default.css');
                // Start to build the spreadsheet
                $excel = new PHPExcel();
                $excel->setActiveSheetIndex(0);
                $excel->getActiveSheet()->getHeaderFooter()->setOddFooter("&RPage &P of &N");
                //
                $excel->getActiveSheet()->setCellValue('A1', 'Titulo');
                $excel->getActiveSheet()->setCellValue('B1', 'Asignado');
                $excel->getActiveSheet()->setCellValue('C1', 'Categoria');
                $excel->getActiveSheet()->setCellValue('D1', 'Solicitante');
                $excel->getActiveSheet()->setCellValue('E1', 'Fecha/hora');
                $excel->getActiveSheet()->setCellValue('F1', 'Texto');
                $excel->getActiveSheet()->setCellValue('G1', 'Estado');
                $excel->getActiveSheet()->getStyle("A1:G1")->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
                $excel->getActiveSheet()->getStyle("A1:G1")->getFont()->setBold(true);
                $excel->getActiveSheet()->getStyle("A1:G1")->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID)->getStartColor()->setRGB('EBEBC6');
                $excel->getActiveSheet()->getColumnDimension('A')->setWidth(20);
                $excel->getActiveSheet()->getColumnDimension('B')->setWidth(15);
                $excel->getActiveSheet()->getColumnDimension('C')->setWidth(10);
                $excel->getActiveSheet()->getColumnDimension('D')->setWidth(15);
                $excel->getActiveSheet()->getColumnDimension('E')->setWidth(15);
                $excel->getActiveSheet()->getColumnDimension('F')->setWidth(30);
                $excel->getActiveSheet()->getColumnDimension('G')->setWidth(10);
                $i = 2;
                foreach ($tickets as $row) {
                    $row_color = $phpcss->property_get('.ticket_status_' . $status_list[$row['ticket_status']]['status_alias'], 'background');
                    $row_color = preg_replace('#^\\#([A-Za-z0-9]+).*?$#is', '\\1', $row_color);
                    if (!isset($row['cat_name'])) {
                        $row['cat_name'] = '';
                    }
                    $assignees = '';
                    if (isset($tech_assoc[$row['ticket_id']])) {
                        foreach ($tech_assoc[$row['ticket_id']] as $rowtech) {
                            $assignees .= (f($assignees) ? ', ' : '') . _fullname($rowtech);
                        }
                    }
                    $excel->getActiveSheet()->setCellValue("A{$i}", entity_decode($row['ticket_title']));
                    $excel->getActiveSheet()->setCellValue("B{$i}", entity_decode($assignees));
                    $excel->getActiveSheet()->setCellValue("C{$i}", entity_decode($row['cat_name']));
                    $excel->getActiveSheet()->setCellValue("D{$i}", entity_decode(_fullname($row)));
                    $excel->getActiveSheet()->setCellValue("E{$i}", entity_decode(_format_date($row['ticket_start'])));
                    $excel->getActiveSheet()->setCellValue("F{$i}", entity_decode($row['ticket_text']));
                    $excel->getActiveSheet()->setCellValue("G{$i}", entity_decode($status_list[$row['ticket_status']]['status_name']));
                    $excel->getActiveSheet()->getStyle("A{$i}:G{$i}")->getAlignment()->setWrapText(true)->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
                    $excel->getActiveSheet()->getStyle("A{$i}:G{$i}")->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID)->getStartColor()->setRGB($row_color);
                    $i++;
                    if (isset($notes_assoc[$row['ticket_id']])) {
                        foreach ($notes_assoc[$row['ticket_id']] as $rownote) {
                            $excel->getActiveSheet()->setCellValue("B{$i}", entity_decode(_fullname($rownote)));
                            $excel->getActiveSheet()->setCellValue("E{$i}", entity_decode(_format_date($rownote['note_time'])));
                            $excel->getActiveSheet()->setCellValue("F{$i}", entity_decode($rownote['note_text']));
                            $excel->getActiveSheet()->mergeCells("F{$i}:G{$i}");
                            $excel->getActiveSheet()->getStyle("A{$i}:G{$i}")->getAlignment()->setWrapText(true)->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
                            $i++;
                        }
                    }
                }
                $excel->getActiveSheet()->freezePane('A2');
                //
                // Output the headers
                header('Content-Type: application/vnd.ms-excel;');
                header('Content-type: application/x-msexcel');
                header('Content-Disposition: attachment; filename="solicitudes-' . date('Y-m-d') . '.xls"');
                header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
                header('Last-Modified: ' . gmdate('D,d M YH:i:s') . ' GMT');
                header('Cache-Control: no-cache, must-revalidate');
                header('Pragma: no-cache');
                // Output the spreadsheet in binary format
                $writer = new PHPExcel_Writer_Excel5($excel);
                $writer->save('php://output');
                exit;
            }
            $u_link = array('view' => $v['view'], 'f' => $v['f']);
            if ($v['view'] == 'search') {
                $u_link['ssid'] = $v['ssid'];
            }
            $sv = array('TITLE' => $v['a_view']['mode_name'], 'SIZE' => $total, 'CURRENT' => $v['offset'], 'U_ETABLE' => _link($this->m(), array_merge($u_link, array('e' => 'table'))), 'G_ETABLE' => _lang('TICKET_ETABLE_YES'), 'U_TICKET' => _link($this->m(), array('x1' => 'view', 'a' => '*', 'offset' => $v['offset'])), 'U_STATUS' => _link($this->m(), array('x1' => 'search', 'x2' => 'status', 'e' => $v['e'])));
            foreach ($tickets as $i => $row) {
                if (!$i) {
                    $pags = _pagination(_link($this->m(), $u_link), 'offset:%d', $total, $per_page, $v['offset']);
                    _style('tickets', array_merge($sv, $pags));
                }
                if (!isset($row['ticket_group']) || !$row['ticket_group']) {
                    $row['ticket_group'] = 1;
                }
                $ticket_row = array('ID' => $row['ticket_id'], 'URL' => _link($this->m(), array('x1' => 'view', 'a' => $row['ticket_id'], 'offset' => $v['offset'])), 'STATUS' => $this->init_status($row['ticket_status']), 'STATUS_NAME' => $status_list[$row['ticket_status']]['status_name'], 'TITLE' => dvar($row['ticket_title'], _lang('TICKET_NO_SUBJECT')), 'TEXT' => _message($row['ticket_text']), 'START' => _format_date($row['ticket_start']), 'AUTHOR' => _fullname($row), 'GROUP' => $user->v('is_founder') ? $groups[$row['ticket_group']]['group_email'] : '');
                _style('tickets.row', _vs($ticket_row, 'v'));
                if (isset($tech_assoc[$row['ticket_id']])) {
                    foreach ($tech_assoc[$row['ticket_id']] as $ti => $tech_name) {
                        if (!$ti) {
                            _style('tickets.row.techs');
                        }
                        _style('tickets.row.techs.rowt', array('NAME' => _fullname($tech_name)));
                    }
                }
                if (isset($notes_assoc[$row['ticket_id']])) {
                    foreach ($notes_assoc[$row['ticket_id']] as $ti => $note_row) {
                        if (!$ti) {
                            _style('tickets.row.notes');
                        }
                        _style('tickets.row.notes.rown', array('TEXT' => $note_row['note_text'], 'TIME' => _format_date($note_row['note_time']), 'REALNAME' => _fullname($note_row)));
                    }
                }
            }
        } else {
            if ($v['offset']) {
                redirect(_link($this->m(), array('view' => $v['view'])));
            }
            _style('noresults');
        }
        v_style(array('V_CHOWN' => f($v['f']) ? $v['f'] : ''));
        return $this->__home_common($v['offset'], $v['view']);
    }
Exemplo n.º 3
0
    protected function _messages_home()
    {
        global $bio, $core;
        $v = $this->__(array('i' => 'home', 'u' => '', 'a' => array(0 => ''), 's' => 0));
        if (!in_array($v['i'], $this->messages_a)) {
            _fatal();
        }
        switch ($v['i']) {
            case 'write':
                if (!$bio->v('bio_active')) {
                    $this->_error('PLEASE_CONFIRM_ACCOUNT');
                }
                if (f($v['u']) && $v['u'] != $bio->v('bio_alias')) {
                    $v['a'][] = $v['u'];
                }
                unset($v['u']);
                if (_button()) {
                    $v = array_merge($v, $this->__(array('subject', 'message', 'parent' => 0)));
                    if ($v['parent']) {
                        $sql = 'SELECT *
							FROM _bio_talk
							WHERE talk_id = ?';
                        if (!($talk = _fieldrow(sql_filter($sql, $v['parent'])))) {
                            _fatal();
                        }
                        $sql = 'SELECT *
							FROM _bio_talkers
							WHERE talker_talk = ?
								AND talker_bio = ?';
                        if (!($talkers = _rowset(sql_filter($sql, $v['parent'], $bio->v('bio_id'))))) {
                            _fatal();
                        }
                    } else {
                        if (!f($v['subject'])) {
                            $this->_error('#TALK_NO_SUBJECT');
                        }
                        $sql = 'SELECT bio_alias, bio_name, bio_email
							FROM bio
							WHERE bio_id IN (??)
							ORDER BY bio_alias';
                        if (!($talkers = _rowset(sql_filter($sql, _implode(',', $v['a']))))) {
                            $this->_error('#TALK_NO_TALKERS');
                        }
                    }
                    if (!f($v['message'])) {
                        $this->_error('#NO_MESSAGE');
                    }
                    $sql_insert = array('parent' => $v['parent'], 'subject' => _prepare($v['subject']), 'message' => _prepare($v['message']), 'time' => time());
                    $v->talk_id = sql_put('_bio_talk', $sql_insert);
                    foreach ($talkers as $row) {
                        $sql_insert = array('talk' => $v['parent'] ? $v['parent'] : $v->talk_id, 'bio' => $row['bio_id']);
                        sql_put('_bio_talkers', $sql_insert);
                        $properties = array('from' => 'info', 'to' => $row['bio_email'], 'subject' => '', 'body' => '', 'template' => '');
                        _sendmail($properties);
                    }
                    if (is_ghost() && $v['parent']) {
                        $response = array('message_id' => $message_id, 'message_content' => $v['message'], 'message_time' => _format_date());
                        return $this->e(json_encode($response));
                    }
                    redirect('my', array('messages', 'm' => $message_id));
                }
                break;
            default:
                $v = array_merge($v, $this->__(array('m' => 0)));
                if ($v['m']) {
                    $sql = 'SELECT *
						FROM _bio_talk t, _bio_talkers r
						WHERE t.talk_id = ?
							AND r.talker_bio = ?
							AND t.talk_id = r.talker_talk';
                    if (!($talk = _fieldrow(sql_filter($sql, $v['m'], $bio->v('bio_id'))))) {
                        _fatal();
                    }
                    $sql = 'SELECT t.*, b.bio_id, b.bio_alias, b.bio_name
						FROM _bio_talk t, _bio_talkers r, _bio b
						WHERE t.talk_parent = ?
							AND t.talk_id = r.talker_talk
							AND t.talk_author = r.talker_bio
							AND r.talker_bio = b.bio_id
						ORDER BY t.talk_time';
                    $messages = _rowset(sql_filter($sql, $talk['talk_parent']));
                    foreach ($messages as $i => $row) {
                        if (!$i) {
                            _style('messages');
                        }
                        _style('messages.row');
                    }
                    return;
                }
                //
                // Message lists
                $is_draft = 0;
                switch ($v['i']) {
                    case 'sent':
                        $sql_total = 'SELECT COUNT(talk_id) AS total
							FROM _bio_talk
							WHERE talk_author = ?
								AND talk_draft = ?
								AND talk_id = talk_parent';
                        $sql_list = 'SELECT *
							FROM _bio_talk
							WHERE talk_author = ?
								AND talk_draft = ?
								AND talk_id = t.talk_parent
							ORDER BY talk_lasttime DESC
							LIMIT ??, ??';
                        break;
                    case 'draft':
                        $sql_total = 'SELECT COUNT(talk_id) AS total
							FROM _bio_talk
							WHERE talk_author = ?
								AND talk_draft = ?
								AND talk_id = talk_parent';
                        $sql_list = 'SELECT *
							FROM _bio_talk
							WHERE talk_author = ?
								AND talk_draft = ?
								AND talk_id = talk_parent
							ORDER BY talk_lasttime DESC
							LIMIT ??, ??';
                        $is_draft = 1;
                        break;
                    default:
                        $sql_total = 'SELECT COUNT(talk_id) AS total
							FROM _bio_talk t, _bio_talkers r
							WHERE r.talker_bio = ?
								AND t.talk_draft = ?
								AND t.talk_id = t.talk_parent
								AND t.talk_id = r.talker_talk';
                        $sql_list = 'SELECT *
							FROM _bio_talk t, _bio_talkers r
							WHERE r.talker_bio = ?
								AND t.talk_draft = ?
								AND t.talk_id = t.talk_parent
								AND t.talk_id = r.talker_talk
							ORDER BY t.talk_lasttime DESC
							LIMIT ??, ??';
                        break;
                }
                $talk_total = _field(sql_filter($sql_total, $bio->v('bio_id'), $is_draft), 'total', 0);
                $talk_list = _rowset(sql_filter($sql_list, $bio->v('bio_id'), $is_draft, $v['s'], $core->v('talk_pager')));
                if ($talk_total && !count($talk_list)) {
                    redirect(_link($this->m(), array('messages', 'i' => $v['i'])));
                }
                foreach ($messages as $i => $row) {
                    if (!$i) {
                        _style('talks', _pagination(_link('my', array('messages', 'i' => $v['i'])), 's:%d', $messages_total, $core->v('talk_pager'), $v['s']));
                    }
                    if (!$row['message_last']) {
                        $row['message_last'] = $row['message_id'];
                        $row['message_last_time'] = $row['message_time'];
                    }
                    _style('talks.row', _vs(array('PARENT' => $row['talk_parent'], 'SUBJECT' => $row['talk_subject'], 'READ' => _link($this->m(), array('messages', 'i' => $v['i'], 'm' => $row['talk_last'])), 'TIME' => _format_date($row['talk_lasttime']), 'ROOT' => $row['talk_root']), 'TALK'));
                }
                break;
        }
        return;
    }
Exemplo n.º 4
0
 protected final function _replies($f)
 {
     global $bio;
     $rf_k = $rf_v = w();
     foreach ($f as $k => $v) {
         $rf_k[] = '{' . strtoupper($k) . '}';
     }
     $rf_v = array_values($f);
     $f['sql'] = str_replace($rf_k, $rf_v, $f['sql']);
     if (!($rows = _rowset($f['sql']))) {
         return;
     }
     // TODO: Control Panel. Modify & remove comments
     $bio = w();
     foreach ($rows as $i => $row) {
         if (!$i) {
             _style($f['block'], _vs(_pagination($f['ref'], $f['start_f'] . ':%d', $f['rows'], $f['rows_page'], $f['start'])));
         }
         $uid = $row['bio_id'];
         $row['is_member'] = $uid != 1 ? 1 : 0;
         if (!isset($bio[$uid]) || !$row['is_member']) {
             $bio[$uid] = $this->_profile($row);
         }
         $s_row = array('V_MEMBER' => $row['is_member'], 'V_TIME' => _format_date($row['post_time']), 'V_MESSAGE' => _message($row['post_text']));
         _style($f['block'] . '.row', array_merge($s_row, _vs($bio[$uid], 'v')));
     }
     return;
 }
Exemplo n.º 5
0
    protected function _topic_home()
    {
        global $bio;
        $v = $this->__(_array_keys(w('t p s'), 0));
        if (!$v->t && !$v->p) {
            $warning->now();
        }
        $sql_from = $sql_where = $sql_count = $sql_order = '';
        if ($v['p']) {
            $sql_count = ', COUNT(p2.post_id) AS prev_posts, p.post_deleted';
            $sql_from = ', _board_posts p, _board_posts p2, _bio b ';
            $sql_where = sql_filter('p.post_id = ? AND p.poster_id = b.bio_id AND t.topic_id = p.topic_id AND p2.topic_id = p.topic_id AND p2.post_id <= ?', $v->p, $v->p);
            $sql_order = ' GROUP BY p.post_id, t.topic_id, t.topic_title, t.topic_locked, t.topic_replies, t.topic_time, t.topic_important, t.topic_vote, t.topic_last_post_id, f.forum_name, f.forum_locked, f.forum_id, f.auth_view, f.auth_read, f.auth_post, f.auth_reply, f.auth_announce, f.auth_pollcreate, f.auth_vote ORDER BY p.post_id ASC';
        } else {
            $sql_where = sql_filter('t.topic_id = ?', $v->t);
        }
        $sql = 'SELECT t.*, f.*' . $sql_count . '
			FROM _board_topics t, _board_forums f' . $sql_from . '
			WHERE ' . $sql_where . ' AND f.forum_id = t.forum_id' . $sql_order;
        if (!($topic_data = sql_fieldrow($sql))) {
            _fatal();
        }
        $v->f = $topic_data->forum_id;
        $v->t = $topic_data->topic_id;
        //
        if ($v->p) {
            $v->s = floor(($topic_data->prev_posts - 1) / (int) $core->v('posts_per_page')) * (int) $core->v('posts_per_page');
        }
        //
        // Update the topic views
        /*
        if (!$v->offset && !$bio->v('auth_founder') && $bio->v('auth_member') && ($topic_data['topic_poster'] != $bio->v('bio_id')))
        {
        	$sql = 'UPDATE _forum_topics SET topic_views = topic_views + 1
        		WHERE topic_id = ?';
        	_sql(sql_filter($sql, $v->t));
        }
        */
        //
        // Get topic data
        $sql = 'SELECT p.*, b.bio_id, b.bio_alias, b.bio_name, b.bio_color, b.bio_avatar, b.bio_avatar_up, b.bio_sig
			FROM _board_posts p, _bio b
			WHERE p.post_topic = ?
				AND p.post_bio = b.bio_id
			ORDER BY p.post_time ASC
			LIMIT ??, ??';
        if (!($posts = sql_rowset(sql_filter($sql, $v->t, $v->offset, $core->v('posts_per_page'))))) {
            _fatal();
        }
        $allow_posts = !$topic_data->forum_locked;
        if ($allow_posts) {
            _style('publish');
        }
        foreach ($posts as $i => $row) {
            if (!$i) {
                _style('posts', _pagination(_link('board', array('topic', $v->t, 's%d')), $topic_data->topic_replies + 1, $core->v('posts_per_page'), $start));
            }
            $_row = array('ID' => $row->post_id, 'BIO' => $row->post_bio, 'TIME' => _format_date($row->post_time), 'CONTENT' => _message($row->post_content), 'PLAYING' => $row->post_playing);
            _style('posts.row', array_merge($_row, $this->_profile($row)));
            if ($allow_posts) {
                _style('posts.row.publish');
            }
        }
        $this->monetize();
        // TODO: Include social networks buttons
        $this->set_nav($v->f, $topic_data->forum_name, 'forum');
        $this->set_nav($v->t, $topic_data->topic_title, 'topic');
        //
        $_v = $v->p ? 'p' : 'f';
        $_w = $v->p ? 'p' : 't';
        v_style(array('U_PUBLISH' => _link('board publish'), 'H_PUBLISH' => _hidden(array($_v => $v[$_w]))));
        return;
    }
Exemplo n.º 6
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;
    }
Exemplo n.º 7
0
<!-- pagination -->
<div class="pagination">
	<?php 
_pagination();
?>
</div>
<!-- /pagination -->
Exemplo n.º 8
0
function pagination_go($r = array())
{
    global $MSO;
    $r_orig = $r;
    if (!$r) {
        return $r;
    }
    if (!isset($r['maxcount'])) {
        return $r;
    }
    if (!isset($r['limit'])) {
        return $r;
    }
    // нужно указать сколько записей выводить
    if (!isset($r['type'])) {
        $r['type'] = false;
    }
    // можно задать свой тип
    if (!isset($r['next_url'])) {
        $r['next_url'] = 'next';
    }
    $options = mso_get_option('plugin_pagination', 'plugins', array());
    // получаем опции
    if (!isset($r['range'])) {
        $r['range'] = isset($options['range']) ? (int) $options['range'] : 3;
    }
    if (!isset($r['sep'])) {
        $r['sep'] = isset($options['sep']) ? $options['sep'] : ' &middot; ';
    }
    if (!isset($r['sep2'])) {
        $r['sep2'] = isset($options['sep2']) ? $options['sep2'] : ' | ';
    }
    if (!isset($r['format'])) {
        // $r['format'] =
        $r['format'][] = isset($options['format_first']) ? $options['format_first'] : '« ' . tf('Первая');
        $r['format'][] = isset($options['format_prev']) ? $options['format_prev'] : '‹ ' . tf('предыдущая');
        $r['format'][] = isset($options['format_next']) ? $options['format_next'] : tf('следующая') . ' ›';
        $r['format'][] = isset($options['format_last']) ? $options['format_last'] : tf('последняя') . ' »';
    }
    # текущая пагинация вычисляется по адресу url
    # должно быть /next/6 - номер страницы
    $current_paged = mso_current_paged($r['next_url']);
    if ($current_paged > $r['maxcount']) {
        $current_paged = $r['maxcount'];
    }
    if ($r['type'] !== false) {
        $type = $r['type'];
    } else {
        $type = $MSO->data['type'];
    }
    // текущий урл сделаем
    $a_cur_url = $MSO->data['uri_segment'];
    // $cur_url = getinfo('site_url') . $type;
    if ($type != 'page_404') {
        $cur_url = getinfo('site_url') . $type;
    } else {
        $cur_url = getinfo('site_url');
    }
    // pr($cur_url);
    foreach ($a_cur_url as $val) {
        #if ($val == 'next') break; // next - дальше не нужно
        if ($val == $r['next_url']) {
            break;
        } else {
            if ($val != $type) {
                $cur_url .= '/@@' . $val;
            }
        }
    }
    $cur_url = str_replace('//@@', '/', $cur_url);
    $cur_url = str_replace('@@', '', $cur_url);
    // pr($cur_url);
    if ($type == 'home') {
        $home_url = getinfo('site_url');
    } else {
        $home_url = $cur_url;
    }
    //pr($home_url);
    $out = _pagination($r['maxcount'], $current_paged, $cur_url . '/' . $r['next_url'] . '/', $r['range'], $cur_url, '', $r['sep'], $home_url, $r['sep2']);
    if ($out) {
        $out = str_replace(array('%FIRST%', '%PREV%', '%NEXT%', '%LAST%'), $r['format'], $out);
        echo NR . '<div class="pagination">' . $out . '</div>' . NR;
    }
    return $r_orig;
}
Exemplo n.º 9
0
function pagination_go($r = array())
{
    global $MSO;
    $r_orig = $r;
    if (!$r) {
        return $r;
    }
    if (!isset($r['maxcount'])) {
        return $r;
    }
    if (!isset($r['limit'])) {
        return $r;
    }
    // нужно указать сколько записей выводить
    if (!isset($r['type'])) {
        $r['type'] = false;
    }
    // можно задать свой тип
    if (!isset($r['next_url'])) {
        $r['next_url'] = 'next';
    }
    $options = mso_get_option('plugin_pagination', 'plugins', array());
    // получаем опции
    if (!isset($r['range'])) {
        $r['range'] = isset($options['range']) ? (int) $options['range'] : 3;
    }
    if (!isset($r['sep'])) {
        $r['sep'] = isset($options['sep']) ? $options['sep'] : ' ';
    }
    if (!isset($r['sep2'])) {
        $r['sep2'] = isset($options['sep2']) ? $options['sep2'] : ' ';
    }
    if (!isset($r['format'])) {
        // $r['format'] =
        $r['format'][] = isset($options['format_first']) ? $options['format_first'] : '&lt;&lt;';
        $r['format'][] = isset($options['format_prev']) ? $options['format_prev'] : '&lt;';
        $r['format'][] = isset($options['format_next']) ? $options['format_next'] : '&gt;';
        $r['format'][] = isset($options['format_last']) ? $options['format_last'] : '&gt;&gt;';
    }
    # текущая пагинация вычисляется по адресу url
    # должно быть /next/6 - номер страницы
    $current_paged = mso_current_paged($r['next_url']);
    if ($current_paged > $r['maxcount']) {
        $current_paged = $r['maxcount'];
    }
    if ($r['type'] !== false) {
        $type = $r['type'];
    } else {
        $type = $MSO->data['type'];
    }
    // текущий адрес
    $cur_url = mso_current_url(true);
    // в текущем адресе нужно исключить пагинацию next
    if (preg_match("!/" . $r['next_url'] . "/!is", $cur_url, $matches, PREG_OFFSET_CAPTURE)) {
        $cur_url = substr($cur_url, 0, $matches[0][1]);
    }
    if ($type == 'home' and $current_paged == 1) {
        $cur_url = $cur_url . 'home';
    }
    // pr($cur_url);
    if ($type == 'home') {
        $home_url = getinfo('site_url');
    } else {
        $home_url = $cur_url;
    }
    $out = _pagination($r['maxcount'], $current_paged, $cur_url . '/' . $r['next_url'] . '/', $r['range'], $cur_url, '', $r['sep'], $home_url, $r['sep2']);
    if ($out) {
        $out = str_replace(array('%FIRST%', '%PREV%', '%NEXT%', '%LAST%'), $r['format'], $out);
        echo '<div class="pagination"><nav>' . $out . '</nav></div>';
    }
    return $r_orig;
}
Exemplo n.º 10
0
    protected function _search_home()
    {
        global $user;
        $v = $this->__(array('m', 'q', 'g' => 0, 'start' => 0));
        $v_results = 0;
        if (f($v['m']) || $v['g']) {
            if ($v['g']) {
                $sql = 'SELECT m.*
					FROM _members m
					LEFT JOIN _members_dept g ON g.this_id = m.user_dept
					WHERE m.user_dept = ?';
                $sql = sql_filter($sql, $v['g']);
            } else {
                $sql = 'SELECT *
					FROM _members
					WHERE user_username = ?';
                $sql = sql_filter($sql, $v['m']);
            }
            redirect(_link($this->m(), array('x1' => 'search', 'q' => array_key(sql_cache($sql), 'sid'))));
        }
        $button = _button();
        if ($button || f($v['q'])) {
            if (!f($v['q'])) {
                $build_search = $this->advanced_search($this->m());
                $build = 'SELECT mb.user_id, mb.user_active, mb.user_firstname, mb.user_lastname
					FROM ' . _implode(', ', $build_search['from']) . '
					WHERE ' . _implode(' ', $build_search['where']) . '
					GROUP BY mb.user_id
					ORDER BY mb.user_firstname, mb.user_lastname';
                redirect(_link($this->m(), array('x1' => 'search', 'q' => array_key(sql_cache($build), 'sid'))));
            }
            $button = true;
            $v_sql = array('limit_start' => $v['start'], 'limit_end' => 20);
            $cached = sql_cache('', $v['q']);
            if (strstr($cached['query'], 'SELECT a_assoc') !== false) {
                $cached['query'] = 'SELECT mb.user_id, mb.user_active, mb.user_firstname, mb.user_lastname
					FROM _members
					WHERE user_id IN (' . _implode(',', _rowset($cached['query'], false, 'user_id')) . ')
					ORDER BY user_firstname, user_lastname';
            }
            $build = _template_query($cached['query'], $v_sql);
            $build_limit = _template_query($cached['query'] . ' LIMIT {v_limit_start}, {v_limit_end}', $v_sql);
            if ($results = _rowset($build_limit, 'user_id', false, false, true)) {
                $tabs = $this->init_tabs();
                $v_results = array_key(_fieldrow($build), '_numrows');
                _style('search', _vs(_pagination(_link($this->m(), array('x1' => 'search', 'q' => $v['q'])), 'start:%d', $v_results, 20, $v['start'])));
                $user->auth_replace('contacts_tab_general', 'contacts_search');
                foreach ($results as $row) {
                    _style('search.row', _vs(array('ID' => $row['user_id'], 'TITLE' => _fullname($row), 'STATUS' => $row['user_active'] ? 'closed' : 'open'), 'V'));
                    foreach ($tabs as $k => $k2) {
                        // TODO: User pending tabs
                        switch ($k) {
                            case 'components':
                            case 'attributes':
                            case 'report':
                            case 'vacation':
                                continue 2;
                                break;
                        }
                        if (!_auth_get('contacts_tab_' . $k)) {
                            continue;
                        }
                        _style('search.row.tab', _vs(array('TAG' => $k, 'TITLE' => $k2['tab_name']), 'V'));
                    }
                }
            }
        }
        $this->advanced_search_form($this->m());
        return v_style(array('IS_SUBMIT' => $button, 'RESULTS_PAGE' => $v_results, 'U_SEARCH_TAB' => _link($this->m(), array('x1' => 'tab', 'uid' => '*', 'tag' => '?'))));
    }