• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Aucun tag

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

PukiWiki


Commit MetaInfo

Révision441743dc6d32b9573f08dfe3091a66e60fa0e464 (tree)
l'heure2006-04-11 02:37:08
Auteurteanan <teanan>
Commiterteanan

Message de Log

BugTrack2/170: Added rename function.

Change Summary

Modification

--- a/en.lng.php
+++ b/en.lng.php
@@ -1,6 +1,6 @@
11 <?php
22 // 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 $
44 // Copyright (C)
55 // 2002-2005 PukiWiki Developers Team
66 // 2001-2002 Originally written by yu-ji
@@ -145,6 +145,7 @@ $_attach_messages = array(
145145 'msg_deleted' => 'Deleted the file in $1',
146146 'msg_freezed' => 'The file has been frozen.',
147147 'msg_unfreezed'=> 'The file has been unfrozen',
148+ 'msg_renamed' => 'The file has been renamed',
148149 'msg_upload' => 'Upload to $1',
149150 'msg_info' => 'File information',
150151 'msg_confirm' => '<p>Delete %s.</p>',
@@ -160,6 +161,8 @@ $_attach_messages = array(
160161 'msg_freeze' => 'Freeze file.',
161162 'msg_unfreeze' => 'Unfreeze file.',
162163 'msg_isfreeze' => 'File is frozen.',
164+ 'msg_rename' => 'Rename',
165+ 'msg_newname' => 'New file name',
163166 'msg_require' => '(require administrator password)',
164167 'msg_filesize' => 'size',
165168 'msg_date' => 'date',
@@ -173,6 +176,7 @@ $_attach_messages = array(
173176 'err_notfound' => 'Could not fid the file in $1',
174177 'err_noexist' => 'File does not exist.',
175178 'err_delete' => 'Cannot delete file in $1',
179+ 'err_rename' => 'Cannot rename this file',
176180 'err_password' => 'Wrong password.',
177181 'err_adminpass'=> 'Wrong administrator password',
178182 'btn_upload' => 'Upload',
--- a/ja.lng.php
+++ b/ja.lng.php
@@ -1,6 +1,6 @@
11 <?php
22 // 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 $
44 // Copyright (C)
55 // 2002-2005 PukiWiki Developers Team
66 // 2001-2002 Originally written by yu-ji
@@ -147,6 +147,7 @@ $_attach_messages = array(
147147 'msg_deleted' => '$1 からファイルを削除しました',
148148 'msg_freezed' => '添付ファイルを凍結しました。',
149149 'msg_unfreezed'=> '添付ファイルを凍結解除しました。',
150+ 'msg_renamed' => '添付ファイルの名前を変更しました。',
150151 'msg_upload' => '$1 への添付',
151152 'msg_info' => '添付ファイルの情報',
152153 'msg_confirm' => '<p>%s を削除します。</p>',
@@ -162,6 +163,8 @@ $_attach_messages = array(
162163 'msg_freeze' => 'このファイルを凍結します。',
163164 'msg_unfreeze' => 'このファイルを凍結解除します。',
164165 'msg_isfreeze' => 'このファイルは凍結されています。',
166+ 'msg_rename' => '名前を変更します。',
167+ 'msg_newname' => '新しい名前',
165168 'msg_require' => '(管理者パスワードが必要です)',
166169 'msg_filesize' => 'サイズ',
167170 'msg_date' => '登録日時',
@@ -175,6 +178,7 @@ $_attach_messages = array(
175178 'err_notfound' => '$1 にそのファイルは見つかりません',
176179 'err_noexist' => '添付ファイルがありません。',
177180 'err_delete' => '$1 からファイルを削除できませんでした',
181+ 'err_rename' => 'ファイル名を変更できませんでした',
178182 'err_password' => 'パスワードが一致しません。',
179183 'err_adminpass'=> '管理者パスワードが一致しません。',
180184 'btn_upload' => 'アップロード',
--- a/plugin/attach.inc.php
+++ b/plugin/attach.inc.php
@@ -1,8 +1,8 @@
11 <?php
22 // 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 $
44 // Copyright (C)
5-// 2003-2005 PukiWiki Developers Team
5+// 2003-2006 PukiWiki Developers Team
66 // 2002-2003 PANDA <panda@arino.jp> http://home.arino.jp/
77 // 2002 Y.MASUI <masui@hisec.co.jp> http://masui.net/pukiwiki/
88 // 2001-2002 Originally written by yu-ji
@@ -32,6 +32,9 @@ define('PLUGIN_ATTACH_DELETE_ADMIN_NOBACKUP', TRUE); // FALSE or TRUE
3232 // アップロード/削除時にパスワードを要求する(ADMIN_ONLYが優先)
3333 define('PLUGIN_ATTACH_PASSWORD_REQUIRE', FALSE); // FALSE or TRUE
3434
35+// 添付ファイル名を変更できるようにする
36+define('PLUGIN_ATTACH_RENAME_ENABLE', TRUE); // FALSE or TRUE
37+
3538 // ファイルのアクセス権
3639 define('PLUGIN_ATTACH_FILE_MODE', 0644);
3740 //define('PLUGIN_ATTACH_FILE_MODE', 0604); // for XREA.COM
@@ -118,6 +121,7 @@ function plugin_attach_action()
118121 case 'list' : return attach_list();
119122 case 'freeze' : return attach_freeze(TRUE);
120123 case 'unfreeze' : return attach_freeze(FALSE);
124+ case 'rename' : return attach_rename();
121125 case 'upload' : return attach_showform();
122126 }
123127 if ($page == '' || ! is_page($page)) {
@@ -275,6 +279,26 @@ function attach_freeze($freeze)
275279 }
276280 }
277281
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+
278302 // ダウンロード
279303 function attach_open()
280304 {
@@ -502,6 +526,7 @@ class AttachFile
502526 $s_file = htmlspecialchars($this->file);
503527 $s_err = ($err == '') ? '' : '<p style="font-weight:bold">' . $_attach_messages[$err] . '</p>';
504528
529+ $msg_rename = '';
505530 if ($this->age) {
506531 $msg_freezed = '';
507532 $msg_delete = '<input type="radio" name="pcmd" id="_p_attach_delete" value="delete" />' .
@@ -525,6 +550,16 @@ class AttachFile
525550 $msg_freeze = '<input type="radio" name="pcmd" id="_p_attach_freeze" value="freeze" />' .
526551 '<label for="_p_attach_freeze">' . $_attach_messages['msg_freeze'] .
527552 $_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 />&nbsp;&nbsp;&nbsp;&nbsp;' .
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+ }
528563 }
529564 }
530565 $info = $this->toString(TRUE, FALSE);
@@ -556,6 +591,8 @@ $s_err
556591 <input type="hidden" name="age" value="{$this->age}" />
557592 $msg_delete
558593 $msg_freeze
594+ $msg_rename
595+ <br />
559596 <label for="_p_attach_password">{$_attach_messages['msg_password']}:</label>
560597 <input type="password" name="pass" id="_p_attach_password" size="8" />
561598 <input type="submit" value="{$_attach_messages['btn_submit']}" />
@@ -617,6 +654,31 @@ EOD;
617654 return array('msg'=>$_attach_messages['msg_deleted']);
618655 }
619656
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+
620682 function freeze($freeze, $pass)
621683 {
622684 global $_attach_messages;