Plugin Directory

Changeset 444136


Ignore:
Timestamp:
09/27/2011 10:22:23 AM (15 years ago)
Author:
namja
Message:

Add Tag 0.5.8.2

  • Bugfix "Search No Result"
  • Bugfix "Notice Error CAPA_DBUG"
  • Bugfix "Warning array_flip"
Location:
capa
Files:
7 edited
1 copied

Legend:

Unmodified
Added
Removed
  • capa/tags/0.5.8.2/capa-options.php

    r391586 r444136  
    2424
    2525    // DEV Variable
     26        define('CAPA_DBUG', FALSE);
    2627        $menu_slug = (CAPA_DBUG) ? __FILE__ : 'capa/capa-options';
    2728
    28 /**
     29    /**
    2930    TODO
    3031    - 26.0001 verhindert, dass ein anderes Plugin den Platz stiehlt. - Notloesung; Aendern
     
    3839
    3940        // Global Subpage
    40             $page['global'] =   add_submenu_page(__FILE__, __('CaPa › General Settings','capa'), __('CaPa Settings','capa'), 'manage_options', $menu_slug, 'capa_global_page');
     41            $page['global'] =   add_submenu_page($menu_slug, __('CaPa › General Settings','capa'), __('CaPa Settings','capa'), 'manage_options', $menu_slug, 'capa_global_page');
    4142
    4243        // Roles Subpage
    43             $page['roles'] =    add_submenu_page(__FILE__, __('CaPa › User Roles','capa'),   __('User Roles','capa'),    'manage_options', 'capa-roles-page', 'capa_sublevel_roles');
     44            $page['roles'] =    add_submenu_page($menu_slug, __('CaPa › User Roles','capa'), __('User Roles','capa'),    'manage_options', 'capa/capa-roles-page', 'capa_sublevel_roles');
    4445
    4546        // Support Subpage
    46             $page['help'] =     add_submenu_page(__FILE__, __('CaPa › Support','capa'),      __('CaPa Support','capa'),  'manage_options', 'capa-support-page', 'capa_sublevel_support');
    47 
     47            $page['help'] =     add_submenu_page($menu_slug, __('CaPa › Support','capa'),        __('CaPa Support','capa'),  'manage_options', 'capa/capa-support-page', 'capa_sublevel_support');
    4848
    4949    // Add Help
     
    7171        echo (function_exists('screen_icon')) ? screen_icon('options-general') : NULL;
    7272       
    73             echo '<h2 style="margin-bottom:15px;">' . __('CaPa &raquo; General settings','capa') . '<br><span class="description" style="line-height:0.5em;">'. __('These settings define the display of the CaPa protected content on your blog.','capa'). '</span></h2>';
     73            echo '<h2 style="margin-bottom:15px;">' . __('CaPa &raquo; General settings','capa') . '<br><span class="description">'. __('These settings define the display of the CaPa protected content on your blog.','capa'). '</span></h2>';
    7474
    7575            echo '<form name="capa_protect" method="post">';
     
    297297
    298298            echo '<a name="capa-scroll-category"></a>';
    299             echo '<h2 style="margin-bottom:15px;">' . _n('Category visibility','Categories visibility',count($categorys),'capa') . '<br><span class="description" style="line-height:0.5em;">'. __('Select which categories are available for each user role.','capa'). '</span></h2>';
     299            echo '<h2 style="margin-bottom:15px;">' . _n('Category visibility','Categories visibility',count($categorys),'capa') . '<br><span class="description">'. __('Select which categories are available for each user role.','capa'). '</span></h2>';
    300300
    301301            echo '
     
    379379
    380380            echo '<a name="capa-scroll-page"></a>';
    381             echo '<h2 style="margin-bottom:15px;">' . _n('Page visibility', 'Pages visibility', count($pages),'capa') . '<br><span class="description" style="line-height:0.5em;">'. __('Select which pages are available for each user role.','capa'). '</span></h2>';
     381            echo '<h2 style="margin-bottom:15px;">' . _n('Page visibility', 'Pages visibility', count($pages),'capa') . '<br><span class="description">'. __('Select which pages are available for each user role.','capa'). '</span></h2>';
    382382           
    383383            echo '
     
    451451
    452452            echo '<a name="capa-scroll-redirect"></a>';
    453             echo '<h2 style="margin-bottom:15px;">' . _n('Redirect', 'Redirects', 0,'capa') . '<br><span class="description" style="line-height:0.5em;">'. __('Select which pages are available for each user role.','capa'). '</span></h2>';
     453            echo '<h2 style="margin-bottom:15px;">' . _n('Redirect', 'Redirects', 0,'capa') . '<br><span class="description">'. __('Select which pages are available for each user role.','capa'). '</span></h2>';
    454454
    455455            echo '
  • capa/tags/0.5.8.2/capa.php

    r398346 r444136  
    44Plugin URI: http://www.smatern.de/category/coding/capa/
    55Description: CaPa provides Category & Pages protection on a roles & user basis.
    6 Version: 0.5.8.1
     6Version: 0.5.8.2
    77Author: S. Matern
    88Author URI: http://www.smatern.de
     
    576576
    577577    // In case sql is for the attachments
    578         $fld_id = (strpos($sql,'attachment')) ? 'post_parent' : 'ID';
    579 
     578        $fld_id = (strpos($sql, "post_type = 'attachment'")) ? 'post_parent' : 'ID';
    580579
    581580        if(sizeof($ids) > 0){
    582             $sql .= " AND ".$fld_id." IN (".implode(",",$ids).(($capa_protect_show_only_allowed_attachments && $capa_protect_show_unattached_files) ? ', 0' : ', -1').")";
     581            $sql .= " AND ".$fld_id." IN (".implode(",",$ids).( ($capa_protect_show_only_allowed_attachments && $capa_protect_show_unattached_files) ? ', 0' : ', -1' ).")";
    583582        }else{
    584583            $sql .= " AND ".$fld_id." IN ('".(($capa_protect_show_unattached_files) ? "0" : "-1")."')";
     
    889888
    890889        $all_category_tax_ids = capa_protect::_get_taxonomy_ids();
    891         $all_category_tax_ids = array_flip($all_category_tax_ids['category']);
     890        $all_category_tax_ids = (isset($all_category_tax_ids['category'])) ? array_flip($all_category_tax_ids['category']) : array();
    892891
    893892        if ($current_user && isset($current_user->allcaps['manage_categories']) && !isset($current_user->caps['editor'])){
     
    12051204                    $taxonomy_ids[$row['taxonomy']][$row['term_taxonomy_id']] = $row['term_id'];
    12061205                }
     1206
    12071207        return $taxonomy_ids;
    1208 
    12091208    }
    12101209
     
    13431342     */
    13441343    function filter_wpdb_query($param){
     1344
    13451345        global $current_user;
    13461346
     
    15571557
    15581558
     1559    // SQLFILTER::function get_var ( case of unattached file count )
     1560    #   SELECT COUNT( * ) FROM $wpdb->posts
     1561    #   WHERE post_type = 'attachment' AND post_status != 'trash' AND post_parent < 1
     1562    //  DEV
     1563        if(strpos($param, "SELECT COUNT( * ) FROM $wpdb->posts WHERE post_type = 'attachment' AND post_status != 'trash' AND post_parent < 1") !== FALSE){
     1564            global $capa_protect_show_unattached_files;
     1565
     1566            if(!$capa_protect_show_unattached_files){
     1567                $param .= ' AND post_parent NOT IN (0)';
     1568            }
     1569        }
     1570
     1571
    15591572        return $param;
    15601573    }
  • capa/tags/0.5.8.2/readme.txt

    r398346 r444136  
    44Tags: restrict, restriction, category, categories, page, pages, protect, comments, security, Post, admin, plugin, posts, invisible, hide comments, comments private, hide comments from non-members, members, membership, sicherheit, begrenzung
    55Requires at least: 2.7.1
    6 Tested up to: 3.1.3
    7 Stable tag: 0.5.8.1
     6Tested up to: 3.2.1
     7Stable tag: 0.5.8.2
    88
    99Protects Categories, Pages and Posts for specific users & anonymous visitor
     
    6161
    6262== Changelog ==
     63
     64= v0.5.8.2 =
     65* Bugfix "Search No Result"
     66* Bugfix "Notice Error CAPA_DBUG"
     67* Bugfix "Warning array_flip"
    6368
    6469= v0.5.8.1 =
  • capa/trunk/capa-options.php

    r391586 r444136  
    2323
    2424
    25     // DEV Variable
    26         $menu_slug = (CAPA_DBUG) ? __FILE__ : 'capa/capa-options';
    27 
    28 /**
    29     TODO
    30     - 26.0001 verhindert, dass ein anderes Plugin den Platz stiehlt. - Notloesung; Aendern
     25        // DEV Variable
     26            define('CAPA_DBUG', TRUE);
     27            $menu_slug = (CAPA_DBUG) ? __FILE__ : 'capa/capa-options';
     28
     29        /**
     30        TODO
     31        - 26.0001 verhindert, dass ein anderes Plugin den Platz stiehlt. - Notloesung; Aendern
    3132*/
    3233
    33     // Add Capa Separator
    34         $menu['26.0001'] = array( '', 'manage_options', 'separator-capa', '', 'wp-menu-separator' );
    35 
    36     // Add CaPa Menu ( after the CaPa Separator and before Appearance) :
    37         add_menu_page( __('CaPa','capa'), 'CaPa', 'manage_options', $menu_slug, 'capa_global_page', 'div', '26.0002');
    38 
    39         // Global Subpage
    40             $page['global'] =   add_submenu_page(__FILE__, __('CaPa &rsaquo; General Settings','capa'), __('CaPa Settings','capa'), 'manage_options', $menu_slug, 'capa_global_page');
    41 
    42         // Roles Subpage
    43             $page['roles'] =    add_submenu_page(__FILE__, __('CaPa &rsaquo; User Roles','capa'),   __('User Roles','capa'),    'manage_options', 'capa-roles-page', 'capa_sublevel_roles');
    44 
    45         // Support Subpage
    46             $page['help'] =     add_submenu_page(__FILE__, __('CaPa &rsaquo; Support','capa'),      __('CaPa Support','capa'),  'manage_options', 'capa-support-page', 'capa_sublevel_support');
     34        // Add Capa Separator
     35            $menu['26.0001'] = array( '', 'manage_options', 'separator-capa', '', 'wp-menu-separator' );
     36
     37        // Add CaPa Menu ( after the CaPa Separator and before Appearance) :
     38            add_menu_page( __('CaPa','capa'), 'CaPa', 'manage_options', $menu_slug, 'capa_global_page', 'div', '26.0002');
     39
     40            // Global Subpage
     41                $page['global'] =   add_submenu_page($menu_slug, __('CaPa &rsaquo; General Settings','capa'), __('CaPa Settings','capa'), 'manage_options', $menu_slug, 'capa_global_page');
     42
     43            // Roles Subpage
     44                $page['roles'] =    add_submenu_page($menu_slug, __('CaPa &rsaquo; User Roles','capa'), __('User Roles','capa'),    'manage_options', 'capa/capa-roles-page', 'capa_sublevel_roles');
     45
     46            // Support Subpage
     47                $page['help'] =     add_submenu_page($menu_slug, __('CaPa &rsaquo; Support','capa'),        __('CaPa Support','capa'),  'manage_options', 'capa/capa-support-page', 'capa_sublevel_support');
    4748
    4849
     
    5556
    5657        }
    57        
    5858       
    5959    }
     
    7171        echo (function_exists('screen_icon')) ? screen_icon('options-general') : NULL;
    7272       
    73             echo '<h2 style="margin-bottom:15px;">' . __('CaPa &raquo; General settings','capa') . '<br><span class="description" style="line-height:0.5em;">'. __('These settings define the display of the CaPa protected content on your blog.','capa'). '</span></h2>';
     73            echo '<h2 style="margin-bottom:15px;">' . __('CaPa &raquo; General settings','capa') . '<br><span class="description" style="line-height:1.5em;">'. __('These settings define the display of the CaPa protected content on your blog.','capa'). '</span></h2>';
    7474
    7575            echo '<form name="capa_protect" method="post">';
     
    242242    }
    243243
     244
     245// capa_sublevel_roles() display custom Roles and there settings/restrict
     246    function capa_custom_roles(){
     247    // Check if POST isnt empty
     248        ($_POST) ? capa_handle_action() : NULL ;
     249
     250        echo '<div class="wrap">';
     251        // For WP < 27
     252            echo (function_exists('screen_icon')) ? screen_icon('users') : NULL;
     253            echo '<h2 style="margin-bottom:15px;">' . __('CaPa &raquo; Custom Roles','capa') . '</h2>';
     254
     255            echo '<ul class="subsubsub" style="float:none;">';
     256                echo '<li><a href="#capa-scroll-settings">'.__('Settings', 'capa').'</a> | </li>';
     257                echo '<li><a href="#capa-scroll-add">'.__('Create/Modify Custom Role', 'capa').'</a></li>'; #  |
     258            echo '</ul>';
     259
     260            echo '<form name="capa_protect" method="post">';
     261
     262      // --------------------------------------------------------------
     263      // ---- Categories Custom Role --- //
     264      // --------------------------------------------------------------
     265
     266            echo '<a name="capa-scroll-settings"></a>';
     267            echo '<h2 style="margin-bottom:15px;">' . _n('Category visibility','Categories visibility',count($categorys),'capa') . '<br><span class="description" style="line-height:1.5em;">'. __('Select which categories are available for each custom role.','capa'). '</span></h2>';
     268
     269                $odd[0] = '';
     270                $odd[1] = ' class="alternate"';
     271
     272                $_custom_roles = get_option('wp_user_roles');
     273            // Remove Standard Roles
     274                unset($_custom_roles['administrator'], $_custom_roles['editor'], $_custom_roles['author'], $_custom_roles['contributor'], $_custom_roles['subscriber']);
     275
     276                    $categorys  =   get_categories( array('sort_column' => 'menu_order','hide_empty'=>0, 'child_of'=>0, 'hierarchical'=>0) );;
     277                    $pages      =   get_pages(array('sort_column' => 'menu_order'));
     278
     279                    foreach($_custom_roles as $obj=>$values){
     280                        $_role[$obj] = $values['name'];
     281                        $category_check_role[$obj] = get_option("capa_protect_cat_role_".$obj);
     282                        $page_check_role[$obj] = get_option("capa_protect_pag_role_".$obj);
     283                    }
     284
     285
     286                    $_thead = $_tfoot = null;
     287                        foreach( $_role as $obj=>$name){
     288                            $_thead .= '<th>'.$name.'</th>';
     289                        }
     290
     291                        foreach( $_role as $obj=>$name){
     292                            $_tfoot .= '<th> <input type="checkbox" id="check-cat-'.$obj.'" onclick="capa_check(\'capa_protect_cat['.$obj.'][]\',\'check-cat-'.$obj.'\');"> </th>';
     293                        }
     294
     295                echo '
     296                    <table class="widefat fixed capa-table">
     297                        <thead>
     298                            <tr><th>&nbsp;</th>'.$_thead.'</tr>
     299                        </thead>
     300                        <tfoot>
     301                            <tr> <th> '. __('check/uncheck','capa') .' </th>'.$_tfoot.'</tr>
     302                        </tfoot>
     303
     304                        <tbody class="capa-tbody">
     305                    ';
     306
     307                    foreach ( $categorys as $id=>$cat ) {
     308                        $raw_order[$cat->term_id] = $id;
     309                        $search[$cat->term_id] = $cat->category_parent;
     310                    }
     311
     312                    // Get children-lvl
     313                        foreach($categorys as $id=>$cat){
     314                                $lvl['cat'][$cat->term_id] = capa_find_lvl($cat->term_id,$search);
     315                        }
     316
     317                    // Get category menu_order
     318                    ob_start();
     319                        wp_category_checklist();
     320                        $cat_output = ob_get_contents();
     321                    ob_end_clean();
     322
     323                        preg_match_all("#category-(?P<id>(\d+))'( |>)#isU",$cat_output, $sort_order, PREG_PATTERN_ORDER);
     324                        $sort_order = $sort_order['id'];
     325                        $i = 0;
     326
     327                    foreach ($sort_order as $key=>$id){
     328                        echo '<tr style="text-align:center;" '.$odd[($i%2)].'>';
     329                            echo '<th><input type="hidden" id="empty-'.$categorys[$raw_order[$id]]->slug.'" name="empty" value="0" readonly><label onclick="capa_check_slug(\''.$categorys[$raw_order[$id]]->slug.'-'.$categorys[$raw_order[$id]]->term_id.'\',\'empty-'.$categorys[$raw_order[$id]]->slug.'\');">'. str_repeat( '<span style="color:#21759B;">&rsaquo;</span> ', $lvl['cat'][$categorys[$raw_order[$id]]->term_id] ). $categorys[$raw_order[$id]]->cat_name .'</label></th>';
     330
     331                            foreach($_role as $obj=>$name){
     332                                echo '<td><input class="category_id_role '.$categorys[$raw_order[$id]]->slug.'-'.$categorys[$raw_order[$id]]->term_id.'"  type="checkbox" name="capa_protect_cat['.$obj.'][]" value="'.$categorys[$raw_order[$id]]->term_id.'" '.       ((isset($category_check_role[$obj][$categorys[$raw_order[$id]]->term_id])) ? 'checked' : NULL).'></td>';
     333                            }
     334                        echo '</tr>';
     335                        $i++;
     336                    }
     337
     338                echo '
     339                        </tbody>
     340                    </table>
     341                ';
     342
     343            echo '<br>';
     344
     345
     346      // --------------------------------------------------------------
     347      // ---- Pages --- //
     348      // --------------------------------------------------------------
     349            if($pages){
     350
     351                echo '<a name="capa-scroll-page"></a>';
     352                echo '<h2 style="margin-bottom:15px;">' . _n('Page visibility', 'Pages visibility', count($pages),'capa') . '<br><span class="description" style="line-height:1.5em;">'. __('Select which pages are available for each custom role.','capa'). '</span></h2>';
     353
     354
     355                $_thead = $_tfoot = null;
     356
     357                    foreach( $_role as $obj => $name){
     358                        $_thead .= '<th>'.$name.'</th>';
     359                    }
     360
     361                    foreach( $_role as $obj => $name){
     362                        $_tfoot .= '<th> <input type="checkbox" id="check-pag-'.$obj.'" onclick="capa_check(\'capa_protect_pag['.$obj.'][]\',\'check-pag-'.$obj.'\');"> </th>';
     363                    }
     364
     365                echo '
     366                    <table class="widefat fixed capa-table">
     367                        <thead>
     368                            <tr><th>&nbsp;</th>'.$_thead.'</tr>
     369                        </thead>
     370                        <tfoot>
     371                            <tr><th> '. __('check/uncheck','capa') .' </th>'.$_tfoot.'</tr>
     372                        </tfoot>
     373
     374
     375                        <tbody class="capa-tbody">
     376                    ';
     377                    $i = 0;
     378
     379                    foreach ( $pages as $id=>$page ) {
     380                        $search[$page->ID] = $page->post_parent;
     381                    }
     382                        foreach($pages as $id=>$page){
     383                            $lvl['page'][$page->ID] = capa_find_lvl($page->ID,$search);
     384                        }
     385
     386                    foreach ($pages as $page){
     387
     388                        echo '<tr style="text-align:center;" '.$odd[($i%2)].'>';
     389                            echo '<th><input type="hidden" id="empty-'.$page->post_name.'" name="empty" value="0" readonly><label onclick="capa_check_slug(\''.$page->post_name.'-'.$page->ID.'\',\'empty-'.$page->post_name.'\');">'. str_repeat( '<span style="color:#21759B;">&rsaquo;</span> ', $lvl['page'][$page->ID] ). $page->post_title .'</label></th>';
     390
     391                            foreach($_role as $obj => $name){
     392                                echo '<td><input class="page_id_role '.$page->post_name.'-'.$page->ID.'" type="checkbox" name="capa_protect_pag['.$obj.'][]" value="'.$page->ID.'" '.((isset($page_check_role[$obj][$page->ID])) ? 'checked' : NULL).'></td>';
     393                            }
     394
     395                        echo '</tr>';
     396                        $i++;
     397                    }
     398
     399                echo '
     400                        </tbody>
     401                    </table>
     402                ';
     403            }
     404
     405
     406            echo '
     407                <p class="submit" style="float:left; margin-right:10px;">
     408                    <button type="submit" name="submit" class="button-primary" value="update custom role options" >'. __('Update custom roles settings','capa') .'</button>
     409                </p>
     410                <p class="submit">
     411                    <button type="submit" name="submit" class="button" value="reset custom role" >'. __('Reset custom roles','capa').'</button>
     412                </p>
     413                ';
     414
     415
     416            echo "<br>";
     417      // --------------------------------------------------------------
     418      // ---- Create Custom Role --- //
     419      // --------------------------------------------------------------
     420
     421            echo '<a name="capa-scroll-add"></a>';
     422            echo '<h2 style="margin-bottom:15px;">' . __('Create/Modify Custom Role','capa') . '<br><span class="description" style="line-height:1.5em;">'. __('Create a new custom role or modify.','capa'). '</span></h2>';
     423
     424                global $current_user;
     425
     426            // Get only allowed capabilities
     427                $_capabilities = $current_user->allcaps;
     428
     429                $_tmp = null;
     430
     431                foreach($_capabilities as $obj=>$value){
     432                    if($value){
     433                    // Dont show levels or custom caps from other plugins ( which values arent exactly bool )
     434                        if( strpos( $obj, 'level' ) !== FALSE || !is_bool($value) ) continue;
     435
     436                        $_tmp .= '<li><input type="checkbox" name="'.$obj.'" id="cap-'.$obj.'"><label for="cap-'.$obj.'">'.ucfirst(str_replace('_',' ',$obj)).'</label></li>';
     437                    }
     438                }
     439
     440                $_capabilites = '<ul id="capa-capabilities">'.$_tmp.'</ul>';
     441
     442            echo '
     443                    <table class="form-table capa-form-table">
     444                    <tr>
     445                        <th scope="row">'.__('Custom role name','capa').'</th>
     446                        <td>
     447                            <label>
     448                                <input name="role-name" type="text">
     449                            </label>
     450                        </td>
     451                    </tr>
     452
     453                    <tr>
     454                        <th scope="row">'.__('Capabilities','capa').'</th>
     455                        <td>
     456                            '.$_capabilites.'
     457                        </td>
     458                    </tr>
     459
     460
     461                    </table>
     462                ';
     463
     464
     465            echo '
     466                <p class="submit" style="float:left; margin-right:10px;">
     467                    <button type="submit" name="submit" class="button-primary" value="create custom role" >'. __('Create custom role','capa') .'</button>
     468                </p>
     469                </form>';
     470
     471    }
     472
    244473// capa_sublevel_roles() displays the page content for the roles submenu
    245474    function capa_sublevel_roles() {
     
    297526
    298527            echo '<a name="capa-scroll-category"></a>';
    299             echo '<h2 style="margin-bottom:15px;">' . _n('Category visibility','Categories visibility',count($categorys),'capa') . '<br><span class="description" style="line-height:0.5em;">'. __('Select which categories are available for each user role.','capa'). '</span></h2>';
     528            echo '<h2 style="margin-bottom:15px;">' . _n('Category visibility','Categories visibility',count($categorys),'capa') . '<br><span class="description" style="line-height:1.5em;">'. __('Select which categories are available for each user role.','capa'). '</span></h2>';
    300529
    301530            echo '
     
    379608
    380609            echo '<a name="capa-scroll-page"></a>';
    381             echo '<h2 style="margin-bottom:15px;">' . _n('Page visibility', 'Pages visibility', count($pages),'capa') . '<br><span class="description" style="line-height:0.5em;">'. __('Select which pages are available for each user role.','capa'). '</span></h2>';
     610            echo '<h2 style="margin-bottom:15px;">' . _n('Page visibility', 'Pages visibility', count($pages),'capa') . '<br><span class="description" style="line-height:1.5em;">'. __('Select which pages are available for each user role.','capa'). '</span></h2>';
    382611           
    383612            echo '
     
    451680
    452681            echo '<a name="capa-scroll-redirect"></a>';
    453             echo '<h2 style="margin-bottom:15px;">' . _n('Redirect', 'Redirects', 0,'capa') . '<br><span class="description" style="line-height:0.5em;">'. __('Select which pages are available for each user role.','capa'). '</span></h2>';
     682            echo '<h2 style="margin-bottom:15px;">' . _n('Redirect', 'Redirects', 0,'capa') . '<br><span class="description" style="line-height:1.5em;">'. __('Select which pages are available for each user role.','capa'). '</span></h2>';
    454683
    455684            echo '
     
    525754    }
    526755
     756
     757
     758
    527759// capa_subleve_debug() displays information for an better help
    528760    function capa_sublevel_support() {
     
    663895    }
    664896
    665 
    666897    function capa_handle_action() {
    667898        global $_POST;
     
    710941        }
    711942
     943        if($_POST['submit'] == 'reset custom role'){
     944
     945            $_custom_roles = get_option('wp_user_roles');
     946        // Remove Standard Roles
     947            unset($_custom_roles['administrator'], $_custom_roles['editor'], $_custom_roles['author'], $_custom_roles['contributor'], $_custom_roles['subscriber']);
     948
     949            foreach($_custom_roles as $obj=>$values){
     950                delete_option("capa_protect_cat_role_".$obj);
     951                delete_option("capa_protect_pag_role_".$obj);
     952            }
     953
     954        // Show Update Message
     955            echo '<div id="message" class="updated fade"><p><strong>'.__('Custom Role Settings are reset.','capa').'</strong></p></div>';
     956
     957        }
     958
    712959
    713960        if($_POST['submit'] == 'Update general settings'){
     
    8831130        }
    8841131
     1132
     1133        if($_POST['submit'] == 'update custom role options'){
     1134
     1135                $_custom_roles = get_option('wp_user_roles');
     1136            // Remove Standard Roles
     1137                unset($_custom_roles['administrator'], $_custom_roles['editor'], $_custom_roles['author'], $_custom_roles['contributor'], $_custom_roles['subscriber']);
     1138
     1139            // CATEGORY
     1140                if(isset($_POST['capa_protect_cat']) && is_array($_POST['capa_protect_cat'])){
     1141                    foreach($_POST['capa_protect_cat'] as $role=>$value){
     1142                        foreach($value as $id=>$wert){
     1143                            $tmp['cat'][$role][$wert] = TRUE;
     1144                        }
     1145                    }
     1146
     1147                    foreach($_custom_roles as $obj=>$value){
     1148                        if(isset($tmp['cat'][$obj])){
     1149                            update_option('capa_protect_cat_role_'.$obj, $tmp['cat'][$obj]);
     1150                        }else{
     1151                            delete_option('capa_protect_cat_role_'.$obj);
     1152                        }
     1153                    }
     1154                }
     1155
     1156            // PAGE
     1157                if(isset($_POST['capa_protect_pag']) && is_array($_POST['capa_protect_pag'])){
     1158                    foreach($_POST['capa_protect_pag'] as $role=>$value){
     1159                        foreach($value as $id=>$wert){
     1160                            $tmp['pag'][$role][$wert] = TRUE;
     1161                        }
     1162                    }
     1163
     1164                    foreach($_custom_roles as $obj=>$value){
     1165                        if(isset($tmp['pag'][$obj])){
     1166                            update_option('capa_protect_pag_role_'.$obj, $tmp['pag'][$obj]);
     1167                        }else{
     1168                            delete_option('capa_protect_pag_role_'.$obj);
     1169                        }
     1170                    }
     1171                }
     1172
     1173            // Show Update Message
     1174                echo '<div id="message" class="updated fade"><p><strong>'.__('Custom Role Settings saved.','capa').'</strong></p></div>';
     1175        }
    8851176
    8861177        if($_POST['submit'] == 'Send Help'){
  • capa/trunk/capa.php

    r398346 r444136  
    44Plugin URI: http://www.smatern.de/category/coding/capa/
    55Description: CaPa provides Category & Pages protection on a roles & user basis.
    6 Version: 0.5.8.1
     6Version: 0.5.8.2
    77Author: S. Matern
    88Author URI: http://www.smatern.de
     
    576576
    577577    // In case sql is for the attachments
    578         $fld_id = (strpos($sql,'attachment')) ? 'post_parent' : 'ID';
    579 
     578        $fld_id = (strpos($sql, "post_type = 'attachment'")) ? 'post_parent' : 'ID';
    580579
    581580        if(sizeof($ids) > 0){
    582             $sql .= " AND ".$fld_id." IN (".implode(",",$ids).(($capa_protect_show_only_allowed_attachments && $capa_protect_show_unattached_files) ? ', 0' : ', -1').")";
     581            $sql .= " AND ".$fld_id." IN (".implode(",",$ids).( ($capa_protect_show_only_allowed_attachments && $capa_protect_show_unattached_files) ? ', 0' : ', -1' ).")";
    583582        }else{
    584583            $sql .= " AND ".$fld_id." IN ('".(($capa_protect_show_unattached_files) ? "0" : "-1")."')";
     
    889888
    890889        $all_category_tax_ids = capa_protect::_get_taxonomy_ids();
    891         $all_category_tax_ids = array_flip($all_category_tax_ids['category']);
     890        $all_category_tax_ids = (isset($all_category_tax_ids['category'])) ? array_flip($all_category_tax_ids['category']) : array();
    892891
    893892        if ($current_user && isset($current_user->allcaps['manage_categories']) && !isset($current_user->caps['editor'])){
     
    12051204                    $taxonomy_ids[$row['taxonomy']][$row['term_taxonomy_id']] = $row['term_id'];
    12061205                }
     1206
    12071207        return $taxonomy_ids;
    1208 
    12091208    }
    12101209
     
    13431342     */
    13441343    function filter_wpdb_query($param){
     1344
    13451345        global $current_user;
    13461346
     
    15571557
    15581558
     1559    // SQLFILTER::function get_var ( case of unattached file count )
     1560    #   SELECT COUNT( * ) FROM $wpdb->posts
     1561    #   WHERE post_type = 'attachment' AND post_status != 'trash' AND post_parent < 1
     1562    //  DEV
     1563        if(strpos($param, "SELECT COUNT( * ) FROM $wpdb->posts WHERE post_type = 'attachment' AND post_status != 'trash' AND post_parent < 1") !== FALSE){
     1564            global $capa_protect_show_unattached_files;
     1565
     1566            if(!$capa_protect_show_unattached_files){
     1567                $param .= ' AND post_parent NOT IN (0)';
     1568            }
     1569        }
     1570
     1571
    15591572        return $param;
    15601573    }
  • capa/trunk/css/capa-style.css

    r391586 r444136  
    7575        border-bottom:1px solid #DFDFDF
    7676    }
     77
     78#capa-capabilities li{
     79    display:    inline-block;
     80    width:      200px;
     81}
     82#capa-capabilities label{
     83    padding:    3px 0px  0px 10px;
     84}
  • capa/trunk/readme.txt

    r398346 r444136  
    44Tags: restrict, restriction, category, categories, page, pages, protect, comments, security, Post, admin, plugin, posts, invisible, hide comments, comments private, hide comments from non-members, members, membership, sicherheit, begrenzung
    55Requires at least: 2.7.1
    6 Tested up to: 3.1.3
    7 Stable tag: 0.5.8.1
     6Tested up to: 3.2.1
     7Stable tag: 0.5.8.2
    88
    99Protects Categories, Pages and Posts for specific users & anonymous visitor
     
    6161
    6262== Changelog ==
     63
     64= v0.5.8.2 =
     65* Bugfix "Search No Result"
     66* Bugfix "Notice Error CAPA_DBUG"
     67* Bugfix "Warning array_flip"
    6368
    6469= v0.5.8.1 =
Note: See TracChangeset for help on using the changeset viewer.