From: samhemelryk Date: Fri, 11 Sep 2009 03:14:42 +0000 (+0000) Subject: mod-data MDL-20253 Updated database activity module to make use of the new navigation... X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=29b64a22728e04d1260ff26f843abcc6758fdee8;p=moodle.git mod-data MDL-20253 Updated database activity module to make use of the new navigation structure --- diff --git a/lang/en_utf8/data.php b/lang/en_utf8/data.php index d9fac63da2..00838457af 100644 --- a/lang/en_utf8/data.php +++ b/lang/en_utf8/data.php @@ -50,6 +50,7 @@ $string['csvfailed'] = 'Unable to read the raw data from the CSV file'; $string['csvfile'] = 'CSV file'; $string['csvimport'] = 'CSV file import'; $string['csvwithselecteddelimiter'] = 'CSV text with selected delimiter:'; +$string['dataadministration'] = 'Database activity administration'; $string['data:approve'] = 'Approve unapproved entries'; $string['data:comment'] = 'Write comments'; $string['data:exportentry'] = 'Export a database entry'; diff --git a/mod/data/edit.php b/mod/data/edit.php index 51b8a329b8..ac5c6dbdb4 100755 --- a/mod/data/edit.php +++ b/mod/data/edit.php @@ -108,6 +108,12 @@ /// Print the page header $strdata = get_string('modulenameplural','data'); + if ($rid) { + $PAGE->navbar->add(get_string('editentry', 'data')); + } else { + $PAGE->navbar->add(get_string('add', 'data')); + } + $PAGE->set_title($data->name); $PAGE->set_button(update_module_button($cm->id, $course->id, get_string('modulename', 'data'))); echo $OUTPUT->header(); diff --git a/mod/data/export.php b/mod/data/export.php index 2242aef2f4..20e8657f6f 100644 --- a/mod/data/export.php +++ b/mod/data/export.php @@ -49,6 +49,8 @@ foreach ($fieldrecords as $fieldrecord) { $fields[]= data_get_field($fieldrecord, $data); } +$PAGE->navbar->add(get_string('export','data')); + $mform = new mod_data_export_form('export.php?d='.$data->id, $fields, $cm); if($mform->is_cancelled()) { diff --git a/mod/data/field.php b/mod/data/field.php index 824399cd3d..852d57785e 100755 --- a/mod/data/field.php +++ b/mod/data/field.php @@ -225,6 +225,7 @@ asort($menufield); //sort in alphabetical order $PAGE->set_pagetype('mod-data-field-' . $newtype); + $PAGE->navbar->add(get_string('fields', 'data')); if (($mode == 'new') && (!empty($newtype)) && confirm_sesskey()) { /// Adding a new field data_print_header($course, $cm, $data,'fields'); diff --git a/mod/data/lib.php b/mod/data/lib.php index 2ebe924f25..6f2af3454f 100755 --- a/mod/data/lib.php +++ b/mod/data/lib.php @@ -3192,3 +3192,84 @@ class data_portfolio_caller extends portfolio_module_caller_base { return array($formats, $includedfiles); } } + +function data_extend_navigation($navigation, $course, $module, $cm) { + global $CFG, $OUTPUT, $USER, $DB; + + $rid = optional_param('rid', 0, PARAM_INT); + + $data = $DB->get_record('data', array('id'=>$cm->instance)); + $currentgroup = groups_get_activity_group($cm); + $groupmode = groups_get_activity_groupmode($cm); + + $numentries = data_numentries($data); + /// Check the number of entries required against the number of entries already made (doesn't apply to teachers) + if ($data->requiredentries > 0 && $numentries < $data->requiredentries && !has_capability('mod/data:manageentries', $cm->context)) { + $data->entriesleft = $data->requiredentries - $numentries; + $key = $navigation->add(get_string('entrieslefttoadd', 'data', $data)); + $navigation->get($key)->add_class('note'); + } + + $navigation->add(get_string('list', 'data'), new moodle_url($CFG->wwwroot.'/mod/data/view.php', array('d'=>$cm->instance))); + if (!empty($rid)) { + $navigation->add(get_string('single', 'data'), new moodle_url($CFG->wwwroot.'/mod/data/view.php', array('d'=>$cm->instance, 'rid'=>$rid))); + } else { + $navigation->add(get_string('single', 'data'), new moodle_url($CFG->wwwroot.'/mod/data/view.php', array('d'=>$cm->instance, 'mode'=>'single'))); + } + $navigation->add(get_string('search', 'data'), new moodle_url($CFG->wwwroot.'/mod/data/view.php', array('d'=>$cm->instance, 'mode'=>'search'))); +} + +function data_extend_settings_navigation($settings, $module) { + global $PAGE, $USER, $OUTPUT, $CFG, $DB; + + $data = $DB->get_record('data', array('id'=>$PAGE->cm->instance)); + $datanavkey = $settings->add(get_string('dataadministration', 'data')); + $datanav = $settings->get($datanavkey); + $datanav->forceopen = true; + + $currentgroup = groups_get_activity_group($PAGE->cm); + $groupmode = groups_get_activity_groupmode($PAGE->cm); + + if (data_user_can_add_entry($data, $currentgroup, $groupmode)) { // took out participation list here! + if (empty($editentry)) { + $addstring = get_string('add', 'data'); + } else { + $addstring = get_string('editentry', 'data'); + } + $datanav->add($addstring, new moodle_url($CFG->wwwroot.'/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. + $datanav->add(get_string('export', 'data'), new moodle_url($CFG->wwwroot.'/mod/data/export.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'; + } + + $templatekey = $datanav->add(get_string('templates', 'data')); + $templates = $datanav->get($templatekey); + + $templatelist = array ('listtemplate', 'singletemplate', 'asearchtemplate', 'addtemplate', 'rsstemplate', 'csstemplate', 'jstemplate'); + foreach ($templatelist as $template) { + $templates->add(get_string($template, 'data'), new moodle_url($CFG->wwwroot.'/mod/data/templates.php', array('d'=>$data->id,'mode'=>$template))); + } + + $datanav->add(get_string('fields', 'data'), new moodle_url($CFG->wwwroot.'/mod/data/field.php', array('d'=>$data->id))); + $datanav->add(get_string('presets', 'data'), new moodle_url($CFG->wwwroot.'/mod/data/preset.php', array('d'=>$data->id))); + } + + if (has_capability('moodle/course:manageactivities', $PAGE->cm->context)) { + $datanav->add(get_string('updatethis', '', get_string('modulename', 'choice')), new moodle_url($CFG->wwwroot.'/course/mod.php', array('update' => $PAGE->cm->id, 'return' => true, 'sesskey' => sesskey()))); + } +} \ No newline at end of file diff --git a/mod/data/preset.php b/mod/data/preset.php index da735ec359..341456872a 100644 --- a/mod/data/preset.php +++ b/mod/data/preset.php @@ -67,6 +67,8 @@ if ($userid && ($userid != $USER->id) && !has_capability('mod/data:viewalluserpr /* Need sesskey security check here for import instruction */ $sesskey = sesskey(); +$PAGE->navbar->add(get_string('presets', 'data')); + /********************************************************************/ /* Output */ if ($action !== 'export') { diff --git a/mod/data/templates.php b/mod/data/templates.php index 1c252bbf48..3db76f0d9c 100755 --- a/mod/data/templates.php +++ b/mod/data/templates.php @@ -78,6 +78,7 @@ $bodytag .= 'currTextarea = document.getElementById(\'tempform\').template;'; $bodytag .= '" '; + $PAGE->navbar->add(get_string($mode,'data')); $PAGE->requires->js('mod/data/data.js'); $PAGE->set_title($data->name); $PAGE->set_button(update_module_button($cm->id, $course->id, get_string('modulename', 'data'))); @@ -155,7 +156,7 @@ echo ''; /// Add the HTML editor(s). - $usehtmleditor = $editor && can_use_html_editor() && ($mode != 'csstemplate') && ($mode != 'jstemplate'); + $usehtmleditor = can_use_html_editor() && ($mode != 'csstemplate') && ($mode != 'jstemplate'); if ($mode == 'listtemplate'){ // Print the list template header. echo ''; @@ -234,7 +235,7 @@ echo '



'; if (can_use_html_editor()) { echo '

'; - if ($editor) { + if ($usehtmleditor) { $switcheditor = get_string('editordisable', 'data'); } else { $switcheditor = get_string('editorenable', 'data'); diff --git a/mod/data/view.php b/mod/data/view.php index 2d8c032514..d24b3b99fa 100755 --- a/mod/data/view.php +++ b/mod/data/view.php @@ -288,6 +288,10 @@ } $buttons .= '
'; + if ($mode == 'asearch') { + $PAGE->navbar->add(get_string('search')); + } + $PAGE->set_title($title); $PAGE->set_heading($course->fullname); $PAGE->set_button($buttons);