def discussion_category_id_access(course, user, discussion_id, xblock=None):
 if (discussion_id in course.top_level_discussion_topic_ids):
  return True
 try:
  if (not xblock):
   key = get_cached_discussion_key(course.id, discussion_id)
   if (not key):
    return False
   xblock = modulestore().get_item(key)
  return (has_required_keys(xblock) and has_access(user, 'load', xblock, course.id))
 except DiscussionIdMapIsNotCached:
  return (discussion_id in get_discussion_categories_ids(course, user))

def discussion_category_id_access ( course , user , discussion_id , xblock = None ) : if ( discussion_id in course . top_level_discussion_topic_ids ) : return True try : if ( not xblock ) : key = get_cached_discussion_key ( course . id , discussion_id ) if ( not key ) : return False xblock = modulestore ( ) . get_item ( key ) return ( has_required_keys ( xblock ) and has_access ( user , 'load' , xblock , course . id ) ) except DiscussionIdMapIsNotCached : return ( discussion_id in get_discussion_categories_ids ( course , user ) )
returns true iff the given discussion_id is accessible for user in course .