@@ -43,7 +43,7 @@ |
||
43 | 43 | * Create a video chat |
44 | 44 | * @param int $fromUser The sender user |
45 | 45 | * @param int $toUser The receiver user |
46 | - * @return int The created video chat id. Otherwise return false |
|
46 | + * @return false|string The created video chat id. Otherwise return false |
|
47 | 47 | */ |
48 | 48 | public static function createRoom($fromUser, $toUser) |
49 | 49 | { |
@@ -121,6 +121,9 @@ |
||
121 | 121 | return $form->isSubmitted() == false || $form->validate(); |
122 | 122 | } |
123 | 123 | |
124 | + /** |
|
125 | + * @param string $format |
|
126 | + */ |
|
124 | 127 | function get_ceiling($format = null) |
125 | 128 | { |
126 | 129 | $result = Request::get('ceiling'); |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | } |
168 | 168 | |
169 | 169 | $action = $this->get_action(); |
170 | - $f = array($this, 'action_' . $action); |
|
170 | + $f = array($this, 'action_'.$action); |
|
171 | 171 | if (is_callable($f)) { |
172 | 172 | return call_user_func($f, $ids); |
173 | 173 | } |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | $text = get_lang('No'); |
293 | 293 | } |
294 | 294 | |
295 | - $result = Display::return_icon($image . '.png', $text); |
|
295 | + $result = Display::return_icon($image.'.png', $text); |
|
296 | 296 | return $result; |
297 | 297 | } |
298 | 298 |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | * This function return the value of a php.ini setting if not "" or if exists, |
98 | 98 | * otherwise return false |
99 | 99 | * @param string $phpSetting The name of a PHP setting |
100 | - * @return mixed The value of the setting, or false if not found |
|
100 | + * @return string|false The value of the setting, or false if not found |
|
101 | 101 | */ |
102 | 102 | function checkPhpSettingExists($phpSetting) |
103 | 103 | { |
@@ -1268,6 +1268,10 @@ discard block |
||
1268 | 1268 | * @param string Extra notice (to show on the right side) |
1269 | 1269 | * @param boolean Whether to display in update mode |
1270 | 1270 | * @param string Additional attribute for the <tr> element |
1271 | + * @param string $installType |
|
1272 | + * @param string $parameterName |
|
1273 | + * @param string $formFieldName |
|
1274 | + * @param string $extra_notice |
|
1271 | 1275 | * @return void Direct output |
1272 | 1276 | */ |
1273 | 1277 | function displayDatabaseParameter( |
@@ -1481,6 +1485,11 @@ discard block |
||
1481 | 1485 | |
1482 | 1486 | <?php |
1483 | 1487 | } |
1488 | +/** |
|
1489 | + * @param string $content |
|
1490 | + * @param string $title |
|
1491 | + * @param string $id |
|
1492 | + */ |
|
1484 | 1493 | function panel($content = null, $title = null, $id = null, $style = null) { |
1485 | 1494 | $html = ''; |
1486 | 1495 | if (empty($style)) { |
@@ -1837,8 +1846,8 @@ discard block |
||
1837 | 1846 | } |
1838 | 1847 | |
1839 | 1848 | /** |
1840 | - * @param $current_value |
|
1841 | - * @param $wanted_value |
|
1849 | + * @param string $current_value |
|
1850 | + * @param string $wanted_value |
|
1842 | 1851 | * @return string |
1843 | 1852 | */ |
1844 | 1853 | function compare_setting_values($current_value, $wanted_value) |
@@ -1855,8 +1864,8 @@ discard block |
||
1855 | 1864 | } |
1856 | 1865 | |
1857 | 1866 | /** |
1858 | - * @param $course_dir |
|
1859 | - * @param $course_attempt_name |
|
1867 | + * @param string $course_dir |
|
1868 | + * @param string $course_attempt_name |
|
1860 | 1869 | * @param string $file |
1861 | 1870 | * @return bool |
1862 | 1871 | */ |
@@ -1682,7 +1682,7 @@ discard block |
||
1682 | 1682 | $html .= '<label class="checkbox-inline"> |
1683 | 1683 | <input type="radio" name="allowSelfReg" value="0" id="allowSelfReg0" '. ($allowSelfReg == 'false' ? '' : 'checked="checked" ') .' /> '. get_lang('No') .' |
1684 | 1684 | </label>'; |
1685 | - $html .= '<label class="checkbox-inline"> |
|
1685 | + $html .= '<label class="checkbox-inline"> |
|
1686 | 1686 | <input type="radio" name="allowSelfReg" value="0" id="allowSelfReg0" '. ($allowSelfReg == 'approval' ? '' : 'checked="checked" ') .' /> '. get_lang('AfterApproval') .' |
1687 | 1687 | </label>'; |
1688 | 1688 | $html .= '</div>'; |
@@ -1716,7 +1716,7 @@ discard block |
||
1716 | 1716 | </div>'; |
1717 | 1717 | |
1718 | 1718 | echo panel($html, get_lang('Platform'), 'platform'); |
1719 | - ?> |
|
1719 | + ?> |
|
1720 | 1720 | <div class='form-group'> |
1721 | 1721 | <div class="col-sm-6"> |
1722 | 1722 | <button type="submit" class="btn btn-default pull-right" name="step3" value="< <?php echo get_lang('Previous'); ?>" ><em class="fa fa-backward"> </em> <?php echo get_lang('Previous'); ?></button> |
@@ -973,8 +973,7 @@ discard block |
||
973 | 973 | <?php echo get_lang('Error'); ?>!<br /> |
974 | 974 | Chamilo <?php echo implode('|', $update_from_version_8).' '.get_lang('HasNotBeenFoundInThatDir'); ?>. |
975 | 975 | </div> |
976 | - <?php } |
|
977 | - else { |
|
976 | + <?php } else { |
|
978 | 977 | echo '<br />'; |
979 | 978 | } |
980 | 979 | ?> |
@@ -1060,14 +1059,19 @@ discard block |
||
1060 | 1059 | <button type="submit" name="step1" class="btn btn-default" onclick="javascript: window.location='index.php'; return false;" value="<?php echo get_lang('Previous'); ?>" > |
1061 | 1060 | <em class="fa fa-backward"> </em> <?php echo get_lang('Previous'); ?> |
1062 | 1061 | </button> |
1063 | - <button type="submit" name="step2_install" class="btn btn-success" value="<?php echo get_lang("NewInstallation"); ?>" <?php if ($error) echo 'disabled="disabled"'; ?> > |
|
1062 | + <button type="submit" name="step2_install" class="btn btn-success" value="<?php echo get_lang("NewInstallation"); ?>" <?php if ($error) { |
|
1063 | + echo 'disabled="disabled"'; |
|
1064 | +} |
|
1065 | +?> > |
|
1064 | 1066 | <em class="fa fa-forward"> </em> <?php echo get_lang('NewInstallation'); ?> |
1065 | 1067 | </button> |
1066 | 1068 | <input type="hidden" name="is_executable" id="is_executable" value="-" /> |
1067 | 1069 | <?php |
1068 | 1070 | // Real code |
1069 | 1071 | echo '<button type="submit" class="btn btn-default" name="step2_update_8" value="Upgrade from Chamilo 1.9.x"'; |
1070 | - if ($error) echo ' disabled="disabled"'; |
|
1072 | + if ($error) { |
|
1073 | + echo ' disabled="disabled"'; |
|
1074 | + } |
|
1071 | 1075 | echo ' ><em class="fa fa-forward"> </em> '.get_lang('UpgradeFromLMS19x').'</button>'; |
1072 | 1076 | |
1073 | 1077 | echo '</p>'; |
@@ -1350,7 +1354,7 @@ discard block |
||
1350 | 1354 | <input type="hidden" name="dbHostForm" value="<?php echo htmlentities($dbHostForm); ?>" /><?php echo $dbHostForm; ?> |
1351 | 1355 | </div> |
1352 | 1356 | <div class="col-sm-3"></div> |
1353 | - <?php }else{ ?> |
|
1357 | + <?php } else{ ?> |
|
1354 | 1358 | <div class="col-sm-5"> |
1355 | 1359 | <input type="text" class="form-control" size="25" maxlength="50" name="dbHostForm" value="<?php echo htmlentities($dbHostForm); ?>" /> |
1356 | 1360 | </div> |
@@ -1364,7 +1368,7 @@ discard block |
||
1364 | 1368 | <input type="hidden" name="dbPortForm" value="<?php echo htmlentities($dbPortForm); ?>" /><?php echo $dbPortForm; ?> |
1365 | 1369 | </div> |
1366 | 1370 | <div class="col-sm-3"></div> |
1367 | - <?php }else{ ?> |
|
1371 | + <?php } else{ ?> |
|
1368 | 1372 | <div class="col-sm-5"> |
1369 | 1373 | <input type="text" class="form-control" size="25" maxlength="50" name="dbPortForm" value="<?php echo htmlentities($dbPortForm); ?>" /> |
1370 | 1374 | </div> |
@@ -1446,9 +1450,12 @@ discard block |
||
1446 | 1450 | Database port: <strong><?php echo $manager->getConnection()->getPort(); ?></strong><br/> |
1447 | 1451 | Database driver: <strong><?php echo $manager->getConnection()->getDriver()->getName(); ?></strong><br/> |
1448 | 1452 | </div> |
1449 | - <?php else: ?> |
|
1453 | + <?php else { |
|
1454 | + : ?> |
|
1450 | 1455 | <div id="db_status" class="alert alert-danger"> |
1451 | - <p><?php echo get_lang('FailedConectionDatabase'); ?></strong></p> |
|
1456 | + <p><?php echo get_lang('FailedConectionDatabase'); |
|
1457 | +} |
|
1458 | +?></strong></p> |
|
1452 | 1459 | <code><?php echo $database_exists_text ?></code> |
1453 | 1460 | </div> |
1454 | 1461 | <?php endif; ?> |
@@ -395,7 +395,7 @@ discard block |
||
395 | 395 | if (!is_array($result)) { |
396 | 396 | $result = array(); |
397 | 397 | $exceptions = array('.', '..', 'CVS', '.svn'); |
398 | - $search = array('_latin', '_unicode', '_corporate', '_org' , '_KM', '_'); |
|
398 | + $search = array('_latin', '_unicode', '_corporate', '_org', '_KM', '_'); |
|
399 | 399 | $replace_with = array(' (Latin)', ' (unicode)', ' (corporate)', ' (org)', ' (KM)', ' '); |
400 | 400 | $dirname = api_get_path(SYS_LANG_PATH); |
401 | 401 | $handle = opendir($dirname); |
@@ -430,9 +430,9 @@ discard block |
||
430 | 430 | if ($handle = opendir($directory)) { |
431 | 431 | while (false !== ($file = readdir($handle))) { |
432 | 432 | if ($file != "." && $file != "..") { |
433 | - if (is_dir($directory. "/" . $file)) { |
|
434 | - $array_items = array_merge($array_items, my_directory_to_array($directory. '/' . $file)); |
|
435 | - $file = $directory . "/" . $file; |
|
433 | + if (is_dir($directory."/".$file)) { |
|
434 | + $array_items = array_merge($array_items, my_directory_to_array($directory.'/'.$file)); |
|
435 | + $file = $directory."/".$file; |
|
436 | 436 | $array_items[] = preg_replace("/\/\//si", '/', $file); |
437 | 437 | } |
438 | 438 | } |
@@ -636,7 +636,7 @@ discard block |
||
636 | 636 | <h2><?php get_lang('WelcomeToTheChamiloInstaller'); ?></h2> |
637 | 637 | <div class="RequirementHeading"> |
638 | 638 | <h2><?php echo display_step_sequence(); ?> |
639 | - <?php echo get_lang('InstallationLanguage');?> |
|
639 | + <?php echo get_lang('InstallationLanguage'); ?> |
|
640 | 640 | </h2> |
641 | 641 | <p><?php echo get_lang('PleaseSelectInstallationProcessLanguage'); ?>:</p> |
642 | 642 | <form id="lang_form" method="post" action="<?php echo api_get_self(); ?>"> |
@@ -709,7 +709,7 @@ discard block |
||
709 | 709 | if (phpversion() < REQUIRED_PHP_VERSION) { |
710 | 710 | echo '<strong><font color="red">'.get_lang('PHPVersionError').'</font></strong>'; |
711 | 711 | } else { |
712 | - echo '<strong><font color="green">'.get_lang('PHPVersionOK'). ' '.phpversion().'</font></strong>'; |
|
712 | + echo '<strong><font color="green">'.get_lang('PHPVersionOK').' '.phpversion().'</font></strong>'; |
|
713 | 713 | } |
714 | 714 | echo '</td> |
715 | 715 | </tr> |
@@ -1137,7 +1137,7 @@ discard block |
||
1137 | 1137 | function get_contact_registration_form() |
1138 | 1138 | { |
1139 | 1139 | |
1140 | - $html =' |
|
1140 | + $html = ' |
|
1141 | 1141 | <form class="form-horizontal"> |
1142 | 1142 | <div class="panel panel-default"> |
1143 | 1143 | <div class="panel-body"> |
@@ -1234,7 +1234,7 @@ discard block |
||
1234 | 1234 | <div class="col-sm-9"> |
1235 | 1235 | <div class="radio"> |
1236 | 1236 | <label> |
1237 | - <input type="radio" name="financial_decision" id="financial_decision1" value="1" checked /> ' . get_lang('Yes') . ' |
|
1237 | + <input type="radio" name="financial_decision" id="financial_decision1" value="1" checked /> ' . get_lang('Yes').' |
|
1238 | 1238 | </label> |
1239 | 1239 | </div> |
1240 | 1240 | <div class="radio"> |
@@ -1293,8 +1293,8 @@ discard block |
||
1293 | 1293 | echo '<input type="hidden" name="'.$formFieldName.'" id="'.$formFieldName.'" value="'.api_htmlentities($parameterValue).'" />'; |
1294 | 1294 | echo api_htmlentities($parameterValue); |
1295 | 1295 | } else { |
1296 | - echo '<div class="col-sm-5"><input type="' . $inputType . '" class="form-control" size="' . DATABASE_FORM_FIELD_DISPLAY_LENGTH . '" maxlength="' . $maxLength . '" name="' . $formFieldName . '" id="' . $formFieldName . '" value="' . api_htmlentities($parameterValue) . '" />' . "</div>"; |
|
1297 | - echo '<div class="col-sm-3">' . $extra_notice . '</div>'; |
|
1296 | + echo '<div class="col-sm-5"><input type="'.$inputType.'" class="form-control" size="'.DATABASE_FORM_FIELD_DISPLAY_LENGTH.'" maxlength="'.$maxLength.'" name="'.$formFieldName.'" id="'.$formFieldName.'" value="'.api_htmlentities($parameterValue).'" />'."</div>"; |
|
1297 | + echo '<div class="col-sm-3">'.$extra_notice.'</div>'; |
|
1298 | 1298 | } |
1299 | 1299 | } |
1300 | 1300 | } |
@@ -1328,12 +1328,12 @@ discard block |
||
1328 | 1328 | $dbNameForm = $_configuration['main_database']; |
1329 | 1329 | $dbPortForm = isset($_configuration['db_port']) ? $_configuration['db_port'] : ''; |
1330 | 1330 | |
1331 | - echo '<div class="RequirementHeading"><h2>' . display_step_sequence() .get_lang('DBSetting') . '</h2></div>'; |
|
1331 | + echo '<div class="RequirementHeading"><h2>'.display_step_sequence().get_lang('DBSetting').'</h2></div>'; |
|
1332 | 1332 | echo '<div class="RequirementContent">'; |
1333 | 1333 | echo get_lang('DBSettingUpgradeIntro'); |
1334 | 1334 | echo '</div>'; |
1335 | 1335 | } else { |
1336 | - echo '<div class="RequirementHeading"><h2>' . display_step_sequence() .get_lang('DBSetting') . '</h2></div>'; |
|
1336 | + echo '<div class="RequirementHeading"><h2>'.display_step_sequence().get_lang('DBSetting').'</h2></div>'; |
|
1337 | 1337 | echo '<div class="RequirementContent">'; |
1338 | 1338 | echo get_lang('DBSettingIntro'); |
1339 | 1339 | echo '</div>'; |
@@ -1343,12 +1343,12 @@ discard block |
||
1343 | 1343 | <div class="panel-body"> |
1344 | 1344 | <div class="form-group"> |
1345 | 1345 | <label class="col-sm-4"><?php echo get_lang('DBHost'); ?> </label> |
1346 | - <?php if ($installType == 'update'){ ?> |
|
1346 | + <?php if ($installType == 'update') { ?> |
|
1347 | 1347 | <div class="col-sm-5"> |
1348 | 1348 | <input type="hidden" name="dbHostForm" value="<?php echo htmlentities($dbHostForm); ?>" /><?php echo $dbHostForm; ?> |
1349 | 1349 | </div> |
1350 | 1350 | <div class="col-sm-3"></div> |
1351 | - <?php }else{ ?> |
|
1351 | + <?php } else { ?> |
|
1352 | 1352 | <div class="col-sm-5"> |
1353 | 1353 | <input type="text" class="form-control" size="25" maxlength="50" name="dbHostForm" value="<?php echo htmlentities($dbHostForm); ?>" /> |
1354 | 1354 | </div> |
@@ -1357,12 +1357,12 @@ discard block |
||
1357 | 1357 | </div> |
1358 | 1358 | <div class="form-group"> |
1359 | 1359 | <label class="col-sm-4"><?php echo get_lang('DBPort'); ?> </label> |
1360 | - <?php if ($installType == 'update'){ ?> |
|
1360 | + <?php if ($installType == 'update') { ?> |
|
1361 | 1361 | <div class="col-sm-5"> |
1362 | 1362 | <input type="hidden" name="dbPortForm" value="<?php echo htmlentities($dbPortForm); ?>" /><?php echo $dbPortForm; ?> |
1363 | 1363 | </div> |
1364 | 1364 | <div class="col-sm-3"></div> |
1365 | - <?php }else{ ?> |
|
1365 | + <?php } else { ?> |
|
1366 | 1366 | <div class="col-sm-5"> |
1367 | 1367 | <input type="text" class="form-control" size="25" maxlength="50" name="dbPortForm" value="<?php echo htmlentities($dbPortForm); ?>" /> |
1368 | 1368 | </div> |
@@ -1388,7 +1388,7 @@ discard block |
||
1388 | 1388 | <?php |
1389 | 1389 | //Database Name fix replace weird chars |
1390 | 1390 | if ($installType != INSTALL_TYPE_UPDATE) { |
1391 | - $dbNameForm = str_replace(array('-','*', '$', ' ', '.'), '', $dbNameForm); |
|
1391 | + $dbNameForm = str_replace(array('-', '*', '$', ' ', '.'), '', $dbNameForm); |
|
1392 | 1392 | } |
1393 | 1393 | |
1394 | 1394 | displayDatabaseParameter( |
@@ -1481,7 +1481,7 @@ discard block |
||
1481 | 1481 | if (!empty($title)) { |
1482 | 1482 | $panelTitle = Display::div($title, array('class' => 'panel-heading')); |
1483 | 1483 | $panelBody = Display::div($content, array('class' => 'panel-body')); |
1484 | - $panelParent = Display::div($panelTitle . $panelBody, array('id' => $id, 'class' => 'panel panel-'.$style)); |
|
1484 | + $panelParent = Display::div($panelTitle.$panelBody, array('id' => $id, 'class' => 'panel panel-'.$style)); |
|
1485 | 1485 | } else { |
1486 | 1486 | $panelBody = Display::div($html, array('class' => 'panel-body')); |
1487 | 1487 | $panelParent = Display::div($panelBody, array('id' => $id, 'class' => 'panel panel-'.$style)); |
@@ -1507,9 +1507,9 @@ discard block |
||
1507 | 1507 | $displayWhenUpdate = 'true' |
1508 | 1508 | ) { |
1509 | 1509 | $html = '<div class="form-group">'; |
1510 | - $html .= '<label class="col-sm-6 control-label">' . $parameterName . '</label>'; |
|
1510 | + $html .= '<label class="col-sm-6 control-label">'.$parameterName.'</label>'; |
|
1511 | 1511 | if ($installType == INSTALL_TYPE_UPDATE && $displayWhenUpdate) { |
1512 | - $html .= '<input type="hidden" name="' . $formFieldName . '" value="'. api_htmlentities($parameterValue, ENT_QUOTES). '" />' . $parameterValue; |
|
1512 | + $html .= '<input type="hidden" name="'.$formFieldName.'" value="'.api_htmlentities($parameterValue, ENT_QUOTES).'" />'.$parameterValue; |
|
1513 | 1513 | } else { |
1514 | 1514 | $html .= '<div class="col-sm-6"><input class="form-control" type="text" size="'.FORM_FIELD_DISPLAY_LENGTH.'" maxlength="'.MAX_FORM_FIELD_LENGTH.'" name="'.$formFieldName.'" value="'.api_htmlentities($parameterValue, ENT_QUOTES).'" />'."</div>"; |
1515 | 1515 | } |
@@ -1557,7 +1557,7 @@ discard block |
||
1557 | 1557 | $languageForm = $_SESSION['install_language']; |
1558 | 1558 | } |
1559 | 1559 | echo '<div class="RequirementHeading">'; |
1560 | - echo "<h2>" . display_step_sequence() . get_lang("CfgSetting") . "</h2>"; |
|
1560 | + echo "<h2>".display_step_sequence().get_lang("CfgSetting")."</h2>"; |
|
1561 | 1561 | echo '</div>'; |
1562 | 1562 | |
1563 | 1563 | echo '<p>'.get_lang('ConfigSettingsInfo').' <strong>app/config/configuration.php</strong></p>'; |
@@ -1575,14 +1575,14 @@ discard block |
||
1575 | 1575 | |
1576 | 1576 | // Parameters 3 and 4: administrator's names |
1577 | 1577 | |
1578 | - $html .= display_configuration_parameter($installType, get_lang('AdminFirstName'), 'adminFirstName', $adminFirstName); |
|
1579 | - $html .= display_configuration_parameter($installType, get_lang('AdminLastName'), 'adminLastName', $adminLastName); |
|
1578 | + $html .= display_configuration_parameter($installType, get_lang('AdminFirstName'), 'adminFirstName', $adminFirstName); |
|
1579 | + $html .= display_configuration_parameter($installType, get_lang('AdminLastName'), 'adminLastName', $adminLastName); |
|
1580 | 1580 | |
1581 | 1581 | //Parameter 3: administrator's email |
1582 | - $html .= display_configuration_parameter($installType, get_lang('AdminEmail'), 'emailForm', $emailForm); |
|
1582 | + $html .= display_configuration_parameter($installType, get_lang('AdminEmail'), 'emailForm', $emailForm); |
|
1583 | 1583 | |
1584 | 1584 | //Parameter 6: administrator's telephone |
1585 | - $html .= display_configuration_parameter($installType, get_lang('AdminPhone'), 'adminPhoneForm', $adminPhoneForm); |
|
1585 | + $html .= display_configuration_parameter($installType, get_lang('AdminPhone'), 'adminPhoneForm', $adminPhoneForm); |
|
1586 | 1586 | |
1587 | 1587 | |
1588 | 1588 | echo panel($html, get_lang('Administrator'), 'administrator'); |
@@ -1601,12 +1601,12 @@ discard block |
||
1601 | 1601 | $html .= display_language_selection_box('languageForm', $languageForm); |
1602 | 1602 | $html .= '</div>'; |
1603 | 1603 | } |
1604 | - $html.= "</div>"; |
|
1604 | + $html .= "</div>"; |
|
1605 | 1605 | |
1606 | 1606 | |
1607 | 1607 | //Second parameter: Chamilo URL |
1608 | 1608 | $html .= '<div class="form-group">'; |
1609 | - $html .= '<label class="col-sm-6 control-label">'.get_lang('ChamiloURL') .get_lang('ThisFieldIsRequired').'</label>'; |
|
1609 | + $html .= '<label class="col-sm-6 control-label">'.get_lang('ChamiloURL').get_lang('ThisFieldIsRequired').'</label>'; |
|
1610 | 1610 | |
1611 | 1611 | |
1612 | 1612 | |
@@ -1630,34 +1630,34 @@ discard block |
||
1630 | 1630 | |
1631 | 1631 | |
1632 | 1632 | $html .= '<div class="form-group"> |
1633 | - <label class="col-sm-6 control-label">' . get_lang("EncryptMethodUserPass") . '</label> |
|
1633 | + <label class="col-sm-6 control-label">' . get_lang("EncryptMethodUserPass").'</label> |
|
1634 | 1634 | <div class="col-sm-6">'; |
1635 | 1635 | if ($installType == 'update') { |
1636 | - $html .= '<input type="hidden" name="encryptPassForm" value="'. $encryptPassForm .'" />'. $encryptPassForm; |
|
1636 | + $html .= '<input type="hidden" name="encryptPassForm" value="'.$encryptPassForm.'" />'.$encryptPassForm; |
|
1637 | 1637 | } else { |
1638 | 1638 | |
1639 | 1639 | $html .= '<div class="checkbox"> |
1640 | 1640 | <label> |
1641 | - <input type="radio" name="encryptPassForm" value="bcrypt" id="encryptPass1" '. ($encryptPassForm == 'bcrypt' ? 'checked="checked" ':'') .'/> bcrypt |
|
1641 | + <input type="radio" name="encryptPassForm" value="bcrypt" id="encryptPass1" '. ($encryptPassForm == 'bcrypt' ? 'checked="checked" ' : '').'/> bcrypt |
|
1642 | 1642 | </label>'; |
1643 | 1643 | |
1644 | 1644 | $html .= '<label> |
1645 | - <input type="radio" name="encryptPassForm" value="sha1" id="encryptPass1" '. ($encryptPassForm == 'sha1' ? 'checked="checked" ':'') .'/> sha1 |
|
1645 | + <input type="radio" name="encryptPassForm" value="sha1" id="encryptPass1" '. ($encryptPassForm == 'sha1' ? 'checked="checked" ' : '').'/> sha1 |
|
1646 | 1646 | </label>'; |
1647 | 1647 | |
1648 | 1648 | $html .= '<label> |
1649 | - <input type="radio" name="encryptPassForm" value="md5" id="encryptPass0" '. ($encryptPassForm == 'md5' ? 'checked="checked" ':'') .'/> md5 |
|
1649 | + <input type="radio" name="encryptPassForm" value="md5" id="encryptPass0" '. ($encryptPassForm == 'md5' ? 'checked="checked" ' : '').'/> md5 |
|
1650 | 1650 | </label>'; |
1651 | 1651 | |
1652 | 1652 | $html .= '<label> |
1653 | - <input type="radio" name="encryptPassForm" value="none" id="encryptPass2" '. ($encryptPassForm == 'none' ? 'checked="checked" ':'') .'/>'. get_lang('None').' |
|
1653 | + <input type="radio" name="encryptPassForm" value="none" id="encryptPass2" '. ($encryptPassForm == 'none' ? 'checked="checked" ' : '').'/>'.get_lang('None').' |
|
1654 | 1654 | </label>'; |
1655 | 1655 | $html .= '</div>'; |
1656 | 1656 | } |
1657 | 1657 | $html .= '</div></div>'; |
1658 | 1658 | |
1659 | 1659 | $html .= '<div class="form-group"> |
1660 | - <label class="col-sm-6 control-label">' . get_lang('AllowSelfReg') . '</label> |
|
1660 | + <label class="col-sm-6 control-label">' . get_lang('AllowSelfReg').'</label> |
|
1661 | 1661 | <div class="col-sm-6">'; |
1662 | 1662 | if ($installType == 'update') { |
1663 | 1663 | if ($allowSelfReg == 'true') { |
@@ -1667,17 +1667,17 @@ discard block |
||
1667 | 1667 | } else { |
1668 | 1668 | $label = get_lang('AfterApproval'); |
1669 | 1669 | } |
1670 | - $html .= '<input type="hidden" name="allowSelfReg" value="'. $allowSelfReg .'" />'. $label; |
|
1670 | + $html .= '<input type="hidden" name="allowSelfReg" value="'.$allowSelfReg.'" />'.$label; |
|
1671 | 1671 | } else { |
1672 | 1672 | $html .= '<div class="control-group">'; |
1673 | 1673 | $html .= '<label class="checkbox-inline"> |
1674 | - <input type="radio" name="allowSelfReg" value="1" id="allowSelfReg1" '. ($allowSelfReg == 'true' ? 'checked="checked" ' : '') . ' /> '. get_lang('Yes') .' |
|
1674 | + <input type="radio" name="allowSelfReg" value="1" id="allowSelfReg1" '. ($allowSelfReg == 'true' ? 'checked="checked" ' : '').' /> '.get_lang('Yes').' |
|
1675 | 1675 | </label>'; |
1676 | 1676 | $html .= '<label class="checkbox-inline"> |
1677 | - <input type="radio" name="allowSelfReg" value="0" id="allowSelfReg0" '. ($allowSelfReg == 'false' ? '' : 'checked="checked" ') .' /> '. get_lang('No') .' |
|
1677 | + <input type="radio" name="allowSelfReg" value="0" id="allowSelfReg0" '. ($allowSelfReg == 'false' ? '' : 'checked="checked" ').' /> '.get_lang('No').' |
|
1678 | 1678 | </label>'; |
1679 | 1679 | $html .= '<label class="checkbox-inline"> |
1680 | - <input type="radio" name="allowSelfReg" value="0" id="allowSelfReg0" '. ($allowSelfReg == 'approval' ? '' : 'checked="checked" ') .' /> '. get_lang('AfterApproval') .' |
|
1680 | + <input type="radio" name="allowSelfReg" value="0" id="allowSelfReg0" '. ($allowSelfReg == 'approval' ? '' : 'checked="checked" ').' /> '.get_lang('AfterApproval').' |
|
1681 | 1681 | </label>'; |
1682 | 1682 | $html .= '</div>'; |
1683 | 1683 | } |
@@ -1685,7 +1685,7 @@ discard block |
||
1685 | 1685 | $html .= '</div>'; |
1686 | 1686 | |
1687 | 1687 | $html .= '<div class="form-group">'; |
1688 | - $html .= '<label class="col-sm-6 control-label">'. get_lang('AllowSelfRegProf') .'</label> |
|
1688 | + $html .= '<label class="col-sm-6 control-label">'.get_lang('AllowSelfRegProf').'</label> |
|
1689 | 1689 | <div class="col-sm-6">'; |
1690 | 1690 | if ($installType == 'update') { |
1691 | 1691 | if ($allowSelfRegProf == 'true') { |
@@ -1693,16 +1693,16 @@ discard block |
||
1693 | 1693 | } else { |
1694 | 1694 | $label = get_lang('No'); |
1695 | 1695 | } |
1696 | - $html .= '<input type="hidden" name="allowSelfRegProf" value="'. $allowSelfRegProf.'" />'. $label; |
|
1696 | + $html .= '<input type="hidden" name="allowSelfRegProf" value="'.$allowSelfRegProf.'" />'.$label; |
|
1697 | 1697 | } else { |
1698 | 1698 | $html .= '<div class="control-group"> |
1699 | 1699 | <label class="checkbox-inline"> |
1700 | - <input type="radio" name="allowSelfRegProf" value="1" id="allowSelfRegProf1" '. ($allowSelfRegProf ? 'checked="checked" ' : '') .'/> |
|
1701 | - ' . get_lang('Yes') .' |
|
1700 | + <input type="radio" name="allowSelfRegProf" value="1" id="allowSelfRegProf1" '. ($allowSelfRegProf ? 'checked="checked" ' : '').'/> |
|
1701 | + ' . get_lang('Yes').' |
|
1702 | 1702 | </label>'; |
1703 | 1703 | $html .= '<label class="checkbox-inline"> |
1704 | - <input type="radio" name="allowSelfRegProf" value="0" id="allowSelfRegProf0" '. ($allowSelfRegProf ? '' : 'checked="checked" ') .' /> |
|
1705 | - '. get_lang('No') .' |
|
1704 | + <input type="radio" name="allowSelfRegProf" value="0" id="allowSelfRegProf0" '. ($allowSelfRegProf ? '' : 'checked="checked" ').' /> |
|
1705 | + '. get_lang('No').' |
|
1706 | 1706 | </label>'; |
1707 | 1707 | $html .= '</div>'; |
1708 | 1708 | } |
@@ -1767,7 +1767,7 @@ discard block |
||
1767 | 1767 | "Macedonia", "Madagascar", "Malawi", "Malaysia", "Maldives", "Mali", "Malta", "Marshall Islands", "Mauritania", "Mauritius", "Mexico", "Micronesia", "Moldova", "Monaco", "Mongolia", "Morocco", "Mozambique", "Myanmar", |
1768 | 1768 | "Namibia", "Nauru", "Nepa", "Netherlands", "New Zealand", "Nicaragua", "Niger", "Nigeria", "Norway", |
1769 | 1769 | "Oman", |
1770 | - "Pakistan", "Palau", "Panama", "Papua New Guinea", "Paraguay", "Peru", "Philippines", "Poland","Portugal", |
|
1770 | + "Pakistan", "Palau", "Panama", "Papua New Guinea", "Paraguay", "Peru", "Philippines", "Poland", "Portugal", |
|
1771 | 1771 | "Qatar", |
1772 | 1772 | "Romania", "Russia", "Rwanda", |
1773 | 1773 | "Saint Kitts and Nevis", "Saint Lucia", "Saint Vincent", "Samoa", "San Marino", "Sao Tome and Principe", "Saudi Arabia", "Senegal", "Serbia and Montenegro", "Seychelles", "Sierra Leone", "Singapore", "Slovakia", "Slovenia", "Solomon Islands", "Somalia", "South Africa", "Spain", "Sri Lanka", "Sudan", "Suriname", "Swaziland", "Sweden", "Switzerland", "Syria", |
@@ -1814,11 +1814,11 @@ discard block |
||
1814 | 1814 | $permissions_for_new_directories = isset($_SESSION['permissions_for_new_directories']) ? $_SESSION['permissions_for_new_directories'] : 0770; |
1815 | 1815 | $permissions_for_new_files = isset($_SESSION['permissions_for_new_files']) ? $_SESSION['permissions_for_new_files'] : 0660; |
1816 | 1816 | // use decoct() to store as string |
1817 | - $sql = "UPDATE $table SET selected_value = '0" . decoct($permissions_for_new_directories) . "' |
|
1817 | + $sql = "UPDATE $table SET selected_value = '0".decoct($permissions_for_new_directories)."' |
|
1818 | 1818 | WHERE variable = 'permissions_for_new_directories'"; |
1819 | 1819 | Database::query($sql); |
1820 | 1820 | |
1821 | - $sql = "UPDATE $table SET selected_value = '0" . decoct($permissions_for_new_files) . "' WHERE variable = 'permissions_for_new_files'"; |
|
1821 | + $sql = "UPDATE $table SET selected_value = '0".decoct($permissions_for_new_files)."' WHERE variable = 'permissions_for_new_files'"; |
|
1822 | 1822 | Database::query($sql); |
1823 | 1823 | |
1824 | 1824 | if (isset($_SESSION['permissions_for_new_directories'])) { |
@@ -1838,8 +1838,8 @@ discard block |
||
1838 | 1838 | function compare_setting_values($current_value, $wanted_value) |
1839 | 1839 | { |
1840 | 1840 | $current_value_string = $current_value; |
1841 | - $current_value = (float)$current_value; |
|
1842 | - $wanted_value = (float)$wanted_value; |
|
1841 | + $current_value = (float) $current_value; |
|
1842 | + $wanted_value = (float) $wanted_value; |
|
1843 | 1843 | |
1844 | 1844 | if ($current_value >= $wanted_value) { |
1845 | 1845 | return Display::label($current_value_string, 'success'); |
@@ -1890,7 +1890,7 @@ discard block |
||
1890 | 1890 | |
1891 | 1891 | fwrite($fp, $out); |
1892 | 1892 | while (!feof($fp)) { |
1893 | - $result = str_replace("\r\n", '',fgets($fp, 128)); |
|
1893 | + $result = str_replace("\r\n", '', fgets($fp, 128)); |
|
1894 | 1894 | if (!empty($result) && $result == '123') { |
1895 | 1895 | $output = true; |
1896 | 1896 | } |
@@ -1913,7 +1913,7 @@ discard block |
||
1913 | 1913 | curl_setopt($ch, CURLOPT_URL, $url); |
1914 | 1914 | //curl_setopt($ch, CURLOPT_TIMEOUT, 30); |
1915 | 1915 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
1916 | - $result = curl_exec ($ch); |
|
1916 | + $result = curl_exec($ch); |
|
1917 | 1917 | if (!empty($result) && $result == '123') { |
1918 | 1918 | $output = true; |
1919 | 1919 | } |
@@ -2127,12 +2127,12 @@ discard block |
||
2127 | 2127 | $adminPhoneForm, |
2128 | 2128 | '', //$picture_uri = '', |
2129 | 2129 | PLATFORM_AUTH_SOURCE, |
2130 | - '',//$expirationDate, |
|
2130 | + '', //$expirationDate, |
|
2131 | 2131 | 1, |
2132 | 2132 | 0, |
2133 | 2133 | null, |
2134 | 2134 | '', |
2135 | - false, //$send_mail = false, |
|
2135 | + false, //$send_mail = false, |
|
2136 | 2136 | true //$isAdmin = false |
2137 | 2137 | ); |
2138 | 2138 | |
@@ -2154,7 +2154,7 @@ discard block |
||
2154 | 2154 | 0, |
2155 | 2155 | null, |
2156 | 2156 | '', |
2157 | - false, //$send_mail = false, |
|
2157 | + false, //$send_mail = false, |
|
2158 | 2158 | false //$isAdmin = false |
2159 | 2159 | ); |
2160 | 2160 | |
@@ -2184,7 +2184,7 @@ discard block |
||
2184 | 2184 | $finder = new \Symfony\Component\Finder\Finder(); |
2185 | 2185 | $files = $finder->files()->in($path); |
2186 | 2186 | foreach ($files as $version) { |
2187 | - $version = str_replace(['Version', '.php' ], '', $version->getFilename()); |
|
2187 | + $version = str_replace(['Version', '.php'], '', $version->getFilename()); |
|
2188 | 2188 | $sql = "INSERT INTO version VALUES ('$version')"; |
2189 | 2189 | Database::query($sql); |
2190 | 2190 | } |
@@ -2230,7 +2230,7 @@ discard block |
||
2230 | 2230 | SET selected_value = '".$param->selected_value."' |
2231 | 2231 | WHERE variable = '".$param->variable."'"; |
2232 | 2232 | if (!empty($param->subkey)) { |
2233 | - $sql .= " AND subkey='" . $param->subkey . "'"; |
|
2233 | + $sql .= " AND subkey='".$param->subkey."'"; |
|
2234 | 2234 | } |
2235 | 2235 | Database::query($sql); |
2236 | 2236 | } |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | |
119 | 119 | /** |
120 | 120 | * This function retrieves the existing permissions of a user, group or role. |
121 | -* @param $content are we retrieving the rights of a user, a group or a role (the database depends on it) |
|
121 | +* @param string $content are we retrieving the rights of a user, a group or a role (the database depends on it) |
|
122 | 122 | * @param $id the id of the user, group or role |
123 | 123 | * @author Patrick Cool <[email protected]>, Ghent University |
124 | 124 | * @version 1.0 |
@@ -526,7 +526,7 @@ discard block |
||
526 | 526 | |
527 | 527 | /** |
528 | 528 | * This function gets all the roles that are defined |
529 | -* @param $content are we finding the roles for a user or a group (the database depends on it) |
|
529 | +* @param string $content are we finding the roles for a user or a group (the database depends on it) |
|
530 | 530 | * @param $id the id of the user or group |
531 | 531 | * @param string Deprecated parameter allowing use of 'platform' scope - the corresponding tables don't exist anymore so the scope is always set to 'course' |
532 | 532 | * @return array that contains the name of the roles the user has |
@@ -132,24 +132,20 @@ discard block |
||
132 | 132 | { |
133 | 133 | $table=Database::get_course_table(TABLE_PERMISSION_USER); |
134 | 134 | $id_field = 'user_id'; |
135 | - } |
|
136 | - elseif ($content == 'group') |
|
135 | + } elseif ($content == 'group') |
|
137 | 136 | { |
138 | 137 | $table=Database::get_course_table(TABLE_PERMISSION_GROUP); |
139 | 138 | $id_field = 'group_id'; |
140 | - } |
|
141 | - elseif ($content == 'role') |
|
139 | + } elseif ($content == 'role') |
|
142 | 140 | { |
143 | 141 | $table=Database::get_course_table(TABLE_ROLE_PERMISSION); |
144 | 142 | $id_field = 'role_id'; |
145 | - } |
|
146 | - elseif ($content == 'platform_role') |
|
143 | + } elseif ($content == 'platform_role') |
|
147 | 144 | { |
148 | 145 | $table=Database::get_main_table(TABLE_ROLE_PERMISSION); |
149 | 146 | $id_field = 'role_id'; |
150 | 147 | $course_id_condition = ''; |
151 | - } |
|
152 | - elseif ($content == 'task') |
|
148 | + } elseif ($content == 'task') |
|
153 | 149 | { |
154 | 150 | $table=Database::get_course_table(TABLE_BLOGS_TASKS_PERMISSIONS); |
155 | 151 | $id_field = 'task_id'; |
@@ -162,8 +158,9 @@ discard block |
||
162 | 158 | WHERE $course_id_condition " . $id_field . "='" . Database::escape_string($id) . "'"; |
163 | 159 | $result = Database::query($sql); |
164 | 160 | |
165 | - while($row = Database::fetch_array($result)) |
|
166 | - $currentpermissions[$row['tool']][] = $row['action']; |
|
161 | + while($row = Database::fetch_array($result)) { |
|
162 | + $currentpermissions[$row['tool']][] = $row['action']; |
|
163 | + } |
|
167 | 164 | |
168 | 165 | return $currentpermissions; |
169 | 166 | } |
@@ -321,14 +318,12 @@ discard block |
||
321 | 318 | if ($course_admin) |
322 | 319 | { |
323 | 320 | echo "\t\t\t<img src=\"../img/checkbox_on3.gif\" border=\"0\"/ title=\"".get_lang('PermissionGrantedByGroupOrRole')."\">"; |
324 | - } |
|
325 | - else |
|
321 | + } else |
|
326 | 322 | { |
327 | 323 | if (!empty($inherited_permissions) and in_array($permission,$inherited_permissions[$tool])) |
328 | 324 | { |
329 | 325 | echo "\t\t\t<img src=\"../img/checkbox_on3.gif\" border=\"0\"/ title=\"".get_lang('PermissionGrantedByGroupOrRole')."\">"; |
330 | - } |
|
331 | - else |
|
326 | + } else |
|
332 | 327 | { |
333 | 328 | if (is_array($permission_array[$tool]) AND in_array($permission,$permission_array[$tool])) |
334 | 329 | { |
@@ -439,8 +434,7 @@ discard block |
||
439 | 434 | $checked='checked'; |
440 | 435 | $image='checkbox_on2.gif'; |
441 | 436 | $action='revoke'; |
442 | - } |
|
443 | - else |
|
437 | + } else |
|
444 | 438 | { |
445 | 439 | $checked=''; |
446 | 440 | $image='wrong.gif'; |
@@ -25,38 +25,38 @@ discard block |
||
25 | 25 | function store_permissions($content, $id) { |
26 | 26 | $course_id = api_get_course_int_id(); |
27 | 27 | |
28 | - // Which database are we using (depending on the $content parameter) |
|
29 | - if ($content=='user') |
|
30 | - { |
|
31 | - $table=Database::get_course_table(TABLE_PERMISSION_USER); |
|
32 | - $id_field = user_id; |
|
33 | - } |
|
34 | - if ($content=='group') |
|
35 | - { |
|
36 | - $table=Database::get_course_table(TABLE_PERMISSION_GROUP); |
|
37 | - $id_field = group_id; |
|
38 | - } |
|
39 | - if ($content=='role') |
|
40 | - { |
|
41 | - $table=Database::get_course_table(TABLE_ROLE_PERMISSION); |
|
42 | - $id_field = role_id; |
|
43 | - } |
|
44 | - |
|
45 | - // We first delete all the existing permissions for that user/group/role |
|
46 | - $sql="DELETE FROM $table WHERE c_id = $course_id AND $id_field = '".Database::escape_string($id)."'"; |
|
47 | - $result=Database::query($sql); |
|
48 | - |
|
49 | - // looping through the post values to find the permission (containing the string permission* ) |
|
50 | - foreach ($_POST as $key => $value) |
|
51 | - { |
|
52 | - if (strstr($key,"permission*")) |
|
53 | - { |
|
54 | - list($brol,$tool,$action)=explode("*",$key); |
|
55 | - $sql="INSERT INTO $table (c_id, $id_field,tool,action) VALUES ($course_id, '".Database::escape_string($id)."','".Database::escape_string($tool)."','".Database::escape_string($action)."')"; |
|
56 | - $result=Database::query($sql); |
|
57 | - } |
|
58 | - } |
|
59 | - return get_lang('PermissionsStored'); |
|
28 | + // Which database are we using (depending on the $content parameter) |
|
29 | + if ($content=='user') |
|
30 | + { |
|
31 | + $table=Database::get_course_table(TABLE_PERMISSION_USER); |
|
32 | + $id_field = user_id; |
|
33 | + } |
|
34 | + if ($content=='group') |
|
35 | + { |
|
36 | + $table=Database::get_course_table(TABLE_PERMISSION_GROUP); |
|
37 | + $id_field = group_id; |
|
38 | + } |
|
39 | + if ($content=='role') |
|
40 | + { |
|
41 | + $table=Database::get_course_table(TABLE_ROLE_PERMISSION); |
|
42 | + $id_field = role_id; |
|
43 | + } |
|
44 | + |
|
45 | + // We first delete all the existing permissions for that user/group/role |
|
46 | + $sql="DELETE FROM $table WHERE c_id = $course_id AND $id_field = '".Database::escape_string($id)."'"; |
|
47 | + $result=Database::query($sql); |
|
48 | + |
|
49 | + // looping through the post values to find the permission (containing the string permission* ) |
|
50 | + foreach ($_POST as $key => $value) |
|
51 | + { |
|
52 | + if (strstr($key,"permission*")) |
|
53 | + { |
|
54 | + list($brol,$tool,$action)=explode("*",$key); |
|
55 | + $sql="INSERT INTO $table (c_id, $id_field,tool,action) VALUES ($course_id, '".Database::escape_string($id)."','".Database::escape_string($tool)."','".Database::escape_string($action)."')"; |
|
56 | + $result=Database::query($sql); |
|
57 | + } |
|
58 | + } |
|
59 | + return get_lang('PermissionsStored'); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | /** |
@@ -70,50 +70,50 @@ discard block |
||
70 | 70 | * @version 1.0 |
71 | 71 | */ |
72 | 72 | function store_one_permission($content, $action, $id, $tool,$permission) { |
73 | - global $rights_full; |
|
73 | + global $rights_full; |
|
74 | 74 | $course_id = api_get_course_int_id(); |
75 | - // for some reason I don't know, he can't get to the $rights_full array, so commented the following lines out. |
|
75 | + // for some reason I don't know, he can't get to the $rights_full array, so commented the following lines out. |
|
76 | 76 | |
77 | - // check |
|
78 | - //if(!in_array($permission, $rights_full)) |
|
79 | - //{ |
|
80 | - // return get_lang('Error'); |
|
81 | - //} |
|
77 | + // check |
|
78 | + //if(!in_array($permission, $rights_full)) |
|
79 | + //{ |
|
80 | + // return get_lang('Error'); |
|
81 | + //} |
|
82 | 82 | |
83 | - // Which database are we using (depending on the $content parameter) |
|
83 | + // Which database are we using (depending on the $content parameter) |
|
84 | 84 | |
85 | - if ($content=='user') { |
|
86 | - $table=Database::get_course_table(TABLE_PERMISSION_USER); |
|
87 | - $id_field = user_id; |
|
88 | - } |
|
89 | - if ($content=='group') |
|
90 | - { |
|
91 | - $table=Database::get_course_table(TABLE_PERMISSION_GROUP); |
|
92 | - $id_field = group_id; |
|
93 | - } |
|
94 | - if ($content=='role') |
|
95 | - { |
|
96 | - $table=Database::get_course_table(TABLE_ROLE_PERMISSION); |
|
97 | - $id_field = role_id; |
|
98 | - } |
|
99 | - |
|
100 | - // grating a right |
|
101 | - if ($action=='grant') { |
|
102 | - $sql="INSERT INTO $table (c_id, $id_field,tool,action) VALUES ($course_id, '".Database::escape_string($id)."','".Database::escape_string($tool)."','".Database::escape_string($permission)."')"; |
|
103 | - $result=Database::query($sql); |
|
104 | - if($result) { |
|
105 | - $result_message=get_lang('PermissionGranted'); |
|
106 | - } |
|
107 | - } |
|
108 | - if ($action=='revoke') |
|
109 | - { |
|
110 | - $sql="DELETE FROM $table WHERE c_id = $course_id AND $id_field = '".Database::escape_string($id)."' AND tool='".Database::escape_string($tool)."' AND action='".Database::escape_string($permission)."'"; |
|
111 | - $result=Database::query($sql); |
|
112 | - if($result) { |
|
113 | - $result_message=get_lang('PermissionRevoked'); |
|
114 | - } |
|
115 | - } |
|
116 | - return $result_message; |
|
85 | + if ($content=='user') { |
|
86 | + $table=Database::get_course_table(TABLE_PERMISSION_USER); |
|
87 | + $id_field = user_id; |
|
88 | + } |
|
89 | + if ($content=='group') |
|
90 | + { |
|
91 | + $table=Database::get_course_table(TABLE_PERMISSION_GROUP); |
|
92 | + $id_field = group_id; |
|
93 | + } |
|
94 | + if ($content=='role') |
|
95 | + { |
|
96 | + $table=Database::get_course_table(TABLE_ROLE_PERMISSION); |
|
97 | + $id_field = role_id; |
|
98 | + } |
|
99 | + |
|
100 | + // grating a right |
|
101 | + if ($action=='grant') { |
|
102 | + $sql="INSERT INTO $table (c_id, $id_field,tool,action) VALUES ($course_id, '".Database::escape_string($id)."','".Database::escape_string($tool)."','".Database::escape_string($permission)."')"; |
|
103 | + $result=Database::query($sql); |
|
104 | + if($result) { |
|
105 | + $result_message=get_lang('PermissionGranted'); |
|
106 | + } |
|
107 | + } |
|
108 | + if ($action=='revoke') |
|
109 | + { |
|
110 | + $sql="DELETE FROM $table WHERE c_id = $course_id AND $id_field = '".Database::escape_string($id)."' AND tool='".Database::escape_string($tool)."' AND action='".Database::escape_string($permission)."'"; |
|
111 | + $result=Database::query($sql); |
|
112 | + if($result) { |
|
113 | + $result_message=get_lang('PermissionRevoked'); |
|
114 | + } |
|
115 | + } |
|
116 | + return $result_message; |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | /** |
@@ -125,47 +125,47 @@ discard block |
||
125 | 125 | */ |
126 | 126 | function get_permissions($content, $id) { |
127 | 127 | $course_id = api_get_course_int_id(); |
128 | - $currentpermissions=array(); |
|
129 | - // Which database are we using (depending on the $content parameter) |
|
128 | + $currentpermissions=array(); |
|
129 | + // Which database are we using (depending on the $content parameter) |
|
130 | 130 | $course_id_condition = " c_id = $course_id AND "; |
131 | - if ($content == 'user') |
|
132 | - { |
|
133 | - $table=Database::get_course_table(TABLE_PERMISSION_USER); |
|
134 | - $id_field = 'user_id'; |
|
135 | - } |
|
136 | - elseif ($content == 'group') |
|
137 | - { |
|
138 | - $table=Database::get_course_table(TABLE_PERMISSION_GROUP); |
|
139 | - $id_field = 'group_id'; |
|
140 | - } |
|
141 | - elseif ($content == 'role') |
|
142 | - { |
|
143 | - $table=Database::get_course_table(TABLE_ROLE_PERMISSION); |
|
144 | - $id_field = 'role_id'; |
|
145 | - } |
|
146 | - elseif ($content == 'platform_role') |
|
147 | - { |
|
148 | - $table=Database::get_main_table(TABLE_ROLE_PERMISSION); |
|
149 | - $id_field = 'role_id'; |
|
131 | + if ($content == 'user') |
|
132 | + { |
|
133 | + $table=Database::get_course_table(TABLE_PERMISSION_USER); |
|
134 | + $id_field = 'user_id'; |
|
135 | + } |
|
136 | + elseif ($content == 'group') |
|
137 | + { |
|
138 | + $table=Database::get_course_table(TABLE_PERMISSION_GROUP); |
|
139 | + $id_field = 'group_id'; |
|
140 | + } |
|
141 | + elseif ($content == 'role') |
|
142 | + { |
|
143 | + $table=Database::get_course_table(TABLE_ROLE_PERMISSION); |
|
144 | + $id_field = 'role_id'; |
|
145 | + } |
|
146 | + elseif ($content == 'platform_role') |
|
147 | + { |
|
148 | + $table=Database::get_main_table(TABLE_ROLE_PERMISSION); |
|
149 | + $id_field = 'role_id'; |
|
150 | 150 | $course_id_condition = ''; |
151 | - } |
|
152 | - elseif ($content == 'task') |
|
153 | - { |
|
154 | - $table=Database::get_course_table(TABLE_BLOGS_TASKS_PERMISSIONS); |
|
155 | - $id_field = 'task_id'; |
|
156 | - } |
|
157 | - |
|
158 | - // finding all the permissions. We store this in a multidimensional array |
|
159 | - // where the first dimension is the tool. |
|
160 | - $sql=" |
|
151 | + } |
|
152 | + elseif ($content == 'task') |
|
153 | + { |
|
154 | + $table=Database::get_course_table(TABLE_BLOGS_TASKS_PERMISSIONS); |
|
155 | + $id_field = 'task_id'; |
|
156 | + } |
|
157 | + |
|
158 | + // finding all the permissions. We store this in a multidimensional array |
|
159 | + // where the first dimension is the tool. |
|
160 | + $sql=" |
|
161 | 161 | SELECT * FROM " . $table . " |
162 | 162 | WHERE $course_id_condition " . $id_field . "='" . Database::escape_string($id) . "'"; |
163 | - $result = Database::query($sql); |
|
163 | + $result = Database::query($sql); |
|
164 | 164 | |
165 | - while($row = Database::fetch_array($result)) |
|
166 | - $currentpermissions[$row['tool']][] = $row['action']; |
|
165 | + while($row = Database::fetch_array($result)) |
|
166 | + $currentpermissions[$row['tool']][] = $row['action']; |
|
167 | 167 | |
168 | - return $currentpermissions; |
|
168 | + return $currentpermissions; |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | /** |
@@ -179,38 +179,38 @@ discard block |
||
179 | 179 | */ |
180 | 180 | function limited_or_full($current_permissions) |
181 | 181 | { |
182 | - if (api_get_setting('permissions')=='limited') |
|
183 | - { |
|
184 | - foreach ($current_permissions as $tool=>$tool_rights) |
|
185 | - { |
|
186 | - // we loop through the possible permissions of a tool and unset the entry if it is view |
|
187 | - // if it is visibility or move we have to grant the edit right |
|
188 | - foreach ($tool_rights as $key=>$value) |
|
189 | - { |
|
190 | - if ($value=='View') |
|
191 | - { |
|
192 | - unset($current_permissions[$tool][$key]); |
|
193 | - } |
|
194 | - if ($value=='Visibility' OR $value=='Move') |
|
195 | - { |
|
196 | - if (!in_array('Edit',$current_permissions[$tool])) |
|
197 | - { |
|
198 | - $current_permissions[$tool][]='Edit'; |
|
199 | - } |
|
200 | - unset($current_permissions[$tool][$key]); |
|
201 | - } |
|
202 | - //else |
|
203 | - //{ |
|
204 | - // $current_permissions[$tool][]=$value; |
|
205 | - //} |
|
206 | - } |
|
207 | - } |
|
208 | - return $current_permissions; |
|
209 | - } |
|
210 | - if (api_get_setting('permissions')=='full') |
|
211 | - { |
|
212 | - return $current_permissions; |
|
213 | - } |
|
182 | + if (api_get_setting('permissions')=='limited') |
|
183 | + { |
|
184 | + foreach ($current_permissions as $tool=>$tool_rights) |
|
185 | + { |
|
186 | + // we loop through the possible permissions of a tool and unset the entry if it is view |
|
187 | + // if it is visibility or move we have to grant the edit right |
|
188 | + foreach ($tool_rights as $key=>$value) |
|
189 | + { |
|
190 | + if ($value=='View') |
|
191 | + { |
|
192 | + unset($current_permissions[$tool][$key]); |
|
193 | + } |
|
194 | + if ($value=='Visibility' OR $value=='Move') |
|
195 | + { |
|
196 | + if (!in_array('Edit',$current_permissions[$tool])) |
|
197 | + { |
|
198 | + $current_permissions[$tool][]='Edit'; |
|
199 | + } |
|
200 | + unset($current_permissions[$tool][$key]); |
|
201 | + } |
|
202 | + //else |
|
203 | + //{ |
|
204 | + // $current_permissions[$tool][]=$value; |
|
205 | + //} |
|
206 | + } |
|
207 | + } |
|
208 | + return $current_permissions; |
|
209 | + } |
|
210 | + if (api_get_setting('permissions')=='full') |
|
211 | + { |
|
212 | + return $current_permissions; |
|
213 | + } |
|
214 | 214 | } |
215 | 215 | /** |
216 | 216 | * This function displays a checked or unchecked checkbox. The checkbox will be checked if the |
@@ -224,12 +224,12 @@ discard block |
||
224 | 224 | */ |
225 | 225 | function display_checkbox_matrix($permission_array, $tool, $permission, $inherited_permissions=array()) |
226 | 226 | { |
227 | - $checked=""; |
|
228 | - if (is_array($permission_array[$tool]) AND in_array($permission,$permission_array[$tool])) |
|
229 | - { |
|
230 | - $checked="checked"; |
|
231 | - } |
|
232 | - echo "\t\t\t<input type=\"checkbox\" name=\"permission*$tool*$permission\" $checked>\n"; |
|
227 | + $checked=""; |
|
228 | + if (is_array($permission_array[$tool]) AND in_array($permission,$permission_array[$tool])) |
|
229 | + { |
|
230 | + $checked="checked"; |
|
231 | + } |
|
232 | + echo "\t\t\t<input type=\"checkbox\" name=\"permission*$tool*$permission\" $checked>\n"; |
|
233 | 233 | |
234 | 234 | } |
235 | 235 | |
@@ -245,62 +245,62 @@ discard block |
||
245 | 245 | */ |
246 | 246 | function display_image_matrix($permission_array, $tool, $permission,$inherited_permissions=array(), $course_admin=false, $editable=true) |
247 | 247 | { |
248 | - if ($course_admin) { |
|
249 | - echo "\t\t\t<img src=\"../img/checkbox_on3.gif\" border=\"0\"/ title=\"".get_lang('PermissionGrantedByGroupOrRole')."\">"; |
|
250 | - } else { |
|
251 | - if (in_array($permission,$inherited_permissions[$tool])) { |
|
252 | - echo "\t\t\t<img src=\"../img/checkbox_on3.gif\" border=\"0\"/ title=\"".get_lang('PermissionGrantedByGroupOrRole')."\">"; |
|
253 | - } else { |
|
254 | - if (is_array($permission_array[$tool]) AND in_array($permission,$permission_array[$tool])) { |
|
255 | - if ($editable) { |
|
256 | - $url=api_get_self(); |
|
257 | - $urlparameters = ''; |
|
258 | - foreach($_GET as $key=>$value) { |
|
259 | - $parameter[$key]=$value; |
|
260 | - } |
|
261 | - $parameter['action']='revoke'; |
|
262 | - $parameter['permission']=$permission; |
|
263 | - $parameter['tool']=$tool; |
|
264 | - foreach ($parameter as $key=>$value) { |
|
265 | - $urlparameters.=$key.'='.$value.'&'; |
|
266 | - } |
|
267 | - $url=$url.'?'.$urlparameters; |
|
268 | - |
|
269 | - echo "\t\t\t <a href=\"".$url."\">"; |
|
270 | - } |
|
271 | - echo "<img src=\"../img/checkbox_on2.gif\" border=\"0\"/>"; |
|
272 | - if ($editable) { |
|
273 | - echo "</a>"; |
|
274 | - } |
|
275 | - } else { |
|
276 | - if ($editable) |
|
277 | - { |
|
278 | - $url=api_get_self(); |
|
279 | - $urlparameters = ''; |
|
280 | - foreach ($_GET as $key=>$value) |
|
281 | - { |
|
282 | - $parameter[$key]=$value; |
|
283 | - } |
|
284 | - $parameter['action']='grant'; |
|
285 | - $parameter['permission']=$permission; |
|
286 | - $parameter['tool']=$tool; |
|
287 | - foreach ($parameter as $key=>$value) |
|
288 | - { |
|
289 | - $urlparameters.=$key.'='.$value.'&'; |
|
290 | - } |
|
291 | - $url=$url.'?'.$urlparameters; |
|
292 | - |
|
293 | - //echo "\t\t\t <a href=\"".str_replace('&', '&', $_SERVER['REQUEST_URI'])."&action=grant&permission=$permission&tool=$tool\">"; |
|
294 | - echo "\t\t\t <a href=\"".$url."\">"; |
|
295 | - } |
|
296 | - echo "<img src=\"../img/wrong.gif\" border=\"0\"/>"; |
|
297 | - if ($editable) |
|
298 | - { |
|
299 | - echo "</a>"; |
|
300 | - } |
|
301 | - } |
|
302 | - } |
|
303 | - } |
|
248 | + if ($course_admin) { |
|
249 | + echo "\t\t\t<img src=\"../img/checkbox_on3.gif\" border=\"0\"/ title=\"".get_lang('PermissionGrantedByGroupOrRole')."\">"; |
|
250 | + } else { |
|
251 | + if (in_array($permission,$inherited_permissions[$tool])) { |
|
252 | + echo "\t\t\t<img src=\"../img/checkbox_on3.gif\" border=\"0\"/ title=\"".get_lang('PermissionGrantedByGroupOrRole')."\">"; |
|
253 | + } else { |
|
254 | + if (is_array($permission_array[$tool]) AND in_array($permission,$permission_array[$tool])) { |
|
255 | + if ($editable) { |
|
256 | + $url=api_get_self(); |
|
257 | + $urlparameters = ''; |
|
258 | + foreach($_GET as $key=>$value) { |
|
259 | + $parameter[$key]=$value; |
|
260 | + } |
|
261 | + $parameter['action']='revoke'; |
|
262 | + $parameter['permission']=$permission; |
|
263 | + $parameter['tool']=$tool; |
|
264 | + foreach ($parameter as $key=>$value) { |
|
265 | + $urlparameters.=$key.'='.$value.'&'; |
|
266 | + } |
|
267 | + $url=$url.'?'.$urlparameters; |
|
268 | + |
|
269 | + echo "\t\t\t <a href=\"".$url."\">"; |
|
270 | + } |
|
271 | + echo "<img src=\"../img/checkbox_on2.gif\" border=\"0\"/>"; |
|
272 | + if ($editable) { |
|
273 | + echo "</a>"; |
|
274 | + } |
|
275 | + } else { |
|
276 | + if ($editable) |
|
277 | + { |
|
278 | + $url=api_get_self(); |
|
279 | + $urlparameters = ''; |
|
280 | + foreach ($_GET as $key=>$value) |
|
281 | + { |
|
282 | + $parameter[$key]=$value; |
|
283 | + } |
|
284 | + $parameter['action']='grant'; |
|
285 | + $parameter['permission']=$permission; |
|
286 | + $parameter['tool']=$tool; |
|
287 | + foreach ($parameter as $key=>$value) |
|
288 | + { |
|
289 | + $urlparameters.=$key.'='.$value.'&'; |
|
290 | + } |
|
291 | + $url=$url.'?'.$urlparameters; |
|
292 | + |
|
293 | + //echo "\t\t\t <a href=\"".str_replace('&', '&', $_SERVER['REQUEST_URI'])."&action=grant&permission=$permission&tool=$tool\">"; |
|
294 | + echo "\t\t\t <a href=\"".$url."\">"; |
|
295 | + } |
|
296 | + echo "<img src=\"../img/wrong.gif\" border=\"0\"/>"; |
|
297 | + if ($editable) |
|
298 | + { |
|
299 | + echo "</a>"; |
|
300 | + } |
|
301 | + } |
|
302 | + } |
|
303 | + } |
|
304 | 304 | } |
305 | 305 | |
306 | 306 | |
@@ -318,72 +318,72 @@ discard block |
||
318 | 318 | function display_image_matrix_for_blogs($permission_array, $user_id, $tool, $permission,$inherited_permissions=array(), $course_admin=false, $editable=true) |
319 | 319 | { |
320 | 320 | |
321 | - if ($course_admin) |
|
322 | - { |
|
323 | - echo "\t\t\t<img src=\"../img/checkbox_on3.gif\" border=\"0\"/ title=\"".get_lang('PermissionGrantedByGroupOrRole')."\">"; |
|
324 | - } |
|
325 | - else |
|
326 | - { |
|
327 | - if (!empty($inherited_permissions) and in_array($permission,$inherited_permissions[$tool])) |
|
328 | - { |
|
329 | - echo "\t\t\t<img src=\"../img/checkbox_on3.gif\" border=\"0\"/ title=\"".get_lang('PermissionGrantedByGroupOrRole')."\">"; |
|
330 | - } |
|
331 | - else |
|
332 | - { |
|
333 | - if (is_array($permission_array[$tool]) AND in_array($permission,$permission_array[$tool])) |
|
334 | - { |
|
335 | - if ($editable) |
|
336 | - { |
|
337 | - $url = api_get_self(); |
|
338 | - $urlparameters = ''; |
|
339 | - foreach($_GET as $key => $value) |
|
340 | - { |
|
341 | - $parameter[$key] = $value; |
|
342 | - } |
|
343 | - $parameter['action']='manage_rights'; |
|
344 | - $parameter['do']='revoke'; |
|
345 | - $parameter['permission']=$permission; |
|
346 | - $parameter['tool']=$tool; |
|
347 | - $parameter['user_id']=$user_id; |
|
348 | - foreach ($parameter as $key=>$value) |
|
349 | - { |
|
350 | - $urlparameters .= $key . '=' . $value . '&'; |
|
351 | - } |
|
352 | - $url = $url . '?' . $urlparameters; |
|
353 | - |
|
354 | - echo "\t\t\t <a href=\"".$url."\">"; |
|
355 | - } |
|
356 | - echo "<img src=\"../img/checkbox_on2.gif\" border=\"0\"/ title=\"".get_lang('UserHasPermission')."\">"; |
|
357 | - if ($editable) { |
|
358 | - echo "</a>"; |
|
359 | - } |
|
360 | - } else { |
|
361 | - if ($editable) { |
|
362 | - $url = api_get_self(); |
|
363 | - $urlparameters = ''; |
|
364 | - foreach ($_GET as $key=>$value) { |
|
365 | - $parameter[$key]=$value; |
|
366 | - } |
|
367 | - $parameter['action']='manage_rights'; |
|
368 | - $parameter['do']='grant'; |
|
369 | - $parameter['permission']=$permission; |
|
370 | - $parameter['tool']=$tool; |
|
371 | - $parameter['user_id']=$user_id; |
|
372 | - foreach ($parameter as $key=>$value) { |
|
373 | - $urlparameters .= $key . '=' . $value . '&'; |
|
374 | - } |
|
375 | - $url=$url.'?'.$urlparameters; |
|
376 | - |
|
377 | - //echo "\t\t\t <a href=\"".str_replace('&', '&', $_SERVER['REQUEST_URI'])."&action=grant&permission=$permission&tool=$tool\">"; |
|
378 | - echo "\t\t\t <a href=\"".$url."\">"; |
|
379 | - } |
|
380 | - echo "<img src=\"../img/wrong.gif\" border=\"0\"/ title=\"".get_lang('UserHasPermissionNot')."\">"; |
|
381 | - if ($editable) { |
|
382 | - echo "</a>"; |
|
383 | - } |
|
384 | - } |
|
385 | - } |
|
386 | - } |
|
321 | + if ($course_admin) |
|
322 | + { |
|
323 | + echo "\t\t\t<img src=\"../img/checkbox_on3.gif\" border=\"0\"/ title=\"".get_lang('PermissionGrantedByGroupOrRole')."\">"; |
|
324 | + } |
|
325 | + else |
|
326 | + { |
|
327 | + if (!empty($inherited_permissions) and in_array($permission,$inherited_permissions[$tool])) |
|
328 | + { |
|
329 | + echo "\t\t\t<img src=\"../img/checkbox_on3.gif\" border=\"0\"/ title=\"".get_lang('PermissionGrantedByGroupOrRole')."\">"; |
|
330 | + } |
|
331 | + else |
|
332 | + { |
|
333 | + if (is_array($permission_array[$tool]) AND in_array($permission,$permission_array[$tool])) |
|
334 | + { |
|
335 | + if ($editable) |
|
336 | + { |
|
337 | + $url = api_get_self(); |
|
338 | + $urlparameters = ''; |
|
339 | + foreach($_GET as $key => $value) |
|
340 | + { |
|
341 | + $parameter[$key] = $value; |
|
342 | + } |
|
343 | + $parameter['action']='manage_rights'; |
|
344 | + $parameter['do']='revoke'; |
|
345 | + $parameter['permission']=$permission; |
|
346 | + $parameter['tool']=$tool; |
|
347 | + $parameter['user_id']=$user_id; |
|
348 | + foreach ($parameter as $key=>$value) |
|
349 | + { |
|
350 | + $urlparameters .= $key . '=' . $value . '&'; |
|
351 | + } |
|
352 | + $url = $url . '?' . $urlparameters; |
|
353 | + |
|
354 | + echo "\t\t\t <a href=\"".$url."\">"; |
|
355 | + } |
|
356 | + echo "<img src=\"../img/checkbox_on2.gif\" border=\"0\"/ title=\"".get_lang('UserHasPermission')."\">"; |
|
357 | + if ($editable) { |
|
358 | + echo "</a>"; |
|
359 | + } |
|
360 | + } else { |
|
361 | + if ($editable) { |
|
362 | + $url = api_get_self(); |
|
363 | + $urlparameters = ''; |
|
364 | + foreach ($_GET as $key=>$value) { |
|
365 | + $parameter[$key]=$value; |
|
366 | + } |
|
367 | + $parameter['action']='manage_rights'; |
|
368 | + $parameter['do']='grant'; |
|
369 | + $parameter['permission']=$permission; |
|
370 | + $parameter['tool']=$tool; |
|
371 | + $parameter['user_id']=$user_id; |
|
372 | + foreach ($parameter as $key=>$value) { |
|
373 | + $urlparameters .= $key . '=' . $value . '&'; |
|
374 | + } |
|
375 | + $url=$url.'?'.$urlparameters; |
|
376 | + |
|
377 | + //echo "\t\t\t <a href=\"".str_replace('&', '&', $_SERVER['REQUEST_URI'])."&action=grant&permission=$permission&tool=$tool\">"; |
|
378 | + echo "\t\t\t <a href=\"".$url."\">"; |
|
379 | + } |
|
380 | + echo "<img src=\"../img/wrong.gif\" border=\"0\"/ title=\"".get_lang('UserHasPermissionNot')."\">"; |
|
381 | + if ($editable) { |
|
382 | + echo "</a>"; |
|
383 | + } |
|
384 | + } |
|
385 | + } |
|
386 | + } |
|
387 | 387 | } |
388 | 388 | |
389 | 389 | |
@@ -394,41 +394,41 @@ discard block |
||
394 | 394 | */ |
395 | 395 | function display_role_list($current_course_roles, $current_platform_roles) |
396 | 396 | { |
397 | - global $setting_visualisation; |
|
397 | + global $setting_visualisation; |
|
398 | 398 | $course_id = api_get_course_int_id(); |
399 | 399 | |
400 | - $coures_roles_table=Database::get_course_table(TABLE_ROLE); |
|
401 | - |
|
402 | - // course roles |
|
403 | - $sql="SELECT * FROM $coures_roles_table WHERE c_id = $course_id "; |
|
404 | - $result=Database::query($sql); |
|
405 | - while ($row=Database::fetch_array($result)) |
|
406 | - { |
|
407 | - if (in_array($row['role_id'], $current_course_roles)) |
|
408 | - { |
|
409 | - $checked='checked'; |
|
410 | - $image='checkbox_on2.gif'; |
|
411 | - $action='revoke'; |
|
412 | - } |
|
413 | - else |
|
414 | - { |
|
415 | - $checked=''; |
|
416 | - $image='wrong.gif'; |
|
417 | - $action='grant'; |
|
418 | - } |
|
419 | - if ($setting_visualisation=='checkbox') |
|
420 | - { |
|
421 | - echo "<input type=\"checkbox\" name=\"role*course*".$row['role_id']."\" $checked>"; |
|
422 | - } |
|
423 | - if ($setting_visualisation=='image') |
|
424 | - { |
|
425 | - echo "<a href=\"".str_replace('&', '&', $_SERVER['REQUEST_URI'])."&action=$action&role=".$row['role_id']."&scope=course\"><img src=\"../img/".$image."\" border=\"0\"/></a>"; |
|
426 | - } |
|
427 | - |
|
428 | - |
|
429 | - echo $row['role_name']." <a href=\"../permissions/roles.php?role_id=".$row['role_id']."&scope=course\"><img src=\"../img/edit.gif\" /></a><br />\n"; |
|
430 | - echo $row['role_comment']."<br />\n"; |
|
431 | - } |
|
400 | + $coures_roles_table=Database::get_course_table(TABLE_ROLE); |
|
401 | + |
|
402 | + // course roles |
|
403 | + $sql="SELECT * FROM $coures_roles_table WHERE c_id = $course_id "; |
|
404 | + $result=Database::query($sql); |
|
405 | + while ($row=Database::fetch_array($result)) |
|
406 | + { |
|
407 | + if (in_array($row['role_id'], $current_course_roles)) |
|
408 | + { |
|
409 | + $checked='checked'; |
|
410 | + $image='checkbox_on2.gif'; |
|
411 | + $action='revoke'; |
|
412 | + } |
|
413 | + else |
|
414 | + { |
|
415 | + $checked=''; |
|
416 | + $image='wrong.gif'; |
|
417 | + $action='grant'; |
|
418 | + } |
|
419 | + if ($setting_visualisation=='checkbox') |
|
420 | + { |
|
421 | + echo "<input type=\"checkbox\" name=\"role*course*".$row['role_id']."\" $checked>"; |
|
422 | + } |
|
423 | + if ($setting_visualisation=='image') |
|
424 | + { |
|
425 | + echo "<a href=\"".str_replace('&', '&', $_SERVER['REQUEST_URI'])."&action=$action&role=".$row['role_id']."&scope=course\"><img src=\"../img/".$image."\" border=\"0\"/></a>"; |
|
426 | + } |
|
427 | + |
|
428 | + |
|
429 | + echo $row['role_name']." <a href=\"../permissions/roles.php?role_id=".$row['role_id']."&scope=course\"><img src=\"../img/edit.gif\" /></a><br />\n"; |
|
430 | + echo $row['role_comment']."<br />\n"; |
|
431 | + } |
|
432 | 432 | } |
433 | 433 | |
434 | 434 | /** |
@@ -442,24 +442,24 @@ discard block |
||
442 | 442 | */ |
443 | 443 | function get_roles($content,$id, $scope='course') { |
444 | 444 | $course_id = api_get_course_int_id(); |
445 | - if ($content=='user') { |
|
446 | - $table=Database::get_course_table(TABLE_ROLE_USER); |
|
447 | - $id_field = user_id; |
|
448 | - } |
|
449 | - if ($content=='group') { |
|
450 | - $table=Database::get_course_table(TABLE_ROLE_GROUP); |
|
451 | - $id_field = 'group_id'; |
|
452 | - } |
|
453 | - $table_role=Database::get_course_table(TABLE_ROLE); |
|
454 | - |
|
455 | - $current_roles=array(); |
|
456 | - //$sql="SELECT role.role_id FROM $table role_group_user, $table_role role WHERE role_group_user.$id_field = '$id' AND role_group_user.role_id=role.role_id AND role_group_user.scope='".$scope."'";$sql="SELECT role.role_id FROM $table role_group_user, $table_role role WHERE role_group_user.$id_field = '$id' AND role_group_user.role_id=role.role_id AND role_group_user.scope='".$scope."'"; |
|
457 | - $sql="SELECT role_id FROM $table WHERE c_id = $course_id AND $id_field = '$id' AND scope='".$scope."'"; |
|
458 | - $result=Database::query($sql); |
|
459 | - while ($row=Database::fetch_array($result)) { |
|
460 | - $current_roles[]=$row['role_id']; |
|
461 | - } |
|
462 | - return $current_roles; |
|
445 | + if ($content=='user') { |
|
446 | + $table=Database::get_course_table(TABLE_ROLE_USER); |
|
447 | + $id_field = user_id; |
|
448 | + } |
|
449 | + if ($content=='group') { |
|
450 | + $table=Database::get_course_table(TABLE_ROLE_GROUP); |
|
451 | + $id_field = 'group_id'; |
|
452 | + } |
|
453 | + $table_role=Database::get_course_table(TABLE_ROLE); |
|
454 | + |
|
455 | + $current_roles=array(); |
|
456 | + //$sql="SELECT role.role_id FROM $table role_group_user, $table_role role WHERE role_group_user.$id_field = '$id' AND role_group_user.role_id=role.role_id AND role_group_user.scope='".$scope."'";$sql="SELECT role.role_id FROM $table role_group_user, $table_role role WHERE role_group_user.$id_field = '$id' AND role_group_user.role_id=role.role_id AND role_group_user.scope='".$scope."'"; |
|
457 | + $sql="SELECT role_id FROM $table WHERE c_id = $course_id AND $id_field = '$id' AND scope='".$scope."'"; |
|
458 | + $result=Database::query($sql); |
|
459 | + while ($row=Database::fetch_array($result)) { |
|
460 | + $current_roles[]=$row['role_id']; |
|
461 | + } |
|
462 | + return $current_roles; |
|
463 | 463 | } |
464 | 464 | |
465 | 465 | /** |
@@ -472,25 +472,25 @@ discard block |
||
472 | 472 | $course_id = api_get_course_int_id(); |
473 | 473 | $course_id_condition = " WHERE c_id = $course_id "; |
474 | 474 | |
475 | - if ($content=='course') |
|
476 | - { |
|
477 | - $table_role=Database::get_course_table(TABLE_ROLE); |
|
478 | - } |
|
479 | - if ($content=='platform') |
|
480 | - { |
|
481 | - $table_role=Database::get_main_table(TABLE_ROLE); |
|
482 | - $course_id_condition = ''; |
|
483 | - } |
|
484 | - |
|
485 | - $current_roles=array(); |
|
486 | - $sql="SELECT * FROM $table_role $course_id_condition "; |
|
487 | - $result=Database::query($sql); |
|
488 | - while ($row=Database::fetch_array($result)) |
|
489 | - { |
|
490 | - $roles[]=$row; |
|
491 | - } |
|
492 | - |
|
493 | - return $roles; |
|
475 | + if ($content=='course') |
|
476 | + { |
|
477 | + $table_role=Database::get_course_table(TABLE_ROLE); |
|
478 | + } |
|
479 | + if ($content=='platform') |
|
480 | + { |
|
481 | + $table_role=Database::get_main_table(TABLE_ROLE); |
|
482 | + $course_id_condition = ''; |
|
483 | + } |
|
484 | + |
|
485 | + $current_roles=array(); |
|
486 | + $sql="SELECT * FROM $table_role $course_id_condition "; |
|
487 | + $result=Database::query($sql); |
|
488 | + while ($row=Database::fetch_array($result)) |
|
489 | + { |
|
490 | + $roles[]=$row; |
|
491 | + } |
|
492 | + |
|
493 | + return $roles; |
|
494 | 494 | } |
495 | 495 | |
496 | 496 | |
@@ -506,34 +506,34 @@ discard block |
||
506 | 506 | */ |
507 | 507 | function get_roles_permissions($content,$id, $scope='course') { |
508 | 508 | $course_id = api_get_course_int_id(); |
509 | - if ($content == 'user') { |
|
510 | - $table=Database::get_course_table(TABLE_ROLE_USER); |
|
511 | - $id_field = 'user_id'; |
|
512 | - } |
|
513 | - |
|
514 | - if ($content == 'group') { |
|
515 | - $table = Database::get_course_table(TABLE_ROLE_GROUP); |
|
516 | - $id_field = 'group_id'; |
|
517 | - } |
|
518 | - |
|
519 | - // course roles or platform roles |
|
520 | - $scope = 'course'; |
|
521 | - if ($scope == 'course') { |
|
522 | - $table_role = Database::get_course_table(TABLE_ROLE); |
|
523 | - $table_role_permissions = Database::get_course_table(TABLE_ROLE_PERMISSION); |
|
509 | + if ($content == 'user') { |
|
510 | + $table=Database::get_course_table(TABLE_ROLE_USER); |
|
511 | + $id_field = 'user_id'; |
|
512 | + } |
|
513 | + |
|
514 | + if ($content == 'group') { |
|
515 | + $table = Database::get_course_table(TABLE_ROLE_GROUP); |
|
516 | + $id_field = 'group_id'; |
|
517 | + } |
|
518 | + |
|
519 | + // course roles or platform roles |
|
520 | + $scope = 'course'; |
|
521 | + if ($scope == 'course') { |
|
522 | + $table_role = Database::get_course_table(TABLE_ROLE); |
|
523 | + $table_role_permissions = Database::get_course_table(TABLE_ROLE_PERMISSION); |
|
524 | 524 | |
525 | 525 | $role_condition = " role.c_id = $course_id AND role_permissions.c_id = $course_id AND "; |
526 | - } |
|
526 | + } |
|
527 | 527 | |
528 | - if ($scope == 'platform') { |
|
529 | - $table_role = Database::get_main_table(TABLE_ROLE); |
|
530 | - $table_role_permissions = Database::get_main_table(TABLE_ROLE_PERMISSION); |
|
528 | + if ($scope == 'platform') { |
|
529 | + $table_role = Database::get_main_table(TABLE_ROLE); |
|
530 | + $table_role_permissions = Database::get_main_table(TABLE_ROLE_PERMISSION); |
|
531 | 531 | $role_condition = ''; |
532 | - } |
|
532 | + } |
|
533 | 533 | |
534 | - $current_roles = array(); |
|
534 | + $current_roles = array(); |
|
535 | 535 | |
536 | - $sql = " |
|
536 | + $sql = " |
|
537 | 537 | SELECT * |
538 | 538 | FROM |
539 | 539 | " . $table . " role_group_user, |
@@ -547,12 +547,12 @@ discard block |
||
547 | 547 | role_group_user.role_id = role.role_id AND |
548 | 548 | role.role_id = role_permissions.role_id"; |
549 | 549 | |
550 | - $result = Database::query($sql); |
|
550 | + $result = Database::query($sql); |
|
551 | 551 | $current_role_permissions = array(); |
552 | - while ($row=Database::fetch_array($result)) { |
|
553 | - $current_role_permissions[$row['tool']][]=$row['action']; |
|
552 | + while ($row=Database::fetch_array($result)) { |
|
553 | + $current_role_permissions[$row['tool']][]=$row['action']; |
|
554 | 554 | } |
555 | - return $current_role_permissions; |
|
555 | + return $current_role_permissions; |
|
556 | 556 | } |
557 | 557 | |
558 | 558 | /** |
@@ -566,34 +566,34 @@ discard block |
||
566 | 566 | |
567 | 567 | function assign_role($content, $action, $id, $role_id, $scope='course') { |
568 | 568 | $course_id = api_get_course_int_id(); |
569 | - // Which database are we using (depending on the $content parameter) |
|
570 | - if ($content=='user') { |
|
571 | - $table=Database::get_course_table(TABLE_ROLE_USER); |
|
572 | - $id_field = 'user_id'; |
|
573 | - } elseif($content=='group') { |
|
574 | - $table=Database::get_course_table(TABLE_ROLE_GROUP); |
|
575 | - $id_field = 'group_id'; |
|
576 | - } else { |
|
577 | - return get_lang('Error'); |
|
578 | - } |
|
579 | - |
|
580 | - // grating a right |
|
581 | - if ($action=='grant') { |
|
582 | - $sql="INSERT INTO $table (c_id, role_id, scope, $id_field) VALUES ($course_id, '".Database::escape_string($role_id)."','".Database::escape_string($scope)."','".Database::escape_string($id)."')"; |
|
583 | - $result=Database::query($sql); |
|
584 | - if ($result) { |
|
585 | - $result_message=get_lang('RoleGranted'); |
|
586 | - } |
|
587 | - } |
|
569 | + // Which database are we using (depending on the $content parameter) |
|
570 | + if ($content=='user') { |
|
571 | + $table=Database::get_course_table(TABLE_ROLE_USER); |
|
572 | + $id_field = 'user_id'; |
|
573 | + } elseif($content=='group') { |
|
574 | + $table=Database::get_course_table(TABLE_ROLE_GROUP); |
|
575 | + $id_field = 'group_id'; |
|
576 | + } else { |
|
577 | + return get_lang('Error'); |
|
578 | + } |
|
579 | + |
|
580 | + // grating a right |
|
581 | + if ($action=='grant') { |
|
582 | + $sql="INSERT INTO $table (c_id, role_id, scope, $id_field) VALUES ($course_id, '".Database::escape_string($role_id)."','".Database::escape_string($scope)."','".Database::escape_string($id)."')"; |
|
583 | + $result=Database::query($sql); |
|
584 | + if ($result) { |
|
585 | + $result_message=get_lang('RoleGranted'); |
|
586 | + } |
|
587 | + } |
|
588 | 588 | |
589 | - if ($action=='revoke') { |
|
590 | - $sql="DELETE FROM $table WHERE c_id = $course_id AND $id_field = '".Database::escape_string($id)."' AND role_id='".Database::escape_string($role_id)."'"; |
|
591 | - $result=Database::query($sql); |
|
592 | - if ($result) { |
|
593 | - $result_message=get_lang('RoleRevoked'); |
|
594 | - } |
|
595 | - } |
|
596 | - return $result_message; |
|
589 | + if ($action=='revoke') { |
|
590 | + $sql="DELETE FROM $table WHERE c_id = $course_id AND $id_field = '".Database::escape_string($id)."' AND role_id='".Database::escape_string($role_id)."'"; |
|
591 | + $result=Database::query($sql); |
|
592 | + if ($result) { |
|
593 | + $result_message=get_lang('RoleRevoked'); |
|
594 | + } |
|
595 | + } |
|
596 | + return $result_message; |
|
597 | 597 | } |
598 | 598 | |
599 | 599 | |
@@ -603,21 +603,21 @@ discard block |
||
603 | 603 | */ |
604 | 604 | function permission_array_merge($array1, $array2) |
605 | 605 | { |
606 | - foreach ($array2 as $tool=>$permissions) |
|
607 | - { |
|
608 | - foreach ($permissions as $permissionkey=>$permissionvalue) |
|
609 | - { |
|
610 | - $array1[$tool][]=$permissionvalue; |
|
611 | - } |
|
612 | - } |
|
613 | - return $array1; |
|
606 | + foreach ($array2 as $tool=>$permissions) |
|
607 | + { |
|
608 | + foreach ($permissions as $permissionkey=>$permissionvalue) |
|
609 | + { |
|
610 | + $array1[$tool][]=$permissionvalue; |
|
611 | + } |
|
612 | + } |
|
613 | + return $array1; |
|
614 | 614 | } |
615 | 615 | |
616 | 616 | |
617 | 617 | function my_print_r($array) |
618 | 618 | { |
619 | - echo '<pre>'; |
|
620 | - print_r($array); |
|
621 | - echo '</pre>'; |
|
619 | + echo '<pre>'; |
|
620 | + print_r($array); |
|
621 | + echo '</pre>'; |
|
622 | 622 | } |
623 | 623 | ?> |
@@ -26,34 +26,34 @@ discard block |
||
26 | 26 | $course_id = api_get_course_int_id(); |
27 | 27 | |
28 | 28 | // Which database are we using (depending on the $content parameter) |
29 | - if ($content=='user') |
|
29 | + if ($content == 'user') |
|
30 | 30 | { |
31 | - $table=Database::get_course_table(TABLE_PERMISSION_USER); |
|
31 | + $table = Database::get_course_table(TABLE_PERMISSION_USER); |
|
32 | 32 | $id_field = user_id; |
33 | 33 | } |
34 | - if ($content=='group') |
|
34 | + if ($content == 'group') |
|
35 | 35 | { |
36 | - $table=Database::get_course_table(TABLE_PERMISSION_GROUP); |
|
36 | + $table = Database::get_course_table(TABLE_PERMISSION_GROUP); |
|
37 | 37 | $id_field = group_id; |
38 | 38 | } |
39 | - if ($content=='role') |
|
39 | + if ($content == 'role') |
|
40 | 40 | { |
41 | - $table=Database::get_course_table(TABLE_ROLE_PERMISSION); |
|
41 | + $table = Database::get_course_table(TABLE_ROLE_PERMISSION); |
|
42 | 42 | $id_field = role_id; |
43 | 43 | } |
44 | 44 | |
45 | 45 | // We first delete all the existing permissions for that user/group/role |
46 | - $sql="DELETE FROM $table WHERE c_id = $course_id AND $id_field = '".Database::escape_string($id)."'"; |
|
47 | - $result=Database::query($sql); |
|
46 | + $sql = "DELETE FROM $table WHERE c_id = $course_id AND $id_field = '".Database::escape_string($id)."'"; |
|
47 | + $result = Database::query($sql); |
|
48 | 48 | |
49 | 49 | // looping through the post values to find the permission (containing the string permission* ) |
50 | 50 | foreach ($_POST as $key => $value) |
51 | 51 | { |
52 | - if (strstr($key,"permission*")) |
|
52 | + if (strstr($key, "permission*")) |
|
53 | 53 | { |
54 | - list($brol,$tool,$action)=explode("*",$key); |
|
55 | - $sql="INSERT INTO $table (c_id, $id_field,tool,action) VALUES ($course_id, '".Database::escape_string($id)."','".Database::escape_string($tool)."','".Database::escape_string($action)."')"; |
|
56 | - $result=Database::query($sql); |
|
54 | + list($brol, $tool, $action) = explode("*", $key); |
|
55 | + $sql = "INSERT INTO $table (c_id, $id_field,tool,action) VALUES ($course_id, '".Database::escape_string($id)."','".Database::escape_string($tool)."','".Database::escape_string($action)."')"; |
|
56 | + $result = Database::query($sql); |
|
57 | 57 | } |
58 | 58 | } |
59 | 59 | return get_lang('PermissionsStored'); |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | * @author Patrick Cool <[email protected]>, Ghent University |
70 | 70 | * @version 1.0 |
71 | 71 | */ |
72 | -function store_one_permission($content, $action, $id, $tool,$permission) { |
|
72 | +function store_one_permission($content, $action, $id, $tool, $permission) { |
|
73 | 73 | global $rights_full; |
74 | 74 | $course_id = api_get_course_int_id(); |
75 | 75 | // for some reason I don't know, he can't get to the $rights_full array, so commented the following lines out. |
@@ -82,35 +82,35 @@ discard block |
||
82 | 82 | |
83 | 83 | // Which database are we using (depending on the $content parameter) |
84 | 84 | |
85 | - if ($content=='user') { |
|
86 | - $table=Database::get_course_table(TABLE_PERMISSION_USER); |
|
85 | + if ($content == 'user') { |
|
86 | + $table = Database::get_course_table(TABLE_PERMISSION_USER); |
|
87 | 87 | $id_field = user_id; |
88 | 88 | } |
89 | - if ($content=='group') |
|
89 | + if ($content == 'group') |
|
90 | 90 | { |
91 | - $table=Database::get_course_table(TABLE_PERMISSION_GROUP); |
|
91 | + $table = Database::get_course_table(TABLE_PERMISSION_GROUP); |
|
92 | 92 | $id_field = group_id; |
93 | 93 | } |
94 | - if ($content=='role') |
|
94 | + if ($content == 'role') |
|
95 | 95 | { |
96 | - $table=Database::get_course_table(TABLE_ROLE_PERMISSION); |
|
96 | + $table = Database::get_course_table(TABLE_ROLE_PERMISSION); |
|
97 | 97 | $id_field = role_id; |
98 | 98 | } |
99 | 99 | |
100 | 100 | // grating a right |
101 | - if ($action=='grant') { |
|
102 | - $sql="INSERT INTO $table (c_id, $id_field,tool,action) VALUES ($course_id, '".Database::escape_string($id)."','".Database::escape_string($tool)."','".Database::escape_string($permission)."')"; |
|
103 | - $result=Database::query($sql); |
|
104 | - if($result) { |
|
105 | - $result_message=get_lang('PermissionGranted'); |
|
101 | + if ($action == 'grant') { |
|
102 | + $sql = "INSERT INTO $table (c_id, $id_field,tool,action) VALUES ($course_id, '".Database::escape_string($id)."','".Database::escape_string($tool)."','".Database::escape_string($permission)."')"; |
|
103 | + $result = Database::query($sql); |
|
104 | + if ($result) { |
|
105 | + $result_message = get_lang('PermissionGranted'); |
|
106 | 106 | } |
107 | 107 | } |
108 | - if ($action=='revoke') |
|
108 | + if ($action == 'revoke') |
|
109 | 109 | { |
110 | - $sql="DELETE FROM $table WHERE c_id = $course_id AND $id_field = '".Database::escape_string($id)."' AND tool='".Database::escape_string($tool)."' AND action='".Database::escape_string($permission)."'"; |
|
111 | - $result=Database::query($sql); |
|
112 | - if($result) { |
|
113 | - $result_message=get_lang('PermissionRevoked'); |
|
110 | + $sql = "DELETE FROM $table WHERE c_id = $course_id AND $id_field = '".Database::escape_string($id)."' AND tool='".Database::escape_string($tool)."' AND action='".Database::escape_string($permission)."'"; |
|
111 | + $result = Database::query($sql); |
|
112 | + if ($result) { |
|
113 | + $result_message = get_lang('PermissionRevoked'); |
|
114 | 114 | } |
115 | 115 | } |
116 | 116 | return $result_message; |
@@ -125,44 +125,44 @@ discard block |
||
125 | 125 | */ |
126 | 126 | function get_permissions($content, $id) { |
127 | 127 | $course_id = api_get_course_int_id(); |
128 | - $currentpermissions=array(); |
|
128 | + $currentpermissions = array(); |
|
129 | 129 | // Which database are we using (depending on the $content parameter) |
130 | 130 | $course_id_condition = " c_id = $course_id AND "; |
131 | 131 | if ($content == 'user') |
132 | 132 | { |
133 | - $table=Database::get_course_table(TABLE_PERMISSION_USER); |
|
133 | + $table = Database::get_course_table(TABLE_PERMISSION_USER); |
|
134 | 134 | $id_field = 'user_id'; |
135 | 135 | } |
136 | 136 | elseif ($content == 'group') |
137 | 137 | { |
138 | - $table=Database::get_course_table(TABLE_PERMISSION_GROUP); |
|
138 | + $table = Database::get_course_table(TABLE_PERMISSION_GROUP); |
|
139 | 139 | $id_field = 'group_id'; |
140 | 140 | } |
141 | 141 | elseif ($content == 'role') |
142 | 142 | { |
143 | - $table=Database::get_course_table(TABLE_ROLE_PERMISSION); |
|
143 | + $table = Database::get_course_table(TABLE_ROLE_PERMISSION); |
|
144 | 144 | $id_field = 'role_id'; |
145 | 145 | } |
146 | 146 | elseif ($content == 'platform_role') |
147 | 147 | { |
148 | - $table=Database::get_main_table(TABLE_ROLE_PERMISSION); |
|
148 | + $table = Database::get_main_table(TABLE_ROLE_PERMISSION); |
|
149 | 149 | $id_field = 'role_id'; |
150 | 150 | $course_id_condition = ''; |
151 | 151 | } |
152 | 152 | elseif ($content == 'task') |
153 | 153 | { |
154 | - $table=Database::get_course_table(TABLE_BLOGS_TASKS_PERMISSIONS); |
|
154 | + $table = Database::get_course_table(TABLE_BLOGS_TASKS_PERMISSIONS); |
|
155 | 155 | $id_field = 'task_id'; |
156 | 156 | } |
157 | 157 | |
158 | 158 | // finding all the permissions. We store this in a multidimensional array |
159 | 159 | // where the first dimension is the tool. |
160 | - $sql=" |
|
161 | - SELECT * FROM " . $table . " |
|
162 | - WHERE $course_id_condition " . $id_field . "='" . Database::escape_string($id) . "'"; |
|
160 | + $sql = " |
|
161 | + SELECT * FROM " . $table." |
|
162 | + WHERE $course_id_condition ".$id_field."='".Database::escape_string($id)."'"; |
|
163 | 163 | $result = Database::query($sql); |
164 | 164 | |
165 | - while($row = Database::fetch_array($result)) |
|
165 | + while ($row = Database::fetch_array($result)) |
|
166 | 166 | $currentpermissions[$row['tool']][] = $row['action']; |
167 | 167 | |
168 | 168 | return $currentpermissions; |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | */ |
180 | 180 | function limited_or_full($current_permissions) |
181 | 181 | { |
182 | - if (api_get_setting('permissions')=='limited') |
|
182 | + if (api_get_setting('permissions') == 'limited') |
|
183 | 183 | { |
184 | 184 | foreach ($current_permissions as $tool=>$tool_rights) |
185 | 185 | { |
@@ -187,15 +187,15 @@ discard block |
||
187 | 187 | // if it is visibility or move we have to grant the edit right |
188 | 188 | foreach ($tool_rights as $key=>$value) |
189 | 189 | { |
190 | - if ($value=='View') |
|
190 | + if ($value == 'View') |
|
191 | 191 | { |
192 | 192 | unset($current_permissions[$tool][$key]); |
193 | 193 | } |
194 | - if ($value=='Visibility' OR $value=='Move') |
|
194 | + if ($value == 'Visibility' OR $value == 'Move') |
|
195 | 195 | { |
196 | - if (!in_array('Edit',$current_permissions[$tool])) |
|
196 | + if (!in_array('Edit', $current_permissions[$tool])) |
|
197 | 197 | { |
198 | - $current_permissions[$tool][]='Edit'; |
|
198 | + $current_permissions[$tool][] = 'Edit'; |
|
199 | 199 | } |
200 | 200 | unset($current_permissions[$tool][$key]); |
201 | 201 | } |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | } |
208 | 208 | return $current_permissions; |
209 | 209 | } |
210 | - if (api_get_setting('permissions')=='full') |
|
210 | + if (api_get_setting('permissions') == 'full') |
|
211 | 211 | { |
212 | 212 | return $current_permissions; |
213 | 213 | } |
@@ -222,12 +222,12 @@ discard block |
||
222 | 222 | * @author Patrick Cool <[email protected]>, Ghent University |
223 | 223 | * @version 1.0 |
224 | 224 | */ |
225 | -function display_checkbox_matrix($permission_array, $tool, $permission, $inherited_permissions=array()) |
|
225 | +function display_checkbox_matrix($permission_array, $tool, $permission, $inherited_permissions = array()) |
|
226 | 226 | { |
227 | - $checked=""; |
|
228 | - if (is_array($permission_array[$tool]) AND in_array($permission,$permission_array[$tool])) |
|
227 | + $checked = ""; |
|
228 | + if (is_array($permission_array[$tool]) AND in_array($permission, $permission_array[$tool])) |
|
229 | 229 | { |
230 | - $checked="checked"; |
|
230 | + $checked = "checked"; |
|
231 | 231 | } |
232 | 232 | echo "\t\t\t<input type=\"checkbox\" name=\"permission*$tool*$permission\" $checked>\n"; |
233 | 233 | |
@@ -243,28 +243,28 @@ discard block |
||
243 | 243 | * @author Patrick Cool <[email protected]>, Ghent University |
244 | 244 | * @version 1.0 |
245 | 245 | */ |
246 | -function display_image_matrix($permission_array, $tool, $permission,$inherited_permissions=array(), $course_admin=false, $editable=true) |
|
246 | +function display_image_matrix($permission_array, $tool, $permission, $inherited_permissions = array(), $course_admin = false, $editable = true) |
|
247 | 247 | { |
248 | 248 | if ($course_admin) { |
249 | 249 | echo "\t\t\t<img src=\"../img/checkbox_on3.gif\" border=\"0\"/ title=\"".get_lang('PermissionGrantedByGroupOrRole')."\">"; |
250 | 250 | } else { |
251 | - if (in_array($permission,$inherited_permissions[$tool])) { |
|
251 | + if (in_array($permission, $inherited_permissions[$tool])) { |
|
252 | 252 | echo "\t\t\t<img src=\"../img/checkbox_on3.gif\" border=\"0\"/ title=\"".get_lang('PermissionGrantedByGroupOrRole')."\">"; |
253 | 253 | } else { |
254 | - if (is_array($permission_array[$tool]) AND in_array($permission,$permission_array[$tool])) { |
|
254 | + if (is_array($permission_array[$tool]) AND in_array($permission, $permission_array[$tool])) { |
|
255 | 255 | if ($editable) { |
256 | - $url=api_get_self(); |
|
256 | + $url = api_get_self(); |
|
257 | 257 | $urlparameters = ''; |
258 | - foreach($_GET as $key=>$value) { |
|
259 | - $parameter[$key]=$value; |
|
258 | + foreach ($_GET as $key=>$value) { |
|
259 | + $parameter[$key] = $value; |
|
260 | 260 | } |
261 | - $parameter['action']='revoke'; |
|
262 | - $parameter['permission']=$permission; |
|
263 | - $parameter['tool']=$tool; |
|
261 | + $parameter['action'] = 'revoke'; |
|
262 | + $parameter['permission'] = $permission; |
|
263 | + $parameter['tool'] = $tool; |
|
264 | 264 | foreach ($parameter as $key=>$value) { |
265 | - $urlparameters.=$key.'='.$value.'&'; |
|
265 | + $urlparameters .= $key.'='.$value.'&'; |
|
266 | 266 | } |
267 | - $url=$url.'?'.$urlparameters; |
|
267 | + $url = $url.'?'.$urlparameters; |
|
268 | 268 | |
269 | 269 | echo "\t\t\t <a href=\"".$url."\">"; |
270 | 270 | } |
@@ -275,20 +275,20 @@ discard block |
||
275 | 275 | } else { |
276 | 276 | if ($editable) |
277 | 277 | { |
278 | - $url=api_get_self(); |
|
278 | + $url = api_get_self(); |
|
279 | 279 | $urlparameters = ''; |
280 | 280 | foreach ($_GET as $key=>$value) |
281 | 281 | { |
282 | - $parameter[$key]=$value; |
|
282 | + $parameter[$key] = $value; |
|
283 | 283 | } |
284 | - $parameter['action']='grant'; |
|
285 | - $parameter['permission']=$permission; |
|
286 | - $parameter['tool']=$tool; |
|
284 | + $parameter['action'] = 'grant'; |
|
285 | + $parameter['permission'] = $permission; |
|
286 | + $parameter['tool'] = $tool; |
|
287 | 287 | foreach ($parameter as $key=>$value) |
288 | 288 | { |
289 | - $urlparameters.=$key.'='.$value.'&'; |
|
289 | + $urlparameters .= $key.'='.$value.'&'; |
|
290 | 290 | } |
291 | - $url=$url.'?'.$urlparameters; |
|
291 | + $url = $url.'?'.$urlparameters; |
|
292 | 292 | |
293 | 293 | //echo "\t\t\t <a href=\"".str_replace('&', '&', $_SERVER['REQUEST_URI'])."&action=grant&permission=$permission&tool=$tool\">"; |
294 | 294 | echo "\t\t\t <a href=\"".$url."\">"; |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | * @author Patrick Cool <[email protected]>, Ghent University |
316 | 316 | * @version 1.0 |
317 | 317 | */ |
318 | -function display_image_matrix_for_blogs($permission_array, $user_id, $tool, $permission,$inherited_permissions=array(), $course_admin=false, $editable=true) |
|
318 | +function display_image_matrix_for_blogs($permission_array, $user_id, $tool, $permission, $inherited_permissions = array(), $course_admin = false, $editable = true) |
|
319 | 319 | { |
320 | 320 | |
321 | 321 | if ($course_admin) |
@@ -324,32 +324,32 @@ discard block |
||
324 | 324 | } |
325 | 325 | else |
326 | 326 | { |
327 | - if (!empty($inherited_permissions) and in_array($permission,$inherited_permissions[$tool])) |
|
327 | + if (!empty($inherited_permissions) and in_array($permission, $inherited_permissions[$tool])) |
|
328 | 328 | { |
329 | 329 | echo "\t\t\t<img src=\"../img/checkbox_on3.gif\" border=\"0\"/ title=\"".get_lang('PermissionGrantedByGroupOrRole')."\">"; |
330 | 330 | } |
331 | 331 | else |
332 | 332 | { |
333 | - if (is_array($permission_array[$tool]) AND in_array($permission,$permission_array[$tool])) |
|
333 | + if (is_array($permission_array[$tool]) AND in_array($permission, $permission_array[$tool])) |
|
334 | 334 | { |
335 | 335 | if ($editable) |
336 | 336 | { |
337 | 337 | $url = api_get_self(); |
338 | 338 | $urlparameters = ''; |
339 | - foreach($_GET as $key => $value) |
|
339 | + foreach ($_GET as $key => $value) |
|
340 | 340 | { |
341 | 341 | $parameter[$key] = $value; |
342 | 342 | } |
343 | - $parameter['action']='manage_rights'; |
|
344 | - $parameter['do']='revoke'; |
|
345 | - $parameter['permission']=$permission; |
|
346 | - $parameter['tool']=$tool; |
|
347 | - $parameter['user_id']=$user_id; |
|
343 | + $parameter['action'] = 'manage_rights'; |
|
344 | + $parameter['do'] = 'revoke'; |
|
345 | + $parameter['permission'] = $permission; |
|
346 | + $parameter['tool'] = $tool; |
|
347 | + $parameter['user_id'] = $user_id; |
|
348 | 348 | foreach ($parameter as $key=>$value) |
349 | 349 | { |
350 | - $urlparameters .= $key . '=' . $value . '&'; |
|
350 | + $urlparameters .= $key.'='.$value.'&'; |
|
351 | 351 | } |
352 | - $url = $url . '?' . $urlparameters; |
|
352 | + $url = $url.'?'.$urlparameters; |
|
353 | 353 | |
354 | 354 | echo "\t\t\t <a href=\"".$url."\">"; |
355 | 355 | } |
@@ -362,17 +362,17 @@ discard block |
||
362 | 362 | $url = api_get_self(); |
363 | 363 | $urlparameters = ''; |
364 | 364 | foreach ($_GET as $key=>$value) { |
365 | - $parameter[$key]=$value; |
|
365 | + $parameter[$key] = $value; |
|
366 | 366 | } |
367 | - $parameter['action']='manage_rights'; |
|
368 | - $parameter['do']='grant'; |
|
369 | - $parameter['permission']=$permission; |
|
370 | - $parameter['tool']=$tool; |
|
371 | - $parameter['user_id']=$user_id; |
|
367 | + $parameter['action'] = 'manage_rights'; |
|
368 | + $parameter['do'] = 'grant'; |
|
369 | + $parameter['permission'] = $permission; |
|
370 | + $parameter['tool'] = $tool; |
|
371 | + $parameter['user_id'] = $user_id; |
|
372 | 372 | foreach ($parameter as $key=>$value) { |
373 | - $urlparameters .= $key . '=' . $value . '&'; |
|
373 | + $urlparameters .= $key.'='.$value.'&'; |
|
374 | 374 | } |
375 | - $url=$url.'?'.$urlparameters; |
|
375 | + $url = $url.'?'.$urlparameters; |
|
376 | 376 | |
377 | 377 | //echo "\t\t\t <a href=\"".str_replace('&', '&', $_SERVER['REQUEST_URI'])."&action=grant&permission=$permission&tool=$tool\">"; |
378 | 378 | echo "\t\t\t <a href=\"".$url."\">"; |
@@ -397,30 +397,30 @@ discard block |
||
397 | 397 | global $setting_visualisation; |
398 | 398 | $course_id = api_get_course_int_id(); |
399 | 399 | |
400 | - $coures_roles_table=Database::get_course_table(TABLE_ROLE); |
|
400 | + $coures_roles_table = Database::get_course_table(TABLE_ROLE); |
|
401 | 401 | |
402 | 402 | // course roles |
403 | - $sql="SELECT * FROM $coures_roles_table WHERE c_id = $course_id "; |
|
404 | - $result=Database::query($sql); |
|
405 | - while ($row=Database::fetch_array($result)) |
|
403 | + $sql = "SELECT * FROM $coures_roles_table WHERE c_id = $course_id "; |
|
404 | + $result = Database::query($sql); |
|
405 | + while ($row = Database::fetch_array($result)) |
|
406 | 406 | { |
407 | 407 | if (in_array($row['role_id'], $current_course_roles)) |
408 | 408 | { |
409 | - $checked='checked'; |
|
410 | - $image='checkbox_on2.gif'; |
|
411 | - $action='revoke'; |
|
409 | + $checked = 'checked'; |
|
410 | + $image = 'checkbox_on2.gif'; |
|
411 | + $action = 'revoke'; |
|
412 | 412 | } |
413 | 413 | else |
414 | 414 | { |
415 | - $checked=''; |
|
416 | - $image='wrong.gif'; |
|
417 | - $action='grant'; |
|
415 | + $checked = ''; |
|
416 | + $image = 'wrong.gif'; |
|
417 | + $action = 'grant'; |
|
418 | 418 | } |
419 | - if ($setting_visualisation=='checkbox') |
|
419 | + if ($setting_visualisation == 'checkbox') |
|
420 | 420 | { |
421 | 421 | echo "<input type=\"checkbox\" name=\"role*course*".$row['role_id']."\" $checked>"; |
422 | 422 | } |
423 | - if ($setting_visualisation=='image') |
|
423 | + if ($setting_visualisation == 'image') |
|
424 | 424 | { |
425 | 425 | echo "<a href=\"".str_replace('&', '&', $_SERVER['REQUEST_URI'])."&action=$action&role=".$row['role_id']."&scope=course\"><img src=\"../img/".$image."\" border=\"0\"/></a>"; |
426 | 426 | } |
@@ -440,24 +440,24 @@ discard block |
||
440 | 440 | * @author Patrick Cool <[email protected]>, Ghent University |
441 | 441 | * @version 1.0 |
442 | 442 | */ |
443 | -function get_roles($content,$id, $scope='course') { |
|
444 | - $course_id = api_get_course_int_id(); |
|
445 | - if ($content=='user') { |
|
446 | - $table=Database::get_course_table(TABLE_ROLE_USER); |
|
443 | +function get_roles($content, $id, $scope = 'course') { |
|
444 | + $course_id = api_get_course_int_id(); |
|
445 | + if ($content == 'user') { |
|
446 | + $table = Database::get_course_table(TABLE_ROLE_USER); |
|
447 | 447 | $id_field = user_id; |
448 | 448 | } |
449 | - if ($content=='group') { |
|
450 | - $table=Database::get_course_table(TABLE_ROLE_GROUP); |
|
449 | + if ($content == 'group') { |
|
450 | + $table = Database::get_course_table(TABLE_ROLE_GROUP); |
|
451 | 451 | $id_field = 'group_id'; |
452 | 452 | } |
453 | - $table_role=Database::get_course_table(TABLE_ROLE); |
|
453 | + $table_role = Database::get_course_table(TABLE_ROLE); |
|
454 | 454 | |
455 | - $current_roles=array(); |
|
455 | + $current_roles = array(); |
|
456 | 456 | //$sql="SELECT role.role_id FROM $table role_group_user, $table_role role WHERE role_group_user.$id_field = '$id' AND role_group_user.role_id=role.role_id AND role_group_user.scope='".$scope."'";$sql="SELECT role.role_id FROM $table role_group_user, $table_role role WHERE role_group_user.$id_field = '$id' AND role_group_user.role_id=role.role_id AND role_group_user.scope='".$scope."'"; |
457 | - $sql="SELECT role_id FROM $table WHERE c_id = $course_id AND $id_field = '$id' AND scope='".$scope."'"; |
|
458 | - $result=Database::query($sql); |
|
459 | - while ($row=Database::fetch_array($result)) { |
|
460 | - $current_roles[]=$row['role_id']; |
|
457 | + $sql = "SELECT role_id FROM $table WHERE c_id = $course_id AND $id_field = '$id' AND scope='".$scope."'"; |
|
458 | + $result = Database::query($sql); |
|
459 | + while ($row = Database::fetch_array($result)) { |
|
460 | + $current_roles[] = $row['role_id']; |
|
461 | 461 | } |
462 | 462 | return $current_roles; |
463 | 463 | } |
@@ -468,26 +468,26 @@ discard block |
||
468 | 468 | * @author Patrick Cool <[email protected]>, Ghent University |
469 | 469 | * @version 1.0 |
470 | 470 | */ |
471 | -function get_all_roles($content='course') { |
|
471 | +function get_all_roles($content = 'course') { |
|
472 | 472 | $course_id = api_get_course_int_id(); |
473 | 473 | $course_id_condition = " WHERE c_id = $course_id "; |
474 | 474 | |
475 | - if ($content=='course') |
|
475 | + if ($content == 'course') |
|
476 | 476 | { |
477 | - $table_role=Database::get_course_table(TABLE_ROLE); |
|
477 | + $table_role = Database::get_course_table(TABLE_ROLE); |
|
478 | 478 | } |
479 | - if ($content=='platform') |
|
479 | + if ($content == 'platform') |
|
480 | 480 | { |
481 | - $table_role=Database::get_main_table(TABLE_ROLE); |
|
481 | + $table_role = Database::get_main_table(TABLE_ROLE); |
|
482 | 482 | $course_id_condition = ''; |
483 | 483 | } |
484 | 484 | |
485 | - $current_roles=array(); |
|
486 | - $sql="SELECT * FROM $table_role $course_id_condition "; |
|
487 | - $result=Database::query($sql); |
|
488 | - while ($row=Database::fetch_array($result)) |
|
485 | + $current_roles = array(); |
|
486 | + $sql = "SELECT * FROM $table_role $course_id_condition "; |
|
487 | + $result = Database::query($sql); |
|
488 | + while ($row = Database::fetch_array($result)) |
|
489 | 489 | { |
490 | - $roles[]=$row; |
|
490 | + $roles[] = $row; |
|
491 | 491 | } |
492 | 492 | |
493 | 493 | return $roles; |
@@ -504,10 +504,10 @@ discard block |
||
504 | 504 | * @author Patrick Cool <[email protected]>, Ghent University |
505 | 505 | * @version 1.0 |
506 | 506 | */ |
507 | -function get_roles_permissions($content,$id, $scope='course') { |
|
507 | +function get_roles_permissions($content, $id, $scope = 'course') { |
|
508 | 508 | $course_id = api_get_course_int_id(); |
509 | 509 | if ($content == 'user') { |
510 | - $table=Database::get_course_table(TABLE_ROLE_USER); |
|
510 | + $table = Database::get_course_table(TABLE_ROLE_USER); |
|
511 | 511 | $id_field = 'user_id'; |
512 | 512 | } |
513 | 513 | |
@@ -536,21 +536,21 @@ discard block |
||
536 | 536 | $sql = " |
537 | 537 | SELECT * |
538 | 538 | FROM |
539 | - " . $table . " role_group_user, |
|
540 | - " . $table_role . " role, |
|
541 | - " . $table_role_permissions . " role_permissions |
|
539 | + " . $table." role_group_user, |
|
540 | + " . $table_role." role, |
|
541 | + " . $table_role_permissions." role_permissions |
|
542 | 542 | WHERE |
543 | 543 | role_group_user.c_id = $course_id AND |
544 | 544 | $role_condition |
545 | - role_group_user.scope = '" . $scope . "' AND |
|
546 | - role_group_user." . $id_field . " = '" . $id . "' AND |
|
545 | + role_group_user.scope = '".$scope."' AND |
|
546 | + role_group_user." . $id_field." = '".$id."' AND |
|
547 | 547 | role_group_user.role_id = role.role_id AND |
548 | 548 | role.role_id = role_permissions.role_id"; |
549 | 549 | |
550 | 550 | $result = Database::query($sql); |
551 | 551 | $current_role_permissions = array(); |
552 | - while ($row=Database::fetch_array($result)) { |
|
553 | - $current_role_permissions[$row['tool']][]=$row['action']; |
|
552 | + while ($row = Database::fetch_array($result)) { |
|
553 | + $current_role_permissions[$row['tool']][] = $row['action']; |
|
554 | 554 | } |
555 | 555 | return $current_role_permissions; |
556 | 556 | } |
@@ -564,33 +564,33 @@ discard block |
||
564 | 564 | * @author Patrick Cool <[email protected]>, Ghent University |
565 | 565 | */ |
566 | 566 | |
567 | -function assign_role($content, $action, $id, $role_id, $scope='course') { |
|
567 | +function assign_role($content, $action, $id, $role_id, $scope = 'course') { |
|
568 | 568 | $course_id = api_get_course_int_id(); |
569 | 569 | // Which database are we using (depending on the $content parameter) |
570 | - if ($content=='user') { |
|
571 | - $table=Database::get_course_table(TABLE_ROLE_USER); |
|
570 | + if ($content == 'user') { |
|
571 | + $table = Database::get_course_table(TABLE_ROLE_USER); |
|
572 | 572 | $id_field = 'user_id'; |
573 | - } elseif($content=='group') { |
|
574 | - $table=Database::get_course_table(TABLE_ROLE_GROUP); |
|
573 | + } elseif ($content == 'group') { |
|
574 | + $table = Database::get_course_table(TABLE_ROLE_GROUP); |
|
575 | 575 | $id_field = 'group_id'; |
576 | 576 | } else { |
577 | 577 | return get_lang('Error'); |
578 | 578 | } |
579 | 579 | |
580 | 580 | // grating a right |
581 | - if ($action=='grant') { |
|
582 | - $sql="INSERT INTO $table (c_id, role_id, scope, $id_field) VALUES ($course_id, '".Database::escape_string($role_id)."','".Database::escape_string($scope)."','".Database::escape_string($id)."')"; |
|
583 | - $result=Database::query($sql); |
|
581 | + if ($action == 'grant') { |
|
582 | + $sql = "INSERT INTO $table (c_id, role_id, scope, $id_field) VALUES ($course_id, '".Database::escape_string($role_id)."','".Database::escape_string($scope)."','".Database::escape_string($id)."')"; |
|
583 | + $result = Database::query($sql); |
|
584 | 584 | if ($result) { |
585 | - $result_message=get_lang('RoleGranted'); |
|
585 | + $result_message = get_lang('RoleGranted'); |
|
586 | 586 | } |
587 | 587 | } |
588 | 588 | |
589 | - if ($action=='revoke') { |
|
590 | - $sql="DELETE FROM $table WHERE c_id = $course_id AND $id_field = '".Database::escape_string($id)."' AND role_id='".Database::escape_string($role_id)."'"; |
|
591 | - $result=Database::query($sql); |
|
589 | + if ($action == 'revoke') { |
|
590 | + $sql = "DELETE FROM $table WHERE c_id = $course_id AND $id_field = '".Database::escape_string($id)."' AND role_id='".Database::escape_string($role_id)."'"; |
|
591 | + $result = Database::query($sql); |
|
592 | 592 | if ($result) { |
593 | - $result_message=get_lang('RoleRevoked'); |
|
593 | + $result_message = get_lang('RoleRevoked'); |
|
594 | 594 | } |
595 | 595 | } |
596 | 596 | return $result_message; |
@@ -607,7 +607,7 @@ discard block |
||
607 | 607 | { |
608 | 608 | foreach ($permissions as $permissionkey=>$permissionvalue) |
609 | 609 | { |
610 | - $array1[$tool][]=$permissionvalue; |
|
610 | + $array1[$tool][] = $permissionvalue; |
|
611 | 611 | } |
612 | 612 | } |
613 | 613 | return $array1; |
@@ -735,7 +735,6 @@ |
||
735 | 735 | * lock = the user can no longer use this account |
736 | 736 | * @author Patrick Cool <[email protected]>, Ghent University |
737 | 737 | * @param int $active the current state of the account |
738 | - * @param int $user_id The user id |
|
739 | 738 | * @param string $urlParams |
740 | 739 | * |
741 | 740 | * @return string Some HTML-code with the lock/unlock button |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | */ |
14 | 14 | $use_anonymous = true; |
15 | 15 | require_once '../inc/global.inc.php'; |
16 | -$current_course_tool = TOOL_USER; |
|
16 | +$current_course_tool = TOOL_USER; |
|
17 | 17 | $this_section = SECTION_COURSES; |
18 | 18 | |
19 | 19 | // notice for unauthorized people. |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | |
42 | 42 | //Can't auto unregister from a session |
43 | 43 | if (!empty($sessionId)) { |
44 | - $course_info['unsubscribe'] = 0; |
|
44 | + $course_info['unsubscribe'] = 0; |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | /* Unregistering a user section */ |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | '#', |
185 | 185 | get_lang('UserPicture'), |
186 | 186 | get_lang('OfficialCode'), |
187 | - get_lang('FirstName') . ', ' . get_lang('LastName'), |
|
187 | + get_lang('FirstName').', '.get_lang('LastName'), |
|
188 | 188 | get_lang('Email'), |
189 | 189 | get_lang('Phone') |
190 | 190 | ); |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | '#', |
194 | 194 | get_lang('UserPicture'), |
195 | 195 | get_lang('OfficialCode'), |
196 | - get_lang('LastName') . ', ' . get_lang('FirstName'), |
|
196 | + get_lang('LastName').', '.get_lang('FirstName'), |
|
197 | 197 | get_lang('Email'), |
198 | 198 | get_lang('Phone') |
199 | 199 | ); |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | if (api_is_multiple_url_enabled()) { |
219 | 219 | $sql .= ' , '.Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER).' au '; |
220 | 220 | } |
221 | - $sql .=" WHERE c_id = '$courseId' AND session_course_user.user_id = user.user_id "; |
|
221 | + $sql .= " WHERE c_id = '$courseId' AND session_course_user.user_id = user.user_id "; |
|
222 | 222 | $sql .= ' AND session_id = '.$sessionId; |
223 | 223 | |
224 | 224 | if (api_is_multiple_url_enabled()) { |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | true |
253 | 253 | ); |
254 | 254 | if (!empty($extra_fields)) { |
255 | - foreach($extra_fields as $key => $extra_value) { |
|
255 | + foreach ($extra_fields as $key => $extra_value) { |
|
256 | 256 | $user[$key] = $extra_value; |
257 | 257 | } |
258 | 258 | } |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | $counter, |
267 | 267 | $user_image, |
268 | 268 | $user['official_code'], |
269 | - $user['firstname'] . ', ' . $user['lastname'], |
|
269 | + $user['firstname'].', '.$user['lastname'], |
|
270 | 270 | $user['email'], |
271 | 271 | $user['phone'] |
272 | 272 | ); |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | $counter, |
276 | 276 | $user_image, |
277 | 277 | $user['official_code'], |
278 | - $user['lastname'] . ', ' . $user['firstname'], |
|
278 | + $user['lastname'].', '.$user['firstname'], |
|
279 | 279 | $user['email'], |
280 | 280 | $user['phone'] |
281 | 281 | ); |
@@ -354,7 +354,7 @@ discard block |
||
354 | 354 | $counter, |
355 | 355 | $user_image, |
356 | 356 | $user['official_code'], |
357 | - $user['firstname'] . ', ' . $user['lastname'], |
|
357 | + $user['firstname'].', '.$user['lastname'], |
|
358 | 358 | $user['email'], |
359 | 359 | $user['phone'] |
360 | 360 | ); |
@@ -363,7 +363,7 @@ discard block |
||
363 | 363 | $counter, |
364 | 364 | $user_image, |
365 | 365 | $user['official_code'], |
366 | - $user['lastname'] . ', ' . $user['firstname'], |
|
366 | + $user['lastname'].', '.$user['firstname'], |
|
367 | 367 | $user['email'], |
368 | 368 | $user['phone'] |
369 | 369 | ); |
@@ -700,7 +700,7 @@ discard block |
||
700 | 700 | $userInfo = api_get_user_info($user_id); |
701 | 701 | $userPicture = $userInfo['avatar']; |
702 | 702 | |
703 | - $photo= '<img src="'.$userPicture.'" alt="'.$userInfo['complete_name'].'" width="22" height="22" title="'.$userInfo['complete_name'].'" />'; |
|
703 | + $photo = '<img src="'.$userPicture.'" alt="'.$userInfo['complete_name'].'" width="22" height="22" title="'.$userInfo['complete_name'].'" />'; |
|
704 | 704 | |
705 | 705 | $temp[] = $user_id; |
706 | 706 | $temp[] = $photo; |
@@ -821,7 +821,7 @@ discard block |
||
821 | 821 | if (api_get_setting('allow_user_course_subscription_by_course_admin') == 'true' or api_is_platform_admin()) { |
822 | 822 | // unregister |
823 | 823 | if ($user_id != $current_user_id || api_is_platform_admin()) { |
824 | - $result .= '<a class="btn btn-small btn-danger" href="'.api_get_self().'?'.api_get_cidreq().'&type='.$type.'&unregister=yes&user_id='.$user_id.'" title="'.get_lang('Unreg').' " onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang('ConfirmYourChoice'),ENT_QUOTES,$charset)).'\')) return false;">'. |
|
824 | + $result .= '<a class="btn btn-small btn-danger" href="'.api_get_self().'?'.api_get_cidreq().'&type='.$type.'&unregister=yes&user_id='.$user_id.'" title="'.get_lang('Unreg').' " onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES, $charset)).'\')) return false;">'. |
|
825 | 825 | get_lang('Unreg').'</a> '; |
826 | 826 | } else { |
827 | 827 | //$result .= Display::return_icon('unsubscribe_course_na.png', get_lang('Unreg'),'',ICON_SIZE_SMALL).'</a> '; |
@@ -831,7 +831,7 @@ discard block |
||
831 | 831 | // Show buttons for unsubscribe |
832 | 832 | if ($course_info['unsubscribe'] == 1) { |
833 | 833 | if ($user_id == $current_user_id) { |
834 | - $result .= '<a class="btn btn-small btn-danger" href="'.api_get_self().'?'.api_get_cidreq().'&type='.$type.'&unregister=yes&user_id='.$user_id.'" title="'.get_lang('Unreg').' " onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang('ConfirmYourChoice'),ENT_QUOTES,$charset)).'\')) return false;">'. |
|
834 | + $result .= '<a class="btn btn-small btn-danger" href="'.api_get_self().'?'.api_get_cidreq().'&type='.$type.'&unregister=yes&user_id='.$user_id.'" title="'.get_lang('Unreg').' " onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES, $charset)).'\')) return false;">'. |
|
835 | 835 | get_lang('Unreg').'</a> '; |
836 | 836 | } |
837 | 837 | } |
@@ -907,7 +907,7 @@ discard block |
||
907 | 907 | |
908 | 908 | // Actions column |
909 | 909 | $table->set_header($header_nr++, get_lang('Action'), false); |
910 | - $table->set_column_filter($header_nr-1, 'modify_filter'); |
|
910 | + $table->set_column_filter($header_nr - 1, 'modify_filter'); |
|
911 | 911 | |
912 | 912 | if (api_get_setting('allow_user_course_subscription_by_course_admin') == 'true') { |
913 | 913 | $table->set_form_actions(array('unsubscribe' => get_lang('Unreg')), 'user'); |
@@ -915,7 +915,7 @@ discard block |
||
915 | 915 | } else { |
916 | 916 | if ($course_info['unsubscribe'] == 1) { |
917 | 917 | $table->set_header($header_nr++, get_lang('Action'), false); |
918 | - $table->set_column_filter($header_nr-1, 'modify_filter'); |
|
918 | + $table->set_column_filter($header_nr - 1, 'modify_filter'); |
|
919 | 919 | } |
920 | 920 | } |
921 | 921 | |
@@ -971,19 +971,19 @@ discard block |
||
971 | 971 | echo '<div class="col-md-6">'; |
972 | 972 | echo $icon; |
973 | 973 | $actions .= '<a href="user.php?'.api_get_cidreq().'&action=export&format=csv&type='.$type.'">'. |
974 | - Display::return_icon('export_csv.png', get_lang('ExportAsCSV'),'',ICON_SIZE_MEDIUM).'</a> '; |
|
974 | + Display::return_icon('export_csv.png', get_lang('ExportAsCSV'), '', ICON_SIZE_MEDIUM).'</a> '; |
|
975 | 975 | $actions .= '<a href="user.php?'.api_get_cidreq().'&action=export&format=xls&type='.$type.'">'. |
976 | - Display::return_icon('export_excel.png', get_lang('ExportAsXLS'),'',ICON_SIZE_MEDIUM).'</a> '; |
|
976 | + Display::return_icon('export_excel.png', get_lang('ExportAsXLS'), '', ICON_SIZE_MEDIUM).'</a> '; |
|
977 | 977 | |
978 | 978 | if (api_get_setting('allow_user_course_subscription_by_course_admin') == 'true' || |
979 | 979 | api_is_platform_admin() |
980 | 980 | ) { |
981 | 981 | $actions .= '<a href="user_import.php?'.api_get_cidreq().'&action=import">'. |
982 | - Display::return_icon('import_csv.png', get_lang('ImportUsersToACourse'),'',ICON_SIZE_MEDIUM).'</a> '; |
|
982 | + Display::return_icon('import_csv.png', get_lang('ImportUsersToACourse'), '', ICON_SIZE_MEDIUM).'</a> '; |
|
983 | 983 | } |
984 | 984 | |
985 | 985 | $actions .= '<a href="user.php?'.api_get_cidreq().'&action=export&format=pdf&type='.$type.'">'. |
986 | - Display::return_icon('pdf.png', get_lang('ExportToPDF'),'',ICON_SIZE_MEDIUM).'</a> '; |
|
986 | + Display::return_icon('pdf.png', get_lang('ExportToPDF'), '', ICON_SIZE_MEDIUM).'</a> '; |
|
987 | 987 | echo $actions; |
988 | 988 | |
989 | 989 | echo '</div>'; |
@@ -84,7 +84,7 @@ |
||
84 | 84 | } |
85 | 85 | |
86 | 86 | /** |
87 | - * @param $directoryPath |
|
87 | + * @param string $directoryPath |
|
88 | 88 | * @return bool |
89 | 89 | */ |
90 | 90 | function deleteDirectory($directoryPath) |
@@ -19,24 +19,24 @@ discard block |
||
19 | 19 | { |
20 | 20 | $fileData = $pptData['file_data']; |
21 | 21 | $dataInfo = pathinfo($pptData['file_name']); |
22 | - $fileName = basename($pptData['file_name'], '.' . $dataInfo['extension']); |
|
22 | + $fileName = basename($pptData['file_name'], '.'.$dataInfo['extension']); |
|
23 | 23 | $fullFileName = $pptData['file_name']; |
24 | 24 | |
25 | 25 | $tempArchivePath = api_get_path(SYS_ARCHIVE_PATH); |
26 | - $tempPath = $tempArchivePath . 'wsConvert/' . $fileName . '/'; |
|
27 | - $tempPathNewFiles = $tempArchivePath . 'wsConvert/' . $fileName . '-n/'; |
|
26 | + $tempPath = $tempArchivePath.'wsConvert/'.$fileName.'/'; |
|
27 | + $tempPathNewFiles = $tempArchivePath.'wsConvert/'.$fileName.'-n/'; |
|
28 | 28 | |
29 | 29 | $perms = api_get_permissions_for_new_directories(); |
30 | 30 | pptConverterDirectoriesCreate($tempPath, $tempPathNewFiles, $fileName, $perms); |
31 | 31 | |
32 | 32 | $file = base64_decode($fileData); |
33 | - file_put_contents($tempPath . $fullFileName, $file); |
|
33 | + file_put_contents($tempPath.$fullFileName, $file); |
|
34 | 34 | |
35 | 35 | $cmd = pptConverterGetCommandBaseParams(); |
36 | - $cmd .= ' -w 720 -h 540 -d oogie "' . $tempPath . $fullFileName.'" "' . $tempPathNewFiles . $fileName . '.html"'; |
|
36 | + $cmd .= ' -w 720 -h 540 -d oogie "'.$tempPath.$fullFileName.'" "'.$tempPathNewFiles.$fileName.'.html"'; |
|
37 | 37 | |
38 | 38 | $perms = api_get_permissions_for_new_files(); |
39 | - chmod($tempPathNewFiles . $fileName, $perms, true); |
|
39 | + chmod($tempPathNewFiles.$fileName, $perms, true); |
|
40 | 40 | |
41 | 41 | $files = array(); |
42 | 42 | $return = 0; |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | if (is_array($files) && !empty($files)) { |
48 | 48 | foreach ($files as $file) { |
49 | 49 | $imageData = explode('||', $file); |
50 | - $images[$imageData[1]] = base64_encode(file_get_contents($tempPathNewFiles . $fileName . '/' . $imageData[1])); |
|
50 | + $images[$imageData[1]] = base64_encode(file_get_contents($tempPathNewFiles.$fileName.'/'.$imageData[1])); |
|
51 | 51 | } |
52 | 52 | } |
53 | 53 | $data = array( |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | */ |
74 | 74 | function deleteDirectory($directoryPath) |
75 | 75 | { |
76 | - $files = array_diff(scandir($directoryPath), array('.','..')); |
|
76 | + $files = array_diff(scandir($directoryPath), array('.', '..')); |
|
77 | 77 | foreach ($files as $file) { |
78 | 78 | if (is_dir("$directoryPath/$file")) { |
79 | 79 | deleteDirectory("$directoryPath/$file"); |
@@ -101,8 +101,8 @@ discard block |
||
101 | 101 | if (!is_dir($tempPathNewFiles)) { |
102 | 102 | mkdir($tempPathNewFiles, $perms, true); |
103 | 103 | } |
104 | - if (!is_dir($tempPathNewFiles . $fileName)) { |
|
105 | - mkdir($tempPathNewFiles . $fileName, $perms, true); |
|
104 | + if (!is_dir($tempPathNewFiles.$fileName)) { |
|
105 | + mkdir($tempPathNewFiles.$fileName, $perms, true); |
|
106 | 106 | } |
107 | 107 | } |
108 | 108 | |
@@ -113,16 +113,16 @@ discard block |
||
113 | 113 | function pptConverterGetCommandBaseParams() |
114 | 114 | { |
115 | 115 | if (IS_WINDOWS_OS) { // IS_WINDOWS_OS has been defined in main_api.lib.php |
116 | - $converterPath = str_replace('/', '\\', api_get_path(SYS_PATH) . 'main/inc/lib/ppt2png'); |
|
117 | - $classPath = $converterPath . ';' . $converterPath . '/jodconverter-2.2.2.jar;' . $converterPath . '/jodconverter-cli-2.2.2.jar'; |
|
118 | - $cmd = 'java -Dfile.encoding=UTF-8 -cp "' . $classPath . '" DokeosConverter'; |
|
116 | + $converterPath = str_replace('/', '\\', api_get_path(SYS_PATH).'main/inc/lib/ppt2png'); |
|
117 | + $classPath = $converterPath.';'.$converterPath.'/jodconverter-2.2.2.jar;'.$converterPath.'/jodconverter-cli-2.2.2.jar'; |
|
118 | + $cmd = 'java -Dfile.encoding=UTF-8 -cp "'.$classPath.'" DokeosConverter'; |
|
119 | 119 | } else { |
120 | - $converterPath = api_get_path(SYS_PATH) . 'main/inc/lib/ppt2png'; |
|
120 | + $converterPath = api_get_path(SYS_PATH).'main/inc/lib/ppt2png'; |
|
121 | 121 | $classPath = ' -Dfile.encoding=UTF-8 -cp .:jodconverter-2.2.2.jar:jodconverter-cli-2.2.2.jar'; |
122 | - $cmd = 'cd ' . $converterPath . ' && java ' . $classPath . ' DokeosConverter'; |
|
122 | + $cmd = 'cd '.$converterPath.' && java '.$classPath.' DokeosConverter'; |
|
123 | 123 | } |
124 | 124 | |
125 | - $cmd .= ' -p ' . api_get_setting('service_ppt2lp', 'port'); |
|
125 | + $cmd .= ' -p '.api_get_setting('service_ppt2lp', 'port'); |
|
126 | 126 | return $cmd; |
127 | 127 | } |
128 | 128 | |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | $webCodePath = api_get_path(WEB_CODE_PATH); |
132 | 132 | $options = array( |
133 | 133 | 'uri' => $webPath, |
134 | - 'location' => $webCodePath . 'webservices/additional_webservices.php' |
|
134 | + 'location' => $webCodePath.'webservices/additional_webservices.php' |
|
135 | 135 | ); |
136 | 136 | |
137 | 137 | $soapServer = new SoapServer(NULL, $options); |
@@ -32,6 +32,8 @@ discard block |
||
32 | 32 | * |
33 | 33 | * @param int Error code |
34 | 34 | * @param string Error message |
35 | + * @param integer $code |
|
36 | + * @param string $message |
|
35 | 37 | */ |
36 | 38 | public function __construct($code, $message) { |
37 | 39 | $this->code = $code; |
@@ -42,6 +44,7 @@ discard block |
||
42 | 44 | * Sets the error handler |
43 | 45 | * |
44 | 46 | * @param WSErrorHandler Error handler |
47 | + * @param WSCMSoapErrorHandler $handler |
|
45 | 48 | */ |
46 | 49 | public static function setErrorHandler($handler) { |
47 | 50 | if($handler instanceof WSErrorHandler) { |
@@ -76,6 +79,7 @@ discard block |
||
76 | 79 | * Handle method |
77 | 80 | * |
78 | 81 | * @param WSError Error |
82 | + * @return void |
|
79 | 83 | */ |
80 | 84 | public function handle($error); |
81 | 85 | } |
@@ -102,7 +106,7 @@ discard block |
||
102 | 106 | * Verifies the API key |
103 | 107 | * |
104 | 108 | * @param string Secret key |
105 | - * @return mixed WSError in case of failure, null in case of success |
|
109 | + * @return WSCMError|null WSError in case of failure, null in case of success |
|
106 | 110 | */ |
107 | 111 | protected function verifyKey($secret_key) { |
108 | 112 | $ip = trim($_SERVER['REMOTE_ADDR']); |
@@ -9,70 +9,70 @@ discard block |
||
9 | 9 | */ |
10 | 10 | class WSCMError |
11 | 11 | { |
12 | - /** |
|
13 | - * Error handler. This needs to be a class that implements the interface WSErrorHandler |
|
14 | - * |
|
15 | - * @var WSErrorHandler |
|
16 | - */ |
|
17 | - protected static $_handler; |
|
12 | + /** |
|
13 | + * Error handler. This needs to be a class that implements the interface WSErrorHandler |
|
14 | + * |
|
15 | + * @var WSErrorHandler |
|
16 | + */ |
|
17 | + protected static $_handler; |
|
18 | 18 | |
19 | - /** |
|
20 | - * Error code |
|
21 | - * |
|
22 | - * @var int |
|
23 | - */ |
|
24 | - public $code; |
|
19 | + /** |
|
20 | + * Error code |
|
21 | + * |
|
22 | + * @var int |
|
23 | + */ |
|
24 | + public $code; |
|
25 | 25 | |
26 | - /** |
|
27 | - * Error message |
|
28 | - * |
|
29 | - * @var string |
|
30 | - */ |
|
31 | - public $message; |
|
26 | + /** |
|
27 | + * Error message |
|
28 | + * |
|
29 | + * @var string |
|
30 | + */ |
|
31 | + public $message; |
|
32 | 32 | |
33 | - /** |
|
34 | - * Constructor |
|
35 | - * |
|
36 | - * @param int Error code |
|
37 | - * @param string Error message |
|
38 | - */ |
|
39 | - public function __construct($code, $message) |
|
33 | + /** |
|
34 | + * Constructor |
|
35 | + * |
|
36 | + * @param int Error code |
|
37 | + * @param string Error message |
|
38 | + */ |
|
39 | + public function __construct($code, $message) |
|
40 | 40 | { |
41 | - $this->code = $code; |
|
42 | - $this->message = $message; |
|
43 | - } |
|
41 | + $this->code = $code; |
|
42 | + $this->message = $message; |
|
43 | + } |
|
44 | 44 | |
45 | - /** |
|
46 | - * Sets the error handler |
|
47 | - * |
|
48 | - * @param WSErrorHandler Error handler |
|
49 | - */ |
|
50 | - public static function setErrorHandler($handler) |
|
45 | + /** |
|
46 | + * Sets the error handler |
|
47 | + * |
|
48 | + * @param WSErrorHandler Error handler |
|
49 | + */ |
|
50 | + public static function setErrorHandler($handler) |
|
51 | 51 | { |
52 | - if($handler instanceof WSErrorHandler) { |
|
53 | - self::$_handler = $handler; |
|
54 | - } |
|
55 | - } |
|
52 | + if($handler instanceof WSErrorHandler) { |
|
53 | + self::$_handler = $handler; |
|
54 | + } |
|
55 | + } |
|
56 | 56 | |
57 | - /** |
|
58 | - * Returns the error handler |
|
59 | - * |
|
60 | - * @return WSErrorHandler Error handler |
|
61 | - */ |
|
62 | - public static function getErrorHandler() |
|
57 | + /** |
|
58 | + * Returns the error handler |
|
59 | + * |
|
60 | + * @return WSErrorHandler Error handler |
|
61 | + */ |
|
62 | + public static function getErrorHandler() |
|
63 | 63 | { |
64 | - return self::$_handler; |
|
65 | - } |
|
64 | + return self::$_handler; |
|
65 | + } |
|
66 | 66 | |
67 | - /** |
|
68 | - * Transforms the error into an array |
|
69 | - * |
|
70 | - * @return array Associative array with code and message |
|
71 | - */ |
|
72 | - public function toArray() |
|
67 | + /** |
|
68 | + * Transforms the error into an array |
|
69 | + * |
|
70 | + * @return array Associative array with code and message |
|
71 | + */ |
|
72 | + public function toArray() |
|
73 | 73 | { |
74 | - return array('code' => $this->code, 'message' => $this->message); |
|
75 | - } |
|
74 | + return array('code' => $this->code, 'message' => $this->message); |
|
75 | + } |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | /** |
@@ -80,12 +80,12 @@ discard block |
||
80 | 80 | */ |
81 | 81 | interface WSCMErrorHandler |
82 | 82 | { |
83 | - /** |
|
84 | - * Handle method |
|
85 | - * |
|
86 | - * @param WSError Error |
|
87 | - */ |
|
88 | - public function handle($error); |
|
83 | + /** |
|
84 | + * Handle method |
|
85 | + * |
|
86 | + * @param WSError Error |
|
87 | + */ |
|
88 | + public function handle($error); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | /** |
@@ -93,58 +93,58 @@ discard block |
||
93 | 93 | */ |
94 | 94 | class WSCM |
95 | 95 | { |
96 | - /** |
|
97 | - * Chamilo configuration |
|
98 | - * |
|
99 | - * @var array |
|
100 | - */ |
|
101 | - protected $_configuration; |
|
96 | + /** |
|
97 | + * Chamilo configuration |
|
98 | + * |
|
99 | + * @var array |
|
100 | + */ |
|
101 | + protected $_configuration; |
|
102 | 102 | |
103 | - /** |
|
104 | - * Constructor |
|
105 | - */ |
|
106 | - public function __construct() |
|
103 | + /** |
|
104 | + * Constructor |
|
105 | + */ |
|
106 | + public function __construct() |
|
107 | 107 | { |
108 | - $this->_configuration = $GLOBALS['_configuration']; |
|
109 | - } |
|
108 | + $this->_configuration = $GLOBALS['_configuration']; |
|
109 | + } |
|
110 | 110 | |
111 | - /** |
|
112 | - * Verifies the API key |
|
113 | - * |
|
114 | - * @param string Secret key |
|
115 | - * @return mixed WSError in case of failure, null in case of success |
|
116 | - */ |
|
117 | - protected function verifyKey($secret_key) |
|
111 | + /** |
|
112 | + * Verifies the API key |
|
113 | + * |
|
114 | + * @param string Secret key |
|
115 | + * @return mixed WSError in case of failure, null in case of success |
|
116 | + */ |
|
117 | + protected function verifyKey($secret_key) |
|
118 | 118 | { |
119 | - $ip = trim($_SERVER['REMOTE_ADDR']); |
|
120 | - // if we are behind a reverse proxy, assume it will send the |
|
121 | - // HTTP_X_FORWARDED_FOR header and use this IP instead |
|
122 | - if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { |
|
123 | - list($ip1,$ip2) = split(',',$_SERVER['HTTP_X_FORWARDED_FOR']); |
|
124 | - $ip = trim($ip1); |
|
125 | - } |
|
126 | - $security_key = $ip.$this->_configuration['security_key']; |
|
119 | + $ip = trim($_SERVER['REMOTE_ADDR']); |
|
120 | + // if we are behind a reverse proxy, assume it will send the |
|
121 | + // HTTP_X_FORWARDED_FOR header and use this IP instead |
|
122 | + if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { |
|
123 | + list($ip1,$ip2) = split(',',$_SERVER['HTTP_X_FORWARDED_FOR']); |
|
124 | + $ip = trim($ip1); |
|
125 | + } |
|
126 | + $security_key = $ip.$this->_configuration['security_key']; |
|
127 | 127 | |
128 | - if(!api_is_valid_secret_key($secret_key, $security_key)) { |
|
129 | - return new WSCMError(1, "API key is invalid"); |
|
130 | - } else { |
|
131 | - return null; |
|
132 | - } |
|
133 | - } |
|
128 | + if(!api_is_valid_secret_key($secret_key, $security_key)) { |
|
129 | + return new WSCMError(1, "API key is invalid"); |
|
130 | + } else { |
|
131 | + return null; |
|
132 | + } |
|
133 | + } |
|
134 | 134 | |
135 | - /** |
|
136 | - * Verifies if the user is valid |
|
137 | - * |
|
138 | - * @param <String> $username of the user in chamilo |
|
139 | - * @param <String> $pass of the same user (in MD5 of SHA) |
|
140 | - * |
|
141 | - * return "valid" if username e password are correct! Else, return a message error |
|
142 | - */ |
|
135 | + /** |
|
136 | + * Verifies if the user is valid |
|
137 | + * |
|
138 | + * @param <String> $username of the user in chamilo |
|
139 | + * @param <String> $pass of the same user (in MD5 of SHA) |
|
140 | + * |
|
141 | + * return "valid" if username e password are correct! Else, return a message error |
|
142 | + */ |
|
143 | 143 | |
144 | - public function verifyUserPass($username, $pass) |
|
144 | + public function verifyUserPass($username, $pass) |
|
145 | 145 | { |
146 | - $login = $username; |
|
147 | - $password = $pass; |
|
146 | + $login = $username; |
|
147 | + $password = $pass; |
|
148 | 148 | |
149 | 149 | //lookup the user in the main database |
150 | 150 | $user_table = Database::get_main_table(TABLE_MAIN_USER); |
@@ -182,132 +182,132 @@ discard block |
||
182 | 182 | } |
183 | 183 | } |
184 | 184 | return get_lang('InvalidId'); |
185 | - } |
|
185 | + } |
|
186 | 186 | |
187 | - /** |
|
188 | - * Gets the real user id based on the user id field name and value. |
|
189 | - * Note that if the user id field name is "chamilo_user_id", it will use the user id |
|
190 | - * in the system database |
|
191 | - * |
|
192 | - * @param string User id field name |
|
193 | - * @param string User id value |
|
194 | - * @return mixed System user id if the user was found, WSError otherwise |
|
195 | - */ |
|
196 | - protected function getUserId($user_id_field_name, $user_id_value) |
|
187 | + /** |
|
188 | + * Gets the real user id based on the user id field name and value. |
|
189 | + * Note that if the user id field name is "chamilo_user_id", it will use the user id |
|
190 | + * in the system database |
|
191 | + * |
|
192 | + * @param string User id field name |
|
193 | + * @param string User id value |
|
194 | + * @return mixed System user id if the user was found, WSError otherwise |
|
195 | + */ |
|
196 | + protected function getUserId($user_id_field_name, $user_id_value) |
|
197 | 197 | { |
198 | - if($user_id_field_name == "chamilo_user_id") { |
|
199 | - if(UserManager::is_user_id_valid(intval($user_id_value))) { |
|
200 | - return intval($user_id_value); |
|
201 | - } else { |
|
202 | - return new WSCMError(100, "User not found"); |
|
203 | - } |
|
204 | - } else { |
|
205 | - $user_id = UserManager::get_user_id_from_original_id($user_id_value, $user_id_field_name); |
|
206 | - if($user_id == 0) { |
|
207 | - return new WSCMError(100, "User not found"); |
|
208 | - } else { |
|
209 | - return $user_id; |
|
210 | - } |
|
211 | - } |
|
212 | - } |
|
198 | + if($user_id_field_name == "chamilo_user_id") { |
|
199 | + if(UserManager::is_user_id_valid(intval($user_id_value))) { |
|
200 | + return intval($user_id_value); |
|
201 | + } else { |
|
202 | + return new WSCMError(100, "User not found"); |
|
203 | + } |
|
204 | + } else { |
|
205 | + $user_id = UserManager::get_user_id_from_original_id($user_id_value, $user_id_field_name); |
|
206 | + if($user_id == 0) { |
|
207 | + return new WSCMError(100, "User not found"); |
|
208 | + } else { |
|
209 | + return $user_id; |
|
210 | + } |
|
211 | + } |
|
212 | + } |
|
213 | 213 | |
214 | - /** |
|
215 | - * Gets the real course id based on the course id field name and value. |
|
216 | - * Note that if the course id field name is "chamilo_course_id", it will use the course id |
|
217 | - * in the system database |
|
218 | - * |
|
219 | - * @param string Course id field name |
|
220 | - * @param string Course id value |
|
221 | - * @return mixed System course id if the course was found, WSError otherwise |
|
222 | - */ |
|
223 | - protected function getCourseId($course_id_field_name, $course_id_value) |
|
214 | + /** |
|
215 | + * Gets the real course id based on the course id field name and value. |
|
216 | + * Note that if the course id field name is "chamilo_course_id", it will use the course id |
|
217 | + * in the system database |
|
218 | + * |
|
219 | + * @param string Course id field name |
|
220 | + * @param string Course id value |
|
221 | + * @return mixed System course id if the course was found, WSError otherwise |
|
222 | + */ |
|
223 | + protected function getCourseId($course_id_field_name, $course_id_value) |
|
224 | 224 | { |
225 | - if($course_id_field_name == "chamilo_course_id") { |
|
226 | - if(CourseManager::get_course_code_from_course_id(intval($course_id_value)) != null) { |
|
227 | - return intval($course_id_value); |
|
228 | - } else { |
|
229 | - return new WSCMError(200, "Course not found"); |
|
230 | - } |
|
231 | - } else { |
|
232 | - $courseId = CourseManager::get_course_code_from_original_id($course_id_value, $course_id_field_name); |
|
233 | - if (empty($courseId)) { |
|
234 | - return new WSCMError(200, "Course not found"); |
|
235 | - } else { |
|
236 | - return $courseId; |
|
237 | - } |
|
238 | - } |
|
239 | - } |
|
225 | + if($course_id_field_name == "chamilo_course_id") { |
|
226 | + if(CourseManager::get_course_code_from_course_id(intval($course_id_value)) != null) { |
|
227 | + return intval($course_id_value); |
|
228 | + } else { |
|
229 | + return new WSCMError(200, "Course not found"); |
|
230 | + } |
|
231 | + } else { |
|
232 | + $courseId = CourseManager::get_course_code_from_original_id($course_id_value, $course_id_field_name); |
|
233 | + if (empty($courseId)) { |
|
234 | + return new WSCMError(200, "Course not found"); |
|
235 | + } else { |
|
236 | + return $courseId; |
|
237 | + } |
|
238 | + } |
|
239 | + } |
|
240 | 240 | |
241 | - /** |
|
242 | - * Gets the real session id based on the session id field name and value. |
|
243 | - * Note that if the session id field name is "chamilo_session_id", it will use the session id |
|
244 | - * in the system database |
|
245 | - * |
|
246 | - * @param string Session id field name |
|
247 | - * @param string Session id value |
|
248 | - * @return mixed System session id if the session was found, WSError otherwise |
|
249 | - */ |
|
250 | - protected function getSessionId($session_id_field_name, $session_id_value) |
|
251 | - { |
|
252 | - if ($session_id_field_name == "chamilo_session_id") { |
|
253 | - $session = SessionManager::fetch((int)$session_id_value); |
|
254 | - if(!empty($session)) { |
|
255 | - return intval($session_id_value); |
|
256 | - } else { |
|
257 | - return new WSCMError(300, "Session not found"); |
|
258 | - } |
|
259 | - } else { |
|
260 | - $session_id = SessionManager::getSessionIdFromOriginalId( |
|
261 | - $session_id_value, |
|
262 | - $session_id_field_name |
|
263 | - ); |
|
264 | - if($session_id == 0) { |
|
265 | - return new WSCMError(300, "Session not found"); |
|
266 | - } else { |
|
267 | - return $session_id; |
|
268 | - } |
|
269 | - } |
|
270 | - } |
|
241 | + /** |
|
242 | + * Gets the real session id based on the session id field name and value. |
|
243 | + * Note that if the session id field name is "chamilo_session_id", it will use the session id |
|
244 | + * in the system database |
|
245 | + * |
|
246 | + * @param string Session id field name |
|
247 | + * @param string Session id value |
|
248 | + * @return mixed System session id if the session was found, WSError otherwise |
|
249 | + */ |
|
250 | + protected function getSessionId($session_id_field_name, $session_id_value) |
|
251 | + { |
|
252 | + if ($session_id_field_name == "chamilo_session_id") { |
|
253 | + $session = SessionManager::fetch((int)$session_id_value); |
|
254 | + if(!empty($session)) { |
|
255 | + return intval($session_id_value); |
|
256 | + } else { |
|
257 | + return new WSCMError(300, "Session not found"); |
|
258 | + } |
|
259 | + } else { |
|
260 | + $session_id = SessionManager::getSessionIdFromOriginalId( |
|
261 | + $session_id_value, |
|
262 | + $session_id_field_name |
|
263 | + ); |
|
264 | + if($session_id == 0) { |
|
265 | + return new WSCMError(300, "Session not found"); |
|
266 | + } else { |
|
267 | + return $session_id; |
|
268 | + } |
|
269 | + } |
|
270 | + } |
|
271 | 271 | |
272 | - /** |
|
273 | - * Handles an error by calling the WSError error handler |
|
274 | - * |
|
275 | - * @param WSError Error |
|
276 | - */ |
|
277 | - protected function handleError($error) |
|
278 | - { |
|
279 | - $handler = WSCMError::getErrorHandler(); |
|
280 | - $handler->handle($error); |
|
281 | - } |
|
272 | + /** |
|
273 | + * Handles an error by calling the WSError error handler |
|
274 | + * |
|
275 | + * @param WSError Error |
|
276 | + */ |
|
277 | + protected function handleError($error) |
|
278 | + { |
|
279 | + $handler = WSCMError::getErrorHandler(); |
|
280 | + $handler->handle($error); |
|
281 | + } |
|
282 | 282 | |
283 | - /** |
|
284 | - * Gets a successful result |
|
285 | - * |
|
286 | - * @return array Array with a code of 0 and a message 'Operation was successful' |
|
287 | - */ |
|
288 | - protected function getSuccessfulResult() |
|
289 | - { |
|
290 | - return array('code' => 0, 'message' => 'Operation was successful'); |
|
291 | - } |
|
283 | + /** |
|
284 | + * Gets a successful result |
|
285 | + * |
|
286 | + * @return array Array with a code of 0 and a message 'Operation was successful' |
|
287 | + */ |
|
288 | + protected function getSuccessfulResult() |
|
289 | + { |
|
290 | + return array('code' => 0, 'message' => 'Operation was successful'); |
|
291 | + } |
|
292 | 292 | |
293 | - /** |
|
294 | - * Test function. Returns the string success |
|
295 | - * |
|
296 | - * @return string Success |
|
297 | - */ |
|
298 | - public function test() |
|
299 | - { |
|
300 | - return "success"; |
|
301 | - } |
|
293 | + /** |
|
294 | + * Test function. Returns the string success |
|
295 | + * |
|
296 | + * @return string Success |
|
297 | + */ |
|
298 | + public function test() |
|
299 | + { |
|
300 | + return "success"; |
|
301 | + } |
|
302 | 302 | |
303 | - /** |
|
304 | - * *Strictly* reverts PHP's nl2br() effects (whether it was used in XHTML mode or not) |
|
305 | - * @param <type> $string |
|
306 | - * @return <type> $string |
|
307 | - */ |
|
308 | - public function nl2br_revert($string) { |
|
309 | - return preg_replace('`<br(?: /)?>([\\n\\r])`', '$1', $string); |
|
310 | - } |
|
303 | + /** |
|
304 | + * *Strictly* reverts PHP's nl2br() effects (whether it was used in XHTML mode or not) |
|
305 | + * @param <type> $string |
|
306 | + * @return <type> $string |
|
307 | + */ |
|
308 | + public function nl2br_revert($string) { |
|
309 | + return preg_replace('`<br(?: /)?>([\\n\\r])`', '$1', $string); |
|
310 | + } |
|
311 | 311 | |
312 | 312 | |
313 | 313 | } |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | */ |
50 | 50 | public static function setErrorHandler($handler) |
51 | 51 | { |
52 | - if($handler instanceof WSErrorHandler) { |
|
52 | + if ($handler instanceof WSErrorHandler) { |
|
53 | 53 | self::$_handler = $handler; |
54 | 54 | } |
55 | 55 | } |
@@ -120,12 +120,12 @@ discard block |
||
120 | 120 | // if we are behind a reverse proxy, assume it will send the |
121 | 121 | // HTTP_X_FORWARDED_FOR header and use this IP instead |
122 | 122 | if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { |
123 | - list($ip1,$ip2) = split(',',$_SERVER['HTTP_X_FORWARDED_FOR']); |
|
123 | + list($ip1, $ip2) = split(',', $_SERVER['HTTP_X_FORWARDED_FOR']); |
|
124 | 124 | $ip = trim($ip1); |
125 | 125 | } |
126 | 126 | $security_key = $ip.$this->_configuration['security_key']; |
127 | 127 | |
128 | - if(!api_is_valid_secret_key($secret_key, $security_key)) { |
|
128 | + if (!api_is_valid_secret_key($secret_key, $security_key)) { |
|
129 | 129 | return new WSCMError(1, "API key is invalid"); |
130 | 130 | } else { |
131 | 131 | return null; |
@@ -195,15 +195,15 @@ discard block |
||
195 | 195 | */ |
196 | 196 | protected function getUserId($user_id_field_name, $user_id_value) |
197 | 197 | { |
198 | - if($user_id_field_name == "chamilo_user_id") { |
|
199 | - if(UserManager::is_user_id_valid(intval($user_id_value))) { |
|
198 | + if ($user_id_field_name == "chamilo_user_id") { |
|
199 | + if (UserManager::is_user_id_valid(intval($user_id_value))) { |
|
200 | 200 | return intval($user_id_value); |
201 | 201 | } else { |
202 | 202 | return new WSCMError(100, "User not found"); |
203 | 203 | } |
204 | 204 | } else { |
205 | 205 | $user_id = UserManager::get_user_id_from_original_id($user_id_value, $user_id_field_name); |
206 | - if($user_id == 0) { |
|
206 | + if ($user_id == 0) { |
|
207 | 207 | return new WSCMError(100, "User not found"); |
208 | 208 | } else { |
209 | 209 | return $user_id; |
@@ -222,8 +222,8 @@ discard block |
||
222 | 222 | */ |
223 | 223 | protected function getCourseId($course_id_field_name, $course_id_value) |
224 | 224 | { |
225 | - if($course_id_field_name == "chamilo_course_id") { |
|
226 | - if(CourseManager::get_course_code_from_course_id(intval($course_id_value)) != null) { |
|
225 | + if ($course_id_field_name == "chamilo_course_id") { |
|
226 | + if (CourseManager::get_course_code_from_course_id(intval($course_id_value)) != null) { |
|
227 | 227 | return intval($course_id_value); |
228 | 228 | } else { |
229 | 229 | return new WSCMError(200, "Course not found"); |
@@ -250,8 +250,8 @@ discard block |
||
250 | 250 | protected function getSessionId($session_id_field_name, $session_id_value) |
251 | 251 | { |
252 | 252 | if ($session_id_field_name == "chamilo_session_id") { |
253 | - $session = SessionManager::fetch((int)$session_id_value); |
|
254 | - if(!empty($session)) { |
|
253 | + $session = SessionManager::fetch((int) $session_id_value); |
|
254 | + if (!empty($session)) { |
|
255 | 255 | return intval($session_id_value); |
256 | 256 | } else { |
257 | 257 | return new WSCMError(300, "Session not found"); |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | $session_id_value, |
262 | 262 | $session_id_field_name |
263 | 263 | ); |
264 | - if($session_id == 0) { |
|
264 | + if ($session_id == 0) { |
|
265 | 265 | return new WSCMError(300, "Session not found"); |
266 | 266 | } else { |
267 | 267 | return $session_id; |
@@ -204,6 +204,9 @@ |
||
204 | 204 | |
205 | 205 | } |
206 | 206 | |
207 | + /** |
|
208 | + * @param integer $user_id |
|
209 | + */ |
|
207 | 210 | protected function set_message_as_read($user_id, $message_id){ |
208 | 211 | $table_message = Database::get_main_table(TABLE_MESSAGE); |
209 | 212 | $query = "UPDATE $table_message SET msg_status = '".MESSAGE_STATUS_NEW."' WHERE user_receiver_id=".$user_id." AND id='".$message_id."';"; |
@@ -37,8 +37,8 @@ discard block |
||
37 | 37 | $table_message = Database::get_main_table(TABLE_MESSAGE); |
38 | 38 | |
39 | 39 | $sql_query = "SELECT id FROM $table_message " . |
40 | - " WHERE user_receiver_id=".$user_id." AND msg_status IN (0,1)" . |
|
41 | - " ORDER BY send_date LIMIT $from,$number_of_items"; |
|
40 | + " WHERE user_receiver_id=".$user_id." AND msg_status IN (0,1)" . |
|
41 | + " ORDER BY send_date LIMIT $from,$number_of_items"; |
|
42 | 42 | |
43 | 43 | $sql_result = Database::query($sql_query); |
44 | 44 | $message = "#"; |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | $table_message = Database::get_main_table(TABLE_MESSAGE); |
87 | 87 | |
88 | 88 | $sql_query = "SELECT ".$field_table." FROM $table_message " . |
89 | - " WHERE user_receiver_id=".$user_id." AND id=".$message_id; |
|
89 | + " WHERE user_receiver_id=".$user_id." AND id=".$message_id; |
|
90 | 90 | |
91 | 91 | $sql_result = Database::query($sql_query); |
92 | 92 | $result = Database::fetch_row($sql_result); |
@@ -107,8 +107,8 @@ discard block |
||
107 | 107 | $table_message = Database::get_main_table(TABLE_MESSAGE); |
108 | 108 | |
109 | 109 | $sql_query = "SELECT id FROM $table_message " . |
110 | - "WHERE user_sender_id=".$user_id." AND msg_status=".MESSAGE_STATUS_OUTBOX." " . |
|
111 | - "ORDER BY send_date LIMIT $from,$number_of_items"; |
|
110 | + "WHERE user_sender_id=".$user_id." AND msg_status=".MESSAGE_STATUS_OUTBOX." " . |
|
111 | + "ORDER BY send_date LIMIT $from,$number_of_items"; |
|
112 | 112 | |
113 | 113 | $sql_result = Database::query($sql_query); |
114 | 114 | $message = "#"; |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | $table_message = Database::get_main_table(TABLE_MESSAGE); |
158 | 158 | |
159 | 159 | $sql_query = "SELECT ".$field_table." FROM $table_message " . |
160 | - " WHERE user_sender_id=".$user_id." AND id=".$id; |
|
160 | + " WHERE user_sender_id=".$user_id." AND id=".$id; |
|
161 | 161 | |
162 | 162 | $sql_result = Database::query($sql_query); |
163 | 163 | $result = Database::fetch_row($sql_result); |
@@ -188,11 +188,11 @@ discard block |
||
188 | 188 | $table_message = Database::get_main_table(TABLE_MESSAGE); |
189 | 189 | |
190 | 190 | $query = "INSERT INTO $table_message(user_sender_id, user_receiver_id, msg_status, send_date, title, content, group_id, parent_id, update_date ) ". |
191 | - " VALUES ('$user_sender_id', '$receiver_user_id', '1', '".api_get_utc_datetime()."','$subject','$content','$group_id','$parent_id', '".api_get_utc_datetime()."')"; |
|
191 | + " VALUES ('$user_sender_id', '$receiver_user_id', '1', '".api_get_utc_datetime()."','$subject','$content','$group_id','$parent_id', '".api_get_utc_datetime()."')"; |
|
192 | 192 | $result = Database::query($query); |
193 | 193 | |
194 | 194 | $query = "INSERT INTO $table_message(user_sender_id, user_receiver_id, msg_status, send_date, title, content, group_id, parent_id, update_date ) ". |
195 | - " VALUES ('$user_sender_id', '$receiver_user_id', '4', '".api_get_utc_datetime()."','$subject','$content','$group_id','$parent_id', '".api_get_utc_datetime()."')"; |
|
195 | + " VALUES ('$user_sender_id', '$receiver_user_id', '4', '".api_get_utc_datetime()."','$subject','$content','$group_id','$parent_id', '".api_get_utc_datetime()."')"; |
|
196 | 196 | $result = Database::query($query); |
197 | 197 | |
198 | 198 | $inbox_last_id = Database::insert_id(); |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | { |
13 | 13 | public function unreadMessage($username, $password) |
14 | 14 | { |
15 | - if($this->verifyUserPass($username, $password) == "valid") |
|
15 | + if ($this->verifyUserPass($username, $password) == "valid") |
|
16 | 16 | { |
17 | 17 | $table_message = Database::get_main_table(TABLE_MESSAGE); |
18 | 18 | $user_id = UserManager::get_user_id_from_username($username); |
@@ -30,14 +30,14 @@ discard block |
||
30 | 30 | |
31 | 31 | public function get_message_id($username, $password, $from, $number_of_items) |
32 | 32 | { |
33 | - if($this->verifyUserPass($username, $password) == "valid") |
|
33 | + if ($this->verifyUserPass($username, $password) == "valid") |
|
34 | 34 | { |
35 | 35 | $user_id = UserManager::get_user_id_from_username($username); |
36 | 36 | |
37 | 37 | $table_message = Database::get_main_table(TABLE_MESSAGE); |
38 | 38 | |
39 | - $sql_query = "SELECT id FROM $table_message " . |
|
40 | - " WHERE user_receiver_id=".$user_id." AND msg_status IN (0,1)" . |
|
39 | + $sql_query = "SELECT id FROM $table_message ". |
|
40 | + " WHERE user_receiver_id=".$user_id." AND msg_status IN (0,1)". |
|
41 | 41 | " ORDER BY send_date LIMIT $from,$number_of_items"; |
42 | 42 | |
43 | 43 | $sql_result = Database::query($sql_query); |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | |
56 | 56 | public function get_message_data($username, $password, $message_id, $field) |
57 | 57 | { |
58 | - if($this->verifyUserPass($username, $password) == "valid") |
|
58 | + if ($this->verifyUserPass($username, $password) == "valid") |
|
59 | 59 | { |
60 | 60 | $htmlcode = false; |
61 | 61 | $user_id = UserManager::get_user_id_from_username($username); |
@@ -85,14 +85,14 @@ discard block |
||
85 | 85 | |
86 | 86 | $table_message = Database::get_main_table(TABLE_MESSAGE); |
87 | 87 | |
88 | - $sql_query = "SELECT ".$field_table." FROM $table_message " . |
|
88 | + $sql_query = "SELECT ".$field_table." FROM $table_message ". |
|
89 | 89 | " WHERE user_receiver_id=".$user_id." AND id=".$message_id; |
90 | 90 | |
91 | 91 | $sql_result = Database::query($sql_query); |
92 | 92 | $result = Database::fetch_row($sql_result); |
93 | 93 | return (htmlcode) ? html_entity_decode($result[0]) : $result[0]; |
94 | 94 | |
95 | - }else |
|
95 | + } else |
|
96 | 96 | return get_lang('InvalidId'); |
97 | 97 | |
98 | 98 | |
@@ -100,14 +100,14 @@ discard block |
||
100 | 100 | |
101 | 101 | public function get_message_id_sent($username, $password, $from, $number_of_items) |
102 | 102 | { |
103 | - if($this->verifyUserPass($username, $password) == "valid") |
|
103 | + if ($this->verifyUserPass($username, $password) == "valid") |
|
104 | 104 | { |
105 | 105 | $user_id = UserManager::get_user_id_from_username($username); |
106 | 106 | |
107 | 107 | $table_message = Database::get_main_table(TABLE_MESSAGE); |
108 | 108 | |
109 | - $sql_query = "SELECT id FROM $table_message " . |
|
110 | - "WHERE user_sender_id=".$user_id." AND msg_status=".MESSAGE_STATUS_OUTBOX." " . |
|
109 | + $sql_query = "SELECT id FROM $table_message ". |
|
110 | + "WHERE user_sender_id=".$user_id." AND msg_status=".MESSAGE_STATUS_OUTBOX." ". |
|
111 | 111 | "ORDER BY send_date LIMIT $from,$number_of_items"; |
112 | 112 | |
113 | 113 | $sql_result = Database::query($sql_query); |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | |
127 | 127 | public function get_message_data_sent($username, $password, $id, $field) |
128 | 128 | { |
129 | - if($this->verifyUserPass($username, $password) == "valid") |
|
129 | + if ($this->verifyUserPass($username, $password) == "valid") |
|
130 | 130 | { |
131 | 131 | $htmlcode = false; |
132 | 132 | switch ($field) |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | |
157 | 157 | $table_message = Database::get_main_table(TABLE_MESSAGE); |
158 | 158 | |
159 | - $sql_query = "SELECT ".$field_table." FROM $table_message " . |
|
159 | + $sql_query = "SELECT ".$field_table." FROM $table_message ". |
|
160 | 160 | " WHERE user_sender_id=".$user_id." AND id=".$id; |
161 | 161 | |
162 | 162 | $sql_result = Database::query($sql_query); |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | |
165 | 165 | return (htmlcode) ? html_entity_decode($result[0]) : $result[0]; |
166 | 166 | |
167 | - }else |
|
167 | + } else |
|
168 | 168 | return get_lang('InvalidId'); |
169 | 169 | |
170 | 170 | |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | public function message_send($username, $password, $receiver_user_id, $subject, $content) |
174 | 174 | { |
175 | 175 | //TODO: verificar data de envio. Esta divergindo de data! |
176 | - if($this->verifyUserPass($username, $password) == "valid") |
|
176 | + if ($this->verifyUserPass($username, $password) == "valid") |
|
177 | 177 | { |
178 | 178 | $group_id = intval(0); |
179 | 179 | $parent_id = intval(0); |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | |
205 | 205 | } |
206 | 206 | |
207 | - protected function set_message_as_read($user_id, $message_id){ |
|
207 | + protected function set_message_as_read($user_id, $message_id) { |
|
208 | 208 | $table_message = Database::get_main_table(TABLE_MESSAGE); |
209 | 209 | $query = "UPDATE $table_message SET msg_status = '".MESSAGE_STATUS_NEW."' WHERE user_receiver_id=".$user_id." AND id='".$message_id."';"; |
210 | 210 | $result = Database::query($query); |
@@ -48,8 +48,9 @@ discard block |
||
48 | 48 | |
49 | 49 | return $message; |
50 | 50 | |
51 | - } else |
|
52 | - return get_lang('InvalidId'); |
|
51 | + } else { |
|
52 | + return get_lang('InvalidId'); |
|
53 | + } |
|
53 | 54 | |
54 | 55 | } |
55 | 56 | |
@@ -92,8 +93,9 @@ discard block |
||
92 | 93 | $result = Database::fetch_row($sql_result); |
93 | 94 | return (htmlcode) ? html_entity_decode($result[0]) : $result[0]; |
94 | 95 | |
95 | - }else |
|
96 | - return get_lang('InvalidId'); |
|
96 | + } else { |
|
97 | + return get_lang('InvalidId'); |
|
98 | + } |
|
97 | 99 | |
98 | 100 | |
99 | 101 | } |
@@ -118,8 +120,9 @@ discard block |
||
118 | 120 | |
119 | 121 | return $message; |
120 | 122 | |
121 | - } else |
|
122 | - return get_lang('InvalidId'); |
|
123 | + } else { |
|
124 | + return get_lang('InvalidId'); |
|
125 | + } |
|
123 | 126 | |
124 | 127 | } |
125 | 128 | |
@@ -164,8 +167,9 @@ discard block |
||
164 | 167 | |
165 | 168 | return (htmlcode) ? html_entity_decode($result[0]) : $result[0]; |
166 | 169 | |
167 | - }else |
|
168 | - return get_lang('InvalidId'); |
|
170 | + } else { |
|
171 | + return get_lang('InvalidId'); |
|
172 | + } |
|
169 | 173 | |
170 | 174 | |
171 | 175 | } |
@@ -199,8 +203,9 @@ discard block |
||
199 | 203 | |
200 | 204 | return $inbox_last_id; |
201 | 205 | |
202 | - } else |
|
203 | - return get_lang('InvalidId'); |
|
206 | + } else { |
|
207 | + return get_lang('InvalidId'); |
|
208 | + } |
|
204 | 209 | |
205 | 210 | } |
206 | 211 |
@@ -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'); |