Conflicts: apps/calendar/export.php apps/contacts/index.phpremotes/origin/stable
commit
3e2e5196d2
@ -0,0 +1,22 @@ |
||||
As I like to run regular, automated backups of my PIM data I looked into an |
||||
easy way of getting the direct link to an address book, and noticed the |
||||
elegant way it was possible in the calendar, where you can click on the |
||||
'Calendars' button and download it directly. |
||||
I modified the export.php script for the contacts app and can now run backups |
||||
with wget and http authentication. Hence the name 'tanghus_remote_backup' for |
||||
this branch. |
||||
Then I implemented the nice popup window function to get an UI for it and one |
||||
thing lead to another: |
||||
|
||||
As for the Calendar app there's a js popup for address book activation, CardDAV link, export, |
||||
edit, delete and add address books. |
||||
|
||||
When making changes to the address books the contact list is updated to show the |
||||
contacts in the active address book(s). |
||||
|
||||
When an address book is activated the setting is saved using OC_Preferences::setValue(). |
||||
|
||||
Most of the code is copy/paste from the Calendar and Contacts apps ;-) |
||||
|
||||
Tested with fresh clone from git@gitorious.org:~tanghus/owncloud/tanghus-owncloud.git, removed |
||||
database and config.php. |
||||
@ -0,0 +1,22 @@ |
||||
<?php |
||||
/** |
||||
* Copyright (c) 2011 Thomas Tanghus <thomas@tanghus.net> |
||||
* Copyright (c) 2011 Bart Visscher <bartv@thisnet.nl> |
||||
* 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_JSON::checkLoggedIn(); |
||||
OC_JSON::checkAppEnabled('contacts'); |
||||
$bookid = $_POST['bookid']; |
||||
OC_Contacts_Addressbook::setActive($bookid, $_POST['active']); |
||||
$book = OC_Contacts_App::getAddressbook($bookid); |
||||
|
||||
/* is there an OC_JSON::error() ? */ |
||||
OC_JSON::success(array( |
||||
'active' => OC_Contacts_Addressbook::isActive($bookid), |
||||
'bookid' => $bookid, |
||||
'book' => $book, |
||||
)); |
||||
@ -0,0 +1,21 @@ |
||||
<?php |
||||
/** |
||||
* Copyright (c) 2011 Bart Visscher <bartv@thisnet.nl> |
||||
* This file is licensed under the Affero General Public License version 3 or |
||||
* later. |
||||
* See the COPYING-README file. |
||||
*/ |
||||
|
||||
require_once('../../../lib/base.php'); |
||||
$l10n = new OC_L10N('contacts'); |
||||
OC_JSON::checkLoggedIn(); |
||||
OC_JSON::checkAppEnabled('contacts'); |
||||
$book = array( |
||||
'id' => 'new', |
||||
'displayname' => '', |
||||
); |
||||
$tmpl = new OC_Template('contacts', 'part.editaddressbook'); |
||||
$tmpl->assign('new', true); |
||||
$tmpl->assign('addressbook', $book); |
||||
$tmpl->printPage(); |
||||
?> |
||||
@ -0,0 +1,16 @@ |
||||
<?php |
||||
/** |
||||
* Copyright (c) 2011 Thomas Tanghus <thomas@tanghus.net> |
||||
* This file is licensed under the Affero General Public License version 3 or |
||||
* later. |
||||
* See the COPYING-README file. |
||||
*/ |
||||
|
||||
require_once('../../../lib/base.php'); |
||||
$l10n = new OC_L10N('contacts'); |
||||
OC_JSON::checkLoggedIn(); |
||||
OC_JSON::checkAppEnabled('contacts'); |
||||
|
||||
$output = new OC_TEMPLATE("contacts", "part.chooseaddressbook"); |
||||
$output -> printpage(); |
||||
?> |
||||
@ -0,0 +1,34 @@ |
||||
<?php |
||||
/** |
||||
* Copyright (c) 2011 Thomas Tanghus <thomas@tanghus.net> |
||||
* This file is licensed under the Affero General Public License version 3 or |
||||
* later. |
||||
* See the COPYING-README file. |
||||
*/ |
||||
|
||||
function contacts_namesort($a,$b){ |
||||
return strcasecmp($a['fullname'],$b['fullname']); |
||||
} |
||||
|
||||
require_once('../../../lib/base.php'); |
||||
OC_JSON::checkLoggedIn(); |
||||
OC_JSON::checkAppEnabled('contacts'); |
||||
|
||||
$addressbooks = OC_Contacts_Addressbook::active(OC_User::getUser()); |
||||
$contacts = array(); |
||||
foreach( $addressbooks as $addressbook ){ |
||||
$addressbookcontacts = OC_Contacts_VCard::all($addressbook['id']); |
||||
foreach( $addressbookcontacts as $contact ){ |
||||
if(is_null($contact['fullname'])){ |
||||
continue; |
||||
} |
||||
$contacts[] = $contact; |
||||
} |
||||
} |
||||
usort($contacts,'contacts_namesort'); |
||||
$tmpl = new OC_TEMPLATE("contacts", "part.contacts"); |
||||
$tmpl->assign('contacts', $contacts); |
||||
$page = $tmpl->fetchPage(); |
||||
|
||||
OC_JSON::success(array('data' => array( 'page' => $page ))); |
||||
?> |
||||
@ -0,0 +1,26 @@ |
||||
<?php |
||||
/** |
||||
* Copyright (c) 2011 Thomas Tanghus <thomas@tanghus.net> |
||||
* Copyright (c) 2011 Bart Visscher <bartv@thisnet.nl> |
||||
* This file is licensed under the Affero General Public License version 3 or |
||||
* later. |
||||
* See the COPYING-README file. |
||||
*/ |
||||
require_once('../../../lib/base.php'); |
||||
|
||||
$l10n = new OC_L10N('contacts'); |
||||
|
||||
// Check if we are a user |
||||
OC_JSON::checkLoggedIn(); |
||||
OC_JSON::checkAppEnabled('contacts'); |
||||
|
||||
$userid = OC_User::getUser(); |
||||
$bookid = OC_Contacts_Addressbook::add($userid, $_POST['name'], null); |
||||
OC_Contacts_Addressbook::setActive($bookid, 1); |
||||
$addressbook = OC_Contacts_App::getAddressbook($bookid); |
||||
$tmpl = new OC_Template('contacts', 'part.chooseaddressbook.rowfields'); |
||||
$tmpl->assign('addressbook', $addressbook); |
||||
OC_JSON::success(array( |
||||
'page' => $tmpl->fetchPage(), |
||||
'addressbook' => $addressbook, |
||||
)); |
||||
@ -0,0 +1,18 @@ |
||||
<?php |
||||
/** |
||||
* Copyright (c) 2011 Bart Visscher <bartv@thisnet.nl> |
||||
* This file is licensed under the Affero General Public License version 3 or |
||||
* later. |
||||
* See the COPYING-README file. |
||||
*/ |
||||
|
||||
require_once('../../../lib/base.php'); |
||||
$l10n = new OC_L10N('contacts'); |
||||
OC_JSON::checkLoggedIn(); |
||||
OC_JSON::checkAppEnabled('contacts'); |
||||
$addressbook = OC_Contacts_App::getAddressbook($_GET['bookid']); |
||||
$tmpl = new OC_Template("contacts", "part.editaddressbook"); |
||||
$tmpl->assign('new', false); |
||||
$tmpl->assign('addressbook', $addressbook); |
||||
$tmpl->printPage(); |
||||
?> |
||||
@ -0,0 +1,26 @@ |
||||
<?php |
||||
/** |
||||
* Copyright (c) 2011 Bart Visscher <bartv@thisnet.nl> |
||||
* This file is licensed under the Affero General Public License version 3 or |
||||
* later. |
||||
* See the COPYING-README file. |
||||
*/ |
||||
|
||||
require_once('../../../lib/base.php'); |
||||
|
||||
$l10n = new OC_L10N('contacts'); |
||||
|
||||
// Check if we are a user |
||||
OC_JSON::checkLoggedIn(); |
||||
OC_JSON::checkAppEnabled('contacts'); |
||||
|
||||
$bookid = $_POST['id']; |
||||
OC_Contacts_Addressbook::edit($bookid, $_POST['name'], null); |
||||
OC_Contacts_Addressbook::setActive($bookid, $_POST['active']); |
||||
$addressbook = OC_Contacts_App::getAddressbook($bookid); |
||||
$tmpl = new OC_Template('contacts', 'part.chooseaddressbook.rowfields'); |
||||
$tmpl->assign('addressbook', $addressbook); |
||||
OC_JSON::success(array( |
||||
'page' => $tmpl->fetchPage(), |
||||
'addressbook' => $addressbook, |
||||
)); |
||||
@ -0,0 +1,39 @@ |
||||
<?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'); |
||||
$book = isset($_GET['bookid']) ? $_GET['bookid'] : NULL; |
||||
$contact = isset($_GET['contactid']) ? $_GET['contactid'] : NULL; |
||||
if(isset($book)){ |
||||
$addressbook = OC_Contacts_App::getAddressbook($book); |
||||
if($addressbook['userid'] != OC_User::getUser()){ |
||||
OC_JSON::error(); |
||||
exit; |
||||
} |
||||
$cardobjects = OC_Contacts_VCard::all($book); |
||||
header('Content-Type: text/directory'); |
||||
header('Content-Disposition: inline; filename=' . str_replace(' ', '_', $addressbook['displayname']) . '.vcf'); |
||||
for($i = 0;$i <= count($cardobjects); $i++){ |
||||
echo $cardobjects[$i]['carddata']; |
||||
//echo '\r\n'; |
||||
} |
||||
}elseif(isset($contact)){ |
||||
$data = OC_Contacts_App::getContactObject($contact); |
||||
$addressbookid = $data['addressbookid']; |
||||
$addressbook = OC_Contacts_App::getAddressbook($addressbookid); |
||||
if($addressbook['userid'] != OC_User::getUser()){ |
||||
OC_JSON::error(); |
||||
exit; |
||||
} |
||||
header('Content-Type: text/directory'); |
||||
header('Content-Disposition: inline; filename=' . $data['fullname'] . '.vcf'); |
||||
echo $data['carddata']; |
||||
} |
||||
?> |
||||
@ -0,0 +1,24 @@ |
||||
<div id="chooseaddressbook_dialog" title="<?php echo $l->t("Choose active Address Books"); ?>">
|
||||
<table width="100%" style="border: 0;"> |
||||
<?php |
||||
$option_addressbooks = OC_Contacts_Addressbook::all(OC_User::getUser()); |
||||
for($i = 0; $i < count($option_addressbooks); $i++){ |
||||
echo "<tr>"; |
||||
$tmpl = new OC_Template('contacts', 'part.chooseaddressbook.rowfields'); |
||||
$tmpl->assign('addressbook', $option_addressbooks[$i]); |
||||
$tmpl->assign('active', OC_Contacts_Addressbook::isActive($option_addressbooks[$i]['id'])); |
||||
$tmpl->printpage(); |
||||
echo "</tr>"; |
||||
} |
||||
?> |
||||
<tr> |
||||
<td colspan="5"> |
||||
<a href="#" onclick="Contacts.UI.Addressbooks.newAddressbook(this);"><?php echo $l->t('New Address Book') ?></a>
|
||||
</td> |
||||
</tr> |
||||
<tr> |
||||
<td colspan="5"> |
||||
<p style="margin: 0 auto;width: 90%;"><input style="display:none;width: 90%;float: left;" type="text" id="carddav_url" onmouseover="$('#carddav_url').select();" title="<?php echo $l->t("CardDav Link"); ?>"><img id="carddav_url_close" style="height: 20px;vertical-align: middle;display: none;" src="../../core/img/actions/delete.svg" alt="close" onclick="$('#carddav_url').hide();$('#carddav_url_close').hide();"/></p>
|
||||
</td> |
||||
</tr> |
||||
</table> |
||||
@ -0,0 +1,5 @@ |
||||
<?php |
||||
|
||||
echo "<td width=\"20px\"><input id=\"active_" . $_['addressbook']["id"] . "\" type=\"checkbox\" onClick=\"Contacts.UI.Addressbooks.activation(this, " . $_['addressbook']["id"] . ")\"" . (OC_Contacts_Addressbook::isActive($_['addressbook']["id"]) ? ' checked="checked"' : '') . "></td>"; |
||||
echo "<td><label for=\"active_" . $_['addressbook']["id"] . "\">" . $_['addressbook']["displayname"] . "</label></td>"; |
||||
echo "<td width=\"20px\"><a href=\"#\" onclick=\"Contacts.UI.showCardDAVUrl('" . OC_User::getUser() . "', '" . $_['addressbook']["uri"] . "');\" title=\"" . $l->t("CardDav Link") . "\" class=\"action\"><img class=\"svg action\" src=\"../../core/img/actions/public.svg\"></a></td><td width=\"20px\"><a href=\"export.php?bookid=" . $_['addressbook']["id"] . "\" title=\"" . $l->t("Download") . "\" class=\"action\"><img class=\"svg action\" src=\"../../core/img/actions/download.svg\"></a></td><td width=\"20px\"><a href=\"#\" title=\"" . $l->t("Edit") . "\" class=\"action\" onclick=\"Contacts.UI.Addressbooks.editAddressbook(this, " . $_['addressbook']["id"] . ");\"><img class=\"svg action\" src=\"../../core/img/actions/rename.svg\"></a></td><td width=\"20px\"><a href=\"#\" onclick=\"Contacts.UI.Addressbooks.deleteAddressbook('" . $_['addressbook']["id"] . "');\" title=\"" . $l->t("Delete") . "\" class=\"action\"><img class=\"svg action\" src=\"../../core/img/actions/delete.svg\"></a></td>"; |
||||
@ -1,3 +1,3 @@ |
||||
<?php foreach( $_['contacts'] as $contact ): ?> |
||||
<li data-id="<?php echo $contact['id']; ?>"><a href="index.php?id=<?php echo $contact['id']; ?>"><?php echo $contact['name']; ?></a> </li>
|
||||
<li book-id="<?php echo $contact['addressbookid']; ?>" data-id="<?php echo $contact['id']; ?>"><a href="index.php?id=<?php echo $contact['id']; ?>"><?php echo $contact['fullname']; ?></a> </li>
|
||||
<?php endforeach; ?> |
||||
|
||||
@ -0,0 +1,31 @@ |
||||
<?php |
||||
/** |
||||
* Copyright (c) 2011 Bart Visscher <bartv@thisnet.nl> |
||||
* This file is licensed under the Affero General Public License version 3 or |
||||
* later. |
||||
* See the COPYING-README file. |
||||
*/ |
||||
?> |
||||
<td id="<?php echo $_['new'] ? 'new' : 'edit' ?>addressbook_dialog" title="<?php echo $_['new'] ? $l->t("New Address Book") : $l->t("Edit Address Book"); ?>" colspan="6">
|
||||
<table width="100%" style="border: 0;"> |
||||
<tr> |
||||
<th><?php echo $l->t('Displayname') ?></th>
|
||||
<td> |
||||
<input id="displayname_<?php echo $_['addressbook']['id'] ?>" type="text" value="<?php echo $_['addressbook']['displayname'] ?>">
|
||||
</td> |
||||
</tr> |
||||
<?php if (!$_['new']): ?> |
||||
<tr> |
||||
<td></td> |
||||
<td> |
||||
<input id="edit_active_<?php echo $_['addressbook']['id'] ?>" type="checkbox"<?php echo OC_Contacts_Addressbook::isActive($_['addressbook']['id']) ? ' checked="checked"' : '' ?>>
|
||||
<label for="edit_active_<?php echo $_['addressbook']['id'] ?>">
|
||||
<?php echo $l->t('Active') ?> |
||||
</label> |
||||
</td> |
||||
</tr> |
||||
<?php endif; ?> |
||||
</table> |
||||
<input style="float: left;" type="button" onclick="Contacts.UI.Addressbooks.submit(this, <?php echo $_['new'] ? "'new'" : $_['addressbook']['id'] ?>);" value="<?php echo $_['new'] ? $l->t("Save") : $l->t("Submit"); ?>">
|
||||
<input style="float: left;" type="button" onclick="Contacts.UI.Addressbooks.cancel(this, <?php echo $_['new'] ? "'new'" : $_['addressbook']['id'] ?>);" value="<?php echo $l->t("Cancel"); ?>">
|
||||
</td> |
||||
Loading…
Reference in new issue