add a shortcut - avoid costly (1sec) discover process if address book uri is known
This commit is contained in:
parent
65bcf54862
commit
94bf6c6fad
1 changed files with 9 additions and 0 deletions
|
@ -62,6 +62,13 @@ class abook_carddav extends addressbook_backend {
|
||||||
function open() {
|
function open() {
|
||||||
// backend open function
|
// backend open function
|
||||||
$this->account = new Account(DISCOVERY_URI, USERNAME, PASSWORD);
|
$this->account = new Account(DISCOVERY_URI, USERNAME, PASSWORD);
|
||||||
|
// Use stored addressbook uri if it exists
|
||||||
|
if(defined('abook_uri')){
|
||||||
|
$this->abook = new AddressbookCollection(abook_uri, $this->account);
|
||||||
|
// TODO: check that it's valid
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// Discover the addressbooks for that account
|
// Discover the addressbooks for that account
|
||||||
try {
|
try {
|
||||||
$discover = new Discovery();
|
$discover = new Discovery();
|
||||||
|
@ -73,6 +80,8 @@ class abook_carddav extends addressbook_backend {
|
||||||
return $this->set_error("Cannot proceed because no addressbooks were found - exiting");
|
return $this->set_error("Cannot proceed because no addressbooks were found - exiting");
|
||||||
}
|
}
|
||||||
$this->abook = $abooks[0];
|
$this->abook = $abooks[0];
|
||||||
|
// HINT: use this line to get your discovered addressbook URI
|
||||||
|
// echo "discovered: " . $this->abook->getUri();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue