Changeset 1998 for trunk/phpgwapi/inc/class.vfs_sql.inc.php
- Timestamp:
- 02/10/10 15:29:22 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/phpgwapi/inc/class.vfs_sql.inc.php
r1928 r1998 1063 1063 } 1064 1064 } 1065 1066 1065 /* We, however, have to decide this ourselves */ 1067 1066 if ($this->file_exists (array( … … 1114 1113 'size' => 0, 1115 1114 'deleteable' => 'Y', 1116 'app' => $currentapp 1115 'app' => $currentapp, 1116 'comment' => '' 1117 1117 ) 1118 1118 ) … … 1158 1158 $quota = $this->get_quota(array('string' => SEP.$path[1].SEP.$path[2])); 1159 1159 $size = $this->get_size(array('string' => SEP.$path[1].SEP.$path[2], 'relatives' => $data['relatives'][1])); 1160 1161 1160 if ($quota > 0 && ($quota * 1024 * 1024) < $size) 1162 1161 return false; … … 1319 1318 } 1320 1319 else 1321 { 1320 { 1322 1321 $this->touch (array( 1323 1322 'string' => $t->fake_full_path, … … 2490 2489 return $size; 2491 2490 } 2491 2492 /*return the total number of files in path*/ 2493 function count_files($data){ 2494 if (!is_array ($data)) 2495 { 2496 $data = array (); 2497 } 2498 2499 $default_values = array 2500 ( 2501 'relatives' => array (RELATIVE_CURRENT) 2502 ); 2503 2504 $data = array_merge ($this->default_values ($data, $default_values), $data); 2505 2506 $p = $this->path_parts (array( 2507 'string' => $data['string'], 2508 'relatives' => RELATIVE_NONE 2509 ) 2510 ); 2511 2512 if (!$this->acl_check (array( 2513 'string' => $p->fake_full_path, 2514 'relatives' => $p->mask, 2515 'operation' => PHPGW_ACL_READ 2516 )) 2517 ) 2518 { 2519 return False; 2520 } 2521 $sql = "SELECT count(*) FROM phpgw_vfs WHERE directory = '".$GLOBALS['phpgw']->db->db_addslashes($data['string'])."'"; 2522 $sql .= $this->extra_sql (array ('query_type' => VFS_SQL_SELECT)); 2523 $query = $GLOBALS['phpgw']->db->query ($sql, __LINE__,__FILE__); 2524 2525 $GLOBALS['phpgw']->db->next_record (); 2526 $record = $GLOBALS['phpgw']->db->Record; 2527 return $record['count']; 2528 } 2529 2492 2530 /* 2493 2531 * get the quota defined for the path in sql table … … 2621 2659 'nofiles' => False, 2622 2660 'summary' => False, 2623 'orderby' => 'directory' 2661 'orderby' => 'directory', 2662 'otype' => 1 2624 2663 ); 2625 2664 … … 2635 2674 $this->attributes['summary'] = 'summary'; 2636 2675 2676 $type = $this->file_type (array( 2677 'string' => $dir, 2678 'relatives' => array ($p->mask) 2679 )); 2637 2680 /* If they pass us a file or 'nofiles' is set, return the info for $dir only */ 2638 if (@$data['file_id'] 2639 || ((($type = $this->file_type (array( 2640 'string' => $dir, 2641 'relatives' => array ($p->mask) 2642 )) != 'Directory')) 2643 || ($data['nofiles'])) && !$p->outside 2644 ) 2681 if (@$data['file_id'] || ($type != 'Directory' || $data['nofiles']) && !$p->outside) 2645 2682 { 2646 2683 /* SELECT all, the, attributes */ … … 2773 2810 $sql .= " AND mime_type='".$data['mime_type']."'"; 2774 2811 } 2775 if (strlen($data['orderby']) > 0) 2776 $sql .= ' ORDER BY '.$data['orderby']; 2812 if (strlen($data['orderby']) > 0 && $data['orderby'] != 'directory'){ 2813 $order_direction = $data['otype'] ? ' ASC' : ' DESC'; 2814 if ($data['orderby'] == 'name' || $data['orderby'] == 'comment') 2815 $sql .= ' ORDER BY upper('.$data['orderby'].')'.$order_direction; 2816 else 2817 $sql .= ' ORDER BY '.$data['orderby'].$order_direction; 2818 if ($data['orderby'] != 'name') 2819 $sql .= ', upper(name)'.$order_direction; 2820 } 2821 $data['offset'] = $data['offset'] ? $data['offset'] : 0; 2822 $data['limit'] = $data['limit'] ? $data['limit'] : 10000; 2823 if ($data['orderby'] != 'directory') 2824 $sql .= ' LIMIT '.$data['limit'].' OFFSET '.$data['offset']; 2777 2825 $query = $GLOBALS['phpgw']->db->query ($sql, __LINE__, __FILE__); 2778 2826
Note: See TracChangeset
for help on using the changeset viewer.