Index: common/db/task.php
===================================================================
--- common/db/task.php	(revision 956)
+++ common/db/task.php	(working copy)
@@ -33,7 +33,7 @@
     return mem_cache_set("task-by-id:$task_id", db_fetch($query));
 }
 
-// create new task
+// Create new task
 function task_create($task, $task_params) {
     log_assert_valid(task_validate($task));
     log_assert_valid(task_validate_parameters($task['type'], $task_params));
@@ -54,6 +54,48 @@
     return $res;
 }
 
+// Delete a task, including scores, jobs and page
+// WARNING: This is irreversible.
+function task_delete($task) {
+    log_assert_valid(task_validate($task));
+
+    _task_cache_delete($task);
+
+    // Delete problem page
+    textblock_delete($task["page_name"]);
+
+    // Remove task from all rounds
+    db_query("DELETE FROM `ia_round_task`
+              WHERE `task_id` = " . db_quote($task["id"]));
+
+    // Delete all scores received on task
+    db_query("DELETE FROM `ia_score`
+              WHERE `task_id` = " . db_quote($task["id"]));
+
+    // Delete task jobs
+    $job_ids_fetched = db_fetch_all("
+        SELECT `id`
+        FROM `ia_job`
+        WHERE `task_id` = " . db_quote($task["id"]));
+
+    $job_ids = array();
+    foreach ($job_ids_fetched as $job) {
+        $job_ids[] = (int)$job["id"];
+    }
+
+    $formated_job_ids = implode(", ", array_map("db_quote", $job_ids));
+    db_query("DELETE FROM `ia_job_test`
+              WHERE `job_id` IN ({$formated_job_ids})");
+    db_query("DELETE FROM `ia_job`
+              WHERE `id` IN ({$formated_job_ids})");
+
+    // Delete task
+    db_query("DELETE FROM `ia_task` WHERE `id` = '" . db_escape($task["id"]) . "'");
+
+    // Delete all task parameters
+    task_update_parameters($task["id"], array());
+}
+
 function task_update($task) {
     log_assert_valid(task_validate($task));
     if (db_update('ia_task', $task,
Index: www/controllers/task.php
===================================================================
--- www/controllers/task.php	(revision 956)
+++ www/controllers/task.php	(working copy)
@@ -197,4 +197,35 @@
     execute_view_die("views/task_create.php", $view);
 }
 
+// Deletes a task.
+function controller_task_delete($task_id) {
+    if (!request_is_post()) {
+        flash_error("Problema nu a putut fi stearsa.");
+        redirect(url_home());
+    }
+
+    // Validate task_id
+    if (!is_task_id($task_id)) {
+        flash_error("Problema inexistenta.");
+        redirect(url_home());
+    }
+
+    // Get task
+    $task = task_get($task_id);
+    if (!$task) {
+        flash_error("Problema inexistenta.");
+        redirect(url_home());
+    }
+
+    // Security check
+    identity_require('task-delete', $task);
+
+    // Delete the task
+    task_delete($task);
+
+    flash("Problema a fost stearsa.");
+    redirect(url_home());
+}
+
+
 ?>
Index: www/index.php
===================================================================
--- www/index.php	(revision 956)
+++ www/index.php	(working copy)
@@ -75,6 +75,12 @@
     controller_task_create();
 }
 
+// Task deleter
+else if ($page == 'admin/problema-sterge') {
+    require_once(IA_ROOT_DIR.'www/controllers/task.php');
+    controller_task_delete(request("task_id"));
+}
+
 // Task detail editor
 else if ($urlstart == 'admin' && getattr($pagepath, 1) == 'problema') {
     $obj_id = implode("/", array_slice($pagepath, 2));
Index: www/url.php
===================================================================
--- www/url.php	(revision 956)
+++ www/url.php	(working copy)
@@ -256,6 +256,10 @@
     return url_complex("admin/problema-noua");
 }
 
+function url_task_delete() {
+    return url_complex("admin/problema-sterge");
+}
+
 function url_task_list($page_name, $filter = null) {
     $args = $filter ? array('filtru' => $filter) : array();
     return url_complex($page_name, $args);
Index: www/views/task_edit.php
===================================================================
--- www/views/task_edit.php	(revision 956)
+++ www/views/task_edit.php	(working copy)
@@ -64,6 +64,13 @@
 
 <h1>Editare <a href="<?= html_escape(url_task($view['task_id'])) ?>"><?= html_escape($view['title']) ?></a></h1>
 
+<?php if (identity_can("task-delete", $task)) { ?>
+<form action="<?= html_escape(url_task_delete()) ?>" method="post" style="float: right">
+    <input type="hidden" name="task_id" value="<?= html_escape($task_id) ?>" />
+    <input onclick="return confirm('Aceasta actiune este ireversibila! Doresti sa continui?')") type="submit" value="Sterge problema" id="form_delete" class="button important" />
+</form>
+<?php } ?>
+
 <form action="<?= html_escape(url_task_edit($task_id)) ?>"
       method="post"
       class="task"
