Пример #1
0
 /**
  * Store feeds into the Contacts
  * @param array $feed 
  */
 public static function parseFeed($feed)
 {
     $userid = \OCP\User::getUser();
     foreach ($feed as $source) {
         $entry = Adapter::translateContact($source);
         if (isset($entry[self::CONTACT_GID]) && !empty($entry[self::CONTACT_GID])) {
             $oldContactId = self::findByGid($userid, $entry[self::CONTACT_GID]);
             if ($oldContactId) {
                 //If exists and should not be updated - skip
                 if (self::needUpdate($oldContactId)) {
                     $vcard = self::toVcard($entry);
                     \OCA\Contacts\VCard::edit($oldContactId, $vcard);
                 }
                 continue;
             }
         }
         $vcard = self::toVcard($entry);
         $bookid = self::getBookId($userid);
         \OCA\Contacts\VCard::add($bookid, $vcard);
     }
     \OCA\Contacts\App::getCategories();
 }