/** * Extracts ical properties and updates calendar. * * @see database_driver::edit_calendar() */ public function edit_calendar($prop) { $protected = array(); $preinstalled_calendars = $this->rc->config->get('calendar_preinstalled_calendars', array()); foreach ($preinstalled_calendars as $idx => $properties) { if ($properties['driver'] == 'ical') { $url = str_replace('@', urlencode('@'), str_replace('%u', $this->rc->get_user_name(), $properties['ical_url'])); if (stripos($prop['ical_url'], $url) === 0) { $protected = $properties['protected']; $protected['unsubscribe'] = isset($properties['unsubscribe']) ? $properties['unsubscribe'] : 1; foreach ($protected as $key => $val) { if ($val && $key != 'ical_user' && $key != 'ical_pass' && $key != 'ical_url' && $key != 'name' || $key == 'unsubscribe') { $prop[$key] = $properties[$key]; } } break; } } } $prev_prop = $this->_get_ical_props($prop['id'], self::OBJ_TYPE_ICAL); $props['user'] = $prop['ical_user']; $props['pass'] = $prop['ical_pass'] ? $prop['ical_pass'] : $prev_prop['pass']; $props['url'] = str_ireplace('webcal://', 'http://', self::_encode_url($prop['ical_url'])); $props['url'] = $prop['ical_url'] = $this->_check_connection($props); if (!$this->_check_connection($props)) { return false; } if (parent::edit_calendar($prop) !== false) { // Don't change the password if not specified if (!$prop['ical_pass']) { if ($prev_prop) { $prop['ical_pass'] = $prev_prop['pass']; } } return $this->_set_ical_props($prop['id'], self::OBJ_TYPE_ICAL, array('url' => self::_encode_url($prop['ical_url']), 'user' => $prop['ical_user'], 'pass' => $prop['ical_pass'], 'sync' => $prop['sync'])); } return false; }
/** * Extracts caldav properties and updates calendar. * * @see database_driver::edit_calendar() */ public function edit_calendar($prop) { $protected = array(); $preinstalled_calendars = $this->rc->config->get('calendar_preinstalled_calendars', array()); foreach ($preinstalled_calendars as $idx => $properties) { if ($properties['driver'] == 'caldav') { $url = str_replace('@', urlencode('@'), str_replace('%u', $this->rc->get_user_name(), $properties['caldav_url'])); if (stripos($prop['caldav_url'], $url) === 0) { $protected = $properties['protected']; $protected['unsubscribe'] = isset($properties['unsubscribe']) ? $properties['unsubscribe'] : 1; foreach ($protected as $key => $val) { if ($val && $key != 'caldav_user' && $key != 'caldav_pass' && $key != 'caldav_url' && $key != 'name' || $key == 'unsubscribe') { $prop[$key] = $properties[$key]; } } break; } } } $prev_prop = $this->_get_caldav_props($prop['id'], self::OBJ_TYPE_VCAL); $props['user'] = $prop['caldav_user']; $props['pass'] = $prop['caldav_pass'] ? $prop['caldav_pass'] : $prev_prop['pass']; $props['url'] = $prop['caldav_url']; $props['authtype'] = $prop['authtype']; $pwd_expanded_props = $props; $this->_expand_pass($pwd_expanded_props); if ($redirect = $this->_check_redirection($pwd_expanded_props)) { $pwd_expanded_props['url'] = $props['url'] = $prop['url'] = $redirect; } if ($pwd_expanded_props['pass'] != '***TOKEN***' && !$props['url']) { return false; } if (stripos($props['url'], 'https://apidata.googleusercontent.com/caldav/v2/') === false && !$this->_check_connection($pwd_expanded_props)) { return false; } if (parent::edit_calendar($prop, $prop['events']) !== false) { // Don't change the password if not specified if (!$prop['caldav_pass']) { if ($prev_prop) { $prop['caldav_pass'] = $prev_prop['pass']; } } return $this->_set_caldav_props($prop['id'], self::OBJ_TYPE_VCAL, array('url' => self::_encode_url($prop['caldav_url']), 'user' => $prop['caldav_user'], 'pass' => $prop['caldav_pass'], 'sync' => $prop['sync'], 'authtype' => $prop['authtype'], 'edit_calendar')); } return false; }