[2] | 1 | <?php |
---|
| 2 | /**************************************************************************\ |
---|
| 3 | * eGroupWare - Admin * |
---|
| 4 | * http://www.egroupware.org * |
---|
| 5 | * Written by Miles Lott <milosch@phpwhere.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 | class boserver |
---|
| 15 | { |
---|
| 16 | var $public_functions = array( |
---|
| 17 | 'list_servers' => True, |
---|
| 18 | 'read' => True, |
---|
| 19 | 'edit' => True, |
---|
| 20 | 'delete' => True |
---|
| 21 | ); |
---|
| 22 | |
---|
| 23 | var $xml_functions = array(); |
---|
| 24 | var $soap_functions = array(); |
---|
| 25 | |
---|
| 26 | var $debug = False; |
---|
| 27 | |
---|
| 28 | var $so = ''; |
---|
| 29 | var $start = 0; |
---|
| 30 | var $limit = 0; |
---|
| 31 | var $query = ''; |
---|
| 32 | var $sort = ''; |
---|
| 33 | var $order = ''; |
---|
| 34 | var $total = 0; |
---|
| 35 | |
---|
| 36 | var $use_session = False; |
---|
| 37 | |
---|
| 38 | function boserver($session=False) |
---|
| 39 | { |
---|
| 40 | $this->so = CreateObject('admin.soserver'); |
---|
| 41 | |
---|
| 42 | if($session) |
---|
| 43 | { |
---|
| 44 | $this->read_sessiondata(); |
---|
| 45 | $this->use_session = True; |
---|
| 46 | } |
---|
| 47 | |
---|
| 48 | $start = $GLOBALS['start']; |
---|
| 49 | $query = $GLOBALS['query']; |
---|
| 50 | $sort = $GLOBALS['sort']; |
---|
| 51 | $order = $GLOBALS['order']; |
---|
| 52 | |
---|
| 53 | if(!empty($start) || ($start == '0') || ($start == 0)) |
---|
| 54 | { |
---|
| 55 | if($this->debug) { echo '<br>overriding start: "' . $this->start . '" now "' . $start . '"'; } |
---|
| 56 | $this->start = $start; |
---|
| 57 | } |
---|
| 58 | |
---|
| 59 | if((empty($query) && !empty($this->query)) || !empty($query)) |
---|
| 60 | { |
---|
| 61 | $this->query = $query; |
---|
| 62 | } |
---|
| 63 | |
---|
| 64 | if($limit) { $this->limit = $limit; } |
---|
| 65 | if(isset($sort)) { $this->sort = $sort; } |
---|
| 66 | if(isset($order)) { $this->order = $order; } |
---|
| 67 | } |
---|
| 68 | |
---|
| 69 | function save_sessiondata($data) |
---|
| 70 | { |
---|
| 71 | if ($this->use_session) |
---|
| 72 | { |
---|
| 73 | if($this->debug) { echo '<br>Save:'; _debug_array($data); } |
---|
| 74 | $GLOBALS['phpgw']->session->appsession('session_data','admin_servers',$data); |
---|
| 75 | } |
---|
| 76 | } |
---|
| 77 | |
---|
| 78 | function read_sessiondata() |
---|
| 79 | { |
---|
| 80 | $data = $GLOBALS['phpgw']->session->appsession('session_data','admin_servers'); |
---|
| 81 | if($this->debug) { echo '<br>Read:'; _debug_array($data); } |
---|
| 82 | |
---|
| 83 | $this->start = $data['start']; |
---|
| 84 | $this->limit = $data['limit']; |
---|
| 85 | $this->query = $data['query']; |
---|
| 86 | $this->sort = $data['sort']; |
---|
| 87 | $this->order = $data['order']; |
---|
| 88 | } |
---|
| 89 | |
---|
| 90 | function list_servers() |
---|
| 91 | { |
---|
| 92 | return $this->so->list_servers(array($this->start,$this->sort,$this->order,$this->query,$this->limit),$this->total); |
---|
| 93 | } |
---|
| 94 | |
---|
| 95 | function read($id) |
---|
| 96 | { |
---|
| 97 | if(is_array($id)) |
---|
| 98 | { |
---|
| 99 | $id = $id['server_id']; |
---|
| 100 | } |
---|
| 101 | return $this->so->read($id); |
---|
| 102 | } |
---|
| 103 | |
---|
| 104 | function edit($server_info) |
---|
| 105 | { |
---|
| 106 | if(!is_array($server_info)) |
---|
| 107 | { |
---|
| 108 | return False; |
---|
| 109 | } |
---|
| 110 | |
---|
| 111 | if($server_info['server_id']) |
---|
| 112 | { |
---|
| 113 | return $this->so->update($server_info); |
---|
| 114 | } |
---|
| 115 | else |
---|
| 116 | { |
---|
| 117 | return $this->so->add($server_info); |
---|
| 118 | } |
---|
| 119 | } |
---|
| 120 | |
---|
| 121 | function delete($id) |
---|
| 122 | { |
---|
| 123 | if(is_array($id)) |
---|
| 124 | { |
---|
| 125 | $id = $id['server_id']; |
---|
| 126 | } |
---|
| 127 | return $this->so->delete($id); |
---|
| 128 | } |
---|
| 129 | } |
---|