Checking arguments is added
Signed-off-by: Valentin Popov <info@valentineus.link>
This commit is contained in:
parent
092d0436e8
commit
975c6f8d20
17
lib.php
17
lib.php
@ -38,6 +38,11 @@ require_once(__DIR__ . "/locallib.php");
|
|||||||
function local_webhooks_change_status($serviceid) {
|
function local_webhooks_change_status($serviceid) {
|
||||||
global $DB;
|
global $DB;
|
||||||
|
|
||||||
|
/* Checks arguments */
|
||||||
|
if (empty($serviceid)) {
|
||||||
|
print_error("missingparam", "error", null, "serviceid");
|
||||||
|
}
|
||||||
|
|
||||||
/* Gets the current status */
|
/* Gets the current status */
|
||||||
$status = $DB->get_field(LOCAL_WEBHOOKS_TABLE_SERVICES, "status", array("id" => $serviceid), IGNORE_MISSING);
|
$status = $DB->get_field(LOCAL_WEBHOOKS_TABLE_SERVICES, "status", array("id" => $serviceid), IGNORE_MISSING);
|
||||||
|
|
||||||
@ -56,11 +61,16 @@ function local_webhooks_change_status($serviceid) {
|
|||||||
* @param string $eventname Event name
|
* @param string $eventname Event name
|
||||||
* @param number $limitfrom Start position
|
* @param number $limitfrom Start position
|
||||||
* @param number $limitnum End position
|
* @param number $limitnum End position
|
||||||
* @return array
|
* @return array Search results
|
||||||
*/
|
*/
|
||||||
function local_webhooks_search_record($eventname, $limitfrom = 0, $limitnum = 0) {
|
function local_webhooks_search_record($eventname, $limitfrom = 0, $limitnum = 0) {
|
||||||
global $DB;
|
global $DB;
|
||||||
|
|
||||||
|
/* Checks arguments */
|
||||||
|
if (empty($eventname)) {
|
||||||
|
print_error("missingparam", "error", null, "eventname");
|
||||||
|
}
|
||||||
|
|
||||||
/* Checks for the presence of a cache */
|
/* Checks for the presence of a cache */
|
||||||
$namecache = "${eventname}_${limitfrom}_${limitnum}";
|
$namecache = "${eventname}_${limitfrom}_${limitnum}";
|
||||||
if (is_array($records = local_webhooks_cache_get($namecache))) {
|
if (is_array($records = local_webhooks_cache_get($namecache))) {
|
||||||
@ -95,6 +105,11 @@ function local_webhooks_search_record($eventname, $limitfrom = 0, $limitnum = 0)
|
|||||||
function local_webhooks_get_record($serviceid) {
|
function local_webhooks_get_record($serviceid) {
|
||||||
global $DB;
|
global $DB;
|
||||||
|
|
||||||
|
/* Checks arguments */
|
||||||
|
if (empty($serviceid)) {
|
||||||
|
print_error("missingparam", "error", null, "serviceid");
|
||||||
|
}
|
||||||
|
|
||||||
/* Loads service data */
|
/* Loads service data */
|
||||||
$record = $DB->get_record(LOCAL_WEBHOOKS_TABLE_SERVICES, array("id" => $serviceid), "*", IGNORE_MISSING);
|
$record = $DB->get_record(LOCAL_WEBHOOKS_TABLE_SERVICES, array("id" => $serviceid), "*", IGNORE_MISSING);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user