[2000] | 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 | 'search_user' => True, |
---|
| 15 | 'update_quota' => True, |
---|
| 16 | 'load_quota' => True, |
---|
| 17 | 'quota' => True, |
---|
| 18 | 'removeFolder' => True, |
---|
| 19 | 'reconstructFolder' => True, |
---|
| 20 | 'set_owner' => True, |
---|
| 21 | 'set_permission' => True, |
---|
| 22 | 'renameFolder' => True, |
---|
| 23 | 'createFolder' => True, |
---|
| 24 | 'groups_users' => True, |
---|
| 25 | 'folders' => True |
---|
| 26 | ); |
---|
| 27 | |
---|
| 28 | function vfs_functions(){ |
---|
| 29 | } |
---|
[2877] | 30 | function folders() |
---|
| 31 | { |
---|
| 32 | $GLOBALS['phpgw_info']['flags'] = array |
---|
| 33 | ( |
---|
| 34 | 'currentapp' => 'filemanager', |
---|
| 35 | 'nofooter' => false, |
---|
| 36 | 'noappheader' => false, |
---|
| 37 | 'enable_browser_class' => True |
---|
| 38 | ); |
---|
[2000] | 39 | |
---|
[2877] | 40 | $GLOBALS[ 'phpgw'] -> js -> validate_file( 'jscode', 'connector', 'filemanager' ); |
---|
| 41 | $GLOBALS[ 'phpgw'] -> js -> validate_file( 'jscode', 'common_functions', 'filemanager' ); |
---|
| 42 | $GLOBALS[ 'phpgw'] -> js -> validate_file( 'jscode', 'config', 'filemanager' ); |
---|
| 43 | |
---|
[2000] | 44 | $t = $GLOBALS['phpgw']->template; |
---|
| 45 | $t->set_file(array('config_list' => 'config_folders.tpl')); |
---|
| 46 | $t->set_block('config_list','body','body'); |
---|
| 47 | |
---|
[2877] | 48 | $t -> set_var( array( |
---|
| 49 | 'lang_directory' => lang('directory'), |
---|
| 50 | 'lang_search' => lang('search'), |
---|
| 51 | 'lang_remove' => lang('remove'), |
---|
| 52 | 'lang_rename' => lang('rename'), |
---|
| 53 | 'lang_create' => lang('create'), |
---|
| 54 | 'lang_reconstruct' => lang('reconstruct') |
---|
| 55 | ) ); |
---|
[2000] | 56 | |
---|
[2877] | 57 | $t -> pparse( 'out', 'body' ); |
---|
| 58 | $GLOBALS[ 'phpgw' ] -> common -> phpgw_footer( ); |
---|
[2000] | 59 | } |
---|
[2877] | 60 | function groups_users( ) |
---|
| 61 | { |
---|
| 62 | $GLOBALS['phpgw_info']['flags'] = array |
---|
| 63 | ( |
---|
| 64 | 'currentapp' => 'filemanager', |
---|
| 65 | 'nofooter' => false, |
---|
| 66 | 'noappheader' => false, |
---|
| 67 | 'enable_browser_class' => True |
---|
| 68 | ); |
---|
[2000] | 69 | |
---|
[2877] | 70 | $GLOBALS[ 'phpgw'] -> js -> validate_file( 'jscode', 'connector', 'filemanager' ); |
---|
| 71 | $GLOBALS[ 'phpgw'] -> js -> validate_file( 'jscode', 'common_functions', 'filemanager' ); |
---|
| 72 | $GLOBALS[ 'phpgw'] -> js -> validate_file( 'jscode', 'config', 'filemanager' ); |
---|
| 73 | |
---|
[2000] | 74 | $t = $GLOBALS['phpgw']->template; |
---|
| 75 | $t->set_file(array('config_list' => 'config_owner.tpl')); |
---|
| 76 | $t->set_block('config_list','body','body'); |
---|
| 77 | |
---|
[2877] | 78 | $t -> set_var( array( |
---|
| 79 | 'lang_directory' => lang('directory'), |
---|
| 80 | 'lang_search' => lang('search'), |
---|
| 81 | 'lang_setowner' => lang('set owner'), |
---|
| 82 | 'lang_setperm' => lang('set permission'), |
---|
| 83 | 'lang_users_and_groups' => lang('Users and groups') |
---|
| 84 | ) ); |
---|
[2000] | 85 | |
---|
[2877] | 86 | $t -> pparse( 'out', 'body' ); |
---|
| 87 | $GLOBALS[ 'phpgw' ] -> common -> phpgw_footer( ); |
---|
[2000] | 88 | } |
---|
| 89 | |
---|
| 90 | function createFolder(){ |
---|
| 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['name'])); |
---|
| 102 | if (strlen($name) < 2) |
---|
| 103 | return false; |
---|
| 104 | $c = CreateObject('phpgwapi.config','filemanager'); |
---|
| 105 | $c->read_repository(); |
---|
| 106 | $current_config = $c->config_data; |
---|
| 107 | |
---|
| 108 | $bo->vfs->override_acl = 1; |
---|
| 109 | |
---|
| 110 | if ( $bo->vfs->mkdir(array( |
---|
| 111 | 'string' => $name, |
---|
| 112 | 'relatives' => array(RELATIVE_NONE) |
---|
| 113 | )) ) |
---|
| 114 | if ( $bo->vfs->set_quota(array( |
---|
| 115 | 'string' => $name, |
---|
| 116 | 'relatives' => array(RELATIVE_NONE), |
---|
| 117 | 'new_quota' => $current_config['filemanager_quota_size'] |
---|
| 118 | )) ) |
---|
| 119 | $return = True; |
---|
| 120 | |
---|
| 121 | $bo->vfs->override_acl = 0; |
---|
| 122 | if ($return){ |
---|
| 123 | echo "Folder created"; |
---|
| 124 | } |
---|
| 125 | else |
---|
| 126 | echo "Error"; |
---|
| 127 | } |
---|
| 128 | |
---|
| 129 | function removeFolder(){ |
---|
| 130 | $GLOBALS['phpgw_info']['flags'] = array |
---|
| 131 | ( |
---|
| 132 | 'currentapp' => 'filemanager', |
---|
| 133 | 'noheader' => True, |
---|
| 134 | 'nonavbar' => True, |
---|
| 135 | 'nofooter' => True, |
---|
| 136 | 'noappheader' => True, |
---|
| 137 | 'enable_browser_class' => True |
---|
| 138 | ); |
---|
| 139 | $bo = CreateObject('filemanager.bofilemanager'); |
---|
| 140 | $name = $GLOBALS['phpgw']->db->db_addslashes(base64_decode($_GET['dir'])); |
---|
| 141 | if (strlen($name) < 2) |
---|
| 142 | return false; |
---|
[2026] | 143 | if ( $bo->vfs->delete(array( |
---|
[2000] | 144 | 'string' => $name, |
---|
| 145 | 'relatives' => array(RELATIVE_NONE) |
---|
[2026] | 146 | )) ) |
---|
| 147 | { |
---|
| 148 | /* Clean the log */ |
---|
| 149 | $GLOBALS['phpgw']->db->query('DELETE FROM phpgw_vfs WHERE directory = \''.$name.'\'',__LINE__,__FILE__); |
---|
| 150 | if ($GLOBALS['phpgw']->db->Error) |
---|
| 151 | echo "Erro"; |
---|
[2000] | 152 | else |
---|
[2026] | 153 | { |
---|
| 154 | $GLOBALS['phpgw']->db->query('DELETE FROM phpgw_vfs_quota WHERE directory = \''.$name.'\'',__LINE__,__FILE__); |
---|
| 155 | if (!$GLOBALS['phpgw']->db->Error) |
---|
| 156 | echo lang('directory removed sucessfully'); |
---|
| 157 | else |
---|
| 158 | echo "Erro"; |
---|
| 159 | } |
---|
[2000] | 160 | } |
---|
| 161 | return; |
---|
| 162 | |
---|
| 163 | } |
---|
| 164 | function reconstructFolder(){ |
---|
| 165 | $GLOBALS['phpgw_info']['flags'] = array |
---|
| 166 | ( |
---|
| 167 | 'currentapp' => 'filemanager', |
---|
| 168 | 'noheader' => True, |
---|
| 169 | 'nonavbar' => True, |
---|
| 170 | 'nofooter' => True, |
---|
| 171 | 'noappheader' => True, |
---|
| 172 | 'enable_browser_class' => True |
---|
| 173 | ); |
---|
| 174 | $bo = CreateObject('filemanager.bofilemanager'); |
---|
| 175 | $name = $GLOBALS['phpgw']->db->db_addslashes(base64_decode($_GET['dir'])); |
---|
| 176 | if (strlen($name) < 2) |
---|
| 177 | return false; |
---|
| 178 | $bo->vfs->update_real(array( |
---|
| 179 | 'string' => $name, |
---|
| 180 | 'relatives' => array(RELATIVE_NONE) |
---|
| 181 | )); |
---|
| 182 | $bo->vfs->flush_journal(array( |
---|
| 183 | 'string' => $name, |
---|
| 184 | 'relatives' => array(RELATIVE_NONE), |
---|
| 185 | 'deleteall' => True |
---|
| 186 | )); |
---|
| 187 | echo lang('Your operation was successfully executed'); |
---|
| 188 | } |
---|
| 189 | |
---|
| 190 | function renameFolder(){ |
---|
| 191 | $GLOBALS['phpgw_info']['flags'] = array |
---|
| 192 | ( |
---|
| 193 | 'currentapp' => 'filemanager', |
---|
| 194 | 'noheader' => True, |
---|
| 195 | 'nonavbar' => True, |
---|
| 196 | 'nofooter' => True, |
---|
| 197 | 'noappheader' => True, |
---|
| 198 | 'enable_browser_class' => True |
---|
| 199 | ); |
---|
| 200 | $bo = CreateObject('filemanager.bofilemanager'); |
---|
| 201 | $name = $GLOBALS['phpgw']->db->db_addslashes(base64_decode($_GET['dir'])); |
---|
| 202 | $to = $GLOBALS['phpgw']->db->db_addslashes(base64_decode($_GET['to'])); |
---|
| 203 | if (strlen($name) < 2) |
---|
| 204 | return false; |
---|
| 205 | if ( $bo->vfs->mv(array( |
---|
| 206 | 'from' => $name, |
---|
| 207 | 'to' => $to, |
---|
| 208 | 'relatives' => array(RELATIVE_NONE) |
---|
| 209 | )) ){ |
---|
| 210 | $bo->vfs->flush_journal(array( |
---|
| 211 | 'string' => $name, |
---|
| 212 | 'relatives' => array(RELATIVE_NONE), |
---|
| 213 | 'deleteall' => True |
---|
| 214 | )); |
---|
| 215 | echo lang('Your operation was successfully executed'); |
---|
| 216 | } |
---|
| 217 | else |
---|
| 218 | echo lang('Error'); |
---|
| 219 | } |
---|
| 220 | |
---|
[2877] | 221 | function quota( ) |
---|
| 222 | { |
---|
| 223 | $GLOBALS['phpgw_info']['flags'] = array |
---|
| 224 | ( |
---|
| 225 | 'currentapp' => 'filemanager', |
---|
| 226 | 'nofooter' => false, |
---|
| 227 | 'noappheader' => false, |
---|
| 228 | 'enable_browser_class' => True |
---|
| 229 | ); |
---|
[2000] | 230 | |
---|
[2877] | 231 | $GLOBALS[ 'phpgw'] -> js -> validate_file( 'jscode', 'connector', 'filemanager' ); |
---|
| 232 | $GLOBALS[ 'phpgw'] -> js -> validate_file( 'jscode', 'common_functions', 'filemanager' ); |
---|
| 233 | $GLOBALS[ 'phpgw'] -> js -> validate_file( 'jscode', 'config', 'filemanager' ); |
---|
| 234 | |
---|
[2000] | 235 | $t = $GLOBALS['phpgw']->template; |
---|
| 236 | $t->set_file(array('config_list' => 'config_quota.tpl')); |
---|
| 237 | $t->set_block('config_list','body','body'); |
---|
| 238 | |
---|
[2877] | 239 | $t -> set_var( array( |
---|
| 240 | 'lang_directory' => lang('directory'), |
---|
| 241 | 'lang_search' => lang('search'), |
---|
| 242 | 'lang_save' => lang('save') |
---|
| 243 | ) ); |
---|
[2000] | 244 | |
---|
[2877] | 245 | $t -> pparse( 'out', 'body' ); |
---|
| 246 | $GLOBALS[ 'phpgw' ] -> common -> phpgw_footer( ); |
---|
[2000] | 247 | } |
---|
| 248 | function search_dir(){ |
---|
| 249 | $GLOBALS['phpgw_info']['flags'] = array |
---|
| 250 | ( |
---|
| 251 | 'currentapp' => 'filemanager', |
---|
| 252 | 'noheader' => True, |
---|
| 253 | 'nonavbar' => True, |
---|
| 254 | 'nofooter' => True, |
---|
| 255 | 'noappheader' => True, |
---|
| 256 | 'enable_browser_class' => True |
---|
| 257 | ); |
---|
| 258 | $name = $GLOBALS['phpgw']->db->db_addslashes($_GET['name']); |
---|
| 259 | $GLOBALS['phpgw']->db->query('SELECT DISTINCT directory FROM phpgw_vfs WHERE (directory like \'%'.$name.'%\') LIMIT 20',__LINE__,__FILE__); |
---|
| 260 | while ($GLOBALS['phpgw']->db->next_record()){ |
---|
| 261 | $val = $GLOBALS['phpgw']->db->row(); |
---|
| 262 | echo "<option>".$val['directory']."</option>"; |
---|
| 263 | } |
---|
| 264 | $GLOBALS['phpgw']->db->query('SELECT directory,name from phpgw_vfs WHERE directory = \'/home\' and name like \'%'.$name.'%\' LIMIT 1',__LINE__,__FILE__); |
---|
| 265 | if ($GLOBALS['phpgw']->db->next_record()){ |
---|
| 266 | $val = $GLOBALS['phpgw']->db->row(); |
---|
| 267 | echo "<option>".$val['directory']."/".$val['name']."</option>"; |
---|
| 268 | } |
---|
| 269 | |
---|
| 270 | |
---|
| 271 | } |
---|
| 272 | function search_user(){ |
---|
| 273 | $GLOBALS['phpgw_info']['flags'] = array |
---|
| 274 | ( |
---|
| 275 | 'currentapp' => 'filemanager', |
---|
| 276 | 'noheader' => True, |
---|
| 277 | 'nonavbar' => True, |
---|
| 278 | 'nofooter' => True, |
---|
| 279 | 'noappheader' => True, |
---|
| 280 | 'enable_browser_class' => True |
---|
| 281 | ); |
---|
| 282 | $account_info = $GLOBALS['phpgw']->accounts->get_list('both',0,'','',$_GET['name'],'all'); |
---|
| 283 | |
---|
| 284 | foreach($account_info as $val) |
---|
| 285 | echo "<option value='".$val['account_id']."'>".$val['account_lid']."</option>"; |
---|
| 286 | } |
---|
| 287 | function set_permission(){ |
---|
| 288 | $GLOBALS['phpgw_info']['flags'] = array |
---|
| 289 | ( |
---|
| 290 | 'currentapp' => 'filemanager', |
---|
| 291 | 'noheader' => True, |
---|
| 292 | 'nonavbar' => True, |
---|
| 293 | 'nofooter' => True, |
---|
| 294 | 'noappheader' => True, |
---|
| 295 | 'enable_browser_class' => True |
---|
| 296 | ); |
---|
| 297 | $name = $GLOBALS['phpgw']->db->db_addslashes(base64_decode($_GET['dir'])); |
---|
| 298 | $perms = ($_GET['perms'])*1; |
---|
| 299 | $owner = ($_GET['owner'])*1; |
---|
| 300 | $dirs=explode('/',$name); |
---|
| 301 | $GLOBALS['phpgw']->db->query('SELECT owner_id from phpgw_vfs WHERE directory = \'/'.$dirs[1].'\' and name=\''.$dirs[2].'\' LIMIT 1',__LINE__,__FILE__); |
---|
| 302 | if ($GLOBALS['phpgw']->db->next_record()){ |
---|
| 303 | $val = $GLOBALS['phpgw']->db->row(); |
---|
| 304 | $owner_id = $val['owner_id']; |
---|
| 305 | } |
---|
| 306 | |
---|
| 307 | $query = "SELECT count(*) FROM phpgw_acl WHERE acl_appname = 'filemanager' and acl_account = '".$owner_id."' and acl_location='".$owner."'"; |
---|
| 308 | if ($GLOBALS['phpgw']->db->query($query) && $GLOBALS['phpgw']->db->next_record()) |
---|
| 309 | $val = $GLOBALS['phpgw']->db->row(); |
---|
| 310 | else |
---|
| 311 | { |
---|
| 312 | echo $GLOBALS['phpgw']->db->error; |
---|
| 313 | return false; |
---|
| 314 | } |
---|
| 315 | if ($val['count'] == '1') |
---|
| 316 | $GLOBALS['phpgw']->db->query("UPDATE phpgw_acl SET acl_rights = ".$perms." where acl_appname = 'filemanager' and acl_account = '".$owner_id."' AND acl_location = '".$owner."'",__LINE__,__FILE__); |
---|
| 317 | else |
---|
| 318 | $GLOBALS['phpgw']->db->query("INSERT INTO phpgw_acl values('filemanager','".$owner."','".$owner_id."',".$perms.")",__LINE__,__FILE__); |
---|
| 319 | if ($GLOBALS['phpgw']->db->Error) |
---|
| 320 | echo "Erro"; |
---|
| 321 | else |
---|
| 322 | { |
---|
| 323 | echo lang('entry updated sucessfully'); |
---|
| 324 | } |
---|
| 325 | return; |
---|
| 326 | } |
---|
| 327 | |
---|
| 328 | |
---|
| 329 | function set_owner(){ |
---|
| 330 | $GLOBALS['phpgw_info']['flags'] = array |
---|
| 331 | ( |
---|
| 332 | 'currentapp' => 'filemanager', |
---|
| 333 | 'noheader' => True, |
---|
| 334 | 'nonavbar' => True, |
---|
| 335 | 'nofooter' => True, |
---|
| 336 | 'noappheader' => True, |
---|
| 337 | 'enable_browser_class' => True |
---|
| 338 | ); |
---|
| 339 | $name = $GLOBALS['phpgw']->db->db_addslashes(base64_decode($_GET['dir'])); |
---|
| 340 | $owner = ($_GET['owner'])*1; |
---|
| 341 | |
---|
| 342 | $GLOBALS['phpgw']->db->query('UPDATE phpgw_vfs SET owner_id = '.$owner.' WHERE directory = \''.$name.'\'',__LINE__,__FILE__); |
---|
| 343 | if ($GLOBALS['phpgw']->db->Error) |
---|
| 344 | echo "Erro"; |
---|
| 345 | else |
---|
| 346 | { |
---|
| 347 | $dirs=explode('/',$name); |
---|
| 348 | $GLOBALS['phpgw']->db->query('UPDATE phpgw_vfs SET owner_id = '.$owner.' WHERE directory = \'/'.$dirs[1].'\' and name=\''.$dirs[2].'\'',__LINE__,__FILE__); |
---|
| 349 | if ($GLOBALS['phpgw']->db->Error) |
---|
| 350 | echo "Erro"; |
---|
| 351 | else |
---|
| 352 | { |
---|
| 353 | echo lang('entry updated sucessfully'); |
---|
| 354 | } |
---|
| 355 | } |
---|
| 356 | return; |
---|
| 357 | } |
---|
| 358 | |
---|
| 359 | function update_quota(){ |
---|
| 360 | $GLOBALS['phpgw_info']['flags'] = array |
---|
| 361 | ( |
---|
| 362 | 'currentapp' => 'filemanager', |
---|
| 363 | 'noheader' => True, |
---|
| 364 | 'nonavbar' => True, |
---|
| 365 | 'nofooter' => True, |
---|
| 366 | 'noappheader' => True, |
---|
| 367 | 'enable_browser_class' => True |
---|
| 368 | ); |
---|
| 369 | $name = $GLOBALS['phpgw']->db->db_addslashes(base64_decode($_GET['dir'])); |
---|
| 370 | $size = ($_GET['val'])*1; |
---|
| 371 | |
---|
| 372 | /* See if quota exists or not */ |
---|
| 373 | $query = "SELECT count(directory) FROM phpgw_vfs_quota WHERE directory = '".$name."' LIMIT 1"; |
---|
| 374 | if ($GLOBALS['phpgw']->db->query($query) && $GLOBALS['phpgw']->db->next_record()) |
---|
| 375 | $val = $GLOBALS['phpgw']->db->row(); |
---|
| 376 | else |
---|
| 377 | { |
---|
| 378 | echo $GLOBALS['phpgw']->db->error; |
---|
| 379 | return false; |
---|
| 380 | } |
---|
| 381 | if ($val['count'] == '1') |
---|
| 382 | { |
---|
| 383 | $GLOBALS['phpgw']->db->query('UPDATE phpgw_vfs_quota SET quota_size = '.$size.' WHERE directory = \''.$name.'\'',__LINE__,__FILE__); |
---|
| 384 | if ($GLOBALS['phpgw']->db->Error) |
---|
| 385 | echo "Erro"; |
---|
| 386 | else |
---|
| 387 | echo lang('entry updated sucessfully'); |
---|
| 388 | } |
---|
| 389 | else |
---|
| 390 | { |
---|
| 391 | /*preferences does not exist*/ |
---|
| 392 | $query = "INSERT INTO phpgw_vfs_quota values ('".$name."',".$size.")"; |
---|
| 393 | if (!$GLOBALS['phpgw']->db->query($query)) |
---|
| 394 | echo $GLOBALS['phpgw']->db->error; |
---|
| 395 | else |
---|
| 396 | echo lang('entry updated sucessfully'); |
---|
| 397 | } |
---|
| 398 | return; |
---|
| 399 | } |
---|
| 400 | function load_quota(){ |
---|
| 401 | $GLOBALS['phpgw_info']['flags'] = array |
---|
| 402 | ( |
---|
| 403 | 'currentapp' => 'filemanager', |
---|
| 404 | 'noheader' => True, |
---|
| 405 | 'nonavbar' => True, |
---|
| 406 | 'nofooter' => True, |
---|
| 407 | 'noappheader' => True, |
---|
| 408 | 'enable_browser_class' => True |
---|
| 409 | ); |
---|
| 410 | $name = $GLOBALS['phpgw']->db->db_addslashes(base64_decode($_GET['name'])); |
---|
| 411 | $GLOBALS['phpgw']->db->query('SELECT quota_size FROM phpgw_vfs_quota WHERE directory = \''.$name.'\' LIMIT 1',__LINE__,__FILE__); |
---|
| 412 | $GLOBALS['phpgw']->db->next_record(); |
---|
| 413 | $val =$GLOBALS['phpgw']->db->row(); |
---|
| 414 | echo $val['quota_size']; |
---|
| 415 | return; |
---|
| 416 | |
---|
| 417 | } |
---|
| 418 | |
---|
| 419 | |
---|
| 420 | } |
---|
| 421 | ?> |
---|