- // @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",
- 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(
- '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";
+ // @TODO Rewrite this to something with include files and/or filter
+ switch ($taskData['task_type']) {
+ case 'EXTENSION': // Install new extensions
+ $ext_name = substr($taskData['subject'], 1, strpos($taskData['subject'], ':') - 1);
+ if (!isExtensionInstalled($ext_name)) {
+ // New (not yet installed) extension found
+ $OUT .= loadTemplate('admin_extension_reg_form', true, array(
+ 'id' => bigintval($taskId),
+ 'ext_name' => $ext_name
+ ));
+ } else {
+ // Extension is already installed
+ $OUT .= '<div class="notice">{--ADMIN_EXTENSION_ALREADY_REGISTERED--}</div>';
+
+ // Close task but not already closed, solved, deleted or update tasks
+ if ((!in_array($taskData['status'], array('CLOSED', 'DELETED', 'SOLVED'))) && ($taskData['task_type'] != 'EXTENSION_UPDATE')) {
+ // Solve the task
+ runFilterChain('solve_task', $taskData['id']);
+ } // END - if
+ }
+ break;
+
+ case 'EXTENSION_UPDATE': // Extension update
+ // Extension updates are installed automatically
+ $OUT .= '<div class="notice medium">{--ADMIN_EXTENSION_UPDATED--}</div>';