Пример #1
0
 /**
  * Gets a view for the caller.
  *
  * @since	3.0
  * @access	public
  */
 public function getView($name = '', $type = '', $prefix = '', $config = array())
 {
     $theme = new DiscussThemes();
     $file = $name . '.ejs';
     $output = $theme->fetch($file);
     return $output;
 }
Пример #2
0
 /**
  * Displays the user's points achievement history
  *
  * @since	2.0
  * @access	public
  */
 public function history($tmpl = null)
 {
     $app = JFactory::getApplication();
     $id = JRequest::getInt('id');
     if (!$id) {
         DiscussHelper::setMessageQueue(JText::_('Unable to locate the id of the user.'), DISCUSS_QUEUE_ERROR);
         $app->redirect('index.php?option=com_easydiscuss');
         $app->close();
     }
     $model = DiscussHelper::getModel('Points', true);
     $history = $model->getPointsHistory($id);
     foreach ($history as $item) {
         $date = DiscussDateHelper::dateWithOffSet($item->created);
         $item->created = $date->toFormat('%A, %b %e %Y');
         $points = DiscussHelper::getHelper('Points')->getPoints($item->command);
         if ($points) {
             if ($points[0]->rule_limit < 0) {
                 $item->class = 'badge-important';
                 $item->points = $points[0]->rule_limit;
             } else {
                 $item->class = 'badge-info';
                 $item->points = '+' . $points[0]->rule_limit;
             }
         } else {
             $item->class = 'badge-info';
             $item->points = '+';
         }
     }
     $theme = new DiscussThemes();
     $theme->set('history', $history);
     echo $theme->fetch('points.history.php');
 }
Пример #3
0
 function ajaxSubscribe($id)
 {
     $disjax = new disjax();
     $mainframe = JFactory::getApplication();
     $my = JFactory::getUser();
     $tag = DiscussHelper::getTable('Tags');
     $tag->load($id);
     $tpl = new DiscussThemes();
     $tpl->set('tag', $tag);
     $tpl->set('my', $my);
     $html = $tpl->fetch('ajax.subscribe.tag.php');
     $options = new stdClass();
     $options->title = JText::sprintf('COM_EASYDISCUSS_SUBSCRIBE_TO_TAG', $tag->title);
     $options->content = $html;
     $buttons = array();
     $button = new stdClass();
     $button->title = JText::_('COM_EASYDISCUSS_BUTTON_CANCEL');
     $button->action = 'disjax.closedlg();';
     $buttons[] = $button;
     $button = new stdClass();
     $button->title = JText::_('COM_EASYDISCUSS_BUTTON_SUBSCRIBE');
     $button->action = 'discuss.subscribe.tag(' . $tag->id . ')';
     $button->className = 'btn-primary';
     $buttons[] = $button;
     $options->buttons = $buttons;
     $disjax->dialog($options);
     $disjax->send();
 }
Пример #4
0
 public function getAjaxTemplate()
 {
     // Since this is the back end we need to load the front end's language file here.
     JFactory::getLanguage()->load('com_easydiscuss', JPATH_ROOT);
     $files = JRequest::getVar('names', '');
     if (empty($files)) {
         return false;
     }
     // Ensure the integrity of each items submitted to be an array.
     if (!is_array($files)) {
         $files = array($files);
     }
     $result = array();
     foreach ($files as $file) {
         $template = new DiscussThemes();
         $out = $template->fetch($file . '.ejs');
         $obj = new stdClass();
         $obj->name = $file;
         $obj->content = $out;
         $result[] = $obj;
     }
     header('Content-type: text/javascript; UTF-8');
     echo json_encode($result);
     exit;
 }
Пример #5
0
 /**
  * Displays a confirmation dialog to delete an attachment.
  *
  * @since	3.0
  * @access	public
  * @param	int 	The id of the attachment.
  */
 public function confirmDelete($id)
 {
     $ajax = new Disjax();
     $user = JFactory::getUser();
     // @rule: Do not allow empty id or guests to delete files.
     if (empty($id) || empty($user->id)) {
         return false;
     }
     $attachment = DiscussHelper::getTable('Attachments');
     $attachment->load($id);
     // Ensure that only post owner or admin can delete it.
     if (!$attachment->deleteable()) {
         return false;
     }
     $theme = new DiscussThemes();
     $theme->set('id', $id);
     $content = $theme->fetch('ajax.attachment.delete.php', array('dialog' => true));
     $options = new stdClass();
     $options->content = $content;
     $options->title = JText::_('COM_EASYDISCUSS_ATTACHMENT_DELETE_CONFIRMATION_TITLE');
     $buttons = array();
     $button = new stdClass();
     $button->title = JText::_('COM_EASYDISCUSS_BUTTON_CANCEL');
     $button->action = 'disjax.closedlg();';
     $buttons[] = $button;
     $button = new stdClass();
     $button->title = JText::_('COM_EASYDISCUSS_BUTTON_DELETE');
     $button->action = "disjax.loadingDialog();disjax.load('attachments','delete','" . $id . "');";
     $button->className = 'btn-danger';
     $buttons[] = $button;
     $options->buttons = $buttons;
     $ajax->dialog($options);
     $ajax->send();
 }
Пример #6
0
 public static function getHTML()
 {
     $captcha = DiscussHelper::getTable('Captcha');
     $captcha->created = DiscussHelper::getDate()->toMySQL();
     $captcha->store();
     $theme = new DiscussThemes();
     $theme->set('id', $captcha->id);
     return $theme->fetch('form.captcha.php');
 }
Пример #7
0
 public static function getHTML()
 {
     $config = DiscussHelper::getConfig();
     $adsenseObj = new stdClass();
     $adsenseObj->header = '';
     $adsenseObj->beforereplies = '';
     $adsenseObj->footer = '';
     $defaultCode = '';
     $defaultDisplay = '';
     $my = JFactory::getUser();
     if (!$config->get('integration_google_adsense_enable')) {
         return $adsenseObj;
     }
     if ($config->get('integration_google_adsense_display_access') == 'members' && $my->id == 0) {
         return $adsenseObj;
     }
     if ($config->get('integration_google_adsense_display_access') == 'guests' && $my->id > 0) {
         return $adsenseObj;
     }
     $adminAdsenseCode = $config->get('integration_google_adsense_code');
     $adminAdsenseDisplay = $config->get('integration_google_adsense_display');
     if (!empty($adminAdsenseCode)) {
         $defaultCode = $adminAdsenseCode;
         $defaultDisplay = $adminAdsenseDisplay;
     }
     if (!empty($defaultCode)) {
         $adTheme = new DiscussThemes();
         $adTheme->set('adsense', $defaultCode);
         $adsenseHTML = $adTheme->fetch('adsense.php');
         switch ($defaultDisplay) {
             case 'beforereplies':
                 $adsenseObj->beforereplies = $adsenseHTML;
                 break;
             case 'header':
                 $adsenseObj->header = $adsenseHTML;
                 break;
             case 'footer':
                 $adsenseObj->footer = $adsenseHTML;
                 break;
             case 'both':
             default:
                 $adsenseObj->header = $adsenseHTML;
                 $adsenseObj->footer = $adsenseHTML;
                 break;
         }
     }
     //end if
     return $adsenseObj;
 }
Пример #8
0
 public function display($tpl = null)
 {
     $my = JFactory::getUser();
     if (!$my->id) {
         DiscussHelper::setMessageQueue(JText::_('COM_EASYDISCUSS_PLEASE_LOGIN_FIRST'), 'error');
         JFactory::getApplication()->redirect(DiscussRouter::_('index.php?option=com_easydiscuss', false));
     }
     $model = $this->getModel('Notification');
     $this->setPathway(JText::_('COM_EASYDISCUSS_BREADCRUMBS_NOTIFICATIONS'));
     // Make this configurable?
     $limit = 100;
     $notifications = $model->getNotifications($my->id, false, $limit);
     DiscussHelper::getHelper('Notifications')->format($notifications, true);
     $theme = new DiscussThemes();
     $theme->set('notifications', $notifications);
     echo $theme->fetch('notifications.php');
 }
Пример #9
0
 public function load()
 {
     $my = JFactory::getUser();
     $ajax = DiscussHelper::getHelper('Ajax');
     $config = DiscussHelper::getConfig();
     if ($my->id <= 0 || !$config->get('main_notifications')) {
         $ajax->fail(JText::_('COM_EASYDISCUSS_NOT_ALLOWED'));
         return;
     }
     $model = $this->getModel('Notification');
     $notifications = $model->getNotifications($my->id, true, $config->get('main_notifications_limit'));
     DiscussHelper::getHelper('Notifications')->format($notifications);
     $theme = new DiscussThemes();
     $theme->set('notifications', $notifications);
     $html = $theme->fetch('toolbar.notification.item.php');
     $ajax->success($html);
 }
Пример #10
0
 public function getLastRepliesHTML($postId = '0', $options)
 {
     $db = DiscussHelper::getDBO();
     $query = 'SELECT DISTINCT a.`user_id`';
     $query .= ' FROM `#__discuss_posts` as a';
     $query .= ' WHERE a.`published` = ' . $db->Quote('1');
     $query .= ' AND a.`parent_id` = ' . $db->Quote($postId);
     $query .= ' AND a.`user_type` = ' . $db->Quote('member');
     $query .= ' AND a.`user_id` != ' . $db->Quote('0');
     $query .= ' LIMIT 8';
     $db->setQuery($query);
     $replies = $db->loadObjectList();
     $json = new Services_JSON();
     $options = $json->encode($options);
     $themes = new DiscussThemes();
     $themes->set('replies', $replies);
     $themes->set('options', $options);
     return $themes->fetch('tooltip.lastreplies.php');
 }
Пример #11
0
 function display($tpl = null)
 {
     $config = DiscussHelper::getConfig();
     $app = JFactory::getApplication();
     if (!$config->get('main_favorite')) {
         DiscussHelper::setMessageQueue(JText::_('COM_EASYDISCUSS_FEATURE_IS_DISABLED'), DISCUSS_QUEUE_ERROR);
         $app->redirect(DiscussRouter::_('index.php?option=com_easydiscuss', false));
         $app->close();
     }
     DiscussHelper::setPageTitle(JText::_('COM_EASYDISCUSS_FAVOURITES_TITLE'));
     // @task: Add view
     $this->logView();
     DiscussHelper::setMeta();
     $postModel = DiscussHelper::getModel('Posts');
     $posts = $postModel->getData(true, 'latest', null, 'favourites');
     $posts = DiscussHelper::formatPost($posts);
     $theme = new DiscussThemes();
     $theme->set('posts', $posts);
     echo $theme->fetch('favourites.php');
 }
Пример #12
0
 /**
  * Generate the voting user interface HTML
  *
  * @access	public
  * @param	object	$post		The post object.
  * @param	array	$params		The parameters.
  *
  * @return	String	The HTML string.
  **/
 public static function getHTML(&$post, $params = array())
 {
     $isLock = false;
     if (isset($params['parent_id'])) {
         $isLock = self::isLock($params['parent_id']);
     }
     if (isset($params['isMainLocked'])) {
         $isLock = $params['isMainLocked'];
     }
     $my = isset($params['my']) ? $params['my'] : JFactory::getUser();
     $config = isset($params['config']) ? $params['config'] : DiscussHelper::getConfig();
     $tmpl = isset($params['tmpl']) ? $params['tmpl'] : 'vote.php';
     $canVote = !$config->get('main_allowselfvote') && $my->id == $post->user_id ? false : true;
     $template = new DiscussThemes();
     $template->set('post', $post);
     $template->set('isLock', $isLock);
     $template->set('canVote', $canVote);
     $html = $template->fetch($tmpl);
     return $html;
 }
Пример #13
0
 public function listings()
 {
     $app = JFactory::getApplication();
     $config = DiscussHelper::getConfig();
     $id = JRequest::getInt('id');
     if (empty($id)) {
         $app->redirect(DiscussRouter::_('index.php?option=com_easydiscuss&view=badges', false), JText::_('COM_EASYDISCUSS_INVALID_BADGE'));
         $app->close();
     }
     $badge = DiscussHelper::getTable('Badges');
     $badge->load($id);
     $this->setPathway(JText::_('COM_EASYDISCUSS_BADGES'), DiscussRouter::_('index.php?option=com_easydiscuss&view=badges'));
     $this->setPathway(JText::_($badge->get('title')));
     DiscussHelper::setPageTitle(JText::sprintf('COM_EASYDISCUSS_VIEWING_BADGE_TITLE', $this->escape($badge->title)));
     $users = $badge->getUsers();
     $theme = new DiscussThemes();
     $theme->set('badge', $badge);
     $theme->set('users', $users);
     echo $theme->fetch('badge.php');
 }
Пример #14
0
 public function display($tpl = null)
 {
     $doc = JFactory::getDocument();
     $my = JFactory::getUser();
     EDC::setPageTitle(JText::_('COM_EASYDISCUSS_PAGETITLE_ASSIGNED'));
     $this->setPathway(JText::_('COM_EASYDISCUSS_BREADCRUMB_ASSIGNED'));
     if (!EDC::isModerator()) {
         return JError::raiseError(404, JText::_('COM_EASYDISCUSS_YOU_ARE_NOT_ALLOWED_HERE'));
     }
     $subs = array();
     // [Model:Assigned]
     $model = EDC::getModel('Assigned');
     $posts = $model->getPosts();
     $posts = EDC::formatPost($posts);
     $posts = Discusshelper::getPostStatusAndTypes($posts);
     // Get total number of posts assigned to the current user.
     $totalAssigned = $model->getTotalAssigned($my->id);
     // Get total number of posts that is assigned to this user and resolved.
     // [Model:Assigned]
     $totalResolved = $model->getTotalSolved($my->id);
     // Calculate percentage
     $percentage = 0;
     if ($posts) {
         $percentage = round($totalResolved / $totalAssigned * 100, 2);
     }
     $theme = new DiscussThemes();
     $theme->set('totalAssigned', $totalAssigned);
     $theme->set('totalResolved', $totalResolved);
     $theme->set('percentage', $percentage);
     $theme->set('posts', $posts);
     echo $theme->fetch('assigned.php');
 }
Пример #15
0
 function display($tmpl = null)
 {
     $document = JFactory::getDocument();
     $config = DiscussHelper::getConfig();
     $doc = JFactory::getDocument();
     DiscussHelper::setPageTitle(JText::_('COM_EASYDISCUSS_MEMBERS_TITLE'));
     $this->setPathway(JText::_('COM_EASYDISCUSS_BREADCRUMBS_MEMBERS'));
     $model = $this->getModel('Users');
     $userQuery = JRequest::getString('userQuery', '');
     $result = $model->getData($userQuery);
     $pagination = $model->getPagination();
     $sort = JRequest::getString('sort', 'latest');
     $filteractive = JRequest::getString('filter', 'allposts');
     $users = DiscussHelper::formatUsers($result);
     $sort = JRequest::getCmd('sort', 'name');
     $uids = $config->get('main_exclude_members');
     if (!empty($uids)) {
         // Remove white space
         $uids = str_replace(' ', '', $uids);
         $excludeId = explode(',', $uids);
         $temp = array();
         foreach ($users as $user) {
             if (!in_array($user->id, $excludeId)) {
                 $temp[] = $user;
             }
         }
         $users = $temp;
     }
     $theme = new DiscussThemes();
     $theme->set('users', $users);
     $theme->set('pagination', $pagination);
     $theme->set('sort', $sort);
     $theme->set('userQuery', $userQuery);
     echo $theme->fetch('users.php');
 }
Пример #16
0
 /**
  * Displays a confirmation dialog to remove a location
  * from a post.
  *
  * @since	3.0
  * @access	public
  * @param	null
  */
 public function confirmRemoveLocation($id)
 {
     $ajax = new Disjax();
     $theme = new DiscussThemes();
     $content = $theme->fetch('ajax.location.delete.php', array('dialog' => true));
     $options = new stdClass();
     $options->content = $content;
     $options->title = JText::_('COM_EASYDISCUSS_DELETE_LOCATION_TITLE');
     $buttons = array();
     $button = new stdClass();
     $button->title = JText::_('COM_EASYDISCUSS_BUTTON_NO');
     $button->action = 'disjax.closedlg();';
     $buttons[] = $button;
     $button = new stdClass();
     $button->title = JText::_('COM_EASYDISCUSS_BUTTON_YES');
     $button->action = 'discuss.location.remove("' . $id . '");';
     $button->className = 'btn-primary';
     $buttons[] = $button;
     $options->buttons = $buttons;
     $ajax->dialog($options);
     return $ajax->send();
 }
Пример #17
0
 public function getAjaxTemplate()
 {
     $files = JRequest::getVar('names', '');
     if (empty($files)) {
         return false;
     }
     // Ensure the integrity of each items submitted to be an array.
     if (!is_array($files)) {
         $files = array($files);
     }
     $result = array();
     foreach ($files as $file) {
         $template = new DiscussThemes();
         $out = $template->fetch($file . '.ejs');
         $obj = new stdClass();
         $obj->name = $file;
         $obj->content = $out;
         $result[] = $obj;
     }
     header('Content-type: text/javascript; UTF-8');
     echo json_encode($result);
     exit;
 }
Пример #18
0
 /**
  * Returns html formatted data of this current attachment
  *
  * @param	none
  * @return	string	$html	HTML formatted data.
  **/
 public function toHTML($isEmail = false)
 {
     require_once DISCUSS_CLASSES . '/themes.php';
     $type = explode('/', $this->mime);
     switch ($type[0]) {
         case 'image':
             $childtheme = 'attachment.image.php';
             break;
         case 'application':
         case 'audio':
         case 'message':
         case 'multipart':
         case 'text':
         case 'video':
         default:
             $childtheme = 'attachment.download.php';
             break;
     }
     $theme = new DiscussThemes();
     $theme->set('childtheme', $childtheme);
     $theme->set('attachment', $this);
     $theme->set('isEmail', $isEmail);
     return $theme->fetch('attachment.default.php');
 }
Пример #19
0
 public function display($tpl = null)
 {
     // Initialise variables
     $doc = JFactory::getDocument();
     $my = JFactory::getUser();
     $config = DiscussHelper::getConfig();
     $app = JFactory::getApplication();
     $registry = DiscussHelper::getRegistry();
     $categoryId = JRequest::getInt('category_id', 0);
     // Perform redirection if there is a category_id in the index view.
     if (!empty($categoryId)) {
         $app->redirect(DiscussRouter::_('index.php?option=com_easydiscuss&view=categories&layout=listings&category_id=' . $categoryId, false));
         $app->close();
     }
     // Try to detect if there's any category id being set in the menu parameter.
     $activeMenu = $app->getMenu()->getActive();
     if ($activeMenu && !$categoryId) {
         // Load menu params to the registry.
         $registry->loadString($activeMenu->params);
         if ($registry->get('category_id')) {
             $categoryId = $registry->get('category_id');
         }
     }
     // Get the current logged in user's access.
     $acl = DiscussHelper::getHelper('ACL');
     // Todo: Perhaps we should fix the confused naming of filter and sort to type and sort
     $filter = JRequest::getString('filter', $registry->get('filter'));
     $sort = JRequest::getString('sort', $registry->get('sort'));
     // Get the pagination limit
     $limit = $registry->get('limit');
     $limit = $limit == '-2' ? DiscussHelper::getListLimit() : $limit;
     $limit = $limit == '-1' ? DiscussHelper::getJConfig()->get('list_limit') : $limit;
     // Add view to this page.
     $this->logView();
     // set page title.
     DiscussHelper::setPageTitle();
     // Set the meta of the page.
     DiscussHelper::setMeta();
     // Add rss feed into headers
     DiscussHelper::getHelper('Feeds')->addHeaders('index.php?option=com_easydiscuss&view=index');
     // Get list of categories on the site.
     $catModel = $this->getModel('Categories');
     // Pagination is by default disabled.
     $pagination = false;
     // Get the model.
     $postModel = DiscussHelper::getModel('Posts');
     // Get a list of accessible categories
     $cats = $this->getAccessibleCategories($categoryId);
     // Get featured posts from this particular category.
     $featured = array();
     if ($config->get('layout_featuredpost_frontpage')) {
         $options = array('pagination' => false, 'category' => $cats, 'sort' => $sort, 'filter' => $filter, 'limit' => $config->get('layout_featuredpost_limit', $limit), 'featured' => true);
         $featured = $postModel->getDiscussions($options);
         if (is_null($featured)) {
             $featured = array();
         }
     }
     // Get normal discussion posts.
     $options = array('sort' => $sort, 'category' => $cats, 'filter' => $filter, 'limit' => $limit, 'featured' => false);
     $posts = $postModel->getDiscussions($options);
     if (is_null($posts)) {
         $posts = array();
     }
     $authorIds = array();
     $topicIds = array();
     $tmpPostsArr = array_merge($featured, $posts);
     if (count($tmpPostsArr) > 0) {
         foreach ($tmpPostsArr as $tmpArr) {
             $authorIds[] = $tmpArr->user_id;
             $topicIds[] = $tmpArr->id;
         }
     }
     $pagination = $postModel->getPagination(0, 'latest', '', $cats, false);
     $postLoader = EDC::getTable('Posts');
     $postLoader->loadBatch($topicIds);
     $postTagsModel = EDC::getModel('PostsTags');
     $postTagsModel->setPostTagsBatch($topicIds);
     $model = EDC::getModel('Posts');
     $lastReplyUser = $model->setLastReplyBatch($topicIds);
     // Reduce SQL queries by pre-loading all author object.
     $authorIds = array_merge($lastReplyUser, $authorIds);
     $authorIds = array_unique($authorIds);
     // Initialize the list of user's so we run lesser sql queries.
     $profile = EDC::getTable('Profile');
     $profile->init($authorIds);
     // Format featured entries.
     $featured = EDC::formatPost($featured, false, true);
     // Format normal entries
     $posts = EDC::formatPost($posts, false, true);
     // Get unread count
     $unreadCount = $model->getUnreadCount($cats, false);
     // Get unresolved count
     // Change the "all" to TRUE or FALSE to include/exclude featured post count
     $unresolvedCount = $model->getUnresolvedCount('', $cats, '', 'all');
     // Get resolved count
     $resolvedCount = $model->getTotalResolved();
     // Get unanswered count
     $unansweredCount = EDC::getUnansweredCount($cats, true);
     // Get assigned post count that isn't answered yet.
     $assignedCount = 0;
     if (EDC::isSiteAdmin() || EDC::isModerator()) {
         $assignedModel = EDC::getModel('Assigned');
         $assignedCount = $assignedModel->getTotalUnresolved();
     }
     $activeFilter = $config->get('layout_frontpage_sorting');
     // Let's render the layout now.
     $theme = new DiscussThemes();
     $theme->set('assignedCount', $assignedCount);
     $theme->set('activeFilter', $activeFilter);
     $theme->set('activeSort', $sort);
     $theme->set('categories', $categoryId);
     $theme->set('unreadCount', $unreadCount);
     $theme->set('unansweredCount', $unansweredCount);
     $theme->set('resolvedCount', $resolvedCount);
     $theme->set('unresolvedCount', $unresolvedCount);
     $theme->set('posts', $posts);
     $theme->set('featured', $featured);
     $theme->set('pagination', $pagination);
     echo $theme->fetch('frontpage.index.php');
 }
Пример #20
0
 /**
  * We cannot rely on PHP's Foundry object here because this might be called through CLI
  *
  * @since	1.0
  * @access	public
  * @param	string
  * @return
  */
 public function getView($name)
 {
     $name = str_replace('easydiscuss/', '', $name);
     if (defined('EASYDISCUSS_COMPONENT_CLI')) {
         // Break down the namespace to segments
         $segments = explode('/', $name);
         // Determine the current location
         $location = $segments[0];
         unset($segments[0]);
         // @TODO: We should read the db and see which is the default theme
         if ($segments[0] == 'media') {
             $path = JPATH_ROOT . '/media/com_easydiscuss/scripts/media';
         } else {
             $path = JPATH_ROOT . '/components/com_easydiscuss/themes/simplistic';
         }
         $path = $path . '/' . implode('/', $segments) . '.ejs';
         jimport('joomla.filesystem.file');
         if (!JFile::exists($path)) {
             return '';
         }
         ob_start();
         include $path;
         $contents = ob_get_contents();
         ob_end_clean();
     } else {
         jimport('joomla.filesystem.file');
         $path = JPATH_ROOT . '/components/com_easydiscuss/themes/simplistic/' . $name . '.ejs';
         $system = new stdClass();
         $system->config = DiscussHelper::getConfig();
         ob_start();
         include $path;
         $contents = ob_get_contents();
         ob_end_clean();
         $template = new DiscussThemes();
         $contents = $template->fetch($name . '.ejs');
     }
     return $contents;
 }
Пример #21
0
 public function filter($viewtype = 'user-post', $profileId = null)
 {
     $ajax = new Disjax();
     $mainframe = JFactory::getApplication();
     $config = DiscussHelper::getConfig();
     $acl = DiscussHelper::getHelper('ACL');
     $sort = 'latest';
     $data = null;
     $pagination = null;
     $model = $this->getModel('Posts');
     $tagsModel = $this->getModel('Tags');
     switch ($viewtype) {
         case 'user-achievements':
             $profile = DiscussHelper::getTable('Profile');
             $profile->load($profileId);
             $data = $profile->getBadges();
             break;
         case 'user-tags':
             $data = $tagsModel->getTagCloud('', '', '', $profileId);
             break;
         case 'user-replies':
             $data = $model->getRepliesFromUser($profileId);
             $pagination = $model->getPagination();
             DiscussHelper::formatPost($data);
             break;
         case 'user-unresolved':
             $data = $model->getUnresolvedFromUser($profileId);
             $pagination = $model->getPagination();
             DiscussHelper::formatPost($data);
             break;
         case 'user-post':
         default:
             if (is_null($profileId)) {
                 break;
             }
             $model = $this->getModel('Posts');
             $data = $model->getPostsBy('user', $profileId);
             $data = DiscussHelper::formatPost($data);
             $pagination = $model->getPagination();
             break;
     }
     // replace the content
     $content = '';
     $tpl = new DiscussThemes();
     $tpl->set('profileId', $profileId);
     if ($viewtype == 'user-post' || $viewtype == 'user-replies' || $viewtype == 'user-unresolved') {
         $nextLimit = DiscussHelper::getListLimit();
         if ($nextLimit >= $pagination->total) {
             // $ajax->remove( 'dc_pagination' );
             $ajax->assign($viewtype . ' #dc_pagination', '');
         }
         $tpl->set('posts', $data);
         $content = $tpl->fetch('main.item.php');
         $ajax->assign($viewtype . ' #dc_list', $content);
         //reset the next start limi
         $ajax->value('pagination-start', $nextLimit);
         if ($nextLimit < $pagination->total) {
             $filterArr = array();
             $filterArr['viewtype'] = $viewtype;
             $filterArr['id'] = $profileId;
             $ajax->assign($viewtype . ' #dc_pagination', $pagination->getPagesLinks('profile', $filterArr, true));
         }
     } else {
         if ($viewtype == 'user-tags') {
             $tpl->set('tagCloud', $data);
             $content = $tpl->fetch('tags.item.php');
             $ajax->assign('discuss-tag-list', $content);
         } else {
             if ($viewtype == 'user-achievements') {
                 $tpl->set('badges', $data);
                 $content = $tpl->fetch('users.achievements.list.php');
                 $ajax->assign('user-achievements', $content);
             }
         }
     }
     $ajax->script('discuss.spinner.hide( "profile-loading" );');
     //$ajax->assign( 'sort-wrapper' , $sort );
     //$ajax->script( 'EasyDiscuss.$("#pagination-filter").val("'.$viewtype.'");');
     $ajax->script('EasyDiscuss.$("#' . $viewtype . '").show();');
     $ajax->script('EasyDiscuss.$("#' . $viewtype . ' #dc_pagination").show();');
     $ajax->send();
 }
Пример #22
0
 public function getFields()
 {
     // select top 20 tags.
     $tagmodel = DiscussHelper::getModel('Tags');
     $tags = $tagmodel->getTagCloud('', 'post_count', 'DESC');
     $theme = new DiscussThemes();
     $theme->set('tags', $tags);
     $theme->set('composer', $this);
     $theme->set('post', $this->post);
     $theme->set('parent', $this->parent);
     $theme->set('isDiscussion', $this->isDiscussion);
     $theme->set('renderMode', $this->renderMode);
     return $theme->fetch('form.tabs.php');
 }
Пример #23
0
 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');
 }
Пример #24
0
 /**
  * Displays a list of voters on the site.
  *
  * @since	3.0
  */
 public function showVoters($id)
 {
     // Allow users to see who voted on the discussion
     $ajax = new Disjax();
     $config = DiscussHelper::getConfig();
     $my = JFactory::getUser();
     // If main_allowguestview_whovoted is lock
     if (!$config->get('main_allowguestview_whovoted') && !$my->id) {
         $ajax->reject(JText::_('COM_EASYDISCUSS_NOT_ALLOWED_HERE'));
         return $ajax->send();
     }
     $voteModel = DiscussHelper::getModel('Votes');
     $voters = $voteModel->getVoters($id);
     $guests = 0;
     $users = array();
     if ($voters) {
         foreach ($voters as $voter) {
             if (!$voter->user_id) {
                 $guests += 1;
             } else {
                 $profile = DiscussHelper::getTable('Profile');
                 $users[] = $profile->load($voter->user_id);
             }
         }
     }
     $options = new stdClass();
     $options->title = JText::_('COM_EASYDISCUSS_VIEWING_VOTERS_TITLE');
     $theme = new DiscussThemes();
     $theme->set('users', $users);
     $theme->set('guests', $guests);
     $content = $theme->fetch('voters.php', array('dialog' => true));
     $options->content = $content;
     $buttons = array();
     $button = new stdClass();
     $button->title = JText::_('COM_EASYDISCUSS_BUTTON_CLOSE');
     $button->action = 'disjax.closedlg();';
     $buttons[] = $button;
     $options->buttons = $buttons;
     $ajax->dialog($options);
     return $ajax->send();
 }
Пример #25
0
 /**
  * Displays a list of recent discussions from a particular category.
  *
  * @since	3.0
  * @access	public
  */
 public function listings()
 {
     // Initialise variables
     $doc = JFactory::getDocument();
     $my = JFactory::getUser();
     $config = DiscussHelper::getConfig();
     $app = JFactory::getApplication();
     $registry = DiscussHelper::getRegistry();
     $categoryId = JRequest::getInt('category_id', 0);
     // Try to detect if there's any category id being set in the menu parameter.
     $activeMenu = $app->getMenu()->getActive();
     if ($activeMenu) {
         // Load menu params to the registry.
         $registry->loadString($activeMenu->params);
         // Set the active category id if exists.
         $categoryId = $registry->get('category_id') ? $registry->get('category_id') : $categoryId;
     }
     // Get the current logged in user's access.
     $acl = DiscussHelper::getHelper('ACL');
     // Todo: Perhaps we should fix the confused naming of filter and sort to type and sort
     $activeFilter = JRequest::getString('filter', $registry->get('filter'));
     $sort = JRequest::getString('sort', $registry->get('sort'));
     // Get the pagination limit
     $limit = $registry->get('limit');
     $limit = $limit == '-2' ? DiscussHelper::getListLimit() : $limit;
     $limit = $limit == '-1' ? DiscussHelper::getJConfig()->get('list_limit') : $limit;
     // Get the active category id if there is any
     $activeCategory = DiscussHelper::getTable('Category');
     $activeCategory->load($categoryId);
     DiscussHelper::setPageTitle($activeCategory->title);
     // Add breadcrumbs for active category.
     if ($activeCategory->id != 0) {
         // Test if user is really allowed to access this category.
         if (!$activeCategory->canAccess()) {
             $app->redirect(DiscussRouter::_('index.php?option=com_easydiscuss&view=index', false), JText::_('COM_EASYDISCUSS_SYSTEM_INSUFFICIENT_PERMISSIONS'));
             $app->close();
             return;
         }
         // Add pathway for category here.
         DiscussHelper::getHelper('Pathway')->setCategoryPathway($activeCategory);
     }
     // Add view to this page.
     $this->logView();
     // Set the meta of the page.
     DiscussHelper::setMeta();
     $doc = JFactory::getDocument();
     $doc->setMetadata('description', strip_tags($activeCategory->getDescription()));
     // Add rss feed into headers
     DiscussHelper::getHelper('Feeds')->addHeaders('index.php?option=com_easydiscuss&view=index');
     // Get list of categories on the site.
     $catModel = $this->getModel('Categories');
     // Pagination is by default disabled.
     $pagination = false;
     if ($categoryId) {
         $category = DiscussHelper::getTable('Category');
         $category->load($categoryId);
         $categories[] = $category;
     } else {
         $categories = $catModel->getCategories($categoryId);
         if (count($categories) > 1) {
             $ids = array();
             foreach ($categories as $row) {
                 $ids[] = $row->id;
             }
             // iniCounts should only called in index page.
             $category = DiscussHelper::getTable('Category');
             $category->initCounts($ids, true);
         }
     }
     // Get the model.
     $postModel = DiscussHelper::getModel('Posts');
     $authorIds = array();
     $topicIds = array();
     for ($i = 0; $i < count($categories); $i++) {
         $category =& $categories[$i];
         // building category childs lickage.
         $category->childs = null;
         $nestedLinks = '';
         // In category page
         if ($config->get('layout_show_all_subcategories', '1')) {
             // By default show all the subcategories of the selected category
             DiscussHelper::buildNestedCategories($category->id, $category, false, true);
         } else {
             // Show one level of subcategories of the selected category only
             $category->childs = $catModel->getChildCategories($category->id);
         }
         DiscussHelper::accessNestedCategories($category, $nestedLinks, '0', '', 'listlink', ', ');
         $category->nestedLink = $nestedLinks;
         // Get featured posts from this particular category.
         $featured = $postModel->getDiscussions(array('pagination' => false, 'sort' => $sort, 'filter' => $activeFilter, 'category' => $category->id, 'limit' => $config->get('layout_featuredpost_limit', $limit), 'featured' => true));
         // Get normal discussion posts.
         $posts = $postModel->getDiscussions(array('sort' => $sort, 'filter' => $activeFilter, 'category' => $category->id, 'limit' => $limit, 'featured' => false));
         $tmpPostsArr = array_merge($featured, $posts);
         if (count($tmpPostsArr) > 0) {
             foreach ($tmpPostsArr as $tmpArr) {
                 $authorIds[] = $tmpArr->user_id;
                 $topicIds[] = $tmpArr->id;
             }
         }
         if ($categoryId) {
             $pagination = $postModel->getPagination(0, 'latest', '', $categoryId, false);
         }
         // Set these items into the category object.
         $category->featured = $featured;
         $category->posts = $posts;
         // Set active filter for the category
         $category->activeFilter = $activeFilter;
         $category->activeSort = $sort;
     }
     $lastReplyUser = $postModel->setLastReplyBatch($topicIds);
     $authorIds = array_merge($lastReplyUser, $authorIds);
     // load all author object 1st.
     $authorIds = array_unique($authorIds);
     $profile = DiscussHelper::getTable('Profile');
     $profile->init($authorIds);
     $postLoader = DiscussHelper::getTable('Posts');
     $postLoader->loadBatch($topicIds);
     $postTagsModel = DiscussHelper::getModel('PostsTags');
     $postTagsModel->setPostTagsBatch($topicIds);
     // perform data formating here.
     for ($i = 0; $i < count($categories); $i++) {
         $category =& $categories[$i];
         // perform data formating here.
         if ($category->featured) {
             $category->featured = DiscussHelper::formatPost($category->featured, false, true);
         }
         if ($category->posts) {
             $category->posts = DiscussHelper::formatPost($category->posts, false, true);
         }
     }
     // Let's render the layout now.
     $theme = new DiscussThemes();
     $theme->set('activeFilter', $activeFilter);
     $theme->set('activeSort', $sort);
     $theme->set('categories', $categories);
     $theme->set('pagination', $pagination);
     echo $theme->fetch('frontpage.php');
 }
Пример #26
0
 public function getTemplate($name = null, $vars = array())
 {
     $theme = new DiscussThemes();
     if (!empty($vars)) {
         foreach ($vars as $key => $value) {
             $theme->set($key, $value);
         }
     }
     $ajax = new Disjax();
     $option = new stdClass();
     $option->content = $theme->fetch($name, array('dialog' => true));
     $ajax->dialog($option);
     $ajax->send();
 }
Пример #27
0
 /**
  * Renders a module position in the template
  */
 public static function renderModule($position, $attributes = array(), $content = null)
 {
     jimport('joomla.application.module.helper');
     $doc = JFactory::getDocument();
     $renderer = $doc->loadRenderer('module');
     $buffer = '';
     $modules = JModuleHelper::getModules($position);
     foreach ($modules as $module) {
         $theme = new DiscussThemes();
         $theme->set('position', $position);
         $theme->set('output', $renderer->render($module, $attributes, $content));
         $buffer .= $theme->fetch('modules.item.php');
     }
     return $buffer;
 }
Пример #28
0
 /**
  * Displays the user editing form
  *
  * @since	1.0
  * @access	public
  * @return
  */
 public function edit($tmpl = null)
 {
     require_once DISCUSS_HELPERS . '/integrate.php';
     $document = JFactory::getDocument();
     $mainframe = JFactory::getApplication();
     $user = JFactory::getUser();
     $config = DiscussHelper::getConfig();
     if (empty($user->id)) {
         $mainframe->enqueueMessage(JText::_('COM_EASYDISCUSS_YOU_MUST_LOGIN_FIRST'), 'error');
         $mainframe->redirect(DiscussRouter::_('index.php?option=com_easydiscuss&view=index'));
         return false;
     }
     $this->setPathway(JText::_('COM_EASYDISCUSS_PROFILE'), DiscussRouter::_('index.php?option=com_easydiscuss&view=profile&id=' . $user->id));
     $this->setPathway(JText::_('COM_EASYDISCUSS_EDIT_PROFILE'));
     //load porfile info and auto save into table if user is not already exist in discuss's user table.
     $profile = DiscussHelper::getTable('Profile');
     $profile->load($user->id);
     $userparams = DiscussHelper::getRegistry($profile->get('params'));
     $siteDetails = DiscussHelper::getRegistry($profile->get('site'));
     $maxSize = ini_get('upload_max_filesize');
     $configMaxSize = $config->get('main_upload_maxsize', 0);
     if ($configMaxSize > 0) {
         // Backend settings is MB
         $configMaxSize = $configMaxSize * 1024 * 1204;
         // We convert to bytes because the function is accepting bytes
         $configMaxSize = DiscussHelper::getHelper('String')->bytesToSize($configMaxSize);
     }
     $avatar_config_path = $config->get('main_avatarpath');
     $avatar_config_path = rtrim($avatar_config_path, '/');
     $avatar_config_path = JString::str_ireplace('/', DIRECTORY_SEPARATOR, $avatar_config_path);
     $croppable = false;
     $allowJFBCAvatarEdit = false;
     if ($config->get('layout_avatarIntegration') == 'default') {
         $original = JPATH_ROOT . '/' . rtrim($config->get('main_avatarpath'), '/') . '/' . 'original_' . $profile->avatar;
         if (JFile::exists($original)) {
             $size = getimagesize($original);
             $width = $size[0];
             $height = $size[1];
             $configAvatarWidth = $config->get('layout_avatarwidth', 160);
             $configAvatarHeight = $config->get('layout_avatarheight', 160);
             if ($width >= $configAvatarWidth && $height >= $configAvatarHeight) {
                 $croppable = true;
             }
         }
     } else {
         if ($config->get('layout_avatarIntegration') == 'jfbconnect') {
             $integrate = new DiscussIntegrate();
             $hasAvatar = $integrate::jfbconnect($profile);
             if (!$hasAvatar) {
                 $croppable = true;
                 $allowJFBCAvatarEdit = true;
             }
         }
     }
     $tpl = new DiscussThemes();
     $tpl->set('croppable', $croppable);
     $tpl->set('allowJFBCAvatarEdit', $allowJFBCAvatarEdit);
     $tpl->set('size', $maxSize);
     $tpl->set('user', $user);
     $tpl->set('profile', $profile);
     $tpl->set('config', $config);
     $tpl->set('configMaxSize', $configMaxSize);
     $tpl->set('avatarIntegration', $config->get('layout_avatarIntegration', 'default'));
     $tpl->set('userparams', $userparams);
     $tpl->set('siteDetails', $siteDetails);
     echo $tpl->fetch('form.user.edit.php');
 }
Пример #29
0
 public function getResourcesSettings()
 {
     $config = DiscussHelper::getConfig();
     // Build a deterministic cache
     $settings = array("language" => JFactory::getLanguage()->getTag(), "template" => array("site" => $config->get('layout_theme')), "view" => array(), "modified" => filemtime($this->resourceManifestFile));
     // Get manifest
     $manifest = $this->getResourcesManifest();
     if (isset($manifest[0]->view) && $manifest[0]->view) {
         foreach ($manifest[0]->view as $view) {
             $theme = new DiscussThemes();
             $path = $theme->resolve($view . '.ejs');
             // If the file still does not exist, we'll skip this
             if (!JFile::exists($path)) {
                 continue;
             }
             $settings["view"][] = array("path" => str_ireplace(JPATH_ROOT, '', $path), "modified" => filemtime($path));
         }
     }
     // Build hash
     $settings["id"] = md5(serialize($settings));
     return $settings;
 }
Пример #30
0
 /**
  * Merges the current discussion into an existing discussion
  *
  * @since   1.0
  * @access  public
  * @param   string
  * @return
  */
 public function mergeForm($id)
 {
     $ajax = new Disjax();
     $model = DiscussHelper::getModel('Posts');
     $posts = $model->getDiscussions(array('limit' => DISCUSS_NO_LIMIT, 'exclude' => array($id)));
     $theme = new DiscussThemes();
     $theme->set('posts', $posts);
     $theme->set('current', $id);
     $content = $theme->fetch('ajax.post.merge.php', array('dialog' => true));
     $options = new stdClass();
     $options->content = $content;
     $options->title = JText::_('COM_EASYDISCUSS_MERGE_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_MERGE');
     $button->form = '#frmMergePost';
     $button->className = 'btn-primary';
     $buttons[] = $button;
     $options->buttons = $buttons;
     $ajax->dialog($options);
     $ajax->send();
 }