X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=classes%2FUser_group.php;h=310ecff1ef766726197eaa06457b6a3c5cfcc405;hb=38409f1683351ae2b9bc932d441c6021a8b2aae7;hp=9b4b01ead7424f60ba7bae7db2df4152ee2ab335;hpb=71dc910a53eb2aba509c418e7ac0f8e9b94cba9a;p=quix0rs-gnu-social.git diff --git a/classes/User_group.php b/classes/User_group.php index 9b4b01ead7..310ecff1ef 100644 --- a/classes/User_group.php +++ b/classes/User_group.php @@ -13,7 +13,7 @@ class User_group extends Memcached_DataObject public $nickname; // varchar(64) unique_key public $fullname; // varchar(255) public $homepage; // varchar(255) - public $description; // varchar(140) + public $description; // text() public $location; // varchar(255) public $original_logo; // varchar(255) public $homepage_logo; // varchar(255) @@ -126,6 +126,30 @@ class User_group extends Memcached_DataObject return $members; } + function getAdmins($offset=0, $limit=null) + { + $qry = + 'SELECT profile.* ' . + 'FROM profile JOIN group_member '. + 'ON profile.id = group_member.profile_id ' . + 'WHERE group_member.group_id = %d ' . + 'AND group_member.is_admin = 1 ' . + 'ORDER BY group_member.modified ASC '; + + if ($limit != null) { + if (common_config('db','type') == 'pgsql') { + $qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset; + } else { + $qry .= ' LIMIT ' . $offset . ', ' . $limit; + } + } + + $admins = new Profile(); + + $admins->query(sprintf($qry, $this->id)); + return $admins; + } + function getBlocked($offset=0, $limit=null) { $qry = @@ -251,11 +275,14 @@ class User_group extends Memcached_DataObject // XXX: cache this $user = new User(); + if(common_config('db','quote_identifiers')) + $user_table = '"user"'; + else $user_table = 'user'; $qry = 'SELECT id ' . - 'FROM user JOIN group_member '. - 'ON user.id = group_member.profile_id ' . + 'FROM '. $user_table .' JOIN group_member '. + 'ON '. $user_table .'.id = group_member.profile_id ' . 'WHERE group_member.group_id = %d '; $user->query(sprintf($qry, $this->id)); @@ -270,4 +297,61 @@ class User_group extends Memcached_DataObject return $ids; } + + static function maxDescription() + { + $desclimit = common_config('group', 'desclimit'); + // null => use global limit (distinct from 0!) + if (is_null($desclimit)) { + $desclimit = common_config('site', 'textlimit'); + } + return $desclimit; + } + + static function descriptionTooLong($desc) + { + $desclimit = self::maxDescription(); + return ($desclimit > 0 && !empty($desc) && (mb_strlen($desc) > $desclimit)); + } + + function asAtomEntry($namespace=false, $source=false) + { + $xs = new XMLStringer(true); + + if ($namespace) { + $attrs = array('xmlns' => 'http://www.w3.org/2005/Atom', + 'xmlns:thr' => 'http://purl.org/syndication/thread/1.0'); + } else { + $attrs = array(); + } + + $xs->elementStart('entry', $attrs); + + if ($source) { + $xs->elementStart('source'); + $xs->element('title', null, $profile->nickname . " - " . common_config('site', 'name')); + $xs->element('link', array('href' => $this->permalink())); + } + + if ($source) { + $xs->elementEnd('source'); + } + + $xs->element('title', null, $this->nickname); + $xs->element('summary', null, $this->description); + + $xs->element('link', array('rel' => 'alternate', + 'href' => $this->permalink())); + + $xs->element('id', null, $this->permalink()); + + $xs->element('published', null, common_date_w3dtf($this->created)); + $xs->element('updated', null, common_date_w3dtf($this->modified)); + + $xs->element('content', array('type' => 'html'), $this->description); + + $xs->elementEnd('entry'); + + return $xs->getString(); + } }