[ Index ]

PHP Cross Reference of Moodle 1.9.3 [Build 15-Oct-2008]

title

Body

[close]

/mod/data/ -> tabs.php (source)

   1  <?php  // $Id: tabs.php,v 1.28.2.3 2008/06/12 13:49:40 robertall Exp $
   2  ///////////////////////////////////////////////////////////////////////////
   3  //                                                                       //
   4  // NOTICE OF COPYRIGHT                                                   //
   5  //                                                                       //
   6  // Moodle - Modular Object-Oriented Dynamic Learning Environment         //
   7  //          http://moodle.org                                            //
   8  //                                                                       //
   9  // Copyright (C) 2005 Martin Dougiamas  http://dougiamas.com             //
  10  //                                                                       //
  11  // This program is free software; you can redistribute it and/or modify  //
  12  // it under the terms of the GNU General Public License as published by  //
  13  // the Free Software Foundation; either version 2 of the License, or     //
  14  // (at your option) any later version.                                   //
  15  //                                                                       //
  16  // This program is distributed in the hope that it will be useful,       //
  17  // but WITHOUT ANY WARRANTY; without even the implied warranty of        //
  18  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         //
  19  // GNU General Public License for more details:                          //
  20  //                                                                       //
  21  //          http://www.gnu.org/copyleft/gpl.html                         //
  22  //                                                                       //
  23  ///////////////////////////////////////////////////////////////////////////
  24  
  25  // This file to be included so we can assume config.php has already been included.
  26  // We also assume that $user, $course, $currenttab have been set
  27  
  28  
  29      if (empty($currenttab) or empty($data) or empty($course)) {
  30          error('You cannot call this script in that way');
  31      }
  32  
  33      $context = get_context_instance(CONTEXT_MODULE, $cm->id);
  34  
  35      $inactive = NULL;
  36      $activetwo = NULL;
  37      $tabs = array();
  38      $row = array();
  39  
  40      $row[] = new tabobject('list', $CFG->wwwroot.'/mod/data/view.php?d='.$data->id, get_string('list','data'));
  41      
  42      if (isset($record)) {
  43          $row[] = new tabobject('single', $CFG->wwwroot.'/mod/data/view.php?d='.$data->id.'&amp;rid='.$record->id, get_string('single','data'));
  44      } else {
  45          $row[] = new tabobject('single', $CFG->wwwroot.'/mod/data/view.php?d='.$data->id.'&amp;mode=single', get_string('single','data'));
  46      }
  47  
  48      // Add an advanced search tab.
  49      $row[] = new tabobject('asearch', $CFG->wwwroot.'/mod/data/view.php?d='.$data->id.'&amp;mode=asearch', get_string('search', 'data'));
  50  
  51      if (isloggedin()) {
  52          if (data_user_can_add_entry($data, $currentgroup, $groupmode)) { // took out participation list here!
  53              $addstring = empty($editentry) ? get_string('add', 'data') : get_string('editentry', 'data');
  54              $row[] = new tabobject('add', $CFG->wwwroot.'/mod/data/edit.php?d='.$data->id, $addstring);
  55          }
  56          if (has_capability(DATA_CAP_EXPORT, $context)) {
  57              // The capability required to Export database records is centrally defined in 'lib.php'
  58              // and should be weaker than those required to edit Templates, Fields and Presets. 
  59              $row[] = new tabobject('export', $CFG->wwwroot.'/mod/data/export.php?d='.$data->id,
  60                           get_string('export', 'data'));
  61          }
  62          if (has_capability('mod/data:managetemplates', $context)) {
  63              if ($currenttab == 'list') {
  64                  $defaultemplate = 'listtemplate';
  65              } else if ($currenttab == 'add') {
  66                  $defaultemplate = 'addtemplate';
  67              } else if ($currenttab == 'asearch') {
  68                  $defaultemplate = 'asearchtemplate';
  69              } else {
  70                  $defaultemplate = 'singletemplate';
  71              }
  72  
  73              $row[] = new tabobject('templates', $CFG->wwwroot.'/mod/data/templates.php?d='.$data->id.'&amp;mode='.$defaultemplate,
  74                           get_string('templates','data'));
  75              $row[] = new tabobject('fields', $CFG->wwwroot.'/mod/data/field.php?d='.$data->id,
  76                           get_string('fields','data'));
  77              $row[] = new tabobject('presets', $CFG->wwwroot.'/mod/data/preset.php?d='.$data->id,
  78                           get_string('presets', 'data'));
  79          }
  80      }
  81  
  82      $tabs[] = $row;
  83  
  84      if ($currenttab == 'templates' and isset($mode)) {
  85  
  86          $inactive = array();
  87          $inactive[] = 'templates';
  88          $templatelist = array ('listtemplate', 'singletemplate', 'asearchtemplate', 'addtemplate', 'rsstemplate', 'csstemplate', 'jstemplate');
  89  
  90          $row  = array();
  91          $currenttab ='';
  92          foreach ($templatelist as $template) {
  93              $row[] = new tabobject($template, "templates.php?d=$data->id&amp;mode=$template", get_string($template, 'data'));
  94              if ($template == $mode) {
  95                  $currenttab = $template;
  96              }
  97          }
  98          if ($currenttab == '') {
  99              $currenttab = $mode = 'singletemplate';
 100          }
 101          $tabs[] = $row;
 102          $activetwo = array('templates');
 103      }
 104  
 105  // Print out the tabs and continue!
 106      print_tabs($tabs, $currenttab, $inactive, $activetwo);
 107  
 108  ?>


Generated: Wed Jan 14 11:33:29 2009 Cross-referenced by PHPXref 0.7