1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
<?php
/*
* service.php - Abstract super class of all Stud.IP webservices.
*
* Copyright (C) 2006 - Marcus Lunzenauer <mlunzena@uos.de>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*/
/**
* This class is the abstract superclass of all available Stud.IP webservices.
* You have to extend it when implementing your own webservice.
*
* @package studip
* @subpackage ws
*
* @abstract
*
* @author mlunzena
* @copyright (c) Authors
* @version $Id: service.php 3888 2006-09-06 13:27:19Z mlunzena $
*/
class Studip_Ws_Service {
/**
* <FieldDescription>
*
* @access private
* @var array
*/
var $api_methods = array();
/**
* This method is called before every service method.
*
* @param string the function's name.
* @param array an array of arguments that will be delivered to the function.
*
* @return mixed if this method returns a "Studip_Ws_Fault" or "FALSE",
* further processing will be aborted and a "Studip_Ws_Fault"
* delivered.
*/
function before_filter(&$name, &$args) {
}
/**
* This method is called after every service method. You may modify the
* result of that call. This way you can easily implement filters.
*
* @param string the function's name.
* @param array an array of arguments that were delivered to the function.
* @param mixed the result of the last service method call.
*
* @return void
*/
function after_filter(&$name, &$args, &$result) {
}
/**
* <MethodDescription>
*
* @access protected
*
* @param string the methods name
* @param array <description>
* @param mixed <description>
* @param string the description of the method
*
* @return void
*/
function add_api_method($name, $expects = NULL, $returns = NULL,
$description = NULL) {
# check $name
if (!method_exists($this, $name . '_action'))
trigger_error(sprintf('No such method exists: %s.', $name), E_USER_ERROR);
if (isset($this->api_methods[$name])) {
trigger_error(sprintf('Method %s already added.', $name), E_USER_ERROR);
return NULL;
}
return $this->api_methods[$name] =
new Studip_Ws_Method($this, $name, $expects, $returns, $description);
}
/**
* Returns the defined API methods of this service.
*
* @return array the API methods
*/
function &get_api_methods() {
return $this->api_methods;
}
}
|