/[drupal]/contributions/modules/amfphp/amfphp.module
ViewVC logotype

Contents of /contributions/modules/amfphp/amfphp.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.10 - (show annotations) (download) (as text)
Sat Feb 14 20:26:21 2009 UTC (9 months, 1 week ago) by snelson
Branch: MAIN
CVS Tags: DRUPAL-6--1-0-BETA1, HEAD
Branch point for: DRUPAL-6--1
Changes since 1.9: +6 -1 lines
File MIME type: text/x-php
fixed hook_server_error implementation, must trigger_error so that amfphp will send a fault to the client
1 <?php
2 // $Id: amfphp.module,v 1.9 2008/04/12 01:09:53 snelson Exp $
3
4 /*
5 * Implementation of hook_requirements()
6 */
7 function amfphp_requirements($phase) {
8 $t = get_t();
9
10 // Test AMFPHP version
11 $requirements['amfphp'] = array(
12 'title' => $t('AMFPHP'),
13 'value' => $t('1.9 Beta 2'),
14 );
15
16 if (!file_exists(realpath(dirname(__FILE__) . '/amfphp/globals.php'))) {
17 $requirements['amfphp']['value'] = $t('Not found or wrong version');
18 $requirements['amfphp']['description'] = $t('You must dowload <a href="http://downloads.sourceforge.net/amfphp/amfphp-1.9.beta.20080120.zip?modtime=1200844138">AMFPHP 1.9 beta 2</a>, and extract to modules/amfphp/amfphp, or respective site modules directory.');
19 $requirements['amfphp']['severity'] = REQUIREMENT_ERROR;
20 }
21
22 return $requirements;
23 }
24
25 /*
26 * Implementation of hook_server_info()
27 */
28 function amfphp_server_info() {
29 return array(
30 '#name' => 'AMFPHP',
31 '#path' => 'amfphp'
32 );
33 }
34
35 /*
36 * Implementation of hook_server()
37 * here we include the contents of a gateway.php
38 */
39 function amfphp_server() {
40 $path = drupal_get_path('module', 'amfphp');
41 define("PRODUCTION_SERVER", !variable_get('services_debug', FALSE));
42
43 require_once $path . "/amfphp/globals.php";
44 require_once $path . "/overrides/AmfphpGateway.php";
45
46 $gateway = new AmfphpGateway();
47 $gateway->setClassPath($servicesPath);
48 $gateway->setClassMappingsPath($voPath);
49 $gateway->setCharsetHandler("utf8_decode", "ISO-8859-1", "ISO-8859-1");
50 $gateway->setErrorHandling(E_ALL ^ E_NOTICE);
51
52 if(PRODUCTION_SERVER)
53 {
54 $gateway->disableDebug();
55 }
56
57 $gateway->enableGzipCompression(25*1024);
58 $gateway->service();
59 }
60
61 /*
62 * ugly! ugly! ugly!
63 * we need to use a method call wrapper here to convert all 'uid' values in the result
64 * to 'userid'. this is because flex uses the property 'uid' in objects and will overwrite
65 * anything we send with its own value.
66 */
67 function amfphp_method_call($method_name, $args) {
68
69 // convert all userid to uid
70 $args = amfphp_fix_uid($args, 0);
71
72 $result = services_method_call($method_name, $args);
73
74 // convert all uid to userid
75 $result = amfphp_fix_uid($result);
76
77 return $result;
78 }
79
80 /*
81 * ugly! ugly! ugly!
82 */
83 function amfphp_fix_uid($data, $direction = 1) {
84 $uid = 's:3:"uid";';
85 $userid = 's:6:"userid";';
86
87 $from = ($direction) ? $uid : $userid;
88 $to = (!$direction) ? $uid : $userid;
89
90 $data = serialize($data);
91 $data = str_replace($from, $to, $data);
92 $data = unserialize($data);
93
94 return $data;
95 }
96
97 /*
98 * Implementation of hook_server_error()
99 */
100 function amfphp_server_error($message) {
101 // log error to watchdog
102 watchdog('amfphp server', $message, NULL, WATCHDOG_ERROR);
103
104 // we must throw an error here as it is caught by AMFPHP to send faults back
105 // to the client
106 trigger_error($message, E_USER_ERROR);
107 }

  ViewVC Help
Powered by ViewVC 1.1.2