Author: Jan Schneider (jan@horde.org)
Author: Michael Slusarz (slusarz@horde.org)
Beispiel #1
0
 /**
  * Adds a tab to the interface.
  *
  * @param string $title    The text which appears on the tab.
  * @param Horde_Url $link  The target page.
  * @param mixed $params    Either a string value to set the tab variable to,
  *                         or a hash of parameters. If an array, the tab
  *                         variable can be set by the 'tabname' key.
  */
 public function addTab($title, $link, $params = array())
 {
     if (!is_array($params)) {
         $params = array('tabname' => $params);
     }
     $this->_tabs[] = array_merge(array('title' => $title, 'link' => $link->copy(), 'tabname' => null, 'img' => null, 'class' => null), $params);
 }
Beispiel #2
0
 public function testUrlMissingScheme()
 {
     $url = new Horde_Url('example.com/test?foo=1&bar=2');
     $url->setScheme();
     $this->assertEquals('/test?foo=1&bar=2', $url->toString(true, false));
     $this->assertEquals('http://example.com/test?foo=1&bar=2', $url->toString(true, true));
 }
 public function testBaseUrlWithParametersWithoutAnchor()
 {
     $base = new Horde_Url('test');
     $base->add('foo', 0);
     $url = new Horde_Core_Smartmobile_Url($base);
     $url->add(array('foo' => 1, 'bar' => 2));
     $this->assertEquals('test?foo=1&bar=2', (string) $url);
 }
Beispiel #4
0
 public function testLink()
 {
     $url = new Horde_Url('test', true);
     $url->add(array('foo' => 1, 'bar' => 2));
     $this->assertEquals('test?foo=1&bar=2', (string) $url);
     $this->assertEquals('<a href="test?foo=1&amp;bar=2">', $url->link());
     $this->assertEquals('<a href="test?foo=1&amp;bar=2" title="foo&amp;bar">', $url->link(array('title' => 'foo&bar')));
     $this->assertEquals('<a href="test?foo=1&amp;bar=2" title="foo&bar">', $url->link(array('title.raw' => 'foo&bar')));
 }
Beispiel #5
0
 public function testEmptyRedirect()
 {
     $url = new Horde_Url('');
     try {
         $url->redirect();
         $this->fail();
     } catch (Horde_Url_Exception $e) {
     }
 }
Beispiel #6
0
 /**
  * Renders a token into text matching the requested format.
  *
  * @access public
  *
  * @param array $options The "options" portion of the token (second
  * element).
  *
  * @return string The text rendered from the token options.
  */
 public function token($options)
 {
     try {
         $link = new Horde_Url($GLOBALS['registry']->link($options['method'], $options['args']));
     } catch (Horde_Exception $e) {
         return $e->getMessage();
     }
     return $link->link() . $options['title'] . '</a>';
 }
Beispiel #7
0
 /**
  */
 protected function _init()
 {
     global $browser, $injector, $page_output, $registry;
     $page_output->addScriptFile('base.js');
     $page_output->addScriptFile('passphrase.js');
     $page_output->addScriptFile('viewport.js');
     $page_output->addScriptFile('external/CustomElements.js');
     $page_output->addScriptFile('external/time-elements.js');
     $page_output->addScriptFile('external/tinycon.js');
     $page_output->addScriptFile('dragdrop2.js', 'horde');
     $page_output->addScriptFile('form_ghost.js', 'horde');
     $page_output->addScriptFile('jstorage.js', 'horde');
     $page_output->addScriptFile('slider2.js', 'horde');
     $page_output->addScriptFile('toggle_quotes.js', 'horde');
     $page_output->addScriptPackage('Horde_Core_Script_Package_Dialog');
     $page_output->addScriptPackage('IMP_Script_Package_Imp');
     $page_output->addThemeStylesheet('mailbox.css');
     $page_output->addThemeStylesheet('message_view.css');
     $imp_imap = $injector->getInstance('IMP_Factory_Imap')->create();
     if ($imp_imap->access(IMP_Imap::ACCESS_FLAGS)) {
         $page_output->addScriptFile('colorpicker.js', 'horde');
         $this->view->picker_img = Horde_Themes_Image::tag('colorpicker.png', array('alt' => _("Color Picker")));
     }
     if ($imp_imap->access(IMP_Imap::ACCESS_REMOTE)) {
         $page_output->addScriptFile('external/base64.js');
     }
     $this->_addMailboxVars();
     $this->view->show_innocent = !empty($imp_imap->config->innocent_params);
     $this->view->show_search = $imp_imap->access(IMP_Imap::ACCESS_SEARCH);
     $this->view->show_spam = !empty($imp_imap->config->spam_params);
     $impSubinfo = new Horde_View(array('templatePath' => IMP_TEMPLATES . '/dynamic'));
     $impSubinfo->addHelper('Text');
     $impSubinfo->quota = (bool) $imp_imap->config->quota;
     $topbar = $injector->getInstance('Horde_View_Topbar');
     $topbar->search = $this->view->show_search;
     $topbar->searchMenu = true;
     $topbar->subinfo = $impSubinfo->render('mailbox_subinfo');
     $page_output->topbar = true;
     $blank = new Horde_Url();
     $impSidebar = new Horde_View(array('templatePath' => array($registry->get('templates', 'horde') . '/sidebar', IMP_TEMPLATES . '/dynamic')));
     $impSidebar->addHelper('Text');
     $impSidebar->containers = array(array('id' => 'imp-specialmboxes'));
     if ($imp_imap->isImap()) {
         $impSidebar->containers[] = array('rows' => array(array('id' => 'folderopts_link', 'cssClass' => 'folderoptsImg', 'link' => $blank->link() . _("Folder Actions") . '</a>'), array('id' => 'dropbase', 'style' => 'display:none', 'cssClass' => 'folderImg', 'link' => $blank->link() . _("Move to Base Level") . '</a>')));
         $impSidebar->containers[] = array('id' => 'imp-normalmboxes');
     }
     $sidebar = $injector->getInstance('Horde_View_Sidebar');
     $sidebar->newLink = $blank->link(array('id' => 'composelink', 'class' => 'icon'));
     $sidebar->newText = _("New Message");
     $sidebar->content = $impSidebar->render('sidebar');
     $this->view->sidebar = $sidebar->render();
     $this->view->max_fsize = intval($browser->allowFileUploads());
     $page_output->noDnsPrefetch();
     $this->_pages[] = 'mailbox';
 }
Beispiel #8
0
 /**
  * Send a POST request
  *
  * @param string $method  The method to call.
  * @param array  $params  The method parameters.
  *
  * @return string The request results
  * @throws Horde_Service_Facebook_Exception
  */
 protected function _postRequest($method, &$params)
 {
     $this->_finalizeParams($params);
     try {
         $url = new Horde_Url(Horde_Service_Facebook::REST_SERVER_ADDR . $method);
         $result = $this->_http->request('POST', $url->toString(), $this->_createPostString($params));
     } catch (Exception $e) {
         $this->_facebook->logger->err($e->getMessage());
         throw new Horde_Service_Facebook_Exception(Horde_Service_Facebook_Translation::t("Facebook service is unavailable. Please try again later."));
     }
     return $result->getBody();
 }
Beispiel #9
0
 /**
  * Builds URL strings for various targets
  * @param string $controller  The internal name of the controller or page
  * @param array $details      The parameters to attach either as path or as get parameters
  * @param boolean $full       Generate a full url or relative to dolcore, defaults to false
  * @param boolean $legacy     Generate an url for the legacy target page or for a dolcore controller. Ignored if one is missing
  * @returns string  The generated URL
  */
 public function getUrlFor($controller, array $details = null, $full = false, $legacy = false)
 {
     switch ($controller) {
         case 'discussion':
             if ($legacy) {
                 $parameters = array('position' => 700, 'frage_id' => $details['discussion_id']);
                 $url = new Horde_Url($GLOBALS['conf']['path']['dol2day_front'], true);
                 return $url->add($parameters)->toString();
             }
             break;
     }
 }
Beispiel #10
0
 /**
  * @TODO: For reverse requests come up with a reasonable algorithm for
  *        checking if we have a lat/lng in the US since the
  *        findNearestAddress method is US only. If non-us, fallback to a
  *        findNearest or findPostalcode or similar request. Also will need
  *        to normalize the various response structures.
  *
  * 'locations' will trigger a forward geocoding request.
  * 'lat' and 'lon' will trigger a reverse geocoding request.
  *
  * @throws Horde_Exception
  */
 protected function _handle(Horde_Variables $vars)
 {
     if ($vars->location) {
         $url = new Horde_Url('http://ws.geonames.org/searchJSON');
         $url->add(array('q' => $vars->location));
     } elseif ($vars->lat && $vars->lon) {
         $url = new Horde_Url('http:/ws.geonames.org/findNearestJSON');
         $url->add(array('lat' => $vars->lat, 'lng' => $vars->lon));
     } else {
         throw new Horde_Exception('Incorrect parameters');
     }
     $response = $GLOBALS['injector']->getInstance('Horde_Core_Factory_HttpClient')->create()->get($url);
     return new Horde_Core_Ajax_Response_Prototypejs(array('results' => $response->getBody(), 'status' => 200));
 }
Beispiel #11
0
 /**
  * Perform search
  *
  * @throws Mnemo_Exception
  */
 protected function _doSearch()
 {
     $search_pattern = $this->_vars->get('search_pattern');
     $search_type = $this->_vars->get('search_type');
     $search_desc = $search_type == 'desc';
     $search_body = $search_type == 'body';
     if (!empty($search_pattern) && ($search_body || $search_desc)) {
         $search_pattern = '/' . preg_quote($search_pattern, '/') . '/i';
         $search_result = array();
         foreach ($this->_notes as $memo_id => $memo) {
             if ($search_desc && preg_match($search_pattern, $memo['desc']) || $search_body && preg_match($search_pattern, $memo['body'])) {
                 $search_result[$memo_id] = $memo;
             }
         }
         $this->_notes = $search_result;
     } elseif ($search_type == 'tags') {
         // Tag search, use the browser.
         $this->_browser->clearSearch();
         $tags = $GLOBALS['injector']->getInstance('Mnemo_Tagger')->split($this->_vars->get('search_pattern'));
         foreach ($tags as $tag) {
             $this->_browser->addTag($tag);
         }
         $this->_notes = $this->_browser->getSlice();
         $this->_handleActions(false);
         return;
     }
     $this->_baseurl->add(array('actionID' => 'search_memos', 'search_pattern' => $search_pattern, 'search_type' => $search_type));
 }
Beispiel #12
0
 public function testFromUrl()
 {
     $baseurl = new Horde_Url('test', true);
     $baseurl->add(array('foo' => 1, 'bar' => 2));
     $url = new Horde_Url($baseurl);
     $this->assertEquals('test?foo=1&bar=2', (string) $url);
     $url = new Horde_Url($baseurl, true);
     $this->assertEquals('test?foo=1&bar=2', (string) $url);
     $url = new Horde_Url($baseurl, false);
     $this->assertEquals('test?foo=1&amp;bar=2', (string) $url);
     $baseurl = new Horde_Url('test', false);
     $baseurl->add(array('foo' => 1, 'bar' => 2));
     $url = new Horde_Url($baseurl);
     $this->assertEquals('test?foo=1&amp;bar=2', (string) $url);
     $url = new Horde_Url($baseurl, true);
     $this->assertEquals('test?foo=1&bar=2', (string) $url);
     $url = new Horde_Url($baseurl, false);
     $this->assertEquals('test?foo=1&amp;bar=2', (string) $url);
 }
Beispiel #13
0
 /**
  * Creates the full URL string.
  *
  * @param boolean $raw   Whether to output the URL in the raw URL format
  *                       or HTML-encoded.
  * @param boolean $full  Output the full URL?
  *
  * @return string  The string representation of this object.
  */
 public function toString($raw = false, $full = true)
 {
     if ($this->toStringCallback || !strlen($this->anchor)) {
         $baseUrl = $this->_baseUrl->copy();
         $baseUrl->parameters = array_merge($baseUrl->parameters, $this->parameters);
         if (strlen($this->pathInfo)) {
             $baseUrl->pathInfo = $this->pathInfo;
         }
         return $baseUrl->toString($raw, $full);
     }
     $url = $this->_baseUrl->toString($raw, $full);
     if (strlen($this->pathInfo)) {
         $url = rtrim($url, '/');
         $url .= '/' . $this->pathInfo;
     }
     if ($this->anchor) {
         $url .= '#' . ($raw ? $this->anchor : rawurlencode($this->anchor));
     }
     if ($params = $this->_getParameters()) {
         $url .= '?' . implode($raw ? '&' : '&amp;', $params);
     }
     return strval($url);
 }
Beispiel #14
0
 public function __construct(array $config)
 {
     if (!empty($config['what']) && !empty($config['loc'])) {
         $this->title = $this->header = _("Search Results");
         $url = new Horde_Url('list.php');
         $this->backToList = $url->link() . _('Back to stock list') . '</a>';
     } else {
         $this->title = $this->header = _("Available Inventory");
     }
     $this->selectedCategories = is_array($config['selectedCategories']) ? $config['selectedCategories'] : array($config['selectedCategories']);
     if (empty($this->selectedCategories[0])) {
         array_shift($this->selectedCategories);
     }
     $this->shownProperties = $this->properties($config['propertyIds']);
     $this->columnHeaders = $this->columnHeaders($config['sortDir'], $config['sortBy']);
     $filters = array();
     if (!empty($this->selectedCategories)) {
         $filters[] = array('type' => 'categories', 'value' => $this->selectedCategories, 'exact' => $config['exact']);
     }
     if (!empty($config['loc'])) {
         if (in_array(Sesha::SEARCH_ID, $config['loc'])) {
             $filters[] = array('type' => 'stock_id', 'exact' => $config['exact'], 'value' => $config['what']);
         }
         if (in_array(Sesha::SEARCH_NAME, $config['loc'])) {
             $filters[] = array('type' => 'stock_name', 'exact' => $config['exact'], 'value' => $config['what']);
         }
         if (in_array(Sesha::SEARCH_NOTE, $config['loc'])) {
             $filters[] = array('type' => 'note', 'exact' => $config['exact'], 'value' => $config['what']);
         }
         if (in_array(Sesha::SEARCH_PROPERTY, $config['loc'])) {
             $filters[] = array('type' => 'values', 'exact' => $config['exact'], 'value' => array(array('values' => array($config['what']))));
         }
     }
     $this->shownStock = $this->stock($filters);
     parent::__construct($config);
 }
Beispiel #15
0
 /**
  * Run this request and return the data.
  *
  * @return mixed Either raw JSON, or an array of decoded values.
  * @throws Horde_Service_Facebook_Exception
  */
 public function run()
 {
     if ($this->_request != 'POST') {
         $this->_endpoint->add($this->_params);
         $params = array();
     } else {
         $params = $this->_params;
     }
     try {
         $result = $this->_http->request($this->_request, $this->_endpoint->toString(true), $params);
     } catch (Horde_Http_Exception $e) {
         $this->_facebook->logger->err($e->getMessage());
         throw new Horde_Service_Facebook_Exception($e);
     }
     if ($result->code != '200') {
         $body = $result->getBody();
         if (($error = json_decode($body, true)) && isset($error['error']['message'])) {
             throw new Horde_Service_Facebook_Exception($error['error']['message']);
         }
         throw new Horde_Service_Facebook_Exception($body);
     }
     return json_decode($result->getBody());
 }
Beispiel #16
0
/**
 * Construct the URL back to a supplied search
 */
function _getSearchUrl($vars)
{
    $qUrl = new Horde_Url();
    $queue = (int) $vars->get('queue');
    $qUrl->add(array('queue' => $queue));
    $summary = $vars->get('summary');
    if ($summary) {
        $qUrl->add('summary', $summary);
    }
    $states = $vars->get('states');
    if (is_array($states)) {
        foreach ($states as $type => $state) {
            if (is_array($state)) {
                foreach ($state as $s) {
                    $qUrl->add("states[{$type}][]", $s);
                }
            } else {
                $qUrl->add("states[{$type}]", $state);
            }
        }
    }
    return substr($qUrl, 1);
}
Beispiel #17
0
 /**
  * Deconstruct the ID elements from the ID string
  *
  * @param string $id The ID to be deconstructed.
  *
  * @return array A tuple of (owner, folder subpath).
  */
 private function _idDeconstruct($id)
 {
     if (!($decoded_id = Horde_Url::uriB64Decode($id))) {
         $msg = sprintf('Share id %s is invalid.', $id);
         $this->_logger->err($msg);
         throw new Horde_Exception_NotFound($msg);
     }
     if (!($sid = @unserialize($decoded_id))) {
         $msg = sprintf('Share id %s is invalid.', $decoded_id);
         $this->_logger->err($msg);
         throw new Horde_Exception_NotFound($msg);
     }
     return $sid;
 }
Beispiel #18
0
 /**
  * Make the remote API call.
  *
  * @param Horde_Url $url  The endpoint.
  *
  * @return mixed  The unserialized results form the remote API call.
  * @throws Horde_Service_Weather_Exception
  */
 protected function _makeRequest(Horde_Url $url)
 {
     // Owm returns temperature data in Kelvin by default!
     if ($this->units == Horde_Service_Weather::UNITS_METRIC) {
         $url->add('units', 'metric');
     } else {
         $url->add('units', 'imperial');
     }
     $url->add(array('key' => $this->_key))->setRaw(true);
     $cachekey = md5('hordeweather' . $url);
     if (!empty($this->_cache) && !($results = $this->_cache->get($cachekey, $this->_cache_lifetime)) || empty($this->_cache)) {
         $response = $this->_http->get((string) $url);
         if (!$response->code == '200') {
             throw new Horde_Service_Weather_Exception($response->code);
         }
         $results = $response->getBody();
         if (!empty($this->_cache)) {
             $this->_cache->set($cachekey, $results);
         }
     }
     $results = Horde_Serialize::unserialize($results, Horde_Serialize::JSON);
     if (!$results instanceof StdClass) {
         throw new Horde_Service_Weather_Exception(sprintf('Error, unable to decode response: %s', $results));
     }
     return $results;
 }
Beispiel #19
0
 /**
  * Handles saving the gallery information from the form submission, and
  * redirects back to previous view when complete.
  *
  * @return void
  */
 private function _runSave()
 {
     // Check general permissions.
     if (!$GLOBALS['registry']->isAdmin() && ($GLOBALS['injector']->getInstance('Horde_Perms')->exists('ansel') && !$GLOBALS['injector']->getInstance('Horde_Perms')->hasPermission('ansel', $GLOBALS['registry']->getAuth(), Horde_Perms::EDIT))) {
         $GLOBALS['notification']->push(_("Access denied editing galleries."), 'horde.error');
         Horde::url('view.php?view=List', true)->redirect();
         exit;
     }
     // Get the form values.
     $galleryId = Horde_Util::getFormData('gallery');
     $gallery_name = Horde_Util::getFormData('gallery_name');
     $gallery_desc = Horde_Util::getFormData('gallery_desc');
     $gallery_slug = Horde_Util::getFormData('gallery_slug');
     $gallery_age = (int) Horde_Util::getFormData('gallery_age', 0);
     $gallery_download = Horde_Util::getFormData('gallery_download');
     $gallery_mode = Horde_Util::getFormData('view_mode', 'Normal');
     $gallery_passwd = Horde_Util::getFormData('gallery_passwd');
     $gallery_tags = Horde_Util::getFormData('gallery_tags');
     $gallery_thumbstyle = Horde_Util::getFormData('gallery_style');
     $gallery_parent = Horde_Util::getFormData('gallery_parent');
     // Style
     $style = new Ansel_Style(array('thumbstyle' => Horde_Util::getFormData('thumbnail_style'), 'background' => Horde_Util::getFormData('background_color'), 'gallery_view' => Horde_Util::getFormData('gallery_view'), 'widgets' => array('Tags' => array('view' => 'gallery'), 'OtherGalleries' => array(), 'Geotag' => array(), 'Links' => array(), 'GalleryFaces' => array(), 'OwnerFaces' => array())));
     // Double check for an empty string instead of null
     if (empty($gallery_parent)) {
         $gallery_parent = null;
     }
     if ($galleryId && ($exists = $GLOBALS['injector']->getInstance('Ansel_Storage')->galleryExists($galleryId) === true)) {
         // Modifying an existing gallery.
         $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery($galleryId);
         if (!$gallery->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::EDIT)) {
             $GLOBALS['notification']->push(_("Access denied saving this gallery."), 'horde.error');
         } else {
             // Don't allow the display name to be nulled out.
             if ($gallery_name) {
                 $gallery->set('name', $gallery_name);
             }
             $gallery->set('desc', $gallery_desc);
             $gallery->setTags(!empty($gallery_tags) ? explode(',', $gallery_tags) : array());
             $gallery->set('style', $style);
             $gallery->set('slug', $gallery_slug);
             $gallery->set('age', $gallery_age);
             $gallery->set('download', $gallery_download);
             $gallery->set('view_mode', $gallery_mode);
             if ($GLOBALS['registry']->getAuth() && $gallery->get('owner') == $GLOBALS['registry']->getAuth()) {
                 $gallery->set('passwd', $gallery_passwd);
             }
             // Did the parent change?
             $old_parent = $gallery->getParent();
             if (!is_null($old_parent)) {
                 $old_parent_id = $old_parent->id;
             } else {
                 $old_parent_id = null;
             }
             if ($gallery_parent != $old_parent_id) {
                 if (!is_null($gallery_parent)) {
                     $new_parent = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery($gallery_parent);
                 } else {
                     $new_parent = null;
                 }
                 try {
                     $result = $gallery->setParent($new_parent);
                 } catch (Ansel_Exception $e) {
                     $GLOBALS['notification']->push($e->getMessage(), 'horde.error');
                     Horde::url(Ansel::getUrlFor('view', array('view' => 'List'), true))->redirect();
                     exit;
                 }
             }
             try {
                 $result = $gallery->save();
                 $GLOBALS['notification']->push(_("The gallery was saved."), 'horde.success');
             } catch (Ansel_Exception $e) {
                 $GLOBALS['notification']->push($e->getMessage(), 'horde.error');
             }
         }
     } else {
         // Is this a new subgallery?
         if ($gallery_parent) {
             try {
                 $parent = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery($gallery_parent);
             } catch (Ansel_Exception $e) {
                 $GLOBALS['notification']->push($e->getMessage(), 'horde.error');
                 Horde::url(Ansel::getUrlFor('view', array('view' => 'List'), true))->redirect();
                 exit;
             }
             if (!$parent->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::EDIT)) {
                 $GLOBALS['notification']->push(_("You do not have permission to add sub galleries to this gallery."), 'horde.error');
                 Horde::url(Ansel::getUrlFor('view', array('view' => 'List'), true))->redirect();
                 exit;
             }
         }
         // Require a display name.
         if (!$gallery_name) {
             $GLOBALS['notification']->push(_("You must provide a display name for your new gallery."), 'horde.warning');
             $actionId = 'add';
             $title = _("Adding A New Gallery");
         }
         // Create the new gallery.
         $perm = !empty($parent) ? $parent->getPermission() : null;
         try {
             $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->createGallery(array('name' => $gallery_name, 'desc' => $gallery_desc, 'tags' => explode(',', $gallery_tags), 'style' => $style, 'slug' => $gallery_slug, 'age' => $gallery_age, 'download' => $gallery_download, 'view_mode' => $gallery_mode, 'passwd' => $gallery_passwd), $perm, $gallery_parent);
             $galleryId = $gallery->id;
             $msg = sprintf(_("The gallery \"%s\" was created successfully."), $gallery_name);
             $GLOBALS['notification']->push($msg, 'horde.success');
             Horde::url('img/upload.php')->add('gallery', $galleryId)->redirect();
         } catch (Ansel_Exception $e) {
             $galleryId = null;
             $error = sprintf(_("The gallery \"%s\" couldn't be created: %s"), $gallery_name, $e->getMessage());
             Horde::log($error, 'ERR');
             $GLOBALS['notification']->push($error, 'horde.error');
             Horde::url(Ansel::getUrlFor('view', array('view' => 'List'), true))->redirect();
             exit;
         }
     }
     // Make sure that the style hash is recorded, ignoring non-styled thumbs
     if ($style->thumbstyle != 'Thumb') {
         $GLOBALS['injector']->getInstance('Ansel_Storage')->ensureHash($gallery->getStyle()->getHash('thumb'));
     }
     // Clear the OtherGalleries widget cache
     if ($GLOBALS['conf']['ansel_cache']['usecache']) {
         $GLOBALS['injector']->getInstance('Horde_Cache')->expire('Ansel_OtherGalleries' . $gallery->get('owner'));
     }
     // Return to the last view.
     $url = Horde_Util::getFormData('url');
     if (empty($url) && empty($exists)) {
         // Redirect to the images upload page for newly creted galleries
         $url = Horde::url('img/upload.php')->add('gallery', $galleryId);
     } elseif (empty($url)) {
         $url = Horde::url('index.php', true);
     } else {
         $url = new Horde_Url($url);
     }
     $url->redirect();
 }
Beispiel #20
0
 /**
  * Generate a URL using the current mailbox.
  *
  * @param string|Horde_Url $page  Page name to link to.
  * @param string $buid            The BUID to use on the linked page.
  * @param boolean $encode         Encode the argument separator?
  *
  * @return Horde_Url  URL to $page with any necessary mailbox information
  *                    added to the parameter list of the URL.
  */
 public function url($page, $buid = null, $encode = true)
 {
     if ($page instanceof Horde_Url) {
         return $page->add($this->urlParams($buid))->setRaw(!$encode);
     }
     switch ($GLOBALS['registry']->getView()) {
         case Horde_Registry::VIEW_BASIC:
         case Horde_Registry::VIEW_DYNAMIC:
             $anchor = is_null($buid) ? 'mbox:' . $this->form_to : 'msg:' . $this->form_to . ';' . $buid;
             return Horde::url('index.php')->setAnchor($anchor);
         case Horde_Registry::VIEW_MINIMAL:
         case Horde_Registry::VIEW_SMARTMOBILE:
             $url = Horde::url('smartmobile.php');
             $anchor = is_null($buid) ? 'mbox=' . $this->form_to : 'msg=' . $this->form_to . ';' . $buid;
             $url->setAnchor('mailbox?' . $anchor);
             return $url;
     }
     return Horde::url($page . '.php')->add($this->urlParams($buid))->setRaw(!$encode);
 }
Beispiel #21
0
 * Copyright 2004-2014 Horde LLC (http://www.horde.org/)
 *
 * See the enclosed file COPYING for license information (LGPL-2). If you
 * did not receive this file, see http://www.horde.org/licenses/lgpl.
 *
 * @author    Chuck Hagenbuch <*****@*****.**>
 * @category  Horde
 * @copyright 2004-2014 Horde LLC
 * @license   http://www.horde.org/licenses/lgpl LGPL-2
 * @package   Horde
 */
require_once __DIR__ . '/../lib/Application.php';
Horde_Registry::appInit('horde');
$apps = $registry->listAllApps();
sort($apps);
$url = new Horde_Url('icon_browser.php');
$vars = $injector->getInstance('Horde_Variables');
if (($app = basename($vars->app)) && in_array($app, $apps)) {
    $img = Horde_Themes::img(null, array('app' => $app, 'theme' => 'default'));
    $img_fs = $img->fs;
    // Throws Exception on error.
    $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($img_fs));
    // Provide a non-white background for eyeballing transparency.
    echo '<html><body bgcolor="#aaaaaa">' . '<h2>' . sprintf(_("Icons for %s"), $registry->get('name', $app)) . '</h2>';
    foreach ($iterator as $val) {
        if ($val->isFile() && in_array(substr($val->getFilename(), -4), array('.png', '.gif', 'jpg'))) {
            $imgs[] = strval($val);
        }
    }
    if (count($imgs)) {
        natsort($imgs);
Beispiel #22
0
 /**
  * Retrieves sub-tasks from the database.
  *
  * @param string $parentId          The parent id for the sub-tasks to
  *                                  retrieve.
  * @param boolean $include_history  Include created/modified info? Not
  *                                  currently honored.
  *
  * @return array  List of sub-tasks.
  * @throws Nag_Exception
  */
 public function getChildren($parentId, $include_history = true)
 {
     $task_list = $this->_getData()->getObjects();
     if (empty($task_list)) {
         return array();
     }
     $tasks = array();
     foreach ($task_list as $task) {
         if (Horde_Url::uriB64Encode($task['parent']) != $parentId) {
             continue;
         }
         $t = new Nag_Task($this, $this->_buildTask($task));
         $children = $this->getChildren($t->id);
         $t->mergeChildren($children);
         $tasks[] = $t;
     }
     return $tasks;
 }
Beispiel #23
0
 /**
  * Redirect to the given URL.
  *
  * @param Horde_Url|string $url  The URL to redirect to.
  */
 public function redirect($url)
 {
     $url = new Horde_Url($url);
     $url->redirect();
 }
Beispiel #24
0
 /**
  * Return an autocomplete search response.
  *
  * @see Horde_Service_Weather_Base::autocompleteLocation()
  */
 public function autocompleteLocation($search)
 {
     $url = new Horde_Url('http://autocomplete.wunderground.com/aq');
     $url->add(array('query' => $search, 'format' => 'JSON'));
     return $this->_parseAutocomplete($this->_makeRequest($url));
 }
Beispiel #25
0
 /**
  * Produces a directory link used for navigation.
  *
  * @param string $currdir  The current directory string.
  * @param string $url      The URL to link to.
  *
  * @return string  The directory navigation string.
  */
 public static function directoryNavLink($currdir, $url)
 {
     $label = array();
     $root_dir_name = self::$backend['name'];
     if ($currdir == $root_dir_name) {
         $label[] = '[' . $root_dir_name . ']';
     } else {
         $parts = explode('/', $currdir);
         $parts_count = count($parts);
         $url = new Horde_Url($url);
         $label[] = Horde::link($url->add('dir', self::$backend['root']), sprintf(_("Up to %s"), $root_dir_name)) . '[' . $root_dir_name . ']</a>';
         for ($i = 1; $i <= $parts_count; ++$i) {
             $part = array_slice($parts, 0, $i);
             $dir = implode('/', $part);
             if (strstr($dir, self::$backend['root']) !== false && self::$backend['root'] != $dir) {
                 if ($i == $parts_count) {
                     $label[] = $parts[$i - 1];
                 } else {
                     $label[] = Horde::link($url->add('dir', $dir), sprintf(_("Up to %s"), $dir)) . htmlspecialchars($parts[$i - 1]) . '</a>';
                 }
             }
         }
     }
     return implode('/', $label);
 }
Beispiel #26
0
 /**
  * Create the URL for the keyserver.
  *
  * @param string $uri    Action URI.
  * @param array $params  List of parameters to add to URL.
  *
  * @return Horde_Url  Keyserver URL.
  */
 protected function _createUrl($uri, array $params = array())
 {
     $url = new Horde_Url($this->_keyserver . $uri, true);
     return $url->add($params);
 }
Beispiel #27
0
<?php

/**
 * Copyright 1999-2014 Horde LLC (http://www.horde.org/)
 *
 * See the enclosed file COPYING for license information (GPL). If you
 * did not receive this file, see http://www.horde.org/licenses/gpl
 */
require_once __DIR__ . '/lib/Application.php';
Horde_Registry::appInit('ansel');
$blocks = $injector->getInstance('Horde_Core_Factory_BlockCollection')->create(array('ansel'), 'myansel_layout');
$layout = $blocks->getLayoutManager();
// Handle requested actions.
$layout->handle(Horde_Util::getFormData('action'), (int) Horde_Util::getFormData('row'), (int) Horde_Util::getFormData('col'));
if ($layout->updated()) {
    $prefs->setValue('myansel_layout', $layout->serialize());
    if (Horde_Util::getFormData('url')) {
        $url = new Horde_Url(Horde_Util::getFormData('url'));
        $url->unique()->redirect();
    }
}
$page_output->header(array('title' => _("My Photos :: Add Content")));
$notification->notify(array('listeners' => 'status'));
require $registry->get('templates', 'horde') . '/portal/edit.inc';
$page_output->footer();
Beispiel #28
0
 /**
  * Saves an event in the backend.
  *
  * @param Kronolith_Event $event  The event to save.
  *
  * @return string  The event id.
  * @throws Horde_Mime_Exception
  */
 protected function _saveEvent($event, $edit)
 {
     $this->synchronize();
     $action = $edit ? array('action' => 'modify') : array('action' => 'add');
     if (!$event->uid) {
         $event->uid = $this->_data->generateUID();
         $event->id = Horde_Url::uriB64Encode($event->uid);
     }
     $object = $event->toKolab();
     if ($edit) {
         $this->_data->modify($object);
     } else {
         $this->_data->create($object);
     }
     /* Deal with tags */
     if ($edit) {
         $this->_updateTags($event);
     } else {
         $this->_addTags($event);
     }
     /* Notify about the changed event. */
     Kronolith::sendNotification($event, $edit ? 'edit' : 'add');
     /* Log the creation/modification of this item in the history log. */
     try {
         $GLOBALS['injector']->getInstance('Horde_History')->log('kronolith:' . $event->calendar . ':' . $event->uid, $action, true);
     } catch (Exception $e) {
         Horde::log($e, 'ERR');
     }
     // refresh IMAP cache
     $this->synchronize(true);
     if (is_callable('Kolab', 'triggerFreeBusyUpdate')) {
         //Kolab::triggerFreeBusyUpdate($this->_data->parseFolder($event->calendar));
     }
     return $event->id;
 }
Beispiel #29
0
 /**
  */
 protected function _node($doc, $node)
 {
     parent::_node($doc, $node);
     if (empty($this->_imptmp) || !$node instanceof DOMElement) {
         if ($node instanceof DOMText && $node->length > 1) {
             /* Filter bad language. */
             $text = IMP::filterText($node->data);
             if ($node->data != $text) {
                 $node->replaceData(0, $node->length, $text);
             }
         }
         return;
     }
     $tag = Horde_String::lower($node->tagName);
     /* Remove 'height' styles from HTML messages, because it can break
      * sizing of IFRAME. */
     foreach ($node->attributes as $key => $val) {
         if ($key == 'style') {
             /* Do simplistic style parsing here. */
             $parts = array_filter(explode(';', $val->value));
             foreach ($parts as $k2 => $v2) {
                 if (preg_match("/^\\s*height:\\s*/i", $v2)) {
                     unset($parts[$k2]);
                 }
             }
             $val->value = implode(';', $parts);
         }
     }
     switch ($tag) {
         case 'a':
         case 'area':
             /* Convert links to open in new windows. Ignore mailto: links and
              * links that already have a target. */
             if ($node->hasAttribute('href')) {
                 $url = parse_url($node->getAttribute('href'));
                 if (isset($url['scheme']) && $url['scheme'] == 'mailto') {
                     /* We don't include HordePopup in IFRAME, so need to use
                      * 'simple' links. */
                     $clink = new IMP_Compose_Link($node->getAttribute('href'));
                     $node->setAttribute('href', $clink->link(true));
                     $node->removeAttribute('target');
                 } elseif (!empty($this->_imptmp['inline']) && isset($url['fragment']) && empty($url['path']) && $GLOBALS['browser']->isBrowser('mozilla')) {
                     /* See Bug #8695: internal anchors are broken in
                      * Mozilla. */
                     $node->removeAttribute('href');
                 } elseif (empty($url)) {
                     /* Empty URL - remove href/target so the link is not
                      * clickable. */
                     $node->removeAttribute('href');
                     $node->removeAttribute('target');
                 } else {
                     $node->setAttribute('target', strval(new Horde_Support_Randomid()));
                 }
             }
             break;
         case 'body':
             $style = $node->hasAttribute('style') ? rtrim($node->getAttribute('style'), ';') . ';' : '';
             $node->setAttribute('style', $style . 'width:auto !important');
             break;
         case 'img':
         case 'input':
             if ($node->hasAttribute('src')) {
                 $val = $node->getAttribute('src');
                 /* Multipart/related. */
                 if ($tag == 'img' && ($id = $this->_cidSearch($val))) {
                     $val = $this->getConfigParam('imp_contents')->urlView(null, 'view_attach', array('params' => array('ctype' => 'image/*', 'id' => $id, 'imp_img_view' => 'data')));
                 }
                 /* Block images.*/
                 if ($this->_imgBlock()) {
                     if (Horde_Url_Data::isData($val)) {
                         $url = new Horde_Url_Data($val);
                     } else {
                         /* Check for relative URLs. These won't be loaded and
                          * will cause unnecessary 404 hits to the local web
                          * server. */
                         $parsed_url = parse_url($val);
                         if (isset($parsed_url['host'])) {
                             $url = new Horde_Url($val);
                             $url->setScheme();
                         } else {
                             $url = null;
                         }
                     }
                     if ($url) {
                         $node->setAttribute(self::IMGBLOCK, $url);
                         $node->setAttribute('src', $this->_imgBlockImg());
                         $this->_imptmp['imgblock'] = true;
                     } else {
                         $node->parentNode->removeChild($node);
                         $this->_imptmp['imgbroken'] = true;
                     }
                 } else {
                     $node->removeAttribute('src');
                     $node->setAttribute('data-src', $val);
                 }
             }
             /* IMG only */
             if ($tag == 'img' && $this->_imgBlock() && $node->hasAttribute('srcset')) {
                 $node->setAttribute(self::SRCSETBLOCK, $node->getAttribute('srcset'));
                 $node->setAttribute('srcset', '');
                 $this->_imptmp['imgblock'] = true;
             }
             break;
         case 'link':
             /* Block all link tags that reference foreign URLs, other than
              * CSS. There's no inherently wrong with linking to a foreign
              * CSS file other than privacy concerns. Therefore, block
              * linking until requested by the user. */
             $delete_link = true;
             switch (Horde_String::lower($node->getAttribute('type'))) {
                 case 'text/css':
                     if ($node->hasAttribute('href')) {
                         $tmp = $node->getAttribute('href');
                         if ($id = $this->_cidSearch($tmp, false)) {
                             $this->_imptmp['style'][] = $this->getConfigParam('imp_contents')->getMIMEPart($id)->getContents();
                         } elseif ($this->_imgBlock()) {
                             $node->setAttribute(self::CSSBLOCK, $node->getAttribute('href'));
                             $node->removeAttribute('href');
                             $this->_imptmp['cssblock'] = true;
                             $delete_link = false;
                         }
                     }
                     break;
             }
             if ($delete_link && $node->hasAttribute('href') && $node->parentNode) {
                 $node->parentNode->removeChild($node);
             }
             break;
         case 'style':
             switch (Horde_String::lower($node->getAttribute('type'))) {
                 case 'text/css':
                     $this->_imptmp['style'][] = str_replace(array('<!--', '-->'), '', $node->nodeValue);
                     $node->parentNode->removeChild($node);
                     break;
             }
             break;
         case 'table':
             /* If displaying inline (in IFRAME), tables with 100% height seems
              * to confuse many browsers re: the IFRAME internal height. */
             if (!empty($this->_imptmp['inline']) && $node->hasAttribute('height') && $node->getAttribute('height') == '100%') {
                 $node->removeAttribute('height');
             }
             // Fall-through
         // Fall-through
         case 'body':
         case 'td':
             if ($node->hasAttribute('background')) {
                 $val = $node->getAttribute('background');
                 /* Multipart/related. */
                 if ($id = $this->_cidSearch($val)) {
                     $val = $this->getConfigParam('imp_contents')->urlView(null, 'view_attach', array('params' => array('id' => $id, 'imp_img_view' => 'data')));
                     $node->setAttribute('background', $val);
                 }
                 /* Block images.*/
                 if ($this->_imgBlock()) {
                     $node->setAttribute(self::IMGBLOCK, $val);
                     $node->setAttribute('background', $this->_imgBlockImg());
                     $this->_imptmp['imgblock'] = true;
                 }
             }
             break;
     }
     $remove = array();
     foreach ($node->attributes as $val) {
         /* Catch random mailto: strings in attributes that will cause
          * problems with e-mail linking. */
         if (stripos($val->value, 'mailto:') === 0) {
             $remove[] = $val->name;
         }
     }
     foreach ($remove as $val) {
         $node->removeAttribute($val);
     }
     if ($node->hasAttribute('style')) {
         if (strpos($node->getAttribute('style'), 'content:') !== false) {
             // TODO: Figure out way to unblock?
             $node->removeAttribute('style');
         } elseif (!empty($this->_imptmp['cid']) || $this->_imgBlock()) {
             $this->_imptmp['node'] = $node;
             $style = preg_replace_callback(self::CSS_BG_PREG, array($this, '_styleCallback'), $node->getAttribute('style'), -1, $matches);
             if ($matches) {
                 $node->setAttribute('style', $style);
             }
         }
     }
 }
Beispiel #30
0
require_once __DIR__ . '/lib/Application.php';
Horde_Registry::appInit('kronolith');
if (Kronolith::showAjaxView()) {
    Horde::url('', true)->redirect();
}
$c = Horde_Util::getFormData('calendar');
$driver = Horde_Util::getFormData('type');
$kronolith_driver = Kronolith::getDriver($driver, $c);
if ($eventID = Horde_Util::getFormData('eventID')) {
    try {
        $event = $kronolith_driver->getEvent($eventID);
    } catch (Exception $e) {
        if (($url = Horde_Util::getFormData('url')) === null) {
            $url = Horde::url($prefs->getValue('defaultview') . '.php', true);
        } else {
            $url = new Horde_Url($url);
        }
        $url->redirect();
    }
    if ($driver != 'resource') {
        if ($driver == 'remote') {
            /* The remote server is doing the permission checks for us. */
            $have_perms = true;
        } else {
            $share = $injector->getInstance('Kronolith_Shares')->getShare($event->calendar);
            if (!$share->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::DELETE, $event->creator)) {
                $notification->push(_("You do not have permission to delete this event."), 'horde.warning');
            } else {
                $have_perms = true;
            }
        }