1
0
mirror of https://github.com/owncloudarchive/contacts.git synced 2025-01-18 07:52:21 +01:00
babelouest 2014-04-09 16:07:13 -04:00
parent 03cf95f37c
commit c20022562d
4 changed files with 24 additions and 27 deletions

View File

@ -12,7 +12,6 @@ OC.Contacts = OC.Contacts || {};
OC.Contacts.OtherBackendConfig = OtherBackendConfig; OC.Contacts.OtherBackendConfig = OtherBackendConfig;
OtherBackendConfig.prototype.openAddressbookUi = function() { OtherBackendConfig.prototype.openAddressbookUi = function() {
var self = this;
this.addressbookUiInit(); this.addressbookUiInit();
}; };
@ -69,8 +68,8 @@ OC.Contacts = OC.Contacts || {};
$('#addressbooks-ui-ldapvcardconnector').append($option); $('#addressbooks-ui-ldapvcardconnector').append($option);
} }
if (custom) { if (custom) {
console.log("custom selected");
var $option = $('<option value="">' + 'Custom connector' + '</option>').attr('selected','selected'); var $option = $('<option value="">' + 'Custom connector' + '</option>').attr('selected','selected');
$('#addressbooks-ui-ldapvcardconnector').append($option);
$('#addressbooks-ui-ldapvcardconnector-value-p').show(); $('#addressbooks-ui-ldapvcardconnector-value-p').show();
$('#addressbooks-ui-ldapvcardconnector-copyfrom-p').show(); $('#addressbooks-ui-ldapvcardconnector-copyfrom-p').show();
$.when(self.storage.getConnectors($('#addressbooks-ui-backend').val())) $.when(self.storage.getConnectors($('#addressbooks-ui-backend').val()))
@ -91,10 +90,9 @@ OC.Contacts = OC.Contacts || {};
$('#addressbooks-ui-ldapvcardconnector-value').text(addressbook.ldap_vcard_connector); $('#addressbooks-ui-ldapvcardconnector-value').text(addressbook.ldap_vcard_connector);
} else { } else {
console.log("custom not selected");
var $option = $('<option value="">' + 'Custom connector' + '</option>'); var $option = $('<option value="">' + 'Custom connector' + '</option>');
$('#addressbooks-ui-ldapvcardconnector').append($option);
} }
$('#addressbooks-ui-ldapvcardconnector').append($option);
}) })
.fail(function(jqxhr, textStatus, error) { .fail(function(jqxhr, textStatus, error) {
var err = textStatus + ', ' + error; var err = textStatus + ', ' + error;
@ -232,12 +230,12 @@ OC.Contacts = OC.Contacts || {};
} }
}); });
$('#addressbooks-ui-ldapbasednsearch').change(function() { $('#addressbooks-ui-ldapbasednsearch').change(function() {
if ($('#addressbooks-ui-ldapbasednmodify').val() == '') { if ($('#addressbooks-ui-ldapbasednmodify').val() === '') {
$('#addressbooks-ui-ldapbasednmodify').val($('#addressbooks-ui-ldapbasednsearch').val()); $('#addressbooks-ui-ldapbasednmodify').val($('#addressbooks-ui-ldapbasednsearch').val());
} }
}); });
$('#addressbooks-ui-ldapbasednmodify').change(function() { $('#addressbooks-ui-ldapbasednmodify').change(function() {
if ($('#addressbooks-ui-ldapbasednsearch').val() == '') { if ($('#addressbooks-ui-ldapbasednsearch').val() === '') {
$('#addressbooks-ui-ldapbasednsearch').val($('#addressbooks-ui-ldapbasednmodify').val()); $('#addressbooks-ui-ldapbasednsearch').val($('#addressbooks-ui-ldapbasednmodify').val());
} }
}); });
@ -246,7 +244,7 @@ OC.Contacts = OC.Contacts || {};
$('#addressbooks-ui-ldapvcardconnector').empty(); $('#addressbooks-ui-ldapvcardconnector').empty();
var $option = null; var $option = null;
for (var id = 0; id < response.data.length; id++) { for (var id = 0; id < response.data.length; id++) {
if (response.data[id] != null) { if (response.data[id] !== null) {
$option = $('<option value="' + response.data[id].id + '">' + response.data[id].name + '</option>'); $option = $('<option value="' + response.data[id].id + '">' + response.data[id].name + '</option>');
$('#addressbooks-ui-ldapvcardconnector').append($option); $('#addressbooks-ui-ldapvcardconnector').append($option);
} }
@ -261,7 +259,7 @@ OC.Contacts = OC.Contacts || {};
}); });
$('#addressbooks-ui-ldapvcardconnector').change(function() { $('#addressbooks-ui-ldapvcardconnector').change(function() {
// Custom connector // Custom connector
if ($('#addressbooks-ui-ldapvcardconnector').val() == '') { if ($('#addressbooks-ui-ldapvcardconnector').val() === '') {
$('#addressbooks-ui-ldapvcardconnector-value-p').show(); $('#addressbooks-ui-ldapvcardconnector-value-p').show();
$('#addressbooks-ui-ldapvcardconnector-copyfrom-p').show(); $('#addressbooks-ui-ldapvcardconnector-copyfrom-p').show();
$.when(self.storage.getConnectors($('#addressbooks-ui-backend').val())) $.when(self.storage.getConnectors($('#addressbooks-ui-backend').val()))
@ -270,7 +268,7 @@ OC.Contacts = OC.Contacts || {};
var $option = $('<option value="">' + 'Select connector' + '</option>').attr('selected','selected'); var $option = $('<option value="">' + 'Select connector' + '</option>').attr('selected','selected');
$('#addressbooks-ui-ldapvcardconnector-copyfrom').append($option); $('#addressbooks-ui-ldapvcardconnector-copyfrom').append($option);
for (var id = 0; id < response.data.length; id++) { for (var id = 0; id < response.data.length; id++) {
var $option = $('<option value="' + response.data[id].id + '">' + response.data[id].name + '</option>'); $option = $('<option value="' + response.data[id].id + '">' + response.data[id].name + '</option>');
$('#addressbooks-ui-ldapvcardconnector-copyfrom').append($option); $('#addressbooks-ui-ldapvcardconnector-copyfrom').append($option);
} }
}) })
@ -285,11 +283,11 @@ OC.Contacts = OC.Contacts || {};
} }
}); });
$('#addressbooks-ui-ldapvcardconnector-copyfrom').change(function() { $('#addressbooks-ui-ldapvcardconnector-copyfrom').change(function() {
if ($('#addressbooks-ui-ldapvcardconnector-copyfrom').val() != '') { if ($('#addressbooks-ui-ldapvcardconnector-copyfrom').val() !== '') {
$.when(self.storage.getConnectors($('#addressbooks-ui-backend').val())) $.when(self.storage.getConnectors($('#addressbooks-ui-backend').val()))
.then(function(response) { .then(function(response) {
for (var id = 0; id < response.data.length; id++) { for (var id = 0; id < response.data.length; id++) {
if ($('#addressbooks-ui-ldapvcardconnector-copyfrom').val() == response.data[id].id) { if ($('#addressbooks-ui-ldapvcardconnector-copyfrom').val() === response.data[id].id) {
console.log(response.data[id].id); console.log(response.data[id].id);
$('#addressbooks-ui-ldapvcardconnector-value').text(response.data[id].xml); $('#addressbooks-ui-ldapvcardconnector-value').text(response.data[id].xml);
} }

View File

@ -45,7 +45,7 @@ class Ldap extends AbstractBackend {
* The cached address books. * The cached address books.
* @var array[] * @var array[]
*/ */
public $addressBooks; public $addressbooks;
/** /**
* @brief validates and sets the ldap parameters * @brief validates and sets the ldap parameters
@ -728,7 +728,6 @@ class Ldap extends AbstractBackend {
public function deleteContact($addressbookid, $id, array $options = array()) { public function deleteContact($addressbookid, $id, array $options = array()) {
self::setLdapParams($addressbookid); self::setLdapParams($addressbookid);
self::ldapCreateAndBindConnection(); self::ldapCreateAndBindConnection();
$card=null;
if (is_array($id)) { if (is_array($id)) {
$card = self::getContact($addressbookid, $id); $card = self::getContact($addressbookid, $id);
} else { } else {

View File

@ -57,20 +57,20 @@ class LdapConnector {
for ($i=0; $i<$ldapEntry["count"]; $i++) { for ($i=0; $i<$ldapEntry["count"]; $i++) {
// ldap property name : $ldap_entry[$i] // ldap property name : $ldap_entry[$i]
$l_property = $ldapEntry[$i]; $lProperty = $ldapEntry[$i];
for ($j=0;$j<$ldapEntry[$l_property]["count"];$j++){ for ($j=0;$j<$ldapEntry[$lProperty]["count"];$j++){
// What to do : // What to do :
// convert the ldap property into vcard property, type and position (if needed) // convert the ldap property into vcard property, type and position (if needed)
// $v_params format: array('property' => property, 'type' => array(types), 'position' => position) // $v_params format: array('property' => property, 'type' => array(types), 'position' => position)
$v_params = $this->getVCardProperty($l_property); $v_params = $this->getVCardProperty($lProperty);
foreach ($v_params as $v_param) { foreach ($v_params as $v_param) {
if (isset($v_param['unassigned'])) { if (isset($v_param['unassigned'])) {
// if the value comes from the unassigned entry, it's a vcard property dumped // if the value comes from the unassigned entry, it's a vcard property dumped
try { try {
$property = \Sabre\VObject\Reader::read($ldapEntry[$l_property][$j]); $property = \Sabre\VObject\Reader::read($ldapEntry[$lProperty][$j]);
$vcard->add($property); $vcard->add($property);
} catch (exception $e) { } catch (exception $e) {
} }
@ -82,9 +82,9 @@ class LdapConnector {
// modify the property with the new data // modify the property with the new data
if (strcasecmp($v_param['image'], 'true') == 0) { if (strcasecmp($v_param['image'], 'true') == 0) {
$this->updateVCardImageProperty($v_property, $ldapEntry[$l_property][$j], $vcard->VERSION); $this->updateVCardImageProperty($v_property, $ldapEntry[$lProperty][$j], $vcard->VERSION);
} else { } else {
$this->updateVCardProperty($v_property, $ldapEntry[$l_property][$j], $v_param['position']); $this->updateVCardProperty($v_property, $ldapEntry[$lProperty][$j], $v_param['position']);
} }
} }
} }
@ -186,16 +186,16 @@ class LdapConnector {
/** /**
* @brief gets the vcard property values from an ldif entry name * @brief gets the vcard property values from an ldif entry name
* @param $l_property the ldif property name * @param $lProperty the ldif property name
* @return array('property' => property, 'type' => type, 'position' => position) * @return array('property' => property, 'type' => type, 'position' => position)
*/ */
public function getVCardProperty($l_property) { public function getVCardProperty($lProperty) {
$properties = array(); $properties = array();
if (strcmp($l_property, $this->getUnassignedVCardProperty()) == 0) { if (strcmp($lProperty, $this->getUnassignedVCardProperty()) == 0) {
$properties[] = array('unassigned' => true); $properties[] = array('unassigned' => true);
} else { } else {
foreach ($this->config_content->ldap_entries->ldif_entry as $ldif_entry) { foreach ($this->config_content->ldap_entries->ldif_entry as $ldif_entry) {
if ($l_property == $ldif_entry['name']) { if ($lProperty == $ldif_entry['name']) {
// $ldif_entry['name'] is the right config xml // $ldif_entry['name'] is the right config xml
foreach ($ldif_entry->vcard_entry as $vcard_entry) { foreach ($ldif_entry->vcard_entry as $vcard_entry) {
$type=isset($vcard_entry['type'])?$vcard_entry['type']:""; $type=isset($vcard_entry['type'])?$vcard_entry['type']:"";
@ -438,9 +438,9 @@ class LdapConnector {
public function insertEmptyEntries($source, &$dest) { public function insertEmptyEntries($source, &$dest) {
for ($i=0; $i<$source["count"]; $i++) { for ($i=0; $i<$source["count"]; $i++) {
$l_property = $source[$i]; $lProperty = $source[$i];
if (!isset($dest[$l_property]) && $l_property != 'modifytimestamp') { if (!isset($dest[$lProperty]) && $lProperty != 'modifytimestamp') {
$dest[$l_property] = array(); $dest[$lProperty] = array();
} }
} }
} }

View File

@ -74,7 +74,7 @@ class Dispatcher extends MainApp {
return new AddressBookController($this->appName, $request, $app); return new AddressBookController($this->appName, $request, $app);
}); });
$this->container->registerService('BackendController', function(IAppContainer $container) use($app) { $this->container->registerService('BackendController', function(IAppContainer $container) use($app) {
return new BackendController($container, $app); return new BackendController($container, $request, $app);
}); });
$this->container->registerService('GroupController', function(IAppContainer $container) use($app) { $this->container->registerService('GroupController', function(IAppContainer $container) use($app) {
$request = $container->query('Request'); $request = $container->query('Request');