'qsearch' => Horde_Util::getPost('qsearch'),
'qsearchflag' => Horde_Util::getPost('qsearchflag'),
'qsearchmbox' => Horde_Util::getPost('qsearchmbox'),
- 'qsearchflagnot' => Horde_Util::getPost('qsearchflagnot')
+ 'qsearchflagnot' => Horde_Util::getPost('qsearchflagnot'),
+ 'sortby' => Horde_Util::getPost('sortby'),
+ 'sortdir' => Horde_Util::getPost('sortdir'),
);
$search = Horde_Util::getPost('search');
* ajax_url: (string) The URL to send the viewport requests to.
* This URL should return its response in an object named
* 'ViewPort' (other information can be returned in the response and
- * will be ignored by the viewport object).
+ * will be ignored by this class).
* container: (Element/string) A DOM element/ID of the container that holds
* the viewport. This element should be empty and have no children.
* onContent: (function) A function that takes 2 arguments - the data object
* cache: (string) The list of uids cached on the browser.
* cacheid: (string) A unique string that changes whenever the viewport
* list changes.
- * initial: (integer) TODO
+ * initial: (integer) This is the initial browser request for this view.
* requestid: (integer) A unique identifier for this AJAX request.
* view: (string) The view of the request.
*
* the viewable rows. Keys are a unique ID (see also the 'rowlist'
* entry). Values are the data objects. Internal keys for these data
* objects must NOT begin with the string 'vp'.
- * label: (string) The label to use for the current view.
- * metadata [optional]: (object) TODO
- * rangelist: TODO
+ * label: (string) [REQUIRED when initial is true] The label to use for the
+ * view.
+ * metadata [optional]: (object) Metadata for the view. Entries in buffer are
+ * updated with these entries (unless resetmd is set).
+ * rangelist [optional]: TODO
* requestid: (string) The request ID sent in the outgoing AJAX request.
* reset [optional]: (integer) If set, purges all cached data.
* resetmd [optional]: (integer) If set, purges all user metadata.
type = 'search';
value = opts.search;
params.set('search', Object.toJSON(value));
- } else if (opts.initial) {
+ }
+
+ if (opts.initial) {
params.set('initial', 1);
- } else {
+ }
+
+ if (opts.purge) {
b.resetRowlist();
}
this.isbusy = true;
this._clearWait();
- var callback, offset,
+ var callback, offset, tmp,
buffer = this._getBuffer(r.view),
llist = buffer.getMetaData('llist') || $H();
llist.unset(r.requestid);
- buffer.setMetaData({
+ tmp = {
cacheid: r.cacheid,
- label: r.label,
llist: llist,
total_rows: r.totalrows
- }, true);
+ };
+ if (r.label) {
+ tmp.label = r.label;
+ }
+ buffer.setMetaData(tmp, true);
this.opts.container.fire('ViewPort:cacheUpdate', r.view);
if ($is_search) {
$GLOBALS['imp_search']->createSearchQuery($query, array($args['qsearchmbox']), array(), _("Search Results"), $mbox);
}
+ } else {
+ $is_search = $GLOBALS['imp_search']->isSearchMbox($mbox);
}
/* Set the current time zone. */
$result = $this->getBaseOb($mbox);
$result->cacheid = $imp_mailbox->getCacheID();
$result->totalrows = $msgcount;
+ if (!$args['initial']) {
+ unset($result->label);
+ }
/* Mail-specific viewport information. */
$md = &$result->metadata;
if (!IMP::threadSortAvailable($mbox)) {
$md->nothread = 1;
}
- $md->sortby = intval($sortpref['by']);
- $md->sortdir = intval($sortpref['dir']);
- if ($sortpref['limit']) {
- $md->sortlimit = 1;
+ if ($args['initial'] || !is_null($args['sortby'])) {
+ $md->sortby = intval($sortpref['by']);
+ }
+ if ($args['initial'] || !is_null($args['sortdir'])) {
+ $md->sortdir = intval($sortpref['dir']);
}
- if (IMP::isSpecialFolder($mbox)) {
+ if ($args['initial'] && IMP::isSpecialFolder($mbox)) {
$md->special = 1;
}
- if ($is_search || $GLOBALS['imp_search']->isSearchMbox($mbox)) {
+ if ($args['initial'] && $is_search) {
$md->search = 1;
}
- if ($GLOBALS['imp_imap']->isReadOnly($mbox)) {
- $md->readonly = 1;
+
+ /* These entries may change during a session, so always need to
+ * update them. */
+ $md->readonly = intval($GLOBALS['imp_imap']->isReadOnly($mbox));
+ if (!$is_search &&
+ !empty($GLOBALS['conf']['server']['sort_limit'])) {
+ $md->sortlimit = $sortpref['limit'] ? 1 : 0;
}
/* Check for mailbox existence now. If there are no messages, there
}
/**
- * Prepare the base object used by the ViewPort javascript object.
+ * Prepare the base object used by the ViewPort javascript class.
*
* @param string $mbox The mailbox name.
*