aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorValentin Popov <info@valentineus.link>2017-11-30 11:54:03 +0300
committerValentin Popov <info@valentineus.link>2017-11-30 11:54:03 +0300
commit12356f9fcc09f19891dbaed2f3d011186c35a436 (patch)
treeadba5827e670ca23d5bbc1bec1ac2f7d480560dc
parent9b223669df8b17669013d0e94c4278bc3a1666e6 (diff)
downloadtool_managertokens-12356f9fcc09f19891dbaed2f3d011186c35a436.tar.xz
tool_managertokens-12356f9fcc09f19891dbaed2f3d011186c35a436.zip
Edit in functions
-rw-r--r--lib.php82
1 files changed, 41 insertions, 41 deletions
diff --git a/lib.php b/lib.php
index 88ac107..b63a2b4 100644
--- a/lib.php
+++ b/lib.php
@@ -51,51 +51,51 @@ function tool_managertokens_activate_token($token = "") {
/**
* Creates an entry in the database.
*
- * @param array $options
+ * @param object $options
* @return number
*/
-function tool_managertokens_create_record($options = array()) {
+function tool_managertokens_create_record($options) {
global $DB;
- if (!isset($options["targetid"])) {
+ if (!isset($options->targetid)) {
print_error("missingparam", "error", "", "targetid");
}
- if (!isset($options["targettype"])) {
+ if (!isset($options->targettype)) {
print_error("missingparam", "error", "", "targettype");
}
- if (!isset($options["token"])) {
+ if (!isset($options->token)) {
print_error("missingparam", "error", "", "token");
}
- if ($DB->record_exists("tool_managertokens_tokens", array("token" => $options["token"]))) {
+ if ($DB->record_exists("tool_managertokens_tokens", array("token" => $options->token))) {
print_error("duplicatefieldname", "error", "", "token");
}
- $token = array();
- $token["enabled"] = false;
- $token["timecreated"] = time();
- $token["targetid"] = intval($options["targetid"]);
- $token["targettype"] = intval($options["targettype"]);
- $token["timemodified"] = $token["timecreated"];
- $token["token"] = strval($options["token"]);
+ $token = new stdClass();
+ $token->enabled = false;
+ $token->timecreated = time();
+ $token->targetid = intval($options->targetid);
+ $token->targettype = intval($options->targettype);
+ $token->timemodified = $token->timecreated;
+ $token->token = strval($options->token);
- if (isset($options["enabled"])) {
- $token["enabled"] = boolval($options["enabled"]);
+ if (isset($options->enabled)) {
+ $token->enabled = boolval($options->enabled);
}
- if (isset($options["extendedaction"]) && isset($options["extendedoptions"])) {
- $token["extendedaction"] = strval($options["extendedaction"]);
- $token["extendedoptions"] = strval($options["extendedoptions"]);
+ if (isset($options->extendedaction) && isset($options->extendedoptions)) {
+ $token->extendedaction = strval($options->extendedaction);
+ $token->extendedoptions = strval($options->extendedoptions);
}
- if (isset($options["limited"])) {
- $token["limited"] = intval($options["limited"]);
+ if (isset($options->limited)) {
+ $token->limited = intval($options->limited);
}
- if (isset($options["timelimited"])) {
- $token["timelimited"] = intval($options["timelimited"]);
+ if (isset($options->timelimited)) {
+ $token->timelimited = intval($options->timelimited);
}
$recordid = $DB->insert_record("tool_managertokens_tokens", $token, true, false);
@@ -156,48 +156,48 @@ function tool_managertokens_get_list($limitfrom = 0, $limitnum = 0) {
/**
* Updates the entry in the database.
*
- * @param array $options
+ * @param object $options
* @return boolean
*/
-function tool_managertokens_update_record($options = array()) {
+function tool_managertokens_update_record($options) {
global $DB;
$result = false;
- if (!isset($options["id"])) {
+ if (!isset($options->id)) {
print_error("missingparam", "error", "", "id");
}
- if ($token = $DB->get_record("tool_managertokens_tokens", array("id" => $options["id"]), "*", IGNORE_MISSING)) {
+ if ($token = $DB->get_record("tool_managertokens_tokens", array("id" => $options->id), "*", IGNORE_MISSING)) {
$token->timemodified = time();
- if (isset($options["enabled"])) {
- $token->enabled = boolval($options["enabled"]);
+ if (isset($options->enabled)) {
+ $token->enabled = boolval($options->enabled);
}
- if (isset($options["extendedaction"]) && isset($options["extendedoptions"])) {
- $token->extendedaction = strval($options["extendedaction"]);
- $token->extendedoptions = strval($options["extendedoptions"]);
+ if (isset($options->extendedaction) && isset($options->extendedoptions)) {
+ $token->extendedaction = strval($options->extendedaction);
+ $token->extendedoptions = strval($options->extendedoptions);
}
- if (isset($options["limited"])) {
- $token->limited = intval($options["limited"]);
+ if (isset($options->limited)) {
+ $token->limited = intval($options->limited);
}
- if (isset($options["targetid"])) {
- $token->targetid = intval($options["targetid"]);
+ if (isset($options->targetid)) {
+ $token->targetid = intval($options->targetid);
}
- if (isset($options["targettype"])) {
- $token->targettype = strval($options["targettype"]);
+ if (isset($options->targettype)) {
+ $token->targettype = strval($options->targettype);
}
- if (isset($options["token"])) {
- $token->token = strval($options["token"]);
+ if (isset($options->token)) {
+ $token->token = strval($options->token);
}
- if (isset($options["timelimited"])) {
- $token->timelimited = intval($options["timelimited"]);
+ if (isset($options->timelimited)) {
+ $token->timelimited = intval($options->timelimited);
}
$result = $DB->update_record("tool_managertokens_tokens", $token, false);