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'); }
public function upload() { $app = JFactory::getApplication(); $my = JFactory::getUser(); $cfg = EasyBlogHelper::getConfig(); $acl = EasyBlogACLHelper::getRuleSet(); // @rule: Only allowed users are allowed to upload images. if ($my->id == 0 || empty($acl->rules->upload_image)) { $sessionid = JRequest::getVar('sessionid'); if ($sessionid) { $session = JTable::getInstance('Session'); $session->load($sessionid); if (!$session->userid) { $this->output($this->getMessageObj(EBLOG_MEDIA_SECURITY_ERROR, JText::_('COM_EASYBLOG_NOT_ALLOWED'))); } $my = JFactory::getUser($session->userid); } else { $this->output($this->getMessageObj(EBLOG_MEDIA_SECURITY_ERROR, JText::_('COM_EASYBLOG_NOT_ALLOWED'))); } } // Let's get the path for the current request. $file = JRequest::getVar('file', '', 'FILES', 'array'); $place = JRequest::getVar('place'); // The user might be from a subfolder? $source = urldecode(JRequest::getVar('path', '/')); // @task: Let's find the exact path first as there could be 3 possibilities here. // 1. Shared folder // 2. User folder $absolutePath = EasyBlogMediaManager::getAbsolutePath($source, $place); $absoluteURI = EasyBlogMediaManager::getAbsoluteURI($source, $place); // @TODO: Test if user is allowed to upload this image $message = $this->getMessageObj(); $allowed = EasyImageHelper::canUploadFile($file, $message); if ($allowed !== true) { return $this->output($message); } $media = new EasyBlogMediaManager(); $result = $media->upload($absolutePath, $absoluteURI, $file, $source, $place); // This should be an error if the $result is not an MMIM object. if (!is_object($result)) { $message = $this->getMessageObj('404', $result); } else { $message = $this->getMessageObj(EBLOG_MEDIA_UPLOAD_SUCCESS, JText::_('COM_EASYBLOG_IMAGE_MANAGER_UPLOAD_SUCCESS'), $result); } return $this->output($message); }
function import() { $my = JFactory::getUser(); $ajax = new Ejax(); $acl = EasyBlogACLHelper::getRuleSet(); $config = EasyBlogHelper::getConfig(); ob_start(); ?> <form name="import" id="import-settings" method="post" enctype="multipart/form-data"> <div class="mtm"> <label for="file"><?php echo JText::_('Exported File'); ?> </label> <input type="file" name="file" /> </div> <div class="dialog-actions"> <?php echo JHTML::_('form.token'); ?> <input type="hidden" name="option" value="com_easyblog" /> <input type="hidden" name="c" value="settings" /> <input type="hidden" name="task" value="import" /> <input type="button" value="<?php echo JText::_('COM_EASYBLOG_CANCEL_BUTTON'); ?> " class="button" id="edialog-cancel" name="edialog-cancel" onclick="ejax.closedlg();" /> <input type="submit" value="<?php echo JText::_('COM_EASYBLOG_IMPORT_BUTTON'); ?> " class="button" /> </div> </form> <?php $contents = ob_get_contents(); ob_end_clean(); $options = new stdClass(); $options->title = JText::_('COM_EASYBLOG_PENDING_DIALOG_CONFIRM_REJECT_TITLE'); $options->content = $contents; $ajax->dialog($options); return $ajax->send(); }
function confirmRejectBlog($draftId) { $my = JFactory::getUser(); $ajax = new Ejax(); $acl = EasyBlogACLHelper::getRuleSet(); $config = EasyBlogHelper::getConfig(); $ids = $draftId; if (!is_array($ids)) { $ids = array($ids); } JTable::addIncludePath(EBLOG_TABLES); foreach ($ids as $id) { $blog = EasyBlogHelper::getTable('Draft', 'Table'); $blog->load($id); // @rule: Check if the blog is really under pending if ($blog->pending_approval != 1) { $options = new stdClass(); $options->content = JText::_('COM_EASYBLOG_NOT_ALLOWED'); $ajax->dialog($options); return $ajax->send(); } } $content = ''; $content .= '<p>' . JText::_('COM_EASYBLOG_PENDING_REJECT_PENDING_ENTRIES_MESSAGE') . '</p>'; $content .= '<form name="reject-post" id="reject-post" action="' . JRoute::_('index.php?option=com_easyblog&c=pending&task=reject') . '" method="post">'; $content .= '<div class="mtm">'; $content .= ' <label for="message">' . JText::_('COM_EASYBLOG_PENDING_SPECIFY_REASON') . '</label>'; $content .= ' <textarea class="full" id="message" name="message"></textarea>'; $content .= '</div>'; $content .= '<div class="dialog-actions">'; $content .= JHTML::_('form.token'); foreach ($ids as $id) { $content .= ' <input type="hidden" name="draft_id[]" value="' . $id . '" />'; } $content .= ' <input type="button" value="' . JText::_('COM_EASYBLOG_PENDING_CANCEL_BUTTON') . '" class="button" id="edialog-cancel" name="edialog-cancel" onclick="ejax.closedlg();" />'; $content .= ' <input type="submit" value="' . JText::_('COM_EASYBLOG_PENDING_PROCEED_BUTTON') . '" class="button" />'; $content .= '</div>'; $options = new stdClass(); $options->title = JText::_('COM_EASYBLOG_PENDING_DIALOG_CONFIRM_REJECT_TITLE'); $options->content = $content; $ajax->dialog($options); return $ajax->send(); }
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.category', '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(); $config = EasyBlogHelper::getConfig(); $acl = EasyBlogACLHelper::getRuleSet(); //Load pane behavior jimport('joomla.html.pane'); $catId = JRequest::getVar('catid', ''); $cat = EasyBlogHelper::getTable('Category', 'Table'); $cat->load($catId); $this->cat = $cat; // Set default values for new entries. if (empty($cat->created)) { $date = EasyBlogDateHelper::getDate(); $now = EasyBlogDateHelper::toFormat($date); $cat->created = $now; $cat->published = true; } $catRuleItems = EasyBlogHelper::getTable('CategoryAclItem', 'Table'); $categoryRules = $catRuleItems->getAllRuleItems(); $assignedACL = $cat->getAssignedACL(); $parentList = EasyBlogHelper::populateCategories('', '', 'select', 'parent_id', $cat->parent_id, false, false, false, array($cat->id)); $editor = JFactory::getEditor($config->get('layout_editor')); $this->assignRef('editor', $editor); $this->assignRef('cat', $cat); $this->assignRef('config', $config); $this->assignRef('acl', $acl); $this->assignRef('parentList', $parentList); $this->assignRef('categoryRules', $categoryRules); $this->assignRef('assignedACL', $assignedACL); parent::display($tpl); }
function display($tmpl = null) { JPluginHelper::importPlugin('easyblog'); $dispatcher = JDispatcher::getInstance(); $mainframe = JFactory::getApplication(); $document = JFactory::getDocument(); $config = EasyBlogHelper::getConfig(); $acl = EasyBlogACLHelper::getRuleSet(); if (!EasyBlogRouter::isCurrentActiveMenu('featured')) { $this->setPathway(JText::_('COM_EASYBLOG_FEATURED_BREADCRUMB')); } // set meta tags for featured view EasyBlogHelper::setMeta(META_ID_FEATURED, META_TYPE_VIEW); EasyBlogHelper::getHelper('Feeds')->addHeaders('index.php?option=com_easyblog&view=featured'); $model = $this->getModel('Featured'); $data = $model->getFeaturedBlog(); $pagination = $model->getPagination(); $params = $mainframe->getParams('com_easyblog'); $data = EasyBlogHelper::formatBlog($data); $blogModel = $this->getModel('Blog'); $pageNumber = $pagination->get('pages.current'); $pageText = $pageNumber == 1 ? '' : ' - ' . JText::sprintf('COM_EASYBLOG_PAGE_NUMBER', $pageNumber); $document->setTitle(EasyBlogHelper::getPageTitle(JText::_('COM_EASYBLOG_FEATURED_PAGE_TITLE') . $pageText)); 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; } } $theme = new CodeThemes(); $theme->set('data', $data); $theme->set('pagination', $pagination->getPagesLinks()); $theme->set('currentURL', 'index.php?option=com_easyblog&view=featured'); $theme->set('siteadmin', EasyBlogHelper::isSiteAdmin()); $theme->set('config', $config); $theme->set('acl', $acl); echo $theme->fetch('blog.featured.php'); }
function updateTeamSubscriptionEmail($sid, $userId, $email) { $config = EasyBlogHelper::getConfig(); $acl = EasyBlogACLHelper::getRuleSet(); $my = JFactory::getUser(); $subscriber = EasyBlogHelper::getTable('TeamSubscription', 'Table'); $subscriber->load($sid); $teamTbl = EasyBlogHelper::getTable('Teamblog', 'Table'); $teamTbl->load($subscriber->team_id); $gid = EasyBlogHelper::getUserGids($userId); $isMember = $teamTbl->isMember($userId, $gid); if ($teamTbl->allowSubscription($teamTbl->access, $userId, $isMember, $acl->rules->allow_subscription)) { $subscriber->user_id = $userId; $subscriber->email = $email; $subscriber->store(); } }
public function processMailbox() { /* * Check enabled */ $config = EasyBlogHelper::getConfig(); $debug = JRequest::getBool('debug', false); if (!$config->get('main_remotepublishing_mailbox') && !$config->get('main_comment_email')) { return; } /* * Check Prerequisites setting */ $userid = 0; if ($config->get('main_remotepublishing_mailbox_userid') == 0 && !$config->get('main_remotepublishing_mailbox_syncuser')) { echo 'Mailbox: Unspecified default user id.' . "<br />\n"; return false; } /* * Check time interval */ $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 = EasyBlogHelper::getRegistry($configTable->params); $parameters->set('main_remotepublishing_mailbox_next_run', $newnextrun); $configTable->params = $parameters->toString('ini'); $configTable->store(); /* * Connect to mailbox */ require_once JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_easyblog' . DIRECTORY_SEPARATOR . 'classes' . DIRECTORY_SEPARATOR . 'mailbox.php'; $mailbox = new EasyblogMailbox(); if (!$mailbox->connect()) { $mailbox->disconnect(); echo 'Mailbox: Could not connect to mailbox.'; return false; } /* * Get data from mailbox */ $total_mails = $mailbox->getMessageCount(); if ($total_mails < 1) { // No mails in mailbox $mailbox->disconnect(); echo 'Mailbox: No emails found.'; return false; } // Let's get the correct mails $prefix = $config->get('main_remotepublishing_mailbox_prefix'); $search_criteria = 'UNSEEN'; if (!empty($prefix)) { $search_criteria .= ' SUBJECT "' . $prefix . '"'; } $sequence_list = $mailbox->searchMessages($search_criteria); if ($sequence_list === false) { // Email with matching subject not found $mailbox->disconnect(); echo 'Mailbox: No matching mails found. ' . $search_criteria; echo $debug ? ' criteria: ' . $search_criteria . ' ' : ''; return false; } /* * Found the mails according to prefix, * Let's process each of them */ $total = 0; $enable_attachment = $config->get('main_remotepublishing_mailbox_image_attachment'); $format = $config->get('main_remotepublishing_mailbox_format'); $limit = $config->get('main_remotepublishing_mailbox_fetch_limit'); // there's not limit function for imap, so we work around with the array // get the oldest message first sort($sequence_list); $sequence_list = array_slice($sequence_list, 0, $limit); foreach ($sequence_list as $sequence) { // first, extract from the header $msg_info = $mailbox->getMessageInfo($sequence); if ($msg_info === false) { echo 'Mailbox: Could not get message header.'; echo $debug ? ' sequence:' . $sequence . ' ' : ''; continue; } $uid = $msg_info->message_id; $date = $msg_info->MailDate; $udate = $msg_info->udate; $size = $msg_info->Size; $subject = $msg_info->subject; $from = ''; if (isset($msg_info->from)) { $senderInfo = $msg_info->from[0]; if (!empty($senderInfo->mailbox) && !empty($senderInfo->host)) { $from = $senderInfo->mailbox . '@' . $senderInfo->host; } } if (empty($from)) { $from = $msg_info->fromemail; } // @rule: Try to map the sender's email to a user email on the site. if ($config->get('main_remotepublishing_mailbox_syncuser')) { $db = EasyBlogHelper::db(); $query = 'SELECT ' . $db->nameQuote('id') . ' FROM ' . $db->nameQuote('#__users') . ' ' . 'WHERE ' . $db->nameQuote('email') . '=' . $db->Quote($from); $db->setQuery($query); $userid = $db->loadResult(); // Check if they have permissions if ($userid) { $acl = EasyBlogACLHelper::getRuleSet($userid); if (!$acl->rules->add_entry) { continue; } } } else { // sync user email is not require. use the default selected user. $userid = $config->get('main_remotepublishing_mailbox_userid'); } if ($userid == 0) { echo 'Mailbox: Unable to detect the user based on the email ' . $from . "<br />\n"; echo $debug ? ' sequence:' . $sequence . ' ' : ''; continue; } $date = EasyBlogHelper::getDate($date); $date = $date->toMySQL(); $subject = str_ireplace($prefix, '', $subject); $filter = JFilterInput::getInstance(); $subject = $filter->clean($subject, 'string'); // @task: If subject is empty, we need to append this with a temporary string. Otherwise user can't edit it from the back end. if (empty($subject)) { $subject = JText::_('COM_EASYBLOG_MICROBLOG_EMPTY_SUBJECT'); } // filter email according to the whitelist $filter = JFilterInput::getInstance(); $whitelist = $config->get('main_remotepublishing_mailbox_from_whitelist'); $whitelist = $filter->clean($whitelist, 'string'); $whitelist = trim($whitelist); if (!empty($whitelist)) { // Ok. I bluffed we only accept comma seperated values. *wink* $pattern = '([\\w\\.\\-]+\\@(?:[a-z0-9\\.\\-]+\\.)+(?:[a-z0-9\\-]{2,4}))'; preg_match_all($pattern, $whitelist, $matches); $emails = $matches[0]; if (!in_array($from, $emails)) { echo 'Mailbox: Message sender is block: #' . $sequence . ' ' . $subject; continue; } } // this is the magic $message = new EasyblogMailboxMessage($mailbox->stream, $sequence); $message->getMessage(); $html = $message->getHTML(); $plain = $message->getPlain(); $plain = nl2br($plain); $body = $format == 'html' ? $html : $plain; $body = $body ? $body : $plain; // If plain text is empty, just fall back to html if (empty($plain)) { $body = nl2br(strip_tags($html)); } $safeHtmlFilter = JFilterInput::getInstance(null, null, 1, 1); // JFilterInput doesn't strip css tags $body = preg_replace("'<style[^>]*>.*?</style>'si", '', $body); $body = $safeHtmlFilter->clean($body, 'html'); $body = trim($body); $attachments = array(); if ($enable_attachment) { $attachments = $message->getAttachment(); // process attached images if (!empty($attachments)) { $config = EasyBlogHelper::getConfig(); $main_image_path = $config->get('main_image_path'); $main_image_path = rtrim($main_image_path, '/'); $rel_upload_path = $main_image_path . '/' . $userid; $userUploadPath = JPATH_ROOT . DIRECTORY_SEPARATOR . $main_image_path . DIRECTORY_SEPARATOR . $userid; $userUploadPath = JPath::clean($userUploadPath); $dir = $userUploadPath . DIRECTORY_SEPARATOR; $tmp_dir = JPATH_ROOT . DIRECTORY_SEPARATOR . 'tmp' . DIRECTORY_SEPARATOR; $uri = JURI::base() . $main_image_path . '/' . $userid . '/'; if (!JFolder::exists($dir)) { JFolder::create($dir); } foreach ($attachments as $attachment) { // clean up file name if (strpos($attachment['name'], '/') !== FALSE) { $attachment['name'] = substr($attachment['name'], strrpos($attachment['name'], '/') + 1); } elseif (strpos($attachment['name'], '\\' !== FALSE)) { $attachment['name'] = substr($attachment['name'], strrpos($attachment['name'], '\\') + 1); } // @task: check if the attachment has file extension. ( assuming is images ) $imgExts = array('jpg', 'png', 'gif', 'JPG', 'PNG', 'GIF', 'jpeg', 'JPEG'); $imageSegment = explode('.', $attachment['name']); if (!in_array($imageSegment[count($imageSegment) - 1], $imgExts)) { $attachment['name'] = $attachment['name'] . '.jpg'; } // @task: Store the file into a temporary location first. $attachment['tmp_name'] = $tmp_dir . $attachment['name']; JFile::write($attachment['tmp_name'], $attachment['data']); require_once EBLOG_CLASSES . DIRECTORY_SEPARATOR . 'mediamanager.php'; // @task: Ensure that images goes through the same resizing format when uploading via media manager. $media = new EasyBlogMediaManager(); $result = $media->upload($dir, $uri, $attachment, '/', 'user'); // get the image file name and path if (is_object($result) && property_exists($result, 'title')) { $atmTitle = $result->title; $atmURL = $result->url; } else { $atmTitle = $attachment['name']; $atmURL = $uri . $attachment['name']; } // @task: Once the attachment is processed, delete the temporary file. JFile::delete($attachment['tmp_name']); // now we need to replace the img tag in the email which the source is an attachment id :( $attachId = $attachment['id']; if (!empty($attachId)) { $attachId = str_replace('<', '', $attachId); $attachId = str_replace('>', '', $attachId); $imgPattern = array('/<div><img[^>]*src="[A-Za-z0-9:^>]*' . $attachId . '"[^>]*\\/><\\/div>/si', '/<img[^>]*src="[A-Za-z0-9:^>]*' . $attachId . '"[^>]*\\/>/si'); $imgReplace = array('', ''); $body = preg_replace($imgPattern, $imgReplace, $body); } // insert image into blog post $body .= '<p><a class="easyblog-thumb-preview" href="' . $atmURL . '" title="' . $atmTitle . '"><img width="' . $config->get('main_thumbnail_width') . '" title="' . $atmTitle . '." alt="" src="' . $atmURL . '" /></a></p>'; } } } if ($format == 'plain') { $body = nl2br($body); } // tidy up the content so that the content do not contain incomplete html tag. $body = EasyBlogHelper::getHelper('string')->tidyHTMLContent($body); $type = $config->get('main_remotepublishing_mailbox_type'); // insert $body, $subject, $from, $date $blog = EasyBlogHelper::getTable('Blog', 'Table'); // @task: Store the blog post $blog->set('title', $subject); $blog->set('permalink', EasyBlogHelper::getPermalink($blog->title)); $blog->set('source', 'email'); $blog->set('created_by', $userid); $blog->set('created', $date); $blog->set('modified', $date); $blog->set('publish_up', $date); $blog->set($type, $body); $blog->set('category_id', $config->get('main_remotepublishing_mailbox_categoryid')); $blog->set('published', $config->get('main_remotepublishing_mailbox_publish')); $blog->set('frontpage', $config->get('main_remotepublishing_mailbox_frontpage')); $blog->set('send_notification_emails', $config->get('main_remotepublishing_mailbox_publish')); $blog->set('issitewide', true); // @task: Set the blog's privacy here. $blog->set('private', $config->get('main_remotepublishing_mailbox_privacy')); // Store the blog post if (!$blog->store()) { echo 'Mailbox: Message store failed. > ' . $subject . ' :: ' . $blog->getError(); continue; } if ($mailbox->service == 'pop3') { $mailbox->deleteMessage($sequence); } if ($mailbox->service == 'imap') { $mailbox->setMessageFlag($sequence, '\\Seen'); } // @rule: Autoposting to social network sites. if ($blog->published == POST_ID_PUBLISHED) { $blog->autopost(array(EBLOG_OAUTH_LINKEDIN, EBLOG_OAUTH_FACEBOOK, EBLOG_OAUTH_TWITTER), array(EBLOG_OAUTH_LINKEDIN, EBLOG_OAUTH_FACEBOOK, EBLOG_OAUTH_TWITTER)); $blog->notify(false); } $total++; } /* * Disconnect from mailbox */ $mailbox->disconnect(); /* * Generate report */ echo JText::sprintf('%1s blog posts fetched from mailbox: ' . $config->get('main_remotepublishing_mailbox_remotesystemname') . '.', $total); }
public function deleteComment($id) { $config = EasyBlogHelper::getConfig(); $my = JFactory::getUser(); $ajax = new Ejax(); $acl = EasyBlogACLHelper::getRuleSet(); JTable::addIncludePath(EBLOG_TABLES); $comment = EasyBlogHelper::getTable('Comment', 'Table'); $comment->load($id); if (($my->id == 0 || $my->id != $comment->created_by || !$acl->rules->delete_comment) && !EasyBlogHelper::isSiteAdmin()) { $ajax->alert(JText::_('COM_EASYBLOG_NO_PERMISSION_TO_EDIT_COMMENT'), JText::_('COM_EASYBLOG_INFO'), '450', 'auto'); return $ajax->send(); } $tpl = new CodeThemes(); $tpl->set('comment', $comment); $options = new stdClass(); $options->title = JText::_('COM_EASYBLOG_DASHBOARD_DELETE_COMMENT'); $options->content = $tpl->fetch('ajax.dialog.comments.delete.php'); $ajax->dialog($options); $ajax->send(); }
<?php /** * @package EasyBlog * @copyright Copyright (C) 2010 Stack Ideas Private Limited. All rights reserved. * @license GNU/GPL, see LICENSE.php * EasyBlog is free software. This version may have been modified pursuant * to the GNU General Public License, and as distributed it includes or * is derivative of works licensed under the GNU General Public License or * other free or open source software licenses. * See COPYRIGHT.php for copyright notices and details. */ defined('_JEXEC') or die('Restricted access'); $acl = EasyBlogACLHelper::getRuleSet(); $isBloggerMode = EasyBlogRouter::isBloggerMode(); $itemid = JRequest::getVar('Itemid', ''); $menu = JFactory::getApplication()->getMenu(); $item = $menu->getItem($itemid); $params = EasyBlogHelper::getRegistry(); if ($item) { $params->load($item->params); } if ($system->config->get('layout_responsive')) { ?> <script type="text/javascript"> EasyBlog.require() .script('layout/responsive') .done(function($){ $('#ezblog-head #ezblog-search').bind('focus', function(){ $(this).animate({ width: '170'} );
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.user', '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(); $filter_state = $mainframe->getUserStateFromRequest('com_easyblog.users.filter_state', 'filter_state', '*', 'word'); $search = $mainframe->getUserStateFromRequest('com_easyblog.users.search', 'search', '', 'string'); $search = trim(JString::strtolower($search)); $order = $mainframe->getUserStateFromRequest('com_easyblog.users.filter_order', 'filter_order', 'a.id', 'cmd'); $orderDirection = $mainframe->getUserStateFromRequest('com_easyblog.users.filter_order_Dir', 'filter_order_Dir', '', 'word'); //Get data from the model $isBrowse = JRequest::getVar('browse', '0'); $model = $this->getModel(); $users = $model->getUsers($isBrowse); $pagination = $this->get('Pagination'); if (!$isBrowse) { // Filter to show users which have the ability to write post $acl = EasyBlogACLHelper::getRuleSet(); $bloggers = array(); if (!empty($users)) { foreach ($users as $user) { $acl = EasyBlogACLHelper::getRuleSet($user->id); if (!empty($acl->rules->add_entry)) { // We call them bloggers for user with the acl permission to write entry $bloggers[] = $user; } } } // Pass back lists of bloggers back to users $users = $bloggers; } if (EasyBlogHelper::getJoomlaVersion() >= '1.6') { if (count($users) > 0) { for ($i = 0; $i < count($users); $i++) { $row = $users[$i]; $row->usergroups = $this->getGroupTitle($row->id); } } } $browse = JRequest::getInt('browse', 0); $browsefunction = JRequest::getVar('browsefunction', 'insertMember'); $browseUID = JRequest::getVar('uid', ''); $this->assign('browseUID', $browseUID); $this->assign('browse', $browse); $this->assign('browsefunction', $browsefunction); $this->assignRef('users', $users); $this->assignRef('pagination', $pagination); $this->assign('state', JHTML::_('grid.state', $filter_state)); $this->assign('search', $search); $this->assign('order', $order); $this->assign('orderDirection', $orderDirection); parent::display($tpl); }
public static function getCommentHTML($blog, $comments = array(), $pagination = '') { $config = EasyBlogHelper::getConfig(); $path = EBLOG_CLASSES . DIRECTORY_SEPARATOR . 'comments'; $registration = $config->get('comment_registeroncomment'); $commentSystems = array(); // Double check this with Joomla's registration component if ($registration) { $params = JComponentHelper::getParams('com_users'); $registration = $params->get('allowUserRegistration') == '0' ? false : $registration; } if ($config->get('comment_facebook')) { require_once $path . DIRECTORY_SEPARATOR . 'facebook.php'; $commentSystems['FACEBOOK'] = EasyBlogCommentFacebook::getHTML($blog); if (!$config->get('main_comment_multiple')) { return $commentSystems['FACEBOOK']; } } $easysocial = EasyBlogHelper::getHelper('EasySocial'); if ($config->get('comment_easysocial') && $easysocial->exists()) { $easysocial->init(); $commentSystems['EASYSOCIAL'] = $easysocial->getCommentHTML($blog); if (!$config->get('main_comment_multiple')) { return $commentSystems['EASYSOCIAL']; } } if ($config->get('comment_compojoom')) { $file = JPATH_ROOT . '/administrator/components/com_comment/plugin/com_easyblog/josc_com_easyblog.php'; if (JFile::exists($file)) { require_once $file; $commentSystems['COMPOJOOM'] = CommentEasyBlog::output($blog, array()); } $file = JPATH_ROOT . '/components/com_comment/helpers/utils.php'; if (JFile::exists($file)) { JLoader::discover('ccommentHelper', JPATH_ROOT . '/components/com_comment/helpers'); $commentSystems['COMPOJOOM'] = ccommentHelperUtils::commentInit('com_easyblog', $blog); } if (!$config->get('main_comment_multiple')) { return $commentSystems['COMPOJOOM']; } } if ($config->get('comment_intensedebate')) { require_once $path . DIRECTORY_SEPARATOR . 'intensedebate.php'; $commentSystems['INTENSEDEBATE'] = EasyBlogCommentIntenseDebate::getHTML($blog); if (!$config->get('main_comment_multiple')) { return $commentSystems['INTENSEDEBATE']; } } if ($config->get('comment_disqus')) { require_once $path . DIRECTORY_SEPARATOR . 'disqus.php'; $commentSystems['DISQUS'] = EasyBlogCommentDisqus::getHTML($blog); if (!$config->get('main_comment_multiple')) { return $commentSystems['DISQUS']; } } if ($config->get('comment_jomcomment')) { $file = JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_jomcomment' . DIRECTORY_SEPARATOR . 'jomcomment.php'; // Test if jomcomment exists. if (JFile::exists($file)) { require_once $path . DIRECTORY_SEPARATOR . 'jomcomment.php'; $commentSystems['JOMCOMMENT'] = EasyBlogCommentJomComment::getHTML($blog); if (!$config->get('main_comment_multiple')) { return $commentSystems['JOMCOMMENT']; } } } if ($config->get('comment_livefyre')) { require_once $path . DIRECTORY_SEPARATOR . 'livefyre.php'; $commentSystems['LIVEFYRE'] = EasyBlogCommentLiveFyre::getHTML($blog); if (!$config->get('main_comment_multiple')) { return $commentSystems['LIVEFYRE']; } } if ($config->get('comment_jcomments')) { $file = JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_jcomments' . DIRECTORY_SEPARATOR . 'jcomments.php'; if (JFile::exists($file)) { require_once $path . DIRECTORY_SEPARATOR . 'jcomments.php'; $commentSystems['JCOMMENTS'] = EasyBlogCommentJComments::getHTML($blog); if (!$config->get('main_comment_multiple')) { return $commentSystems['JCOMMENTS']; } } } if ($config->get('comment_rscomments')) { $file = JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_rscomments' . DIRECTORY_SEPARATOR . 'rscomments.php'; if (JFile::exists($file)) { include_once $path . DIRECTORY_SEPARATOR . 'rscomments.php'; $commentSystems['RSCOMMENTS'] = EasyBlogCommentRSComments::getHTML($blog); if (!$config->get('main_comment_multiple')) { return $commentSystems['RSCOMMENTS']; } } } if ($config->get('comment_easydiscuss')) { $enabled = JPluginHelper::isEnabled('content', 'easydiscuss'); if ($enabled) { JPluginHelper::importPlugin('content', 'easydiscuss'); $articleParams = new stdClass(); $result = JFactory::getApplication()->triggerEvent('onDisplayComments', array(&$blog, &$articleParams)); if (isset($result[0]) || isset($result[1])) { // There could be komento running on the site if (isset($result[1]) && $result[1]) { $commentSystems['EASYDISCUSS'] = $result[1]; } else { $commentSystems['EASYDISCUSS'] = $result[0]; } if (!$config->get('main_comment_multiple')) { return $commentSystems['EASYDISCUSS']; } } } } if ($config->get('comment_komento')) { $file = JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_komento' . DIRECTORY_SEPARATOR . 'bootstrap.php'; if (JFile::exists($file)) { include_once $file; $commentSystems['KOMENTO'] = Komento::commentify('com_easyblog', $blog, array('trigger' => 'onDisplayComments')); if (!$config->get('main_comment_multiple')) { return $commentSystems['KOMENTO']; } } } if (!$config->get('main_comment_multiple') || $config->get('comment_easyblog')) { //check if bbcode enabled or not. if ($config->get('comment_bbcode')) { EasyBlogCommentHelper::loadBBCode(); } // If all else fail, try to use the default comment system $theme = new CodeThemes(); // setup my own info to show in comment form area $my = JFactory::getUser(); $profile = EasyBlogHelper::getTable('Profile', 'Table'); $profile->load($my->id); $my->avatar = $profile->getAvatar(); $my->displayName = $profile->getName(); $my->url = $profile->url; $blogURL = base64_encode(EasyBlogRouter::_('index.php?option=com_easyblog&view=entry&id=' . $blog->id, false)); $loginURL = EasyBlogHelper::getLoginLink($blogURL); $enableRecaptcha = $config->get('comment_recaptcha'); $publicKey = $config->get('comment_recaptcha_public'); // check if the user has subcribed to this thread $subscriptionId = false; if ($my->id > 0) { $blogModel = EasyblogHelper::getModel('Blog'); $subscriptionId = $blogModel->isBlogSubscribedUser($blog->id, $my->id, $my->email); $subscriptionId = is_null($subscriptionId) ? false : $subscriptionId; } $theme->set('loginURL', $loginURL); $theme->set('blog', $blog); $theme->set('my', $my); $theme->set('config', $config); $theme->set('blogComments', $comments); $theme->set('pagination', $pagination); $theme->set('allowComment', true); $theme->set('canRegister', $registration); $theme->set('acl', EasyBlogACLHelper::getRuleSet()); $theme->set('subscriptionId', $subscriptionId); $commentSystems['EASYBLOGCOMMENTS'] = $theme->fetch('blog.comment.box.php'); } if (!$config->get('main_comment_multiple')) { return $commentSystems['EASYBLOGCOMMENTS']; } // If there's 1 system only, there's no point loading the tabs. if (count($commentSystems) == 1) { return $commentSystems[key($commentSystems)]; } unset($theme); // Reverse the comment systems array so that easyblog comments are always the first item. $commentSystems = array_reverse($commentSystems); $theme = new CodeThemes(); $theme->set('commentSystems', $commentSystems); return $theme->fetch('blog.comment.multiple.php'); }
/** * Display specific tag from the site. **/ function tag() { $document = JFactory::getDocument(); $config = EasyBlogHelper::getConfig(); $my = JFactory::getUser(); $acl = EasyBlogACLHelper::getRuleSet(); $id = JRequest::getVar('id', '', 'REQUEST'); JTable::addIncludePath(EBLOG_TABLES); // Add noindex for tags view by default. $document->setMetadata('robots', 'noindex,follow'); $tag = EasyBlogHelper::getTable('Tag', 'Table'); $tag->load($id); $title = EasyBlogHelper::getPageTitle($tag->title); // @task: Set the page title parent::setPageTitle($title, false, $config->get('main_pagetitle_autoappend')); // set meta tags for tags view EasyBlogHelper::setMeta(META_ID_TAGS, META_TYPE_VIEW, JText::_($tag->title) . ' - ' . EasyBlogHelper::getPageTitle($config->get('main_title'))); if (!EasyBlogRouter::isCurrentActiveMenu('tags')) { $this->setPathway(JText::_('COM_EASYBLOG_TAGS_BREADCRUMB'), EasyBlogRouter::_('index.php?option=com_easyblog&view=tags')); } $this->setPathway(JText::_($tag->title)); $blogModel = $this->getModel('Blog'); $tagModel = $this->getModel('Tags'); $rows = $blogModel->getTaggedBlogs($id); $pagination = $blogModel->getPagination(); $privateBlogCount = 0; $teamBlogCount = 0; if ($my->id == 0) { $privateBlogCount = $tagModel->getTagPrivateBlogCount($id); } if (!$config->get('main_includeteamblogpost')) { $teamBlogCount = $tagModel->getTeamBlogCount($id); } //for trigger only JPluginHelper::importPlugin('easyblog'); $dispatcher = JDispatcher::getInstance(); $mainframe = JFactory::getApplication(); $params = $mainframe->getParams('com_easyblog'); $limitstart = JRequest::getVar('limitstart', 0, '', 'int'); if (!empty($rows)) { $rows = EasyBlogHelper::formatBlog($rows, true, true, true, true); for ($i = 0; $i < count($rows); $i++) { $row =& $rows[$i]; $row->category = $blogModel->getCategoryName($row->category_id); // $row->readmore = JText::_('COM_EASYBLOG_CONTINUE_READING'); if ($config->get('layout_showcomment', false)) { $maxComment = $config->get('layout_showcommentcount', 3); $comments = EasyBlogHelper::getHelper('Comment')->getBlogComment($row->id, $maxComment, 'desc'); $comments = EasyBlogHelper::formatBlogCommentsLite($comments); $row->comments = $comments; } } } $theme = new CodeThemes(); $theme->set('tag', $tag); $theme->set('rows', $rows); $theme->set('pagination', $pagination); $theme->set('currentURL', 'index.php?option=com_easyblog&view=tags&layout=tag&id=' . $tag->id); $theme->set('privateBlogCount', $privateBlogCount); $theme->set('teamBlogCount', $teamBlogCount); echo $theme->fetch('blog.tags.php'); }
function rejectItem($id) { // @task: Check for acl rules. $this->checkAccess('blog'); $mainframe = JFactory::getApplication(); $redirect = base64_decode(JRequest::getVar('redirect', '')); $redirect = empty($redirect) ? EasyBlogRouter::_('index.php?option=com_easyblog&view=pending', false) : EasyBlogRouter::_($redirect, false); $my = JFactory::getUser(); $config = EasyBlogHelper::getConfig(); $acl = EasyBlogACLHelper::getRuleSet(); $message = JRequest::getVar('message', ''); if (empty($id)) { $mainframe->enqueueMessage(JText::_('COM_EASYBLOG_NOT_ALLOWED'), 'error'); $mainframe->redirect($redirect); $mainframe->close(); } if (!EasyBlogHelper::isSiteAdmin() && empty($acl->rules->manage_pending)) { $mainframe->enqueueMessage(JText::_('COM_EASYBLOG_NOT_ALLOWED'), 'error'); $mainframe->redirect($redirect); $mainframe->close(); } JTable::addIncludePath(EBLOG_TABLES); $draft = EasyBlogHelper::getTable('Draft', 'Table'); $draft->load($id); if ($draft->pending_approval != 1) { $mainframe->enqueueMessage(JText::_('COM_EASYBLOG_NOT_ALLOWED'), 'error'); $mainframe->redirect($redirect); $mainframe->close(); } // If the draft is rejected, revert draft status and create a note for the rejected draft. $draft->set('pending_approval', 0); $draft->store(); // Create the message $postreject = EasyBlogHelper::getTable('PostReject', 'Table'); $postreject->draft_id = $draft->id; $postreject->message = $message; $postreject->created_by = $my->id; $postreject->created = EasyBlogHelper::getDate()->toMySQL(); $postreject->store(); }
private function allowSubscribeTeam($id) { JTable::addIncludePath(EBLOG_TABLES); $team = EasyBlogHelper::getTable('Teamblog', 'Table'); $team->load($id); $acl = EasyBlogACLHelper::getRuleSet(); $my = JFactory::getUser(); $gid = EasyBlogHelper::getUserGids(); return $team->allowSubscription($team->access, $my->id, $team->isMember($my->id, $gid), $acl->rules->allow_subscription); }
/** * Must only be bind when using POST data **/ function bind($data, $post = false) { if (!$post) { return parent::bind($data); } parent::bind($data); $acl = EasyBlogACLHelper::getRuleSet(); $my = JFactory::getUser(); // Some properties needs to be overriden. $content = $this->content; //remove unclean editor code. $pattern = array('/<p><br _mce_bogus="1"><\\/p>/i', '/<p><br mce_bogus="1"><\\/p>/i', '/<br _mce_bogus="1">/i', '/<br mce_bogus="1">/i', '/<p><br><\\/p>/i'); $replace = array('', '', '', '', ''); $content = preg_replace($pattern, $replace, $content); // Search for readmore tags using Joomla's mechanism $pattern = '#<hr\\s+id=("|\')system-readmore("|\')\\s*\\/*>#i'; $pos = preg_match($pattern, $content); if ($pos == 0) { $this->intro = $content; $this->content = ''; } else { list($intro, $main) = preg_split($pattern, $content, 2); $this->intro = $intro; $this->content = $main; } $intro = $this->intro; $content = $this->content; $publish_up = ''; $publish_down = ''; $created_date = ''; $tzoffset = EasyBlogDateHelper::getOffSet(); if (!empty($this->created)) { $date = EasyBlogHelper::getDate($this->created, $tzoffset); $created_date = $date->toMySQL(); } if ($this->publish_down == '0000-00-00 00:00:00') { $publish_down = $this->publish_down; } else { if (!empty($this->publish_down)) { $date = EasyBlogHelper::getDate($this->publish_down, $tzoffset); $publish_down = $date->toMySQL(); } } if (!empty($this->publish_up)) { $date = EasyBlogHelper::getDate($this->publish_up, $tzoffset); $publish_up = $date->toMySQL(); } //default joomla date obj $date = EasyBlogHelper::getDate(); $this->created = !empty($created_date) ? $created_date : $date->toMySQL(); $this->intro = $intro; $this->content = $content; $this->modified = $date->toMySQL(); $this->publish_up = !empty($publish_up) ? $publish_up : $date->toMySQL(); $this->publish_down = empty($publish_down) ? '0000-00-00 00:00:00' : $publish_down; $this->ispending = empty($acl->rules->publish_entry) ? 1 : 0; $this->issitewide = empty($this->blog_contribute) ? 1 : 0; // Bind necessary stuffs for the next load if (isset($data['tags']) && !empty($data['tags']) && is_array($data['tags'])) { $this->set('tags', implode(',', $data['tags'])); } if (isset($data['keywords']) && !empty($data['keywords'])) { $this->set('metakey', $data['keywords']); } if (isset($data['description']) && !empty($data['description'])) { $this->set('metadesc', $data['description']); } if (isset($data['trackback']) && !empty($data['trackback'])) { $this->set('trackbacks', $data['trackback']); } if (isset($data['blogpassword']) && !empty($data['blogpassword'])) { $this->set('blogpassword', $data['blogpassword']); } // @task: Try to detect autoposting for centralized sites if (isset($data['centralized']) && !empty($data['centralized'])) { $this->set('autopost_centralized', implode(',', $data['centralized'])); } if (isset($data['socialshare']) && !empty($data['socialshare'])) { $this->set('autopost', implode(',', $data['socialshare'])); } if (isset($data['blog_contribute_source']) && $data['blog_contribute_source'] != 'easyblog') { $this->set('external_source', $data['blog_contribute_source']); $this->set('external_group_id', $data['blog_contribute']); } if (isset($data['image']) && $data['image']) { $this->set('image', $data['image']); } return true; }
/** * Method to store tags for a blog post. * * @access private * @param TableBlog $blog The blog's database row. */ public function saveTags($tags) { // If there's no tags, just skip the whole block if (!$tags) { return false; } $config = EasyBlogHelper::getConfig(); $acl = EasyBlogACLHelper::getRuleSet(); // @rule: Needed to add points for each tag creation if ($config->get('main_jomsocial_userpoint')) { $path = JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_community' . DIRECTORY_SEPARATOR . 'libraries' . DIRECTORY_SEPARATOR . 'userpoints.php'; if (JFile::exists($path)) { require_once $path; } } if (!is_array($tags)) { $tags = array($tags); } $model = EasyBlogHelper::getModel('PostTag'); foreach ($tags as $title) { // Skip this if the tag is invalid. if (empty($title)) { continue; } $tag = EasyBlogHelper::getTable('Tag'); $tag->load($title, true); if (!$tag->exists($title) && $acl->rules->create_tag) { $tag->created_by = JFactory::getUser()->id; $tag->title = $title; $tag->created = EasyBlogHelper::getDate()->toMySQL(); $tag->store(); } // Add the association for the tag. $model->add($tag->id, $blog->id, EasyBlogHelper::getDate()->toMySQL()); } return true; }
public static function getLink($type, $id) { if (empty($type) || empty($id)) { return false; } //prevent jtable is not loading incase overwritten by other component. JTable::addIncludePath(EBLOG_TABLES); $oauth = EasyBlogHelper::getTable('Oauth', 'Table'); $oauth->loadByUser($id, $type); $param = EasyBlogHelper::getRegistry(); $param->load($oauth->params); $screenName = $param->get('screen_name', ''); $acl = EasyBlogACLHelper::getRuleSet($id); $rule = 'update_' . $type; if (!$acl->rules->{$rule}) { return false; } switch ($type) { case 'twitter': $link = empty($screenName) ? '' : 'http://twitter.com/' . $screenName; break; case 'facebook': $link = ''; break; case 'linkedin': $link = ''; break; } return $link; }
function calendar($tmpl = null) { JPluginHelper::importPlugin('easyblog'); $dispatcher = JDispatcher::getInstance(); $mainframe = JFactory::getApplication(); $document = JFactory::getDocument(); $config = EasyBlogHelper::getConfig(); $my = JFactory::getUser(); $acl = EasyBlogACLHelper::getRuleSet(); //setting pathway $pathway = $mainframe->getPathway(); if (!EasyBlogRouter::isCurrentActiveMenu('archive')) { $pathway->addItem(JText::_('COM_EASYBLOG_ARCHIVE_BREADCRUMB'), ''); } EasyBlogHelper::getHelper('Feeds')->addHeaders('index.php?option=com_easyblog&view=archive'); $menuParams = $mainframe->getParams(); $defaultYear = $menuParams->get('es_archieve_year', 0); $defaultMonth = $menuParams->get('es_archieve_month', 0); $archiveYear = JRequest::getVar('archiveyear', $defaultYear, 'REQUEST'); $archiveMonth = JRequest::getVar('archivemonth', $defaultMonth, 'REQUEST'); $archiveDay = JRequest::getVar('archiveday', 0, 'REQUEST'); $itemId = JRequest::getInt('Itemid', 0); if (empty($archiveYear) || empty($archiveMonth)) { // @task: Set the page title $title = EasyBlogHelper::getPageTitle(JText::_('COM_EASYBLOG_ARCHIVE_PAGE_TITLE')); parent::setPageTitle($title, false, $config->get('main_pagetitle_autoappend')); $tpl = new CodeThemes(); $tpl->set('itemId', $itemId); echo $tpl->fetch('calendar.php'); return; } $date = EasyBlogHelper::getDate(); $sort = 'latest'; $model = $this->getModel('Archive'); $year = $model->getArchiveMinMaxYear(); $data = $model->getArchive($archiveYear, $archiveMonth, $archiveDay); $pagination = $model->getPagination(); $params = $mainframe->getParams('com_easyblog'); $limitstart = JRequest::getVar('limitstart', 0, '', 'int'); $data = EasyBlogHelper::formatBlog($data); //if day is empty if (empty($archiveDay)) { $archiveDay = '01'; $dateformat = '%B %Y'; $emptyPostMsg = JText::_('COM_EASYBLOG_ARCHIVE_NO_ENTRIES_ON_MONTH'); } else { $dateformat = '%d %B %Y'; $emptyPostMsg = JText::_('COM_EASYBLOG_ARCHIVE_NO_ENTRIES_ON_DAY'); } $archiveDay = strlen($archiveDay) < 2 ? '0' . $archiveDay : $archiveDay; $viewDate = EasyBlogHelper::getDate($archiveYear . '-' . $archiveMonth . '-' . $archiveDay); $formatedDate = $viewDate->toFormat($dateformat); $archiveTitle = JText::sprintf('COM_EASYBLOG_ARCHIVE_HEADING_TITLE', $formatedDate); // @task: Set the page title $title = EasyBlogHelper::getPageTitle(JText::sprintf('COM_EASYBLOG_ARCHIVE_HEADING_TITLE', $formatedDate)); parent::setPageTitle($title, false, $config->get('main_pagetitle_autoappend')); // set meta tags for featured view EasyBlogHelper::setMeta(META_ID_ARCHIVE, META_TYPE_VIEW, JText::_('COM_EASYBLOG_ARCHIVE_PAGE_TITLE') . ' - ' . $formatedDate); // set meta tags for featured view EasyBlogHelper::setMeta(META_ID_ARCHIVE, META_TYPE_VIEW, JText::_('COM_EASYBLOG_ARCHIVE_PAGE_TITLE') . ' - ' . $formatedDate); $tpl = new CodeThemes(); $tpl->set('data', $data); $tpl->set('pagination', $pagination->getPagesLinks()); $tpl->set('siteadmin', EasyBlogHelper::isSiteAdmin()); $tpl->set('archiveYear', $archiveYear); $tpl->set('archiveMonth', $archiveMonth); $tpl->set('archiveDay', $archiveDay); $tpl->set('config', $config); $tpl->set('my', $my); $tpl->set('acl', $acl); $tpl->set('archiveTitle', $archiveTitle); $tpl->set('emptyPostMsg', $emptyPostMsg); echo $tpl->fetch('blog.archive.php'); }
function listings() { $app = JFactory::getApplication(); $doc = JFactory::getDocument(); $config = EasyBlogHelper::getConfig(); $my = JFactory::getUser(); $acl = EasyBlogACLHelper::getRuleSet(); $sort = JRequest::getCmd('sort', $config->get('layout_postorder')); $catId = JRequest::getCmd('id', '0'); $category = EasyBlogHelper::getTable('Category', 'Table'); $category->load($catId); if ($category->id == 0) { $category->title = JText::_('COM_EASYBLOG_UNCATEGORIZED'); } // Set the meta description for the category EasyBlogHelper::setMeta($category->id, META_TYPE_CATEGORY); // Set the meta description for the category // $doc->setMetadata( 'description' , strip_tags( $category->description ) ); //setting pathway $pathway = $app->getPathway(); $privacy = $category->checkPrivacy(); $addRSS = true; if (!$privacy->allowed) { if ($my->id == 0 && !$config->get('main_allowguestsubscribe')) { $addRSS = false; } } if ($addRSS) { // Add rss feed link $doc->addHeadLink($category->getRSS(), 'alternate', 'rel', array('type' => 'application/rss+xml', 'title' => 'RSS 2.0')); $doc->addHeadLink($category->getAtom(), 'alternate', 'rel', array('type' => 'application/atom+xml', 'title' => 'Atom 1.0')); } if (!EasyBlogRouter::isCurrentActiveMenu('categories', $category->id)) { if (!EasyBlogRouter::isCurrentActiveMenu('categories')) { $this->setPathway(JText::_('COM_EASYBLOG_CATEGORIES_BREADCRUMB'), EasyBlogRouter::_('index.php?option=com_easyblog&view=categories')); } //add the pathway for category $this->setPathway($category->title, ''); } //get the nested categories $category->childs = null; EasyBlogHelper::buildNestedCategories($category->id, $category, false, true); // TODO: Parameterize initial subcategories to display. Ability to configure from backend. $nestedLinks = ''; $initialLimit = $app->getCfg('list_limit') == 0 ? 5 : $app->getCfg('list_limit'); if (count($category->childs) > $initialLimit) { $initialNestedLinks = ''; $initialRow = new stdClass(); $initialRow->childs = array_slice($category->childs, 0, $initialLimit); EasyBlogHelper::accessNestedCategories($initialRow, $initialNestedLinks, '0', '', 'link', ', '); $moreNestedLinks = ''; $moreRow = new stdClass(); $moreRow->childs = array_slice($category->childs, $initialLimit); EasyBlogHelper::accessNestedCategories($moreRow, $moreNestedLinks, '0', '', 'link', ', '); // Hide more nested links until triggered $nestedLinks .= $initialNestedLinks; $nestedLinks .= '<span class="more-subcategories-toggle"> ' . JText::_('COM_EASYBLOG_AND') . ' <a href="javascript: void(0);onclick="eblog.categories.loadMore( this );">' . JText::sprintf('COM_EASYBLOG_OTHER_SUBCATEGORIES', count($category->childs) - $initialLimit) . '</a></span>'; $nestedLinks .= '<span class="more-subcategories" style="display: none;">, ' . $moreNestedLinks . '</span>'; } else { EasyBlogHelper::accessNestedCategories($category, $nestedLinks, '0', '', 'link', ', '); } $catIds = array(); $catIds[] = $category->id; EasyBlogHelper::accessNestedCategoriesId($category, $catIds); $category->nestedLink = $nestedLinks; $modelC = $this->getModel('Category'); $category->cnt = $modelC->getTotalPostCount($category->id); $modelPT = $this->getModel('PostTag'); $model = $this->getModel('Blog'); $modelCat = $this->getModel('Category'); $data = $model->getBlogsBy('category', $catIds, $sort, null, null, null, null, array(), null, null, null, array(), array(), null, EBLOG_PAGINATION_CATEGORIES); $pagination = $model->getPagination(); $allowCat = $modelCat->allowAclCategory($category->id); //for trigger $params = $app->getParams('com_easyblog'); $limitstart = JRequest::getVar('limitstart', 0, '', 'int'); if (!empty($data)) { $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; } } } $teamBlogCount = $modelCat->getTeamBlogCount($category->id); $title = EasyBlogHelper::getPageTitle(JText::_($category->title)); // @task: Set the page title parent::setPageTitle($title, $pagination, $config->get('main_pagetitle_autoappend')); $themes = new CodeThemes(); $themes->set('allowCat', $allowCat); $themes->set('category', $category); $themes->set('sort', $sort); $themes->set('blogs', $data); $themes->set('currentURL', 'index.php?option=com_easyblog&view=categories&layout=listings&id=' . $category->id); $themes->set('pagination', $pagination->getPagesLinks()); $themes->set('config', $config); $themes->set('teamBlogCount', $teamBlogCount); $themes->set('my', $my); $themes->set('acl', $acl); $themes->set('privacy', $privacy); echo $themes->fetch('blog.category.php'); }
function teamApproval() { // Check for request forgeries JRequest::checkToken('GET') or jexit('Invalid Token'); // @task: Check for acl rules. $this->checkAccess('teamblog'); $mainframe = JFactory::getApplication(); $acl = EasyBlogACLHelper::getRuleSet(); $config = EasyBlogHelper::getConfig(); $document = JFactory::getDocument(); $my = JFactory::getUser(); $teamId = JRequest::getInt('team', 0); $approval = JRequest::getInt('approve'); $requestId = JRequest::getInt('id', 0); $ok = true; $message = ''; $type = 'info'; $teamRequest = EasyBlogHelper::getTable('TeamBlogRequest', 'Table'); $teamRequest->load($requestId); if ($approval) { $teamUsers = EasyBlogHelper::getTable('TeamBlogUsers', 'Table'); $teamUsers->user_id = $teamRequest->user_id; $teamUsers->team_id = $teamRequest->team_id; if ($teamUsers->store()) { $message = JText::_('COM_EASYBLOG_TEAMBLOGS_APPROVAL_APPROVED'); } else { $ok = false; $message = JText::_('COM_EASYBLOG_TEAMBLOGS_APPROVAL_FAILED'); $type = 'error'; } } else { $message = JText::_('COM_EASYBLOG_TEAMBLOGS_APPROVAL_REJECTED'); } if ($ok) { $teamRequest->ispending = 0; $teamRequest->store(); $teamBlog = EasyBlogHelper::getTable('TeamBlog', 'Table'); $teamBlog->load($teamRequest->team_id); //now we send notification to requestor $requestor = JFactory::getUser($teamRequest->user_id); $template = $approval ? 'email.teamblog.approved' : 'email.teamblog.rejected'; $toNotifyEmails = array(); $obj = new StdClass(); $obj->unsubscribe = false; $obj->email = $requestor->email; $toNotifyEmails[] = $obj; $notify = EasyBlogHelper::getHelper('Notification'); $emailData = array(); $emailData['team'] = $teamBlog->title; $notify->send($toNotifyEmails, JText::_('COM_EASYBLOG_TEAMBLOGS_JOIN_REQUEST'), $template, $emailData); } $this->setRedirect('index.php?option=com_easyblog&view=teamrequest', $message, $type); }
public function listCategories() { // Anyone with moderate_entry acl is also allowed to change author. $acl = EasyBlogACLHelper::getRuleSet(); $model = $this->getModel('Categories'); $rows = $model->getCategoriesHierarchy(); $pagination = $model->getPagination(); JFactory::getDocument()->addStyleSheet(rtrim(JURI::root(), '/') . '/components/com_easyblog/assets/css/reset.css'); for ($i = 0; $i < count($rows); $i++) { $item =& $rows[$i]; $category = EasyBlogHelper::getTable('Category'); $category->load($item->id); $item->avatar = $category->getAvatar(); } $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('categories', $rows); $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.list.categories.php'); return; }
function newMediaObject($blogid, $username, $password, $file) { jimport('joomla.utilities.error'); jimport('joomla.filesystem.file'); jimport('joomla.filesystem.folder'); global $xmlrpcerruser, $xmlrpcI4, $xmlrpcInt, $xmlrpcBoolean, $xmlrpcDouble, $xmlrpcString, $xmlrpcDateTime, $xmlrpcBase64, $xmlrpcArray, $xmlrpcStruct, $xmlrpcValue; EasyBlogXMLRPCHelper::loginUser($username, $password); $user = JUser::getInstance($username); $acl = EasyBlogACLHelper::getRuleSet($user->id); if (empty($acl->rules->upload_image)) { return new xmlrpcresp(0, $xmlrpcerruser + 2, JText::_('YOU DO NOT HAVE IMAGE UPLOAD RIGHT')); } $config = EasyBlogHelper::getConfig(); $main_image_path = $config->get('main_image_path'); $main_image_path = rtrim($main_image_path, '/'); $rel_upload_path = $main_image_path . '/' . $user->id; $userUploadPath = JPATH_ROOT . DIRECTORY_SEPARATOR . str_ireplace('/', DIRECTORY_SEPARATOR, $main_image_path . DIRECTORY_SEPARATOR . $user->id); $folder = JPath::clean($userUploadPath); $dir = $userUploadPath . DIRECTORY_SEPARATOR; $tmp_dir = JPATH_ROOT . DIRECTORY_SEPARATOR . 'tmp' . DIRECTORY_SEPARATOR; if (!JFolder::exists($dir)) { JFolder::create($dir); } if (strpos($file['name'], '/') !== FALSE) { $file['name'] = substr($file['name'], strrpos($file['name'], '/') + 1); } elseif (strpos($file['name'], '\\' !== FALSE)) { $file['name'] = substr($file['name'], strrpos($file['name'], '\\') + 1); } // Set FTP credentials, if given jimport('joomla.client.helper'); JClientHelper::setCredentialsFromRequest('ftp'); $ftp = JClientHelper::getCredentials('ftp'); $file['name'] = JFile::makesafe($file['name']); //$file['name'] = substr($file['name'], 0, -4) . rand() . '.' . JFile::getExt($file['name']); $file['name'] = substr($file['name'], 0, -4) . '.' . JFile::getExt($file['name']); // write to temp folder $file['tmp_name'] = $tmp_dir . $file['name']; @JFile::write($file['tmp_name'], $file['bits']); $file['size'] = 0; $error = ''; $allowed = EasyImageHelper::canUploadFile($file); if ($allowed !== true) { @JFile::delete($file['tmp_name']); return new xmlrpcresp(0, $xmlrpcerruser + 1, 'The file is not valid'); } // @JFile::write( $dir . $file['name'], $file['bits']); // @task: Ensure that images goes through the same resizing format when uploading via media manager. require_once EBLOG_CLASSES . DIRECTORY_SEPARATOR . 'mediamanager.php'; $media = new EasyBlogMediaManager(); $result = $media->upload($dir, $userUploadPath, $file, '/', 'user'); @JFile::delete($file['tmp_name']); $file['name'] = EasyBlogXMLRPCHelper::cleanImageName($file['name']); $fileUrl = rtrim(JURI::root(), '/') . '/' . $rel_upload_path . '/' . $file['name']; return new xmlrpcresp(new xmlrpcval(array('url' => new xmlrpcval($fileUrl)), 'struct')); }
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); }
function updateBloggerSubscriptionEmail($sid, $email) { $config = EasyBlogHelper::getConfig(); $acl = EasyBlogACLHelper::getRuleSet(); $my = JFactory::getUser(); if ($acl->rules->allow_subscription || empty($my->id) && $config->get('main_allowguestsubscribe')) { $subscriber = EasyBlogHelper::getTable('BloggerSubscription', 'Table'); $subscriber->load($sid); $subscriber->email = $email; $subscriber->store(); } }
public static function isBlogger($userId) { if (empty($userId)) { return false; } $acl = EasyBlogACLHelper::getRuleSet($userId); if ($acl->rules->add_entry) { return true; } else { return false; } }
function preview() { JPluginHelper::importPlugin('easyblog'); $dispatcher = JDispatcher::getInstance(); $mainframe = JFactory::getApplication(); $acl = EasyBlogACLHelper::getRuleSet(); $config = EasyBlogHelper::getConfig(); $document = JFactory::getDocument(); $my = JFactory::getUser(); $params = $mainframe->getParams('com_easyblog'); if (!EasyBlogHelper::isLoggedIn()) { EasyBlogHelper::showLogin(); return; } $draftId = JRequest::getVar('draftid', ''); $draft = EasyBlogHelper::getTable('Draft', 'Table'); $draft->load($draftId); $blog = EasyBlogHelper::getTable('Blog', 'Table'); $blog->bind($draft); $blogger = null; if ($blog->created_by != 0) { $blogger = EasyBlogHelper::getTable('Profile', 'Table'); $blogger->load($blog->created_by); } // @rule: Set the author object into the table. $blog->author = $blogger; $blog->blogger = $blogger; $blogId = empty($draft->entry_id) ? $draft->id : $draft->entry_id; $limitstart = '0'; $notice = ''; $team = ''; $blog->tags = empty($draft->tags) ? array() : $this->bindTags(explode(',', $draft->tags)); // metas $meta = new stdClass(); $meta->id = ''; $meta->keywords = $draft->metakey; $meta->description = $draft->metadesc; $pageTitle = EasyBlogHelper::getPageTitle($config->get('main_title')); $document->setTitle($blog->title . $pageTitle); // process the video here if nessary $blog->intro = EasyBlogHelper::getHelper('Videos')->processVideos($blog->intro); $blog->content = EasyBlogHelper::getHelper('Videos')->processVideos($blog->content); // @rule: Process audio files. $blog->intro = EasyBlogHelper::getHelper('Audio')->process($blog->intro); $blog->content = EasyBlogHelper::getHelper('Audio')->process($blog->content); // @rule: Before any trigger happens, try to replace the gallery first and append it at the bottom. $blog->intro = EasyBlogHelper::getHelper('Gallery')->process($blog->intro, $blog->created_by); $blog->content = EasyBlogHelper::getHelper('Gallery')->process($blog->content, $blog->created_by); // Process jomsocial album's. $blog->intro = EasyBlogHelper::getHelper('Album')->process($blog->intro, $blog->created_by); $blog->content = EasyBlogHelper::getHelper('Album')->process($blog->content, $blog->created_by); // @trigger: onEasyBlogPrepareContent EasyBlogHelper::triggerEvent('easyblog.prepareContent', $blog, $params, $limitstart); //onPrepareContent trigger start $blog->introtext = $blog->intro; $blog->text = $blog->intro . $blog->content; // @trigger: onEasyBlogPrepareContent EasyBlogHelper::triggerEvent('prepareContent', $blog, $params, $limitstart); $blog->intro = $blog->introtext; $blog->content = $blog->text; $isFeatured = false; //page setup $blogHtml = ''; $commentHtml = ''; $blogHeader = ''; $blogFooter = ''; $adsenseHtml = ''; $trackbackHtml = ''; $blogger = null; if ($blog->created_by != 0) { $blogger = EasyBlogHelper::getTable('Profile', 'Table'); $blogger->load($blog->created_by); } //onAfterDisplayTitle, onBeforeDisplayContent, onAfterDisplayContent trigger start $blog->event = new stdClass(); // @trigger: onAfterDisplayTitle / onContentAfterTitle $results = EasyBlogHelper::triggerEvent('afterDisplayTitle', $blog, $params, $limitstart); $blog->event->afterDisplayTitle = JString::trim(implode("\n", $results)); // @trigger: onBeforeDisplayContent / onContentBeforeDisplay $results = EasyBlogHelper::triggerEvent('beforeDisplayContent', $blog, $params, $limitstart); $blog->event->beforeDisplayContent = JString::trim(implode("\n", $results)); // @trigger: onAfterDisplayContent / onContentAfterDisplay EasyBlogHelper::triggerEvent('afterDisplayContent', $blog, $params, $limitstart); $blog->event->afterDisplayContent = JString::trim(implode("\n", $results)); if (!EasyBlogRouter::isCurrentActiveMenu('blogger', $blogger->id)) { $this->setPathway($blogger->getName(), $blogger->getLink()); } if (!EasyBlogRouter::isCurrentActiveMenu('entry', $blog->id)) { $this->setPathway($blog->title, ''); } $blog->totalComments = 0; // Facebook Like integrations require_once EBLOG_CLASSES . DIRECTORY_SEPARATOR . 'facebook.php'; $facebookLike = EasyBlogFacebookLikes::getLikeHTML($blog); $url = EasyBlogRouter::getRoutedURL('index.php?option=com_easyblog&view=entry&id=' . $blog->id, false, true); //get blog navigation object $blogNav = EasyBlogHelper::getBlogNavigation($blog->id, $blog->created, $team, 'team'); //$team $prevLink = array(); if (!empty($blogNav['prev'])) { $prevLink['id'] = $blogNav['prev'][0]->id; $prevLink['title'] = JString::strlen($blogNav['prev'][0]->title) > 50 ? JString::substr($blogNav['prev'][0]->title, 0, 50) . '...' : $blogNav['prev'][0]->title; } $nextLink = array(); if (!empty($blogNav['next'])) { $nextLink['id'] = $blogNav['next'][0]->id; $nextLink['title'] = JString::strlen($blogNav['next'][0]->title) > 50 ? JString::substr($blogNav['next'][0]->title, 0, 50) . '...' : $blogNav['next'][0]->title; } // @rule: Hide introtext if necessary if ($config->get('main_hideintro_entryview')) { $blog->intro = ''; } //get social bookmark provider. require_once EBLOG_CLASSES . DIRECTORY_SEPARATOR . 'bookmark.php'; $bookmark = EasyBlogBookmark::getHTML(); $theme = new CodeThemes(); $theme->set('facebookLike', $facebookLike); $theme->set('notice', $notice); $theme->set('blog', $blog); $theme->set('tags', $blog->tags); $theme->set('blogger', $blogger); $theme->set('prevLink', $prevLink); $theme->set('nextLink', $nextLink); $theme->set('blogRelatedPost', ''); $theme->set('isFeatured', $isFeatured); $theme->set('isMineBlog', true); $theme->set('acl', $acl); $theme->set('url', $url); $theme->set('commentHTML', $commentHtml); $theme->set('bookmark', $bookmark); $theme->set('pdfLinkProperties', EasyBlogHelper::getPDFlinkProperties()); $theme->set('ispreview', true); // @task: trackbacks $trackbacks = ''; $theme->set('trackbackURL', EasyBlogRouter::getRoutedURL('index.php?option=com_easyblog&view=trackback&post_id=' . $blog->id, true, true)); $theme->set('trackbacks', $trackbacks); //google adsense require_once EBLOG_CLASSES . DIRECTORY_SEPARATOR . 'adsense.php'; $adsense = EasyBlogGoogleAdsense::getHTML($blogger->id); $blogHeader = $adsense->header; $blogFooter = $adsense->footer; $theme->set('adsenseHTML', $adsense->beforecomments); $blogHtml = $theme->fetch('blog.read.php'); echo $blogHeader; echo $blogHtml; echo $blogFooter; }
/** * Responsible to display the front page of the blog listings * * @access public */ function display($tmpl = null) { // @task: Set meta tags for latest post EasyBlogHelper::setMeta(META_ID_LATEST, META_TYPE_VIEW); // @task: Set rss links into headers. EasyBlogHelper::getHelper('Feeds')->addHeaders('index.php?option=com_easyblog&view=latest'); $app = JFactory::getApplication(); $doc = JFactory::getDocument(); $config = EasyBlogHelper::getConfig(); $my = JFactory::getUser(); $acl = EasyBlogACLHelper::getRuleSet(); // @task: Add a breadcrumb if the current menu that's being accessed is not from the latest view. if (!EasyBlogRouter::isCurrentActiveMenu('latest')) { $this->setPathway(JText::_('COM_EASYBLOG_LATEST_BREADCRUMB'), ''); } // @task: Get the current active menu's properties. $menu = $app->getMenu()->getActive(); $menu = JFactory::getApplication()->getMenu()->getActive(); $inclusion = ''; if (is_object($menu)) { $params = EasyBlogHelper::getRegistry(); $params->load($menu->params); $inclusion = EasyBlogHelper::getCategoryInclusion($params->get('inclusion')); if ($params->get('includesubcategories', 0) && !empty($inclusion)) { $tmpInclusion = array(); foreach ($inclusion as $includeCatId) { //get the nested categories $category = new stdClass(); $category->id = $includeCatId; $category->childs = null; EasyBlogHelper::buildNestedCategories($category->id, $category); $linkage = ''; EasyBlogHelper::accessNestedCategories($category, $linkage, '0', '', 'link', ', '); $catIds = array(); $catIds[] = $category->id; EasyBlogHelper::accessNestedCategoriesId($category, $catIds); $tmpInclusion = array_merge($tmpInclusion, $catIds); } $inclusion = $tmpInclusion; } } // @task: Necessary filters $sort = JRequest::getCmd('sort', $config->get('layout_postorder')); $model = $this->getModel('Blog'); // @task: Retrieve the list of featured blog posts. $featured = $model->getFeaturedBlog($inclusion); $excludeIds = array(); // @task: Add canonical URLs. if ($config->get('main_canonical_entry')) { $canonicalUrl = EasyBlogRouter::getRoutedURL('index.php?option=com_easyblog&view=latest', false, true, true); $doc->addCustomTag('<link rel="canonical" href="' . $canonicalUrl . '"/>'); } // Test if user also wants the featured items to be appearing in the blog listings on the front page. // Otherwise, we'll need to exclude the featured id's from appearing on the front page. if (!$config->get('layout_featured_frontpage')) { foreach ($featured as $item) { $excludeIds[] = $item->id; } } // @task: Admin might want to display the featured blogs on all pages. if (!$config->get('layout_featured_allpages') && (JRequest::getInt('start', 0) != 0 || JRequest::getInt('limitstart', 0) != 0)) { $featured = array(); } else { for ($i = 0; $i < count($featured); $i++) { $row = $featured[$i]; $row->featuredImage = EasyBlogHelper::getFeaturedImage($row->intro . $row->content); } $featured = EasyBlogHelper::formatBlog($featured, true, false, false, false, false); } // @task: Try to retrieve any categories to be excluded. $excludedCategories = $config->get('layout_exclude_categories'); $excludedCategories = empty($excludedCategories) ? '' : explode(',', $excludedCategories); // @task: Fetch the blog entries. $data = $model->getBlogsBy('', '', $sort, 0, EBLOG_FILTER_PUBLISHED, null, true, $excludeIds, false, false, true, $excludedCategories, $inclusion); $pagination = $model->getPagination(); $params = $app->getParams('com_easyblog'); // @task: Perform necessary formatting here. $data = EasyBlogHelper::formatBlog($data, true, true, true, true); // @task: Update the title of the page if navigating on different pages to avoid Google marking these title's as duplicates. $title = EasyBlogHelper::getPageTitle(JText::_('COM_EASYBLOG_LATEST_PAGE_TITLE')); // @task: Set the page title parent::setPageTitle($title, $pagination, $config->get('main_pagetitle_autoappend')); // @task: Get pagination output here. $paginationHTML = $pagination->getPagesLinks(); $theme = new CodeThemes(); $theme->set('data', $data); $theme->set('featured', $featured); $theme->set('currentURL', EasyBlogRouter::_('index.php?option=com_easyblog&view=latest', false)); $theme->set('pagination', $paginationHTML); // @task: Send back response to the browser. echo $theme->fetch('blog.latest.php'); }
function statistic() { JPluginHelper::importPlugin('easyblog'); $dispatcher = JDispatcher::getInstance(); $mainframe = JFactory::getApplication(); $document = JFactory::getDocument(); $config = EasyBlogHelper::getConfig(); $my = JFactory::getUser(); $acl = EasyBlogACLHelper::getRuleSet(); // Add noindex for tags view by default. $document->setMetadata('robots', 'noindex,follow'); $sort = JRequest::getCmd('sort', $config->get('layout_postorder')); $bId = JRequest::getCmd('id', '0'); //stats type $statType = JRequest::getString('stat', ''); $statId = $statType == 'tag' ? JRequest::getString('tagid', '') : JRequest::getString('catid', ''); $statObject = null; if ($statType == 'category') { $statObject = EasyBlogHelper::getTable('Category', 'Table'); $statObject->load($statId); } else { JTable::addIncludePath(EBLOG_TABLES); $statObject = EasyBlogHelper::getTable('Tag', 'Table'); $statObject->load($statId); } $blogger = EasyBlogHelper::getTable('Profile', 'Table'); $blogger->load($bId); // set meta tags for blogger if ($acl->rules->allow_seo) { EasyBlogHelper::setMeta($blogger->id, META_TYPE_BLOGGER, true); } if (!EasyBlogRouter::isCurrentActiveMenu('blogger')) { $this->setPathway(JText::_('COM_EASYBLOG_BLOGGERS'), EasyBlogRouter::_('index.php?option=com_easyblog&view=blogger')); } if (!EasyBlogRouter::isCurrentActiveMenu('blogger', $blogger->id)) { $this->setPathway($blogger->getName()); } $model = $this->getModel('Blog'); $data = $model->getBlogsBy('blogger', $blogger->id, $sort); $pagination = $model->getPagination(); $data = EasyBlogHelper::formatBlog($data); $rssURL = EasyBlogRouter::_('index.php?option=com_easyblog&view=blogger&task=rss'); 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; } } $twitterFollowMelink = EasyBlogSocialShareHelper::getLink('twitter', $blogger->id); if ($config->get('main_rss')) { if ($config->get('main_feedburner') && $config->get('main_feedburnerblogger')) { $document->addHeadLink($blogger->getRSS(), 'alternate', 'rel', array('type' => 'application/rss+xml', 'title' => 'RSS 2.0')); } else { // Add rss feed link $document->addHeadLink($blogger->getRSS(), 'alternate', 'rel', array('type' => 'application/rss+xml', 'title' => 'RSS 2.0')); $document->addHeadLink($blogger->getAtom(), 'alternate', 'rel', array('type' => 'application/atom+xml', 'title' => 'Atom 1.0')); } } $pageTitle = EasyBlogHelper::getPageTitle($config->get('main_title')); $pageNumber = $pagination->get('pages.current'); $pageText = $pageNumber == 1 ? '' : ' - ' . JText::sprintf('COM_EASYBLOG_PAGE_NUMBER', $pageNumber); $statTitle = ''; if (isset($statType)) { if ($statType == 'tag') { $statTitle = ' - ' . JText::sprintf('COM_EASYBLOG_BLOGGER_STAT_TAG', $statObject->title); } else { $statTitle = ' - ' . JText::sprintf('COM_EASYBLOG_BLOGGER_STAT_CATEGORY', $statObject->title); } } $document->setTitle($blogger->getName() . $statTitle . $pageText . $pageTitle); $tpl = new CodeThemes(); $tpl->set('blogger', $blogger); $tpl->set('sort', $sort); $tpl->set('blogs', $data); $tpl->set('config', $config); $tpl->set('siteadmin', EasyBlogHelper::isSiteAdmin()); $tpl->set('pagination', $pagination->getPagesLinks()); $tpl->set('twitterFollowMelink', $twitterFollowMelink); $tpl->set('my', $my); $tpl->set('acl', $acl); $tpl->set('currentURL', ltrim('/', JRequest::getURI())); $tpl->set('statType', $statType); $tpl->set('statObject', $statObject); echo $tpl->fetch('blog.blogger.php'); }
function statistic() { JPluginHelper::importPlugin('easyblog'); $dispatcher = JDispatcher::getInstance(); $mainframe = JFactory::getApplication(); $document = JFactory::getDocument(); $config = EasyBlogHelper::getConfig(); $my = JFactory::getUser(); $acl = EasyBlogACLHelper::getRuleSet(); $sort = JRequest::getCmd('sort', 'latest'); $id = JRequest::getInt('id', 0); //setting pathway $pathway = $mainframe->getPathway(); $this->setPathway(JText::_('COM_EASYBLOG_TEAMBLOG'), EasyBlogRouter::_('index.php?option=com_easyblog&view=teamblog')); $id = JRequest::getInt('id', 0); if ($id == 0) { echo JText::_('COM_EASYBLOG_TEAMBLOG_INVALID_ID'); return; } // set meta tags for teamblog view EasyBlogHelper::setMeta($id, META_TYPE_TEAM); //stats type $statType = JRequest::getString('stat', ''); $statId = $statType == 'tag' ? JRequest::getString('tagid', '') : JRequest::getString('catid', ''); $statObject = null; if ($statType == 'category') { $statObject = EasyBlogHelper::getTable('Category', 'Table'); $statObject->load($statId); } else { $statObject = EasyBlogHelper::getTable('Tag', 'Table'); $statObject->load($statId); } $team = EasyBlogHelper::getTable('TeamBlog', 'Table'); $team->load($id); $team->avatar = $team->getAvatar(); $gid = EasyBlogHelper::getUserGids(); $isMember = $team->isMember($my->id, $gid); //check if the logged in user a teammember when the team set to member only. if ($team->access == EBLOG_TEAMBLOG_ACCESS_MEMBER) { $isMember = $team->isMember($my->id, $gid); } $team->isMember = $isMember; // check if team description is emtpy or not. if yes, show default message. if (empty($team->description)) { $team->description = JText::_('COM_EASYBLOG_TEAMBLOG_NO_DESCRIPTION'); } //add the pathway for teamblog $this->setPathway($team->title, ''); $tbModel = $this->getModel('TeamBlogs'); $model = $this->getModel('Blog'); $blogs = $model->getBlogsBy('teamblog', $team->id); $blogs = EasyBlogHelper::formatBlog($blogs); $pagination = $model->getPagination(); //now get the teams info $members = $tbModel->getTeamMembers($team->id); $teamMembers = EasyBlogHelper::formatTeamMembers($members); $isFeatured = EasyBlogHelper::isFeatured('teamblog', $team->id); $pageTitle = EasyBlogHelper::getPageTitle($config->get('main_title')); $pageNumber = $pagination->get('pages.current'); $pageText = $pageNumber == 1 ? '' : ' - ' . JText::sprintf('COM_EASYBLOG_PAGE_NUMBER', $pageNumber); $document->setTitle($team->title . $pageText . $pageTitle); EasyBlogHelper::storeSession($team->id, 'EASYBLOG_TEAMBLOG_ID'); //var_dump($blogs);exit; $tpl = new CodeThemes(); $tpl->set('team', $team); $tpl->set('teamMembers', $teamMembers); $tpl->set('data', $blogs); $tpl->set('isFeatured', $isFeatured); $tpl->set('pagination', $pagination->getPagesLinks()); $tpl->set('siteadmin', EasyBlogHelper::isSiteAdmin()); $tpl->set('config', $config); $tpl->set('my', $my); $tpl->set('acl', $acl); $tpl->set('statType', $statType); $tpl->set('statObject', $statObject); echo $tpl->fetch('blog.teamblogs.php'); }