Completed
Push — 1.10.x ( f409b5...1f80a0 )
by Julito
112:29 queued 56:28
created
main/inc/lib/events_email.class.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
 
125 125
                 // If the mail only need to be send once (we know that thanks to the events.conf), we log it in the table
126 126
                 if ($event_config[$event_name]["sending_mail_once"]) {
127
-                    $sql = 'INSERT INTO ' . Database::get_main_table(TABLE_EVENT_SENT) . ' (user_from, user_to, event_type_name)
127
+                    $sql = 'INSERT INTO '.Database::get_main_table(TABLE_EVENT_SENT).' (user_from, user_to, event_type_name)
128 128
                             VALUES ('.$event_data["user_id"].', '.$id.' ,"'.Database::escape_string($event_name).'")
129 129
                     ';
130 130
                     Database::query($sql);
@@ -135,9 +135,9 @@  discard block
 block discarded – undo
135 135
         // Second, we send to people linked to the event
136 136
         // So, we get everyone
137 137
         $sql = 'SELECT u.user_id, u.language, u.email, u.firstname, u.lastname
138
-                FROM ' . Database::get_main_table(TABLE_EVENT_TYPE_REL_USER) . ' ue
138
+                FROM ' . Database::get_main_table(TABLE_EVENT_TYPE_REL_USER).' ue
139 139
                 INNER JOIN '.Database::get_main_table(TABLE_MAIN_USER).' u ON u.user_id = ue.user_id
140
-                WHERE event_type_name = "' . $event_name . '"';
140
+                WHERE event_type_name = "' . $event_name.'"';
141 141
         $result = Database::store_result(Database::query($sql), 'ASSOC');
142 142
         // for each of the linked users
143 143
         foreach ($result as $key => $value) {
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
 
178 178
             // If the mail only need to be send once (we know that thanks to the events.conf, we log it in the table
179 179
             if ($event_config[$event_name]["sending_mail_once"]) {
180
-                $sql = 'INSERT INTO ' . Database::get_main_table(TABLE_EVENT_SENT) . '
180
+                $sql = 'INSERT INTO '.Database::get_main_table(TABLE_EVENT_SENT).'
181 181
                     (user_from, user_to, event_type_name)
182 182
                     VALUES ('.$event_data["user_id"].', '.$value["user_id"].' , "'.Database::escape_string($event_name).'");
183 183
                     ';
@@ -202,16 +202,16 @@  discard block
 block discarded – undo
202 202
         $current_language = api_get_interface_language();
203 203
 
204 204
         $sql = 'SELECT COUNT(*) as total
205
-                FROM ' . Database::get_main_table(TABLE_EVENT_EMAIL_TEMPLATE) . ' em
206
-                INNER JOIN ' . Database::get_main_table(TABLE_MAIN_LANGUAGE) . ' l
205
+                FROM ' . Database::get_main_table(TABLE_EVENT_EMAIL_TEMPLATE).' em
206
+                INNER JOIN ' . Database::get_main_table(TABLE_MAIN_LANGUAGE).' l
207 207
                 ON em.language_id = l.id
208 208
                 WHERE
209
-                    em.event_type_name = "' . $event_name . '" and
209
+                    em.event_type_name = "' . $event_name.'" and
210 210
                     l.dokeos_folder = "'.$current_language.'" and
211 211
                     em.activated = 1';
212 212
 
213 213
         $exists = Database::store_result(Database::query($sql), 'ASSOC');
214
-        if ($exists[0]["total"])  {
214
+        if ($exists[0]["total"]) {
215 215
             return true;
216 216
         } else {
217 217
             return false;
@@ -228,12 +228,12 @@  discard block
 block discarded – undo
228 228
     private static function getMessage($event_name, $language)
229 229
     {
230 230
         $sql = 'SELECT message, subject, l.dokeos_folder
231
-                FROM ' . Database::get_main_table(TABLE_EVENT_EMAIL_TEMPLATE) . ' em
232
-                INNER JOIN ' . Database::get_main_table(TABLE_MAIN_LANGUAGE) . ' l
231
+                FROM ' . Database::get_main_table(TABLE_EVENT_EMAIL_TEMPLATE).' em
232
+                INNER JOIN ' . Database::get_main_table(TABLE_MAIN_LANGUAGE).' l
233 233
                 ON em.language_id = l.id
234 234
                 WHERE
235
-                    em.event_type_name = "' . $event_name . '" AND
236
-                    (l.dokeos_folder = "' . $language . '" OR l.dokeos_folder = "english") AND
235
+                    em.event_type_name = "' . $event_name.'" AND
236
+                    (l.dokeos_folder = "' . $language.'" OR l.dokeos_folder = "english") AND
237 237
                     em.message <> ""
238 238
                 ';
239 239
         return Database::store_result(Database::query($sql), 'ASSOC');
@@ -274,8 +274,8 @@  discard block
 block discarded – undo
274 274
     private static function formatMessage(&$message, &$subject, $event_config, $event_name, &$event_data)
275 275
     {
276 276
         foreach ($event_config[$event_name]["available_keyvars"] as $key => $word) {
277
-            $message = str_replace('((' . $key . '))', $event_data[$word], $message);
278
-            $subject = str_replace('((' . $key . '))', $event_data[$word], $subject);
277
+            $message = str_replace('(('.$key.'))', $event_data[$word], $message);
278
+            $subject = str_replace('(('.$key.'))', $event_data[$word], $subject);
279 279
         }
280 280
     }
281 281
 }
Please login to merge, or discard this patch.
main/inc/lib/event_email_template.class.php 2 patches
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -12,10 +12,10 @@  discard block
 block discarded – undo
12 12
     /**
13 13
      * Constructor
14 14
      */
15
-	public function __construct()
15
+    public function __construct()
16 16
     {
17 17
         $this->table =  Database::get_main_table(TABLE_EVENT_EMAIL_TEMPLATE);
18
-	}
18
+    }
19 19
 
20 20
     public function get_all($where_conditions = array())
21 21
     {
@@ -29,19 +29,19 @@  discard block
 block discarded – undo
29 29
     /**
30 30
      * Displays the title + grid
31 31
      */
32
-	public function display()
32
+    public function display()
33 33
     {
34
-		// action links
35
-		$content = Display::actions(array(
34
+        // action links
35
+        $content = Display::actions(array(
36 36
                 array(
37 37
                     'url' => 'event_type.php' ,
38 38
                     'content' => Display::return_icon('new_document.png', get_lang('Add'), array(), ICON_SIZE_MEDIUM)
39
-                 )
39
+                    )
40 40
             )
41 41
         );
42 42
         $content .= Display::grid_html('event_email_template');
43 43
         return $content;
44
-	}
44
+    }
45 45
 
46 46
     public function get_status_list()
47 47
     {
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
                 'Height' => '250',
83 83
             )
84 84
         );
85
-	    $status_list = $this->get_status_list();
85
+        $status_list = $this->get_status_list();
86 86
         $form->addElement('select', 'status', get_lang('Status'), $status_list);
87 87
         if ($action == 'edit') {
88 88
             $form->addElement('text', 'created_at', get_lang('CreatedAt'));
@@ -99,17 +99,17 @@  discard block
 block discarded – undo
99 99
         $defaults = $this->get($id);
100 100
 
101 101
         if (!empty($defaults['created_at'])) {
102
-        	$defaults['created_at'] = api_convert_and_format_date($defaults['created_at']);
102
+            $defaults['created_at'] = api_convert_and_format_date($defaults['created_at']);
103 103
         }
104 104
         if (!empty($defaults['updated_at'])) {
105
-        	$defaults['updated_at'] = api_convert_and_format_date($defaults['updated_at']);
105
+            $defaults['updated_at'] = api_convert_and_format_date($defaults['updated_at']);
106 106
         }
107 107
         $form->setDefaults($defaults);
108 108
 
109 109
         // Setting the rules
110 110
         $form->addRule('name', get_lang('ThisFieldIsRequired'), 'required');
111 111
 
112
-		return $form;
112
+        return $form;
113 113
     }
114 114
 
115 115
     public function get_count()
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -7,14 +7,14 @@  discard block
 block discarded – undo
7 7
 class EventEmailTemplate extends Model
8 8
 {
9 9
     public $table;
10
-    public $columns = array('id', 'message','subject','event_type_name','activated');
10
+    public $columns = array('id', 'message', 'subject', 'event_type_name', 'activated');
11 11
 
12 12
     /**
13 13
      * Constructor
14 14
      */
15 15
 	public function __construct()
16 16
     {
17
-        $this->table =  Database::get_main_table(TABLE_EVENT_EMAIL_TEMPLATE);
17
+        $this->table = Database::get_main_table(TABLE_EVENT_EMAIL_TEMPLATE);
18 18
 	}
19 19
 
20 20
     public function get_all($where_conditions = array())
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 		// action links
35 35
 		$content = Display::actions(array(
36 36
                 array(
37
-                    'url' => 'event_type.php' ,
37
+                    'url' => 'event_type.php',
38 38
                     'content' => Display::return_icon('new_document.png', get_lang('Add'), array(), ICON_SIZE_MEDIUM)
39 39
                  )
40 40
             )
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 
115 115
     public function get_count()
116 116
     {
117
-        $row = Database::select('count(*) as count', $this->table, array(),'first');
117
+        $row = Database::select('count(*) as count', $this->table, array(), 'first');
118 118
 
119 119
         return $row['count'];
120 120
     }
Please login to merge, or discard this patch.
main/inc/lib/wami-recorder/record_document.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@
 block discarded – undo
48 48
 // Do not use here check Fileinfo method because return: text/plain
49 49
 
50 50
 $dirBaseDocuments = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
51
-$saveDir = $dirBaseDocuments . $wamidir;
51
+$saveDir = $dirBaseDocuments.$wamidir;
52 52
 
53 53
 if (!is_dir($saveDir)) {
54 54
     DocumentManager::createDefaultAudioFolder($_course);
Please login to merge, or discard this patch.
main/inc/lib/access_url_edit_users_to_url_functions.lib.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -43,22 +43,22 @@
 block discarded – undo
43 43
                    ' WHERE (username LIKE "'.$needle.'%" '.
44 44
                    ' OR firstname LIKE "'.$needle.'%" '.
45 45
                    ' OR lastname LIKE "'.$needle.'%") '.
46
-                    $order_clause .
46
+                    $order_clause.
47 47
                    ' LIMIT 11';
48 48
 
49 49
             $rs = Database::query($sql);
50
-            $i=0;
50
+            $i = 0;
51 51
 
52 52
             while ($user = Database :: fetch_array($rs)) {
53 53
                 $i++;
54
-                if ($i<=10) {
54
+                if ($i <= 10) {
55 55
                     $return .= '<a href="javascript: void(0);" onclick="javascript: add_user_to_url(\''.addslashes($user['user_id']).'\',\''.api_get_person_name(addslashes($user['firstname']), addslashes($user['lastname'])).' ('.addslashes($user['username']).')'.'\')">'.api_get_person_name($user['firstname'], $user['lastname']).' ('.$user['username'].')</a><br />';
56 56
                 } else {
57 57
                     $return .= '...<br />';
58 58
                 }
59 59
             }
60 60
         }
61
-        $xajax_response -> addAssign('ajax_list_users','innerHTML',api_utf8_encode($return));
61
+        $xajax_response -> addAssign('ajax_list_users', 'innerHTML', api_utf8_encode($return));
62 62
         return $xajax_response;
63 63
     }
64 64
 }
Please login to merge, or discard this patch.
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -40,11 +40,11 @@
 block discarded – undo
40 40
             // search users where username or firstname or lastname begins likes $needle
41 41
             $order_clause = api_sort_by_first_name() ? ' ORDER BY firstname, lastname, username' : ' ORDER BY lastname, firstname, username';
42 42
             $sql = 'SELECT u.user_id, username, lastname, firstname FROM '.$tbl_user.' u '.
43
-                   ' WHERE (username LIKE "'.$needle.'%" '.
44
-                   ' OR firstname LIKE "'.$needle.'%" '.
45
-                   ' OR lastname LIKE "'.$needle.'%") '.
43
+                    ' WHERE (username LIKE "'.$needle.'%" '.
44
+                    ' OR firstname LIKE "'.$needle.'%" '.
45
+                    ' OR lastname LIKE "'.$needle.'%") '.
46 46
                     $order_clause .
47
-                   ' LIMIT 11';
47
+                    ' LIMIT 11';
48 48
 
49 49
             $rs = Database::query($sql);
50 50
             $i=0;
Please login to merge, or discard this patch.
main/inc/lib/nusoap/class.soap_parser.php 2 patches
Indentation   +545 added lines, -545 removed lines patch added patch discarded remove patch
@@ -11,234 +11,234 @@  discard block
 block discarded – undo
11 11
 */
12 12
 class nusoap_parser extends nusoap_base
13 13
 {
14
-	var $xml = '';
15
-	var $xml_encoding = '';
16
-	var $method = '';
17
-	var $root_struct = '';
18
-	var $root_struct_name = '';
19
-	var $root_struct_namespace = '';
20
-	var $root_header = '';
14
+    var $xml = '';
15
+    var $xml_encoding = '';
16
+    var $method = '';
17
+    var $root_struct = '';
18
+    var $root_struct_name = '';
19
+    var $root_struct_namespace = '';
20
+    var $root_header = '';
21 21
     var $document = '';			// incoming SOAP body (text)
22
-	// determines where in the message we are (envelope,header,body,method)
23
-	var $status = '';
24
-	var $position = 0;
25
-	var $depth = 0;
26
-	var $default_namespace = '';
27
-	var $namespaces = array();
28
-	var $message = array();
22
+    // determines where in the message we are (envelope,header,body,method)
23
+    var $status = '';
24
+    var $position = 0;
25
+    var $depth = 0;
26
+    var $default_namespace = '';
27
+    var $namespaces = array();
28
+    var $message = array();
29 29
     var $parent = '';
30
-	var $fault = false;
31
-	var $fault_code = '';
32
-	var $fault_str = '';
33
-	var $fault_detail = '';
34
-	var $depth_array = array();
35
-	var $debug_flag = true;
36
-	var $soapresponse = NULL;	// parsed SOAP Body
37
-	var $soapheader = NULL;		// parsed SOAP Header
38
-	var $responseHeaders = '';	// incoming SOAP headers (text)
39
-	var $body_position = 0;
40
-	// for multiref parsing:
41
-	// array of id => pos
42
-	var $ids = array();
43
-	// array of id => hrefs => pos
44
-	var $multirefs = array();
45
-	// toggle for auto-decoding element content
46
-	var $decode_utf8 = true;
30
+    var $fault = false;
31
+    var $fault_code = '';
32
+    var $fault_str = '';
33
+    var $fault_detail = '';
34
+    var $depth_array = array();
35
+    var $debug_flag = true;
36
+    var $soapresponse = NULL;	// parsed SOAP Body
37
+    var $soapheader = NULL;		// parsed SOAP Header
38
+    var $responseHeaders = '';	// incoming SOAP headers (text)
39
+    var $body_position = 0;
40
+    // for multiref parsing:
41
+    // array of id => pos
42
+    var $ids = array();
43
+    // array of id => hrefs => pos
44
+    var $multirefs = array();
45
+    // toggle for auto-decoding element content
46
+    var $decode_utf8 = true;
47 47
 
48
-	/**
49
-	* constructor that actually does the parsing
50
-	*
51
-	* @param    string $xml SOAP message
52
-	* @param    string $encoding character encoding scheme of message
53
-	* @param    string $method method for which XML is parsed (unused?)
54
-	* @param    string $decode_utf8 whether to decode UTF-8 to ISO-8859-1
55
-	* @access   public
56
-	*/
57
-	function nusoap_parser($xml,$encoding='UTF-8',$method='',$decode_utf8=true){
58
-		parent::nusoap_base();
59
-		$this->xml = $xml;
60
-		$this->xml_encoding = $encoding;
61
-		$this->method = $method;
62
-		$this->decode_utf8 = $decode_utf8;
48
+    /**
49
+     * constructor that actually does the parsing
50
+     *
51
+     * @param    string $xml SOAP message
52
+     * @param    string $encoding character encoding scheme of message
53
+     * @param    string $method method for which XML is parsed (unused?)
54
+     * @param    string $decode_utf8 whether to decode UTF-8 to ISO-8859-1
55
+     * @access   public
56
+     */
57
+    function nusoap_parser($xml,$encoding='UTF-8',$method='',$decode_utf8=true){
58
+        parent::nusoap_base();
59
+        $this->xml = $xml;
60
+        $this->xml_encoding = $encoding;
61
+        $this->method = $method;
62
+        $this->decode_utf8 = $decode_utf8;
63 63
 
64
-		// Check whether content has been read.
65
-		if(!empty($this->xml)){
66
-			// Check XML encoding
67
-			$pos_xml = strpos($xml, '<?xml');
68
-			if ($pos_xml !== FALSE) {
69
-				$xml_decl = substr($xml, $pos_xml, strpos($xml, '?>', $pos_xml + 2) - $pos_xml + 1);
70
-				if (preg_match("/encoding=[\"']([^\"']*)[\"']/", $xml_decl, $res)) {
71
-					$xml_encoding = $res[1];
72
-					if (strtoupper($xml_encoding) != $encoding) {
73
-						$err = "Charset from HTTP Content-Type '" . $encoding . "' does not match encoding from XML declaration '" . $xml_encoding . "'";
74
-						$this->debug($err);
75
-						if ($encoding != 'ISO-8859-1' || strtoupper($xml_encoding) != 'UTF-8') {
76
-							$this->setError($err);
77
-							return;
78
-						}
79
-						// when HTTP says ISO-8859-1 (the default) and XML says UTF-8 (the typical), assume the other endpoint is just sloppy and proceed
80
-					} else {
81
-						$this->debug('Charset from HTTP Content-Type matches encoding from XML declaration');
82
-					}
83
-				} else {
84
-					$this->debug('No encoding specified in XML declaration');
85
-				}
86
-			} else {
87
-				$this->debug('No XML declaration');
88
-			}
89
-			$this->debug('Entering nusoap_parser(), length='.strlen($xml).', encoding='.$encoding);
90
-			// Create an XML parser - why not xml_parser_create_ns?
91
-			$this->parser = xml_parser_create($this->xml_encoding);
92
-			// Set the options for parsing the XML data.
93
-			//xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
94
-			xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0);
95
-			xml_parser_set_option($this->parser, XML_OPTION_TARGET_ENCODING, $this->xml_encoding);
96
-			// Set the object for the parser.
97
-			xml_set_object($this->parser, $this);
98
-			// Set the element handlers for the parser.
99
-			xml_set_element_handler($this->parser, 'start_element','end_element');
100
-			xml_set_character_data_handler($this->parser,'character_data');
64
+        // Check whether content has been read.
65
+        if(!empty($this->xml)){
66
+            // Check XML encoding
67
+            $pos_xml = strpos($xml, '<?xml');
68
+            if ($pos_xml !== FALSE) {
69
+                $xml_decl = substr($xml, $pos_xml, strpos($xml, '?>', $pos_xml + 2) - $pos_xml + 1);
70
+                if (preg_match("/encoding=[\"']([^\"']*)[\"']/", $xml_decl, $res)) {
71
+                    $xml_encoding = $res[1];
72
+                    if (strtoupper($xml_encoding) != $encoding) {
73
+                        $err = "Charset from HTTP Content-Type '" . $encoding . "' does not match encoding from XML declaration '" . $xml_encoding . "'";
74
+                        $this->debug($err);
75
+                        if ($encoding != 'ISO-8859-1' || strtoupper($xml_encoding) != 'UTF-8') {
76
+                            $this->setError($err);
77
+                            return;
78
+                        }
79
+                        // when HTTP says ISO-8859-1 (the default) and XML says UTF-8 (the typical), assume the other endpoint is just sloppy and proceed
80
+                    } else {
81
+                        $this->debug('Charset from HTTP Content-Type matches encoding from XML declaration');
82
+                    }
83
+                } else {
84
+                    $this->debug('No encoding specified in XML declaration');
85
+                }
86
+            } else {
87
+                $this->debug('No XML declaration');
88
+            }
89
+            $this->debug('Entering nusoap_parser(), length='.strlen($xml).', encoding='.$encoding);
90
+            // Create an XML parser - why not xml_parser_create_ns?
91
+            $this->parser = xml_parser_create($this->xml_encoding);
92
+            // Set the options for parsing the XML data.
93
+            //xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
94
+            xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0);
95
+            xml_parser_set_option($this->parser, XML_OPTION_TARGET_ENCODING, $this->xml_encoding);
96
+            // Set the object for the parser.
97
+            xml_set_object($this->parser, $this);
98
+            // Set the element handlers for the parser.
99
+            xml_set_element_handler($this->parser, 'start_element','end_element');
100
+            xml_set_character_data_handler($this->parser,'character_data');
101 101
 
102
-			xml_parse($this->parser, $this->xml);
102
+            xml_parse($this->parser, $this->xml);
103 103
 
104
-			// Parse the XML file.
105
-			//if (!xml_parse($this->parser,$xml,true)){
106
-			if (false) {
107
-			    // Display an error message.
108
-			    $err = sprintf('XML error parsing SOAP payload on line %d: %s',
109
-			    xml_get_current_line_number($this->parser),
110
-			    xml_error_string(xml_get_error_code($this->parser)));
111
-				$this->debug($err);
112
-				$this->debug("XML payload:\n" . $xml);
113
-				$this->setError($err);
114
-			} else {
115
-				$this->debug('in nusoap_parser ctor, message:');
116
-				$this->appendDebug($this->varDump($this->message));
117
-				$this->debug('parsed successfully, found root struct: '.$this->root_struct.' of name '.$this->root_struct_name);
118
-				// get final value
119
-				$this->soapresponse = $this->message[$this->root_struct]['result'];
120
-				// get header value
121
-				if($this->root_header != '' && isset($this->message[$this->root_header]['result'])){
122
-					$this->soapheader = $this->message[$this->root_header]['result'];
123
-				}
124
-				// resolve hrefs/ids
125
-				if(sizeof($this->multirefs) > 0){
126
-					foreach($this->multirefs as $id => $hrefs){
127
-						$this->debug('resolving multirefs for id: '.$id);
128
-						$idVal = $this->buildVal($this->ids[$id]);
129
-						if (is_array($idVal) && isset($idVal['!id'])) {
130
-							unset($idVal['!id']);
131
-						}
132
-						foreach($hrefs as $refPos => $ref){
133
-							$this->debug('resolving href at pos '.$refPos);
134
-							$this->multirefs[$id][$refPos] = $idVal;
135
-						}
136
-					}
137
-				}
138
-			}
139
-			xml_parser_free($this->parser);
140
-		} else {
141
-			$this->debug('xml was empty, didn\'t parse!');
142
-			$this->setError('xml was empty, didn\'t parse!');
143
-		}
144
-	}
104
+            // Parse the XML file.
105
+            //if (!xml_parse($this->parser,$xml,true)){
106
+            if (false) {
107
+                // Display an error message.
108
+                $err = sprintf('XML error parsing SOAP payload on line %d: %s',
109
+                xml_get_current_line_number($this->parser),
110
+                xml_error_string(xml_get_error_code($this->parser)));
111
+                $this->debug($err);
112
+                $this->debug("XML payload:\n" . $xml);
113
+                $this->setError($err);
114
+            } else {
115
+                $this->debug('in nusoap_parser ctor, message:');
116
+                $this->appendDebug($this->varDump($this->message));
117
+                $this->debug('parsed successfully, found root struct: '.$this->root_struct.' of name '.$this->root_struct_name);
118
+                // get final value
119
+                $this->soapresponse = $this->message[$this->root_struct]['result'];
120
+                // get header value
121
+                if($this->root_header != '' && isset($this->message[$this->root_header]['result'])){
122
+                    $this->soapheader = $this->message[$this->root_header]['result'];
123
+                }
124
+                // resolve hrefs/ids
125
+                if(sizeof($this->multirefs) > 0){
126
+                    foreach($this->multirefs as $id => $hrefs){
127
+                        $this->debug('resolving multirefs for id: '.$id);
128
+                        $idVal = $this->buildVal($this->ids[$id]);
129
+                        if (is_array($idVal) && isset($idVal['!id'])) {
130
+                            unset($idVal['!id']);
131
+                        }
132
+                        foreach($hrefs as $refPos => $ref){
133
+                            $this->debug('resolving href at pos '.$refPos);
134
+                            $this->multirefs[$id][$refPos] = $idVal;
135
+                        }
136
+                    }
137
+                }
138
+            }
139
+            xml_parser_free($this->parser);
140
+        } else {
141
+            $this->debug('xml was empty, didn\'t parse!');
142
+            $this->setError('xml was empty, didn\'t parse!');
143
+        }
144
+    }
145 145
 
146
-	/**
147
-	* start-element handler
148
-	*
149
-	* @param    resource $parser XML parser object
150
-	* @param    string $name element name
151
-	* @param    array $attrs associative array of attributes
152
-	* @access   private
153
-	*/
154
-	function start_element($parser, $name, $attrs) {
146
+    /**
147
+     * start-element handler
148
+     *
149
+     * @param    resource $parser XML parser object
150
+     * @param    string $name element name
151
+     * @param    array $attrs associative array of attributes
152
+     * @access   private
153
+     */
154
+    function start_element($parser, $name, $attrs) {
155 155
 
156
-		// position in a total number of elements, starting from 0
157
-		// update class level pos
158
-		$pos = $this->position++;
159
-		// and set mine
160
-		$this->message[$pos] = array('pos' => $pos,'children'=>'','cdata'=>'');
161
-		// depth = how many levels removed from root?
162
-		// set mine as current global depth and increment global depth value
163
-		$this->message[$pos]['depth'] = $this->depth++;
156
+        // position in a total number of elements, starting from 0
157
+        // update class level pos
158
+        $pos = $this->position++;
159
+        // and set mine
160
+        $this->message[$pos] = array('pos' => $pos,'children'=>'','cdata'=>'');
161
+        // depth = how many levels removed from root?
162
+        // set mine as current global depth and increment global depth value
163
+        $this->message[$pos]['depth'] = $this->depth++;
164 164
 
165
-		// else add self as child to whoever the current parent is
166
-		if($pos != 0){
167
-			$this->message[$this->parent]['children'] .= '|'.$pos;
168
-		}
169
-		// set my parent
170
-		$this->message[$pos]['parent'] = $this->parent;
171
-		// set self as current parent
172
-		$this->parent = $pos;
173
-		// set self as current value for this depth
174
-		$this->depth_array[$this->depth] = $pos;
175
-		// get element prefix
176
-		if(strpos($name,':')){
177
-			// get ns prefix
178
-			$prefix = substr($name,0,strpos($name,':'));
179
-			// get unqualified name
180
-			$name = substr(strstr($name,':'),1);
181
-		}
182
-		// set status
183
-		if ($name == 'Envelope' && $this->status == '') {
184
-			$this->status = 'envelope';
185
-		} elseif ($name == 'Header' && $this->status == 'envelope') {
186
-			$this->root_header = $pos;
187
-			$this->status = 'header';
188
-		} elseif ($name == 'Body' && $this->status == 'envelope'){
189
-			$this->status = 'body';
190
-			$this->body_position = $pos;
191
-		// set method
192
-		} elseif($this->status == 'body' && $pos == ($this->body_position+1)) {
193
-			$this->status = 'method';
194
-			$this->root_struct_name = $name;
195
-			$this->root_struct = $pos;
196
-			$this->message[$pos]['type'] = 'struct';
197
-			$this->debug("found root struct $this->root_struct_name, pos $this->root_struct");
198
-		}
199
-		// set my status
200
-		$this->message[$pos]['status'] = $this->status;
201
-		// set name
202
-		$this->message[$pos]['name'] = htmlspecialchars($name);
203
-		// set attrs
204
-		$this->message[$pos]['attrs'] = $attrs;
165
+        // else add self as child to whoever the current parent is
166
+        if($pos != 0){
167
+            $this->message[$this->parent]['children'] .= '|'.$pos;
168
+        }
169
+        // set my parent
170
+        $this->message[$pos]['parent'] = $this->parent;
171
+        // set self as current parent
172
+        $this->parent = $pos;
173
+        // set self as current value for this depth
174
+        $this->depth_array[$this->depth] = $pos;
175
+        // get element prefix
176
+        if(strpos($name,':')){
177
+            // get ns prefix
178
+            $prefix = substr($name,0,strpos($name,':'));
179
+            // get unqualified name
180
+            $name = substr(strstr($name,':'),1);
181
+        }
182
+        // set status
183
+        if ($name == 'Envelope' && $this->status == '') {
184
+            $this->status = 'envelope';
185
+        } elseif ($name == 'Header' && $this->status == 'envelope') {
186
+            $this->root_header = $pos;
187
+            $this->status = 'header';
188
+        } elseif ($name == 'Body' && $this->status == 'envelope'){
189
+            $this->status = 'body';
190
+            $this->body_position = $pos;
191
+        // set method
192
+        } elseif($this->status == 'body' && $pos == ($this->body_position+1)) {
193
+            $this->status = 'method';
194
+            $this->root_struct_name = $name;
195
+            $this->root_struct = $pos;
196
+            $this->message[$pos]['type'] = 'struct';
197
+            $this->debug("found root struct $this->root_struct_name, pos $this->root_struct");
198
+        }
199
+        // set my status
200
+        $this->message[$pos]['status'] = $this->status;
201
+        // set name
202
+        $this->message[$pos]['name'] = htmlspecialchars($name);
203
+        // set attrs
204
+        $this->message[$pos]['attrs'] = $attrs;
205 205
 
206
-		// loop through atts, logging ns and type declarations
206
+        // loop through atts, logging ns and type declarations
207 207
         $attstr = '';
208
-		foreach($attrs as $key => $value){
209
-        	$key_prefix = $this->getPrefix($key);
210
-			$key_localpart = $this->getLocalPart($key);
211
-			// if ns declarations, add to class level array of valid namespaces
208
+        foreach($attrs as $key => $value){
209
+            $key_prefix = $this->getPrefix($key);
210
+            $key_localpart = $this->getLocalPart($key);
211
+            // if ns declarations, add to class level array of valid namespaces
212 212
             if($key_prefix == 'xmlns'){
213
-				if(preg_match('/^http:\/\/www.w3.org\/[0-9]{4}\/XMLSchema$/',$value)){
214
-					$this->XMLSchemaVersion = $value;
215
-					$this->namespaces['xsd'] = $this->XMLSchemaVersion;
216
-					$this->namespaces['xsi'] = $this->XMLSchemaVersion.'-instance';
217
-				}
213
+                if(preg_match('/^http:\/\/www.w3.org\/[0-9]{4}\/XMLSchema$/',$value)){
214
+                    $this->XMLSchemaVersion = $value;
215
+                    $this->namespaces['xsd'] = $this->XMLSchemaVersion;
216
+                    $this->namespaces['xsi'] = $this->XMLSchemaVersion.'-instance';
217
+                }
218 218
                 $this->namespaces[$key_localpart] = $value;
219
-				// set method namespace
220
-				if($name == $this->root_struct_name){
221
-					$this->methodNamespace = $value;
222
-				}
223
-			// if it's a type declaration, set type
219
+                // set method namespace
220
+                if($name == $this->root_struct_name){
221
+                    $this->methodNamespace = $value;
222
+                }
223
+            // if it's a type declaration, set type
224 224
         } elseif($key_localpart == 'type'){
225
-        		if (isset($this->message[$pos]['type']) && $this->message[$pos]['type'] == 'array') {
226
-        			// do nothing: already processed arrayType
227
-        		} else {
228
-	            	$value_prefix = $this->getPrefix($value);
229
-	                $value_localpart = $this->getLocalPart($value);
230
-					$this->message[$pos]['type'] = $value_localpart;
231
-					$this->message[$pos]['typePrefix'] = $value_prefix;
232
-	                if(isset($this->namespaces[$value_prefix])){
233
-	                	$this->message[$pos]['type_namespace'] = $this->namespaces[$value_prefix];
234
-	                } else if(isset($attrs['xmlns:'.$value_prefix])) {
235
-						$this->message[$pos]['type_namespace'] = $attrs['xmlns:'.$value_prefix];
236
-	                }
237
-					// should do something here with the namespace of specified type?
238
-				}
239
-			} elseif($key_localpart == 'arrayType'){
240
-				$this->message[$pos]['type'] = 'array';
241
-				/* do arrayType ereg here
225
+                if (isset($this->message[$pos]['type']) && $this->message[$pos]['type'] == 'array') {
226
+                    // do nothing: already processed arrayType
227
+                } else {
228
+                    $value_prefix = $this->getPrefix($value);
229
+                    $value_localpart = $this->getLocalPart($value);
230
+                    $this->message[$pos]['type'] = $value_localpart;
231
+                    $this->message[$pos]['typePrefix'] = $value_prefix;
232
+                    if(isset($this->namespaces[$value_prefix])){
233
+                        $this->message[$pos]['type_namespace'] = $this->namespaces[$value_prefix];
234
+                    } else if(isset($attrs['xmlns:'.$value_prefix])) {
235
+                        $this->message[$pos]['type_namespace'] = $attrs['xmlns:'.$value_prefix];
236
+                    }
237
+                    // should do something here with the namespace of specified type?
238
+                }
239
+            } elseif($key_localpart == 'arrayType'){
240
+                $this->message[$pos]['type'] = 'array';
241
+                /* do arrayType ereg here
242 242
 				[1]    arrayTypeValue    ::=    atype asize
243 243
 				[2]    atype    ::=    QName rank*
244 244
 				[3]    rank    ::=    '[' (',')* ']'
@@ -246,129 +246,129 @@  discard block
 block discarded – undo
246 246
 				[5]    length    ::=    nextDimension* Digit+
247 247
 				[6]    nextDimension    ::=    Digit+ ','
248 248
 				*/
249
-				$expr = '/([A-Za-z0-9_]+):([A-Za-z]+[A-Za-z0-9_]+)\[([0-9]+),?([0-9]*)\]/';
250
-				if(preg_match($expr,$value,$regs)){
251
-					$this->message[$pos]['typePrefix'] = $regs[1];
252
-					$this->message[$pos]['arrayTypePrefix'] = $regs[1];
253
-	                if (isset($this->namespaces[$regs[1]])) {
254
-	                	$this->message[$pos]['arrayTypeNamespace'] = $this->namespaces[$regs[1]];
255
-	                } else if (isset($attrs['xmlns:'.$regs[1]])) {
256
-						$this->message[$pos]['arrayTypeNamespace'] = $attrs['xmlns:'.$regs[1]];
257
-	                }
258
-					$this->message[$pos]['arrayType'] = $regs[2];
259
-					$this->message[$pos]['arraySize'] = $regs[3];
260
-					$this->message[$pos]['arrayCols'] = $regs[4];
261
-				}
262
-			// specifies nil value (or not)
263
-			} elseif ($key_localpart == 'nil'){
264
-				$this->message[$pos]['nil'] = ($value == 'true' || $value == '1');
265
-			// some other attribute
266
-			} elseif ($key != 'href' && $key != 'xmlns' && $key_localpart != 'encodingStyle' && $key_localpart != 'root') {
267
-				$this->message[$pos]['xattrs']['!' . $key] = $value;
268
-			}
249
+                $expr = '/([A-Za-z0-9_]+):([A-Za-z]+[A-Za-z0-9_]+)\[([0-9]+),?([0-9]*)\]/';
250
+                if(preg_match($expr,$value,$regs)){
251
+                    $this->message[$pos]['typePrefix'] = $regs[1];
252
+                    $this->message[$pos]['arrayTypePrefix'] = $regs[1];
253
+                    if (isset($this->namespaces[$regs[1]])) {
254
+                        $this->message[$pos]['arrayTypeNamespace'] = $this->namespaces[$regs[1]];
255
+                    } else if (isset($attrs['xmlns:'.$regs[1]])) {
256
+                        $this->message[$pos]['arrayTypeNamespace'] = $attrs['xmlns:'.$regs[1]];
257
+                    }
258
+                    $this->message[$pos]['arrayType'] = $regs[2];
259
+                    $this->message[$pos]['arraySize'] = $regs[3];
260
+                    $this->message[$pos]['arrayCols'] = $regs[4];
261
+                }
262
+            // specifies nil value (or not)
263
+            } elseif ($key_localpart == 'nil'){
264
+                $this->message[$pos]['nil'] = ($value == 'true' || $value == '1');
265
+            // some other attribute
266
+            } elseif ($key != 'href' && $key != 'xmlns' && $key_localpart != 'encodingStyle' && $key_localpart != 'root') {
267
+                $this->message[$pos]['xattrs']['!' . $key] = $value;
268
+            }
269 269
 
270
-			if ($key == 'xmlns') {
271
-				$this->default_namespace = $value;
272
-			}
273
-			// log id
274
-			if($key == 'id'){
275
-				$this->ids[$value] = $pos;
276
-			}
277
-			// root
278
-			if($key_localpart == 'root' && $value == 1){
279
-				$this->status = 'method';
280
-				$this->root_struct_name = $name;
281
-				$this->root_struct = $pos;
282
-				$this->debug("found root struct $this->root_struct_name, pos $pos");
283
-			}
270
+            if ($key == 'xmlns') {
271
+                $this->default_namespace = $value;
272
+            }
273
+            // log id
274
+            if($key == 'id'){
275
+                $this->ids[$value] = $pos;
276
+            }
277
+            // root
278
+            if($key_localpart == 'root' && $value == 1){
279
+                $this->status = 'method';
280
+                $this->root_struct_name = $name;
281
+                $this->root_struct = $pos;
282
+                $this->debug("found root struct $this->root_struct_name, pos $pos");
283
+            }
284 284
             // for doclit
285 285
             $attstr .= " $key=\"$value\"";
286
-		}
286
+        }
287 287
         // get namespace - must be done after namespace atts are processed
288
-		if(isset($prefix)){
289
-			$this->message[$pos]['namespace'] = $this->namespaces[$prefix];
290
-			$this->default_namespace = $this->namespaces[$prefix];
291
-		} else {
292
-			$this->message[$pos]['namespace'] = $this->default_namespace;
293
-		}
288
+        if(isset($prefix)){
289
+            $this->message[$pos]['namespace'] = $this->namespaces[$prefix];
290
+            $this->default_namespace = $this->namespaces[$prefix];
291
+        } else {
292
+            $this->message[$pos]['namespace'] = $this->default_namespace;
293
+        }
294 294
         if($this->status == 'header'){
295
-        	if ($this->root_header != $pos) {
296
-	        	$this->responseHeaders .= "<" . (isset($prefix) ? $prefix . ':' : '') . "$name$attstr>";
297
-	        }
295
+            if ($this->root_header != $pos) {
296
+                $this->responseHeaders .= "<" . (isset($prefix) ? $prefix . ':' : '') . "$name$attstr>";
297
+            }
298 298
         } elseif($this->root_struct_name != ''){
299
-        	$this->document .= "<" . (isset($prefix) ? $prefix . ':' : '') . "$name$attstr>";
299
+            $this->document .= "<" . (isset($prefix) ? $prefix . ':' : '') . "$name$attstr>";
300 300
         }
301
-	}
301
+    }
302 302
 
303
-	/**
304
-	* end-element handler
305
-	*
306
-	* @param    resource $parser XML parser object
307
-	* @param    string $name element name
308
-	* @access   private
309
-	*/
310
-	function end_element($parser, $name) {
311
-		// position of current element is equal to the last value left in depth_array for my depth
312
-		$pos = $this->depth_array[$this->depth--];
303
+    /**
304
+     * end-element handler
305
+     *
306
+     * @param    resource $parser XML parser object
307
+     * @param    string $name element name
308
+     * @access   private
309
+     */
310
+    function end_element($parser, $name) {
311
+        // position of current element is equal to the last value left in depth_array for my depth
312
+        $pos = $this->depth_array[$this->depth--];
313 313
 
314 314
         // get element prefix
315
-		if(strpos($name,':')){
316
-			// get ns prefix
317
-			$prefix = substr($name,0,strpos($name,':'));
318
-			// get unqualified name
319
-			$name = substr(strstr($name,':'),1);
320
-		}
315
+        if(strpos($name,':')){
316
+            // get ns prefix
317
+            $prefix = substr($name,0,strpos($name,':'));
318
+            // get unqualified name
319
+            $name = substr(strstr($name,':'),1);
320
+        }
321 321
 		
322
-		// build to native type
323
-		if(isset($this->body_position) && $pos > $this->body_position){
324
-			// deal w/ multirefs
325
-			if(isset($this->message[$pos]['attrs']['href'])){
326
-				// get id
327
-				$id = substr($this->message[$pos]['attrs']['href'],1);
328
-				// add placeholder to href array
329
-				$this->multirefs[$id][$pos] = 'placeholder';
330
-				// add set a reference to it as the result value
331
-				$this->message[$pos]['result'] =& $this->multirefs[$id][$pos];
322
+        // build to native type
323
+        if(isset($this->body_position) && $pos > $this->body_position){
324
+            // deal w/ multirefs
325
+            if(isset($this->message[$pos]['attrs']['href'])){
326
+                // get id
327
+                $id = substr($this->message[$pos]['attrs']['href'],1);
328
+                // add placeholder to href array
329
+                $this->multirefs[$id][$pos] = 'placeholder';
330
+                // add set a reference to it as the result value
331
+                $this->message[$pos]['result'] =& $this->multirefs[$id][$pos];
332 332
             // build complexType values
333
-			} elseif($this->message[$pos]['children'] != ''){
334
-				// if result has already been generated (struct/array)
335
-				if(!isset($this->message[$pos]['result'])){
336
-					$this->message[$pos]['result'] = $this->buildVal($pos);
337
-				}
338
-			// build complexType values of attributes and possibly simpleContent
339
-			} elseif (isset($this->message[$pos]['xattrs'])) {
340
-				if (isset($this->message[$pos]['nil']) && $this->message[$pos]['nil']) {
341
-					$this->message[$pos]['xattrs']['!'] = null;
342
-				} elseif (isset($this->message[$pos]['cdata']) && trim($this->message[$pos]['cdata']) != '') {
343
-	            	if (isset($this->message[$pos]['type'])) {
344
-						$this->message[$pos]['xattrs']['!'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$pos]['type'], isset($this->message[$pos]['type_namespace']) ? $this->message[$pos]['type_namespace'] : '');
345
-					} else {
346
-						$parent = $this->message[$pos]['parent'];
347
-						if (isset($this->message[$parent]['type']) && ($this->message[$parent]['type'] == 'array') && isset($this->message[$parent]['arrayType'])) {
348
-							$this->message[$pos]['xattrs']['!'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$parent]['arrayType'], isset($this->message[$parent]['arrayTypeNamespace']) ? $this->message[$parent]['arrayTypeNamespace'] : '');
349
-						} else {
350
-							$this->message[$pos]['xattrs']['!'] = $this->message[$pos]['cdata'];
351
-						}
352
-					}
353
-				}
354
-				$this->message[$pos]['result'] = $this->message[$pos]['xattrs'];
355
-			// set value of simpleType (or nil complexType)
356
-			} else {
357
-            	//$this->debug('adding data for scalar value '.$this->message[$pos]['name'].' of value '.$this->message[$pos]['cdata']);
358
-				if (isset($this->message[$pos]['nil']) && $this->message[$pos]['nil']) {
359
-					$this->message[$pos]['xattrs']['!'] = null;
360
-				} elseif (isset($this->message[$pos]['type'])) {
361
-					$this->message[$pos]['result'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$pos]['type'], isset($this->message[$pos]['type_namespace']) ? $this->message[$pos]['type_namespace'] : '');
362
-				} else {
363
-					$parent = $this->message[$pos]['parent'];
364
-					if (isset($this->message[$parent]['type']) && ($this->message[$parent]['type'] == 'array') && isset($this->message[$parent]['arrayType'])) {
365
-						$this->message[$pos]['result'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$parent]['arrayType'], isset($this->message[$parent]['arrayTypeNamespace']) ? $this->message[$parent]['arrayTypeNamespace'] : '');
366
-					} else {
367
-						$this->message[$pos]['result'] = $this->message[$pos]['cdata'];
368
-					}
369
-				}
333
+            } elseif($this->message[$pos]['children'] != ''){
334
+                // if result has already been generated (struct/array)
335
+                if(!isset($this->message[$pos]['result'])){
336
+                    $this->message[$pos]['result'] = $this->buildVal($pos);
337
+                }
338
+            // build complexType values of attributes and possibly simpleContent
339
+            } elseif (isset($this->message[$pos]['xattrs'])) {
340
+                if (isset($this->message[$pos]['nil']) && $this->message[$pos]['nil']) {
341
+                    $this->message[$pos]['xattrs']['!'] = null;
342
+                } elseif (isset($this->message[$pos]['cdata']) && trim($this->message[$pos]['cdata']) != '') {
343
+                    if (isset($this->message[$pos]['type'])) {
344
+                        $this->message[$pos]['xattrs']['!'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$pos]['type'], isset($this->message[$pos]['type_namespace']) ? $this->message[$pos]['type_namespace'] : '');
345
+                    } else {
346
+                        $parent = $this->message[$pos]['parent'];
347
+                        if (isset($this->message[$parent]['type']) && ($this->message[$parent]['type'] == 'array') && isset($this->message[$parent]['arrayType'])) {
348
+                            $this->message[$pos]['xattrs']['!'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$parent]['arrayType'], isset($this->message[$parent]['arrayTypeNamespace']) ? $this->message[$parent]['arrayTypeNamespace'] : '');
349
+                        } else {
350
+                            $this->message[$pos]['xattrs']['!'] = $this->message[$pos]['cdata'];
351
+                        }
352
+                    }
353
+                }
354
+                $this->message[$pos]['result'] = $this->message[$pos]['xattrs'];
355
+            // set value of simpleType (or nil complexType)
356
+            } else {
357
+                //$this->debug('adding data for scalar value '.$this->message[$pos]['name'].' of value '.$this->message[$pos]['cdata']);
358
+                if (isset($this->message[$pos]['nil']) && $this->message[$pos]['nil']) {
359
+                    $this->message[$pos]['xattrs']['!'] = null;
360
+                } elseif (isset($this->message[$pos]['type'])) {
361
+                    $this->message[$pos]['result'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$pos]['type'], isset($this->message[$pos]['type_namespace']) ? $this->message[$pos]['type_namespace'] : '');
362
+                } else {
363
+                    $parent = $this->message[$pos]['parent'];
364
+                    if (isset($this->message[$parent]['type']) && ($this->message[$parent]['type'] == 'array') && isset($this->message[$parent]['arrayType'])) {
365
+                        $this->message[$pos]['result'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$parent]['arrayType'], isset($this->message[$parent]['arrayTypeNamespace']) ? $this->message[$parent]['arrayTypeNamespace'] : '');
366
+                    } else {
367
+                        $this->message[$pos]['result'] = $this->message[$pos]['cdata'];
368
+                    }
369
+                }
370 370
 
371
-				/* add value to parent's result, if parent is struct/array
371
+                /* add value to parent's result, if parent is struct/array
372 372
 				$parent = $this->message[$pos]['parent'];
373 373
 				if($this->message[$parent]['type'] != 'map'){
374 374
 					if(strtolower($this->message[$parent]['type']) == 'array'){
@@ -378,261 +378,261 @@  discard block
 block discarded – undo
378 378
 					}
379 379
 				}
380 380
 				*/
381
-			}
382
-		}
381
+            }
382
+        }
383 383
 		
384 384
         // for doclit
385 385
         if($this->status == 'header'){
386
-        	if ($this->root_header != $pos) {
387
-	        	$this->responseHeaders .= "</" . (isset($prefix) ? $prefix . ':' : '') . "$name>";
388
-	        }
386
+            if ($this->root_header != $pos) {
387
+                $this->responseHeaders .= "</" . (isset($prefix) ? $prefix . ':' : '') . "$name>";
388
+            }
389 389
         } elseif($pos >= $this->root_struct){
390
-        	$this->document .= "</" . (isset($prefix) ? $prefix . ':' : '') . "$name>";
390
+            $this->document .= "</" . (isset($prefix) ? $prefix . ':' : '') . "$name>";
391 391
         }
392
-		// switch status
393
-		if ($pos == $this->root_struct){
394
-			$this->status = 'body';
395
-			$this->root_struct_namespace = $this->message[$pos]['namespace'];
396
-		} elseif ($pos == $this->root_header) {
397
-			$this->status = 'envelope';
398
-		} elseif ($name == 'Body' && $this->status == 'body') {
399
-			$this->status = 'envelope';
400
-		} elseif ($name == 'Header' && $this->status == 'header') { // will never happen
401
-			$this->status = 'envelope';
402
-		} elseif ($name == 'Envelope' && $this->status == 'envelope') {
403
-			$this->status = '';
404
-		}
405
-		// set parent back to my parent
406
-		$this->parent = $this->message[$pos]['parent'];
407
-	}
392
+        // switch status
393
+        if ($pos == $this->root_struct){
394
+            $this->status = 'body';
395
+            $this->root_struct_namespace = $this->message[$pos]['namespace'];
396
+        } elseif ($pos == $this->root_header) {
397
+            $this->status = 'envelope';
398
+        } elseif ($name == 'Body' && $this->status == 'body') {
399
+            $this->status = 'envelope';
400
+        } elseif ($name == 'Header' && $this->status == 'header') { // will never happen
401
+            $this->status = 'envelope';
402
+        } elseif ($name == 'Envelope' && $this->status == 'envelope') {
403
+            $this->status = '';
404
+        }
405
+        // set parent back to my parent
406
+        $this->parent = $this->message[$pos]['parent'];
407
+    }
408 408
 
409
-	/**
410
-	* element content handler
411
-	*
412
-	* @param    resource $parser XML parser object
413
-	* @param    string $data element content
414
-	* @access   private
415
-	*/
416
-	function character_data($parser, $data)
409
+    /**
410
+     * element content handler
411
+     *
412
+     * @param    resource $parser XML parser object
413
+     * @param    string $data element content
414
+     * @access   private
415
+     */
416
+    function character_data($parser, $data)
417 417
     {
418
-		$pos = $this->depth_array[$this->depth];
419
-		if ($this->xml_encoding == 'UTF-8'){
420
-			// TODO: add an option to disable this for folks who want
421
-			// raw UTF-8 that, e.g., might not map to iso-8859-1
422
-			// TODO: this can also be handled with xml_parser_set_option($this->parser, XML_OPTION_TARGET_ENCODING, "ISO-8859-1");
423
-			if($this->decode_utf8){
424
-				$data = utf8_decode($data);
425
-			}
426
-		}
418
+        $pos = $this->depth_array[$this->depth];
419
+        if ($this->xml_encoding == 'UTF-8'){
420
+            // TODO: add an option to disable this for folks who want
421
+            // raw UTF-8 that, e.g., might not map to iso-8859-1
422
+            // TODO: this can also be handled with xml_parser_set_option($this->parser, XML_OPTION_TARGET_ENCODING, "ISO-8859-1");
423
+            if($this->decode_utf8){
424
+                $data = utf8_decode($data);
425
+            }
426
+        }
427 427
         $this->message[$pos]['cdata'] .= $data;
428 428
         // for doclit
429 429
         if($this->status == 'header'){
430
-        	$this->responseHeaders .= $data;
430
+            $this->responseHeaders .= $data;
431 431
         } else {
432
-        	$this->document .= $data;
432
+            $this->document .= $data;
433 433
         }
434
-	}
434
+    }
435 435
 
436
-	/**
437
-	* get the parsed message (SOAP Body)
438
-	*
439
-	* @return	mixed
440
-	* @access   public
441
-	* @deprecated	use get_soapbody instead
442
-	*/
443
-	function get_response(){
444
-		return $this->soapresponse;
445
-	}
436
+    /**
437
+     * get the parsed message (SOAP Body)
438
+     *
439
+     * @return	mixed
440
+     * @access   public
441
+     * @deprecated	use get_soapbody instead
442
+     */
443
+    function get_response(){
444
+        return $this->soapresponse;
445
+    }
446 446
 
447
-	/**
448
-	* get the parsed SOAP Body (NULL if there was none)
449
-	*
450
-	* @return	mixed
451
-	* @access   public
452
-	*/
453
-	function get_soapbody(){
454
-		return $this->soapresponse;
455
-	}
447
+    /**
448
+     * get the parsed SOAP Body (NULL if there was none)
449
+     *
450
+     * @return	mixed
451
+     * @access   public
452
+     */
453
+    function get_soapbody(){
454
+        return $this->soapresponse;
455
+    }
456 456
 
457
-	/**
458
-	* get the parsed SOAP Header (NULL if there was none)
459
-	*
460
-	* @return	mixed
461
-	* @access   public
462
-	*/
463
-	function get_soapheader(){
464
-		return $this->soapheader;
465
-	}
457
+    /**
458
+     * get the parsed SOAP Header (NULL if there was none)
459
+     *
460
+     * @return	mixed
461
+     * @access   public
462
+     */
463
+    function get_soapheader(){
464
+        return $this->soapheader;
465
+    }
466 466
 
467
-	/**
468
-	* get the unparsed SOAP Header
469
-	*
470
-	* @return	string XML or empty if no Header
471
-	* @access   public
472
-	*/
473
-	function getHeaders(){
474
-	    return $this->responseHeaders;
475
-	}
467
+    /**
468
+     * get the unparsed SOAP Header
469
+     *
470
+     * @return	string XML or empty if no Header
471
+     * @access   public
472
+     */
473
+    function getHeaders(){
474
+        return $this->responseHeaders;
475
+    }
476 476
 
477
-	/**
478
-	* decodes simple types into PHP variables
479
-	*
480
-	* @param    string $value value to decode
481
-	* @param    string $type XML type to decode
482
-	* @param    string $typens XML type namespace to decode
483
-	* @return	mixed PHP value
484
-	* @access   private
485
-	*/
486
-	function decodeSimple($value, $type, $typens) {
487
-		// TODO: use the namespace!
488
-		if ((!isset($type)) || $type == 'string' || $type == 'long' || $type == 'unsignedLong') {
489
-			return (string) $value;
490
-		}
491
-		if ($type == 'int' || $type == 'integer' || $type == 'short' || $type == 'byte') {
492
-			return (int) $value;
493
-		}
494
-		if ($type == 'float' || $type == 'double' || $type == 'decimal') {
495
-			return (double) $value;
496
-		}
497
-		if ($type == 'boolean') {
498
-			if (strtolower($value) == 'false' || strtolower($value) == 'f') {
499
-				return false;
500
-			}
501
-			return (boolean) $value;
502
-		}
503
-		if ($type == 'base64' || $type == 'base64Binary') {
504
-			$this->debug('Decode base64 value');
505
-			return base64_decode($value);
506
-		}
507
-		// obscure numeric types
508
-		if ($type == 'nonPositiveInteger' || $type == 'negativeInteger'
509
-			|| $type == 'nonNegativeInteger' || $type == 'positiveInteger'
510
-			|| $type == 'unsignedInt'
511
-			|| $type == 'unsignedShort' || $type == 'unsignedByte') {
512
-			return (int) $value;
513
-		}
514
-		// bogus: parser treats array with no elements as a simple type
515
-		if ($type == 'array') {
516
-			return array();
517
-		}
518
-		// everything else
519
-		return (string) $value;
520
-	}
477
+    /**
478
+     * decodes simple types into PHP variables
479
+     *
480
+     * @param    string $value value to decode
481
+     * @param    string $type XML type to decode
482
+     * @param    string $typens XML type namespace to decode
483
+     * @return	mixed PHP value
484
+     * @access   private
485
+     */
486
+    function decodeSimple($value, $type, $typens) {
487
+        // TODO: use the namespace!
488
+        if ((!isset($type)) || $type == 'string' || $type == 'long' || $type == 'unsignedLong') {
489
+            return (string) $value;
490
+        }
491
+        if ($type == 'int' || $type == 'integer' || $type == 'short' || $type == 'byte') {
492
+            return (int) $value;
493
+        }
494
+        if ($type == 'float' || $type == 'double' || $type == 'decimal') {
495
+            return (double) $value;
496
+        }
497
+        if ($type == 'boolean') {
498
+            if (strtolower($value) == 'false' || strtolower($value) == 'f') {
499
+                return false;
500
+            }
501
+            return (boolean) $value;
502
+        }
503
+        if ($type == 'base64' || $type == 'base64Binary') {
504
+            $this->debug('Decode base64 value');
505
+            return base64_decode($value);
506
+        }
507
+        // obscure numeric types
508
+        if ($type == 'nonPositiveInteger' || $type == 'negativeInteger'
509
+            || $type == 'nonNegativeInteger' || $type == 'positiveInteger'
510
+            || $type == 'unsignedInt'
511
+            || $type == 'unsignedShort' || $type == 'unsignedByte') {
512
+            return (int) $value;
513
+        }
514
+        // bogus: parser treats array with no elements as a simple type
515
+        if ($type == 'array') {
516
+            return array();
517
+        }
518
+        // everything else
519
+        return (string) $value;
520
+    }
521 521
 
522
-	/**
523
-	* builds response structures for compound values (arrays/structs)
524
-	* and scalars
525
-	*
526
-	* @param    integer $pos position in node tree
527
-	* @return	mixed	PHP value
528
-	* @access   private
529
-	*/
530
-	function buildVal($pos){
531
-		if(!isset($this->message[$pos]['type'])){
532
-			$this->message[$pos]['type'] = '';
533
-		}
534
-		$this->debug('in buildVal() for '.$this->message[$pos]['name']."(pos $pos) of type ".$this->message[$pos]['type']);
535
-		// if there are children...
536
-		if($this->message[$pos]['children'] != ''){
537
-			$this->debug('in buildVal, there are children');
538
-			$children = explode('|',$this->message[$pos]['children']);
539
-			array_shift($children); // knock off empty
540
-			// md array
541
-			if(isset($this->message[$pos]['arrayCols']) && $this->message[$pos]['arrayCols'] != ''){
542
-            	$r=0; // rowcount
543
-            	$c=0; // colcount
544
-            	foreach($children as $child_pos){
545
-					$this->debug("in buildVal, got an MD array element: $r, $c");
546
-					$params[$r][] = $this->message[$child_pos]['result'];
547
-				    $c++;
548
-				    if($c == $this->message[$pos]['arrayCols']){
549
-				    	$c = 0;
550
-						$r++;
551
-				    }
522
+    /**
523
+     * builds response structures for compound values (arrays/structs)
524
+     * and scalars
525
+     *
526
+     * @param    integer $pos position in node tree
527
+     * @return	mixed	PHP value
528
+     * @access   private
529
+     */
530
+    function buildVal($pos){
531
+        if(!isset($this->message[$pos]['type'])){
532
+            $this->message[$pos]['type'] = '';
533
+        }
534
+        $this->debug('in buildVal() for '.$this->message[$pos]['name']."(pos $pos) of type ".$this->message[$pos]['type']);
535
+        // if there are children...
536
+        if($this->message[$pos]['children'] != ''){
537
+            $this->debug('in buildVal, there are children');
538
+            $children = explode('|',$this->message[$pos]['children']);
539
+            array_shift($children); // knock off empty
540
+            // md array
541
+            if(isset($this->message[$pos]['arrayCols']) && $this->message[$pos]['arrayCols'] != ''){
542
+                $r=0; // rowcount
543
+                $c=0; // colcount
544
+                foreach($children as $child_pos){
545
+                    $this->debug("in buildVal, got an MD array element: $r, $c");
546
+                    $params[$r][] = $this->message[$child_pos]['result'];
547
+                    $c++;
548
+                    if($c == $this->message[$pos]['arrayCols']){
549
+                        $c = 0;
550
+                        $r++;
551
+                    }
552 552
                 }
553 553
             // array
554
-			} elseif($this->message[$pos]['type'] == 'array' || $this->message[$pos]['type'] == 'Array'){
554
+            } elseif($this->message[$pos]['type'] == 'array' || $this->message[$pos]['type'] == 'Array'){
555 555
                 $this->debug('in buildVal, adding array '.$this->message[$pos]['name']);
556 556
                 foreach($children as $child_pos){
557
-                	$params[] = &$this->message[$child_pos]['result'];
557
+                    $params[] = &$this->message[$child_pos]['result'];
558 558
                 }
559 559
             // apache Map type: java hashtable
560 560
             } elseif($this->message[$pos]['type'] == 'Map' && $this->message[$pos]['type_namespace'] == 'http://xml.apache.org/xml-soap'){
561 561
                 $this->debug('in buildVal, Java Map '.$this->message[$pos]['name']);
562 562
                 foreach($children as $child_pos){
563
-                	$kv = explode("|",$this->message[$child_pos]['children']);
564
-                   	$params[$this->message[$kv[1]]['result']] = &$this->message[$kv[2]]['result'];
563
+                    $kv = explode("|",$this->message[$child_pos]['children']);
564
+                        $params[$this->message[$kv[1]]['result']] = &$this->message[$kv[2]]['result'];
565 565
                 }
566 566
             // generic compound type
567 567
             //} elseif($this->message[$pos]['type'] == 'SOAPStruct' || $this->message[$pos]['type'] == 'struct') {
568
-		    } else {
569
-	    		// Apache Vector type: treat as an array
568
+            } else {
569
+                // Apache Vector type: treat as an array
570 570
                 $this->debug('in buildVal, adding Java Vector or generic compound type '.$this->message[$pos]['name']);
571
-				if ($this->message[$pos]['type'] == 'Vector' && $this->message[$pos]['type_namespace'] == 'http://xml.apache.org/xml-soap') {
572
-					$notstruct = 1;
573
-				} else {
574
-					$notstruct = 0;
575
-	            }
576
-            	//
577
-            	foreach($children as $child_pos){
578
-            		if($notstruct){
579
-            			$params[] = &$this->message[$child_pos]['result'];
580
-            		} else {
581
-            			if (isset($params[$this->message[$child_pos]['name']])) {
582
-            				// de-serialize repeated element name into an array
583
-            				if ((!is_array($params[$this->message[$child_pos]['name']])) || (!isset($params[$this->message[$child_pos]['name']][0]))) {
584
-            					$params[$this->message[$child_pos]['name']] = array($params[$this->message[$child_pos]['name']]);
585
-            				}
586
-            				$params[$this->message[$child_pos]['name']][] = &$this->message[$child_pos]['result'];
587
-            			} else {
588
-					    	$params[$this->message[$child_pos]['name']] = &$this->message[$child_pos]['result'];
589
-					    }
590
-                	}
571
+                if ($this->message[$pos]['type'] == 'Vector' && $this->message[$pos]['type_namespace'] == 'http://xml.apache.org/xml-soap') {
572
+                    $notstruct = 1;
573
+                } else {
574
+                    $notstruct = 0;
591 575
                 }
592
-			}
593
-			if (isset($this->message[$pos]['xattrs'])) {
576
+                //
577
+                foreach($children as $child_pos){
578
+                    if($notstruct){
579
+                        $params[] = &$this->message[$child_pos]['result'];
580
+                    } else {
581
+                        if (isset($params[$this->message[$child_pos]['name']])) {
582
+                            // de-serialize repeated element name into an array
583
+                            if ((!is_array($params[$this->message[$child_pos]['name']])) || (!isset($params[$this->message[$child_pos]['name']][0]))) {
584
+                                $params[$this->message[$child_pos]['name']] = array($params[$this->message[$child_pos]['name']]);
585
+                            }
586
+                            $params[$this->message[$child_pos]['name']][] = &$this->message[$child_pos]['result'];
587
+                        } else {
588
+                            $params[$this->message[$child_pos]['name']] = &$this->message[$child_pos]['result'];
589
+                        }
590
+                    }
591
+                }
592
+            }
593
+            if (isset($this->message[$pos]['xattrs'])) {
594 594
                 $this->debug('in buildVal, handling attributes');
595
-				foreach ($this->message[$pos]['xattrs'] as $n => $v) {
596
-					$params[$n] = $v;
597
-				}
598
-			}
599
-			// handle simpleContent
600
-			if (isset($this->message[$pos]['cdata']) && trim($this->message[$pos]['cdata']) != '') {
595
+                foreach ($this->message[$pos]['xattrs'] as $n => $v) {
596
+                    $params[$n] = $v;
597
+                }
598
+            }
599
+            // handle simpleContent
600
+            if (isset($this->message[$pos]['cdata']) && trim($this->message[$pos]['cdata']) != '') {
601 601
                 $this->debug('in buildVal, handling simpleContent');
602
-            	if (isset($this->message[$pos]['type'])) {
603
-					$params['!'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$pos]['type'], isset($this->message[$pos]['type_namespace']) ? $this->message[$pos]['type_namespace'] : '');
604
-				} else {
605
-					$parent = $this->message[$pos]['parent'];
606
-					if (isset($this->message[$parent]['type']) && ($this->message[$parent]['type'] == 'array') && isset($this->message[$parent]['arrayType'])) {
607
-						$params['!'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$parent]['arrayType'], isset($this->message[$parent]['arrayTypeNamespace']) ? $this->message[$parent]['arrayTypeNamespace'] : '');
608
-					} else {
609
-						$params['!'] = $this->message[$pos]['cdata'];
610
-					}
611
-				}
612
-			}
613
-			$ret = is_array($params) ? $params : array();
614
-			$this->debug('in buildVal, return:');
615
-			//$this->appendDebug($this->varDump($ret));
616
-			return $ret;
617
-		} else {
618
-        	$this->debug('in buildVal, no children, building scalar');
619
-			$cdata = isset($this->message[$pos]['cdata']) ? $this->message[$pos]['cdata'] : '';
620
-        	if (isset($this->message[$pos]['type'])) {
621
-				$ret = $this->decodeSimple($cdata, $this->message[$pos]['type'], isset($this->message[$pos]['type_namespace']) ? $this->message[$pos]['type_namespace'] : '');
622
-				$this->debug("in buildVal, return: $ret");
623
-				return $ret;
624
-			}
625
-			$parent = $this->message[$pos]['parent'];
626
-			if (isset($this->message[$parent]['type']) && ($this->message[$parent]['type'] == 'array') && isset($this->message[$parent]['arrayType'])) {
627
-				$ret = $this->decodeSimple($cdata, $this->message[$parent]['arrayType'], isset($this->message[$parent]['arrayTypeNamespace']) ? $this->message[$parent]['arrayTypeNamespace'] : '');
628
-				$this->debug("in buildVal, return: $ret");
629
-				return $ret;
630
-			}
631
-           	$ret = $this->message[$pos]['cdata'];
632
-			$this->debug("in buildVal, return: $ret");
633
-           	return $ret;
634
-		}
635
-	}
602
+                if (isset($this->message[$pos]['type'])) {
603
+                    $params['!'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$pos]['type'], isset($this->message[$pos]['type_namespace']) ? $this->message[$pos]['type_namespace'] : '');
604
+                } else {
605
+                    $parent = $this->message[$pos]['parent'];
606
+                    if (isset($this->message[$parent]['type']) && ($this->message[$parent]['type'] == 'array') && isset($this->message[$parent]['arrayType'])) {
607
+                        $params['!'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$parent]['arrayType'], isset($this->message[$parent]['arrayTypeNamespace']) ? $this->message[$parent]['arrayTypeNamespace'] : '');
608
+                    } else {
609
+                        $params['!'] = $this->message[$pos]['cdata'];
610
+                    }
611
+                }
612
+            }
613
+            $ret = is_array($params) ? $params : array();
614
+            $this->debug('in buildVal, return:');
615
+            //$this->appendDebug($this->varDump($ret));
616
+            return $ret;
617
+        } else {
618
+            $this->debug('in buildVal, no children, building scalar');
619
+            $cdata = isset($this->message[$pos]['cdata']) ? $this->message[$pos]['cdata'] : '';
620
+            if (isset($this->message[$pos]['type'])) {
621
+                $ret = $this->decodeSimple($cdata, $this->message[$pos]['type'], isset($this->message[$pos]['type_namespace']) ? $this->message[$pos]['type_namespace'] : '');
622
+                $this->debug("in buildVal, return: $ret");
623
+                return $ret;
624
+            }
625
+            $parent = $this->message[$pos]['parent'];
626
+            if (isset($this->message[$parent]['type']) && ($this->message[$parent]['type'] == 'array') && isset($this->message[$parent]['arrayType'])) {
627
+                $ret = $this->decodeSimple($cdata, $this->message[$parent]['arrayType'], isset($this->message[$parent]['arrayTypeNamespace']) ? $this->message[$parent]['arrayTypeNamespace'] : '');
628
+                $this->debug("in buildVal, return: $ret");
629
+                return $ret;
630
+            }
631
+                $ret = $this->message[$pos]['cdata'];
632
+            $this->debug("in buildVal, return: $ret");
633
+                return $ret;
634
+        }
635
+    }
636 636
 }
637 637
 
638 638
 /**
Please login to merge, or discard this patch.
Spacing   +76 added lines, -76 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 	var $root_struct_name = '';
19 19
 	var $root_struct_namespace = '';
20 20
 	var $root_header = '';
21
-    var $document = '';			// incoming SOAP body (text)
21
+    var $document = ''; // incoming SOAP body (text)
22 22
 	// determines where in the message we are (envelope,header,body,method)
23 23
 	var $status = '';
24 24
 	var $position = 0;
@@ -33,9 +33,9 @@  discard block
 block discarded – undo
33 33
 	var $fault_detail = '';
34 34
 	var $depth_array = array();
35 35
 	var $debug_flag = true;
36
-	var $soapresponse = NULL;	// parsed SOAP Body
37
-	var $soapheader = NULL;		// parsed SOAP Header
38
-	var $responseHeaders = '';	// incoming SOAP headers (text)
36
+	var $soapresponse = NULL; // parsed SOAP Body
37
+	var $soapheader = NULL; // parsed SOAP Header
38
+	var $responseHeaders = ''; // incoming SOAP headers (text)
39 39
 	var $body_position = 0;
40 40
 	// for multiref parsing:
41 41
 	// array of id => pos
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 	* @param    string $decode_utf8 whether to decode UTF-8 to ISO-8859-1
55 55
 	* @access   public
56 56
 	*/
57
-	function nusoap_parser($xml,$encoding='UTF-8',$method='',$decode_utf8=true){
57
+	function nusoap_parser($xml, $encoding = 'UTF-8', $method = '', $decode_utf8 = true) {
58 58
 		parent::nusoap_base();
59 59
 		$this->xml = $xml;
60 60
 		$this->xml_encoding = $encoding;
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 		$this->decode_utf8 = $decode_utf8;
63 63
 
64 64
 		// Check whether content has been read.
65
-		if(!empty($this->xml)){
65
+		if (!empty($this->xml)) {
66 66
 			// Check XML encoding
67 67
 			$pos_xml = strpos($xml, '<?xml');
68 68
 			if ($pos_xml !== FALSE) {
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 				if (preg_match("/encoding=[\"']([^\"']*)[\"']/", $xml_decl, $res)) {
71 71
 					$xml_encoding = $res[1];
72 72
 					if (strtoupper($xml_encoding) != $encoding) {
73
-						$err = "Charset from HTTP Content-Type '" . $encoding . "' does not match encoding from XML declaration '" . $xml_encoding . "'";
73
+						$err = "Charset from HTTP Content-Type '".$encoding."' does not match encoding from XML declaration '".$xml_encoding."'";
74 74
 						$this->debug($err);
75 75
 						if ($encoding != 'ISO-8859-1' || strtoupper($xml_encoding) != 'UTF-8') {
76 76
 							$this->setError($err);
@@ -96,8 +96,8 @@  discard block
 block discarded – undo
96 96
 			// Set the object for the parser.
97 97
 			xml_set_object($this->parser, $this);
98 98
 			// Set the element handlers for the parser.
99
-			xml_set_element_handler($this->parser, 'start_element','end_element');
100
-			xml_set_character_data_handler($this->parser,'character_data');
99
+			xml_set_element_handler($this->parser, 'start_element', 'end_element');
100
+			xml_set_character_data_handler($this->parser, 'character_data');
101 101
 
102 102
 			xml_parse($this->parser, $this->xml);
103 103
 
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
 			    xml_get_current_line_number($this->parser),
110 110
 			    xml_error_string(xml_get_error_code($this->parser)));
111 111
 				$this->debug($err);
112
-				$this->debug("XML payload:\n" . $xml);
112
+				$this->debug("XML payload:\n".$xml);
113 113
 				$this->setError($err);
114 114
 			} else {
115 115
 				$this->debug('in nusoap_parser ctor, message:');
@@ -118,18 +118,18 @@  discard block
 block discarded – undo
118 118
 				// get final value
119 119
 				$this->soapresponse = $this->message[$this->root_struct]['result'];
120 120
 				// get header value
121
-				if($this->root_header != '' && isset($this->message[$this->root_header]['result'])){
121
+				if ($this->root_header != '' && isset($this->message[$this->root_header]['result'])) {
122 122
 					$this->soapheader = $this->message[$this->root_header]['result'];
123 123
 				}
124 124
 				// resolve hrefs/ids
125
-				if(sizeof($this->multirefs) > 0){
126
-					foreach($this->multirefs as $id => $hrefs){
125
+				if (sizeof($this->multirefs) > 0) {
126
+					foreach ($this->multirefs as $id => $hrefs) {
127 127
 						$this->debug('resolving multirefs for id: '.$id);
128 128
 						$idVal = $this->buildVal($this->ids[$id]);
129 129
 						if (is_array($idVal) && isset($idVal['!id'])) {
130 130
 							unset($idVal['!id']);
131 131
 						}
132
-						foreach($hrefs as $refPos => $ref){
132
+						foreach ($hrefs as $refPos => $ref) {
133 133
 							$this->debug('resolving href at pos '.$refPos);
134 134
 							$this->multirefs[$id][$refPos] = $idVal;
135 135
 						}
@@ -157,13 +157,13 @@  discard block
 block discarded – undo
157 157
 		// update class level pos
158 158
 		$pos = $this->position++;
159 159
 		// and set mine
160
-		$this->message[$pos] = array('pos' => $pos,'children'=>'','cdata'=>'');
160
+		$this->message[$pos] = array('pos' => $pos, 'children'=>'', 'cdata'=>'');
161 161
 		// depth = how many levels removed from root?
162 162
 		// set mine as current global depth and increment global depth value
163 163
 		$this->message[$pos]['depth'] = $this->depth++;
164 164
 
165 165
 		// else add self as child to whoever the current parent is
166
-		if($pos != 0){
166
+		if ($pos != 0) {
167 167
 			$this->message[$this->parent]['children'] .= '|'.$pos;
168 168
 		}
169 169
 		// set my parent
@@ -173,11 +173,11 @@  discard block
 block discarded – undo
173 173
 		// set self as current value for this depth
174 174
 		$this->depth_array[$this->depth] = $pos;
175 175
 		// get element prefix
176
-		if(strpos($name,':')){
176
+		if (strpos($name, ':')) {
177 177
 			// get ns prefix
178
-			$prefix = substr($name,0,strpos($name,':'));
178
+			$prefix = substr($name, 0, strpos($name, ':'));
179 179
 			// get unqualified name
180
-			$name = substr(strstr($name,':'),1);
180
+			$name = substr(strstr($name, ':'), 1);
181 181
 		}
182 182
 		// set status
183 183
 		if ($name == 'Envelope' && $this->status == '') {
@@ -185,11 +185,11 @@  discard block
 block discarded – undo
185 185
 		} elseif ($name == 'Header' && $this->status == 'envelope') {
186 186
 			$this->root_header = $pos;
187 187
 			$this->status = 'header';
188
-		} elseif ($name == 'Body' && $this->status == 'envelope'){
188
+		} elseif ($name == 'Body' && $this->status == 'envelope') {
189 189
 			$this->status = 'body';
190 190
 			$this->body_position = $pos;
191 191
 		// set method
192
-		} elseif($this->status == 'body' && $pos == ($this->body_position+1)) {
192
+		} elseif ($this->status == 'body' && $pos == ($this->body_position + 1)) {
193 193
 			$this->status = 'method';
194 194
 			$this->root_struct_name = $name;
195 195
 			$this->root_struct = $pos;
@@ -205,23 +205,23 @@  discard block
 block discarded – undo
205 205
 
206 206
 		// loop through atts, logging ns and type declarations
207 207
         $attstr = '';
208
-		foreach($attrs as $key => $value){
208
+		foreach ($attrs as $key => $value) {
209 209
         	$key_prefix = $this->getPrefix($key);
210 210
 			$key_localpart = $this->getLocalPart($key);
211 211
 			// if ns declarations, add to class level array of valid namespaces
212
-            if($key_prefix == 'xmlns'){
213
-				if(preg_match('/^http:\/\/www.w3.org\/[0-9]{4}\/XMLSchema$/',$value)){
212
+            if ($key_prefix == 'xmlns') {
213
+				if (preg_match('/^http:\/\/www.w3.org\/[0-9]{4}\/XMLSchema$/', $value)) {
214 214
 					$this->XMLSchemaVersion = $value;
215 215
 					$this->namespaces['xsd'] = $this->XMLSchemaVersion;
216 216
 					$this->namespaces['xsi'] = $this->XMLSchemaVersion.'-instance';
217 217
 				}
218 218
                 $this->namespaces[$key_localpart] = $value;
219 219
 				// set method namespace
220
-				if($name == $this->root_struct_name){
220
+				if ($name == $this->root_struct_name) {
221 221
 					$this->methodNamespace = $value;
222 222
 				}
223 223
 			// if it's a type declaration, set type
224
-        } elseif($key_localpart == 'type'){
224
+        } elseif ($key_localpart == 'type') {
225 225
         		if (isset($this->message[$pos]['type']) && $this->message[$pos]['type'] == 'array') {
226 226
         			// do nothing: already processed arrayType
227 227
         		} else {
@@ -229,14 +229,14 @@  discard block
 block discarded – undo
229 229
 	                $value_localpart = $this->getLocalPart($value);
230 230
 					$this->message[$pos]['type'] = $value_localpart;
231 231
 					$this->message[$pos]['typePrefix'] = $value_prefix;
232
-	                if(isset($this->namespaces[$value_prefix])){
232
+	                if (isset($this->namespaces[$value_prefix])) {
233 233
 	                	$this->message[$pos]['type_namespace'] = $this->namespaces[$value_prefix];
234
-	                } else if(isset($attrs['xmlns:'.$value_prefix])) {
234
+	                } else if (isset($attrs['xmlns:'.$value_prefix])) {
235 235
 						$this->message[$pos]['type_namespace'] = $attrs['xmlns:'.$value_prefix];
236 236
 	                }
237 237
 					// should do something here with the namespace of specified type?
238 238
 				}
239
-			} elseif($key_localpart == 'arrayType'){
239
+			} elseif ($key_localpart == 'arrayType') {
240 240
 				$this->message[$pos]['type'] = 'array';
241 241
 				/* do arrayType ereg here
242 242
 				[1]    arrayTypeValue    ::=    atype asize
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
 				[6]    nextDimension    ::=    Digit+ ','
248 248
 				*/
249 249
 				$expr = '/([A-Za-z0-9_]+):([A-Za-z]+[A-Za-z0-9_]+)\[([0-9]+),?([0-9]*)\]/';
250
-				if(preg_match($expr,$value,$regs)){
250
+				if (preg_match($expr, $value, $regs)) {
251 251
 					$this->message[$pos]['typePrefix'] = $regs[1];
252 252
 					$this->message[$pos]['arrayTypePrefix'] = $regs[1];
253 253
 	                if (isset($this->namespaces[$regs[1]])) {
@@ -260,22 +260,22 @@  discard block
 block discarded – undo
260 260
 					$this->message[$pos]['arrayCols'] = $regs[4];
261 261
 				}
262 262
 			// specifies nil value (or not)
263
-			} elseif ($key_localpart == 'nil'){
263
+			} elseif ($key_localpart == 'nil') {
264 264
 				$this->message[$pos]['nil'] = ($value == 'true' || $value == '1');
265 265
 			// some other attribute
266 266
 			} elseif ($key != 'href' && $key != 'xmlns' && $key_localpart != 'encodingStyle' && $key_localpart != 'root') {
267
-				$this->message[$pos]['xattrs']['!' . $key] = $value;
267
+				$this->message[$pos]['xattrs']['!'.$key] = $value;
268 268
 			}
269 269
 
270 270
 			if ($key == 'xmlns') {
271 271
 				$this->default_namespace = $value;
272 272
 			}
273 273
 			// log id
274
-			if($key == 'id'){
274
+			if ($key == 'id') {
275 275
 				$this->ids[$value] = $pos;
276 276
 			}
277 277
 			// root
278
-			if($key_localpart == 'root' && $value == 1){
278
+			if ($key_localpart == 'root' && $value == 1) {
279 279
 				$this->status = 'method';
280 280
 				$this->root_struct_name = $name;
281 281
 				$this->root_struct = $pos;
@@ -285,18 +285,18 @@  discard block
 block discarded – undo
285 285
             $attstr .= " $key=\"$value\"";
286 286
 		}
287 287
         // get namespace - must be done after namespace atts are processed
288
-		if(isset($prefix)){
288
+		if (isset($prefix)) {
289 289
 			$this->message[$pos]['namespace'] = $this->namespaces[$prefix];
290 290
 			$this->default_namespace = $this->namespaces[$prefix];
291 291
 		} else {
292 292
 			$this->message[$pos]['namespace'] = $this->default_namespace;
293 293
 		}
294
-        if($this->status == 'header'){
294
+        if ($this->status == 'header') {
295 295
         	if ($this->root_header != $pos) {
296
-	        	$this->responseHeaders .= "<" . (isset($prefix) ? $prefix . ':' : '') . "$name$attstr>";
296
+	        	$this->responseHeaders .= "<".(isset($prefix) ? $prefix.':' : '')."$name$attstr>";
297 297
 	        }
298
-        } elseif($this->root_struct_name != ''){
299
-        	$this->document .= "<" . (isset($prefix) ? $prefix . ':' : '') . "$name$attstr>";
298
+        } elseif ($this->root_struct_name != '') {
299
+        	$this->document .= "<".(isset($prefix) ? $prefix.':' : '')."$name$attstr>";
300 300
         }
301 301
 	}
302 302
 
@@ -312,27 +312,27 @@  discard block
 block discarded – undo
312 312
 		$pos = $this->depth_array[$this->depth--];
313 313
 
314 314
         // get element prefix
315
-		if(strpos($name,':')){
315
+		if (strpos($name, ':')) {
316 316
 			// get ns prefix
317
-			$prefix = substr($name,0,strpos($name,':'));
317
+			$prefix = substr($name, 0, strpos($name, ':'));
318 318
 			// get unqualified name
319
-			$name = substr(strstr($name,':'),1);
319
+			$name = substr(strstr($name, ':'), 1);
320 320
 		}
321 321
 		
322 322
 		// build to native type
323
-		if(isset($this->body_position) && $pos > $this->body_position){
323
+		if (isset($this->body_position) && $pos > $this->body_position) {
324 324
 			// deal w/ multirefs
325
-			if(isset($this->message[$pos]['attrs']['href'])){
325
+			if (isset($this->message[$pos]['attrs']['href'])) {
326 326
 				// get id
327
-				$id = substr($this->message[$pos]['attrs']['href'],1);
327
+				$id = substr($this->message[$pos]['attrs']['href'], 1);
328 328
 				// add placeholder to href array
329 329
 				$this->multirefs[$id][$pos] = 'placeholder';
330 330
 				// add set a reference to it as the result value
331
-				$this->message[$pos]['result'] =& $this->multirefs[$id][$pos];
331
+				$this->message[$pos]['result'] = & $this->multirefs[$id][$pos];
332 332
             // build complexType values
333
-			} elseif($this->message[$pos]['children'] != ''){
333
+			} elseif ($this->message[$pos]['children'] != '') {
334 334
 				// if result has already been generated (struct/array)
335
-				if(!isset($this->message[$pos]['result'])){
335
+				if (!isset($this->message[$pos]['result'])) {
336 336
 					$this->message[$pos]['result'] = $this->buildVal($pos);
337 337
 				}
338 338
 			// build complexType values of attributes and possibly simpleContent
@@ -382,15 +382,15 @@  discard block
 block discarded – undo
382 382
 		}
383 383
 		
384 384
         // for doclit
385
-        if($this->status == 'header'){
385
+        if ($this->status == 'header') {
386 386
         	if ($this->root_header != $pos) {
387
-	        	$this->responseHeaders .= "</" . (isset($prefix) ? $prefix . ':' : '') . "$name>";
387
+	        	$this->responseHeaders .= "</".(isset($prefix) ? $prefix.':' : '')."$name>";
388 388
 	        }
389
-        } elseif($pos >= $this->root_struct){
390
-        	$this->document .= "</" . (isset($prefix) ? $prefix . ':' : '') . "$name>";
389
+        } elseif ($pos >= $this->root_struct) {
390
+        	$this->document .= "</".(isset($prefix) ? $prefix.':' : '')."$name>";
391 391
         }
392 392
 		// switch status
393
-		if ($pos == $this->root_struct){
393
+		if ($pos == $this->root_struct) {
394 394
 			$this->status = 'body';
395 395
 			$this->root_struct_namespace = $this->message[$pos]['namespace'];
396 396
 		} elseif ($pos == $this->root_header) {
@@ -416,17 +416,17 @@  discard block
 block discarded – undo
416 416
 	function character_data($parser, $data)
417 417
     {
418 418
 		$pos = $this->depth_array[$this->depth];
419
-		if ($this->xml_encoding == 'UTF-8'){
419
+		if ($this->xml_encoding == 'UTF-8') {
420 420
 			// TODO: add an option to disable this for folks who want
421 421
 			// raw UTF-8 that, e.g., might not map to iso-8859-1
422 422
 			// TODO: this can also be handled with xml_parser_set_option($this->parser, XML_OPTION_TARGET_ENCODING, "ISO-8859-1");
423
-			if($this->decode_utf8){
423
+			if ($this->decode_utf8) {
424 424
 				$data = utf8_decode($data);
425 425
 			}
426 426
 		}
427 427
         $this->message[$pos]['cdata'] .= $data;
428 428
         // for doclit
429
-        if($this->status == 'header'){
429
+        if ($this->status == 'header') {
430 430
         	$this->responseHeaders .= $data;
431 431
         } else {
432 432
         	$this->document .= $data;
@@ -440,7 +440,7 @@  discard block
 block discarded – undo
440 440
 	* @access   public
441 441
 	* @deprecated	use get_soapbody instead
442 442
 	*/
443
-	function get_response(){
443
+	function get_response() {
444 444
 		return $this->soapresponse;
445 445
 	}
446 446
 
@@ -450,7 +450,7 @@  discard block
 block discarded – undo
450 450
 	* @return	mixed
451 451
 	* @access   public
452 452
 	*/
453
-	function get_soapbody(){
453
+	function get_soapbody() {
454 454
 		return $this->soapresponse;
455 455
 	}
456 456
 
@@ -460,7 +460,7 @@  discard block
 block discarded – undo
460 460
 	* @return	mixed
461 461
 	* @access   public
462 462
 	*/
463
-	function get_soapheader(){
463
+	function get_soapheader() {
464 464
 		return $this->soapheader;
465 465
 	}
466 466
 
@@ -470,7 +470,7 @@  discard block
 block discarded – undo
470 470
 	* @return	string XML or empty if no Header
471 471
 	* @access   public
472 472
 	*/
473
-	function getHeaders(){
473
+	function getHeaders() {
474 474
 	    return $this->responseHeaders;
475 475
 	}
476 476
 
@@ -527,40 +527,40 @@  discard block
 block discarded – undo
527 527
 	* @return	mixed	PHP value
528 528
 	* @access   private
529 529
 	*/
530
-	function buildVal($pos){
531
-		if(!isset($this->message[$pos]['type'])){
530
+	function buildVal($pos) {
531
+		if (!isset($this->message[$pos]['type'])) {
532 532
 			$this->message[$pos]['type'] = '';
533 533
 		}
534 534
 		$this->debug('in buildVal() for '.$this->message[$pos]['name']."(pos $pos) of type ".$this->message[$pos]['type']);
535 535
 		// if there are children...
536
-		if($this->message[$pos]['children'] != ''){
536
+		if ($this->message[$pos]['children'] != '') {
537 537
 			$this->debug('in buildVal, there are children');
538
-			$children = explode('|',$this->message[$pos]['children']);
538
+			$children = explode('|', $this->message[$pos]['children']);
539 539
 			array_shift($children); // knock off empty
540 540
 			// md array
541
-			if(isset($this->message[$pos]['arrayCols']) && $this->message[$pos]['arrayCols'] != ''){
542
-            	$r=0; // rowcount
543
-            	$c=0; // colcount
544
-            	foreach($children as $child_pos){
541
+			if (isset($this->message[$pos]['arrayCols']) && $this->message[$pos]['arrayCols'] != '') {
542
+            	$r = 0; // rowcount
543
+            	$c = 0; // colcount
544
+            	foreach ($children as $child_pos) {
545 545
 					$this->debug("in buildVal, got an MD array element: $r, $c");
546 546
 					$params[$r][] = $this->message[$child_pos]['result'];
547 547
 				    $c++;
548
-				    if($c == $this->message[$pos]['arrayCols']){
548
+				    if ($c == $this->message[$pos]['arrayCols']) {
549 549
 				    	$c = 0;
550 550
 						$r++;
551 551
 				    }
552 552
                 }
553 553
             // array
554
-			} elseif($this->message[$pos]['type'] == 'array' || $this->message[$pos]['type'] == 'Array'){
554
+			} elseif ($this->message[$pos]['type'] == 'array' || $this->message[$pos]['type'] == 'Array') {
555 555
                 $this->debug('in buildVal, adding array '.$this->message[$pos]['name']);
556
-                foreach($children as $child_pos){
556
+                foreach ($children as $child_pos) {
557 557
                 	$params[] = &$this->message[$child_pos]['result'];
558 558
                 }
559 559
             // apache Map type: java hashtable
560
-            } elseif($this->message[$pos]['type'] == 'Map' && $this->message[$pos]['type_namespace'] == 'http://xml.apache.org/xml-soap'){
560
+            } elseif ($this->message[$pos]['type'] == 'Map' && $this->message[$pos]['type_namespace'] == 'http://xml.apache.org/xml-soap') {
561 561
                 $this->debug('in buildVal, Java Map '.$this->message[$pos]['name']);
562
-                foreach($children as $child_pos){
563
-                	$kv = explode("|",$this->message[$child_pos]['children']);
562
+                foreach ($children as $child_pos) {
563
+                	$kv = explode("|", $this->message[$child_pos]['children']);
564 564
                    	$params[$this->message[$kv[1]]['result']] = &$this->message[$kv[2]]['result'];
565 565
                 }
566 566
             // generic compound type
@@ -574,8 +574,8 @@  discard block
 block discarded – undo
574 574
 					$notstruct = 0;
575 575
 	            }
576 576
             	//
577
-            	foreach($children as $child_pos){
578
-            		if($notstruct){
577
+            	foreach ($children as $child_pos) {
578
+            		if ($notstruct) {
579 579
             			$params[] = &$this->message[$child_pos]['result'];
580 580
             		} else {
581 581
             			if (isset($params[$this->message[$child_pos]['name']])) {
Please login to merge, or discard this patch.
main/inc/lib/nusoap/class.wsdlcache.php 2 patches
Indentation   +175 added lines, -175 removed lines patch added patch discarded remove patch
@@ -16,189 +16,189 @@
 block discarded – undo
16 16
 * @access public 
17 17
 */
18 18
 class nusoap_wsdlcache {
19
-	/**
20
-	 *	@var resource
21
-	 *	@access private
22
-	 */
23
-	var $fplock;
24
-	/**
25
-	 *	@var integer
26
-	 *	@access private
27
-	 */
28
-	var $cache_lifetime;
29
-	/**
30
-	 *	@var string
31
-	 *	@access private
32
-	 */
33
-	var $cache_dir;
34
-	/**
35
-	 *	@var string
36
-	 *	@access public
37
-	 */
38
-	var $debug_str = '';
19
+    /**
20
+     *	@var resource
21
+     *	@access private
22
+     */
23
+    var $fplock;
24
+    /**
25
+     *	@var integer
26
+     *	@access private
27
+     */
28
+    var $cache_lifetime;
29
+    /**
30
+     *	@var string
31
+     *	@access private
32
+     */
33
+    var $cache_dir;
34
+    /**
35
+     *	@var string
36
+     *	@access public
37
+     */
38
+    var $debug_str = '';
39 39
 
40
-	/**
41
-	* constructor
42
-	*
43
-	* @param string $cache_dir directory for cache-files
44
-	* @param integer $cache_lifetime lifetime for caching-files in seconds or 0 for unlimited
45
-	* @access public
46
-	*/
47
-	function nusoap_wsdlcache($cache_dir='.', $cache_lifetime=0) {
48
-		$this->fplock = array();
49
-		$this->cache_dir = $cache_dir != '' ? $cache_dir : '.';
50
-		$this->cache_lifetime = $cache_lifetime;
51
-	}
40
+    /**
41
+     * constructor
42
+     *
43
+     * @param string $cache_dir directory for cache-files
44
+     * @param integer $cache_lifetime lifetime for caching-files in seconds or 0 for unlimited
45
+     * @access public
46
+     */
47
+    function nusoap_wsdlcache($cache_dir='.', $cache_lifetime=0) {
48
+        $this->fplock = array();
49
+        $this->cache_dir = $cache_dir != '' ? $cache_dir : '.';
50
+        $this->cache_lifetime = $cache_lifetime;
51
+    }
52 52
 
53
-	/**
54
-	* creates the filename used to cache a wsdl instance
55
-	*
56
-	* @param string $wsdl The URL of the wsdl instance
57
-	* @return string The filename used to cache the instance
58
-	* @access private
59
-	*/
60
-	function createFilename($wsdl) {
61
-		return $this->cache_dir.'/wsdlcache-' . md5($wsdl);
62
-	}
53
+    /**
54
+     * creates the filename used to cache a wsdl instance
55
+     *
56
+     * @param string $wsdl The URL of the wsdl instance
57
+     * @return string The filename used to cache the instance
58
+     * @access private
59
+     */
60
+    function createFilename($wsdl) {
61
+        return $this->cache_dir.'/wsdlcache-' . md5($wsdl);
62
+    }
63 63
 
64
-	/**
65
-	* adds debug data to the class level debug string
66
-	*
67
-	* @param    string $string debug data
68
-	* @access   private
69
-	*/
70
-	function debug($string){
71
-		$this->debug_str .= get_class($this).": $string\n";
72
-	}
64
+    /**
65
+     * adds debug data to the class level debug string
66
+     *
67
+     * @param    string $string debug data
68
+     * @access   private
69
+     */
70
+    function debug($string){
71
+        $this->debug_str .= get_class($this).": $string\n";
72
+    }
73 73
 
74
-	/**
75
-	* gets a wsdl instance from the cache
76
-	*
77
-	* @param string $wsdl The URL of the wsdl instance
78
-	* @return object wsdl The cached wsdl instance, null if the instance is not in the cache
79
-	* @access public
80
-	*/
81
-	function get($wsdl) {
82
-		$filename = $this->createFilename($wsdl);
83
-		if ($this->obtainMutex($filename, "r")) {
84
-			// check for expired WSDL that must be removed from the cache
85
- 			if ($this->cache_lifetime > 0) {
86
-				if (file_exists($filename) && (time() - filemtime($filename) > $this->cache_lifetime)) {
87
-					unlink($filename);
88
-					$this->debug("Expired $wsdl ($filename) from cache");
89
-					$this->releaseMutex($filename);
90
-					return null;
91
-  				}
92
-			}
93
-			// see what there is to return
94
-			if (!file_exists($filename)) {
95
-				$this->debug("$wsdl ($filename) not in cache (1)");
96
-				$this->releaseMutex($filename);
97
-				return null;
98
-			}
99
-			$fp = @fopen($filename, "r");
100
-			if ($fp) {
101
-				$s = implode("", @file($filename));
102
-				fclose($fp);
103
-				$this->debug("Got $wsdl ($filename) from cache");
104
-			} else {
105
-				$s = null;
106
-				$this->debug("$wsdl ($filename) not in cache (2)");
107
-			}
108
-			$this->releaseMutex($filename);
109
-			return (!is_null($s)) ? unserialize($s) : null;
110
-		} else {
111
-			$this->debug("Unable to obtain mutex for $filename in get");
112
-		}
113
-		return null;
114
-	}
74
+    /**
75
+     * gets a wsdl instance from the cache
76
+     *
77
+     * @param string $wsdl The URL of the wsdl instance
78
+     * @return object wsdl The cached wsdl instance, null if the instance is not in the cache
79
+     * @access public
80
+     */
81
+    function get($wsdl) {
82
+        $filename = $this->createFilename($wsdl);
83
+        if ($this->obtainMutex($filename, "r")) {
84
+            // check for expired WSDL that must be removed from the cache
85
+                if ($this->cache_lifetime > 0) {
86
+                if (file_exists($filename) && (time() - filemtime($filename) > $this->cache_lifetime)) {
87
+                    unlink($filename);
88
+                    $this->debug("Expired $wsdl ($filename) from cache");
89
+                    $this->releaseMutex($filename);
90
+                    return null;
91
+                    }
92
+            }
93
+            // see what there is to return
94
+            if (!file_exists($filename)) {
95
+                $this->debug("$wsdl ($filename) not in cache (1)");
96
+                $this->releaseMutex($filename);
97
+                return null;
98
+            }
99
+            $fp = @fopen($filename, "r");
100
+            if ($fp) {
101
+                $s = implode("", @file($filename));
102
+                fclose($fp);
103
+                $this->debug("Got $wsdl ($filename) from cache");
104
+            } else {
105
+                $s = null;
106
+                $this->debug("$wsdl ($filename) not in cache (2)");
107
+            }
108
+            $this->releaseMutex($filename);
109
+            return (!is_null($s)) ? unserialize($s) : null;
110
+        } else {
111
+            $this->debug("Unable to obtain mutex for $filename in get");
112
+        }
113
+        return null;
114
+    }
115 115
 
116
-	/**
117
-	* obtains the local mutex
118
-	*
119
-	* @param string $filename The Filename of the Cache to lock
120
-	* @param string $mode The open-mode ("r" or "w") or the file - affects lock-mode
121
-	* @return boolean Lock successfully obtained ?!
122
-	* @access private
123
-	*/
124
-	function obtainMutex($filename, $mode) {
125
-		if (isset($this->fplock[md5($filename)])) {
126
-			$this->debug("Lock for $filename already exists");
127
-			return false;
128
-		}
129
-		$this->fplock[md5($filename)] = fopen($filename.".lock", "w");
130
-		if ($mode == "r") {
131
-			return flock($this->fplock[md5($filename)], LOCK_SH);
132
-		} else {
133
-			return flock($this->fplock[md5($filename)], LOCK_EX);
134
-		}
135
-	}
116
+    /**
117
+     * obtains the local mutex
118
+     *
119
+     * @param string $filename The Filename of the Cache to lock
120
+     * @param string $mode The open-mode ("r" or "w") or the file - affects lock-mode
121
+     * @return boolean Lock successfully obtained ?!
122
+     * @access private
123
+     */
124
+    function obtainMutex($filename, $mode) {
125
+        if (isset($this->fplock[md5($filename)])) {
126
+            $this->debug("Lock for $filename already exists");
127
+            return false;
128
+        }
129
+        $this->fplock[md5($filename)] = fopen($filename.".lock", "w");
130
+        if ($mode == "r") {
131
+            return flock($this->fplock[md5($filename)], LOCK_SH);
132
+        } else {
133
+            return flock($this->fplock[md5($filename)], LOCK_EX);
134
+        }
135
+    }
136 136
 
137
-	/**
138
-	* adds a wsdl instance to the cache
139
-	*
140
-	* @param object wsdl $wsdl_instance The wsdl instance to add
141
-	* @return boolean WSDL successfully cached
142
-	* @access public
143
-	*/
144
-	function put($wsdl_instance) {
145
-		$filename = $this->createFilename($wsdl_instance->wsdl);
146
-		$s = serialize($wsdl_instance);
147
-		if ($this->obtainMutex($filename, "w")) {
148
-			$fp = fopen($filename, "w");
149
-			if (! $fp) {
150
-				$this->debug("Cannot write $wsdl_instance->wsdl ($filename) in cache");
151
-				$this->releaseMutex($filename);
152
-				return false;
153
-			}
154
-			fputs($fp, $s);
155
-			fclose($fp);
156
-			$this->debug("Put $wsdl_instance->wsdl ($filename) in cache");
157
-			$this->releaseMutex($filename);
158
-			return true;
159
-		} else {
160
-			$this->debug("Unable to obtain mutex for $filename in put");
161
-		}
162
-		return false;
163
-	}
137
+    /**
138
+     * adds a wsdl instance to the cache
139
+     *
140
+     * @param object wsdl $wsdl_instance The wsdl instance to add
141
+     * @return boolean WSDL successfully cached
142
+     * @access public
143
+     */
144
+    function put($wsdl_instance) {
145
+        $filename = $this->createFilename($wsdl_instance->wsdl);
146
+        $s = serialize($wsdl_instance);
147
+        if ($this->obtainMutex($filename, "w")) {
148
+            $fp = fopen($filename, "w");
149
+            if (! $fp) {
150
+                $this->debug("Cannot write $wsdl_instance->wsdl ($filename) in cache");
151
+                $this->releaseMutex($filename);
152
+                return false;
153
+            }
154
+            fputs($fp, $s);
155
+            fclose($fp);
156
+            $this->debug("Put $wsdl_instance->wsdl ($filename) in cache");
157
+            $this->releaseMutex($filename);
158
+            return true;
159
+        } else {
160
+            $this->debug("Unable to obtain mutex for $filename in put");
161
+        }
162
+        return false;
163
+    }
164 164
 
165
-	/**
166
-	* releases the local mutex
167
-	*
168
-	* @param string $filename The Filename of the Cache to lock
169
-	* @return boolean Lock successfully released
170
-	* @access private
171
-	*/
172
-	function releaseMutex($filename) {
173
-		$ret = flock($this->fplock[md5($filename)], LOCK_UN);
174
-		fclose($this->fplock[md5($filename)]);
175
-		unset($this->fplock[md5($filename)]);
176
-		if (! $ret) {
177
-			$this->debug("Not able to release lock for $filename");
178
-		}
179
-		return $ret;
180
-	}
165
+    /**
166
+     * releases the local mutex
167
+     *
168
+     * @param string $filename The Filename of the Cache to lock
169
+     * @return boolean Lock successfully released
170
+     * @access private
171
+     */
172
+    function releaseMutex($filename) {
173
+        $ret = flock($this->fplock[md5($filename)], LOCK_UN);
174
+        fclose($this->fplock[md5($filename)]);
175
+        unset($this->fplock[md5($filename)]);
176
+        if (! $ret) {
177
+            $this->debug("Not able to release lock for $filename");
178
+        }
179
+        return $ret;
180
+    }
181 181
 
182
-	/**
183
-	* removes a wsdl instance from the cache
184
-	*
185
-	* @param string $wsdl The URL of the wsdl instance
186
-	* @return boolean Whether there was an instance to remove
187
-	* @access public
188
-	*/
189
-	function remove($wsdl) {
190
-		$filename = $this->createFilename($wsdl);
191
-		if (!file_exists($filename)) {
192
-			$this->debug("$wsdl ($filename) not in cache to be removed");
193
-			return false;
194
-		}
195
-		// ignore errors obtaining mutex
196
-		$this->obtainMutex($filename, "w");
197
-		$ret = unlink($filename);
198
-		$this->debug("Removed ($ret) $wsdl ($filename) from cache");
199
-		$this->releaseMutex($filename);
200
-		return $ret;
201
-	}
182
+    /**
183
+     * removes a wsdl instance from the cache
184
+     *
185
+     * @param string $wsdl The URL of the wsdl instance
186
+     * @return boolean Whether there was an instance to remove
187
+     * @access public
188
+     */
189
+    function remove($wsdl) {
190
+        $filename = $this->createFilename($wsdl);
191
+        if (!file_exists($filename)) {
192
+            $this->debug("$wsdl ($filename) not in cache to be removed");
193
+            return false;
194
+        }
195
+        // ignore errors obtaining mutex
196
+        $this->obtainMutex($filename, "w");
197
+        $ret = unlink($filename);
198
+        $this->debug("Removed ($ret) $wsdl ($filename) from cache");
199
+        $this->releaseMutex($filename);
200
+        return $ret;
201
+    }
202 202
 }
203 203
 
204 204
 /**
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 	* @param integer $cache_lifetime lifetime for caching-files in seconds or 0 for unlimited
45 45
 	* @access public
46 46
 	*/
47
-	function nusoap_wsdlcache($cache_dir='.', $cache_lifetime=0) {
47
+	function nusoap_wsdlcache($cache_dir = '.', $cache_lifetime = 0) {
48 48
 		$this->fplock = array();
49 49
 		$this->cache_dir = $cache_dir != '' ? $cache_dir : '.';
50 50
 		$this->cache_lifetime = $cache_lifetime;
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 	* @access private
59 59
 	*/
60 60
 	function createFilename($wsdl) {
61
-		return $this->cache_dir.'/wsdlcache-' . md5($wsdl);
61
+		return $this->cache_dir.'/wsdlcache-'.md5($wsdl);
62 62
 	}
63 63
 
64 64
 	/**
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 	* @param    string $string debug data
68 68
 	* @access   private
69 69
 	*/
70
-	function debug($string){
70
+	function debug($string) {
71 71
 		$this->debug_str .= get_class($this).": $string\n";
72 72
 	}
73 73
 
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 		$s = serialize($wsdl_instance);
147 147
 		if ($this->obtainMutex($filename, "w")) {
148 148
 			$fp = fopen($filename, "w");
149
-			if (! $fp) {
149
+			if (!$fp) {
150 150
 				$this->debug("Cannot write $wsdl_instance->wsdl ($filename) in cache");
151 151
 				$this->releaseMutex($filename);
152 152
 				return false;
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
 		$ret = flock($this->fplock[md5($filename)], LOCK_UN);
174 174
 		fclose($this->fplock[md5($filename)]);
175 175
 		unset($this->fplock[md5($filename)]);
176
-		if (! $ret) {
176
+		if (!$ret) {
177 177
 			$this->debug("Not able to release lock for $filename");
178 178
 		}
179 179
 		return $ret;
Please login to merge, or discard this patch.
main/inc/lib/link.lib.php 1 patch
Spacing   +108 added lines, -108 removed lines patch added patch discarded remove patch
@@ -77,11 +77,11 @@  discard block
 block discarded – undo
77 77
         $params['session_id'] = api_get_session_id();
78 78
         $params['category_id'] = isset($params['category_id']) ? $params['category_id'] : 0;
79 79
 
80
-        $sql =  "SELECT MAX(display_order)
80
+        $sql = "SELECT MAX(display_order)
81 81
                 FROM  ".$this->table."
82 82
                 WHERE
83 83
                     c_id = $courseId AND
84
-                    category_id = '" . intval($params['category_id'])."'";
84
+                    category_id = '".intval($params['category_id'])."'";
85 85
         $result = Database:: query($sql);
86 86
         list ($orderMax) = Database:: fetch_row($result);
87 87
         $order = $orderMax + 1;
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
 
186 186
             // We ensure URL to be absolute.
187 187
             if (strpos($urllink, '://') === false) {
188
-                $urllink = 'http://' . $urllink;
188
+                $urllink = 'http://'.$urllink;
189 189
             }
190 190
 
191 191
             // If the title is empty, we use the URL as title.
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
                     'c_id' => $course_id,
208 208
                     'url' => $urllink,
209 209
                     'title' => $title,
210
-                    'description' => $description ,
210
+                    'description' => $description,
211 211
                     'category_id' => $selectcategory,
212 212
                     'on_homepage' => $onhomepage,
213 213
                     'target' => $target,
@@ -220,9 +220,9 @@  discard block
 block discarded – undo
220 220
                 if ((api_get_setting('search_enabled') == 'true') &&
221 221
                     $link_id && extension_loaded('xapian')
222 222
                 ) {
223
-                    require_once api_get_path(LIBRARY_PATH) . 'search/ChamiloIndexer.class.php';
224
-                    require_once api_get_path(LIBRARY_PATH) . 'search/IndexableChunk.class.php';
225
-                    require_once api_get_path(LIBRARY_PATH) . 'specific_fields_manager.lib.php';
223
+                    require_once api_get_path(LIBRARY_PATH).'search/ChamiloIndexer.class.php';
224
+                    require_once api_get_path(LIBRARY_PATH).'search/IndexableChunk.class.php';
225
+                    require_once api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php';
226 226
 
227 227
                     $course_int_id = $_course['real_id'];
228 228
                     $courseCode = $_course['code'];
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
                         if (isset ($_REQUEST[$specific_field['code']])) {
236 236
                             $sterms = trim($_REQUEST[$specific_field['code']]);
237 237
                             if (!empty ($sterms)) {
238
-                                $all_specific_terms .= ' ' . $sterms;
238
+                                $all_specific_terms .= ' '.$sterms;
239 239
                                 $sterms = explode(',', $sterms);
240 240
                                 foreach ($sterms as $sterm) {
241 241
                                     $ic_slide->addTerm(
@@ -262,12 +262,12 @@  discard block
 block discarded – undo
262 262
                         SE_COURSE_ID => $courseCode,
263 263
                         SE_TOOL_ID => TOOL_LINK,
264 264
                         SE_DATA => array(
265
-                            'link_id' => (int)$link_id
265
+                            'link_id' => (int) $link_id
266 266
                         ),
267
-                        SE_USER => (int)api_get_user_id(),
267
+                        SE_USER => (int) api_get_user_id(),
268 268
                     );
269 269
                     $ic_slide->xapian_data = serialize($xapian_data);
270
-                    $description = $all_specific_terms . ' ' . $description;
270
+                    $description = $all_specific_terms.' '.$description;
271 271
                     $ic_slide->addValue('content', $description);
272 272
 
273 273
                     // Add category name if set.
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
                         $sql_cat = sprintf(
280 280
                             $sql_cat,
281 281
                             $table_link_category,
282
-                            (int)$selectcategory,
282
+                            (int) $selectcategory,
283 283
                             $course_int_id
284 284
                         );
285 285
                         $result = Database:: query($sql_cat);
@@ -399,7 +399,7 @@  discard block
 block discarded – undo
399 399
                 // This will make a restore function possible for the platform administrator.
400 400
 
401 401
                 $sql = "UPDATE $tbl_link SET on_homepage='0'
402
-                        WHERE c_id = $course_id AND id='" . $id . "'";
402
+                        WHERE c_id = $course_id AND id='".$id."'";
403 403
                 Database:: query($sql);
404 404
 
405 405
                 api_item_property_update(
@@ -415,12 +415,12 @@  discard block
 block discarded – undo
415 415
                 break;
416 416
             case 'category':
417 417
                 // First we delete the category itself and afterwards all the links of this category.
418
-                $sql = "DELETE FROM " . $tbl_categories . "
419
-                        WHERE c_id = $course_id AND id='" . $id . "'";
418
+                $sql = "DELETE FROM ".$tbl_categories."
419
+                        WHERE c_id = $course_id AND id='".$id."'";
420 420
                 Database:: query($sql);
421 421
 
422
-                $sql = "DELETE FROM " . $tbl_link . "
423
-                        WHERE c_id = $course_id AND category_id='" . $id . "'";
422
+                $sql = "DELETE FROM ".$tbl_link."
423
+                        WHERE c_id = $course_id AND category_id='".$id."'";
424 424
                 Database:: query($sql);
425 425
 
426 426
                 api_item_property_update(
@@ -459,16 +459,16 @@  discard block
 block discarded – undo
459 459
                 $row = Database:: fetch_array($res);
460 460
                 require_once api_get_path(
461 461
                         LIBRARY_PATH
462
-                    ) . 'search/ChamiloIndexer.class.php';
462
+                    ).'search/ChamiloIndexer.class.php';
463 463
                 $di = new ChamiloIndexer();
464
-                $di->remove_document((int)$row['search_did']);
464
+                $di->remove_document((int) $row['search_did']);
465 465
             }
466 466
             $sql = 'DELETE FROM %s WHERE course_code=\'%s\' AND tool_id=\'%s\' AND ref_id_high_level=%s LIMIT 1';
467 467
             $sql = sprintf($sql, $tbl_se_ref, $course_id, TOOL_LINK, $link_id);
468 468
             Database:: query($sql);
469 469
 
470 470
             // Remove terms from db.
471
-            require_once api_get_path(LIBRARY_PATH) . 'specific_fields_manager.lib.php';
471
+            require_once api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php';
472 472
             delete_all_values_for_item($course_id, TOOL_DOCUMENT, $link_id);
473 473
         }
474 474
     }
@@ -484,8 +484,8 @@  discard block
 block discarded – undo
484 484
     {
485 485
         $tbl_link = Database:: get_course_table(TABLE_LINK);
486 486
         $course_id = api_get_course_int_id();
487
-        $sql = "SELECT * FROM " . $tbl_link . "
488
-                WHERE c_id = $course_id AND id='" . intval($id) . "' ";
487
+        $sql = "SELECT * FROM ".$tbl_link."
488
+                WHERE c_id = $course_id AND id='".intval($id)."' ";
489 489
         $result = Database::query($sql);
490 490
         $data = array();
491 491
         if (Database::num_rows($result)) {
@@ -514,7 +514,7 @@  discard block
 block discarded – undo
514 514
 
515 515
         // We ensure URL to be absolute.
516 516
         if (strpos($values['url'], '://') === false) {
517
-            $values['url'] = 'http://' . $_POST['url'];
517
+            $values['url'] = 'http://'.$_POST['url'];
518 518
         }
519 519
 
520 520
         // If the title is empty, we use the URL as title.
@@ -532,18 +532,18 @@  discard block
 block discarded – undo
532 532
         }
533 533
 
534 534
         // Finding the old category_id.
535
-        $sql = "SELECT * FROM " . $tbl_link . "
536
-                WHERE c_id = $course_id AND id='" . $id . "'";
535
+        $sql = "SELECT * FROM ".$tbl_link."
536
+                WHERE c_id = $course_id AND id='".$id."'";
537 537
         $result = Database:: query($sql);
538 538
         $row = Database:: fetch_array($result);
539 539
         $category_id = $row['category_id'];
540 540
 
541 541
         if ($category_id != $values['category_id']) {
542 542
             $sql = "SELECT MAX(display_order)
543
-                    FROM " . $tbl_link . "
543
+                    FROM " . $tbl_link."
544 544
                     WHERE
545 545
                         c_id = $course_id AND
546
-                        category_id='" . intval($values['category_id']) . "'";
546
+                        category_id='".intval($values['category_id'])."'";
547 547
             $result = Database:: query($sql);
548 548
             list ($max_display_order) = Database:: fetch_row($result);
549 549
             $max_display_order++;
@@ -560,7 +560,7 @@  discard block
 block discarded – undo
560 560
             'target' => $values['target'],
561 561
             'category_id' => $values['category_id'],
562 562
         ];
563
-        Database::update($tbl_link, $params, ['c_id = ? AND id = ?' => [$course_id, $id] ]);
563
+        Database::update($tbl_link, $params, ['c_id = ? AND id = ?' => [$course_id, $id]]);
564 564
 
565 565
         // Update search enchine and its values table if enabled.
566 566
         if (api_get_setting('search_enabled') == 'true') {
@@ -613,7 +613,7 @@  discard block
 block discarded – undo
613 613
                             $_REQUEST[$specific_field['code']]
614 614
                         );
615 615
                         if (!empty ($sterms)) {
616
-                            $all_specific_terms .= ' ' . $sterms;
616
+                            $all_specific_terms .= ' '.$sterms;
617 617
                             $sterms = explode(',', $sterms);
618 618
                             foreach ($sterms as $sterm) {
619 619
                                 $ic_slide->addTerm(
@@ -640,13 +640,13 @@  discard block
 block discarded – undo
640 640
                     SE_COURSE_ID => $course_id,
641 641
                     SE_TOOL_ID => TOOL_LINK,
642 642
                     SE_DATA => array(
643
-                        'link_id' => (int)$id
643
+                        'link_id' => (int) $id
644 644
                     ),
645
-                    SE_USER => (int)api_get_user_id(),
645
+                    SE_USER => (int) api_get_user_id(),
646 646
 
647 647
                 );
648 648
                 $ic_slide->xapian_data = serialize($xapian_data);
649
-                $link_description = $all_specific_terms . ' ' . $link_description;
649
+                $link_description = $all_specific_terms.' '.$link_description;
650 650
                 $ic_slide->addValue('content', $link_description);
651 651
 
652 652
                 // Add category name if set.
@@ -674,7 +674,7 @@  discard block
 block discarded – undo
674 674
                 $di = new ChamiloIndexer();
675 675
                 isset ($_POST['language']) ? $lang = Database:: escape_string($_POST['language']) : $lang = 'english';
676 676
                 $di->connectDb(null, null, $lang);
677
-                $di->remove_document((int)$se_ref['search_did']);
677
+                $di->remove_document((int) $se_ref['search_did']);
678 678
                 $di->addChunk($ic_slide);
679 679
 
680 680
                 // Index and return search engine document id.
@@ -791,7 +791,7 @@  discard block
 block discarded – undo
791 791
         $sql = "SELECT *, linkcat.id
792 792
                 FROM $tblLinkCategory linkcat
793 793
                 WHERE
794
-                    linkcat.c_id = " . $courseId . "
794
+                    linkcat.c_id = ".$courseId."
795 795
                     $sessionCondition
796 796
                 ORDER BY linkcat.display_order DESC";
797 797
 
@@ -803,10 +803,10 @@  discard block
 block discarded – undo
803 803
                 INNER JOIN $tblItemProperty itemproperties
804 804
                 ON (linkcat.id = itemproperties.ref AND linkcat.c_id = itemproperties.c_id)
805 805
                 WHERE
806
-                    itemproperties.tool = '" . TOOL_LINK_CATEGORY . "' AND
806
+                    itemproperties.tool = '".TOOL_LINK_CATEGORY."' AND
807 807
                     (itemproperties.visibility = '0' OR itemproperties.visibility = '1')
808 808
                     $sessionCondition AND
809
-                    linkcat.c_id = " . $courseId . "
809
+                    linkcat.c_id = ".$courseId."
810 810
                 ORDER BY linkcat.display_order DESC";
811 811
 
812 812
         $result = Database::query($sql);
@@ -829,10 +829,10 @@  discard block
 block discarded – undo
829 829
                 INNER JOIN $tblItemProperty itemproperties
830 830
                 ON (linkcat.id = itemproperties.ref AND linkcat.c_id = itemproperties.c_id)
831 831
                 WHERE
832
-                    itemproperties.tool = '" . TOOL_LINK_CATEGORY . "' AND
832
+                    itemproperties.tool = '".TOOL_LINK_CATEGORY."' AND
833 833
                     (itemproperties.visibility = '0' OR itemproperties.visibility = '1')
834 834
                     $sessionCondition AND
835
-                    linkcat.c_id = " . $courseId . "
835
+                    linkcat.c_id = ".$courseId."
836 836
                 ORDER BY linkcat.display_order DESC
837 837
                 ";
838 838
         $result = Database::query($sql);
@@ -864,12 +864,12 @@  discard block
 block discarded – undo
864 864
                 INNER JOIN $TABLE_ITEM_PROPERTY itemproperties
865 865
                 ON (link.id=itemproperties.ref AND link.c_id = itemproperties.c_id )
866 866
                 WHERE
867
-                    itemproperties.tool='" . TOOL_LINK . "' AND
868
-                    link.category_id='" . $catid . "' AND
867
+                    itemproperties.tool='".TOOL_LINK."' AND
868
+                    link.category_id='" . $catid."' AND
869 869
                     (itemproperties.visibility='0' OR itemproperties.visibility='1')
870 870
                     $condition_session AND
871
-                    link.c_id = " . $course_id . " AND
872
-                    itemproperties.c_id = " . $course_id . "
871
+                    link.c_id = ".$course_id." AND
872
+                    itemproperties.c_id = " . $course_id."
873 873
                 ORDER BY link.display_order DESC";
874 874
         $result = Database:: query($sql);
875 875
         $numberoflinks = Database:: num_rows($result);
@@ -892,14 +892,14 @@  discard block
 block discarded – undo
892 892
                             'retweet',
893 893
                             'default btn-sm',
894 894
                             array(
895
-                                'onclick' => "check_url('" . $myrow['id'] . "', '" . addslashes($myrow['url']) . "');",
895
+                                'onclick' => "check_url('".$myrow['id']."', '".addslashes($myrow['url'])."');",
896 896
                                 'title' => get_lang('CheckURL')
897 897
                                 )
898 898
                             );
899 899
                     $link_validator .= Display::span(
900 900
                         '',
901 901
                         array(
902
-                            'id' => 'url_id_' . $myrow['id'],
902
+                            'id' => 'url_id_'.$myrow['id'],
903 903
                             'class' => 'check-link'
904 904
                             )
905 905
                     );
@@ -909,10 +909,10 @@  discard block
 block discarded – undo
909 909
                 if (api_is_allowed_to_edit(null, true)) {
910 910
 
911 911
                     if ($session_id == $myrow['session_id']) {
912
-                        $url = api_get_self() . '?' . api_get_cidreq() .
913
-                            '&action=editlink&category=' . (!empty ($category) ? $category : '') .
914
-                            '&id=' . $myrow['id'] .
915
-                            '&category_id=' . $myrow['id'];
912
+                        $url = api_get_self().'?'.api_get_cidreq().
913
+                            '&action=editlink&category='.(!empty ($category) ? $category : '').
914
+                            '&id='.$myrow['id'].
915
+                            '&category_id='.$myrow['id'];
916 916
                         $title = get_lang('Edit');
917 917
                         $toolbar .= Display::toolbarButton(
918 918
                             '',
@@ -940,10 +940,10 @@  discard block
 block discarded – undo
940 940
                         }*/
941 941
 
942 942
                         if ($myrow['visibility'] == '1') {
943
-                            $url .= 'link.php?' . api_get_cidreq() .
944
-                                '&sec_token=' . $token .
945
-                                '&action=invisible&id=' . $myrow['id'] .
946
-                                '&scope=link&category_id=' . $myrow['category_id'];
943
+                            $url .= 'link.php?'.api_get_cidreq().
944
+                                '&sec_token='.$token.
945
+                                '&action=invisible&id='.$myrow['id'].
946
+                                '&scope=link&category_id='.$myrow['category_id'];
947 947
                             $title = get_lang('MakeInvisible');
948 948
                             $toolbar .= Display::toolbarButton(
949 949
                                 '',
@@ -957,7 +957,7 @@  discard block
 block discarded – undo
957 957
 
958 958
                         }
959 959
                         if ($myrow['visibility'] == '0') {
960
-                            $url .= 'link.php?' . api_get_cidreq() .'&sec_token=' . $token .'&action=visible&id=' . $myrow['id'] .'&scope=link&category_id=' . $myrow['category_id'];
960
+                            $url .= 'link.php?'.api_get_cidreq().'&sec_token='.$token.'&action=visible&id='.$myrow['id'].'&scope=link&category_id='.$myrow['category_id'];
961 961
                             $title = get_lang('MakeVisible');
962 962
                             $toolbar .= Display::toolbarButton(
963 963
                                 '',
@@ -970,8 +970,8 @@  discard block
 block discarded – undo
970 970
                             );
971 971
                         }
972 972
 
973
-                        $url .= api_get_self() . '?' . api_get_cidreq() .'&sec_token=' . $token .'&action=deletelink&id=' . $myrow['id'] .'&category_id=' . $myrow['category_id'];
974
-                        $event = "javascript: if(!confirm('" . get_lang('LinkDelconfirm') . "'))return false;";
973
+                        $url .= api_get_self().'?'.api_get_cidreq().'&sec_token='.$token.'&action=deletelink&id='.$myrow['id'].'&category_id='.$myrow['category_id'];
974
+                        $event = "javascript: if(!confirm('".get_lang('LinkDelconfirm')."'))return false;";
975 975
                         $title = get_lang('Delete');
976 976
 
977 977
                         $toolbar .= Display::toolbarButton(
@@ -1012,7 +1012,7 @@  discard block
 block discarded – undo
1012 1012
                     $content .= '<div class="pull-right"><div class="btn-group">'.$toolbar.'</div></div>';
1013 1013
                     $content .= '<h4 class="list-group-item-heading">';
1014 1014
                     $content .= $iconLink;
1015
-                    $url =  'link_goto.php?' . api_get_cidreq() .'&link_id=' . $myrow['id'] .'&link_url=' . urlencode($myrow['url']);
1015
+                    $url = 'link_goto.php?'.api_get_cidreq().'&link_id='.$myrow['id'].'&link_url='.urlencode($myrow['url']);
1016 1016
                     $content .= Display::tag(
1017 1017
                             'a',
1018 1018
                             Security:: remove_XSS($myrow['title']),
@@ -1025,7 +1025,7 @@  discard block
 block discarded – undo
1025 1025
                     $content .= $session_img;
1026 1026
                     $content .= '</h4>';
1027 1027
 
1028
-                    $content .= '<p class="list-group-item-text">' . $myrow['description'] . '</p>';
1028
+                    $content .= '<p class="list-group-item-text">'.$myrow['description'].'</p>';
1029 1029
                     $content .= '</div>';
1030 1030
                 } else {
1031 1031
                     if (api_is_allowed_to_edit(null, true)) {
@@ -1033,7 +1033,7 @@  discard block
 block discarded – undo
1033 1033
                         $content .= '<div class="pull-right"><div class="btn-group">'.$toolbar.'</div></div>';
1034 1034
                         $content .= '<h4 class="list-group-item-heading">';
1035 1035
                         $content .= $iconLink;
1036
-                        $url = 'link_goto.php?' . api_get_cidreq() .'&link_id=' . $myrow['id'] . "&link_url=" . urlencode($myrow['url']);
1036
+                        $url = 'link_goto.php?'.api_get_cidreq().'&link_id='.$myrow['id']."&link_url=".urlencode($myrow['url']);
1037 1037
                         $content .= Display::tag(
1038 1038
                                 'a',
1039 1039
                                 Security:: remove_XSS($myrow['title']),
@@ -1046,7 +1046,7 @@  discard block
 block discarded – undo
1046 1046
                         $content .= $link_validator;
1047 1047
                         $content .= $session_img;
1048 1048
                         $content .= '</h4>';
1049
-                        $content .= '<p class="list-group-item-text">' . $myrow['description'] . '</p>';
1049
+                        $content .= '<p class="list-group-item-text">'.$myrow['description'].'</p>';
1050 1050
                         $content .= '</div>';
1051 1051
                     }
1052 1052
                 }
@@ -1068,58 +1068,58 @@  discard block
 block discarded – undo
1068 1068
     {
1069 1069
         $categoryId = $category['id'];
1070 1070
         $token = null;
1071
-        $tools = '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&sec_token=' . $token . '&action=editcategory&id=' . $categoryId . '&category_id=' . $categoryId . '" title=' . get_lang('Modify') . '">' .
1071
+        $tools = '<a href="'.api_get_self().'?'.api_get_cidreq().'&sec_token='.$token.'&action=editcategory&id='.$categoryId.'&category_id='.$categoryId.'" title='.get_lang('Modify').'">'.
1072 1072
             Display:: return_icon(
1073 1073
                 'edit.png',
1074 1074
                 get_lang('Modify'),
1075 1075
                 array(),
1076 1076
                 ICON_SIZE_SMALL
1077
-            ) . '</a>';
1077
+            ).'</a>';
1078 1078
 
1079 1079
         // DISPLAY MOVE UP COMMAND only if it is not the top link.
1080 1080
         if ($currentCategory != 0) {
1081
-            $tools .= '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&sec_token=' . $token . '&action=up&up='.$categoryId.'&category_id='.$categoryId.'" title="'.get_lang('Up').'">'.
1081
+            $tools .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&sec_token='.$token.'&action=up&up='.$categoryId.'&category_id='.$categoryId.'" title="'.get_lang('Up').'">'.
1082 1082
                 Display:: return_icon(
1083 1083
                     'up.png',
1084 1084
                     get_lang('Up'),
1085 1085
                     array(),
1086 1086
                     ICON_SIZE_SMALL
1087
-                ) . '</a>';
1087
+                ).'</a>';
1088 1088
         } else {
1089 1089
             $tools .= Display:: return_icon(
1090 1090
                 'up_na.png',
1091 1091
                 get_lang('Up'),
1092 1092
                 array(),
1093 1093
                 ICON_SIZE_SMALL
1094
-            ) . '</a>';
1094
+            ).'</a>';
1095 1095
         }
1096 1096
 
1097 1097
         // DISPLAY MOVE DOWN COMMAND only if it is not the bottom link.
1098
-        if ($currentCategory < $countCategories-1) {
1099
-            $tools .= '<a href="' . api_get_self() . '?' . api_get_cidreq() .'&sec_token=' . $token .'&action=down&down=' . $categoryId .'&category_id=' . $categoryId . '">'.
1098
+        if ($currentCategory < $countCategories - 1) {
1099
+            $tools .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&sec_token='.$token.'&action=down&down='.$categoryId.'&category_id='.$categoryId.'">'.
1100 1100
                 Display:: return_icon(
1101 1101
                     'down.png',
1102 1102
                     get_lang('Down'),
1103 1103
                     array(),
1104 1104
                     ICON_SIZE_SMALL
1105
-                ) . '</a>';
1105
+                ).'</a>';
1106 1106
         } else {
1107 1107
             $tools .= Display:: return_icon(
1108 1108
                     'down_na.png',
1109 1109
                     get_lang('Down'),
1110 1110
                     array(),
1111 1111
                     ICON_SIZE_SMALL
1112
-                ) . '</a>';
1112
+                ).'</a>';
1113 1113
         }
1114 1114
 
1115
-        $tools .= '<a href="' . api_get_self() . '?' . api_get_cidreq() .'&sec_token=' . $token .'&action=deletecategory&id='.$categoryId.            "&category_id=$categoryId\"
1116
-            onclick=\"javascript: if(!confirm('" . get_lang('CategoryDelconfirm') . "')) return false;\">".
1115
+        $tools .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&sec_token='.$token.'&action=deletecategory&id='.$categoryId."&category_id=$categoryId\"
1116
+            onclick=\"javascript: if(!confirm('".get_lang('CategoryDelconfirm')."')) return false;\">".
1117 1117
             Display:: return_icon(
1118 1118
                 'delete.png',
1119 1119
                 get_lang('Delete'),
1120 1120
                 array(),
1121 1121
                 ICON_SIZE_SMALL
1122
-            ) . '</a>';
1122
+            ).'</a>';
1123 1123
 
1124 1124
         return $tools;
1125 1125
     }
@@ -1166,7 +1166,7 @@  discard block
 block discarded – undo
1166 1166
             $movetable = $tbl_link;
1167 1167
             // Getting the category of the link.
1168 1168
             if (!empty ($thiscatlinkId)) {
1169
-                $sql = "SELECT category_id FROM " . $movetable . "
1169
+                $sql = "SELECT category_id FROM ".$movetable."
1170 1170
                         WHERE c_id = $courseId AND id='$thiscatlinkId'";
1171 1171
                 $result = Database:: query($sql);
1172 1172
                 $catid = Database:: fetch_array($result);
@@ -1186,7 +1186,7 @@  discard block
 block discarded – undo
1186 1186
                         ORDER BY display_order $sortDirection";
1187 1187
             } else {
1188 1188
                 $sql = "SELECT id, display_order FROM  $movetable
1189
-                        WHERE c_id = $courseId AND category_id='" . $catid[0] . "'
1189
+                        WHERE c_id = $courseId AND category_id='".$catid[0]."'
1190 1190
                         ORDER BY display_order $sortDirection";
1191 1191
             }
1192 1192
             $linkresult = Database:: query($sql);
@@ -1200,12 +1200,12 @@  discard block
 block discarded – undo
1200 1200
                     $nextlinkOrder = $sortrow['display_order'];
1201 1201
 
1202 1202
                     Database:: query(
1203
-                        "UPDATE " . $movetable . "
1203
+                        "UPDATE ".$movetable."
1204 1204
                         SET display_order = '$nextlinkOrder'
1205 1205
                         WHERE c_id = $courseId  AND id =  '$thiscatlinkId'"
1206 1206
                     );
1207 1207
                     Database:: query(
1208
-                        "UPDATE " . $movetable . "
1208
+                        "UPDATE ".$movetable."
1209 1209
                         SET display_order = '$thislinkOrder'
1210 1210
                         WHERE c_id = $courseId  AND id =  '$nextlinkId'"
1211 1211
                     );
@@ -1233,10 +1233,10 @@  discard block
 block discarded – undo
1233 1233
         $course_id = api_get_course_int_id();
1234 1234
 
1235 1235
         $result = Database:: query(
1236
-            "SELECT id FROM " . $tbl_categories . "
1237
-            WHERE c_id = $course_id AND category_title='" . Database::escape_string(
1236
+            "SELECT id FROM ".$tbl_categories."
1237
+            WHERE c_id = $course_id AND category_title='".Database::escape_string(
1238 1238
                 $catname
1239
-            ) . "'"
1239
+            )."'"
1240 1240
         );
1241 1241
         if (Database:: num_rows($result) >= 1 && ($row = Database:: fetch_array(
1242 1242
                 $result
@@ -1246,7 +1246,7 @@  discard block
 block discarded – undo
1246 1246
         }
1247 1247
 
1248 1248
         $result = Database:: query(
1249
-            "SELECT MAX(display_order) FROM " . $tbl_categories . " WHERE c_id = $course_id "
1249
+            "SELECT MAX(display_order) FROM ".$tbl_categories." WHERE c_id = $course_id "
1250 1250
         );
1251 1251
         list ($max_order) = Database:: fetch_row($result);
1252 1252
 
@@ -1273,12 +1273,12 @@  discard block
 block discarded – undo
1273 1273
         $tbl_link = Database:: get_course_table(TABLE_LINK);
1274 1274
         $course_id = api_get_course_int_id();
1275 1275
 
1276
-        $urleq = "url='" . Database:: escape_string($url) . "'";
1277
-        $cateq = "category_id=" . intval($cat);
1276
+        $urleq = "url='".Database:: escape_string($url)."'";
1277
+        $cateq = "category_id=".intval($cat);
1278 1278
 
1279 1279
         $result = Database:: query("
1280 1280
             SELECT id FROM $tbl_link
1281
-            WHERE c_id = $course_id AND " . $urleq . ' AND ' . $cateq
1281
+            WHERE c_id = $course_id AND ".$urleq.' AND '.$cateq
1282 1282
         );
1283 1283
 
1284 1284
         if (Database:: num_rows($result) >= 1 && ($row = Database:: fetch_array(
@@ -1286,14 +1286,14 @@  discard block
 block discarded – undo
1286 1286
             ))
1287 1287
         ) {
1288 1288
             Database:: query(
1289
-                "UPDATE $tbl_link set title='" . Database:: escape_string(
1289
+                "UPDATE $tbl_link set title='".Database:: escape_string(
1290 1290
                     $title
1291
-                ) . "', description='" . Database:: escape_string(
1291
+                )."', description='".Database:: escape_string(
1292 1292
                     $description
1293
-                ) . "'
1294
-                WHERE c_id = $course_id AND  id='" . Database:: escape_string(
1293
+                )."'
1294
+                WHERE c_id = $course_id AND  id='".Database:: escape_string(
1295 1295
                     $row['id']
1296
-                ) . "'"
1296
+                )."'"
1297 1297
             );
1298 1298
 
1299 1299
             $ipu = 'LinkUpdated';
@@ -1302,18 +1302,18 @@  discard block
 block discarded – undo
1302 1302
             // Add new link
1303 1303
             $result = Database:: query(
1304 1304
                 "SELECT MAX(display_order) FROM  $tbl_link
1305
-                WHERE c_id = $course_id AND category_id='" . intval($cat) . "'"
1305
+                WHERE c_id = $course_id AND category_id='".intval($cat)."'"
1306 1306
             );
1307 1307
             list ($max_order) = Database:: fetch_row($result);
1308 1308
 
1309 1309
             Database:: query(
1310 1310
                 "INSERT INTO $tbl_link (c_id, url, title, description, category_id, display_order, on_homepage)
1311
-                VALUES (" . api_get_course_int_id() . ",
1312
-                '" . Database:: escape_string($url) . "',
1313
-                '" . Database:: escape_string($title) . "',
1314
-                '" . Database:: escape_string($description) . "',
1315
-                '" . intval($cat) . "','" . (intval($max_order) + 1) . "',
1316
-                '" . intval($on_homepage) .
1311
+                VALUES (".api_get_course_int_id().",
1312
+                '" . Database:: escape_string($url)."',
1313
+                '" . Database:: escape_string($title)."',
1314
+                '" . Database:: escape_string($description)."',
1315
+                '" . intval($cat)."','".(intval($max_order) + 1)."',
1316
+                '" . intval($on_homepage).
1317 1317
                 "')"
1318 1318
             );
1319 1319
 
@@ -1391,30 +1391,30 @@  discard block
 block discarded – undo
1391 1391
                     )
1392 1392
                 ) { // possibly in <...>
1393 1393
                     if (($kwlist = trim($regs[1])) != '') {
1394
-                        $kw = '<i kw="' . htmlspecialchars($kwlist) . '">';
1394
+                        $kw = '<i kw="'.htmlspecialchars($kwlist).'">';
1395 1395
                     } else {
1396 1396
                         $kw = '';
1397 1397
                     }
1398 1398
                     // i.e. assume only one of the $hide_fields will be present
1399 1399
                     // and if found, hide the value as expando property of an <i> tag
1400 1400
                 } elseif (trim($value)) {
1401
-                    $d .= ', ' . $key . ':' . $value;
1401
+                    $d .= ', '.$key.':'.$value;
1402 1402
                 }
1403 1403
             }
1404 1404
         }
1405 1405
         if (!empty($d)) {
1406
-            $d = substr($d, 2) . ' - ';
1406
+            $d = substr($d, 2).' - ';
1407 1407
         }
1408 1408
 
1409 1409
         return Link::put_link(
1410 1410
             $url,
1411 1411
             $cat,
1412 1412
             $title,
1413
-            $kw . ereg_replace(
1413
+            $kw.ereg_replace(
1414 1414
                 '\[((/?(b|big|i|small|sub|sup|u))|br/)\]',
1415 1415
                 '<\\1>',
1416
-                htmlspecialchars($d . $linkdata['description'])
1417
-            ) . ($kw ? '</i>' : ''),
1416
+                htmlspecialchars($d.$linkdata['description'])
1417
+            ).($kw ? '</i>' : ''),
1418 1418
             $linkdata['on_homepage'] ? '1' : '0',
1419 1419
             $linkdata['hidden'] ? '1' : '0'
1420 1420
         );
@@ -1535,19 +1535,19 @@  discard block
 block discarded – undo
1535 1535
         echo '<div class="actions">';
1536 1536
         if (api_is_allowed_to_edit(null, true)) {
1537 1537
             echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&action=addlink&category_id='.$categoryId.'">'.
1538
-                Display::return_icon('new_link.png', get_lang('LinkAdd'),'',ICON_SIZE_MEDIUM).'</a>';
1538
+                Display::return_icon('new_link.png', get_lang('LinkAdd'), '', ICON_SIZE_MEDIUM).'</a>';
1539 1539
             echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&action=addcategory&category_id='.$categoryId.'">'.
1540
-                Display::return_icon('new_folder.png', get_lang('CategoryAdd'),'',ICON_SIZE_MEDIUM).'</a>';
1540
+                Display::return_icon('new_folder.png', get_lang('CategoryAdd'), '', ICON_SIZE_MEDIUM).'</a>';
1541 1541
         }
1542 1542
 
1543 1543
         $categories = Link::getLinkCategories($course_id, $session_id);
1544 1544
         $count = count($categories);
1545 1545
         if (!empty($count)) {
1546 1546
             echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&action=list&show=none">';
1547
-            echo Display::return_icon('forum_listview.png', get_lang('FlatView'), '', ICON_SIZE_MEDIUM) . ' </a>';
1547
+            echo Display::return_icon('forum_listview.png', get_lang('FlatView'), '', ICON_SIZE_MEDIUM).' </a>';
1548 1548
 
1549 1549
             echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&action=list&show=all">';
1550
-            echo Display::return_icon('forum_nestedview.png', get_lang('NestedView'), '', ICON_SIZE_MEDIUM) . '</a>';
1550
+            echo Display::return_icon('forum_nestedview.png', get_lang('NestedView'), '', ICON_SIZE_MEDIUM).'</a>';
1551 1551
         }
1552 1552
         echo '</div>';
1553 1553
 
@@ -1579,12 +1579,12 @@  discard block
 block discarded – undo
1579 1579
             $strVisibility = '';
1580 1580
             $visibilityClass = null;
1581 1581
             if ($myrow['visibility'] == '1') {
1582
-                $strVisibility =  '<a href="link.php?' . api_get_cidreq() .  '&sec_token='.$token.'&action=invisible&id=' . $myrow['id'] . '&scope=' . TOOL_LINK_CATEGORY . '" title="' . get_lang('Hide') . '">' .
1583
-                    Display :: return_icon('visible.png', get_lang('Hide'), array (), ICON_SIZE_SMALL) . '</a>';
1582
+                $strVisibility = '<a href="link.php?'.api_get_cidreq().'&sec_token='.$token.'&action=invisible&id='.$myrow['id'].'&scope='.TOOL_LINK_CATEGORY.'" title="'.get_lang('Hide').'">'.
1583
+                    Display :: return_icon('visible.png', get_lang('Hide'), array(), ICON_SIZE_SMALL).'</a>';
1584 1584
             } elseif ($myrow['visibility'] == '0') {
1585 1585
                 $visibilityClass = 'invisible';
1586
-                $strVisibility =  ' <a href="link.php?' . api_get_cidreq() .  '&sec_token='.$token.'&action=visible&id=' . $myrow['id'] . '&scope=' . TOOL_LINK_CATEGORY . '" title="' . get_lang('Show') . '">' .
1587
-                    Display :: return_icon('invisible.png', get_lang('Show'), array (), ICON_SIZE_SMALL) . '</a>';
1586
+                $strVisibility = ' <a href="link.php?'.api_get_cidreq().'&sec_token='.$token.'&action=visible&id='.$myrow['id'].'&scope='.TOOL_LINK_CATEGORY.'" title="'.get_lang('Show').'">'.
1587
+                    Display :: return_icon('invisible.png', get_lang('Show'), array(), ICON_SIZE_SMALL).'</a>';
1588 1588
             }
1589 1589
 
1590 1590
             $header = '';
Please login to merge, or discard this patch.
main/inc/lib/extra_field_option.lib.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
 
217 217
                         foreach ($sub_options as $sub_option) {
218 218
                             if (!empty($sub_option)) {
219
-                                $new_params  = array(
219
+                                $new_params = array(
220 220
                                     'field_id' => $field_id,
221 221
                                     'option_value' => $sub_id,
222 222
                                     'display_text' => $sub_option,
@@ -552,7 +552,7 @@  discard block
 block discarded – undo
552 552
         echo '<div class="actions">';
553 553
         $field_id = isset($_REQUEST['field_id']) ? intval($_REQUEST['field_id']) : null;
554 554
         echo '<a href="'.api_get_self().'?action=add&type='.$this->type.'&field_id='.$field_id.'">'.
555
-                Display::return_icon('add_user_fields.png', get_lang('Add'), '', ICON_SIZE_MEDIUM ).'</a>';
555
+                Display::return_icon('add_user_fields.png', get_lang('Add'), '', ICON_SIZE_MEDIUM).'</a>';
556 556
         echo '</div>';
557 557
         echo Display::grid_html('extra_field_options');
558 558
     }
Please login to merge, or discard this patch.
main/inc/lib/add_many_session_to_category_functions.lib.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -21,12 +21,12 @@  discard block
 block discarded – undo
21 21
      * @assert () !== ''
22 22
      * @assert ('abc','single') !== ''
23 23
      */
24
-    function search_courses($needle,$type)
24
+    function search_courses($needle, $type)
25 25
     {
26 26
         $tbl_session = Database :: get_main_table(TABLE_MAIN_SESSION);
27 27
 		$xajax_response = new xajaxResponse();
28 28
 		$return = '';
29
-		if(!empty($needle) && !empty($type)) {
29
+		if (!empty($needle) && !empty($type)) {
30 30
 			// xajax send utf8 datas... datas in db can be non-utf8 datas
31 31
 			$charset = api_get_system_encoding();
32 32
 			$needle = api_convert_encoding($needle, $charset, 'utf-8');
@@ -38,12 +38,12 @@  discard block
 block discarded – undo
38 38
 			$course_list = array();
39 39
 
40 40
 			$return .= '<select id="origin" name="NoSessionCategoryList[]" multiple="multiple" size="20" style="width:340px;">';
41
-			while($course = Database :: fetch_array($rs)) {
41
+			while ($course = Database :: fetch_array($rs)) {
42 42
 				$course_list[] = $course['id'];
43
-				$return .= '<option value="'.$course['id'].'" title="'.htmlspecialchars($course['name'],ENT_QUOTES).'">'.$course['name'].'</option>';
43
+				$return .= '<option value="'.$course['id'].'" title="'.htmlspecialchars($course['name'], ENT_QUOTES).'">'.$course['name'].'</option>';
44 44
 			}
45 45
 			$return .= '</select>';
46
-			$xajax_response -> addAssign('ajax_list_courses_multiple','innerHTML',api_utf8_encode($return));
46
+			$xajax_response -> addAssign('ajax_list_courses_multiple', 'innerHTML', api_utf8_encode($return));
47 47
 		}
48 48
 		$_SESSION['course_list'] = $course_list;
49 49
 		return $xajax_response;
Please login to merge, or discard this patch.
Indentation   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -24,28 +24,28 @@
 block discarded – undo
24 24
     function search_courses($needle,$type)
25 25
     {
26 26
         $tbl_session = Database :: get_main_table(TABLE_MAIN_SESSION);
27
-		$xajax_response = new xajaxResponse();
28
-		$return = '';
29
-		if(!empty($needle) && !empty($type)) {
30
-			// xajax send utf8 datas... datas in db can be non-utf8 datas
31
-			$charset = api_get_system_encoding();
32
-			$needle = api_convert_encoding($needle, $charset, 'utf-8');
33
-			$needle = Database::escape_string($needle);
27
+        $xajax_response = new xajaxResponse();
28
+        $return = '';
29
+        if(!empty($needle) && !empty($type)) {
30
+            // xajax send utf8 datas... datas in db can be non-utf8 datas
31
+            $charset = api_get_system_encoding();
32
+            $needle = api_convert_encoding($needle, $charset, 'utf-8');
33
+            $needle = Database::escape_string($needle);
34 34
 
35
-			$sql = 'SELECT * FROM '.$tbl_session.' WHERE name LIKE "'.$needle.'%" ORDER BY id';
35
+            $sql = 'SELECT * FROM '.$tbl_session.' WHERE name LIKE "'.$needle.'%" ORDER BY id';
36 36
 
37
-			$rs = Database::query($sql);
38
-			$course_list = array();
37
+            $rs = Database::query($sql);
38
+            $course_list = array();
39 39
 
40
-			$return .= '<select id="origin" name="NoSessionCategoryList[]" multiple="multiple" size="20" style="width:340px;">';
41
-			while($course = Database :: fetch_array($rs)) {
42
-				$course_list[] = $course['id'];
43
-				$return .= '<option value="'.$course['id'].'" title="'.htmlspecialchars($course['name'],ENT_QUOTES).'">'.$course['name'].'</option>';
44
-			}
45
-			$return .= '</select>';
46
-			$xajax_response -> addAssign('ajax_list_courses_multiple','innerHTML',api_utf8_encode($return));
47
-		}
48
-		$_SESSION['course_list'] = $course_list;
49
-		return $xajax_response;
50
-	}
40
+            $return .= '<select id="origin" name="NoSessionCategoryList[]" multiple="multiple" size="20" style="width:340px;">';
41
+            while($course = Database :: fetch_array($rs)) {
42
+                $course_list[] = $course['id'];
43
+                $return .= '<option value="'.$course['id'].'" title="'.htmlspecialchars($course['name'],ENT_QUOTES).'">'.$course['name'].'</option>';
44
+            }
45
+            $return .= '</select>';
46
+            $xajax_response -> addAssign('ajax_list_courses_multiple','innerHTML',api_utf8_encode($return));
47
+        }
48
+        $_SESSION['course_list'] = $course_list;
49
+        return $xajax_response;
50
+    }
51 51
 }
Please login to merge, or discard this patch.