Beispiel #1
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');
 }
    return;
}
require_once $path;
// require_once (dirname(__FILE__) . '/helper.php');
DiscussHelper::loadStylesheet("module", "mod_easydiscuss_your_discussions");
$my = JFactory::getUser();
$config = DiscussHelper::getConfig();
$profile = DiscussHelper::getTable('Profile');
$profile->load($my->id);
$postsModel = DiscussHelper::getModel('Posts');
$count = $params->get('count', 5);
$posts = array();
$posts = $postsModel->getPostsBy('user', $profile->id, 'latest', '0', '', '', $count);
$posts = DiscussHelper::formatPost($posts);
if (!empty($posts)) {
    $posts = Discusshelper::getPostStatusAndTypes($posts);
    // foreach( $posts as $post )
    // {
    // 	// Translate post status from integer to string
    // 	switch( $post->post_status )
    // 	{
    // 		case '0':
    // 			$post->post_status = '';
    // 			break;
    // 		case '1':
    // 			$post->post_status = JText::_( 'COM_EASYDISCUSS_POST_STATUS_ON_HOLD' );
    // 			break;
    // 		case '2':
    // 			$post->post_status = JText::_( 'COM_EASYDISCUSS_POST_STATUS_ACCEPTED' );
    // 			break;
    // 		case '3':
Beispiel #3
0
 public function tab()
 {
     // always reset the limitstart.
     JRequest::setVar('limitstart', 0);
     $type = JRequest::getVar('type');
     $profileId = JRequest::getVar('id');
     $ajax = DiscussHelper::getHelper('ajax');
     $model = DiscussHelper::getModel('Posts');
     $tagsModel = DiscussHelper::getModel('Tags');
     $config = DiscussHelper::getConfig();
     $template = new DiscussThemes();
     $html = '';
     $pagination = null;
     switch ($type) {
         case 'tags':
             $tags = $tagsModel->getTagCloud('', '', '', $profileId);
             $template->set('tags', $tags);
             $html = $template->fetch('profile.tags.php');
             break;
         case 'questions':
             $posts = $model->getPostsBy('user', $profileId);
             $posts = DiscussHelper::formatPost($posts);
             $pagination = $model->getPagination();
             $template->set('posts', $posts);
             $html = $template->fetch('profile.questions.php');
             break;
         case 'unresolved':
             $posts = $model->getUnresolvedFromUser($profileId);
             $posts = DiscussHelper::formatPost($posts);
             $pagination = $model->getPagination();
             $posts = Discusshelper::getPostStatusAndTypes($posts);
             $template->set('posts', $posts);
             $html = $template->fetch('profile.unresolved.php');
             break;
         case 'favourites':
             if (!$config->get('main_favorite')) {
                 return false;
             }
             $posts = $model->getData(true, 'latest', null, 'favourites', '', null, 'all', $profileId);
             $posts = DiscussHelper::formatPost($posts);
             $posts = Discusshelper::getPostStatusAndTypes($posts);
             $template->set('posts', $posts);
             $html = $template->fetch('profile.favourites.php');
             break;
         case 'replies':
             $posts = $model->getRepliesFromUser($profileId);
             $posts = DiscussHelper::formatPost($posts);
             $pagination = $model->getPagination();
             $posts = Discusshelper::getPostStatusAndTypes($posts);
             $template->set('posts', $posts);
             $html = $template->fetch('profile.replies.php');
             break;
         case 'tabEasyBlog':
             $helperFile = JPATH_ROOT . '/components/com_easyblog/helpers/helper.php';
             if (!JFile::exists($helperFile)) {
                 $html = JText::_('COM_EASYDISCUSS_EASYBLOG_DOES_NOT_EXIST');
             } else {
                 require_once $helperFile;
                 require_once JPATH_ROOT . '/components/com_easyblog/router.php';
                 $blogModel = EasyBlogHelper::getModel('Blog');
                 $blogs = $blogModel->getBlogsBy('blogger', $profileId);
                 $blogs = EasyBlogHelper::formatBlog($blogs);
                 $ebConfig = EasyBlogHelper::getConfig();
                 $user = JFactory::getUser($profileId);
                 $template->set('user', $user);
                 $template->set('ebConfig', $ebConfig);
                 $template->set('blogs', $blogs);
                 // Load EasyBlog's language file
                 JFactory::getLanguage()->load('com_easyblog', JPATH_ROOT);
                 $html = $template->fetch('profile.blogs.php');
             }
             break;
         case 'tabKomento':
             $helperFile = JPATH_ROOT . '/components/com_komento/helpers/helper.php';
             if (!JFile::exists($helperFile)) {
                 $html = JText::_('COM_EASYDISCUSS_KOMENTO_DOES_NOT_EXIST');
             } else {
                 require_once $helperFile;
                 $commentsModel = Komento::getModel('comments');
                 $commentHelper = Komento::getHelper('comment');
                 $options = array('sort' => 'latest', 'userid' => $profileId, 'threaded' => 0);
                 $comments = $commentsModel->getComments('all', 'all', $options);
                 foreach ($comments as &$comment) {
                     $comment = $commentHelper->process($comment);
                 }
                 $feedUrl = Komento::getHelper('router')->getFeedUrl('all', 'all', $profileId);
                 JFactory::getLanguage()->load('com_komento', JPATH_ROOT);
                 $template->set('feedUrl', $feedUrl);
                 $template->set('comments', $comments);
                 $html = $template->fetch('profile.comments.php');
             }
             break;
         case 'subscriptions':
             $subModel = DiscussHelper::getModel('subscribe');
             $rows = $subModel->getSubscriptions();
             $subs = array();
             if ($rows) {
                 foreach ($rows as $row) {
                     $obj = new stdClass();
                     $obj->id = $row->id;
                     $obj->type = $row->type;
                     $obj->unsublink = Discusshelper::getUnsubscribeLink($row, false);
                     switch ($row->type) {
                         case 'site':
                             $obj->title = '';
                             $obj->link = '';
                             break;
                         case 'post':
                             $post = DiscussHelper::getTable('Post');
                             $post->load($row->cid);
                             $obj->title = $post->title;
                             $obj->link = DiscussRouter::_('index.php?option=com_easydiscuss&view=post&id=' . $post->id);
                             break;
                         case 'category':
                             $category = DiscussHelper::getTable('Category');
                             $category->load($row->cid);
                             $obj->title = $category->title;
                             $obj->link = DiscussRouter::getCategoryRoute($category->id);
                             break;
                         case 'user':
                             $profile = DiscussHelper::getTable('Profile');
                             $profile->load($row->cid);
                             $obj->title = $profile->getName();
                             $obj->link = $profile->getLink();
                             break;
                         default:
                             unset($obj);
                             break;
                     }
                     if (!empty($obj)) {
                         $obj->title = DiscussStringHelper::escape($obj->title);
                         $subs[$row->type][] = $obj;
                         unset($obj);
                     }
                 }
             }
             $template->set('subscriptions', $subs);
             $html = $template->fetch('profile.subscriptions.php');
             break;
         default:
             break;
     }
     if ($pagination) {
         $filterArr = array();
         $filterArr['viewtype'] = $type;
         $filterArr['id'] = $profileId;
         $pagination = $pagination->getPagesLinks('profile', $filterArr, true);
     }
     $ajax->success($html, $pagination);
     $ajax->send();
 }
Beispiel #4
0
 /**
  * Displays the user's profile.
  *
  * @since	2.0
  * @access	public
  */
 function display($tmpl = null)
 {
     $doc = JFactory::getDocument();
     $app = JFactory::getApplication();
     $id = JRequest::getInt('id', null);
     $my = JFactory::getUser($id);
     $config = DiscussHelper::getConfig();
     // Custom parameters.
     $sort = JRequest::getString('sort', 'latest');
     $filteractive = JRequest::getString('filter', 'allposts');
     $viewType = JRequest::getString('viewtype', 'questions');
     $profile = DiscussHelper::getTable('Profile');
     $profile->load($my->id);
     // If profile is invalid, throw an error.
     if (!$profile->id) {
         // Show login form.
         $theme = new DiscussThemes();
         $theme->set('redirect', DiscussRouter::_('index.php?option=com_easydiscuss&view=profile', false));
         echo $theme->fetch('login.form.php');
         return;
     }
     $params = DiscussHelper::getRegistry($profile->params);
     $fields = array('facebook', 'linkedin', 'twitter', 'website');
     foreach ($fields as $site) {
         if ($params->get($site, '') != '') {
             if ($site == 'facebook' || $site == 'linkedin' || $site == 'twitter') {
                 $name = $params->get($site);
                 $url = 'www.' . $site . '.com/' . $name;
                 $params->set($site, DiscussUrlHelper::clean($url));
             }
             if ($site == 'website') {
                 $url = $params->get($site);
                 $params->set($site, DiscussUrlHelper::clean($url));
             }
         }
     }
     // Set the title for the page.
     DiscussHelper::setPageTitle(JText::sprintf('COM_EASYDISCUSS_PROFILE_PAGE_TITLE', $profile->getName()));
     // Set the pathway
     $this->setPathway(JText::_($profile->getName()));
     $postsModel = DiscussHelper::getModel('Posts');
     $tagsModel = DiscussHelper::getModel('Tags');
     $posts = array();
     $replies = array();
     $tagCloud = array();
     $badges = array();
     $unresolved = array();
     $pagination = null;
     $filterArr = array();
     $filterArr['viewtype'] = $viewType;
     $filterArr['id'] = $profile->id;
     switch ($viewType) {
         case 'replies':
             $replies = $postsModel->getRepliesFromUser($profile->id);
             $pagination = $postsModel->getPagination();
             $pagination = $pagination->getPagesLinks('profile', $filterArr, true);
             $replies = DiscussHelper::formatPost($replies);
             break;
         case 'unresolved':
             $unresolved = $postsModel->getUnresolvedFromUser($profile->id);
             $pagination = $postsModel->getPagination();
             $pagination = $pagination->getPagesLinks('profile', $filterArr, true);
             $unresolved = DiscussHelper::formatPost($unresolved);
             break;
         case 'questions':
         default:
             $posts = $postsModel->getPostsBy('user', $profile->id);
             $pagination = $postsModel->getPagination();
             $pagination = $pagination->getPagesLinks('profile', $filterArr, true);
             $posts = DiscussHelper::formatPost($posts);
             break;
     }
     // Get user badges
     $badges = $profile->getBadges();
     // @rule: Clear up any notifications that are visible for the user.
     $notifications = DiscussHelper::getModel('Notification');
     $notifications->markRead($profile->id, false, array(DISCUSS_NOTIFICATIONS_PROFILE, DISCUSS_NOTIFICATIONS_BADGE));
     $tpl = new DiscussThemes();
     // EasyBlog integrations
     $easyblogExists = $this->easyblogExists();
     $blogCount = 0;
     if ($easyblogExists && $config->get('integrations_easyblog_profile')) {
         $blogModel = EasyBlogHelper::getModel('Blog');
         $blogCount = $blogModel->getBlogPostsCount($profile->id, false);
     }
     $komentoExists = $this->komentoExists();
     $commentCount = 0;
     if ($komentoExists && $config->get('integrations_komento_profile')) {
         $commentsModel = Komento::getModel('comments');
         $commentCount = $commentsModel->getTotalComment($profile->id);
     }
     $posts = Discusshelper::getPostStatusAndTypes($posts);
     $favPosts = $postsModel->getData('true', 'latest', 'null', 'favourites');
     $favPosts = DiscussHelper::formatPost($favPosts);
     $tpl->set('sort', $sort);
     $tpl->set('filter', $filteractive);
     $tpl->set('tagCloud', $tagCloud);
     $tpl->set('paginationType', DISCUSS_USERQUESTIONS_TYPE);
     $tpl->set('parent_id', $profile->id);
     $tpl->set('pagination', $pagination);
     $tpl->set('posts', $posts);
     $tpl->set('badges', $badges);
     $tpl->set('favPosts', $favPosts);
     $tpl->set('profile', $profile);
     $tpl->set('replies', $replies);
     $tpl->set('unresolved', $unresolved);
     $tpl->set('params', $params);
     $tpl->set('viewType', $viewType);
     $tpl->set('easyblogExists', $easyblogExists);
     $tpl->set('komentoExists', $komentoExists);
     $tpl->set('blogCount', $blogCount);
     $tpl->set('commentCount', $commentCount);
     $filterArr = array();
     $filterArr['filter'] = $filteractive;
     $filterArr['id'] = $profile->id;
     $filterArr['sort'] = $sort;
     $filterArr['viewtype'] = $viewType;
     $tpl->set('filterArr', $filterArr);
     $tpl->set('page', 'profile');
     echo $tpl->fetch('profile.php');
 }
Beispiel #5
0
 public function tag($tmpl = null)
 {
     //initialise variables
     $mainframe = JFactory::getApplication();
     $doc = JFactory::getDocument();
     $user = JFactory::getUser();
     $config = DiscussHelper::getConfig();
     $tag = JRequest::getInt('id', 0);
     if (empty($tag)) {
         return JError::raiseError(404, JText::_('COM_EASYDISCUSS_INVALID_TAG'));
     }
     DiscussHelper::setMeta();
     $table = DiscussHelper::getTable('Tags');
     $table->load($tag);
     $doc = JFactory::getDocument();
     DiscussHelper::setPageTitle(JText::sprintf('COM_EASYDISCUSS_VIEWING_TAG_TITLE', $this->escape($table->title)));
     $this->setPathway(JText::_($table->title));
     $concatCode = DiscussHelper::getJConfig()->getValue('sef') ? '?' : '&';
     $doc->addHeadLink(JRoute::_('index.php?option=com_easydiscuss&view=tags&id=' . $tag) . $concatCode . 'format=feed&type=rss', 'alternate', 'rel', array('type' => 'application/rss+xml', 'title' => 'RSS 2.0'));
     $doc->addHeadLink(JRoute::_('index.php?option=com_easydiscuss&view=tags&id=' . $tag) . $concatCode . 'format=feed&type=atom', 'alternate', 'rel', array('type' => 'application/atom+xml', 'title' => 'Atom 1.0'));
     $filteractive = JRequest::getString('filter', 'allposts');
     $sort = JRequest::getString('sort', 'latest');
     if ($filteractive == 'unanswered' && ($sort == 'active' || $sort == 'popular')) {
         //reset the active to latest.
         $sort = 'latest';
     }
     $postModel = DiscussHelper::getModel('Posts');
     $posts = $postModel->getTaggedPost($tag, $sort, $filteractive);
     $pagination = $postModel->getPagination($sort, $filteractive);
     $authorIds = array();
     $topicIds = array();
     if (count($posts) > 0) {
         foreach ($posts as $item) {
             $authorIds[] = $item->user_id;
             $topicIds[] = $item->id;
         }
     }
     $lastReplyUser = $postModel->setLastReplyBatch($topicIds);
     $authorIds = array_merge($lastReplyUser, $authorIds);
     // Reduce SQL queries by pre-loading all author object.
     $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);
     $posts = DiscussHelper::formatPost($posts, false, true);
     $currentTag = $table->title;
     $posts = Discusshelper::getPostStatusAndTypes($posts);
     $tpl = new DiscussThemes();
     $tpl->set('rssLink', JRoute::_('index.php?option=com_easydiscuss&view=tags&id=' . $tag . '&format=feed'));
     $tpl->set('posts', $posts);
     $tpl->set('paginationType', DISCUSS_TAGS_TYPE);
     $tpl->set('pagination', $pagination);
     $tpl->set('sort', $sort);
     $tpl->set('filter', $filteractive);
     $tpl->set('showEmailSubscribe', true);
     $tpl->set('currentTag', $currentTag);
     $tpl->set('parent_id', $tag);
     $tpl->set('config', $config);
     echo $tpl->fetch('tag.php');
 }