Remove Horde::nocacheUrl().
* @param integer $row A layout row.
* @param integer $col A layout column.
*
- * @return string An URL with all necessary parameters.
+ * @return Horde_Url An URL with all necessary parameters.
*/
public function getActionUrl($action, $row, $col)
{
- return Horde_Util::addParameter(
- Horde::url($this->_editUrl),
- array('col' => $col,
- 'row' => $row,
- 'action' => $action,
- 'url' => $this->_viewUrl,
- 'nocache' => base_convert(microtime(), 10, 36))) . '#block';
+ return Horde::url($this->_editUrl)->unique()->setAnchor('block')->add(array(
+ 'col' => $col,
+ 'row' => $row,
+ 'action' => $action,
+ 'url' => $this->_viewUrl
+ ));
}
/**
*
* @param boolean $script_params Include script parameters like
* QUERY_STRING and PATH_INFO?
- * @param boolean $nocache Include a nocache parameter in the URL?
+ * @param boolean $nocache Include a cache-buster parameter in the
+ * URL?
* @param boolean $full Return a full URL?
* @param boolean $force_ssl Ignore $conf['use_ssl'] and force creation
* of a SSL URL?
$url = self::url($url, $full, 0, $force_ssl);
- return $nocache
- ? self::nocacheUrl($url)
+ return ($nocache && $GLOBALS['browser']->hasQuirk('cache_same_url'))
+ ? $url->unique()
: $url;
}
/**
- * Returns a url with the 'nocache' parameter added, if the browser is
- * buggy and caches old URLs.
- *
- * @param Horde_Url|string $url The URL to modify.
- *
- * @return Horde_Url The requested URL.
- */
- static public function nocacheUrl($url)
- {
- if (!$url instanceof Horde_Url) {
- $url = new Horde_Url($url);
- }
-
- /* We may need to set a dummy parameter 'nocache' since some
- * browsers do not always honor the 'no-cache' header. */
- if ($GLOBALS['browser']->hasQuirk('cache_same_url')) {
- $url->add('nocache', uniqid());
- }
-
- return $url;
- }
-
- /**
* Constructs a correctly-pathed link to an image.
*
* @param mixed $src The image file (either a string or a
<api>beta</api>
</stability>
<license uri="http://www.gnu.org/copyleft/lesser.html">LGPL</license>
- <notes>* Absorb horde/Ui package.
+ <notes>* Remove Horde::nocacheUrl.
+ * Absorb horde/Ui package.
* Absorb horde/Ajax package.
* Import application auth driver from horde/Auth.
* Import signup code from horde/Auth.
}
/**
+ * Add a unique parameter to the URL to aid in cache-busting.
+ *
+ * @return Horde_Url This (modified) object, to allow chaining.
+ */
+ public function unique()
+ {
+ return $this->add('u', uniqid(mt_rand()));
+ }
+
+ /**
* URL-safe base64 encoding, with trimmed '='.
*
* @param string $string String to encode.
<api>beta</api>
</stability>
<license uri="http://www.gnu.org/copyleft/lesser.html">LGPL</license>
- <notes>* Add support for callback function for toString conversion.
+ <notes>* Add Horde_Url::unique().
+ * Add support for callback function for toString conversion.
* Add support for URL anchors.
* Added Horde_Url::uriB64Encode() and Horde_Url::uriB64Decode().
* Initial package.
/* Set up the base template now. */
$t = $injector->createInstance('Horde_Template');
$t->setOption('gettext', true);
-$t->set('post_action', Horde::applicationUrl('compose.php')->add('uniq', uniqid(mt_rand())));
+$t->set('post_action', Horde::applicationUrl('compose.php')->unique());
$t->set('allow_compose', !$compose_disable);
if ($redirect) {
$template = $injector->createInstance('Horde_Template');
$template->setOption('gettext', true);
-$template->set('action', Horde::applicationUrl('contacts.php')->add(array('uniq' => uniqid(mt_rand()))));
+$template->set('action', Horde::applicationUrl('contacts.php')->unique());
$template->set('formname', $vars->formname);
$template->set('formInput', Horde_Util::formInput());
$template->set('search', htmlspecialchars($vars->search));
}
if ($conf['user']['allow_folders']) {
- $menu->add(Horde::nocacheUrl(Horde::applicationUrl('folders.php')), _("_Folders"), 'folders/folder.png');
+ $menu->add(Horde::applicationUrl('folders.php')->unique(), _("_Folders"), 'folders/folder.png');
}
if ($_SESSION['imp']['protocol'] != 'pop') {
}
if (!in_array($page, array('compose', 'search')) && IMP::canCompose()) {
- $items[] = array(_("New Message"), Horde::applicationUrl('compose-mimp.php')->add('u', uniqid(mt_rand())));
+ $items[] = array(_("New Message"), Horde::applicationUrl('compose-mimp.php')->unique());
}
if (!in_array($page, array('folders', 'search'))) {
}
// Make sure URL is unique.
-header('Location: ' . $url->add('unique', hash('md5', microtime())));
+header('Location: ' . $url->unique());
}
// Make sure URL is unique.
- header('Location: ' . $url->add('unique', hash('md5', microtime())));
+ header('Location: ' . $url->unique());
exit;
case 'clear':
}
// Make sure URL is unique.
-header('Location: ' . $url->add('unique', hash('md5', microtime())));
+header('Location: ' . $url->unique());
}
// Make sure URL is unique.
-header('Location: ' . $url->add('unique', hash('md5', microtime())));
+header('Location: ' . $url->unique());
} else {
$url = Horde::applicationUrl($prefs->getValue('defaultview') . '.php', true);
}
- header('Location: ' . $url->add('unique', hash('md5', microtime())));
+ header('Location: ' . $url->unique());
exit;
}
break;
//-->
</script>
-<form method="post" name="contacts" onsubmit="passAddresses();" action="contacts.php?nocache=<?php echo hash('md5', mt_rand()) ?>">
+<form method="post" name="contacts" onsubmit="passAddresses();" action="<?php echo Horde::applicationUrl('contacts.php')->unique() ?>">
<input type="hidden" name="sa" />
<?php Horde_Util::pformInput() ?>
} else {
$url = new Horde_Url($url, true);
}
- header('Location: ' . $url->add('unique', hash('md5', microtime())));
+ header('Location: ' . $url->unique());
exit;
}
$driver = Turba_Driver::singleton($source);
if ($url = Horde_Util::getFormData('url')) {
- $url = new Horde_Url($url, true);
- $url->add('unique', hash('md5', microtime()));
+ $url = new Horde_Url($url, true)->unique();
}
$contact = $driver->getObject($mergeInto);