Actualización

This commit is contained in:
Xes
2025-04-10 12:49:05 +02:00
parent 4aff98e77b
commit 1cdd00920f
9151 changed files with 1800913 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Class CheckLoginCredentialsHook.
*/
class CheckLoginCredentialsHook extends HookEvent implements CheckLoginCredentialsHookEventInterface
{
/**
* CheckLoginCredentialsHook constructor.
*
* @throws Exception
*/
protected function __construct()
{
parent::__construct('CheckLoginCredentialsHook');
}
/**
* Call to all observers.
*
* @return bool
*/
public function notifyLoginCredentials()
{
/** @var CheckLoginCredentialsHookObserverInterface $observer */
foreach ($this->observers as $observer) {
$isChecked = $observer->checkLoginCredentials($this);
if ($isChecked) {
return true;
}
}
return false;
}
}

View File

@@ -0,0 +1,53 @@
<?php
/* For licensing terms, see /license.txt */
/**
* This file contains a Hook Event class for Admin Block.
*
* @package chamilo.library.hook
*/
/**
* Class HookAdminBlock
* This class is a Hook event implementing Admin Block Event interface.
* This class is used to modify admin block by notifying Hook Observer for Admin Block.
*/
class HookAdminBlock extends HookEvent implements HookAdminBlockEventInterface
{
/**
* Constructor.
*/
protected function __construct()
{
parent::__construct('HookAdminBlock');
}
/**
* Notify Hook observers for Admin Block event.
*
* @param int $type Set the type of hook event called.
* 0: HOOK_EVENT_TYPE_PRE, 1: HOOK_EVENT_TYPE_POST
*
* @return array|int
*/
public function notifyAdminBlock($type)
{
/** @var \HookAdminBlockObserverInterface $observer */
// Save data
if (isset($this->eventData['blocks'])) {
$this->eventData['type'] = $type;
// Call all registered hook observers for admin block
foreach ($this->observers as $observer) {
$data = $observer->hookAdminBlock($this);
if (isset($data['blocks'])) {
// Get modified data
$this->eventData['blocks'] = $data['blocks'];
}
}
return $this->eventData;
}
return 0;
}
}

View File

@@ -0,0 +1,36 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Class HookConditionalLogin.
* Hook to implement Conditional Login.
*/
class HookConditionalLogin extends HookEvent implements HookConditionalLoginEventInterface
{
/**
* HookConditionalLogin constructor.
*
* @throws Exception
*/
protected function __construct()
{
parent::__construct('HookConditionalLogin');
}
/**
* Notify to all hook observers.
*
* @return array
*/
public function notifyConditionalLogin()
{
$conditions = [];
/** @var HookConditionalLoginObserverInterface $observer */
foreach ($this->observers as $observer) {
$conditions[] = $observer->hookConditionalLogin($this);
}
return $conditions;
}
}

View File

@@ -0,0 +1,37 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Class HookCreateCourse.
*/
class HookCreateCourse extends HookEvent implements HookCreateCourseEventInterface
{
/**
* HookCreateCourse constructor.
*
* @throws Exception
*/
protected function __construct()
{
parent::__construct('HookCreateCourse');
}
/**
* Update all the observers.
*
* @param int $type
*
* @return int
*/
public function notifyCreateCourse($type)
{
$this->eventData['type'] = $type;
/** @var HookCreateCourseObserverInterface $observer */
foreach ($this->observers as $observer) {
$observer->hookCreateCourse($this);
}
return 1;
}
}

View File

@@ -0,0 +1,37 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Class HookCreateUser.
*
* @var \SplObjectStorage
*/
class HookCreateUser extends HookEvent implements HookCreateUserEventInterface
{
/**
* Constructor.
*/
protected function __construct()
{
parent::__construct('HookCreateUser');
}
/**
* Update all the observers.
*
* @param int $type
*
* @return int
*/
public function notifyCreateUser($type)
{
$this->eventData['type'] = $type;
/** @var HookCreateUserObserverInterface $observer */
foreach ($this->observers as $observer) {
$observer->hookCreateUser($this);
}
return 1;
}
}

View File

@@ -0,0 +1,39 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Class HookDocumentAction.
*/
class HookDocumentAction extends HookEvent implements HookDocumentActionEventInterface
{
/**
* HookDocumentAction constructor.
*
* @throws \Exception
*/
protected function __construct()
{
parent::__construct('HookDocumentAction');
}
/**
* Update all the observers.
*
* @param int $type
*
* @return array
*/
public function notifyDocumentAction($type)
{
$this->eventData['type'] = $type;
/** @var \HookDocumentActionObserverInterface $observer */
foreach ($this->observers as $observer) {
$data = $observer->notifyDocumentAction($this);
$this->setEventData($data);
}
return $this->eventData;
}
}

View File

@@ -0,0 +1,39 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Class HookDocumentItemAction.
*/
class HookDocumentItemAction extends HookEvent implements HookDocumentItemActionEventInterface
{
/**
* HookDocumentItemAction constructor.
*
* @throws \Exception
*/
protected function __construct()
{
parent::__construct('HookDocumentItemAction');
}
/**
* Update all the observers.
*
* @param int $type
*
* @return array
*/
public function notifyDocumentItemAction($type)
{
$this->eventData['type'] = $type;
/** @var \HookDocumentItemActionObserverInterface $observer */
foreach ($this->observers as $observer) {
$data = $observer->notifyDocumentItemAction($this);
$this->setEventData($data);
}
return $this->eventData;
}
}

View File

@@ -0,0 +1,34 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Class HookDocumentItemView.
*/
class HookDocumentItemView extends HookEvent implements HookDocumentItemViewEventInterface
{
/**
* HookDocumentItemView constructor.
*
* @throws Exception
*/
protected function __construct()
{
parent::__construct('HookDocumentItemView');
}
/**
* {@inheritDoc}
*/
public function notifyDocumentItemView(): array
{
$tools = [];
/** @var HookDocumentItemViewObserverInterface $observer */
foreach ($this->observers as $observer) {
$tools[] = $observer->notifyDocumentItemView($this);
}
return $tools;
}
}

View File

@@ -0,0 +1,193 @@
<?php
/* For licensing terms, see /license.txt */
/**
* This file contains an abstract Hook event class
* Used for Hook Events (e.g Create user, Webservice registration).
*
* @package chamilo.library.hook
*/
/**
* Class HookEvent
* This abstract class implements Hook Event Interface to build the base
* for Hook Events. This class have some public static method,
* e.g for create Hook Events.
*/
abstract class HookEvent implements HookEventInterface
{
public $observers;
public $eventName;
public $eventData;
public $manager;
public static $hook;
/**
* Construct Method.
*
* @param string $eventName
*
* @throws Exception
*/
protected function __construct($eventName)
{
$this->observers = new SplObjectStorage();
$this->eventName = $eventName;
$this->eventData = [];
$this->manager = HookManagement::create();
$this->loadAttachments();
}
/**
* Return the singleton instance of Hook event.
*
* @return static
*/
public static function create()
{
static $result = null;
if ($result) {
return $result;
} else {
try {
$class = get_called_class();
return new $class();
} catch (Exception $e) {
return null;
}
}
}
/**
* Attach an HookObserver.
*
* @see http://php.net/manual/en/splsubject.attach.php
*
* @param \HookObserverInterface| $observer <p>
* The <b>HookObserver</b> to attach.
* </p>
*/
public function attach(HookObserverInterface $observer)
{
$observerClass = get_class($observer);
self::$hook[$this->eventName][$observerClass] = [
'class_name' => $observerClass,
'path' => $observer->getPath(),
'plugin_name' => $observer->getPluginName(),
];
$this->observers->attach($observer);
$this->manager->insertHook($this->eventName, $observerClass, HOOK_EVENT_TYPE_ALL);
}
/**
* Detach an HookObserver.
*
* @see http://php.net/manual/en/splsubject.detach.php
*
* @param \HookObserverInterface| $observer <p>
* The <b>HookObserver</b> to detach.
* </p>
*/
public function detach(HookObserverInterface $observer)
{
$observerClass = get_class($observer);
unset(self::$hook[$this->eventName][$observerClass]);
$this->observers->detach($observer);
$this->manager->deleteHook($this->eventName, $observerClass, HOOK_EVENT_TYPE_ALL);
}
/**
* Notify an observer.
*
* @see http://php.net/manual/en/splsubject.notify.php
*/
public function notify()
{
foreach ($this->observers as $observer) {
$observer->update($this);
}
}
/**
* Return the event name refer to where hook is used.
*
* @return string
*/
public function getEventName()
{
return $this->eventName;
}
/**
* Return an array containing all data needed by the hook observer to update.
*
* @return array
*/
public function getEventData()
{
return $this->eventData;
}
/**
* Set an array with data needed by hooks.
*
* @return $this
*/
public function setEventData(array $data)
{
foreach ($data as $key => $value) {
// Assign value for each array item
$this->eventData[$key] = $value;
}
return $this;
}
/**
* Detach all hook observers.
*
* @return $this
*/
public function detachAll()
{
self::$hook[$this->eventName] = null;
$this->observers->removeAll($this->observers);
}
/**
* Clear all hookObservers without detach them.
*
* @return mixed
*/
public function clearAttachments()
{
$this->observers->removeAll($this->observers);
}
/**
* Load all hook observer already registered from Session or Database.
*
* @return $this
*/
public function loadAttachments()
{
if (isset(self::$hook[$this->eventName]) && is_array(self::$hook[$this->eventName])) {
foreach (self::$hook[$this->eventName] as $hookObserver => $val) {
$hookObserverInstance = $hookObserver::create();
$this->observers->attach($hookObserverInstance);
}
} else {
// Load from Database and save into global name
self::$hook[$this->eventName] = $this->manager->listHookObservers($this->eventName);
if (isset(self::$hook[$this->eventName]) && is_array(self::$hook[$this->eventName])) {
foreach (self::$hook[$this->eventName] as $hookObserver => $val) {
$hookObserverInstance = $hookObserver::create();
$this->observers->attach($hookObserverInstance);
}
}
}
return $this;
}
}

View File

@@ -0,0 +1,19 @@
<?php
/* For licensing terms, see /license.txt */
class HookLearningPathCreated extends HookEvent implements HookLearningPathCreatedEventInterface
{
protected function __construct()
{
parent::__construct('HookLearningPathCreated');
}
public function notifyCreated()
{
/** @var HookLearningPathCreatedObserverInterface $observer */
foreach ($this->observers as $observer) {
$observer->hookCreated($this);
}
}
}

View File

@@ -0,0 +1,30 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Class HookLearningPathEnd.
*/
class HookLearningPathEnd extends HookEvent implements HookLearningPathEndEventInterface
{
/**
* HookLearningPathEnd constructor.
*
* @throws \Exception
*/
protected function __construct()
{
parent::__construct('HookLearningPathEndEvent');
}
/**
* {@inheritdoc}
*/
public function hookLearningPathEnd()
{
/** @var \HookLearningPathEndObserverInterface $observer */
foreach ($this->observers as $observer) {
$observer->notifyLearningPathEnd($this);
}
}
}

View File

@@ -0,0 +1,30 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Class HookLearningPathItemViewed.
*/
class HookLearningPathItemViewed extends HookEvent implements HookLearningPathItemViewedEventInterface
{
/**
* HookLearningPathItemViewed constructor.
*
* @throws \Exception
*/
protected function __construct()
{
parent::__construct('HookLearningPathItemViewed');
}
/**
* {@inheritdoc}
*/
public function notifyLearningPathItemViewed()
{
/** @var \HookLearningPathItemViewedObserverInterface $observer */
foreach ($this->observers as $observer) {
$observer->hookLearningPathItemViewed($this);
}
}
}

View File

@@ -0,0 +1,371 @@
<?php
/* For licensing terms, see /license.txt */
/**
* @TODO: Improve description
*
* @package chamilo.hookmanagement
*/
class HookManagement implements HookManagementInterface
{
/**
* Constructor.
*/
protected function __construct()
{
$this->tables[TABLE_HOOK_OBSERVER] = Database::get_main_table(TABLE_HOOK_OBSERVER);
$this->tables[TABLE_HOOK_EVENT] = Database::get_main_table(TABLE_HOOK_EVENT);
$this->tables[TABLE_HOOK_CALL] = Database::get_main_table(TABLE_HOOK_CALL);
$this->hookCalls = $this->listAllHookCalls();
$this->hookEvents = $this->listAllHookEvents();
$this->hookObservers = $this->listAllHookObservers();
}
/**
* Instance the hook manager.
*
* @staticvar null $result
*
* @return HookManagement
*/
public static function create()
{
static $result = null;
return $result ? $result : $result = new self();
}
/**
* Insert hook into Database. Return insert id.
*
* @param string $eventName
* @param string $observerClassName
* @param int $type
*
* @return int
*/
public function insertHook($eventName, $observerClassName, $type)
{
if ($type === HOOK_EVENT_TYPE_ALL) {
$this->insertHook($eventName, $observerClassName, HOOK_EVENT_TYPE_PRE);
$this->insertHook($eventName, $observerClassName, HOOK_EVENT_TYPE_POST);
} else {
$this->insertHookIfNotExist($eventName, $observerClassName);
// Check if exists hook call
$row = Database::select(
'id, enabled',
$this->tables[TABLE_HOOK_CALL],
[
'where' => [
'hook_event_id = ? ' => $this->hookEvents[$eventName],
'AND hook_observer_id = ? ' => $this->hookObservers[$observerClassName],
'AND type = ? ' => $type,
],
],
'ASSOC'
);
if (!empty($row) && is_array($row)) {
// Check if is hook call is active
if ((int) $row['enabled'] === 0) {
Database::update(
$this->tables[TABLE_HOOK_CALL],
[
'enabled' => 1,
],
[
'id = ?' => $row['id'],
]
);
}
}
}
}
/**
* Delete hook from Database. Return deleted rows number.
*
* @param string $eventName
* @param string $observerClassName
* @param int $type
*
* @return int
*/
public function deleteHook($eventName, $observerClassName, $type)
{
if ($type === HOOK_EVENT_TYPE_ALL) {
$this->deleteHook($eventName, $observerClassName, HOOK_EVENT_TYPE_PRE);
$this->deleteHook($eventName, $observerClassName, HOOK_EVENT_TYPE_POST);
} else {
$this->insertHookIfNotExist($eventName, $observerClassName);
Database::update(
$this->tables[TABLE_HOOK_CALL],
[
'enabled' => 0,
],
[
'id = ? ' => $this->hookCalls[$eventName][$observerClassName][$type],
]
);
}
}
/**
* Update hook observer order by hook event.
*
* @param $eventName
* @param $type
* @param $hookOrders
*
* @return int
*/
public function orderHook($eventName, $type, $hookOrders)
{
foreach ($this->hookCalls[$eventName] as $observerClassName => $types) {
foreach ($hookOrders as $oldOrder => $newOrder) {
$res = Database::update(
$this->tables[TABLE_HOOK_CALL],
[
'hook_order ' => $newOrder,
],
[
'id = ? ' => $types[$type],
'AND hook_order = ? ' => $oldOrder,
]
);
if ($res) {
break;
}
}
}
}
/**
* Return a list an associative array where keys are the active hook observer class name.
*
* @param string $eventName
*
* @return array
*/
public function listHookObservers($eventName)
{
$array = [];
$joinTable = $this->tables[TABLE_HOOK_CALL].' hc'.
' INNER JOIN '.$this->tables[TABLE_HOOK_EVENT].' he'.
' ON hc.hook_event_id = he.id '.
' INNER JOIN '.$this->tables[TABLE_HOOK_OBSERVER].' ho '.
' ON hc.hook_observer_id = ho.id ';
$columns = 'ho.class_name, ho.path, ho.plugin_name, hc.enabled';
$where = ['where' => ['he.class_name = ? ' => $eventName, 'AND hc.enabled = ? ' => 1]];
$rows = Database::select($columns, $joinTable, $where);
foreach ($rows as $row) {
$array[$row['class_name']] = $row;
}
return $array;
}
/**
* Return a list an associative array where keys are the active hook observer class name.
*
* @return array
*/
public function listAllHookObservers()
{
$array = [];
$columns = 'id, class_name';
$rows = Database::select($columns, $this->tables[TABLE_HOOK_OBSERVER]);
foreach ($rows as $row) {
$array[$row['class_name']] = $row['id'];
}
return $array;
}
/**
* Return a list an associative array where keys are the active hook observer class name.
*
* @return array
*/
public function listAllHookEvents()
{
$array = [];
$columns = 'id, class_name';
$rows = Database::select($columns, $this->tables[TABLE_HOOK_EVENT]);
foreach ($rows as $row) {
$array[$row['class_name']] = $row['id'];
}
return $array;
}
/**
* Return a list an associative array where keys are the active hook observer class name.
*
* @return array
*/
public function listAllHookCalls()
{
$array = [];
$joinTable = $this->tables[TABLE_HOOK_CALL].' hc'.
' INNER JOIN '.$this->tables[TABLE_HOOK_EVENT].' he'.
' ON hc.hook_event_id = he.id '.
' INNER JOIN '.$this->tables[TABLE_HOOK_OBSERVER].' ho '.
' ON hc.hook_observer_id = ho.id ';
$columns = 'he.class_name AS event_class_name, ho.class_name AS observer_class_name, hc.id AS id, hc.type AS type';
$rows = Database::select($columns, $joinTable);
foreach ($rows as $row) {
$array[$row['event_class_name']][$row['observer_class_name']][$row['type']] = $row['id'];
}
return $array;
}
/**
* Check if hooks (event, observer, call) exist in Database, if not,
* Will insert them into their respective table.
*
* @param string $eventName
* @param string $observerClassName
*
* @return int
*/
public function insertHookIfNotExist($eventName = null, $observerClassName = null)
{
// Check if exists hook event
if (isset($eventName) && !isset($this->hookEvents[$eventName])) {
$attributes = [
'class_name' => $eventName,
'description' => get_lang('HookDescription'.$eventName),
];
$id = Database::insert($this->tables[TABLE_HOOK_EVENT], $attributes);
$this->hookEvents[$eventName] = $id;
}
// Check if exists hook observer
if (isset($observerClassName) &&
!isset($this->hookObservers[$observerClassName])
) {
$object = $observerClassName::create();
$attributes = [
'class_name' => $observerClassName,
'path' => $object->getPath(),
'plugin_name' => $object->getPluginName(),
];
$id = Database::insert($this->tables[TABLE_HOOK_OBSERVER], $attributes);
$this->hookObservers[$observerClassName] = $id;
}
if (isset($eventName) &&
isset($observerClassName) &&
!isset($this->hookCalls[$eventName][$observerClassName])
) {
// HOOK TYPE PRE
$row = Database::select(
'MAX(hook_order) as hook_order',
$this->tables[TABLE_HOOK_CALL],
[
'where' => [
'hook_event_id = ? ' => $this->hookEvents[$eventName],
'AND type = ? ' => HOOK_EVENT_TYPE_PRE,
],
],
'ASSOC'
);
// Check if exists hook call
$id = Database::insert(
$this->tables[TABLE_HOOK_CALL],
[
'hook_event_id' => $this->hookEvents[$eventName],
'hook_observer_id' => $this->hookObservers[$observerClassName],
'type' => HOOK_EVENT_TYPE_PRE,
'enabled' => 0,
'hook_order' => $row['hook_order'] + 1,
]
);
$this->hookCalls[$eventName][$observerClassName][HOOK_EVENT_TYPE_PRE] = $id;
// HOOK TYPE POST
$row = Database::select(
'MAX(hook_order) as hook_order',
$this->tables[TABLE_HOOK_CALL],
[
'where' => [
'hook_event_id = ? ' => $this->hookEvents[$eventName],
'AND type = ? ' => HOOK_EVENT_TYPE_POST,
],
],
'ASSOC'
);
// Check if exists hook call
$id = Database::insert(
$this->tables[TABLE_HOOK_CALL],
[
'hook_event_id' => $this->hookEvents[$eventName],
'hook_observer_id' => $this->hookObservers[$observerClassName],
'type' => HOOK_EVENT_TYPE_POST,
'enabled' => 0,
'hook_order' => $row['hook_order'] + 1,
]
);
$this->hookCalls[$eventName][$observerClassName][HOOK_EVENT_TYPE_POST] = $id;
} elseif (isset($eventName) && !isset($observerClassName)) {
foreach ($this->hookObservers as $observer => $id) {
$this->insertHookIfNotExist($eventName, $observer);
}
} elseif (!isset($eventName) && isset($observerClassName)) {
foreach ($this->hookEvents as $event => $id) {
$this->insertHookIfNotExist($event, $observerClassName);
}
}
return 1;
}
/**
* Return the hook call id identified by hook event, hook observer and type.
*
* @param string $eventName
* @param string $observerClassName
* @param int $type
*
* @return mixed
*/
public function getHookCallId($eventName, $observerClassName, $type)
{
$eventName = Database::escape_string($eventName);
$observerClassName($observerClassName);
$type = Database::escape_string($type);
$joinTable = $this->tables[TABLE_HOOK_CALL].' hc'.
' INNER JOIN '.$this->tables[TABLE_HOOK_EVENT].' he'.
' ON hc.hook_event_id = he.id '.
' INNER JOIN '.$this->tables[TABLE_HOOK_OBSERVER].' ho '.
' ON hc.hook_observer_id = ho.id ';
$row = Database::select(
'id',
$joinTable,
[
'where' => [
'he.class_name = ? ' => $eventName,
'AND ho.class_name = ? ' => $observerClassName,
'AND hc.type = ? ' => $type,
],
],
'ASSOC'
);
return $row['id'];
}
}

View File

@@ -0,0 +1,54 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Class HookMyStudentsLpTracking.
*/
class HookMyStudentsLpTracking extends HookEvent implements HookMyStudentsLpTrackingEventInterface
{
/**
* HookMyStudentsLpTracking constructor.
*
* @throws Exception
*/
protected function __construct()
{
parent::__construct('HookMyStudentsLpTracking');
}
/**
* @return array
*/
public function notifyTrackingHeader()
{
$results = [];
/** @var HookMyStudentsLpTrackingObserverInterface $observer */
foreach ($this->observers as $observer) {
$results[] = $observer->trackingHeader($this);
}
return $results;
}
/**
* @param int $lpId
* @param int $studentId
*
* @return array
*/
public function notifyTrackingContent($lpId, $studentId)
{
$this->eventData['lp_id'] = $lpId;
$this->eventData['student_id'] = $studentId;
$results = [];
/** @var HookMyStudentsLpTrackingObserverInterface $observer */
foreach ($this->observers as $observer) {
$results[] = $observer->trackingContent($this);
}
return $results;
}
}

View File

@@ -0,0 +1,54 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Class HookMyStudentsQuizTracking.
*/
class HookMyStudentsQuizTracking extends HookEvent implements HookMyStudentsQuizTrackingEventInterface
{
/**
* HookMyStudentsQuizTracking constructor.
*
* @throws Exception
*/
protected function __construct()
{
parent::__construct('HookMyStudentsQuizTracking');
}
/**
* @return array
*/
public function notifyTrackingHeader()
{
$results = [];
/** @var HookMyStudentsQuizTrackingObserverInterface $observer */
foreach ($this->observers as $observer) {
$results[] = $observer->trackingHeader($this);
}
return $results;
}
/**
* @param int $quizId
* @param int $studentId
*
* @return array
*/
public function notifyTrackingContent($quizId, $studentId)
{
$this->eventData['quiz_id'] = $quizId;
$this->eventData['student_id'] = $studentId;
$results = [];
/** @var HookMyStudentsQuizTrackingObserverInterface $observer */
foreach ($this->observers as $observer) {
$results[] = $observer->trackingContent($this);
}
return $results;
}
}

View File

@@ -0,0 +1,47 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Class HookNotificationContent
* Hook Event class for Content format of Notifications.
*
* @package chamilo.library.hook
*/
class HookNotificationContent extends HookEvent implements HookNotificationContentEventInterface
{
/**
* Construct.
*/
protected function __construct()
{
parent::__construct('HookNotificationContent');
}
/**
* @param int $type
*
* @return array|null
*/
public function notifyNotificationContent($type)
{
/** @var \HookNotificationContentObserverInterface $observer */
// Check if exists data content
if (isset($this->eventData['content'])) {
// Save data type
$this->eventData['type'] = $type;
// Check for hook all registered observers
foreach ($this->observers as $observer) {
$data = $observer->hookNotificationContent($this);
// Check if isset content
if (isset($data['content'])) {
// Set data from hook observer data
$this->setEventData($data);
}
}
return $this->eventData;
}
return null;
}
}

View File

@@ -0,0 +1,50 @@
<?php
/* For licensing terms, see /license.txt */
/**
* This file contains the Hook Event class for Title of Notifications.
*
* @package chamilo.library.hook
*/
/**
* Class HookNotificationTitle.
*/
class HookNotificationTitle extends HookEvent implements HookNotificationTitleEventInterface
{
/**
* Construct.
*/
protected function __construct()
{
parent::__construct('HookNotificationTitle');
}
/**
* @param int $type
*
* @return array|null
*/
public function notifyNotificationTitle($type)
{
/** @var \HookNotificationTitleObserverInterface $observer */
// Check if exists data title
if (isset($this->eventData['title'])) {
// Save data type
$this->eventData['type'] = $type;
// Check for hook all registered observers
foreach ($this->observers as $observer) {
// Get data from hook observer
$data = $observer->hookNotificationTitle($this);
// Check if isset data title
if (isset($data['title'])) {
// Set data from hook observer data
$this->setEventData($data);
}
}
return $this->eventData;
}
return null;
}
}

View File

@@ -0,0 +1,78 @@
<?php
/* For licensing terms, see /license.txt */
/**
* This file contains an abstract Hook observer class
* Used for Hook Observers in plugins, called when a hook event happens
* (e.g Create user, Webservice registration).
*
* @package chamilo.library.hook
*/
/**
* Class HookObserver
* This abstract class implements Hook Observer Interface to build the base
* for Hook Observer. This class have some public static method,
* e.g for create Hook Observers.
*/
abstract class HookObserver implements HookObserverInterface
{
public $path;
public $pluginName;
/**
* Construct method
* Save the path of Hook Observer class implementation and
* the plugin name where this class is included.
*
* @param string $path
* @param string $pluginName
*/
protected function __construct($path, $pluginName)
{
$this->path = $path;
$this->pluginName = $pluginName;
}
/**
* Return the singleton instance of Hook observer.
* If Hook Management plugin is not enabled, will return NULL.
*
* @return HookObserver
*/
public static function create()
{
static $result = null;
if ($result) {
return $result;
} else {
try {
$class = get_called_class();
return new $class();
} catch (Exception $e) {
return null;
}
}
}
/**
* Return the path from the class, needed to store location or autoload later.
*
* @return string
*/
public function getPath()
{
return $this->path;
}
/**
* Return the plugin name where is the Hook Observer.
*
* @return string
*/
public function getPluginName()
{
return $this->pluginName;
}
}

View File

@@ -0,0 +1,19 @@
<?php
/* For licensing terms, see /license.txt */
class HookPortfolioCommentEdited extends HookEvent implements HookPortfolioCommentEditedEventInterface
{
protected function __construct()
{
parent::__construct('HookPortfolioCommentEdited');
}
public function notifyCommentEdited()
{
/** @var HookPortfolioCommentEditedObserverInterface $observer */
foreach ($this->observers as $observer) {
$observer->hookCommentEdited($this);
}
}
}

View File

@@ -0,0 +1,19 @@
<?php
/* For licensing terms, see /license.txt */
class HookPortfolioCommentScored extends HookEvent implements HookPortfolioCommentScoredEventInterface
{
protected function __construct()
{
parent::__construct('HookPortfolioCommentScored');
}
public function notifyCommentScored()
{
/** @var HookPortfolioCommentScoredObserverInterface $observer */
foreach ($this->observers as $observer) {
$observer->hookCommentScored($this);
}
}
}

View File

@@ -0,0 +1,19 @@
<?php
/* For licensing terms, see /license.txt */
class HookPortfolioDownloaded extends HookEvent implements HookPortfolioDownloadedEventInterface
{
protected function __construct()
{
parent::__construct('HookPortfolioDownloaded');
}
public function notifyPortfolioDownloaded(): void
{
/** @var HookPortfolioDownloadedObserverInterface $observer */
foreach ($this->observers as $observer) {
$observer->hookPortfolioDownloaded($this);
}
}
}

View File

@@ -0,0 +1,30 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Class HookPortfolioItemAdded.
*/
class HookPortfolioItemAdded extends HookEvent implements HookPortfolioItemAddedEventInterface
{
/**
* HookPortfolioItemAdded constructor.
*
* @throws \Exception
*/
public function __construct()
{
parent::__construct('HookPortfolioItemAdded');
}
/**
* {@inheritDoc}
*/
public function notifyItemAdded()
{
/** @var \HookPortfolioItemAddedObserverInterface $observer */
foreach ($this->observers as $observer) {
$observer->hookItemAdded($this);
}
}
}

View File

@@ -0,0 +1,27 @@
<?php
/* For licensing terms, see /license.txt */
class HookPortfolioItemCommented extends HookEvent implements HookPortfolioItemCommentedEventInterface
{
/**
* HookPortfolioItemCommented constructor.
*
* @throws \Exception
*/
protected function __construct()
{
parent::__construct('HookPortfolioItemCommented');
}
/**
* {@inheritDoc}
*/
public function notifyItemCommented()
{
/** @var \HookPortfolioItemCommentedObserverInterface $observer */
foreach ($this->observers as $observer) {
$observer->hookItemCommented($this);
}
}
}

View File

@@ -0,0 +1,19 @@
<?php
/* For licensing terms, see /license.txt */
class HookPortfolioItemDeleted extends HookEvent implements HookPortfolioItemDeletedEventInterface
{
protected function __construct()
{
parent::__construct('HookPortfolioItemDeleted');
}
public function notifyItemDeleted()
{
/** @var HookPortfolioItemDeletedHookObserverInterface $observer */
foreach ($this->observers as $observer) {
$observer->hookItemDeleted($this);
}
}
}

View File

@@ -0,0 +1,19 @@
<?php
/* For licensing terms, see /license.txt */
class HookPortfolioItemEdited extends HookEvent implements HookPortfolioItemEditedEventInterface
{
protected function __construct()
{
parent::__construct('HookPortfolioItemEdited');
}
public function notifyItemEdited()
{
/** @var HookPortfolioItemEditedObserverInterface $observer */
foreach ($this->observers as $observer) {
$observer->hookItemEdited($this);
}
}
}

View File

@@ -0,0 +1,19 @@
<?php
/* For licensing terms, see /license.txt */
class HookPortfolioItemHighlighted extends HookEvent implements HookPortfolioItemHighlightedEventInterface
{
protected function __construct()
{
parent::__construct('HookPortfolioItemHighlighted');
}
public function notifyItemHighlighted()
{
/** @var HookPortfolioItemHighlightedObserverInterface $observer */
foreach ($this->observers as $observer) {
$observer->hookItemHighlighted($this);
}
}
}

View File

@@ -0,0 +1,19 @@
<?php
/* For licensing terms, see /license.txt */
class HookPortfolioItemScored extends HookEvent implements HookPortfolioItemScoredEventInterface
{
protected function __construct()
{
parent::__construct('HookPortfolioItemScored');
}
public function notifyItemScored(): void
{
/** @var HookPortfolioItemScoredObserverInterface $observer */
foreach ($this->observers as $observer) {
$observer->hookItemScored($this);
}
}
}

View File

@@ -0,0 +1,19 @@
<?php
/* For licensing terms, see /license.txt */
class HookPortfolioItemViewed extends HookEvent implements HookPortfolioItemViewedEventInterface
{
protected function __construct()
{
parent::__construct('HookPortfolioItemViewed');
}
public function notifyItemViewed(): void
{
/** @var HookPortfolioItemViewedObserverInterface $observer */
foreach ($this->observers as $observer) {
$observer->hookItemViewed($this);
}
}
}

View File

@@ -0,0 +1,22 @@
<?php
/* For licensing terms, see /license.txt */
class HookPortfolioItemVisibility extends HookEvent implements HookPortfolioItemVisibilityEventInterface
{
protected function __construct()
{
parent::__construct('HookPortfolioItemVisibility');
}
/**
* {@inheritDoc}
*/
public function notifyItemVisibility()
{
/** @var HookPortfolioItemVisibilityObserverInterface $observer */
foreach ($this->observers as $observer) {
$observer->hookItemVisibility($this);
}
}
}

View File

@@ -0,0 +1,29 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Class HookQuizEnd.
*/
class HookQuizEnd extends HookEvent implements HookQuizEndEventInterface
{
/**
* HookQuizEnd constructor.
*
* @throws Exception
*/
protected function __construct()
{
parent::__construct('HookQuizEnd');
}
/**
* {@inheritdoc}
*/
public function notifyQuizEnd()
{
/** @var HookQuizEndObserverInterface $observer */
foreach ($this->observers as $observer) {
$observer->hookQuizEnd($this);
}
}
}

View File

@@ -0,0 +1,30 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Class HookQuizQuestionAnswered.
*/
class HookQuizQuestionAnswered extends HookEvent implements HookQuizQuestionAnsweredEventInterface
{
/**
* HookQuizQuestionAnswered constructor.
*
* @throws \Exception
*/
protected function __construct()
{
parent::__construct('HookQuestionAnswered');
}
/**
* {@inheritdoc}
*/
public function notifyQuizQuestionAnswered()
{
/** @var \HookQuizQuestionAnsweredObserverInterface $observer */
foreach ($this->observers as $observer) {
$observer->hookQuizQuestionAnswered($this);
}
}
}

View File

@@ -0,0 +1,36 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Class HookResubscribe.
*
* @var \SplObjectStorage
*/
class HookResubscribe extends HookEvent implements HookResubscribeEventInterface
{
/**
* Constructor.
*/
protected function __construct()
{
parent::__construct('HookResubscribe');
}
/**
* Update all the observers.
*
* @param int $type
*
* @return int
*/
public function notifyResubscribe($type)
{
/** @var \HookResubscribeObserverInterface $observer */
$this->eventData['type'] = $type;
foreach ($this->observers as $observer) {
$observer->hookResubscribe($this);
}
return 1;
}
}

View File

@@ -0,0 +1,36 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Class HookEventSkype.
*
* @var \SplObjectStorage
*/
class HookEventSkype extends HookEvent implements HookSkypeEventInterface
{
/**
* Constructor.
*/
protected function __construct()
{
parent::__construct('HookEventSkype');
}
/**
* Update all the observers.
*
* @param int $type
*
* @return int
*/
public function notifySkype($type)
{
/** @var \HookSkypeObserverInterface $observer */
$this->eventData['type'] = $type;
foreach ($this->observers as $observer) {
$observer->hookEventSkype($this);
}
return 1;
}
}

View File

@@ -0,0 +1,37 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Class HookUpdateUser.
*
* @var \SplObjectStorage
*/
class HookUpdateUser extends HookEvent implements HookUpdateUserEventInterface
{
/**
* Constructor.
*/
public function __construct()
{
parent::__construct('HookUpdateUser');
}
/**
* Update all the observers.
*
* @param int $type
*
* @return int
*/
public function notifyUpdateUser($type)
{
$this->eventData['type'] = $type;
/** @var HookUpdateUserObserverInterface $observer */
foreach ($this->observers as $observer) {
$observer->hookUpdateUser($this);
}
return 1;
}
}

View File

@@ -0,0 +1,58 @@
<?php
/* For licensing terms, see /license.txt */
/**
* This file contains a Hook Event class for Admin Block.
*
* @package chamilo.library.hook
*/
/**
* Class HookWSRegistration
* This class is a Hook event implementing Webservice Registration Event interface.
* This class is used to modify ws for registration by notifying Hook Observer
* for Webservice registration.
*/
class HookWSRegistration extends HookEvent implements HookWSRegistrationEventInterface
{
/**
* Construct.
*/
protected function __construct()
{
parent::__construct('HookWSRegistration');
}
/**
* Notify all Hook observer for WS Registration.
* This save "server" (soap server) and send to Hook observer to be modified
* (e.g. add more registration webservice).
*
* @param int $type Set the type of hook event called.
* 0: HOOK_EVENT_TYPE_PRE, 1: HOOK_EVENT_TYPE_POST
*
* @return int
*/
public function notifyWSRegistration($type)
{
/** @var \HookWSRegistrationObserverInterface $observer */
// check if already have server data
if (isset($this->eventData['server'])) {
// Save Hook event type data
$this->eventData['type'] = $type;
foreach ($this->observers as $observer) {
// Notify all registered observers
$data = $observer->hookWSRegistration($this);
// check if server is not null
if (isset($data['server'])) {
// Get modified server
$this->eventData['server'] = $data['server'];
}
}
return $this->eventData;
}
return 1;
}
}

View File

@@ -0,0 +1,65 @@
Hook Management plugin for Chamilo LMS
=======================================
Enable hooks in Chamilo to allow plugins and core to extend current features and
watch for certain events.
The Hooks structure is based on the Observer pattern
The base structure is composed of 3 Interfaces
* HookEvent: will call the hook methods in Chamilo code
* HookObserver: will be executed when a Hook event is called
* HookManagement: manages hooks, creation, instantiation, persistence and
connection to the database
From version 1.10.x, the following Hooks (or more) exist:
|Number| Directory | EventClass | ObserverInterface | Reference |
|------|-----------------------------------|----------------|---------------------------------|---------------------------|
| 1| /main/inc/lib/usermanager.lib.php | HookCreateUser | HookCreateUserObserverInterface | UserManager::createUser() |
| 2| /main/inc/lib/usermanager.lib.php | HookUpdateUser | HookUpdateUserObserverInterface | UserManager::updateUser() |
| 3| /main/admin/index.php | HookAdminBlock | HookAdminBlockObserverInterface | ADMIN BLOCK |
# What do I need to use Hooks?
You need to create a class extending the `HookObserver` class and implement any
(or many) Hook Observer Interfaces, e.g. `HookCreateUserObserverInterface`.
An observer can implement many Hook Observer Interfaces.
This was developed to allow plugins to have a unique Hook Observer class.
Don't forget to add your Hook Observer class to the autoload file (vendor/composer/autoload_classmap.php).
# How to add MyHookObserver to my plugin?
When installing your plugin (or other functions) you should call the attach
method from a specific Hook Observer class, e.g. `HookCreateUser` class
```
$myHookObserver = MyHookObserver::create();
HookCreateUser::create()->attach($myHookObserver);
```
# How to detach MyHookObserver from inside my plugin?
To detach the HookObserver, it should be detached from a specific Hook Event class
```
$myHookObserver = MyHookObserver::create();
HookCreateUser::create()->detach($myHookObserver);
```
# How to add HookEvents to the Chamilo code (add the possibility to be hooked)?
To expand Hooks in Chamilo you should:
1. Identify an event that could be customized through a plugin
2. Create an interface for the Hook Event and the Hook Observer.
The names should be like the Hooks interfaces already created,
with The Pattern: HookXyzEventInterface and HookXyzObserverInterface.
e.g. Hook event: `HookUpdateUserEventInterface`, Hook observer: `HookUpdateUserObserverInterface`
3. Add at least one notify method to Hook Event Interface and update method to
Hook Observer Interface
4. Create a class extending the `HookEvent` class and implementing your Hook
Event Interface
5. Complete the notify method calling the Hook Observer update
6. Add your Interfaces and Class to the autoload file (vendor/composer/autoload_classmap.php)
7. Test your hook. If your Observer requires data, you can use the data property
from Hook Event

View File

@@ -0,0 +1,15 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Interface CheckLoginCredentialsHookEventInterface.
*/
interface CheckLoginCredentialsHookEventInterface extends HookEventInterface
{
/**
* Call to all observers.
*
* @return bool
*/
public function notifyLoginCredentials();
}

View File

@@ -0,0 +1,13 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Interface CheckLoginCredentialsHookObserverInterface.
*/
interface CheckLoginCredentialsHookObserverInterface extends HookObserverInterface
{
/**
* @return bool
*/
public function checkLoginCredentials(CheckLoginCredentialsHookEventInterface $event);
}

View File

@@ -0,0 +1,21 @@
<?php
/* For licensing terms, see /license.txt */
/**
* This file contains all Hook interfaces and their relation.
* They are used for Hook classes.
*
* @package chamilo.library.hook
*/
/**
* Interface HookAdminBlockEventInterface.
*/
interface HookAdminBlockEventInterface extends HookEventInterface
{
/**
* @param int $type
*
* @return int
*/
public function notifyAdminBlock($type);
}

View File

@@ -0,0 +1,19 @@
<?php
/* For licensing terms, see /license.txt */
/**
* This file contains all Hook interfaces and their relation.
* They are used for Hook classes.
*
* @package chamilo.library.hook
*/
/**
* Interface HookAdminBlockObserverInterface.
*/
interface HookAdminBlockObserverInterface extends HookObserverInterface
{
/**
* @return int
*/
public function hookAdminBlock(HookAdminBlockEventInterface $hook);
}

View File

@@ -0,0 +1,15 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Interface HookConditionalLoginEventInterface.
*/
interface HookConditionalLoginEventInterface extends HookEventInterface
{
/**
* Call Conditional Login hooks.
*
* @return array
*/
public function notifyConditionalLogin();
}

View File

@@ -0,0 +1,22 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Interface HookConditionalLoginObserverInterface.
*/
interface HookConditionalLoginObserverInterface extends HookObserverInterface
{
/**
* Return an associative array (callable, url) needed for Conditional Login.
* <code>
* [
* 'conditional_function' => function (array $userInfo) {},
* 'url' => '',
* ]
* </code>
* conditional_function returns false to redirect to the url and returns true to continue with the classical login.
*
* @return array
*/
public function hookConditionalLogin(HookConditionalLoginEventInterface $hook);
}

View File

@@ -0,0 +1,23 @@
<?php
/* For licensing terms, see /license.txt */
/**
* This file contains all Hook interfaces and their relation.
* They are used for Hook classes.
*
* @package chamilo.library.hook
*/
/**
* Interface HookCreateUserEventInterface.
*/
interface HookCreateCourseEventInterface extends HookEventInterface
{
/**
* Update all the observers.
*
* @param int $type
*
* @return int
*/
public function notifyCreateCourse($type);
}

View File

@@ -0,0 +1,19 @@
<?php
/* For licensing terms, see /license.txt */
/**
* This file contains all Hook interfaces and their relation.
* They are used for Hook classes.
*
* @package chamilo.library.hook
*/
/**
* Interface CreateUserHookInterface.
*/
interface HookCreateCourseObserverInterface extends HookObserverInterface
{
/**
* @return int
*/
public function hookCreateCourse(HookCreateCourseEventInterface $hook);
}

View File

@@ -0,0 +1,23 @@
<?php
/* For licensing terms, see /license.txt */
/**
* This file contains all Hook interfaces and their relation.
* They are used for Hook classes.
*
* @package chamilo.library.hook
*/
/**
* Interface HookCreateUserEventInterface.
*/
interface HookCreateUserEventInterface extends HookEventInterface
{
/**
* Update all the observers.
*
* @param int $type
*
* @return int
*/
public function notifyCreateUser($type);
}

View File

@@ -0,0 +1,19 @@
<?php
/* For licensing terms, see /license.txt */
/**
* This file contains all Hook interfaces and their relation.
* They are used for Hook classes.
*
* @package chamilo.library.hook
*/
/**
* Interface CreateUserHookInterface.
*/
interface HookCreateUserObserverInterface extends HookObserverInterface
{
/**
* @return int
*/
public function hookCreateUser(HookCreateUserEventInterface $hook);
}

View File

@@ -0,0 +1,16 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Interface HookDocumentActionEventInterface.
*/
interface HookDocumentActionEventInterface extends HookEventInterface
{
/**
* @param $type
*
* @return mixed
*/
public function notifyDocumentAction($type);
}

View File

@@ -0,0 +1,16 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Interface HookDocumentActionObserverInterface.
*/
interface HookDocumentActionObserverInterface extends HookObserverInterface
{
/**
* @param \HookDocumentActionEventInterface $hookvent
*
* @return mixed
*/
public function notifyDocumentAction(HookDocumentActionEventInterface $hookvent);
}

View File

@@ -0,0 +1,16 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Interface HookDocumentItemActionEventInterface.
*/
interface HookDocumentItemActionEventInterface extends HookEventInterface
{
/**
* @param $type
*
* @return mixed
*/
public function notifyDocumentItemAction($type);
}

View File

@@ -0,0 +1,16 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Interface HookDocumentItemActionObserverInterface.
*/
interface HookDocumentItemActionObserverInterface extends HookObserverInterface
{
/**
* @param \HookDocumentItemActionEventInterface $hookvent
*
* @return mixed
*/
public function notifyDocumentItemAction(HookDocumentItemActionEventInterface $hookvent);
}

View File

@@ -0,0 +1,8 @@
<?php
/* For licensing terms, see /license.txt */
interface HookDocumentItemViewEventInterface extends HookEventInterface
{
public function notifyDocumentItemView(): array;
}

View File

@@ -0,0 +1,11 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Interface HookDocumentItemViewObserverInterface.
*/
interface HookDocumentItemViewObserverInterface extends HookObserverInterface
{
public function notifyDocumentItemView(HookDocumentItemViewEventInterface $hookvent): string;
}

View File

@@ -0,0 +1,8 @@
<?php
/* For licensing terms, see /license.txt */
interface HookLearningPathCreatedEventInterface extends HookEventInterface
{
public function notifyCreated();
}

View File

@@ -0,0 +1,8 @@
<?php
/* For licensing terms, see /license.txt */
interface HookLearningPathCreatedObserverInterface extends HookObserverInterface
{
public function hookCreated(HookLearningPathCreatedEventInterface $hookEvent);
}

View File

@@ -0,0 +1,13 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Interface HookLearningPathEndEventInterface.
*/
interface HookLearningPathEndEventInterface extends HookEventInterface
{
/**
* @return mixed
*/
public function hookLearningPathEnd();
}

View File

@@ -0,0 +1,10 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Interface HookLearningPathEndObserverInterface.
*/
interface HookLearningPathEndObserverInterface extends HookObserverInterface
{
public function notifyLearningPathEnd(HookLearningPathEndEventInterface $event);
}

View File

@@ -0,0 +1,13 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Interface HookLearningPathItemViewedEventInterface.
*/
interface HookLearningPathItemViewedEventInterface extends HookEventInterface
{
/**
* @return mixed
*/
public function notifyLearningPathItemViewed();
}

View File

@@ -0,0 +1,15 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Interface HookLearningPathItemViewedObserverInterface.
*/
interface HookLearningPathItemViewedObserverInterface extends HookObserverInterface
{
/**
* @param \HookLearningPathItemViewedEventInterface $event
*
* @return mixed
*/
public function hookLearningPathItemViewed(HookLearningPathItemViewedEventInterface $event);
}

View File

@@ -0,0 +1,21 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Interface HookMyStudentsLpTrackingEventInterface.
*/
interface HookMyStudentsLpTrackingEventInterface extends HookEventInterface
{
/**
* @return array
*/
public function notifyTrackingHeader();
/**
* @param int $lpId
* @param int $studentId
*
* @return array
*/
public function notifyTrackingContent($lpId, $studentId);
}

View File

@@ -0,0 +1,34 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Interface HookMyStudentsLpTrackingObserverInterface.
*/
interface HookMyStudentsLpTrackingObserverInterface extends HookObserverInterface
{
/**
* Return an associative array this value and attributes.
* <code>
* [
* 'value' => 'Users online',
* 'attrs' => ['class' => 'text-center'],
* ]
* </code>.
*
* @return array
*/
public function trackingHeader(HookMyStudentsLpTrackingEventInterface $hook);
/**
* Return an associative array this value and attributes.
* <code>
* [
* 'value' => '5 connected users ',
* 'attrs' => ['class' => 'text-center text-success'],
* ]
* </code>.
*
* @return array
*/
public function trackingContent(HookMyStudentsLpTrackingEventInterface $hook);
}

View File

@@ -0,0 +1,21 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Interface HookMyStudentsQuizTrackingEventInterface.
*/
interface HookMyStudentsQuizTrackingEventInterface extends HookEventInterface
{
/**
* @return array
*/
public function notifyTrackingHeader();
/**
* @param int $quizId
* @param int $studentId
*
* @return array
*/
public function notifyTrackingContent($quizId, $studentId);
}

View File

@@ -0,0 +1,34 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Interface HookMyStudentsQuizTrackingObserverInterface.
*/
interface HookMyStudentsQuizTrackingObserverInterface extends HookObserverInterface
{
/**
* Return an associative array this value and attributes.
* <code>
* [
* 'value' => 'Users online',
* 'attrs' => ['class' => 'text-center'],
* ]
* </code>.
*
* @return array
*/
public function trackingHeader(HookMyStudentsQuizTrackingEventInterface $hook);
/**
* Return an associative array this value and attributes.
* <code>
* [
* 'value' => '5 connected users ',
* 'attrs' => ['class' => 'text-center text-success'],
* ]
* </code>.
*
* @return array
*/
public function trackingContent(HookMyStudentsQuizTrackingEventInterface $hook);
}

View File

@@ -0,0 +1,20 @@
<?php
/* For licensing terms, see /license.txt */
/**
* This file contains Hook event interface for notification content.
*
* @package chamilo.library.hook
*/
/**
* Interface HookNotificationContentEventInterface.
*/
interface HookNotificationContentEventInterface extends HookEventInterface
{
/**
* @param int $type
*
* @return array
*/
public function notifyNotificationContent($type);
}

View File

@@ -0,0 +1,18 @@
<?php
/* For licensing terms, see /license.txt */
/**
* This file contains Hook observer interface for notification content.
*
* @package chamilo.library.hook
*/
/**
* Interface HookNotificationContentObserverInterface.
*/
interface HookNotificationContentObserverInterface extends HookObserverInterface
{
/**
* @return array
*/
public function hookNotificationContent(HookNotificationContentEventInterface $hook);
}

View File

@@ -0,0 +1,20 @@
<?php
/* For licensing terms, see /license.txt */
/**
* This file contains Hook event interface for notification title.
*
* @package chamilo.library.hook
*/
/**
* Interface HookNotificationTitleEventInterface.
*/
interface HookNotificationTitleEventInterface extends HookEventInterface
{
/**
* @param int $type
*
* @return array
*/
public function notifyNotificationTitle($type);
}

View File

@@ -0,0 +1,18 @@
<?php
/* For licensing terms, see /license.txt */
/**
* This file contains Hook observer interface for notification title.
*
* @package chamilo.library.hook
*/
/**
* Interface HookNotificationTitleObserverInterface.
*/
interface HookNotificationTitleObserverInterface extends HookObserverInterface
{
/**
* @return array
*/
public function hookNotificationTitle(HookNotificationTitleEventInterface $hook);
}

View File

@@ -0,0 +1,8 @@
<?php
/* For licensing terms, see /license.txt */
interface HookPortfolioCommentEditedEventInterface extends HookEventInterface
{
public function notifyCommentEdited();
}

View File

@@ -0,0 +1,8 @@
<?php
/* For licensing terms, see /license.txt */
interface HookPortfolioCommentEditedObserverInterface extends HookObserverInterface
{
public function hookCommentEdited(HookPortfolioCommentEditedEventInterface $hookEvent);
}

View File

@@ -0,0 +1,8 @@
<?php
/* For licensing terms, see /license.txt */
interface HookPortfolioCommentScoredEventInterface extends HookEventInterface
{
public function notifyCommentScored();
}

View File

@@ -0,0 +1,8 @@
<?php
/* For licensing terms, see /license.txt */
interface HookPortfolioCommentScoredObserverInterface extends HookObserverInterface
{
public function hookCommentScored(HookPortfolioCommentScoredEventInterface $hookEvent);
}

View File

@@ -0,0 +1,8 @@
<?php
/* For licensing terms, see /license.txt */
interface HookPortfolioDownloadedEventInterface extends HookEventInterface
{
public function notifyPortfolioDownloaded();
}

View File

@@ -0,0 +1,8 @@
<?php
/* For licensing terms, see /license.txt */
interface HookPortfolioDownloadedObserverInterface extends HookObserverInterface
{
public function hookPortfolioDownloaded(HookPortfolioDownloadedEventInterface $hookEvent);
}

View File

@@ -0,0 +1,14 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Interface HookPortfolioItemAddedEventInterface.
*/
interface HookPortfolioItemAddedEventInterface extends HookEventInterface
{
/**
* @return void
*/
public function notifyItemAdded();
}

View File

@@ -0,0 +1,16 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Interface HookPortfolioItemAddedObserverInterface.
*/
interface HookPortfolioItemAddedObserverInterface extends HookObserverInterface
{
/**
* @param \HookPortfolioItemAddedEventInterface $hookEvent
*
* @return mixed
*/
public function hookItemAdded(HookPortfolioItemAddedEventInterface $hookEvent);
}

View File

@@ -0,0 +1,14 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Interface HookPortfolioItemCommentedEventInterface.
*/
interface HookPortfolioItemCommentedEventInterface extends HookEventInterface
{
/**
* @return void
*/
public function notifyItemCommented();
}

View File

@@ -0,0 +1,16 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Interface HookPortfolioItemCommentedObserverInterface.
*/
interface HookPortfolioItemCommentedObserverInterface extends HookObserverInterface
{
/**
* @param \HookPortfolioItemCommentedEventInterface $hookEvent
*
* @return mixed
*/
public function hookItemCommented(HookPortfolioItemCommentedEventInterface $hookEvent);
}

View File

@@ -0,0 +1,8 @@
<?php
/* For licensing terms, see /license.txt */
interface HookPortfolioItemDeletedEventInterface extends HookEventInterface
{
public function notifyItemDeleted();
}

View File

@@ -0,0 +1,8 @@
<?php
/* For licensing terms, see /license.txt */
interface HookPortfolioItemDeletedHookObserverInterface extends HookObserverInterface
{
public function hookItemDeleted(HookPortfolioItemDeletedEventInterface $hookEvent);
}

View File

@@ -0,0 +1,8 @@
<?php
/* For licensing terms, see /license.txt */
interface HookPortfolioItemEditedEventInterface extends HookEventInterface
{
public function notifyItemEdited();
}

View File

@@ -0,0 +1,8 @@
<?php
/* For licensing terms, see /license.txt */
interface HookPortfolioItemEditedObserverInterface extends HookObserverInterface
{
public function hookItemEdited(HookPortfolioItemEditedEventInterface $hookEvent);
}

View File

@@ -0,0 +1,8 @@
<?php
/* For licensing terms, see /license.txt */
interface HookPortfolioItemHighlightedEventInterface extends HookEventInterface
{
public function notifyItemHighlighted();
}

View File

@@ -0,0 +1,8 @@
<?php
/* For licensing terms, see /license.txt */
interface HookPortfolioItemHighlightedObserverInterface extends HookObserverInterface
{
public function hookItemHighlighted(HookPortfolioItemHighlightedEventInterface $hookEvent);
}

View File

@@ -0,0 +1,8 @@
<?php
/* For licensing terms, see /license.txt */
interface HookPortfolioItemScoredEventInterface extends HookEventInterface
{
public function notifyItemScored();
}

View File

@@ -0,0 +1,8 @@
<?php
/* For licensing terms, see /license.txt */
interface HookPortfolioItemScoredObserverInterface extends HookObserverInterface
{
public function hookItemScored(HookPortfolioItemScoredEventInterface $hookEvent);
}

View File

@@ -0,0 +1,8 @@
<?php
/* For licensing terms, see /license.txt */
interface HookPortfolioItemViewedEventInterface extends HookEventInterface
{
public function notifyItemViewed(): void;
}

View File

@@ -0,0 +1,8 @@
<?php
/* For licensing terms, see /license.txt */
interface HookPortfolioItemViewedObserverInterface extends HookObserverInterface
{
public function hookItemViewed(HookPortfolioItemViewedEventInterface $hookEvent);
}

View File

@@ -0,0 +1,11 @@
<?php
/* For licensing terms, see /license.txt */
interface HookPortfolioItemVisibilityEventInterface extends HookEventInterface
{
/**
* @return void
*/
public function notifyItemVisibility();
}

View File

@@ -0,0 +1,11 @@
<?php
/* For licensing terms, see /license.txt */
interface HookPortfolioItemVisibilityObserverInterface extends HookObserverInterface
{
/**
* @return void
*/
public function hookItemVisibility(HookPortfolioItemVisibilityEventInterface $event);
}

View File

@@ -0,0 +1,13 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Interface HookQuizEndEventInterface.
*/
interface HookQuizEndEventInterface extends HookEventInterface
{
/**
* @return void
*/
public function notifyQuizEnd();
}

View File

@@ -0,0 +1,15 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Interface HookQuizEndObserverInterface.
*/
interface HookQuizEndObserverInterface
{
/**
* @param \HookQuizEndEventInterface $hookEvent
*
* @return mixed
*/
public function hookQuizEnd(HookQuizEndEventInterface $hookEvent);
}

View File

@@ -0,0 +1,13 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Interface HookQuizQuestionAnsweredEventInterface.
*/
interface HookQuizQuestionAnsweredEventInterface extends HookEventInterface
{
/**
* @return mixed
*/
public function notifyQuizQuestionAnswered();
}

View File

@@ -0,0 +1,15 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Interface HookQuizQuestionAnsweredObserverInterface.
*/
interface HookQuizQuestionAnsweredObserverInterface extends HookObserverInterface
{
/**
* @param \HookQuizQuestionAnsweredEventInterface $event
*
* @return mixed
*/
public function hookQuizQuestionAnswered(HookQuizQuestionAnsweredEventInterface $event);
}

View File

@@ -0,0 +1,23 @@
<?php
/* For licensing terms, see /license.txt */
/**
* This file contains all Hook interfaces and their relation.
* They are used for Hook classes.
*
* @package chamilo.library.hook
*/
/**
* Interface HookResubscribeEventInterface.
*/
interface HookResubscribeEventInterface extends HookEventInterface
{
/**
* Update all the observers.
*
* @param int $type
*
* @return int
*/
public function notifyResubscribe($type);
}

View File

@@ -0,0 +1,19 @@
<?php
/* For licensing terms, see /license.txt */
/**
* This file contains all Hook interfaces and their relation.
* They are used for Hook classes.
*
* @package chamilo.library.hook
*/
/**
* Interface ResubscribeHookInterface.
*/
interface HookResubscribeObserverInterface extends HookObserverInterface
{
/**
* @return int
*/
public function hookResubscribe(HookResubscribeEventInterface $hook);
}

View File

@@ -0,0 +1,23 @@
<?php
/* For licensing terms, see /license.txt */
/**
* This file contains all Hook interfaces and their relation.
* They are used for Hook classes.
*
* @package chamilo.library.hook
*/
/**
* Interface HookSkypeEventInterface.
*/
interface HookSkypeEventInterface extends HookEventInterface
{
/**
* Update all the observers.
*
* @param int $type
*
* @return int
*/
public function notifySkype($type);
}

View File

@@ -0,0 +1,21 @@
<?php
/* For licensing terms, see /license.txt */
/**
* This file contains all Hook interfaces and their relation.
* They are used for Hook classes.
*
* @package chamilo.library.hook
*/
/**
* Interface SkypeHookInterface.
*/
interface HookSkypeObserverInterface extends HookObserverInterface
{
/**
* @param HookSkypeObserverInterface $hook
*
* @return int
*/
public function hookEventSkype(HookSkypeEventInterface $hook);
}

View File

@@ -0,0 +1,23 @@
<?php
/* For licensing terms, see /license.txt */
/**
* This file contains all Hook interfaces and their relation.
* They are used for Hook classes.
*
* @package chamilo.library.hook
*/
/**
* Interface HookUpdateUserEventInterface.
*/
interface HookUpdateUserEventInterface extends HookEventInterface
{
/**
* Update all the observers.
*
* @param int $type
*
* @return int
*/
public function notifyUpdateUser($type);
}

View File

@@ -0,0 +1,19 @@
<?php
/* For licensing terms, see /license.txt */
/**
* This file contains all Hook interfaces and their relation.
* They are used for Hook classes.
*
* @package chamilo.library.hook
*/
/**
* Interface UpdateUserHookInterface.
*/
interface HookUpdateUserObserverInterface extends HookObserverInterface
{
/**
* @return int
*/
public function hookUpdateUser(HookUpdateUserEventInterface $hook);
}

View File

@@ -0,0 +1,21 @@
<?php
/* For licensing terms, see /license.txt */
/**
* This file contains all Hook interfaces and their relation.
* They are used for Hook classes.
*
* @package chamilo.library.hook
*/
/**
* Interface HookWSRegistrationEventInterface.
*/
interface HookWSRegistrationEventInterface extends HookEventInterface
{
/**
* @param int $type
*
* @return int
*/
public function notifyWSRegistration($type);
}

View File

@@ -0,0 +1,19 @@
<?php
/* For licensing terms, see /license.txt */
/**
* This file contains all Hook interfaces and their relation.
* They are used for Hook classes.
*
* @package chamilo.library.hook
*/
/**
* Interface HookWSRegistrationObserverInterface.
*/
interface HookWSRegistrationObserverInterface extends HookObserverInterface
{
/**
* @return int
*/
public function hookWSRegistration(HookWSRegistrationEventInterface $hook);
}

Some files were not shown because too many files have changed in this diff Show More