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; }
function _help_edit() { global $bio, $core; $error = array(); $sub = $this->control->get_var('sub', ''); $id = $this->control->get_var('id', 0); $submit = isset($_POST['submit']) ? true : false; switch ($sub) { case 'cat': $sql = 'SELECT c.*, m.* FROM _help_cat c, _help_modules m WHERE c.help_id = ' . (int) $id . ' AND c.help_module = m.module_id'; $result = $db->sql_query($sql); if (!($cat_data = $db->sql_fetchrow($result))) { fatal_error(); } $db->sql_freeresult($result); $order = $this->control->get_var('order', ''); if (!empty($order)) { if (preg_match('/_([0-9]+)/', $order)) { $sig = '-'; $order = str_replace('_', '', $order); } else { $sig = '+'; } $sql = 'UPDATE _help_cat SET help_order = help_order ' . $sig . ' ' . (int) $order . ' WHERE help_id = ' . (int) $id; $db->sql_query($sql); $this->_help_edit_move(); $cache->unload('help_cat'); redirect(_link_control('comments', array('mode' => $this->mode))); } // IF order $module_id = $cat_data['help_module']; $help_es = $cat_data['help_es']; $help_en = $cat_data['help_en']; break; case 'faq': $sql = 'SELECT * FROM _help_faq WHERE faq_id = ' . (int) $id; $result = $db->sql_query($sql); if (!($faq_data = $db->sql_fetchrow($result))) { fatal_error(); } $db->sql_freeresult($result); $question_es = $faq_data['faq_question_es']; $question_en = $faq_data['faq_question_en']; $answer_es = $faq_data['faq_answer_es']; $answer_en = $faq_data['faq_answer_en']; $help_id = $faq_data['help_id']; break; default: redirect(_link_control('comments', array('mode' => $this->mode))); break; } // IF submit if ($submit) { switch ($sub) { case 'cat': $module_id = $this->control->get_var('module_id', 0); $help_es = $this->control->get_var('help_es', ''); $help_en = $this->control->get_var('help_en', ''); if (empty($help_es) || empty($help_en)) { $error[] = 'CONTROL_COMMENTS_HELP_EMPTY'; } // Update if (!sizeof($error)) { $sql_update = array('help_es' => $help_es, 'help_en' => $help_en, 'help_module' => (int) $module_id); $sql = 'UPDATE _help_cat SET ' . $db->sql_build_array('UPDATE', $sql_update) . ' WHERE help_id = ' . (int) $id; $db->sql_query($sql); $cache->unload('help_cat'); redirect(_link_control('comments', array('mode' => $this->mode))); } break; case 'faq': $question_es = $this->control->get_var('question_es', ''); $question_en = $this->control->get_var('question_en', ''); $answer_es = $this->control->get_var('answer_es', ''); $answer_en = $this->control->get_var('answer_en', ''); $help_id = $this->control->get_var('help_id', 0); if (empty($question_es) || empty($question_en) || empty($answer_es) || empty($answer_en)) { $error[] = 'CONTROL_COMMENTS_HELP_EMPTY'; } if (!sizeof($error)) { $sql = 'SELECT * FROM _help_cat WHERE help_id = ' . (int) $help_id; $result = $db->sql_query($sql); if (!($cat_data = $db->sql_fetchrow($result))) { $error[] = 'CONTROL_COMMENTS_HELP_NOCAT'; } } // Update if (!sizeof($error)) { $sql_update = array('help_id' => (int) $help_id, 'faq_question_es' => $question_es, 'faq_question_en' => $question_en, 'faq_answer_es' => $answer_es, 'faq_answer_en' => $answer_en); $sql = 'UPDATE _help_faq SET ' . $db->sql_build_array('UPDATE', $sql_update) . ' WHERE faq_id = ' . (int) $id; $db->sql_query($sql); $cache->unload('help_faq'); redirect(_link_control('comments', array('mode' => $this->mode))); } break; } // switch if (sizeof($error)) { _style('error', array('MESSAGE' => parse_error($error))); } } $this->nav(); $this->control->set_nav(array('mode' => $this->mode, 'manage' => $this->manage, 'sub' => $sub, 'id' => $id), 'CONTROL_EDIT'); $template_vars = array('SUB' => $sub, 'S_HIDDEN' => _hidden(array('module' => $this->control->module, 'mode' => $this->mode, 'manage' => $this->manage, 'sub' => $sub, 'id' => $id))); switch ($sub) { case 'cat': $sql = 'SELECT * FROM _help_modules ORDER BY module_id'; $result = $db->sql_query($sql); $select_mod = ''; while ($row = $db->sql_fetchrow($result)) { $selected = $row['module_id'] == $module_id; $select_mod .= '<option' . ($selected ? ' class="bold"' : '') . ' value="' . $row['module_id'] . '"' . ($selected ? ' selected' : '') . '>' . $row['module_name'] . '</option>'; } $db->sql_freeresult($result); $sv += array('MODULE' => $select_mod, 'HELP_ES' => $help_es, 'HELP_EN' => $help_en); break; case 'faq': $sql = 'SELECT * FROM _help_cat ORDER BY help_id'; $result = $db->sql_query($sql); $select_cat = ''; while ($row = $db->sql_fetchrow($result)) { $selected = $row['help_id'] == $help_id; $select_cat .= '<option' . ($selected ? ' class="bold"' : '') . ' value="' . $row['help_id'] . '"' . ($selected ? ' selected' : '') . '>' . $row['help_es'] . ' | ' . $row['help_en'] . '</option>'; } $db->sql_freeresult($result); $sv += array('CATEGORY' => $select_cat, 'QUESTION_ES' => $question_es, 'QUESTION_EN' => $question_en, 'ANSWER_ES' => $answer_es, 'ANSWER_EN' => $answer_en); break; } v_style($sv); return; }
protected function _biography_home() { global $bio; $v = $this->__(w('s')); $sql = 'SELECT bio_details FROM _bio WHERE bio_id = ?'; $details = sql_field(sql_filter($sql, $bio->v('bio_id'), 'bio_details', '')); $s_hidden = array('module' => $this->control->module, 'a' => $bio->v('bio_alias'), 'x1' => $this->x(1), 'manage' => 'edit'); v_style(array('MESSAGE' => $details, 'S_HIDDEN' => _hidden($s_hidden))); if ($v->s == 'u') { _style('updated'); } }