| 
									
										
										
										
											2009-01-23 03:00:51 +01:00
										 |  |  | <?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; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-13 15:49:26 -04:00
										 |  |  |     function isReadOnly($args) | 
					
						
							| 
									
										
										
										
											2009-01-23 09:49:38 +01:00
										 |  |  |     { | 
					
						
							|  |  |  |         return true; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-23 03:00:51 +01:00
										 |  |  |     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() | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2009-01-23 03:47:32 +00:00
										 |  |  |         $this->elementStart('p', array('id' => 'new_group')); | 
					
						
							| 
									
										
										
										
											2009-01-23 03:00:51 +01:00
										 |  |  |         $this->element('a', array('href' => common_local_url('newgroup'), | 
					
						
							| 
									
										
										
										
											2009-01-23 03:47:32 +00:00
										 |  |  |                                   'class' => 'more'), | 
					
						
							| 
									
										
										
										
											2009-01-23 03:00:51 +01:00
										 |  |  |                        _('Create a new group')); | 
					
						
							| 
									
										
										
										
											2009-01-23 03:47:32 +00:00
										 |  |  |         $this->elementEnd('p'); | 
					
						
							| 
									
										
										
										
											2009-01-23 03:00:51 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |         $offset = ($this->page-1) * GROUPS_PER_PAGE; | 
					
						
							| 
									
										
										
										
											2009-01-24 11:05:38 +01:00
										 |  |  |         $limit =  GROUPS_PER_PAGE + 1; | 
					
						
							| 
									
										
										
										
											2009-01-23 03:00:51 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |         $groups = new User_group(); | 
					
						
							| 
									
										
										
										
											2009-01-24 11:05:38 +01:00
										 |  |  |         $groups->orderBy('created DESC'); | 
					
						
							|  |  |  |         $groups->limit($offset, $limit); | 
					
						
							| 
									
										
										
										
											2009-01-23 03:00:51 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |         if ($groups->find()) { | 
					
						
							|  |  |  |             $gl = new GroupList($groups, null, $this); | 
					
						
							|  |  |  |             $cnt = $gl->show(); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         $this->pagination($this->page > 1, $cnt > GROUPS_PER_PAGE, | 
					
						
							| 
									
										
										
										
											2009-01-24 11:05:38 +01:00
										 |  |  |                           $this->page, 'groups'); | 
					
						
							| 
									
										
										
										
											2009-01-23 03:00:51 +01:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2009-01-23 03:03:17 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     function showSections() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         $gbp = new GroupsByPostsSection($this); | 
					
						
							|  |  |  |         $gbp->show(); | 
					
						
							| 
									
										
										
										
											2009-01-23 03:07:03 +01:00
										 |  |  |         $gbm = new GroupsByMembersSection($this); | 
					
						
							|  |  |  |         $gbm->show(); | 
					
						
							| 
									
										
										
										
											2009-01-23 03:03:17 +01:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2009-01-23 03:00:51 +01:00
										 |  |  | } |