HotPot: refine detection of media urls in escaped javascript and <param> tags
[moodle.git] / webservice / lib.php
CommitLineData
06e7fadc 1<?php
cc93c7da 2
3// This file is part of Moodle - http://moodle.org/
4//
5// Moodle is free software: you can redistribute it and/or modify
6// it under the terms of the GNU General Public License as published by
7// the Free Software Foundation, either version 3 of the License, or
8// (at your option) any later version.
9//
10// Moodle is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14//
15// You should have received a copy of the GNU General Public License
16// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
17
06e7fadc 18/**
cc93c7da 19 * Web services utility functions and classes
06e7fadc 20 *
06e7fadc 21 * @package webservice
551f4420 22 * @copyright 2009 Moodle Pty Ltd (http://moodle.com)
cc93c7da 23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
06e7fadc 24 */
25
cc93c7da 26require_once($CFG->libdir.'/externallib.php');
893d7f0f 27
cc93c7da 28function webservice_protocol_is_enabled($protocol) {
29 global $CFG;
893d7f0f 30
cc93c7da 31 if (empty($CFG->enablewebservices)) {
32 return false;
893d7f0f 33 }
34
cc93c7da 35 $active = explode(',', $CFG->webserviceprotocols);
893d7f0f 36
cc93c7da 37 return(in_array($protocol, $active));
38}
893d7f0f 39
cc93c7da 40/**
41 * Mandatory web service server interface
42 * @author Petr Skoda (skodak)
43 */
44interface webservice_server {
45 /**
46 * Process request from client.
47 * @param bool $simple use simple authentication
48 * @return void
49 */
50 public function run($simple);
893d7f0f 51}
52
06e7fadc 53/**
cc93c7da 54 * Special abstraction of our srvices that allows
55 * interaction with stock Zend ws servers.
56 * @author skodak
06e7fadc 57 */
cc93c7da 58abstract class webservice_zend_server implements webservice_server {
88098133 59
60 /** @property string name of the zend server class */
61 protected $zend_class;
62
63 /** @property object Zend server instance */
64 protected $zend_server;
65
66 /** @property string $wsname name of the web server plugin */
67 protected $wsname = null;
68
69 /** @property bool $simple true if simple auth used */
70 protected $simple;
71
72 /** @property string $service_class virtual web service class with all functions user name execute, created on the fly */
73 protected $service_class;
74
75 /** @property object restricted context */
76 protected $restricted_context;
77
78 /**
79 * Contructor
80 */
81 public function __construct($zend_class) {
82 $this->zend_class = $zend_class;
83 }
84
85 /**
86 * Process request from client.
87 * @param bool $simple use simple authentication
88 * @return void
89 */
90 public function run($simple) {
91 $this->simple = $simple;
92
93 // we will probably need a lot of memory in some functions
94 @raise_memory_limit('128M');
95
96 // set some longer timeout, this script is not sending any output,
97 // this means we need to manually extend the timeout operations
98 // that need longer time to finish
99 external_api::set_timeout();
100
101 // set up exception handler first, we want to sent them back in correct format that
102 // the other system understands
103 // we do not need to call the original default handler because this ws handler does everything
104 set_exception_handler(array($this, 'exception_handler'));
105
106 // now create the instance of zend server
107 $this->init_zend_server();
108
109 // this sets up $USER and $SESSION and context restrictions
110 $this->authenticate_user();
111
112 // make a list of all functions user is allowed to excecute
113 $this->init_service_class();
114
115 // start the server
116 $this->zend_server->setClass($this->service_class);
117 $response = $this->zend_server->handle();
118
119 // session cleanup
120 $this->session_cleanup();
121
122 //TODO: we need to send some headers too I guess
123 echo $response;
124 die;
125 }
126
127 /**
128 * Load virtual class needed for Zend api
129 * @return void
130 */
131 protected function init_service_class() {
132 global $USER, $DB;
133
134 // first ofall get a complete list of services user is allowed to access
135 if ($this->simple) {
136 // now make sure the function is listed in at least one service user is allowed to use
137 // allow access only if:
138 // 1/ entry in the external_services_users table if required
139 // 2/ validuntil not reached
140 // 3/ has capability if specified in service desc
141 // 4/ iprestriction
142
143 $sql = "SELECT s.*, NULL AS iprestriction
144 FROM {external_services} s
145 JOIN {external_services_functions} sf ON (sf.externalserviceid = s.id AND s.restrictedusers = 0)
146 WHERE s.enabled = 1
147
148 UNION
149
150 SELECT s.*, su.iprestriction
151 FROM {external_services} s
152 JOIN {external_services_functions} sf ON (sf.externalserviceid = s.id AND s.restrictedusers = 1)
153 JOIN {external_services_users} su ON (su.externalserviceid = s.id AND su.userid = :userid)
154 WHERE s.enabled = 1 AND su.validuntil IS NULL OR su.validuntil < :now";
155 $params = array('userid'=>$USER->id, 'now'=>time());
156 } else {
157
158 //TODO: token may restrict access to one service only
159 die('not implemented yet');
160 }
161
162 $serviceids = array();
163 $rs = $DB->get_recordset_sql($sql, $params);
164
165 // now make sure user may access at least one service
166 $remoteaddr = getremoteaddr();
167 $allowed = false;
168 foreach ($rs as $service) {
169 if (isset($serviceids[$service->id])) {
170 continue;
171 }
172 if ($service->requiredcapability and !has_capability($service->requiredcapability, $this->restricted_context)) {
173 continue; // cap required, sorry
174 }
175 if ($service->iprestriction and !address_in_subnet($remoteaddr, $service->iprestriction)) {
176 continue; // wrong request source ip, sorry
177 }
178 $serviceids[$service->id] = $service->id;
179 }
180 $rs->close();
181
182 // now get the list of all functions
183 if ($serviceids) {
184 list($serviceids, $params) = $DB->get_in_or_equal($serviceids);
185 $sql = "SELECT f.*
186 FROM {external_functions} f
187 WHERE f.name IN (SELECT sf.functionname
188 FROM {external_services_functions} sf
189 WHERE sf.externalserviceid $serviceids)";
190 $functions = $DB->get_records_sql($sql, $params);
191 } else {
192 $functions = array();
193 }
194
195 // now make the virtual WS class with all the fuctions for this particular user
196 $methods = '';
197 foreach ($functions as $function) {
198 $methods .= $this->get_virtual_method_code($function);
199 }
200
201 $classname = 'webservices_virtual_class_000000';
202 while(class_exists($classname)) {
203 $classname++;
204 }
205
206 $code = '
207/**
208 * Virtual class web services for user id '.$USER->id.' in context '.$this->restricted_context->id.'.
209 */
210class '.$classname.' {
211'.$methods.'
212}
213';
214 // load the virtual class definition into memory
215 eval($code);
216echo "<xmp>".$code."</xmp>";
217 $this->service_class = $classname;
218 }
219
220 /**
221 * returns virtual method code
222 * @param object $function
223 * @return string PHP code
224 */
225 protected function get_virtual_method_code($function) {
226 global $CFG;
227
228 //first find and include the ext implementation class
229 $function->classpath = empty($function->classpath) ? get_component_directory($function->component).'/externallib.php' : $CFG->dirroot.'/'.$function->classpath;
230 if (!file_exists($function->classpath)) {
231 throw new coding_exception('Can not find file with external function implementation');
232 }
233 require_once($function->classpath);
234
235 $function->parameters_method = $function->methodname.'_parameters';
236 $function->returns_method = $function->methodname.'_returns';
237
238 // make sure the implementaion class is ok
239 if (!method_exists($function->classname, $function->methodname)) {
240 throw new coding_exception('Missing implementation method');
241 }
242 if (!method_exists($function->classname, $function->parameters_method)) {
243 throw new coding_exception('Missing parameters description');
244 }
245 if (!method_exists($function->classname, $function->returns_method)) {
246 throw new coding_exception('Missing returned values description');
247 }
248
249 // fetch the parameters description
250 $function->parameters_desc = call_user_func(array($function->classname, $function->parameters_method));
251 if (!($function->parameters_desc instanceof external_function_parameters)) {
252 throw new coding_exception('Invalid parameters description');
253 }
254
255 // fetch the return values description
256 $function->returns_desc = call_user_func(array($function->classname, $function->returns_method));
257 // null means void result or result is ignored
258 if (!is_null($function->returns_desc) and !($function->returns_desc instanceof external_description)) {
259 throw new coding_exception('Invalid return description');
260 }
261
262 $params = array();
263 $params_desc = array();
264 foreach ($function->parameters_desc->keys as $name=>$unused) {
265 $params[] = '$'.$name;
266 $params_desc[] = ' * @param mixed '.$name. '';
267 }
268 $params = implode(', ', $params);
269 $params_desc = implode("\n", $params_desc);
270
271
272 // now crate a virtual method that calls the ext implemenation
273 // TODO: add PHP docs and all missing info here
274
275 $code = '
276 /**
277 * External function: '.$function->name.'
278 * TODO: add proper param and return description
279'.$params_desc.'
280 * @return mixed result
281 */
282 public function '.$function->name.'('.$params.') {
283 return '.$function->classname.'::'.$function->methodname.'('.$params.');
284 }
285';
286 return $code;
287 }
288
289 /**
290 * Set up zend serice class
291 * @return void
292 */
293 protected function init_zend_server() {
294 include "Zend/Loader.php";
295 Zend_Loader::registerAutoload();
296 //TODO: set up some server options and debugging too - maybe a new method
297 //TODO: add some zend exeption handler too
298 $this->zend_server = new $this->zend_class();
299 }
300
301 /**
302 * Send the error information to the WS client.
303 * @param exception $ex
304 * @return void
305 */
306 protected function send_error($ex=null) {
307 var_dump($ex);
308 die('TODO');
309 // TODO: find some way to send the error back through the Zend
310 }
311
312 /**
313 * Authenticate user using username+password or token.
314 * This function sets up $USER global.
315 * It is safe to use has_capability() after this.
316 * This method also verifies user is allowed to use this
317 * server.
318 * @return void
319 */
320 protected function authenticate_user() {
321 global $CFG, $DB;
322
323 if (!NO_MOODLE_COOKIES) {
324 throw new coding_exception('Cookies must be disabled in WS servers!');
325 }
326
327 if ($this->simple) {
328 $this->restricted_context = get_context_instance(CONTEXT_SYSTEM);
329
330 if (!is_enabled_auth('webservice')) {
331 die('WS auth not enabled');
332 }
333
334 if (!$auth = get_auth_plugin('webservice')) {
335 die('WS auth missing');
336 }
337
338 // the username is hardcoded as URL parameter because we can not easily parse the request data :-(
339 if (!$username = optional_param('wsusername', '', PARAM_RAW)) {
340 throw new invalid_parameter_exception('Missing username');
341 }
342
343 // the password is hardcoded as URL parameter because we can not easily parse the request data :-(
344 if (!$password = optional_param('wspassword', '', PARAM_RAW)) {
345 throw new invalid_parameter_exception('Missing password');
346 }
347
348 if (!$auth->user_login_webservice($username, $password)) {
349 throw new invalid_parameter_exception('Wrong username or password');
350 }
351
352 $user = $DB->get_record('user', array('username'=>$username, 'mnethostid'=>$CFG->mnet_localhost_id, 'deleted'=>0), '*', MUST_EXIST);
353
354 // now fake user login, the session is completely empty too
355 session_set_user($user);
356
357 } else {
358
359 //TODO: not implemented yet
360 die('token login not implemented yet');
361 //TODO: $this->restricted_context is derived from the token context
362 }
363
364 if (!has_capability("webservice/$this->wsname:use", $this->restricted_context)) {
365 throw new invalid_parameter_exception('Access to web service not allowed');
366 }
367
368 external_api::set_context_restriction($this->restricted_context);
369 }
370
371 /**
372 * Specialised exception handler, we can not use the standard one because
373 * it can not just print html to output.
374 *
375 * @param exception $ex
376 * @return void does not return
377 */
378 public function exception_handler($ex) {
379 global $CFG, $DB, $SCRIPT;
380
381 // detect active db transactions, rollback and log as error
382 if ($DB->is_transaction_started()) {
383 error_log('Database transaction aborted by exception in ' . $CFG->dirroot . $SCRIPT);
384 try {
385 // note: transaction blocks should never change current $_SESSION
386 $DB->rollback_sql();
387 } catch (Exception $ignored) {
388 }
389 }
390
391 // now let the plugin send the exception to client
392 $this->send_error($ex);
393
394 // some hacks might need a cleanup hook
395 $this->session_cleanup($ex);
396
397 // not much else we can do now, add some logging later
398 exit(1);
399 }
400
401 /**
402 * Future hook needed for emulated sessions.
403 * @param exception $exception null means normal termination, $exception received when WS call failed
404 * @return void
405 */
406 protected function session_cleanup($exception=null) {
407 if ($this->simple) {
408 // nothing needs to be done, there is no persistent session
409 } else {
410 // close emulated session if used
411 }
412 }
413
cc93c7da 414}
415
06e7fadc 416
886d7556 417/**
cc93c7da 418 * Web Service server base class, this class handles both
419 * simple and token authentication.
420 * @author Petr Skoda (skodak)
886d7556 421 */
cc93c7da 422abstract class webservice_base_server implements webservice_server {
423
424 /** @property string $wsname name of the web server plugin */
425 protected $wsname = null;
426
427 /** @property bool $simple true if simple auth used */
428 protected $simple;
429
430 /** @property string $username name of local user */
431 protected $username = null;
432
433 /** @property string $password password of the local user */
434 protected $password = null;
435
436 /** @property string $token authentication token*/
437 protected $token = null;
438
88098133 439 /** @property object restricted context */
440 protected $restricted_context;
441
cc93c7da 442 /** @property array $parameters the function parameters - the real values submitted in the request */
443 protected $parameters = null;
444
445 /** @property string $functionname the name of the function that is executed */
446 protected $functionname = null;
447
448 /** @property object $function full function description */
449 protected $function = null;
450
451 /** @property mixed $returns function return value */
452 protected $returns = null;
06e7fadc 453
454 /**
cc93c7da 455 * Contructor
06e7fadc 456 */
cc93c7da 457 public function __construct() {
06e7fadc 458 }
459
24350e06 460 /**
cc93c7da 461 * This method parses the request input, it needs to get:
462 * 1/ user authentication - username+password or token
463 * 2/ function name
464 * 3/ function parameters
465 *
466 * @return void
24350e06 467 */
cc93c7da 468 abstract protected function parse_request();
24350e06 469
cc93c7da 470 /**
471 * Send the result of function call to the WS client.
472 * @return void
473 */
474 abstract protected function send_response();
24350e06 475
fa0797ec 476 /**
cc93c7da 477 * Send the error information to the WS client.
478 * @param exception $ex
479 * @return void
fa0797ec 480 */
cc93c7da 481 abstract protected function send_error($ex=null);
fa0797ec 482
fa0797ec 483
cc93c7da 484 /**
485 * Process request from client.
486 * @param bool $simple use simple authentication
487 * @return void
488 */
489 public function run($simple) {
490 $this->simple = $simple;
fa0797ec 491
cc93c7da 492 // we will probably need a lot of memory in some functions
493 @raise_memory_limit('128M');
fa0797ec 494
cc93c7da 495 // set some longer timeout, this script is not sending any output,
496 // this means we need to manually extend the timeout operations
497 // that need longer time to finish
498 external_api::set_timeout();
fa0797ec 499
cc93c7da 500 // set up exception handler first, we want to sent them back in correct format that
501 // the other system understands
502 // we do not need to call the original default handler because this ws handler does everything
503 set_exception_handler(array($this, 'exception_handler'));
06e7fadc 504
cc93c7da 505 // init all properties from the request data
506 $this->parse_request();
06e7fadc 507
cc93c7da 508 // authenticate user, this has to be done after the request parsing
509 // this also sets up $USER and $SESSION
510 $this->authenticate_user();
06e7fadc 511
cc93c7da 512 // find all needed function info and make sure user may actually execute the function
513 $this->load_function_info();
f7631e73 514
cc93c7da 515 // finally, execute the function - any errors are catched by the default exception handler
516 $this->execute();
06e7fadc 517
cc93c7da 518 // send the results back in correct format
519 $this->send_response();
06e7fadc 520
cc93c7da 521 // session cleanup
522 $this->session_cleanup();
06e7fadc 523
cc93c7da 524 die;
f7631e73 525 }
526
cc93c7da 527 /**
528 * Specialised exception handler, we can not use the standard one because
529 * it can not just print html to output.
530 *
531 * @param exception $ex
532 * @return void does not return
533 */
534 public function exception_handler($ex) {
535 global $CFG, $DB, $SCRIPT;
536
537 // detect active db transactions, rollback and log as error
538 if ($DB->is_transaction_started()) {
539 error_log('Database transaction aborted by exception in ' . $CFG->dirroot . $SCRIPT);
540 try {
541 // note: transaction blocks should never change current $_SESSION
542 $DB->rollback_sql();
543 } catch (Exception $ignored) {
544 }
545 }
06e7fadc 546
cc93c7da 547 // now let the plugin send the exception to client
548 $this->send_error($ex);
f7631e73 549
cc93c7da 550 // some hacks might need a cleanup hook
551 $this->session_cleanup($ex);
06e7fadc 552
cc93c7da 553 // not much else we can do now, add some logging later
554 exit(1);
f7631e73 555 }
556
557 /**
cc93c7da 558 * Future hook needed for emulated sessions.
559 * @param exception $exception null means normal termination, $exception received when WS call failed
560 * @return void
f7631e73 561 */
cc93c7da 562 protected function session_cleanup($exception=null) {
563 if ($this->simple) {
564 // nothing needs to be done, there is no persistent session
565 } else {
566 // close emulated session if used
567 }
f7631e73 568 }
569
cc93c7da 570 /**
571 * Authenticate user using username+password or token.
572 * This function sets up $USER global.
573 * It is safe to use has_capability() after this.
574 * This method also verifies user is allowed to use this
575 * server.
576 * @return void
577 */
578 protected function authenticate_user() {
579 global $CFG, $DB;
06e7fadc 580
cc93c7da 581 if (!NO_MOODLE_COOKIES) {
582 throw new coding_exception('Cookies must be disabled in WS servers!');
583 }
584
585 if ($this->simple) {
88098133 586 $this->restricted_context = get_context_instance(CONTEXT_SYSTEM);
587
cc93c7da 588 if (!is_enabled_auth('webservice')) {
589 die('WS auth not enabled');
590 }
591
592 if (!$auth = get_auth_plugin('webservice')) {
593 die('WS auth missing');
594 }
595
596 if (!$this->username) {
597 throw new invalid_parameter_exception('Missing username');
598 }
599
600 if (!$this->password) {
601 throw new invalid_parameter_exception('Missing password');
602 }
603
604 if (!$auth->user_login_webservice($this->username, $this->password)) {
605 throw new invalid_parameter_exception('Wrong username or password');
606 }
607
608 $user = $DB->get_record('user', array('username'=>$this->username, 'mnethostid'=>$CFG->mnet_localhost_id, 'deleted'=>0), '*', MUST_EXIST);
609
610 // now fake user login, the session is completely empty too
611 session_set_user($user);
06e7fadc 612 } else {
88098133 613
cc93c7da 614 //TODO: not implemented yet
615 die('token login not implemented yet');
88098133 616 //TODO: $this->restricted_context is derived from the token context
617 }
cc93c7da 618
88098133 619 if (!has_capability("webservice/$this->wsname:use", $this->restricted_context)) {
620 throw new invalid_parameter_exception('Access to web service not allowed');
886d7556 621 }
88098133 622
623 external_api::set_context_restriction($this->restricted_context);
06e7fadc 624 }
24350e06 625
626 /**
cc93c7da 627 * Fetches the function description from database,
628 * verifies user is allowed to use this function and
629 * loads all paremeters and return descriptions.
630 * @return void
24350e06 631 */
cc93c7da 632 protected function load_function_info() {
633 global $DB, $USER, $CFG;
40f024c9 634
cc93c7da 635 if (empty($this->functionname)) {
636 throw new invalid_parameter_exception('Missing function name');
637 }
24350e06 638
cc93c7da 639 // function must exist
640 $function = $DB->get_record('external_functions', array('name'=>$this->functionname), '*', MUST_EXIST);
641
642
643 // now let's verify access control
644 if ($this->simple) {
645 // now make sure the function is listed in at least one service user is allowed to use
646 // allow access only if:
647 // 1/ entry in the external_services_users table if required
648 // 2/ validuntil not reached
649 // 3/ has capability if specified in service desc
650 // 4/ iprestriction
651
652 $sql = "SELECT s.*, NULL AS iprestriction
653 FROM {external_services} s
654 JOIN {external_services_functions} sf ON (sf.externalserviceid = s.id AND s.restrictedusers = 0 AND sf.functionname = :name1)
655 WHERE s.enabled = 1
656
657 UNION
658
659 SELECT s.*, su.iprestriction
660 FROM {external_services} s
661 JOIN {external_services_functions} sf ON (sf.externalserviceid = s.id AND s.restrictedusers = 1 AND sf.functionname = :name2)
662 JOIN {external_services_users} su ON (su.externalserviceid = s.id AND su.userid = :userid)
663 WHERE s.enabled = 1 AND su.validuntil IS NULL OR su.validuntil < :now";
88098133 664 $params = array('userid'=>$USER->id, 'name1'=>$function->name, 'name2'=>$function->name, 'now'=>time());
665 } else {
cc93c7da 666
88098133 667 //TODO: token may restrict access to one service only
668 die('not implemented yet');
669 }
670
671 $rs = $DB->get_recordset_sql($sql, $params);
672 // now make sure user may access at least one service
673 $remoteaddr = getremoteaddr();
674 $allowed = false;
675 foreach ($rs as $service) {
676 if ($service->requiredcapability and !has_capability($service->requiredcapability, $this->restricted_context)) {
677 continue; // cap required, sorry
cc93c7da 678 }
88098133 679 if ($service->iprestriction and !address_in_subnet($remoteaddr, $service->iprestriction)) {
680 continue; // wrong request source ip, sorry
cc93c7da 681 }
88098133 682 $allowed = true;
683 break; // one service is enough, no need to continue
684 }
685 $rs->close();
686 if (!$allowed) {
687 throw new invalid_parameter_exception('Access to external function not allowed');
cc93c7da 688 }
88098133 689 // now we finally know the user may execute this function,
690 // the last step is to set context restriction - in this simple case
691 // we use system context because each external system has different user account
692 // and we can manage everything through normal permissions.
24350e06 693
cc93c7da 694 // get the params and return descriptions of the function
695 unset($function->id); // we want to prevent any accidental db updates ;-)
f7631e73 696
cc93c7da 697 $function->classpath = empty($function->classpath) ? get_component_directory($function->component).'/externallib.php' : $CFG->dirroot.'/'.$function->classpath;
698 if (!file_exists($function->classpath)) {
699 throw new coding_exception('Can not find file with external function implementation');
f7631e73 700 }
cc93c7da 701 require_once($function->classpath);
f7631e73 702
cc93c7da 703 $function->parameters_method = $function->methodname.'_parameters';
704 $function->returns_method = $function->methodname.'_returns';
f7631e73 705
cc93c7da 706 // make sure the implementaion class is ok
707 if (!method_exists($function->classname, $function->methodname)) {
708 throw new coding_exception('Missing implementation method');
709 }
710 if (!method_exists($function->classname, $function->parameters_method)) {
711 throw new coding_exception('Missing parameters description');
712 }
713 if (!method_exists($function->classname, $function->returns_method)) {
714 throw new coding_exception('Missing returned values description');
715 }
9baf6825 716
cc93c7da 717 // fetch the parameters description
718 $function->parameters_desc = call_user_func(array($function->classname, $function->parameters_method));
719 if (!($function->parameters_desc instanceof external_function_parameters)) {
720 throw new coding_exception('Invalid parameters description');
9baf6825 721 }
722
cc93c7da 723 // fetch the return values description
724 $function->returns_desc = call_user_func(array($function->classname, $function->returns_method));
725 // null means void result or result is ignored
726 if (!is_null($function->returns_desc) and !($function->returns_desc instanceof external_description)) {
727 throw new coding_exception('Invalid return description');
9baf6825 728 }
729
cc93c7da 730 // we have all we need now
731 $this->function = $function;
732 }
733
734 /**
735 * Execute previously loaded function using parameters parsed from the request data.
736 * @return void
737 */
738 protected function execute() {
739 // validate params, this also sorts the params properly, we need the correct order in the next part
740 $params = call_user_func(array($this->function->classname, 'validate_parameters'), $this->function->parameters_desc, $this->parameters);
9baf6825 741
cc93c7da 742 // execute - yay!
743 $this->returns = call_user_func_array(array($this->function->classname, $this->function->methodname), array_values($params));
9baf6825 744 }
745}
746
747