2011-12-01 01:02:45 +00:00
|
|
|
<?php
|
|
|
|
/**
|
2012-01-11 02:56:53 +00:00
|
|
|
* Copyright (c) 2011-2012 Thomas Tanghus <thomas@tanghus.net>
|
2011-12-01 01:02:45 +00:00
|
|
|
* This file is licensed under the Affero General Public License version 3 or
|
|
|
|
* later.
|
|
|
|
* See the COPYING-README file.
|
|
|
|
*/
|
|
|
|
|
2012-04-17 17:31:29 +00:00
|
|
|
|
2012-05-01 20:59:38 +00:00
|
|
|
OCP\User::checkLoggedIn();
|
2012-05-02 17:08:37 +00:00
|
|
|
OCP\App::checkAppEnabled('contacts');
|
2012-02-12 15:12:46 +00:00
|
|
|
$bookid = isset($_GET['bookid']) ? $_GET['bookid'] : NULL;
|
|
|
|
$contactid = isset($_GET['contactid']) ? $_GET['contactid'] : NULL;
|
2012-01-14 23:55:02 +00:00
|
|
|
$nl = "\n";
|
2012-02-12 15:12:46 +00:00
|
|
|
if(isset($bookid)){
|
|
|
|
$addressbook = OC_Contacts_App::getAddressbook($bookid);
|
|
|
|
$cardobjects = OC_Contacts_VCard::all($bookid);
|
2011-12-01 15:06:27 +00:00
|
|
|
header('Content-Type: text/directory');
|
2011-12-16 16:42:07 +00:00
|
|
|
header('Content-Disposition: inline; filename=' . str_replace(' ', '_', $addressbook['displayname']) . '.vcf');
|
2012-01-11 02:56:53 +00:00
|
|
|
|
|
|
|
foreach($cardobjects as $card) {
|
2012-01-14 23:47:50 +00:00
|
|
|
echo $card['carddata'] . $nl;
|
2011-12-01 01:02:45 +00:00
|
|
|
}
|
2012-02-12 15:12:46 +00:00
|
|
|
}elseif(isset($contactid)){
|
|
|
|
$data = OC_Contacts_App::getContactObject($contactid);
|
2011-12-01 15:06:27 +00:00
|
|
|
header('Content-Type: text/directory');
|
2012-01-11 05:20:06 +00:00
|
|
|
header('Content-Disposition: inline; filename=' . str_replace(' ', '_', $data['fullname']) . '.vcf');
|
2011-12-01 15:06:27 +00:00
|
|
|
echo $data['carddata'];
|
2011-12-01 01:02:45 +00:00
|
|
|
}
|
|
|
|
?>
|