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


PHP common_current_user函数代码示例

本文整理汇总了PHP中common_current_user函数的典型用法代码示例。如果您正苦于以下问题:PHP common_current_user函数的具体用法?PHP common_current_user怎么用?PHP common_current_user使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: prepare

 function prepare($args)
 {
     parent::prepare($args);
     $this->user = common_current_user();
     if (empty($this->user)) {
         // TRANS: Client error displayed when trying to repeat a notice while not logged in.
         $this->clientError(_('Only logged-in users can repeat notices.'));
         return false;
     }
     $id = $this->trimmed('notice');
     if (empty($id)) {
         // TRANS: Client error displayed when trying to repeat a notice while not providing a notice ID.
         $this->clientError(_('No notice specified.'));
         return false;
     }
     $this->notice = Notice::staticGet('id', $id);
     if (empty($this->notice)) {
         // TRANS: Client error displayed when trying to repeat a non-existing notice.
         $this->clientError(_('No notice specified.'));
         return false;
     }
     $token = $this->trimmed('token-' . $id);
     if (empty($token) || $token != common_session_token()) {
         // TRANS: Client error displayed when the session token does not match or is not given.
         $this->clientError(_('There was a problem with your session token. Try again, please.'));
         return false;
     }
     return true;
 }
开发者ID:Grasia,项目名称:bolotweet,代码行数:29,代码来源:repeat.php

示例2: showBody

 /**
  * Show body - override to add a special CSS class for the pin pages's
  * "desktop mode" (minimal display)
  *
  * Calls template methods
  *
  * @return nothing
  */
 function showBody()
 {
     $bodyClasses = array();
     if ($this->desktopMode) {
         $bodyClasses[] = 'oauth-desktop-mode';
     }
     if (common_current_user()) {
         $bodyClasses[] = 'user_in';
     }
     $attrs = array('id' => strtolower($this->trimmed('action')));
     if (!empty($bodyClasses)) {
         $attrs['class'] = implode(' ', $bodyClasses);
     }
     $this->elementStart('body', $attrs);
     $this->elementStart('div', array('id' => 'wrap'));
     if (Event::handle('StartShowHeader', array($this))) {
         $this->showHeader();
         Event::handle('EndShowHeader', array($this));
     }
     $this->showCore();
     if (Event::handle('StartShowFooter', array($this))) {
         $this->showFooter();
         Event::handle('EndShowFooter', array($this));
     }
     $this->elementEnd('div');
     $this->showScripts();
     $this->elementEnd('body');
 }
开发者ID:microcosmx,项目名称:experiments,代码行数:36,代码来源:apioauthpin.php

示例3: prepare

 /**
  * Take arguments for running
  *
  * @param array $args $_REQUEST args
  *
  * @return boolean success flag
  */
 function prepare($args)
 {
     if (!parent::prepare($args)) {
         return false;
     }
     if (!common_logged_in()) {
         // TRANS: Client error displayed trying to delete an application while not logged in.
         $this->clientError(_('You must be logged in to delete an application.'));
         return false;
     }
     $id = (int) $this->arg('id');
     $this->app = Oauth_application::staticGet('id', $id);
     if (empty($this->app)) {
         // TRANS: Client error displayed trying to delete an application that does not exist.
         $this->clientError(_('Application not found.'));
         return false;
     }
     $cur = common_current_user();
     if ($cur->id != $this->app->owner) {
         // TRANS: Client error displayed trying to delete an application the current user does not own.
         $this->clientError(_('You are not the owner of this application.'), 401);
         return false;
     }
     return true;
 }
开发者ID:microcosmx,项目名称:experiments,代码行数:32,代码来源:deleteapplication.php

示例4: prepare

 /**
  * Check parameters
  *
  * @param array $args action arguments (URL, GET, POST)
  *
  * @return boolean success flag
  */
 function prepare($args)
 {
     if (!parent::prepare($args)) {
         return false;
     }
     $this->role = $this->arg('role');
     if (!Profile_role::isValid($this->role)) {
         $this->clientError(_('Invalid role.'));
         return false;
     }
     if (!Profile_role::isSettable($this->role)) {
         $this->clientError(_('This role is reserved and cannot be set.'));
         return false;
     }
     $cur = common_current_user();
     assert(!empty($cur));
     // checked by parent
     if (!$cur->hasRight(Right::REVOKEROLE)) {
         $this->clientError(_('You cannot revoke user roles on this site.'));
         return false;
     }
     assert(!empty($this->profile));
     // checked by parent
     if (!$this->profile->hasRole($this->role)) {
         $this->clientError(_("User doesn't have this role."));
         return false;
     }
     return true;
 }
开发者ID:microcosmx,项目名称:experiments,代码行数:36,代码来源:revokerole.php

示例5: handle

 /**
  * Handle input and output a page
  *
  * @param array $args $_REQUEST arguments
  *
  * @return void
  */
 function handle($args)
 {
     parent::handle($args);
     if (!common_logged_in()) {
         $this->clientError(_('Not logged in.'));
         return;
     } else {
         if (!common_is_real_login()) {
             // Cookie theft means that automatic logins can't
             // change important settings or see private info, and
             // _all_ our settings are important
             common_set_returnto($this->selfUrl());
             $user = common_current_user();
             if (Event::handle('RedirectToLogin', array($this, $user))) {
                 common_redirect(common_local_url('login'), 303);
             }
         } else {
             if ($_SERVER['REQUEST_METHOD'] == 'POST') {
                 $this->handlePost();
             } else {
                 $this->showForm();
             }
         }
     }
 }
开发者ID:microcosmx,项目名称:experiments,代码行数:32,代码来源:settingsaction.php

示例6: prepare

 /**
  * Check parameters
  *
  * @param array $args action arguments (URL, GET, POST)
  *
  * @return boolean success flag
  */
 function prepare($args)
 {
     if (!parent::prepare($args)) {
         return false;
     }
     $this->role = $this->arg('role');
     if (!Profile_role::isValid($this->role)) {
         // TRANS: Client error displayed when trying to revoke an invalid role.
         $this->clientError(_('Invalid role.'));
     }
     if (!Profile_role::isSettable($this->role)) {
         // TRANS: Client error displayed when trying to revoke a reserved role.
         $this->clientError(_('This role is reserved and cannot be set.'));
     }
     $cur = common_current_user();
     assert(!empty($cur));
     // checked by parent
     if (!$cur->hasRight(Right::REVOKEROLE)) {
         // TRANS: Client error displayed when trying to revoke a role without having the right to do that.
         $this->clientError(_('You cannot revoke user roles on this site.'));
     }
     assert(!empty($this->profile));
     // checked by parent
     if (!$this->profile->hasRole($this->role)) {
         // TRANS: Client error displayed when trying to revoke a role that is not set.
         $this->clientError(_('User does not have this role.'));
     }
     return true;
 }
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:36,代码来源:revokerole.php

示例7: prepare

 /**
  * For initializing members of the class.
  *
  * @param array $argarray misc. arguments
  *
  * @return boolean true
  */
 function prepare($argarray)
 {
     parent::prepare($argarray);
     $this->user = common_current_user();
     if (empty($this->user)) {
         // TRANS: Client exception thrown when trying to view group private messages without being logged in.
         throw new ClientException(_m('Only logged-in users can view private messages.'), 403);
     }
     $id = $this->trimmed('id');
     $this->gm = Group_message::getKV('id', $id);
     if (empty($this->gm)) {
         // TRANS: Client exception thrown when trying to view a non-existing group private message.
         throw new ClientException(_m('No such message.'), 404);
     }
     $this->group = User_group::getKV('id', $this->gm->to_group);
     if (empty($this->group)) {
         // TRANS: Server exception thrown when trying to view group private messages for a non-exsting group.
         throw new ServerException(_m('Group not found.'));
     }
     if (!$this->user->isMember($this->group)) {
         // TRANS: Client exception thrown when trying to view a group private message without being a group member.
         throw new ClientException(_m('Cannot read message.'), 403);
     }
     $this->sender = Profile::getKV('id', $this->gm->from_profile);
     if (empty($this->sender)) {
         // TRANS: Server exception thrown when trying to view a group private message without a sender.
         throw new ServerException(_m('No sender found.'));
     }
     return true;
 }
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:37,代码来源:showgroupmessage.php

示例8: prepare

 /**
  * Check pre-requisites and instantiate attributes
  *
  * @param Array $args array of arguments (URL, GET, POST)
  *
  * @return boolean success flag
  */
 function prepare($args)
 {
     parent::prepare($args);
     // CSRF protection
     $token = $this->trimmed('token');
     if (!$token || $token != common_session_token()) {
         // TRANS: Client error displayed when the session token does not match or is not given.
         $this->clientError(_('There was a problem with your session token.' . ' Try again, please.'));
         return false;
     }
     // Only for logged-in users
     $this->user = common_current_user();
     if (empty($this->user)) {
         // TRANS: Error message displayed when trying to perform an action that requires a logged in user.
         $this->clientError(_('Not logged in.'));
         return false;
     }
     $id = $this->arg('peopletag_id');
     $this->peopletag = Profile_list::staticGet('id', $id);
     if (empty($this->peopletag)) {
         // TRANS: Client error displayed trying to reference a non-existing list.
         $this->clientError(_('No such list.'));
         return false;
     }
     $field = $this->arg('field');
     if (!in_array($field, array('fulltext', 'nickname', 'fullname', 'description', 'location', 'uri'))) {
         // TRANS: Client error displayed when trying to add an unindentified field to profile.
         // TRANS: %s is a field name.
         $this->clientError(sprintf(_('Unidentified field %s.'), htmlspecialchars($field)), 404);
         return false;
     }
     $this->field = $field;
     return true;
 }
开发者ID:Grasia,项目名称:bolotweet,代码行数:41,代码来源:profilecompletion.php

示例9: prepare

 /**
  * For initializing members of the class.
  *
  * @param array $argarray misc. arguments
  *
  * @return boolean true
  */
 function prepare($argarray)
 {
     parent::prepare($argarray);
     if ($this->boolean('ajax')) {
         GNUsocial::setApi(true);
     }
     $this->user = common_current_user();
     if (empty($this->user)) {
         // TRANS: Client exception thrown trying to respond to a poll while not logged in.
         throw new ClientException(_m('You must be logged in to respond to a poll.'), 403);
     }
     if ($this->isPost()) {
         $this->checkSessionToken();
     }
     $id = $this->trimmed('id');
     $this->poll = Poll::getKV('id', $id);
     if (empty($this->poll)) {
         // TRANS: Client exception thrown trying to respond to a non-existing poll.
         throw new ClientException(_m('Invalid or missing poll.'), 404);
     }
     $selection = intval($this->trimmed('pollselection'));
     if ($selection < 1 || $selection > count($this->poll->getOptions())) {
         // TRANS: Client exception thrown responding to a poll with an invalid answer.
         throw new ClientException(_m('Invalid poll selection.'));
     }
     $this->selection = $selection;
     return true;
 }
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:35,代码来源:respondpoll.php

示例10: prepare

 /**
  * For initializing members of the class.
  *
  * @param array $argarray misc. arguments
  *
  * @return boolean true
  */
 function prepare($argarray)
 {
     parent::prepare($argarray);
     $cur = common_current_user();
     if (empty($cur)) {
         throw new ClientException(_('Only for logged-in users'), 403);
     }
     $nicknameArg = $this->trimmed('nickname');
     $nickname = common_canonical_nickname($nicknameArg);
     if ($nickname != $nicknameArg) {
         $url = common_local_url('groupinbox', array('nickname' => $nickname));
         common_redirect($url);
         return false;
     }
     $localGroup = Local_group::staticGet('nickname', $nickname);
     if (empty($localGroup)) {
         throw new ClientException(_('No such group'), 404);
     }
     $this->group = User_group::staticGet('id', $localGroup->group_id);
     if (empty($this->group)) {
         throw new ClientException(_('No such group'), 404);
     }
     if (!$cur->isMember($this->group)) {
         throw new ClientException(_('Only for members'), 403);
     }
     $this->page = $this->trimmed('page');
     if (!$this->page) {
         $this->page = 1;
     }
     $this->gm = Group_message::forGroup($this->group, ($this->page - 1) * MESSAGES_PER_PAGE, MESSAGES_PER_PAGE + 1);
     return true;
 }
开发者ID:microcosmx,项目名称:experiments,代码行数:39,代码来源:groupinbox.php

示例11: prepare

 /**
  * Check pre-requisites and instantiate attributes
  *
  * @param Array $args array of arguments (URL, GET, POST)
  *
  * @return boolean success flag
  */
 function prepare($args)
 {
     parent::prepare($args);
     // CSRF protection
     $token = $this->trimmed('token');
     if (!$token || $token != common_session_token()) {
         // TRANS: Client error displayed when the session token does not match or is not given.
         $this->clientError(_('There was a problem with your session token.' . ' Try again, please.'));
     }
     // Only for logged-in users
     $this->user = common_current_user();
     if (empty($this->user)) {
         // TRANS: Error message displayed when trying to perform an action that requires a logged in user.
         $this->clientError(_('Not logged in.'));
     }
     // Profile to subscribe to
     $tagged_id = $this->arg('tagged');
     $this->tagged = Profile::getKV('id', $tagged_id);
     if (empty($this->tagged)) {
         // TRANS: Client error displayed trying to perform an action related to a non-existing profile.
         $this->clientError(_('No such profile.'));
     }
     $id = $this->arg('peopletag_id');
     $this->peopletag = Profile_list::getKV('id', $id);
     if (empty($this->peopletag)) {
         // TRANS: Client error displayed trying to reference a non-existing list.
         $this->clientError(_('No such list.'));
     }
     return true;
 }
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:37,代码来源:addpeopletag.php

示例12: prepare

 /**
  * Take arguments for running
  *
  * @param array $args $_REQUEST args
  *
  * @return boolean success flag
  */
 function prepare($args)
 {
     parent::prepare($args);
     $this->checkSessionToken();
     if (!common_logged_in()) {
         if ($_SERVER['REQUEST_METHOD'] == 'POST') {
             $this->clientError(_('Not logged in.'));
         } else {
             // Redirect to login.
             common_set_returnto($this->selfUrl());
             $user = common_current_user();
             if (Event::handle('RedirectToLogin', array($this, $user))) {
                 common_redirect(common_local_url('login'), 303);
             }
         }
         return false;
     }
     $id = $this->trimmed('profileid');
     if (!$id) {
         $this->clientError(_('No profile specified.'));
         return false;
     }
     $this->profile = Profile::staticGet('id', $id);
     if (!$this->profile) {
         $this->clientError(_('No profile with that ID.'));
         return false;
     }
     return true;
 }
开发者ID:stevertiqo,项目名称:StatusNet,代码行数:36,代码来源:profileformaction.php

示例13: prepare

 /**
  * Prepare for the action
  *
  * We check to see that the user is logged in, has
  * authenticated in this session, and has the right
  * to configure the site.
  *
  * @param array $args Array of arguments from Web driver
  *
  * @return boolean success flag
  */
 function prepare($args)
 {
     parent::prepare($args);
     // User must be logged in.
     if (!common_logged_in()) {
         // TRANS: Error message displayed when trying to perform an action that requires a logged in user.
         $this->clientError(_('Not logged in.'));
     }
     $user = common_current_user();
     // ...because they're logged in
     assert(!empty($user));
     // It must be a "real" login, not saved cookie login
     if (!common_is_real_login()) {
         // Cookie theft is too easy; we require automatic
         // logins to re-authenticate before admining the site
         common_set_returnto($this->selfUrl());
         if (Event::handle('RedirectToLogin', array($this, $user))) {
             common_redirect(common_local_url('login'), 303);
         }
     }
     // User must have the right to change admin settings
     if (!$user->hasRight(Right::CONFIGURESITE)) {
         // TRANS: Client error message thrown when a user tries to change admin settings but has no access rights.
         $this->clientError(_('You cannot make changes to this site.'));
     }
     // This panel must be enabled
     $name = $this->trimmed('action');
     $name = mb_substr($name, 0, -10);
     if (!self::canAdmin($name)) {
         // TRANS: Client error message throw when a certain panel's settings cannot be changed.
         $this->clientError(_('Changes to that panel are not allowed.'), 403);
     }
     return true;
 }
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:45,代码来源:adminpanelaction.php

示例14: prepare

 /**
  * For initializing members of the class.
  *
  * @param array $argarray misc. arguments
  *
  * @return boolean true
  */
 function prepare($argarray)
 {
     parent::prepare($argarray);
     $this->user = common_current_user();
     if (empty($this->user)) {
         throw new ClientException(_('Only logged-in users can view private messages.'), 403);
     }
     $id = $this->trimmed('id');
     $this->gm = Group_message::staticGet('id', $id);
     if (empty($this->gm)) {
         throw new ClientException(_('No such message'), 404);
     }
     $this->group = User_group::staticGet('id', $this->gm->to_group);
     if (empty($this->group)) {
         throw new ServerException(_('Group not found.'));
     }
     if (!$this->user->isMember($this->group)) {
         throw new ClientException(_('Cannot read message.'), 403);
     }
     $this->sender = Profile::staticGet('id', $this->gm->from_profile);
     if (empty($this->sender)) {
         throw new ServerException(_('No sender found.'));
     }
     return true;
 }
开发者ID:microcosmx,项目名称:experiments,代码行数:32,代码来源:showgroupmessage.php

示例15: showContent

 function showContent()
 {
     $cur = common_current_user();
     $profile = $cur->getProfile();
     $widget = new ExtendedProfileWidget($this, $profile, ExtendedProfileWidget::EDITABLE);
     $widget->show();
 }
开发者ID:microcosmx,项目名称:experiments,代码行数:7,代码来源:profiledetailsettingsaction.php


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