Completed
Pull Request — 1.11.x (#1296)
by José
132:18 queued 93:54
created
main/inc/lib/grade_model.lib.php 3 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -248,6 +248,9 @@
 block discarded – undo
248 248
 	    //event_system(LOG_CAREER_DELETE, LOG_CAREER_ID, $id, api_get_utc_datetime(), api_get_user_id());
249 249
     }
250 250
 
251
+    /**
252
+     * @param CatForm $form
253
+     */
251 254
     public function fill_grade_model_select_in_form(&$form, $name = 'gradebook_model_id', $default_value = null)
252 255
     {
253 256
         if (api_get_setting('gradebook_enable_grade_model') == 'false') {
Please login to merge, or discard this patch.
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -51,15 +51,15 @@  discard block
 block discarded – undo
51 51
     /**
52 52
      * Displays the title + grid
53 53
      */
54
-	public function display()
54
+    public function display()
55 55
     {
56
-		// action links
57
-		echo '<div class="actions" style="margin-bottom:20px">';
56
+        // action links
57
+        echo '<div class="actions" style="margin-bottom:20px">';
58 58
         echo '<a href="grade_models.php">'.Display::return_icon('back.png',get_lang('Back'),'','32').'</a>';
59
-		echo '<a href="'.api_get_self().'?action=add">'.Display::return_icon('add.png',get_lang('Add'),'','32').'</a>';
60
-		echo '</div>';
59
+        echo '<a href="'.api_get_self().'?action=add">'.Display::return_icon('add.png',get_lang('Add'),'','32').'</a>';
60
+        echo '</div>';
61 61
         echo Display::grid_html('grade_model');
62
-	}
62
+    }
63 63
 
64 64
     /**
65 65
      * Returns a Form validator Obj
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
         }
117 117
 
118 118
         $form->addElement('hidden', 'maxvalue', '100');
119
-		$form->addElement('hidden', 'minvalue', '0');
119
+        $form->addElement('hidden', 'minvalue', '0');
120 120
         $renderer = & $form->defaultRenderer();
121 121
 
122 122
         $component_array = array();
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
         // Setting the rules
194 194
         $form->addRule('name', get_lang('ThisFieldIsRequired'), 'required');
195 195
 
196
-		return $form;
196
+        return $form;
197 197
     }
198 198
 
199 199
     /**
@@ -216,8 +216,8 @@  discard block
 block discarded – undo
216 216
      */
217 217
     public function save($params, $show_query = false)
218 218
     {
219
-	    $id = parent::save($params, $show_query);
220
-	    if (!empty($id)) {
219
+        $id = parent::save($params, $show_query);
220
+        if (!empty($id)) {
221 221
             foreach ($params['components'] as $component) {
222 222
                 if (!empty($component['title']) && !empty($component['percentage']) && !empty($component['acronym'])) {
223 223
                     $obj = new GradeModelComponents();
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
         }
229 229
 
230 230
         //event_system(LOG_CAREER_CREATE, LOG_CAREER_ID, $id, api_get_utc_datetime(), api_get_user_id());
231
-   		return $id;
231
+            return $id;
232 232
     }
233 233
 
234 234
     /**
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
      */
258 258
     public function delete($id)
259 259
     {
260
-	    parent::delete($id);
260
+        parent::delete($id);
261 261
     }
262 262
 
263 263
     public function fill_grade_model_select_in_form(&$form, $name = 'gradebook_model_id', $default_value = null)
@@ -305,11 +305,11 @@  discard block
 block discarded – undo
305 305
     /**
306 306
      * GradeModelComponents constructor.
307 307
      */
308
-	public function __construct()
308
+    public function __construct()
309 309
     {
310 310
         parent::__construct();
311 311
         $this->table = Database::get_main_table(TABLE_GRADE_MODEL_COMPONENTS);
312
-	}
312
+    }
313 313
 
314 314
     /**
315 315
      * @param array $params
@@ -318,7 +318,7 @@  discard block
 block discarded – undo
318 318
      */
319 319
     public function save($params, $show_query = false)
320 320
     {
321
-	    $id = parent::save($params, $show_query);
321
+        $id = parent::save($params, $show_query);
322 322
         
323 323
         return $id;
324 324
     }
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
     public function __construct()
17 17
     {
18 18
         parent::__construct();
19
-        $this->table =  Database::get_main_table(TABLE_GRADE_MODEL);
19
+        $this->table = Database::get_main_table(TABLE_GRADE_MODEL);
20 20
     }
21 21
 
22 22
     /**
@@ -55,8 +55,8 @@  discard block
 block discarded – undo
55 55
     {
56 56
 		// action links
57 57
 		echo '<div class="actions" style="margin-bottom:20px">';
58
-        echo '<a href="grade_models.php">'.Display::return_icon('back.png',get_lang('Back'),'','32').'</a>';
59
-		echo '<a href="'.api_get_self().'?action=add">'.Display::return_icon('add.png',get_lang('Add'),'','32').'</a>';
58
+        echo '<a href="grade_models.php">'.Display::return_icon('back.png', get_lang('Back'), '', '32').'</a>';
59
+		echo '<a href="'.api_get_self().'?action=add">'.Display::return_icon('add.png', get_lang('Add'), '', '32').'</a>';
60 60
 		echo '</div>';
61 61
         echo Display::grid_html('grade_model');
62 62
 	}
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
 
113 113
         if ($action == 'edit') {
114 114
             if (!empty($components)) {
115
-                $nr_items = count($components) -1;
115
+                $nr_items = count($components) - 1;
116 116
             }
117 117
         }
118 118
 
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
             $form->addElement('hidden', 'components['.$i.'][id]', null);
131 131
 
132 132
             $template_percentage =
133
-            '<div id=' . $i . ' style="display: '.(($i<=$nr_items)?'inline':'none').';" class="control-group">
133
+            '<div id='.$i.' style="display: '.(($i <= $nr_items) ? 'inline' : 'none').';" class="control-group">
134 134
                 <p>
135 135
                 <label class="control-label">{label}</label>
136 136
                 <div class="controls">
@@ -143,11 +143,11 @@  discard block
 block discarded – undo
143 143
 
144 144
             $template_title =
145 145
             '&nbsp{element} <!-- BEGIN error --> <span class="form_error">{error}</span><!-- END error -->
146
-             <a href="javascript:plusItem(' . ($counter+1) . ')">
147
-                '.Display::return_icon('add.png', get_lang('Add'), ['id' => 'plus-' . ($counter+1), 'style' => 'display: '.(($counter>=$nr_items) ? 'inline':'none') ]).'
146
+             <a href="javascript:plusItem(' . ($counter + 1).')">
147
+                '.Display::return_icon('add.png', get_lang('Add'), ['id' => 'plus-'.($counter + 1), 'style' => 'display: '.(($counter >= $nr_items) ? 'inline' : 'none')]).'
148 148
             </a>
149
-            <a href="javascript:minItem(' . ($counter) . ')">
150
-                '.Display::return_icon('delete.png', get_lang('Delete'), ['id' => 'min-' . ($counter), 'style' => 'display: '.(($counter>=$nr_items) ? 'inline':'none') ]).'
149
+            <a href="javascript:minItem(' . ($counter).')">
150
+                '.Display::return_icon('delete.png', get_lang('Delete'), ['id' => 'min-'.($counter), 'style' => 'display: '.(($counter >= $nr_items) ? 'inline' : 'none')]).'
151 151
             </a>
152 152
             </div></p></div>';
153 153
             $renderer->setElementTemplate($template_title, 'components['.$i.'][title]');
Please login to merge, or discard this patch.
main/inc/lib/groupmanager.lib.php 2 patches
Doc Comments   +13 added lines, -10 removed lines patch added patch discarded remove patch
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
      * @author Christophe Gesche <[email protected]>
370 370
      * @author Hugues Peeters <[email protected]>
371 371
      * @author Bart Mollet
372
-     * @param  mixed  $groupIdList - group(s) to delete. It can be a single id
372
+     * @param  mixed  $group_ids - group(s) to delete. It can be a single id
373 373
      *                                (int) or a list of id (array).
374 374
      * @param string $course_code Default is current course
375 375
      * @return integer              - number of groups deleted.
@@ -573,7 +573,7 @@  discard block
 block discarded – undo
573 573
      * @param bool      Whether self registration is allowed or not
574 574
      * @param bool      Whether self unregistration is allowed or not
575 575
      * @param int       $categoryId
576
-     * @return bool     TRUE if properties are successfully changed, false otherwise
576
+     * @return Statement|null     TRUE if properties are successfully changed, false otherwise
577 577
      */
578 578
     public static function set_group_properties(
579 579
         $group_id,
@@ -724,7 +724,7 @@  discard block
 block discarded – undo
724 724
      * @param int $group_id The id of the group
725 725
      * @param string $course_code The course in which the group is (default =
726 726
      * current course)
727
-     * @return array The category
727
+     * @return integer The category
728 728
      */
729 729
     public static function get_category_from_group($group_id, $course_code = null)
730 730
     {
@@ -786,9 +786,9 @@  discard block
 block discarded – undo
786 786
      * Create group category
787 787
      * @param string $title The title of the new category
788 788
      * @param string $description The description of the new category
789
-     * @param bool $self_registration_allowed
790
-     * @param bool $self_unregistration_allowed
791
-     * @param int $max_number_of_students
789
+     * @param integer $self_registration_allowed
790
+     * @param integer $self_unregistration_allowed
791
+     * @param int $maximum_number_of_students
792 792
      * @param int $groups_per_user
793 793
      */
794 794
     public static function create_category(
@@ -994,6 +994,8 @@  discard block
 block discarded – undo
994 994
      * @param int $limit
995 995
      * @param bool $getCount
996 996
      * @param int $courseId
997
+     * @param string $column
998
+     * @param string $direction
997 999
      * @return array list of user id
998 1000
      */
999 1001
     public static function get_users(
@@ -1172,7 +1174,7 @@  discard block
 block discarded – undo
1172 1174
      *         Hugues Peeters     <[email protected]> - original version
1173 1175
      * @author Roan Embrechts - virtual course support, code cleaning
1174 1176
      * @author Bart Mollet - code cleaning, use other GroupManager-functions
1175
-     * @return void
1177
+     * @return false|null
1176 1178
      */
1177 1179
     public static function fill_groups($group_ids)
1178 1180
     {
@@ -1625,7 +1627,7 @@  discard block
 block discarded – undo
1625 1627
      * Unsubscribe user(s) from a specified group in current course
1626 1628
      * @param mixed $user_ids Can be an array with user-id's or a single user-id
1627 1629
      * @param int $group_id
1628
-     * @return bool TRUE if successful
1630
+     * @return boolean|null TRUE if successful
1629 1631
      */
1630 1632
     public static function unsubscribe_users($user_ids, $group_id)
1631 1633
     {
@@ -1644,7 +1646,7 @@  discard block
 block discarded – undo
1644 1646
 
1645 1647
     /**
1646 1648
      * Unsubscribe all users from one or more groups
1647
-     * @param mixed $group_id Can be an array with group-id's or a single group-id
1649
+     * @param mixed $group_ids Can be an array with group-id's or a single group-id
1648 1650
      * @return bool TRUE if successful
1649 1651
      */
1650 1652
     public static function unsubscribe_all_users($group_ids)
@@ -1676,7 +1678,7 @@  discard block
 block discarded – undo
1676 1678
 
1677 1679
     /**
1678 1680
      * Unsubscribe all tutors from one or more groups
1679
-     * @param mixed $group_id Can be an array with group-id's or a single group-id
1681
+     * @param mixed $group_ids Can be an array with group-id's or a single group-id
1680 1682
      * @see unsubscribe_all_users. This function is almost an exact copy of that function.
1681 1683
      * @return bool TRUE if successful
1682 1684
      * @author Patrick Cool <[email protected]>, Ghent University
@@ -1861,6 +1863,7 @@  discard block
 block discarded – undo
1861 1863
      *
1862 1864
      * @param $user_array_in list of users (must be sorted).
1863 1865
      * @param string $compare_field, the field to be compared
1866
+     * @param string $compare_field
1864 1867
      */
1865 1868
     public static function filter_duplicates($user_array_in, $compare_field)
1866 1869
     {
Please login to merge, or discard this patch.
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -211,8 +211,8 @@  discard block
 block discarded – undo
211 211
             $sql = "UPDATE $table_group SET id = iid WHERE iid = $lastId";
212 212
             Database::query($sql);
213 213
 
214
-            $desired_dir_name= '/'.api_replace_dangerous_char($name).'_groupdocs';
215
-            $my_path = api_get_path(SYS_COURSE_PATH) . $currentCourseRepository . '/document';
214
+            $desired_dir_name = '/'.api_replace_dangerous_char($name).'_groupdocs';
215
+            $my_path = api_get_path(SYS_COURSE_PATH).$currentCourseRepository.'/document';
216 216
 
217 217
             $newFolderData = create_unexisting_directory(
218 218
                 $_course,
@@ -275,11 +275,11 @@  discard block
 block discarded – undo
275 275
                 $values['default_view_type_group']['default_view_type'] = api_get_setting('default_forum_view');
276 276
                 $values['group_forum'] = $lastId;
277 277
                 if ($forumState == '1') {
278
-                    $values['public_private_group_forum_group']['public_private_group_forum']='public';
278
+                    $values['public_private_group_forum_group']['public_private_group_forum'] = 'public';
279 279
                 } elseif ($forumState == '2') {
280
-                    $values['public_private_group_forum_group']['public_private_group_forum']='private';
280
+                    $values['public_private_group_forum_group']['public_private_group_forum'] = 'private';
281 281
                 } elseif ($forumState == '0') {
282
-                    $values['public_private_group_forum_group']['public_private_group_forum']='unavailable';
282
+                    $values['public_private_group_forum_group']['public_private_group_forum'] = 'unavailable';
283 283
                 }
284 284
                 store_forum($values);
285 285
             }
@@ -310,9 +310,9 @@  discard block
 block discarded – undo
310 310
             1
311 311
         );
312 312
         $users = self::get_users($group_id);
313
-        $group_ids = array ();
313
+        $group_ids = array();
314 314
 
315
-        for ($group_nr = 1; $group_nr <= $number_of_groups; $group_nr ++) {
315
+        for ($group_nr = 1; $group_nr <= $number_of_groups; $group_nr++) {
316 316
             $group_ids[] = self::create_group(
317 317
                 get_lang('Subgroup').' '.$group_nr,
318 318
                 $category_id,
@@ -356,7 +356,7 @@  discard block
 block discarded – undo
356 356
                 0,
357 357
                 count($users_ids)
358 358
             );
359
-            self::subscribe_users($users_ids,$group_id);
359
+            self::subscribe_users($users_ids, $group_id);
360 360
             $group_ids[] = $group_id;
361 361
         }
362 362
         return $group_ids;
@@ -381,14 +381,14 @@  discard block
 block discarded – undo
381 381
         $group_table = Database:: get_course_table(TABLE_GROUP);
382 382
         $forum_table = Database:: get_course_table(TABLE_FORUM);
383 383
 
384
-        $group_ids = is_array($group_ids) ? $group_ids : array ($group_ids);
385
-        $group_ids = array_map('intval',$group_ids);
384
+        $group_ids = is_array($group_ids) ? $group_ids : array($group_ids);
385
+        $group_ids = array_map('intval', $group_ids);
386 386
 
387 387
         if (api_is_course_coach()) {
388 388
             //a coach can only delete courses from his session
389 389
             for ($i = 0; $i < count($group_ids); $i++) {
390
-                if (!api_is_element_in_the_session(TOOL_GROUP,$group_ids[$i])) {
391
-                    array_splice($group_ids,$i,1);
390
+                if (!api_is_element_in_the_session(TOOL_GROUP, $group_ids[$i])) {
391
+                    array_splice($group_ids, $i, 1);
392 392
                     $i--;
393 393
                 }
394 394
             }
@@ -623,7 +623,7 @@  discard block
 block discarded – undo
623 623
         } elseif ($forum_state === 0) {
624 624
             $sql2 .= " forum_group_public_private='unavailable' ";
625 625
         }
626
-        $sql2 .=" WHERE c_id = $course_id AND forum_of_group=".$group_id;
626
+        $sql2 .= " WHERE c_id = $course_id AND forum_of_group=".$group_id;
627 627
         Database::query($sql2);
628 628
         return $result;
629 629
     }
@@ -653,13 +653,13 @@  discard block
 block discarded – undo
653 653
     public static function get_categories($course_code = null)
654 654
     {
655 655
         $course_info = api_get_course_info($course_code);
656
-        $course_id     = $course_info['real_id'];
656
+        $course_id = $course_info['real_id'];
657 657
         $table_group_cat = Database :: get_course_table(TABLE_GROUP_CATEGORY);
658 658
         $sql = "SELECT * FROM $table_group_cat
659 659
                 WHERE c_id = $course_id
660 660
                 ORDER BY display_order";
661 661
         $res = Database::query($sql);
662
-        $cats = array ();
662
+        $cats = array();
663 663
         while ($cat = Database::fetch_array($res)) {
664 664
             $cats[] = $cat;
665 665
         }
@@ -771,7 +771,7 @@  discard block
 block discarded – undo
771 771
                 WHERE c_id = $course_id AND category_id='".$cat_id."'";
772 772
         $res = Database::query($sql);
773 773
         if (Database::num_rows($res) > 0) {
774
-            $groups_to_delete = array ();
774
+            $groups_to_delete = array();
775 775
             while ($group = Database::fetch_object($res)) {
776 776
                 $groups_to_delete[] = $group->id;
777 777
             }
@@ -939,7 +939,7 @@  discard block
 block discarded – undo
939 939
      */
940 940
     public static function get_current_max_groups_per_user($category_id = null, $course_code = null)
941 941
     {
942
-        $course_info = api_get_course_info ($course_code);
942
+        $course_info = api_get_course_info($course_code);
943 943
         $group_table = Database :: get_course_table(TABLE_GROUP);
944 944
         $group_user_table = Database :: get_course_table(TABLE_GROUP_USER);
945 945
         $sql = 'SELECT COUNT(gu.group_id) AS current_max
@@ -1182,17 +1182,17 @@  discard block
 block discarded – undo
1182 1182
     {
1183 1183
         $_course = api_get_course_info();
1184 1184
 
1185
-        $group_ids = is_array($group_ids) ? $group_ids : array ($group_ids);
1185
+        $group_ids = is_array($group_ids) ? $group_ids : array($group_ids);
1186 1186
         $group_ids = array_map('intval', $group_ids);
1187 1187
 
1188 1188
         if (api_is_course_coach()) {
1189
-            for ($i=0 ; $i < count($group_ids) ; $i++) {
1190
-                if (!api_is_element_in_the_session(TOOL_GROUP, $group_ids[$i])){
1191
-                    array_splice($group_ids,$i,1);
1189
+            for ($i = 0; $i < count($group_ids); $i++) {
1190
+                if (!api_is_element_in_the_session(TOOL_GROUP, $group_ids[$i])) {
1191
+                    array_splice($group_ids, $i, 1);
1192 1192
                     $i--;
1193 1193
                 }
1194 1194
             }
1195
-            if (count($group_ids)==0) {
1195
+            if (count($group_ids) == 0) {
1196 1196
                 return false;
1197 1197
             }
1198 1198
         }
@@ -1231,9 +1231,9 @@  discard block
 block discarded – undo
1231 1231
          * Retrieve course users (reverse) ordered by the number
1232 1232
          * of group they are already enrolled
1233 1233
          */
1234
-        for ($i = 0; $i < count($complete_user_list); $i ++) {
1234
+        for ($i = 0; $i < count($complete_user_list); $i++) {
1235 1235
             //find # of groups the user is enrolled in
1236
-            $number_of_groups = self :: user_in_number_of_groups($complete_user_list[$i]["user_id"], (isset($category['id'])?$category['id']:null));
1236
+            $number_of_groups = self :: user_in_number_of_groups($complete_user_list[$i]["user_id"], (isset($category['id']) ? $category['id'] : null));
1237 1237
             //add # of groups to user list
1238 1238
             $complete_user_list[$i]['number_groups_left'] = $number_groups_per_user - $number_of_groups;
1239 1239
         }
@@ -1245,7 +1245,7 @@  discard block
 block discarded – undo
1245 1245
 
1246 1246
         //now sort by # of group left
1247 1247
         $complete_user_list = TableSort :: sort_table($complete_user_list, 'number_groups_left', SORT_DESC);
1248
-        $userToken = array ();
1248
+        $userToken = array();
1249 1249
         foreach ($complete_user_list as $this_user) {
1250 1250
             if ($this_user['number_groups_left'] > 0) {
1251 1251
                 $userToken[$this_user['user_id']] = $this_user['number_groups_left'];
@@ -1440,7 +1440,7 @@  discard block
 block discarded – undo
1440 1440
                 if ($category['groups_per_user'] == self::GROUP_PER_MEMBER_NO_LIMIT) {
1441 1441
                     $category['groups_per_user'] = self::INFINITE;
1442 1442
                 }
1443
-                $result = self:: user_in_number_of_groups($user_id, $category['id'] ) < $category['groups_per_user'];
1443
+                $result = self:: user_in_number_of_groups($user_id, $category['id']) < $category['groups_per_user'];
1444 1444
                 if ($result == false) {
1445 1445
                     return false;
1446 1446
                 }
@@ -1551,7 +1551,7 @@  discard block
 block discarded – undo
1551 1551
                     tg.group_id='".$group_id."' AND
1552 1552
                     tg.user_id=u.user_id".$order_clause;
1553 1553
         $db_result = Database::query($sql);
1554
-        $users = array ();
1554
+        $users = array();
1555 1555
         while ($user = Database::fetch_object($db_result)) {
1556 1556
             if (!$id_only) {
1557 1557
                 $member['user_id'] = $user->user_id;
@@ -1616,8 +1616,8 @@  discard block
 block discarded – undo
1616 1616
         foreach ($user_ids as $user_id) {
1617 1617
             $user_id = intval($user_id);
1618 1618
             if (self::can_user_subscribe($user_id, $group_id, false)) {
1619
-                $sql = "INSERT INTO " . $table_group_tutor . " (c_id, user_id, group_id)
1620
-                        VALUES ('$course_id', '" . $user_id . "', '" . $group_id . "')";
1619
+                $sql = "INSERT INTO ".$table_group_tutor." (c_id, user_id, group_id)
1620
+                        VALUES ('$course_id', '".$user_id."', '".$group_id."')";
1621 1621
                 $result &= Database::query($sql);
1622 1622
             }
1623 1623
         }
@@ -1633,7 +1633,7 @@  discard block
 block discarded – undo
1633 1633
      */
1634 1634
     public static function unsubscribe_users($user_ids, $group_id)
1635 1635
     {
1636
-        $user_ids = is_array($user_ids) ? $user_ids : array ($user_ids);
1636
+        $user_ids = is_array($user_ids) ? $user_ids : array($user_ids);
1637 1637
         $table_group_user = Database :: get_course_table(TABLE_GROUP_USER);
1638 1638
         $group_id = intval($group_id);
1639 1639
         $course_id = api_get_course_int_id();
@@ -2179,7 +2179,7 @@  discard block
 block discarded – undo
2179 2179
          * Retrieve course users (reverse) ordered by the number
2180 2180
          * of group they are already enrolled
2181 2181
          */
2182
-        for ($i = 0; $i < count($complete_user_list); $i ++) {
2182
+        for ($i = 0; $i < count($complete_user_list); $i++) {
2183 2183
             // find # of groups the user is enrolled in
2184 2184
             $number_of_groups = self:: user_in_number_of_groups(
2185 2185
                 $complete_user_list[$i]["user_id"],
@@ -2312,14 +2312,14 @@  discard block
 block discarded – undo
2312 2312
                 !(api_is_course_coach() && intval($this_group['session_id']) != $session_id)
2313 2313
             ) {
2314 2314
                 $edit_actions = '<a href="'.$url.'settings.php?'.api_get_cidreq(true, false).'&gidReq='.$this_group['id'].'"  title="'.get_lang('Edit').'">'.
2315
-                    Display::return_icon('edit.png', get_lang('EditGroup'),'',ICON_SIZE_SMALL).'</a>&nbsp;';
2315
+                    Display::return_icon('edit.png', get_lang('EditGroup'), '', ICON_SIZE_SMALL).'</a>&nbsp;';
2316 2316
 
2317 2317
                 if ($this_group['status'] == 1) {
2318
-                    $edit_actions .= '<a href="' . api_get_self() . '?' . api_get_cidreq(true,false) . '&category=' . $category_id . '&action=set_invisible&id=' . $this_group['id'] . '" title="' . get_lang('Hide') . '">' .
2319
-                        Display::return_icon('visible.png', get_lang('Hide'), '', ICON_SIZE_SMALL) . '</a>&nbsp;';
2318
+                    $edit_actions .= '<a href="'.api_get_self().'?'.api_get_cidreq(true, false).'&category='.$category_id.'&action=set_invisible&id='.$this_group['id'].'" title="'.get_lang('Hide').'">'.
2319
+                        Display::return_icon('visible.png', get_lang('Hide'), '', ICON_SIZE_SMALL).'</a>&nbsp;';
2320 2320
                 } else {
2321
-                    $edit_actions .= '<a href="' . api_get_self() . '?' . api_get_cidreq(true, false) . '&category=' . $category_id . '&action=set_visible&id=' . $this_group['id'] . '" title="' . get_lang('Show') . '">' .
2322
-                        Display::return_icon('invisible.png', get_lang('Show'), '', ICON_SIZE_SMALL) . '</a>&nbsp;';
2321
+                    $edit_actions .= '<a href="'.api_get_self().'?'.api_get_cidreq(true, false).'&category='.$category_id.'&action=set_visible&id='.$this_group['id'].'" title="'.get_lang('Show').'">'.
2322
+                        Display::return_icon('invisible.png', get_lang('Show'), '', ICON_SIZE_SMALL).'</a>&nbsp;';
2323 2323
                 }
2324 2324
 
2325 2325
                 $edit_actions .= '<a href="'.$url.'member_settings.php?'.api_get_cidreq(true, false).'&gidReq='.$this_group['id'].'"  title="'.get_lang('GroupMembers').'">'.
@@ -2332,10 +2332,10 @@  discard block
 block discarded – undo
2332 2332
                     Display::return_icon('clean.png',get_lang('EmptyGroup'),'',ICON_SIZE_SMALL).'</a>&nbsp;';*/
2333 2333
 
2334 2334
                 $edit_actions .= '<a href="'.api_get_self().'?'.api_get_cidreq(true, false).'&category='.$category_id.'&action=fill_one&id='.$this_group['id'].'" onclick="javascript: if(!confirm('."'".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES))."'".')) return false;" title="'.get_lang('FillGroup').'">'.
2335
-                    Display::return_icon('fill.png',get_lang('FillGroup'),'',ICON_SIZE_SMALL).'</a>&nbsp;';
2335
+                    Display::return_icon('fill.png', get_lang('FillGroup'), '', ICON_SIZE_SMALL).'</a>&nbsp;';
2336 2336
 
2337 2337
                 $edit_actions .= '<a href="'.api_get_self().'?'.api_get_cidreq(true, false).'&category='.$category_id.'&action=delete_one&id='.$this_group['id'].'" onclick="javascript: if(!confirm('."'".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES))."'".')) return false;" title="'.get_lang('Delete').'">'.
2338
-                    Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_SMALL).'</a>&nbsp;';
2338
+                    Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL).'</a>&nbsp;';
2339 2339
 
2340 2340
                 $row[] = $edit_actions;
2341 2341
             }
@@ -2707,7 +2707,7 @@  discard block
 block discarded – undo
2707 2707
         $activeTutor = null;
2708 2708
         $activeMember = null;
2709 2709
 
2710
-        switch($default) {
2710
+        switch ($default) {
2711 2711
             case 'settings':
2712 2712
                 $activeSettings = 'active';
2713 2713
                 break;
Please login to merge, or discard this patch.
main/inc/lib/hook/HookManagement.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -138,7 +138,7 @@
 block discarded – undo
138 138
 
139 139
     /**
140 140
      * Return a list an associative array where keys are the active hook observer class name
141
-     * @param $eventName
141
+     * @param string $eventName
142 142
      *
143 143
      * @return array
144 144
      */
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -145,10 +145,10 @@  discard block
 block discarded – undo
145 145
     public function listHookObservers($eventName)
146 146
     {
147 147
         $array = array();
148
-        $joinTable = $this->tables[TABLE_HOOK_CALL] . ' hc' .
149
-            ' INNER JOIN ' . $this->tables[TABLE_HOOK_EVENT] . ' he' .
150
-            ' ON hc.hook_event_id = he.id ' .
151
-            ' INNER JOIN ' . $this->tables[TABLE_HOOK_OBSERVER] . ' ho ' .
148
+        $joinTable = $this->tables[TABLE_HOOK_CALL].' hc'.
149
+            ' INNER JOIN '.$this->tables[TABLE_HOOK_EVENT].' he'.
150
+            ' ON hc.hook_event_id = he.id '.
151
+            ' INNER JOIN '.$this->tables[TABLE_HOOK_OBSERVER].' ho '.
152 152
             ' ON hc.hook_observer_id = ho.id ';
153 153
         $columns = 'ho.class_name, ho.path, ho.plugin_name, hc.enabled';
154 154
         $where = array('where' => array('he.class_name = ? ' => $eventName, 'AND hc.enabled = ? ' => 1));
@@ -202,10 +202,10 @@  discard block
 block discarded – undo
202 202
     public function listAllHookCalls()
203 203
     {
204 204
         $array = array();
205
-        $joinTable = $this->tables[TABLE_HOOK_CALL] . ' hc' .
206
-            ' INNER JOIN ' . $this->tables[TABLE_HOOK_EVENT] . ' he' .
207
-            ' ON hc.hook_event_id = he.id ' .
208
-            ' INNER JOIN ' . $this->tables[TABLE_HOOK_OBSERVER] . ' ho ' .
205
+        $joinTable = $this->tables[TABLE_HOOK_CALL].' hc'.
206
+            ' INNER JOIN '.$this->tables[TABLE_HOOK_EVENT].' he'.
207
+            ' ON hc.hook_event_id = he.id '.
208
+            ' INNER JOIN '.$this->tables[TABLE_HOOK_OBSERVER].' ho '.
209 209
             ' ON hc.hook_observer_id = ho.id ';
210 210
         $columns = 'he.class_name AS event_class_name, ho.class_name AS observer_class_name, hc.id AS id, hc.type AS type';
211 211
         $rows = Database::select($columns, $joinTable);
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
         if (isset($eventName) && !isset($this->hookEvents[$eventName])) {
232 232
             $attributes = array(
233 233
                 'class_name' => $eventName,
234
-                'description' => get_lang('HookDescription' . $eventName),
234
+                'description' => get_lang('HookDescription'.$eventName),
235 235
             );
236 236
             $id = Database::insert($this->tables[TABLE_HOOK_EVENT], $attributes);
237 237
             $this->hookEvents[$eventName] = $id;
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
         // Check if exists hook observer
241 241
         if (isset($observerClassName) &&
242 242
             !isset($this->hookObservers[$observerClassName])
243
-        ){
243
+        ) {
244 244
             $object = $observerClassName::create();
245 245
             $attributes = array(
246 246
                 'class_name' => $observerClassName,
@@ -338,10 +338,10 @@  discard block
 block discarded – undo
338 338
         $eventName = Database::escape_string($eventName);
339 339
         $observerClassName($observerClassName);
340 340
         $type = Database::escape_string($type);
341
-        $joinTable = $this->tables[TABLE_HOOK_CALL] . ' hc' .
342
-            ' INNER JOIN ' . $this->tables[TABLE_HOOK_EVENT] . ' he' .
343
-            ' ON hc.hook_event_id = he.id ' .
344
-            ' INNER JOIN ' . $this->tables[TABLE_HOOK_OBSERVER] . ' ho ' .
341
+        $joinTable = $this->tables[TABLE_HOOK_CALL].' hc'.
342
+            ' INNER JOIN '.$this->tables[TABLE_HOOK_EVENT].' he'.
343
+            ' ON hc.hook_event_id = he.id '.
344
+            ' INNER JOIN '.$this->tables[TABLE_HOOK_OBSERVER].' ho '.
345 345
             ' ON hc.hook_observer_id = ho.id ';
346 346
         $row = Database::select(
347 347
             'id',
Please login to merge, or discard this patch.
main/inc/lib/login.lib.php 3 patches
Doc Comments   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -266,6 +266,7 @@  discard block
 block discarded – undo
266 266
      * @global bool   $is_platformAdmin
267 267
      * @global bool   $is_allowedCreateCourse
268 268
      * @global object $_user
269
+     * @param boolean $reset
269 270
      */
270 271
     public static function init_user($user_id, $reset)
271 272
     {
@@ -355,7 +356,7 @@  discard block
 block discarded – undo
355 356
      * @global type $is_allowed_in_course
356 357
      *
357 358
      * @param type $course_id
358
-     * @param type $reset
359
+     * @param boolean $reset
359 360
      */
360 361
     static function init_course($course_id, $reset)
361 362
     {
Please login to merge, or discard this patch.
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -37,24 +37,24 @@  discard block
 block discarded – undo
37 37
             if ($by_username) {
38 38
                 $secret_word = self::get_secret_word($user['email']);
39 39
                 if ($reset) {
40
-                    $reset_link = $portal_url . "main/auth/lostPassword.php?reset=" . $secret_word . "&id=" . $user['uid'];
40
+                    $reset_link = $portal_url."main/auth/lostPassword.php?reset=".$secret_word."&id=".$user['uid'];
41 41
                 } else {
42
-                    $reset_link = get_lang('Pass') . " : $user[password]";
42
+                    $reset_link = get_lang('Pass')." : $user[password]";
43 43
                 }
44
-                $user_account_list = get_lang('YourRegistrationData') . " : \n" . get_lang('UserName') . ' : ' . $user['loginName'] . "\n" . get_lang('ResetLink') . ' : ' . $reset_link . '';
44
+                $user_account_list = get_lang('YourRegistrationData')." : \n".get_lang('UserName').' : '.$user['loginName']."\n".get_lang('ResetLink').' : '.$reset_link.'';
45 45
 
46 46
                 if ($user_account_list) {
47
-                    $user_account_list = "\n-----------------------------------------------\n" . $user_account_list;
47
+                    $user_account_list = "\n-----------------------------------------------\n".$user_account_list;
48 48
                 }
49 49
             } else {
50 50
                 foreach ($user as $this_user) {
51 51
                     $secret_word = self::get_secret_word($this_user['email']);
52 52
                     if ($reset) {
53
-                        $reset_link = $portal_url . "main/auth/lostPassword.php?reset=" . $secret_word . "&id=" . $this_user['uid'];
53
+                        $reset_link = $portal_url."main/auth/lostPassword.php?reset=".$secret_word."&id=".$this_user['uid'];
54 54
                     } else {
55
-                        $reset_link = get_lang('Pass') . " : $this_user[password]";
55
+                        $reset_link = get_lang('Pass')." : $this_user[password]";
56 56
                     }
57
-                    $user_account_list[] = get_lang('YourRegistrationData') . " : \n" . get_lang('UserName') . ' : ' . $this_user['loginName'] . "\n" . get_lang('ResetLink') . ' : ' . $reset_link . '';
57
+                    $user_account_list[] = get_lang('YourRegistrationData')." : \n".get_lang('UserName').' : '.$this_user['loginName']."\n".get_lang('ResetLink').' : '.$reset_link.'';
58 58
                 }
59 59
                 if ($user_account_list) {
60 60
                     $user_account_list = implode("\n-----------------------------------------------\n", $user_account_list);
@@ -64,8 +64,8 @@  discard block
 block discarded – undo
64 64
             if (!$by_username) {
65 65
                 $user = $user[0];
66 66
             }
67
-            $reset_link = get_lang('Pass') . " : $user[password]";
68
-            $user_account_list = get_lang('YourRegistrationData') . " : \n" . get_lang('UserName') . ' : ' . $user['loginName'] . "\n" . $reset_link . '';
67
+            $reset_link = get_lang('Pass')." : $user[password]";
68
+            $user_account_list = get_lang('YourRegistrationData')." : \n".get_lang('UserName').' : '.$user['loginName']."\n".$reset_link.'';
69 69
         }
70 70
         return $user_account_list;
71 71
     }
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
      */
79 79
     public static function send_password_to_user($user, $by_username = false)
80 80
     {
81
-        $email_subject = "[" . api_get_setting('siteName') . "] " . get_lang('LoginRequest'); // SUBJECT
81
+        $email_subject = "[".api_get_setting('siteName')."] ".get_lang('LoginRequest'); // SUBJECT
82 82
 
83 83
         if ($by_username) { // Show only for lost password
84 84
             $user_account_list = self::get_user_account_list($user, false, $by_username); // BODY
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
             }
98 98
         }
99 99
 
100
-        $email_body = get_lang('YourAccountParam') . " " . $portal_url . "\n\n$user_account_list";
100
+        $email_body = get_lang('YourAccountParam')." ".$portal_url."\n\n$user_account_list";
101 101
         // SEND MESSAGE
102 102
         $sender_name = api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'), null, PERSON_NAME_EMAIL_ADDRESS);
103 103
         $email_admin = api_get_setting('emailAdministrator');
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
      */
132 132
     public static function handle_encrypted_password($user, $by_username = false)
133 133
     {
134
-        $email_subject = "[" . api_get_setting('siteName') . "] " . get_lang('LoginRequest'); // SUBJECT
134
+        $email_subject = "[".api_get_setting('siteName')."] ".get_lang('LoginRequest'); // SUBJECT
135 135
 
136 136
         if ($by_username) {
137 137
         // Show only for lost password
@@ -141,11 +141,11 @@  discard block
 block discarded – undo
141 141
             $user_account_list = self::get_user_account_list($user, true); // BODY
142 142
             $email_to = $user[0]['email'];
143 143
         }
144
-        $email_body = get_lang('DearUser') . " :\n" . get_lang('password_request') . "\n";
145
-        $email_body .= $user_account_list . "\n-----------------------------------------------\n\n";
144
+        $email_body = get_lang('DearUser')." :\n".get_lang('password_request')."\n";
145
+        $email_body .= $user_account_list."\n-----------------------------------------------\n\n";
146 146
         $email_body .= get_lang('PasswordEncryptedForSecurity');
147 147
 
148
-        $email_body .= "\n\n" . get_lang('SignatureFormula') . ",\n" . api_get_setting('administratorName') . " " . api_get_setting('administratorSurname') . "\n" . get_lang('PlataformAdmin') . " - " . api_get_setting('siteName');
148
+        $email_body .= "\n\n".get_lang('SignatureFormula').",\n".api_get_setting('administratorName')." ".api_get_setting('administratorSurname')."\n".get_lang('PlataformAdmin')." - ".api_get_setting('siteName');
149 149
 
150 150
         $sender_name = api_get_person_name(
151 151
             api_get_setting('administratorName'),
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
                     username AS loginName,
239 239
                     password,
240 240
                     email
241
-                FROM " . $tbl_user . "
241
+                FROM " . $tbl_user."
242 242
                 WHERE user_id = $id";
243 243
         $result = Database::query($sql);
244 244
         $num_rows = Database::num_rows($result);
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
                         ON user.user_id = a.user_id
292 292
                         LEFT JOIN $track_e_login login
293 293
                         ON user.user_id  = login.login_user_id
294
-                        WHERE user.user_id = '" . $_user['user_id'] . "'
294
+                        WHERE user.user_id = '".$_user['user_id']."'
295 295
                         ORDER BY login.login_date DESC LIMIT 1";
296 296
 
297 297
                 $result = Database::query($sql);
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
                     Session::write('is_platformAdmin', $is_platformAdmin);
322 322
                     Session::write('is_allowedCreateCourse', $is_allowedCreateCourse);
323 323
                 } else {
324
-                    header('location:' . api_get_path(WEB_PATH));
324
+                    header('location:'.api_get_path(WEB_PATH));
325 325
                     //exit("WARNING UNDEFINED UID !! ");
326 326
                 }
327 327
             } else { // no uid => logout or Anonymous
@@ -368,9 +368,9 @@  discard block
 block discarded – undo
368 368
         global $_course;
369 369
         global $_real_cid;
370 370
 
371
-        global $is_courseAdmin;  //course teacher
372
-        global $is_courseTutor;  //course teacher - some rights
373
-        global $is_courseCoach;  //course coach
371
+        global $is_courseAdmin; //course teacher
372
+        global $is_courseTutor; //course teacher - some rights
373
+        global $is_courseCoach; //course coach
374 374
         global $is_courseMember; //course student
375 375
         global $is_sessionAdmin;
376 376
         global $is_allowed_in_course;
@@ -427,7 +427,7 @@  discard block
 block discarded – undo
427 427
 
428 428
                     if (!empty($_GET['id_session'])) {
429 429
                         $_SESSION['id_session'] = intval($_GET['id_session']);
430
-                        $sql = 'SELECT name FROM ' . $tbl_session . ' WHERE id="' . intval($_SESSION['id_session']) . '"';
430
+                        $sql = 'SELECT name FROM '.$tbl_session.' WHERE id="'.intval($_SESSION['id_session']).'"';
431 431
                         $rs = Database::query($sql);
432 432
                         list($_SESSION['session_name']) = Database::fetch_array($rs);
433 433
                     } else {
@@ -443,7 +443,7 @@  discard block
 block discarded – undo
443 443
                     }
444 444
                 } else {
445 445
                     //exit("WARNING UNDEFINED CID !! ");
446
-                    header('location:' . api_get_path(WEB_PATH));
446
+                    header('location:'.api_get_path(WEB_PATH));
447 447
                 }
448 448
             } else {
449 449
                 Session::erase('_cid');
@@ -470,7 +470,7 @@  discard block
 block discarded – undo
470 470
         } else {
471 471
             // Continue with the previous values
472 472
             if (empty($_SESSION['_course']) OR empty($_SESSION['_cid'])) { //no previous values...
473
-                $_cid = -1;        //set default values that will be caracteristic of being unset
473
+                $_cid = -1; //set default values that will be caracteristic of being unset
474 474
                 $_course = -1;
475 475
             } else {
476 476
                 $_cid = $_SESSION['_cid'];
@@ -480,7 +480,7 @@  discard block
 block discarded – undo
480 480
                 // Moreover, if we want to track a course with another session it can be usefull
481 481
                 if (!empty($_GET['id_session'])) {
482 482
                     $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
483
-                    $sql = 'SELECT name FROM ' . $tbl_session . ' WHERE id="' . intval($_SESSION['id_session']) . '"';
483
+                    $sql = 'SELECT name FROM '.$tbl_session.' WHERE id="'.intval($_SESSION['id_session']).'"';
484 484
                     $rs = Database::query($sql);
485 485
                     list($_SESSION['session_name']) = Database::fetch_array($rs);
486 486
                     $_SESSION['id_session'] = intval($_GET['id_session']);
@@ -520,9 +520,9 @@  discard block
 block discarded – undo
520 520
                             //But only if the login date is < than now + max_life_time
521 521
                             $sql = "SELECT course_access_id FROM $course_tracking_table
522 522
                                     WHERE
523
-                                        user_id     = " . intval($_user ['user_id']) . " AND
523
+                                        user_id     = ".intval($_user ['user_id'])." AND
524 524
                                         c_id = '".api_get_course_int_id()."' AND
525
-                                        session_id  = " . api_get_session_id() . " AND
525
+                                        session_id  = " . api_get_session_id()." AND
526 526
                                         login_course_date > now() - INTERVAL $session_lifetime SECOND
527 527
                                     ORDER BY login_course_date DESC LIMIT 0,1";
528 528
                             $result = Database::query($sql);
@@ -532,11 +532,11 @@  discard block
 block discarded – undo
532 532
                                 //We update the course tracking table
533 533
                                 $sql = "UPDATE $course_tracking_table
534 534
                                         SET logout_course_date = '$time', counter = counter+1
535
-                                        WHERE course_access_id = " . intval($i_course_access_id) . " AND session_id = " . api_get_session_id();
535
+                                        WHERE course_access_id = ".intval($i_course_access_id)." AND session_id = ".api_get_session_id();
536 536
                                 Database::query($sql);
537 537
                             } else {
538
-                                $sql = "INSERT INTO $course_tracking_table (c_id, user_id, login_course_date, logout_course_date, counter, session_id)" .
539
-                                        "VALUES('" . api_get_course_int_id() . "', '" . $_user['user_id'] . "', '$time', '$time', '1','" . api_get_session_id() . "')";
538
+                                $sql = "INSERT INTO $course_tracking_table (c_id, user_id, login_course_date, logout_course_date, counter, session_id)".
539
+                                        "VALUES('".api_get_course_int_id()."', '".$_user['user_id']."', '$time', '$time', '1','".api_get_session_id()."')";
540 540
                                 Database::query($sql);
541 541
                             }
542 542
                         }
@@ -564,8 +564,8 @@  discard block
 block discarded – undo
564 564
                 $course_user_table = Database::get_main_table(TABLE_MAIN_COURSE_USER);
565 565
                 $sql = "SELECT * FROM $course_user_table
566 566
                        WHERE
567
-                        user_id  = '" . $user_id . "' AND
568
-                        relation_type <> " . COURSE_RELATION_TYPE_RRHH . " AND
567
+                        user_id  = '".$user_id."' AND
568
+                        relation_type <> " . COURSE_RELATION_TYPE_RRHH." AND
569 569
                         course_code = '$course_id'";
570 570
                 $result = Database::query($sql);
571 571
 
@@ -585,8 +585,8 @@  discard block
 block discarded – undo
585 585
                             $session_id
586 586
                         );
587 587
                         if (!$user_is_subscribed) {
588
-                            $url = api_get_path(WEB_CODE_PATH) . 'course_info/legal.php?course_code=' . $_course['code'] . '&session_id=' . $session_id;
589
-                            header('Location: ' . $url);
588
+                            $url = api_get_path(WEB_CODE_PATH).'course_info/legal.php?course_code='.$_course['code'].'&session_id='.$session_id;
589
+                            header('Location: '.$url);
590 590
                             exit;
591 591
                         }
592 592
                     }
@@ -627,11 +627,11 @@  discard block
 block discarded – undo
627 627
                         } else {
628 628
                             //Im a coach or a student?
629 629
                             $sql = "SELECT user_id, status
630
-                                    FROM " . $tbl_session_course_user . "
630
+                                    FROM " . $tbl_session_course_user."
631 631
                                     WHERE
632 632
                                         c_id = '$_cid' AND
633
-                                        user_id = '" . $user_id . "' AND
634
-                                        session_id = '" . $session_id . "'
633
+                                        user_id = '".$user_id."' AND
634
+                                        session_id = '" . $session_id."'
635 635
                                     LIMIT 1";
636 636
                             $result = Database::query($sql);
637 637
 
@@ -777,7 +777,7 @@  discard block
 block discarded – undo
777 777
         if ($reset) { // session data refresh requested
778 778
             if ($group_id && $_cid && !empty($_course['real_id'])) { // have keys to search data
779 779
                 $group_table = Database::get_course_table(TABLE_GROUP);
780
-                $sql = "SELECT * FROM $group_table WHERE c_id = " . $_course['real_id'] . " AND id = '$group_id'";
780
+                $sql = "SELECT * FROM $group_table WHERE c_id = ".$_course['real_id']." AND id = '$group_id'";
781 781
                 $result = Database::query($sql);
782 782
                 if (Database::num_rows($result) > 0) { // This group has recorded status related to this course
783 783
                     $gpData = Database::fetch_array($result);
@@ -830,7 +830,7 @@  discard block
 block discarded – undo
830 830
      */
831 831
     public static function get_user_accounts_by_username($username)
832 832
     {
833
-        if (strpos($username,'@')){
833
+        if (strpos($username, '@')) {
834 834
             $username = api_strtolower($username);
835 835
             $email = true;
836 836
         } else {
Please login to merge, or discard this patch.
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -852,14 +852,14 @@  discard block
 block discarded – undo
852 852
             $email = false;
853 853
         }
854 854
 
855
-		if ($email) {
856
-			$condition = "LOWER(email) = '".Database::escape_string($username)."' ";
857
-		} else {
855
+        if ($email) {
856
+            $condition = "LOWER(email) = '".Database::escape_string($username)."' ";
857
+        } else {
858 858
             $condition = "LOWER(username) = '".Database::escape_string($username)."'";
859 859
         }
860 860
 
861
-		$tbl_user = Database :: get_main_table(TABLE_MAIN_USER);
862
-		$query = "SELECT 
861
+        $tbl_user = Database :: get_main_table(TABLE_MAIN_USER);
862
+        $query = "SELECT 
863 863
 		            user_id AS uid, 
864 864
 		            lastname AS lastName, 
865 865
 		            firstname AS firstName, 
@@ -874,7 +874,7 @@  discard block
 block discarded – undo
874 874
                     auth_source
875 875
 				 FROM $tbl_user
876 876
 				 WHERE ( $condition AND active = 1) ";
877
-		$result = Database::query($query);
877
+        $result = Database::query($query);
878 878
         $num_rows = Database::num_rows($result);
879 879
         if ($result && $num_rows > 0) {
880 880
             return Database::fetch_assoc($result);
Please login to merge, or discard this patch.
main/inc/lib/model.lib.php 1 patch
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -25,6 +25,7 @@
 block discarded – undo
25 25
 
26 26
     /**
27 27
      * Useful finder - experimental akelos like only use in notification.lib.php send function
28
+     * @param string $type
28 29
      */
29 30
     public function find($type, $options = null)
30 31
     {
Please login to merge, or discard this patch.
main/inc/lib/myspace.lib.php 3 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -634,7 +634,6 @@  discard block
 block discarded – undo
634 634
      * @param   int $sessionId  The session ID
635 635
      * @param   int $courseId   The course ID
636 636
      * @param   int $exerciseId The quiz ID
637
-     * @param   int $answer Answer status (0 = incorrect, 1 = correct, 2 = both)
638 637
      * @return  string  HTML array of results formatted for gridJS
639 638
      * @author César Perales <[email protected]>, Beeznest Team
640 639
      */
@@ -1222,6 +1221,7 @@  discard block
 block discarded – undo
1222 1221
      * @param int Number of items to select
1223 1222
      * @param string Column to order on
1224 1223
      * @param string Order direction
1224
+     * @param integer $number_of_items
1225 1225
      * @return array Results
1226 1226
      */
1227 1227
     public static function get_course_data_tracking_overview($from, $number_of_items, $column, $direction)
@@ -1556,6 +1556,7 @@  discard block
 block discarded – undo
1556 1556
      * @param int Number of items to select
1557 1557
      * @param string Column to order on
1558 1558
      * @param string Order direction
1559
+     * @param integer $number_of_items
1559 1560
      * @return array Results
1560 1561
      */
1561 1562
     public static function get_session_data_tracking_overview($from, $number_of_items, $column, $direction)
@@ -1576,7 +1577,6 @@  discard block
 block discarded – undo
1576 1577
     /**
1577 1578
      * Fills in session reporting data
1578 1579
      *
1579
-     * @param integer $user_id the id of the user
1580 1580
      * @param array $url_params additonal url parameters
1581 1581
      * @param array $row the row information (the other columns)
1582 1582
      * @return string html code
@@ -2206,6 +2206,7 @@  discard block
 block discarded – undo
2206 2206
      * @author Patrick Cool <[email protected]>, Ghent University, Belgium
2207 2207
      * @version Dokeos 1.8.6
2208 2208
      * @since October 2008
2209
+     * @param integer $number_of_items
2209 2210
      */
2210 2211
     public static function get_user_data_tracking_overview($from, $number_of_items, $column, $direction)
2211 2212
     {
@@ -2308,7 +2309,6 @@  discard block
 block discarded – undo
2308 2309
     /**
2309 2310
      * Checks if there are repeted users in a given array
2310 2311
      * @param  array $usernames list of the usernames in the uploaded file
2311
-     * @param  array $user_array['username'] and $user_array['sufix'] where sufix is the number part in a login i.e -> jmontoya2
2312 2312
      * @return array with the $usernames array and the $user_array array
2313 2313
      * @author Julio Montoya Armas
2314 2314
      */
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -2097,7 +2097,9 @@
 block discarded – undo
2097 2097
                 FROM $tbl_course course
2098 2098
                 WHERE course.code IN (".implode(',',$courses_code).")";
2099 2099
 
2100
-        if (!in_array($direction, array('ASC','DESC'))) $direction = 'ASC';
2100
+        if (!in_array($direction, array('ASC','DESC'))) {
2101
+            $direction = 'ASC';
2102
+        }
2101 2103
 
2102 2104
         $column = intval($column);
2103 2105
         $from = intval($from);
Please login to merge, or discard this patch.
Spacing   +168 added lines, -168 removed lines patch added patch discarded remove patch
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
         $session_id  = intval($session_id);
135 135
 
136 136
         $sql = 'SELECT login_course_date, logout_course_date
137
-                FROM ' . $tbl_track_course . '
137
+                FROM ' . $tbl_track_course.'
138 138
                 WHERE
139 139
                     user_id = '.$user_id.' AND
140 140
                     c_id = '.$courseId.' AND
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
         foreach ($course_list as $course_item) {
174 174
             $courseInfo = api_get_course_info($course_item['code']);
175 175
             $courseId = $courseInfo['real_id'];
176
-            $new_course_list[] =  '"'.$courseId.'"';
176
+            $new_course_list[] = '"'.$courseId.'"';
177 177
         }
178 178
         $course_list = implode(', ', $new_course_list);
179 179
 
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
             return false;
182 182
         }
183 183
         $sql = 'SELECT login_course_date, logout_course_date, c_id
184
-                FROM ' . $tbl_track_course . '
184
+                FROM ' . $tbl_track_course.'
185 185
                 WHERE
186 186
                     user_id = '.$user_id.' AND
187 187
                     c_id IN ('.$course_list.') AND
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
             // student score
260 260
             $avg_score = Tracking :: get_avg_student_score($user_id, $courseCode);
261 261
             if (is_numeric($avg_score)) {
262
-                $avg_score = round($avg_score,2);
262
+                $avg_score = round($avg_score, 2);
263 263
             } else {
264 264
                 $$avg_score = '-';
265 265
             }
@@ -295,7 +295,7 @@  discard block
 block discarded – undo
295 295
 
296 296
         $t_head = '    <table style="width: 100%;border:0;padding:0;border-collapse:collapse;table-layout: fixed">';
297 297
         //$t_head .= '  <caption>'.get_lang('CourseInformation').'</caption>';
298
-        $t_head .=      '<tr>';
298
+        $t_head .= '<tr>';
299 299
         $t_head .= '        <th width="155px" style="border-left:0;border-bottom:0"><span>'.get_lang('Course').'</span></th>';
300 300
         $t_head .= '        <th style="padding:0;border-bottom:0"><span>'.cut(get_lang('AvgTimeSpentInTheCourse'), 6, true).'</span></th>';
301 301
         $t_head .= '        <th style="padding:0;border-bottom:0"><span>'.cut(get_lang('AvgStudentsProgress'), 6, true).'</span></th>';
@@ -313,7 +313,7 @@  discard block
 block discarded – undo
313 313
 
314 314
         $addparams = array('view' => 'admin', 'display' => 'user');
315 315
 
316
-        $table = new SortableTable('tracking_user_overview', array('MySpace','get_number_of_users_tracking_overview'), array('MySpace','get_user_data_tracking_overview'), 0);
316
+        $table = new SortableTable('tracking_user_overview', array('MySpace', 'get_number_of_users_tracking_overview'), array('MySpace', 'get_user_data_tracking_overview'), 0);
317 317
         $table->additional_parameters = $addparams;
318 318
 
319 319
         $table->set_header(0, get_lang('OfficialCode'), true, array('style' => 'font-size:8pt'), array('style' => 'font-size:8pt'));
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
         }
327 327
         $table->set_header(3, get_lang('LoginName'), true, array('style' => 'font-size:8pt'), array('style' => 'font-size:8pt'));
328 328
         $table->set_header(4, $t_head, false, array('style' => 'width:90%;border:0;padding:0;font-size:7.5pt;'), array('style' => 'width:90%;padding:0;font-size:7.5pt;'));
329
-        $table->set_column_filter(4, array('MySpace','course_info_tracking_filter'));
329
+        $table->set_column_filter(4, array('MySpace', 'course_info_tracking_filter'));
330 330
         $table->display();
331 331
     }
332 332
 
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
         $table -> set_header(7, get_lang('Sessions'), false);
372 372
 
373 373
         if ($is_western_name_order) {
374
-            $csv_header[] = array (
374
+            $csv_header[] = array(
375 375
                 get_lang('FirstName', ''),
376 376
                 get_lang('LastName', ''),
377 377
                 get_lang('TimeSpentOnThePlatform', ''),
@@ -381,7 +381,7 @@  discard block
 block discarded – undo
381 381
                 get_lang('NumberOfSessions', '')
382 382
             );
383 383
         } else {
384
-            $csv_header[] = array (
384
+            $csv_header[] = array(
385 385
                 get_lang('LastName', ''),
386 386
                 get_lang('FirstName', ''),
387 387
                 get_lang('TimeSpentOnThePlatform', ''),
@@ -523,9 +523,9 @@  discard block
 block discarded – undo
523 523
 
524 524
         if ($tracking_column != 3) {
525 525
             if ($tracking_direction == 'DESC') {
526
-                usort($all_datas, array('MySpace','rsort_users'));
526
+                usort($all_datas, array('MySpace', 'rsort_users'));
527 527
             } else {
528
-                usort($all_datas, array('MySpace','sort_users'));
528
+                usort($all_datas, array('MySpace', 'sort_users'));
529 529
             }
530 530
         }
531 531
 
@@ -584,7 +584,7 @@  discard block
 block discarded – undo
584 584
         /**
585 585
          * Column config
586 586
          */
587
-        $column_model   = array(
587
+        $column_model = array(
588 588
             array(
589 589
                 'name' => 'username',
590 590
                 'index' => 'username',
@@ -625,7 +625,7 @@  discard block
 block discarded – undo
625 625
 
626 626
         $action_links = '';
627 627
         // jqgrid will use this URL to do the selects
628
-        $url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_session_lp_progress&session_id=' . $sessionId . '&course_id=' . $courseId . '&date_to=' . $date_to . '&date_from=' . $date_from;
628
+        $url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_session_lp_progress&session_id='.$sessionId.'&course_id='.$courseId.'&date_to='.$date_to.'&date_from='.$date_from;
629 629
 
630 630
         //Table Id
631 631
         $tableId = 'lpProgress';
@@ -647,11 +647,11 @@  discard block
 block discarded – undo
647 647
             true
648 648
         );
649 649
 
650
-        $return = '<script>$(function() {'. $table .
650
+        $return = '<script>$(function() {'.$table.
651 651
             'jQuery("#'.$tableId.'").jqGrid("navGrid","#'.$tableId.'_pager",{view:false, edit:false, add:false, del:false, search:false, excel:true});
652 652
                 jQuery("#'.$tableId.'").jqGrid("navButtonAdd","#'.$tableId.'_pager",{
653 653
                        caption:"",
654
-                       title:"' . get_lang('ExportExcel') . '",
654
+                       title:"' . get_lang('ExportExcel').'",
655 655
                        onClickButton : function () {
656 656
                            jQuery("#'.$tableId.'").jqGrid("excelExport",{"url":"'.$url.'&export_format=xls"});
657 657
                        }
@@ -701,7 +701,7 @@  discard block
 block discarded – undo
701 701
         /**
702 702
          * Column config
703 703
          */
704
-        $column_model   = array(
704
+        $column_model = array(
705 705
             array('name'=>'session', 'index'=>'session', 'align'=>'left', 'search' => 'true', 'wrap_cell' => "true"),
706 706
             array('name'=>'exercise_id', 'index'=>'exercise_id', 'align'=>'left', 'search' => 'true'),
707 707
             array('name'=>'quiz_title', 'index'=>'quiz_title', 'align'=>'left', 'search' => 'true'),
@@ -718,7 +718,7 @@  discard block
 block discarded – undo
718 718
         //get dynamic column names
719 719
 
720 720
         // jqgrid will use this URL to do the selects
721
-        $url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_exercise_progress&session_id=' . $sessionId . '&course_id=' . $courseId  . '&exercise_id=' . $exerciseId . '&date_to=' . $date_to . '&date_from=' . $date_from;
721
+        $url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_exercise_progress&session_id='.$sessionId.'&course_id='.$courseId.'&exercise_id='.$exerciseId.'&date_to='.$date_to.'&date_from='.$date_from;
722 722
 
723 723
         // Autowidth
724 724
         $extra_params['autowidth'] = 'true';
@@ -729,11 +729,11 @@  discard block
 block discarded – undo
729 729
         $tableId = 'exerciseProgressOverview';
730 730
         $table = Display::grid_js($tableId, $url, $columns, $column_model, $extra_params, array(), '', true);
731 731
 
732
-        $return = '<script>$(function() {'. $table .
732
+        $return = '<script>$(function() {'.$table.
733 733
             'jQuery("#'.$tableId.'").jqGrid("navGrid","#'.$tableId.'_pager",{view:false, edit:false, add:false, del:false, search:false, excel:true});
734 734
                 jQuery("#'.$tableId.'").jqGrid("navButtonAdd","#'.$tableId.'_pager",{
735 735
                        caption:"",
736
-                       title:"' . get_lang('ExportExcel') . '",
736
+                       title:"' . get_lang('ExportExcel').'",
737 737
                        onClickButton : function () {
738 738
                            jQuery("#'.$tableId.'").jqGrid("excelExport",{"url":"'.$url.'&export_format=xls"});
739 739
                        }
@@ -819,8 +819,8 @@  discard block
 block discarded – undo
819 819
 
820 820
                     $column[] = $title;
821 821
                     $column_model[] = array(
822
-                        'name' => 'exer' . $i,
823
-                        'index' => 'exer' . $i,
822
+                        'name' => 'exer'.$i,
823
+                        'index' => 'exer'.$i,
824 824
                         'align' => 'center',
825 825
                         'search' => 'true',
826 826
                         'wrap_cell' => "true"
@@ -832,7 +832,7 @@  discard block
 block discarded – undo
832 832
 
833 833
         //end get dynamic column names
834 834
         // jqgrid will use this URL to do the selects
835
-        $url = api_get_path(WEB_AJAX_PATH) . 'model.ajax.php?a=get_exercise_grade&session_id=' . $sessionId . '&course_id=' . $courseId;
835
+        $url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_exercise_grade&session_id='.$sessionId.'&course_id='.$courseId;
836 836
 
837 837
         // Autowidth
838 838
         $extra_params['autowidth'] = 'true';
@@ -843,13 +843,13 @@  discard block
 block discarded – undo
843 843
         $tableId = 'exerciseGradeOverview';
844 844
         $table = Display::grid_js($tableId, $url, $column, $column_model, $extra_params, array(), '', true);
845 845
 
846
-        $return = '<script>$(function() {' . $table .
847
-            'jQuery("#' . $tableId . '").jqGrid("navGrid","#' . $tableId . '_pager",{view:false, edit:false, add:false, del:false, search:false, excel:true});
848
-                jQuery("#' . $tableId . '").jqGrid("navButtonAdd","#' . $tableId . '_pager",{
846
+        $return = '<script>$(function() {'.$table.
847
+            'jQuery("#'.$tableId.'").jqGrid("navGrid","#'.$tableId.'_pager",{view:false, edit:false, add:false, del:false, search:false, excel:true});
848
+                jQuery("#' . $tableId.'").jqGrid("navButtonAdd","#'.$tableId.'_pager",{
849 849
                        caption:"",
850
-                       title:"' . get_lang('ExportExcel') . '",
850
+                       title:"' . get_lang('ExportExcel').'",
851 851
                        onClickButton : function () {
852
-                           jQuery("#' . $tableId . '").jqGrid("excelExport",{"url":"' . $url . '&export_format=xls"});
852
+                           jQuery("#' . $tableId.'").jqGrid("excelExport",{"url":"'.$url.'&export_format=xls"});
853 853
                        }
854 854
                 });
855 855
             });</script>';
@@ -882,10 +882,10 @@  discard block
 block discarded – undo
882 882
         /**
883 883
          * Column config
884 884
          */
885
-        $column_model   = array(
886
-            array('name'=>'username',   'index'=>'username',    'align'=>'left', 'search' => 'true', 'wrap_cell' => "true"),
887
-            array('name'=>'firstname',  'index'=>'firstname',   'align'=>'left', 'search' => 'true'),
888
-            array('name'=>'lastname',   'index'=>'lastname',    'align'=>'left', 'search' => 'true'),
885
+        $column_model = array(
886
+            array('name'=>'username', 'index'=>'username', 'align'=>'left', 'search' => 'true', 'wrap_cell' => "true"),
887
+            array('name'=>'firstname', 'index'=>'firstname', 'align'=>'left', 'search' => 'true'),
888
+            array('name'=>'lastname', 'index'=>'lastname', 'align'=>'left', 'search' => 'true'),
889 889
         );
890 890
         //get dinamic column names
891 891
         foreach ($questions as $question_id => $question) {
@@ -901,7 +901,7 @@  discard block
 block discarded – undo
901 901
         $action_links = '';
902 902
 
903 903
         // jqgrid will use this URL to do the selects
904
-        $url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_survey_overview&session_id=' . $sessionId . '&course_id=' . $courseId . '&survey_id=' . $surveyId . '&date_to=' . $date_to . '&date_from=' . $date_from;
904
+        $url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_survey_overview&session_id='.$sessionId.'&course_id='.$courseId.'&survey_id='.$surveyId.'&date_to='.$date_to.'&date_from='.$date_from;
905 905
 
906 906
         // Table Id
907 907
         $tableId = 'lpProgress';
@@ -923,11 +923,11 @@  discard block
 block discarded – undo
923 923
             true
924 924
         );
925 925
 
926
-        $return = '<script>$(function() {'. $table .
926
+        $return = '<script>$(function() {'.$table.
927 927
             'jQuery("#'.$tableId.'").jqGrid("navGrid","#'.$tableId.'_pager",{view:false, edit:false, add:false, del:false, search:false, excel:true});
928 928
                 jQuery("#'.$tableId.'").jqGrid("navButtonAdd","#'.$tableId.'_pager",{
929 929
                        caption:"",
930
-                       title:"' . get_lang('ExportExcel') . '",
930
+                       title:"' . get_lang('ExportExcel').'",
931 931
                        onClickButton : function () {
932 932
                            jQuery("#'.$tableId.'").jqGrid("excelExport",{"url":"'.$url.'&export_format=xls"});
933 933
                        }
@@ -942,7 +942,7 @@  discard block
 block discarded – undo
942 942
      * Display a sortable table that contains an overview off all the progress of the user in a session
943 943
      * @author César Perales <[email protected]>, Beeznest Team
944 944
      */
945
-    static function display_tracking_progress_overview($sessionId = 0, $courseId = 0,  $date_from, $date_to)
945
+    static function display_tracking_progress_overview($sessionId = 0, $courseId = 0, $date_from, $date_to)
946 946
     {
947 947
         //The order is important you need to check the the $column variable in the model.ajax.php file
948 948
         $columns = array(
@@ -992,55 +992,55 @@  discard block
 block discarded – undo
992 992
         );
993 993
 
994 994
         //Column config
995
-        $column_model   = array(
996
-            array('name'=>'lastname',   'index'=>'lastname',     'align'=>'left'),
997
-            array('name'=>'firstname',  'index'=>'firstname',    'align'=>'left'),
998
-            array('name'=>'username',   'index'=>'username',     'align'=>'left'),
995
+        $column_model = array(
996
+            array('name'=>'lastname', 'index'=>'lastname', 'align'=>'left'),
997
+            array('name'=>'firstname', 'index'=>'firstname', 'align'=>'left'),
998
+            array('name'=>'username', 'index'=>'username', 'align'=>'left'),
999 999
             #array('name'=>'profile',   'index'=>'username',     'align'=>'left'),
1000
-            array('name'=>'total',      'index'=>'total',        'align'=>'left'),
1001
-            array('name'=>'courses',    'index'=>'courses',      'align'=>'left', 'sortable' => 'false'),
1002
-            array('name'=>'lessons',    'index'=>'lessons',      'align'=>'left', 'sortable' => 'false'),
1003
-            array('name'=>'exercises',  'index'=>'exercises',    'align'=>'left', 'sortable' => 'false'),
1004
-            array('name'=>'forums',     'index'=>'forums',       'align'=>'left', 'sortable' => 'false'),
1005
-            array('name'=>'homeworks',  'index'=>'homeworks',    'align'=>'left', 'sortable' => 'false'),
1006
-            array('name'=>'wikis',      'index'=>'wikis',        'align'=>'left', 'sortable' => 'false'),
1007
-            array('name'=>'surveys',    'index'=>'surveys',      'align'=>'left', 'sortable' => 'false'),
1000
+            array('name'=>'total', 'index'=>'total', 'align'=>'left'),
1001
+            array('name'=>'courses', 'index'=>'courses', 'align'=>'left', 'sortable' => 'false'),
1002
+            array('name'=>'lessons', 'index'=>'lessons', 'align'=>'left', 'sortable' => 'false'),
1003
+            array('name'=>'exercises', 'index'=>'exercises', 'align'=>'left', 'sortable' => 'false'),
1004
+            array('name'=>'forums', 'index'=>'forums', 'align'=>'left', 'sortable' => 'false'),
1005
+            array('name'=>'homeworks', 'index'=>'homeworks', 'align'=>'left', 'sortable' => 'false'),
1006
+            array('name'=>'wikis', 'index'=>'wikis', 'align'=>'left', 'sortable' => 'false'),
1007
+            array('name'=>'surveys', 'index'=>'surveys', 'align'=>'left', 'sortable' => 'false'),
1008 1008
             //Lessons
1009
-            array('name'=>'lessons_total',    'index'=>'lessons_total',      'align'=>'center', 'sortable' => 'false'),
1010
-            array('name'=>'lessons_done',     'index'=>'lessons_done',       'align'=>'center', 'sortable' => 'false'),
1011
-            array('name'=>'lessons_left',     'index'=>'lessons_left',       'align'=>'center', 'sortable' => 'false'),
1012
-            array('name'=>'lessons_progress', 'index'=>'lessons_progress',   'align'=>'center', 'sortable' => 'false'),
1009
+            array('name'=>'lessons_total', 'index'=>'lessons_total', 'align'=>'center', 'sortable' => 'false'),
1010
+            array('name'=>'lessons_done', 'index'=>'lessons_done', 'align'=>'center', 'sortable' => 'false'),
1011
+            array('name'=>'lessons_left', 'index'=>'lessons_left', 'align'=>'center', 'sortable' => 'false'),
1012
+            array('name'=>'lessons_progress', 'index'=>'lessons_progress', 'align'=>'center', 'sortable' => 'false'),
1013 1013
             //Exercises
1014
-            array('name'=>'exercises_total',    'index'=>'exercises_total',      'align'=>'center', 'sortable' => 'false'),
1015
-            array('name'=>'exercises_done',     'index'=>'exercises_done',       'align'=>'center', 'sortable' => 'false'),
1016
-            array('name'=>'exercises_left',     'index'=>'exercises_left',       'align'=>'center', 'sortable' => 'false'),
1017
-            array('name'=>'exercises_progress', 'index'=>'exercises_progress',   'align'=>'center', 'sortable' => 'false'),
1014
+            array('name'=>'exercises_total', 'index'=>'exercises_total', 'align'=>'center', 'sortable' => 'false'),
1015
+            array('name'=>'exercises_done', 'index'=>'exercises_done', 'align'=>'center', 'sortable' => 'false'),
1016
+            array('name'=>'exercises_left', 'index'=>'exercises_left', 'align'=>'center', 'sortable' => 'false'),
1017
+            array('name'=>'exercises_progress', 'index'=>'exercises_progress', 'align'=>'center', 'sortable' => 'false'),
1018 1018
             //Assignments
1019
-            array('name'=>'forums_total',    'index'=>'forums_total',        'align'=>'center', 'sortable' => 'false'),
1020
-            array('name'=>'forums_done',     'index'=>'forums_done',         'align'=>'center', 'sortable' => 'false'),
1021
-            array('name'=>'forums_left',     'index'=>'forums_left',         'align'=>'center', 'sortable' => 'false'),
1022
-            array('name'=>'forums_progress', 'index'=>'forums_progress',     'align'=>'center', 'sortable' => 'false'),
1019
+            array('name'=>'forums_total', 'index'=>'forums_total', 'align'=>'center', 'sortable' => 'false'),
1020
+            array('name'=>'forums_done', 'index'=>'forums_done', 'align'=>'center', 'sortable' => 'false'),
1021
+            array('name'=>'forums_left', 'index'=>'forums_left', 'align'=>'center', 'sortable' => 'false'),
1022
+            array('name'=>'forums_progress', 'index'=>'forums_progress', 'align'=>'center', 'sortable' => 'false'),
1023 1023
             //Assignments
1024
-            array('name'=>'assigments_total',    'index'=>'assigments_total',        'align'=>'center', 'sortable' => 'false'),
1025
-            array('name'=>'assigments_done',     'index'=>'assigments_done',         'align'=>'center', 'sortable' => 'false'),
1026
-            array('name'=>'assigments_left',     'index'=>'assigments_left',         'align'=>'center', 'sortable' => 'false'),
1027
-            array('name'=>'assigments_progress', 'index'=>'assigments_progress',     'align'=>'center', 'sortable' => 'false'),
1024
+            array('name'=>'assigments_total', 'index'=>'assigments_total', 'align'=>'center', 'sortable' => 'false'),
1025
+            array('name'=>'assigments_done', 'index'=>'assigments_done', 'align'=>'center', 'sortable' => 'false'),
1026
+            array('name'=>'assigments_left', 'index'=>'assigments_left', 'align'=>'center', 'sortable' => 'false'),
1027
+            array('name'=>'assigments_progress', 'index'=>'assigments_progress', 'align'=>'center', 'sortable' => 'false'),
1028 1028
             //Assignments
1029
-            array('name'=>'wiki_total',         'index'=>'wiki_total',       'align'=>'center', 'sortable' => 'false'),
1030
-            array('name'=>'wiki_revisions',     'index'=>'wiki_revisions',   'align'=>'center', 'sortable' => 'false'),
1031
-            array('name'=>'wiki_read',          'index'=>'wiki_read',        'align'=>'center', 'sortable' => 'false'),
1032
-            array('name'=>'wiki_unread',        'index'=>'wiki_unread',      'align'=>'center', 'sortable' => 'false'),
1033
-            array('name'=>'wiki_progress',      'index'=>'wiki_progress',    'align'=>'center', 'sortable' => 'false'),
1029
+            array('name'=>'wiki_total', 'index'=>'wiki_total', 'align'=>'center', 'sortable' => 'false'),
1030
+            array('name'=>'wiki_revisions', 'index'=>'wiki_revisions', 'align'=>'center', 'sortable' => 'false'),
1031
+            array('name'=>'wiki_read', 'index'=>'wiki_read', 'align'=>'center', 'sortable' => 'false'),
1032
+            array('name'=>'wiki_unread', 'index'=>'wiki_unread', 'align'=>'center', 'sortable' => 'false'),
1033
+            array('name'=>'wiki_progress', 'index'=>'wiki_progress', 'align'=>'center', 'sortable' => 'false'),
1034 1034
             //Surveys
1035
-            array('name'=>'surveys_total',    'index'=>'surveys_total',      'align'=>'center', 'sortable' => 'false'),
1036
-            array('name'=>'surveys_done',     'index'=>'surveys_done',       'align'=>'center', 'sortable' => 'false'),
1037
-            array('name'=>'surveys_left',     'index'=>'surveys_left',       'align'=>'center', 'sortable' => 'false'),
1038
-            array('name'=>'surveys_progress', 'index'=>'surveys_progress',   'align'=>'center', 'sortable' => 'false'),
1035
+            array('name'=>'surveys_total', 'index'=>'surveys_total', 'align'=>'center', 'sortable' => 'false'),
1036
+            array('name'=>'surveys_done', 'index'=>'surveys_done', 'align'=>'center', 'sortable' => 'false'),
1037
+            array('name'=>'surveys_left', 'index'=>'surveys_left', 'align'=>'center', 'sortable' => 'false'),
1038
+            array('name'=>'surveys_progress', 'index'=>'surveys_progress', 'align'=>'center', 'sortable' => 'false'),
1039 1039
         );
1040 1040
 
1041 1041
         $action_links = '';
1042 1042
         // jqgrid will use this URL to do the selects
1043
-        $url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_session_progress&session_id=' . $sessionId . '&course_id=' . $courseId . '&date_to=' . $date_to . '&date_from=' . $date_from;
1043
+        $url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_session_progress&session_id='.$sessionId.'&course_id='.$courseId.'&date_to='.$date_to.'&date_from='.$date_from;
1044 1044
 
1045 1045
         //Table Id
1046 1046
         $tableId = 'progressOverview';
@@ -1100,11 +1100,11 @@  discard block
 block discarded – undo
1100 1100
             true
1101 1101
         );
1102 1102
 
1103
-        $return = '<script>$(function() {'. $table .
1103
+        $return = '<script>$(function() {'.$table.
1104 1104
             'jQuery("#'.$tableId.'").jqGrid("navGrid","#'.$tableId.'_pager",{view:false, edit:false, add:false, del:false, search:false, excel:true});
1105 1105
                 jQuery("#'.$tableId.'").jqGrid("navButtonAdd","#'.$tableId.'_pager",{
1106 1106
                        caption:"",
1107
-                       title:"' . get_lang('ExportExcel') . '",
1107
+                       title:"' . get_lang('ExportExcel').'",
1108 1108
                        onClickButton : function () {
1109 1109
                            jQuery("#'.$tableId.'").jqGrid("excelExport",{"url":"'.$url.'&export_format=xls"});
1110 1110
                        }
@@ -1164,7 +1164,7 @@  discard block
 block discarded – undo
1164 1164
                 // adding the fields that are checked to the session
1165 1165
                 $message = '';
1166 1166
                 foreach ($values as $field_ids => $value) {
1167
-                    if ($value == 1 && strstr($field_ids,'extra_export_field')) {
1167
+                    if ($value == 1 && strstr($field_ids, 'extra_export_field')) {
1168 1168
                         $_SESSION['additional_export_fields'][] = str_replace('extra_export_field', '', $field_ids);
1169 1169
                     }
1170 1170
                 }
@@ -1179,7 +1179,7 @@  discard block
 block discarded – undo
1179 1179
                 // Displaying a feedback message
1180 1180
                 if (!empty($_SESSION['additional_export_fields'])) {
1181 1181
                     Display::display_confirmation_message(get_lang('FollowingFieldsWillAlsoBeExported').': <br /><ul>'.$message.'</ul>', false);
1182
-                } else  {
1182
+                } else {
1183 1183
                     Display::display_confirmation_message(get_lang('NoAdditionalFieldsWillBeExported'), false);
1184 1184
                 }
1185 1185
             } else {
@@ -1207,7 +1207,7 @@  discard block
 block discarded – undo
1207 1207
     {
1208 1208
         $t_head = '    <table style="width: 100%;border:0;padding:0;border-collapse:collapse;table-layout: fixed">';
1209 1209
         //$t_head .= '  <caption>'.get_lang('CourseInformation').'</caption>';
1210
-        $t_head .=      '<tr>';
1210
+        $t_head .= '<tr>';
1211 1211
         $t_head .= '        <th style="padding:0;border-bottom:0"><span>'.cut(get_lang('AvgTimeSpentInTheCourse'), 6, true).'</span></th>';
1212 1212
         $t_head .= '        <th style="padding:0;border-bottom:0"><span>'.cut(get_lang('AvgStudentsProgress'), 6, true).'</span></th>';
1213 1213
         $t_head .= '        <th style="padding:0;border-bottom:0"><span>'.cut(get_lang('AvgCourseScore'), 6, true).'</span></th>';
@@ -1224,13 +1224,13 @@  discard block
 block discarded – undo
1224 1224
 
1225 1225
         $addparams = array('view' => 'admin', 'display' => 'courseoverview');
1226 1226
 
1227
-        $table = new SortableTable('tracking_session_overview', array('MySpace', 'get_total_number_courses'), array('MySpace','get_course_data_tracking_overview'), 1);
1227
+        $table = new SortableTable('tracking_session_overview', array('MySpace', 'get_total_number_courses'), array('MySpace', 'get_course_data_tracking_overview'), 1);
1228 1228
         $table->additional_parameters = $addparams;
1229 1229
 
1230 1230
         $table->set_header(0, '', false, null, array('style' => 'display: none'));
1231 1231
         $table->set_header(1, get_lang('Course'), true, array('style' => 'font-size:8pt'), array('style' => 'font-size:8pt'));
1232 1232
         $table->set_header(2, $t_head, false, array('style' => 'width:90%;border:0;padding:0;font-size:7.5pt;'), array('style' => 'width:90%;padding:0;font-size:7.5pt;'));
1233
-        $table->set_column_filter(2, array('MySpace','course_tracking_filter'));
1233
+        $table->set_column_filter(2, array('MySpace', 'course_tracking_filter'));
1234 1234
         $table->display();
1235 1235
     }
1236 1236
 
@@ -1266,7 +1266,7 @@  discard block
 block discarded – undo
1266 1266
         $sql .= " ORDER BY col$column $direction ";
1267 1267
         $sql .= " LIMIT $from,$number_of_items";
1268 1268
         $result = Database::query($sql);
1269
-        $return = array ();
1269
+        $return = array();
1270 1270
         while ($course = Database::fetch_row($result)) {
1271 1271
             $return[] = $course;
1272 1272
         }
@@ -1319,18 +1319,18 @@  discard block
 block discarded – undo
1319 1319
             $progress += $progress_tmp[0];
1320 1320
             $nb_progress_lp += $progress_tmp[1];
1321 1321
             $score_tmp = Tracking :: get_avg_student_score($row->user_id, $course_code, array(), null, true);
1322
-            if(is_array($score_tmp)) {
1322
+            if (is_array($score_tmp)) {
1323 1323
                 $score += $score_tmp[0];
1324 1324
                 $nb_score_lp += $score_tmp[1];
1325 1325
             }
1326 1326
             $nb_messages += Tracking::count_student_messages($row->user_id, $course_code);
1327 1327
             $nb_assignments += Tracking::count_student_assignments($row->user_id, $course_code);
1328 1328
             $last_login_date_tmp = Tracking :: get_last_connection_date_on_the_course($row->user_id, $courseInfo, null, false);
1329
-            if($last_login_date_tmp != false && $last_login_date == false) { // TODO: To be cleaned
1329
+            if ($last_login_date_tmp != false && $last_login_date == false) { // TODO: To be cleaned
1330 1330
                 $last_login_date = $last_login_date_tmp;
1331
-            } else if($last_login_date_tmp != false && $last_login_date != false) { // TODO: Repeated previous condition. To be cleaned.
1331
+            } else if ($last_login_date_tmp != false && $last_login_date != false) { // TODO: Repeated previous condition. To be cleaned.
1332 1332
                 // Find the max and assign it to first_login_date
1333
-                if(strtotime($last_login_date_tmp) > strtotime($last_login_date)) {
1333
+                if (strtotime($last_login_date_tmp) > strtotime($last_login_date)) {
1334 1334
                     $last_login_date = $last_login_date_tmp;
1335 1335
                 }
1336 1336
             }
@@ -1340,27 +1340,27 @@  discard block
 block discarded – undo
1340 1340
             $total_score_possible += $exercise_results_tmp['score_possible'];
1341 1341
             $total_questions_answered += $exercise_results_tmp['questions_answered'];
1342 1342
         }
1343
-        if($nb_progress_lp > 0) {
1343
+        if ($nb_progress_lp > 0) {
1344 1344
             $avg_progress = round($progress / $nb_progress_lp, 2);
1345 1345
         } else {
1346 1346
             $avg_progress = 0;
1347 1347
         }
1348
-        if($nb_score_lp > 0) {
1348
+        if ($nb_score_lp > 0) {
1349 1349
             $avg_score = round($score / $nb_score_lp, 2);
1350 1350
         } else {
1351 1351
             $avg_score = '-';
1352 1352
         }
1353
-        if($last_login_date) {
1353
+        if ($last_login_date) {
1354 1354
             $last_login_date = api_convert_and_format_date($last_login_date, DATE_FORMAT_SHORT, date_default_timezone_get());
1355 1355
         } else {
1356 1356
             $last_login_date = '-';
1357 1357
         }
1358
-        if($total_score_possible > 0) {
1358
+        if ($total_score_possible > 0) {
1359 1359
             $total_score_percentage = round($total_score_obtained / $total_score_possible * 100, 2);
1360 1360
         } else {
1361 1361
             $total_score_percentage = 0;
1362 1362
         }
1363
-        if($total_score_percentage > 0) {
1363
+        if ($total_score_percentage > 0) {
1364 1364
             $total_score = $total_score_obtained.'/'.$total_score_possible.' ('.$total_score_percentage.' %)';
1365 1365
         } else {
1366 1366
             $total_score = '-';
@@ -1468,7 +1468,7 @@  discard block
 block discarded – undo
1468 1468
                 $progress += $progress_tmp[0];
1469 1469
                 $nb_progress_lp += $progress_tmp[1];
1470 1470
                 $score_tmp = Tracking :: get_avg_student_score($row->user_id, $course_code, array(), null, true);
1471
-                if(is_array($score_tmp)) {
1471
+                if (is_array($score_tmp)) {
1472 1472
                     $score += $score_tmp[0];
1473 1473
                     $nb_score_lp += $score_tmp[1];
1474 1474
                 }
@@ -1476,11 +1476,11 @@  discard block
 block discarded – undo
1476 1476
                 $nb_assignments += Tracking::count_student_assignments($row->user_id, $course_code);
1477 1477
 
1478 1478
                 $last_login_date_tmp = Tracking::get_last_connection_date_on_the_course($row->user_id, $courseInfo, null, false);
1479
-                if($last_login_date_tmp != false && $last_login_date == false) { // TODO: To be cleaned.
1479
+                if ($last_login_date_tmp != false && $last_login_date == false) { // TODO: To be cleaned.
1480 1480
                     $last_login_date = $last_login_date_tmp;
1481
-                } else if($last_login_date_tmp != false && $last_login_date == false) { // TODO: Repeated previous condition. To be cleaned.
1481
+                } else if ($last_login_date_tmp != false && $last_login_date == false) { // TODO: Repeated previous condition. To be cleaned.
1482 1482
                     // Find the max and assign it to first_login_date
1483
-                    if(strtotime($last_login_date_tmp) > strtotime($last_login_date)) {
1483
+                    if (strtotime($last_login_date_tmp) > strtotime($last_login_date)) {
1484 1484
                         $last_login_date = $last_login_date_tmp;
1485 1485
                     }
1486 1486
                 }
@@ -1490,22 +1490,22 @@  discard block
 block discarded – undo
1490 1490
                 $total_score_possible += $exercise_results_tmp['score_possible'];
1491 1491
                 $total_questions_answered += $exercise_results_tmp['questions_answered'];
1492 1492
             }
1493
-            if($nb_progress_lp > 0) {
1493
+            if ($nb_progress_lp > 0) {
1494 1494
                 $avg_progress = round($progress / $nb_progress_lp, 2);
1495 1495
             } else {
1496 1496
                 $avg_progress = 0;
1497 1497
             }
1498
-            if($nb_score_lp > 0) {
1498
+            if ($nb_score_lp > 0) {
1499 1499
                 $avg_score = round($score / $nb_score_lp, 2);
1500 1500
             } else {
1501 1501
                 $avg_score = '-';
1502 1502
             }
1503
-            if($last_login_date) {
1503
+            if ($last_login_date) {
1504 1504
                 $last_login_date = api_convert_and_format_date($last_login_date, DATE_FORMAT_SHORT, date_default_timezone_get());
1505 1505
             } else {
1506 1506
                 $last_login_date = '-';
1507 1507
             }
1508
-            if($total_score_possible > 0) {
1508
+            if ($total_score_possible > 0) {
1509 1509
                 $total_score_percentage = round($total_score_obtained / $total_score_possible * 100, 2);
1510 1510
             } else {
1511 1511
                 $total_score_percentage = 0;
@@ -1541,7 +1541,7 @@  discard block
 block discarded – undo
1541 1541
     {
1542 1542
         $t_head = '    <table style="width: 100%;border:0;padding:0;border-collapse:collapse;table-layout: fixed">';
1543 1543
         //$t_head .= '  <caption>'.get_lang('CourseInformation').'</caption>';
1544
-        $t_head .=      '<tr>';
1544
+        $t_head .= '<tr>';
1545 1545
         $t_head .= '        <th width="155px" style="border-left:0;border-bottom:0"><span>'.get_lang('Course').'</span></th>';
1546 1546
         $t_head .= '        <th style="padding:0;border-bottom:0"><span>'.cut(get_lang('AvgTimeSpentInTheCourse'), 6, true).'</span></th>';
1547 1547
         $t_head .= '        <th style="padding:0;border-bottom:0"><span>'.cut(get_lang('AvgStudentsProgress'), 6, true).'</span></th>';
@@ -1559,7 +1559,7 @@  discard block
 block discarded – undo
1559 1559
 
1560 1560
         $addparams = array('view' => 'admin', 'display' => 'sessionoverview');
1561 1561
 
1562
-        $table = new SortableTable('tracking_session_overview', array('MySpace','get_total_number_sessions'), array('MySpace','get_session_data_tracking_overview'), 1);
1562
+        $table = new SortableTable('tracking_session_overview', array('MySpace', 'get_total_number_sessions'), array('MySpace', 'get_session_data_tracking_overview'), 1);
1563 1563
         $table->additional_parameters = $addparams;
1564 1564
 
1565 1565
         $table->set_header(0, '', false, null, array('style' => 'display: none'));
@@ -1598,7 +1598,7 @@  discard block
 block discarded – undo
1598 1598
         $sql .= " ORDER BY col$column $direction ";
1599 1599
         $sql .= " LIMIT $from,$number_of_items";
1600 1600
         $result = Database::query($sql);
1601
-        $return = array ();
1601
+        $return = array();
1602 1602
         while ($session = Database::fetch_row($result)) {
1603 1603
             $return[] = $session;
1604 1604
         }
@@ -1687,10 +1687,10 @@  discard block
 block discarded – undo
1687 1687
                 if ($last_login_date_tmp != false && $last_login_date == false) {
1688 1688
                     // TODO: To be cleaned.
1689 1689
                     $last_login_date = $last_login_date_tmp;
1690
-                } else if($last_login_date_tmp != false && $last_login_date != false) {
1690
+                } else if ($last_login_date_tmp != false && $last_login_date != false) {
1691 1691
                     // TODO: Repeated previous condition! To be cleaned.
1692 1692
                     // Find the max and assign it to first_login_date
1693
-                    if(strtotime($last_login_date_tmp) > strtotime($last_login_date)) {
1693
+                    if (strtotime($last_login_date_tmp) > strtotime($last_login_date)) {
1694 1694
                         $last_login_date = $last_login_date_tmp;
1695 1695
                     }
1696 1696
                 }
@@ -1700,27 +1700,27 @@  discard block
 block discarded – undo
1700 1700
                 $total_score_possible += $exercise_results_tmp['score_possible'];
1701 1701
                 $total_questions_answered += $exercise_results_tmp['questions_answered'];
1702 1702
             }
1703
-            if($nb_progress_lp > 0) {
1703
+            if ($nb_progress_lp > 0) {
1704 1704
                 $avg_progress = round($progress / $nb_progress_lp, 2);
1705 1705
             } else {
1706 1706
                 $avg_progress = 0;
1707 1707
             }
1708
-            if($nb_score_lp > 0) {
1708
+            if ($nb_score_lp > 0) {
1709 1709
                 $avg_score = round($score / $nb_score_lp, 2);
1710 1710
             } else {
1711 1711
                 $avg_score = '-';
1712 1712
             }
1713
-            if($last_login_date) {
1713
+            if ($last_login_date) {
1714 1714
                 $last_login_date = api_convert_and_format_date($last_login_date, DATE_FORMAT_SHORT, date_default_timezone_get());
1715 1715
             } else {
1716 1716
                 $last_login_date = '-';
1717 1717
             }
1718
-            if($total_score_possible > 0) {
1718
+            if ($total_score_possible > 0) {
1719 1719
                 $total_score_percentage = round($total_score_obtained / $total_score_possible * 100, 2);
1720 1720
             } else {
1721 1721
                 $total_score_percentage = 0;
1722 1722
             }
1723
-            if($total_score_percentage > 0) {
1723
+            if ($total_score_percentage > 0) {
1724 1724
                 $total_score = $total_score_obtained.'/'.$total_score_possible.' ('.$total_score_percentage.' %)';
1725 1725
             } else {
1726 1726
                 $total_score = '-';
@@ -1831,7 +1831,7 @@  discard block
 block discarded – undo
1831 1831
                 $total_score_obtained = 0;
1832 1832
                 $total_score_possible = 0;
1833 1833
                 $total_questions_answered = 0;
1834
-                while($row_user = Database::fetch_object($result_users)) {
1834
+                while ($row_user = Database::fetch_object($result_users)) {
1835 1835
                     // get time spent in the course and session
1836 1836
                     $time_spent += Tracking::get_time_spent_on_the_course($row_user->user_id, $courseId, $session_id);
1837 1837
                     $progress_tmp = Tracking::get_avg_student_progress($row_user->user_id, $row->code, array(), $session_id, true);
@@ -1860,11 +1860,11 @@  discard block
 block discarded – undo
1860 1860
                         $session_id,
1861 1861
                         false
1862 1862
                     );
1863
-                    if($last_login_date_tmp != false && $last_login_date == false) { // TODO: To be cleaned.
1863
+                    if ($last_login_date_tmp != false && $last_login_date == false) { // TODO: To be cleaned.
1864 1864
                         $last_login_date = $last_login_date_tmp;
1865
-                    } else if($last_login_date_tmp != false && $last_login_date == false) { // TODO: Repeated previous condition. To be cleaned.
1865
+                    } else if ($last_login_date_tmp != false && $last_login_date == false) { // TODO: Repeated previous condition. To be cleaned.
1866 1866
                         // Find the max and assign it to first_login_date
1867
-                        if(strtotime($last_login_date_tmp) > strtotime($last_login_date)) {
1867
+                        if (strtotime($last_login_date_tmp) > strtotime($last_login_date)) {
1868 1868
                             $last_login_date = $last_login_date_tmp;
1869 1869
                         }
1870 1870
                     }
@@ -1874,27 +1874,27 @@  discard block
 block discarded – undo
1874 1874
                     $total_score_possible += $exercise_results_tmp['score_possible'];
1875 1875
                     $total_questions_answered += $exercise_results_tmp['questions_answered'];
1876 1876
                 }
1877
-                if($nb_progress_lp > 0) {
1877
+                if ($nb_progress_lp > 0) {
1878 1878
                     $avg_progress = round($progress / $nb_progress_lp, 2);
1879 1879
                 } else {
1880 1880
                     $avg_progress = 0;
1881 1881
                 }
1882
-                if($nb_score_lp > 0) {
1882
+                if ($nb_score_lp > 0) {
1883 1883
                     $avg_score = round($score / $nb_score_lp, 2);
1884 1884
                 } else {
1885 1885
                     $avg_score = '-';
1886 1886
                 }
1887
-                if($last_login_date) {
1887
+                if ($last_login_date) {
1888 1888
                     $last_login_date = api_convert_and_format_date($last_login_date, DATE_FORMAT_SHORT, date_default_timezone_get());
1889 1889
                 } else {
1890 1890
                     $last_login_date = '-';
1891 1891
                 }
1892
-                if($total_score_possible > 0) {
1892
+                if ($total_score_possible > 0) {
1893 1893
                     $total_score_percentage = round($total_score_obtained / $total_score_possible * 100, 2);
1894 1894
                 } else {
1895 1895
                     $total_score_percentage = 0;
1896 1896
                 }
1897
-                if($total_score_percentage > 0) {
1897
+                if ($total_score_percentage > 0) {
1898 1898
                     $total_score = $total_score_obtained.'/'.$total_score_possible.' ('.$total_score_percentage.' %)';
1899 1899
                 } else {
1900 1900
                     $total_score = '-';
@@ -1944,7 +1944,7 @@  discard block
 block discarded – undo
1944 1944
             FROM '.Database :: get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES)."
1945 1945
             WHERE c_id = ' . $courseId . '
1946 1946
             AND exe_user_id = '".intval($user_id)."'";
1947
-        if($session_id !== false) {
1947
+        if ($session_id !== false) {
1948 1948
             $sql .= " AND session_id = '".$session_id."' ";
1949 1949
         }
1950 1950
         $result = Database::query($sql);
@@ -1954,7 +1954,7 @@  discard block
 block discarded – undo
1954 1954
         while ($row = Database::fetch_array($result)) {
1955 1955
             $score_obtained += $row['exe_result'];
1956 1956
             $score_possible += $row['exe_weighting'];
1957
-            $questions_answered ++;
1957
+            $questions_answered++;
1958 1958
         }
1959 1959
 
1960 1960
         if ($score_possible != 0) {
@@ -2075,9 +2075,9 @@  discard block
 block discarded – undo
2075 2075
                     }
2076 2076
                 }
2077 2077
                 // time spent in the course
2078
-                $csv_row[] = api_time_to_hms(Tracking::get_time_spent_on_the_course ($user[4], $courseId));
2078
+                $csv_row[] = api_time_to_hms(Tracking::get_time_spent_on_the_course($user[4], $courseId));
2079 2079
                 // student progress in course
2080
-                $csv_row[] = round(Tracking::get_avg_student_progress ($user[4], $row[0]), 2);
2080
+                $csv_row[] = round(Tracking::get_avg_student_progress($user[4], $row[0]), 2);
2081 2081
                 // student score
2082 2082
                 $csv_row[] = round(Tracking::get_avg_student_score($user[4], $row[0]), 2);
2083 2083
                 // student tes score
@@ -2085,7 +2085,7 @@  discard block
 block discarded – undo
2085 2085
                 // student messages
2086 2086
                 $csv_row[] = Tracking::count_student_messages($user[4], $row[0]);
2087 2087
                 // student assignments
2088
-                $csv_row[] = Tracking::count_student_assignments ($user[4], $row[0]);
2088
+                $csv_row[] = Tracking::count_student_assignments($user[4], $row[0]);
2089 2089
                 // student exercises results
2090 2090
                 $exercises_results = MySpace::exercises_results($user[4], $row[0]);
2091 2091
                 $csv_row[] = $exercises_results['score_obtained'];
@@ -2093,7 +2093,7 @@  discard block
 block discarded – undo
2093 2093
                 $csv_row[] = $exercises_results['questions_answered'];
2094 2094
                 $csv_row[] = $exercises_results['percentage'];
2095 2095
                 // first connection
2096
-                $csv_row[] = Tracking::get_first_connection_date_on_the_course ($user[4], $courseId);
2096
+                $csv_row[] = Tracking::get_first_connection_date_on_the_course($user[4], $courseId);
2097 2097
                 // last connection
2098 2098
                 $csv_row[] = strip_tags(Tracking::get_last_connection_date_on_the_course($user[4], $courseInfo));
2099 2099
 
@@ -2127,9 +2127,9 @@  discard block
 block discarded – undo
2127 2127
         // get all courses with limit
2128 2128
         $sql = "SELECT course.code as col1, course.title as col2
2129 2129
                 FROM $tbl_course course
2130
-                WHERE course.code IN (".implode(',',$courses_code).")";
2130
+                WHERE course.code IN (".implode(',', $courses_code).")";
2131 2131
 
2132
-        if (!in_array($direction, array('ASC','DESC'))) $direction = 'ASC';
2132
+        if (!in_array($direction, array('ASC', 'DESC'))) $direction = 'ASC';
2133 2133
 
2134 2134
         $column = intval($column);
2135 2135
         $from = intval($from);
@@ -2198,7 +2198,7 @@  discard block
 block discarded – undo
2198 2198
             $table_row[] = $avg_assignments_in_course;
2199 2199
 
2200 2200
             //set the "from" value to know if I access the Reporting by the chamilo tab or the course link
2201
-            $table_row[] = '<center><a href="../../tracking/courseLog.php?cidReq=' .$course_code.'&from=myspace&id_session='.$session_id.'">
2201
+            $table_row[] = '<center><a href="../../tracking/courseLog.php?cidReq='.$course_code.'&from=myspace&id_session='.$session_id.'">
2202 2202
                              '.Display::return_icon('2rightarrow.png').'
2203 2203
                              </a>
2204 2204
                             </center>';
@@ -2207,7 +2207,7 @@  discard block
 block discarded – undo
2207 2207
                 $nb_students_in_course,
2208 2208
                 $avg_time_spent_in_course,
2209 2209
                 is_null($avg_progress_in_course) ? null : $avg_progress_in_course.'%',
2210
-                is_null($avg_score_in_course) ? null : is_numeric($avg_score_in_course) ? $avg_score_in_course.'%' : $avg_score_in_course ,
2210
+                is_null($avg_score_in_course) ? null : is_numeric($avg_score_in_course) ? $avg_score_in_course.'%' : $avg_score_in_course,
2211 2211
                 is_null($avg_score_in_exercise) ? null : $avg_score_in_exercise.'%',
2212 2212
                 $avg_messages_in_course,
2213 2213
                 $avg_assignments_in_course,
@@ -2275,7 +2275,7 @@  discard block
 block discarded – undo
2275 2275
         $sql .= " ORDER BY col$column $direction ";
2276 2276
         $sql .= " LIMIT $from,$number_of_items";
2277 2277
         $result = Database::query($sql);
2278
-        $return = array ();
2278
+        $return = array();
2279 2279
         while ($user = Database::fetch_row($result)) {
2280 2280
             $return[] = $user;
2281 2281
         }
@@ -2330,7 +2330,7 @@  discard block
 block discarded – undo
2330 2330
                     $i++;
2331 2331
                 }
2332 2332
             }
2333
-            $username_array = array('username' => $desired_username , 'sufix' => $sufix);
2333
+            $username_array = array('username' => $desired_username, 'sufix' => $sufix);
2334 2334
             return $username_array;
2335 2335
         } else {
2336 2336
             $username_array = array('username' => $username, 'sufix' => '');
@@ -2605,7 +2605,7 @@  discard block
 block discarded – undo
2605 2605
         foreach ($users as $index => $user) {
2606 2606
             $userid = $user['id'];
2607 2607
             $sql_insert = "INSERT IGNORE INTO $tbl_session_rel_user(session_id, user_id, registered_at)
2608
-                           VALUES ('$id_session','$userid', '" . api_get_utc_datetime() . "')";
2608
+                           VALUES ('$id_session','$userid', '".api_get_utc_datetime()."')";
2609 2609
             Database::query($sql_insert);
2610 2610
             $user['added_at_session'] = 1;
2611 2611
             $new_users[] = $user;
@@ -2639,10 +2639,10 @@  discard block
 block discarded – undo
2639 2639
                 );
2640 2640
                 $userInfo = api_get_user_info($user['id']);
2641 2641
 
2642
-                if (($user['added_at_platform'] == 1  && $user['added_at_session'] == 1) || $user['added_at_session'] == 1) {
2642
+                if (($user['added_at_platform'] == 1 && $user['added_at_session'] == 1) || $user['added_at_session'] == 1) {
2643 2643
                     if ($user['added_at_platform'] == 1) {
2644 2644
                         $addedto = get_lang('UserCreatedPlatform');
2645
-                    } else  {
2645
+                    } else {
2646 2646
                         $addedto = '          ';
2647 2647
                     }
2648 2648
 
@@ -2705,7 +2705,7 @@  discard block
 block discarded – undo
2705 2705
         global $current_tag;
2706 2706
         switch ($data) {
2707 2707
             case 'Contact' :
2708
-                $user = array ();
2708
+                $user = array();
2709 2709
                 break;
2710 2710
             default :
2711 2711
                 $current_tag = $data;
@@ -2752,9 +2752,9 @@  discard block
 block discarded – undo
2752 2752
         global $current_value;
2753 2753
         global $user;
2754 2754
         global $users;
2755
-        $users = array ();
2755
+        $users = array();
2756 2756
         $parser = xml_parser_create('UTF-8');
2757
-        xml_set_element_handler($parser, array('MySpace','element_start'), array('MySpace','element_end'));
2757
+        xml_set_element_handler($parser, array('MySpace', 'element_start'), array('MySpace', 'element_end'));
2758 2758
         xml_set_character_data_handler($parser, "character_data");
2759 2759
         xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, false);
2760 2760
         xml_parse($parser, api_utf8_encode_xml(file_get_contents($file)));
@@ -2800,7 +2800,7 @@  discard block
 block discarded – undo
2800 2800
             get_lang('SearchCourse'),
2801 2801
             $courseList,
2802 2802
             [
2803
-                'url' => api_get_path(WEB_AJAX_PATH) . 'course.ajax.php?' . http_build_query([
2803
+                'url' => api_get_path(WEB_AJAX_PATH).'course.ajax.php?'.http_build_query([
2804 2804
                     'a' => 'search_course_by_session_all',
2805 2805
                     'session_id' => $sessionId
2806 2806
                 ])
@@ -2819,7 +2819,7 @@  discard block
 block discarded – undo
2819 2819
                             course_id: $('#course_id').val() || 0
2820 2820
                         });
2821 2821
 
2822
-                        return '" . api_get_path(WEB_AJAX_PATH) . "session.ajax.php?' + params;
2822
+                        return '" . api_get_path(WEB_AJAX_PATH)."session.ajax.php?' + params;
2823 2823
                     }
2824 2824
                 "
2825 2825
             ]
@@ -2850,7 +2850,7 @@  discard block
 block discarded – undo
2850 2850
                             course_id: $('#course_id').val()
2851 2851
                         });
2852 2852
 
2853
-                        return '" . api_get_path(WEB_AJAX_PATH) . "course.ajax.php?' + params;
2853
+                        return '" . api_get_path(WEB_AJAX_PATH)."course.ajax.php?' + params;
2854 2854
                     }
2855 2855
                 "
2856 2856
             ]
@@ -2876,8 +2876,8 @@  discard block
 block discarded – undo
2876 2876
         if ($form->validate()) {
2877 2877
             $table = new SortableTable(
2878 2878
                 'tracking_access_overview',
2879
-                ['MySpace','getNumberOfRrackingAccessOverview'],
2880
-                ['MySpace','getUserDataAccessTrackingOverview'],
2879
+                ['MySpace', 'getNumberOfRrackingAccessOverview'],
2880
+                ['MySpace', 'getUserDataAccessTrackingOverview'],
2881 2881
                 0
2882 2882
             );
2883 2883
             $table->additional_parameters = $form->exportValues();
@@ -2938,7 +2938,7 @@  discard block
 block discarded – undo
2938 2938
                     " : "
2939 2939
                         u.lastname AS col2,
2940 2940
                         u.firstname AS col3,
2941
-                " ) . "
2941
+                " )."
2942 2942
                 a.logout_course_date,
2943 2943
                 c.title,
2944 2944
                 c.code,
@@ -2949,7 +2949,7 @@  discard block
 block discarded – undo
2949 2949
 
2950 2950
         if (isset($_GET['session_id']) && !empty($_GET['session_id'])) {
2951 2951
             $sessionId = intval($_GET['session_id']);
2952
-            $sql .= " WHERE a.session_id = " . $sessionId;
2952
+            $sql .= " WHERE a.session_id = ".$sessionId;
2953 2953
         }
2954 2954
 
2955 2955
         $sql .= " ORDER BY col$column $orderDirection ";
@@ -3010,14 +3010,14 @@  discard block
 block discarded – undo
3010 3010
 function get_stats($user_id, $courseId, $start_date = null, $end_date = null)
3011 3011
 {
3012 3012
     // Database table definitions
3013
-    $tbl_track_course   = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
3013
+    $tbl_track_course = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
3014 3014
 
3015 3015
     $course_info = api_get_course_info_by_id($courseId);
3016 3016
     if (!empty($course_info)) {
3017 3017
         $strg_sd    = "";
3018 3018
         $strg_ed    = "";
3019
-        if ($start_date != null && $end_date != null){
3020
-            $end_date = add_day_to( $end_date );
3019
+        if ($start_date != null && $end_date != null) {
3020
+            $end_date = add_day_to($end_date);
3021 3021
             $strg_sd = "AND login_course_date BETWEEN '$start_date' AND '$end_date'";
3022 3022
             $strg_ed = "AND logout_course_date BETWEEN '$start_date' AND '$end_date'";
3023 3023
         }
@@ -3025,10 +3025,10 @@  discard block
 block discarded – undo
3025 3025
                 SEC_TO_TIME(avg(time_to_sec(timediff(logout_course_date,login_course_date)))) as avrg,
3026 3026
                 SEC_TO_TIME(sum(time_to_sec(timediff(logout_course_date,login_course_date)))) as total,
3027 3027
                 count(user_id) as times
3028
-                FROM ' . $tbl_track_course . '
3028
+                FROM ' . $tbl_track_course.'
3029 3029
                 WHERE
3030
-                    user_id = ' . intval($user_id) . ' AND
3031
-                    c_id = ' . intval($courseId) . ' '.$strg_sd.' '.$strg_ed.' '.'
3030
+                    user_id = ' . intval($user_id).' AND
3031
+                    c_id = ' . intval($courseId).' '.$strg_sd.' '.$strg_ed.' '.'
3032 3032
                 ORDER BY login_course_date ASC';
3033 3033
 
3034 3034
         $rs = Database::query($sql);
@@ -3046,7 +3046,7 @@  discard block
 block discarded – undo
3046 3046
 }
3047 3047
 
3048 3048
 function add_day_to($end_date) {
3049
-    $foo_date = strtotime( $end_date );
3049
+    $foo_date = strtotime($end_date);
3050 3050
     $foo_date = strtotime(" +1 day", $foo_date);
3051 3051
     $foo_date = date("Y-m-d", $foo_date);
3052 3052
     return $foo_date;
@@ -3106,7 +3106,7 @@  discard block
 block discarded – undo
3106 3106
  * @version OCT-22- 2010
3107 3107
  * @return array
3108 3108
  */
3109
-function convert_to_array($sql_result){
3109
+function convert_to_array($sql_result) {
3110 3110
     $result_to_print = '<table>';
3111 3111
     foreach ($sql_result as $key => $data) {
3112 3112
         $result_to_print .= '<tr><td>'.date('d-m-Y (H:i:s)', $data['login']).'</td><td>'.api_time_to_hms($data['logout'] - $data['login']).'</tr></td>'."\n";
@@ -3125,7 +3125,7 @@  discard block
 block discarded – undo
3125 3125
  * @version OCT-22- 2010
3126 3126
  * @return string
3127 3127
  */
3128
-function convert_to_string($sql_result){
3128
+function convert_to_string($sql_result) {
3129 3129
     $result_to_print = '<table>';
3130 3130
     if (!empty($sql_result)) {
3131 3131
         foreach ($sql_result as $key => $data) {
@@ -3150,18 +3150,18 @@  discard block
 block discarded – undo
3150 3150
  */
3151 3151
 function grapher($sql_result, $start_date, $end_date, $type = "")
3152 3152
 {
3153
-    if (empty($start_date)) { $start_date =""; }
3154
-    if (empty($end_date)) { $end_date =""; }
3155
-    if ($type == ""){ $type = 'day'; }
3156
-    $main_year  = $main_month_year = $main_day = array();
3153
+    if (empty($start_date)) { $start_date = ""; }
3154
+    if (empty($end_date)) { $end_date = ""; }
3155
+    if ($type == "") { $type = 'day'; }
3156
+    $main_year = $main_month_year = $main_day = array();
3157 3157
     // get last 8 days/months
3158 3158
     $last_days      = 5;
3159 3159
     $last_months    = 3;
3160 3160
     for ($i = $last_days; $i >= 0; $i--) {
3161
-        $main_day[date ('d-m-Y', mktime () - $i * 3600 * 24)] = 0;
3161
+        $main_day[date('d-m-Y', mktime() - $i * 3600 * 24)] = 0;
3162 3162
     }
3163 3163
     for ($i = $last_months; $i >= 0; $i--) {
3164
-        $main_month_year[date ('m-Y', mktime () - $i * 30 * 3600 * 24)] = 0;
3164
+        $main_month_year[date('m-Y', mktime() - $i * 30 * 3600 * 24)] = 0;
3165 3165
     }
3166 3166
 
3167 3167
     $i = 0;
@@ -3197,7 +3197,7 @@  discard block
 block discarded – undo
3197 3197
         /* Create and populate the pData object */
3198 3198
         $myData = new pData();
3199 3199
         $myData->addPoints($main_date, 'Serie1');
3200
-        if (count($main_date)!= 1) {
3200
+        if (count($main_date) != 1) {
3201 3201
             $myData->addPoints($labels, 'Labels');
3202 3202
             $myData->setSerieDescription('Labels', 'Months');
3203 3203
             $myData->setAbscissa('Labels');
@@ -3205,7 +3205,7 @@  discard block
 block discarded – undo
3205 3205
         $myData->setSerieWeight('Serie1', 1);
3206 3206
         $myData->setSerieDescription('Serie1', get_lang('MyResults'));
3207 3207
         $myData->setAxisName(0, get_lang('Minutes'));
3208
-        $myData->loadPalette(api_get_path(SYS_CODE_PATH) . 'palettes/pchart/default.color', true);
3208
+        $myData->loadPalette(api_get_path(SYS_CODE_PATH).'palettes/pchart/default.color', true);
3209 3209
 
3210 3210
         // Cache definition
3211 3211
         $cachePath = api_get_path(SYS_ARCHIVE_PATH);
@@ -3214,9 +3214,9 @@  discard block
 block discarded – undo
3214 3214
 
3215 3215
         if ($myCache->isInCache($chartHash)) {
3216 3216
             //if we already created the img
3217
-            $imgPath = api_get_path(SYS_ARCHIVE_PATH) . $chartHash;
3217
+            $imgPath = api_get_path(SYS_ARCHIVE_PATH).$chartHash;
3218 3218
             $myCache->saveFromCache($chartHash, $imgPath);
3219
-            $imgPath = api_get_path(WEB_ARCHIVE_PATH) . $chartHash;
3219
+            $imgPath = api_get_path(WEB_ARCHIVE_PATH).$chartHash;
3220 3220
         } else {
3221 3221
             /* Define width, height and angle */
3222 3222
             $mainWidth = 760;
@@ -3245,7 +3245,7 @@  discard block
 block discarded – undo
3245 3245
             /* Set the default font */
3246 3246
             $myPicture->setFontProperties(
3247 3247
                 array(
3248
-                    "FontName" => api_get_path(SYS_FONTS_PATH) . 'opensans/OpenSans-Regular.ttf',
3248
+                    "FontName" => api_get_path(SYS_FONTS_PATH).'opensans/OpenSans-Regular.ttf',
3249 3249
                     "FontSize" => 10)
3250 3250
             );
3251 3251
             /* Write the chart title */
@@ -3262,7 +3262,7 @@  discard block
 block discarded – undo
3262 3262
             /* Set the default font */
3263 3263
             $myPicture->setFontProperties(
3264 3264
                 array(
3265
-                    "FontName" => api_get_path(SYS_FONTS_PATH) . 'opensans/OpenSans-Regular.ttf',
3265
+                    "FontName" => api_get_path(SYS_FONTS_PATH).'opensans/OpenSans-Regular.ttf',
3266 3266
                     "FontSize" => 8
3267 3267
                 )
3268 3268
             );
@@ -3304,7 +3304,7 @@  discard block
 block discarded – undo
3304 3304
             /* Draw the line chart */
3305 3305
             $myPicture->setFontProperties(
3306 3306
                 array(
3307
-                    "FontName" => api_get_path(SYS_FONTS_PATH) . 'opensans/OpenSans-Regular.ttf',
3307
+                    "FontName" => api_get_path(SYS_FONTS_PATH).'opensans/OpenSans-Regular.ttf',
3308 3308
                     "FontSize" => 10
3309 3309
                 )
3310 3310
             );
@@ -3323,15 +3323,15 @@  discard block
 block discarded – undo
3323 3323
 
3324 3324
             /* Write and save into cache */
3325 3325
             $myCache->writeToCache($chartHash, $myPicture);
3326
-            $imgPath = api_get_path(SYS_ARCHIVE_PATH) . $chartHash;
3326
+            $imgPath = api_get_path(SYS_ARCHIVE_PATH).$chartHash;
3327 3327
             $myCache->saveFromCache($chartHash, $imgPath);
3328
-            $imgPath = api_get_path(WEB_ARCHIVE_PATH) . $chartHash;
3328
+            $imgPath = api_get_path(WEB_ARCHIVE_PATH).$chartHash;
3329 3329
         }
3330
-        $html = '<img src="' . $imgPath . '">';
3330
+        $html = '<img src="'.$imgPath.'">';
3331 3331
 
3332 3332
         return $html;
3333 3333
     } else {
3334
-        $foo_img = api_convert_encoding('<div id="messages" class="warning-message">'.get_lang('GraphicNotAvailable').'</div>','UTF-8');
3334
+        $foo_img = api_convert_encoding('<div id="messages" class="warning-message">'.get_lang('GraphicNotAvailable').'</div>', 'UTF-8');
3335 3335
 
3336 3336
         return $foo_img;
3337 3337
     }
Please login to merge, or discard this patch.
main/inc/lib/notification.lib.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -219,7 +219,7 @@
 block discarded – undo
219 219
      * @param array	    $user_list recipients: user list of ids
220 220
      * @param string	$title
221 221
      * @param string	$content
222
-     * @param array	    $sender_info
222
+     * @param array	    $senderInfo
223 223
      * result of api_get_user_info() or GroupPortalManager:get_group_data()
224 224
      */
225 225
     public function save_notification(
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -355,7 +355,7 @@  discard block
 block discarded – undo
355 355
                 $newMessageText = '';
356 356
                 $linkToNewMessage = Display::url(
357 357
                     get_lang('SeeMessage'),
358
-                    api_get_path(WEB_CODE_PATH) . 'messages/inbox.php'
358
+                    api_get_path(WEB_CODE_PATH).'messages/inbox.php'
359 359
                 );
360 360
                 break;
361 361
             case self::NOTIFICATION_TYPE_MESSAGE:
@@ -370,7 +370,7 @@  discard block
 block discarded – undo
370 370
                 }
371 371
                 $linkToNewMessage = Display::url(
372 372
                     get_lang('SeeMessage'),
373
-                    api_get_path(WEB_CODE_PATH) . 'messages/inbox.php'
373
+                    api_get_path(WEB_CODE_PATH).'messages/inbox.php'
374 374
                 );
375 375
                 break;
376 376
             case self::NOTIFICATION_TYPE_INVITATION:
@@ -385,7 +385,7 @@  discard block
 block discarded – undo
385 385
                 }
386 386
                 $linkToNewMessage = Display::url(
387 387
                     get_lang('SeeInvitation'),
388
-                    api_get_path(WEB_CODE_PATH) . 'social/invitations.php'
388
+                    api_get_path(WEB_CODE_PATH).'social/invitations.php'
389 389
                 );
390 390
                 break;
391 391
             case self::NOTIFICATION_TYPE_GROUP:
Please login to merge, or discard this patch.
main/inc/lib/nusoap/class.nusoap_base.php 3 patches
Doc Comments   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -306,7 +306,7 @@  discard block
 block discarded – undo
306 306
 	/**
307 307
 	* gets the current debug data for this instance
308 308
 	*
309
-	* @return   debug data
309
+	* @return   string data
310 310
 	* @access   public
311 311
 	*/
312 312
 	function &getDebug() {
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
 	* gets the current debug data for this instance as an XML comment
320 320
 	* this may change the contents of the debug data
321 321
 	*
322
-	* @return   debug data as an XML comment
322
+	* @return   string data as an XML comment
323 323
 	* @access   public
324 324
 	*/
325 325
 	function &getDebugAsXMLComment() {
@@ -352,7 +352,7 @@  discard block
 block discarded – undo
352 352
 	/**
353 353
 	* returns error string if present
354 354
 	*
355
-	* @return   mixed error string or false
355
+	* @return   string|false error string or false
356 356
 	* @access   public
357 357
 	*/
358 358
 	function getError(){
@@ -365,7 +365,7 @@  discard block
 block discarded – undo
365 365
 	/**
366 366
 	* sets error string
367 367
 	*
368
-	* @return   boolean $string error string
368
+	* @return   boolean|null $string error string
369 369
 	* @access   private
370 370
 	*/
371 371
 	function setError($str){
@@ -801,7 +801,7 @@  discard block
 block discarded – undo
801 801
     * returns false, if not prefixed
802 802
     *
803 803
     * @param string $str The prefixed string
804
-    * @return mixed The prefix or false if there is no prefix
804
+    * @return string|false The prefix or false if there is no prefix
805 805
     * @access public
806 806
     */
807 807
 	function getPrefix($str){
@@ -832,7 +832,7 @@  discard block
 block discarded – undo
832 832
     * or false if no prefixes registered for the given namespace
833 833
     *
834 834
     * @param string $ns The namespace
835
-    * @return mixed The prefix, false if the namespace has no prefixes
835
+    * @return string The prefix, false if the namespace has no prefixes
836 836
     * @access public
837 837
     */
838 838
 	function getPrefixFromNamespace($ns) {
@@ -898,7 +898,7 @@  discard block
 block discarded – undo
898 898
 *
899 899
 * @param    int $timestamp Unix time stamp
900 900
 * @param	boolean $utc Whether the time stamp is UTC or local
901
-* @return	mixed ISO 8601 date string or false
901
+* @return	string|false ISO 8601 date string or false
902 902
 * @access   public
903 903
 */
904 904
 function timestamp_to_iso8601($timestamp,$utc=true){
Please login to merge, or discard this patch.
Spacing   +115 added lines, -115 removed lines patch added patch discarded remove patch
@@ -183,26 +183,26 @@  discard block
 block discarded – undo
183 183
 	*/
184 184
 	var $typemap = array(
185 185
 	'http://www.w3.org/2001/XMLSchema' => array(
186
-		'string'=>'string','boolean'=>'boolean','float'=>'double','double'=>'double','decimal'=>'double',
187
-		'duration'=>'','dateTime'=>'string','time'=>'string','date'=>'string','gYearMonth'=>'',
188
-		'gYear'=>'','gMonthDay'=>'','gDay'=>'','gMonth'=>'','hexBinary'=>'string','base64Binary'=>'string',
186
+		'string'=>'string', 'boolean'=>'boolean', 'float'=>'double', 'double'=>'double', 'decimal'=>'double',
187
+		'duration'=>'', 'dateTime'=>'string', 'time'=>'string', 'date'=>'string', 'gYearMonth'=>'',
188
+		'gYear'=>'', 'gMonthDay'=>'', 'gDay'=>'', 'gMonth'=>'', 'hexBinary'=>'string', 'base64Binary'=>'string',
189 189
 		// abstract "any" types
190
-		'anyType'=>'string','anySimpleType'=>'string',
190
+		'anyType'=>'string', 'anySimpleType'=>'string',
191 191
 		// derived datatypes
192
-		'normalizedString'=>'string','token'=>'string','language'=>'','NMTOKEN'=>'','NMTOKENS'=>'','Name'=>'','NCName'=>'','ID'=>'',
193
-		'IDREF'=>'','IDREFS'=>'','ENTITY'=>'','ENTITIES'=>'','integer'=>'integer','nonPositiveInteger'=>'integer',
194
-		'negativeInteger'=>'integer','long'=>'integer','int'=>'integer','short'=>'integer','byte'=>'integer','nonNegativeInteger'=>'integer',
195
-		'unsignedLong'=>'','unsignedInt'=>'','unsignedShort'=>'','unsignedByte'=>'','positiveInteger'=>''),
192
+		'normalizedString'=>'string', 'token'=>'string', 'language'=>'', 'NMTOKEN'=>'', 'NMTOKENS'=>'', 'Name'=>'', 'NCName'=>'', 'ID'=>'',
193
+		'IDREF'=>'', 'IDREFS'=>'', 'ENTITY'=>'', 'ENTITIES'=>'', 'integer'=>'integer', 'nonPositiveInteger'=>'integer',
194
+		'negativeInteger'=>'integer', 'long'=>'integer', 'int'=>'integer', 'short'=>'integer', 'byte'=>'integer', 'nonNegativeInteger'=>'integer',
195
+		'unsignedLong'=>'', 'unsignedInt'=>'', 'unsignedShort'=>'', 'unsignedByte'=>'', 'positiveInteger'=>''),
196 196
 	'http://www.w3.org/2000/10/XMLSchema' => array(
197
-		'i4'=>'','int'=>'integer','boolean'=>'boolean','string'=>'string','double'=>'double',
198
-		'float'=>'double','dateTime'=>'string',
199
-		'timeInstant'=>'string','base64Binary'=>'string','base64'=>'string','ur-type'=>'array'),
197
+		'i4'=>'', 'int'=>'integer', 'boolean'=>'boolean', 'string'=>'string', 'double'=>'double',
198
+		'float'=>'double', 'dateTime'=>'string',
199
+		'timeInstant'=>'string', 'base64Binary'=>'string', 'base64'=>'string', 'ur-type'=>'array'),
200 200
 	'http://www.w3.org/1999/XMLSchema' => array(
201
-		'i4'=>'','int'=>'integer','boolean'=>'boolean','string'=>'string','double'=>'double',
202
-		'float'=>'double','dateTime'=>'string',
203
-		'timeInstant'=>'string','base64Binary'=>'string','base64'=>'string','ur-type'=>'array'),
201
+		'i4'=>'', 'int'=>'integer', 'boolean'=>'boolean', 'string'=>'string', 'double'=>'double',
202
+		'float'=>'double', 'dateTime'=>'string',
203
+		'timeInstant'=>'string', 'base64Binary'=>'string', 'base64'=>'string', 'ur-type'=>'array'),
204 204
 	'http://soapinterop.org/xsd' => array('SOAPStruct'=>'struct'),
205
-	'http://schemas.xmlsoap.org/soap/encoding/' => array('base64'=>'string','array'=>'array','Array'=>'array'),
205
+	'http://schemas.xmlsoap.org/soap/encoding/' => array('base64'=>'string', 'array'=>'array', 'Array'=>'array'),
206 206
     'http://xml.apache.org/xml-soap' => array('Map')
207 207
 	);
208 208
 
@@ -214,8 +214,8 @@  discard block
 block discarded – undo
214 214
 	* @deprecated
215 215
 	* @see	expandEntities
216 216
 	*/
217
-	var $xmlEntities = array('quot' => '"','amp' => '&',
218
-		'lt' => '<','gt' => '>','apos' => "'");
217
+	var $xmlEntities = array('quot' => '"', 'amp' => '&',
218
+		'lt' => '<', 'gt' => '>', 'apos' => "'");
219 219
 
220 220
 	/**
221 221
 	* constructor
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
 	* @param    string $string debug data
273 273
 	* @access   private
274 274
 	*/
275
-	function debug($string){
275
+	function debug($string) {
276 276
 		if ($this->debugLevel > 0) {
277 277
 			$this->appendDebug($this->getmicrotime().' '.get_class($this).": $string\n");
278 278
 		}
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
 	* @param    string $string debug data
285 285
 	* @access   public
286 286
 	*/
287
-	function appendDebug($string){
287
+	function appendDebug($string) {
288 288
 		if ($this->debugLevel > 0) {
289 289
 			// it would be nice to use a memory stream here to use
290 290
 			// memory more efficiently
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
 		while (strpos($this->debug_str, '--')) {
329 329
 			$this->debug_str = str_replace('--', '- -', $this->debug_str);
330 330
 		}
331
-		$ret = "<!--\n" . $this->debug_str . "\n-->";
331
+		$ret = "<!--\n".$this->debug_str."\n-->";
332 332
     	return $ret;
333 333
 	}
334 334
 
@@ -355,8 +355,8 @@  discard block
 block discarded – undo
355 355
 	* @return   mixed error string or false
356 356
 	* @access   public
357 357
 	*/
358
-	function getError(){
359
-		if($this->error_str != ''){
358
+	function getError() {
359
+		if ($this->error_str != '') {
360 360
 			return $this->error_str;
361 361
 		}
362 362
 		return false;
@@ -368,7 +368,7 @@  discard block
 block discarded – undo
368 368
 	* @return   boolean $string error string
369 369
 	* @access   private
370 370
 	*/
371
-	function setError($str){
371
+	function setError($str) {
372 372
 		$this->error_str = $str;
373 373
 	}
374 374
 
@@ -404,12 +404,12 @@  discard block
 block discarded – undo
404 404
 	* @return	string	The serialized element, possibly with child elements
405 405
     * @access	public
406 406
 	*/
407
-	function serialize_val($val,$name=false,$type=false,$name_ns=false,$type_ns=false,$attributes=false,$use='encoded',$soapval=false) {
407
+	function serialize_val($val, $name = false, $type = false, $name_ns = false, $type_ns = false, $attributes = false, $use = 'encoded', $soapval = false) {
408 408
 		$this->debug("in serialize_val: name=$name, type=$type, name_ns=$name_ns, type_ns=$type_ns, use=$use, soapval=$soapval");
409
-		$this->appendDebug('value=' . $this->varDump($val));
410
-		$this->appendDebug('attributes=' . $this->varDump($attributes));
409
+		$this->appendDebug('value='.$this->varDump($val));
410
+		$this->appendDebug('attributes='.$this->varDump($attributes));
411 411
 
412
-    	if (is_object($val) && get_class($val) == 'soapval' && (! $soapval)) {
412
+    	if (is_object($val) && get_class($val) == 'soapval' && (!$soapval)) {
413 413
     		$this->debug("serialize_val: serialize soapval");
414 414
         	$xml = $val->serialize($use);
415 415
 			$this->appendDebug($val->getDebug());
@@ -419,30 +419,30 @@  discard block
 block discarded – undo
419 419
         }
420 420
 		// force valid name if necessary
421 421
 		if (is_numeric($name)) {
422
-			$name = '__numeric_' . $name;
423
-		} elseif (! $name) {
422
+			$name = '__numeric_'.$name;
423
+		} elseif (!$name) {
424 424
 			$name = 'noname';
425 425
 		}
426 426
 		// if name has ns, add ns prefix to name
427 427
 		$xmlns = '';
428
-        if($name_ns){
429
-			$prefix = 'nu'.rand(1000,9999);
428
+        if ($name_ns) {
429
+			$prefix = 'nu'.rand(1000, 9999);
430 430
 			$name = $prefix.':'.$name;
431 431
 			$xmlns .= " xmlns:$prefix=\"$name_ns\"";
432 432
 		}
433 433
 		// if type is prefixed, create type prefix
434
-		if($type_ns != '' && $type_ns == $this->namespaces['xsd']){
434
+		if ($type_ns != '' && $type_ns == $this->namespaces['xsd']) {
435 435
 			// need to fix this. shouldn't default to xsd if no ns specified
436 436
 		    // w/o checking against typemap
437 437
 			$type_prefix = 'xsd';
438
-		} elseif($type_ns){
439
-			$type_prefix = 'ns'.rand(1000,9999);
438
+		} elseif ($type_ns) {
439
+			$type_prefix = 'ns'.rand(1000, 9999);
440 440
 			$xmlns .= " xmlns:$type_prefix=\"$type_ns\"";
441 441
 		}
442 442
 		// serialize attributes if present
443 443
 		$atts = '';
444
-		if($attributes){
445
-			foreach($attributes as $k => $v){
444
+		if ($attributes) {
445
+			foreach ($attributes as $k => $v) {
446 446
 				$atts .= " $k=\"".$this->expandEntities($v).'"';
447 447
 			}
448 448
 		}
@@ -466,12 +466,12 @@  discard block
 block discarded – undo
466 466
         	}
467 467
 		}
468 468
         // serialize if an xsd built-in primitive type
469
-        if($type != '' && isset($this->typemap[$this->XMLSchemaVersion][$type])){
469
+        if ($type != '' && isset($this->typemap[$this->XMLSchemaVersion][$type])) {
470 470
     		$this->debug("serialize_val: serialize xsd built-in primitive type");
471 471
         	if (is_bool($val)) {
472 472
         		if ($type == 'boolean') {
473 473
 	        		$val = $val ? 'true' : 'false';
474
-	        	} elseif (! $val) {
474
+	        	} elseif (!$val) {
475 475
 	        		$val = 0;
476 476
 	        	}
477 477
 			} else if (is_string($val)) {
@@ -489,12 +489,12 @@  discard block
 block discarded – undo
489 489
         }
490 490
 		// detect type and serialize
491 491
 		$xml = '';
492
-		switch(true) {
492
+		switch (true) {
493 493
 			case (is_bool($val) || $type == 'boolean'):
494 494
 		   		$this->debug("serialize_val: serialize boolean");
495 495
         		if ($type == 'boolean') {
496 496
 	        		$val = $val ? 'true' : 'false';
497
-	        	} elseif (! $val) {
497
+	        	} elseif (!$val) {
498 498
 	        		$val = 0;
499 499
 	        	}
500 500
 				if ($use == 'literal') {
@@ -511,7 +511,7 @@  discard block
 block discarded – undo
511 511
 					$xml .= "<$name$xmlns xsi:type=\"xsd:int\"$atts>$val</$name>";
512 512
 				}
513 513
 				break;
514
-			case (is_float($val)|| is_double($val) || $type == 'float'):
514
+			case (is_float($val) || is_double($val) || $type == 'float'):
515 515
 		   		$this->debug("serialize_val: serialize float");
516 516
 				if ($use == 'literal') {
517 517
 					$xml .= "<$name$xmlns$atts>$val</$name>";
@@ -536,17 +536,17 @@  discard block
 block discarded – undo
536 536
 					$this->appendDebug($val->getDebug());
537 537
 					$val->clearDebug();
538 538
 		        } else {
539
-					if (! $name) {
539
+					if (!$name) {
540 540
 						$name = get_class($val);
541 541
 						$this->debug("In serialize_val, used class name $name as element name");
542 542
 					} else {
543
-						$this->debug("In serialize_val, do not override name $name for element name for class " . get_class($val));
543
+						$this->debug("In serialize_val, do not override name $name for element name for class ".get_class($val));
544 544
 					}
545
-					foreach(get_object_vars($val) as $k => $v){
546
-						$pXml = isset($pXml) ? $pXml.$this->serialize_val($v,$k,false,false,false,false,$use) : $this->serialize_val($v,$k,false,false,false,false,$use);
545
+					foreach (get_object_vars($val) as $k => $v) {
546
+						$pXml = isset($pXml) ? $pXml.$this->serialize_val($v, $k, false, false, false, false, $use) : $this->serialize_val($v, $k, false, false, false, false, $use);
547 547
 					}
548 548
 				}
549
-				if(isset($type) && isset($type_prefix)){
549
+				if (isset($type) && isset($type_prefix)) {
550 550
 					$type_str = " xsi:type=\"$type_prefix:$type\"";
551 551
 				} else {
552 552
 					$type_str = '';
@@ -561,12 +561,12 @@  discard block
 block discarded – undo
561 561
 			case (is_array($val) || $type):
562 562
 				// detect if struct or array
563 563
 				$valueType = $this->isArraySimpleOrStruct($val);
564
-                if($valueType=='arraySimple' || preg_match('/^ArrayOf/',$type)){
564
+                if ($valueType == 'arraySimple' || preg_match('/^ArrayOf/', $type)) {
565 565
 			   		$this->debug("serialize_val: serialize array");
566 566
 					$i = 0;
567
-					if(is_array($val) && count($val)> 0){
568
-						foreach($val as $v){
569
-	                    	if(is_object($v) && get_class($v) ==  'soapval'){
567
+					if (is_array($val) && count($val) > 0) {
568
+						foreach ($val as $v) {
569
+	                    	if (is_object($v) && get_class($v) == 'soapval') {
570 570
 								$tt_ns = $v->type_ns;
571 571
 								$tt = $v->type;
572 572
 							} elseif (is_array($v)) {
@@ -576,26 +576,26 @@  discard block
 block discarded – undo
576 576
 	                        }
577 577
 							$array_types[$tt] = 1;
578 578
 							// TODO: for literal, the name should be $name
579
-							$xml .= $this->serialize_val($v,'item',false,false,false,false,$use);
579
+							$xml .= $this->serialize_val($v, 'item', false, false, false, false, $use);
580 580
 							++$i;
581 581
 						}
582
-						if(count($array_types) > 1){
582
+						if (count($array_types) > 1) {
583 583
 							$array_typename = 'xsd:anyType';
584
-						} elseif(isset($tt) && isset($this->typemap[$this->XMLSchemaVersion][$tt])) {
584
+						} elseif (isset($tt) && isset($this->typemap[$this->XMLSchemaVersion][$tt])) {
585 585
 							if ($tt == 'integer') {
586 586
 								$tt = 'int';
587 587
 							}
588 588
 							$array_typename = 'xsd:'.$tt;
589
-						} elseif(isset($tt) && $tt == 'arraySimple'){
589
+						} elseif (isset($tt) && $tt == 'arraySimple') {
590 590
 							$array_typename = 'SOAP-ENC:Array';
591
-						} elseif(isset($tt) && $tt == 'arrayStruct'){
591
+						} elseif (isset($tt) && $tt == 'arrayStruct') {
592 592
 							$array_typename = 'unnamed_struct_use_soapval';
593 593
 						} else {
594 594
 							// if type is prefixed, create type prefix
595
-							if ($tt_ns != '' && $tt_ns == $this->namespaces['xsd']){
596
-								 $array_typename = 'xsd:' . $tt;
595
+							if ($tt_ns != '' && $tt_ns == $this->namespaces['xsd']) {
596
+								 $array_typename = 'xsd:'.$tt;
597 597
 							} elseif ($tt_ns) {
598
-								$tt_prefix = 'ns' . rand(1000, 9999);
598
+								$tt_prefix = 'ns'.rand(1000, 9999);
599 599
 								$array_typename = "$tt_prefix:$tt";
600 600
 								$xmlns .= " xmlns:$tt_prefix=\"$tt_ns\"";
601 601
 							} else {
@@ -625,7 +625,7 @@  discard block
 block discarded – undo
625 625
 				} else {
626 626
 					// got a struct
627 627
 			   		$this->debug("serialize_val: serialize struct");
628
-					if(isset($type) && isset($type_prefix)){
628
+					if (isset($type) && isset($type_prefix)) {
629 629
 						$type_str = " xsi:type=\"$type_prefix:$type\"";
630 630
 					} else {
631 631
 						$type_str = '';
@@ -635,15 +635,15 @@  discard block
 block discarded – undo
635 635
 					} else {
636 636
 						$xml .= "<$name$xmlns$type_str$atts>";
637 637
 					}
638
-					foreach($val as $k => $v){
638
+					foreach ($val as $k => $v) {
639 639
 						// Apache Map
640 640
 						if ($type == 'Map' && $type_ns == 'http://xml.apache.org/xml-soap') {
641 641
 							$xml .= '<item>';
642
-							$xml .= $this->serialize_val($k,'key',false,false,false,false,$use);
643
-							$xml .= $this->serialize_val($v,'value',false,false,false,false,$use);
642
+							$xml .= $this->serialize_val($k, 'key', false, false, false, false, $use);
643
+							$xml .= $this->serialize_val($v, 'value', false, false, false, false, $use);
644 644
 							$xml .= '</item>';
645 645
 						} else {
646
-							$xml .= $this->serialize_val($v,$k,false,false,false,false,$use);
646
+							$xml .= $this->serialize_val($v, $k, false, false, false, false, $use);
647 647
 						}
648 648
 					}
649 649
 					$xml .= "</$name>";
@@ -670,12 +670,12 @@  discard block
 block discarded – undo
670 670
     * @return string the message
671 671
     * @access public
672 672
     */
673
-    function serializeEnvelope($body,$headers=false,$namespaces=array(),$style='rpc',$use='encoded',$encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'){
673
+    function serializeEnvelope($body, $headers = false, $namespaces = array(), $style = 'rpc', $use = 'encoded', $encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/') {
674 674
     // TODO: add an option to automatically run utf8_encode on $body and $headers
675 675
     // if $this->soap_defencoding is UTF-8.  Not doing this automatically allows
676 676
     // one to send arbitrary UTF-8 characters, not just characters that map to ISO-8859-1
677 677
 
678
-	$this->debug("In serializeEnvelope length=" . strlen($body) . " body (max 1000 characters)=" . substr($body, 0, 1000) . " style=$style use=$use encodingStyle=$encodingStyle");
678
+	$this->debug("In serializeEnvelope length=".strlen($body)." body (max 1000 characters)=".substr($body, 0, 1000)." style=$style use=$use encodingStyle=$encodingStyle");
679 679
 	$this->debug("headers:");
680 680
 	$this->appendDebug($this->varDump($headers));
681 681
 	$this->debug("namespaces:");
@@ -683,15 +683,15 @@  discard block
 block discarded – undo
683 683
 
684 684
 	// serialize namespaces
685 685
     $ns_string = '';
686
-	foreach(array_merge($this->namespaces,$namespaces) as $k => $v){
686
+	foreach (array_merge($this->namespaces, $namespaces) as $k => $v) {
687 687
 		$ns_string .= " xmlns:$k=\"$v\"";
688 688
 	}
689
-	if($encodingStyle) {
689
+	if ($encodingStyle) {
690 690
 		$ns_string = " SOAP-ENV:encodingStyle=\"$encodingStyle\"$ns_string";
691 691
 	}
692 692
 
693 693
 	// serialize headers
694
-	if($headers){
694
+	if ($headers) {
695 695
 		if (is_array($headers)) {
696 696
 			$xml = '';
697 697
 			foreach ($headers as $k => $v) {
@@ -708,7 +708,7 @@  discard block
 block discarded – undo
708 708
 	}
709 709
 	// serialize envelope
710 710
 	return
711
-	'<?xml version="1.0" encoding="'.$this->soap_defencoding .'"?'.">".
711
+	'<?xml version="1.0" encoding="'.$this->soap_defencoding.'"?'.">".
712 712
 	'<SOAP-ENV:Envelope'.$ns_string.">".
713 713
 	$headers.
714 714
 	"<SOAP-ENV:Body>".
@@ -725,7 +725,7 @@  discard block
 block discarded – undo
725 725
 	 * @access public
726 726
 	 * @deprecated
727 727
 	 */
728
-    function formatDump($str){
728
+    function formatDump($str) {
729 729
 		$str = htmlspecialchars($str);
730 730
 		return nl2br($str);
731 731
     }
@@ -737,7 +737,7 @@  discard block
 block discarded – undo
737 737
 	* @return	string contracted qname
738 738
 	* @access   private
739 739
 	*/
740
-	function contractQname($qname){
740
+	function contractQname($qname) {
741 741
 		// get element namespace
742 742
 		//$this->xdebug("Contract $qname");
743 743
 		if (strrpos($qname, ':')) {
@@ -747,7 +747,7 @@  discard block
 block discarded – undo
747 747
 			$ns = substr($qname, 0, strrpos($qname, ':'));
748 748
 			$p = $this->getPrefixFromNamespace($ns);
749 749
 			if ($p) {
750
-				return $p . ':' . $name;
750
+				return $p.':'.$name;
751 751
 			}
752 752
 			return $qname;
753 753
 		} else {
@@ -762,14 +762,14 @@  discard block
 block discarded – undo
762 762
 	* @return	string expanded qname
763 763
 	* @access   private
764 764
 	*/
765
-	function expandQname($qname){
765
+	function expandQname($qname) {
766 766
 		// get element prefix
767
-		if(strpos($qname,':') && !preg_match('/^http:\/\//',$qname)){
767
+		if (strpos($qname, ':') && !preg_match('/^http:\/\//', $qname)) {
768 768
 			// get unqualified name
769
-			$name = substr(strstr($qname,':'),1);
769
+			$name = substr(strstr($qname, ':'), 1);
770 770
 			// get ns prefix
771
-			$prefix = substr($qname,0,strpos($qname,':'));
772
-			if(isset($this->namespaces[$prefix])){
771
+			$prefix = substr($qname, 0, strpos($qname, ':'));
772
+			if (isset($this->namespaces[$prefix])) {
773 773
 				return $this->namespaces[$prefix].':'.$name;
774 774
 			} else {
775 775
 				return $qname;
@@ -787,10 +787,10 @@  discard block
 block discarded – undo
787 787
     * @return string The local part
788 788
     * @access public
789 789
     */
790
-	function getLocalPart($str){
791
-		if($sstr = strrchr($str,':')){
790
+	function getLocalPart($str) {
791
+		if ($sstr = strrchr($str, ':')) {
792 792
 			// get unqualified name
793
-			return substr( $sstr, 1 );
793
+			return substr($sstr, 1);
794 794
 		} else {
795 795
 			return $str;
796 796
 		}
@@ -804,10 +804,10 @@  discard block
 block discarded – undo
804 804
     * @return mixed The prefix or false if there is no prefix
805 805
     * @access public
806 806
     */
807
-	function getPrefix($str){
808
-		if($pos = strrpos($str,':')){
807
+	function getPrefix($str) {
808
+		if ($pos = strrpos($str, ':')) {
809 809
 			// get prefix
810
-			return substr($str,0,$pos);
810
+			return substr($str, 0, $pos);
811 811
 		}
812 812
 		return false;
813 813
 	}
@@ -819,7 +819,7 @@  discard block
 block discarded – undo
819 819
     * @return mixed The namespace, false if no namespace has the specified prefix
820 820
     * @access public
821 821
     */
822
-	function getNamespaceFromPrefix($prefix){
822
+	function getNamespaceFromPrefix($prefix) {
823 823
 		if (isset($this->namespaces[$prefix])) {
824 824
 			return $this->namespaces[$prefix];
825 825
 		}
@@ -860,7 +860,7 @@  discard block
 block discarded – undo
860 860
 			$sec = time();
861 861
 			$usec = 0;
862 862
 		}
863
-		return strftime('%Y-%m-%d %H:%M:%S', $sec) . '.' . sprintf('%06d', $usec);
863
+		return strftime('%Y-%m-%d %H:%M:%S', $sec).'.'.sprintf('%06d', $usec);
864 864
 	}
865 865
 
866 866
 	/**
@@ -901,31 +901,31 @@  discard block
 block discarded – undo
901 901
 * @return	mixed ISO 8601 date string or false
902 902
 * @access   public
903 903
 */
904
-function timestamp_to_iso8601($timestamp,$utc=true){
905
-	$datestr = date('Y-m-d\TH:i:sO',$timestamp);
904
+function timestamp_to_iso8601($timestamp, $utc = true) {
905
+	$datestr = date('Y-m-d\TH:i:sO', $timestamp);
906 906
 	$pos = strrpos($datestr, "+");
907 907
 	if ($pos === FALSE) {
908 908
 		$pos = strrpos($datestr, "-");
909 909
 	}
910 910
 	if ($pos !== FALSE) {
911 911
 		if (strlen($datestr) == $pos + 5) {
912
-			$datestr = substr($datestr, 0, $pos + 3) . ':' . substr($datestr, -2);
912
+			$datestr = substr($datestr, 0, $pos + 3).':'.substr($datestr, -2);
913 913
 		}
914 914
 	}
915
-	if($utc){
915
+	if ($utc) {
916 916
 		$pattern = '/'.
917
-		'([0-9]{4})-'.	// centuries & years CCYY-
918
-		'([0-9]{2})-'.	// months MM-
919
-		'([0-9]{2})'.	// days DD
920
-		'T'.			// separator T
921
-		'([0-9]{2}):'.	// hours hh:
922
-		'([0-9]{2}):'.	// minutes mm:
923
-		'([0-9]{2})(\.[0-9]*)?'. // seconds ss.ss...
924
-		'(Z|[+\-][0-9]{2}:?[0-9]{2})?'. // Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's
917
+		'([0-9]{4})-'.// centuries & years CCYY-
918
+		'([0-9]{2})-'.// months MM-
919
+		'([0-9]{2})'.// days DD
920
+		'T'.// separator T
921
+		'([0-9]{2}):'.// hours hh:
922
+		'([0-9]{2}):'.// minutes mm:
923
+		'([0-9]{2})(\.[0-9]*)?'.// seconds ss.ss...
924
+		'(Z|[+\-][0-9]{2}:?[0-9]{2})?'.// Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's
925 925
 		'/';
926 926
 
927
-		if(preg_match($pattern,$datestr,$regs)){
928
-			return sprintf('%04d-%02d-%02dT%02d:%02d:%02dZ',$regs[1],$regs[2],$regs[3],$regs[4],$regs[5],$regs[6]);
927
+		if (preg_match($pattern, $datestr, $regs)) {
928
+			return sprintf('%04d-%02d-%02dT%02d:%02d:%02dZ', $regs[1], $regs[2], $regs[3], $regs[4], $regs[5], $regs[6]);
929 929
 		}
930 930
 		return false;
931 931
 	} else {
@@ -940,27 +940,27 @@  discard block
 block discarded – undo
940 940
 * @return	mixed Unix timestamp (int) or false
941 941
 * @access   public
942 942
 */
943
-function iso8601_to_timestamp($datestr){
943
+function iso8601_to_timestamp($datestr) {
944 944
 	$pattern = '/'.
945
-	'([0-9]{4})-'.	// centuries & years CCYY-
946
-	'([0-9]{2})-'.	// months MM-
947
-	'([0-9]{2})'.	// days DD
948
-	'T'.			// separator T
949
-	'([0-9]{2}):'.	// hours hh:
950
-	'([0-9]{2}):'.	// minutes mm:
951
-	'([0-9]{2})(\.[0-9]+)?'. // seconds ss.ss...
952
-	'(Z|[+\-][0-9]{2}:?[0-9]{2})?'. // Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's
945
+	'([0-9]{4})-'.// centuries & years CCYY-
946
+	'([0-9]{2})-'.// months MM-
947
+	'([0-9]{2})'.// days DD
948
+	'T'.// separator T
949
+	'([0-9]{2}):'.// hours hh:
950
+	'([0-9]{2}):'.// minutes mm:
951
+	'([0-9]{2})(\.[0-9]+)?'.// seconds ss.ss...
952
+	'(Z|[+\-][0-9]{2}:?[0-9]{2})?'.// Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's
953 953
 	'/';
954
-	if(preg_match($pattern,$datestr,$regs)){
954
+	if (preg_match($pattern, $datestr, $regs)) {
955 955
 		// not utc
956
-		if($regs[8] != 'Z'){
957
-			$op = substr($regs[8],0,1);
958
-			$h = substr($regs[8],1,2);
959
-			$m = substr($regs[8],strlen($regs[8])-2,2);
960
-			if($op == '-'){
956
+		if ($regs[8] != 'Z') {
957
+			$op = substr($regs[8], 0, 1);
958
+			$h = substr($regs[8], 1, 2);
959
+			$m = substr($regs[8], strlen($regs[8]) - 2, 2);
960
+			if ($op == '-') {
961 961
 				$regs[4] = $regs[4] + $h;
962 962
 				$regs[5] = $regs[5] + $m;
963
-			} elseif($op == '+'){
963
+			} elseif ($op == '+') {
964 964
 				$regs[4] = $regs[4] - $h;
965 965
 				$regs[5] = $regs[5] - $m;
966 966
 			}
Please login to merge, or discard this patch.
Indentation   +845 added lines, -845 removed lines patch added patch discarded remove patch
@@ -83,809 +83,809 @@  discard block
 block discarded – undo
83 83
 * @access   public
84 84
 */
85 85
 class nusoap_base {
86
-	/**
87
-	 * Identification for HTTP headers.
88
-	 *
89
-	 * @var string
90
-	 * @access private
91
-	 */
92
-	var $title = 'NuSOAP';
93
-	/**
94
-	 * Version for HTTP headers.
95
-	 *
96
-	 * @var string
97
-	 * @access private
98
-	 */
99
-	var $version = '0.9.5';
100
-	/**
101
-	 * CVS revision for HTTP headers.
102
-	 *
103
-	 * @var string
104
-	 * @access private
105
-	 */
106
-	var $revision = '$Revision: 1.56 $';
86
+    /**
87
+     * Identification for HTTP headers.
88
+     *
89
+     * @var string
90
+     * @access private
91
+     */
92
+    var $title = 'NuSOAP';
93
+    /**
94
+     * Version for HTTP headers.
95
+     *
96
+     * @var string
97
+     * @access private
98
+     */
99
+    var $version = '0.9.5';
100
+    /**
101
+     * CVS revision for HTTP headers.
102
+     *
103
+     * @var string
104
+     * @access private
105
+     */
106
+    var $revision = '$Revision: 1.56 $';
107 107
     /**
108 108
      * Current error string (manipulated by getError/setError)
109
-	 *
110
-	 * @var string
111
-	 * @access private
112
-	 */
113
-	var $error_str = '';
109
+     *
110
+     * @var string
111
+     * @access private
112
+     */
113
+    var $error_str = '';
114 114
     /**
115 115
      * Current debug string (manipulated by debug/appendDebug/clearDebug/getDebug/getDebugAsXMLComment)
116
-	 *
117
-	 * @var string
118
-	 * @access private
119
-	 */
116
+     *
117
+     * @var string
118
+     * @access private
119
+     */
120 120
     var $debug_str = '';
121 121
     /**
122
-	 * toggles automatic encoding of special characters as entities
123
-	 * (should always be true, I think)
124
-	 *
125
-	 * @var boolean
126
-	 * @access private
127
-	 */
128
-	var $charencoding = true;
129
-	/**
130
-	 * the debug level for this instance
131
-	 *
132
-	 * @var	integer
133
-	 * @access private
134
-	 */
135
-	var $debugLevel;
136
-
137
-    /**
138
-	* set schema version
139
-	*
140
-	* @var      string
141
-	* @access   public
142
-	*/
143
-	var $XMLSchemaVersion = 'http://www.w3.org/2001/XMLSchema';
144
-
145
-    /**
146
-	* charset encoding for outgoing messages
147
-	*
148
-	* @var      string
149
-	* @access   public
150
-	*/
122
+     * toggles automatic encoding of special characters as entities
123
+     * (should always be true, I think)
124
+     *
125
+     * @var boolean
126
+     * @access private
127
+     */
128
+    var $charencoding = true;
129
+    /**
130
+     * the debug level for this instance
131
+     *
132
+     * @var	integer
133
+     * @access private
134
+     */
135
+    var $debugLevel;
136
+
137
+    /**
138
+     * set schema version
139
+     *
140
+     * @var      string
141
+     * @access   public
142
+     */
143
+    var $XMLSchemaVersion = 'http://www.w3.org/2001/XMLSchema';
144
+
145
+    /**
146
+     * charset encoding for outgoing messages
147
+     *
148
+     * @var      string
149
+     * @access   public
150
+     */
151 151
     var $soap_defencoding = 'ISO-8859-1';
152
-	//var $soap_defencoding = 'UTF-8';
153
-
154
-	/**
155
-	* namespaces in an array of prefix => uri
156
-	*
157
-	* this is "seeded" by a set of constants, but it may be altered by code
158
-	*
159
-	* @var      array
160
-	* @access   public
161
-	*/
162
-	var $namespaces = array(
163
-		'SOAP-ENV' => 'http://schemas.xmlsoap.org/soap/envelope/',
164
-		'xsd' => 'http://www.w3.org/2001/XMLSchema',
165
-		'xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
166
-		'SOAP-ENC' => 'http://schemas.xmlsoap.org/soap/encoding/'
167
-		);
168
-
169
-	/**
170
-	* namespaces used in the current context, e.g. during serialization
171
-	*
172
-	* @var      array
173
-	* @access   private
174
-	*/
175
-	var $usedNamespaces = array();
176
-
177
-	/**
178
-	* XML Schema types in an array of uri => (array of xml type => php type)
179
-	* is this legacy yet?
180
-	* no, this is used by the nusoap_xmlschema class to verify type => namespace mappings.
181
-	* @var      array
182
-	* @access   public
183
-	*/
184
-	var $typemap = array(
185
-	'http://www.w3.org/2001/XMLSchema' => array(
186
-		'string'=>'string','boolean'=>'boolean','float'=>'double','double'=>'double','decimal'=>'double',
187
-		'duration'=>'','dateTime'=>'string','time'=>'string','date'=>'string','gYearMonth'=>'',
188
-		'gYear'=>'','gMonthDay'=>'','gDay'=>'','gMonth'=>'','hexBinary'=>'string','base64Binary'=>'string',
189
-		// abstract "any" types
190
-		'anyType'=>'string','anySimpleType'=>'string',
191
-		// derived datatypes
192
-		'normalizedString'=>'string','token'=>'string','language'=>'','NMTOKEN'=>'','NMTOKENS'=>'','Name'=>'','NCName'=>'','ID'=>'',
193
-		'IDREF'=>'','IDREFS'=>'','ENTITY'=>'','ENTITIES'=>'','integer'=>'integer','nonPositiveInteger'=>'integer',
194
-		'negativeInteger'=>'integer','long'=>'integer','int'=>'integer','short'=>'integer','byte'=>'integer','nonNegativeInteger'=>'integer',
195
-		'unsignedLong'=>'','unsignedInt'=>'','unsignedShort'=>'','unsignedByte'=>'','positiveInteger'=>''),
196
-	'http://www.w3.org/2000/10/XMLSchema' => array(
197
-		'i4'=>'','int'=>'integer','boolean'=>'boolean','string'=>'string','double'=>'double',
198
-		'float'=>'double','dateTime'=>'string',
199
-		'timeInstant'=>'string','base64Binary'=>'string','base64'=>'string','ur-type'=>'array'),
200
-	'http://www.w3.org/1999/XMLSchema' => array(
201
-		'i4'=>'','int'=>'integer','boolean'=>'boolean','string'=>'string','double'=>'double',
202
-		'float'=>'double','dateTime'=>'string',
203
-		'timeInstant'=>'string','base64Binary'=>'string','base64'=>'string','ur-type'=>'array'),
204
-	'http://soapinterop.org/xsd' => array('SOAPStruct'=>'struct'),
205
-	'http://schemas.xmlsoap.org/soap/encoding/' => array('base64'=>'string','array'=>'array','Array'=>'array'),
152
+    //var $soap_defencoding = 'UTF-8';
153
+
154
+    /**
155
+     * namespaces in an array of prefix => uri
156
+     *
157
+     * this is "seeded" by a set of constants, but it may be altered by code
158
+     *
159
+     * @var      array
160
+     * @access   public
161
+     */
162
+    var $namespaces = array(
163
+        'SOAP-ENV' => 'http://schemas.xmlsoap.org/soap/envelope/',
164
+        'xsd' => 'http://www.w3.org/2001/XMLSchema',
165
+        'xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
166
+        'SOAP-ENC' => 'http://schemas.xmlsoap.org/soap/encoding/'
167
+        );
168
+
169
+    /**
170
+     * namespaces used in the current context, e.g. during serialization
171
+     *
172
+     * @var      array
173
+     * @access   private
174
+     */
175
+    var $usedNamespaces = array();
176
+
177
+    /**
178
+     * XML Schema types in an array of uri => (array of xml type => php type)
179
+     * is this legacy yet?
180
+     * no, this is used by the nusoap_xmlschema class to verify type => namespace mappings.
181
+     * @var      array
182
+     * @access   public
183
+     */
184
+    var $typemap = array(
185
+    'http://www.w3.org/2001/XMLSchema' => array(
186
+        'string'=>'string','boolean'=>'boolean','float'=>'double','double'=>'double','decimal'=>'double',
187
+        'duration'=>'','dateTime'=>'string','time'=>'string','date'=>'string','gYearMonth'=>'',
188
+        'gYear'=>'','gMonthDay'=>'','gDay'=>'','gMonth'=>'','hexBinary'=>'string','base64Binary'=>'string',
189
+        // abstract "any" types
190
+        'anyType'=>'string','anySimpleType'=>'string',
191
+        // derived datatypes
192
+        'normalizedString'=>'string','token'=>'string','language'=>'','NMTOKEN'=>'','NMTOKENS'=>'','Name'=>'','NCName'=>'','ID'=>'',
193
+        'IDREF'=>'','IDREFS'=>'','ENTITY'=>'','ENTITIES'=>'','integer'=>'integer','nonPositiveInteger'=>'integer',
194
+        'negativeInteger'=>'integer','long'=>'integer','int'=>'integer','short'=>'integer','byte'=>'integer','nonNegativeInteger'=>'integer',
195
+        'unsignedLong'=>'','unsignedInt'=>'','unsignedShort'=>'','unsignedByte'=>'','positiveInteger'=>''),
196
+    'http://www.w3.org/2000/10/XMLSchema' => array(
197
+        'i4'=>'','int'=>'integer','boolean'=>'boolean','string'=>'string','double'=>'double',
198
+        'float'=>'double','dateTime'=>'string',
199
+        'timeInstant'=>'string','base64Binary'=>'string','base64'=>'string','ur-type'=>'array'),
200
+    'http://www.w3.org/1999/XMLSchema' => array(
201
+        'i4'=>'','int'=>'integer','boolean'=>'boolean','string'=>'string','double'=>'double',
202
+        'float'=>'double','dateTime'=>'string',
203
+        'timeInstant'=>'string','base64Binary'=>'string','base64'=>'string','ur-type'=>'array'),
204
+    'http://soapinterop.org/xsd' => array('SOAPStruct'=>'struct'),
205
+    'http://schemas.xmlsoap.org/soap/encoding/' => array('base64'=>'string','array'=>'array','Array'=>'array'),
206 206
     'http://xml.apache.org/xml-soap' => array('Map')
207
-	);
208
-
209
-	/**
210
-	* XML entities to convert
211
-	*
212
-	* @var      array
213
-	* @access   public
214
-	* @deprecated
215
-	* @see	expandEntities
216
-	*/
217
-	var $xmlEntities = array('quot' => '"','amp' => '&',
218
-		'lt' => '<','gt' => '>','apos' => "'");
219
-
220
-	/**
221
-	* constructor
222
-	*
223
-	* @access	public
224
-	*/
225
-	function __construct() {
226
-		$this->debugLevel = $GLOBALS['_transient']['static']['nusoap_base']['globalDebugLevel'];
227
-	}
228
-
229
-	/**
230
-	* gets the global debug level, which applies to future instances
231
-	*
232
-	* @return	integer	Debug level 0-9, where 0 turns off
233
-	* @access	public
234
-	*/
235
-	function getGlobalDebugLevel() {
236
-		return $GLOBALS['_transient']['static']['nusoap_base']['globalDebugLevel'];
237
-	}
238
-
239
-	/**
240
-	* sets the global debug level, which applies to future instances
241
-	*
242
-	* @param	int	$level	Debug level 0-9, where 0 turns off
243
-	* @access	public
244
-	*/
245
-	function setGlobalDebugLevel($level) {
246
-		$GLOBALS['_transient']['static']['nusoap_base']['globalDebugLevel'] = $level;
247
-	}
248
-
249
-	/**
250
-	* gets the debug level for this instance
251
-	*
252
-	* @return	int	Debug level 0-9, where 0 turns off
253
-	* @access	public
254
-	*/
255
-	function getDebugLevel() {
256
-		return $this->debugLevel;
257
-	}
258
-
259
-	/**
260
-	* sets the debug level for this instance
261
-	*
262
-	* @param	int	$level	Debug level 0-9, where 0 turns off
263
-	* @access	public
264
-	*/
265
-	function setDebugLevel($level) {
266
-		$this->debugLevel = $level;
267
-	}
268
-
269
-	/**
270
-	* adds debug data to the instance debug string with formatting
271
-	*
272
-	* @param    string $string debug data
273
-	* @access   private
274
-	*/
275
-	function debug($string){
276
-		if ($this->debugLevel > 0) {
277
-			$this->appendDebug($this->getmicrotime().' '.get_class($this).": $string\n");
278
-		}
279
-	}
280
-
281
-	/**
282
-	* adds debug data to the instance debug string without formatting
283
-	*
284
-	* @param    string $string debug data
285
-	* @access   public
286
-	*/
287
-	function appendDebug($string){
288
-		if ($this->debugLevel > 0) {
289
-			// it would be nice to use a memory stream here to use
290
-			// memory more efficiently
291
-			$this->debug_str .= $string;
292
-		}
293
-	}
294
-
295
-	/**
296
-	* clears the current debug data for this instance
297
-	*
298
-	* @access   public
299
-	*/
300
-	function clearDebug() {
301
-		// it would be nice to use a memory stream here to use
302
-		// memory more efficiently
303
-		$this->debug_str = '';
304
-	}
305
-
306
-	/**
307
-	* gets the current debug data for this instance
308
-	*
309
-	* @return   debug data
310
-	* @access   public
311
-	*/
312
-	function &getDebug() {
313
-		// it would be nice to use a memory stream here to use
314
-		// memory more efficiently
315
-		return $this->debug_str;
316
-	}
317
-
318
-	/**
319
-	* gets the current debug data for this instance as an XML comment
320
-	* this may change the contents of the debug data
321
-	*
322
-	* @return   debug data as an XML comment
323
-	* @access   public
324
-	*/
325
-	function &getDebugAsXMLComment() {
326
-		// it would be nice to use a memory stream here to use
327
-		// memory more efficiently
328
-		while (strpos($this->debug_str, '--')) {
329
-			$this->debug_str = str_replace('--', '- -', $this->debug_str);
330
-		}
331
-		$ret = "<!--\n" . $this->debug_str . "\n-->";
332
-    	return $ret;
333
-	}
334
-
335
-	/**
336
-	* expands entities, e.g. changes '<' to '&lt;'.
337
-	*
338
-	* @param	string	$val	The string in which to expand entities.
339
-	* @access	private
340
-	*/
341
-	function expandEntities($val) {
342
-		if ($this->charencoding) {
343
-	    	$val = str_replace('&', '&amp;', $val);
344
-	    	$val = str_replace("'", '&apos;', $val);
345
-	    	$val = str_replace('"', '&quot;', $val);
346
-	    	$val = str_replace('<', '&lt;', $val);
347
-	    	$val = str_replace('>', '&gt;', $val);
348
-	    }
349
-	    return $val;
350
-	}
351
-
352
-	/**
353
-	* returns error string if present
354
-	*
355
-	* @return   mixed error string or false
356
-	* @access   public
357
-	*/
358
-	function getError(){
359
-		if($this->error_str != ''){
360
-			return $this->error_str;
361
-		}
362
-		return false;
363
-	}
364
-
365
-	/**
366
-	* sets error string
367
-	*
368
-	* @return   boolean $string error string
369
-	* @access   private
370
-	*/
371
-	function setError($str){
372
-		$this->error_str = $str;
373
-	}
374
-
375
-	/**
376
-	* detect if array is a simple array or a struct (associative array)
377
-	*
378
-	* @param	mixed	$val	The PHP array
379
-	* @return	string	(arraySimple|arrayStruct)
380
-	* @access	private
381
-	*/
382
-	function isArraySimpleOrStruct($val) {
207
+    );
208
+
209
+    /**
210
+     * XML entities to convert
211
+     *
212
+     * @var      array
213
+     * @access   public
214
+     * @deprecated
215
+     * @see	expandEntities
216
+     */
217
+    var $xmlEntities = array('quot' => '"','amp' => '&',
218
+        'lt' => '<','gt' => '>','apos' => "'");
219
+
220
+    /**
221
+     * constructor
222
+     *
223
+     * @access	public
224
+     */
225
+    function __construct() {
226
+        $this->debugLevel = $GLOBALS['_transient']['static']['nusoap_base']['globalDebugLevel'];
227
+    }
228
+
229
+    /**
230
+     * gets the global debug level, which applies to future instances
231
+     *
232
+     * @return	integer	Debug level 0-9, where 0 turns off
233
+     * @access	public
234
+     */
235
+    function getGlobalDebugLevel() {
236
+        return $GLOBALS['_transient']['static']['nusoap_base']['globalDebugLevel'];
237
+    }
238
+
239
+    /**
240
+     * sets the global debug level, which applies to future instances
241
+     *
242
+     * @param	int	$level	Debug level 0-9, where 0 turns off
243
+     * @access	public
244
+     */
245
+    function setGlobalDebugLevel($level) {
246
+        $GLOBALS['_transient']['static']['nusoap_base']['globalDebugLevel'] = $level;
247
+    }
248
+
249
+    /**
250
+     * gets the debug level for this instance
251
+     *
252
+     * @return	int	Debug level 0-9, where 0 turns off
253
+     * @access	public
254
+     */
255
+    function getDebugLevel() {
256
+        return $this->debugLevel;
257
+    }
258
+
259
+    /**
260
+     * sets the debug level for this instance
261
+     *
262
+     * @param	int	$level	Debug level 0-9, where 0 turns off
263
+     * @access	public
264
+     */
265
+    function setDebugLevel($level) {
266
+        $this->debugLevel = $level;
267
+    }
268
+
269
+    /**
270
+     * adds debug data to the instance debug string with formatting
271
+     *
272
+     * @param    string $string debug data
273
+     * @access   private
274
+     */
275
+    function debug($string){
276
+        if ($this->debugLevel > 0) {
277
+            $this->appendDebug($this->getmicrotime().' '.get_class($this).": $string\n");
278
+        }
279
+    }
280
+
281
+    /**
282
+     * adds debug data to the instance debug string without formatting
283
+     *
284
+     * @param    string $string debug data
285
+     * @access   public
286
+     */
287
+    function appendDebug($string){
288
+        if ($this->debugLevel > 0) {
289
+            // it would be nice to use a memory stream here to use
290
+            // memory more efficiently
291
+            $this->debug_str .= $string;
292
+        }
293
+    }
294
+
295
+    /**
296
+     * clears the current debug data for this instance
297
+     *
298
+     * @access   public
299
+     */
300
+    function clearDebug() {
301
+        // it would be nice to use a memory stream here to use
302
+        // memory more efficiently
303
+        $this->debug_str = '';
304
+    }
305
+
306
+    /**
307
+     * gets the current debug data for this instance
308
+     *
309
+     * @return   debug data
310
+     * @access   public
311
+     */
312
+    function &getDebug() {
313
+        // it would be nice to use a memory stream here to use
314
+        // memory more efficiently
315
+        return $this->debug_str;
316
+    }
317
+
318
+    /**
319
+     * gets the current debug data for this instance as an XML comment
320
+     * this may change the contents of the debug data
321
+     *
322
+     * @return   debug data as an XML comment
323
+     * @access   public
324
+     */
325
+    function &getDebugAsXMLComment() {
326
+        // it would be nice to use a memory stream here to use
327
+        // memory more efficiently
328
+        while (strpos($this->debug_str, '--')) {
329
+            $this->debug_str = str_replace('--', '- -', $this->debug_str);
330
+        }
331
+        $ret = "<!--\n" . $this->debug_str . "\n-->";
332
+        return $ret;
333
+    }
334
+
335
+    /**
336
+     * expands entities, e.g. changes '<' to '&lt;'.
337
+     *
338
+     * @param	string	$val	The string in which to expand entities.
339
+     * @access	private
340
+     */
341
+    function expandEntities($val) {
342
+        if ($this->charencoding) {
343
+            $val = str_replace('&', '&amp;', $val);
344
+            $val = str_replace("'", '&apos;', $val);
345
+            $val = str_replace('"', '&quot;', $val);
346
+            $val = str_replace('<', '&lt;', $val);
347
+            $val = str_replace('>', '&gt;', $val);
348
+        }
349
+        return $val;
350
+    }
351
+
352
+    /**
353
+     * returns error string if present
354
+     *
355
+     * @return   mixed error string or false
356
+     * @access   public
357
+     */
358
+    function getError(){
359
+        if($this->error_str != ''){
360
+            return $this->error_str;
361
+        }
362
+        return false;
363
+    }
364
+
365
+    /**
366
+     * sets error string
367
+     *
368
+     * @return   boolean $string error string
369
+     * @access   private
370
+     */
371
+    function setError($str){
372
+        $this->error_str = $str;
373
+    }
374
+
375
+    /**
376
+     * detect if array is a simple array or a struct (associative array)
377
+     *
378
+     * @param	mixed	$val	The PHP array
379
+     * @return	string	(arraySimple|arrayStruct)
380
+     * @access	private
381
+     */
382
+    function isArraySimpleOrStruct($val) {
383 383
         $keyList = array_keys($val);
384
-		foreach ($keyList as $keyListValue) {
385
-			if (!is_int($keyListValue)) {
386
-				return 'arrayStruct';
387
-			}
388
-		}
389
-		return 'arraySimple';
390
-	}
391
-
392
-	/**
393
-	* serializes PHP values in accordance w/ section 5. Type information is
394
-	* not serialized if $use == 'literal'.
395
-	*
396
-	* @param	mixed	$val	The value to serialize
397
-	* @param	string	$name	The name (local part) of the XML element
398
-	* @param	string	$type	The XML schema type (local part) for the element
399
-	* @param	string	$name_ns	The namespace for the name of the XML element
400
-	* @param	string	$type_ns	The namespace for the type of the element
401
-	* @param	array	$attributes	The attributes to serialize as name=>value pairs
402
-	* @param	string	$use	The WSDL "use" (encoded|literal)
403
-	* @param	boolean	$soapval	Whether this is called from soapval.
404
-	* @return	string	The serialized element, possibly with child elements
405
-    * @access	public
406
-	*/
407
-	function serialize_val($val,$name=false,$type=false,$name_ns=false,$type_ns=false,$attributes=false,$use='encoded',$soapval=false) {
408
-		$this->debug("in serialize_val: name=$name, type=$type, name_ns=$name_ns, type_ns=$type_ns, use=$use, soapval=$soapval");
409
-		$this->appendDebug('value=' . $this->varDump($val));
410
-		$this->appendDebug('attributes=' . $this->varDump($attributes));
411
-
412
-    	if (is_object($val) && get_class($val) == 'soapval' && (! $soapval)) {
413
-    		$this->debug("serialize_val: serialize soapval");
414
-        	$xml = $val->serialize($use);
415
-			$this->appendDebug($val->getDebug());
416
-			$val->clearDebug();
417
-			$this->debug("serialize_val of soapval returning $xml");
418
-			return $xml;
384
+        foreach ($keyList as $keyListValue) {
385
+            if (!is_int($keyListValue)) {
386
+                return 'arrayStruct';
387
+            }
419 388
         }
420
-		// force valid name if necessary
421
-		if (is_numeric($name)) {
422
-			$name = '__numeric_' . $name;
423
-		} elseif (! $name) {
424
-			$name = 'noname';
425
-		}
426
-		// if name has ns, add ns prefix to name
427
-		$xmlns = '';
389
+        return 'arraySimple';
390
+    }
391
+
392
+    /**
393
+     * serializes PHP values in accordance w/ section 5. Type information is
394
+     * not serialized if $use == 'literal'.
395
+     *
396
+     * @param	mixed	$val	The value to serialize
397
+     * @param	string	$name	The name (local part) of the XML element
398
+     * @param	string	$type	The XML schema type (local part) for the element
399
+     * @param	string	$name_ns	The namespace for the name of the XML element
400
+     * @param	string	$type_ns	The namespace for the type of the element
401
+     * @param	array	$attributes	The attributes to serialize as name=>value pairs
402
+     * @param	string	$use	The WSDL "use" (encoded|literal)
403
+     * @param	boolean	$soapval	Whether this is called from soapval.
404
+     * @return	string	The serialized element, possibly with child elements
405
+     * @access	public
406
+     */
407
+    function serialize_val($val,$name=false,$type=false,$name_ns=false,$type_ns=false,$attributes=false,$use='encoded',$soapval=false) {
408
+        $this->debug("in serialize_val: name=$name, type=$type, name_ns=$name_ns, type_ns=$type_ns, use=$use, soapval=$soapval");
409
+        $this->appendDebug('value=' . $this->varDump($val));
410
+        $this->appendDebug('attributes=' . $this->varDump($attributes));
411
+
412
+        if (is_object($val) && get_class($val) == 'soapval' && (! $soapval)) {
413
+            $this->debug("serialize_val: serialize soapval");
414
+            $xml = $val->serialize($use);
415
+            $this->appendDebug($val->getDebug());
416
+            $val->clearDebug();
417
+            $this->debug("serialize_val of soapval returning $xml");
418
+            return $xml;
419
+        }
420
+        // force valid name if necessary
421
+        if (is_numeric($name)) {
422
+            $name = '__numeric_' . $name;
423
+        } elseif (! $name) {
424
+            $name = 'noname';
425
+        }
426
+        // if name has ns, add ns prefix to name
427
+        $xmlns = '';
428 428
         if($name_ns){
429
-			$prefix = 'nu'.rand(1000,9999);
430
-			$name = $prefix.':'.$name;
431
-			$xmlns .= " xmlns:$prefix=\"$name_ns\"";
432
-		}
433
-		// if type is prefixed, create type prefix
434
-		if($type_ns != '' && $type_ns == $this->namespaces['xsd']){
435
-			// need to fix this. shouldn't default to xsd if no ns specified
436
-		    // w/o checking against typemap
437
-			$type_prefix = 'xsd';
438
-		} elseif($type_ns){
439
-			$type_prefix = 'ns'.rand(1000,9999);
440
-			$xmlns .= " xmlns:$type_prefix=\"$type_ns\"";
441
-		}
442
-		// serialize attributes if present
443
-		$atts = '';
444
-		if($attributes){
445
-			foreach($attributes as $k => $v){
446
-				$atts .= " $k=\"".$this->expandEntities($v).'"';
447
-			}
448
-		}
449
-		// serialize null value
450
-		if (is_null($val)) {
451
-    		$this->debug("serialize_val: serialize null");
452
-			if ($use == 'literal') {
453
-				// TODO: depends on minOccurs
454
-				$xml = "<$name$xmlns$atts/>";
455
-				$this->debug("serialize_val returning $xml");
456
-	        	return $xml;
457
-        	} else {
458
-				if (isset($type) && isset($type_prefix)) {
459
-					$type_str = " xsi:type=\"$type_prefix:$type\"";
460
-				} else {
461
-					$type_str = '';
462
-				}
463
-				$xml = "<$name$xmlns$type_str$atts xsi:nil=\"true\"/>";
464
-				$this->debug("serialize_val returning $xml");
465
-	        	return $xml;
466
-        	}
467
-		}
429
+            $prefix = 'nu'.rand(1000,9999);
430
+            $name = $prefix.':'.$name;
431
+            $xmlns .= " xmlns:$prefix=\"$name_ns\"";
432
+        }
433
+        // if type is prefixed, create type prefix
434
+        if($type_ns != '' && $type_ns == $this->namespaces['xsd']){
435
+            // need to fix this. shouldn't default to xsd if no ns specified
436
+            // w/o checking against typemap
437
+            $type_prefix = 'xsd';
438
+        } elseif($type_ns){
439
+            $type_prefix = 'ns'.rand(1000,9999);
440
+            $xmlns .= " xmlns:$type_prefix=\"$type_ns\"";
441
+        }
442
+        // serialize attributes if present
443
+        $atts = '';
444
+        if($attributes){
445
+            foreach($attributes as $k => $v){
446
+                $atts .= " $k=\"".$this->expandEntities($v).'"';
447
+            }
448
+        }
449
+        // serialize null value
450
+        if (is_null($val)) {
451
+            $this->debug("serialize_val: serialize null");
452
+            if ($use == 'literal') {
453
+                // TODO: depends on minOccurs
454
+                $xml = "<$name$xmlns$atts/>";
455
+                $this->debug("serialize_val returning $xml");
456
+                return $xml;
457
+            } else {
458
+                if (isset($type) && isset($type_prefix)) {
459
+                    $type_str = " xsi:type=\"$type_prefix:$type\"";
460
+                } else {
461
+                    $type_str = '';
462
+                }
463
+                $xml = "<$name$xmlns$type_str$atts xsi:nil=\"true\"/>";
464
+                $this->debug("serialize_val returning $xml");
465
+                return $xml;
466
+            }
467
+        }
468 468
         // serialize if an xsd built-in primitive type
469 469
         if($type != '' && isset($this->typemap[$this->XMLSchemaVersion][$type])){
470
-    		$this->debug("serialize_val: serialize xsd built-in primitive type");
471
-        	if (is_bool($val)) {
472
-        		if ($type == 'boolean') {
473
-	        		$val = $val ? 'true' : 'false';
474
-	        	} elseif (! $val) {
475
-	        		$val = 0;
476
-	        	}
477
-			} else if (is_string($val)) {
478
-				$val = $this->expandEntities($val);
479
-			}
480
-			if ($use == 'literal') {
481
-				$xml = "<$name$xmlns$atts>$val</$name>";
482
-				$this->debug("serialize_val returning $xml");
483
-	        	return $xml;
484
-        	} else {
485
-				$xml = "<$name$xmlns xsi:type=\"xsd:$type\"$atts>$val</$name>";
486
-				$this->debug("serialize_val returning $xml");
487
-	        	return $xml;
488
-        	}
470
+            $this->debug("serialize_val: serialize xsd built-in primitive type");
471
+            if (is_bool($val)) {
472
+                if ($type == 'boolean') {
473
+                    $val = $val ? 'true' : 'false';
474
+                } elseif (! $val) {
475
+                    $val = 0;
476
+                }
477
+            } else if (is_string($val)) {
478
+                $val = $this->expandEntities($val);
479
+            }
480
+            if ($use == 'literal') {
481
+                $xml = "<$name$xmlns$atts>$val</$name>";
482
+                $this->debug("serialize_val returning $xml");
483
+                return $xml;
484
+            } else {
485
+                $xml = "<$name$xmlns xsi:type=\"xsd:$type\"$atts>$val</$name>";
486
+                $this->debug("serialize_val returning $xml");
487
+                return $xml;
488
+            }
489 489
         }
490
-		// detect type and serialize
491
-		$xml = '';
492
-		switch(true) {
493
-			case (is_bool($val) || $type == 'boolean'):
494
-		   		$this->debug("serialize_val: serialize boolean");
495
-        		if ($type == 'boolean') {
496
-	        		$val = $val ? 'true' : 'false';
497
-	        	} elseif (! $val) {
498
-	        		$val = 0;
499
-	        	}
500
-				if ($use == 'literal') {
501
-					$xml .= "<$name$xmlns$atts>$val</$name>";
502
-				} else {
503
-					$xml .= "<$name$xmlns xsi:type=\"xsd:boolean\"$atts>$val</$name>";
504
-				}
505
-				break;
506
-			case (is_int($val) || is_long($val) || $type == 'int'):
507
-		   		$this->debug("serialize_val: serialize int");
508
-				if ($use == 'literal') {
509
-					$xml .= "<$name$xmlns$atts>$val</$name>";
510
-				} else {
511
-					$xml .= "<$name$xmlns xsi:type=\"xsd:int\"$atts>$val</$name>";
512
-				}
513
-				break;
514
-			case (is_float($val)|| is_double($val) || $type == 'float'):
515
-		   		$this->debug("serialize_val: serialize float");
516
-				if ($use == 'literal') {
517
-					$xml .= "<$name$xmlns$atts>$val</$name>";
518
-				} else {
519
-					$xml .= "<$name$xmlns xsi:type=\"xsd:float\"$atts>$val</$name>";
520
-				}
521
-				break;
522
-			case (is_string($val) || $type == 'string'):
523
-		   		$this->debug("serialize_val: serialize string");
524
-				$val = $this->expandEntities($val);
525
-				if ($use == 'literal') {
526
-					$xml .= "<$name$xmlns$atts>$val</$name>";
527
-				} else {
528
-					$xml .= "<$name$xmlns xsi:type=\"xsd:string\"$atts>$val</$name>";
529
-				}
530
-				break;
531
-			case is_object($val):
532
-		   		$this->debug("serialize_val: serialize object");
533
-		    	if (get_class($val) == 'soapval') {
534
-		    		$this->debug("serialize_val: serialize soapval object");
535
-		        	$pXml = $val->serialize($use);
536
-					$this->appendDebug($val->getDebug());
537
-					$val->clearDebug();
538
-		        } else {
539
-					if (! $name) {
540
-						$name = get_class($val);
541
-						$this->debug("In serialize_val, used class name $name as element name");
542
-					} else {
543
-						$this->debug("In serialize_val, do not override name $name for element name for class " . get_class($val));
544
-					}
545
-					foreach(get_object_vars($val) as $k => $v){
546
-						$pXml = isset($pXml) ? $pXml.$this->serialize_val($v,$k,false,false,false,false,$use) : $this->serialize_val($v,$k,false,false,false,false,$use);
547
-					}
548
-				}
549
-				if(isset($type) && isset($type_prefix)){
550
-					$type_str = " xsi:type=\"$type_prefix:$type\"";
551
-				} else {
552
-					$type_str = '';
553
-				}
554
-				if ($use == 'literal') {
555
-					$xml .= "<$name$xmlns$atts>$pXml</$name>";
556
-				} else {
557
-					$xml .= "<$name$xmlns$type_str$atts>$pXml</$name>";
558
-				}
559
-				break;
560
-			case (is_array($val) || $type):
561
-				// detect if struct or array
562
-				$valueType = $this->isArraySimpleOrStruct($val);
490
+        // detect type and serialize
491
+        $xml = '';
492
+        switch(true) {
493
+            case (is_bool($val) || $type == 'boolean'):
494
+                   $this->debug("serialize_val: serialize boolean");
495
+                if ($type == 'boolean') {
496
+                    $val = $val ? 'true' : 'false';
497
+                } elseif (! $val) {
498
+                    $val = 0;
499
+                }
500
+                if ($use == 'literal') {
501
+                    $xml .= "<$name$xmlns$atts>$val</$name>";
502
+                } else {
503
+                    $xml .= "<$name$xmlns xsi:type=\"xsd:boolean\"$atts>$val</$name>";
504
+                }
505
+                break;
506
+            case (is_int($val) || is_long($val) || $type == 'int'):
507
+                   $this->debug("serialize_val: serialize int");
508
+                if ($use == 'literal') {
509
+                    $xml .= "<$name$xmlns$atts>$val</$name>";
510
+                } else {
511
+                    $xml .= "<$name$xmlns xsi:type=\"xsd:int\"$atts>$val</$name>";
512
+                }
513
+                break;
514
+            case (is_float($val)|| is_double($val) || $type == 'float'):
515
+                   $this->debug("serialize_val: serialize float");
516
+                if ($use == 'literal') {
517
+                    $xml .= "<$name$xmlns$atts>$val</$name>";
518
+                } else {
519
+                    $xml .= "<$name$xmlns xsi:type=\"xsd:float\"$atts>$val</$name>";
520
+                }
521
+                break;
522
+            case (is_string($val) || $type == 'string'):
523
+                   $this->debug("serialize_val: serialize string");
524
+                $val = $this->expandEntities($val);
525
+                if ($use == 'literal') {
526
+                    $xml .= "<$name$xmlns$atts>$val</$name>";
527
+                } else {
528
+                    $xml .= "<$name$xmlns xsi:type=\"xsd:string\"$atts>$val</$name>";
529
+                }
530
+                break;
531
+            case is_object($val):
532
+                   $this->debug("serialize_val: serialize object");
533
+                if (get_class($val) == 'soapval') {
534
+                    $this->debug("serialize_val: serialize soapval object");
535
+                    $pXml = $val->serialize($use);
536
+                    $this->appendDebug($val->getDebug());
537
+                    $val->clearDebug();
538
+                } else {
539
+                    if (! $name) {
540
+                        $name = get_class($val);
541
+                        $this->debug("In serialize_val, used class name $name as element name");
542
+                    } else {
543
+                        $this->debug("In serialize_val, do not override name $name for element name for class " . get_class($val));
544
+                    }
545
+                    foreach(get_object_vars($val) as $k => $v){
546
+                        $pXml = isset($pXml) ? $pXml.$this->serialize_val($v,$k,false,false,false,false,$use) : $this->serialize_val($v,$k,false,false,false,false,$use);
547
+                    }
548
+                }
549
+                if(isset($type) && isset($type_prefix)){
550
+                    $type_str = " xsi:type=\"$type_prefix:$type\"";
551
+                } else {
552
+                    $type_str = '';
553
+                }
554
+                if ($use == 'literal') {
555
+                    $xml .= "<$name$xmlns$atts>$pXml</$name>";
556
+                } else {
557
+                    $xml .= "<$name$xmlns$type_str$atts>$pXml</$name>";
558
+                }
559
+                break;
560
+            case (is_array($val) || $type):
561
+                // detect if struct or array
562
+                $valueType = $this->isArraySimpleOrStruct($val);
563 563
                 if($valueType=='arraySimple' || preg_match('/^ArrayOf/',$type)){
564
-			   		$this->debug("serialize_val: serialize array");
565
-					$i = 0;
566
-					if(is_array($val) && count($val)> 0){
567
-						foreach($val as $v){
568
-	                    	if(is_object($v) && get_class($v) ==  'soapval'){
569
-								$tt_ns = $v->type_ns;
570
-								$tt = $v->type;
571
-							} elseif (is_array($v)) {
572
-								$tt = $this->isArraySimpleOrStruct($v);
573
-							} else {
574
-								$tt = gettype($v);
575
-	                        }
576
-							$array_types[$tt] = 1;
577
-							// TODO: for literal, the name should be $name
578
-							$xml .= $this->serialize_val($v,'item',false,false,false,false,$use);
579
-							++$i;
580
-						}
581
-						if(count($array_types) > 1){
582
-							$array_typename = 'xsd:anyType';
583
-						} elseif(isset($tt) && isset($this->typemap[$this->XMLSchemaVersion][$tt])) {
584
-							if ($tt == 'integer') {
585
-								$tt = 'int';
586
-							}
587
-							$array_typename = 'xsd:'.$tt;
588
-						} elseif(isset($tt) && $tt == 'arraySimple'){
589
-							$array_typename = 'SOAP-ENC:Array';
590
-						} elseif(isset($tt) && $tt == 'arrayStruct'){
591
-							$array_typename = 'unnamed_struct_use_soapval';
592
-						} else {
593
-							// if type is prefixed, create type prefix
594
-							if ($tt_ns != '' && $tt_ns == $this->namespaces['xsd']){
595
-								 $array_typename = 'xsd:' . $tt;
596
-							} elseif ($tt_ns) {
597
-								$tt_prefix = 'ns' . rand(1000, 9999);
598
-								$array_typename = "$tt_prefix:$tt";
599
-								$xmlns .= " xmlns:$tt_prefix=\"$tt_ns\"";
600
-							} else {
601
-								$array_typename = $tt;
602
-							}
603
-						}
604
-						$array_type = $i;
605
-						if ($use == 'literal') {
606
-							$type_str = '';
607
-						} else if (isset($type) && isset($type_prefix)) {
608
-							$type_str = " xsi:type=\"$type_prefix:$type\"";
609
-						} else {
610
-							$type_str = " xsi:type=\"SOAP-ENC:Array\" SOAP-ENC:arrayType=\"".$array_typename."[$array_type]\"";
611
-						}
612
-					// empty array
613
-					} else {
614
-						if ($use == 'literal') {
615
-							$type_str = '';
616
-						} else if (isset($type) && isset($type_prefix)) {
617
-							$type_str = " xsi:type=\"$type_prefix:$type\"";
618
-						} else {
619
-							$type_str = " xsi:type=\"SOAP-ENC:Array\" SOAP-ENC:arrayType=\"xsd:anyType[0]\"";
620
-						}
621
-					}
622
-					// TODO: for array in literal, there is no wrapper here
623
-					$xml = "<$name$xmlns$type_str$atts>".$xml."</$name>";
624
-				} else {
625
-					// got a struct
626
-			   		$this->debug("serialize_val: serialize struct");
627
-					if(isset($type) && isset($type_prefix)){
628
-						$type_str = " xsi:type=\"$type_prefix:$type\"";
629
-					} else {
630
-						$type_str = '';
631
-					}
632
-					if ($use == 'literal') {
633
-						$xml .= "<$name$xmlns$atts>";
634
-					} else {
635
-						$xml .= "<$name$xmlns$type_str$atts>";
636
-					}
637
-					foreach($val as $k => $v){
638
-						// Apache Map
639
-						if ($type == 'Map' && $type_ns == 'http://xml.apache.org/xml-soap') {
640
-							$xml .= '<item>';
641
-							$xml .= $this->serialize_val($k,'key',false,false,false,false,$use);
642
-							$xml .= $this->serialize_val($v,'value',false,false,false,false,$use);
643
-							$xml .= '</item>';
644
-						} else {
645
-							$xml .= $this->serialize_val($v,$k,false,false,false,false,$use);
646
-						}
647
-					}
648
-					$xml .= "</$name>";
649
-				}
650
-				break;
651
-			default:
652
-		   		$this->debug("serialize_val: serialize unknown");
653
-				$xml .= 'not detected, got '.gettype($val).' for '.$val;
654
-				break;
655
-		}
656
-		$this->debug("serialize_val returning $xml");
657
-		return $xml;
658
-	}
659
-
660
-    /**
661
-    * serializes a message
662
-    *
663
-    * @param string $body the XML of the SOAP body
664
-    * @param mixed $headers optional string of XML with SOAP header content, or array of soapval objects for SOAP headers, or associative array
665
-    * @param array $namespaces optional the namespaces used in generating the body and headers
666
-    * @param string $style optional (rpc|document)
667
-    * @param string $use optional (encoded|literal)
668
-    * @param string $encodingStyle optional (usually 'http://schemas.xmlsoap.org/soap/encoding/' for encoded)
669
-    * @return string the message
670
-    * @access public
671
-    */
564
+                        $this->debug("serialize_val: serialize array");
565
+                    $i = 0;
566
+                    if(is_array($val) && count($val)> 0){
567
+                        foreach($val as $v){
568
+                            if(is_object($v) && get_class($v) ==  'soapval'){
569
+                                $tt_ns = $v->type_ns;
570
+                                $tt = $v->type;
571
+                            } elseif (is_array($v)) {
572
+                                $tt = $this->isArraySimpleOrStruct($v);
573
+                            } else {
574
+                                $tt = gettype($v);
575
+                            }
576
+                            $array_types[$tt] = 1;
577
+                            // TODO: for literal, the name should be $name
578
+                            $xml .= $this->serialize_val($v,'item',false,false,false,false,$use);
579
+                            ++$i;
580
+                        }
581
+                        if(count($array_types) > 1){
582
+                            $array_typename = 'xsd:anyType';
583
+                        } elseif(isset($tt) && isset($this->typemap[$this->XMLSchemaVersion][$tt])) {
584
+                            if ($tt == 'integer') {
585
+                                $tt = 'int';
586
+                            }
587
+                            $array_typename = 'xsd:'.$tt;
588
+                        } elseif(isset($tt) && $tt == 'arraySimple'){
589
+                            $array_typename = 'SOAP-ENC:Array';
590
+                        } elseif(isset($tt) && $tt == 'arrayStruct'){
591
+                            $array_typename = 'unnamed_struct_use_soapval';
592
+                        } else {
593
+                            // if type is prefixed, create type prefix
594
+                            if ($tt_ns != '' && $tt_ns == $this->namespaces['xsd']){
595
+                                    $array_typename = 'xsd:' . $tt;
596
+                            } elseif ($tt_ns) {
597
+                                $tt_prefix = 'ns' . rand(1000, 9999);
598
+                                $array_typename = "$tt_prefix:$tt";
599
+                                $xmlns .= " xmlns:$tt_prefix=\"$tt_ns\"";
600
+                            } else {
601
+                                $array_typename = $tt;
602
+                            }
603
+                        }
604
+                        $array_type = $i;
605
+                        if ($use == 'literal') {
606
+                            $type_str = '';
607
+                        } else if (isset($type) && isset($type_prefix)) {
608
+                            $type_str = " xsi:type=\"$type_prefix:$type\"";
609
+                        } else {
610
+                            $type_str = " xsi:type=\"SOAP-ENC:Array\" SOAP-ENC:arrayType=\"".$array_typename."[$array_type]\"";
611
+                        }
612
+                    // empty array
613
+                    } else {
614
+                        if ($use == 'literal') {
615
+                            $type_str = '';
616
+                        } else if (isset($type) && isset($type_prefix)) {
617
+                            $type_str = " xsi:type=\"$type_prefix:$type\"";
618
+                        } else {
619
+                            $type_str = " xsi:type=\"SOAP-ENC:Array\" SOAP-ENC:arrayType=\"xsd:anyType[0]\"";
620
+                        }
621
+                    }
622
+                    // TODO: for array in literal, there is no wrapper here
623
+                    $xml = "<$name$xmlns$type_str$atts>".$xml."</$name>";
624
+                } else {
625
+                    // got a struct
626
+                        $this->debug("serialize_val: serialize struct");
627
+                    if(isset($type) && isset($type_prefix)){
628
+                        $type_str = " xsi:type=\"$type_prefix:$type\"";
629
+                    } else {
630
+                        $type_str = '';
631
+                    }
632
+                    if ($use == 'literal') {
633
+                        $xml .= "<$name$xmlns$atts>";
634
+                    } else {
635
+                        $xml .= "<$name$xmlns$type_str$atts>";
636
+                    }
637
+                    foreach($val as $k => $v){
638
+                        // Apache Map
639
+                        if ($type == 'Map' && $type_ns == 'http://xml.apache.org/xml-soap') {
640
+                            $xml .= '<item>';
641
+                            $xml .= $this->serialize_val($k,'key',false,false,false,false,$use);
642
+                            $xml .= $this->serialize_val($v,'value',false,false,false,false,$use);
643
+                            $xml .= '</item>';
644
+                        } else {
645
+                            $xml .= $this->serialize_val($v,$k,false,false,false,false,$use);
646
+                        }
647
+                    }
648
+                    $xml .= "</$name>";
649
+                }
650
+                break;
651
+            default:
652
+                   $this->debug("serialize_val: serialize unknown");
653
+                $xml .= 'not detected, got '.gettype($val).' for '.$val;
654
+                break;
655
+        }
656
+        $this->debug("serialize_val returning $xml");
657
+        return $xml;
658
+    }
659
+
660
+    /**
661
+     * serializes a message
662
+     *
663
+     * @param string $body the XML of the SOAP body
664
+     * @param mixed $headers optional string of XML with SOAP header content, or array of soapval objects for SOAP headers, or associative array
665
+     * @param array $namespaces optional the namespaces used in generating the body and headers
666
+     * @param string $style optional (rpc|document)
667
+     * @param string $use optional (encoded|literal)
668
+     * @param string $encodingStyle optional (usually 'http://schemas.xmlsoap.org/soap/encoding/' for encoded)
669
+     * @return string the message
670
+     * @access public
671
+     */
672 672
     function serializeEnvelope($body,$headers=false,$namespaces=array(),$style='rpc',$use='encoded',$encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'){
673 673
     // TODO: add an option to automatically run utf8_encode on $body and $headers
674 674
     // if $this->soap_defencoding is UTF-8.  Not doing this automatically allows
675 675
     // one to send arbitrary UTF-8 characters, not just characters that map to ISO-8859-1
676 676
 
677
-	$this->debug("In serializeEnvelope length=" . strlen($body) . " body (max 1000 characters)=" . substr($body, 0, 1000) . " style=$style use=$use encodingStyle=$encodingStyle");
678
-	$this->debug("headers:");
679
-	$this->appendDebug($this->varDump($headers));
680
-	$this->debug("namespaces:");
681
-	$this->appendDebug($this->varDump($namespaces));
677
+    $this->debug("In serializeEnvelope length=" . strlen($body) . " body (max 1000 characters)=" . substr($body, 0, 1000) . " style=$style use=$use encodingStyle=$encodingStyle");
678
+    $this->debug("headers:");
679
+    $this->appendDebug($this->varDump($headers));
680
+    $this->debug("namespaces:");
681
+    $this->appendDebug($this->varDump($namespaces));
682 682
 
683
-	// serialize namespaces
683
+    // serialize namespaces
684 684
     $ns_string = '';
685
-	foreach(array_merge($this->namespaces,$namespaces) as $k => $v){
686
-		$ns_string .= " xmlns:$k=\"$v\"";
687
-	}
688
-	if($encodingStyle) {
689
-		$ns_string = " SOAP-ENV:encodingStyle=\"$encodingStyle\"$ns_string";
690
-	}
691
-
692
-	// serialize headers
693
-	if($headers){
694
-		if (is_array($headers)) {
695
-			$xml = '';
696
-			foreach ($headers as $k => $v) {
697
-				if (is_object($v) && get_class($v) == 'soapval') {
698
-					$xml .= $this->serialize_val($v, false, false, false, false, false, $use);
699
-				} else {
700
-					$xml .= $this->serialize_val($v, $k, false, false, false, false, $use);
701
-				}
702
-			}
703
-			$headers = $xml;
704
-			$this->debug("In serializeEnvelope, serialized array of headers to $headers");
705
-		}
706
-		$headers = "<SOAP-ENV:Header>".$headers."</SOAP-ENV:Header>";
707
-	}
708
-	// serialize envelope
709
-	return
710
-	'<?xml version="1.0" encoding="'.$this->soap_defencoding .'"?'.">".
711
-	'<SOAP-ENV:Envelope'.$ns_string.">".
712
-	$headers.
713
-	"<SOAP-ENV:Body>".
714
-		$body.
715
-	"</SOAP-ENV:Body>".
716
-	"</SOAP-ENV:Envelope>";
717
-    }
718
-
719
-	/**
720
-	 * formats a string to be inserted into an HTML stream
721
-	 *
722
-	 * @param string $str The string to format
723
-	 * @return string The formatted string
724
-	 * @access public
725
-	 * @deprecated
726
-	 */
685
+    foreach(array_merge($this->namespaces,$namespaces) as $k => $v){
686
+        $ns_string .= " xmlns:$k=\"$v\"";
687
+    }
688
+    if($encodingStyle) {
689
+        $ns_string = " SOAP-ENV:encodingStyle=\"$encodingStyle\"$ns_string";
690
+    }
691
+
692
+    // serialize headers
693
+    if($headers){
694
+        if (is_array($headers)) {
695
+            $xml = '';
696
+            foreach ($headers as $k => $v) {
697
+                if (is_object($v) && get_class($v) == 'soapval') {
698
+                    $xml .= $this->serialize_val($v, false, false, false, false, false, $use);
699
+                } else {
700
+                    $xml .= $this->serialize_val($v, $k, false, false, false, false, $use);
701
+                }
702
+            }
703
+            $headers = $xml;
704
+            $this->debug("In serializeEnvelope, serialized array of headers to $headers");
705
+        }
706
+        $headers = "<SOAP-ENV:Header>".$headers."</SOAP-ENV:Header>";
707
+    }
708
+    // serialize envelope
709
+    return
710
+    '<?xml version="1.0" encoding="'.$this->soap_defencoding .'"?'.">".
711
+    '<SOAP-ENV:Envelope'.$ns_string.">".
712
+    $headers.
713
+    "<SOAP-ENV:Body>".
714
+        $body.
715
+    "</SOAP-ENV:Body>".
716
+    "</SOAP-ENV:Envelope>";
717
+    }
718
+
719
+    /**
720
+     * formats a string to be inserted into an HTML stream
721
+     *
722
+     * @param string $str The string to format
723
+     * @return string The formatted string
724
+     * @access public
725
+     * @deprecated
726
+     */
727 727
     function formatDump($str){
728
-		$str = htmlspecialchars($str);
729
-		return nl2br($str);
730
-    }
731
-
732
-	/**
733
-	* contracts (changes namespace to prefix) a qualified name
734
-	*
735
-	* @param    string $qname qname
736
-	* @return	string contracted qname
737
-	* @access   private
738
-	*/
739
-	function contractQname($qname){
740
-		// get element namespace
741
-		//$this->xdebug("Contract $qname");
742
-		if (strrpos($qname, ':')) {
743
-			// get unqualified name
744
-			$name = substr($qname, strrpos($qname, ':') + 1);
745
-			// get ns
746
-			$ns = substr($qname, 0, strrpos($qname, ':'));
747
-			$p = $this->getPrefixFromNamespace($ns);
748
-			if ($p) {
749
-				return $p . ':' . $name;
750
-			}
751
-			return $qname;
752
-		} else {
753
-			return $qname;
754
-		}
755
-	}
756
-
757
-	/**
758
-	* expands (changes prefix to namespace) a qualified name
759
-	*
760
-	* @param    string $qname qname
761
-	* @return	string expanded qname
762
-	* @access   private
763
-	*/
764
-	function expandQname($qname){
765
-		// get element prefix
766
-		if(strpos($qname,':') && !preg_match('/^http:\/\//',$qname)){
767
-			// get unqualified name
768
-			$name = substr(strstr($qname,':'),1);
769
-			// get ns prefix
770
-			$prefix = substr($qname,0,strpos($qname,':'));
771
-			if(isset($this->namespaces[$prefix])){
772
-				return $this->namespaces[$prefix].':'.$name;
773
-			} else {
774
-				return $qname;
775
-			}
776
-		} else {
777
-			return $qname;
778
-		}
779
-	}
780
-
781
-    /**
782
-    * returns the local part of a prefixed string
783
-    * returns the original string, if not prefixed
784
-    *
785
-    * @param string $str The prefixed string
786
-    * @return string The local part
787
-    * @access public
788
-    */
789
-	function getLocalPart($str){
790
-		if($sstr = strrchr($str,':')){
791
-			// get unqualified name
792
-			return substr( $sstr, 1 );
793
-		} else {
794
-			return $str;
795
-		}
796
-	}
797
-
798
-	/**
799
-    * returns the prefix part of a prefixed string
800
-    * returns false, if not prefixed
801
-    *
802
-    * @param string $str The prefixed string
803
-    * @return mixed The prefix or false if there is no prefix
804
-    * @access public
805
-    */
806
-	function getPrefix($str){
807
-		if($pos = strrpos($str,':')){
808
-			// get prefix
809
-			return substr($str,0,$pos);
810
-		}
811
-		return false;
812
-	}
813
-
814
-	/**
815
-    * pass it a prefix, it returns a namespace
816
-    *
817
-    * @param string $prefix The prefix
818
-    * @return mixed The namespace, false if no namespace has the specified prefix
819
-    * @access public
820
-    */
821
-	function getNamespaceFromPrefix($prefix){
822
-		if (isset($this->namespaces[$prefix])) {
823
-			return $this->namespaces[$prefix];
824
-		}
825
-		//$this->setError("No namespace registered for prefix '$prefix'");
826
-		return false;
827
-	}
828
-
829
-	/**
830
-    * returns the prefix for a given namespace (or prefix)
831
-    * or false if no prefixes registered for the given namespace
832
-    *
833
-    * @param string $ns The namespace
834
-    * @return mixed The prefix, false if the namespace has no prefixes
835
-    * @access public
836
-    */
837
-	function getPrefixFromNamespace($ns) {
838
-		foreach ($this->namespaces as $p => $n) {
839
-			if ($ns == $n || $ns == $p) {
840
-			    $this->usedNamespaces[$p] = $n;
841
-				return $p;
842
-			}
843
-		}
844
-		return false;
845
-	}
846
-
847
-	/**
848
-    * returns the time in ODBC canonical form with microseconds
849
-    *
850
-    * @return string The time in ODBC canonical form with microseconds
851
-    * @access public
852
-    */
853
-	function getmicrotime() {
854
-		if (function_exists('gettimeofday')) {
855
-			$tod = gettimeofday();
856
-			$sec = $tod['sec'];
857
-			$usec = $tod['usec'];
858
-		} else {
859
-			$sec = time();
860
-			$usec = 0;
861
-		}
862
-		return strftime('%Y-%m-%d %H:%M:%S', $sec) . '.' . sprintf('%06d', $usec);
863
-	}
864
-
865
-	/**
866
-	 * Returns a string with the output of var_dump
867
-	 *
868
-	 * @param mixed $data The variable to var_dump
869
-	 * @return string The output of var_dump
870
-	 * @access public
871
-	 */
728
+        $str = htmlspecialchars($str);
729
+        return nl2br($str);
730
+    }
731
+
732
+    /**
733
+     * contracts (changes namespace to prefix) a qualified name
734
+     *
735
+     * @param    string $qname qname
736
+     * @return	string contracted qname
737
+     * @access   private
738
+     */
739
+    function contractQname($qname){
740
+        // get element namespace
741
+        //$this->xdebug("Contract $qname");
742
+        if (strrpos($qname, ':')) {
743
+            // get unqualified name
744
+            $name = substr($qname, strrpos($qname, ':') + 1);
745
+            // get ns
746
+            $ns = substr($qname, 0, strrpos($qname, ':'));
747
+            $p = $this->getPrefixFromNamespace($ns);
748
+            if ($p) {
749
+                return $p . ':' . $name;
750
+            }
751
+            return $qname;
752
+        } else {
753
+            return $qname;
754
+        }
755
+    }
756
+
757
+    /**
758
+     * expands (changes prefix to namespace) a qualified name
759
+     *
760
+     * @param    string $qname qname
761
+     * @return	string expanded qname
762
+     * @access   private
763
+     */
764
+    function expandQname($qname){
765
+        // get element prefix
766
+        if(strpos($qname,':') && !preg_match('/^http:\/\//',$qname)){
767
+            // get unqualified name
768
+            $name = substr(strstr($qname,':'),1);
769
+            // get ns prefix
770
+            $prefix = substr($qname,0,strpos($qname,':'));
771
+            if(isset($this->namespaces[$prefix])){
772
+                return $this->namespaces[$prefix].':'.$name;
773
+            } else {
774
+                return $qname;
775
+            }
776
+        } else {
777
+            return $qname;
778
+        }
779
+    }
780
+
781
+    /**
782
+     * returns the local part of a prefixed string
783
+     * returns the original string, if not prefixed
784
+     *
785
+     * @param string $str The prefixed string
786
+     * @return string The local part
787
+     * @access public
788
+     */
789
+    function getLocalPart($str){
790
+        if($sstr = strrchr($str,':')){
791
+            // get unqualified name
792
+            return substr( $sstr, 1 );
793
+        } else {
794
+            return $str;
795
+        }
796
+    }
797
+
798
+    /**
799
+     * returns the prefix part of a prefixed string
800
+     * returns false, if not prefixed
801
+     *
802
+     * @param string $str The prefixed string
803
+     * @return mixed The prefix or false if there is no prefix
804
+     * @access public
805
+     */
806
+    function getPrefix($str){
807
+        if($pos = strrpos($str,':')){
808
+            // get prefix
809
+            return substr($str,0,$pos);
810
+        }
811
+        return false;
812
+    }
813
+
814
+    /**
815
+     * pass it a prefix, it returns a namespace
816
+     *
817
+     * @param string $prefix The prefix
818
+     * @return mixed The namespace, false if no namespace has the specified prefix
819
+     * @access public
820
+     */
821
+    function getNamespaceFromPrefix($prefix){
822
+        if (isset($this->namespaces[$prefix])) {
823
+            return $this->namespaces[$prefix];
824
+        }
825
+        //$this->setError("No namespace registered for prefix '$prefix'");
826
+        return false;
827
+    }
828
+
829
+    /**
830
+     * returns the prefix for a given namespace (or prefix)
831
+     * or false if no prefixes registered for the given namespace
832
+     *
833
+     * @param string $ns The namespace
834
+     * @return mixed The prefix, false if the namespace has no prefixes
835
+     * @access public
836
+     */
837
+    function getPrefixFromNamespace($ns) {
838
+        foreach ($this->namespaces as $p => $n) {
839
+            if ($ns == $n || $ns == $p) {
840
+                $this->usedNamespaces[$p] = $n;
841
+                return $p;
842
+            }
843
+        }
844
+        return false;
845
+    }
846
+
847
+    /**
848
+     * returns the time in ODBC canonical form with microseconds
849
+     *
850
+     * @return string The time in ODBC canonical form with microseconds
851
+     * @access public
852
+     */
853
+    function getmicrotime() {
854
+        if (function_exists('gettimeofday')) {
855
+            $tod = gettimeofday();
856
+            $sec = $tod['sec'];
857
+            $usec = $tod['usec'];
858
+        } else {
859
+            $sec = time();
860
+            $usec = 0;
861
+        }
862
+        return strftime('%Y-%m-%d %H:%M:%S', $sec) . '.' . sprintf('%06d', $usec);
863
+    }
864
+
865
+    /**
866
+     * Returns a string with the output of var_dump
867
+     *
868
+     * @param mixed $data The variable to var_dump
869
+     * @return string The output of var_dump
870
+     * @access public
871
+     */
872 872
     function varDump($data) {
873
-		ob_start();
874
-		var_dump($data);
875
-		$ret_val = ob_get_contents();
876
-		ob_end_clean();
877
-		return $ret_val;
878
-	}
879
-
880
-	/**
881
-	* represents the object as a string
882
-	*
883
-	* @return	string
884
-	* @access   public
885
-	*/
886
-	function __toString() {
887
-		return $this->varDump($this);
888
-	}
873
+        ob_start();
874
+        var_dump($data);
875
+        $ret_val = ob_get_contents();
876
+        ob_end_clean();
877
+        return $ret_val;
878
+    }
879
+
880
+    /**
881
+     * represents the object as a string
882
+     *
883
+     * @return	string
884
+     * @access   public
885
+     */
886
+    function __toString() {
887
+        return $this->varDump($this);
888
+    }
889 889
 }
890 890
 
891 891
 // XML Schema Datatype Helper Functions
@@ -901,35 +901,35 @@  discard block
 block discarded – undo
901 901
 * @access   public
902 902
 */
903 903
 function timestamp_to_iso8601($timestamp,$utc=true){
904
-	$datestr = date('Y-m-d\TH:i:sO',$timestamp);
905
-	$pos = strrpos($datestr, "+");
906
-	if ($pos === FALSE) {
907
-		$pos = strrpos($datestr, "-");
908
-	}
909
-	if ($pos !== FALSE) {
910
-		if (strlen($datestr) == $pos + 5) {
911
-			$datestr = substr($datestr, 0, $pos + 3) . ':' . substr($datestr, -2);
912
-		}
913
-	}
914
-	if($utc){
915
-		$pattern = '/'.
916
-		'([0-9]{4})-'.	// centuries & years CCYY-
917
-		'([0-9]{2})-'.	// months MM-
918
-		'([0-9]{2})'.	// days DD
919
-		'T'.			// separator T
920
-		'([0-9]{2}):'.	// hours hh:
921
-		'([0-9]{2}):'.	// minutes mm:
922
-		'([0-9]{2})(\.[0-9]*)?'. // seconds ss.ss...
923
-		'(Z|[+\-][0-9]{2}:?[0-9]{2})?'. // Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's
924
-		'/';
925
-
926
-		if(preg_match($pattern,$datestr,$regs)){
927
-			return sprintf('%04d-%02d-%02dT%02d:%02d:%02dZ',$regs[1],$regs[2],$regs[3],$regs[4],$regs[5],$regs[6]);
928
-		}
929
-		return false;
930
-	} else {
931
-		return $datestr;
932
-	}
904
+    $datestr = date('Y-m-d\TH:i:sO',$timestamp);
905
+    $pos = strrpos($datestr, "+");
906
+    if ($pos === FALSE) {
907
+        $pos = strrpos($datestr, "-");
908
+    }
909
+    if ($pos !== FALSE) {
910
+        if (strlen($datestr) == $pos + 5) {
911
+            $datestr = substr($datestr, 0, $pos + 3) . ':' . substr($datestr, -2);
912
+        }
913
+    }
914
+    if($utc){
915
+        $pattern = '/'.
916
+        '([0-9]{4})-'.	// centuries & years CCYY-
917
+        '([0-9]{2})-'.	// months MM-
918
+        '([0-9]{2})'.	// days DD
919
+        'T'.			// separator T
920
+        '([0-9]{2}):'.	// hours hh:
921
+        '([0-9]{2}):'.	// minutes mm:
922
+        '([0-9]{2})(\.[0-9]*)?'. // seconds ss.ss...
923
+        '(Z|[+\-][0-9]{2}:?[0-9]{2})?'. // Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's
924
+        '/';
925
+
926
+        if(preg_match($pattern,$datestr,$regs)){
927
+            return sprintf('%04d-%02d-%02dT%02d:%02d:%02dZ',$regs[1],$regs[2],$regs[3],$regs[4],$regs[5],$regs[6]);
928
+        }
929
+        return false;
930
+    } else {
931
+        return $datestr;
932
+    }
933 933
 }
934 934
 
935 935
 /**
@@ -940,35 +940,35 @@  discard block
 block discarded – undo
940 940
 * @access   public
941 941
 */
942 942
 function iso8601_to_timestamp($datestr){
943
-	$pattern = '/'.
944
-	'([0-9]{4})-'.	// centuries & years CCYY-
945
-	'([0-9]{2})-'.	// months MM-
946
-	'([0-9]{2})'.	// days DD
947
-	'T'.			// separator T
948
-	'([0-9]{2}):'.	// hours hh:
949
-	'([0-9]{2}):'.	// minutes mm:
950
-	'([0-9]{2})(\.[0-9]+)?'. // seconds ss.ss...
951
-	'(Z|[+\-][0-9]{2}:?[0-9]{2})?'. // Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's
952
-	'/';
953
-	if(preg_match($pattern,$datestr,$regs)){
954
-		// not utc
955
-		if($regs[8] != 'Z'){
956
-			$op = substr($regs[8],0,1);
957
-			$h = substr($regs[8],1,2);
958
-			$m = substr($regs[8],strlen($regs[8])-2,2);
959
-			if($op == '-'){
960
-				$regs[4] = $regs[4] + $h;
961
-				$regs[5] = $regs[5] + $m;
962
-			} elseif($op == '+'){
963
-				$regs[4] = $regs[4] - $h;
964
-				$regs[5] = $regs[5] - $m;
965
-			}
966
-		}
967
-		return gmmktime($regs[4], $regs[5], $regs[6], $regs[2], $regs[3], $regs[1]);
943
+    $pattern = '/'.
944
+    '([0-9]{4})-'.	// centuries & years CCYY-
945
+    '([0-9]{2})-'.	// months MM-
946
+    '([0-9]{2})'.	// days DD
947
+    'T'.			// separator T
948
+    '([0-9]{2}):'.	// hours hh:
949
+    '([0-9]{2}):'.	// minutes mm:
950
+    '([0-9]{2})(\.[0-9]+)?'. // seconds ss.ss...
951
+    '(Z|[+\-][0-9]{2}:?[0-9]{2})?'. // Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's
952
+    '/';
953
+    if(preg_match($pattern,$datestr,$regs)){
954
+        // not utc
955
+        if($regs[8] != 'Z'){
956
+            $op = substr($regs[8],0,1);
957
+            $h = substr($regs[8],1,2);
958
+            $m = substr($regs[8],strlen($regs[8])-2,2);
959
+            if($op == '-'){
960
+                $regs[4] = $regs[4] + $h;
961
+                $regs[5] = $regs[5] + $m;
962
+            } elseif($op == '+'){
963
+                $regs[4] = $regs[4] - $h;
964
+                $regs[5] = $regs[5] - $m;
965
+            }
966
+        }
967
+        return gmmktime($regs[4], $regs[5], $regs[6], $regs[2], $regs[3], $regs[1]);
968 968
 //		return strtotime("$regs[1]-$regs[2]-$regs[3] $regs[4]:$regs[5]:$regs[6]Z");
969
-	} else {
970
-		return false;
971
-	}
969
+    } else {
970
+        return false;
971
+    }
972 972
 }
973 973
 
974 974
 /**
@@ -980,13 +980,13 @@  discard block
 block discarded – undo
980 980
 */
981 981
 function usleepWindows($usec)
982 982
 {
983
-	$start = gettimeofday();
984
-
985
-	do
986
-	{
987
-		$stop = gettimeofday();
988
-		$timePassed = 1000000 * ($stop['sec'] - $start['sec'])
989
-		+ $stop['usec'] - $start['usec'];
990
-	}
991
-	while ($timePassed < $usec);
983
+    $start = gettimeofday();
984
+
985
+    do
986
+    {
987
+        $stop = gettimeofday();
988
+        $timePassed = 1000000 * ($stop['sec'] - $start['sec'])
989
+        + $stop['usec'] - $start['usec'];
990
+    }
991
+    while ($timePassed < $usec);
992 992
 }
Please login to merge, or discard this patch.
main/inc/lib/nusoap/class.soap_server.php 3 patches
Doc Comments   +8 added lines, -7 removed lines patch added patch discarded remove patch
@@ -843,7 +843,7 @@  discard block
 block discarded – undo
843 843
 	*
844 844
 	* @param	array	$headers	The HTTP headers
845 845
 	* @param	string	$data		unprocessed request data from client
846
-	* @return	mixed	value of the message, decoded into a PHP type
846
+	* @return	false|null	value of the message, decoded into a PHP type
847 847
 	* @access   private
848 848
 	*/
849 849
     function parseRequest($headers, $data) {
@@ -951,10 +951,10 @@  discard block
 block discarded – undo
951 951
 	* @param    string $name the name of the PHP function, class.method or class..method
952 952
 	* @param    array $in assoc array of input values: key = param name, value = param type
953 953
 	* @param    array $out assoc array of output values: key = param name, value = param type
954
-	* @param	mixed $namespace the element namespace for the method or false
955
-	* @param	mixed $soapaction the soapaction for the method or false
956
-	* @param	mixed $style optional (rpc|document) or false Note: when 'document' is specified, parameter and return wrappers are created for you automatically
957
-	* @param	mixed $use optional (encoded|literal) or false
954
+	* @param	string $namespace the element namespace for the method or false
955
+	* @param	string $soapaction the soapaction for the method or false
956
+	* @param	string $style optional (rpc|document) or false Note: when 'document' is specified, parameter and return wrappers are created for you automatically
957
+	* @param	string $use optional (encoded|literal) or false
958 958
 	* @param	string $documentation optional Description to include in WSDL
959 959
 	* @param	string $encodingStyle optional (usually 'http://schemas.xmlsoap.org/soap/encoding/' for encoded)
960 960
 	* @access   public
@@ -1041,11 +1041,12 @@  discard block
 block discarded – undo
1041 1041
     * Acts as a flag to enable internal WSDL generation
1042 1042
     *
1043 1043
     * @param string $serviceName, name of the service
1044
-    * @param mixed $namespace optional 'tns' service namespace or false
1044
+    * @param string $namespace optional 'tns' service namespace or false
1045 1045
     * @param mixed $endpoint optional URL of service endpoint or false
1046 1046
     * @param string $style optional (rpc|document) WSDL style (also specified by operation)
1047 1047
     * @param string $transport optional SOAP transport
1048
-    * @param mixed $schemaTargetNamespace optional 'types' targetNamespace for service schema or false
1048
+    * @param mixed $schemaTargetNamespace optional 'types' targetNamespace for service schema or false
1049
+    * @param string $serviceName
1049 1050
     */
1050 1051
     function configureWSDL($serviceName,$namespace = false,$endpoint = false,$style='rpc', $transport = 'http://schemas.xmlsoap.org/soap/http', $schemaTargetNamespace = false)
1051 1052
     {
Please login to merge, or discard this patch.
Indentation   +1023 added lines, -1023 removed lines patch added patch discarded remove patch
@@ -14,1076 +14,1076 @@  discard block
 block discarded – undo
14 14
 * @access   public
15 15
 */
16 16
 class nusoap_server extends nusoap_base {
17
-	/**
18
-	 * HTTP headers of request
19
-	 * @var array
20
-	 * @access private
21
-	 */
22
-	var $headers = array();
23
-	/**
24
-	 * HTTP request
25
-	 * @var string
26
-	 * @access private
27
-	 */
28
-	var $request = '';
29
-	/**
30
-	 * SOAP headers from request (incomplete namespace resolution; special characters not escaped) (text)
31
-	 * @var string
32
-	 * @access public
33
-	 */
34
-	var $requestHeaders = '';
35
-	/**
36
-	 * SOAP Headers from request (parsed)
37
-	 * @var mixed
38
-	 * @access public
39
-	 */
40
-	var $requestHeader = NULL;
41
-	/**
42
-	 * SOAP body request portion (incomplete namespace resolution; special characters not escaped) (text)
43
-	 * @var string
44
-	 * @access public
45
-	 */
46
-	var $document = '';
47
-	/**
48
-	 * SOAP payload for request (text)
49
-	 * @var string
50
-	 * @access public
51
-	 */
52
-	var $requestSOAP = '';
53
-	/**
54
-	 * requested method namespace URI
55
-	 * @var string
56
-	 * @access private
57
-	 */
58
-	var $methodURI = '';
59
-	/**
60
-	 * name of method requested
61
-	 * @var string
62
-	 * @access private
63
-	 */
64
-	var $methodname = '';
65
-	/**
66
-	 * method parameters from request
67
-	 * @var array
68
-	 * @access private
69
-	 */
70
-	var $methodparams = array();
71
-	/**
72
-	 * SOAP Action from request
73
-	 * @var string
74
-	 * @access private
75
-	 */
76
-	var $SOAPAction = '';
77
-	/**
78
-	 * character set encoding of incoming (request) messages
79
-	 * @var string
80
-	 * @access public
81
-	 */
82
-	var $xml_encoding = '';
83
-	/**
84
-	 * toggles whether the parser decodes element content w/ utf8_decode()
85
-	 * @var boolean
86
-	 * @access public
87
-	 */
17
+    /**
18
+     * HTTP headers of request
19
+     * @var array
20
+     * @access private
21
+     */
22
+    var $headers = array();
23
+    /**
24
+     * HTTP request
25
+     * @var string
26
+     * @access private
27
+     */
28
+    var $request = '';
29
+    /**
30
+     * SOAP headers from request (incomplete namespace resolution; special characters not escaped) (text)
31
+     * @var string
32
+     * @access public
33
+     */
34
+    var $requestHeaders = '';
35
+    /**
36
+     * SOAP Headers from request (parsed)
37
+     * @var mixed
38
+     * @access public
39
+     */
40
+    var $requestHeader = NULL;
41
+    /**
42
+     * SOAP body request portion (incomplete namespace resolution; special characters not escaped) (text)
43
+     * @var string
44
+     * @access public
45
+     */
46
+    var $document = '';
47
+    /**
48
+     * SOAP payload for request (text)
49
+     * @var string
50
+     * @access public
51
+     */
52
+    var $requestSOAP = '';
53
+    /**
54
+     * requested method namespace URI
55
+     * @var string
56
+     * @access private
57
+     */
58
+    var $methodURI = '';
59
+    /**
60
+     * name of method requested
61
+     * @var string
62
+     * @access private
63
+     */
64
+    var $methodname = '';
65
+    /**
66
+     * method parameters from request
67
+     * @var array
68
+     * @access private
69
+     */
70
+    var $methodparams = array();
71
+    /**
72
+     * SOAP Action from request
73
+     * @var string
74
+     * @access private
75
+     */
76
+    var $SOAPAction = '';
77
+    /**
78
+     * character set encoding of incoming (request) messages
79
+     * @var string
80
+     * @access public
81
+     */
82
+    var $xml_encoding = '';
83
+    /**
84
+     * toggles whether the parser decodes element content w/ utf8_decode()
85
+     * @var boolean
86
+     * @access public
87
+     */
88 88
     var $decode_utf8 = true;
89 89
 
90
-	/**
91
-	 * HTTP headers of response
92
-	 * @var array
93
-	 * @access public
94
-	 */
95
-	var $outgoing_headers = array();
96
-	/**
97
-	 * HTTP response
98
-	 * @var string
99
-	 * @access private
100
-	 */
101
-	var $response = '';
102
-	/**
103
-	 * SOAP headers for response (text or array of soapval or associative array)
104
-	 * @var mixed
105
-	 * @access public
106
-	 */
107
-	var $responseHeaders = '';
108
-	/**
109
-	 * SOAP payload for response (text)
110
-	 * @var string
111
-	 * @access private
112
-	 */
113
-	var $responseSOAP = '';
114
-	/**
115
-	 * method return value to place in response
116
-	 * @var mixed
117
-	 * @access private
118
-	 */
119
-	var $methodreturn = false;
120
-	/**
121
-	 * whether $methodreturn is a string of literal XML
122
-	 * @var boolean
123
-	 * @access public
124
-	 */
125
-	var $methodreturnisliteralxml = false;
126
-	/**
127
-	 * SOAP fault for response (or false)
128
-	 * @var mixed
129
-	 * @access private
130
-	 */
131
-	var $fault = false;
132
-	/**
133
-	 * text indication of result (for debugging)
134
-	 * @var string
135
-	 * @access private
136
-	 */
137
-	var $result = 'successful';
90
+    /**
91
+     * HTTP headers of response
92
+     * @var array
93
+     * @access public
94
+     */
95
+    var $outgoing_headers = array();
96
+    /**
97
+     * HTTP response
98
+     * @var string
99
+     * @access private
100
+     */
101
+    var $response = '';
102
+    /**
103
+     * SOAP headers for response (text or array of soapval or associative array)
104
+     * @var mixed
105
+     * @access public
106
+     */
107
+    var $responseHeaders = '';
108
+    /**
109
+     * SOAP payload for response (text)
110
+     * @var string
111
+     * @access private
112
+     */
113
+    var $responseSOAP = '';
114
+    /**
115
+     * method return value to place in response
116
+     * @var mixed
117
+     * @access private
118
+     */
119
+    var $methodreturn = false;
120
+    /**
121
+     * whether $methodreturn is a string of literal XML
122
+     * @var boolean
123
+     * @access public
124
+     */
125
+    var $methodreturnisliteralxml = false;
126
+    /**
127
+     * SOAP fault for response (or false)
128
+     * @var mixed
129
+     * @access private
130
+     */
131
+    var $fault = false;
132
+    /**
133
+     * text indication of result (for debugging)
134
+     * @var string
135
+     * @access private
136
+     */
137
+    var $result = 'successful';
138 138
 
139
-	/**
140
-	 * assoc array of operations => opData; operations are added by the register()
141
-	 * method or by parsing an external WSDL definition
142
-	 * @var array
143
-	 * @access private
144
-	 */
145
-	var $operations = array();
146
-	/**
147
-	 * wsdl instance (if one)
148
-	 * @var mixed
149
-	 * @access private
150
-	 */
151
-	var $wsdl = false;
152
-	/**
153
-	 * URL for WSDL (if one)
154
-	 * @var mixed
155
-	 * @access private
156
-	 */
157
-	var $externalWSDLURL = false;
158
-	/**
159
-	 * whether to append debug to response as XML comment
160
-	 * @var boolean
161
-	 * @access public
162
-	 */
163
-	var $debug_flag = false;
139
+    /**
140
+     * assoc array of operations => opData; operations are added by the register()
141
+     * method or by parsing an external WSDL definition
142
+     * @var array
143
+     * @access private
144
+     */
145
+    var $operations = array();
146
+    /**
147
+     * wsdl instance (if one)
148
+     * @var mixed
149
+     * @access private
150
+     */
151
+    var $wsdl = false;
152
+    /**
153
+     * URL for WSDL (if one)
154
+     * @var mixed
155
+     * @access private
156
+     */
157
+    var $externalWSDLURL = false;
158
+    /**
159
+     * whether to append debug to response as XML comment
160
+     * @var boolean
161
+     * @access public
162
+     */
163
+    var $debug_flag = false;
164 164
 
165 165
 
166
-	/**
167
-	* constructor
168
-    * the optional parameter is a path to a WSDL file that you'd like to bind the server instance to.
169
-	*
170
-    * @param mixed $wsdl file path or URL (string), or wsdl instance (object)
171
-	* @access   public
172
-	*/
173
-	function nusoap_server($wsdl=false){
174
-		parent::nusoap_base();
175
-		// turn on debugging?
176
-		global $debug;
177
-		global $HTTP_SERVER_VARS;
166
+    /**
167
+     * constructor
168
+     * the optional parameter is a path to a WSDL file that you'd like to bind the server instance to.
169
+     *
170
+     * @param mixed $wsdl file path or URL (string), or wsdl instance (object)
171
+     * @access   public
172
+     */
173
+    function nusoap_server($wsdl=false){
174
+        parent::nusoap_base();
175
+        // turn on debugging?
176
+        global $debug;
177
+        global $HTTP_SERVER_VARS;
178 178
 
179
-		if (isset($_SERVER)) {
180
-			$this->debug("_SERVER is defined:");
181
-			$this->appendDebug($this->varDump($_SERVER));
182
-		} elseif (isset($HTTP_SERVER_VARS)) {
183
-			$this->debug("HTTP_SERVER_VARS is defined:");
184
-			$this->appendDebug($this->varDump($HTTP_SERVER_VARS));
185
-		} else {
186
-			$this->debug("Neither _SERVER nor HTTP_SERVER_VARS is defined.");
187
-		}
179
+        if (isset($_SERVER)) {
180
+            $this->debug("_SERVER is defined:");
181
+            $this->appendDebug($this->varDump($_SERVER));
182
+        } elseif (isset($HTTP_SERVER_VARS)) {
183
+            $this->debug("HTTP_SERVER_VARS is defined:");
184
+            $this->appendDebug($this->varDump($HTTP_SERVER_VARS));
185
+        } else {
186
+            $this->debug("Neither _SERVER nor HTTP_SERVER_VARS is defined.");
187
+        }
188 188
 
189
-		if (isset($debug)) {
190
-			$this->debug("In nusoap_server, set debug_flag=$debug based on global flag");
191
-			$this->debug_flag = $debug;
192
-		} elseif (isset($_SERVER['QUERY_STRING'])) {
193
-			$qs = explode('&', $_SERVER['QUERY_STRING']);
194
-			foreach ($qs as $v) {
195
-				if (substr($v, 0, 6) == 'debug=') {
196
-					$this->debug("In nusoap_server, set debug_flag=" . substr($v, 6) . " based on query string #1");
197
-					$this->debug_flag = substr($v, 6);
198
-				}
199
-			}
200
-		} elseif (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
201
-			$qs = explode('&', $HTTP_SERVER_VARS['QUERY_STRING']);
202
-			foreach ($qs as $v) {
203
-				if (substr($v, 0, 6) == 'debug=') {
204
-					$this->debug("In nusoap_server, set debug_flag=" . substr($v, 6) . " based on query string #2");
205
-					$this->debug_flag = substr($v, 6);
206
-				}
207
-			}
208
-		}
189
+        if (isset($debug)) {
190
+            $this->debug("In nusoap_server, set debug_flag=$debug based on global flag");
191
+            $this->debug_flag = $debug;
192
+        } elseif (isset($_SERVER['QUERY_STRING'])) {
193
+            $qs = explode('&', $_SERVER['QUERY_STRING']);
194
+            foreach ($qs as $v) {
195
+                if (substr($v, 0, 6) == 'debug=') {
196
+                    $this->debug("In nusoap_server, set debug_flag=" . substr($v, 6) . " based on query string #1");
197
+                    $this->debug_flag = substr($v, 6);
198
+                }
199
+            }
200
+        } elseif (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
201
+            $qs = explode('&', $HTTP_SERVER_VARS['QUERY_STRING']);
202
+            foreach ($qs as $v) {
203
+                if (substr($v, 0, 6) == 'debug=') {
204
+                    $this->debug("In nusoap_server, set debug_flag=" . substr($v, 6) . " based on query string #2");
205
+                    $this->debug_flag = substr($v, 6);
206
+                }
207
+            }
208
+        }
209 209
 
210
-		// wsdl
211
-		if($wsdl){
212
-			$this->debug("In nusoap_server, WSDL is specified");
213
-			if (is_object($wsdl) && (get_class($wsdl) == 'wsdl')) {
214
-				$this->wsdl = $wsdl;
215
-				$this->externalWSDLURL = $this->wsdl->wsdl;
216
-				$this->debug('Use existing wsdl instance from ' . $this->externalWSDLURL);
217
-			} else {
218
-				$this->debug('Create wsdl from ' . $wsdl);
219
-				$this->wsdl = new wsdl($wsdl);
220
-				$this->externalWSDLURL = $wsdl;
221
-			}
222
-			$this->appendDebug($this->wsdl->getDebug());
223
-			$this->wsdl->clearDebug();
224
-			if($err = $this->wsdl->getError()){
225
-				die('WSDL ERROR: '.$err);
226
-			}
227
-		}
228
-	}
210
+        // wsdl
211
+        if($wsdl){
212
+            $this->debug("In nusoap_server, WSDL is specified");
213
+            if (is_object($wsdl) && (get_class($wsdl) == 'wsdl')) {
214
+                $this->wsdl = $wsdl;
215
+                $this->externalWSDLURL = $this->wsdl->wsdl;
216
+                $this->debug('Use existing wsdl instance from ' . $this->externalWSDLURL);
217
+            } else {
218
+                $this->debug('Create wsdl from ' . $wsdl);
219
+                $this->wsdl = new wsdl($wsdl);
220
+                $this->externalWSDLURL = $wsdl;
221
+            }
222
+            $this->appendDebug($this->wsdl->getDebug());
223
+            $this->wsdl->clearDebug();
224
+            if($err = $this->wsdl->getError()){
225
+                die('WSDL ERROR: '.$err);
226
+            }
227
+        }
228
+    }
229 229
 
230
-	/**
231
-	* processes request and returns response
232
-	*
233
-	* @param    string $data usually is the value of $HTTP_RAW_POST_DATA
234
-	* @access   public
235
-	*/
236
-	function service($data){
237
-		global $HTTP_SERVER_VARS;
230
+    /**
231
+     * processes request and returns response
232
+     *
233
+     * @param    string $data usually is the value of $HTTP_RAW_POST_DATA
234
+     * @access   public
235
+     */
236
+    function service($data){
237
+        global $HTTP_SERVER_VARS;
238 238
 
239
-		if (isset($_SERVER['REQUEST_METHOD'])) {
240
-			$rm = $_SERVER['REQUEST_METHOD'];
241
-		} elseif (isset($HTTP_SERVER_VARS['REQUEST_METHOD'])) {
242
-			$rm = $HTTP_SERVER_VARS['REQUEST_METHOD'];
243
-		} else {
244
-			$rm = '';
245
-		}
239
+        if (isset($_SERVER['REQUEST_METHOD'])) {
240
+            $rm = $_SERVER['REQUEST_METHOD'];
241
+        } elseif (isset($HTTP_SERVER_VARS['REQUEST_METHOD'])) {
242
+            $rm = $HTTP_SERVER_VARS['REQUEST_METHOD'];
243
+        } else {
244
+            $rm = '';
245
+        }
246 246
 
247
-		if (isset($_SERVER['QUERY_STRING'])) {
248
-			$qs = $_SERVER['QUERY_STRING'];
249
-		} elseif (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
250
-			$qs = $HTTP_SERVER_VARS['QUERY_STRING'];
251
-		} else {
252
-			$qs = '';
253
-		}
254
-		$this->debug("In service, request method=$rm query string=$qs strlen(\$data)=" . strlen($data));
247
+        if (isset($_SERVER['QUERY_STRING'])) {
248
+            $qs = $_SERVER['QUERY_STRING'];
249
+        } elseif (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
250
+            $qs = $HTTP_SERVER_VARS['QUERY_STRING'];
251
+        } else {
252
+            $qs = '';
253
+        }
254
+        $this->debug("In service, request method=$rm query string=$qs strlen(\$data)=" . strlen($data));
255 255
 
256
-		if ($rm == 'POST') {
257
-			$this->debug("In service, invoke the request");
258
-			$this->parse_request($data);
259
-			if (! $this->fault) {
260
-				$this->invoke_method();
261
-			}
262
-			if (! $this->fault) {
263
-				$this->serialize_return();
264
-			}
265
-			$this->send_response();
266
-		} elseif (preg_match('/wsdl/', $qs) ){
267
-			$this->debug("In service, this is a request for WSDL");
268
-			if ($this->externalWSDLURL){
269
-              if (strpos($this->externalWSDLURL, "http://") !== false) { // assume URL
270
-				$this->debug("In service, re-direct for WSDL");
271
-				header('Location: '.$this->externalWSDLURL);
272
-              } else { // assume file
273
-				$this->debug("In service, use file passthru for WSDL");
256
+        if ($rm == 'POST') {
257
+            $this->debug("In service, invoke the request");
258
+            $this->parse_request($data);
259
+            if (! $this->fault) {
260
+                $this->invoke_method();
261
+            }
262
+            if (! $this->fault) {
263
+                $this->serialize_return();
264
+            }
265
+            $this->send_response();
266
+        } elseif (preg_match('/wsdl/', $qs) ){
267
+            $this->debug("In service, this is a request for WSDL");
268
+            if ($this->externalWSDLURL){
269
+                if (strpos($this->externalWSDLURL, "http://") !== false) { // assume URL
270
+                $this->debug("In service, re-direct for WSDL");
271
+                header('Location: '.$this->externalWSDLURL);
272
+                } else { // assume file
273
+                $this->debug("In service, use file passthru for WSDL");
274 274
                 header("Content-Type: text/xml\r\n");
275
-				$pos = strpos($this->externalWSDLURL, "file://");
276
-				if ($pos === false) {
277
-					$filename = $this->externalWSDLURL;
278
-				} else {
279
-					$filename = substr($this->externalWSDLURL, $pos + 7);
280
-				}
275
+                $pos = strpos($this->externalWSDLURL, "file://");
276
+                if ($pos === false) {
277
+                    $filename = $this->externalWSDLURL;
278
+                } else {
279
+                    $filename = substr($this->externalWSDLURL, $pos + 7);
280
+                }
281 281
                 $fp = fopen($this->externalWSDLURL, 'r');
282 282
                 fpassthru($fp);
283
-              }
284
-			} elseif ($this->wsdl) {
285
-				$this->debug("In service, serialize WSDL");
286
-				header("Content-Type: text/xml; charset=ISO-8859-1\r\n");
287
-				print $this->wsdl->serialize($this->debug_flag);
288
-				if ($this->debug_flag) {
289
-					$this->debug('wsdl:');
290
-					$this->appendDebug($this->varDump($this->wsdl));
291
-					print $this->getDebugAsXMLComment();
292
-				}
293
-			} else {
294
-				$this->debug("In service, there is no WSDL");
295
-				header("Content-Type: text/html; charset=ISO-8859-1\r\n");
296
-				print "This service does not provide WSDL";
297
-			}
298
-		} elseif ($this->wsdl) {
299
-			$this->debug("In service, return Web description");
300
-			print $this->wsdl->webDescription();
301
-		} else {
302
-			$this->debug("In service, no Web description");
303
-			header("Content-Type: text/html; charset=ISO-8859-1\r\n");
304
-			print "This service does not provide a Web description";
305
-		}
306
-	}
283
+                }
284
+            } elseif ($this->wsdl) {
285
+                $this->debug("In service, serialize WSDL");
286
+                header("Content-Type: text/xml; charset=ISO-8859-1\r\n");
287
+                print $this->wsdl->serialize($this->debug_flag);
288
+                if ($this->debug_flag) {
289
+                    $this->debug('wsdl:');
290
+                    $this->appendDebug($this->varDump($this->wsdl));
291
+                    print $this->getDebugAsXMLComment();
292
+                }
293
+            } else {
294
+                $this->debug("In service, there is no WSDL");
295
+                header("Content-Type: text/html; charset=ISO-8859-1\r\n");
296
+                print "This service does not provide WSDL";
297
+            }
298
+        } elseif ($this->wsdl) {
299
+            $this->debug("In service, return Web description");
300
+            print $this->wsdl->webDescription();
301
+        } else {
302
+            $this->debug("In service, no Web description");
303
+            header("Content-Type: text/html; charset=ISO-8859-1\r\n");
304
+            print "This service does not provide a Web description";
305
+        }
306
+    }
307 307
 
308
-	/**
309
-	* parses HTTP request headers.
310
-	*
311
-	* The following fields are set by this function (when successful)
312
-	*
313
-	* headers
314
-	* request
315
-	* xml_encoding
316
-	* SOAPAction
317
-	*
318
-	* @access   private
319
-	*/
320
-	function parse_http_headers() {
321
-		global $HTTP_SERVER_VARS;
308
+    /**
309
+     * parses HTTP request headers.
310
+     *
311
+     * The following fields are set by this function (when successful)
312
+     *
313
+     * headers
314
+     * request
315
+     * xml_encoding
316
+     * SOAPAction
317
+     *
318
+     * @access   private
319
+     */
320
+    function parse_http_headers() {
321
+        global $HTTP_SERVER_VARS;
322 322
 
323
-		$this->request = '';
324
-		$this->SOAPAction = '';
325
-		if(function_exists('getallheaders')){
326
-			$this->debug("In parse_http_headers, use getallheaders");
327
-			$headers = getallheaders();
328
-			foreach($headers as $k=>$v){
329
-				$k = strtolower($k);
330
-				$this->headers[$k] = $v;
331
-				$this->request .= "$k: $v\r\n";
332
-				$this->debug("$k: $v");
333
-			}
334
-			// get SOAPAction header
335
-			if(isset($this->headers['soapaction'])){
336
-				$this->SOAPAction = str_replace('"','',$this->headers['soapaction']);
337
-			}
338
-			// get the character encoding of the incoming request
339
-			if(isset($this->headers['content-type']) && strpos($this->headers['content-type'],'=')){
340
-				$enc = str_replace('"','',substr(strstr($this->headers["content-type"],'='),1));
341
-				if(preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)){
342
-					$this->xml_encoding = strtoupper($enc);
343
-				} else {
344
-					$this->xml_encoding = 'US-ASCII';
345
-				}
346
-			} else {
347
-				// should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1
348
-				$this->xml_encoding = 'ISO-8859-1';
349
-			}
350
-		} elseif(isset($_SERVER) && is_array($_SERVER)){
351
-			$this->debug("In parse_http_headers, use _SERVER");
352
-			foreach ($_SERVER as $k => $v) {
353
-				if (substr($k, 0, 5) == 'HTTP_') {
354
-					$k = str_replace(' ', '-', strtolower(str_replace('_', ' ', substr($k, 5))));
355
-				} else {
356
-					$k = str_replace(' ', '-', strtolower(str_replace('_', ' ', $k)));
357
-				}
358
-				if ($k == 'soapaction') {
359
-					// get SOAPAction header
360
-					$k = 'SOAPAction';
361
-					$v = str_replace('"', '', $v);
362
-					$v = str_replace('\\', '', $v);
363
-					$this->SOAPAction = $v;
364
-				} else if ($k == 'content-type') {
365
-					// get the character encoding of the incoming request
366
-					if (strpos($v, '=')) {
367
-						$enc = substr(strstr($v, '='), 1);
368
-						$enc = str_replace('"', '', $enc);
369
-						$enc = str_replace('\\', '', $enc);
370
-						if (preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)) {
371
-							$this->xml_encoding = strtoupper($enc);
372
-						} else {
373
-							$this->xml_encoding = 'US-ASCII';
374
-						}
375
-					} else {
376
-						// should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1
377
-						$this->xml_encoding = 'ISO-8859-1';
378
-					}
379
-				}
380
-				$this->headers[$k] = $v;
381
-				$this->request .= "$k: $v\r\n";
382
-				$this->debug("$k: $v");
383
-			}
384
-		} elseif (is_array($HTTP_SERVER_VARS)) {
385
-			$this->debug("In parse_http_headers, use HTTP_SERVER_VARS");
386
-			foreach ($HTTP_SERVER_VARS as $k => $v) {
387
-				if (substr($k, 0, 5) == 'HTTP_') {
388
-					$k = str_replace(' ', '-', strtolower(str_replace('_', ' ', substr($k, 5)))); 	                                         $k = strtolower(substr($k, 5));
389
-				} else {
390
-					$k = str_replace(' ', '-', strtolower(str_replace('_', ' ', $k))); 	                                         $k = strtolower($k);
391
-				}
392
-				if ($k == 'soapaction') {
393
-					// get SOAPAction header
394
-					$k = 'SOAPAction';
395
-					$v = str_replace('"', '', $v);
396
-					$v = str_replace('\\', '', $v);
397
-					$this->SOAPAction = $v;
398
-				} else if ($k == 'content-type') {
399
-					// get the character encoding of the incoming request
400
-					if (strpos($v, '=')) {
401
-						$enc = substr(strstr($v, '='), 1);
402
-						$enc = str_replace('"', '', $enc);
403
-						$enc = str_replace('\\', '', $enc);
404
-						if (preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)) {
405
-							$this->xml_encoding = strtoupper($enc);
406
-						} else {
407
-							$this->xml_encoding = 'US-ASCII';
408
-						}
409
-					} else {
410
-						// should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1
411
-						$this->xml_encoding = 'ISO-8859-1';
412
-					}
413
-				}
414
-				$this->headers[$k] = $v;
415
-				$this->request .= "$k: $v\r\n";
416
-				$this->debug("$k: $v");
417
-			}
418
-		} else {
419
-			$this->debug("In parse_http_headers, HTTP headers not accessible");
420
-			$this->setError("HTTP headers not accessible");
421
-		}
422
-	}
323
+        $this->request = '';
324
+        $this->SOAPAction = '';
325
+        if(function_exists('getallheaders')){
326
+            $this->debug("In parse_http_headers, use getallheaders");
327
+            $headers = getallheaders();
328
+            foreach($headers as $k=>$v){
329
+                $k = strtolower($k);
330
+                $this->headers[$k] = $v;
331
+                $this->request .= "$k: $v\r\n";
332
+                $this->debug("$k: $v");
333
+            }
334
+            // get SOAPAction header
335
+            if(isset($this->headers['soapaction'])){
336
+                $this->SOAPAction = str_replace('"','',$this->headers['soapaction']);
337
+            }
338
+            // get the character encoding of the incoming request
339
+            if(isset($this->headers['content-type']) && strpos($this->headers['content-type'],'=')){
340
+                $enc = str_replace('"','',substr(strstr($this->headers["content-type"],'='),1));
341
+                if(preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)){
342
+                    $this->xml_encoding = strtoupper($enc);
343
+                } else {
344
+                    $this->xml_encoding = 'US-ASCII';
345
+                }
346
+            } else {
347
+                // should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1
348
+                $this->xml_encoding = 'ISO-8859-1';
349
+            }
350
+        } elseif(isset($_SERVER) && is_array($_SERVER)){
351
+            $this->debug("In parse_http_headers, use _SERVER");
352
+            foreach ($_SERVER as $k => $v) {
353
+                if (substr($k, 0, 5) == 'HTTP_') {
354
+                    $k = str_replace(' ', '-', strtolower(str_replace('_', ' ', substr($k, 5))));
355
+                } else {
356
+                    $k = str_replace(' ', '-', strtolower(str_replace('_', ' ', $k)));
357
+                }
358
+                if ($k == 'soapaction') {
359
+                    // get SOAPAction header
360
+                    $k = 'SOAPAction';
361
+                    $v = str_replace('"', '', $v);
362
+                    $v = str_replace('\\', '', $v);
363
+                    $this->SOAPAction = $v;
364
+                } else if ($k == 'content-type') {
365
+                    // get the character encoding of the incoming request
366
+                    if (strpos($v, '=')) {
367
+                        $enc = substr(strstr($v, '='), 1);
368
+                        $enc = str_replace('"', '', $enc);
369
+                        $enc = str_replace('\\', '', $enc);
370
+                        if (preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)) {
371
+                            $this->xml_encoding = strtoupper($enc);
372
+                        } else {
373
+                            $this->xml_encoding = 'US-ASCII';
374
+                        }
375
+                    } else {
376
+                        // should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1
377
+                        $this->xml_encoding = 'ISO-8859-1';
378
+                    }
379
+                }
380
+                $this->headers[$k] = $v;
381
+                $this->request .= "$k: $v\r\n";
382
+                $this->debug("$k: $v");
383
+            }
384
+        } elseif (is_array($HTTP_SERVER_VARS)) {
385
+            $this->debug("In parse_http_headers, use HTTP_SERVER_VARS");
386
+            foreach ($HTTP_SERVER_VARS as $k => $v) {
387
+                if (substr($k, 0, 5) == 'HTTP_') {
388
+                    $k = str_replace(' ', '-', strtolower(str_replace('_', ' ', substr($k, 5)))); 	                                         $k = strtolower(substr($k, 5));
389
+                } else {
390
+                    $k = str_replace(' ', '-', strtolower(str_replace('_', ' ', $k))); 	                                         $k = strtolower($k);
391
+                }
392
+                if ($k == 'soapaction') {
393
+                    // get SOAPAction header
394
+                    $k = 'SOAPAction';
395
+                    $v = str_replace('"', '', $v);
396
+                    $v = str_replace('\\', '', $v);
397
+                    $this->SOAPAction = $v;
398
+                } else if ($k == 'content-type') {
399
+                    // get the character encoding of the incoming request
400
+                    if (strpos($v, '=')) {
401
+                        $enc = substr(strstr($v, '='), 1);
402
+                        $enc = str_replace('"', '', $enc);
403
+                        $enc = str_replace('\\', '', $enc);
404
+                        if (preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)) {
405
+                            $this->xml_encoding = strtoupper($enc);
406
+                        } else {
407
+                            $this->xml_encoding = 'US-ASCII';
408
+                        }
409
+                    } else {
410
+                        // should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1
411
+                        $this->xml_encoding = 'ISO-8859-1';
412
+                    }
413
+                }
414
+                $this->headers[$k] = $v;
415
+                $this->request .= "$k: $v\r\n";
416
+                $this->debug("$k: $v");
417
+            }
418
+        } else {
419
+            $this->debug("In parse_http_headers, HTTP headers not accessible");
420
+            $this->setError("HTTP headers not accessible");
421
+        }
422
+    }
423 423
 
424
-	/**
425
-	* parses a request
426
-	*
427
-	* The following fields are set by this function (when successful)
428
-	*
429
-	* headers
430
-	* request
431
-	* xml_encoding
432
-	* SOAPAction
433
-	* request
434
-	* requestSOAP
435
-	* methodURI
436
-	* methodname
437
-	* methodparams
438
-	* requestHeaders
439
-	* document
440
-	*
441
-	* This sets the fault field on error
442
-	*
443
-	* @param    string $data XML string
444
-	* @access   private
445
-	*/
446
-	function parse_request($data='') {
447
-		$this->debug('entering parse_request()');
448
-		$this->parse_http_headers();
449
-		$this->debug('got character encoding: '.$this->xml_encoding);
450
-		// uncompress if necessary
451
-		if (isset($this->headers['content-encoding']) && $this->headers['content-encoding'] != '') {
452
-			$this->debug('got content encoding: ' . $this->headers['content-encoding']);
453
-			if ($this->headers['content-encoding'] == 'deflate' || $this->headers['content-encoding'] == 'gzip') {
454
-		    	// if decoding works, use it. else assume data wasn't gzencoded
455
-				if (function_exists('gzuncompress')) {
456
-					if ($this->headers['content-encoding'] == 'deflate' && $degzdata = @gzuncompress($data)) {
457
-						$data = $degzdata;
458
-					} elseif ($this->headers['content-encoding'] == 'gzip' && $degzdata = gzinflate(substr($data, 10))) {
459
-						$data = $degzdata;
460
-					} else {
461
-						$this->fault('SOAP-ENV:Client', 'Errors occurred when trying to decode the data');
462
-						return;
463
-					}
464
-				} else {
465
-					$this->fault('SOAP-ENV:Client', 'This Server does not support compressed data');
466
-					return;
467
-				}
468
-			}
469
-		}
470
-		$this->request .= "\r\n".$data;
471
-		$data = $this->parseRequest($this->headers, $data);
472
-		$this->requestSOAP = $data;
473
-		$this->debug('leaving parse_request');
474
-	}
424
+    /**
425
+     * parses a request
426
+     *
427
+     * The following fields are set by this function (when successful)
428
+     *
429
+     * headers
430
+     * request
431
+     * xml_encoding
432
+     * SOAPAction
433
+     * request
434
+     * requestSOAP
435
+     * methodURI
436
+     * methodname
437
+     * methodparams
438
+     * requestHeaders
439
+     * document
440
+     *
441
+     * This sets the fault field on error
442
+     *
443
+     * @param    string $data XML string
444
+     * @access   private
445
+     */
446
+    function parse_request($data='') {
447
+        $this->debug('entering parse_request()');
448
+        $this->parse_http_headers();
449
+        $this->debug('got character encoding: '.$this->xml_encoding);
450
+        // uncompress if necessary
451
+        if (isset($this->headers['content-encoding']) && $this->headers['content-encoding'] != '') {
452
+            $this->debug('got content encoding: ' . $this->headers['content-encoding']);
453
+            if ($this->headers['content-encoding'] == 'deflate' || $this->headers['content-encoding'] == 'gzip') {
454
+                // if decoding works, use it. else assume data wasn't gzencoded
455
+                if (function_exists('gzuncompress')) {
456
+                    if ($this->headers['content-encoding'] == 'deflate' && $degzdata = @gzuncompress($data)) {
457
+                        $data = $degzdata;
458
+                    } elseif ($this->headers['content-encoding'] == 'gzip' && $degzdata = gzinflate(substr($data, 10))) {
459
+                        $data = $degzdata;
460
+                    } else {
461
+                        $this->fault('SOAP-ENV:Client', 'Errors occurred when trying to decode the data');
462
+                        return;
463
+                    }
464
+                } else {
465
+                    $this->fault('SOAP-ENV:Client', 'This Server does not support compressed data');
466
+                    return;
467
+                }
468
+            }
469
+        }
470
+        $this->request .= "\r\n".$data;
471
+        $data = $this->parseRequest($this->headers, $data);
472
+        $this->requestSOAP = $data;
473
+        $this->debug('leaving parse_request');
474
+    }
475 475
 
476
-	/**
477
-	* invokes a PHP function for the requested SOAP method
478
-	*
479
-	* The following fields are set by this function (when successful)
480
-	*
481
-	* methodreturn
482
-	*
483
-	* Note that the PHP function that is called may also set the following
484
-	* fields to affect the response sent to the client
485
-	*
486
-	* responseHeaders
487
-	* outgoing_headers
488
-	*
489
-	* This sets the fault field on error
490
-	*
491
-	* @access   private
492
-	*/
493
-	function invoke_method() {
494
-		$this->debug('in invoke_method, methodname=' . $this->methodname . ' methodURI=' . $this->methodURI . ' SOAPAction=' . $this->SOAPAction);
476
+    /**
477
+     * invokes a PHP function for the requested SOAP method
478
+     *
479
+     * The following fields are set by this function (when successful)
480
+     *
481
+     * methodreturn
482
+     *
483
+     * Note that the PHP function that is called may also set the following
484
+     * fields to affect the response sent to the client
485
+     *
486
+     * responseHeaders
487
+     * outgoing_headers
488
+     *
489
+     * This sets the fault field on error
490
+     *
491
+     * @access   private
492
+     */
493
+    function invoke_method() {
494
+        $this->debug('in invoke_method, methodname=' . $this->methodname . ' methodURI=' . $this->methodURI . ' SOAPAction=' . $this->SOAPAction);
495 495
 
496
-		//
497
-		// if you are debugging in this area of the code, your service uses a class to implement methods,
498
-		// you use SOAP RPC, and the client is .NET, please be aware of the following...
499
-		// when the .NET wsdl.exe utility generates a proxy, it will remove the '.' or '..' from the
500
-		// method name.  that is fine for naming the .NET methods.  it is not fine for properly constructing
501
-		// the XML request and reading the XML response.  you need to add the RequestElementName and
502
-		// ResponseElementName to the System.Web.Services.Protocols.SoapRpcMethodAttribute that wsdl.exe
503
-		// generates for the method.  these parameters are used to specify the correct XML element names
504
-		// for .NET to use, i.e. the names with the '.' in them.
505
-		//
506
-		$orig_methodname = $this->methodname;
507
-		if ($this->wsdl) {
508
-			if ($this->opData = $this->wsdl->getOperationData($this->methodname)) {
509
-				$this->debug('in invoke_method, found WSDL operation=' . $this->methodname);
510
-				$this->appendDebug('opData=' . $this->varDump($this->opData));
511
-			} elseif ($this->opData = $this->wsdl->getOperationDataForSoapAction($this->SOAPAction)) {
512
-				// Note: hopefully this case will only be used for doc/lit, since rpc services should have wrapper element
513
-				$this->debug('in invoke_method, found WSDL soapAction=' . $this->SOAPAction . ' for operation=' . $this->opData['name']);
514
-				$this->appendDebug('opData=' . $this->varDump($this->opData));
515
-				$this->methodname = $this->opData['name'];
516
-			} else {
517
-				$this->debug('in invoke_method, no WSDL for operation=' . $this->methodname);
518
-				$this->fault('SOAP-ENV:Client', "Operation '" . $this->methodname . "' is not defined in the WSDL for this service");
519
-				return;
520
-			}
521
-		} else {
522
-			$this->debug('in invoke_method, no WSDL to validate method');
523
-		}
496
+        //
497
+        // if you are debugging in this area of the code, your service uses a class to implement methods,
498
+        // you use SOAP RPC, and the client is .NET, please be aware of the following...
499
+        // when the .NET wsdl.exe utility generates a proxy, it will remove the '.' or '..' from the
500
+        // method name.  that is fine for naming the .NET methods.  it is not fine for properly constructing
501
+        // the XML request and reading the XML response.  you need to add the RequestElementName and
502
+        // ResponseElementName to the System.Web.Services.Protocols.SoapRpcMethodAttribute that wsdl.exe
503
+        // generates for the method.  these parameters are used to specify the correct XML element names
504
+        // for .NET to use, i.e. the names with the '.' in them.
505
+        //
506
+        $orig_methodname = $this->methodname;
507
+        if ($this->wsdl) {
508
+            if ($this->opData = $this->wsdl->getOperationData($this->methodname)) {
509
+                $this->debug('in invoke_method, found WSDL operation=' . $this->methodname);
510
+                $this->appendDebug('opData=' . $this->varDump($this->opData));
511
+            } elseif ($this->opData = $this->wsdl->getOperationDataForSoapAction($this->SOAPAction)) {
512
+                // Note: hopefully this case will only be used for doc/lit, since rpc services should have wrapper element
513
+                $this->debug('in invoke_method, found WSDL soapAction=' . $this->SOAPAction . ' for operation=' . $this->opData['name']);
514
+                $this->appendDebug('opData=' . $this->varDump($this->opData));
515
+                $this->methodname = $this->opData['name'];
516
+            } else {
517
+                $this->debug('in invoke_method, no WSDL for operation=' . $this->methodname);
518
+                $this->fault('SOAP-ENV:Client', "Operation '" . $this->methodname . "' is not defined in the WSDL for this service");
519
+                return;
520
+            }
521
+        } else {
522
+            $this->debug('in invoke_method, no WSDL to validate method');
523
+        }
524 524
 
525
-		// if a . is present in $this->methodname, we see if there is a class in scope,
526
-		// which could be referred to. We will also distinguish between two deliminators,
527
-		// to allow methods to be called a the class or an instance
528
-		if (strpos($this->methodname, '..') > 0) {
529
-			$delim = '..';
530
-		} else if (strpos($this->methodname, '.') > 0) {
531
-			$delim = '.';
532
-		} else {
533
-			$delim = '';
534
-		}
535
-		$this->debug("in invoke_method, delim=$delim");
525
+        // if a . is present in $this->methodname, we see if there is a class in scope,
526
+        // which could be referred to. We will also distinguish between two deliminators,
527
+        // to allow methods to be called a the class or an instance
528
+        if (strpos($this->methodname, '..') > 0) {
529
+            $delim = '..';
530
+        } else if (strpos($this->methodname, '.') > 0) {
531
+            $delim = '.';
532
+        } else {
533
+            $delim = '';
534
+        }
535
+        $this->debug("in invoke_method, delim=$delim");
536 536
 
537
-		$class = '';
538
-		$method = '';
539
-		if (strlen($delim) > 0 && substr_count($this->methodname, $delim) == 1) {
540
-			$try_class = substr($this->methodname, 0, strpos($this->methodname, $delim));
541
-			if (class_exists($try_class)) {
542
-				// get the class and method name
543
-				$class = $try_class;
544
-				$method = substr($this->methodname, strpos($this->methodname, $delim) + strlen($delim));
545
-				$this->debug("in invoke_method, class=$class method=$method delim=$delim");
546
-			} else {
547
-				$this->debug("in invoke_method, class=$try_class not found");
548
-			}
549
-		} else {
550
-			$try_class = '';
551
-			$this->debug("in invoke_method, no class to try");
552
-		}
537
+        $class = '';
538
+        $method = '';
539
+        if (strlen($delim) > 0 && substr_count($this->methodname, $delim) == 1) {
540
+            $try_class = substr($this->methodname, 0, strpos($this->methodname, $delim));
541
+            if (class_exists($try_class)) {
542
+                // get the class and method name
543
+                $class = $try_class;
544
+                $method = substr($this->methodname, strpos($this->methodname, $delim) + strlen($delim));
545
+                $this->debug("in invoke_method, class=$class method=$method delim=$delim");
546
+            } else {
547
+                $this->debug("in invoke_method, class=$try_class not found");
548
+            }
549
+        } else {
550
+            $try_class = '';
551
+            $this->debug("in invoke_method, no class to try");
552
+        }
553 553
 
554
-		// does method exist?
555
-		if ($class == '') {
556
-			if (!function_exists($this->methodname)) {
557
-				$this->debug("in invoke_method, function '$this->methodname' not found!");
558
-				$this->result = 'fault: method not found';
559
-				$this->fault('SOAP-ENV:Client',"method '$this->methodname'('$orig_methodname') not defined in service('$try_class' '$delim')");
560
-				return;
561
-			}
562
-		} else {
563
-			$method_to_compare = (substr(phpversion(), 0, 2) == '4.') ? strtolower($method) : $method;
564
-			if (!in_array($method_to_compare, get_class_methods($class))) {
565
-				$this->debug("in invoke_method, method '$this->methodname' not found in class '$class'!");
566
-				$this->result = 'fault: method not found';
567
-				$this->fault('SOAP-ENV:Client',"method '$this->methodname'/'$method_to_compare'('$orig_methodname') not defined in service/'$class'('$try_class' '$delim')");
568
-				return;
569
-			}
570
-		}
554
+        // does method exist?
555
+        if ($class == '') {
556
+            if (!function_exists($this->methodname)) {
557
+                $this->debug("in invoke_method, function '$this->methodname' not found!");
558
+                $this->result = 'fault: method not found';
559
+                $this->fault('SOAP-ENV:Client',"method '$this->methodname'('$orig_methodname') not defined in service('$try_class' '$delim')");
560
+                return;
561
+            }
562
+        } else {
563
+            $method_to_compare = (substr(phpversion(), 0, 2) == '4.') ? strtolower($method) : $method;
564
+            if (!in_array($method_to_compare, get_class_methods($class))) {
565
+                $this->debug("in invoke_method, method '$this->methodname' not found in class '$class'!");
566
+                $this->result = 'fault: method not found';
567
+                $this->fault('SOAP-ENV:Client',"method '$this->methodname'/'$method_to_compare'('$orig_methodname') not defined in service/'$class'('$try_class' '$delim')");
568
+                return;
569
+            }
570
+        }
571 571
 
572
-		// evaluate message, getting back parameters
573
-		// verify that request parameters match the method's signature
574
-		if(! $this->verify_method($this->methodname,$this->methodparams)){
575
-			// debug
576
-			$this->debug('ERROR: request not verified against method signature');
577
-			$this->result = 'fault: request failed validation against method signature';
578
-			// return fault
579
-			$this->fault('SOAP-ENV:Client',"Operation '$this->methodname' not defined in service.");
580
-			return;
581
-		}
572
+        // evaluate message, getting back parameters
573
+        // verify that request parameters match the method's signature
574
+        if(! $this->verify_method($this->methodname,$this->methodparams)){
575
+            // debug
576
+            $this->debug('ERROR: request not verified against method signature');
577
+            $this->result = 'fault: request failed validation against method signature';
578
+            // return fault
579
+            $this->fault('SOAP-ENV:Client',"Operation '$this->methodname' not defined in service.");
580
+            return;
581
+        }
582 582
 
583
-		// if there are parameters to pass
584
-		$this->debug('in invoke_method, params:');
585
-		$this->appendDebug($this->varDump($this->methodparams));
586
-		$this->debug("in invoke_method, calling '$this->methodname'");
587
-		if (!function_exists('call_user_func_array')) {
588
-			if ($class == '') {
589
-				$this->debug('in invoke_method, calling function using eval()');
590
-				$funcCall = "\$this->methodreturn = $this->methodname(";
591
-			} else {
592
-				if ($delim == '..') {
593
-					$this->debug('in invoke_method, calling class method using eval()');
594
-					$funcCall = "\$this->methodreturn = ".$class."::".$method."(";
595
-				} else {
596
-					$this->debug('in invoke_method, calling instance method using eval()');
597
-					// generate unique instance name
598
-					$instname = "\$inst_".time();
599
-					$funcCall = $instname." = new ".$class."(); ";
600
-					$funcCall .= "\$this->methodreturn = ".$instname."->".$method."(";
601
-				}
602
-			}
603
-			if ($this->methodparams) {
604
-				foreach ($this->methodparams as $param) {
605
-					if (is_array($param) || is_object($param)) {
606
-						$this->fault('SOAP-ENV:Client', 'NuSOAP does not handle complexType parameters correctly when using eval; call_user_func_array must be available');
607
-						return;
608
-					}
609
-					$funcCall .= "\"$param\",";
610
-				}
611
-				$funcCall = substr($funcCall, 0, -1);
612
-			}
613
-			$funcCall .= ');';
614
-			$this->debug('in invoke_method, function call: '.$funcCall);
615
-			@eval($funcCall);
616
-		} else {
617
-			if ($class == '') {
618
-				$this->debug('in invoke_method, calling function using call_user_func_array()');
619
-				$call_arg = "$this->methodname";	// straight assignment changes $this->methodname to lower case after call_user_func_array()
620
-			} elseif ($delim == '..') {
621
-				$this->debug('in invoke_method, calling class method using call_user_func_array()');
622
-				$call_arg = array ($class, $method);
623
-			} else {
624
-				$this->debug('in invoke_method, calling instance method using call_user_func_array()');
625
-				$instance = new $class ();
626
-				$call_arg = array(&$instance, $method);
627
-			}
628
-			if (is_array($this->methodparams)) {
629
-				$this->methodreturn = call_user_func_array($call_arg, array_values($this->methodparams));
630
-			} else {
631
-				$this->methodreturn = call_user_func_array($call_arg, array());
632
-			}
633
-		}
583
+        // if there are parameters to pass
584
+        $this->debug('in invoke_method, params:');
585
+        $this->appendDebug($this->varDump($this->methodparams));
586
+        $this->debug("in invoke_method, calling '$this->methodname'");
587
+        if (!function_exists('call_user_func_array')) {
588
+            if ($class == '') {
589
+                $this->debug('in invoke_method, calling function using eval()');
590
+                $funcCall = "\$this->methodreturn = $this->methodname(";
591
+            } else {
592
+                if ($delim == '..') {
593
+                    $this->debug('in invoke_method, calling class method using eval()');
594
+                    $funcCall = "\$this->methodreturn = ".$class."::".$method."(";
595
+                } else {
596
+                    $this->debug('in invoke_method, calling instance method using eval()');
597
+                    // generate unique instance name
598
+                    $instname = "\$inst_".time();
599
+                    $funcCall = $instname." = new ".$class."(); ";
600
+                    $funcCall .= "\$this->methodreturn = ".$instname."->".$method."(";
601
+                }
602
+            }
603
+            if ($this->methodparams) {
604
+                foreach ($this->methodparams as $param) {
605
+                    if (is_array($param) || is_object($param)) {
606
+                        $this->fault('SOAP-ENV:Client', 'NuSOAP does not handle complexType parameters correctly when using eval; call_user_func_array must be available');
607
+                        return;
608
+                    }
609
+                    $funcCall .= "\"$param\",";
610
+                }
611
+                $funcCall = substr($funcCall, 0, -1);
612
+            }
613
+            $funcCall .= ');';
614
+            $this->debug('in invoke_method, function call: '.$funcCall);
615
+            @eval($funcCall);
616
+        } else {
617
+            if ($class == '') {
618
+                $this->debug('in invoke_method, calling function using call_user_func_array()');
619
+                $call_arg = "$this->methodname";	// straight assignment changes $this->methodname to lower case after call_user_func_array()
620
+            } elseif ($delim == '..') {
621
+                $this->debug('in invoke_method, calling class method using call_user_func_array()');
622
+                $call_arg = array ($class, $method);
623
+            } else {
624
+                $this->debug('in invoke_method, calling instance method using call_user_func_array()');
625
+                $instance = new $class ();
626
+                $call_arg = array(&$instance, $method);
627
+            }
628
+            if (is_array($this->methodparams)) {
629
+                $this->methodreturn = call_user_func_array($call_arg, array_values($this->methodparams));
630
+            } else {
631
+                $this->methodreturn = call_user_func_array($call_arg, array());
632
+            }
633
+        }
634 634
         $this->debug('in invoke_method, methodreturn:');
635 635
         $this->appendDebug($this->varDump($this->methodreturn));
636
-		$this->debug("in invoke_method, called method $this->methodname, received data of type ".gettype($this->methodreturn));
637
-	}
636
+        $this->debug("in invoke_method, called method $this->methodname, received data of type ".gettype($this->methodreturn));
637
+    }
638 638
 
639
-	/**
640
-	* serializes the return value from a PHP function into a full SOAP Envelope
641
-	*
642
-	* The following fields are set by this function (when successful)
643
-	*
644
-	* responseSOAP
645
-	*
646
-	* This sets the fault field on error
647
-	*
648
-	* @access   private
649
-	*/
650
-	function serialize_return() {
651
-		$this->debug('Entering serialize_return methodname: ' . $this->methodname . ' methodURI: ' . $this->methodURI);
652
-		// if fault
653
-		if (isset($this->methodreturn) && is_object($this->methodreturn) && ((get_class($this->methodreturn) == 'soap_fault') || (get_class($this->methodreturn) == 'nusoap_fault'))) {
654
-			$this->debug('got a fault object from method');
655
-			$this->fault = $this->methodreturn;
656
-			return;
657
-		} elseif ($this->methodreturnisliteralxml) {
658
-			$return_val = $this->methodreturn;
659
-		// returned value(s)
660
-		} else {
661
-			$this->debug('got a(n) '.gettype($this->methodreturn).' from method');
662
-			$this->debug('serializing return value');
663
-			if($this->wsdl){
664
-				$opParams = "";
665
-				if (sizeof($this->opData['output']['parts']) > 1) {
666
-					$this->debug('more than one output part, so use the method return unchanged');
667
-			    	$opParams = $this->methodreturn;
668
-			    } elseif (sizeof($this->opData['output']['parts']) == 1) {
669
-					$this->debug('exactly one output part, so wrap the method return in a simple array');
670
-					// TODO: verify that it is not already wrapped!
671
-			    	//foreach ($this->opData['output']['parts'] as $name => $type) {
672
-					//	$this->debug('wrap in element named ' . $name);
673
-			    	//}
674
-			    	$opParams = array($this->methodreturn);
675
-			    }
676
-			    $return_val = $this->wsdl->serializeRPCParameters($this->methodname,'output',$opParams);
677
-			    $this->appendDebug($this->wsdl->getDebug());
678
-			    $this->wsdl->clearDebug();
679
-				if($errstr = $this->wsdl->getError()){
680
-					$this->debug('got wsdl error: '.$errstr);
681
-					$this->fault('SOAP-ENV:Server', 'unable to serialize result');
682
-					return;
683
-				}
684
-			} else {
685
-				if (isset($this->methodreturn)) {
686
-					$return_val = $this->serialize_val($this->methodreturn, 'return');
687
-				} else {
688
-					$return_val = '';
689
-					$this->debug('in absence of WSDL, assume void return for backward compatibility');
690
-				}
691
-			}
692
-		}
693
-		$this->debug('return value:');
694
-		$this->appendDebug($this->varDump($return_val));
639
+    /**
640
+     * serializes the return value from a PHP function into a full SOAP Envelope
641
+     *
642
+     * The following fields are set by this function (when successful)
643
+     *
644
+     * responseSOAP
645
+     *
646
+     * This sets the fault field on error
647
+     *
648
+     * @access   private
649
+     */
650
+    function serialize_return() {
651
+        $this->debug('Entering serialize_return methodname: ' . $this->methodname . ' methodURI: ' . $this->methodURI);
652
+        // if fault
653
+        if (isset($this->methodreturn) && is_object($this->methodreturn) && ((get_class($this->methodreturn) == 'soap_fault') || (get_class($this->methodreturn) == 'nusoap_fault'))) {
654
+            $this->debug('got a fault object from method');
655
+            $this->fault = $this->methodreturn;
656
+            return;
657
+        } elseif ($this->methodreturnisliteralxml) {
658
+            $return_val = $this->methodreturn;
659
+        // returned value(s)
660
+        } else {
661
+            $this->debug('got a(n) '.gettype($this->methodreturn).' from method');
662
+            $this->debug('serializing return value');
663
+            if($this->wsdl){
664
+                $opParams = "";
665
+                if (sizeof($this->opData['output']['parts']) > 1) {
666
+                    $this->debug('more than one output part, so use the method return unchanged');
667
+                    $opParams = $this->methodreturn;
668
+                } elseif (sizeof($this->opData['output']['parts']) == 1) {
669
+                    $this->debug('exactly one output part, so wrap the method return in a simple array');
670
+                    // TODO: verify that it is not already wrapped!
671
+                    //foreach ($this->opData['output']['parts'] as $name => $type) {
672
+                    //	$this->debug('wrap in element named ' . $name);
673
+                    //}
674
+                    $opParams = array($this->methodreturn);
675
+                }
676
+                $return_val = $this->wsdl->serializeRPCParameters($this->methodname,'output',$opParams);
677
+                $this->appendDebug($this->wsdl->getDebug());
678
+                $this->wsdl->clearDebug();
679
+                if($errstr = $this->wsdl->getError()){
680
+                    $this->debug('got wsdl error: '.$errstr);
681
+                    $this->fault('SOAP-ENV:Server', 'unable to serialize result');
682
+                    return;
683
+                }
684
+            } else {
685
+                if (isset($this->methodreturn)) {
686
+                    $return_val = $this->serialize_val($this->methodreturn, 'return');
687
+                } else {
688
+                    $return_val = '';
689
+                    $this->debug('in absence of WSDL, assume void return for backward compatibility');
690
+                }
691
+            }
692
+        }
693
+        $this->debug('return value:');
694
+        $this->appendDebug($this->varDump($return_val));
695 695
 
696
-		$this->debug('serializing response');
697
-		if ($this->wsdl) {
698
-			$this->debug('have WSDL for serialization: style is ' . $this->opData['style']);
699
-			if ($this->opData['style'] == 'rpc') {
700
-				$this->debug('style is rpc for serialization: use is ' . $this->opData['output']['use']);
701
-				if ($this->opData['output']['use'] == 'literal') {
702
-					// http://www.ws-i.org/Profiles/BasicProfile-1.1-2004-08-24.html R2735 says rpc/literal accessor elements should not be in a namespace
703
-					if ($this->methodURI) {
704
-						$payload = '<ns1:'.$this->methodname.'Response xmlns:ns1="'.$this->methodURI.'">'.$return_val.'</ns1:'.$this->methodname."Response>";
705
-					} else {
706
-						$payload = '<'.$this->methodname.'Response>'.$return_val.'</'.$this->methodname.'Response>';
707
-					}
708
-				} else {
709
-					if ($this->methodURI) {
710
-						$payload = '<ns1:'.$this->methodname.'Response xmlns:ns1="'.$this->methodURI.'">'.$return_val.'</ns1:'.$this->methodname."Response>";
711
-					} else {
712
-						$payload = '<'.$this->methodname.'Response>'.$return_val.'</'.$this->methodname.'Response>';
713
-					}
714
-				}
715
-			} else {
716
-				$this->debug('style is not rpc for serialization: assume document');
717
-				$payload = $return_val;
718
-			}
719
-		} else {
720
-			$this->debug('do not have WSDL for serialization: assume rpc/encoded');
721
-			$payload = '<ns1:'.$this->methodname.'Response xmlns:ns1="'.$this->methodURI.'">'.$return_val.'</ns1:'.$this->methodname."Response>";
722
-		}
723
-		$this->result = 'successful';
724
-		if($this->wsdl){
725
-			//if($this->debug_flag){
726
-            	$this->appendDebug($this->wsdl->getDebug());
696
+        $this->debug('serializing response');
697
+        if ($this->wsdl) {
698
+            $this->debug('have WSDL for serialization: style is ' . $this->opData['style']);
699
+            if ($this->opData['style'] == 'rpc') {
700
+                $this->debug('style is rpc for serialization: use is ' . $this->opData['output']['use']);
701
+                if ($this->opData['output']['use'] == 'literal') {
702
+                    // http://www.ws-i.org/Profiles/BasicProfile-1.1-2004-08-24.html R2735 says rpc/literal accessor elements should not be in a namespace
703
+                    if ($this->methodURI) {
704
+                        $payload = '<ns1:'.$this->methodname.'Response xmlns:ns1="'.$this->methodURI.'">'.$return_val.'</ns1:'.$this->methodname."Response>";
705
+                    } else {
706
+                        $payload = '<'.$this->methodname.'Response>'.$return_val.'</'.$this->methodname.'Response>';
707
+                    }
708
+                } else {
709
+                    if ($this->methodURI) {
710
+                        $payload = '<ns1:'.$this->methodname.'Response xmlns:ns1="'.$this->methodURI.'">'.$return_val.'</ns1:'.$this->methodname."Response>";
711
+                    } else {
712
+                        $payload = '<'.$this->methodname.'Response>'.$return_val.'</'.$this->methodname.'Response>';
713
+                    }
714
+                }
715
+            } else {
716
+                $this->debug('style is not rpc for serialization: assume document');
717
+                $payload = $return_val;
718
+            }
719
+        } else {
720
+            $this->debug('do not have WSDL for serialization: assume rpc/encoded');
721
+            $payload = '<ns1:'.$this->methodname.'Response xmlns:ns1="'.$this->methodURI.'">'.$return_val.'</ns1:'.$this->methodname."Response>";
722
+        }
723
+        $this->result = 'successful';
724
+        if($this->wsdl){
725
+            //if($this->debug_flag){
726
+                $this->appendDebug($this->wsdl->getDebug());
727 727
             //	}
728
-			if (isset($this->opData['output']['encodingStyle'])) {
729
-				$encodingStyle = $this->opData['output']['encodingStyle'];
730
-			} else {
731
-				$encodingStyle = '';
732
-			}
733
-			// Added: In case we use a WSDL, return a serialized env. WITH the usedNamespaces.
734
-			$this->responseSOAP = $this->serializeEnvelope($payload,$this->responseHeaders,$this->wsdl->usedNamespaces,$this->opData['style'],$this->opData['output']['use'],$encodingStyle);
735
-		} else {
736
-			$this->responseSOAP = $this->serializeEnvelope($payload,$this->responseHeaders);
737
-		}
738
-		$this->debug("Leaving serialize_return");
739
-	}
728
+            if (isset($this->opData['output']['encodingStyle'])) {
729
+                $encodingStyle = $this->opData['output']['encodingStyle'];
730
+            } else {
731
+                $encodingStyle = '';
732
+            }
733
+            // Added: In case we use a WSDL, return a serialized env. WITH the usedNamespaces.
734
+            $this->responseSOAP = $this->serializeEnvelope($payload,$this->responseHeaders,$this->wsdl->usedNamespaces,$this->opData['style'],$this->opData['output']['use'],$encodingStyle);
735
+        } else {
736
+            $this->responseSOAP = $this->serializeEnvelope($payload,$this->responseHeaders);
737
+        }
738
+        $this->debug("Leaving serialize_return");
739
+    }
740 740
 
741
-	/**
742
-	* sends an HTTP response
743
-	*
744
-	* The following fields are set by this function (when successful)
745
-	*
746
-	* outgoing_headers
747
-	* response
748
-	*
749
-	* @access   private
750
-	*/
751
-	function send_response() {
752
-		$this->debug('Enter send_response');
753
-		if ($this->fault) {
754
-			$payload = $this->fault->serialize();
755
-			$this->outgoing_headers[] = "HTTP/1.0 500 Internal Server Error";
756
-			$this->outgoing_headers[] = "Status: 500 Internal Server Error";
757
-		} else {
758
-			$payload = $this->responseSOAP;
759
-			// Some combinations of PHP+Web server allow the Status
760
-			// to come through as a header.  Since OK is the default
761
-			// just do nothing.
762
-			// $this->outgoing_headers[] = "HTTP/1.0 200 OK";
763
-			// $this->outgoing_headers[] = "Status: 200 OK";
764
-		}
741
+    /**
742
+     * sends an HTTP response
743
+     *
744
+     * The following fields are set by this function (when successful)
745
+     *
746
+     * outgoing_headers
747
+     * response
748
+     *
749
+     * @access   private
750
+     */
751
+    function send_response() {
752
+        $this->debug('Enter send_response');
753
+        if ($this->fault) {
754
+            $payload = $this->fault->serialize();
755
+            $this->outgoing_headers[] = "HTTP/1.0 500 Internal Server Error";
756
+            $this->outgoing_headers[] = "Status: 500 Internal Server Error";
757
+        } else {
758
+            $payload = $this->responseSOAP;
759
+            // Some combinations of PHP+Web server allow the Status
760
+            // to come through as a header.  Since OK is the default
761
+            // just do nothing.
762
+            // $this->outgoing_headers[] = "HTTP/1.0 200 OK";
763
+            // $this->outgoing_headers[] = "Status: 200 OK";
764
+        }
765 765
         // add debug data if in debug mode
766
-		if(isset($this->debug_flag) && $this->debug_flag){
767
-        	$payload .= $this->getDebugAsXMLComment();
766
+        if(isset($this->debug_flag) && $this->debug_flag){
767
+            $payload .= $this->getDebugAsXMLComment();
768
+        }
769
+        $this->outgoing_headers[] = "Server: $this->title Server v$this->version";
770
+        preg_match('/\$Revisio' . 'n: ([^ ]+)/', $this->revision, $rev);
771
+        $this->outgoing_headers[] = "X-SOAP-Server: $this->title/$this->version (".$rev[1].")";
772
+        // Let the Web server decide about this
773
+        //$this->outgoing_headers[] = "Connection: Close\r\n";
774
+        $payload = $this->getHTTPBody($payload);
775
+        $type = $this->getHTTPContentType();
776
+        $charset = $this->getHTTPContentTypeCharset();
777
+        $this->outgoing_headers[] = "Content-Type: $type" . ($charset ? '; charset=' . $charset : '');
778
+        //begin code to compress payload - by John
779
+        // NOTE: there is no way to know whether the Web server will also compress
780
+        // this data.
781
+        if (strlen($payload) > 1024 && isset($this->headers) && isset($this->headers['accept-encoding'])) {
782
+            if (strstr($this->headers['accept-encoding'], 'gzip')) {
783
+                if (function_exists('gzencode')) {
784
+                    if (isset($this->debug_flag) && $this->debug_flag) {
785
+                        $payload .= "<!-- Content being gzipped -->";
786
+                    }
787
+                    $this->outgoing_headers[] = "Content-Encoding: gzip";
788
+                    $payload = gzencode($payload);
789
+                } else {
790
+                    if (isset($this->debug_flag) && $this->debug_flag) {
791
+                        $payload .= "<!-- Content will not be gzipped: no gzencode -->";
792
+                    }
793
+                }
794
+            } elseif (strstr($this->headers['accept-encoding'], 'deflate')) {
795
+                // Note: MSIE requires gzdeflate output (no Zlib header and checksum),
796
+                // instead of gzcompress output,
797
+                // which conflicts with HTTP 1.1 spec (http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.5)
798
+                if (function_exists('gzdeflate')) {
799
+                    if (isset($this->debug_flag) && $this->debug_flag) {
800
+                        $payload .= "<!-- Content being deflated -->";
801
+                    }
802
+                    $this->outgoing_headers[] = "Content-Encoding: deflate";
803
+                    $payload = gzdeflate($payload);
804
+                } else {
805
+                    if (isset($this->debug_flag) && $this->debug_flag) {
806
+                        $payload .= "<!-- Content will not be deflated: no gzcompress -->";
807
+                    }
808
+                }
809
+            }
768 810
         }
769
-		$this->outgoing_headers[] = "Server: $this->title Server v$this->version";
770
-		preg_match('/\$Revisio' . 'n: ([^ ]+)/', $this->revision, $rev);
771
-		$this->outgoing_headers[] = "X-SOAP-Server: $this->title/$this->version (".$rev[1].")";
772
-		// Let the Web server decide about this
773
-		//$this->outgoing_headers[] = "Connection: Close\r\n";
774
-		$payload = $this->getHTTPBody($payload);
775
-		$type = $this->getHTTPContentType();
776
-		$charset = $this->getHTTPContentTypeCharset();
777
-		$this->outgoing_headers[] = "Content-Type: $type" . ($charset ? '; charset=' . $charset : '');
778
-		//begin code to compress payload - by John
779
-		// NOTE: there is no way to know whether the Web server will also compress
780
-		// this data.
781
-		if (strlen($payload) > 1024 && isset($this->headers) && isset($this->headers['accept-encoding'])) {
782
-			if (strstr($this->headers['accept-encoding'], 'gzip')) {
783
-				if (function_exists('gzencode')) {
784
-					if (isset($this->debug_flag) && $this->debug_flag) {
785
-						$payload .= "<!-- Content being gzipped -->";
786
-					}
787
-					$this->outgoing_headers[] = "Content-Encoding: gzip";
788
-					$payload = gzencode($payload);
789
-				} else {
790
-					if (isset($this->debug_flag) && $this->debug_flag) {
791
-						$payload .= "<!-- Content will not be gzipped: no gzencode -->";
792
-					}
793
-				}
794
-			} elseif (strstr($this->headers['accept-encoding'], 'deflate')) {
795
-				// Note: MSIE requires gzdeflate output (no Zlib header and checksum),
796
-				// instead of gzcompress output,
797
-				// which conflicts with HTTP 1.1 spec (http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.5)
798
-				if (function_exists('gzdeflate')) {
799
-					if (isset($this->debug_flag) && $this->debug_flag) {
800
-						$payload .= "<!-- Content being deflated -->";
801
-					}
802
-					$this->outgoing_headers[] = "Content-Encoding: deflate";
803
-					$payload = gzdeflate($payload);
804
-				} else {
805
-					if (isset($this->debug_flag) && $this->debug_flag) {
806
-						$payload .= "<!-- Content will not be deflated: no gzcompress -->";
807
-					}
808
-				}
809
-			}
810
-		}
811
-		//end code
812
-		$this->outgoing_headers[] = "Content-Length: ".strlen($payload);
813
-		reset($this->outgoing_headers);
814
-		foreach($this->outgoing_headers as $hdr){
815
-			header($hdr, false);
816
-		}
817
-		print $payload;
818
-		$this->response = join("\r\n",$this->outgoing_headers)."\r\n\r\n".$payload;
819
-	}
811
+        //end code
812
+        $this->outgoing_headers[] = "Content-Length: ".strlen($payload);
813
+        reset($this->outgoing_headers);
814
+        foreach($this->outgoing_headers as $hdr){
815
+            header($hdr, false);
816
+        }
817
+        print $payload;
818
+        $this->response = join("\r\n",$this->outgoing_headers)."\r\n\r\n".$payload;
819
+    }
820 820
 
821
-	/**
822
-	* takes the value that was created by parsing the request
823
-	* and compares to the method's signature, if available.
824
-	*
825
-	* @param	string	$operation	The operation to be invoked
826
-	* @param	array	$request	The array of parameter values
827
-	* @return	boolean	Whether the operation was found
828
-	* @access   private
829
-	*/
830
-	function verify_method($operation,$request){
831
-		if(isset($this->wsdl) && is_object($this->wsdl)){
832
-			if($this->wsdl->getOperationData($operation)){
833
-				return true;
834
-			}
835
-	    } elseif(isset($this->operations[$operation])){
836
-			return true;
837
-		}
838
-		return false;
839
-	}
821
+    /**
822
+     * takes the value that was created by parsing the request
823
+     * and compares to the method's signature, if available.
824
+     *
825
+     * @param	string	$operation	The operation to be invoked
826
+     * @param	array	$request	The array of parameter values
827
+     * @return	boolean	Whether the operation was found
828
+     * @access   private
829
+     */
830
+    function verify_method($operation,$request){
831
+        if(isset($this->wsdl) && is_object($this->wsdl)){
832
+            if($this->wsdl->getOperationData($operation)){
833
+                return true;
834
+            }
835
+        } elseif(isset($this->operations[$operation])){
836
+            return true;
837
+        }
838
+        return false;
839
+    }
840 840
 
841
-	/**
842
-	* processes SOAP message received from client
843
-	*
844
-	* @param	array	$headers	The HTTP headers
845
-	* @param	string	$data		unprocessed request data from client
846
-	* @return	mixed	value of the message, decoded into a PHP type
847
-	* @access   private
848
-	*/
841
+    /**
842
+     * processes SOAP message received from client
843
+     *
844
+     * @param	array	$headers	The HTTP headers
845
+     * @param	string	$data		unprocessed request data from client
846
+     * @return	mixed	value of the message, decoded into a PHP type
847
+     * @access   private
848
+     */
849 849
     function parseRequest($headers, $data) {
850
-		$this->debug('Entering parseRequest() for data of length ' . strlen($data) . ' headers:');
851
-		$this->appendDebug($this->varDump($headers));
852
-    	if (!isset($headers['content-type'])) {
853
-			$this->setError('Request not of type text/xml (no content-type header)');
854
-			return false;
855
-    	}
856
-		if (!strstr($headers['content-type'], 'text/xml')) {
857
-			$this->setError('Request not of type text/xml');
858
-			return false;
859
-		}
860
-		if (strpos($headers['content-type'], '=')) {
861
-			$enc = str_replace('"', '', substr(strstr($headers["content-type"], '='), 1));
862
-			$this->debug('Got response encoding: ' . $enc);
863
-			if(preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)){
864
-				$this->xml_encoding = strtoupper($enc);
865
-			} else {
866
-				$this->xml_encoding = 'US-ASCII';
867
-			}
868
-		} else {
869
-			// should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1
870
-			$this->xml_encoding = 'ISO-8859-1';
871
-		}
872
-		$this->debug('Use encoding: ' . $this->xml_encoding . ' when creating nusoap_parser');
873
-		// parse response, get soap parser obj
874
-		$parser = new nusoap_parser($data,$this->xml_encoding,'',$this->decode_utf8);
850
+        $this->debug('Entering parseRequest() for data of length ' . strlen($data) . ' headers:');
851
+        $this->appendDebug($this->varDump($headers));
852
+        if (!isset($headers['content-type'])) {
853
+            $this->setError('Request not of type text/xml (no content-type header)');
854
+            return false;
855
+        }
856
+        if (!strstr($headers['content-type'], 'text/xml')) {
857
+            $this->setError('Request not of type text/xml');
858
+            return false;
859
+        }
860
+        if (strpos($headers['content-type'], '=')) {
861
+            $enc = str_replace('"', '', substr(strstr($headers["content-type"], '='), 1));
862
+            $this->debug('Got response encoding: ' . $enc);
863
+            if(preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)){
864
+                $this->xml_encoding = strtoupper($enc);
865
+            } else {
866
+                $this->xml_encoding = 'US-ASCII';
867
+            }
868
+        } else {
869
+            // should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1
870
+            $this->xml_encoding = 'ISO-8859-1';
871
+        }
872
+        $this->debug('Use encoding: ' . $this->xml_encoding . ' when creating nusoap_parser');
873
+        // parse response, get soap parser obj
874
+        $parser = new nusoap_parser($data,$this->xml_encoding,'',$this->decode_utf8);
875 875
 
876
-		// parser debug
877
-		$this->debug("parser debug: \n".$parser->getDebug());
878
-		// if fault occurred during message parsing
879
-		if($err = $parser->getError()){
880
-			$this->result = 'fault: error in msg parsing: '.$err;
881
-			$this->fault('SOAP-ENV:Client',"error in msg parsing:\n".$err);
882
-		// else successfully parsed request into soapval object
883
-		} else {
884
-			// get/set methodname
885
-			$this->methodURI = $parser->root_struct_namespace;
886
-			$this->methodname = $parser->root_struct_name;
887
-			$this->debug('methodname: '.$this->methodname.' methodURI: '.$this->methodURI);
888
-			$this->debug('calling parser->get_soapbody()');
889
-			$this->methodparams = $parser->get_soapbody();
890
-			// get SOAP headers
891
-			$this->requestHeaders = $parser->getHeaders();
892
-			// get SOAP Header
893
-			$this->requestHeader = $parser->get_soapheader();
876
+        // parser debug
877
+        $this->debug("parser debug: \n".$parser->getDebug());
878
+        // if fault occurred during message parsing
879
+        if($err = $parser->getError()){
880
+            $this->result = 'fault: error in msg parsing: '.$err;
881
+            $this->fault('SOAP-ENV:Client',"error in msg parsing:\n".$err);
882
+        // else successfully parsed request into soapval object
883
+        } else {
884
+            // get/set methodname
885
+            $this->methodURI = $parser->root_struct_namespace;
886
+            $this->methodname = $parser->root_struct_name;
887
+            $this->debug('methodname: '.$this->methodname.' methodURI: '.$this->methodURI);
888
+            $this->debug('calling parser->get_soapbody()');
889
+            $this->methodparams = $parser->get_soapbody();
890
+            // get SOAP headers
891
+            $this->requestHeaders = $parser->getHeaders();
892
+            // get SOAP Header
893
+            $this->requestHeader = $parser->get_soapheader();
894 894
             // add document for doclit support
895 895
             $this->document = $parser->document;
896
-		}
897
-	 }
896
+        }
897
+        }
898 898
 
899
-	/**
900
-	* gets the HTTP body for the current response.
901
-	*
902
-	* @param string $soapmsg The SOAP payload
903
-	* @return string The HTTP body, which includes the SOAP payload
904
-	* @access private
905
-	*/
906
-	function getHTTPBody($soapmsg) {
907
-		return $soapmsg;
908
-	}
899
+    /**
900
+     * gets the HTTP body for the current response.
901
+     *
902
+     * @param string $soapmsg The SOAP payload
903
+     * @return string The HTTP body, which includes the SOAP payload
904
+     * @access private
905
+     */
906
+    function getHTTPBody($soapmsg) {
907
+        return $soapmsg;
908
+    }
909 909
 
910
-	/**
911
-	* gets the HTTP content type for the current response.
912
-	*
913
-	* Note: getHTTPBody must be called before this.
914
-	*
915
-	* @return string the HTTP content type for the current response.
916
-	* @access private
917
-	*/
918
-	function getHTTPContentType() {
919
-		return 'text/xml';
920
-	}
910
+    /**
911
+     * gets the HTTP content type for the current response.
912
+     *
913
+     * Note: getHTTPBody must be called before this.
914
+     *
915
+     * @return string the HTTP content type for the current response.
916
+     * @access private
917
+     */
918
+    function getHTTPContentType() {
919
+        return 'text/xml';
920
+    }
921 921
 
922
-	/**
923
-	* gets the HTTP content type charset for the current response.
924
-	* returns false for non-text content types.
925
-	*
926
-	* Note: getHTTPBody must be called before this.
927
-	*
928
-	* @return string the HTTP content type charset for the current response.
929
-	* @access private
930
-	*/
931
-	function getHTTPContentTypeCharset() {
932
-		return $this->soap_defencoding;
933
-	}
922
+    /**
923
+     * gets the HTTP content type charset for the current response.
924
+     * returns false for non-text content types.
925
+     *
926
+     * Note: getHTTPBody must be called before this.
927
+     *
928
+     * @return string the HTTP content type charset for the current response.
929
+     * @access private
930
+     */
931
+    function getHTTPContentTypeCharset() {
932
+        return $this->soap_defencoding;
933
+    }
934 934
 
935
-	/**
936
-	* add a method to the dispatch map (this has been replaced by the register method)
937
-	*
938
-	* @param    string $methodname
939
-	* @param    string $in array of input values
940
-	* @param    string $out array of output values
941
-	* @access   public
942
-	* @deprecated
943
-	*/
944
-	function add_to_map($methodname,$in,$out){
945
-			$this->operations[$methodname] = array('name' => $methodname,'in' => $in,'out' => $out);
946
-	}
935
+    /**
936
+     * add a method to the dispatch map (this has been replaced by the register method)
937
+     *
938
+     * @param    string $methodname
939
+     * @param    string $in array of input values
940
+     * @param    string $out array of output values
941
+     * @access   public
942
+     * @deprecated
943
+     */
944
+    function add_to_map($methodname,$in,$out){
945
+            $this->operations[$methodname] = array('name' => $methodname,'in' => $in,'out' => $out);
946
+    }
947 947
 
948
-	/**
949
-	* register a service function with the server
950
-	*
951
-	* @param    string $name the name of the PHP function, class.method or class..method
952
-	* @param    array $in assoc array of input values: key = param name, value = param type
953
-	* @param    array $out assoc array of output values: key = param name, value = param type
954
-	* @param	mixed $namespace the element namespace for the method or false
955
-	* @param	mixed $soapaction the soapaction for the method or false
956
-	* @param	mixed $style optional (rpc|document) or false Note: when 'document' is specified, parameter and return wrappers are created for you automatically
957
-	* @param	mixed $use optional (encoded|literal) or false
958
-	* @param	string $documentation optional Description to include in WSDL
959
-	* @param	string $encodingStyle optional (usually 'http://schemas.xmlsoap.org/soap/encoding/' for encoded)
960
-	* @access   public
961
-	*/
962
-	function register($name,$in=array(),$out=array(),$namespace=false,$soapaction=false,$style=false,$use=false,$documentation='',$encodingStyle=''){
963
-		global $HTTP_SERVER_VARS;
948
+    /**
949
+     * register a service function with the server
950
+     *
951
+     * @param    string $name the name of the PHP function, class.method or class..method
952
+     * @param    array $in assoc array of input values: key = param name, value = param type
953
+     * @param    array $out assoc array of output values: key = param name, value = param type
954
+     * @param	mixed $namespace the element namespace for the method or false
955
+     * @param	mixed $soapaction the soapaction for the method or false
956
+     * @param	mixed $style optional (rpc|document) or false Note: when 'document' is specified, parameter and return wrappers are created for you automatically
957
+     * @param	mixed $use optional (encoded|literal) or false
958
+     * @param	string $documentation optional Description to include in WSDL
959
+     * @param	string $encodingStyle optional (usually 'http://schemas.xmlsoap.org/soap/encoding/' for encoded)
960
+     * @access   public
961
+     */
962
+    function register($name,$in=array(),$out=array(),$namespace=false,$soapaction=false,$style=false,$use=false,$documentation='',$encodingStyle=''){
963
+        global $HTTP_SERVER_VARS;
964 964
 
965
-		if($this->externalWSDLURL){
966
-			die('You cannot bind to an external WSDL file, and register methods outside of it! Please choose either WSDL or no WSDL.');
967
-		}
968
-		if (! $name) {
969
-			die('You must specify a name when you register an operation');
970
-		}
971
-		if (!is_array($in)) {
972
-			die('You must provide an array for operation inputs');
973
-		}
974
-		if (!is_array($out)) {
975
-			die('You must provide an array for operation outputs');
976
-		}
977
-		if(false == $namespace) {
978
-		}
979
-		if(false == $soapaction) {
980
-			if (isset($_SERVER)) {
981
-				$SERVER_NAME = $_SERVER['SERVER_NAME'];
982
-				$SCRIPT_NAME = isset($_SERVER['PHP_SELF']) ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME'];
983
-				$HTTPS = isset($_SERVER['HTTPS']) ? $_SERVER['HTTPS'] : (isset($HTTP_SERVER_VARS['HTTPS']) ? $HTTP_SERVER_VARS['HTTPS'] : 'off');
984
-			} elseif (isset($HTTP_SERVER_VARS)) {
985
-				$SERVER_NAME = $HTTP_SERVER_VARS['SERVER_NAME'];
986
-				$SCRIPT_NAME = isset($HTTP_SERVER_VARS['PHP_SELF']) ? $HTTP_SERVER_VARS['PHP_SELF'] : $HTTP_SERVER_VARS['SCRIPT_NAME'];
987
-				$HTTPS = isset($HTTP_SERVER_VARS['HTTPS']) ? $HTTP_SERVER_VARS['HTTPS'] : 'off';
988
-			} else {
989
-				$this->setError("Neither _SERVER nor HTTP_SERVER_VARS is available");
990
-			}
991
-        	if ($HTTPS == '1' || $HTTPS == 'on') {
992
-        		$SCHEME = 'https';
993
-        	} else {
994
-        		$SCHEME = 'http';
995
-        	}
996
-			$soapaction = "$SCHEME://$SERVER_NAME$SCRIPT_NAME/$name";
997
-		}
998
-		if(false == $style) {
999
-			$style = "rpc";
1000
-		}
1001
-		if(false == $use) {
1002
-			$use = "encoded";
1003
-		}
1004
-		if ($use == 'encoded' && $encodingStyle == '') {
1005
-			$encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/';
1006
-		}
965
+        if($this->externalWSDLURL){
966
+            die('You cannot bind to an external WSDL file, and register methods outside of it! Please choose either WSDL or no WSDL.');
967
+        }
968
+        if (! $name) {
969
+            die('You must specify a name when you register an operation');
970
+        }
971
+        if (!is_array($in)) {
972
+            die('You must provide an array for operation inputs');
973
+        }
974
+        if (!is_array($out)) {
975
+            die('You must provide an array for operation outputs');
976
+        }
977
+        if(false == $namespace) {
978
+        }
979
+        if(false == $soapaction) {
980
+            if (isset($_SERVER)) {
981
+                $SERVER_NAME = $_SERVER['SERVER_NAME'];
982
+                $SCRIPT_NAME = isset($_SERVER['PHP_SELF']) ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME'];
983
+                $HTTPS = isset($_SERVER['HTTPS']) ? $_SERVER['HTTPS'] : (isset($HTTP_SERVER_VARS['HTTPS']) ? $HTTP_SERVER_VARS['HTTPS'] : 'off');
984
+            } elseif (isset($HTTP_SERVER_VARS)) {
985
+                $SERVER_NAME = $HTTP_SERVER_VARS['SERVER_NAME'];
986
+                $SCRIPT_NAME = isset($HTTP_SERVER_VARS['PHP_SELF']) ? $HTTP_SERVER_VARS['PHP_SELF'] : $HTTP_SERVER_VARS['SCRIPT_NAME'];
987
+                $HTTPS = isset($HTTP_SERVER_VARS['HTTPS']) ? $HTTP_SERVER_VARS['HTTPS'] : 'off';
988
+            } else {
989
+                $this->setError("Neither _SERVER nor HTTP_SERVER_VARS is available");
990
+            }
991
+            if ($HTTPS == '1' || $HTTPS == 'on') {
992
+                $SCHEME = 'https';
993
+            } else {
994
+                $SCHEME = 'http';
995
+            }
996
+            $soapaction = "$SCHEME://$SERVER_NAME$SCRIPT_NAME/$name";
997
+        }
998
+        if(false == $style) {
999
+            $style = "rpc";
1000
+        }
1001
+        if(false == $use) {
1002
+            $use = "encoded";
1003
+        }
1004
+        if ($use == 'encoded' && $encodingStyle == '') {
1005
+            $encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/';
1006
+        }
1007 1007
 
1008
-		$this->operations[$name] = array(
1009
-	    'name' => $name,
1010
-	    'in' => $in,
1011
-	    'out' => $out,
1012
-	    'namespace' => $namespace,
1013
-	    'soapaction' => $soapaction,
1014
-	    'style' => $style);
1008
+        $this->operations[$name] = array(
1009
+        'name' => $name,
1010
+        'in' => $in,
1011
+        'out' => $out,
1012
+        'namespace' => $namespace,
1013
+        'soapaction' => $soapaction,
1014
+        'style' => $style);
1015 1015
         if($this->wsdl){
1016
-        	$this->wsdl->addOperation($name,$in,$out,$namespace,$soapaction,$style,$use,$documentation,$encodingStyle);
1017
-	    }
1018
-		return true;
1019
-	}
1016
+            $this->wsdl->addOperation($name,$in,$out,$namespace,$soapaction,$style,$use,$documentation,$encodingStyle);
1017
+        }
1018
+        return true;
1019
+    }
1020 1020
 
1021
-	/**
1022
-	* Specify a fault to be returned to the client.
1023
-	* This also acts as a flag to the server that a fault has occured.
1024
-	*
1025
-	* @param	string $faultcode
1026
-	* @param	string $faultstring
1027
-	* @param	string $faultactor
1028
-	* @param	string $faultdetail
1029
-	* @access   public
1030
-	*/
1031
-	function fault($faultcode,$faultstring,$faultactor='',$faultdetail=''){
1032
-		if ($faultdetail == '' && $this->debug_flag) {
1033
-			$faultdetail = $this->getDebug();
1034
-		}
1035
-		$this->fault = new nusoap_fault($faultcode,$faultactor,$faultstring,$faultdetail);
1036
-		$this->fault->soap_defencoding = $this->soap_defencoding;
1037
-	}
1021
+    /**
1022
+     * Specify a fault to be returned to the client.
1023
+     * This also acts as a flag to the server that a fault has occured.
1024
+     *
1025
+     * @param	string $faultcode
1026
+     * @param	string $faultstring
1027
+     * @param	string $faultactor
1028
+     * @param	string $faultdetail
1029
+     * @access   public
1030
+     */
1031
+    function fault($faultcode,$faultstring,$faultactor='',$faultdetail=''){
1032
+        if ($faultdetail == '' && $this->debug_flag) {
1033
+            $faultdetail = $this->getDebug();
1034
+        }
1035
+        $this->fault = new nusoap_fault($faultcode,$faultactor,$faultstring,$faultdetail);
1036
+        $this->fault->soap_defencoding = $this->soap_defencoding;
1037
+    }
1038 1038
 
1039 1039
     /**
1040
-    * Sets up wsdl object.
1041
-    * Acts as a flag to enable internal WSDL generation
1042
-    *
1043
-    * @param string $serviceName, name of the service
1044
-    * @param mixed $namespace optional 'tns' service namespace or false
1045
-    * @param mixed $endpoint optional URL of service endpoint or false
1046
-    * @param string $style optional (rpc|document) WSDL style (also specified by operation)
1047
-    * @param string $transport optional SOAP transport
1048
-    * @param mixed $schemaTargetNamespace optional 'types' targetNamespace for service schema or false
1049
-    */
1040
+     * Sets up wsdl object.
1041
+     * Acts as a flag to enable internal WSDL generation
1042
+     *
1043
+     * @param string $serviceName, name of the service
1044
+     * @param mixed $namespace optional 'tns' service namespace or false
1045
+     * @param mixed $endpoint optional URL of service endpoint or false
1046
+     * @param string $style optional (rpc|document) WSDL style (also specified by operation)
1047
+     * @param string $transport optional SOAP transport
1048
+     * @param mixed $schemaTargetNamespace optional 'types' targetNamespace for service schema or false
1049
+     */
1050 1050
     function configureWSDL($serviceName,$namespace = false,$endpoint = false,$style='rpc', $transport = 'http://schemas.xmlsoap.org/soap/http', $schemaTargetNamespace = false)
1051 1051
     {
1052
-    	global $HTTP_SERVER_VARS;
1052
+        global $HTTP_SERVER_VARS;
1053 1053
 
1054
-		if (isset($_SERVER)) {
1055
-			$SERVER_NAME = $_SERVER['SERVER_NAME'];
1056
-			$SERVER_PORT = $_SERVER['SERVER_PORT'];
1057
-			$SCRIPT_NAME = isset($_SERVER['PHP_SELF']) ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME'];
1058
-			$HTTPS = isset($_SERVER['HTTPS']) ? $_SERVER['HTTPS'] : (isset($HTTP_SERVER_VARS['HTTPS']) ? $HTTP_SERVER_VARS['HTTPS'] : 'off');
1059
-		} elseif (isset($HTTP_SERVER_VARS)) {
1060
-			$SERVER_NAME = $HTTP_SERVER_VARS['SERVER_NAME'];
1061
-			$SERVER_PORT = $HTTP_SERVER_VARS['SERVER_PORT'];
1062
-			$SCRIPT_NAME = isset($HTTP_SERVER_VARS['PHP_SELF']) ? $HTTP_SERVER_VARS['PHP_SELF'] : $HTTP_SERVER_VARS['SCRIPT_NAME'];
1063
-			$HTTPS = isset($HTTP_SERVER_VARS['HTTPS']) ? $HTTP_SERVER_VARS['HTTPS'] : 'off';
1064
-		} else {
1065
-			$this->setError("Neither _SERVER nor HTTP_SERVER_VARS is available");
1066
-		}
1067
-		// If server name has port number attached then strip it (else port number gets duplicated in WSDL output) (occurred using lighttpd and FastCGI)
1068
-		$colon = strpos($SERVER_NAME,":");
1069
-		if ($colon) {
1070
-		    $SERVER_NAME = substr($SERVER_NAME, 0, $colon);
1071
-		}
1072
-		if ($SERVER_PORT == 80) {
1073
-			$SERVER_PORT = '';
1074
-		} else {
1075
-			$SERVER_PORT = ':' . $SERVER_PORT;
1076
-		}
1054
+        if (isset($_SERVER)) {
1055
+            $SERVER_NAME = $_SERVER['SERVER_NAME'];
1056
+            $SERVER_PORT = $_SERVER['SERVER_PORT'];
1057
+            $SCRIPT_NAME = isset($_SERVER['PHP_SELF']) ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME'];
1058
+            $HTTPS = isset($_SERVER['HTTPS']) ? $_SERVER['HTTPS'] : (isset($HTTP_SERVER_VARS['HTTPS']) ? $HTTP_SERVER_VARS['HTTPS'] : 'off');
1059
+        } elseif (isset($HTTP_SERVER_VARS)) {
1060
+            $SERVER_NAME = $HTTP_SERVER_VARS['SERVER_NAME'];
1061
+            $SERVER_PORT = $HTTP_SERVER_VARS['SERVER_PORT'];
1062
+            $SCRIPT_NAME = isset($HTTP_SERVER_VARS['PHP_SELF']) ? $HTTP_SERVER_VARS['PHP_SELF'] : $HTTP_SERVER_VARS['SCRIPT_NAME'];
1063
+            $HTTPS = isset($HTTP_SERVER_VARS['HTTPS']) ? $HTTP_SERVER_VARS['HTTPS'] : 'off';
1064
+        } else {
1065
+            $this->setError("Neither _SERVER nor HTTP_SERVER_VARS is available");
1066
+        }
1067
+        // If server name has port number attached then strip it (else port number gets duplicated in WSDL output) (occurred using lighttpd and FastCGI)
1068
+        $colon = strpos($SERVER_NAME,":");
1069
+        if ($colon) {
1070
+            $SERVER_NAME = substr($SERVER_NAME, 0, $colon);
1071
+        }
1072
+        if ($SERVER_PORT == 80) {
1073
+            $SERVER_PORT = '';
1074
+        } else {
1075
+            $SERVER_PORT = ':' . $SERVER_PORT;
1076
+        }
1077 1077
         if(false == $namespace) {
1078 1078
             $namespace = "http://$SERVER_NAME/soap/$serviceName";
1079 1079
         }
1080 1080
 
1081 1081
         if(false == $endpoint) {
1082
-        	if ($HTTPS == '1' || $HTTPS == 'on') {
1083
-        		$SCHEME = 'https';
1084
-        	} else {
1085
-        		$SCHEME = 'http';
1086
-        	}
1082
+            if ($HTTPS == '1' || $HTTPS == 'on') {
1083
+                $SCHEME = 'https';
1084
+            } else {
1085
+                $SCHEME = 'http';
1086
+            }
1087 1087
             $endpoint = "$SCHEME://$SERVER_NAME$SERVER_PORT$SCRIPT_NAME";
1088 1088
         }
1089 1089
 
@@ -1091,29 +1091,29 @@  discard block
 block discarded – undo
1091 1091
             $schemaTargetNamespace = $namespace;
1092 1092
         }
1093 1093
 
1094
-		$this->wsdl = new wsdl;
1095
-		$this->wsdl->serviceName = $serviceName;
1094
+        $this->wsdl = new wsdl;
1095
+        $this->wsdl->serviceName = $serviceName;
1096 1096
         $this->wsdl->endpoint = $endpoint;
1097
-		$this->wsdl->namespaces['tns'] = $namespace;
1098
-		$this->wsdl->namespaces['soap'] = 'http://schemas.xmlsoap.org/wsdl/soap/';
1099
-		$this->wsdl->namespaces['wsdl'] = 'http://schemas.xmlsoap.org/wsdl/';
1100
-		if ($schemaTargetNamespace != $namespace) {
1101
-			$this->wsdl->namespaces['types'] = $schemaTargetNamespace;
1102
-		}
1097
+        $this->wsdl->namespaces['tns'] = $namespace;
1098
+        $this->wsdl->namespaces['soap'] = 'http://schemas.xmlsoap.org/wsdl/soap/';
1099
+        $this->wsdl->namespaces['wsdl'] = 'http://schemas.xmlsoap.org/wsdl/';
1100
+        if ($schemaTargetNamespace != $namespace) {
1101
+            $this->wsdl->namespaces['types'] = $schemaTargetNamespace;
1102
+        }
1103 1103
         $this->wsdl->schemas[$schemaTargetNamespace][0] = new nusoap_xmlschema('', '', $this->wsdl->namespaces);
1104 1104
         if ($style == 'document') {
1105
-	        $this->wsdl->schemas[$schemaTargetNamespace][0]->schemaInfo['elementFormDefault'] = 'qualified';
1105
+            $this->wsdl->schemas[$schemaTargetNamespace][0]->schemaInfo['elementFormDefault'] = 'qualified';
1106 1106
         }
1107 1107
         $this->wsdl->schemas[$schemaTargetNamespace][0]->schemaTargetNamespace = $schemaTargetNamespace;
1108 1108
         $this->wsdl->schemas[$schemaTargetNamespace][0]->imports['http://schemas.xmlsoap.org/soap/encoding/'][0] = array('location' => '', 'loaded' => true);
1109 1109
         $this->wsdl->schemas[$schemaTargetNamespace][0]->imports['http://schemas.xmlsoap.org/wsdl/'][0] = array('location' => '', 'loaded' => true);
1110 1110
         $this->wsdl->bindings[$serviceName.'Binding'] = array(
1111
-        	'name'=>$serviceName.'Binding',
1111
+            'name'=>$serviceName.'Binding',
1112 1112
             'style'=>$style,
1113 1113
             'transport'=>$transport,
1114 1114
             'portType'=>$serviceName.'PortType');
1115 1115
         $this->wsdl->ports[$serviceName.'Port'] = array(
1116
-        	'binding'=>$serviceName.'Binding',
1116
+            'binding'=>$serviceName.'Binding',
1117 1117
             'location'=>$endpoint,
1118 1118
             'bindingType'=>'http://schemas.xmlsoap.org/wsdl/soap/');
1119 1119
     }
Please login to merge, or discard this patch.
Spacing   +85 added lines, -85 removed lines patch added patch discarded remove patch
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
     * @param mixed $wsdl file path or URL (string), or wsdl instance (object)
171 171
 	* @access   public
172 172
 	*/
173
-	function nusoap_server($wsdl=false){
173
+	function nusoap_server($wsdl = false) {
174 174
 		parent::nusoap_base();
175 175
 		// turn on debugging?
176 176
 		global $debug;
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
 			$qs = explode('&', $_SERVER['QUERY_STRING']);
194 194
 			foreach ($qs as $v) {
195 195
 				if (substr($v, 0, 6) == 'debug=') {
196
-					$this->debug("In nusoap_server, set debug_flag=" . substr($v, 6) . " based on query string #1");
196
+					$this->debug("In nusoap_server, set debug_flag=".substr($v, 6)." based on query string #1");
197 197
 					$this->debug_flag = substr($v, 6);
198 198
 				}
199 199
 			}
@@ -201,27 +201,27 @@  discard block
 block discarded – undo
201 201
 			$qs = explode('&', $HTTP_SERVER_VARS['QUERY_STRING']);
202 202
 			foreach ($qs as $v) {
203 203
 				if (substr($v, 0, 6) == 'debug=') {
204
-					$this->debug("In nusoap_server, set debug_flag=" . substr($v, 6) . " based on query string #2");
204
+					$this->debug("In nusoap_server, set debug_flag=".substr($v, 6)." based on query string #2");
205 205
 					$this->debug_flag = substr($v, 6);
206 206
 				}
207 207
 			}
208 208
 		}
209 209
 
210 210
 		// wsdl
211
-		if($wsdl){
211
+		if ($wsdl) {
212 212
 			$this->debug("In nusoap_server, WSDL is specified");
213 213
 			if (is_object($wsdl) && (get_class($wsdl) == 'wsdl')) {
214 214
 				$this->wsdl = $wsdl;
215 215
 				$this->externalWSDLURL = $this->wsdl->wsdl;
216
-				$this->debug('Use existing wsdl instance from ' . $this->externalWSDLURL);
216
+				$this->debug('Use existing wsdl instance from '.$this->externalWSDLURL);
217 217
 			} else {
218
-				$this->debug('Create wsdl from ' . $wsdl);
218
+				$this->debug('Create wsdl from '.$wsdl);
219 219
 				$this->wsdl = new wsdl($wsdl);
220 220
 				$this->externalWSDLURL = $wsdl;
221 221
 			}
222 222
 			$this->appendDebug($this->wsdl->getDebug());
223 223
 			$this->wsdl->clearDebug();
224
-			if($err = $this->wsdl->getError()){
224
+			if ($err = $this->wsdl->getError()) {
225 225
 				die('WSDL ERROR: '.$err);
226 226
 			}
227 227
 		}
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
 	* @param    string $data usually is the value of $HTTP_RAW_POST_DATA
234 234
 	* @access   public
235 235
 	*/
236
-	function service($data){
236
+	function service($data) {
237 237
 		global $HTTP_SERVER_VARS;
238 238
 
239 239
 		if (isset($_SERVER['REQUEST_METHOD'])) {
@@ -251,21 +251,21 @@  discard block
 block discarded – undo
251 251
 		} else {
252 252
 			$qs = '';
253 253
 		}
254
-		$this->debug("In service, request method=$rm query string=$qs strlen(\$data)=" . strlen($data));
254
+		$this->debug("In service, request method=$rm query string=$qs strlen(\$data)=".strlen($data));
255 255
 
256 256
 		if ($rm == 'POST') {
257 257
 			$this->debug("In service, invoke the request");
258 258
 			$this->parse_request($data);
259
-			if (! $this->fault) {
259
+			if (!$this->fault) {
260 260
 				$this->invoke_method();
261 261
 			}
262
-			if (! $this->fault) {
262
+			if (!$this->fault) {
263 263
 				$this->serialize_return();
264 264
 			}
265 265
 			$this->send_response();
266
-		} elseif (preg_match('/wsdl/', $qs) ){
266
+		} elseif (preg_match('/wsdl/', $qs)) {
267 267
 			$this->debug("In service, this is a request for WSDL");
268
-			if ($this->externalWSDLURL){
268
+			if ($this->externalWSDLURL) {
269 269
               if (strpos($this->externalWSDLURL, "http://") !== false) { // assume URL
270 270
 				$this->debug("In service, re-direct for WSDL");
271 271
 				header('Location: '.$this->externalWSDLURL);
@@ -322,23 +322,23 @@  discard block
 block discarded – undo
322 322
 
323 323
 		$this->request = '';
324 324
 		$this->SOAPAction = '';
325
-		if(function_exists('getallheaders')){
325
+		if (function_exists('getallheaders')) {
326 326
 			$this->debug("In parse_http_headers, use getallheaders");
327 327
 			$headers = getallheaders();
328
-			foreach($headers as $k=>$v){
328
+			foreach ($headers as $k=>$v) {
329 329
 				$k = strtolower($k);
330 330
 				$this->headers[$k] = $v;
331 331
 				$this->request .= "$k: $v\r\n";
332 332
 				$this->debug("$k: $v");
333 333
 			}
334 334
 			// get SOAPAction header
335
-			if(isset($this->headers['soapaction'])){
336
-				$this->SOAPAction = str_replace('"','',$this->headers['soapaction']);
335
+			if (isset($this->headers['soapaction'])) {
336
+				$this->SOAPAction = str_replace('"', '', $this->headers['soapaction']);
337 337
 			}
338 338
 			// get the character encoding of the incoming request
339
-			if(isset($this->headers['content-type']) && strpos($this->headers['content-type'],'=')){
340
-				$enc = str_replace('"','',substr(strstr($this->headers["content-type"],'='),1));
341
-				if(preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)){
339
+			if (isset($this->headers['content-type']) && strpos($this->headers['content-type'], '=')) {
340
+				$enc = str_replace('"', '', substr(strstr($this->headers["content-type"], '='), 1));
341
+				if (preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i', $enc)) {
342 342
 					$this->xml_encoding = strtoupper($enc);
343 343
 				} else {
344 344
 					$this->xml_encoding = 'US-ASCII';
@@ -347,7 +347,7 @@  discard block
 block discarded – undo
347 347
 				// should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1
348 348
 				$this->xml_encoding = 'ISO-8859-1';
349 349
 			}
350
-		} elseif(isset($_SERVER) && is_array($_SERVER)){
350
+		} elseif (isset($_SERVER) && is_array($_SERVER)) {
351 351
 			$this->debug("In parse_http_headers, use _SERVER");
352 352
 			foreach ($_SERVER as $k => $v) {
353 353
 				if (substr($k, 0, 5) == 'HTTP_') {
@@ -367,7 +367,7 @@  discard block
 block discarded – undo
367 367
 						$enc = substr(strstr($v, '='), 1);
368 368
 						$enc = str_replace('"', '', $enc);
369 369
 						$enc = str_replace('\\', '', $enc);
370
-						if (preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)) {
370
+						if (preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i', $enc)) {
371 371
 							$this->xml_encoding = strtoupper($enc);
372 372
 						} else {
373 373
 							$this->xml_encoding = 'US-ASCII';
@@ -385,9 +385,9 @@  discard block
 block discarded – undo
385 385
 			$this->debug("In parse_http_headers, use HTTP_SERVER_VARS");
386 386
 			foreach ($HTTP_SERVER_VARS as $k => $v) {
387 387
 				if (substr($k, 0, 5) == 'HTTP_') {
388
-					$k = str_replace(' ', '-', strtolower(str_replace('_', ' ', substr($k, 5)))); 	                                         $k = strtolower(substr($k, 5));
388
+					$k = str_replace(' ', '-', strtolower(str_replace('_', ' ', substr($k, 5)))); $k = strtolower(substr($k, 5));
389 389
 				} else {
390
-					$k = str_replace(' ', '-', strtolower(str_replace('_', ' ', $k))); 	                                         $k = strtolower($k);
390
+					$k = str_replace(' ', '-', strtolower(str_replace('_', ' ', $k))); $k = strtolower($k);
391 391
 				}
392 392
 				if ($k == 'soapaction') {
393 393
 					// get SOAPAction header
@@ -401,7 +401,7 @@  discard block
 block discarded – undo
401 401
 						$enc = substr(strstr($v, '='), 1);
402 402
 						$enc = str_replace('"', '', $enc);
403 403
 						$enc = str_replace('\\', '', $enc);
404
-						if (preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)) {
404
+						if (preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i', $enc)) {
405 405
 							$this->xml_encoding = strtoupper($enc);
406 406
 						} else {
407 407
 							$this->xml_encoding = 'US-ASCII';
@@ -443,13 +443,13 @@  discard block
 block discarded – undo
443 443
 	* @param    string $data XML string
444 444
 	* @access   private
445 445
 	*/
446
-	function parse_request($data='') {
446
+	function parse_request($data = '') {
447 447
 		$this->debug('entering parse_request()');
448 448
 		$this->parse_http_headers();
449 449
 		$this->debug('got character encoding: '.$this->xml_encoding);
450 450
 		// uncompress if necessary
451 451
 		if (isset($this->headers['content-encoding']) && $this->headers['content-encoding'] != '') {
452
-			$this->debug('got content encoding: ' . $this->headers['content-encoding']);
452
+			$this->debug('got content encoding: '.$this->headers['content-encoding']);
453 453
 			if ($this->headers['content-encoding'] == 'deflate' || $this->headers['content-encoding'] == 'gzip') {
454 454
 		    	// if decoding works, use it. else assume data wasn't gzencoded
455 455
 				if (function_exists('gzuncompress')) {
@@ -491,7 +491,7 @@  discard block
 block discarded – undo
491 491
 	* @access   private
492 492
 	*/
493 493
 	function invoke_method() {
494
-		$this->debug('in invoke_method, methodname=' . $this->methodname . ' methodURI=' . $this->methodURI . ' SOAPAction=' . $this->SOAPAction);
494
+		$this->debug('in invoke_method, methodname='.$this->methodname.' methodURI='.$this->methodURI.' SOAPAction='.$this->SOAPAction);
495 495
 
496 496
 		//
497 497
 		// if you are debugging in this area of the code, your service uses a class to implement methods,
@@ -506,16 +506,16 @@  discard block
 block discarded – undo
506 506
 		$orig_methodname = $this->methodname;
507 507
 		if ($this->wsdl) {
508 508
 			if ($this->opData = $this->wsdl->getOperationData($this->methodname)) {
509
-				$this->debug('in invoke_method, found WSDL operation=' . $this->methodname);
510
-				$this->appendDebug('opData=' . $this->varDump($this->opData));
509
+				$this->debug('in invoke_method, found WSDL operation='.$this->methodname);
510
+				$this->appendDebug('opData='.$this->varDump($this->opData));
511 511
 			} elseif ($this->opData = $this->wsdl->getOperationDataForSoapAction($this->SOAPAction)) {
512 512
 				// Note: hopefully this case will only be used for doc/lit, since rpc services should have wrapper element
513
-				$this->debug('in invoke_method, found WSDL soapAction=' . $this->SOAPAction . ' for operation=' . $this->opData['name']);
514
-				$this->appendDebug('opData=' . $this->varDump($this->opData));
513
+				$this->debug('in invoke_method, found WSDL soapAction='.$this->SOAPAction.' for operation='.$this->opData['name']);
514
+				$this->appendDebug('opData='.$this->varDump($this->opData));
515 515
 				$this->methodname = $this->opData['name'];
516 516
 			} else {
517
-				$this->debug('in invoke_method, no WSDL for operation=' . $this->methodname);
518
-				$this->fault('SOAP-ENV:Client', "Operation '" . $this->methodname . "' is not defined in the WSDL for this service");
517
+				$this->debug('in invoke_method, no WSDL for operation='.$this->methodname);
518
+				$this->fault('SOAP-ENV:Client', "Operation '".$this->methodname."' is not defined in the WSDL for this service");
519 519
 				return;
520 520
 			}
521 521
 		} else {
@@ -556,7 +556,7 @@  discard block
 block discarded – undo
556 556
 			if (!function_exists($this->methodname)) {
557 557
 				$this->debug("in invoke_method, function '$this->methodname' not found!");
558 558
 				$this->result = 'fault: method not found';
559
-				$this->fault('SOAP-ENV:Client',"method '$this->methodname'('$orig_methodname') not defined in service('$try_class' '$delim')");
559
+				$this->fault('SOAP-ENV:Client', "method '$this->methodname'('$orig_methodname') not defined in service('$try_class' '$delim')");
560 560
 				return;
561 561
 			}
562 562
 		} else {
@@ -564,19 +564,19 @@  discard block
 block discarded – undo
564 564
 			if (!in_array($method_to_compare, get_class_methods($class))) {
565 565
 				$this->debug("in invoke_method, method '$this->methodname' not found in class '$class'!");
566 566
 				$this->result = 'fault: method not found';
567
-				$this->fault('SOAP-ENV:Client',"method '$this->methodname'/'$method_to_compare'('$orig_methodname') not defined in service/'$class'('$try_class' '$delim')");
567
+				$this->fault('SOAP-ENV:Client', "method '$this->methodname'/'$method_to_compare'('$orig_methodname') not defined in service/'$class'('$try_class' '$delim')");
568 568
 				return;
569 569
 			}
570 570
 		}
571 571
 
572 572
 		// evaluate message, getting back parameters
573 573
 		// verify that request parameters match the method's signature
574
-		if(! $this->verify_method($this->methodname,$this->methodparams)){
574
+		if (!$this->verify_method($this->methodname, $this->methodparams)) {
575 575
 			// debug
576 576
 			$this->debug('ERROR: request not verified against method signature');
577 577
 			$this->result = 'fault: request failed validation against method signature';
578 578
 			// return fault
579
-			$this->fault('SOAP-ENV:Client',"Operation '$this->methodname' not defined in service.");
579
+			$this->fault('SOAP-ENV:Client', "Operation '$this->methodname' not defined in service.");
580 580
 			return;
581 581
 		}
582 582
 
@@ -616,13 +616,13 @@  discard block
 block discarded – undo
616 616
 		} else {
617 617
 			if ($class == '') {
618 618
 				$this->debug('in invoke_method, calling function using call_user_func_array()');
619
-				$call_arg = "$this->methodname";	// straight assignment changes $this->methodname to lower case after call_user_func_array()
619
+				$call_arg = "$this->methodname"; // straight assignment changes $this->methodname to lower case after call_user_func_array()
620 620
 			} elseif ($delim == '..') {
621 621
 				$this->debug('in invoke_method, calling class method using call_user_func_array()');
622
-				$call_arg = array ($class, $method);
622
+				$call_arg = array($class, $method);
623 623
 			} else {
624 624
 				$this->debug('in invoke_method, calling instance method using call_user_func_array()');
625
-				$instance = new $class ();
625
+				$instance = new $class();
626 626
 				$call_arg = array(&$instance, $method);
627 627
 			}
628 628
 			if (is_array($this->methodparams)) {
@@ -648,7 +648,7 @@  discard block
 block discarded – undo
648 648
 	* @access   private
649 649
 	*/
650 650
 	function serialize_return() {
651
-		$this->debug('Entering serialize_return methodname: ' . $this->methodname . ' methodURI: ' . $this->methodURI);
651
+		$this->debug('Entering serialize_return methodname: '.$this->methodname.' methodURI: '.$this->methodURI);
652 652
 		// if fault
653 653
 		if (isset($this->methodreturn) && is_object($this->methodreturn) && ((get_class($this->methodreturn) == 'soap_fault') || (get_class($this->methodreturn) == 'nusoap_fault'))) {
654 654
 			$this->debug('got a fault object from method');
@@ -660,7 +660,7 @@  discard block
 block discarded – undo
660 660
 		} else {
661 661
 			$this->debug('got a(n) '.gettype($this->methodreturn).' from method');
662 662
 			$this->debug('serializing return value');
663
-			if($this->wsdl){
663
+			if ($this->wsdl) {
664 664
 				$opParams = "";
665 665
 				if (sizeof($this->opData['output']['parts']) > 1) {
666 666
 					$this->debug('more than one output part, so use the method return unchanged');
@@ -673,10 +673,10 @@  discard block
 block discarded – undo
673 673
 			    	//}
674 674
 			    	$opParams = array($this->methodreturn);
675 675
 			    }
676
-			    $return_val = $this->wsdl->serializeRPCParameters($this->methodname,'output',$opParams);
676
+			    $return_val = $this->wsdl->serializeRPCParameters($this->methodname, 'output', $opParams);
677 677
 			    $this->appendDebug($this->wsdl->getDebug());
678 678
 			    $this->wsdl->clearDebug();
679
-				if($errstr = $this->wsdl->getError()){
679
+				if ($errstr = $this->wsdl->getError()) {
680 680
 					$this->debug('got wsdl error: '.$errstr);
681 681
 					$this->fault('SOAP-ENV:Server', 'unable to serialize result');
682 682
 					return;
@@ -695,9 +695,9 @@  discard block
 block discarded – undo
695 695
 
696 696
 		$this->debug('serializing response');
697 697
 		if ($this->wsdl) {
698
-			$this->debug('have WSDL for serialization: style is ' . $this->opData['style']);
698
+			$this->debug('have WSDL for serialization: style is '.$this->opData['style']);
699 699
 			if ($this->opData['style'] == 'rpc') {
700
-				$this->debug('style is rpc for serialization: use is ' . $this->opData['output']['use']);
700
+				$this->debug('style is rpc for serialization: use is '.$this->opData['output']['use']);
701 701
 				if ($this->opData['output']['use'] == 'literal') {
702 702
 					// http://www.ws-i.org/Profiles/BasicProfile-1.1-2004-08-24.html R2735 says rpc/literal accessor elements should not be in a namespace
703 703
 					if ($this->methodURI) {
@@ -721,7 +721,7 @@  discard block
 block discarded – undo
721 721
 			$payload = '<ns1:'.$this->methodname.'Response xmlns:ns1="'.$this->methodURI.'">'.$return_val.'</ns1:'.$this->methodname."Response>";
722 722
 		}
723 723
 		$this->result = 'successful';
724
-		if($this->wsdl){
724
+		if ($this->wsdl) {
725 725
 			//if($this->debug_flag){
726 726
             	$this->appendDebug($this->wsdl->getDebug());
727 727
             //	}
@@ -731,9 +731,9 @@  discard block
 block discarded – undo
731 731
 				$encodingStyle = '';
732 732
 			}
733 733
 			// Added: In case we use a WSDL, return a serialized env. WITH the usedNamespaces.
734
-			$this->responseSOAP = $this->serializeEnvelope($payload,$this->responseHeaders,$this->wsdl->usedNamespaces,$this->opData['style'],$this->opData['output']['use'],$encodingStyle);
734
+			$this->responseSOAP = $this->serializeEnvelope($payload, $this->responseHeaders, $this->wsdl->usedNamespaces, $this->opData['style'], $this->opData['output']['use'], $encodingStyle);
735 735
 		} else {
736
-			$this->responseSOAP = $this->serializeEnvelope($payload,$this->responseHeaders);
736
+			$this->responseSOAP = $this->serializeEnvelope($payload, $this->responseHeaders);
737 737
 		}
738 738
 		$this->debug("Leaving serialize_return");
739 739
 	}
@@ -763,18 +763,18 @@  discard block
 block discarded – undo
763 763
 			// $this->outgoing_headers[] = "Status: 200 OK";
764 764
 		}
765 765
         // add debug data if in debug mode
766
-		if(isset($this->debug_flag) && $this->debug_flag){
766
+		if (isset($this->debug_flag) && $this->debug_flag) {
767 767
         	$payload .= $this->getDebugAsXMLComment();
768 768
         }
769 769
 		$this->outgoing_headers[] = "Server: $this->title Server v$this->version";
770
-		preg_match('/\$Revisio' . 'n: ([^ ]+)/', $this->revision, $rev);
770
+		preg_match('/\$Revisio'.'n: ([^ ]+)/', $this->revision, $rev);
771 771
 		$this->outgoing_headers[] = "X-SOAP-Server: $this->title/$this->version (".$rev[1].")";
772 772
 		// Let the Web server decide about this
773 773
 		//$this->outgoing_headers[] = "Connection: Close\r\n";
774 774
 		$payload = $this->getHTTPBody($payload);
775 775
 		$type = $this->getHTTPContentType();
776 776
 		$charset = $this->getHTTPContentTypeCharset();
777
-		$this->outgoing_headers[] = "Content-Type: $type" . ($charset ? '; charset=' . $charset : '');
777
+		$this->outgoing_headers[] = "Content-Type: $type".($charset ? '; charset='.$charset : '');
778 778
 		//begin code to compress payload - by John
779 779
 		// NOTE: there is no way to know whether the Web server will also compress
780 780
 		// this data.
@@ -811,11 +811,11 @@  discard block
 block discarded – undo
811 811
 		//end code
812 812
 		$this->outgoing_headers[] = "Content-Length: ".strlen($payload);
813 813
 		reset($this->outgoing_headers);
814
-		foreach($this->outgoing_headers as $hdr){
814
+		foreach ($this->outgoing_headers as $hdr) {
815 815
 			header($hdr, false);
816 816
 		}
817 817
 		print $payload;
818
-		$this->response = join("\r\n",$this->outgoing_headers)."\r\n\r\n".$payload;
818
+		$this->response = join("\r\n", $this->outgoing_headers)."\r\n\r\n".$payload;
819 819
 	}
820 820
 
821 821
 	/**
@@ -827,12 +827,12 @@  discard block
 block discarded – undo
827 827
 	* @return	boolean	Whether the operation was found
828 828
 	* @access   private
829 829
 	*/
830
-	function verify_method($operation,$request){
831
-		if(isset($this->wsdl) && is_object($this->wsdl)){
832
-			if($this->wsdl->getOperationData($operation)){
830
+	function verify_method($operation, $request) {
831
+		if (isset($this->wsdl) && is_object($this->wsdl)) {
832
+			if ($this->wsdl->getOperationData($operation)) {
833 833
 				return true;
834 834
 			}
835
-	    } elseif(isset($this->operations[$operation])){
835
+	    } elseif (isset($this->operations[$operation])) {
836 836
 			return true;
837 837
 		}
838 838
 		return false;
@@ -847,7 +847,7 @@  discard block
 block discarded – undo
847 847
 	* @access   private
848 848
 	*/
849 849
     function parseRequest($headers, $data) {
850
-		$this->debug('Entering parseRequest() for data of length ' . strlen($data) . ' headers:');
850
+		$this->debug('Entering parseRequest() for data of length '.strlen($data).' headers:');
851 851
 		$this->appendDebug($this->varDump($headers));
852 852
     	if (!isset($headers['content-type'])) {
853 853
 			$this->setError('Request not of type text/xml (no content-type header)');
@@ -859,8 +859,8 @@  discard block
 block discarded – undo
859 859
 		}
860 860
 		if (strpos($headers['content-type'], '=')) {
861 861
 			$enc = str_replace('"', '', substr(strstr($headers["content-type"], '='), 1));
862
-			$this->debug('Got response encoding: ' . $enc);
863
-			if(preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)){
862
+			$this->debug('Got response encoding: '.$enc);
863
+			if (preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i', $enc)) {
864 864
 				$this->xml_encoding = strtoupper($enc);
865 865
 			} else {
866 866
 				$this->xml_encoding = 'US-ASCII';
@@ -869,16 +869,16 @@  discard block
 block discarded – undo
869 869
 			// should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1
870 870
 			$this->xml_encoding = 'ISO-8859-1';
871 871
 		}
872
-		$this->debug('Use encoding: ' . $this->xml_encoding . ' when creating nusoap_parser');
872
+		$this->debug('Use encoding: '.$this->xml_encoding.' when creating nusoap_parser');
873 873
 		// parse response, get soap parser obj
874
-		$parser = new nusoap_parser($data,$this->xml_encoding,'',$this->decode_utf8);
874
+		$parser = new nusoap_parser($data, $this->xml_encoding, '', $this->decode_utf8);
875 875
 
876 876
 		// parser debug
877 877
 		$this->debug("parser debug: \n".$parser->getDebug());
878 878
 		// if fault occurred during message parsing
879
-		if($err = $parser->getError()){
879
+		if ($err = $parser->getError()) {
880 880
 			$this->result = 'fault: error in msg parsing: '.$err;
881
-			$this->fault('SOAP-ENV:Client',"error in msg parsing:\n".$err);
881
+			$this->fault('SOAP-ENV:Client', "error in msg parsing:\n".$err);
882 882
 		// else successfully parsed request into soapval object
883 883
 		} else {
884 884
 			// get/set methodname
@@ -941,8 +941,8 @@  discard block
 block discarded – undo
941 941
 	* @access   public
942 942
 	* @deprecated
943 943
 	*/
944
-	function add_to_map($methodname,$in,$out){
945
-			$this->operations[$methodname] = array('name' => $methodname,'in' => $in,'out' => $out);
944
+	function add_to_map($methodname, $in, $out) {
945
+			$this->operations[$methodname] = array('name' => $methodname, 'in' => $in, 'out' => $out);
946 946
 	}
947 947
 
948 948
 	/**
@@ -959,13 +959,13 @@  discard block
 block discarded – undo
959 959
 	* @param	string $encodingStyle optional (usually 'http://schemas.xmlsoap.org/soap/encoding/' for encoded)
960 960
 	* @access   public
961 961
 	*/
962
-	function register($name,$in=array(),$out=array(),$namespace=false,$soapaction=false,$style=false,$use=false,$documentation='',$encodingStyle=''){
962
+	function register($name, $in = array(), $out = array(), $namespace = false, $soapaction = false, $style = false, $use = false, $documentation = '', $encodingStyle = '') {
963 963
 		global $HTTP_SERVER_VARS;
964 964
 
965
-		if($this->externalWSDLURL){
965
+		if ($this->externalWSDLURL) {
966 966
 			die('You cannot bind to an external WSDL file, and register methods outside of it! Please choose either WSDL or no WSDL.');
967 967
 		}
968
-		if (! $name) {
968
+		if (!$name) {
969 969
 			die('You must specify a name when you register an operation');
970 970
 		}
971 971
 		if (!is_array($in)) {
@@ -974,9 +974,9 @@  discard block
 block discarded – undo
974 974
 		if (!is_array($out)) {
975 975
 			die('You must provide an array for operation outputs');
976 976
 		}
977
-		if(false == $namespace) {
977
+		if (false == $namespace) {
978 978
 		}
979
-		if(false == $soapaction) {
979
+		if (false == $soapaction) {
980 980
 			if (isset($_SERVER)) {
981 981
 				$SERVER_NAME = $_SERVER['SERVER_NAME'];
982 982
 				$SCRIPT_NAME = isset($_SERVER['PHP_SELF']) ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME'];
@@ -995,10 +995,10 @@  discard block
 block discarded – undo
995 995
         	}
996 996
 			$soapaction = "$SCHEME://$SERVER_NAME$SCRIPT_NAME/$name";
997 997
 		}
998
-		if(false == $style) {
998
+		if (false == $style) {
999 999
 			$style = "rpc";
1000 1000
 		}
1001
-		if(false == $use) {
1001
+		if (false == $use) {
1002 1002
 			$use = "encoded";
1003 1003
 		}
1004 1004
 		if ($use == 'encoded' && $encodingStyle == '') {
@@ -1012,8 +1012,8 @@  discard block
 block discarded – undo
1012 1012
 	    'namespace' => $namespace,
1013 1013
 	    'soapaction' => $soapaction,
1014 1014
 	    'style' => $style);
1015
-        if($this->wsdl){
1016
-        	$this->wsdl->addOperation($name,$in,$out,$namespace,$soapaction,$style,$use,$documentation,$encodingStyle);
1015
+        if ($this->wsdl) {
1016
+        	$this->wsdl->addOperation($name, $in, $out, $namespace, $soapaction, $style, $use, $documentation, $encodingStyle);
1017 1017
 	    }
1018 1018
 		return true;
1019 1019
 	}
@@ -1028,11 +1028,11 @@  discard block
 block discarded – undo
1028 1028
 	* @param	string $faultdetail
1029 1029
 	* @access   public
1030 1030
 	*/
1031
-	function fault($faultcode,$faultstring,$faultactor='',$faultdetail=''){
1031
+	function fault($faultcode, $faultstring, $faultactor = '', $faultdetail = '') {
1032 1032
 		if ($faultdetail == '' && $this->debug_flag) {
1033 1033
 			$faultdetail = $this->getDebug();
1034 1034
 		}
1035
-		$this->fault = new nusoap_fault($faultcode,$faultactor,$faultstring,$faultdetail);
1035
+		$this->fault = new nusoap_fault($faultcode, $faultactor, $faultstring, $faultdetail);
1036 1036
 		$this->fault->soap_defencoding = $this->soap_defencoding;
1037 1037
 	}
1038 1038
 
@@ -1047,7 +1047,7 @@  discard block
 block discarded – undo
1047 1047
     * @param string $transport optional SOAP transport
1048 1048
     * @param mixed $schemaTargetNamespace optional 'types' targetNamespace for service schema or false
1049 1049
     */
1050
-    function configureWSDL($serviceName,$namespace = false,$endpoint = false,$style='rpc', $transport = 'http://schemas.xmlsoap.org/soap/http', $schemaTargetNamespace = false)
1050
+    function configureWSDL($serviceName, $namespace = false, $endpoint = false, $style = 'rpc', $transport = 'http://schemas.xmlsoap.org/soap/http', $schemaTargetNamespace = false)
1051 1051
     {
1052 1052
     	global $HTTP_SERVER_VARS;
1053 1053
 
@@ -1065,20 +1065,20 @@  discard block
 block discarded – undo
1065 1065
 			$this->setError("Neither _SERVER nor HTTP_SERVER_VARS is available");
1066 1066
 		}
1067 1067
 		// If server name has port number attached then strip it (else port number gets duplicated in WSDL output) (occurred using lighttpd and FastCGI)
1068
-		$colon = strpos($SERVER_NAME,":");
1068
+		$colon = strpos($SERVER_NAME, ":");
1069 1069
 		if ($colon) {
1070 1070
 		    $SERVER_NAME = substr($SERVER_NAME, 0, $colon);
1071 1071
 		}
1072 1072
 		if ($SERVER_PORT == 80) {
1073 1073
 			$SERVER_PORT = '';
1074 1074
 		} else {
1075
-			$SERVER_PORT = ':' . $SERVER_PORT;
1075
+			$SERVER_PORT = ':'.$SERVER_PORT;
1076 1076
 		}
1077
-        if(false == $namespace) {
1077
+        if (false == $namespace) {
1078 1078
             $namespace = "http://$SERVER_NAME/soap/$serviceName";
1079 1079
         }
1080 1080
 
1081
-        if(false == $endpoint) {
1081
+        if (false == $endpoint) {
1082 1082
         	if ($HTTPS == '1' || $HTTPS == 'on') {
1083 1083
         		$SCHEME = 'https';
1084 1084
         	} else {
@@ -1087,7 +1087,7 @@  discard block
 block discarded – undo
1087 1087
             $endpoint = "$SCHEME://$SERVER_NAME$SERVER_PORT$SCRIPT_NAME";
1088 1088
         }
1089 1089
 
1090
-        if(false == $schemaTargetNamespace) {
1090
+        if (false == $schemaTargetNamespace) {
1091 1091
             $schemaTargetNamespace = $namespace;
1092 1092
         }
1093 1093
 
Please login to merge, or discard this patch.