[ Index ]

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

title

Body

[close]

/calendar/ -> preferences.php (source)

   1  <?PHP  // $Id: preferences.php,v 1.19.2.2 2008/01/24 14:10:45 nicolasconnault Exp $
   2         // preferences.php - user prefs for calendar
   3  
   4      require_once ('../config.php');
   5      require_once($CFG->dirroot.'/calendar/lib.php');
   6  
   7      if (isset($SESSION->cal_course_referer)) {
   8          if (! $course = get_record('course', 'id', $SESSION->cal_course_referer)) {
   9              $course = get_site();
  10          }
  11      }
  12  
  13      if ($course->id != SITEID) {
  14          require_login($course->id);
  15      }
  16      // Initialize the session variables
  17      calendar_session_vars();
  18  
  19  /// If data submitted, then process and store.
  20  
  21      if ($form = data_submitted()) {
  22          foreach ($form as $preference => $value) {
  23              switch ($preference) {
  24                  case 'timeformat':
  25                      if ($value != CALENDAR_TF_12 and $value != CALENDAR_TF_24) {
  26                          $value = '';
  27                      }
  28                      set_user_preference('calendar_timeformat', $value);
  29                  break;
  30                  case 'startwday':
  31                      $value = intval($value);
  32                      if ($value < 0 or $value > 6) {
  33                          $value = abs($value % 7);
  34                      }
  35                      set_user_preference('calendar_startwday', $value);
  36                  break;
  37                  case 'maxevents':
  38                      if (intval($value) >= 1) {
  39                          set_user_preference('calendar_maxevents', $value);
  40                      }
  41                  break;
  42                  case 'lookahead':
  43                      if (intval($value) >= 1) {
  44                          set_user_preference('calendar_lookahead', $value);
  45                      }
  46                  break;
  47                  case 'persistflt':
  48                      set_user_preference('calendar_persistflt', intval($value));
  49                  break;
  50              }
  51          }
  52          redirect('view.php?course='.$course->id, get_string('changessaved'), 1);
  53          exit;
  54      }
  55  
  56      $site = get_site();
  57  
  58      $strcalendar = get_string('calendar', 'calendar');
  59      $strpreferences = get_string('preferences', 'calendar');
  60  
  61      $navlinks = array();
  62      if ($course->id != SITEID) {
  63          $navlinks[] = array('name' => $course->shortname,
  64                              'link' => "$CFG->wwwroot/course/view.php?id=$course->id",
  65                              'type' => 'misc');
  66      }
  67      $navlinks[] = array('name' => $strpreferences, 'link' => 'view.php', 'type' => 'misc');
  68      $navigation = build_navigation($navlinks);
  69  
  70      print_header("$site->shortname: $strcalendar: $strpreferences", $strcalendar, $navigation,
  71                   '', '', true, '', user_login_string($site));
  72  
  73  
  74      print_heading($strpreferences);
  75  
  76      print_simple_box_start("center");
  77  
  78      $prefs->timeformat = get_user_preferences('calendar_timeformat', '');
  79      $prefs->startwday  = get_user_preferences('calendar_startwday', CALENDAR_STARTING_WEEKDAY);
  80      $prefs->maxevents  = get_user_preferences('calendar_maxevents', CALENDAR_UPCOMING_MAXEVENTS);
  81      $prefs->lookahead  = get_user_preferences('calendar_lookahead', CALENDAR_UPCOMING_DAYS);
  82      $prefs->persistflt = get_user_preferences('calendar_persistflt', 0);
  83  
  84      include ('./preferences.html');
  85      print_simple_box_end();
  86  
  87      print_footer($course);
  88  
  89  ?>


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