Should not be loadInclude() here, we need to rewrite EXT_LOAD_MODE and EXT_VER here
[mailer.git] / inc / modules / admin / overview-inc.php
index 972644fe83607b26873d8aee761b48762dd98c57..97b4ce5437e8d2326b4b585672bd9fe2e08268d2 100644 (file)
@@ -45,18 +45,20 @@ if ((!defined('__SECURITY')) || (!IS_ADMIN())) {
 function OUTPUT_STANDARD_OVERVIEW (&$result_tasks) {
        // First check for solved and not assigned tasks and assign them to current admin
        SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_task_system` SET `assigned_admin`=%s WHERE assigned_admin < 1 AND status != 'NEW'",
-       array(getCurrentAdminId()), __FILE__, __LINE__);
+               array(getCurrentAdminId()), __FILE__, __LINE__);
 
        // We currently don't want to install an extension so let's find out if we need...
        $EXT_LOAD_MODE = 'register';
        $jobsDone = true;
 
        // Open the extension directory
-       $extensionList = getArrayFromDirectory("inc/extensions/", "ext-", false, false);
+       $extensionList = getArrayFromDirectory('inc/extensions/', 'ext-', false, false);
        foreach ($extensionList as $file) {
+               // Only file name is required... :(
+               $file = basename($file);
+
                // Is this file an extension?
-               if ((substr($file, 0, 4) == "ext-") && (substr($file, -4) == '.php')) {
-                       //* DEBUG: */ echo $file."<br />\n";
+               if ((substr($file, 0, 4) == 'ext-') && (substr($file, -4) == '.php')) {
                        // Possible newly installed extension found so we extract extension's name
                        $ext_name = strtolower(substr($file, 4, -4)); // Keep always extension names on lower case!!!
 
@@ -65,6 +67,7 @@ function OUTPUT_STANDARD_OVERVIEW (&$result_tasks) {
 
                        // Check if extension is installed or not
                        $ext_ver = GET_EXT_VERSION($ext_name);
+                       //* DEBUG: */ OUTPUT_HTML($ext_name."=".$ext_ver."<br />");
 
                        // Is the extension not yet installed?
                        if (empty($ext_ver)) {
@@ -78,10 +81,10 @@ function OUTPUT_STANDARD_OVERVIEW (&$result_tasks) {
                                } // END - if
                        } else {
                                // Test-drive extension in update mode
-                               require(sprintf("%sinc/extensions/ext-%s.php", constant('PATH'), $ext_name));
+                               require(sprintf("%sinc/extensions/ext-%s.php", getConfig('PATH'), $ext_name));
 
                                // Update extension if extension is installed and outdated
-                               //* DEBUG: */ print "ext={$ext_name},ver={EXT_GET_VERSION()}/".GET_EXT_VERSION($ext_name)."<br />\n";
+                               //* DEBUG: */ OUTPUT_HTML("ext={$ext_name},ver={EXT_GET_VERSION()}/".GET_EXT_VERSION($ext_name)."<br />");
                                if (EXT_GET_VERSION() > $ext_ver) {
                                        // Update the extension
                                        EXTENSION_UPDATE($ext_name, $ext_ver);
@@ -158,7 +161,7 @@ LIMIT 1",
                                        // Entry found?
                                        if (SQL_NUMROWS($result_user) == 1) {
                                                list($gender, $sname, $fname, $email) = SQL_FETCHROW($result_user);
-                                               $add = "<li>{--ADMIN_MEMBER_UID--}: <strong>".generateUserProfileLink($uid)." (<a href=\"".generateMemberEmailLink($email, "user_data")."\">".translateGender($gender)." ".$sname." ".$fname."</a>)</strong></li>";
+                                               $add = "<li>{--ADMIN_MEMBER_UID--}: <strong>".generateUserProfileLink($uid, 'user_data')." (<a href=\"".generateEmailLink($email, 'user_data')."\">".translateGender($gender)." ".$sname." ".$fname."</a>)</strong></li>";
                                        } else {
                                                // Invalid userid, so log and zero it
                                                DEBUG_LOG(__FUNCTION__, __LINE__, 'Invalid userid=' . $uid . '-> Not found!');
@@ -187,6 +190,9 @@ LIMIT 1",
 
                                        // Update task or extension task?
                                        if ($type == 'EXTENSION') {
+                                               // @TODO Should we init sql_notes here or inside REGISTER_EXTENSION()?
+                                               EXT_INIT_NOTES();
+
                                                // Load SQL commands for registering
                                                REGISTER_EXTENSION($ext_name, $id, true);
 
@@ -350,20 +356,20 @@ LIMIT 1",
 
                                                        case 'NL_UNSUBSCRIBE': // Newsletter unsubscriptions
                                                                $result = SQL_QUERY_ESC("SELECT nl_timespan FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s LIMIT 1",
-                                                               array(bigintval($uid)), __FILE__, __LINE__);
+                                                                       array(bigintval($uid)), __FILE__, __LINE__);
                                                                list($span) = SQL_FETCHROW($result);
                                                                SQL_FREERESULT($result);
 
                                                                if ($span > 0) {
                                                                        // Undone unscubscribe request
                                                                        $content = array(
-                                                       'uid' => $uid,
-                                                       'id'  => $tid
+                                                                               'uid' => $uid,
+                                                                               'id'  => $tid
                                                                        );
                                                                        $OUT .= LOAD_TEMPLATE('admin_newsletter_tsk', true, $content);
                                                                } else {
                                                                        // Already unsubscribed
-                                                                       $OUT .= "<div class=\"admin_failed medium\">".ADMIN_NL_UNSUBSCRIBE_ALREADY."</div>\n";
+                                                                       $OUT .= "<div class=\"admin_failed medium\">{--ADMIN_NL_UNSUBSCRIBE_ALREADY--}</div>\n";
                                                                }
                                                                break;
 
@@ -419,8 +425,8 @@ LIMIT 1",
                        $content['assigned_admin'] = generateAdminLink($content['assigned_admin']);
 
                        // Generate infos
-                       switch ($content['task_type'])
-                       {
+                       // @TODO Try to move this in includes
+                       switch ($content['task_type']) {
                                case 'EXTENSION':
                                case 'EXTENSION_UPDATE':
                                        $content['infos'] = substr($content['subject'], 1, strpos($content['subject'], ':') - 1);