Changeset 3746


Ignore:
Timestamp:
10/01/09 17:28:20 (2 years ago)
Author:
rickc
Message:

Make the undelete plugin ACL aware.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/htdocs/system/plugins/undelete/undelete.plugin.php

    r3715 r3746  
    4141                // see the false return value, and simply return, leaving 
    4242                // the post in the database. 
    43                 if( $post->status != Post::status( 'deleted' ) && is_object( User::get_by_id( $post->user_id ) ) ) { 
     43                if( $post->status != Post::status( 'deleted' ) && ACL::access_check( $post->get_access(), 'delete' ) ) { 
    4444                        $post->info->prior_status = $post->status; 
    4545                        $post->status = Post::status( 'deleted' ); 
     
    5454        public function filter_post_actions($actions, $post) 
    5555        { 
    56                 if ( $post->status == Post::status('deleted') ) { 
     56                if ( $post->status == Post::status('deleted') && ACL::access_check( $post->get_access(), 'delete' ) ) { 
    5757                        $actions['remove']['label']= _t('Delete forever'); 
    5858                        $actions['remove']['title']= _t('Permanently delete this post'); 
     
    7676        { 
    7777                $post = Post::get( array( 'id' => $post_id, 'status' => Post::status('any') ) ); 
    78                 if ( $post->status == Post::status('deleted') ) { 
     78                if ( $post->status == Post::status('deleted') && ACL::access_check( $post->get_access(), 'delete' ) ) { 
    7979                        $post->status = $post->info->prior_status ? $post->info->prior_status : Post::status( 'draft' ); 
    8080                        unset( $post->info->prior_status ); 
     
    106106        } 
    107107 
     108        private function get_perms() 
     109        { 
     110                $type_perms = array(); 
     111                $types = Post::list_active_post_types(); 
     112                foreach( $types as $key => $value ) { 
     113                        $perm = array( 'post_' . $key => ACL::get_bitmask( 'delete' ) ); 
     114                        $types_perms = array_merge( $type_perms, $perm ); 
     115                } 
     116                $perms = array( 'own_posts' => ACL::get_bitmask( 'delete' ), 'post_any' => ACL::get_bitmask( 'delete' ) ); 
     117                $perms = array_merge( $perms, $type_perms ); 
     118                return $perms; 
     119        } 
     120 
    108121        public function filter_plugin_config( $actions, $plugin_id ) 
    109122        { 
    110123                if ( $plugin_id == $this->plugin_id() ) { 
    111124                        $actions[]= _t( 'Configure' ); 
    112                         $actions[]= _t( 'Empty Trash' ); 
     125                        if( User::identify()->can_any( $this->get_perms() ) ) { 
     126                                $actions[]= _t( 'Empty Trash' ); 
     127                        } 
    113128                } 
    114129                return $actions; 
     
    161176 
    162177                foreach($posts as $post) { 
    163                         $post->delete(); 
    164                         $count++; 
     178                        if( ACL::access_check( $post->get_access(), 'delete' ) ) { 
     179                                $post->delete(); 
     180                                $count++; 
     181                        } 
    165182                } 
    166183 
Note: See TracChangeset for help on using the changeset viewer.