PukiWiki
Révision | 441743dc6d32b9573f08dfe3091a66e60fa0e464 (tree) |
---|---|
l'heure | 2006-04-11 02:37:08 |
Auteur | teanan <teanan> |
Commiter | teanan |
BugTrack2/170: Added rename function.
@@ -1,6 +1,6 @@ | ||
1 | 1 | <?php |
2 | 2 | // PukiWiki - Yet another WikiWikiWeb clone. |
3 | -// $Id: en.lng.php,v 1.14 2006/01/09 12:09:57 henoheno Exp $ | |
3 | +// $Id: en.lng.php,v 1.15 2006/04/10 17:36:56 teanan Exp $ | |
4 | 4 | // Copyright (C) |
5 | 5 | // 2002-2005 PukiWiki Developers Team |
6 | 6 | // 2001-2002 Originally written by yu-ji |
@@ -145,6 +145,7 @@ $_attach_messages = array( | ||
145 | 145 | 'msg_deleted' => 'Deleted the file in $1', |
146 | 146 | 'msg_freezed' => 'The file has been frozen.', |
147 | 147 | 'msg_unfreezed'=> 'The file has been unfrozen', |
148 | + 'msg_renamed' => 'The file has been renamed', | |
148 | 149 | 'msg_upload' => 'Upload to $1', |
149 | 150 | 'msg_info' => 'File information', |
150 | 151 | 'msg_confirm' => '<p>Delete %s.</p>', |
@@ -160,6 +161,8 @@ $_attach_messages = array( | ||
160 | 161 | 'msg_freeze' => 'Freeze file.', |
161 | 162 | 'msg_unfreeze' => 'Unfreeze file.', |
162 | 163 | 'msg_isfreeze' => 'File is frozen.', |
164 | + 'msg_rename' => 'Rename', | |
165 | + 'msg_newname' => 'New file name', | |
163 | 166 | 'msg_require' => '(require administrator password)', |
164 | 167 | 'msg_filesize' => 'size', |
165 | 168 | 'msg_date' => 'date', |
@@ -173,6 +176,7 @@ $_attach_messages = array( | ||
173 | 176 | 'err_notfound' => 'Could not fid the file in $1', |
174 | 177 | 'err_noexist' => 'File does not exist.', |
175 | 178 | 'err_delete' => 'Cannot delete file in $1', |
179 | + 'err_rename' => 'Cannot rename this file', | |
176 | 180 | 'err_password' => 'Wrong password.', |
177 | 181 | 'err_adminpass'=> 'Wrong administrator password', |
178 | 182 | 'btn_upload' => 'Upload', |
@@ -1,6 +1,6 @@ | ||
1 | 1 | <?php |
2 | 2 | // PukiWiki - Yet another WikiWikiWeb clone. |
3 | -// $Id: ja.lng.php,v 1.13 2006/01/09 12:09:57 henoheno Exp $ | |
3 | +// $Id: ja.lng.php,v 1.14 2006/04/10 17:36:56 teanan Exp $ | |
4 | 4 | // Copyright (C) |
5 | 5 | // 2002-2005 PukiWiki Developers Team |
6 | 6 | // 2001-2002 Originally written by yu-ji |
@@ -147,6 +147,7 @@ $_attach_messages = array( | ||
147 | 147 | 'msg_deleted' => '$1 からファイルを削除しました', |
148 | 148 | 'msg_freezed' => '添付ファイルを凍結しました。', |
149 | 149 | 'msg_unfreezed'=> '添付ファイルを凍結解除しました。', |
150 | + 'msg_renamed' => '添付ファイルの名前を変更しました。', | |
150 | 151 | 'msg_upload' => '$1 への添付', |
151 | 152 | 'msg_info' => '添付ファイルの情報', |
152 | 153 | 'msg_confirm' => '<p>%s を削除します。</p>', |
@@ -162,6 +163,8 @@ $_attach_messages = array( | ||
162 | 163 | 'msg_freeze' => 'このファイルを凍結します。', |
163 | 164 | 'msg_unfreeze' => 'このファイルを凍結解除します。', |
164 | 165 | 'msg_isfreeze' => 'このファイルは凍結されています。', |
166 | + 'msg_rename' => '名前を変更します。', | |
167 | + 'msg_newname' => '新しい名前', | |
165 | 168 | 'msg_require' => '(管理者パスワードが必要です)', |
166 | 169 | 'msg_filesize' => 'サイズ', |
167 | 170 | 'msg_date' => '登録日時', |
@@ -175,6 +178,7 @@ $_attach_messages = array( | ||
175 | 178 | 'err_notfound' => '$1 にそのファイルは見つかりません', |
176 | 179 | 'err_noexist' => '添付ファイルがありません。', |
177 | 180 | 'err_delete' => '$1 からファイルを削除できませんでした', |
181 | + 'err_rename' => 'ファイル名を変更できませんでした', | |
178 | 182 | 'err_password' => 'パスワードが一致しません。', |
179 | 183 | 'err_adminpass'=> '管理者パスワードが一致しません。', |
180 | 184 | 'btn_upload' => 'アップロード', |
@@ -1,8 +1,8 @@ | ||
1 | 1 | <?php |
2 | 2 | // PukiWiki - Yet another WikiWikiWeb clone |
3 | -// $Id: attach.inc.php,v 1.80 2005/12/18 15:27:43 henoheno Exp $ | |
3 | +// $Id: attach.inc.php,v 1.81 2006/04/10 17:37:08 teanan Exp $ | |
4 | 4 | // Copyright (C) |
5 | -// 2003-2005 PukiWiki Developers Team | |
5 | +// 2003-2006 PukiWiki Developers Team | |
6 | 6 | // 2002-2003 PANDA <panda@arino.jp> http://home.arino.jp/ |
7 | 7 | // 2002 Y.MASUI <masui@hisec.co.jp> http://masui.net/pukiwiki/ |
8 | 8 | // 2001-2002 Originally written by yu-ji |
@@ -32,6 +32,9 @@ define('PLUGIN_ATTACH_DELETE_ADMIN_NOBACKUP', TRUE); // FALSE or TRUE | ||
32 | 32 | // アップロード/削除時にパスワードを要求する(ADMIN_ONLYが優先) |
33 | 33 | define('PLUGIN_ATTACH_PASSWORD_REQUIRE', FALSE); // FALSE or TRUE |
34 | 34 | |
35 | +// 添付ファイル名を変更できるようにする | |
36 | +define('PLUGIN_ATTACH_RENAME_ENABLE', TRUE); // FALSE or TRUE | |
37 | + | |
35 | 38 | // ファイルのアクセス権 |
36 | 39 | define('PLUGIN_ATTACH_FILE_MODE', 0644); |
37 | 40 | //define('PLUGIN_ATTACH_FILE_MODE', 0604); // for XREA.COM |
@@ -118,6 +121,7 @@ function plugin_attach_action() | ||
118 | 121 | case 'list' : return attach_list(); |
119 | 122 | case 'freeze' : return attach_freeze(TRUE); |
120 | 123 | case 'unfreeze' : return attach_freeze(FALSE); |
124 | + case 'rename' : return attach_rename(); | |
121 | 125 | case 'upload' : return attach_showform(); |
122 | 126 | } |
123 | 127 | if ($page == '' || ! is_page($page)) { |
@@ -275,6 +279,26 @@ function attach_freeze($freeze) | ||
275 | 279 | } |
276 | 280 | } |
277 | 281 | |
282 | +// リネーム | |
283 | +function attach_rename() | |
284 | +{ | |
285 | + global $vars, $_attach_messages; | |
286 | + | |
287 | + foreach (array('refer', 'file', 'age', 'pass', 'newname') as $var) { | |
288 | + ${$var} = isset($vars[$var]) ? $vars[$var] : ''; | |
289 | + } | |
290 | + | |
291 | + if (is_freeze($refer) || ! is_editable($refer)) { | |
292 | + return array('msg'=>$_attach_messages['err_noparm']); | |
293 | + } | |
294 | + $obj = & new AttachFile($refer, $file, $age); | |
295 | + if (! $obj->getstatus()) | |
296 | + return array('msg'=>$_attach_messages['err_notfound']); | |
297 | + | |
298 | + return $obj->rename($pass, $newname); | |
299 | + | |
300 | +} | |
301 | + | |
278 | 302 | // ダウンロード |
279 | 303 | function attach_open() |
280 | 304 | { |
@@ -502,6 +526,7 @@ class AttachFile | ||
502 | 526 | $s_file = htmlspecialchars($this->file); |
503 | 527 | $s_err = ($err == '') ? '' : '<p style="font-weight:bold">' . $_attach_messages[$err] . '</p>'; |
504 | 528 | |
529 | + $msg_rename = ''; | |
505 | 530 | if ($this->age) { |
506 | 531 | $msg_freezed = ''; |
507 | 532 | $msg_delete = '<input type="radio" name="pcmd" id="_p_attach_delete" value="delete" />' . |
@@ -525,6 +550,16 @@ class AttachFile | ||
525 | 550 | $msg_freeze = '<input type="radio" name="pcmd" id="_p_attach_freeze" value="freeze" />' . |
526 | 551 | '<label for="_p_attach_freeze">' . $_attach_messages['msg_freeze'] . |
527 | 552 | $_attach_messages['msg_require'] . '</label><br />'; |
553 | + | |
554 | + if (PLUGIN_ATTACH_RENAME_ENABLE) { | |
555 | + $msg_rename = '<input type="radio" name="pcmd" id="_p_attach_rename" value="rename" />' . | |
556 | + '<label for="_p_attach_rename">' . $_attach_messages['msg_rename'] . | |
557 | + $_attach_messages['msg_require'] . '</label><br /> ' . | |
558 | + '<label for="_p_attach_newname">' . $_attach_messages['msg_newname'] . | |
559 | + ':</label> ' . | |
560 | + '<input type="test" name="newname" id="_p_attach_newname" size="40" value="' . | |
561 | + $this->file . '" /><br />'; | |
562 | + } | |
528 | 563 | } |
529 | 564 | } |
530 | 565 | $info = $this->toString(TRUE, FALSE); |
@@ -556,6 +591,8 @@ $s_err | ||
556 | 591 | <input type="hidden" name="age" value="{$this->age}" /> |
557 | 592 | $msg_delete |
558 | 593 | $msg_freeze |
594 | + $msg_rename | |
595 | + <br /> | |
559 | 596 | <label for="_p_attach_password">{$_attach_messages['msg_password']}:</label> |
560 | 597 | <input type="password" name="pass" id="_p_attach_password" size="8" /> |
561 | 598 | <input type="submit" value="{$_attach_messages['btn_submit']}" /> |
@@ -617,6 +654,31 @@ EOD; | ||
617 | 654 | return array('msg'=>$_attach_messages['msg_deleted']); |
618 | 655 | } |
619 | 656 | |
657 | + function rename($pass, $newname) | |
658 | + { | |
659 | + global $_attach_messages, $notify, $notify_subject; | |
660 | + | |
661 | + if ($this->status['freeze']) return attach_info('msg_isfreeze'); | |
662 | + | |
663 | + if (! pkwk_login($pass)) { | |
664 | + if (PLUGIN_ATTACH_DELETE_ADMIN_ONLY || $this->age) { | |
665 | + return attach_info('err_adminpass'); | |
666 | + } else if (PLUGIN_ATTACH_PASSWORD_REQUIRE && | |
667 | + md5($pass) != $this->status['pass']) { | |
668 | + return attach_info('err_password'); | |
669 | + } | |
670 | + } | |
671 | + $newbase = UPLOAD_DIR . encode($this->page) . '_' . encode($newname); | |
672 | + if (file_exists($newbase)) { | |
673 | + return array('msg'=>$_attach_messages['err_exists']); | |
674 | + } | |
675 | + if (! PLUGIN_ATTACH_RENAME_ENABLE || ! rename($this->basename, $newbase)) { | |
676 | + return array('msg'=>$_attach_messages['err_rename']); | |
677 | + } | |
678 | + | |
679 | + return array('msg'=>$_attach_messages['msg_renamed']); | |
680 | + } | |
681 | + | |
620 | 682 | function freeze($freeze, $pass) |
621 | 683 | { |
622 | 684 | global $_attach_messages; |