From a7ea08b73adb313071a94cf8307f56b1018f39ee Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Wed, 21 Jan 2009 02:55:55 -0500 Subject: Add group by id for group permalinks --- actions/groupbyid.php | 108 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 actions/groupbyid.php (limited to 'actions/groupbyid.php') diff --git a/actions/groupbyid.php b/actions/groupbyid.php new file mode 100644 index 000000000..678119a94 --- /dev/null +++ b/actions/groupbyid.php @@ -0,0 +1,108 @@ +. + * + * @category Group + * @package Laconica + * @author Evan Prodromou + * @author Sarven Capadisli + * @copyright 2008-2009 Control Yourself, Inc. + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://laconi.ca/ + */ + +if (!defined('LACONICA')) { + exit(1); +} + +require_once INSTALLDIR.'/lib/noticelist.php'; +require_once INSTALLDIR.'/lib/feedlist.php'; + +/** + * Permalink for a group + * + * The group nickname can change, but not the group ID. So we use + * an URL with the ID in it as the permanent identifier. + * + * @category Group + * @package Laconica + * @author Evan Prodromou + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://laconi.ca/ + */ + +class GroupbyidAction extends Action +{ + /** group we're viewing. */ + var $group = null; + + /** + * Is this page read-only? + * + * @return boolean true + */ + + function isReadOnly() + { + return true; + } + + function prepare($args) + { + parent::prepare($args); + + if (!common_config('inboxes','enabled')) { + $this->serverError(_('Inboxes must be enabled for groups to work')); + return false; + } + + $id = $this->arg('id'); + + if (!$id) { + $this->clientError(_('No ID')); + return false; + } + + common_debug("Got ID $id"); + + $this->group = User_group::staticGet('id', $id); + + if (!$this->group) { + $this->clientError(_('No such group'), 404); + return false; + } + + return true; + } + + /** + * Handle the request + * + * Shows a profile for the group, some controls, and a list of + * group notices. + * + * @return void + */ + + function handle($args) + { + common_redirect($this->group->homeUrl(), 303); + } +} \ No newline at end of file -- cgit v1.2.3-54-g00ecf