[ 新規 ] [ 検索 | 一覧 | 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()内の変更
-is_frozen()の戻り値が1の時に凍結ページ、2の場合には認証済みページとして扱う

 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()内の変更
-認証用のラジオボタンを追加、値は2とする

 @{[
     $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()内の変更
-info_IsFrozenの値の扱いの変更
-[allow comment in frozen]の条件判断を先にするように変更

 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()内の変更
-info_IsFrozenの値を直接返すように変更

 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]
 }


02403