Added general list functions
This commit is contained in:
parent
1736128dbf
commit
85bcb64e37
@ -35,6 +35,29 @@ require_once($CFG->libdir . "/externallib.php");
|
|||||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||||
*/
|
*/
|
||||||
class local_webhooks_external extends external_api {
|
class local_webhooks_external extends external_api {
|
||||||
|
/**
|
||||||
|
* Formation of the final list.
|
||||||
|
*
|
||||||
|
* @param array $listrecords
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
private static function formation_list($listrecords) {
|
||||||
|
$result = array();
|
||||||
|
|
||||||
|
foreach ($listrecords as $index => $record) {
|
||||||
|
$result[$index]["events"] = self::formation_events($record->events);
|
||||||
|
$result[$index]["enable"] = $record->enable;
|
||||||
|
$result[$index]["id"] = $record->id;
|
||||||
|
$result[$index]["other"] = $record->other;
|
||||||
|
$result[$index]["title"] = $record->title;
|
||||||
|
$result[$index]["token"] = $record->token;
|
||||||
|
$result[$index]["type"] = $record->type;
|
||||||
|
$result[$index]["url"] = $record->url;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Formation of the final list of events.
|
* Formation of the final list of events.
|
||||||
*
|
*
|
||||||
@ -126,16 +149,7 @@ class local_webhooks_external extends external_api {
|
|||||||
|
|
||||||
$result = array();
|
$result = array();
|
||||||
if ($listrecords = local_webhooks_search_services_by_event($parameters["eventname"], $parameters["active"])) {
|
if ($listrecords = local_webhooks_search_services_by_event($parameters["eventname"], $parameters["active"])) {
|
||||||
foreach ($listrecords as $index => $record) {
|
$result = self::formation_list($listrecords);
|
||||||
$result[$index]["events"] = self::formation_events($record->events);
|
|
||||||
$result[$index]["enable"] = $record->enable;
|
|
||||||
$result[$index]["id"] = $record->id;
|
|
||||||
$result[$index]["other"] = $record->other;
|
|
||||||
$result[$index]["title"] = $record->title;
|
|
||||||
$result[$index]["token"] = $record->token;
|
|
||||||
$result[$index]["type"] = $record->type;
|
|
||||||
$result[$index]["url"] = $record->url;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
@ -267,16 +281,7 @@ class local_webhooks_external extends external_api {
|
|||||||
|
|
||||||
$result = array();
|
$result = array();
|
||||||
if ($listrecords = local_webhooks_get_list_records()) {
|
if ($listrecords = local_webhooks_get_list_records()) {
|
||||||
foreach ($listrecords as $index => $record) {
|
$result = self::formation_list($listrecords);
|
||||||
$result[$index]["events"] = self::formation_events($record->events);
|
|
||||||
$result[$index]["enable"] = $record->enable;
|
|
||||||
$result[$index]["id"] = $record->id;
|
|
||||||
$result[$index]["other"] = $record->other;
|
|
||||||
$result[$index]["title"] = $record->title;
|
|
||||||
$result[$index]["token"] = $record->token;
|
|
||||||
$result[$index]["type"] = $record->type;
|
|
||||||
$result[$index]["url"] = $record->url;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user