[PLUGIN API] Bug fixes and improvements
This commit is contained in:
parent
55d049b1e8
commit
b6e7b18c7b
|
@ -1,36 +1,20 @@
|
|||
<?php
|
||||
/**
|
||||
* StatusNet - the distributed open-source microblogging tool
|
||||
* Copyright (C) 2010, StatusNet, Inc.
|
||||
*
|
||||
* Plugin enable 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>
|
||||
* @copyright 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('STATUSNET') || die();
|
||||
|
||||
/**
|
||||
* Plugin enable action.
|
||||
|
@ -52,7 +36,7 @@ if (!defined('STATUSNET')) {
|
|||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3
|
||||
* @link http://status.net/
|
||||
*/
|
||||
class PluginDisableAction extends PluginEnableAction
|
||||
class PlugindisableAction extends PluginenableAction
|
||||
{
|
||||
/**
|
||||
* Value to save into $config['plugins']['disable-<name>']
|
||||
|
@ -70,6 +54,6 @@ class PluginDisableAction extends PluginEnableAction
|
|||
|
||||
protected function successNextForm()
|
||||
{
|
||||
return new EnablePluginForm($this, $this->plugin);
|
||||
return new PluginEnableForm($this, $this->plugin);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,36 +1,20 @@
|
|||
<?php
|
||||
/**
|
||||
* StatusNet - the distributed open-source microblogging tool
|
||||
* Copyright (C) 2010, StatusNet, Inc.
|
||||
*
|
||||
* Plugin enable 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>
|
||||
* @copyright 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('STATUSNET') || die();
|
||||
|
||||
/**
|
||||
* Plugin enable action.
|
||||
|
@ -41,7 +25,7 @@ if (!defined('STATUSNET')) {
|
|||
*
|
||||
* - plugin: plugin name
|
||||
* - token: session token to prevent CSRF attacks
|
||||
* - ajax: boolean; whether to return Ajax or full-browser results
|
||||
* - ajax: bool; whether to return Ajax or full-browser results
|
||||
*
|
||||
* Only works if the current user is logged in.
|
||||
*
|
||||
|
@ -52,7 +36,7 @@ if (!defined('STATUSNET')) {
|
|||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3
|
||||
* @link http://status.net/
|
||||
*/
|
||||
class PluginEnableAction extends Action
|
||||
class PluginenableAction extends Action
|
||||
{
|
||||
var $user;
|
||||
var $plugin;
|
||||
|
@ -60,11 +44,12 @@ class PluginEnableAction extends Action
|
|||
/**
|
||||
* 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())
|
||||
function prepare(array $args = [])
|
||||
{
|
||||
parent::prepare($args);
|
||||
|
||||
|
@ -117,9 +102,8 @@ class PluginEnableAction extends Action
|
|||
*
|
||||
* Does the subscription and returns results.
|
||||
*
|
||||
* @param Array $args unused.
|
||||
*
|
||||
* @return void
|
||||
* @throws ClientException
|
||||
*/
|
||||
function handle()
|
||||
{
|
||||
|
@ -159,6 +143,6 @@ class PluginEnableAction extends Action
|
|||
|
||||
protected function successNextForm()
|
||||
{
|
||||
return new DisablePluginForm($this, $this->plugin);
|
||||
return new PluginDisableForm($this, $this->plugin);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,41 +1,26 @@
|
|||
<?php
|
||||
/**
|
||||
* StatusNet, the distributed open-source microblogging tool
|
||||
*
|
||||
* Plugins administration panel
|
||||
*
|
||||
* 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 Settings
|
||||
* @package StatusNet
|
||||
* @author Brion Vibber <brion@status.net>
|
||||
* @copyright 2010 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')) {
|
||||
exit(1);
|
||||
}
|
||||
defined('STATUSNET') || die();
|
||||
|
||||
/**
|
||||
* Plugins settings
|
||||
*
|
||||
* @category Admin
|
||||
* @package StatusNet
|
||||
* @package GNUsocial
|
||||
* @author Brion Vibber <brion@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/
|
||||
|
@ -46,6 +31,7 @@ class PluginsadminpanelAction extends AdminPanelAction
|
|||
* Returns the page title
|
||||
*
|
||||
* @return string page title
|
||||
* @throws Exception
|
||||
*/
|
||||
function title()
|
||||
{
|
||||
|
@ -62,7 +48,7 @@ class PluginsadminpanelAction extends AdminPanelAction
|
|||
{
|
||||
// TRANS: Instructions at top of plugin admin page.
|
||||
return _('Additional plugins can be enabled and configured manually. ' .
|
||||
'See the <a href="https://git.gnu.io/gnu/gnu-social/blob/master/plugins/README.md">online plugin ' .
|
||||
'See the <a href="https://notabug.org/diogo/gnu-social/src/nightly/plugins/README.md">online plugin ' .
|
||||
'documentation</a> for more details.');
|
||||
}
|
||||
|
||||
|
@ -76,7 +62,7 @@ class PluginsadminpanelAction extends AdminPanelAction
|
|||
$this->elementStart('fieldset', array('id' => 'settings_plugins_default'));
|
||||
|
||||
// TRANS: Admin form section header
|
||||
$this->element('legend', null, _('Default plugins'), 'default');
|
||||
$this->element('legend', null, _('Default plugins'));
|
||||
|
||||
$this->showDefaultPlugins();
|
||||
|
||||
|
|
|
@ -1,33 +1,20 @@
|
|||
<?php
|
||||
/**
|
||||
* StatusNet - the distributed open-source microblogging tool
|
||||
* Copyright (C) 2008-2011, StatusNet, Inc.
|
||||
*
|
||||
* Show version information for this software and plugins
|
||||
*
|
||||
* 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 Info
|
||||
* @package GNUsocial
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @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('GNUSOCIAL')) { exit(1); }
|
||||
defined('STATUSNET') || die();
|
||||
|
||||
/**
|
||||
* Version info page
|
||||
|
@ -46,14 +33,14 @@ if (!defined('GNUSOCIAL')) { exit(1); }
|
|||
*/
|
||||
class VersionAction extends Action
|
||||
{
|
||||
var $pluginVersions = array();
|
||||
var $pluginVersions = [];
|
||||
|
||||
/**
|
||||
* Return true since we're read-only.
|
||||
*
|
||||
* @param array $args other arguments
|
||||
*
|
||||
* @return boolean is read only action?
|
||||
* @return bool is read only action?
|
||||
*/
|
||||
function isReadOnly($args)
|
||||
{
|
||||
|
@ -79,9 +66,9 @@ class VersionAction extends Action
|
|||
*
|
||||
* @param array $args array misc. arguments
|
||||
*
|
||||
* @return boolean true
|
||||
* @return bool true
|
||||
*/
|
||||
protected function prepare(array $args=array())
|
||||
protected function prepare(array $args = [])
|
||||
{
|
||||
parent::prepare($args);
|
||||
|
||||
|
@ -113,24 +100,25 @@ class VersionAction extends Action
|
|||
* @return void
|
||||
*/
|
||||
function showContentBlock()
|
||||
{
|
||||
$this->elementStart('div', array('id' => 'content', 'class' => 'h-entry'));
|
||||
$this->showPageTitle();
|
||||
$this->showPageNoticeBlock();
|
||||
$this->elementStart('div', array('id' => 'content_inner',
|
||||
'class' => 'e-content'));
|
||||
// show the actual content (forms, lists, whatever)
|
||||
$this->showContent();
|
||||
$this->elementEnd('div');
|
||||
$this->elementEnd('div');
|
||||
}
|
||||
{
|
||||
$this->elementStart('div', array('id' => 'content', 'class' => 'h-entry'));
|
||||
$this->showPageTitle();
|
||||
$this->showPageNoticeBlock();
|
||||
$this->elementStart('div', array('id' => 'content_inner',
|
||||
'class' => 'e-content'));
|
||||
// show the actual content (forms, lists, whatever)
|
||||
$this->showContent();
|
||||
$this->elementEnd('div');
|
||||
$this->elementEnd('div');
|
||||
}
|
||||
|
||||
/*
|
||||
* Overrride to add entry-title class
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function showPageTitle() {
|
||||
function showPageTitle()
|
||||
{
|
||||
$this->element('h1', array('class' => 'entry-title'), $this->title());
|
||||
}
|
||||
|
||||
|
@ -146,12 +134,12 @@ class VersionAction extends Action
|
|||
|
||||
// TRANS: Content part of engine version page.
|
||||
// TRANS: %1$s is the engine name (GNU social) and %2$s is the GNU social version.
|
||||
$this->raw(sprintf(_('This site is powered by %1$s version %2$s, '.
|
||||
'Copyright 2010 Free Software Foundation, Inc.'),
|
||||
XMLStringer::estring('a', array('href' => GNUSOCIAL_ENGINE_URL),
|
||||
// TRANS: Engine name.
|
||||
GNUSOCIAL_ENGINE),
|
||||
GNUSOCIAL_VERSION));
|
||||
$this->raw(sprintf(_('This site is powered by %1$s version %2$s, ' .
|
||||
'Copyright 2010 Free Software Foundation, Inc.'),
|
||||
XMLStringer::estring('a', array('href' => GNUSOCIAL_ENGINE_URL),
|
||||
// TRANS: Engine name.
|
||||
GNUSOCIAL_ENGINE),
|
||||
GNUSOCIAL_VERSION));
|
||||
$this->elementEnd('p');
|
||||
|
||||
// TRANS: Header for engine software contributors section on the version page.
|
||||
|
@ -159,34 +147,34 @@ class VersionAction extends Action
|
|||
|
||||
$this->elementStart('p');
|
||||
$this->raw(sprintf('See %s for a full list of contributors.',
|
||||
XMLStringer::estring('a', array('href' => 'https://notabug.org/diogo/gnu-social/src/nightly/CREDITS.md'),
|
||||
'https://notabug.org/diogo/gnu-social/src/nightly/CREDITS.md')));
|
||||
XMLStringer::estring('a', array('href' => 'https://notabug.org/diogo/gnu-social/src/nightly/CREDITS.md'),
|
||||
'https://notabug.org/diogo/gnu-social/src/nightly/CREDITS.md')));
|
||||
$this->elementEnd('p');
|
||||
|
||||
// TRANS: Header for engine software license section on the version page.
|
||||
$this->element('h2', null, _('License'));
|
||||
|
||||
$this->element('p', null,
|
||||
// TRANS: Content part of engine software version page. %1s is engine name
|
||||
sprintf(_('%1$s 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.'), GNUSOCIAL_ENGINE));
|
||||
// TRANS: Content part of engine software version page. %1s is engine name
|
||||
sprintf(_('%1$s 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.'), GNUSOCIAL_ENGINE));
|
||||
|
||||
$this->element('p', null,
|
||||
// TRANS: Content part of engine software version page.
|
||||
_('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.'));
|
||||
// TRANS: Content part of engine software version page.
|
||||
_('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.'));
|
||||
|
||||
$this->elementStart('p');
|
||||
// TRANS: Content part of engine version page.
|
||||
// TRANS: %s is a link to the AGPL license with link description "http://www.gnu.org/licenses/agpl.html".
|
||||
$this->raw(sprintf(_('You should have received a copy of the GNU Affero General Public License '.
|
||||
'along with this program. If not, see %s.'),
|
||||
XMLStringer::estring('a', array('href' => 'https://www.gnu.org/licenses/agpl.html'),
|
||||
'https://www.gnu.org/licenses/agpl.html')));
|
||||
$this->raw(sprintf(_('You should have received a copy of the GNU Affero General Public License ' .
|
||||
'along with this program. If not, see %s.'),
|
||||
XMLStringer::estring('a', array('href' => 'https://www.gnu.org/licenses/agpl.html'),
|
||||
'https://www.gnu.org/licenses/agpl.html')));
|
||||
$this->elementEnd('p');
|
||||
|
||||
// XXX: Theme information?
|
||||
|
@ -200,13 +188,13 @@ class VersionAction extends Action
|
|||
$this->elementStart('thead');
|
||||
$this->elementStart('tr');
|
||||
// TRANS: Column header for plugins table on version page.
|
||||
$this->element('th', array('id' => 'plugin_name'), _m('HEADER','Name'));
|
||||
$this->element('th', array('id' => 'plugin_name'), _m('HEADER', 'Name'));
|
||||
// TRANS: Column header for plugins table on version page.
|
||||
$this->element('th', array('id' => 'plugin_version'), _m('HEADER','Version'));
|
||||
$this->element('th', array('id' => 'plugin_version'), _m('HEADER', 'Version'));
|
||||
// TRANS: Column header for plugins table on version page.
|
||||
$this->element('th', array('id' => 'plugin_authors'), _m('HEADER','Author(s)'));
|
||||
$this->element('th', array('id' => 'plugin_authors'), _m('HEADER', 'Author(s)'));
|
||||
// TRANS: Column header for plugins table on version page.
|
||||
$this->element('th', array('id' => 'plugin_description'), _m('HEADER','Description'));
|
||||
$this->element('th', array('id' => 'plugin_description'), _m('HEADER', 'Description'));
|
||||
$this->elementEnd('tr');
|
||||
$this->elementEnd('thead');
|
||||
|
||||
|
@ -216,7 +204,7 @@ class VersionAction extends Action
|
|||
if (array_key_exists('homepage', $plugin)) {
|
||||
$this->elementStart('th');
|
||||
$this->element('a', array('href' => $plugin['homepage']),
|
||||
$plugin['name']);
|
||||
$plugin['name']);
|
||||
$this->elementEnd('th');
|
||||
} else {
|
||||
$this->element('th', null, $plugin['name']);
|
||||
|
|
|
@ -124,9 +124,9 @@ class Cache
|
|||
|
||||
if (empty($prefix)) {
|
||||
|
||||
$names = array();
|
||||
$names = [];
|
||||
|
||||
foreach (GNUsocial::getActivePlugins() as $plugin=>$attrs) {
|
||||
foreach (GNUsocial::getActiveModules() as $plugin => $attrs) {
|
||||
$names[] = $plugin;
|
||||
}
|
||||
|
||||
|
|
|
@ -78,7 +78,7 @@ class Event {
|
|||
* @param string $name Name of the event that's happening
|
||||
* @param array $args Arguments for handlers
|
||||
*
|
||||
* @return boolean flag saying whether to continue processing, based
|
||||
* @return bool flag saying whether to continue processing, based
|
||||
* on results of handlers.
|
||||
*/
|
||||
|
||||
|
@ -104,7 +104,7 @@ class Event {
|
|||
* @param string $name Name of the event to look for
|
||||
* @param string $plugin Optional name of the plugin class to look for
|
||||
*
|
||||
* @return boolean flag saying whether such a handler exists
|
||||
* @return bool flag saying whether such a handler exists
|
||||
*
|
||||
*/
|
||||
|
||||
|
|
|
@ -197,4 +197,3 @@ function PEAR_ErrorToPEAR_Exception(PEAR_Error $err)
|
|||
}
|
||||
throw new PEAR_Exception($err->getMessage());
|
||||
}
|
||||
|
||||
|
|
|
@ -23,68 +23,67 @@ global $config, $_server, $_path;
|
|||
*/
|
||||
class GNUsocial
|
||||
{
|
||||
protected static $config_files = array();
|
||||
protected static $config_files = [];
|
||||
protected static $have_config;
|
||||
protected static $is_api;
|
||||
protected static $is_ajax;
|
||||
protected static $plugins = array();
|
||||
protected static $plugins = [];
|
||||
|
||||
/**
|
||||
* Configure and instantiate a plugin (or a core module) into the current configuration.
|
||||
* Class definitions will be loaded from standard paths if necessary.
|
||||
* Note that initialization events won't be fired until later.
|
||||
*
|
||||
* @param string $name class name & plugin file/subdir name
|
||||
* @param array $attrs key/value pairs of public attributes to set on plugin instance
|
||||
* @param string $name class name & module file/subdir name
|
||||
* @param array $attrs key/value pairs of public attributes to set on module instance
|
||||
*
|
||||
* @throws ServerException if plugin can't be found
|
||||
* @return bool
|
||||
* @throws ServerException if module can't be found
|
||||
*/
|
||||
public static function addPlugin($name, array $attrs = [])
|
||||
public static function addPlugin(string $name, array $attrs = [])
|
||||
{
|
||||
$name = ucfirst($name);
|
||||
|
||||
if (isset(self::$plugins[$name])) {
|
||||
// We have already loaded this plugin. Don't try to
|
||||
// We have already loaded this module. Don't try to
|
||||
// do it again with (possibly) different values.
|
||||
// Försten till kvarn får mala.
|
||||
return true;
|
||||
}
|
||||
|
||||
$pluginclass = "{$name}Plugin";
|
||||
$moduleclass = "{$name}Plugin";
|
||||
|
||||
if (!class_exists($pluginclass)) {
|
||||
if (!class_exists($moduleclass)) {
|
||||
|
||||
$files = [
|
||||
"local/plugins/{$pluginclass}.php",
|
||||
"local/plugins/{$name}/{$pluginclass}.php",
|
||||
"local/{$pluginclass}.php",
|
||||
"local/{$name}/{$pluginclass}.php",
|
||||
"modules/{$pluginclass}.php",
|
||||
"modules/{$name}/{$pluginclass}.php",
|
||||
"plugins/{$pluginclass}.php",
|
||||
"plugins/{$name}/{$pluginclass}.php"
|
||||
"local/plugins/{$moduleclass}.php",
|
||||
"local/plugins/{$name}/{$moduleclass}.php",
|
||||
"modules/{$moduleclass}.php",
|
||||
"modules/{$name}/{$moduleclass}.php",
|
||||
"plugins/{$moduleclass}.php",
|
||||
"plugins/{$name}/{$moduleclass}.php"
|
||||
];
|
||||
|
||||
foreach ($files as $file) {
|
||||
$fullpath = INSTALLDIR.'/'.$file;
|
||||
$fullpath = INSTALLDIR . '/' . $file;
|
||||
if (@file_exists($fullpath)) {
|
||||
include_once($fullpath);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!class_exists($pluginclass)) {
|
||||
if (!class_exists($moduleclass)) {
|
||||
throw new ServerException("Plugin $name not found.", 500);
|
||||
}
|
||||
}
|
||||
|
||||
// Doesn't this $inst risk being garbage collected or something?
|
||||
// TODO: put into a static array that makes sure $inst isn't lost.
|
||||
$inst = new $pluginclass();
|
||||
$inst = new $moduleclass();
|
||||
foreach ($attrs as $aname => $avalue) {
|
||||
$inst->$aname = $avalue;
|
||||
}
|
||||
|
||||
// Record activated plugins for later display/config dump
|
||||
// Record activated modules for later display/config dump
|
||||
self::$plugins[$name] = $attrs;
|
||||
|
||||
return true;
|
||||
|
@ -92,20 +91,20 @@ class GNUsocial
|
|||
|
||||
public static function delPlugin($name)
|
||||
{
|
||||
// Remove our plugin if it was previously loaded
|
||||
// Remove our module if it was previously loaded
|
||||
$name = ucfirst($name);
|
||||
if (isset(self::$plugins[$name])) {
|
||||
unset(self::$plugins[$name]);
|
||||
}
|
||||
|
||||
// make sure initPlugins will avoid this
|
||||
common_config_set('plugins', 'disable-'.$name, true);
|
||||
common_config_set('plugins', 'disable-' . $name, true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of activated plugins in this process.
|
||||
* Get a list of activated modules in this process.
|
||||
* @return array of (string $name, array $args) pairs
|
||||
*/
|
||||
public static function getActivePlugins()
|
||||
|
@ -115,7 +114,7 @@ class GNUsocial
|
|||
|
||||
/**
|
||||
* Initialize, or re-initialize, GNU social global configuration
|
||||
* and plugins.
|
||||
* and modules.
|
||||
*
|
||||
* If switching site configurations during script execution, be
|
||||
* careful when working with leftover objects -- global settings
|
||||
|
@ -125,9 +124,11 @@ class GNUsocial
|
|||
* @param $path optional URL path for picking config
|
||||
* @param $conffile optional configuration file path
|
||||
*
|
||||
* @throws ConfigException
|
||||
* @throws NoConfigException if config file can't be found
|
||||
* @throws ServerException
|
||||
*/
|
||||
public static function init($server=null, $path=null, $conffile=null)
|
||||
public static function init($server = null, $path = null, $conffile = null)
|
||||
{
|
||||
Router::clear();
|
||||
|
||||
|
@ -165,6 +166,10 @@ class GNUsocial
|
|||
* site is missing or configured incorrectly.
|
||||
*
|
||||
* @param string $nickname
|
||||
* @return bool
|
||||
* @throws ConfigException
|
||||
* @throws NoConfigException
|
||||
* @throws ServerException
|
||||
*/
|
||||
public static function switchSite($nickname)
|
||||
{
|
||||
|
@ -175,7 +180,7 @@ class GNUsocial
|
|||
$sn = Status_network::getKV('nickname', $nickname);
|
||||
if (empty($sn)) {
|
||||
return false;
|
||||
throw new Exception("No such site nickname '$nickname'");
|
||||
//throw new Exception("No such site nickname '$nickname'");
|
||||
}
|
||||
|
||||
$server = $sn->getServerName();
|
||||
|
@ -191,7 +196,7 @@ class GNUsocial
|
|||
*/
|
||||
public static function findAllSites()
|
||||
{
|
||||
$sites = array();
|
||||
$sites = [];
|
||||
$sn = new Status_network();
|
||||
$sn->find();
|
||||
while ($sn->fetch()) {
|
||||
|
@ -205,11 +210,11 @@ class GNUsocial
|
|||
*/
|
||||
protected static function initPlugins()
|
||||
{
|
||||
// User config may have already added some of these plugins, with
|
||||
// maybe configured parameters. The self::addPlugin function will
|
||||
// User config may have already added some of these modules, with
|
||||
// maybe configured parameters. The self::addModule function will
|
||||
// ignore the new call if it has already been instantiated.
|
||||
|
||||
// Load core plugins
|
||||
// Load core modules
|
||||
foreach (common_config('plugins', 'core') as $name => $params) {
|
||||
call_user_func('self::addPlugin', $name, $params);
|
||||
}
|
||||
|
@ -221,32 +226,26 @@ class GNUsocial
|
|||
continue;
|
||||
}
|
||||
|
||||
// TODO: We should be able to avoid this is_null and assume $params
|
||||
// is an array, since that's how it is typed in addPlugin
|
||||
if (is_null($params)) {
|
||||
if (count($params) == 0) {
|
||||
self::addPlugin($name);
|
||||
} else if (is_array($params)) {
|
||||
if (count($params) == 0) {
|
||||
self::addPlugin($name);
|
||||
} else {
|
||||
$keys = array_keys($params);
|
||||
if (is_string($keys[0])) {
|
||||
self::addPlugin($name, $params);
|
||||
} else {
|
||||
$keys = array_keys($params);
|
||||
if (is_string($keys[0])) {
|
||||
self::addPlugin($name, $params);
|
||||
} else {
|
||||
foreach ($params as $paramset) {
|
||||
self::addPlugin($name, $paramset);
|
||||
}
|
||||
foreach ($params as $paramset) {
|
||||
self::addPlugin($name, $paramset);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// XXX: if plugins should check the schema at runtime, do that here.
|
||||
// XXX: if modules should check the schema at runtime, do that here.
|
||||
if (common_config('db', 'schemacheck') == 'runtime') {
|
||||
Event::handle('CheckSchema');
|
||||
}
|
||||
|
||||
// Give plugins a chance to initialize in a fully-prepared environment
|
||||
// Give modules a chance to initialize in a fully-prepared environment
|
||||
Event::handle('InitializePlugin');
|
||||
}
|
||||
|
||||
|
@ -298,7 +297,7 @@ class GNUsocial
|
|||
protected static function defaultConfig()
|
||||
{
|
||||
global $_server, $_path;
|
||||
require(INSTALLDIR.'/lib/default.php');
|
||||
require(INSTALLDIR . '/lib/default.php');
|
||||
return $default;
|
||||
}
|
||||
|
||||
|
@ -311,7 +310,7 @@ class GNUsocial
|
|||
global $_server, $_path, $config, $_PEAR;
|
||||
|
||||
Event::clearHandlers();
|
||||
self::$plugins = array();
|
||||
self::$plugins = [];
|
||||
|
||||
// try to figure out where we are. $server and $path
|
||||
// can be set by including module, else we guess based
|
||||
|
@ -321,16 +320,16 @@ class GNUsocial
|
|||
$_server = $server;
|
||||
} else {
|
||||
$_server = array_key_exists('SERVER_NAME', $_SERVER) ?
|
||||
strtolower($_SERVER['SERVER_NAME']) :
|
||||
null;
|
||||
strtolower($_SERVER['SERVER_NAME']) :
|
||||
null;
|
||||
}
|
||||
|
||||
if (isset($path)) {
|
||||
$_path = $path;
|
||||
} else {
|
||||
$_path = (array_key_exists('SERVER_NAME', $_SERVER) && array_key_exists('SCRIPT_NAME', $_SERVER)) ?
|
||||
self::_sn_to_path($_SERVER['SCRIPT_NAME']) :
|
||||
null;
|
||||
self::_sn_to_path($_SERVER['SCRIPT_NAME']) :
|
||||
null;
|
||||
}
|
||||
|
||||
// Set config values initially to default values
|
||||
|
@ -340,7 +339,7 @@ class GNUsocial
|
|||
// default configuration, overwritten in config.php
|
||||
// Keep DB_DataObject's db config synced to ours...
|
||||
|
||||
$config['db'] = &$_PEAR->getStaticProperty('DB_DataObject','options');
|
||||
$config['db'] = &$_PEAR->getStaticProperty('DB_DataObject', 'options');
|
||||
|
||||
$config['db'] = $default['db'];
|
||||
}
|
||||
|
@ -366,11 +365,12 @@ class GNUsocial
|
|||
|
||||
/**
|
||||
* Load the default or specified configuration file.
|
||||
* Modifies global $config and may establish plugins.
|
||||
* Modifies global $config and may establish modules.
|
||||
*
|
||||
* @throws NoConfigException
|
||||
* @throws ServerException
|
||||
*/
|
||||
protected static function loadConfigFile($conffile=null)
|
||||
protected static function loadConfigFile($conffile = null)
|
||||
{
|
||||
global $_server, $_path, $config;
|
||||
|
||||
|
@ -379,16 +379,16 @@ class GNUsocial
|
|||
// finally for a dir (usually only need one of the last two).
|
||||
|
||||
if (isset($conffile)) {
|
||||
$config_files = array($conffile);
|
||||
$config_files = [$conffile];
|
||||
} else {
|
||||
$config_files = array('/etc/gnusocial/config.php',
|
||||
'/etc/gnusocial/config.d/'.$_server.'.php');
|
||||
$config_files = ['/etc/gnusocial/config.php',
|
||||
'/etc/gnusocial/config.d/' . $_server . '.php'];
|
||||
|
||||
if (strlen($_path) > 0) {
|
||||
$config_files[] = '/etc/gnusocial/config.d/'.$_server.'_'.$_path.'.php';
|
||||
$config_files[] = '/etc/gnusocial/config.d/' . $_server . '_' . $_path . '.php';
|
||||
}
|
||||
|
||||
$config_files[] = INSTALLDIR.'/config.php';
|
||||
$config_files[] = INSTALLDIR . '/config.php';
|
||||
}
|
||||
|
||||
self::$have_config = false;
|
||||
|
@ -406,7 +406,7 @@ class GNUsocial
|
|||
|
||||
if (!self::$have_config) {
|
||||
throw new NoConfigException("No configuration file found.",
|
||||
$config_files);
|
||||
$config_files);
|
||||
}
|
||||
|
||||
// Check for database server; must exist!
|
||||
|
@ -436,7 +436,7 @@ class GNUsocial
|
|||
$mkdirs = [];
|
||||
|
||||
if (common_config('htmlpurifier', 'Cache.DefinitionImpl') === 'Serializer'
|
||||
&& !is_dir(common_config('htmlpurifier', 'Cache.SerializerPath'))) {
|
||||
&& !is_dir(common_config('htmlpurifier', 'Cache.SerializerPath'))) {
|
||||
$mkdirs[common_config('htmlpurifier', 'Cache.SerializerPath')] = 'HTMLPurifier Serializer cache';
|
||||
}
|
||||
|
||||
|
@ -449,15 +449,15 @@ class GNUsocial
|
|||
}
|
||||
|
||||
// try to create those that are not directories
|
||||
foreach ($mkdirs as $dir=>$description) {
|
||||
foreach ($mkdirs as $dir => $description) {
|
||||
if (is_file($dir)) {
|
||||
throw new ConfigException('Expected directory for '._ve($description).' is a file!');
|
||||
throw new ConfigException('Expected directory for ' . _ve($description) . ' is a file!');
|
||||
}
|
||||
if (!mkdir($dir)) {
|
||||
throw new ConfigException('Could not create directory for '._ve($description).': '._ve($dir));
|
||||
throw new ConfigException('Could not create directory for ' . _ve($description) . ': ' . _ve($dir));
|
||||
}
|
||||
if (!chmod($dir, 0775)) {
|
||||
common_log(LOG_WARNING, 'Could not chmod 0775 on directory for '._ve($description).': '._ve($dir));
|
||||
common_log(LOG_WARNING, 'Could not chmod 0775 on directory for ' . _ve($description) . ': ' . _ve($dir));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -500,7 +500,8 @@ class NoConfigException extends Exception
|
|||
{
|
||||
public $configFiles;
|
||||
|
||||
function __construct($msg, $configFiles) {
|
||||
function __construct($msg, $configFiles)
|
||||
{
|
||||
parent::__construct($msg);
|
||||
$this->configFiles = $configFiles;
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ if (!defined('GNUSOCIAL')) { exit(1); }
|
|||
* @package Activity
|
||||
* @maintainer Mikael Nordfeldth <mmn@hethane.se>
|
||||
*/
|
||||
abstract class ActivityVerbHandlerPlugin extends ActivityHandlerPlugin
|
||||
abstract class ActivityVerbHandlerModule extends ActivityHandlerPlugin
|
||||
{
|
||||
public function onActivityVerbTitle(ManagedAction $action, $verb, Notice $target, Profile $scoped, &$title)
|
||||
{
|
|
@ -32,8 +32,8 @@ if (!defined('GNUSOCIAL')) { exit(1); }
|
|||
/**
|
||||
* Superclass for plugins that do authentication
|
||||
*
|
||||
* @category Plugin
|
||||
* @package StatusNet
|
||||
* @category Module
|
||||
* @package GNUsocial
|
||||
* @author Craig Andrews <candrews@integralblue.com>
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
|
|
|
@ -34,8 +34,8 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
|
|||
/**
|
||||
* Superclass for plugins that do authorization
|
||||
*
|
||||
* @category Plugin
|
||||
* @package StatusNet
|
||||
* @category Module
|
||||
* @package GNUsocial
|
||||
* @author Craig Andrews <candrews@integralblue.com>
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
|
|
|
@ -36,8 +36,8 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
|
|||
* Implementations will likely want to override onStartIoManagerClasses() so that their
|
||||
* IO manager is used
|
||||
*
|
||||
* @category Plugin
|
||||
* @package StatusNet
|
||||
* @category Module
|
||||
* @package GNUsocial
|
||||
* @author Craig Andrews <candrews@integralblue.com>
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
|
|
|
@ -42,13 +42,13 @@ if (!defined('STATUSNET')) {
|
|||
* The applications work more-or-less like other
|
||||
*
|
||||
* @category Microapp
|
||||
* @package StatusNet
|
||||
* @package GNUsocial
|
||||
* @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/
|
||||
*/
|
||||
abstract class MicroAppPlugin extends ActivityHandlerPlugin
|
||||
abstract class MicroAppModule extends ActivityHandlerPlugin
|
||||
{
|
||||
/**
|
||||
* Returns a localized string which represents this micro-app,
|
|
@ -17,7 +17,7 @@
|
|||
defined('GNUSOCIAL') || die();
|
||||
|
||||
/**
|
||||
* Base class for plugins
|
||||
* Base class for modules
|
||||
*
|
||||
* A base class for GNU social modules. Mostly a light wrapper around
|
||||
* the Event framework.
|
||||
|
@ -29,8 +29,8 @@ defined('GNUSOCIAL') || die();
|
|||
* They will also automatically handle the InitializePlugin and CleanupPlugin with the
|
||||
* initialize() and cleanup() methods, respectively.
|
||||
*
|
||||
* @category Plugin
|
||||
* @package GNU social
|
||||
* @category Module
|
||||
* @package GNUsocial
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @copyright 2010-2019 Free Software Foundation, Inc http://www.fsf.org
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
|
@ -39,10 +39,10 @@ defined('GNUSOCIAL') || die();
|
|||
*/
|
||||
class Plugin
|
||||
{
|
||||
function __construct()
|
||||
public function __construct()
|
||||
{
|
||||
Event::addHandler('InitializePlugin', array($this, 'initialize'));
|
||||
Event::addHandler('CleanupPlugin', array($this, 'cleanup'));
|
||||
Event::addHandler('InitializePlugin', [$this, 'initialize']);
|
||||
Event::addHandler('CleanupPlugin', [$this, 'cleanup']);
|
||||
|
||||
foreach (get_class_methods($this) as $method) {
|
||||
if (mb_substr($method, 0, 2) == 'on') {
|
||||
|
@ -53,12 +53,12 @@ class Plugin
|
|||
$this->setupGettext();
|
||||
}
|
||||
|
||||
function initialize()
|
||||
public function initialize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
function cleanup()
|
||||
public function cleanup()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -81,7 +81,8 @@ class Plugin
|
|||
*
|
||||
* @return bool hook value; true means continue processing, false means stop.
|
||||
*/
|
||||
public function onAutoload($cls) {
|
||||
public function onAutoload($cls)
|
||||
{
|
||||
$cls = basename($cls);
|
||||
$basedir = INSTALLDIR . '/local/plugins/' . mb_substr(get_called_class(), 0, -6);
|
||||
if (!file_exists($basedir)) {
|
||||
|
@ -124,7 +125,7 @@ class Plugin
|
|||
protected function setupGettext()
|
||||
{
|
||||
$class = get_class($this);
|
||||
if (substr($class, -6) == 'Plugin') {
|
||||
if (substr($class, -6) == 'Module') {
|
||||
$name = substr($class, 0, -6);
|
||||
$path = common_config('plugins', 'locale_path');
|
||||
if (!$path) {
|
||||
|
@ -147,7 +148,7 @@ class Plugin
|
|||
|
||||
protected function log($level, $msg)
|
||||
{
|
||||
common_log($level, get_class($this) . ': '.$msg);
|
||||
common_log($level, get_class($this) . ': ' . $msg);
|
||||
}
|
||||
|
||||
protected function debug($msg)
|
||||
|
@ -166,28 +167,29 @@ class Plugin
|
|||
return GNUSOCIAL_VERSION;
|
||||
}
|
||||
|
||||
protected function userAgent() {
|
||||
protected function userAgent()
|
||||
{
|
||||
return HTTPClient::userAgent()
|
||||
. ' (' . get_class($this) . ' v' . $this->version() . ')';
|
||||
. ' (' . get_class($this) . ' v' . $this->version() . ')';
|
||||
}
|
||||
|
||||
function onPluginVersion(array &$versions)
|
||||
public function onModuleVersion(array &$versions)
|
||||
{
|
||||
$name = $this->name();
|
||||
|
||||
$versions[] = array('name' => $name,
|
||||
// TRANS: Displayed as version information for a plugin if no version information was found.
|
||||
'version' => _('Unknown'));
|
||||
// TRANS: Displayed as version information for a plugin if no version information was found.
|
||||
'version' => _('Unknown'));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function path($relative)
|
||||
public function path($relative)
|
||||
{
|
||||
return self::staticPath($this->name(), $relative);
|
||||
}
|
||||
|
||||
static function staticPath($plugin, $relative)
|
||||
public static function staticPath($module, $relative)
|
||||
{
|
||||
if (GNUsocial::useHTTPS()) {
|
||||
$server = common_config('plugins', 'sslserver');
|
||||
|
@ -212,25 +214,25 @@ class Plugin
|
|||
|
||||
if (empty($path)) {
|
||||
// XXX: extra stat().
|
||||
if (@file_exists(PUBLICDIR . '/local/plugins/' . $plugin . '/' . $relative)) {
|
||||
if (@file_exists(PUBLICDIR . '/local/plugins/' . $module . '/' . $relative)) {
|
||||
$path = common_config('site', 'path') . '/local/plugins/';
|
||||
} elseif (@file_exists(PUBLICDIR . '/modules/' . $plugin . '/' . $relative)) {
|
||||
} elseif (@file_exists(PUBLICDIR . '/modules/' . $module . '/' . $relative)) {
|
||||
$path = common_config('site', 'path') . '/modules/';
|
||||
} else {
|
||||
$path = common_config('site', 'path') . '/plugins/';
|
||||
}
|
||||
}
|
||||
|
||||
if ($path[strlen($path)-1] != '/') {
|
||||
if ($path[strlen($path) - 1] != '/') {
|
||||
$path .= '/';
|
||||
}
|
||||
|
||||
if ($path[0] != '/') {
|
||||
$path = '/'.$path;
|
||||
$path = '/' . $path;
|
||||
}
|
||||
|
||||
$protocol = GNUsocial::useHTTPS() ? 'https' : 'http';
|
||||
|
||||
return $protocol.'://'.$server.$path.$plugin.'/'.$relative;
|
||||
return $protocol . '://' . $server . $path . $module . '/' . $relative;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,8 +44,8 @@ if (!defined('STATUSNET')) {
|
|||
* Leaderboard 728x90
|
||||
* Wide Skyscraper 160x600
|
||||
*
|
||||
* @category Plugin
|
||||
* @package StatusNet
|
||||
* @category Module
|
||||
* @package GNUsocial
|
||||
* @author Sarven Capadisli <csarven@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
|
||||
|
|
|
@ -33,8 +33,8 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
|
|||
/**
|
||||
* Superclass for plugins that do URL shortening
|
||||
*
|
||||
* @category Plugin
|
||||
* @package StatusNet
|
||||
* @category Module
|
||||
* @package GNUsocial
|
||||
* @author Craig Andrews <candrews@integralblue.com>
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
|
|
|
@ -1,34 +1,20 @@
|
|||
<?php
|
||||
/**
|
||||
* StatusNet, the distributed open-source microblogging tool
|
||||
*
|
||||
* Form for enabling/disabling plugins
|
||||
*
|
||||
* 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 Form
|
||||
* @package StatusNet
|
||||
* @copyright 2010 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('STATUSNET') || die();
|
||||
|
||||
/**
|
||||
* Form for joining a group
|
||||
|
@ -41,7 +27,6 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
|
|||
*
|
||||
* @see PluginEnableForm
|
||||
*/
|
||||
|
||||
class PluginDisableForm extends PluginEnableForm
|
||||
{
|
||||
/**
|
||||
|
@ -50,7 +35,7 @@ class PluginDisableForm extends PluginEnableForm
|
|||
* @return string ID of the form
|
||||
*/
|
||||
|
||||
function id()
|
||||
public function id()
|
||||
{
|
||||
return 'plugin-disable-' . $this->plugin;
|
||||
}
|
||||
|
@ -61,7 +46,7 @@ class PluginDisableForm extends PluginEnableForm
|
|||
* @return string of the form class
|
||||
*/
|
||||
|
||||
function formClass()
|
||||
public function formClass()
|
||||
{
|
||||
return 'form_plugin_disable';
|
||||
}
|
||||
|
@ -72,22 +57,24 @@ class PluginDisableForm extends PluginEnableForm
|
|||
* @return string URL of the action
|
||||
*/
|
||||
|
||||
function action()
|
||||
public function action()
|
||||
{
|
||||
return common_local_url('plugindisable',
|
||||
array('plugin' => $this->plugin));
|
||||
return common_local_url(
|
||||
'plugindisable',
|
||||
['plugin' => $this->plugin]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Action elements
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
|
||||
function formActions()
|
||||
public function formActions()
|
||||
{
|
||||
// TRANS: Plugin admin panel controls
|
||||
$this->out->submit('submit', _m('plugin', 'Disable'));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,36 +1,22 @@
|
|||
<?php
|
||||
/**
|
||||
* StatusNet, the distributed open-source microblogging tool
|
||||
*
|
||||
* Form for enabling/disabling plugins
|
||||
*
|
||||
* 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 Form
|
||||
* @package StatusNet
|
||||
* @copyright 2010 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('STATUSNET') || die();
|
||||
|
||||
require_once INSTALLDIR.'/lib/form.php';
|
||||
require_once INSTALLDIR . '/lib/form.php';
|
||||
|
||||
/**
|
||||
* Form for joining a group
|
||||
|
@ -43,23 +29,22 @@ require_once INSTALLDIR.'/lib/form.php';
|
|||
*
|
||||
* @see PluginDisableForm
|
||||
*/
|
||||
|
||||
class PluginEnableForm extends Form
|
||||
{
|
||||
/**
|
||||
* Plugin to enable/disable
|
||||
*/
|
||||
|
||||
var $plugin = null;
|
||||
public $plugin = null;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param HTMLOutputter $out output channel
|
||||
* @param string $plugin plugin to enable/disable
|
||||
* @param HTMLOutputter $out output channel
|
||||
* @param string $plugin plugin to enable/disable
|
||||
*/
|
||||
|
||||
function __construct($out=null, $plugin=null)
|
||||
public function __construct($out = null, $plugin = null)
|
||||
{
|
||||
parent::__construct($out);
|
||||
|
||||
|
@ -72,7 +57,7 @@ class PluginEnableForm extends Form
|
|||
* @return string ID of the form
|
||||
*/
|
||||
|
||||
function id()
|
||||
public function id()
|
||||
{
|
||||
return 'plugin-enable-' . $this->plugin;
|
||||
}
|
||||
|
@ -83,7 +68,7 @@ class PluginEnableForm extends Form
|
|||
* @return string of the form class
|
||||
*/
|
||||
|
||||
function formClass()
|
||||
public function formClass()
|
||||
{
|
||||
return 'form_plugin_enable';
|
||||
}
|
||||
|
@ -94,19 +79,22 @@ class PluginEnableForm extends Form
|
|||
* @return string URL of the action
|
||||
*/
|
||||
|
||||
function action()
|
||||
public function action()
|
||||
{
|
||||
return common_local_url('pluginenable',
|
||||
array('plugin' => $this->plugin));
|
||||
return common_local_url(
|
||||
'pluginenable',
|
||||
['plugin' => $this->plugin]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Action elements
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
|
||||
function formActions()
|
||||
public function formActions()
|
||||
{
|
||||
// TRANS: Plugin admin panel controls
|
||||
$this->out->submit('submit', _m('plugin', 'Enable'));
|
||||
|
|
|
@ -1,35 +1,20 @@
|
|||
<?php
|
||||
/**
|
||||
* StatusNet, the distributed open-source microblogging tool
|
||||
*
|
||||
* Plugins administration panel
|
||||
*
|
||||
* 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 Settings
|
||||
* @package StatusNet
|
||||
* @author Brion Vibber <brion@status.net>
|
||||
* @copyright 2010 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')) {
|
||||
exit(1);
|
||||
}
|
||||
defined('STATUSNET') || die();
|
||||
|
||||
require INSTALLDIR . "/lib/pluginenableform.php";
|
||||
require INSTALLDIR . "/lib/plugindisableform.php";
|
||||
|
@ -38,39 +23,39 @@ require INSTALLDIR . "/lib/plugindisableform.php";
|
|||
* Plugin list
|
||||
*
|
||||
* @category Admin
|
||||
* @package StatusNet
|
||||
* @package GNUsocial
|
||||
* @author Brion Vibber <brion@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/
|
||||
*/
|
||||
class PluginList extends Widget
|
||||
{
|
||||
var $plugins = array();
|
||||
public $plugins = [];
|
||||
|
||||
function __construct($plugins, $out)
|
||||
public function __construct($plugins, $out)
|
||||
{
|
||||
parent::__construct($out);
|
||||
$this->plugins = $plugins;
|
||||
}
|
||||
|
||||
function show()
|
||||
public function show()
|
||||
{
|
||||
$this->startList();
|
||||
$this->showPlugins();
|
||||
$this->endList();
|
||||
}
|
||||
|
||||
function startList()
|
||||
public function startList()
|
||||
{
|
||||
$this->out->elementStart('table', 'plugin_list');
|
||||
}
|
||||
|
||||
function endList()
|
||||
public function endList()
|
||||
{
|
||||
$this->out->elementEnd('table');
|
||||
}
|
||||
|
||||
function showPlugins()
|
||||
public function showPlugins()
|
||||
{
|
||||
foreach ($this->plugins as $plugin) {
|
||||
$pli = $this->newListItem($plugin);
|
||||
|
@ -78,7 +63,7 @@ class PluginList extends Widget
|
|||
}
|
||||
}
|
||||
|
||||
function newListItem($plugin)
|
||||
public function newListItem($plugin)
|
||||
{
|
||||
return new PluginListItem($plugin, $this->out);
|
||||
}
|
||||
|
@ -87,18 +72,18 @@ class PluginList extends Widget
|
|||
class PluginListItem extends Widget
|
||||
{
|
||||
/** Current plugin. */
|
||||
var $plugin = null;
|
||||
public $plugin = null;
|
||||
|
||||
/** Local cache for plugin version info */
|
||||
protected static $versions = false;
|
||||
|
||||
function __construct($plugin, $out)
|
||||
public function __construct($plugin, $out)
|
||||
{
|
||||
parent::__construct($out);
|
||||
$this->plugin = $plugin;
|
||||
}
|
||||
|
||||
function show()
|
||||
public function show()
|
||||
{
|
||||
$meta = $this->metaInfo();
|
||||
|
||||
|
@ -139,6 +124,8 @@ class PluginListItem extends Widget
|
|||
$this->out->elementStart('td');
|
||||
if (!empty($meta['rawdescription'])) {
|
||||
$this->out->raw($meta['rawdescription']);
|
||||
} elseif (!empty($meta['description'])) {
|
||||
$this->out->raw($meta['description']);
|
||||
}
|
||||
$this->out->elementEnd('td');
|
||||
|
||||
|
@ -168,18 +155,19 @@ class PluginListItem extends Widget
|
|||
*
|
||||
* @fixme pull structured data from plugin source
|
||||
*/
|
||||
function metaInfo()
|
||||
public function metaInfo()
|
||||
{
|
||||
$versions = self::getPluginVersions();
|
||||
$found = false;
|
||||
|
||||
foreach ($versions as $info) {
|
||||
// hack for URL shorteners... "LilUrl (ur1.ca)" etc
|
||||
list($name, ) = explode(' ', $info['name']);
|
||||
// We need a proper name for comparison, that is, without spaces nor the `(section)`
|
||||
// Therefore, a plugin named "Diogo Cordeiro (diogo@fc.up.pt)" becomes "DiogoCordeiro"
|
||||
$name_without_spaces = str_replace(' ', '', $info['name']);
|
||||
$name_without_spaces_nor_parentheses_section = substr($name_without_spaces, 0, strpos($name_without_spaces.'(', '('));
|
||||
|
||||
if ($name == $this->plugin) {
|
||||
if (strtolower($name_without_spaces_nor_parentheses_section) == strtolower($this->plugin)) {
|
||||
if ($found) {
|
||||
// hack for URL shorteners...
|
||||
$found['rawdescription'] .= "<br />\n" . $info['rawdescription'];
|
||||
} else {
|
||||
$found = $info;
|
||||
|
@ -190,9 +178,9 @@ class PluginListItem extends Widget
|
|||
if ($found) {
|
||||
return $found;
|
||||
} else {
|
||||
return array('name' => $this->plugin,
|
||||
// TRANS: Plugin description for a disabled plugin.
|
||||
'rawdescription' => _m('plugin-description','(The plugin description is unavailable when a plugin has been disabled.)'));
|
||||
return ['name' => $this->plugin,
|
||||
// TRANS: Plugin description for a disabled plugin.
|
||||
'rawdescription' => _m('plugin-description', '(The plugin description is unavailable when a plugin has been disabled.)')];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -203,8 +191,8 @@ class PluginListItem extends Widget
|
|||
protected static function getPluginVersions()
|
||||
{
|
||||
if (!is_array(self::$versions)) {
|
||||
$versions = array();
|
||||
Event::handle('PluginVersion', array(&$versions));
|
||||
$versions = [];
|
||||
Event::handle('ModuleVersion', [&$versions]);
|
||||
self::$versions = $versions;
|
||||
}
|
||||
return self::$versions;
|
||||
|
|
|
@ -1,35 +1,32 @@
|
|||
<?php
|
||||
/*
|
||||
* StatusNet - the distributed open-source microblogging tool
|
||||
* Copyright (C) 2008, 2009, 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/>.
|
||||
*/
|
||||
// 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();
|
||||
|
||||
/**
|
||||
* Queue handler for letting plugins handle stuff.
|
||||
* Queue handler for letting modules handle stuff.
|
||||
*
|
||||
* The plugin queue handler accepts notices over the "plugin" queue
|
||||
* The module queue handler accepts notices over the "module" queue
|
||||
* and simply passes them through the "HandleQueuedNotice" event.
|
||||
*
|
||||
* This gives plugins a chance to do background processing without
|
||||
* actually registering their own queue and ensuring that things
|
||||
* are queued into it.
|
||||
*
|
||||
* Fancier plugins may wish to instead hook the 'GetQueueHandlerClass'
|
||||
* Fancier modules may wish to instead hook the 'GetQueueHandlerClass'
|
||||
* event with their own class, in which case they must ensure that
|
||||
* their notices get enqueued when they need them.
|
||||
*/
|
||||
|
@ -40,7 +37,7 @@ class PluginQueueHandler extends QueueHandler
|
|||
return 'plugin';
|
||||
}
|
||||
|
||||
function handle($notice) : bool
|
||||
function handle($notice): bool
|
||||
{
|
||||
if (!($notice instanceof Notice)) {
|
||||
common_log(LOG_ERR, "Got a bogus notice, not broadcasting");
|
||||
|
|
|
@ -294,7 +294,7 @@ abstract class QueueManager extends IoManager
|
|||
$this->connect('actmove', 'ActivityMover');
|
||||
|
||||
// For compat with old plugins not registering their own handlers.
|
||||
$this->connect('plugin', 'PluginQueueHandler');
|
||||
$this->connect('Module', 'ModuleQueueHandler');
|
||||
}
|
||||
Event::handle('EndInitializeQueueManager', array($this));
|
||||
}
|
||||
|
|
|
@ -1,20 +0,0 @@
|
|||
<?php
|
||||
|
||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||
|
||||
/**
|
||||
* Backwards compatible class for plugins for GNU social <1.2
|
||||
* and thus only have the class StatusNet defined.
|
||||
*/
|
||||
class StatusNet
|
||||
{
|
||||
public static function getActivePlugins()
|
||||
{
|
||||
return GNUsocial::getActivePlugins();
|
||||
}
|
||||
|
||||
public static function isHTTPS()
|
||||
{
|
||||
return GNUsocial::isHTTPS();
|
||||
}
|
||||
}
|
|
@ -1678,7 +1678,7 @@ function common_enqueue_notice($notice)
|
|||
$transports[] = 'sms';
|
||||
}
|
||||
if (Event::hasHandler('HandleQueuedNotice')) {
|
||||
$transports[] = 'plugin';
|
||||
$transports[] = 'Module';
|
||||
}
|
||||
|
||||
// We can skip these for gatewayed notices.
|
||||
|
|
Loading…
Reference in New Issue
Block a user