/** * Processes requests to join the team * * @since 4.0 * @access public * @param string * @return */ public function join() { // Check for request forgeries EB::checkToken(); // Only allow registered users EB::requireLogin(); $return = $this->input->get('return', '', 'default'); if ($return) { $return = base64_decode($return); } // Default return url if (!$return) { $return = EB::_('index.php?option=com_easyblog&view=teamblog', false); } // Get the team data $id = $this->input->get('id', 0, 'int'); $team = EB::table('TeamBlog'); $team->load($id); if (!$id || !$team->id) { $this->info->set('COM_EASYBLOG_TEAMBLOG_INVALID_ID_PROVIDED', 'error'); return $this->app->redirect($return); } $model = EB::model('TeamBlogs'); $isMember = $model->isMember($team->id, $this->my->id); // Check if the user already exists if ($isMember) { $this->info->set('COM_EASYBLOG_TEAMBLOG_ALREADY_MEMBER', 'error'); return $this->app->redirect($return); } // If the user is a site admin, they are free to do whatever they want if (EB::isSiteAdmin()) { $map = EB::table('TeamBlogUsers'); $map->user_id = $this->my->id; $map->team_id = $team->id; $map->store(); $this->info->set('COM_EASYBLOG_TEAMBLOG_REQUEST_JOINED', 'success'); } else { // Create a new request $request = EB::table('TeamBlogRequest'); $request->team_id = $team->id; $request->user_id = $this->my->id; $request->ispending = true; $request->created = EB::date()->toSql(); // If request was already made previously, skip this if ($request->exists()) { $this->info->set('COM_EASYBLOG_TEAMBLOG_REQUEST_ALREADY_SENT', 'error'); return $this->app->redirect($return); } // Store the request now $state = $request->store(); if (!$state) { $this->info->set($request->getError(), 'error'); return $this->app->redirect($return); } // Send moderation emails $request->sendModerationEmail(); $this->info->set('COM_EASYBLOG_TEAMBLOG_REQUEST_SENT', 'success'); } return $this->app->redirect($return); }
/** * Removes featured status from an object * * @since 4.0 * @access public * @param string * @return */ public function removeFeatured() { $ajax = EB::ajax(); // Ensure that the user has privileges if (!EB::isSiteAdmin() && !$this->acl->get('feature_entry')) { return JError::raiseError(500, JText::_('COM_EASYBLOG_NOT_ALLOWED')); } $type = $this->input->get('type', '', 'word'); $id = $this->input->get('id', '', 'int'); if ($type == 'blogger') { $title = JText::_('COM_EASYBLOG_UNFEATURE_AUTHOR_DIALOG_TITLE'); $content = JText::_('COM_EASYBLOG_UNFEATURE_AUTHOR_DIALOG_CONTENT'); } if ($type == 'teamblog') { $title = JText::_('COM_EASYBLOG_UNFEATURE_TEAMBLOG_DIALOG_TITLE'); $content = JText::_('COM_EASYBLOG_UNFEATURE_TEAMBLOG_DIALOG_CONTENT'); } $model = EB::model('Featured'); $model->removeFeatured($type, $id); $theme = EB::template(); $theme->set('title', $title); $theme->set('content', $content); $output = $theme->output('site/featured/dialog.unfeature'); return $ajax->resolve($output); }
/** * Deletes a list of post templates * * @since 4.0 * @access public * @param string * @return */ public function delete() { // Check for request forgeries EB::checkToken(); $ids = $this->input->get('ids', array(), 'array'); $redirect = EB::_('index.php?option=com_easyblog&view=dashboard&layout=templates', false); if (!$ids) { $this->info->set(JText::_('COM_EASYBLOG_DASHBOARD_TEMPLATES_INVALID_ID'), 'error'); return $this->app->redirect($redirect); } foreach ($ids as $id) { $template = EB::table('PostTemplate'); $template->load((int) $id); // Ensure that the user has access to delete this if ($template->user_id == $this->my->id || EB::isSiteAdmin()) { $template->delete(); } } if ($this->doc->getType() != 'ajax') { $this->info->set('COM_EASYBLOG_DASHBOARD_TEMPLATES_DELETED_SUCCESS', 'success'); return $this->app->redirect($redirect); } // For ajax calls, we shouldn't do anything return $this->ajax->resolve(); }
/** * Determines if the post template is a core templae * * @since 5.0 * @access public * @param string * @return */ public function isOwner() { $my = EB::user(); if (EB::isSiteAdmin($my->id) || $this->user_id == $my->id) { return true; } else { return false; } }
function display($tmpl = null) { JPluginHelper::importPlugin('easyblog'); $dispatcher = JDispatcher::getInstance(); $mainframe = JFactory::getApplication(); $document = JFactory::getDocument(); $config = EasyBlogHelper::getConfig(); //for trigger $params = $mainframe->getParams('com_easyblog'); $joomlaVersion = EasyBlogHelper::getJoomlaVersion(); $blogId = $this->input->get('id', 0, 'int'); if (empty($blogId)) { return JError::raiseError(404, JText::_('COM_EASYBLOG_BLOG_NOT_FOUND')); } $my = JFactory::getUser(); $blog = EB::table('Blog'); $blog->load($blogId); $post = EB::post($blogId); // Check if blog is password protected. $protected = $this->isProtected($post); if ($protected !== false) { return; } // If the blog post is already deleted, we shouldn't let it to be accessible at all. if ($post->isTrashed()) { return JError::raiseError(404, JText::_('COM_EASYBLOG_ENTRY_BLOG_NOT_FOUND')); } // Check if the blog post is trashed if (!$post->isPublished() && $this->my->id != $post->created_by && !EB::isSiteAdmin()) { return JError::raiseError(404, JText::_('COM_EASYBLOG_ENTRY_BLOG_NOT_FOUND')); } // Check for team's privacy $allowed = $this->checkTeamPrivacy($post); if ($allowed === false) { return JError::raiseError(404, JText::_('COM_EASYBLOG_TEAMBLOG_MEMBERS_ONLY')); } // Check if the blog post is accessible. $accessible = $post->isAccessible(); if (!$accessible->allowed) { echo $accessible->error; return; } // Format the post $post = EB::formatter('entry', $post); $theme = EB::template(); $theme->set('post', $post); $blogHtml = $theme->output('site/blogs/entry/pdf'); $pageTitle = EasyBlogHelper::getPageTitle($config->get('main_title')); $document->setTitle($post->title . $pageTitle); $document->setName($post->getPermalink()); // Fix phoca pdf plugin. if (method_exists($document, 'setArticleText')) { $document->setArticleText($blogHtml); } echo $blogHtml; }
/** * Pushes to the oauth site * * @since 4.0 * @access public * @param string * @return */ public function push(EasyBlogPost &$post) { // When there is no access token set on this oauth record, we shouldn't do anything if (!$this->access_token) { $this->setError(JText::sprintf('No access token available for autoposting on %1$s', $this->type)); return false; } $config = EB::config(); // Determines if this user is really allowed to auto post $author = $post->getAuthor(); // Check the author's acl $acl = EB::acl($author->id); $rule = 'update_' . $this->type; if (!$acl->get($rule) && !EB::isSiteAdmin($post->created_by)) { $this->setError(JText::sprintf('No access to autopost on %1$s', $this->type)); return false; } // we only check if the autopost on blog edit is disabled. if (!$config->get('integrations_' . $this->type . '_centralized_send_updates')) { // Check if the blog post was shared before. if ($this->isShared($post->id)) { $this->setError(JText::sprintf('Post %1$s has been shared to %2$s before.', $post->id, $this->type)); return false; } } // Ensure that the oauth data has been set correctly $config = EB::config(); $key = $config->get('integrations_' . $this->type . '_api_key'); $secret = $config->get('integrations_' . $this->type . '_secret_key'); // If either of this is empty, skip this if (!$key || !$secret) { return false; } // Set the callback URL $callback = JURI::base() . 'index.php?option=com_easyblog&task=oauth.grant&type=' . $this->type; // Now we do the real thing. Get the library and push $lib = EB::oauth()->getClient($this->type, $key, $secret, $callback); $lib->setAccess($this->access_token); // Try to share the post now $state = $lib->share($post, $this); if ($state === true) { $history = EB::table('OAuthPost'); $history->load(array('oauth_id' => $this->id, 'post_id' => $post->id)); $history->post_id = $post->id; $history->oauth_id = $this->id; $history->created = EB::date()->toSql(); $history->modified = EB::date()->toSql(); $history->sent = EB::date()->toSql(); $history->store(); return true; } return false; }
/** * Allows caller to unsubscribe a person given the id of the subscription * * @since 5.0 * @access public */ public function unsubscribe() { // Default redirection url $redirect = EBR::_('index.php?option=com_easyblog&view=subscription', false); // Default redirection link should link to the front page if the user isn't logged in if ($this->my->guest) { $redirect = EBR::_('index.php?option=com_easyblog', false); } $return = $this->getReturnURL(); if ($return) { $redirect = $return; } // Get the subscription id $id = $this->input->get('id', 0, 'int'); $subscription = EB::table('Subscriptions'); // Load up the subscription if id is provided if ($id) { $subscription->load($id); // Verify if the user really has access to unsubscribe for guests if (!$subscription->id) { return JError::raiseError(500, JText::_('COM_EASYBLOG_NOT_ALLOWED_TO_PERFORM_ACTION')); } // Ensure that the registered user is allowed to unsubscribe. if ($subscription->user_id && $this->my->id != $subscription->user_id && !EB::isSiteAdmin()) { return JError::raiseError(500, JText::_('COM_EASYBLOG_NOT_ALLOWED_TO_PERFORM_ACTION')); } } else { // Try to get the email and what not from the query $data = $this->input->get('data', '', 'raw'); $data = base64_decode($data); $registry = new JRegistry($data); $id = $registry->get('sid', ''); $subscription->load($id); // Verify if the user really has access to unsubscribe for guests if (!$subscription->id) { return JError::raiseError(500, JText::_('COM_EASYBLOG_NOT_ALLOWED_TO_PERFORM_ACTION')); } // Get the token from the url and ensure that the token matches $token = $registry->get('token', ''); if ($token != md5($subscription->id . $subscription->created)) { JError::raiseError(500, JText::_('COM_EASYBLOG_NOT_ALLOWED_TO_PERFORM_ACTION')); } } // Try to delete the subscription $state = $subscription->delete(); // Ensure that the user really owns this item if (!$state) { $this->info->set($subscription->getError()); return $this->app->redirect($redirect); } $this->info->set('COM_EASYBLOG_UNSUBSCRIBED_SUCCESS', 'success'); return $this->app->redirect($redirect); }
public function execute() { if (!$this->items) { return $this->items; } // cache teamblogs EB::cache()->insertTeams($this->items); $teams = array(); // Load up the blogs model $model = EB::model('TeamBlogs'); // Get the current user's group id's $gid = EB::getUserGids(); foreach ($this->items as $item) { $team = EB::table('TeamBlog'); $team->load($item->id); // Check if the logged in user is a member of the group $team->isMember = $team->isMember($this->my->id, $gid); $team->isActualMember = $team->isMember($this->my->id, $gid, false); $team->members = $model->getAllMembers($team->id, 5); // total member count ( including actual members and users from asociated joomla group.) $team->memberCount = $team->getAllMembersCount(); // post count associated with this teamblog. $team->postCount = $team->getPostCount(); // Get the list of blog posts form this team $blogs = array(); if ($team->access != EBLOG_TEAMBLOG_ACCESS_MEMBER || $team->isMember || EB::isSiteAdmin()) { $blogs = $model->getPosts($team->id, EASYBLOG_TEAMBLOG_LISTING_NO_POST); $blogs = EB::formatter('list', $blogs); } $team->blogs = $blogs; // Get the list of tags // $team->tags = $team->getTags(); // Get categories used in this team // $team->categories = $team->getCategories(); // Determines if the team is featured if (isset($item->isfeatured)) { $team->isFeatured = $item->isfeatured; } else { $team->isFeatured = EB::isFeatured('teamblog', $team->id); } // 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'); } // Determines if the viewer is subscribed to this team $team->isTeamSubscribed = $model->isTeamSubscribedEmail($team->id, $this->my->email); // If the user is subscribed, we need to get his subscription id $team->subscription_id = $team->isTeamSubscribed; $teams[] = $team; } return $teams; }
public function __construct($overrideTheme = null, $options = array()) { parent::__construct(); // Determine if this is an admin location if (isset($options['admin']) && $options['admin']) { $this->admin = true; } // Determine the configured theme $theme = $this->config->get('layout_theme', $overrideTheme); // If a view is provided into the theme, the theme files could call methods from a view if (isset($options['view']) && is_object($options['view'])) { $this->view = $options['view']; } $this->theme = $theme; $obj = new stdClass(); $obj->config = EB::config(); $obj->my = JFactory::getUser(); $obj->admin = EB::isSiteAdmin(); $obj->profile = EB::user(); // If it's development mode, allow user to invoke in the url to change theme. $environment = $obj->config->get('easyblog_environment'); if ($environment == 'development') { $invokeTheme = $this->input->get('theme', '', 'word'); if ($invokeTheme) { $this->theme = $invokeTheme; } } // If this is entry view, or category view, we need to respect the theme's category $this->menu = $this->app->getMenu()->getActive(); $this->params = new JRegistry(); // If there is an active menu, try to get the menu parameters. if ($this->menu) { // Get the params prefix $prefix = isset($options['paramsPrefix']) ? $options['paramsPrefix'] : ''; // Set the current parameters. if ($prefix) { $model = EB::model('Menu'); $this->params = $model->getCustomMenuParams($this->menu->id, $this->menu->params, $prefix); } else { $this->params = $this->menu->params; } // We will just set it here from the menu when this class first get instantiate. // The corresponding view will have to do their own assignment if the view's templates need to access this entryParams $this->entryParams = $this->params; } //is blogger mode flag $obj->isBloggerMode = EBR::isBloggerMode(); $this->my = $obj->my; // Assign the acl $this->acl = EB::acl(); }
/** * Retrieves a list of articles on the site * * @since 5.0 * @access public * @param string * @return */ public function getPosts($userId = null) { $db = EB::db(); $query = array(); $query[] = 'SELECT * FROM ' . $db->quoteName('#__easyblog_post'); $query[] = 'WHERE ' . $db->quoteName('published') . '!=' . $db->Quote(EASYBLOG_POST_BLANK); $query[] = 'and ' . $db->quoteName('state') . '!=' . $db->Quote(EASYBLOG_POST_NORMAL); // If user is a site admin, we want to show everything if (!EB::isSiteAdmin()) { $user = JFactory::getUser($userId); $query[] = 'AND ' . $db->quoteName('created_by') . '=' . $db->Quote($user->id); } $query = implode(' ', $query); $db->setQuery($query); $result = $db->loadObjectList(); return $result; }
/** * Allows caller to compile scripts on the site * * @since 5.0 * @access public * @param string * @return */ public function compile() { if (!EB::isSiteAdmin()) { return JError::raiseError(JText::_('You had fun?')); } // See if the user wants to compile by specific sections $sections = $this->input->get('sections', array('admin', 'site', 'dashboard', 'composer'), 'word'); // Should we be compiling and minifying the scripts? $minify = $this->input->get('minify', false, 'bool'); $compiler = EB::compiler(); $results = array(); foreach ($sections as $section) { $result = $compiler->compile($section, $minify); $results[] = $result; } // XHR transport header('Content-type: text/x-json; UTF-8'); echo json_encode($results); exit; }
public function display($tmpl = null) { // Get the blog post $id = $this->input->get('id', 0, 'int'); // Load the blog post now $blog = EB::table('Blog'); $blog->load($id); // If blog id is not provided correctly, throw a 404 error page if (!$id || !$blog->id) { return JError::raiseError(404, JText::_('COM_EASYBLOG_ENTRY_BLOG_NOT_FOUND')); } // If the settings requires the user to be logged in, do not allow guests here. if ($this->my->id <= 0 && $this->config->get('main_login_read')) { $url = EB::_('index.php?option=com_easyblog&view=entry&id=' . $id . '&layout=login', false); return $this->app->redirect($url); } // Check if blog is password protected. if ($this->config->get('main_password_protect') && !empty($blog->blogpassword) && !$blog->verifyPassword()) { return JError::raiseError(404, JText::_('COM_EASYBLOG_ENTRY_BLOG_NOT_FOUND')); } // If the blog post is already deleted, we shouldn't let it to be accessible at all. if ($blog->isTrashed()) { return JError::raiseError(404, JText::_('COM_EASYBLOG_ENTRY_BLOG_NOT_FOUND')); } // Check if the blog post is trashed if (!$blog->isPublished() && $my->id != $blog->created_by && !EB::isSiteAdmin()) { return JError::raiseError(404, JText::_('COM_EASYBLOG_ENTRY_BLOG_NOT_FOUND')); } // If the viewer is the owner of the blog post, display a proper message if ($this->my->id == $blog->created_by && !$blog->isPublished()) { $notice = JText::_('COM_EASYBLOG_ENTRY_BLOG_UNPUBLISHED_VISIBLE_TO_OWNER'); } if (EB::isSiteAdmin() && !$blog->isPublished()) { $notice = JText::_('COM_EASYBLOG_ENTRY_BLOG_UNPUBLISHED_VISIBLE_TO_ADMIN'); } $blog = EB::formatter('post', $blog); $this->set('post', $blog); return parent::display(); }
public function getPosts($tmpl = null) { // Ensure that the user is logged in. EB::requireLogin(); $lang = $this->input->getVar('code', null); $langid = $this->input->getVar('codeid', null); $search = $this->input->getVar('query', ''); // Admin might want to display the featured blogs on all pages. $start = $this->input->get('start', 0, 'int'); $limitstart = $this->input->get('limitstart', 0, 'int'); // conditions $options = array(); $options['langcode'] = $lang; if ($search) { $options['search'] = $search; } if (!EB::isSiteAdmin()) { $options['userid'] = $this->my->id; } $model = EB::model('Blog'); // get results $data = $model->getAssociationPosts($options); // Get the pagination $pagination = $model->getPagination(); // $pagination = $pagination->getPagesLinks(); if ($data) { EB::cache()->insert($data); } $posts = EB::formatter('list', $data, false); $this->set('posts', $posts); $this->set('langcode', $lang); $this->set('langid', $langid); $this->set('search', $search); $this->set('pagination', $pagination); parent::display('composer/posts/listing'); }
/** * Toggle publish for posts * * @since 4.0 * @access public * @param string * @return */ public function togglePublish() { // Check for tokens EB::checkToken(); // Build the return url $return = EBR::_('index.php?option=com_easyblog&view=dashboard&layout=entries', false); if ($this->getReturnURL()) { $return = $this->getReturnURL(); } // Ensure that the user has access to publish items if ($this->my->guest) { return JError::raiseError(500, 'COM_EASYBLOG_NO_PERMISSION_TO_PUBLISH_OR_UNPUBLISH_BLOG'); } // Get the task $task = $this->getTask(); // Get id's $ids = $this->input->get('ids', '', 'array'); foreach ($ids as $id) { $post = EB::post($id); if (!$this->acl->get('moderate_entry') && !$this->acl->get('publish_entry') && !EB::isSiteAdmin()) { $this->info->set(JText::_('COM_EASYBLOG_NO_PERMISSIONS_TO_MODERATE'), 'error'); return $this->app->redirect($return); } if (method_exists($post, $task)) { $post->{$task}(); } } $message = JText::_('COM_EASYBLOG_POSTS_PUBLISHED_SUCCESS'); if ($task == 'unpublish') { $message = JText::_('COM_EASYBLOG_POSTS_UNPUBLISHED_SUCCESS'); } // Set info data $this->info->set($message, 'success'); return $this->app->redirect($return); }
/** * Saves an author object * * @since 4.0 * @access public * @param string * @return */ public function save() { // Check for request forgeries EB::checkToken(); // Check for acl rules. $this->checkAccess('user'); // Create a new JUser object $id = $this->input->get('id', 0, 'int'); $user = JFactory::getUser($id); // Get the user group's id $gid = $user->get('gid'); // Get the posted data $post = $this->input->getArray('post'); // Retrieve the username and password of the user $post['username'] = $this->input->get('username', '', 'default'); $post['password'] = $this->input->get('password', '', 'default'); $post['password2'] = $this->input->get('password2', '', 'default'); // Get the data from Joomla's form if (isset($post['jform']['params'])) { $post['params'] = $post['jform']['params']; unset($post['jform']); } // Bind the post request on the user's object $state = $user->bind($post); // Default redirection url $redirect = 'index.php?option=com_easyblog&view=bloggers&layout=form&id=' . $user->id; if (!$state) { $this->info->set($user->getError(), 'error'); return $this->app->redirect($redirect); } // Get the user's id if ($user->id == $this->my->id && $user->block) { $this->info->set(JText::_('You are not allowed to block yourself.'), 'error'); return $this->app->redirect($redirect); } if ($user->authorise('core.admin') && $user->block) { $this->info->set(JText::_('You are not allowed to block a super administrator.'), 'error'); return $this->app->redirect($redirect); } if ($user->authorise('core.admin') && !$this->my->authorise('core.admin')) { $this->info->set(JText::_('You cannot edit a Super User account.'), 'error'); return $this->app->redirect($redirect); } $gid = $post['gid']; if (!empty($gid)) { $user->groups = array(); foreach ($gid as $groupid) { $user->groups[$groupid] = $groupid; } } // Are we dealing with a new user which we need to create? $isNew = $user->id < 1; // Try to save the user now $state = $user->save(); if (!$state) { $this->info->set($user->getError(), 'error'); return $this->app->redirect($redirect); } // Update the user's session data if the current user is being edited to ensure that // the current user's data is correct if ($user->id == $this->my->id) { $session = JFactory::getSession(); $session->set('user', $user); } // If this is a new record, ensure that the id is not set if ($isNew) { unset($post['id']); } // Set the proper permalink if (isset($post['user_permalink'])) { $post['permalink'] = $post['user_permalink']; unset($post['user_permalink']); } // Only allow site admins to add html codes for the description and biography if (EB::isSiteAdmin()) { $post['description'] = $this->input->get('description', '', 'html'); $post['biography'] = $this->input->get('biography', '', 'html'); } // After the user record is stored, we also want to update EasyBlog's records. $author = EB::user($user->id); // Bind the posted data $author->bind($post); // Get the file data $file = $this->input->files->get('avatar', ''); if (isset($file['tmp_name']) && !empty($file['tmp_name'])) { $author->bindAvatar($file, EB::acl()); } // Save other user parameters $registry = EB::registry(); // Save google profile url if (isset($post['google_profile_url'])) { $registry->set('google_profile_url', $post['google_profile_url']); } if (isset($post['show_google_profile_url'])) { $registry->set('show_google_profile_url', $post['show_google_profile_url']); } $author->params = $registry->toString(); // Try to save the author object now $author->store(); // Save the social settings $twitter = EB::table('OAuth'); $twitter->load(array('user_id' => $user->id, 'type' => EBLOG_OAUTH_TWITTER)); $twitter->auto = $this->input->get('integrations_twitter_auto'); $twitter->message = $this->input->get('integrations_twitter_message', '', 'default'); // Try to save the twitter oauth object now $state = $twitter->store(); if (!$state) { $this->info->set($twitter->getError(), 'error'); return $this->app->redirect($redirect); } // Try to save the linked in oauth object $linkedin = EB::table('OAuth'); $linkedin->load(array('user_id' => $user->id, 'type' => EBLOG_OAUTH_LINKEDIN)); $linkedin->auto = $this->input->get('integrations_linkedin_auto', '', 'bool'); $linkedin->message = $this->input->get('integrations_linkedin_message', '', 'default'); $linkedin->private = $this->input->get('integrations_linkedin_private', '', 'bool'); // Save the oauth object now $state = $linkedin->store(); if (!$state) { $this->info->set($linkedin->getError(), 'error'); return $this->app->redirect($redirect); } // Store the Facebook oauth object now $facebook = EB::table('OAuth'); $facebook->load(array('user_id' => $user->id, 'type' => EBLOG_OAUTH_FACEBOOK)); $facebook->auto = $this->input->get('integrations_facebook_auto', '', 'bool'); $facebook->message = ''; // Save the facebook object now $state = $facebook->store(); if (!$state) { $this->info->set($facebook->getError(), 'error'); return $this->app->redirect($redirect); } // Save google adsense codes now if ($this->config->get('integration_google_adsense_enable')) { $adsense = EB::table('Adsense'); $adsense->load($user->id); $adsense->code = $post['adsense_code']; $adsense->display = $post['adsense_display']; $adsense->published = $post['adsense_published']; $adsense->store(); } // Store Feedburner's data $feedburner = EB::table('Feedburner'); $feedburner->load($user->id); $feedburner->url = $post['feedburner_url']; $feedburner->store(); // Get the current task $task = $this->getTask(); $this->info->set('COM_EASYBLOG_BLOGGER_SAVED', 'success'); if ($task == 'apply') { $redirect = 'index.php?option=com_easyblog&view=bloggers&layout=form&id=' . $user->id; return $this->app->redirect($redirect); } return $this->app->redirect('index.php?option=com_easyblog&view=bloggers'); }
defined('_JEXEC') or die('Unauthorized Access'); ?> <div class="eb-head"> <h2 class="eb-head-title reset-heading pull-left"> <i class="fa fa-tags"></i> <?php echo JText::_('COM_EASYBLOG_DASHBOARD_TAGS'); ?> </h2> </div> <?php echo EB::info()->html(); ?> <?php if ($this->acl->get('create_tag') || EB::isSiteAdmin()) { ?> <form id="tags" method="post" action="<?php echo JRoute::_('index.php'); ?> "> <div class="eb-box"> <div class="eb-box-head"> <?php echo JText::_('COM_EASYBLOG_DASHBOARD_TAG_CREATE_NEW'); ?> </div> <div class="eb-box-body"> <p class="eb-box-lead"> <?php echo JText::_('COM_EASYBLOG_DASHBOARD_TAG_CREATE_NEW_HELP');
/** * Determines if the user is a team admin * * @since 4.0 * @access public * @param string * @return */ public static function isTeamAdmin() { static $admins = null; $my = JFactory::getUser(); if ($my->guest) { return false; } if (EB::isSiteAdmin()) { return true; } if (!isset($admisn[$my->id])) { $model = EB::model('TeamBlogs'); $admins[$my->id] = $model->checkIsTeamAdmin($my->id); } return $admins[$my->id]; }
/** * Retrieves a list of blog posts the user has created * * @since 4.0 * @access public * @param string * @return */ public static function getUserBlogs($appkey, $username, $password) { global $xmlrpcerruser, $xmlrpcI4, $xmlrpcInt, $xmlrpcBoolean, $xmlrpcDouble, $xmlrpcString, $xmlrpcDateTime, $xmlrpcBase64, $xmlrpcArray, $xmlrpcStruct, $xmlrpcValue; self::login($username, $password); $my = JFactory::getUser($username); $uri = JURI::getInstance(); $admin = EB::isSiteAdmin($my); $domain = $uri->toString(array('scheme', 'host', 'port')); $xmlrpcLink = $domain . '/index.php?option=com_easyblog&controller=xmlrpc'; $structArray = array(); $structArray[] = new xmlrpcval(array('isAdmin' => new xmlrpcval($admin, $xmlrpcBoolean), 'url' => new xmlrpcval(JURI::root(), $xmlrpcString), 'blogid' => new xmlrpcval($my->id, $xmlrpcString), 'blogName' => new xmlrpcval($my->name . '\'s blog entries', $xmlrpcString), 'xmlrpc' => new xmlrpcval($xmlrpcLink, $xmlrpcString)), 'struct'); return new xmlrpcresp(new xmlrpcval($structArray, $xmlrpcArray)); }
/** * Determines the current viewer can delete the revision * * @since 5.0 * @access public * @param string * @return */ public function canDelete($pk = null, $joins = null) { $user = JFactory::getUser(); // If this revision is being used as a post, it shouldn't be delete-able $post = EB::post($this->post_id); if ($post->revision_id == $this->id) { return false; } if ($this->created_by == $user->id) { return true; } if (EB::isSiteAdmin()) { return true; } return false; }
echo $tag; ?> </a></span> <?php } ?> </span> <?php } ?> </div> <div class="eb-table-toolbar btn-toolbar mt-15"> <div class="btn-group btn-group-sm"> <?php if ($this->acl->get('manage_pending') && $this->acl->get('add_entry') || EB::isSiteAdmin()) { ?> <a href="<?php echo $post->getEditLink(); ?> " class="btn btn-default" target="_blank" data-eb-composer> <?php echo JText::_('COM_EASYBLOG_DASHBOARD_PENDING_REVIEW_POST'); ?> </a> <?php echo $this->html('dashboard.action', 'COM_EASYBLOG_DASHBOARD_PENDING_APPROVE_POST', 'site/views/dashboard/confirmApproveBlog'); ?> <?php }
/** * Retrieves a list of blog posts by specific month * * @since 5.0 * @access public * @param string * @return */ public function getArchivePostByMonth($month = '', $year = '', $showPrivate = false) { $db = EB::db(); $user = JFactory::getUser(); $config = EB::config(); // used for privacy $queryWhere = ''; $queryExclude = ''; $queryExcludePending = ''; $excludeCats = array(); if ($user->id == 0) { $showPrivate = false; } // Blog privacy setting // @integrations: jomsocial privacy $privateBlog = ''; if (EB::easysocial()->exists() && $config->get('integrations_easysocial_privacy') && !EB::isSiteAdmin()) { $esPrivacyQuery = EB::easysocial()->buildPrivacyQuery('a'); $privateBlog .= $esPrivacyQuery; } else { if ($config->get('main_jomsocial_privacy') && EB::jomsocial()->exists() && !EB::isSiteAdmin()) { $friendsModel = CFactory::getModel('Friends'); $friends = $friendsModel->getFriendIds($user->id); // Insert query here. $privateBlog .= ' AND ('; $privateBlog .= ' (a.`access`= 0 ) OR'; $privateBlog .= ' ( (a.`access` = 20) AND (' . $db->Quote($user->id) . ' > 0 ) ) OR'; if (!$friends) { $privateBlog .= ' ( (a.`access` = 30) AND ( 1 = 2 ) ) OR'; } else { $privateBlog .= ' ( (a.`access` = 30) AND ( a.' . $db->nameQuote('created_by') . ' IN (' . implode(',', $friends) . ') ) ) OR'; } $privateBlog .= ' ( (a.`access` = 40) AND ( a.' . $db->nameQuote('created_by') . '=' . $user->id . ') )'; $privateBlog .= ' )'; } else { if ($user->id == 0) { $privateBlog .= ' AND a.`access` = ' . $db->Quote(0); } } } // Join the query ? $privateBlog = $showPrivate ? '' : $privateBlog; $isJSGrpPluginInstalled = false; $isJSGrpPluginInstalled = JPluginHelper::isEnabled('system', 'groupeasyblog'); $isEventPluginInstalled = JPluginHelper::isEnabled('system', 'eventeasyblog'); $isJSInstalled = false; // need to check if the site installed jomsocial. if (EB::jomsocial()->exists()) { $isJSInstalled = true; } $includeJSGrp = $isJSGrpPluginInstalled && $isJSInstalled ? true : false; $includeJSEvent = $isEventPluginInstalled && $isJSInstalled ? true : false; // contribution type sql $contributor = EB::contributor(); $contributeSQL = ' AND ( (a.`source_type` = ' . $db->Quote(EASYBLOG_POST_SOURCE_SITEWIDE) . ') '; if ($config->get('main_includeteamblogpost')) { $contributeSQL .= $contributor::genAccessSQL(EASYBLOG_POST_SOURCE_TEAM, 'a'); } if ($includeJSEvent) { $contributeSQL .= $contributor::genAccessSQL(EASYBLOG_POST_SOURCE_JOMSOCIAL_EVENT, 'a'); } if ($includeJSGrp) { $contributeSQL .= $contributor::genAccessSQL(EASYBLOG_POST_SOURCE_JOMSOCIAL_GROUP, 'a'); } if (EB::easysocial()->exists()) { $contributeSQL .= $contributor::genAccessSQL(EASYBLOG_POST_SOURCE_EASYSOCIAL_GROUP, 'a'); $contributeSQL .= $contributor::genAccessSQL(EASYBLOG_POST_SOURCE_EASYSOCIAL_EVENT, 'a'); } $contributeSQL .= ')'; $queryWhere .= $contributeSQL; //get teamblogs id. $query = ''; $extraSQL = ''; // If this is on blogger mode, we need to only pick items from the blogger. $blogger = EBR::isBloggerMode(); if ($blogger !== false) { $extraSQL = ' AND a.`created_by` = ' . $db->Quote($blogger); } $tzoffset = EB::date()->getOffSet(true); $query = 'SELECT a.*, DAY( DATE_ADD(a.`created`, INTERVAL ' . $tzoffset . ' HOUR) ) AS day,'; $query .= ' MONTH( DATE_ADD(a.`created`, INTERVAL ' . $tzoffset . ' HOUR) ) AS month,'; $query .= ' YEAR( DATE_ADD(a.`created`, INTERVAL ' . $tzoffset . ' HOUR) ) AS year '; $query .= ' FROM ' . $db->nameQuote('#__easyblog_post') . ' as a'; $query .= ' WHERE a.`published` = ' . $db->Quote(EASYBLOG_POST_PUBLISHED) . ' '; $query .= ' AND a.' . $db->quoteName('state') . ' = ' . $db->Quote(EASYBLOG_POST_NORMAL) . ' '; $query .= $privateBlog . ' '; $query .= ' AND (a.`created` > ' . $db->Quote($year . '-' . $month . '-01 00:00:00') . ' AND a.`created` < ' . $db->Quote($year . '-' . $month . '-31 23:59:59') . ') '; // If do not display private posts, we need to append additional queries here. if (!$showPrivate) { // sql for category access $catLib = EB::category(); $catAccessSQL = $catLib->genAccessSQL('a.`id`'); $query .= ' AND (' . $catAccessSQL . ')'; } $query .= $extraSQL . ' '; $query .= $queryWhere; $query .= ' ORDER BY a.`created` ASC '; // echo $query;exit; $db->setQuery($query); $result = $db->loadObjectList(); $postCount = new EasyblogCalendarObject($month, $year); if (!empty($result)) { foreach ($result as $row) { $post = EB::post($row->id); // $post->bind($row); $post = EB::formatter('entry', $post); // var_dump($row);exit; if ($postCount->{$year}->{$month}->{$row->day} == 0) { $postCount->{$year}->{$month}->{$row->day} = array($post); } else { array_push($postCount->{$year}->{$month}->{$row->day}, $post); } } } return $postCount; }
/** * Main display for the blog entry view * * @since 4.0 * @access public * @param string * @return */ public function preview($tpl = null) { // Get the blog post id from the request $id = $this->input->get('uid', '', 'default'); // Load the blog post now $post = EB::post($id); // After the post is loaded, set it into the cache EB::cache()->insert(array($post)); // If blog id is not provided correctly, throw a 404 error page if (!$id || !$post->id) { return JError::raiseError(404, JText::_('COM_EASYBLOG_ENTRY_BLOG_NOT_FOUND')); } // If the settings requires the user to be logged in, do not allow guests here. $post->requiresLoginToRead(); // Render necessary data on the headers $post->renderHeaders(); // Check if blog is password protected. $protected = $this->isProtected($post); if ($protected !== false) { return; } // Perform validation checks to see if post is valid $exception = $post->checkView(); if ($exception instanceof EasyBlogException) { return JError::raiseError(400, $exception->getMessage()); } // If the viewer is the owner of the blog post, display a proper message if ($this->my->id == $post->created_by && !$post->isPublished()) { $notice = JText::_('COM_EASYBLOG_ENTRY_BLOG_UNPUBLISHED_VISIBLE_TO_OWNER'); } if (EB::isSiteAdmin() && !$post->isPublished()) { $notice = JText::_('COM_EASYBLOG_ENTRY_BLOG_UNPUBLISHED_VISIBLE_TO_ADMIN'); } // Format the post $post = EB::formatter('entry', $post); // Add bloggers breadcrumbs if (!EBR::isCurrentActiveMenu('blogger', $post->author->id) && $this->config->get('layout_blogger_breadcrumb')) { $this->setPathway($post->author->getName(), $post->author->getPermalink()); } // Add entry breadcrumb if (!EBR::isCurrentActiveMenu('entry', $post->id)) { $this->setPathway($post->title, ''); } // Load up the blog model $model = EB::model('Blog'); // Get author's recent posts. $recent = $this->getRecentPosts($post); // Add canonical URLs for the blog post if ($this->config->get('main_canonical_entry')) { $this->canonical('index.php?option=com_easyblog&view=entry&id=' . $post->id); } // Prepare navigation object $navigation = $this->prepareNavigation($post); // Retrieve Google Adsense codes $adsense = EB::adsense()->html($post); // If a custom theme is setup for entries in the category, set a different theme if (!empty($post->category->theme)) { $this->setTheme($post->category->theme); } // Check if the user subscribed to this post. $isBlogSubscribed = $model->isBlogSubscribedEmail($post->id, $this->my->email); $theme = EB::template(); // Prepare related post $relatedPosts = array(); // @TODO: Related posts seems to be missing from the theme file. if ($theme->params->get('post_related', true)) { $relatedPosts = $model->getRelatedPosts($post->id, $theme->params->get('post_related_limit', 5)); } if (!$post->posttype) { $post->posttype = 'standard'; } $this->set('post', $post); $this->set('navigation', $navigation); $this->set('relatedPosts', $relatedPosts); $this->set('recent', $recent); $this->set('preview', true); $this->set('adsense', $adsense); $this->set('isBlogSubscribed', $isBlogSubscribed); // Get the menu params associated with this post $params = $post->getMenuParams(); $this->theme->entryParams = $params; parent::display('blogs/entry/default'); }
<?php echo JText::_('COM_EASYBLOG_CATEGORIES_NOT_ALLOWED'); ?> </div> <?php } ?> <?php if ($posts) { ?> <?php foreach ($posts as $post) { ?> <?php if (!EB::isSiteAdmin() && $this->config->get('main_password_protect') && !empty($post->blogpassword) && !$post->verifyPassword()) { ?> <?php echo $this->output('site/blogs/latest/default.protected', array('post' => $post)); ?> <?php } else { ?> <?php echo $this->output('site/blogs/latest/default.main', array('post' => $post)); ?> <?php } ?> <?php }
<li> <a href="<?php echo EB::_('index.php?option=com_easyblog&view=subscription'); ?> "> <i class="fa fa-envelope"></i> <?php echo JText::_('COM_EASYBLOG_TOOLBAR_MANAGE_SUBSCRIPTIONS'); ?> </a> </li> <?php } ?> <?php if ((EB::isTeamAdmin() || EB::isSiteAdmin()) && $this->config->get('toolbar_teamrequest')) { ?> <li> <a href="<?php echo EBR::_('index.php?option=com_easyblog&view=dashboard&layout=requests'); ?> "> <i class="fa fa-users"></i> <?php echo JText::_('COM_EASYBLOG_TOOLBAR_TEAM_REQUESTS'); ?> </a> </li> <?php } ?>
/** * Use explicitly on dashboard view only. * * @since 4.0 * @access public * @param string * @return */ public function getDashboardToolbar() { // Get total pending blog posts $model = EB::model('Blogs'); $total = $model->getTotalPending(); $totalTeamRequest = 0; // Get total team requests to join team. if (EB::isTeamAdmin()) { $teamModel = EB::model('TeamBlogs'); $totalTeamRequest = $teamModel->getTotalRequest(); } // Get the logout link $logoutActionLink = 'index.php?option=com_users&task=user.logout'; // @task: Determine if the current user is a blogger or not. $isBlogger = EB::isSiteAdmin() || $this->acl->get('add_entry'); // Get the logout return url $itemId = EB::router()->getItemid('latest'); $logoutReturn = base64_encode(EB::_('index.php?option=com_easyblog&view=latest&Itemid=' . $itemId, false)); // Get the current active layout $layout = $this->input->get('layout', '', 'cmd'); // Get the current user $user = EB::user(JFactory::getUser()->id); // Get the template $theme = EB::template(); $theme->set('current', $this->getLayout()); $theme->set('isBlogger', $isBlogger); $theme->set('totalPending', $total); $theme->set('user', $user); $theme->set('logoutURL', $logoutReturn); $theme->set('logoutActionLink', $logoutActionLink); $theme->set('totalTeamRequest', $totalTeamRequest); $output = $theme->output('site/dashboard/toolbar/default'); return $output; }
/** * Displays a list of blog posts on the site filtered by a category. * * @since 4.0 * @access public * @param string * @return */ public function listings() { // Retrieve sorting options $sort = $this->input->get('sort', $this->config->get('layout_postorder'), 'cmd'); $id = $this->input->get('id', 0, 'int'); // Try to load the category $category = EB::table('Category'); $category->load($id); // If the category isn't found on the site throw an error. if (!$id || !$category->id) { return JError::raiseError(404, JText::_('COM_EASYBLOG_CATEGORY_NOT_FOUND')); } // Set the meta description for the category EB::setMeta($category->id, META_TYPE_CATEGORY); // Set a canonical link for the category page. $this->canonical($category->getExternalPermalink()); // Get the privacy $privacy = $category->checkPrivacy(); if ($privacy->allowed || EB::isSiteAdmin() || !$this->my->guest && $this->config->get('main_allowguestsubscribe')) { $this->doc->addHeadLink($category->getRSS(), 'alternate', 'rel', array('type' => 'application/rss+xml', 'title' => 'RSS 2.0')); $this->doc->addHeadLink($category->getAtom(), 'alternate', 'rel', array('type' => 'application/atom+xml', 'title' => 'Atom 1.0')); } // Set views breadcrumbs $this->setViewBreadcrumb($this->getName()); // Set the breadcrumb for this category if (!EBR::isCurrentActiveMenu('categories', $category->id)) { // Always add the final pathway to the category title. $this->setPathway($category->title, ''); } //get the nested categories $category->childs = null; // Build nested childsets EB::buildNestedCategories($category->id, $category, false, true); // Parameterize initial subcategories to display. Ability to configure from backend. $nestedLinks = ''; $initialLimit = $this->app->getCfg('list_limit') == 0 ? 5 : $this->app->getCfg('list_limit'); if (count($category->childs) > $initialLimit) { $initialNestedLinks = ''; $initialRow = new stdClass(); $initialRow->childs = array_slice($category->childs, 0, $initialLimit); EB::accessNestedCategories($initialRow, $initialNestedLinks, '0', '', 'link', ', '); $moreNestedLinks = ''; $moreRow = new stdClass(); $moreRow->childs = array_slice($category->childs, $initialLimit); EB::accessNestedCategories($moreRow, $moreNestedLinks, '0', '', 'link', ', '); // Hide more nested links until triggered $nestedLinks .= $initialNestedLinks; $nestedLinks .= '<span class="more-subcategories-toggle" data-more-categories-link> ' . JText::_('COM_EASYBLOG_AND') . ' <a href="javascript:void(0);">' . JText::sprintf('COM_EASYBLOG_OTHER_SUBCATEGORIES', count($category->childs) - $initialLimit) . '</a></span>'; $nestedLinks .= '<span class="more-subcategories" style="display: none;" data-more-categories>, ' . $moreNestedLinks . '</span>'; } else { EB::accessNestedCategories($category, $nestedLinks, '0', '', 'link', ', '); } $catIds = array(); $catIds[] = $category->id; EB::accessNestedCategoriesId($category, $catIds); $category->nestedLink = $nestedLinks; // Get the category model $model = EB::model('Category'); // Get total posts in this category $category->cnt = $model->getTotalPostCount($category->id); // Get teamblog posts count // $teamBlogCount = $model->getTeamBlogCount($category->id); $limit = EB::call('Pagination', 'getLimit', array(EBLOG_PAGINATION_CATEGORIES)); // Get the posts in the category $data = $model->getPosts($catIds, $limit); // Get the pagination $pagination = $model->getPagination(); // Get allowed categories $allowCat = $model->allowAclCategory($category->id); // Format the data that we need $posts = array(); // Ensure that the user is really allowed to view the blogs if (!empty($data)) { $posts = EB::formatter('list', $data); } // Check isCategorySubscribed $isCategorySubscribed = $model->isCategorySubscribedEmail($category->id, $this->my->email); // If this category has a different theme, we need to output it differently if (!empty($category->theme)) { $this->setTheme($category->theme); } // Set the page title $title = EB::getPageTitle(JText::_($category->title)); $this->setPageTitle($title, $pagination, $this->config->get('main_pagetitle_autoappend')); // Set the return url $return = base64_encode($category->getExternalPermalink()); // Get the pagination $pagination = $pagination->getPagesLinks(); $this->set('allowCat', $allowCat); $this->set('category', $category); $this->set('sort', $sort); $this->set('posts', $posts); $this->set('return', $return); $this->set('pagination', $pagination); // $this->set('teamBlogCount', $teamBlogCount); $this->set('privacy', $privacy); $this->set('isCategorySubscribed', $isCategorySubscribed); parent::display('blogs/categories/item'); }
<li> <a href="<?php echo $post->getEditLink(); ?> "> <?php echo JText::_('COM_EASYBLOG_EDIT'); ?> </a> </li> <?php } ?> <?php if ($this->acl->get('delete_entry') || EB::isSiteAdmin()) { ?> <li> <a href="javascript:void(0);" data-post-delete> <?php echo JText::_('COM_EASYBLOG_DASHBOARD_DRAFTS_DISCARD'); ?> </a> </li> <?php } ?> <li> <a target="_blank" href="<?php echo EB::_('index.php?option=com_easyblog&view=entry&layout=preview&draftid=' . $post->id);
</li> <?php } ?> <?php if (($post->isPublished() || $post->isUnpublished()) && ($this->acl->get('publish_entry') || EB::isSiteAdmin())) { ?> <li class="divider"></li> <?php } ?> <?php if (!$post->locked && $this->acl->get('add_entry') || EB::isSiteAdmin()) { ?> <li> <a href="<?php echo $post->getEditLink(); ?> " target="_blank" data-eb-composer> <?php echo JText::_('COM_EASYBLOG_EDIT'); ?> </a> </li> <?php } ?>
/** * Renders a list of articles for media manager * * @since 5.0 * @access public * @param string * @return */ public static function renderPosts() { $posts = array(); $model = EB::model('Dashboard'); $userId = EB::user()->id; // If the user is an admin, list down all blog posts created on the site if (EB::isSiteAdmin()) { $userId = null; } $posts = $model->getEntries($userId, array('state' => EASYBLOG_POST_PUBLISHED)); $template = EB::template(); $template->set('posts', $posts); $html = $template->output('site/mediamanager/posts'); return $html; }
/** * Determines if the current post is protected * * @since 4.0 * @access public * @param string * @return */ public function isProtected(EasyBlogPost &$blog) { // Password protection disabled if (!$this->config->get('main_password_protect')) { return false; } // Site admin should not be restricted if (EB::isSiteAdmin()) { return false; } // Blog does not contain any password protection if (empty($blog->blogpassword)) { return false; } // User already entered password if ($blog->verifyPassword()) { return false; } // Set the return url to the current url $return = base64_encode(JRequest::getURI()); $category = $blog->getPrimaryCategory(); $blog->category = $category; $blog->categories = $blog->getCategories(); // Get the blogger object $blogger = EB::user($blog->created_by); // Set the author object into the table. $blog->author = $blogger; $this->set('blogger', $blog->author); $this->set('return', $return); $this->set('blog', $blog); $this->set('category', $category); parent::display('blogs/entry/default.protected'); return; }