************************************************************************/
// Some security stuff...
-if ((ereg(basename(__FILE__), $_SERVER['PHP_SELF'])) || (!IS_ADMIN()))
-{
+if ((ereg(basename(__FILE__), $_SERVER['PHP_SELF'])) || (!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']);
// 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()))
{
// 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__);
+ $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']))
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
{
// 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",
+ $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_task_system SET status='DELETED' WHERE id=%s LIMIT 1",
array(bigintval($id)), __FILE__, __LINE__);
}
}
}
// 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!