Implement free/busy triggering

This commit is contained in:
Thomas B 2012-04-24 09:30:04 +02:00
parent 66915007d4
commit bbf3901308

View file

@ -605,21 +605,28 @@ class kolab_storage_folder
public function trigger() public function trigger()
{ {
$owner = $this->get_owner(); $owner = $this->get_owner();
$result = false;
switch($this->type) { switch($this->type) {
case 'event': case 'event':
$url = sprintf('%s/trigger/%s/%s.pfb', kolab_storage::get_freebusy_server(), $owner, $this->subpath); if ($this->get_namespace() == 'personal') {
$result = $this->trigger_url(
sprintf('%s/trigger/%s/%s.pfb', kolab_storage::get_freebusy_server(), $owner, $this->imap->mod_folder($this->name)),
$this->imap->options['user'],
$this->imap->options['password']
);
}
break; break;
default: default:
return true; return true;
} }
$result = $this->trigger_url($url); if ($result && is_a($result, 'PEAR_Error')) {
if (is_a($result, 'PEAR_Error')) {
return PEAR::raiseError(sprintf("Failed triggering folder %s. Error was: %s", return PEAR::raiseError(sprintf("Failed triggering folder %s. Error was: %s",
$this->name, $result->getMessage())); $this->name, $result->getMessage()));
} }
return $result; return $result;
} }
@ -627,12 +634,24 @@ class kolab_storage_folder
* Triggers a URL. * Triggers a URL.
* *
* @param string $url The URL to be triggered. * @param string $url The URL to be triggered.
* @param string $auth_user Username to authenticate with
* @param string $auth_passwd Password for basic auth
* @return boolean|PEAR_Error True if successfull. * @return boolean|PEAR_Error True if successfull.
*/ */
private function trigger_url($url) private function trigger_url($url, $auth_user = null, $auth_passwd = null)
{ {
// TBD. require_once('HTTP/Request.php');
return PEAR::raiseError("Feature not implemented.");
$request = new HTTP_Request($url);
// set authentication credentials
if ($auth_user && $auth_passwd)
$request->setBasicAuth($auth_user, $auth_passwd);
$result = $request->sendRequest(true);
// rcube::write_log('trigger', $request->getResponseBody());
return $result;
} }
@ -652,6 +671,7 @@ class kolab_storage_folder
*/ */
public function getMyRights() public function getMyRights()
{ {
PEAR::raiseError("Call to deprecated method kolab_storage_folder::getMyRights()");
return $this->get_myrights(); return $this->get_myrights();
} }
@ -660,6 +680,7 @@ class kolab_storage_folder
*/ */
public function getData() public function getData()
{ {
PEAR::raiseError("Call to deprecated method kolab_storage_folder::getData()");
return $this; return $this;
} }
@ -668,6 +689,7 @@ class kolab_storage_folder
*/ */
public function getObjects($type = null) public function getObjects($type = null)
{ {
PEAR::raiseError("Call to deprecated method kolab_storage_folder::getObjects()");
return $this->get_objects($type); return $this->get_objects($type);
} }
@ -676,6 +698,7 @@ class kolab_storage_folder
*/ */
public function getObject($uid) public function getObject($uid)
{ {
PEAR::raiseError("Call to deprecated method kolab_storage_folder::getObject()");
return $this->get_object($uid); return $this->get_object($uid);
} }
@ -693,6 +716,7 @@ class kolab_storage_folder
*/ */
public function deleteMessage($id, $trigger = true, $expunge = true) public function deleteMessage($id, $trigger = true, $expunge = true)
{ {
PEAR::raiseError("Call to deprecated method kolab_storage_folder::deleteMessage()");
return $this->delete(array('_msguid' => $id), $trigger, $expunge); return $this->delete(array('_msguid' => $id), $trigger, $expunge);
} }
@ -701,6 +725,7 @@ class kolab_storage_folder
*/ */
public function deleteAll() public function deleteAll()
{ {
PEAR::raiseError("Call to deprecated method kolab_storage_folder::deleteAll()");
return $this->delete_all(); return $this->delete_all();
} }