public function load($cid)
 {
     static $instances = array();
     if (!isset($instances[$cid])) {
         $this->_item = EB::post($cid);
         if (!$this->_item) {
             return $this->onLoadArticleError($cid);
         }
         $blogger = EB::user($this->_item->created_by);
         $this->_item->blogger = $blogger;
         $link = 'index.php?option=com_easyblog&view=entry&id=' . $this->getContentId();
         // forcefully get item id if request is ajax
         $format = JRequest::getString('format', 'html');
         if ($format === 'ajax') {
             $itemid = JRequest::getInt('pageItemId');
             if (!empty($itemid)) {
                 $link .= '&Itemid=' . $itemid;
             }
         }
         $link = EBR::_($link);
         $this->_item->permalink = $this->prepareLink($link);
         $instances[$cid] = $this->_item;
     }
     $this->_item = $instances[$cid];
     return $this;
 }
Example #2
0
 /**
  * Displays a list of voters
  *
  * @since	4.0
  * @access	public
  * @param	string
  * @return
  */
 public function voters()
 {
     // Get the composite keys
     $uid = $this->input->get('uid', 0, 'int');
     $type = $this->input->get('type', '', 'cmd');
     // Get maximum number of voters to show up in the dialog.
     $limit = EB::config()->get('main_ratings_display_raters_max');
     // Get the ratings
     $model = EB::model('Ratings');
     $votes = $model->getRatingUsers($uid, $type, $limit);
     // Determines the total number of guest votes
     $totalGuests = 0;
     // Format the votes
     if ($votes) {
         foreach ($votes as &$vote) {
             $vote->user = false;
             if ($vote->created_by) {
                 $user = EB::user($vote->created_by);
                 $vote->user = $user;
             } else {
                 $totalGuests += 1;
             }
         }
     }
     $theme = EB::template();
     $theme->set('totalGuests', $totalGuests);
     $theme->set('votes', $votes);
     $output = $theme->output('site/ratings/dialog.voters');
     return $this->ajax->resolve($output);
 }
Example #3
0
 public function getAuthor()
 {
     if (!isset($this->author) || is_null($this->author)) {
         $this->author = EB::user($this->created_by);
     }
     return $this->author;
 }
Example #4
0
 public function __construct()
 {
     $this->my = JFactory::getUser();
     $this->app = JFactory::getApplication();
     $this->input = EB::request();
     $this->acl = EB::acl();
     $this->config = EB::config();
     // Set the user project
     $this->user = EB::user($this->my->id);
 }
Example #5
0
 function display($tmpl = null)
 {
     if (!$this->config->get('main_rss')) {
         return;
     }
     $model = EB::model('Blog');
     $data = $model->getFeaturedBlog();
     $document = JFactory::getDocument();
     $document->link = EBR::_('index.php?option=com_easyblog&view=featured');
     $document->setTitle(JText::_('COM_EASYBLOG_FEEDS_FEATURED_TITLE'));
     $document->setDescription(JText::sprintf('COM_EASYBLOG_FEEDS_FEATURED_DESC', JURI::root()));
     if (empty($data)) {
         return;
     }
     $uri = JURI::getInstance();
     $scheme = $uri->toString(array('scheme'));
     $scheme = str_replace('://', ':', $scheme);
     foreach ($data as $row) {
         $blog = EB::table('Blog');
         $blog->load($row->id);
         $profile = EB::user($row->created_by);
         $created = EB::date($row->created);
         $row->created = $created->toSql();
         if ($this->config->get('main_rss_content') == 'introtext') {
             $row->text = !empty($row->intro) ? $row->intro : $row->content;
             //read more for feed
             $row->text .= '<br /><a href=' . EBR::_('index.php?option=com_easyblog&view=entry&id=' . $row->id) . '>Read more</a>';
         } else {
             $row->text = $row->intro . $row->content;
         }
         $row->text = EB::videos()->strip($row->text);
         $row->text = EB::adsense()->stripAdsenseCode($row->text);
         $category = EB::table('Category');
         // Get primary category
         $primaryCategory = $blog->getPrimaryCategory();
         $category->load($primaryCategory->id);
         // Assign to feed item
         $title = $this->escape($row->title);
         $title = html_entity_decode($title);
         // load individual item creator class
         $item = new JFeedItem();
         $item->title = $title;
         $item->link = EBR::_('index.php?option=com_easyblog&view=entry&id=' . $row->id);
         $item->description = $row->text;
         // replace the image source to proper format so that feed reader can view the image correctly.
         $item->description = str_replace('src="//', 'src="' . $scheme . '//', $item->description);
         $item->description = str_replace('href="//', 'href="' . $scheme . '//', $item->description);
         $item->date = $row->created;
         $item->category = $category->getTitle();
         $item->author = $profile->getName();
         $item->authorEmail = $this->getRssEmail($profile);
         $document->addItem($item);
     }
 }
Example #6
0
 public static function getBloggerProfile($userid)
 {
     if (empty($userid)) {
         return false;
     }
     $blogger = EB::user($userid);
     $integrate = new EasyBlogIntegrate();
     $profile = $integrate->integrate($blogger);
     $profile->displayName = $blogger->getName();
     return $profile;
 }
Example #7
0
 /**
  * Retrieves a list of posts created by a list of specified authors.
  *
  * @since	5.0
  * @access	public
  * @param	string
  * @return	
  */
 public static function getPostByBlogger(&$params, $authorId)
 {
     $db = EB::db();
     $config = EB::config();
     // Get the profile of the user.
     $author = EB::user($authorId);
     // Default posts to empty.
     $author->posts = array();
     $author->posts = modLatestBlogsHelper::getLatestPost($params, $author->id, 'blogger');
     return $author;
 }
Example #8
0
 public function _getURL($user, $sizex, $sizey)
 {
     if (!$user->userid == 0) {
         $user = KunenaFactory::getUser($user->userid);
         $user = EB::user($user->userid);
         $avatar = $user->getAvatar();
     } else {
         $avatar = JUri::root(true) . '/components/com_easyblog/assets/images/default_blogger.png';
     }
     return $avatar;
 }
Example #9
0
 public function execute()
 {
     if ($this->cache) {
         //preload posts information
         EB::cache()->insert($this->items);
     }
     // For featured items we wouldn't want to process comments
     $comment = true;
     // For featured items we want to remove featured image
     $removeFeaturedImage = true;
     // For featured items we do not want to load videos
     $video = false;
     // For featured items we do not want to process gallery
     $gallery = false;
     // Ensure that the content does not exceed the introtext limit for featured items
     $contentLimit = $this->config->get('layout_featured_intro_limit');
     $result = array();
     foreach ($this->items as &$item) {
         $blog = EB::post($item->id);
         // Load the author's profile
         $author = EB::user($blog->created_by);
         // @Assign dynamic properties that must exist everytime formatBlog is called
         // We can't rely on ->author because CB plugins would mess things up.
         $blog->author = $author;
         $blog->blogger = $author;
         // Password verifications
         $this->password($blog);
         // Format microblog postings
         if ($blog->posttype) {
             $this->formatMicroblog($blog);
         }
         // Detect if content requires read more link
         $blog->readmore = $this->hasReadmore($blog);
         // // Truncate content
         // $this->truncate($blog);
         // EB::truncateContent($blog, $loadVideo, $frontpage, $loadGallery);
         // Format the content for the featured items
         if (empty($blog->intro)) {
             $blog->intro = $blog->content;
         }
         // We wouldn't want to display html codes in the content
         $blog->intro = strip_tags($blog->intro);
         // Get the content length
         $length = JString::strlen($blog->intro);
         if ($length > $contentLimit) {
             $blog->intro = JString::substr($blog->intro, 0, $contentLimit);
         }
         // Prepare nice date for the featured area
         $blog->date = EB::date($blog->created)->format(JText::_('DATE_FORMAT_LC'));
         $result[] = $blog;
     }
     return $result;
 }
Example #10
0
 public function __construct($overrideTheme = null, $options = array())
 {
     parent::__construct();
     // Determine if this is an admin location
     if (isset($options['admin']) && $options['admin']) {
         $this->admin = true;
     }
     // Determine the configured theme
     $theme = $this->config->get('layout_theme', $overrideTheme);
     // If a view is provided into the theme, the theme files could call methods from a view
     if (isset($options['view']) && is_object($options['view'])) {
         $this->view = $options['view'];
     }
     $this->theme = $theme;
     $obj = new stdClass();
     $obj->config = EB::config();
     $obj->my = JFactory::getUser();
     $obj->admin = EB::isSiteAdmin();
     $obj->profile = EB::user();
     // If it's development mode, allow user to invoke in the url to change theme.
     $environment = $obj->config->get('easyblog_environment');
     if ($environment == 'development') {
         $invokeTheme = $this->input->get('theme', '', 'word');
         if ($invokeTheme) {
             $this->theme = $invokeTheme;
         }
     }
     // If this is entry view, or category view, we need to respect the theme's category
     $this->menu = $this->app->getMenu()->getActive();
     $this->params = new JRegistry();
     // If there is an active menu, try to get the menu parameters.
     if ($this->menu) {
         // Get the params prefix
         $prefix = isset($options['paramsPrefix']) ? $options['paramsPrefix'] : '';
         // Set the current parameters.
         if ($prefix) {
             $model = EB::model('Menu');
             $this->params = $model->getCustomMenuParams($this->menu->id, $this->menu->params, $prefix);
         } else {
             $this->params = $this->menu->params;
         }
         // We will just set it here from the menu when this class first get instantiate.
         // The corresponding view will have to do their own assignment if the view's templates need to access this entryParams
         $this->entryParams = $this->params;
     }
     //is blogger mode flag
     $obj->isBloggerMode = EBR::isBloggerMode();
     $this->my = $obj->my;
     // Assign the acl
     $this->acl = EB::acl();
 }
Example #11
0
 /**
  * Displays the comment output
  *
  * @since	4.0
  * @access	public
  * @param	string
  * @return
  */
 public function html(EasyBlogPost &$blog)
 {
     // Load up template file
     $theme = EB::template();
     // Get comments
     $result = $this->prepareComments($blog);
     $comments = isset($result->comments) ? $result->comments : array();
     $pagination = isset($result->pagination) ? $result->pagination : false;
     // Retrieve the pagination for the blog entry comment view
     $pagination = $pagination->getPagesLinks();
     // Get user's information
     $profile = EB::user($this->my->id);
     // Retrieve blog posts url
     $url = base64_encode($blog->getPermalink());
     // Retrieve login url
     $loginUrl = EB::getLoginLink($url);
     // check if the user has subcribed to this thread
     $subscribed = false;
     if (!$this->my->guest) {
         $model = EB::model('Blog');
         $subscribed = $model->isBlogSubscribedUser($blog->id, $this->my->id, $this->my->email);
     }
     // Determines if the user can register while commenting
     $registration = $this->canRegister();
     $date = EB::date();
     // Determines if we should show the website field
     $website = false;
     if ($this->config->get('comment_show_website') || $this->config->get('comment_required_website')) {
         $website = true;
     }
     // Determines if we should show the email field
     $email = false;
     if ($this->config->get('comment_show_email') || $this->config->get('comment_require_email') || $registration) {
         $email = true;
     }
     $language = JFactory::getLanguage();
     $rtl = $language->isRTL();
     $theme->set('rtl', $rtl);
     $theme->set('email', $email);
     $theme->set('website', $website);
     $theme->set('date', $date);
     $theme->set('user', $profile);
     $theme->set('loginURL', $loginUrl);
     $theme->set('blog', $blog);
     $theme->set('comments', $comments);
     $theme->set('pagination', $pagination);
     $theme->set('registration', $registration);
     $theme->set('subscribed', $subscribed);
     $output = $theme->output('site/comments/default');
     return $output;
 }
Example #12
0
 public function execute()
 {
     if ($this->cache) {
         //preload posts information
         EB::cache()->insert($this->items);
     }
     // For featured items we wouldn't want to process comments
     $comment = true;
     // For featured items we want to remove featured image
     $removeFeaturedImage = true;
     // For featured items we do not want to load videos
     $video = false;
     // For featured items we do not want to process gallery
     $gallery = false;
     // Ensure that the content does not exceed the introtext limit for featured items
     $contentLimit = $this->config->get('layout_featured_intro_limit');
     $result = array();
     foreach ($this->items as &$item) {
         $blog = EB::post($item->id);
         // Load the author's profile
         $author = EB::user($blog->created_by);
         // @Assign dynamic properties that must exist everytime formatBlog is called
         // We can't rely on ->author because CB plugins would mess things up.
         $blog->author = $author;
         $blog->blogger = $author;
         // Password verifications
         $this->password($blog);
         // Format microblog postings
         if ($blog->posttype) {
             $this->formatMicroblog($blog);
         }
         // Get featured image
         if ($blog->hasImage()) {
             $blog->image = $blog->getImage($this->config->get('cover_featured_size', 'large'));
         } else {
             $tmp = $blog->getContentImage();
             if ($tmp) {
                 $blog->image = $tmp;
             } else {
                 $blog->image = '';
             }
         }
         // Detect if content requires read more link
         $blog->readmore = $this->hasReadmore($blog);
         // Prepare nice date for the featured area
         $blog->date = EB::date($blog->created)->format(JText::_('DATE_FORMAT_LC'));
         $result[] = $blog;
     }
     return $result;
 }
Example #13
0
 public static function getUsers()
 {
     $id = JRequest::getVar('id');
     $view = JRequest::getVar('view');
     $db = EB::db();
     $query = '';
     if ($view == 'entry') {
         $query = 'select disctinct a.`user_id` from `#__easyblog_subscriptions` as a';
         $query .= ' inner join `#__users` as b on a.`user_id` = b.`id`';
         $query .= ' where (';
         // entry
         $query .= ' (a.`uid` = ' . $db->Quote($id) . ' AND a.`utype` = ' . $db->Quote(EBLOG_SUBSCRIPTION_ENTRY) . ') OR';
         // category
         $query .= ' (a.`uid` IN (select pc.`category_id` from `#__easyblog_post_category` as pc where pc.`post_id` = ' . $db->Quote($id) . ' ) AND a.`utype` = ' . $db->Quote(EBLOG_SUBSCRIPTION_CATEGORY) . ') OR';
         // teamblog
         $query .= ' (a.`uid` IN (select pc.`source_id` from `#__easyblog_post` as p where p.`id` = ' . $db->Quote($id) . ' and p.`source_type` = ' . $db->Quote(EASYBLOG_POST_SOURCE_TEAM) . ' ) AND a.`utype` = ' . $db->Quote(EBLOG_SUBSCRIPTION_TEAMBLOG) . ')';
         $query .= ')';
     } else {
         if ($view == 'categories' && $id) {
             $query = 'select disctinct a.`user_id` from `#__easyblog_subscriptions` as a';
             $query .= ' inner join `#__users` as b on a.`user_id` = b.`id`';
             $query .= ' where a.`uid` = ' . $db->Quote($id);
             $query .= ' and a.`utype` = ' . $db->Quote(EBLOG_SUBSCRIPTION_CATEGORY);
         } else {
             if ($view == 'teamblog') {
                 $query = 'select disctinct a.`user_id` from `#__easyblog_subscriptions` as a';
                 $query .= ' inner join `#__users` as b on a.`user_id` = b.`id`';
                 $query .= ' where a.`uid` = ' . $db->Quote($id);
                 $query .= ' and a.`utype` = ' . $db->Quote(EBLOG_SUBSCRIPTION_TEAMBLOG);
             }
         }
     }
     $db->setQuery($query);
     $result = $db->loadObjectList();
     if (!$result) {
         return false;
     }
     //preload users
     $ids = array();
     foreach ($result as $row) {
         $ids[] = $row->user_id;
     }
     EB::user($ids);
     $subscribers = array();
     foreach ($result as $row) {
         $subscribers[] = EB::user($row->user_id);
     }
     return $subscribers;
 }
Example #14
0
 protected function getInput()
 {
     $title = JText::_('COM_EASYBLOG_SELECT_A_USER');
     if ($this->value) {
         $author = EB::user((int) $this->value);
         $title = $author->getName();
     }
     $theme = EB::template();
     $theme->set('id', $this->id);
     $theme->set('name', $this->name);
     $theme->set('value', $this->value);
     $theme->set('title', $title);
     $output = $theme->output('admin/elements/authors');
     return $output;
 }
Example #15
0
 /**
  * Default display method for my blog listings
  *
  * @since	4.0
  * @access	public
  * @param	string
  * @return
  */
 public function display($tmpl = null)
 {
     // Require user to be logged in to access this page
     EB::requireLogin();
     // Get the default sorting behavior
     $sort = $this->input->get('sort', $this->config->get('layout_postorder'), 'cmd');
     // Load up the author profile
     $author = EB::user($this->my->id);
     // Set meta tags for blogger
     EB::setMeta($this->my->id, META_ID_BLOGGERS);
     // Set the breadcrumbs
     $this->setPathway(JText::_('COM_EASYBLOG_BLOGGERS_BREADCRUMB'), EB::_('index.php?option=com_easyblog&view=blogger'));
     $this->setPathway($author->getName());
     $menu = JFactory::getApplication()->getMenu();
     $categoryInclusion = array();
     if ($menu) {
         $active = $menu->getActive();
         $categoryInclusion = $active->params->get('inclusion');
     }
     $model = EB::model('Blog');
     $posts = $model->getBlogsBy('blogger', $author->id, $sort, 0, EBLOG_FILTER_PUBLISHED, false, false, array(), false, false, true, array(), $categoryInclusion);
     // Get the pagination
     $pagination = $model->getPagination();
     // Set the page title
     $title = $author->getName() . ' - ' . EB::getPageTitle(JText::_('COM_EASYBLOG_MY_BLOG_PAGE_TITLE'));
     $this->setPageTitle($title, $pagination, $this->config->get('main_pagetitle_autoappend'));
     // Format the posts
     $posts = EB::formatter('list', $posts);
     // Add the RSS headers on the page
     EB::feeds()->addHeaders('index.php?option=com_easyblog&view=myblog');
     // Determines if the viewer already subscribed to the author
     $subscribed = false;
     $bloggerModel = EB::model('Blogger');
     if ($bloggerModel->isBloggerSubscribedUser($author->id, $this->my->id, $this->my->email)) {
         $subscribed = true;
     }
     // Get the current url
     $return = EBR::_('index.php?option=com_easyblog', false);
     $this->set('return', $return);
     $this->set('subscribed', $subscribed);
     $this->set('author', $author);
     $this->set('posts', $posts);
     $this->set('sort', $sort);
     $this->set('pagination', $pagination);
     parent::display('blogs/myblog/default');
 }
Example #16
0
 public function display($tpl = null)
 {
     // Ensure that rss is enabled
     if (!$this->config->get('main_rss')) {
         return;
     }
     // Get the default sorting behavior
     $sort = $this->input->get('sort', $this->config->get('layout_postorder'), 'cmd');
     // Load up the author profile
     $author = EB::user($this->my->id);
     // Get the blogs model
     $model = EB::model('Blog');
     $posts = $model->getBlogsBy('blogger', $author->id, $sort);
     $this->doc->link = EB::_('index.php?option=com_easyblog&view=myblog');
     $this->doc->setTitle(JText::_('COM_EASYBLOG_FEEDS_MYBLOG_TITLE'));
     $this->doc->setDescription(JText::sprintf('COM_EASYBLOG_FEEDS_MYBLOG_DESC', $author->user->name));
     // If there's no data, skip this altogether
     if (!$posts) {
         return;
     }
     $uri = JURI::getInstance();
     $scheme = $uri->toString(array('scheme'));
     $scheme = str_replace('://', ':', $scheme);
     $posts = EB::formatter('list', $posts);
     foreach ($posts as $post) {
         $image = '';
         if ($post->hasImage()) {
             $image = '<img src="' . $post->getImage('medium', true, true) . '" width="250" align="left" />';
         }
         $item = new JFeedItem();
         $item->title = $this->escape($post->title);
         $item->link = $post->getPermalink();
         $item->description = $image . $post->getIntro();
         // replace the image source to proper format so that feed reader can view the image correctly.
         $item->description = str_replace('src="//', 'src="' . $scheme . '//', $item->description);
         $item->description = str_replace('href="//', 'href="' . $scheme . '//', $item->description);
         $item->date = $post->getCreationDate()->toSql();
         $item->category = $post->getPrimaryCategory()->getTitle();
         $item->author = $post->author->getName();
         $item->authorEmail = $this->getRssEmail($post->author);
         $this->doc->addItem($item);
     }
     return;
 }
Example #17
0
 public function display($tmpl = null)
 {
     // Check if rss is enabled
     if (!$this->config->get('main_rss')) {
         return JError::raiseError(404, JText::_('COM_EASYBLOG_FEEDS_DISABLED'));
     }
     // Check if the author's id is provided
     $id = $this->input->get('id', '', 'cmd');
     if (!$id) {
         return JError::raiseError(404, JText::_('COM_EASYBLOG_FEEDS_INVALID_AUTHOR_ID'));
     }
     $author = EB::user($id);
     $model = EB::model('Blog');
     $posts = $model->getBlogsBy('blogger', $author->id);
     $posts = EB::formatter('list', $posts);
     $this->doc->link = $author->getPermalink();
     $this->doc->setTitle(JText::sprintf('COM_EASYBLOG_FEEDS_BLOGGER_TITLE', $author->getName()));
     $this->doc->setDescription(strip_tags($author->description));
     if (!$posts) {
         return;
     }
     $uri = JURI::getInstance();
     $scheme = $uri->toString(array('scheme'));
     $scheme = str_replace('://', ':', $scheme);
     foreach ($posts as $post) {
         $image = '';
         if ($post->hasImage()) {
             $image = '<img src="' . $post->getImage('medium', true, true) . '" width="250" align="left" />';
         }
         $item = new JFeedItem();
         $item->title = $this->escape($post->title);
         $item->link = $post->getPermalink();
         $item->description = $image . $post->getIntro();
         // replace the image source to proper format so that feed reader can view the image correctly.
         $item->description = str_replace('src="//', 'src="' . $scheme . '//', $item->description);
         $item->description = str_replace('href="//', 'href="' . $scheme . '//', $item->description);
         $item->date = $post->getCreationDate()->toSql();
         $item->category = $post->getPrimaryCategory()->getTitle();
         $item->author = $post->author->getName();
         $item->authorEmail = $this->getRssEmail($profile);
         $this->doc->addItem($item);
     }
 }
Example #18
0
 static function getJComment(&$params)
 {
     $db = EB::db();
     $query = 'SELECT * FROM ' . $db->nameQuote('#__jcomments') . ' ' . 'WHERE ' . $db->nameQuote('published') . '=' . $db->Quote(1) . ' ' . 'AND ' . $db->nameQuote('object_group') . '=' . $db->Quote('com_easyblog') . ' ' . 'ORDER BY `date` ' . 'LIMIT 0,' . $params->get('count');
     $db->setQuery($query);
     $rows = $db->loadObjectList();
     $comments = array();
     if ($rows) {
         foreach ($rows as $row) {
             $row->author = EB::user($row->userid);
             $row->created_by = $row->userid;
             $row->post_id = $row->object_id;
             $blog = EB::table('Blog');
             $blog->load($row->object_id);
             $row->blog_title = $blog->title;
             $row->created = $row->date;
             $comments[] = $row;
         }
     }
     return $comments;
 }
Example #19
0
 /**
  * Retrieves a list of items from a given uri
  *
  * @since	5.0
  * @access	public
  * @param	string
  * @return
  */
 public function getItems($uri, $includeVariations = false)
 {
     // Retrieve a list of authors from the site.
     $model = EB::model('Blogger');
     $result = $model->getBloggers();
     // Get path and folder
     $folder = $this->getFolderItem($uri);
     // Get the absolute path to the main "articles" folder
     $folderPath = EasyBlogMediaManager::getPath($folder->uri);
     if (!$result) {
         return $folder;
     }
     // Filegroup is the array where files are stored.
     // Sort arrays are used to speed up file sorting.
     $filegroup = EasyBlogMediaManager::filegroup();
     // The strategy used here is to use a single loop that build:
     // - data that is ready-to-use
     // - sort arrays so sorting becomes cheap.
     // - variations
     $variations = array();
     $total = 0;
     // Map them with the profile table
     $authors = array();
     if ($result) {
         foreach ($result as $row) {
             $author = EB::user($row->id);
             $authorPath = $folderPath . '/' . $row->id;
             $uri = 'user:'******'folder'][] = $items;
             $total++;
         }
     }
     // Set the folder contents
     $folder->contents = $filegroup;
     $folder->total = $total;
     return $folder;
 }
Example #20
0
 /**
  * Renders a folder contents in Media manager
  *
  * @since	5.0
  * @access	public
  * @param	string
  * @return
  */
 public static function renderFolder($uri)
 {
     $my = JFactory::getUser();
     $user = EB::user();
     // Get the place data
     $place = self::getPlace($uri);
     // Determines if this is a local type or other remote sources
     $type = self::getSourceType($place->id);
     $currentEditor = $user->getEditor();
     $mm = new self($type);
     $folder = $mm->getItems($uri);
     $config = EB::config();
     $useIndex = $config->get('ajax_use_index');
     // Set the upload url
     $session = JFactory::getSession();
     $uploadUrl = JURI::base();
     if ($useIndex) {
         $uploadUrl .= 'index.php';
     }
     $uploadUrl .= '?option=com_easyblog&task=media.upload&tmpl=component&lang=en&key=' . $folder->key . '&sessionid=' . $session->getId() . '&' . EB::getToken() . '=1';
     // Set the id's for dropzones and browse button
     $browseButtonId = 'eb-mm-folder-browse-' . $folder->key;
     $dropElementId = 'eb-mm-folder-drop-' . $folder->key;
     $template = EB::template();
     $template->set('currentEditor', $currentEditor);
     $template->set('uploadUrl', $uploadUrl);
     $template->set('browseButtonId', $browseButtonId);
     $template->set('dropElementId', $dropElementId);
     $template->set('place', $place);
     $template->set('folder', $folder);
     $html = $template->output('site/mediamanager/folder');
     return $html;
 }
Example #21
0
 /**
  * Use explicitly on dashboard view only.
  *
  * @since   4.0
  * @access  public
  * @param   string
  * @return
  */
 public function getDashboardToolbar()
 {
     // Get total pending blog posts
     $model = EB::model('Blogs');
     $total = $model->getTotalPending();
     $totalTeamRequest = 0;
     // Get total team requests to join team.
     if (EB::isTeamAdmin()) {
         $teamModel = EB::model('TeamBlogs');
         $totalTeamRequest = $teamModel->getTotalRequest();
     }
     // Get the logout link
     $logoutActionLink = 'index.php?option=com_users&task=user.logout';
     // @task: Determine if the current user is a blogger or not.
     $isBlogger = EB::isSiteAdmin() || $this->acl->get('add_entry');
     // Get the logout return url
     $itemId = EB::router()->getItemid('latest');
     $logoutReturn = base64_encode(EB::_('index.php?option=com_easyblog&view=latest&Itemid=' . $itemId, false));
     // Get the current active layout
     $layout = $this->input->get('layout', '', 'cmd');
     // Get the current user
     $user = EB::user(JFactory::getUser()->id);
     // Get the template
     $theme = EB::template();
     $theme->set('current', $this->getLayout());
     $theme->set('isBlogger', $isBlogger);
     $theme->set('totalPending', $total);
     $theme->set('user', $user);
     $theme->set('logoutURL', $logoutReturn);
     $theme->set('logoutActionLink', $logoutActionLink);
     $theme->set('totalTeamRequest', $totalTeamRequest);
     $output = $theme->output('site/dashboard/toolbar/default');
     return $output;
 }
Example #22
0
 public function migrate($wpBlogId)
 {
     $session = JFactory::getSession();
     $migrateStat = $session->get('EBLOG_MIGRATOR_JOOMLA_STAT', '', 'EASYBLOG');
     if (empty($migrateStat)) {
         $migrateStat = new stdClass();
         $migrateStat->blog = 0;
         $migrateStat->category = 0;
         $migrateStat->user = array();
     }
     // Get item based on $wpBlogId
     $items = $this->getItem($wpBlogId);
     // If no item to migrate, just return
     if (!$items) {
         return $this->ajax->resolve('noitem');
     }
     foreach ($items as $item) {
         // step 1 : create categery if not exist in eblog_categories
         // step 2 : create user if not exists in eblog_users - create user through profile jtable load method.
         $date = EB::date();
         $blogObj = new stdClass();
         // Create category if this item's category does not exist on the site
         //$wpTableNamePrex = ($wpBlogId == '1') ? '' : $wpBlogId . '_';
         // Get the easyblog category Id
         $categoryId = $this->getEasyblogCategory();
         $blogObj->category_id = $categoryId;
         // this is needed because posy lib actually use this to create the post - category relations
         $blogObj->categories = array($categoryId);
         //load user profile
         $profile = EB::user($item->post_author);
         //assigning blog data
         $blogObj->created_by = $profile->id;
         $blogObj->created = !empty($item->post_date) ? $item->post_date : $date->toMySQL();
         $blogObj->modified = $date->toMySQL();
         $blogObj->title = $item->post_title;
         $blogObj->permalink = $item->post_title;
         // post lib will take care of the normalization of permalink
         /* replacing [caption] and [gallery] */
         // Migrate caption
         $item = $this->migrateCaption($item);
         $blogObj->intro = $item->post_excerpt;
         $blogObj->content = $item->post_content;
         //translating the article state into easyblog publish status.
         $blogState = '0';
         $isPrivate = '0';
         if ($item->post_status == 'private') {
             $isPrivate = '1';
             $blogState = '1';
         } else {
             if ($item->post_status == 'publish') {
                 $isPrivate = '0';
                 $blogState = '1';
             }
         }
         $blogObj->blogpassword = $item->post_password;
         $blogObj->access = $isPrivate;
         $blogObj->published = $blogState;
         $blogObj->publish_up = !empty($item->post_date) ? $item->post_date : $date->toMySQL();
         $blogObj->publish_down = '0000-00-00 00:00:00';
         $blogObj->ordering = 0;
         $blogObj->hits = 0;
         $blogObj->frontpage = 1;
         $blogObj->allowcomment = $item->comment_status == 'open' ? 1 : 0;
         // lets create blank post which are legacy type.
         $post = EB::post();
         $post->create(array('overrideDoctType' => 'legacy'));
         // now let get the uid
         $blogObj->uid = $post->uid;
         $blogObj->revision_id = $post->revision->id;
         // binding
         $post->bind($blogObj, array());
         $saveOptions = array('applyDateOffset' => false, 'validateData' => false, 'useAuthorAsRevisionOwner' => true);
         $post->save($saveOptions);
         // add tags.
         $wpPostTag = $this->getWPTerms($item->id, 'post_tag');
         // Migrate tag
         if (count($wpPostTag) > 0) {
             foreach ($wpPostTag as $tag) {
                 $this->migrateTag($tag, $post);
             }
         }
         // Migrate comments
         $this->migrateComment($post, $item);
         //update session value
         $migrateStat->blog++;
         $statUser = $migrateStat->user;
         $statUserObj = null;
         if (!isset($statUser[$profile->id])) {
             $statUserObj = new stdClass();
             $statUserObj->name = $profile->nickname;
             $statUserObj->blogcount = 0;
         } else {
             $statUserObj = $statUser[$profile->id];
         }
         $statUserObj->blogcount++;
         $statUser[$profile->id] = $statUserObj;
         $migrateStat->user = $statUser;
         $session->set('EBLOG_MIGRATOR_JOOMLA_STAT', $migrateStat, 'EASYBLOG');
         //log the entry into migrate table.
         $migratorTable = EB::table('Migrate');
         $migratorTable->content_id = $item->id;
         $migratorTable->post_id = $post->id;
         $migratorTable->session_id = $session->getToken();
         $migratorTable->component = 'com_wordpress';
         $migratorTable->store();
         $this->ajax->append('[data-progress-status]', JText::_('COM_EASYBLOG_MIGRATOR_MIGRATED_WORDPRESS_BLOG') . ': ' . $item->id . JText::_('COM_EASYBLOG_MIGRATOR_EASYBLOG') . ': ' . $post->id . '<br />');
     }
     $stat = JText::_('COM_EASYBLOG_MIGRATOR_WORDPRESS_TOTAL_ARTICLE') . ' : ' . $migrateStat->blog . '<br />';
     $stat .= JText::_('COM_EASYBLOG_MIGRATOR_WORDPRESS_TOTAL_CATEGORY') . ' : ' . $migrateStat->category . '<br />';
     $this->ajax->append('[data-progress-status]', JText::_('COM_EASYBLOG_MIGRATOR_FINISHED'));
     $this->ajax->append('[data-progress-stat]', $stat);
     // we need to clear the stat variable that stored in session.
     $jSession = JFactory::getSession();
     $jSession->set('EBLOG_MIGRATOR_JOOMLA_STAT', '', 'EASYBLOG');
     return $this->ajax->resolve();
 }
* 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.
*/
defined('_JEXEC') or die('Unauthorized Access');
jimport('joomla.filesystem.file');
$engine = JPATH_ADMINISTRATOR . '/components/com_easyblog/includes/easyblog.php';
if (!JFile::exists($engine)) {
    return;
}
require_once $engine;
require_once __DIR__ . '/helper.php';
// This module will require the main script file since composer needs to be loaded
EB::init('site');
// Ensure that all script are loaded in the site.
EB::init('module');
// Attach modules stylesheet
EB::stylesheet('module')->attach();
// Get the current user.
$my = JFactory::getUser();
// Get the return url
$return = modEasyBlogWelcomeHelper::getReturnURL($params);
// Get the blogger object
$author = EB::user($my->id);
// Get available options
$config = EB::config();
$acl = EB::acl();
// Determines if we should allow registration
$usersConfig = JComponentHelper::getParams('com_users');
$allowRegistration = $usersConfig->get('allowUserRegistration');
require JModuleHelper::getLayoutPath('mod_easyblogwelcome');
Example #24
0
 public function migrate($migrateComment, $migrateAll, $catId)
 {
     // Determine which category to import from
     $catId = $catId == 0 ? null : $catId;
     // Render Joomla's session
     $session = JFactory::getSession();
     // Statistics
     $migrateStat = $session->get('EBLOG_MIGRATOR_JOOMLA_STAT', '', 'EASYBLOG');
     if (empty($migrateStat)) {
         $migrateStat = new stdClass();
         $migrateStat->blog = 0;
         $migrateStat->category = 0;
         $migrateStat->user = array();
     }
     // Get the total number of items
     $total = $this->getTotalItems($catId);
     // Get the real items
     $items = $this->getItems($catId);
     // Determines if there is still items to be migrated
     $balance = $total - count($items);
     // If there's nothing to load just skip this
     if (!$items) {
         return $this->ajax->resolve('noitem');
     }
     foreach ($items as $item) {
         // Create a new blog object
         $blogObj = new stdClass();
         // Get today's date
         $date = EB::date();
         // Create category if this item's category does not exist on the site
         $categoryId = $this->migrateCategory($item);
         // Assign the new category to the blog object
         $blogObj->category_id = $categoryId;
         // this is needed because post lib actually use this to create the post - category relations.
         $blogObj->categories = array($categoryId);
         // Create user if the user does not exist in `#__easyblog_users`
         $profile = EB::user($item->created_by);
         //assigning blog data
         $blogObj->created_by = $profile->id;
         $blogObj->created = !empty($item->created) ? $item->created : $date->toMySQL();
         $blogObj->modified = $date->toMySQL();
         $blogObj->title = $item->title;
         $blogObj->permalink = $item->alias;
         // post lib will take care of the normalization of permalink
         $blogObj->intro = $item->introtext;
         if (!empty($item->fulltext)) {
             $blogObj->content = $item->fulltext;
         }
         $blogState = $item->published == 2 || $item->published == -2 ? 0 : $item->published;
         $blogObj->published = $blogState;
         $blogObj->publish_up = !empty($item->publish_up) ? $item->publish_up : $date->toMySQL();
         $blogObj->publish_down = !empty($item->publish_down) ? $item->publish_down : $date->toMySQL();
         $blogObj->ordering = $item->ordering;
         $blogObj->hits = $item->hits;
         $blogObj->frontpage = 1;
         $blogObj->eb_language = $item->language;
         $blogObj->posttype = '';
         $blogObj->source_id = '0';
         $blogObj->source_type = EASYBLOG_POST_SOURCE_SITEWIDE;
         // lets create blank post which are legacy type.
         $post = EB::post();
         $post->create(array('overrideDoctType' => 'legacy'));
         // now let get the uid
         $blogObj->uid = $post->uid;
         $blogObj->revision_id = $post->revision->id;
         // binding
         $post->bind($blogObj, array());
         $saveOptions = array('applyDateOffset' => false, 'validateData' => false, 'useAuthorAsRevisionOwner' => true);
         $post->save($saveOptions);
         //Added video to blog content
         $this->migrateK2Videos($item, $post);
         //Migrate over the images
         $this->migrateK2Images($item, $post, $profile);
         //Get K2 Tags and map into Easyblog Tags
         $K2Tags = $this->getK2Tag($item->id);
         if ($K2Tags) {
             foreach ($K2Tags as $tag) {
                 $this->mapK2Tag($tag, $item, $post);
             }
         }
         // if article was featured, lets mark this blog post as featured as well.
         if ($item->featured) {
             // just call the model file will do as we do not want to create stream on featured action at this migration.
             $modelFeatured = EB::model('Featured');
             $modelFeatured->makeFeatured('post', $post->id);
         }
         //update session value
         $migrateStat->blog++;
         $statUser = $migrateStat->user;
         $statUserObj = null;
         if (!isset($statUser[$profile->id])) {
             $statUserObj = new stdClass();
             $statUserObj->name = $profile->nickname;
             $statUserObj->blogcount = 0;
         } else {
             $statUserObj = $statUser[$profile->id];
         }
         $statUserObj->blogcount++;
         $statUser[$profile->id] = $statUserObj;
         $migrateStat->user = $statUser;
         $session->set('EBLOG_MIGRATOR_JOOMLA_STAT', $migrateStat, 'EASYBLOG');
         //log the entry into migrate table.
         $migratorTable = EB::table('Migrate');
         $migratorTable->content_id = $item->id;
         $migratorTable->post_id = $post->id;
         $migratorTable->session_id = $session->getToken();
         $migratorTable->component = 'com_k2';
         $migratorTable->store();
         $this->ajax->append('[data-progress-status]', JText::_('COM_EASYBLOG_MIGRATOR_MIGRATED_K2') . ': ' . $item->id . JText::_('COM_EASYBLOG_MIGRATOR_EASYBLOG') . ': ' . $post->id . '<br />');
         if ($migrateComment) {
             $this->migrateK2Comments($item, $post);
             $return = array();
             $return['migrate_k2_comments'] = 1;
             $return['k2category'] = $catId;
             $return = json_encode($return);
         }
     }
     $hasmore = false;
     if ($balance) {
         $hasmore = true;
     }
     if (!$hasmore) {
         $stat = JText::_('COM_EASYBLOG_MIGRATOR_K2_TOTAL_ARTICLE') . ' : ' . $migrateStat->blog . '<br />';
         $stat .= JText::_('COM_EASYBLOG_MIGRATOR_K2_TOTAL_CATEGORY') . ' : ' . $migrateStat->category . '<br />';
         $this->ajax->append('[data-progress-status]', JText::_('COM_EASYBLOG_MIGRATOR_FINISHED'));
         $this->ajax->append('[data-progress-stat]', $stat);
         // we need to clear the stat variable that stored in session.
         $jSession = JFactory::getSession();
         $jSession->set('EBLOG_MIGRATOR_JOOMLA_STAT', '', 'EASYBLOG');
     }
     return $this->ajax->resolve($hasmore);
 }
Example #25
0
 /**
  * Saves an author object
  *
  * @since	4.0
  * @access	public
  * @param	string
  * @return
  */
 public function save()
 {
     // Check for request forgeries
     EB::checkToken();
     // Check for acl rules.
     $this->checkAccess('user');
     // Create a new JUser object
     $id = $this->input->get('id', 0, 'int');
     $user = JFactory::getUser($id);
     // Get the user group's id
     $gid = $user->get('gid');
     // Get the posted data
     $post = $this->input->getArray('post');
     // Retrieve the username and password of the user
     $post['username'] = $this->input->get('username', '', 'default');
     $post['password'] = $this->input->get('password', '', 'default');
     $post['password2'] = $this->input->get('password2', '', 'default');
     // Get the data from Joomla's form
     if (isset($post['jform']['params'])) {
         $post['params'] = $post['jform']['params'];
         unset($post['jform']);
     }
     // Bind the post request on the user's object
     $state = $user->bind($post);
     // Default redirection url
     $redirect = 'index.php?option=com_easyblog&view=bloggers&layout=form&id=' . $user->id;
     if (!$state) {
         $this->info->set($user->getError(), 'error');
         return $this->app->redirect($redirect);
     }
     // Get the user's id
     if ($user->id == $this->my->id && $user->block) {
         $this->info->set(JText::_('You are not allowed to block yourself.'), 'error');
         return $this->app->redirect($redirect);
     }
     if ($user->authorise('core.admin') && $user->block) {
         $this->info->set(JText::_('You are not allowed to block a super administrator.'), 'error');
         return $this->app->redirect($redirect);
     }
     if ($user->authorise('core.admin') && !$this->my->authorise('core.admin')) {
         $this->info->set(JText::_('You cannot edit a Super User account.'), 'error');
         return $this->app->redirect($redirect);
     }
     $gid = $post['gid'];
     if (!empty($gid)) {
         $user->groups = array();
         foreach ($gid as $groupid) {
             $user->groups[$groupid] = $groupid;
         }
     }
     // Are we dealing with a new user which we need to create?
     $isNew = $user->id < 1;
     // Try to save the user now
     $state = $user->save();
     if (!$state) {
         $this->info->set($user->getError(), 'error');
         return $this->app->redirect($redirect);
     }
     // Update the user's session data if the current user is being edited to ensure that
     // the current user's data is correct
     if ($user->id == $this->my->id) {
         $session = JFactory::getSession();
         $session->set('user', $user);
     }
     // If this is a new record, ensure that the id is not set
     if ($isNew) {
         unset($post['id']);
     }
     // Set the proper permalink
     if (isset($post['user_permalink'])) {
         $post['permalink'] = $post['user_permalink'];
         unset($post['user_permalink']);
     }
     // Only allow site admins to add html codes for the description and biography
     if (EB::isSiteAdmin()) {
         $post['description'] = $this->input->get('description', '', 'html');
         $post['biography'] = $this->input->get('biography', '', 'html');
     }
     // After the user record is stored, we also want to update EasyBlog's records.
     $author = EB::user($user->id);
     // Bind the posted data
     $author->bind($post);
     // Get the file data
     $file = $this->input->files->get('avatar', '');
     if (isset($file['tmp_name']) && !empty($file['tmp_name'])) {
         $author->bindAvatar($file, EB::acl());
     }
     // Save other user parameters
     $registry = EB::registry();
     // Save google profile url
     if (isset($post['google_profile_url'])) {
         $registry->set('google_profile_url', $post['google_profile_url']);
     }
     if (isset($post['show_google_profile_url'])) {
         $registry->set('show_google_profile_url', $post['show_google_profile_url']);
     }
     $author->params = $registry->toString();
     // Try to save the author object now
     $author->store();
     // Save the social settings
     $twitter = EB::table('OAuth');
     $twitter->load(array('user_id' => $user->id, 'type' => EBLOG_OAUTH_TWITTER));
     $twitter->auto = $this->input->get('integrations_twitter_auto');
     $twitter->message = $this->input->get('integrations_twitter_message', '', 'default');
     // Try to save the twitter oauth object now
     $state = $twitter->store();
     if (!$state) {
         $this->info->set($twitter->getError(), 'error');
         return $this->app->redirect($redirect);
     }
     // Try to save the linked in oauth object
     $linkedin = EB::table('OAuth');
     $linkedin->load(array('user_id' => $user->id, 'type' => EBLOG_OAUTH_LINKEDIN));
     $linkedin->auto = $this->input->get('integrations_linkedin_auto', '', 'bool');
     $linkedin->message = $this->input->get('integrations_linkedin_message', '', 'default');
     $linkedin->private = $this->input->get('integrations_linkedin_private', '', 'bool');
     // Save the oauth object now
     $state = $linkedin->store();
     if (!$state) {
         $this->info->set($linkedin->getError(), 'error');
         return $this->app->redirect($redirect);
     }
     // Store the Facebook oauth object now
     $facebook = EB::table('OAuth');
     $facebook->load(array('user_id' => $user->id, 'type' => EBLOG_OAUTH_FACEBOOK));
     $facebook->auto = $this->input->get('integrations_facebook_auto', '', 'bool');
     $facebook->message = '';
     // Save the facebook object now
     $state = $facebook->store();
     if (!$state) {
         $this->info->set($facebook->getError(), 'error');
         return $this->app->redirect($redirect);
     }
     // Save google adsense codes now
     if ($this->config->get('integration_google_adsense_enable')) {
         $adsense = EB::table('Adsense');
         $adsense->load($user->id);
         $adsense->code = $post['adsense_code'];
         $adsense->display = $post['adsense_display'];
         $adsense->published = $post['adsense_published'];
         $adsense->store();
     }
     // Store Feedburner's data
     $feedburner = EB::table('Feedburner');
     $feedburner->load($user->id);
     $feedburner->url = $post['feedburner_url'];
     $feedburner->store();
     // Get the current task
     $task = $this->getTask();
     $this->info->set('COM_EASYBLOG_BLOGGER_SAVED', 'success');
     if ($task == 'apply') {
         $redirect = 'index.php?option=com_easyblog&view=bloggers&layout=form&id=' . $user->id;
         return $this->app->redirect($redirect);
     }
     return $this->app->redirect('index.php?option=com_easyblog&view=bloggers');
 }
Example #26
0
 public static function getBloggerTheme()
 {
     $id = EasyBlogRouter::isBloggerMode();
     if (empty($id)) {
         return false;
     }
     $profile = EB::user($id);
     $userparams = EB::registry($profile->params);
     return $userparams->get('theme', false);
 }
Example #27
0
 /**
  * Validates posted data
  *
  * @since	4.0
  * @access	public
  * @param	string
  * @return
  */
 public function validatePost($post)
 {
     $config = EB::config();
     $my = JFactory::getUser();
     $comment = isset($post['comment']) ? $post['comment'] : '';
     $title = isset($post['title']) ? $post['title'] : '';
     $register = isset($post['register']) ? $post['register'] : false;
     $username = isset($post['username']) ? $post['username'] : '';
     $subscribe = isset($post['subscribe']) ? $post['subscribe'] : false;
     $name = isset($post['name']) ? $post['name'] : '';
     $email = isset($post['email']) ? $post['email'] : '';
     $website = isset($post['website']) ? $post['website'] : '';
     $terms = isset($post['terms']) ? $post['terms'] : '';
     // If name is empty, it could be that the user is logged in
     if (!$my->guest) {
         $user = EB::user($my->id);
         // Override the name
         $name = $user->getName();
         // Override the email
         $email = $my->email;
         // Override the website
         $website = $user->getWebsite();
     }
     if (!$comment || JString::strlen($comment) == 0) {
         $this->setError(JText::_('COM_EASYBLOG_COMMENTS_PLEASE_ENTER_SOME_COMMENTS'));
         return false;
     }
     if ($config->get('comment_requiretitle') && JString::strlen($title) == 0) {
         $this->setError(JText::_('COM_EASYBLOG_COMMENT_TITLE_IS_EMPTY'));
         return false;
     }
     if ($register && (!$username || JString::strlen($username) == 0)) {
         $this->setError(JText::_('COM_EASYBLOG_SUBSCRIPTION_USERNAME_IS_EMPTY'));
         return false;
     }
     if (!$name || JString::strlen($name) == 0) {
         $this->setError(JText::_('COM_EASYBLOG_COMMENT_NAME_IS_EMPTY'));
         return false;
     }
     if ($config->get('comment_require_email') && (!$email || JString::strlen($email) == 0)) {
         $this->setError(JText::_('COM_EASYBLOG_COMMENT_EMAIL_IS_EMPTY'));
         return false;
     }
     if ($my->guest && ($config->get('comment_require_website') && (!$website || JString::strlen($website) == 0))) {
         $this->setError(JText::_('COM_EASYBLOG_COMMENT_WEBSITE_IS_EMPTY'));
         return false;
     }
     // If user is subscribed to the blog, ensure that email exists
     if ($subscribe && !$email) {
         $this->setError(JText::_('COM_EASYBLOG_COMMENT_EMAIL_IS_EMPTY'));
         return false;
     }
     // Check for valid email
     $validEmail = EB::string()->isValidEmail($email);
     if ($config->get('comment_require_email') && !$validEmail) {
         $this->setError(JText::_('COM_EASYBLOG_COMMENT_EMAIL_INVALID'));
         return false;
     }
     // Ensure that the user checked the terms and condition box.
     if ($config->get('comment_tnc') && !$terms && ($config->get('comment_tnc_users') == 0 && $my->guest || $config->get('comment_tnc_users') == 1 && !$my->guest || $config->get('comment_tnc_users') == 2)) {
         $this->setError(JText::_('COM_EASYBLOG_YOU_MUST_ACCEPT_TNC'));
         return false;
     }
     return true;
 }
Example #28
0
 /**
  * Retrieves the author that created this reject
  *
  * @since	4.0
  * @access	public
  * @param	string
  * @return
  */
 public function getAuthor()
 {
     $user = EB::user($this->created_by);
     return $user;
 }
    return;
}
// @task: Include module's helper file.
require_once $engine;
// Ensure that all script are loaded in the site.
EB::init('module');
// Attach modules stylesheet
EB::stylesheet('module')->attach();
$document = JFactory::getDocument();
$document->addStyleSheet(rtrim(JURI::root(), '/') . '/components/com_easyblog/assets/css/module.css');
$config = EB::config();
$model = EB::model('Blog');
if ($params->get('catid')) {
    $categories = explode(',', $params->get('catid'));
    $entries = $model->getBlogsBy('category', $categories, 'latest', $params->get('count'), EBLOG_FILTER_PUBLISHED, null, true, array(), false, false, false);
} else {
    $entries = $model->getBlogsBy('', '', 'latest', $params->get('count'), EBLOG_FILTER_PUBLISHED, null, true, array(), false, false, false);
}
// If there's nothing to show at all, don't even display a box.
if (!$entries) {
    return;
}
$items = array();
foreach ($entries as $entry) {
    $row = EB::post($entry->id);
    $row->bind($entry);
    $row->author = EB::user($row->created_by);
    $row->date = EB::date($row->created)->toFormat($config->get('layout_dateformat', JText::_('DATE_FORMAT_LC1')));
    $items[] = $row;
}
require JModuleHelper::getLayoutPath('mod_easyblogticker');
Example #30
0
 /**
  * Retrieves a list of active authors for a category
  *
  * @since	4.0
  * @access	public
  * @param	string
  * @return
  */
 public function getActiveAuthors($categoryId)
 {
     $db = EB::db();
     $query = array();
     $query[] = 'SELECT DISTINCT(a.' . $db->quoteName('created_by') . ') FROM ' . $db->quoteName('#__easyblog_post') . ' AS a';
     $query[] = 'INNER JOIN ' . $db->quoteName('#__easyblog_post_category') . ' AS b';
     $query[] = 'ON a.' . $db->quoteName('id') . ' = b.' . $db->quoteName('post_id');
     $query[] = 'where b.' . $db->quoteName('category_id') . ' = ' . $db->Quote($categoryId);
     // Glue back the queries into a single string
     $query = implode(' ', $query);
     $db->setQuery($query);
     $result = $db->loadColum();
     if (!$result) {
         return $result;
     }
     $authors = array();
     // preload users.
     EB::user($result);
     foreach ($result as $id) {
         $author = EB::user($id);
         $authors[] = $author;
     }
     return $authors;
 }