diff options
author | Georg Ehrke <dev@georgswebsite.de> | 2012-04-24 21:59:56 +0200 |
---|---|---|
committer | Georg Ehrke <dev@georgswebsite.de> | 2012-04-24 21:59:56 +0200 |
commit | f17eea506afaab0c0755d0fefe3a3f62eeb38e9d (patch) | |
tree | b5c1f8a33aef46f1a718d5313bef8f4e52700acf /apps/contacts/import.php | |
parent | d6346b5b0bece4feecc36b7b97308dd3a5a4d6cc (diff) | |
parent | 9b134b063683aca678e19912ebc3928321751714 (diff) | |
download | nextcloud-server-f17eea506afaab0c0755d0fefe3a3f62eeb38e9d.tar.gz nextcloud-server-f17eea506afaab0c0755d0fefe3a3f62eeb38e9d.zip |
fix merge conflicts
Diffstat (limited to 'apps/contacts/import.php')
-rw-r--r-- | apps/contacts/import.php | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/apps/contacts/import.php b/apps/contacts/import.php index b80021e00ea..ca2c1e1605d 100644 --- a/apps/contacts/import.php +++ b/apps/contacts/import.php @@ -17,8 +17,14 @@ if(is_writable('import_tmp/')){ fwrite($progressfopen, '10'); fclose($progressfopen); } -$file = OC_Filesystem::file_get_contents($_POST['path'] . '/' . $_POST['file']); -if($_POST['method'] == 'new'){ +$view = $file = null; +if(isset($_POST['fstype']) && $_POST['fstype'] == 'OC_FilesystemView') { + $view = OC_App::getStorage('contacts'); + $file = $view->file_get_contents('/' . $_POST['file']); +} else { + $file = OC_Filesystem::file_get_contents($_POST['path'] . '/' . $_POST['file']); +} +if(isset($_POST['method']) && $_POST['method'] == 'new'){ $id = OC_Contacts_Addressbook::add(OC_User::getUser(), $_POST['addressbookname']); OC_Contacts_Addressbook::setActive($id, 1); }else{ @@ -99,12 +105,16 @@ if(is_writable('import_tmp/')){ if(count($parts) == 1){ $importready = array($file); } +$imported = 0; +$failed = 0; foreach($importready as $import){ $card = OC_VObject::parse($import); if (!$card) { + $failed += 1; OC_Log::write('contacts','Import: skipping card. Error parsing VCard: '.$import, OC_Log::ERROR); continue; // Ditch cards that can't be parsed by Sabre. } + $imported += 1; OC_Contacts_VCard::add($id, $card); } //done the import @@ -117,4 +127,9 @@ sleep(3); if(is_writable('import_tmp/')){ unlink($progressfile); } -OC_JSON::success(); +if(isset($_POST['fstype']) && $_POST['fstype'] == 'OC_FilesystemView') { + if(!$view->unlink('/' . $_POST['file'])) { + OC_Log::write('contacts','Import: Error unlinking OC_FilesystemView ' . '/' . $_POST['file'], OC_Log::ERROR); + } +} +OC_JSON::success(array('data' => array('imported'=>$imported, 'failed'=>$failed))); |