Changeset 1768 for trunk


Ignore:
Timestamp:
Jan 29, 2007, 9:38:08 PM (18 years ago)
Author:
rvelices
Message:

web services: give vincent the calling partner id

Location:
trunk
Files:
4 edited

Legend:

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

    r1698 r1768  
    564564      return new PwgError(WS_ERR_MISSING_PARAM, 'Missing parameters: '.implode(',',$missing_params));
    565565    }
    566 
    567     $result = call_user_func_array($callback, array($params, &$this) );
     566    $result = trigger_event('ws_invoke_allowed', true, $methodName, $params);
     567    if ( strtolower( get_class($result) )!='pwgerror')
     568    {
     569      $result = call_user_func_array($callback, array($params, &$this) );
     570    }
    568571    return $result;
    569572  }
  • trunk/include/ws_functions.inc.php

    r1760 r1768  
    2828
    2929/**
     30 * Event handler for method invocation security check. Should return a PwgError
     31 * if the preconditions are not satifsied for method invocation.
     32 */
     33function ws_isInvokeAllowed($res, $methodName, $params)
     34{
     35  global $conf, $calling_partner_id;
     36  if ( !$conf['ws_access_control'])
     37  {
     38    return $res; // No controls are requested
     39  }
     40  $query = '
     41SELECT * FROM '.WEB_SERVICES_ACCESS_TABLE."
     42 WHERE `name` = '$calling_partner_id'
     43   AND NOW() <= end; ";
     44  $result = pwg_query($query);
     45  $row = mysql_fetch_assoc($result);
     46  if ( empty($row) )
     47  {
     48    return new PwgError(403, 'Partner id does not exist');
     49  }
     50  return $res;
     51}
     52
     53/**
    3054 * ws_add_controls
    3155 * returns additionnal controls if requested
  • trunk/include/ws_protocols/rest_handler.php

    • Property svn:keywords set to Author Date Id Revision
    r1698 r1768  
    55// +-----------------------------------------------------------------------+
    66// | branch        : BSF (Best So Far)
    7 // | file          : $URL: svn+ssh://rvelices@svn.gna.org/svn/phpwebgallery/trunk/action.php $
    8 // | last update   : $Date: 2006-12-21 18:49:12 -0500 (Thu, 21 Dec 2006) $
    9 // | last modifier : $Author: rvelices $
    10 // | revision      : $Rev: 1678 $
     7// | file          : $Id$
     8// | last update   : $Date$
     9// | last modifier : $Author$
     10// | revision      : $Rev$
    1111// +-----------------------------------------------------------------------+
    1212// | This program is free software; you can redistribute it and/or modify  |
     
    3434    foreach ($param_array as $name => $value)
    3535    {
    36       if ($name=='format')
    37         continue;
     36      if ($name=='format' or $name=='partner')
     37        continue; // ignore - special keys
    3838      if ($name=='method')
    3939      {
  • trunk/ws.php

    r1750 r1768  
    3030include_once(PHPWG_ROOT_PATH.'include/ws_core.inc.php');
    3131
     32/**
     33 * event handler that registers standard methods with the web service
     34 */
    3235function ws_addDefaultMethods( $arr )
    3336{
     
    107110}
    108111
    109 add_event_handler('ws_add_methods', 'ws_addDefaultMethods' );
     112add_event_handler('ws_add_methods', 'ws_addDefaultMethods');
    110113
     114
     115add_event_handler('ws_invoke_allowed', 'ws_isInvokeAllowed', EVENT_HANDLER_PRIORITY_NEUTRAL, 3);
     116
     117$calling_partner_id = '';
    111118$requestFormat = null;
    112119$responseFormat = null;
    113120
     121if ( isset($_GET['partner']) )
     122{
     123  $calling_partner_id = $_GET['partner'];
     124}
    114125if ( isset($_GET['format']) )
    115126{
Note: See TracChangeset for help on using the changeset viewer.