本文整理汇总了PHP中Local_group类的典型用法代码示例。如果您正苦于以下问题:PHP Local_group类的具体用法?PHP Local_group怎么用?PHP Local_group使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Local_group类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: prepare
function prepare($args)
{
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('groupmembers', $args), 301);
return false;
}
if (!$nickname) {
$this->clientError(_('No nickname.'), 404);
return false;
}
$local = Local_group::staticGet('nickname', $nickname);
if (!$local) {
$this->clientError(_('No such group.'), 404);
return false;
}
$this->group = User_group::staticGet('id', $local->group_id);
if (!$this->group) {
$this->clientError(_('No such group.'), 404);
return false;
}
return true;
}
示例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;
}
示例3: importGroup
/**
* Load or create an imported group from Yammer data.
*
* @param object $item loaded JSON data for Yammer importer
* @return User_group
*/
function importGroup($item)
{
$data = $this->prepGroup($item);
$nickname = $data['options']['nickname'];
$groupId = $this->findImportedGroup($data['orig_id']);
if ($groupId) {
return User_group::staticGet('id', $groupId);
} else {
$local = Local_group::staticGet('nickname', $nickname);
if ($local) {
common_log(LOG_WARN, "Copying Yammer group info onto existing group {$nickname}");
$group = User_group::staticGet('id', $local->group_id);
$this->savePropertiesOn($group, $data['options'], array('fullname', 'description'));
} else {
$group = User_group::register($data['options']);
}
if ($data['avatar']) {
try {
$this->saveAvatar($data['avatar'], $group);
} catch (Exception $e) {
common_log(LOG_ERR, "Error importing Yammer avatar: " . $e->getMessage());
}
}
$this->recordImportedGroup($data['orig_id'], $group->id);
return $group;
}
}
示例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);
return false;
}
if (!$nickname) {
// TRANS: Client error displayed when requesting a group RSS feed without providing a group nickname.
$this->clientError(_('No nickname.'), 404);
return false;
}
$local = Local_group::staticGet('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);
return false;
}
$this->group = User_group::staticGet('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);
return false;
}
$this->notices = $this->getNotices($this->limit);
return true;
}
示例5: 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();
}
示例6: 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;
}
示例7: 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;
}
示例8: 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;
}
示例9: prepare
function prepare($args)
{
parent::prepare($args);
$nickname_arg = $this->arg('nickname');
if (empty($nickname_arg)) {
$this->clientError(_('No such group.'), 404);
return false;
}
$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::staticGet('nickname', $this->nickname);
if (!$local) {
$this->clientError(_('No such group.'), 404);
return false;
}
$this->group = User_group::staticGet('id', $local->group_id);
if (!$this->group) {
$this->clientError(_('No such group.'), 404);
return false;
}
common_set_returnto($this->selfUrl());
return true;
}
示例10: 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;
}
示例11: 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(_('Must be logged in.'), 403);
}
if (!$this->user->hasRight(Right::NEWMESSAGE)) {
throw new Exception(sprintf(_('User %s 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);
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);
}
// 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;
}
示例12: 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;
}
示例13: prepare
/**
* Prepare to run
*/
function prepare($args)
{
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.'));
return false;
}
$nickname_arg = $this->trimmed('nickname');
$id = intval($this->arg('id'));
if ($id) {
$this->group = User_group::staticGet('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);
return false;
}
$local = Local_group::staticGet('nickname', $nickname);
if (!$local) {
// TRANS: Client error displayed when trying to join a non-local group.
$this->clientError(_('No such group.'), 404);
return false;
}
$this->group = User_group::staticGet('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);
return false;
}
}
if (!$this->group) {
// TRANS: Client error displayed when trying to join a non-existing group.
$this->clientError(_('No such group.'), 404);
return false;
}
$cur = common_current_user();
if ($cur->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);
return false;
}
if (Group_block::isBlocked($this->group, $cur->getProfile())) {
// 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 false;
}
return true;
}
示例14: 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.'));
return false;
}
$nickname_arg = $this->trimmed('nickname');
$id = intval($this->arg('id'));
if ($id) {
$this->group = User_group::staticGet('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);
return false;
}
$local = Local_group::staticGet('nickname', $nickname);
if (!$local) {
// TRANS: Client error when trying to delete a non-local group.
$this->clientError(_('No such group.'), 404);
return false;
}
$this->group = User_group::staticGet('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);
return false;
}
}
if (!$this->group) {
// TRANS: Client error when trying to delete a non-existing group.
$this->clientError(_('No such group.'), 404);
return false;
}
$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 false;
}
return true;
}
示例15: prepare
/**
* Sets the right action for the form, and passes request args into
* the base action
*
* @param array $args misc. arguments
*
* @return boolean true
*/
function prepare($args)
{
parent::prepare($args);
if (!common_logged_in()) {
// TRANS: Client error displayed trying to change group design settings while not logged in.
$this->clientError(_('You must be logged in to edit a group.'));
return false;
}
$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('groupdesignsettings', $args), 301);
return false;
}
if (!$nickname) {
// TRANS: Client error displayed trying to change group design settings without providing a group nickname.
$this->clientError(_('No nickname.'), 404);
return false;
}
$groupid = $this->trimmed('groupid');
if ($groupid) {
$this->group = User_group::staticGet('id', $groupid);
} else {
$local = Local_group::staticGet('nickname', $nickname);
if ($local) {
$this->group = User_group::staticGet('id', $local->group_id);
}
}
if (!$this->group) {
// TRANS: Client error displayed trying to change group design settings while providing a nickname for a non-existing group.
$this->clientError(_('No such group.'), 404);
return false;
}
$cur = common_current_user();
if (!$cur->isAdmin($this->group)) {
// TRANS: Client error displayed trying to change group design settings without being a (group) admin.
$this->clientError(_('You must be an admin to edit the group.'), 403);
return false;
}
$this->submitaction = common_local_url('groupdesignsettings', array('nickname' => $this->group->nickname));
return true;
}