本文整理汇总了PHP中Local_group::staticGet方法的典型用法代码示例。如果您正苦于以下问题:PHP Local_group::staticGet方法的具体用法?PHP Local_group::staticGet怎么用?PHP Local_group::staticGet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Local_group
的用法示例。
在下文中一共展示了Local_group::staticGet方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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) {
$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;
}
$this->notices = $this->getNotices($this->limit);
return true;
}
示例2: 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;
}
示例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
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;
}
示例5: 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);
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) {
// TRANS: Client error displayed when requesting Friends of a Friend feed for a non-local group.
$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 Friends of a Friend feed for a nickname that is not a group.
$this->clientError(_('No such group.'), 404);
return false;
}
common_set_returnto($this->selfUrl());
return true;
}
示例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
/**
* 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;
}
示例8: 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;
}
示例9: 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;
}
示例10: prepare
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);
if ($this->page != 1) {
$args['page'] = $this->page;
}
common_redirect(common_local_url('showgroup', $args), 301);
return false;
}
if (!$nickname) {
// TRANS: Client error displayed if no nickname argument was given requesting a group page.
$this->clientError(_('No nickname.'), 404);
return false;
}
$local = Local_group::staticGet('nickname', $nickname);
if (!$local) {
$alias = Group_alias::staticGet('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);
return false;
} 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);
return false;
}
}
$this->group = User_group::staticGet('id', $local->group_id);
if (!$this->group) {
// TRANS: Client error displayed if no local group with a given name was found requesting group page.
$this->clientError(_('No such group.'), 404);
return false;
}
}
示例11: prepare
/**
* Prepare to run
*/
function prepare($args)
{
parent::prepare($args);
if (!common_logged_in()) {
$this->clientError(_('You must be logged in to leave 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) {
$this->clientError(_('No such group.'), 404);
return false;
}
$this->group = User_group::staticGet('id', $local->group_id);
} else {
$this->clientError(_('No nickname or ID.'), 404);
return false;
}
}
if (!$this->group) {
$this->clientError(_('No such group.'), 404);
return false;
}
$cur = common_current_user();
if (!$cur->isMember($this->group)) {
$this->clientError(_('You are not a member of that group.'), 403);
return false;
}
return true;
}
示例12: prepare
/**
* Prepare to run
*/
function prepare($args)
{
parent::prepare($args);
if (!common_logged_in()) {
$this->clientError(_('You must be logged in to create 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('grouplogo', $args), 301);
return false;
}
if (!$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) {
$this->clientError(_('No such group.'), 404);
return false;
}
$cur = common_current_user();
if (!$cur->isAdmin($this->group)) {
$this->clientError(_('You must be an admin to edit the group.'), 403);
return false;
}
return true;
}
示例13: targetProfile
/**
* Build the canonical profile URI+URL of the requested user or group
*/
function targetProfile()
{
if ($this->nickname) {
$user = User::staticGet('nickname', $this->nickname);
if ($user) {
return common_local_url('userbyid', array('id' => $user->id));
} else {
$this->clientError("No such user.");
}
} else {
if ($this->group) {
$group = Local_group::staticGet('nickname', $this->group);
if ($group) {
return common_local_url('groupbyid', array('id' => $group->group_id));
} else {
$this->clientError("No such group.");
}
} else {
$this->clientError("No local user or group nickname provided.");
}
}
}
示例14: nicknameExists
function nicknameExists($nickname)
{
$group = Local_group::staticGet('nickname', $nickname);
if (!empty($group) && $group->group_id != $this->group->id) {
return true;
}
$alias = Group_alias::staticGet('alias', $nickname);
if (!empty($alias) && $alias->group_id != $this->group->id) {
return true;
}
return false;
}
示例15: 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.'));
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 leave 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 leave 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 leave a non-existing group.
$this->clientError(_('No such group.'), 404);
return false;
}
$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);
return false;
}
if ($this->arg('profile_id')) {
if ($cur->isAdmin($this->group)) {
$this->profile = Profile::staticGet('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);
return false;
}
} 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;
}