+// Creates a new task for updated extension
+function CREATE_EXTENSION_UPDATE_TASK ($admin_id, $ext_name, $ext_ver, $notes) {
+ // Create subject line
+ $subject = "[UPDATE-".$ext_name."-".$ext_ver.":] {!ADMIN_UPDATE_EXT_SUBJ!}";
+
+ // Is the extension there?
+ if (GET_EXT_VERSION($ext_name) != "") {
+ // Check if task is not there
+ if (DETERMINE_TASK_ID_BY_SUBJECT($subject) == 0) {
+ // Task not created so it's a brand-new extension which we need to register and create a task for!
+ 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
+ } // END - if
+}
+
+// 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?
+ if ((DETERMINE_TASK_ID_BY_SUBJECT($subject) == 0) && (GET_EXT_VERSION($ext) == "")) {
+ // Template file
+ $tpl = sprintf("%stemplates/%s/html/ext/ext_%s.tpl",
+ constant('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!
+ 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,
+ addslashes($msg),
+ ), __FILE__, __LINE__, true, false
+ );
+ } // END - if
+}
+
+// Creates a task for automatically deactivated (deprecated) extension
+function CREATE_EXTENSION_DEACTIVATION_TASK ($ext) {
+ // Create subject line
+ $subject = sprintf("[%s:] %s", $ext, TASK_SUBJ_EXTENSION_DEACTIVATED);
+
+ // Not installed and do we have created a task for the admin?
+ if ((DETERMINE_TASK_ID_BY_SUBJECT($subject) == 0) && (GET_EXT_VERSION($ext) != "")) {
+ // Task not created so add it
+ SQL_QUERY_ESC("INSERT INTO `{!_MYSQL_PREFIX!}_task_system` (assigned_admin, userid, status, task_type, subject, text, task_created)
+VALUES (0,0,'NEW','EXTENSION_DEACTIVATION','%s','%s',UNIX_TIMESTAMP())",
+ array(
+ $subject,
+ addslashes(LOAD_TEMPLATE("task_ext_deactivated", true, $ext)),
+ ), __FILE__, __LINE__, true, false
+ );
+ } // END - if
+}
+
+// Checks if the module has a menu
+function MODULE_HAS_MENU ($mod, $forceDb = false) {
+ global $cacheArray;
+
+ // All is false by default
+ $ret = false;
+ //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):mod={$mod},cache=".GET_EXT_VERSION("cache")."<br />\n";
+ if (GET_EXT_VERSION("cache") >= "0.1.2") {
+ // Cache version is okay, so let's check the cache!
+ if (isset($cacheArray['modules']['has_menu'][$mod])) {
+ // Check module cache and count hit
+ $ret = ($cacheArray['modules']['has_menu'][$mod] == "Y");
+ incrementConfigEntry('cache_hits');
+ } elseif (isset($cacheArray['extensions']['ext_menu'][$mod])) {
+ // Check cache and count hit
+ $ret = ($cacheArray['extensions']['ext_menu'][$mod] == "Y");
+ incrementConfigEntry('cache_hits');
+ } elseif ((IS_ADMIN()) && ($mod == "admin")) {
+ // Admin module has always a menu!
+ $ret = true;
+ }
+ } elseif ((GET_EXT_VERSION("sql_patches") >= "0.3.6") && ((!EXT_IS_ACTIVE("cache")) || ($forceDb === true))) {
+ // Check database for entry
+ $result = SQL_QUERY_ESC("SELECT has_menu FROM `{!_MYSQL_PREFIX!}_mod_reg` WHERE module='%s' LIMIT 1",
+ array($mod), __FILE__, __LINE__);
+
+ // Entry found?
+ if (SQL_NUMROWS($result) == 1) {
+ // Load "has_menu" column
+ list($has_menu) = SQL_FETCHROW($result);
+
+ // Fake cache... ;-)
+ $cacheArray['extensions']['ext_menu'][$mod] = $has_menu;
+
+ // Does it have a menu?
+ $ret = ($has_menu == "Y");
+ } // END - if
+
+ // Free memory
+ SQL_FREERESULT($result);
+ } elseif (GET_EXT_VERSION("sql_patches") == "") {
+ // No sql_patches installed, so maybe in admin area?
+ $ret = ((IS_ADMIN()) && ($mod == "admin")); // Then there is a menu!
+ }
+
+ // Return status
+ //* DEBUG: */ var_dump($ret);
+ return $ret;
+}
+
+// Determines the task id for given extension
+function DETERMINE_EXTENSION_TASK_ID ($ext_name) {
+ // Default is not found
+ $task_id = 0;
+
+ // Search for extension task's id
+ $result = SQL_QUERY_ESC("SELECT id FROM `{!_MYSQL_PREFIX!}_task_system` WHERE task_type='EXTENSION' AND subject='[%s:]' LIMIT 1",
+ array($ext_name), __FILE__, __LINE__);
+
+ // Entry found?
+ if (SQL_NUMROWS($result) == 1) {
+ // Task found so load task's ID and register extension...
+ list($task_id) = SQL_FETCHROW($result);
+ } // END - if
+
+ // Free result
+ SQL_FREERESULT($result);
+
+ // Return it
+ return $task_id;
+}
+
+// Determines the task id for given subject
+function DETERMINE_TASK_ID_BY_SUBJECT ($subject) {
+ // Default is not found
+ $task_id = 0;
+
+ // Search for task id
+ $result = SQL_QUERY_ESC("SELECT id FROM `{!_MYSQL_PREFIX!}_task_system` WHERE subject LIKE '%s%%' LIMIT 1",
+ array($subject), __FILE__, __LINE__);
+
+ // Entry found?
+ if (SQL_NUMROWS($result) == 1) {
+ // Task found so load task's ID and register extension...
+ list($task_id) = SQL_FETCHROW($result);
+ } // END - if
+
+ // Free result
+ SQL_FREERESULT($result);
+
+ // Return it
+ return $task_id;
+}
+
+// Add updates notes for given version
+function ADD_EXTENSION_NOTES ($ver, &$UPDATE_NOTES) {
+ // Init notes/content
+ $out = ""; $content = array();
+
+ // Is do we have verbose output enabled?
+ if ((getConfig('verbose_sql') == "Y") || (!EXT_IS_ACTIVE("sql_patches"))) {
+
+ // Update notes found?
+ if (!empty($UPDATE_NOTES)) {
+ // Update notes found
+ $content = array(
+ 'ver' => $ver,
+ 'notes' => $UPDATE_NOTES
+ );
+ $UPDATE_NOTES = "";
+ } elseif (($ver == "0.0") || ($ver == "0.0.0")) {
+ // Initial release
+ $content = array(
+ 'ver' => $ver,
+ 'notes' => INITIAL_RELEASE
+ );
+ } else {
+ // No update notes found!
+ $content = array(
+ 'ver' => $ver,
+ 'notes' => NO_UPDATE_NOTES
+ );
+ }
+
+ // Load template
+ $out = LOAD_TEMPLATE("admin_ext_notes", true, $content);
+ } // END - if
+
+ // Return the output
+ return $out;
+}
+