getParam() public method

Returns a value from the internal params array.
public getParam ( string $key ) : mixed
$key string The param key.
return mixed The param value, or null if not found.
Ejemplo n.º 1
0
 /**
  * Constructor.
  *
  * @param array $params  Configuration parameters:
  * <pre>
  *   - REQUIRED Parameters:
  *     - backend: (Horde_Imap_Client_Cache_Backend) The cache backend.
  *     - baseob: (Horde_Imap_Client_Base) The base client object.
  *
  *   - Optional Parameters:
  *     - debug: (Horde_Imap_Client_Base_Debug) Debug object.
  *              DEFAULT: No debug output
  * </pre>
  */
 public function __construct(array $params = array())
 {
     $this->_backend = $params['backend'];
     $this->_baseob = $params['baseob'];
     $this->_backend->setParams(array('hostspec' => $this->_baseob->getParam('hostspec'), 'port' => $this->_baseob->getParam('port'), 'username' => $this->_baseob->getParam('username')));
     if (isset($params['debug']) && $params['debug'] instanceof Horde_Imap_Client_Base_Debug) {
         $this->_debug = $params['debug'];
         $this->_debug->info(sprintf('CACHE: Using the %s storage driver.', get_class($this->_backend)));
     }
 }
Ejemplo n.º 2
0
 /**
  * Constructor.
  *
  * @param array $params  Configuration parameters:
  * <ul>
  *  <li>
  *   REQUIRED Parameters:
  *   <ul>
  *    <li>
  *     baseob: (Horde_Imap_Client_Base) The driver object.
  *    </li>
  *    <li>
  *     cacheob: (Horde_Cache) The cache object to use.
  *    </li>
  *   </ul>
  *  </li>
  *  <li>
  *   Optional Parameters:
  *   <ul>
  *    <li>
  *     debug: (boolean) If true, will output debug information.
  *            DEFAULT: No debug output
  *    </li>
  *    <li>
  *     lifetime: (integer) The lifetime of the cache data (in seconds).
  *               DEFAULT: 1 week (604800 seconds)
  *    </li>
  *    <li>
  *     slicesize: (integer) The slicesize to use.
  *                DEFAULT: 50
  *    </li>
  *   </ul>
  *  </li>
  * </ul>
  */
 public function __construct(array $params = array())
 {
     $required = array('baseob', 'cacheob');
     foreach ($required as $val) {
         if (empty($params[$val])) {
             throw new InvalidArgumentException('Missing required parameter for ' . __CLASS__ . ': ' . $val);
         }
     }
     // Default parameters.
     $params = array_merge(array('debug' => false, 'lifetime' => 604800, 'slicesize' => 50), array_filter($params));
     $this->_base = $params['baseob'];
     $this->_params = array('hostspec' => $this->_base->getParam('hostspec'), 'port' => $this->_base->getParam('port'), 'username' => $this->_base->getParam('username'));
     $this->_cache = $params['cacheob'];
     $this->_params['debug'] = (bool) $params['debug'];
     $this->_params['lifetime'] = intval($params['lifetime']);
     $this->_params['slicesize'] = intval($params['slicesize']);
     register_shutdown_function(array($this, 'shutdown'));
 }
Ejemplo n.º 3
0
 /**
  */
 public function getParam($key)
 {
     switch ($key) {
         case 'xoauth2_token':
             if (isset($this->_params[$key]) && $this->_params[$key] instanceof Horde_Imap_Client_Base_Password) {
                 return $this->_params[$key]->getPassword();
             }
             break;
     }
     return parent::getParam($key);
 }
Ejemplo n.º 4
0
 /**
  * All other calls to this class are routed to the underlying
  * Horde_Imap_Client_Base object.
  *
  * @param string $method  Method name.
  * @param array $params   Method parameters.
  *
  * @return mixed  The return from the requested method.
  * @throws BadMethodCallException
  * @throws IMP_Imap_Exception
  */
 public function __call($method, $params)
 {
     global $injector;
     if (!$this->init) {
         /* Fallback for these methods. */
         switch ($method) {
             case 'getIdsOb':
                 $ob = new Horde_Imap_Client_Ids();
                 call_user_func_array(array($ob, 'add'), $params);
                 return $ob;
         }
         throw new Horde_Exception_AuthenticationFailure('IMP is marked as authenticated, but no credentials can be found in the session.', Horde_Auth::REASON_SESSION);
     }
     switch ($method) {
         case 'append':
         case 'createMailbox':
         case 'deleteMailbox':
         case 'expunge':
         case 'fetch':
         case 'getACL':
         case 'getMetadata':
         case 'getMyACLRights':
         case 'getQuota':
         case 'getQuotaRoot':
         case 'getSyncToken':
         case 'setMetadata':
         case 'setQuota':
         case 'store':
         case 'subscribeMailbox':
         case 'sync':
         case 'thread':
             // Horde_Imap_Client_Mailbox: these calls all have the mailbox as
             // their first parameter.
             $params[0] = IMP_Mailbox::getImapMboxOb($params[0]);
             break;
         case 'copy':
         case 'renameMailbox':
             // These calls may hit multiple servers.
             $source = IMP_Mailbox::get($params[0]);
             $dest = IMP_Mailbox::get($params[1]);
             if ($source->remote_account != $dest->remote_account) {
                 return call_user_func_array(array($this, '_' . $method), $params);
             }
             // Horde_Imap_Client_Mailbox: these calls all have the mailbox as
             // their first two parameters.
             $params[0] = $source->imap_mbox_ob;
             $params[1] = $dest->imap_mbox_ob;
             break;
         case 'getNamespaces':
             if (isset($this->_temp['ns'])) {
                 return $this->_temp['ns'];
             }
             $nsconfig = $this->config->namespace;
             $params[0] = is_null($nsconfig) ? array() : $nsconfig;
             $params[1] = array('ob_return' => true);
             break;
         case 'impStatus':
             /* Internal method: allows status call with array of mailboxes,
              * guaranteeing they are all on this server. */
             $params[0] = IMP_Mailbox::getImapMboxOb($params[0]);
             $method = 'status';
             break;
         case 'openMailbox':
             $mbox = IMP_Mailbox::get($params[0]);
             if ($mbox->search) {
                 /* Can't open a search mailbox. */
                 return;
             }
             $params[0] = $mbox->imap_mbox_ob;
             break;
         case 'search':
             $params = call_user_func_array(array($this, '_search'), $params);
             break;
         case 'status':
             if (is_array($params[0])) {
                 return $this->_status($params);
             }
             $params[0] = IMP_Mailbox::getImapMboxOb($params[0]);
             break;
         default:
             if (!method_exists($this->_ob, $method)) {
                 throw new BadMethodCallException(sprintf('%s: Invalid method call "%s".', __CLASS__, $method));
             }
             break;
     }
     try {
         $result = call_user_func_array(array($this->_ob, $method), $params);
     } catch (Horde_Imap_Client_Exception $e) {
         switch ($method) {
             case 'getNamespaces':
                 return new Horde_Imap_Client_Namespace_List();
         }
         Horde::log(new Exception(sprintf('[%s] %s', $method, $e->raw_msg), $e->getCode(), $e), 'WARN');
         $error = new IMP_Imap_Exception($e);
         throw ($auth_e = $error->authException(false)) ? $auth_e : $error;
     }
     /* Special handling for various methods. */
     switch ($method) {
         case 'createMailbox':
         case 'deleteMailbox':
         case 'renameMailbox':
             $injector->getInstance('IMP_Mailbox_SessionCache')->expire(null, IMP_Mailbox::get($params[0]));
             break;
         case 'getNamespaces':
             $this->_temp['ns'] = $result;
             break;
         case 'login':
             if (!$this->_ob->getParam('imp:login')) {
                 /* Check for POP3 UIDL support. */
                 if ($this->isPop3() && !$this->queryCapability('UIDL')) {
                     Horde::log(sprintf('The POP3 server does not support the REQUIRED UIDL capability. [server key: %s]', $this->server_key), 'CRIT');
                     throw new Horde_Exception_AuthenticationFailure(_("The mail server is not currently avaliable."), Horde_Auth::REASON_MESSAGE);
                 }
                 $this->_ob->setParam('imp:login', true);
                 $this->_changed = true;
             }
             break;
         case 'setACL':
             $injector->getInstance('IMP_Mailbox_SessionCache')->expire(IMP_Mailbox_SessionCache::CACHE_ACL, IMP_Mailbox::get($params[0]));
             break;
     }
     return $result;
 }