diff -r 1e40b33f2e3e -r c949e82b8f49 index.php --- a/index.php Mon Apr 13 12:32:36 2009 -0400 +++ b/index.php Mon Apr 13 14:43:28 2009 -0400 @@ -329,39 +329,92 @@ $template->footer(); break; case 'protect': - if (!isset($_REQUEST['level'])) die_friendly('Invalid request', '

No protection level specified

'); - require_once(ENANO_ROOT.'/includes/pageutils.php'); - if(!empty($_POST['reason'])) + if ( isset($_POST['level']) && isset($_POST['reason']) ) { - if(!preg_match('#^([0-2]*){1}$#', $_POST['level'])) die_friendly('Error protecting page', '

Request validation failed

'); - PageUtils::protect($paths->page_id, $paths->namespace, intval($_POST['level']), $_POST['reason']); + $level = intval($_POST['level']); + if ( !in_array($level, array(PROTECT_FULL, PROTECT_SEMI, PROTECT_NONE)) ) + { + $errors[] = 'bad level'; + } + $reason = trim($_POST['reason']); + if ( empty($reason) ) + { + $errors[] = $lang->get('onpage_protect_err_need_reason'); + } - die_friendly($lang->get('page_protect_lbl_success_title'), '

' . $lang->get('page_protect_lbl_success_body', array( 'page_link' => makeUrl($paths->page) )) . '

'); + $page = new PageProcessor($paths->page_id, $paths->namespace); + $result = $page->protect_page($level, $reason); + if ( $result['success'] ) + { + redirect(makeUrl($paths->page), $lang->get('page_protect_lbl_success_title'), $lang->get('page_protect_lbl_success_body', array('page_link' => makeUrl($paths->page, false, true))), 3); + } + else + { + $errors[] = $lang->get('page_err_' . $result['error']); + } } $template->header(); ?>
- - ' . $lang->get('page_protect_err_need_reason') . '

'; ?> -

get('page_protect_lbl_reason'); ?>

-


- get('page_protect_lbl_level'); ?> get('page_protect_lbl_level_none'); - break; - case '1': - echo $lang->get('page_protect_lbl_level_full'); - break; - case '2': - echo $lang->get('page_protect_lbl_level_semi'); - break; - default: - echo 'None; Warning: request validation will fail after clicking submit'; - } - ?>

-

+

get('onpage_protect_heading'); ?>

+

get('onpage_protect_msg_select_level'); ?>

+ +
  • ' . implode('
  • ', $errors) . '
  • '; + } + ?> + +
    + +
    +
    + get('onpage_protect_btn_full_hint'); ?> +
    + +
    + +
    +
    + get('onpage_protect_btn_semi_hint'); ?> +
    + +
    + +
    +
    + get('onpage_protect_btn_none_hint'); ?> +
    + + + + + + +
    + get('onpage_protect_lbl_reason'); ?> + +
    + get('onpage_protect_lbl_reason_hint'); ?> +
    + +

    + + get('etc_cancel'); ?> +

    footer();