Changeset 1627 for trunk/phpgwapi
- Timestamp:
- 11/12/09 09:06:56 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/phpgwapi/inc/class.vfs_sql.inc.php
r1575 r1627 38 38 var $working_id; 39 39 var $working_lid; 40 var $my_home; 40 41 var $meta_types; 41 42 var $now; … … 52 53 $this->working_id = $GLOBALS['phpgw_info']['user']['account_id']; 53 54 $this->working_lid = $GLOBALS['phpgw']->accounts->id2name($this->working_id); 55 $this->my_home = $this->fakebase.'/'.$this->working_lid; 54 56 $this->now = date ('Y-m-d H:i:s'); 55 57 … … 64 66 $this->attributes[] = 'deleteable'; 65 67 $this->attributes[] = 'content'; 68 $this->attributes[] = 'type'; 66 69 67 70 /* … … 612 615 function acl_check ($data) 613 616 { 617 614 618 if (!is_array ($data)) 615 619 { 616 620 $data = array (); 617 621 } 622 623 /* ExpressoLivre principle: In your home you do what you want*/ 624 if (strpos($data['string'],$this->my_home) === 0) 625 return True; 618 626 619 627 $default_values = array … … 845 853 $data = array (); 846 854 } 855 856 $path = explode('/',$data['string']); 857 $quota = $this->get_quota(array('string' => '/'.$path[1].'/'.$path[2])); 858 if ($quota > 0 && $this->get_size($data) >= $quota * 1024 * 1024) 859 return false; 860 847 861 848 862 $default_values = array … … 1082 1096 $data = array (); 1083 1097 } 1098 $path = explode('/',$data['to']); 1099 $quota = $this->get_quota(array('string' => '/'.$path[1].'/'.$path[2])); 1100 $size = $this->get_size(array('string' => $data['to'], 'relatives' => $data['relatives'][1])); 1101 if ($quota > 0 && $size >= $quota * 1024 * 1024) 1102 return false; 1084 1103 1085 1104 $default_values = array … … 1344 1363 $data = array (); 1345 1364 } 1365 1366 $path = explode('/',$data['to']); 1367 $quota = $this->get_quota(array('string' => '/'.$path[1].'/'.$path[2])); 1368 $size = $this->get_size(array('string' => $data['to'], 'relatives' => $data['relatives'][1])); 1369 if ($quota > 0 && $size >= $quota * 1024 * 1024) 1370 return false; 1371 1346 1372 1347 1373 $default_values = array … … 2325 2351 return $size; 2326 2352 } 2353 /* 2354 * get the quota defined for the path in sql table 2355 */ 2356 function get_quota($data){ 2357 if (!is_array ($data)) 2358 { 2359 $data = array (); 2360 } 2361 2362 $default_values = array 2363 ( 2364 'relatives' => array (RELATIVE_CURRENT) 2365 ); 2366 2367 $data = array_merge ($this->default_values ($data, $default_values), $data); 2368 2369 $p = $this->path_parts (array( 2370 'string' => $data['string'], 2371 'relatives' => RELATIVE_NONE 2372 ) 2373 ); 2374 2375 if (!$this->acl_check (array( 2376 'string' => $p->fake_full_path, 2377 'relatives' => $p->mask, 2378 'operation' => PHPGW_ACL_READ 2379 )) 2380 ) 2381 { 2382 return False; 2383 } 2384 $query = $GLOBALS['phpgw']->db->query ("SELECT quota_size FROM phpgw_vfs_quota WHERE directory = '".$data['string']."' LIMIT 1;", __LINE__,__FILE__); 2385 2386 $GLOBALS['phpgw']->db->next_record (); 2387 $record = $GLOBALS['phpgw']->db->Record; 2388 return $record['quota_size']; 2389 } 2390 function set_quota($data){ 2391 if (!is_array ($data)) 2392 { 2393 $data = array (); 2394 } 2395 2396 $default_values = array 2397 ( 2398 'relatives' => array (RELATIVE_CURRENT) 2399 ); 2400 2401 $data = array_merge ($this->default_values ($data, $default_values), $data); 2402 2403 $p = $this->path_parts (array( 2404 'string' => $data['string'], 2405 'relatives' => array ($data['relatives'][0]) 2406 ) 2407 ); 2408 2409 if (!$this->acl_check (array( 2410 'string' => $p->fake_full_path, 2411 'relatives' => array ($p->mask), 2412 'operation' => PHPGW_ACL_READ 2413 )) 2414 ) 2415 { 2416 return False; 2417 } 2418 // INSERT INTO phpgw_vfs_quota values('/home/amuller',200); 2419 // 2420 return $GLOBALS['phpgw']->db->query("INSERT INTO phpgw_vfs_quota VALUES ('".$data['string']."',".$data['new_quota'].");", __LINE__,__FILE__); 2421 } 2422 2327 2423 2328 2424 /*! … … 2399 2495 $dir = $p->fake_full_path; 2400 2496 2497 2401 2498 /* If they pass us a file or 'nofiles' is set, return the info for $dir only */ 2402 2499 if (@$data['file_id'] … … 2428 2525 else 2429 2526 { 2430 $sql .= " directory='".$GLOBALS['phpgw']->db->db_addslashes($p->fake_leading_dirs_clean).2431 " ' ANDname='".$GLOBALS['phpgw']->db->db_addslashes($p->fake_name_clean)."'".2527 $sql .= " directory='".$GLOBALS['phpgw']->db->db_addslashes($p->fake_leading_dirs_clean)."' AND". 2528 " name='".$GLOBALS['phpgw']->db->db_addslashes($p->fake_name_clean)."'". 2432 2529 $this->extra_sql (array ('query_type' => VFS_SQL_SELECT)); 2433 2530 } … … 2508 2605 /* SELECT all, the, attributes FROM phpgw_vfs WHERE file=$dir */ 2509 2606 $sql = 'SELECT '; 2607 if (!$this->acl_check (array ( 2608 'string' => $p->fake_full_path, 2609 'relatives' => array ($p->mask), 2610 'operation' => PHPGW_ACL_PRIVATE) 2611 )) 2612 $query_type = " type != 1 AND"; 2613 else 2614 $query_type = ""; 2510 2615 2511 2616 foreach($this->attributes as $num => $attribute) … … 2520 2625 2521 2626 $dir_clean = $this->clean_string (array ('string' => $dir)); 2522 $sql .= " FROM phpgw_vfs WHERE directory LIKE '".$GLOBALS['phpgw']->db->db_addslashes($dir_clean)."%'";2627 $sql .= " FROM phpgw_vfs WHERE ".$query_type." directory LIKE '".$GLOBALS['phpgw']->db->db_addslashes($dir_clean)."%'"; 2523 2628 $sql .= $this->extra_sql (array ('query_type' => VFS_SQL_SELECT)); 2524 2629 … … 2527 2632 $sql .= " AND mime_type='".$data['mime_type']."'"; 2528 2633 } 2529 2530 $sql .= ' ORDER BY '.$data['orderby']; 2531 2634 if (strlen($data['orderby']) > 0) 2635 $sql .= ' ORDER BY '.$data['orderby']; 2532 2636 $query = $GLOBALS['phpgw']->db->query ($sql, __LINE__, __FILE__); 2533 2637
Note: See TracChangeset
for help on using the changeset viewer.