Merge pull request #1 from Dimonyga/master

CalDav support
This commit is contained in:
Konstantin Shalygin 2017-09-06 14:59:00 +07:00 committed by GitHub
commit 05f861ec59
6 changed files with 50 additions and 1 deletions

23
caldav.php Normal file
View file

@ -0,0 +1,23 @@
<?php
function makeCaldavSettings($caldav_entries, $caldav_base_url, $ldap_entryuuid) {
foreach ($caldav_entries as $cal) {
$cal_uuid = $cal[uuid];
$cal_color = $cal[color];
$cal_name = $cal[name];
$cal_id = $cal[id];
$ret .= 'pref("calendar.registry.'.$cal_uuid.'.cache.enabled", true);
pref("calendar.registry.'.$cal_uuid.'.color", "'.$cal_color.'");
pref("calendar.registry.'.$cal_uuid.'.imip.identity.key", "id1");
pref("calendar.registry.'.$cal_uuid.'.name", "'.$cal_name.'");
pref("calendar.registry.'.$cal_uuid.'.readOnly", false);
pref("calendar.registry.'.$cal_uuid.'.type", "caldav");
pref("calendar.registry.'.$cal_uuid.'.uri", "'.$caldav_base_url.'/'.$ldap_entryuuid.'/'.$cal_id.'/");
';
if ($cal === end($caldav_entries)) {
$ret = rtrim($ret);
}
}
return $ret;
}
?>

View file

@ -33,6 +33,12 @@ $ldap_nonascii_desc = 'Domain';
$ldap_nonascii_uri = "ldap://$ldap_host/$ldap_base??sub?(objectClass=posixAccount)"; $ldap_nonascii_uri = "ldap://$ldap_host/$ldap_base??sub?(objectClass=posixAccount)";
$quicktext_default_import = '/home/exchange/quicktext.xml'; $quicktext_default_import = '/home/exchange/quicktext.xml';
$messenger_save_dir = '/tmp'; $messenger_save_dir = '/tmp';
//Caldav
$caldav_enable = true;
$caldav_base_url = 'https://calendar.example.com/remote.php/dav/calendars/';
$caldav_entries = array (
array (name => 'Personal', id => 'personal', color => '#3300ff', uuid => uniqid())
);
// Signature // Signature
$siga_marketing = "Marketing bullshit<br>"; $siga_marketing = "Marketing bullshit<br>";
$siga_prefix = "Best regards, "; $siga_prefix = "Best regards, ";

View file

@ -5,4 +5,17 @@ $ldap_givenname = '';
$ldap_sn = ''; $ldap_sn = '';
$ldap_title = ''; $ldap_title = '';
$ldap_mail = ''; $ldap_mail = '';
$ldap_attributes = array(
"gidnumber",
"givenname",
"sn",
"title",
"mail",
"telephonenumber",
"telexnumber",
"pager",
"homephone",
"entryuuid"
);
?> ?>

View file

@ -79,6 +79,7 @@ try {
defaultPref("quicktext.defaultImport", "$quicktext_default_import"); defaultPref("quicktext.defaultImport", "$quicktext_default_import");
defaultPref("quicktext.firstTime", false); defaultPref("quicktext.firstTime", false);
defaultPref("messenger.save.dir", "$messenger_save_dir"); defaultPref("messenger.save.dir", "$messenger_save_dir");
$caldav_settings
lockPref("mail.identity.id1.htmlSigFormat", true); lockPref("mail.identity.id1.htmlSigFormat", true);
lockPref("mail.identity.id1.htmlSigText", "$signature"); lockPref("mail.identity.id1.htmlSigText", "$signature");
} catch(e) { } catch(e) {

View file

@ -7,4 +7,5 @@ $ldap_mail = ($info[0]["mail"][0]);
$ldap_givenname_exploded = explode(" ",$ldap_givenname); $ldap_givenname_exploded = explode(" ",$ldap_givenname);
$ldap_givenname_exploded = $ldap_givenname_exploded[0]; $ldap_givenname_exploded = $ldap_givenname_exploded[0];
$ldap_mail_replaced = preg_replace('+@+','%40', $ldap_mail); $ldap_mail_replaced = preg_replace('+@+','%40', $ldap_mail);
$ldap_entryuuid = $info[0]["entryuuid"][0];
?> ?>

View file

@ -5,6 +5,7 @@
require_once 'ldap.cfg.php'; require_once 'ldap.cfg.php';
require_once 'ldap.defaults.php'; require_once 'ldap.defaults.php';
require_once 'ldap.siga.php'; require_once 'ldap.siga.php';
require_once 'caldav.php';
if(empty($_GET['user'])) { if(empty($_GET['user'])) {
exit('Error: user not present'); exit('Error: user not present');
@ -20,7 +21,7 @@ if(!$ldap_bind) {
exit('Error (' . ldap_errno($link) . '): ' . $ldap_error . "\n"); exit('Error (' . ldap_errno($link) . '): ' . $ldap_error . "\n");
} }
$result_uid = ldap_search($link, $ldap_base, $ldap_filter); $result_uid = ldap_search($link, $ldap_base, $ldap_filter, $ldap_attributes);
$entry_uid = ldap_first_entry($link, $result_uid); $entry_uid = ldap_first_entry($link, $result_uid);
if($entry_uid == false) { if($entry_uid == false) {
@ -82,6 +83,10 @@ else {
} }
} }
if ($caldav_enable == true) {
$caldav_settings = makeCaldavSettings($caldav_entries, $caldav_base_url, $ldap_entryuuid);
}
ldap_unbind($link); ldap_unbind($link);
require_once 'ldap.settings.php'; require_once 'ldap.settings.php';