Skip to content

Commit

Permalink
Add ability to replace current mesage flag information via AJAX imp:f…
Browse files Browse the repository at this point in the history
…lag task

Conflicts:
	imp/lib/Ajax/Queue.php
  • Loading branch information
slusarz committed Oct 10, 2013
1 parent cf905fe commit 2ec7c13
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 2 deletions.
8 changes: 8 additions & 0 deletions imp/js/dimpbase.js
Original file line number Diff line number Diff line change
Expand Up @@ -3122,6 +3122,14 @@ var DimpBase = {
VP_id: { equal: m.value.parseViewportUidString() }
});

if (entry.replace) {
s.get('dataob').each(function(d) {
d.flag = [];
this.viewport.updateRow(d);
}, this);
entry.add = entry.replace;
}

if (entry.add) {
entry.add.each(function(f) {
this.updateFlag(s, f, true);
Expand Down
44 changes: 42 additions & 2 deletions imp/lib/Ajax/Queue.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,11 @@ class IMP_Ajax_Queue
*
* For flag data (key: 'flag'), an array of objects with these properties:
* - add: (array) The list of flags that were added.
* - buids: (string) Indices of the messages that have changed (IMAP
* sequence string; mboxes are base64url encoded).
* - deselect: (boolean) If true, deselect the uids.
* - remove: (array) The list of flags that were removed.
* - uids: (string) Indices of the messages that have changed (IMAP
* sequence string; mboxes are base64url encoded).
* - replace: (array) Replace the flag list with these flags.
*
* For flag configuration data (key: 'flag-config'), an array containing
* flag data:
Expand Down Expand Up @@ -346,6 +348,44 @@ public function flag($flags, $add, IMP_Indices $indices)
$this->_flag[] = $result;
}

/**
* Sends replacement flag information for the indices provided.
*
* @param IMP_Indices $indices Indices object.
*/
public function flagReplace(IMP_Indices $indices)
{
global $injector, $prefs;

$imp_flags = $injector->getInstance('IMP_Flags');

foreach ($indices as $ob) {
$list_ob = $ob->mbox->list_ob;
$msgnum = array();

foreach ($ob->uids as $uid) {
$msgnum[] = $list_ob->getArrayIndex($uid) + 1;
}

$marray = $list_ob->getMailboxArray($msgnum, array(
'headers' => true,
'type' => $prefs->getValue('atc_flag')
));

foreach ($marray['overview'] as $val) {
$result = new stdClass;
$result->buids = $ob->mbox->toBuids(new IMP_Indices($ob->mbox, $val['uid']))->toArray();
$result->replace = array_map('strval', $imp_flags->parse(array(
'flags' => $val['flags'],
'headers' => $val['headers'],
'runhook' => $val,
'personal' => $val['envelope']->to
)));
$this->_flag[] = $result;
}
}
}

/**
* Add flag configuration information to response queue.
*/
Expand Down

0 comments on commit 2ec7c13

Please sign in to comment.