@@ -137,7 +137,7 @@ |
||
| 137 | 137 | /** |
| 138 | 138 | * Get a list of users of which the given conditions match with a LIKE '%cond%' |
| 139 | 139 | * @param array $conditions a list of condition (exemple : status=>STUDENT) |
| 140 | - * @param array $order_by a list of fields on which sort |
|
| 140 | + * @param string[] $order_by a list of fields on which sort |
|
| 141 | 141 | * @return array An array with all users of the platform. |
| 142 | 142 | * @todo optional course code parameter, optional sorting parameters... |
| 143 | 143 | *@todo Use the UserManager class |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | { |
| 96 | 96 | global $charset; |
| 97 | 97 | if ($this->verifyUserPass($username, $password) == "valid") { |
| 98 | - $user_id = UserManager::get_user_id_from_username($username); |
|
| 98 | + $user_id = UserManager::get_user_id_from_username($username); |
|
| 99 | 99 | $message_title = get_lang('Invitation'); |
| 100 | 100 | $count_is_true = SocialManager::send_invitation_friend($user_id,$userfriend_id, $message_title, $content_message); |
| 101 | 101 | |
@@ -135,14 +135,14 @@ discard block |
||
| 135 | 135 | |
| 136 | 136 | |
| 137 | 137 | /** |
| 138 | - * Get a list of users of which the given conditions match with a LIKE '%cond%' |
|
| 139 | - * @param array $conditions a list of condition (exemple : status=>STUDENT) |
|
| 140 | - * @param array $order_by a list of fields on which sort |
|
| 141 | - * @return array An array with all users of the platform. |
|
| 142 | - * @todo optional course code parameter, optional sorting parameters... |
|
| 138 | + * Get a list of users of which the given conditions match with a LIKE '%cond%' |
|
| 139 | + * @param array $conditions a list of condition (exemple : status=>STUDENT) |
|
| 140 | + * @param array $order_by a list of fields on which sort |
|
| 141 | + * @return array An array with all users of the platform. |
|
| 142 | + * @todo optional course code parameter, optional sorting parameters... |
|
| 143 | 143 | *@todo Use the UserManager class |
| 144 | 144 | * @todo security filter order by |
| 145 | - */ |
|
| 145 | + */ |
|
| 146 | 146 | private static function get_user_list_like_start($conditions = array(), $order_by = array()) |
| 147 | 147 | { |
| 148 | 148 | $user_table = Database :: get_main_table(TABLE_MAIN_USER); |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | |
| 14 | 14 | public function find_id_user($username, $password, $name) |
| 15 | 15 | { |
| 16 | - if($this->verifyUserPass($username, $password) == "valid") |
|
| 16 | + if ($this->verifyUserPass($username, $password) == "valid") |
|
| 17 | 17 | { |
| 18 | 18 | |
| 19 | 19 | $listResult = "#"; |
@@ -40,9 +40,9 @@ discard block |
||
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | $listArrayResult = array_unique($listArray); |
| 43 | - foreach($listArrayResult as $result) |
|
| 43 | + foreach ($listArrayResult as $result) |
|
| 44 | 44 | { |
| 45 | - $listResult .= $result . "#"; |
|
| 45 | + $listResult .= $result."#"; |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | return $listResult; |
@@ -97,12 +97,12 @@ discard block |
||
| 97 | 97 | if ($this->verifyUserPass($username, $password) == "valid") { |
| 98 | 98 | $user_id = UserManager::get_user_id_from_username($username); |
| 99 | 99 | $message_title = get_lang('Invitation'); |
| 100 | - $count_is_true = SocialManager::send_invitation_friend($user_id,$userfriend_id, $message_title, $content_message); |
|
| 100 | + $count_is_true = SocialManager::send_invitation_friend($user_id, $userfriend_id, $message_title, $content_message); |
|
| 101 | 101 | |
| 102 | 102 | if ($count_is_true) { |
| 103 | - return Display::display_normal_message(api_htmlentities(get_lang('InvitationHasBeenSent'), ENT_QUOTES,$charset),false); |
|
| 103 | + return Display::display_normal_message(api_htmlentities(get_lang('InvitationHasBeenSent'), ENT_QUOTES, $charset), false); |
|
| 104 | 104 | } else { |
| 105 | - return Display::display_error_message(api_htmlentities(get_lang('YouAlreadySentAnInvitation'), ENT_QUOTES,$charset),false); |
|
| 105 | + return Display::display_error_message(api_htmlentities(get_lang('YouAlreadySentAnInvitation'), ENT_QUOTES, $charset), false); |
|
| 106 | 106 | } |
| 107 | 107 | } |
| 108 | 108 | return get_lang('InvalidId'); |
@@ -20,6 +20,9 @@ |
||
| 20 | 20 | |
| 21 | 21 | define('WS_ERROR_SECRET_KEY', 1); |
| 22 | 22 | |
| 23 | +/** |
|
| 24 | + * @param integer $code |
|
| 25 | + */ |
|
| 23 | 26 | function return_error($code) { |
| 24 | 27 | $fault = null; |
| 25 | 28 | switch ($code) { |
@@ -581,7 +581,7 @@ |
||
| 581 | 581 | /*$sessionIdName = isset($params['session_id_name']) ? $params['session_id_name'] : null; |
| 582 | 582 | $sessionIdValue = isset($params['session_id_value']) ? $params['session_id_value'] : null;*/ |
| 583 | 583 | |
| 584 | - $courseInfo = CourseManager::getCourseInfoFromOriginalId( |
|
| 584 | + $courseInfo = CourseManager::getCourseInfoFromOriginalId( |
|
| 585 | 585 | $courseIdValue, |
| 586 | 586 | $courseIdName |
| 587 | 587 | ); |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | if ($debug) { |
| 68 | - error_log("checkip " . intval($check_ip)); |
|
| 68 | + error_log("checkip ".intval($check_ip)); |
|
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | if ($check_ip) { |
@@ -120,13 +120,13 @@ discard block |
||
| 120 | 120 | ); |
| 121 | 121 | |
| 122 | 122 | // Register the method to expose |
| 123 | -$server->register('WSImportLP', // method name |
|
| 124 | - array('params' => 'tns:params'), // input parameters |
|
| 125 | - array('return' => 'xsd:string'), // output parameters |
|
| 126 | - 'urn:WSLP', // namespace |
|
| 127 | - 'urn:WSLP#WSImportLP', // soapaction |
|
| 128 | - 'rpc', // style |
|
| 129 | - 'encoded', // use |
|
| 123 | +$server->register('WSImportLP', // method name |
|
| 124 | + array('params' => 'tns:params'), // input parameters |
|
| 125 | + array('return' => 'xsd:string'), // output parameters |
|
| 126 | + 'urn:WSLP', // namespace |
|
| 127 | + 'urn:WSLP#WSImportLP', // soapaction |
|
| 128 | + 'rpc', // style |
|
| 129 | + 'encoded', // use |
|
| 130 | 130 | 'This service adds users' // documentation |
| 131 | 131 | ); |
| 132 | 132 | |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | |
| 184 | 184 | $uniqueFile = uniqid(); |
| 185 | 185 | $userId = 1; // admin |
| 186 | - $filePath = api_get_path(SYS_ARCHIVE_PATH) . $uniqueFile; |
|
| 186 | + $filePath = api_get_path(SYS_ARCHIVE_PATH).$uniqueFile; |
|
| 187 | 187 | file_put_contents($filePath, $fileData); |
| 188 | 188 | |
| 189 | 189 | $fileName = $params['filename']; |
@@ -257,8 +257,8 @@ discard block |
||
| 257 | 257 | 'all', |
| 258 | 258 | '', |
| 259 | 259 | array( |
| 260 | - 'id' => array('name' => 'id', 'type' => 'xsd:string'), |
|
| 261 | - 'name' => array('name' => 'name', 'type' => 'xsd:string'), |
|
| 260 | + 'id' => array('name' => 'id', 'type' => 'xsd:string'), |
|
| 261 | + 'name' => array('name' => 'name', 'type' => 'xsd:string'), |
|
| 262 | 262 | ) |
| 263 | 263 | ); |
| 264 | 264 | |
@@ -274,13 +274,13 @@ discard block |
||
| 274 | 274 | ); |
| 275 | 275 | |
| 276 | 276 | // Register the method to expose |
| 277 | -$server->register('WSGetLpList', // method name |
|
| 278 | - array('params' => 'tns:paramsGetLpList'), // input parameters |
|
| 279 | - array('return' => 'tns:lpList'), // output parameters |
|
| 280 | - 'urn:WSLP', // namespace |
|
| 281 | - 'urn:WSLP#WSGetLpList', // soapaction |
|
| 282 | - 'rpc', // style |
|
| 283 | - 'encoded', // use |
|
| 277 | +$server->register('WSGetLpList', // method name |
|
| 278 | + array('params' => 'tns:paramsGetLpList'), // input parameters |
|
| 279 | + array('return' => 'tns:lpList'), // output parameters |
|
| 280 | + 'urn:WSLP', // namespace |
|
| 281 | + 'urn:WSLP#WSGetLpList', // soapaction |
|
| 282 | + 'rpc', // style |
|
| 283 | + 'encoded', // use |
|
| 284 | 284 | 'This service adds users' // documentation |
| 285 | 285 | ); |
| 286 | 286 | |
@@ -369,13 +369,13 @@ discard block |
||
| 369 | 369 | ); |
| 370 | 370 | |
| 371 | 371 | // Register the method to expose |
| 372 | -$server->register('WSDeleteLp', // method name |
|
| 373 | - array('params' => 'tns:paramsDeleteLp'), // input parameters |
|
| 374 | - array('return' => 'xsd:string'), // output parameters |
|
| 375 | - 'urn:WSLP', // namespace |
|
| 376 | - 'urn:WSLP#WSDeleteLp', // soapaction |
|
| 377 | - 'rpc', // style |
|
| 378 | - 'encoded', // use |
|
| 372 | +$server->register('WSDeleteLp', // method name |
|
| 373 | + array('params' => 'tns:paramsDeleteLp'), // input parameters |
|
| 374 | + array('return' => 'xsd:string'), // output parameters |
|
| 375 | + 'urn:WSLP', // namespace |
|
| 376 | + 'urn:WSLP#WSDeleteLp', // soapaction |
|
| 377 | + 'rpc', // style |
|
| 378 | + 'encoded', // use |
|
| 379 | 379 | 'This service deletes a LP' // documentation |
| 380 | 380 | ); |
| 381 | 381 | |
@@ -434,9 +434,9 @@ discard block |
||
| 434 | 434 | if ($lp) { |
| 435 | 435 | if ($debug) error_log("LP deleted $lpId"); |
| 436 | 436 | |
| 437 | - $course_dir = $courseInfo['directory'] . '/document'; |
|
| 437 | + $course_dir = $courseInfo['directory'].'/document'; |
|
| 438 | 438 | $sys_course_path = api_get_path(SYS_COURSE_PATH); |
| 439 | - $base_work_dir = $sys_course_path . $course_dir; |
|
| 439 | + $base_work_dir = $sys_course_path.$course_dir; |
|
| 440 | 440 | |
| 441 | 441 | $items = $lp->get_flat_ordered_items_list($lpId, 0, $courseId); |
| 442 | 442 | |
@@ -495,9 +495,9 @@ discard block |
||
| 495 | 495 | 'all', |
| 496 | 496 | '', |
| 497 | 497 | array( |
| 498 | - 'data' => array('name' => 'data', 'type' => 'xsd:string'), |
|
| 499 | - 'title' => array('name' => 'title', 'type' => 'xsd:string'), |
|
| 500 | - 'filename' => array('name' => 'filename', 'type' => 'xsd:string'), |
|
| 498 | + 'data' => array('name' => 'data', 'type' => 'xsd:string'), |
|
| 499 | + 'title' => array('name' => 'title', 'type' => 'xsd:string'), |
|
| 500 | + 'filename' => array('name' => 'filename', 'type' => 'xsd:string'), |
|
| 501 | 501 | ) |
| 502 | 502 | ); |
| 503 | 503 | |
@@ -548,13 +548,13 @@ discard block |
||
| 548 | 548 | ); |
| 549 | 549 | |
| 550 | 550 | // Register the method to expose |
| 551 | -$server->register('WSCreateLp', // method name |
|
| 552 | - array('params' => 'tns:paramsCreateLp'), // input parameters |
|
| 553 | - array('return' => 'xsd:string'), // output parameters |
|
| 554 | - 'urn:WSLP', // namespace |
|
| 555 | - 'urn:WSLP#WSCreateLp', // soapaction |
|
| 556 | - 'rpc', // style |
|
| 557 | - 'encoded', // use |
|
| 551 | +$server->register('WSCreateLp', // method name |
|
| 552 | + array('params' => 'tns:paramsCreateLp'), // input parameters |
|
| 553 | + array('return' => 'xsd:string'), // output parameters |
|
| 554 | + 'urn:WSLP', // namespace |
|
| 555 | + 'urn:WSLP#WSCreateLp', // soapaction |
|
| 556 | + 'rpc', // style |
|
| 557 | + 'encoded', // use |
|
| 558 | 558 | 'This service creates a LP' // documentation |
| 559 | 559 | ); |
| 560 | 560 | |
@@ -48,19 +48,22 @@ discard block |
||
| 48 | 48 | list($ip1, $ip2) = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']); |
| 49 | 49 | $ip = trim($ip1); |
| 50 | 50 | } |
| 51 | - if ($debug) |
|
| 52 | - error_log("ip: $ip"); |
|
| 51 | + if ($debug) { |
|
| 52 | + error_log("ip: $ip"); |
|
| 53 | + } |
|
| 53 | 54 | // Check if a file that limits access from webservices exists and contains |
| 54 | 55 | // the restraining check |
| 55 | 56 | if (is_file('webservice-auth-ip.conf.php')) { |
| 56 | 57 | include 'webservice-auth-ip.conf.php'; |
| 57 | - if ($debug) |
|
| 58 | - error_log("webservice-auth-ip.conf.php file included"); |
|
| 58 | + if ($debug) { |
|
| 59 | + error_log("webservice-auth-ip.conf.php file included"); |
|
| 60 | + } |
|
| 59 | 61 | if (!empty($ws_auth_ip)) { |
| 60 | 62 | $check_ip = true; |
| 61 | 63 | $ip_matches = api_check_ip_in_range($ip, $ws_auth_ip); |
| 62 | - if ($debug) |
|
| 63 | - error_log("ip_matches: $ip_matches"); |
|
| 64 | + if ($debug) { |
|
| 65 | + error_log("ip_matches: $ip_matches"); |
|
| 66 | + } |
|
| 64 | 67 | } |
| 65 | 68 | } |
| 66 | 69 | |
@@ -76,8 +79,9 @@ discard block |
||
| 76 | 79 | } |
| 77 | 80 | $result = api_is_valid_secret_key($secret_key, $security_key); |
| 78 | 81 | //error_log($secret_key.'-'.$security_key); |
| 79 | - if ($debug) |
|
| 80 | - error_log('WSHelperVerifyKey result: '.intval($result)); |
|
| 82 | + if ($debug) { |
|
| 83 | + error_log('WSHelperVerifyKey result: '.intval($result)); |
|
| 84 | + } |
|
| 81 | 85 | return $result; |
| 82 | 86 | } |
| 83 | 87 | |
@@ -140,7 +144,9 @@ discard block |
||
| 140 | 144 | if (!WSHelperVerifyKey($params)) { |
| 141 | 145 | return return_error(WS_ERROR_SECRET_KEY); |
| 142 | 146 | } |
| 143 | - if ($debug) error_log('WSImportLP'); |
|
| 147 | + if ($debug) { |
|
| 148 | + error_log('WSImportLP'); |
|
| 149 | + } |
|
| 144 | 150 | |
| 145 | 151 | $courseIdName = $params['course_id_name']; |
| 146 | 152 | $courseIdValue = $params['course_id_value']; |
@@ -156,7 +162,9 @@ discard block |
||
| 156 | 162 | $courseId = $courseInfo['real_id']; |
| 157 | 163 | |
| 158 | 164 | if (empty($courseInfo)) { |
| 159 | - if ($debug) error_log('Course not found'); |
|
| 165 | + if ($debug) { |
|
| 166 | + error_log('Course not found'); |
|
| 167 | + } |
|
| 160 | 168 | return 'Course not found'; |
| 161 | 169 | } |
| 162 | 170 | |
@@ -169,7 +177,9 @@ discard block |
||
| 169 | 177 | |
| 170 | 178 | if (empty($sessionId)) { |
| 171 | 179 | |
| 172 | - if ($debug) error_log('Session not found'); |
|
| 180 | + if ($debug) { |
|
| 181 | + error_log('Session not found'); |
|
| 182 | + } |
|
| 173 | 183 | return 'Session not found'; |
| 174 | 184 | } |
| 175 | 185 | } |
@@ -196,7 +206,9 @@ discard block |
||
| 196 | 206 | $manifest = $oScorm->import_package($fileInfo, '', $courseInfo); |
| 197 | 207 | |
| 198 | 208 | if (!$manifest) { |
| 199 | - if ($debug) error_log('manifest.xml file not found'); |
|
| 209 | + if ($debug) { |
|
| 210 | + error_log('manifest.xml file not found'); |
|
| 211 | + } |
|
| 200 | 212 | //if api_set_failure |
| 201 | 213 | return 'manifest.xml file not found'; |
| 202 | 214 | } |
@@ -215,10 +227,14 @@ discard block |
||
| 215 | 227 | $oScorm->set_maker($maker, $courseId); |
| 216 | 228 | //$oScorm->set_jslib('scorm_api.php'); |
| 217 | 229 | |
| 218 | - if ($debug) error_log('scorm was added'); |
|
| 230 | + if ($debug) { |
|
| 231 | + error_log('scorm was added'); |
|
| 232 | + } |
|
| 219 | 233 | return 1; |
| 220 | 234 | } else { |
| 221 | - if ($debug) error_log('manifest data empty'); |
|
| 235 | + if ($debug) { |
|
| 236 | + error_log('manifest data empty'); |
|
| 237 | + } |
|
| 222 | 238 | return 'manifest data empty'; |
| 223 | 239 | } |
| 224 | 240 | } |
@@ -311,7 +327,9 @@ discard block |
||
| 311 | 327 | ); |
| 312 | 328 | |
| 313 | 329 | if (empty($courseInfo)) { |
| 314 | - if ($debug) error_log("Course not found: $courseIdName : $courseIdValue"); |
|
| 330 | + if ($debug) { |
|
| 331 | + error_log("Course not found: $courseIdName : $courseIdValue"); |
|
| 332 | + } |
|
| 315 | 333 | return 'Course not found'; |
| 316 | 334 | } |
| 317 | 335 | |
@@ -326,7 +344,9 @@ discard block |
||
| 326 | 344 | |
| 327 | 345 | if (empty($sessionId)) { |
| 328 | 346 | |
| 329 | - if ($debug) error_log('Session not found'); |
|
| 347 | + if ($debug) { |
|
| 348 | + error_log('Session not found'); |
|
| 349 | + } |
|
| 330 | 350 | return 'Session not found'; |
| 331 | 351 | } |
| 332 | 352 | } |
@@ -407,7 +427,9 @@ discard block |
||
| 407 | 427 | ); |
| 408 | 428 | |
| 409 | 429 | if (empty($courseInfo)) { |
| 410 | - if ($debug) error_log("Course not found: $courseIdName : $courseIdValue"); |
|
| 430 | + if ($debug) { |
|
| 431 | + error_log("Course not found: $courseIdName : $courseIdValue"); |
|
| 432 | + } |
|
| 411 | 433 | return 'Course not found'; |
| 412 | 434 | } |
| 413 | 435 | $courseId = $courseInfo['real_id']; |
@@ -432,7 +454,9 @@ discard block |
||
| 432 | 454 | |
| 433 | 455 | $lp = new learnpath($courseCode, $lpId, null); |
| 434 | 456 | if ($lp) { |
| 435 | - if ($debug) error_log("LP deleted $lpId"); |
|
| 457 | + if ($debug) { |
|
| 458 | + error_log("LP deleted $lpId"); |
|
| 459 | + } |
|
| 436 | 460 | |
| 437 | 461 | $course_dir = $courseInfo['directory'] . '/document'; |
| 438 | 462 | $sys_course_path = api_get_path(SYS_COURSE_PATH); |
@@ -448,7 +472,9 @@ discard block |
||
| 448 | 472 | if ($item) { |
| 449 | 473 | $documentId = $item->get_path(); |
| 450 | 474 | |
| 451 | - if ($debug) error_log("lp item id found #$itemId"); |
|
| 475 | + if ($debug) { |
|
| 476 | + error_log("lp item id found #$itemId"); |
|
| 477 | + } |
|
| 452 | 478 | |
| 453 | 479 | $documentInfo = DocumentManager::get_document_data_by_id( |
| 454 | 480 | $documentId, |
@@ -474,7 +500,9 @@ discard block |
||
| 474 | 500 | } |
| 475 | 501 | } |
| 476 | 502 | } else { |
| 477 | - if ($debug) error_log("Document not found #$itemId"); |
|
| 503 | + if ($debug) { |
|
| 504 | + error_log("Document not found #$itemId"); |
|
| 505 | + } |
|
| 478 | 506 | } |
| 479 | 507 | } |
| 480 | 508 | } |
@@ -2617,6 +2617,9 @@ |
||
| 2617 | 2617 | ) |
| 2618 | 2618 | ); |
| 2619 | 2619 | |
| 2620 | +/** |
|
| 2621 | + * @param string $type |
|
| 2622 | + */ |
|
| 2620 | 2623 | function WSHelperActionOnUsers($params, $type) { |
| 2621 | 2624 | if(!WSHelperVerifyKey($params)) { |
| 2622 | 2625 | return returnError(WS_ERROR_SECRET_KEY); |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | if ($debug) { |
| 83 | - error_log("checkip " . intval($check_ip)); |
|
| 83 | + error_log("checkip ".intval($check_ip)); |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | if ($check_ip) { |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | '', |
| 139 | 139 | 'SOAP-ENC:Array', |
| 140 | 140 | array(), |
| 141 | - array(array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType' => 'tns:extras[]')), |
|
| 141 | + array(array('ref'=>'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:extras[]')), |
|
| 142 | 142 | 'tns:extras' |
| 143 | 143 | ); |
| 144 | 144 | |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | '', |
| 172 | 172 | 'SOAP-ENC:Array', |
| 173 | 173 | array(), |
| 174 | - array(array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType' => 'tns:usersParams[]')), |
|
| 174 | + array(array('ref'=>'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:usersParams[]')), |
|
| 175 | 175 | 'tns:usersParams' |
| 176 | 176 | ); |
| 177 | 177 | |
@@ -210,17 +210,17 @@ discard block |
||
| 210 | 210 | '', |
| 211 | 211 | 'SOAP-ENC:Array', |
| 212 | 212 | array(), |
| 213 | - array(array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType' => 'tns:result_createUsers[]')),'tns:result_createUsers' |
|
| 213 | + array(array('ref'=>'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:result_createUsers[]')), 'tns:result_createUsers' |
|
| 214 | 214 | ); |
| 215 | 215 | |
| 216 | 216 | // Register the method to expose |
| 217 | -$server->register('WSCreateUsers', // method name |
|
| 218 | - array('createUsers' => 'tns:createUsers'), // input parameters |
|
| 219 | - array('return' => 'tns:results_createUsers'), // output parameters |
|
| 220 | - 'urn:WSRegistration', // namespace |
|
| 221 | - 'urn:WSRegistration#WSCreateUsers', // soapaction |
|
| 222 | - 'rpc', // style |
|
| 223 | - 'encoded', // use |
|
| 217 | +$server->register('WSCreateUsers', // method name |
|
| 218 | + array('createUsers' => 'tns:createUsers'), // input parameters |
|
| 219 | + array('return' => 'tns:results_createUsers'), // output parameters |
|
| 220 | + 'urn:WSRegistration', // namespace |
|
| 221 | + 'urn:WSRegistration#WSCreateUsers', // soapaction |
|
| 222 | + 'rpc', // style |
|
| 223 | + 'encoded', // use |
|
| 224 | 224 | 'This service adds a user' // documentation |
| 225 | 225 | ); |
| 226 | 226 | |
@@ -401,7 +401,7 @@ discard block |
||
| 401 | 401 | continue; |
| 402 | 402 | } |
| 403 | 403 | |
| 404 | - $results[] = $userId; |
|
| 404 | + $results[] = $userId; |
|
| 405 | 405 | |
| 406 | 406 | } // end principal foreach |
| 407 | 407 | |
@@ -447,13 +447,13 @@ discard block |
||
| 447 | 447 | |
| 448 | 448 | |
| 449 | 449 | // Register the method to expose |
| 450 | -$server->register('WSCreateUser', // method name |
|
| 451 | - array('createUser' => 'tns:createUser'), // input parameters |
|
| 452 | - array('return' => 'xsd:string'), // output parameters |
|
| 453 | - 'urn:WSRegistration', // namespace |
|
| 454 | - 'urn:WSRegistration#WSCreateUser', // soapaction |
|
| 455 | - 'rpc', // style |
|
| 456 | - 'encoded', // use |
|
| 450 | +$server->register('WSCreateUser', // method name |
|
| 451 | + array('createUser' => 'tns:createUser'), // input parameters |
|
| 452 | + array('return' => 'xsd:string'), // output parameters |
|
| 453 | + 'urn:WSRegistration', // namespace |
|
| 454 | + 'urn:WSRegistration#WSCreateUser', // soapaction |
|
| 455 | + 'rpc', // style |
|
| 456 | + 'encoded', // use |
|
| 457 | 457 | 'This service adds a user' // documentation |
| 458 | 458 | ); |
| 459 | 459 | |
@@ -558,7 +558,7 @@ discard block |
||
| 558 | 558 | } |
| 559 | 559 | |
| 560 | 560 | if (isset($original_user_id_name) && isset($original_user_id_value)) { |
| 561 | - $_SESSION['ws_' . $original_user_id_name] = $original_user_id_value; |
|
| 561 | + $_SESSION['ws_'.$original_user_id_name] = $original_user_id_value; |
|
| 562 | 562 | } |
| 563 | 563 | |
| 564 | 564 | /** @var User $user */ |
@@ -606,7 +606,7 @@ discard block |
||
| 606 | 606 | ); |
| 607 | 607 | |
| 608 | 608 | if (isset($original_user_id_name) && isset($original_user_id_value)) { |
| 609 | - unset($_SESSION['ws_' . $original_user_id_name]); |
|
| 609 | + unset($_SESSION['ws_'.$original_user_id_name]); |
|
| 610 | 610 | } |
| 611 | 611 | |
| 612 | 612 | if (is_array($extra_list) && count($extra_list) > 0) { |
@@ -658,7 +658,7 @@ discard block |
||
| 658 | 658 | 'language' => array('name' => 'language', 'type' => 'xsd:string'), |
| 659 | 659 | 'phone' => array('name' => 'phone', 'type' => 'xsd:string'), |
| 660 | 660 | 'expiration_date' => array('name' => 'expiration_date', 'type' => 'xsd:string'), |
| 661 | - 'official_code' => array('name' => 'official_code', 'type' => 'xsd:string'), |
|
| 661 | + 'official_code' => array('name' => 'official_code', 'type' => 'xsd:string'), |
|
| 662 | 662 | 'original_user_id_name' => array('name' => 'original_user_id_name', 'type' => 'xsd:string'), |
| 663 | 663 | 'original_user_id_value'=> array('name' => 'original_user_id_value', 'type' => 'xsd:string'), |
| 664 | 664 | 'extra' => array('name' => 'extra', 'type' => 'tns:extrasList') |
@@ -686,7 +686,7 @@ discard block |
||
| 686 | 686 | 'all', |
| 687 | 687 | '', |
| 688 | 688 | array( |
| 689 | - 'users' => array('name' => 'users', 'type' => 'tns:createUsersPassEncryptParamsList'), |
|
| 689 | + 'users' => array('name' => 'users', 'type' => 'tns:createUsersPassEncryptParamsList'), |
|
| 690 | 690 | 'secret_key' => array('name' => 'secret_key', 'type' => 'xsd:string') |
| 691 | 691 | ) |
| 692 | 692 | ); |
@@ -716,13 +716,13 @@ discard block |
||
| 716 | 716 | ); |
| 717 | 717 | |
| 718 | 718 | // Register the method to expose |
| 719 | -$server->register('WSCreateUsersPasswordCrypted', // method name |
|
| 719 | +$server->register('WSCreateUsersPasswordCrypted', // method name |
|
| 720 | 720 | array('createUsersPasswordCrypted' => 'tns:createUsersPasswordCrypted'), // input parameters |
| 721 | - array('return' => 'tns:results_createUsersPassEncrypt'), // output parameters |
|
| 722 | - 'urn:WSRegistration', // namespace |
|
| 723 | - 'urn:WSRegistration#WSCreateUsersPasswordCrypted', // soapaction |
|
| 724 | - 'rpc', // style |
|
| 725 | - 'encoded', // use |
|
| 721 | + array('return' => 'tns:results_createUsersPassEncrypt'), // output parameters |
|
| 722 | + 'urn:WSRegistration', // namespace |
|
| 723 | + 'urn:WSRegistration#WSCreateUsersPasswordCrypted', // soapaction |
|
| 724 | + 'rpc', // style |
|
| 725 | + 'encoded', // use |
|
| 726 | 726 | 'This service adds users to the system' // documentation |
| 727 | 727 | ); |
| 728 | 728 | |
@@ -769,7 +769,7 @@ discard block |
||
| 769 | 769 | $salt = ''; |
| 770 | 770 | |
| 771 | 771 | if (!empty($_configuration['password_encryption'])) { |
| 772 | - if ($_configuration['password_encryption'] === $encrypt_method ) { |
|
| 772 | + if ($_configuration['password_encryption'] === $encrypt_method) { |
|
| 773 | 773 | if ($encrypt_method == 'md5' && !preg_match('/^[A-Fa-f0-9]{32}$/', $password)) { |
| 774 | 774 | $msg = "Encryption $encrypt_method is invalid"; |
| 775 | 775 | $results[] = $msg; |
@@ -792,7 +792,7 @@ discard block |
||
| 792 | 792 | |
| 793 | 793 | if (is_array($extra_list) && count($extra_list) > 0) { |
| 794 | 794 | foreach ($extra_list as $extra) { |
| 795 | - if($extra['field_name'] == 'salt') { |
|
| 795 | + if ($extra['field_name'] == 'salt') { |
|
| 796 | 796 | $salt = $extra['field_value']; |
| 797 | 797 | break; |
| 798 | 798 | } |
@@ -847,7 +847,7 @@ discard block |
||
| 847 | 847 | active='1', |
| 848 | 848 | hr_dept_id=".intval($hr_dept_id); |
| 849 | 849 | |
| 850 | - $sql .= " WHERE user_id='".$r_check_user[0]."'"; |
|
| 850 | + $sql .= " WHERE user_id='".$r_check_user[0]."'"; |
|
| 851 | 851 | Database::query($sql); |
| 852 | 852 | |
| 853 | 853 | if (is_array($extra_list) && count($extra_list) > 0) { |
@@ -967,7 +967,7 @@ discard block |
||
| 967 | 967 | |
| 968 | 968 | $count_results = count($results); |
| 969 | 969 | $output = array(); |
| 970 | - for($i = 0; $i < $count_results; $i++) { |
|
| 970 | + for ($i = 0; $i < $count_results; $i++) { |
|
| 971 | 971 | $output[] = array( |
| 972 | 972 | 'original_user_id_value' => $orig_user_id_value[$i], |
| 973 | 973 | 'result' => $results[$i], |
@@ -986,9 +986,9 @@ discard block |
||
| 986 | 986 | 'all', |
| 987 | 987 | '', |
| 988 | 988 | array( |
| 989 | - 'user_id' => array('name' => 'course', 'type' => 'xsd:string'), // Chamilo user Id |
|
| 990 | - 'session_id' => array('name' => 'user_id', 'type' => 'xsd:string'), // Current Session course ID |
|
| 991 | - 'course_id' =>array('name' => 'courseId', 'type' => 'xsd:string'), // Course Real Id |
|
| 989 | + 'user_id' => array('name' => 'course', 'type' => 'xsd:string'), // Chamilo user Id |
|
| 990 | + 'session_id' => array('name' => 'user_id', 'type' => 'xsd:string'), // Current Session course ID |
|
| 991 | + 'course_id' =>array('name' => 'courseId', 'type' => 'xsd:string'), // Course Real Id |
|
| 992 | 992 | 'secret_key' => array('name' => 'secret_key', 'type' => 'xsd:string'), |
| 993 | 993 | |
| 994 | 994 | // optional |
@@ -1044,9 +1044,9 @@ discard block |
||
| 1044 | 1044 | ); |
| 1045 | 1045 | } |
| 1046 | 1046 | |
| 1047 | - if ($debug) error_log('$userId found: '. $userId); |
|
| 1048 | - if ($debug) error_log('$courseId found: '. $courseId); |
|
| 1049 | - if ($debug) error_log('$sessionId found: '. $sessionId); |
|
| 1047 | + if ($debug) error_log('$userId found: '.$userId); |
|
| 1048 | + if ($debug) error_log('$courseId found: '.$courseId); |
|
| 1049 | + if ($debug) error_log('$sessionId found: '.$sessionId); |
|
| 1050 | 1050 | |
| 1051 | 1051 | return [ |
| 1052 | 1052 | 'user_id' => $userId, |
@@ -1082,7 +1082,7 @@ discard block |
||
| 1082 | 1082 | return returnError(WS_ERROR_SECRET_KEY); |
| 1083 | 1083 | } |
| 1084 | 1084 | |
| 1085 | - if ($debug) error_log('Params '. print_r($params, 1)); |
|
| 1085 | + if ($debug) error_log('Params '.print_r($params, 1)); |
|
| 1086 | 1086 | |
| 1087 | 1087 | $params = parseCourseSessionUserParams($params); |
| 1088 | 1088 | |
@@ -1095,13 +1095,13 @@ discard block |
||
| 1095 | 1095 | $result = 0; |
| 1096 | 1096 | |
| 1097 | 1097 | if (!empty($coaches)) { |
| 1098 | - if ($debug) error_log('Coaches: '. print_r($coaches, 1)); |
|
| 1098 | + if ($debug) error_log('Coaches: '.print_r($coaches, 1)); |
|
| 1099 | 1099 | if (in_array($userId, $coaches)) { |
| 1100 | 1100 | $result = 1; |
| 1101 | 1101 | } |
| 1102 | 1102 | } |
| 1103 | 1103 | |
| 1104 | - if ($debug) error_log('Result: '. $result); |
|
| 1104 | + if ($debug) error_log('Result: '.$result); |
|
| 1105 | 1105 | |
| 1106 | 1106 | return $result; |
| 1107 | 1107 | } |
@@ -1133,7 +1133,7 @@ discard block |
||
| 1133 | 1133 | return returnError(WS_ERROR_SECRET_KEY); |
| 1134 | 1134 | } |
| 1135 | 1135 | |
| 1136 | - if ($debug) error_log('Params '. print_r($params, 1)); |
|
| 1136 | + if ($debug) error_log('Params '.print_r($params, 1)); |
|
| 1137 | 1137 | |
| 1138 | 1138 | $params = parseCourseSessionUserParams($params); |
| 1139 | 1139 | |
@@ -1147,7 +1147,7 @@ discard block |
||
| 1147 | 1147 | $result = 0; |
| 1148 | 1148 | |
| 1149 | 1149 | if (!empty($coaches)) { |
| 1150 | - if ($debug) error_log('Coaches: ' . print_r($coaches, 1)); |
|
| 1150 | + if ($debug) error_log('Coaches: '.print_r($coaches, 1)); |
|
| 1151 | 1151 | if (!in_array($userId, $coaches)) { |
| 1152 | 1152 | $result = 1; |
| 1153 | 1153 | } |
@@ -1155,7 +1155,7 @@ discard block |
||
| 1155 | 1155 | $result = 1; |
| 1156 | 1156 | } |
| 1157 | 1157 | |
| 1158 | - if ($debug) error_log('Final Result: '. $result); |
|
| 1158 | + if ($debug) error_log('Final Result: '.$result); |
|
| 1159 | 1159 | |
| 1160 | 1160 | return $result; |
| 1161 | 1161 | } |
@@ -1173,32 +1173,32 @@ discard block |
||
| 1173 | 1173 | 'all', |
| 1174 | 1174 | '', |
| 1175 | 1175 | array( |
| 1176 | - 'firstname' => array('name' => 'firstname', 'type' => 'xsd:string'), |
|
| 1177 | - 'lastname' => array('name' => 'lastname', 'type' => 'xsd:string'), |
|
| 1178 | - 'status' => array('name' => 'status', 'type' => 'xsd:string'), |
|
| 1179 | - 'email' => array('name' => 'email', 'type' => 'xsd:string'), |
|
| 1180 | - 'loginname' => array('name' => 'loginname', 'type' => 'xsd:string'), |
|
| 1181 | - 'password' => array('name' => 'password', 'type' => 'xsd:string'), //encripted password using the encrypt_method |
|
| 1182 | - 'encrypt_method' => array('name' => 'encrypt_method', 'type' => 'xsd:string'), |
|
| 1183 | - 'language' => array('name' => 'language', 'type' => 'xsd:string'), |
|
| 1184 | - 'phone' => array('name' => 'phone', 'type' => 'xsd:string'), |
|
| 1185 | - 'expiration_date' => array('name' => 'expiration_date', 'type' => 'xsd:string'), |
|
| 1186 | - 'official_code' => array('name' => 'official_code', 'type' => 'xsd:string'), |
|
| 1187 | - 'original_user_id_name' => array('name' => 'original_user_id_name', 'type' => 'xsd:string'), |
|
| 1188 | - 'original_user_id_value' => array('name' => 'original_user_id_value', 'type' => 'xsd:string'), |
|
| 1189 | - 'extra' => array('name' => 'extra', 'type' => 'tns:extrasList'), |
|
| 1190 | - 'secret_key' => array('name' => 'secret_key', 'type' => 'xsd:string') |
|
| 1176 | + 'firstname' => array('name' => 'firstname', 'type' => 'xsd:string'), |
|
| 1177 | + 'lastname' => array('name' => 'lastname', 'type' => 'xsd:string'), |
|
| 1178 | + 'status' => array('name' => 'status', 'type' => 'xsd:string'), |
|
| 1179 | + 'email' => array('name' => 'email', 'type' => 'xsd:string'), |
|
| 1180 | + 'loginname' => array('name' => 'loginname', 'type' => 'xsd:string'), |
|
| 1181 | + 'password' => array('name' => 'password', 'type' => 'xsd:string'), //encripted password using the encrypt_method |
|
| 1182 | + 'encrypt_method' => array('name' => 'encrypt_method', 'type' => 'xsd:string'), |
|
| 1183 | + 'language' => array('name' => 'language', 'type' => 'xsd:string'), |
|
| 1184 | + 'phone' => array('name' => 'phone', 'type' => 'xsd:string'), |
|
| 1185 | + 'expiration_date' => array('name' => 'expiration_date', 'type' => 'xsd:string'), |
|
| 1186 | + 'official_code' => array('name' => 'official_code', 'type' => 'xsd:string'), |
|
| 1187 | + 'original_user_id_name' => array('name' => 'original_user_id_name', 'type' => 'xsd:string'), |
|
| 1188 | + 'original_user_id_value' => array('name' => 'original_user_id_value', 'type' => 'xsd:string'), |
|
| 1189 | + 'extra' => array('name' => 'extra', 'type' => 'tns:extrasList'), |
|
| 1190 | + 'secret_key' => array('name' => 'secret_key', 'type' => 'xsd:string') |
|
| 1191 | 1191 | ) |
| 1192 | 1192 | ); |
| 1193 | 1193 | |
| 1194 | 1194 | // Register the method to expose |
| 1195 | -$server->register('WSCreateUserPasswordCrypted', // method name |
|
| 1196 | - array('createUserPasswordCrypted' => 'tns:createUserPasswordCrypted'), // input parameters |
|
| 1197 | - array('return' => 'xsd:string'), // output parameters |
|
| 1198 | - 'urn:WSRegistration', // namespace |
|
| 1199 | - 'urn:WSRegistration#WSCreateUserPasswordCrypted', // soapaction |
|
| 1200 | - 'rpc', // style |
|
| 1201 | - 'encoded', // use |
|
| 1195 | +$server->register('WSCreateUserPasswordCrypted', // method name |
|
| 1196 | + array('createUserPasswordCrypted' => 'tns:createUserPasswordCrypted'), // input parameters |
|
| 1197 | + array('return' => 'xsd:string'), // output parameters |
|
| 1198 | + 'urn:WSRegistration', // namespace |
|
| 1199 | + 'urn:WSRegistration#WSCreateUserPasswordCrypted', // soapaction |
|
| 1200 | + 'rpc', // style |
|
| 1201 | + 'encoded', // use |
|
| 1202 | 1202 | 'This service adds users' // documentation |
| 1203 | 1203 | ); |
| 1204 | 1204 | |
@@ -1208,7 +1208,7 @@ discard block |
||
| 1208 | 1208 | global $_user, $_configuration, $debug; |
| 1209 | 1209 | $debug = 1; |
| 1210 | 1210 | if ($debug) error_log('WSCreateUserPasswordCrypted'); |
| 1211 | - if ($debug) error_log(print_r($params,1)); |
|
| 1211 | + if ($debug) error_log(print_r($params, 1)); |
|
| 1212 | 1212 | |
| 1213 | 1213 | if (!WSHelperVerifyKey($params)) { |
| 1214 | 1214 | return returnError(WS_ERROR_SECRET_KEY); |
@@ -1241,7 +1241,7 @@ discard block |
||
| 1241 | 1241 | $extra_list = isset($params['extra']) ? $params['extra'] : ''; |
| 1242 | 1242 | |
| 1243 | 1243 | if (!empty($_configuration['password_encryption'])) { |
| 1244 | - if ($_configuration['password_encryption'] === $encrypt_method ) { |
|
| 1244 | + if ($_configuration['password_encryption'] === $encrypt_method) { |
|
| 1245 | 1245 | if ($encrypt_method == 'md5' && !preg_match('/^[A-Fa-f0-9]{32}$/', $password)) { |
| 1246 | 1246 | $msg = "Encryption $encrypt_method is invalid"; |
| 1247 | 1247 | if ($debug) error_log($msg); |
@@ -1303,7 +1303,7 @@ discard block |
||
| 1303 | 1303 | if (!is_null($auth_source)) { |
| 1304 | 1304 | $sql .= " auth_source='".Database::escape_string($auth_source)."',"; |
| 1305 | 1305 | } |
| 1306 | - $sql .= " |
|
| 1306 | + $sql .= " |
|
| 1307 | 1307 | password='".Database::escape_string($password)."', |
| 1308 | 1308 | email='".Database::escape_string($email)."', |
| 1309 | 1309 | status='".Database::escape_string($status)."', |
@@ -1312,7 +1312,7 @@ discard block |
||
| 1312 | 1312 | expiration_date='".Database::escape_string($expiration_date)."', |
| 1313 | 1313 | active='1', |
| 1314 | 1314 | hr_dept_id=".intval($hr_dept_id); |
| 1315 | - $sql .= " WHERE user_id='".$r_check_user[0]."'"; |
|
| 1315 | + $sql .= " WHERE user_id='".$r_check_user[0]."'"; |
|
| 1316 | 1316 | if ($debug) error_log($sql); |
| 1317 | 1317 | Database::query($sql); |
| 1318 | 1318 | |
@@ -1492,13 +1492,13 @@ discard block |
||
| 1492 | 1492 | ); |
| 1493 | 1493 | |
| 1494 | 1494 | // Register the method to expose |
| 1495 | -$server->register('WSEditUserCredentials', // method name |
|
| 1496 | - array('editUserCredentials' => 'tns:editUserCredentials'), // input parameters |
|
| 1497 | - array('return' => 'xsd:string'), // output parameters |
|
| 1498 | - 'urn:WSRegistration', // namespace |
|
| 1499 | - 'urn:WSRegistration#WSEditUserCredentials', // soapaction |
|
| 1500 | - 'rpc', // style |
|
| 1501 | - 'encoded', // use |
|
| 1495 | +$server->register('WSEditUserCredentials', // method name |
|
| 1496 | + array('editUserCredentials' => 'tns:editUserCredentials'), // input parameters |
|
| 1497 | + array('return' => 'xsd:string'), // output parameters |
|
| 1498 | + 'urn:WSRegistration', // namespace |
|
| 1499 | + 'urn:WSRegistration#WSEditUserCredentials', // soapaction |
|
| 1500 | + 'rpc', // style |
|
| 1501 | + 'encoded', // use |
|
| 1502 | 1502 | 'This service edits the username and password of a user' // documentation |
| 1503 | 1503 | ); |
| 1504 | 1504 | |
@@ -1597,13 +1597,13 @@ discard block |
||
| 1597 | 1597 | ); |
| 1598 | 1598 | |
| 1599 | 1599 | // Register the method to expose |
| 1600 | -$server->register('WSEditUsers', // method name |
|
| 1601 | - array('editUsers' => 'tns:editUsers'), // input parameters |
|
| 1600 | +$server->register('WSEditUsers', // method name |
|
| 1601 | + array('editUsers' => 'tns:editUsers'), // input parameters |
|
| 1602 | 1602 | array('return' => 'tns:results_editUsers'), // output parameters |
| 1603 | - 'urn:WSRegistration', // namespace |
|
| 1604 | - 'urn:WSRegistration#WSEditUsers', // soapaction |
|
| 1605 | - 'rpc', // style |
|
| 1606 | - 'encoded', // use |
|
| 1603 | + 'urn:WSRegistration', // namespace |
|
| 1604 | + 'urn:WSRegistration#WSEditUsers', // soapaction |
|
| 1605 | + 'rpc', // style |
|
| 1606 | + 'encoded', // use |
|
| 1607 | 1607 | 'This service edits a user from wiener' // documentation |
| 1608 | 1608 | ); |
| 1609 | 1609 | |
@@ -1795,13 +1795,13 @@ discard block |
||
| 1795 | 1795 | ); |
| 1796 | 1796 | |
| 1797 | 1797 | // Register the method to expose |
| 1798 | -$server->register('WSEditUser', // method name |
|
| 1799 | - array('editUser' => 'tns:editUser'), // input parameters |
|
| 1800 | - array('return' => 'xsd:string'), // output parameters |
|
| 1801 | - 'urn:WSRegistration', // namespace |
|
| 1802 | - 'urn:WSRegistration#WSEditUser', // soapaction |
|
| 1803 | - 'rpc', // style |
|
| 1804 | - 'encoded', // use |
|
| 1798 | +$server->register('WSEditUser', // method name |
|
| 1799 | + array('editUser' => 'tns:editUser'), // input parameters |
|
| 1800 | + array('return' => 'xsd:string'), // output parameters |
|
| 1801 | + 'urn:WSRegistration', // namespace |
|
| 1802 | + 'urn:WSRegistration#WSEditUser', // soapaction |
|
| 1803 | + 'rpc', // style |
|
| 1804 | + 'encoded', // use |
|
| 1805 | 1805 | 'This service edits a user from wiener' // documentation |
| 1806 | 1806 | ); |
| 1807 | 1807 | |
@@ -1972,13 +1972,13 @@ discard block |
||
| 1972 | 1972 | ); |
| 1973 | 1973 | |
| 1974 | 1974 | // Register the method to expose |
| 1975 | -$server->register('WSEditUserWithPicture', // method name |
|
| 1976 | - array('editUserWithPicture' => 'tns:editUserWithPicture'), // input parameters |
|
| 1977 | - array('return' => 'xsd:string'), // output parameters |
|
| 1978 | - 'urn:WSRegistration', // namespace |
|
| 1979 | - 'urn:WSRegistration#WSEditUserWithPicture', // soapaction |
|
| 1980 | - 'rpc', // style |
|
| 1981 | - 'encoded', // use |
|
| 1975 | +$server->register('WSEditUserWithPicture', // method name |
|
| 1976 | + array('editUserWithPicture' => 'tns:editUserWithPicture'), // input parameters |
|
| 1977 | + array('return' => 'xsd:string'), // output parameters |
|
| 1978 | + 'urn:WSRegistration', // namespace |
|
| 1979 | + 'urn:WSRegistration#WSEditUserWithPicture', // soapaction |
|
| 1980 | + 'rpc', // style |
|
| 1981 | + 'encoded', // use |
|
| 1982 | 1982 | 'This service edits a user from wiener' // documentation |
| 1983 | 1983 | ); |
| 1984 | 1984 | |
@@ -2036,8 +2036,8 @@ discard block |
||
| 2036 | 2036 | $tempDir = api_get_path(SYS_ARCHIVE_PATH); |
| 2037 | 2037 | // Make sure the file download was OK by checking the HTTP headers for OK |
| 2038 | 2038 | if (strpos(get_headers($picture_url)[0], "OK")) { |
| 2039 | - file_put_contents($tempDir . $filename, file_get_contents($picture_url)); |
|
| 2040 | - $pictureUri = UserManager::update_user_picture($user_id, $filename, $tempDir . $filename); |
|
| 2039 | + file_put_contents($tempDir.$filename, file_get_contents($picture_url)); |
|
| 2040 | + $pictureUri = UserManager::update_user_picture($user_id, $filename, $tempDir.$filename); |
|
| 2041 | 2041 | } |
| 2042 | 2042 | |
| 2043 | 2043 | if ($user_id == 0) { |
@@ -2108,7 +2108,7 @@ discard block |
||
| 2108 | 2108 | ->setExpirationDate($expiration_date) |
| 2109 | 2109 | ->setHrDeptId($hr_dept_id) |
| 2110 | 2110 | ->setActive(true) |
| 2111 | - ->setPictureUri($pictureUri);; |
|
| 2111 | + ->setPictureUri($pictureUri); ; |
|
| 2112 | 2112 | |
| 2113 | 2113 | if (!is_null($creator_id)) { |
| 2114 | 2114 | $user->setCreatorId($creator_id); |
@@ -2205,13 +2205,13 @@ discard block |
||
| 2205 | 2205 | ); |
| 2206 | 2206 | |
| 2207 | 2207 | // Register the method to expose |
| 2208 | -$server->register('WSEditUsersPasswordCrypted', // method name |
|
| 2209 | - array('editUsersPasswordCrypted' => 'tns:editUsersPasswordCrypted'), // input parameters |
|
| 2210 | - array('return' => 'tns:results_editUsersPasswordCrypted'), // output parameters |
|
| 2211 | - 'urn:WSRegistration', // namespace |
|
| 2212 | - 'urn:WSRegistration#WSEditUsersPasswordCrypted', // soapaction |
|
| 2213 | - 'rpc', // style |
|
| 2214 | - 'encoded', // use |
|
| 2208 | +$server->register('WSEditUsersPasswordCrypted', // method name |
|
| 2209 | + array('editUsersPasswordCrypted' => 'tns:editUsersPasswordCrypted'), // input parameters |
|
| 2210 | + array('return' => 'tns:results_editUsersPasswordCrypted'), // output parameters |
|
| 2211 | + 'urn:WSRegistration', // namespace |
|
| 2212 | + 'urn:WSRegistration#WSEditUsersPasswordCrypted', // soapaction |
|
| 2213 | + 'rpc', // style |
|
| 2214 | + 'encoded', // use |
|
| 2215 | 2215 | 'This service edits a user' // documentation |
| 2216 | 2216 | ); |
| 2217 | 2217 | |
@@ -2219,7 +2219,7 @@ discard block |
||
| 2219 | 2219 | function WSEditUsersPasswordCrypted($params) { |
| 2220 | 2220 | global $_configuration; |
| 2221 | 2221 | |
| 2222 | - if(!WSHelperVerifyKey($params)) { |
|
| 2222 | + if (!WSHelperVerifyKey($params)) { |
|
| 2223 | 2223 | return returnError(WS_ERROR_SECRET_KEY); |
| 2224 | 2224 | } |
| 2225 | 2225 | |
@@ -2256,7 +2256,7 @@ discard block |
||
| 2256 | 2256 | |
| 2257 | 2257 | $password = $user_param['password']; |
| 2258 | 2258 | $encrypt_method = $user_param['encrypt_method']; |
| 2259 | - if ($_configuration['password_encryption'] === $encrypt_method ) { |
|
| 2259 | + if ($_configuration['password_encryption'] === $encrypt_method) { |
|
| 2260 | 2260 | if ($encrypt_method == 'md5' && !preg_match('/^[A-Fa-f0-9]{32}$/', $password)) { |
| 2261 | 2261 | $msg = "Encryption $encrypt_method is invalid"; |
| 2262 | 2262 | $results[] = $msg; |
@@ -2271,11 +2271,11 @@ discard block |
||
| 2271 | 2271 | $results[] = $msg; |
| 2272 | 2272 | continue; |
| 2273 | 2273 | } |
| 2274 | - } elseif (!empty($user_param['password']) && empty($user_param['encrypt_method'])){ |
|
| 2274 | + } elseif (!empty($user_param['password']) && empty($user_param['encrypt_method'])) { |
|
| 2275 | 2275 | $msg = "If password is not empty the encrypt_method param is required "; |
| 2276 | 2276 | $results[] = $msg; |
| 2277 | 2277 | continue; |
| 2278 | - } elseif (empty($user_param['password']) && !empty($user_param['encrypt_method'])){ |
|
| 2278 | + } elseif (empty($user_param['password']) && !empty($user_param['encrypt_method'])) { |
|
| 2279 | 2279 | $msg = "If encrypt_method is not empty the password param is required "; |
| 2280 | 2280 | $results[] = $msg; |
| 2281 | 2281 | continue; |
@@ -2411,13 +2411,13 @@ discard block |
||
| 2411 | 2411 | ); |
| 2412 | 2412 | |
| 2413 | 2413 | // Register the method to expose |
| 2414 | -$server->register('WSEditUserPasswordCrypted', // method name |
|
| 2414 | +$server->register('WSEditUserPasswordCrypted', // method name |
|
| 2415 | 2415 | array('editUserPasswordCrypted' => 'tns:editUserPasswordCrypted'), // input parameters |
| 2416 | - array('return' => 'xsd:string'), // output parameters |
|
| 2417 | - 'urn:WSRegistration', // namespace |
|
| 2418 | - 'urn:WSRegistration#WSEditUserPasswordCrypted', // soapaction |
|
| 2419 | - 'rpc', // style |
|
| 2420 | - 'encoded', // use |
|
| 2416 | + array('return' => 'xsd:string'), // output parameters |
|
| 2417 | + 'urn:WSRegistration', // namespace |
|
| 2418 | + 'urn:WSRegistration#WSEditUserPasswordCrypted', // soapaction |
|
| 2419 | + 'rpc', // style |
|
| 2420 | + 'encoded', // use |
|
| 2421 | 2421 | 'This service edits a user' // documentation |
| 2422 | 2422 | ); |
| 2423 | 2423 | |
@@ -2461,7 +2461,7 @@ discard block |
||
| 2461 | 2461 | if (!empty($params['password']) && !empty($params['encrypt_method'])) { |
| 2462 | 2462 | $password = $params['password']; |
| 2463 | 2463 | $encrypt_method = $params['encrypt_method']; |
| 2464 | - if ($_configuration['password_encryption'] === $encrypt_method ) { |
|
| 2464 | + if ($_configuration['password_encryption'] === $encrypt_method) { |
|
| 2465 | 2465 | if ($encrypt_method == 'md5' && !preg_match('/^[A-Fa-f0-9]{32}$/', $password)) { |
| 2466 | 2466 | $msg = "Encryption $encrypt_method is invalid"; |
| 2467 | 2467 | return $msg; |
@@ -2606,7 +2606,7 @@ discard block |
||
| 2606 | 2606 | '', |
| 2607 | 2607 | 'SOAP-ENC:Array', |
| 2608 | 2608 | array(), |
| 2609 | - array(array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType' => 'tns:user_id[]')),'tns:user_id' |
|
| 2609 | + array(array('ref'=>'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:user_id[]')), 'tns:user_id' |
|
| 2610 | 2610 | ); |
| 2611 | 2611 | |
| 2612 | 2612 | $server->wsdl->addComplexType( |
@@ -2622,35 +2622,35 @@ discard block |
||
| 2622 | 2622 | ); |
| 2623 | 2623 | |
| 2624 | 2624 | function WSHelperActionOnUsers($params, $type) { |
| 2625 | - if(!WSHelperVerifyKey($params)) { |
|
| 2625 | + if (!WSHelperVerifyKey($params)) { |
|
| 2626 | 2626 | return returnError(WS_ERROR_SECRET_KEY); |
| 2627 | 2627 | } |
| 2628 | 2628 | |
| 2629 | 2629 | $original_user_ids = $params['ids']; |
| 2630 | - foreach($original_user_ids as $original_user_id) { |
|
| 2630 | + foreach ($original_user_ids as $original_user_id) { |
|
| 2631 | 2631 | $user_id = UserManager::get_user_id_from_original_id( |
| 2632 | 2632 | $original_user_id['original_user_id_value'], |
| 2633 | 2633 | $original_user_id['original_user_id_name'] |
| 2634 | 2634 | ); |
| 2635 | - if($user_id > 0) { |
|
| 2636 | - if($type == "delete") { |
|
| 2635 | + if ($user_id > 0) { |
|
| 2636 | + if ($type == "delete") { |
|
| 2637 | 2637 | UserManager::delete_user($user_id); |
| 2638 | - } else if($type == "disable") { |
|
| 2638 | + } else if ($type == "disable") { |
|
| 2639 | 2639 | UserManager::disable($user_id); |
| 2640 | - } else if($type == "enable") { |
|
| 2640 | + } else if ($type == "enable") { |
|
| 2641 | 2641 | UserManager::enable($user_id); |
| 2642 | 2642 | } |
| 2643 | 2643 | } |
| 2644 | 2644 | } |
| 2645 | 2645 | } |
| 2646 | 2646 | |
| 2647 | -$server->register('WSDeleteUsers', // method name |
|
| 2648 | - array('user_ids' => 'tns:user_ids'), // input parameters |
|
| 2649 | - array(), // output parameters |
|
| 2650 | - 'urn:WSRegistration', // namespace |
|
| 2651 | - 'urn:WSRegistration#WSDeleteUsers', // soapaction |
|
| 2652 | - 'rpc', // style |
|
| 2653 | - 'encoded', // use |
|
| 2647 | +$server->register('WSDeleteUsers', // method name |
|
| 2648 | + array('user_ids' => 'tns:user_ids'), // input parameters |
|
| 2649 | + array(), // output parameters |
|
| 2650 | + 'urn:WSRegistration', // namespace |
|
| 2651 | + 'urn:WSRegistration#WSDeleteUsers', // soapaction |
|
| 2652 | + 'rpc', // style |
|
| 2653 | + 'encoded', // use |
|
| 2654 | 2654 | 'Deletes users provided as parameters from the system' // documentation |
| 2655 | 2655 | ); |
| 2656 | 2656 | |
@@ -2659,13 +2659,13 @@ discard block |
||
| 2659 | 2659 | } |
| 2660 | 2660 | |
| 2661 | 2661 | /** WSDisableUsers **/ |
| 2662 | -$server->register('WSDisableUsers', // method name |
|
| 2663 | - array('user_ids' => 'tns:user_ids'), // input parameters |
|
| 2664 | - array(), // output parameters |
|
| 2665 | - 'urn:WSRegistration', // namespace |
|
| 2666 | - 'urn:WSRegistration#WSDisableUsers', // soapaction |
|
| 2667 | - 'rpc', // style |
|
| 2668 | - 'encoded', // use |
|
| 2662 | +$server->register('WSDisableUsers', // method name |
|
| 2663 | + array('user_ids' => 'tns:user_ids'), // input parameters |
|
| 2664 | + array(), // output parameters |
|
| 2665 | + 'urn:WSRegistration', // namespace |
|
| 2666 | + 'urn:WSRegistration#WSDisableUsers', // soapaction |
|
| 2667 | + 'rpc', // style |
|
| 2668 | + 'encoded', // use |
|
| 2669 | 2669 | 'Disables users provided as parameters from the system' // documentation |
| 2670 | 2670 | ); |
| 2671 | 2671 | |
@@ -2674,13 +2674,13 @@ discard block |
||
| 2674 | 2674 | } |
| 2675 | 2675 | |
| 2676 | 2676 | /** WSEnableUsers **/ |
| 2677 | -$server->register('WSEnableUsers', // method name |
|
| 2678 | - array('user_ids' => 'tns:user_ids'), // input parameters |
|
| 2679 | - array(), // output parameters |
|
| 2680 | - 'urn:WSRegistration', // namespace |
|
| 2681 | - 'urn:WSRegistration#WSEnableUsers', // soapaction |
|
| 2682 | - 'rpc', // style |
|
| 2683 | - 'encoded', // use |
|
| 2677 | +$server->register('WSEnableUsers', // method name |
|
| 2678 | + array('user_ids' => 'tns:user_ids'), // input parameters |
|
| 2679 | + array(), // output parameters |
|
| 2680 | + 'urn:WSRegistration', // namespace |
|
| 2681 | + 'urn:WSRegistration#WSEnableUsers', // soapaction |
|
| 2682 | + 'rpc', // style |
|
| 2683 | + 'encoded', // use |
|
| 2684 | 2684 | 'Enables users provided as parameters' // documentation |
| 2685 | 2685 | ); |
| 2686 | 2686 | |
@@ -2730,7 +2730,7 @@ discard block |
||
| 2730 | 2730 | '', |
| 2731 | 2731 | 'SOAP-ENC:Array', |
| 2732 | 2732 | array(), |
| 2733 | - array(array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType' => 'tns:createCourseParams[]')),'tns:createCourseParams' |
|
| 2733 | + array(array('ref'=>'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:createCourseParams[]')), 'tns:createCourseParams' |
|
| 2734 | 2734 | ); |
| 2735 | 2735 | |
| 2736 | 2736 | // Register the data structures used by the service |
@@ -2771,13 +2771,13 @@ discard block |
||
| 2771 | 2771 | ); |
| 2772 | 2772 | |
| 2773 | 2773 | // Register the method to expose |
| 2774 | -$server->register('WSCreateCourse', // method name |
|
| 2775 | - array('createCourse' => 'tns:createCourse'), // input parameters |
|
| 2774 | +$server->register('WSCreateCourse', // method name |
|
| 2775 | + array('createCourse' => 'tns:createCourse'), // input parameters |
|
| 2776 | 2776 | array('return' => 'tns:results_createCourse'), // output parameters |
| 2777 | - 'urn:WSRegistration', // namespace |
|
| 2778 | - 'urn:WSRegistration#WSCreateCourse', // soapaction |
|
| 2779 | - 'rpc', // style |
|
| 2780 | - 'encoded', // use |
|
| 2777 | + 'urn:WSRegistration', // namespace |
|
| 2778 | + 'urn:WSRegistration#WSCreateCourse', // soapaction |
|
| 2779 | + 'rpc', // style |
|
| 2780 | + 'encoded', // use |
|
| 2781 | 2781 | 'This service adds a course' // documentation |
| 2782 | 2782 | ); |
| 2783 | 2783 | |
@@ -2833,7 +2833,7 @@ discard block |
||
| 2833 | 2833 | category_code='".Database::escape_string($category_code)."', |
| 2834 | 2834 | tutor_name='".Database::escape_string($tutor_name)."', |
| 2835 | 2835 | visual_code='".Database::escape_string($wanted_code)."'"; |
| 2836 | - if($visibility !== null) { |
|
| 2836 | + if ($visibility !== null) { |
|
| 2837 | 2837 | $sql .= ", visibility = '$visibility' "; |
| 2838 | 2838 | } |
| 2839 | 2839 | $sql .= " WHERE id='".$courseInfo['real_id']."'"; |
@@ -2883,7 +2883,7 @@ discard block |
||
| 2883 | 2883 | $params['title'] = $title; |
| 2884 | 2884 | $params['wanted_code'] = $wanted_code; |
| 2885 | 2885 | $params['category_code'] = $category_code; |
| 2886 | - $params['course_category'] = $category_code; |
|
| 2886 | + $params['course_category'] = $category_code; |
|
| 2887 | 2887 | $params['tutor_name'] = $tutor_name; |
| 2888 | 2888 | $params['course_language'] = $course_language; |
| 2889 | 2889 | $params['user_id'] = api_get_user_id(); |
@@ -3014,13 +3014,13 @@ discard block |
||
| 3014 | 3014 | |
| 3015 | 3015 | |
| 3016 | 3016 | // Register the method to expose |
| 3017 | -$server->register('WSCreateCourseByTitle', // method name |
|
| 3017 | +$server->register('WSCreateCourseByTitle', // method name |
|
| 3018 | 3018 | array('createCourseByTitle' => 'tns:createCourseByTitle'), // input parameters |
| 3019 | - array('return' => 'tns:results_createCourseByTitle'), // output parameters |
|
| 3020 | - 'urn:WSRegistration', // namespace |
|
| 3021 | - 'urn:WSRegistration#WSCreateCourseByTitle', // soapaction |
|
| 3022 | - 'rpc', // style |
|
| 3023 | - 'encoded', // use |
|
| 3019 | + array('return' => 'tns:results_createCourseByTitle'), // output parameters |
|
| 3020 | + 'urn:WSRegistration', // namespace |
|
| 3021 | + 'urn:WSRegistration#WSCreateCourseByTitle', // soapaction |
|
| 3022 | + 'rpc', // style |
|
| 3023 | + 'encoded', // use |
|
| 3024 | 3024 | 'This service adds a course by title' // documentation |
| 3025 | 3025 | ); |
| 3026 | 3026 | |
@@ -3251,18 +3251,18 @@ discard block |
||
| 3251 | 3251 | ); |
| 3252 | 3252 | |
| 3253 | 3253 | // Register the method to expose |
| 3254 | -$server->register('WSEditCourse', // method name |
|
| 3255 | - array('editCourse' => 'tns:editCourse'), // input parameters |
|
| 3254 | +$server->register('WSEditCourse', // method name |
|
| 3255 | + array('editCourse' => 'tns:editCourse'), // input parameters |
|
| 3256 | 3256 | array('return' => 'tns:results_editCourse'), // output parameters |
| 3257 | - 'urn:WSRegistration', // namespace |
|
| 3258 | - 'urn:WSRegistration#WSEditCourse', // soapaction |
|
| 3259 | - 'rpc', // style |
|
| 3260 | - 'encoded', // use |
|
| 3257 | + 'urn:WSRegistration', // namespace |
|
| 3258 | + 'urn:WSRegistration#WSEditCourse', // soapaction |
|
| 3259 | + 'rpc', // style |
|
| 3260 | + 'encoded', // use |
|
| 3261 | 3261 | 'This service edits a course' // documentation |
| 3262 | 3262 | ); |
| 3263 | 3263 | |
| 3264 | 3264 | // Define the method WSEditCourse |
| 3265 | -function WSEditCourse($params){ |
|
| 3265 | +function WSEditCourse($params) { |
|
| 3266 | 3266 | |
| 3267 | 3267 | global $_configuration; |
| 3268 | 3268 | if (!WSHelperVerifyKey($params)) { |
@@ -3417,13 +3417,13 @@ discard block |
||
| 3417 | 3417 | |
| 3418 | 3418 | |
| 3419 | 3419 | // Register the method to expose |
| 3420 | -$server->register('WSCourseDescription', // method name |
|
| 3421 | - array('courseDescription' => 'tns:courseDescription'), // input parameters |
|
| 3422 | - array('return' => 'tns:fields_course_desc_list'), // output parameters |
|
| 3423 | - 'urn:WSRegistration', // namespace |
|
| 3424 | - 'urn:WSRegistration#WSCourseDescription', // soapaction |
|
| 3425 | - 'rpc', // style |
|
| 3426 | - 'encoded', // use |
|
| 3420 | +$server->register('WSCourseDescription', // method name |
|
| 3421 | + array('courseDescription' => 'tns:courseDescription'), // input parameters |
|
| 3422 | + array('return' => 'tns:fields_course_desc_list'), // output parameters |
|
| 3423 | + 'urn:WSRegistration', // namespace |
|
| 3424 | + 'urn:WSRegistration#WSCourseDescription', // soapaction |
|
| 3425 | + 'rpc', // style |
|
| 3426 | + 'encoded', // use |
|
| 3427 | 3427 | 'This service edits a course description' // documentation |
| 3428 | 3428 | ); |
| 3429 | 3429 | |
@@ -3476,14 +3476,14 @@ discard block |
||
| 3476 | 3476 | } |
| 3477 | 3477 | |
| 3478 | 3478 | while ($row = Database::fetch_array($result)) { |
| 3479 | - $ind = (int)$row['id']; |
|
| 3479 | + $ind = (int) $row['id']; |
|
| 3480 | 3480 | $array_course_desc_title[$ind] = $row['title']; |
| 3481 | 3481 | $array_course_desc_content[$ind] = $row['content']; |
| 3482 | 3482 | } |
| 3483 | 3483 | |
| 3484 | 3484 | $count_results = count($default_titles); |
| 3485 | 3485 | $output = array(); |
| 3486 | - for($i = 1; $i <= $count_results; $i++) { |
|
| 3486 | + for ($i = 1; $i <= $count_results; $i++) { |
|
| 3487 | 3487 | $output[] = array( |
| 3488 | 3488 | 'course_desc_id' => $array_course_desc_id[$i], |
| 3489 | 3489 | 'course_desc_default_title' => $array_course_desc_default_title[$i], |
@@ -3563,13 +3563,13 @@ discard block |
||
| 3563 | 3563 | |
| 3564 | 3564 | |
| 3565 | 3565 | // Register the method to expose |
| 3566 | -$server->register('WSEditCourseDescription', // method name |
|
| 3566 | +$server->register('WSEditCourseDescription', // method name |
|
| 3567 | 3567 | array('editCourseDescription' => 'tns:editCourseDescription'), // input parameters |
| 3568 | - array('return' => 'tns:results_editCourseDescription'), // output parameters |
|
| 3569 | - 'urn:WSRegistration', // namespace |
|
| 3570 | - 'urn:WSRegistration#WSEditCourseDescription', // soapaction |
|
| 3571 | - 'rpc', // style |
|
| 3572 | - 'encoded', // use |
|
| 3568 | + array('return' => 'tns:results_editCourseDescription'), // output parameters |
|
| 3569 | + 'urn:WSRegistration', // namespace |
|
| 3570 | + 'urn:WSRegistration#WSEditCourseDescription', // soapaction |
|
| 3571 | + 'rpc', // style |
|
| 3572 | + 'encoded', // use |
|
| 3573 | 3573 | 'This service edits a course description' // documentation |
| 3574 | 3574 | ); |
| 3575 | 3575 | |
@@ -3613,7 +3613,7 @@ discard block |
||
| 3613 | 3613 | $course_desc_title = Database::escape_string($course_desc_title); |
| 3614 | 3614 | $course_desc_content = Database::escape_string($course_desc_content); |
| 3615 | 3615 | |
| 3616 | - $course_desc_id = (int)$course_desc_id; |
|
| 3616 | + $course_desc_id = (int) $course_desc_id; |
|
| 3617 | 3617 | if ($course_desc_id > 8 && $course_desc_id < 1) { |
| 3618 | 3618 | $results[] = 0; // course_desc_id invalid. |
| 3619 | 3619 | continue; |
@@ -3647,7 +3647,7 @@ discard block |
||
| 3647 | 3647 | |
| 3648 | 3648 | $count_results = count($results); |
| 3649 | 3649 | $output = array(); |
| 3650 | - for($i = 0; $i < $count_results; $i++) { |
|
| 3650 | + for ($i = 0; $i < $count_results; $i++) { |
|
| 3651 | 3651 | $output[] = array( |
| 3652 | 3652 | 'original_course_id_value' => $orig_course_id_value[$i], |
| 3653 | 3653 | 'result' => $results[$i], |
@@ -3719,13 +3719,13 @@ discard block |
||
| 3719 | 3719 | 'tns:result_deleteCourse' |
| 3720 | 3720 | ); |
| 3721 | 3721 | |
| 3722 | -$server->register('WSDeleteCourse', // method name |
|
| 3723 | - array('deleteCourse' => 'tns:deleteCourse'), // input parameters |
|
| 3722 | +$server->register('WSDeleteCourse', // method name |
|
| 3723 | + array('deleteCourse' => 'tns:deleteCourse'), // input parameters |
|
| 3724 | 3724 | array('return' => 'tns:results_deleteCourse'), // output parameters |
| 3725 | - 'urn:WSRegistration', // namespace |
|
| 3726 | - 'urn:WSRegistration#WSDeleteCourse', // soapaction |
|
| 3727 | - 'rpc', // style |
|
| 3728 | - 'encoded', // use |
|
| 3725 | + 'urn:WSRegistration', // namespace |
|
| 3726 | + 'urn:WSRegistration#WSDeleteCourse', // soapaction |
|
| 3727 | + 'rpc', // style |
|
| 3728 | + 'encoded', // use |
|
| 3729 | 3729 | 'This service deletes a course ' // documentation |
| 3730 | 3730 | ); |
| 3731 | 3731 | |
@@ -3851,13 +3851,13 @@ discard block |
||
| 3851 | 3851 | ); |
| 3852 | 3852 | |
| 3853 | 3853 | // Register the method to expose |
| 3854 | -$server->register('WSCreateSession', // method name |
|
| 3855 | - array('createSession' => 'tns:createSession'), // input parameters |
|
| 3854 | +$server->register('WSCreateSession', // method name |
|
| 3855 | + array('createSession' => 'tns:createSession'), // input parameters |
|
| 3856 | 3856 | array('return' => 'tns:results_createSession'), // output parameters |
| 3857 | - 'urn:WSRegistration', // namespace |
|
| 3858 | - 'urn:WSRegistration#WSCreateSession', // soapaction |
|
| 3859 | - 'rpc', // style |
|
| 3860 | - 'encoded', // use |
|
| 3857 | + 'urn:WSRegistration', // namespace |
|
| 3858 | + 'urn:WSRegistration#WSCreateSession', // soapaction |
|
| 3859 | + 'rpc', // style |
|
| 3860 | + 'encoded', // use |
|
| 3861 | 3861 | 'This service edits a session' // documentation |
| 3862 | 3862 | ); |
| 3863 | 3863 | |
@@ -3911,8 +3911,8 @@ discard block |
||
| 3911 | 3911 | } |
| 3912 | 3912 | |
| 3913 | 3913 | if (empty($nolimit)) { |
| 3914 | - $date_start = "$year_start-".(($month_start < 10)?"0$month_start":$month_start)."-".(($day_start < 10)?"0$day_start":$day_start) . ' 00:00:00'; |
|
| 3915 | - $date_end = "$year_end-".(($month_end < 10)?"0$month_end":$month_end)."-".(($day_end < 10)?"0$day_end":$day_end) . ' 23:59:59'; |
|
| 3914 | + $date_start = "$year_start-".(($month_start < 10) ? "0$month_start" : $month_start)."-".(($day_start < 10) ? "0$day_start" : $day_start).' 00:00:00'; |
|
| 3915 | + $date_end = "$year_end-".(($month_end < 10) ? "0$month_end" : $month_end)."-".(($day_end < 10) ? "0$day_end" : $day_end).' 23:59:59'; |
|
| 3916 | 3916 | } else { |
| 3917 | 3917 | $date_start = ""; |
| 3918 | 3918 | $date_end = ""; |
@@ -3930,7 +3930,7 @@ discard block |
||
| 3930 | 3930 | } |
| 3931 | 3931 | $results[] = 0; |
| 3932 | 3932 | continue; |
| 3933 | - } elseif (empty($nolimit) && (!$month_end || !$day_end || !$year_end || !checkdate($month_end, $day_end, $year_end))) { |
|
| 3933 | + } elseif (empty($nolimit) && (!$month_end || !$day_end || !$year_end || !checkdate($month_end, $day_end, $year_end))) { |
|
| 3934 | 3934 | $results[] = 0; |
| 3935 | 3935 | if ($debug) { |
| 3936 | 3936 | error_log("There's an error with the end date: $month_end - $day_end - $year_end"); |
@@ -4033,7 +4033,7 @@ discard block |
||
| 4033 | 4033 | |
| 4034 | 4034 | $count_results = count($results); |
| 4035 | 4035 | $output = array(); |
| 4036 | - for($i = 0; $i < $count_results; $i++) { |
|
| 4036 | + for ($i = 0; $i < $count_results; $i++) { |
|
| 4037 | 4037 | $output[] = array( |
| 4038 | 4038 | 'original_session_id_value' => $orig_session_id_value[$i], |
| 4039 | 4039 | 'result' => $results[$i], |
@@ -4118,13 +4118,13 @@ discard block |
||
| 4118 | 4118 | |
| 4119 | 4119 | |
| 4120 | 4120 | // Register the method to expose |
| 4121 | -$server->register('WSEditSession', // method name |
|
| 4122 | - array('editSession' => 'tns:editSession'), // input parameters |
|
| 4121 | +$server->register('WSEditSession', // method name |
|
| 4122 | + array('editSession' => 'tns:editSession'), // input parameters |
|
| 4123 | 4123 | array('return' => 'tns:results_editSession'), // output parameters |
| 4124 | - 'urn:WSRegistration', // namespace |
|
| 4125 | - 'urn:WSRegistration#WSEditSession', // soapaction |
|
| 4126 | - 'rpc', // style |
|
| 4127 | - 'encoded', // use |
|
| 4124 | + 'urn:WSRegistration', // namespace |
|
| 4125 | + 'urn:WSRegistration#WSEditSession', // soapaction |
|
| 4126 | + 'rpc', // style |
|
| 4127 | + 'encoded', // use |
|
| 4128 | 4128 | 'This service edits a session' // documentation |
| 4129 | 4129 | ); |
| 4130 | 4130 | |
@@ -4174,11 +4174,11 @@ discard block |
||
| 4174 | 4174 | } |
| 4175 | 4175 | |
| 4176 | 4176 | if (empty($nolimit)) { |
| 4177 | - $date_start="$year_start-".(($month_start < 10)?"0$month_start":$month_start)."-".(($day_start < 10)?"0$day_start":$day_start); |
|
| 4178 | - $date_end="$year_end-".(($month_end < 10)?"0$month_end":$month_end)."-".(($day_end < 10)?"0$day_end":$day_end); |
|
| 4177 | + $date_start = "$year_start-".(($month_start < 10) ? "0$month_start" : $month_start)."-".(($day_start < 10) ? "0$day_start" : $day_start); |
|
| 4178 | + $date_end = "$year_end-".(($month_end < 10) ? "0$month_end" : $month_end)."-".(($day_end < 10) ? "0$day_end" : $day_end); |
|
| 4179 | 4179 | } else { |
| 4180 | - $date_start=""; |
|
| 4181 | - $date_end=""; |
|
| 4180 | + $date_start = ""; |
|
| 4181 | + $date_end = ""; |
|
| 4182 | 4182 | } |
| 4183 | 4183 | if (empty($name)) { |
| 4184 | 4184 | $results[] = 0; //SessionNameIsRequired |
@@ -4322,13 +4322,13 @@ discard block |
||
| 4322 | 4322 | 'tns:result_deleteSession' |
| 4323 | 4323 | ); |
| 4324 | 4324 | |
| 4325 | -$server->register('WSDeleteSession', // method name |
|
| 4326 | - array('deleteSession' => 'tns:deleteSession'), // input parameters |
|
| 4325 | +$server->register('WSDeleteSession', // method name |
|
| 4326 | + array('deleteSession' => 'tns:deleteSession'), // input parameters |
|
| 4327 | 4327 | array('return' => 'tns:results_deleteSession'), // output parameters |
| 4328 | - 'urn:WSRegistration', // namespace |
|
| 4329 | - 'urn:WSRegistration#WSDeleteSession', // soapaction |
|
| 4330 | - 'rpc', // style |
|
| 4331 | - 'encoded', // use |
|
| 4328 | + 'urn:WSRegistration', // namespace |
|
| 4329 | + 'urn:WSRegistration#WSDeleteSession', // soapaction |
|
| 4330 | + 'rpc', // style |
|
| 4331 | + 'encoded', // use |
|
| 4332 | 4332 | 'This service deletes a session ' // documentation |
| 4333 | 4333 | ); |
| 4334 | 4334 | |
@@ -4410,10 +4410,10 @@ discard block |
||
| 4410 | 4410 | 'struct', |
| 4411 | 4411 | 'all', |
| 4412 | 4412 | '', |
| 4413 | - array ( |
|
| 4413 | + array( |
|
| 4414 | 4414 | 'course_id' => array('name' => 'course_id', 'type' => 'tns:course_id'), |
| 4415 | - 'user_id' => array('name' => 'user_id', 'type' => 'tns:user_id'), |
|
| 4416 | - 'status' => array('name' => 'status', 'type' => 'xsd:int') |
|
| 4415 | + 'user_id' => array('name' => 'user_id', 'type' => 'tns:user_id'), |
|
| 4416 | + 'status' => array('name' => 'status', 'type' => 'xsd:int') |
|
| 4417 | 4417 | ) |
| 4418 | 4418 | ); |
| 4419 | 4419 | |
@@ -4423,9 +4423,9 @@ discard block |
||
| 4423 | 4423 | 'struct', |
| 4424 | 4424 | 'all', |
| 4425 | 4425 | '', |
| 4426 | - array ( |
|
| 4427 | - 'userscourses' => array('name' => 'userscourses', 'type' => 'tns:user_course_status_array'), //removed [] |
|
| 4428 | - 'secret_key' => array('name' => 'secret_key', 'type' => 'xsd:string') |
|
| 4426 | + array( |
|
| 4427 | + 'userscourses' => array('name' => 'userscourses', 'type' => 'tns:user_course_status_array'), //removed [] |
|
| 4428 | + 'secret_key' => array('name' => 'secret_key', 'type' => 'xsd:string') |
|
| 4429 | 4429 | ) |
| 4430 | 4430 | ); |
| 4431 | 4431 | |
@@ -4450,9 +4450,9 @@ discard block |
||
| 4450 | 4450 | 'all', |
| 4451 | 4451 | '', |
| 4452 | 4452 | array( |
| 4453 | - 'original_user_id_value' => array('name' => 'original_user_id_value', 'type' => 'xsd:string'), |
|
| 4454 | - 'original_course_id_value' => array('name' => 'original_course_id_value', 'type' => 'xsd:string'), |
|
| 4455 | - 'result' => array('name' => 'result', 'type' => 'xsd:int') |
|
| 4453 | + 'original_user_id_value' => array('name' => 'original_user_id_value', 'type' => 'xsd:string'), |
|
| 4454 | + 'original_course_id_value' => array('name' => 'original_course_id_value', 'type' => 'xsd:string'), |
|
| 4455 | + 'result' => array('name' => 'result', 'type' => 'xsd:int') |
|
| 4456 | 4456 | ) |
| 4457 | 4457 | ); |
| 4458 | 4458 | |
@@ -4468,13 +4468,13 @@ discard block |
||
| 4468 | 4468 | ); |
| 4469 | 4469 | |
| 4470 | 4470 | // Register the method to expose |
| 4471 | -$server->register('WSSubscribeUserToCourse', // method name |
|
| 4472 | - array('subscribeUserToCourse' => 'tns:subscribeUserToCourse_arg'), // input parameters |
|
| 4471 | +$server->register('WSSubscribeUserToCourse', // method name |
|
| 4472 | + array('subscribeUserToCourse' => 'tns:subscribeUserToCourse_arg'), // input parameters |
|
| 4473 | 4473 | array('return' => 'tns:subscribeUserToCourse_return_global'), |
| 4474 | - 'urn:WSRegistration', // namespace |
|
| 4475 | - 'urn:WSRegistration#WSSubscribeUserToCourse', // soapaction |
|
| 4476 | - 'rpc', // style |
|
| 4477 | - 'encoded', // use |
|
| 4474 | + 'urn:WSRegistration', // namespace |
|
| 4475 | + 'urn:WSRegistration#WSSubscribeUserToCourse', // soapaction |
|
| 4476 | + 'rpc', // style |
|
| 4477 | + 'encoded', // use |
|
| 4478 | 4478 | 'This service subscribes a user to a course' // documentation |
| 4479 | 4479 | ); |
| 4480 | 4480 | |
@@ -4484,7 +4484,7 @@ discard block |
||
| 4484 | 4484 | if (!WSHelperVerifyKey($params)) { |
| 4485 | 4485 | return returnError(WS_ERROR_SECRET_KEY); |
| 4486 | 4486 | } |
| 4487 | - if ($debug) error_log('WSSubscribeUserToCourse params: '.print_r($params,1)); |
|
| 4487 | + if ($debug) error_log('WSSubscribeUserToCourse params: '.print_r($params, 1)); |
|
| 4488 | 4488 | |
| 4489 | 4489 | $results = array(); |
| 4490 | 4490 | $userscourses = $params['userscourses']; |
@@ -4552,8 +4552,8 @@ discard block |
||
| 4552 | 4552 | 'all', |
| 4553 | 4553 | '', |
| 4554 | 4554 | array( |
| 4555 | - 'course' => array('name' => 'course', 'type' => 'xsd:string'), //Course string code |
|
| 4556 | - 'user_id' => array('name' => 'user_id', 'type' => 'xsd:string'), //Chamilo user_id |
|
| 4555 | + 'course' => array('name' => 'course', 'type' => 'xsd:string'), //Course string code |
|
| 4556 | + 'user_id' => array('name' => 'user_id', 'type' => 'xsd:string'), //Chamilo user_id |
|
| 4557 | 4557 | 'secret_key' => array('name' => 'secret_key', 'type' => 'xsd:string') |
| 4558 | 4558 | ) |
| 4559 | 4559 | ); |
@@ -4566,18 +4566,18 @@ discard block |
||
| 4566 | 4566 | 'struct', |
| 4567 | 4567 | 'all', |
| 4568 | 4568 | '', |
| 4569 | - array('message' => array('name' => 'message', 'type' => 'xsd:string')) |
|
| 4569 | + array('message' => array('name' => 'message', 'type' => 'xsd:string')) |
|
| 4570 | 4570 | ); |
| 4571 | 4571 | |
| 4572 | 4572 | |
| 4573 | 4573 | // Register the method to expose |
| 4574 | -$server->register('WSSubscribeUserToCourseSimple', // method name |
|
| 4574 | +$server->register('WSSubscribeUserToCourseSimple', // method name |
|
| 4575 | 4575 | array('subscribeUserToCourseSimple' => 'tns:subscribeUserToCourseSimple_arg'), // input parameters |
| 4576 | - array('return' => 'xsd:string'), // output parameters |
|
| 4577 | - 'urn:WSRegistration', // namespace |
|
| 4578 | - 'urn:WSRegistration#WSSubscribeUserToCourseSimple', // soapaction |
|
| 4579 | - 'rpc', // style |
|
| 4580 | - 'encoded', // use |
|
| 4576 | + array('return' => 'xsd:string'), // output parameters |
|
| 4577 | + 'urn:WSRegistration', // namespace |
|
| 4578 | + 'urn:WSRegistration#WSSubscribeUserToCourseSimple', // soapaction |
|
| 4579 | + 'rpc', // style |
|
| 4580 | + 'encoded', // use |
|
| 4581 | 4581 | 'This service subscribes a user to a course in a simple way' // documentation |
| 4582 | 4582 | ); |
| 4583 | 4583 | |
@@ -4586,7 +4586,7 @@ discard block |
||
| 4586 | 4586 | global $debug; |
| 4587 | 4587 | |
| 4588 | 4588 | if ($debug) error_log('WSSubscribeUserToCourseSimple'); |
| 4589 | - if ($debug) error_log('Params '. print_r($params, 1)); |
|
| 4589 | + if ($debug) error_log('Params '.print_r($params, 1)); |
|
| 4590 | 4590 | if (!WSHelperVerifyKey($params)) { |
| 4591 | 4591 | return returnError(WS_ERROR_SECRET_KEY); |
| 4592 | 4592 | } |
@@ -4634,9 +4634,9 @@ discard block |
||
| 4634 | 4634 | 'all', |
| 4635 | 4635 | '', |
| 4636 | 4636 | array( |
| 4637 | - 'original_user_id_value' => array('name' => 'original_user_id_value', 'type' => 'xsd:string'), |
|
| 4638 | - 'original_user_id_name' => array('name' => 'original_user_id_name', 'type' => 'xsd:string'), |
|
| 4639 | - 'secret_key' => array('name' => 'secret_key', 'type' => 'xsd:string') |
|
| 4637 | + 'original_user_id_value' => array('name' => 'original_user_id_value', 'type' => 'xsd:string'), |
|
| 4638 | + 'original_user_id_name' => array('name' => 'original_user_id_name', 'type' => 'xsd:string'), |
|
| 4639 | + 'secret_key' => array('name' => 'secret_key', 'type' => 'xsd:string') |
|
| 4640 | 4640 | ) |
| 4641 | 4641 | ); |
| 4642 | 4642 | |
@@ -4647,21 +4647,21 @@ discard block |
||
| 4647 | 4647 | 'struct', |
| 4648 | 4648 | 'all', |
| 4649 | 4649 | '', |
| 4650 | - array ( |
|
| 4651 | - 'user_id' => array('name' => 'user_id', 'type' => 'xsd:string'), |
|
| 4652 | - 'firstname' => array('name' => 'firstname', 'type' => 'xsd:string'), |
|
| 4653 | - 'lastname' => array('name' => 'lastname', 'type' => 'xsd:string'), |
|
| 4650 | + array( |
|
| 4651 | + 'user_id' => array('name' => 'user_id', 'type' => 'xsd:string'), |
|
| 4652 | + 'firstname' => array('name' => 'firstname', 'type' => 'xsd:string'), |
|
| 4653 | + 'lastname' => array('name' => 'lastname', 'type' => 'xsd:string'), |
|
| 4654 | 4654 | ) |
| 4655 | 4655 | ); |
| 4656 | 4656 | |
| 4657 | 4657 | // Register the method to expose |
| 4658 | -$server->register('WSGetUser', // method name |
|
| 4659 | - array('GetUser' => 'tns:GetUserArg'), // input parameters |
|
| 4660 | - array('return' => 'tns:User'), // output parameters |
|
| 4661 | - 'urn:WSRegistration', // namespace |
|
| 4662 | - 'urn:WSRegistration#WSGetUser', // soapaction |
|
| 4663 | - 'rpc', // style |
|
| 4664 | - 'encoded', // use |
|
| 4658 | +$server->register('WSGetUser', // method name |
|
| 4659 | + array('GetUser' => 'tns:GetUserArg'), // input parameters |
|
| 4660 | + array('return' => 'tns:User'), // output parameters |
|
| 4661 | + 'urn:WSRegistration', // namespace |
|
| 4662 | + 'urn:WSRegistration#WSGetUser', // soapaction |
|
| 4663 | + 'rpc', // style |
|
| 4664 | + 'encoded', // use |
|
| 4665 | 4665 | 'This service get user information by id' // documentation |
| 4666 | 4666 | ); |
| 4667 | 4667 | |
@@ -4705,17 +4705,17 @@ discard block |
||
| 4705 | 4705 | '', |
| 4706 | 4706 | array( |
| 4707 | 4707 | 'username' => array('name' => 'username', 'type' => 'xsd:string'), |
| 4708 | - 'secret_key' => array('name' => 'secret_key','type' => 'xsd:string') |
|
| 4708 | + 'secret_key' => array('name' => 'secret_key', 'type' => 'xsd:string') |
|
| 4709 | 4709 | ) |
| 4710 | 4710 | ); |
| 4711 | 4711 | // Register the method to expose |
| 4712 | -$server->register('WSGetUserFromUsername', // method name |
|
| 4713 | - array('GetUserFromUsername' => 'tns:GetUserArgUsername'), // input params |
|
| 4714 | - array('return' => 'tns:User'), // output parameters |
|
| 4715 | - 'urn:WSRegistration', // namespace |
|
| 4716 | - 'urn:WSRegistration#WSGetUserFromUsername', // soapaction |
|
| 4717 | - 'rpc', // style |
|
| 4718 | - 'encoded', // use |
|
| 4712 | +$server->register('WSGetUserFromUsername', // method name |
|
| 4713 | + array('GetUserFromUsername' => 'tns:GetUserArgUsername'), // input params |
|
| 4714 | + array('return' => 'tns:User'), // output parameters |
|
| 4715 | + 'urn:WSRegistration', // namespace |
|
| 4716 | + 'urn:WSRegistration#WSGetUserFromUsername', // soapaction |
|
| 4717 | + 'rpc', // style |
|
| 4718 | + 'encoded', // use |
|
| 4719 | 4719 | 'This service get user information by username' // documentation |
| 4720 | 4720 | ); |
| 4721 | 4721 | |
@@ -4756,10 +4756,10 @@ discard block |
||
| 4756 | 4756 | 'all', |
| 4757 | 4757 | '', |
| 4758 | 4758 | array( |
| 4759 | - 'original_user_id_values' => array('name' => 'original_user_id_values', 'type' => 'tns:originalUsersList'), |
|
| 4760 | - 'original_user_id_name' => array('name' => 'original_user_id_name', 'type' => 'xsd:string'), |
|
| 4761 | - 'original_course_id_value' => array('name' => 'original_course_id_value', 'type' => 'xsd:string'), |
|
| 4762 | - 'original_course_id_name' => array('name' => 'original_course_id_name', 'type' => 'xsd:string'), |
|
| 4759 | + 'original_user_id_values' => array('name' => 'original_user_id_values', 'type' => 'tns:originalUsersList'), |
|
| 4760 | + 'original_user_id_name' => array('name' => 'original_user_id_name', 'type' => 'xsd:string'), |
|
| 4761 | + 'original_course_id_value' => array('name' => 'original_course_id_value', 'type' => 'xsd:string'), |
|
| 4762 | + 'original_course_id_name' => array('name' => 'original_course_id_name', 'type' => 'xsd:string'), |
|
| 4763 | 4763 | ) |
| 4764 | 4764 | ); |
| 4765 | 4765 | |
@@ -4812,13 +4812,13 @@ discard block |
||
| 4812 | 4812 | ); |
| 4813 | 4813 | |
| 4814 | 4814 | // Register the method to expose |
| 4815 | -$server->register('WSUnsubscribeUserFromCourse', // method name |
|
| 4815 | +$server->register('WSUnsubscribeUserFromCourse', // method name |
|
| 4816 | 4816 | array('unsuscribeUserFromCourse' => 'tns:unsuscribeUserFromCourse'), // input parameters |
| 4817 | - array('return' => 'tns:results_unsuscribeUserFromCourse'), // output parameters |
|
| 4818 | - 'urn:WSRegistration', // namespace |
|
| 4819 | - 'urn:WSRegistration#WSUnsubscribeUserFromCourse', // soapaction |
|
| 4820 | - 'rpc', // style |
|
| 4821 | - 'encoded', // use |
|
| 4817 | + array('return' => 'tns:results_unsuscribeUserFromCourse'), // output parameters |
|
| 4818 | + 'urn:WSRegistration', // namespace |
|
| 4819 | + 'urn:WSRegistration#WSUnsubscribeUserFromCourse', // soapaction |
|
| 4820 | + 'rpc', // style |
|
| 4821 | + 'encoded', // use |
|
| 4822 | 4822 | 'This service unsubscribes a user from a course' // documentation |
| 4823 | 4823 | ); |
| 4824 | 4824 | |
@@ -4830,7 +4830,7 @@ discard block |
||
| 4830 | 4830 | } |
| 4831 | 4831 | |
| 4832 | 4832 | $user_table = Database::get_main_table(TABLE_MAIN_USER); |
| 4833 | - $table_course = Database :: get_main_table(TABLE_MAIN_COURSE); |
|
| 4833 | + $table_course = Database :: get_main_table(TABLE_MAIN_COURSE); |
|
| 4834 | 4834 | $table_course_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER); |
| 4835 | 4835 | |
| 4836 | 4836 | $userscourses_params = $params['userscourses']; |
@@ -4840,8 +4840,8 @@ discard block |
||
| 4840 | 4840 | foreach ($userscourses_params as $usercourse_param) { |
| 4841 | 4841 | |
| 4842 | 4842 | $original_user_id_values = $usercourse_param['original_user_id_values']; |
| 4843 | - $original_user_id_name = $usercourse_param['original_user_id_name']; |
|
| 4844 | - $original_course_id_value = $usercourse_param['original_course_id_value']; |
|
| 4843 | + $original_user_id_name = $usercourse_param['original_user_id_name']; |
|
| 4844 | + $original_course_id_value = $usercourse_param['original_course_id_value']; |
|
| 4845 | 4845 | $original_course_id_name = $usercourse_param['original_course_id_name']; |
| 4846 | 4846 | $orig_course_id_value[] = $original_course_id_value; |
| 4847 | 4847 | |
@@ -4862,7 +4862,7 @@ discard block |
||
| 4862 | 4862 | $usersList[] = $user_id; |
| 4863 | 4863 | } |
| 4864 | 4864 | |
| 4865 | - $orig_user_id_value[] = implode(',',$usersList); |
|
| 4865 | + $orig_user_id_value[] = implode(',', $usersList); |
|
| 4866 | 4866 | |
| 4867 | 4867 | $courseInfo = CourseManager::getCourseInfoFromOriginalId( |
| 4868 | 4868 | $original_course_id_value, |
@@ -4895,7 +4895,7 @@ discard block |
||
| 4895 | 4895 | |
| 4896 | 4896 | $count_results = count($results); |
| 4897 | 4897 | $output = array(); |
| 4898 | - for($i = 0; $i < $count_results; $i++) { |
|
| 4898 | + for ($i = 0; $i < $count_results; $i++) { |
|
| 4899 | 4899 | $output[] = array( |
| 4900 | 4900 | 'original_user_id_values' => $orig_user_id_value[$i], |
| 4901 | 4901 | 'original_course_id_value' => $orig_course_id_value[$i], |
@@ -4924,13 +4924,13 @@ discard block |
||
| 4924 | 4924 | |
| 4925 | 4925 | |
| 4926 | 4926 | // Register the method to expose |
| 4927 | -$server->register('WSUnSubscribeUserFromCourseSimple', // method name |
|
| 4927 | +$server->register('WSUnSubscribeUserFromCourseSimple', // method name |
|
| 4928 | 4928 | array('unSubscribeUserFromCourseSimple' => 'tns:unSubscribeUserFromCourseSimple'), // input parameters |
| 4929 | - array('return' => 'tns:result_createUsersPassEncrypt'), // output parameters |
|
| 4930 | - 'urn:WSRegistration', // namespace |
|
| 4931 | - 'urn:WSRegistration#WSUnSubscribeUserFromCourseSimple', // soapaction |
|
| 4932 | - 'rpc', // style |
|
| 4933 | - 'encoded', // use |
|
| 4929 | + array('return' => 'tns:result_createUsersPassEncrypt'), // output parameters |
|
| 4930 | + 'urn:WSRegistration', // namespace |
|
| 4931 | + 'urn:WSRegistration#WSUnSubscribeUserFromCourseSimple', // soapaction |
|
| 4932 | + 'rpc', // style |
|
| 4933 | + 'encoded', // use |
|
| 4934 | 4934 | 'This service unsubscribe a user from a course' // documentation |
| 4935 | 4935 | ); |
| 4936 | 4936 | /** |
@@ -5000,10 +5000,10 @@ discard block |
||
| 5000 | 5000 | 'all', |
| 5001 | 5001 | '', |
| 5002 | 5002 | array( |
| 5003 | - 'original_user_id_values' => array('name' => 'original_user_id_values', 'type' => 'tns:originalUsersList'), |
|
| 5004 | - 'original_user_id_name' => array('name' => 'original_user_id_name', 'type' => 'xsd:string'), |
|
| 5005 | - 'original_course_id_value' => array('name' => 'original_course_id_value', 'type' => 'xsd:string'), |
|
| 5006 | - 'original_course_id_name' => array('name' => 'original_course_id_value', 'type' => 'xsd:string') |
|
| 5003 | + 'original_user_id_values' => array('name' => 'original_user_id_values', 'type' => 'tns:originalUsersList'), |
|
| 5004 | + 'original_user_id_name' => array('name' => 'original_user_id_name', 'type' => 'xsd:string'), |
|
| 5005 | + 'original_course_id_value' => array('name' => 'original_course_id_value', 'type' => 'xsd:string'), |
|
| 5006 | + 'original_course_id_name' => array('name' => 'original_course_id_value', 'type' => 'xsd:string') |
|
| 5007 | 5007 | ) |
| 5008 | 5008 | ); |
| 5009 | 5009 | |
@@ -5097,13 +5097,13 @@ discard block |
||
| 5097 | 5097 | |
| 5098 | 5098 | |
| 5099 | 5099 | // Register the method to expose |
| 5100 | -$server->register('WSSuscribeUsersToSession', // method name |
|
| 5100 | +$server->register('WSSuscribeUsersToSession', // method name |
|
| 5101 | 5101 | array('subscribeUsersToSession' => 'tns:subscribeUsersToSession'), // input parameters |
| 5102 | - array('return' => 'tns:results_subscribeUsersToSession'), // output parameters |
|
| 5103 | - 'urn:WSRegistration', // namespace |
|
| 5104 | - 'urn:WSRegistration#WSSuscribeUsersToSession', // soapaction |
|
| 5105 | - 'rpc', // style |
|
| 5106 | - 'encoded', // use |
|
| 5102 | + array('return' => 'tns:results_subscribeUsersToSession'), // output parameters |
|
| 5103 | + 'urn:WSRegistration', // namespace |
|
| 5104 | + 'urn:WSRegistration#WSSuscribeUsersToSession', // soapaction |
|
| 5105 | + 'rpc', // style |
|
| 5106 | + 'encoded', // use |
|
| 5107 | 5107 | 'This service subscribes a user to a session' // documentation |
| 5108 | 5108 | ); |
| 5109 | 5109 | |
@@ -5180,7 +5180,7 @@ discard block |
||
| 5180 | 5180 | |
| 5181 | 5181 | $count_results = count($results); |
| 5182 | 5182 | $output = array(); |
| 5183 | - for($i = 0; $i < $count_results; $i++) { |
|
| 5183 | + for ($i = 0; $i < $count_results; $i++) { |
|
| 5184 | 5184 | $output[] = array( |
| 5185 | 5185 | 'original_user_id_values' => $orig_user_id_value[$i], |
| 5186 | 5186 | 'original_session_id_value' => $orig_session_id_value[$i], |
@@ -5200,25 +5200,25 @@ discard block |
||
| 5200 | 5200 | 'all', |
| 5201 | 5201 | '', |
| 5202 | 5202 | array( |
| 5203 | - 'session' => array('name' => 'session', 'type' => 'xsd:string'), // Session ID |
|
| 5204 | - 'user_id' => array('name' => 'user_id', 'type' => 'xsd:string'), // Chamilo user_id |
|
| 5203 | + 'session' => array('name' => 'session', 'type' => 'xsd:string'), // Session ID |
|
| 5204 | + 'user_id' => array('name' => 'user_id', 'type' => 'xsd:string'), // Chamilo user_id |
|
| 5205 | 5205 | 'secret_key' => array('name' => 'secret_key', 'type' => 'xsd:string') |
| 5206 | 5206 | ) |
| 5207 | 5207 | ); |
| 5208 | -$server->register('WSSubscribeUserToSessionSimple', // method name |
|
| 5209 | - array('subscribeUserToSessionSimple' => 'tns:subscribeUserToSessionSimple_arg'), // input parameters |
|
| 5210 | - array('return' => 'xsd:string'), // output parameters |
|
| 5211 | - 'urn:WSRegistration', // namespace |
|
| 5212 | - 'urn:WSRegistration#WSSubscribeUserToSessionSimple', // soapaction |
|
| 5213 | - 'rpc', // style |
|
| 5214 | - 'encoded', // use |
|
| 5208 | +$server->register('WSSubscribeUserToSessionSimple', // method name |
|
| 5209 | + array('subscribeUserToSessionSimple' => 'tns:subscribeUserToSessionSimple_arg'), // input parameters |
|
| 5210 | + array('return' => 'xsd:string'), // output parameters |
|
| 5211 | + 'urn:WSRegistration', // namespace |
|
| 5212 | + 'urn:WSRegistration#WSSubscribeUserToSessionSimple', // soapaction |
|
| 5213 | + 'rpc', // style |
|
| 5214 | + 'encoded', // use |
|
| 5215 | 5215 | 'This service subscribes a user to a session in a simple way' // documentation |
| 5216 | 5216 | ); |
| 5217 | 5217 | function WSSubscribeUserToSessionSimple($params) { |
| 5218 | 5218 | global $debug; |
| 5219 | 5219 | |
| 5220 | 5220 | if ($debug) { |
| 5221 | - error_log('WSSubscribeUserToSessionSimple with params=[' . serialize($params). ']'); |
|
| 5221 | + error_log('WSSubscribeUserToSessionSimple with params=['.serialize($params).']'); |
|
| 5222 | 5222 | } |
| 5223 | 5223 | |
| 5224 | 5224 | // Check security key |
@@ -5227,8 +5227,8 @@ discard block |
||
| 5227 | 5227 | } |
| 5228 | 5228 | |
| 5229 | 5229 | // Get input parameters |
| 5230 | - $session_id = intval($params['session']); // Session ID |
|
| 5231 | - $user_id = intval($params['user_id']); // Chamilo user id |
|
| 5230 | + $session_id = intval($params['session']); // Session ID |
|
| 5231 | + $user_id = intval($params['user_id']); // Chamilo user id |
|
| 5232 | 5232 | |
| 5233 | 5233 | // Get user id |
| 5234 | 5234 | $user_data = api_get_user_info($user_id); |
@@ -5329,13 +5329,13 @@ discard block |
||
| 5329 | 5329 | ); |
| 5330 | 5330 | |
| 5331 | 5331 | // Register the method to expose |
| 5332 | -$server->register('WSUnsuscribeUsersFromSession', // method name |
|
| 5332 | +$server->register('WSUnsuscribeUsersFromSession', // method name |
|
| 5333 | 5333 | array('unsubscribeUsersFromSession' => 'tns:unsubscribeUsersFromSession'), // input parameters |
| 5334 | - array('return' => 'tns:results_unsubscribeUsersFromSession'), // output parameters |
|
| 5335 | - 'urn:WSRegistration', // namespace |
|
| 5336 | - 'urn:WSRegistration#WSUnsuscribeUsersFromSession', // soapaction |
|
| 5337 | - 'rpc', // style |
|
| 5338 | - 'encoded', // use |
|
| 5334 | + array('return' => 'tns:results_unsubscribeUsersFromSession'), // output parameters |
|
| 5335 | + 'urn:WSRegistration', // namespace |
|
| 5336 | + 'urn:WSRegistration#WSUnsuscribeUsersFromSession', // soapaction |
|
| 5337 | + 'rpc', // style |
|
| 5338 | + 'encoded', // use |
|
| 5339 | 5339 | 'This service unsubscribes a user to a session' // documentation |
| 5340 | 5340 | ); |
| 5341 | 5341 | |
@@ -5349,7 +5349,7 @@ discard block |
||
| 5349 | 5349 | global $debug; |
| 5350 | 5350 | |
| 5351 | 5351 | if ($debug) { |
| 5352 | - error_log('WSUnsuscribeUsersFromSession with params=[' . serialize($params). ']'); |
|
| 5352 | + error_log('WSUnsuscribeUsersFromSession with params=['.serialize($params).']'); |
|
| 5353 | 5353 | } |
| 5354 | 5354 | |
| 5355 | 5355 | $user_table = Database::get_main_table(TABLE_MAIN_USER); |
@@ -5441,7 +5441,7 @@ discard block |
||
| 5441 | 5441 | 'all', |
| 5442 | 5442 | '', |
| 5443 | 5443 | array( |
| 5444 | - 'course_code' => array('name' => 'course_code', 'type' => 'xsd:string'), |
|
| 5444 | + 'course_code' => array('name' => 'course_code', 'type' => 'xsd:string'), |
|
| 5445 | 5445 | ) |
| 5446 | 5446 | ); |
| 5447 | 5447 | |
@@ -5477,9 +5477,9 @@ discard block |
||
| 5477 | 5477 | '', |
| 5478 | 5478 | array( |
| 5479 | 5479 | 'original_course_id_values' => array('name' => 'original_course_id_values', 'type' => 'tns:originalCoursesList'), |
| 5480 | - 'original_course_id_name' => array('name' => 'original_course_id_name', 'type' => 'xsd:string'), |
|
| 5480 | + 'original_course_id_name' => array('name' => 'original_course_id_name', 'type' => 'xsd:string'), |
|
| 5481 | 5481 | 'original_session_id_value' => array('name' => 'original_session_id_value', 'type' => 'xsd:string'), |
| 5482 | - 'original_session_id_name' => array('name' => 'original_session_id_name', 'type' => 'xsd:string') |
|
| 5482 | + 'original_session_id_name' => array('name' => 'original_session_id_name', 'type' => 'xsd:string') |
|
| 5483 | 5483 | ) |
| 5484 | 5484 | ); |
| 5485 | 5485 | |
@@ -5532,13 +5532,13 @@ discard block |
||
| 5532 | 5532 | ); |
| 5533 | 5533 | |
| 5534 | 5534 | // Register the method to expose |
| 5535 | -$server->register('WSSuscribeCoursesToSession', // method name |
|
| 5535 | +$server->register('WSSuscribeCoursesToSession', // method name |
|
| 5536 | 5536 | array('subscribeCoursesToSession' => 'tns:subscribeCoursesToSession'), // input parameters |
| 5537 | - array('return' => 'tns:results_subscribeCoursesToSession'), // output parameters |
|
| 5538 | - 'urn:WSRegistration', // namespace |
|
| 5539 | - 'urn:WSRegistration#WSSuscribeCoursesToSession', // soapaction |
|
| 5540 | - 'rpc', // style |
|
| 5541 | - 'encoded', // use |
|
| 5537 | + array('return' => 'tns:results_subscribeCoursesToSession'), // output parameters |
|
| 5538 | + 'urn:WSRegistration', // namespace |
|
| 5539 | + 'urn:WSRegistration#WSSuscribeCoursesToSession', // soapaction |
|
| 5540 | + 'rpc', // style |
|
| 5541 | + 'encoded', // use |
|
| 5542 | 5542 | 'This service subscribes a course to a session' // documentation |
| 5543 | 5543 | ); |
| 5544 | 5544 | |
@@ -5676,13 +5676,13 @@ discard block |
||
| 5676 | 5676 | |
| 5677 | 5677 | |
| 5678 | 5678 | // Register the method to expose |
| 5679 | -$server->register('WSUnsuscribeCoursesFromSession', // method name |
|
| 5679 | +$server->register('WSUnsuscribeCoursesFromSession', // method name |
|
| 5680 | 5680 | array('unsubscribeCoursesFromSession' => 'tns:unsubscribeCoursesFromSession'), // input parameters |
| 5681 | - array('return' => 'tns:results_unsubscribeCoursesFromSession'), // output parameters |
|
| 5682 | - 'urn:WSRegistration', // namespace |
|
| 5683 | - 'urn:WSRegistration#WSUnsuscribeCoursesFromSession', // soapaction |
|
| 5684 | - 'rpc', // style |
|
| 5685 | - 'encoded', // use |
|
| 5681 | + array('return' => 'tns:results_unsubscribeCoursesFromSession'), // output parameters |
|
| 5682 | + 'urn:WSRegistration', // namespace |
|
| 5683 | + 'urn:WSRegistration#WSUnsuscribeCoursesFromSession', // soapaction |
|
| 5684 | + 'rpc', // style |
|
| 5685 | + 'encoded', // use |
|
| 5686 | 5686 | 'This service subscribes a course to a session' // documentation |
| 5687 | 5687 | ); |
| 5688 | 5688 | |
@@ -5789,7 +5789,7 @@ discard block |
||
| 5789 | 5789 | |
| 5790 | 5790 | $count_results = count($results); |
| 5791 | 5791 | $output = array(); |
| 5792 | - for($i = 0; $i < $count_results; $i++) { |
|
| 5792 | + for ($i = 0; $i < $count_results; $i++) { |
|
| 5793 | 5793 | $output[] = array( |
| 5794 | 5794 | 'original_course_id_values' => $orig_course_id_value[$i], |
| 5795 | 5795 | 'original_session_id_value' => $orig_session_id_value[$i], |
@@ -5847,13 +5847,13 @@ discard block |
||
| 5847 | 5847 | |
| 5848 | 5848 | |
| 5849 | 5849 | // Register the method to expose |
| 5850 | -$server->register('WSListCourses', // method name |
|
| 5850 | +$server->register('WSListCourses', // method name |
|
| 5851 | 5851 | array('listCourseInput' => 'tns:listCourseInput'), // input parameters |
| 5852 | - array('return' => 'tns:courses'), // output parameters |
|
| 5853 | - 'urn:WSRegistration', // namespace |
|
| 5854 | - 'urn:WSRegistration#WSListCourses', // soapaction |
|
| 5855 | - 'rpc', // style |
|
| 5856 | - 'encoded', // use |
|
| 5852 | + array('return' => 'tns:courses'), // output parameters |
|
| 5853 | + 'urn:WSRegistration', // namespace |
|
| 5854 | + 'urn:WSRegistration#WSListCourses', // soapaction |
|
| 5855 | + 'rpc', // style |
|
| 5856 | + 'encoded', // use |
|
| 5857 | 5857 | 'This service list courses available on the system' // documentation |
| 5858 | 5858 | ); |
| 5859 | 5859 | |
@@ -5933,27 +5933,27 @@ discard block |
||
| 5933 | 5933 | 'all', |
| 5934 | 5934 | '', |
| 5935 | 5935 | array( |
| 5936 | - 'original_user_id_name' => array('name' => 'original_user_id_name', 'type' => 'xsd:string'), |
|
| 5937 | - 'original_user_id_value' => array('name' => 'original_user_id_value', 'type' => 'xsd:string'), |
|
| 5938 | - 'chamilo_username' => array('name' => 'chamilo_username', 'type' => 'xsd:string'), |
|
| 5939 | - 'secret_key' => array('name' => 'secret_key', 'type' => 'xsd:string') |
|
| 5936 | + 'original_user_id_name' => array('name' => 'original_user_id_name', 'type' => 'xsd:string'), |
|
| 5937 | + 'original_user_id_value' => array('name' => 'original_user_id_value', 'type' => 'xsd:string'), |
|
| 5938 | + 'chamilo_username' => array('name' => 'chamilo_username', 'type' => 'xsd:string'), |
|
| 5939 | + 'secret_key' => array('name' => 'secret_key', 'type' => 'xsd:string') |
|
| 5940 | 5940 | ) |
| 5941 | 5941 | ); |
| 5942 | 5942 | |
| 5943 | 5943 | // Register the method to expose |
| 5944 | -$server->register('WSUpdateUserApiKey', // method name |
|
| 5944 | +$server->register('WSUpdateUserApiKey', // method name |
|
| 5945 | 5945 | array('userApiKey' => 'tns:userApiKey'), // input parameters |
| 5946 | - array('return' => 'xsd:string'), // output parameters |
|
| 5947 | - 'urn:WSRegistration', // namespace |
|
| 5948 | - 'urn:WSRegistration#WSListCourses', // soapaction |
|
| 5949 | - 'rpc', // style |
|
| 5950 | - 'encoded', // use |
|
| 5946 | + array('return' => 'xsd:string'), // output parameters |
|
| 5947 | + 'urn:WSRegistration', // namespace |
|
| 5948 | + 'urn:WSRegistration#WSListCourses', // soapaction |
|
| 5949 | + 'rpc', // style |
|
| 5950 | + 'encoded', // use |
|
| 5951 | 5951 | 'This service return user api key' // documentation |
| 5952 | 5952 | ); |
| 5953 | 5953 | |
| 5954 | 5954 | |
| 5955 | 5955 | function WSUpdateUserApiKey($params) { |
| 5956 | - if(!WSHelperVerifyKey($params)) { |
|
| 5956 | + if (!WSHelperVerifyKey($params)) { |
|
| 5957 | 5957 | return returnError(WS_ERROR_SECRET_KEY); |
| 5958 | 5958 | } |
| 5959 | 5959 | |
@@ -5995,11 +5995,11 @@ discard block |
||
| 5995 | 5995 | 'all', |
| 5996 | 5996 | '', |
| 5997 | 5997 | array( |
| 5998 | - 'from' => array('name' => 'from', 'type' => 'xsd:int'), |
|
| 5999 | - 'to' => array('name' => 'to', 'type' => 'xsd:int'), |
|
| 6000 | - 'date_start' => array('name' => 'date_start', 'type' => 'xsd:string'), |
|
| 6001 | - 'date_end' => array('name' => 'date_end', 'type' => 'xsd:string'), |
|
| 6002 | - 'secret_key' => array('name' => 'secret_key', 'type' => 'xsd:string') |
|
| 5998 | + 'from' => array('name' => 'from', 'type' => 'xsd:int'), |
|
| 5999 | + 'to' => array('name' => 'to', 'type' => 'xsd:int'), |
|
| 6000 | + 'date_start' => array('name' => 'date_start', 'type' => 'xsd:string'), |
|
| 6001 | + 'date_end' => array('name' => 'date_end', 'type' => 'xsd:string'), |
|
| 6002 | + 'secret_key' => array('name' => 'secret_key', 'type' => 'xsd:string') |
|
| 6003 | 6003 | ) |
| 6004 | 6004 | ); |
| 6005 | 6005 | |
@@ -6010,11 +6010,11 @@ discard block |
||
| 6010 | 6010 | 'all', |
| 6011 | 6011 | '', |
| 6012 | 6012 | array( |
| 6013 | - 'id' => array ('name' => 'id' , 'type' => 'xsd:int'), |
|
| 6014 | - 'title' => array ('name' => 'title', 'type' => 'xsd:string'), |
|
| 6015 | - 'url' => array ('name' => 'url', 'type' => 'xsd:string'), |
|
| 6016 | - 'date_start' => array ('name' => 'date_start', 'type' => 'xsd:string'), |
|
| 6017 | - 'date_end' => array ('name' => 'date_end', 'type' => 'xsd:string'), |
|
| 6013 | + 'id' => array('name' => 'id', 'type' => 'xsd:int'), |
|
| 6014 | + 'title' => array('name' => 'title', 'type' => 'xsd:string'), |
|
| 6015 | + 'url' => array('name' => 'url', 'type' => 'xsd:string'), |
|
| 6016 | + 'date_start' => array('name' => 'date_start', 'type' => 'xsd:string'), |
|
| 6017 | + 'date_end' => array('name' => 'date_end', 'type' => 'xsd:string'), |
|
| 6018 | 6018 | ) |
| 6019 | 6019 | ); |
| 6020 | 6020 | |
@@ -6033,13 +6033,13 @@ discard block |
||
| 6033 | 6033 | ); |
| 6034 | 6034 | |
| 6035 | 6035 | // Register the method to expose |
| 6036 | -$server->register('WSListSessions', // method name |
|
| 6037 | - array('input' => 'tns:session_arg'), // input parameters |
|
| 6038 | - array('return' => 'tns:sessions'), // output parameters |
|
| 6039 | - 'urn:WSRegistration', // namespace |
|
| 6040 | - 'urn:WSRegistration#WSListSessions', // soapaction |
|
| 6041 | - 'rpc', // style |
|
| 6042 | - 'encoded', // use |
|
| 6036 | +$server->register('WSListSessions', // method name |
|
| 6037 | + array('input' => 'tns:session_arg'), // input parameters |
|
| 6038 | + array('return' => 'tns:sessions'), // output parameters |
|
| 6039 | + 'urn:WSRegistration', // namespace |
|
| 6040 | + 'urn:WSRegistration#WSListSessions', // soapaction |
|
| 6041 | + 'rpc', // style |
|
| 6042 | + 'encoded', // use |
|
| 6043 | 6043 | 'This service returns a list of sessions' // documentation |
| 6044 | 6044 | ); |
| 6045 | 6045 | |
@@ -6097,20 +6097,20 @@ discard block |
||
| 6097 | 6097 | 'all', |
| 6098 | 6098 | '', |
| 6099 | 6099 | array( |
| 6100 | - 'course' => array('name' => 'course', 'type' => 'xsd:string'), //Course string code |
|
| 6101 | - 'user_id' => array('name' => 'user_id', 'type' => 'xsd:string'), //Chamilo user_id |
|
| 6100 | + 'course' => array('name' => 'course', 'type' => 'xsd:string'), //Course string code |
|
| 6101 | + 'user_id' => array('name' => 'user_id', 'type' => 'xsd:string'), //Chamilo user_id |
|
| 6102 | 6102 | 'secret_key' => array('name' => 'secret_key', 'type' => 'xsd:string') |
| 6103 | 6103 | ) |
| 6104 | 6104 | ); |
| 6105 | 6105 | |
| 6106 | 6106 | // Register the method to expose |
| 6107 | -$server->register('WSUserSubscribedInCourse', // method name |
|
| 6108 | - array('UserSubscribedInCourse' => 'tns:UserSubscribedInCourse'), // input parameters |
|
| 6109 | - array('return' => 'xsd:string'), // output parameters |
|
| 6110 | - 'urn:WSRegistration', // namespace |
|
| 6111 | - 'urn:WSRegistration#WSUserSubscribedInCourse', // soapaction |
|
| 6112 | - 'rpc', // style |
|
| 6113 | - 'encoded', // use |
|
| 6107 | +$server->register('WSUserSubscribedInCourse', // method name |
|
| 6108 | + array('UserSubscribedInCourse' => 'tns:UserSubscribedInCourse'), // input parameters |
|
| 6109 | + array('return' => 'xsd:string'), // output parameters |
|
| 6110 | + 'urn:WSRegistration', // namespace |
|
| 6111 | + 'urn:WSRegistration#WSUserSubscribedInCourse', // soapaction |
|
| 6112 | + 'rpc', // style |
|
| 6113 | + 'encoded', // use |
|
| 6114 | 6114 | 'This service checks if user assigned to course' // documentation |
| 6115 | 6115 | ); |
| 6116 | 6116 | |
@@ -6124,7 +6124,7 @@ discard block |
||
| 6124 | 6124 | global $debug; |
| 6125 | 6125 | |
| 6126 | 6126 | if ($debug) error_log('WSUserSubscribedInCourse'); |
| 6127 | - if ($debug) error_log('Params '. print_r($params, 1)); |
|
| 6127 | + if ($debug) error_log('Params '.print_r($params, 1)); |
|
| 6128 | 6128 | if (!WSHelperVerifyKey($params)) { |
| 6129 | 6129 | |
| 6130 | 6130 | return returnError(WS_ERROR_SECRET_KEY); |
@@ -6132,7 +6132,7 @@ discard block |
||
| 6132 | 6132 | $courseCode = $params['course']; //Course code |
| 6133 | 6133 | $userId = $params['user_id']; //chamilo user id |
| 6134 | 6134 | |
| 6135 | - return (CourseManager::is_user_subscribed_in_course($userId,$courseCode)); |
|
| 6135 | + return (CourseManager::is_user_subscribed_in_course($userId, $courseCode)); |
|
| 6136 | 6136 | } |
| 6137 | 6137 | |
| 6138 | 6138 | |
@@ -6160,8 +6160,8 @@ discard block |
||
| 6160 | 6160 | 'all', |
| 6161 | 6161 | '', |
| 6162 | 6162 | array( |
| 6163 | - 'variable' => array('name'=>'variable','type'=>'xsd:string'), |
|
| 6164 | - 'value' => array('name'=>'value','type'=>'xsd:string') |
|
| 6163 | + 'variable' => array('name'=>'variable', 'type'=>'xsd:string'), |
|
| 6164 | + 'value' => array('name'=>'value', 'type'=>'xsd:string') |
|
| 6165 | 6165 | ) |
| 6166 | 6166 | ); |
| 6167 | 6167 | |
@@ -6223,12 +6223,12 @@ discard block |
||
| 6223 | 6223 | //Reister WSSearchSession |
| 6224 | 6224 | $server->register( |
| 6225 | 6225 | 'WSSearchSession', |
| 6226 | - array('SearchSession' => 'tns:SearchSession'), // input parameters |
|
| 6227 | - array('return' => 'tns:searchedSessionList'), // output parameters |
|
| 6228 | - 'urn:WSRegistration', // namespace |
|
| 6229 | - 'urn:WSRegistration#WSSearchSession', // soapaction |
|
| 6230 | - 'rpc', // style |
|
| 6231 | - 'encoded', // use |
|
| 6226 | + array('SearchSession' => 'tns:SearchSession'), // input parameters |
|
| 6227 | + array('return' => 'tns:searchedSessionList'), // output parameters |
|
| 6228 | + 'urn:WSRegistration', // namespace |
|
| 6229 | + 'urn:WSRegistration#WSSearchSession', // soapaction |
|
| 6230 | + 'rpc', // style |
|
| 6231 | + 'encoded', // use |
|
| 6232 | 6232 | 'This service to get a session list filtered by name, description or short description extra field' // documentation |
| 6233 | 6233 | ); |
| 6234 | 6234 | |
@@ -6283,12 +6283,12 @@ discard block |
||
| 6283 | 6283 | //Reister WSFetchSession |
| 6284 | 6284 | $server->register( |
| 6285 | 6285 | 'WSFetchSession', |
| 6286 | - array('SearchSession' => 'tns:FetchSession'), // input parameters |
|
| 6287 | - array('return' => 'tns:searchedSessionList'), // output parameters |
|
| 6288 | - 'urn:WSRegistration', // namespace |
|
| 6289 | - 'urn:WSRegistration#WSFetchSession', // soapaction |
|
| 6290 | - 'rpc', // style |
|
| 6291 | - 'encoded', // use |
|
| 6286 | + array('SearchSession' => 'tns:FetchSession'), // input parameters |
|
| 6287 | + array('return' => 'tns:searchedSessionList'), // output parameters |
|
| 6288 | + 'urn:WSRegistration', // namespace |
|
| 6289 | + 'urn:WSRegistration#WSFetchSession', // soapaction |
|
| 6290 | + 'rpc', // style |
|
| 6291 | + 'encoded', // use |
|
| 6292 | 6292 | 'This service get a session by its id. Optionally can get its extra fields values' // documentation |
| 6293 | 6293 | ); |
| 6294 | 6294 | |
@@ -6365,16 +6365,16 @@ discard block |
||
| 6365 | 6365 | ); |
| 6366 | 6366 | // Register the method to expose |
| 6367 | 6367 | $server->register( |
| 6368 | - 'WSCertificatesList', // method name |
|
| 6368 | + 'WSCertificatesList', // method name |
|
| 6369 | 6369 | array( |
| 6370 | - 'startingDate' => 'xsd:string', // input parameters |
|
| 6370 | + 'startingDate' => 'xsd:string', // input parameters |
|
| 6371 | 6371 | 'endingDate' => 'xsd:string' |
| 6372 | 6372 | ), |
| 6373 | - array('return' => 'tns:certificatesList'), // output parameters |
|
| 6374 | - 'urn:WSRegistration', // namespace |
|
| 6375 | - 'urn:WSRegistration#WSCertificatesList', // soapaction |
|
| 6376 | - 'rpc', // style |
|
| 6377 | - 'encoded', // use |
|
| 6373 | + array('return' => 'tns:certificatesList'), // output parameters |
|
| 6374 | + 'urn:WSRegistration', // namespace |
|
| 6375 | + 'urn:WSRegistration#WSCertificatesList', // soapaction |
|
| 6376 | + 'rpc', // style |
|
| 6377 | + 'encoded', // use |
|
| 6378 | 6378 | 'This service returns a list of certificates' // documentation |
| 6379 | 6379 | ); |
| 6380 | 6380 | |
@@ -6440,13 +6440,13 @@ discard block |
||
| 6440 | 6440 | ); |
| 6441 | 6441 | |
| 6442 | 6442 | // Register the method to expose |
| 6443 | -$server->register('WSCreateGroup', // method name |
|
| 6444 | - array('createGroup' => 'tns:createGroup'), // input parameters |
|
| 6445 | - array('return' => 'xsd:string'), // output parameters |
|
| 6446 | - 'urn:WSRegistration', // namespace |
|
| 6447 | - 'urn:WSRegistration#WSCreateGroup', // soapaction |
|
| 6448 | - 'rpc', // style |
|
| 6449 | - 'encoded', // use |
|
| 6443 | +$server->register('WSCreateGroup', // method name |
|
| 6444 | + array('createGroup' => 'tns:createGroup'), // input parameters |
|
| 6445 | + array('return' => 'xsd:string'), // output parameters |
|
| 6446 | + 'urn:WSRegistration', // namespace |
|
| 6447 | + 'urn:WSRegistration#WSCreateGroup', // soapaction |
|
| 6448 | + 'rpc', // style |
|
| 6449 | + 'encoded', // use |
|
| 6450 | 6450 | 'This service adds a group' // documentation |
| 6451 | 6451 | ); |
| 6452 | 6452 | |
@@ -6489,13 +6489,13 @@ discard block |
||
| 6489 | 6489 | ); |
| 6490 | 6490 | |
| 6491 | 6491 | // Register the method to expose |
| 6492 | -$server->register('WSUpdateGroup', // method name |
|
| 6493 | - array('updateGroup' => 'tns:updateGroup'), // input parameters |
|
| 6494 | - array('return' => 'xsd:string'), // output parameters |
|
| 6495 | - 'urn:WSRegistration', // namespace |
|
| 6496 | - 'urn:WSRegistration#WSUpdateGroup', // soapaction |
|
| 6497 | - 'rpc', // style |
|
| 6498 | - 'encoded', // use |
|
| 6492 | +$server->register('WSUpdateGroup', // method name |
|
| 6493 | + array('updateGroup' => 'tns:updateGroup'), // input parameters |
|
| 6494 | + array('return' => 'xsd:string'), // output parameters |
|
| 6495 | + 'urn:WSRegistration', // namespace |
|
| 6496 | + 'urn:WSRegistration#WSUpdateGroup', // soapaction |
|
| 6497 | + 'rpc', // style |
|
| 6498 | + 'encoded', // use |
|
| 6499 | 6499 | 'This service updates a group' // documentation |
| 6500 | 6500 | ); |
| 6501 | 6501 | |
@@ -6540,13 +6540,13 @@ discard block |
||
| 6540 | 6540 | ); |
| 6541 | 6541 | |
| 6542 | 6542 | // Register the method to expose |
| 6543 | -$server->register('WSDeleteGroup', // method name |
|
| 6544 | - array('deleteGroup' => 'tns:deleteGroup'), // input parameters |
|
| 6545 | - array('return' => 'xsd:string'), // output parameters |
|
| 6546 | - 'urn:WSRegistration', // namespace |
|
| 6547 | - 'urn:WSRegistration#WSDeleteGroup', // soapaction |
|
| 6548 | - 'rpc', // style |
|
| 6549 | - 'encoded', // use |
|
| 6543 | +$server->register('WSDeleteGroup', // method name |
|
| 6544 | + array('deleteGroup' => 'tns:deleteGroup'), // input parameters |
|
| 6545 | + array('return' => 'xsd:string'), // output parameters |
|
| 6546 | + 'urn:WSRegistration', // namespace |
|
| 6547 | + 'urn:WSRegistration#WSDeleteGroup', // soapaction |
|
| 6548 | + 'rpc', // style |
|
| 6549 | + 'encoded', // use |
|
| 6550 | 6550 | 'This service deletes a group' // documentation |
| 6551 | 6551 | ); |
| 6552 | 6552 | |
@@ -6583,13 +6583,13 @@ discard block |
||
| 6583 | 6583 | ); |
| 6584 | 6584 | |
| 6585 | 6585 | // Register the method to expose |
| 6586 | -$server->register('GroupBindToParent', // method name |
|
| 6587 | - array('groupBindToParent' => 'tns:groupBindToParent'), // input parameters |
|
| 6588 | - array('return' => 'xsd:string'), // output parameters |
|
| 6589 | - 'urn:WSRegistration', // namespace |
|
| 6590 | - 'urn:WSRegistration#GroupBindToParent', // soapaction |
|
| 6591 | - 'rpc', // style |
|
| 6592 | - 'encoded', // use |
|
| 6586 | +$server->register('GroupBindToParent', // method name |
|
| 6587 | + array('groupBindToParent' => 'tns:groupBindToParent'), // input parameters |
|
| 6588 | + array('return' => 'xsd:string'), // output parameters |
|
| 6589 | + 'urn:WSRegistration', // namespace |
|
| 6590 | + 'urn:WSRegistration#GroupBindToParent', // soapaction |
|
| 6591 | + 'rpc', // style |
|
| 6592 | + 'encoded', // use |
|
| 6593 | 6593 | 'This service binds a group to a parent' // documentation |
| 6594 | 6594 | ); |
| 6595 | 6595 | |
@@ -6625,13 +6625,13 @@ discard block |
||
| 6625 | 6625 | ); |
| 6626 | 6626 | |
| 6627 | 6627 | // Register the method to expose |
| 6628 | -$server->register('GroupUnbindFromParent', // method name |
|
| 6629 | - array('groupUnbindFromParent' => 'tns:groupUnbindFromParent'), // input parameters |
|
| 6630 | - array('return' => 'xsd:string'), // output parameters |
|
| 6631 | - 'urn:WSRegistration', // namespace |
|
| 6632 | - 'urn:WSRegistration#GroupUnbindFromParent', // soapaction |
|
| 6633 | - 'rpc', // style |
|
| 6634 | - 'encoded', // use |
|
| 6628 | +$server->register('GroupUnbindFromParent', // method name |
|
| 6629 | + array('groupUnbindFromParent' => 'tns:groupUnbindFromParent'), // input parameters |
|
| 6630 | + array('return' => 'xsd:string'), // output parameters |
|
| 6631 | + 'urn:WSRegistration', // namespace |
|
| 6632 | + 'urn:WSRegistration#GroupUnbindFromParent', // soapaction |
|
| 6633 | + 'rpc', // style |
|
| 6634 | + 'encoded', // use |
|
| 6635 | 6635 | 'This service unbinds a group from its parent' // documentation |
| 6636 | 6636 | ); |
| 6637 | 6637 | |
@@ -6665,13 +6665,13 @@ discard block |
||
| 6665 | 6665 | ); |
| 6666 | 6666 | |
| 6667 | 6667 | // Register the method to expose |
| 6668 | -$server->register('WSAddUserToGroup', // method name |
|
| 6669 | - array('addUserToGroup' => 'tns:addUserToGroup'), // input parameters |
|
| 6670 | - array('return' => 'xsd:string'), // output parameters |
|
| 6671 | - 'urn:WSRegistration', // namespace |
|
| 6672 | - 'urn:WSRegistration#WSAddUserToGroup', // soapaction |
|
| 6673 | - 'rpc', // style |
|
| 6674 | - 'encoded', // use |
|
| 6668 | +$server->register('WSAddUserToGroup', // method name |
|
| 6669 | + array('addUserToGroup' => 'tns:addUserToGroup'), // input parameters |
|
| 6670 | + array('return' => 'xsd:string'), // output parameters |
|
| 6671 | + 'urn:WSRegistration', // namespace |
|
| 6672 | + 'urn:WSRegistration#WSAddUserToGroup', // soapaction |
|
| 6673 | + 'rpc', // style |
|
| 6674 | + 'encoded', // use |
|
| 6675 | 6675 | 'This service adds a user to a group' // documentation |
| 6676 | 6676 | ); |
| 6677 | 6677 | |
@@ -6708,13 +6708,13 @@ discard block |
||
| 6708 | 6708 | ); |
| 6709 | 6709 | |
| 6710 | 6710 | // Register the method to expose |
| 6711 | -$server->register('WSUpdateUserRoleInGroup', // method name |
|
| 6712 | - array('updateUserRoleInGroup' => 'tns:updateUserRoleInGroup'), // input parameters |
|
| 6713 | - array('return' => 'xsd:string'), // output parameters |
|
| 6714 | - 'urn:WSRegistration', // namespace |
|
| 6715 | - 'urn:WSRegistration#WSUpdateUserRoleInGroup', // soapaction |
|
| 6716 | - 'rpc', // style |
|
| 6717 | - 'encoded', // use |
|
| 6711 | +$server->register('WSUpdateUserRoleInGroup', // method name |
|
| 6712 | + array('updateUserRoleInGroup' => 'tns:updateUserRoleInGroup'), // input parameters |
|
| 6713 | + array('return' => 'xsd:string'), // output parameters |
|
| 6714 | + 'urn:WSRegistration', // namespace |
|
| 6715 | + 'urn:WSRegistration#WSUpdateUserRoleInGroup', // soapaction |
|
| 6716 | + 'rpc', // style |
|
| 6717 | + 'encoded', // use |
|
| 6718 | 6718 | 'This service updates a user role in group' // documentation |
| 6719 | 6719 | ); |
| 6720 | 6720 | |
@@ -6753,13 +6753,13 @@ discard block |
||
| 6753 | 6753 | ); |
| 6754 | 6754 | |
| 6755 | 6755 | // Register the method to expose |
| 6756 | -$server->register('WSDeleteUserFromGroup', // method name |
|
| 6757 | - array('deleteUserFromGroup' => 'tns:deleteUserFromGroup'), // input parameters |
|
| 6758 | - array('return' => 'xsd:string'), // output parameters |
|
| 6759 | - 'urn:WSRegistration', // namespace |
|
| 6760 | - 'urn:WSRegistration#WSDeleteUserFromGroup', // soapaction |
|
| 6761 | - 'rpc', // style |
|
| 6762 | - 'encoded', // use |
|
| 6756 | +$server->register('WSDeleteUserFromGroup', // method name |
|
| 6757 | + array('deleteUserFromGroup' => 'tns:deleteUserFromGroup'), // input parameters |
|
| 6758 | + array('return' => 'xsd:string'), // output parameters |
|
| 6759 | + 'urn:WSRegistration', // namespace |
|
| 6760 | + 'urn:WSRegistration#WSDeleteUserFromGroup', // soapaction |
|
| 6761 | + 'rpc', // style |
|
| 6762 | + 'encoded', // use |
|
| 6763 | 6763 | 'This service deletes a user from a group' // documentation |
| 6764 | 6764 | ); |
| 6765 | 6765 | |
@@ -63,19 +63,22 @@ discard block |
||
| 63 | 63 | list($ip1) = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']); |
| 64 | 64 | $ip = trim($ip1); |
| 65 | 65 | } |
| 66 | - if ($debug) |
|
| 67 | - error_log("ip: $ip"); |
|
| 66 | + if ($debug) { |
|
| 67 | + error_log("ip: $ip"); |
|
| 68 | + } |
|
| 68 | 69 | // Check if a file that limits access from webservices exists and contains |
| 69 | 70 | // the restraining check |
| 70 | 71 | if (is_file('webservice-auth-ip.conf.php')) { |
| 71 | 72 | include 'webservice-auth-ip.conf.php'; |
| 72 | - if ($debug) |
|
| 73 | - error_log("webservice-auth-ip.conf.php file included"); |
|
| 73 | + if ($debug) { |
|
| 74 | + error_log("webservice-auth-ip.conf.php file included"); |
|
| 75 | + } |
|
| 74 | 76 | if (!empty($ws_auth_ip)) { |
| 75 | 77 | $check_ip = true; |
| 76 | 78 | $ip_matches = api_check_ip_in_range($ip, $ws_auth_ip); |
| 77 | - if ($debug) |
|
| 78 | - error_log("ip_matches: $ip_matches"); |
|
| 79 | + if ($debug) { |
|
| 80 | + error_log("ip_matches: $ip_matches"); |
|
| 81 | + } |
|
| 79 | 82 | } |
| 80 | 83 | } |
| 81 | 84 | |
@@ -92,8 +95,9 @@ discard block |
||
| 92 | 95 | |
| 93 | 96 | $result = api_is_valid_secret_key($secret_key, $security_key); |
| 94 | 97 | |
| 95 | - if ($debug) |
|
| 96 | - error_log('WSHelperVerifyKey result: '.intval($result)); |
|
| 98 | + if ($debug) { |
|
| 99 | + error_log('WSHelperVerifyKey result: '.intval($result)); |
|
| 100 | + } |
|
| 97 | 101 | return $result; |
| 98 | 102 | } |
| 99 | 103 | |
@@ -553,7 +557,9 @@ discard block |
||
| 553 | 557 | |
| 554 | 558 | // First check wether the login already exists |
| 555 | 559 | if (!UserManager::is_username_available($loginName)) { |
| 556 | - if ($debug) error_log("Username $loginName is not available"); |
|
| 560 | + if ($debug) { |
|
| 561 | + error_log("Username $loginName is not available"); |
|
| 562 | + } |
|
| 557 | 563 | return 0; |
| 558 | 564 | } |
| 559 | 565 | |
@@ -1012,7 +1018,9 @@ discard block |
||
| 1012 | 1018 | if (empty($userId) && empty($sessionId) && empty($courseId)) { |
| 1013 | 1019 | // try original values |
| 1014 | 1020 | |
| 1015 | - if ($debug) error_log('try original values'); |
|
| 1021 | + if ($debug) { |
|
| 1022 | + error_log('try original values'); |
|
| 1023 | + } |
|
| 1016 | 1024 | |
| 1017 | 1025 | $userIdName = isset($params['original_user_id_name']) ? $params['original_user_id_name'] : 0; |
| 1018 | 1026 | $userIdValue = isset($params['original_user_id_value']) ? $params['original_user_id_value'] : 0; |
@@ -1044,9 +1052,15 @@ discard block |
||
| 1044 | 1052 | ); |
| 1045 | 1053 | } |
| 1046 | 1054 | |
| 1047 | - if ($debug) error_log('$userId found: '. $userId); |
|
| 1048 | - if ($debug) error_log('$courseId found: '. $courseId); |
|
| 1049 | - if ($debug) error_log('$sessionId found: '. $sessionId); |
|
| 1055 | + if ($debug) { |
|
| 1056 | + error_log('$userId found: '. $userId); |
|
| 1057 | + } |
|
| 1058 | + if ($debug) { |
|
| 1059 | + error_log('$courseId found: '. $courseId); |
|
| 1060 | + } |
|
| 1061 | + if ($debug) { |
|
| 1062 | + error_log('$sessionId found: '. $sessionId); |
|
| 1063 | + } |
|
| 1050 | 1064 | |
| 1051 | 1065 | return [ |
| 1052 | 1066 | 'user_id' => $userId, |
@@ -1076,13 +1090,17 @@ discard block |
||
| 1076 | 1090 | { |
| 1077 | 1091 | global $debug; |
| 1078 | 1092 | |
| 1079 | - if ($debug) error_log('WSSubscribeTeacherToSessionCourse'); |
|
| 1093 | + if ($debug) { |
|
| 1094 | + error_log('WSSubscribeTeacherToSessionCourse'); |
|
| 1095 | + } |
|
| 1080 | 1096 | |
| 1081 | 1097 | if (!WSHelperVerifyKey($params)) { |
| 1082 | 1098 | return returnError(WS_ERROR_SECRET_KEY); |
| 1083 | 1099 | } |
| 1084 | 1100 | |
| 1085 | - if ($debug) error_log('Params '. print_r($params, 1)); |
|
| 1101 | + if ($debug) { |
|
| 1102 | + error_log('Params '. print_r($params, 1)); |
|
| 1103 | + } |
|
| 1086 | 1104 | |
| 1087 | 1105 | $params = parseCourseSessionUserParams($params); |
| 1088 | 1106 | |
@@ -1095,13 +1113,17 @@ discard block |
||
| 1095 | 1113 | $result = 0; |
| 1096 | 1114 | |
| 1097 | 1115 | if (!empty($coaches)) { |
| 1098 | - if ($debug) error_log('Coaches: '. print_r($coaches, 1)); |
|
| 1116 | + if ($debug) { |
|
| 1117 | + error_log('Coaches: '. print_r($coaches, 1)); |
|
| 1118 | + } |
|
| 1099 | 1119 | if (in_array($userId, $coaches)) { |
| 1100 | 1120 | $result = 1; |
| 1101 | 1121 | } |
| 1102 | 1122 | } |
| 1103 | 1123 | |
| 1104 | - if ($debug) error_log('Result: '. $result); |
|
| 1124 | + if ($debug) { |
|
| 1125 | + error_log('Result: '. $result); |
|
| 1126 | + } |
|
| 1105 | 1127 | |
| 1106 | 1128 | return $result; |
| 1107 | 1129 | } |
@@ -1127,13 +1149,17 @@ discard block |
||
| 1127 | 1149 | { |
| 1128 | 1150 | global $debug; |
| 1129 | 1151 | |
| 1130 | - if ($debug) error_log('WSSubscribeTeacherToSessionCourse'); |
|
| 1152 | + if ($debug) { |
|
| 1153 | + error_log('WSSubscribeTeacherToSessionCourse'); |
|
| 1154 | + } |
|
| 1131 | 1155 | |
| 1132 | 1156 | if (!WSHelperVerifyKey($params)) { |
| 1133 | 1157 | return returnError(WS_ERROR_SECRET_KEY); |
| 1134 | 1158 | } |
| 1135 | 1159 | |
| 1136 | - if ($debug) error_log('Params '. print_r($params, 1)); |
|
| 1160 | + if ($debug) { |
|
| 1161 | + error_log('Params '. print_r($params, 1)); |
|
| 1162 | + } |
|
| 1137 | 1163 | |
| 1138 | 1164 | $params = parseCourseSessionUserParams($params); |
| 1139 | 1165 | |
@@ -1147,7 +1173,9 @@ discard block |
||
| 1147 | 1173 | $result = 0; |
| 1148 | 1174 | |
| 1149 | 1175 | if (!empty($coaches)) { |
| 1150 | - if ($debug) error_log('Coaches: ' . print_r($coaches, 1)); |
|
| 1176 | + if ($debug) { |
|
| 1177 | + error_log('Coaches: ' . print_r($coaches, 1)); |
|
| 1178 | + } |
|
| 1151 | 1179 | if (!in_array($userId, $coaches)) { |
| 1152 | 1180 | $result = 1; |
| 1153 | 1181 | } |
@@ -1155,7 +1183,9 @@ discard block |
||
| 1155 | 1183 | $result = 1; |
| 1156 | 1184 | } |
| 1157 | 1185 | |
| 1158 | - if ($debug) error_log('Final Result: '. $result); |
|
| 1186 | + if ($debug) { |
|
| 1187 | + error_log('Final Result: '. $result); |
|
| 1188 | + } |
|
| 1159 | 1189 | |
| 1160 | 1190 | return $result; |
| 1161 | 1191 | } |
@@ -1207,8 +1237,12 @@ discard block |
||
| 1207 | 1237 | { |
| 1208 | 1238 | global $_user, $_configuration, $debug; |
| 1209 | 1239 | $debug = 1; |
| 1210 | - if ($debug) error_log('WSCreateUserPasswordCrypted'); |
|
| 1211 | - if ($debug) error_log(print_r($params,1)); |
|
| 1240 | + if ($debug) { |
|
| 1241 | + error_log('WSCreateUserPasswordCrypted'); |
|
| 1242 | + } |
|
| 1243 | + if ($debug) { |
|
| 1244 | + error_log(print_r($params,1)); |
|
| 1245 | + } |
|
| 1212 | 1246 | |
| 1213 | 1247 | if (!WSHelperVerifyKey($params)) { |
| 1214 | 1248 | return returnError(WS_ERROR_SECRET_KEY); |
@@ -1244,22 +1278,30 @@ discard block |
||
| 1244 | 1278 | if ($_configuration['password_encryption'] === $encrypt_method ) { |
| 1245 | 1279 | if ($encrypt_method == 'md5' && !preg_match('/^[A-Fa-f0-9]{32}$/', $password)) { |
| 1246 | 1280 | $msg = "Encryption $encrypt_method is invalid"; |
| 1247 | - if ($debug) error_log($msg); |
|
| 1281 | + if ($debug) { |
|
| 1282 | + error_log($msg); |
|
| 1283 | + } |
|
| 1248 | 1284 | return $msg; |
| 1249 | 1285 | |
| 1250 | 1286 | } else if ($encrypt_method == 'sha1' && !preg_match('/^[A-Fa-f0-9]{40}$/', $password)) { |
| 1251 | 1287 | $msg = "Encryption $encrypt_method is invalid"; |
| 1252 | - if ($debug) error_log($msg); |
|
| 1288 | + if ($debug) { |
|
| 1289 | + error_log($msg); |
|
| 1290 | + } |
|
| 1253 | 1291 | return $msg; |
| 1254 | 1292 | } |
| 1255 | 1293 | } else { |
| 1256 | 1294 | $msg = "This encryption $encrypt_method is not configured"; |
| 1257 | - if ($debug) error_log($msg); |
|
| 1295 | + if ($debug) { |
|
| 1296 | + error_log($msg); |
|
| 1297 | + } |
|
| 1258 | 1298 | return $msg; |
| 1259 | 1299 | } |
| 1260 | 1300 | } else { |
| 1261 | 1301 | $msg = 'The chamilo setting $_configuration["password_encryption"] is not configured'; |
| 1262 | - if ($debug) error_log($msg); |
|
| 1302 | + if ($debug) { |
|
| 1303 | + error_log($msg); |
|
| 1304 | + } |
|
| 1263 | 1305 | return $msg; |
| 1264 | 1306 | } |
| 1265 | 1307 | |
@@ -1279,10 +1321,14 @@ discard block |
||
| 1279 | 1321 | $original_user_id_name |
| 1280 | 1322 | ); |
| 1281 | 1323 | |
| 1282 | - if ($debug) error_log('Ready to create user'); |
|
| 1324 | + if ($debug) { |
|
| 1325 | + error_log('Ready to create user'); |
|
| 1326 | + } |
|
| 1283 | 1327 | |
| 1284 | 1328 | if ($user_id > 0) { |
| 1285 | - if ($debug) error_log('User found with id: '.$user_id); |
|
| 1329 | + if ($debug) { |
|
| 1330 | + error_log('User found with id: '.$user_id); |
|
| 1331 | + } |
|
| 1286 | 1332 | |
| 1287 | 1333 | // Check whether user is not active |
| 1288 | 1334 | //@todo why this condition exists?? |
@@ -1293,7 +1339,9 @@ discard block |
||
| 1293 | 1339 | $count_check_user = Database::num_rows($resu); |
| 1294 | 1340 | if ($count_check_user > 0) { |
| 1295 | 1341 | |
| 1296 | - if ($debug) error_log('User id: '.$user_id.' exists and is NOT active. Updating user and setting setting active = 1'); |
|
| 1342 | + if ($debug) { |
|
| 1343 | + error_log('User id: '.$user_id.' exists and is NOT active. Updating user and setting setting active = 1'); |
|
| 1344 | + } |
|
| 1297 | 1345 | |
| 1298 | 1346 | $sql = "UPDATE $table_user SET |
| 1299 | 1347 | lastname='".Database::escape_string($lastName)."', |
@@ -1313,7 +1361,9 @@ discard block |
||
| 1313 | 1361 | active='1', |
| 1314 | 1362 | hr_dept_id=".intval($hr_dept_id); |
| 1315 | 1363 | $sql .= " WHERE user_id='".$r_check_user[0]."'"; |
| 1316 | - if ($debug) error_log($sql); |
|
| 1364 | + if ($debug) { |
|
| 1365 | + error_log($sql); |
|
| 1366 | + } |
|
| 1317 | 1367 | Database::query($sql); |
| 1318 | 1368 | |
| 1319 | 1369 | if (is_array($extra_list) && count($extra_list) > 0) { |
@@ -1330,11 +1380,15 @@ discard block |
||
| 1330 | 1380 | } |
| 1331 | 1381 | return $r_check_user[0]; |
| 1332 | 1382 | } else { |
| 1333 | - if ($debug) error_log('User exists but is active. Cant be updated'); |
|
| 1383 | + if ($debug) { |
|
| 1384 | + error_log('User exists but is active. Cant be updated'); |
|
| 1385 | + } |
|
| 1334 | 1386 | return 0; |
| 1335 | 1387 | } |
| 1336 | 1388 | } else { |
| 1337 | - if ($debug) error_log("User not found with original_id = $original_user_id_value and original_name = $original_user_id_name"); |
|
| 1389 | + if ($debug) { |
|
| 1390 | + error_log("User not found with original_id = $original_user_id_value and original_name = $original_user_id_name"); |
|
| 1391 | + } |
|
| 1338 | 1392 | } |
| 1339 | 1393 | |
| 1340 | 1394 | // Default language. |
@@ -1350,12 +1404,16 @@ discard block |
||
| 1350 | 1404 | |
| 1351 | 1405 | // First check wether the login already exists |
| 1352 | 1406 | if (!UserManager::is_username_available($loginName)) { |
| 1353 | - if ($debug) error_log("Username $loginName is not available"); |
|
| 1407 | + if ($debug) { |
|
| 1408 | + error_log("Username $loginName is not available"); |
|
| 1409 | + } |
|
| 1354 | 1410 | return 0; |
| 1355 | 1411 | } |
| 1356 | 1412 | |
| 1357 | 1413 | $queryExpirationDate = ''; |
| 1358 | - if (!empty($params['expiration_date'])) $queryExpirationDate = "expiration_date = '".Database::escape_string($expiration_date)."', "; |
|
| 1414 | + if (!empty($params['expiration_date'])) { |
|
| 1415 | + $queryExpirationDate = "expiration_date = '".Database::escape_string($expiration_date)."', "; |
|
| 1416 | + } |
|
| 1359 | 1417 | |
| 1360 | 1418 | $sql = "INSERT INTO $table_user SET |
| 1361 | 1419 | lastname = '".Database::escape_string(trim($lastName))."', |
@@ -1375,7 +1433,9 @@ discard block |
||
| 1375 | 1433 | ".$queryExpirationDate." |
| 1376 | 1434 | hr_dept_id = '".Database::escape_string($hr_dept_id)."', |
| 1377 | 1435 | active = '".Database::escape_string($active)."'"; |
| 1378 | - if ($debug) error_log($sql); |
|
| 1436 | + if ($debug) { |
|
| 1437 | + error_log($sql); |
|
| 1438 | + } |
|
| 1379 | 1439 | |
| 1380 | 1440 | Database::query($sql); |
| 1381 | 1441 | $return = Database::insert_id(); |
@@ -1387,7 +1447,9 @@ discard block |
||
| 1387 | 1447 | |
| 1388 | 1448 | $url_id = api_get_current_access_url_id(); |
| 1389 | 1449 | UrlManager::add_user_to_url($return, $url_id); |
| 1390 | - if ($debug) error_log("Adding user_id = $return to URL id $url_id "); |
|
| 1450 | + if ($debug) { |
|
| 1451 | + error_log("Adding user_id = $return to URL id $url_id "); |
|
| 1452 | + } |
|
| 1391 | 1453 | |
| 1392 | 1454 | // Create extra field for the original_user_id_name |
| 1393 | 1455 | UserManager::create_extra_field( |
@@ -1424,7 +1486,9 @@ discard block |
||
| 1424 | 1486 | } |
| 1425 | 1487 | } |
| 1426 | 1488 | } else { |
| 1427 | - if ($debug) error_log('Error while inserting a user'); |
|
| 1489 | + if ($debug) { |
|
| 1490 | + error_log('Error while inserting a user'); |
|
| 1491 | + } |
|
| 1428 | 1492 | return 0; |
| 1429 | 1493 | } |
| 1430 | 1494 | |
@@ -4487,7 +4551,9 @@ discard block |
||
| 4487 | 4551 | if (!WSHelperVerifyKey($params)) { |
| 4488 | 4552 | return returnError(WS_ERROR_SECRET_KEY); |
| 4489 | 4553 | } |
| 4490 | - if ($debug) error_log('WSSubscribeUserToCourse params: '.print_r($params,1)); |
|
| 4554 | + if ($debug) { |
|
| 4555 | + error_log('WSSubscribeUserToCourse params: '.print_r($params,1)); |
|
| 4556 | + } |
|
| 4491 | 4557 | |
| 4492 | 4558 | $results = array(); |
| 4493 | 4559 | $userscourses = $params['userscourses']; |
@@ -4506,7 +4572,9 @@ discard block |
||
| 4506 | 4572 | $original_user_id['original_user_id_value'], |
| 4507 | 4573 | $original_user_id['original_user_id_name'] |
| 4508 | 4574 | ); |
| 4509 | - if ($debug) error_log('WSSubscribeUserToCourse user_id: '.$user_id); |
|
| 4575 | + if ($debug) { |
|
| 4576 | + error_log('WSSubscribeUserToCourse user_id: '.$user_id); |
|
| 4577 | + } |
|
| 4510 | 4578 | |
| 4511 | 4579 | if ($user_id == 0) { |
| 4512 | 4580 | // If user was not found, there was a problem |
@@ -4524,13 +4592,19 @@ discard block |
||
| 4524 | 4592 | // Course was not found |
| 4525 | 4593 | $resultValue = 0; |
| 4526 | 4594 | } else { |
| 4527 | - if ($debug) error_log('WSSubscribeUserToCourse courseCode: '.$courseCode); |
|
| 4595 | + if ($debug) { |
|
| 4596 | + error_log('WSSubscribeUserToCourse courseCode: '.$courseCode); |
|
| 4597 | + } |
|
| 4528 | 4598 | $result = CourseManager::add_user_to_course($user_id, $courseCode, $status, false); |
| 4529 | 4599 | if ($result) { |
| 4530 | 4600 | $resultValue = 1; |
| 4531 | - if ($debug) error_log('WSSubscribeUserToCourse subscribed'); |
|
| 4601 | + if ($debug) { |
|
| 4602 | + error_log('WSSubscribeUserToCourse subscribed'); |
|
| 4603 | + } |
|
| 4532 | 4604 | } else { |
| 4533 | - if ($debug) error_log('WSSubscribeUserToCourse NOT subscribed: '); |
|
| 4605 | + if ($debug) { |
|
| 4606 | + error_log('WSSubscribeUserToCourse NOT subscribed: '); |
|
| 4607 | + } |
|
| 4534 | 4608 | } |
| 4535 | 4609 | } |
| 4536 | 4610 | } |
@@ -4588,8 +4662,12 @@ discard block |
||
| 4588 | 4662 | function WSSubscribeUserToCourseSimple($params) { |
| 4589 | 4663 | global $debug; |
| 4590 | 4664 | |
| 4591 | - if ($debug) error_log('WSSubscribeUserToCourseSimple'); |
|
| 4592 | - if ($debug) error_log('Params '. print_r($params, 1)); |
|
| 4665 | + if ($debug) { |
|
| 4666 | + error_log('WSSubscribeUserToCourseSimple'); |
|
| 4667 | + } |
|
| 4668 | + if ($debug) { |
|
| 4669 | + error_log('Params '. print_r($params, 1)); |
|
| 4670 | + } |
|
| 4593 | 4671 | if (!WSHelperVerifyKey($params)) { |
| 4594 | 4672 | return returnError(WS_ERROR_SECRET_KEY); |
| 4595 | 4673 | } |
@@ -4604,7 +4682,9 @@ discard block |
||
| 4604 | 4682 | if (empty($user_data)) { |
| 4605 | 4683 | // If user was not found, there was a problem |
| 4606 | 4684 | $result = "User $user_id does not exist"; |
| 4607 | - if ($debug) error_log($result); |
|
| 4685 | + if ($debug) { |
|
| 4686 | + error_log($result); |
|
| 4687 | + } |
|
| 4608 | 4688 | return $result; |
| 4609 | 4689 | } |
| 4610 | 4690 | if (!empty($course_code)) { |
@@ -4612,14 +4692,22 @@ discard block |
||
| 4612 | 4692 | if (empty($course_data)) { |
| 4613 | 4693 | // Course was not found |
| 4614 | 4694 | $result = "Course $course_code does not exist in the platform "; |
| 4615 | - if ($debug) error_log($result); |
|
| 4695 | + if ($debug) { |
|
| 4696 | + error_log($result); |
|
| 4697 | + } |
|
| 4616 | 4698 | } else { |
| 4617 | - if ($debug) error_log('Try to register: user_id= '.$user_id.' to course: '.$course_data['code']); |
|
| 4699 | + if ($debug) { |
|
| 4700 | + error_log('Try to register: user_id= '.$user_id.' to course: '.$course_data['code']); |
|
| 4701 | + } |
|
| 4618 | 4702 | if (!CourseManager::add_user_to_course($user_id, $course_data['code'], $status)) { |
| 4619 | 4703 | $result = 'User was not registered possible reasons: User already registered to the course, Course visibility doesnt allow user subscriptions '; |
| 4620 | - if ($debug) error_log($result); |
|
| 4704 | + if ($debug) { |
|
| 4705 | + error_log($result); |
|
| 4706 | + } |
|
| 4621 | 4707 | } else { |
| 4622 | - if ($debug) error_log('User registered to the course: '.$course_data['code']); |
|
| 4708 | + if ($debug) { |
|
| 4709 | + error_log('User registered to the course: '.$course_data['code']); |
|
| 4710 | + } |
|
| 4623 | 4711 | $result = 1; |
| 4624 | 4712 | } |
| 4625 | 4713 | } |
@@ -4671,8 +4759,12 @@ discard block |
||
| 4671 | 4759 | // define the method WSGetUser |
| 4672 | 4760 | function WSGetUser($params) { |
| 4673 | 4761 | global $debug; |
| 4674 | - if ($debug) error_log('WSGetUser'); |
|
| 4675 | - if ($debug) error_log('$params: '.print_r($params, 1)); |
|
| 4762 | + if ($debug) { |
|
| 4763 | + error_log('WSGetUser'); |
|
| 4764 | + } |
|
| 4765 | + if ($debug) { |
|
| 4766 | + error_log('$params: '.print_r($params, 1)); |
|
| 4767 | + } |
|
| 4676 | 4768 | |
| 4677 | 4769 | if (!WSHelperVerifyKey($params)) { |
| 4678 | 4770 | return returnError(WS_ERROR_SECRET_KEY); |
@@ -4725,8 +4817,12 @@ discard block |
||
| 4725 | 4817 | // define the method WSGetUserFromUsername |
| 4726 | 4818 | function WSGetUserFromUsername($params) { |
| 4727 | 4819 | global $debug; |
| 4728 | - if ($debug) error_log('WSGetUserFromUsername'); |
|
| 4729 | - if ($debug) error_log('$params: '.print_r($params, 1)); |
|
| 4820 | + if ($debug) { |
|
| 4821 | + error_log('WSGetUserFromUsername'); |
|
| 4822 | + } |
|
| 4823 | + if ($debug) { |
|
| 4824 | + error_log('$params: '.print_r($params, 1)); |
|
| 4825 | + } |
|
| 4730 | 4826 | |
| 4731 | 4827 | if (!WSHelperVerifyKey($params)) { |
| 4732 | 4828 | return returnError(WS_ERROR_SECRET_KEY); |
@@ -5176,7 +5272,9 @@ discard block |
||
| 5176 | 5272 | $orig_session_id_value[] = $original_session_id_value; |
| 5177 | 5273 | $results[] = 1; |
| 5178 | 5274 | |
| 5179 | - if ($debug) error_log("subscribe user:$user_id to session $sessionId"); |
|
| 5275 | + if ($debug) { |
|
| 5276 | + error_log("subscribe user:$user_id to session $sessionId"); |
|
| 5277 | + } |
|
| 5180 | 5278 | } |
| 5181 | 5279 | } |
| 5182 | 5280 | } // end principal foreach |
@@ -5260,7 +5358,9 @@ discard block |
||
| 5260 | 5358 | SESSION_VISIBLE_READ_ONLY, |
| 5261 | 5359 | false |
| 5262 | 5360 | ); |
| 5263 | - if ($debug) error_log('User registered to the course: '.$session_id); |
|
| 5361 | + if ($debug) { |
|
| 5362 | + error_log('User registered to the course: '.$session_id); |
|
| 5363 | + } |
|
| 5264 | 5364 | $result = 1; |
| 5265 | 5365 | } |
| 5266 | 5366 | } |
@@ -5406,7 +5506,9 @@ discard block |
||
| 5406 | 5506 | $orig_session_id_value[] = $original_session_id_value; |
| 5407 | 5507 | $results[] = 1; |
| 5408 | 5508 | |
| 5409 | - if ($debug) error_log("Unsubscribe user:$user_id to session:$id_session"); |
|
| 5509 | + if ($debug) { |
|
| 5510 | + error_log("Unsubscribe user:$user_id to session:$id_session"); |
|
| 5511 | + } |
|
| 5410 | 5512 | } |
| 5411 | 5513 | } |
| 5412 | 5514 | } // end principal foreach |
@@ -5553,7 +5655,9 @@ discard block |
||
| 5553 | 5655 | return returnError(WS_ERROR_SECRET_KEY); |
| 5554 | 5656 | } |
| 5555 | 5657 | |
| 5556 | - if ($debug) error_log('WSSuscribeCoursesToSession: '.print_r($params, 1)); |
|
| 5658 | + if ($debug) { |
|
| 5659 | + error_log('WSSuscribeCoursesToSession: '.print_r($params, 1)); |
|
| 5660 | + } |
|
| 5557 | 5661 | |
| 5558 | 5662 | $coursessessions_params = $params['coursessessions']; |
| 5559 | 5663 | $results = array(); |
@@ -5591,7 +5695,9 @@ discard block |
||
| 5591 | 5695 | array($courseInfo['real_id']), |
| 5592 | 5696 | false |
| 5593 | 5697 | ); |
| 5594 | - if ($debug) error_log("add_courses_to_session: course:$courseCode to session:$sessionId"); |
|
| 5698 | + if ($debug) { |
|
| 5699 | + error_log("add_courses_to_session: course:$courseCode to session:$sessionId"); |
|
| 5700 | + } |
|
| 5595 | 5701 | |
| 5596 | 5702 | $results[] = 1; |
| 5597 | 5703 | $orig_course_id_value[] = $original_session_id_value; |
@@ -5969,8 +6075,7 @@ discard block |
||
| 5969 | 6075 | UserManager::create_extra_field($params['original_user_id_name'], 1, $params['original_user_id_name'], ''); |
| 5970 | 6076 | // Save the external system's id into user_field_value table. |
| 5971 | 6077 | UserManager::update_extra_field_value($user_id, $params['original_user_id_name'], $params['original_user_id_value']); |
| 5972 | - } |
|
| 5973 | - else { |
|
| 6078 | + } else { |
|
| 5974 | 6079 | return 0; |
| 5975 | 6080 | } |
| 5976 | 6081 | } |
@@ -6126,8 +6231,12 @@ discard block |
||
| 6126 | 6231 | { |
| 6127 | 6232 | global $debug; |
| 6128 | 6233 | |
| 6129 | - if ($debug) error_log('WSUserSubscribedInCourse'); |
|
| 6130 | - if ($debug) error_log('Params '. print_r($params, 1)); |
|
| 6234 | + if ($debug) { |
|
| 6235 | + error_log('WSUserSubscribedInCourse'); |
|
| 6236 | + } |
|
| 6237 | + if ($debug) { |
|
| 6238 | + error_log('Params '. print_r($params, 1)); |
|
| 6239 | + } |
|
| 6131 | 6240 | if (!WSHelperVerifyKey($params)) { |
| 6132 | 6241 | |
| 6133 | 6242 | return returnError(WS_ERROR_SECRET_KEY); |
@@ -37,6 +37,8 @@ discard block |
||
| 37 | 37 | * |
| 38 | 38 | * @param int Error code |
| 39 | 39 | * @param string Error message |
| 40 | + * @param integer $code |
|
| 41 | + * @param string $message |
|
| 40 | 42 | */ |
| 41 | 43 | public function __construct($code, $message) { |
| 42 | 44 | $this->code = $code; |
@@ -47,6 +49,7 @@ discard block |
||
| 47 | 49 | * Sets the error handler |
| 48 | 50 | * |
| 49 | 51 | * @param WSErrorHandler Error handler |
| 52 | + * @param WSSoapErrorHandler $handler |
|
| 50 | 53 | */ |
| 51 | 54 | public static function setErrorHandler($handler) { |
| 52 | 55 | if($handler instanceof WSErrorHandler) { |
@@ -81,6 +84,7 @@ discard block |
||
| 81 | 84 | * Handle method |
| 82 | 85 | * |
| 83 | 86 | * @param WSError Error |
| 87 | + * @return void |
|
| 84 | 88 | */ |
| 85 | 89 | public function handle($error); |
| 86 | 90 | } |
@@ -107,7 +111,7 @@ discard block |
||
| 107 | 111 | * Verifies the API key |
| 108 | 112 | * |
| 109 | 113 | * @param string Secret key |
| 110 | - * @return mixed WSError in case of failure, null in case of success |
|
| 114 | + * @return WSError|null WSError in case of failure, null in case of success |
|
| 111 | 115 | */ |
| 112 | 116 | protected function verifyKey($secret_key) { |
| 113 | 117 | $ip = trim($_SERVER['REMOTE_ADDR']); |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | * @param WSErrorHandler Error handler |
| 50 | 50 | */ |
| 51 | 51 | public static function setErrorHandler($handler) { |
| 52 | - if($handler instanceof WSErrorHandler) { |
|
| 52 | + if ($handler instanceof WSErrorHandler) { |
|
| 53 | 53 | self::$_handler = $handler; |
| 54 | 54 | } |
| 55 | 55 | } |
@@ -114,12 +114,12 @@ discard block |
||
| 114 | 114 | // if we are behind a reverse proxy, assume it will send the |
| 115 | 115 | // HTTP_X_FORWARDED_FOR header and use this IP instead |
| 116 | 116 | if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { |
| 117 | - list($ip1,$ip2) = preg_split('/,/',$_SERVER['HTTP_X_FORWARDED_FOR']); |
|
| 117 | + list($ip1, $ip2) = preg_split('/,/', $_SERVER['HTTP_X_FORWARDED_FOR']); |
|
| 118 | 118 | $ip = trim($ip1); |
| 119 | 119 | } |
| 120 | 120 | $security_key = $ip.$this->_configuration['security_key']; |
| 121 | 121 | |
| 122 | - if(!api_is_valid_secret_key($secret_key, $security_key)) { |
|
| 122 | + if (!api_is_valid_secret_key($secret_key, $security_key)) { |
|
| 123 | 123 | return new WSError(1, "API key is invalid"); |
| 124 | 124 | } else { |
| 125 | 125 | return null; |
@@ -136,15 +136,15 @@ discard block |
||
| 136 | 136 | * @return mixed System user id if the user was found, WSError otherwise |
| 137 | 137 | */ |
| 138 | 138 | protected function getUserId($user_id_field_name, $user_id_value) { |
| 139 | - if($user_id_field_name == "chamilo_user_id") { |
|
| 140 | - if(UserManager::is_user_id_valid(intval($user_id_value))) { |
|
| 139 | + if ($user_id_field_name == "chamilo_user_id") { |
|
| 140 | + if (UserManager::is_user_id_valid(intval($user_id_value))) { |
|
| 141 | 141 | return intval($user_id_value); |
| 142 | 142 | } else { |
| 143 | 143 | return new WSError(100, "User not found"); |
| 144 | 144 | } |
| 145 | 145 | } else { |
| 146 | 146 | $user_id = UserManager::get_user_id_from_original_id($user_id_value, $user_id_field_name); |
| 147 | - if($user_id == 0) { |
|
| 147 | + if ($user_id == 0) { |
|
| 148 | 148 | return new WSError(100, "User not found"); |
| 149 | 149 | } else { |
| 150 | 150 | return $user_id; |
@@ -197,7 +197,7 @@ discard block |
||
| 197 | 197 | protected function getSessionId($session_id_field_name, $session_id_value) |
| 198 | 198 | { |
| 199 | 199 | if ($session_id_field_name == "chamilo_session_id") { |
| 200 | - $session = SessionManager::fetch((int)$session_id_value); |
|
| 200 | + $session = SessionManager::fetch((int) $session_id_value); |
|
| 201 | 201 | if (!empty($session)) { |
| 202 | 202 | return intval($session_id_value); |
| 203 | 203 | } else { |
@@ -11,237 +11,237 @@ |
||
| 11 | 11 | */ |
| 12 | 12 | class WSError |
| 13 | 13 | { |
| 14 | - /** |
|
| 15 | - * Error handler. This needs to be a class that implements the interface WSErrorHandler |
|
| 16 | - * |
|
| 17 | - * @var WSErrorHandler |
|
| 18 | - */ |
|
| 19 | - protected static $_handler; |
|
| 20 | - |
|
| 21 | - /** |
|
| 22 | - * Error code |
|
| 23 | - * |
|
| 24 | - * @var int |
|
| 25 | - */ |
|
| 26 | - public $code; |
|
| 27 | - |
|
| 28 | - /** |
|
| 29 | - * Error message |
|
| 30 | - * |
|
| 31 | - * @var string |
|
| 32 | - */ |
|
| 33 | - public $message; |
|
| 34 | - |
|
| 35 | - /** |
|
| 36 | - * Constructor |
|
| 37 | - * |
|
| 38 | - * @param int Error code |
|
| 39 | - * @param string Error message |
|
| 40 | - */ |
|
| 41 | - public function __construct($code, $message) { |
|
| 42 | - $this->code = $code; |
|
| 43 | - $this->message = $message; |
|
| 44 | - } |
|
| 45 | - |
|
| 46 | - /** |
|
| 47 | - * Sets the error handler |
|
| 48 | - * |
|
| 49 | - * @param WSErrorHandler Error handler |
|
| 50 | - */ |
|
| 51 | - public static function setErrorHandler($handler) { |
|
| 52 | - if($handler instanceof WSErrorHandler) { |
|
| 53 | - self::$_handler = $handler; |
|
| 54 | - } |
|
| 55 | - } |
|
| 56 | - |
|
| 57 | - /** |
|
| 58 | - * Returns the error handler |
|
| 59 | - * |
|
| 60 | - * @return WSErrorHandler Error handler |
|
| 61 | - */ |
|
| 62 | - public static function getErrorHandler() { |
|
| 63 | - return self::$_handler; |
|
| 64 | - } |
|
| 65 | - |
|
| 66 | - /** |
|
| 67 | - * Transforms the error into an array |
|
| 68 | - * |
|
| 69 | - * @return array Associative array with code and message |
|
| 70 | - */ |
|
| 71 | - public function toArray() { |
|
| 72 | - return array('code' => $this->code, 'message' => $this->message); |
|
| 73 | - } |
|
| 14 | + /** |
|
| 15 | + * Error handler. This needs to be a class that implements the interface WSErrorHandler |
|
| 16 | + * |
|
| 17 | + * @var WSErrorHandler |
|
| 18 | + */ |
|
| 19 | + protected static $_handler; |
|
| 20 | + |
|
| 21 | + /** |
|
| 22 | + * Error code |
|
| 23 | + * |
|
| 24 | + * @var int |
|
| 25 | + */ |
|
| 26 | + public $code; |
|
| 27 | + |
|
| 28 | + /** |
|
| 29 | + * Error message |
|
| 30 | + * |
|
| 31 | + * @var string |
|
| 32 | + */ |
|
| 33 | + public $message; |
|
| 34 | + |
|
| 35 | + /** |
|
| 36 | + * Constructor |
|
| 37 | + * |
|
| 38 | + * @param int Error code |
|
| 39 | + * @param string Error message |
|
| 40 | + */ |
|
| 41 | + public function __construct($code, $message) { |
|
| 42 | + $this->code = $code; |
|
| 43 | + $this->message = $message; |
|
| 44 | + } |
|
| 45 | + |
|
| 46 | + /** |
|
| 47 | + * Sets the error handler |
|
| 48 | + * |
|
| 49 | + * @param WSErrorHandler Error handler |
|
| 50 | + */ |
|
| 51 | + public static function setErrorHandler($handler) { |
|
| 52 | + if($handler instanceof WSErrorHandler) { |
|
| 53 | + self::$_handler = $handler; |
|
| 54 | + } |
|
| 55 | + } |
|
| 56 | + |
|
| 57 | + /** |
|
| 58 | + * Returns the error handler |
|
| 59 | + * |
|
| 60 | + * @return WSErrorHandler Error handler |
|
| 61 | + */ |
|
| 62 | + public static function getErrorHandler() { |
|
| 63 | + return self::$_handler; |
|
| 64 | + } |
|
| 65 | + |
|
| 66 | + /** |
|
| 67 | + * Transforms the error into an array |
|
| 68 | + * |
|
| 69 | + * @return array Associative array with code and message |
|
| 70 | + */ |
|
| 71 | + public function toArray() { |
|
| 72 | + return array('code' => $this->code, 'message' => $this->message); |
|
| 73 | + } |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | /** |
| 77 | 77 | * Interface that must be implemented by any error handler |
| 78 | 78 | */ |
| 79 | 79 | interface WSErrorHandler { |
| 80 | - /** |
|
| 81 | - * Handle method |
|
| 82 | - * |
|
| 83 | - * @param WSError Error |
|
| 84 | - */ |
|
| 85 | - public function handle($error); |
|
| 80 | + /** |
|
| 81 | + * Handle method |
|
| 82 | + * |
|
| 83 | + * @param WSError Error |
|
| 84 | + */ |
|
| 85 | + public function handle($error); |
|
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | /** |
| 89 | 89 | * Main class of the webservice. Webservice classes extend this class |
| 90 | 90 | */ |
| 91 | 91 | class WS { |
| 92 | - /** |
|
| 93 | - * Chamilo configuration |
|
| 94 | - * |
|
| 95 | - * @var array |
|
| 96 | - */ |
|
| 97 | - protected $_configuration; |
|
| 98 | - |
|
| 99 | - /** |
|
| 100 | - * Constructor |
|
| 101 | - */ |
|
| 102 | - public function __construct() { |
|
| 103 | - $this->_configuration = $GLOBALS['_configuration']; |
|
| 104 | - } |
|
| 105 | - |
|
| 106 | - /** |
|
| 107 | - * Verifies the API key |
|
| 108 | - * |
|
| 109 | - * @param string Secret key |
|
| 110 | - * @return mixed WSError in case of failure, null in case of success |
|
| 111 | - */ |
|
| 112 | - protected function verifyKey($secret_key) { |
|
| 113 | - $ip = trim($_SERVER['REMOTE_ADDR']); |
|
| 114 | - // if we are behind a reverse proxy, assume it will send the |
|
| 115 | - // HTTP_X_FORWARDED_FOR header and use this IP instead |
|
| 116 | - if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { |
|
| 117 | - list($ip1,$ip2) = preg_split('/,/',$_SERVER['HTTP_X_FORWARDED_FOR']); |
|
| 118 | - $ip = trim($ip1); |
|
| 119 | - } |
|
| 120 | - $security_key = $ip.$this->_configuration['security_key']; |
|
| 121 | - |
|
| 122 | - if(!api_is_valid_secret_key($secret_key, $security_key)) { |
|
| 123 | - return new WSError(1, "API key is invalid"); |
|
| 124 | - } else { |
|
| 125 | - return null; |
|
| 126 | - } |
|
| 127 | - } |
|
| 128 | - |
|
| 129 | - /** |
|
| 130 | - * Gets the real user id based on the user id field name and value. |
|
| 131 | - * Note that if the user id field name is "chamilo_user_id", it will use the user id |
|
| 132 | - * in the system database |
|
| 133 | - * |
|
| 134 | - * @param string User id field name |
|
| 135 | - * @param string User id value |
|
| 136 | - * @return mixed System user id if the user was found, WSError otherwise |
|
| 137 | - */ |
|
| 138 | - protected function getUserId($user_id_field_name, $user_id_value) { |
|
| 139 | - if($user_id_field_name == "chamilo_user_id") { |
|
| 140 | - if(UserManager::is_user_id_valid(intval($user_id_value))) { |
|
| 141 | - return intval($user_id_value); |
|
| 142 | - } else { |
|
| 143 | - return new WSError(100, "User not found"); |
|
| 144 | - } |
|
| 145 | - } else { |
|
| 146 | - $user_id = UserManager::get_user_id_from_original_id($user_id_value, $user_id_field_name); |
|
| 147 | - if($user_id == 0) { |
|
| 148 | - return new WSError(100, "User not found"); |
|
| 149 | - } else { |
|
| 150 | - return $user_id; |
|
| 151 | - } |
|
| 152 | - } |
|
| 153 | - } |
|
| 154 | - |
|
| 155 | - /** |
|
| 156 | - * Gets the real course id based on the course id field name and value. |
|
| 157 | - * Note that if the course id field name is "chamilo_course_id", it will use the course id |
|
| 158 | - * in the system database |
|
| 159 | - * |
|
| 160 | - * @param string Course id field name |
|
| 161 | - * @param string Course id value |
|
| 162 | - * @return mixed System course id if the course was found, WSError otherwise |
|
| 163 | - */ |
|
| 164 | - protected function getCourseId($course_id_field_name, $course_id_value) |
|
| 165 | - { |
|
| 166 | - if ($course_id_field_name == "chamilo_course_id") { |
|
| 167 | - if (CourseManager::get_course_code_from_course_id( |
|
| 168 | - intval($course_id_value) |
|
| 169 | - ) != null |
|
| 170 | - ) { |
|
| 171 | - return intval($course_id_value); |
|
| 172 | - } else { |
|
| 173 | - return new WSError(200, "Course not found"); |
|
| 174 | - } |
|
| 175 | - } else { |
|
| 176 | - $courseId = CourseManager::get_course_code_from_original_id( |
|
| 177 | - $course_id_value, |
|
| 178 | - $course_id_field_name |
|
| 179 | - ); |
|
| 180 | - if (!empty($courseId)) { |
|
| 181 | - return $courseId; |
|
| 182 | - } else { |
|
| 183 | - return new WSError(200, "Course not found"); |
|
| 184 | - } |
|
| 185 | - } |
|
| 186 | - } |
|
| 187 | - |
|
| 188 | - /** |
|
| 189 | - * Gets the real session id based on the session id field name and value. |
|
| 190 | - * Note that if the session id field name is "chamilo_session_id", it will use the session id |
|
| 191 | - * in the system database |
|
| 192 | - * |
|
| 193 | - * @param string Session id field name |
|
| 194 | - * @param string Session id value |
|
| 195 | - * @return mixed System session id if the session was found, WSError otherwise |
|
| 196 | - */ |
|
| 197 | - protected function getSessionId($session_id_field_name, $session_id_value) |
|
| 198 | - { |
|
| 199 | - if ($session_id_field_name == "chamilo_session_id") { |
|
| 200 | - $session = SessionManager::fetch((int)$session_id_value); |
|
| 201 | - if (!empty($session)) { |
|
| 202 | - return intval($session_id_value); |
|
| 203 | - } else { |
|
| 204 | - return new WSError(300, "Session not found"); |
|
| 205 | - } |
|
| 206 | - } else { |
|
| 207 | - $session_id = SessionManager::getSessionIdFromOriginalId( |
|
| 208 | - $session_id_value, |
|
| 209 | - $session_id_field_name |
|
| 210 | - ); |
|
| 211 | - if ($session_id == 0) { |
|
| 212 | - return new WSError(300, "Session not found"); |
|
| 213 | - } else { |
|
| 214 | - return $session_id; |
|
| 215 | - } |
|
| 216 | - } |
|
| 217 | - } |
|
| 218 | - |
|
| 219 | - /** |
|
| 220 | - * Handles an error by calling the WSError error handler |
|
| 221 | - * |
|
| 222 | - * @param WSError Error |
|
| 223 | - */ |
|
| 224 | - protected function handleError($error) { |
|
| 225 | - $handler = WSError::getErrorHandler(); |
|
| 226 | - $handler->handle($error); |
|
| 227 | - } |
|
| 228 | - |
|
| 229 | - /** |
|
| 230 | - * Gets a successful result |
|
| 231 | - * |
|
| 232 | - * @return array Array with a code of 0 and a message 'Operation was successful' |
|
| 233 | - */ |
|
| 234 | - protected function getSuccessfulResult() { |
|
| 235 | - return array('code' => 0, 'message' => 'Operation was successful'); |
|
| 236 | - } |
|
| 237 | - |
|
| 238 | - /** |
|
| 239 | - * Test function. Returns the string success |
|
| 240 | - * |
|
| 241 | - * @return string Success |
|
| 242 | - */ |
|
| 243 | - public function test() { |
|
| 244 | - return "success"; |
|
| 245 | - } |
|
| 92 | + /** |
|
| 93 | + * Chamilo configuration |
|
| 94 | + * |
|
| 95 | + * @var array |
|
| 96 | + */ |
|
| 97 | + protected $_configuration; |
|
| 98 | + |
|
| 99 | + /** |
|
| 100 | + * Constructor |
|
| 101 | + */ |
|
| 102 | + public function __construct() { |
|
| 103 | + $this->_configuration = $GLOBALS['_configuration']; |
|
| 104 | + } |
|
| 105 | + |
|
| 106 | + /** |
|
| 107 | + * Verifies the API key |
|
| 108 | + * |
|
| 109 | + * @param string Secret key |
|
| 110 | + * @return mixed WSError in case of failure, null in case of success |
|
| 111 | + */ |
|
| 112 | + protected function verifyKey($secret_key) { |
|
| 113 | + $ip = trim($_SERVER['REMOTE_ADDR']); |
|
| 114 | + // if we are behind a reverse proxy, assume it will send the |
|
| 115 | + // HTTP_X_FORWARDED_FOR header and use this IP instead |
|
| 116 | + if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { |
|
| 117 | + list($ip1,$ip2) = preg_split('/,/',$_SERVER['HTTP_X_FORWARDED_FOR']); |
|
| 118 | + $ip = trim($ip1); |
|
| 119 | + } |
|
| 120 | + $security_key = $ip.$this->_configuration['security_key']; |
|
| 121 | + |
|
| 122 | + if(!api_is_valid_secret_key($secret_key, $security_key)) { |
|
| 123 | + return new WSError(1, "API key is invalid"); |
|
| 124 | + } else { |
|
| 125 | + return null; |
|
| 126 | + } |
|
| 127 | + } |
|
| 128 | + |
|
| 129 | + /** |
|
| 130 | + * Gets the real user id based on the user id field name and value. |
|
| 131 | + * Note that if the user id field name is "chamilo_user_id", it will use the user id |
|
| 132 | + * in the system database |
|
| 133 | + * |
|
| 134 | + * @param string User id field name |
|
| 135 | + * @param string User id value |
|
| 136 | + * @return mixed System user id if the user was found, WSError otherwise |
|
| 137 | + */ |
|
| 138 | + protected function getUserId($user_id_field_name, $user_id_value) { |
|
| 139 | + if($user_id_field_name == "chamilo_user_id") { |
|
| 140 | + if(UserManager::is_user_id_valid(intval($user_id_value))) { |
|
| 141 | + return intval($user_id_value); |
|
| 142 | + } else { |
|
| 143 | + return new WSError(100, "User not found"); |
|
| 144 | + } |
|
| 145 | + } else { |
|
| 146 | + $user_id = UserManager::get_user_id_from_original_id($user_id_value, $user_id_field_name); |
|
| 147 | + if($user_id == 0) { |
|
| 148 | + return new WSError(100, "User not found"); |
|
| 149 | + } else { |
|
| 150 | + return $user_id; |
|
| 151 | + } |
|
| 152 | + } |
|
| 153 | + } |
|
| 154 | + |
|
| 155 | + /** |
|
| 156 | + * Gets the real course id based on the course id field name and value. |
|
| 157 | + * Note that if the course id field name is "chamilo_course_id", it will use the course id |
|
| 158 | + * in the system database |
|
| 159 | + * |
|
| 160 | + * @param string Course id field name |
|
| 161 | + * @param string Course id value |
|
| 162 | + * @return mixed System course id if the course was found, WSError otherwise |
|
| 163 | + */ |
|
| 164 | + protected function getCourseId($course_id_field_name, $course_id_value) |
|
| 165 | + { |
|
| 166 | + if ($course_id_field_name == "chamilo_course_id") { |
|
| 167 | + if (CourseManager::get_course_code_from_course_id( |
|
| 168 | + intval($course_id_value) |
|
| 169 | + ) != null |
|
| 170 | + ) { |
|
| 171 | + return intval($course_id_value); |
|
| 172 | + } else { |
|
| 173 | + return new WSError(200, "Course not found"); |
|
| 174 | + } |
|
| 175 | + } else { |
|
| 176 | + $courseId = CourseManager::get_course_code_from_original_id( |
|
| 177 | + $course_id_value, |
|
| 178 | + $course_id_field_name |
|
| 179 | + ); |
|
| 180 | + if (!empty($courseId)) { |
|
| 181 | + return $courseId; |
|
| 182 | + } else { |
|
| 183 | + return new WSError(200, "Course not found"); |
|
| 184 | + } |
|
| 185 | + } |
|
| 186 | + } |
|
| 187 | + |
|
| 188 | + /** |
|
| 189 | + * Gets the real session id based on the session id field name and value. |
|
| 190 | + * Note that if the session id field name is "chamilo_session_id", it will use the session id |
|
| 191 | + * in the system database |
|
| 192 | + * |
|
| 193 | + * @param string Session id field name |
|
| 194 | + * @param string Session id value |
|
| 195 | + * @return mixed System session id if the session was found, WSError otherwise |
|
| 196 | + */ |
|
| 197 | + protected function getSessionId($session_id_field_name, $session_id_value) |
|
| 198 | + { |
|
| 199 | + if ($session_id_field_name == "chamilo_session_id") { |
|
| 200 | + $session = SessionManager::fetch((int)$session_id_value); |
|
| 201 | + if (!empty($session)) { |
|
| 202 | + return intval($session_id_value); |
|
| 203 | + } else { |
|
| 204 | + return new WSError(300, "Session not found"); |
|
| 205 | + } |
|
| 206 | + } else { |
|
| 207 | + $session_id = SessionManager::getSessionIdFromOriginalId( |
|
| 208 | + $session_id_value, |
|
| 209 | + $session_id_field_name |
|
| 210 | + ); |
|
| 211 | + if ($session_id == 0) { |
|
| 212 | + return new WSError(300, "Session not found"); |
|
| 213 | + } else { |
|
| 214 | + return $session_id; |
|
| 215 | + } |
|
| 216 | + } |
|
| 217 | + } |
|
| 218 | + |
|
| 219 | + /** |
|
| 220 | + * Handles an error by calling the WSError error handler |
|
| 221 | + * |
|
| 222 | + * @param WSError Error |
|
| 223 | + */ |
|
| 224 | + protected function handleError($error) { |
|
| 225 | + $handler = WSError::getErrorHandler(); |
|
| 226 | + $handler->handle($error); |
|
| 227 | + } |
|
| 228 | + |
|
| 229 | + /** |
|
| 230 | + * Gets a successful result |
|
| 231 | + * |
|
| 232 | + * @return array Array with a code of 0 and a message 'Operation was successful' |
|
| 233 | + */ |
|
| 234 | + protected function getSuccessfulResult() { |
|
| 235 | + return array('code' => 0, 'message' => 'Operation was successful'); |
|
| 236 | + } |
|
| 237 | + |
|
| 238 | + /** |
|
| 239 | + * Test function. Returns the string success |
|
| 240 | + * |
|
| 241 | + * @return string Success |
|
| 242 | + */ |
|
| 243 | + public function test() { |
|
| 244 | + return "success"; |
|
| 245 | + } |
|
| 246 | 246 | } |
| 247 | 247 | |
@@ -453,6 +453,7 @@ |
||
| 453 | 453 | * @param string Session id field name |
| 454 | 454 | * @param string Session id value |
| 455 | 455 | * @param int State (1 to subscribe, 0 to unsubscribe) |
| 456 | + * @param integer $state |
|
| 456 | 457 | * @return mixed True on success, WSError otherwise |
| 457 | 458 | */ |
| 458 | 459 | protected function changeCourseSubscription($course_id_field_name, $course_id_value, $session_id_field_name, $session_id_value, $state) { |
@@ -14,177 +14,177 @@ discard block |
||
| 14 | 14 | class WSSession extends WS |
| 15 | 15 | { |
| 16 | 16 | |
| 17 | - /** |
|
| 18 | - * Creates a session (helper method) |
|
| 19 | - * |
|
| 20 | - * @param string Name of the session |
|
| 21 | - * @param string Start date, use the 'YYYY-MM-DD' format |
|
| 22 | - * @param string End date, use the 'YYYY-MM-DD' format |
|
| 23 | - * @param int Access delays of the coach (days before) |
|
| 24 | - * @param int Access delays of the coach (days after) |
|
| 25 | - * @param int Nolimit (0 = no limit of time, 1 = limit of time) |
|
| 26 | - * @param int Visibility |
|
| 27 | - * @param string User id field name for the coach |
|
| 28 | - * @param string User id value for the coach |
|
| 29 | - * @param string Original session id field name (use "chamilo_session_id" to use internal id) |
|
| 30 | - * @param string Original session id value |
|
| 31 | - * @param array Array of extra fields |
|
| 32 | - * @return mixed Generated id in case of success, WSError otherwise |
|
| 33 | - */ |
|
| 34 | - protected function createSessionHelper( |
|
| 35 | - $name, |
|
| 36 | - $start_date, |
|
| 37 | - $end_date, |
|
| 38 | - $nb_days_access_before, |
|
| 39 | - $nb_days_access_after, |
|
| 40 | - $nolimit, |
|
| 41 | - $visibility, |
|
| 42 | - $user_id_field_name, |
|
| 43 | - $user_id_value, |
|
| 44 | - $session_id_field_name, |
|
| 45 | - $session_id_value, |
|
| 46 | - $extras |
|
| 47 | - ) { |
|
| 48 | - // Verify that coach exists and get its id |
|
| 49 | - $user_id = $this->getUserId($user_id_field_name, $user_id_value); |
|
| 50 | - if ($user_id instanceof WSError) { |
|
| 51 | - return $user_id; |
|
| 52 | - } |
|
| 17 | + /** |
|
| 18 | + * Creates a session (helper method) |
|
| 19 | + * |
|
| 20 | + * @param string Name of the session |
|
| 21 | + * @param string Start date, use the 'YYYY-MM-DD' format |
|
| 22 | + * @param string End date, use the 'YYYY-MM-DD' format |
|
| 23 | + * @param int Access delays of the coach (days before) |
|
| 24 | + * @param int Access delays of the coach (days after) |
|
| 25 | + * @param int Nolimit (0 = no limit of time, 1 = limit of time) |
|
| 26 | + * @param int Visibility |
|
| 27 | + * @param string User id field name for the coach |
|
| 28 | + * @param string User id value for the coach |
|
| 29 | + * @param string Original session id field name (use "chamilo_session_id" to use internal id) |
|
| 30 | + * @param string Original session id value |
|
| 31 | + * @param array Array of extra fields |
|
| 32 | + * @return mixed Generated id in case of success, WSError otherwise |
|
| 33 | + */ |
|
| 34 | + protected function createSessionHelper( |
|
| 35 | + $name, |
|
| 36 | + $start_date, |
|
| 37 | + $end_date, |
|
| 38 | + $nb_days_access_before, |
|
| 39 | + $nb_days_access_after, |
|
| 40 | + $nolimit, |
|
| 41 | + $visibility, |
|
| 42 | + $user_id_field_name, |
|
| 43 | + $user_id_value, |
|
| 44 | + $session_id_field_name, |
|
| 45 | + $session_id_value, |
|
| 46 | + $extras |
|
| 47 | + ) { |
|
| 48 | + // Verify that coach exists and get its id |
|
| 49 | + $user_id = $this->getUserId($user_id_field_name, $user_id_value); |
|
| 50 | + if ($user_id instanceof WSError) { |
|
| 51 | + return $user_id; |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | - $coachStartDate = null; |
|
| 55 | - if (!empty($nb_days_access_before)) { |
|
| 56 | - $day = intval($nb_days_access_before); |
|
| 57 | - $coachStartDate = date('Y-m-d ', strtotime($start_date. ' + '.$day.' days')); |
|
| 58 | - } |
|
| 54 | + $coachStartDate = null; |
|
| 55 | + if (!empty($nb_days_access_before)) { |
|
| 56 | + $day = intval($nb_days_access_before); |
|
| 57 | + $coachStartDate = date('Y-m-d ', strtotime($start_date. ' + '.$day.' days')); |
|
| 58 | + } |
|
| 59 | 59 | |
| 60 | - $coachEndDate = null; |
|
| 61 | - if (!empty($nb_days_access_after)) { |
|
| 62 | - $day = intval($nb_days_access_after); |
|
| 63 | - $coachEndDate = date('Y-m-d ', strtotime($end_date. ' + '.$day.' days')); |
|
| 64 | - } |
|
| 60 | + $coachEndDate = null; |
|
| 61 | + if (!empty($nb_days_access_after)) { |
|
| 62 | + $day = intval($nb_days_access_after); |
|
| 63 | + $coachEndDate = date('Y-m-d ', strtotime($end_date. ' + '.$day.' days')); |
|
| 64 | + } |
|
| 65 | 65 | |
| 66 | - // Try to create the session |
|
| 67 | - $session_id = SessionManager::create_session( |
|
| 68 | - $name, |
|
| 69 | - $start_date, |
|
| 70 | - $end_date, |
|
| 71 | - $start_date, |
|
| 72 | - $end_date, |
|
| 73 | - $coachStartDate, |
|
| 74 | - $coachEndDate, |
|
| 75 | - $user_id, |
|
| 76 | - 0, |
|
| 77 | - $visibility |
|
| 78 | - ); |
|
| 79 | - if(!is_int($session_id)) { |
|
| 80 | - return new WSError(301, 'Could not create the session'); |
|
| 81 | - } else { |
|
| 82 | - // Add the Original session id to the extra fields |
|
| 83 | - $extras_associative = array(); |
|
| 84 | - if($session_id_field_name != "chamilo_session_id") { |
|
| 85 | - $extras_associative[$session_id_field_name] = $session_id_value; |
|
| 86 | - } |
|
| 87 | - foreach($extras as $extra) { |
|
| 88 | - $extras_associative[$extra['field_name']] = $extra['field_value']; |
|
| 89 | - } |
|
| 90 | - // Create the extra fields |
|
| 91 | - foreach($extras_associative as $fname => $fvalue) { |
|
| 92 | - SessionManager::create_session_extra_field($fname, 1, $fname); |
|
| 93 | - SessionManager::update_session_extra_field_value( |
|
| 94 | - $session_id, |
|
| 95 | - $fname, |
|
| 96 | - $fvalue |
|
| 97 | - ); |
|
| 98 | - } |
|
| 99 | - return $session_id; |
|
| 100 | - } |
|
| 101 | - } |
|
| 66 | + // Try to create the session |
|
| 67 | + $session_id = SessionManager::create_session( |
|
| 68 | + $name, |
|
| 69 | + $start_date, |
|
| 70 | + $end_date, |
|
| 71 | + $start_date, |
|
| 72 | + $end_date, |
|
| 73 | + $coachStartDate, |
|
| 74 | + $coachEndDate, |
|
| 75 | + $user_id, |
|
| 76 | + 0, |
|
| 77 | + $visibility |
|
| 78 | + ); |
|
| 79 | + if(!is_int($session_id)) { |
|
| 80 | + return new WSError(301, 'Could not create the session'); |
|
| 81 | + } else { |
|
| 82 | + // Add the Original session id to the extra fields |
|
| 83 | + $extras_associative = array(); |
|
| 84 | + if($session_id_field_name != "chamilo_session_id") { |
|
| 85 | + $extras_associative[$session_id_field_name] = $session_id_value; |
|
| 86 | + } |
|
| 87 | + foreach($extras as $extra) { |
|
| 88 | + $extras_associative[$extra['field_name']] = $extra['field_value']; |
|
| 89 | + } |
|
| 90 | + // Create the extra fields |
|
| 91 | + foreach($extras_associative as $fname => $fvalue) { |
|
| 92 | + SessionManager::create_session_extra_field($fname, 1, $fname); |
|
| 93 | + SessionManager::update_session_extra_field_value( |
|
| 94 | + $session_id, |
|
| 95 | + $fname, |
|
| 96 | + $fvalue |
|
| 97 | + ); |
|
| 98 | + } |
|
| 99 | + return $session_id; |
|
| 100 | + } |
|
| 101 | + } |
|
| 102 | 102 | |
| 103 | - /** |
|
| 104 | - * Creates a session |
|
| 105 | - * |
|
| 106 | - * @param string API secret key |
|
| 107 | - * @param string Name of the session |
|
| 108 | - * @param string Start date, use the 'YYYY-MM-DD' format |
|
| 109 | - * @param string End date, use the 'YYYY-MM-DD' format |
|
| 110 | - * @param int Access delays of the coach (days before) |
|
| 111 | - * @param int Access delays of the coach (days after) |
|
| 112 | - * @param int Nolimit (0 = no limit of time, 1 = limit of time) |
|
| 113 | - * @param int Visibility |
|
| 114 | - * @param string User id field name for the coach |
|
| 115 | - * @param string User id value for the coach |
|
| 116 | - * @param string Original session id field name (use "chamilo_session_id" to use internal id) |
|
| 117 | - * @param string Original session id value |
|
| 118 | - * @param array Array of extra fields |
|
| 119 | - * @return int Session id generated |
|
| 120 | - */ |
|
| 121 | - public function CreateSession($secret_key, $name, $start_date, $end_date, $nb_days_access_before, $nb_days_access_after, $nolimit, $visibility, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, $extras) { |
|
| 122 | - $verifKey = $this->verifyKey($secret_key); |
|
| 123 | - if($verifKey instanceof WSError) { |
|
| 124 | - $this->handleError($verifKey); |
|
| 125 | - } else { |
|
| 126 | - $session_id = $this->createSessionHelper($name, $start_date, $end_date, $nb_days_access_before, $nb_days_access_after, $nolimit, $visibility, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, $extras); |
|
| 127 | - if($session_id instanceof WSError) { |
|
| 128 | - $this->handleError($session_id); |
|
| 129 | - } else { |
|
| 130 | - return $session_id; |
|
| 131 | - } |
|
| 132 | - } |
|
| 133 | - } |
|
| 103 | + /** |
|
| 104 | + * Creates a session |
|
| 105 | + * |
|
| 106 | + * @param string API secret key |
|
| 107 | + * @param string Name of the session |
|
| 108 | + * @param string Start date, use the 'YYYY-MM-DD' format |
|
| 109 | + * @param string End date, use the 'YYYY-MM-DD' format |
|
| 110 | + * @param int Access delays of the coach (days before) |
|
| 111 | + * @param int Access delays of the coach (days after) |
|
| 112 | + * @param int Nolimit (0 = no limit of time, 1 = limit of time) |
|
| 113 | + * @param int Visibility |
|
| 114 | + * @param string User id field name for the coach |
|
| 115 | + * @param string User id value for the coach |
|
| 116 | + * @param string Original session id field name (use "chamilo_session_id" to use internal id) |
|
| 117 | + * @param string Original session id value |
|
| 118 | + * @param array Array of extra fields |
|
| 119 | + * @return int Session id generated |
|
| 120 | + */ |
|
| 121 | + public function CreateSession($secret_key, $name, $start_date, $end_date, $nb_days_access_before, $nb_days_access_after, $nolimit, $visibility, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, $extras) { |
|
| 122 | + $verifKey = $this->verifyKey($secret_key); |
|
| 123 | + if($verifKey instanceof WSError) { |
|
| 124 | + $this->handleError($verifKey); |
|
| 125 | + } else { |
|
| 126 | + $session_id = $this->createSessionHelper($name, $start_date, $end_date, $nb_days_access_before, $nb_days_access_after, $nolimit, $visibility, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, $extras); |
|
| 127 | + if($session_id instanceof WSError) { |
|
| 128 | + $this->handleError($session_id); |
|
| 129 | + } else { |
|
| 130 | + return $session_id; |
|
| 131 | + } |
|
| 132 | + } |
|
| 133 | + } |
|
| 134 | 134 | |
| 135 | - /** |
|
| 136 | - * Deletes a session (helper method) |
|
| 137 | - * |
|
| 138 | - * @param string Session id field name |
|
| 139 | - * @param string Session id value |
|
| 140 | - * @return mixed True in case of success, WSError otherwise |
|
| 141 | - */ |
|
| 142 | - protected function deleteSessionHelper($session_id_field_name, $session_id_value) { |
|
| 143 | - $session_id = $this->getSessionId($session_id_field_name, $session_id_value); |
|
| 144 | - if($session_id instanceof WSError) { |
|
| 145 | - return $session_id; |
|
| 146 | - } else { |
|
| 147 | - SessionManager::delete($session_id, true); |
|
| 148 | - return true; |
|
| 149 | - } |
|
| 150 | - } |
|
| 135 | + /** |
|
| 136 | + * Deletes a session (helper method) |
|
| 137 | + * |
|
| 138 | + * @param string Session id field name |
|
| 139 | + * @param string Session id value |
|
| 140 | + * @return mixed True in case of success, WSError otherwise |
|
| 141 | + */ |
|
| 142 | + protected function deleteSessionHelper($session_id_field_name, $session_id_value) { |
|
| 143 | + $session_id = $this->getSessionId($session_id_field_name, $session_id_value); |
|
| 144 | + if($session_id instanceof WSError) { |
|
| 145 | + return $session_id; |
|
| 146 | + } else { |
|
| 147 | + SessionManager::delete($session_id, true); |
|
| 148 | + return true; |
|
| 149 | + } |
|
| 150 | + } |
|
| 151 | 151 | |
| 152 | - /** |
|
| 153 | - * Deletes a session |
|
| 154 | - * |
|
| 155 | - * @param string API secret key |
|
| 156 | - * @param string Session id field name |
|
| 157 | - * @param string Session id value |
|
| 158 | - */ |
|
| 159 | - public function DeleteSession($secret_key, $session_id_field_name, $session_id_value) { |
|
| 160 | - $verifKey = $this->verifyKey($secret_key); |
|
| 161 | - if($verifKey instanceof WSError) { |
|
| 162 | - $this->handleError($verifKey); |
|
| 163 | - } else { |
|
| 164 | - $result = $this->deleteSessionHelper($session_id_field_name, $session_id_value); |
|
| 165 | - if($result instanceof WSError) { |
|
| 166 | - $this->handleError($result); |
|
| 167 | - } |
|
| 168 | - } |
|
| 169 | - } |
|
| 152 | + /** |
|
| 153 | + * Deletes a session |
|
| 154 | + * |
|
| 155 | + * @param string API secret key |
|
| 156 | + * @param string Session id field name |
|
| 157 | + * @param string Session id value |
|
| 158 | + */ |
|
| 159 | + public function DeleteSession($secret_key, $session_id_field_name, $session_id_value) { |
|
| 160 | + $verifKey = $this->verifyKey($secret_key); |
|
| 161 | + if($verifKey instanceof WSError) { |
|
| 162 | + $this->handleError($verifKey); |
|
| 163 | + } else { |
|
| 164 | + $result = $this->deleteSessionHelper($session_id_field_name, $session_id_value); |
|
| 165 | + if($result instanceof WSError) { |
|
| 166 | + $this->handleError($result); |
|
| 167 | + } |
|
| 168 | + } |
|
| 169 | + } |
|
| 170 | 170 | |
| 171 | - /** |
|
| 172 | - * Edits a session (helper method) |
|
| 173 | - * |
|
| 174 | - * @param string Name of the session |
|
| 175 | - * @param string Start date, use the 'YYYY-MM-DD' format |
|
| 176 | - * @param string End date, use the 'YYYY-MM-DD' format |
|
| 177 | - * @param int Access delays of the coach (days before) |
|
| 178 | - * @param int Access delays of the coach (days after) |
|
| 179 | - * @param int Nolimit (0 = no limit of time, 1 = limit of time) |
|
| 180 | - * @param int Visibility |
|
| 181 | - * @param string User id field name for the coach |
|
| 182 | - * @param string User id value for the coach |
|
| 183 | - * @param string Original session id field name (use "chamilo_session_id" to use internal id) |
|
| 184 | - * @param string Original session id value |
|
| 185 | - * @param array Array of extra fields |
|
| 186 | - * @return mixed True on success, WSError otherwise |
|
| 187 | - */ |
|
| 171 | + /** |
|
| 172 | + * Edits a session (helper method) |
|
| 173 | + * |
|
| 174 | + * @param string Name of the session |
|
| 175 | + * @param string Start date, use the 'YYYY-MM-DD' format |
|
| 176 | + * @param string End date, use the 'YYYY-MM-DD' format |
|
| 177 | + * @param int Access delays of the coach (days before) |
|
| 178 | + * @param int Access delays of the coach (days after) |
|
| 179 | + * @param int Nolimit (0 = no limit of time, 1 = limit of time) |
|
| 180 | + * @param int Visibility |
|
| 181 | + * @param string User id field name for the coach |
|
| 182 | + * @param string User id value for the coach |
|
| 183 | + * @param string Original session id field name (use "chamilo_session_id" to use internal id) |
|
| 184 | + * @param string Original session id value |
|
| 185 | + * @param array Array of extra fields |
|
| 186 | + * @return mixed True on success, WSError otherwise |
|
| 187 | + */ |
|
| 188 | 188 | protected function editSessionHelper( |
| 189 | 189 | $name, |
| 190 | 190 | $start_date, |
@@ -199,15 +199,15 @@ discard block |
||
| 199 | 199 | $session_id_value, |
| 200 | 200 | $extras |
| 201 | 201 | ) { |
| 202 | - $session_id = $this->getSessionId($session_id_field_name, $session_id_value); |
|
| 203 | - if($session_id instanceof WSError) { |
|
| 204 | - return $session_id; |
|
| 205 | - } else { |
|
| 206 | - // Verify that coach exists and get its id |
|
| 207 | - $user_id = $this->getUserId($user_id_field_name, $user_id_value); |
|
| 208 | - if ($user_id instanceof WSError) { |
|
| 209 | - return $user_id; |
|
| 210 | - } |
|
| 202 | + $session_id = $this->getSessionId($session_id_field_name, $session_id_value); |
|
| 203 | + if($session_id instanceof WSError) { |
|
| 204 | + return $session_id; |
|
| 205 | + } else { |
|
| 206 | + // Verify that coach exists and get its id |
|
| 207 | + $user_id = $this->getUserId($user_id_field_name, $user_id_value); |
|
| 208 | + if ($user_id instanceof WSError) { |
|
| 209 | + return $user_id; |
|
| 210 | + } |
|
| 211 | 211 | |
| 212 | 212 | $coachStartDate = null; |
| 213 | 213 | if (!empty($nb_days_access_before)) { |
@@ -234,127 +234,127 @@ discard block |
||
| 234 | 234 | 0, |
| 235 | 235 | (int)$visibility |
| 236 | 236 | ); |
| 237 | - if(!is_int($result_id)) { |
|
| 238 | - return new WSError(302, 'Could not edit the session'); |
|
| 239 | - } else { |
|
| 240 | - if(!empty($extras)) { |
|
| 241 | - $extras_associative = array(); |
|
| 242 | - foreach($extras as $extra) { |
|
| 243 | - $extras_associative[$extra['field_name']] = $extra['field_value']; |
|
| 244 | - } |
|
| 245 | - // Create the extra fields |
|
| 246 | - foreach($extras_associative as $fname => $fvalue) { |
|
| 247 | - SessionManager::create_session_extra_field($fname, 1, $fname); |
|
| 248 | - SessionManager::update_session_extra_field_value($session_id, $fname, $fvalue); |
|
| 249 | - } |
|
| 250 | - } |
|
| 251 | - return true; |
|
| 252 | - } |
|
| 253 | - } |
|
| 254 | - } |
|
| 237 | + if(!is_int($result_id)) { |
|
| 238 | + return new WSError(302, 'Could not edit the session'); |
|
| 239 | + } else { |
|
| 240 | + if(!empty($extras)) { |
|
| 241 | + $extras_associative = array(); |
|
| 242 | + foreach($extras as $extra) { |
|
| 243 | + $extras_associative[$extra['field_name']] = $extra['field_value']; |
|
| 244 | + } |
|
| 245 | + // Create the extra fields |
|
| 246 | + foreach($extras_associative as $fname => $fvalue) { |
|
| 247 | + SessionManager::create_session_extra_field($fname, 1, $fname); |
|
| 248 | + SessionManager::update_session_extra_field_value($session_id, $fname, $fvalue); |
|
| 249 | + } |
|
| 250 | + } |
|
| 251 | + return true; |
|
| 252 | + } |
|
| 253 | + } |
|
| 254 | + } |
|
| 255 | 255 | |
| 256 | - /** |
|
| 257 | - * Edits a session |
|
| 258 | - * |
|
| 259 | - * @param string API secret key |
|
| 260 | - * @param string Name of the session |
|
| 261 | - * @param string Start date, use the 'YYYY-MM-DD' format |
|
| 262 | - * @param string End date, use the 'YYYY-MM-DD' format |
|
| 263 | - * @param int Access delays of the coach (days before) |
|
| 264 | - * @param int Access delays of the coach (days after) |
|
| 265 | - * @param int Nolimit (0 = no limit of time, 1 = limit of time) |
|
| 266 | - * @param int Visibility |
|
| 267 | - * @param string User id field name for the coach |
|
| 268 | - * @param string User id value for the coach |
|
| 269 | - * @param string Original session id field name (use "chamilo_session_id" to use internal id) |
|
| 270 | - * @param string Original session id value |
|
| 271 | - * @param array Array of extra fields |
|
| 272 | - */ |
|
| 273 | - public function EditSession($secret_key, $name, $start_date, $end_date, $nb_days_access_before, $nb_days_access_after, $nolimit, $visibility, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, $extras) { |
|
| 274 | - $verifKey = $this->verifyKey($secret_key); |
|
| 275 | - if($verifKey instanceof WSError) { |
|
| 276 | - $this->handleError($verifKey); |
|
| 277 | - } else { |
|
| 278 | - $result = $this->editSessionHelper($name, $start_date, $end_date, $nb_days_access_before, $nb_days_access_after, $nolimit, $visibility, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, $extras); |
|
| 279 | - if($session_id_value instanceof WSError) { |
|
| 280 | - $this->handleError($result); |
|
| 281 | - } |
|
| 282 | - } |
|
| 283 | - } |
|
| 256 | + /** |
|
| 257 | + * Edits a session |
|
| 258 | + * |
|
| 259 | + * @param string API secret key |
|
| 260 | + * @param string Name of the session |
|
| 261 | + * @param string Start date, use the 'YYYY-MM-DD' format |
|
| 262 | + * @param string End date, use the 'YYYY-MM-DD' format |
|
| 263 | + * @param int Access delays of the coach (days before) |
|
| 264 | + * @param int Access delays of the coach (days after) |
|
| 265 | + * @param int Nolimit (0 = no limit of time, 1 = limit of time) |
|
| 266 | + * @param int Visibility |
|
| 267 | + * @param string User id field name for the coach |
|
| 268 | + * @param string User id value for the coach |
|
| 269 | + * @param string Original session id field name (use "chamilo_session_id" to use internal id) |
|
| 270 | + * @param string Original session id value |
|
| 271 | + * @param array Array of extra fields |
|
| 272 | + */ |
|
| 273 | + public function EditSession($secret_key, $name, $start_date, $end_date, $nb_days_access_before, $nb_days_access_after, $nolimit, $visibility, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, $extras) { |
|
| 274 | + $verifKey = $this->verifyKey($secret_key); |
|
| 275 | + if($verifKey instanceof WSError) { |
|
| 276 | + $this->handleError($verifKey); |
|
| 277 | + } else { |
|
| 278 | + $result = $this->editSessionHelper($name, $start_date, $end_date, $nb_days_access_before, $nb_days_access_after, $nolimit, $visibility, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, $extras); |
|
| 279 | + if($session_id_value instanceof WSError) { |
|
| 280 | + $this->handleError($result); |
|
| 281 | + } |
|
| 282 | + } |
|
| 283 | + } |
|
| 284 | 284 | |
| 285 | - /** |
|
| 286 | - * Change user subscription (helper method) |
|
| 287 | - * |
|
| 288 | - * @param string User id field name |
|
| 289 | - * @param string User id value |
|
| 290 | - * @param string Session id field name |
|
| 291 | - * @param string Session id value |
|
| 292 | - * @param int State (1 to subscribe, 0 to unsubscribe) |
|
| 293 | - * @return mixed True on success, WSError otherwise |
|
| 294 | - */ |
|
| 295 | - protected function changeUserSubscription($user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, $state) { |
|
| 296 | - $session_id = $this->getSessionId($session_id_field_name, $session_id_value); |
|
| 297 | - if($session_id instanceof WSError) { |
|
| 298 | - return $session_id; |
|
| 299 | - } else { |
|
| 300 | - $user_id = $this->getUserId($user_id_field_name, $user_id_value); |
|
| 301 | - if($user_id instanceof WSError) { |
|
| 302 | - return $user_id; |
|
| 303 | - } else { |
|
| 304 | - if($state == 1) { |
|
| 305 | - SessionManager::suscribe_users_to_session($session_id, array($user_id)); |
|
| 306 | - } else { |
|
| 307 | - $result = SessionManager::unsubscribe_user_from_session($session_id, $user_id); |
|
| 308 | - if (!$result) { |
|
| 309 | - return new WSError(303, 'There was an error unsubscribing this user from the session'); |
|
| 310 | - } |
|
| 311 | - } |
|
| 312 | - return true; |
|
| 313 | - } |
|
| 314 | - } |
|
| 315 | - } |
|
| 285 | + /** |
|
| 286 | + * Change user subscription (helper method) |
|
| 287 | + * |
|
| 288 | + * @param string User id field name |
|
| 289 | + * @param string User id value |
|
| 290 | + * @param string Session id field name |
|
| 291 | + * @param string Session id value |
|
| 292 | + * @param int State (1 to subscribe, 0 to unsubscribe) |
|
| 293 | + * @return mixed True on success, WSError otherwise |
|
| 294 | + */ |
|
| 295 | + protected function changeUserSubscription($user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, $state) { |
|
| 296 | + $session_id = $this->getSessionId($session_id_field_name, $session_id_value); |
|
| 297 | + if($session_id instanceof WSError) { |
|
| 298 | + return $session_id; |
|
| 299 | + } else { |
|
| 300 | + $user_id = $this->getUserId($user_id_field_name, $user_id_value); |
|
| 301 | + if($user_id instanceof WSError) { |
|
| 302 | + return $user_id; |
|
| 303 | + } else { |
|
| 304 | + if($state == 1) { |
|
| 305 | + SessionManager::suscribe_users_to_session($session_id, array($user_id)); |
|
| 306 | + } else { |
|
| 307 | + $result = SessionManager::unsubscribe_user_from_session($session_id, $user_id); |
|
| 308 | + if (!$result) { |
|
| 309 | + return new WSError(303, 'There was an error unsubscribing this user from the session'); |
|
| 310 | + } |
|
| 311 | + } |
|
| 312 | + return true; |
|
| 313 | + } |
|
| 314 | + } |
|
| 315 | + } |
|
| 316 | 316 | |
| 317 | - /** |
|
| 318 | - * Subscribe user to a session |
|
| 319 | - * |
|
| 320 | - * @param string API secret key |
|
| 321 | - * @param string User id field name |
|
| 322 | - * @param string User id value |
|
| 323 | - * @param string Session id field name |
|
| 324 | - * @param string Session id value |
|
| 325 | - */ |
|
| 326 | - public function SubscribeUserToSession($secret_key, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value) { |
|
| 327 | - $verifKey = $this->verifyKey($secret_key); |
|
| 328 | - if($verifKey instanceof WSError) { |
|
| 329 | - $this->handleError($verifKey); |
|
| 330 | - } else { |
|
| 331 | - $result = $this->changeUserSubscription($user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, 1); |
|
| 332 | - if($result instanceof WSError) { |
|
| 333 | - $this->handleError($result); |
|
| 334 | - } |
|
| 335 | - } |
|
| 336 | - } |
|
| 317 | + /** |
|
| 318 | + * Subscribe user to a session |
|
| 319 | + * |
|
| 320 | + * @param string API secret key |
|
| 321 | + * @param string User id field name |
|
| 322 | + * @param string User id value |
|
| 323 | + * @param string Session id field name |
|
| 324 | + * @param string Session id value |
|
| 325 | + */ |
|
| 326 | + public function SubscribeUserToSession($secret_key, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value) { |
|
| 327 | + $verifKey = $this->verifyKey($secret_key); |
|
| 328 | + if($verifKey instanceof WSError) { |
|
| 329 | + $this->handleError($verifKey); |
|
| 330 | + } else { |
|
| 331 | + $result = $this->changeUserSubscription($user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, 1); |
|
| 332 | + if($result instanceof WSError) { |
|
| 333 | + $this->handleError($result); |
|
| 334 | + } |
|
| 335 | + } |
|
| 336 | + } |
|
| 337 | 337 | |
| 338 | - /** |
|
| 339 | - * Subscribe user to a session |
|
| 340 | - * |
|
| 341 | - * @param string API secret key |
|
| 342 | - * @param string User id field name |
|
| 343 | - * @param string User id value |
|
| 344 | - * @param string Session id field name |
|
| 345 | - * @param string Session id value |
|
| 346 | - */ |
|
| 347 | - public function UnsubscribeUserFromSession($secret_key, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value) { |
|
| 348 | - $verifKey = $this->verifyKey($secret_key); |
|
| 349 | - if($verifKey instanceof WSError) { |
|
| 350 | - $this->handleError($verifKey); |
|
| 351 | - } else { |
|
| 352 | - $result = $this->changeUserSubscription($user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, 0); |
|
| 353 | - if($result instanceof WSError) { |
|
| 354 | - $this->handleError($result); |
|
| 355 | - } |
|
| 356 | - } |
|
| 357 | - } |
|
| 338 | + /** |
|
| 339 | + * Subscribe user to a session |
|
| 340 | + * |
|
| 341 | + * @param string API secret key |
|
| 342 | + * @param string User id field name |
|
| 343 | + * @param string User id value |
|
| 344 | + * @param string Session id field name |
|
| 345 | + * @param string Session id value |
|
| 346 | + */ |
|
| 347 | + public function UnsubscribeUserFromSession($secret_key, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value) { |
|
| 348 | + $verifKey = $this->verifyKey($secret_key); |
|
| 349 | + if($verifKey instanceof WSError) { |
|
| 350 | + $this->handleError($verifKey); |
|
| 351 | + } else { |
|
| 352 | + $result = $this->changeUserSubscription($user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, 0); |
|
| 353 | + if($result instanceof WSError) { |
|
| 354 | + $this->handleError($result); |
|
| 355 | + } |
|
| 356 | + } |
|
| 357 | + } |
|
| 358 | 358 | |
| 359 | 359 | /** |
| 360 | 360 | * Change Teacher subscription (helper method) |
@@ -446,79 +446,79 @@ discard block |
||
| 446 | 446 | } |
| 447 | 447 | |
| 448 | 448 | /** |
| 449 | - * Change course subscription |
|
| 450 | - * |
|
| 451 | - * @param string Course id field name |
|
| 452 | - * @param string Course id value |
|
| 453 | - * @param string Session id field name |
|
| 454 | - * @param string Session id value |
|
| 455 | - * @param int State (1 to subscribe, 0 to unsubscribe) |
|
| 456 | - * @return mixed True on success, WSError otherwise |
|
| 457 | - */ |
|
| 458 | - protected function changeCourseSubscription($course_id_field_name, $course_id_value, $session_id_field_name, $session_id_value, $state) { |
|
| 459 | - $session_id = $this->getSessionId($session_id_field_name, $session_id_value); |
|
| 460 | - if($session_id instanceof WSError) { |
|
| 461 | - return $session_id; |
|
| 462 | - } else { |
|
| 463 | - $course_id = $this->getCourseId($course_id_field_name, $course_id_value); |
|
| 464 | - if($course_id instanceof WSError) { |
|
| 465 | - return $course_id; |
|
| 466 | - } else { |
|
| 467 | - if($state == 1) { |
|
| 468 | - SessionManager::add_courses_to_session($session_id, array($course_id)); |
|
| 469 | - return true; |
|
| 470 | - } else { |
|
| 471 | - $result = SessionManager::unsubscribe_course_from_session($session_id, $course_id); |
|
| 472 | - if ($result) { |
|
| 473 | - return true; |
|
| 474 | - } else { |
|
| 475 | - return new WSError(304, 'Error unsubscribing course from session'); |
|
| 476 | - } |
|
| 477 | - } |
|
| 478 | - } |
|
| 479 | - } |
|
| 449 | + * Change course subscription |
|
| 450 | + * |
|
| 451 | + * @param string Course id field name |
|
| 452 | + * @param string Course id value |
|
| 453 | + * @param string Session id field name |
|
| 454 | + * @param string Session id value |
|
| 455 | + * @param int State (1 to subscribe, 0 to unsubscribe) |
|
| 456 | + * @return mixed True on success, WSError otherwise |
|
| 457 | + */ |
|
| 458 | + protected function changeCourseSubscription($course_id_field_name, $course_id_value, $session_id_field_name, $session_id_value, $state) { |
|
| 459 | + $session_id = $this->getSessionId($session_id_field_name, $session_id_value); |
|
| 460 | + if($session_id instanceof WSError) { |
|
| 461 | + return $session_id; |
|
| 462 | + } else { |
|
| 463 | + $course_id = $this->getCourseId($course_id_field_name, $course_id_value); |
|
| 464 | + if($course_id instanceof WSError) { |
|
| 465 | + return $course_id; |
|
| 466 | + } else { |
|
| 467 | + if($state == 1) { |
|
| 468 | + SessionManager::add_courses_to_session($session_id, array($course_id)); |
|
| 469 | + return true; |
|
| 470 | + } else { |
|
| 471 | + $result = SessionManager::unsubscribe_course_from_session($session_id, $course_id); |
|
| 472 | + if ($result) { |
|
| 473 | + return true; |
|
| 474 | + } else { |
|
| 475 | + return new WSError(304, 'Error unsubscribing course from session'); |
|
| 476 | + } |
|
| 477 | + } |
|
| 478 | + } |
|
| 479 | + } |
|
| 480 | 480 | } |
| 481 | 481 | |
| 482 | - /** |
|
| 483 | - * Subscribe course to session |
|
| 484 | - * |
|
| 485 | - * @param string API secret key |
|
| 486 | - * @param string Course id field name |
|
| 487 | - * @param string Course id value |
|
| 488 | - * @param string Session id field name |
|
| 489 | - * @param string Session id value |
|
| 490 | - */ |
|
| 491 | - public function SubscribeCourseToSession($secret_key, $course_id_field_name, $course_id_value, $session_id_field_name, $session_id_value) { |
|
| 492 | - $verifKey = $this->verifyKey($secret_key); |
|
| 493 | - if($verifKey instanceof WSError) { |
|
| 494 | - $this->handleError($verifKey); |
|
| 495 | - } else { |
|
| 496 | - $result = $this->changeCourseSubscription($course_id_field_name, $course_id_value, $session_id_field_name, $session_id_value, 1); |
|
| 497 | - if($result instanceof WSError) { |
|
| 498 | - $this->handleError($result); |
|
| 499 | - } |
|
| 500 | - } |
|
| 501 | - } |
|
| 482 | + /** |
|
| 483 | + * Subscribe course to session |
|
| 484 | + * |
|
| 485 | + * @param string API secret key |
|
| 486 | + * @param string Course id field name |
|
| 487 | + * @param string Course id value |
|
| 488 | + * @param string Session id field name |
|
| 489 | + * @param string Session id value |
|
| 490 | + */ |
|
| 491 | + public function SubscribeCourseToSession($secret_key, $course_id_field_name, $course_id_value, $session_id_field_name, $session_id_value) { |
|
| 492 | + $verifKey = $this->verifyKey($secret_key); |
|
| 493 | + if($verifKey instanceof WSError) { |
|
| 494 | + $this->handleError($verifKey); |
|
| 495 | + } else { |
|
| 496 | + $result = $this->changeCourseSubscription($course_id_field_name, $course_id_value, $session_id_field_name, $session_id_value, 1); |
|
| 497 | + if($result instanceof WSError) { |
|
| 498 | + $this->handleError($result); |
|
| 499 | + } |
|
| 500 | + } |
|
| 501 | + } |
|
| 502 | 502 | |
| 503 | - /** |
|
| 504 | - * Unsubscribe course from session |
|
| 505 | - * |
|
| 506 | - * @param string API secret key |
|
| 507 | - * @param string Course id field name |
|
| 508 | - * @param string Course id value |
|
| 509 | - * @param string Session id field name |
|
| 510 | - * @param string Session id value |
|
| 511 | - */ |
|
| 512 | - public function UnsubscribeCourseFromSession($secret_key, $course_id_field_name, $course_id_value, $session_id_field_name, $session_id_value) { |
|
| 513 | - $verifKey = $this->verifyKey($secret_key); |
|
| 514 | - if($verifKey instanceof WSError) { |
|
| 515 | - $this->handleError($verifKey); |
|
| 516 | - } else { |
|
| 517 | - $result = $this->changeCourseSubscription($course_id_field_name, $course_id_value, $session_id_field_name, $session_id_value, 0); |
|
| 518 | - if($result instanceof WSError) { |
|
| 519 | - $this->handleError($result); |
|
| 520 | - } |
|
| 521 | - } |
|
| 522 | - } |
|
| 503 | + /** |
|
| 504 | + * Unsubscribe course from session |
|
| 505 | + * |
|
| 506 | + * @param string API secret key |
|
| 507 | + * @param string Course id field name |
|
| 508 | + * @param string Course id value |
|
| 509 | + * @param string Session id field name |
|
| 510 | + * @param string Session id value |
|
| 511 | + */ |
|
| 512 | + public function UnsubscribeCourseFromSession($secret_key, $course_id_field_name, $course_id_value, $session_id_field_name, $session_id_value) { |
|
| 513 | + $verifKey = $this->verifyKey($secret_key); |
|
| 514 | + if($verifKey instanceof WSError) { |
|
| 515 | + $this->handleError($verifKey); |
|
| 516 | + } else { |
|
| 517 | + $result = $this->changeCourseSubscription($course_id_field_name, $course_id_value, $session_id_field_name, $session_id_value, 0); |
|
| 518 | + if($result instanceof WSError) { |
|
| 519 | + $this->handleError($result); |
|
| 520 | + } |
|
| 521 | + } |
|
| 522 | + } |
|
| 523 | 523 | |
| 524 | 524 | } |
@@ -54,13 +54,13 @@ discard block |
||
| 54 | 54 | $coachStartDate = null; |
| 55 | 55 | if (!empty($nb_days_access_before)) { |
| 56 | 56 | $day = intval($nb_days_access_before); |
| 57 | - $coachStartDate = date('Y-m-d ', strtotime($start_date. ' + '.$day.' days')); |
|
| 57 | + $coachStartDate = date('Y-m-d ', strtotime($start_date.' + '.$day.' days')); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | $coachEndDate = null; |
| 61 | 61 | if (!empty($nb_days_access_after)) { |
| 62 | 62 | $day = intval($nb_days_access_after); |
| 63 | - $coachEndDate = date('Y-m-d ', strtotime($end_date. ' + '.$day.' days')); |
|
| 63 | + $coachEndDate = date('Y-m-d ', strtotime($end_date.' + '.$day.' days')); |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | // Try to create the session |
@@ -76,19 +76,19 @@ discard block |
||
| 76 | 76 | 0, |
| 77 | 77 | $visibility |
| 78 | 78 | ); |
| 79 | - if(!is_int($session_id)) { |
|
| 79 | + if (!is_int($session_id)) { |
|
| 80 | 80 | return new WSError(301, 'Could not create the session'); |
| 81 | 81 | } else { |
| 82 | 82 | // Add the Original session id to the extra fields |
| 83 | 83 | $extras_associative = array(); |
| 84 | - if($session_id_field_name != "chamilo_session_id") { |
|
| 84 | + if ($session_id_field_name != "chamilo_session_id") { |
|
| 85 | 85 | $extras_associative[$session_id_field_name] = $session_id_value; |
| 86 | 86 | } |
| 87 | - foreach($extras as $extra) { |
|
| 87 | + foreach ($extras as $extra) { |
|
| 88 | 88 | $extras_associative[$extra['field_name']] = $extra['field_value']; |
| 89 | 89 | } |
| 90 | 90 | // Create the extra fields |
| 91 | - foreach($extras_associative as $fname => $fvalue) { |
|
| 91 | + foreach ($extras_associative as $fname => $fvalue) { |
|
| 92 | 92 | SessionManager::create_session_extra_field($fname, 1, $fname); |
| 93 | 93 | SessionManager::update_session_extra_field_value( |
| 94 | 94 | $session_id, |
@@ -120,11 +120,11 @@ discard block |
||
| 120 | 120 | */ |
| 121 | 121 | public function CreateSession($secret_key, $name, $start_date, $end_date, $nb_days_access_before, $nb_days_access_after, $nolimit, $visibility, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, $extras) { |
| 122 | 122 | $verifKey = $this->verifyKey($secret_key); |
| 123 | - if($verifKey instanceof WSError) { |
|
| 123 | + if ($verifKey instanceof WSError) { |
|
| 124 | 124 | $this->handleError($verifKey); |
| 125 | 125 | } else { |
| 126 | 126 | $session_id = $this->createSessionHelper($name, $start_date, $end_date, $nb_days_access_before, $nb_days_access_after, $nolimit, $visibility, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, $extras); |
| 127 | - if($session_id instanceof WSError) { |
|
| 127 | + if ($session_id instanceof WSError) { |
|
| 128 | 128 | $this->handleError($session_id); |
| 129 | 129 | } else { |
| 130 | 130 | return $session_id; |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | */ |
| 142 | 142 | protected function deleteSessionHelper($session_id_field_name, $session_id_value) { |
| 143 | 143 | $session_id = $this->getSessionId($session_id_field_name, $session_id_value); |
| 144 | - if($session_id instanceof WSError) { |
|
| 144 | + if ($session_id instanceof WSError) { |
|
| 145 | 145 | return $session_id; |
| 146 | 146 | } else { |
| 147 | 147 | SessionManager::delete($session_id, true); |
@@ -158,11 +158,11 @@ discard block |
||
| 158 | 158 | */ |
| 159 | 159 | public function DeleteSession($secret_key, $session_id_field_name, $session_id_value) { |
| 160 | 160 | $verifKey = $this->verifyKey($secret_key); |
| 161 | - if($verifKey instanceof WSError) { |
|
| 161 | + if ($verifKey instanceof WSError) { |
|
| 162 | 162 | $this->handleError($verifKey); |
| 163 | 163 | } else { |
| 164 | 164 | $result = $this->deleteSessionHelper($session_id_field_name, $session_id_value); |
| 165 | - if($result instanceof WSError) { |
|
| 165 | + if ($result instanceof WSError) { |
|
| 166 | 166 | $this->handleError($result); |
| 167 | 167 | } |
| 168 | 168 | } |
@@ -200,7 +200,7 @@ discard block |
||
| 200 | 200 | $extras |
| 201 | 201 | ) { |
| 202 | 202 | $session_id = $this->getSessionId($session_id_field_name, $session_id_value); |
| 203 | - if($session_id instanceof WSError) { |
|
| 203 | + if ($session_id instanceof WSError) { |
|
| 204 | 204 | return $session_id; |
| 205 | 205 | } else { |
| 206 | 206 | // Verify that coach exists and get its id |
@@ -212,13 +212,13 @@ discard block |
||
| 212 | 212 | $coachStartDate = null; |
| 213 | 213 | if (!empty($nb_days_access_before)) { |
| 214 | 214 | $day = intval($nb_days_access_before); |
| 215 | - $coachStartDate = date('Y-m-d ', strtotime($start_date. ' + '.$day.' days')); |
|
| 215 | + $coachStartDate = date('Y-m-d ', strtotime($start_date.' + '.$day.' days')); |
|
| 216 | 216 | } |
| 217 | 217 | |
| 218 | 218 | $coachEndDate = null; |
| 219 | 219 | if (!empty($nb_days_access_after)) { |
| 220 | 220 | $day = intval($nb_days_access_after); |
| 221 | - $coachEndDate = date('Y-m-d ', strtotime($end_date. ' + '.$day.' days')); |
|
| 221 | + $coachEndDate = date('Y-m-d ', strtotime($end_date.' + '.$day.' days')); |
|
| 222 | 222 | } |
| 223 | 223 | |
| 224 | 224 | $result_id = SessionManager::edit_session( |
@@ -232,18 +232,18 @@ discard block |
||
| 232 | 232 | $coachEndDate, |
| 233 | 233 | $user_id, |
| 234 | 234 | 0, |
| 235 | - (int)$visibility |
|
| 235 | + (int) $visibility |
|
| 236 | 236 | ); |
| 237 | - if(!is_int($result_id)) { |
|
| 237 | + if (!is_int($result_id)) { |
|
| 238 | 238 | return new WSError(302, 'Could not edit the session'); |
| 239 | 239 | } else { |
| 240 | - if(!empty($extras)) { |
|
| 240 | + if (!empty($extras)) { |
|
| 241 | 241 | $extras_associative = array(); |
| 242 | - foreach($extras as $extra) { |
|
| 242 | + foreach ($extras as $extra) { |
|
| 243 | 243 | $extras_associative[$extra['field_name']] = $extra['field_value']; |
| 244 | 244 | } |
| 245 | 245 | // Create the extra fields |
| 246 | - foreach($extras_associative as $fname => $fvalue) { |
|
| 246 | + foreach ($extras_associative as $fname => $fvalue) { |
|
| 247 | 247 | SessionManager::create_session_extra_field($fname, 1, $fname); |
| 248 | 248 | SessionManager::update_session_extra_field_value($session_id, $fname, $fvalue); |
| 249 | 249 | } |
@@ -272,11 +272,11 @@ discard block |
||
| 272 | 272 | */ |
| 273 | 273 | public function EditSession($secret_key, $name, $start_date, $end_date, $nb_days_access_before, $nb_days_access_after, $nolimit, $visibility, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, $extras) { |
| 274 | 274 | $verifKey = $this->verifyKey($secret_key); |
| 275 | - if($verifKey instanceof WSError) { |
|
| 275 | + if ($verifKey instanceof WSError) { |
|
| 276 | 276 | $this->handleError($verifKey); |
| 277 | 277 | } else { |
| 278 | 278 | $result = $this->editSessionHelper($name, $start_date, $end_date, $nb_days_access_before, $nb_days_access_after, $nolimit, $visibility, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, $extras); |
| 279 | - if($session_id_value instanceof WSError) { |
|
| 279 | + if ($session_id_value instanceof WSError) { |
|
| 280 | 280 | $this->handleError($result); |
| 281 | 281 | } |
| 282 | 282 | } |
@@ -294,14 +294,14 @@ discard block |
||
| 294 | 294 | */ |
| 295 | 295 | protected function changeUserSubscription($user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, $state) { |
| 296 | 296 | $session_id = $this->getSessionId($session_id_field_name, $session_id_value); |
| 297 | - if($session_id instanceof WSError) { |
|
| 297 | + if ($session_id instanceof WSError) { |
|
| 298 | 298 | return $session_id; |
| 299 | 299 | } else { |
| 300 | 300 | $user_id = $this->getUserId($user_id_field_name, $user_id_value); |
| 301 | - if($user_id instanceof WSError) { |
|
| 301 | + if ($user_id instanceof WSError) { |
|
| 302 | 302 | return $user_id; |
| 303 | 303 | } else { |
| 304 | - if($state == 1) { |
|
| 304 | + if ($state == 1) { |
|
| 305 | 305 | SessionManager::suscribe_users_to_session($session_id, array($user_id)); |
| 306 | 306 | } else { |
| 307 | 307 | $result = SessionManager::unsubscribe_user_from_session($session_id, $user_id); |
@@ -325,11 +325,11 @@ discard block |
||
| 325 | 325 | */ |
| 326 | 326 | public function SubscribeUserToSession($secret_key, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value) { |
| 327 | 327 | $verifKey = $this->verifyKey($secret_key); |
| 328 | - if($verifKey instanceof WSError) { |
|
| 328 | + if ($verifKey instanceof WSError) { |
|
| 329 | 329 | $this->handleError($verifKey); |
| 330 | 330 | } else { |
| 331 | 331 | $result = $this->changeUserSubscription($user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, 1); |
| 332 | - if($result instanceof WSError) { |
|
| 332 | + if ($result instanceof WSError) { |
|
| 333 | 333 | $this->handleError($result); |
| 334 | 334 | } |
| 335 | 335 | } |
@@ -346,11 +346,11 @@ discard block |
||
| 346 | 346 | */ |
| 347 | 347 | public function UnsubscribeUserFromSession($secret_key, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value) { |
| 348 | 348 | $verifKey = $this->verifyKey($secret_key); |
| 349 | - if($verifKey instanceof WSError) { |
|
| 349 | + if ($verifKey instanceof WSError) { |
|
| 350 | 350 | $this->handleError($verifKey); |
| 351 | 351 | } else { |
| 352 | 352 | $result = $this->changeUserSubscription($user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, 0); |
| 353 | - if($result instanceof WSError) { |
|
| 353 | + if ($result instanceof WSError) { |
|
| 354 | 354 | $this->handleError($result); |
| 355 | 355 | } |
| 356 | 356 | } |
@@ -385,7 +385,7 @@ discard block |
||
| 385 | 385 | if ($state == 1) { |
| 386 | 386 | SessionManager::set_coach_to_course_session($user_id, $session_id, $course_id); |
| 387 | 387 | } else { |
| 388 | - $user_id = array (0 => $user_id); |
|
| 388 | + $user_id = array(0 => $user_id); |
|
| 389 | 389 | $result = SessionManager::removeUsersFromCourseSession($user_id, $session_id, $course_id); |
| 390 | 390 | if (!$result) { |
| 391 | 391 | return new WSError(303, 'There was an error unsubscribing this Teacher from the session'); |
@@ -457,14 +457,14 @@ discard block |
||
| 457 | 457 | */ |
| 458 | 458 | protected function changeCourseSubscription($course_id_field_name, $course_id_value, $session_id_field_name, $session_id_value, $state) { |
| 459 | 459 | $session_id = $this->getSessionId($session_id_field_name, $session_id_value); |
| 460 | - if($session_id instanceof WSError) { |
|
| 460 | + if ($session_id instanceof WSError) { |
|
| 461 | 461 | return $session_id; |
| 462 | 462 | } else { |
| 463 | 463 | $course_id = $this->getCourseId($course_id_field_name, $course_id_value); |
| 464 | - if($course_id instanceof WSError) { |
|
| 464 | + if ($course_id instanceof WSError) { |
|
| 465 | 465 | return $course_id; |
| 466 | 466 | } else { |
| 467 | - if($state == 1) { |
|
| 467 | + if ($state == 1) { |
|
| 468 | 468 | SessionManager::add_courses_to_session($session_id, array($course_id)); |
| 469 | 469 | return true; |
| 470 | 470 | } else { |
@@ -490,11 +490,11 @@ discard block |
||
| 490 | 490 | */ |
| 491 | 491 | public function SubscribeCourseToSession($secret_key, $course_id_field_name, $course_id_value, $session_id_field_name, $session_id_value) { |
| 492 | 492 | $verifKey = $this->verifyKey($secret_key); |
| 493 | - if($verifKey instanceof WSError) { |
|
| 493 | + if ($verifKey instanceof WSError) { |
|
| 494 | 494 | $this->handleError($verifKey); |
| 495 | 495 | } else { |
| 496 | 496 | $result = $this->changeCourseSubscription($course_id_field_name, $course_id_value, $session_id_field_name, $session_id_value, 1); |
| 497 | - if($result instanceof WSError) { |
|
| 497 | + if ($result instanceof WSError) { |
|
| 498 | 498 | $this->handleError($result); |
| 499 | 499 | } |
| 500 | 500 | } |
@@ -511,11 +511,11 @@ discard block |
||
| 511 | 511 | */ |
| 512 | 512 | public function UnsubscribeCourseFromSession($secret_key, $course_id_field_name, $course_id_value, $session_id_field_name, $session_id_value) { |
| 513 | 513 | $verifKey = $this->verifyKey($secret_key); |
| 514 | - if($verifKey instanceof WSError) { |
|
| 514 | + if ($verifKey instanceof WSError) { |
|
| 515 | 515 | $this->handleError($verifKey); |
| 516 | 516 | } else { |
| 517 | 517 | $result = $this->changeCourseSubscription($course_id_field_name, $course_id_value, $session_id_field_name, $session_id_value, 0); |
| 518 | - if($result instanceof WSError) { |
|
| 518 | + if ($result instanceof WSError) { |
|
| 519 | 519 | $this->handleError($result); |
| 520 | 520 | } |
| 521 | 521 | } |
@@ -36,6 +36,7 @@ discard block |
||
| 36 | 36 | * |
| 37 | 37 | * @param array Users |
| 38 | 38 | * @param int Set to 1 to enable and to 0 to disable |
| 39 | + * @param integer $state |
|
| 39 | 40 | * @return array Array of results |
| 40 | 41 | */ |
| 41 | 42 | protected function changeUsersActiveState($users, $state) { |
@@ -217,6 +218,11 @@ discard block |
||
| 217 | 218 | * @param string Phone. |
| 218 | 219 | * @param string Expiration date |
| 219 | 220 | * @param array Extra fields. An array with elements of the form ('field_name' => 'name_of_the_field', 'field_value' => 'value_of_the_field'). |
| 221 | + * @param integer|null $visibility |
|
| 222 | + * @param string|null $email |
|
| 223 | + * @param string|null $language |
|
| 224 | + * @param string|null $phone |
|
| 225 | + * @param string|null $expiration_date |
|
| 220 | 226 | * @return mixed New user id generated by the system, WSError otherwise |
| 221 | 227 | */ |
| 222 | 228 | protected function createUserHelper($firstname, $lastname, $status, $login, $password, $encrypt_method, $user_id_field_name, $user_id_value, $visibility, $email, $language, $phone, $expiration_date, $extras = array()) { |
@@ -11,458 +11,458 @@ |
||
| 11 | 11 | */ |
| 12 | 12 | class WSUser extends WS { |
| 13 | 13 | |
| 14 | - /** |
|
| 15 | - * Enables or disables a user |
|
| 16 | - * |
|
| 17 | - * @param string User id field name |
|
| 18 | - * @param string User id value |
|
| 19 | - * @param int Set to 1 to enable and to 0 to disable |
|
| 20 | - */ |
|
| 21 | - protected function changeUserActiveState($user_id_field_name, $user_id_value, $state) { |
|
| 22 | - $user_id = $this->getUserId($user_id_field_name, $user_id_value); |
|
| 23 | - if($user_id instanceof WSError) { |
|
| 24 | - return $user_id; |
|
| 25 | - } else { |
|
| 26 | - if($state == 0) { |
|
| 27 | - UserManager::disable($user_id); |
|
| 28 | - } else if($state == 1) { |
|
| 29 | - UserManager::enable($user_id); |
|
| 30 | - } |
|
| 31 | - } |
|
| 32 | - } |
|
| 14 | + /** |
|
| 15 | + * Enables or disables a user |
|
| 16 | + * |
|
| 17 | + * @param string User id field name |
|
| 18 | + * @param string User id value |
|
| 19 | + * @param int Set to 1 to enable and to 0 to disable |
|
| 20 | + */ |
|
| 21 | + protected function changeUserActiveState($user_id_field_name, $user_id_value, $state) { |
|
| 22 | + $user_id = $this->getUserId($user_id_field_name, $user_id_value); |
|
| 23 | + if($user_id instanceof WSError) { |
|
| 24 | + return $user_id; |
|
| 25 | + } else { |
|
| 26 | + if($state == 0) { |
|
| 27 | + UserManager::disable($user_id); |
|
| 28 | + } else if($state == 1) { |
|
| 29 | + UserManager::enable($user_id); |
|
| 30 | + } |
|
| 31 | + } |
|
| 32 | + } |
|
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * Enables or disables multiple users |
|
| 36 | - * |
|
| 37 | - * @param array Users |
|
| 38 | - * @param int Set to 1 to enable and to 0 to disable |
|
| 39 | - * @return array Array of results |
|
| 40 | - */ |
|
| 41 | - protected function changeUsersActiveState($users, $state) { |
|
| 42 | - $results = array(); |
|
| 43 | - foreach($users as $user) { |
|
| 44 | - $result_tmp = array(); |
|
| 45 | - $result_op = $this->changeUserActiveState($user['user_id_field_name'], $user['user_id_value'], $state); |
|
| 46 | - $result_tmp['user_id_value'] = $user['user_id_value']; |
|
| 47 | - if($result_op instanceof WSError) { |
|
| 48 | - // Return the error in the results |
|
| 49 | - $result_tmp['result'] = $result_op->toArray(); |
|
| 50 | - } else { |
|
| 51 | - $result_tmp['result'] = $this->getSuccessfulResult(); |
|
| 52 | - } |
|
| 53 | - $results[] = $result_tmp; |
|
| 54 | - } |
|
| 55 | - return $results; |
|
| 56 | - } |
|
| 34 | + /** |
|
| 35 | + * Enables or disables multiple users |
|
| 36 | + * |
|
| 37 | + * @param array Users |
|
| 38 | + * @param int Set to 1 to enable and to 0 to disable |
|
| 39 | + * @return array Array of results |
|
| 40 | + */ |
|
| 41 | + protected function changeUsersActiveState($users, $state) { |
|
| 42 | + $results = array(); |
|
| 43 | + foreach($users as $user) { |
|
| 44 | + $result_tmp = array(); |
|
| 45 | + $result_op = $this->changeUserActiveState($user['user_id_field_name'], $user['user_id_value'], $state); |
|
| 46 | + $result_tmp['user_id_value'] = $user['user_id_value']; |
|
| 47 | + if($result_op instanceof WSError) { |
|
| 48 | + // Return the error in the results |
|
| 49 | + $result_tmp['result'] = $result_op->toArray(); |
|
| 50 | + } else { |
|
| 51 | + $result_tmp['result'] = $this->getSuccessfulResult(); |
|
| 52 | + } |
|
| 53 | + $results[] = $result_tmp; |
|
| 54 | + } |
|
| 55 | + return $results; |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | - /** |
|
| 59 | - * Disables a user |
|
| 60 | - * |
|
| 61 | - * @param string API secret key |
|
| 62 | - * @param string User id field name. Use "chamilo_user_id" as the field name if you want to use the internal user_id |
|
| 63 | - * @param string User id value |
|
| 64 | - */ |
|
| 65 | - public function DisableUser($secret_key, $user_id_field_name, $user_id_value) { |
|
| 66 | - $verifKey = $this->verifyKey($secret_key); |
|
| 67 | - if($verifKey instanceof WSError) { |
|
| 68 | - // Let the implementation handle it |
|
| 69 | - $this->handleError($verifKey); |
|
| 70 | - } else { |
|
| 71 | - $result = $this->changeUserActiveState($user_id_field_name, $user_id_value, 0); |
|
| 72 | - if($result instanceof WSError) { |
|
| 73 | - $this->handleError($result); |
|
| 74 | - } |
|
| 75 | - } |
|
| 76 | - } |
|
| 58 | + /** |
|
| 59 | + * Disables a user |
|
| 60 | + * |
|
| 61 | + * @param string API secret key |
|
| 62 | + * @param string User id field name. Use "chamilo_user_id" as the field name if you want to use the internal user_id |
|
| 63 | + * @param string User id value |
|
| 64 | + */ |
|
| 65 | + public function DisableUser($secret_key, $user_id_field_name, $user_id_value) { |
|
| 66 | + $verifKey = $this->verifyKey($secret_key); |
|
| 67 | + if($verifKey instanceof WSError) { |
|
| 68 | + // Let the implementation handle it |
|
| 69 | + $this->handleError($verifKey); |
|
| 70 | + } else { |
|
| 71 | + $result = $this->changeUserActiveState($user_id_field_name, $user_id_value, 0); |
|
| 72 | + if($result instanceof WSError) { |
|
| 73 | + $this->handleError($result); |
|
| 74 | + } |
|
| 75 | + } |
|
| 76 | + } |
|
| 77 | 77 | |
| 78 | - /** |
|
| 79 | - * Disables multiple users |
|
| 80 | - * |
|
| 81 | - * @param string API secret key |
|
| 82 | - * @param array Array of users with elements of the form array('user_id_field_name' => 'name_of_field', 'user_id_value' => 'value') |
|
| 83 | - * @return array Array with elements like array('user_id_value' => 'value', 'result' => array('code' => 0, 'message' => 'Operation was successful')). Note that if the result array contains a code different |
|
| 84 | - * than 0, an error occured |
|
| 85 | - */ |
|
| 86 | - public function DisableUsers($secret_key, $users) { |
|
| 87 | - $verifKey = $this->verifyKey($secret_key); |
|
| 88 | - if($verifKey instanceof WSError) { |
|
| 89 | - // Let the implementation handle it |
|
| 90 | - $this->handleError($verifKey); |
|
| 91 | - } else { |
|
| 92 | - return $this->changeUsersActiveState($users, 0); |
|
| 93 | - } |
|
| 94 | - } |
|
| 78 | + /** |
|
| 79 | + * Disables multiple users |
|
| 80 | + * |
|
| 81 | + * @param string API secret key |
|
| 82 | + * @param array Array of users with elements of the form array('user_id_field_name' => 'name_of_field', 'user_id_value' => 'value') |
|
| 83 | + * @return array Array with elements like array('user_id_value' => 'value', 'result' => array('code' => 0, 'message' => 'Operation was successful')). Note that if the result array contains a code different |
|
| 84 | + * than 0, an error occured |
|
| 85 | + */ |
|
| 86 | + public function DisableUsers($secret_key, $users) { |
|
| 87 | + $verifKey = $this->verifyKey($secret_key); |
|
| 88 | + if($verifKey instanceof WSError) { |
|
| 89 | + // Let the implementation handle it |
|
| 90 | + $this->handleError($verifKey); |
|
| 91 | + } else { |
|
| 92 | + return $this->changeUsersActiveState($users, 0); |
|
| 93 | + } |
|
| 94 | + } |
|
| 95 | 95 | |
| 96 | - /** |
|
| 97 | - * Enables a user |
|
| 98 | - * |
|
| 99 | - * @param string API secret key |
|
| 100 | - * @param string User id field name. Use "chamilo_user_id" as the field name if you want to use the internal user_id |
|
| 101 | - * @param string User id value |
|
| 102 | - */ |
|
| 103 | - public function EnableUser($secret_key, $user_id_field_name, $user_id_value) { |
|
| 104 | - $verifKey = $this->verifyKey($secret_key); |
|
| 105 | - if($verifKey instanceof WSError) { |
|
| 106 | - $this->handleError($verifKey); |
|
| 107 | - } else { |
|
| 108 | - $result = $this->changeUserActiveState($user_id_field_name, $user_id_value, 1); |
|
| 109 | - if($result instanceof WSError) { |
|
| 110 | - $this->handleError($result); |
|
| 111 | - } |
|
| 112 | - } |
|
| 113 | - } |
|
| 96 | + /** |
|
| 97 | + * Enables a user |
|
| 98 | + * |
|
| 99 | + * @param string API secret key |
|
| 100 | + * @param string User id field name. Use "chamilo_user_id" as the field name if you want to use the internal user_id |
|
| 101 | + * @param string User id value |
|
| 102 | + */ |
|
| 103 | + public function EnableUser($secret_key, $user_id_field_name, $user_id_value) { |
|
| 104 | + $verifKey = $this->verifyKey($secret_key); |
|
| 105 | + if($verifKey instanceof WSError) { |
|
| 106 | + $this->handleError($verifKey); |
|
| 107 | + } else { |
|
| 108 | + $result = $this->changeUserActiveState($user_id_field_name, $user_id_value, 1); |
|
| 109 | + if($result instanceof WSError) { |
|
| 110 | + $this->handleError($result); |
|
| 111 | + } |
|
| 112 | + } |
|
| 113 | + } |
|
| 114 | 114 | |
| 115 | - /** |
|
| 116 | - * Enables multiple users |
|
| 117 | - * |
|
| 118 | - * @param string API secret key |
|
| 119 | - * @param array Array of users with elements of the form array('user_id_field_name' => 'name_of_field', 'user_id_value' => 'value') |
|
| 120 | - * @return array Array with elements like array('user_id_value' => 'value', 'result' => array('code' => 0, 'message' => 'Operation was successful')). Note that if the result array contains a code different |
|
| 121 | - * than 0, an error occured |
|
| 122 | - */ |
|
| 123 | - public function EnableUsers($secret_key, $users) { |
|
| 124 | - $verifKey = $this->verifyKey($secret_key); |
|
| 125 | - if($verifKey instanceof WSError) { |
|
| 126 | - // Let the implementation handle it |
|
| 127 | - $this->handleError($verifKey); |
|
| 128 | - } else { |
|
| 129 | - return $this->changeUsersActiveState($users, 1); |
|
| 130 | - } |
|
| 131 | - } |
|
| 115 | + /** |
|
| 116 | + * Enables multiple users |
|
| 117 | + * |
|
| 118 | + * @param string API secret key |
|
| 119 | + * @param array Array of users with elements of the form array('user_id_field_name' => 'name_of_field', 'user_id_value' => 'value') |
|
| 120 | + * @return array Array with elements like array('user_id_value' => 'value', 'result' => array('code' => 0, 'message' => 'Operation was successful')). Note that if the result array contains a code different |
|
| 121 | + * than 0, an error occured |
|
| 122 | + */ |
|
| 123 | + public function EnableUsers($secret_key, $users) { |
|
| 124 | + $verifKey = $this->verifyKey($secret_key); |
|
| 125 | + if($verifKey instanceof WSError) { |
|
| 126 | + // Let the implementation handle it |
|
| 127 | + $this->handleError($verifKey); |
|
| 128 | + } else { |
|
| 129 | + return $this->changeUsersActiveState($users, 1); |
|
| 130 | + } |
|
| 131 | + } |
|
| 132 | 132 | |
| 133 | - /** |
|
| 134 | - * Deletes a user (helper method) |
|
| 135 | - * |
|
| 136 | - * @param string User id field name. Use "chamilo_user_id" as the field name if you want to use the internal user_id |
|
| 137 | - * @param string User id value |
|
| 138 | - * @return mixed True if user was successfully deleted, WSError otherwise |
|
| 139 | - */ |
|
| 140 | - protected function deleteUserHelper($user_id_field_name, $user_id_value) { |
|
| 141 | - $user_id = $this->getUserId($user_id_field_name, $user_id_value); |
|
| 142 | - if($user_id instanceof WSError) { |
|
| 143 | - return $user_id; |
|
| 144 | - } else { |
|
| 145 | - if(!UserManager::delete_user($user_id)) { |
|
| 146 | - return new WSError(101, "There was a problem while deleting this user"); |
|
| 147 | - } else { |
|
| 148 | - return true; |
|
| 149 | - } |
|
| 150 | - } |
|
| 151 | - } |
|
| 133 | + /** |
|
| 134 | + * Deletes a user (helper method) |
|
| 135 | + * |
|
| 136 | + * @param string User id field name. Use "chamilo_user_id" as the field name if you want to use the internal user_id |
|
| 137 | + * @param string User id value |
|
| 138 | + * @return mixed True if user was successfully deleted, WSError otherwise |
|
| 139 | + */ |
|
| 140 | + protected function deleteUserHelper($user_id_field_name, $user_id_value) { |
|
| 141 | + $user_id = $this->getUserId($user_id_field_name, $user_id_value); |
|
| 142 | + if($user_id instanceof WSError) { |
|
| 143 | + return $user_id; |
|
| 144 | + } else { |
|
| 145 | + if(!UserManager::delete_user($user_id)) { |
|
| 146 | + return new WSError(101, "There was a problem while deleting this user"); |
|
| 147 | + } else { |
|
| 148 | + return true; |
|
| 149 | + } |
|
| 150 | + } |
|
| 151 | + } |
|
| 152 | 152 | |
| 153 | - /** |
|
| 154 | - * Deletes a user |
|
| 155 | - * |
|
| 156 | - * @param string API secret key |
|
| 157 | - * @param string User id field name. Use "chamilo_user_id" as the field name if you want to use the internal user_id |
|
| 158 | - * @param string User id value |
|
| 159 | - */ |
|
| 160 | - public function DeleteUser($secret_key, $user_id_field_name, $user_id_value) { |
|
| 161 | - $verifKey = $this->verifyKey($secret_key); |
|
| 162 | - if($verifKey instanceof WSError) { |
|
| 163 | - $this->handleError($verifKey); |
|
| 164 | - } else { |
|
| 165 | - $result = $this->deleteUserHelper($user_id_field_name, $user_id_value); |
|
| 166 | - if($result instanceof WSError) { |
|
| 167 | - $this->handleError($result); |
|
| 168 | - } |
|
| 169 | - } |
|
| 170 | - } |
|
| 153 | + /** |
|
| 154 | + * Deletes a user |
|
| 155 | + * |
|
| 156 | + * @param string API secret key |
|
| 157 | + * @param string User id field name. Use "chamilo_user_id" as the field name if you want to use the internal user_id |
|
| 158 | + * @param string User id value |
|
| 159 | + */ |
|
| 160 | + public function DeleteUser($secret_key, $user_id_field_name, $user_id_value) { |
|
| 161 | + $verifKey = $this->verifyKey($secret_key); |
|
| 162 | + if($verifKey instanceof WSError) { |
|
| 163 | + $this->handleError($verifKey); |
|
| 164 | + } else { |
|
| 165 | + $result = $this->deleteUserHelper($user_id_field_name, $user_id_value); |
|
| 166 | + if($result instanceof WSError) { |
|
| 167 | + $this->handleError($result); |
|
| 168 | + } |
|
| 169 | + } |
|
| 170 | + } |
|
| 171 | 171 | |
| 172 | - /** |
|
| 173 | - * Deletes multiple users |
|
| 174 | - * |
|
| 175 | - * @param string API secret key |
|
| 176 | - * @param array Array of users with elements of the form array('user_id_field_name' => 'name_of_field', 'user_id_value' => 'value') |
|
| 177 | - * @return array Array with elements like array('user_id_value' => 'value', 'result' => array('code' => 0, 'message' => 'Operation was successful')). Note that if the result array contains a code different |
|
| 178 | - * than 0, an error occured |
|
| 179 | - */ |
|
| 180 | - public function DeleteUsers($secret_key, $users) { |
|
| 181 | - $verifKey = $this->verifyKey($secret_key); |
|
| 182 | - if($verifKey instanceof WSError) { |
|
| 183 | - $this->handleError($verifKey); |
|
| 184 | - } else { |
|
| 185 | - $results = array(); |
|
| 186 | - foreach($users as $user) { |
|
| 187 | - $result_tmp = array(); |
|
| 188 | - $result_op = $this->deleteUserHelper($user['user_id_field_name'], $user['user_id_value']); |
|
| 189 | - $result_tmp['user_id_value'] = $user['user_id_value']; |
|
| 190 | - if($result_op instanceof WSError) { |
|
| 191 | - // Return the error in the results |
|
| 192 | - $result_tmp['result'] = $result_op->toArray(); |
|
| 193 | - } else { |
|
| 194 | - $result_tmp['result'] = $this->getSuccessfulResult(); |
|
| 195 | - } |
|
| 196 | - $results[] = $result_tmp; |
|
| 197 | - } |
|
| 198 | - return $results; |
|
| 199 | - } |
|
| 200 | - } |
|
| 172 | + /** |
|
| 173 | + * Deletes multiple users |
|
| 174 | + * |
|
| 175 | + * @param string API secret key |
|
| 176 | + * @param array Array of users with elements of the form array('user_id_field_name' => 'name_of_field', 'user_id_value' => 'value') |
|
| 177 | + * @return array Array with elements like array('user_id_value' => 'value', 'result' => array('code' => 0, 'message' => 'Operation was successful')). Note that if the result array contains a code different |
|
| 178 | + * than 0, an error occured |
|
| 179 | + */ |
|
| 180 | + public function DeleteUsers($secret_key, $users) { |
|
| 181 | + $verifKey = $this->verifyKey($secret_key); |
|
| 182 | + if($verifKey instanceof WSError) { |
|
| 183 | + $this->handleError($verifKey); |
|
| 184 | + } else { |
|
| 185 | + $results = array(); |
|
| 186 | + foreach($users as $user) { |
|
| 187 | + $result_tmp = array(); |
|
| 188 | + $result_op = $this->deleteUserHelper($user['user_id_field_name'], $user['user_id_value']); |
|
| 189 | + $result_tmp['user_id_value'] = $user['user_id_value']; |
|
| 190 | + if($result_op instanceof WSError) { |
|
| 191 | + // Return the error in the results |
|
| 192 | + $result_tmp['result'] = $result_op->toArray(); |
|
| 193 | + } else { |
|
| 194 | + $result_tmp['result'] = $this->getSuccessfulResult(); |
|
| 195 | + } |
|
| 196 | + $results[] = $result_tmp; |
|
| 197 | + } |
|
| 198 | + return $results; |
|
| 199 | + } |
|
| 200 | + } |
|
| 201 | 201 | |
| 202 | - /** |
|
| 203 | - * Creates a user (helper method) |
|
| 204 | - * |
|
| 205 | - * @param string User first name |
|
| 206 | - * @param string User last name |
|
| 207 | - * @param int User status |
|
| 208 | - * @param string Login name |
|
| 209 | - * @param string Password (encrypted or not) |
|
| 210 | - * @param string Encrypt method. Leave blank if you are passing the password in clear text, set to the encrypt method used to encrypt the password otherwise. Remember |
|
| 211 | - * to include the salt in the extra fields if you are encrypting the password |
|
| 212 | - * @param string User id field name. Use "chamilo_user_id" as the field name if you want to use the internal user_id |
|
| 213 | - * @param string User id value. Leave blank if you are using the internal user_id |
|
| 214 | - * @param int Visibility. |
|
| 215 | - * @param string User email. |
|
| 216 | - * @param string Language. |
|
| 217 | - * @param string Phone. |
|
| 218 | - * @param string Expiration date |
|
| 219 | - * @param array Extra fields. An array with elements of the form ('field_name' => 'name_of_the_field', 'field_value' => 'value_of_the_field'). |
|
| 220 | - * @return mixed New user id generated by the system, WSError otherwise |
|
| 221 | - */ |
|
| 222 | - protected function createUserHelper($firstname, $lastname, $status, $login, $password, $encrypt_method, $user_id_field_name, $user_id_value, $visibility, $email, $language, $phone, $expiration_date, $extras = array()) { |
|
| 202 | + /** |
|
| 203 | + * Creates a user (helper method) |
|
| 204 | + * |
|
| 205 | + * @param string User first name |
|
| 206 | + * @param string User last name |
|
| 207 | + * @param int User status |
|
| 208 | + * @param string Login name |
|
| 209 | + * @param string Password (encrypted or not) |
|
| 210 | + * @param string Encrypt method. Leave blank if you are passing the password in clear text, set to the encrypt method used to encrypt the password otherwise. Remember |
|
| 211 | + * to include the salt in the extra fields if you are encrypting the password |
|
| 212 | + * @param string User id field name. Use "chamilo_user_id" as the field name if you want to use the internal user_id |
|
| 213 | + * @param string User id value. Leave blank if you are using the internal user_id |
|
| 214 | + * @param int Visibility. |
|
| 215 | + * @param string User email. |
|
| 216 | + * @param string Language. |
|
| 217 | + * @param string Phone. |
|
| 218 | + * @param string Expiration date |
|
| 219 | + * @param array Extra fields. An array with elements of the form ('field_name' => 'name_of_the_field', 'field_value' => 'value_of_the_field'). |
|
| 220 | + * @return mixed New user id generated by the system, WSError otherwise |
|
| 221 | + */ |
|
| 222 | + protected function createUserHelper($firstname, $lastname, $status, $login, $password, $encrypt_method, $user_id_field_name, $user_id_value, $visibility, $email, $language, $phone, $expiration_date, $extras = array()) { |
|
| 223 | 223 | global $api_failureList; |
| 224 | - // Add the original user id field name and value to the extra fields if needed |
|
| 225 | - $extras_associative = array(); |
|
| 226 | - if($user_id_field_name != "chamilo_user_id") { |
|
| 227 | - $extras_associative[$user_id_field_name] = $user_id_value; |
|
| 228 | - } |
|
| 224 | + // Add the original user id field name and value to the extra fields if needed |
|
| 225 | + $extras_associative = array(); |
|
| 226 | + if($user_id_field_name != "chamilo_user_id") { |
|
| 227 | + $extras_associative[$user_id_field_name] = $user_id_value; |
|
| 228 | + } |
|
| 229 | 229 | if (!empty($extras)) { |
| 230 | 230 | foreach($extras as $extra) { |
| 231 | 231 | $extras_associative[$extra['field_name']] = $extra['field_value']; |
| 232 | 232 | } |
| 233 | 233 | } |
| 234 | - $result = UserManager::create_user($firstname, $lastname, $status, $email, $login, $password, '', $language, $phone, '', PLATFORM_AUTH_SOURCE, $expiration_date, $visibility, 0, $extras_associative, $encrypt_method); |
|
| 235 | - if (!$result) { |
|
| 236 | - $failure = $api_failureList[0]; |
|
| 237 | - if($failure == 'login-pass already taken') { |
|
| 238 | - return new WSError(102, 'This username is already taken'); |
|
| 239 | - } else if($failure == 'encrypt_method invalid') { |
|
| 240 | - return new WSError(103, 'The encryption of the password is invalid'); |
|
| 241 | - } else { |
|
| 242 | - return new WSError(104, 'There was an error creating the user'); |
|
| 243 | - } |
|
| 244 | - } else { |
|
| 245 | - return $result; |
|
| 246 | - } |
|
| 247 | - } |
|
| 234 | + $result = UserManager::create_user($firstname, $lastname, $status, $email, $login, $password, '', $language, $phone, '', PLATFORM_AUTH_SOURCE, $expiration_date, $visibility, 0, $extras_associative, $encrypt_method); |
|
| 235 | + if (!$result) { |
|
| 236 | + $failure = $api_failureList[0]; |
|
| 237 | + if($failure == 'login-pass already taken') { |
|
| 238 | + return new WSError(102, 'This username is already taken'); |
|
| 239 | + } else if($failure == 'encrypt_method invalid') { |
|
| 240 | + return new WSError(103, 'The encryption of the password is invalid'); |
|
| 241 | + } else { |
|
| 242 | + return new WSError(104, 'There was an error creating the user'); |
|
| 243 | + } |
|
| 244 | + } else { |
|
| 245 | + return $result; |
|
| 246 | + } |
|
| 247 | + } |
|
| 248 | 248 | |
| 249 | - /** |
|
| 250 | - * Creates a user |
|
| 251 | - * |
|
| 252 | - * @param string API secret key |
|
| 253 | - * @param string User first name |
|
| 254 | - * @param string User last name |
|
| 255 | - * @param int User status |
|
| 256 | - * @param string Login name |
|
| 257 | - * @param string Password (encrypted or not) |
|
| 258 | - * @param string Encrypt method. Leave blank if you are passing the password in clear text, set to the encrypt method used to encrypt the password otherwise. Remember |
|
| 259 | - * to include the salt in the extra fields if you are encrypting the password |
|
| 260 | - * @param string User id field name. Use "chamilo_user_id" as the field name if you want to use the internal user_id |
|
| 261 | - * @param string User id value. Leave blank if you are using the internal user_id |
|
| 262 | - * @param int Visibility. Set by default to 1 |
|
| 263 | - * @param string User email. Set by default to an empty string |
|
| 264 | - * @param string Language. Set by default to english |
|
| 265 | - * @param string Phone. Set by default to an empty string |
|
| 266 | - * @param string Expiration date. Set to null by default |
|
| 267 | - * @param array Extra fields. An array with elements of the form ('field_name' => 'name_of_the_field', 'field_value' => 'value_of_the_field'). Set to an empty array by default |
|
| 268 | - * @return int New user id generated by the system |
|
| 269 | - */ |
|
| 270 | - public function CreateUser($secret_key, $firstname, $lastname, $status, $login, $password, $encrypt_method, $user_id_field_name, $user_id_value, $visibility = 1, $email = '', $language = 'english', $phone = '', $expiration_date = '0000-00-00 00:00:00', $extras = array()) { |
|
| 271 | - // First, verify the secret key |
|
| 272 | - $verifKey = $this->verifyKey($secret_key); |
|
| 273 | - if($verifKey instanceof WSError) { |
|
| 274 | - $this->handleError($verifKey); |
|
| 275 | - } else { |
|
| 276 | - $result = $this->createUserHelper($firstname, $lastname, $status, $login, $password, $encrypt_method, $user_id_field_name, $user_id_value, $visibility, $email, $language, $phone, $expiration_date, $extras); |
|
| 277 | - if($result instanceof WSError) { |
|
| 278 | - $this->handleError($result); |
|
| 279 | - } else { |
|
| 280 | - return $result; |
|
| 281 | - } |
|
| 282 | - } |
|
| 283 | - } |
|
| 249 | + /** |
|
| 250 | + * Creates a user |
|
| 251 | + * |
|
| 252 | + * @param string API secret key |
|
| 253 | + * @param string User first name |
|
| 254 | + * @param string User last name |
|
| 255 | + * @param int User status |
|
| 256 | + * @param string Login name |
|
| 257 | + * @param string Password (encrypted or not) |
|
| 258 | + * @param string Encrypt method. Leave blank if you are passing the password in clear text, set to the encrypt method used to encrypt the password otherwise. Remember |
|
| 259 | + * to include the salt in the extra fields if you are encrypting the password |
|
| 260 | + * @param string User id field name. Use "chamilo_user_id" as the field name if you want to use the internal user_id |
|
| 261 | + * @param string User id value. Leave blank if you are using the internal user_id |
|
| 262 | + * @param int Visibility. Set by default to 1 |
|
| 263 | + * @param string User email. Set by default to an empty string |
|
| 264 | + * @param string Language. Set by default to english |
|
| 265 | + * @param string Phone. Set by default to an empty string |
|
| 266 | + * @param string Expiration date. Set to null by default |
|
| 267 | + * @param array Extra fields. An array with elements of the form ('field_name' => 'name_of_the_field', 'field_value' => 'value_of_the_field'). Set to an empty array by default |
|
| 268 | + * @return int New user id generated by the system |
|
| 269 | + */ |
|
| 270 | + public function CreateUser($secret_key, $firstname, $lastname, $status, $login, $password, $encrypt_method, $user_id_field_name, $user_id_value, $visibility = 1, $email = '', $language = 'english', $phone = '', $expiration_date = '0000-00-00 00:00:00', $extras = array()) { |
|
| 271 | + // First, verify the secret key |
|
| 272 | + $verifKey = $this->verifyKey($secret_key); |
|
| 273 | + if($verifKey instanceof WSError) { |
|
| 274 | + $this->handleError($verifKey); |
|
| 275 | + } else { |
|
| 276 | + $result = $this->createUserHelper($firstname, $lastname, $status, $login, $password, $encrypt_method, $user_id_field_name, $user_id_value, $visibility, $email, $language, $phone, $expiration_date, $extras); |
|
| 277 | + if($result instanceof WSError) { |
|
| 278 | + $this->handleError($result); |
|
| 279 | + } else { |
|
| 280 | + return $result; |
|
| 281 | + } |
|
| 282 | + } |
|
| 283 | + } |
|
| 284 | 284 | |
| 285 | - /** |
|
| 286 | - * Creates multiple users |
|
| 287 | - * |
|
| 288 | - * @param string API secret key |
|
| 289 | - * @param array Users array. Each member of this array must follow the structure imposed by the CreateUser method |
|
| 290 | - * @return array Array with elements of the form array('user_id_value' => 'original value sent', 'user_id_generated' => 'value_generated', 'result' => array('code' => 0, 'message' => 'Operation was successful')) |
|
| 291 | - */ |
|
| 292 | - public function CreateUsers($secret_key, $users) { |
|
| 293 | - $verifKey = $this->verifyKey($secret_key); |
|
| 294 | - if($verifKey instanceof WSError) { |
|
| 295 | - $this->handleError($verifKey); |
|
| 296 | - } else { |
|
| 297 | - $results = array(); |
|
| 298 | - foreach($users as $user) { |
|
| 299 | - $result_tmp = array(); |
|
| 285 | + /** |
|
| 286 | + * Creates multiple users |
|
| 287 | + * |
|
| 288 | + * @param string API secret key |
|
| 289 | + * @param array Users array. Each member of this array must follow the structure imposed by the CreateUser method |
|
| 290 | + * @return array Array with elements of the form array('user_id_value' => 'original value sent', 'user_id_generated' => 'value_generated', 'result' => array('code' => 0, 'message' => 'Operation was successful')) |
|
| 291 | + */ |
|
| 292 | + public function CreateUsers($secret_key, $users) { |
|
| 293 | + $verifKey = $this->verifyKey($secret_key); |
|
| 294 | + if($verifKey instanceof WSError) { |
|
| 295 | + $this->handleError($verifKey); |
|
| 296 | + } else { |
|
| 297 | + $results = array(); |
|
| 298 | + foreach($users as $user) { |
|
| 299 | + $result_tmp = array(); |
|
| 300 | 300 | // re-initialize variables just in case |
| 301 | 301 | $firstname = $lastname = $status = $login = $password = $encrypt_method = $user_id_field_name = $user_id_value = $visibility = $email = $language = $phone = $expiration_date = $extras = null; |
| 302 | - extract($user); |
|
| 303 | - $result = $this->createUserHelper($firstname, $lastname, $status, $login, $password, $encrypt_method, $user_id_field_name, $user_id_value, $visibility, $email, $language, $phone, $expiration_date, $extras); |
|
| 304 | - if($result instanceof WSError) { |
|
| 305 | - $result_tmp['result'] = $result->toArray(); |
|
| 306 | - $result_tmp['user_id_value'] = $user_id_value; |
|
| 307 | - $result_tmp['user_id_generated'] = 0; |
|
| 308 | - } else { |
|
| 309 | - $result_tmp['result'] = $this->getSuccessfulResult(); |
|
| 310 | - $result_tmp['user_id_value'] = $user_id_value; |
|
| 311 | - $result_tmp['user_id_generated'] = $result; |
|
| 312 | - } |
|
| 313 | - $results[] = $result_tmp; |
|
| 314 | - } |
|
| 315 | - return $results; |
|
| 316 | - } |
|
| 317 | - } |
|
| 302 | + extract($user); |
|
| 303 | + $result = $this->createUserHelper($firstname, $lastname, $status, $login, $password, $encrypt_method, $user_id_field_name, $user_id_value, $visibility, $email, $language, $phone, $expiration_date, $extras); |
|
| 304 | + if($result instanceof WSError) { |
|
| 305 | + $result_tmp['result'] = $result->toArray(); |
|
| 306 | + $result_tmp['user_id_value'] = $user_id_value; |
|
| 307 | + $result_tmp['user_id_generated'] = 0; |
|
| 308 | + } else { |
|
| 309 | + $result_tmp['result'] = $this->getSuccessfulResult(); |
|
| 310 | + $result_tmp['user_id_value'] = $user_id_value; |
|
| 311 | + $result_tmp['user_id_generated'] = $result; |
|
| 312 | + } |
|
| 313 | + $results[] = $result_tmp; |
|
| 314 | + } |
|
| 315 | + return $results; |
|
| 316 | + } |
|
| 317 | + } |
|
| 318 | 318 | |
| 319 | - /** |
|
| 320 | - * Edits user info (helper method) |
|
| 321 | - * |
|
| 322 | - * @param string User id field name. Use "chamilo_user_id" in order to use internal system id |
|
| 323 | - * @param string User id value |
|
| 324 | - * @param string First name |
|
| 325 | - * @param string Last name |
|
| 326 | - * @param int User status |
|
| 327 | - * @param string Login name |
|
| 328 | - * @param string Password. Leave blank if you don't want to update it |
|
| 329 | - * @param string Encrypt method |
|
| 330 | - * @param string User email |
|
| 331 | - * @param string Language. Set by default to english |
|
| 332 | - * @param string Phone. Set by default to an empty string |
|
| 333 | - * @param string Expiration date. Set to null by default |
|
| 334 | - * @param array Extra fields. An array with elements of the form ('field_name' => 'name_of_the_field', 'field_value' => 'value_of_the_field'). Leave empty if you don't want to update |
|
| 335 | - * @return mixed True if user was successfully updated, WSError otherwise |
|
| 336 | - */ |
|
| 337 | - protected function editUserHelper( |
|
| 338 | - $user_id_field_name, |
|
| 339 | - $user_id_value, |
|
| 340 | - $firstname, |
|
| 341 | - $lastname, |
|
| 342 | - $status, |
|
| 343 | - $loginname, |
|
| 344 | - $password, |
|
| 345 | - $encrypt_method, |
|
| 346 | - $email, |
|
| 347 | - $language, |
|
| 348 | - $phone, |
|
| 349 | - $expiration_date, |
|
| 350 | - $extras |
|
| 351 | - ) { |
|
| 319 | + /** |
|
| 320 | + * Edits user info (helper method) |
|
| 321 | + * |
|
| 322 | + * @param string User id field name. Use "chamilo_user_id" in order to use internal system id |
|
| 323 | + * @param string User id value |
|
| 324 | + * @param string First name |
|
| 325 | + * @param string Last name |
|
| 326 | + * @param int User status |
|
| 327 | + * @param string Login name |
|
| 328 | + * @param string Password. Leave blank if you don't want to update it |
|
| 329 | + * @param string Encrypt method |
|
| 330 | + * @param string User email |
|
| 331 | + * @param string Language. Set by default to english |
|
| 332 | + * @param string Phone. Set by default to an empty string |
|
| 333 | + * @param string Expiration date. Set to null by default |
|
| 334 | + * @param array Extra fields. An array with elements of the form ('field_name' => 'name_of_the_field', 'field_value' => 'value_of_the_field'). Leave empty if you don't want to update |
|
| 335 | + * @return mixed True if user was successfully updated, WSError otherwise |
|
| 336 | + */ |
|
| 337 | + protected function editUserHelper( |
|
| 338 | + $user_id_field_name, |
|
| 339 | + $user_id_value, |
|
| 340 | + $firstname, |
|
| 341 | + $lastname, |
|
| 342 | + $status, |
|
| 343 | + $loginname, |
|
| 344 | + $password, |
|
| 345 | + $encrypt_method, |
|
| 346 | + $email, |
|
| 347 | + $language, |
|
| 348 | + $phone, |
|
| 349 | + $expiration_date, |
|
| 350 | + $extras |
|
| 351 | + ) { |
|
| 352 | 352 | global $api_failureList; |
| 353 | - $user_id = $this->getUserId($user_id_field_name, $user_id_value); |
|
| 354 | - if($user_id instanceof WSError) { |
|
| 355 | - return $user_id; |
|
| 356 | - } else { |
|
| 357 | - if($password == '') { |
|
| 358 | - $password = null; |
|
| 359 | - } |
|
| 360 | - $user_info = api_get_user_info($user_id); |
|
| 361 | - if (count($extras) == 0) { |
|
| 362 | - $extras = null; |
|
| 363 | - } |
|
| 353 | + $user_id = $this->getUserId($user_id_field_name, $user_id_value); |
|
| 354 | + if($user_id instanceof WSError) { |
|
| 355 | + return $user_id; |
|
| 356 | + } else { |
|
| 357 | + if($password == '') { |
|
| 358 | + $password = null; |
|
| 359 | + } |
|
| 360 | + $user_info = api_get_user_info($user_id); |
|
| 361 | + if (count($extras) == 0) { |
|
| 362 | + $extras = null; |
|
| 363 | + } |
|
| 364 | 364 | |
| 365 | - $result = UserManager::update_user( |
|
| 366 | - $user_id, |
|
| 367 | - $firstname, |
|
| 368 | - $lastname, |
|
| 369 | - $loginname, |
|
| 370 | - $password, |
|
| 371 | - PLATFORM_AUTH_SOURCE, |
|
| 372 | - $email, |
|
| 373 | - $status, |
|
| 374 | - '', |
|
| 375 | - $phone, |
|
| 376 | - $user_info['picture_uri'], |
|
| 377 | - $expiration_date, |
|
| 378 | - $user_info['active'], |
|
| 379 | - null, |
|
| 380 | - $user_info['hr_dept_id'], |
|
| 381 | - $extras, |
|
| 382 | - $encrypt_method |
|
| 383 | - ); |
|
| 384 | - if (!$result) { |
|
| 385 | - $failure = $api_failureList[0]; |
|
| 386 | - if($failure == 'encrypt_method invalid') { |
|
| 387 | - return new WSError(103, 'The encryption of the password is invalid'); |
|
| 388 | - } else { |
|
| 389 | - return new WSError(105, 'There was an error updating the user'); |
|
| 390 | - } |
|
| 391 | - } else { |
|
| 392 | - return $result; |
|
| 393 | - } |
|
| 394 | - } |
|
| 395 | - } |
|
| 365 | + $result = UserManager::update_user( |
|
| 366 | + $user_id, |
|
| 367 | + $firstname, |
|
| 368 | + $lastname, |
|
| 369 | + $loginname, |
|
| 370 | + $password, |
|
| 371 | + PLATFORM_AUTH_SOURCE, |
|
| 372 | + $email, |
|
| 373 | + $status, |
|
| 374 | + '', |
|
| 375 | + $phone, |
|
| 376 | + $user_info['picture_uri'], |
|
| 377 | + $expiration_date, |
|
| 378 | + $user_info['active'], |
|
| 379 | + null, |
|
| 380 | + $user_info['hr_dept_id'], |
|
| 381 | + $extras, |
|
| 382 | + $encrypt_method |
|
| 383 | + ); |
|
| 384 | + if (!$result) { |
|
| 385 | + $failure = $api_failureList[0]; |
|
| 386 | + if($failure == 'encrypt_method invalid') { |
|
| 387 | + return new WSError(103, 'The encryption of the password is invalid'); |
|
| 388 | + } else { |
|
| 389 | + return new WSError(105, 'There was an error updating the user'); |
|
| 390 | + } |
|
| 391 | + } else { |
|
| 392 | + return $result; |
|
| 393 | + } |
|
| 394 | + } |
|
| 395 | + } |
|
| 396 | 396 | |
| 397 | - /** |
|
| 398 | - * Edits user info |
|
| 399 | - * |
|
| 400 | - * @param string API secret key |
|
| 401 | - * @param string User id field name. Use "chamilo_user_id" in order to use internal system id |
|
| 402 | - * @param string User id value |
|
| 403 | - * @param string First name |
|
| 404 | - * @param string Last name |
|
| 405 | - * @param int User status |
|
| 406 | - * @param string Login name |
|
| 407 | - * @param string Password. Leave blank if you don't want to update it |
|
| 408 | - * @param string Encrypt method |
|
| 409 | - * @param string User email |
|
| 410 | - * @param string Language. Set by default to english |
|
| 411 | - * @param string Phone. Set by default to an empty string |
|
| 412 | - * @param string Expiration date. Set to null by default |
|
| 413 | - * @param array Extra fields. An array with elements of the form ('field_name' => 'name_of_the_field', 'field_value' => 'value_of_the_field'). Leave empty if you don't want to update |
|
| 414 | - */ |
|
| 415 | - public function EditUser($secret_key, $user_id_field_name, $user_id_value, $firstname, $lastname, $status, $loginname, $password, $encrypt_method, $email, $language, $phone, $expiration_date, $extras) { |
|
| 416 | - // First, verify the secret key |
|
| 417 | - $verifKey = $this->verifyKey($secret_key); |
|
| 418 | - if($verifKey instanceof WSError) { |
|
| 419 | - $this->handleError($verifKey); |
|
| 420 | - } else { |
|
| 397 | + /** |
|
| 398 | + * Edits user info |
|
| 399 | + * |
|
| 400 | + * @param string API secret key |
|
| 401 | + * @param string User id field name. Use "chamilo_user_id" in order to use internal system id |
|
| 402 | + * @param string User id value |
|
| 403 | + * @param string First name |
|
| 404 | + * @param string Last name |
|
| 405 | + * @param int User status |
|
| 406 | + * @param string Login name |
|
| 407 | + * @param string Password. Leave blank if you don't want to update it |
|
| 408 | + * @param string Encrypt method |
|
| 409 | + * @param string User email |
|
| 410 | + * @param string Language. Set by default to english |
|
| 411 | + * @param string Phone. Set by default to an empty string |
|
| 412 | + * @param string Expiration date. Set to null by default |
|
| 413 | + * @param array Extra fields. An array with elements of the form ('field_name' => 'name_of_the_field', 'field_value' => 'value_of_the_field'). Leave empty if you don't want to update |
|
| 414 | + */ |
|
| 415 | + public function EditUser($secret_key, $user_id_field_name, $user_id_value, $firstname, $lastname, $status, $loginname, $password, $encrypt_method, $email, $language, $phone, $expiration_date, $extras) { |
|
| 416 | + // First, verify the secret key |
|
| 417 | + $verifKey = $this->verifyKey($secret_key); |
|
| 418 | + if($verifKey instanceof WSError) { |
|
| 419 | + $this->handleError($verifKey); |
|
| 420 | + } else { |
|
| 421 | 421 | |
| 422 | - $extras_associative = array(); |
|
| 423 | - if (!empty($extras)) { |
|
| 424 | - foreach($extras as $extra) { |
|
| 425 | - $extras_associative[$extra['field_name']] = $extra['field_value']; |
|
| 426 | - } |
|
| 427 | - } |
|
| 422 | + $extras_associative = array(); |
|
| 423 | + if (!empty($extras)) { |
|
| 424 | + foreach($extras as $extra) { |
|
| 425 | + $extras_associative[$extra['field_name']] = $extra['field_value']; |
|
| 426 | + } |
|
| 427 | + } |
|
| 428 | 428 | |
| 429 | - $result = $this->editUserHelper($user_id_field_name, $user_id_value, $firstname, $lastname, $status, $loginname, $password, $encrypt_method, $email, $language, $phone, $expiration_date, $extras_associative); |
|
| 430 | - if($result instanceof WSError) { |
|
| 431 | - $this->handleError($result); |
|
| 432 | - } |
|
| 433 | - } |
|
| 434 | - } |
|
| 429 | + $result = $this->editUserHelper($user_id_field_name, $user_id_value, $firstname, $lastname, $status, $loginname, $password, $encrypt_method, $email, $language, $phone, $expiration_date, $extras_associative); |
|
| 430 | + if($result instanceof WSError) { |
|
| 431 | + $this->handleError($result); |
|
| 432 | + } |
|
| 433 | + } |
|
| 434 | + } |
|
| 435 | 435 | |
| 436 | - /** |
|
| 437 | - * Edits multiple users |
|
| 438 | - * |
|
| 439 | - * @param string API secret key |
|
| 440 | - * @param array Users array. Each member of this array must follow the structure imposed by the EditUser method |
|
| 441 | - * @return array Array with elements like array('user_id_value' => 'value', 'result' => array('code' => 0, 'message' => 'Operation was successful')). Note that if the result array contains a code different |
|
| 442 | - * than 0, an error occured |
|
| 443 | - */ |
|
| 444 | - public function EditUsers($secret_key, $users) { |
|
| 445 | - $verifKey = $this->verifyKey($secret_key); |
|
| 446 | - if($verifKey instanceof WSError) { |
|
| 447 | - $this->handleError($verifKey); |
|
| 448 | - } else { |
|
| 449 | - $results = array(); |
|
| 450 | - foreach($users as $user) { |
|
| 451 | - $result_tmp = array(); |
|
| 436 | + /** |
|
| 437 | + * Edits multiple users |
|
| 438 | + * |
|
| 439 | + * @param string API secret key |
|
| 440 | + * @param array Users array. Each member of this array must follow the structure imposed by the EditUser method |
|
| 441 | + * @return array Array with elements like array('user_id_value' => 'value', 'result' => array('code' => 0, 'message' => 'Operation was successful')). Note that if the result array contains a code different |
|
| 442 | + * than 0, an error occured |
|
| 443 | + */ |
|
| 444 | + public function EditUsers($secret_key, $users) { |
|
| 445 | + $verifKey = $this->verifyKey($secret_key); |
|
| 446 | + if($verifKey instanceof WSError) { |
|
| 447 | + $this->handleError($verifKey); |
|
| 448 | + } else { |
|
| 449 | + $results = array(); |
|
| 450 | + foreach($users as $user) { |
|
| 451 | + $result_tmp = array(); |
|
| 452 | 452 | // re-initialize variables just in case |
| 453 | 453 | $user_id_field_name = $user_id_value = $firstname = $lastname = $status = $loginname = $password = $encrypt_method = $email = $language = $phone = $expiration_date = $extras = null; |
| 454 | - extract($user); |
|
| 455 | - $result_op = $this->editUserHelper($user_id_field_name, $user_id_value, $firstname, $lastname, $status, $loginname, $password, $encrypt_method, $email, $language, $phone, $expiration_date, $extras); |
|
| 456 | - $result_tmp['user_id_value'] = $user['user_id_value']; |
|
| 457 | - if($result_op instanceof WSError) { |
|
| 458 | - // Return the error in the results |
|
| 459 | - $result_tmp['result'] = $result_op->toArray(); |
|
| 460 | - } else { |
|
| 461 | - $result_tmp['result'] = $this->getSuccessfulResult(); |
|
| 462 | - } |
|
| 463 | - $results[] = $result_tmp; |
|
| 464 | - } |
|
| 465 | - return $results; |
|
| 466 | - } |
|
| 467 | - } |
|
| 454 | + extract($user); |
|
| 455 | + $result_op = $this->editUserHelper($user_id_field_name, $user_id_value, $firstname, $lastname, $status, $loginname, $password, $encrypt_method, $email, $language, $phone, $expiration_date, $extras); |
|
| 456 | + $result_tmp['user_id_value'] = $user['user_id_value']; |
|
| 457 | + if($result_op instanceof WSError) { |
|
| 458 | + // Return the error in the results |
|
| 459 | + $result_tmp['result'] = $result_op->toArray(); |
|
| 460 | + } else { |
|
| 461 | + $result_tmp['result'] = $this->getSuccessfulResult(); |
|
| 462 | + } |
|
| 463 | + $results[] = $result_tmp; |
|
| 464 | + } |
|
| 465 | + return $results; |
|
| 466 | + } |
|
| 467 | + } |
|
| 468 | 468 | } |
@@ -20,12 +20,12 @@ discard block |
||
| 20 | 20 | */ |
| 21 | 21 | protected function changeUserActiveState($user_id_field_name, $user_id_value, $state) { |
| 22 | 22 | $user_id = $this->getUserId($user_id_field_name, $user_id_value); |
| 23 | - if($user_id instanceof WSError) { |
|
| 23 | + if ($user_id instanceof WSError) { |
|
| 24 | 24 | return $user_id; |
| 25 | 25 | } else { |
| 26 | - if($state == 0) { |
|
| 26 | + if ($state == 0) { |
|
| 27 | 27 | UserManager::disable($user_id); |
| 28 | - } else if($state == 1) { |
|
| 28 | + } else if ($state == 1) { |
|
| 29 | 29 | UserManager::enable($user_id); |
| 30 | 30 | } |
| 31 | 31 | } |
@@ -40,11 +40,11 @@ discard block |
||
| 40 | 40 | */ |
| 41 | 41 | protected function changeUsersActiveState($users, $state) { |
| 42 | 42 | $results = array(); |
| 43 | - foreach($users as $user) { |
|
| 43 | + foreach ($users as $user) { |
|
| 44 | 44 | $result_tmp = array(); |
| 45 | 45 | $result_op = $this->changeUserActiveState($user['user_id_field_name'], $user['user_id_value'], $state); |
| 46 | 46 | $result_tmp['user_id_value'] = $user['user_id_value']; |
| 47 | - if($result_op instanceof WSError) { |
|
| 47 | + if ($result_op instanceof WSError) { |
|
| 48 | 48 | // Return the error in the results |
| 49 | 49 | $result_tmp['result'] = $result_op->toArray(); |
| 50 | 50 | } else { |
@@ -64,12 +64,12 @@ discard block |
||
| 64 | 64 | */ |
| 65 | 65 | public function DisableUser($secret_key, $user_id_field_name, $user_id_value) { |
| 66 | 66 | $verifKey = $this->verifyKey($secret_key); |
| 67 | - if($verifKey instanceof WSError) { |
|
| 67 | + if ($verifKey instanceof WSError) { |
|
| 68 | 68 | // Let the implementation handle it |
| 69 | 69 | $this->handleError($verifKey); |
| 70 | 70 | } else { |
| 71 | 71 | $result = $this->changeUserActiveState($user_id_field_name, $user_id_value, 0); |
| 72 | - if($result instanceof WSError) { |
|
| 72 | + if ($result instanceof WSError) { |
|
| 73 | 73 | $this->handleError($result); |
| 74 | 74 | } |
| 75 | 75 | } |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | */ |
| 86 | 86 | public function DisableUsers($secret_key, $users) { |
| 87 | 87 | $verifKey = $this->verifyKey($secret_key); |
| 88 | - if($verifKey instanceof WSError) { |
|
| 88 | + if ($verifKey instanceof WSError) { |
|
| 89 | 89 | // Let the implementation handle it |
| 90 | 90 | $this->handleError($verifKey); |
| 91 | 91 | } else { |
@@ -102,11 +102,11 @@ discard block |
||
| 102 | 102 | */ |
| 103 | 103 | public function EnableUser($secret_key, $user_id_field_name, $user_id_value) { |
| 104 | 104 | $verifKey = $this->verifyKey($secret_key); |
| 105 | - if($verifKey instanceof WSError) { |
|
| 105 | + if ($verifKey instanceof WSError) { |
|
| 106 | 106 | $this->handleError($verifKey); |
| 107 | 107 | } else { |
| 108 | 108 | $result = $this->changeUserActiveState($user_id_field_name, $user_id_value, 1); |
| 109 | - if($result instanceof WSError) { |
|
| 109 | + if ($result instanceof WSError) { |
|
| 110 | 110 | $this->handleError($result); |
| 111 | 111 | } |
| 112 | 112 | } |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | */ |
| 123 | 123 | public function EnableUsers($secret_key, $users) { |
| 124 | 124 | $verifKey = $this->verifyKey($secret_key); |
| 125 | - if($verifKey instanceof WSError) { |
|
| 125 | + if ($verifKey instanceof WSError) { |
|
| 126 | 126 | // Let the implementation handle it |
| 127 | 127 | $this->handleError($verifKey); |
| 128 | 128 | } else { |
@@ -139,10 +139,10 @@ discard block |
||
| 139 | 139 | */ |
| 140 | 140 | protected function deleteUserHelper($user_id_field_name, $user_id_value) { |
| 141 | 141 | $user_id = $this->getUserId($user_id_field_name, $user_id_value); |
| 142 | - if($user_id instanceof WSError) { |
|
| 142 | + if ($user_id instanceof WSError) { |
|
| 143 | 143 | return $user_id; |
| 144 | 144 | } else { |
| 145 | - if(!UserManager::delete_user($user_id)) { |
|
| 145 | + if (!UserManager::delete_user($user_id)) { |
|
| 146 | 146 | return new WSError(101, "There was a problem while deleting this user"); |
| 147 | 147 | } else { |
| 148 | 148 | return true; |
@@ -159,11 +159,11 @@ discard block |
||
| 159 | 159 | */ |
| 160 | 160 | public function DeleteUser($secret_key, $user_id_field_name, $user_id_value) { |
| 161 | 161 | $verifKey = $this->verifyKey($secret_key); |
| 162 | - if($verifKey instanceof WSError) { |
|
| 162 | + if ($verifKey instanceof WSError) { |
|
| 163 | 163 | $this->handleError($verifKey); |
| 164 | 164 | } else { |
| 165 | 165 | $result = $this->deleteUserHelper($user_id_field_name, $user_id_value); |
| 166 | - if($result instanceof WSError) { |
|
| 166 | + if ($result instanceof WSError) { |
|
| 167 | 167 | $this->handleError($result); |
| 168 | 168 | } |
| 169 | 169 | } |
@@ -179,15 +179,15 @@ discard block |
||
| 179 | 179 | */ |
| 180 | 180 | public function DeleteUsers($secret_key, $users) { |
| 181 | 181 | $verifKey = $this->verifyKey($secret_key); |
| 182 | - if($verifKey instanceof WSError) { |
|
| 182 | + if ($verifKey instanceof WSError) { |
|
| 183 | 183 | $this->handleError($verifKey); |
| 184 | 184 | } else { |
| 185 | 185 | $results = array(); |
| 186 | - foreach($users as $user) { |
|
| 186 | + foreach ($users as $user) { |
|
| 187 | 187 | $result_tmp = array(); |
| 188 | 188 | $result_op = $this->deleteUserHelper($user['user_id_field_name'], $user['user_id_value']); |
| 189 | 189 | $result_tmp['user_id_value'] = $user['user_id_value']; |
| 190 | - if($result_op instanceof WSError) { |
|
| 190 | + if ($result_op instanceof WSError) { |
|
| 191 | 191 | // Return the error in the results |
| 192 | 192 | $result_tmp['result'] = $result_op->toArray(); |
| 193 | 193 | } else { |
@@ -223,20 +223,20 @@ discard block |
||
| 223 | 223 | global $api_failureList; |
| 224 | 224 | // Add the original user id field name and value to the extra fields if needed |
| 225 | 225 | $extras_associative = array(); |
| 226 | - if($user_id_field_name != "chamilo_user_id") { |
|
| 226 | + if ($user_id_field_name != "chamilo_user_id") { |
|
| 227 | 227 | $extras_associative[$user_id_field_name] = $user_id_value; |
| 228 | 228 | } |
| 229 | 229 | if (!empty($extras)) { |
| 230 | - foreach($extras as $extra) { |
|
| 230 | + foreach ($extras as $extra) { |
|
| 231 | 231 | $extras_associative[$extra['field_name']] = $extra['field_value']; |
| 232 | 232 | } |
| 233 | 233 | } |
| 234 | 234 | $result = UserManager::create_user($firstname, $lastname, $status, $email, $login, $password, '', $language, $phone, '', PLATFORM_AUTH_SOURCE, $expiration_date, $visibility, 0, $extras_associative, $encrypt_method); |
| 235 | 235 | if (!$result) { |
| 236 | 236 | $failure = $api_failureList[0]; |
| 237 | - if($failure == 'login-pass already taken') { |
|
| 237 | + if ($failure == 'login-pass already taken') { |
|
| 238 | 238 | return new WSError(102, 'This username is already taken'); |
| 239 | - } else if($failure == 'encrypt_method invalid') { |
|
| 239 | + } else if ($failure == 'encrypt_method invalid') { |
|
| 240 | 240 | return new WSError(103, 'The encryption of the password is invalid'); |
| 241 | 241 | } else { |
| 242 | 242 | return new WSError(104, 'There was an error creating the user'); |
@@ -270,11 +270,11 @@ discard block |
||
| 270 | 270 | public function CreateUser($secret_key, $firstname, $lastname, $status, $login, $password, $encrypt_method, $user_id_field_name, $user_id_value, $visibility = 1, $email = '', $language = 'english', $phone = '', $expiration_date = '0000-00-00 00:00:00', $extras = array()) { |
| 271 | 271 | // First, verify the secret key |
| 272 | 272 | $verifKey = $this->verifyKey($secret_key); |
| 273 | - if($verifKey instanceof WSError) { |
|
| 273 | + if ($verifKey instanceof WSError) { |
|
| 274 | 274 | $this->handleError($verifKey); |
| 275 | 275 | } else { |
| 276 | 276 | $result = $this->createUserHelper($firstname, $lastname, $status, $login, $password, $encrypt_method, $user_id_field_name, $user_id_value, $visibility, $email, $language, $phone, $expiration_date, $extras); |
| 277 | - if($result instanceof WSError) { |
|
| 277 | + if ($result instanceof WSError) { |
|
| 278 | 278 | $this->handleError($result); |
| 279 | 279 | } else { |
| 280 | 280 | return $result; |
@@ -291,17 +291,17 @@ discard block |
||
| 291 | 291 | */ |
| 292 | 292 | public function CreateUsers($secret_key, $users) { |
| 293 | 293 | $verifKey = $this->verifyKey($secret_key); |
| 294 | - if($verifKey instanceof WSError) { |
|
| 294 | + if ($verifKey instanceof WSError) { |
|
| 295 | 295 | $this->handleError($verifKey); |
| 296 | 296 | } else { |
| 297 | 297 | $results = array(); |
| 298 | - foreach($users as $user) { |
|
| 298 | + foreach ($users as $user) { |
|
| 299 | 299 | $result_tmp = array(); |
| 300 | 300 | // re-initialize variables just in case |
| 301 | 301 | $firstname = $lastname = $status = $login = $password = $encrypt_method = $user_id_field_name = $user_id_value = $visibility = $email = $language = $phone = $expiration_date = $extras = null; |
| 302 | 302 | extract($user); |
| 303 | 303 | $result = $this->createUserHelper($firstname, $lastname, $status, $login, $password, $encrypt_method, $user_id_field_name, $user_id_value, $visibility, $email, $language, $phone, $expiration_date, $extras); |
| 304 | - if($result instanceof WSError) { |
|
| 304 | + if ($result instanceof WSError) { |
|
| 305 | 305 | $result_tmp['result'] = $result->toArray(); |
| 306 | 306 | $result_tmp['user_id_value'] = $user_id_value; |
| 307 | 307 | $result_tmp['user_id_generated'] = 0; |
@@ -351,10 +351,10 @@ discard block |
||
| 351 | 351 | ) { |
| 352 | 352 | global $api_failureList; |
| 353 | 353 | $user_id = $this->getUserId($user_id_field_name, $user_id_value); |
| 354 | - if($user_id instanceof WSError) { |
|
| 354 | + if ($user_id instanceof WSError) { |
|
| 355 | 355 | return $user_id; |
| 356 | 356 | } else { |
| 357 | - if($password == '') { |
|
| 357 | + if ($password == '') { |
|
| 358 | 358 | $password = null; |
| 359 | 359 | } |
| 360 | 360 | $user_info = api_get_user_info($user_id); |
@@ -383,7 +383,7 @@ discard block |
||
| 383 | 383 | ); |
| 384 | 384 | if (!$result) { |
| 385 | 385 | $failure = $api_failureList[0]; |
| 386 | - if($failure == 'encrypt_method invalid') { |
|
| 386 | + if ($failure == 'encrypt_method invalid') { |
|
| 387 | 387 | return new WSError(103, 'The encryption of the password is invalid'); |
| 388 | 388 | } else { |
| 389 | 389 | return new WSError(105, 'There was an error updating the user'); |
@@ -415,19 +415,19 @@ discard block |
||
| 415 | 415 | public function EditUser($secret_key, $user_id_field_name, $user_id_value, $firstname, $lastname, $status, $loginname, $password, $encrypt_method, $email, $language, $phone, $expiration_date, $extras) { |
| 416 | 416 | // First, verify the secret key |
| 417 | 417 | $verifKey = $this->verifyKey($secret_key); |
| 418 | - if($verifKey instanceof WSError) { |
|
| 418 | + if ($verifKey instanceof WSError) { |
|
| 419 | 419 | $this->handleError($verifKey); |
| 420 | 420 | } else { |
| 421 | 421 | |
| 422 | 422 | $extras_associative = array(); |
| 423 | 423 | if (!empty($extras)) { |
| 424 | - foreach($extras as $extra) { |
|
| 424 | + foreach ($extras as $extra) { |
|
| 425 | 425 | $extras_associative[$extra['field_name']] = $extra['field_value']; |
| 426 | 426 | } |
| 427 | 427 | } |
| 428 | 428 | |
| 429 | 429 | $result = $this->editUserHelper($user_id_field_name, $user_id_value, $firstname, $lastname, $status, $loginname, $password, $encrypt_method, $email, $language, $phone, $expiration_date, $extras_associative); |
| 430 | - if($result instanceof WSError) { |
|
| 430 | + if ($result instanceof WSError) { |
|
| 431 | 431 | $this->handleError($result); |
| 432 | 432 | } |
| 433 | 433 | } |
@@ -443,18 +443,18 @@ discard block |
||
| 443 | 443 | */ |
| 444 | 444 | public function EditUsers($secret_key, $users) { |
| 445 | 445 | $verifKey = $this->verifyKey($secret_key); |
| 446 | - if($verifKey instanceof WSError) { |
|
| 446 | + if ($verifKey instanceof WSError) { |
|
| 447 | 447 | $this->handleError($verifKey); |
| 448 | 448 | } else { |
| 449 | 449 | $results = array(); |
| 450 | - foreach($users as $user) { |
|
| 450 | + foreach ($users as $user) { |
|
| 451 | 451 | $result_tmp = array(); |
| 452 | 452 | // re-initialize variables just in case |
| 453 | 453 | $user_id_field_name = $user_id_value = $firstname = $lastname = $status = $loginname = $password = $encrypt_method = $email = $language = $phone = $expiration_date = $extras = null; |
| 454 | 454 | extract($user); |
| 455 | 455 | $result_op = $this->editUserHelper($user_id_field_name, $user_id_value, $firstname, $lastname, $status, $loginname, $password, $encrypt_method, $email, $language, $phone, $expiration_date, $extras); |
| 456 | 456 | $result_tmp['user_id_value'] = $user['user_id_value']; |
| 457 | - if($result_op instanceof WSError) { |
|
| 457 | + if ($result_op instanceof WSError) { |
|
| 458 | 458 | // Return the error in the results |
| 459 | 459 | $result_tmp['result'] = $result_op->toArray(); |
| 460 | 460 | } else { |
@@ -212,7 +212,7 @@ |
||
| 212 | 212 | * @param array $arr1 first array |
| 213 | 213 | * @param array $arr2 second array |
| 214 | 214 | * |
| 215 | - * @return array difference between the two arrays |
|
| 215 | + * @return string difference between the two arrays |
|
| 216 | 216 | */ |
| 217 | 217 | function diff($arr1, $arr2) |
| 218 | 218 | { |
@@ -62,7 +62,7 @@ |
||
| 62 | 62 | |
| 63 | 63 | if (api_is_allowed_to_edit() || api_is_coach()) { |
| 64 | 64 | //Search for all files that are not deleted => visibility != 2 |
| 65 | - $sql = "SELECT DISTINCT |
|
| 65 | + $sql = "SELECT DISTINCT |
|
| 66 | 66 | url, |
| 67 | 67 | title, |
| 68 | 68 | description, |
@@ -9,7 +9,7 @@ discard block |
||
| 9 | 9 | |
| 10 | 10 | $work_id = $_GET['id']; |
| 11 | 11 | require_once '../inc/global.inc.php'; |
| 12 | -$current_course_tool = TOOL_STUDENTPUBLICATION; |
|
| 12 | +$current_course_tool = TOOL_STUDENTPUBLICATION; |
|
| 13 | 13 | $_course = api_get_course_info(); |
| 14 | 14 | |
| 15 | 15 | // Protection |
@@ -178,10 +178,10 @@ discard block |
||
| 178 | 178 | if (!empty($files)) { |
| 179 | 179 | $fileName = api_replace_dangerous_char($work_data['title']); |
| 180 | 180 | // Logging |
| 181 | - Event::event_download($fileName .'.zip (folder)'); |
|
| 181 | + Event::event_download($fileName.'.zip (folder)'); |
|
| 182 | 182 | |
| 183 | 183 | //start download of created file |
| 184 | - $name = $fileName .'.zip'; |
|
| 184 | + $name = $fileName.'.zip'; |
|
| 185 | 185 | if (Security::check_abs_path($temp_zip_file, api_get_path(SYS_ARCHIVE_PATH))) { |
| 186 | 186 | DocumentManager::file_send_for_download($temp_zip_file, true, $name); |
| 187 | 187 | @unlink($temp_zip_file); |
@@ -370,7 +370,7 @@ discard block |
||
| 370 | 370 | * Register a user into a queue for a session |
| 371 | 371 | * @param $userId |
| 372 | 372 | * @param $sessionId |
| 373 | - * @return bool|int |
|
| 373 | + * @return false|string |
|
| 374 | 374 | */ |
| 375 | 375 | public function addToQueue($userId, $sessionId) |
| 376 | 376 | { |
@@ -396,7 +396,7 @@ discard block |
||
| 396 | 396 | * Register message with type and status |
| 397 | 397 | * @param $mailId |
| 398 | 398 | * @param $userId |
| 399 | - * @param $sessionId |
|
| 399 | + * @param integer $sessionId |
|
| 400 | 400 | * @return bool|int |
| 401 | 401 | */ |
| 402 | 402 | public function saveLastMessage($mailId, $userId, $sessionId) |
@@ -509,7 +509,7 @@ discard block |
||
| 509 | 509 | |
| 510 | 510 | /** |
| 511 | 511 | * Check if session is open for subscription |
| 512 | - * @param $sessionId |
|
| 512 | + * @param integer $sessionId |
|
| 513 | 513 | * @param string $fieldVariable |
| 514 | 514 | * @return bool |
| 515 | 515 | */ |
@@ -531,8 +531,8 @@ discard block |
||
| 531 | 531 | |
| 532 | 532 | /** |
| 533 | 533 | * Check if user is in the session's target group based on its area |
| 534 | - * @param $userId |
|
| 535 | - * @param $sessionId |
|
| 534 | + * @param integer $userId |
|
| 535 | + * @param integer $sessionId |
|
| 536 | 536 | * @param string $userFieldVariable |
| 537 | 537 | * @param string $sessionFieldVariable |
| 538 | 538 | * @return bool |
@@ -1002,7 +1002,7 @@ discard block |
||
| 1002 | 1002 | /** |
| 1003 | 1003 | * Return the session details data from a session ID (including the extra |
| 1004 | 1004 | * fields used for the advanced subscription mechanism) |
| 1005 | - * @param $sessionId |
|
| 1005 | + * @param integer $sessionId |
|
| 1006 | 1006 | * @return bool|mixed |
| 1007 | 1007 | */ |
| 1008 | 1008 | public function getSessionDetails($sessionId) |
@@ -1102,7 +1102,7 @@ discard block |
||
| 1102 | 1102 | |
| 1103 | 1103 | /** |
| 1104 | 1104 | * Return the url to go to session |
| 1105 | - * @param $sessionId |
|
| 1105 | + * @param integer $sessionId |
|
| 1106 | 1106 | * |
| 1107 | 1107 | * @return string |
| 1108 | 1108 | */ |
@@ -1069,7 +1069,7 @@ |
||
| 1069 | 1069 | */ |
| 1070 | 1070 | public function getStatusMessage($status, $isAble = true) |
| 1071 | 1071 | { |
| 1072 | - $message = ''; |
|
| 1072 | + $message = ''; |
|
| 1073 | 1073 | switch ($status) { |
| 1074 | 1074 | case ADVANCED_SUBSCRIPTION_QUEUE_STATUS_NO_QUEUE: |
| 1075 | 1075 | if ($isAble) { |
@@ -106,15 +106,15 @@ discard block |
||
| 106 | 106 | { |
| 107 | 107 | $advancedSubscriptionQueueTable = Database::get_main_table(TABLE_ADVANCED_SUBSCRIPTION_QUEUE); |
| 108 | 108 | |
| 109 | - $sql = "CREATE TABLE IF NOT EXISTS $advancedSubscriptionQueueTable (" . |
|
| 110 | - "id int UNSIGNED NOT NULL AUTO_INCREMENT, " . |
|
| 111 | - "session_id int UNSIGNED NOT NULL, " . |
|
| 112 | - "user_id int UNSIGNED NOT NULL, " . |
|
| 113 | - "status int UNSIGNED NOT NULL, " . |
|
| 114 | - "last_message_id int UNSIGNED NOT NULL, " . |
|
| 115 | - "created_at datetime NOT NULL, " . |
|
| 116 | - "updated_at datetime NULL, " . |
|
| 117 | - "PRIMARY KEY PK_advanced_subscription_queue (id), " . |
|
| 109 | + $sql = "CREATE TABLE IF NOT EXISTS $advancedSubscriptionQueueTable (". |
|
| 110 | + "id int UNSIGNED NOT NULL AUTO_INCREMENT, ". |
|
| 111 | + "session_id int UNSIGNED NOT NULL, ". |
|
| 112 | + "user_id int UNSIGNED NOT NULL, ". |
|
| 113 | + "status int UNSIGNED NOT NULL, ". |
|
| 114 | + "last_message_id int UNSIGNED NOT NULL, ". |
|
| 115 | + "created_at datetime NOT NULL, ". |
|
| 116 | + "updated_at datetime NULL, ". |
|
| 117 | + "PRIMARY KEY PK_advanced_subscription_queue (id), ". |
|
| 118 | 118 | "UNIQUE KEY UK_advanced_subscription_queue (user_id, session_id)); "; |
| 119 | 119 | Database::query($sql); |
| 120 | 120 | } |
@@ -265,11 +265,10 @@ discard block |
||
| 265 | 265 | $now = new DateTime(api_get_utc_datetime()); |
| 266 | 266 | $newYearDate = $plugin->get('course_session_credit_year_start_date'); |
| 267 | 267 | $newYearDate = !empty($newYearDate) ? |
| 268 | - new \DateTime($newYearDate . $now->format('/Y')) : |
|
| 269 | - $now; |
|
| 268 | + new \DateTime($newYearDate.$now->format('/Y')) : $now; |
|
| 270 | 269 | $extra = new ExtraFieldValue('session'); |
| 271 | - $joinSessionTable = Database::get_main_table(TABLE_MAIN_SESSION_USER) . ' su INNER JOIN ' . |
|
| 272 | - Database::get_main_table(TABLE_MAIN_SESSION) . ' s ON s.id = su.session_id'; |
|
| 270 | + $joinSessionTable = Database::get_main_table(TABLE_MAIN_SESSION_USER).' su INNER JOIN '. |
|
| 271 | + Database::get_main_table(TABLE_MAIN_SESSION).' s ON s.id = su.session_id'; |
|
| 273 | 272 | $whereSessionParams = 'su.relation_type = ? AND s.access_start_date >= ? AND su.user_id = ?'; |
| 274 | 273 | $whereSessionParamsValues = array( |
| 275 | 274 | 0, |
@@ -734,14 +733,14 @@ discard block |
||
| 734 | 733 | $tpl->assign('termsContent', $termsAndConditions); |
| 735 | 734 | $termsAndConditions = $tpl->fetch('/advanced_subscription/views/terms_and_conditions_to_pdf.tpl'); |
| 736 | 735 | $pdf = new PDF(); |
| 737 | - $filename = 'terms' . sha1(rand(0,99999)); |
|
| 736 | + $filename = 'terms'.sha1(rand(0, 99999)); |
|
| 738 | 737 | $pdf->content_to_pdf($termsAndConditions, null, $filename, null, 'F'); |
| 739 | 738 | $fileAttachments['file'][] = array( |
| 740 | - 'name' => $filename . '.pdf', |
|
| 741 | - 'application/pdf' => $filename . '.pdf', |
|
| 742 | - 'tmp_name' => api_get_path(SYS_ARCHIVE_PATH) . $filename . '.pdf', |
|
| 739 | + 'name' => $filename.'.pdf', |
|
| 740 | + 'application/pdf' => $filename.'.pdf', |
|
| 741 | + 'tmp_name' => api_get_path(SYS_ARCHIVE_PATH).$filename.'.pdf', |
|
| 743 | 742 | 'error' => UPLOAD_ERR_OK, |
| 744 | - 'size' => filesize(api_get_path(SYS_ARCHIVE_PATH) . $filename . '.pdf'), |
|
| 743 | + 'size' => filesize(api_get_path(SYS_ARCHIVE_PATH).$filename.'.pdf'), |
|
| 745 | 744 | ); |
| 746 | 745 | $fileAttachments['comments'][] = get_lang('TermsAndConditions'); |
| 747 | 746 | } |
@@ -1032,7 +1031,7 @@ discard block |
||
| 1032 | 1031 | |
| 1033 | 1032 | $mergedArray = array_merge(array($sessionId), array_keys($fields)); |
| 1034 | 1033 | |
| 1035 | - $sql = "SELECT * FROM " . Database::get_main_table(TABLE_EXTRA_FIELD_VALUES) ." |
|
| 1034 | + $sql = "SELECT * FROM ".Database::get_main_table(TABLE_EXTRA_FIELD_VALUES)." |
|
| 1036 | 1035 | WHERE item_id = %d AND field_id IN (%d, %d, %d, %d, %d, %d, %d)"; |
| 1037 | 1036 | $sql = vsprintf($sql, $mergedArray); |
| 1038 | 1037 | $sessionFieldValueList = Database::query($sql); |
@@ -1048,10 +1047,10 @@ discard block |
||
| 1048 | 1047 | $sessionArray['description'] = SessionManager::getDescriptionFromSessionId($sessionId); |
| 1049 | 1048 | |
| 1050 | 1049 | if (isset($sessionArray['brochure'])) { |
| 1051 | - $sessionArray['brochure'] = api_get_path(WEB_UPLOAD_PATH) . $sessionArray['brochure']; |
|
| 1050 | + $sessionArray['brochure'] = api_get_path(WEB_UPLOAD_PATH).$sessionArray['brochure']; |
|
| 1052 | 1051 | } |
| 1053 | 1052 | if (isset($sessionArray['banner'])) { |
| 1054 | - $sessionArray['banner'] = api_get_path(WEB_UPLOAD_PATH) . $sessionArray['banner']; |
|
| 1053 | + $sessionArray['banner'] = api_get_path(WEB_UPLOAD_PATH).$sessionArray['banner']; |
|
| 1055 | 1054 | } |
| 1056 | 1055 | |
| 1057 | 1056 | return $sessionArray; |
@@ -1108,7 +1107,7 @@ discard block |
||
| 1108 | 1107 | */ |
| 1109 | 1108 | public function getSessionUrl($sessionId) |
| 1110 | 1109 | { |
| 1111 | - $url = api_get_path(WEB_CODE_PATH) . 'session/?session_id=' . intval($sessionId); |
|
| 1110 | + $url = api_get_path(WEB_CODE_PATH).'session/?session_id='.intval($sessionId); |
|
| 1112 | 1111 | |
| 1113 | 1112 | return $url; |
| 1114 | 1113 | } |
@@ -1157,16 +1156,16 @@ discard block |
||
| 1157 | 1156 | */ |
| 1158 | 1157 | public function getQueueUrl($params) |
| 1159 | 1158 | { |
| 1160 | - $url = api_get_path(WEB_PLUGIN_PATH) . 'advanced_subscription/ajax/advanced_subscription.ajax.php?' . |
|
| 1161 | - 'a=' . Security::remove_XSS($params['action']) . '&' . |
|
| 1162 | - 's=' . intval($params['sessionId']) . '&' . |
|
| 1163 | - 'current_user_id=' . intval($params['currentUserId']) . '&' . |
|
| 1164 | - 'e=' . intval($params['newStatus']) . '&' . |
|
| 1165 | - 'u=' . intval($params['studentUserId']) . '&' . |
|
| 1166 | - 'q=' . intval($params['queueId']) . '&' . |
|
| 1167 | - 'is_connected=' . 1 . '&' . |
|
| 1168 | - 'profile_completed=' . intval($params['profile_completed']) . '&' . |
|
| 1169 | - 'v=' . $this->generateHash($params); |
|
| 1159 | + $url = api_get_path(WEB_PLUGIN_PATH).'advanced_subscription/ajax/advanced_subscription.ajax.php?'. |
|
| 1160 | + 'a='.Security::remove_XSS($params['action']).'&'. |
|
| 1161 | + 's='.intval($params['sessionId']).'&'. |
|
| 1162 | + 'current_user_id='.intval($params['currentUserId']).'&'. |
|
| 1163 | + 'e='.intval($params['newStatus']).'&'. |
|
| 1164 | + 'u='.intval($params['studentUserId']).'&'. |
|
| 1165 | + 'q='.intval($params['queueId']).'&'. |
|
| 1166 | + 'is_connected='.1.'&'. |
|
| 1167 | + 'profile_completed='.intval($params['profile_completed']).'&'. |
|
| 1168 | + 'v='.$this->generateHash($params); |
|
| 1170 | 1169 | |
| 1171 | 1170 | return $url; |
| 1172 | 1171 | } |
@@ -1219,7 +1218,7 @@ discard block |
||
| 1219 | 1218 | } |
| 1220 | 1219 | $queueTable = Database::get_main_table(TABLE_ADVANCED_SUBSCRIPTION_QUEUE); |
| 1221 | 1220 | $userTable = Database::get_main_table(TABLE_MAIN_USER); |
| 1222 | - $userJoinTable = $queueTable . ' q INNER JOIN ' . $userTable . ' u ON q.user_id = u.user_id'; |
|
| 1221 | + $userJoinTable = $queueTable.' q INNER JOIN '.$userTable.' u ON q.user_id = u.user_id'; |
|
| 1223 | 1222 | $where = array( |
| 1224 | 1223 | 'where' => array( |
| 1225 | 1224 | 'q.session_id = ?' => array( |
@@ -1232,7 +1231,7 @@ discard block |
||
| 1232 | 1231 | $students = Database::select($select, $userJoinTable, $where); |
| 1233 | 1232 | foreach ($students as &$student) { |
| 1234 | 1233 | $status = intval($student['status']); |
| 1235 | - switch($status) { |
|
| 1234 | + switch ($status) { |
|
| 1236 | 1235 | case ADVANCED_SUBSCRIPTION_QUEUE_STATUS_NO_QUEUE: |
| 1237 | 1236 | case ADVANCED_SUBSCRIPTION_QUEUE_STATUS_START: |
| 1238 | 1237 | $student['validation'] = ''; |
@@ -1246,7 +1245,7 @@ discard block |
||
| 1246 | 1245 | $student['validation'] = 'Yes'; |
| 1247 | 1246 | break; |
| 1248 | 1247 | default: |
| 1249 | - error_log(__FILE__ . ' ' . __FUNCTION__ . ' Student status no detected'); |
|
| 1248 | + error_log(__FILE__.' '.__FUNCTION__.' Student status no detected'); |
|
| 1250 | 1249 | } |
| 1251 | 1250 | } |
| 1252 | 1251 | $return = array( |
@@ -1295,7 +1294,7 @@ discard block |
||
| 1295 | 1294 | $dataPrepared['queueId'] = intval($data['queueId']); |
| 1296 | 1295 | $dataPrepared['newStatus'] = intval($data['newStatus']); |
| 1297 | 1296 | $dataPrepared = serialize($dataPrepared); |
| 1298 | - return sha1($dataPrepared . $key); |
|
| 1297 | + return sha1($dataPrepared.$key); |
|
| 1299 | 1298 | } |
| 1300 | 1299 | |
| 1301 | 1300 | /** |
@@ -1350,12 +1349,12 @@ discard block |
||
| 1350 | 1349 | break; |
| 1351 | 1350 | } |
| 1352 | 1351 | |
| 1353 | - $url = api_get_path(WEB_PLUGIN_PATH) . "advanced_subscription/src/terms_and_conditions.php?"; |
|
| 1352 | + $url = api_get_path(WEB_PLUGIN_PATH)."advanced_subscription/src/terms_and_conditions.php?"; |
|
| 1354 | 1353 | $url .= http_build_query($urlParams); |
| 1355 | 1354 | |
| 1356 | 1355 | // Launch popup |
| 1357 | 1356 | if ($mode == ADVANCED_SUBSCRIPTION_TERMS_MODE_POPUP) { |
| 1358 | - $url = 'javascript:void(window.open(\'' . $url .'\',\'AdvancedSubscriptionTerms\', \'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=700px,height=600px\', \'100\' ))'; |
|
| 1357 | + $url = 'javascript:void(window.open(\''.$url.'\',\'AdvancedSubscriptionTerms\', \'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=700px,height=600px\', \'100\' ))'; |
|
| 1359 | 1358 | } |
| 1360 | 1359 | return $url; |
| 1361 | 1360 | } |
@@ -1367,9 +1366,9 @@ discard block |
||
| 1367 | 1366 | */ |
| 1368 | 1367 | public function getRenderMailUrl($params) |
| 1369 | 1368 | { |
| 1370 | - $url = api_get_path(WEB_PLUGIN_PATH) . 'advanced_subscription/src/render_mail.php?' . |
|
| 1371 | - 'q=' . $params['queueId'] . '&' . |
|
| 1372 | - 'v=' . $this->generateHash($params); |
|
| 1369 | + $url = api_get_path(WEB_PLUGIN_PATH).'advanced_subscription/src/render_mail.php?'. |
|
| 1370 | + 'q='.$params['queueId'].'&'. |
|
| 1371 | + 'v='.$this->generateHash($params); |
|
| 1373 | 1372 | return $url; |
| 1374 | 1373 | } |
| 1375 | 1374 | |
@@ -1440,7 +1439,7 @@ discard block |
||
| 1440 | 1439 | sf.extra_field_type = $extraFieldType AND |
| 1441 | 1440 | sf.variable = 'is_induction_session' AND |
| 1442 | 1441 | su.relation_type = 0 AND |
| 1443 | - su.user_id = " . intval($userId); |
|
| 1442 | + su.user_id = ".intval($userId); |
|
| 1444 | 1443 | |
| 1445 | 1444 | $result = Database::query($sql); |
| 1446 | 1445 | |
@@ -59,6 +59,9 @@ |
||
| 59 | 59 | $this->_bbbServerBaseUrl = CONFIG_SERVER_BASE_URL; |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | + /** |
|
| 63 | + * @param string $url |
|
| 64 | + */ |
|
| 62 | 65 | private function _processXmlResponse($url){ |
| 63 | 66 | /* |
| 64 | 67 | A private utility method used by other public methods to process XML responses. |
@@ -55,25 +55,25 @@ discard block |
||
| 55 | 55 | */ |
| 56 | 56 | // BASE CONFIGS - set these for your BBB server in config.php and they will |
| 57 | 57 | // simply flow in here via the constants: |
| 58 | - $this->_securitySalt = CONFIG_SECURITY_SALT; |
|
| 59 | - $this->_bbbServerBaseUrl = CONFIG_SERVER_BASE_URL; |
|
| 58 | + $this->_securitySalt = CONFIG_SECURITY_SALT; |
|
| 59 | + $this->_bbbServerBaseUrl = CONFIG_SERVER_BASE_URL; |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | - private function _processXmlResponse($url){ |
|
| 62 | + private function _processXmlResponse($url) { |
|
| 63 | 63 | /* |
| 64 | 64 | A private utility method used by other public methods to process XML responses. |
| 65 | 65 | */ |
| 66 | 66 | if (extension_loaded('curl')) { |
| 67 | - $ch = curl_init() or die ( curl_error($ch) ); |
|
| 67 | + $ch = curl_init() or die (curl_error($ch)); |
|
| 68 | 68 | $timeout = 10; |
| 69 | - curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false); |
|
| 70 | - curl_setopt( $ch, CURLOPT_URL, $url ); |
|
| 71 | - curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 ); |
|
| 72 | - curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT, $timeout); |
|
| 73 | - $data = curl_exec( $ch ); |
|
| 74 | - curl_close( $ch ); |
|
| 75 | - |
|
| 76 | - if($data) |
|
| 69 | + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); |
|
| 70 | + curl_setopt($ch, CURLOPT_URL, $url); |
|
| 71 | + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
|
| 72 | + curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); |
|
| 73 | + $data = curl_exec($ch); |
|
| 74 | + curl_close($ch); |
|
| 75 | + |
|
| 76 | + if ($data) |
|
| 77 | 77 | return (new SimpleXMLElement($data)); |
| 78 | 78 | else |
| 79 | 79 | return false; |
@@ -137,10 +137,10 @@ discard block |
||
| 137 | 137 | '&duration='.urlencode($creationParams['duration']); |
| 138 | 138 | //'&meta_category='.urlencode($creationParams['meta_category']); |
| 139 | 139 | $welcomeMessage = $creationParams['welcomeMsg']; |
| 140 | - if(trim($welcomeMessage)) |
|
| 140 | + if (trim($welcomeMessage)) |
|
| 141 | 141 | $params .= '&welcome='.urlencode($welcomeMessage); |
| 142 | 142 | // Return the complete URL: |
| 143 | - return ( $creationUrl.$params.'&checksum='.sha1("create".$params.$this->_securitySalt) ); |
|
| 143 | + return ($creationUrl.$params.'&checksum='.sha1("create".$params.$this->_securitySalt)); |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | public function createMeetingWithXmlResponseArray($creationParams) { |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | $xml = $this->_processXmlResponse($this->getCreateMeetingURL($creationParams)); |
| 166 | 166 | |
| 167 | 167 | if ($xml) { |
| 168 | - if($xml->meetingID) |
|
| 168 | + if ($xml->meetingID) |
|
| 169 | 169 | return array( |
| 170 | 170 | 'returncode' => $xml->returncode, |
| 171 | 171 | 'message' => $xml->message, |
@@ -283,7 +283,7 @@ discard block |
||
| 283 | 283 | $meetingId = '1234' -- REQUIRED - The unique id for the meeting |
| 284 | 284 | */ |
| 285 | 285 | $xml = $this->_processXmlResponse($this->getIsMeetingRunningUrl($meetingId)); |
| 286 | - if($xml) { |
|
| 286 | + if ($xml) { |
|
| 287 | 287 | return array( |
| 288 | 288 | 'returncode' => $xml->returncode, |
| 289 | 289 | 'running' => $xml->running // -- Returns true/false. |
@@ -310,7 +310,7 @@ discard block |
||
| 310 | 310 | and then handle the results that we get in the XML response. |
| 311 | 311 | */ |
| 312 | 312 | $xml = $this->_processXmlResponse($this->getGetMeetingsUrl()); |
| 313 | - if($xml) { |
|
| 313 | + if ($xml) { |
|
| 314 | 314 | // If we don't get a success code, stop processing and return just the returncode: |
| 315 | 315 | if ($xml->returncode != 'SUCCESS') { |
| 316 | 316 | $result = array( |
@@ -379,7 +379,7 @@ discard block |
||
| 379 | 379 | ); |
| 380 | 380 | */ |
| 381 | 381 | $xml = $this->_processXmlResponse($this->getMeetingInfoUrl($infoParams)); |
| 382 | - if($xml) { |
|
| 382 | + if ($xml) { |
|
| 383 | 383 | // If we don't get a success code or messageKey, find out why: |
| 384 | 384 | if (($xml->returncode != 'SUCCESS') || ($xml->messageKey == null)) { |
| 385 | 385 | $result = array( |
@@ -454,7 +454,7 @@ discard block |
||
| 454 | 454 | probably be required in user code when 'recording' is set to true. |
| 455 | 455 | */ |
| 456 | 456 | $xml = $this->_processXmlResponse($this->getRecordingsUrl($recordingParams)); |
| 457 | - if($xml) { |
|
| 457 | + if ($xml) { |
|
| 458 | 458 | // If we don't get a success code or messageKey, find out why: |
| 459 | 459 | if (($xml->returncode != 'SUCCESS') || ($xml->messageKey == null)) { |
| 460 | 460 | $result = array( |
@@ -524,7 +524,7 @@ discard block |
||
| 524 | 524 | ); |
| 525 | 525 | */ |
| 526 | 526 | $xml = $this->_processXmlResponse($this->getPublishRecordingsUrl($recordingParams)); |
| 527 | - if($xml) { |
|
| 527 | + if ($xml) { |
|
| 528 | 528 | return array( |
| 529 | 529 | 'returncode' => $xml->returncode, |
| 530 | 530 | 'published' => $xml->published // -- Returns true/false. |
@@ -557,7 +557,7 @@ discard block |
||
| 557 | 557 | */ |
| 558 | 558 | |
| 559 | 559 | $xml = $this->_processXmlResponse($this->getDeleteRecordingsUrl($recordingParams)); |
| 560 | - if($xml) { |
|
| 560 | + if ($xml) { |
|
| 561 | 561 | return array( |
| 562 | 562 | 'returncode' => $xml->returncode, |
| 563 | 563 | 'deleted' => $xml->deleted // -- Returns true/false. |
@@ -73,10 +73,11 @@ discard block |
||
| 73 | 73 | $data = curl_exec( $ch ); |
| 74 | 74 | curl_close( $ch ); |
| 75 | 75 | |
| 76 | - if($data) |
|
| 77 | - return (new SimpleXMLElement($data)); |
|
| 78 | - else |
|
| 79 | - return false; |
|
| 76 | + if($data) { |
|
| 77 | + return (new SimpleXMLElement($data)); |
|
| 78 | + } else { |
|
| 79 | + return false; |
|
| 80 | + } |
|
| 80 | 81 | } |
| 81 | 82 | return (simplexml_load_file($url)); |
| 82 | 83 | } |
@@ -85,11 +86,9 @@ discard block |
||
| 85 | 86 | /* Process required params and throw errors if we don't get values */ |
| 86 | 87 | if ((isset($param)) && ($param != '')) { |
| 87 | 88 | return $param; |
| 88 | - } |
|
| 89 | - elseif (!isset($param)) { |
|
| 89 | + } elseif (!isset($param)) { |
|
| 90 | 90 | throw new Exception('Missing parameter.'); |
| 91 | - } |
|
| 92 | - else { |
|
| 91 | + } else { |
|
| 93 | 92 | throw new Exception(''.$param.' is required.'); |
| 94 | 93 | } |
| 95 | 94 | } |
@@ -99,8 +98,7 @@ discard block |
||
| 99 | 98 | /* Don't know if we'll use this one, but let's build it in case. */ |
| 100 | 99 | if ((isset($param)) && ($param != '')) { |
| 101 | 100 | return $param; |
| 102 | - } |
|
| 103 | - else { |
|
| 101 | + } else { |
|
| 104 | 102 | $param = ''; |
| 105 | 103 | return $param; |
| 106 | 104 | } |
@@ -137,8 +135,9 @@ discard block |
||
| 137 | 135 | '&duration='.urlencode($creationParams['duration']); |
| 138 | 136 | //'&meta_category='.urlencode($creationParams['meta_category']); |
| 139 | 137 | $welcomeMessage = $creationParams['welcomeMsg']; |
| 140 | - if(trim($welcomeMessage)) |
|
| 141 | - $params .= '&welcome='.urlencode($welcomeMessage); |
|
| 138 | + if(trim($welcomeMessage)) { |
|
| 139 | + $params .= '&welcome='.urlencode($welcomeMessage); |
|
| 140 | + } |
|
| 142 | 141 | // Return the complete URL: |
| 143 | 142 | return ( $creationUrl.$params.'&checksum='.sha1("create".$params.$this->_securitySalt) ); |
| 144 | 143 | } |
@@ -165,8 +164,8 @@ discard block |
||
| 165 | 164 | $xml = $this->_processXmlResponse($this->getCreateMeetingURL($creationParams)); |
| 166 | 165 | |
| 167 | 166 | if ($xml) { |
| 168 | - if($xml->meetingID) |
|
| 169 | - return array( |
|
| 167 | + if($xml->meetingID) { |
|
| 168 | + return array( |
|
| 170 | 169 | 'returncode' => $xml->returncode, |
| 171 | 170 | 'message' => $xml->message, |
| 172 | 171 | 'messageKey' => $xml->messageKey, |
@@ -176,14 +175,14 @@ discard block |
||
| 176 | 175 | 'hasBeenForciblyEnded' => $xml->hasBeenForciblyEnded, |
| 177 | 176 | 'createTime' => $xml->createTime |
| 178 | 177 | ); |
| 179 | - else |
|
| 180 | - return array( |
|
| 178 | + } else { |
|
| 179 | + return array( |
|
| 181 | 180 | 'returncode' => $xml->returncode, |
| 182 | 181 | 'message' => $xml->message, |
| 183 | 182 | 'messageKey' => $xml->messageKey |
| 184 | 183 | ); |
| 185 | - } |
|
| 186 | - else { |
|
| 184 | + } |
|
| 185 | + } else { |
|
| 187 | 186 | return null; |
| 188 | 187 | } |
| 189 | 188 | } |
@@ -253,8 +252,7 @@ discard block |
||
| 253 | 252 | 'message' => $xml->message, |
| 254 | 253 | 'messageKey' => $xml->messageKey |
| 255 | 254 | ); |
| 256 | - } |
|
| 257 | - else { |
|
| 255 | + } else { |
|
| 258 | 256 | return null; |
| 259 | 257 | } |
| 260 | 258 | |
@@ -288,8 +286,7 @@ discard block |
||
| 288 | 286 | 'returncode' => $xml->returncode, |
| 289 | 287 | 'running' => $xml->running // -- Returns true/false. |
| 290 | 288 | ); |
| 291 | - } |
|
| 292 | - else { |
|
| 289 | + } else { |
|
| 293 | 290 | return null; |
| 294 | 291 | } |
| 295 | 292 | |
@@ -317,8 +314,7 @@ discard block |
||
| 317 | 314 | 'returncode' => $xml->returncode |
| 318 | 315 | ); |
| 319 | 316 | return $result; |
| 320 | - } |
|
| 321 | - elseif ($xml->messageKey == 'noMeetings') { |
|
| 317 | + } elseif ($xml->messageKey == 'noMeetings') { |
|
| 322 | 318 | /* No meetings on server, so return just this info: */ |
| 323 | 319 | $result = array( |
| 324 | 320 | 'returncode' => $xml->returncode, |
@@ -326,8 +322,7 @@ discard block |
||
| 326 | 322 | 'message' => $xml->message |
| 327 | 323 | ); |
| 328 | 324 | return $result; |
| 329 | - } |
|
| 330 | - else { |
|
| 325 | + } else { |
|
| 331 | 326 | // In this case, we have success and meetings. First return general response: |
| 332 | 327 | $result = array( |
| 333 | 328 | 'returncode' => $xml->returncode, |
@@ -348,8 +343,7 @@ discard block |
||
| 348 | 343 | } |
| 349 | 344 | return $result; |
| 350 | 345 | } |
| 351 | - } |
|
| 352 | - else { |
|
| 346 | + } else { |
|
| 353 | 347 | return null; |
| 354 | 348 | } |
| 355 | 349 | |
@@ -388,8 +382,7 @@ discard block |
||
| 388 | 382 | 'message' => $xml->message |
| 389 | 383 | ); |
| 390 | 384 | return $result; |
| 391 | - } |
|
| 392 | - else { |
|
| 385 | + } else { |
|
| 393 | 386 | // In this case, we have success and meeting info: |
| 394 | 387 | $result = array( |
| 395 | 388 | 'returncode' => $xml->returncode, |
@@ -418,8 +411,7 @@ discard block |
||
| 418 | 411 | } |
| 419 | 412 | return $result; |
| 420 | 413 | } |
| 421 | - } |
|
| 422 | - else { |
|
| 414 | + } else { |
|
| 423 | 415 | return null; |
| 424 | 416 | } |
| 425 | 417 | |
@@ -463,8 +455,7 @@ discard block |
||
| 463 | 455 | 'message' => $xml->message |
| 464 | 456 | ); |
| 465 | 457 | return $result; |
| 466 | - } |
|
| 467 | - else { |
|
| 458 | + } else { |
|
| 468 | 459 | // In this case, we have success and recording info: |
| 469 | 460 | $result = array( |
| 470 | 461 | 'returncode' => $xml->returncode, |
@@ -495,8 +486,7 @@ discard block |
||
| 495 | 486 | } |
| 496 | 487 | return $result; |
| 497 | 488 | } |
| 498 | - } |
|
| 499 | - else { |
|
| 489 | + } else { |
|
| 500 | 490 | return null; |
| 501 | 491 | } |
| 502 | 492 | } |
@@ -529,8 +519,7 @@ discard block |
||
| 529 | 519 | 'returncode' => $xml->returncode, |
| 530 | 520 | 'published' => $xml->published // -- Returns true/false. |
| 531 | 521 | ); |
| 532 | - } |
|
| 533 | - else { |
|
| 522 | + } else { |
|
| 534 | 523 | return null; |
| 535 | 524 | } |
| 536 | 525 | |
@@ -562,8 +551,7 @@ discard block |
||
| 562 | 551 | 'returncode' => $xml->returncode, |
| 563 | 552 | 'deleted' => $xml->deleted // -- Returns true/false. |
| 564 | 553 | ); |
| 565 | - } |
|
| 566 | - else { |
|
| 554 | + } else { |
|
| 567 | 555 | return null; |
| 568 | 556 | } |
| 569 | 557 | |
@@ -44,107 +44,107 @@ discard block |
||
| 44 | 44 | |
| 45 | 45 | class BigBlueButtonBN { |
| 46 | 46 | |
| 47 | - private $_securitySalt; |
|
| 48 | - private $_bbbServerBaseUrl; |
|
| 47 | + private $_securitySalt; |
|
| 48 | + private $_bbbServerBaseUrl; |
|
| 49 | 49 | |
| 50 | - /* ___________ General Methods for the BigBlueButton Class __________ */ |
|
| 50 | + /* ___________ General Methods for the BigBlueButton Class __________ */ |
|
| 51 | 51 | |
| 52 | - function __construct() { |
|
| 53 | - /* |
|
| 52 | + function __construct() { |
|
| 53 | + /* |
|
| 54 | 54 | Establish just our basic elements in the constructor: |
| 55 | 55 | */ |
| 56 | - // BASE CONFIGS - set these for your BBB server in config.php and they will |
|
| 57 | - // simply flow in here via the constants: |
|
| 58 | - $this->_securitySalt = CONFIG_SECURITY_SALT; |
|
| 59 | - $this->_bbbServerBaseUrl = CONFIG_SERVER_BASE_URL; |
|
| 60 | - } |
|
| 61 | - |
|
| 62 | - private function _processXmlResponse($url){ |
|
| 63 | - /* |
|
| 56 | + // BASE CONFIGS - set these for your BBB server in config.php and they will |
|
| 57 | + // simply flow in here via the constants: |
|
| 58 | + $this->_securitySalt = CONFIG_SECURITY_SALT; |
|
| 59 | + $this->_bbbServerBaseUrl = CONFIG_SERVER_BASE_URL; |
|
| 60 | + } |
|
| 61 | + |
|
| 62 | + private function _processXmlResponse($url){ |
|
| 63 | + /* |
|
| 64 | 64 | A private utility method used by other public methods to process XML responses. |
| 65 | 65 | */ |
| 66 | - if (extension_loaded('curl')) { |
|
| 67 | - $ch = curl_init() or die ( curl_error($ch) ); |
|
| 68 | - $timeout = 10; |
|
| 69 | - curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false); |
|
| 70 | - curl_setopt( $ch, CURLOPT_URL, $url ); |
|
| 71 | - curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 ); |
|
| 72 | - curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT, $timeout); |
|
| 73 | - $data = curl_exec( $ch ); |
|
| 74 | - curl_close( $ch ); |
|
| 75 | - |
|
| 76 | - if($data) |
|
| 77 | - return (new SimpleXMLElement($data)); |
|
| 78 | - else |
|
| 79 | - return false; |
|
| 80 | - } |
|
| 81 | - return (simplexml_load_file($url)); |
|
| 82 | - } |
|
| 83 | - |
|
| 84 | - private function _requiredParam($param) { |
|
| 85 | - /* Process required params and throw errors if we don't get values */ |
|
| 86 | - if ((isset($param)) && ($param != '')) { |
|
| 87 | - return $param; |
|
| 88 | - } |
|
| 89 | - elseif (!isset($param)) { |
|
| 90 | - throw new Exception('Missing parameter.'); |
|
| 91 | - } |
|
| 92 | - else { |
|
| 93 | - throw new Exception(''.$param.' is required.'); |
|
| 94 | - } |
|
| 95 | - } |
|
| 96 | - |
|
| 97 | - private function _optionalParam($param) { |
|
| 98 | - /* Pass most optional params through as set value, or set to '' */ |
|
| 99 | - /* Don't know if we'll use this one, but let's build it in case. */ |
|
| 100 | - if ((isset($param)) && ($param != '')) { |
|
| 101 | - return $param; |
|
| 102 | - } |
|
| 103 | - else { |
|
| 104 | - $param = ''; |
|
| 105 | - return $param; |
|
| 106 | - } |
|
| 107 | - } |
|
| 108 | - |
|
| 109 | - /* __________________ BBB ADMINISTRATION METHODS _________________ */ |
|
| 110 | - /* The methods in the following section support the following categories of the BBB API: |
|
| 66 | + if (extension_loaded('curl')) { |
|
| 67 | + $ch = curl_init() or die ( curl_error($ch) ); |
|
| 68 | + $timeout = 10; |
|
| 69 | + curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false); |
|
| 70 | + curl_setopt( $ch, CURLOPT_URL, $url ); |
|
| 71 | + curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 ); |
|
| 72 | + curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT, $timeout); |
|
| 73 | + $data = curl_exec( $ch ); |
|
| 74 | + curl_close( $ch ); |
|
| 75 | + |
|
| 76 | + if($data) |
|
| 77 | + return (new SimpleXMLElement($data)); |
|
| 78 | + else |
|
| 79 | + return false; |
|
| 80 | + } |
|
| 81 | + return (simplexml_load_file($url)); |
|
| 82 | + } |
|
| 83 | + |
|
| 84 | + private function _requiredParam($param) { |
|
| 85 | + /* Process required params and throw errors if we don't get values */ |
|
| 86 | + if ((isset($param)) && ($param != '')) { |
|
| 87 | + return $param; |
|
| 88 | + } |
|
| 89 | + elseif (!isset($param)) { |
|
| 90 | + throw new Exception('Missing parameter.'); |
|
| 91 | + } |
|
| 92 | + else { |
|
| 93 | + throw new Exception(''.$param.' is required.'); |
|
| 94 | + } |
|
| 95 | + } |
|
| 96 | + |
|
| 97 | + private function _optionalParam($param) { |
|
| 98 | + /* Pass most optional params through as set value, or set to '' */ |
|
| 99 | + /* Don't know if we'll use this one, but let's build it in case. */ |
|
| 100 | + if ((isset($param)) && ($param != '')) { |
|
| 101 | + return $param; |
|
| 102 | + } |
|
| 103 | + else { |
|
| 104 | + $param = ''; |
|
| 105 | + return $param; |
|
| 106 | + } |
|
| 107 | + } |
|
| 108 | + |
|
| 109 | + /* __________________ BBB ADMINISTRATION METHODS _________________ */ |
|
| 110 | + /* The methods in the following section support the following categories of the BBB API: |
|
| 111 | 111 | -- create |
| 112 | 112 | -- join |
| 113 | 113 | -- end |
| 114 | 114 | */ |
| 115 | 115 | |
| 116 | - public function getCreateMeetingUrl($creationParams) { |
|
| 117 | - /* |
|
| 116 | + public function getCreateMeetingUrl($creationParams) { |
|
| 117 | + /* |
|
| 118 | 118 | USAGE: |
| 119 | 119 | (see $creationParams array in createMeetingArray method.) |
| 120 | 120 | */ |
| 121 | - $this->_meetingId = $this->_requiredParam($creationParams['meetingId']); |
|
| 122 | - $this->_meetingName = $this->_requiredParam($creationParams['meetingName']); |
|
| 123 | - // Set up the basic creation URL: |
|
| 124 | - $creationUrl = $this->_bbbServerBaseUrl."api/create?"; |
|
| 125 | - // Add params: |
|
| 126 | - $params = |
|
| 127 | - 'name='.urlencode($this->_meetingName). |
|
| 128 | - '&meetingID='.urlencode($this->_meetingId). |
|
| 129 | - '&attendeePW='.urlencode($creationParams['attendeePw']). |
|
| 130 | - '&moderatorPW='.urlencode($creationParams['moderatorPw']). |
|
| 131 | - '&dialNumber='.urlencode($creationParams['dialNumber']). |
|
| 132 | - '&voiceBridge='.urlencode($creationParams['voiceBridge']). |
|
| 133 | - '&webVoice='.urlencode($creationParams['webVoice']). |
|
| 134 | - '&logoutURL='.urlencode($creationParams['logoutUrl']). |
|
| 135 | - '&maxParticipants='.urlencode($creationParams['maxParticipants']). |
|
| 136 | - '&record='.urlencode($creationParams['record']). |
|
| 137 | - '&duration='.urlencode($creationParams['duration']); |
|
| 138 | - //'&meta_category='.urlencode($creationParams['meta_category']); |
|
| 139 | - $welcomeMessage = $creationParams['welcomeMsg']; |
|
| 140 | - if(trim($welcomeMessage)) |
|
| 141 | - $params .= '&welcome='.urlencode($welcomeMessage); |
|
| 142 | - // Return the complete URL: |
|
| 143 | - return ( $creationUrl.$params.'&checksum='.sha1("create".$params.$this->_securitySalt) ); |
|
| 144 | - } |
|
| 145 | - |
|
| 146 | - public function createMeetingWithXmlResponseArray($creationParams) { |
|
| 147 | - /* |
|
| 121 | + $this->_meetingId = $this->_requiredParam($creationParams['meetingId']); |
|
| 122 | + $this->_meetingName = $this->_requiredParam($creationParams['meetingName']); |
|
| 123 | + // Set up the basic creation URL: |
|
| 124 | + $creationUrl = $this->_bbbServerBaseUrl."api/create?"; |
|
| 125 | + // Add params: |
|
| 126 | + $params = |
|
| 127 | + 'name='.urlencode($this->_meetingName). |
|
| 128 | + '&meetingID='.urlencode($this->_meetingId). |
|
| 129 | + '&attendeePW='.urlencode($creationParams['attendeePw']). |
|
| 130 | + '&moderatorPW='.urlencode($creationParams['moderatorPw']). |
|
| 131 | + '&dialNumber='.urlencode($creationParams['dialNumber']). |
|
| 132 | + '&voiceBridge='.urlencode($creationParams['voiceBridge']). |
|
| 133 | + '&webVoice='.urlencode($creationParams['webVoice']). |
|
| 134 | + '&logoutURL='.urlencode($creationParams['logoutUrl']). |
|
| 135 | + '&maxParticipants='.urlencode($creationParams['maxParticipants']). |
|
| 136 | + '&record='.urlencode($creationParams['record']). |
|
| 137 | + '&duration='.urlencode($creationParams['duration']); |
|
| 138 | + //'&meta_category='.urlencode($creationParams['meta_category']); |
|
| 139 | + $welcomeMessage = $creationParams['welcomeMsg']; |
|
| 140 | + if(trim($welcomeMessage)) |
|
| 141 | + $params .= '&welcome='.urlencode($welcomeMessage); |
|
| 142 | + // Return the complete URL: |
|
| 143 | + return ( $creationUrl.$params.'&checksum='.sha1("create".$params.$this->_securitySalt) ); |
|
| 144 | + } |
|
| 145 | + |
|
| 146 | + public function createMeetingWithXmlResponseArray($creationParams) { |
|
| 147 | + /* |
|
| 148 | 148 | USAGE: |
| 149 | 149 | $creationParams = array( |
| 150 | 150 | 'name' => 'Meeting Name', -- A name for the meeting (or username) |
@@ -162,34 +162,34 @@ discard block |
||
| 162 | 162 | 'meta_category' => '', -- Use to pass additional info to BBB server. See API docs to enable. |
| 163 | 163 | ); |
| 164 | 164 | */ |
| 165 | - $xml = $this->_processXmlResponse($this->getCreateMeetingURL($creationParams)); |
|
| 165 | + $xml = $this->_processXmlResponse($this->getCreateMeetingURL($creationParams)); |
|
| 166 | 166 | |
| 167 | 167 | if ($xml) { |
| 168 | - if($xml->meetingID) |
|
| 169 | - return array( |
|
| 170 | - 'returncode' => $xml->returncode->__toString(), |
|
| 171 | - 'message' => $xml->message->__toString(), |
|
| 172 | - 'messageKey' => $xml->messageKey->__toString(), |
|
| 173 | - 'meetingId' => $xml->meetingID->__toString(), |
|
| 174 | - 'attendeePw' => $xml->attendeePW->__toString(), |
|
| 175 | - 'moderatorPw' => $xml->moderatorPW->__toString(), |
|
| 176 | - 'hasBeenForciblyEnded' => $xml->hasBeenForciblyEnded->__toString(), |
|
| 177 | - 'createTime' => $xml->createTime->__toString() |
|
| 178 | - ); |
|
| 179 | - else |
|
| 180 | - return array( |
|
| 181 | - 'returncode' => $xml->returncode->__toString(), |
|
| 182 | - 'message' => $xml->message->__toString(), |
|
| 183 | - 'messageKey' => $xml->messageKey->__toString() |
|
| 184 | - ); |
|
| 185 | - } |
|
| 186 | - else { |
|
| 187 | - return null; |
|
| 188 | - } |
|
| 189 | - } |
|
| 190 | - |
|
| 191 | - public function getJoinMeetingURL($joinParams) { |
|
| 192 | - /* |
|
| 168 | + if($xml->meetingID) |
|
| 169 | + return array( |
|
| 170 | + 'returncode' => $xml->returncode->__toString(), |
|
| 171 | + 'message' => $xml->message->__toString(), |
|
| 172 | + 'messageKey' => $xml->messageKey->__toString(), |
|
| 173 | + 'meetingId' => $xml->meetingID->__toString(), |
|
| 174 | + 'attendeePw' => $xml->attendeePW->__toString(), |
|
| 175 | + 'moderatorPw' => $xml->moderatorPW->__toString(), |
|
| 176 | + 'hasBeenForciblyEnded' => $xml->hasBeenForciblyEnded->__toString(), |
|
| 177 | + 'createTime' => $xml->createTime->__toString() |
|
| 178 | + ); |
|
| 179 | + else |
|
| 180 | + return array( |
|
| 181 | + 'returncode' => $xml->returncode->__toString(), |
|
| 182 | + 'message' => $xml->message->__toString(), |
|
| 183 | + 'messageKey' => $xml->messageKey->__toString() |
|
| 184 | + ); |
|
| 185 | + } |
|
| 186 | + else { |
|
| 187 | + return null; |
|
| 188 | + } |
|
| 189 | + } |
|
| 190 | + |
|
| 191 | + public function getJoinMeetingURL($joinParams) { |
|
| 192 | + /* |
|
| 193 | 193 | NOTE: At this point, we don't use a corresponding joinMeetingWithXmlResponse here because the API |
| 194 | 194 | doesn't respond on success, but you can still code that method if you need it. Or, you can take the URL |
| 195 | 195 | that's returned from this method and simply send your users off to that URL in your code. |
@@ -203,249 +203,249 @@ discard block |
||
| 203 | 203 | 'webVoiceConf' => '' -- OPTIONAL - string |
| 204 | 204 | ); |
| 205 | 205 | */ |
| 206 | - $this->_meetingId = $this->_requiredParam($joinParams['meetingId']); |
|
| 207 | - $this->_username = $this->_requiredParam($joinParams['username']); |
|
| 208 | - $this->_password = $this->_requiredParam($joinParams['password']); |
|
| 209 | - // Establish the basic join URL: |
|
| 210 | - $joinUrl = $this->_bbbServerBaseUrl."api/join?"; |
|
| 211 | - // Add parameters to the URL: |
|
| 212 | - $params = |
|
| 213 | - 'meetingID='.urlencode($this->_meetingId). |
|
| 214 | - '&fullName='.urlencode($this->_username). |
|
| 215 | - '&password='.urlencode($this->_password). |
|
| 216 | - '&userID='.urlencode($joinParams['userID']). |
|
| 217 | - '&webVoiceConf='.urlencode($joinParams['webVoiceConf']); |
|
| 218 | - // Only use createTime if we really want to use it. If it's '', then don't pass it: |
|
| 219 | - if (((isset($joinParams['createTime'])) && ($joinParams['createTime'] != ''))) { |
|
| 220 | - $params .= '&createTime='.urlencode($joinParams['createTime']); |
|
| 221 | - } |
|
| 222 | - // Return the URL: |
|
| 223 | - return ($joinUrl.$params.'&checksum='.sha1("join".$params.$this->_securitySalt)); |
|
| 224 | - } |
|
| 225 | - |
|
| 226 | - public function getEndMeetingURL($endParams) { |
|
| 227 | - /* USAGE: |
|
| 206 | + $this->_meetingId = $this->_requiredParam($joinParams['meetingId']); |
|
| 207 | + $this->_username = $this->_requiredParam($joinParams['username']); |
|
| 208 | + $this->_password = $this->_requiredParam($joinParams['password']); |
|
| 209 | + // Establish the basic join URL: |
|
| 210 | + $joinUrl = $this->_bbbServerBaseUrl."api/join?"; |
|
| 211 | + // Add parameters to the URL: |
|
| 212 | + $params = |
|
| 213 | + 'meetingID='.urlencode($this->_meetingId). |
|
| 214 | + '&fullName='.urlencode($this->_username). |
|
| 215 | + '&password='.urlencode($this->_password). |
|
| 216 | + '&userID='.urlencode($joinParams['userID']). |
|
| 217 | + '&webVoiceConf='.urlencode($joinParams['webVoiceConf']); |
|
| 218 | + // Only use createTime if we really want to use it. If it's '', then don't pass it: |
|
| 219 | + if (((isset($joinParams['createTime'])) && ($joinParams['createTime'] != ''))) { |
|
| 220 | + $params .= '&createTime='.urlencode($joinParams['createTime']); |
|
| 221 | + } |
|
| 222 | + // Return the URL: |
|
| 223 | + return ($joinUrl.$params.'&checksum='.sha1("join".$params.$this->_securitySalt)); |
|
| 224 | + } |
|
| 225 | + |
|
| 226 | + public function getEndMeetingURL($endParams) { |
|
| 227 | + /* USAGE: |
|
| 228 | 228 | $endParams = array ( |
| 229 | 229 | 'meetingId' => '1234', -- REQUIRED - The unique id for the meeting |
| 230 | 230 | 'password' => 'mp' -- REQUIRED - The moderator password for the meeting |
| 231 | 231 | ); |
| 232 | 232 | */ |
| 233 | - $this->_meetingId = $this->_requiredParam($endParams['meetingId']); |
|
| 234 | - $this->_password = $this->_requiredParam($endParams['password']); |
|
| 235 | - $endUrl = $this->_bbbServerBaseUrl."api/end?"; |
|
| 236 | - $params = |
|
| 237 | - 'meetingID='.urlencode($this->_meetingId). |
|
| 238 | - '&password='.urlencode($this->_password); |
|
| 239 | - return ($endUrl.$params.'&checksum='.sha1("end".$params.$this->_securitySalt)); |
|
| 240 | - } |
|
| 241 | - |
|
| 242 | - public function endMeetingWithXmlResponseArray($endParams) { |
|
| 243 | - /* USAGE: |
|
| 233 | + $this->_meetingId = $this->_requiredParam($endParams['meetingId']); |
|
| 234 | + $this->_password = $this->_requiredParam($endParams['password']); |
|
| 235 | + $endUrl = $this->_bbbServerBaseUrl."api/end?"; |
|
| 236 | + $params = |
|
| 237 | + 'meetingID='.urlencode($this->_meetingId). |
|
| 238 | + '&password='.urlencode($this->_password); |
|
| 239 | + return ($endUrl.$params.'&checksum='.sha1("end".$params.$this->_securitySalt)); |
|
| 240 | + } |
|
| 241 | + |
|
| 242 | + public function endMeetingWithXmlResponseArray($endParams) { |
|
| 243 | + /* USAGE: |
|
| 244 | 244 | $endParams = array ( |
| 245 | 245 | 'meetingId' => '1234', -- REQUIRED - The unique id for the meeting |
| 246 | 246 | 'password' => 'mp' -- REQUIRED - The moderator password for the meeting |
| 247 | 247 | ); |
| 248 | 248 | */ |
| 249 | - $xml = $this->_processXmlResponse($this->getEndMeetingURL($endParams)); |
|
| 250 | - if ($xml) { |
|
| 251 | - return array( |
|
| 252 | - 'returncode' => $xml->returncode->__toString(), |
|
| 253 | - 'message' => $xml->message->__toString(), |
|
| 254 | - 'messageKey' => $xml->messageKey->__toString() |
|
| 255 | - ); |
|
| 256 | - } |
|
| 257 | - else { |
|
| 258 | - return null; |
|
| 259 | - } |
|
| 260 | - |
|
| 261 | - } |
|
| 262 | - |
|
| 263 | - /* __________________ BBB MONITORING METHODS _________________ */ |
|
| 264 | - /* The methods in the following section support the following categories of the BBB API: |
|
| 249 | + $xml = $this->_processXmlResponse($this->getEndMeetingURL($endParams)); |
|
| 250 | + if ($xml) { |
|
| 251 | + return array( |
|
| 252 | + 'returncode' => $xml->returncode->__toString(), |
|
| 253 | + 'message' => $xml->message->__toString(), |
|
| 254 | + 'messageKey' => $xml->messageKey->__toString() |
|
| 255 | + ); |
|
| 256 | + } |
|
| 257 | + else { |
|
| 258 | + return null; |
|
| 259 | + } |
|
| 260 | + |
|
| 261 | + } |
|
| 262 | + |
|
| 263 | + /* __________________ BBB MONITORING METHODS _________________ */ |
|
| 264 | + /* The methods in the following section support the following categories of the BBB API: |
|
| 265 | 265 | -- isMeetingRunning |
| 266 | 266 | -- getMeetings |
| 267 | 267 | -- getMeetingInfo |
| 268 | 268 | */ |
| 269 | 269 | |
| 270 | - public function getIsMeetingRunningUrl($meetingId) { |
|
| 271 | - /* USAGE: |
|
| 270 | + public function getIsMeetingRunningUrl($meetingId) { |
|
| 271 | + /* USAGE: |
|
| 272 | 272 | $meetingId = '1234' -- REQUIRED - The unique id for the meeting |
| 273 | 273 | */ |
| 274 | - $this->_meetingId = $this->_requiredParam($meetingId); |
|
| 275 | - $runningUrl = $this->_bbbServerBaseUrl."api/isMeetingRunning?"; |
|
| 276 | - $params = |
|
| 277 | - 'meetingID='.urlencode($this->_meetingId); |
|
| 278 | - return ($runningUrl.$params.'&checksum='.sha1("isMeetingRunning".$params.$this->_securitySalt)); |
|
| 279 | - } |
|
| 280 | - |
|
| 281 | - public function isMeetingRunningWithXmlResponseArray($meetingId) { |
|
| 282 | - /* USAGE: |
|
| 274 | + $this->_meetingId = $this->_requiredParam($meetingId); |
|
| 275 | + $runningUrl = $this->_bbbServerBaseUrl."api/isMeetingRunning?"; |
|
| 276 | + $params = |
|
| 277 | + 'meetingID='.urlencode($this->_meetingId); |
|
| 278 | + return ($runningUrl.$params.'&checksum='.sha1("isMeetingRunning".$params.$this->_securitySalt)); |
|
| 279 | + } |
|
| 280 | + |
|
| 281 | + public function isMeetingRunningWithXmlResponseArray($meetingId) { |
|
| 282 | + /* USAGE: |
|
| 283 | 283 | $meetingId = '1234' -- REQUIRED - The unique id for the meeting |
| 284 | 284 | */ |
| 285 | - $xml = $this->_processXmlResponse($this->getIsMeetingRunningUrl($meetingId)); |
|
| 286 | - if($xml) { |
|
| 287 | - return array( |
|
| 288 | - 'returncode' => $xml->returncode->__toString(), |
|
| 289 | - 'running' => $xml->running->__toString() // -- Returns true/false. |
|
| 290 | - ); |
|
| 291 | - } |
|
| 292 | - else { |
|
| 293 | - return null; |
|
| 294 | - } |
|
| 295 | - |
|
| 296 | - } |
|
| 297 | - |
|
| 298 | - public function getGetMeetingsUrl() { |
|
| 299 | - /* Simply formulate the getMeetings URL |
|
| 285 | + $xml = $this->_processXmlResponse($this->getIsMeetingRunningUrl($meetingId)); |
|
| 286 | + if($xml) { |
|
| 287 | + return array( |
|
| 288 | + 'returncode' => $xml->returncode->__toString(), |
|
| 289 | + 'running' => $xml->running->__toString() // -- Returns true/false. |
|
| 290 | + ); |
|
| 291 | + } |
|
| 292 | + else { |
|
| 293 | + return null; |
|
| 294 | + } |
|
| 295 | + |
|
| 296 | + } |
|
| 297 | + |
|
| 298 | + public function getGetMeetingsUrl() { |
|
| 299 | + /* Simply formulate the getMeetings URL |
|
| 300 | 300 | We do this in a separate function so we have the option to just get this |
| 301 | 301 | URL and print it if we want for some reason. |
| 302 | 302 | */ |
| 303 | - $getMeetingsUrl = $this->_bbbServerBaseUrl."api/getMeetings?checksum=".sha1("getMeetings".$this->_securitySalt); |
|
| 304 | - return $getMeetingsUrl; |
|
| 305 | - } |
|
| 303 | + $getMeetingsUrl = $this->_bbbServerBaseUrl."api/getMeetings?checksum=".sha1("getMeetings".$this->_securitySalt); |
|
| 304 | + return $getMeetingsUrl; |
|
| 305 | + } |
|
| 306 | 306 | |
| 307 | - public function getMeetingsWithXmlResponseArray() { |
|
| 308 | - /* USAGE: |
|
| 307 | + public function getMeetingsWithXmlResponseArray() { |
|
| 308 | + /* USAGE: |
|
| 309 | 309 | We don't need to pass any parameters with this one, so we just send the query URL off to BBB |
| 310 | 310 | and then handle the results that we get in the XML response. |
| 311 | 311 | */ |
| 312 | - $xml = $this->_processXmlResponse($this->getGetMeetingsUrl()); |
|
| 313 | - if($xml) { |
|
| 314 | - // If we don't get a success code, stop processing and return just the returncode: |
|
| 315 | - if ($xml->returncode != 'SUCCESS') { |
|
| 316 | - $result = array( |
|
| 317 | - 'returncode' => $xml->returncode->__toString() |
|
| 318 | - ); |
|
| 319 | - return $result; |
|
| 320 | - } |
|
| 321 | - elseif ($xml->messageKey == 'noMeetings') { |
|
| 322 | - /* No meetings on server, so return just this info: */ |
|
| 323 | - $result = array( |
|
| 324 | - 'returncode' => $xml->returncode->__toString(), |
|
| 325 | - 'messageKey' => $xml->messageKey->__toString(), |
|
| 326 | - 'message' => $xml->message->__toString() |
|
| 327 | - ); |
|
| 328 | - return $result; |
|
| 329 | - } |
|
| 330 | - else { |
|
| 331 | - // In this case, we have success and meetings. First return general response: |
|
| 332 | - $result = array( |
|
| 333 | - 'returncode' => $xml->returncode->__toString(), |
|
| 334 | - 'messageKey' => $xml->messageKey->__toString(), |
|
| 335 | - 'message' => $xml->message->__toString() |
|
| 336 | - ); |
|
| 337 | - // Then interate through meeting results and return them as part of the array: |
|
| 338 | - foreach ($xml->meetings->meeting as $m) { |
|
| 339 | - $result[] = array( |
|
| 340 | - 'meetingId' => $m->meetingID->__toString(), |
|
| 341 | - 'meetingName' => $m->meetingName->__toString(), |
|
| 342 | - 'createTime' => $m->createTime->__toString(), |
|
| 343 | - 'attendeePw' => $m->attendeePW->__toString(), |
|
| 344 | - 'moderatorPw' => $m->moderatorPW->__toString(), |
|
| 345 | - 'hasBeenForciblyEnded' => $m->hasBeenForciblyEnded->__toString(), |
|
| 346 | - 'running' => $m->running->__toString() |
|
| 347 | - ); |
|
| 348 | - } |
|
| 349 | - return $result; |
|
| 350 | - } |
|
| 351 | - } |
|
| 352 | - else { |
|
| 353 | - return null; |
|
| 354 | - } |
|
| 355 | - |
|
| 356 | - } |
|
| 357 | - |
|
| 358 | - public function getMeetingInfoUrl($infoParams) { |
|
| 359 | - /* USAGE: |
|
| 312 | + $xml = $this->_processXmlResponse($this->getGetMeetingsUrl()); |
|
| 313 | + if($xml) { |
|
| 314 | + // If we don't get a success code, stop processing and return just the returncode: |
|
| 315 | + if ($xml->returncode != 'SUCCESS') { |
|
| 316 | + $result = array( |
|
| 317 | + 'returncode' => $xml->returncode->__toString() |
|
| 318 | + ); |
|
| 319 | + return $result; |
|
| 320 | + } |
|
| 321 | + elseif ($xml->messageKey == 'noMeetings') { |
|
| 322 | + /* No meetings on server, so return just this info: */ |
|
| 323 | + $result = array( |
|
| 324 | + 'returncode' => $xml->returncode->__toString(), |
|
| 325 | + 'messageKey' => $xml->messageKey->__toString(), |
|
| 326 | + 'message' => $xml->message->__toString() |
|
| 327 | + ); |
|
| 328 | + return $result; |
|
| 329 | + } |
|
| 330 | + else { |
|
| 331 | + // In this case, we have success and meetings. First return general response: |
|
| 332 | + $result = array( |
|
| 333 | + 'returncode' => $xml->returncode->__toString(), |
|
| 334 | + 'messageKey' => $xml->messageKey->__toString(), |
|
| 335 | + 'message' => $xml->message->__toString() |
|
| 336 | + ); |
|
| 337 | + // Then interate through meeting results and return them as part of the array: |
|
| 338 | + foreach ($xml->meetings->meeting as $m) { |
|
| 339 | + $result[] = array( |
|
| 340 | + 'meetingId' => $m->meetingID->__toString(), |
|
| 341 | + 'meetingName' => $m->meetingName->__toString(), |
|
| 342 | + 'createTime' => $m->createTime->__toString(), |
|
| 343 | + 'attendeePw' => $m->attendeePW->__toString(), |
|
| 344 | + 'moderatorPw' => $m->moderatorPW->__toString(), |
|
| 345 | + 'hasBeenForciblyEnded' => $m->hasBeenForciblyEnded->__toString(), |
|
| 346 | + 'running' => $m->running->__toString() |
|
| 347 | + ); |
|
| 348 | + } |
|
| 349 | + return $result; |
|
| 350 | + } |
|
| 351 | + } |
|
| 352 | + else { |
|
| 353 | + return null; |
|
| 354 | + } |
|
| 355 | + |
|
| 356 | + } |
|
| 357 | + |
|
| 358 | + public function getMeetingInfoUrl($infoParams) { |
|
| 359 | + /* USAGE: |
|
| 360 | 360 | $infoParams = array( |
| 361 | 361 | 'meetingId' => '1234', -- REQUIRED - The unique id for the meeting |
| 362 | 362 | 'password' => 'mp' -- REQUIRED - The moderator password for the meeting |
| 363 | 363 | ); |
| 364 | 364 | */ |
| 365 | - $this->_meetingId = $this->_requiredParam($infoParams['meetingId']); |
|
| 366 | - $this->_password = $this->_requiredParam($infoParams['password']); |
|
| 367 | - $infoUrl = $this->_bbbServerBaseUrl."api/getMeetingInfo?"; |
|
| 368 | - $params = |
|
| 369 | - 'meetingID='.urlencode($this->_meetingId). |
|
| 370 | - '&password='.urlencode($this->_password); |
|
| 371 | - return ($infoUrl.$params.'&checksum='.sha1("getMeetingInfo".$params.$this->_securitySalt)); |
|
| 372 | - } |
|
| 373 | - |
|
| 374 | - public function getMeetingInfoWithXmlResponseArray($infoParams) { |
|
| 375 | - /* USAGE: |
|
| 365 | + $this->_meetingId = $this->_requiredParam($infoParams['meetingId']); |
|
| 366 | + $this->_password = $this->_requiredParam($infoParams['password']); |
|
| 367 | + $infoUrl = $this->_bbbServerBaseUrl."api/getMeetingInfo?"; |
|
| 368 | + $params = |
|
| 369 | + 'meetingID='.urlencode($this->_meetingId). |
|
| 370 | + '&password='.urlencode($this->_password); |
|
| 371 | + return ($infoUrl.$params.'&checksum='.sha1("getMeetingInfo".$params.$this->_securitySalt)); |
|
| 372 | + } |
|
| 373 | + |
|
| 374 | + public function getMeetingInfoWithXmlResponseArray($infoParams) { |
|
| 375 | + /* USAGE: |
|
| 376 | 376 | $infoParams = array( |
| 377 | 377 | 'meetingId' => '1234', -- REQUIRED - The unique id for the meeting |
| 378 | 378 | 'password' => 'mp' -- REQUIRED - The moderator password for the meeting |
| 379 | 379 | ); |
| 380 | 380 | */ |
| 381 | - $xml = $this->_processXmlResponse($this->getMeetingInfoUrl($infoParams)); |
|
| 382 | - if($xml) { |
|
| 383 | - // If we don't get a success code or messageKey, find out why: |
|
| 384 | - if (($xml->returncode != 'SUCCESS') || ($xml->messageKey == null)) { |
|
| 385 | - $result = array( |
|
| 386 | - 'returncode' => $xml->returncode->__toString(), |
|
| 387 | - 'messageKey' => $xml->messageKey->__toString(), |
|
| 388 | - 'message' => $xml->message->__toString() |
|
| 389 | - ); |
|
| 390 | - return $result; |
|
| 391 | - } |
|
| 392 | - else { |
|
| 393 | - // In this case, we have success and meeting info: |
|
| 394 | - $result = array( |
|
| 395 | - 'returncode' => $xml->returncode->__toString(), |
|
| 396 | - 'meetingName' => $xml->meetingName->__toString(), |
|
| 397 | - 'meetingId' => $xml->meetingID->__toString(), |
|
| 398 | - 'createTime' => $xml->createTime->__toString(), |
|
| 399 | - 'voiceBridge' => $xml->voiceBridge->__toString(), |
|
| 400 | - 'attendeePw' => $xml->attendeePW->__toString(), |
|
| 401 | - 'moderatorPw' => $xml->moderatorPW->__toString(), |
|
| 402 | - 'running' => $xml->running->__toString(), |
|
| 403 | - 'recording' => $xml->recording->__toString(), |
|
| 404 | - 'hasBeenForciblyEnded' => $xml->hasBeenForciblyEnded->__toString(), |
|
| 405 | - 'startTime' => $xml->startTime->__toString(), |
|
| 406 | - 'endTime' => $xml->endTime->__toString(), |
|
| 407 | - 'participantCount' => $xml->participantCount->__toString(), |
|
| 408 | - 'maxUsers' => $xml->maxUsers->__toString(), |
|
| 409 | - 'moderatorCount' => $xml->moderatorCount->__toString(), |
|
| 410 | - ); |
|
| 411 | - // Then interate through attendee results and return them as part of the array: |
|
| 412 | - foreach ($xml->attendees->attendee as $a) { |
|
| 413 | - $result[] = array( |
|
| 414 | - 'userId' => $a->userID->__toString(), |
|
| 415 | - 'fullName' => $a->fullName->__toString(), |
|
| 416 | - 'role' => $a->role->__toString() |
|
| 417 | - ); |
|
| 418 | - } |
|
| 419 | - return $result; |
|
| 420 | - } |
|
| 421 | - } |
|
| 422 | - else { |
|
| 423 | - return null; |
|
| 424 | - } |
|
| 425 | - |
|
| 426 | - } |
|
| 427 | - |
|
| 428 | - /* __________________ BBB RECORDING METHODS _________________ */ |
|
| 429 | - /* The methods in the following section support the following categories of the BBB API: |
|
| 381 | + $xml = $this->_processXmlResponse($this->getMeetingInfoUrl($infoParams)); |
|
| 382 | + if($xml) { |
|
| 383 | + // If we don't get a success code or messageKey, find out why: |
|
| 384 | + if (($xml->returncode != 'SUCCESS') || ($xml->messageKey == null)) { |
|
| 385 | + $result = array( |
|
| 386 | + 'returncode' => $xml->returncode->__toString(), |
|
| 387 | + 'messageKey' => $xml->messageKey->__toString(), |
|
| 388 | + 'message' => $xml->message->__toString() |
|
| 389 | + ); |
|
| 390 | + return $result; |
|
| 391 | + } |
|
| 392 | + else { |
|
| 393 | + // In this case, we have success and meeting info: |
|
| 394 | + $result = array( |
|
| 395 | + 'returncode' => $xml->returncode->__toString(), |
|
| 396 | + 'meetingName' => $xml->meetingName->__toString(), |
|
| 397 | + 'meetingId' => $xml->meetingID->__toString(), |
|
| 398 | + 'createTime' => $xml->createTime->__toString(), |
|
| 399 | + 'voiceBridge' => $xml->voiceBridge->__toString(), |
|
| 400 | + 'attendeePw' => $xml->attendeePW->__toString(), |
|
| 401 | + 'moderatorPw' => $xml->moderatorPW->__toString(), |
|
| 402 | + 'running' => $xml->running->__toString(), |
|
| 403 | + 'recording' => $xml->recording->__toString(), |
|
| 404 | + 'hasBeenForciblyEnded' => $xml->hasBeenForciblyEnded->__toString(), |
|
| 405 | + 'startTime' => $xml->startTime->__toString(), |
|
| 406 | + 'endTime' => $xml->endTime->__toString(), |
|
| 407 | + 'participantCount' => $xml->participantCount->__toString(), |
|
| 408 | + 'maxUsers' => $xml->maxUsers->__toString(), |
|
| 409 | + 'moderatorCount' => $xml->moderatorCount->__toString(), |
|
| 410 | + ); |
|
| 411 | + // Then interate through attendee results and return them as part of the array: |
|
| 412 | + foreach ($xml->attendees->attendee as $a) { |
|
| 413 | + $result[] = array( |
|
| 414 | + 'userId' => $a->userID->__toString(), |
|
| 415 | + 'fullName' => $a->fullName->__toString(), |
|
| 416 | + 'role' => $a->role->__toString() |
|
| 417 | + ); |
|
| 418 | + } |
|
| 419 | + return $result; |
|
| 420 | + } |
|
| 421 | + } |
|
| 422 | + else { |
|
| 423 | + return null; |
|
| 424 | + } |
|
| 425 | + |
|
| 426 | + } |
|
| 427 | + |
|
| 428 | + /* __________________ BBB RECORDING METHODS _________________ */ |
|
| 429 | + /* The methods in the following section support the following categories of the BBB API: |
|
| 430 | 430 | -- getRecordings |
| 431 | 431 | -- publishRecordings |
| 432 | 432 | -- deleteRecordings |
| 433 | 433 | */ |
| 434 | 434 | |
| 435 | - public function getRecordingsUrl($recordingParams) { |
|
| 436 | - /* USAGE: |
|
| 435 | + public function getRecordingsUrl($recordingParams) { |
|
| 436 | + /* USAGE: |
|
| 437 | 437 | $recordingParams = array( |
| 438 | 438 | 'meetingId' => '1234', -- OPTIONAL - comma separate if multiple ids |
| 439 | 439 | ); |
| 440 | 440 | */ |
| 441 | - $recordingsUrl = $this->_bbbServerBaseUrl."api/getRecordings?"; |
|
| 442 | - $params = 'meetingID='.urlencode($recordingParams['meetingId']); |
|
| 443 | - return ($recordingsUrl.$params.'&checksum='.sha1("getRecordings".$params.$this->_securitySalt)); |
|
| 441 | + $recordingsUrl = $this->_bbbServerBaseUrl."api/getRecordings?"; |
|
| 442 | + $params = 'meetingID='.urlencode($recordingParams['meetingId']); |
|
| 443 | + return ($recordingsUrl.$params.'&checksum='.sha1("getRecordings".$params.$this->_securitySalt)); |
|
| 444 | 444 | |
| 445 | - } |
|
| 445 | + } |
|
| 446 | 446 | |
| 447 | - public function getRecordingsWithXmlResponseArray($recordingParams) { |
|
| 448 | - /* USAGE: |
|
| 447 | + public function getRecordingsWithXmlResponseArray($recordingParams) { |
|
| 448 | + /* USAGE: |
|
| 449 | 449 | $recordingParams = array( |
| 450 | 450 | 'meetingId' => '1234', -- OPTIONAL - comma separate if multiple ids |
| 451 | 451 | ); |
@@ -453,121 +453,121 @@ discard block |
||
| 453 | 453 | when creating a meeting, it will kick users out after the duration. Should |
| 454 | 454 | probably be required in user code when 'recording' is set to true. |
| 455 | 455 | */ |
| 456 | - $xml = $this->_processXmlResponse($this->getRecordingsUrl($recordingParams)); |
|
| 457 | - if($xml) { |
|
| 458 | - // If we don't get a success code or messageKey, find out why: |
|
| 459 | - if (($xml->returncode != 'SUCCESS') || ($xml->messageKey == null)) { |
|
| 460 | - $result = array( |
|
| 461 | - 'returncode' => $xml->returncode->__toString(), |
|
| 462 | - 'messageKey' => $xml->messageKey->__toString(), |
|
| 463 | - 'message' => $xml->message->__toString() |
|
| 464 | - ); |
|
| 465 | - return $result; |
|
| 466 | - } |
|
| 467 | - else { |
|
| 468 | - // In this case, we have success and recording info: |
|
| 469 | - $result = array( |
|
| 470 | - 'returncode' => $xml->returncode->__toString(), |
|
| 471 | - 'messageKey' => $xml->messageKey->__toString(), |
|
| 472 | - 'message' => $xml->message->__toString() |
|
| 473 | - ); |
|
| 474 | - |
|
| 475 | - foreach ($xml->recordings->recording as $r) { |
|
| 476 | - $result[] = array( |
|
| 477 | - 'recordId' => $r->recordID->__toString(), |
|
| 478 | - 'meetingId' => $r->meetingID->__toString(), |
|
| 479 | - 'name' => $r->name->__toString(), |
|
| 480 | - 'published' => $r->published->__toString(), |
|
| 481 | - 'startTime' => $r->startTime->__toString(), |
|
| 482 | - 'endTime' => $r->endTime->__toString(), |
|
| 483 | - 'playbackFormatType' => $r->playback->format->type->__toString(), |
|
| 484 | - 'playbackFormatUrl' => $r->playback->format->url->__toString(), |
|
| 485 | - 'playbackFormatLength' => $r->playback->format->length->__toString(), |
|
| 486 | - 'metadataTitle' => $r->metadata->title->__toString(), |
|
| 487 | - 'metadataSubject' => $r->metadata->subject->__toString(), |
|
| 488 | - 'metadataDescription' => $r->metadata->description->__toString(), |
|
| 489 | - 'metadataCreator' => $r->metadata->creator->__toString(), |
|
| 490 | - 'metadataContributor' => $r->metadata->contributor->__toString(), |
|
| 491 | - 'metadataLanguage' => $r->metadata->language->__toString(), |
|
| 492 | - // Add more here as needed for your app depending on your |
|
| 493 | - // use of metadata when creating recordings. |
|
| 494 | - ); |
|
| 495 | - } |
|
| 496 | - return $result; |
|
| 497 | - } |
|
| 498 | - } |
|
| 499 | - else { |
|
| 500 | - return null; |
|
| 501 | - } |
|
| 502 | - } |
|
| 503 | - |
|
| 504 | - public function getPublishRecordingsUrl($recordingParams) { |
|
| 505 | - /* USAGE: |
|
| 456 | + $xml = $this->_processXmlResponse($this->getRecordingsUrl($recordingParams)); |
|
| 457 | + if($xml) { |
|
| 458 | + // If we don't get a success code or messageKey, find out why: |
|
| 459 | + if (($xml->returncode != 'SUCCESS') || ($xml->messageKey == null)) { |
|
| 460 | + $result = array( |
|
| 461 | + 'returncode' => $xml->returncode->__toString(), |
|
| 462 | + 'messageKey' => $xml->messageKey->__toString(), |
|
| 463 | + 'message' => $xml->message->__toString() |
|
| 464 | + ); |
|
| 465 | + return $result; |
|
| 466 | + } |
|
| 467 | + else { |
|
| 468 | + // In this case, we have success and recording info: |
|
| 469 | + $result = array( |
|
| 470 | + 'returncode' => $xml->returncode->__toString(), |
|
| 471 | + 'messageKey' => $xml->messageKey->__toString(), |
|
| 472 | + 'message' => $xml->message->__toString() |
|
| 473 | + ); |
|
| 474 | + |
|
| 475 | + foreach ($xml->recordings->recording as $r) { |
|
| 476 | + $result[] = array( |
|
| 477 | + 'recordId' => $r->recordID->__toString(), |
|
| 478 | + 'meetingId' => $r->meetingID->__toString(), |
|
| 479 | + 'name' => $r->name->__toString(), |
|
| 480 | + 'published' => $r->published->__toString(), |
|
| 481 | + 'startTime' => $r->startTime->__toString(), |
|
| 482 | + 'endTime' => $r->endTime->__toString(), |
|
| 483 | + 'playbackFormatType' => $r->playback->format->type->__toString(), |
|
| 484 | + 'playbackFormatUrl' => $r->playback->format->url->__toString(), |
|
| 485 | + 'playbackFormatLength' => $r->playback->format->length->__toString(), |
|
| 486 | + 'metadataTitle' => $r->metadata->title->__toString(), |
|
| 487 | + 'metadataSubject' => $r->metadata->subject->__toString(), |
|
| 488 | + 'metadataDescription' => $r->metadata->description->__toString(), |
|
| 489 | + 'metadataCreator' => $r->metadata->creator->__toString(), |
|
| 490 | + 'metadataContributor' => $r->metadata->contributor->__toString(), |
|
| 491 | + 'metadataLanguage' => $r->metadata->language->__toString(), |
|
| 492 | + // Add more here as needed for your app depending on your |
|
| 493 | + // use of metadata when creating recordings. |
|
| 494 | + ); |
|
| 495 | + } |
|
| 496 | + return $result; |
|
| 497 | + } |
|
| 498 | + } |
|
| 499 | + else { |
|
| 500 | + return null; |
|
| 501 | + } |
|
| 502 | + } |
|
| 503 | + |
|
| 504 | + public function getPublishRecordingsUrl($recordingParams) { |
|
| 505 | + /* USAGE: |
|
| 506 | 506 | $recordingParams = array( |
| 507 | 507 | 'recordId' => '1234', -- REQUIRED - comma separate if multiple ids |
| 508 | 508 | 'publish' => 'true', -- REQUIRED - boolean: true/false |
| 509 | 509 | ); |
| 510 | 510 | */ |
| 511 | - $recordingsUrl = $this->_bbbServerBaseUrl."api/publishRecordings?"; |
|
| 512 | - $params = |
|
| 513 | - 'recordID='.urlencode($recordingParams['recordId']). |
|
| 514 | - '&publish='.urlencode($recordingParams['publish']); |
|
| 515 | - return ($recordingsUrl.$params.'&checksum='.sha1("publishRecordings".$params.$this->_securitySalt)); |
|
| 511 | + $recordingsUrl = $this->_bbbServerBaseUrl."api/publishRecordings?"; |
|
| 512 | + $params = |
|
| 513 | + 'recordID='.urlencode($recordingParams['recordId']). |
|
| 514 | + '&publish='.urlencode($recordingParams['publish']); |
|
| 515 | + return ($recordingsUrl.$params.'&checksum='.sha1("publishRecordings".$params.$this->_securitySalt)); |
|
| 516 | 516 | |
| 517 | - } |
|
| 517 | + } |
|
| 518 | 518 | |
| 519 | - public function publishRecordingsWithXmlResponseArray($recordingParams) { |
|
| 520 | - /* USAGE: |
|
| 519 | + public function publishRecordingsWithXmlResponseArray($recordingParams) { |
|
| 520 | + /* USAGE: |
|
| 521 | 521 | $recordingParams = array( |
| 522 | 522 | 'recordId' => '1234', -- REQUIRED - comma separate if multiple ids |
| 523 | 523 | 'publish' => 'true', -- REQUIRED - boolean: true/false |
| 524 | 524 | ); |
| 525 | 525 | */ |
| 526 | - $xml = $this->_processXmlResponse($this->getPublishRecordingsUrl($recordingParams)); |
|
| 527 | - if($xml) { |
|
| 528 | - return array( |
|
| 529 | - 'returncode' => $xml->returncode->__toString(), |
|
| 530 | - 'published' => $xml->published->__toString() // -- Returns true/false. |
|
| 531 | - ); |
|
| 532 | - } |
|
| 533 | - else { |
|
| 534 | - return null; |
|
| 535 | - } |
|
| 536 | - |
|
| 537 | - |
|
| 538 | - } |
|
| 539 | - |
|
| 540 | - public function getDeleteRecordingsUrl($recordingParams) { |
|
| 541 | - /* USAGE: |
|
| 526 | + $xml = $this->_processXmlResponse($this->getPublishRecordingsUrl($recordingParams)); |
|
| 527 | + if($xml) { |
|
| 528 | + return array( |
|
| 529 | + 'returncode' => $xml->returncode->__toString(), |
|
| 530 | + 'published' => $xml->published->__toString() // -- Returns true/false. |
|
| 531 | + ); |
|
| 532 | + } |
|
| 533 | + else { |
|
| 534 | + return null; |
|
| 535 | + } |
|
| 536 | + |
|
| 537 | + |
|
| 538 | + } |
|
| 539 | + |
|
| 540 | + public function getDeleteRecordingsUrl($recordingParams) { |
|
| 541 | + /* USAGE: |
|
| 542 | 542 | $recordingParams = array( |
| 543 | 543 | 'recordId' => '1234', -- REQUIRED - comma separate if multiple ids |
| 544 | 544 | ); |
| 545 | 545 | */ |
| 546 | - $recordingsUrl = $this->_bbbServerBaseUrl."api/deleteRecordings?"; |
|
| 547 | - $params = |
|
| 548 | - 'recordID='.urlencode($recordingParams['recordId']); |
|
| 549 | - return ($recordingsUrl.$params.'&checksum='.sha1("deleteRecordings".$params.$this->_securitySalt)); |
|
| 550 | - } |
|
| 551 | - |
|
| 552 | - public function deleteRecordingsWithXmlResponseArray($recordingParams) { |
|
| 553 | - /* USAGE: |
|
| 546 | + $recordingsUrl = $this->_bbbServerBaseUrl."api/deleteRecordings?"; |
|
| 547 | + $params = |
|
| 548 | + 'recordID='.urlencode($recordingParams['recordId']); |
|
| 549 | + return ($recordingsUrl.$params.'&checksum='.sha1("deleteRecordings".$params.$this->_securitySalt)); |
|
| 550 | + } |
|
| 551 | + |
|
| 552 | + public function deleteRecordingsWithXmlResponseArray($recordingParams) { |
|
| 553 | + /* USAGE: |
|
| 554 | 554 | $recordingParams = array( |
| 555 | 555 | 'recordId' => '1234', -- REQUIRED - comma separate if multiple ids |
| 556 | 556 | ); |
| 557 | 557 | */ |
| 558 | 558 | |
| 559 | - $xml = $this->_processXmlResponse($this->getDeleteRecordingsUrl($recordingParams)); |
|
| 560 | - if($xml) { |
|
| 561 | - return array( |
|
| 562 | - 'returncode' => $xml->returncode->__toString(), |
|
| 563 | - 'deleted' => $xml->deleted->__toString() // -- Returns true/false. |
|
| 564 | - ); |
|
| 565 | - } |
|
| 566 | - else { |
|
| 567 | - return null; |
|
| 568 | - } |
|
| 569 | - |
|
| 570 | - } |
|
| 559 | + $xml = $this->_processXmlResponse($this->getDeleteRecordingsUrl($recordingParams)); |
|
| 560 | + if($xml) { |
|
| 561 | + return array( |
|
| 562 | + 'returncode' => $xml->returncode->__toString(), |
|
| 563 | + 'deleted' => $xml->deleted->__toString() // -- Returns true/false. |
|
| 564 | + ); |
|
| 565 | + } |
|
| 566 | + else { |
|
| 567 | + return null; |
|
| 568 | + } |
|
| 569 | + |
|
| 570 | + } |
|
| 571 | 571 | |
| 572 | 572 | |
| 573 | 573 | |