Esempio n. 1
0
 function display($tmpl = null)
 {
     $config = EasyBlogHelper::getConfig();
     $id = JRequest::getInt('id');
     $team = EasyBlogHelper::getTable('TeamBlog');
     $team->load($id);
     if ($team->access != EBLOG_TEAMBLOG_ACCESS_EVERYONE) {
         return;
     }
     $model = $this->getModel('Blog');
     $posts = $model->getBlogsBy('teamblog', $team->id);
     $weever = EasyBlogHelper::getHelper('Weever')->getMainFeed();
     $weever->set('description', JText::sprintf('COM_EASYBLOG_FEEDS_TEAMBLOGS_DESC', $team->title));
     $weever->set('url', EasyBlogRouter::getRoutedUrl('index.php?option=com_easyblog&view=teamblog&id=' . $id . '&format=weever', false, true));
     $weever->set('thisPage', 1);
     $weever->set('lastPage', 1);
     if ($posts) {
         foreach ($posts as $post) {
             $blog = EasyBlogHelper::getTable('Blog');
             $blog->load($post->id);
             $weever->addChild($blog);
         }
     }
     $weever->toJSON(true, JRequest::getVar('callback'));
 }
Esempio n. 2
0
 function display($tmpl = null)
 {
     $config = EasyBlogHelper::getConfig();
     $id = JRequest::getInt('id');
     $my = JFactory::getUser();
     if (!$id) {
         echo JText::_('COM_EASYBLOG_ENTRY_BLOG_NOT_FOUND');
         exit;
     }
     // @task: Do not allow access to read when configured to.
     if ($my->id <= 0 && $config->get('main_login_read')) {
         echo JText::_('You are not allowed to read this');
         exit;
     }
     // @task: Do not allow users to read password protected entries
     if ($config->get('main_password_protect', true) && !empty($blog->blogpassword)) {
         echo JText::_('Password protected entries are not allowed yet.');
         exit;
     }
     $blog = EasyBlogHelper::getTable('Blog');
     $blog->load($id);
     $weever = EasyBlogHelper::getHelper('Weever')->getDetailsFeed();
     $weever->map($blog);
     $weever->toJSON(true, JRequest::getVar('callback'));
 }
Esempio n. 3
0
 public function store()
 {
     $isNew = empty($this->id) ? true : false;
     $state = parent::store();
     if ($state && $isNew) {
         $blog = EasyBlogHelper::getTable('Blog');
         $blog->load($this->post_id);
         $profile = EasyBlogHelper::getTable('Profile');
         $profile->load($blog->created_by);
         $obj = new stdClass();
         $obj->blogtitle = $blog->title;
         $obj->blogauthor = $profile->getName();
         $obj->subscribername = $this->fullname;
         $obj->subscriberemail = $this->email;
         $activity = new stdClass();
         $activity->actor_id = empty($this->user_id) ? '0' : $this->user_id;
         $activity->target_id = $blog->created_by;
         $activity->context_type = 'post';
         $activity->context_id = $this->post_id;
         $activity->verb = 'subscribe';
         $activity->source_id = $this->id;
         $activity->uuid = serialize($obj);
         EasyBlogHelper::activityLog($activity);
     }
     return $state;
 }
Esempio n. 4
0
 /**
  * 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');
 }
Esempio n. 5
0
 public function store()
 {
     // @task: Load language file from the front end.
     JFactory::getLanguage()->load('com_easyblog', JPATH_ROOT);
     $this->clear($this->draft_id);
     // @rule: Send notification to the author of the post.
     $draft = EasyBlogHelper::getTable('Draft');
     $draft->load($this->draft_id);
     $author = EasyBlogHelper::getTable('Profile');
     $author->load($draft->created_by);
     $data['blogTitle'] = $draft->title;
     $data['blogAuthor'] = $author->getName();
     $data['blogAuthorAvatar'] = $author->getAvatar();
     $data['blogEditLink'] = EasyBlogRouter::getRoutedURL('index.php?option=com_easyblog&view=dashboard&layout=write&draft_id=' . $draft->id, false, true);
     $data['blogAuthorEmail'] = $author->user->email;
     $data['rejectMessage'] = $this->message;
     // If blog post is being posted from the back end and SH404 is installed, we should just use the raw urls.
     $sh404exists = EasyBlogRouter::isSh404Enabled();
     if (JFactory::getApplication()->isAdmin() && $sh404exists) {
         $data['blogEditLink'] = JURI::root() . 'index.php?option=com_easyblog&view=dashboard&layout=write&draft_id=' . $draft->id;
     }
     $emailTitle = JText::_('COM_EASYBLOG_EMAIL_TITLE_NEW_BLOG_REJECTED');
     $obj = new StdClass();
     $obj->unsubscribe = false;
     $obj->email = $author->user->email;
     $emails = array($obj);
     $notification = EasyBlogHelper::getHelper('Notification');
     $notification->send($emails, $emailTitle, 'email.blog.rejected', $data);
     return parent::store();
 }
Esempio n. 6
0
 function display($tmpl = null)
 {
     $config = EasyBlogHelper::getConfig();
     $id = JRequest::getCmd('id', '0');
     $category = EasyBlogHelper::getTable('Category', 'Table');
     $category->load($id);
     // private category shouldn't allow to access.
     $privacy = $category->checkPrivacy();
     if (!$privacy->allowed) {
         return;
     }
     $catIds = array();
     $catIds[] = $category->id;
     EasyBlogHelper::accessNestedCategoriesId($category, $catIds);
     $model = $this->getModel('Blog');
     $posts = $model->getBlogsBy('category', $catIds);
     $weever = EasyBlogHelper::getHelper('Weever')->getMainFeed();
     $weever->set('description', JText::sprintf('COM_EASYBLOG_FEEDS_CATEGORY_DESC', $this->escape($category->title)));
     $weever->set('url', EasyBlogRouter::getRoutedUrl('index.php?option=com_easyblog&view=categories&id=' . $id . '&format=weever', false, true));
     $weever->set('thisPage', 1);
     $weever->set('lastPage', 1);
     if ($posts) {
         foreach ($posts as $post) {
             $blog = EasyBlogHelper::getTable('Blog');
             $blog->load($post->id);
             $weever->addChild($blog);
         }
     }
     $weever->toJSON(true, JRequest::getVar('callback'));
 }
Esempio n. 7
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.comment', '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();
     //Load pane behavior
     jimport('joomla.html.pane');
     $commentId = JRequest::getVar('commentid', '');
     $comment = EasyBlogHelper::getTable('Comment', 'Table');
     $comment->load($commentId);
     $this->comment = $comment;
     // Set default values for new entries.
     if (empty($comment->created)) {
         $date = EasyBlogDateHelper::getDate();
         $now = EasyBlogDateHelper::toFormat($date);
         $comment->created = $now;
         $comment->published = true;
     }
     $this->assignRef('comment', $comment);
     parent::display($tpl);
 }
Esempio n. 8
0
 /**
  * Generates a random captcha image
  *
  **/
 function display($cachable = false, $urlparams = false)
 {
     // @TODO: Run some cleaning query here to clear the database.
     JTable::addIncludePath(EBLOG_TABLES);
     $id = JRequest::getInt('captcha-id', '');
     $captcha = EasyBlogHelper::getTable('Captcha', 'Table');
     // clearing the oudated keys.
     $captcha->clear();
     // load the captcha records.
     $captcha->load($id);
     if (!$captcha->id) {
         return false;
     }
     // @task: Generate a very random integer and take only 5 chars max.
     $hash = JString::substr(md5(rand(0, 9999)), 0, 5);
     $captcha->response = $hash;
     $captcha->store();
     // Captcha width and height
     $width = 100;
     $height = 20;
     $image = ImageCreate($width, $height);
     $white = ImageColorAllocate($image, 255, 255, 255);
     $black = ImageColorAllocate($image, 0, 0, 0);
     $gray = ImageColorAllocate($image, 204, 204, 204);
     ImageFill($image, 0, 0, $white);
     ImageString($image, 5, 30, 3, $hash, $black);
     ImageRectangle($image, 0, 0, $width - 1, $height - 1, $gray);
     imageline($image, 0, $height / 2, $width, $height / 2, $gray);
     imageline($image, $width / 2, 0, $width / 2, $height, $gray);
     header('Content-type: image/jpeg');
     ImageJpeg($image);
     ImageDestroy($image);
     exit;
 }
Esempio n. 9
0
 function sendOnPageLoad($max = 5)
 {
     $db = EasyBlogHelper::db();
     $config = EasyBlogHelper::getConfig();
     $sendHTML = $config->get('main_mailqueuehtmlformat', 0);
     // Delete existing mails that has already been sent.
     $query = 'DELETE FROM ' . $db->nameQuote('#__easyblog_mailq') . ' WHERE ' . $db->nameQuote('status') . '=' . $db->Quote(1) . ' AND DATEDIFF(NOW(), `created`) >= 7';
     $db->setQuery($query);
     $db->Query();
     $query = 'SELECT `id` FROM `#__easyblog_mailq` WHERE `status` = 0';
     $query .= ' ORDER BY `created` ASC';
     $query .= ' LIMIT ' . $max;
     $db->setQuery($query);
     $result = $db->loadObjectList();
     if (!empty($result)) {
         foreach ($result as $mail) {
             $mailq = EasyBlogHelper::getTable('MailQueue', 'Table');
             $mailq->load($mail->id);
             // update the status to 1 == proccessed
             $mailq->status = 1;
             if ($mailq->store()) {
                 // Send emails out.
                 if (EasyBlogHelper::getJoomlaVersion() >= '3.0') {
                     $mail = JFactory::getMailer();
                     $mail->sendMail($mailq->mailfrom, $mailq->fromname, $mailq->recipient, $mailq->subject, $mailq->body, $sendHTML);
                 } else {
                     JUtility::sendMail($mailq->mailfrom, $mailq->fromname, $mailq->recipient, $mailq->subject, $mailq->body, $sendHTML);
                 }
             }
         }
     }
 }
Esempio n. 10
0
 public function load($cid)
 {
     static $instances = array();
     if (!isset($instances[$cid])) {
         $this->_item = EasyBlogHelper::getTable('Blog', 'Table');
         if (!$this->_item->load($cid)) {
             return $this->onLoadArticleError($cid);
         }
         $blogger = EasyBlogHelper::getTable('Profile', 'Table');
         $blogger->load($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 = EasyBlogRouter::_($link);
         $this->_item->permalink = $this->prepareLink($link);
         $instances[$cid] = $this->_item;
     }
     $this->_item = $instances[$cid];
     return $this;
 }
Esempio n. 11
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);
 }
Esempio n. 12
0
 public function form($tpl = null)
 {
     JHTML::_('behavior.modal', 'a.modal');
     $feed = EasyBlogHelper::getTable('Feed', 'Table');
     JToolBarHelper::title(JText::_('COM_EASYBLOG_BLOGS_FEEDS_CREATE_NEW_TITLE'), 'feeds');
     JToolBarHelper::custom('save', 'save.png', 'save_f2.png', 'COM_EASYBLOG_SAVE', false);
     JToolbarHelper::cancel();
     $cid = JRequest::getVar('cid', '', 'REQUEST');
     if (!empty($cid)) {
         $feed->load($cid);
     }
     $post = JRequest::get('POST');
     if (!empty($post)) {
         $feed->bind($post);
     }
     $categoryName = '';
     $authorName = '';
     if (!empty($feed->item_category)) {
         $categoryName = $feed->getCategoryName();
     }
     if (!empty($feed->item_creator)) {
         $author = JFactory::getUser($feed->item_creator);
         $authorName = $author->name;
     }
     $params = EasyBlogHelper::getRegistry($feed->params);
     $this->assignRef('params', $params);
     $this->assignRef('feed', $feed);
     $this->assignRef('categoryName', $categoryName);
     $this->assignRef('authorName', $authorName);
     parent::display($tpl);
 }
Esempio n. 13
0
 public function __construct()
 {
     $my = JFactory::getUser();
     // @rule: Test if the user is already associated with Flickr
     $this->oauth = EasyBlogHelper::getTable('Oauth');
     $this->oauth->loadByUser($my->id, EBLOG_OAUTH_FLICKR);
 }
Esempio n. 14
0
 /**
  * Displays the files and folders that are in the media manager.
  */
 public function display($tpl = null)
 {
     $config = EasyBlogHelper::getConfig();
     $document = JFactory::getDocument();
     $my = JFactory::getUser();
     $app = JFactory::getApplication();
     $profile = EasyBlogHelper::getTable('Profile');
     $profile->load($my->id);
     if ($my->id <= 0) {
         echo JText::_('COM_EASYBLOG_NOT_ALLOWED');
         exit;
     }
     $user = JFactory::getUser();
     $document->setTitle(JText::_('COM_EASYBLOG_MEDIA_MANAGER'));
     // Only allow admin to impersonate anyone.
     if (EasyBlogHelper::isSiteAdmin()) {
         $user = JFactory::getUser(JRequest::getVar('blogger_id', $my->id));
     }
     $debug = $config->get('debug_javascript') || JRequest::getVar('ebjsdebug') == 1 ? 'true' : 'false';
     $theme = new CodeThemes(true);
     $theme->set('debug', $debug);
     $theme->set('session', JFactory::getSession());
     $theme->set('blogger_id', $user->id);
     // @rule: Test if the user is already associated with Flickr
     $oauth = EasyBlogHelper::getTable('Oauth');
     $associated = $oauth->loadByUser($my->id, EBLOG_OAUTH_FLICKR);
     $theme->set('flickrAssociated', $associated);
     echo $theme->fetch('media.php');
 }
Esempio n. 15
0
 function remove()
 {
     // Check for request forgeries
     JRequest::checkToken() or jexit('Invalid Token');
     // @task: Check for acl rules.
     $this->checkAccess('mail');
     $mails = JRequest::getVar('cid', '', 'POST');
     $message = '';
     $type = 'info';
     if (empty($mails)) {
         $message = JText::_('COM_EASYBLOG_NO_MAIL_ID_PROVIDED');
         $type = 'error';
     } else {
         $table = EasyBlogHelper::getTable('MailQueue', 'Table');
         foreach ($mails as $id) {
             $table->load($id);
             if (!$table->delete()) {
                 $message = JText::_('COM_EASYBLOG_SPOOLS_DELETE_ERROR');
                 $type = 'error';
                 $this->setRedirect('index.php?option=com_easyblog&view=spools', $message, $type);
                 return;
             }
         }
         $message = JText::_('COM_EASYBLOG_SPOOLS_DELETE_SUCCESS');
     }
     $this->setRedirect('index.php?option=com_easyblog&view=spools', $message);
 }
Esempio n. 16
0
 function save()
 {
     // Check for request forgeries
     JRequest::checkToken() or jexit('Invalid Token');
     // @task: Check for acl rules.
     $this->checkAccess('trackback');
     $mainframe = JFactory::getApplication();
     $message = '';
     $type = 'message';
     if (JRequest::getMethod() != 'POST') {
         $mainframe->redirect('index.php?option=com_easyblog&view=trackbacks', JText::_('COM_EASYBLOG_TRACKBACKS_INVALID_REQUEST'), 'error');
         $mainframe->close();
     }
     $post = JRequest::get('POST');
     $my = JFactory::getUser();
     $id = JRequest::getInt('id', 0);
     JTable::addIncludePath(EBLOG_TABLES);
     $trackback = EasyBlogHelper::getTable('Trackback', 'Table');
     $trackback->load($id);
     $trackback->bind($post);
     if (!$trackback->store()) {
         $mainframe->redirect('index.php?option=com_easyblog&view=trackbacks', JText::_('COM_EASYBLOG_TRACKBACKS_SAVE_ERROR'), 'error');
         $mainframe->close();
     }
     $mainframe->redirect('index.php?option=com_easyblog&view=trackbacks', JText::_('COM_EASYBLOG_TRACKBACKS_SAVE_SUCCESS'));
     $mainframe->close();
 }
Esempio n. 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.tag', '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();
     // Render modal
     JHTML::_('behavior.modal');
     $tagId = JRequest::getVar('tagid', '');
     $tag = EasyBlogHelper::getTable('Tag', 'Table');
     $tag->load($tagId);
     $tag->title = JString::trim($tag->title);
     $tag->alias = JString::trim($tag->alias);
     $this->tag = $tag;
     // Set default values for new entries.
     if (empty($tag->created)) {
         $date = EasyBlogDateHelper::getDate();
         $now = EasyBlogDateHelper::toFormat($date);
         $tag->created = $now;
         $tag->published = true;
     }
     $this->assignRef('my', $user);
     $this->assignRef('tag', $tag);
     parent::display($tpl);
 }
Esempio n. 18
0
 function display()
 {
     JTable::addIncludePath(EBLOG_TABLES);
     $document = JFactory::getDocument();
     $viewType = $document->getType();
     $config = EasyBlogHelper::getConfig();
     $id = JRequest::getInt('post_id', 0);
     if (!$config->get('main_trackbacks')) {
         echo JText::_('Trackback disabled');
         return;
     }
     if ($id == 0) {
         echo JText::_('COM_EASYBLOG_TRACKBACK_INVALID_BLOG_ENTRY_PROVIDED');
         return;
     }
     $blog = EasyBlogHelper::getTable('Blog', 'Table');
     $blog->load($id);
     header('Content-Type: text/xml');
     require_once EBLOG_CLASSES . DIRECTORY_SEPARATOR . 'trackback.php';
     $data = JRequest::get('REQUEST');
     $trackback = EasyBlogHelper::getTable('Trackback', 'Table');
     $trackback->bind($data);
     $title = JString::trim($trackback->title);
     $excerpt = JString::trim($trackback->excerpt);
     $url = JString::trim($trackback->url);
     $tb = new EasyBlogTrackback('', '', 'UTF-8');
     //@task: We must have at least the important information
     if (empty($title)) {
         echo $tb->receive(false, JText::_('COM_EASYBLOG_TRACKBACK_INVALID_TITLE_PROVIDED'));
         exit;
     }
     //@task: We must have at least the important information
     if (empty($excerpt)) {
         echo $tb->receive(false, JText::_('COM_EASYBLOG_TRACKBACK_INVALID_EXCERT_PROVIDED'));
         exit;
     }
     //@task: We must have at least the important information
     if (empty($url)) {
         echo $tb->receive(false, JText::_('COM_EASYBLOG_TRACKBACK_INVALID_URL_PROVIDED'));
         exit;
     }
     // Check for spams with Akismet
     if ($config->get('comment_akismet_trackback')) {
         $data = array('author' => $title, 'email' => '', 'website' => JURI::root(), 'body' => $excerpt, 'permalink' => $url);
         if (EasyBlogHelper::getHelper('Akismet')->isSpam($data)) {
             echo $tb->receive(false, JText::_('COM_EASYBLOG_TRACKBACK_MARKED_AS_SPAM'));
             exit;
         }
     }
     $trackback->created = EasyBlogHelper::getDate()->toMySQL();
     $trackback->published = '0';
     $trackback->ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '';
     if ($trackback->store()) {
         echo $tb->receive(true);
         exit;
     }
     echo $tb->receive(false, JText::_('COM_EASYBLOG_ERROR'));
     exit;
 }
Esempio n. 19
0
 function display($tmpl = null)
 {
     $config = EasyBlogHelper::getConfig();
     $jConfig = EasyBlogHelper::getJConfig();
     if (!$config->get('main_rss')) {
         return;
     }
     $model = $this->getModel('Featured');
     $data = $model->getFeaturedBlog();
     $document = JFactory::getDocument();
     $document->link = EasyBlogRouter::_('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)) {
         for ($i = 0; $i < count($data); $i++) {
             $row =& $data[$i];
             $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;
                 }
             }
             // $row->created       = ( $formatDate ) ? $created->toFormat( $config->get('layout_dateformat', '%A, %d %B %Y') ) : $created->toFormat();
             $row->created = $created->toMySQL();
             if ($config->get('main_rss_content') == 'introtext') {
                 $row->text = !empty($row->intro) ? $row->intro : $row->content;
                 //read more for feed
                 $row->text .= '<br /><a href=' . EasyBlogRouter::_('index.php?option=com_easyblog&view=entry&id=' . $row->id) . '>Read more</a>';
             } else {
                 $row->text = $row->intro . $row->content;
             }
             $row->text = EasyBlogHelper::getHelper('Videos')->strip($row->text);
             $row->text = EasyBlogGoogleAdsense::stripAdsenseCode($row->text);
             $category = EasyBlogHelper::getTable('Category', 'Table');
             $category->load($row->category_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 = EasyBlogRouter::_('index.php?option=com_easyblog&view=entry&id=' . $row->id);
             $item->description = $row->text;
             $item->date = $row->created;
             $item->category = $category->title;
             $item->author = $profile->getName();
             if ($jConfig->get('feed_email') == 'author') {
                 $item->authorEmail = $profile->user->email;
             } else {
                 $item->authorEmail = $jConfig->get('mailfrom');
             }
             $document->addItem($item);
         }
     }
 }
Esempio n. 20
0
 function checkIfSent($blogId)
 {
     $posts = EasyBlogHelper::getTable('TwitterPosts', 'Table');
     $posts->load($blogId);
     if (empty($posts->id)) {
         return false;
     }
     return true;
 }
Esempio n. 21
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;
 }
Esempio n. 22
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;
 }
Esempio n. 23
0
 function remove()
 {
     // Check for request forgeries
     JRequest::checkToken() or jexit('Invalid Token');
     // @task: Check for acl rules.
     $this->checkAccess('subscription');
     $subs = JRequest::getVar('cid', '', 'POST');
     $filter = JRequest::getVar('filter', '', 'POST');
     $message = '';
     $type = 'message';
     if (empty($filter)) {
         $message = JText::_('COM_EASYBLOG_ERROR_REMOVING_SUBSCRIPTION_MISSING_SUBSCRIPTION_TYPE');
         $type = 'error';
         $this->setRedirect('index.php?option=com_easyblog&view=subscriptions', $message, $type);
         return;
     }
     if (empty($subs)) {
         $message = JText::_('COM_EASYBLOG_INVALID_SUBSCRIPTION_ID');
         $type = 'error';
     } else {
         $tablename = '';
         switch ($filter) {
             case 'blog':
                 $tablename = 'Subscription';
                 break;
             case 'category':
                 $tablename = 'CategorySubscription';
                 break;
             case 'site':
                 $tablename = 'SiteSubscription';
                 break;
             case 'team':
                 $tablename = 'TeamSubscription';
                 break;
             case 'blogger':
             default:
                 $tablename = 'BloggerSubscription';
                 break;
         }
         $table = EasyBlogHelper::getTable($tablename, 'Table');
         foreach ($subs as $sub) {
             $table->load($sub);
             if (!$table->delete()) {
                 $message = JText::_('COM_EASYBLOG_ERROR_REMOVING_SUBSCRIPTION_PLEASE_TRY_AGAIN_LATER');
                 $type = 'error';
                 $this->setRedirect('index.php?option=com_easyblog&view=subscriptions', $message, $type);
                 return;
             }
         }
         $message = JText::_('COM_EASYBLOG_SUBSCRIPTION_DELETED');
     }
     $this->setRedirect('index.php?option=com_easyblog&view=subscriptions', $message, $type);
 }
Esempio n. 24
0
 function display($tmpl = null)
 {
     $my = JFactory::getUser();
     if ($my->id < 1) {
         EasyBlogHelper::showLogin();
         return;
     }
     JPluginHelper::importPlugin('easyblog');
     $dispatcher = JDispatcher::getInstance();
     $mainframe = JFactory::getApplication();
     $document = JFactory::getDocument();
     $acl = EasyBlogACLHelper::getRuleSet();
     $config = EasyBlogHelper::getConfig();
     $sort = JRequest::getCmd('sort', $config->get('layout_postorder'));
     $blogger = EasyBlogHelper::getTable('Profile', 'Table');
     $blogger->load($my->id);
     // set meta tags for blogger
     EasyBlogHelper::setMeta($my->id, META_ID_BLOGGERS);
     if (!EasyBlogRouter::isCurrentActiveMenu('myblog', $my->id)) {
         $this->setPathway(JText::_('COM_EASYBLOG_BLOGGERS_BREADCRUMB'), EasyBlogRouter::_('index.php?option=com_easyblog&view=blogger'));
         $this->setPathway($blogger->getName());
     }
     $model = $this->getModel('Blog');
     $data = $model->getBlogsBy('blogger', $blogger->id, $sort);
     $pagination = $model->getPagination();
     $pageNumber = $pagination->get('pages.current');
     $pageText = $pageNumber == 1 ? '' : ' - ' . JText::sprintf('COM_EASYBLOG_PAGE_NUMBER', $pageNumber);
     $document->setTitle($blogger->getName() . $pageText . EasyBlogHelper::getPageTitle(JText::_('COM_EASYBLOG_MY_BLOG_PAGE_TITLE')));
     $data = EasyBlogHelper::formatBlog($data, false, true, true, true);
     if ($config->get('layout_showcomment', false)) {
         for ($i = 0; $i < count($data); $i++) {
             $row =& $data[$i];
             $maxComment = $config->get('layout_showcommentcount', 3);
             $comments = EasyBlogHelper::getHelper('Comment')->getBlogComment($row->id, $maxComment, 'desc');
             $comments = EasyBlogHelper::formatBlogCommentsLite($comments);
             $row->comments = $comments;
         }
     }
     $rssURL = EasyBlogRouter::_('index.php?option=com_easyblog&view=blogger&task=rss');
     //twitter follow me link
     $twitterFollowMelink = EasyBlogSocialShareHelper::getLink('twitter', $blogger->id);
     $theme = new CodeThemes();
     $theme->set('rssURL', $rssURL);
     $theme->set('blogger', $blogger);
     $theme->set('sort', $sort);
     $theme->set('blogs', $data);
     $theme->set('currentURL', 'index.php?option=com_easyblog&view=latest');
     $theme->set('pagination', $pagination->getPagesLinks());
     $theme->set('twitterFollowMelink', $twitterFollowMelink);
     $theme->set('my', $my);
     $theme->set('acl', $acl);
     echo $theme->fetch('blog.blogger.php');
 }
Esempio n. 25
0
 public function getReloadScript($ajax, $post)
 {
     JTable::addIncludePath(EBLOG_TABLES);
     if (isset($post['captcha-id'])) {
         $ref = EasyBlogHelper::getTable('Captcha', 'Table');
         $state = $ref->load($post['captcha-id']);
         if ($state) {
             $ref->delete();
         }
     }
     return 'eblog.captcha.reload();';
 }
Esempio n. 26
0
 public function preview($blogId)
 {
     $ajax = new Ejax();
     $mailq = EasyBlogHelper::getTable('Mailqueue');
     $mailq->load($blogId);
     $url = JURI::root() . 'administrator/index.php?option=com_easyblog&c=spools&task=preview&id=' . $mailq->id . '&' . EasyBlogHelper::getToken() . '=1';
     $options = new stdClass();
     $options->title = JText::_('COM_EASYBLOG_EMAIL_PREVIEW');
     $options->content = '<iframe src="' . $url . '" width="100%" height="500"></iframe>';
     $options->width = '750';
     $ajax->dialog($options);
     $ajax->send();
 }
Esempio n. 27
0
 public function resetHits()
 {
     $id = JRequest::getInt('id');
     if (!$id) {
         exit;
     }
     $ajax = EasyBlogHelper::getHelper('Ajax');
     $blog = EasyBlogHelper::getTable('Blog');
     $blog->load($id);
     $blog->hits = 0;
     $blog->store();
     $ajax->success(true);
 }
Esempio n. 28
0
 public function getReportLink($objId, $objType)
 {
     // @TODO: Configurable item links.
     switch ($objType) {
         case EBLOG_REPORTING_POST:
         default:
             $blog = EasyBlogHelper::getTable('Blog');
             $blog->load($objId);
             $url = JURI::root() . 'index.php?option=com_easyblog&view=entry&id=' . $objId;
             return '<a href="' . $url . '" target="_blank">' . $blog->title . '</a>';
             break;
     }
 }
Esempio n. 29
0
 function saveUserAppsParams($mode = '', $userId, $appId, $referId = 0, $param = null)
 {
     $db = EasyBlogHelper::db();
     $result = true;
     if (!empty($mode)) {
         $command = array();
         $todayDate = new JDate();
         if ($mode == 'insert') {
             $inserted = false;
             $uApps = EasyBlogHelper::getTable('UserApps', 'Table');
             $uApps->app_id = $appId;
             $uApps->user_id = $userId;
             $uApps->created = $todayDate->toMySql();
             $uApps->modified = $todayDate->toMySql();
             $uApps->published = true;
             if ($uApps->store()) {
                 $inserted = true;
             }
             if ($inserted) {
                 $tmpId = $uApps->id;
                 foreach ($param as $key => $val) {
                     $query = 'INSERT INTO ' . EasyBlogHelper::getHelper('SQL')->nameQuote('#__easyblog_params') . ' ' . ' ( ' . EasyBlogHelper::getHelper('SQL')->nameQuote('refer_id') . ', ' . EasyBlogHelper::getHelper('SQL')->nameQuote('param_name') . ', ' . EasyBlogHelper::getHelper('SQL')->nameQuote('param_value') . ', ' . EasyBlogHelper::getHelper('SQL')->nameQuote('param_value_type') . ', ' . EasyBlogHelper::getHelper('SQL')->nameQuote('param_type') . ', ' . EasyBlogHelper::getHelper('SQL')->nameQuote('created') . ', ' . EasyBlogHelper::getHelper('SQL')->nameQuote('modified') . ', ' . EasyBlogHelper::getHelper('SQL')->nameQuote('published') . ', ' . EasyBlogHelper::getHelper('SQL')->nameQuote('ordering') . ' ' . ' ) ' . 'VALUES ' . ' ( ' . $db->quote($tmpId) . ', ' . $db->quote($key) . ', ' . $db->quote($val) . ', ' . $db->quote('string') . ', ' . $db->quote('userapp') . ', ' . $db->quote($todayDate->toMySql()) . ', ' . $db->quote($todayDate->toMySql()) . ', ' . $db->quote('1') . ', ' . $db->quote('1') . ' ' . ' ); ';
                     $command[] = $query;
                 }
             }
         } else {
             foreach ($param as $key => $val) {
                 $query = 'UPDATE ' . EasyBlogHelper::getHelper('SQL')->nameQuote('#__easyblog_params') . ' ' . 'SET ' . EasyBlogHelper::getHelper('SQL')->nameQuote('param_value') . ' = ' . $db->quote($val) . ', ' . EasyBlogHelper::getHelper('SQL')->nameQuote('modified') . ' = ' . $db->Quote($todayDate->toMySql()) . ' ' . 'WHERE ' . EasyBlogHelper::getHelper('SQL')->nameQuote('refer_id') . ' = ' . $db->quote($referId) . ' AND ' . EasyBlogHelper::getHelper('SQL')->nameQuote('param_name') . ' = ' . $db->quote($key) . ' AND ' . EasyBlogHelper::getHelper('SQL')->nameQuote('param_type') . ' = ' . $db->quote('userapp');
                 $command[] = $query;
             }
         }
         // now we execute all the query
         if (empty($command)) {
             $result = false;
         }
         foreach ($command as $cmdQuery) {
             $db->setQuery($cmdQuery);
             if (!$db->Query()) {
                 $result = false;
             }
             if ($db->getErrorNum()) {
                 JError::raiseError(500, $db->stderr());
             }
         }
         //process ended here.
     } else {
         $result = false;
     }
     return $result;
 }
Esempio n. 30
0
 public function setRatings()
 {
     $input = JFactory::getApplication()->input;
     $user_id = $input->get('uid', 0, 'INT');
     $blog_id = $input->get('blogid', 0, 'INT');
     $values = $input->get('values', 0, 'INT');
     $model = EasyBlogHelper::getTable('Ratings');
     $model->uid = $blog_id;
     $model->created_by = $user_id;
     $model->value = $values;
     $model->type = 'entry';
     $model->fill($user_id, $blog_id, 'entry');
     $ratingValue = $model->store();
     return $ratingValue;
 }