'Return library data in the form of a dictionary.
:param  library:       library
:type   library:       galaxy.model.Library
:returns:   dict with data about the library
:rtype:     dictionary'

def get_library_dict(self, trans, library):

    library_dict = library.to_dict(view='element', value_mapper={'id': trans.security.encode_id, 'root_folder_id': trans.security.encode_id})
    if trans.app.security_agent.library_is_public(library, contents=False):
        library_dict['public'] = True
    library_dict['create_time_pretty'] = pretty_print_time_interval(library.create_time, precise=True)
    current_user_roles = trans.get_current_user_roles()
    if (not trans.user_is_admin()):
        library_dict['can_user_add'] = trans.app.security_agent.can_add_library_item(current_user_roles, library)
        library_dict['can_user_modify'] = trans.app.security_agent.can_modify_library_item(current_user_roles, library)
        library_dict['can_user_manage'] = trans.app.security_agent.can_manage_library_item(current_user_roles, library)
    else:
        library_dict['can_user_add'] = True
        library_dict['can_user_modify'] = True
        library_dict['can_user_manage'] = True
    return library_dict
