Use formatted shared addressbook in all cases, addressbooks out of order now
This commit is contained in:
parent
4185bd6292
commit
1e36e1f2cb
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue