Esempio n. 1
0
 /**
  * @brief Converts the shared item sources back into the item in the specified format
  * @param array Shared items
  * @param int Format
  * @return ?
  *
  * The items array is a 3-dimensional array with the item_source as the first key and the share id as the second key to an array with the share info.
  * The key/value pairs included in the share info depend on the function originally called:
  * If called by getItem(s)Shared: id, item_type, item, item_source, share_type, share_with, permissions, stime, file_source
  * If called by getItem(s)SharedWith: id, item_type, item, item_source, item_target, share_type, share_with, permissions, stime, file_source, file_target
  * This function allows the backend to control the output of shared items with custom formats.
  * It is only called through calls to the public getItem(s)Shared(With) functions.
  */
 public function formatItems($items, $format, $parameters = null)
 {
     $addressbooks = array();
     if ($format == self::FORMAT_ADDRESSBOOKS) {
         foreach ($items as $item) {
             $addressbook = AddrBook::find($item['item_source']);
             if ($addressbook) {
                 $addressbook['displayname'] = $item['item_target'];
                 $addressbook['permissions'] = $item['permissions'];
                 $addressbooks[] = $addressbook;
             }
         }
     }
     return $addressbooks;
 }
Esempio n. 2
0
 /**
  * @brief Move card(s) to an address book
  * @param integer $aid Address book id
  * @param $id Array or integer of cards to be moved.
  * @return boolean
  *
  */
 public static function moveToAddressBook($aid, $id, $isAddressbook = false)
 {
     $addressbook = Addressbook::find($aid);
     if ($addressbook['userid'] != \OCP\User::getUser()) {
         $sharedAddressbook = \OCP\Share::getItemSharedWithBySource(App::SHAREADDRESSBOOK, App::SHAREADDRESSBOOKPREFIX . $aid);
         if (!$sharedAddressbook || !($sharedAddressbook['permissions'] & \OCP\PERMISSION_CREATE)) {
             throw new \Exception(App::$l10n->t('You don\'t have permissions to move contacts into this address book'));
         }
     }
     if (is_array($id)) {
         // NOTE: This block is currently not used and need rewrite if used!
         foreach ($id as $index => $cardId) {
             $card = self::find($cardId);
             if (!$card) {
                 unset($id[$index]);
             }
             $oldAddressbook = Addressbook::find($card['addressbookid']);
             if ($oldAddressbook['userid'] != \OCP\User::getUser()) {
                 $sharedContact = \OCP\Share::getItemSharedWithBySource(App::SHARECONTACT, App::SHARECONTACTPREFIX . $cardId, \OCP\Share::FORMAT_NONE, null, true);
                 if (!$sharedContact || !($sharedContact['permissions'] & \OCP\PERMISSION_DELETE)) {
                     unset($id[$index]);
                 }
             }
         }
         $id_sql = join(',', array_fill(0, count($id), '?'));
         $prep = 'UPDATE `' . App::ContactsTable . '` SET `addressbookid` = ? WHERE `id` IN (' . $id_sql . ')';
         try {
             $stmt = \OCP\DB::prepare($prep);
             //$aid = array($aid);
             $vals = array_merge((array) $aid, $id);
             $result = $stmt->execute($vals);
             if (\OCP\DB::isError($result)) {
                 \OCP\Util::writeLog(App::$appname, __METHOD__ . 'DB error: ' . \OCP\DB::getErrorMessage($result), \OCP\Util::ERROR);
                 throw new \Exception(App::$l10n->t('Database error during move.'));
             }
         } catch (\Exception $e) {
             \OCP\Util::writeLog(App::$appname, __METHOD__ . ', exception: ' . $e->getMessage(), \OCP\Util::ERROR);
             \OCP\Util::writeLog(App::$appname, __METHOD__ . ', ids: ' . join(',', $vals), \OCP\Util::DEBUG);
             \OCP\Util::writeLog(App::$appname, __METHOD__ . ', SQL:' . $prep, \OCP\Util::DEBUG);
             throw new \Exception(App::$l10n->t('Database error during move.'));
         }
     } else {
         $stmt = null;
         if ($isAddressbook) {
             $stmt = \OCP\DB::prepare('UPDATE `' . App::ContactsTable . '` SET `addressbookid` = ? WHERE `addressbookid` = ?');
         } else {
             $card = self::find($id);
             if (!$card) {
                 throw new \Exception(App::$l10n->t('Error finding card to move.'));
             }
             $oldAddressbook = Addressbook::find($card['addressbookid']);
             if ($oldAddressbook['userid'] != \OCP\User::getUser()) {
                 $sharedAddressbook = \OCP\Share::getItemSharedWithBySource(App::SHAREADDRESSBOOK, App::SHAREADDRESSBOOKPREFIX . $oldAddressbook['id']);
                 if (!$sharedAddressbook || !($sharedAddressbook['permissions'] & \OCP\PERMISSION_DELETE)) {
                     throw new \Exception(App::$l10n->t('You don\'t have permissions to move contacts from this address book'));
                 }
             }
             Addressbook::touch($oldAddressbook['id']);
             $stmt = \OCP\DB::prepare('UPDATE `' . App::ContactsTable . '` SET `addressbookid` = ? WHERE `id` = ?');
         }
         try {
             $result = $stmt->execute(array($aid, $id));
             if (\OCP\DB::isError($result)) {
                 \OCP\Util::writeLog(App::$appname, __METHOD__ . 'DB error: ' . \OCP\DB::getErrorMessage($result), \OCP\Util::ERROR);
                 throw new \Exception(App::$l10n->t('Database error during move.'));
             }
         } catch (\Exception $e) {
             \OCP\Util::writeLog(App::$appname, __METHOD__ . ', exception: ' . $e->getMessage(), \OCP\Util::DEBUG);
             \OCP\Util::writeLog(App::$appname, __METHOD__ . ' id: ' . $id, \OCP\Util::DEBUG);
             throw new \Exception(App::$l10n->t('Database error during move.'));
         }
     }
     //\OC_Hook::emit('\OCA\Contacts\VCard', 'post_moveToAddressbook', array('aid' => $aid, 'id' => $id));
     Addressbook::touch($aid);
     return true;
 }
Esempio n. 3
0
 /**
  * @NoAdminRequired
  */
 public function importVcards()
 {
     $pProgresskey = $this->params('progresskey');
     $pGetprogress = $this->params('getprogress');
     $pPath = $this->params('path');
     $pFile = $this->params('file');
     $pMethod = $this->params('method');
     $pAddressbook = $this->params('addressbookname');
     $pIsDragged = $this->params('isDragged');
     $pId = $this->params('id');
     $pOverwrite = $this->params('overwrite');
     \OC::$server->getSession()->close();
     if (isset($pProgresskey) && isset($pGetprogress)) {
         $aCurrent = \OC::$server->getCache()->get($pProgresskey);
         $aCurrent = json_decode($aCurrent);
         $numVC = isset($aCurrent->{'all'}) ? $aCurrent->{'all'} : 0;
         $currentVCCount = isset($aCurrent->{'current'}) ? $aCurrent->{'current'} : 0;
         $currentFn = isset($aCurrent->{'currentFn'}) ? $aCurrent->{'currentFn'} : '';
         $percent = isset($aCurrent->{'percent'}) ? $aCurrent->{'percent'} : '';
         if ($percent == '') {
             $percent = 0;
         }
         $params = ['status' => 'success', 'percent' => $percent, 'currentmsg' => $currentFn . ' ' . $percent . '% (' . $currentVCCount . '/' . $numVC . ')'];
         $response = new JSONResponse($params);
         return $response;
     }
     if ($pIsDragged === 'true') {
         //OCP\JSON::error(array('error'=>'404'));
         $file = explode(',', $pFile);
         $file = end($file);
         $file = base64_decode($file);
     } else {
         $file = \OC\Files\Filesystem::file_get_contents($pPath . '/' . $pFile);
     }
     if (!$file) {
         $params = ['status' => 'error', 'error' => '404'];
         $response = new JSONResponse($params);
         return $response;
     }
     $file = \Sabre\VObject\StringUtil::convertToUTF8($file);
     $import = new Import($file);
     $import->setUserID($this->userId);
     $import->setProgresskey($pProgresskey);
     $import->enableProgressCache();
     \OCP\Util::writeLog($this->appName, ' PROG: ' . $pProgresskey, \OCP\Util::DEBUG);
     if (!$import->isValid()) {
         $params = ['status' => 'error', 'error' => 'notvalid'];
         $response = new JSONResponse($params);
         return $response;
     }
     $newAddressbook = false;
     if ($pMethod == 'new') {
         $id = Addressbook::add($this->userId, $pAddressbook);
         if ($id) {
             Addressbook::setActive($id, 1);
             $newAddressbook = true;
         }
     } else {
         $id = $pId;
         Addressbook::find($id);
         $import->setOverwrite($pOverwrite);
     }
     //\OCP\Util::writeLog($this->appName,' METHOD: '.$pMethod.'ID:'.$id, \OCP\Util::DEBUG);
     $import->setAddressbookId($id);
     try {
         $import->import();
     } catch (\Exception $e) {
         $params = ['status' => 'error', 'message' => $this->l10n->t('Import failed')];
         $response = new JSONResponse($params);
         return $response;
     }
     $count = $import->getCount();
     $errorCount = $import->getErrorCount();
     if ($count == 0) {
         if ($newAddressbook) {
             Addressbook::delete($id);
         }
         $params = ['status' => 'error', 'message' => $this->l10n->t('The file contained either no vcard or all vcards are already saved in your addessbook.')];
         $response = new JSONResponse($params);
         return $response;
     } else {
         if ($newAddressbook) {
             $params = ['status' => 'success', 'message' => $count . ' ' . $this->l10n->t('vcards has been saved in the new addressbook') . ' ' . strip_tags($pAddressbook)];
             $response = new JSONResponse($params);
             return $response;
         } else {
             $params = ['status' => 'success', 'message' => $errorCount . ' Error - ' . $count . ' ' . $this->l10n->t('vcards has been saved in your addressbook')];
             $response = new JSONResponse($params);
             return $response;
         }
     }
 }
Esempio n. 4
0
 public static function renderOutput($addrbookId, $grpId = 'all')
 {
     if ($grpId === 'all') {
         $contacts_alphabet = VCard::all($addrbookId, null, null, array(), true);
     } elseif ($grpId === 'fav') {
         $contacts_alphabet = VCard::allByFavourite();
     } else {
         $contacts_alphabet = VCard::getCardsByGroups($addrbookId, $grpId, null, null, true);
     }
     $addressBookPerm = Addressbook::find($addrbookId);
     //Favourites
     $favorites = \OC::$server->getTagManager()->load(self::$appname)->getFavorites();
     $aFavourites = array();
     if (is_array($favorites)) {
         foreach ($favorites as $fav) {
             $aFavourites[$fav] = 1;
         }
     }
     $contacts = array();
     $counterAlle = 0;
     $aLetter = [];
     if ($contacts_alphabet) {
         $oldLetter = '';
         foreach ($contacts_alphabet as $contact) {
             try {
                 $vcard = VObject\Reader::read($contact['carddata']);
                 $details = VCard::structureContact($vcard);
                 $imgBuild = '';
                 if ($vcard->PHOTO) {
                     $image = new \OCP\Image();
                     $image->loadFromData((string) $vcard->PHOTO);
                     $imgSrc = $image->__toString();
                     $imgBuild = 'data:' . $image->mimeType() . ';base64,' . $imgSrc;
                 }
                 $sLetter = strtoupper(mb_substr($contact['sortFullname'], 0, 1, "UTF-8"));
                 if ($sLetter !== $oldLetter) {
                     $aLetter[] = $sLetter;
                 }
                 //\OCP\Util::writeLog(self::$appname,'LETTER: '. $sLetter.':'.$contact['fullname'], \OCP\Util::DEBUG);
                 $contacts[$sLetter][] = array('id' => $contact['id'], 'aid' => $contact['addressbookid'], 'letter' => $sLetter, 'photo' => $imgBuild, 'component' => $contact['component'], 'fullname' => $contact['fullname'], 'surename' => $contact['surename'], 'lastname' => $contact['lastname'], 'organization' => $contact['organization'], 'bcompany' => $contact['bcompany'], 'data' => $details);
                 $oldLetter = $sLetter;
                 $counterAlle++;
             } catch (Exception $e) {
                 continue;
             }
         }
         $oldLetter = '';
         $buildingOutput = '<ul>';
         foreach ($aLetter as $letterInfo) {
             $bFound = false;
             $ContactsOutput = '';
             if (isset($contacts[$letterInfo])) {
                 foreach ($contacts[$letterInfo] as $contactInfo) {
                     $bFound = true;
                     $CONTACTDATA = $contactInfo['data'];
                     $prepareOutput = self::renderSingleCard($CONTACTDATA, $contactInfo, $addressBookPerm, $aFavourites);
                     $ContactsOutput .= '<li class="contactsrow visible">' . $prepareOutput . '</li>';
                 }
             }
             if ($bFound === true) {
                 $buildingOutput .= '<li class="letter" data-scroll="' . $letterInfo . '"><span>' . $letterInfo . '</span></li>' . $ContactsOutput;
             } else {
                 $buildingOutput .= '<li class="letter hidden" data-scroll="' . $letterInfo . '"><span>' . $letterInfo . '</span></li>';
             }
         }
         $buildingOutput .= '<li><span class="noitem hidden">' . (string) self::$l10n->t('No Cards found!') . '</span></li>';
         $buildingOutput .= '</ul>';
     } else {
         $buildingOutput = '<ul>';
         foreach ($aLetter as $letterInfo) {
             $buildingOutput .= '<li class="letter hidden" data-scroll="' . $letterInfo . '"><span>' . $letterInfo . '</span></li>';
         }
         $buildingOutput .= '<li><span class="noitem">' . (string) self::$l10n->t('Add a new contact or import existing contacts from a file (VCF) per Drag & Drop.') . ' <i id="importAddrStart" title="' . (string) self::$l10n->t('Import addressbook per Drag & Drop') . '" class="toolTip ioc ioc-upload"></i></span></li>';
         $buildingOutput .= '</ul>';
     }
     return $buildingOutput;
 }
Esempio n. 5
0
 public static function renderOutput($addrbookId, $grpId = 'all')
 {
     if ($grpId === 'all') {
         $contacts_alphabet = VCard::all($addrbookId, null, null, array(), true);
     } elseif ($grpId === 'fav') {
         $contacts_alphabet = VCard::allByFavourite();
     } else {
         $contacts_alphabet = VCard::getCardsByGroups($addrbookId, $grpId, null, null, true);
     }
     $addressBookPerm = Addressbook::find($addrbookId);
     //Favourites
     $favorites = \OC::$server->getTagManager()->load(self::$appname)->getFavorites();
     $aFavourites = array();
     if (is_array($favorites)) {
         foreach ($favorites as $fav) {
             $aFavourites[$fav] = 1;
         }
     }
     $contacts = array();
     $counterAlle = 0;
     $aLetter = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z');
     if ($contacts_alphabet) {
         foreach ($contacts_alphabet as $contact) {
             try {
                 $vcard = VObject\Reader::read($contact['carddata']);
                 $details = VCard::structureContact($vcard);
                 $imgBuild = '';
                 if ($vcard->PHOTO) {
                     $image = new \OCP\Image();
                     $image->loadFromData((string) $vcard->PHOTO);
                     $imgSrc = $image->__toString();
                     $imgBuild = 'data:' . $image->mimeType() . ';base64,' . $imgSrc;
                 }
                 $sLetter = strtoupper(substr($contact['fullname'], 0, 1));
                 //\OCP\Util::writeLog(self::$appname,'LETTER: '. $sLetter.':'.$contact['fullname'], \OCP\Util::DEBUG);
                 $contacts[$sLetter][] = array('id' => $contact['id'], 'aid' => $contact['addressbookid'], 'letter' => $sLetter, 'photo' => $imgBuild, 'component' => $contact['component'], 'fullname' => $contact['fullname'], 'surename' => $contact['surename'], 'lastname' => $contact['lastname'], 'data' => $details);
                 $counterAlle++;
             } catch (Exception $e) {
                 continue;
             }
         }
         $oldLetter = '';
         $buildingOutput = '<ul>';
         foreach ($aLetter as $letterInfo) {
             $bFound = false;
             $ContactsOutput = '';
             if (isset($contacts[$letterInfo])) {
                 foreach ($contacts[$letterInfo] as $contactInfo) {
                     $bFound = true;
                     $CONTACTDATA = $contactInfo['data'];
                     $prepareOutput = self::renderSingleCard($CONTACTDATA, $contactInfo, $addressBookPerm, $aFavourites);
                     $ContactsOutput .= '<li class="contactsrow">' . $prepareOutput . '</li>';
                 }
             }
             if ($bFound === true) {
                 $buildingOutput .= '<li class="letter" data-scroll="' . $letterInfo . '"><span>' . $letterInfo . '</span></li>' . $ContactsOutput;
             } else {
                 $buildingOutput .= '<li class="letter hidden" data-scroll="' . $letterInfo . '"><span>' . $letterInfo . '</span></li>';
             }
         }
         $buildingOutput .= '</ul>';
     } else {
         $buildingOutput = '<ul>';
         foreach ($aLetter as $letterInfo) {
             $buildingOutput .= '<li class="letter hidden" data-scroll="' . $letterInfo . '"><span>' . $letterInfo . '</span></li>';
         }
         $buildingOutput .= '<li><span class="noitem">' . (string) self::$l10n->t('No Cards found!') . '</span></li>';
         $buildingOutput .= '</ul>';
     }
     return $buildingOutput;
 }
Esempio n. 6
0
 /**
  * @NoAdminRequired
  * @NoCSRFRequired
  */
 public function exportBirthdays()
 {
     $bookid = $this->params('aid');
     $bookid = isset($bookid) ? $bookid : null;
     if (!is_null($bookid)) {
         $addressbook = Addressbook::find($bookid);
         $aDefNArray = array('0' => 'fname', '1' => 'lname', '3' => 'title', '4' => '');
         foreach (VCard::all($bookid) as $contact) {
             try {
                 $vcard = VObject\Reader::read($contact['carddata']);
             } catch (Exception $e) {
                 continue;
             }
             $birthday = $vcard->BDAY;
             if ((string) $birthday) {
                 $details = VCard::structureContact($vcard);
                 $BirthdayTemp = new \DateTime($birthday);
                 $checkForm = $BirthdayTemp->format('d-m-Y');
                 $temp = explode('-', $checkForm);
                 $getAge = $this->getAgeCalc($temp[2], $temp[1], $temp[0]);
                 //$getAge=$BirthdayTemp->format('d-m-Y');
                 $title = isset($vcard->FN) ? strtr($vcard->FN->getValue(), array('\\,' => ',', '\\;' => ';')) : '';
                 $sNameOutput = '';
                 if (isset($details['N'][0]['value']) && count($details['N'][0]['value']) > 0) {
                     foreach ($details['N'][0]['value'] as $key => $val) {
                         if ($val != '') {
                             $aNameOutput[$aDefNArray[$key]] = $val;
                         }
                     }
                     //$sNameOutput=isset($aNameOutput['title'])?$aNameOutput['title'].' ':'';
                     $sNameOutput .= isset($aNameOutput['lname']) ? $aNameOutput['lname'] . ' ' : '';
                     $sNameOutput .= isset($aNameOutput['fname']) ? $aNameOutput['fname'] . ' ' : '';
                     unset($aNameOutput);
                 }
                 if ($sNameOutput == '') {
                     $sNameOutput = $title;
                 }
                 $sTitle1 = (string) $this->l10n->t('%1$s (%2$s)', array($sNameOutput, $getAge));
                 $aktYear = $BirthdayTemp->format('d-m');
                 $aktYear = $aktYear . date('-Y');
                 $start = new \DateTime($aktYear);
                 $end = new \DateTime($aktYear . ' +1 day');
                 $vcalendar = new VObject\Component\VCalendar();
                 $vevent = $vcalendar->createComponent('VEVENT');
                 $vevent->add('DTSTART');
                 $vevent->DTSTART->setDateTime($start);
                 $vevent->DTSTART['VALUE'] = 'date';
                 $vevent->add('DTEND');
                 $vevent->DTEND->setDateTime($end);
                 $vevent->DTEND['VALUE'] = 'date';
                 $vevent->{'SUMMARY'} = (string) $sTitle1;
                 $vevent->{'UID'} = substr(md5(rand() . time()), 0, 10);
                 $params['events'][] = $vevent->serialize();
             }
         }
         if (is_array($params['events'])) {
             $return = "BEGIN:VCALENDAR\nVERSION:2.0\nPRODID:ownCloud Calendar " . \OCP\App::getAppVersion('calendar') . "\nX-WR-CALNAME: export-bday-" . $bookid . "\n";
             foreach ($params['events'] as $event) {
                 $return .= $event;
             }
             $return .= "END:VCALENDAR";
             $name = str_replace(' ', '_', $addressbook['displayname']) . '_birthdays' . '.ics';
             $response = new DataDownloadResponse($return, $name, 'text/calendar');
             return $response;
         }
     }
 }
 /**
  * @NoAdminRequired
  */
 public function update()
 {
     $pId = $this->params('id');
     $pActive = $this->params('active');
     $pName = $this->params('name');
     $pDescription = $this->params('description');
     $pName = isset($pName) ? trim(strip_tags($pName)) : null;
     $description = isset($pDescription) ? trim(strip_tags($pDescription)) : null;
     if (!$pId) {
         $msg = (string) $this->l10n->t('id is not set.');
     }
     if (!$pName) {
         $msg = (string) $this->l10n->t('Cannot update addressbook with an empty name.');
     }
     try {
         Addressbook::edit($pId, $pName, $pDescription);
     } catch (Exception $e) {
         //bailOut($e->getMessage());
     }
     if (!Addressbook::setActive($pId, $pActive)) {
         $msg = (string) $this->l10n->t('Error (de)activating addressbook.');
     }
     $addressbook = Addressbook::find($pId);
     $params = ['status' => 'success', 'data' => ['addressbook' => $addressbook]];
     $response = new JSONResponse($params);
     return $response;
 }
Esempio n. 8
0
 /**
  * @NoAdminRequired
  */
 public function moveContact()
 {
     $pIds = $this->params('id');
     $aPid = explode(',', $pIds);
     $pAddrBookId = $this->params('addrid');
     $bMove = false;
     foreach ($aPid as $id) {
         $oldcard = VCard::find($id);
         $addressbook = Addressbook::find($oldcard['addressbookid']);
         if ($addressbook['userid'] !== $this->userId) {
             $sharedAddressbook = \OCP\Share::getItemSharedWithBySource(ContactsApp::SHAREADDRESSBOOK, ContactsApp::SHAREADDRESSBOOKPREFIX . $oldcard['addressbookid']);
             if (!$sharedAddressbook || !($sharedAddressbook['permissions'] & \OCP\PERMISSION_CREATE)) {
                 $bMove = false;
                 break;
             }
         }
         if ($oldcard['addressbookid'] !== $pAddrBookId) {
             VCard::moveToAddressBook($pAddrBookId, $id);
             $bMove = true;
         }
     }
     if ($bMove) {
         $params = ['status' => 'success', 'data' => ['id' => $aPid[0], 'count' => count($aPid)]];
     } else {
         $sMsg = 'Kontakt konnte nicht verschoben werden! Fehlende Berechtigungen.';
         $params = ['status' => 'error', 'data' => ['msg' => $sMsg]];
     }
     $response = new JSONResponse($params);
     return $response;
 }
 /**
  * @NoAdminRequired
  */
 public function showContact()
 {
     $id = $this->params('id');
     $vcard = ContactsApp::getContactVCard($id);
     $oldaddressbookid = VCard::getAddressbookid($id);
     $addressBookPerm = Addressbook::find($oldaddressbookid);
     $editInfoCard = VCard::structureContact($vcard);
     $TELTYPE = ContactsApp::getTypesOfProperty('TEL');
     $EMAILTYPE = ContactsApp::getTypesOfProperty('EMAIL');
     $URLTYPE = ContactsApp::getTypesOfProperty('URL');
     $ADRTYPE = ContactsApp::getTypesOfProperty('ADR');
     $aDefNArray = array('0' => 'lname', '1' => 'fname', '2' => 'anrede', '3' => 'title');
     $aN = '';
     if (isset($editInfoCard['N'][0]['value']) && count($editInfoCard['N'][0]['value']) > 0) {
         foreach ($editInfoCard['N'][0]['value'] as $key => $val) {
             if ($val != '') {
                 $aN[$aDefNArray[$key]] = $val;
             }
         }
     }
     $aOrgDef = array('0' => 'firm', '1' => 'department');
     $aOrg = array();
     if (isset($editInfoCard['ORG'][0]['value']) && count($editInfoCard['ORG'][0]['value']) > 0) {
         foreach ($editInfoCard['ORG'][0]['value'] as $key => $val) {
             if ($val != '') {
                 $aOrg[$aOrgDef[$key]] = $val;
             }
         }
     }
     $sBday = '';
     if (isset($editInfoCard['BDAY'][0]['value']) && !empty($editInfoCard['BDAY'][0]['value'])) {
         $sBday = $editInfoCard['BDAY'][0]['value'];
         $date = new \DateTime($sBday);
         $sBday = $date->format('d. M Y');
     }
     $sNotice = '';
     if (isset($editInfoCard['NOTE'][0]['value']) && !empty($editInfoCard['NOTE'][0]['value'])) {
         $sNotice = $editInfoCard['NOTE'][0]['value'];
     }
     $sNickname = '';
     if (isset($editInfoCard['NICKNAME'][0]['value']) && !empty($editInfoCard['NICKNAME'][0]['value'])) {
         $sNickname = $editInfoCard['NICKNAME'][0]['value'];
     }
     $sPosition = '';
     if (isset($editInfoCard['TITLE'][0]['value']) && !empty($editInfoCard['TITLE'][0]['value'])) {
         $sPosition = $editInfoCard['TITLE'][0]['value'];
     }
     $aAddr = '';
     if (array_key_exists('ADR', $editInfoCard)) {
         $aAddr = $this->getAddressInfo($editInfoCard['ADR'], $ADRTYPE);
     }
     $aTel = '';
     if (array_key_exists('TEL', $editInfoCard)) {
         $aTel = $this->getPhoneInfo($editInfoCard['TEL'], $TELTYPE);
     }
     $aEmail = '';
     if (array_key_exists('EMAIL', $editInfoCard)) {
         $aEmail = $this->getEmailInfo($editInfoCard['EMAIL'], $EMAILTYPE);
     }
     $aUrl = '';
     if (array_key_exists('URL', $editInfoCard)) {
         $aUrl = $this->getUrlInfo($editInfoCard['URL'], $URLTYPE);
     }
     $bPhoto = 0;
     $imgSrc = '';
     $imgMimeType = '';
     $thumb = '<div id="noimage" class="ioc ioc-user"></div>';
     if (isset($vcard->PHOTO)) {
         $bPhoto = 1;
         $thumb = '';
         $image = new \OCP\Image();
         $image->loadFromData((string) $vcard->PHOTO);
         $imgSrc = $image->__toString();
         $imgMimeType = $image->mimeType();
         \OC::$server->getCache()->set('show-contacts-foto-' . $id, $image->data(), 600);
     }
     $maxUploadFilesize = \OCP\Util::maxUploadFilesize('/');
     $params = ['id' => $id, 'tmpkey' => 'show-contacts-foto-' . $id, 'oldaddressbookid' => $oldaddressbookid, 'addressbooksPerm' => $addressBookPerm, 'isPhoto' => $bPhoto, 'thumbnail' => $thumb, 'imgsrc' => $imgSrc, 'imgMimeType' => $imgMimeType, 'anrede' => isset($aN['title']) ? $aN['title'] : '', 'fname' => isset($aN['fname']) ? $aN['fname'] : '', 'lname' => isset($aN['lname']) ? $aN['lname'] : '', 'firm' => isset($aOrg['firm']) ? $aOrg['firm'] : '', 'department' => isset($aOrg['department']) ? $aOrg['department'] : '', 'uploadMaxHumanFilesize' => \OCP\Util::humanFileSize($maxUploadFilesize), 'aTel' => isset($aTel) ? $aTel : '', 'aEmail' => isset($aEmail) ? $aEmail : '', 'aAddr' => isset($aAddr) ? $aAddr : '', 'aUrl' => isset($aUrl) ? $aUrl : '', 'sBday' => isset($sBday) ? $sBday : '', 'nickname' => isset($sNickname) ? $sNickname : '', 'position' => isset($sPosition) ? $sPosition : '', 'sNotice' => isset($sNotice) ? $sNotice : ''];
     $response = new TemplateResponse($this->appName, 'contact.show', $params, '');
     return $response;
 }