Source for file options_order.php

Documentation is available at options_order.php

  1. <?php
  2. /**
  3.  * options_order.php
  4.  *
  5.  * Displays messagelist column order options
  6.  *
  7.  * @copyright &copy; 1999-2006 The SquirrelMail Project Team
  8.  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  9.  * @version $Id: options_order.php,v 1.52 2006/09/22 09:29:04 pdontthink Exp $
  10.  * @package squirrelmail
  11.  * @subpackage prefs
  12.  */
  13.  
  14. /**
  15.  * Include the SquirrelMail initialization file.
  16.  */
  17. require('../include/init.php');
  18.  
  19. /* SquirrelMail required files. */
  20. require_once(SM_PATH 'functions/forms.php');
  21.  
  22. /* get globals */
  23. if (sqgetGlobalVar('num',       $num,       SQ_GET)) {
  24.    $num = (int) $num;
  25. else {
  26.    $num false;
  27. }
  28. if (!sqgetGlobalVar('method'$method)) {
  29.     $method '';
  30. else {
  31.     $method htmlspecialchars($method);
  32. }
  33. if (!sqgetGlobalVar('positions'$posSQ_GET)) {
  34.     $pos 0;
  35. else {
  36.     $pos = (int) $pos;
  37. }
  38.  
  39. if (!sqgetGlobalVar('account'$accountSQ_GET)) {
  40.     $iAccount 0;
  41. else {
  42.     $iAccount = (int) $account;
  43. }
  44.  
  45. if (sqgetGlobalVar('mailbox'$mailboxSQ_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];
  49.    }
  50. else {
  51.     $index_order_ser getPref($data_dir$username'index_order');
  52.     if ($index_order_ser{
  53.         $index_order=unserialize($index_order_ser);
  54.     }
  55. }
  56. if (!isset($index_order)) {
  57.     if (isset($internal_date_sort&& $internal_date_sort == false{
  58.     else {
  59.     }
  60. }
  61.  
  62. if (!sqgetGlobalVar('account'$account,  SQ_GET)) {
  63.    $account 0// future work, multiple imap accounts
  64. else {
  65.    $account = (int) $account;
  66. }
  67.  
  68. /* end of get globals */
  69.  
  70. /***************************************************************/
  71. /* Finally, display whatever page we are supposed to show now. */
  72. /***************************************************************/
  73.  
  74. displayPageHeader($color'None'(isset($optpage_data['xtra']$optpage_data['xtra'''));
  75.  
  76.  
  77. /**
  78.  * Change the column order of a mailbox
  79.  *
  80.  * @param array  $index_order (reference) contains an ordered list with columns
  81.  * @param string $method action to take, move, add and remove are supported
  82.  * @param int    $num target column
  83.  * @param int    $pos positions to move a column in the index_order array
  84.  * @return bool  $r A change in the ordered list took place.
  85.  */
  86. function change_columns_list(&$index_order,$method,$num,$pos=0{
  87.     $r false;
  88.     switch ($method{
  89.       case 'move'$r sqm_array_move_value($index_order,$num,$pos)break;
  90.       case 'add':
  91.           $index_order[= (int) $num;
  92.           $r true;
  93.           /**
  94.            * flush the cache in order to retrieve the new columns
  95.            */
  96.           sqsession_unregister('mailbox_cache');
  97.           break;
  98.       case 'remove':
  99.         if(in_array($num$index_order)) {
  100.             unset($index_order[array_search($num$index_order)]);
  101.             $index_order array_values($index_order);
  102.             $r true;
  103.         }
  104.         break;
  105.       defaultbreak;
  106.     }
  107.     return $r;
  108. }
  109.  
  110. /**
  111.  * Column to string translation array
  112.  */
  113. $available[SQM_COL_CHECK]      _("Checkbox");
  114. $available[SQM_COL_FROM]       _("From");
  115. $available[SQM_COL_DATE]       _("Date");
  116. $available[SQM_COL_SUBJ]       _("Subject");
  117. $available[SQM_COL_FLAGS]      _("Flags");
  118. $available[SQM_COL_SIZE]       _("Size");
  119. $available[SQM_COL_PRIO]       _("Priority");
  120. $available[SQM_COL_ATTACHMENT_("Attachments");
  121. $available[SQM_COL_INT_DATE]   _("Received");
  122. $available[SQM_COL_TO]         _("To");
  123. $available[SQM_COL_CC]         _("Cc");
  124. $available[SQM_COL_BCC]        _("Bcc");
  125.  
  126. if (change_columns_list($index_order,$method,$num,$pos)) {
  127.     if ($method{
  128.         // TODO, bound index_order to mailbox and make a difference between the global index_order and mailbox bounded index_order
  129.                 setPref($data_dir$username'index_order'serialize($index_order));
  130.     }
  131. }
  132.  
  133.  
  134. $opts array();
  135. if (count($index_order!= count($available)) {
  136.     for ($i=0$i count($available)$i++{
  137.         if (!in_array($i,$index_order)) {
  138.              $opts[$i$available[$i];
  139.          }
  140.     }
  141. }
  142.  
  143. sqgetGlobalVar('PHP_SELF'$PHP_SELFSQ_SERVER);
  144. $x = isset($mailbox&& $mailbox '&amp;mailbox='.urlencode($mailbox'';
  145.  
  146. $oTemplate->assign('fields'$available);
  147. $oTemplate->assign('current_order'$index_order);
  148. $oTemplate->assign('not_used'$opts);
  149. $oTemplate->assign('always_show'array(SQM_COL_SUBJSQM_COL_FLAGS));
  150.  
  151. $oTemplate->assign('move_up'$PHP_SELF .'?method=move&amp;positions=-1'$x .'&amp;num=');
  152. $oTemplate->assign('move_down'$PHP_SELF .'?method=move&amp;positions=1'$x .'&amp;num=');
  153. $oTemplate->assign('remove'$PHP_SELF .'?method=remove'$x .'&amp;num=');
  154. $oTemplate->assign('add'$PHP_SELF.'?method=add'.$x.'&amp;num=');
  155. $oTemplate->assign('addField_action'$PHP_SELF);
  156.  
  157. $oTemplate->display('options_order.tpl');
  158.  
  159. $oTemplate->display('footer.tpl');
  160. ?>

Documentation generated on Sat, 07 Oct 2006 16:12:57 +0300 by phpDocumentor 1.3.0RC6