public function __construct() { parent::__construct(); // Test if the user is already associated with Flickr $this->oauth = EB::table('OAuth'); $this->oauth->loadByUser($this->my->id, EBLOG_OAUTH_FLICKR); }
/** * Generates the captcha image * * @since 4.0 * @access public * @param string * @return */ public function generate() { $id = $this->input->get('id', '', 'int'); // Load up the captcha object $captcha = EB::table('Captcha'); // Clear outdated keys $captcha->clear(); // load the captcha records. $captcha->load($id); if (!$captcha->id) { return false; } // @task: Generate a very random integer and take only 5 chars max. $hash = JString::substr(md5(rand(0, 9999)), 0, 5); $captcha->response = $hash; $captcha->store(); // Captcha width and height $width = 100; $height = 20; $image = ImageCreate($width, $height); $white = ImageColorAllocate($image, 255, 255, 255); $black = ImageColorAllocate($image, 0, 0, 0); $gray = ImageColorAllocate($image, 204, 204, 204); ImageFill($image, 0, 0, $white); ImageString($image, 5, 30, 3, $hash, $black); ImageRectangle($image, 0, 0, $width - 1, $height - 1, $gray); imageline($image, 0, $height / 2, $width, $height / 2, $gray); imageline($image, $width / 2, 0, $width / 2, $height, $gray); header('Content-type: image/jpeg'); ImageJpeg($image); ImageDestroy($image); exit; }
/** 1.5 **/ public function onSearch($text, $phrase = '', $ordering = '', $areas = null) { $plugin = JPluginHelper::getPlugin('search', 'easyblog'); $params = EB::registry($plugin->params); if (!plgSearchEasyblog::exists()) { return array(); } if (is_array($areas)) { if (!array_intersect($areas, array_keys(plgSearchEasyblog::onContentSearchAreas()))) { return array(); } } $text = trim($text); if ($text == '') { return array(); } $result = plgSearchEasyblog::getResult($text, $phrase, $ordering); if (!$result) { return array(); } // require_once( EBLOG_HELPERS . DIRECTORY_SEPARATOR . 'router.php' ); foreach ($result as $row) { $row->section = plgSearchEasyblog::getCategory($row->category_id); $row->section = JText::sprintf('PLG_EASYBLOG_SEARCH_BLOGS_SECTION', $row->section); $row->href = EBR::_('index.php?option=com_easyblog&view=entry&id=' . $row->id); $blog = EB::table('Blog'); $blog->bind($row); if ($blog->getImage()) { $row->image = $blog->getImage('frontpage'); } } return $result; }
public function reportBlog() { $app = JFactory::getApplication(); // Get the composite keys $log_user = $this->plugin->get('user')->id; $id = $app->input->get('id', 0, 'int'); $type = $app->input->get('type', '', 'POST'); $reason = $app->input->get('reason', '', 'STRING'); if (!$reason) { $message = "Reason is empty"; $final_result['message'] = $message; $final_result['status'] = false; return $final_result; } $report = EB::table('Report'); $report->obj_id = $id; $report->obj_type = $type; $report->reason = $reason; $report->created = EB::date()->toSql(); $report->created_by = $log_user; $state = $report->store(); if (!$state) { $message = "Cant store your report"; $final_result['message'] = $message; $final_result['status'] = false; return $final_result; } // Notify the site admin when there's a new report made $post = EB::post($id); $report->notify($post); $final_result['message'] = "Report logged successfully!"; $final_result['status'] = true; return $final_result; }
/** * Displays the team blog form * * @since 4.0 * @access public * @param string * @return */ public function form() { // Try to load the team object $id = $this->input->get('id', 0, 'int'); // Try to load up the team blog $team = EB::table('TeamBlog'); $team->load($id); if ($id) { $this->setHeading('COM_EASYBLOG_EDITING_TEAMBLOG', '', 'fa-users'); } else { $this->setHeading('COM_EASYBLOG_TEAMBLOGS_CREATE_TITLE', '', 'fa-users'); } $blogAccess = array(); $blogAccess[] = JHTML::_('select.option', '1', JText::_('COM_EASYBLOG_TEAM_MEMBER_ONLY')); $blogAccess[] = JHTML::_('select.option', '2', JText::_('COM_EASYBLOG_ALL_REGISTERED_USERS')); $blogAccess[] = JHTML::_('select.option', '3', JText::_('COM_EASYBLOG_EVERYONE')); $blogAccessList = JHTML::_('select.genericlist', $blogAccess, 'access', ' class="form-control"', 'value', 'text', $team->access); // Get the editor $editor = JFactory::getEditor(); // get meta tags $metaModel = EB::model('Metas'); $meta = $metaModel->getMetaInfo(META_TYPE_TEAM, $id); // Get a list of team members $members = $team->getMembers(); // Get the groups associated with this team $groups = $team->getGroups(); $this->set('groups', $groups); $this->set('members', $members); $this->set('editor', $editor); $this->set('team', $team); $this->set('meta', $meta); $this->set('blogAccess', $blogAccessList); parent::display('teamblogs/form'); }
public function __construct($id, $type) { parent::__construct($id, $type); $team = EB::table('TeamBlog'); $team->load($id); $this->team = $team; }
/** * Removes a subscriber from the list * * @since 5.0 * @access public * @param string * @return */ public function remove() { // Check for request forgeries EB::checkToken(); // @task: Check for acl rules. $this->checkAccess('subscription'); $ids = $this->input->get('cid', array(), 'array'); $filter = $this->input->get('filter', '', 'cmd'); if (!$filter) { $this->info->set('COM_EASYBLOG_ERROR_REMOVING_SUBSCRIPTION_MISSING_SUBSCRIPTION_TYPE', 'error'); return $this->app->redirect('index.php?option=com_easyblog&view=subscriptions'); } if (!$filter) { $this->info->set('COM_EASYBLOG_INVALID_SUBSCRIPTION_ID', 'error'); return $this->app->redirect('index.php?option=com_easyblog&view=subscriptions'); } foreach ($ids as $id) { $id = (int) $id; if (!$id) { continue; } $table = EB::table('Subscriptions'); $table->load((int) $id); $table->delete(); } $this->info->set('COM_EASYBLOG_SUBSCRIPTION_DELETED', 'success'); return $this->app->redirect('index.php?option=com_easyblog&view=subscriptions'); }
/** * Auto post to social network sites * * @since 5.0 * @access public * @param string * @return */ public function shareSystem(EasyBlogPost &$post, $force = false) { // Determines if the primary category of this post requires auto posting or not $category = $post->getPrimaryCategory(); if (!$category->autopost) { return; } // Get a list of system oauth clients. $model = EB::model('Oauth'); $clients = $model->getSystemClients(); foreach ($clients as $client) { // If this is a new post, ensure that it respects the settings before auto posting if ($post->isNew() && !$this->config->get('integrations_' . $client->type . '_centralized_auto_post') && !$force) { continue; } // If the post is updated, ensure that it respects the settings before auto posting if (!$post->isNew() && !$this->config->get('integrations_' . $client->type . '_centralized_send_updates') && !$force) { continue; } $table = EB::table('OAuth'); $table->bind($client); // Push the item now $table->push($post); } }
/** * Displays a list of reports * * @since 4.0 * @access public * @param string * @return */ public function display($tpl = null) { // Test for user access if on 1.6 and above $this->checkAccess('easyblog.manage.report'); $this->setHeading('COM_EASYBLOG_TITLE_REPORTS', '', 'fa-exclamation-triangle'); $order = $this->app->getUserStateFromRequest('com_easyblog.reports.filter_order', 'filter_order', 'a.created', 'cmd'); $orderDirection = $this->app->getUserStateFromRequest('com_easyblog.reports.filter_order_Dir', 'filter_order_Dir', 'asc', 'word'); // Get reports $model = EB::model('Reports'); $result = $model->getData(); $pagination = $model->getPagination(); $reports = array(); if ($result) { foreach ($result as $row) { $report = EB::table('Report'); $report->bind($row); $blog = EB::table('Blog'); $blog->load($report->obj_id); $report->blog = $blog; $reports[] = $report; } } $this->set('pagination', $pagination); $this->set('reports', $reports); $this->set('order', $order); $this->set('orderDirection', $orderDirection); parent::display('reports/default'); }
/** * Synchronizes database tables * * @since 4.0 * @access public * @param string * @return */ public function execute() { // Load foundry $this->engine(); // Get this installation version $version = $this->getInstalledVersion(); // Get previous version installed $previous = $this->getPreviousVersion('dbversion'); $affected = ''; if ($previous !== false) { // lets run the db scripts sync if needed. $db = EB::db(); $affected = $db->sync($previous); } // Update the version in the database to the latest now $config = EB::table('Configs'); $config->load(array('name' => 'dbversion')); $config->name = 'dbversion'; $config->params = $version; // Save the configuration $config->store($config->name); // If the previous version is empty, we can skip this altogether as we know this is a fresh installation if (!empty($affected)) { $this->setInfo(JText::sprintf('COM_EASYBLOG_INSTALLATION_MAINTENANCE_DB_SYNCED', $version)); } else { $this->setInfo(JText::sprintf('COM_EASYBLOG_INSTALLATION_MAINTENANCE_DB_NOTHING_TO_SYNC', $version)); } return $this->output(); }
/** * Toggles the publishing state of a block * * @since 4.0 * @access public * @param string * @return */ public function togglePublish() { // Check for request forgeries EB::checkToken(); // Default redirection url $redirect = 'index.php?option=com_easyblog&view=blocks'; // Get the items to be published / unpublished $ids = $this->input->get('cid', array(), 'array'); if (!$ids) { $this->info->set('COM_EASYBLOG_BLOCKS_INVALID_ID_PROVIDED', 'error'); return $this->app->redirect($redirect); } // Get the current task $task = $this->getTask(); foreach ($ids as $id) { $block = EB::table('Block'); $block->load((int) $id); $block->{$task}(); } $message = 'COM_EASYBLOG_BLOCKS_PUBLISHED_SUCCESSFULLY'; if ($task == 'unpublish') { $message = 'COM_EASYBLOG_BLOCKS_UNPUBLISHED_SUCCESSFULLY'; } $this->info->set(JText::_($message)); return $this->app->redirect($redirect); }
function checkIfSent($blogId) { $posts = EB::table('TwitterPosts'); $posts->load($blogId); if (empty($posts->id)) { return false; } return true; }
/** * Default feed display method * * @since 5.0 * @access public * @param string * @return */ public function display($tmpl = null) { // Ensure that rss is enabled if (!$this->config->get('main_rss')) { return JError::raiseError(404, JText::_('COM_EASYBLOG_FEEDS_DISABLED')); } $id = $this->input->get('id', '', 'cmd'); $category = EB::table('Category'); $category->load($id); // Private category shouldn't allow to access. $privacy = $category->checkPrivacy(); if (!$privacy->allowed) { return JError::raiseError(500, JText::_('COM_EASYBLOG_NOT_ALLOWED_HERE')); } // Get the nested categories $category->childs = null; EB::buildNestedCategories($category->id, $category); $linkage = ''; EB::accessNestedCategories($category, $linkage, '0', '', 'link', ', '); $catIds = array(); $catIds[] = $category->id; EB::accessNestedCategoriesId($category, $catIds); $category->nestedLink = $linkage; $model = EB::model('Blog'); $sort = $this->input->get('sort', $this->config->get('layout_postorder'), 'cmd'); $posts = $model->getBlogsBy('category', $catIds, $sort); $posts = EB::formatter('list', $posts); $this->doc->link = EBR::_('index.php?option=com_easyblog&view=categories&id=' . $id . '&layout=listings'); $this->doc->setTitle($this->escape($category->getTitle())); $this->doc->setDescription(JText::sprintf('COM_EASYBLOG_FEEDS_CATEGORY_DESC', $this->escape($category->getTitle()))); if (!$posts) { return; } $uri = JURI::getInstance(); $scheme = $uri->toString(array('scheme')); $scheme = str_replace('://', ':', $scheme); foreach ($posts as $post) { $image = ''; if ($post->hasImage()) { $image = '<img src="' . $post->getImage('medium', true, true) . '" width="250" align="left" />'; } $item = new JFeedItem(); $item->title = $this->escape($post->title); $item->link = $post->getPermalink(); $item->description = $image . $post->getIntro(); // replace the image source to proper format so that feed reader can view the image correctly. $item->description = str_replace('src="//', 'src="' . $scheme . '//', $item->description); $item->description = str_replace('href="//', 'href="' . $scheme . '//', $item->description); $item->date = $post->getCreationDate()->toSql(); $item->category = $post->getPrimaryCategory()->getTitle(); $item->author = $post->author->getName(); $item->authorEmail = $this->getRssEmail($post->author); $this->doc->addItem($item); } // exit; }
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; }
/** * Save assets * * @since 4.0 * @access public * @param string * @return */ public function saveAsset($blogId, $key, $value) { // Load up the assets object $assets = EB::table('assets'); $assets->post_id = $blogId; $assets->key = $key; $assets->value = $value; $assets->store(); return true; }
/** * Displays blog listings by specific tags on the site * * @since 4.0 * @access public * @param string * @return */ public function tag() { // Get the tag id $id = $this->input->get('id', '', 'default'); // Add noindex for tags listing by default $this->doc->setMetadata('robots', 'noindex,follow'); // Load the tag object $tag = EB::table('Tag'); $tag->load($id); // The tag could be a permalink if (!$tag->id) { $tag->load($id, true); } // Set page title $this->setPageTitle($tag->getTitle(), '', $this->config->get('main_pagetitle_autoappend')); // set meta tags for tags view EB::setMeta(META_ID_TAGS, META_TYPE_VIEW, $tag->getTitle() . ' - ' . EB::getPageTitle($this->config->get('main_title'))); // Set breadcrumb if (!EBR::isCurrentActiveMenu('tags')) { $this->setPathway(JText::_('COM_EASYBLOG_TAGS_BREADCRUMB'), EBR::_('index.php?option=com_easyblog&view=tags')); } $this->setPathway($tag->getTitle()); // Get the blogs model $blogModel = EB::model('Blog'); $tagModel = EB::model('Tags'); // Get the blog posts now $rows = $blogModel->getTaggedBlogs($tag->id, false, ''); // Get the pagination $pagination = $blogModel->getPagination(); if (is_object($pagination) && method_exists($pagination, 'setAdditionalUrlParam')) { $pagination->setAdditionalUrlParam('id', $tag->alias); } // Get total number of private blog posts $privateCount = 0; // Get total number of team blog count $teamblogCount = 0; if ($this->my->guest) { $privateCount = $tagModel->getTagPrivateBlogCount($id); } // Determines if we should get the team blog count if (!$this->config->get('main_includeteamblogpost')) { $teamblogCount = $tagModel->getTeamBlogCount($id); } // Format the blog posts using the standard list formatter $posts = EB::formatter('list', $rows); $return = base64_encode($tag->getPermalink()); $this->set('return', $return); $this->set('tag', $tag); $this->set('posts', $posts); $this->set('pagination', $pagination); $this->set('private', $privateCount); $this->set('team', $teamblogCount); parent::display('tags/item'); }
public function isAssociated($userId, $type) { //check if centralized, then use centralized. $config = EasyBlogHelper::getConfig(); $allowed = $config->get('integrations_' . strtolower($type) . '_centralized_and_own'); if (!$allowed) { return false; } $oauth = EB::table('Oauth'); return $oauth->loadByUser($userId, constant('EBLOG_OAUTH_' . strtoupper($type))); }
/** * Previews a mail * * @since 4.0 * @access public * @param string * @return */ public function preview() { // Check for acl rules. $this->checkAccess('mail'); // Get the mail id $id = $this->input->get('id', 0, 'int'); $mailq = EB::table('Mailqueue'); $mailq->load($id); echo $mailq->getBody(); exit; }
function display($tmpl = null) { if (!$this->config->get('main_rss')) { return; } $model = EB::model('Blog'); $data = $model->getFeaturedBlog(); $document = JFactory::getDocument(); $document->link = EBR::_('index.php?option=com_easyblog&view=featured'); $document->setTitle(JText::_('COM_EASYBLOG_FEEDS_FEATURED_TITLE')); $document->setDescription(JText::sprintf('COM_EASYBLOG_FEEDS_FEATURED_DESC', JURI::root())); if (empty($data)) { return; } $uri = JURI::getInstance(); $scheme = $uri->toString(array('scheme')); $scheme = str_replace('://', ':', $scheme); foreach ($data as $row) { $blog = EB::table('Blog'); $blog->load($row->id); $profile = EB::user($row->created_by); $created = EB::date($row->created); $row->created = $created->toSql(); if ($this->config->get('main_rss_content') == 'introtext') { $row->text = !empty($row->intro) ? $row->intro : $row->content; //read more for feed $row->text .= '<br /><a href=' . EBR::_('index.php?option=com_easyblog&view=entry&id=' . $row->id) . '>Read more</a>'; } else { $row->text = $row->intro . $row->content; } $row->text = EB::videos()->strip($row->text); $row->text = EB::adsense()->stripAdsenseCode($row->text); $category = EB::table('Category'); // Get primary category $primaryCategory = $blog->getPrimaryCategory(); $category->load($primaryCategory->id); // Assign to feed item $title = $this->escape($row->title); $title = html_entity_decode($title); // load individual item creator class $item = new JFeedItem(); $item->title = $title; $item->link = EBR::_('index.php?option=com_easyblog&view=entry&id=' . $row->id); $item->description = $row->text; // replace the image source to proper format so that feed reader can view the image correctly. $item->description = str_replace('src="//', 'src="' . $scheme . '//', $item->description); $item->description = str_replace('href="//', 'href="' . $scheme . '//', $item->description); $item->date = $row->created; $item->category = $category->getTitle(); $item->author = $profile->getName(); $item->authorEmail = $this->getRssEmail($profile); $document->addItem($item); } }
/** * Displays a list of blog posts from a specific team * * @since 4.0 * @access public * @param string * @return */ public function listings() { // Get the team id that is being accessed now $id = $this->input->get('id', 0, 'int'); $team = EB::table('TeamBlog'); $team->load($id); if (!$id || !$team->id) { return JError::raiseError(404, JText::_('COM_EASYBLOG_TEAMBLOG_INVALID_ID')); } // set meta tags for teamblog view EB::setMeta($id, META_TYPE_TEAM); $gid = EB::getUserGids(); $isMember = $team->isMember($this->my->id, $gid); $team->isMember = $isMember; $team->isActualMember = $team->isMember($this->my->id, $gid, false); // Add rss feed link if ($team->access == EBLOG_TEAMBLOG_ACCESS_EVERYONE || $team->isMember) { $this->doc->addHeadLink($team->getRSS(), 'alternate', 'rel', array('type' => 'application/rss+xml', 'title' => 'RSS 2.0')); $this->doc->addHeadLink($team->getAtom(), 'alternate', 'rel', array('type' => 'application/atom+xml', 'title' => 'Atom 1.0')); } // 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'); } // Set the breadcrumbs for this view $this->setViewBreadcrumb('teamblog'); $this->setPathway($team->getTitle()); $limit = EB::call('Pagination', 'getLimit', array(EBLOG_PAGINATION_TEAMBLOGS)); // Retrieve the model $model = EB::model('TeamBlogs'); $posts = $model->getPosts($team->id, $limit); $posts = EB::formatter('list', $posts); // Get the pagination $pagination = $model->getPagination(); // Retrieve team's information $members = $model->getTeamMembers($team->id); // Determines if the team blog is featured $team->isFeatured = EB::isFeatured('teamblog', $team->id); // Set the page title $title = EB::getPageTitle($team->title); $this->setPageTitle($title, $pagination, $this->config->get('main_pagetitle_autoappend')); // Check if subscribed $isTeamSubscribed = $model->isTeamSubscribedEmail($team->id, $this->my->email); // Get the current url $return = $team->getPermalink(); $this->set('return', $return); $this->set('team', $team); $this->set('members', $members); $this->set('pagination', $pagination->getPagesLinks()); $this->set('posts', $posts); $this->set('isTeamSubscribed', $isTeamSubscribed); parent::display('teamblogs/item'); }
public function getReloadScript($ajax, $post) { JTable::addIncludePath(EBLOG_TABLES); if (isset($post['captcha-id'])) { $ref = EB::table('Captcha'); $state = $ref->load($post['captcha-id']); if ($state) { $ref->delete(); } } return 'eblog.captcha.reload();'; }
/** * Saves an acl * * @since 5.0 * @access public * @param string * @return */ public function save() { // Check for request forgeries EB::checkToken(); // @task: Check for acl rules. $this->checkAccess('acl'); // get current task name. $task = $this->getTask(); $id = $this->input->get('id', 0, 'int'); $name = $this->input->get('name', '', 'cmd'); // Ensure that the composite keys are provided. if (empty($id)) { $this->info->set('COM_EASYBLOG_ACL_INVALID_ID_ERROR', 'error'); return $this->app->redirect('index.php?option=com_easyblog&view=acls&layout=form&id=' . $id); } // Get the data from the post $data = $this->input->getArray('post'); // Get the text filters first. $filter = EB::table('ACLFilter'); $state = $filter->load($id); if (!$state) { $filter->content_id = $id; $filter->type = 'group'; } // Set the disallowed tags $filter->disallow_tags = $data['disallow_tags']; $filter->disallow_attributes = $data['disallow_attributes']; $filter->store(); // Load the acl model $model = EB::model('ACL'); // Delete all existing rule set $state = $model->deleteRuleset($id); // Unset unecessary data form the post unset($data['task']); unset($data['option']); unset($data['c']); unset($data['id']); unset($data['name']); unset($data['disallow_tags']); unset($data['disallow_attributes']); // Insert new rules $state = $model->insertRuleset($id, $data); if (!$state) { $this->info->set('COM_EASYBLOG_ACL_ERROR_SAVING_ACL', 'error'); return $this->app->redirect('index.php?option=com_easyblog&view=acls&layout=form&id=' . $id); } $url = 'index.php?option=com_easyblog&view=acls'; if ($task == 'apply') { $url = 'index.php?option=com_easyblog&view=acls&layout=form&id=' . $id; } $this->info->set('COM_EASYBLOG_ACL_SAVE_SUCCESS', 'success'); return $this->app->redirect($url); }
/** * Renders the blog template * * @since 5.0 * @access public * @param string * @return */ public function renderTemplate() { $uid = $this->input->get('uid', 0, 'int'); $postTemplate = EB::table('PostTemplate'); $postTemplate->load($uid); if (!$postTemplate->data) { return $this->ajax->resolve(); } $document = $postTemplate->getDocument(); $content = $document->getEditableContent(); return $this->ajax->resolve($document->title, $document->permalink, $content); }
/** * 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; }
/** * Set the next run time for remote publishing * * @since 4.0 * @access public * @param string * @return */ private function setNextRunTime() { $interval = (int) $this->config->get('main_remotepublishing_mailbox_run_interval'); $nextrun = EB::date('+' . $interval . ' minutes'); // Save the next run time // use $configTable to avoid variable name conflict $table = EB::table('configs'); $table->load('config'); $params = new JRegistry($table->params); $params->set('main_remotepublishing_mailbox_next_run', $nextrun->toUnix()); $table->params = $params->toString('ini'); $table->store(); }
public function getParams($name = '', $contents = '', $manifestFile, $xpath = false) { $this->form = new JForm($name); if ($xpath == 'params') { $xpath = 'config/fields'; } $this->form->loadFile($manifestFile, true, $xpath); $config = EB::table('Configs'); $config->load($name); $params = new JRegistry($config->params); $registry = EB::registry($contents); $this->form->bind($registry->toArray()); }
/** * Previews an email * * @since 5.0 * @access public * @param string * @return */ public function preview() { $id = $this->input->get('id', 0, 'int'); if (!$id) { return $this->ajax->reject(); } $mailq = EB::table('Mailqueue'); $mailq->load($id); $url = JURI::root() . 'administrator/index.php?option=com_easyblog&view=spools&layout=preview&tmpl=component&id=' . $mailq->id; $theme = EB::template(); $theme->set('url', $url); $output = $theme->output('admin/spools/dialog.preview'); return $this->ajax->resolve($output); }
/** * Determines if the provided user is associated with the respective oauth client * * @since 4.0 * @access public * @param string * @return */ public function isUserAssociated($client, $userId = null) { $config = EB::config(); $allowed = $config->get('integrations_' . strtolower($client) . '_centralized_and_own'); if (!$allowed) { return false; } $allowed = $config->get('integrations_' . strtolower($client)); if (!$allowed) { return false; } $oauth = EB::table('OAuth'); $exists = $oauth->loadByUser($userId, constant('EBLOG_OAUTH_' . strtoupper($client))); return $exists; }
/** * Retrieve a custom field form * * @since 4.0 * @access public * @param string * @return */ public function getForm() { // Get the field id $id = $this->input->get('id', 0, 'int'); // Get the field type $type = $this->input->get('type', '', 'cmd'); if (!$type) { return $this->ajax->reject(); } $field = EB::table('Field'); $field->load($id); // Get the form $form = EB::fields()->get($type)->admin($field); return $this->ajax->resolve($form); }