6 * Copyright (c) 1999-2005 The SquirrelMail Project Team
7 * Licensed under the GNU GPL. For full terms see the file COPYING.
9 * Displays messagelist column order options
12 * @package squirrelmail
17 * Path for SquirrelMail required files.
20 define('SM_PATH','../');
22 /* SquirrelMail required files. */
23 require_once(SM_PATH
. 'include/validate.php');
24 include_once(SM_PATH
. 'functions/global.php');
25 include_once(SM_PATH
. 'functions/display_messages.php');
26 include_once(SM_PATH
. 'functions/imap.php');
27 include_once(SM_PATH
. 'functions/plugin.php');
28 include_once(SM_PATH
. 'functions/html.php');
29 include_once(SM_PATH
. 'functions/forms.php');
30 include_once(SM_PATH
. 'functions/arrays.php');
31 //require_once(SM_PATH . 'functions/options.php');
34 if (sqgetGlobalVar('num', $num, SQ_GET
)) {
39 if (!sqgetGlobalVar('method', $method)) {
42 $method = htmlspecialchars($method);
44 if (!sqgetGlobalVar('positions', $pos, SQ_GET
)) {
50 if (!sqgetGlobalVar('account', $account, SQ_GET
)) {
53 $iAccount = (int) $account;
56 if (sqgetGlobalVar('mailbox', $mailbox, SQ_GET
)) {
57 $aMailboxPrefs = unserialize(getPref($data_dir, $username, "pref_".$iAccount.'_'.urldecode($mailbox)));
58 if (isset($aMailboxPrefs[MBX_PREF_COLUMNS
])) {
59 $index_order = $aMailboxPrefs[MBX_PREF_COLUMNS
];
62 $index_order_ser = getPref($data_dir, $username, 'index_order');
63 if ($index_order_ser) {
64 $index_order=unserialize($index_order_ser);
67 if (!isset($index_order)) {
68 if (isset($internal_date_sort) && $internal_date_sort == false) {
69 $index_order = array(SQM_COL_CHECK
,SQM_COL_FROM
,SQM_COL_DATE
,SQM_COL_FLAGS
,SQM_COL_ATTACHMENT
,SQM_COL_PRIO
,SQM_COL_SUBJ
);
71 $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
);
75 if (!sqgetGlobalVar('account', $account, SQ_GET
)) {
76 $account = 0; // future work, multiple imap accounts
78 $account = (int) $account;
81 /* end of get globals */
83 /***************************************************************/
84 /* Finally, display whatever page we are supposed to show now. */
85 /***************************************************************/
87 displayPageHeader($color, 'None', (isset($optpage_data['xtra']) ?
$optpage_data['xtra'] : ''));
91 * Change the column order of a mailbox
93 * @param array $index_order (reference) contains an ordered list with columns
94 * @param string $method action to take, move, add and remove are supported
95 * @param int $num target column
96 * @param int $pos positions to move a column in the index_order array
97 * @return bool $r A change in the ordered list took place.
99 function change_columns_list(&$index_order,$method,$num,$pos=0) {
102 case 'move': $r = sqm_array_move_value($index_order,$num,$pos); break;
104 $index_order[] = (int) $num;
107 * flush the cache in order to retrieve the new columns
109 sqsession_unregister('mailbox_cache');
112 if(in_array($num, $index_order)) {
113 unset($index_order[array_search($num, $index_order)]);
114 $index_order = array_values($index_order);
124 * Column to string translation array
126 $available[SQM_COL_CHECK
] = _("Checkbox");
127 $available[SQM_COL_FROM
] = _("From");
128 $available[SQM_COL_DATE
] = _("Date");
129 $available[SQM_COL_SUBJ
] = _("Subject");
130 $available[SQM_COL_FLAGS
] = _("Flags");
131 $available[SQM_COL_SIZE
] = _("Size");
132 $available[SQM_COL_PRIO
] = _("Priority");
133 $available[SQM_COL_ATTACHMENT
] = _("Attachments");
134 $available[SQM_COL_INT_DATE
] = _("Received");
135 $available[SQM_COL_TO
] = _("To");
136 $available[SQM_COL_CC
] = _("Cc");
137 $available[SQM_COL_BCC
] = _("Bcc");
139 if (change_columns_list($index_order,$method,$num,$pos)) {
141 // TODO, bound index_order to mailbox and make a difference between the global index_order and mailbox bounded index_order
142 setPref($data_dir, $username, 'index_order', serialize($index_order));
148 if (count($index_order) != count($available)) {
149 for ($i=0; $i < count($available); $i++
) {
150 if (!in_array($i,$index_order)) {
151 $opts[$i] = $available[$i];
158 viewOrderForm($available, $index_order,$opts,urldecode($mailbox));
161 // FOOD for html designers
162 function viewOrderForm($aColumns, $aOrder, $aOpts, $mailbox) {
166 <table align
="center" width
="95%" border
="0" cellpadding
="1" cellspacing
="0">
168 <td align
="center" bgcolor
="<?php echo $color[0];?>">
169 <b
> <?php
echo _("Options");?
> - <?php
echo _("Index Order");?
> </b
>
170 <table width
="100%" border
="0" cellpadding
="8" cellspacing
="0">
172 <td align
="center" bgcolor
="<?php echo $color[4];?>">
173 <table width
="65%" border
="0" cellpadding
="0" cellspacing
="0">
176 <?php
echo _("The index order is the order that the columns are arranged in the message index. You can add, remove, and move columns around to customize them to fit your needs.");?
>
182 <?php
if (count($aOrder)) { ?
>
183 <table cellspacing
="0" cellpadding
="0" border
="0">
184 <?php
foreach($aOrder as $i => $iCol) {
185 $sQuery = "&num=$iCol";
186 if (isset($mailbox) && $mailbox) {
187 $sQuery .= '&mailbox='.urlencode($mailbox);
193 <td
><small
><a href
="options_order.php?method=move&positions=-1&num=<?php echo $sQuery; ?>"> <?php
echo _("up");?
> </a
></small
></td
>
197 <td
><small
> 
;|
 
;</small
></td
>
198 <?php
if ($i < count($aOrder) -1) { ?
>
199 <td
><small
><a href
="options_order.php?method=move&positions=1&num=<?php echo $sQuery; ?>"> <?php
echo _("down");?
> </a
></small
></td
>
203 <td
><small
> 
;|
 
;</small
></td
>
205 /* Always show the subject */
206 if ($iCol !== SQM_COL_SUBJ
&& $iCol !== SQM_COL_FLAGS
) {
208 <td
><small
><a href
="options_order.php?method=remove&num=<?php echo $sQuery; ?>"> <?php
echo _("remove");?
> </a
></small
></td
>
212 <td
><small
> 
;|
 
;</small
></td
>
213 <td
><?php
echo $aColumns[$iCol]; ?
></td
>
223 echo addForm('options_order.php', 'get', 'f');
224 echo addSelect('num', $aOpts, '', TRUE);
225 echo addHidden('method', 'add');
226 if (isset($mailbox) && $mailbox) {
227 echo addHidden('mailbox', urlencode($mailbox));
229 echo addSubmit(_("Add"), 'submit');
233 <p
><a href
="../src/options.php"><?php
echo _("Return to options page");?
></a
></p
><br
>