Esempio n. 1
0
 public function formatItems($items, $format, $parameters = null)
 {
     $contacts = array();
     if ($format == self::FORMAT_CONTACT) {
         foreach ($items as $item) {
             $contact = VCard::find($item['item_source']);
             $contact['fullname'] = $item['item_target'];
             $contacts[] = $contact;
         }
     }
     return $contacts;
 }
Esempio n. 2
0
 function search($query)
 {
     $unescape = function ($value) {
         return strtr($value, array('\\,' => ',', '\\;' => ';'));
     };
     $searchresults = array();
     $results = \OCP\Contacts::search($query, array('N', 'FN', 'EMAIL', 'NICKNAME', 'ORG'));
     $l = new \OC_l10n('contacts');
     foreach ($results as $result) {
         $vcard = VCard::find($result['id']);
         $link = \OCP\Util::linkTo('contacts', 'index.php') . '#' . $vcard['id'];
         $props = array();
         foreach (array('EMAIL', 'NICKNAME', 'ORG') as $searchvar) {
             if (isset($result[$searchvar]) && count($result[$searchvar]) > 0 && strlen($result[$searchvar][0]) > 3) {
                 $props = array_merge($props, $result[$searchvar]);
             }
         }
         $props = array_map($unescape, $props);
         $searchresults[] = new \OC_Search_Result($vcard['fullname'], implode(', ', $props), $link, (string) $l->t('Contact'));
         //$name,$text,$link,$type
     }
     return $searchresults;
 }
Esempio n. 3
0
    private function isDuplicate($insertid)
    {
        $newobject = VCard::find($insertid);
        $stmt = \OCP\DB::prepare('SELECT COUNT(*) AS `COUNTING` FROM `' . App::ContactsTable . '` `CC`
								 INNER JOIN `' . App::AddrBookTable . '` `CA` ON `CC`.`addressbookid`=`CA`.`id`
								 WHERE  `CC`.`fullname`= ? AND `CC`.`carddata`=? AND `CC`.`component`=? AND `CA`.`id` = ? AND `CA`.`userid` = ?');
        $result = $stmt->execute(array($newobject['fullname'], $newobject['carddata'], 'VCARD', $this->id, $this->userid));
        $result = $result->fetchRow();
        if ($result['COUNTING'] >= 2) {
            return true;
        }
        return false;
    }