************************************************************************/
// Some security stuff...
-if ((ereg(basename(__FILE__), $_SERVER['PHP_SELF'])) || (!IS_ADMIN()))
-{
+if ((!defined('__SECURITY')) || (!IS_ADMIN())) {
$INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
require($INC);
+} elseif (!EXT_IS_ACTIVE("task")) {
+ ADD_FATAL(EXTENSION_PROBLEM_EXT_INACTIVE, "task");
+ return;
}
+
// Add description as navigation point
ADD_DESCR("admin", basename(__FILE__));
-$WHERE = "";
+$whereStatement = "";
if (empty($_GET['type'])) $_GET['type'] = "your";
switch ($_GET['type'])
{
case "your": // List only your own open (new) tasks
- $WHERE = "assigned_admin='".GET_ADMIN_ID($_COOKIE['admin_login'])."' AND status='NEW' AND task_type != 'EXTENSION_UPDATE'";
+ $whereStatement = "assigned_admin='".GET_ADMIN_ID(get_session('admin_login'))."' AND status='NEW' AND task_type != 'EXTENSION_UPDATE'";
break;
case "updates": // List only updates assigned to you
- $WHERE = "assigned_admin='".GET_ADMIN_ID($_COOKIE['admin_login'])."' AND status='NEW' AND task_type = 'EXTENSION_UPDATE'";
+ $whereStatement = "assigned_admin='".GET_ADMIN_ID(get_session('admin_login'))."' AND status='NEW' AND task_type = 'EXTENSION_UPDATE'";
break;
case "solved": // List only solved tasks assigned to you
- $WHERE = "assigned_admin='".GET_ADMIN_ID($_COOKIE['admin_login'])."' AND status='SOLVED'";
+ $whereStatement = "assigned_admin='".GET_ADMIN_ID(get_session('admin_login'))."' AND status='SOLVED'";
break;
case "unassigned": // List unassigned (but not deleted) tasks
- $WHERE = "assigned_admin='0' AND status != 'DELETED'";
+ $whereStatement = "assigned_admin='0' AND status != 'DELETED'";
break;
case "deleted": // List all deleted
- $WHERE = "status='DELETED'";
+ $whereStatement = "status='DELETED'";
break;
case "closed": // List all closed
- $WHERE = "assigned_admin='".GET_ADMIN_ID($_COOKIE['admin_login'])."' AND status='CLOSED'";
+ $whereStatement = "assigned_admin='".GET_ADMIN_ID(get_session('admin_login'))."' AND status='CLOSED'";
break;
default: // Unknown type
break;
}
-if (!empty($WHERE))
+if (!empty($whereStatement))
{
$SEL = 0;
if (isset($_POST['task'])) $SEL = SELECTION_COUNT($_POST['task']);
- if ((isset($_POST['assign'])) && ($SEL > 0))
- {
+ if ((isset($_POST['assign'])) && ($SEL > 0)) {
// Assign / do tasks
require_once(PATH."inc/modules/admin/overview-inc.php");
if (empty($dmy)) $dmy = "";
OUTPUT_SELECTED_TASKS($_POST, $dmy);
- }
- else
- {
+ } else {
// Start listing tasks matching selected filter
$result_tasks = SQL_QUERY("SELECT id, assigned_admin, userid, task_type, subject, text, task_created
FROM "._MYSQL_PREFIX."_task_system
-WHERE ".$WHERE."
+WHERE ".$whereStatement."
ORDER BY userid DESC, task_type DESC, subject, task_created DESC", __FILE__, __LINE__);
- if (($SEL > 0) && (!IS_DEMO()))
- {
+ if (($SEL > 0) && (!IS_DEMO())) {
// Only unassign / delete tasks when there are selected tasks posted
- if (isset($_POST['unassign']))
- {
+ if (isset($_POST['unassign'])) {
// Unassign from tasks
- foreach ($_POST['task'] as $id=>$sel)
- {
- $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_task_system SET assigned_admin='0' WHERE id=%d AND assigned_admin='%s' LIMIT 1",
- array(bigintval($id), GET_ADMIN_ID($_COOKIE['admin_login'])), __FILE__, __LINE__);
+ foreach ($_POST['task'] as $id => $sel) {
+ $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_task_system SET assigned_admin=0 WHERE id=%s AND assigned_admin=%s LIMIT 1",
+ array(bigintval($id), GET_ADMIN_ID(get_session('admin_login'))), __FILE__, __LINE__);
}
- }
- elseif (isset($_POST['del']))
- {
+ } elseif (isset($_POST['del'])) {
// Delete tasks
- foreach ($_POST['task'] as $id=>$sel)
- {
- if ($_GET['type'] == "deleted")
- {
+ foreach ($_POST['task'] as $id => $sel) {
+ if ($_GET['type'] == "deleted") {
// Delete task immediately
- $result = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_task_system WHERE id=%d LIMIT 1",
+ $result = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_task_system WHERE id=%s LIMIT 1",
array(bigintval($id)),__FILE__, __LINE__);
- }
- else
- {
+ } else {
// Mark task as to be deleted (purged by autppurge extension)
- $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_task_system SET status='DELETED' WHERE id=%d LIMIT 1",
- array(bigintval($id)), __FILE__, __LINE__);
+ ADMIN_DELETE_TASK($id);
}
}
}
// Update query
- $result_tasks = SQL_QUERY("SELECT id, assigned_admin, userid, task_type, subject, text, task_created FROM "._MYSQL_PREFIX."_task_system WHERE ".$WHERE." ORDER BY subject, task_created DESC", __FILE__, __LINE__);
+ $result_tasks = SQL_QUERY("SELECT id, assigned_admin, userid, task_type, subject, text, task_created FROM "._MYSQL_PREFIX."_task_system WHERE ".$whereStatement." ORDER BY subject, task_created DESC", __FILE__, __LINE__);
}
// There are uncompleted jobs!
- $eval = "\$TYPE = ADMIN_OVERVIEW_TASK_".strtoupper($_GET['type'])."_TYPE;";
+ $eval = "\$type = ADMIN_OVERVIEW_TASK_".strtoupper($_GET['type'])."_TYPE;";
eval($eval);
LOAD_TEMPLATE("admin_overview_header_task", false, array(
- 'message' => $TYPE,
+ 'message' => $type,
'type' => $_GET['type']
));
$SW = 2;