Index: common/db/textblock.php
===================================================================
--- common/db/textblock.php	(revision 1027)
+++ common/db/textblock.php	(working copy)
@@ -71,6 +71,34 @@
     return db_query($query);
 }
 
+// Delete $revision from database
+// The revision is identified by name and timestamp
+// $curr is true if $revision is the current revision and false otherwise
+function textblock_delete_revision($revision, $curr)
+{
+    if ($curr == false) {
+        $name = $revision['name'];
+        $timestamp = $revision['timestamp'];
+        $query = "DELETE FROM `ia_textblock_revision` 
+            WHERE `name` = ".db_quote($name)." && 
+                `timestamp` = ".db_quote($timestamp);
+        db_query($query);
+    } else {
+        $name = $revision['name'];
+        $query = "REPLACE INTO `ia_textblock` 
+                    (SELECT * FROM `ia_textblock_revision` 
+                    WHERE `name` = ".db_quote($name)." 
+                    ORDER BY `timestamp` DESC LIMIT 1)";
+        db_query($query);
+
+        //delete last_rev from ia_textblock_revision
+        $query = "DELETE FROM `ia_textblock_revision` 
+                WHERE `name` = ".db_quote($name)." 
+                ORDER BY `timestamp` DESC LIMIT 1";
+        db_query($query);
+    }
+}
+
 // This is the function called by most query functions.
 function textblock_complex_query($options)
 {
Index: common/security.php
===================================================================
--- common/security.php	(revision 1027)
+++ common/security.php	(working copy)
@@ -130,6 +130,7 @@
         case 'task-delete':
         case 'round-delete':
         case 'textblock-delete':
+        case 'textblock-delete-revision':
         case 'grader-overwrite':
         case 'grader-delete':
         case 'grader-rename':
Index: www/controllers/textblock.php
===================================================================
--- www/controllers/textblock.php	(revision 1027)
+++ www/controllers/textblock.php	(working copy)
@@ -208,10 +208,51 @@
     } else {
         // Missing page.
         flash_error("Pagina inexistenta.");
+        redirect(url_home);
     }
     textblock_delete($page_name);
     flash("Pagina a fost stearsa.");
     redirect(url_home());
 }
 
+// Delete a certain revision
+function controller_textblock_delete_revision($page = null, $rev_num = null) {
+    if (!request_is_post()) {
+        flash_error("Pagina nu a putut fi stearsa");
+        redirect(url_textblock($page));
+    }
+
+    if ($page == null) {
+        flash_error("Nu a fost specificata pagina");
+        redirect(url_home());
+    }
+    if ($rev_num == null) {
+        flash_error("Nu a fost specificat numarul reviziei");
+        redirect(url_home());
+    }
+
+    $total_revs = textblock_get_revision_count($page);
+    if ($rev_num > $total_revs) {
+        flash_error("Nu exista revizia");
+        redirect(url_home());
+    }
+
+    if ($total_revs == 1) {
+        textblock_delete($page);
+    }
+
+    $revision = textblock_get_revision($page, $rev_num == $total_revs ? null : $rev_num);
+    if ($revision) {
+        identity_require('textblock-delete-revision', $revision);
+    } else {
+        flash_error("Revizie inexistenta");
+        redirect(url_home());
+    }
+
+    textblock_delete_revision($revision, $rev_num == $total_revs);
+
+    flash("Revizia a fost stearsa");
+    redirect(url_textblock_history($page));
+}
+
 ?>
Index: www/index.php
===================================================================
--- www/index.php	(revision 1027)
+++ www/index.php	(working copy)
@@ -152,6 +152,15 @@
     require_once(IA_ROOT_DIR.'www/controllers/textblock.php');
     controller_textblock_delete($page);
 }
+// - delete textblock revision
+else if ($action == 'delete-revision') {
+    require_once(IA_ROOT_DIR.'www/controllers/textblock.php');
+
+    $rev = request('revision');
+    $rev_cnt = request('revision_count');
+    controller_textblock_delete_revision($page, $rev, $rev_cnt);
+}
+
 //  - view textblock history
 else if ($action == 'history') {
     require_once(IA_ROOT_DIR.'www/controllers/textblock.php');
Index: www/url.php
===================================================================
--- www/url.php	(revision 1027)
+++ www/url.php	(working copy)
@@ -128,7 +128,7 @@
 function url_textblock_delete_revision($page_name, $rev) {
     return url_complex($page_name, array(
             'action' => 'delete-revision',
-            'revision' => $rev,
+            'revision' => $rev
     ));
 }
 
Index: www/views/revision_warning.php
===================================================================
--- www/views/revision_warning.php	(revision 1027)
+++ www/views/revision_warning.php	(working copy)
@@ -17,4 +17,10 @@
         echo "Revizia urmatoare";
     }
     ?>
+    &nbsp;
+    <?php
+    if (identity_can('textblock-delete-revision', $view['textblock'])) {
+        echo format_post_link(url_textblock_delete_revision($view['page_name'], $view['revision']), "Sterge");
+    }
+    ?>
 </div>
Index: www/views/textblock_history.php
===================================================================
--- www/views/textblock_history.php	(revision 1027)
+++ www/views/textblock_history.php	(working copy)
@@ -3,6 +3,7 @@
 require_once(IA_ROOT_DIR . "www/format/table.php");
 require_once(IA_ROOT_DIR . "www/format/format.php");
 require_once(IA_ROOT_DIR . "www/format/form.php");
+require_once(IA_ROOT_DIR . "common/db/textblock.php");
 ?>
 
 <h1>Istoria paginii <?= format_link(url_textblock($page_name), $page_name) ?></h1>
@@ -36,12 +37,13 @@
     $delurl = url_textblock_delete_revision($page_name, $row['revision_id']);
     $viewurl = url_textblock_revision($page_name, $row['revision_id']);
     if ($row['revision_id'] == $total_entries) {
-        return '<strong>Ultima versiune</strong>';
+        $ret = '<strong>Ultima versiune</strong> ['. format_post_link($delurl, "Sterge") .']';
+        return $ret;
     } else {
-        return  '['. format_link($diffurl, "Compara cu ultima revizie") .'] '.
+        return '['. format_link($diffurl, "Compara cu ultima revizie") .'] '.
                 '['. format_post_link($resturl, "Inlocuieste") .'] '.
-                '['. format_link($viewurl, "Vezi") .'] '/*.
-                '['. format_link($delurl, "Sterge") .']'*/;
+                '['. format_link($viewurl, "Vezi") .'] '.
+                '['. format_post_link($delurl, "Sterge") .']';
     }
 }
 
