Ticket #1485165 (closed Patches: duplicate)

Opened 2 months ago

Last modified 2 months ago

Message flags

Reported by: rosali Owned by:
Priority: 5 Milestone: 0.2-stable
Component: Client Scripts Version: 0.2-alpha
Severity: normal Keywords:
Cc:

Description

I hope to see message flags soon. It is a standard feature.

Attached is an old patch from roundcubeforum.net ...

Please implement this feature during v2.0 dev !

-Roland

... hmmm can't attach the file (.zip) ... permission denied!

Index: roundcubemail/config/main.inc.php.dist =================================================================== --- roundcubemail/config/main.inc.php.dist (revision 888) +++ roundcubemail/config/main.inc.php.dist (working copy) @@ -86,6 +86,10 @@

// Log sent messages $rcmail_configsmtp_log? = TRUE;

+// this column is shown in the message list if set to TRUE +// shows the flagged/unflagged status of a message +$rcmail_configflag_col? = FALSE; +

// these cols are shown in the message list // available cols are: subject, from, to, cc, replyto, date, size, encoding $rcmail_configlist_cols? = array('subject', 'from', 'date', 'size');

Index: roundcubemail/program/include/rcube_imap.inc =================================================================== --- roundcubemail/program/include/rcube_imap.inc (revision 888) +++ roundcubemail/program/include/rcube_imap.inc (working copy) @@ -1296,6 +1296,10 @@

$result = iil_C_Undelete($this->conn, $this->mailbox, join(',', array_values($msg_ids)));

else if ($flag=='UNSEEN')

$result = iil_C_Unseen($this->conn, $this->mailbox, join(',', array_values($msg_ids)));

+ else if ($flag=='FLAGGED') + $result = iil_C_Flag($this->conn, $this->mailbox, join(',', array_values($msg_ids)), $flag); + else if ($flag=='UNFLAGGED') + $result = iil_C_Unflag($this->conn, $this->mailbox, join(',', array_values($msg_ids)), $flag);

else

$result = iil_C_Flag($this->conn, $this->mailbox, join(',', array_values($msg_ids)), $flag);

Index: roundcubemail/program/js/app.js =================================================================== --- roundcubemail/program/js/app.js (revision 888) +++ roundcubemail/program/js/app.js (working copy) @@ -137,7 +137,8 @@

this.message_list.init(); this.enable_command('toggle_status', true);

- + this.enable_command('toggle_flag', true); +

if (this.gui_objects.mailcontframe)

{ this.gui_objects.mailcontframe.onmousedown = function(e){ return p.click_on_list(e); };

@@ -355,6 +356,7 @@

row.deleted = this.env.messages[uid].deleted ? true : false; row.unread = this.env.messages[uid].unread ? true : false; row.replied = this.env.messages[uid].replied ? true : false;

+ row.flagged = this.env.messages[uid].flagged ? true : false;

}

// set eventhandler to message icon

@@ -365,6 +367,16 @@

row.icon._row = row.obj; row.icon.onmousedown = function(e) { p.command('toggle_status', this); }; }

+ + // set eventhandler to flagged icon, if icon found + // TODO: global variable flag_cols has not been defined yet + if ((row.flagged_icon = row.obj.cells[1].childNodes[0]) && row.flagged_icon.nodeName=='IMG') + { + var p = this; + row.flagged_icon.id = 'flaggedicn_'+row.uid; + row.flagged_icon._row = row.obj; + row.flagged_icon.onmousedown = function(e) { p.command('toggle_flag', this); }; + }

};

@@ -685,6 +697,24 @@

this.mark_message(flag, uid); break;

+ case 'toggle_flag': + if (props && !props._row) + break; + + var uid; + var flag = 'flagged'; + + if (props._row.uid) + { + uid = props._row.uid; + this.message_list.dont_select = true; + // toggle flagged/unflagged + if (this.message_list.rows[uid].flagged) + flag = 'unflagged'; + } + this.mark_message(flag, uid); + break; +

case 'load-images':

if (this.env.uid)

this.show_message(this.env.uid, true, this.env.action=='preview');

@@ -1471,7 +1501,8 @@

{ id = selection[n];

if ((flag=='read' && this.message_list.rows[id].unread) (flag=='unread' && !this.message_list.rows[id].unread)

- (flag=='delete' && !this.message_list.rows[id].deleted) (flag=='undelete' && this.message_list.rows[id].deleted))

+ (flag=='delete' && !this.message_list.rows[id].deleted) (flag=='undelete' && this.message_list.rows[id].deleted)

+ (flag=='unflagged' && this.message_list.rows[id].flagged) (flag=='flagged' && !this.message_list.rows[id].flagged))

a_uids[a_uids.length] = id;

}

}

@@ -1490,6 +1521,12 @@

case 'undelete':

this.toggle_delete_status(a_uids); break;

+ case 'flagged': + this.toggle_flagged_status(flag, a_uids); + break; + case 'unflagged': + this.toggle_flagged_status(flag, a_uids); + break;

}

};

@@ -1533,6 +1570,32 @@

this.http_post('mark', '_uid='+a_uids.join(',')+'&_flag='+flag);

};

+ // set image to flagged or unflagged + this.toggle_flagged_status = function(flag, a_uids) + { + // mark all message rows as flagged/unflagged + var icn_src; + var rows = this.message_list.rows; + for (var i=0; i<a_uids.length; i++) + { + uid = a_uids[i]; + if (rows[uid]) + { + rows[uid].flagged = (flag=='flagged' ? true : false); + + if (rows[uid].flagged && this.env.flaggedicon) + icn_src = this.env.flaggedicon; + else + icn_src = this.env.unflaggedicon; + + if (rows[uid].flagged_icon && icn_src) + rows[uid].flagged_icon.src = icn_src; + } + } + + this.http_post('mark', '_uid='+a_uids.join(',')+'&_flag='+flag); + }; +

// mark all message rows as deleted/undeleted this.toggle_delete_status = function(a_uids) {

@@ -3122,6 +3185,11 @@

return null;

};

+ // for setting the flagged column + this.set_message_flaggedcol = function(flagged_col) + { + this.flagged_col = flagged_col; + };

// for reordering column array, Konqueror workaround this.set_message_coltypes = function(coltypes)

@@ -3130,11 +3198,12 @@

// set correct list titles var cell, col;

+ var skip = this.flagged_col ? 2 : 1;

var thead = this.gui_objects.messagelist ? this.gui_objects.messagelist.tHead : null; for (var n=0; thead && n<this.coltypes.length; n++)

{ col = this.coltypes[n];

- if ((cell = thead.rows[0].cells[n+1]) && (col=='from' col=='to'))

+ if ((cell = thead.rows[0].cells[n+skip]) && (col=='from' col=='to'))

{ // if we have links for sorting, it's a bit more complicated... if (cell.firstChild && cell.firstChild.tagName=='A')

@@ -3153,7 +3222,7 @@

};

// create a table row in the message list

- this.add_message_row = function(uid, cols, flags, attachment, attop) + this.add_message_row = function(uid, cols, flags, flaggedsw, attachment, attop)

{

if (!this.gui_objects.messagelist !this.message_list)

return false;

@@ -3164,7 +3233,8 @@

this.env.messages[uid] = {deleted:flags.deleted?1:0,

replied:flags.replied?1:0,

- unread:flags.unread?1:0}; + unread:flags.unread?1:0, + flagged:flaggedsw?1:0};

var row = document.createElement('TR'); row.id = 'rcmrow'+uid;

@@ -3182,6 +3252,18 @@

col.innerHTML = icon ? '<img src="'+icon+'" alt="" border="0" />' : ; row.appendChild(col);

+ // add flagged col + if (this.flagged_col) + { + col = document.createElement('TD'); + col.className = 'icon'; + if (flaggedsw && this.env.flaggedicon) + col.innerHTML = '<img src="'+this.env.flaggedicon+'" alt="" border="0" />'; + else + col.innerHTML = '<img src="'+this.env.unflaggedicon+'" alt="" border="0" />'; + row.appendChild(col); + } +

// add each submitted col for (var n = 0; n < this.coltypes.length; n++)

{

Index: roundcubemail/program/lib/imap.inc =================================================================== --- roundcubemail/program/lib/imap.inc (revision 888) +++ roundcubemail/program/lib/imap.inc (working copy) @@ -1369,6 +1369,7 @@

else if (strcasecmp($val, "Deleted")==0) $result[$id]->deleted=true; else if (strcasecmp($val, "Recent")==0) $result[$id]->recent = true; else if (strcasecmp($val, "Answered")==0) $result[$id]->answered = true;

+ if (strcasecmp($val, "Flagged")==0) $result[$id]->flagged=true;

} $result[$id]->flags=$flags_str;

}

Index: roundcubemail/program/steps/mail/func.inc =================================================================== --- roundcubemail/program/steps/mail/func.inc (revision 888) +++ roundcubemail/program/steps/mail/func.inc (working copy) @@ -133,6 +133,10 @@

// add table title $out .= "<thead><tr>\n<td class=\"icon\">&nbsp;</td>\n";

+ // add flagged column header + if ($a_flag_col) + $out .= "<td class=\"icon\">&nbsp;</td>\n"; +

$javascript = ; foreach ($a_show_cols as $col)

{

@@ -201,7 +205,7 @@

// create row for each message foreach ($a_headers as $i => $header) //while (list($i, $header) = each($a_headers))

{

- $message_icon = $attach_icon = ; + $message_icon = $attach_icon = $flagged_icon = ;

$js_row_arr = array(); $zebra_class = $i%2 ? 'even' : 'odd';

@@ -212,6 +216,9 @@

$js_row_arrunread? = true;

if ($header->answered)

$js_row_arrreplied? = true;

+ if ($header->flagged) + $js_row_arrflagged? = true; +

// set message icon if ($attribdeletedicon? && $header->deleted)

$message_icon = $attribdeletedicon?;

@@ -234,6 +241,17 @@

$out .= sprintf("<td class=\"icon\">%s</td>\n", $message_icon ? sprintf($image_tag, $skin_path, $message_icon, ) : );

+ // set flagged / unflagged icon + if ($a_flag_col) + { + if ($attribflaggedicon? && $header->flagged) + $flagged_icon = $attribflaggedicon?; + else if ($attribunflaggedicon?) + $flagged_icon = $attribunflaggedicon?; + + $out .= sprintf("<td class=\"icon\">%s</td>\n", $flagged_icon ? sprintf($image_tag, $skin_path, $flagged_icon, ) : ); + } +

// format each col foreach ($a_show_cols as $col)

{

@@ -289,6 +307,10 @@

$OUTPUT->set_env('repliedicon', $skin_path . $attribrepliedicon?);

if ($attribattachmenticon?)

$OUTPUT->set_env('attachmenticon', $skin_path . $attribattachmenticon?);

+ if ($attribflaggedicon?) + $OUTPUT->set_env('flaggedicon', $skin_path . $attribflaggedicon?); + if ($attribunflaggedicon?) + $OUTPUT->set_env('unflaggedicon', $skin_path . $attribunflaggedicon?);

$OUTPUT->set_env('messages', $a_js_message_arr);

@@ -304,6 +326,7 @@

global $CONFIG, $IMAP, $OUTPUT;

$a_show_cols = is_array($CONFIGlist_cols?) ? $CONFIGlist_cols? : array('subject');

+ $a_flag_col = ($CONFIGflag_col?) ? TRUE : FALSE;

$mbox = $IMAP->get_mailbox_name();

// show 'to' instead of from in sent messages

@@ -311,6 +334,9 @@

&& (($f = array_search('from', $a_show_cols)) !== false) && array_search('to', $a_show_cols) === false)

$a_show_cols[$f] = 'to';

+// Must be set before set_message_coltypes + $OUTPUT->command('set_message_flaggedcol', $a_flag_col); +

$OUTPUT->command('set_message_coltypes', $a_show_cols);

// loop through message headers

@@ -318,7 +344,8 @@

{ $a_msg_cols = array(); $a_msg_flags = array();

- + $a_msg_flagged = FALSE; +

if (empty($header))

continue;

@@ -348,10 +375,14 @@

$a_msg_flagsdeleted? = $header->deleted ? 1 : 0; $a_msg_flagsunread? = $header->seen ? 0 : 1; $a_msg_flagsreplied? = $header->answered ? 1 : 0;

+ + $a_msg_flagged = $header->flagged ? 1 : 0; +

$OUTPUT->command('add_message_row',

$header->uid, $a_msg_cols, $a_msg_flags,

+ $a_msg_flagged,

preg_match("/multipart\/m/i", $header->ctype), $insert_top);

}

Index: roundcubemail/program/steps/mail/mark.inc =================================================================== --- roundcubemail/program/steps/mail/mark.inc (revision 888) +++ roundcubemail/program/steps/mail/mark.inc (working copy) @@ -22,7 +22,9 @@

'undelete' => 'UNDELETED', 'delete' => 'DELETED', 'read' => 'SEEN',

- 'unread' => 'UNSEEN'); + 'unread' => 'UNSEEN', + 'flagged' => 'FLAGGED', + 'unflagged' => 'UNFLAGGED');

if (($uids = get_input_value('_uid', RCUBE_INPUT_POST)) && ($flag = get_input_value('_flag', RCUBE_INPUT_POST))) {

Index: roundcubemail/skins/default/templates/mail.html =================================================================== --- roundcubemail/skins/default/templates/mail.html (revision 888) +++ roundcubemail/skins/default/templates/mail.html (working copy) @@ -54,7 +54,9 @@

unreadIcon="/images/icons/unread.png" deletedIcon="/images/icons/deleted.png" repliedIcon="/images/icons/replied.png"

- attachmentIcon="/images/icons/attachment.png" /> + attachmentIcon="/images/icons/attachment.png" + flaggedIcon="/images/icons/flagged.png" + unflaggedIcon="/images/icons/unflagged.png" />

</div>

<roundcube:if condition="config:preview_pane == true" />

Change History

in reply to: ↑ description   Changed 2 months ago by rosali

download old patch @ http://liebl.ath.cx/dl/rc_flags

  Changed 2 months ago by alec

  • status changed from new to closed
  • resolution set to duplicate

Duplicate of #1484623.

Note: See TracTickets for help on using tickets.