/** * 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); }
/** * Make the provided theme a default theme for EasyBlog * * @since 4.0 * @access public */ public function setDefault() { // Check for request forgeries EB::checkToken(); // Check for acl rules. $this->checkAccess('theme'); $element = $this->input->get('cid', '', 'array'); $element = $element[0]; if (!$element || !isset($element[0])) { EB::info()->set(JText::_('COM_EASYBLOG_THEME_INVALID_THEME_PROVIDED'), 'error'); return $this->app->redirect('index.php?option=com_easyblog&view=themes'); } // Legacy codes and should be removed soon $this->config->set('layout_theme', $element); // Get the configuration object $this->config->set('theme_site', $element); $table = EB::table('Configs'); $table->load('config'); $table->params = $this->config->toString('INI'); $table->store(); // Clear the component's cache $cache = JFactory::getCache('com_easyblog'); $cache->clean(); EB::info()->set(JText::sprintf('COM_EASYBLOG_THEME_SET_AS_DEFAULT', $element), 'success'); $this->app->redirect('index.php?option=com_easyblog&view=themes'); }
public function reject() { // Check for request forgeries EB::checkToken(); // Ensure that user is logged in EB::requireLogin(); // Get any return url $return = EB::_('index.php?option=com_easyblog&view=dashboard&layout=moderate'); if ($this->getReturnURL()) { $return = $this->getReturnURL(); } // Check if the user is privileged enough if (!$this->acl->get('add_entry') && !$this->acl->get('manage_pending')) { return JError::raiseError(500, JText::_('COM_EASYBLOG_NO_PERMISSION_TO_MODERATE_BLOG')); } // Get a list of ids $ids = $this->input->get('ids', array(), 'array'); $message = $this->input->get('message', '', 'default'); foreach ($ids as $id) { $id = (int) $id; $post = EB::post($id); $post->reject($message); } $message = JText::_('COM_EASYBLOG_BLOGS_BLOG_SAVE_REJECTED'); $this->info->set($message, 'success'); return $this->app->redirect($return); }
/** * Search blogger * * @since 4.0 * @access public */ public function blogger() { // Check for request forgeries EB::checkToken(); // Get the query $search = $this->input->get('search', '', 'string'); $url = EB::_('index.php?option=com_easyblog&view=blogger&search=' . $search, false); return $this->app->redirect($url); }
/** * 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); }
/** * Approves a blog post * * @since 5.0 * @access public * @param string * @return */ public function approve() { // Check for request forgeries EB::checkToken(); // Check for acl $this->checkAccess('pending'); // Get a list of id's to approve $ids = $this->input->get('cid', array(), 'array'); foreach ($ids as $id) { $post = EB::post($id); $post->approve(); } $message = JText::_('COM_EASYBLOG_BLOGS_BLOG_SAVE_APPROVED'); $this->info->set($message, 'success'); $this->app->redirect('index.php?option=com_easyblog&view=blogs&layout=pending'); }
/** * Install language file on the site * * @since 4.0 * @access public * @param string * @return */ public function install() { // Check for request forgeries here EB::checkToken(); // Get the language id $ids = $this->input->get('cid', array(), 'array'); foreach ($ids as $id) { $table = EB::table('Language'); $table->load($id); $state = $table->install(); if (!$state) { EB::info()->set($table->getError(), 'error'); return $this->app->redirect('index.php?option=com_easyblog&view=languages'); } } EB::info()->set(JText::_('COM_EASYBLOG_LANGUAGE_INSTALLED_SUCCESSFULLY'), 'success'); $this->app->redirect('index.php?option=com_easyblog&view=languages'); }
public function setAsAdmin($teamId, $userId, $isAdmin) { // Check for request forgeries EB::checkToken(); // @task: Check for acl rules. $this->checkAccess('easyblog.manage.teamblog'); $db = EB::db(); $query = 'UPDATE `#__easyblog_team_users` SET '; if ($isAdmin) { $query .= ' `isadmin` = ' . $db->Quote('1'); } else { $query .= ' `isadmin` = ' . $db->Quote('0'); } $query .= ' WHERE `team_id` = ' . $db->Quote($teamId); $query .= ' AND `user_id` = ' . $db->Quote($userId); $db->setQuery($query); $db->query(); return true; }
/** * save post templates * * @since 4.0 * @access public * @param string * @return */ public function save() { // Check for request forgeries EB::checkToken(); $id = $this->input->get('id', '', 'int'); $template = EB::table('PostTemplate'); $template->load($id); $title = $this->input->get('title', '', 'default'); $content = $this->input->get('template_content', '', 'raw'); $data['content'] = $content; $template->title = $title; $template->data = json_encode($data); $template->user_id = $this->my->id; $template->created = EB::date()->toSql(); $template->store(); $this->info->set('COM_EASYBLOG_DASHBOARD_TEMPLATES_SAVED_SUCCESS', 'success'); $redirect = EB::_('index.php?option=com_easyblog&view=dashboard&layout=templates', false); return $this->app->redirect($redirect); }
/** * Deletes a mailer item * * @since 4.0 * @access public * @param string * @return */ public function remove() { // Check for request forgeries EB::checkToken(); // @task: Check for acl rules. $this->checkAccess('mail'); $mails = $this->input->get('cid', array(), 'array'); if (!$mails) { $message = JText::_('COM_EASYBLOG_NO_MAIL_ID_PROVIDED'); $this->info->set($message, 'error'); return $this->app->redirect('index.php?option=com_easyblog&view=spools'); } foreach ($mails as $id) { $table = EB::table('MailQueue'); $table->load((int) $id); $table->delete(); } $this->info->set('COM_EASYBLOG_SPOOLS_DELETE_SUCCESS', 'success'); return $this->app->redirect('index.php?option=com_easyblog&view=spools'); }
/** * Allows caller to submit a report * * @since 4.0 * @access public * @param string * @return */ public function submit() { // Check for request forgeries EB::checkToken(); // Get the composite keys $id = $this->input->get('id', 0, 'int'); $type = $this->input->get('type', '', 'cmd'); // Initialize redirection link $redirect = EB::_('index.php?option=com_easyblog&view=entry&id=' . $id, false); // Check if guest is allowed to report or not. if ($this->my->guest && !$this->config->get('main_reporting_guests')) { $this->info->set('COM_EASYBLOG_CATEGORIES_FOR_REGISTERED_USERS_ONLY', 'error'); return $this->app->redirect($redirect); } // Ensure that the report reason is not empty. $reason = $this->input->get('reason', '', 'default'); if (!$reason) { EB::info()->set(JText::_('COM_EASYBLOG_REPORT_PLEASE_SPECIFY_REASON'), 'error'); return $this->app->redirect($redirect); } $report = EB::table('Report'); $report->obj_id = $id; $report->obj_type = $type; $report->reason = $reason; $report->created = EB::date()->toSql(); $report->created_by = $this->my->id; $report->ip = @$_SERVER['REMOTE_ADDR']; $state = $report->store(); if (!$state) { $this->info->set($report->getError()); return $this->app->redirect($redirect); } // Notify the site admin when there's a new report made $post = EB::post($id); $report->notify($post); $message = JText::_('COM_EASYBLOG_THANKS_FOR_REPORTING'); $this->info->set($message, 'success'); return $this->app->redirect($redirect); }
/** * Saves an uploaded webcam picture * * @since 4.0 * @access public * @param string * @return */ public function saveWebcam() { // Check for request forgeries EB::checkToken(); // Ensure that the user user must be logged into the site EB::requireLogin(); $image = $this->input->get('image', '', 'default'); $image = imagecreatefrompng($image); ob_start(); imagepng($image, null, 9); $contents = ob_get_contents(); ob_end_clean(); // Store this in a temporary location $file = md5(EB::date()->toSql()) . '.png'; $tmp = JPATH_ROOT . '/tmp/' . $file; $uri = JURI::root() . 'tmp/' . $file; JFile::write($tmp, $contents); $result = new stdClass(); $result->file = $file; $result->url = $uri; $this->ajax->resolve($result); }
/** * Deletes a draft from the site * * @since 5.0 * @access public * @param string * @return */ public function remove() { // Check for request forgeries EB::checkToken(); // Check for acl access $this->checkAccess('blog'); // Get list of blog post id's. $ids = $this->input->get('cid', array(), 'array'); if (!$ids) { $this->info->set('COM_EASYBLOG_INVALID_BLOG_ID', 'error'); return $this->app->redirect($return); } foreach ($ids as $id) { $id = (int) $id; $draft = EB::table('Revision'); $draft->load($id); $draft->delete(); } $this->info->set('COM_EASYBLOG_BLOGS_DELETED_SUCCESSFULLY', 'success'); $return = 'index.php?option=com_easyblog&view=blogs&layout=drafts'; return $this->app->redirect($return); }
public function runscript() { // Check for request forgeries EB::checkToken(); // Get the key $key = $this->input->get('key', '', 'default'); // Get the model $model = EB::model('Maintenance'); $script = $model->getItemByKey($key); if (!$script) { return $this->ajax->reject(JText::_('COM_EASYBLOG_MAINTENANCE_SCRIPT_NOT_FOUND')); } $classname = $script->classname; if (!class_exists($classname)) { return $this->ajax->reject(JText::_('COM_EASYBLOG_MAINTENANCE_CLASS_NOT_FOUND')); } $class = new $classname(); try { $class->main(); } catch (Exception $e) { return $this->ajax->reject($e->getMessage()); } return $this->ajax->resolve(); }
/** * Deletes a user from the site * * @since 4.0 * @access public */ public function delete() { // Check for request forgeries EB::checkToken(); // Check for acl rules. $this->checkAccess('user'); // Get a list of user id's to delete $ids = $this->input->get('cid', array(), 'array'); // Default redirection url $redirect = 'index.php?option=com_easyblog&view=bloggers'; if (!$ids) { $this->info->set('COM_EASYBLOG_INVALID_BLOGGER_ID'); return $this->app->redirect($redirect); } foreach ($ids as $id) { $id = (int) $id; $user = JFactory::getUser($id); if ($user->authorise('core.admin')) { // Throw error $this->info->set('COM_EASYBLOG_BLOGGER_NOT_ALLOWED_TO_DELETE_SUPER_ADMIN'); return $this->app->redirect($redirect); } if ($user->id == $this->my->id) { $this->info->set('COM_EASYBLOG_BLOGGER_NOT_ALLOWED_TO_DELETE_SELF'); return $this->app->redirect($redirect); } // Try to delete the user $user->delete(); } $this->info->set('COM_EASYBLOG_BLOGGER_DELETED_SUCCESSFULLY', 'success'); return $this->app->redirect($redirect); }
/** * Respond to a team request * * @since 4.0 * @access public */ public function respond() { // Check for request forgeries EB::checkToken(); // Check for acl rules. $this->checkAccess('teamblog'); $ids = $this->input->get('cid', '', 'array'); if (!$ids) { EB::info()->set(JText::_('COM_EASYBLOG_TEAMBLOGS_INVALID_ID_PROVIDED'), 'error'); return $this->app->redirect('index.php?option=com_easyblog&view=teamblogs&layout=requests'); } // Get the task $task = $this->getTask(); foreach ($ids as $id) { // Load the request $request = EB::table('TeamBlogRequest'); $request->load($id); $request->{$task}(); } $message = $task == 'approve' ? JText::_('COM_EASYBLOG_TEAMBLOGS_APPROVED_REQUESTS_SUCCESS') : JText::_('COM_EASYBLOG_TEAMBLOGS_REJECT_REQUESTS_SUCCESS'); EB::info()->set($message, 'success'); return $this->app->redirect('index.php?option=com_easyblog&view=teamblogs&layout=requests'); }
/** * Allows user to import settings file * * @since 4.0 * @access public * @param string * @return */ public function import() { // Check for request forgeries EB::checkToken(); // @task: Check for acl rules. $this->checkAccess('setting'); // Get the file data $file = $this->input->files->get('file'); if (!isset($file['tmp_name']) || empty($file['tmp_name'])) { $this->info->set('COM_EASYBLOG_SETTINGS_IMPORT_ERROR_FILE_INVALID', 'error'); return $this->app->redirect('index.php?option=com_easyblog&view=settings'); } // Get the path to the temporary file $path = $file['tmp_name']; $contents = JFile::read($path); // Load the configuration $table = EB::table('Configs'); $table->load(array('name' => 'config')); $table->params = $contents; $table->store(); $this->info->set('COM_EASYBLOG_SETTINGS_IMPORT_SUCCESS', 'success'); return $this->app->redirect('index.php?option=com_easyblog&view=settings'); }
/** * Allows caller to leave a team * * @since 4.0 * @access public * @param string * @return */ public function leave() { // Check for request forgeries EB::checkToken(); // Ensure that the user is logged in first 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 object $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); } // Ensure that the current user requesting to leave the team is really a member of the team $model = EB::model('TeamBlogs'); $isMember = $model->isMember($team->id, $this->my->id); if (!$isMember) { $this->info->set('COM_EASYBLOG_TEAMBLOG_NOT_MEMBER_OF_TEAM', 'error'); return $this->app->redirect($return); } // Get the total members in the team because we do not want to allow empty team members in a team $count = $team->getMemberCount(); if ($count <= 1) { $this->info->set('COM_EASYBLOG_TEAMBLOG_YOU_ARE_LAST_MEMBER', 'error'); return $this->app->redirect($return); } // Delete the member now $team->deleteMembers($this->my->id); $this->info->set('COM_EASYBLOG_TEAMBLOG_LEAVE_TEAM_SUCCESS', 'success'); return $this->app->redirect($return); }
/** * Toggles publishing of a comment item * * @since 4.0 * @access public * @param string * @return */ public function togglePublish() { // Check for request forgeries EB::checkToken(); // Check for acl rules. $this->checkAccess('comment'); // Get the id's $ids = $this->input->get('cid', array(), 'array'); if (!$ids) { $this->info->set('COM_EASYBLOG_COMMENTS_INVALID_ID_PROVIDED', 'error'); return $this->app->redirect('index.php?option=com_easyblog&view=comments'); } // Get the comments model $model = EB::model('Comments'); // Get the current task $task = $this->getTask(); foreach ($ids as $id) { $comment = EB::table('Comment'); $comment->load((int) $id); // Publish the comment $comment->{$task}(); } $message = 'COM_EASYBLOG_COMMENTS_COMMENT_PUBLISHED'; if ($task == 'unpublish') { $message = 'COM_EASYBLOG_COMMENTS_COMMENT_UNPUBLISHED'; } $this->info->set($message, 'success'); return $this->app->redirect('index.php?option=com_easyblog&view=comments'); }
/** * Saves a user profile * * @since 4.0 * @access public * @param string * @return */ public function save() { // Check for request forgeries EB::checkToken(); // Require user to be logged in EB::requireLogin(); // Get the post data here $post = $this->input->getArray('post'); // Since adsense codes may contain html codes $post['adsense_code'] = $this->input->get('adsense_code', '', 'raw'); // Prepare the redirection url $redirect = EB::_('index.php?option=com_easyblog&view=dashboard&layout=profile', false); if (EB::isSiteAdmin() || $this->config->get('layout_dashboard_biography_editor')) { $post['description'] = $this->input->get('description', '', 'raw'); $post['biography'] = $this->input->get('biography', '', 'raw'); } // Trim data array_walk($post, array($this, '_trim')); if ($this->config->get('main_dashboard_editaccount')) { if (!$this->validateProfile($post)) { return $this->app->redirect($redirect); } $this->my->name = $post['fullname']; $this->my->save(); } // Determines if we should save the user's params. if ($this->config->get('main_joomlauserparams')) { $email = $post['email']; $password = $post['password']; $password2 = $post['password2']; if (JString::strlen($password) || JString::strlen($password2)) { if ($password != $password2) { EB::info()->set(JText::_('COM_EASYBLOG_DASHBOARD_ACCOUNT_PASSWORD_ERROR'), 'error'); return $this->app->redirect($redirect); } } // Store Joomla info $user = JFactory::getUser(); $data = array('email' => $email, 'password' => $password, 'password2' => $password2); // Bind data $user->bind($data); $state = $user->save(); if (!$state) { EB::info()->set($user->getError(), 'error'); return $this->app->redirect($redirect); } $session = JFactory::getSession(); $session->set('user', $user); $table = JTable::getInstance('Session'); $table->load($session->getId()); $table->username = $user->get('username'); $table->store(); } // Set the permalink $post['permalink'] = $post['user_permalink']; unset($post['user_permalink']); // Get users model $model = EB::model('Users'); // Ensure that the permalink doesn't exist if ($model->permalinkExists($post['permalink'], $this->my->id)) { EB::info()->set(JText::_('COM_EASYBLOG_DASHBOARD_ACCOUNT_PERMALINK_EXISTS'), 'error'); return $this->app->redirect($redirect); } // Load up EasyBlog's profile $profile = EB::user($this->my->id); $profile->bind($post); // Bind Feedburner data $profile->bindFeedburner($post, $this->acl); // Bind oauth settings $profile->bindOauth($post, $this->acl); // Bind adsense settings $profile->bindAdsense($post, $this->acl); // Bind avatar $avatar = $this->input->files->get('avatar', ''); // Save avatar if (isset($avatar['tmp_name']) && !empty($avatar['tmp_name'])) { $profile->bindAvatar($avatar, $this->acl); } $acl = EB::acl(); //save meta if ($acl->get('add_entry')) { //meta post info $metaId = JRequest::getInt('metaid', 0); $metapos = array(); $metapost['keywords'] = $this->input->get('metakeywords', '', 'raw'); $metapost['description'] = $this->input->get('metadescription', '', 'raw'); $metapost['content_id'] = $this->my->id; $metapost['type'] = META_TYPE_BLOGGER; $meta = EB::table('Meta'); $meta->load($metaId); $meta->bind($metapost); $meta->store(); } //save params $userparams = EB::registry(); $userparams->set('theme', $post['theme']); // @rule: Save google profile url if (isset($post['google_profile_url'])) { $userparams->set('google_profile_url', $post['google_profile_url']); } if (isset($post['show_google_profile_url'])) { $userparams->set('show_google_profile_url', $post['show_google_profile_url']); } $profile->params = $userparams->toString(); // If user is allowed to save their settings if ($this->config->get('main_dashboard_editaccount') && $this->config->get('main_joomlauserparams')) { $this->my->save(true); } $state = $profile->store(); if (!$state) { EB::info()->set(JText::_('COM_EASYBLOG_DASHBOARD_PROFILE_UPDATE_FAILED'), 'error'); return $this->app->redirect($redirect); } EB::info()->set(JText::_('COM_EASYBLOG_DASHBOARD_PROFILE_UPDATE_SUCCESS'), 'success'); return $this->app->redirect($redirect); }
/** * Allow users to import csv files into subscriptions table * * @since 4.0 * @access public * @param string * @return */ public function importFile() { // Check for request forgeries EB::checkToken(); $file = JRequest::getVar('package', '', 'files', 'array'); $model = EB::model('Subscription'); // Check if the file exists if (!$file || !isset($file['tmp_name']) || empty($file['tmp_name'])) { EB::info()->set('COM_EASYBLOG_SUBSCRIPTION_IMPORT_FILE_NOT_EXIST', 'error'); return $this->app->redirect('index.php?option=com_easyblog&view=subscriptions'); } //the name of the file in PHP's temp directory that we are going to move to our folder $fileTemp = $file['tmp_name']; $fileName = $file['name']; //always use constants when making file paths, to avoid the possibilty of remote file inclusion $uploadPath = JPATH_ROOT . DIRECTORY_SEPARATOR . 'tmp' . DIRECTORY_SEPARATOR . $fileName; $model = EB::model('Subscription'); $result = $model->massAssignSubscriber($fileTemp); //var_dump($result); if ($result) { // Redirect user back EB::info()->set(count($result) . ' successfully added to subsription list', 'success'); // $this->app = JFactory::getApplication(); $this->app->redirect('index.php?option=com_easyblog&view=subscriptions'); } else { EB::info()->set('No one be added to subsription list', 'success'); $this->app->redirect('index.php?option=com_easyblog&view=subscriptions'); } }
/** * Saves a blog post template * * @since 4.0 * @access public * @param string * @return */ public function save() { // Check for request forgeries EB::checkToken(); // Ensure that the user is logged in EB::requireLogin(); // We want to get the document data $document = $this->input->get('document', '', 'raw'); $title = $this->input->get('template_title', '', 'default'); // If the caller passes us an id, we are assuming that they want to update the template $templateId = $this->input->get('template_id', 0, 'int'); $postTemplate = EB::table('PostTemplate'); // Default success message $message = 'COM_EASYBLOG_BLOG_TEMPLATE_SAVED_SUCCESS'; if ($templateId) { $postTemplate->load($templateId); $message = 'COM_EASYBLOG_BLOG_TEMPLATE_UPDATE_SUCCESS'; } else { $postTemplate->title = $title; $postTemplate->user_id = $this->my->id; $postTemplate->created = EB::date()->toSql(); $postTemplate->system = $this->input->get('system', 0, 'int'); } $postTemplate->data = $document; $postTemplate->store(); // Create an exportable object $export = $postTemplate->export(); return $this->ajax->resolve(EB::exception($message, EASYBLOG_MSG_SUCCESS), $export); }
/** * Toggles a category as the default category * * @since 4.0 * @access public * @param string * @return */ public function makeDefault() { // Check for request forgeries EB::checkToken(); // Get the category id $id = $this->input->get('cid', array(), 'array()'); if (!$id) { $this->info->set('COM_EASYBLOG_CATEGORIES_INVALID_CATEGORY', 'error'); return $this->app->redirect('index.php?option=com_easyblog&view=categories'); } // Check for acl rules. $this->checkAccess('category'); // Since the id is an array, we only want the first item $id = (int) $id[0]; // Set the current category as default $category = EB::table('Category'); $category->load($id); if (!$category->isNotAssigned()) { $this->info->set('COM_EASYBLOG_CATEGORIES_NOT_PUBLIC', 'error'); return $this->app->redirect('index.php?option=com_easyblog&view=categories'); } $category->setDefault(); $this->info->set('COM_EASYBLOG_CATEGORIES_MARKED_AS_DEFAULT', 'success'); return $this->app->redirect('index.php?option=com_easyblog&view=categories'); }
/** * Saves the google auto posting settings * * @since 4.0 * @access public * @param string * @return */ public function save() { // Check for request forgeries EB::checkToken(); // Get the client id $post = $this->input->getArray('post'); unset($post['task']); unset($post['option']); unset($post[EB::getToken()]); // Get the model so that we can store the settings $model = EB::model('Settings'); $model->save($post); // Redirect the user EB::info()->set(JText::_('COM_EASYBLOG_AUTOPOSTING_TWITTER_SAVE_SUCCESS'), 'success'); $this->app->redirect('index.php?option=com_easyblog&view=autoposting&layout=twitter'); }
/** * Toggles a default state * * @since 4.0 * @access public * @param string * @return */ public function toggleDefault() { // Check for request forgeries EB::checkToken(); // @task: Check for acl rules. $this->checkAccess('tag'); // Get the list of ids $ids = $this->input->get('cid', array(), 'array'); if (!$ids) { $this->info->set('COM_EASYBLOG_TAGS_INVALID_ID_PROVIDED', 'error'); return $this->app->redirect('index.php?option=com_easyblog&view=tags'); } $method = $this->getTask(); $model = EB::model('Tags'); $model->{$method}($ids); if ($method == 'setDefault') { $this->info->set('COM_EASYBLOG_TAGS_TAG_SET_DEFAULT_SUCCESS', 'success'); } else { $this->info->set('COM_EASYBLOG_TAGS_TAG_UNSET_DEFAULT_SUCCESS', 'success'); } return $this->app->redirect('index.php?option=com_easyblog&view=tags'); }
/** * Stores a new rss feed import * * @since 4.0 * @access public */ public function save() { // Check for request forgeries EB::checkToken(); // @task: Check for acl rules. $this->checkAccess('feeds'); $post = JRequest::get('post'); $id = $this->input->get('id', 0, 'int'); $feed = EB::table('Feed'); $feed->load($id); $feed->bind($post); if (!$feed->item_creator) { EB::info()->set('COM_EASYBLOG_BLOGS_FEEDS_ERROR_AUTHOR', 'error'); $session = JFactory::getSession(); $session->set('feeds.data', $post, 'easyblog'); return $this->app->redirect('index.php?option=com_easyblog&view=feeds&layout=form'); } if (!$feed->item_category) { EB::info()->set('COM_EASYBLOG_BLOGS_FEEDS_ERROR_CATEGORY', 'error'); $session = JFactory::getSession(); $session->set('feeds.data', $post, 'easyblog'); return $this->app->redirect('index.php?option=com_easyblog&view=feeds&layout=form'); } if (!$feed->url) { EB::info()->set('COM_EASYBLOG_BLOGS_FEEDS_ERROR_URL', 'error'); $session = JFactory::getSession(); $session->set('feeds.data', $post, 'easyblog'); return $this->app->redirect('index.php?option=com_easyblog&view=feeds&layout=form'); } if (!$feed->title) { EB::info()->set('COM_EASYBLOG_BLOGS_FEEDS_ERROR_TITLE', 'error'); $session = JFactory::getSession(); $session->set('feeds.data', $post, 'easyblog'); return $this->app->redirect('index.php?option=com_easyblog&view=feeds&layout=form'); } // Store the allowed tags here. $allowed = JRequest::getVar('item_allowed_tags', '', 'REQUEST', 'none', JREQUEST_ALLOWRAW); $copyrights = JRequest::getVar('copyrights', ''); $sourceLinks = JRequest::getVar('sourceLinks', '0'); $feedamount = JRequest::getVar('feedamount', '0'); $autopost = JRequest::getVar('autopost', 0); $params = EB::getRegistry(); $params->set('allowed', $allowed); $params->set('copyrights', $copyrights); $params->set('sourceLinks', $sourceLinks); $params->set('autopost', $autopost); $params->set('feedamount', $feedamount); $params->set('item_get_fulltext', $this->input->get('item_get_fulltext', '', 'default')); $params->set('notify', $this->input->get('notify', '', 'default')); $feed->params = $params->toString(); $state = $feed->store(); if (!$state) { EB::info()->set($feed->getError(), 'error'); $session = JFactory::getSession(); $session->set('feeds.data', $post, 'easyblog'); return $this->app->redirect('index.php?option=com_easyblog&view=feeds&layout=form'); } EB::info()->set('COM_EASYBLOG_BLOGS_FEEDS_SAVE_SUCCESS', 'success'); $task = $this->getTask(); if ($task == 'apply') { return $this->app->redirect('index.php?option=com_easyblog&view=feeds&layout=form&id=' . $feed->id); } if ($task == 'save') { return $this->app->redirect('index.php?option=com_easyblog&view=feeds'); } if ($task == 'savenew') { return $this->app->redirect('index.php?option=com_easyblog&view=feeds&layout=form'); } }
/** * Ensure that the user is allowed to save the blog post * * @since 5.0 * @access public * @param string * @return */ private function verifyAccess() { // Check for request forgeries EB::checkToken(); // Ensure that the user must be logged into the site EB::requireLogin(); // Ensure that the user really has permissions to create blog posts on the site if (!$this->acl->get('add_entry')) { throw EB::exception('COM_EASYBLOG_NO_PERMISSION_TO_CREATE_BLOG'); } // Ensure uid is provided $uid = $this->input->get('uid'); if (empty($uid)) { throw EB::exception('COM_EASYBLOG_MISSING_UID'); } }
/** * Duplicates a blog post * * @since 4.0 * @access public * @param string * @return */ public function copy() { // Check for request forgeries EB::checkToken(); // @task: Check for acl rules. $this->checkAccess('blog'); $ids = $this->input->get('cid', array(), 'array'); if (!$ids) { $this->info()->set(JText::_('COM_EASYBLOG_BLOGS_COPY_ERROR'), 'error'); return $this->app->redirect('index.php?option=com_easyblog&view=blogs'); } foreach ($ids as $id) { $post = EB::post($id); $post->duplicate(); } $this->info->set(JText::sprintf('COM_EASYBLOG_BLOGS_COPIED_SUCCESSFULLY', count($ids)), 'success'); return $this->app->redirect('index.php?option=com_easyblog&view=blogs'); }
/** * Deletes metas from the site * * @since 4.0 * @access public * @param string * @return */ public function delete() { // Check for request forgeries EB::checkToken(); // Check for acl rules. $this->checkAccess('meta'); // Get the list of metas to be deleted $ids = $this->input->get('cid', array(), 'array'); if (!$ids) { $this->info->set(JText::_('Invalid meta id'), 'error'); return $this->app->redirect('index.php?option=com_easyblog&view=metas'); } // Do whatever you need to do here foreach ($ids as $id) { $meta = EB::table('Meta'); $meta->load((int) $id); // Delete the tag $meta->delete(); } $this->info->set('COM_EASYBLOG_METAS_META_REMOVED', 'success'); return $this->app->redirect('index.php?option=com_easyblog&view=metas'); }
/** * Saves the google auto posting settings * * @since 4.0 * @access public * @param string * @return */ public function save() { // Check for request forgeries EB::checkToken(); // Get the client id $post = $this->input->getArray('post'); unset($post['task']); unset($post['option']); unset($post[EB::getToken()]); if (isset($post['integrations_facebook_page_id'])) { $pages = $post['integrations_facebook_page_id']; // We need to merge them to be comma separated values $post['integrations_facebook_page_id'] = implode(',', $pages); } if (isset($post['integrations_facebook_group_id'])) { $groups = $post['integrations_facebook_group_id']; // Merge the array into string values $post['integrations_facebook_group_id'] = implode(',', $groups); } // Get the model so that we can store the settings $model = EB::model('Settings'); $model->save($post); // Redirect the user EB::info()->set(JText::_('COM_EASYBLOG_AUTOPOSTING_FACEBOOK_SAVE_SUCCESS'), 'success'); $this->app->redirect('index.php?option=com_easyblog&view=autoposting&layout=facebook'); }