Example #1
0
 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);
 }
Example #2
0
 public function display($tmpl = null)
 {
     // Ensure that the user is logged in.
     EB::requireLogin();
     // null = new post
     // 63   = post 63 from post table
     // 63.2 = post 63, revision 2 from history table
     $uid = $this->input->getVar('uid', null);
     // If no id given, create a new post.
     $post = EB::post($uid);
     // Verify access (see function manager())
     if (!$post->canCreate() && !$post->canEdit()) {
         // Do not allow user to access this page if he doesn't have access
         JError::raiseError(500, JText::_('COM_EASYBLOG_NOT_ALLOWED_ACCESS_IN_THIS_SECTION'));
         return;
     }
     // If there's no id provided, we will need to create the initial revision for the post.
     if (!$uid) {
         $post->create();
         $uid = $post->uid;
     }
     // Determines if we should show the sidebars by default
     $templateId = $this->input->get('block_template', 0, 'int');
     if (!$post->title) {
         $this->doc->setTitle(JText::_('COM_EASYBLOG_COMPOSER_POST_UNTITLED'));
     }
     $composer = EB::composer();
     // Render default post templates
     $postTemplatesModel = EB::model('Templates');
     $postTemplates = $postTemplatesModel->getPostTemplates($this->my->id);
     $this->set('postTemplates', $postTemplates);
     $this->set('composer', $composer);
     $this->set('post', $post);
     return parent::display('composer/default');
 }
Example #3
0
 /**
  * Deletes a tag from the site
  *
  * @since	4.0
  * @access	public
  * @param	string
  * @return
  */
 public function delete()
 {
     // Check for request forgeries
     EB::checkToken();
     // Ensure that the user is logged in
     EB::requireLogin();
     // Default return url
     $return = EB::_('index.php?option=com_easyblog&view=dashboard&layout=tags', false);
     // Ensure that the user has access to create tags
     if (!$this->acl->get('create_tag') && !EB::isSiteAdmin()) {
         $this->info->set('COM_EASYBLOG_NO_PERMISSION_TO_CREATE_TAG', 'error');
         return $this->app->redirect($return);
     }
     // Ensure that the tag exists
     $id = $this->input->get('id', 0, 'int');
     $tag = EB::table('Tag');
     $tag->load($id);
     if (!$id || !$tag->id) {
         $this->info->set('COM_EASYBLOG_TAG_INVALID_ID', 'error');
         return $this->app->redirect($return);
     }
     // Ensure that the user owns this tag
     if ($tag->created_by != $this->my->id && !EB::isSiteAdmin()) {
         $this->info->set('COM_EASYBLOG_NO_PERMISSION_TO_DELETE_TAG', 'error');
         return $this->app->redirect($return);
     }
     $state = $tag->delete();
     if (!$state) {
         $this->info->set($tag->getError(), 'error');
         return $this->app->redirect($return);
     }
     $this->info->set('COM_EASYBLOG_TAG_DELETED', 'success');
     return $this->app->redirect($return);
 }
Example #4
0
 /**
  * Allows tagging suggestion which is used by the composer
  *
  * @since	4.0
  * @access	public
  * @param	string
  * @return	
  */
 public function suggest()
 {
     // Only logged in users are allowed here
     EB::requireLogin();
     $keyword = $this->input->get('search', '', 'default');
     $model = EB::model('Tags');
     $suggestions = $model->suggest($keyword);
     return $this->ajax->resolve($suggestions);
 }
Example #5
0
 /**
  * Displays all members from a team
  *
  * @since   5.0
  * @access  public
  * @param   string
  * @return
  */
 public function viewMembers()
 {
     // Require user to be logged in
     EB::requireLogin();
     $id = $this->input->get('id', 0, 'int');
     if (!$id) {
         return $this->ajax->reject(JText::_('COM_EASYBLOG_TEAMBLOG_INVALID_TEAM_ID_PROVIDED'));
     }
     $model = EB::model('TeamBlogs');
     $members = $model->getAllMembers($id);
     $template = EB::template();
     $template->set('members', $members);
     $output = $template->output('site/teamblogs/dialog.members');
     return $this->ajax->resolve($output);
 }
Example #6
0
 /**
  * Main display for the blog entry view
  *
  * @since	4.0
  * @access	public
  * @param	string
  * @return
  */
 public function display($tpl = null)
 {
     // Get the blog post id from the request
     $id = $this->input->get('id', 0, 'int');
     // Load the blog post now
     $post = EB::post($id);
     // 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.
     if ($this->my->guest && $this->config->get('main_login_read')) {
         return EB::requireLogin();
     }
     // 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;
     }
     // Increment the hit counter for the blog post.
     $post->hit();
     // Format the post
     $post = EB::formatter('entry', $post);
     $theme = EB::template();
     $theme->set('post', $post);
     $output = $theme->output('site/blogs/entry/default.print');
     echo $output;
 }
Example #7
0
 /**
  * Default display method for my blog listings
  *
  * @since	4.0
  * @access	public
  * @param	string
  * @return
  */
 public function display($tmpl = null)
 {
     // Require user to be logged in to access this page
     EB::requireLogin();
     // Get the default sorting behavior
     $sort = $this->input->get('sort', $this->config->get('layout_postorder'), 'cmd');
     // Load up the author profile
     $author = EB::user($this->my->id);
     // Set meta tags for blogger
     EB::setMeta($this->my->id, META_ID_BLOGGERS);
     // Set the breadcrumbs
     $this->setPathway(JText::_('COM_EASYBLOG_BLOGGERS_BREADCRUMB'), EB::_('index.php?option=com_easyblog&view=blogger'));
     $this->setPathway($author->getName());
     $menu = JFactory::getApplication()->getMenu();
     $categoryInclusion = array();
     if ($menu) {
         $active = $menu->getActive();
         $categoryInclusion = $active->params->get('inclusion');
     }
     $model = EB::model('Blog');
     $posts = $model->getBlogsBy('blogger', $author->id, $sort, 0, EBLOG_FILTER_PUBLISHED, false, false, array(), false, false, true, array(), $categoryInclusion);
     // Get the pagination
     $pagination = $model->getPagination();
     // Set the page title
     $title = $author->getName() . ' - ' . EB::getPageTitle(JText::_('COM_EASYBLOG_MY_BLOG_PAGE_TITLE'));
     $this->setPageTitle($title, $pagination, $this->config->get('main_pagetitle_autoappend'));
     // Format the posts
     $posts = EB::formatter('list', $posts);
     // Add the RSS headers on the page
     EB::feeds()->addHeaders('index.php?option=com_easyblog&view=myblog');
     // Determines if the viewer already subscribed to the author
     $subscribed = false;
     $bloggerModel = EB::model('Blogger');
     if ($bloggerModel->isBloggerSubscribedUser($author->id, $this->my->id, $this->my->email)) {
         $subscribed = true;
     }
     // Get the current url
     $return = EBR::_('index.php?option=com_easyblog', false);
     $this->set('return', $return);
     $this->set('subscribed', $subscribed);
     $this->set('author', $author);
     $this->set('posts', $posts);
     $this->set('sort', $sort);
     $this->set('pagination', $pagination);
     parent::display('blogs/myblog/default');
 }
Example #8
0
 /**
  * Displays a list of subscriptions the user belongs to.
  *
  * @since	5.0
  * @access	public
  * @param	string
  * @return	
  */
 public function display($tpl = null)
 {
     // Check for acl
     $this->checkAcl('allow_subscription');
     // Do not allow guests to access this page
     if ($this->my->guest) {
         return EB::requireLogin();
     }
     // Set the title of the page
     $this->doc->setTitle(JText::_('COM_EASYBLOG_SUBSCRIPTIONS_PAGE_TITLE'));
     // Add pathway
     if (!EBR::isCurrentActiveMenu('subscription')) {
         $this->setPathway(JText::_('COM_EASYBLOG_SUBSCRIPTIONS_BREADCRUMB'));
     }
     // Ensure that the user has access to manage subscriptions
     if (!$this->acl->get('allow_subscription')) {
         return JError::raiseError(500, JText::_('COM_EASYBLOG_YOU_DO_NOT_HAVE_PERMISSION_TO_VIEW'));
     }
     // Get a list of subscriptions the user has
     $model = EB::model('Subscriptions');
     $result = $model->getSubscriptionsByUser($this->my->id);
     $subscriptions = array();
     $groups = array();
     if ($result) {
         foreach ($result as $row) {
             $type = $row->utype;
             $groups[] = $type;
             if (!isset($subscriptions[$type])) {
                 $subscriptions[$row->utype] = array();
             }
             // Get the formatted type title
             $row->object = $row->getObject();
             $subscriptions[$row->utype][] = $row;
         }
     }
     // Ensure that the groups are unique
     $groups = array_unique($groups);
     $this->set('groups', $groups);
     $this->set('subscriptions', $subscriptions);
     parent::display('subscription/default');
 }
Example #9
0
 /**
  * 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);
 }
Example #10
0
 /**
  * Handles uploads from media manager.
  *
  * @since	4.0
  * @access	public
  * @param	string
  * @return
  */
 public function upload()
 {
     // Ensure that the user is logged in
     EB::requireLogin();
     // Only allowed users who are allowed to upload images
     if (!$this->acl->get('upload_image')) {
         $this->output(EB::exception('COM_EASYBLOG_NOT_ALLOWED', EASYBLOG_MSG_ERROR));
     }
     // Load up media manager
     $mm = EB::mediamanager();
     // Get uri
     $key = $this->input->getRaw('key');
     // Get the target folder
     $placeId = EBMM::getUri($key);
     // Get the file input
     $file = $this->input->files->get('file');
     // Check if the file is really allowed to be uploaded to the site.
     $state = EB::image()->canUploadFile($file);
     if ($state instanceof Exception) {
         return $this->output($state);
     }
     // MM should check if the user really has access to upload to the target folder
     $allowed = EBMM::hasAccess($placeId);
     if ($allowed instanceof Exception) {
         return $this->output($allowed);
     }
     // Check the image name is it got contain space, if yes need to replace to '-'
     $fileName = $file['name'];
     $file['name'] = str_replace(' ', '-', $fileName);
     // Upload the file now
     $file = $mm->upload($file, $placeId);
     // Response object is intended to also include
     // other properties like status message and status code.
     // Right now it only inclues the media item.
     $response = new stdClass();
     $response->media = EBMM::getMedia($file->uri);
     return $this->output($response);
 }
Example #11
0
 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');
 }
Example #12
0
 /**
  * Location suggestions
  *
  * @since	5.0
  * @access	public
  * @param	string
  * @return
  */
 public function getLocations()
 {
     // Require user to be logged in
     EB::requireLogin();
     $lat = $this->input->get('latitude', '', 'string');
     $lng = $this->input->get('longitude', '', 'string');
     $query = $this->input->get('query', '', 'string');
     // Get the configured service provider for location
     $provider = $this->config->get('location_service_provider');
     $service = EB::location($provider);
     if ($service->hasErrors()) {
         return $this->ajax->reject($service->getError());
     }
     if ($lat && $lng) {
         $service->setCoordinates($lat, $lng);
     }
     if ($query) {
         $service->setSearch($query);
     }
     $venues = $service->getResult($query);
     if ($service->hasErrors()) {
         return $this->ajax->reject($service->getError());
     }
     return $this->ajax->resolve($venues);
 }
Example #13
0
 /**
  * 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');
     }
 }
Example #14
0
 /**
  * Revokes the user's oauth access
  *
  * @since	5.0
  * @access	public
  * @param	string
  * @return	
  */
 public function revoke()
 {
     // Require the user to be logged in
     EB::requireLogin();
     // The default url
     $url = EBR::_('index.php?option=com_easyblog&view=dashboard&layout=profile', false);
     // Get any redirection url
     $redirect = $this->input->get('redirect', '', 'default');
     // Get the oauth client
     $type = $this->input->get('client', '', 'cmd');
     // If redirect url is provided, we know for sure where to redirect the user to
     if ($redirect) {
         $url = base64_decode($redirect);
     }
     // Load up the oauth object
     $table = EB::table('OAuth');
     $table->loadByUser($this->my->id, $type);
     // Load up the oauth client and set the access
     $client = EB::oauth()->getClient($type);
     $client->setAccess($table->access_token);
     // Get the callback url
     $callback = EBR::getRoutedURL('index.php?option=com_easyblog&task=oauth.grant&client=' . $type, false, true);
     // Get the consumer and secret key
     $key = $this->config->get('integrations_' . $type . '_api_key');
     $secret = $this->config->get('integrations_' . $type . '_secret_key');
     // Try to revoke the app
     $state = $client->revoke();
     // After revoking the access, delete the oauth record
     $table->delete();
     $this->info->set(JText::_('COM_EASYBLOG_APPLICATION_REVOKED_SUCCESSFULLY'), 'success');
     return $this->app->redirect($url, false);
 }
Example #15
0
 /**
  * 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);
 }
Example #16
0
 /**
  * Creates a new folder on the site
  *
  * @since   5.0
  * @access  public
  * @param   string
  * @return
  */
 public function createFolder()
 {
     // Ensure that the user is logged in
     EB::requireLogin();
     $key = $this->input->getRaw('key');
     $uri = EBMM::getUri($key);
     $folder = $this->input->get('folder', '', 'cmd');
     $media = EB::mediamanager();
     $uri = $media->createFolder($uri, $folder);
     if ($uri instanceof EasyBlogException) {
         return $this->ajax->reject($item);
     }
     $html = EBMM::renderFile($uri);
     return $this->ajax->resolve($html);
 }
Example #17
0
 /**
  * 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);
 }
Example #18
0
 /**
  * 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);
 }
Example #19
0
 /**
  * Saves a category
  *
  * @since	5.0
  * @access	public
  * @param	string
  * @return
  */
 public function save()
 {
     // Check for request forgeries
     EB::checkToken();
     // Ensure that the user is logged in
     EB::requireLogin();
     // Default return url
     $return = EBR::_('index.php?option=com_easyblog&view=dashboard&layout=categories', false);
     // Ensure that the user has access to create category
     if (!$this->acl->get('create_category') && !EB::isSiteAdmin()) {
         $this->info->set('COM_EASYBLOG_NO_PERMISSION_TO_CREATE_CATEGORY', 'error');
         return $this->app->redirect($return);
     }
     // Possibility is that this category is being edited.
     $id = $this->input->get('id', 0, 'int');
     // Get the title of the category
     $title = $this->input->get('title', '', 'default');
     if (!$title) {
         $this->info->set('COM_EASYBLOG_DASHBOARD_CATEGORIES_EMPTY_CATEGORY_TITLE_ERROR', 'error');
         return $this->app->redirect($return);
     }
     $category = EB::table('Category');
     $category->load($id);
     // Default success message
     $message = 'COM_EASYBLOG_DASHBOARD_CATEGORIES_ADDED_SUCCESSFULLY';
     if ($category->id && $id) {
         $message = 'COM_EASYBLOG_DASHBOARD_CATEGORY_UPDATED_SUCCESSFULLY';
     }
     // Check whether the same category already exists on the site.
     $model = EB::model('Category');
     $exists = $model->isExist($title, $category->id);
     if ($exists) {
         $this->info->set(JText::sprintf('COM_EASYBLOG_DASHBOARD_CATEGORIES_ALREADY_EXISTS_ERROR', $title), 'error');
         return $this->app->redirect($return);
     }
     $post = $this->input->getArray('post');
     $post['title'] = $title;
     $post['created_by'] = $this->my->id;
     $post['parent_id'] = $this->input->get('parent_id', 0, 'int');
     $post['private'] = $this->input->get('private', 0, 'int');
     $post['description'] = $this->input->get('description', '', 'raw');
     $category->bind($post);
     // Set the category as published by default.
     $category->published = true;
     // Assign default category params
     $file = JPATH_ADMINISTRATOR . '/components/com_easyblog/defaults/category.json';
     $content = JFile::read($file);
     if ($content) {
         $params = array();
         $rawParams = json_decode($content);
         foreach ($rawParams as $raw) {
             $params[$raw->name] = $raw->default;
         }
         $category->params = json_encode($params);
     }
     // Save the cat 1st so that the id get updated
     $category->store();
     // Delete all acl related to this category
     $category->deleteACL();
     if ($category->private == CATEGORY_PRIVACY_ACL) {
         $category->saveACL($post);
     }
     // Set a category avatar if required
     $file = $this->input->files->get('Filedata', '', 'array');
     if (isset($file['name']) && !empty($file['name'])) {
         $category->avatar = EB::uploadCategoryAvatar($category);
         $category->store();
     }
     $this->info->set(JText::sprintf($message, $category->getTitle()), 'success');
     return $this->app->redirect($return);
 }
Example #20
0
 /**
  * Displays the quickpost layout
  *
  * @since	4.0
  * @access	public
  * @param	string
  * @return
  */
 public function quickpost()
 {
     // Require user to be logged in
     EB::requireLogin();
     // Test if microblogging is allowed
     if (!$this->config->get('main_microblog')) {
         $this->info->set(JText::_('COM_EASYBLOG_NOT_ALLOWED'), 'error');
         return $this->app->redirect(EBR::_('index.php?option=com_easyblog&view=dashboard', false));
     }
     // Test ACL if add entry is allowed
     if (!$this->acl->get('add_entry')) {
         return $this->app->redirect(EBR::_('index.php?option=com_easyblog&view=dashboard', false));
     }
     // Set the page title
     $title = EB::getPageTitle(JText::_('COM_EASYBLOG_DASHBOARD_SHARE_A_STORY_TITLE'));
     parent::setPageTitle($title, false, $this->config->get('main_pagetitle_autoappend'));
     // Get active tabs
     $active = $this->input->get('type', 'standard', 'word');
     // Get a list of available auto post sites
     $facebook = EB::oauth()->isUserAssociated('facebook', $this->my->id);
     $twitter = EB::oauth()->isUserAssociated('twitter', $this->my->id);
     $linkedin = EB::oauth()->isUserAssociated('linkedin', $this->my->id);
     // Retrieve existing tags
     $tagsModel = EB::model('Tags');
     $tags = $tagsModel->getTags();
     $this->set('facebook', $facebook);
     $this->set('twitter', $twitter);
     $this->set('linkedin', $linkedin);
     $this->set('active', $active);
     $this->set('tags', $tags);
     parent::display('dashboard/quickpost/default');
 }
Example #21
0
 /**
  * Load media configuration
  *
  * @since	4.0
  * @access	public
  * @param	string
  * @return
  */
 public function mediaConfiguration()
 {
     $ajax = EB::ajax();
     // Require login
     EB::requireLogin();
     $user = EB::user($this->my->id);
     $tpl = EB::template();
     $blogger_id = $user->id;
     $tpl->set('blogger_id', $blogger_id);
     // @since: 3.6
     // Media manager options
     $tpl->set('session', JFactory::getSession());
     $mediamanager = EB::mediamanager();
     $userFolders = $mediamanager->getInfo(EasyBlogMediaManager::getAbsolutePath('', 'user'), 'folders');
     $userFiles = $mediamanager->getInfo(EasyBlogMediaManager::getAbsolutePath('', 'user'), 'files');
     $sharedFolders = $mediamanager->getInfo(EasyBlogMediaManager::getAbsolutePath('', 'shared'), 'folders');
     $sharedFiles = $mediamanager->getInfo(EasyBlogMediaManager::getAbsolutePath('', 'shared'), 'files');
     $tpl->set('userFolders', $userFolders);
     $tpl->set('userFiles', $userFiles);
     $tpl->set('sharedFolders', $sharedFolders);
     $tpl->set('sharedFiles', $sharedFiles);
     // @rule: Test if the user is already associated with Flickr
     $oauth = EB::table('OAuth');
     $associated = $oauth->loadByUser($this->my->id, EBLOG_OAUTH_FLICKR);
     $tpl->set('flickrAssociated', $associated);
     // Retrieve flickr's data
     $flickr = $this->getFlickrData();
     // Retrieve dropbox's data
     $dropbox = $this->getDropboxData();
     $tpl->set('flickr', $flickr);
     $tpl->set('dropbox', $dropbox);
     $html = $tpl->output('site/media/configuration');
     $ajax->resolve($html);
 }