diff --git a/actions/blockedfromgroup.php b/actions/blockedfromgroup.php index 07ed41e414..caf3911d7d 100644 --- a/actions/blockedfromgroup.php +++ b/actions/blockedfromgroup.php @@ -122,12 +122,6 @@ class BlockedfromgroupAction extends GroupAction _('A list of the users blocked from joining this group.')); } - function showObjectNav() - { - $nav = new GroupNav($this, $this->group); - $nav->show(); - } - function showContent() { $offset = ($this->page-1) * PROFILES_PER_PAGE; diff --git a/actions/editgroup.php b/actions/editgroup.php index 8405dbe292..35dd25b896 100644 --- a/actions/editgroup.php +++ b/actions/editgroup.php @@ -139,12 +139,6 @@ class EditgroupAction extends GroupAction $this->showPage(); } - function showObjectNav() - { - $nav = new GroupNav($this, $this->group); - $nav->show(); - } - function showContent() { $form = new GroupEditForm($this, $this->group); diff --git a/actions/grouplogo.php b/actions/grouplogo.php index c5a106520d..46ce274274 100644 --- a/actions/grouplogo.php +++ b/actions/grouplogo.php @@ -457,10 +457,4 @@ class GrouplogoAction extends GroupAction $this->autofocus('avatarfile'); } - - function showObjectNav() - { - $nav = new GroupNav($this, $this->group); - $nav->show(); - } } diff --git a/actions/groupqueue.php b/actions/groupqueue.php index 2a7239400e..4bbf5dcb02 100644 --- a/actions/groupqueue.php +++ b/actions/groupqueue.php @@ -132,12 +132,6 @@ class GroupqueueAction extends GroupAction _('A list of users awaiting approval to join this group.')); } - function showObjectNav() - { - $nav = new GroupNav($this, $this->group); - $nav->show(); - } - function showContent() { $offset = ($this->page-1) * PROFILES_PER_PAGE; diff --git a/classes/Notice.php b/classes/Notice.php index 15696f6eef..60958c9e6a 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -92,7 +92,7 @@ class Notice extends Managed_DataObject 'id' => array('type' => 'serial', 'not null' => true, 'description' => 'unique identifier'), 'profile_id' => array('type' => 'int', 'not null' => true, 'description' => 'who made the update'), 'uri' => array('type' => 'varchar', 'length' => 255, 'description' => 'universally unique identifier, usually a tag URI'), - 'content' => array('type' => 'text', 'description' => 'update content'), + 'content' => array('type' => 'text', 'description' => 'update content', 'collate' => 'utf8_general_ci'), 'rendered' => array('type' => 'text', 'description' => 'HTML version of the content'), 'url' => array('type' => 'varchar', 'length' => 255, 'description' => 'URL of any attachment (image, video, bookmark, whatever)'), 'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'), diff --git a/classes/Profile.php b/classes/Profile.php index 06ea31c435..a6275cf451 100644 --- a/classes/Profile.php +++ b/classes/Profile.php @@ -55,12 +55,12 @@ class Profile extends Managed_DataObject 'description' => 'local and remote users have profiles', 'fields' => array( 'id' => array('type' => 'serial', 'not null' => true, 'description' => 'unique identifier'), - 'nickname' => array('type' => 'varchar', 'length' => 64, 'not null' => true, 'description' => 'nickname or username'), - 'fullname' => array('type' => 'varchar', 'length' => 255, 'description' => 'display name'), + 'nickname' => array('type' => 'varchar', 'length' => 64, 'not null' => true, 'description' => 'nickname or username', 'collate' => 'utf8_general_ci'), + 'fullname' => array('type' => 'varchar', 'length' => 255, 'description' => 'display name', 'collate' => 'utf8_general_ci'), 'profileurl' => array('type' => 'varchar', 'length' => 255, 'description' => 'URL, cached so we dont regenerate'), - 'homepage' => array('type' => 'varchar', 'length' => 255, 'description' => 'identifying URL'), - 'bio' => array('type' => 'text', 'description' => 'descriptive biography'), - 'location' => array('type' => 'varchar', 'length' => 255, 'description' => 'physical location'), + 'homepage' => array('type' => 'varchar', 'length' => 255, 'description' => 'identifying URL', 'collate' => 'utf8_general_ci'), + 'bio' => array('type' => 'text', 'description' => 'descriptive biography', 'collate' => 'utf8_general_ci'), + 'location' => array('type' => 'varchar', 'length' => 255, 'description' => 'physical location', 'collate' => 'utf8_general_ci'), 'lat' => array('type' => 'numeric', 'precision' => 10, 'scale' => 7, 'description' => 'latitude'), 'lon' => array('type' => 'numeric', 'precision' => 10, 'scale' => 7, 'description' => 'longitude'), 'location_id' => array('type' => 'int', 'description' => 'location id if possible'), diff --git a/classes/User_group.php b/classes/User_group.php index 4870e39a15..0f1cc40b28 100644 --- a/classes/User_group.php +++ b/classes/User_group.php @@ -209,6 +209,26 @@ class User_group extends Managed_DataObject return $member_count; } + function getBlockedCount() + { + // XXX: WORM cache this + + $block = new Group_block(); + $block->group_id = $this->id; + + return $block->count(); + } + + function getQueueCount() + { + // XXX: WORM cache this + + $queue = new Group_join_queue(); + $queue->group_id = $this->id; + + return $queue->count(); + } + function getAdmins($offset=0, $limit=null) { $qry = diff --git a/lib/groupaction.php b/lib/groupaction.php index 3b5cd52875..3e3cc45b30 100644 --- a/lib/groupaction.php +++ b/lib/groupaction.php @@ -105,19 +105,6 @@ class GroupAction extends Action $block->show(); } - /** - * Local menu - * - * @return void - */ - - function showObjectNav() - { - $nav = new GroupNav($this, $this->group); - $nav->show(); - } - - /** * Fill in the sidebar. * @@ -126,6 +113,11 @@ class GroupAction extends Action function showSections() { $this->showMembers(); + $cur = common_current_user(); + if ($cur && $cur->isAdmin($this->group)) { + $this->showPending(); + $this->showBlocked(); + } $this->showAdmins(); $cloud = new GroupTagCloudSection($this, $this->group); $cloud->show(); @@ -184,6 +176,98 @@ class GroupAction extends Action $this->elementEnd('div'); } + + function showPending() + { + if ($this->group->join_policy != User_group::JOIN_POLICY_MODERATE) { + return; + } + + $pending = $this->group->getQueueCount(); + + if (!$pending) { + return; + } + + $request = $this->group->getRequests(0, MEMBERS_PER_SECTION); + + if (!$request) { + return; + } + + $this->elementStart('div', array('id' => 'entity_pending', + 'class' => 'section')); + + if (Event::handle('StartShowGroupPendingMiniList', array($this))) { + + $this->elementStart('h2'); + + $this->element('a', array('href' => common_local_url('groupqueue', array('nickname' => + $this->group->nickname))), + _('Pending')); + + $this->text(' '); + + $this->text($pending); + + $this->elementEnd('h2'); + + $gmml = new ProfileMiniList($request, $this); + $gmml->show(); + + Event::handle('EndShowGroupPendingMiniList', array($this)); + } + + $this->elementEnd('div'); + } + + function showBlocked() + { + $blocked = $this->group->getBlocked(0, MEMBERS_PER_SECTION); + + if (!$blocked) { + return; + } + + $this->elementStart('div', array('id' => 'entity_blocked', + 'class' => 'section')); + + if (Event::handle('StartShowGroupBlockedMiniList', array($this))) { + + $this->elementStart('h2'); + + $this->element('a', array('href' => common_local_url('blockedfromgroup', array('nickname' => + $this->group->nickname))), + _('Blocked')); + + $this->text(' '); + + $this->text($this->group->getBlockedCount()); + + $this->elementEnd('h2'); + + $gmml = new GroupBlockedMiniList($blocked, $this); + $cnt = $gmml->show(); + if ($cnt == 0) { + // TRANS: Description for mini list of group members on a group page when the group has no members. + $this->element('p', null, _('(None)')); + } + + // @todo FIXME: Should be shown if a group has more than 27 members, but I do not see it displayed at + // for example http://identi.ca/group/statusnet. Broken? + if ($cnt > MEMBERS_PER_SECTION) { + $this->element('a', array('href' => common_local_url('blockedfromgroup', + array('nickname' => $this->group->nickname))), + // TRANS: Link to all group members from mini list of group members if group has more than n members. + _('All members')); + } + + Event::handle('EndShowGroupBlockedMiniList', array($this)); + } + + $this->elementEnd('div'); + } + /** * Show list of admins * @@ -263,6 +347,28 @@ class GroupMembersMiniListItem extends ProfileMiniListItem } } +class GroupBlockedMiniList extends ProfileMiniList +{ + function newListItem($profile) + { + return new GroupBlockedMiniListItem($profile, $this->action); + } +} + +class GroupBlockedMiniListItem extends ProfileMiniListItem +{ + function linkAttributes() + { + $aAttrs = parent::linkAttributes(); + + if (common_config('nofollow', 'members')) { + $aAttrs['rel'] .= ' nofollow'; + } + + return $aAttrs; + } +} + class ThreadingGroupNoticeStream extends ThreadingNoticeStream { function __construct($group, $profile) diff --git a/lib/groupnav.php b/lib/groupnav.php deleted file mode 100644 index 61d3cfbd74..0000000000 --- a/lib/groupnav.php +++ /dev/null @@ -1,125 +0,0 @@ -. - * - * @category Action - * @package StatusNet - * @author Evan Prodromou - * @author Sarven Capadisli - * @copyright 2008 StatusNet, Inc. - * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 - * @link http://status.net/ - */ - -if (!defined('STATUSNET') && !defined('LACONICA')) { - exit(1); -} - -require_once INSTALLDIR.'/lib/widget.php'; - -/** - * Tabset for a group - * - * Shows a group of tabs for a particular user group - * - * @category Output - * @package StatusNet - * @author Evan Prodromou - * @author Sarven Capadisli - * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 - * @link http://status.net/ - * - * @see HTMLOutputter - */ -class GroupNav extends Menu -{ - var $group = null; - - /** - * Construction - * - * @param Action $action current action, used for output - */ - function __construct($action=null, $group=null) - { - parent::__construct($action); - $this->group = $group; - } - - /** - * Show the menu - * - * @return void - */ - function show() - { - $action_name = $this->action->trimmed('action'); - $nickname = $this->group->nickname; - - $this->out->elementStart('ul', array('class' => 'nav')); - if (Event::handle('StartGroupGroupNav', array($this))) { - - $cur = common_current_user(); - - if ($cur && $cur->isAdmin($this->group)) { - $pending = $this->countPendingMembers(); - if ($pending || $this->group->join_policy == User_group::JOIN_POLICY_MODERATE) { - $this->out->menuItem(common_local_url('groupqueue', array('nickname' => - $nickname)), - // TRANS: Menu item in the group navigation page. Only shown for group administrators. - // TRANS: %d is the number of pending members. - sprintf(_m('MENU','Pending members (%d)','Pending members (%d)',$pending), $pending), - // TRANS: Tooltip for menu item in the group navigation page. Only shown for group administrators. - // TRANS: %s is the nickname of the group. - sprintf(_m('TOOLTIP','%s pending members'), $nickname), - $action_name == 'groupqueue', - 'nav_group_pending'); - } - $this->out->menuItem(common_local_url('blockedfromgroup', array('nickname' => - $nickname)), - // TRANS: Menu item in the group navigation page. Only shown for group administrators. - _m('MENU','Blocked'), - // TRANS: Tooltip for menu item in the group navigation page. Only shown for group administrators. - // TRANS: %s is the nickname of the group. - sprintf(_m('TOOLTIP','%s blocked users'), $nickname), - $action_name == 'blockedfromgroup', - 'nav_group_blocked'); - $this->out->menuItem(common_local_url('grouplogo', array('nickname' => - $nickname)), - // TRANS: Menu item in the group navigation page. Only shown for group administrators. - _m('MENU','Logo'), - // TRANS: Tooltip for menu item in the group navigation page. Only shown for group administrators. - // TRANS: %s is the nickname of the group. - sprintf(_m('TOOLTIP','Add or edit %s logo'), $nickname), - $action_name == 'grouplogo', - 'nav_group_logo'); - } - Event::handle('EndGroupGroupNav', array($this)); - } - $this->out->elementEnd('ul'); - } - - function countPendingMembers() - { - $req = new Group_join_queue(); - $req->group_id = $this->group->id; - return $req->count(); - } -} diff --git a/lib/groupprofileblock.php b/lib/groupprofileblock.php index 258a2f792e..9372a78680 100644 --- a/lib/groupprofileblock.php +++ b/lib/groupprofileblock.php @@ -122,6 +122,15 @@ class GroupProfileBlock extends ProfileBlock // TRANS: Link text for link on user profile. _m('BUTTON','Edit')); $this->out->elementEnd('li'); + $this->out->elementStart('li', 'entity_edit'); + $this->out->element('a', array('href' => common_local_url('grouplogo', + array('nickname' => $this->group->nickname)), + // TRANS: Tooltip for menu item in the group navigation page. Only shown for group administrators. + // TRANS: %s is the nickname of the group. + 'title' => sprintf(_m('TOOLTIP','Add or edit %s logo'), $nickname)), + // TRANS: Link text for link on user profile. + _m('MENU','Logo')); + $this->out->elementEnd('li'); } if ($cur && $cur->hasRight(Right::DELETEGROUP)) { $this->out->elementStart('li', 'entity_delete'); diff --git a/lib/grouptagcloudsection.php b/lib/grouptagcloudsection.php index 5b914c0073..5ed14560ce 100644 --- a/lib/grouptagcloudsection.php +++ b/lib/grouptagcloudsection.php @@ -54,7 +54,7 @@ class GroupTagCloudSection extends TagCloudSection { // TRANS: Title for group tag cloud section. // TRANS: %s is a group name. - return sprintf(_('Tags in %s group\'s notices'), $this->group->nickname); + return _('Tags'); } function getTags()