[1678] | 1 | <?php |
---|
| 2 | /**************************************************************************\ |
---|
| 3 | * -------------------------------------------------------------------------* |
---|
| 4 | * This library is free software; you can redistribute it and/or modify it * |
---|
| 5 | * under the terms of the GNU Lesser General Public License as published by * |
---|
| 6 | * the Free Software Foundation; either version 2.1 of the License, * |
---|
| 7 | * or any later version. * |
---|
| 8 | \**************************************************************************/ |
---|
| 9 | |
---|
| 10 | class uiconfig |
---|
| 11 | { |
---|
| 12 | var $public_functions = array( |
---|
| 13 | 'search_dir' => True, |
---|
| 14 | 'update_quota' => True, |
---|
| 15 | 'load_quota' => True, |
---|
[1787] | 16 | 'quota' => True, |
---|
| 17 | 'removeFolder' => True, |
---|
[1888] | 18 | 'reconstructFolder' => True, |
---|
| 19 | 'renameFolder' => True, |
---|
[1787] | 20 | 'folders' => True |
---|
[1678] | 21 | ); |
---|
| 22 | |
---|
| 23 | function vfs_functions(){ |
---|
| 24 | } |
---|
[1787] | 25 | function folders(){ |
---|
| 26 | $GLOBALS['phpgw_info']['flags'] = array |
---|
| 27 | ( |
---|
| 28 | 'currentapp' => 'filemanager', |
---|
| 29 | 'noheader' => False, |
---|
| 30 | 'nonavbar' => False, |
---|
| 31 | 'nofooter' => False, |
---|
| 32 | 'noappheader' => False, |
---|
| 33 | 'enable_browser_class' => True |
---|
| 34 | ); |
---|
[1678] | 35 | |
---|
[1787] | 36 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
| 37 | include('load_lang.php'); |
---|
| 38 | echo "<script src='".$GLOBALS['phpgw_info']['flags']['currentapp']."/js/connector.js'></script>"; |
---|
| 39 | echo "<script src='".$GLOBALS['phpgw_info']['flags']['currentapp']."/js/common_functions.js'></script>"; |
---|
| 40 | echo "<script src='".$GLOBALS['phpgw_info']['flags']['currentapp']."/js/config.js'></script>"; |
---|
| 41 | $t = $GLOBALS['phpgw']->template; |
---|
| 42 | $t->set_file(array('config_list' => 'config_folders.tpl')); |
---|
| 43 | $t->set_block('config_list','body','body'); |
---|
| 44 | $vars[lang_directory]=lang('directory'); |
---|
| 45 | $vars[lang_search]=lang('search'); |
---|
| 46 | $vars[lang_remove]=lang('remove'); |
---|
[1888] | 47 | $vars[lang_rename]=lang('rename'); |
---|
| 48 | $vars[lang_reconstruct]=lang('reconstruct'); |
---|
[1787] | 49 | |
---|
| 50 | $t->set_var($vars); |
---|
| 51 | $t->pparse('out','body'); |
---|
| 52 | $GLOBALS['phpgw']->common->phpgw_footer(); |
---|
| 53 | $GLOBALS['phpgw']->common->phpgw_exit(); |
---|
| 54 | |
---|
| 55 | } |
---|
| 56 | function removeFolder(){ |
---|
| 57 | $GLOBALS['phpgw_info']['flags'] = array |
---|
| 58 | ( |
---|
| 59 | 'currentapp' => 'filemanager', |
---|
| 60 | 'noheader' => True, |
---|
| 61 | 'nonavbar' => True, |
---|
| 62 | 'nofooter' => True, |
---|
| 63 | 'noappheader' => True, |
---|
| 64 | 'enable_browser_class' => True |
---|
| 65 | ); |
---|
| 66 | $bo = CreateObject('filemanager.bofilemanager'); |
---|
| 67 | $name = $GLOBALS['phpgw']->db->db_addslashes(base64_decode($_GET['dir'])); |
---|
| 68 | if (strlen($name) < 2) |
---|
| 69 | return false; |
---|
| 70 | $bo->vfs->delete(array( |
---|
| 71 | 'string' => $name, |
---|
| 72 | 'relatives' => array(RELATIVE_NONE) |
---|
| 73 | )); |
---|
| 74 | |
---|
[1791] | 75 | /* Clean the log */ |
---|
[1787] | 76 | $GLOBALS['phpgw']->db->query('DELETE FROM phpgw_vfs WHERE directory = \''.$name.'\'',__LINE__,__FILE__); |
---|
| 77 | if ($GLOBALS['phpgw']->db->Error) |
---|
| 78 | echo "Erro"; |
---|
| 79 | else |
---|
| 80 | { |
---|
| 81 | $GLOBALS['phpgw']->db->query('DELETE FROM phpgw_vfs_quota WHERE directory = \''.$name.'\'',__LINE__,__FILE__); |
---|
| 82 | if (!$GLOBALS['phpgw']->db->Error) |
---|
| 83 | echo lang('directory removed sucessfully'); |
---|
| 84 | else |
---|
| 85 | echo "Erro"; |
---|
| 86 | } |
---|
| 87 | return; |
---|
| 88 | |
---|
| 89 | } |
---|
[1888] | 90 | function reconstructFolder(){ |
---|
| 91 | $GLOBALS['phpgw_info']['flags'] = array |
---|
| 92 | ( |
---|
| 93 | 'currentapp' => 'filemanager', |
---|
| 94 | 'noheader' => True, |
---|
| 95 | 'nonavbar' => True, |
---|
| 96 | 'nofooter' => True, |
---|
| 97 | 'noappheader' => True, |
---|
| 98 | 'enable_browser_class' => True |
---|
| 99 | ); |
---|
| 100 | $bo = CreateObject('filemanager.bofilemanager'); |
---|
| 101 | $name = $GLOBALS['phpgw']->db->db_addslashes(base64_decode($_GET['dir'])); |
---|
| 102 | if (strlen($name) < 2) |
---|
| 103 | return false; |
---|
| 104 | $bo->vfs->update_real(array( |
---|
| 105 | 'string' => $name, |
---|
| 106 | 'relatives' => array(RELATIVE_NONE) |
---|
| 107 | )); |
---|
| 108 | $bo->vfs->flush_journal(array( |
---|
| 109 | 'string' => $name, |
---|
| 110 | 'relatives' => array(RELATIVE_NONE), |
---|
| 111 | 'deleteall' => True |
---|
| 112 | )); |
---|
| 113 | echo lang('Your operation was successfully executed'); |
---|
| 114 | } |
---|
[1787] | 115 | |
---|
[1888] | 116 | function renameFolder(){ |
---|
| 117 | $GLOBALS['phpgw_info']['flags'] = array |
---|
| 118 | ( |
---|
| 119 | 'currentapp' => 'filemanager', |
---|
| 120 | 'noheader' => True, |
---|
| 121 | 'nonavbar' => True, |
---|
| 122 | 'nofooter' => True, |
---|
| 123 | 'noappheader' => True, |
---|
| 124 | 'enable_browser_class' => True |
---|
| 125 | ); |
---|
| 126 | $bo = CreateObject('filemanager.bofilemanager'); |
---|
| 127 | $name = $GLOBALS['phpgw']->db->db_addslashes(base64_decode($_GET['dir'])); |
---|
| 128 | $to = $GLOBALS['phpgw']->db->db_addslashes(base64_decode($_GET['to'])); |
---|
| 129 | if (strlen($name) < 2) |
---|
| 130 | return false; |
---|
| 131 | if ( $bo->vfs->mv(array( |
---|
| 132 | 'from' => $name, |
---|
| 133 | 'to' => $to, |
---|
| 134 | 'relatives' => array(RELATIVE_NONE) |
---|
| 135 | )) ){ |
---|
| 136 | $bo->vfs->flush_journal(array( |
---|
| 137 | 'string' => $name, |
---|
| 138 | 'relatives' => array(RELATIVE_NONE), |
---|
| 139 | 'deleteall' => True |
---|
| 140 | )); |
---|
| 141 | echo lang('Your operation was successfully executed'); |
---|
| 142 | } |
---|
| 143 | else |
---|
| 144 | echo lang('Error'); |
---|
| 145 | } |
---|
[1787] | 146 | |
---|
[1678] | 147 | function quota(){ |
---|
| 148 | $GLOBALS['phpgw_info']['flags'] = array |
---|
| 149 | ( |
---|
| 150 | 'currentapp' => 'filemanager', |
---|
| 151 | 'noheader' => False, |
---|
| 152 | 'nonavbar' => False, |
---|
| 153 | 'nofooter' => False, |
---|
| 154 | 'noappheader' => False, |
---|
| 155 | 'enable_browser_class' => True |
---|
| 156 | ); |
---|
| 157 | |
---|
| 158 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
[1726] | 159 | include('load_lang.php'); |
---|
[1678] | 160 | echo "<script src='".$GLOBALS['phpgw_info']['flags']['currentapp']."/js/connector.js'></script>"; |
---|
| 161 | echo "<script src='".$GLOBALS['phpgw_info']['flags']['currentapp']."/js/common_functions.js'></script>"; |
---|
[1787] | 162 | echo "<script src='".$GLOBALS['phpgw_info']['flags']['currentapp']."/js/config.js'></script>"; |
---|
| 163 | $t = $GLOBALS['phpgw']->template; |
---|
| 164 | $t->set_file(array('config_list' => 'config_quota.tpl')); |
---|
| 165 | $t->set_block('config_list','body','body'); |
---|
| 166 | $vars[lang_directory]=lang('directory'); |
---|
| 167 | $vars[lang_search]=lang('search'); |
---|
| 168 | $vars[lang_save]=lang('save'); |
---|
| 169 | |
---|
| 170 | $t->set_var($vars); |
---|
| 171 | $t->pparse('out','body'); |
---|
| 172 | $GLOBALS['phpgw']->common->phpgw_footer(); |
---|
| 173 | $GLOBALS['phpgw']->common->phpgw_exit(); |
---|
| 174 | |
---|
[1678] | 175 | } |
---|
| 176 | function search_dir(){ |
---|
| 177 | $GLOBALS['phpgw_info']['flags'] = array |
---|
| 178 | ( |
---|
| 179 | 'currentapp' => 'filemanager', |
---|
| 180 | 'noheader' => True, |
---|
| 181 | 'nonavbar' => True, |
---|
| 182 | 'nofooter' => True, |
---|
| 183 | 'noappheader' => True, |
---|
| 184 | 'enable_browser_class' => True |
---|
| 185 | ); |
---|
| 186 | $name = $GLOBALS['phpgw']->db->db_addslashes($_GET['name']); |
---|
| 187 | $GLOBALS['phpgw']->db->query('SELECT DISTINCT directory FROM phpgw_vfs WHERE directory like \'%'.$name.'%\' LIMIT 20',__LINE__,__FILE__); |
---|
| 188 | while ($GLOBALS['phpgw']->db->next_record()){ |
---|
| 189 | $val = $GLOBALS['phpgw']->db->row(); |
---|
| 190 | echo "<option>".$val['directory']."</option>"; |
---|
| 191 | } |
---|
| 192 | } |
---|
| 193 | function update_quota(){ |
---|
| 194 | $GLOBALS['phpgw_info']['flags'] = array |
---|
| 195 | ( |
---|
| 196 | 'currentapp' => 'filemanager', |
---|
| 197 | 'noheader' => True, |
---|
| 198 | 'nonavbar' => True, |
---|
| 199 | 'nofooter' => True, |
---|
| 200 | 'noappheader' => True, |
---|
| 201 | 'enable_browser_class' => True |
---|
| 202 | ); |
---|
| 203 | $name = $GLOBALS['phpgw']->db->db_addslashes(base64_decode($_GET['dir'])); |
---|
| 204 | $size = ($_GET['val'])*1; |
---|
[1823] | 205 | |
---|
| 206 | /* See if quota exists or not */ |
---|
| 207 | $query = "SELECT count(directory) FROM phpgw_vfs_quota WHERE directory = '".$name."' LIMIT 1"; |
---|
| 208 | if ($GLOBALS['phpgw']->db->query($query) && $GLOBALS['phpgw']->db->next_record()) |
---|
| 209 | $val = $GLOBALS['phpgw']->db->row(); |
---|
[1678] | 210 | else |
---|
[1823] | 211 | { |
---|
| 212 | echo $GLOBALS['phpgw']->db->error; |
---|
| 213 | return false; |
---|
| 214 | } |
---|
| 215 | if ($val['count'] == '1') |
---|
| 216 | { |
---|
| 217 | $GLOBALS['phpgw']->db->query('UPDATE phpgw_vfs_quota SET quota_size = '.$size.' WHERE directory = \''.$name.'\'',__LINE__,__FILE__); |
---|
| 218 | if ($GLOBALS['phpgw']->db->Error) |
---|
| 219 | echo "Erro"; |
---|
| 220 | else |
---|
| 221 | echo lang('entry updated sucessfully'); |
---|
| 222 | } |
---|
| 223 | else |
---|
| 224 | { |
---|
| 225 | /*preferences does not exist*/ |
---|
| 226 | $query = "INSERT INTO phpgw_vfs_quota values ('".$name."',".$size.")"; |
---|
| 227 | if (!$GLOBALS['phpgw']->db->query($query)) |
---|
| 228 | echo $GLOBALS['phpgw']->db->error; |
---|
| 229 | else |
---|
| 230 | echo lang('entry updated sucessfully'); |
---|
| 231 | } |
---|
[1678] | 232 | return; |
---|
| 233 | } |
---|
| 234 | function load_quota(){ |
---|
| 235 | $GLOBALS['phpgw_info']['flags'] = array |
---|
| 236 | ( |
---|
| 237 | 'currentapp' => 'filemanager', |
---|
| 238 | 'noheader' => True, |
---|
| 239 | 'nonavbar' => True, |
---|
| 240 | 'nofooter' => True, |
---|
| 241 | 'noappheader' => True, |
---|
| 242 | 'enable_browser_class' => True |
---|
| 243 | ); |
---|
| 244 | $name = $GLOBALS['phpgw']->db->db_addslashes(base64_decode($_GET['name'])); |
---|
| 245 | $GLOBALS['phpgw']->db->query('SELECT quota_size FROM phpgw_vfs_quota WHERE directory = \''.$name.'\' LIMIT 1',__LINE__,__FILE__); |
---|
| 246 | $GLOBALS['phpgw']->db->next_record(); |
---|
| 247 | $val =$GLOBALS['phpgw']->db->row(); |
---|
| 248 | echo $val['quota_size']; |
---|
| 249 | return; |
---|
| 250 | |
---|
| 251 | } |
---|
| 252 | |
---|
| 253 | |
---|
| 254 | } |
---|
| 255 | ?> |
---|