Beispiel #1
0
             $namearr = explode('_', $name);
             // Second one is the field id
             if (empty($field->field) || $namearr[1] != $field->field->id) {
                 // Try to reuse classes
                 $field = data_get_field_from_id($namearr[1], $data);
             }
             if ($field) {
                 $field->update_content($rid, $value, $name);
             }
         }
     }
     add_to_log($course->id, 'data', 'update', "view.php?d={$data->id}&rid={$rid}", $data->id, $cm->id);
     redirect($CFG->wwwroot . '/mod/data/view.php?d=' . $data->id . '&rid=' . $rid);
 } else {
     /// Add some new records
     if (!data_user_can_add_entry($data, $currentgroup, $groupmode, $context)) {
         print_error('cannotadd', 'data');
     }
     /// Check if maximum number of entry as specified by this database is reached
     /// Of course, you can't be stopped if you are an editting teacher! =)
     if (data_atmaxentries($data) and !has_capability('mod/data:manageentries', $context)) {
         echo $OUTPUT->header();
         echo $OUTPUT->notification(get_string('atmaxentry', 'data'));
         echo $OUTPUT->footer();
         exit;
     }
     ///Empty form checking - you can't submit an empty form!
     $emptyform = true;
     // assume the worst
     foreach ($datarecord as $name => $value) {
         if (!in_array($name, $ignorenames)) {
Beispiel #2
0
if (empty($currenttab) or empty($data) or empty($course)) {
    error('You cannot call this script in that way');
}
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
$inactive = NULL;
$activetwo = NULL;
$tabs = array();
$row = array();
$row[] = new tabobject('list', $CFG->wwwroot . '/mod/data/view.php?d=' . $data->id, get_string('list', 'data'));
if (isset($record)) {
    $row[] = new tabobject('single', $CFG->wwwroot . '/mod/data/view.php?d=' . $data->id . '&rid=' . $record->id, get_string('single', 'data'));
} else {
    $row[] = new tabobject('single', $CFG->wwwroot . '/mod/data/view.php?d=' . $data->id . '&mode=single', get_string('single', 'data'));
}
if (isloggedin()) {
    if (data_user_can_add_entry($data, $currentgroup, $groupmode)) {
        // took out participation list here!
        $addstring = empty($editentry) ? get_string('add', 'data') : get_string('editentry', 'data');
        $row[] = new tabobject('add', $CFG->wwwroot . '/mod/data/edit.php?d=' . $data->id, $addstring);
    }
    if (has_capability('mod/data:managetemplates', $context)) {
        if ($currenttab == 'list') {
            $defaultemplate = 'listtemplate';
        } else {
            if ($currenttab == 'add') {
                $defaultemplate = 'addtemplate';
            } else {
                $defaultemplate = 'singletemplate';
            }
        }
        $row[] = new tabobject('templates', $CFG->wwwroot . '/mod/data/templates.php?d=' . $data->id . '&mode=' . $defaultemplate, get_string('templates', 'data'));
Beispiel #3
0
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
$inactive = NULL;
$activetwo = NULL;
$tabs = array();
$row = array();
$row[] = new tabobject('list', $CFG->wwwroot . '/mod/data/view.php?d=' . $data->id, get_string('list', 'data'));
if (isset($record)) {
    $row[] = new tabobject('single', $CFG->wwwroot . '/mod/data/view.php?d=' . $data->id . '&rid=' . $record->id, get_string('single', 'data'));
} else {
    $row[] = new tabobject('single', $CFG->wwwroot . '/mod/data/view.php?d=' . $data->id . '&mode=single', get_string('single', 'data'));
}
// Add an advanced search tab.
$row[] = new tabobject('asearch', $CFG->wwwroot . '/mod/data/view.php?d=' . $data->id . '&mode=asearch', get_string('search', 'data'));
if (isloggedin()) {
    // just a perf shortcut
    if (data_user_can_add_entry($data, $currentgroup, $groupmode) && !data_atmaxentries($data)) {
        // took out participation list here!
        $addstring = empty($editentry) ? get_string('add', 'data') : get_string('editentry', 'data');
        $row[] = new tabobject('add', $CFG->wwwroot . '/mod/data/edit.php?d=' . $data->id, $addstring);
    }
    if (has_capability(DATA_CAP_EXPORT, $context)) {
        // The capability required to Export database records is centrally defined in 'lib.php'
        // and should be weaker than those required to edit Templates, Fields and Presets.
        $row[] = new tabobject('export', $CFG->wwwroot . '/mod/data/export.php?d=' . $data->id, get_string('export', 'data'));
    }
    if (has_capability('mod/data:managetemplates', $context)) {
        if ($currenttab == 'list') {
            $defaultemplate = 'listtemplate';
        } else {
            if ($currenttab == 'add') {
                $defaultemplate = 'addtemplate';
Beispiel #4
0
/**
 * Adds module specific settings to the settings block
 *
 * @param settings_navigation $settings The settings navigation object
 * @param navigation_node $datanode The node to add module settings to
 */
function data_extend_settings_navigation(settings_navigation $settings, navigation_node $datanode) {
    global $PAGE, $DB, $CFG, $USER;

    $data = $DB->get_record('data', array("id" => $PAGE->cm->instance));

    $currentgroup = groups_get_activity_group($PAGE->cm);
    $groupmode = groups_get_activity_groupmode($PAGE->cm);

    if (data_user_can_add_entry($data, $currentgroup, $groupmode, $PAGE->cm->context)) { // took out participation list here!
        if (empty($editentry)) { //TODO: undefined
            $addstring = get_string('add', 'data');
        } else {
            $addstring = get_string('editentry', 'data');
        }
        $datanode->add($addstring, new moodle_url('/mod/data/edit.php', array('d'=>$PAGE->cm->instance)));
    }

    if (has_capability(DATA_CAP_EXPORT, $PAGE->cm->context)) {
        // The capability required to Export database records is centrally defined in 'lib.php'
        // and should be weaker than those required to edit Templates, Fields and Presets.
        $datanode->add(get_string('exportentries', 'data'), new moodle_url('/mod/data/export.php', array('d'=>$data->id)));
    }
    if (has_capability('mod/data:manageentries', $PAGE->cm->context)) {
        $datanode->add(get_string('importentries', 'data'), new moodle_url('/mod/data/import.php', array('d'=>$data->id)));
    }

    if (has_capability('mod/data:managetemplates', $PAGE->cm->context)) {
        $currenttab = '';
        if ($currenttab == 'list') {
            $defaultemplate = 'listtemplate';
        } else if ($currenttab == 'add') {
            $defaultemplate = 'addtemplate';
        } else if ($currenttab == 'asearch') {
            $defaultemplate = 'asearchtemplate';
        } else {
            $defaultemplate = 'singletemplate';
        }

        $templates = $datanode->add(get_string('templates', 'data'));

        $templatelist = array ('listtemplate', 'singletemplate', 'asearchtemplate', 'addtemplate', 'rsstemplate', 'csstemplate', 'jstemplate');
        foreach ($templatelist as $template) {
            $templates->add(get_string($template, 'data'), new moodle_url('/mod/data/templates.php', array('d'=>$data->id,'mode'=>$template)));
        }

        $datanode->add(get_string('fields', 'data'), new moodle_url('/mod/data/field.php', array('d'=>$data->id)));
        $datanode->add(get_string('presets', 'data'), new moodle_url('/mod/data/preset.php', array('d'=>$data->id)));
    }

    if (!empty($CFG->enablerssfeeds) && !empty($CFG->data_enablerssfeeds) && $data->rssarticles > 0) {
        require_once("$CFG->libdir/rsslib.php");

        $string = get_string('rsstype','forum');

        $url = new moodle_url(rss_get_url($PAGE->cm->context->id, $USER->id, 'mod_data', $data->id));
        $datanode->add($string, $url, settings_navigation::TYPE_SETTING, null, null, new pix_icon('i/rss', ''));
    }
}
Beispiel #5
0
    $tabs = array();
    $row = array();

    $row[] = new tabobject('list', $CFG->wwwroot.'/mod/data/view.php?d='.$data->id, get_string('list','data'));

    if (isset($record)) {
        $row[] = new tabobject('single', $CFG->wwwroot.'/mod/data/view.php?d='.$data->id.'&rid='.$record->id, get_string('single','data'));
    } else {
        $row[] = new tabobject('single', $CFG->wwwroot.'/mod/data/view.php?d='.$data->id.'&mode=single', get_string('single','data'));
    }

    // Add an advanced search tab.
    $row[] = new tabobject('asearch', $CFG->wwwroot.'/mod/data/view.php?d='.$data->id.'&mode=asearch', get_string('search', 'data'));

    if (isloggedin()) { // just a perf shortcut
        if (data_user_can_add_entry($data, $currentgroup, $groupmode, $context)) { // took out participation list here!
            $addstring = empty($editentry) ? get_string('add', 'data') : get_string('editentry', 'data');
            $row[] = new tabobject('add', $CFG->wwwroot.'/mod/data/edit.php?d='.$data->id, $addstring);
        }
        if (has_capability(DATA_CAP_EXPORT, $context)) {
            // The capability required to Export database records is centrally defined in 'lib.php'
            // and should be weaker than those required to edit Templates, Fields and Presets.
            $row[] = new tabobject('export', $CFG->wwwroot.'/mod/data/export.php?d='.$data->id,
                         get_string('export', 'data'));
        }
        if (has_capability('mod/data:managetemplates', $context)) {
            if ($currenttab == 'list') {
                $defaultemplate = 'listtemplate';
            } else if ($currenttab == 'add') {
                $defaultemplate = 'addtemplate';
            } else if ($currenttab == 'asearch') {