Example #1
0
 public function auth($authToken, $login = null, $password = null)
 {
     if (is_null($authToken)) {
         $soapHeader = new \SoapHeader('urn:zimbra', 'context');
         $params = array(ZimbraSoapClient::SoapVarArray(array('account' => $login, 'password' => $password)));
         $result = $this->__soapCall("AuthRequest", $params, null, $soapHeader);
         if (array_key_exists('authToken', $result)) {
             $this->authToken = $result['authToken'];
             return $this->authToken;
         } else {
             return false;
         }
     } else {
         $params = array(ZimbraSoapClient::SoapVarArray(array('authToken' => array('@verifyAccount' => 1, '%' => $authToken))));
         try {
             $result = $this->__soapCall("AuthRequest", $params, null, $soapHeader);
             $this->authToken = $result['authToken'];
             return $this->authToken;
         } catch (SoapFault $e) {
             if ($e->getMessage() == 'no valid authtoken present') {
                 return $this->auth(null, $login, $password);
             }
             throwException($e);
         }
     }
 }
Example #2
0
 public function searchContact($o)
 {
     $default = 'in:contacts';
     $params = array(ZimbraSoapClient::SoapVarArray(array('offset' => akead('start', $o, 0), 'limit' => akead('limit', $o, 25), 'sortBy' => akead('sort', $o, 'name') . ucfirst(strtolower(akead('dir', $o, 'asc'))), 'query' => $o['query'] == '' ? $default : $o['query'], 'total' => 1, 'types' => 'contact')));
     $res = $this->imapStream->call('zimbraMail', 'SearchRequest', $params, true);
     $arrResult = array_map(function ($contact) {
         ZimbraSoapClient::_mapAttr($contact['a'], '@n', '%');
         return array('name' => $contact['a']['nom'], 'email' => $contact['a']['email']);
     }, akead('cn', $res['Envelope']['Body']['SearchResponse'], array()));
     return array('data' => $arrResult, 'totalCount' => $res['Envelope']['Body']['SearchResponse']['@more'] == 1 ? akead('start', $o, 0) + count($arrResult) + 1 : count($arrResult));
 }