[SearchSub][README] No longer is a default plugin since 8614cd77
This commit is contained in:
parent
92388e1734
commit
49da433879
|
@ -2,7 +2,7 @@ The SearchSub plugin allows following all messages with a given search.
|
|||
|
||||
Installation
|
||||
============
|
||||
This plugin is enabled by default
|
||||
- Edit your `config.php` to include `addModule("SearchSub");`
|
||||
|
||||
Settings
|
||||
========
|
||||
|
|
|
@ -1,46 +1,29 @@
|
|||
<?php
|
||||
/**
|
||||
* StatusNet - the distributed open-source microblogging tool
|
||||
* Copyright (C) 2011, StatusNet, Inc.
|
||||
*
|
||||
* A plugin to enable local tab subscription
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* 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 SearchSubPlugin
|
||||
* @package StatusNet
|
||||
* @author Brion Vibber <brion@status.net>
|
||||
* @copyright 2011 StatusNet, Inc.
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
// 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/>.
|
||||
|
||||
if (!defined('STATUSNET')) {
|
||||
exit(1);
|
||||
}
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
/**
|
||||
* SearchSub plugin main class
|
||||
*
|
||||
* @category SearchSubPlugin
|
||||
* @package StatusNet
|
||||
* @category Plugin
|
||||
* @package SearchSubPlugin
|
||||
* @author Brion Vibber <brionv@status.net>
|
||||
* @copyright 2011 StatusNet, Inc.
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
|
||||
* @link http://status.net/
|
||||
* @copyright 2011-2019 Free Software Foundation, Inc http://www.fsf.org
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
class SearchSubPlugin extends Plugin
|
||||
{
|
||||
|
@ -49,11 +32,12 @@ class SearchSubPlugin extends Plugin
|
|||
/**
|
||||
* Database schema setup
|
||||
*
|
||||
* @return bool hook value; true means continue processing, false means stop.
|
||||
* @throws PEAR_Exception
|
||||
* @see Schema
|
||||
*
|
||||
* @return boolean hook value; true means continue processing, false means stop.
|
||||
*/
|
||||
function onCheckSchema()
|
||||
public function onCheckSchema(): bool
|
||||
{
|
||||
$schema = Schema::get();
|
||||
$schema->ensureTable('searchsub', SearchSub::schemaDef());
|
||||
|
@ -65,38 +49,46 @@ class SearchSubPlugin extends Plugin
|
|||
*
|
||||
* @param URLMapper $m path-to-action mapper
|
||||
*
|
||||
* @return boolean hook value; true means continue processing, false means stop.
|
||||
* @return bool hook value; true means continue processing, false means stop.
|
||||
* @throws Exception
|
||||
*/
|
||||
public function onRouterInitialized(URLMapper $m)
|
||||
public function onRouterInitialized(URLMapper $m): bool
|
||||
{
|
||||
$m->connect('search/:search/subscribe',
|
||||
['action' => 'searchsub'],
|
||||
['search' => Router::REGEX_TAG]);
|
||||
$m->connect('search/:search/unsubscribe',
|
||||
['action' => 'searchunsub'],
|
||||
['search' => Router::REGEX_TAG]);
|
||||
$m->connect(':nickname/search-subscriptions',
|
||||
['action' => 'searchsubs'],
|
||||
['nickname' => Nickname::DISPLAY_FMT]);
|
||||
$m->connect(
|
||||
'search/:search/subscribe',
|
||||
['action' => 'searchsub'],
|
||||
['search' => Router::REGEX_TAG]
|
||||
);
|
||||
$m->connect(
|
||||
'search/:search/unsubscribe',
|
||||
['action' => 'searchunsub'],
|
||||
['search' => Router::REGEX_TAG]
|
||||
);
|
||||
$m->connect(
|
||||
':nickname/search-subscriptions',
|
||||
['action' => 'searchsubs'],
|
||||
['nickname' => Nickname::DISPLAY_FMT]
|
||||
);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Plugin version data
|
||||
* Module version data
|
||||
*
|
||||
* @param array &$versions array of version data
|
||||
*
|
||||
* @return value
|
||||
* @return bool
|
||||
* @throws Exception
|
||||
*/
|
||||
public function onPluginVersion(array &$versions): bool
|
||||
{
|
||||
$versions[] = array('name' => 'SearchSub',
|
||||
'version' => self::PLUGIN_VERSION,
|
||||
'author' => 'Brion Vibber',
|
||||
'homepage' => 'https://git.gnu.io/gnu/gnu-social/tree/master/plugins/SearchSub',
|
||||
'rawdescription' =>
|
||||
// TRANS: Plugin description.
|
||||
_m('Plugin to allow following all messages with a given search.'));
|
||||
'version' => self::PLUGIN_VERSION,
|
||||
'author' => 'Brion Vibber',
|
||||
'homepage' => 'https://git.gnu.io/gnu/gnu-social/tree/master/plugins/SearchSub',
|
||||
'rawdescription' =>
|
||||
// TRANS: Module description.
|
||||
_m('Module to allow following all messages with a given search.'));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -110,9 +102,9 @@ class SearchSubPlugin extends Plugin
|
|||
*
|
||||
* @param Notice $notice
|
||||
* @param array $ni in/out map of profile IDs to inbox constants
|
||||
* @return boolean hook result
|
||||
* @return bool hook result
|
||||
*/
|
||||
function onStartNoticeWhoGets(Notice $notice, array &$ni)
|
||||
public function onStartNoticeWhoGets(Notice $notice, array &$ni): bool
|
||||
{
|
||||
// Warning: this is potentially very slow
|
||||
// with a lot of searches!
|
||||
|
@ -148,9 +140,9 @@ class SearchSubPlugin extends Plugin
|
|||
*
|
||||
* @param Notice $notice
|
||||
* @param string $search
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
function matchSearch(Notice $notice, $search)
|
||||
public function matchSearch(Notice $notice, $search): bool
|
||||
{
|
||||
return (mb_stripos($notice->content, $search) !== false);
|
||||
}
|
||||
|
@ -160,15 +152,15 @@ class SearchSubPlugin extends Plugin
|
|||
* @param NoticeSearchAction $action
|
||||
* @param string $q
|
||||
* @param Notice $notice
|
||||
* @return boolean hook result
|
||||
* @return bool hook result
|
||||
*/
|
||||
function onStartNoticeSearchShowResults($action, $q, $notice)
|
||||
public function onStartNoticeSearchShowResults($action, $q, $notice): bool
|
||||
{
|
||||
$user = common_current_user();
|
||||
if ($user) {
|
||||
$search = $q;
|
||||
$searchsub = SearchSub::pkeyGet(array('search' => $search,
|
||||
'profile_id' => $user->id));
|
||||
'profile_id' => $user->id));
|
||||
if ($searchsub) {
|
||||
$form = new SearchUnsubForm($action, $search);
|
||||
} else {
|
||||
|
@ -190,19 +182,22 @@ class SearchSubPlugin extends Plugin
|
|||
*
|
||||
* @param Widget $widget Widget being executed
|
||||
*
|
||||
* @return boolean hook return
|
||||
* @return bool hook return
|
||||
* @throws Exception
|
||||
*/
|
||||
function onEndSubGroupNav($widget)
|
||||
public function onEndSubGroupNav($widget): bool
|
||||
{
|
||||
$action = $widget->out;
|
||||
$action_name = $action->trimmed('action');
|
||||
|
||||
$action->menuItem(common_local_url('searchsubs', array('nickname' => $action->user->nickname)),
|
||||
// TRANS: SearchSub plugin menu item on user settings page.
|
||||
_m('MENU', 'Searches'),
|
||||
// TRANS: SearchSub plugin tooltip for user settings menu item.
|
||||
_m('Configure search subscriptions'),
|
||||
$action_name == 'searchsubs' && $action->arg('nickname') == $action->user->nickname);
|
||||
$action->menuItem(
|
||||
common_local_url('searchsubs', array('nickname' => $action->user->nickname)),
|
||||
// TRANS: SearchSub plugin menu item on user settings page.
|
||||
_m('MENU', 'Searches'),
|
||||
// TRANS: SearchSub plugin tooltip for user settings menu item.
|
||||
_m('Configure search subscriptions'),
|
||||
$action_name == 'searchsubs' && $action->arg('nickname') == $action->user->nickname
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -215,20 +210,20 @@ class SearchSubPlugin extends Plugin
|
|||
* @param string $arg
|
||||
* @param User $user
|
||||
* @param Command $result
|
||||
* @return boolean hook result
|
||||
* @return bool hook result
|
||||
*/
|
||||
function onEndInterpretCommand($cmd, $arg, $user, &$result)
|
||||
public function onEndInterpretCommand($cmd, $arg, $user, &$result): bool
|
||||
{
|
||||
if ($result instanceof TrackCommand) {
|
||||
$result = new SearchSubTrackCommand($user, $arg);
|
||||
return false;
|
||||
} else if ($result instanceof TrackOffCommand) {
|
||||
} elseif ($result instanceof TrackOffCommand) {
|
||||
$result = new SearchSubTrackOffCommand($user);
|
||||
return false;
|
||||
} else if ($result instanceof TrackingCommand) {
|
||||
} elseif ($result instanceof TrackingCommand) {
|
||||
$result = new SearchSubTrackingCommand($user);
|
||||
return false;
|
||||
} else if ($result instanceof UntrackCommand) {
|
||||
} elseif ($result instanceof UntrackCommand) {
|
||||
$result = new SearchSubUntrackCommand($user, $arg);
|
||||
return false;
|
||||
} else {
|
||||
|
@ -236,7 +231,7 @@ class SearchSubPlugin extends Plugin
|
|||
}
|
||||
}
|
||||
|
||||
function onHelpCommandMessages($cmd, &$commands)
|
||||
public function onHelpCommandMessages($cmd, &$commands): void
|
||||
{
|
||||
// TRANS: Help message for IM/SMS command "track <word>"
|
||||
$commands["track <word>"] = _m('COMMANDHELP', "Start following notices matching the given search query.");
|
||||
|
@ -252,7 +247,7 @@ class SearchSubPlugin extends Plugin
|
|||
$commands["tracking"] = _m('COMMANDHELP', "List all your search subscriptions.");
|
||||
}
|
||||
|
||||
function onEndDefaultLocalNav($menu, $user)
|
||||
public function onEndDefaultLocalNav($menu, $user): bool
|
||||
{
|
||||
$user = common_current_user();
|
||||
|
||||
|
@ -262,7 +257,7 @@ class SearchSubPlugin extends Plugin
|
|||
if (!empty($searches) && count($searches) > 0) {
|
||||
$searchSubMenu = new SearchSubMenu($menu->out, $user, $searches);
|
||||
// TRANS: Sub menu for searches.
|
||||
$menu->submenu(_m('MENU','Searches'), $searchSubMenu);
|
||||
$menu->submenu(_m('MENU', 'Searches'), $searchSubMenu);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,37 +1,20 @@
|
|||
<?php
|
||||
/**
|
||||
* StatusNet - the distributed open-source microblogging tool
|
||||
* Copyright (C) 2008-2011, StatusNet, Inc.
|
||||
*
|
||||
* Search subscription action.
|
||||
*
|
||||
* 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/>.
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category Action
|
||||
* @package StatusNet
|
||||
* @author Brion Vibber <brion@status.net>
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @copyright 2008-2010 StatusNet, Inc.
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3
|
||||
* @link http://status.net/
|
||||
*/
|
||||
// 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/>.
|
||||
|
||||
if (!defined('STATUSNET')) {
|
||||
exit(1);
|
||||
}
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
/**
|
||||
* Search subscription action
|
||||
|
@ -43,27 +26,27 @@ if (!defined('STATUSNET')) {
|
|||
*
|
||||
* Only works if the current user is logged in.
|
||||
*
|
||||
* @category Action
|
||||
* @package StatusNet
|
||||
* @category Plugin
|
||||
* @package SearchSubPlugin
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @author Brion Vibber <brion@status.net>
|
||||
* @copyright 2008-2011 StatusNet, Inc.
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3
|
||||
* @link http://status.net/
|
||||
* @copyright 2011-2019 Free Software Foundation, Inc http://www.fsf.org
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
class SearchsubAction extends Action
|
||||
{
|
||||
var $user;
|
||||
var $search;
|
||||
public $user;
|
||||
public $search;
|
||||
|
||||
/**
|
||||
* Check pre-requisites and instantiate attributes
|
||||
*
|
||||
* @param Array $args array of arguments (URL, GET, POST)
|
||||
* @param array $args array of arguments (URL, GET, POST)
|
||||
*
|
||||
* @return boolean success flag
|
||||
* @return bool success flag
|
||||
* @throws ClientException
|
||||
*/
|
||||
function prepare(array $args = array())
|
||||
public function prepare(array $args = [])
|
||||
{
|
||||
parent::prepare($args);
|
||||
if ($this->boolean('ajax')) {
|
||||
|
@ -84,8 +67,8 @@ class SearchsubAction extends Action
|
|||
|
||||
if (!$token || $token != common_session_token()) {
|
||||
// TRANS: Client error displayed when the session token is not okay.
|
||||
$this->clientError(_m('There was a problem with your session token.'.
|
||||
' Try again, please.'));
|
||||
$this->clientError(_m('There was a problem with your session token.' .
|
||||
' Try again, please.'));
|
||||
}
|
||||
|
||||
// Only for logged-in users
|
||||
|
@ -114,16 +97,17 @@ class SearchsubAction extends Action
|
|||
*
|
||||
* Does the subscription and returns results.
|
||||
*
|
||||
* @param Array $args unused.
|
||||
*
|
||||
* @return void
|
||||
* @throws ClientException
|
||||
*/
|
||||
function handle()
|
||||
public function handle()
|
||||
{
|
||||
// Throws exception on error
|
||||
|
||||
SearchSub::start($this->user->getProfile(),
|
||||
$this->search);
|
||||
SearchSub::start(
|
||||
$this->user->getProfile(),
|
||||
$this->search
|
||||
);
|
||||
|
||||
if ($this->boolean('ajax')) {
|
||||
$this->startHTML('text/xml;charset=utf-8');
|
||||
|
@ -137,8 +121,10 @@ class SearchsubAction extends Action
|
|||
$this->elementEnd('body');
|
||||
$this->endHTML();
|
||||
} else {
|
||||
$url = common_local_url('search',
|
||||
array('search' => $this->search));
|
||||
$url = common_local_url(
|
||||
'search',
|
||||
array('search' => $this->search)
|
||||
);
|
||||
common_redirect($url, 303);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,47 +1,33 @@
|
|||
<?php
|
||||
/**
|
||||
* StatusNet, the distributed open-source microblogging tool
|
||||
*
|
||||
* List of a user's subscriptions
|
||||
*
|
||||
* 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 Social
|
||||
* @package StatusNet
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @author Sarven Capadisli <csarven@status.net>
|
||||
* @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://status.net/
|
||||
*/
|
||||
// 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/>.
|
||||
|
||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
/**
|
||||
* A list of the user's subscriptions
|
||||
*
|
||||
* @category Social
|
||||
* @package StatusNet
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
* @category Plugin
|
||||
* @package SearchSubPlugin
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @copyright 2011-2019 Free Software Foundation, Inc http://www.fsf.org
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
class SearchSubsAction extends GalleryAction
|
||||
{
|
||||
function title()
|
||||
public function title()
|
||||
{
|
||||
if ($this->page == 1) {
|
||||
// TRANS: Header for subscriptions overview for a user (first page).
|
||||
|
@ -50,35 +36,45 @@ class SearchSubsAction extends GalleryAction
|
|||
} else {
|
||||
// TRANS: Header for subscriptions overview for a user (not first page).
|
||||
// TRANS: %1$s is a user nickname, %2$d is the page number.
|
||||
return sprintf(_m('%1$s\'s search subscriptions, page %2$d'),
|
||||
$this->getTarget()->getNickname(),
|
||||
$this->page);
|
||||
return sprintf(
|
||||
_m('%1$s\'s search subscriptions, page %2$d'),
|
||||
$this->getTarget()->getNickname(),
|
||||
$this->page
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function showPageNotice()
|
||||
public function showPageNotice()
|
||||
{
|
||||
if ($this->scoped instanceof Profile && $this->scoped->sameAs($this->getTarget())) {
|
||||
$this->element('p', null,
|
||||
// TRANS: Page notice for page with an overview of all search subscriptions
|
||||
// TRANS: of the logged in user's own profile.
|
||||
_m('You have subscribed to receive all notices on this site matching the following searches:'));
|
||||
$this->element(
|
||||
'p',
|
||||
null,
|
||||
// TRANS: Page notice for page with an overview of all search subscriptions
|
||||
// TRANS: of the logged in user's own profile.
|
||||
_m('You have subscribed to receive all notices on this site matching the following searches:')
|
||||
);
|
||||
} else {
|
||||
$this->element('p', null,
|
||||
// TRANS: Page notice for page with an overview of all subscriptions of a user other
|
||||
// TRANS: than the logged in user. %s is the user nickname.
|
||||
sprintf(_m('%s has subscribed to receive all notices on this site matching the following searches:'),
|
||||
$this->getTarget()->getNickname()));
|
||||
$this->element(
|
||||
'p',
|
||||
null,
|
||||
// TRANS: Page notice for page with an overview of all subscriptions of a user other
|
||||
// TRANS: than the logged in user. %s is the user nickname.
|
||||
sprintf(
|
||||
_m('%s has subscribed to receive all notices on this site matching the following searches:'),
|
||||
$this->getTarget()->getNickname()
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function showContent()
|
||||
public function showContent()
|
||||
{
|
||||
if (Event::handle('StartShowTagSubscriptionsContent', array($this))) {
|
||||
parent::showContent();
|
||||
|
||||
$offset = ($this->page-1) * PROFILES_PER_PAGE;
|
||||
$limit = PROFILES_PER_PAGE + 1;
|
||||
$offset = ($this->page - 1) * PROFILES_PER_PAGE;
|
||||
$limit = PROFILES_PER_PAGE + 1;
|
||||
|
||||
$cnt = 0;
|
||||
|
||||
|
@ -97,30 +93,33 @@ class SearchSubsAction extends GalleryAction
|
|||
$this->showEmptyListMessage();
|
||||
}
|
||||
|
||||
$this->pagination($this->page > 1, $cnt > PROFILES_PER_PAGE,
|
||||
$this->page, 'searchsubs',
|
||||
array('nickname' => $this->getTarget()->getNickname()));
|
||||
$this->pagination(
|
||||
$this->page > 1,
|
||||
$cnt > PROFILES_PER_PAGE,
|
||||
$this->page,
|
||||
'searchsubs',
|
||||
array('nickname' => $this->getTarget()->getNickname())
|
||||
);
|
||||
|
||||
|
||||
Event::handle('EndShowTagSubscriptionsContent', array($this));
|
||||
}
|
||||
}
|
||||
|
||||
function showEmptyListMessage()
|
||||
public function showEmptyListMessage()
|
||||
{
|
||||
if (common_logged_in()) {
|
||||
if ($this->scoped->sameAs($this->getTarget())) {
|
||||
// TRANS: Search subscription list text when the logged in user has no search subscriptions.
|
||||
$message = _m('You are not subscribed to any text searches right now. You can push the "Subscribe" button ' .
|
||||
'on any notice text search to automatically receive any public messages on this site that match that ' .
|
||||
'search, even if you are not subscribed to the poster.');
|
||||
'on any notice text search to automatically receive any public messages on this site that match that ' .
|
||||
'search, even if you are not subscribed to the poster.');
|
||||
} else {
|
||||
// TRANS: Search subscription list text when looking at the subscriptions for a of a user other
|
||||
// TRANS: than the logged in user that has no search subscriptions. %s is the user nickname.
|
||||
$message = sprintf(_m('%s is not subscribed to any searches.'), $this->getTarget()->getNickname());
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// TRANS: Subscription list text when looking at the subscriptions for a of a user that has none
|
||||
// TRANS: as an anonymous user. %s is the user nickname.
|
||||
$message = sprintf(_m('%s is not subscribed to any searches.'), $this->getTarget()->getNickname());
|
||||
|
@ -136,7 +135,7 @@ class SearchSubsAction extends GalleryAction
|
|||
|
||||
class SearchSubscriptionsList extends SubscriptionList
|
||||
{
|
||||
function newListItem(Profile $searchsub)
|
||||
public function newListItem(Profile $searchsub)
|
||||
{
|
||||
return new SearchSubscriptionsListItem($searchsub, $this->owner, $this->action);
|
||||
}
|
||||
|
@ -144,12 +143,12 @@ class SearchSubscriptionsList extends SubscriptionList
|
|||
|
||||
class SearchSubscriptionsListItem extends SubscriptionListItem
|
||||
{
|
||||
function startItem()
|
||||
public function startItem()
|
||||
{
|
||||
$this->out->elementStart('li', array('class' => 'searchsub'));
|
||||
}
|
||||
|
||||
function showProfile()
|
||||
public function showProfile()
|
||||
{
|
||||
$searchsub = $this->profile;
|
||||
$search = $searchsub->search;
|
||||
|
@ -163,10 +162,12 @@ class SearchSubscriptionsListItem extends SubscriptionListItem
|
|||
$url = common_local_url('noticesearch', array('q' => $search));
|
||||
// TRANS: Search subscription list item. %1$s is a URL to a notice search,
|
||||
// TRANS: %2$s are the search criteria, %3$s is a datestring.
|
||||
$linkline = sprintf(_m('"<a href="%1$s">%2$s</a>" since %3$s'),
|
||||
htmlspecialchars($url),
|
||||
htmlspecialchars($search),
|
||||
common_date_string($searchsub->created));
|
||||
$linkline = sprintf(
|
||||
_m('"<a href="%1$s">%2$s</a>" since %3$s'),
|
||||
htmlspecialchars($url),
|
||||
htmlspecialchars($search),
|
||||
common_date_string($searchsub->created)
|
||||
);
|
||||
|
||||
$this->out->elementStart('div', 'searchsub-item');
|
||||
$this->out->raw($linkline);
|
||||
|
@ -174,11 +175,11 @@ class SearchSubscriptionsListItem extends SubscriptionListItem
|
|||
$this->out->elementEnd('div');
|
||||
}
|
||||
|
||||
function showActions()
|
||||
public function showActions()
|
||||
{
|
||||
}
|
||||
|
||||
function showOwnerControls()
|
||||
public function showOwnerControls()
|
||||
{
|
||||
$this->out->elementStart('div', 'entity_actions');
|
||||
|
||||
|
|
|
@ -1,37 +1,20 @@
|
|||
<?php
|
||||
/**
|
||||
* StatusNet - the distributed open-source microblogging tool
|
||||
* Copyright (C) 2008-2011, StatusNet, Inc.
|
||||
*
|
||||
* Search subscription action.
|
||||
*
|
||||
* 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/>.
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category Action
|
||||
* @package StatusNet
|
||||
* @author Brion Vibber <brion@status.net>
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @copyright 2008-2010 StatusNet, Inc.
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3
|
||||
* @link http://status.net/
|
||||
*/
|
||||
// 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/>.
|
||||
|
||||
if (!defined('STATUSNET')) {
|
||||
exit(1);
|
||||
}
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
/**
|
||||
* Search unsubscription action
|
||||
|
@ -43,13 +26,12 @@ if (!defined('STATUSNET')) {
|
|||
*
|
||||
* Only works if the current user is logged in.
|
||||
*
|
||||
* @category Action
|
||||
* @package StatusNet
|
||||
* @category Plugin
|
||||
* @package SearchSubPlugin
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @author Brion Vibber <brion@status.net>
|
||||
* @copyright 2008-2011 StatusNet, Inc.
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3
|
||||
* @link http://status.net/
|
||||
* @copyright 2011-2019 Free Software Foundation, Inc http://www.fsf.org
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
class SearchunsubAction extends SearchsubAction
|
||||
{
|
||||
|
@ -58,16 +40,17 @@ class SearchunsubAction extends SearchsubAction
|
|||
*
|
||||
* Does the subscription and returns results.
|
||||
*
|
||||
* @param Array $args unused.
|
||||
*
|
||||
* @return void
|
||||
* @throws ClientException
|
||||
*/
|
||||
function handle()
|
||||
public function handle()
|
||||
{
|
||||
// Throws exception on error
|
||||
|
||||
SearchSub::cancel($this->user->getProfile(),
|
||||
$this->search);
|
||||
SearchSub::cancel(
|
||||
$this->user->getProfile(),
|
||||
$this->search
|
||||
);
|
||||
|
||||
if ($this->boolean('ajax')) {
|
||||
$this->startHTML('text/xml;charset=utf-8');
|
||||
|
@ -81,8 +64,10 @@ class SearchunsubAction extends SearchsubAction
|
|||
$this->elementEnd('body');
|
||||
$this->endHTML();
|
||||
} else {
|
||||
$url = common_local_url('search',
|
||||
array('search' => $this->search));
|
||||
$url = common_local_url(
|
||||
'search',
|
||||
array('search' => $this->search)
|
||||
);
|
||||
common_redirect($url, 303);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,48 +1,40 @@
|
|||
<?php
|
||||
// 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/>.
|
||||
|
||||
/**
|
||||
* Data class to store local search subscriptions
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category SearchSubPlugin
|
||||
* @package StatusNet
|
||||
* @author Brion Vibber <brion@status.net>
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
|
||||
* @link http://status.net/
|
||||
*
|
||||
* StatusNet - the distributed open-source microblogging tool
|
||||
* Copyright (C) 2011, StatusNet, Inc.
|
||||
*
|
||||
* 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 Plugin
|
||||
* @package SearchSubPlugin
|
||||
* @author Brion Vibber <brion@status.net>
|
||||
* @copyright 2011-2019 Free Software Foundation, Inc http://www.fsf.org
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
|
||||
if (!defined('STATUSNET')) {
|
||||
exit(1);
|
||||
}
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
/**
|
||||
* For storing the search subscriptions
|
||||
*
|
||||
* @category PollPlugin
|
||||
* @package StatusNet
|
||||
* @author Brion Vibber <brion@status.net>
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
|
||||
* @link http://status.net/
|
||||
* @author Brion Vibber <brion@status.net>
|
||||
* @copyright 2011-2019 Free Software Foundation, Inc http://www.fsf.org
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*
|
||||
* @see DB_DataObject
|
||||
*/
|
||||
|
||||
class SearchSub extends Managed_DataObject
|
||||
{
|
||||
public $__table = 'searchsub'; // table name
|
||||
|
@ -80,7 +72,7 @@ class SearchSub extends Managed_DataObject
|
|||
* @param string $search subscribee
|
||||
* @return SearchSub
|
||||
*/
|
||||
static function start(Profile $profile, $search)
|
||||
public static function start(Profile $profile, $search)
|
||||
{
|
||||
$ts = new SearchSub();
|
||||
$ts->search = $search;
|
||||
|
@ -97,27 +89,27 @@ class SearchSub extends Managed_DataObject
|
|||
* @param profile $profile subscriber
|
||||
* @param string $search subscribee
|
||||
*/
|
||||
static function cancel(Profile $profile, $search)
|
||||
public static function cancel(Profile $profile, $search)
|
||||
{
|
||||
$ts = SearchSub::pkeyGet(array('search' => $search,
|
||||
'profile_id' => $profile->id));
|
||||
'profile_id' => $profile->id));
|
||||
if ($ts) {
|
||||
$ts->delete();
|
||||
self::blow('searchsub:by_profile:%d', $profile->id);
|
||||
}
|
||||
}
|
||||
|
||||
static function forProfile(Profile $profile)
|
||||
public static function forProfile(Profile $profile)
|
||||
{
|
||||
$searches = array();
|
||||
|
||||
$keypart = sprintf('searchsub:by_profile:%d', $profile->id);
|
||||
$searchstring = self::cacheGet($keypart);
|
||||
|
||||
|
||||
if ($searchstring !== false) {
|
||||
if (!empty($searchstring)) {
|
||||
$searches = explode(',', $searchstring);
|
||||
}
|
||||
if (!empty($searchstring)) {
|
||||
$searches = explode(',', $searchstring);
|
||||
}
|
||||
} else {
|
||||
$searchsub = new SearchSub();
|
||||
$searchsub->profile_id = $profile->id;
|
||||
|
|
|
@ -1,48 +1,31 @@
|
|||
<?php
|
||||
/**
|
||||
* StatusNet, the distributed open-source microblogging tool
|
||||
*
|
||||
* Form for subscribing to a search
|
||||
*
|
||||
* 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 SearchSubPlugin
|
||||
* @package StatusNet
|
||||
* @author Brion Vibber <brion@status.net>
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @author Sarven Capadisli <csarven@status.net>
|
||||
* @copyright 2009-2011 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/
|
||||
*/
|
||||
// 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/>.
|
||||
|
||||
if (!defined('STATUSNET') && !defined('LACONICA')) {
|
||||
exit(1);
|
||||
}
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
/**
|
||||
* Form for subscribing to a user
|
||||
*
|
||||
* @category SearchSubPlugin
|
||||
* @package StatusNet
|
||||
* @author Brion Vibber <brion@status.net>
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @author Sarven Capadisli <csarven@status.net>
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
* @category Plugin
|
||||
* @package SearchSubPlugin
|
||||
* @author Brion Vibber <brion@status.net>
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @author Sarven Capadisli <csarven@status.net>
|
||||
* @copyright 2011-2019 Free Software Foundation, Inc http://www.fsf.org
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*
|
||||
* @see UnsubscribeForm
|
||||
*/
|
||||
|
@ -51,15 +34,15 @@ class SearchSubForm extends Form
|
|||
/**
|
||||
* Name of search to subscribe to
|
||||
*/
|
||||
var $search = '';
|
||||
public $search = '';
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param HTMLOutputter $out output channel
|
||||
* @param string $search name of search to subscribe to
|
||||
* @param Action $out output channel (usually HTMLOutputter)
|
||||
* @param string $search name of search to subscribe to
|
||||
*/
|
||||
function __construct($out=null, $search=null)
|
||||
public function __construct($out = null, $search = null)
|
||||
{
|
||||
parent::__construct($out);
|
||||
|
||||
|
@ -71,7 +54,7 @@ class SearchSubForm extends Form
|
|||
*
|
||||
* @return int ID of the form
|
||||
*/
|
||||
function id()
|
||||
public function id()
|
||||
{
|
||||
return 'search-subscribe-' . $this->search;
|
||||
}
|
||||
|
@ -82,7 +65,7 @@ class SearchSubForm extends Form
|
|||
*
|
||||
* @return string of the form class
|
||||
*/
|
||||
function formClass()
|
||||
public function formClass()
|
||||
{
|
||||
// class to match existing styles...
|
||||
return 'form_user_subscribe ajax';
|
||||
|
@ -94,7 +77,7 @@ class SearchSubForm extends Form
|
|||
*
|
||||
* @return string URL of the action
|
||||
*/
|
||||
function action()
|
||||
public function action()
|
||||
{
|
||||
return common_local_url('searchsub', array('search' => $this->search));
|
||||
}
|
||||
|
@ -103,8 +86,9 @@ class SearchSubForm extends Form
|
|||
* Legend of the Form
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
function formLegend()
|
||||
public function formLegend()
|
||||
{
|
||||
// TRANS: Form legend.
|
||||
$this->out->element('legend', null, _m('Subscribe to this search'));
|
||||
|
@ -115,26 +99,31 @@ class SearchSubForm extends Form
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
function formData()
|
||||
public function formData()
|
||||
{
|
||||
$this->out->hidden('subscribeto-' . $this->search,
|
||||
$this->search,
|
||||
'subscribeto');
|
||||
$this->out->hidden(
|
||||
'subscribeto-' . $this->search,
|
||||
$this->search,
|
||||
'subscribeto'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Action elements
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
function formActions()
|
||||
public function formActions()
|
||||
{
|
||||
$this->out->submit('submit',
|
||||
// TRANS: Button text for subscribing to a search.
|
||||
_m('BUTTON','Subscribe'),
|
||||
'submit',
|
||||
null,
|
||||
// TRANS: Button title for subscribing to a search.
|
||||
_m('Subscribe to this search.'));
|
||||
$this->out->submit(
|
||||
'submit',
|
||||
// TRANS: Button text for subscribing to a search.
|
||||
_m('BUTTON', 'Subscribe'),
|
||||
'submit',
|
||||
null,
|
||||
// TRANS: Button title for subscribing to a search.
|
||||
_m('Subscribe to this search.')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,48 +1,31 @@
|
|||
<?php
|
||||
/**
|
||||
* StatusNet, the distributed open-source microblogging tool
|
||||
*
|
||||
* Form for subscribing to a search
|
||||
*
|
||||
* 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 SearchSubPlugin
|
||||
* @package StatusNet
|
||||
* @author Brion Vibber <brion@status.net>
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @author Sarven Capadisli <csarven@status.net>
|
||||
* @copyright 2009-2011 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/
|
||||
*/
|
||||
// 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/>.
|
||||
|
||||
if (!defined('STATUSNET') && !defined('LACONICA')) {
|
||||
exit(1);
|
||||
}
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
/**
|
||||
* Form for subscribing to a user
|
||||
*
|
||||
* @category SearchSubPlugin
|
||||
* @package StatusNet
|
||||
* @author Brion Vibber <brion@status.net>
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @author Sarven Capadisli <csarven@status.net>
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
* @category Plugin
|
||||
* @package SearchSubPlugin
|
||||
* @author Brion Vibber <brion@status.net>
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @author Sarven Capadisli <csarven@status.net>
|
||||
* @copyright 2011-2019 Free Software Foundation, Inc http://www.fsf.org
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*
|
||||
* @see UnsubscribeForm
|
||||
*/
|
||||
|
@ -53,7 +36,7 @@ class SearchUnsubForm extends SearchSubForm
|
|||
*
|
||||
* @return int ID of the form
|
||||
*/
|
||||
function id()
|
||||
public function id()
|
||||
{
|
||||
return 'search-unsubscribe-' . $this->search;
|
||||
}
|
||||
|
@ -63,7 +46,7 @@ class SearchUnsubForm extends SearchSubForm
|
|||
*
|
||||
* @return string of the form class
|
||||
*/
|
||||
function formClass()
|
||||
public function formClass()
|
||||
{
|
||||
// class to match existing styles...
|
||||
return 'form_user_unsubscribe ajax';
|
||||
|
@ -74,7 +57,7 @@ class SearchUnsubForm extends SearchSubForm
|
|||
*
|
||||
* @return string URL of the action
|
||||
*/
|
||||
function action()
|
||||
public function action()
|
||||
{
|
||||
return common_local_url('searchunsub', array('search' => $this->search));
|
||||
}
|
||||
|
@ -83,8 +66,9 @@ class SearchUnsubForm extends SearchSubForm
|
|||
* Legend of the Form
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
function formLegend()
|
||||
public function formLegend()
|
||||
{
|
||||
// TRANS: Form legend.
|
||||
$this->out->element('legend', null, _m('Unsubscribe from this search'));
|
||||
|
@ -94,15 +78,18 @@ class SearchUnsubForm extends SearchSubForm
|
|||
* Action elements
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
function formActions()
|
||||
public function formActions()
|
||||
{
|
||||
$this->out->submit('submit',
|
||||
// TRANS: Button text for unsubscribing from a text search.
|
||||
_m('BUTTON','Unsubscribe'),
|
||||
'submit',
|
||||
null,
|
||||
// TRANS: Button title for unsubscribing from a text search.
|
||||
_m('Unsubscribe from this search.'));
|
||||
$this->out->submit(
|
||||
'submit',
|
||||
// TRANS: Button text for unsubscribing from a text search.
|
||||
_m('BUTTON', 'Unsubscribe'),
|
||||
'submit',
|
||||
null,
|
||||
// TRANS: Button title for unsubscribing from a text search.
|
||||
_m('Unsubscribe from this search.')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,92 +1,73 @@
|
|||
<?php
|
||||
/**
|
||||
* StatusNet - the distributed open-source microblogging tool
|
||||
* Copyright (C) 2011, StatusNet, Inc.
|
||||
*
|
||||
* Menu to show searches you're subscribed to
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* 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 Menu
|
||||
* @package StatusNet
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @copyright 2011 StatusNet, Inc.
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
// 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/>.
|
||||
|
||||
if (!defined('STATUSNET')) {
|
||||
// This check helps protect against security problems;
|
||||
// your code file can't be executed directly from the web.
|
||||
exit(1);
|
||||
}
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
/**
|
||||
* Class comment
|
||||
*
|
||||
* @category General
|
||||
* @package StatusNet
|
||||
* @category Plugin
|
||||
* @package SearchSubPlugin
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @copyright 2011 StatusNet, Inc.
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
|
||||
* @link http://status.net/
|
||||
* @copyright 2011-2019 Free Software Foundation, Inc http://www.fsf.org
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
|
||||
class SearchSubMenu extends MoreMenu
|
||||
{
|
||||
protected $user;
|
||||
protected $searches;
|
||||
|
||||
function __construct($out, $user, $searches)
|
||||
public function __construct($out, $user, $searches)
|
||||
{
|
||||
parent::__construct($out);
|
||||
$this->user = $user;
|
||||
$this->searches = $searches;
|
||||
}
|
||||
|
||||
function tag()
|
||||
public function tag()
|
||||
{
|
||||
return 'searchsubs';
|
||||
}
|
||||
|
||||
function seeAllItem()
|
||||
public function seeAllItem()
|
||||
{
|
||||
return array('searchsubs',
|
||||
array('nickname' => $this->user->nickname),
|
||||
_('See all'),
|
||||
_('See all searches you are following'));
|
||||
array('nickname' => $this->user->nickname),
|
||||
_('See all'),
|
||||
_('See all searches you are following'));
|
||||
}
|
||||
|
||||
function getItems()
|
||||
public function getItems()
|
||||
{
|
||||
$items = array();
|
||||
|
||||
|
||||
foreach ($this->searches as $search) {
|
||||
if (!empty($search)) {
|
||||
$items[] = array('noticesearch',
|
||||
array('q' => $search),
|
||||
sprintf('"%s"', $search),
|
||||
sprintf(_('Notices including %s'), $search));;
|
||||
array('q' => $search),
|
||||
sprintf('"%s"', $search),
|
||||
sprintf(_('Notices including %s'), $search));;
|
||||
}
|
||||
}
|
||||
|
||||
return $items;
|
||||
}
|
||||
}
|
||||
|
||||
function item($actionName, array $args, $label, $description, $id=null, $cls=null)
|
||||
public function item($actionName, array $args, $label, $description, $id = null, $cls = null)
|
||||
{
|
||||
if (empty($id)) {
|
||||
$id = $this->menuItemID($actionName, $args);
|
||||
|
@ -99,12 +80,13 @@ class SearchSubMenu extends MoreMenu
|
|||
$url = common_local_url($actionName, $args);
|
||||
}
|
||||
|
||||
$this->out->menuItem($url,
|
||||
$label,
|
||||
$description,
|
||||
$this->isCurrent($actionName, $args),
|
||||
$id,
|
||||
$cls);
|
||||
$this->out->menuItem(
|
||||
$url,
|
||||
$label,
|
||||
$description,
|
||||
$this->isCurrent($actionName, $args),
|
||||
$id,
|
||||
$cls
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,20 +1,36 @@
|
|||
<?php
|
||||
// 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/>.
|
||||
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
class SearchSubTrackCommand extends Command
|
||||
{
|
||||
var $keyword = null;
|
||||
public $keyword = null;
|
||||
|
||||
function __construct($user, $keyword)
|
||||
public function __construct($user, $keyword)
|
||||
{
|
||||
parent::__construct($user);
|
||||
$this->keyword = $keyword;
|
||||
}
|
||||
|
||||
function handle($channel)
|
||||
public function handle($channel)
|
||||
{
|
||||
$cur = $this->user;
|
||||
$searchsub = SearchSub::pkeyGet(array('search' => $this->keyword,
|
||||
'profile_id' => $cur->id));
|
||||
'profile_id' => $cur->id));
|
||||
|
||||
if ($searchsub) {
|
||||
// TRANS: Error text shown a user tries to track a search query they're already subscribed to.
|
||||
|
@ -26,13 +42,17 @@ class SearchSubTrackCommand extends Command
|
|||
SearchSub::start($cur->getProfile(), $this->keyword);
|
||||
} catch (Exception $e) {
|
||||
// TRANS: Message given having failed to set up a search subscription by track command.
|
||||
$channel->error($cur, sprintf(_m('Could not start a search subscription for query "%s".'),
|
||||
$this->keyword));
|
||||
$channel->error($cur, sprintf(
|
||||
_m('Could not start a search subscription for query "%s".'),
|
||||
$this->keyword
|
||||
));
|
||||
return;
|
||||
}
|
||||
|
||||
// TRANS: Message given having added a search subscription by track command.
|
||||
$channel->output($cur, sprintf(_m('You are subscribed to the search "%s".'),
|
||||
$this->keyword));
|
||||
$channel->output($cur, sprintf(
|
||||
_m('You are subscribed to the search "%s".'),
|
||||
$this->keyword
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,24 @@
|
|||
<?php
|
||||
// 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/>.
|
||||
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
class SearchSubTrackingCommand extends Command
|
||||
{
|
||||
function handle($channel)
|
||||
public function handle($channel)
|
||||
{
|
||||
$cur = $this->user;
|
||||
$all = new SearchSub();
|
||||
|
@ -21,11 +37,13 @@ class SearchSubTrackingCommand extends Command
|
|||
}
|
||||
|
||||
// TRANS: Separator for list of tracked searches.
|
||||
$separator = _m('SEPARATOR','", "');
|
||||
$separator = _m('SEPARATOR', '", "');
|
||||
|
||||
// TRANS: Message given having disabled all search subscriptions with 'track off'.
|
||||
// TRANS: %s is a list of searches. Separator default is '", "'.
|
||||
$channel->output($cur, sprintf(_m('You are tracking searches for: "%s".'),
|
||||
implode($separator, $list)));
|
||||
$channel->output($cur, sprintf(
|
||||
_m('You are tracking searches for: "%s".'),
|
||||
implode($separator, $list)
|
||||
));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,24 @@
|
|||
<?php
|
||||
// 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/>.
|
||||
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
class SearchSubTrackoffCommand extends Command
|
||||
{
|
||||
function handle($channel)
|
||||
public function handle($channel)
|
||||
{
|
||||
$cur = $this->user;
|
||||
$all = new SearchSub();
|
||||
|
@ -22,8 +38,10 @@ class SearchSubTrackoffCommand extends Command
|
|||
} catch (Exception $e) {
|
||||
// TRANS: Message given having failed to cancel one of the search subs with 'track off' command.
|
||||
// TRANS: %s is the search for which the subscription removal failed.
|
||||
$channel->error($cur, sprintf(_m('Error disabling search subscription for query "%s".'),
|
||||
$all->search));
|
||||
$channel->error($cur, sprintf(
|
||||
_m('Error disabling search subscription for query "%s".'),
|
||||
$all->search
|
||||
));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,20 +1,36 @@
|
|||
<?php
|
||||
// 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/>.
|
||||
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
class SearchSubUntrackCommand extends Command
|
||||
{
|
||||
var $keyword = null;
|
||||
public $keyword = null;
|
||||
|
||||
function __construct($user, $keyword)
|
||||
public function __construct($user, $keyword)
|
||||
{
|
||||
parent::__construct($user);
|
||||
$this->keyword = $keyword;
|
||||
}
|
||||
|
||||
function handle($channel)
|
||||
public function handle($channel)
|
||||
{
|
||||
$cur = $this->user;
|
||||
$searchsub = SearchSub::pkeyGet(array('search' => $this->keyword,
|
||||
'profile_id' => $cur->id));
|
||||
'profile_id' => $cur->id));
|
||||
|
||||
if (!$searchsub) {
|
||||
// TRANS: Error text shown a user tries to untrack a search query they're not subscribed to.
|
||||
|
@ -28,14 +44,18 @@ class SearchSubUntrackCommand extends Command
|
|||
} catch (Exception $e) {
|
||||
// TRANS: Message given having failed to cancel a search subscription by untrack command.
|
||||
// TRANS: %s is the keyword for the query.
|
||||
$channel->error($cur, sprintf(_m('Could not end a search subscription for query "%s".'),
|
||||
$this->keyword));
|
||||
$channel->error($cur, sprintf(
|
||||
_m('Could not end a search subscription for query "%s".'),
|
||||
$this->keyword
|
||||
));
|
||||
return;
|
||||
}
|
||||
|
||||
// TRANS: Message given having removed a search subscription by untrack command.
|
||||
// TRANS: %s is the keyword for the search.
|
||||
$channel->output($cur, sprintf(_m('You are no longer subscribed to the search "%s".'),
|
||||
$this->keyword));
|
||||
$channel->output($cur, sprintf(
|
||||
_m('You are no longer subscribed to the search "%s".'),
|
||||
$this->keyword
|
||||
));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user