summaryrefslogtreecommitdiff
path: root/actions
diff options
context:
space:
mode:
authorEvan Prodromou <evan@status.net>2010-02-25 08:44:15 -0500
committerEvan Prodromou <evan@status.net>2010-02-25 08:44:15 -0500
commite6858d7203bd36923f6251968bede6f4b271bf84 (patch)
treedaf24ce51064058af226eb8e296476a3f9155473 /actions
parentddc3671b6aeb0b543d261251a1740a53469684c3 (diff)
modify group actions so they use Local_group to look up by nickname
Diffstat (limited to 'actions')
-rw-r--r--actions/apigroupcreate.php8
-rw-r--r--actions/apigrouplistall.php10
-rw-r--r--actions/blockedfromgroup.php9
-rw-r--r--actions/editgroup.php14
-rw-r--r--actions/foafgroup.php17
-rw-r--r--actions/groupdesignsettings.php5
-rw-r--r--actions/grouplogo.php5
-rw-r--r--actions/groupmembers.php9
-rw-r--r--actions/grouprss.php9
-rw-r--r--actions/groups.php18
-rw-r--r--actions/joingroup.php9
-rw-r--r--actions/leavegroup.php9
-rw-r--r--actions/newgroup.php7
-rw-r--r--actions/showgroup.php10
14 files changed, 106 insertions, 33 deletions
diff --git a/actions/apigroupcreate.php b/actions/apigroupcreate.php
index 028d76a78..145806356 100644
--- a/actions/apigroupcreate.php
+++ b/actions/apigroupcreate.php
@@ -123,7 +123,9 @@ class ApiGroupCreateAction extends ApiAuthAction
'description' => $this->description,
'location' => $this->location,
'aliases' => $this->aliases,
- 'userid' => $this->user->id));
+ 'userid' => $this->user->id,
+ 'local' => true));
+
switch($this->format) {
case 'xml':
$this->showSingleXmlGroup($group);
@@ -306,9 +308,9 @@ class ApiGroupCreateAction extends ApiAuthAction
function groupNicknameExists($nickname)
{
- $group = User_group::staticGet('nickname', $nickname);
+ $local = Local_group::staticGet('nickname', $nickname);
- if (!empty($group)) {
+ if (!empty($local)) {
return true;
}
diff --git a/actions/apigrouplistall.php b/actions/apigrouplistall.php
index d2ef2978a..e1b54a832 100644
--- a/actions/apigrouplistall.php
+++ b/actions/apigrouplistall.php
@@ -134,13 +134,13 @@ class ApiGroupListAllAction extends ApiPrivateAuthAction
function getGroups()
{
- $groups = array();
-
- // XXX: Use the $page, $count, $max_id, $since_id, and $since parameters
+ $qry = 'SELECT user_group.* '.
+ 'from user_group join local_group on user_group.id = local_group.group_id '.
+ 'order by created desc ';
$group = new User_group();
- $group->orderBy('created DESC');
- $group->find();
+
+ $group->query($qry);
while ($group->fetch()) {
$groups[] = clone($group);
diff --git a/actions/blockedfromgroup.php b/actions/blockedfromgroup.php
index 0b4caf5bf..a0598db27 100644
--- a/actions/blockedfromgroup.php
+++ b/actions/blockedfromgroup.php
@@ -74,7 +74,14 @@ class BlockedfromgroupAction extends GroupDesignAction
return false;
}
- $this->group = User_group::staticGet('nickname', $nickname);
+ $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);
diff --git a/actions/editgroup.php b/actions/editgroup.php
index ad0b6e185..bbbb7a0f4 100644
--- a/actions/editgroup.php
+++ b/actions/editgroup.php
@@ -86,10 +86,14 @@ class EditgroupAction extends GroupDesignAction
}
$groupid = $this->trimmed('groupid');
+
if ($groupid) {
$this->group = User_group::staticGet('id', $groupid);
} else {
- $this->group = User_group::staticGet('nickname', $nickname);
+ $local = Local_group::staticGet('nickname', $nickname);
+ if ($local) {
+ $this->group = User_group::staticGet('id', $local->group_id);
+ }
}
if (!$this->group) {
@@ -259,6 +263,12 @@ class EditgroupAction extends GroupDesignAction
$this->serverError(_('Could not create aliases.'));
}
+ if ($nickname != $orig->nickname) {
+ common_log(LOG_INFO, "Saving local group info.");
+ $local = Local_group::staticGet('group_id', $this->group->id);
+ $local->setNickname($nickname);
+ }
+
$this->group->query('COMMIT');
if ($this->group->nickname != $orig->nickname) {
@@ -272,7 +282,7 @@ class EditgroupAction extends GroupDesignAction
function nicknameExists($nickname)
{
- $group = User_group::staticGet('nickname', $nickname);
+ $group = Local_group::staticGet('nickname', $nickname);
if (!empty($group) &&
$group->id != $this->group->id) {
diff --git a/actions/foafgroup.php b/actions/foafgroup.php
index f5fd7fe88..ebdf1cee2 100644
--- a/actions/foafgroup.php
+++ b/actions/foafgroup.php
@@ -56,7 +56,14 @@ class FoafGroupAction extends Action
return false;
}
- $this->group = User_group::staticGet('nickname', $this->nickname);
+ $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);
@@ -113,7 +120,7 @@ class FoafGroupAction extends Action
if ($this->group->homepage_logo) {
$this->element('depiction', array('rdf:resource' => $this->group->homepage_logo));
}
-
+
$members = $this->group->getMembers();
$member_details = array();
while ($members->fetch()) {
@@ -123,7 +130,7 @@ class FoafGroupAction extends Action
);
$this->element('member', array('rdf:resource' => $member_uri));
}
-
+
$admins = $this->group->getAdmins();
while ($admins->fetch()) {
$admin_uri = common_local_url('userbyid', array('id'=>$admins->id));
@@ -132,7 +139,7 @@ class FoafGroupAction extends Action
}
$this->elementEnd('Group');
-
+
ksort($member_details);
foreach ($member_details as $uri => $details) {
if ($details['is_admin'])
@@ -158,7 +165,7 @@ class FoafGroupAction extends Action
));
}
}
-
+
$this->elementEnd('rdf:RDF');
$this->endXML();
}
diff --git a/actions/groupdesignsettings.php b/actions/groupdesignsettings.php
index e290ba514..526226a28 100644
--- a/actions/groupdesignsettings.php
+++ b/actions/groupdesignsettings.php
@@ -90,7 +90,10 @@ class GroupDesignSettingsAction extends DesignSettingsAction
if ($groupid) {
$this->group = User_group::staticGet('id', $groupid);
} else {
- $this->group = User_group::staticGet('nickname', $nickname);
+ $local = Local_group::staticGet('nickname', $nickname);
+ if ($local) {
+ $this->group = User_group::staticGet('id', $local->group_id);
+ }
}
if (!$this->group) {
diff --git a/actions/grouplogo.php b/actions/grouplogo.php
index 3c9b56296..f414a23cc 100644
--- a/actions/grouplogo.php
+++ b/actions/grouplogo.php
@@ -92,7 +92,10 @@ class GrouplogoAction extends GroupDesignAction
if ($groupid) {
$this->group = User_group::staticGet('id', $groupid);
} else {
- $this->group = User_group::staticGet('nickname', $nickname);
+ $local = Local_group::staticGet('nickname', $nickname);
+ if ($local) {
+ $this->group = User_group::staticGet('id', $local->group_id);
+ }
}
if (!$this->group) {
diff --git a/actions/groupmembers.php b/actions/groupmembers.php
index f16e972a4..a16debd7b 100644
--- a/actions/groupmembers.php
+++ b/actions/groupmembers.php
@@ -77,7 +77,14 @@ class GroupmembersAction extends GroupDesignAction
return false;
}
- $this->group = User_group::staticGet('nickname', $nickname);
+ $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);
diff --git a/actions/grouprss.php b/actions/grouprss.php
index 866fc66eb..490f6f945 100644
--- a/actions/grouprss.php
+++ b/actions/grouprss.php
@@ -92,7 +92,14 @@ class groupRssAction extends Rss10Action
return false;
}
- $this->group = User_group::staticGet('nickname', $nickname);
+ $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);
diff --git a/actions/groups.php b/actions/groups.php
index 10a1d5964..8aacff8b0 100644
--- a/actions/groups.php
+++ b/actions/groups.php
@@ -109,17 +109,21 @@ class GroupsAction extends Action
}
$offset = ($this->page-1) * GROUPS_PER_PAGE;
- $limit = GROUPS_PER_PAGE + 1;
+ $limit = GROUPS_PER_PAGE + 1;
+
+ $qry = 'SELECT user_group.* '.
+ 'from user_group join local_group on user_group.id = local_group.group_id '.
+ 'order by user_group.created desc '.
+ 'limit ' . $limit . ' offset ' . $offset;
$groups = new User_group();
- $groups->orderBy('created DESC');
- $groups->limit($offset, $limit);
$cnt = 0;
- if ($groups->find()) {
- $gl = new GroupList($groups, null, $this);
- $cnt = $gl->show();
- }
+
+ $groups->query($qry);
+
+ $gl = new GroupList($groups, null, $this);
+ $cnt = $gl->show();
$this->pagination($this->page > 1, $cnt > GROUPS_PER_PAGE,
$this->page, 'groups');
diff --git a/actions/joingroup.php b/actions/joingroup.php
index 235e5ab4c..ba642f712 100644
--- a/actions/joingroup.php
+++ b/actions/joingroup.php
@@ -77,7 +77,14 @@ class JoingroupAction extends Action
return false;
}
- $this->group = User_group::staticGet('nickname', $nickname);
+ $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);
diff --git a/actions/leavegroup.php b/actions/leavegroup.php
index 9b9d83b6c..222d4c1b4 100644
--- a/actions/leavegroup.php
+++ b/actions/leavegroup.php
@@ -77,7 +77,14 @@ class LeavegroupAction extends Action
return false;
}
- $this->group = User_group::staticGet('nickname', $nickname);
+ $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);
diff --git a/actions/newgroup.php b/actions/newgroup.php
index 25da7f8fc..6bb3eca76 100644
--- a/actions/newgroup.php
+++ b/actions/newgroup.php
@@ -192,16 +192,17 @@ class NewgroupAction extends Action
'description' => $description,
'location' => $location,
'aliases' => $aliases,
- 'userid' => $cur->id));
+ 'userid' => $cur->id,
+ 'local' => true));
common_redirect($group->homeUrl(), 303);
}
function nicknameExists($nickname)
{
- $group = User_group::staticGet('nickname', $nickname);
+ $local = Local_group::staticGet('nickname', $nickname);
- if (!empty($group)) {
+ if (!empty($local)) {
return true;
}
diff --git a/actions/showgroup.php b/actions/showgroup.php
index eb1238902..0139ba157 100644
--- a/actions/showgroup.php
+++ b/actions/showgroup.php
@@ -122,7 +122,15 @@ class ShowgroupAction extends GroupDesignAction
return false;
}
- $this->group = User_group::staticGet('nickname', $nickname);
+ $local = Local_group::staticGet('nickname', $nickname);
+
+ if (!$local) {
+ common_log(LOG_NOTICE, "Couldn't find local group for nickname '$nickname'");
+ $this->clientError(_('No such group.'), 404);
+ return false;
+ }
+
+ $this->group = User_group::staticGet('id', $local->group_id);
if (!$this->group) {
$alias = Group_alias::staticGet('alias', $nickname);