Old config.php is now automatically updated to new config-local.php format, several...
[mailer.git] / inc / modules / admin / overview-inc.php
index 14944df068121621c3e0ebbf08f50ee901f19518..36cf9c6f3fe6ffc09814ff0bbac6d2fb9946aa45 100644 (file)
@@ -45,7 +45,7 @@ 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';
@@ -103,7 +103,7 @@ function OUTPUT_STANDARD_OVERVIEW(&$result_tasks) {
 FROM `{!_MYSQL_PREFIX!}_task_system`
 WHERE `assigned_admin`=%s OR (`assigned_admin`=0 AND `status`='NEW')
 ORDER BY `userid` DESC, `task_type` DESC, `subject` ASC, `task_created` DESC",
-               array(getCurrentAdminId()), __FILE__, __LINE__);
+       array(getCurrentAdminId()), __FILE__, __LINE__);
 
        if (SQL_NUMROWS($result_tasks) > 0) {
                // New jobs found!
@@ -127,7 +127,7 @@ function OUTPUT_SELECTED_TASKS ($POST, $result_tasks) {
 FROM `{!_MYSQL_PREFIX!}_task_system`
 WHERE `id`=%s AND (`assigned_admin`=%s OR (`assigned_admin`=0 AND `status`='NEW'))
 LIMIT 1",
-                               array(bigintval($id), getCurrentAdminId()), __FILE__, __LINE__);
+                       array(bigintval($id), getCurrentAdminId()), __FILE__, __LINE__);
                        if (SQL_NUMROWS($result_task) == 1) {
                                // Task is valid...
                                list($tid, $uid, $type, $subj, $text, $created, $status, $aid) = SQL_FETCHROW($result_task);
@@ -136,7 +136,7 @@ LIMIT 1",
                                if ($aid == '0') {
                                        // Assgin current admin to unassgigned task
                                        SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_task_system` SET `assigned_admin`=%s WHERE `id`=%s LIMIT 1",
-                                               array(getCurrentAdminId(), bigintval($tid)), __FILE__, __LINE__);
+                                       array(getCurrentAdminId(), bigintval($tid)), __FILE__, __LINE__);
                                } // END - if
 
                                $add = '';
@@ -149,7 +149,7 @@ LIMIT 1",
 
                                if ($uid > 0) {
                                        $result_user = SQL_QUERY_ESC("SELECT gender, surname, family, email FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s LIMIT 1",
-                                        array(bigintval($uid)), __FILE__, __LINE__);
+                                       array(bigintval($uid)), __FILE__, __LINE__);
                                        if (SQL_NUMROWS($result_user) == 1) {
                                                list($gender, $sname, $fname, $email) = SQL_FETCHROW($result_user);
                                                SQL_FREERESULT($result_user);
@@ -230,129 +230,129 @@ LIMIT 1",
                                // @TODO Rewrite this to something with include files
                                switch ($type)
                                {
-                               case 'EXTENSION': // Install new extensions
-                                       $ext_name = substr($subj, 1, strpos($subj, ':') - 1);
-                                       $result_lines = SQL_QUERY_ESC("SELECT `id` FROM `{!_MYSQL_PREFIX!}_extensions` WHERE `ext_name`='%s' LIMIT 1",
+                                       case 'EXTENSION': // Install new extensions
+                                               $ext_name = substr($subj, 1, strpos($subj, ':') - 1);
+                                               $result_lines = SQL_QUERY_ESC("SELECT `id` FROM `{!_MYSQL_PREFIX!}_extensions` WHERE `ext_name`='%s' LIMIT 1",
                                                array($ext_name), __FILE__, __LINE__);
-                                       $lines = SQL_NUMROWS($result_lines);
-                                       SQL_FREERESULT($result_lines);
-                                       if ($lines == '0') {
-                                               // New extension found
-                                               $OUT .= LOAD_TEMPLATE('admin_ext_reg_form', true, array(
+                                               $lines = SQL_NUMROWS($result_lines);
+                                               SQL_FREERESULT($result_lines);
+                                               if ($lines == '0') {
+                                                       // New extension found
+                                                       $OUT .= LOAD_TEMPLATE('admin_ext_reg_form', true, array(
                                                        'id'       => bigintval($id),
                                                        'ext_name' => $ext_name
-                                               ));
-                                       } else {
-                                               // Task is closed so nothing is todo
-                                               $OUT .= "<div class=\"admin_failed\">{--ADMIN_EXT_ALREADY_REGISTERED--}</div>\n";
+                                                       ));
+                                               } else {
+                                                       // Task is closed so nothing is todo
+                                                       $OUT .= "<div class=\"admin_failed\">{--ADMIN_EXT_ALREADY_REGISTERED--}</div>\n";
+
+                                                       // Close task but not already closes or deleted or update tasks
+                                                       if (($status != 'CLOSED') && ($status != 'DELETED') && ($type != 'EXTENSION_UPDATE')) {
+                                                               // Solve the task
+                                                               runFilterChain('solve_task', $tid);
+                                                       } // END - if
+                                               }
+                                               break;
 
-                                               // Close task but not already closes or deleted or update tasks
-                                               if (($status != 'CLOSED') && ($status != 'DELETED') && ($type != 'EXTENSION_UPDATE')) {
+                                       case 'EXTENSION_UPDATE': // Extension update
+                                               // Extension updates are installed automatically
+                                               $OUT .= "<div class=\"admin_failed medium\">{--ADMIN_EXTENSION_UPDATED--}</div>\n";
+
+                                               // Close task
+                                               if (($status != 'CLOSED') && ($status != 'DELETED')) {
                                                        // Solve the task
                                                        runFilterChain('solve_task', $tid);
                                                } // END - if
-                                       }
-                                       break;
-
-                               case 'EXTENSION_UPDATE': // Extension update
-                                       // Extension updates are installed automatically
-                                       $OUT .= "<div class=\"admin_failed medium\">{--ADMIN_EXTENSION_UPDATED--}</div>\n";
-
-                                       // Close task
-                                       if (($status != 'CLOSED') && ($status != 'DELETED')) {
-                                               // Solve the task
-                                               runFilterChain('solve_task', $tid);
-                                       } // END - if
-                                       break;
+                                               break;
 
-                               case 'SUPPORT_MEMBER': // Assign on member's support request
-                                       // @TODO This may also be rewritten to include files
-                                       switch ($mode)
-                                       {
-                                       default: // @TODO Unknown support mode
-                                               DEBUG_LOG(__FILE__, __LINE__, sprintf("Unknown support mode %s detected. This part is under construction!", $mode));
-                                               $OUT .= "<div class=\"admin_failed medium\">".sprintf(getMessage('ADMIN_UNKNOWN_SUPPORT_MODE'), $mode)."</div>\n";
+                                       case 'SUPPORT_MEMBER': // Assign on member's support request
+                                               // @TODO This may also be rewritten to include files
+                                               switch ($mode)
+                                               {
+                                                       default: // @TODO Unknown support mode
+                                                       DEBUG_LOG(__FILE__, __LINE__, sprintf("Unknown support mode %s detected. This part is under construction!", $mode));
+                                                       $OUT .= "<div class=\"admin_failed medium\">".sprintf(getMessage('ADMIN_UNKNOWN_SUPPORT_MODE'), $mode)."</div>\n";
+                                                       break;
+                                               }
                                                break;
-                                       }
-                                       break;
 
-                               case 'PAYOUT_REQUEST': // Payout requests
-                                       if (EXT_IS_ACTIVE('payout')) {
-                                               // Extension is installed so let him send a notification to the user
-                                               $result_pay = SQL_QUERY_ESC("SELECT `id` FROM `{!_MYSQL_PREFIX!}_user_payouts` WHERE userid=%s AND payout_timestamp=%s LIMIT 1",
-                                                       array(bigintval($uid), bigintval($created)), __FILE__, __LINE__);
-                                               list($pid) = SQL_FETCHROW($result_pay);
-                                               SQL_FREERESULT($result_pay);
-
-                                               if ((!empty($pid)) && ($pid > 0)) {
-                                                       // Payout ID can be obtained
-                                                       $content = array(
+                                                       case 'PAYOUT_REQUEST': // Payout requests
+                                                               if (EXT_IS_ACTIVE('payout')) {
+                                                                       // Extension is installed so let him send a notification to the user
+                                                                       $result_pay = SQL_QUERY_ESC("SELECT `id` FROM `{!_MYSQL_PREFIX!}_user_payouts` WHERE userid=%s AND payout_timestamp=%s LIMIT 1",
+                                                                       array(bigintval($uid), bigintval($created)), __FILE__, __LINE__);
+                                                                       list($pid) = SQL_FETCHROW($result_pay);
+                                                                       SQL_FREERESULT($result_pay);
+
+                                                                       if ((!empty($pid)) && ($pid > 0)) {
+                                                                               // Payout ID can be obtained
+                                                                               $content = array(
                                                                'pid' => $pid,
                                                                'tid' => $tid,
-                                                       );
-                                                       $OUT .= LOAD_TEMPLATE('admin_payout_overview_form', true, $content);
-                                               } else {
-                                                       // Problem obtaining payout ID
-                                                       $OUT .= "<div class=\"admin_failed medium\">{--PAYOUT_OBTAIN_ID_FAILED--}</div>\n";
-                                               }
-                                       } else {
-                                               // Extension is not installed
-                                               $OUT .= "<div class=\"admin_failed medium\">{--ADMIN_PAYOUT_NOT_INSTALLED--}</div>\n";
-                                       }
-                                       break;
-
-                               case 'WERNIS_REQUEST': // Wernis requests
-                                       if (EXT_IS_ACTIVE('wernis')) {
-                                               // Extension is installed so let him send a notification to the user
-                                               $result_pay = SQL_QUERY_ESC("SELECT `id` FROM `{!_MYSQL_PREFIX!}_user_wernis` WHERE userid=%s AND wernis_timestamp=%s LIMIT 1",
-                                                       array(bigintval($uid), bigintval($created)), __FILE__, __LINE__);
-                                               list($pid) = SQL_FETCHROW($result_pay);
-                                               SQL_FREERESULT($result_pay);
-
-                                               if ((!empty($pid)) && ($pid > 0)) {
-                                                       // Payout ID can be obtained
-                                                       $content = array(
+                                                                               );
+                                                                               $OUT .= LOAD_TEMPLATE('admin_payout_overview_form', true, $content);
+                                                                       } else {
+                                                                               // Problem obtaining payout ID
+                                                                               $OUT .= "<div class=\"admin_failed medium\">{--PAYOUT_OBTAIN_ID_FAILED--}</div>\n";
+                                                                       }
+                                                               } else {
+                                                                       // Extension is not installed
+                                                                       $OUT .= "<div class=\"admin_failed medium\">{--ADMIN_PAYOUT_NOT_INSTALLED--}</div>\n";
+                                                               }
+                                                               break;
+
+                                                       case 'WERNIS_REQUEST': // Wernis requests
+                                                               if (EXT_IS_ACTIVE('wernis')) {
+                                                                       // Extension is installed so let him send a notification to the user
+                                                                       $result_pay = SQL_QUERY_ESC("SELECT `id` FROM `{!_MYSQL_PREFIX!}_user_wernis` WHERE userid=%s AND wernis_timestamp=%s LIMIT 1",
+                                                                       array(bigintval($uid), bigintval($created)), __FILE__, __LINE__);
+                                                                       list($pid) = SQL_FETCHROW($result_pay);
+                                                                       SQL_FREERESULT($result_pay);
+
+                                                                       if ((!empty($pid)) && ($pid > 0)) {
+                                                                               // Payout ID can be obtained
+                                                                               $content = array(
                                                                'pid' => $pid,
                                                                'tid' => $tid,
-                                                       );
-                                                       $OUT .= LOAD_TEMPLATE('admin_wernis_overview_form', true, $content);
-                                               } else {
-                                                       // Problem obtaining wernis ID
-                                                       $OUT .= "<div class=\"admin_failed medium\">{--WERNIS_OBTAIN_ID_FAILED--}</div>\n";
-                                               }
-                                       } else {
-                                               // Extension is not installed
-                                               $OUT .= "<div class=\"admin_failed medium\">{--ADMIN_WERNIS_NOT_INSTALLED--}</div>\n";
-                                       }
-                                       break;
-
-                               case 'HOLIDAY_REQUEST': // Holiday requests
-                                       $OUT .= LOAD_TEMPLATE('admin_task_holiday', true, $uid);
-                                       break;
-
-                               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__);
-                                       list($span) = SQL_FETCHROW($result);
-                                       SQL_FREERESULT($result);
-
-                                       if ($span > 0) {
-                                               // Undone unscubscribe request
-                                               $content = array(
+                                                                               );
+                                                                               $OUT .= LOAD_TEMPLATE('admin_wernis_overview_form', true, $content);
+                                                                       } else {
+                                                                               // Problem obtaining wernis ID
+                                                                               $OUT .= "<div class=\"admin_failed medium\">{--WERNIS_OBTAIN_ID_FAILED--}</div>\n";
+                                                                       }
+                                                               } else {
+                                                                       // Extension is not installed
+                                                                       $OUT .= "<div class=\"admin_failed medium\">{--ADMIN_WERNIS_NOT_INSTALLED--}</div>\n";
+                                                               }
+                                                               break;
+
+                                                       case 'HOLIDAY_REQUEST': // Holiday requests
+                                                               $OUT .= LOAD_TEMPLATE('admin_task_holiday', true, $uid);
+                                                               break;
+
+                                                       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__);
+                                                               list($span) = SQL_FETCHROW($result);
+                                                               SQL_FREERESULT($result);
+
+                                                               if ($span > 0) {
+                                                                       // Undone unscubscribe request
+                                                                       $content = array(
                                                        '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";
-                                       }
-                                       break;
-
-                               default: // Unknown task type
-                                       DEBUG_LOG(__FILE__, __LINE__, sprintf("Unknown task type %s detected.", $type));
-                                       $OUT .= "<div class=\"admin_failed medium\">".sprintf(getMessage('ADMIN_UNKNOWN_TASK_TYPE'), $type, $id)."</div>\n";
-                                       break;
+                                                                       );
+                                                                       $OUT .= LOAD_TEMPLATE('admin_newsletter_tsk', true, $content);
+                                                               } else {
+                                                                       // Already unsubscribed
+                                                                       $OUT .= "<div class=\"admin_failed medium\">".ADMIN_NL_UNSUBSCRIBE_ALREADY."</div>\n";
+                                                               }
+                                                               break;
+
+                                                       default: // Unknown task type
+                                                               DEBUG_LOG(__FILE__, __LINE__, sprintf("Unknown task type %s detected.", $type));
+                                                               $OUT .= "<div class=\"admin_failed medium\">".sprintf(getMessage('ADMIN_UNKNOWN_TASK_TYPE'), $type, $id)."</div>\n";
+                                                               break;
                                }
                                $OUT .= "  </td>
   <td width=\"1%\" class=\"switch_sw".$SW." bottom2 right2\">&nbsp;</td>
@@ -371,19 +371,19 @@ LIMIT 1",
                                // Unassign from tasks
                                foreach ($POST['task'] as $id => $sel) {
                                        SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_task_system` SET `assigned_admin`=0 WHERE `id`=%s AND `assigned_admin`=%s LIMIT 1",
-                                               array(bigintval($id), getCurrentAdminId()), __FILE__, __LINE__);
+                                       array(bigintval($id), getCurrentAdminId()), __FILE__, __LINE__);
                                }
                        } elseif (isset($POST['del'])) {
                                // Delete tasks
                                foreach ($POST['task'] as $id => $sel) {
                                        SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_task_system` WHERE `id`=%s AND assigned_admin IN (%s,0) LIMIT 1",
-                                               array(bigintval($id), getCurrentAdminId()), __FILE__, __LINE__);
+                                       array(bigintval($id), getCurrentAdminId()), __FILE__, __LINE__);
                                }
                        }
 
                        // Update query
                        $result_tasks = SQL_QUERY_ESC("SELECT id, assigned_admin, userid, task_type, subject, text, task_created FROM `{!_MYSQL_PREFIX!}_task_system` WHERE `assigned_admin`=%s OR (`assigned_admin`=0 AND `status`='NEW') ORDER BY task_created DESC",
-                               array(getCurrentAdminId()), __FILE__, __LINE__);
+                       array(getCurrentAdminId()), __FILE__, __LINE__);
                } // END - if
 
                // There are uncompleted jobs!
@@ -398,10 +398,10 @@ LIMIT 1",
                        // Generate infos
                        switch ($content['task_type'])
                        {
-                       case 'EXTENSION':
-                       case 'EXTENSION_UPDATE':
-                               $content['infos'] = substr($content['subject'], 1, strpos($content['subject'], ':') - 1);
-                               break;
+                               case 'EXTENSION':
+                               case 'EXTENSION_UPDATE':
+                                       $content['infos'] = substr($content['subject'], 1, strpos($content['subject'], ':') - 1);
+                                       break;
                        }
 
                        // Get task type