Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/mod/data/tabs.php
Go to the documentation of this file.
00001 <?php
00003 //                                                                       //
00004 // NOTICE OF COPYRIGHT                                                   //
00005 //                                                                       //
00006 // Moodle - Modular Object-Oriented Dynamic Learning Environment         //
00007 //          http://moodle.org                                            //
00008 //                                                                       //
00009 // Copyright (C) 2005 Martin Dougiamas  http://dougiamas.com             //
00010 //                                                                       //
00011 // This program is free software; you can redistribute it and/or modify  //
00012 // it under the terms of the GNU General Public License as published by  //
00013 // the Free Software Foundation; either version 2 of the License, or     //
00014 // (at your option) any later version.                                   //
00015 //                                                                       //
00016 // This program is distributed in the hope that it will be useful,       //
00017 // but WITHOUT ANY WARRANTY; without even the implied warranty of        //
00018 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         //
00019 // GNU General Public License for more details:                          //
00020 //                                                                       //
00021 //          http://www.gnu.org/copyleft/gpl.html                         //
00022 //                                                                       //
00024 
00025 // This file to be included so we can assume config.php has already been included.
00026 // We also assume that $user, $course, $currenttab have been set
00027 
00028 
00029     if (empty($currenttab) or empty($data) or empty($course)) {
00030         print_error('cannotcallscript');
00031     }
00032 
00033     $context = get_context_instance(CONTEXT_MODULE, $cm->id);
00034 
00035     $inactive = NULL;
00036     $activetwo = NULL;
00037     $tabs = array();
00038     $row = array();
00039 
00040     $row[] = new tabobject('list', $CFG->wwwroot.'/mod/data/view.php?d='.$data->id, get_string('list','data'));
00041 
00042     if (isset($record)) {
00043         $row[] = new tabobject('single', $CFG->wwwroot.'/mod/data/view.php?d='.$data->id.'&amp;rid='.$record->id, get_string('single','data'));
00044     } else {
00045         $row[] = new tabobject('single', $CFG->wwwroot.'/mod/data/view.php?d='.$data->id.'&amp;mode=single', get_string('single','data'));
00046     }
00047 
00048     // Add an advanced search tab.
00049     $row[] = new tabobject('asearch', $CFG->wwwroot.'/mod/data/view.php?d='.$data->id.'&amp;mode=asearch', get_string('search', 'data'));
00050 
00051     if (isloggedin()) { // just a perf shortcut
00052         if (data_user_can_add_entry($data, $currentgroup, $groupmode, $context)) { // took out participation list here!
00053             $addstring = empty($editentry) ? get_string('add', 'data') : get_string('editentry', 'data');
00054             $row[] = new tabobject('add', $CFG->wwwroot.'/mod/data/edit.php?d='.$data->id, $addstring);
00055         }
00056         if (has_capability(DATA_CAP_EXPORT, $context)) {
00057             // The capability required to Export database records is centrally defined in 'lib.php'
00058             // and should be weaker than those required to edit Templates, Fields and Presets.
00059             $row[] = new tabobject('export', $CFG->wwwroot.'/mod/data/export.php?d='.$data->id,
00060                          get_string('export', 'data'));
00061         }
00062         if (has_capability('mod/data:managetemplates', $context)) {
00063             if ($currenttab == 'list') {
00064                 $defaultemplate = 'listtemplate';
00065             } else if ($currenttab == 'add') {
00066                 $defaultemplate = 'addtemplate';
00067             } else if ($currenttab == 'asearch') {
00068                 $defaultemplate = 'asearchtemplate';
00069             } else {
00070                 $defaultemplate = 'singletemplate';
00071             }
00072 
00073             $row[] = new tabobject('templates', $CFG->wwwroot.'/mod/data/templates.php?d='.$data->id.'&amp;mode='.$defaultemplate,
00074                          get_string('templates','data'));
00075             $row[] = new tabobject('fields', $CFG->wwwroot.'/mod/data/field.php?d='.$data->id,
00076                          get_string('fields','data'));
00077             $row[] = new tabobject('presets', $CFG->wwwroot.'/mod/data/preset.php?d='.$data->id,
00078                          get_string('presets', 'data'));
00079         }
00080     }
00081 
00082     $tabs[] = $row;
00083 
00084     if ($currenttab == 'templates' and isset($mode)) {
00085 
00086         $inactive = array();
00087         $inactive[] = 'templates';
00088         $templatelist = array ('listtemplate', 'singletemplate', 'asearchtemplate', 'addtemplate', 'rsstemplate', 'csstemplate', 'jstemplate');
00089 
00090         $row  = array();
00091         $currenttab ='';
00092         foreach ($templatelist as $template) {
00093             $row[] = new tabobject($template, "templates.php?d=$data->id&amp;mode=$template", get_string($template, 'data'));
00094             if ($template == $mode) {
00095                 $currenttab = $template;
00096             }
00097         }
00098         if ($currenttab == '') {
00099             $currenttab = $mode = 'singletemplate';
00100         }
00101         $tabs[] = $row;
00102         $activetwo = array('templates');
00103     }
00104 
00105 // Print out the tabs and continue!
00106     print_tabs($tabs, $currenttab, $inactive, $activetwo);
00107 
00108 
 All Data Structures Namespaces Files Functions Variables Enumerations