/** * Generates the unsubscribe link for the email * * @since 5.0 * @access public * @param string * @return */ public function getUnsubscribeLink($data, $external = false) { $itemId = EBR::getItemId('latest'); // Generate the unsubscribe hash $hash = base64_encode(json_encode($data->export())); $link = EBR::getRoutedURL('index.php?option=com_easyblog&task=subscription.unsubscribe&data=' . $hash . '&Itemid=' . $itemId, false, $external); return $link; }
function EasyBlogBuildRoute(&$query) { $segments = array(); $config = EB::config(); // index.php?option=com_easyblog&view=entry if (isset($query['view']) && $query['view'] == 'entry' && isset($query['id'])) { if ($config->get('main_sef') != 'simple') { $segments[] = EBR::translate($query['view']); } // Get the post from the cache $postId = (int) $query['id']; $post = EB::post(); $post->load($postId); // Since the cache library is already using the post library to re-render the post table data, just use the permalink. $segments[] = $post->getAlias(); unset($query['id']); unset($query['view']); } // Single category view // index.php?option=com_easyblog&view=categories&layout=listings&id=xxxx if (isset($query['view']) && $query['view'] == 'categories') { // Try to get rid of duplicated view vs menu alias $itemId = isset($query['Itemid']) ? $query['Itemid'] : ''; if ($itemId) { $menu = JFactory::getApplication()->getMenu()->getItem($itemId); // Translate the view first if ($menu->query['view'] != EBR::translate($query['view'])) { $segments[] = EBR::translate($query['view']); } } // Translate the category permalink now if (isset($query['id'])) { $category = EB::cache()->get((int) $query['id'], 'category'); if ($category) { $segments[] = $category->getAlias(); } } unset($query['id']); unset($query['view']); unset($query['layout']); } // Single tag view // index.php?option=com_easyblog&view=tags&layout=listings&id=xxxx if (isset($query['view']) && $query['view'] == 'tags') { $segments[] = EBR::translate($query['view']); if (isset($query['id']) && isset($query['layout'])) { $segments[] = $query['id']; } unset($query['id']); unset($query['view']); unset($query['layout']); } // index.php?option=com_easyblog&view=teamblog&layout=listings&id=xxx if (isset($query['view']) && $query['view'] == 'teamblog') { $segments[] = EBR::translate($query['view']); if (isset($query['layout'])) { $segments[] = EBR::translate($query['layout']); } if (isset($query['id'])) { $team = EB::cache()->get((int) $query['id'], 'team'); $segments[] = $team->getAlias(); } unset($query['id']); unset($query['stat']); unset($query['layout']); unset($query['view']); } // view=blogger&layout=listings&id=xxx if (isset($query['view']) && $query['view'] == 'blogger') { // Add view=blogger $segments[] = EBR::translate($query['view']); // Add bloggers permalink if (isset($query['id'])) { $author = EB::cache()->get((int) $query['id'], 'author'); $segments[] = $author->getAlias(); } if (isset($query['sort'])) { $segments[] = EBR::translate('sort'); $segments[] = EBR::translate($query['sort']); unset($query['sort']); } if (isset($query['search'])) { $segments[] = $query['search']; } unset($query['view']); unset($query['id']); unset($query['layout']); } // index.php?option=com_easyblog&view=dashboard&layout=xxx if (isset($query['view']) && $query['view'] == 'dashboard') { $segments[] = EBR::translate($query['view']); if (isset($query['layout'])) { $segments[] = EBR::translate($query['layout']); } if (isset($query['filter'])) { $segments[] = $query['filter']; unset($query['filter']); } if (isset($query['blogid'])) { $segments[] = $query['blogid']; unset($query['blogid']); } if (isset($query['postType'])) { $segments[] = $query['postType']; unset($query['postType']); } unset($query['view']); unset($query['layout']); } // index.php?option=com_easyblog&view=archive if (isset($query['view']) && $query['view'] == 'archive') { $segments[] = EBR::translate($query['view']); unset($query['view']); if (isset($query['layout'])) { $segments[] = $query['layout']; unset($query['layout']); } if (isset($query['archiveyear'])) { $segments[] = $query['archiveyear']; unset($query['archiveyear']); } if (isset($query['archivemonth'])) { $segments[] = $query['archivemonth']; unset($query['archivemonth']); } if (isset($query['archiveday'])) { $segments[] = $query['archiveday']; unset($query['archiveday']); } } // index.php?option=com_easyblog&view=calendar if (isset($query['view']) && $query['view'] == 'calendar') { $segments[] = EBR::translate($query['view']); unset($query['view']); if (isset($query['year'])) { $segments[] = $query['year']; unset($query['year']); } if (isset($query['month'])) { $segments[] = $query['month']; unset($query['month']); } if (isset($query['day'])) { $segments[] = $query['day']; unset($query['day']); } } // index.php?option=com_easyblog&view=search if (isset($query['view']) && $query['view'] == 'search') { $segments[] = EBR::translate($query['view']); unset($query['view']); if (isset($query['layout'])) { $segments[] = $query['layout']; unset($query['layout']); } if (isset($query['query'])) { $segments[] = $query['query']; unset($query['query']); } } // // index.php?option=com_easyblog&view=composer // if (isset($query['view']) && $query['view'] == 'composer') { // dump('here'); // } // index.php?option=com_easyblog&view=login if (isset($query['view']) && $query['view'] == 'login') { $segments[] = EBR::translate($query['view']); unset($query['view']); } if (isset($query['type'])) { if (!isset($query['format']) && !isset($query['controller'])) { $segments[] = $query['type']; unset($query['type']); } } if (!isset($query['Itemid'])) { $query['Itemid'] = EBR::getItemId(); } return $segments; }
public function onAfterEasyBlogSave($post, $isNew) { if (!$this->exists()) { return; } if (!$post->isPublished()) { return; } $db = EasyBlogHelper::db(); $user = JFactory::getUser(); // Get plugin info $plugin = JPluginHelper::getPlugin('easyblog', 'autoarticle'); $pluginParams = EB::registry($plugin->params); // easyblog blog details $data = array(); $data['title'] = $post->title; $data['alias'] = $post->permalink; // if (empty($post->intro)) { // $data['introtext'] = $post->content; // $data['fulltext'] = ''; // } else { // $data['introtext'] = $post->intro; // $data['fulltext'] = $post->content; // } $data['introtext'] = $post->getContent('entry'); $data['fulltext'] = ''; $EasyBlogitemId = EBR::getItemId('latest'); $readmoreURL = EBR::_('index.php?option=com_easyblog&view=entry&id=' . $post->id . '&Itemid=' . $EasyBlogitemId); $readmoreURL = str_replace('/administrator/', '/', $readmoreURL); $readmoreLink = '<a href="' . $readmoreURL . '" class="readon"><span>' . JText::_('Read More') . '</span></a>'; $data['introtext'] = $data['introtext'] . '<br />' . $readmoreLink; $data['created'] = $post->created; $data['created_by'] = $post->created_by; $data['modified'] = $post->modified; $data['modified_by'] = $user->id; $data['publish_up'] = $post->publish_up; $data['publish_down'] = $post->publish_down; //these four get from plugin params $state = $pluginParams->get('status'); $access = 1; if ($pluginParams->get('access', '-1') == '-1') { $access = $post->access ? 2 : 1; } else { $tmpAccess = $pluginParams->get('access'); switch ($tmpAccess) { case '1': $access = '2'; break; case '2': $access = '3'; break; case '0': default: $access = '1'; break; } } $section = '0'; $category = $pluginParams->get('sectionCategory', '0'); $frontpage = $pluginParams->get('frontpage', '-1') == '-1' ? $post->frontpage : $pluginParams->get('frontpage', '0'); $autoMapCategory = $pluginParams->get('autocategory', '0'); if ($autoMapCategory) { $autoMapped = self::mapCategory($post->category_id); if (!empty($autoMapped->cid)) { $category = $autoMapped->cid; } } $data['state'] = $state; $data['access'] = $access; $data['sectionid'] = $section; $data['catid'] = $category; $data['metakey'] = JRequest::getVar('keywords', ''); $data['metadesc'] = JRequest::getVar('description', ''); $contentMap = EB::table('AutoArticleMap'); $joomlaContent = JTable::getInstance('content'); $aid = ''; // try to get the existing content id via the mapping table $contentMap->load($post->id, true); if (!empty($contentMap->content_id)) { $aid = $contentMap->content_id; } if (empty($aid) && !empty($post->permalink)) { //try to get if the article already inserted before based on title alias. $query = 'SELECT `id` FROM `#__content` WHERE `alias` = ' . $db->Quote($post->permalink); $db->setQuery($query); $aid = $db->loadResult(); } if (!empty($aid)) { $joomlaContent->load($aid); } $joomlaContent->bind($data); // Convert the params field to an array. $registry = new JRegistry(); $joomlaContent->attribs = $registry->toArray(); $joomlaContent->store(); $articleId = $joomlaContent->id; if (is_null($isNew)) { // something wrong here. test the aid to determine. if (empty($aid)) { $isNew = true; } else { $isNew = false; } } if ($isNew && !empty($articleId)) { // if saved ok, then insert the mapping into our map table. $jdate = EB::date(); $map = array(); $map['content_id'] = $articleId; $map['post_id'] = $post->id; $map['created'] = $jdate->toMySQL(); $contentMap->bind($map); $contentMap->store(); } if ($isNew && $frontpage) { JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_content/tables'); $table = JTable::getInstance('Featured', 'ContentTable'); // Insert the new entry $query = 'INSERT INTO `#__content_frontpage`' . ' VALUES ( ' . (int) $articleId . ', 1 )'; $db->setQuery($query); $db->query(); // we require the table object so that we can reorder the ordering column. // reorder featured table ordering $table->reorder(); } $cache = JFactory::getCache('com_content'); $cache->clean(); }
</li> <li> <a href="<?php echo EBR::_('index.php?option=com_easyblog&view=dashboard&layout=entries&Itemid=' . EBR::getItemId('dashboard')); ?> "> <i class="ies-newspaper ies-small"></i> <span><?php echo JText::_('MOD_EASYSOCIAL_MENU_EASYBLOG_POSTS'); ?> </span> </a> </li> <li> <a href="<?php echo EBR::_('index.php?option=com_easyblog&view=dashboard&layout=drafts&Itemid=' . EBR::getItemId('dashboard')); ?> "> <i class="ies-upload-5 ies-small"></i> <span><?php echo JText::_('MOD_EASYSOCIAL_MENU_EASYBLOG_DRAFTS'); ?> </span> </a> </li> <?php } ?> <?php } ?>
/** * Inserts activity stream for JomSocial * * @since 5.0 * @access public * @param EasyBlogTableBlog * @return */ public function insertActivity(EasyBlogPost $post, $command = '', $content = '') { // Determine which command to use for this stream if (empty($command)) { $command = $post->isNew() ? 'easyblog.blog.add' : 'easyblog.blog.update'; } // Check if Jomsocial exists if (!$this->exists()) { return false; } // If this is a feed source and the settings doesn't allow this, skip this if ($command == 'easyblog.blog.add' && $post->isNew() && $post->isFromFeed() && !$this->config->get('integrations_jomsocial_rss_import_activity')) { return false; } // Ensure that the configuration allows user to publish new feed if ($command == 'easyblog.blog.add' && $post->isNew() && !$this->config->get('integrations_jomsocial_blog_new_activity')) { return false; } // Ensure that the configuration allows user to publish new feed when blog is updated if ($command == 'easyblog.blog.update' && !$post->isNew() && !$this->config->get('integrations_jomsocial_blog_update_activity')) { return false; } // Determine the post title $title = $this->getPostTitle($post); // Get the category the post is associated to $category = $post->getPrimaryCategory(); $categoryLink = $category->getExternalPermalink(); // Get the permalink of the blog post $permalink = $post->getExternalPermalink(); // If blog post is being posted from the back end and SH404 is installed, we should just use the raw urls. if ($this->app->isAdmin() && EB::router()->isSh404Enabled()) { $itemId = EBR::getItemId('latest'); $itemId = '&Itemid=' . $itemId; $permalink = rtrim(JURI::root(), '/') . '/index.php?option=com_easyblog&view=entry&id=' . $post->id . $itemId; $categoryLink = rtrim(JURI::root(), '/') . '/index.php?option=com_easyblog&view=categories&layout=listings&id=' . $category->id . $itemId; } // If there is no content provided, we assume that the user wants to use the blog post if (!$content) { $content = $this->prepareBlogContent($post, $permalink); } // Prepare the title of the post $streamTitle = JText::sprintf('COM_EASYBLOG_JS_ACTIVITY_BLOG_ADDED_NON_CATEGORY', $permalink, $title); // If this is not a new post, we need to use a different title if (!$post->isNew() && $command == 'easyblog.blog.update') { $streamTitle = JText::sprintf('COM_EASYBLOG_JS_ACTIVITY_BLOG_UPDATED_NON_CATEGORY', $permalink, $title); } // Determines which stream title to use if ($this->config->get('integrations_jomsocial_show_category') && $post->isNew() && $command == 'easyblog.blog.add') { $streamTitle = JText::sprintf('COM_EASYBLOG_JS_ACTIVITY_BLOG_ADDED', $permalink, $title, $categoryLink, JText::_($category->title)); } if (!$post->isNew() && $command == 'easyblog.blog.update') { $streamTitle = JText::sprintf('COM_EASYBLOG_JS_ACTIVITY_BLOG_UPDATED', $permalink, $title, $categoryLink, JText::_($category->title)); } // Featuring of a blog post if ($command == 'easyblog.blog.featured') { $streamTitle = JText::sprintf('COM_EASYBLOG_JS_ACTIVITY_BLOG_FEATURED', $permalink, $title); } // Insert the object into the stream now $obj = new stdClass(); $obj->access = $post->access; $obj->title = $streamTitle; $obj->content = $content; $obj->cmd = $command; // Should we enable likes if ($this->config->get('integrations_jomsocial_activity_likes')) { $obj->like_id = $post->id; $obj->like_type = 'com_easyblog'; } // Should we link the comments if ($this->config->get('integrations_jomsocial_activity_comments')) { $obj->comment_id = $post->id; $obj->comment_type = 'com_easyblog'; } $obj->actor = $post->created_by; $obj->target = 0; $obj->app = 'easyblog'; $obj->cid = $post->id; // If this post is contributed in an event or a group, update it accordingly. if ($post->getBlogContribution()) { // Get the event object // $contribution = $post->getBlogContribution(); // Event type if ($post->source_type == EASYBLOG_POST_SOURCE_JOMSOCIAL_EVENT) { JTable::addIncludePath(JPATH_ROOT . '/components/com_community/tables'); // Load the event $event = JTable::getInstance('Event', 'CTable'); $event->load($post->source_id); // Set the stream title $eventLink = CRoute::_('index.php?option=com_community&view=events&task=viewevent&eventid=' . $event->id); $obj->title = JText::sprintf('COM_EASYBLOG_JS_ACTIVITY_EVENT_BLOG_ADDED', $permalink, $title, $eventLink, $event->title); // Set a new command $obj->cmd = 'event.blog.added'; $obj->target = $event->id; $obj->cid = $event->id; $obj->eventid = $event->id; } // Group type if ($post->source_type == EASYBLOG_POST_SOURCE_JOMSOCIAL_GROUP) { JTable::addIncludePath(JPATH_ROOT . '/components/com_community/tables'); // Load the group $group = JTable::getInstance('Group', 'CTable'); $group->load($post->source_id); // Set the stream title $groupLink = CRoute::_('index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $group->id); $obj->title = JText::sprintf('COM_EASYBLOG_JS_ACTIVITY_GROUP_BLOG_ADDED', $permalink, $title, $groupLink, $group->name); $obj->group_access = $group->approvals; $obj->target = $group->id; $obj->cid = $group->id; $obj->groupid = $group->id; $obj->cmd = 'group.blog.added'; } } // Ensure that the likes and comment uses the correct type if (!$post->isNew()) { $obj->like_type = 'com_easyblog.update'; $obj->comment_type = 'com_easyblog.update'; } // Insert into jomsocial now CFactory::load('libraries', 'activities'); CActivityStream::add($obj); }