From cd688acceb131312e10a219700ba21d4a3566695 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Fri, 21 Aug 2009 06:13:41 -0400 Subject: [PATCH] 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(-) diff --git a/actions/editgroup.php b/actions/editgroup.php index 6aa6f8b11f..aeeea2b63c 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 0289e77c25..71647d8348 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 7b0daad94c..38e0058c13 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)); + } }