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