本文整理汇总了PHP中User_group类的典型用法代码示例。如果您正苦于以下问题:PHP User_group类的具体用法?PHP User_group怎么用?PHP User_group使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了User_group类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updateGroupUrls
function updateGroupUrls()
{
printfnq("Updating group URLs...\n");
$group = new User_group();
if ($group->find()) {
while ($group->fetch()) {
try {
printfv("Updating group {$group->nickname}...");
$orig = User_group::getKV('id', $group->id);
if (!empty($group->original_logo)) {
$group->original_logo = Avatar::url(basename($group->original_logo));
$group->homepage_logo = Avatar::url(basename($group->homepage_logo));
$group->stream_logo = Avatar::url(basename($group->stream_logo));
$group->mini_logo = Avatar::url(basename($group->mini_logo));
}
// XXX: this is a hack to see if a group is local or not
$localUri = common_local_url('groupbyid', array('id' => $group->id));
if ($group->getUri() != $localUri) {
$group->mainpage = common_local_url('showgroup', array('nickname' => $group->nickname));
}
$group->update($orig);
printfv("DONE.");
} catch (Exception $e) {
echo "Can't update avatars for group " . $group->nickname . ": " . $e->getMessage();
}
}
}
}
示例2: __construct
/**
* constructor
*
* @param User_group $user User_group that's missing a profile
*/
public function __construct(User_group $group)
{
$this->group = $group;
// TRANS: Exception text shown when no profile can be found for a group.
// TRANS: %1$s is a group nickname, $2$d is a group profile_id (number).
$message = sprintf(_('Group "%1$s" (%2$d) has no profile record.'), $group->nickname, $group->getID());
parent::__construct($group->profile_id, $message);
}
示例3: getGroup
public function getGroup()
{
$group = new User_group();
$group->id = $this->group_id;
$group->find(true);
if (!$group instanceof User_group) {
common_log(LOG_ERR, 'User_group does not exist for Local_group: ' . $this->group_id);
throw new NoResultException($group);
}
return $group;
}
示例4: 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;
}
示例5: 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;
}
示例6: prepare
/**
* Prepare to run
*/
function prepare($args)
{
parent::prepare($args);
if (!common_config('inboxes', 'enabled')) {
$this->serverError(_('Inboxes must be enabled for groups to work.'));
return false;
}
if (!common_logged_in()) {
$this->clientError(_('You must be logged in to leave 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('leavegroup', $args), 301);
return false;
}
if (!$nickname) {
$this->clientError(_('No nickname.'), 404);
return false;
}
$this->group = User_group::staticGet('nickname', $nickname);
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;
}
示例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('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;
}
示例8: __construct
/**
* Constructor
*
* @param Group $group the group for the feed
* @param User $cur the current authenticated user, if any
* @param boolean $indent flag to turn indenting on or off
*
* @return void
*/
function __construct($group, $cur = null, $indent = true)
{
parent::__construct($cur, $indent);
$this->group = $group;
// TRANS: Title in atom group notice feed. %s is a group name.
$title = sprintf(_("%s timeline"), $group->nickname);
$this->setTitle($title);
$sitename = common_config('site', 'name');
$subtitle = sprintf(_('Updates from %1$s on %2$s!'), $group->nickname, $sitename);
$this->setSubtitle($subtitle);
$avatar = $group->homepage_logo;
$logo = $avatar ? $avatar : User_group::defaultLogo(AVATAR_PROFILE_SIZE);
$this->setLogo($logo);
$this->setUpdated('now');
$self = common_local_url('ApiTimelineGroup', array('id' => $group->id, 'format' => 'atom'));
$this->setId($self);
$this->setSelfLink($self);
// For groups, we generate an author _AND_ an <activity:subject>
// Versions of StatusNet under 0.9.7 treat <author> as a person
// XXX: remove this workaround in future versions
$ao = ActivityObject::fromGroup($group);
$this->addAuthorRaw($ao->asString('author'));
$depMsg = 'Deprecation warning: activity:subject is present ' . 'only for backward compatibility. It will be ' . 'removed in the next version of StatusNet.';
$this->addAuthorRaw("<!--{$depMsg}-->\n" . $ao->asString('activity:subject'));
$this->addLink($group->homeUrl());
}
示例9: 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;
}
示例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)) {
// 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;
}
示例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: updateGroupUri
function updateGroupUri($group)
{
if (!have_option('q', 'quiet')) {
print "Updating URI for group '" . $group->nickname . "' (" . $group->id . ")...";
}
if (empty($group->uri)) {
// Using clone here was screwing up the group->find() iteration
$orig = User_group::staticGet('id', $group->id);
$group->uri = $group->getUri();
if (have_option('dry_run')) {
echo " would have set {$group->uri} ";
} else {
if (!$group->update($orig)) {
throw new Exception("Can't update uri for group " . $group->nickname . ".");
}
echo " set {$group->uri} ";
}
} else {
print " already set, keeping {$group->uri} ";
}
if (have_option('v', 'verbose')) {
print "DONE.";
}
if (!have_option('q', 'quiet') || have_option('v', 'verbose')) {
print "\n";
}
}
示例13: 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;
}
示例14: 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;
}
示例15: handle
/**
* Handle input, produce output
*
* Switches based on GET or POST method. On GET, shows a form
* for posting a notice. On POST, saves the results of that form.
*
* Results may be a full page, or just a single notice list item,
* depending on whether AJAX was requested.
*
* @param array $args $_REQUEST contents
*
* @return void
*/
function handle($args)
{
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.'));
} else {
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
// check for this before token since all POST and FILES data
// is losts when size is exceeded
if (empty($_POST) && $_SERVER['CONTENT_LENGTH']) {
// TRANS: Client error displayed when the number of bytes in a POST request exceeds a limit.
// TRANS: %s is the number of bytes of the CONTENT_LENGTH.
$msg = _m('The server was unable to handle that much POST data (%s byte) due to its current configuration.', 'The server was unable to handle that much POST data (%s bytes) due to its current configuration.', intval($_SERVER['CONTENT_LENGTH']));
$this->clientError(sprintf($msg, $_SERVER['CONTENT_LENGTH']));
}
parent::handle($args);
$user = common_current_user();
$group = User_group::staticGet('id', $this->trimmed('groupid'));
$taskid = $this->trimmed('taskid');
try {
$this->saveNewNotice();
Task::completeTask($user->id, $taskid);
} catch (Exception $e) {
$this->ajaxErrorMsg($e->getMessage(), $taskid, $group);
return;
}
}
}
}