2011-12-01 05:02:45 +04:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Copyright (c) 2011 Georg Ehrke <ownclouddev at georgswebsite dot de>
|
|
|
|
* This file is licensed under the Affero General Public License version 3 or
|
|
|
|
* later.
|
|
|
|
* See the COPYING-README file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
require_once ("../../lib/base.php");
|
|
|
|
OC_Util::checkLoggedIn();
|
|
|
|
OC_Util::checkAppEnabled('contacts');
|
2011-12-01 19:06:27 +04:00
|
|
|
$book = isset($_GET['bookid']) ? $_GET['bookid'] : NULL;
|
|
|
|
$contact = isset($_GET['contactid']) ? $_GET['contactid'] : NULL;
|
2011-12-01 05:02:45 +04:00
|
|
|
if(isset($book)){
|
2011-12-16 20:42:07 +04:00
|
|
|
$addressbook = OC_Contacts_App::getAddressbook($book);
|
2011-12-01 19:06:27 +04:00
|
|
|
if($addressbook['userid'] != OC_User::getUser()){
|
2011-12-01 05:02:45 +04:00
|
|
|
OC_JSON::error();
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
$cardobjects = OC_Contacts_VCard::all($book);
|
2011-12-01 19:06:27 +04:00
|
|
|
header('Content-Type: text/directory');
|
2011-12-16 20:42:07 +04:00
|
|
|
header('Content-Disposition: inline; filename=' . str_replace(' ', '_', $addressbook['displayname']) . '.vcf');
|
2011-12-01 05:02:45 +04:00
|
|
|
for($i = 0;$i <= count($cardobjects); $i++){
|
2011-12-16 20:42:07 +04:00
|
|
|
echo $cardobjects[$i]['carddata'];
|
|
|
|
//echo '\r\n';
|
2011-12-01 05:02:45 +04:00
|
|
|
}
|
|
|
|
}elseif(isset($contact)){
|
2011-12-16 20:42:07 +04:00
|
|
|
$data = OC_Contacts_App::getContactObject($contact);
|
2011-12-01 19:06:27 +04:00
|
|
|
$addressbookid = $data['addressbookid'];
|
2011-12-16 20:42:07 +04:00
|
|
|
$addressbook = OC_Contacts_App::getAddressbook($addressbookid);
|
2011-12-01 19:06:27 +04:00
|
|
|
if($addressbook['userid'] != OC_User::getUser()){
|
2011-12-01 05:02:45 +04:00
|
|
|
OC_JSON::error();
|
|
|
|
exit;
|
|
|
|
}
|
2011-12-01 19:06:27 +04:00
|
|
|
header('Content-Type: text/directory');
|
|
|
|
header('Content-Disposition: inline; filename=' . $data['fullname'] . '.vcf');
|
|
|
|
echo $data['carddata'];
|
2011-12-01 05:02:45 +04:00
|
|
|
}
|
|
|
|
?>
|