From d59aaa1aafb204ba7ece824fee0550f907af8c3d Mon Sep 17 00:00:00 2001 From: alecpl Date: Sun, 23 Nov 2008 12:25:15 +0000 Subject: [PATCH] - Allow setting attachment col position in 'list_cols' option - Allow override 'list_cols' via skin (#1485577) - Fix: allow empty attribs in templates --- CHANGELOG | 5 +++ config/main.inc.php.dist | 6 ++-- program/include/main.inc | 2 +- program/js/app.js | 17 +++++------ program/steps/mail/func.inc | 51 +++++++++++++++++++++++++------ skins/default/templates/mail.html | 1 + 6 files changed, 58 insertions(+), 24 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index c5e14ed60..c8a7957d9 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,11 @@ CHANGELOG RoundCube Webmail --------------------------- +2008/11/23 (alec) +---------- +- Allow setting attachment col position in 'list_cols' option +- Allow override 'list_cols' via skin (#1485577) + 2008/11/21 (alec) ---------- - Fix 'cache' table cleanup on session destroy (#1485516) diff --git a/config/main.inc.php.dist b/config/main.inc.php.dist index 7d820c479..c4a62b1f8 100644 --- a/config/main.inc.php.dist +++ b/config/main.inc.php.dist @@ -110,9 +110,9 @@ $rcmail_config['smtp_log'] = TRUE; // How many seconds must pass between emails sent by a user $rcmail_config['sendmail_delay'] = 0; -// These cols are shown in the message list -// available cols are: subject, from, to, cc, replyto, date, size, encoding, flag -$rcmail_config['list_cols'] = array('subject', 'from', 'date', 'size', 'flag'); +// These cols are shown in the message list. Available cols are: +// subject, from, to, cc, replyto, date, size, encoding, flag, attachment +$rcmail_config['list_cols'] = array('subject', 'from', 'date', 'size', 'flag', 'attachment'); // Includes should be interpreted as PHP files $rcmail_config['skin_include_php'] = FALSE; diff --git a/program/include/main.inc b/program/include/main.inc index db3745b09..e531bd8d3 100644 --- a/program/include/main.inc +++ b/program/include/main.inc @@ -661,7 +661,7 @@ function create_attrib_string($attrib, $allowed_attribs=array('id', 'class', 'st function parse_attrib_string($str) { $attrib = array(); - preg_match_all('/\s*([-_a-z]+)=(["\'])??(?(2)([^\2]+)\2|(\S+?))/Ui', stripslashes($str), $regs, PREG_SET_ORDER); + preg_match_all('/\s*([-_a-z]+)=(["\'])??(?(2)([^\2]*)\2|(\S+?))/Ui', stripslashes($str), $regs, PREG_SET_ORDER); // convert attributes to an associative array (name => value) if ($regs) diff --git a/program/js/app.js b/program/js/app.js index e7204d040..06978f60b 100644 --- a/program/js/app.js +++ b/program/js/app.js @@ -565,7 +565,7 @@ function rcube_webmail() var sort_col = a_sort[0]; var sort_order = a_sort[1] ? a_sort[1].toUpperCase() : null; var header; - + // no sort order specified: toggle if (sort_order==null) { @@ -579,9 +579,9 @@ function rcube_webmail() break; // set table header class - if (header = document.getElementById('rcmHead'+this.env.sort_col)) + if (header = document.getElementById('rcm'+this.env.sort_col)) this.set_classname(header, 'sorted'+(this.env.sort_order.toUpperCase()), false); - if (header = document.getElementById('rcmHead'+sort_col)) + if (header = document.getElementById('rcm'+sort_col)) this.set_classname(header, 'sorted'+sort_order, true); // save new sort properties @@ -3427,7 +3427,7 @@ function rcube_webmail() else cell.innerHTML = this.get_label(this.coltypes[n]); - cell.id = 'rcmHead'+col; + cell.id = 'rcm'+col; } else if (col == 'subject' && this.message_list) this.message_list.subject_col = n+1; @@ -3498,18 +3498,15 @@ function rcube_webmail() col.innerHTML = ''; else if(this.env.unflaggedicon) col.innerHTML = ''; - } + } + else if (c=='attachment') + col.innerHTML = attachment && this.env.attachmenticon ? '' : ''; else col.innerHTML = cols[c]; row.appendChild(col); } - col = document.createElement('TD'); - col.className = 'icon'; - col.innerHTML = attachment && this.env.attachmenticon ? '' : ''; - row.appendChild(col); - this.message_list.insert_row(row, attop); // remove 'old' row diff --git a/program/steps/mail/func.inc b/program/steps/mail/func.inc index 7f8fb11a8..ea63a266f 100644 --- a/program/steps/mail/func.inc +++ b/program/steps/mail/func.inc @@ -114,8 +114,16 @@ function rcmail_message_list($attrib) $out = '\n"; - // define list of cols to be displayed - $a_show_cols = is_array($CONFIG['list_cols']) ? $CONFIG['list_cols'] : array('subject'); + // define list of cols to be displayed based on parameter or config + if (empty($attrib['columns'])) + $a_show_cols = is_array($CONFIG['list_cols']) ? $CONFIG['list_cols'] : array('subject'); + else + $a_show_cols = explode(',', strip_quotes($attrib['columns'])); + + // store column list in a session-variable + $_SESSION['list_columns'] = $a_show_cols; + + // define sortable columns $a_sort_cols = array('subject', 'date', 'from', 'to', 'size'); $mbox = $IMAP->get_mailbox_name(); @@ -130,9 +138,8 @@ function rcmail_message_list($attrib) $out .= ''; foreach ($a_show_cols as $col) - $out .= sprintf('', $col); + $out .= ($col!='attachment') ? sprintf('', $col) : ''; - $out .= ''; $out .= "\n"; // add table title @@ -142,7 +149,17 @@ function rcmail_message_list($attrib) foreach ($a_show_cols as $col) { // get column name - $col_name = $col != 'flag' ? Q(rcube_label($col)) : sprintf($image_tag, $skin_path, $attrib['unflaggedicon'], ''); + switch ($col) + { + case 'flag': + $col_name = sprintf($image_tag, $skin_path, $attrib['unflaggedicon'], ''); + break; + case 'attachment': + $col_name = sprintf($image_tag, $skin_path, $attrib['attachmenticon'], ''); + break; + default: + $col_name = Q(rcube_label($col)); + } // make sort links $sort = ''; @@ -190,10 +207,12 @@ function rcmail_message_list($attrib) $sort_class = $col==$sort_col ? " sorted$sort_order" : ''; // put it all together - $out .= '' . "$col_name$sort\n"; + if ($col!='attachment') + $out .= '' . "$col_name$sort\n"; + else + $out .= '' . "$col_name$sort\n"; } - $out .= ''.($attrib['attachmenticon'] ? sprintf($image_tag, $skin_path, $attrib['attachmenticon'], '') : ' ')."\n"; $out .= "\n\n"; // no messages in this mailbox @@ -283,10 +302,12 @@ function rcmail_message_list($attrib) else $cont = Q($header->$col); - $out .= '' . $cont . "\n"; + if ($col!='attachment') + $out .= '' . $cont . "\n"; + else + $out .= sprintf("%s\n", $attach_icon ? sprintf($image_tag, $skin_path, $attach_icon, '') : ''); } - $out .= sprintf("%s\n", $attach_icon ? sprintf($image_tag, $skin_path, $attach_icon, '') : ''); $out .= "\n"; if (sizeof($js_row_arr)) @@ -342,7 +363,11 @@ function rcmail_js_message_list($a_headers, $insert_top=FALSE) { global $CONFIG, $IMAP, $OUTPUT; - $a_show_cols = is_array($CONFIG['list_cols']) ? $CONFIG['list_cols'] : array('subject'); + if (empty($_SESSION['list_columns'])) + $a_show_cols = is_array($CONFIG['list_cols']) ? $CONFIG['list_cols'] : array('subject'); + else + $a_show_cols = $_SESSION['list_columns']; + $mbox = $IMAP->get_mailbox_name(); // show 'to' instead of from in sent messages @@ -364,6 +389,12 @@ function rcmail_js_message_list($a_headers, $insert_top=FALSE) if (!empty($header->charset)) $IMAP->set_charset($header->charset); + // remove 'attachment' and 'flag' columns, we don't need them here + if(($key = array_search('attachment', $a_show_cols)) !== FALSE) + unset($a_show_cols[$key]); + if(($key = array_search('flag', $a_show_cols)) !== FALSE) + unset($a_show_cols[$key]); + // format each col; similar as in rcmail_message_list() foreach ($a_show_cols as $col) { diff --git a/skins/default/templates/mail.html b/skins/default/templates/mail.html index 51e1b1f11..34f4254b7 100644 --- a/skins/default/templates/mail.html +++ b/skins/default/templates/mail.html @@ -46,6 +46,7 @@