public static function get_data_access_information($databaseid, $groupid = 0) {

        $params = array('databaseid' => $databaseid, 'groupid' => $groupid);
        $params = self::validate_parameters(self::get_data_access_information_parameters(), $params);
        $warnings = array();

        list($database, $course, $cm, $context) = self::validate_database($params['databaseid']);

        $result = array(
            'warnings' => $warnings
        );

        if (!empty($params['groupid'])) {
            $groupid = $params['groupid'];
            // Determine is the group is visible to user.
            if (!groups_group_visible($groupid, $course, $cm)) {
                throw new moodle_exception('notingroup');
            }
        } else {
            // Check to see if groups are being used here.
            $groupmode = groups_get_activity_groupmode($cm);
            if ($groupmode) {
                $groupid = groups_get_activity_group($cm);
            } else {
                $groupid = 0;
            }
        }
        // Group related information.
        $result['groupid'] = $groupid;
        $result['canaddentry'] = data_user_can_add_entry($database, $groupid, $groupmode, $context);

        // Now capabilities.
        $result['canmanageentries'] = has_capability('mod/data:manageentries', $context);
        $result['canapprove'] = has_capability('mod/data:approve', $context);

        // Now time access restrictions.
        list($result['timeavailable'], $warnings) = data_get_time_availability_status($database, $result['canmanageentries']);

        // Other information.
        $result['numentries'] = data_numentries($database);
        $result['entrieslefttoadd'] = data_get_entries_left_to_add($database, $result['numentries'], $result['canmanageentries']);
        $result['entrieslefttoview'] = data_get_entries_left_to_view($database, $result['numentries'], $result['canmanageentries']);
        $result['inreadonlyperiod'] = data_in_readonly_period($database);

        return $result;
    }
public static function get_data_access_information($databaseid, $groupid = 0) {

        $params = array('databaseid' => $databaseid, 'groupid' => $groupid);
        $params = self::validate_parameters(self::get_data_access_information_parameters(), $params);
        $warnings = array();

        list($database, $course, $cm, $context) = self::validate_database($params['databaseid']);

        $result = array(
            'warnings' => $warnings
        );

        if (!empty($params['groupid'])) {
            $groupid = $params['groupid'];
            // Determine is the group is visible to user.
            if (!groups_group_visible($groupid, $course, $cm)) {
                throw new moodle_exception('notingroup');
            }
        } else {
            // Check to see if groups are being used here.
            $groupmode = groups_get_activity_groupmode($cm);
            if ($groupmode) {
                $groupid = groups_get_activity_group($cm);
            } else {
                $groupid = 0;
            }
        }
        // Group related information.
        $result['groupid'] = $groupid;
        $result['canaddentry'] = data_user_can_add_entry($database, $groupid, $groupmode, $context);

        // Now capabilities.
        $result['canmanageentries'] = has_capability('mod/data:manageentries', $context);
        $result['canapprove'] = has_capability('mod/data:approve', $context);

        // Now time access restrictions.
        list($result['timeavailable'], $warnings) = data_get_time_availability_status($database, $result['canmanageentries']);

        // Other information.
        $result['numentries'] = data_numentries($database);
        $result['entrieslefttoadd'] = data_get_entries_left_to_add($database, $result['numentries'], $result['canmanageentries']);
        $result['entrieslefttoview'] = data_get_entries_left_to_view($database, $result['numentries'], $result['canmanageentries']);
        $result['inreadonlyperiod'] = data_in_readonly_period($database);

        return $result;
    }
public static function get_data_access_information ( $ databaseid , $ groupid = 0 ) { $ params = array ( 'databaseid' => $ databaseid , 'groupid' => $ groupid ) ; $ params = self :: validate_parameters ( self :: get_data_access_information_parameters ( ) , $ params ) ; $ warnings = array ( ) ; list ( $ database , $ course , $ cm , $ context ) = self :: validate_database ( $ params [ 'databaseid' ] ) ; $ result = array ( 'warnings' => $ warnings ) ; if ( ! empty ( $ params [ 'groupid' ] ) ) { $ groupid = $ params [ 'groupid' ] ; // Determine is the group is visible to user. if ( ! groups_group_visible ( $ groupid , $ course , $ cm ) ) { throw new moodle_exception ( 'notingroup' ) ; } } else { // Check to see if groups are being used here. $ groupmode = groups_get_activity_groupmode ( $ cm ) ; if ( $ groupmode ) { $ groupid = groups_get_activity_group ( $ cm ) ; } else { $ groupid = 0 ; } } // Group related information. $ result [ 'groupid' ] = $ groupid ; $ result [ 'canaddentry' ] = data_user_can_add_entry ( $ database , $ groupid , $ groupmode , $ context ) ; // Now capabilities. $ result [ 'canmanageentries' ] = has_capability ( 'mod/data:manageentries' , $ context ) ; $ result [ 'canapprove' ] = has_capability ( 'mod/data:approve' , $ context ) ; // Now time access restrictions. list ( $ result [ 'timeavailable' ] , $ warnings ) = data_get_time_availability_status ( $ database , $ result [ 'canmanageentries' ] ) ; // Other information. $ result [ 'numentries' ] = data_numentries ( $ database ) ; $ result [ 'entrieslefttoadd' ] = data_get_entries_left_to_add ( $ database , $ result [ 'numentries' ] , $ result [ 'canmanageentries' ] ) ; $ result [ 'entrieslefttoview' ] = data_get_entries_left_to_view ( $ database , $ result [ 'numentries' ] , $ result [ 'canmanageentries' ] ) ; $ result [ 'inreadonlyperiod' ] = data_in_readonly_period ( $ database ) ; return $ result ; }
Return access information for a given database.

@param int $databaseid the database instance id
@param int $groupid (optional) group id, 0 means that the function will determine the user group
@return array of warnings and access information
@since Moodle 3.3
@throws moodle_exception
Return access information for a given database .