Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
calendar_event_recurring_prefs.inc
1 <?php
17 require_once SQ_LIB_PATH.'/config/prefs.inc';
18 
19 
30 {
31 
32  var $pref_vars = Array (
33  'SQ_CALENDAR_EVENTS_FREQUENCY' => Array(
34  'name' => 'calendar_events_frequency',
35  'description' => 'Recurrence event frequency threshold in days. If set to a non-zero positive value, the recurring event will be displayed only once in listing pages when its frequency is less than the specified threshold value',
36  'default' => 0,
37  'protected' => FALSE,
38  ),
39  );
40 
41 
46  function __construct($pref_file='')
47  {
48  parent::__construct($pref_file);
49 
50  }//end constructor
51 
52 
63  function paintBackend(&$o, $have_lock, $pref=NULL)
64  {
65  $is_root = $GLOBALS['SQ_SYSTEM']->userRoot();
66  $is_admin = ($is_root || $GLOBALS['SQ_SYSTEM']->userSystemAdmin());
67 
68  if (is_null($pref) || $pref == 'SQ_CALENDAR_EVENTS_FREQUENCY') {
69  if (is_null($pref)) {
70  $o->openField("Events frequency threshold");
71  }
72 
73  if ($have_lock && $is_admin) {
74  text_box('prefs[SQ_CALENDAR_EVENTS_FREQUENCY]', $this->pref_vars['SQ_CALENDAR_EVENTS_FREQUENCY']['default'], 5);
75  } else {
76  echo array_get_index($this->pref_vars['SQ_CALENDAR_EVENTS_FREQUENCY'], 'default', 5);
77  }
78 
79  echo '<div class="sq-backend-note">'.$this->pref_vars['SQ_CALENDAR_EVENTS_FREQUENCY']['description'].'</div>';
80 
81  if (is_null($pref)) $o->closeField();
82  }//end if
83 
84  return TRUE;
85 
86  }//end paintBackend()
87 
88 
99  function processBackend($o, $have_lock, $pref=NULL)
100  {
101  $is_root = $GLOBALS['SQ_SYSTEM']->userRoot();
102  $is_admin = ($is_root || $GLOBALS['SQ_SYSTEM']->userSystemAdmin());
103  if (!$is_admin) return FALSE;
104 
105  // Backend page size
106  if (isset($_POST['prefs']['SQ_CALENDAR_EVENTS_FREQUENCY'])) {
107 
108  // Not an integer = user mistake, or possible script injection?
109  if (!is_numeric($_POST['prefs']['SQ_CALENDAR_EVENTS_FREQUENCY'])) {
110  trigger_error("Recurring events frequency threshold must be an integer", E_USER_WARNING);
111  return FALSE;
112  }
113  $frequency_threshold = (int)$_POST['prefs']['SQ_CALENDAR_EVENTS_FREQUENCY'];
114 
115  // Frequency threshold shouldnt be than zero
116  if ($frequency_threshold < 0) {
117  trigger_error("Recurring events frequency threshold must be an integer", E_USER_WARNING);
118  return FALSE;
119  }
120 
121  $this->pref_vars['SQ_CALENDAR_EVENTS_FREQUENCY']['default'] = $frequency_threshold;
122  }
123 
124  return TRUE;
125 
126  }//end processBackend()
127 
128 
129 }//end class
130 
131 ?>