<?php
/************************************************************************
- * MXChange v0.2.1 Start: 08/03/2004 *
- * ================ Last change: 08/07/2004 *
+ * Mailer v0.2.1-FINAL Start: 08/03/2004 *
+ * =================== Last change: 08/07/2004 *
* *
* -------------------------------------------------------------------- *
* File : what-list_task.php *
* $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 *
+ * Copyright (c) 2009, 2010 by Mailer Developer Team *
* For more information visit: http://www.mxchange.org *
* *
* This program is free software; you can redistribute it and/or modify *
************************************************************************/
// Some security stuff...
-if ((!defined('__SECURITY')) || (!IS_ADMIN())) {
- $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
- require($INC);
-} elseif (!EXT_IS_ACTIVE("task")) {
- addFatalMessage(__FILE__, __LINE__, getMessage('EXTENSION_PROBLEM_EXT_INACTIVE'), "task");
- return;
-}
+if ((!defined('__SECURITY')) || (!isAdmin())) {
+ die();
+} // END - if
// Add description as navigation point
-ADD_DESCR("admin", __FILE__);
+addMenuDescription('admin', __FILE__);
-$whereStatement = "";
-if (!REQUEST_ISSET_GET(('type'))) REQUEST_SET_GET('type', "your");
+if (!isExtensionActive('task')) {
+ loadTemplate('admin_settings_saved', false, generateExtensionInactiveNotInstalledMessage('task'));
+ return;
+} // END - if
-switch (REQUEST_GET('type'))
-{
-case "your": // List only your own open (new) tasks
- $whereStatement = "assigned_admin='".GET_CURRENT_ADMIN_ID()."' AND `status`='NEW' AND task_type != 'EXTENSION_UPDATE'";
- break;
+$whereStatement = '';
+if (!isGetRequestParameterSet('type')) setGetRequestParameter('type', 'your');
-case "updates": // List only updates assigned to you
- $whereStatement = "assigned_admin=".GET_CURRENT_ADMIN_ID()." AND `status`='NEW' AND task_type = 'EXTENSION_UPDATE'";
- break;
+switch (getRequestParameter('type')) {
+ case 'your': // List only your own open (new) tasks
+ $whereStatement = "`assigned_admin`=".getCurrentAdminId()." AND `status`='NEW' AND `task_type` != 'EXTENSION_UPDATE'";
+ break;
-case "solved": // List only solved tasks assigned to you
- $whereStatement = "assigned_admin=".GET_CURRENT_ADMIN_ID()." AND `status`='SOLVED'";
- break;
+ case 'updates': // List only updates assigned to you
+ $whereStatement = "`assigned_admin`=".getCurrentAdminId()." AND `status`='NEW' AND `task_type`='EXTENSION_UPDATE'";
+ break;
-case "unassigned": // List unassigned (but not deleted) tasks
- $whereStatement = "assigned_admin='0' AND status != 'DELETED'";
- break;
+ case 'solved': // List only solved tasks assigned to you
+ $whereStatement = "`assigned_admin`=".getCurrentAdminId()." AND `status`='SOLVED'";
+ break;
-case "deleted": // List all deleted
- $whereStatement = "`status`='DELETED'";
- break;
+ case 'unassigned': // List unassigned (but not deleted) tasks
+ $whereStatement = "`assigned_admin`=0 AND `status` != 'DELETED'";
+ break;
-case "closed": // List all closed
- $whereStatement = "assigned_admin=".GET_CURRENT_ADMIN_ID()." AND `status`='CLOSED'";
- break;
+ case 'deleted': // List all deleted
+ $whereStatement = "`status`='DELETED'";
+ break;
-default: // Unknown type
- DEBUG_LOG(__FILE__, __LINE__, sprintf("Unknown task type %s detected.", REQUEST_GET('type')));
- LOAD_TEMPLATE("admin_settings_saved", false, sprintf(getMessage('ADMIN_TASK_UNKNOWN_MODE'), REQUEST_GET('type')));
- break;
-}
+ case 'closed': // List all closed
+ $whereStatement = "`assigned_admin`=".getCurrentAdminId()." AND `status`='CLOSED'";
+ break;
-if (!empty($whereStatement)) {
- $SEL = 0;
- if (REQUEST_ISSET_POST(('task'))) $SEL = SELECTION_COUNT(REQUEST_POST('task'));
+ default: // Unknown type
+ logDebugMessage(__FILE__, __LINE__, sprintf("Unknown task type %s detected.", getRequestParameter('type')));
+ loadTemplate('admin_settings_saved', false, getMaskedMessage('ADMIN_TASK_UNKNOWN_MODE', getRequestParameter('type')));
+ break;
+} // END - switch
- if ((REQUEST_ISSET_POST(('assign'))) && ($SEL > 0)) {
+if (!empty($whereStatement)) {
+ if ((isPostRequestParameterSet('assign')) && (ifPostContainsSelections())) {
// Assign / do tasks
- LOAD_INC_ONCE("inc/modules/admin/overview-inc.php");
- if (empty($dmy)) $dmy = "";
- OUTPUT_SELECTED_TASKS(REQUEST_POST_ARRAY(), $dmy);
+ loadIncludeOnce('inc/modules/admin/overview-inc.php');
+ if (empty($dmy)) $dmy = '';
+ outputSeletectedTasks(postRequestArray(), $dmy);
} 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 ".$whereStatement."
-ORDER BY userid DESC, task_type DESC, subject, task_created DESC", __FILE__, __LINE__);
- if (($SEL > 0) && (!IS_DEMO())) {
+ $result_tasks = SQL_QUERY('SELECT
+ `id`, `assigned_admin`, `userid`, `task_type`, `subject`, `text`, `task_created`
+FROM
+ `{?_MYSQL_PREFIX?}_task_system`
+WHERE
+ '.$whereStatement.'
+ORDER BY
+ `userid` DESC,
+ `task_type` DESC,
+ `subject` ASC,
+ `task_created` DESC',
+ __FILE__, __LINE__);
+ if ((ifPostContainsSelections()) && (!isDemoModeActive())) {
// Only unassign / delete tasks when there are selected tasks posted
- if (REQUEST_ISSET_POST(('unassign'))) {
+ if (isPostRequestParameterSet('unassign')) {
// Unassign from tasks
- foreach (REQUEST_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), GET_CURRENT_ADMIN_ID()), __FILE__, __LINE__);
- }
- } elseif (REQUEST_ISSET_POST('del')) {
+ foreach (postRequestParameter('sel') 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__);
+ } // END - foreach
+ } elseif (isFormSent('delete')) {
// Delete tasks
- foreach (REQUEST_POST('task') as $id => $sel) {
- if (REQUEST_GET('type') == "deleted") {
+ foreach (postRequestParameter('sel') as $id => $sel) {
+ if (getRequestParameter('type') == 'deleted') {
// Delete task immediately
- SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_task_system` WHERE id=%s LIMIT 1",
+ 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)
- ADMIN_DELETE_TASK($id);
+ // Mark task as to be deleted (purged by autopurge extension)
+ adminDeleteTask($id);
}
- }
+ } // END - foreach
+ } else {
+ // Unknown action performed
+ debug_report_bug(__FILE__, __LINE__, sprintf("Unknown task action performed. data=<pre>%s</pre>", print_r(postRequestArray(), true)));
}
// Update query
- $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__);
+ $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` ASC,
+ `task_created` DESC', __FILE__, __LINE__);
}
// There are uncompleted jobs!
- $type = getMessage('ADMIN_OVERVIEW_TASK_'.strtoupper(REQUEST_GET('type')).'_TYPE');
- // @TODO Rewrite these templates to one and add $OUT
- LOAD_TEMPLATE("admin_overview_header_task", false, array(
- 'message' => $type,
- 'type' => REQUEST_GET('type')
- ));
- $OUT = ""; $SW = 2;
+ $OUT = '';
while ($content = SQL_FETCHARRAY($result_tasks)) {
// Init infos
- $content['infos'] = "---";
-
- // Generate link
- $content['assigned_admin'] = GENERATE_AID_LINK($content['assigned_admin']);
+ $content['infos'] = '';
// Get admin task
- $content['task_type_msg'] = getMessage('ADMIN_TASK_IS_'.strtoupper($content['task_type']).'');
+ $content['task_type_msg'] = '{--ADMIN_TASK_IS_' . strtoupper($content['task_type']) . '--}';
// Generate infos
- switch ($content['task_type'])
- {
- case "EXTENSION":
- case "EXTENSION_UPDATE":
- $content['infos'] = substr($content['subject'], 1, strpos($content['subject'], ":") - 1);
- break;
- }
+ switch ($content['task_type']) {
+ case 'EXTENSION':
+ case 'EXTENSION_UPDATE':
+ $content['infos'] = substr($content['subject'], 1, strpos($content['subject'], ':') - 1);
+ break;
+ } // END - switch
// Member assigned with task?
- if ($content['userid'] > 0) {
+ if (isValidUserId($content['userid'])) {
// Member found otherwise it's a system task
- $content['userid'] = ADMIN_USER_PROFILE_LINK($content['userid']);
+ $content['userid'] = generateUserProfileLink($content['userid']);
} else {
// Is a system task!
- $content['userid'] = "<em>{--ADMIN_IS_SYSTEM_TASK--}</em>";
+ $content['userid'] = '<em>{--ADMIN_IS_SYSTEM_TASK--}</em>';
}
// Prepare content
- // @TODO Rewritings: admin->assigned_admin,uid->userid,type->task_type_msg in template
$content = merge_array($content, array(
- 'sw' => $SW,
- 'admin' => $content['assigned_admin'],
- 'uid' => $content['userid'],
- 'type' => $content['task_type_msg'],
- 'created' => MAKE_DATETIME($content['task_created'], "2")
+ 'assign_admin' => $content['assigned_admin'],
+ 'userid' => $content['userid'],
+ 'task_type_msg' => $content['task_type_msg'],
+ 'task_created' => generateDateTime($content['task_created'], 2)
));
// Do we have an extension task?
- if (($content['task_type'] == "EXTENSION") && (GET_EXT_VERSION($content['infos']) == "")) {
+ if (isExtensionTask($content)) {
// Load extension row template
- // @TODO Rewrite this to $OUT .= ..., true, ...
- LOAD_TEMPLATE("admin_list_task_ext_rows", false, $content);
+ $OUT .= loadTemplate('admin_list_task_ext_rows', true, $content);
} else {
// Load default row template
- // @TODO Rewrite this to $OUT .= ..., true, ...
- LOAD_TEMPLATE("admin_list_task_rows", false, $content);
+ $OUT .= loadTemplate('admin_list_task_rows', true, $content);
}
-
- // Switch colors
- $SW = 3 - $SW;
- }
+ } // END - while
// Free memory
SQL_FREERESULT($result_tasks);
+ // Prepare content
+ $content = array(
+ 'message' => '{--ADMIN_OVERVIEW_TASK_' . strtoupper(getRequestParameter('type')) . '_TYPE--}',
+ 'type' => getRequestParameter('type'),
+ 'rows' => $OUT
+ );
+
// Load footer template
- if (REQUEST_GET('type') == "deleted") {
+ if (getRequestParameter('type') == 'deleted') {
// Delete now button
- LOAD_TEMPLATE("admin_overview_footer_task");
+ loadTemplate('admin_list_task_delete', false, $content);
} else {
// Normal footer
- LOAD_TEMPLATE("admin_overview_footer");
+ loadTemplate('admin_list_task', false, $content);
}
}
-}
-//
+} // END - if
+
+// [EOF]
?>