public function get_access( $user = null ) { if ( ! $user instanceof User ) { $user = User::identify(); } // collect all possible token accesses on the given post $token_accesses = array( ACL::get_user_token_access( 'own_posts' ), ACL::get_user_token_access( 'post_any' ), ACL::get_user_token_access( 'post_' . $this->content_type() ), ); $post_tokens = DB::get_column( 'SELECT token_id FROM {post_tokens} WHERE post_id=?', array( $this->id ) ); foreach ( $post_tokens as $token ) { $token_accesses []= ACL::get_user_token_access( $token ); } // now that we have all the accesses, loop through them to build the access to the particular post $result = 0; foreach ( $token_accesses as $access ) { if ( $access == 0 ) { $mask = 0; break; } else { $result |= $access; } } return ACL::get_bitmask( $result );