+
+ // Return value
+ return $ret;
+}
+
+// Activate given extension
+function ACTIVATE_EXTENSION ($ext_name) {
+ // Activate the extension
+ SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_extensions` SET ext_active='Y' WHERE ext_name='%s' LIMIT 1",
+ array($ext_name), __FILE__, __LINE__);
+
+ // Extension has been activated?
+ if (SQL_AFFECTEDROWS() == 1) {
+ // Then run all queries
+ EXTENSION_RUN_SQLS(GET_EXT_ID($ext_name), "activate");
+ } // END - if
+}
+
+// Deactivate given extension
+function DEACTIVATE_EXTENSION($ext_name) {
+ // Activate the extension
+ SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_extensions` SET ext_active='N' WHERE ext_name='%s' LIMIT 1",
+ array($ext_name), __FILE__, __LINE__);
+
+ // Extension has been activated?
+ if (SQL_AFFECTEDROWS() == 1) {
+ // Then run all queries
+ EXTENSION_RUN_SQLS(GET_EXT_ID($ext_name), "deactivate");
+
+ // Create new task
+ CREATE_EXTENSION_DEACTIVATION_TASK($ext_name);
+
+ // Notify the admin
+ SEND_ADMIN_NOTIFICATION(
+ getMessage('ADMIN_SUBJECT_EXTENSION_DEACTIVATED'),
+ "admin_ext_deactivated",
+ array('ext_name' => $ext_name)
+ );
+ } // END - if
+}
+
+// Checks wether the extension is older than given
+function EXT_VERSION_IS_OLDER ($ext_name, $ext_ver) {
+ // Get current extension version
+ $currVersion = GET_EXT_VERSION($ext_name);
+
+ // Remove all dots from both versions
+ $currVersion = str_replace(".", "", $currVersion);
+ $ext_ver = str_replace(".", "", $ext_ver);
+
+ // Now compare both and return the result
+ return ($currVersion < $ext_ver);
+}
+
+// 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,
+ SQL_ESCAPE($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, getMessage('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,
+ SQL_ESCAPE(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) {
+ // 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($GLOBALS['cache_array']['modules']['has_menu'][$mod])) {
+ // Check module cache and count hit
+ $ret = ($GLOBALS['cache_array']['modules']['has_menu'][$mod] == "Y");
+ incrementConfigEntry('cache_hits');
+ } elseif (isset($GLOBALS['cache_array']['extensions']['ext_menu'][$mod])) {
+ // Check cache and count hit
+ $ret = ($GLOBALS['cache_array']['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... ;-)
+ $GLOBALS['cache_array']['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);