summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--actions/groups.php117
-rw-r--r--htaccess.sample1
-rw-r--r--lib/publicgroupnav.php3
-rw-r--r--lib/util.php2
4 files changed, 123 insertions, 0 deletions
diff --git a/actions/groups.php b/actions/groups.php
new file mode 100644
index 000000000..154976f21
--- /dev/null
+++ b/actions/groups.php
@@ -0,0 +1,117 @@
+<?php
+/**
+ * Laconica, the distributed open-source microblogging tool
+ *
+ * Latest groups information
+ *
+ * PHP version 5
+ *
+ * LICENCE: This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * @category Personal
+ * @package Laconica
+ * @author Evan Prodromou <evan@controlyourself.ca>
+ * @author Sarven Capadisli <csarven@controlyourself.ca>
+ * @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/grouplist.php';
+
+/**
+ * Latest groups
+ *
+ * Show the latest groups on the site
+ *
+ * @category Personal
+ * @package Laconica
+ * @author Evan Prodromou <evan@controlyourself.ca>
+ * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
+ * @link http://laconi.ca/
+ */
+
+class GroupsAction extends Action
+{
+ var $page = null;
+ var $profile = null;
+
+ function title()
+ {
+ if ($this->page == 1) {
+ return _("Groups");
+ } else {
+ return sprintf(_("Groups, page %d"), $this->page);
+ }
+ }
+
+ function prepare($args)
+ {
+ parent::prepare($args);
+ $this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
+ return true;
+ }
+
+ function handle($args)
+ {
+ parent::handle($args);
+ $this->showPage();
+ }
+
+ function showLocalNav()
+ {
+ $nav = new PublicGroupNav($this);
+ $nav->show();
+ }
+
+ function showPageNotice()
+ {
+ $notice =
+ sprintf(_('%%%%site.name%%%% groups let you find and talk with ' .
+ 'people of similar interests. After you join a group ' .
+ 'you can send messages to all other members using the ' .
+ 'syntax "!groupname". Don\'t see a group you like? Try ' .
+ '[searching for one](%%%%action.groupsearch%%%%) or ' .
+ '[start your own!](%%%%action.newgroup%%%%)'));
+ $this->elementStart('div', 'instructions');
+ $this->raw(common_markup_to_html($notice));
+ $this->elementEnd('div');
+ }
+
+ function showContent()
+ {
+ $this->element('a', array('href' => common_local_url('newgroup'),
+ 'id' => 'new_group'),
+ _('Create a new group'));
+
+ $offset = ($this->page-1) * GROUPS_PER_PAGE;
+ $limit = GROUPS_PER_PAGE + 1;
+
+ $groups = new User_group();
+ $groups->orderBy('created DESC');
+ $groups->limit($offset, $limit);
+
+ if ($groups->find()) {
+ $gl = new GroupList($groups, null, $this);
+ $cnt = $gl->show();
+ }
+
+ $this->pagination($this->page > 1, $cnt > GROUPS_PER_PAGE,
+ $this->page, 'groups');
+ }
+}
diff --git a/htaccess.sample b/htaccess.sample
index a0fc74248..2a64e8060 100644
--- a/htaccess.sample
+++ b/htaccess.sample
@@ -93,6 +93,7 @@ RewriteRule ^group/([a-zA-Z0-9]+)/members index.php?action=groupmembers&nickname
RewriteRule ^group/([0-9]+)/id index.php?action=groupbyid&id=$1 [L,QSA]
RewriteRule ^group/([a-zA-Z0-9]+)/rss index.php?action=grouprss&nickname=$1 [L,QSA]
RewriteRule ^group/([a-zA-Z0-9]+)$ index.php?action=showgroup&nickname=$1 [L,QSA]
+RewriteRule ^group$ index.php?action=groups [L,QSA]
# Twitter-compatible API rewrites
# XXX: Surely these can be refactored a little -- Zach
diff --git a/lib/publicgroupnav.php b/lib/publicgroupnav.php
index 8dd97a3b7..d72475e20 100644
--- a/lib/publicgroupnav.php
+++ b/lib/publicgroupnav.php
@@ -76,6 +76,9 @@ class PublicGroupNav extends Widget
$this->out->menuItem(common_local_url('public'), _('Public'),
_('Public timeline'), $action_name == 'public', 'nav_timeline_public');
+ $this->out->menuItem(common_local_url('groups'), _('Groups'),
+ _('User groups'), $action_name == 'groups', 'nav_groups');
+
$this->out->menuItem(common_local_url('publictagcloud'), _('Recent tags'),
_('Recent tags'), $action_name == 'publictagcloud', 'nav_recent-tags');
diff --git a/lib/util.php b/lib/util.php
index d30a56c77..42bc08e7e 100644
--- a/lib/util.php
+++ b/lib/util.php
@@ -945,6 +945,8 @@ function common_fancy_url($action, $args=null)
return common_path('group/'.$args['nickname'].'/members');
case 'usergroups':
return common_path($args['nickname'].'/groups');
+ case 'groups':
+ return common_path('group');
default:
return common_simple_url($action, $args);
}