Exemple #1
0
 /**
  *  Sets all variables to the matching values from $rows.
  *
  *  @param  array   $row        Array of values, from DB or $_POST
  *  @param  boolean $fromDB     True if read from DB, false if from $_POST
  */
 public function SetVars($row, $fromDB = false)
 {
     if (!is_array($row)) {
         return;
     }
     $fields = array('ev_id', 'det_id', 'date_start', 'date_end', 'time_start1', 'time_end1', 'time_start2', 'time_end2');
     foreach ($fields as $field) {
         if (isset($row['rp_' . $field])) {
             $this->{$field} = $row['rp_' . $field];
         }
     }
     // Join or split the date values as needed
     if ($fromDB) {
         // Read from the database
         // dates are YYYY-MM-DD
         list($startyear, $startmonth, $startday) = split('-', $row['rp_start_date']);
         list($endyear, $endmonth, $endday) = split('-', $row['rp_end_date']);
     } else {
         // Coming from the form
         $this->date_start = $row['date_start1'];
         $this->date_end = $row['date_end1'];
         // Ignore time entries & set to all day if flagged as such
         if (isset($row['allday']) && $row['allday'] == '1') {
             $this->time_start1 = '00:00:00';
             $this->time_end1 = '23:59:59';
             $this->time_start2 = NULL;
             $this->time_end2 = NULL;
         } else {
             $tmp = EVLIST_12to24($row['starthour1'], $row['start1_ampm']);
             $this->time_start1 = sprintf('%02d:%02d:00', $tmp, $row['startminute1']);
             $tmp = EVLIST_12to24($row['endhour1'], $row['end1_ampm']);
             $this->time_end1 = sprintf('%02d:%02d:00', $tmp, $row['endminute1']);
             if (isset($row['split']) && $row['split'] == '1') {
                 $tmp = EVLIST_12to24($row['starthour2'], $row['start2_ampm']);
                 $this->time_start2 = sprintf('%02d:%02d:00', $tmp, $row['startminute1']);
                 $tmp = EVLIST_12to24($row['endhour2'], $row['end2_ampm']);
                 $this->time_end2 = sprintf('%02d:%02d:00', $tmp, $row['endminute2']);
             } else {
                 $this->time_start2 = NULL;
                 $this->time_end2 = NULL;
             }
         }
     }
 }
Exemple #2
0
 /**
  *  Sets all variables to the matching values from $rows.
  *
  *  @param  array   $row        Array of values, from DB or $_POST
  *  @param  boolean $fromDB     True if read from DB, false if from $_POST
  */
 public function SetVars($row, $fromDB = false)
 {
     global $_EV_CONF;
     if (!is_array($row)) {
         return;
     }
     $this->date_start1 = isset($row['date_start1']) && !empty($row['date_start1']) ? $row['date_start1'] : date('Y-m-d');
     $this->date_end1 = isset($row['date_end1']) && !empty($row['date_end1']) ? $row['date_end1'] : $this->date_start1;
     $this->cal_id = $row['cal_id'];
     $this->show_upcoming = isset($row['show_upcoming']) ? 1 : 0;
     $this->recurring = isset($row['recurring']) && $row['recurring'] == 1 ? 1 : 0;
     $this->show_upcoming = isset($row['show_upcoming']) && $row['show_upcoming'] == 1 ? 1 : 0;
     if (isset($row['allday']) && $row['allday'] == 1) {
         $this->allday = 1;
         $this->split = 0;
     } else {
         $this->allday = 0;
         $this->split = isset($row['split']) && $row['split'] == 1 ? 1 : 0;
     }
     // Multi-day events can't be split
     if ($this->date_start1 != $this->date_end1) {
         $this->split = 0;
     }
     $this->status = isset($row['status']) && $row['status'] == 1 ? 1 : 0;
     $this->postmode = isset($row['postmode']) && $row['postmode'] == 'html' ? 'html' : 'plaintext';
     $this->enable_reminders = isset($row['enable_reminders']) && $row['enable_reminders'] == 1 ? 1 : 0;
     $this->owner_id = $row['owner_id'];
     $this->group_id = $row['group_id'];
     //$this->title = $row['title'];
     if (isset($row['categories']) && is_array($row['categories'])) {
         $this->categories = $row['categories'];
     }
     // Join or split the date values as needed
     if ($fromDB) {
         // dates are YYYY-MM-DD
         $this->id = isset($row['id']) ? $row['id'] : '';
         $this->rec_data = unserialize($row['rec_data']);
         if (!$this->rec_data) {
             $this->rec_data = array();
         }
         $this->det_id = $row['det_id'];
         $this->hits = $row['hits'];
         $this->perm_owner = $row['perm_owner'];
         $this->perm_group = $row['perm_group'];
         $this->perm_members = $row['perm_members'];
         $this->perm_anon = $row['perm_anon'];
         $this->time_start1 = $row['time_start1'];
         $this->time_end1 = $row['time_end1'];
         $this->time_start2 = $row['time_start2'];
         $this->time_end2 = $row['time_end2'];
         $this->options = unserialize($row['options']);
         if (!$this->options) {
             $this->options = array();
         }
     } else {
         // Coming from the form
         $this->id = isset($row['eid']) ? $row['eid'] : '';
         // Ignore time entries & set to all day if flagged as such
         if (isset($row['allday']) && $row['allday'] == '1') {
             $this->time_start1 = '00:00:00';
             $this->time_end1 = '23:59:59';
         } else {
             $tmp = EVLIST_12to24($row['starthour1'], $row['start1_ampm']);
             $this->time_start1 = sprintf('%02d:%02d:00', $tmp, $row['startminute1']);
             $tmp = EVLIST_12to24($row['endhour1'], $row['end1_ampm']);
             $this->time_end1 = sprintf('%02d:%02d:00', $tmp, $row['endminute1']);
         }
         // If split, record second time/date values.
         // Splits don't support allday events
         if ($this->split == 1) {
             $tmp = EVLIST_12to24($row['starthour2'], $row['start2_ampm']);
             $this->time_start2 = sprintf('%02d:%02d:00', $tmp, $row['startminute2']);
             $tmp = EVLIST_12to24($row['endhour2'], $row['end2_ampm']);
             $this->time_end2 = sprintf('%02d:%02d:00', $tmp, $row['endminute1']);
         } else {
             $this->time_start2 = NULL;
             $this->time_end2 = NULL;
         }
         if (isset($_POST['perm_owner'])) {
             $perms = SEC_getPermissionValues($row['perm_owner'], $row['perm_group'], $row['perm_members'], $row['perm_anon']);
             $this->perm_owner = $perms[0];
             $this->perm_group = $perms[1];
             $this->perm_members = $perms[2];
             $this->perm_anon = $perms[3];
         }
         $this->owner_id = $row['owner_id'];
         $this->group_id = $row['group_id'];
         $this->options['contactlink'] = isset($row['contactlink']) ? 1 : 0;
         $this->options['tickets'] = array();
         if ($_EV_CONF['enable_rsvp']) {
             $this->options['use_rsvp'] = (int) $row['use_rsvp'];
             $this->options['max_rsvp'] = (int) $row['max_rsvp'];
             $this->options['rsvp_waitlist'] = isset($row['rsvp_waitlist']) ? 1 : 0;
             $this->options['rsvp_cutoff'] = (int) $row['rsvp_cutoff'];
             if ($this->options['max_rsvp'] < 0) {
                 $this->options['max_rsvp'] = 0;
             }
             $this->options['max_user_rsvp'] = (int) $row['max_user_rsvp'];
             if (!isset($row['tickets']) || !is_array($row['tickets'])) {
                 // if no ticket specified but rsvp is ensabled, make sure
                 // the general admission ticket is set for free
                 $row['tickets'] = array(1);
                 $row['tick_fees'] = array(0);
             }
             foreach ($row['tickets'] as $tick_id => $tick_data) {
                 $tick_fee = isset($row['tick_fees'][$tick_id]) ? (double) $row['tick_fees'][$tick_id] : 0;
                 $this->options['tickets'][$tick_id] = array('fee' => $tick_fee);
             }
             $this->options['rsvp_print'] = $row['rsvp_print'];
         } else {
             $this->options['use_rsvp'] = 0;
             $this->options['max_rsvp'] = 0;
             $this->options['rsvp_cutoff'] = 0;
             $this->options['rsvp_waitlist'] = 0;
             $this->options['max_user_rsvp'] = 1;
             $this->options['rsvp_print'] = 0;
         }
     }
 }