feat: add preinstalled sources
This commit is contained in:
parent
64599f4cfe
commit
8347d65795
2 changed files with 30 additions and 0 deletions
27
calendar.php
27
calendar.php
|
@ -184,6 +184,33 @@ class calendar extends rcube_plugin
|
|||
// @TODO: do EXPUNGE on kolab objects?
|
||||
}
|
||||
}
|
||||
// loading preinstalled sources
|
||||
$preinstalled_sources = $this->rc->config->get('calendar_preinstalled_sources', FALSE);
|
||||
if ($preinstalled_sources && is_array($preinstalled_sources)) {
|
||||
$username = $this->rc->get_user_name();
|
||||
$password = $this->rc->get_user_password();
|
||||
|
||||
foreach ($preinstalled_sources as $cal){
|
||||
$url = $cal['caldav_url'];
|
||||
$user = $cal['caldav_user'];
|
||||
$pass = $cal['caldav_pass'];
|
||||
|
||||
$url = str_replace('%u', $username, $url);
|
||||
$user = str_replace('%u', $username, $user);
|
||||
$pass = str_replace('%p', $password, $pass);
|
||||
|
||||
$cal['caldav_url'] = $url;
|
||||
$cal['caldav_user'] = $user;
|
||||
$cal['caldav_pass'] = $pass;
|
||||
|
||||
$cal['new-source'] = true;
|
||||
|
||||
if (!$this->driver->create_calendar($cal)) {
|
||||
$error_msg = 'Unable to add default calendars' . ($this->driver && $thi->driver->last_error ? ': ' . $this->driver->last_error :'');
|
||||
$this->rc->output->show_message($error_msg, 'error');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ($args['task'] == 'settings') {
|
||||
// add hooks for Calendar settings
|
||||
|
|
|
@ -302,6 +302,9 @@ class caldav_driver extends calendar_driver
|
|||
{
|
||||
$source['caldav_url'] = self::_encode_url($source['caldav_url']);
|
||||
|
||||
$result = $this->rc->db->query("SELECT user_id, caldav_url, caldav_user FROM " . $this->db_sources . " WHERE user_id=? AND caldav_url=? AND caldav_user=?", $this->rc->user->ID, $source['caldav_url'], $source['caldav_user']);
|
||||
if($this->rc->db->affected_rows($result)) return true;
|
||||
|
||||
try {
|
||||
$calendars = $this->_autodiscover_calendars($source);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue