예제 #1
0
 /**
  * @param string $email
  * @return null|string
  */
 public function getPhoto($email)
 {
     $result = $this->contactsManager->search($email, ['EMAIL']);
     if (count($result) > 0) {
         if (isset($result[0]['PHOTO'])) {
             $s = $result[0]['PHOTO'];
             return substr($s, strpos($s, 'http'));
         }
     }
     return null;
 }
 /**
  * @param string $search
  * @return JSONResponse
  *
  * @NoAdminRequired
  * @NoCSRFRequired
  */
 public function searchAttendee($search)
 {
     $result = $this->contacts->search($search, ['FN', 'EMAIL']);
     $contacts = [];
     foreach ($result as $r) {
         if (!isset($r['EMAIL'])) {
             continue;
         }
         $name = $this->getName($r);
         foreach ($r['EMAIL'] as $email) {
             $contacts[] = ['email' => $email, 'name' => $name];
         }
     }
     return new JSONResponse($contacts);
 }
예제 #3
0
파일: sharees.php 프로젝트: rosarion/core
 /**
  * @param string $search
  * @return array possible sharees
  */
 protected function getRemote($search)
 {
     $this->result['remotes'] = [];
     // Search in contacts
     //@todo Pagination missing
     $addressBookContacts = $this->contactsManager->search($search, ['CLOUD', 'FN']);
     $foundRemoteById = false;
     foreach ($addressBookContacts as $contact) {
         if (isset($contact['CLOUD'])) {
             foreach ($contact['CLOUD'] as $cloudId) {
                 if (strtolower($contact['FN']) === $search || strtolower($cloudId) === $search) {
                     if (strtolower($cloudId) === $search) {
                         $foundRemoteById = true;
                     }
                     $this->result['exact']['remotes'][] = ['label' => $contact['FN'], 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => $cloudId]];
                 } else {
                     $this->result['remotes'][] = ['label' => $contact['FN'], 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => $cloudId]];
                 }
             }
         }
     }
     if (!$foundRemoteById && substr_count($search, '@') >= 1 && substr_count($search, ' ') === 0 && $this->offset === 0) {
         $this->result['exact']['remotes'][] = ['label' => $search, 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => $search]];
     }
     $this->reachedEndFor[] = 'remotes';
 }
예제 #4
0
 /**
  * Extracts all matching contacts with email address and name
  *
  * @param string $term
  * @return array
  */
 public function getMatchingLocaction($term)
 {
     if (!$this->contactsManager->isEnabled()) {
         return array();
     }
     $result = $this->contactsManager->search($term, array('FN', 'ADR', 'N'));
     //$addressDefArray=array('0'=>'','1'=>'','2'=>'street','3'=>'city','4'=>'','5'=>'postalcode','6'=>'country');
     //$aDefNArray=array('0'=>'lname','1'=>'fname','2'=>'anrede', '3'=>'title');
     $receivers = array();
     foreach ($result as $r) {
         $id = $r['id'];
         $fn = $r['FN'];
         $name = '';
         if (isset($r['N'])) {
             list($lastname, $surename, $gender, $title) = $r['N'];
             $name = !empty($surename) ? $surename : '';
             $name .= !empty($lastname) ? ' ' . $lastname : '';
             $name = '(' . $name . ')';
             //$name .= (!empty($gender)?$gender:'');
             //$name .= (!empty($title)?' '.$title:'');
         }
         $address = $r['ADR'];
         if (!is_array($address)) {
             $address = array($address);
         }
         // loop through all email addresses of this contact
         foreach ($address as $e) {
             $aAddr = '';
             list($zero, $one, $street, $city, $four, $postalcode, $country) = $e;
             $aAddr = !empty($street) ? $street : '';
             $aAddr .= !empty($postalcode) ? ', ' . $postalcode . ' ' : '';
             $aAddr .= !empty($city) ? $city : '';
             $aAddr .= !empty($country) ? ', ' . $country : '';
             $displayName = "\"{$fn}\" {$name} {$aAddr}";
             $valueAddr = $aAddr;
             $receivers[] = array('id' => $id, 'label' => $displayName, 'value' => $valueAddr);
         }
     }
     return $receivers;
 }
예제 #5
0
 /**
  * Try to find the user in the contacts
  *
  * @param string $federatedCloudId
  * @return string
  * @throws \OutOfBoundsException when there is no contact for the id
  */
 protected function getDisplayNameFromContact($federatedCloudId)
 {
     $federatedCloudId = strtolower($federatedCloudId);
     if (isset($this->federatedContacts[$federatedCloudId])) {
         if ($this->federatedContacts[$federatedCloudId] !== '') {
             return $this->federatedContacts[$federatedCloudId];
         } else {
             throw new \OutOfBoundsException('No contact found for federated cloud id');
         }
     }
     $addressBookEntries = $this->manager->search($federatedCloudId, ['CLOUD']);
     foreach ($addressBookEntries as $entry) {
         if (isset($entry['CLOUD'])) {
             foreach ($entry['CLOUD'] as $cloudID) {
                 if ($cloudID === $federatedCloudId) {
                     $this->federatedContacts[$federatedCloudId] = $entry['FN'];
                     return $entry['FN'];
                 }
             }
         }
     }
     $this->federatedContacts[$federatedCloudId] = '';
     throw new \OutOfBoundsException('No contact found for federated cloud id');
 }
예제 #6
0
파일: sharees.php 프로젝트: gvde/core
 /**
  * @param string $search
  * @return array possible sharees
  */
 protected function getRemote($search)
 {
     $this->result['remotes'] = [];
     // Search in contacts
     //@todo Pagination missing
     $addressBookContacts = $this->contactsManager->search($search, ['CLOUD', 'FN']);
     $foundRemoteById = false;
     foreach ($addressBookContacts as $contact) {
         if (isset($contact['isLocalSystemBook'])) {
             continue;
         }
         if (isset($contact['CLOUD'])) {
             $cloudIds = $contact['CLOUD'];
             if (!is_array($cloudIds)) {
                 $cloudIds = [$cloudIds];
             }
             foreach ($cloudIds as $cloudId) {
                 list(, $serverUrl) = $this->splitUserRemote($cloudId);
                 if (strtolower($contact['FN']) === $search || strtolower($cloudId) === $search) {
                     if (strtolower($cloudId) === $search) {
                         $foundRemoteById = true;
                     }
                     $this->result['exact']['remotes'][] = ['label' => $contact['FN'], 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => $cloudId, 'server' => $serverUrl]];
                 } else {
                     $this->result['remotes'][] = ['label' => $contact['FN'], 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => $cloudId, 'server' => $serverUrl]];
                 }
             }
         }
     }
     if (!$this->shareeEnumeration) {
         $this->result['remotes'] = [];
     }
     if (!$foundRemoteById && substr_count($search, '@') >= 1 && substr_count($search, ' ') === 0 && $this->offset === 0) {
         $this->result['exact']['remotes'][] = ['label' => $search, 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => $search]];
     }
     $this->reachedEndFor[] = 'remotes';
 }