]> git.mjollnir.org Git - moodle.git/commitdiff
mod-data MDL-20253 Updated database activity module to make use of the new navigation...
authorsamhemelryk <samhemelryk>
Fri, 11 Sep 2009 03:14:42 +0000 (03:14 +0000)
committersamhemelryk <samhemelryk>
Fri, 11 Sep 2009 03:14:42 +0000 (03:14 +0000)
lang/en_utf8/data.php
mod/data/edit.php
mod/data/export.php
mod/data/field.php
mod/data/lib.php
mod/data/preset.php
mod/data/templates.php
mod/data/view.php

index d9fac63da227d1b752bee06bb1621d7c2ec1fc06..00838457af39b2ad64c436471fe880f30fa84e5a 100644 (file)
@@ -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'] = '<acronym title=\"Comma Separated Values\">CSV</acronym> 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';
index 51b8a329b84642669ba75ebb5d69c5b57818a9ef..ac5c6dbdb4390f7550a1d15bc97f6494146f58a7 100755 (executable)
 /// 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();
index 2242aef2f459c2c20b54af18dbc14e2acc5d427b..20e8657f6f7e22fd59dcc4db5c4d6d7a2a06cfc4 100644 (file)
@@ -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()) {
index 824399cd3df428ac8097bec5c7e3f8b2a2b6e247..852d57785e034e952e7bc045d5e562a372e17814 100755 (executable)
     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');
 
index 2ebe924f25744f3c3ad766effc90d1818b91d8dc..6f2af3454f50bdc5e576649e3486049bc550b8c2 100755 (executable)
@@ -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
index da735ec359a9f01db06d09f6652e06769016f10f..341456872afd6d0521e05ffa023d190bee871128 100644 (file)
@@ -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') {
index 1c252bbf48b7a086277b216803aac0e01fc3d804..3db76f0d9ca755c5276e6496b476220d55c188f8 100755 (executable)
@@ -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')));
     echo '<table cellpadding="4" cellspacing="0" border="0">';
 
 /// 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 '<tr>';
         echo '<br /><br /><br /><br /><input type="submit" name="defaultform" value="'.get_string('resettemplate','data').'" />';
         if (can_use_html_editor()) {
             echo '<br /><br />';
-            if ($editor) {
+            if ($usehtmleditor) {
                 $switcheditor = get_string('editordisable', 'data');
             } else {
                 $switcheditor = get_string('editorenable', 'data');
index 2d8c0325142e878de793e4733512b3fb6422fecd..d24b3b99fa1931d6fbc788d7e70e1d3a4b5a8b31 100755 (executable)
     }
     $buttons .= '</tr></table>';
 
+    if ($mode == 'asearch') {
+        $PAGE->navbar->add(get_string('search'));
+    }
+
     $PAGE->set_title($title);
     $PAGE->set_heading($course->fullname);
     $PAGE->set_button($buttons);