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


PHP Local_group::getKV方法代码示例

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


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

示例1: prepare

 protected function prepare(array $args = array())
 {
     parent::prepare($args);
     $this->page = $this->arg('page') ? $this->arg('page') + 0 : 1;
     $nickname_arg = $this->arg('nickname');
     $nickname = common_canonical_nickname($nickname_arg);
     // Permanent redirect on non-canonical nickname
     if ($nickname_arg != $nickname) {
         $args = array('nickname' => $nickname);
         if ($this->page != 1) {
             $args['page'] = $this->page;
         }
         common_redirect(common_local_url('blockedfromgroup', $args), 301);
     }
     if (!$nickname) {
         // TRANS: Client error displayed when requesting a list of blocked users for a group without providing a group nickname.
         $this->clientError(_('No nickname.'), 404);
     }
     $local = Local_group::getKV('nickname', $nickname);
     if (!$local) {
         // TRANS: Client error displayed when requesting a list of blocked users for a non-local group.
         $this->clientError(_('No such group.'), 404);
     }
     $this->group = User_group::getKV('id', $local->group_id);
     if (!$this->group) {
         // TRANS: Client error displayed when requesting a list of blocked users for a non-existing group.
         $this->clientError(_('No such group.'), 404);
     }
     return true;
 }
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:30,代码来源:blockedfromgroup.php

示例2: 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)) {
         // TRANS: Client exception thrown when trying to view group inbox while not logged in.
         throw new ClientException(_m('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);
     }
     $localGroup = Local_group::getKV('nickname', $nickname);
     if (empty($localGroup)) {
         // TRANS: Client exception thrown when trying to view group inbox for non-existing group.
         throw new ClientException(_m('No such group.'), 404);
     }
     $this->group = User_group::getKV('id', $localGroup->group_id);
     if (empty($this->group)) {
         // TRANS: Client exception thrown when trying to view group inbox for non-existing group.
         throw new ClientException(_m('No such group.'), 404);
     }
     if (!$cur->isMember($this->group)) {
         // TRANS: Client exception thrown when trying to view group inbox while not a member.
         throw new ClientException(_m('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:bashrc,项目名称:gnusocial-debian,代码行数:42,代码来源:groupinbox.php

示例3: prepare

 function prepare($args)
 {
     parent::prepare($args);
     $nickname_arg = $this->arg('nickname');
     if (empty($nickname_arg)) {
         // TRANS: Client error displayed when requesting Friends of a Friend feed without providing a group nickname.
         $this->clientError(_('No such group.'), 404);
     }
     $this->nickname = common_canonical_nickname($nickname_arg);
     // Permanent redirect on non-canonical nickname
     if ($nickname_arg != $this->nickname) {
         common_redirect(common_local_url('foafgroup', array('nickname' => $this->nickname)), 301);
         return false;
     }
     $local = Local_group::getKV('nickname', $this->nickname);
     if (!$local) {
         // TRANS: Client error displayed when requesting Friends of a Friend feed for a non-local group.
         $this->clientError(_('No such group.'), 404);
     }
     $this->group = User_group::getKV('id', $local->group_id);
     if (!$this->group) {
         // TRANS: Client error displayed when requesting Friends of a Friend feed for a nickname that is not a group.
         $this->clientError(_('No such group.'), 404);
     }
     common_set_returnto($this->selfUrl());
     return true;
 }
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:27,代码来源:foafgroup.php

示例4: prepare

 /**
  * Prepare the action
  *
  * Reads and validates arguments and instantiates the attributes.
  *
  * @param array $args $_REQUEST args
  *
  * @return boolean success flag
  */
 function prepare($args)
 {
     parent::prepare($args);
     $nickname_arg = $this->arg('nickname');
     $nickname = common_canonical_nickname($nickname_arg);
     // Permanent redirect on non-canonical nickname
     if ($nickname_arg != $nickname) {
         $args = array('nickname' => $nickname);
         common_redirect(common_local_url('showgroup', $args), 301);
     }
     if (!$nickname) {
         // TRANS: Client error displayed when requesting a group RSS feed without providing a group nickname.
         $this->clientError(_('No nickname.'), 404);
     }
     $local = Local_group::getKV('nickname', $nickname);
     if (!$local) {
         // TRANS: Client error displayed when requesting a group RSS feed for group that does not exist.
         $this->clientError(_('No such group.'), 404);
     }
     $this->group = User_group::getKV('id', $local->group_id);
     if (!$this->group) {
         // TRANS: Client error displayed when requesting a group RSS feed for an object that is not a group.
         $this->clientError(_('No such group.'), 404);
     }
     $this->notices = $this->getNotices($this->limit);
     return true;
 }
开发者ID:phpsource,项目名称:gnu-social,代码行数:36,代码来源:grouprss.php

示例5: prepare

 protected function prepare(array $args = array())
 {
     parent::prepare($args);
     $this->page = $this->arg('page') ? $this->arg('page') + 0 : 1;
     $nickname_arg = $this->arg('nickname');
     $nickname = common_canonical_nickname($nickname_arg);
     // Permanent redirect on non-canonical nickname
     if ($nickname_arg != $nickname) {
         $args = array('nickname' => $nickname);
         if ($this->page != 1) {
             $args['page'] = $this->page;
         }
         common_redirect(common_local_url('groupqueue', $args), 301);
     }
     if (!$nickname) {
         // TRANS: Client error displayed when trying to view group members without providing a group nickname.
         $this->clientError(_('No nickname.'), 404);
     }
     $local = Local_group::getKV('nickname', $nickname);
     if (!$local) {
         // TRANS: Client error displayed when trying to view group members for a non-existing group.
         $this->clientError(_('No such group.'), 404);
     }
     $this->group = User_group::getKV('id', $local->group_id);
     if (!$this->group) {
         // TRANS: Client error displayed when trying to view group members for an object that is not a group.
         $this->clientError(_('No such group.'), 404);
     }
     $cur = common_current_user();
     if (!$cur || !$cur->isAdmin($this->group)) {
         // TRANS: Client error displayed when trying to approve group applicants without being a group administrator.
         $this->clientError(_('Only the group admin may approve users.'));
     }
     return true;
 }
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:35,代码来源:groupqueue.php

示例6: doPreparation

 protected function doPreparation()
 {
     // showstream requires a nickname
     $nickname_arg = $this->trimmed('nickname');
     $nickname = common_canonical_nickname($nickname_arg);
     // Permanent redirect on non-canonical nickname
     if ($nickname_arg != $nickname) {
         $args = array('nickname' => $nickname);
         if ($this->arg('page') && $this->arg('page') != 1) {
             $args['page'] = $this->arg['page'];
         }
         common_redirect(common_local_url($this->getActionName(), $args), 301);
     }
     try {
         $user = User::getByNickname($nickname);
     } catch (NoSuchUserException $e) {
         $group = Local_group::getKV('nickname', $nickname);
         if ($group instanceof Local_group) {
             common_redirect($group->getProfile()->getUrl());
         }
         // No user nor group found, throw the NoSuchUserException again
         throw $e;
     }
     $this->target = $user->getProfile();
 }
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:25,代码来源:profileaction.php

示例7: prepare

 /**
  * Prepare to run
  */
 function prepare($args)
 {
     parent::prepare($args);
     if (!common_logged_in()) {
         // TRANS: Client error displayed when trying to leave a group while not logged in.
         $this->clientError(_('You must be logged in to leave a group.'));
     }
     $nickname_arg = $this->trimmed('nickname');
     $id = intval($this->arg('id'));
     if ($id) {
         $this->group = User_group::getKV('id', $id);
     } else {
         if ($nickname_arg) {
             $nickname = common_canonical_nickname($nickname_arg);
             // Permanent redirect on non-canonical nickname
             if ($nickname_arg != $nickname) {
                 $args = array('nickname' => $nickname);
                 common_redirect(common_local_url('leavegroup', $args), 301);
             }
             $local = Local_group::getKV('nickname', $nickname);
             if (!$local) {
                 // TRANS: Client error displayed when trying to leave a non-local group.
                 $this->clientError(_('No such group.'), 404);
             }
             $this->group = User_group::getKV('id', $local->group_id);
         } else {
             // TRANS: Client error displayed when trying to leave a group without providing a group name or group ID.
             $this->clientError(_('No nickname or ID.'), 404);
         }
     }
     if (!$this->group) {
         // TRANS: Client error displayed when trying to leave a non-existing group.
         $this->clientError(_('No such group.'), 404);
     }
     $cur = common_current_user();
     if (empty($cur)) {
         // TRANS: Client error displayed when trying to leave a group while not logged in.
         $this->clientError(_('Must be logged in.'), 403);
     }
     if ($this->arg('profile_id')) {
         if ($cur->isAdmin($this->group)) {
             $this->profile = Profile::getKV('id', $this->arg('profile_id'));
         } else {
             // TRANS: Client error displayed when trying to approve or cancel a group join request without
             // TRANS: being a group administrator.
             $this->clientError(_('Only group admin can approve or cancel join requests.'), 403);
         }
     } else {
         $this->profile = $cur->getProfile();
     }
     $this->request = Group_join_queue::pkeyGet(array('profile_id' => $this->profile->id, 'group_id' => $this->group->id));
     if (empty($this->request)) {
         // TRANS: Client error displayed when trying to approve a non-existing group join request.
         // TRANS: %s is a user nickname.
         $this->clientError(sprintf(_('%s is not in the moderation queue for this group.'), $this->profile->nickname), 403);
     }
     return true;
 }
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:61,代码来源:cancelgroup.php

示例8: prepare

 /**
  * Prepare to run
  */
 protected function prepare(array $args = array())
 {
     parent::prepare($args);
     if (!common_logged_in()) {
         // TRANS: Client error displayed when trying to join a group while not logged in.
         $this->clientError(_('You must be logged in to join a group.'));
     }
     $nickname_arg = $this->trimmed('nickname');
     $id = intval($this->arg('id'));
     if ($id) {
         $this->group = User_group::getKV('id', $id);
     } else {
         if ($nickname_arg) {
             $nickname = common_canonical_nickname($nickname_arg);
             // Permanent redirect on non-canonical nickname
             if ($nickname_arg != $nickname) {
                 $args = array('nickname' => $nickname);
                 common_redirect(common_local_url('leavegroup', $args), 301);
             }
             $local = Local_group::getKV('nickname', $nickname);
             if (!$local) {
                 // TRANS: Client error displayed when trying to join a non-local group.
                 $this->clientError(_('No such group.'), 404);
             }
             $this->group = User_group::getKV('id', $local->group_id);
         } else {
             // TRANS: Client error displayed when trying to join a group without providing a group name or group ID.
             $this->clientError(_('No nickname or ID.'), 404);
         }
     }
     if (!$this->group) {
         // TRANS: Client error displayed when trying to join a non-existing group.
         $this->clientError(_('No such group.'), 404);
     }
     if ($this->scoped->isMember($this->group)) {
         // TRANS: Client error displayed when trying to join a group while already a member.
         $this->clientError(_('You are already a member of that group.'), 403);
     }
     if (Group_block::isBlocked($this->group, $this->scoped)) {
         // TRANS: Client error displayed when trying to join a group while being blocked form joining it.
         $this->clientError(_('You have been blocked from that group by the admin.'), 403);
     }
     return true;
 }
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:47,代码来源:joingroup.php

示例9: prepare

 /**
  * Prepare to run
  *
  * @fixme merge common setup code with other group actions
  * @fixme allow group admins to delete their own groups
  */
 function prepare($args)
 {
     parent::prepare($args);
     if (!common_logged_in()) {
         // TRANS: Client error when trying to delete group while not logged in.
         $this->clientError(_('You must be logged in to delete a group.'));
     }
     $nickname_arg = $this->trimmed('nickname');
     $id = intval($this->arg('id'));
     if ($id) {
         $this->group = User_group::getKV('id', $id);
     } else {
         if ($nickname_arg) {
             $nickname = common_canonical_nickname($nickname_arg);
             // Permanent redirect on non-canonical nickname
             if ($nickname_arg != $nickname) {
                 $args = array('nickname' => $nickname);
                 common_redirect(common_local_url('leavegroup', $args), 301);
             }
             $local = Local_group::getKV('nickname', $nickname);
             if (!$local) {
                 // TRANS: Client error when trying to delete a non-local group.
                 $this->clientError(_('No such group.'), 404);
             }
             $this->group = User_group::getKV('id', $local->group_id);
         } else {
             // TRANS: Client error when trying to delete a group without providing a nickname or ID for the group.
             $this->clientError(_('No nickname or ID.'), 404);
         }
     }
     if (!$this->group) {
         // TRANS: Client error when trying to delete a non-existing group.
         $this->clientError(_('No such group.'), 404);
     }
     $cur = common_current_user();
     if (!$cur->hasRight(Right::DELETEGROUP)) {
         // TRANS: Client error when trying to delete a group without having the rights to delete it.
         $this->clientError(_('You are not allowed to delete this group.'), 403);
     }
     return true;
 }
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:47,代码来源:deletegroup.php

示例10: doStreamPreparation

 protected function doStreamPreparation()
 {
     $nickname_arg = $this->arg('nickname');
     $nickname = common_canonical_nickname($nickname_arg);
     // Permanent redirect on non-canonical nickname
     if ($nickname_arg != $nickname) {
         $args = array('nickname' => $nickname);
         common_redirect(common_local_url('showgroup', $args), 301);
     }
     if (!$nickname) {
         // TRANS: Client error displayed when requesting a group RSS feed without providing a group nickname.
         $this->clientError(_('No nickname.'), 404);
     }
     $local = Local_group::getKV('nickname', $nickname);
     if (!$local instanceof Local_group) {
         // TRANS: Client error displayed when requesting a group RSS feed for group that does not exist.
         $this->clientError(_('No such group.'), 404);
     }
     $this->group = $local->getGroup();
     $this->target = $this->group->getProfile();
 }
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:21,代码来源:grouprss.php

示例11: prepare

 /**
  * Prepare to run
  */
 protected function prepare(array $args = array())
 {
     parent::prepare($args);
     if (!common_logged_in()) {
         // TRANS: Client error displayed trying to edit a group while not logged in.
         $this->clientError(_('You must be logged in to create a group.'));
     }
     $nickname_arg = $this->trimmed('nickname');
     $nickname = common_canonical_nickname($nickname_arg);
     // Permanent redirect on non-canonical nickname
     if ($nickname_arg != $nickname) {
         $args = array('nickname' => $nickname);
         common_redirect(common_local_url('editgroup', $args), 301);
     }
     if (!$nickname) {
         // TRANS: Client error displayed trying to edit a group while not proving a nickname for the group to edit.
         $this->clientError(_('No nickname.'), 404);
     }
     $groupid = $this->trimmed('groupid');
     if ($groupid) {
         $this->group = User_group::getKV('id', $groupid);
     } else {
         $local = Local_group::getKV('nickname', $nickname);
         if ($local) {
             $this->group = User_group::getKV('id', $local->group_id);
         }
     }
     if (!$this->group) {
         // TRANS: Client error displayed trying to edit a non-existing group.
         $this->clientError(_('No such group.'), 404);
     }
     $cur = common_current_user();
     if (!$cur->isAdmin($this->group)) {
         // TRANS: Client error displayed trying to edit a group while not being a group admin.
         $this->clientError(_('You must be an admin to edit the group.'), 403);
     }
     return true;
 }
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:41,代码来源:editgroup.php

示例12: prepare

 protected function prepare(array $args = array())
 {
     parent::prepare($args);
     $nickname_arg = $this->arg('nickname');
     $nickname = common_canonical_nickname($nickname_arg);
     // Permanent redirect on non-canonical nickname
     if ($nickname_arg != $nickname) {
         $args = array('nickname' => $nickname);
         if ($this->page != 1) {
             $args['page'] = $this->page;
         }
         common_redirect(common_local_url('showgroup', $args), 301);
     }
     if (!$nickname) {
         // TRANS: Client error displayed if no nickname argument was given requesting a group page.
         $this->clientError(_('No nickname.'), 404);
     }
     $local = Local_group::getKV('nickname', $nickname);
     if (!$local) {
         $alias = Group_alias::getKV('alias', $nickname);
         if ($alias) {
             $args = array('id' => $alias->group_id);
             if ($this->page != 1) {
                 $args['page'] = $this->page;
             }
             common_redirect(common_local_url('groupbyid', $args), 301);
         } else {
             common_log(LOG_NOTICE, "Couldn't find local group for nickname '{$nickname}'");
             // TRANS: Client error displayed if no remote group with a given name was found requesting group page.
             $this->clientError(_('No such group.'), 404);
         }
     }
     $this->group = User_group::getKV('id', $local->group_id);
     if (!$this->group instanceof User_group) {
         // TRANS: Client error displayed if no local group with a given name was found requesting group page.
         $this->clientError(_('No such group.'), 404);
     }
 }
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:38,代码来源:groupaction.php

示例13: 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 send a private group message while not logged in.
         throw new ClientException(_m('Must be logged in.'), 403);
     }
     if (!$this->user->hasRight(Right::NEWMESSAGE)) {
         // TRANS: Exception thrown when user %s is not allowed to send a private group message.
         throw new Exception(sprintf(_m('User %s is not allowed to send private messages.'), $this->user->nickname));
     }
     $nicknameArg = $this->trimmed('nickname');
     $nickname = common_canonical_nickname($nicknameArg);
     if ($nickname != $nicknameArg) {
         $url = common_local_url('newgroupmessage', array('nickname' => $nickname));
         common_redirect($url, 301);
     }
     $localGroup = Local_group::getKV('nickname', $nickname);
     if (empty($localGroup)) {
         // TRANS: Client exception thrown when trying to send a private group message to a non-existing group.
         throw new ClientException(_m('No such group.'), 404);
     }
     $this->group = User_group::getKV('id', $localGroup->group_id);
     if (empty($this->group)) {
         // TRANS: Client exception thrown when trying to send a private group message to a non-existing group.
         throw new ClientException(_m('No such group.'), 404);
     }
     // This throws an exception on error
     Group_privacy_settings::ensurePost($this->user, $this->group);
     // If we're posted to, check session token and get text
     if ($this->isPost()) {
         $this->checkSessionToken();
         $this->text = $this->trimmed('content');
     }
     return true;
 }
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:44,代码来源:newgroupmessage.php

示例14: doPreparation

 protected function doPreparation()
 {
     // showstream requires a nickname
     $nickname_arg = $this->arg('nickname');
     $nickname = common_canonical_nickname($nickname_arg);
     // Permanent redirect on non-canonical nickname
     if ($nickname_arg != $nickname) {
         $args = array('nickname' => $nickname);
         if ($this->arg('page') && $this->arg('page') != 1) {
             $args['page'] = $this->arg['page'];
         }
         common_redirect(common_local_url($this->getActionName(), $args), 301);
     }
     $this->user = User::getKV('nickname', $nickname);
     if (!$this->user) {
         $group = Local_group::getKV('nickname', $nickname);
         if ($group instanceof Local_group) {
             common_redirect($group->getProfile()->getUrl());
         }
         // TRANS: Client error displayed when calling a profile action without specifying a user.
         $this->clientError(_('No such user.'), 404);
     }
     $this->target = $this->user->getProfile();
 }
开发者ID:phpsource,项目名称:gnu-social,代码行数:24,代码来源:showstream.php

示例15: recognizedFeed

 /**
  * Check whether the given URL represents one of our canonical
  * user or group Atom feeds.
  *
  * @param string $feed URL
  * @return boolean true if it matches, false if not a recognized local feed
  * @throws exception if local entity does not exist
  */
 protected function recognizedFeed($feed)
 {
     $matches = array();
     // Simple mapping to local ID for user or group
     if (preg_match('!/(\\d+)\\.atom$!', $feed, $matches)) {
         $id = $matches[1];
         $params = array('id' => $id, 'format' => 'atom');
         // Double-check against locally generated URLs
         switch ($feed) {
             case common_local_url('ApiTimelineUser', $params):
                 $user = User::getKV('id', $id);
                 if (!$user instanceof User) {
                     // TRANS: Client exception. %s is a feed URL.
                     throw new ClientException(sprintf(_m('Invalid hub.topic "%s". User does not exist.'), $feed));
                 }
                 return true;
             case common_local_url('ApiTimelineGroup', $params):
                 $group = Local_group::getKV('group_id', $id);
                 if (!$group instanceof Local_group) {
                     // TRANS: Client exception. %s is a feed URL.
                     throw new ClientException(sprintf(_m('Invalid hub.topic "%s". Local_group does not exist.'), $feed));
                 }
                 return true;
         }
         common_debug("Feed was not recognized by any local User or Group Atom feed URLs: {$feed}");
         return false;
     }
     // Profile lists are unique per user, so we need both IDs
     if (preg_match('!/(\\d+)/lists/(\\d+)/statuses\\.atom$!', $feed, $matches)) {
         $user = $matches[1];
         $id = $matches[2];
         $params = array('user' => $user, 'id' => $id, 'format' => 'atom');
         // Double-check against locally generated URLs
         switch ($feed) {
             case common_local_url('ApiTimelineList', $params):
                 $list = Profile_list::getKV('id', $id);
                 $user = User::getKV('id', $user);
                 if (!$list instanceof Profile_list || !$user instanceof User || $list->tagger != $user->id) {
                     // TRANS: Client exception. %s is a feed URL.
                     throw new ClientException(sprintf(_m('Invalid hub.topic %s; list does not exist.'), $feed));
                 }
                 return true;
         }
         common_debug("Feed was not recognized by any local Profile_list Atom feed URL: {$feed}");
         return false;
     }
     common_debug("Unknown feed URL structure, can't match against local user, group or profile_list: {$feed}");
     return false;
 }
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:57,代码来源:pushhub.php


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