*/
static public function getServiceLink($type, $app = null)
{
- $webroot = $GLOBALS['registry']->get('webroot', 'horde');
+ $opts = array('app' => 'horde');
switch ($type) {
case 'ajax':
- return self::url($webroot . '/services/ajax.php/' . $app . '/')
+ return self::url('services/ajax.php/' . $app . '/', false, $opts)
->remove('ajaxui');
case 'cache':
- return self::url($webroot . '/services/cache.php', false, -1);
+ $opts['append_session'] = -1;
+ return self::url('services/cache.php', false, $opts);
case 'download':
- return self::url($webroot . '/services/download/')
+ return self::url('services/download/', false, $opts)
->add('module', $app);
case 'emailconfirm':
- return self::url($webroot . '/services/confirm.php');
+ return self::url('services/confirm.php', false, $opts);
case 'go':
- return self::url($webroot . '/services/go.php')
+ return self::url('services/go.php', false, $opts)
->remove('ajaxui');
case 'help':
- return self::url($webroot . '/services/help/')
+ return self::url('services/help/', false, $opts)
->add('module', $app);
case 'imple':
- return self::url($webroot . '/services/imple.php')->
- remove('ajaxui');
+ return self::url('services/imple.php', false, $opts)
+ ->remove('ajaxui');
case 'login':
- return self::url($webroot . '/login.php');
+ return self::url('login.php', false, $opts);
case 'logintasks':
- return self::url($webroot . '/services/logintasks.php')
+ return self::url('services/logintasks.php', false, $opts)
->add('app', $app);
case 'logout':
case 'options':
case 'prefsapi':
if (!in_array($GLOBALS['conf']['prefs']['driver'], array('', 'none'))) {
- $url = self::url($webroot . ($type == 'options' ? '/services/prefs.php' : '/services/prefs/'));
+ $url = self::url(($type == 'options') ? 'services/prefs.php' : 'services/prefs/', false, $opts);
if (!is_null($app)) {
$url->add('app', $app);
}
break;
case 'problem':
- return self::url($webroot . '/services/problem.php')
+ return self::url('services/problem.php', false, $opts)
->add('return_url', urlencode(self::selfUrl(true, true, true)));
case 'sidebar':
- return self::url($webroot . '/services/sidebar.php');
+ return self::url('services/sidebar.php', false, $opts);
}
return false;
* If a full URL is requested, all parameter separators get converted to
* "&", otherwise to "&".
*
- * @param mixed $uri The URI to be modified (either a string
- * or any object with a __toString()
- * function).
- * @param boolean $full Generate a full (http://server/path/)
- * URL.
- * @param integer $append_session 0 = only if needed, 1 = always, -1 =
- * never.
- * @param boolean $force_ssl Ignore $conf['use_ssl'] and force
- * creation of a SSL URL?
+ * @param mixed $uri The URI to be modified (either a string or any
+ * object with a __toString() function).
+ * @param boolean $full Generate a full (http://server/path/) URL.
+ * @param mixed $opts Additional options. If a string/integer, it is
+ * taken to be the 'append_session' option. If an
+ * array, one of the following:
+ * <pre>
+ * 'app' - (string) Use this app for the webroot.
+ * DEFAULT: current application
+ * 'append_session' - (integer) 0 = only if needed [DEFAULT], 1 = always,
+ * -1 = never.
+ * 'force_ssl' - (boolean) Ignore $conf['use_ssl'] and force creation of a
+ * SSL URL?
+ * DEFAULT: false
+ * </pre>
*
* @return Horde_Url The URL with the session id appended (if needed).
*/
- static public function url($uri, $full = false, $append_session = 0,
- $force_ssl = false)
+ static public function url($uri, $full = false, $opts = array())
{
- if ($force_ssl) {
- $full = true;
+ if (is_array($opts)) {
+ $append_session = isset($opts['append_session'])
+ ? $opts['append_session']
+ : 0;
+ if (!empty($opts['force_ssl'])) {
+ $full = true;
+ }
+ } else {
+ $append_session = $opts;
+ $opts = array();
}
$url = '';
- $webroot = $GLOBALS['registry']->get('webroot');
+ $webroot = $GLOBALS['registry']->get('webroot', empty($opts['app']) ? null : $opts['app']);
/* Skip if we already have a full URL. */
if ($full && !preg_match('|^([\w+-]{1,20})://|', $webroot)) {
case 3:
$server_port = '';
- if ($force_ssl) {
+ if (!empty($opts['force_ssl'])) {
$protocol = 'https';
}
break;
}
}
- $url = self::url($url, $full, 0, $force_ssl);
+ $url = self::url($url, $full, array('force_ssl' => $force_ssl));
return ($nocache && $GLOBALS['browser']->hasQuirk('cache_same_url'))
? $url->unique()
/* If we can send as data, no need to get the full path */
$src = self::base64ImgData($src);
if (substr($src, 0, 10) != 'data:image') {
- $src = self::url($src, true, -1);
+ $src = self::url($src, true, array('append_session' => -1));
}
$img = '<img';
/* Set up some node params. */
$spacer = ' ';
$group_node = array('icon' => strval(Horde_Themes::img('group.png')));
-$add = Horde::url('admin/groups.php?actionID=addchild');
+$group_url = Horde::url('admin/groups.php');
+$add = $group_url->copy()->add('actionID', 'addchild');
$add_img = Horde::img('add_group.png');
-$edit = Horde::url('admin/groups.php?actionID=edit');
-$delete = Horde::url('admin/groups.php?actionID=delete');
+$edit = $group_url->copy()->add('actionID', 'edit');
+$delete = $group_url->copy()->add('actionID', 'delete');
$edit_img = Horde::img('edit.png', _("Edit Group"));
$delete_img = Horde::img('delete.png', _("Delete Group"));
// "\n\n" .
// $this->_signup_queued_walkdata($extraFields, $data) .
// "\n" .
-// sprintf(_("You can approve this signup at %s"), Horde::url('admin/user.php', true, -1));
+// sprintf(_("You can approve this signup at %s"), Horde::url('admin/user.php', true, array('append_session' => -1)));
//
// $GLOBALS['injector']->getInstance('Horde_Mail')->send($_SERVER['SERVER_ADMIN'], $headers, $msg);
// }
try {
$facebook = $GLOBALS['injector']->getInstance('Horde_Service_Facebook');
} catch (Horde_Exception $e) {
- Horde::url($registry->get('webroot', 'horde') . '/index.php')->redirect();
+ Horde::url('index.php', false, array('app' => 'horde'))->redirect();
}
/* See why we are here. */
$uid = $facebook->auth->getUser();
$prefs->setValue('facebook', serialize(array('uid' => $uid, 'sid' => $sid)));
$notification->push(_("Succesfully connected your Facebook account."), 'horde.success');
- Horde::url('services/prefs.php', true)->add(array('group' => 'facebook', 'app' => 'horde'))->redirect();
+ Horde::url('services/prefs.php', true)->add(array('group' => 'facebook', 'app' => 'horde'))->redirect();
}
} else {
// Set the name/link.
if (!empty($values['browseable'])) {
- $url = Horde::url($registry->get('webroot', 'horde') . '/services/obrowser/');
- $url = Horde_Util::addParameter($url, 'path', $path);
- $row['name'] = Horde::link($url) . htmlspecialchars($values['name']) . '</a>';
+ $url = Horde::url('services/obrowser', false, array('app' => 'horde'))->add('path', $path);
+ $row['name'] = $url->link() . htmlspecialchars($values['name']) . '</a>';
} else {
$js = "return chooseObject('" . addslashes($path) . "');";
$row['name'] = Horde::link('#', sprintf(_("Choose %s"), $values['name']), '', '', $js) . htmlspecialchars($values['name']) . '</a>';
$links = array();
foreach ($registry->listApps() as $app) {
if ($registry->hasMobileView($app)) {
- $links[htmlspecialchars($registry->get('name', $app))] = Horde::url($registry->get('webroot', $app) . '/');
+ $links[htmlspecialchars($registry->get('name', $app))] = Horde::url('/', false, array('app' => $app));
}
}
/* Send the browser back to the correct page. */
function _returnToPage()
{
- $url = new Horde_Url(Horde_Util::getFormData('return_url', Horde::url($GLOBALS['registry']->get('webroot', 'horde') . '/login.php', true)));
+ $url = new Horde_Url(Horde_Util::getFormData('return_url', Horde::url('login.php', true, array('app' => 'horde'))));
$url->redirect();
}
Horde_Registry::appInit('horde');
if (empty($conf['twitter']['enabled'])) {
- Horde::url($registry->get('webroot', 'horde') . '/index.php')->redirect();
+ Horde::url('index.php', false, array('app' => 'horde'))->redirect();
}
$twitter = $GLOBALS['injector']->getInstance('Horde_Service_Twitter');
<?php
$remove = $auth->hasCapability('remove');
$total = 0;
+$admin_url = Horde::url('user.php');
+
foreach ($users as $user):
if ($total++ < $min || $total > $max) {
continue;
}
+ $user_url = $admin_url->copy()->add('user_name', $user);
?>
<tr>
<?php if ($remove): ?>
- <td width="1%"><?php echo Horde::link(Horde::url('admin/user.php?form=remove_f&user_name=' . $user), _("Delete")) . Horde::img('delete.png', _("Delete")) ?></a></td>
+ <td width="1%"><?php echo Horde::link($user_url->add('form', 'remove_f'), _("Delete")) . Horde::img('delete.png', _("Delete")) ?></a></td>
<?php endif; ?>
- <td width="1%"><?php echo Horde::link(Horde::url('admin/user.php?form=update_f&user_name=' . $user), _("Update")) . Horde::img('edit.png', _("Update")) ?></a></td>
- <td width="1%"><?php echo Horde::link(Horde::url('admin/user.php?form=clear_f&user_name=' . $user), _("Clear user data")) . Horde::img('reload.png', _("Clear user data")) ?></a></td>
+ <td width="1%"><?php echo Horde::link($user_url->add('form', 'update_f'), _("Update")) . Horde::img('edit.png', _("Update")) ?></a></td>
+ <td width="1%"><?php echo Horde::link($user_url->add('form', 'clear_f'), _("Clear user data")) . Horde::img('reload.png', _("Clear user data")) ?></a></td>
<td class="leftAlign"><?php echo $user ?></td>
</tr>
<?php endforeach; ?>
<tr>
<td> </td>
<td class="light leftAlign">
- <?php echo Horde::link(Horde::url($registry->get('webroot', 'horde') . '/signup.php')->add('url', $vars->url), _("Don't have an account? Sign up."), 'light') . _("Don't have an account? Sign up.") ?></a>
+ <?php echo Horde::link(Horde::url('signup.php', false, array('app' => 'horde'))->add('url', $vars->url), _("Don't have an account? Sign up."), 'light') . _("Don't have an account? Sign up.") ?></a>
</td>
</tr>
<?php endif; ?>
<tr>
<td> </td>
<td class="light">
- <?php echo Horde::link(Horde::url($registry->get('webroot', 'horde') . '/services/resetpassword.php')->add('url', $vars->url), _("Forgot your password?"), 'light') . _("Forgot your password?") ?></a>
+ <?php echo Horde::link(Horde::url('services/resetpassword.php', false, array('app' => 'horde'))->add('url', $vars->url), _("Forgot your password?"), 'light') . _("Forgot your password?") ?></a>
</td>
</tr>
<?php endif; ?>
// // name.
// if ((stripos($mailbox, "INBOX/Calendar") !== false) ||
// preg_match("!^user/[^/]+/Calendar!", $mailbox)) {
-// return $GLOBALS['registry']->get('webroot', 'kronolith');
+// return Horde::url('', false, array('app' => 'kronolith'));
// } elseif ((stripos($mailbox, "INBOX/Tasks") !== false) ||
// preg_match("!^user/[^/]+/Tasks!", $mailbox)) {
-// return $GLOBALS['registry']->get('webroot', 'nag');
+// return Horde::url('', false, array('app' => 'nag'));
// } elseif ((strpos($mailbox, "INBOX/Notes") !== false) ||
// preg_match("!^user/[^/]+/Notes!", $mailbox)) {
-// return $GLOBALS['registry']->get('webroot', 'mnemo');
+// return Horde::url('', false, array('app' => 'mnemo'));
// } elseif ((strpos($mailbox, "INBOX/Contacts") !== false) ||
// preg_match("!^user/[^/]+/Contacts!", $mailbox)) {
-// return $GLOBALS['registry']->get('webroot', 'turba');
+// return Horde::url('', false, array('app' => 'turba'));
// }
//
// return '';
// require_once 'Horde/Kolab.php';
// switch (Kolab::getMailboxType($mailbox)) {
// case 'event':
-// return $GLOBALS['registry']->get('webroot', 'kronolith');
+// return Horde::url('', false, array('app' => 'kronolith'));
//
// case 'task':
-// return $GLOBALS['registry']->get('webroot', 'nag');
+// return Horde::url('', false, array('app' => 'nag'));
//
// case 'note':
-// return $GLOBALS['registry']->get('webroot', 'mnemo');
+// return Horde::url('', false, array('app' => 'mnemo'));
//
// case 'contact':
-// return $GLOBALS['registry']->get('webroot', 'turba');
+// return Horde::url('', false, array('app' => 'turba'));
//
// case 'prefs':
// return Horde::getServiceLink('options', 'horde');
/* Image filtering. */
if ($this->_imptmp['img']) {
- $this->_imptmp['blockimg'] = Horde::url(Horde_Themes::img('spacer_red.png'), true, -1);
+ $this->_imptmp['blockimg'] = Horde::url(Horde_Themes::img('spacer_red.png'), true, array('append_session' => -1));
}
/* Search for inlined images that we can display
'title' => $imp_ui->getSubject($ob['envelope']['subject']),
'pubDate' => date('r', strtotime($ob['envelope']['date'])),
'description' => isset($ob['preview']) ? $ob['preview'] : '',
- 'url' => Horde::url(IMP::generateIMPUrl('message.php', $mailbox, $ob['uid'], $mailbox), true, -1),
+ 'url' => Horde::url(IMP::generateIMPUrl('message.php', $mailbox, $ob['uid'], $mailbox), true, array('append_session' => -1)),
'fromAddr' => $from_addr['fullfrom'],
'toAddr' => Horde_Mime_Address::addrArray2String(isset($ob['envelope']['to']) ? $ob['envelope']['to'] : array(), array('charset' => $registry->getCharset()))
));
$t->set('desc', htmlspecialchars($description));
$t->set('title', htmlspecialchars($registry->get('name') . ' - ' . IMP::getLabel($mailbox)));
$t->set('items', $items, true);
-$t->set('url', htmlspecialchars(Horde::url(IMP::generateIMPUrl('message.php', $mailbox), true, -1)));
-$t->set('rss_url', htmlspecialchars(Horde::url('rss.php', true, -1)));
+$t->set('url', htmlspecialchars(Horde::url(IMP::generateIMPUrl('message.php', $mailbox), true, array('append_session' => -1))));
+$t->set('rss_url', htmlspecialchars(Horde::url('rss.php', true, array('append_session' => -1))));
$browser->downloadHeaders('mailbox.rss', 'text/xml', true);
echo $t->fetch(IMP_TEMPLATES . '/rss/mailbox.rss');
);
$_prefs['fb_url'] = array(
- 'value' => '<strong>' . _("My Free/Busy URL") . '</strong><div class="fburl"><div>' . _("Copy this URL for use wherever you need your Free/Busy URL:") . '</div><div class="fixed">' . Horde::url('fb.php', true, -1)->add('u', $GLOBALS['registry']->getAuth()) . '</div></div>',
+ 'value' => '<strong>' . _("My Free/Busy URL") . '</strong><div class="fburl"><div>' . _("Copy this URL for use wherever you need your Free/Busy URL:") . '</div><div class="fixed">' . Horde::url('fb.php', true, array('append_session' => -1))->add('u', $GLOBALS['registry']->getAuth()) . '</div></div>',
'type' => 'rawhtml'
);