Index: common/db/user.php
===================================================================
--- common/db/user.php	(revision 1090)
+++ common/db/user.php	(working copy)
@@ -130,7 +130,7 @@
 // This also creates an user page and SMF user.
 // $user must be a valid user struct, user_id ignored
 // Returns created $user or throws up on error.
-function user_create($user)
+function user_create($user, $remote_ip_info=null)
 {
     log_assert_valid(user_validate($user));
 
@@ -149,7 +149,7 @@
     require_once(IA_ROOT_DIR . "common/textblock.php");
     $replace = array("user_id" => $user['username']);
     textblock_copy_replace("template/newuser", IA_USER_TEXTBLOCK_PREFIX.$user['username'],
-                           $replace, "public", $new_user['id'], remote_ip_info());
+                           $replace, "public", $new_user['id'], $remote_ip_info);
 
     // Create SMF user
     require_once(IA_ROOT_DIR."common/db/smf.php");
Index: common/security.php
===================================================================
--- common/security.php	(revision 1090)
+++ common/security.php	(working copy)
@@ -128,6 +128,7 @@
         case 'task-edit':
         case 'task-create':
         case 'task-delete':
+        case 'task-tag':
         case 'round-delete':
         case 'textblock-delete':
         case 'textblock-delete-revision':
@@ -142,7 +143,6 @@
         case 'task-change-open':
         case 'textblock-change-security':
         case 'task-edit-owner':
-        case 'task-tag':
         case 'round-tag':
         case 'textblock-tag':
         case 'job-reeval':
@@ -279,7 +279,6 @@
 // Jump to security_textblock.
 // FIXME: attach-grader?
 function security_attach($user, $action, $attach) {
-
     $att_name = $attach['name'];
     $att_page = normalize_page_name($attach['page']);
     $usersec = getattr($user, 'security_level', 'anonymous');
@@ -295,18 +294,9 @@
                   "(level, action, object)");
     }
 
-    // HACK: magic prefix.
-    if (preg_match('/^grader\_/', $att_name)) {
-        $newaction = preg_replace('/^attach/', 'grader', $action);
-        if (IA_LOG_SECURITY) {
-            log_print("SECURITY: CONVERTING $action to $newaction");
-        }
-        $action = $newaction;
-    }
-
     // Speed hack: avatars are always visible. This is good.
-    if ($action == 'attach-download' && $att_name = 'avatar' &&
-            strstr($att_page, IA_USER_TEXTBLOCK_PREFIX) === $att_page) {
+    if ($action == 'attach-download' && $att_name == 'avatar' &&
+            starts_with($att_page, IA_USER_TEXTBLOCK_PREFIX)) {
         return true;
     }
 
@@ -317,6 +307,17 @@
     }
     log_assert($tb, "Orphan attachment");
 
+    // Convert action into a grader action if the textblock is a task
+    // textblock and the attachment has the grader_ prefix.
+    if (preg_match("/^ \s* task: \s* (".IA_RE_TASK_ID.") \s* $/xi", $tb["security"]) &&
+        preg_match('/^grader\_/', $att_name)) {
+        $newaction = preg_replace('/^attach/', 'grader', $action);
+        if (IA_LOG_SECURITY) {
+            log_print("SECURITY: CONVERTING $action to $newaction");
+        }
+        $action = $newaction;
+    }
+
     return security_textblock($user, $action, $tb);
 }
 
Index: tests/round.php
===================================================================
--- tests/round.php	(revision 1090)
+++ tests/round.php	(working copy)
@@ -73,9 +73,11 @@
         'post' => array(
             'type' => 'classic',
             'rating_update' => true,
+            'start_time' => db_date_format(time() + 3600),
 )));
+log_assert(!strstr($res['content'], '<span class="fieldError"'));
+log_assert(strstr($res['content'], '<option value="classic" selected="selected">Concurs clasic'));
 log_assert_equal($res['url'], url_absolute(url_round_edit('test_round')));
-log_assert(strstr($res['content'], 'Concurs clasic'));
 
 log_print("Admin adds tasks adunare and cmmdc to round.");
 $res = curl_test(array(
@@ -196,7 +198,7 @@
 ));
 log_assert_equal($res['url'], url_absolute(url_textblock('runda/tEst_Round')));
 log_assert(strstr($res['content'], 'xzx-round-title-xzx'));
-log_assert(!strstr($res['content'], 'Nu esti inscris la'), 
+log_assert(!strstr($res['content'], 'Nu esti inscris la'),
     "Round still waiting, is the evaluator ON?");
 log_assert(strstr($res['content'], 'Nu se mai pot face inscrieri'));
 log_assert(!strstr($res['content'], 'Runda s-a incheiat'));
Index: tests/task.php
===================================================================
--- tests/task.php	(revision 1090)
+++ tests/task.php	(working copy)
@@ -38,7 +38,7 @@
         'user' => 'test_helper1',
         'post' => array(
                 'title' => 'xzx-task1-title-xzx',
-                'author' => 'xzx-task1-author-xzx',
+                'tag_author' => 'xzx-task1-author-xzx',
                 'source' => 'xzx-task1-source-xzx',
 )));
 log_assert_equal($res['url'], url_absolute(url_task_edit('test_task1')));
@@ -222,7 +222,7 @@
 log_assert(strstr($res['content'], 'xzx-task1-title-xzx'));
 log_assert(strstr($res['content'], 'xzx-task1-author-xzx'));
 log_assert(strstr($res['content'], 'xzx-task1-source-xzx'));
-log_assert(strstr($res['content'], 'name="author"'));
+log_assert(strstr($res['content'], 'name="tag_author"'));
 log_assert(!strstr($res['content'], 'name="hidden"'));
 
 test_cleanup();
Index: tests/utilities.php
===================================================================
--- tests/utilities.php	(revision 1090)
+++ tests/utilities.php	(working copy)
@@ -65,7 +65,7 @@
     $res = curl_getinfo($ch);
     $res['content'] = $content;
     curl_close($ch);
-   
+
     if (getattr($args, 'validate_html', false)) {
         validate_html($content);
     }
@@ -131,18 +131,20 @@
 // However, tests are only run on a local copy anyway.
 function test_cleanup()
 {
-    db_query("DELETE FROM ia_user WHERE `username` LIKE 'test_%'");
-    db_query("DELETE FROM ia_task WHERE `id` LIKE 'test_%'");
-    db_query("DELETE FROM ia_round WHERE `id` LIKE 'test_%'");
+    $test_accounts = "('test_dudE1', 'teSt_dude2', 'teSt_helper1', 'test_hElper2', 'tEst_adMin')";
+    db_query("DELETE FROM ia_user WHERE `username` IN $test_accounts");
+    db_query("DELETE FROM ia_smf_members WHERE `memberName` IN $test_accounts");
+    db_query("DELETE FROM ia_task WHERE `id` LIKE 'test\_%'");
+    db_query("DELETE FROM ia_round WHERE `id` LIKE 'test\_%'");
     // Remove various stuff from the wiki.
     $prefixes = array('sandbox', 'utilizator', 'runda', 'problema');
     foreach ($prefixes as $prefix) {
         db_query("DELETE FROM `ia_textblock` ".
-                 "WHERE `name` LIKE '$prefix/test_%'");
+                 "WHERE `name` LIKE '$prefix/test\_%'");
         db_query("DELETE FROM `ia_textblock_revision` ".
-                 "WHERE `name` LIKE '$prefix/test_%'");
+                 "WHERE `name` LIKE '$prefix/test\_%'");
         db_query("DELETE FROM `ia_file` ".
-                 "WHERE `page` LIKE '$prefix/test_%'");
+                 "WHERE `page` LIKE '$prefix/test\_%'");
     }
 }
 
Index: www/controllers/account_validator.php
===================================================================
--- www/controllers/account_validator.php	(revision 1090)
+++ www/controllers/account_validator.php	(working copy)
@@ -45,7 +45,8 @@
             $errors['username'] = 'Numele utilizator contine caractere '
                                   .'invalide.';
         }
-        elseif (user_get_by_username($data['username'])) {
+        elseif (user_get_by_username($data['username']) ||
+                smf_get_member_by_name($data['username'])) {
             $errors['username'] = 'Nume utilizator rezervat de altcineva. Va '
                                   .'rugam alegeti altul.';
         }
Index: www/controllers/register.php
===================================================================
--- www/controllers/register.php	(revision 1090)
+++ www/controllers/register.php	(working copy)
@@ -46,7 +46,7 @@
             $user['newsletter'] = $data['newsletter'];
 
             // There are no acceptable errors in user_create.
-            user_create($user);
+            user_create($user, remote_ip_info());
             flash("Felicitari! Contul a fost creat. Acum te poti "
                   ."autentifica.");
             redirect(url_login());
@@ -58,7 +58,7 @@
         $data['newsletter'] = 1;
         $data['tnc'] = 1;
     }
-    
+
     if(!IA_DEVELOPMENT_MODE) {
         $view['captcha'] = recaptcha_get_html(IA_CAPTCHA_PUBLIC_KEY);
     }
Index: www/controllers/round.php
===================================================================
--- www/controllers/round.php	(revision 1090)
+++ www/controllers/round.php	(working copy)
@@ -133,10 +133,6 @@
         }
     }
 
-    if (request_is_post() && count($values['tasks']) == 0) {
-        $errors['tasks'] = "Trebuie sa alegi cel putin o problema";
-    }
-
     // Additional validation for user defined tasks
     if (!array_key_exists('tasks', $errors)
         && $values['type'] == 'user-defined' &&
