public function display($tpl = null) { // Initialise variables $doc = JFactory::getDocument(); $doc->addScript(JURI::root() . 'administrator/components/com_easydiscuss/assets/js/admin.js'); // Load front end language file. JFactory::getLanguage()->load('com_easydiscuss', JPATH_ROOT); $postId = JRequest::getInt('id', 0); $parentId = JRequest::getString('pid', ''); $source = JRequest::getVar('source', 'posts'); $post = JTable::getInstance('Posts', 'Discuss'); $post->load($postId); $post->content_raw = $post->content; // Get post's tags $postModel = $this->getModel('Posts'); $post->tags = $postModel->getPostTags($post->id); $post->content = EasyDiscussParser::html2bbcode($post->content); // Select top 20 tags. $tagmodel = $this->getModel('Tags'); $populartags = $tagmodel->getTagCloud('20', 'post_count', 'DESC'); $repliesCnt = $postModel->getPostRepliesCount($post->id); $nestedCategories = DiscussHelper::populateCategories('', '', 'select', 'category_id', $post->category_id, true, true); $config = DiscussHelper::getConfig(); // Get's the creator's name $creatorName = $post->poster_name; if ($post->user_id) { $author = DiscussHelper::getTable('Profile'); $author->load($post->user_id); $creatorName = $author->getName(); } require_once DISCUSS_CLASSES . '/composer.php'; $composer = new DiscussComposer("creating", $post); $this->assignRef('creatorName', $creatorName); $this->assignRef('config', $config); $this->assignRef('post', $post); $this->assignRef('populartags', $populartags); $this->assignRef('repliesCnt', $repliesCnt); $this->assignRef('source', $source); $this->assignRef('parentId', $parentId); $this->assignRef('nestedCategories', $nestedCategories); $this->assignRef('composer', $composer); $this->assign('joomlaversion', DiscussHelper::getJoomlaVersion()); //load require javascript string DiscussHelper::loadString(JRequest::getVar('view')); parent::display($tpl); }
public function display($tpl = null) { // Initialise variables $config = DiscussHelper::getConfig(); $catId = JRequest::getVar('catid', ''); $cat = JTable::getInstance('Category', 'Discuss'); $cat->load($catId); $this->cat = $cat; $this->addPathway('Home', 'index.php?option=com_easydiscuss'); $this->addPathway(JText::_('Categories'), 'index.php?option=com_easydiscuss&view=categories'); if ($catId) { $this->addPathway('Edit Category'); } else { $this->addPathway('New Category'); } // Set default values for new entries. if (empty($cat->created)) { $date = DiscussDateHelper::getDate(); $now = DiscussDateHelper::toFormat($date); $cat->created = $now; $cat->published = true; } $catRuleItems = JTable::getInstance('CategoryAclItem', 'Discuss'); $categoryRules = $catRuleItems->getAllRuleItems(); $assignedGroupACL = $cat->getAssignedACL('group'); $assignedUserACL = $cat->getAssignedACL('user'); $assignedGroupMod = $cat->getAssignedModerator('group'); $assignedUserMod = $cat->getAssignedModerator('user'); $joomlaGroups = DiscussHelper::getJoomlaUserGroups(); $parentList = DiscussHelper::populateCategories('', '', 'select', 'parent_id', $cat->parent_id); $jConfig = DiscussHelper::getJConfig(); $editor = JFactory::getEditor($jConfig->get('editor')); $this->assignRef('editor', $editor); $this->assignRef('cat', $cat); $this->assignRef('config', $config); $this->assignRef('acl', $acl); $this->assignRef('parentList', $parentList); $this->assignRef('categoryRules', $categoryRules); $this->assignRef('assignedGroupACL', $assignedGroupACL); $this->assignRef('assignedUserACL', $assignedUserACL); $this->assignRef('assignedGroupMod', $assignedGroupMod); $this->assignRef('assignedUserMod', $assignedUserMod); $this->assignRef('joomlaGroups', $joomlaGroups); parent::display($tpl); }
public function display($tpl = null) { // @rule: Test for user access if on 1.6 and above if (DiscussHelper::getJoomlaVersion() >= '1.6') { if (!JFactory::getUser()->authorise('discuss.manage.posts', 'com_easydiscuss')) { JFactory::getApplication()->redirect('index.php', JText::_('JERROR_ALERTNOAUTHOR'), 'error'); JFactory::getApplication()->close(); } } // Initialise variables $mainframe = JFactory::getApplication(); $filter_state = $mainframe->getUserStateFromRequest('com_easydiscuss.posts.filter_state', 'filter_state', '*', 'word'); $search = $mainframe->getUserStateFromRequest('com_easydiscuss.posts.search', 'search', '', 'string'); $search = trim(JString::strtolower($search)); $order = $mainframe->getUserStateFromRequest('com_easydiscuss.posts.filter_order', 'filter_order', 'a.id', 'cmd'); $orderDirection = $mainframe->getUserStateFromRequest('com_easydiscuss.posts.filter_order_Dir', 'filter_order_Dir', '', 'word'); $parentId = JRequest::getString('pid', ''); $parentTitle = ''; $this->addPathway(JText::_('COM_EASYDISCUSS_BREADCRUMB_HOME'), 'index.php?option=com_easydiscuss'); if (!empty($parentId)) { $post = JTable::getInstance('Posts', 'Discuss'); $post->load($parentId); $parentTitle = $post->title; $this->addPathway(JText::_('COM_EASYDISCUSS_BREADCRUMB_DISCUSSIONS'), 'index.php?option=com_easydiscuss&view=posts'); $this->addPathway(JText::sprintf('COM_EASYDISCUSS_BREADCRUMB_VIEWING_REPLIES', $parentTitle), ''); } else { $this->addPathway(JText::_('COM_EASYDISCUSS_BREADCRUMB_DISCUSSIONS'), ''); } $postModel = $this->getModel('Threaded'); $filterCategory = JRequest::getInt('category_id'); $categoryFilter = DiscussHelper::populateCategories('', '', 'select', 'category_id', $filterCategory, true, false, true, true, 'inputbox'); $posts = $postModel->getPosts(); $pagination = $postModel->getPagination(); $this->assignRef('posts', $posts); $this->assignRef('pagination', $pagination); $this->assign('categoryFilter', $categoryFilter); $this->assign('state', $this->getFilterState($filter_state)); $this->assign('search', $search); $this->assign('order', $order); $this->assign('orderDirection', $orderDirection); $this->assign('parentId', $parentId); $this->assign('parentTitle', $parentTitle); parent::display($tpl); }
/** * Displays a dialog with a category selection. * * @since 3.0 * @access public */ public function movePost($id) { $ajax = new Disjax(); $my = JFactory::getUser(); $post = DiscussHelper::getTable('Post'); $state = $post->load($id); if (!$state || !$id || $post->parent_id) { echo JText::_('COM_EASYDISCUSS_SYSTEM_INVALID_ID'); return $ajax->send(); } // Load the category of the post. $category = DiscussHelper::getTable('Category'); $category->load($post->category_id); // Load the access. $access = $post->getAccess($category); if (!$my->id || !$access->canMove()) { echo JText::_('COM_EASYDISCUSS_SYSTEM_INSUFFICIENT_PERMISSIONS'); return $ajax->send(); } // Get list of categories. $categories = DiscussHelper::populateCategories('', '', 'select', 'category_id', $post->category_id, true, true, true, true); $theme = new DiscussThemes(); $theme->set('categories', $categories); $theme->set('id', $id); $content = $theme->fetch('ajax.post.move.php', array('dialog' => true)); $options = new stdClass(); $options->content = $content; $options->title = JText::_('COM_EASYDISCUSS_MOVE_POST_TITLE'); $buttons = array(); $button = new stdClass(); $button->title = JText::_('COM_EASYDISCUSS_BUTTON_CLOSE'); $button->action = 'disjax.closedlg();'; $buttons[] = $button; $button = new stdClass(); $button->title = JText::_('COM_EASYDISCUSS_BUTTON_MOVE'); $button->form = '#frmMovePost'; $button->className = 'btn-primary'; $buttons[] = $button; $options->buttons = $buttons; $ajax->dialog($options); $ajax->send(); }
public function showMoveDialog() { $ajax = new Disjax(); $options = new stdClass(); // Get list of categories. $categories = DiscussHelper::populateCategories('', '', 'select', 'new_category', '', true, true, true, true); $options->title = JText::_('COM_EASYDISCUSS_DIALOG_MOVE_TITLE'); $action = DiscussHelper::getJoomlaVersion() >= '1.6' ? 'Joomla.submitbutton(\'movePosts\');' : 'submitbutton(\'movePosts\')'; ob_start(); ?> <div style="display:none;" id="new_category_error" class="alert alert-error"></div> <p><?php echo JText::_('COM_EASYDISCUSS_DIALOG_MOVE_CONTENT'); ?> </p> <p> <?php echo $categories; ?> </p> <?php $options->content = ob_get_clean(); $buttons = array(); $button = new stdClass(); $button->title = JText::_('COM_EASYDISCUSS_CANCEL_BUTTON'); $button->action = 'disjax.closedlg();'; $buttons[] = $button; $button = new stdClass(); $button->title = JText::_('COM_EASYDISCUSS_MOVE_BUTTON'); $button->action = $action; $button->className = 'btn-primary'; $buttons[] = $button; $options->buttons = $buttons; $ajax->dialog($options); $ajax->send(); }
* See COPYRIGHT.php for copyright notices and details. */ defined('_JEXEC') or die('Restricted access'); require_once DISCUSS_HELPERS . '/router.php'; $config = DiscussHelper::getConfig(); $isEditMode = false; $post = DiscussHelper::getTable('Post'); $category = JRequest::getInt('category', $post->category_id); $categoryModel = DiscussHelper::getModel('Category'); $defaultCategory = $categoryModel->getDefaultCategory(); $my = JFactory::getUser(); $showPrivateCat = $my->id == 0 ? false : true; if ($category == 0 && $defaultCategory !== false) { $category = $defaultCategory->id; } $nestedCategories = DiscussHelper::populateCategories('', '', 'select', 'category_id', $category, true, true, $showPrivateCat); //recaptcha integration $recaptcha = ''; $enableRecaptcha = $config->get('antispam_recaptcha'); $publicKey = $config->get('antispam_recaptcha_public'); $skipRecaptcha = $config->get('antispam_skip_recaptcha'); $model = DiscussHelper::getModel('Posts'); $postCount = count($model->getPostsBy('user', $my->id)); if ($enableRecaptcha && !empty($publicKey) && $postCount < $skipRecaptcha) { require_once DISCUSS_CLASSES . '/recaptcha.php'; $recaptcha = getRecaptchaData($publicKey, $config->get('antispam_recaptcha_theme'), $config->get('antispam_recaptcha_lang'), null, $config->get('antispam_recaptcha_ssl')); } ?> <script src="http://easydiscuss.dev/media/foundry/js/foundry.js" type="text/javascript"></script>
public function edit($tpl = null) { $app = JFactory::getApplication(); $doc = JFactory::getDocument(); $my = JFactory::getUser(); $acl = DiscussHelper::getHelper('ACL'); $config = DiscussHelper::getConfig(); // Load post item $id = JRequest::getInt('id', 0); if (empty($id)) { DiscussHelper::setMessageQueue(JText::_('COM_EASYDISCUSS_INVALID_POST_ID')); return; } $post = DiscussHelper::getTable('Post'); $post->load($id); $post->content_raw = $post->content; $editing = (bool) $post->id; if (!$editing) { // try to get from session if there are any. $this->getSessionData($post); } $categoryId = JRequest::getInt('category', $post->category_id); // Load category item. $category = DiscussHelper::getTable('Category'); $category->load($categoryId); // Check if user is allowed to post a discussion, we also need to check against the category acl if (empty($my->id) && !$acl->allowed('add_question', 0)) { DiscussHelper::setMessageQueue(JText::_('COM_EASYDISCUSS_PLEASE_KINDLY_LOGIN_TO_CREATE_A_POST')); $app->redirect(DiscussRouter::_('index.php?option=com_easydiscuss&view=index', false)); $app->close(); return; } if ($my->id != 0 && !$acl->allowed('add_question', '0') && !$category->canPost()) { $app->redirect(DiscussRouter::_('index.php?option=com_easydiscuss&view=index', false), JText::_('COM_EASYDISCUSS_SYSTEM_INSUFFICIENT_PERMISSIONS')); $app->close(); return; } // Set the breadcrumbs. $this->setPathway(JText::_('COM_EASYDISCUSS_BREADCRUMBS_ASK')); // Set the page title. $title = JText::_('COM_EASYDISCUSS_TITLE_ASK'); if ($id && $post->id) { $title = JText::sprintf('COM_EASYDISCUSS_TITLE_EDIT_QUESTION', $post->getTitle()); } // Set the page title DiscussHelper::setPageTitle($title); if ($editing) { $isModerator = DiscussHelper::getHelper('Moderator')->isModerator($post->category_id); if (!DiscussHelper::isMine($post->user_id) && !DiscussHelper::isSiteAdmin() && !$acl->allowed('edit_question') && !$isModerator) { $app->redirect(DiscussRouter::_('index.php?option=com_easydiscuss&view=post&id=' . $postid, false), JText::_('COM_EASYDISCUSS_SYSTEM_INSUFFICIENT_PERMISSIONS')); $app->close(); } $tagsModel = DiscussHelper::getModel('PostsTags'); $post->tags = $tagsModel->getPostTags($post->id); } else { if ($categoryId) { // set the default category $post->category_id = $categoryId; } } $attachments = $post->getAttachments(); if (isset($post->sessiondata)) { $attachments = ''; } $model = DiscussHelper::getModel('Posts'); $postCount = count($model->getPostsBy('user', $my->id)); $onlyPublished = empty($post->id) ? true : false; // @rule: If there is a category id passed through the query, respect it first. $showPrivateCat = empty($post->id) && $my->id == 0 ? false : true; // [model:category] $categoryModel = $this->getModel('Category'); $defaultCategory = $categoryModel->getDefaultCategory(); if ($categoryId == 0 && $defaultCategory !== false) { $categoryId = $defaultCategory->id; } $nestedCategories = ''; $categories = ''; if ($config->get('layout_category_selection') == 'multitier') { $categoriesModel = $this->getModel('Categories'); $categories = $categoriesModel->getCategories(array('acl_type' => DISCUSS_CATEGORY_ACL_ACTION_SELECT)); } else { $nestedCategories = DiscussHelper::populateCategories('', '', 'select', 'category_id', $categoryId, true, $onlyPublished, $showPrivateCat, true); } if ($config->get('layout_reply_editor') == 'bbcode') { // Legacy fix when switching from WYSIWYG editor to bbcode. $post->content = EasyDiscussParser::html2bbcode($post->content); } $editor = ''; if ($config->get('layout_editor') != 'bbcode') { $editor = JFactory::getEditor($config->get('layout_editor')); } // Get list of moderators from the site. $moderatorList = array(); if ($config->get('main_assign_user')) { $moderatorList = DiscussHelper::getHelper('Moderator')->getSelectOptions($post->category_id); } $composer = new DiscussComposer("editing", $post); // Set the discussion object. $access = $post->getAccess($category); $theme = new DiscussThemes(); // Test if reference is passed in query string. $reference = JRequest::getWord('reference'); $referenceId = JRequest::getInt('reference_id', 0); $redirect = JRequest::getVar('redirect', ''); $theme->set('redirect', $redirect); $theme->set('reference', $reference); $theme->set('referenceId', $referenceId); $theme->set('isEditMode', $editing); $theme->set('post', $post); $theme->set('composer', $composer); $theme->set('parent', $composer->parent); $theme->set('nestedCategories', $nestedCategories); $theme->set('attachments', $attachments); $theme->set('editor', $editor); $theme->set('moderatorList', $moderatorList); $theme->set('categories', $categories); $theme->set('access', $access); // Deprecated since 3.0. Will be removed in 4.0 $theme->set('config', $config); echo $theme->fetch('form.reply.wysiwyg.php'); }
* is derivative of works licensed under the GNU General Public License or * other free or open source software licenses. * See COPYRIGHT.php for copyright notices and details. */ // no direct access defined('_JEXEC') or die('Restricted access'); $user = JFactory::getUser(); if (!empty($user->id)) { $postId = JRequest::getInt('id', 0); $postCat = ''; if ($postId) { $post = DiscussHelper::getTable('Posts'); $post->load($postId); $postCat = $post->category_id; } $nestedCategories = DiscussHelper::populateCategories('', '', 'select', 'mod_post_topic_category_id', $postCat, true, true); } ?> <?php if (!empty($user->id)) { ?> <div id="discuss-post-topic" class="discuss-mod discuss-post-topic<?php echo $params->get('moduleclass_sfx'); ?> "> <form id="mod_post_topic" name="mod_post_topic" action="<?php echo DiscussRouter::_('index.php?option=com_easydiscuss&controller=posts&task=submit'); ?> " method="post" enctype="multipart/form-data" class="form-horizontal"> <div>