Changeset 1756
- Timestamp:
- Jan 25, 2007, 10:14:35 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/ws_functions.inc.php
r1744 r1756 28 28 29 29 /** 30 * ws_add_controls 31 * returns additionnal controls if requested 32 * usable for 99% of Web Service methods 33 * 34 * - Args 35 * $params: is where clauses 36 * $img_tbl: indicates if phpwebgallery_images is selected 37 * $partner: is the key 38 * $tbl_name: is the alias_name in the query (sometimes called correlation name) 39 * - Logic 40 * Access_control is not active: Return 41 * Key is incorrect: Return 0 = 1 (False condition for MySQL) 42 * One of Params doesn't match with type of request: return 0 = 1 again 43 * Access list(id/cat/tag) is converted in expended image-id list 44 * image-id list: converted to an in-where-clause 45 * 46 * The additionnal in-where-clause is return 47 */ 48 function ws_add_controls( $params, $img_tbl=false, $partner='', $tbl_name='' ) 49 { 50 global $conf; 51 if ( !$conf['ws_access_control'] ) 52 { 53 return ' 1 = 1 '; // No controls are requested 54 } 55 // Step 1 - Found Partner 56 $query = ' 57 SELECT FROM '.WEB_SERVICES_ACCESS_TABLE." 58 WHERE `name` = '$partner';"; 59 $result = pwg_query($query); 60 if ( mysql_num_rows( pwg_query($query) ) = 0 ) 61 { 62 return ' 0 = 1 '; // Unknown partner 63 } 64 // Step 2 - Clauses / Request matching 65 // Restrict Request has to be redefined first 66 // Step 3 - Target restrict 67 return $addings; 68 } 69 70 /** 30 71 * returns a "standard" (for our web service) array of sql where clauses that 31 72 * filters the images (images table only) … … 77 118 { 78 119 $clauses[] = $tbl_name.'tn_ext IS NOT NULL'; 120 } 121 // Squared picture to show to rvelices how to solve that kind of request 122 if ( $params['f_square_ratio'] ) 123 { 124 $clauses[] = $tbl_name.'width/'.$tbl_name.'height BETWEEN ' 125 . $params['f_square_ratio'] . ' AND ' 126 . (2 - $params['f_square_ratio']) ; 79 127 } 80 128 return $clauses; … … 201 249 .implode(',', array_keys($cats) ) 202 250 .')'; 251 252 // example of ws_add_controls call 253 // $where_clause[] = 254 // ws_add_controls call( $params, true, $partner, $tbl_name='i.' ); 255 203 256 $order_by = ws_std_image_sql_order($params, 'i.'); 204 257 if (empty($order_by))
Note: See TracChangeset
for help on using the changeset viewer.