Fix and test WS - refs BT#9092

Conflicts:
	main/inc/lib/extra_field.lib.php
	main/inc/lib/sessionmanager.lib.php
	plugin/advancedsubscription/src/HookAdvancedSubscription.class.php
1.10.x
Daniel Barreto 10 years ago
parent 9923f2d7a5
commit 2e580e8b07
  1. 6
      main/inc/lib/database.constants.inc.php
  2. 4
      main/inc/lib/hook/HookEvent.class.php
  3. 18
      main/inc/lib/hook/HookManagement.class.php
  4. 38
      main/inc/lib/hook/HookWSRegistration.class.php
  5. 2
      main/inc/lib/main_api.lib.php
  6. 11
      plugin/hookmanagement/config.php
  7. 2
      plugin/hookmanagement/index.php
  8. 17
      plugin/hookmanagement/install.php
  9. 8
      plugin/hookmanagement/lang/english.php
  10. 7
      plugin/hookmanagement/lang/spanish.php
  11. 1
      plugin/hookmanagement/license.txt
  12. 12
      plugin/hookmanagement/plugin.php
  13. 17
      plugin/hookmanagement/uninstall.php

@ -348,6 +348,6 @@ define('TABLE_GRADE_MODEL', 'grade_model');
define('TABLE_GRADE_MODEL_COMPONENTS', 'grade_components');
// Hook tables
define('TABLE_PLUGIN_HOOK_OBSERVER', 'plugin_hook_observer');
define('TABLE_PLUGIN_HOOK_CALL', 'plugin_hook_call');
define('TABLE_PLUGIN_HOOK_EVENT', 'plugin_hook_event');
define('TABLE_PLUGIN_HOOK_OBSERVER', 'hook_observer');
define('TABLE_PLUGIN_HOOK_CALL', 'hook_call');
define('TABLE_PLUGIN_HOOK_EVENT', 'hook_event');

@ -19,7 +19,7 @@ abstract class HookEvent implements HookEventInterface
$this->observers = new SplObjectStorage();
$this->eventName = $eventName;
$this->eventData = array();
$this->plugin = HookManagementPlugin::create();
$this->plugin = HookManagement::create();
$this->loadAttachments();
} else {
throw new \Exception('Hook Management Plugin is not active');
@ -183,7 +183,7 @@ abstract class HookEvent implements HookEventInterface
$isActive = false;
$appPlugin = new AppPlugin();
$pluginList = $appPlugin->getInstalledPluginListName();
if (in_array(HOOK_MANAGEMENT_PLUGIN, $pluginList)) {
if (in_array(HOOK_MANAGEMENT, $pluginList)) {
$isActive = true;
}

@ -2,20 +2,16 @@
/* For licensing terms, see /license.txt */
/**
* @TODO: Improve description
* @package chamilo.plugin.hookmanagement
* @package chamilo.hookmanagement
*/
class HookManagementPlugin extends Plugin implements HookManagementInterface
class HookManagement implements HookManagementInterface
{
/**
* Constructor
*/
protected function __construct()
{
$parameters = array(
'tool_enable' => 'boolean',
);
$this->tables[TABLE_PLUGIN_HOOK_OBSERVER] = Database::get_main_table(TABLE_PLUGIN_HOOK_OBSERVER);
$this->tables[TABLE_PLUGIN_HOOK_EVENT] = Database::get_main_table(TABLE_PLUGIN_HOOK_EVENT);
$this->tables[TABLE_PLUGIN_HOOK_CALL] = Database::get_main_table(TABLE_PLUGIN_HOOK_CALL);
@ -23,14 +19,12 @@ class HookManagementPlugin extends Plugin implements HookManagementInterface
$this->hookCalls = $this->listAllHookCalls();
$this->hookEvents = $this->listAllHookEvents();
$this->hookObservers = $this->listAllHookObservers();
parent::__construct('1.0', 'Daniel Barreto', $parameters);
}
/**
* Instance the plugin
* Instance the hook manager
* @staticvar null $result
* @return HookManagementPlugin
* @return HookManagement
*/
static function create()
{
@ -149,7 +143,7 @@ class HookManagementPlugin extends Plugin implements HookManagementInterface
foreach ($hookEvents as $hookEvent => $v) {
$attributes = array(
'class_name' => $hookEvent,
'description' => get_plugin_lang('HookDescription' . $hookEvent, 'HookManagementPlugin'),
'description' => get_lang('HookDescription' . $hookEvent),
);
$id = Database::insert($this->tables[TABLE_PLUGIN_HOOK_EVENT], $attributes);
// store hook event into property
@ -395,7 +389,7 @@ class HookManagementPlugin extends Plugin implements HookManagementInterface
if (isset($eventName) && !isset($this->hookEvents[$eventName])) {
$attributes = array(
'class_name' => $eventName,
'description' => get_plugin_lang('HookDescription' . $eventName, 'HookManagementPlugin'),
'description' => get_lang('HookDescription' . $eventName),
);
$id = Database::insert($this->tables[TABLE_PLUGIN_HOOK_EVENT], $attributes, true);
$this->hookEvents[$eventName] = $id;

@ -0,0 +1,38 @@
<?php
/**
* Created by PhpStorm.
* User: dbarreto
* Date: 19/12/14
* Time: 09:45 AM
*/
class HookWSRegistration extends HookEvent implements HookWSRegistrationEventInterface
{
protected function __construct()
{
parent::__construct('HookWSRegistration');
}
/**
* @param int $type
* @return int
*/
public function notifyWSRegistration($type)
{
/** @var \HookWSRegistrationObserverInterface $observer */
if (!isset($this->eventData['server'])) {
global $server;
$this->eventData['server'] = $server;
}
$this->eventData['type'] = $type;
foreach ($this->observers as $observer) {
$data = $observer->hookWSRegistration($this);
$this->eventData['server'] = $data['server'];
if (isset($server)) {
$server = $this->eventData['server'] ;
}
}
return 1;
}
}

@ -360,7 +360,7 @@ define('HOOK_TYPE_PRE', 0);
define('HOOK_TYPE_POST', 1);
define('HOOK_TYPE_ALL', 10);
define('HOOK_MANAGEMENT_PLUGIN', 'hookmanagement');
define('HOOK_MANAGEMENT', 'hookmanagement');
/**
* Inclusion of internationalization libraries

@ -1,11 +0,0 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Config the plugin
* @author Daniel Alejandro Barreto Alva <daniel.barreto@beeznest.com>
* @package chamilo.plugin.hookmanagement
*/
require_once __DIR__ . '/../../main/inc/global.inc.php';
require_once api_get_path(LIBRARY_PATH) . 'plugin.class.php';
require_once api_get_path(PLUGIN_PATH) . 'hookmanagement/src/HookManagementPlugin.class.php';

@ -1,2 +0,0 @@
<?php
/* For license terms, see /license.txt */

@ -1,17 +0,0 @@
<?php
/* For license terms, see /license.txt */
/**
* This script is included by main/admin/settings.lib.php and generally
* includes things to execute in the main database (settings_current table)
* @package chamilo.plugin.hookmanagement
*/
/**
* Initialization
*/
require_once dirname(__FILE__) . '/config.php';
if (!api_is_platform_admin()) {
die ('You must have admin permissions to install plugins');
}
HookManagementPlugin::create()->install();

@ -1,8 +0,0 @@
<?php
/* Strings for settings */
$strings['plugin_title'] = 'Hook Management';
$strings['plugin_comment'] = 'This plugin allow the use of hooks for others plugins, To use hooks, this plugins must be enabled';
$strings['tool_enable'] = 'Enable Hook management plugin';
$strings['tool_enable_help'] = "Escoja si desea activar el gestor de Hooks.";

@ -1,7 +0,0 @@
<?php
/* Strings for settings */
$strings['plugin_title'] = 'Gestor de Hooks';
$strings['plugin_comment'] = 'Este plugin permite el uso de hooks y los gestiona. Debe estar activado para usar los hooks';
$strings['tool_enable'] = 'Activar plugin Gestor de Hooks';
$strings['tool_enable_help'] = "Escoja si desea activar el gestor de Hooks.";

@ -1 +0,0 @@
This plugin, as the rest of Chamilo, is released under the GNU/GPLv3 license.

@ -1,12 +0,0 @@
<?php
/* For license terms, see /license.txt */
/**
* This script is a configuration file for the date plugin. You can use it as a master for other platform plugins (course plugins are slightly different).
* These settings will be used in the administration interface for plugins (Chamilo configuration settings->Plugins)
* @package chamilo.plugin.hookmanagement
*/
/**
* Plugin details (must be present)
*/
require_once __DIR__ . '/config.php';
$plugin_info = HookManagementPlugin::create()->get_info();

@ -1,17 +0,0 @@
<?php
/* For license terms, see /license.txt */
/**
* This script is included by main/admin/settings.lib.php when unselecting a plugin
* and is meant to remove things installed by the install.php script in both
* the global database and the courses tables
* @package chamilo.plugin.hookmanagement
*/
/**
* Queries
*/
require_once dirname(__FILE__) . '/config.php';
if (!api_is_platform_admin()) {
die ('You must have admin permissions to uninstall plugins');
}
HookManagementPlugin::create()->uninstall();
Loading…
Cancel
Save