isLocal() for User_group

This commit is contained in:
Mikael Nordfeldth 2014-05-19 14:46:54 +02:00
parent 37e57610fb
commit 1207f4f06f
2 changed files with 10 additions and 3 deletions

View File

@ -752,6 +752,8 @@ class User_group extends Managed_DataObject
// or we'll miss clearing some cache keys; that can make it hard // 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. // to create a new group with one of those names or aliases.
$this->setAliases(array()); $this->setAliases(array());
// $this->isLocal() but we're using the resulting object
$local = Local_group::getKV('group_id', $this->id); $local = Local_group::getKV('group_id', $this->id);
if ($local instanceof Local_group) { if ($local instanceof Local_group) {
$local->delete(); $local->delete();
@ -804,6 +806,12 @@ class User_group extends Managed_DataObject
$this->force_scope == 1); $this->force_scope == 1);
} }
public function isLocal()
{
$local = Local_group::getKV('group_id', $this->id);
return ($local instanceof Local_group);
}
static function groupsFromText($text, Profile $profile) static function groupsFromText($text, Profile $profile)
{ {
$groups = array(); $groups = array();

View File

@ -1258,9 +1258,8 @@ class OStatusPlugin extends Plugin
public static function localGroupFromUrl($url) public static function localGroupFromUrl($url)
{ {
$group = User_group::getKV('uri', $url); $group = User_group::getKV('uri', $url);
if ($group) { if ($group instanceof User_group) {
$local = Local_group::getKV('group_id', $group->id); if ($group->isLocal()) {
if ($local) {
return $group->id; return $group->id;
} }
} else { } else {