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