Plugin Directory

Changeset 615301


Ignore:
Timestamp:
10/21/2012 04:39:13 PM (13 years ago)
Author:
fabifott
Message:

WP-Filebase 0.2.9.24

  • Added field to rename files in file upload form
  • Configuration of old File Widget will be retained on update. Please change to the new multi-instance widget after updating!
  • New Option Inaccessible category message
  • Improved access permission handling for AJAX tree
  • Fixed OpenOffice download link
  • New template variable %cat_user_can_access% and %file_user_can_access%
  • Files are only re-scanned if changed
  • Fixed external MD5 hashing on Windows
  • MySQL connection are closed during download
  • New Template varialbe %file_cat_folder%
  • Added sync debug info when query variable debug is set to 1 (add &debug=1 to the sync page URL and see the HTML source for backtrace)
  • Inaccessible categories are displayed in lists, but their content cannot be viewed
  • Fixed resources URL when using SSL
Location:
wp-filebase
Files:
625 added
28 edited

Legend:

Unmodified
Added
Removed
  • wp-filebase/trunk/classes/Admin.php

    r599590 r615301  
    2727    if($upload_path_base == '' || $upload_path_base == '/')
    2828        $upload_path_base = 'wp-content/uploads';
    29    
     29       
     30    $last_sync_time = intval(get_option(WPFB_OPT_NAME.'_cron_sync_time'));
     31    $last_sync_time = ($last_sync_time > 0) ? (" (".sprintf( __('Last cron sync on %1$s at %2$s.',WPFB), date_i18n( get_option( 'date_format', $last_sync_time ) ), date_i18n( get_option( 'time_format', $last_sync_time ) ) ).")") : '';
     32       
    3033    return array (
    3134   
     
    9295    'inaccessible_msg'      => array('default' => __('You are not allowed to access this file!', WPFB), 'title' => __('Inaccessible file message', WPFB), 'type' => 'text', 'size' => 65, 'desc' => (__('This message will be displayed if users try to download a file they cannot access', WPFB).'. '.__('You can enter a URL to redirect users.', WPFB))),
    9396    'inaccessible_redirect' => array('default' => false, 'title' => __('Redirect to login', WPFB), 'type' => 'checkbox', 'desc' => __('Guests trying to download inaccessible files are redirected to the login page if this option is enabled.', WPFB)),
     97    'cat_inaccessible_msg'  => array('default' => __('Access to category denied!', WPFB), 'title' => __('Inaccessible category message', WPFB), 'type' => 'text', 'size' => 65, 'desc' => (__('This message will be displayed if users try to access a category without permission.', WPFB))),
    9498    'login_redirect_src'    => array('default' => false, 'title' => __('Redirect to referring page after login', WPFB), 'type' => 'checkbox', 'desc' => __('Users are redirected to the page where they clicked on the download link after logging in.', WPFB)),
    9599   
     
    116120    //'file_context_menu'   => array('default' => true, 'title' => '', 'type' => 'checkbox', 'desc' => ''),
    117121   
    118     'cron_sync' => array('default' => false, 'title' => __('Automatic Sync', WPFB), 'type' => 'checkbox', 'desc' => __('Schedules a cronjob to hourly synchronize the filesystem and the database.', WPFB)),
     122    'cron_sync' => array('default' => false, 'title' => __('Automatic Sync', WPFB), 'type' => 'checkbox', 'desc' => __('Schedules a cronjob to hourly synchronize the filesystem and the database.', WPFB).$last_sync_time),
     123   
    119124   
    120125    'search_integration' =>  array('default' => true, 'title' => __('Search Integration', WPFB), 'type' => 'checkbox', 'desc' => __('Searches in attached files and lists the associated posts and pages when searching the site.', WPFB)),
     
    127132   
    128133    // file browser
    129     'disable_footer_credits'  => array('default' => false, 'title' => __('Remove WP-Filebase Footer credits', WPFB), 'type' => 'checkbox', 'desc' => sprintf(__('This disables the footer credits only displayed on <a href="%s">File Browser Page</a>. Why should you keep the credits? Every backlink helps WP-Filebase to get more popular, popularity motivates the developer to continue work on the plugin. Win-Win!', WPFB), get_permalink(WPFB_Core::GetOpt('file_browser_post_id')).'#wpfb-credits')),
     134    'disable_footer_credits'  => array('default' => false, 'title' => __('Remove WP-Filebase Footer credits', WPFB), 'type' => 'checkbox', 'desc' => sprintf(__('This disables the footer credits only displayed on <a href="%s">File Browser Page</a>. Why should you keep the credits? Every backlink helps WP-Filebase to get more popular, popularity motivates the developer to continue work on the plugin.', WPFB), get_permalink(WPFB_Core::GetOpt('file_browser_post_id')).'#wpfb-credits')),
    130135    'footer_credits_style'  => array('default' => 'margin:0 auto 2px auto; text-align:center; font-size:11px;', 'title' => __('Footer credits Style', WPFB), 'type' => 'text', 'class' => 'code', 'desc' => __('Set custom CSS style for WP-Filebase footer credits',WPFB),'size'=>80),
    131136    'late_script_loading'   => array('default' => false, 'title' => __('Late script loading', WPFB), 'type' => 'checkbox', 'desc' => __('Scripts will be included in content, not in header. Enable if your AJAX tree view does not work properly.', WPFB)),
     
    144149Java|java|http://www.java.com/download/
    145150Flash|flash|http://get.adobe.com/flashplayer/
    146 Open Office|ooffice|http://download.openoffice.org/
     151Open Office|ooffice|http://www.openoffice.org/download/index.html
    147152.NET Framework 3.5|.net35|http://www.microsoft.com/downloads/details.aspx?FamilyID=333325fd-ae52-4e35-b531-508d977d32a6",
    148153    'title' => __('Requirements', WPFB), 'type' => 'textarea', 'desc' => $multiple_entries_desc . ' ' . __('You can optionally add |<i>URL</i> to each line to link to the required software/file.', WPFB), 'nowrap' => true),
     
    150155    'custom_fields'         => array('default' => "Custom Field 1|cf1\nCustom Field 2|cf2", 'title' => __('Custom Fields'), 'type' => 'textarea', 'desc' =>
    151156    __('With custom fields you can add even more file properties.',WPFB).' '.$multiple_entries_desc),
     157   
     158   
    152159   
    153160   
     
    237244   
    238245    //'cat_required_level'  => __('The minimum user level to view this category (-1 = guest, 0 = Subscriber ...)', WPFB),
     246    'cat_user_can_access'   => sprintf(__('Variable to check if the %s is accessible (boolean 0/1)', WPFB),__('Category')),
    239247   
    240248    'cat_id'                => __('The category ID', WPFB),
     
    271279   
    272280    //'file_required_level' => __('The minimum user level to download this file (-1 = guest, 0 = Subscriber ...)', WPFB),
     281    'file_user_can_access'  => sprintf(__('Variable to check if the %s is accessible (boolean 0/1)', WPFB),__('File',WPFB)),
     282   
    273283    'file_offline'          => __('1 if file is offline, otherwise 0', WPFB),
    274284    'file_direct_linking'   => __('1 if direct linking is allowed, otherwise 0', WPFB),
     
    436446    // explicitly set permissions:
    437447    if(!empty($data->cat_perm_explicit) && isset($data->cat_user_roles))
    438         $cat->SetUserRoles((empty($data->cat_user_roles) || count(array_filter($data->cat_user_roles)) == 0) ? array() : $data->cat_user_roles);   
     448        $cat->SetReadPermissions((empty($data->cat_user_roles) || count(array_filter($data->cat_user_roles)) == 0) ? array() : $data->cat_user_roles); 
    439449   
    440450    // apply permissions to children
    441451    if($update && !empty($cat_child_apply_perm))
    442452    {
    443         $cur = $cat->GetUserRoles();
     453        $cur = $cat->GetReadPermissions();
    444454        $childs = $cat->GetChildFiles(true);
    445         foreach($childs as $child) $child->SetUserRoles($cur);
     455        foreach($childs as $child) $child->SetReadPermissions($cur);
    446456       
    447457        $childs = $cat->GetChildCats(true);
    448         foreach($childs as $child) $child->SetUserRoles($cur);
     458        foreach($childs as $child) $child->SetReadPermissions($cur);
    449459    }
    450460       
     
    572582   
    573583    // this sets permissions as well:
    574     $result = $file->ChangeCategoryOrName($file_category, $file_name, $add_existing, !empty($data->overwrite));
     584    $result = $file->ChangeCategoryOrName($file_category, empty($data->file_rename) ? $file_name : $data->file_rename, $add_existing, !empty($data->overwrite));
    575585    if(!empty($result['error'])) return $result;
    576586   
    577587    // explicitly set permissions:
    578588    if(!empty($data->file_perm_explicit) && isset($data->file_user_roles))
    579         $file->SetUserRoles((empty($data->file_user_roles) || count(array_filter($data->file_user_roles)) == 0) ? array() : $data->file_user_roles);   
     589        $file->SetReadPermissions((empty($data->file_user_roles) || count(array_filter($data->file_user_roles)) == 0) ? array() : $data->file_user_roles); 
    580590
    581591    // if there is an uploaded file
     
    614624        $file->file_size = filesize($file->GetLocalPath());
    615625        $file->file_mtime = filemtime($file->GetLocalPath());
     626        $old_hash = $file->file_hash;
    616627        $file->file_hash = WPFB_Admin::GetFileHash($file->GetLocalPath());
    617628       
    618         wpfb_loadclass('GetID3');
    619         $file_info = WPFB_GetID3::AnalyzeFile($file);
     629        // only analyze files if changed!
     630        if($upload || !$update || $file->file_hash != $old_hash)
     631        {
     632            wpfb_loadclass('GetID3');
     633            $file_info = WPFB_GetID3::AnalyzeFile($file);
    620634               
    621         if(!empty($file_info['comments']['picture'][0]['data']))
    622             $cover_img =& $file_info['comments']['picture'][0]['data'];
    623         elseif(!empty($file_info['id3v2']['APIC'][0]['data']))
    624             $cover_img =& $file_info['id3v2']['APIC'][0]['data'];
    625         else $cover_img = null;
    626        
    627         if(!$upload_thumb && empty($data->file_thumbnail) && !empty($cover_img))
    628         {
    629             $cover = $file->GetLocalPath();
    630             $cover = substr($cover,0,strrpos($cover,'.')).'.jpg';
    631             file_put_contents($cover, $cover_img);
    632             $file->CreateThumbnail($cover, true);
    633             @unlink($cover);
     635            if(!empty($file_info['comments']['picture'][0]['data']))
     636                $cover_img =& $file_info['comments']['picture'][0]['data'];
     637            elseif(!empty($file_info['id3v2']['APIC'][0]['data']))
     638                $cover_img =& $file_info['id3v2']['APIC'][0]['data'];
     639            else $cover_img = null;
     640           
     641            if(!$upload_thumb && empty($data->file_thumbnail) && !empty($cover_img))
     642            {
     643                $cover = $file->GetLocalPath();
     644                $cover = substr($cover,0,strrpos($cover,'.')).'.jpg';
     645                file_put_contents($cover, $cover_img);
     646                $file->CreateThumbnail($cover, true);
     647                @unlink($cover);
     648            }
    634649        }
    635650    }
     
    654669    if(!isset($data->file_direct_linking))
    655670        $data->file_direct_linking = 1; // allow direct linking by default
    656     $file->file_direct_linking = (int)!empty($data->file_direct_linking);
     671    $file->file_direct_linking = intval($data->file_direct_linking);
    657672
    658673    if(isset($data->file_post_id))
     
    981996    WPFB_Core::UpdateOption('template_file_parsed', WPFB_TplLib::Parse(WPFB_Core::GetOpt('template_file')));
    982997    WPFB_Core::UpdateOption('template_cat_parsed', WPFB_TplLib::Parse(WPFB_Core::GetOpt('template_cat')));
    983    
    984     // parse widget
    985     $widget = WPFB_Core::GetOpt('widget'); 
    986     $widget['filelist_template_parsed'] = WPFB_TplLib::Parse($widget['filelist_template']);
    987     WPFB_Core::UpdateOption('widget', $widget);
    988998       
    989999    // parse custom
     
    10711081}
    10721082
     1083
    10731084// this is used for post filter
    10741085public function ProcessWidgetUpload(){ 
    10751086    $content = '';
    10761087    $title = '';
    1077    
     1088
    10781089    if(!WPFB_Core::GetOpt('frontend_upload') && !current_user_can('upload_files'))
    10791090        wp_die(__('Cheatin&#8217; uh?'). " (disabled)");
    10801091
    1081         $nonce_action = $_POST['prefix']."=&cat=".((int)$_POST['cat'])."&overwrite=".((int)$_POST['overwrite']);
    1082 
    1083     // nonce/referer check (security)
    1084     if(!wp_verify_nonce($_POST['wpfb-file-nonce'],$nonce_action) || !check_admin_referer($nonce_action,'wpfb-file-nonce'))
    1085         wp_die(__('Cheatin&#8217; uh?') . ' (nonce)');
     1092    {
     1093        $nonce_action = $_POST['prefix']."=&cat=".((int)$_POST['cat'])."&overwrite=".((int)$_POST['overwrite'])."&file_post_id=".((int)$_POST['file_post_id']);
     1094        // nonce/referer check (security)
     1095        if(!wp_verify_nonce($_POST['wpfb-file-nonce'],$nonce_action) || !check_admin_referer($nonce_action,'wpfb-file-nonce'))
     1096            wp_die(__('Cheatin&#8217; uh?') . ' (nonce)');
     1097    }
    10861098       
    10871099    // if category is set in widget options, force to use this. security done with nonce checking ($_POST['cat'] is reliable)
     
    11891201}
    11901202
    1191 static function RolesCheckList($field_name, $selected_roles=array()) {
     1203static function RolesCheckList($field_name, $selected_roles=array(), $display_everyone=true) {
    11921204    global $wp_roles;
    11931205    $all_roles = $wp_roles->roles;
     
    11981210    <ul id="<?php echo $field_name; ?>-list" class="wpfilebase-roles-checklist">
    11991211<?php
    1200     echo "<li id='{$field_name}_none'><label class='selectit'><input value='' type='checkbox' name='{$field_name}[]' id='in-{$field_name}_none' ".(empty($selected_roles)?"checked='checked'":"")." onchange=\"jQuery('[id^=in-$field_name-]').prop('disabled', this.checked).prop('checked', false);\" /> <i>".__('Everyone',WPFB)."</i></label></li>";
     1212    if($display_everyone) echo "<li id='{$field_name}_none'><label class='selectit'><input value='' type='checkbox' name='{$field_name}[]' id='in-{$field_name}_none' ".(empty($selected_roles)?"checked='checked'":"")." onchange=\"jQuery('[id^=in-$field_name-]').prop('disabled', this.checked).prop('checked', false);\" /> <i>".__('Everyone',WPFB)."</i></label></li>";
    12011213    foreach ( $all_roles as $role => $details ) {
    12021214        $name = translate_user_role($details['name']);
    1203         echo "<li id='$field_name-$role'><label class='selectit'><input value='$role' type='checkbox' name='{$field_name}[]' id='in-$field_name-$role' ".(in_array($role, $selected_roles)?"checked='checked'":"")." ".(empty($selected_roles)?"disabled='disabled'":"")." /> $name</label></li>";
    1204     }
    1205     ?>
     1215        echo "<li id='$field_name-$role'><label class='selectit'><input value='$role' type='checkbox' name='{$field_name}[]' id='in-$field_name-$role' ".(in_array($role, $selected_roles)?"checked='checked'":"")." ".((empty($selected_roles)&&$display_everyone)?"disabled='disabled'":"")." /> $name</label></li>";
     1216    }
     1217?>
    12061218    </ul>
    12071219</div>
     
    12211233}
    12221234
     1235static function GetTmpPath($name) {
     1236    $dir = WPFB_Core::UploadDir().'/.tmp/'.uniqid($name);
     1237    self::Mkdir($dir);
     1238    return $dir;
     1239}
     1240
    12231241static function LockUploadDir($lock=true)
    12241242{
     
    12371255    static $use_php_func = false;
    12381256    if($use_php_func) return md5_file($filename);
    1239     $hash = substr(@exec("md5sum \"$filename\""), 0, 32);
     1257    $hash = substr(trim(substr(@exec("md5sum \"$filename\""), 0, 33),"\\ \t"), 0, 32); // on windows, hash starts with \ if not in same dir!
    12401258    if(empty($hash) && file_exists($filename)) {
    12411259        $use_php_func = true;
     
    12451263}
    12461264
    1247 }
     1265static function CurUserCanUpload()
     1266{
     1267    return (current_user_can('upload_files'));
     1268}
     1269
     1270static function CurUserCanCreateCat()
     1271{
     1272    return  current_user_can('manage_categories');
     1273}
     1274}
  • wp-filebase/trunk/classes/AdminGuiCats.php

    r559064 r615301  
    66    $cat_id = $cat->cat_id;
    77    $parent_cat = $cat->GetParent();
    8     $user_roles = $cat->GetUserRoles();
     8    $user_roles = $cat->GetReadPermissions();
    99    $title = esc_attr($cat->cat_name);
    1010    if($sub_level > 0) $title = str_repeat('-', $sub_level) . " $title";
     
    3131    global $wpdb, $user_ID;
    3232   
     33    if ( !WPFB_Admin::CurUserCanCreateCat() )
     34        wp_die(__('Cheatin&#8217; uh?'));
     35   
    3336    wpfb_loadclass('Category', 'File', 'Admin', 'Output');
    3437   
     
    5356    switch($action)
    5457    {
    55         case 'editcat':
    56             if ( !current_user_can('manage_categories') )
    57                 wp_die(__('Cheatin&#8217; uh?'));
    58                
     58        case 'editcat':             
    5959            $cat_id = (int)$_GET['cat_id'];
    6060            $file_category = &WPFB_Category::GetCat($cat_id);
     
    6868        case 'addcat':
    6969            $update = !empty($update);
    70             if ( !current_user_can('manage_categories') )
    71                 wp_die(__('Cheatin&#8217; uh?'/*def*/));
    7270           
    7371            $result = WPFB_Admin::InsertCategory(array_merge(stripslashes_deep($_POST), $_FILES));
     
    8078            //wp_redirect($clean_uri . '&action=manage_cats&message=' . urlencode($message));
    8179       
    82         default:
    83             if(!current_user_can('manage_categories'))
    84                 wp_die(__('Cheatin&#8217; uh?'/*def*/));
    85                
     80        default:               
    8681            if(!empty($_POST['deleteit']))
    8782            {
    8883                foreach ( (array) $_POST['delete'] as $cat_id ) {
    89                     if(is_object($cat = WPFB_Category::GetCat($cat_id)))
     84                    if(is_object($cat = WPFB_Category::GetCat($cat_id)) && $cat->CurUserCanEdit())
    9085                        $cat->Delete();
    9186                }
  • wp-filebase/trunk/classes/AdminGuiFiles.php

    r590827 r615301  
    2626    if(isset($_GET['exform'])) {
    2727        $exform = (!empty($_GET['exform']) && $_GET['exform'] == 1);
    28         update_user_option($user_ID, WPFB_OPT_NAME . '_exform', $exform);
     28        update_user_option($user_ID, WPFB_OPT_NAME . '_exform', $exform?1:0);
    2929    } else {
    30         $exform = (bool)get_user_option(WPFB_OPT_NAME . '_exform');
     30        $exform = (get_user_option(WPFB_OPT_NAME . '_exform') === 1);
    3131    }
    3232   
     
    6262
    6363        case 'updatefile':
     64            if(!current_user_can('upload_files')) wp_die(__('Cheatin&#8217; uh?'));
    6465            $file_id = (int)$_POST['file_id'];
    6566            $update = true;
     
    6970        case 'addfile':
    7071            $update = !empty($update);
    71            
     72       
    7273            if ( !current_user_can('upload_files') )
    7374                wp_die(__('Cheatin&#8217; uh?'));
    74                
    75             /* // this was causing some trouble...
    76             foreach ( array('aa', 'mm', 'jj', 'hh', 'mn') as $timeunit ) {
    77                 if ( !empty($_POST['hidden_' . $timeunit] ) && $_POST['hidden_' . $timeunit] != $_POST[$timeunit] ) {
    78                     $edit_date = true;
    79                     break;
    80                 }
    81             }*/
    8275           
    8376            extract($_POST);
     
    9891            }
    9992
    100         default:       
     93        default:
    10194            if(!current_user_can('upload_files'))
    10295                wp_die(__('Cheatin&#8217; uh?'));
     
    116109    ?></h2>
    117110    <?php if ( !empty($message) ) : ?><div id="message" class="updated fade"><p><?php echo $message; ?></p></div><?php endif;
    118     if($action == 'addfile' || $action == 'updatefile')
     111    if(WPFB_Admin::CurUserCanUpload() && ($action == 'addfile' || $action == 'updatefile'))
    119112    {
    120113        unset($file);
     
    200193                       
    201194                    $cat = $file->GetParent();
    202                     $user_roles = $file->GetUserRoles();
     195                    $user_roles = $file->GetReadPermissions();
    203196                ?>
    204197                <tr id='file-<?php echo $file_id ?>'<?php if($file->file_offline) { echo " class='offline'"; } ?>>
    205198                            <th scope='row' class='check-column'><input type='checkbox' name='delete[]' value='<?php echo $file_id ?>' /></th>
    206199                            <td class="num"><?php echo $file_id ?></td>
    207                             <td class="wpfilebase-admin-list-row-title"><a class='row-title' href='<?php echo esc_attr($file->GetEditUrl()) ?>' title='&quot;<?php echo esc_attr($file->file_display_name); ?>&quot; bearbeiten'>
     200                            <td class="wpfilebase-admin-list-row-title">
     201                            <a class='row-title' href='<?php echo esc_attr($file->GetEditUrl()) ?>' title='&quot;<?php echo esc_attr($file->file_display_name); ?>&quot; bearbeiten'>
    208202                            <?php if(!empty($file->file_thumbnail)) { ?><img src="<?php echo esc_attr($file->GetIconUrl()); ?>" height="32" /><?php } ?>
    209203                            <span><?php if($file->IsRemote()){echo '*';} echo esc_html($file->file_display_name); ?></span>
     
    233227<?php
    234228
    235     if($action != 'addfile' && $action != 'updatefile')
     229    if($action != 'addfile' && $action != 'updatefile' && WPFB_Admin::CurUserCanUpload())
    236230    {
    237231        unset($file);
  • wp-filebase/trunk/classes/AdminGuiManage.php

    r599972 r615301  
    4242    </script>   
    4343    <div class="wrap">
     44    <div id="icon-wpfilebase" class="icon32"><br /></div>
    4445    <h2><?php echo WPFB_PLUGIN_NAME; ?></h2>
    4546   
     
    7273               
    7374                if(!empty($error_msg)) echo '<div class="error default-password-nag"><p>'.$error_msg.'</p></div>';             
     75               
    7476                    if(WPFB_Core::GetOpt('tag_conv_req')) {
    7577                    echo '<div class="updated"><p><a href="'.add_query_arg('action', 'convert-tags').'">';
    7678                    _e('WP-Filebase content tags must be converted',WPFB);
    7779                    echo '</a></p></div><div style="clear:both;"></div>';
     80                }
     81               
     82                if(!get_post(WPFB_Core::GetOpt('file_browser_post_id'))) {
     83                    echo '<div class="updated"><p>';
     84                    printf(__('File Browser post or page not set! Some features like search will not work. <a href="%s">Click here to set the File Browser Post ID.</a>',WPFB), esc_attr(admin_url('admin.php?page=wpfilebase_sets#'.sanitize_title(__('File Browser',WPFB)))));
     85                    echo '</p></div><div style="clear:both;"></div>';
    7886                }
    7987               
     
    168176                array('action' => 'sync',
    169177                )); ?>" class="button"><?php _e('Sync Filebase',WPFB)?></a> &nbsp; <?php _e('Synchronises the database with the file system. Use this to add FTP-uploaded files.',WPFB) ?></p>
    170 <p><a href="<?php echo add_query_arg('action', 'convert-tags') ?>" class="button"><?php _e('Convert old Tags',WPFB)?></a> &nbsp; <?php printf(__('Convert tags from versions earlier than %s.',WPFB), '0.2.0') ?></p>
     178<?php if(WPFB_Core::GetOpt('tag_conv_req')) { ?><p><a href="<?php echo add_query_arg('action', 'convert-tags') ?>" class="button"><?php _e('Convert old Tags',WPFB)?></a> &nbsp; <?php printf(__('Convert tags from versions earlier than %s.',WPFB), '0.2.0') ?></p> <?php } ?>
    171179<!--  <p><a href="<?php echo add_query_arg('action', 'add-urls') ?>" class="button"><?php _e('Add multiple URLs',WPFB)?></a> &nbsp; <?php _e('Add multiple remote files at once.', WPFB); ?></p>
    172180-->
    173181
    174             <?php WPFB_Admin::PrintForm('file', null, array('exform' => $exform)) ?>
     182<?php
     183    if(WPFB_admin::CurUserCanUpload()) WPFB_Admin::PrintForm('file', null, array('exform' => $exform));
     184?>
    175185           
    176186        <?php
  • wp-filebase/trunk/classes/AdminGuiSettings.php

    r598768 r615301  
    5555                    case 'roles':
    5656                        $post[$opt_tag] = array_values(array_filter($post[$opt_tag]));
     57                        // the following must not be removed! if the roles array is empty, permissions are assumed to be set for everyone!
     58                        // so make sure that the admin is explicitly set!
     59                        if(!empty($opt_data['not_everyone']) && !in_array('administrator', $post[$opt_tag])) {
     60                            if(!is_array($post[$opt_tag])) $post[$opt_tag] = array();
     61                            array_unshift($post[$opt_tag],'administrator');
     62                        }
    5763                        break;
    5864                   
     
    183189
    184190<div class="wrap">
     191<div id="icon-options-general" class="icon32"><br /></div>
    185192<h2><?php echo WPFB_PLUGIN_NAME; echo ' '; _e("Settings"/*def*/); ?></h2>
    186193
     
    199206        __('Common', WPFB)                  => array('upload_path','search_integration' /*'cat_drop_down'*/),
    200207        __('Display', WPFB)                 => array('file_date_format','thumbnail_size','auto_attach_files', 'attach_loop','attach_pos', 'filelist_sorting', 'filelist_sorting_dir', 'filelist_num', /* TODO: remove? 'parse_tags_rss',*/ 'decimal_size_format'),
    201         __('File Browser',WPFB)             => array('file_browser_post_id','file_browser_cat_sort_by','file_browser_cat_sort_dir','file_browser_file_sort_by','file_browser_file_sort_dir','file_browser_fbc', 'late_script_loading','disable_footer_credits','footer_credits_style'),
     208        __('File Browser',WPFB)             => array('file_browser_post_id','file_browser_cat_sort_by','file_browser_cat_sort_dir','file_browser_file_sort_by','file_browser_file_sort_dir','file_browser_fbc', 'late_script_loading',
     209        'disable_footer_credits','footer_credits_style',
     210        ),
    202211        __('Download', WPFB)                => array(
    203212                                                'disable_permalinks', 'download_base', 'force_download', 'range_download', 'http_nocache', 'ignore_admin_dls', 'accept_empty_referers','allowed_referers','dl_destroy_session'),
    204213        __('Form Presets', WPFB)            => array('default_author','default_roles', 'default_cat', 'languages', 'platforms', 'licenses', 'requirements', 'custom_fields'),
    205214        __('Limits', WPFB)                  => array('bitrate_unregistered', 'bitrate_registered', 'traffic_day', 'traffic_month', 'traffic_exceeded_msg', 'file_offline_msg', 'daily_user_limits', 'daily_limit_subscriber', 'daily_limit_contributor', 'daily_limit_author', 'daily_limit_editor', 'daily_limit_exceeded_msg'),
    206         __('Security', WPFB)                => array('allow_srv_script_upload', 'frontend_upload', 'hide_inaccessible', 'inaccessible_msg', 'inaccessible_redirect', 'login_redirect_src', 'protect_upload_path', 'private_files'),
     215        __('Security', WPFB)                => array('allow_srv_script_upload', 'frontend_upload', 'hide_inaccessible', 'inaccessible_msg', 'inaccessible_redirect', 'cat_inaccessible_msg', 'login_redirect_src', 'protect_upload_path', 'private_files'),
    207216        __('Templates and Scripts', WPFB)   => array('template_file', 'template_cat', 'dlclick_js'),
    208217        __('Misc')                          => $misc_tags,
     
    274283                   
    275284                case 'roles':
    276                     WPFB_Admin::RolesCheckList($opt_tag, $opt_val);
     285                    WPFB_Admin::RolesCheckList($opt_tag, $opt_val, empty($field_data['not_everyone']));
    277286                    break;
    278287                   
  • wp-filebase/trunk/classes/AdminGuiTpls.php

    r598768 r615301  
    248248        <th scope="row" class="check-column"><input type="checkbox" name="tpl[]" value="<?php echo esc_attr($tpl_tag) ?>" /></th>
    249249        <td class="column-title">
    250             <strong><a class="row-title" href="<?php echo $edit_link ?>" title="<?php printf(__('Edit &#8220;%s&#8221;'), $tpl_tag) ?>"><?php echo __(__(esc_html(WPFB_Output::Filename2Title($tpl_tag))), WPFB) ?></a></strong>
     250            <strong><a class="row-title" href="<?php echo $edit_link ?>" title="<?php printf(__('Edit &#8220;%s&#8221;'), $tpl_tag) ?>"><?php echo self::TplTitle($tpl_tag); ?></a></strong>
    251251            <div class="row-actions"><span class='edit'><a href="<?php echo $edit_link ?>" title="<?php _e('Edit this item') ?>"><?php _e('Edit') ?></a></span>
    252252            <?php if(!in_array($tpl_tag, self::$protected_tags)){ ?><span class='trash'>| <a class='submitdelete' title='<?php _e('Delete this item permanently') ?>' href='<?php echo add_query_arg(array('action'=>'del','type'=>$type,'tpl'=>$tpl_tag)).'#'.$type ?>'><?php _e('Delete') ?></a></span><?php } ?>
     
    290290    }
    291291?>
    292 <h2><?php _e($new?'Add Template' : 'Edit Template', WPFB) ?></h2>
     292<h2><?php _e($new?'Add Template' : 'Edit Template', WPFB);
     293        if(!empty($tpl_tag)) echo ' '.self::TplTitle($tpl_tag);  ?></h2>
    293294<form action="<?php echo remove_query_arg(array('action','type','tpl')).'#'.$type ?>" method="post">
    294295    <input type="hidden" name="action" value="<?php echo $new?'add':'update'; ?>" />   
     
    357358    return $content;
    358359}
    359 }
    360 ?>
     360
     361static function TplTitle($tpl_tag)
     362{
     363    return __(__(esc_html(WPFB_Output::Filename2Title($tpl_tag))), WPFB);
     364}
     365}
  • wp-filebase/trunk/classes/AdminLite.php

    r599972 r615301  
    3333   
    3434    $menu_entries = array(
    35         array('tit'=>'Files',                       'tag'=>'files', 'fnc'=>'DisplayFilesPage',  'desc'=>'View uploaded files and edit them',                                                    'cap'=>'upload_files'),
    36         array('tit'=>__('Categories'/*def*/),       'tag'=>'cats',  'fnc'=>'DisplayCatsPage',   'desc'=>'Manage existing categories and add new ones.',                                         'cap'=>'manage_categories'),
     35        array('tit'=>'Files',                       'tag'=>'files', 'fnc'=>'DisplayFilesPage',  'desc'=>'View uploaded files and edit them',
     36                'cap'=>'upload_files',
     37        ),
     38        array('tit'=>__('Categories'/*def*/),       'tag'=>'cats',  'fnc'=>'DisplayCatsPage',   'desc'=>'Manage existing categories and add new ones.',
     39                'cap'=>'manage_categories',
     40        ),
     41       
    3742        //array('tit'=>'Sync Filebase', 'hide'=>true, 'tag'=>'sync',    'fnc'=>'DisplaySyncPage',   'desc'=>'Synchronises the database with the file system. Use this to add FTP-uploaded files.',  'cap'=>'upload_files'),
    38         array('tit'=>'Edit Stylesheet',             'tag'=>'css',   'fnc'=>'DisplayStylePage',  'desc'=>'Edit the CSS for the file template',                                                   'cap'=>'edit_themes'),
    39         array('tit'=>'Manage Templates',            'tag'=>'tpls',  'fnc'=>'DisplayTplsPage',   'desc'=>'Edit custom file list templates',                                                      'cap'=>'edit_themes'),
    40         array('tit'=>__('Settings'),                'tag'=>'sets',  'fnc'=>'DisplaySettingsPage','desc'=>'Change Settings',                                                 'cap'=>'manage_options'),
     43       
     44        array('tit'=>'Edit Stylesheet',             'tag'=>'css',   'fnc'=>'DisplayStylePage',  'desc'=>'Edit the CSS for the file template',
     45                'cap'=>'edit_themes',
     46        ),
     47       
     48        array('tit'=>'Manage Templates',            'tag'=>'tpls',  'fnc'=>'DisplayTplsPage',   'desc'=>'Edit custom file list templates',
     49                'cap'=>'edit_themes',
     50        ),
     51       
     52        array('tit'=>__('Settings'),                'tag'=>'sets',  'fnc'=>'DisplaySettingsPage','desc'=>'Change Settings',
     53                                                        'cap'=>'manage_options'),
    4154        array('tit'=>'Donate &amp; Feature Request','tag'=>'sup',   'fnc'=>'DisplaySupportPage','desc'=>'If you like this plugin and want to support my work, please donate. You can also post your ideas making the plugin better.', 'cap'=>'manage_options'),
    4255    );
    4356   
    4457    foreach($menu_entries as $me)
    45     {       
     58    {
    4659        $callback = array(__CLASS__, $me['fnc']);
    4760        add_submenu_page($pm_tag, WPFB_PLUGIN_NAME.' - '.__($me['tit'], WPFB), empty($me['hide'])?__($me['tit'], WPFB):null, empty($me['cap'])?'read':$me['cap'], WPFB_OPT_NAME.'_'.$me['tag'], $callback);
  • wp-filebase/trunk/classes/Category.php

    r529024 r615301  
    172172            case 'cat_parent_name': return is_object($parent =& $this->GetParent()) ? $parent->cat_name : '';
    173173            case 'cat_icon_url':    return $this->GetIconUrl();
    174             case 'cat_small_icon':  $esc=false; return '<img align="" src="'.$this->GetIconUrl('small').'" style="height:32px;vertical-align:middle;" />';
     174            case 'cat_small_icon':  $esc=false; return '<img src="'.$this->GetIconUrl('small').'" style="height:32px;vertical-align:middle;" />';
    175175            case 'cat_num_files':       return $this->cat_num_files;
    176176            case 'cat_num_files_total': return $this->cat_num_files_total;
    177             //case 'cat_required_level':    return ($this->cat_required_level - 1);         
     177            //case 'cat_required_level':    return ($this->cat_required_level - 1);
     178            case 'cat_user_can_access': return $this->CurUserCanAccess();   
    178179            case 'uid':                 return self::$tpl_uid;             
    179180        }
     
    186187        return $esc?esc_html($v):$v;
    187188    }
     189   
     190    function CurUserIsOwner()
     191    {
     192        return false; // TODO: cats dont have owners
     193    }
    188194}
    189195
  • wp-filebase/trunk/classes/Core.php

    r599590 r615301  
    3030    add_filter('wp_get_attachment_url', array(__CLASS__, 'GetAttachmentUrlFilter'));
    3131    add_filter('get_attached_file', array(__CLASS__, 'GetAttachedFileFilter'));
     32
    3233   
    3334    // register treeview stuff
     
    289290        'num' => 0,
    290291        'pagenav' => 1,
    291         'linktext' => null,
     292        'linktext' => null
    292293    ), $atts), $content, $tag);
    293294}
     
    538539
    539540static function AdminDashboardSetup() {
    540     if(current_user_can('upload_files')) {
    541         wpfb_loadclass('Admin');
     541   
     542    if(wpfb_call('Admin','CurUserCanUpload'))
     543    {
    542544        wp_add_dashboard_widget('wpfb-add-file-widget', WPFB_PLUGIN_NAME.': '.__('Add File', WPFB), array('WPFB_Admin', 'AddFileWidget'));
    543545    }   
     
    568570
    569571static function Cron() {
    570     if(self::GetOpt('cron_sync'))
     572    if(self::GetOpt('cron_sync')) {
    571573        wpfb_call('Sync', 'Sync');
     574        update_option(WPFB_OPT_NAME.'_cron_sync_time', time());
     575    }
    572576}
    573577
     
    643647    return create_function('$f', "return ($parsed_tpl);");
    644648}
    645 }
     649
     650}
  • wp-filebase/trunk/classes/Download.php

    r598768 r615301  
    459459    $bandwidth *= 1024;
    460460    $bandwidth /= 1000;
     461   
     462    global $wpdb;
     463    if(!empty($wpdb->dbh))
     464        @mysql_close($wpdb->dbh);
    461465
    462466    $cur = $begin;
  • wp-filebase/trunk/classes/File.php

    r599590 r615301  
    7979            } else {
    8080                $permission_sql = "file_user_roles = ''";
    81                 foreach($current_user->roles as $ur) {
     81                $roles = $current_user->roles;
     82                foreach($roles as $ur) {
    8283                    $ur = $wpdb->escape($ur);
    83                     $permission_sql .= " OR (file_user_roles = '{$ur}') OR (file_user_roles LIKE '{$ur}|%') OR (file_user_roles LIKE '%|{$ur}|%') OR (file_user_roles LIKE '%|{$ur}')";
     84                    $permission_sql .= " OR MATCH(file_user_roles) AGAINST ('{$ur}' IN BOOLEAN MODE)";
    8485                }
    8586                if($current_user->ID > 0)
     
    199200        foreach($ints as $i) $this->$i = intval($this->$i);
    200201        $this->file_offline = (int)!empty($this->file_offline);
    201         $this->file_direct_linking = (int)!empty($this->file_direct_linking);
     202        $this->file_direct_linking = (int)$this->file_direct_linking;
    202203        $this->file_force_download = (int)!empty($this->file_force_download);
    203204        if(empty($this->file_last_dl_time)) $this->file_last_dl_time = '0000-00-00 00:00:00';
     
    414415            case 'cat_url':             return is_null($cat = $this->GetParent()) ? '' : htmlspecialchars($cat->GetUrl());
    415416           
     417            case 'file_cat_folder':     return htmlspecialchars(is_object($cat = $this->GetParent()) ? $cat->cat_folder : '');
     418           
    416419            case 'file_languages':      return wpfb_call('Output','ParseSelOpts', array('languages', $this->file_language),true);
    417420            case 'file_platforms':      return wpfb_call('Output','ParseSelOpts', array('platforms', $this->file_platform),true);
     
    420423           
    421424            //case 'file_required_level':   return ($this->file_required_level - 1);
     425            case 'file_user_can_access': return $this->CurUserCanAccess();
    422426           
    423427            case 'file_description':    return nl2br($this->file_description);
     
    486490       
    487491        // check referrer
    488         if(!$this->file_direct_linking) {           
     492        if($this->file_direct_linking != 1) {           
    489493            // if referer check failed, redirect to the file post
    490494            if(!WPFB_Download::RefererCheck()) {
  • wp-filebase/trunk/classes/FileListTable.php

    r529024 r615301  
    2121        $columns = array(
    2222            'cb'            => '<input type="checkbox" />', //Render a checkbox instead of text
    23             'id'            => 'Title',
    24             'display_name'  => __('',WPFB),
    25             'name'          => __('',WPFB),
    26             'size'          => __('',WPFB),
    27             'desc'          => __('',WPFB),
    28             'cat'           => __('',WPFB),
    29             'perm'          => __('',WPFB),
    30             'owner'         => __('',WPFB),
    31             'date'          => __('',WPFB),
    32             'hits'          => __('',WPFB),
    33             'dltime'        => __('',WPFB)
    3423        );
    3524        return $columns;
     
    3827    function get_sortable_columns() {
    3928        $sortable_columns = array(
    40             'title'     => array('title',true),     //true means its already sorted
    41             'rating'    => array('rating',false),
    42             'director'  => array('director',false)
     29            'id'            => _e('ID'/*def*/),
     30            'display_name'  => _e('Name'/*def*/),
     31            'name'          => _e('Filename', WPFB),
     32            'size'          => _e('Size'/*def*/),
     33            //'description'     => _e('Description'/*def*/),
     34            'category_name' => _e('Category'/*def*/),
     35            'user_roles'    => _e('Access Permission',WPFB),
     36            'added_by'      => _e('Owner',WPFB),
     37            'date'          => _e('Date'/*def*/),
     38            'hits'          => _e('Hits', WPFB),
     39            'last_dl_time'  => _e('Last download', WPFB)
    4340        );
    4441        return $sortable_columns;
     
    5855    }
    5956   
    60     function column_title($item){
     57    function column_display_name($item){
    6158        $actions = array(
    62             'edit'      => '<a href="'.$item->GetEditUrl().'">"'.__('Edit').'</a>',
    63             'delete'    => '<a href="'.$item->GetEditUrl().'">"'.__('Delete').'</a>',
    64         );
    65         /*
    66 <?php if(!empty($file->file_thumbnail)) { ?><img src="<?php echo esc_attr($file->GetIconUrl()); ?>" height="32" /><?php } ?>
    67                             <span><?php if($file->IsRemote()){echo '*';} echo esc_html($file->file_display_name); ?></span>
    68                            
    69         */
    70        
    71         //Return the title contents
    72         return sprintf('%1$s <span style="color:silver">(id:%2$s)</span>%3$s',
    73             /*$1%s*/ $item->GetTitle(),
    74             /*$2%s*/ $item->GetId(),
    75             /*$3%s*/ $this->row_actions($actions)
    76         );
    77     }
    78    
     59            'edit'      => '<a href="'.esc_attr($item->GetEditUrl()).'">"'.__('Edit').'</a>',
     60            'delete'    => '<a href="">"'.__('Delete').'</a>',
     61        );
     62       
     63        $col = '<a class="row-title" href="'.esc_attr($file->GetEditUrl()).'" title="'.esc_attr(sprintf(__('Edit &#8220;%s&#8221;'),$file->GetTitle())).'">';
     64        if(!empty($file->file_thumbnail))
     65            $col .= '<img src="'.esc_attr($file->GetIconUrl()).'" height="32" />';
     66        $col .= '<span>'.($file->IsRemote()?'*':'').esc_html($file->GetTitle(32)).'</span>';
     67        $col .= '</a>';                         
     68        $col .= $this->row_actions($actions);
     69        return $col;
     70    }
     71   
     72    function column_name($file)
     73    {
     74        return '<a href="'.esc_attr($file->GetUrl()).'">'.esc_html($file->file_name).'</a>';
     75    }
     76   
     77    function column_size($file)
     78    {
     79        return WPFB_Output::FormatFilesize($file->file_size);
     80    }
     81   
     82    function column_category_name($file)
     83    {
     84        $cat = $file->GetParent();
     85        return (!is_null($cat) ? ('<a href="'.esc_attr($cat->GetEditUrl()).'">'.esc_html($file->file_category_name).'</a>') : '-');
     86    }
     87   
     88    function column_user_roles($file)
     89    {
     90        return WPFB_Output::RoleNames($file->GetReadPermissions(), true);
     91    }
     92   
     93    function column_added_by($file)
     94    {
     95        return (empty($file->file_added_by) || !($usr = get_userdata($file->file_added_by))) ? '-' : esc_html($usr->user_login);
     96    }
     97   
     98    function column_date($file)
     99    {
     100        return $file->GetFormattedDate();
     101    }
     102   
     103    function column_hits($file)
     104    {
     105        return $file->file_hits;
     106    }
     107   
     108    function column_last_dl_time($file)
     109    {
     110        return ( (!empty($file->file_last_dl_time) && $file->file_last_dl_time > 0) ? mysql2date(get_option('date_format'), $file->file_last_dl_time) : '-');
     111    }
    79112   
    80113    function get_bulk_actions() {
    81114        $actions = array(
    82             'delete'    => 'Delete'
     115            'delete'    => 'Delete',
     116            'edit' => 'Change Category',
     117            ''
    83118        );
    84119        return $actions;
  • wp-filebase/trunk/classes/GetID3.php

    r566139 r615301  
    77        require_once(WPFB_PLUGIN_ROOT.'extras/getid3/getid3.php');     
    88        self::$engine = new getID3;
    9     //$getID3->setOption(array(
    10     //  'option_md5_data'  => $AutoGetHashes,
    11     //  'option_sha1_data' => $AutoGetHashes,
    12     //));       
    139    }
    1410   
     
    110106                self::getKeywords($val, $keywords);
    111107                self::getKeywords(array_keys($val), $keywords); // this is for archive files, where file names are array keys
    112             } else if(is_string($val)) {               
    113                 if(!in_array($val, $keywords))
    114                     array_push($keywords, $val);
     108            } else if(is_string($val)) {
     109                $val = explode(' ', strtolower(preg_replace('/\W+/',' ',$val)));
     110                foreach($val as $v) {
     111                    if(!in_array($v, $keywords))
     112                        array_push($keywords, $v);
     113                }
    115114            }
    116115        }
    117116        return $keywords;
    118117    }
     118
    119119}
  • wp-filebase/trunk/classes/Item.php

    r599590 r615301  
    99   
    1010    var $locked = 0;
     11   
     12    private $_read_permissions = null;
    1113   
    1214    static $tpl_uid = 0;
     
    4345        }
    4446        return $this->last_parent;
     47    }
     48    function GetParents()
     49    {
     50        $parents = array();
     51        while(!is_null($p = $this->GetParent())) $parents[] = $p;
     52        return $parents;
    4553    }
    4654    function Lock($lock=true) {
     
    189197        if( ($for_tpl && !WPFB_Core::GetOpt('hide_inaccessible')) || in_array('administrator',$current_user->roles) || ($this->is_file && $this->CurUserIsOwner()) )
    190198            return true;
    191        
    192199        if($this->is_file && WPFB_Core::GetOpt('private_files') && $this->file_added_by != 0 && !$this->CurUserIsOwner()) // check private files
    193200            return false;
    194            
    195         $frs = $this->GetUserRoles();
    196         if(empty($frs[0])) return true; // item is for everyone!       
     201        $frs = $this->GetReadPermissions();
     202        if(empty($frs)) return true; // item is for everyone!       
    197203        foreach($current_user->roles as $ur) { // check user roles against item roles
    198204            if(in_array($ur, $frs))
     
    204210    function CurUserCanEdit()
    205211    {
    206         global $current_user;
    207         if($current_user->ID > 0 && empty($current_user->roles[0]))
    208             $current_user = new WP_User($current_user->ID);// load the roles!
    209        
    210         if(in_array('administrator',$current_user->roles) || ($this->is_file && $this->CurUserIsOwner())) return true;
    211         if(!current_user_can('upload_files')) return false;
    212        
    213         return $this->is_file ? (current_user_can('edit_others_posts') && !WPFB_Core::GetOpt('private_files')) : current_user_can('manage_categories');
     212        // current_user_can('edit_files') checks if user is admin!
     213        return $this->CurUserIsOwner() || current_user_can('edit_files') || (!WPFB_Core::GetOpt('private_files') && current_user_can($this->is_file ? 'edit_others_posts' : 'manage_categories'));
    214214    }
    215215   
     
    360360    }
    361361   
    362     function GetUserRoles() {
    363         if(isset($this->roles_array)) return $this->roles_array; //caching
     362    function GetReadPermissions() {
     363        if(!is_null($this->_read_permissions)) return $this->_read_permissions; //caching
    364364        $rs = $this->is_file?$this->file_user_roles:$this->cat_user_roles;
    365         return ($this->roles_array = empty($rs) ? array() : (is_string($rs) ? explode('|', $rs) : (array)$rs));
    366     }
    367    
    368     function SetUserRoles($roles) {
     365        return ($this->_read_permissions = empty($rs) ? array() : array_filter((is_string($rs) ? explode('|', $rs) : (array)$rs)));
     366    }
     367   
     368    function SetReadPermissions($roles)
     369    {
    369370        if(!is_array($roles)) $roles = explode('|',$roles);
    370         $this->roles_array = $roles =  array_filter(array_filter(array_map('trim',$roles),'strlen')); // remove empty
     371        $this->_read_permissions = $roles =  array_filter(array_filter(array_map('trim',$roles),'strlen')); // remove empty
    371372        $roles = implode('|', $roles);
    372373        if($this->is_file) $this->file_user_roles = $roles;
     
    409410       
    410411        // inherit user roles
    411         if(count($this->GetUserRoles()) == 0)
    412             $this->SetUserRoles(($new_cat_id != 0) ? $new_cat->GetUserRoles() : WPFB_Core::GetOpt('default_roles'));
     412        if(count($this->GetReadPermissions()) == 0)
     413            $this->SetReadPermissions(($new_cat_id != 0) ? $new_cat->GetReadPermissions() : WPFB_Core::GetOpt('default_roles'));
    413414       
    414415        // flush cache
  • wp-filebase/trunk/classes/Output.php

    r599590 r615301  
    1010        $args ['id'] = $id = is_null($item = WPFB_Item::GetByPath($args['path'])) ? 0 : $item->GetId();
    1111    }
    12    
    13    
     12       
    1413    switch($args['tag']) {
    1514        case 'list': return do_shortcode(self::FileList($args));
     
    147146static function FileBrowserList(&$content, &$parents, $root_cat=null)
    148147{
     148    if(!is_null($root_cat) && !$root_cat->CurUserCanAccess()) {
     149        $content .= '<li>'.WPFB_Core::GetOpt('cat_inaccessible_msg').'</li>';
     150        return;
     151    }
     152       
    149153    $cats = WPFB_Category::GetFileBrowserCats(is_null($root_cat) ? 0 : $root_cat->cat_id);
    150154    $open_cat = array_pop($parents);
     
    158162   
    159163    foreach($cats as $cat) {
    160         if(!$cat->CurUserCanAccess()) continue;
     164        if(!$cat->CurUserCanAccess(true)) continue;
    161165       
    162166        $liclass = '';
     
    401405    if(!empty($roles)) {
    402406        foreach($roles as $role)
    403             $names[$role] = translate_user_role($wp_roles->roles[$role]['name']);
     407        {
     408                $names[$role] = translate_user_role($wp_roles->roles[$role]['name']);
     409        }
    404410    }
    405411    return $fmt_string ? (empty($names) ? ("<i>".__('Everyone',WPFB)."</i>") : join(', ',$names)) : $names;
  • wp-filebase/trunk/classes/ProgressReporter.php

    r599590 r615301  
    11<?php class WPFB_ProgressReporter {
    22    var $quiet;
     3   
     4    var $progress_cur;
     5    var $progress_end;
     6    var $progress_bar;
     7   
     8    var $files = array();
     9   
     10    function WPFB_ProgressReporter($suppress_output = false)
     11    {
     12        $this->quiet = !!$suppress_output;
     13    }
    314   
    415    function Log($msg, $no_new_line=false) {
     
    920    function LogError($err)
    1021    {
    11        
     22        if($this->quiet) return;
     23        self::DEcho("<span style='color:#d00;'>$err</span><br />");     
    1224    }
    1325   
    14     function SetProgress($percentage)
     26    function InitProgress($progress_end)
    1527    {
    16        
     28        $this->progress_end = $progress_end;
     29        if(!$this->quiet) {
     30            if(is_null($this->progress_bar)) {
     31                include_once(WPFB_PLUGIN_ROOT.'extras/progressbar.class.php');
     32                $this->progress_bar = new progressbar(0, 100);
     33                $this->progress_bar->print_code();
     34            }
     35        }           
     36    }
     37   
     38    function SetProgress($progress)
     39    {
     40        $this->progress_cur = $progress;
     41        if(!$this->quiet && !is_null($this->progress_bar)) {                   
     42            $this->progress_bar->set(100*$progress/$this->progress_end);
     43        }       
     44    }
     45   
     46    function SetSubProgress($sub_progress, $sub_total)
     47    {
     48        if(!$this->quiet && !is_null($this->progress_bar))
     49            $this->progress_bar->set(100*($this->progress_cur+$sub_progress)/$this->progress_end);
     50    }
     51   
     52    function FileChanged($file, $action)
     53    {
     54        if(empty($this->files[$action])) $this->files[$action] = array();
     55        $this->files[$action][] = $file;
     56    }
     57   
     58    function ChangedFilesReport()
     59    {
     60        foreach($this->files as $tag => $group)
     61        {
     62            $t = str_replace('_', ' ', $tag);
     63            $t{0} = strtoupper($t{0});
     64           
     65            echo '<h2>' . __($t) . '</h2><ul>';
     66            foreach($group as $item)
     67                echo '<li>' . (is_object($item) ? ('<a href="'.$item->GetEditUrl().'">'.$item->GetLocalPathRel().'</a>') : $item) . '</li>';
     68            echo '</ul>';
     69        }
     70
     71        foreach($this->files as $t => $group)
     72        {
     73            $n = count($group);
     74            echo '<p>';
     75            printf(__('%d files <i>%s</i>',WPFB), $n, $t);
     76            echo '</p>';
     77        }
    1778    }
    1879
  • wp-filebase/trunk/classes/Search.php

    r598768 r615301  
    6060    $where = "(1";
    6161   
     62    // TODO: search fields with match...
    6263    foreach($search_terms as $term) {
    6364        $where .= " AND (";
     
    6869            if(empty($or)) $or = 'OR ';
    6970        }
    70         if($search_id3) $where .= " OR ({$wpdb->wpfilebase_files_id3}.keywords LIKE '{$p}{$term}{$p}')";
     71        if($search_id3) $where .= " OR ({$wpdb->wpfilebase_files_id3}.keywords LIKE '{$p}{$term}{$p}')"; // TODO: MATCH func here
    7172        $where .= ") ";
    7273    }
  • wp-filebase/trunk/classes/Setup.php

    r599972 r615301  
    225225
    226226
    227 static function SetupDBTables()
     227static function SetupDBTables($old_ver=null)
    228228{
    229229    global $wpdb;
     
    247247  `cat_exclude_browser` enum('0','1') NOT NULL default '0',
    248248  `cat_order` int(8) NOT NULL default '0',
    249   PRIMARY KEY  (`cat_id`)
     249  PRIMARY KEY  (`cat_id`),
     250  FULLTEXT KEY `USER_ROLES` (`cat_user_roles`)
    250251) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1";
    251252               
     
    272273  `file_user_roles` varchar(255) NOT NULL default '',
    273274  `file_offline` enum('0','1') NOT NULL default '0',
    274   `file_direct_linking` enum('0','1') NOT NULL default '0',
     275  `file_direct_linking` enum('0','1','3') NOT NULL default '0',
    275276  `file_force_download` enum('0','1') NOT NULL default '0',
    276277  `file_category` int(8) unsigned NOT NULL default '0',
     
    288289  ". /*`file_meta` TEXT NULL DEFAULT NULL,*/ "
    289290  PRIMARY KEY  (`file_id`),
    290   FULLTEXT KEY `FULLTEXT` (`file_description`)
     291  FULLTEXT KEY `DESCRIPTION` (`file_description`),
     292  FULLTEXT KEY `USER_ROLES` (`file_user_roles`)
    291293) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1";   
    292294   
     
    296298  `value` LONGTEXT NOT NULL,
    297299  `keywords` TEXT NOT NULL,
    298   PRIMARY KEY  (`file_id`)
     300  PRIMARY KEY  (`file_id`),
     301  FULLTEXT KEY `KEYWORDS` (`keywords`)
    299302) ENGINE=MyISAM  DEFAULT CHARSET=utf8";
    300303
     
    354357    //$queries[] = "@ALTER TABLE `$tbl_files` ADD `file_meta` TEXT NULL DEFAULT NULL";
    355358   
     359    // add fulltext indices
     360    if(!empty($old_ver) && version_compare($old_ver, '0.2.9.24') < 0) {     // TODO: search fields fulltext index!
     361        $queries[] = "@ALTER TABLE `$tbl_files` ADD FULLTEXT `USER_ROLES` (`file_user_roles`)";
     362        $queries[] = "@ALTER TABLE `$tbl_cats` ADD FULLTEXT `USER_ROLES` (`cat_user_roles`)";       
     363        $queries[] = "@ALTER TABLE `$tbl_files_id3` ADD FULLTEXT `KEYWORDS` (`keywords`)";
     364    }
     365   
     366    // 2 is for file pages
     367    if(!empty($old_ver) && version_compare($old_ver, '0.2.9.24') < 0)
     368        $queries[] = "ALTER TABLE  `$tbl_files` CHANGE  `file_direct_linking`  `file_direct_linking` ENUM(  '0',  '1',  '2' ) NOT NULL DEFAULT '0'";
    356369
    357370    $queries[] = "OPTIMIZE TABLE `$tbl_cats`";
     
    387400        $files = $wpdb->get_results("SELECT file_id,file_required_level FROM $tbl_files WHERE file_required_level <> 0");
    388401        foreach ( (array) $files as $file ) {
    389             $wpdb->query("UPDATE `$tbl_files` SET `file_user_roles` = '".WPFB_Core::UserLevel2Role($file->file_required_level - 1)."' WHERE `file_id` = $file->file_id");
     402            $wpdb->query("UPDATE `$tbl_files` SET `file_user_roles` = '|".WPFB_Core::UserLevel2Role($file->file_required_level - 1)."' WHERE `file_id` = $file->file_id");
    390403        }
    391404        $wpdb->query("ALTER TABLE `$tbl_files` DROP `file_required_level`");
     
    395408        $cats = $wpdb->get_results("SELECT cat_id,cat_required_level FROM $tbl_cats WHERE cat_required_level <> 0");
    396409        foreach ( (array) $cats as $cat ) {
    397             $wpdb->query("UPDATE `$tbl_cats` SET `cat_user_roles` = '".WPFB_Core::UserLevel2Role($cat->cat_required_level - 1)."' WHERE `cat_id` = $cat->cat_id");
     410            $wpdb->query("UPDATE `$tbl_cats` SET `cat_user_roles` = '|".WPFB_Core::UserLevel2Role($cat->cat_required_level - 1)."' WHERE `cat_id` = $cat->cat_id");
    398411        }
    399412        $wpdb->query("ALTER TABLE `$tbl_cats` DROP `cat_required_level`");
    400413    }
     414   
     415    /* NOT neeeded since using fulltext index!
     416    // add leading | to user_roles
     417    if(!empty($old_ver) && version_compare($old_ver, '0.2.9.24') < 0) {
     418        $wpdb->query("UPDATE `$tbl_files` SET `file_user_roles` = CONCAT('|', `file_user_roles`) WHERE LEFT(`file_user_roles`, 1) <> '|'");
     419        $wpdb->query("UPDATE `$tbl_cats` SET `cat_user_roles` = CONCAT('|', `cat_user_roles`) WHERE LEFT(`cat_user_roles`, 1) <> '|'");
     420    }
     421    */
    401422}
    402423
     
    502523static function OnActivateOrVerChange($old_ver=null) {
    503524    wpfb_loadclass('Admin','File','Category');
    504     self::SetupDBTables();
     525    self::SetupDBTables($old_ver);
    505526    $old_options = get_option(WPFB_OPT_NAME);
    506527    self::AddOptions();
  • wp-filebase/trunk/classes/Sync.php

    r598768 r615301  
    1919private static function PreSync($sync_data)
    2020{
     21    self::PrintDebugTrace();
    2122    @ini_set('max_execution_time', '0');
    2223    @set_time_limit(0);
     
    2930private static function SyncPase1($sync_data, $output)
    3031{
     32    self::PrintDebugTrace();
     33   
    3134    if($output) self::DEcho('<p>'. __('Checking for file changes...',WPFB).' ');
    3235    self::CheckChangedFiles($sync_data);
     
    4346   
    4447    if($output) self::DEcho('<p>'. __('Searching for new files...',WPFB).' ');
     48   
     49    self::PrintDebugTrace("new_files");
    4550   
    4651    // search for not added files
     
    6772        $num_new_files++;
    6873    }
     74   
     75    self::PrintDebugTrace("new_files_end");
    6976
    7077    $sync_data->num_files_to_add = $num_new_files;
     
    7582
    7683static function Sync($hash_sync=false, $output=false)
    77 {   
     84{
     85    self::PrintDebugTrace();
     86   
     87    wpfb_loadclass('File', 'Category');
    7888    $sync_data = new WPFB_SyncData(true);
    7989    $sync_data->hash_sync = $hash_sync;
     
    103113private function PostSync($sync_data, $output)
    104114{
     115    self::PrintDebugTrace();
     116   
    105117    // chmod
    106118    if($output) self::DEcho('<p>Setting permissions...');
     
    184196static function AddNewFiles($sync_data, $progress_bar=null, $max_batch_size=0)
    185197{
     198    self::PrintDebugTrace();
    186199    $keys = array_keys($sync_data->new_files);
    187200    $upload_dir = self::cleanPath(WPFB_Core::UploadDir());
     
    401414            }
    402415}
     416
     417static function PrintDebugTrace($tag="") {
     418    if(!empty($_GET['debug']))
     419    {
     420        echo "<!-- [$tag] BACKTRACE:\n";
     421        echo esc_html(print_r(wp_debug_backtrace_summary(), true));
     422        echo "\nEND -->";
     423    }
     424}
    403425}
    404426
  • wp-filebase/trunk/classes/Widget.php

    r599972 r615301  
    128128    <?php
    129129}
     130
     131function CatTree(&$root_cat)
     132{
     133    echo '<li><a href="'.$root_cat->GetUrl().'">'.esc_html($root_cat->cat_name).'</a>';
     134   
     135    $childs =& $root_cat->GetChildCats();
     136    if(count($childs) > 0)
     137    {
     138        echo '<ul>';
     139        foreach(array_keys($childs) as $i) self::CatTree($childs[$i]);
     140        echo '</ul>';
     141    }
     142   
     143    echo '</li>';
     144}
    130145}
    131146
     
    136151    }
    137152
    138     function widget( $args, $instance ) {           
     153    function widget( $args, $instance ) {
    139154        if(!WPFB_Core::GetOpt('frontend_upload'))
    140155            return;
    141 
    142156        wpfb_loadclass('File', 'Category', 'Output');
    143157       
     
    151165        $prefix = "wpfb-upload-widget-".$this->id_base;
    152166        $form_url = add_query_arg('wpfb_upload_file', 1);
    153         WPFB_Output::FileForm($prefix, $form_url, array('cat' => $instance['category'], 'overwrite' => (int)$instance['overwrite']));
     167        $form_args = array('cat' => $instance['category'], 'overwrite' => (int)$instance['overwrite']);
     168        $form_args['file_post_id'] = $instance['attach'] ? WPFB_Core::GetPostId() : 0; // attach file to current post
     169        WPFB_Output::FileForm($prefix, $form_url, $form_args);
    154170       
    155171        echo $after_widget;
     
    162178        $instance['category'] = ($new_instance['category'] > 0) ? (is_null($cat=WPFB_Category::GetCat($new_instance['category'])) ? 0 : $cat->GetId()) : (int)$new_instance['category'];
    163179        $instance['overwrite'] = !empty($new_instance['overwrite']);
     180        $instance['attach'] = !empty($new_instance['attach']);
    164181        return $instance;
    165182    }
     
    181198            </label></p>
    182199            <p><input type="checkbox" id="<?php echo $this->get_field_id('overwrite'); ?>" name="<?php echo $this->get_field_name('overwrite'); ?>" value="1" <?php checked(!empty($instance['overwrite'])) ?> /> <label for="<?php echo $this->get_field_id('overwrite'); ?>"><?php _e('Overwrite existing files', WPFB) ?></label></p>
     200            <p><input type="checkbox" id="<?php echo $this->get_field_id('attach'); ?>" name="<?php echo $this->get_field_name('attach'); ?>" value="1" <?php checked(!empty($instance['attach'])) ?> /> <label for="<?php echo $this->get_field_id('attach'); ?>"><?php _e('Attach file to current post/page', WPFB) ?></label></p>
    183201        </div><?php
    184202    }
  • wp-filebase/trunk/editor_plugin.php

    r598768 r615301  
    270270    <?php
    271271}
    272 WPFB_Admin::PrintForm('file', $file, array('exform'=>!empty($_GET['exform']), 'in_editor'=>true, 'post_id'=>$post_id));
     272//if( (WPFB_Admin::CurUserCanUpload()&&empty($file))) TODO
     273    WPFB_Admin::PrintForm('file', $file, array('exform'=>!empty($_GET['exform']), 'in_editor'=>true, 'post_id'=>$post_id));
    273274?>
    274275<h3 class="media-title"><?php _e('Attach existing file', WPFB) ?></h3>
  • wp-filebase/trunk/lib/wpfb_form_cat.php

    r494110 r615301  
    1414
    1515$default_roles = WPFB_Core::GetOpt('default_roles');
    16 $user_roles = ($update || empty($default_roles)) ? $file_category->GetUserRoles() : $default_roles;
     16$user_roles = ($update || empty($default_roles)) ? $file_category->GetReadPermissions() : $default_roles;
    1717$cat_members_only = !empty($user_roles);
    1818
     
    5656            <?php } ?>
    5757            </td>
    58         </tr>
    59         <!-- <tr>
    60        
    61        
    62         <th scope="row" valign="top"><label for="cat_members_only"><?php _e('For members only', WPFB) ?></label>
    63         <input type="checkbox" name="cat_members_only" value="1" <?php checked(true, $cat_members_only) ?> onclick="WPFB_CheckBoxShowHide(this, 'cat_user_roles')" /></th>
    64         <td>
    65             <select name="cat_user_roles[]" id="cat_user_roles" size="40" multiple="multiple" style="height: 80px;" class="<?php if(!$cat_members_only) { echo 'hidden'; } ?>">
    66             <?php WPFB_Output::RolesDropDown($file_category->GetUserRoles());
    67             ?></select><br />
    68             <label for="cat_user_roles" class="<?php if(!$cat_members_only) { echo 'hidden'; } ?>"><?php _e("Select multiple roles by holding the CTRL/COMMAND key.")?></label>
    69         </td>
    70         </tr>
    71          -->
    72          
     58        </tr>       
    7359        <tr>
    7460            <th scope="row" valign="top"><?php _e('Access Permission',WPFB) ?></th>
  • wp-filebase/trunk/lib/wpfb_form_file.php

    r598768 r615301  
    2121
    2222$default_roles = WPFB_Core::GetOpt('default_roles');
    23 $user_roles = ($update || empty($default_roles)) ? $file->GetUserRoles() : $default_roles;
     23$user_roles = ($update || empty($default_roles)) ? $file->GetReadPermissions() : $default_roles;
    2424$file_members_only = !empty($user_roles);
    2525
     
    192192                </div>
    193193                <div id="flash-upload-ui"><?php wpfb_call($adv_uploader,'Display',$form_url); ?></div> <!--  flash-upload-ui -->
    194                 <?php if($update) { echo '<div><b><a href="'.$file->GetUrl().'">' . $file->file_name . '</a></b> (' . $file->GetFormattedSize() . ', '.wpfb_call('Download', 'GetFileType', $file->file_name).', MD5: <code>'.$file->file_hash.'</code>)</div>'; } ?>
     194                <?php if($update) { echo '<div>'.__('Rename').': '; ?>
     195                <input name="file_rename" id="file_rename" type="text" value="<?php echo esc_attr($file->file_name); ?>" style="width:280px;" /><br />
     196                <?php echo ' (' . $file->GetFormattedSize() . ', '.wpfb_call('Download', 'GetFileType', $file->file_name).', MD5: <code>'.$file->file_hash.'</code>)</div>'; } ?>
    195197            </div>
    196198            <div id="file-remote-wrap" <?php echo ($file->IsRemote() ? '' : 'class="hidden"'); ?>>
     
    284286                <label title="<?php _e('Yes') ?>"><input type="radio" name="file_direct_linking" value="1" <?php checked('1', $file->file_direct_linking); ?>/> <?php _e('Allow direct linking', WPFB) ?></label><br />
    285287                <label title="<?php _e('No') ?>"><input type="radio" name="file_direct_linking" value="0" <?php checked('0', $file->file_direct_linking); ?>/> <?php _e('Redirect to post', WPFB) ?></label>
     288<?php
     289?>
    286290            </fieldset>
    287291        </td>
  • wp-filebase/trunk/readme.txt

    r599972 r615301  
    55Requires at least: 3.1
    66Tested up to: 3.4.2
    7 Stable tag: 0.2.9.23
     7Stable tag: 0.2.9.24
    88
    99Adds a powerful download manager supporting file categories, downloads counter, widgets, sorted file lists and more to your WordPress blog.
     
    104104
    105105== Changelog ==
     106
     107= 0.2.9.24 =
     108* Added field to rename files in file upload form
     109* Configuration of old File Widget will be retained on update. Please change to the new multi-instance widget after updating!
     110* New Option `Inaccessible category message`
     111* Improved access permission handling for AJAX tree
     112* Fixed OpenOffice download link
     113* New template variable `%cat_user_can_access%` and `%file_user_can_access%`
     114* Files are only re-scanned if changed
     115* Fixed external MD5 hashing on Windows
     116* MySQL connection are closed during download
     117* New Template varialbe `%file_cat_folder%`
     118* Added sync debug info when query variable `debug` is set to 1 (add &debug=1 to the sync page URL and see the HTML source for backtrace)
     119* Inaccessible categories are displayed in lists, but their content cannot be viewed
     120* Fixed resources URL when using SSL
     121* Removed HTML align property for category icons according to HTML5 standard
    106122
    107123= 0.2.9.23 =
  • wp-filebase/trunk/todo.txt

    r599972 r615301  
    1 rescan files to build thumbnails in batch action
     1file ratings
    22-secondary category: tpl var?
     3
     4documentation:
    35- pdf searching: which option need to be enabled?
     6
    47ghostscript test file
    5 - auto redirect file page!
    6 - hotlinking: redirect to files page!
    7 -batch action on categories!
    8 - sync: rsyncs!
    98rsync: make sure cat is empty!
    10 dropbox: checkbox for toggle preview
    119wp-search: Notice: Undefined index: wpfb_s in C:\xampp\htdocs\wpt\wp-content\plugins\wp-filebase-pro\classes\Search.php on line 126
    12 multiple instance file widget
    13 dont re-scan pdf when editing file without upload!
    14 bmp thumnails in  otuner broken??!?
    1510drag & drop file widget
    1611
    17 simpel form by default!
     12
     13batch actions, edit action: (also on categories)
     14rename, set owner, rebuild thumbnails
    1815
    1916
    2017ftp sideload link
    21 multi istance file widget
    22 upload widget: attach to current post
    2318
    2419file list category sorting
     
    5045 - test download file
    5146 
    52  
    53 -check permissions system:
    54 private files
    55 editor plugin ajax tree (hide inaccessible)
    56 different user/user roles
    57 -upload widget: checbox: attach to current post
    58 -disable date sync
    59 - safe mode options
    60 - sync settings tab
    6147
    6248force download per file
     
    7258_ widget: users which cannot upload files should not change widget!!
    7359- upload widget: fixed category
    74 - editor plugin: field box not collapsable, missing JS
    75 
    76 - batch actions
    7760- forms
    7861
    7962- default user roles options
    8063- search lists WP attachments without permissions (due to generated content!)
    81 + create post for files
    8264-ppollplll
    83 - better syncing many files!
    8465Comments
    85 -inline upload
    8666- update version on file sync cahnged
    8767- user upload paths
    88 -disable automatic sync by default
    8968
    9069-check sortings
     
    11392global hotlink protecting
    11493
    115  batch actions for files: set properties, delete, create thumbnails, hotlink protection etc...
    116 
    11794conflicts:
    11895http://wordpress.org/support/topic/plugin-simple-facebook-connect-conflict-with-wp-filebase-plugin?replies=2
     
    123100-multi uploadh
    124101-wigets
    125 -public upload (like inline upload)
    126 -multi categories
    127102-cat syncing
    128103-id3 sorting!!
     
    133108- Custom field for post edit screen http://wordpress.org/support/topic/plugin-wp-filebase-download-manager-custom-field-for-post-edit-screen?replies=1
    134109- drag & drop widget
    135 - auto redirect dl page
    136 1. superuser - can upload files to any user and see files for any user
    137 2. user - can upload and access only his/hers own files (including those uploaded by superuser)?
  • wp-filebase/trunk/wp-filebase-admin.css

    r598768 r615301  
     1#icon-wpfilebase {
     2    background-image: url('images/wpfb-icon.png'); 
     3}
     4
    15.wpfilebase-progress {
    26    margin: 4px;
     
    5357    margin:0 0 3px;
    5458    padding:3px 1em 0;
     59    overflow: auto;
    5560}
    5661.wpfb-tab-menu li {height:25px;display:inline;line-height:200%;list-style:none;text-align:center;white-space:nowrap; margin-right: 15px;}
    5762.wpfb-tab-menu li a{color:#21759b;font-size:12px;text-decoration:none;padding:.3em .4em .4em;}
    5863.wpfb-tab-menu li a:hover{color:#D54E21;}
    59 .wpfb-tab-menu li.ui-tabs-selected{font-weight:700;background:#f9f9f9;color:#1C6280;padding:0.3em 0 0.4em;}
     64.wpfb-tab-menu li.ui-tabs-selected{background:#f9f9f9;color:#1C6280;padding:0.3em 0 0.4em;}
    6065.wpfb-tab-menu li.ui-tabs-selected a{color:#464646;}
    6166.wpfb-tab-menu li.ui-tabs-selected a:hover{background:#D54E21;color:#fff;}
     
    6469.wpfilebase-opttab {
    6570    margin: 15px;
     71}
     72
     73.wpfilebase-opttab table tr {
     74    border-top: 1px solid #e3e3e3;
    6675}
    6776
  • wp-filebase/trunk/wp-filebase.php

    r599972 r615301  
    55Description: Adds a powerful downloads manager supporting file categories, download counter, widgets, sorted file lists and more to your WordPress blog.
    66Author: Fabian Schlieper
    7 Version: 0.2.9.23
     7Version: 0.2.9.24
    88Author URI: http://fabi.me/
    99*/
     
    1212{
    1313    define('WPFB', 'wpfb');
    14     define('WPFB_VERSION', '0.2.9.23');
     14    define('WPFB_VERSION', '0.2.9.24');
    1515    define('WPFB_PLUGIN_ROOT', str_replace('\\','/',dirname(__FILE__)).'/');
    1616    if(!defined('ABSPATH')) {
    1717        define('ABSPATH', dirname(dirname(dirname(dirname(__FILE__)))));
    1818    } else {
    19         define('WPFB_PLUGIN_URI', str_replace(str_replace('\\','/',ABSPATH),get_option('siteurl').'/',WPFB_PLUGIN_ROOT));
     19        //define('WPFB_PLUGIN_URI', plugins_url('/',__FILE__));
     20        $wpfb_uri = str_replace(str_replace('\\','/',ABSPATH),get_option('siteurl').'/',WPFB_PLUGIN_ROOT);
     21        if(is_ssl()) $wpfb_uri = str_replace('http://', 'https://', $wpfb_uri);
     22        define('WPFB_PLUGIN_URI', $wpfb_uri);
    2023    }
    2124    if(!defined('WPFB_PERM_FILE')) define('WPFB_PERM_FILE', 666);
  • wp-filebase/trunk/wpfb-ajax.php

    r598768 r615301  
    4343            $parent_id = is_numeric($root) ? intval($root) : intval(substr(strrchr($root,'-'),1));
    4444        }
     45       
     46        if($parent_id > 0) {
     47            if(is_null($cat=WPFB_Category::GetCat($parent_id)) || !$cat->CurUserCanAccess()) {
     48                wpfb_print_json(array(array('id' => 0, 'text' => WPFB_Core::GetOpt('cat_inaccessible_msg'))));
     49                exit;
     50            }
     51        }
    4552           
    4653        $browser = ($type=='browser');
     
    5663        if($parent_id == 0 && $catsel && count($cats) == 0) {
    5764            wpfb_print_json(array(array(
    58                 'id' => sprintf($cat_id_format, $c->cat_id),
     65                'id' => sprintf($cat_id_format, 0),
    5966                'text' => sprintf(__('You did not create a category. <a href="%s" target="_parent">Click here to create one.</a>', WPFB), admin_url('admin.php?page=wpfilebase_cats#addcat')),
    6067                'hasChildren'=>false
     
    6774        foreach($cats as $c)
    6875        {
    69             if($c->CurUserCanAccess())
     76            if($c->CurUserCanAccess(true))
    7077                $cat_items[$i++] = array('id'=>sprintf($cat_id_format, $c->cat_id),
    7178                    'text'=> $catsel ?
     
    193200                        'url' => $cat->GetUrl(),
    194201                        'path' => $cat->GetLocalPathRel(),
    195                         'roles' => $cat->GetUserRoles(),
    196                         'roles_str' => WPFB_Output::RoleNames($cat->GetUserRoles(), true)
     202                        'roles' => $cat->GetReadPermissions(),
     203                        'roles_str' => WPFB_Output::RoleNames($cat->GetReadPermissions(), true)
    197204                ));
    198205            } else {
     
    202209       
    203210    case 'postbrowser':
    204         if(!current_user_can('read_private_posts')) {
     211        if(!current_user_can('edit_posts')) {
    205212            wpfb_print_json(array(array('id'=>'0','text'=>__('Cheatin&#8217; uh?'), 'classes' => '','hasChildren'=>false)));
    206213            exit;
Note: See TracChangeset for help on using the changeset viewer.