public function manage_topic($id = false) { $topic_info = ''; $topic = new \CODOF\Forum\Topic($this->db); if ($id) { $tid = (int) $id; $qry = 'SELECT t.topic_id,t.title, t.cat_id, t.uid,t.topic_status, c.cat_name, p.imessage ' . 'FROM ' . PREFIX . 'codo_topics AS t ' . 'INNER JOIN ' . PREFIX . 'codo_categories AS c ON c.cat_id=t.cat_id ' . 'INNER JOIN ' . PREFIX . 'codo_posts AS p ON p.topic_id=t.topic_id ' . 'WHERE t.topic_id=' . $tid; $res = $this->db->query($qry); $topic_info = $res->fetch(); //i have come to edit the topic $tuid = $topic_info['uid']; $cid = $topic_info['cat_id']; $has_permission = $topic->canViewTopic($tuid, $cid, $tid) && $topic->canEditTopic($tuid, $cid, $tid); } else { $topic_info = array("title" => "", "imessage" => "", "topic_status" => 0, "cat_id" => 0, "topic_id" => 0); //i have come to create a new topic $has_permission = $topic->canCreateTopicInAtleastOne(); } if ($has_permission) { $tags = ''; if ($id) { $_tags = $topic->getTags($id); if ($_tags) { $tags = implode(",", $_tags); } \CODOF\Store::set('sub_title', _t('Edit topic ') . $topic_info['title']); } else { \CODOF\Store::set('sub_title', _t('Create topic')); } $this->smarty->assign('tags', $tags); $cat = new \CODOF\Forum\Category($this->db); $cats = $cat->generate_tree($cat->getCategoriesWhereUserCanCreateTopic()); $this->smarty->assign('cats', $cats); $this->assign_editor_vars(); $this->smarty->assign('topic', $topic_info); $this->smarty->assign('sticky_checked', \CODOF\Forum\Forum::isSticky($topic_info['topic_status'])); $this->smarty->assign('frontpage_checked', $topic_info['topic_status'] == \CODOF\Forum\Forum::STICKY); $user = \CODOF\User\User::get(); $this->smarty->assign('can_make_sticky', $user->can('make sticky')); $this->smarty->assign('can_add_tags', $user->can('add tags')); $this->css_files = array('new_topic', 'editor', 'jquery.textcomplete'); $arr = array(array(DATA_PATH . "assets/js/bootstrap-tagsinput.min.js", array('type' => 'defer'))); $this->js_files = array_merge($arr, $cat->get_js_editor_files()); $this->view = 'forum/new_topic'; } else { if (!\CODOF\User\CurrentUser\CurrentUser::loggedIn()) { header('Location: ' . \CODOF\User\User::getProfileUrl()); } else { \CODOF\Store::set('sub_title', _t('Access denied')); $this->view = 'access_denied'; } } }