예제 #1
0
 public function buildNestedCategories(&$parent, $ignorePrivate = false, $isPublishedOnly = true)
 {
     $catModel = EasyBlogHelper::getModel('Categories');
     $childs = $catModel->getChildCategories($parent->id, $isPublishedOnly);
     $accessibleCatsIds = EasyBlogHelper::getAccessibleCategories($parent->id);
     if (!empty($childs)) {
         for ($j = 0; $j < count($childs); $j++) {
             $child = $childs[$j];
             $child->childs = null;
             if (!$ignorePrivate) {
                 if (count($accessibleCatsIds) > 0) {
                     $access = false;
                     foreach ($accessibleCatsIds as $canAccess) {
                         if ($canAccess->id == $child->id) {
                             $access = true;
                         }
                     }
                     if (!$access) {
                         continue;
                     }
                 } else {
                     continue;
                 }
             }
             if (!$this->buildNestedCategories($child, $ignorePrivate, $isPublishedOnly)) {
                 $parent->childs[] = $child;
             }
         }
         // for $j
     } else {
         return false;
     }
 }
예제 #2
0
파일: ratings.php 프로젝트: Tommar/vino2
 /**
  * Retrieves the html codes for the ratings.
  *
  * @param	int	$uid	The unique id for the item that is being rated
  * @param	string	$type	The unique type for the item that is being rated
  * @param	string	$command	A textual representation to request user to vote for this item.
  * @param	string	$element	A dom element id.
  **/
 public function getHTML($uid, $type, $command, $elementId, $disabled = false)
 {
     $config = EasyBlogHelper::getConfig();
     if (!$config->get('main_ratings')) {
         return false;
     }
     $language = JFactory::getLanguage();
     $language->load('com_easyblog', JPATH_ROOT);
     // Add ratings to the page
     $document = JFactory::getDocument();
     $rating = EasyBlogHelper::getTable('Ratings', 'Table');
     $my = JFactory::getUser();
     $hash = $my->id > 0 ? '' : JFactory::getSession()->getId();
     $voted = $rating->fill($my->id, $uid, $type, $hash);
     $locked = $voted || $my->id < 1 && !$config->get('main_ratings_guests') || $disabled;
     $model = EasyBlogHelper::getModel('Ratings');
     $ratingValue = $model->getRatingValues($uid, $type);
     $theme = new CodeThemes();
     $theme->set('voted', $voted);
     $theme->set('elementId', $elementId);
     $theme->set('rating', $ratingValue->ratings);
     $theme->set('total', $ratingValue->total);
     $theme->set('locked', $locked);
     $theme->set('command', $command);
     $theme->set('uid', $uid);
     $theme->set('type', $type);
     return $theme->fetch('ratings.form.php');
 }
예제 #3
0
 public function get()
 {
     $input = JFactory::getApplication()->input;
     $model = EasyBlogHelper::getModel('Blog');
     $config = EasyBlogHelper::getConfig();
     $id = $input->get('id', null, 'INT');
     // If we have an id try to fetch the user
     $blog = EasyBlogHelper::getTable('Blog');
     $blog->load($id);
     if (!$id) {
         $this->plugin->setResponse($this->getErrorResponse(404, 'Blog id cannot be blank'));
         return;
     }
     if (!$blog->id) {
         $this->plugin->setResponse($this->getErrorResponse(404, 'Blog not found'));
         return;
     }
     $item = EasyBlogHelper::getHelper('SimpleSchema')->mapPost($blog, '<p><br><pre><a><blockquote><strong><h2><h3><em><ul><ol><li><iframe>');
     $item->isowner = $blog->created_by == $this->plugin->get('user')->id ? true : false;
     // Tags
     $modelPT = EasyBlogHelper::getModel('PostTag');
     $item->tags = $modelPT->getBlogTags($blog->id);
     //created by vishal - for show extra images
     //$item->text = preg_replace('/"images/i', '"'.JURI::root().'images', $item->text );
     $item->text = str_replace('href="', 'href="' . JURI::root(), $item->text);
     $item->text = str_replace('src="', 'src="' . JURI::root(), $item->text);
     $this->plugin->setResponse($item);
 }
예제 #4
0
 /**
  * Method to update ordering before a comment is saved.
  **/
 public function updateOrdering()
 {
     $model = EasyBlogHelper::getModel('Comment');
     $latestComment = $model->getLatestComment($this->post_id, $this->parent_id);
     // @rule: Processing child comments
     if ($this->parent_id != 0) {
         $parentComment = EasyBlogHelper::getTable('Comment');
         $parentComment->load($this->parent_id);
         $left = $parentComment->lft + 1;
         $right = $parentComment->lft + 2;
         $nodeVal = $parentComment->lft;
         if (!empty($latestComment)) {
             $left = $latestComment->rgt + 1;
             $right = $latestComment->rgt + 2;
             $nodeVal = $latestComment->rgt;
         }
         $model->updateCommentSibling($this->post_id, $nodeVal);
         $this->lft = $left;
         $this->rgt = $right;
         return true;
     }
     // @rule: Processing new comments
     $left = 1;
     $right = 2;
     if (!empty($latestComment)) {
         $left = $latestComment->rgt + 1;
         $right = $latestComment->rgt + 2;
         $model->updateCommentSibling($this->post_id, $latestComment->rgt);
     }
     $this->lft = $left;
     $this->rgt = $right;
     return true;
 }
예제 #5
0
 public function get()
 {
     $input = JFactory::getApplication()->input;
     $model = EasyBlogHelper::getModel('Blog');
     $category = EasyBlogHelper::getTable('Category', 'Table');
     $id = $input->get('id', null, 'INT');
     $search = $input->get('search', null, 'STRING');
     $posts = array();
     if (!isset($id)) {
         $categoriesmodel = EasyBlogHelper::getModel('Categories');
         $categories = $categoriesmodel->getCategoryTree('ordering');
         $this->plugin->setResponse($categories);
         return;
     }
     $category->load($id);
     // private category shouldn't allow to access.
     $privacy = $category->checkPrivacy();
     if (!$category->id || !$privacy->allowed) {
         $this->plugin->setResponse($this->getErrorResponse(404, 'Category not found'));
         return;
     }
     $catIds = array();
     $catIds[] = $category->id;
     EasyBlogHelper::accessNestedCategoriesId($category, $catIds);
     $sorting = $this->plugin->params->get('sorting', 'latest');
     $rows = $model->getBlogsBy('category', $catIds, $sorting, 0, EBLOG_FILTER_PUBLISHED, $search);
     foreach ($rows as $k => $v) {
         $item = EasyBlogHelper::getHelper('SimpleSchema')->mapPost($v, '', 100, array('text'));
         $item->isowner = $v->created_by == $this->plugin->get('user')->id ? true : false;
         $posts[] = $item;
     }
     $this->plugin->setResponse($posts);
 }
예제 #6
0
파일: view.ejax.php 프로젝트: Tommar/vino2
 function likesComment($contentId, $status, $likesId)
 {
     $my = JFactory::getUser();
     $ejax = new Ejax();
     if ($my->id <= 0) {
         $ejax->alert(JText::_('COM_EASYBLOG_NOT_ALLOWED'), '', '450');
         $ejax->send();
         return;
     }
     $jsLink = '';
     if ($status) {
         // add likes
         $id = EasyBlogHelper::addLikes($contentId, 'comment', $my->id);
         $jsLink = "<a href=\"javascript:eblog.comment.likes('" . $contentId . "', '0', '" . $id . "');\" class=\"likes\">" . JText::_('COM_EASYBLOG_UNLIKE') . "</a>";
     } else {
         // remove likes
         EasyBlogHelper::removeLikes($likesId);
         $jsLink = '<b>&middot;</b>  ' . "<a href=\"javascript:eblog.comment.likes('" . $contentId . "', '1', '0');\" class=\"likes\">" . JText::_('COM_EASYBLOG_LIKES') . "</a>";
     }
     //now reformat the likes authors
     $authors = EasyBlogHelper::getLikesAuthors($contentId, 'comment', $my->id);
     $ejax->assign('likes-' . $contentId, $jsLink);
     $ejax->assign('likes-container-' . $contentId, '<b>&middot;</b>  ' . $authors);
     if (empty($authors)) {
         $ejax->script("\$('#likes-container-" . $contentId . "').hide();");
     } else {
         $ejax->script("\$('#likes-container-" . $contentId . "').show();");
     }
     $totalLikes = EasyBlogHelper::getModel('comment')->getCommentTotalLikes($contentId);
     $ejax->script("\$('#comment-likescounter-" . $contentId . "').html('Likes: " . $totalLikes . "');");
     $ejax->script("eblog.loader.doneLoading();");
     $ejax->send();
     return;
 }
예제 #7
0
 public function get()
 {
     $input = JFactory::getApplication()->input;
     $model = EasyBlogHelper::getModel('Blog');
     //$id = $input->get('id', null, 'INT');
     $id = 0;
     $search = $input->get('search', '', 'STRING');
     $featured = $input->get('featured', 0, 'INT');
     $tags = $input->get('tags', 0, 'INT');
     $user_id = $input->get('user_id', 0, 'INT');
     $posts = array();
     // If we have an id try to fetch the user
     $blog = EasyBlogHelper::table('Blog');
     $blog->load($id);
     $modelPT = EasyBlogHelper::getModel('PostTag');
     if ($tags) {
         $rows = $model->getTaggedBlogs($tags);
     } else {
         if ($featured) {
             $rows = $this->getfeature_Blog();
             $sorting = $this->plugin->params->get('sorting', 'featured');
         } else {
             if ($user_id) {
                 $blogs = EasyBlogHelper::getModel('Blog');
                 $rows = $blogs->getBlogsBy('blogger', $user_id, 'latest');
             } else {
                 //to get latest blog
                 //$sorting	= $this->plugin->params->get( 'sorting' , 'latest' );
                 //$rows 	= $model->getBlogsBy( $sorting , '' , $sorting , 0, EBLOG_FILTER_PUBLISHED, $search );
                 $rows = $model->getBlogsBy('', '', 'latest', 0, EBLOG_FILTER_PUBLISHED, null, true, array(), false, false, true, '', '', null, 'listlength', false);
                 //$rows = EB::formatter('list', $rows, false);
             }
         }
     }
     $rows = EB::formatter('list', $rows, false);
     //data mapping
     foreach ($rows as $k => $v) {
         //$item = EB::helper( 'simpleschema' )->mapPost($v,'', 100, array('text'));
         $scm_obj = new EasyBlogSimpleSchema_plg();
         $item = $scm_obj->mapPost($v, '', 100, array('text'));
         $item->tags = $modelPT->getBlogTags($item->postid);
         $item->isowner = $v->created_by == $this->plugin->get('user')->id ? true : false;
         if ($v->blogpassword != '') {
             $item->ispassword = true;
         } else {
             $item->ispassword = false;
         }
         $item->blogpassword = $v->blogpassword;
         $model = EasyBlogHelper::getModel('Ratings');
         $ratingValue = $model->getRatingValues($item->postid, 'entry');
         $item->rate = $ratingValue;
         $item->isVoted = $model->hasVoted($item->postid, 'entry', $this->plugin->get('user')->id);
         if ($item->rate->ratings == 0) {
             $item->rate->ratings = -2;
         }
         $posts[] = $item;
     }
     $this->plugin->setResponse($posts);
 }
예제 #8
0
 function getFilterCategory($filter_type = '*')
 {
     $filter[] = JHTML::_('select.option', '', '- ' . JText::_('Select Category') . ' -');
     $model = EasyBlogHelper::getModel('Categories', true);
     $categories = $model->getAllCategories();
     foreach ($categories as $cat) {
         $filter[] = JHTML::_('select.option', $cat->id, $cat->title);
     }
     return JHTML::_('select.genericlist', $filter, 'filter_category', 'class="inputbox" size="1" onchange="submitform( );"', 'value', 'text', $filter_type);
 }
예제 #9
0
 public function mapPost($row, $strip_tags = '', $text_length = 0, $skip = array())
 {
     $config = EasyBlogHelper::getConfig();
     $blog = EasyBlogHelper::getTable('Blog');
     $blog->load($row->id);
     $profile = EasyBlogHelper::getTable('Profile', 'Table');
     $profile->load($row->created_by);
     $created = EasyBlogDateHelper::dateWithOffSet($row->created);
     $formatDate = true;
     if (EasyBlogHelper::getJoomlaVersion() >= '1.6') {
         $langCode = EasyBlogStringHelper::getLangCode();
         if ($langCode != 'en-GB' || $langCode != 'en-US') {
             $formatDate = false;
         }
     }
     $blog->created = $created->toMySQL();
     $blog->text = $row->intro . $row->content;
     $config->set('max_video_width', 320);
     $config->set('max_video_width', 180);
     $blog->text = EasyBlogHelper::getHelper('Videos')->processVideos($blog->text);
     $blog->text = EasyBlogGoogleAdsense::stripAdsenseCode($blog->text);
     $category = EasyBlogHelper::getTable('Category', 'Table');
     $category->load($row->category_id);
     $item = new PostSimpleSchema();
     $item->textplain = $blog->text;
     // @TODO : Take care of a case when strip tags and length are used together
     if ($strip_tags) {
         $item->textplain = strip_tags($blog->text, $strip_tags);
     }
     if ($text_length > 0) {
         $pos = JString::strpos(strip_tags($item->textplain), ' ', $text_length);
         $item->textplain = JString::substr(strip_tags($blog->text), 0, $pos);
     }
     $image_data = json_decode($blog->image);
     $item->postid = $blog->id;
     $item->title = $blog->title;
     $item->text = $blog->text;
     $item->textplain = $this->sanitize($item->textplain);
     $item->image = $blog->getImage();
     $item->image->url = $image_data->url;
     $item->created_date = $blog->created;
     $item->created_date_elapsed = EasyBlogDateHelper::getLapsedTime($blog->created);
     $item->author->name = $profile->nickname;
     $item->author->photo = JURI::root() . $profile->avatar;
     $item->category->categoryid = $category->id;
     $item->category->title = $category->title;
     $item->url = JURI::root() . trim(EasyBlogRouter::_('index.php?option=com_easyblog&view=entry&id=' . $blog->id), '/');
     // Tags
     $modelPT = EasyBlogHelper::getModel('PostTag');
     $item->tags = $modelPT->getBlogTags($blog->id);
     foreach ($skip as $v) {
         unset($item->{$v});
     }
     return $item;
 }
예제 #10
0
 public function getItems()
 {
     $catid = $this->get('ezb_catfilter') ? $this->get('ezb_catid', NULL) : '';
     $ordering = $this->get('ezb_ordering', 'latest');
     $user = JFactory::getUser();
     $category = EasyBlogHelper::getTable('Category', 'Table');
     $category->load($catid);
     if ($category->private && $user->id == 0) {
         echo JText::_('This category is set to private');
         return;
     }
     if (!class_exists('EasyBlogModelBlog')) {
         jimport('joomla.application.component.model');
         JLoader::import('blog', EBLOG_ROOT . '/' . 'models');
     }
     $model = EasyBlogHelper::getModel('Blog');
     if ($this->get('ezfeatured')) {
         $items = $model->getFeaturedBlog($catid, $this->get('count'));
     } else {
         $items = $model->getBlogsBy('category', $catid, $ordering, $this->get('count'), EBLOG_FILTER_PUBLISHED, null, false);
     }
     $config = EasyBlogHelper::getConfig();
     if (!empty($items)) {
         for ($i = 0; $i < count($items); $i++) {
             $row =& $items[$i];
             $author = EasyBlogHelper::getTable('Profile', 'Table');
             $row->author = $author->load($row->created_by);
             $row->commentCount = EasyBlogHelper::getCommentCount($row->id);
             $requireVerification = false;
             if ($config->get('main_password_protect', true) && !empty($row->blogpassword)) {
                 $row->title = JText::sprintf('COM_EASYBLOG_PASSWORD_PROTECTED_BLOG_TITLE', $row->title);
                 $requireVerification = true;
             }
             if ($requireVerification && !EasyBlogHelper::verifyBlogPassword($row->blogpassword, $row->id)) {
                 $theme = new CodeThemes();
                 $theme->set('id', $row->id);
                 $theme->set('return', base64_encode(EasyBlogRouter::_('index.php?option=com_easyblog&view=entry&id=' . $row->id)));
                 $row->introtext = $theme->fetch('blog.protected.php');
                 $row->content = $row->introtext;
                 $row->showRating = false;
                 $row->protect = true;
             } else {
                 $row->introtext = EasyBlogHelper::getHelper('Videos')->strip($row->content);
                 $row->showRating = true;
                 $row->protect = false;
             }
         }
         //end foreach
     }
     //XEFUtility::debug($items);
     $items = $this->prepareItems($items);
     return $items;
 }
예제 #11
0
 public function get()
 {
     $input = JFactory::getApplication()->input;
     $model = EasyBlogHelper::getModel('Blog');
     //$id = $input->get('id', null, 'INT');
     $search = $input->get('search', null, 'STRING');
     $featured = $input->get('featured', 0, 'INT');
     $tags = $input->get('tags', 0, 'INT');
     $user_id = $input->get('user_id', 0, 'INT');
     $posts = array();
     // If we have an id try to fetch the user
     $blog = EasyBlogHelper::getTable('Blog');
     $blog->load($id);
     $modelPT = EasyBlogHelper::getModel('PostTag');
     //~ if ($id && !$tags) {
     //~ if(!$blog->id)
     //~ {
     //~ $this->plugin->setResponse( $this->getErrorResponse(404, 'Blog not found') );
     //~ return;
     //~ }
     //~ $this->plugin->setResponse( $blog );
     //~ }
     if ($tags) {
         $rows = $model->getTaggedBlogs($tags);
     } else {
         if ($featured) {
             $rows = $this->getfeature_Blog();
             $sorting = $this->plugin->params->get('sorting', 'featured');
         } else {
             if ($user_id) {
                 $blogs = EasyBlogHelper::getModel('Blog');
                 $rows = $blogs->getBlogsBy('blogger', $user_id, 'latest');
             } else {
                 //to get latest blog
                 $sorting = $this->plugin->params->get('sorting', 'latest');
                 $rows = $model->getBlogsBy($sorting, '', $sorting, 0, EBLOG_FILTER_PUBLISHED, $search);
             }
         }
     }
     //data mapping
     foreach ($rows as $k => $v) {
         $item = EasyBlogHelper::getHelper('SimpleSchema')->mapPost($v, '', 100, array('text'));
         $item->tags = $modelPT->getBlogTags($item->postid);
         $item->isowner = $v->created_by == $this->plugin->get('user')->id ? true : false;
         $posts[] = $item;
     }
     $this->plugin->setResponse($posts);
 }
예제 #12
0
파일: view.ejax.php 프로젝트: Tommar/vino2
 public function vote($value, $uid, $type, $elementId)
 {
     $ajax = new Ejax();
     $my = JFactory::getUser();
     $config = EasyBlogHelper::getConfig();
     $blog = EasyBlogHelper::getTable('Blog', 'Table');
     $blog->load($uid);
     if ($config->get('main_password_protect', true) && !empty($blog->blogpassword)) {
         if (!EasyBlogHelper::verifyBlogPassword($blog->blogpassword, $blog->id)) {
             echo 'Invalid Access.';
             exit;
         }
     }
     $rating = EasyBlogHelper::getTable('Ratings', 'Table');
     // Do not allow guest to vote, or if the voter already voted.
     if ($rating->fill($my->id, $uid, $type, JFactory::getSession()->getId()) || $my->id < 1 && !$config->get('main_ratings_guests')) {
         // We wouldn't allow user to vote more than once so don't do anything here
         $ajax->send();
     }
     $rating->set('created_by', $my->id);
     $rating->set('type', $type);
     $rating->set('uid', $uid);
     $rating->set('ip', @$_SERVER['REMOTE_ADDR']);
     $rating->set('value', (int) $value);
     $rating->set('sessionid', JFactory::getSession()->getId());
     $rating->set('created', EasyBlogHelper::getDate()->toMySQL());
     $rating->set('published', 1);
     $rating->store();
     $model = EasyBlogHelper::getModel('Ratings');
     $ratingValue = $model->getRatingValues($uid, $type);
     $total = $ratingValue->total;
     $rating = $ratingValue->ratings;
     // Assign badge for users that report blog post.
     // Only give points if the viewer is viewing another person's blog post.
     EasyBlogHelper::getHelper('EasySocial')->assignBadge('blog.rate', JText::_('COM_EASYBLOG_EASYSOCIAL_BADGE_RATED_BLOG'));
     $ajax->script('eblog.loader.doneLoading("' . $elementId . '-command .ratings-text")');
     $ajax->script('eblog.ratings.update("' . $elementId . '", "' . $type . '" , "' . $rating . '" , "' . JText::_('COM_EASYBLOG_RATINGS_RATED_THANK_YOU') . '");');
     $ajax->assign($elementId . ' .ratings-value', '<i></i>' . $total . '<b>&radic;</b>');
     if (EasyBlogHelper::isAUPEnabled()) {
         $id = AlphaUserPointsHelper::getAnyUserReferreID($my->id);
         AlphaUserPointsHelper::newpoints('plgaup_easyblog_rate_blog', $id, '', JText::sprintf('COM_EASYBLOG_AUP_BLOG_RATED'), '');
     }
     $ajax->send();
 }
예제 #13
0
    public function changeCategory()
    {
        $ajax = new Ejax();
        $options = new stdClass();
        $options->title = JText::_('COM_EASYBLOG_MOVE');
        $filter[] = JHTML::_('select.option', '', '- ' . JText::_('COM_EASYBLOG_SELECT_CATEGORY') . ' -');
        $model = EasyBlogHelper::getModel('Categories', true);
        $categories = $model->getAllCategories();
        foreach ($categories as $cat) {
            $filter[] = JHTML::_('select.option', $cat->id, $cat->title);
        }
        $action = EasyBlogHelper::getJoomlaVersion() >= '1.6' ? 'Joomla.submitbutton(\'moveCategory\');' : 'submitbutton(\'moveCategory\')';
        ob_start();
        ?>
		<p><?php 
        echo JText::_('COM_EASYBLOG_CHANGE_CATEGORY_DIALOG_INFO');
        ?>
</p>
		<div style="margin-top:10px;">
			<?php 
        echo JHTML::_('select.genericlist', $filter, 'move_category', 'class="inputbox" size="1"', 'value', 'text', '');
        ?>
		</div>
		<div class="dialog-actions">
			<input type="button" onclick="ejax.closedlg();" name="edialog-cancel" id="edialog-cancel" class="button" value="<?php 
        echo JText::_('COM_EASYBLOG_CANCEL_BUTTON');
        ?>
">
			<input type="button" onclick="<?php 
        echo $action;
        ?>
" class="button" value="<?php 
        echo JText::_('COM_EASYBLOG_MOVE_POSTS_BUTTON');
        ?>
">
		</div>
		<?php 
        $options->content = ob_get_contents();
        ob_end_clean();
        $ajax->dialog($options);
        $ajax->send();
    }
예제 #14
0
 /**
  * Joomla 2.5 trigger.
  *
  * @since	3.7
  * @access	public
  */
 public function onUserAfterSave($data, $isNew, $result, $error)
 {
     //j.16
     $this->onAfterStoreUser($data);
     $userId = JArrayHelper::getValue($data, 'id', 0, 'int');
     // Process user subscription
     if ($userId && $result && isset($data['easyblog']) && count($data['easyblog'])) {
         if (!empty($data['easyblog']['subscribe']) && $data['easyblog']['subscribe'] == '1') {
             $model = EasyBlogHelper::getModel('Subscription');
             $exists = $model->isSiteSubscribedUser($userId, $data['email']);
             if ($exists) {
                 // user found update the email address
                 $model->updateSiteSubscriptionEmail($exists, $userId, $data['email']);
                 return true;
             }
             $model->addSiteSubscription($data['email'], $userId, $data['name']);
             return true;
         }
     }
 }
예제 #15
0
 function display($tpl = null)
 {
     // @rule: Test for user access if on 1.6 and above
     if (EasyBlogHelper::getJoomlaVersion() >= '1.6') {
         if (!JFactory::getUser()->authorise('easyblog.manage.acl', 'com_easyblog')) {
             JFactory::getApplication()->redirect('index.php', JText::_('JERROR_ALERTNOAUTHOR'), 'error');
             JFactory::getApplication()->close();
         }
     }
     //initialise variables
     $document = JFactory::getDocument();
     $user = JFactory::getUser();
     $mainframe = JFactory::getApplication();
     $model = EasyBlogHelper::getModel('Acl', true);
     $config = EasyBlogHelper::getConfig();
     $type = $mainframe->getUserStateFromRequest('com_easyblog.acls.filter_type', 'filter_type', 'group', 'word');
     //filtering
     $filter = new stdClass();
     $filter->type = $this->getFilterType($type);
     $filter->search = $mainframe->getUserStateFromRequest('com_easyblog.acls.search', 'search', '', 'string');
     //sorting
     $sort = new stdClass();
     $sort->order = $mainframe->getUserStateFromRequest('com_easyblog.acls.filter_order', 'filter_order', 'a.`id`', 'cmd');
     $sort->orderDirection = $mainframe->getUserStateFromRequest('com_easyblog.acls.filter_order_Dir', 'filter_order_Dir', '', 'word');
     $rulesets = $model->getRuleSets($type);
     $pagination = $model->getPagination($type);
     if ($type == 'assigned') {
         $document->setTitle(JText::_("COM_EASYBLOG_ACL_ASSIGN_USER"));
         JToolBarHelper::title(JText::_('COM_EASYBLOG_ACL_ASSIGN_USER'), 'acl');
     } else {
         $document->setTitle(JText::_("COM_EASYBLOG_ACL_JOOMLA_USER_GROUP"));
         JToolBarHelper::title(JText::_('COM_EASYBLOG_ACL_JOOMLA_USER_GROUP'), 'acl');
     }
     $this->assignRef('config', $config);
     $this->assignRef('rulesets', $rulesets);
     $this->assignRef('filter', $filter);
     $this->assignRef('sort', $sort);
     $this->assignRef('type', $type);
     $this->assignRef('pagination', $pagination);
     parent::display($tpl);
 }
예제 #16
0
 public function searchTag()
 {
     $app = JFactory::getApplication();
     $limitstart = $app->input->get('limitstart', 0, 'INT');
     $limit = $app->input->get('limit', 20, 'INT');
     $Tagmodel = EasyBlogHelper::getModel('Tags');
     $input = JFactory::getApplication()->input;
     $keyword = $input->get('title', '', 'STRING');
     $wordSearch = true;
     $db = EB::db();
     $query = array();
     $search = $wordSearch ? '%' . $keyword . '%' : $keyword . '%';
     $query[] = 'SELECT * FROM ' . $db->quoteName('#__easyblog_tag');
     $query[] = 'WHERE ' . $db->quoteName('title') . ' LIKE ' . $db->Quote($search);
     $query[] = 'AND ' . $db->quoteName('published') . '=' . $db->Quote(1);
     $query = implode(' ', $query);
     $db->setQuery($query);
     $result = $db->loadObjectList();
     $output = array_slice($result, $limitstart, $limit);
     return $output;
 }
예제 #17
0
 function display($tpl = null)
 {
     // @rule: Test for user access if on 1.6 and above
     if (EasyBlogHelper::getJoomlaVersion() >= '1.6') {
         if (!JFactory::getUser()->authorise('easyblog.manage.teamblog', 'com_easyblog')) {
             JFactory::getApplication()->redirect('index.php', JText::_('JERROR_ALERTNOAUTHOR'), 'error');
             JFactory::getApplication()->close();
         }
     }
     //initialise variables
     $document = JFactory::getDocument();
     $user = JFactory::getUser();
     $mainframe = JFactory::getApplication();
     $id = JRequest::getInt('id');
     JHTML::_('behavior.modal', 'a.modal');
     $document = JFactory::getDocument();
     $document->addStyleSheet(JURI::root() . 'components/com_easyblog/assets/css/common.css');
     $team = EasyBlogHelper::getTable('TeamBlog', 'Table');
     $team->load($id);
     $this->team = $team;
     $blogAccess = array();
     $blogAccess[] = JHTML::_('select.option', '1', JText::_('COM_EASYBLOG_TEAM_MEMBER_ONLY'));
     $blogAccess[] = JHTML::_('select.option', '2', JText::_('COM_EASYBLOG_ALL_REGISTERED_USERS'));
     $blogAccess[] = JHTML::_('select.option', '3', JText::_('COM_EASYBLOG_EVERYONE'));
     $blogAccessList = JHTML::_('select.genericlist', $blogAccess, 'access', 'size="1" class="inputbox"', 'value', 'text', $team->access);
     $config = EasyBlogHelper::getConfig();
     $editor = JFactory::getEditor($config->get('layout_editor'));
     // get meta tags
     $metaModel = EasyBlogHelper::getModel('Metas');
     $meta = $metaModel->getMetaInfo(META_TYPE_TEAM, $id);
     $joomlaVersion = EasyBlogHelper::getJoomlaVersion();
     $this->assignRef('joomlaversion', $joomlaVersion);
     $this->assignRef('editor', $editor);
     $this->assignRef('team', $team);
     $this->assignRef('meta', $meta);
     $this->assignRef('config', $config);
     $this->assignRef('blogAccessList', $blogAccessList);
     parent::display($tpl);
 }
예제 #18
0
파일: dashboard.php 프로젝트: Tommar/vino2
 function listBloggers()
 {
     // Anyone with moderate_entry acl is also allowed to change author.
     $acl = EasyBlogACLHelper::getRuleSet();
     if (!EasyBlogHelper::isSiteAdmin() && !$acl->rules->moderate_entry) {
         echo JText::_('COM_EASYBLOG_NOT_ALLOWED');
         return;
     }
     // $model 		= $this->getModel( 'Users' );
     $model = EasyBlogHelper::getModel('Users');
     $rows = $model->getUsers(true);
     $users = array();
     JTable::addIncludePath(EBLOG_TABLES);
     foreach ($rows as $row) {
         $user = EasyBlogHelper::getTable('Profile', 'Table');
         $user->load($row->id);
         $users[] = $user;
     }
     $pagination = $model->getPagination(true);
     $orderDir = JRequest::getVar('filter_order_Dir', '', 'REQUEST');
     switch ($orderDir) {
         case 'asc':
             $orderDir = 'desc';
             break;
         case 'desc':
         default:
             $orderDir = 'asc';
     }
     $order = JRequest::getVar('filter_order', 'name', 'REQUEST');
     $search = JRequest::getVar('search', '', 'REQUEST');
     $filter_state = JRequest::getVar('filter_state', 'P', 'REQUEST');
     $tpl = new CodeThemes('dashboard');
     $tpl->set('users', $users);
     $tpl->set('pagination', $pagination);
     $tpl->set('orderDir', $orderDir);
     $tpl->set('order', $order);
     $tpl->set('search', $search);
     $tpl->set('filter_state', $filter_state);
     echo $tpl->fetch('dashboard.users.php');
     return;
 }
예제 #19
0
 /**
  * Get a list of tag objects that are associated with this blog post.
  *
  * @access	public
  * @param	null
  * @return	Array	An Array of TableTag objects.
  */
 public function getTags()
 {
     // @task: Get the tags relations model.
     $model = EasyBlogHelper::getModel('PostTag');
     $result = $model->getBlogTags($this->id);
     return $result;
 }
예제 #20
0
 /**
  * Plugin that returns the object list for DJ-Mediatools album
  * 
  * Each object must contain following properties (mandatory): title, description, image
  * Optional properties: link, target (_blank or _self), alt (alt attribute for image)
  * 
  * @param	object	The album params
  */
 public function onAlbumPrepare(&$source, &$params)
 {
     // Lets check the requirements
     $check = $this->onCheckRequirements($source);
     if (is_null($check) || is_string($check)) {
         return null;
     }
     $app = JFactory::getApplication();
     $default_image = $params->get('plg_easyblog_image');
     $path = JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_easyblog' . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR . 'helper.php';
     if (!JFile::exists($path)) {
         return null;
     }
     require_once $path;
     require_once EBLOG_HELPERS . DIRECTORY_SEPARATOR . 'router.php';
     JFactory::getLanguage()->load('com_easyblog', JPATH_ROOT);
     $mparams = new JRegistry();
     $count = $params->get('max_images');
     $sort = array();
     $sort[0] = $params->get('plg_easyblog_order');
     $sort[1] = $params->get('plg_easyblog_order_dir');
     $featured = $params->get('plg_easyblog_usefeatured');
     $type = 'latest';
     $model = EasyBlogHelper::getModel('Blog');
     $categories = EasyBlogHelper::getCategoryInclusion($params->get('plg_easyblog_catid'));
     $catIds = array();
     if (!empty($categories)) {
         if (!is_array($categories)) {
             $categories = array($categories);
         }
         foreach ($categories as $item) {
             $category = new stdClass();
             $category->id = trim($item);
             $catIds[] = $category->id;
             if ($params->get('plg_easyblog_includesubcategory', 0)) {
                 $category->childs = null;
                 EasyBlogHelper::buildNestedCategories($category->id, $category, false, true);
                 EasyBlogHelper::accessNestedCategoriesId($category, $catIds);
             }
         }
         $catIds = array_unique($catIds);
     }
     $cid = $catIds;
     if (!empty($cid)) {
         $type = 'category';
     }
     $posts = $model->getBlogsBy($type, $cid, $sort, $count, EBLOG_FILTER_PUBLISHED, null, $featured, array(), false, false, true, array(), $cid);
     $slides = array();
     foreach ($posts as $item) {
         $slide = (object) array();
         $row = EasyBlogHelper::getTable('Blog', 'Table');
         $row->bind($item);
         $image = $row->getImage();
         if (!empty($image)) {
             $slide->image = str_replace(JURI::base(), '', $image->getSource('original'));
         } else {
             $slide->image = DJMediatoolsLayoutHelper::getImageFromText($item->intro);
         }
         // if no image found in images and introtext then try fulltext
         if (empty($slide->image)) {
             $slide->image = DJMediatoolsLayoutHelper::getImageFromText($item->content);
         }
         // if no image found in fulltext then take default image
         if (empty($slide->image)) {
             $slide->image = $default_image;
         }
         // if no default image set then don't display this article
         if (empty($slide->image)) {
             continue;
         }
         $slide->title = $item->title;
         $slide->description = $item->intro;
         if (empty($slide->description)) {
             $slide->description = $item->content;
         }
         $slide->canonical = $slide->link = EasyBlogRouter::_('index.php?option=com_easyblog&view=entry&id=' . $item->id);
         //.'&Itemid='. EasyBlogRouter::getItemIdByCategories( $item->category_id ) );
         $slide->id = $item->id . ':' . $item->permalink;
         //$this->dd($item);
         if ($comments = $params->get('commnets', 0)) {
             $host = str_replace(JURI::root(true), '', JURI::root());
             $host = preg_replace('/\\/$/', '', $host);
             switch ($comments) {
                 case 1:
                     // jcomments
                     $slide->comments = array('id' => $item->id, 'group' => 'com_easyblog');
                     break;
                 case 2:
                     // disqus
                     $disqus_shortname = $params->get('disqus_shortname', '');
                     if (!empty($disqus_shortname)) {
                         $slide->comments = array();
                         $slide->comments['url'] = $host . $slide->link;
                         $slide->comments['identifier'] = $disqus_shortname . '-easyblog-' . $item->id;
                         // ??
                     }
                     break;
                 case 3:
                     // facebook
                     $slide->comments = $host . $slide->link;
                     break;
                 case 4:
                     //komento
                     // not implemented
                     break;
             }
         }
         $slides[] = $slide;
     }
     return $slides;
 }
예제 #21
0
 public function get()
 {
     $input = JFactory::getApplication()->input;
     $model = EasyBlogHelper::getModel('Blog');
     $category = EasyBlogHelper::table('Category', 'Table');
     $id = $input->get('id', null, 'INT');
     $search = $input->get('search', null, 'STRING');
     $posts = array();
     if (!isset($id)) {
         $categoriesmodel = EasyBlogHelper::getModel('Categories');
         $categories = $categoriesmodel->getCategoryTree('ordering');
         $this->plugin->setResponse($categories);
         return;
     }
     $category->load($id);
     // private category shouldn't allow to access.
     $privacy = $category->checkPrivacy();
     if (!$category->id || !$privacy->allowed) {
         $this->plugin->setResponse($this->getErrorResponse(404, 'Category not found'));
         return;
     }
     //new code
     $category = EB::table('Category');
     $category->load($id);
     //get the nested categories
     $category->childs = null;
     // Build nested childsets
     EB::buildNestedCategories($category->id, $category, false, true);
     $catIds = array();
     $catIds[] = $category->id;
     EB::accessNestedCategoriesId($category, $catIds);
     // Get the category model
     $model = EB::model('Category');
     // Get total posts in this category
     $category->cnt = $model->getTotalPostCount($category->id);
     // Get teamblog posts count
     // $teamBlogCount = $model->getTeamBlogCount($category->id);
     $limit = EB::call('Pagination', 'getLimit', array(EBLOG_PAGINATION_CATEGORIES));
     // Get the posts in the category
     $data = $model->getPosts($catIds, $limit);
     $rows = EB::formatter('list', $data);
     //end
     foreach ($rows as $k => $v) {
         //$item = EasyBlogHelper::getHelper( 'SimpleSchema' )->mapPost($v, '', 100, array('text'));
         $scm_obj = new EasyBlogSimpleSchema_plg();
         $item = $scm_obj->mapPost($v, '', 100, array('text'));
         $item->isowner = $v->created_by == $this->plugin->get('user')->id ? true : false;
         if ($v->blogpassword != '') {
             $item->ispassword = true;
         } else {
             $item->ispassword = false;
         }
         $item->blogpassword = $v->blogpassword;
         $model = EasyBlogHelper::getModel('Ratings');
         $ratingValue = $model->getRatingValues($item->postid, 'entry');
         $item->rate = $ratingValue;
         $item->isVoted = $model->hasVoted($item->postid, 'entry', $this->plugin->get('user')->id);
         if ($item->rate->ratings == 0) {
             $item->rate->ratings = -2;
         }
         $posts[] = $item;
     }
     $this->plugin->setResponse($posts);
 }
예제 #22
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();
 }
예제 #23
0
 private function _migrateJACommentChildIntoEasyBlog($blogId, $oldId, $newId)
 {
     $db = EasyBlogHelper::db();
     // get all direct child comments with $oldId as parent
     $query = 'SELECT * FROM `#__jacomment_itmes`';
     $query .= ' WHERE `parentid` = ' . $db->quote($oldId);
     $query .= ' ORDER BY `date`';
     $db->setQuery($query);
     $children = $db->loadObjectList();
     // migrate child by child
     foreach ($children as $child) {
         // set the node to the parent as default
         $parent = EasyBlogHelper::getTable('Comment', 'Table');
         $parent->load($newId);
         $node = $parent->lft;
         // check and see if the parent comment (has already migrated to easyblog) contains any child comment existing or not
         // if this parent comment contains child comment, then use the latest child comment's as node
         $model = EasyBlogHelper::getModel('comments');
         $latest = $model->getLatestComment($blogId, $newId);
         if (!empty($latest)) {
             $node = $latest->rgt;
         }
         // update all sibling to make room for this comment
         $model->updateCommentSibling($blogId, $node);
         // set the lft rgt value for this comment
         $child->lft = $node + 1;
         $child->rgt = $node + 2;
         // store the comment
         $new = EasyBlogHelper::getTable('Comment', 'Table');
         $new->post_id = $blogId;
         $new->parent_id = $newId;
         $new->comment = $child->comment;
         $new->title = $child->contenttitle;
         $new->name = $child->name;
         $new->email = $child->email;
         $new->url = $child->website;
         $new->created_by = $child->userid;
         $new->created = $child->date;
         $new->published = $child->published;
         $new->ip = $child->ip;
         $new->lft = $child->lft;
         $new->rgt = $child->rgt;
         $new->store();
         // oldId is $child->id
         $oldId = $parent->id;
         // newId is $new->id
         $newId = $new->id;
         // check for any direct child comment for this child
         // the oldId will be used to find the direct child comments with oldId as parent id
         // the newId will be used as the child's new parent id
         $this->_migrateJACommentChildIntoEasyBlog($blogId, $oldId, $newId);
     }
 }
예제 #24
0
 public function getSiteSubscriberEmails(&$emails = array())
 {
     $model = EasyBlogHelper::getModel('Subscription');
     $subscribers = $model->getSiteSubscribers();
     if (!empty($subscribers)) {
         foreach ($subscribers as $subscriber) {
             if (!array_key_exists($subscriber->email, $emails)) {
                 $obj = new stdClass();
                 $obj->email = $subscriber->email;
                 $obj->unsubscribe = EasyBlogHelper::getUnsubscribeLink($subscriber, true);
                 $emails[$subscriber->email] = $obj;
             }
         }
     }
 }
예제 #25
0
파일: microblog.php 프로젝트: Tommar/vino2
 public function processCommentMailbox()
 {
     /*
      * Check enabled
      */
     $config = EasyBlogHelper::getConfig();
     $debug = JRequest::getBool('debug', false);
     if (!$config->get('main_comment_email')) {
         return;
     }
     $interval = (int) $config->get('main_remotepublishing_mailbox_run_interval');
     $nextrun = (int) $config->get('main_remotepublishing_mailbox_next_run');
     $nextrun = EasyBlogHelper::getDate($nextrun)->toUnix();
     $timenow = EasyBlogHelper::getDate()->toUnix();
     if ($nextrun !== 0 && $timenow < $nextrun) {
         if (!$debug) {
             echo 'time now: ' . EasyBlogHelper::getDate($timenow)->toMySQL() . "<br />\n";
             echo 'next email run: ' . EasyBlogHelper::getDate($nextrun)->toMySQL() . "<br />\n";
             return;
         }
     }
     $txOffset = EasyBlogDateHelper::getOffSet();
     $newnextrun = EasyBlogHelper::getDate('+ ' . $interval . ' minutes', $txOffset)->toUnix();
     // use $configTable to avoid variable name conflict
     $configTable = EasyBlogHelper::getTable('configs');
     $configTable->load('config');
     $parameters = new JParameter($configTable->params);
     $parameters->set('main_remotepublishing_mailbox_next_run', $newnextrun);
     $configTable->params = $parameters->toString('ini');
     $configTable->store();
     /*
      * Connect to mailbox
      */
     require_once JPATH_ROOT . DS . 'components' . DS . 'com_easyblog' . DS . 'classes' . DS . 'mailbox.php';
     $mailbox = new EasyblogMailbox();
     if (!$mailbox->connect()) {
         $mailbox->disconnect();
         echo 'Comment Mailbox: Could not connect to mailbox.';
         return false;
     }
     $total = 0;
     /*
      * Get data from mailbox
      */
     $total_mails = $mailbox->getMessageCount();
     if ($total_mails < 1) {
         // No mails in mailbox
         $mailbox->disconnect();
         echo 'Comment Mailbox: No emails found.';
         return false;
     }
     // Let's get the correct mails
     $messages = $mailbox->searchMessages('UNSEEN');
     if ($messages) {
         $prefix = '/\\[\\#(.*)\\]/is';
         $filter = JFilterInput::getInstance();
         $db = EasyBlogHelper::db();
         foreach ($messages as $messageSequence) {
             $info = $mailbox->getMessageInfo($messageSequence);
             $from = $info->fromemail;
             $senderName = $info->from[0]->personal;
             $subject = $filter->clean($info->subject);
             // @rule: Detect if this is actually a reply.
             preg_match('/\\[\\#(.*)\\]/is', $subject, $matches);
             // If the title doesn't match the comment specific title, just continue the block.
             if (empty($matches)) {
                 continue;
             }
             $query = 'SELECT ' . $db->nameQuote('id') . ' FROM ' . $db->nameQuote('#__users') . ' ' . 'WHERE ' . $db->nameQuote('email') . '=' . $db->Quote($from);
             $db->setQuery($query);
             $userId = $db->loadResult();
             $commentId = $matches[1];
             $refComment = EasyBlogHelper::getTable('Comment');
             $refComment->load($commentId);
             // Get the message contents.
             $message = new EasyblogMailboxMessage($mailbox->stream, $messageSequence);
             $message->getMessage();
             $content = $message->getPlain();
             // If guest commenting is not allowed, and user's email does not exist in system, pass this.
             if (!$config->get('main_allowguestcomment') && !$userId) {
                 continue;
             }
             // Apply akismet filtering
             if ($config->get('comment_akismet')) {
                 $data = array('author' => $senderName, 'email' => $from, 'website' => JURI::root(), 'body' => $content, 'permalink' => EasyBlogRouter::_('index.php?option=com_easyblog&view=entry&id=' . $refComment->post_id));
                 if (EasyBlogHelper::getHelper('Akismet')->isSpam($data)) {
                     continue;
                 }
             }
             $model = EasyBlogHelper::getModel('Comment');
             $comment = EasyBlogHelper::getTable('Comment');
             $comment->name = $senderName;
             $comment->email = $from;
             $comment->comment = $content;
             $comment->post_id = $refComment->post_id;
             $date = EasyBlogHelper::getDate();
             $comment->created = $date->toMySQL();
             $comment->modified = $date->toMySQL();
             $comment->published = 1;
             if ($userId) {
                 $comment->created_by = $userId;
             }
             $comment->sent = 0;
             $isModerated = false;
             // Update publish status if the comment requires moderation
             if ($config->get('comment_moderatecomment') == 1 || !$userId && $config->get('comment_moderateguestcomment') == 1) {
                 $comment->set('published', EBLOG_COMMENT_STATUS_MODERATED);
                 $isModerated = true;
             }
             $blog = EasyBlogHelper::getTable('Blog');
             $blog->load($comment->post_id);
             // If moderation for author is disabled, ensure that the comment is published.
             // If the author is the owner of the blog, it should never be moderated.
             if (!$config->get('comment_moderateauthorcomment') && $blog->created_by == $userId) {
                 $comment->set('published', 1);
                 $isModerated = false;
             }
             if (!$comment->store()) {
                 echo 'Error storing comment: ' . $comment->getError();
                 return;
             }
             echo '* Added comment for post <strong>' . $blog->title . '</strong><br />';
             // @rule: Process notifications
             $comment->processEmails($isModerated, $blog);
             // Update the sent flag
             $comment->updateSent();
             $total++;
         }
     }
     /*
      * Disconnect from mailbox
      */
     $mailbox->disconnect();
     /*
      * Generate report
      */
     echo JText::sprintf('Comment Mailbox: %1s comments fetched from mailbox: ' . $config->get('main_remotepublishing_mailbox_remotesystemname') . '.', $total);
 }
예제 #26
0
 function display($tpl = null)
 {
     // @rule: Test for user access if on 1.6 and above
     if (EasyBlogHelper::getJoomlaVersion() >= '1.6') {
         if (!JFactory::getUser()->authorise('easyblog.manage.blog', 'com_easyblog')) {
             JFactory::getApplication()->redirect('index.php', JText::_('JERROR_ALERTNOAUTHOR'), 'error');
             JFactory::getApplication()->close();
         }
     }
     // Load the front end language file.
     $lang = JFactory::getLanguage();
     $lang->load('com_easyblog', JPATH_ROOT);
     // Initial variables.
     $doc = JFactory::getDocument();
     $my = JFactory::getUser();
     $app = JFactory::getApplication();
     $acl = EasyBlogACLHelper::getRuleSet();
     $config = EasyBlogHelper::getConfig();
     // Load the JEditor object
     $editor = JFactory::getEditor($config->get('layout_editor', 'tinymce'));
     // Enable datetime picker
     EasyBlogDateHelper::enableDateTimePicker();
     // required variable initiation.
     $meta = null;
     $blogContributed = array();
     $tags = null;
     $external = '';
     $extGroupId = '';
     // Event id state.
     $externalEventId = '';
     //Load blog table
     $blogId = JRequest::getVar('blogid', '');
     $blog = EasyBlogHelper::getTable('Blog', 'Table');
     $blog->load($blogId);
     $tmpBlogData = EasyBlogHelper::getSession('tmpBlogData');
     $loadFromSession = false;
     // Initialize default tags.
     $blog->tags = array();
     if (isset($tmpBlogData)) {
         $loadFromSession = true;
         $blog->bind($tmpBlogData);
         // reprocess the date offset here.
         $tzoffset = EasyBlogDateHelper::getOffSet();
         if (!empty($blog->created)) {
             $date = EasyBlogHelper::getDate($blog->created, $tzoffset);
             $blog->created = $date->toMySQL();
         }
         if (!empty($blog->publish_up) && $blog->publish_up != '0000-00-00 00:00:00') {
             $date = EasyBlogHelper::getDate($blog->publish_up, $tzoffset);
             $blog->publish_up = $date->toMySQL();
         }
         if (!empty($blog->publish_down) && $blog->publish_down != '0000-00-00 00:00:00') {
             $date = EasyBlogHelper::getDate($blog->publish_down, $tzoffset);
             $blog->publish_down = $date->toMySQL();
         }
         //bind the content from previous form
         $blog->content = $tmpBlogData['write_content'];
         if (isset($tmpBlogData['tags'])) {
             $blog->tags = $this->bindTags($tmpBlogData['tags']);
         }
         // metas
         $meta = new stdClass();
         $meta->id = '';
         $meta->keywords = isset($tmpBlogData['keywords']) ? $tmpBlogData['keywords'] : '';
         $meta->description = isset($tmpBlogData['description']) ? $tmpBlogData['description'] : '';
         if (isset($tmpBlogData['blog_contribute'])) {
             $blogContributed = $this->bindContribute($tmpBlogData['blog_contribute']);
         }
         $contributionSource = isset($tmpBlogData['blog_contribute_source']) ? $tmpBlogData['blog_contribute_source'] : '';
         if (!empty($contributionSource) && $contributionSource != 'easyblog') {
             $external = true;
             $extGroupId = $tmpBlogData['blog_contribute'];
             $externalEventId = $tmpBlogData['blog_contribute'];
         }
         $blog->unsaveTrackbacks = '';
         if (!empty($tmpBlogData['trackback'])) {
             $blog->unsaveTrackbacks = $tmpBlogData['trackback'];
         }
     }
     $draft = EasyBlogHelper::getTable('Draft', 'Table');
     $draft_id = JRequest::getVar('draft_id', '');
     $isDraft = false;
     $pending_approval = JRequest::getVar('approval', '');
     if (!empty($draft_id)) {
         //first check if the logged in user have the required acl or not.
         if (empty($acl->rules->add_entry) || empty($acl->rules->publish_entry) || empty($acl->rules->manage_pending)) {
             $message = JText::_('COM_EASYBLOG_BLOGS_BLOG_NO_PERMISSION_TO_CREATE_BLOG');
             $app->enqueueMessage($message, 'error');
             $app->redirect(JRoute::_('index.php?option=com_easyblog&view=blogs', false));
         }
         $draft->load($draft_id);
         $blog->load($draft->entry_id);
         $blog->bind($draft);
         $blog->tags = $this->bindTags(explode(',', $draft->tags));
         $blog->newtags = $blog->tags;
         $tags = $blog->tags;
         // metas
         $meta = new stdClass();
         $meta->id = '';
         $meta->keywords = $draft->metakey;
         $meta->description = $draft->metadesc;
         $blog->unsaveTrackbacks = '';
         if (!empty($draft->trackbacks)) {
             $blog->unsaveTrackbacks = $draft->trackbacks;
         }
         if ($draft->blog_contribute) {
             $blogContributed = $this->bindContribute($draft->blog_contribute);
         }
         $blog->set('id', $draft->entry_id);
         $blogId = $blog->id;
         $isDraft = true;
     }
     // set page title
     if (!empty($blogId)) {
         $doc->setTitle(JText::_('COM_EASYBLOG_BLOGS_EDIT_POST') . ' - ' . $config->get('main_title'));
         $editorTitle = JText::_('COM_EASYBLOG_BLOGS_EDIT_POST');
         // check if previous status is not Draft
         if ($blog->published != POST_ID_DRAFT) {
             $isEdit = true;
         }
     } else {
         $doc->setTitle(JText::_('COM_EASYBLOG_BLOGS_NEW_POST'));
         $editorTitle = JText::_('COM_EASYBLOG_BLOGS_NEW_POST');
         if (!$loadFromSession && !$isDraft) {
             // set to 'publish' for new blog in backend.
             $blog->published = $config->get('main_blogpublishing', '1');
         }
     }
     $author = null;
     if (!empty($blog->created_by)) {
         $creator = JFactory::getUser($blog->created_by);
         $author = EasyBlogHelper::getTable('Profile', 'Table');
         $author->setUser($creator);
         unset($creator);
     } else {
         $creator = JFactory::getUser($my->id);
         $author = EasyBlogHelper::getTable('Profile', 'Table');
         $author->setUser($creator);
         unset($creator);
     }
     //Get tag
     if (!$loadFromSession && !$isDraft) {
         $tagModel = EasyBlogHelper::getModel('PostTag', true);
         $tags = $tagModel->getBlogTags($blogId);
     }
     $tagsArray = array();
     if ($tags) {
         foreach ($tags as $data) {
             $tagsArray[] = $data->title;
         }
         $tagsString = implode(",", $tagsArray);
     }
     //prepare initial blog settings.
     $isPrivate = $config->get('main_blogprivacy', '0');
     $allowComment = $config->get('main_comment', 1);
     $allowSubscribe = $config->get('main_subscription', 1);
     $showFrontpage = $config->get('main_newblogonfrontpage', 0);
     $sendEmails = $config->get('main_sendemailnotifications', 0);
     $isSiteWide = isset($blog->issitewide) ? $blog->issitewide : '1';
     $tbModel = EasyBlogHelper::getModel('TeamBlogs', true);
     $teamBlogJoined = $tbModel->getTeamJoined($author->id);
     if (!empty($blog->id)) {
         $isPrivate = $blog->private;
         $allowComment = $blog->allowcomment;
         $allowSubscribe = $blog->subscription;
         $showFrontpage = $blog->frontpage;
         $sendEmails = $blog->send_notification_emails;
         //get user teamblog
         $teamBlogJoined = $tbModel->getTeamJoined($blog->created_by);
         if (!$isDraft) {
             $blogContributed = $tbModel->getBlogContributed($blog->id);
         }
     }
     if ($loadFromSession || $isDraft) {
         $isPrivate = $blog->private;
         $allowComment = $blog->allowcomment;
         $allowSubscribe = $blog->subscription;
         $showFrontpage = $blog->frontpage;
         $sendEmails = $blog->send_notification_emails;
     }
     if (count($blogContributed) > 0 && $blogContributed) {
         for ($i = 0; $i < count($teamBlogJoined); $i++) {
             $joined = $teamBlogJoined[$i];
             if ($joined->team_id == $blogContributed->team_id) {
                 $joined->selected = 1;
                 continue;
             }
         }
     }
     //get all tags ever created.
     $newTagsModel = EasyBlogHelper::getModel('Tags');
     if (isset($blog->newtags)) {
         $blog->newtags = array_merge($blog->newtags, $newTagsModel->getTags());
     } else {
         $blog->newtags = $newTagsModel->getTags();
     }
     //get tags used in this blog post
     if (!$loadFromSession && !$isDraft && $blogId) {
         $tagsModel = EasyBlogHelper::getModel('PostTag');
         $blog->tags = $tagsModel->getBlogTags($blogId);
     }
     //@task: List all trackbacks
     $trackbacksModel = EasyBlogHelper::getModel('TrackbackSent');
     $trackbacks = $trackbacksModel->getSentTrackbacks($blogId);
     // get meta tags
     if (!$loadFromSession && !$isDraft) {
         $metaModel = EasyBlogHelper::getModel('Metas');
         $meta = $metaModel->getPostMeta($blogId);
     }
     //perform some title string formatting
     $blog->title = $this->escape($blog->title);
     $blogger_id = !isset($blog->created_by) ? $my->id : $blog->created_by;
     $defaultCategory = empty($blog->category_id) ? EasyBlogHelper::getDefaultCategoryId() : $blog->category_id;
     $category = EasyBlogHelper::getTable('Category');
     $category->load($defaultCategory);
     $content = $blog->intro;
     // Append the readmore if necessary
     if (!empty($blog->intro) && !empty($blog->content)) {
         $content .= '<hr id="system-readmore" />';
     }
     $content .= $blog->content;
     //check if this is a external group contribution.
     $blog_contribute_source = 'easyblog';
     $external = false;
     $extGroupId = EasyBlogHelper::getHelper('Groups')->getGroupContribution($blog->id);
     $externalEventId = EasyBlogHelper::getHelper('Event')->getContribution($blog->id);
     $extGroupName = '';
     if (!empty($extGroupId)) {
         $external = $extGroupId;
         $blog_contribute_source = EasyBlogHelper::getHelper('Groups')->getGroupSourceType();
         $extGroupName = EasyBlogHelper::getHelper('Groups')->getGroupContribution($blog->id, $blog_contribute_source, 'name');
     }
     if (!empty($externalEventId)) {
         $external = $externalEventId;
         $blog_contribute_source = EasyBlogHelper::getHelper('Event')->getSourceType();
     }
     //site wide or team contribution
     $teamblogModel = EasyBlogHelper::getModel('TeamBlogs');
     $teams = !empty($blog->created_by) ? $teamblogModel->getTeamJoined($blog->created_by) : $teamblogModel->getTeamJoined($my->id);
     $this->assignRef('teams', $teams);
     $this->assignRef('isDraft', $isDraft);
     $joomlaVersion = EasyBlogHelper::getJoomlaVersion();
     $my = JFactory::getUser();
     $blogger_id = $my->id;
     $nestedCategories = '';
     $categoryselecttype = $config->get('layout_dashboardcategoryselect') == 'multitier' ? 'select' : $config->get('layout_dashboardcategoryselect');
     if ($categoryselecttype == 'select') {
         $nestedCategories = EasyBlogHelper::populateCategories('', '', 'select', 'category_id', $blog->category_id, true, true, false);
     }
     // Load media manager and get info about the files.
     require_once EBLOG_CLASSES . DIRECTORY_SEPARATOR . 'mediamanager.php';
     $mediamanager = new EasyBlogMediaManager();
     $userFolders = $mediamanager->getInfo(EasyBlogMediaManager::getAbsolutePath('', 'user'), 'folders');
     $userFiles = $mediamanager->getInfo(EasyBlogMediaManager::getAbsolutePath('', 'user'), 'files');
     $sharedFolders = $mediamanager->getInfo(EasyBlogMediaManager::getAbsolutePath('', 'shared'), 'folders');
     $sharedFiles = $mediamanager->getInfo(EasyBlogMediaManager::getAbsolutePath('', 'shared'), 'files');
     // @rule: Test if the user is already associated with Flickr
     $oauth = EasyBlogHelper::getTable('Oauth');
     $associated = $oauth->loadByUser($my->id, EBLOG_OAUTH_FLICKR);
     $jConfig = EasyBlogHelper::getJConfig();
     $this->set('flickrAssociated', $associated);
     $this->assignRef('userFolders', $userFolders);
     $this->assignRef('userFiles', $userFiles);
     $this->assignRef('sharedFolders', $sharedFolders);
     $this->assignRef('sharedFiles', $sharedFiles);
     $this->assignRef('jConfig', $jConfig);
     $this->assignRef('my', $my);
     $this->assignRef('content', $content);
     $this->assignRef('category', $category);
     $this->assignRef('blogger_id', $blogger_id);
     $this->assignRef('joomlaversion', $joomlaVersion);
     $this->assignRef('isEdit', $isEdit);
     $this->assignRef('editorTitle', $editorTitle);
     $this->assignRef('blog', $blog);
     $this->assignRef('meta', $meta);
     $this->assignRef('editor', $editor);
     $this->assignRef('tagsString', $tagsString);
     $this->assignRef('acl', $acl);
     $this->assignRef('isPrivate', $isPrivate);
     $this->assignRef('allowComment', $allowComment);
     $this->assignRef('subscription', $allowSubscribe);
     $this->assignRef('frontpage', $showFrontpage);
     $this->assignRef('trackbacks', $trackbacks);
     $this->assignRef('author', $author);
     $this->assignRef('nestedCategories', $nestedCategories);
     $this->assignRef('teamBlogJoined', $teamBlogJoined);
     $this->assignRef('isSiteWide', $isSiteWide);
     $this->assignRef('draft', $draft);
     $this->assignRef('config', $config);
     $this->assignRef('pending_approval', $pending_approval);
     $this->assignRef('external', $external);
     $this->assignRef('extGroupId', $extGroupId);
     $this->assignRef('externalEventId', $externalEventId);
     $this->assignRef('extGroupName', $extGroupName);
     $this->assignRef('blog_contribute_source', $blog_contribute_source);
     $this->assignRef('categoryselecttype', $categoryselecttype);
     $this->assignRef('send_notification_emails', $sendEmails);
     parent::display($tpl);
 }
예제 #27
0
파일: xmlrpc.php 프로젝트: Tommar/vino2
 public static function addTrackback($trackback, $blogObj, $my)
 {
     // JTable::addIncludePath( JPATH_ROOT . DIRECTORY_SEPARATOR . 'administrator' . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_easyblog' . DIRECTORY_SEPARATOR . 'tables' );
     // JModel::addIncludePath( JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_easyblog' . DIRECTORY_SEPARATOR . 'models' );
     require_once JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_easyblog' . DIRECTORY_SEPARATOR . 'classes' . DIRECTORY_SEPARATOR . 'trackback.php';
     $author = EasyBlogHelper::getTable('Profile', 'Table');
     $author->setUser($my);
     if (!empty($trackback) && is_string($trackback)) {
         $trackbacks = explode(' ', $trackback);
         for ($x = 0; $x < count($trackbacks); $x++) {
             $tbl = EasyBlogHelper::getTable('TrackbackSent', 'Table');
             // check if the URL has been added to our record
             $exists = $tbl->load($trackbacks[$x], true, $blogObj->id);
             // if not exists, we need to store them
             if (!$exists) {
                 $tbl = EasyBlogHelper::getTable('TrackbackSent', 'Table');
                 $tbl->post_id = $blogObj->id;
                 $tbl->url = $trackbacks[$x];
                 $tbl->sent = 0;
                 $tbl->store();
             }
         }
     }
     // only process this part when publish blog
     if ($blogObj->published == '1') {
         // now load trackback model
         jimport('joomla.application.component.model');
         $trackbackModel = EasyBlogHelper::getModel('TrackbackSent');
         // get lists of trackback URLs based on blog ID
         $tbacks = $trackbackModel->getSentTrackbacks($blogObj->id, true);
         if (count($tbacks) > 0) {
             // loop each URL, ping if necessary
             foreach ($tbacks as $tback) {
                 $tb = new EasyBlogTrackBack($author->getName(), $author->getName(), 'UTF-8');
                 $text = empty($blogObj->intro) ? $blogObj->content : $blogObj->intro;
                 if (@$tb->ping($tback->url, EasyBlogRouter::getEntryRoute($blogObj->id), $blogObj->title, $text)) {
                     $tbl = EasyBlogHelper::getTable('TrackbackSent', 'Table');
                     $tbl->load($tback->id);
                     $new_trackbacks = array();
                     $new_trackbacks['url'] = $tback->url;
                     $new_trackbacks['post_id'] = $tback->post_id;
                     $new_trackbacks['sent'] = 1;
                     $tbl->bind($new_trackbacks);
                     $tbl->store();
                 }
             }
             //enf foreach
         }
         //end if
     }
 }
예제 #28
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');
 }
예제 #29
0
jimport('joomla.filesystem.file');
$path = JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_easyblog' . DIRECTORY_SEPARATOR . 'constants.php';
if (!JFile::exists($path)) {
    return;
}
// Include constants
require_once $path;
require_once EBLOG_HELPERS . DIRECTORY_SEPARATOR . 'helper.php';
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'helper.php';
EasyBlogHelper::loadHeaders();
JTable::addIncludePath(EBLOG_TABLES);
$document = JFactory::getDocument();
$document->addStyleSheet(rtrim(JURI::root(), '/') . '/components/com_easyblog/assets/css/module.css');
$config = EasyBlogHelper::getConfig();
$posttype = $params->get('showposttype', 'featured');
$model = EasyBlogHelper::getModel('Blog');
if ($posttype == 'latest') {
    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);
    }
} else {
    $category = explode(',', $params->get('catid'));
    if ($params->get('catid') == '0') {
        $category = '';
    }
    $entries = $model->getFeaturedBlog($category);
}
// If there's nothing to show at all, don't even display a box.
예제 #30
0
 public function post()
 {
     $app = JFactory::getApplication();
     $my = $this->plugin->getUser();
     $config = EasyBlogHelper::getConfig();
     //$acl = EasyBlogACLHelper::getRuleSet();
     $acl = EB::acl();
     $post = $app->input->post->getArray();
     if (empty($acl->rules->allow_comment) && (empty($my->id) && !$config->get('main_allowguestcomment'))) {
         $this->plugin->setResponse($this->getErrorResponse(500, JText::_('COM_EASYBLOG_NO_PERMISSION_TO_POST_COMMENT')));
     }
     $isModerated = false;
     $parentId = isset($post['parent_id']) ? $post['parent_id'] : 0;
     $commentDepth = isset($post['comment_depth']) ? $post['comment_depth'] : 0;
     $blogId = isset($post['id']) ? $post['id'] : 0;
     $subscribeBlog = isset($post['subscribe-to-blog']) ? true : false;
     if (!$blogId) {
         $this->plugin->setResponse($this->getErrorResponse(404, 'Invalid Blog'));
     }
     // @task: Cleanup posted values.
     array_walk($post, array($this, '_trim'));
     array_walk($post, array($this, '_revertValue'));
     if (!$config->get('comment_require_email') && !isset($post['esemail'])) {
         $post['esemail'] = '';
     }
     // @task: Run some validation tests on the posted values.
     if (!$this->_validateFields($post)) {
         $this->plugin->setResponse($this->getErrorResponse(500, $this->err[0]));
     }
     // @task: Akismet detection service.
     if ($config->get('comment_akismet')) {
         $data = array('author' => $post['esname'], 'email' => $post['esname'], 'website' => JURI::root(), 'body' => $post['comment'], 'permalink' => EasyBlogRouter::_('index.php?option=com_easyblog&view=entry&id=' . $post['id']));
         if (EasyBlogHelper::getHelper('Akismet')->isSpam($data)) {
             $this->plugin->setResponse($this->getErrorResponse(500, JText::_('COM_EASYBLOG_SPAM_DETECTED_IN_COMMENT')));
         }
     }
     // @task: Retrieve the comments model
     $model = EasyBlogHelper::getModel('Comment');
     // @task: Retrieve the comment's table
     $comment = EasyBlogHelper::table('Comment');
     // We need to rename the esname and esemail back to name and email.
     $post['post_id'] = $post['id'];
     $post['name'] = $post['esname'];
     $post['email'] = $post['esemail'];
     unset($post['id']);
     unset($post['esname']);
     unset($post['esemail']);
     // @task: Bind posted values into the table.
     $comment->bindPost($post);
     // @task: Process registrations
     $registerUser = isset($post['esregister']) ? true : false;
     $fullname = isset($post['name']) ? $post['name'] : '';
     $username = isset($post['esusername']) ? $post['esusername'] : '';
     $email = $post['email'];
     $message = '';
     $newUserId = 0;
     // @task: Process registrations if necessary
     if ($registerUser && $my->id <= 0) {
         $state = $this->processRegistrations($post, $username, $email, $ajax);
         if (!is_numeric($state)) {
             $this->plugin->setResponse($this->getErrorResponse(500, $state));
         }
         $newUserId = $state;
     }
     $totalComments = empty($post['totalComment']) ? 1 : $post['totalComment'];
     //$date 	= EasyBlogHelper::getDate();
     $date = EasyBlogDate::getDate();
     $comment->set('created', $date->toMySQL());
     $comment->set('modified', $date->toMySQL());
     $comment->set('published', 1);
     $comment->set('parent_id', $parentId);
     $comment->set('sent', 0);
     $comment->set('created_by', $my->id);
     // @rule: Update the user's id if they have just registered earlier.
     if ($newUserId != 0) {
         $comment->set('created_by', $newUserId);
     }
     // @rule: Update publish status if the comment requires moderation
     if ($config->get('comment_moderatecomment') == 1 || $my->id == 0 && $config->get('comment_moderateguestcomment') == 1) {
         $comment->set('published', EBLOG_COMMENT_STATUS_MODERATED);
         $isModerated = true;
     }
     $blog = EasyBlogHelper::table('Blog');
     $blog->load($blogId);
     // If moderation for author is disabled, ensure that the comment is published.
     // If the author is the owner of the blog, it should never be moderated.
     if (!$config->get('comment_moderateauthorcomment') && $blog->created_by == $my->id) {
         $comment->set('published', 1);
         $isModerated = false;
     }
     if (!$comment->store()) {
         $this->plugin->setResponse($this->getErrorResponse(500, 'There was a problem saving the comment'));
     }
     // @rule: Process subscription for blog automatically when the user submits a new comment and wants to subscribe to the blog.
     if ($subscribeBlog && $config->get('main_subscription') && $blog->subscription) {
         $isSubscribed = false;
         $userId = $my->id;
         $blogModel = EasyblogHelper::getModel('Blog');
         if ($userId == 0) {
             $sid = $blogModel->isBlogSubscribedEmail($blog->id, $email);
             if (empty($sid)) {
                 $isSubscribed = $blogModel->addBlogSubscription($blog->id, $email, '', $fullname);
             }
         } else {
             $sid = $blogModel->isBlogSubscribedUser($blog->id, $userId, $email);
             if (!empty($sid)) {
                 // @task: User found, update the email address
                 $blogModel->updateBlogSubscriptionEmail($sid, $userId, $email);
             } else {
                 $isSubscribed = $blogModel->addBlogSubscription($blog->id, $email, $userId, $fullname);
             }
         }
     }
     $row = $comment;
     $creator = EasyBlogHelper::table('Profile');
     $creator->load($my->id);
     $row->poster = $creator;
     $row->comment = nl2br($row->comment);
     $row->comment = EasyBlogComment::parseBBCode($row->comment);
     $row->depth = is_null($commentDepth) ? '0' : $commentDepth;
     $row->likesAuthor = '';
     // @rule: Process notifications
     $comment->processEmails($isModerated, $blog);
     //update the sent flag to sent
     $comment->updateSent();
     // @TODO - Move this to a map comment function
     $item = new CommentSimpleSchema();
     $item->commentid = $comment->id;
     $item->postid = $comment->post_id;
     $item->title = $comment->title;
     $item->text = EasyBlogComment::parseBBCode($comment->comment);
     $item->textplain = strip_tags(EasyBlogComment::parseBBCode($comment->comment));
     $item->created_date = $comment->created;
     $item->created_date_elapsed = EasyBlogDate::getLapsedTime($comment->created);
     $item->updated_date = $comment->modified;
     // Author
     $item->author->name = isset($comment->poster->nickname) ? $comment->poster->nickname : $comment->name;
     $item->author->photo = isset($comment->poster->avatar) ? $comment->poster->avatar : 'default_blogger.png';
     $item->author->photo = JURI::root() . 'components/com_easyblog/assets/images/' . $item->author->photo;
     $item->author->email = $comment->email;
     $item->author->website = isset($comment->poster->url) ? $comment->poster->url : $comment->url;
     $this->plugin->setResponse($item);
 }