/** * Replaces place holders in a query. * * @param string $query A SQL query with place holders. * @param integer $rule A Ingo::RULE_* constant. * * @return string A valid query. */ protected function _placeHolders($query, $rule) { $transport = $GLOBALS['injector']->getInstance('Ingo_Factory_Transport')->create(isset($this->_params['transport'][$rule]) ? $this->_params['transport'][$rule] : $this->_params['transport'][Ingo::RULE_ALL]); $search = array('%u', '%d'); $replace = array($transport->quote(Ingo::getUser()), $transport->quote(Ingo::getDomain())); switch ($rule) { case Ingo::RULE_VACATION: $vacation = $this->_params['storage']->retrieve(Ingo_Storage::ACTION_VACATION); $search[] = '%m'; $search[] = '%s'; $replace[] = $transport->quote($vacation->getVacationReason()); $replace[] = $transport->quote($vacation->getVacationSubject()); break; } return str_replace($search, $replace, $query); }
/** * Connect to the VFS server. * * @throws Ingo_Exception */ protected function _connect() { /* Do variable substitution. */ if (!empty($this->_params['vfs_path'])) { $this->_params['vfs_path'] = str_replace(array('%u', '%d', '%U'), array(Ingo::getUser(), Ingo::getDomain(), $this->_params['username']), $this->_params['vfs_path']); } if (!empty($this->_vfs)) { return; } try { $this->_vfs = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Vfs')->create('ingo', array('type' => $this->_params['vfstype'], 'params' => $this->_params)); } catch (Horde_Exception $e) { throw new Ingo_Exception($e); } }