BugTrack/2184
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
検索
|
最終更新
|
ヘルプ
|
ログイン
]
開始行:
* is_edit_auth() が欲しい [#s5c62ddc]
- ページ: [[BugTrack]]
- 投稿者: [[sonots]]
- 優先順位: 低
- 状態: 完了
- カテゴリー: その他
- 投稿日: 2006-06-25 (日) 04:41:11
- バージョン: 1.4.7
- リリース予定バージョン: 1.5.2
#contents
** 第一弾 [#q4ea43a4]
凍結に対しては is_freeze がありますが、
ほぼ同等の効果のある編集制限に対しては is_edit_auth があ...
プラグインを作成していて欲しいときがあるので、Pukiwiki AP...
//referred lib/auth.php#basic_auth
function is_edit_auth($page, $user = '')
{
global $edit_auth, $edit_auth_pages, $auth_method_type;
if (! $edit_auth) {
return FALSE;
}
// Checked by:
$target_str = '';
if ($auth_method_type == 'pagename') {
$target_str = $page; // Page name
} else if ($auth_method_type == 'contents') {
$target_str = join('', get_source($page)); // Its cont...
}
foreach($edit_auth_pages as $regexp => $users) {
if (preg_match($regexp, $target_str)) {
if ($user == '' || in_array($user, explode(',', $user...
return TRUE;
}
}
}
return FALSE;
}
is_read_auth もあったほうがいいとは思います((1.4.7 前に言...
--------
*** check_editable()で代替可能か [#z68656b8]
- lib/auth.phpのcheck_editable, check_readableで代替可能...
-- いいえ、check_editable は basic_auth を表示してしまい...
-- パスワードを要求するものと、要求しないものの違いです。...
- check_editable($page, false, false); のようにすると tru...
-- いいえ、$auth_flag は basic 認証プロンプトを出すかどう...
-- あ、そのページ自体に何らかの編集制限がかかっているかど...
-- $user はいつか再利用される時を考えてとりあえずつけてお...
-- 第一弾の動作仕様を確認: 第二引数を空欄にした場合、「そ...
//#comment
*** 実装周り [#b236edd6]
- なるほど。何度も呼ばれた時を考えるともう少し軽くできる...
- basic_auth を参考にして作ったものにすぎないので、一つに...
-- なるほど、経緯がわかりました。であれば「この件だけに関...
-- 了解しました。時間を見つけて取り組もうと思います。 -- ...
//#comment
** 第2弾 [#eef3add2]
--- auth.php.orig 2006-06-29 18:01:39.137336000 -0700
+++ auth.php 2006-06-29 18:52:38.930193600 -0700
@@ -170,19 +170,7 @@
{
global $auth_method_type, $auth_users, $_msg_auth;
- // Checked by:
- $target_str = '';
- if ($auth_method_type == 'pagename') {
- $target_str = $page; // Page name
- } else if ($auth_method_type == 'contents') {
- $target_str = join('', get_source($page)); // Its con...
- }
-
- $user_list = array();
- foreach($auth_pages as $key=>$val)
- if (preg_match($key, $target_str))
- $user_list = array_merge($user_list, explode(',', $v...
-
+ $user_list = auth_user_list($page, $auth_pages);
if (empty($user_list)) return TRUE; // No limit
$matches = array();
@@ -224,4 +212,48 @@
return TRUE;
}
}
+
+// is_auth
+function is_edit_auth($page, $user = '')
+{
+ global $edit_auth, $edit_auth_pages;
+ return $edit_auth ? is_auth($page, $user, $edit_auth_p...
+}
+
+function is_read_auth($page, $user = '')
+{
+ global $read_auth, $read_auth_pages;
+ return $read_auth ? is_auth($page, $user, $read_auth_p...
+}
+
+// whether the specified page is restricted and the spe...
+function is_auth($page, $user = '', $auth_pages)
+{
+ global $auth_users;
+ $user_list = auth_user_list($page, $auth_pages);
+ if (empty($user_list)) return FALSE;
+ if ($user == '' || (in_array($user, $user_list) && iss...
+ return FALSE;
+}
+
+function auth_user_list($page, $auth_pages)
+{
+ global $auth_method_type;
+
+ // Checked by:
+ $target_str = '';
+ if ($auth_method_type == 'pagename') {
+ $target_str = $page; // Page name
+ } else if ($auth_method_type == 'contents') {
+ $target_str = join('', get_source($page)); // Its con...
+ }
+
+ $user_list = array();
+ foreach($auth_pages as $key=>$val)
+ if (preg_match($key, $target_str))
+ $user_list = array_merge($user_list, explode(',', $v...
+
+ return $user_list;
+}
+
?>
- とりあえず [[上>#eef3add2]] のようになりました。さらに
@@ -170,8 +170,7 @@
- $user_list = auth_user_list($page, $auth_pages);
- if (empty($user_list)) return TRUE; // No limit
+ if (! is_auth($page, '', $auth_pages)) return TR...
@@ -187,8 +186,7 @@
- ! in_array($_SERVER['PHP_AUTH_USER'], $u...
- ! isset($auth_users[$_SERVER['PHP_AUTH_U...
+ ! is_auth($page, $_SERVER['PHP_AUTH_USER...
ともできるのですが、$user_list を内部的に二度作ることにな...
- 後は$user 引数が必要かどうか、と is_freeze のように sta...
-- キャッシュをもつようにする場合、edit 用バッファと read...
- 第一弾のコードと、第一段へのコメントの中に、第二段のソ...
-- お疲れ様です。お解りかと思いますが、基本は多人数向けの...
- 第二段の実装部分について。関数作成に関する話題になって...
-- (1) そうしたくなったお気持は判るのですが、グローバル変...
-- (2) is_auth() は名称から見ると、is_edit_auth() や is_r...
-- (3) auth_user_list() は仕事ごとに関数が作られていない...
-- うーん、is_auth() がきっちり作られたならば、is_edit_au...
- (1)については、既存の関数の流儀に従ったつもりでした。(2...
-- 最後は、is_edit_auth が is_auth('edit') のように呼ばれ...
-- (3)は何のことかわかりませんが、auth_user_list はキャッ...
-- is_auth($mode = 'edit' | 'read') のような方針でよろし...
- お疲れ様です。auth_user_list() に存在意義が無いか希薄で...
-- $mode に別の文字が与えられる気持ち悪さがあるので、私は...
-- うーん、他の文字ならエラーを返すというのが妥当ではない...
-- 後、「第二段のコードは、関数のインターフェースが設定関...
#comment
***キャッシュ周り [#jd106e65]
-is_freeze では static $is_freeze[$page] だけで済んでいま...
-- 認証関係は現在 edit, read の二種類あり、別々の体系とな...
--- 別々だと考えるのならば、突き詰めると is_edit_auth, is...
-- 「キャッシュ」というのは、本来考えるべきことを避けるた...
--- is_edit_auth は少なくとも is_freeze と同じくらいの呼...
#comment
** 確認: is_edit_auth() / is_auth() の存在意義 [#i654da3f]
- お疲れ様です。そもそも、この関数が必要だったシチュエー...
-- 最初から述べている通り、凍結と同等の意味合いとして使用...
-- せっかくなので、それら3つをまとめた関数を作ってもいい...
- 提案の is_edit_auth(), is_read_auth() に相当する is_pag...
-- これはSession利用のForm認証([[BugTrack/2375]])のためで...
#comment
終了行:
* is_edit_auth() が欲しい [#s5c62ddc]
- ページ: [[BugTrack]]
- 投稿者: [[sonots]]
- 優先順位: 低
- 状態: 完了
- カテゴリー: その他
- 投稿日: 2006-06-25 (日) 04:41:11
- バージョン: 1.4.7
- リリース予定バージョン: 1.5.2
#contents
** 第一弾 [#q4ea43a4]
凍結に対しては is_freeze がありますが、
ほぼ同等の効果のある編集制限に対しては is_edit_auth があ...
プラグインを作成していて欲しいときがあるので、Pukiwiki AP...
//referred lib/auth.php#basic_auth
function is_edit_auth($page, $user = '')
{
global $edit_auth, $edit_auth_pages, $auth_method_type;
if (! $edit_auth) {
return FALSE;
}
// Checked by:
$target_str = '';
if ($auth_method_type == 'pagename') {
$target_str = $page; // Page name
} else if ($auth_method_type == 'contents') {
$target_str = join('', get_source($page)); // Its cont...
}
foreach($edit_auth_pages as $regexp => $users) {
if (preg_match($regexp, $target_str)) {
if ($user == '' || in_array($user, explode(',', $user...
return TRUE;
}
}
}
return FALSE;
}
is_read_auth もあったほうがいいとは思います((1.4.7 前に言...
--------
*** check_editable()で代替可能か [#z68656b8]
- lib/auth.phpのcheck_editable, check_readableで代替可能...
-- いいえ、check_editable は basic_auth を表示してしまい...
-- パスワードを要求するものと、要求しないものの違いです。...
- check_editable($page, false, false); のようにすると tru...
-- いいえ、$auth_flag は basic 認証プロンプトを出すかどう...
-- あ、そのページ自体に何らかの編集制限がかかっているかど...
-- $user はいつか再利用される時を考えてとりあえずつけてお...
-- 第一弾の動作仕様を確認: 第二引数を空欄にした場合、「そ...
//#comment
*** 実装周り [#b236edd6]
- なるほど。何度も呼ばれた時を考えるともう少し軽くできる...
- basic_auth を参考にして作ったものにすぎないので、一つに...
-- なるほど、経緯がわかりました。であれば「この件だけに関...
-- 了解しました。時間を見つけて取り組もうと思います。 -- ...
//#comment
** 第2弾 [#eef3add2]
--- auth.php.orig 2006-06-29 18:01:39.137336000 -0700
+++ auth.php 2006-06-29 18:52:38.930193600 -0700
@@ -170,19 +170,7 @@
{
global $auth_method_type, $auth_users, $_msg_auth;
- // Checked by:
- $target_str = '';
- if ($auth_method_type == 'pagename') {
- $target_str = $page; // Page name
- } else if ($auth_method_type == 'contents') {
- $target_str = join('', get_source($page)); // Its con...
- }
-
- $user_list = array();
- foreach($auth_pages as $key=>$val)
- if (preg_match($key, $target_str))
- $user_list = array_merge($user_list, explode(',', $v...
-
+ $user_list = auth_user_list($page, $auth_pages);
if (empty($user_list)) return TRUE; // No limit
$matches = array();
@@ -224,4 +212,48 @@
return TRUE;
}
}
+
+// is_auth
+function is_edit_auth($page, $user = '')
+{
+ global $edit_auth, $edit_auth_pages;
+ return $edit_auth ? is_auth($page, $user, $edit_auth_p...
+}
+
+function is_read_auth($page, $user = '')
+{
+ global $read_auth, $read_auth_pages;
+ return $read_auth ? is_auth($page, $user, $read_auth_p...
+}
+
+// whether the specified page is restricted and the spe...
+function is_auth($page, $user = '', $auth_pages)
+{
+ global $auth_users;
+ $user_list = auth_user_list($page, $auth_pages);
+ if (empty($user_list)) return FALSE;
+ if ($user == '' || (in_array($user, $user_list) && iss...
+ return FALSE;
+}
+
+function auth_user_list($page, $auth_pages)
+{
+ global $auth_method_type;
+
+ // Checked by:
+ $target_str = '';
+ if ($auth_method_type == 'pagename') {
+ $target_str = $page; // Page name
+ } else if ($auth_method_type == 'contents') {
+ $target_str = join('', get_source($page)); // Its con...
+ }
+
+ $user_list = array();
+ foreach($auth_pages as $key=>$val)
+ if (preg_match($key, $target_str))
+ $user_list = array_merge($user_list, explode(',', $v...
+
+ return $user_list;
+}
+
?>
- とりあえず [[上>#eef3add2]] のようになりました。さらに
@@ -170,8 +170,7 @@
- $user_list = auth_user_list($page, $auth_pages);
- if (empty($user_list)) return TRUE; // No limit
+ if (! is_auth($page, '', $auth_pages)) return TR...
@@ -187,8 +186,7 @@
- ! in_array($_SERVER['PHP_AUTH_USER'], $u...
- ! isset($auth_users[$_SERVER['PHP_AUTH_U...
+ ! is_auth($page, $_SERVER['PHP_AUTH_USER...
ともできるのですが、$user_list を内部的に二度作ることにな...
- 後は$user 引数が必要かどうか、と is_freeze のように sta...
-- キャッシュをもつようにする場合、edit 用バッファと read...
- 第一弾のコードと、第一段へのコメントの中に、第二段のソ...
-- お疲れ様です。お解りかと思いますが、基本は多人数向けの...
- 第二段の実装部分について。関数作成に関する話題になって...
-- (1) そうしたくなったお気持は判るのですが、グローバル変...
-- (2) is_auth() は名称から見ると、is_edit_auth() や is_r...
-- (3) auth_user_list() は仕事ごとに関数が作られていない...
-- うーん、is_auth() がきっちり作られたならば、is_edit_au...
- (1)については、既存の関数の流儀に従ったつもりでした。(2...
-- 最後は、is_edit_auth が is_auth('edit') のように呼ばれ...
-- (3)は何のことかわかりませんが、auth_user_list はキャッ...
-- is_auth($mode = 'edit' | 'read') のような方針でよろし...
- お疲れ様です。auth_user_list() に存在意義が無いか希薄で...
-- $mode に別の文字が与えられる気持ち悪さがあるので、私は...
-- うーん、他の文字ならエラーを返すというのが妥当ではない...
-- 後、「第二段のコードは、関数のインターフェースが設定関...
#comment
***キャッシュ周り [#jd106e65]
-is_freeze では static $is_freeze[$page] だけで済んでいま...
-- 認証関係は現在 edit, read の二種類あり、別々の体系とな...
--- 別々だと考えるのならば、突き詰めると is_edit_auth, is...
-- 「キャッシュ」というのは、本来考えるべきことを避けるた...
--- is_edit_auth は少なくとも is_freeze と同じくらいの呼...
#comment
** 確認: is_edit_auth() / is_auth() の存在意義 [#i654da3f]
- お疲れ様です。そもそも、この関数が必要だったシチュエー...
-- 最初から述べている通り、凍結と同等の意味合いとして使用...
-- せっかくなので、それら3つをまとめた関数を作ってもいい...
- 提案の is_edit_auth(), is_read_auth() に相当する is_pag...
-- これはSession利用のForm認証([[BugTrack/2375]])のためで...
#comment
ページ名: