2010-09-30 23:56:38 +01:00
|
|
|
<?php
|
2019-08-10 20:21:09 +01:00
|
|
|
// This file is part of GNU social - https://www.gnu.org/software/social
|
|
|
|
//
|
|
|
|
// GNU social 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.
|
|
|
|
//
|
|
|
|
// GNU social 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 GNU social. If not, see <http://www.gnu.org/licenses/>.
|
2010-09-30 23:56:38 +01:00
|
|
|
|
|
|
|
/**
|
2019-08-10 20:21:09 +01:00
|
|
|
* The GroupFavorited plugin adds a menu item for popular notices in groups.
|
|
|
|
*
|
|
|
|
* @package GroupFavoritedPlugin
|
|
|
|
* @author Brion Vibber <brion@status.net>
|
|
|
|
* @author Diogo Cordeiro <diogo@fc.up.pt>
|
|
|
|
* @copyright 2010-2019 Free Software Foundation, Inc http://www.fsf.org
|
|
|
|
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
2010-09-30 23:56:38 +01:00
|
|
|
*/
|
|
|
|
|
2019-08-10 20:21:09 +01:00
|
|
|
defined('GNUSOCIAL') || die();
|
2010-09-30 23:56:38 +01:00
|
|
|
|
|
|
|
class GroupFavoritedPlugin extends Plugin
|
|
|
|
{
|
2019-08-10 20:21:09 +01:00
|
|
|
const PLUGIN_VERSION = '2.0.1';
|
2019-06-03 01:56:52 +01:00
|
|
|
|
2010-09-30 23:56:38 +01:00
|
|
|
/**
|
|
|
|
* Hook for RouterInitialized event.
|
|
|
|
*
|
2014-11-07 14:24:05 +00:00
|
|
|
* @param URLMapper $m path-to-action mapper
|
2010-09-30 23:56:38 +01:00
|
|
|
* @return boolean hook return
|
2019-08-10 20:21:09 +01:00
|
|
|
* @throws Exception
|
2010-09-30 23:56:38 +01:00
|
|
|
*/
|
2019-08-10 20:21:09 +01:00
|
|
|
public function onRouterInitialized(URLMapper $m)
|
2010-09-30 23:56:38 +01:00
|
|
|
{
|
2019-08-10 20:21:09 +01:00
|
|
|
$m->connect(
|
|
|
|
'group/:nickname/favorited',
|
|
|
|
['action' => 'groupfavorited'],
|
|
|
|
['nickname' => '[a-zA-Z0-9]+']
|
|
|
|
);
|
2010-09-30 23:56:38 +01:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-08-10 20:21:09 +01:00
|
|
|
public function onEndGroupActionsList(GroupProfileBlock $nav, User_group $group)
|
2010-09-30 23:56:38 +01:00
|
|
|
{
|
2019-08-10 20:21:09 +01:00
|
|
|
$nav->out->elementStart('li', 'entity_popular');
|
|
|
|
$nav->out->element(
|
|
|
|
'a',
|
|
|
|
[
|
|
|
|
'href' => common_local_url(
|
|
|
|
'groupfavorited',
|
|
|
|
['nickname' => $group->nickname]
|
|
|
|
),
|
|
|
|
// TRANS: Tooltip for menu item in the group navigation page.
|
|
|
|
// TRANS: %s is the nickname of the group.
|
|
|
|
'title' => sprintf(_m('TOOLTIP', 'Popular notices in %s group'), $group->nickname)
|
|
|
|
],
|
|
|
|
// TRANS: Menu item in the group navigation page.
|
|
|
|
_m('MENU', 'Popular')
|
|
|
|
);
|
|
|
|
$nav->out->elementEnd('li');
|
2010-09-30 23:56:38 +01:00
|
|
|
}
|
2010-10-01 21:01:18 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Provide plugin version information.
|
|
|
|
*
|
|
|
|
* This data is used when showing the version page.
|
|
|
|
*
|
|
|
|
* @param array &$versions array of version data arrays; see EVENTS.txt
|
|
|
|
*
|
2019-08-12 15:03:30 +01:00
|
|
|
* @return bool hook value
|
2010-10-01 21:01:18 +01:00
|
|
|
*/
|
2019-08-12 15:03:30 +01:00
|
|
|
public function onPluginVersion(array &$versions): bool
|
2010-10-01 21:01:18 +01:00
|
|
|
{
|
2019-11-21 00:21:22 +00:00
|
|
|
$url = GNUSOCIAL_ENGINE_REPO_URL . 'tree/master/plugins/GroupFavorited';
|
2010-10-01 21:01:18 +01:00
|
|
|
|
2019-08-12 15:03:30 +01:00
|
|
|
$versions[] = ['name' => 'GroupFavorited',
|
2019-06-03 01:56:52 +01:00
|
|
|
'version' => self::PLUGIN_VERSION,
|
2010-10-01 21:01:18 +01:00
|
|
|
'author' => 'Brion Vibber',
|
|
|
|
'homepage' => $url,
|
|
|
|
'rawdescription' =>
|
|
|
|
// TRANS: Plugin description.
|
2019-08-12 15:03:30 +01:00
|
|
|
_m('This plugin adds a menu item for popular notices in groups.')
|
|
|
|
];
|
2010-10-01 21:01:18 +01:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2010-09-30 23:56:38 +01:00
|
|
|
}
|