Changeset 1069

Show
Ignore:
Timestamp:
05/10/08 17:35:35 (7 months ago)
Author:
_ck_
Message:

0.1.1 role check before hooks, ability to disable upload on new posts if compatibility issues

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • bb-attachments/trunk/bb-attachments.php

    r1036 r1069  
    66Author: _ck_ 
    77Author URI: http://bbShowcase.org 
    8 Version: 0.1.0 
     8Version: 0.1.1 
    99 
    1010License: CC-GNU-GPL http://creativecommons.org/licenses/GPL/2.0/ 
     
    4545 
    4646$bb_attachments['path']=dirname($_SERVER['DOCUMENT_ROOT'])."/bb-attachments/";  //  make *NOT* WEB ACCESSABLE for security 
     47 
     48$bb_attachments['upload_on_new']=true;  // allow uploads directly on new posts (set FALSE if incompatible for some reason) 
    4749 
    4850$bb_attachments['icons']=array('default'=>'default.gif','bmp'=>'img.gif','doc'=>'doc.gif','gif'=>'img.gif','gz'=>'zip.gif','jpeg'=>'img.gif','jpg'=>'img.gif','pdf'=>'pdf.gif','png'=>'img.gif','txt'=>'txt.gif','xls'=>'xls.gif','zip'=>'zip.gif'); 
     
    8991        if ($bb_attachments['title']) {add_filter('topic_title', 'bb_attachments_title',200);} 
    9092} 
    91 add_action('post_edit_form','bb_attachments');  // auto-insert on post edit form 
    92 add_action('post_form','bb_attachments_upload_form'); // auto-insert on new post form  
    93 add_action('pre_post_form','bb_attachments_enctype'); // multipart workaround on new post form 
     93 
    9494if ($bb_attachments['style']) {add_action('bb_head', 'bb_attachments_add_css');}        // add css if present (including Kakumei  0.9.0.2 LI fix!) 
    95 
     95 
     96if (bb_current_user_can($bb_attachments['role']['upload'])) { 
     97add_action('post_edit_form','bb_attachments');          // auto-insert on post edit form 
     98 
     99if ($bb_attachments['upload_on_new']) { 
     100add_action('post_form','bb_attachments_upload_form');    // auto-insert on new post form  
     101add_action('pre_post_form','bb_attachments_enctype');    // multipart workaround on new post form 
    96102 
    97103// insane bbPress workaround - adds multipart enctype to the new post form via uri patch 
     
    99105function bb_attachments_uri($uri) {remove_filter( 'bb_get_option_uri','bb_attachments_uri',999);  
    100106                                        return $uri. 'bb-post.php"  enctype="multipart/form-data" hack="';}  
     107} 
     108}                                        
     109} 
    101110 
    102111function bb_attachments_add_css() { global $bb_attachments;  echo '<style type="text/css">'.$bb_attachments['style'].'</style>';} // inject css 
  • bb-attachments/trunk/readme.txt

    r1032 r1069  
    5050* 0.0.9 no longer necessary to edit `edit-post.php` template if using bbPress 0.9.0.2 or newer 
    5151* 0.1.0 uploading now possible directly on new posts (instead of only attaching afterwards) 
     52* 0.1.1 role check before hooks, ability to disable upload on new posts if compatibility issues 
    5253         
    5354== To Do ==