mirror of
https://github.com/nextcloud/server.git
synced 2026-06-09 00:32:29 -04:00
- Added fix for empty 'FN' field on import via CardDAV clients.
- Make sure that the contact in the list has a display name. - More tweaks on thumbnail caching.
This commit is contained in:
parent
137c630377
commit
ca03a26f15
3 changed files with 27 additions and 5 deletions
|
|
@ -159,15 +159,27 @@ class OC_Contacts_VCard{
|
|||
*/
|
||||
public static function addFromDAVData($id,$uri,$data){
|
||||
$fn = null;
|
||||
$email = null;
|
||||
$card = OC_VObject::parse($data);
|
||||
if(!is_null($card)){
|
||||
foreach($card->children as $property){
|
||||
if($property->name == 'FN'){
|
||||
$fn = $property->value;
|
||||
break;
|
||||
}
|
||||
if($property->name == 'EMAIL' && is_null($email)){
|
||||
$email = $property->value;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!$fn) {
|
||||
if($email) {
|
||||
$fn = $email;
|
||||
} else {
|
||||
$fn = 'Unknown';
|
||||
}
|
||||
$card->addProperty('EMAIL', $email);
|
||||
$data = $card->serialize();
|
||||
}
|
||||
|
||||
$stmt = OC_DB::prepare( 'INSERT INTO *PREFIX*contacts_cards (addressbookid,fullname,carddata,uri,lastmodified) VALUES(?,?,?,?,?)' );
|
||||
$result = $stmt->execute(array($id,$fn,$data,$uri,time()));
|
||||
|
|
|
|||
|
|
@ -1,3 +1,13 @@
|
|||
<?php foreach( $_['contacts'] as $contact ): ?>
|
||||
<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 foreach( $_['contacts'] as $contact ):
|
||||
$display = trim($contact['fullname']);
|
||||
if(!$display) {
|
||||
$vcard = OC_Contacts_App::getContactVCard($contact['id']);
|
||||
if(!is_null($vcard)) {
|
||||
$struct = OC_Contacts_VCard::structureContact($vcard);
|
||||
$display = isset($struct['EMAIL'][0])?$struct['EMAIL'][0]['value']:'[UNKNOWN]';
|
||||
}
|
||||
}
|
||||
echo '<!-- '.$display.' -->';
|
||||
?>
|
||||
<li book-id="<?php echo $contact['addressbookid']; ?>" data-id="<?php echo $contact['id']; ?>"><a href="index.php?id=<?php echo $contact['id']; ?>"><?php echo $display; ?></a></li>
|
||||
<?php endforeach; ?>
|
||||
|
|
|
|||
|
|
@ -22,8 +22,8 @@
|
|||
|
||||
// Init owncloud
|
||||
require_once('../../lib/base.php');
|
||||
//OC_JSON::checkLoggedIn();
|
||||
OC_Util::checkLoggedIn();
|
||||
OC_JSON::checkLoggedIn();
|
||||
//OC_Util::checkLoggedIn();
|
||||
OC_Util::checkAppEnabled('contacts');
|
||||
|
||||
function getStandardImage(){
|
||||
|
|
|
|||
Loading…
Reference in a new issue