Ignore:
Timestamp:
Jan 25, 2007, 10:14:35 PM (17 years ago)
Author:
vdigital
Message:

WS_Access_tabble integration in ws_functions.inc.php :

  • workframe
  • many comments
  • to share with rvelices
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/ws_functions.inc.php

    r1744 r1756  
    2828
    2929/**
     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 */       
     48function 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 = '
     57SELECT 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/**
    3071 * returns a "standard" (for our web service) array of sql where clauses that
    3172 * filters the images (images table only)
     
    77118  {
    78119    $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']) ;
    79127  }
    80128  return $clauses;
     
    201249      .implode(',', array_keys($cats) )
    202250      .')';
     251
     252// example of ws_add_controls call   
     253//  $where_clause[] =
     254//          ws_add_controls call( $params, true, $partner, $tbl_name='i.' );
     255   
    203256    $order_by = ws_std_image_sql_order($params, 'i.');
    204257    if (empty($order_by))
Note: See TracChangeset for help on using the changeset viewer.