返信する: PC/WEBの話題


オプション

参照

XWORDS にAttachfileを適用
投稿者: なーお 投稿日時: 2008/1/8 2:18

XWORDS に Attachfile を適用

XWORDS-ver0.46にAttachfile-ver1.4を適用してみました。
少々面倒です。

  1.  Attachfileモジュールが、対象をD3モジュール前提な感じなので、少々ごまかしが必要。
    以下の内容のファイル「mytrustdirname.php」をつくり、xwordsのルートディレクトリにコピー。
    1
    2
    3
    
    <?php
    	$mytrustdirname = 'xwords' ;
    ?>
  2.  アクセス権限ファイルの作成
    念のため、ゲストにはアップロード不可に。
    XOOPS_TRUST_PATH/modules/attachfile/plugin/xword/permission.php
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    
    <?php
     
    // ===========================================================================
    // The permission file is necessary in each module.
    // If target module is "D3 module", the permission file is necessary
    // in each directory in XOOPS_TRUST_PATH (not XOOPS_ROOT_PATH).
    //
    // -- argument --
    // 
    // $mydirname			: attachfile's dirname in XOOPS_ROOT_PATH
    // $module_dirname		: target module's dirname in XOOPS_ROOT_PATH
    // $mytrustdirname		: attachfile's dirname in XOOPS_TRUST_PATH
    // $targettrustdirname	: target module's dirname in XOOPS_TRUST_PATH
    // $target_id			: target mosule's contents id (target to attach)
    // 
    // -- return value --
    // 
    // true					: allow access
    // false				: deny access
    // ===========================================================================
     
    function attachfile_check_upload_permission_plugin( $mydirname , $module_dirname , $mytrustdirname , $targettrustdirname , $target_id )
    {
    	global $xoopsUser ;
    	if( $xoopsUser ) {
    		return true; 
    	}
    	else {
    		return false;
    	}
    }
     
    function attachfile_check_download_permission_plugin( $mydirname , $module_dirname , $mytrustdirname , $targettrustdirname , $target_id )
    {
    	return true;
    }
     
    ?>
  3.  xwordsのsubmit.php のハック
    submit.phpの210行目付近
    1
    2
    3
    4
    5
    6
    7
    8
    
    		else
    			{
    			$legenddesc = constant("_MD_{$MYDIRNAME}_SUB_SNEWNAMEDESC2");
    			}
    	      $xoopsTpl -> assign ( 'entryID', $entryID ); //←naao hack この行を追加
    		}
    	else // therez no parameter, so were adding an entry
    		{
  4.  テンプレート編集
    •  xwords_submit.html 45行目付近 (「+」部分を追加)
       1
       2
       3
       4
       5
       6
       7
       8
       9
      10
      
           <{/foreach}>
      +		<tr valign="top" align="left">
      +		<th class="head">
      +		<{attachfile_attach_upload dirname=attachfile label=1}>
      +		</th>
      +		<td class="even">
      +		<{attachfile_attach_upload dirname=attachfile target_id=$entryID}>
      +		</td>
      +		</tr>
         </table>
      23.gif
    •  xwords_entry.html 65行目付近 (「+」部分を追加)
      1
      2
      3
      
         <{$thisterm.term}>
       </h2>
      +<{attachfile_attach_download dirname=attachfile target_id=$com_itemid}>
      24.gif