Author: Michael Slusarz (slusarz@horde.org)
Inheritance: extends Horde_Url
Example #1
0
 /**
  */
 protected function _initPages()
 {
     global $injector;
     $this->view->list = array();
     if ($GLOBALS['browse_source_count']) {
         foreach (Turba::getAddressBooks() as $key => $val) {
             if (!empty($val['browse'])) {
                 try {
                     $driver = $injector->getInstance('Turba_Factory_Driver')->create($key);
                 } catch (Turba_Exception $e) {
                     continue;
                 }
                 try {
                     $contacts = $driver->search(array(), null, 'AND', array('__key', 'name'));
                     $contacts->reset();
                 } catch (Turba_Exception $e) {
                     continue;
                 }
                 $url = new Horde_Core_Smartmobile_Url();
                 $url->add('source', $key);
                 $url->setAnchor('entry');
                 $tmp = array();
                 while ($contact = $contacts->next()) {
                     $name = Turba::formatName($contact);
                     $tmp[] = array('group' => $contact->isGroup(), 'name' => strlen($name) ? $name : '[' . _("No Name") . ']', 'url' => strval($url->add('key', $contact->getValue('__key'))));
                 }
                 $this->view->list[$val['title']] = $tmp;
             }
         }
     }
 }
Example #2
0
 /**
  * Returns the appropriate link to call the message composition script.
  *
  * @param string $simplejs  Use simple JS (instead of HordePopup JS)?
  *
  * @return Horde_Url  The link to the message composition script.
  */
 public function link($simplejs = false)
 {
     global $browser, $prefs, $registry;
     $args = $this->args;
     $callback = $raw = false;
     $view = $registry->getView();
     if ($view == Horde_Registry::VIEW_SMARTMOBILE) {
         $url = new Horde_Core_Smartmobile_Url(Horde::url('smartmobile.php'));
         $url->setAnchor('compose');
     } elseif ($simplejs || $view == Horde_Registry::VIEW_DYNAMIC) {
         $args['popup'] = 1;
         $url = $view == Horde_Registry::VIEW_DYNAMIC ? IMP_Dynamic_Compose::url() : IMP_Basic_Compose::url();
         $raw = true;
         $callback = array($this, 'composeLinkSimpleCallback');
     } elseif ($view != Horde_Registry::VIEW_MINIMAL && $prefs->getValue('compose_popup') && $browser->hasFeature('javascript')) {
         $url = IMP_Basic_Compose::url();
         $callback = array($this, 'composeLinkJsCallback');
     } else {
         $url = $view == Horde_Registry::VIEW_MINIMAL ? IMP_Minimal_Compose::url() : IMP_Basic_Compose::url();
     }
     if (isset($args['mailbox'])) {
         $url = IMP_Mailbox::get($args['mailbox'])->url($url, $args['buid']);
         unset($args['buid'], $args['mailbox']);
     } elseif (!$url instanceof Horde_Url) {
         $url = Horde::url($url);
     }
     $url->setRaw($raw)->add($args);
     if ($callback) {
         $url->toStringCallback = $callback;
     }
     return $url;
 }
Example #3
0
File: Link.php Project: horde/horde
 /**
  * Returns the appropriate link to call the message composition script.
  *
  * @return Horde_Url  The link to the message composition script.
  */
 public function link()
 {
     global $registry;
     $args = $this->args;
     $callback = $raw = false;
     switch ($registry->getView()) {
         case Horde_Registry::VIEW_MINIMAL:
         case Horde_Registry::VIEW_SMARTMOBILE:
             $url = new Horde_Core_Smartmobile_Url(Horde::url('smartmobile.php'));
             $url->setAnchor('compose');
             break;
         default:
             $url = IMP_Dynamic_Compose::url();
             $raw = true;
             $callback = array($this, 'composeLinkSimpleCallback');
             break;
     }
     if (isset($args['mailbox'])) {
         $url = IMP_Mailbox::get($args['mailbox'])->url($url, $args['buid']);
         unset($args['buid'], $args['mailbox']);
     } elseif (!$url instanceof Horde_Url) {
         $url = Horde::url($url);
     }
     $url->setRaw($raw)->add($args);
     if ($callback) {
         $url->toStringCallback = $callback;
     }
     return $url;
 }
Example #4
0
 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);
 }
Example #5
0
 /**
  * AJAX action: Get entry data.
  *
  * Variables used:
  *   - key: (string) UID of entry.
  *   - source: (string) UID of source addressbook.
  *
  * @return object  TODO
  *   - entry: (array)
  *   - error: (boolean)
  *   - group: (array)
  */
 public function smartmobileEntry()
 {
     global $attributes, $cfgSources, $injector, $notification, $registry;
     $contact = null;
     $out = new stdClass();
     $source = $this->vars->get('source');
     if (isset($cfgSources[$source])) {
         try {
             $contact = $injector->getInstance('Turba_Factory_Driver')->create($source)->getObject($this->vars->get('key'));
         } catch (Horde_Exception $e) {
         }
     }
     if (is_null($contact)) {
         $notification->push(_("Addressbook entry could not be loaded."), 'horde.error');
         $out->error = true;
         return $out;
     }
     $out->entry = array();
     if (!count($tabs = $contact->driver->tabs)) {
         $tabs = array(_("Entries") => array_keys($contact->driver->getCriteria()));
     }
     foreach ($tabs as $key => $val) {
         foreach ($val as $val2) {
             if (strlen($val3 = $contact->getValue($val2))) {
                 $url = null;
                 switch ($val2) {
                     case 'email':
                     case 'emails':
                         $addrs = $GLOBALS['injector']->getInstance('Horde_Mail_Rfc822')->parseAddressList($val3, array('limit' => $val2 == 'emails' ? 0 : 1));
                         foreach ($addrs as $addr) {
                             $addr = $addr->writeAddress(true);
                             try {
                                 $url = strval($registry->call('mail/compose', array(array('to' => $addr))));
                             } catch (Horde_Exception $e) {
                             }
                             $out->entry[$key][] = array_filter(array('l' => $attributes[$val2]['label'], 'u' => $url, 'v' => $addr));
                         }
                         continue 2;
                 }
                 $out->entry[$key][] = array_filter(array('l' => $attributes[$val2]['label'], 'u' => $url, 'v' => $val3));
             }
         }
     }
     if ($contact->isGroup()) {
         $members = $contact->listMembers();
         $members->reset();
         $url = new Horde_Core_Smartmobile_Url();
         $url->setAnchor('entry');
         $out->group = array('l' => _("Contact List Members"), 'm' => array());
         while ($ob = $members->next()) {
             $out->group['m'][] = array('n' => strlen($name = Turba::formatName($ob)) ? $name : '[' . _("No Name") . ']', 'u' => strval($url->copy()->setRaw(true)->add(array('key' => $ob->getValue('__key'), 'source' => $ob->getSource()))));
         }
     }
     return $out;
 }
Example #6
0
 /**
  */
 protected function _initPages()
 {
     global $injector, $session;
     $this->view->list = array();
     $filters = Ingo_Storage_FilterIterator_Match::create($injector->getInstance('Ingo_Factory_Storage')->create(), $session->get('ingo', 'script_categories'));
     foreach ($filters as $val) {
         // Skip disabled rules.
         if ($val->disable) {
             continue;
         }
         switch (get_class($val)) {
             case 'Ingo_Rule_System_Blacklist':
                 $img = 'blacklist.png';
                 break;
             case 'Ingo_Rule_System_Whitelist':
                 $img = 'whitelist.png';
                 break;
             case 'Ingo_Rule_System_Vacation':
                 $img = 'vacation.png';
                 break;
             case 'Ingo_Rule_System_Forward':
                 $img = 'forward.png';
                 break;
             case 'Ingo_Rule_System_Spam':
                 $img = 'spam.png';
                 break;
             default:
                 $img = null;
                 break;
         }
         $url = new Horde_Core_Smartmobile_Url();
         $url->add('uid', $val->uid);
         $url->setAnchor('rule');
         $this->view->list[] = array('img' => is_null($img) ? null : Horde_Themes_Image::tag($img, array('attr' => array('class' => 'ui-li-icon'))), 'name' => $val->name, 'url' => $url);
     }
 }
Example #7
0
 /**
  */
 protected function _initPages()
 {
     global $injector, $session;
     $this->view->list = array();
     $filters = $injector->getInstance('Ingo_Factory_Storage')->create()->retrieve(Ingo_Storage::ACTION_FILTERS)->getFilterList();
     $s_categories = $session->get('ingo', 'script_categories');
     foreach ($filters as $key => $val) {
         // For now, skip non-display categories and disabled rules.
         if (!empty($val['disable']) || !in_array($val['action'], $s_categories)) {
             continue;
         }
         switch ($val['action']) {
             case Ingo_Storage::ACTION_BLACKLIST:
                 $img = 'blacklist.png';
                 $name = _("Blacklist");
                 break;
             case Ingo_Storage::ACTION_WHITELIST:
                 $img = 'whitelist.png';
                 $name = _("Whitelist");
                 break;
             case Ingo_Storage::ACTION_VACATION:
                 $img = 'vacation.png';
                 $name = _("Vacation");
                 break;
             case Ingo_Storage::ACTION_FORWARD:
                 $img = 'forward.png';
                 $name = _("Forward");
                 break;
             case Ingo_Storage::ACTION_SPAM:
                 $img = 'spam.png';
                 $name = _("Spam Filter");
                 break;
             default:
                 $img = null;
                 $name = $val['name'];
                 break;
         }
         $url = new Horde_Core_Smartmobile_Url();
         $url->add('rulenum', $key);
         $url->setAnchor('rule');
         $this->view->list[] = array('img' => is_null($img) ? null : Horde_Themes_Image::tag($img, array('attr' => array('class' => 'ui-li-icon'))), 'name' => $name, 'url' => $url);
     }
 }
Example #8
0
 /**
  * Creates a Horde_Tree representation of the current tree.
  *
  * @param string|Horde_Tree $name  Either the tree name, or a Horde_Tree
  *                                 object to add nodes to.
  * @param array $opts              Additional options:
  *   - basename: (boolean) Use raw basename instead of abbreviated label?
  *               DEFAULT: false
  *   - checkbox: (boolean) Display checkboxes?
  *               DEFAULT: false
  *   - editvfolder: (boolean) Display vfolder edit links?
  *                  DEFAULT: false
  *   - iterator: (Iterator) Tree iterator to use.
  *               DEFAULT: Base iterator.
  *   - open: (boolean) Force child mailboxes to this status.
  *           DEFAULT: null
  *   - parent: (string) The parent object of the current level.
  *             DEFAULT: null (add to base level)
  *   - poll_info: (boolean) Include poll information in output?
  *                DEFAULT: false
  *   - render_params: (array) List of params to pass to renderer if
  *                    auto-creating.
  *                    DEFAULT: 'alternate', 'lines', and 'lines_base'
  *                             are passed in with true values.
  *   - render_type: (string) The renderer name.
  *                  DEFAULT: Javascript
  *
  * @return Horde_Tree  The tree object.
  */
 public function createTree($name, array $opts = array())
 {
     global $injector, $registry;
     $opts = array_merge(array('parent' => null, 'render_params' => array(), 'render_type' => 'Javascript'), $opts);
     $view = $registry->getView();
     if ($name instanceof Horde_Tree_Renderer_Base) {
         $tree = $name;
         $parent = $opts['parent'];
     } else {
         $tree = $injector->getInstance('Horde_Core_Factory_Tree')->create($name, $opts['render_type'], array_merge(array('alternate' => true, 'lines' => true, 'lines_base' => true, 'nosession' => true), $opts['render_params']));
         $parent = null;
     }
     $iterator = empty($opts['iterator']) ? new IMP_Ftree_IteratorFilter($this) : $opts['iterator'];
     foreach ($iterator as $val) {
         $after = '';
         $elt_parent = null;
         $mbox_ob = $val->mbox_ob;
         $params = array();
         switch ($opts['render_type']) {
             case 'IMP_Tree_Flist':
                 if ($mbox_ob->vfolder_container) {
                     continue 2;
                 }
                 $is_open = true;
                 $label = $params['orig_label'] = empty($opts['basename']) ? $mbox_ob->abbrev_label : $mbox_ob->basename;
                 break;
             case 'IMP_Tree_Jquerymobile':
                 $is_open = true;
                 $label = $mbox_ob->display_html;
                 $icon = $mbox_ob->icon;
                 $params['icon'] = $icon->icon;
                 $params['special'] = $mbox_ob->inbox || $mbox_ob->special;
                 $params['class'] = 'imp-folder';
                 $params['urlattributes'] = array('id' => 'imp-mailbox-' . $mbox_ob->form_to);
                 /* Force to flat tree so that non-polled parents don't cause
                  * polled children to be skipped by renderer (see Bug
                  * #11238). */
                 $elt_parent = $this[self::BASE_ELT];
                 break;
             case 'Javascript':
                 $is_open = $val->open;
                 $label = empty($opts['basename']) ? htmlspecialchars($mbox_ob->abbrev_label) : htmlspecialchars($mbox_ob->basename);
                 $icon = $mbox_ob->icon;
                 $params['icon'] = $icon->icon;
                 $params['iconopen'] = $icon->iconopen;
                 break;
         }
         if (!empty($opts['poll_info']) && $val->polled) {
             $poll_info = $mbox_ob->poll_info;
             if ($poll_info->unseen) {
                 switch ($opts['render_type']) {
                     case 'IMP_Tree_Jquerymobile':
                         $after = $poll_info->unseen;
                         break;
                     default:
                         $label = '<strong>' . $label . '</strong>&nbsp;(' . $poll_info->unseen . ')';
                 }
             }
         }
         if ($val->container) {
             $params['container'] = true;
         } else {
             switch ($view) {
                 case $registry::VIEW_SMARTMOBILE:
                     $url = new Horde_Core_Smartmobile_Url();
                     $url->add('mbox', $mbox_ob->form_to);
                     $url->setAnchor('mailbox');
                     $params['url'] = strval($url);
                     break;
                 default:
                     $params['url'] = $mbox_ob->url('mailbox')->setRaw(true);
                     break;
             }
             if (!$val->subscribed) {
                 $params['class'] = 'mboxunsub';
             }
         }
         $checkbox = empty($opts['checkbox']) ? '' : '<input type="checkbox" class="checkbox" name="mbox_list[]" value="' . $mbox_ob->form_to . '"';
         if ($val->nonimap) {
             $checkbox .= ' disabled="disabled"';
         }
         if ($val->vfolder && !empty($opts['editvfolder']) && $val->container) {
             $after = '&nbsp[' . $registry->getServiceLink('prefs', 'imp')->add('group', 'searches')->link(array('title' => _("Edit Virtual Folder"))) . _("Edit") . '</a>' . ']';
         }
         if (is_null($elt_parent)) {
             $elt_parent = $val->parent;
         }
         $tree->addNode(array('id' => $mbox_ob->form_to, 'parent' => $elt_parent->base_elt ? $parent : $elt_parent->mbox_ob->form_to, 'label' => $label, 'expanded' => isset($opts['open']) ? $opts['open'] : $is_open, 'params' => $params, 'right' => $after, 'left' => empty($opts['checkbox']) ? null : $checkbox . ' />'));
     }
     return $tree;
 }
Example #9
0
<?php

/**
 * Nag index script.
 *
 * Copyright 2001-2016 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('nag');
switch ($registry->getView()) {
    case $registry::VIEW_SMARTMOBILE:
        $url = new Horde_Core_Smartmobile_Url(Horde::url('smartmobile.php'));
        $url->setAnchor('nag-list')->redirect();
        break;
    default:
        require __DIR__ . '/list.php';
        break;
}