Changeset 1091 for trunk/common


Ignore:
Timestamp:
12/23/09 00:26:25 (2 years ago)
Author:
bogdan2412
Message:

Many many small fixes.

  • Changed task-tag action from simple-critical to simple-edit.
  • Fixed downloading attachments containing grader from normal (non-task) pages.
  • Moved a call to remote_ip_info() from common/ to www/ where it's supposed to be in MVC.
  • Fixed round and task tests.
  • Fixed test cleanup to delete only the created users and to delete them from the forum also.
  • Check that the username doesn't exist in the forum when someone tries to register (there are users on the forum that are not on infoarena, because of the import from info.devnet.ro i guess). Having two smf users with the same name crashes things.
  • Allow rounds to have no tasks.

Reviewed: http://reviewboard.infoarena.ro/r/126/

Location:
trunk/common
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/common/db/user.php

    r1070 r1091  
    131131// $user must be a valid user struct, user_id ignored 
    132132// Returns created $user or throws up on error. 
    133 function user_create($user) 
     133function user_create($user, $remote_ip_info=null) 
    134134{ 
    135135    log_assert_valid(user_validate($user)); 
     
    150150    $replace = array("user_id" => $user['username']); 
    151151    textblock_copy_replace("template/newuser", IA_USER_TEXTBLOCK_PREFIX.$user['username'], 
    152                            $replace, "public", $new_user['id'], remote_ip_info()); 
     152                           $replace, "public", $new_user['id'], $remote_ip_info); 
    153153 
    154154    // Create SMF user 
  • trunk/common/security.php

    r1087 r1091  
    129129        case 'task-create': 
    130130        case 'task-delete': 
     131        case 'task-tag': 
    131132        case 'round-delete': 
    132133        case 'textblock-delete': 
     
    143144        case 'textblock-change-security': 
    144145        case 'task-edit-owner': 
    145         case 'task-tag': 
    146146        case 'round-tag': 
    147147        case 'textblock-tag': 
     
    280280// FIXME: attach-grader? 
    281281function security_attach($user, $action, $attach) { 
    282  
    283282    $att_name = $attach['name']; 
    284283    $att_page = normalize_page_name($attach['page']); 
     
    296295    } 
    297296 
    298     // HACK: magic prefix. 
    299     if (preg_match('/^grader\_/', $att_name)) { 
     297    // Speed hack: avatars are always visible. This is good. 
     298    if ($action == 'attach-download' && $att_name == 'avatar' && 
     299            starts_with($att_page, IA_USER_TEXTBLOCK_PREFIX)) { 
     300        return true; 
     301    } 
     302 
     303    // Forward to textblock. 
     304    $tb = textblock_get_revision($attach['page']); 
     305    if (!$tb) { 
     306        log_print_r($attach); 
     307    } 
     308    log_assert($tb, "Orphan attachment"); 
     309 
     310    // Convert action into a grader action if the textblock is a task 
     311    // textblock and the attachment has the grader_ prefix. 
     312    if (preg_match("/^ \s* task: \s* (".IA_RE_TASK_ID.") \s* $/xi", $tb["security"]) && 
     313        preg_match('/^grader\_/', $att_name)) { 
    300314        $newaction = preg_replace('/^attach/', 'grader', $action); 
    301315        if (IA_LOG_SECURITY) { 
     
    304318        $action = $newaction; 
    305319    } 
    306  
    307     // Speed hack: avatars are always visible. This is good. 
    308     if ($action == 'attach-download' && $att_name = 'avatar' && 
    309             strstr($att_page, IA_USER_TEXTBLOCK_PREFIX) === $att_page) { 
    310         return true; 
    311     } 
    312  
    313     // Forward to textblock. 
    314     $tb = textblock_get_revision($attach['page']); 
    315     if (!$tb) { 
    316         log_print_r($attach); 
    317     } 
    318     log_assert($tb, "Orphan attachment"); 
    319320 
    320321    return security_textblock($user, $action, $tb); 
Note: See TracChangeset for help on using the changeset viewer.