5 * Displays messagelist column order options
7 * @copyright © 1999-2007 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');
23 if (sqgetGlobalVar('num', $num, SQ_GET
)) {
28 if (!sqgetGlobalVar('method', $method)) {
31 $method = htmlspecialchars($method);
33 if (!sqgetGlobalVar('positions', $pos, SQ_GET
)) {
39 if (!sqgetGlobalVar('account', $account, SQ_GET
)) {
42 $iAccount = (int) $account;
45 if (sqgetGlobalVar('mailbox', $mailbox, SQ_GET
)) {
46 $aMailboxPrefs = unserialize(getPref($data_dir, $username, "pref_".$iAccount.'_'.urldecode($mailbox)));
47 if (isset($aMailboxPrefs[MBX_PREF_COLUMNS
])) {
48 $index_order = $aMailboxPrefs[MBX_PREF_COLUMNS
];
51 $index_order_ser = getPref($data_dir, $username, 'index_order');
52 if ($index_order_ser) {
53 $index_order=unserialize($index_order_ser);
56 if (!isset($index_order)) {
57 if (isset($internal_date_sort) && $internal_date_sort == false) {
58 $index_order = array(SQM_COL_CHECK
,SQM_COL_FROM
,SQM_COL_DATE
,SQM_COL_FLAGS
,SQM_COL_ATTACHMENT
,SQM_COL_PRIO
,SQM_COL_SUBJ
);
60 $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
);
64 if (!sqgetGlobalVar('account', $account, SQ_GET
)) {
65 $account = 0; // future work, multiple imap accounts
67 $account = (int) $account;
70 /* end of get globals */
72 /***************************************************************/
73 /* Finally, display whatever page we are supposed to show now. */
74 /***************************************************************/
76 displayPageHeader($color, null, (isset($optpage_data['xtra']) ?
$optpage_data['xtra'] : ''));
80 * Change the column order of a mailbox
82 * @param array $index_order (reference) contains an ordered list with columns
83 * @param string $method action to take, move, add and remove are supported
84 * @param int $num target column
85 * @param int $pos positions to move a column in the index_order array
86 * @return bool $r A change in the ordered list took place.
88 function change_columns_list(&$index_order,$method,$num,$pos=0) {
91 case 'move': $r = sqm_array_move_value($index_order,$num,$pos); break;
93 $index_order[] = (int) $num;
96 * flush the cache in order to retrieve the new columns
98 sqsession_unregister('mailbox_cache');
101 if(in_array($num, $index_order)) {
102 unset($index_order[array_search($num, $index_order)]);
103 $index_order = array_values($index_order);
113 * Column to string translation array
115 $available[SQM_COL_CHECK
] = _("Checkbox");
116 $available[SQM_COL_FROM
] = _("From");
117 $available[SQM_COL_DATE
] = _("Date");
118 $available[SQM_COL_SUBJ
] = _("Subject");
119 $available[SQM_COL_FLAGS
] = _("Flags");
120 $available[SQM_COL_SIZE
] = _("Size");
121 $available[SQM_COL_PRIO
] = _("Priority");
122 $available[SQM_COL_ATTACHMENT
] = _("Attachments");
123 $available[SQM_COL_INT_DATE
] = _("Received");
124 $available[SQM_COL_TO
] = _("To");
125 $available[SQM_COL_CC
] = _("Cc");
126 $available[SQM_COL_BCC
] = _("Bcc");
128 if (change_columns_list($index_order,$method,$num,$pos)) {
130 // TODO, bound index_order to mailbox and make a difference between the global index_order and mailbox bounded index_order
131 setPref($data_dir, $username, 'index_order', serialize($index_order));
137 if (count($index_order) != count($available)) {
138 for ($i=0; $i < count($available); $i++
) {
139 if (!in_array($i,$index_order)) {
140 $opts[$i] = $available[$i];
145 // FIXME: why are we using this? $PHP_SELF is already a global var processed (and therefore trustworthy) by init.php
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 // FIXME: (related to the above) $PHP_SELF might already have a query string... don't assume otherwise here by adding the ? sign!!
155 $oTemplate->assign('move_up', $PHP_SELF .'?method=move&positions=-1'. $x .'&num=');
156 $oTemplate->assign('move_down', $PHP_SELF .'?method=move&positions=1'. $x .'&num=');
157 $oTemplate->assign('remove', $PHP_SELF .'?method=remove'. $x .'&num=');
158 $oTemplate->assign('add', $PHP_SELF.'?method=add'.$x.'&num=');
159 $oTemplate->assign('addField_action', $PHP_SELF);
161 $oTemplate->display('options_order.tpl');
163 $oTemplate->display('footer.tpl');