こんにちは,五十嵐です.管理用の処理を作成します.本来は管理者権限がある場合にのみアクセスできるべきですが,その点は考慮しつつ,先に作ってしまいます.今回は管理処理の部分のみについて考えます.なお,最初に書き忘れましたが,javascript を off にしているブラウザは対象にしません.かならず,javascript が使用可能なブラウザでアクセスしてください.表示テストには Firefox 2.0 と IE6/7 を使用します.
アクセス用の URL は,"/admin/* " とします.画面遷移と処理は次のようにします.
/admin 下の処理として,user, role, tag, bookmark に対してそれぞれ list, search, delete, edit の処理を行います./admin/ のページには,list と search のリンクを作り,基本的には list ページから delete と edit を呼び出します.
例外的にユーザ admin と,ロール admin, public は削除できないようにします.
リストされたユーザの編集や削除のフォームは,画面を遷移するのではなく,リストされたそれぞれのラインの下にフォームをあらかじめ用意し,style で "display:none;" をしていしてかくしておきます.編集と削除のボタンをクリックすることで,フォームが表れるようにします.フォームから,delete と edit を呼び出します.ここで,javascript が有効ではないブラウザでアクセスすると,編集も削除もできません.
"/admin/" の処理を行うために,Contoroller を作成します.
$ ./script/securesbm_create.pl controller Admin
exists "...(省略)/SecureSBM/script/../lib/SecureSBM/Controller"
exists "...(省略)/SecureSBM/script/../t/Controller"
created "...(省略)/SecureSBM/script/../lib/SecureSBM/Controller/Admin.pm"
created "...(省略)/SecureSBM/script/../t/Controller/Admin.t"
$
これで lib/SecureSBM/Controller/Admin.pm が作成されました.このファイルに変更を加えていきます.管理のコントロールを Admin.pm に集中させることで,後に設定するアクセス管理がしやすくなります.Controller が Admin であるときに,ユーザが admin かどうかを判断することになります.アクセスコントロールの詳細は後日記述します.
同時に,View のテンプレートを作成します.前回のトップページで作成した通り,左右には共通のメニューを作りますので,admin 用のページは,center の部分に表示させます.admin.tt は以下のようになります.
[% INCLUDE top.tt %]
<div class="left" id="left">[% INCLUDE index_left.tt %]
</div><!-- end of left -->
<div class="center" id="center">[% INCLUDE admin_center.tt %]
</div><!-- end of center -->
<div class="right" id="right">[% INCLUDE index_right.tt %]
</div><!-- end of right -->
[% INCLUDE bottom.tt %]
[%#
This Program is distributed under version 1.0 of the Rinza Public
License Agreement, that is bundled with this package in the file
LICENSE, and is available through the website at the following URL:
http://www.tyzoh.jp/rinza/licenses/LICENSE-1.0.txt.
This is the Original Program.
The Initial Developer of the Original Program is Nihon Unisys, Ltd.
The Original Program is copyrighted (C) 2006-2007 by Nihon Unisys, Ltd. with
all rights reserved.
There is NO WARRANTY OF ANY KIND by the Initial Developer of the
Original Program.
%]<div id="admin_center">
<h1>Admin 画面</h1>
ここには Admin 用の画面が入ります.
</div> <!-- end of admin_center -->
[%#
This Program is distributed under version 1.0 of the Rinza Public
License Agreement, that is bundled with this package in the file
LICENSE, and is available through the website at the following URL:
http://www.tyzoh.jp/rinza/licenses/LICENSE-1.0.txt.
This is the Original Program.
The Initial Developer of the Original Program is Nihon Unisys, Ltd.
The Original Program is copyrighted (C) 2006-2007 by Nihon Unisys, Ltd. with
all rights reserved.
There is NO WARRANTY OF ANY KIND by the Initial Developer of the
Original Program.
%]sub index : Private {
my ( $self, $c ) = @_;
$c->stash->{template} = 'admin/admin.tt';
}[info] *** Request 4 (0.053/s) [20768] [Wed Mar 21 18:21:41 2007] ***
[debug] "GET" request for "admin/" from "127.0.0.1"
[debug] Path is "admin/"
[debug] Rendering template "admin.tt"
[info] Request took 1.096074s (0.912/s)
.----------------------------------------------------------------+-----------.
| Action | Time |
+----------------------------------------------------------------+-----------+
| /admin/index | 0.000424s |
| /end | 0.103940s |
| -> SecureSBM::View::TT->process | 0.080338s |
'----------------------------------------------------------------+-----------'
これで,/admin に関しては,プログラム側で行うことは終わりです(あとで,少し調整しますが,それは後日).他は template の方で設定します.
リスト,検索,登録はそれぞれボタンにして,onclick の javascript で動作を設定します.テンプレート(admin_center.tt)の一部は以下のようになります.
<div id="admin_role_admin">
<h2>ロール管理</h2>
<button id="list_roles">リスト</button>
<button id="search_role">検索</button>
<button id="regist_role">登録</button>
<div id="search_role_block" class="hiddenblock">
<br />
<form method="POST" action="/searchrole" id="search_role_form">
ロール名: <input type="text" name="role_name" size="30"> <br />
<div align="right">
<input type="submit" value="検索"><input type="reset" value="クリア">
</div>
</form>
</div><!-- end of search_role_block -->
<div id="regist_role_block" class="hiddenblock">
<br />
<form method="POST" action="/registrole" id="regist_role_form"
name="regist_role_form">
ロール名: <input type="text" name="role_name" size="30"> <br />
<div align="right">
<input type="submit" value="登録"><input type="reset" value="クリア">
</div>
</form>
</div><!-- end of regist_role_block -->
<script type="text/javascript">
<!--
_getObjectById('list_roles').onclick = function(){
location.href = '/admin/listroles';
}
_getObjectById('search_role').onclick = function(){
var search_style = _getObjectById('search_role_block').style;
var regist_style = _getObjectById('regist_role_block').style;
if( search_style.display == "block" ){
search_style.display = "none";
}else{
search_style.display = "block";
regist_style.display = "none";
}
}
_getObjectById('regist_role').onclick = function(){
var search_style = _getObjectById('search_role_block').style;
var regist_style = _getObjectById('regist_role_block').style;
if( regist_style.display == "block" ){
regist_style.display = "none";
}else{
regist_style.display = "block";
search_style.display = "none";
}
}
// -->
</script>
</div><!-- end of admin_role_admin -->
タグ:Secure-SBM
<< TGIF: タイムスリップ | Main | [Secure-SBM:009] データベース管理処理 (2) >>
いかちょー (2007-05-28 11:24) | コメント(0)| トラックバック(6)
トラックバックURL:
月別アーカイブ
Copyright (C) 2004-2011 Nihon Unisys, Ltd. All Rights Reserved.
Powered by Movable Type Open Source