当前位置: 首页>>代码示例>>PHP>>正文


PHP EB::isSiteAdmin方法代码示例

本文整理汇总了PHP中EB::isSiteAdmin方法的典型用法代码示例。如果您正苦于以下问题:PHP EB::isSiteAdmin方法的具体用法?PHP EB::isSiteAdmin怎么用?PHP EB::isSiteAdmin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在EB的用法示例。


在下文中一共展示了EB::isSiteAdmin方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: join

 /**
  * Processes requests to join the team
  *
  * @since	4.0
  * @access	public
  * @param	string
  * @return
  */
 public function join()
 {
     // Check for request forgeries
     EB::checkToken();
     // Only allow registered users
     EB::requireLogin();
     $return = $this->input->get('return', '', 'default');
     if ($return) {
         $return = base64_decode($return);
     }
     // Default return url
     if (!$return) {
         $return = EB::_('index.php?option=com_easyblog&view=teamblog', false);
     }
     // Get the team data
     $id = $this->input->get('id', 0, 'int');
     $team = EB::table('TeamBlog');
     $team->load($id);
     if (!$id || !$team->id) {
         $this->info->set('COM_EASYBLOG_TEAMBLOG_INVALID_ID_PROVIDED', 'error');
         return $this->app->redirect($return);
     }
     $model = EB::model('TeamBlogs');
     $isMember = $model->isMember($team->id, $this->my->id);
     // Check if the user already exists
     if ($isMember) {
         $this->info->set('COM_EASYBLOG_TEAMBLOG_ALREADY_MEMBER', 'error');
         return $this->app->redirect($return);
     }
     // If the user is a site admin, they are free to do whatever they want
     if (EB::isSiteAdmin()) {
         $map = EB::table('TeamBlogUsers');
         $map->user_id = $this->my->id;
         $map->team_id = $team->id;
         $map->store();
         $this->info->set('COM_EASYBLOG_TEAMBLOG_REQUEST_JOINED', 'success');
     } else {
         // Create a new request
         $request = EB::table('TeamBlogRequest');
         $request->team_id = $team->id;
         $request->user_id = $this->my->id;
         $request->ispending = true;
         $request->created = EB::date()->toSql();
         // If request was already made previously, skip this
         if ($request->exists()) {
             $this->info->set('COM_EASYBLOG_TEAMBLOG_REQUEST_ALREADY_SENT', 'error');
             return $this->app->redirect($return);
         }
         // Store the request now
         $state = $request->store();
         if (!$state) {
             $this->info->set($request->getError(), 'error');
             return $this->app->redirect($return);
         }
         // Send moderation emails
         $request->sendModerationEmail();
         $this->info->set('COM_EASYBLOG_TEAMBLOG_REQUEST_SENT', 'success');
     }
     return $this->app->redirect($return);
 }
开发者ID:knigherrant,项目名称:decopatio,代码行数:68,代码来源:teamblogs.php

示例2: removeFeatured

 /**
  * Removes featured status from an object
  *
  * @since	4.0
  * @access	public
  * @param	string
  * @return
  */
 public function removeFeatured()
 {
     $ajax = EB::ajax();
     // Ensure that the user has privileges
     if (!EB::isSiteAdmin() && !$this->acl->get('feature_entry')) {
         return JError::raiseError(500, JText::_('COM_EASYBLOG_NOT_ALLOWED'));
     }
     $type = $this->input->get('type', '', 'word');
     $id = $this->input->get('id', '', 'int');
     if ($type == 'blogger') {
         $title = JText::_('COM_EASYBLOG_UNFEATURE_AUTHOR_DIALOG_TITLE');
         $content = JText::_('COM_EASYBLOG_UNFEATURE_AUTHOR_DIALOG_CONTENT');
     }
     if ($type == 'teamblog') {
         $title = JText::_('COM_EASYBLOG_UNFEATURE_TEAMBLOG_DIALOG_TITLE');
         $content = JText::_('COM_EASYBLOG_UNFEATURE_TEAMBLOG_DIALOG_CONTENT');
     }
     $model = EB::model('Featured');
     $model->removeFeatured($type, $id);
     $theme = EB::template();
     $theme->set('title', $title);
     $theme->set('content', $content);
     $output = $theme->output('site/featured/dialog.unfeature');
     return $ajax->resolve($output);
 }
开发者ID:knigherrant,项目名称:decopatio,代码行数:33,代码来源:view.ajax.php

示例3: delete

 /**
  * Deletes a list of post templates
  *
  * @since	4.0
  * @access	public
  * @param	string
  * @return
  */
 public function delete()
 {
     // Check for request forgeries
     EB::checkToken();
     $ids = $this->input->get('ids', array(), 'array');
     $redirect = EB::_('index.php?option=com_easyblog&view=dashboard&layout=templates', false);
     if (!$ids) {
         $this->info->set(JText::_('COM_EASYBLOG_DASHBOARD_TEMPLATES_INVALID_ID'), 'error');
         return $this->app->redirect($redirect);
     }
     foreach ($ids as $id) {
         $template = EB::table('PostTemplate');
         $template->load((int) $id);
         // Ensure that the user has access to delete this
         if ($template->user_id == $this->my->id || EB::isSiteAdmin()) {
             $template->delete();
         }
     }
     if ($this->doc->getType() != 'ajax') {
         $this->info->set('COM_EASYBLOG_DASHBOARD_TEMPLATES_DELETED_SUCCESS', 'success');
         return $this->app->redirect($redirect);
     }
     // For ajax calls, we shouldn't do anything
     return $this->ajax->resolve();
 }
开发者ID:knigherrant,项目名称:decopatio,代码行数:33,代码来源:templates.php

示例4: isOwner

 /**
  * Determines if the post template is a core templae
  *
  * @since   5.0
  * @access  public
  * @param   string
  * @return
  */
 public function isOwner()
 {
     $my = EB::user();
     if (EB::isSiteAdmin($my->id) || $this->user_id == $my->id) {
         return true;
     } else {
         return false;
     }
 }
开发者ID:knigherrant,项目名称:decopatio,代码行数:17,代码来源:posttemplate.php

示例5: display

 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;
 }
开发者ID:BetterBetterBetter,项目名称:B3App,代码行数:56,代码来源:view.pdf.php

示例6: push

 /**
  * Pushes to the oauth site
  *
  * @since	4.0
  * @access	public
  * @param	string
  * @return
  */
 public function push(EasyBlogPost &$post)
 {
     // When there is no access token set on this oauth record, we shouldn't do anything
     if (!$this->access_token) {
         $this->setError(JText::sprintf('No access token available for autoposting on %1$s', $this->type));
         return false;
     }
     $config = EB::config();
     // Determines if this user is really allowed to auto post
     $author = $post->getAuthor();
     // Check the author's acl
     $acl = EB::acl($author->id);
     $rule = 'update_' . $this->type;
     if (!$acl->get($rule) && !EB::isSiteAdmin($post->created_by)) {
         $this->setError(JText::sprintf('No access to autopost on %1$s', $this->type));
         return false;
     }
     // we only check if the autopost on blog edit is disabled.
     if (!$config->get('integrations_' . $this->type . '_centralized_send_updates')) {
         // Check if the blog post was shared before.
         if ($this->isShared($post->id)) {
             $this->setError(JText::sprintf('Post %1$s has been shared to %2$s before.', $post->id, $this->type));
             return false;
         }
     }
     // Ensure that the oauth data has been set correctly
     $config = EB::config();
     $key = $config->get('integrations_' . $this->type . '_api_key');
     $secret = $config->get('integrations_' . $this->type . '_secret_key');
     // If either of this is empty, skip this
     if (!$key || !$secret) {
         return false;
     }
     // Set the callback URL
     $callback = JURI::base() . 'index.php?option=com_easyblog&task=oauth.grant&type=' . $this->type;
     // Now we do the real thing. Get the library and push
     $lib = EB::oauth()->getClient($this->type, $key, $secret, $callback);
     $lib->setAccess($this->access_token);
     // Try to share the post now
     $state = $lib->share($post, $this);
     if ($state === true) {
         $history = EB::table('OAuthPost');
         $history->load(array('oauth_id' => $this->id, 'post_id' => $post->id));
         $history->post_id = $post->id;
         $history->oauth_id = $this->id;
         $history->created = EB::date()->toSql();
         $history->modified = EB::date()->toSql();
         $history->sent = EB::date()->toSql();
         $history->store();
         return true;
     }
     return false;
 }
开发者ID:knigherrant,项目名称:decopatio,代码行数:61,代码来源:oauth.php

示例7: unsubscribe

 /**
  * 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);
 }
开发者ID:knigherrant,项目名称:decopatio,代码行数:59,代码来源:subscription.php

示例8: execute

 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;
 }
开发者ID:knigherrant,项目名称:decopatio,代码行数:52,代码来源:teamblogs.php

示例9: __construct

 public function __construct($overrideTheme = null, $options = array())
 {
     parent::__construct();
     // Determine if this is an admin location
     if (isset($options['admin']) && $options['admin']) {
         $this->admin = true;
     }
     // Determine the configured theme
     $theme = $this->config->get('layout_theme', $overrideTheme);
     // If a view is provided into the theme, the theme files could call methods from a view
     if (isset($options['view']) && is_object($options['view'])) {
         $this->view = $options['view'];
     }
     $this->theme = $theme;
     $obj = new stdClass();
     $obj->config = EB::config();
     $obj->my = JFactory::getUser();
     $obj->admin = EB::isSiteAdmin();
     $obj->profile = EB::user();
     // If it's development mode, allow user to invoke in the url to change theme.
     $environment = $obj->config->get('easyblog_environment');
     if ($environment == 'development') {
         $invokeTheme = $this->input->get('theme', '', 'word');
         if ($invokeTheme) {
             $this->theme = $invokeTheme;
         }
     }
     // If this is entry view, or category view, we need to respect the theme's category
     $this->menu = $this->app->getMenu()->getActive();
     $this->params = new JRegistry();
     // If there is an active menu, try to get the menu parameters.
     if ($this->menu) {
         // Get the params prefix
         $prefix = isset($options['paramsPrefix']) ? $options['paramsPrefix'] : '';
         // Set the current parameters.
         if ($prefix) {
             $model = EB::model('Menu');
             $this->params = $model->getCustomMenuParams($this->menu->id, $this->menu->params, $prefix);
         } else {
             $this->params = $this->menu->params;
         }
         // We will just set it here from the menu when this class first get instantiate.
         // The corresponding view will have to do their own assignment if the view's templates need to access this entryParams
         $this->entryParams = $this->params;
     }
     //is blogger mode flag
     $obj->isBloggerMode = EBR::isBloggerMode();
     $this->my = $obj->my;
     // Assign the acl
     $this->acl = EB::acl();
 }
开发者ID:knigherrant,项目名称:decopatio,代码行数:51,代码来源:themes.php

示例10: getPosts

 /**
  * Retrieves a list of articles on the site
  *
  * @since	5.0
  * @access	public
  * @param	string
  * @return
  */
 public function getPosts($userId = null)
 {
     $db = EB::db();
     $query = array();
     $query[] = 'SELECT * FROM ' . $db->quoteName('#__easyblog_post');
     $query[] = 'WHERE ' . $db->quoteName('published') . '!=' . $db->Quote(EASYBLOG_POST_BLANK);
     $query[] = 'and ' . $db->quoteName('state') . '!=' . $db->Quote(EASYBLOG_POST_NORMAL);
     // If user is a site admin, we want to show everything
     if (!EB::isSiteAdmin()) {
         $user = JFactory::getUser($userId);
         $query[] = 'AND ' . $db->quoteName('created_by') . '=' . $db->Quote($user->id);
     }
     $query = implode(' ', $query);
     $db->setQuery($query);
     $result = $db->loadObjectList();
     return $result;
 }
开发者ID:knigherrant,项目名称:decopatio,代码行数:25,代码来源:mediamanager.php

示例11: compile

 /**
  * Allows caller to compile scripts on the site
  *
  * @since	5.0
  * @access	public
  * @param	string
  * @return	
  */
 public function compile()
 {
     if (!EB::isSiteAdmin()) {
         return JError::raiseError(JText::_('You had fun?'));
     }
     // See if the user wants to compile by specific sections
     $sections = $this->input->get('sections', array('admin', 'site', 'dashboard', 'composer'), 'word');
     // Should we be compiling and minifying the scripts?
     $minify = $this->input->get('minify', false, 'bool');
     $compiler = EB::compiler();
     $results = array();
     foreach ($sections as $section) {
         $result = $compiler->compile($section, $minify);
         $results[] = $result;
     }
     // XHR transport
     header('Content-type: text/x-json; UTF-8');
     echo json_encode($results);
     exit;
 }
开发者ID:knigherrant,项目名称:decopatio,代码行数:28,代码来源:compiler.php

示例12: display

 public function display($tmpl = null)
 {
     // Get the blog post
     $id = $this->input->get('id', 0, 'int');
     // Load the blog post now
     $blog = EB::table('Blog');
     $blog->load($id);
     // If blog id is not provided correctly, throw a 404 error page
     if (!$id || !$blog->id) {
         return JError::raiseError(404, JText::_('COM_EASYBLOG_ENTRY_BLOG_NOT_FOUND'));
     }
     // If the settings requires the user to be logged in, do not allow guests here.
     if ($this->my->id <= 0 && $this->config->get('main_login_read')) {
         $url = EB::_('index.php?option=com_easyblog&view=entry&id=' . $id . '&layout=login', false);
         return $this->app->redirect($url);
     }
     // Check if blog is password protected.
     if ($this->config->get('main_password_protect') && !empty($blog->blogpassword) && !$blog->verifyPassword()) {
         return JError::raiseError(404, JText::_('COM_EASYBLOG_ENTRY_BLOG_NOT_FOUND'));
     }
     // If the blog post is already deleted, we shouldn't let it to be accessible at all.
     if ($blog->isTrashed()) {
         return JError::raiseError(404, JText::_('COM_EASYBLOG_ENTRY_BLOG_NOT_FOUND'));
     }
     // Check if the blog post is trashed
     if (!$blog->isPublished() && $my->id != $blog->created_by && !EB::isSiteAdmin()) {
         return JError::raiseError(404, JText::_('COM_EASYBLOG_ENTRY_BLOG_NOT_FOUND'));
     }
     // If the viewer is the owner of the blog post, display a proper message
     if ($this->my->id == $blog->created_by && !$blog->isPublished()) {
         $notice = JText::_('COM_EASYBLOG_ENTRY_BLOG_UNPUBLISHED_VISIBLE_TO_OWNER');
     }
     if (EB::isSiteAdmin() && !$blog->isPublished()) {
         $notice = JText::_('COM_EASYBLOG_ENTRY_BLOG_UNPUBLISHED_VISIBLE_TO_ADMIN');
     }
     $blog = EB::formatter('post', $blog);
     $this->set('post', $blog);
     return parent::display();
 }
开发者ID:knigherrant,项目名称:decopatio,代码行数:39,代码来源:view.json.php

示例13: getPosts

 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');
 }
开发者ID:knigherrant,项目名称:decopatio,代码行数:36,代码来源:view.html.php

示例14: togglePublish

 /**
  * Toggle publish for posts
  *
  * @since	4.0
  * @access	public
  * @param	string
  * @return
  */
 public function togglePublish()
 {
     // Check for tokens
     EB::checkToken();
     // Build the return url
     $return = EBR::_('index.php?option=com_easyblog&view=dashboard&layout=entries', false);
     if ($this->getReturnURL()) {
         $return = $this->getReturnURL();
     }
     // Ensure that the user has access to publish items
     if ($this->my->guest) {
         return JError::raiseError(500, 'COM_EASYBLOG_NO_PERMISSION_TO_PUBLISH_OR_UNPUBLISH_BLOG');
     }
     // Get the task
     $task = $this->getTask();
     // Get id's
     $ids = $this->input->get('ids', '', 'array');
     foreach ($ids as $id) {
         $post = EB::post($id);
         if (!$this->acl->get('moderate_entry') && !$this->acl->get('publish_entry') && !EB::isSiteAdmin()) {
             $this->info->set(JText::_('COM_EASYBLOG_NO_PERMISSIONS_TO_MODERATE'), 'error');
             return $this->app->redirect($return);
         }
         if (method_exists($post, $task)) {
             $post->{$task}();
         }
     }
     $message = JText::_('COM_EASYBLOG_POSTS_PUBLISHED_SUCCESS');
     if ($task == 'unpublish') {
         $message = JText::_('COM_EASYBLOG_POSTS_UNPUBLISHED_SUCCESS');
     }
     // Set info data
     $this->info->set($message, 'success');
     return $this->app->redirect($return);
 }
开发者ID:BetterBetterBetter,项目名称:B3App,代码行数:43,代码来源:posts.php

示例15: save

 /**
  * Saves an author object
  *
  * @since	4.0
  * @access	public
  * @param	string
  * @return
  */
 public function save()
 {
     // Check for request forgeries
     EB::checkToken();
     // Check for acl rules.
     $this->checkAccess('user');
     // Create a new JUser object
     $id = $this->input->get('id', 0, 'int');
     $user = JFactory::getUser($id);
     // Get the user group's id
     $gid = $user->get('gid');
     // Get the posted data
     $post = $this->input->getArray('post');
     // Retrieve the username and password of the user
     $post['username'] = $this->input->get('username', '', 'default');
     $post['password'] = $this->input->get('password', '', 'default');
     $post['password2'] = $this->input->get('password2', '', 'default');
     // Get the data from Joomla's form
     if (isset($post['jform']['params'])) {
         $post['params'] = $post['jform']['params'];
         unset($post['jform']);
     }
     // Bind the post request on the user's object
     $state = $user->bind($post);
     // Default redirection url
     $redirect = 'index.php?option=com_easyblog&view=bloggers&layout=form&id=' . $user->id;
     if (!$state) {
         $this->info->set($user->getError(), 'error');
         return $this->app->redirect($redirect);
     }
     // Get the user's id
     if ($user->id == $this->my->id && $user->block) {
         $this->info->set(JText::_('You are not allowed to block yourself.'), 'error');
         return $this->app->redirect($redirect);
     }
     if ($user->authorise('core.admin') && $user->block) {
         $this->info->set(JText::_('You are not allowed to block a super administrator.'), 'error');
         return $this->app->redirect($redirect);
     }
     if ($user->authorise('core.admin') && !$this->my->authorise('core.admin')) {
         $this->info->set(JText::_('You cannot edit a Super User account.'), 'error');
         return $this->app->redirect($redirect);
     }
     $gid = $post['gid'];
     if (!empty($gid)) {
         $user->groups = array();
         foreach ($gid as $groupid) {
             $user->groups[$groupid] = $groupid;
         }
     }
     // Are we dealing with a new user which we need to create?
     $isNew = $user->id < 1;
     // Try to save the user now
     $state = $user->save();
     if (!$state) {
         $this->info->set($user->getError(), 'error');
         return $this->app->redirect($redirect);
     }
     // Update the user's session data if the current user is being edited to ensure that
     // the current user's data is correct
     if ($user->id == $this->my->id) {
         $session = JFactory::getSession();
         $session->set('user', $user);
     }
     // If this is a new record, ensure that the id is not set
     if ($isNew) {
         unset($post['id']);
     }
     // Set the proper permalink
     if (isset($post['user_permalink'])) {
         $post['permalink'] = $post['user_permalink'];
         unset($post['user_permalink']);
     }
     // Only allow site admins to add html codes for the description and biography
     if (EB::isSiteAdmin()) {
         $post['description'] = $this->input->get('description', '', 'html');
         $post['biography'] = $this->input->get('biography', '', 'html');
     }
     // After the user record is stored, we also want to update EasyBlog's records.
     $author = EB::user($user->id);
     // Bind the posted data
     $author->bind($post);
     // Get the file data
     $file = $this->input->files->get('avatar', '');
     if (isset($file['tmp_name']) && !empty($file['tmp_name'])) {
         $author->bindAvatar($file, EB::acl());
     }
     // Save other user parameters
     $registry = EB::registry();
     // Save google profile url
     if (isset($post['google_profile_url'])) {
         $registry->set('google_profile_url', $post['google_profile_url']);
//.........这里部分代码省略.........
开发者ID:knigherrant,项目名称:decopatio,代码行数:101,代码来源:bloggers.php


注:本文中的EB::isSiteAdmin方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。