[2] | 1 | <?php |
---|
| 2 | /**************************************************************************\ |
---|
| 3 | * phpGroupWare * |
---|
| 4 | * http://www.phpgroupware.org * |
---|
| 5 | * The file written by Joseph Engo <jengo@phpgroupware.org> * |
---|
| 6 | * -------------------------------------------- * |
---|
| 7 | * This program is free software; you can redistribute it and/or modify it * |
---|
| 8 | * under the terms of the GNU General Public License as published by the * |
---|
| 9 | * Free Software Foundation; either version 2 of the License, or (at your * |
---|
| 10 | * option) any later version. * |
---|
| 11 | \**************************************************************************/ |
---|
| 12 | |
---|
| 13 | |
---|
| 14 | $GLOBALS['phpgw_info']['flags'] = Array( |
---|
| 15 | 'noheader' => True, |
---|
| 16 | 'nofooter' => True, |
---|
| 17 | 'currentapp' => 'home' |
---|
| 18 | ); |
---|
| 19 | include('header.inc.php'); |
---|
| 20 | |
---|
| 21 | // if(basename($HTTP_REFERER) != 'home.php') |
---|
| 22 | // { |
---|
| 23 | // Header('Location: '.$GLOBALS['phpgw']->link('/home.php')); |
---|
| 24 | // $GLOBALS['phpgw']->common->phpgw_exit(); |
---|
| 25 | // } |
---|
| 26 | |
---|
| 27 | @reset($GLOBALS['phpgw_info']['user']['preferences']); |
---|
| 28 | //_debug_array($GLOBALS['phpgw_info']['user']['preferences']['portal_order']); |
---|
| 29 | // $GLOBALS['phpgw']->preferences->delete('portal_order'); |
---|
| 30 | // unset($GLOBALS['phpgw_info']['user']['preferences']['portal_order']); |
---|
| 31 | // $GLOBALS['phpgw']->preferences->save_repository(); |
---|
| 32 | |
---|
| 33 | function move_boxes($curr_position,$new_order,$offset,$value_to_check,$max_num) |
---|
| 34 | { |
---|
| 35 | //echo "MOVE: $curr_position,$new_order,$offset,$value_to_check,$max_num<br>"; |
---|
| 36 | if(isset($GLOBALS['phpgw_info']['user']['preferences']['portal_order'][$new_order])) |
---|
| 37 | { |
---|
| 38 | if($new_order == $max_num) |
---|
| 39 | { |
---|
| 40 | if($offset < 0) |
---|
| 41 | { |
---|
| 42 | @ksort($GLOBALS['phpgw_info']['user']['preferences']['portal_order']); |
---|
| 43 | } |
---|
| 44 | else |
---|
| 45 | { |
---|
| 46 | @krsort($GLOBALS['phpgw_info']['user']['preferences']['portal_order']); |
---|
| 47 | } |
---|
| 48 | while(list($seq_order,$appid) = each($GLOBALS['phpgw_info']['user']['preferences']['portal_order'])) |
---|
| 49 | { |
---|
| 50 | if($seq_order != $value_to_check) |
---|
| 51 | { |
---|
| 52 | $prev_seq = $seq_order + $offset; |
---|
| 53 | $GLOBALS['phpgw']->preferences->delete('portal_order',$prev_seq); |
---|
| 54 | $GLOBALS['phpgw']->preferences->add('portal_order',$prev_seq,$appid); |
---|
| 55 | } |
---|
| 56 | } |
---|
| 57 | } |
---|
| 58 | else |
---|
| 59 | { |
---|
| 60 | $GLOBALS['phpgw']->preferences->delete('portal_order',$curr_position); |
---|
| 61 | $GLOBALS['phpgw']->preferences->add('portal_order',$curr_position,(int)$GLOBALS['phpgw_info']['user']['preferences']['portal_order'][$new_order]); |
---|
| 62 | } |
---|
| 63 | } |
---|
| 64 | $GLOBALS['phpgw']->preferences->delete('portal_order',$new_order); |
---|
| 65 | $GLOBALS['phpgw']->preferences->add('portal_order',$new_order,(int)$_GET['app']); |
---|
| 66 | |
---|
| 67 | $GLOBALS['phpgw']->preferences->save_repository(); |
---|
| 68 | } |
---|
| 69 | |
---|
| 70 | //error_reporting(E_ALL); |
---|
| 71 | switch($_GET['control']) |
---|
| 72 | { |
---|
| 73 | //print_debug('set_box', $GLOBALS['phpgw_info']['user']['preferences']['portal_order']),'app',5); |
---|
| 74 | case 'up': |
---|
| 75 | $curr_position = $GLOBALS['phpgw']->common->find_portal_order((int)$_GET['app']); |
---|
| 76 | $max_count = count($GLOBALS['phpgw_info']['user']['preferences']['portal_order']) - 1; |
---|
| 77 | $offset = -1; |
---|
| 78 | if($curr_position <= 0) |
---|
| 79 | { |
---|
| 80 | $new_order = $max_count; |
---|
| 81 | } |
---|
| 82 | else |
---|
| 83 | { |
---|
| 84 | $new_order = $curr_position + $offset; |
---|
| 85 | } |
---|
| 86 | move_boxes($curr_position,$new_order,$offset,0,$max_count); |
---|
| 87 | break; |
---|
| 88 | case 'down': |
---|
| 89 | $curr_position = $GLOBALS['phpgw']->common->find_portal_order((int)$_GET['app']); |
---|
| 90 | $max_count = count($GLOBALS['phpgw_info']['user']['preferences']['portal_order']) - 1; |
---|
| 91 | $offset = 1; |
---|
| 92 | if($curr_position >= $max_count) |
---|
| 93 | { |
---|
| 94 | $new_order = 0; |
---|
| 95 | } |
---|
| 96 | else |
---|
| 97 | { |
---|
| 98 | $new_order = $curr_position + $offset; |
---|
| 99 | } |
---|
| 100 | move_boxes($curr_position,$new_order,$offset,$max_count,0); |
---|
| 101 | break; |
---|
| 102 | case 'edit': |
---|
| 103 | case 'question': |
---|
| 104 | case 'close': |
---|
| 105 | default: |
---|
| 106 | } |
---|
| 107 | |
---|
| 108 | header('Location: '.$GLOBALS['phpgw']->link('/home.php')); |
---|
| 109 | $GLOBALS['phpgw']->common->phpgw_exit(); |
---|
| 110 | ?> |
---|
| 111 | |
---|