From 11086c78239a30dc47622837a2800d899ebf9b0f Mon Sep 17 00:00:00 2001 From: Craig Andrews Date: Fri, 7 Aug 2009 18:00:04 -0400 Subject: Implemented the list_all and list groups API methods as defined at http://laconi.ca/trac/wiki/ProposedGroupsAPI Made the Autocomplete plugin also autocomplete groups --- classes/User_group.php | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'classes/User_group.php') diff --git a/classes/User_group.php b/classes/User_group.php index b1ab1c2d3..ea19cbb97 100644 --- a/classes/User_group.php +++ b/classes/User_group.php @@ -297,4 +297,45 @@ class User_group extends Memcached_DataObject return $ids; } + + 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(); + } } -- cgit v1.2.3-54-g00ecf From 900ca5c50c3ed4311d67c546a3a289b8eaa0ea0e Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Thu, 20 Aug 2009 17:12:52 -0400 Subject: data classes allow >140c in user group descriptions --- classes/User_group.php | 2 +- classes/laconica.ini | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'classes/User_group.php') diff --git a/classes/User_group.php b/classes/User_group.php index b1ab1c2d3..7b0daad94 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) diff --git a/classes/laconica.ini b/classes/laconica.ini index de5979f35..c02996b3f 100755 --- a/classes/laconica.ini +++ b/classes/laconica.ini @@ -486,7 +486,7 @@ id = 129 nickname = 2 fullname = 2 homepage = 2 -description = 2 +description = 34 location = 2 original_logo = 2 homepage_logo = 2 -- cgit v1.2.3-54-g00ecf From cd688acceb131312e10a219700ba21d4a3566695 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Fri, 21 Aug 2009 06:13:41 -0400 Subject: allow configurable length for user group description --- actions/editgroup.php | 4 ++-- actions/newgroup.php | 4 ++-- classes/User_group.php | 15 +++++++++++++++ 3 files changed, 19 insertions(+), 4 deletions(-) (limited to 'classes/User_group.php') diff --git a/actions/editgroup.php b/actions/editgroup.php index 6aa6f8b11..aeeea2b63 100644 --- a/actions/editgroup.php +++ b/actions/editgroup.php @@ -196,8 +196,8 @@ class EditgroupAction extends GroupDesignAction } else if (!is_null($fullname) && mb_strlen($fullname) > 255) { $this->showForm(_('Full name is too long (max 255 chars).')); return; - } else if (!is_null($description) && mb_strlen($description) > 140) { - $this->showForm(_('description is too long (max 140 chars).')); + } else if (User_group::descriptionTooLong($description)) { + $this->showForm(sprintf(_('description is too long (max %d chars).'), User_group::maxDescription())); return; } else if (!is_null($location) && mb_strlen($location) > 255) { $this->showForm(_('Location is too long (max 255 chars).')); diff --git a/actions/newgroup.php b/actions/newgroup.php index 0289e77c2..71647d834 100644 --- a/actions/newgroup.php +++ b/actions/newgroup.php @@ -146,8 +146,8 @@ class NewgroupAction extends Action } else if (!is_null($fullname) && mb_strlen($fullname) > 255) { $this->showForm(_('Full name is too long (max 255 chars).')); return; - } else if (!is_null($description) && mb_strlen($description) > 140) { - $this->showForm(_('description is too long (max 140 chars).')); + } else if (User_group::descriptionTooLong($description)) { + $this->showForm(sprintf(_('description is too long (max %d chars).'), User_group::maxDescription())); return; } else if (!is_null($location) && mb_strlen($location) > 255) { $this->showForm(_('Location is too long (max 255 chars).')); diff --git a/classes/User_group.php b/classes/User_group.php index 7b0daad94..38e0058c1 100644 --- a/classes/User_group.php +++ b/classes/User_group.php @@ -297,4 +297,19 @@ class User_group extends Memcached_DataObject return $ids; } + + static function maxDescription() + { + $desclimit = common_config('group', 'desclimit'); + if (empty($desclimit)) { + $desclimit = common_config('site', 'textlimit'); + } + return $desclimit; + } + + static function descriptionTooLong($desc) + { + $desclimit = self::maxDescription(); + return (!empty($desclimit) && !empty($desc) && (mb_strlen($desc) > $desclimit)); + } } -- cgit v1.2.3-54-g00ecf From 92ef4895b40498d97150a40b2f24fe9604e4c944 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Fri, 21 Aug 2009 06:36:55 -0400 Subject: can set group desc limit to unlimited without resetting global limit --- classes/User_group.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'classes/User_group.php') diff --git a/classes/User_group.php b/classes/User_group.php index 38e0058c1..e6e79ca6a 100644 --- a/classes/User_group.php +++ b/classes/User_group.php @@ -301,7 +301,8 @@ class User_group extends Memcached_DataObject static function maxDescription() { $desclimit = common_config('group', 'desclimit'); - if (empty($desclimit)) { + // null => use global limit (distinct from 0!) + if (is_null($desclimit)) { $desclimit = common_config('site', 'textlimit'); } return $desclimit; @@ -310,6 +311,6 @@ class User_group extends Memcached_DataObject static function descriptionTooLong($desc) { $desclimit = self::maxDescription(); - return (!empty($desclimit) && !empty($desc) && (mb_strlen($desc) > $desclimit)); + return ($desclimit > 0 && !empty($desc) && (mb_strlen($desc) > $desclimit)); } } -- cgit v1.2.3-54-g00ecf