/[openfoncier]/trunk/services/REST/consultations.php
ViewVC logotype

Contents of /trunk/services/REST/consultations.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 718 - (show annotations)
Fri Nov 16 13:09:39 2012 UTC (12 years, 2 months ago) by mlimic
File size: 2582 byte(s)
Change due to a change in the sendReply function in the base class Services (services/REST/services.php); also added storage of error message when bad file_data given

1 <?php
2
3 /*
4 * Treats requests that deal with consultation of a dossier from an external
5 * source (such as ERP).
6 *
7 * @author: Mirna Limic <[email protected]>
8 * @uses ./restler The RESTLER framework. When using PUT and POST http methods
9 * the function receiving the incomming data MUST contain a parameter called
10 * request_data. The RESTLER framework stores the incoming JSON string converted
11 * into an array in the request_data parameter.
12 *
13 *
14 * Date: 18/10/2012
15 * Follow-up:
16 * Bugs: Unknown
17 *
18 */
19
20
21 include_once ('./REST/services.php');
22 include_once ('./metier/consultationmanager.php');
23
24
25 class consultations extends Services {
26
27 /*
28 * Constructor
29 *
30 * Calls its parent's constructor and fills the contents array with the
31 * keys that are to be searched for in the incoming JSON data.
32 *
33 */
34 public function __construct() {
35 parent::__construct();
36 $this->contents['date_retour'] = '';
37 $this->contents['avis'] = '';
38 }
39
40
41 /*
42 * Destructor
43 *
44 * Call's its parent's destructor.
45 */
46 public function __destruct() {
47 parent::__destruct();
48 //
49 }
50
51
52 /*
53 * Called when a PUT http request is made to update the information
54 * of a consultation given its ID.
55 *
56 * Checks the validity of the format, and the presence of
57 * content (if mandatory) of the data received with the request.
58 * @param mixed $request_data The incoming JSON data as an array.
59 * Note: the parameter has to be named this way due to RESTLER's
60 * parameter mapping of JSON data onto $request_data.
61 * @param string $id The ID of a user.
62 * @return mixed The array contining the return code. Where 400 is
63 * sent if data is missing or bad, and 500 is sent on other error.
64 * 200 is sent on success.
65 */
66 public function put($request_data, $id) {
67 // check that ID is present
68 if (!$id || empty($id)) {
69 $this->sendHttpCode(400, 'No ID supplied.');
70 }
71
72 // check the validity of the request
73 $optional = array('motivation', 'nom_fichier', 'fichier_base64');
74 if (!$this->requestValid($request_data, $optional)) {
75 return $this->sendHttpCode(400, 'Missing mandatory data.');
76 }
77
78 $this->metier_manager = new ConsultationManager();
79 $ret = $this->metier_manager->consultationDecision($request_data, $id);
80
81 // send the reply
82 return $this->sendReply($ret, $this->metier_manager->getMessage());
83 }
84
85 }
86
87 ?>

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26