X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=actions%2Fusergroups.php;h=29bda0a765c289dc107316bd1f1a4a5135346472;hb=47665e845ae74e6ee5b9a39565fb45dd9a93f921;hp=f56f9c6b29119c3c1ced54e05fab06c7d983c813;hpb=318b81c02787cec872c6576f0fcca0fc9ea63322;p=quix0rs-gnu-social.git diff --git a/actions/usergroups.php b/actions/usergroups.php index f56f9c6b29..29bda0a765 100644 --- a/actions/usergroups.php +++ b/actions/usergroups.php @@ -1,6 +1,6 @@ . * * @category Personal - * @package Laconica - * @author Evan Prodromou - * @author Sarven Capadisli - * @copyright 2008-2009 Control Yourself, Inc. + * @package StatusNet + * @author Evan Prodromou + * @author Sarven Capadisli + * @copyright 2008-2009 StatusNet, Inc. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 - * @link http://laconi.ca/ + * @link http://status.net/ */ -if (!defined('LACONICA')) { +if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } -define('GROUPS_PER_PAGE', 20); +require_once INSTALLDIR.'/lib/grouplist.php'; /** * User groups page @@ -40,24 +40,28 @@ define('GROUPS_PER_PAGE', 20); * Show the groups a user belongs to * * @category Personal - * @package Laconica - * @author Evan Prodromou + * @package StatusNet + * @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/ + * @link http://status.net/ */ -class UsergroupsAction extends Action +class UsergroupsAction extends OwnerDesignAction { - var $user = null; var $page = null; var $profile = null; + function isReadOnly($args) + { + return true; + } + function title() { if ($this->page == 1) { - return sprintf(_("%s groups"), $this->user->nickname); + return sprintf(_('%s groups'), $this->user->nickname); } else { - return sprintf(_("%s groups, page %d"), + return sprintf(_('%1$s groups, page %2$d'), $this->user->nickname, $this->page); } @@ -114,18 +118,52 @@ class UsergroupsAction extends Action function showContent() { - $offset = ($this->page-1) * GROUPS_PER_PAGE; - $limit = GROUPS_PER_PAGE + 1; + $this->elementStart('p', array('id' => 'new_group')); + $this->element('a', array('href' => common_local_url('newgroup'), + 'class' => 'more'), + _('Create a new group')); + $this->elementEnd('p'); + + $this->elementStart('p', array('id' => 'group_search')); + $this->element('a', array('href' => common_local_url('groupsearch'), + 'class' => 'more'), + _('Search for more groups')); + $this->elementEnd('p'); + + if (Event::handle('StartShowUserGroupsContent', array($this))) { + $offset = ($this->page-1) * GROUPS_PER_PAGE; + $limit = GROUPS_PER_PAGE + 1; + + $groups = $this->user->getGroups($offset, $limit); + + if ($groups) { + $gl = new GroupList($groups, $this->user, $this); + $cnt = $gl->show(); + if (0 == $cnt) { + $this->showEmptyListMessage(); + } + } - $groups = $this->user->getGroups($offset, $limit); + $this->pagination($this->page > 1, $cnt > GROUPS_PER_PAGE, + $this->page, 'usergroups', + array('nickname' => $this->user->nickname)); - if ($groups) { - $gl = new GroupList($groups, $this->user, $this); - $cnt = $gl->show(); + Event::handle('EndShowUserGroupsContent', array($this)); } + } + + function showEmptyListMessage() + { + $message = sprintf(_('%s is not a member of any group.'), $this->user->nickname) . ' '; - $this->pagination($this->page > 1, $cnt > GROUPS_PER_PAGE, - $this->page, 'usergroups', - array('nickname' => $this->user->nickname)); + if (common_logged_in()) { + $current_user = common_current_user(); + if ($this->user->id === $current_user->id) { + $message .= _('Try [searching for groups](%%action.groupsearch%%) and joining them.'); + } + } + $this->elementStart('div', 'guide'); + $this->raw(common_markup_to_html($message)); + $this->elementEnd('div'); } }