60 if (!is_string($username) || !strlen($username)) {
64 $this->_username = $username;
81 if (empty($this->_url)) {
83 'No URL set via '.get_class($this).
'->getServiceUrl($url).' 106 'Cannot set the URL, stream already opened.' 109 if (!is_string($url) || !strlen($url)) {
135 'Cannot set the mailbox, stream already opened.' 138 if (!is_string($mailbox) || !strlen($mailbox)) {
142 $this->_mailbox = $mailbox;
165 'Cannot set options, stream already opened.' 168 if (!is_int($options)) {
172 $this->_options = $options;
197 if (empty($this->_mailbox)) {
199 'You must specify a mailbox via '.get_class($this)
200 .
'->setMailbox($mailbox)' 208 phpCAS::trace(
'opening IMAP mailbox `'.$this->_mailbox.
'\'...
'); 209 $this->_stream = @imap_open( 210 $this->_mailbox, $this->_username, $this->getProxyTicket(), 213 if ($this->_stream) { 216 phpCAS::trace('could not
open mailbox
'); 217 // @todo add localization integration. 218 $message = 'IMAP Error:
'.$this->_url.' '. var_export(imap_errors(), true); 219 phpCAS::trace($message); 220 throw new CAS_ProxiedService_Exception($message); 224 return $this->_stream; 232 protected function hasBeenOpened () 234 return !empty($this->_stream); 237 /********************************************************* 238 * 3. Access the result 239 *********************************************************/ 253 public function getStream () 255 if (!$this->hasBeenOpened()) { 256 throw new CAS_OutOfSequenceException( 257 'Cannot access stream, not opened yet.
' 260 return $this->_stream; 271 public function getImapProxyTicket () 273 if (!$this->hasBeenOpened()) { 274 throw new CAS_OutOfSequenceException( 275 'Cannot access errors, stream not opened yet.
' 278 return $this->getProxyTicket();