Author: Chuck Hagenbuch (chuck@horde.org)
Author: Jon Parise (jon@horde.org)
Example #1
0
 /**
  */
 protected function _handle(Horde_Variables $vars)
 {
     global $injector, $prefs;
     $faces = $injector->getInstance('Ansel_Faces');
     $image_id = intval($vars->image_id);
     $results = $faces->getImageFacesData($image_id);
     // Attempt to get faces from the picture if we don't already have
     // results, or if we were asked to explicitly try again.
     if (empty($results)) {
         $image = $injector->getInstance('Ansel_Storage')->getImage($image_id);
         $image->createView('screen', null, $prefs->getValue('watermark_auto') ? $prefs->getValue('watermark_text', '') : '');
         $results = $faces->getFromPicture($image_id, true);
     }
     if (empty($results)) {
         $results = new stdClass();
         $results->response = _("No faces found");
         return new Horde_Core_Ajax_Response($results);
     }
     $customurl = Horde::url('faces/custom.php');
     Horde::startBuffer();
     include ANSEL_TEMPLATES . '/faces/image.inc';
     $response = new stdClass();
     $response->response = Horde::endBuffer();
     return new Horde_Core_Ajax_Response($response);
 }
Example #2
0
 /**
  */
 protected function _attach($init)
 {
     global $page_output;
     if ($init) {
         $page_output->addScriptPackage('Horde_Core_Script_Package_Dialog');
         $page_output->addScriptFile('passphrase.js', 'imp');
     }
     $params = isset($this->_params['params']) ? $this->_params['params'] : array();
     if (isset($params['reload'])) {
         $params['reload'] = strval($params['reload']);
     }
     switch ($this->_params['type']) {
         case 'pgpPersonal':
             $text = _("Enter your personal PGP passphrase.");
             break;
         case 'pgpSymmetric':
             $text = _("Enter the passphrase used to encrypt this message.");
             break;
         case 'smimePersonal':
             $text = _("Enter your personal S/MIME passphrase.");
             break;
     }
     $js_params = array('hidden' => array_merge($params, array('type' => $this->_params['type'])), 'text' => $text);
     $js = 'ImpPassphraseDialog.display(' . Horde::escapeJson($js_params, array('nodelimit' => true)) . ')';
     if (!empty($this->_params['onload'])) {
         $page_output->addInlineScript(array($js), true);
         return false;
     }
     return $js;
 }
Example #3
0
 /**
  */
 protected function _content()
 {
     if (!isset($this->_params['forum_id'])) {
         throw new Horde_Exception(_("No forum selected"));
     }
     if (empty($this->_threads)) {
         $this->_threads = $GLOBALS['injector']->getInstance('Agora_Factory_Driver')->create('agora', $this->_params['forum_id']);
         if ($this->_threads instanceof PEAR_Error) {
             throw new Horde_Exception(_("Unable to fetch threads for selected forum."));
         }
     }
     /* Get the sorting. */
     $sort_by = Agora::getSortBy('threads');
     $sort_dir = Agora::getSortDir('threads');
     /* Get a list of threads and display only the most recent if
      * preference is set. */
     $threads_list = $this->_threads->getThreads(0, false, $sort_by, $sort_dir, false, Horde::selfUrl(), null, 0, !empty($this->_params['thread_display']) ? $this->_params['thread_display'] : null);
     /* Show a message if no available threads. Don't raise an error
      * as it is not an error to have no threads. */
     if (empty($threads_list)) {
         return _("No available threads.");
     }
     /* Set up the column headers. */
     $col_headers = array('message_subject' => _("Subject"), 'message_author' => _("Posted by"), 'message_timestamp' => _("Date"));
     $col_headers = Agora::formatColumnHeaders($col_headers, $sort_by, $sort_dir, 'threads');
     /* Set up the template tags. */
     $view = new Agora_View();
     $view->col_headers = $col_headers;
     $view->threads = $threads_list;
     return $view->render('block/threads');
 }
Example #4
0
 /**
  */
 public function display(Horde_Core_Prefs_Ui $ui)
 {
     global $injector, $page_output, $prefs, $session;
     $page_output->addScriptPackage('IMP_Script_Package_Imp');
     $imp_pgp = $injector->getInstance('IMP_Crypt_Pgp');
     /* Get list of Public Keys on keyring. */
     try {
         $pubkey_list = $imp_pgp->listPublicKeys();
     } catch (Horde_Exception $e) {
         $pubkey_list = array();
     }
     $pgp_url = IMP_Basic_Pgp::url();
     $view = new Horde_View(array('templatePath' => IMP_TEMPLATES . '/prefs'));
     $view->addHelper('Horde_Core_View_Helper_Help');
     $view->addHelper('Text');
     if (!empty($pubkey_list)) {
         $plist = array();
         $self_url = $ui->selfUrl(array('special' => true, 'token' => true));
         foreach ($pubkey_list as $val) {
             $plist[] = array('name' => $val['name'], 'email' => $val['email'], 'view' => Horde::link($pgp_url->copy()->add(array('actionID' => 'view_public_key', 'email' => $val['email'])), sprintf(_("View %s Public Key"), $val['name']), null, 'view_key'), 'info' => Horde::link($pgp_url->copy()->add(array('actionID' => 'info_public_key', 'email' => $val['email'])), sprintf(_("Information on %s Public Key"), $val['name']), null, 'info_key'), 'delete' => Horde::link($self_url->copy()->add(array('delete_pgp_pubkey' => 1, 'email' => $val['email'])), sprintf(_("Delete %s Public Key"), $val['name']), null, null, "window.confirm('" . addslashes(_("Are you sure you want to delete this public key?")) . "')"));
         }
         $view->pubkey_list = $plist;
     }
     if ($session->get('imp', 'file_upload')) {
         $view->can_import = true;
         $view->no_source = !$prefs->getValue('add_source');
         if (!$view->no_source) {
             $page_output->addInlineScript(array('$("import_pgp_public").observe("click", function(e) { ' . Horde::popupJs($pgp_url, array('params' => array('actionID' => 'import_public_key', 'reload' => base64_encode($ui->selfUrl()->setRaw(true))), 'height' => 275, 'width' => 750, 'urlencode' => true)) . '; e.stop(); })'), true);
         }
     }
     return $view->render('pgppublickey');
 }
Example #5
0
 /**
  * Constructor.
  *
  * @param array $config  Configuration key-value pairs.
  */
 public function __construct($config = array())
 {
     global $prefs, $registry;
     parent::__construct($config);
     $blank = new Horde_Url();
     $this->addNewButton(_("_New Event"), $blank, array('id' => 'kronolithNewEvent'));
     $this->newExtra = $blank->link(array_merge(array('id' => 'kronolithQuickEvent'), Horde::getAccessKeyAndTitle(_("Quick _insert"), false, true)));
     $sidebar = $GLOBALS['injector']->createInstance('Horde_View');
     /* Minical. */
     $today = new Horde_Date($_SERVER['REQUEST_TIME']);
     $sidebar->today = $today->format('F Y');
     $sidebar->weekdays = array();
     for ($i = $prefs->getValue('week_start_monday'), $c = $i + 7; $i < $c; $i++) {
         $weekday = Horde_Nls::getLangInfo(constant('DAY_' . ($i % 7 + 1)));
         $sidebar->weekdays[$weekday] = Horde_String::substr($weekday, 0, 2);
     }
     /* Calendars. */
     $sidebar->newShares = $registry->getAuth() && !$prefs->isLocked('default_share');
     $sidebar->admin = $registry->isAdmin();
     $sidebar->resourceAdmin = $registry->isAdmin() || $GLOBALS['injector']->getInstance('Horde_Core_Perms')->hasAppPermission('resource_management');
     $sidebar->resources = $GLOBALS['conf']['resources']['enabled'];
     $sidebar->addRemote = !$prefs->isLocked('remote_cals');
     $remotes = unserialize($prefs->getValue('remote_cals'));
     $sidebar->showRemote = !($prefs->isLocked('remote_cals') && empty($remotes));
     $this->content = $sidebar->render('dynamic/sidebar');
 }
Example #6
0
 /**
  */
 protected function _content()
 {
     try {
         $channels = $GLOBALS['injector']->getInstance('Jonah_Driver')->getChannels();
     } catch (Jonah_Exception $e) {
         $channels = array();
     }
     $html = '';
     foreach ($channels as $key => $channel) {
         /* Link for HTML delivery. */
         $url = Horde::url('delivery/html.php')->add('channel_id', $channel['channel_id']);
         $label = sprintf(_("\"%s\" stories in HTML"), $channel['channel_name']);
         $html .= '<tr><td width="140">' . Horde::img('story_marker.png') . ' ' . $url->link(array('title' => $label)) . htmlspecialchars($channel['channel_name']) . '</a></td>';
         $html .= '<td>' . ($channel['channel_updated'] ? date('M d, Y H:i', (int) $channel['channel_updated']) : '-') . '</td>';
         /* Link for feed delivery. */
         $url = Horde::url('delivery/rss.php', true, -1)->add('channel_id', $channel['channel_id']);
         $label = sprintf(_("RSS Feed of \"%s\""), $channel['channel_name']);
         $html .= '<td align="right" class="nowrap">' . $url->link(array('title' => $label)) . Horde::img('feed.png') . '</a> ';
     }
     if ($html) {
         return '<table cellspacing="0" width="100%" class="linedRow striped">' . $html . '</table>';
     } else {
         return '<p><em>' . _("No feeds are available.") . '</em></p>';
     }
 }
Example #7
0
 /**
  * @throws Kronolith_Exception
  */
 public function execute()
 {
     if ($this->_vars->get('submitbutton') == _("Cancel")) {
         Horde::url($GLOBALS['prefs']->getValue('defaultview') . '.php', true)->redirect();
     }
     Kronolith::deleteShare($this->_calendar);
 }
Example #8
0
 /**
  * Return a Horde_Alarm instance.
  *
  * @return Horde_Alarm
  * @throws Horde_Exception
  */
 public function create()
 {
     global $conf;
     if (isset($this->_alarm)) {
         return $this->_alarm;
     }
     $driver = empty($conf['alarms']['driver']) ? 'null' : $conf['alarms']['driver'];
     $params = Horde::getDriverConfig('alarms', $driver);
     switch (Horde_String::lower($driver)) {
         case 'sql':
             $params['db'] = $this->_injector->getInstance('Horde_Core_Factory_Db')->create('horde', 'alarms');
             break;
     }
     $params['logger'] = $this->_injector->getInstance('Horde_Log_Logger');
     $params['loader'] = array($this, 'load');
     $this->_ttl = isset($params['ttl']) ? $params['ttl'] : 300;
     $class = $this->_getDriverName($driver, 'Horde_Alarm');
     $this->_alarm = new $class($params);
     $this->_alarm->initialize();
     $this->_alarm->gc();
     /* Add those handlers that need configuration and can't be auto-loaded
      * through Horde_Alarms::handlers(). */
     $this->_alarm->addHandler('notify', new Horde_Core_Alarm_Handler_Notify());
     $this->_alarm->addHandler('desktop', new Horde_Core_Alarm_Handler_Desktop(array('icon' => new Horde_Core_Alarm_Handler_Desktop_Icon('alerts/alarm.png'), 'js_notify' => array($this->_injector->getInstance('Horde_PageOutput'), 'addInlineScript'))));
     $this->_alarm->addHandler('mail', new Horde_Alarm_Handler_Mail(array('identity' => $this->_injector->getInstance('Horde_Core_Factory_Identity'), 'mail' => $this->_injector->getInstance('Horde_Mail'))));
     return $this->_alarm;
 }
Example #9
0
 /**
  * Return the Agora_Driver:: instance.
  *
  * @param string $scope  Instance scope
  * @param int $forum_id  Forum to link to
  *
  * @return Agora_Driver  The singleton instance.
  * @throws Agora_Exception
  */
 public function create($scope = 'agora', $forum_id = 0)
 {
     if (!isset($this->_instances[$scope])) {
         $driver = $GLOBALS['conf']['threads']['split'] ? 'SplitSql' : 'Sql';
         $params = Horde::getDriverConfig('sql');
         $class = 'Agora_Driver_' . $driver;
         if (!class_exists($class)) {
             throw new Agora_Exception(sprintf('Unable to load the definition of %s.', $class));
         }
         $params = array('db' => $this->_injector->getInstance('Horde_Db_Adapter'), 'charset' => $params['charset']);
         $driver = new $class($scope, $params);
         $this->_instances[$scope] = $driver;
     }
     if ($forum_id) {
         /* Check if there was a valid forum object to get. */
         try {
             $forum = $this->_instances[$scope]->getForum($forum_id);
         } catch (Horde_Exception $e) {
             throw new Agora_Exception($e->getMessage());
         }
         /* Set current forum id and forum data */
         $this->_instances[$scope]->_forum = $forum;
         $this->_instances[$scope]->_forum_id = (int) $forum_id;
     }
     return $this->_instances[$scope];
 }
Example #10
0
 /**
  * AJAX action: Check passphrase.
  *
  * Variables required in form input:
  *   - dialog_input: (string) Input from the dialog screen.
  *   - reload: (mixed) If set, reloads page instead of returning data.
  *   - symmetricid: (string) The symmetric ID to process.
  *   - type: (string) The passphrase type.
  *
  * @return boolean  True on success.
  */
 public function checkPassphrase()
 {
     global $injector, $notification;
     $result = false;
     if (!$this->vars->dialog_input) {
         $notification->push(_("No passphrase entered."), 'horde.error');
         return $result;
     }
     try {
         Horde::requireSecureConnection();
         switch ($this->vars->type) {
             case 'pgpPersonal':
                 $result = $injector->getInstance('IMP_Pgp')->storePassphrase('personal', $this->vars->dialog_input);
                 break;
             case 'pgpSymmetric':
                 $result = $injector->getInstance('IMP_Pgp')->storePassphrase('symmetric', $this->vars->dialog_input, $this->vars->symmetricid);
                 break;
             case 'smimePersonal':
                 $result = $injector->getInstance('IMP_Smime')->storePassphrase($this->vars->dialog_input, $this->vars->secondary);
                 break;
         }
         if ($result) {
             $notification->push(_("Passphrase verified."), 'horde.success');
         } else {
             $notification->push(_("Invalid passphrase entered."), 'horde.error');
         }
     } catch (Horde_Exception $e) {
         $notification->push($e, 'horde.error');
     }
     return $result && $this->vars->reload ? new Horde_Core_Ajax_Response_HordeCore_Reload($this->vars->reload) : $result;
 }
Example #11
0
 public static function bookmarkletLink()
 {
     $view = $GLOBALS['injector']->createInstance('Horde_View');
     $view->url = Horde::url('add.php', true, array('append_session' => -1))->add('popup', 1);
     $view->image = Horde::img('add.png');
     return $view->render('bookmarklet');
 }
Example #12
0
 public function execute()
 {
     parent::execute();
     $this->getInfo($this->_vars, $info);
     $next_page = Horde::url('edit.php', true)->add(array('source' => $info['source'], 'original_source' => $info['original_source'], 'objectkeys' => $info['objectkeys'], 'url' => $info['url'], 'actionID' => 'groupedit'));
     $objectkey = array_search($info['source'] . ':' . $info['key'], $info['objectkeys']);
     $submitbutton = $this->_vars->get('submitbutton');
     if ($submitbutton == _("Finish")) {
         $next_page = Horde::url('browse.php', true);
         if ($info['original_source'] == '**search') {
             $next_page->add('key', $info['original_source']);
         } else {
             $next_page->add('source', $info['original_source']);
         }
     } elseif ($submitbutton == _("Previous") && $info['source'] . ':' . $info['key'] != $info['objectkeys'][0]) {
         /* Previous contact */
         list(, $previous_key) = explode(':', $info['objectkeys'][$objectkey - 1]);
         $next_page->add('key', $previous_key);
         if ($this->getOpenSection()) {
             $next_page->add('__formOpenSection', $this->getOpenSection());
         }
     } elseif ($submitbutton == _("Next") && $info['source'] . ':' . $info['key'] != $info['objectkeys'][count($info['objectkeys']) - 1]) {
         /* Next contact */
         list(, $next_key) = explode(':', $info['objectkeys'][$objectkey + 1]);
         $next_page->add('key', $next_key);
         if ($this->getOpenSection()) {
             $next_page->add('__formOpenSection', $this->getOpenSection());
         }
     }
     $next_page->redirect();
 }
Example #13
0
 /**
  */
 public function gc()
 {
     global $registry;
     if (empty($this->_params['lifetime'])) {
         return;
     }
     /* Keep a file in the static directory that prevents us from doing
      * garbage collection more than once a day. */
     $curr_time = time();
     $static_dir = $registry->get('fileroot', 'horde') . '/static';
     $static_stat = $static_dir . '/gc_cachecss';
     $next_run = !is_readable($static_stat) ?: @file_get_contents($static_stat);
     if (!$next_run || $curr_time > $next_run) {
         file_put_contents($static_stat, $curr_time + 86400);
     }
     if (!$next_run || $curr_time < $next_run) {
         return;
     }
     $curr_time -= $this->_params['lifetime'];
     $removed = 0;
     foreach (glob($static_dir . '/*.css') as $file) {
         if ($curr_time > filemtime($file)) {
             @unlink($file);
             ++$removed;
         }
     }
     Horde::log(sprintf('Cleaned out static CSS files (removed %d file(s)).', $removed), 'DEBUG');
 }
Example #14
0
 /**
  */
 protected function _content()
 {
     /* Return empty if we don't have a thread set. */
     if (empty($this->_params['thread_id'])) {
         return '';
     }
     /* Set up the message object. */
     list($forum_id, $message_id) = explode('.', $this->_params['thread_id']);
     $messages = $GLOBALS['injector']->getInstance('Agora_Factory_Driver')->create('agora', $forum_id);
     /* Check if valid thread, otherwise show forum list. */
     if ($messages instanceof PEAR_Error || empty($messages)) {
         throw new Horde_Exception(_("Unable to fetch selected thread."));
     }
     /* Get the sorting. */
     $sort_by = Agora::getSortBy('threads');
     $sort_dir = Agora::getSortDir('threads');
     $view_bodies = $GLOBALS['prefs']->getValue('thread_view_bodies');
     /* Get the message array and the sorted thread list. */
     $threads_list = $messages->getThreads($messages->getThreadRoot($message_id), true, $sort_by, $sort_dir, $view_bodies, Horde::selfUrl());
     /* Set up the column headers. */
     $col_headers = array(array('message_thread' => _("Thread"), 'message_subject' => _("Subject")), 'message_author' => _("Posted by"), 'message_timestamp' => _("Date"));
     $col_headers = Agora::formatColumnHeaders($col_headers, $sort_by, $sort_dir, 'threads');
     /* Set up the template tags. */
     $view = new Agora_View();
     $view->col_headers = $col_headers;
     $view->threads_list = $threads_list;
     $view->threads_list_header = _("Thread List");
     $view->thread_view_bodies = $view_bodies;
     return $view->render('block/thread');
 }
Example #15
0
 /**
  */
 public function status()
 {
     global $notification;
     Horde::startBuffer();
     $notification->notify(array('listeners' => array('status', 'audio')));
     return Horde::endBuffer();
 }
Example #16
0
 /**
  * Returns the spellchecker instance.
  *
  * @param array $args    Configuration arguments to override the
  *                       defaults.
  * @param string $input  Input text.  If set, allows language detection
  *                       if not automatically set.
  *
  * @return Horde_SpellChecker  The spellchecker instance.
  * @throws Horde_Exception
  */
 public function create(array $args = array(), $input = null)
 {
     global $conf, $language, $registry;
     if (empty($conf['spell']['driver'])) {
         throw new Horde_Exception('No spellcheck driver configured.');
     }
     $args = array_merge(array('localDict' => array()), Horde::getDriverConfig('spell', null), $args);
     if (empty($args['locale'])) {
         if (!is_null($input)) {
             try {
                 $args['locale'] = $this->_injector->getInstance('Horde_Core_Factory_LanguageDetect')->getLanguageCode($input);
             } catch (Horde_Exception $e) {
             }
         }
         if (empty($args['locale']) && isset($language)) {
             $args['locale'] = $language;
         }
     }
     /* Add local dictionary words. */
     try {
         $args['localDict'] = array_merge($args['localDict'], $registry->loadConfigFile('spelling.php', 'ignore_list', 'horde')->config['ignore_list']);
     } catch (Horde_Exception $e) {
     }
     $classname = 'Horde_SpellChecker_' . Horde_String::ucfirst(basename($conf['spell']['driver']));
     if (!class_exists($classname)) {
         throw new Horde_Exception('Spellcheck driver does not exist.');
     }
     return new $classname($args);
 }
Example #17
0
 /**
  * Load FB content
  */
 private function _loadFB()
 {
     if ($this->_fb) {
         return true;
     }
     if (!$conf['facebook']['enabled']) {
         $this->_fb = PEAR::raiseError(_("No Facebook integration exists."));
         return false;
     }
     // Check FB user config
     $fbp = unserialize($prefs->getValue('facebook'));
     if (!$fbp || empty($fbp['uid'])) {
         $this->_fb = PEAR::raiseError(_("User has no link."));
         return false;
     }
     try {
         $facebook = $GLOBALS['injector']->getInstance('Horde_Service_Facebook');
     } catch (Horde_Exception $e) {
         $error = PEAR::raiseError($e->getMessage(), $e->getCode());
         Horde::log($error, 'ERR');
         return $error;
     }
     $this->_fb->auth->setUser($fbp['uid'], $fbp['sid'], 0);
     return true;
 }
Example #18
0
 /**
  */
 protected function _content()
 {
     global $whups_driver;
     $queues = Whups::permissionsFilter($whups_driver->getQueues(), 'queue', Horde_Perms::READ);
     $qsummary = $whups_driver->getQueueSummary(array_keys($queues));
     if (!$qsummary) {
         return '<p class="horde-content"><em>' . _("There are no open tickets.") . '</em></p>';
     }
     $summary = $types = array();
     foreach ($qsummary as $queue) {
         $types[$queue['type']] = $queue['type'];
         if (!isset($summary[$queue['id']])) {
             $summary[$queue['id']] = $queue;
         }
         $summary[$queue['id']][$queue['type']] = $queue['open_tickets'];
     }
     $html = '<thead><tr>';
     $sortby = 'queue_name';
     foreach (array_merge(array('queue_name' => _("Queue")), $types) as $column => $name) {
         $html .= '<th' . ($sortby == $column ? ' class="sortdown"' : '') . '>' . $name . '</th>';
     }
     $html .= '</tr></thead><tbody>';
     foreach ($summary as $queue) {
         $html .= '<tr><td>' . Horde::link(Whups::urlFor('queue', $queue, true), $queue['description']) . htmlspecialchars($queue['name']) . '</a></td>';
         foreach ($types as $type) {
             $html .= '<td>' . (isset($queue[$type]) ? $queue[$type] : '&nbsp;') . '</td>';
         }
         $html .= '</tr>';
     }
     $GLOBALS['page_output']->addScriptFile('tables.js', 'horde');
     return '<table id="whups_block_queuesummary" class="horde-table sortable" style="width:100%">' . $html . '</tbody></table>';
 }
Example #19
0
 /**
  */
 public function display(Horde_Core_Prefs_Ui $ui)
 {
     global $injector, $page_output, $prefs, $session;
     $page_output->addScriptPackage('IMP_Script_Package_Imp');
     $view = new Horde_View(array('templatePath' => IMP_TEMPLATES . '/prefs'));
     $view->addHelper('Horde_Core_View_Helper_Help');
     if (!Horde::isConnectionSecure()) {
         $view->notsecure = true;
     } else {
         $smime_url = IMP_Basic_Smime::url();
         $view->has_key = $prefs->getValue('smime_public_key') && $prefs->getValue('smime_private_key');
         if ($view->has_key) {
             $view->viewpublic = Horde::link($smime_url->copy()->add('actionID', 'view_personal_public_key'), _("View Personal Public Certificate"), null, 'view_key');
             $view->infopublic = Horde::link($smime_url->copy()->add('actionID', 'info_personal_public_key'), _("Information on Personal Public Certificate"), null, 'info_key');
             if ($injector->getInstance('IMP_Crypt_Smime')->getPassphrase()) {
                 $view->passphrase = Horde::link($ui->selfUrl(array('special' => true, 'token' => true))->add('unset_smime_passphrase', 1), _("Unload Passphrase")) . _("Unload Passphrase");
             } else {
                 $imple = $injector->getInstance('Horde_Core_Factory_Imple')->create('IMP_Ajax_Imple_PassphraseDialog', array('params' => array('reload' => $ui->selfUrl()->setRaw(true)), 'type' => 'smimePersonal'));
                 $view->passphrase = Horde::link('#', _("Enter Passphrase"), null, null, null, null, null, array('id' => $imple->getDomId())) . _("Enter Passphrase");
             }
             $view->viewprivate = Horde::link($smime_url->copy()->add('actionID', 'view_personal_private_key'), _("View Personal Private Key"), null, 'view_key');
             $page_output->addInlineScript(array('$("delete_smime_personal").observe("click", function(e) { if (!window.confirm(' . json_encode(_("Are you sure you want to delete your keypair? (This is NOT recommended!)")) . ')) { e.stop(); } })'), true);
         } elseif ($session->get('imp', 'file_upload')) {
             $view->import = true;
             $page_output->addInlineScript(array('$("import_smime_personal").observe("click", function(e) { ' . Horde::popupJs($smime_url, array('params' => array('actionID' => 'import_personal_certs', 'reload' => base64_encode($ui->selfUrl()->setRaw(true))), 'height' => 275, 'width' => 750, 'urlencode' => true)) . '; e.stop(); })'), true);
         }
     }
     return $view->render('smimeprivatekey');
 }
Example #20
0
 /**
  * Return the Ingo_Storage instance.
  *
  * @param string $driver  Driver name.
  * @param array $params   Configuration parameters.
  *
  * @return Ingo_Storage  The singleton instance.
  *
  * @throws Ingo_Exception
  */
 public function create($driver = null, $params = null)
 {
     if (is_null($driver)) {
         $driver = $GLOBALS['conf']['storage']['driver'];
     }
     $driver = ucfirst(basename($driver));
     if (!isset($this->_instances[$driver])) {
         if (is_null($params)) {
             $params = Horde::getDriverConfig('storage', $driver);
         }
         switch ($driver) {
             case 'Sql':
                 $params['db'] = $GLOBALS['injector']->getInstance('Horde_Db_Adapter');
                 $params['table_forwards'] = 'ingo_forwards';
                 $params['table_lists'] = 'ingo_lists';
                 $params['table_rules'] = 'ingo_rules';
                 $params['table_spam'] = 'ingo_spam';
                 $params['table_vacations'] = 'ingo_vacations';
                 break;
         }
         $class = 'Ingo_Storage_' . $driver;
         if (class_exists($class)) {
             $this->_instances[$driver] = new $class($params);
         } else {
             throw new Ingo_Exception(sprintf(_("Unable to load the storage driver \"%s\"."), $class));
         }
     }
     return $this->_instances[$driver];
 }
Example #21
0
 /**
  * @throws Horde_Exception
  */
 public function create(Horde_Injector $injector)
 {
     if (empty($GLOBALS['conf']['timezone']['location'])) {
         throw new Horde_Exception('Timezone database location is not configured');
     }
     return new Horde_Timezone(array('cache' => $injector->getInstance('Horde_Cache'), 'location' => $GLOBALS['conf']['timezone']['location'], 'temp' => Horde::getTempDir()));
 }
Example #22
0
 /**
  * Renders a token into text matching the requested format.
  *
  * @param array $options  The "options" portion of the token (second
  *                        element).
  *
  * @return string  The text rendered from the token options.
  */
 public function token($options)
 {
     if (!isset($options['attr']['alt'])) {
         $options['attr']['alt'] = $options['src'];
     }
     if (strpos($options['src'], '://') === false) {
         if ($options['src'][0] != '/') {
             if (strpos($options['src'], ':')) {
                 list($page, $options['src']) = explode(':', $options['src'], 2);
             } else {
                 $page = Horde_Util::getFormData('page');
                 if ($page == 'EditPage') {
                     $page = Horde_Util::getFormData('referrer');
                 }
                 if (empty($page)) {
                     $page = 'Wiki/Home';
                 }
             }
             $params = array('page' => $page, 'mime' => '1', 'file' => $options['src']);
             $options['src'] = $GLOBALS['registry']->downloadUrl($options['src'], $params)->setRaw(true);
         }
     } else {
         $options['src'] = new Horde_Url(Horde::externalUrl($options['src']));
         $options['src']->setRaw(true);
     }
     // Send external links through Horde::externalUrl().
     if (isset($options['attr']['link']) && strpos($options['attr']['link'], '://')) {
         $href = htmlspecialchars($options['attr']['link']);
         unset($options['attr']['link']);
         return Horde::link(Horde::externalUrl($href), $href) . $this->_token($options) . '</a>';
     } else {
         return $this->_token($options);
     }
 }
Example #23
0
 function _content()
 {
     if (empty($this->_params['location'])) {
         return _("No location is set.");
     }
     // Set the timezone variable, if available.
     NLS::setTimeZone();
     list($lat, $long) = explode(':', $this->_params['location']);
     $rise = $this->_calculateSunset(time(), $lat, $long, false, floor(date('Z') / 3600));
     $set = $this->_calculateSunset(time(), $lat, $long, true, floor(date('Z') / 3600));
     $location = '';
     global $coordinates;
     if (!is_array($coordinates)) {
         require HORDE_LIBS . 'Horde/NLS/coordinates.php';
     }
     foreach ($coordinates as $country) {
         if (array_key_exists($this->_params['location'], $country)) {
             $location = $country[$this->_params['location']];
             break;
         }
     }
     $html = '<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0"><tr>';
     $html .= '<td colspan="2" class="control"><b>' . $location . '</b></td></tr><tr height="100%">';
     $html .= '<td width="50%" align="center">';
     $html .= Horde::img('block/sunrise/sunrise.gif', _("Sun Rise"));
     $html .= '<br/>' . $rise;
     $html .= '</td>';
     $html .= '<td width="50%" align="center">';
     $html .= Horde::img('block/sunrise/sunset.gif', _("Sun Set"));
     $html .= '<br/>' . $set;
     $html .= '</td>';
     $html .= '</tr></table>';
     return $html;
 }
Example #24
0
 /**
  */
 protected function _create($mbox, $subject, $body)
 {
     global $notification, $registry;
     $list = str_replace(self::TASKLIST_EDIT, '', $mbox);
     /* Create a new iCalendar. */
     $vCal = new Horde_Icalendar();
     $vCal->setAttribute('PRODID', '-//The Horde Project//IMP ' . $registry->getVersion() . '//EN');
     $vCal->setAttribute('METHOD', 'PUBLISH');
     /* Create a new vTodo object using this message's contents. */
     $vTodo = Horde_Icalendar::newComponent('vtodo', $vCal);
     $vTodo->setAttribute('SUMMARY', $subject);
     $vTodo->setAttribute('DESCRIPTION', $body);
     $vTodo->setAttribute('PRIORITY', '3');
     /* Get the list of editable tasklists. */
     $lists = $this->getTasklists(true);
     /* Attempt to add the new vTodo item to the requested tasklist. */
     try {
         $res = $registry->call('tasks/import', array($vTodo, 'text/calendar', $list));
     } catch (Horde_Exception $e) {
         $notification->push($e);
         return;
     }
     if (!$res) {
         $notification->push(_("An unknown error occured while creating the new task."), 'horde.error');
     } elseif (!empty($lists)) {
         $name = '"' . htmlspecialchars($subject) . '"';
         /* Attempt to convert the object name into a hyperlink. */
         if ($registry->hasLink('tasks/show')) {
             $name = sprintf('<a href="%s">%s</a>', Horde::url($registry->link('tasks/show', array('uid' => $res))), $name);
         }
         $notification->push(sprintf(_("%s was successfully added to \"%s\"."), $name, htmlspecialchars($lists[$list]->get('name'))), 'horde.success', array('content.raw'));
     }
 }
Example #25
0
 /**
  * Renders a token into text matching the requested format.
  *
  * @param array $options  The "options" portion of the token (second
  *                        element).
  *
  * @return string  The text rendered from the token options.
  */
 public function token($options)
 {
     $site = $options['site'];
     $page = $options['page'];
     $text = $options['text'];
     if (isset($this->conf['sites'][$site])) {
         $href = $this->conf['sites'][$site];
     } else {
         return $text;
     }
     // old form where page is at end,
     // or new form with %s placeholder for sprintf()?
     if (strpos($href, '%s') === false) {
         // use the old form
         $href = $href . $page;
     } else {
         // use the new form
         $href = sprintf($href, $page);
     }
     // allow for alternative targets
     $target = $this->getConf('target', '');
     if ($target && trim($target) != '') {
         $target = " target=\"{$target}\"";
     }
     return '<a' . $target . ' href="' . Horde::externalUrl($href) . '">' . $text . '</a>';
 }
Example #26
0
File: Base.php Project: horde/horde
 /**
  * Queues the user's submitted registration info for later admin approval.
  *
  * @param mixed $info  Reference to array of parameters to be passed
  *                     to hook.
  *
  * @throws Horde_Exception
  * @throws Horde_Mime_Exception
  */
 public function queueSignup(&$info)
 {
     /* @var $conf array */
     /* @var $injector Horde_Injector */
     /* @var $registry Horde_Registry */
     global $conf, $injector, $registry;
     // Perform any preprocessing if requested.
     $this->_preSignup($info);
     // If it's a unique username, go ahead and queue the request.
     $signup = $this->newSignup($info['user_name']);
     if (!empty($info['extra'])) {
         $signup->setData($info['extra']);
     }
     $signup->setData(array_merge($signup->getData(), array('dateReceived' => time(), 'password' => $info['password'])));
     $this->_queueSignup($signup);
     try {
         $injector->getInstance('Horde_Core_Hooks')->callHook('signup_queued', 'horde', array($info['user_name'], $info));
     } catch (Horde_Exception_HookNotSet $e) {
     }
     if (!empty($conf['signup']['email'])) {
         $link = Horde::url($registry->get('webroot', 'horde') . '/admin/signup_confirm.php', true, -1)->setRaw(true)->add(array('u' => $signup->getName(), 'h' => hash_hmac('sha1', $signup->getName(), $conf['secret_key'])));
         $message = sprintf(Horde_Core_Translation::t("A new account for the user \"%s\" has been requested through the signup form."), $signup->getName()) . "\n\n" . Horde_Core_Translation::t("Approve the account:") . "\n" . $link->copy()->add('a', 'approve') . "\n" . Horde_Core_Translation::t("Deny the account:") . "\n" . $link->copy()->add('a', 'deny');
         $mail = new Horde_Mime_Mail(array('body' => $message, 'Subject' => sprintf(Horde_Core_Translation::t("Account signup request for \"%s\""), $signup->getName()), 'To' => $conf['signup']['email'], 'From' => $conf['signup']['email']));
         $mail->send($injector->getInstance('Horde_Mail'));
     }
 }
Example #27
0
 protected function _hours()
 {
     global $prefs;
     $hours_html = '';
     $dayWidth = round(100 / $this->_days);
     $span = floor(($this->_endHour - $this->_startHour) / 3);
     if (($this->_endHour - $this->_startHour) % 3) {
         $span++;
     }
     $date_format = $prefs->getValue('date_format');
     for ($i = 0; $i < $this->_days; $i++) {
         $t = new Horde_Date(array('month' => $this->_start->month, 'mday' => $this->_start->mday + $i, 'year' => $this->_start->year));
         $day_label = Horde::url('#')->link(array('onclick' => 'return switchDateView(\'Day\',' . $t->dateString() . ');')) . $t->strftime($date_format) . '</a>';
         $hours_html .= sprintf('<th colspan="%d" width="%s%%">%s</th>', $span, $dayWidth, $day_label);
     }
     $hours_html .= '</tr><tr><td width="100" class="label">&nbsp;</td>';
     $width = round(100 / ($span * $this->_days));
     for ($i = 0; $i < $this->_days; $i++) {
         for ($h = $this->_startHour; $h < $this->_endHour; $h += 3) {
             $start = new Horde_Date(array('hour' => $h, 'month' => $this->_start->month, 'mday' => $this->_start->mday + $i, 'year' => $this->_start->year));
             $end = new Horde_Date($start);
             $end->hour += 2;
             $end->min = 59;
             $this->_timeBlocks[] = array($start, $end);
             $hour = $start->strftime($prefs->getValue('twentyFour') ? '%H:00' : '%I:00');
             $hours_html .= sprintf('<th width="%d%%">%s</th>', $width, $hour);
         }
     }
     return $hours_html;
 }
Example #28
0
 /**
  */
 protected function _initOb($params)
 {
     global $injector;
     $this->_params = $params;
     switch ($this->_params['driver']) {
         case 'cache':
             $ob = new Horde_Imap_Client_Cache_Backend_Cache(array_filter(array('cacheob' => $injector->getInstance('Horde_Cache'), 'lifetime' => isset($this->_params['lifetime']) ? $this->_params['lifetime'] : null)));
             break;
         case 'hashtable':
             $ob = new Horde_Imap_Client_Cache_Backend_Hashtable(array_filter(array('hashtable' => $injector->getInstance('Horde_HashTable'), 'lifetime' => isset($this->_params['lifetime']) ? $this->_params['lifetime'] : null)));
             break;
         case 'none':
             $ob = new Horde_Imap_Client_Cache_Backend_Null();
             break;
         case 'nosql':
             $ob = new Horde_Imap_Client_Cache_Backend_Mongo(array('mongo_db' => $injector->getInstance('Horde_Nosql_Adapter')));
             break;
         case 'sql':
             $ob = new Horde_Imap_Client_Cache_Backend_Db(array('db' => $injector->getInstance('Horde_Db_Adapter')));
             break;
         default:
             $this->_params['driver'] = 'none';
             Horde::log('IMAP caching has been disabled for this session due to an error', 'WARN');
             $ob = new Horde_Imap_Client_Cache_Backend_Null();
             break;
     }
     $this->backend = $ob;
 }
Example #29
0
 /**
  * Add additional items to the sidebar.
  *
  * @param Horde_View_Sidebar $sidebar  The sidebar object.
  */
 public function sidebar($sidebar)
 {
     $perms = $GLOBALS['injector']->getInstance('Horde_Core_Perms');
     if (Sesha::isAdmin(Horde_Perms::READ) || $perms->hasPermission('sesha:addStock', $GLOBALS['registry']->getAuth(), Horde_Perms::READ)) {
         $sidebar->addNewButton(_("_Add Stock"), Horde::url('stock.php')->add('actionId', 'add_stock'));
     }
 }
Example #30
0
 /**
  * @throws Turba_Exception
  */
 public function execute()
 {
     // If cancel was clicked, return false.
     if ($this->_vars->get('submitbutton') == _("Cancel")) {
         Horde::url('', true)->redirect();
     }
     if (!$GLOBALS['registry']->getAuth() || $this->_addressbook->get('owner') != $GLOBALS['registry']->getAuth()) {
         throw new Turba_Exception(_("You do not have permissions to delete this address book."));
     }
     $driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($this->_addressbook->getName());
     if ($driver->hasCapability('delete_all')) {
         try {
             $driver->deleteAll();
         } catch (Turba_Exception $e) {
             Horde::log($e->getMessage(), 'ERR');
             throw $e;
         }
     }
     // Address book successfully deleted from backend, remove the share.
     try {
         $GLOBALS['injector']->getInstance('Turba_Shares')->removeShare($this->_addressbook);
     } catch (Horde_Share_Exception $e) {
         Horde::log($e->getMessage(), 'ERR');
         throw new Turba_Exception($e);
     }
     if ($GLOBALS['session']->get('turba', 'source') == Horde_Util::getFormData('deleteshare')) {
         $GLOBALS['session']->remove('turba', 'source');
     }
 }