[ 新規 | 編集 | 差分 ] [ 検索 | 一覧 | FrontPage ] [ 履歴 (RSS) | 差分履歴 (RSS) ] [ ログイン ]
【PR】Amazon | SL-C3000 | SL-C1000(3/18発売!) | SL-C860 | SL-6000W | SL-6000L | SL-6000N

WalWiki/カスタマイズ/管理者による認証機能

編集

[certified]

編集

info_IsFrozenを下記の様に拡張して扱う。

状態info_IsFrozen編集bodyタグのclass
通常0誰でも編集可能normal
凍結1管理者のみ編集可能frozen
認証済み2誰でも編集可能だが、編集をすると通常状態に遷移certified

resource.txtへの追加

編集
certifybutton認証する

グローバル変数定義

編集
# yakty add [certified] start
my $frozen_frozen = 1;                                                          # yakty add [certified]
my $frozen_certified = 2;                                                       # yakty add [certified]
# yakty add [certified] end

print_header()内の変更

編集
sub print_header {
    my ($page) = @_;
    my $bodyclass = "normal";
    my $editable = 0;
    my $admineditable = 0;
    my $frozen = &is_frozen($page);                                        # yakty add [certified]
    #if (&is_frozen($page) and $form{mycmd} =~ /^(read|write)$/) {         # yakty del [certified]
    if( $frozen == $frozen_frozen and $form{mycmd} =~ /^(read|write)$/) {  # yakty add [certified]
        $editable = 0;
        $admineditable = 1;
        $bodyclass = "frozen";
    # Walrus add [edit admin only] start
    } elsif (&is_editable($page) and $edit_admin_only and $form{mycmd} =~ /^(read|write)$/) {
        $editable = 0;
        $admineditable = 1;
    # Walrus add [edit admin only] end
    } elsif (&is_editable($page) and $form{mycmd} =~ /^(read|write)$/) {
        $admineditable = 1;
        $editable = 1;
        # yakty add [certified] start
        if($frozen == $frozen_certified){
            $bodyclass = "certified";
        }
        # yakty add [certified] end
    } else {
        $editable = 0;
    }

do_edit()内の変更

編集
sub do_edit {
    # Walrus add [edit admin only] start
    if ($edit_admin_only) {
        &do_adminedit;
        return;
    }
    # Walrus add [edit admin only] end
    my ($page) = &unarmor_name(&armor_name($form{mypage}));
    &print_header($page);
    if (not &is_editable($page)) {
        &print_message($resource{cantchange});
    #} elsif (&is_frozen($page)) {                                     # yakty del [certified]
    } elsif (&is_frozen($page) == $frozen_frozen) {                    # yakty add [certified]
        &print_message($resource{cantchange});
    # Walrus add [part edit] start
    } elsif ($form{mypart} =~ /^\d+$/ and $form{mypart}) {
        my $mymsg = (&read_by_part($page))[$form{mypart} - 1];
        &print_editform($mymsg, &get_info($page, $info_LastModified), admin=>0);
    # Walrus add [part edit] end
    } else {
        &print_editform($database{$page}, &get_info($page, $info_LastModified), admin=>0);
    }
    &print_footer($page);
}

print_editform()内の変更

編集
@{[
    $mode{admin} ?
    # yakty del [certified] start
    #qq(
    #<input type="radio" name="myfrozen" value="1" @{[$frozen ? qq(checked="checked") : ""]}>$resource{frozenbutton}
    #<input type="radio" name="myfrozen" value="0" @{[$frozen ? "" : qq(checked="checked")]}>$resource{notfrozenbutton}<br>)
    # yakty del [certified] end
    # yakty add [certtified] start
    qq(
    <input type="radio" name="myfrozen" value="2" @{[($frozen == 2) ? qq(checked="checked") : ""]}>$resource{certifybutton}
    <input type="radio" name="myfrozen" value="1" @{[($frozen == 1) ? qq(checked="checked") : ""]}>$resource{frozenbutton}
    <input type="radio" name="myfrozen" value="0" @{[$frozen ? "" : qq(checked="checked")]}>$resource{notfrozenbutton}<br>)
    # yakty add [certified] end
    : ""
]}

frozen_reject()内の変更

編集
sub frozen_reject {
    my ($isfrozen) = &get_info($form{mypage}, $info_IsFrozen);
    my ($willbefrozen) = $form{myfrozen};
    #if (not $isfrozen and not $willbefrozen) {     # yakty del [certified] 
    if ($allow_comment_in_frozen and $form{'mycmd'} eq 'comment' and not $willbefrozen) {  # yakty add [certified]
        $form{myfrozen} = $isfrozen;                                                       # yakty add [certified]
        # You need no check.
        return 0;
    # Walrus add [allow comment in frozen] start
    #} elsif ($allow_comment_in_frozen and $form{'mycmd'} eq 'comment' and not $willbefrozen) { # yakty del [certified]
    #    $form{myfrozen} = $isfrozen;                                                           # yakty del [certified]
    } elsif (not $isfrozen == $frozen_frozen and not $willbefrozen){                            # yakty add [certified]
        return 0;
    # Walrus add [allow comment in frozen] end
    } elsif (valid_password($form{mypassword})) {
        # You are admin.
        return 0;
    } else {
        &print_error($resource{passworderror});
        return 1;
    }
}

is_frozen()内の変更

編集
sub is_frozen {
    my ($page) = @_;
    # yakty del [certified]
    #if (&get_info($page, $info_IsFrozen)) {
    #    return 1;
    #} else {
    #    return 0;
    #}
    # yakty del [certifled]
    return &get_info($page, $info_IsFrozen);        # yakty add [certified]
}

01972