5 * Displays messagelist column order options
7 * @copyright © 1999-2006 The SquirrelMail Project Team
8 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
10 * @package squirrelmail
15 * Include the SquirrelMail initialization file.
17 require('../include/init.php');
19 /* SquirrelMail required files. */
20 require_once(SM_PATH
. 'functions/forms.php');
21 require_once(SM_PATH
. 'functions/arrays.php');
24 if (sqgetGlobalVar('num', $num, SQ_GET
)) {
29 if (!sqgetGlobalVar('method', $method)) {
32 $method = htmlspecialchars($method);
34 if (!sqgetGlobalVar('positions', $pos, SQ_GET
)) {
40 if (!sqgetGlobalVar('account', $account, SQ_GET
)) {
43 $iAccount = (int) $account;
46 if (sqgetGlobalVar('mailbox', $mailbox, SQ_GET
)) {
47 $aMailboxPrefs = unserialize(getPref($data_dir, $username, "pref_".$iAccount.'_'.urldecode($mailbox)));
48 if (isset($aMailboxPrefs[MBX_PREF_COLUMNS
])) {
49 $index_order = $aMailboxPrefs[MBX_PREF_COLUMNS
];
52 $index_order_ser = getPref($data_dir, $username, 'index_order');
53 if ($index_order_ser) {
54 $index_order=unserialize($index_order_ser);
57 if (!isset($index_order)) {
58 if (isset($internal_date_sort) && $internal_date_sort == false) {
59 $index_order = array(SQM_COL_CHECK
,SQM_COL_FROM
,SQM_COL_DATE
,SQM_COL_FLAGS
,SQM_COL_ATTACHMENT
,SQM_COL_PRIO
,SQM_COL_SUBJ
);
61 $index_order = array(SQM_COL_CHECK
,SQM_COL_FROM
,SQM_COL_INT_DATE
,SQM_COL_FLAGS
,SQM_COL_ATTACHMENT
,SQM_COL_PRIO
,SQM_COL_SUBJ
);
65 if (!sqgetGlobalVar('account', $account, SQ_GET
)) {
66 $account = 0; // future work, multiple imap accounts
68 $account = (int) $account;
71 /* end of get globals */
73 /***************************************************************/
74 /* Finally, display whatever page we are supposed to show now. */
75 /***************************************************************/
77 displayPageHeader($color, 'None', (isset($optpage_data['xtra']) ?
$optpage_data['xtra'] : ''));
81 * Change the column order of a mailbox
83 * @param array $index_order (reference) contains an ordered list with columns
84 * @param string $method action to take, move, add and remove are supported
85 * @param int $num target column
86 * @param int $pos positions to move a column in the index_order array
87 * @return bool $r A change in the ordered list took place.
89 function change_columns_list(&$index_order,$method,$num,$pos=0) {
92 case 'move': $r = sqm_array_move_value($index_order,$num,$pos); break;
94 $index_order[] = (int) $num;
97 * flush the cache in order to retrieve the new columns
99 sqsession_unregister('mailbox_cache');
102 if(in_array($num, $index_order)) {
103 unset($index_order[array_search($num, $index_order)]);
104 $index_order = array_values($index_order);
114 * Column to string translation array
116 $available[SQM_COL_CHECK
] = _("Checkbox");
117 $available[SQM_COL_FROM
] = _("From");
118 $available[SQM_COL_DATE
] = _("Date");
119 $available[SQM_COL_SUBJ
] = _("Subject");
120 $available[SQM_COL_FLAGS
] = _("Flags");
121 $available[SQM_COL_SIZE
] = _("Size");
122 $available[SQM_COL_PRIO
] = _("Priority");
123 $available[SQM_COL_ATTACHMENT
] = _("Attachments");
124 $available[SQM_COL_INT_DATE
] = _("Received");
125 $available[SQM_COL_TO
] = _("To");
126 $available[SQM_COL_CC
] = _("Cc");
127 $available[SQM_COL_BCC
] = _("Bcc");
129 if (change_columns_list($index_order,$method,$num,$pos)) {
131 // TODO, bound index_order to mailbox and make a difference between the global index_order and mailbox bounded index_order
132 setPref($data_dir, $username, 'index_order', serialize($index_order));
138 if (count($index_order) != count($available)) {
139 for ($i=0; $i < count($available); $i++
) {
140 if (!in_array($i,$index_order)) {
141 $opts[$i] = $available[$i];
146 sqgetGlobalVar('PHP_SELF', $PHP_SELF, SQ_SERVER
);
147 $x = isset($mailbox) && $mailbox ?
'&mailbox='.urlencode($mailbox) : '';
149 $oTemplate->assign('fields', $available);
150 $oTemplate->assign('current_order', $index_order);
151 $oTemplate->assign('not_used', $opts);
152 $oTemplate->assign('always_show', array(SQM_COL_SUBJ
, SQM_COL_FLAGS
));
154 $oTemplate->assign('move_up', $PHP_SELF .'?method=move&positions=-1'. $x .'&num=');
155 $oTemplate->assign('move_down', $PHP_SELF .'?method=move&positions=1'. $x .'&num=');
156 $oTemplate->assign('remove', $PHP_SELF .'?method=remove'. $x .'&num=');
157 $oTemplate->assign('add', $PHP_SELF.'?method=add'.$x.'&num=');
158 $oTemplate->assign('addField_action', $PHP_SELF);
160 $oTemplate->display('options_order.tpl');
162 $oTemplate->display('footer.tpl');