Author: Jan Schneider (jan@horde.org)
Inheritance: extends Horde_Translation
Esempio n. 1
0
 /**
  * @throws Horde_Exception
  */
 public function create(Horde_Injector $injector)
 {
     global $conf, $injector;
     if (empty($conf['weather']['provider'])) {
         throw new Horde_Exception(Horde_Core_Translation::t("Weather support not configured."));
     }
     // Parameters for all driver types
     $params = array('cache' => $injector->getInstance('Horde_Cache'), 'cache_lifetime' => $conf['weather']['params']['lifetime'], 'http_client' => $injector->createInstance('Horde_Core_Factory_HttpClient')->create());
     $driver = $conf['weather']['provider'];
     switch ($driver) {
         case 'WeatherUnderground':
         case 'Wwo':
             $params['apikey'] = $conf['weather']['params']['key'];
             break;
         case 'Google':
             $l = explode('_', $GLOBALS['language']);
             $params['language'] = $l[0];
             break;
     }
     $class = $this->_getDriverName($driver, 'Horde_Service_Weather');
     try {
         return new $class($params);
     } catch (InvalidArgumentException $e) {
         throw new Horde_Exception($e);
     }
 }
Esempio n. 2
0
 /**
  * Returns the VFS driver parameters for the specified backend.
  *
  * @param string $name  The VFS system name being used.
  *
  * @return array  A hash with the VFS parameters; the VFS driver in 'type'
  *                and the connection parameters in 'params'.
  * @throws Horde_Exception
  */
 public function getConfig($name = 'horde')
 {
     global $conf;
     if ($name !== 'horde' && !isset($conf[$name]['type'])) {
         throw new Horde_Exception(Horde_Core_Translation::t("You must configure a VFS backend."));
     }
     $vfs = $name == 'horde' || $conf[$name]['type'] == 'horde' ? $conf['vfs'] : $conf[$name];
     switch (Horde_String::lower($vfs['type'])) {
         case 'none':
             $vfs['params'] = array();
             $vfs['type'] = 'null';
             break;
         case 'nosql':
             $nosql = $this->_injector->getInstance('Horde_Core_Factory_Nosql')->create('horde', 'vfs');
             if ($nosql instanceof Horde_Mongo_Client) {
                 $vfs['params']['mongo_db'] = $nosql;
                 $vfs['type'] = 'mongo';
             }
             break;
         case 'sql':
         case 'sqlfile':
         case 'musql':
             $config = Horde::getDriverConfig('vfs', 'sql');
             unset($config['umask'], $config['vfsroot']);
             $vfs['params']['db'] = $this->_injector->getInstance('Horde_Core_Factory_Db')->create('horde', $config);
             break;
     }
     return $vfs;
 }
Esempio n. 3
0
 /**
  * Constructor
  *
  * @var params Horde_Variables  TODO
  */
 public function __construct(&$vars)
 {
     parent::__construct($vars, Horde_Core_Translation::t("Sign up for an account"));
     $this->setButtons(Horde_Core_Translation::t("Sign up"));
     $this->addHidden('', 'url', 'text', false);
     /* Use hooks get any extra fields required in signing up. */
     try {
         $extra = $GLOBALS['injector']->getInstance('Horde_Core_Hooks')->callHook('signup_getextra', 'horde');
     } catch (Horde_Exception_HookNotSet $e) {
     }
     if (!empty($extra)) {
         if (!isset($extra['user_name'])) {
             $this->addVariable(Horde_Core_Translation::t("Choose a username"), 'user_name', 'text', true);
         }
         if (!isset($extra['password'])) {
             $this->addVariable(Horde_Core_Translation::t("Choose a password"), 'password', 'passwordconfirm', true, false, Horde_Core_Translation::t("Type your password twice to confirm"));
         }
         foreach ($extra as $field_name => $field) {
             $readonly = isset($field['readonly']) ? $field['readonly'] : null;
             $desc = isset($field['desc']) ? $field['desc'] : null;
             $required = isset($field['required']) ? $field['required'] : false;
             $field_params = isset($field['params']) ? $field['params'] : array();
             $this->addVariable($field['label'], 'extra[' . $field_name . ']', $field['type'], $required, $readonly, $desc, $field_params);
         }
     } else {
         $this->addVariable(Horde_Core_Translation::t("Choose a username"), 'user_name', 'text', true);
         $this->addVariable(Horde_Core_Translation::t("Choose a password"), 'password', 'passwordconfirm', true, false, Horde_Core_Translation::t("Type your password twice to confirm"));
     }
 }
Esempio n. 4
0
 /**
  * Variables required in form input:
  *   - imple_submit: vcard action. Contains import and source properties
  *   - mime_id
  *   - muid
  *
  * @return boolean  True on success.
  */
 protected function _handle(Horde_Variables $vars)
 {
     global $registry, $injector, $notification;
     $iCal = new Horde_Icalendar();
     try {
         $contents = $injector->getInstance('IMP_Factory_Contents')->create(new IMP_Indices_Mailbox($vars));
         if (!($mime_part = $contents->getMimePart($vars->mime_id))) {
             throw new IMP_Exception(_("Cannot retrieve vCard data from message."));
         } elseif (!$iCal->parsevCalendar($mime_part->getContents(), 'VCALENDAR', $mime_part->getCharset())) {
             throw new IMP_Exception(_("Error reading the contact data."));
         }
         $components = $iCal->getComponents();
     } catch (Exception $e) {
         $notification->push($e, 'horde.error');
     }
     $import = !empty($vars->imple_submit->import) ? $vars->imple_submit->import : false;
     $source = !empty($vars->imple_submit->source) ? $vars->imple_submit->source : false;
     if ($import && $source && $registry->hasMethod('contacts/import')) {
         $count = 0;
         foreach ($components as $c) {
             if ($c->getType() == 'vcard') {
                 try {
                     $registry->call('contacts/import', array($c, null, $source));
                     ++$count;
                 } catch (Horde_Exception $e) {
                     $notification->push(Horde_Core_Translation::t("There was an error importing the contact data:") . ' ' . $e->getMessage(), 'horde.error');
                 }
             }
         }
         $notification->push(sprintf(Horde_Core_Translation::ngettext("%d contact was successfully added to your address book.", "%d contacts were successfully added to your address book.", $count), $count), 'horde.success');
     }
 }
Esempio n. 5
0
 /**
  * Constructor.
  */
 public function __construct()
 {
     $ob = new Horde_Script_File_JsDir('dialog.js', 'horde');
     $ob->jsvars = array('HordeDialog.cancel_text' => Horde_Core_Translation::t("Cancel"), 'HordeDialog.ok_text' => Horde_Core_Translation::t("OK"));
     $this->_files[] = $ob;
     $this->_files[] = new Horde_Script_File_JsDir('redbox.js', 'horde');
     $this->_files[] = new Horde_Script_File_JsDir('scriptaculous/effects.js', 'horde');
 }
Esempio n. 6
0
    protected function _renderVarInput_tableset($form, &$var, &$vars)
    {
        $header = $var->type->getHeader();
        $name = $var->getVarName();
        $values = $var->getValues();
        $form_name = $form->getName();
        $var_name = $var->getVarName() . '[]';
        $checkedValues = $var->getValue($vars);
        $actions = $this->_getActionScripts($form, $var);
        $function_name = 'select' . $form_name . $var->getVarName();
        $enable = Horde_Core_Translation::t("Select all");
        $disable = Horde_Core_Translation::t("Select none");
        $invert = Horde_Core_Translation::t("Invert selection");
        $page = $GLOBALS['injector']->getInstance('Horde_PageOutput');
        $page->addScriptFile('tables.js', 'horde');
        $page->addInlineScript(sprintf('
function %s()
{
    for (var i = 0; i < document.%s.elements.length; i++) {
        f = document.%s$2.elements[i];
        if (f.name != \'%s$3\') {
            continue;
        }
        if (arguments.length) {
            f.checked = arguments[0];
        } else {
            f.checked = !f.checked;
        }
    }
}', $function_name, $form_name, $var_name));
        $html = <<<EOT
<a href="#" onclick="{$function_name}(true); return false;">{$enable}</a>,
<a href="#" onclick="{$function_name}(false); return false;">{$disable}</a>,
<a href="#" onclick="{$function_name}(); return false;">{$invert}</a>
<table style="width: 100%" class="sortable striped" id="tableset_' . {$name} . '"><thead><tr>
<th>&nbsp;</th>
EOT;
        foreach ($header as $col_title) {
            $html .= sprintf('<th class="leftAlign">%s</th>', $col_title);
        }
        $html .= '</tr></thead>';
        if (!is_array($checkedValues)) {
            $checkedValues = array();
        }
        $i = 0;
        foreach ($values as $value => $displays) {
            $checked = in_array($value, $checkedValues) ? ' checked="checked"' : '';
            $html .= '<tr>' . sprintf('<td style="text-align: center"><input id="%s[]" type="checkbox" name="%s[]" value="%s"%s%s /></td>', $name, $name, $value, $checked, $actions);
            foreach ($displays as $col) {
                $html .= sprintf('<td>&nbsp;%s</td>', $col);
            }
            $html .= '</tr>' . "\n";
            $i++;
        }
        $html .= '</table>' . '<a href="#" onclick="' . $function_name . '(true); return false;">' . $enable . '</a>, ' . '<a href="#" onclick="' . $function_name . '(false); return false;">' . $disable . '</a>, ' . '<a href="#" onclick="' . $function_name . '(); return false;">' . $invert . '</a>';
        return $html;
    }
Esempio n. 7
0
File: Sql.php Progetto: horde/horde
 /**
  * Get a user's queued signup information.
  *
  * @param string $username  The username to retrieve the queued info for.
  *
  * @return Horde_Core_Auth_Signup_SqlObject $signup  The object for the
  *                                                   requested signup.
  * @throws Horde_Exception
  * @throws Horde_Db_Exception
  */
 public function getQueuedSignup($username)
 {
     $query = 'SELECT * FROM ' . $this->_params['table'] . ' WHERE user_name = ?';
     $values = array($username);
     $result = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Db')->create('horde', 'signup')->selectOne($query, $values);
     if (empty($result)) {
         throw new Horde_Exception(sprintf(Horde_Core_Translation::t("User \"%s\" does not exist."), $username));
     }
     $object = new Horde_Core_Auth_Signup_SqlObject($result['user_name']);
     $object->setData($result);
     return $object;
 }
Esempio n. 8
0
 /**
  * Parses a valid email address out of a complete address string.
  *
  * Variables used:
  *   - email: (string) An email address.
  *
  * @return object  Object with the following properties:
  *   - email: (string) The parsed email address.
  *
  * @throws Horde_Exception
  * @throws Horde_Mail_Exception
  */
 public function parseEmailAddress()
 {
     $ob = new Horde_Mail_Rfc822_Address($this->vars->email);
     if (is_null($ob->mailbox)) {
         throw new Horde_Exception(Horde_Core_Translation::t("No valid email address found"));
     }
     if (is_null($ob->host) && !is_null($this->defaultDomain)) {
         $ob->host = $this->defaultDomain;
     }
     $ret = new stdClass();
     $ret->email = $ob->bare_address;
     return $ret;
 }
Esempio n. 9
0
 public function create(Horde_Injector $injector)
 {
     global $conf;
     if (empty($conf['twitter']['key']) || empty($conf['twitter']['secret'])) {
         throw new Horde_Service_Twitter_Exception(Horde_Core_Translation::t("No OAuth Key or Secret found for the Twitter API"));
     }
     /* Keys - these are obtained when registering for the service */
     $consumer_key = $conf['twitter']['key'];
     $consumer_secret = $conf['twitter']['secret'];
     /* Parameters required for the Horde_Oauth_Consumer */
     $params = array('key' => $consumer_key, 'secret' => $consumer_secret, 'requestTokenUrl' => Horde_Service_Twitter::REQUEST_TOKEN_URL, 'authorizeTokenUrl' => Horde_Service_Twitter::USER_AUTHORIZE_URL, 'accessTokenUrl' => Horde_Service_Twitter::ACCESS_TOKEN_URL, 'signatureMethod' => new Horde_Oauth_SignatureMethod_HmacSha1(), 'callbackUrl' => $GLOBALS['registry']->getServiceLink('twitter'));
     /* Create the Consumer */
     $auth = new Horde_Service_Twitter_Auth_Oauth(new Horde_Oauth_Consumer($params));
     $request = new Horde_Service_Twitter_Request_Oauth($injector->getInstance('Horde_Controller_Request'));
     $twitter = new Horde_Service_Twitter($auth, $request);
     //$twitter->setCache($injector->getInstance('Horde_Cache'));
     $twitter->setLogger($injector->getInstance('Horde_Log_Logger'));
     $twitter->setHttpClient($injector->getInstance('Horde_Core_Factory_HttpClient')->create());
     return $twitter;
 }
Esempio n. 10
0
 /**
  * Output the title bar.
  *
  * @param array $params  A list of parameters:
  *   - backlink: (mixed) Show backlink. If an array, first is URL to link
  *               to, second is label. If true, shows a basic Back link.
  *   - logout: (boolean) If true, show logout link.
  *   - portal: (boolean) If true, show portal link.
  *   - taptoggle: (boolean) Enable tap-toggle?
  *   - title: (string) If given, used as the title.
  *
  * @return string  Generated HTML code.
  */
 public function smartmobileHeader(array $params = array())
 {
     global $registry;
     $out = '<div data-position="fixed" data-role="header" data-tap-toggle="' . (empty($params['taptoggle']) ? 'false' : 'true') . '">';
     if (!empty($params['backlink'])) {
         if (is_array($params['backlink'])) {
             $out .= '<a class="smartmobile-back ui-btn-left" href="' . $params['backlink'][0] . '" data-icon="arrow-l" data-direction="reverse">' . $params['backlink'][1] . '</a>';
         } else {
             $out .= '<a class="smartmobile-back ui-btn-left" href="#" ' . 'data-icon="arrow-l" data-rel="back">' . Horde_Core_Translation::t("Back") . '</a>';
         }
     }
     if (!empty($params['portal']) && ($portal = $registry->getServiceLink('portal', 'horde')->setRaw(false))) {
         $out .= '<a class="smartmobile-portal ui-btn-left" ' . 'data-ajax="false" href="' . $portal . '">' . Horde_Core_Translation::t("Applications") . '</a>';
     }
     if (isset($params['title']) && strlen($params['title'])) {
         $out .= '<h1 class="smartmobile-title">' . $params['title'] . '</h1>';
     }
     if (!empty($params['logout']) && $registry->showService('logout') && ($logout = $registry->getServiceLink('logout')->setRaw(false))) {
         $out .= '<a class="smartmobile-logout ui-btn-right" href="' . $logout . '" data-ajax="false" data-theme="e" data-icon="delete">' . Horde_Core_Translation::t("Log out") . '</a>';
     }
     return $out . '</div>';
 }
Esempio n. 11
0
 /**
  */
 protected function _attach($init)
 {
     global $page_output;
     if ($init) {
         $page_output->addScriptFile('scriptaculous/effects.js', 'horde');
         $page_output->addScriptFile('inplaceeditor.js', 'horde');
         $value_url = $this->getImpleUrl()->add(array('id' => $this->_params['dataid'], 'input' => 'value'))->setRaw(true);
         $load_url = $value_url->copy()->add(array('action' => 'load'))->setRaw(true);
         $config = new stdClass();
         $config->config = array('cancelClassName' => '', 'cancelText' => Horde_Core_Translation::t("Cancel"), 'emptyText' => Horde_Core_Translation::t("Click to add caption..."), 'okText' => Horde_Core_Translation::t("Ok"));
         $config->ids = new stdClass();
         $config->ids->{$this->getDomId()} = array('load_url' => (string) $load_url, 'rows' => $this->_params['rows'], 'value_url' => (string) $value_url);
         if (!empty($this->_params['width'])) {
             $config->ids->{$this->getDomId()}['width'] = $this->_params['width'];
         }
         $page_output->addInlineJsVars(array('HordeImple.InPlaceEditor' . $this->getDomId() => $config));
         $page_output->addInlineScript(array('$H(HordeImple.InPlaceEditor' . $this->getDomId() . '.ids).each(function(pair) {
                  new InPlaceEditor(pair.key, pair.value.value_url, Object.extend(HordeImple.InPlaceEditor' . $this->getDomId() . '.config, {
                      htmlResponse: false,
                      callback: function(form, value) {
                          return "value=" + encodeURIComponent(value);
                      },
                      onComplete: function(ipe, opts) {
                         if (opts) {
                             $("' . $this->getDomId() . '").update(opts.responseJSON)
                         }
                          ipe.checkEmpty()
                      },
                      loadTextURL: pair.value.load_url,
                      rows: pair.value.rows,
                      autoWidth: true
                  }));
              })'), true);
     }
     return false;
 }
Esempio n. 12
0
    /**
     * Aborts with a fatal error, displaying debug information to the user.
     *
     * @param mixed $error  Either a string or an object with a getMessage()
     *                      method (e.g. PEAR_Error, Exception).
     */
    public static function fatal($error)
    {
        global $registry;
        if (is_object($error)) {
            switch (get_class($error)) {
                case 'Horde_Exception_AuthenticationFailure':
                    $auth_app = !$registry->clearAuthApp($error->application);
                    if ($auth_app && $registry->isAuthenticated(array('app' => $error->application, 'notransparent' => true))) {
                        break;
                    }
                    try {
                        Horde::log($error, 'NOTICE');
                    } catch (Exception $e) {
                    }
                    if (Horde_Cli::runningFromCLI()) {
                        $cli = new Horde_Cli();
                        $cli->fatal($error);
                    }
                    $params = array();
                    if ($registry->getAuth()) {
                        $params['app'] = $error->application;
                    }
                    switch ($error->getCode()) {
                        case Horde_Auth::REASON_MESSAGE:
                            $params['msg'] = $error->getMessage();
                            $params['reason'] = $error->getCode();
                            break;
                    }
                    $logout_url = $registry->getLogoutUrl($params);
                    /* Clear authentication here. Otherwise, there might be
                     * issues on the login page since we would otherwise need
                     * to do session token checking (which might not be
                     * available, so logout won't happen, etc...) */
                    if ($auth_app && array_key_exists('app', $params)) {
                        $registry->clearAuth();
                    }
                    $logout_url->redirect();
            }
        }
        try {
            Horde::log($error, 'EMERG');
        } catch (Exception $e) {
        }
        try {
            $cli = Horde_Cli::runningFromCLI();
        } catch (Exception $e) {
            die($e);
        }
        if ($cli) {
            $cli = new Horde_Cli();
            $cli->fatal($error);
        }
        if (!headers_sent()) {
            header('Content-type: text/html; charset=UTF-8');
        }
        echo <<<HTML
<html>
<head><title>Horde :: Fatal Error</title></head>
<body style="background:#fff; color:#000">
HTML;
        ob_start();
        try {
            $admin = isset($registry) && $registry->isAdmin();
            echo '<h1>' . Horde_Core_Translation::t("A fatal error has occurred") . '</h1>';
            if (is_object($error) && method_exists($error, 'getMessage')) {
                echo '<h3>' . htmlspecialchars($error->getMessage()) . '</h3>';
            } elseif (is_string($error)) {
                echo '<h3>' . htmlspecialchars($error) . '</h3>';
            }
            if ($admin) {
                $trace = $error instanceof Exception ? $error : debug_backtrace();
                echo '<div id="backtrace"><pre>' . strval(new Horde_Support_Backtrace($trace)) . '</pre></div>';
                if (is_object($error)) {
                    echo '<h3>' . Horde_Core_Translation::t("Details") . '</h3>';
                    echo '<h4>' . Horde_Core_Translation::t("The full error message is logged in Horde's log file, and is shown below only to administrators. Non-administrative users will not see error details.") . '</h4>';
                    ob_flush();
                    flush();
                    echo '<div id="details"><pre>' . htmlspecialchars(print_r($error, true)) . '</pre></div>';
                }
            } else {
                echo '<h3>' . Horde_Core_Translation::t("Details have been logged for the administrator.") . '</h3>';
            }
        } catch (Exception $e) {
            die($e);
        }
        ob_end_flush();
        echo '</body></html>';
        exit(1);
    }
Esempio n. 13
0
 /**
  * Constructor.
  */
 public function __construct()
 {
     $ob = new Horde_Script_File_JsDir('popup.js', 'horde');
     $ob->jsvars = array('HordePopup.popup_block_text' => Horde_Core_Translation::t("A popup window could not be opened. Your browser may be blocking popups."));
     $this->_files[] = $ob;
 }
Esempio n. 14
0
 /**
  * Generates and writes the content of the application's configuration
  * file.
  *
  * @param Horde_Variables $formvars  The processed configuration form
  *                                   data.
  * @param string $php                The content of the generated
  *                                   configuration file.
  *
  * @return boolean  True if the configuration file could be written
  *                  immediately to the file system.
  */
 public function writePHPConfig($formvars, &$php = null)
 {
     $php = $this->generatePHPConfig($formvars);
     $path = $GLOBALS['registry']->get('fileroot', $this->_app) . '/config';
     $configFile = $this->configFile();
     if (file_exists($configFile)) {
         if (@copy($configFile, $path . '/conf.bak.php')) {
             $GLOBALS['notification']->push(sprintf(Horde_Core_Translation::t("Successfully saved the backup configuration file %s."), Horde_Util::realPath($path . '/conf.bak.php')), 'horde.success');
         } else {
             $GLOBALS['notification']->push(sprintf(Horde_Core_Translation::t("Could not save the backup configuration file %s."), Horde_Util::realPath($path . '/conf.bak.php')), 'horde.warning');
         }
     }
     if ($fp = @fopen($configFile, 'w')) {
         /* Can write, so output to file. */
         fwrite($fp, $php);
         fclose($fp);
         $GLOBALS['registry']->rebuild();
         $GLOBALS['notification']->push(sprintf(Horde_Core_Translation::t("Successfully wrote %s"), Horde_Util::realPath($configFile)), 'horde.success');
         return true;
     }
     /* Cannot write. Save to session. */
     $GLOBALS['session']->set('horde', 'config/' . $this->_app, $php);
     return false;
 }
Esempio n. 15
0
 /**
  * Output the page header.
  *
  * @param array $opts  Options:
  *   - body_class: (string)
  *   - body_id: (string)
  *   - html_id: (string)
  *   - smartmobileinit: (string) (@deprecated; use $this->smartmobileInit
  *                      instead)
  *   - stylesheet_opts: (array)
  *   - title: (string)
  *   - view: (integer)
  */
 public function header(array $opts = array())
 {
     global $injector, $language, $registry, $session;
     $view = new Horde_View(array('templatePath' => $registry->get('templates', 'horde') . '/common'));
     $view->outputJs = !$this->deferScripts;
     $view->stylesheetOpts = array();
     $this->_view = empty($opts['view']) ? $registry->hasView($registry->getView()) ? $registry->getView() : Horde_Registry::VIEW_BASIC : $opts['view'];
     if ($session->regenerate_due) {
         $session->regenerate();
     }
     switch ($this->_view) {
         case $registry::VIEW_BASIC:
             $this->_addBasicScripts();
             break;
         case $registry::VIEW_DYNAMIC:
             $this->ajax = true;
             $this->growler = true;
             $this->_addBasicScripts();
             $this->addScriptPackage('Horde_Core_Script_Package_Popup');
             break;
         case $registry::VIEW_MINIMAL:
             $view->stylesheetOpts['subonly'] = true;
             $view->minimalView = true;
             $this->sidebar = $this->topbar = false;
             break;
         case $registry::VIEW_SMARTMOBILE:
             $smobile_files = array($this->debug ? 'jquery.mobile/jquery.js' : 'jquery.mobile/jquery.min.js', 'growler-jquery.js', 'horde-jquery.js', 'smartmobile.js', 'horde-jquery-init.js', $this->debug ? 'jquery.mobile/jquery.mobile.js' : 'jquery.mobile/jquery.mobile.min.js');
             foreach ($smobile_files as $val) {
                 $ob = $this->addScriptFile(new Horde_Script_File_JsFramework($val, 'horde'));
                 $ob->cache = 'package_smartmobile';
             }
             $this->smartmobileInit = array_merge(array('$.mobile.page.prototype.options.backBtnText = "' . Horde_Core_Translation::t("Back") . '";', '$.mobile.dialog.prototype.options.closeBtnText = "' . Horde_Core_Translation::t("Close") . '";', '$.mobile.loader.prototype.options.text = "' . Horde_Core_Translation::t("loading") . '";'), isset($opts['smartmobileinit']) ? $opts['smartmobileinit'] : array(), $this->smartmobileInit);
             $this->addInlineJsVars(array('HordeMobile.conf' => array('ajax_url' => $registry->getServiceLink('ajax', $registry->getApp())->url, 'logout_url' => strval($registry->getServiceLink('logout')), 'sid' => SID, 'token' => $session->getToken())));
             $this->addMetaTag('viewport', 'width=device-width, initial-scale=1', false);
             $view->stylesheetOpts['subonly'] = true;
             $this->addStylesheet($registry->get('jsfs', 'horde') . '/jquery.mobile/jquery.mobile.min.css', $registry->get('jsuri', 'horde') . '/jquery.mobile/jquery.mobile.min.css');
             $view->smartmobileView = true;
             // Force JS to load at top of page, so we don't see flicker when
             // mobile styles are applied.
             $view->outputJs = true;
             $this->sidebar = $this->topbar = false;
             break;
     }
     $view->stylesheetOpts['sub'] = Horde_Themes::viewDir($this->_view);
     if ($this->ajax || $this->growler) {
         $this->addScriptFile(new Horde_Script_File_JsFramework('hordecore.js', 'horde'));
         /* Configuration used in core javascript files. */
         $js_conf = array_filter(array('URI_AJAX' => $registry->getServiceLink('ajax', $registry->getApp())->url, 'URI_DLOAD' => strval($registry->getServiceLink('download', $registry->getApp())), 'URI_LOGOUT' => strval($registry->getServiceLink('logout')), 'URI_SNOOZE' => strval(Horde::url($registry->get('webroot', 'horde') . '/services/snooze.php', true, -1)), 'SID' => SID, 'TOKEN' => $session->getToken(), 'growler_log' => $this->topbar, 'popup_height' => 610, 'popup_width' => 820));
         /* Gettext strings used in core javascript files. */
         $js_text = array('ajax_error' => Horde_Core_Translation::t("Error when communicating with the server."), 'ajax_recover' => Horde_Core_Translation::t("The connection to the server has been restored."), 'ajax_timeout' => Horde_Core_Translation::t("There has been no contact with the server for several minutes. The server may be temporarily unavailable or network problems may be interrupting your session. You will not see any updates until the connection is restored."), 'snooze' => sprintf(Horde_Core_Translation::t("You can snooze it for %s or %s dismiss %s it entirely"), '#{time}', '#{dismiss_start}', '#{dismiss_end}'), 'snooze_select' => array('0' => Horde_Core_Translation::t("Select..."), '5' => Horde_Core_Translation::t("5 minutes"), '15' => Horde_Core_Translation::t("15 minutes"), '60' => Horde_Core_Translation::t("1 hour"), '360' => Horde_Core_Translation::t("6 hours"), '1440' => Horde_Core_Translation::t("1 day")), 'dismissed' => Horde_Core_Translation::t("The alarm was dismissed."));
         if ($this->topbar) {
             $js_text['growlerclear'] = Horde_Core_Translation::t("Clear All");
             $js_text['growlerinfo'] = Horde_Core_Translation::t("This is the notification log.");
             $js_text['growlernoalerts'] = Horde_Core_Translation::t("No Alerts");
         }
         $this->addInlineJsVars(array('HordeCore.conf' => $js_conf, 'HordeCore.text' => $js_text), array('top' => true));
     }
     if ($this->growler) {
         $this->addScriptFile('growler.js', 'horde');
         $this->addScriptFile('scriptaculous/effects.js', 'horde');
         $this->addScriptFile('scriptaculous/sound.js', 'horde');
     }
     if (isset($opts['stylesheet_opts'])) {
         $view->stylesheetOpts = array_merge($view->stylesheetOpts, $opts['stylesheet_opts']);
     }
     $html = '';
     if (isset($language)) {
         $html .= ' lang="' . htmlspecialchars(strtr($language, '_', '-')) . '"';
     }
     if (isset($opts['html_id'])) {
         $html .= ' id="' . htmlspecialchars($opts['html_id']) . '"';
     }
     $view->htmlAttr = $html;
     $body = '';
     if (isset($opts['body_class'])) {
         $body .= ' class="' . htmlspecialchars($opts['body_class']) . '"';
     }
     if (isset($opts['body_id'])) {
         $body .= ' id="' . htmlspecialchars($opts['body_id']) . '"';
     }
     $view->bodyAttr = $body;
     $page_title = $registry->get('name');
     if (isset($opts['title'])) {
         $page_title .= ' :: ' . $opts['title'];
     }
     $view->pageTitle = htmlspecialchars($page_title);
     $view->pageOutput = $this;
     header('Content-type: text/html; charset=UTF-8');
     if (isset($language)) {
         header('Vary: Accept-Language');
     }
     echo $view->render('header');
     if ($this->topbar) {
         echo $injector->getInstance('Horde_View_Topbar')->render();
     }
     // Send what we have currently output so the browser can start
     // loading CSS/JS. See:
     // http://developer.yahoo.com/performance/rules.html#flush
     echo Horde::endBuffer();
     flush();
 }
Esempio n. 16
0
File: View.php Progetto: Gomez/horde
 /**
  * Render the current layout as HTML.
  *
  * @return string  HTML layout.
  */
 public function toHtml()
 {
     global $page_output;
     $tplDir = $GLOBALS['registry']->get('templates', 'horde');
     $interval = $GLOBALS['prefs']->getValue('summary_refresh_time');
     $page_output->ajax = $page_output->growler = true;
     $page_output->addScriptFile('hordeblocks.js', 'horde');
     $html = '<table id="portal" class="nopadding" cellspacing="8" width="100%">';
     $bc = $GLOBALS['injector']->getInstance('Horde_Core_Factory_BlockCollection')->create();
     $covered = array();
     $js = array();
     foreach ($this->_layout as $row_num => $row) {
         $width = floor(100 / count($row));
         $html .= '<tr>';
         foreach ($row as $col_num => $item) {
             if (isset($covered[$row_num]) && isset($covered[$row_num][$col_num])) {
                 continue;
             }
             if (is_array($item)) {
                 $block_id = 'block_' . $row_num . '_' . $col_num;
                 $this->_applications[$item['app']] = $item['app'];
                 $rowspan = $colspan = 1;
                 try {
                     $block = $bc->getBlock($item['app'], $item['params']['type2'], $item['params']['params']);
                     if (!$block->enabled) {
                         throw new Horde_Exception('Block not enabled.');
                     }
                     $rowspan = $item['height'];
                     $colspan = $item['width'];
                     for ($i = 0; $i < $item['height']; $i++) {
                         if (!isset($covered[$row_num + $i])) {
                             $covered[$row_num + $i] = array();
                         }
                         for ($j = 0; $j < $item['width']; $j++) {
                             $covered[$row_num + $i][$col_num + $j] = true;
                         }
                     }
                     if ($block instanceof Horde_Core_Block) {
                         $content = $block->getContent();
                         $header = $block->getTitle();
                         ob_start();
                         include $tplDir . '/portal/block.inc';
                         $html .= ob_get_clean();
                         if ($block->updateable && $GLOBALS['browser']->hasFeature('xmlhttpreq')) {
                             $refresh_time = isset($item['params']['params']['_refresh_time']) ? $item['params']['params']['_refresh_time'] : $interval;
                             if (!empty($refresh_time)) {
                                 $js[] = 'HordeBlocks.addUpdateableBlock(' . '"' . $block->getApp() . '", "' . get_class($block) . '", "' . $block_id . '", ' . intval($refresh_time * 1000) . ')';
                             }
                         }
                     } else {
                         $html .= '<td width="' . $width * $colspan . '%">&nbsp;</td>';
                     }
                 } catch (Horde_Exception $e) {
                     $header = Horde_Core_Translation::t("Error");
                     $content = $e->getMessage();
                     ob_start();
                     include $tplDir . '/portal/block.inc';
                     $html .= ob_get_clean();
                 }
             } else {
                 $html .= '<td width="' . $width . '%">&nbsp;</td>';
             }
         }
         $html .= '</tr>';
     }
     $html .= '</table>';
     $page_output->addInlineScript($js, true);
     return $html;
 }
Esempio n. 17
0
 /**
  * Generates the topbar tree object.
  *
  * @return Horde_Tree_Renderer_Base  The topbar tree object.
  */
 public function getTree()
 {
     if ($this->_generated) {
         return $this->_tree;
     }
     global $injector, $prefs, $registry;
     $current = $registry->getApp();
     $isAdmin = $registry->isAdmin();
     $menu = array();
     foreach ($registry->listApps(array('active', 'admin', 'noadmin', 'heading', 'link', 'notoolbar', 'topbar'), true, null) as $app => $params) {
         /* Check if the current user has permisson to see this application,
          * and if the application is active. Headings are visible to
          * everyone (but get filtered out later if they have no
          * children). Administrators always see all applications except
          * those marked 'inactive'. */
         if ($app != 'horde' && (in_array($params['status'], array('heading', 'link')) || in_array($params['status'], array('active', 'admin', 'noadmin', 'topbar')) && !($isAdmin && $params['status'] == 'noadmin') && $registry->hasPermission(!empty($params['app']) ? $params['app'] : $app, Horde_Perms::SHOW))) {
             $menu[$app] = $params;
         }
     }
     do {
         $children = array();
         foreach ($menu as $params) {
             if (isset($params['menu_parent'])) {
                 $children[$params['menu_parent']] = true;
             }
         }
         $found = false;
         foreach (array_keys($menu) as $key) {
             if ($menu[$key]['status'] == 'heading' && empty($children[$key])) {
                 unset($menu[$key]);
                 $found = true;
             }
         }
     } while ($found);
     /* Add the administration menu if the user is an admin or has any
      * admin permissions. */
     $perms = $injector->getInstance('Horde_Perms');
     $admin_item_count = 0;
     try {
         foreach ($registry->callByPackage('horde', 'admin_list') as $method => $val) {
             if ($isAdmin || $perms->hasPermission('horde:administration:' . $method, $registry->getAuth(), Horde_Perms::SHOW)) {
                 ++$admin_item_count;
                 $menu['administration_' . $method] = array('icon' => $val['icon'], 'menu_parent' => 'administration', 'name' => Horde::stripAccessKey($val['name']), 'status' => 'active', 'url' => Horde::url($registry->applicationWebPath($val['link'], 'horde')));
             }
         }
     } catch (Horde_Exception $e) {
     }
     if ($admin_item_count) {
         $menu['administration'] = array('name' => Horde_Core_Translation::t("Administration"), 'status' => 'heading', 'menu_parent' => 'settings');
     }
     $menu['settings'] = array('class' => 'horde-settings horde-icon-settings', 'name' => '', 'noarrow' => true, 'status' => 'active');
     /* Add preferences. */
     if ($registry->showService('prefs') && !$prefs instanceof Horde_Prefs_Session) {
         $menu['prefs'] = array('icon' => Horde_Themes::img('prefs.png'), 'menu_parent' => 'settings', 'name' => Horde_Core_Translation::t("Preferences"), 'status' => 'active', 'url' => $registry->getServiceLink('prefs', $current));
         /* Get a list of configurable applications. */
         $prefs_apps = $registry->listApps(array('active', 'admin'), true, Horde_Perms::READ);
         if (!empty($prefs_apps['horde'])) {
             $menu['prefs_' . 'horde'] = array('icon' => $registry->get('icon', 'horde'), 'menu_parent' => 'prefs', 'name' => Horde_Core_Translation::t("Global Preferences"), 'status' => 'active', 'url' => $registry->getServiceLink('prefs', 'horde'));
             unset($prefs_apps['horde']);
         }
         uasort($prefs_apps, array($this, '_sortByName'));
         foreach ($prefs_apps as $app => $params) {
             $menu['prefs_' . $app] = array('icon' => $registry->get('icon', $app), 'menu_parent' => 'prefs', 'name' => $params['name'], 'status' => 'active', 'url' => $registry->getServiceLink('prefs', $app));
         }
     }
     /* Add notification log. */
     $menu['growlerlog'] = array('icon' => 'info.png', 'menu_parent' => 'settings', 'name' => Horde_Core_Translation::t("Toggle Alerts Log"), 'status' => 'active', 'url' => 'javascript:void(HordeCore.Growler.toggleLog());');
     /* Add problem link. */
     if ($registry->showService('problem') && ($problem_link = $registry->getServiceLink('problem', $current))) {
         $menu['problem_' . $current] = array('icon' => 'problem.png', 'menu_parent' => 'settings', 'name' => Horde_Core_Translation::t("Problem"), 'status' => 'active', 'url' => $problem_link);
     }
     /* Add help link. */
     if ($registry->showService('help') && ($help_link = $registry->getServiceLink('help', $current))) {
         $menu['help_' . $current] = array('icon' => 'help_index.png', 'menu_parent' => 'settings', 'name' => Horde_Core_Translation::t("Help"), 'onclick' => Horde::popupJs($help_link, array('urlencode' => true)) . 'return false;', 'status' => 'active', 'target' => 'help', 'url' => $help_link);
     }
     foreach ($menu as $app => $params) {
         switch ($params['status']) {
             case 'topbar':
                 try {
                     $registry->callAppMethod($params['app'], 'topbarCreate', array('args' => array($this->_tree, empty($params['menu_parent']) ? null : $params['menu_parent'], isset($params['topbar_params']) ? $params['topbar_params'] : array())));
                 } catch (Horde_Exception_PushApp $e) {
                     // Ignore
                 } catch (Horde_Exception $e) {
                     Horde::log($e, 'ERR');
                 }
                 break;
             default:
                 /* Need to run the name through Horde's gettext since the
                  * user's locale may not have been loaded when registry.php was
                  * parsed, and the translations of the application names are
                  * not in the Core package. */
                 $name = strlen($params['name']) ? _($params['name']) : '';
                 /* Headings have no webroot; they're just containers for other
                  * menu items. */
                 if (isset($params['url'])) {
                     $url = $params['url'];
                 } elseif ($params['status'] == 'heading' || !isset($params['webroot'])) {
                     $url = '';
                 } else {
                     $url = Horde::url($registry->getInitialPage($app), false, array('app' => $app));
                 }
                 $this->_tree->addNode(array('id' => $app, 'parent' => empty($params['menu_parent']) ? null : $params['menu_parent'], 'label' => $name, 'expanded' => false, 'params' => array('icon' => strval(isset($params['icon']) ? $params['icon'] : $registry->get('icon', $app)), 'class' => isset($params['class']) ? $params['class'] : ($app == $current ? 'horde-point-center-active' : 'horde-point-center'), 'noarrow' => !empty($params['noarrow']), 'onclick' => isset($params['onclick']) ? $params['onclick'] : null, 'target' => isset($params['target']) ? $params['target'] : null, 'url' => $url, 'active' => $app == $current)));
         }
     }
     $this->_generated = true;
     return $this->_tree;
 }
Esempio n. 18
0
 /**
  * Return the rendered inline version of the Horde_Mime_Part object.
  *
  * @return array  See parent::render().
  */
 protected function _renderInline()
 {
     $browser = $this->getConfigParam('browser');
     $notification = $this->getConfigParam('notification');
     $prefs = $this->getConfigParam('prefs');
     $registry = $this->getConfigParam('registry');
     $data = $this->_mimepart->getContents();
     $html = '';
     $title = Horde_Core_Translation::t("vCard");
     $iCal = new Horde_Icalendar();
     if (!$iCal->parsevCalendar($data, 'VCALENDAR', $this->_mimepart->getCharset())) {
         $notification->push(Horde_Core_Translation::t("There was an error reading the contact data."), 'horde.error');
     }
     if (Horde_Util::getFormData('import') && Horde_Util::getFormData('source') && $registry->hasMethod('contacts/import')) {
         $source = Horde_Util::getFormData('source');
         $count = 0;
         foreach ($iCal->getComponents() as $c) {
             if ($c->getType() == 'vcard') {
                 try {
                     $registry->call('contacts/import', array($c, null, $source));
                     ++$count;
                 } catch (Horde_Exception $e) {
                     $notification->push(Horde_Core_Translation::t("There was an error importing the contact data:") . ' ' . $e->getMessage(), 'horde.error');
                 }
             }
         }
         $notification->push(sprintf(Horde_Core_Translation::ngettext("%d contact was successfully added to your address book.", "%d contacts were successfully added to your address book.", $count), $count), 'horde.success');
     }
     $html .= '<table class="horde-table" style="width:100%">';
     foreach ($iCal->getComponents() as $i => $vc) {
         if ($i > 0) {
             $html .= '<tr><td colspan="2">&nbsp;</td></tr>';
         }
         $addresses = $vc->getAllAttributes('EMAIL');
         $html .= '<tr><td colspan="2" class="header">';
         if (($fullname = $vc->getAttributeDefault('FN', false)) === false) {
             $fullname = count($addresses) ? $addresses[0]['value'] : Horde_Core_Translation::t("[No Label]");
         }
         $html .= htmlspecialchars($fullname) . '</td></tr>';
         $n = $vc->printableName();
         if (!empty($n)) {
             $html .= $this->_row(Horde_Core_Translation::t("Name"), $n);
         }
         try {
             $html .= $this->_row(Horde_Core_Translation::t("Alias"), implode("\n", $vc->getAttributeValues('ALIAS')));
         } catch (Horde_Icalendar_Exception $e) {
         }
         try {
             $birthdays = $vc->getAttributeValues('BDAY');
             $birthday = new Horde_Date($birthdays[0]);
             $html .= $this->_row(Horde_Core_Translation::t("Birthday"), $birthday->strftime($prefs->getValue('date_format')));
         } catch (Horde_Icalendar_Exception $e) {
         }
         $photos = $vc->getAllAttributes('PHOTO');
         foreach ($photos as $p => $photo) {
             if (isset($photo['params']['VALUE']) && Horde_String::upper($photo['params']['VALUE']) == 'URI') {
                 $html .= $this->_row(Horde_Core_Translation::t("Photo"), '<img src="' . htmlspecialchars($photo['value']) . '" />', false);
             } elseif (isset($photo['params']['ENCODING']) && Horde_String::upper($photo['params']['ENCODING']) == 'B' && isset($photo['params']['TYPE'])) {
                 if ($browser->hasFeature('datauri') === true || $browser->hasFeature('datauri') >= strlen($photo['value'])) {
                     $html .= $this->_row(Horde_Core_Translation::t("Photo"), '<img src="' . Horde_Url_Data::create($photo['params']['TYPE'], base64_decode($photo['value'])) . '" />', false);
                 } elseif ($this->_imageUrl) {
                     $html .= $this->_row(Horde_Core_Translation::t("Photo"), '<img src="' . $this->_imageUrl->add(array('c' => $i, 'p' => $p)) . '" />', false);
                 }
             }
         }
         $labels = $vc->getAllAttributes('LABEL');
         foreach ($labels as $label) {
             if (isset($label['params']['TYPE'])) {
                 if (!is_array($label['params']['TYPE'])) {
                     $label['params']['TYPE'] = array($label['params']['TYPE']);
                 }
             } else {
                 $label['params']['TYPE'] = array_keys($label['params']);
             }
             $types = array();
             foreach ($label['params']['TYPE'] as $type) {
                 switch (Horde_String::upper($type)) {
                     case 'HOME':
                         $types[] = Horde_Core_Translation::t("Home Address");
                         break;
                     case 'WORK':
                         $types[] = Horde_Core_Translation::t("Work Address");
                         break;
                     case 'DOM':
                         $types[] = Horde_Core_Translation::t("Domestic Address");
                         break;
                     case 'INTL':
                         $types[] = Horde_Core_Translation::t("International Address");
                         break;
                     case 'POSTAL':
                         $types[] = Horde_Core_Translation::t("Postal Address");
                         break;
                     case 'PARCEL':
                         $types[] = Horde_Core_Translation::t("Parcel Address");
                         break;
                     case 'PREF':
                         $types[] = Horde_Core_Translation::t("Preferred Address");
                         break;
                 }
             }
             if (!count($types)) {
                 $types = array(Horde_Core_Translation::t("Address"));
             }
             $html .= $this->_row(implode('/', $types), $label['value']);
         }
         $adrs = $vc->getAllAttributes('ADR');
         foreach ($adrs as $item) {
             if (isset($item['params']['TYPE'])) {
                 if (!is_array($item['params']['TYPE'])) {
                     $item['params']['TYPE'] = array($item['params']['TYPE']);
                 }
             } else {
                 $item['params']['TYPE'] = array_keys($item['params']);
             }
             $address = $item['values'];
             $a = array();
             $a_list = array(Horde_Icalendar_Vcard::ADR_STREET, Horde_Icalendar_Vcard::ADR_LOCALITY, Horde_Icalendar_Vcard::ADR_REGION, Horde_Icalendar_Vcard::ADR_POSTCODE, Horde_Icalendar_Vcard::ADR_COUNTRY);
             foreach ($a_list as $val) {
                 if (isset($address[$val])) {
                     $a[] = $address[$val];
                 }
             }
             $types = array();
             foreach ($item['params']['TYPE'] as $type) {
                 switch (Horde_String::upper($type)) {
                     case 'HOME':
                         $types[] = Horde_Core_Translation::t("Home Address");
                         break;
                     case 'WORK':
                         $types[] = Horde_Core_Translation::t("Work Address");
                         break;
                     case 'DOM':
                         $types[] = Horde_Core_Translation::t("Domestic Address");
                         break;
                     case 'INTL':
                         $types[] = Horde_Core_Translation::t("International Address");
                         break;
                     case 'POSTAL':
                         $types[] = Horde_Core_Translation::t("Postal Address");
                         break;
                     case 'PARCEL':
                         $types[] = Horde_Core_Translation::t("Parcel Address");
                         break;
                     case 'PREF':
                         $types[] = Horde_Core_Translation::t("Preferred Address");
                         break;
                 }
             }
             if (!count($types)) {
                 $types = array(Horde_Core_Translation::t("Address"));
             }
             $html .= $this->_row(implode('/', $types), implode("\n", $a));
         }
         $numbers = $vc->getAllAttributes('TEL');
         foreach ($numbers as $number) {
             if (isset($number['params']['TYPE'])) {
                 if (!is_array($number['params']['TYPE'])) {
                     $number['params']['TYPE'] = array($number['params']['TYPE']);
                 }
                 foreach ($number['params']['TYPE'] as $type) {
                     $number['params'][Horde_String::upper($type)] = true;
                 }
             }
             if (isset($number['params']['FAX'])) {
                 $html .= $this->_row(Horde_Core_Translation::t("Fax"), $number['value']);
             } else {
                 if (isset($number['params']['HOME'])) {
                     $html .= $this->_row(Horde_Core_Translation::t("Home Phone"), $number['value']);
                 } elseif (isset($number['params']['WORK'])) {
                     $html .= $this->_row(Horde_Core_Translation::t("Work Phone"), $number['value']);
                 } elseif (isset($number['params']['CELL'])) {
                     $html .= $this->_row(Horde_Core_Translation::t("Cell Phone"), $number['value']);
                 } else {
                     $html .= $this->_row(Horde_Core_Translation::t("Phone"), $number['value']);
                 }
             }
         }
         $emails = array();
         foreach ($addresses as $address) {
             if (isset($address['params']['TYPE'])) {
                 if (!is_array($address['params']['TYPE'])) {
                     $address['params']['TYPE'] = array($address['params']['TYPE']);
                 }
                 foreach ($address['params']['TYPE'] as $type) {
                     $address['params'][Horde_String::upper($type)] = true;
                 }
             }
             $email = '<a href="';
             if ($registry->hasMethod('mail/compose')) {
                 $email .= $registry->call('mail/compose', array(array('to' => $address['value'])));
             } else {
                 $email .= 'mailto:' . htmlspecialchars($address['value']);
             }
             $email .= '">' . htmlspecialchars($address['value']) . '</a>';
             if (isset($address['params']['PREF'])) {
                 array_unshift($emails, $email);
             } else {
                 $emails[] = $email;
             }
         }
         if (count($emails)) {
             $html .= $this->_row(Horde_Core_Translation::t("Email"), implode("\n", $emails), false);
         }
         try {
             $title = $vc->getAttributeValues('TITLE');
             $html .= $this->_row(Horde_Core_Translation::t("Title"), $title[0]);
         } catch (Horde_Icalendar_Exception $e) {
         }
         try {
             $role = $vc->getAttributeValues('ROLE');
             $html .= $this->_row(Horde_Core_Translation::t("Role"), $role[0]);
         } catch (Horde_Icalendar_Exception $e) {
         }
         try {
             $org = $vc->getAttributeValues('ORG');
             $html .= $this->_row(Horde_Core_Translation::t("Company"), $org[0]);
             if (isset($org[1])) {
                 $html .= $this->_row(Horde_Core_Translation::t("Department"), $org[1]);
             }
         } catch (Horde_Icalendar_Exception $e) {
         }
         try {
             $notes = $vc->getAttributeValues('NOTE');
             $html .= $this->_row(Horde_Core_Translation::t("Notes"), $notes[0]);
         } catch (Horde_Icalendar_Exception $e) {
         }
         try {
             $url = $vc->getAttributeValues('URL');
             $html .= $this->_row(Horde_Core_Translation::t("URL"), '<a href="' . htmlspecialchars($url[0]) . '" target="_blank">' . htmlspecialchars($url[0]) . '</a>', false);
         } catch (Horde_Icalendar_Exception $e) {
         }
     }
     $html .= '</table>';
     if ($registry->hasMethod('contacts/import') && $registry->hasMethod('contacts/sources')) {
         $html .= '<div class="horde-form-buttons"><form action="' . Horde::selfUrl() . '" method="get" name="vcard_import" id="vcard_import">' . Horde_Util::formInput();
         foreach ($_GET as $key => $val) {
             $html .= '<input type="hidden" name="' . htmlspecialchars($key) . '" value="' . htmlspecialchars($val) . '" />';
         }
         $sources = $registry->call('contacts/sources', array(true));
         if (count($sources) > 1) {
             $html .= '<input type="submit" class="horde-default" name="import" value="' . Horde_Core_Translation::t("Add to address book:") . '" />' . ' <label for="add_source" class="hidden">' . Horde_Core_Translation::t("Address Book") . '</label>' . '<select id="add_source" name="source">';
             foreach ($sources as $key => $label) {
                 $selected = $key == $prefs->getValue('add_source') ? ' selected="selected"' : '';
                 $html .= '<option value="' . htmlspecialchars($key) . '"' . $selected . '>' . htmlspecialchars($label) . '</option>';
             }
             $html .= '</select>';
         } else {
             reset($sources);
             $html .= '<input type="submit" class="horde-default" name="import" value="' . Horde_Core_Translation::t("Add to my address book") . '" />' . '<input type="hidden" name="source" value="' . htmlspecialchars(key($sources)) . '" />';
         }
         $html .= '</form></div>';
     }
     Horde::startBuffer();
     $notification->notify(array('listeners' => 'status'));
     return $this->_renderReturn(Horde::endBuffer() . $html, 'text/html; charset=' . $this->getConfigParam('charset'));
 }
Esempio n. 19
0
 protected function _buildDummyFolder($id)
 {
     $folder = new Horde_ActiveSync_Message_Folder();
     $folder->parentid = '0';
     switch ($id) {
         case self::SPECIAL_TRASH:
             $folder->type = Horde_ActiveSync::FOLDER_TYPE_WASTEBASKET;
             $folder->serverid = $folder->_serverid = 'Trash';
             $folder->displayname = Horde_Core_Translation::t("Trash");
             break;
         case self::SPECIAL_SENT:
             $folder->type = Horde_ActiveSync::FOLDER_TYPE_SENTMAIL;
             $folder->serverid = $folder->_serverid = 'Sent';
             $folder->displayname = Horde_Core_Translation::t("Sent");
             break;
         case self::SPECIAL_INBOX:
             $folder->type = Horde_ActiveSync::FOLDER_TYPE_INBOX;
             $folder->serverid = $folder->_serverid = 'INBOX';
             $folder->displayname = Horde_Core_Translation::t("Inbox");
             break;
         case self::SPECIAL_DRAFTS:
             $folder->type = Horde_ActiveSync::FOLDER_TYPE_DRAFTS;
             $folder->serverid = $folder->_serverid = 'DRAFTS';
             $folder->displayname = Horde_Core_Translation::t("Drafts");
             break;
         case self::SPECIAL_OUTBOX:
             $folder->type = Horde_ActiveSync::FOLDER_TYPE_OUTBOX;
             $folder->serverid = $folder->_serverid = 'OUTBOX';
             $folder->displayname = Horde_Core_Translation::t("Outbox");
             break;
     }
     return $folder;
 }
Esempio n. 20
0
 /**
  * Returns a hash of user-configurable parameters for the handler.
  *
  * The parameters are hashes with parameter names as keys and parameter
  * information as values. The parameter information is a hash with the
  * following keys:
  *   - desc: a parameter description.
  *   - required: whether this parameter is required.
  *   - type: the parameter type as a preference type.
  *
  * @return array
  */
 public function getParameters()
 {
     return array('sound' => array('type' => 'sound', 'desc' => Horde_Core_Translation::t("Play a sound?"), 'required' => false));
 }
Esempio n. 21
0
File: Base.php Progetto: horde/horde
 /**
  * Perform common presignup actions.
  *
  * @param array $info  Reference to array of parameters.
  *
  * @throws Horde_Exception
  */
 protected function _preSignup(&$info)
 {
     /* @var $auth Horde_Auth_Base */
     /* @var $injector Horde_Injector */
     global $auth, $injector;
     try {
         $info = $injector->getInstance('Horde_Core_Hooks')->callHook('signup_preprocess', 'horde', array($info));
     } catch (Horde_Exception_HookNotSet $e) {
     }
     // Check to see if the username already exists in the auth backend or
     // the signup queue.
     if ($auth->exists($info['user_name']) || $this->exists($info['user_name'])) {
         throw new Horde_Exception(sprintf(Horde_Core_Translation::t("Username \"%s\" already exists."), $info['user_name']));
     }
 }
Esempio n. 22
0
 /**
  * Return the body of the replied message in the appropriate type.
  *
  * @param array $body_data         The body data array of the source msg.
  * @param Horde_Mime_Part $partId  The body part of the email to send.
  * @param boolean $html            Is this an html part?
  *
  * @return string  The propertly formatted replied body text.
  */
 protected function _replyText(array $body_data, Horde_Mime_Part $part, $html = false)
 {
     $msg = $this->_msgBody($body_data, $part, $html, true);
     if (!empty($msg) && $html) {
         return self::HTML_BLOCKQUOTE . $msg . '</blockquote><br /><br />';
     }
     return empty($msg) ? '[' . Horde_Core_Translation::t("No message body text") . ']' : $msg;
 }
Esempio n. 23
0
File: Ui.php Progetto: horde/horde
 /**
  * Function to validate any delete form input.
  *
  * @param TODO $info  TODO
  *
  * @return mixed  If the delete button confirmation has been pressed return
  *                true, if any other submit button has been pressed return
  *                false. If form did not validate return null.
  */
 public function validateDeleteForm(&$info)
 {
     $form_submit = $this->_vars->get('submitbutton');
     if ($form_submit == Horde_Core_Translation::t("Delete")) {
         if ($this->_form->validate($this->_vars)) {
             $this->_form->getInfo($this->_vars, $info);
             return true;
         }
     } elseif (!empty($form_submit)) {
         return false;
     }
     return null;
 }
Esempio n. 24
0
 /**
  * Add HTML code at the beginning of a large block of quoted lines.
  *
  * @param array $lines     Lines.
  * @param integer $qcount  Number of lines in quoted level.
  *
  * @return string  HTML code.
  */
 protected function _beginLargeBlock($lines, $qcount)
 {
     return ($this->_params['citeblock'] ? '<br />' : '') . '<div class="toggleQuoteParent">' . '<span class="widget toggleQuoteShow"' . ($this->_params['hideBlocks'] ? '' : ' style="display:none"') . '>' . htmlspecialchars(sprintf(Horde_Core_Translation::t("[Show Quoted Text - %d lines]"), $qcount)) . '</span>' . '<span class="widget toggleQuoteHide"' . ($this->_params['hideBlocks'] ? ' style="display:none"' : '') . '>' . htmlspecialchars(Horde_Core_Translation::t("[Hide Quoted Text]")) . '</span>';
 }
Esempio n. 25
0
 /**
  * Generates the HTML link that will pop up a help window for the
  * requested topic.
  *
  * @param string $module  The name of the current Horde module.
  * @param string $topic   The help topic to be displayed.
  *
  * @return string  The HTML to create the help link.
  */
 public static function link($module, $topic)
 {
     if (!$GLOBALS['registry']->showService('help')) {
         return '';
     }
     $url = $GLOBALS['registry']->getServiceLink('help', $module)->add('topic', $topic);
     return $url->link(array('title' => Horde_Core_Translation::t("Help"), 'class' => 'helplink', 'target' => 'hordehelpwin', 'onclick' => Horde::popupJs($url, array('urlencode' => true)) . 'return false;')) . Horde_Themes_Image::tag('help.png', array('alt' => Horde_Core_Translation::t("Help"))) . '</a>';
 }
Esempio n. 26
0
 /**
  * Given a permission name, returns the title for that permission by
  * looking it up in the applications's permission api.
  *
  * @param string $name  The permissions's name.
  *
  * @return string  The title for the permission.
  */
 public function getTitle($name)
 {
     if ($name === Horde_Perms::ROOT) {
         return Horde_Core_Translation::t("All Permissions");
     }
     $levels = explode(':', $name);
     if (count($levels) == 1) {
         return $this->_registry->get('name', $name) . ' (' . $name . ')';
     }
     array_pop($levels);
     // This is the permission name
     /* First level is always app. */
     $app = $levels[0];
     $app_perms = $this->getApplicationPermissions($app);
     return isset($app_perms['title'][$name]) ? $app_perms['title'][$name] . ' (' . $this->_perms->getShortName($name) . ')' : $this->_perms->getShortName($name);
 }
Esempio n. 27
0
 /**
  * Set vacation message properties.
  *
  * @param array $setting  The vacation details.
  *
  * @throws Horde_Exception
  */
 public function filters_setVacation(array $setting)
 {
     if (!$this->horde_hasInterface('filter')) {
         throw new Horde_Exception('Filter interface unavailable.');
     }
     if ($setting['oofstate'] != Horde_ActiveSync_Request_Settings::OOF_STATE_DISABLED) {
         // Currently the filter/ API only supports a single configuration.
         // So, first check "external" rules and if none found, send the
         // internal rules.
         foreach ($setting['oofmsgs'] as $msg) {
             if ($msg['appliesto'] == Horde_ActiveSync_Request_Settings::SETTINGS_APPLIESTOEXTERNALKNOWN || $msg['appliesto'] == Horde_ActiveSync_Request_Settings::SETTINGS_APPLIESTOEXTERNALUNKNOWN) {
                 $vacation = array('reason' => $msg['replymessage'], 'subject' => Horde_Core_Translation::t('Out Of Office'));
                 break;
             }
             if ($msg['appliesto'] == Horde_ActiveSync_Request_Settings::SETTINGS_APPLIESTOINTERNAL) {
                 $vacation = array('reason' => $msg['replymessage'], 'subject' => Horde_Core_Translation::t('Out Of Office'));
             }
         }
         if (!empty($setting['starttime'])) {
             $vacation['start'] = $setting['starttime']->timestamp();
         }
         if (!empty($setting['endtime'])) {
             $vacation['end'] = $setting['endtime']->timestamp();
         }
         $this->_registry->filter->setVacation($vacation);
     } else {
         $this->_registry->filter->disableVacation();
     }
 }
Esempio n. 28
0
 /**
  * Set vacation message properties.
  *
  * @param array $setting  The vacation details.
  *
  * @throws Horde_Exception
  */
 public function filters_setVacation(array $setting)
 {
     if (!$this->horde_hasInterface('filter')) {
         throw new Horde_Exception('Filter interface unavailable.');
     }
     if ($setting['oofstate'] == Horde_ActiveSync_Request_Settings::OOF_STATE_ENABLED) {
         // Only support a single message, the APPLIESTOINTERNAL message.
         foreach ($setting['oofmsgs'] as $msg) {
             if ($msg['appliesto'] == Horde_ActiveSync_Request_Settings::SETTINGS_APPLIESTOINTERNAL) {
                 $vacation = array('reason' => $msg['replymessage'], 'subject' => Horde_Core_Translation::t('Out Of Office'));
                 $this->_registry->filter->setVacation($vacation);
                 return;
             }
         }
     } else {
         $this->_registry->filter->disableVacation();
     }
 }
Esempio n. 29
0
 /**
  * Sets the default global view mode in the horde session. This can be
  * checked by applications, and overridden if desired. Also sets a cookie
  * to remember the last view selection if applicable.
  */
 protected function _setView()
 {
     global $conf, $browser, $notification, $registry;
     $mode = $this->_view;
     if (empty($conf['user']['force_view'])) {
         if (empty($conf['user']['select_view'])) {
             $mode = 'auto';
         } else {
             /* 'auto' is default, so don't store in cookie. */
             setcookie('default_horde_view', $mode == 'auto' ? '' : $mode, time() + ($mode == 'auto' ? -3600 : 30 * 86400), $conf['cookie']['path'], $conf['cookie']['domain']);
         }
     } else {
         // Forcing mode as per config.
         $mode = $conf['user']['force_view'];
     }
     /* $mode now contains the user's preference for view based on the
      * login screen parameters and configuration. */
     switch ($mode) {
         case 'auto':
             if ($browser->hasFeature('ajax')) {
                 $mode = $browser->isMobile() ? 'smartmobile' : 'dynamic';
             } else {
                 $mode = $browser->isMobile() ? 'mobile' : 'basic';
             }
             break;
         case 'basic':
             if (!$browser->hasFeature('javascript')) {
                 $notification->push(Horde_Core_Translation::t("Your browser does not support javascript. Using minimal view instead."), 'horde.warning');
                 $mode = 'mobile';
             }
             break;
         case 'dynamic':
             if (!$browser->hasFeature('ajax')) {
                 if ($browser->hasFeature('javascript')) {
                     $notification->push(Horde_Core_Translation::t("Your browser does not support the dynamic view. Using basic view instead."), 'horde.warning');
                     $mode = 'basic';
                 } else {
                     $notification->push(Horde_Core_Translation::t("Your browser does not support the dynamic view. Using minimal view instead."), 'horde.warning');
                     $mode = 'mobile';
                 }
             }
             break;
         case 'smartmobile':
             if (!$browser->hasFeature('ajax')) {
                 $notification->push(Horde_Core_Translation::t("Your browser does not support the dynamic view. Using minimal view instead."), 'horde.warning');
                 $mode = 'mobile';
             }
             break;
         case 'mobile':
         default:
             $mode = 'mobile';
             break;
     }
     if ($browser->getBrowser() == 'msie' && $browser->getMajor() < 8 && $mode != 'mobile') {
         $notification->push(Horde_Core_Translation::t("You are using an old, unsupported version of Internet Explorer. You need at least Internet Explorer 8. If you already run IE8 or higher, disable the Compatibility View. Minimal view will be used until you upgrade your browser."));
         $mode = 'mobile';
     }
     $registry_map = array('basic' => Horde_Registry::VIEW_BASIC, 'dynamic' => Horde_Registry::VIEW_DYNAMIC, 'mobile' => Horde_Registry::VIEW_MINIMAL, 'smartmobile' => Horde_Registry::VIEW_SMARTMOBILE);
     $this->_view = $mode;
     $registry->setView($registry_map[$mode]);
 }
Esempio n. 30
0
 /**
  * Removes user's application data.
  *
  * @param string $user  The user ID to delete.
  * @param string $app   If set, only removes data from this application.
  *                      By default, removes data from all apps.
  *
  * @throws Horde_Exception
  */
 public function removeUserData($user, $app = null)
 {
     if (!$this->isAdmin() && $user != $this->getAuth()) {
         throw new Horde_Exception(Horde_Core_Translation::t("You are not allowed to remove user data."));
     }
     $applist = empty($app) ? $this->listApps(array('notoolbar', 'hidden', 'active', 'admin', 'noadmin')) : array($app);
     $errApps = array();
     if (!empty($applist)) {
         $prefs_ob = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Prefs')->create('horde', array('user' => $user));
         // Remove all preference at once, if possible.
         if (empty($app)) {
             try {
                 $prefs_ob->removeAll();
             } catch (Horde_Exception $e) {
                 Horde::log($e);
             }
         }
     }
     foreach ($applist as $item) {
         try {
             $this->callAppMethod($item, 'removeUserData', array('args' => array($user)));
         } catch (Exception $e) {
             Horde::log($e);
             $errApps[] = $item;
         }
         if (empty($app)) {
             continue;
         }
         try {
             $prefs_ob->retrieve($item);
             $prefs_ob->remove();
         } catch (Horde_Exception $e) {
             Horde::log($e);
             $errApps[] = $item;
         }
     }
     if (count($errApps)) {
         throw new Horde_Exception(sprintf(Horde_Core_Translation::t("The following applications encountered errors removing user data: %s"), implode(', ', array_unique($errApps))));
     }
 }