summaryrefslogtreecommitdiffstats
path: root/apps/contacts
diff options
context:
space:
mode:
authorMichael Gapczynski <mtgap@owncloud.com>2012-07-03 11:36:57 -0400
committerMichael Gapczynski <mtgap@owncloud.com>2012-07-03 11:36:57 -0400
commit1e36e1f2cb72298cebda693aa1452ec569250757 (patch)
treee751a471641559ca6ff3887c4572cd49e5594f5f /apps/contacts
parent4185bd629259bfb0618143d0474e192e969daf96 (diff)
downloadnextcloud-server-1e36e1f2cb72298cebda693aa1452ec569250757.tar.gz
nextcloud-server-1e36e1f2cb72298cebda693aa1452ec569250757.zip
Use formatted shared addressbook in all cases, addressbooks out of order now
Diffstat (limited to 'apps/contacts')
-rw-r--r--apps/contacts/lib/addressbook.php13
-rw-r--r--apps/contacts/lib/app.php16
2 files changed, 21 insertions, 8 deletions
diff --git a/apps/contacts/lib/addressbook.php b/apps/contacts/lib/addressbook.php
index afbf1d59201..4f00ce1f9e3 100644
--- a/apps/contacts/lib/addressbook.php
+++ b/apps/contacts/lib/addressbook.php
@@ -235,6 +235,7 @@ class OC_Contacts_Addressbook{
$uid = OCP\USER::getUser();
}
$active = self::activeIds($uid);
+ $shared = OCP\Share::getItemsSharedWith('addressbook', OC_Contacts_Share::FORMAT_ADDRESSBOOKS);
$addressbooks = array();
$ids_sql = join(',', array_fill(0, count($active), '?'));
$prep = 'SELECT * FROM *PREFIX*contacts_addressbooks WHERE id IN ('.$ids_sql.') ORDER BY displayname';
@@ -249,7 +250,17 @@ class OC_Contacts_Addressbook{
}
while( $row = $result->fetchRow()){
- $addressbooks[] = $row;
+ // Insert formatted shared addressbook instead
+ if ($row['userid'] != $uid) {
+ foreach ($shared as $addressbook) {
+ if ($addressbook['id'] == $row['id']) {
+ $addressbooks[] = $addressbook;
+ break;
+ }
+ }
+ } else {
+ $addressbooks[] = $row;
+ }
}
if(!count($addressbooks)) {
self::addDefault($uid);
diff --git a/apps/contacts/lib/app.php b/apps/contacts/lib/app.php
index ce66624c8f9..3b16ffd5c16 100644
--- a/apps/contacts/lib/app.php
+++ b/apps/contacts/lib/app.php
@@ -24,16 +24,18 @@ class OC_Contacts_App {
public static function getAddressbook($id) {
$addressbook = OC_Contacts_Addressbook::find( $id );
- if( $addressbook === false || $addressbook['userid'] != OCP\USER::getUser() && !OCP\Share::getItemSharedWithBySource('addressbook', $id)) {
- if ($addressbook === false) {
- OCP\Util::writeLog('contacts', 'Addressbook not found: '. $id, OCP\Util::ERROR);
- OCP\JSON::error(array('data' => array( 'message' => self::$l10n->t('Addressbook not found.'))));
- }
- else {
+ if ($addressbook === false) {
+ OCP\Util::writeLog('contacts', 'Addressbook not found: '. $id, OCP\Util::ERROR);
+ OCP\JSON::error(array('data' => array( 'message' => self::$l10n->t('Addressbook not found.'))));
+ exit();
+ } else if ($addressbook['userid'] != OCP\USER::getUser()) {
+ if ($shared = OCP\Share::getItemSharedWithBySource('addressbook', $id)) {
+ $addressbook['displayname'] = $shared['item_target'];
+ } else {
OCP\Util::writeLog('contacts', 'Addressbook('.$id.') is not from '.OCP\USER::getUser(), OCP\Util::ERROR);
OCP\JSON::error(array('data' => array( 'message' => self::$l10n->t('This is not your addressbook.'))));
+ exit();
}
- exit();
}
return $addressbook;
}