- if (EXT_IS_ACTIVE("booking")) {
- // Add record
- ADD_BOOKING_RECORD($subject, $uid, $points, "sub");
- } // END - if
-
- // Update mediadata as well
- if (GET_EXT_VERSION("mediadata") >= "0.0.4") {
- // Update database
- MEDIA_UPDATE_ENTRY(array("total_points"), "sub", $points);
- } // END - if
-}
-
-// Update config entries
-function UPDATE_CONFIG ($entries, $values, $updateMode="") {
- global $CSS;
-
- // Do not update config in CSS mode
- if (($CSS == "1") || ($CSS == -1)) {
- return;
- } // END - if
-
- // Do we have multiple entries?
- if (is_array($entries)) {
- // Walk through all
- $all = "";
- foreach ($entries as $idx => $entry) {
- // Update mode set?
- if (!empty($updateMode)) {
- // Update entry
- $all .= sprintf("%s=%s%s%s,", $entry, $entry, $updateMode, (float)$values[$idx]);
- } else {
- // Check if string or number
- if (($values[$idx] + 0) === $values[$idx]) {
- // Number detected
- $all .= sprintf("%s=%s,", $entry, (float)$values[$idx]);
- } elseif ($values[$idx] == "UNIX_TIMESTAMP()") {
- // Function UNIX_TIMESTAMP() detected
- $all .= sprintf("%s=%s,", $entry, $values[$idx]);
- } else {
- // String detected
- $all .= sprintf("%s='%s',", $entry, SQL_ESCAPE($values[$idx]));
- }
- }
- } // END - foreach
-
- // Remove last comma
- $entries = substr($all, 0, -1);
- } elseif (!empty($updateMode)) {
- // Update mode set
- $entries .= sprintf("=%s%s%s", $entries, $updateMode, (float)$values);
- } else {
- // Regular entry to update
- $entries .= sprintf("='%s'", SQL_ESCAPE($values));
- }
-
- // Run database update
- //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "entries={$entries}");
- SQL_QUERY("UPDATE "._MYSQL_PREFIX."_config SET ".$entries." WHERE config=0 LIMIT 1", __FILE__, __LINE__);
-
- // Get affected rows
- $affectedRows = SQL_AFFECTEDROWS();
- //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):entries={$entries},affectedRows={$affectedRows}<br />\n";
-
- // Rebuild cache
- REBUILD_CACHE("config", "config");
-}
-
-// Creates a new task for updated extension
-function CREATE_EXTENSION_UPDATE_TASK ($admin_id, $subject, $notes) {
- // Check if task is not there
- $result = SQL_QUERY_ESC("SELECT id FROM "._MYSQL_PREFIX."_task_system WHERE subject='%s' LIMIT 1",
- array($subject), __FILE__, __LINE__);
- if (SQL_NUMROWS($result) == 0) {
- // Task not created so it's a brand-new extension which we need to register and create a task for!
- $result = SQL_QUERY_ESC("INSERT INTO "._MYSQL_PREFIX."_task_system (assigned_admin, userid, status, task_type, subject, text, task_created) VALUES ('%s','0','NEW','EXTENSION_UPDATE','%s','%s', UNIX_TIMESTAMP())",
- array($admin_id, $subject, $notes), __FILE__, __LINE__);
- } // END - if
-
- // Free memory
- SQL_FREERESULT($result);
-}
-
-// Creates a new task for newly installed extension
-function CREATE_NEW_EXTENSION_TASK ($admin_id, $subject, $ext) {
- // Not installed and do we have created a task for the admin?
- $result = SQL_QUERY_ESC("SELECT `id` FROM `"._MYSQL_PREFIX."_task_system` WHERE `subject` LIKE '%s%%' LIMIT 1",
- array($subject), __FILE__, __LINE__);
- if ((SQL_NUMROWS($result) == 0) && (GET_EXT_VERSION($ext) == "")) {
- // Template file
- $tpl = sprintf("%stemplates/%s/html/ext/ext_%s.tpl",
- PATH,
- GET_LANGUAGE(),
- $ext
- );
-
- // Load text for task
- if (FILE_READABLE($tpl)) {
- // Load extension's own text template (HTML!)
- $msg = LOAD_TEMPLATE("ext_".$ext, true);
- } else {
- // Load default message
- $msg = LOAD_TEMPLATE("admin_new_ext", "", 0);
- }
-
- // Task not created so it's a brand-new extension which we need to register and create a task for!
- $result_insert = SQL_QUERY_ESC("INSERT INTO "._MYSQL_PREFIX."_task_system (assigned_admin, userid, status, task_type, subject, text, task_created)
-VALUES (%s,0,'NEW','EXTENSION','%s','%s',UNIX_TIMESTAMP())",
- array(
- $admin_id,
- $subject,
- SQL_ESCAPE($msg),
- ), __FILE__, __LINE__, true, false
- );
- } // END - if
-
- // Free memory
- SQL_FREERESULT($result);
-}
-
-// Prepares an SQL statement part for HTML mail and/or holiday depency
-function PREPARE_SQL_HTML_HOLIDAY ($mode) {
- // Exclude no users by default
- $MORE = "";
-
- // HTML mail?
- if ($mode == "html") $MORE = " AND html='Y'";
- if (GET_EXT_VERSION("holiday") >= "0.1.3") {
- // Add something for the holiday extension
- $MORE .= " AND holiday_active='N'";
- } // END - if
-
- // Return result
- return $MORE;