summaryrefslogtreecommitdiff
path: root/classes
diff options
context:
space:
mode:
authorBrion Vibber <brion@pobox.com>2010-10-13 15:46:45 -0700
committerBrion Vibber <brion@pobox.com>2010-10-13 15:46:45 -0700
commit4101de7dd7cf059816c29c666c816f260a84c252 (patch)
treedce4b95ec0270ec2cf4dfc357229ee569e1a48f0 /classes
parent621233e1ad6956cfb543042a1493a04b243e92ca (diff)
parentf79dbaf9a76c10969dbc45fd43a0bb26f5f64ed4 (diff)
Merge branch '1.0.x' into schema-x
Diffstat (limited to 'classes')
-rw-r--r--classes/Oauth_application.php17
-rw-r--r--classes/Profile.php1
-rw-r--r--classes/User_group.php42
3 files changed, 55 insertions, 5 deletions
diff --git a/classes/Oauth_application.php b/classes/Oauth_application.php
index e81706104..f1d4fb7a6 100644
--- a/classes/Oauth_application.php
+++ b/classes/Oauth_application.php
@@ -46,12 +46,19 @@ class Oauth_application extends Memcached_DataObject
static function maxDesc()
{
- $desclimit = common_config('application', 'desclimit');
- // null => use global limit (distinct from 0!)
- if (is_null($desclimit)) {
- $desclimit = common_config('site', 'textlimit');
+ // This used to default to textlimit or allow unlimited descriptions,
+ // but this isn't part of a notice and the field's limited to 255 chars
+ // in the DB, so those seem silly.
+ //
+ // Now just defaulting to 255 max unless a smaller application desclimit
+ // is actually set. Setting to 0 will use the maximum.
+ $max = 255;
+ $desclimit = intval(common_config('application', 'desclimit'));
+ if ($desclimit > 0 && $desclimit < $max) {
+ return $desclimit;
+ } else {
+ return $max;
}
- return $desclimit;
}
static function descriptionTooLong($desc)
diff --git a/classes/Profile.php b/classes/Profile.php
index 1d130c44a..8b05bcbf9 100644
--- a/classes/Profile.php
+++ b/classes/Profile.php
@@ -854,6 +854,7 @@ class Profile extends Memcached_DataObject
case Right::SANDBOXUSER:
case Right::SILENCEUSER:
case Right::DELETEUSER:
+ case Right::DELETEGROUP:
$result = $this->hasRole(Profile_role::MODERATOR);
break;
case Right::CONFIGURESITE:
diff --git a/classes/User_group.php b/classes/User_group.php
index cfdcef290..1f7005785 100644
--- a/classes/User_group.php
+++ b/classes/User_group.php
@@ -547,4 +547,46 @@ class User_group extends Memcached_DataObject
$group->query('COMMIT');
return $group;
}
+
+ /**
+ * Handle cascading deletion, on the model of notice and profile.
+ *
+ * This should handle freeing up cached entries for the group's
+ * id, nickname, URI, and aliases. There may be other areas that
+ * are not de-cached in the UI, including the sidebar lists on
+ * GroupsAction
+ */
+ function delete()
+ {
+ if ($this->id) {
+ // Safe to delete in bulk for now
+ $related = array('Group_inbox',
+ 'Group_block',
+ 'Group_member',
+ 'Related_group');
+ Event::handle('UserGroupDeleteRelated', array($this, &$related));
+ foreach ($related as $cls) {
+ $inst = new $cls();
+ $inst->group_id = $this->id;
+ $inst->delete();
+ }
+
+ // And related groups in the other direction...
+ $inst = new Related_group();
+ $inst->related_group_id = $this->id;
+ $inst->delete();
+
+ // Aliases and the local_group entry need to be cleared explicitly
+ // or we'll miss clearing some cache keys; that can make it hard
+ // to create a new group with one of those names or aliases.
+ $this->setAliases(array());
+ $local = Local_group::staticGet('group_id', $this->id);
+ if ($local) {
+ $local->delete();
+ }
+ } else {
+ common_log(LOG_WARN, "Ambiguous user_group->delete(); skipping related tables.");
+ }
+ parent::delete();
+ }
}