mirror of
https://github.com/owncloudarchive/contacts.git
synced 2025-01-30 19:52:17 +01:00
implementing ldap addressbook modification (draft)
This commit is contained in:
parent
a8e6ab0d33
commit
3f26148233
@ -34,7 +34,7 @@ $this->create('contacts_address_books_for_user', 'addressbooks/')
|
||||
}
|
||||
);
|
||||
|
||||
$this->create('contacts_address_books_get_ldap_connectors', 'addressbook/connector')
|
||||
$this->create('contacts_address_book_connectors', 'connectors/{backend}')
|
||||
->get()
|
||||
->action(
|
||||
function($params) {
|
||||
@ -42,7 +42,8 @@ $this->create('contacts_address_books_get_ldap_connectors', 'addressbook/connect
|
||||
$dispatcher = new Dispatcher($params);
|
||||
$dispatcher->dispatch('AddressBookController', 'getLdapConnectors');
|
||||
}
|
||||
);
|
||||
)
|
||||
->requirements(array('backend'));
|
||||
|
||||
$this->create('contacts_address_book_add', 'addressbook/{backend}/add')
|
||||
->post()
|
||||
|
@ -825,6 +825,11 @@ tbody tr.contact.active, tbody tr.contact:hover {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
#calendar-ui > p > textarea {
|
||||
width:200px;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
#calendar-ui > p > label {
|
||||
width:200px;
|
||||
display: inline-block;
|
||||
|
163
formats/backend_ldap_inet_org_person_connector.xml
Normal file
163
formats/backend_ldap_inet_org_person_connector.xml
Normal file
@ -0,0 +1,163 @@
|
||||
<?xml version='1.0' standalone='yes'?>
|
||||
<entries name="inetOrgPerson">
|
||||
|
||||
<vcard_entries>
|
||||
|
||||
<vcard_entry property="FN" enabled="true">
|
||||
<!--<ldif_entry name="cn"/>-->
|
||||
<ldif_entry name="displayname" unique="true"/>
|
||||
</vcard_entry>
|
||||
|
||||
<vcard_entry property="EMAIL" enabled="true">
|
||||
<ldif_entry name="mail" unique="true"/>
|
||||
</vcard_entry>
|
||||
|
||||
<vcard_entry property="NOTE" enabled="true">
|
||||
<ldif_entry name="description" unique="true"/>
|
||||
</vcard_entry>
|
||||
|
||||
<vcard_entry property="N" enabled="true">
|
||||
<ldif_entry vcard_position="0" name="sn" unique="true"/>
|
||||
<ldif_entry vcard_position="1" name="givenname"/>
|
||||
</vcard_entry>
|
||||
|
||||
<vcard_entry property="TEL" type="FAX" enabled="true">
|
||||
<ldif_entry name="facsimiletelephonenumber" unique="true"/>
|
||||
</vcard_entry>
|
||||
|
||||
<vcard_entry property="TEL" type="HOME" enabled="true">
|
||||
<ldif_entry name="telephonenumber" unique="true"/>
|
||||
</vcard_entry>
|
||||
|
||||
<vcard_entry property="TEL" type="CELL" enabled="true">
|
||||
<ldif_entry name="mobile" unique="true"/>
|
||||
</vcard_entry>
|
||||
|
||||
<vcard_entry property="PHOTO" image="true" enabled="true">
|
||||
<ldif_entry name="jpegphoto"/>
|
||||
</vcard_entry>
|
||||
|
||||
<vcard_entry property="ADR" type="HOME" enabled="true">
|
||||
<ldif_entry vcard_position="2" name="street"/>
|
||||
<ldif_entry vcard_position="3" name="l"/>
|
||||
<ldif_entry vcard_position="4" name="st"/>
|
||||
<ldif_entry vcard_position="5" name="postalcode"/>
|
||||
<ldif_entry vcard_position="6" name="vcardcountry" unique="true"/>
|
||||
</vcard_entry>
|
||||
|
||||
<vcard_entry property="CATEGORIES" enabled="true">
|
||||
<ldif_entry name="o" unique="true"/>
|
||||
</vcard_entry>
|
||||
|
||||
<!--<vcard_entry property="" type="" enabled="true">
|
||||
<ldap_entry vcard_position="" unique="" name=""/>
|
||||
</vcard_entry>-->
|
||||
|
||||
</vcard_entries>
|
||||
|
||||
<ldap_entries>
|
||||
|
||||
<ldap_core>
|
||||
<object_class name="top" />
|
||||
<object_class name="inetOrgPerson" />
|
||||
<object_class name="VCardUnassigned" />
|
||||
<unassigned_vcard_property ldap_name="unassignedproperty" />
|
||||
<ldap_id name="cn" />
|
||||
<not_null name="sn">
|
||||
<action_switch name="givenname"/>
|
||||
<!--<action_default value="value"/>-->
|
||||
</not_null>
|
||||
</ldap_core>
|
||||
|
||||
<ldif_entry name="mail" enabled="true">
|
||||
<vcard_entry property="EMAIL" type="HOME">
|
||||
</vcard_entry>
|
||||
</ldif_entry>
|
||||
|
||||
<ldif_entry name="description" enabled="true">
|
||||
<vcard_entry property="NOTE">
|
||||
</vcard_entry>
|
||||
</ldif_entry>
|
||||
|
||||
<ldif_entry name="displayname" enabled="true">
|
||||
<vcard_entry property="FN">
|
||||
</vcard_entry>
|
||||
</ldif_entry>
|
||||
|
||||
<ldif_entry name="sn" enabled="true">
|
||||
<vcard_entry property="N" position="0">
|
||||
</vcard_entry>
|
||||
</ldif_entry>
|
||||
|
||||
<ldif_entry name="givenname" enabled="true">
|
||||
<vcard_entry property="N" position="1">
|
||||
</vcard_entry>
|
||||
</ldif_entry>
|
||||
|
||||
<ldif_entry name="facsimiletelephonenumber" enabled="true">
|
||||
<vcard_entry property="TEL" type="FAX">
|
||||
</vcard_entry>
|
||||
</ldif_entry>
|
||||
|
||||
<ldif_entry name="telephonenumber" enabled="true">
|
||||
<vcard_entry property="TEL" type="HOME">
|
||||
</vcard_entry>
|
||||
</ldif_entry>
|
||||
|
||||
<ldif_entry name="mobile" enabled="true">
|
||||
<vcard_entry property="TEL" type="CELL">
|
||||
</vcard_entry>
|
||||
</ldif_entry>
|
||||
|
||||
<ldif_entry name="jpegphoto" enabled="true" image="true">
|
||||
<vcard_entry property="PHOTO">
|
||||
</vcard_entry>
|
||||
</ldif_entry>
|
||||
|
||||
<ldif_entry name="street" enabled="true">
|
||||
<vcard_entry property="ADR" type="HOME" position="2">
|
||||
</vcard_entry>
|
||||
</ldif_entry>
|
||||
|
||||
<ldif_entry name="l" enabled="true">
|
||||
<vcard_entry property="ADR" type="HOME" position="3">
|
||||
</vcard_entry>
|
||||
</ldif_entry>
|
||||
|
||||
<ldif_entry name="st" enabled="true">
|
||||
<vcard_entry property="ADR" type="HOME" position="4">
|
||||
</vcard_entry>
|
||||
</ldif_entry>
|
||||
|
||||
<ldif_entry name="postalcode" enabled="true">
|
||||
<vcard_entry property="ADR" type="HOME" position="5">
|
||||
</vcard_entry>
|
||||
</ldif_entry>
|
||||
|
||||
<ldif_entry name="vcardcountry" enabled="true">
|
||||
<vcard_entry property="ADR" type="HOME" position="6">
|
||||
</vcard_entry>
|
||||
</ldif_entry>
|
||||
|
||||
<ldif_entry name="c" enabled="true">
|
||||
<vcard_entry property="ADR" type="HOME" position="6">
|
||||
</vcard_entry>
|
||||
</ldif_entry>
|
||||
|
||||
<ldif_entry name="o" enabled="true">
|
||||
<vcard_entry property="CATEGORIES">
|
||||
</vcard_entry>
|
||||
</ldif_entry>
|
||||
|
||||
<ldif_entry name="ou" enabled="true">
|
||||
<vcard_entry property="CATEGORIES">
|
||||
</vcard_entry>
|
||||
</ldif_entry>
|
||||
|
||||
<!--<ldif_entry name="" enabled="true">
|
||||
<vcard_entry property="" type="" prefix="" position="">
|
||||
</vcard_entry>
|
||||
</ldif_entry>-->
|
||||
|
||||
</ldap_entries>
|
||||
</entries>
|
3
formats/backend_ldap_mock_connector.xml
Normal file
3
formats/backend_ldap_mock_connector.xml
Normal file
@ -0,0 +1,3 @@
|
||||
<?xml version='1.0' standalone='yes'?>
|
||||
<entries name="Mock Connector">
|
||||
</entries>
|
@ -67,7 +67,30 @@ OC.Contacts = OC.Contacts || {};
|
||||
});
|
||||
});
|
||||
this.$li.find('a.action.edit').on('click keypress', function(event) {
|
||||
if($(this).data('open')) {
|
||||
var addressbook = self.storage.getAddressBook(self.getBackend(), self.getId(), false);
|
||||
// TODO: remove this mock value
|
||||
var addressbook = JSON.parse('{"uri":"hector","displayname":"hector","description":"Hector LDAP","ldapurl":"ldaps:\/\/hector.babelouest.org\/","ldapanonymous":false,"ldapreadonly":false,"ldapuser":"cn=Radio Radio,ou=private,ou=Addressbook,dc=babelouest,dc=org","ldappass":"Z291Z291","ldappagesize":"20","ldapbasednsearch":"cn=Radio Radio,ou=private,ou=Addressbook,dc=babelouest,dc=org","ldapfilter":"(objectclass=VCardUnassigned)","ldapbasednmodify":"cn=Radio Radio,ou=private,ou=Addressbook,dc=babelouest,dc=org","ldap_vcard_connector":"<xml>","id":"local","owner":"nico","permissions":31,"lastmodified":null}');
|
||||
addressbook.backend=self.getBackend();
|
||||
addressbook.addressbookid=self.getId();
|
||||
$("#calendar-ui")
|
||||
.dialog({
|
||||
title:"Edit Addressbook",
|
||||
close: function() { $(this).hide() },
|
||||
modal: false,
|
||||
width: 'auto',
|
||||
height: 'auto',
|
||||
position: ['top', 100],
|
||||
buttons: {
|
||||
Ok: function() {
|
||||
calendarUiEditOk();
|
||||
},
|
||||
Cancel: function() {
|
||||
calendarUiCancel();
|
||||
}
|
||||
},
|
||||
open: editCalendarUI(addressbook)
|
||||
});
|
||||
/*if($(this).data('open')) {
|
||||
return;
|
||||
}
|
||||
var editor = this;
|
||||
@ -100,7 +123,7 @@ OC.Contacts = OC.Contacts || {};
|
||||
$(editor).data('open', false);
|
||||
}
|
||||
});
|
||||
$(this).data('open', true);
|
||||
$(this).data('open', true);*/
|
||||
});
|
||||
return this.$li;
|
||||
};
|
||||
@ -652,30 +675,65 @@ OC.Contacts = OC.Contacts || {};
|
||||
})(window, jQuery, OC);
|
||||
|
||||
function openCalendarUi() {
|
||||
$("#calendar-ui-backend option[value='local']").prop('selected', true);
|
||||
$("#calendar-ui-uri").attr('disabled', false);
|
||||
$("#calendar-ui-name").removeProp("required");
|
||||
$("#calendar-ui-name").val("");
|
||||
$("#calendar-ui-name").prop("required", "");
|
||||
$("#calendar-ui-uri").removeProp("required");
|
||||
$("#calendar-ui-uri").val("");
|
||||
$("#calendar-ui-uri").prop("required", "");
|
||||
$("#calendar-ui-description").removeProp("required");
|
||||
$("#calendar-ui-description").val("");
|
||||
$("#calendar-ui-description").prop("required", "");
|
||||
$("#calendar-ui-ldapurl").removeProp("required");
|
||||
$("#calendar-ui-ldapurl").val("");
|
||||
$("#calendar-ui-ldapurl").prop("required", "");
|
||||
$("#calendar-ui-ldapanonymous").attr('checked', false);
|
||||
$("#calendar-ui-ldapreadonly").attr('checked', false);
|
||||
$("#calendar-ui-ldapuser").removeProp("required");
|
||||
$("#calendar-ui-ldapuser").val("");
|
||||
$("#calendar-ui-ldapuser").prop("required", "");
|
||||
$("#calendar-ui-ldappass").removeProp("required");
|
||||
$("#calendar-ui-ldappass").val(atob(""));
|
||||
$("#calendar-ui-ldappass").prop("required", "");
|
||||
$("#calendar-ui-ldapbasednsearch").removeProp("required");
|
||||
$("#calendar-ui-ldapbasednsearch").val("");
|
||||
$("#calendar-ui-ldapbasednsearch").prop("required", "");
|
||||
$("#calendar-ui-ldapfilter").removeProp("required");
|
||||
$("#calendar-ui-ldapfilter").val("");
|
||||
$("#calendar-ui-ldapfilter").prop("required", "");
|
||||
$("#calendar-ui-ldapbasednmodify").removeProp("required");
|
||||
$("#calendar-ui-ldapbasednmodify").val("");
|
||||
$("#calendar-ui-ldapbasednmodify").prop("required", "");
|
||||
calendarUiInit();
|
||||
|
||||
$("#calendar-ui-backend").change(function() {
|
||||
storage = new OC.Contacts.Storage();
|
||||
calendarUiInit();
|
||||
var connectors = storage.getConnectors();
|
||||
alert(JSON.stringify(connectors));
|
||||
});
|
||||
$("#calendar-ui-ldapanonymous").change(function() {
|
||||
if ($("#calendar-ui-ldapanonymous").prop('checked')) {
|
||||
$("#calendar-ui-ldapuser").attr('disabled', true);
|
||||
$("#calendar-ui-ldappass").attr('disabled', true);
|
||||
} else {
|
||||
$("#calendar-ui-ldapuser").removeAttr('disabled');
|
||||
$("#calendar-ui-ldappass").removeAttr('disabled');
|
||||
}
|
||||
});
|
||||
$("#calendar-ui-ldapbasednsearch").change(function() {
|
||||
if ($("#calendar-ui-ldapbasednmodify").val() == '') {
|
||||
$("#calendar-ui-ldapbasednmodify").val($("#calendar-ui-ldapbasednsearch").val());
|
||||
}
|
||||
});
|
||||
$("#calendar-ui-ldapbasednmodify").change(function() {
|
||||
if ($("#calendar-ui-ldapbasednsearch").val() == '') {
|
||||
$("#calendar-ui-ldapbasednsearch").val($("#calendar-ui-ldapbasednmodify").val());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function editCalendarUI(addressbook) {
|
||||
$("#calendar-ui-addressbookid").val(addressbook.addressbookid);
|
||||
$("#calendar-ui-backend option[value="+addressbook.backend+"]").prop('selected', true);
|
||||
$("#calendar-ui-name").val(addressbook.displayname);
|
||||
$("#calendar-ui-uri").val(addressbook.uri);
|
||||
$("#calendar-ui-description").val(addressbook.description);
|
||||
$("#calendar-ui-ldapurl").val(addressbook.ldapurl);
|
||||
$("#calendar-ui-ldapanonymous").attr('checked', (addressbook.ldapanonymous==true));
|
||||
$("#calendar-ui-ldapreadonly").attr('checked', (addressbook.ldapreadonly==true));
|
||||
$("#calendar-ui-ldapuser").val(addressbook.ldapuser);
|
||||
$("#calendar-ui-ldappass").val(atob(addressbook.ldappass));
|
||||
$("#calendar-ui-ldappagesize").val(addressbook.ldappagesize);
|
||||
$("#calendar-ui-ldapbasednsearch").val(addressbook.ldapbasednsearch);
|
||||
$("#calendar-ui-ldapfilter").val(addressbook.ldapfilter);
|
||||
$("#calendar-ui-ldapbasednmodify").val(addressbook.ldapbasednmodify);
|
||||
$("#calendar-ui-uri").attr('disabled', true);
|
||||
//$("#calendar-ui-ldapvcardconnector").hide();
|
||||
calendarUiInit();
|
||||
}
|
||||
|
||||
function calendarUiOk() {
|
||||
@ -727,6 +785,56 @@ function calendarUiOk() {
|
||||
});
|
||||
}
|
||||
|
||||
function calendarUiEditOk() {
|
||||
storage = new OC.Contacts.Storage();
|
||||
var defer = $.Deferred();
|
||||
|
||||
$.when(storage.updateAddressBook($("#calendar-ui-backend").val(), $("#calendar-ui-addressbookid").val(),
|
||||
{
|
||||
//addressBookId: $("#calendar-ui-addressbookid").val(),
|
||||
displayname: $("#calendar-ui-name").val(),
|
||||
description: $("#calendar-ui-description").val(),
|
||||
uri: $("#calendar-ui-uri").val(),
|
||||
ldapurl: $("#calendar-ui-ldapurl").val(),
|
||||
ldapanonymous: $("#calendar-ui-ldapanonymous").prop('checked')==true?"true":"false",
|
||||
ldapreadonly: $("#calendar-ui-ldapreadonly").prop('checked')==true?"true":"false",
|
||||
ldapuser: $("#calendar-ui-ldapuser").val(),
|
||||
ldappass: $("#calendar-ui-ldappass").val(),
|
||||
ldappagesize: $("#calendar-ui-ldappagesize").val(),
|
||||
ldapbasednsearch: $("#calendar-ui-ldapbasednsearch").val(),
|
||||
ldapfilter: $("#calendar-ui-ldapfilter").val(),
|
||||
ldapbasednmodify: $("#calendar-ui-ldapbasednmodify").val(),
|
||||
ldapvcardconnector: $("#calendar-ui-ldapvcardconnector").val(),
|
||||
}
|
||||
)).then(function(response) {
|
||||
if(response.error) {
|
||||
error = response.message;
|
||||
if(typeof cb === 'function') {
|
||||
cb({error:true, message:error});
|
||||
}
|
||||
defer.reject(response);
|
||||
} else {
|
||||
/*var book = addressbook.insertAddressBook(response.data);
|
||||
$(document).trigger('status.addressbook.added');
|
||||
if(typeof cb === 'function') {
|
||||
cb({error:false, addressbook: book});
|
||||
}
|
||||
defer.resolve({error:false, addressbook: book});*/
|
||||
$("#calendar-ui").dialog('close');
|
||||
}
|
||||
})
|
||||
.fail(function(jqxhr, textStatus, error) {
|
||||
$(this).removeClass('loading');
|
||||
var err = textStatus + ', ' + error;
|
||||
console.log('Request Failed', + err);
|
||||
error = t('contacts', 'Failed adding address book: {error}', {error:err});
|
||||
if(typeof cb === 'function') {
|
||||
cb({error:true, message:error});
|
||||
}
|
||||
defer.reject({error:true, message:error});
|
||||
});
|
||||
}
|
||||
|
||||
function calendarUiCancel() {
|
||||
$("#calendar-ui").dialog('close');
|
||||
}
|
||||
@ -745,6 +853,7 @@ function calendarUiInit() {
|
||||
$("#calendar-ui-ldapfilter-p").hide();
|
||||
$("#calendar-ui-ldapbasednmodify-p").hide();
|
||||
$("#calendar-ui-ldapvcardconnector-p").hide();
|
||||
$("#calendar-ui-ldapvcardconnector-value-p").hide();
|
||||
} else if ($("#calendar-ui-backend").val() == "ldap") {
|
||||
$("#calendar-ui-uri-p").show();
|
||||
$("#calendar-ui-description-p").show();
|
||||
@ -758,5 +867,30 @@ function calendarUiInit() {
|
||||
$("#calendar-ui-ldapfilter-p").show();
|
||||
$("#calendar-ui-ldapbasednmodify-p").show();
|
||||
$("#calendar-ui-ldapvcardconnector-p").show();
|
||||
$("#calendar-ui-ldapvcardconnector-value-p").hide();
|
||||
}
|
||||
$("#calendar-ui-ldapanonymous").change(function() {
|
||||
if ($("#calendar-ui-ldapanonymous").prop('checked')) {
|
||||
$("#calendar-ui-ldapuser").attr('disabled', true);
|
||||
$("#calendar-ui-ldappass").attr('disabled', true);
|
||||
} else {
|
||||
$("#calendar-ui-ldapuser").removeAttr('disabled');
|
||||
$("#calendar-ui-ldappass").removeAttr('disabled');
|
||||
}
|
||||
});
|
||||
$("#calendar-ui-ldapbasednsearch").change(function() {
|
||||
if ($("#calendar-ui-ldapbasednmodify").val() == '') {
|
||||
$("#calendar-ui-ldapbasednmodify").val($("#calendar-ui-ldapbasednsearch").val());
|
||||
}
|
||||
});
|
||||
$("#calendar-ui-ldapbasednmodify").change(function() {
|
||||
if ($("#calendar-ui-ldapbasednsearch").val() == '') {
|
||||
$("#calendar-ui-ldapbasednsearch").val($("#calendar-ui-ldapbasednmodify").val());
|
||||
}
|
||||
});
|
||||
$("#calendar-ui-ldapvcardconnector").change(function() {
|
||||
if ($("#calendar-ui-ldapvcardconnector").val() == 'custom') {
|
||||
$("#calendar-ui-ldapvcardconnector-value-p").show();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -176,6 +176,33 @@ OC.Contacts = OC.Contacts || {};
|
||||
JSON.stringify({state: state})
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Update an address book in a specific backend
|
||||
*
|
||||
* @param string backend
|
||||
* @param string addressBookId Address book ID
|
||||
* @param object params An object {displayname:"My contacts", description:""}
|
||||
* @return An array containing contact data e.g.:
|
||||
* {
|
||||
* metadata:
|
||||
* {
|
||||
* id:'1234'
|
||||
* permissions:31,
|
||||
* displayname:'My contacts',
|
||||
* lastmodified: (unix timestamp),
|
||||
* owner: 'joye',
|
||||
* }
|
||||
*/
|
||||
Storage.prototype.getConnectors = function(backend) {
|
||||
console.log('Storage.getConnectors', backend);
|
||||
return this.requestRoute(
|
||||
'connectors/{backend}',
|
||||
'GET',
|
||||
{backend: backend},
|
||||
JSON.stringify(properties)
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Get contacts from an address book from a specific backend
|
||||
|
@ -407,6 +407,7 @@ class Addressbook extends AbstractPIMCollection {
|
||||
* @return bool
|
||||
*/
|
||||
public function update(array $data) {
|
||||
error_log(__METHOD__." enter");
|
||||
if (!$this->hasPermission(\OCP\PERMISSION_UPDATE)) {
|
||||
throw new \Exception(
|
||||
self::$l10n->t('Access denied'),
|
||||
@ -421,6 +422,7 @@ class Addressbook extends AbstractPIMCollection {
|
||||
);
|
||||
}
|
||||
|
||||
error_log(__METHOD__." count ".count($data));
|
||||
if (count($data) === 0) {
|
||||
return false;
|
||||
}
|
||||
@ -436,6 +438,7 @@ class Addressbook extends AbstractPIMCollection {
|
||||
}
|
||||
}
|
||||
|
||||
error_log(__METHOD__);
|
||||
return $this->backend->updateAddressBook($this->getId(), $data);
|
||||
}
|
||||
|
||||
|
@ -272,6 +272,16 @@ class Ldap extends AbstractBackend {
|
||||
* @return array $properties
|
||||
*/
|
||||
public function getAddressBook($addressbookid, array $options = array()) {
|
||||
$backtrace = debug_backtrace();
|
||||
$trace=array();
|
||||
foreach ($backtrace as $elt) {
|
||||
foreach ($elt as $key => $line) {
|
||||
if ($key == "file" || $key == "line") {
|
||||
$trace[] = $line;
|
||||
}
|
||||
}
|
||||
}
|
||||
//error_log(__METHOD__." ".print_r($trace,1));
|
||||
//\OC_Log::write('contacts', __METHOD__.' id: '
|
||||
// . $addressbookid, \OC_Log::DEBUG);
|
||||
if($this->addressbooks && isset($this->addressbooks[$addressbookid])) {
|
||||
@ -281,7 +291,12 @@ class Ldap extends AbstractBackend {
|
||||
// Hmm, not found. Lets query the db.
|
||||
$preferences = (array)self::getPreferences($addressbookid);
|
||||
if ($preferences != false) {
|
||||
$current = array();
|
||||
$preferences['id'] = (string)$addressbookid;
|
||||
$preferences['owner'] = $this->userid;
|
||||
$preferences['permissions'] = \OCP\PERMISSION_ALL;
|
||||
$preferences['lastmodified'] = self::lastModifiedAddressBook($addressbookid);
|
||||
return $preferences;
|
||||
/*$current = array();
|
||||
$current['id'] = (string)$addressbookid;
|
||||
$current['displayname'] = (string)$preferences['displayname'];
|
||||
$current['description'] = (string)$preferences['description'];
|
||||
@ -289,7 +304,8 @@ class Ldap extends AbstractBackend {
|
||||
$current['uri'] = (string)$preferences['uri'];
|
||||
$current['permissions'] = \OCP\PERMISSION_ALL;
|
||||
$current['lastmodified'] = self::lastModifiedAddressBook($addressbookid);
|
||||
return $current;
|
||||
error_log(print_r($current, 1));
|
||||
return $current;*/
|
||||
} else {
|
||||
return array();
|
||||
}
|
||||
@ -316,12 +332,18 @@ class Ldap extends AbstractBackend {
|
||||
*
|
||||
* @param string $addressbookid
|
||||
* @param array $properties
|
||||
* @return bool
|
||||
* @return string|false The ID if the modified AddressBook or false on error.
|
||||
*/
|
||||
public function updateAddressBook($addressbookid, array $properties, array $options = array()) {
|
||||
// TODO: use backend settings
|
||||
|
||||
return true;
|
||||
error_log("where am i ?");
|
||||
if ($this->hasAddressBook($addressbookid)) {
|
||||
error_log("was here ?");
|
||||
// Addressbook exists, modify it through the create function
|
||||
return $this->createAddressBook($properties);
|
||||
} else {
|
||||
error_log("nope, was here");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -405,7 +427,7 @@ class Ldap extends AbstractBackend {
|
||||
* @returns int | null
|
||||
*/
|
||||
public function lastModifiedAddressBook($addressbookid, array $options = array()) {
|
||||
return null;
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -435,6 +457,18 @@ class Ldap extends AbstractBackend {
|
||||
* @return array
|
||||
*/
|
||||
public function getContacts($addressbookid, array $options = array()) {
|
||||
//error_log("was here ".__METHOD__);
|
||||
$backtrace = debug_backtrace();
|
||||
$trace=array();
|
||||
foreach ($backtrace as $elt) {
|
||||
foreach ($elt as $key => $line) {
|
||||
if ($key == "file" || $key == "line") {
|
||||
$trace[] = $line;
|
||||
}
|
||||
}
|
||||
}
|
||||
//error_log(__METHOD__." ".print_r($trace,1));
|
||||
|
||||
$cards = array();
|
||||
$vcards = array();
|
||||
if(is_array($addressbookid) && count($addressbookid)) {
|
||||
|
@ -189,7 +189,6 @@ class Backend extends \Sabre_CardDAV_Backend_Abstract {
|
||||
'etag' => '"' . md5($contact['carddata']) . '"',
|
||||
'uri' => urlencode($contact['uri']),
|
||||
'lastmodified' => $contact['lastmodified'] );
|
||||
error_log("backend.getCards(".urlencode($contact['uri'])."): ".md5($contact['carddata'])." - ".$contact['carddata']);
|
||||
}
|
||||
|
||||
return $cards;
|
||||
@ -213,7 +212,6 @@ class Backend extends \Sabre_CardDAV_Backend_Abstract {
|
||||
}
|
||||
if(is_array($contact) ) {
|
||||
$contact['etag'] = '"' . md5($contact['carddata']) . '"';
|
||||
error_log("backend.getCard($carduri): ".$contact['etag']." - ".$contact['carddata']);
|
||||
return $contact;
|
||||
}
|
||||
//throw new \Sabre_DAV_Exception('Error retrieving the card');
|
||||
|
@ -151,8 +151,10 @@ class AddressBookController extends Controller {
|
||||
|
||||
$response = new JSONResponse();
|
||||
|
||||
error_log(__METHOD__.print_r($this->request, true));
|
||||
$addressBook = $this->app->getAddressBook($params['backend'], $params['addressBookId']);
|
||||
$addressBook->update($this->request['properties']);
|
||||
//$addressBook->update($this->request['properties']);
|
||||
$addressBook->update($this->request->post);
|
||||
|
||||
return $response->setParams($addressBook->getMetaData());
|
||||
}
|
||||
@ -338,10 +340,11 @@ class AddressBookController extends Controller {
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
*/
|
||||
public function getLdapConnectors() {
|
||||
$params = $this->request->urlParams;
|
||||
$targetInfo = $this->request->post['target'];
|
||||
//$targetInfo = $this->request->post['target'];
|
||||
|
||||
$response = new JSONResponse();
|
||||
$prefix = "backend_ldap_";
|
||||
|
@ -509,6 +509,7 @@ use OCA\Contacts\ImportManager;
|
||||
</script>
|
||||
|
||||
<div id="calendar-ui" title="Add new addressbook" class="calendar-ui-class">
|
||||
<input type="hidden" id="calendar-ui-addressbookid" />
|
||||
<p id="calendar-ui-backend-p">
|
||||
<label for="calendar-ui-backend">
|
||||
<?php p($l->t('Addressbook type')); ?>:
|
||||
@ -606,13 +607,20 @@ use OCA\Contacts\ImportManager;
|
||||
</label>
|
||||
<select id="calendar-ui-ldapvcardconnector">
|
||||
<?php
|
||||
$ldapConnectors = getLdapConnectors();
|
||||
/*$ldapConnectors = getLdapConnectors();
|
||||
foreach ($ldapConnectors as $value => $label) {
|
||||
echo "<option value=\"$value\">$label</option>";
|
||||
}
|
||||
}*/
|
||||
?>
|
||||
<option value="custom">Custom connector</option>
|
||||
</select>
|
||||
</p>
|
||||
<p id="calendar-ui-ldapvcardconnector-value-p">
|
||||
<label for="calendar-ui-ldapvcardconnector-value">
|
||||
<?php p($l->t('Connector value')); ?>:
|
||||
</label>
|
||||
<textarea id="calendar-ui-ldapvcardconnector-value"></textarea>
|
||||
</p>
|
||||
</div>
|
||||
<?php
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user