Beispiel #1
0
 /**
  * @param int $pageNumber
  * @param string $condition
  * @param int $groupId
  * @param string $sortField
  * @param bool $sortOrder
  * @return ContactCollection
  */
 function &SearchContactsAndGroups($pageNumber, $condition, $groupId, $sortField, $sortOrder, $lookForType)
 {
     $contacts = null;
     if ($this->_dbConnection->Execute($this->_commandCreator->SearchContactsAndGroups($pageNumber, $condition, $groupId, $sortField, $sortOrder, $this->Account, $lookForType))) {
         $contacts = new ContactCollection();
         $k = 0;
         while (false !== ($row = $this->_dbConnection->GetNextRecord())) {
             if ($lookForType == 1 && $k > SUGGESTCONTACTS) {
                 $this->_dbConnection->FreeResult();
                 break;
             }
             $contact = new Contact();
             $contact->Id = $row->id;
             $contact->IsGroup = $row->is_group;
             $contact->Name = $row->name;
             $contact->Email = $row->email;
             $contact->Frequency = $row->frequency;
             $contact->UseFriendlyName = (bool) $row->usefriendlyname;
             $contacts->Add($contact);
             unset($contact);
             $k++;
         }
     }
     return $contacts;
 }
Beispiel #2
0
 /**
  * @param	int		$groupId
  * @return	ContactCollection
  */
 public function GetContactsOfGroup($groupId)
 {
     $contacts = null;
     if ($this->_connect()) {
         if ($this->_search('(&(objectClass=' . self::OBJECT_CLASS_CONTACT . ')(memberofpabgroup=' . $groupId . '))')) {
             $contacts = new ContactCollection();
             $return = ldap_get_entries($this->_link, $this->_search);
             $this->_checkBoolReturn($return);
             if ($return) {
                 $k = 0;
                 while (isset($return[$k])) {
                     $row = $return[$k];
                     if (is_array($row) && isset($row['un'][0])) {
                         $contact = new Contact();
                         $contact->Id = $row['un'][0];
                         $contact->Name = isset($row['cn'][0]) ? $row['cn'][0] : '';
                         $contact->Email = isset($row['mail'][0]) ? $row['mail'][0] : '';
                         $contact->UseFriendlyName = true;
                         $contacts->Add($contact);
                         unset($contact);
                     }
                     $k++;
                 }
             }
         }
     }
     return $contacts;
 }