X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Fmodules%2Fadmin%2Foverview-inc.php;h=97679cc87bc51d8c332a4131d6cedc76529d2a68;hb=eb301334eb0960dd060cc0d59e6021260a41f835;hp=3568b70afb07d667dd572d38098b3043c5c2f0f8;hpb=c3e061c0d6fc0ee8778ebaebf1c05cf2bf126703;p=mailer.git
diff --git a/inc/modules/admin/overview-inc.php b/inc/modules/admin/overview-inc.php
index 3568b70afb..97679cc87b 100644
--- a/inc/modules/admin/overview-inc.php
+++ b/inc/modules/admin/overview-inc.php
@@ -10,9 +10,14 @@
* -------------------------------------------------------------------- *
* Kurzbeschreibung : Standart-Aufgaben-Management ausgeben *
* -------------------------------------------------------------------- *
- * *
+ * $Revision:: $ *
+ * $Date:: $ *
+ * $Tag:: 0.2.1-FINAL $ *
+ * $Author:: $ *
+ * Needs to be in all Files and every File needs "svn propset *
+ * svn:keywords Date Revision" (autoprobset!) at least!!!!!! *
* -------------------------------------------------------------------- *
- * Copyright (c) 2003 - 2008 by Roland Haeder *
+ * Copyright (c) 2003 - 2009 by Roland Haeder *
* For more information visit: http://www.mxchange.org *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -32,507 +37,443 @@
************************************************************************/
// Some security stuff...
-if ((ereg(basename(__FILE__), $_SERVER['PHP_SELF'])) || (!IS_ADMIN()))
-{
- $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
- require($INC);
+if ((!defined('__SECURITY')) || (!isAdmin())) {
+ die();
}
-function OUTPUT_STANDARD_OVERVIEW(&$result_tasks)
-{
- global $EXTENSIONS, $KEEP_ACTIVE;
-
+// @TODO This function does also check for uncompleted tasks
+function outputStandardOverview (&$result_tasks) {
// First check for solved and not assigned tasks and assign them to current admin
- $result_task = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_task_system SET assigned_admin='%s' WHERE assigned_admin < 1 AND status != 'NEW'",
- array(GET_ADMIN_ID($_COOKIE['admin_login'])), __FILE__, __LINE__);
+ SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_task_system` SET `assigned_admin`=%s WHERE assigned_admin < 1 AND status != 'NEW'",
+ 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"; $JOBS_DONE = true;
+ setExtensionMode('register');
+ $jobsDone = true;
// Open the extension directory
- $handle = opendir(PATH."inc/extensions/") or mxchange_die("Cannot read extension directory!");
- while ($file = readdir($handle)) {
+ $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."
\n";
+ if ((substr($file, 0, 4) == 'ext-') && (substr($file, -4) == '.php')) {
// Possible newly installed extension found so we extract extension's name
- $ext = strtolower(substr($file, 4, -4)); // Keep always extension names on lower case!!!
+ $ext_name = strtolower(substr($file, 4, -4)); // Keep always extension names on lower case!!!
- // Check if extension is installed or not
- $ext_ver = "";
- if ((!is_array($EXTENSIONS['ext_version'])) || (empty($EXTENSIONS['ext_version'][$ext]))) {
- // Load data from database
- $result = SQL_QUERY_ESC("SELECT id, ext_version FROM "._MYSQL_PREFIX."_extensions WHERE ext_name='%s' LIMIT 1",
- array($ext), __FILE__, __LINE__);
- } else {
- // Load version from cache
- if (!empty($EXTENSIONS['ext_version'][$ext])) {
- // Extension is installed so we can get it's version number
- $ext_ver = $EXTENSIONS['ext_version'][$ext];
- } else {
- // Extension is not installed so no version number was found
- $ext_ver = "";
- }
+ // Init variables
+ $result = false;
- // Disable load from database
- $result = false;
- }
+ // Check if extension is installed or not
+ $extInstalled = (isExtensionInstalled($ext_name) && (isExtensionActive($ext_name)));
// Is the extension not yet installed?
- if ((SQL_NUMROWS($result) == 0) && (empty($ext_ver))) {
- // Not installed and do we have created a task for the admin?
- $ext_subj = "[".$ext.":] ".ADMIN_NEW_EXT_SUBJ;
- //* DEBUG: */ echo $ext.":".$ext_ver."=";
- $result = SQL_QUERY_ESC("SELECT id FROM "._MYSQL_PREFIX."_task_system WHERE subject='%s' LIMIT 1",
- array($ext_subj), __FILE__, __LINE__);
- //* DEBUG: */ echo SQL_NUMROWS($result)."
\n";
- 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_exists($tpl)) && (is_readable($tpl)))
- {
- // Load extension's own text template (HTML!)
- $MSG = LOAD_TEMPLATE("ext_".$ext, true);
- }
- else
- {
- // Load default message
- $MSG = LOAD_EMAIL_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 = 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(
- GET_ADMIN_ID($_COOKIE['admin_login']),
- $ext_subj,
- addslashes($MSG),
-), __FILE__, __LINE__, true, false);
- }
-
- // Free memory
- SQL_FREERESULT($result);
+ if ($extInstalled === false) {
+ // Generate subject line
+ $ext_subj = sprintf("[%s:]", $ext_name);
// We maybe want to install an extension so let's test-drive it...
- include(PATH."inc/extensions/".$file);
- }
- else
- {
- // Maybe we want to update?
- if ((empty($EXTENSIONS['ext_version'][$ext])) && (SQL_NUMROWS($result) == 1))
- {
- list($dummy, $ext_ver) = SQL_FETCHROW($result);
- SQL_FREERESULT($result);
- }
+ if (loadExtension($ext_name, getExtensionMode(), '', true)) {
+ // Create a task for newly installed extension
+ createNewExtensionTask(getCurrentAdminId(), $ext_subj, $ext_name);
+ } // END - if
+ } else {
+ // Test-drive extension in update mode
+ loadExtension($ext_name, 'test');
- // Update extension
- if (!empty($ext_ver)) EXTENSION_UPDATE($file, $ext, $ext_ver);
+ // Get extension version
+ $ext_ver = getExtensionVersion($ext_name);
+ //* DEBUG: */ outputHtml($ext_name."=".$ext_ver."
");
- if (!empty($KEEP_ACTIVE[$ext]))
- {
+ // Update extension if extension is installed and outdated
+ //* DEBUG: */ outputHtml('ext=' . $ext_name . ',ver=' . getThisExtensionVersion() . '/' . getExtensionVersion($ext_name)."
");
+ if (getThisExtensionVersion() > $ext_ver) {
+ // Update the extension
+ updateExtension($ext_name, $ext_ver);
+ } // END - if
+
+ if (isset($GLOBALS['cache_array']['active_extensions'][$ext_name])) {
// Maybe we want to keept the current extension active?
- if (($KEEP_ACTIVE[$ext] == 'Y') && (!EXT_IS_ACTIVE($ext, true, true)))
- {
+ if (($GLOBALS['cache_array']['active_extensions'][$ext_name] == 'Y') && (!isExtensionActive($ext_name))) {
// Reactivate this extension!
- $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_extensions SET ext_active='Y' WHERE ext_name='%s' LIMIT 1",
- array($ext), __FILE__, __LINE__);
- EXTENSION_RUN_SQLS(GET_EXT_ID($ext), "activate");
- }
- }
+ doActivateExtension($ext_name);
+ } // END - if
+ } // END - if
}
- }
- }
-
- // Close directory handle
- closedir($handle);
+ } // END - if
+ } // END - foreach
// At last - but not least - check for own and new unassigned tasks...
- $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 userid DESC, task_type DESC, subject, task_created DESC",
- array(GET_ADMIN_ID($_COOKIE['admin_login'])), __FILE__, __LINE__);
- if (SQL_NUMROWS($result_tasks) > 0)
- {
+ $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
+ `userid` DESC,
+ `task_type` DESC,
+ `subject` ASC,
+ `task_created` DESC",
+ array(getCurrentAdminId()), __FILE__, __LINE__);
+
+ if (SQL_NUMROWS($result_tasks) > 0) {
// New jobs found!
- $JOBS_DONE = false;
- }
+ $jobsDone = false;
+ } // END - if
+
+ // Free the result
+ SQL_FREERESULT($result);
- return $JOBS_DONE;
+ // Return status
+ return $jobsDone;
}
-//
-function OUTPUT_SELECTED_TASKS($_POST, $result_tasks)
-{
- global $_CONFIG, $NOTES;
- if ((isset($_POST['assign'])) && (count($_POST['task']) > 0))
- {
+
+// Outputs selected tasks
+function outputSeletectedTasks ($postData, $result_tasks) {
+ if ((isset($postData['assign'])) && (count($postData['task']) > 0)) {
// Assign / do tasks
- $OUT = ""; $SW = 2;
- foreach ($_POST['task'] as $id=>$sel)
- {
- $result_task = SQL_QUERY_ESC("SELECT id, userid, task_type, subject, text, task_created, status, assigned_admin FROM "._MYSQL_PREFIX."_task_system WHERE id=%d AND (assigned_admin='%s' OR (assigned_admin='0' AND status='NEW')) LIMIT 1",
- array(bigintval($id), GET_ADMIN_ID($_COOKIE['admin_login'])), __FILE__, __LINE__);
- if (SQL_NUMROWS($result_task) == 1)
- {
+ $OUT = ''; $SW = 2;
+ foreach ($postData['task'] as $id => $sel) {
+ $result_task = SQL_QUERY_ESC("SELECT
+ `id`, `userid`, `task_type`, `subject`, `text`, `task_created`, `status`, `assigned_admin`
+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__);
+
+ // Task is found?
+ if (SQL_NUMROWS($result_task) == 1) {
// Task is valid...
- list($tid, $uid, $type, $subj, $text, $created, $status, $aid) = SQL_FETCHROW($result_task);
- SQL_FREERESULT($result_task);
- if ($aid == "0")
- {
+ list($tid, $userid, $type, $subj, $text, $created, $status, $adminId) = SQL_FETCHROW($result_task);
+
+ if ($adminId == '0') {
// Assgin current admin to unassgigned task
- $result_assign = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_task_system SET assigned_admin='%s' WHERE id=%d LIMIT 1",
- array(GET_ADMIN_ID($_COOKIE['admin_login']), bigintval($tid)), __FILE__, __LINE__);
- }
- $ADD = "";
- if ($type == "SUPPORT_MEMBER")
- {
- $mode = substr($text, 0, strpos($text, ":"));
- $text = substr($text, strpos($text, ":") + 1);
- $ADD = "
%s", print_r($postData, true))); } // 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(GET_ADMIN_ID($_COOKIE['admin_login'])), __FILE__, __LINE__); - } + $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__); + } // END - if // There are uncompleted jobs! - LOAD_TEMPLATE("admin_overview_header"); - $SW = 2; - while (list($id, $admin, $uid, $type, $subj, $text, $created) = SQL_FETCHROW($result_tasks)) - { - $infos = "---"; - if ($admin == "0") - { - // No admin currently is assigned - $admin = "".ADMIN_NO_ADMIN_ASSIGNED.""; - } - else - { - // Load admin's data - $login = GET_ADMIN_LOGIN($admin); - if ($login != "***") - { - // Admin found - $admin = "".$login.""; - } - else - { - // Maybe deleted? - $admin = "".ADMIN_ID_404_1.$admin.ADMIN_ID_404_2.""; - } - } - $evl = "\$type_out = ADMIN_TASK_IS_".strtoupper($type).";"; - eval($evl); - $type2 = substr($text, 0, strpos($text, ":")); + $OUT = ''; $SW = 2; + while ($content = SQL_FETCHARRAY($result_tasks)) { + // Init infos + $content['infos'] = '---'; + + // Generate assign link + $content['assigned_admin'] = generateAdminLink($content['assigned_admin']); + // Generate infos - switch ($type) - { - case "EXTENSION": - case "EXTENSION_UPDATE": - $infos = substr($subj, 1, strpos($subj, ":") - 1); - break; + // @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); + break; } - if ($uid > 0) - { + + // Get task type + $content['task_type_msg'] = getMessage('ADMIN_TASK_IS_'.strtoupper($content['task_type']).''); + + if ($content['userid'] > 0) { // Member found otherwise it's a system task - $uid = ADMIN_USER_PROFILE_LINK($uid); + $content['userid'] = generateUserProfileLink($content['userid']); + } else { + $content['userid'] = "{--ADMIN_IS_SYSTEM_TASK--}"; } - else - { - $uid = "".ADMIN_IS_SYSTEM_TASK.""; + + // Prepare content + $content = merge_array($content, array( + 'sw' => $SW, + 'assigned_admin' => $content['assigned_admin'], + 'userid' => $content['userid'], + 'task_type_msg' => $content['task_type_msg'], + 'created' => generateDateTime($content['task_created'], '2') + )); + + // Do we have extension task? + if (($content['task_type'] == 'EXTENSION') && (isExtensionNameValid($content['infos'])) && (!isExtensionInstalled($content['infos']))) { + // Load extension row template + $OUT .= loadTemplate('admin_overview_list_ext_rows', true, $content); + } else { + // Load default row template + $OUT .= loadTemplate('admin_overview_list_rows', true, $content); } - $content = array( - 'sw' => $SW, - 'id' => $id, - 'admin' => $admin, - 'infos' => $infos, - 'uid' => $uid, - 'type' => $type_out, - 'created' => MAKE_DATETIME($created, "2") - ); - - LOAD_TEMPLATE("admin_overview_list_rows", false, $content); + // Switch color $SW = 3 - $SW; - } + } // END - while + // Free memory SQL_FREERESULT($result_tasks); // Load footer template - LOAD_TEMPLATE("admin_overview_footer"); + loadTemplate('admin_overview_table', false, $OUT); } } -// + +// [EOF] ?>