[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, |
---|
| 18 | 'folders' => True |
---|
[1678] | 19 | ); |
---|
| 20 | |
---|
| 21 | function vfs_functions(){ |
---|
| 22 | } |
---|
[1787] | 23 | function folders(){ |
---|
| 24 | $GLOBALS['phpgw_info']['flags'] = array |
---|
| 25 | ( |
---|
| 26 | 'currentapp' => 'filemanager', |
---|
| 27 | 'noheader' => False, |
---|
| 28 | 'nonavbar' => False, |
---|
| 29 | 'nofooter' => False, |
---|
| 30 | 'noappheader' => False, |
---|
| 31 | 'enable_browser_class' => True |
---|
| 32 | ); |
---|
[1678] | 33 | |
---|
[1787] | 34 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
| 35 | include('load_lang.php'); |
---|
| 36 | echo "<script src='".$GLOBALS['phpgw_info']['flags']['currentapp']."/js/connector.js'></script>"; |
---|
| 37 | echo "<script src='".$GLOBALS['phpgw_info']['flags']['currentapp']."/js/common_functions.js'></script>"; |
---|
| 38 | echo "<script src='".$GLOBALS['phpgw_info']['flags']['currentapp']."/js/config.js'></script>"; |
---|
| 39 | $t = $GLOBALS['phpgw']->template; |
---|
| 40 | $t->set_file(array('config_list' => 'config_folders.tpl')); |
---|
| 41 | $t->set_block('config_list','body','body'); |
---|
| 42 | $vars[lang_directory]=lang('directory'); |
---|
| 43 | $vars[lang_search]=lang('search'); |
---|
| 44 | $vars[lang_remove]=lang('remove'); |
---|
| 45 | |
---|
| 46 | $t->set_var($vars); |
---|
| 47 | $t->pparse('out','body'); |
---|
| 48 | $GLOBALS['phpgw']->common->phpgw_footer(); |
---|
| 49 | $GLOBALS['phpgw']->common->phpgw_exit(); |
---|
| 50 | |
---|
| 51 | } |
---|
| 52 | function removeFolder(){ |
---|
| 53 | $GLOBALS['phpgw_info']['flags'] = array |
---|
| 54 | ( |
---|
| 55 | 'currentapp' => 'filemanager', |
---|
| 56 | 'noheader' => True, |
---|
| 57 | 'nonavbar' => True, |
---|
| 58 | 'nofooter' => True, |
---|
| 59 | 'noappheader' => True, |
---|
| 60 | 'enable_browser_class' => True |
---|
| 61 | ); |
---|
| 62 | $bo = CreateObject('filemanager.bofilemanager'); |
---|
| 63 | $name = $GLOBALS['phpgw']->db->db_addslashes(base64_decode($_GET['dir'])); |
---|
| 64 | if (strlen($name) < 2) |
---|
| 65 | return false; |
---|
| 66 | $bo->vfs->delete(array( |
---|
| 67 | 'string' => $name, |
---|
| 68 | 'relatives' => array(RELATIVE_NONE) |
---|
| 69 | )); |
---|
| 70 | |
---|
[1791] | 71 | /* Clean the log */ |
---|
[1787] | 72 | $GLOBALS['phpgw']->db->query('DELETE FROM phpgw_vfs WHERE directory = \''.$name.'\'',__LINE__,__FILE__); |
---|
| 73 | if ($GLOBALS['phpgw']->db->Error) |
---|
| 74 | echo "Erro"; |
---|
| 75 | else |
---|
| 76 | { |
---|
| 77 | $GLOBALS['phpgw']->db->query('DELETE FROM phpgw_vfs_quota WHERE directory = \''.$name.'\'',__LINE__,__FILE__); |
---|
| 78 | if (!$GLOBALS['phpgw']->db->Error) |
---|
| 79 | echo lang('directory removed sucessfully'); |
---|
| 80 | else |
---|
| 81 | echo "Erro"; |
---|
| 82 | } |
---|
| 83 | return; |
---|
| 84 | |
---|
| 85 | } |
---|
| 86 | |
---|
| 87 | |
---|
[1678] | 88 | function quota(){ |
---|
| 89 | $GLOBALS['phpgw_info']['flags'] = array |
---|
| 90 | ( |
---|
| 91 | 'currentapp' => 'filemanager', |
---|
| 92 | 'noheader' => False, |
---|
| 93 | 'nonavbar' => False, |
---|
| 94 | 'nofooter' => False, |
---|
| 95 | 'noappheader' => False, |
---|
| 96 | 'enable_browser_class' => True |
---|
| 97 | ); |
---|
| 98 | |
---|
| 99 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
[1726] | 100 | include('load_lang.php'); |
---|
[1678] | 101 | echo "<script src='".$GLOBALS['phpgw_info']['flags']['currentapp']."/js/connector.js'></script>"; |
---|
| 102 | echo "<script src='".$GLOBALS['phpgw_info']['flags']['currentapp']."/js/common_functions.js'></script>"; |
---|
[1787] | 103 | echo "<script src='".$GLOBALS['phpgw_info']['flags']['currentapp']."/js/config.js'></script>"; |
---|
| 104 | $t = $GLOBALS['phpgw']->template; |
---|
| 105 | $t->set_file(array('config_list' => 'config_quota.tpl')); |
---|
| 106 | $t->set_block('config_list','body','body'); |
---|
| 107 | $vars[lang_directory]=lang('directory'); |
---|
| 108 | $vars[lang_search]=lang('search'); |
---|
| 109 | $vars[lang_save]=lang('save'); |
---|
| 110 | |
---|
| 111 | $t->set_var($vars); |
---|
| 112 | $t->pparse('out','body'); |
---|
| 113 | $GLOBALS['phpgw']->common->phpgw_footer(); |
---|
| 114 | $GLOBALS['phpgw']->common->phpgw_exit(); |
---|
| 115 | |
---|
[1678] | 116 | } |
---|
| 117 | function search_dir(){ |
---|
| 118 | $GLOBALS['phpgw_info']['flags'] = array |
---|
| 119 | ( |
---|
| 120 | 'currentapp' => 'filemanager', |
---|
| 121 | 'noheader' => True, |
---|
| 122 | 'nonavbar' => True, |
---|
| 123 | 'nofooter' => True, |
---|
| 124 | 'noappheader' => True, |
---|
| 125 | 'enable_browser_class' => True |
---|
| 126 | ); |
---|
| 127 | $name = $GLOBALS['phpgw']->db->db_addslashes($_GET['name']); |
---|
| 128 | $GLOBALS['phpgw']->db->query('SELECT DISTINCT directory FROM phpgw_vfs WHERE directory like \'%'.$name.'%\' LIMIT 20',__LINE__,__FILE__); |
---|
| 129 | while ($GLOBALS['phpgw']->db->next_record()){ |
---|
| 130 | $val = $GLOBALS['phpgw']->db->row(); |
---|
| 131 | echo "<option>".$val['directory']."</option>"; |
---|
| 132 | } |
---|
| 133 | } |
---|
| 134 | function update_quota(){ |
---|
| 135 | $GLOBALS['phpgw_info']['flags'] = array |
---|
| 136 | ( |
---|
| 137 | 'currentapp' => 'filemanager', |
---|
| 138 | 'noheader' => True, |
---|
| 139 | 'nonavbar' => True, |
---|
| 140 | 'nofooter' => True, |
---|
| 141 | 'noappheader' => True, |
---|
| 142 | 'enable_browser_class' => True |
---|
| 143 | ); |
---|
| 144 | $name = $GLOBALS['phpgw']->db->db_addslashes(base64_decode($_GET['dir'])); |
---|
| 145 | $size = ($_GET['val'])*1; |
---|
[1823] | 146 | |
---|
| 147 | /* See if quota exists or not */ |
---|
| 148 | $query = "SELECT count(directory) FROM phpgw_vfs_quota WHERE directory = '".$name."' LIMIT 1"; |
---|
| 149 | if ($GLOBALS['phpgw']->db->query($query) && $GLOBALS['phpgw']->db->next_record()) |
---|
| 150 | $val = $GLOBALS['phpgw']->db->row(); |
---|
[1678] | 151 | else |
---|
[1823] | 152 | { |
---|
| 153 | echo $GLOBALS['phpgw']->db->error; |
---|
| 154 | return false; |
---|
| 155 | } |
---|
| 156 | if ($val['count'] == '1') |
---|
| 157 | { |
---|
| 158 | $GLOBALS['phpgw']->db->query('UPDATE phpgw_vfs_quota SET quota_size = '.$size.' WHERE directory = \''.$name.'\'',__LINE__,__FILE__); |
---|
| 159 | if ($GLOBALS['phpgw']->db->Error) |
---|
| 160 | echo "Erro"; |
---|
| 161 | else |
---|
| 162 | echo lang('entry updated sucessfully'); |
---|
| 163 | } |
---|
| 164 | else |
---|
| 165 | { |
---|
| 166 | /*preferences does not exist*/ |
---|
| 167 | $query = "INSERT INTO phpgw_vfs_quota values ('".$name."',".$size.")"; |
---|
| 168 | if (!$GLOBALS['phpgw']->db->query($query)) |
---|
| 169 | echo $GLOBALS['phpgw']->db->error; |
---|
| 170 | else |
---|
| 171 | echo lang('entry updated sucessfully'); |
---|
| 172 | } |
---|
[1678] | 173 | return; |
---|
| 174 | } |
---|
| 175 | function load_quota(){ |
---|
| 176 | $GLOBALS['phpgw_info']['flags'] = array |
---|
| 177 | ( |
---|
| 178 | 'currentapp' => 'filemanager', |
---|
| 179 | 'noheader' => True, |
---|
| 180 | 'nonavbar' => True, |
---|
| 181 | 'nofooter' => True, |
---|
| 182 | 'noappheader' => True, |
---|
| 183 | 'enable_browser_class' => True |
---|
| 184 | ); |
---|
| 185 | $name = $GLOBALS['phpgw']->db->db_addslashes(base64_decode($_GET['name'])); |
---|
| 186 | $GLOBALS['phpgw']->db->query('SELECT quota_size FROM phpgw_vfs_quota WHERE directory = \''.$name.'\' LIMIT 1',__LINE__,__FILE__); |
---|
| 187 | $GLOBALS['phpgw']->db->next_record(); |
---|
| 188 | $val =$GLOBALS['phpgw']->db->row(); |
---|
| 189 | echo $val['quota_size']; |
---|
| 190 | return; |
---|
| 191 | |
---|
| 192 | } |
---|
| 193 | |
---|
| 194 | |
---|
| 195 | } |
---|
| 196 | ?> |
---|