Author: Jan Schneider (jan@horde.org)
Inheritance: extends Horde_Translation
Example #1
0
 /**
  * Check if we are in an authenticated situation.
  *
  * @return boolean|PEAR_Error True if successful.
  */
 public function authenticated()
 {
     global $conf;
     if (empty($this->user)) {
         header('WWW-Authenticate: Basic realm="Kolab Freebusy"');
         return PEAR::raiseError(Horde_Kolab_FreeBusy_Translation::t("Please authenticate!"));
     }
     if (!$this->_authenticated) {
         return PEAR::raiseError(sprintf(Horde_Kolab_FreeBusy_Translation::t("Invalid authentication for user %s!"), $this->user));
     }
     return true;
 }
Example #2
0
 function stop()
 {
     if (!empty($this->_errors)) {
         $this->linebreak(1);
         echo Horde_Kolab_FreeBusy_Translation::t("Errors:");
         $this->linebreak(1);
         foreach ($this->_errors as $error) {
             echo $error;
         }
         return false;
     } else {
         $this->linebreak(1);
         echo Horde_Kolab_FreeBusy_Translation::t("Successfully regenerated all calendar caches!");
         $this->linebreak(1);
         return true;
     }
 }
Example #3
0
 /**
  * Deliver a "Server Error" page
  *
  * @param PEAR_Error $error    The error.
  */
 function serverError($error)
 {
     $headers = array('HTTP/1.0 500 Server Error');
     if (isset($_SERVER['REQUEST_URI'])) {
         $url = htmlentities($_SERVER['REQUEST_URI']);
     } else {
         $url = '/';
     }
     $this->_errorPage($error, $headers, Horde_Kolab_FreeBusy_Translation::t("500 Server Error"), Horde_Kolab_FreeBusy_Translation::t("Error"), htmlentities(${$url}));
 }
Example #4
0
 /**
  * Fetch remote free/busy user if the current user is not local or
  * redirect to the other server if configured this way.
  *
  * @param boolean $trigger Have we been called for triggering?
  * @param boolean $extended Should the extended information been delivered?
  */
 function fetchRemote($trigger = false, $extended = false)
 {
     global $conf;
     if (!empty($conf['kolab']['freebusy']['server'])) {
         $server = $conf['kolab']['freebusy']['server'];
     } else {
         $server = 'https://localhost/freebusy';
     }
     if (!empty($conf['fb']['redirect'])) {
         $do_redirect = $conf['fb']['redirect'];
     } else {
         $do_redirect = false;
     }
     if ($trigger) {
         $path = sprintf('/trigger/%s/%s.' . $extended ? 'pxfb' : 'pfb', urlencode($this->owner), urlencode($this->imap_folder));
     } else {
         $path = sprintf('/%s.' . $extended ? 'xfb' : 'ifb', urlencode($this->owner));
     }
     /* Check if we are on the right server and redirect if appropriate */
     if ($this->freebusyserver && $this->freebusyserver != $server) {
         $redirect = $this->freebusyserver . $path;
         Horde::log(sprintf("URL %s indicates remote free/busy server since we only offer %s. Redirecting.", $this->freebusyserver, $server), 'INFO');
         if ($do_redirect) {
             header("Location: {$redirect}");
         } else {
             header("X-Redirect-To: {$redirect}");
             $redirect = 'https://' . urlencode($this->user) . ':' . urlencode($GLOBALS['registry']->getAuthCredential('password')) . '@' . $this->freebusyserver . $path;
             if (!@readfile($redirect)) {
                 $message = sprintf(Horde_Kolab_FreeBusy_Translation::t("Unable to read free/busy information from %s"), 'https://' . urlencode($this->user) . ':XXX' . '@' . $this->freebusyserver . $_SERVER['REQUEST_URI']);
                 return PEAR::raiseError($message);
             }
         }
         exit;
     }
 }
Example #5
0
 /**
  * Process both the user accessing the page as well as the
  * owner of the requested free/busy information.
  *
  * @return boolean|PEAR_Error True if successful.
  */
 private function _process()
 {
     global $conf;
     require_once 'Horde/Kolab/Server.php';
     if (isset($conf['kolab']['ldap']['phpdn'])) {
         $params = array('uid' => $conf['kolab']['ldap']['phpdn'], 'pass' => $conf['kolab']['ldap']['phppw']);
     } else {
         $params = array('user' => $GLOBALS['registry']->getAuth(), 'pass' => $GLOBALS['registry']->getAuthCredential('password'));
     }
     /* Connect to the Kolab user database */
     $db =& Horde_Kolab_Server::singleton($params);
     // TODO: Remove once Kolab_Server has been fixed to always return the base dn
     $db->fetch();
     /* Retrieve the server configuration */
     try {
         $server = $db->fetch(sprintf('k=kolab,%s', $db->getBaseUid()), 'Horde_Kolab_Server_Object_Kolab_Server');
         $this->server_object = $server;
     } catch (Horde_Kolab_Server_Exception $e) {
         Horde::log(sprintf("Failed fetching the k=kolab configuration object. Error was: %s", $e->getMessage()), 'ERR');
         $this->server_object = null;
     }
     /* Fetch the user calling us */
     $udn = $db->uidForIdOrMail($this->user);
     if (is_a($udn, 'PEAR_Error')) {
         return $udn;
     }
     if ($udn) {
         $user = $db->fetch($udn, 'Horde_Kolab_Server_Object_Kolab_User');
         if (is_a($user, 'PEAR_Error')) {
             return $user;
         }
         $this->user_object = $user;
     }
     if ($this->user_object && $this->user_object->exists()) {
         $mail = $this->user_object->get(Horde_Kolab_Server_Object_Kolab_User::ATTRIBUTE_MAIL);
         if (is_a($mail, 'PEAR_Error')) {
             return $mail;
         }
         if ($mail) {
             $this->user = $mail;
         }
     }
     /* Fetch the owner of the free/busy data */
     $odn = $db->uidForIdOrMailOrAlias($this->owner);
     if (is_a($odn, 'PEAR_Error')) {
         return $odn;
     }
     if (!$odn) {
         $idx = strpos($this->user, '@');
         if ($idx !== false) {
             $domain = substr($this->user, $idx + 1);
             Horde::log(sprintf("Trying to append %s to %s", $domain, $this->owner), 'DEBUG');
             $odn = $odn = $db->uidForIdOrMail($this->owner . '@' . $domain);
         }
     }
     if ($odn) {
         $owner = $db->fetch($odn, 'Horde_Kolab_Server_Object_Kolab_User');
         if (is_a($owner, 'PEAR_Error')) {
             return $owner;
         }
         $this->owner_object =& $owner;
     }
     if (!empty($this->owner_object)) {
         if ($this->owner_object->exists()) {
             $this->owner = $this->owner_object->get(Horde_Kolab_Server_Object_Kolab_User::ATTRIBUTE_MAIL);
             $freebusyserver = $this->owner_object->getServer('freebusy');
             if (!is_a($freebusyserver, 'PEAR_Error')) {
                 $this->freebusyserver = $freebusyserver;
             }
         }
     } else {
         return PEAR::raiseError(Horde_Kolab_FreeBusy_Translation::t("Unable to determine owner of the free/busy data!"));
     }
     /* Mangle the folder request into an IMAP folder name */
     $this->imap_folder = $this->_getImapFolder();
     return true;
 }
Example #6
0
 /**
  * Returns the plural translation of a message.
  *
  * @param string $singular  The singular version to translate.
  * @param string $plural    The plural version to translate.
  * @param integer $number   The number that determines singular vs. plural.
  *
  * @return string  The string translation, or the original string if no
  *                 translation exists.
  */
 public static function ngettext($singular, $plural, $number)
 {
     self::$_domain = 'Horde_Kolab_FreeBusy';
     self::$_directory = '@data_dir@' == '@' . 'data_dir' . '@' ? __DIR__ . '/../../../../locale' : '@data_dir@/Horde_Kolab_FreeBusy/locale';
     return parent::ngettext($singular, $plural, $number);
 }