Browse Source

Merge pull request #1926 from chamilo/scrutinizer-patch-2

Scrutinizer Auto-Fixes
Julio Montoya 7 years ago
parent
commit
1a51665484

+ 17 - 17
main/admin/dashboard_add_courses_to_user.php

@@ -21,7 +21,7 @@ api_protect_admin_script(true);
 
 // setting breadcrumbs
 $interbreadcrumb[] = array('url' => 'index.php', 'name' => get_lang('PlatformAdmin'));
-$interbreadcrumb[] = array('url' => 'user_list.php','name' => get_lang('UserList'));
+$interbreadcrumb[] = array('url' => 'user_list.php', 'name' => get_lang('UserList'));
 
 // Database Table Definitions
 $tbl_course = Database::get_main_table(TABLE_MAIN_COURSE);
@@ -36,11 +36,11 @@ $current_user_id = api_get_user_id();
 
 // setting the name of the tool
 if (UserManager::is_admin($user_id)) {
-	$tool_name= get_lang('AssignCoursesToPlatformAdministrator');
+	$tool_name = get_lang('AssignCoursesToPlatformAdministrator');
 } else if ($user_info['status'] == SESSIONADMIN) {
-	$tool_name= get_lang('AssignCoursesToSessionsAdministrator');
+	$tool_name = get_lang('AssignCoursesToSessionsAdministrator');
 } else {
-	$tool_name= get_lang('AssignCoursesToHumanResourcesManager');
+	$tool_name = get_lang('AssignCoursesToHumanResourcesManager');
 }
 
 $add_type = 'multiple';
@@ -54,7 +54,7 @@ if (!api_is_platform_admin()) {
 
 function search_courses($needle, $type)
 {
-    global $tbl_course, $tbl_course_rel_access_url,$user_id;
+    global $tbl_course, $tbl_course_rel_access_url, $user_id;
 
     $xajax_response = new xajaxResponse();
     $return = '';
@@ -68,7 +68,7 @@ function search_courses($needle, $type)
         }
         $without_assigned_courses = '';
         if (count($assigned_courses_code) > 0) {
-            $without_assigned_courses = " AND c.code NOT IN(".implode(',',$assigned_courses_code).")";
+            $without_assigned_courses = " AND c.code NOT IN(".implode(',', $assigned_courses_code).")";
         }
 
         if (api_is_multiple_url_enabled()) {
@@ -87,14 +87,14 @@ function search_courses($needle, $type)
                 		$without_assigned_courses ";
         }
 
-		$rs	= Database::query($sql);
+		$rs = Database::query($sql);
 
         $return .= '<select id="origin" name="NoAssignedCoursesList[]" multiple="multiple" size="20" >';
         while ($course = Database :: fetch_array($rs)) {
-            $return .= '<option value="'.$course['code'].'" title="'.htmlspecialchars($course['title'],ENT_QUOTES).'">'.$course['title'].' ('.$course['code'].')</option>';
+            $return .= '<option value="'.$course['code'].'" title="'.htmlspecialchars($course['title'], ENT_QUOTES).'">'.$course['title'].' ('.$course['code'].')</option>';
         }
         $return .= '</select>';
-        $xajax_response -> addAssign('ajax_list_courses_multiple','innerHTML',api_utf8_encode($return));
+        $xajax_response -> addAssign('ajax_list_courses_multiple', 'innerHTML', api_utf8_encode($return));
     }
     return $xajax_response;
 }
@@ -151,7 +151,7 @@ function remove_item(origin) {
 }
 </script>';
 
-$formSent=0;
+$formSent = 0;
 $errorMsg = $firstLetterCourse = '';
 $UserList = array();
 
@@ -210,19 +210,19 @@ if (api_is_multiple_url_enabled()) {
             ORDER BY c.title";
 
 } else {
-	$sql= " SELECT c.code, c.title
+	$sql = " SELECT c.code, c.title
 	        FROM $tbl_course c
             WHERE  c.code LIKE '$needle' $without_assigned_courses
             ORDER BY c.title";
 }
 
-$result	= Database::query($sql);
+$result = Database::query($sql);
 
 ?>
 <form name="formulaire" method="post" action="<?php echo api_get_self(); ?>?user=<?php echo $user_id ?>" style="margin:0px;">
 <input type="hidden" name="formSent" value="1" />
 <?php
-if(!empty($msg)) {
+if (!empty($msg)) {
 	Display::addFlash(Display::return_message($msg, 'normal')); //main API
 }
 ?>
@@ -234,7 +234,7 @@ if(!empty($msg)) {
         <div id="ajax_list_courses_multiple">
 	<select id="origin" name="NoAssignedCoursesList[]" multiple="multiple" size="20" style="width:340px;">
 	<?php while ($enreg = Database::fetch_array($result)) { ?>
-            <option value="<?php echo $enreg['code']; ?>" <?php echo 'title="'.htmlspecialchars($enreg['title'],ENT_QUOTES).'"';?>><?php echo $enreg['title'].' ('.$enreg['code'].')'; ?></option>
+            <option value="<?php echo $enreg['code']; ?>" <?php echo 'title="'.htmlspecialchars($enreg['title'], ENT_QUOTES).'"'; ?>><?php echo $enreg['title'].' ('.$enreg['code'].')'; ?></option>
 	<?php } ?>
 	</select>
         </div>
@@ -242,8 +242,8 @@ if(!empty($msg)) {
     </div>
     <div class="col-md-4">
         <div class="code-course">
-        <?php if($add_type == 'multiple') { ?>
-        <p><?php echo get_lang('FirstLetterCourse');?> :</p>
+        <?php if ($add_type == 'multiple') { ?>
+        <p><?php echo get_lang('FirstLetterCourse'); ?> :</p>
         <select name="firstLetterCourse" class="selectpicker form-control" onchange = "xajax_search_courses(this.value,'multiple')">
             <option value="%">--</option>
             <?php  echo Display :: get_alphabet_options($firstLetter); ?>
@@ -282,7 +282,7 @@ if(!empty($msg)) {
             if (is_array($assigned_courses_to_hrm)) {
                 foreach ($assigned_courses_to_hrm as $enreg) {
             ?>
-                <option value="<?php echo $enreg['code']; ?>" <?php echo 'title="' . htmlspecialchars($enreg['title'], ENT_QUOTES) . '"'; ?>><?php echo $enreg['title'] . ' (' . $enreg['code'] . ')'; ?></option>
+                <option value="<?php echo $enreg['code']; ?>" <?php echo 'title="'.htmlspecialchars($enreg['title'], ENT_QUOTES).'"'; ?>><?php echo $enreg['title'].' ('.$enreg['code'].')'; ?></option>
             <?php
                     }
                 }

+ 29 - 29
main/admin/ldap_users_list.php

@@ -30,7 +30,7 @@ if (($_GET['action']=="add_user") && ($_GET['id_session'] == strval(intval($_GET
 }
 */
 
-$interbreadcrumb[] = array ("url" => 'index.php', "name" => get_lang('PlatformAdmin'));
+$interbreadcrumb[] = array("url" => 'index.php', "name" => get_lang('PlatformAdmin'));
 $tool_name = get_lang('SearchLDAPUsers');
 //Display::display_header($tool_name); //cannot display now as we need to redirect
 //api_display_tool_title($tool_name);
@@ -38,7 +38,7 @@ $tool_name = get_lang('SearchLDAPUsers');
 if (isset ($_GET['action']))
 {
 	$check = Security::check_token('get');
-	if($check)
+	if ($check)
 	{
 		switch ($_GET['action'])
 		{
@@ -59,39 +59,39 @@ if (isset ($_GET['action']))
 				break;
 			case 'lock' :
 				Display::display_header($tool_name);
-				$message=lock_unlock_user('lock',$_GET['user_id']);
+				$message = lock_unlock_user('lock', $_GET['user_id']);
 				Display::addFlash(Display::return_message($message, 'normal'));
 				break;
 			case 'unlock':
 				Display::display_header($tool_name);
-				$message=lock_unlock_user('unlock',$_GET['user_id']);
+				$message = lock_unlock_user('unlock', $_GET['user_id']);
 				Display::addFlash(Display::return_message($message, 'normal'));
 				break;
             case 'add_user':
-				$id=$_GET['id'];
-				$UserList=array();
+				$id = $_GET['id'];
+				$UserList = array();
 				$userid_match_login = array();
 				foreach ($id as $user_id) {
 					$tmp = ldap_add_user($user_id);
-					$UserList[]= $tmp;
+					$UserList[] = $tmp;
 					$userid_match_login[$tmp] = $user_id;
 				}
-				if (isset($_GET['id_session']) && ($_GET['id_session'] == strval(intval($_GET['id_session']))) && ($_GET['id_session']>0)) {
+				if (isset($_GET['id_session']) && ($_GET['id_session'] == strval(intval($_GET['id_session']))) && ($_GET['id_session'] > 0)) {
 					ldap_add_user_to_session($UserList, $_GET['id_session']);
 					header('Location: resume_session.php?id_session='.intval($_GET['id_session']));
 				} else {
 					Display::display_header($tool_name);
-					if(count($userid_match_login)>0)
+					if (count($userid_match_login) > 0)
 					{
-						$message=get_lang('LDAPUsersAddedOrUpdated').':<br />';
-						foreach($userid_match_login as $user_id => $login)
+						$message = get_lang('LDAPUsersAddedOrUpdated').':<br />';
+						foreach ($userid_match_login as $user_id => $login)
 						{
 							$message .= '- '.$login.'<br />';
 						}
 					}
 					else
 					{
-						$message=get_lang('NoUserAdded');
+						$message = get_lang('NoUserAdded');
 					}
 					Display::addFlash(Display::return_message($message, 'normal', false));
 				}
@@ -113,7 +113,7 @@ else
 if (isset ($_POST['action']))
 {
 	$check = Security::check_token('get');
-	if($check)
+	if ($check)
 	{
 		switch ($_POST['action'])
 		{
@@ -122,15 +122,15 @@ if (isset ($_POST['action']))
 				$number_of_deleted_users = 0;
 				foreach ($_POST['id'] as $index => $user_id)
 				{
-					if($user_id != $_user['user_id'])
+					if ($user_id != $_user['user_id'])
 					{
-						if(UserManager::delete_user($user_id))
+						if (UserManager::delete_user($user_id))
 						{
 							$number_of_deleted_users++;
 						}
 					}
 				}
-				if($number_of_selected_users == $number_of_deleted_users)
+				if ($number_of_selected_users == $number_of_deleted_users)
 				{
 					Display::addFlash(Display::return_message(get_lang('SelectedUsersDeleted'), 'normal'));
 				}
@@ -142,17 +142,17 @@ if (isset ($_POST['action']))
 			case 'add_user' :
 				$number_of_selected_users = count($_POST['id']);
 				$number_of_added_users = 0;
-				$UserList=array();
+				$UserList = array();
 				foreach ($_POST['id'] as $index => $user_id)
 				{
-					if($user_id != $_user['user_id'])
+					if ($user_id != $_user['user_id'])
 					{
 						$UserList[] = ldap_add_user($user_id);
 					}
 				}
-				if (isset($_GET['id_session']) && (trim($_GET['id_session'])!=""))
+				if (isset($_GET['id_session']) && (trim($_GET['id_session']) != ""))
 					addUserToSession($UserList, $_GET['id_session']);
-				if(count($UserList)>0)
+				if (count($UserList) > 0)
 				{
 					Display::addFlash(Display::return_message(count($UserList)." ".get_lang('LDAPUsersAdded')));
 				}
@@ -167,8 +167,8 @@ if (isset ($_POST['action']))
 	}
 }
 
-$form = new FormValidator('advanced_search','get');
-$form->addText('keyword_username',get_lang('LoginName'),false);
+$form = new FormValidator('advanced_search', 'get');
+$form->addText('keyword_username', get_lang('LoginName'), false);
 if (api_is_western_name_order())
 {
 	$form->addText('keyword_firstname', get_lang('FirstName'), false);
@@ -176,20 +176,20 @@ if (api_is_western_name_order())
 }
 else
 {
-	$form->addText('keyword_lastname',get_lang('LastName'),false);
-	$form->addText('keyword_firstname',get_lang('FirstName'),false);
+	$form->addText('keyword_lastname', get_lang('LastName'), false);
+	$form->addText('keyword_firstname', get_lang('FirstName'), false);
 }
 if (isset($_GET['id_session']))
-	$form->addElement('hidden','id_session',$_GET['id_session']);
+	$form->addElement('hidden', 'id_session', $_GET['id_session']);
 
 $type = array();
 $type["all"] = get_lang('All');
-$type["employee"]  = get_lang('Teacher');
+$type["employee"] = get_lang('Teacher');
 $type["student"] = get_lang('Student');
 
-$form->addElement('select','keyword_type',get_lang('Status'),$type);
+$form->addElement('select', 'keyword_type', get_lang('Status'), $type);
 // Structure a rajouer ??
-$form->addElement('submit','submit',get_lang('Ok'));
+$form->addElement('submit', 'submit', get_lang('Ok'));
 //$defaults['keyword_active'] = 1;
 //$defaults['keyword_inactive'] = 1;
 //$form->setDefaults($defaults);
@@ -222,7 +222,7 @@ $table->set_header(5, get_lang('Actions'));
 //$table->set_column_filter(5, 'email_filter');
 //$table->set_column_filter(5, 'active_filter');
 $table->set_column_filter(5, 'modify_filter');
-$table->set_form_actions(array ('add_user' => get_lang('AddLDAPUsers')));
+$table->set_form_actions(array('add_user' => get_lang('AddLDAPUsers')));
 $table->display();
 
 /*

+ 35 - 35
main/admin/settings.lib.php

@@ -148,7 +148,7 @@ function handlePlugins()
 
     // Plugins NOT installed
     echo Display::page_subheader(get_lang('Plugins'));
-    echo '<form class="form-horizontal" name="plugins" method="post" action="'.api_get_self().'?category='.Security::remove_XSS($_GET['category']).'&sec_token=' . $token . '">';
+    echo '<form class="form-horizontal" name="plugins" method="post" action="'.api_get_self().'?category='.Security::remove_XSS($_GET['category']).'&sec_token='.$token.'">';
     echo '<table class="data_table">';
     echo '<tr>';
     echo '<th width="20px">';
@@ -197,7 +197,7 @@ function handlePlugins()
             if (file_exists(api_get_path(SYS_PLUGIN_PATH).$pluginName.'/readme.txt')) {
                 echo Display::url(
                     "<em class='fa fa-file-text-o'></em> readme.txt",
-                    api_get_path(WEB_PLUGIN_PATH) . $pluginName . "/readme.txt",
+                    api_get_path(WEB_PLUGIN_PATH).$pluginName."/readme.txt",
                     [
                         'class' => 'btn btn-default ajax',
                         'data-title' => $plugin_info['title'],
@@ -349,7 +349,7 @@ function handleStylesheets()
     $dir = api_get_path(SYS_PUBLIC_PATH).'css/'.$themeDir.'/images/';
     $url = api_get_path(WEB_CSS_PATH).'/'.$themeDir.'/images/';
     $logoFileName = 'header-logo.png';
-    $newLogoFileName = 'header-logo-custom' . api_get_current_access_url_id() . '.png';
+    $newLogoFileName = 'header-logo-custom'.api_get_current_access_url_id().'.png';
     $webPlatformLogoPath = ChamiloApi::getWebPlatformLogoPath($selected);
 
     $logoForm = new FormValidator(
@@ -372,7 +372,7 @@ function handleStylesheets()
     if ($webPlatformLogoPath !== null) {
         $logoForm->addLabel(
             get_lang('CurrentLogo'),
-            '<img id="header-logo-custom" src="' . $webPlatformLogoPath . '?' . time() . '">'
+            '<img id="header-logo-custom" src="'.$webPlatformLogoPath.'?'.time().'">'
         );
     }
     $logoForm->addFile('new_logo', get_lang('UpdateLogo'));
@@ -457,7 +457,7 @@ function handleStylesheets()
             });
             </script>';
             echo Display::tabs(
-                array(get_lang('Update'),get_lang('UpdateLogo'), get_lang('UploadNewStylesheet')),
+                array(get_lang('Update'), get_lang('UpdateLogo'), get_lang('UploadNewStylesheet')),
                 array($form_change->returnForm(), $logoForm->returnForm(), $form->returnForm())
             );
         } else {
@@ -633,7 +633,7 @@ function storeRegions()
             if (!empty($areas_to_installed)) {
                 $plugin_obj->remove_all_regions($plugin);
                 foreach ($areas_to_installed as $region) {
-                    if (!empty($region) && $region != '-1' ) {
+                    if (!empty($region) && $region != '-1') {
                         $plugin_obj->add_to_region($plugin, $region);
                     }
                 }
@@ -740,14 +740,14 @@ function handleSearch()
         $values = api_get_settings_options('search_show_unlinked_results');
 
         $group = formGenerateElementsGroup($form, $values, 'search_show_unlinked_results');
-        $form->addGroup($group, 'search_show_unlinked_results', array(get_lang('SearchShowUnlinkedResultsTitle'),get_lang('SearchShowUnlinkedResultsComment')), null, false);
+        $form->addGroup($group, 'search_show_unlinked_results', array(get_lang('SearchShowUnlinkedResultsTitle'), get_lang('SearchShowUnlinkedResultsComment')), null, false);
         $default_values['search_show_unlinked_results'] = api_get_setting('search_show_unlinked_results');
 
         $sf_values = array();
         foreach ($specific_fields as $sf) {
             $sf_values[$sf['code']] = $sf['name'];
         }
-        $url =  Display::div(Display::url(get_lang('AddSpecificSearchField'), 'specific_fields.php'), array('class'=>'sectioncomment'));
+        $url = Display::div(Display::url(get_lang('AddSpecificSearchField'), 'specific_fields.php'), array('class'=>'sectioncomment'));
         if (empty($sf_values)) {
             $form->addElement('label', [get_lang('SearchPrefilterPrefix'), $url]);
         } else {
@@ -842,7 +842,7 @@ function handleTemplates()
     if ($action != 'add') {
         echo '<div class="actions" style="margin-left: 1px;">';
         echo '<a href="settings.php?category=Templates&action=add">'.
-                Display::return_icon('new_template.png', get_lang('AddTemplate'),'',ICON_SIZE_MEDIUM).'</a>';
+                Display::return_icon('new_template.png', get_lang('AddTemplate'), '', ICON_SIZE_MEDIUM).'</a>';
         echo '</div>';
     }
 
@@ -963,8 +963,8 @@ function getTemplateData($from, $number_of_items, $column, $direction)
  * @since v1.8.6
  */
 function actionsFilter($id) {
-    $return = '<a href="settings.php?category=Templates&action=edit&id='.Security::remove_XSS($id).'">'.Display::return_icon('edit.png', get_lang('Edit'),'',ICON_SIZE_SMALL).'</a>';
-    $return .= '<a href="settings.php?category=Templates&action=delete&id='.Security::remove_XSS($id).'" onClick="javascript:if(!confirm('."'".get_lang('ConfirmYourChoice')."'".')) return false;">'.Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_SMALL).'</a>';
+    $return = '<a href="settings.php?category=Templates&action=edit&id='.Security::remove_XSS($id).'">'.Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_SMALL).'</a>';
+    $return .= '<a href="settings.php?category=Templates&action=delete&id='.Security::remove_XSS($id).'" onClick="javascript:if(!confirm('."'".get_lang('ConfirmYourChoice')."'".')) return false;">'.Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL).'</a>';
     return $return;
 }
 
@@ -1040,10 +1040,10 @@ function addEditTemplate()
         // Adding an extra field: a preview of the image that is currently used.
         if (!empty($row['image'])) {
             $form->addElement('static', 'template_image_preview', '',
-                '<img src="' . api_get_path(WEB_APP_PATH) . 'home/default_platform_document/template_thumb/' . $row['image'] . '" alt="' . get_lang('TemplatePreview') . '"/>');
+                '<img src="'.api_get_path(WEB_APP_PATH).'home/default_platform_document/template_thumb/'.$row['image'].'" alt="'.get_lang('TemplatePreview').'"/>');
         } else {
             $form->addElement('static', 'template_image_preview', '',
-                '<img src="' . api_get_path(WEB_APP_PATH) . 'home/default_platform_document/template_thumb/noimage.gif" alt="' . get_lang('NoTemplatePreview') . '"/>');
+                '<img src="'.api_get_path(WEB_APP_PATH).'home/default_platform_document/template_thumb/noimage.gif" alt="'.get_lang('NoTemplatePreview').'"/>');
         }
 
         // Setting the information of the template that we are editing.
@@ -1095,7 +1095,7 @@ function addEditTemplate()
             // Store the information in the database (as insert or as update).
             $table_system_template = Database::get_main_table('system_template');
             if ($_GET['action'] == 'add') {
-                $content_template =  Security::remove_XSS($values['template_text'], COURSEMANAGERLOWSECURITY);
+                $content_template = Security::remove_XSS($values['template_text'], COURSEMANAGERLOWSECURITY);
                 $params = [
                     'title' =>  $values['title'],
                     'content' => $content_template,
@@ -1105,7 +1105,7 @@ function addEditTemplate()
 
                 // Display a feedback message.
                 Display::addFlash(Display::return_message(get_lang('TemplateAdded'), 'confirm'));
-                echo '<a href="settings.php?category=Templates&action=add">'.Display::return_icon('new_template.png', get_lang('AddTemplate'),'',ICON_SIZE_MEDIUM).'</a>';
+                echo '<a href="settings.php?category=Templates&action=add">'.Display::return_icon('new_template.png', get_lang('AddTemplate'), '', ICON_SIZE_MEDIUM).'</a>';
             } else {
                 $content_template = '<head>{CSS}<style type="text/css">.text{font-weight: normal;}</style></head><body>'.Database::escape_string($values['template_text']).'</body>';
                 $sql = "UPDATE $table_system_template set title = '".Database::escape_string($values['title'])."', content = '".$content_template."'";
@@ -1258,13 +1258,13 @@ function generateSettingsForm($settings, $settings_by_access_list)
                             $form->addElement(
                                 'html',
                                 '<div class="pull-right"><a class="share_this_setting" data_status = "0"  data_to_send = "'.$row['variable'].'" href="javascript:void(0);">'.
-                                Display::return_icon('shared_setting.png', get_lang('ChangeSharedSetting') , null, ICON_SIZE_MEDIUM).'</a></div>'
+                                Display::return_icon('shared_setting.png', get_lang('ChangeSharedSetting'), null, ICON_SIZE_MEDIUM).'</a></div>'
                             );
                         } else {
                             $form->addElement(
                                 'html',
                                 '<div class="pull-right"><a class="share_this_setting" data_status = "1" data_to_send = "'.$row['variable'].'" href="javascript:void(0);">'.
-                                Display::return_icon('shared_setting_na.png', get_lang('ChangeSharedSetting'), null, ICON_SIZE_MEDIUM ).'</a></div>'
+                                Display::return_icon('shared_setting_na.png', get_lang('ChangeSharedSetting'), null, ICON_SIZE_MEDIUM).'</a></div>'
                             );
                         }
                     } else {
@@ -1272,13 +1272,13 @@ function generateSettingsForm($settings, $settings_by_access_list)
                             $form->addElement(
                                 'html',
                                 '<div class="pull-right">'.
-                                Display::return_icon('shared_setting.png', get_lang('ChangeSharedSetting'), null, ICON_SIZE_MEDIUM ).'</div>'
+                                Display::return_icon('shared_setting.png', get_lang('ChangeSharedSetting'), null, ICON_SIZE_MEDIUM).'</div>'
                             );
                         } else {
                             $form->addElement(
                                 'html',
                                 '<div class="pull-right">'.
-                                Display::return_icon('shared_setting_na.png', get_lang('ChangeSharedSetting'), null, ICON_SIZE_MEDIUM ).'</div>'
+                                Display::return_icon('shared_setting_na.png', get_lang('ChangeSharedSetting'), null, ICON_SIZE_MEDIUM).'</div>'
                             );
                         }
                     }
@@ -1330,7 +1330,7 @@ function generateSettingsForm($settings, $settings_by_access_list)
                         array('maxlength' => '8')
                     );
                     $form->applyFilter($row['variable'], 'html_filter');
-                    $default_values[$row['variable']] = round($row['selected_value']/1024/1024, 1);
+                    $default_values[$row['variable']] = round($row['selected_value'] / 1024 / 1024, 1);
                 } elseif ($row['variable'] == 'account_valid_duration') {
                     $form->addElement(
                         'text',
@@ -1358,7 +1358,7 @@ function generateSettingsForm($settings, $settings_by_access_list)
                         ),
                         $hideme
                     );
-                    $form->applyFilter($row['variable'],'html_filter');
+                    $form->applyFilter($row['variable'], 'html_filter');
                     $default_values[$row['variable']] = $row['selected_value'];
                 }
                 break;
@@ -1369,7 +1369,7 @@ function generateSettingsForm($settings, $settings_by_access_list)
                     if (file_exists($file)) {
                         $value = file_get_contents($file);
                     }
-                    $form->addElement('textarea', $row['variable'], array(get_lang($row['title']), get_lang($row['comment'])) , array('rows'=>'10'), $hideme);
+                    $form->addElement('textarea', $row['variable'], array(get_lang($row['title']), get_lang($row['comment'])), array('rows'=>'10'), $hideme);
                     $default_values[$row['variable']] = $value;
                 } elseif ($row['variable'] == 'footer_extra_content') {
                     $file = api_get_home_path().'footer_extra_content.txt';
@@ -1377,16 +1377,16 @@ function generateSettingsForm($settings, $settings_by_access_list)
                     if (file_exists($file)) {
                         $value = file_get_contents($file);
                     }
-                    $form->addElement('textarea', $row['variable'], array(get_lang($row['title']), get_lang($row['comment'])) , array('rows'=>'10'), $hideme);
+                    $form->addElement('textarea', $row['variable'], array(get_lang($row['title']), get_lang($row['comment'])), array('rows'=>'10'), $hideme);
                     $default_values[$row['variable']] = $value;
                 } else {
-                    $form->addElement('textarea', $row['variable'], array(get_lang($row['title']), get_lang($row['comment'])) , array('rows'=>'10'), $hideme);
+                    $form->addElement('textarea', $row['variable'], array(get_lang($row['title']), get_lang($row['comment'])), array('rows'=>'10'), $hideme);
                     $default_values[$row['variable']] = $row['selected_value'];
                 }
                 break;
             case 'radio':
                 $values = api_get_settings_options($row['variable']);
-                $group = array ();
+                $group = array();
                 if (is_array($values)) {
                     foreach ($values as $key => $value) {
                         $element = &$form->createElement(
@@ -1417,7 +1417,7 @@ function generateSettingsForm($settings, $settings_by_access_list)
                         WHERE variable='".$row['variable']."' AND access_url =  1";
 
                 $result = Database::query($sql);
-                $group = array ();
+                $group = array();
                 while ($rowkeys = Database::fetch_array($result)) {
                     // Profile tab option should be hidden when the social tool is enabled.
                     if (api_get_setting('allow_social_tool') == 'true') {
@@ -1474,7 +1474,7 @@ function generateSettingsForm($settings, $settings_by_access_list)
                 break;
             case 'link':
                 $form->addElement('static', null, array(get_lang($row['title']), get_lang($row['comment'])),
-                    get_lang('CurrentValue') . ' : ' . $row['selected_value'], $hideme);
+                    get_lang('CurrentValue').' : '.$row['selected_value'], $hideme);
                 break;
             case 'select':
                 /*
@@ -1506,7 +1506,7 @@ function generateSettingsForm($settings, $settings_by_access_list)
                     $row['variable'],
                     [get_lang($row['title']), get_lang($row['comment'])],
                     $courseSelectOptions,
-                    ['url' => api_get_path(WEB_AJAX_PATH) . 'course.ajax.php?a=search_course']
+                    ['url' => api_get_path(WEB_AJAX_PATH).'course.ajax.php?a=search_course']
                 );
                 $default_values[$row['variable']] = $row['selected_value'];
                 break;
@@ -1514,10 +1514,10 @@ function generateSettingsForm($settings, $settings_by_access_list)
 
         switch ($row['variable']) {
             case 'pdf_export_watermark_enable':
-                $url =  PDF::get_watermark(null);
+                $url = PDF::get_watermark(null);
 
                 if ($url != false) {
-                    $delete_url = '<a href="?delete_watermark">'.get_lang('DelImage').' '.Display::return_icon('delete.png',get_lang('DelImage')).'</a>';
+                    $delete_url = '<a href="?delete_watermark">'.get_lang('DelImage').' '.Display::return_icon('delete.png', get_lang('DelImage')).'</a>';
                     $form->addElement('html', '<div style="max-height:100px; max-width:100px; margin-left:162px; margin-bottom:10px; clear:both;"><img src="'.$url.'" style="margin-bottom:10px;" />'.$delete_url.'</div>');
                 }
 
@@ -1670,7 +1670,7 @@ function showSearchToolsStatusTable()
     //@todo windows support
     if (api_is_windows_os() == false) {
         $list_of_programs = array('pdftotext', 'ps2pdf', 'catdoc', 'html2text', 'unrtf', 'catppt', 'xls2csv');
-        foreach($list_of_programs as $program) {
+        foreach ($list_of_programs as $program) {
             $output = [];
             $ret_val = null;
             exec("which $program", $output, $ret_val);
@@ -1683,7 +1683,7 @@ function showSearchToolsStatusTable()
             if (!empty($output[0])) {
                 $icon = Display::return_icon('bullet_green.png', get_lang('Installed'));
             }
-            $data2[]= array($program, $output[0], $icon);
+            $data2[] = array($program, $output[0], $icon);
         }
         echo Display::tag('h3', get_lang('ProgramsNeededToConvertFiles'));
         $table = new SortableTableFromArray($data2);
@@ -1715,11 +1715,11 @@ function generateCSSDownloadLink($style)
     if (is_dir($dir) && $check) {
         $zip = new PclZip($arch);
         // Remove path prefix except the style name and put file on disk
-        $zip->create($dir, PCLZIP_OPT_REMOVE_PATH, substr($dir,0,-strlen($style)));
-        $url = api_get_path(WEB_CODE_PATH) . 'course_info/download.php?archive_path=&archive=' . str_replace(api_get_path(SYS_ARCHIVE_PATH), '', $arch);
+        $zip->create($dir, PCLZIP_OPT_REMOVE_PATH, substr($dir, 0, -strlen($style)));
+        $url = api_get_path(WEB_CODE_PATH).'course_info/download.php?archive_path=&archive='.str_replace(api_get_path(SYS_ARCHIVE_PATH), '', $arch);
 
         //@TODO: use more generic script to download.
-        $str = '<a class="btn btn-primary btn-large" href="' .$url. '">'.get_lang('ClickHereToDownloadTheFile').'</a>';
+        $str = '<a class="btn btn-primary btn-large" href="'.$url.'">'.get_lang('ClickHereToDownloadTheFile').'</a>';
         Display::addFlash(Display::return_message($str, 'normal', false));
     } else {
         Display::addFlash(Display::return_message(get_lang('FileNotFound'), 'warning'));

+ 14 - 14
main/admin/specific_fields.php

@@ -15,36 +15,36 @@ require_once __DIR__.'/../inc/global.inc.php';
 api_protect_admin_script();
 
 // Breadcrumb
-$interbreadcrumb[] = array ('url' => 'index.php', 'name' => get_lang('PlatformAdmin'));
-$interbreadcrumb[] = array ('url' => 'settings.php?category=Search', 'name' => get_lang('PlatformConfigSettings'));
+$interbreadcrumb[] = array('url' => 'index.php', 'name' => get_lang('PlatformAdmin'));
+$interbreadcrumb[] = array('url' => 'settings.php?category=Search', 'name' => get_lang('PlatformConfigSettings'));
 
 $libpath = api_get_path(LIBRARY_PATH);
 
 include_once $libpath.'specific_fields_manager.lib.php';
 
 // Create an add-field box
-$form = new FormValidator('add_field','post','','',null,false);
-$renderer =& $form->defaultRenderer();
+$form = new FormValidator('add_field', 'post', '', '', null, false);
+$renderer = & $form->defaultRenderer();
 $renderer->setCustomElementTemplate('<span>{element}</span> ');
-$form->addElement('static','search_advanced_link',null,'<a href="specific_fields_add.php">'.Display::return_icon('fieldadd.gif').get_lang('AddSpecificSearchField').'</a>');
+$form->addElement('static', 'search_advanced_link', null, '<a href="specific_fields_add.php">'.Display::return_icon('fieldadd.gif').get_lang('AddSpecificSearchField').'</a>');
 
 // Create a sortable table with specific fields data
-$column_show = array(1,1,1);
-$column_order = array(3,2,1);
+$column_show = array(1, 1, 1);
+$column_order = array(3, 2, 1);
 $extra_fields = get_specific_field_list();
 $number_of_extra_fields = count($extra_fields);
 
-$table = new SortableTableFromArrayConfig($extra_fields,2,50,'',$column_show,$column_order);
-$table->set_header(0, '&nbsp;', false,null,'width="2%"', 'style="display:none"');
+$table = new SortableTableFromArrayConfig($extra_fields, 2, 50, '', $column_show, $column_order);
+$table->set_header(0, '&nbsp;', false, null, 'width="2%"', 'style="display:none"');
 $table->set_header(1, get_lang('Code'), true, 'width="10%"');
 $table->set_header(2, get_lang('Name'));
-$table->set_header(3, get_lang('Modify'),false,'width="10%"');
+$table->set_header(3, get_lang('Modify'), false, 'width="10%"');
 $table->set_column_filter(3, 'edit_filter');
 
-function edit_filter($id,$url_params,$row) {
+function edit_filter($id, $url_params, $row) {
 	global $charset;
-	$return = '<a href="specific_fields_add.php?action=edit&field_id='.$row[0].'">'.Display::return_icon('edit.gif',get_lang('Edit')).'</a>';
-	$return .= ' <a href="'.api_get_self().'?action=delete&field_id='.$row[0].'" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset))."'".')) return false;">'.Display::return_icon('delete.gif',get_lang('Delete')).'</a>';
+	$return = '<a href="specific_fields_add.php?action=edit&field_id='.$row[0].'">'.Display::return_icon('edit.gif', get_lang('Edit')).'</a>';
+	$return .= ' <a href="'.api_get_self().'?action=delete&field_id='.$row[0].'" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"), ENT_QUOTES, $charset))."'".')) return false;">'.Display::return_icon('delete.gif', get_lang('Delete')).'</a>';
 	return $return;
 }
 
@@ -60,7 +60,7 @@ if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'delete') {
 Display::display_header(get_lang('SpecificSearchFields'));
 echo Display::addFlash(Display::return_message(get_lang('SpecificSearchFieldsIntro')));
 
-if(!empty($_GET['message'])) {
+if (!empty($_GET['message'])) {
   Display::addFlash(Display::return_message($_GET['message'], 'confirm'));
 }
 

+ 35 - 35
main/admin/sub_language.php

@@ -11,7 +11,7 @@ require_once __DIR__.'/../inc/global.inc.php';
 $this_section = SECTION_PLATFORM_ADMIN;
 
 api_protect_admin_script();
-$htmlHeadXtra[] ='<script>
+$htmlHeadXtra[] = '<script>
  $(document).ready(function() {
     $(".save").click(function() {
         var button_name=$(this).attr("name");
@@ -36,20 +36,20 @@ $htmlHeadXtra[] ='<script>
                     \'new_language\': is_new_language,
                     \'variable_language\': is_variable_language,
                     \'file_id\': file_id,
-                    \'id\': ' . intval($_REQUEST['id']) . ',
-                    \'sub\': ' . intval($_REQUEST['sub_language_id']) . ',
-                    \'sub_language_id\': ' . intval($_REQUEST['sub_language_id']) . '
+                    \'id\': ' . intval($_REQUEST['id']).',
+                    \'sub\': ' . intval($_REQUEST['sub_language_id']).',
+                    \'sub_language_id\': ' . intval($_REQUEST['sub_language_id']).'
                 },
                 success: function(datos) {
                     if (datos == "1") {
-                        $("#div_message_information_id").html(\'' . Display::return_message(get_lang('TheNewWordHasBeenAdded'), 'success') . '\');
+                        $("#div_message_information_id").html(\'' . Display::return_message(get_lang('TheNewWordHasBeenAdded'), 'success').'\');
                     } else {
                         $("#div_message_information_id").html("<div class=\"alert alert-warning\">" + datos +"</div>");
                     }
                 }
             });
         } else {
-            $("#div_message_information_id").html(\'' . Display::return_message(get_lang('FormHasErrorsPleaseComplete'), 'error') . '\');
+            $("#div_message_information_id").html(\'' . Display::return_message(get_lang('FormHasErrorsPleaseComplete'), 'error').'\');
         }
     });
 });
@@ -61,14 +61,14 @@ $htmlHeadXtra[] ='<script>
 // setting the name of the tool
 $tool_name = get_lang('CreateSubLanguage');
 // setting breadcrumbs
-$interbreadcrumb[] = array ('url' => 'index.php', 'name' => get_lang('PlatformAdmin'));
-$interbreadcrumb[] = array ('url' => 'languages.php', 'name' => get_lang('PlatformLanguages'));
+$interbreadcrumb[] = array('url' => 'index.php', 'name' => get_lang('PlatformAdmin'));
+$interbreadcrumb[] = array('url' => 'languages.php', 'name' => get_lang('PlatformLanguages'));
 
 $sublanguage_folder_error = false;
 
 if (isset($_GET['id']) && $_GET['id'] == strval(intval($_GET['id']))) {
-    $language_name = SubLanguageManager::get_name_of_language_by_id ($_GET['id']);
-    $sub_language_name = SubLanguageManager::get_name_of_language_by_id ($_GET['sub_language_id']);
+    $language_name = SubLanguageManager::get_name_of_language_by_id($_GET['id']);
+    $sub_language_name = SubLanguageManager::get_name_of_language_by_id($_GET['sub_language_id']);
     $all_data_of_language = SubLanguageManager::get_all_information_of_language($_GET['id']);
     $all_data_of_sublanguage = SubLanguageManager::get_all_information_of_language($_GET['sub_language_id']);
     $sub_language_file = api_get_path(SYS_LANG_PATH).$all_data_of_sublanguage['dokeos_folder'];
@@ -76,20 +76,20 @@ if (isset($_GET['id']) && $_GET['id'] == strval(intval($_GET['id']))) {
     if (!file_exists($sub_language_file) || !is_writable($sub_language_file)) {
         $sublanguage_folder_error = $sub_language_file.' '.get_lang('IsNotWritable');
     }
-    if (SubLanguageManager::check_if_exist_language_by_id($_GET['id'])===true) {
+    if (SubLanguageManager::check_if_exist_language_by_id($_GET['id']) === true) {
         $language_id_exist = true;
     } else {
         $language_id_exist = false;
     }
 } else {
-    $language_name='';
-    $language_id_exist=false;
+    $language_name = '';
+    $language_id_exist = false;
 }
 
 $intro = sprintf(get_lang('RegisterTermsOfSubLanguageForX'), strtolower($sub_language_name));
 $path_folder = api_get_path(SYS_LANG_PATH).$all_data_of_language['dokeos_folder'];
 
-if (!is_dir($path_folder) || strlen($all_data_of_language['dokeos_folder'])==0) {
+if (!is_dir($path_folder) || strlen($all_data_of_language['dokeos_folder']) == 0) {
     api_not_allowed(true);
 }
 
@@ -102,16 +102,16 @@ printf(get_lang('ParentLanguageX'), $language_name);
 echo '</div>';
 echo '<br />';
 $txt_search_word = (!empty($_REQUEST['txt_search_word']) ? Security::remove_XSS($_REQUEST['txt_search_word']) : '');
-$html ='<div style="float:left" class="actions">';
-$html.='<form style="float:left"  id="Searchlanguage" name="Searchlanguage" method="GET" action="sub_language.php">';
-$html.='&nbsp;'.get_lang('OriginalName').'&nbsp; :&nbsp;';
+$html = '<div style="float:left" class="actions">';
+$html .= '<form style="float:left"  id="Searchlanguage" name="Searchlanguage" method="GET" action="sub_language.php">';
+$html .= '&nbsp;'.get_lang('OriginalName').'&nbsp; :&nbsp;';
 
-$html.='<input name="id" type="hidden"  id="id" value="'.Security::remove_XSS($_REQUEST['id']).'" />';
-$html.='<input name="sub_language_id" type="hidden"  id="id" value="'.Security::remove_XSS($_REQUEST['sub_language_id']).'" />';
-$html.='<input name="txt_search_word" type="text" size="50"  id="txt_search_word" value="'.$txt_search_word.'" />';
-$html.="&nbsp;".'<button name="SubmitSearchLanguage" class="search" type="submit">'.get_lang('Search').'</button>';
-$html.='</form>';
-$html.='</div>';
+$html .= '<input name="id" type="hidden"  id="id" value="'.Security::remove_XSS($_REQUEST['id']).'" />';
+$html .= '<input name="sub_language_id" type="hidden"  id="id" value="'.Security::remove_XSS($_REQUEST['sub_language_id']).'" />';
+$html .= '<input name="txt_search_word" type="text" size="50"  id="txt_search_word" value="'.$txt_search_word.'" />';
+$html .= "&nbsp;".'<button name="SubmitSearchLanguage" class="search" type="submit">'.get_lang('Search').'</button>';
+$html .= '</form>';
+$html .= '</div>';
 echo $html;
 echo '<br /><br /><br />';
 if (!empty($sublanguage_folder_error)) {
@@ -147,7 +147,7 @@ function search_language_term(
     $language_files_to_load_keys = array_flip($language_files_to_load);
     $array_to_search = $parent_language_array;
     $list_info = array();
-    $term='/'.Security::remove_XSS(trim($_REQUEST['txt_search_word'])).'/i';
+    $term = '/'.Security::remove_XSS(trim($_REQUEST['txt_search_word'])).'/i';
     //@todo optimize this foreach
     foreach ($language_files_to_load as $lang_file) {
         //searching in parent language of the sub language
@@ -176,11 +176,11 @@ function search_language_term(
                         $size =4;
                     }*/
 
-                    $obj_text='<textarea rows="10" cols="40" name="txt|'.$parent_name_variable.'|'.$language_files_to_load_keys[$lang_file].'" id="txtid_'.$language_files_to_load_keys[$lang_file].'_'.$parent_name_variable.'" >'.$sub_language_name_variable.'</textarea>';
-                    $obj_button='<button class="save" type="button" name="btn|'.$parent_name_variable.'|'.$language_files_to_load_keys[$lang_file].'" id="btnid_'.$parent_name_variable.'"  />'.get_lang('Save').'</button>';
+                    $obj_text = '<textarea rows="10" cols="40" name="txt|'.$parent_name_variable.'|'.$language_files_to_load_keys[$lang_file].'" id="txtid_'.$language_files_to_load_keys[$lang_file].'_'.$parent_name_variable.'" >'.$sub_language_name_variable.'</textarea>';
+                    $obj_button = '<button class="save" type="button" name="btn|'.$parent_name_variable.'|'.$language_files_to_load_keys[$lang_file].'" id="btnid_'.$parent_name_variable.'"  />'.get_lang('Save').'</button>';
 
                     $list_info[] = array(
-                        $lang_file . '.inc.php',
+                        $lang_file.'.inc.php',
                         $parent_name_variable,
                         $english_name_variable,
                         $parent_variable_value,
@@ -231,16 +231,16 @@ function search_language_term(
                         $parent_variable_value = $parent_language_array[$lang_file][$name_variable];
                     }
                     //config buttons
-                    $obj_text='<textarea rows="10" cols="40" name="txt|'.$name_variable.'|'.$language_files_to_load_keys[$lang_file].'" id="txtid_'.$language_files_to_load_keys[$lang_file].'_'.$name_variable.'" >'.
+                    $obj_text = '<textarea rows="10" cols="40" name="txt|'.$name_variable.'|'.$language_files_to_load_keys[$lang_file].'" id="txtid_'.$language_files_to_load_keys[$lang_file].'_'.$name_variable.'" >'.
                         $sub_language_name_variable.'
                         </textarea>';
-                    $obj_button='<button class="save" type="button" name="btn|'.$name_variable.'|'.$language_files_to_load_keys[$lang_file].'" id="btnid_'.$name_variable.'"  />'.get_lang('Save').'</button>';
+                    $obj_button = '<button class="save" type="button" name="btn|'.$name_variable.'|'.$language_files_to_load_keys[$lang_file].'" id="btnid_'.$name_variable.'"  />'.get_lang('Save').'</button>';
 
                     //loading variable from the english array
                     $english_name_variable = $english_language_array[$lang_file][$name_variable];
 
                     $list_info[] = array(
-                        $lang_file . '.inc.php',
+                        $lang_file.'.inc.php',
                         $name_variable,
                         $english_name_variable,
                         $parent_variable_value,
@@ -273,15 +273,15 @@ function search_language_term(
                     $sub_language_name_variable = $sub_language_array[$lang_file][$name_variable];
                     $parent_variable_value = $parent_language_array[$lang_file][$name_variable];
                     //config buttons
-                    $obj_text='<textarea rows="10" cols="40" name="txt|'.$name_variable.'|'.$language_files_to_load_keys[$lang_file].'" id="txtid_'.$language_files_to_load_keys[$lang_file].'_'.$name_variable.'" >'.$sub_language_name_variable.'</textarea>';
-                    $obj_button='<button class="save" type="button" name="btn|'.$name_variable.'|'.$language_files_to_load_keys[$lang_file].'" id="btnid_'.$name_variable.'"  />'.get_lang('Save').'</button>';
+                    $obj_text = '<textarea rows="10" cols="40" name="txt|'.$name_variable.'|'.$language_files_to_load_keys[$lang_file].'" id="txtid_'.$language_files_to_load_keys[$lang_file].'_'.$name_variable.'" >'.$sub_language_name_variable.'</textarea>';
+                    $obj_button = '<button class="save" type="button" name="btn|'.$name_variable.'|'.$language_files_to_load_keys[$lang_file].'" id="btnid_'.$name_variable.'"  />'.get_lang('Save').'</button>';
 
                     //loading variable from the english array
                     $english_name_variable = $english_language_array[$lang_file][$name_variable];
-                    $list_info[]=array($lang_file.'.inc.php',
+                    $list_info[] = array($lang_file.'.inc.php',
                         $name_variable,
                         $english_name_variable,
-                        $parent_variable_value,$obj_text,$obj_button);
+                        $parent_variable_value, $obj_text, $obj_button);
                 }
             }
         }
@@ -295,7 +295,7 @@ function search_language_term(
 $list_info = array();
 if (isset($_REQUEST['txt_search_word'])) {
     //@todo fix to accept a char with 1 char
-    if (strlen(trim($_REQUEST['txt_search_word']))>2) {
+    if (strlen(trim($_REQUEST['txt_search_word'])) > 2) {
         $list_info = search_language_term(
             $_REQUEST['txt_search_word'],
             true,

+ 92 - 92
main/auth/ldap/authldap.php

@@ -78,16 +78,16 @@ function ldap_login($login, $password) {
     // res=-1 -> the user does not exist in the ldap database
     // res=1 -> invalid password (user does exist)
 
-    if ($res==1) { //WRONG PASSWORD
+    if ($res == 1) { //WRONG PASSWORD
         //$errorMessage = "LDAP User or password incorrect, try again.<br />";
         if (isset($log)) unset($log); if (isset($uid)) unset($uid);
         $loginLdapSucces = false;
     }
-    if ($res==-1) { //WRONG USERNAME
+    if ($res == -1) { //WRONG USERNAME
         //$errorMessage =  "LDAP User or password incorrect, try again.<br />";
         $login_ldap_success = false;
     }
-    if ($res==0) { //LOGIN & PASSWORD OK - SUCCES
+    if ($res == 0) { //LOGIN & PASSWORD OK - SUCCES
         //$errorMessage = "Successful login w/ LDAP.<br>";
         $login_ldap_success = true;
     }
@@ -103,30 +103,30 @@ function ldap_login($login, $password) {
  *    @author Stefan De Wannemacker
  *    @author Roan Embrechts
  */
-function ldap_find_user_info ($login) {
+function ldap_find_user_info($login) {
     //error_log('Entering ldap_find_user_info('.$login.')',0);
     global $ldap_host, $ldap_port, $ldap_basedn, $ldap_rdn, $ldap_pass, $ldap_search_dn;
     // basic sequence with LDAP is connect, bind, search,
     // interpret search result, close connection
 
     //echo "Connecting ...";
-    $ldap_connect = ldap_connect( $ldap_host, $ldap_port);
+    $ldap_connect = ldap_connect($ldap_host, $ldap_port);
     ldap_set_version($ldap_connect);
     if ($ldap_connect) {
         //echo " Connect to LDAP server successful ";
         //echo "Binding ...";
         $ldap_bind = false;
-        $ldap_bind_res = ldap_handle_bind($ldap_connect,$ldap_bind);
+        $ldap_bind_res = ldap_handle_bind($ldap_connect, $ldap_bind);
         if ($ldap_bind_res) {
             //echo " LDAP bind successful... ";
             //echo " Searching for uid... ";
             // Search surname entry
             //OLD: $sr=ldap_search($ldapconnect,"dc=rug, dc=ac, dc=be", "uid=$login");
             //echo "<p> ldapDc = '$LDAPbasedn' </p>";
-            if(!empty($ldap_search_dn)) {
-                $sr=ldap_search($ldap_connect, $ldap_search_dn, "uid=$login");
+            if (!empty($ldap_search_dn)) {
+                $sr = ldap_search($ldap_connect, $ldap_search_dn, "uid=$login");
             } else {
-                $sr=ldap_search($ldap_connect, $ldap_basedn, "uid=$login");
+                $sr = ldap_search($ldap_connect, $ldap_basedn, "uid=$login");
             }
             //echo " Search result is ".$sr;
             //echo " Number of entries returned is ".ldap_count_entries($ldapconnect,$sr);
@@ -173,25 +173,25 @@ function ldap_put_user_info_locally($login, $info_array) {
     $password1  = $ldap_pass_placeholder;
     $official_code = '';
 
-    define ("STUDENT",5);
-    define ("COURSEMANAGER",1);
+    define("STUDENT", 5);
+    define("COURSEMANAGER", 1);
 
     $tutor_field = api_get_setting('ldap_filled_tutor_field');
     $tutor_value = api_get_setting('ldap_filled_tutor_field_value');
-    if(empty($tutor_field)) {
+    if (empty($tutor_field)) {
         $status = STUDENT;
     } else {
-        if(empty($tutor_value)) {
+        if (empty($tutor_value)) {
             //in this case, we are assuming that the admin didn't give a criteria
             // so that if the field is not empty, it is a tutor
-            if(!empty($info_array[$tutor_field])) {
+            if (!empty($info_array[$tutor_field])) {
                 $status = COURSEMANAGER;
             } else {
                 $status = STUDENT;
             }
         } else {
             //the tutor_value is filled, so we need to check the contents of the LDAP field
-            if (is_array($info_array[$tutor_field]) && in_array($tutor_value,$info_array[$tutor_field])) {
+            if (is_array($info_array[$tutor_field]) && in_array($tutor_value, $info_array[$tutor_field])) {
                 $status = COURSEMANAGER;
             } else {
                 $status = STUDENT;
@@ -208,7 +208,7 @@ function ldap_put_user_info_locally($login, $info_array) {
     if (empty($language)) { $language = 'english'; }
     $_userId = UserManager::create_user($prenom, $nom, $status,
                      $email, $uname, $password, $official_code,
-                     $language,'', '', 'ldap');
+                     $language, '', '', 'ldap');
 
     //echo "new user added to Chamilo, id = $_userId";
 
@@ -242,56 +242,56 @@ function ldap_put_user_info_locally($login, $info_array) {
  * @param string password given by user
  * @return int 0 if authentication succeeded, 1 if password was incorrect, -1 if it didn't belong to LDAP
  */
-function ldap_authentication_check ($uname, $passwd) {
+function ldap_authentication_check($uname, $passwd) {
     //error_log('Entering ldap_authentication_check('.$uname.','.$passwd.')',0);
-    global $ldap_host, $ldap_port, $ldap_basedn, $ldap_host2, $ldap_port2,$ldap_rdn,$ldap_pass;
+    global $ldap_host, $ldap_port, $ldap_basedn, $ldap_host2, $ldap_port2, $ldap_rdn, $ldap_pass;
     //error_log('Entering ldap_authentication_check('.$uname.','.$passwd.')',0);
     // Establish anonymous connection with LDAP server
     // Etablissement de la connexion anonyme avec le serveur LDAP
-    $ds=ldap_connect($ldap_host,$ldap_port);
+    $ds = ldap_connect($ldap_host, $ldap_port);
     ldap_set_version($ds);
 
     $test_bind = false;
-    $test_bind_res = ldap_handle_bind($ds,$test_bind);
+    $test_bind_res = ldap_handle_bind($ds, $test_bind);
     //if problem, use the replica
-    if ($test_bind_res===false) {
-        $ds=ldap_connect($ldap_host2,$ldap_port2);
+    if ($test_bind_res === false) {
+        $ds = ldap_connect($ldap_host2, $ldap_port2);
         ldap_set_version($ds);
     } // else: error_log('Connected to server '.$ldap_host);
-    if ($ds!==false) {
+    if ($ds !== false) {
         //Creation of filter containing values input by the user
         // Here it might be necessary to use $filter="(samaccountName=$uname)"; - see http://support.chamilo.org/issues/4675
-        $filter="(uid=$uname)";
+        $filter = "(uid=$uname)";
         // Open anonymous LDAP connection
-        $result=false;
-        $ldap_bind_res = ldap_handle_bind($ds,$result);
+        $result = false;
+        $ldap_bind_res = ldap_handle_bind($ds, $result);
 	// Executing the search with the $filter parametr
         //error_log('Searching for '.$filter.' on LDAP server',0);
-        $sr=ldap_search($ds,$ldap_basedn,$filter);
+        $sr = ldap_search($ds, $ldap_basedn, $filter);
         $info = ldap_get_entries($ds, $sr);
-        $dn=($info[0]["dn"]);
+        $dn = ($info[0]["dn"]);
         // debug !!    echo"<br> dn = $dn<br> pass = $passwd<br>";
         // closing 1st connection
         ldap_close($ds);
     }
 
     // test the Distinguish Name from the 1st connection
-    if ($dn=="") {
-        return (-1);        // doesn't belong to the addressbook
+    if ($dn == "") {
+        return (-1); // doesn't belong to the addressbook
     }
     //bug ldap.. if password empty, return 1!
-    if ($passwd=="") {
+    if ($passwd == "") {
         return(1);
     }
     // Opening 2nd LDAP connection : Connection user for password check
-    $ds=ldap_connect($ldap_host,$ldap_port);
+    $ds = ldap_connect($ldap_host, $ldap_port);
     ldap_set_version($ds);
     if (!$test_bind) {
-        $ds=ldap_connect($ldap_host2,$ldap_port2);
+        $ds = ldap_connect($ldap_host2, $ldap_port2);
         ldap_set_version($ds);
     }
     // return in case of wrong password connection error
-    if (@ldap_bind( $ds, $dn , $passwd) === false) {
+    if (@ldap_bind($ds, $dn, $passwd) === false) {
         return (1); // invalid password
     } else {// connection successfull
         return (0);
@@ -305,7 +305,7 @@ function ldap_authentication_check ($uname, $passwd) {
 function ldap_set_version(&$resource) {
     //error_log('Entering ldap_set_version(&$resource)',0);
     global $ldap_version;
-    if ($ldap_version>2) {
+    if ($ldap_version > 2) {
         ldap_set_option($resource, LDAP_OPT_PROTOCOL_VERSION, 3);
         //ok - don't do anything
         //failure - should switch back to version 2 by default
@@ -318,14 +318,14 @@ function ldap_set_version(&$resource) {
  * @param boolean $ldap_bind
  * @return    boolean        Status of the bind assignment. True for success, false for failure.
  */
-function ldap_handle_bind(&$ldap_handler,&$ldap_bind) {
+function ldap_handle_bind(&$ldap_handler, &$ldap_bind) {
     //error_log('Entering ldap_handle_bind(&$ldap_handler,&$ldap_bind)',0);
-    global $ldap_rdn,$ldap_pass, $extldap_config;
+    global $ldap_rdn, $ldap_pass, $extldap_config;
     $ldap_rdn = $extldap_config['admin_dn'];
     $ldap_pass = $extldap_config['admin_password'];
     if (!empty($ldap_rdn) and !empty($ldap_pass)) {
         //error_log('Trying authenticated login :'.$ldap_rdn.'/'.$ldap_pass,0);
-        $ldap_bind = ldap_bind($ldap_handler,$ldap_rdn,$ldap_pass);
+        $ldap_bind = ldap_bind($ldap_handler, $ldap_rdn, $ldap_pass);
         if (!$ldap_bind) {
             //error_log('Authenticated login failed',0);
             //try in anonymous mode, you never know...
@@ -351,40 +351,40 @@ function ldap_get_users() {
 
     global $ldap_basedn, $ldap_host, $ldap_port, $ldap_rdn, $ldap_pass, $ldap_search_dn, $extldap_user_correspondance;
 
-    $keyword_firstname = isset($_GET['keyword_firstname']) ? trim(Database::escape_string($_GET['keyword_firstname'])): '';
+    $keyword_firstname = isset($_GET['keyword_firstname']) ? trim(Database::escape_string($_GET['keyword_firstname'])) : '';
     $keyword_lastname = isset($_GET['keyword_lastname']) ? trim(Database::escape_string($_GET['keyword_lastname'])) : '';
     $keyword_username = isset($_GET['keyword_username']) ? trim(Database::escape_string($_GET['keyword_username'])) : '';
     $keyword_type = isset($_GET['keyword_type']) ? Database::escape_string($_GET['keyword_type']) : '';
 
-    $ldap_query=array();
+    $ldap_query = array();
 
     if ($keyword_username != "") {
         $ldap_query[] = str_replace('%username%', $keyword_username, $ldap_search_dn);
     } else {
-        if ($keyword_lastname!=""){
-            $ldap_query[]="(".$extldap_user_correspondance['lastname']."=".$keyword_lastname."*)";
+        if ($keyword_lastname != "") {
+            $ldap_query[] = "(".$extldap_user_correspondance['lastname']."=".$keyword_lastname."*)";
         }
-        if ($keyword_firstname!="") {
-            $ldap_query[]="(".$extldap_user_correspondance['firstname']."=".$keyword_firstname."*)";
+        if ($keyword_firstname != "") {
+            $ldap_query[] = "(".$extldap_user_correspondance['firstname']."=".$keyword_firstname."*)";
         }
     }
-    if ($keyword_type !="" && $keyword_type !="all") {
-        $ldap_query[]="(employeeType=".$keyword_type.")";
+    if ($keyword_type != "" && $keyword_type != "all") {
+        $ldap_query[] = "(employeeType=".$keyword_type.")";
     }
 
-    if (count($ldap_query)>1){
-        $str_query ="(& ";
-        foreach ($ldap_query as $query){
-            $str_query.=" $query";
+    if (count($ldap_query) > 1) {
+        $str_query = "(& ";
+        foreach ($ldap_query as $query) {
+            $str_query .= " $query";
         }
-        $str_query.=" )";
+        $str_query .= " )";
     } else {
-        $str_query= count($ldap_query) > 0 ? $ldap_query[0] : null;
+        $str_query = count($ldap_query) > 0 ? $ldap_query[0] : null;
     }
 
     $ds = ldap_connect($ldap_host, $ldap_port);
     ldap_set_version($ds);
-    if ($ds && count($ldap_query)>0) {
+    if ($ds && count($ldap_query) > 0) {
         $r = false;
         $res = ldap_handle_bind($ds, $r);
         //$sr = ldap_search($ds, "ou=test-ou,$ldap_basedn", $str_query);
@@ -394,7 +394,7 @@ function ldap_get_users() {
         return $info;
 
     } else {
-        if (count($ldap_query)!=0)
+        if (count($ldap_query) != 0)
             Display :: display_error_message(get_lang('LDAPConnectionError'));
         return array();
     }
@@ -407,7 +407,7 @@ function ldap_get_users() {
  */
 function ldap_get_number_of_users() {
     $info = ldap_get_users();
-    if (count($info)>0) {
+    if (count($info) > 0) {
         return $info['count'];
     } else {
         return 0;
@@ -427,9 +427,9 @@ function ldap_get_user_data($from, $number_of_items, $column, $direction) {
     $is_western_name_order = api_is_western_name_order();
     if (isset($_GET['submit'])) {
         $info = ldap_get_users();
-        if ($info['count']>0) {
-            for ($key = 0; $key < $info["count"]; $key ++) {
-                $user=array();
+        if ($info['count'] > 0) {
+            for ($key = 0; $key < $info["count"]; $key++) {
+                $user = array();
                 // Get uid from dn
                 //YW: this might be a variation between LDAP 2 and LDAP 3, but in LDAP 3, the uid is in
                 //the corresponding index of the array
@@ -463,9 +463,9 @@ function ldap_get_user_data($from, $number_of_items, $column, $direction) {
  * @return string Some HTML-code with modify-buttons
  * @author    Mustapha Alouani
  */
-function modify_filter($user_id,$url_params, $row) {
-    $query_string="id[]=".$row[0];
-    if (!empty($_GET['id_session'])){
+function modify_filter($user_id, $url_params, $row) {
+    $query_string = "id[]=".$row[0];
+    if (!empty($_GET['id_session'])) {
         $query_string .= '&amp;id_session='.Security::remove_XSS($_GET['id_session']);
     }
     //$url_params_id="id=".$row[0];
@@ -490,7 +490,7 @@ function ldap_add_user_by_array($data, $update_if_exists = true) {
     $firstname = api_convert_encoding($data['cn'][0], api_get_system_encoding(), 'UTF-8');
     $email = $data['mail'][0];
     // Get uid from dn
-    $dn_array=ldap_explode_dn($data['dn'],1);
+    $dn_array = ldap_explode_dn($data['dn'], 1);
     $username = $dn_array[0]; // uid is first key
     $outab[] = $data['edupersonprimaryaffiliation'][0]; // Here, "student"
     //$val = ldap_get_values_len($ds, $entry, "userPassword");
@@ -498,29 +498,29 @@ function ldap_add_user_by_array($data, $update_if_exists = true) {
     //$password = $val[0];
     // TODO the password, if encrypted at the source, will be encrypted twice, which makes it useless. Try to fix that.
     $password = $data['userPassword'][0];
-    $structure=$data['edupersonprimaryorgunitdn'][0];
-    $array_structure=explode(",", $structure);
-    $array_val=explode("=", $array_structure[0]);
-    $etape=$array_val[1];
-    $array_val=explode("=", $array_structure[1]);
-    $annee=$array_val[1];
+    $structure = $data['edupersonprimaryorgunitdn'][0];
+    $array_structure = explode(",", $structure);
+    $array_val = explode("=", $array_structure[0]);
+    $etape = $array_val[1];
+    $array_val = explode("=", $array_structure[1]);
+    $annee = $array_val[1];
     // To ease management, we add the step-year (etape-annee) code
-    $official_code=$etape."-".$annee;
-    $auth_source='ldap';
+    $official_code = $etape."-".$annee;
+    $auth_source = 'ldap';
     // No expiration date for students (recover from LDAP's shadow expiry)
-    $expiration_date='';
-    $active=1;
-    if(empty($status)){$status = 5;}
-    if(empty($phone)){$phone = '';}
-    if(empty($picture_uri)){$picture_uri = '';}
+    $expiration_date = '';
+    $active = 1;
+    if (empty($status)) {$status = 5; }
+    if (empty($phone)) {$phone = ''; }
+    if (empty($picture_uri)) {$picture_uri = ''; }
     // Adding user
     $user_id = 0;
     if (UserManager::is_username_available($username)) {
-        $user_id = UserManager::create_user($firstname,$lastname,$status,$email,$username,$password,$official_code,api_get_setting('platformLanguage'),$phone,$picture_uri,$auth_source,$expiration_date,$active);
+        $user_id = UserManager::create_user($firstname, $lastname, $status, $email, $username, $password, $official_code, api_get_setting('platformLanguage'), $phone, $picture_uri, $auth_source, $expiration_date, $active);
     } else {
         if ($update_if_exists) {
             $user = api_get_user_info($username);
-            $user_id=$user['user_id'];
+            $user_id = $user['user_id'];
             UserManager::update_user($user_id, $firstname, $lastname, $username, null, null, $email, $status, $official_code, $phone, $picture_uri, $expiration_date, $active);
         }
     }
@@ -537,21 +537,21 @@ function ldap_add_user_to_session($UserList, $id_session) {
 
     // Database Table Definitions
     $tbl_session                        = Database::get_main_table(TABLE_MAIN_SESSION);
-    $tbl_session_rel_class                = Database::get_main_table(TABLE_MAIN_SESSION_CLASS);
+    $tbl_session_rel_class = Database::get_main_table(TABLE_MAIN_SESSION_CLASS);
     $tbl_session_rel_course                = Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
     $tbl_session_rel_course_rel_user    = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
     $tbl_course                            = Database::get_main_table(TABLE_MAIN_COURSE);
     $tbl_user                            = Database::get_main_table(TABLE_MAIN_USER);
     $tbl_session_rel_user                = Database::get_main_table(TABLE_MAIN_SESSION_USER);
-    $tbl_class                            = Database::get_main_table(TABLE_MAIN_CLASS);
-    $tbl_class_user                        = Database::get_main_table(TABLE_MAIN_CLASS_USER);
+    $tbl_class = Database::get_main_table(TABLE_MAIN_CLASS);
+    $tbl_class_user = Database::get_main_table(TABLE_MAIN_CLASS_USER);
 
     $id_session = (int) $id_session;
     // Once users are imported in the users base, we can assign them to the session
-    $result=Database::query("SELECT c_id FROM $tbl_session_rel_course WHERE session_id ='$id_session'");
-    $CourseList=array();
-    while ($row=Database::fetch_array($result)) {
-        $CourseList[]=$row['c_id'];
+    $result = Database::query("SELECT c_id FROM $tbl_session_rel_course WHERE session_id ='$id_session'");
+    $CourseList = array();
+    while ($row = Database::fetch_array($result)) {
+        $CourseList[] = $row['c_id'];
     }
     foreach ($CourseList as $enreg_course) {
         foreach ($UserList as $enreg_user) {
@@ -562,21 +562,21 @@ function ldap_add_user_to_session($UserList, $id_session) {
               "('$id_session','$enreg_course','$enreg_user')");
         }
         $sql = "SELECT COUNT(user_id) as nbUsers ".
-               " FROM $tbl_session_rel_course_rel_user " .
+               " FROM $tbl_session_rel_course_rel_user ".
                " WHERE session_id='$id_session' ".
                " AND c_id='$enreg_course'";
         $rs = Database::query($sql);
         list($nbr_users) = Database::fetch_array($rs);
         Database::query("UPDATE $tbl_session_rel_course  ".
-               " SET nbr_users=$nbr_users " .
+               " SET nbr_users=$nbr_users ".
                " WHERE session_id='$id_session' ".
                " AND c_id='$enreg_course'");
     }
     foreach ($UserList as $enreg_user) {
         $enreg_user = (int) $enreg_user;
         Database::query("INSERT IGNORE INTO $tbl_session_rel_user ".
-               " (session_id, user_id, registered_at) " .
-               " VALUES('$id_session','$enreg_user', '" . api_get_utc_datetime() . "')");
+               " (session_id, user_id, registered_at) ".
+               " VALUES('$id_session','$enreg_user', '".api_get_utc_datetime()."')");
     }
     // We update the number of users in the session
     $sql = "SELECT COUNT(user_id) as nbUsers FROM $tbl_session_rel_user ".
@@ -591,13 +591,13 @@ function ldap_add_user_to_session($UserList, $id_session) {
 function syncro_users() {
     global $ldap_basedn, $ldap_host, $ldap_port, $ldap_rdn, $ldap_pass, $ldap_search_dn;
     echo "Connecting ...";
-    $ldap_connect = ldap_connect( $ldap_host, $ldap_port);
+    $ldap_connect = ldap_connect($ldap_host, $ldap_port);
     ldap_set_version($ldap_connect);
     if ($ldap_connect) {
         //echo " Connect to LDAP server successful ";
         //echo "Binding ...";
         $ldap_bind = false;
-        $ldap_bind_res = ldap_handle_bind($ldap_connect,$ldap_bind);
+        $ldap_bind_res = ldap_handle_bind($ldap_connect, $ldap_bind);
         if ($ldap_bind_res) {
             //echo " LDAP bind successful... ";
             //echo " Searching for uid... ";
@@ -605,7 +605,7 @@ function syncro_users() {
             //OLD: $sr=ldap_search($ldapconnect,"dc=rug, dc=ac, dc=be", "uid=$login");
             //echo "<p> ldapDc = '$LDAPbasedn' </p>";
             $all_user_query = "uid=*";
-            if(!empty($ldap_search_dn)) {
+            if (!empty($ldap_search_dn)) {
                 $sr = ldap_search($ldap_connect, $ldap_search_dn, $all_user_query);
             } else {
                 $sr = ldap_search($ldap_connect, $ldap_basedn, $all_user_query);
@@ -613,7 +613,7 @@ function syncro_users() {
             //echo " Number of entries returned is ".ldap_count_entries($ldapconnect,$sr);
             //echo " Getting entries ...";
             $info = ldap_get_entries($ldap_connect, $sr);
-            for ($key = 0; $key < $info['count']; $key ++) {
+            for ($key = 0; $key < $info['count']; $key++) {
                 $user_id = ldap_add_user_by_array($info[$key], false);
                 if ($user_id) {
                     echo "User #$user_id created ";

+ 1 - 1
main/gradebook/gradebook_view_result.php

@@ -503,7 +503,7 @@ if (isset($_GET['import_user_error'])) {
 }
 if (isset($_GET['import_score_error'])) {
     $userinfo = api_get_user_info($_GET['import_score_error']);
-    Display::addFlash(Display::return_message(get_lang('ScoreDoesNotMatch'). ' ' . api_get_person_name($userinfo['firstname'], $userinfo['lastname']), 'warning'));
+    Display::addFlash(Display::return_message(get_lang('ScoreDoesNotMatch').' '.api_get_person_name($userinfo['firstname'], $userinfo['lastname']), 'warning'));
 }
 if ($file_type == null) {
     //show the result header

+ 24 - 24
main/inc/introductionSection.inc.php

@@ -212,7 +212,7 @@ if ($tool == TOOL_COURSE_HOMEPAGE && !isset($_GET['intro_cmdEdit'])) {
     if ($displayMode == '1') {
         // Show only the current course progress step
         // $information_title = get_lang('InfoAboutLastDoneAdvance');
-        $last_done_advance =  $thematic->get_last_done_thematic_advance();
+        $last_done_advance = $thematic->get_last_done_thematic_advance();
         $thematic_advance_info = $thematic->get_thematic_advance_list($last_done_advance);
         $subTitle1 = get_lang('CurrentTopic');
         $class1 = ' current';
@@ -227,7 +227,7 @@ if ($tool == TOOL_COURSE_HOMEPAGE && !isset($_GET['intro_cmdEdit'])) {
     } else if ($displayMode == '3') {
         // Show the current and next course progress steps
         // $information_title = get_lang('InfoAboutLastDoneAdvanceAndNextAdvanceNotDone');
-        $last_done_advance =  $thematic->get_last_done_thematic_advance();
+        $last_done_advance = $thematic->get_last_done_thematic_advance();
         $next_advance_not_done = $thematic->get_next_thematic_advance_not_done();
         $thematic_advance_info = $thematic->get_thematic_advance_list($last_done_advance);
         $thematic_advance_info2 = $thematic->get_thematic_advance_list($next_advance_not_done);
@@ -238,7 +238,7 @@ if ($tool == TOOL_COURSE_HOMEPAGE && !isset($_GET['intro_cmdEdit'])) {
 
     if (!empty($thematic_advance_info)) {
         $thematic_advance = get_lang('CourseThematicAdvance');
-        $thematicScore = $thematic->get_total_average_of_thematic_advances() . '%';
+        $thematicScore = $thematic->get_total_average_of_thematic_advances().'%';
         $thematicUrl = api_get_path(WEB_CODE_PATH).'course_progress/index.php?action=thematic_details&'.api_get_cidreq();
         $thematic_info = $thematic->get_thematic_list(
             $thematic_advance_info['thematic_id']
@@ -253,11 +253,11 @@ if ($tool == TOOL_COURSE_HOMEPAGE && !isset($_GET['intro_cmdEdit'])) {
         );
         $userInfo = api_get_user_info();
         $courseInfo = api_get_course_info();
-        $titleThematic = $thematic_advance .' : '. $courseInfo['name'] . ' <b>( '. $thematicScore .' )</b>';
+        $titleThematic = $thematic_advance.' : '.$courseInfo['name'].' <b>( '.$thematicScore.' )</b>';
 
-        $infoUser = '<div class="thematic-avatar"><img src="' . $userInfo['avatar'] . '" class="img-circle img-responsive"></div>';
+        $infoUser = '<div class="thematic-avatar"><img src="'.$userInfo['avatar'].'" class="img-circle img-responsive"></div>';
         $infoUser .= '<div class="progress">
-                        <div class="progress-bar progress-bar-danger" role="progressbar" style="width: ' . $thematicScore . ';">
+                        <div class="progress-bar progress-bar-danger" role="progressbar" style="width: ' . $thematicScore.';">
                         '.$thematicScore.'
                         </div>
                     </div>';
@@ -265,11 +265,11 @@ if ($tool == TOOL_COURSE_HOMEPAGE && !isset($_GET['intro_cmdEdit'])) {
         $thematicItemOne = '
         <div class="col-md-6 items-progress">
             <div class="thematic-cont '.$class1.'">
-            <div class="topics">' . $subTitle1 . '</div>
+            <div class="topics">' . $subTitle1.'</div>
             <h4 class="title-topics">'.Display::returnFontAwesomeIcon('book').strip_tags($thematic_info['title']).'</h4>
-            <p class="date">' .  Display::returnFontAwesomeIcon('calendar-o') . $thematic_advance_info['start_date'] . '</p>
-            <div class="views">' . Display::returnFontAwesomeIcon('file-text-o')  . strip_tags($thematic_advance_info['content']). '</div>
-            <p class="time">'. Display::returnFontAwesomeIcon('clock-o') . get_lang('DurationInHours') . ' : ' . $thematic_advance_info['duration'] . ' - <a href="' . $thematicUrl . '">' . get_lang('SeeDetail') . '</a></p>
+            <p class="date">' .  Display::returnFontAwesomeIcon('calendar-o').$thematic_advance_info['start_date'].'</p>
+            <div class="views">' . Display::returnFontAwesomeIcon('file-text-o').strip_tags($thematic_advance_info['content']).'</div>
+            <p class="time">'. Display::returnFontAwesomeIcon('clock-o').get_lang('DurationInHours').' : '.$thematic_advance_info['duration'].' - <a href="'.$thematicUrl.'">'.get_lang('SeeDetail').'</a></p>
             </div>
         </div>';
 
@@ -282,19 +282,19 @@ if ($tool == TOOL_COURSE_HOMEPAGE && !isset($_GET['intro_cmdEdit'])) {
                 <div class="col-md-6 items-progress">
                     <div class="thematic-cont">
                     <div class="topics">'.$subTitle2.'</div>
-                    <h4 class="title-topics">'. Display::returnFontAwesomeIcon('book')  . $thematic_info2['title'].'</h4>
-                    <p class="date">' . Display::returnFontAwesomeIcon('calendar-o') .$thematic_advance_info2['start_date'].'</p>
-                    <div class="views">' . Display::returnFontAwesomeIcon('file-text-o')  . strip_tags($thematic_advance_info2['content']).'</div>
-                    <p class="time">'. Display::returnFontAwesomeIcon('clock-o') .get_lang('DurationInHours').' : '.$thematic_advance_info2['duration'].' - <a href="'.$thematicUrl.'">'.get_lang('SeeDetail').'</a></p>
+                    <h4 class="title-topics">'. Display::returnFontAwesomeIcon('book').$thematic_info2['title'].'</h4>
+                    <p class="date">' . Display::returnFontAwesomeIcon('calendar-o').$thematic_advance_info2['start_date'].'</p>
+                    <div class="views">' . Display::returnFontAwesomeIcon('file-text-o').strip_tags($thematic_advance_info2['content']).'</div>
+                    <p class="time">'. Display::returnFontAwesomeIcon('clock-o').get_lang('DurationInHours').' : '.$thematic_advance_info2['duration'].' - <a href="'.$thematicUrl.'">'.get_lang('SeeDetail').'</a></p>
                     </div>
                 </div>';
         }
         $thematicPanel = '<div class="row">';
-        $thematicPanel .= '<div class="col-md-2">' . $infoUser . '</div>';
-        $thematicPanel .= '<div class="col-md-10"><div class="row">' . $thematicItemOne . $thematicItemTwo . '</div></div>';
+        $thematicPanel .= '<div class="col-md-2">'.$infoUser.'</div>';
+        $thematicPanel .= '<div class="col-md-10"><div class="row">'.$thematicItemOne.$thematicItemTwo.'</div></div>';
         $thematicPanel .= '</div>';
         $thematicPanel .= '<div class="separate">
-                        <a href="' . $thematicUrl . '" class="btn btn-default btn-block">' . get_lang('ShowFullCourseAdvance') . '</a>
+                        <a href="' . $thematicUrl.'" class="btn btn-default btn-block">'.get_lang('ShowFullCourseAdvance').'</a>
                     </div>';
         $thematicProgress = Display::panelCollapse($titleThematic, $thematicPanel, 'thematic', null, 'accordion-thematic', 'collapse-thematic', false);
     }
@@ -311,7 +311,7 @@ if (api_is_allowed_to_edit() && empty($session_id)) {
     $editIconButton = Display::url(
         '<em class="fa fa-wrench"></em> ',
         api_get_path(WEB_CODE_PATH).'course_info/tools.php?'.api_get_cidreq(),
-        ['class' => 'btn btn-default', 'title' => get_lang('CustomizeIcons') ]
+        ['class' => 'btn btn-default', 'title' => get_lang('CustomizeIcons')]
     );
 }
 
@@ -323,12 +323,12 @@ if ($intro_dispCommand) {
         $toolbar .= '<div class="toolbar-edit">';
         $toolbar .= '<div class="btn-group pull-right" role="group">';
         if (!empty($courseId)) {
-            $textIntro  = '<a class="btn btn-default" title="' . addslashes(get_lang('AddIntro')) . '" href="'.api_get_self().'?' . api_get_cidreq().'&intro_cmdAdd=1">';
+            $textIntro  = '<a class="btn btn-default" title="'.addslashes(get_lang('AddIntro')).'" href="'.api_get_self().'?'.api_get_cidreq().'&intro_cmdAdd=1">';
             $textIntro .= '<em class="fa fa-file-text"></em> ';
             $textIntro .= "</a>";
-            $toolbar .= $textIntro . $editIconButton;
+            $toolbar .= $textIntro.$editIconButton;
         } else {
-            $toolbar .= '<a class="btn btn-default" href="' . api_get_self() . '?intro_cmdAdd=1">' . get_lang('AddIntro') . '</a>';
+            $toolbar .= '<a class="btn btn-default" href="'.api_get_self().'?intro_cmdAdd=1">'.get_lang('AddIntro').'</a>';
             $toolbar .= $editIconButton;
         }
         $toolbar .= '</div></div>';
@@ -342,7 +342,7 @@ if ($intro_dispCommand) {
                 '<a  class="btn btn-default" href="'.api_get_self().'?'.api_get_cidreq().'&intro_cmdEdit=1" title="'.get_lang('Modify').'">
                 <em class="fa fa-pencil"></em></a>';
             $toolbar .= $editIconButton;
-            $toolbar .="<a class=\"btn btn-default\" href=\"".api_get_self()."?".api_get_cidreq()."&intro_cmdDel=1\" onclick=\"javascript:
+            $toolbar .= "<a class=\"btn btn-default\" href=\"".api_get_self()."?".api_get_cidreq()."&intro_cmdDel=1\" onclick=\"javascript:
                 if(!confirm('".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES, $charset)).
                 "')) return false;\"><em class=\"fa fa-trash-o\"></em></a>";
 
@@ -356,7 +356,7 @@ if ($intro_dispCommand) {
                 if(!confirm('".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES, $charset)).
                 "')) return false;\"><em class=\"fa fa-trash-o\"></em></a>";
         }
-        $toolbar .=  "</div></div>";
+        $toolbar .= "</div></div>";
         // Fix for chrome XSS filter for videos in iframes - BT#7930
         $browser = api_get_navigator();
         if (strpos($introduction_section, '<iframe') !== false && $browser['name'] == 'Chrome') {
@@ -375,7 +375,7 @@ if ($intro_dispDefault) {
     } else {
         if (api_is_allowed_to_edit()) {
             $introduction_section .= '<div class="help-course">';
-            $introduction_section .= get_lang('AddCustomCourseIntro') . ' ' . $textIntro;
+            $introduction_section .= get_lang('AddCustomCourseIntro').' '.$textIntro;
             $introduction_section .= '</div>';
         }
     }

+ 124 - 124
main/inc/lib/api.lib.php

@@ -43,19 +43,19 @@ define('COURSEMANAGERLOWSECURITY', 10);
 define('PLATFORM_ADMIN', 11);
 define('SESSION_COURSE_COACH', 12);
 define('SESSION_GENERAL_COACH', 13);
-define('COURSE_STUDENT', 14);   //student subscribed in a course
-define('SESSION_STUDENT', 15);  //student subscribed in a session course
+define('COURSE_STUDENT', 14); //student subscribed in a course
+define('SESSION_STUDENT', 15); //student subscribed in a session course
 define('COURSE_TUTOR', 16); // student is tutor of a course (NOT in session)
 define('STUDENT_BOSS', 17); // student is boss
 define('INVITEE', 20);
 
 // Table of status
-$_status_list[COURSEMANAGER] = 'teacher';        // 1
-$_status_list[SESSIONADMIN] = 'session_admin';  // 3
-$_status_list[DRH] = 'drh';            // 4
-$_status_list[STUDENT] = 'user';           // 5
-$_status_list[ANONYMOUS] = 'anonymous';      // 6
-$_status_list[INVITEE] = 'invited';        // 20
+$_status_list[COURSEMANAGER] = 'teacher'; // 1
+$_status_list[SESSIONADMIN] = 'session_admin'; // 3
+$_status_list[DRH] = 'drh'; // 4
+$_status_list[STUDENT] = 'user'; // 5
+$_status_list[ANONYMOUS] = 'anonymous'; // 6
+$_status_list[INVITEE] = 'invited'; // 20
 
 // COURSE VISIBILITY CONSTANTS
 /** only visible for course admin */
@@ -269,14 +269,14 @@ define('USERNAME_PURIFIER_SHALLOW', '/\s/');
 define('IS_WINDOWS_OS', api_is_windows_os());
 
 // Checks for installed optional php-extensions.
-define('INTL_INSTALLED', function_exists('intl_get_error_code'));   // intl extension (from PECL), it is installed by default as of PHP 5.3.0
-define('ICONV_INSTALLED', function_exists('iconv'));                // iconv extension, for PHP5 on Windows it is installed by default.
-define('MBSTRING_INSTALLED', function_exists('mb_strlen'));         // mbstring extension.
+define('INTL_INSTALLED', function_exists('intl_get_error_code')); // intl extension (from PECL), it is installed by default as of PHP 5.3.0
+define('ICONV_INSTALLED', function_exists('iconv')); // iconv extension, for PHP5 on Windows it is installed by default.
+define('MBSTRING_INSTALLED', function_exists('mb_strlen')); // mbstring extension.
 
 // Patterns for processing paths.                                   // Examples:
-define('REPEATED_SLASHES_PURIFIER', '/\/{2,}/');                    // $path = preg_replace(REPEATED_SLASHES_PURIFIER, '/', $path);
-define('VALID_WEB_PATH', '/https?:\/\/[^\/]*(\/.*)?/i');            // $is_valid_path = preg_match(VALID_WEB_PATH, $path);
-define('VALID_WEB_SERVER_BASE', '/https?:\/\/[^\/]*/i');            // $new_path = preg_replace(VALID_WEB_SERVER_BASE, $new_base, $path);
+define('REPEATED_SLASHES_PURIFIER', '/\/{2,}/'); // $path = preg_replace(REPEATED_SLASHES_PURIFIER, '/', $path);
+define('VALID_WEB_PATH', '/https?:\/\/[^\/]*(\/.*)?/i'); // $is_valid_path = preg_match(VALID_WEB_PATH, $path);
+define('VALID_WEB_SERVER_BASE', '/https?:\/\/[^\/]*/i'); // $new_path = preg_replace(VALID_WEB_SERVER_BASE, $new_base, $path);
 
 // Constants for api_get_path() and api_get_path_type(), etc. - registered path types.
 // basic (leaf elements)
@@ -365,19 +365,19 @@ define('LINK_SURVEY', 8);
 define('LINK_HOTPOTATOES', 9);
 
 // Score display types constants
-define('SCORE_DIV', 1);    // X / Y
-define('SCORE_PERCENT', 2);    // XX %
-define('SCORE_DIV_PERCENT', 3);    // X / Y (XX %)
-define('SCORE_AVERAGE', 4);    // XX %
-define('SCORE_DECIMAL', 5);    // 0.50  (X/Y)
-define('SCORE_BAR', 6);    // Uses the Display::bar_progress function
-define('SCORE_SIMPLE', 7);    // X
-define('SCORE_IGNORE_SPLIT', 8);    //  ??
-define('SCORE_DIV_PERCENT_WITH_CUSTOM', 9);    // X / Y (XX %) - Good!
-define('SCORE_CUSTOM', 10);    // Good!
-define('SCORE_DIV_SIMPLE_WITH_CUSTOM', 11);    // X - Good!
-define('SCORE_DIV_SIMPLE_WITH_CUSTOM_LETTERS', 12);    // X - Good!
-define('SCORE_ONLY_SCORE', 13);    // X - Good!
+define('SCORE_DIV', 1); // X / Y
+define('SCORE_PERCENT', 2); // XX %
+define('SCORE_DIV_PERCENT', 3); // X / Y (XX %)
+define('SCORE_AVERAGE', 4); // XX %
+define('SCORE_DECIMAL', 5); // 0.50  (X/Y)
+define('SCORE_BAR', 6); // Uses the Display::bar_progress function
+define('SCORE_SIMPLE', 7); // X
+define('SCORE_IGNORE_SPLIT', 8); //  ??
+define('SCORE_DIV_PERCENT_WITH_CUSTOM', 9); // X / Y (XX %) - Good!
+define('SCORE_CUSTOM', 10); // Good!
+define('SCORE_DIV_SIMPLE_WITH_CUSTOM', 11); // X - Good!
+define('SCORE_DIV_SIMPLE_WITH_CUSTOM_LETTERS', 12); // X - Good!
+define('SCORE_ONLY_SCORE', 13); // X - Good!
 
 define('SCORE_BOTH', 1);
 define('SCORE_ONLY_DEFAULT', 2);
@@ -680,7 +680,7 @@ function api_get_path($path = '', $configuration = [])
 
     $emptyConfigurationParam = false;
     if (empty($configuration)) {
-        $configuration = (array)$_configuration;
+        $configuration = (array) $_configuration;
         $emptyConfigurationParam = true;
     }
 
@@ -712,10 +712,10 @@ function api_get_path($path = '', $configuration = [])
                         && (($server_protocol == 'http'
                                 && $_SERVER['SERVER_PORT'] != 80) || ($server_protocol == 'https' && $_SERVER['SERVER_PORT'] != 443))
                     ) {
-                        $server_name .= ":" . $_SERVER['SERVER_PORT'];
+                        $server_name .= ":".$_SERVER['SERVER_PORT'];
                     }
-                    $root_web = $server_protocol . '://' . $server_name . $root_rel;
-                    $root_sys = str_replace('\\', '/', realpath(__DIR__ . '/../../../')) . '/';
+                    $root_web = $server_protocol.'://'.$server_name.$root_rel;
+                    $root_sys = str_replace('\\', '/', realpath(__DIR__.'/../../../')).'/';
                 }
                 // Here we give up, so we don't touch anything.
             }
@@ -906,7 +906,7 @@ function api_get_path($path = '', $configuration = [])
                 $sys_course_code =
                     isset($_SESSION['_course']['sysCode'])  // User is inside a course?
                         ? $_SESSION['_course']['sysCode']   // Yes, then use course's directory name.
-                        : '{SYS_COURSE_CODE}';              // No, then use a fake code, it may be processed later.
+                        : '{SYS_COURSE_CODE}'; // No, then use a fake code, it may be processed later.
                 $path = $matches[1].'courses/'.$sys_course_code.'/document/'.str_replace('//', '/', $matches[3].'/'.$matches[2]);
             }
         }
@@ -1365,10 +1365,10 @@ function _api_format_user($user, $add_password = false, $loadAvatars = true)
 
     if (isset($user['email'])) {
         $result['mail'] = isset($user['email']) ? $user['email'] : null;
-        $result['email'] = isset($user['email'])? $user['email'] : null;
+        $result['email'] = isset($user['email']) ? $user['email'] : null;
     } else {
         $result['mail'] = isset($user['mail']) ? $user['mail'] : null;
-        $result['email'] = isset($user['mail'])? $user['mail'] : null;
+        $result['email'] = isset($user['mail']) ? $user['mail'] : null;
     }
     $user_id = intval($user['user_id']);
     // Maintain the user_id index for backwards compatibility
@@ -1465,7 +1465,7 @@ function api_get_user_info(
 
         if (isset($userFromSession)) {
             if ($cacheAvailable === true) {
-                $apcVar = api_get_configuration_value('apc_prefix') . 'userinfo_' . $userFromSession['user_id'];
+                $apcVar = api_get_configuration_value('apc_prefix').'userinfo_'.$userFromSession['user_id'];
                 if (apcu_exists($apcVar)) {
                     $user = apcu_fetch($apcVar);
                 } else {
@@ -1487,7 +1487,7 @@ function api_get_user_info(
 
     // Re-use user information if not stale and already stored in APCu
     if ($cacheAvailable === true) {
-        $apcVar = api_get_configuration_value('apc_prefix') . 'userinfo_' . $user_id;
+        $apcVar = api_get_configuration_value('apc_prefix').'userinfo_'.$user_id;
         if (apcu_exists($apcVar)) {
             $user = apcu_fetch($apcVar);
 
@@ -1495,7 +1495,7 @@ function api_get_user_info(
         }
     }
 
-    $sql = "SELECT * FROM " . Database::get_main_table(TABLE_MAIN_USER) . "
+    $sql = "SELECT * FROM ".Database::get_main_table(TABLE_MAIN_USER)."
             WHERE id = $user_id";
     $result = Database::query($sql);
     if (Database::num_rows($result) > 0) {
@@ -1956,7 +1956,7 @@ function api_generate_password($length = 8)
     $charactersUpperCase = 'ABCDEFGHJKLMNPQRSTUVWXYZ';
     $minNumbers = 2;
     $length = $length - $minNumbers;
-    $minLowerCase = round($length/2);
+    $minLowerCase = round($length / 2);
     $minUpperCase = $length - $minLowerCase;
 
     $password = '';
@@ -1979,7 +1979,7 @@ function api_generate_password($length = 8)
     }
 
     // Min digits default 2
-    for ($i = 0; $i < $minNumbers; $i ++) {
+    for ($i = 0; $i < $minNumbers; $i++) {
         $password .= $generator->generateInt(2, 9);
     }
 
@@ -2174,7 +2174,7 @@ function api_get_session_name($session_id = 0)
         }
     }
     $t = Database::get_main_table(TABLE_MAIN_SESSION);
-    $s = "SELECT name FROM $t WHERE id = ".(int)$session_id;
+    $s = "SELECT name FROM $t WHERE id = ".(int) $session_id;
     $r = Database::query($s);
     $c = Database::num_rows($r);
     if ($c > 0) {
@@ -2347,9 +2347,9 @@ function api_get_session_visibility(
  */
 function api_get_session_image($session_id, $status_id)
 {
-    $session_id = (int)$session_id;
+    $session_id = (int) $session_id;
     $session_img = '';
-    if ((int)$status_id != 5) { //check whether is not a student
+    if ((int) $status_id != 5) { //check whether is not a student
         if ($session_id > 0) {
             $session_img = "&nbsp;&nbsp;".Display::return_icon(
                 'star.png',
@@ -2634,7 +2634,7 @@ function api_is_course_tutor()
 function api_is_course_session_coach($user_id, $courseId, $session_id)
 {
     $session_table = Database::get_main_table(TABLE_MAIN_SESSION);
-    $session_rel_course_rel_user_table  = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
+    $session_rel_course_rel_user_table = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
 
     $user_id = intval($user_id);
     $session_id = intval($session_id);
@@ -2886,7 +2886,7 @@ function api_display_tool_view_option()
             return '';
         }
         $sourceurl = substr($_SERVER['REQUEST_URI'], 0, strpos($_SERVER['REQUEST_URI'], '?'));
-        $sourceurl = str_replace('lp/lp_header.php', 'lp/lp_controller.php?'.api_get_cidreq().'&action=view&lp_id='.intval($_GET['lp_id']).'&isStudentView='.($_SESSION['studentview']=='studentview' ? 'false' : 'true'), $sourceurl);
+        $sourceurl = str_replace('lp/lp_header.php', 'lp/lp_controller.php?'.api_get_cidreq().'&action=view&lp_id='.intval($_GET['lp_id']).'&isStudentView='.($_SESSION['studentview'] == 'studentview' ? 'false' : 'true'), $sourceurl);
         //showinframes doesn't handle student view anyway...
         //return '';
         $is_framed = true;
@@ -3364,7 +3364,7 @@ function api_not_allowed($print_headers = false, $message = null)
         }
         $content .= '<div class="well">';
         $content .= $form->returnForm();
-        $content .='</div>';
+        $content .= '</div>';
         if (api_is_cas_activated()) {
             $content .= "</div>";
         }
@@ -3416,7 +3416,7 @@ function api_not_allowed($print_headers = false, $message = null)
         }
         $msg .= '<div class="well">';
         $msg .= $form->returnForm();
-        $msg .='</div>';
+        $msg .= '</div>';
         if ($casEnabled) {
             $msg .= "</div>";
         }
@@ -3447,7 +3447,7 @@ function convert_sql_date($last_post_datetime)
     list ($last_post_date, $last_post_time) = explode(' ', $last_post_datetime);
     list ($year, $month, $day) = explode('-', $last_post_date);
     list ($hour, $min, $sec) = explode(':', $last_post_time);
-    return mktime((int)$hour, (int)$min, (int)$sec, (int)$month, (int)$day, (int)$year);
+    return mktime((int) $hour, (int) $min, (int) $sec, (int) $month, (int) $day, (int) $year);
 }
 
 /**
@@ -3923,7 +3923,7 @@ function api_get_item_property_by_tool($tool, $course_code, $session_id = null)
                 c_id = $course_id AND
                 tool = '$tool'
                 $session_condition ";
-    $rs  = Database::query($sql);
+    $rs = Database::query($sql);
     $list = array();
     if (Database::num_rows($rs) > 0) {
         while ($row = Database::fetch_array($rs, 'ASSOC')) {
@@ -4004,7 +4004,7 @@ function api_get_item_property_id($course_code, $tool, $ref, $sessionId = 0)
                 tool = '$tool' AND
                 ref = $ref
                 $sessionCondition";
-    $rs  = Database::query($sql);
+    $rs = Database::query($sql);
     $item_property_id = '';
     if (Database::num_rows($rs) > 0) {
         $row = Database::fetch_array($rs);
@@ -4065,7 +4065,7 @@ function api_get_track_item_property_history($tool, $ref)
     if ($result === false or $result === null) {
         $result = array();
     } else {
-        $result = Database::store_result($result,'ASSOC');
+        $result = Database::store_result($result, 'ASSOC');
     }
 
     return $result;
@@ -4117,7 +4117,7 @@ function api_get_item_property_info($course_id, $tool, $ref, $session_id = 0, $g
     $rs  = Database::query($sql);
     $row = array();
     if (Database::num_rows($rs) > 0) {
-        $row = Database::fetch_array($rs,'ASSOC');
+        $row = Database::fetch_array($rs, 'ASSOC');
     }
 
     return $row;
@@ -4149,10 +4149,10 @@ function api_get_languages_combo($name = 'language')
         $default = $platformLanguage;
     }
 
-    $languages  = $language_list['name'];
+    $languages = $language_list['name'];
     $folder = $language_list['folder'];
 
-    $ret .= '<select name="' . $name . '" id="language_chosen" class="selectpicker show-tick form-control">';
+    $ret .= '<select name="'.$name.'" id="language_chosen" class="selectpicker show-tick form-control">';
     foreach ($languages as $key => $value) {
         if ($folder[$key] == $default) {
             $selected = ' selected="selected"';
@@ -4203,8 +4203,8 @@ function api_display_language_form($hide_if_no_choice = false)
     }
     </script>';
     $html .= '<form id="lang_form" name="lang_form" method="post" action="'.api_get_self().'">';
-    $html .= '<label style="display: none;" for="language_list">' . get_lang('Language') . '</label>';
-    $html .=  '<select id="language_list" class="selectpicker show-tick form-control" name="language_list" >';
+    $html .= '<label style="display: none;" for="language_list">'.get_lang('Language').'</label>';
+    $html .= '<select id="language_list" class="selectpicker show-tick form-control" name="language_list" >';
 
     foreach ($original_languages as $key => $value) {
         if ($folder[$key] == $user_selected_language) {
@@ -4212,13 +4212,13 @@ function api_display_language_form($hide_if_no_choice = false)
         } else {
             $option_end = '>';
         }
-        $html .=  '<option value="'.api_get_self().'?language='.$folder[$key].'"'.$option_end;
+        $html .= '<option value="'.api_get_self().'?language='.$folder[$key].'"'.$option_end;
         //echo substr($value, 0, 16); // Cut string to keep 800x600 aspect.
-        $html .=  $value.'</option>';
+        $html .= $value.'</option>';
     }
-    $html .=  '</select>';
-    $html .=  '<noscript><input type="submit" name="user_select_language" value="'.get_lang('Ok').'" /></noscript>';
-    $html .=  '</form>';
+    $html .= '</select>';
+    $html .= '<noscript><input type="submit" name="user_select_language" value="'.get_lang('Ok').'" /></noscript>';
+    $html .= '</form>';
     return $html;
 }
 
@@ -4455,7 +4455,7 @@ function api_get_themes($getOnlyThemeFromVirtualInstance = false)
     // This configuration value is set by the vchamilo plugin
     $virtualTheme = api_get_configuration_value('virtual_css_theme_folder');
 
-    $readCssFolder = function ($dir) use ($virtualTheme) {
+    $readCssFolder = function($dir) use ($virtualTheme) {
         $finder = new Finder();
         $themes = $finder->directories()->in($dir)->depth(0)->sortByName();
         $list = [];
@@ -4616,7 +4616,7 @@ function rmdirr($dirname, $delete_only_content_in_folder = false, $strict = fals
     if (is_file($dirname) || is_link($dirname)) {
         $res = unlink($dirname);
         if ($res === false) {
-            error_log(__FILE__.' line '.__LINE__.': '.((bool)ini_get('track_errors') ? $php_errormsg : 'Error not recorded because track_errors is off in your php.ini'), 0);
+            error_log(__FILE__.' line '.__LINE__.': '.((bool) ini_get('track_errors') ? $php_errormsg : 'Error not recorded because track_errors is off in your php.ini'), 0);
         }
         return $res;
     }
@@ -4653,7 +4653,7 @@ function rmdirr($dirname, $delete_only_content_in_folder = false, $strict = fals
     if ($delete_only_content_in_folder == false) {
         $res = rmdir($dirname);
         if ($res === false) {
-            error_log(__FILE__.' line '.__LINE__.': '.((bool)ini_get('track_errors') ? $php_errormsg : 'error not recorded because track_errors is off in your php.ini'), 0);
+            error_log(__FILE__.' line '.__LINE__.': '.((bool) ini_get('track_errors') ? $php_errormsg : 'error not recorded because track_errors is off in your php.ini'), 0);
         }
     }
     return $res;
@@ -4738,7 +4738,7 @@ function copy_folder_course_session(
 
     $course_id = $course_info['real_id'];
 
-    $folders = explode(DIRECTORY_SEPARATOR,str_replace($base_path_document.DIRECTORY_SEPARATOR,'',$pathname));
+    $folders = explode(DIRECTORY_SEPARATOR, str_replace($base_path_document.DIRECTORY_SEPARATOR, '', $pathname));
 
     $new_pathname = $base_path_document;
     $path = '';
@@ -4756,7 +4756,7 @@ function copy_folder_course_session(
                         path = '$path' AND
                         filetype = 'folder' AND
                         session_id = '$session_id'";
-            $rs1  = Database::query($sql);
+            $rs1 = Database::query($sql);
             $num_rows = Database::num_rows($rs1);
 
             if ($num_rows == 0) {
@@ -4916,7 +4916,7 @@ function api_parse_info_file($filename) {
             foreach (array('key', 'value1', 'value2', 'value3') as $var) {
                 $$var = isset($match[++$i]) ? $match[$i] : '';
             }
-            $value = stripslashes(substr($value1, 1, -1)) . stripslashes(substr($value2, 1, -1)) . $value3;
+            $value = stripslashes(substr($value1, 1, -1)).stripslashes(substr($value2, 1, -1)).$value3;
 
             // Parse array syntax.
             $keys = preg_split('/\]?\[/', rtrim($key, ']'));
@@ -5087,7 +5087,7 @@ function api_set_setting($var, $value, $subvar = null, $cat = null, $access_url
     $t_settings = Database::get_main_table(TABLE_MAIN_SETTINGS_CURRENT);
     $var = Database::escape_string($var);
     $value = Database::escape_string($value);
-    $access_url = (int)$access_url;
+    $access_url = (int) $access_url;
     if (empty($access_url)) { $access_url = 1; }
     $select = "SELECT id FROM $t_settings WHERE variable = '$var' ";
     if (!empty($subvar)) {
@@ -5128,11 +5128,11 @@ function api_set_setting($var, $value, $subvar = null, $cat = null, $access_url
                 $row = Database::fetch_array($res);
                 $insert = "INSERT INTO $t_settings (variable, subkey, type,category, selected_value, title, comment, scope, subkeytext, access_url)
                         VALUES
-                        ('".$row['variable']."',".(!empty($row['subkey']) ? "'".$row['subkey']."'" : "NULL")."," .
-                        "'".$row['type']."','".$row['category']."'," .
-                        "'$value','".$row['title']."'," .
-                        "".(!empty($row['comment']) ? "'".$row['comment']."'" : "NULL").",".(!empty($row['scope']) ? "'".$row['scope']."'" : "NULL")."," .
-                        "".(!empty($row['subkeytext'])?"'".$row['subkeytext']."'":"NULL").",$access_url)";
+                        ('".$row['variable']."',".(!empty($row['subkey']) ? "'".$row['subkey']."'" : "NULL").",".
+                        "'".$row['type']."','".$row['category']."',".
+                        "'$value','".$row['title']."',".
+                        "".(!empty($row['comment']) ? "'".$row['comment']."'" : "NULL").",".(!empty($row['scope']) ? "'".$row['scope']."'" : "NULL").",".
+                        "".(!empty($row['subkeytext']) ? "'".$row['subkeytext']."'" : "NULL").",$access_url)";
                 Database::query($insert);
             } else {
                 // Such a setting does not exist.
@@ -5154,11 +5154,11 @@ function api_set_setting($var, $value, $subvar = null, $cat = null, $access_url
                 if ($row['access_url_changeable'] == 1) {
                     $insert = "INSERT INTO $t_settings (variable,subkey, type,category, selected_value,title, comment,scope, subkeytext,access_url, access_url_changeable) VALUES
                             ('".$row['variable']."',".
-                            (!empty($row['subkey']) ? "'".$row['subkey']."'" : "NULL")."," .
-                            "'".$row['type']."','".$row['category']."'," .
-                            "'$value','".$row['title']."'," .
+                            (!empty($row['subkey']) ? "'".$row['subkey']."'" : "NULL").",".
+                            "'".$row['type']."','".$row['category']."',".
+                            "'$value','".$row['title']."',".
                             "".(!empty($row['comment']) ? "'".$row['comment']."'" : "NULL").",".
-                            (!empty($row['scope']) ? "'".$row['scope']."'" : "NULL")."," .
+                            (!empty($row['scope']) ? "'".$row['scope']."'" : "NULL").",".
                             "".(!empty($row['subkeytext']) ? "'".$row['subkeytext']."'" : "NULL").",$access_url,".$row['access_url_changeable'].")";
                     Database::query($insert);
                 }
@@ -5192,10 +5192,10 @@ function api_set_settings_category($category, $value = null, $access_url = 1, $f
         $value = Database::escape_string($value);
         $sql = "UPDATE $t_s SET selected_value = '$value'
                 WHERE category = '$category' AND access_url = $access_url";
-        if (is_array($fieldtype) && count($fieldtype)>0) {
+        if (is_array($fieldtype) && count($fieldtype) > 0) {
             $sql .= " AND ( ";
             $i = 0;
-            foreach ($fieldtype as $type){
+            foreach ($fieldtype as $type) {
                 if ($i > 0) {
                     $sql .= ' OR ';
                 }
@@ -5210,10 +5210,10 @@ function api_set_settings_category($category, $value = null, $access_url = 1, $f
     } else {
         $sql = "UPDATE $t_s SET selected_value = NULL
                 WHERE category = '$category' AND access_url = $access_url";
-        if (is_array($fieldtype) && count($fieldtype)>0) {
+        if (is_array($fieldtype) && count($fieldtype) > 0) {
             $sql .= " AND ( ";
             $i = 0;
-            foreach ($fieldtype as $type){
+            foreach ($fieldtype as $type) {
                 if ($i > 0) {
                     $sql .= ' OR ';
                 }
@@ -5329,7 +5329,7 @@ function &api_get_settings($cat = null, $ordering = 'list', $access_url = 1, $ur
     if ($result === null) {
         return [];
     }
-    $result = Database::store_result($result,'ASSOC');
+    $result = Database::store_result($result, 'ASSOC');
 
     return $result;
 }
@@ -5396,12 +5396,12 @@ function api_add_setting(
 
     // Item not found for this access_url, we have to check if the whole thing is missing
     // (in which case we ignore the insert) or if there *is* a record but just for access_url = 1
-    $insert = "INSERT INTO $t_settings " .
-                "(variable,selected_value," .
-                "type,category," .
-                "subkey,title," .
-                "comment,scope," .
-                "subkeytext,access_url,access_url_changeable)" .
+    $insert = "INSERT INTO $t_settings ".
+                "(variable,selected_value,".
+                "type,category,".
+                "subkey,title,".
+                "comment,scope,".
+                "subkeytext,access_url,access_url_changeable)".
                 " VALUES ('$var','$val',";
     if (isset($type)) {
         $type = Database::escape_string($type);
@@ -5566,7 +5566,7 @@ function api_is_course_visible_for_user($userid = null, $cid = null) {
             $result = Database::query($sql);
 
             //if ($row = Database::fetch_array($result)) {
-            if (Database::num_rows($result) > 0 ) {
+            if (Database::num_rows($result) > 0) {
                 $is_courseMember = true;
                 $is_courseTutor = true;
                 $is_courseCoach = true;
@@ -5856,7 +5856,7 @@ function api_is_windows_os() {
     } else {
         return false;
     }
-    return strtolower(substr((string)$os, 0, 3 )) == 'win';
+    return strtolower(substr((string) $os, 0, 3)) == 'win';
 }
 
 /**
@@ -6454,7 +6454,7 @@ function api_get_jquery_ui_css_web_path()
 function api_get_jquery_ui_js($include_jqgrid = false) {
     $libraries = array();
     if ($include_jqgrid) {
-       $libraries[]='jqgrid';
+       $libraries[] = 'jqgrid';
     }
     return api_get_jquery_libraries_js($libraries);
 }
@@ -6477,12 +6477,12 @@ function api_get_jquery_libraries_js($libraries) {
 
     //jqgrid js and css
     if (in_array('jqgrid', $libraries)) {
-        $languaje   = 'en';
+        $languaje = 'en';
         $platform_isocode = strtolower(api_get_language_isocode());
 
         //languages supported by jqgrid see files in main/inc/lib/javascript/jqgrid/js/i18n
         $jqgrid_langs = array(
-            'bg', 'bg1251', 'cat','cn','cs','da','de','el','en','es','fa','fi','fr','gl','he','hu','is','it','ja','nl','no','pl','pt-br','pt','ro','ru','sk','sr','sv','tr','ua'
+            'bg', 'bg1251', 'cat', 'cn', 'cs', 'da', 'de', 'el', 'en', 'es', 'fa', 'fi', 'fr', 'gl', 'he', 'hu', 'is', 'it', 'ja', 'nl', 'no', 'pl', 'pt-br', 'pt', 'ro', 'ru', 'sk', 'sr', 'sv', 'tr', 'ua'
         );
 
         if (in_array($platform_isocode, $jqgrid_langs)) {
@@ -6513,7 +6513,7 @@ function api_get_jquery_libraries_js($libraries) {
 
     // jquery datepicker
     if (in_array('datepicker', $libraries)) {
-        $languaje   = 'en-GB';
+        $languaje = 'en-GB';
         $platform_isocode = strtolower(api_get_language_isocode());
 
         // languages supported by jqgrid see files in main/inc/lib/javascript/jqgrid/js/i18n
@@ -6685,7 +6685,7 @@ function api_block_course_item_locked_by_gradebook($item_id, $link_type, $course
  */
 function api_check_php_version($my_inc_path = null)
 {
-    if (!function_exists('version_compare') || version_compare( phpversion(), REQUIRED_PHP_VERSION, '<')) {
+    if (!function_exists('version_compare') || version_compare(phpversion(), REQUIRED_PHP_VERSION, '<')) {
         $global_error_code = 1;
         // Incorrect PHP version
         $global_page = $my_inc_path.'global_error_message.inc.php';
@@ -6703,7 +6703,7 @@ function api_check_php_version($my_inc_path = null)
 function api_check_archive_dir()
 {
     if (is_dir(api_get_path(SYS_ARCHIVE_PATH)) && !is_writable(api_get_path(SYS_ARCHIVE_PATH))) {
-        $message = Display::return_message(get_lang('ArchivesDirectoryNotWriteableContactAdmin'),'warning');
+        $message = Display::return_message(get_lang('ArchivesDirectoryNotWriteableContactAdmin'), 'warning');
         api_not_allowed(true, $message);
     }
 }
@@ -6794,23 +6794,23 @@ function api_get_real_ip()
  * @author Yannick Warnier for improvements and managment of multiple ranges
  * @todo check for IPv6 support
  */
-function api_check_ip_in_range($ip,$range)
+function api_check_ip_in_range($ip, $range)
 {
     if (empty($ip) or empty($range)) {
         return false;
     }
-    $ip_ip = ip2long ($ip);
+    $ip_ip = ip2long($ip);
     // divide range param into array of elements
-    if (strpos($range,',')!==false) {
-        $ranges = explode(',',$range);
+    if (strpos($range, ',') !== false) {
+        $ranges = explode(',', $range);
     } else {
         $ranges = array($range);
     }
     foreach ($ranges as $range) {
         $range = trim($range);
         if (empty($range)) { continue; }
-        if (strpos($range,'/')===false) {
-            if (strcmp($ip,$range)===0) {
+        if (strpos($range, '/') === false) {
+            if (strcmp($ip, $range) === 0) {
                 return true; // there is a direct IP match, return OK
             }
             continue; //otherwise, get to the next range
@@ -6818,7 +6818,7 @@ function api_check_ip_in_range($ip,$range)
         // the range contains a "/", so analyse completely
         list ($net, $mask) = explode("/", $range);
 
-        $ip_net = ip2long ($net);
+        $ip_net = ip2long($net);
         // mask binary magic
         $ip_mask = ~((1 << (32 - $mask)) - 1);
 
@@ -7167,7 +7167,7 @@ function api_set_memory_limit($mem)
     }
 
     $memory_limit = ini_get('memory_limit');
-    if (api_get_bytes_memory_limit($mem) > api_get_bytes_memory_limit($memory_limit)){
+    if (api_get_bytes_memory_limit($mem) > api_get_bytes_memory_limit($memory_limit)) {
         ini_set('memory_limit', $mem);
         return true;
     }
@@ -7186,20 +7186,20 @@ function api_set_memory_limit($mem)
  */
 function api_get_bytes_memory_limit($mem)
 {
-    $size = strtolower(substr($mem,-1));
+    $size = strtolower(substr($mem, -1));
 
     switch ($size) {
         case 't':
-            $mem = intval(substr($mem,-1))*1024*1024*1024*1024;
+            $mem = intval(substr($mem, -1)) * 1024 * 1024 * 1024 * 1024;
             break;
         case 'g':
-            $mem = intval(substr($mem,0,-1))*1024*1024*1024;
+            $mem = intval(substr($mem, 0, -1)) * 1024 * 1024 * 1024;
             break;
         case 'm':
-            $mem = intval(substr($mem,0,-1))*1024*1024;
+            $mem = intval(substr($mem, 0, -1)) * 1024 * 1024;
             break;
         case 'k':
-            $mem = intval(substr($mem,0,-1))*1024;
+            $mem = intval(substr($mem, 0, -1)) * 1024;
             break;
         default:
             // we assume it's integer only
@@ -7262,7 +7262,7 @@ function api_get_password_checker_js($usernameInputId, $passwordInputId)
     ];
 
     $js = api_get_asset('pwstrength-bootstrap/dist/pwstrength-bootstrap.min.js');
-    $js .=  "<script>    
+    $js .= "<script>    
     var errorMessages = {
         password_to_short : \"" . get_lang('PasswordIsTooShort')."\",
         same_as_username : \"".get_lang('YourPasswordCannotBeTheSameAsYourUsername')."\"
@@ -7310,7 +7310,7 @@ function api_block_account_captcha($username)
         return false;
     }
     $minutesToBlock = api_get_setting('captcha_time_to_block');
-    $time = time() + $minutesToBlock*60;
+    $time = time() + $minutesToBlock * 60;
     UserManager::update_extra_field_value(
         $userInfo['user_id'],
         'captcha_blocked_until_date',
@@ -7388,7 +7388,7 @@ function api_remove_tags_with_space($in_html, $in_double_quote_replace = true)
         $out_res = str_replace('"', "''", $out_res);
     }
     // avoid text stuck together when tags are removed, adding a space after >
-    $out_res = str_replace (">", "> ", $out_res);
+    $out_res = str_replace(">", "> ", $out_res);
     $out_res = strip_tags($out_res);
 
     return $out_res;
@@ -7596,7 +7596,7 @@ function api_warn_hosting_contact($limitName)
         $body = get_lang('PortalName').': '.api_get_path(WEB_PATH)." \n ";
         $body .= get_lang('PortalLimitType').': '.$limitName." \n ";
         if (isset($hostingParams[$limitName])) {
-            $body .= get_lang('Value') . ': ' . $hostingParams[$limitName];
+            $body .= get_lang('Value').': '.$hostingParams[$limitName];
         }
         api_mail_html(null, $email, $subject, $body);
     }
@@ -7747,7 +7747,7 @@ function api_get_users_status_ignored_in_reports($format = 'array')
  */
 function api_set_site_use_cookie_warning_cookie()
 {
-    setcookie('ChamiloUsesCookies', 'ok', time()+31556926);
+    setcookie('ChamiloUsesCookies', 'ok', time() + 31556926);
 }
 
 /**
@@ -7801,10 +7801,10 @@ function api_create_protected_dir($name, $parentDirectory)
         return false;
     }
 
-    $fullPath = $parentDirectory . api_replace_dangerous_char($name);
+    $fullPath = $parentDirectory.api_replace_dangerous_char($name);
 
     if (mkdir($fullPath, api_get_permissions_for_new_directories(), true)) {
-        $fp = fopen($fullPath . '/index.html', 'w');
+        $fp = fopen($fullPath.'/index.html', 'w');
 
         if ($fp) {
             if (fwrite($fp, '<html><head></head><body></body></html>')) {
@@ -7869,7 +7869,7 @@ function api_mail_html(
             $mail->SMTPSecure = $platform_email['SMTP_SECURE'];
         }
     }
-    $mail->SMTPDebug = isset($platform_email['SMTP_DEBUG'])?$platform_email['SMTP_DEBUG']:0;
+    $mail->SMTPDebug = isset($platform_email['SMTP_DEBUG']) ? $platform_email['SMTP_DEBUG'] : 0;
 
     // 5 = low, 1 = high
     $mail->Priority = 3;
@@ -8015,11 +8015,11 @@ function api_mail_html(
         error_log('ERROR: mail not sent to '.$recipient_name.' ('.$recipient_email.') because of '.$mail->ErrorInfo.'<br />');
         if ($mail->SMTPDebug) {
             error_log(
-                "Connection details :: " .
-                "Protocol: " . $mail->Mailer . ' :: ' .
-                "Host/Port: " . $mail->Host . ':' . $mail->Port . ' :: ' .
-                "Authent/Open: " . ($mail->SMTPAuth?'Authent':'Open') . ' :: ' .
-                ($mail->SMTPAuth?"  User/Pass: " . $mail->Username . ':' . $mail->Password:'')
+                "Connection details :: ".
+                "Protocol: ".$mail->Mailer.' :: '.
+                "Host/Port: ".$mail->Host.':'.$mail->Port.' :: '.
+                "Authent/Open: ".($mail->SMTPAuth ? 'Authent' : 'Open').' :: '.
+                ($mail->SMTPAuth ? "  User/Pass: ".$mail->Username.':'.$mail->Password : '')
             );
         }
         return 0;
@@ -8102,7 +8102,7 @@ function api_unique_multidim_array($array, $key)
     $key_array = [];
 
     foreach ($array as $val) {
-        if(!in_array($val[$key],$key_array)){
+        if (!in_array($val[$key], $key_array)) {
             $key_array[$i] = $val[$key];
             $temp_array[$i] = $val;
         }
@@ -8147,7 +8147,7 @@ function api_upload_file($type, $file, $itemId, $cropParameters = '')
         // No "dangerous" files
         $name = disable_dangerous_file($name);
 
-        $pathId = '/'.substr((string)$itemId, 0, 1).'/'.$itemId.'/';
+        $pathId = '/'.substr((string) $itemId, 0, 1).'/'.$itemId.'/';
         $path = api_get_path(SYS_UPLOAD_PATH).$type.$pathId;
 
         if (!is_dir($path)) {
@@ -8226,7 +8226,7 @@ function api_number_format($number, $decimals = 0)
  */
 function location($url, $exit = true)
 {
-    header('Location: ' . $url);
+    header('Location: '.$url);
 
     if ($exit) {
         exit;

+ 27 - 27
main/inc/lib/blog.lib.php

@@ -526,9 +526,9 @@ class Blog
                 Database::query($sql);
 
                 if ($has_attachment) {
-                    $courseDir = $_course['path'] . '/upload/blog';
+                    $courseDir = $_course['path'].'/upload/blog';
                     $sys_course_path = api_get_path(SYS_COURSE_PATH);
-                    $updir = $sys_course_path . $courseDir;
+                    $updir = $sys_course_path.$courseDir;
 
                     // Try to add an extension to the file if it hasn't one
                     $new_file_name = add_ext_on_mime(
@@ -543,7 +543,7 @@ class Blog
                         echo Display::return_message(get_lang('UplUnableToSaveFileFilteredExtension'), 'error');
                     } else {
                         $new_file_name = uniqid('');
-                        $new_path = $updir . '/' . $new_file_name;
+                        $new_path = $updir.'/'.$new_file_name;
                         $result = @move_uploaded_file($_FILES['user_upload']['tmp_name'], $new_path);
                         $comment = Database::escape_string($file_comment);
                         $size = intval($_FILES['user_upload']['size']);
@@ -1130,7 +1130,7 @@ class Blog
             'comments' => $listComments,
             'form_html' => $formComments,
             'actions' => $blogActions,
-            'score_ranking' => (int)$scoreRanking,
+            'score_ranking' => (int) $scoreRanking,
             'frm_rating' => api_is_allowed('BLOG_'.$blog_id, 'article_rate')
                 ? self::displayRatingCreateForm('post', $blog_id, $post_id)
                 : null
@@ -1283,7 +1283,7 @@ class Blog
                     blog_id = $blog_id
                     AND item_id = $post_id
                     AND rating_type = '$type'
-                    AND user_id = " . $_user['user_id'];
+                    AND user_id = ".$_user['user_id'];
             $result = Database::query($sql);
             // Add rating
             if (Database::num_rows($result) == 0) {
@@ -1470,13 +1470,13 @@ class Blog
                     blog_id = $blog_id AND
                     item_id = $item_id AND
                     rating_type = '$type' AND
-                    user_id = " . $_user['user_id'];
+                    user_id = ".$_user['user_id'];
         $result = Database::query($sql);
 
         // Add rating
         if (Database::num_rows($result) == 0) {
             $sql = "INSERT INTO $tbl_blogs_rating (c_id, blog_id, rating_type, item_id, user_id, rating )
-                    VALUES ($course_id, $blog_id, '$type', $item_id, " . $_user['user_id'] . ", '$rating')";
+                    VALUES ($course_id, $blog_id, '$type', $item_id, ".$_user['user_id'].", '$rating')";
             Database::query($sql);
 
             $id = Database::insert_id();
@@ -1752,8 +1752,8 @@ class Blog
 
             $username = api_htmlentities(sprintf(get_lang('LoginX'), $assignment['username']), ENT_QUOTES);
 
-            $return .='<tr class="'.$css_class.'" valign="top">';
-            $return .='<td width="240">'.Display::tag(
+            $return .= '<tr class="'.$css_class.'" valign="top">';
+            $return .= '<td width="240">'.Display::tag(
                     'span',
                     api_get_person_name($assignment['firstname'], $assignment['lastname']),
                     array('title' => $username)
@@ -2419,7 +2419,7 @@ class Blog
         $query_vars['action'] = 'manage_members';
         $query_vars['blog_id'] = $blog_id;
         $html .= '<form class="form-inline" method="post" action="blog.php?action=manage_members&blog_id='.$blog_id.'">';
-        $html.= Display::return_sortable_table($column_header, $user_data, null, null, $query_vars);
+        $html .= Display::return_sortable_table($column_header, $user_data, null, null, $query_vars);
         $link = '';
         $link .= isset ($_GET['action']) ? 'action='.Security::remove_XSS($_GET['action']).'&' : '';
         $link .= "blog_id=$blog_id&";
@@ -2458,7 +2458,7 @@ class Blog
         $tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER);
         $blog_id = intval($blog_id);
 
-        $html.= '<legend>'.get_lang('UnsubscribeMembers').'</legend>';
+        $html .= '<legend>'.get_lang('UnsubscribeMembers').'</legend>';
 
         $properties["width"] = "100%";
         //table column titles
@@ -2534,25 +2534,25 @@ class Blog
 
         $query_vars['action'] = 'manage_members';
         $query_vars['blog_id'] = $blog_id;
-        $html.= '<form class="form-inline" method="post" action="blog.php?action=manage_members&blog_id='.$blog_id.'">';
-        $html.= Display::return_sortable_table($column_header, $user_data, null, null, $query_vars);
+        $html .= '<form class="form-inline" method="post" action="blog.php?action=manage_members&blog_id='.$blog_id.'">';
+        $html .= Display::return_sortable_table($column_header, $user_data, null, null, $query_vars);
         $link = '';
         $link .= isset ($_GET['action']) ? 'action='.Security::remove_XSS($_GET['action']).'&' : '';
         $link .= "blog_id=$blog_id&";
 
-        $html.= '<a class="btn btn-default" href="blog.php?'.$link.'selectall=unsubscribe">'.get_lang('SelectAll').'</a> - ';
-        $html.= '<a class="btn btn-default" href="blog.php?'.$link.'">'.get_lang('UnSelectAll').'</a> ';
-        $html.= '<div class="form-group">';
-        $html.= '<label>';
-        $html.= get_lang('WithSelected').' : ';
-        $html.= '</label>';
-        $html.= '<select name="action" class="selectpicker">';
-        $html.= '<option value="select_unsubscribe">'.get_lang('UnRegister').'</option>';
-        $html.= '</select>';
-        $html.= '<input type="hidden" name="unregister" value="true" />';
-        $html.= '<button class="btn btn-default" type="submit">'.get_lang('Ok').'</button>';
-        $html.= '</div>';
-        $html.= '</form>';
+        $html .= '<a class="btn btn-default" href="blog.php?'.$link.'selectall=unsubscribe">'.get_lang('SelectAll').'</a> - ';
+        $html .= '<a class="btn btn-default" href="blog.php?'.$link.'">'.get_lang('UnSelectAll').'</a> ';
+        $html .= '<div class="form-group">';
+        $html .= '<label>';
+        $html .= get_lang('WithSelected').' : ';
+        $html .= '</label>';
+        $html .= '<select name="action" class="selectpicker">';
+        $html .= '<option value="select_unsubscribe">'.get_lang('UnRegister').'</option>';
+        $html .= '</select>';
+        $html .= '<input type="hidden" name="unregister" value="true" />';
+        $html .= '<button class="btn btn-default" type="submit">'.get_lang('Ok').'</button>';
+        $html .= '</div>';
+        $html .= '</form>';
 
         return $html;
     }
@@ -2657,7 +2657,7 @@ class Blog
                     task_rel_user.c_id = $course_id AND
                     task.c_id = $course_id AND
                     blog.c_id = $course_id AND
-                    task_rel_user.user_id = " . $_user['user_id'] . " AND
+                    task_rel_user.user_id = ".$_user['user_id']." AND
                     MONTH(target_date) = '$month' AND
                     YEAR(target_date) = '$year'
                 ORDER BY target_date ASC";

+ 96 - 96
main/inc/lib/link.lib.php

@@ -79,11 +79,11 @@ class Link extends Model
         $params['session_id'] = api_get_session_id();
         $params['category_id'] = isset($params['category_id']) ? $params['category_id'] : 0;
 
-        $sql =  "SELECT MAX(display_order)
+        $sql = "SELECT MAX(display_order)
                 FROM  ".$this->table."
                 WHERE
                     c_id = $courseId AND
-                    category_id = '" . intval($params['category_id'])."'";
+                    category_id = '".intval($params['category_id'])."'";
         $result = Database:: query($sql);
         list ($orderMax) = Database:: fetch_row($result);
         $order = $orderMax + 1;
@@ -185,7 +185,7 @@ class Link extends Model
 
             // We ensure URL to be absolute.
             if (strpos($urllink, '://') === false) {
-                $urllink = 'http://' . $urllink;
+                $urllink = 'http://'.$urllink;
             }
 
             // If the title is empty, we use the URL as title.
@@ -207,7 +207,7 @@ class Link extends Model
                     'c_id' => $course_id,
                     'url' => $urllink,
                     'title' => $title,
-                    'description' => $description ,
+                    'description' => $description,
                     'category_id' => $selectcategory,
                     'on_homepage' => $onhomepage,
                     'target' => $target,
@@ -218,9 +218,9 @@ class Link extends Model
                 if ((api_get_setting('search_enabled') == 'true') &&
                     $link_id && extension_loaded('xapian')
                 ) {
-                    require_once api_get_path(LIBRARY_PATH) . 'search/ChamiloIndexer.class.php';
-                    require_once api_get_path(LIBRARY_PATH) . 'search/IndexableChunk.class.php';
-                    require_once api_get_path(LIBRARY_PATH) . 'specific_fields_manager.lib.php';
+                    require_once api_get_path(LIBRARY_PATH).'search/ChamiloIndexer.class.php';
+                    require_once api_get_path(LIBRARY_PATH).'search/IndexableChunk.class.php';
+                    require_once api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php';
 
                     $course_int_id = $_course['real_id'];
                     $courseCode = $_course['code'];
@@ -233,7 +233,7 @@ class Link extends Model
                         if (isset($_REQUEST[$specific_field['code']])) {
                             $sterms = trim($_REQUEST[$specific_field['code']]);
                             if (!empty($sterms)) {
-                                $all_specific_terms .= ' ' . $sterms;
+                                $all_specific_terms .= ' '.$sterms;
                                 $sterms = explode(',', $sterms);
                                 foreach ($sterms as $sterm) {
                                     $ic_slide->addTerm(
@@ -260,12 +260,12 @@ class Link extends Model
                         SE_COURSE_ID => $courseCode,
                         SE_TOOL_ID => TOOL_LINK,
                         SE_DATA => array(
-                            'link_id' => (int)$link_id
+                            'link_id' => (int) $link_id
                         ),
-                        SE_USER => (int)api_get_user_id(),
+                        SE_USER => (int) api_get_user_id(),
                     );
                     $ic_slide->xapian_data = serialize($xapian_data);
-                    $description = $all_specific_terms . ' ' . $description;
+                    $description = $all_specific_terms.' '.$description;
                     $ic_slide->addValue('content', $description);
 
                     // Add category name if set.
@@ -277,7 +277,7 @@ class Link extends Model
                         $sql_cat = sprintf(
                             $sql_cat,
                             $table_link_category,
-                            (int)$selectcategory,
+                            (int) $selectcategory,
                             $course_int_id
                         );
                         $result = Database:: query($sql_cat);
@@ -394,7 +394,7 @@ class Link extends Model
                 // but the visibility is set to 2 (in item_property).
                 // This will make a restore function possible for the platform administrator.
                 $sql = "UPDATE $tbl_link SET on_homepage='0'
-                        WHERE c_id = $course_id AND id='" . $id . "'";
+                        WHERE c_id = $course_id AND id='".$id."'";
                 Database:: query($sql);
 
                 api_item_property_update(
@@ -410,12 +410,12 @@ class Link extends Model
                 break;
             case 'category':
                 // First we delete the category itself and afterwards all the links of this category.
-                $sql = "DELETE FROM " . $tbl_categories . "
-                        WHERE c_id = $course_id AND id='" . $id . "'";
+                $sql = "DELETE FROM ".$tbl_categories."
+                        WHERE c_id = $course_id AND id='".$id."'";
                 Database:: query($sql);
 
-                $sql = "DELETE FROM " . $tbl_link . "
-                        WHERE c_id = $course_id AND category_id='" . $id . "'";
+                $sql = "DELETE FROM ".$tbl_link."
+                        WHERE c_id = $course_id AND category_id='".$id."'";
                 Database:: query($sql);
 
                 api_item_property_update(
@@ -452,16 +452,16 @@ class Link extends Model
             $res = Database:: query($sql);
             if (Database:: num_rows($res) > 0) {
                 $row = Database:: fetch_array($res);
-                require_once api_get_path(LIBRARY_PATH) . 'search/ChamiloIndexer.class.php';
+                require_once api_get_path(LIBRARY_PATH).'search/ChamiloIndexer.class.php';
                 $di = new ChamiloIndexer();
-                $di->remove_document((int)$row['search_did']);
+                $di->remove_document((int) $row['search_did']);
             }
             $sql = 'DELETE FROM %s WHERE course_code=\'%s\' AND tool_id=\'%s\' AND ref_id_high_level=%s LIMIT 1';
             $sql = sprintf($sql, $tbl_se_ref, $course_id, TOOL_LINK, $link_id);
             Database:: query($sql);
 
             // Remove terms from db.
-            require_once api_get_path(LIBRARY_PATH) . 'specific_fields_manager.lib.php';
+            require_once api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php';
             delete_all_values_for_item($course_id, TOOL_DOCUMENT, $link_id);
         }
     }
@@ -484,7 +484,7 @@ class Link extends Model
         }
 
         $sql = "SELECT * FROM $tbl_link
-                WHERE c_id = $course_id AND id='" . intval($id) . "' ";
+                WHERE c_id = $course_id AND id='".intval($id)."' ";
         $result = Database::query($sql);
         $data = array();
         if (Database::num_rows($result)) {
@@ -514,7 +514,7 @@ class Link extends Model
 
         // We ensure URL to be absolute.
         if (strpos($values['url'], '://') === false) {
-            $values['url'] = 'http://' . $_POST['url'];
+            $values['url'] = 'http://'.$_POST['url'];
         }
 
         // If the title is empty, we use the URL as title.
@@ -537,7 +537,7 @@ class Link extends Model
 
         // Finding the old category_id.
         $sql = "SELECT * FROM $tbl_link
-                WHERE c_id = $course_id AND id='" . $id . "'";
+                WHERE c_id = $course_id AND id='".$id."'";
         $result = Database:: query($sql);
         $row = Database:: fetch_array($result);
         $category_id = $row['category_id'];
@@ -547,7 +547,7 @@ class Link extends Model
                     FROM $tbl_link 
                     WHERE
                         c_id = $course_id AND
-                        category_id='" . intval($values['category_id']) . "'";
+                        category_id='".intval($values['category_id'])."'";
             $result = Database:: query($sql);
             list ($max_display_order) = Database:: fetch_row($result);
             $max_display_order++;
@@ -616,7 +616,7 @@ class Link extends Model
                             $_REQUEST[$specific_field['code']]
                         );
                         if (!empty($sterms)) {
-                            $all_specific_terms .= ' ' . $sterms;
+                            $all_specific_terms .= ' '.$sterms;
                             $sterms = explode(',', $sterms);
                             foreach ($sterms as $sterm) {
                                 $ic_slide->addTerm(
@@ -643,13 +643,13 @@ class Link extends Model
                     SE_COURSE_ID => $course_id,
                     SE_TOOL_ID => TOOL_LINK,
                     SE_DATA => array(
-                        'link_id' => (int)$id
+                        'link_id' => (int) $id
                     ),
-                    SE_USER => (int)api_get_user_id(),
+                    SE_USER => (int) api_get_user_id(),
 
                 );
                 $ic_slide->xapian_data = serialize($xapian_data);
-                $link_description = $all_specific_terms . ' ' . $link_description;
+                $link_description = $all_specific_terms.' '.$link_description;
                 $ic_slide->addValue('content', $link_description);
 
                 // Add category name if set.
@@ -677,7 +677,7 @@ class Link extends Model
                 $di = new ChamiloIndexer();
                 isset ($_POST['language']) ? $lang = Database:: escape_string($_POST['language']) : $lang = 'english';
                 $di->connectDb(null, null, $lang);
-                $di->remove_document((int)$se_ref['search_did']);
+                $di->remove_document((int) $se_ref['search_did']);
                 $di->addChunk($ic_slide);
 
                 // Index and return search engine document id.
@@ -817,10 +817,10 @@ class Link extends Model
                 INNER JOIN $tblItemProperty ip
                 ON (linkcat.id = ip.ref AND linkcat.c_id = ip.c_id)
                 WHERE
-                    ip.tool = '" . TOOL_LINK_CATEGORY . "' AND
+                    ip.tool = '".TOOL_LINK_CATEGORY."' AND
                     (ip.visibility = '0' OR ip.visibility = '1')
                     $sessionCondition AND
-                    linkcat.c_id = " . $courseId . "
+                    linkcat.c_id = ".$courseId."
                 ORDER BY linkcat.display_order DESC";
 
         $result = Database::query($sql);
@@ -843,10 +843,10 @@ class Link extends Model
                 INNER JOIN $tblItemProperty ip
                 ON (linkcat.id = ip.ref AND linkcat.c_id = ip.c_id)
                 WHERE
-                    ip.tool = '" . TOOL_LINK_CATEGORY . "' AND
+                    ip.tool = '".TOOL_LINK_CATEGORY."' AND
                     (ip.visibility = '0' OR ip.visibility = '1')
                     $sessionCondition AND
-                    linkcat.c_id = " . $courseId . "
+                    linkcat.c_id = ".$courseId."
                 ORDER BY linkcat.display_order DESC
                 ";
         $result = Database::query($sql);
@@ -906,7 +906,7 @@ class Link extends Model
                 false,
                 'ip.session_id'
             );
-            $condition .=  " AND (ip.visibility = '0' OR ip.visibility = '1') $condition " ;
+            $condition .= " AND (ip.visibility = '0' OR ip.visibility = '1') $condition ";
         }
 
         $sql = "SELECT 
@@ -924,8 +924,8 @@ class Link extends Model
                 INNER JOIN $TABLE_ITEM_PROPERTY ip
                 ON (link.id = ip.ref AND link.c_id = ip.c_id)
                 WHERE
-                    ip.tool = '" . TOOL_LINK . "' AND
-                    link.category_id = '" . $categoryId . "' AND
+                    ip.tool = '".TOOL_LINK."' AND
+                    link.category_id = '" . $categoryId."' AND
                     link.c_id = $courseId AND
                     ip.c_id = $courseId
                     $condition
@@ -985,7 +985,7 @@ class Link extends Model
                         'check-circle-o',
                         'default btn-sm',
                         array(
-                            'onclick' => "check_url('" . $linkId . "', '" . addslashes($myrow['url']) . "');",
+                            'onclick' => "check_url('".$linkId."', '".addslashes($myrow['url'])."');",
                             'title' => get_lang('CheckURL')
                         )
                     );
@@ -993,7 +993,7 @@ class Link extends Model
                     $link_validator .= Display::span(
                         '',
                         array(
-                        'id' => 'url_id_' . $linkId,
+                        'id' => 'url_id_'.$linkId,
                         'class' => 'check-link'
                         )
                     );
@@ -1012,10 +1012,10 @@ class Link extends Model
                         );
                     }
 
-                    $urlVisibility = api_get_self().'?'.api_get_cidreq() .
-                            '&sec_token=' . $token .
-                            '&id=' . $linkId .
-                            '&scope=link&category_id=' . $categoryId;
+                    $urlVisibility = api_get_self().'?'.api_get_cidreq().
+                            '&sec_token='.$token.
+                            '&id='.$linkId.
+                            '&scope=link&category_id='.$categoryId;
 
                     switch ($myrow['visibility']) {
                         case '1':
@@ -1056,25 +1056,25 @@ class Link extends Model
 
                         $toolbar .= Display::toolbarButton(
                             get_lang('MoveUp'),
-                            api_get_self() . '?'.api_get_cidreq() . '&' . http_build_query($moveLinkParams),
+                            api_get_self().'?'.api_get_cidreq().'&'.http_build_query($moveLinkParams),
                             'level-up',
                             'default',
-                            ['class' => 'btn-sm ' . ($i === 1 ? 'disabled' : '')],
+                            ['class' => 'btn-sm '.($i === 1 ? 'disabled' : '')],
                             false
                         );
 
                         $moveLinkParams['action'] = 'move_link_down';
                         $toolbar .= Display::toolbarButton(
                             get_lang('MoveDown'),
-                            api_get_self().'?' . api_get_cidreq() . '&' . http_build_query($moveLinkParams),
+                            api_get_self().'?'.api_get_cidreq().'&'.http_build_query($moveLinkParams),
                             'level-down',
                             'default',
-                            ['class' => 'btn-sm ' . ($i === $numberOfLinks ? 'disabled' : '')],
+                            ['class' => 'btn-sm '.($i === $numberOfLinks ? 'disabled' : '')],
                             false
                         );
 
-                        $url .= api_get_self().'?'.api_get_cidreq() .'&sec_token=' . $token .'&action=deletelink&id=' . $linkId .'&category_id=' . $categoryId;
-                        $event = "javascript: if(!confirm('" . get_lang('LinkDelconfirm') . "'))return false;";
+                        $url .= api_get_self().'?'.api_get_cidreq().'&sec_token='.$token.'&action=deletelink&id='.$linkId.'&category_id='.$categoryId;
+                        $event = "javascript: if(!confirm('".get_lang('LinkDelconfirm')."'))return false;";
                         $title = get_lang('Delete');
 
                         $toolbar .= Display::toolbarButton(
@@ -1102,7 +1102,7 @@ class Link extends Model
                     $content .= '<div class="pull-right"><div class="btn-group">'.$toolbar.'</div></div>';
                     $content .= '<h4 class="list-group-item-heading">';
                     $content .= $iconLink;
-                    $url = api_get_path(WEB_CODE_PATH).'link/link_goto.php?' . api_get_cidreq() .'&link_id=' . $linkId .'&link_url=' . urlencode($myrow['url']);
+                    $url = api_get_path(WEB_CODE_PATH).'link/link_goto.php?'.api_get_cidreq().'&link_id='.$linkId.'&link_url='.urlencode($myrow['url']);
                     $content .= Display::tag(
                         'a',
                         Security::remove_XSS($myrow['title']),
@@ -1115,7 +1115,7 @@ class Link extends Model
                     $content .= $session_img;
                     $content .= '</h4>';
 
-                    $content .= '<p class="list-group-item-text">' . $myrow['description'] . '</p>';
+                    $content .= '<p class="list-group-item-text">'.$myrow['description'].'</p>';
                     $content .= '</div>';
                 } else {
                     if (api_is_allowed_to_edit(null, true)) {
@@ -1123,7 +1123,7 @@ class Link extends Model
                         $content .= '<div class="pull-right"><div class="btn-group">'.$toolbar.'</div></div>';
                         $content .= '<h4 class="list-group-item-heading">';
                         $content .= $iconLink;
-                        $url = api_get_path(WEB_CODE_PATH).'link/link_goto.php?' . api_get_cidreq() .'&link_id=' . $linkId . "&link_url=" . urlencode($myrow['url']);
+                        $url = api_get_path(WEB_CODE_PATH).'link/link_goto.php?'.api_get_cidreq().'&link_id='.$linkId."&link_url=".urlencode($myrow['url']);
                         $content .= Display::tag(
                             'a',
                             Security::remove_XSS($myrow['title']),
@@ -1136,7 +1136,7 @@ class Link extends Model
                         $content .= $link_validator;
                         $content .= $session_img;
                         $content .= '</h4>';
-                        $content .= '<p class="list-group-item-text">' . $myrow['description'] . '</p>';
+                        $content .= '<p class="list-group-item-text">'.$myrow['description'].'</p>';
                         $content .= '</div>';
                     }
                 }
@@ -1161,58 +1161,58 @@ class Link extends Model
     {
         $categoryId = $category['id'];
         $token = null;
-        $tools = '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&sec_token=' . $token . '&action=editcategory&id=' . $categoryId . '&category_id=' . $categoryId . '" title=' . get_lang('Modify') . '">' .
+        $tools = '<a href="'.api_get_self().'?'.api_get_cidreq().'&sec_token='.$token.'&action=editcategory&id='.$categoryId.'&category_id='.$categoryId.'" title='.get_lang('Modify').'">'.
             Display:: return_icon(
                 'edit.png',
                 get_lang('Modify'),
                 array(),
                 ICON_SIZE_SMALL
-            ) . '</a>';
+            ).'</a>';
 
         // DISPLAY MOVE UP COMMAND only if it is not the top link.
         if ($currentCategory != 0) {
-            $tools .= '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&sec_token=' . $token . '&action=up&up='.$categoryId.'&category_id='.$categoryId.'" title="'.get_lang('Up').'">'.
+            $tools .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&sec_token='.$token.'&action=up&up='.$categoryId.'&category_id='.$categoryId.'" title="'.get_lang('Up').'">'.
                 Display:: return_icon(
                     'up.png',
                     get_lang('Up'),
                     array(),
                     ICON_SIZE_SMALL
-                ) . '</a>';
+                ).'</a>';
         } else {
             $tools .= Display:: return_icon(
                 'up_na.png',
                 get_lang('Up'),
                 array(),
                 ICON_SIZE_SMALL
-            ) . '</a>';
+            ).'</a>';
         }
 
         // DISPLAY MOVE DOWN COMMAND only if it is not the bottom link.
-        if ($currentCategory < $countCategories-1) {
-            $tools .= '<a href="' . api_get_self() . '?' . api_get_cidreq() .'&sec_token=' . $token .'&action=down&down=' . $categoryId .'&category_id=' . $categoryId . '">'.
+        if ($currentCategory < $countCategories - 1) {
+            $tools .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&sec_token='.$token.'&action=down&down='.$categoryId.'&category_id='.$categoryId.'">'.
                 Display:: return_icon(
                     'down.png',
                     get_lang('Down'),
                     array(),
                     ICON_SIZE_SMALL
-                ) . '</a>';
+                ).'</a>';
         } else {
             $tools .= Display:: return_icon(
                     'down_na.png',
                     get_lang('Down'),
                     array(),
                     ICON_SIZE_SMALL
-                ) . '</a>';
+                ).'</a>';
         }
 
-        $tools .= '<a href="' . api_get_self() . '?' . api_get_cidreq() .'&sec_token=' . $token .'&action=deletecategory&id='.$categoryId.            "&category_id=$categoryId\"
-            onclick=\"javascript: if(!confirm('" . get_lang('CategoryDelconfirm') . "')) return false;\">".
+        $tools .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&sec_token='.$token.'&action=deletecategory&id='.$categoryId."&category_id=$categoryId\"
+            onclick=\"javascript: if(!confirm('".get_lang('CategoryDelconfirm')."')) return false;\">".
             Display:: return_icon(
                 'delete.png',
                 get_lang('Delete'),
                 array(),
                 ICON_SIZE_SMALL
-            ) . '</a>';
+            ).'</a>';
 
         return $tools;
     }
@@ -1268,12 +1268,12 @@ class Link extends Model
                     $nextlinkOrder = $sortrow['display_order'];
 
                     Database:: query(
-                        "UPDATE " . $movetable . "
+                        "UPDATE ".$movetable."
                         SET display_order = '$nextlinkOrder'
                         WHERE c_id = $courseId  AND id =  '$thiscatlinkId'"
                     );
                     Database:: query(
-                        "UPDATE " . $movetable . "
+                        "UPDATE ".$movetable."
                         SET display_order = '$thislinkOrder'
                         WHERE c_id = $courseId  AND id =  '$nextlinkId'"
                     );
@@ -1302,15 +1302,15 @@ class Link extends Model
         $course_id = api_get_course_int_id();
 
         $result = Database:: query(
-            "SELECT id FROM " . $tbl_categories . "
-            WHERE c_id = $course_id AND category_title='" . Database::escape_string($catname) . "'"
+            "SELECT id FROM ".$tbl_categories."
+            WHERE c_id = $course_id AND category_title='".Database::escape_string($catname)."'"
         );
         if (Database:: num_rows($result) >= 1 && ($row = Database:: fetch_array($result))) {
             return $row['id']; // Several categories with same name: take the first.
         }
 
         $result = Database:: query(
-            "SELECT MAX(display_order) FROM " . $tbl_categories . " WHERE c_id = $course_id "
+            "SELECT MAX(display_order) FROM ".$tbl_categories." WHERE c_id = $course_id "
         );
         list ($max_order) = Database:: fetch_row($result);
 
@@ -1342,19 +1342,19 @@ class Link extends Model
         $tbl_link = Database::get_course_table(TABLE_LINK);
         $course_id = api_get_course_int_id();
 
-        $urleq = "url='" . Database:: escape_string($url) . "'";
-        $cateq = "category_id=" . intval($cat);
+        $urleq = "url='".Database:: escape_string($url)."'";
+        $cateq = "category_id=".intval($cat);
 
         $result = Database:: query("
             SELECT id FROM $tbl_link
-            WHERE c_id = $course_id AND " . $urleq . ' AND ' . $cateq
+            WHERE c_id = $course_id AND ".$urleq.' AND '.$cateq
         );
 
         if (Database:: num_rows($result) >= 1 && ($row = Database:: fetch_array($result))) {
             $sql = "UPDATE $tbl_link SET 
-                        title = '" . Database:: escape_string($title) . "', 
-                        description = '" . Database:: escape_string($description) . "'
-                    WHERE c_id = $course_id AND  id='" . Database:: escape_string($row['id']) . "'";
+                        title = '".Database:: escape_string($title)."', 
+                        description = '" . Database:: escape_string($description)."'
+                    WHERE c_id = $course_id AND  id='".Database:: escape_string($row['id'])."'";
             Database:: query($sql);
 
             $ipu = 'LinkUpdated';
@@ -1363,18 +1363,18 @@ class Link extends Model
             // Add new link
             $result = Database:: query(
                 "SELECT MAX(display_order) FROM  $tbl_link
-                WHERE c_id = $course_id AND category_id='" . intval($cat) . "'"
+                WHERE c_id = $course_id AND category_id='".intval($cat)."'"
             );
             list ($max_order) = Database:: fetch_row($result);
 
             Database:: query(
                 "INSERT INTO $tbl_link (c_id, url, title, description, category_id, display_order, on_homepage)
-                VALUES (" . api_get_course_int_id() . ",
-                '" . Database:: escape_string($url) . "',
-                '" . Database:: escape_string($title) . "',
-                '" . Database:: escape_string($description) . "',
-                '" . intval($cat) . "','" . (intval($max_order) + 1) . "',
-                '" . intval($on_homepage) .
+                VALUES (".api_get_course_int_id().",
+                '" . Database:: escape_string($url)."',
+                '" . Database:: escape_string($title)."',
+                '" . Database:: escape_string($description)."',
+                '" . intval($cat)."','".(intval($max_order) + 1)."',
+                '" . intval($on_homepage).
                 "')"
             );
 
@@ -1451,30 +1451,30 @@ class Link extends Model
                     )
                 ) { // possibly in <...>
                     if (($kwlist = trim($regs[1])) != '') {
-                        $kw = '<i kw="' . htmlspecialchars($kwlist) . '">';
+                        $kw = '<i kw="'.htmlspecialchars($kwlist).'">';
                     } else {
                         $kw = '';
                     }
                     // i.e. assume only one of the $hide_fields will be present
                     // and if found, hide the value as expando property of an <i> tag
                 } elseif (trim($value)) {
-                    $d .= ', ' . $key . ':' . $value;
+                    $d .= ', '.$key.':'.$value;
                 }
             }
         }
         if (!empty($d)) {
-            $d = substr($d, 2) . ' - ';
+            $d = substr($d, 2).' - ';
         }
 
         return self::put_link(
             $url,
             $cat,
             $title,
-            $kw . ereg_replace(
+            $kw.ereg_replace(
                 '\[((/?(b|big|i|small|sub|sup|u))|br/)\]',
                 '<\\1>',
-                htmlspecialchars($d . $linkdata['description'])
-            ) . ($kw ? '</i>' : ''),
+                htmlspecialchars($d.$linkdata['description'])
+            ).($kw ? '</i>' : ''),
             $linkdata['on_homepage'] ? '1' : '0',
             $linkdata['hidden'] ? '1' : '0'
         );
@@ -1593,19 +1593,19 @@ class Link extends Model
         echo '<div class="actions">';
         if (api_is_allowed_to_edit(null, true)) {
             echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&action=addlink&category_id='.$categoryId.'">'.
-                Display::return_icon('new_link.png', get_lang('LinkAdd'),'',ICON_SIZE_MEDIUM).'</a>';
+                Display::return_icon('new_link.png', get_lang('LinkAdd'), '', ICON_SIZE_MEDIUM).'</a>';
             echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&action=addcategory&category_id='.$categoryId.'">'.
-                Display::return_icon('new_folder.png', get_lang('CategoryAdd'),'',ICON_SIZE_MEDIUM).'</a>';
+                Display::return_icon('new_folder.png', get_lang('CategoryAdd'), '', ICON_SIZE_MEDIUM).'</a>';
         }
 
         $categories = self::getLinkCategories($course_id, $session_id);
         $countCategories = count($categories);
         if (!empty($countCategories)) {
             echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&action=list&show=none">';
-            echo Display::return_icon('forum_listview.png', get_lang('FlatView'), '', ICON_SIZE_MEDIUM) . ' </a>';
+            echo Display::return_icon('forum_listview.png', get_lang('FlatView'), '', ICON_SIZE_MEDIUM).' </a>';
 
             echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&action=list&show=all">';
-            echo Display::return_icon('forum_nestedview.png', get_lang('NestedView'), '', ICON_SIZE_MEDIUM) . '</a>';
+            echo Display::return_icon('forum_nestedview.png', get_lang('NestedView'), '', ICON_SIZE_MEDIUM).'</a>';
         }
         echo '</div>';
 
@@ -1648,12 +1648,12 @@ class Link extends Model
             $strVisibility = '';
             $visibilityClass = null;
             if ($myrow['visibility'] == '1') {
-                $strVisibility =  '<a href="link.php?' . api_get_cidreq() .  '&sec_token='.$token.'&action=invisible&id=' . $myrow['id'] . '&scope=' . TOOL_LINK_CATEGORY . '" title="' . get_lang('Hide') . '">' .
-                    Display::return_icon('visible.png', get_lang('Hide'), array (), ICON_SIZE_SMALL) . '</a>';
+                $strVisibility = '<a href="link.php?'.api_get_cidreq().'&sec_token='.$token.'&action=invisible&id='.$myrow['id'].'&scope='.TOOL_LINK_CATEGORY.'" title="'.get_lang('Hide').'">'.
+                    Display::return_icon('visible.png', get_lang('Hide'), array(), ICON_SIZE_SMALL).'</a>';
             } elseif ($myrow['visibility'] == '0') {
                 $visibilityClass = 'text-muted';
-                $strVisibility =  ' <a href="link.php?' . api_get_cidreq() .  '&sec_token='.$token.'&action=visible&id=' . $myrow['id'] . '&scope=' . TOOL_LINK_CATEGORY . '" title="' . get_lang('Show') . '">' .
-                    Display::return_icon('invisible.png', get_lang('Show'), array (), ICON_SIZE_SMALL) . '</a>';
+                $strVisibility = ' <a href="link.php?'.api_get_cidreq().'&sec_token='.$token.'&action=visible&id='.$myrow['id'].'&scope='.TOOL_LINK_CATEGORY.'" title="'.get_lang('Show').'">'.
+                    Display::return_icon('invisible.png', get_lang('Show'), array(), ICON_SIZE_SMALL).'</a>';
             }
 
             $header = '';

+ 13 - 13
main/mySpace/works_in_session_report.php

@@ -53,7 +53,7 @@ if ($session) {
     foreach ($sessionCourses as $sessionCourse) {
         /** @var Course $course */
         $course = $sessionCourse->getCourse();
-        $coursesInfo[$course->getId()] =  $course->getCode();
+        $coursesInfo[$course->getId()] = $course->getCode();
         $userCourseSubscriptions = $session->getUserCourseSubscriptionsByStatus($course, Session::STUDENT);
 
         foreach ($userCourseSubscriptions as $userCourseSubscription) {
@@ -72,15 +72,15 @@ if ($session) {
                 ];
             }
 
-            $usersInfo[$user->getId()][$course->getId() . '_score'] = null;
-            $usersInfo[$user->getId()][$course->getId() . '_progress'] = null;
-            $usersInfo[$user->getId()][$course->getId() . '_last_sent_date'] = null;
+            $usersInfo[$user->getId()][$course->getId().'_score'] = null;
+            $usersInfo[$user->getId()][$course->getId().'_progress'] = null;
+            $usersInfo[$user->getId()][$course->getId().'_last_sent_date'] = null;
 
             if (!$session->hasStudentInCourse($user, $course)) {
                 continue;
             }
 
-            $usersInfo[$user->getId()][$course->getId() . '_score'] = Tracking::get_avg_student_score(
+            $usersInfo[$user->getId()][$course->getId().'_score'] = Tracking::get_avg_student_score(
                 $user->getId(),
                 $course->getCode(),
                 null,
@@ -90,7 +90,7 @@ if ($session) {
                 true
 
             );
-            $usersInfo[$user->getId()][$course->getId() . '_progress'] = Tracking::get_avg_student_progress(
+            $usersInfo[$user->getId()][$course->getId().'_progress'] = Tracking::get_avg_student_progress(
                 $user->getId(),
                 $course->getCode(),
                 null,
@@ -108,14 +108,14 @@ if ($session) {
                 continue;
             }
 
-            $usersInfo[$user->getId()][$course->getId() . '_last_sent_date'] = api_get_local_time(
+            $usersInfo[$user->getId()][$course->getId().'_last_sent_date'] = api_get_local_time(
                 $lastPublication->getSentDate()->getTimestamp());
         }
     }
 }
 
 if (isset($_GET['export']) && $session && ($coursesInfo && $usersInfo)) {
-    $fileName = 'works_in_session_' . api_get_local_time();
+    $fileName = 'works_in_session_'.api_get_local_time();
 
     $dataToExport = [];
     $dataToExport[] = [$toolName, $session->getName()];
@@ -126,7 +126,7 @@ if (isset($_GET['export']) && $session && ($coursesInfo && $usersInfo)) {
     $dataToExport['headers'][] = get_lang('LatestLoginInPlatform');
 
     foreach ($coursesInfo as $courseCode) {
-        $dataToExport['headers'][] = $courseCode. ' ('.get_lang('BestScore').')';
+        $dataToExport['headers'][] = $courseCode.' ('.get_lang('BestScore').')';
         $dataToExport['headers'][] = get_lang('Progress');
         $dataToExport['headers'][] = get_lang('LastSentWorkDate');
     }
@@ -148,7 +148,7 @@ if (isset($_GET['export']) && $session && ($coursesInfo && $usersInfo)) {
 }
 
 $interbreadcrumb[] = [
-    'url' => api_get_path(WEB_CODE_PATH) . 'mySpace/index.php',
+    'url' => api_get_path(WEB_CODE_PATH).'mySpace/index.php',
     'name' => get_lang('MySpace')
 ];
 
@@ -157,11 +157,11 @@ $actions = null;
 if ($session) {
     $actions = Display::url(
         Display::return_icon('export_csv.png', get_lang('ExportAsCSV'), [], ICON_SIZE_MEDIUM),
-        api_get_self() . '?' . http_build_query(['export' => 'csv', 'session' => $session->getId()])
+        api_get_self().'?'.http_build_query(['export' => 'csv', 'session' => $session->getId()])
     );
-    $actions .=Display::url(
+    $actions .= Display::url(
         Display::return_icon('export_excel.png', get_lang('ExportAsXLS'), [], ICON_SIZE_MEDIUM),
-        api_get_self() . '?' . http_build_query(['export' => 'xls', 'session' => $session->getId()])
+        api_get_self().'?'.http_build_query(['export' => 'xls', 'session' => $session->getId()])
     );
 }
 

+ 11 - 11
main/session/session_course_edit.php

@@ -36,15 +36,15 @@ $sql = "SELECT s.name, c.title
             sc.c_id ='".$courseId."'";
 $result = Database::query($sql);
 
-if (!list($session_name,$course_title) = Database::fetch_row($result)) {
+if (!list($session_name, $course_title) = Database::fetch_row($result)) {
     header('Location: session_course_list.php?id_session='.$id_session);
     exit();
 }
 
 //$interbreadcrumb[]=array('url' => 'index.php',"name" => get_lang('PlatformAdmin'));
-$interbreadcrumb[]=array('url' => "session_list.php","name" => get_lang("SessionList"));
-$interbreadcrumb[]=array('url' => "resume_session.php?id_session=".$id_session,"name" => get_lang('SessionOverview'));
-$interbreadcrumb[]=array('url' => "session_course_list.php?id_session=$id_session","name" =>api_htmlentities($session_name, ENT_QUOTES, $charset));
+$interbreadcrumb[] = array('url' => "session_list.php", "name" => get_lang("SessionList"));
+$interbreadcrumb[] = array('url' => "resume_session.php?id_session=".$id_session, "name" => get_lang('SessionOverview'));
+$interbreadcrumb[] = array('url' => "session_course_list.php?id_session=$id_session", "name" =>api_htmlentities($session_name, ENT_QUOTES, $charset));
 
 $arr_infos = array();
 if (isset($_POST['formSent']) && $_POST['formSent']) {
@@ -57,13 +57,13 @@ if (isset($_POST['formSent']) && $_POST['formSent']) {
     $rs_coaches = Database::query($sql);
 
     $coaches_course_session = array();
-    if (Database::num_rows($rs_coaches) > 0){
+    if (Database::num_rows($rs_coaches) > 0) {
         while ($row_coaches = Database::fetch_row($rs_coaches)) {
             $coaches_course_session[] = $row_coaches[0];
         }
     }
 
-    $id_coaches= $_POST['id_coach'];
+    $id_coaches = $_POST['id_coach'];
 
     if (is_array($id_coaches) && count($id_coaches) > 0) {
 
@@ -77,7 +77,7 @@ if (isset($_POST['formSent']) && $_POST['formSent']) {
         }
 
         // set status to 0 other tutors from multiple list
-        $array_intersect = array_diff($coaches_course_session,$id_coaches);
+        $array_intersect = array_diff($coaches_course_session, $id_coaches);
 
         foreach ($array_intersect as $no_coach_user_id) {
             $rs2 = SessionManager::set_coach_to_course_session(
@@ -110,7 +110,7 @@ if (isset($_POST['formSent']) && $_POST['formSent']) {
 $order_clause = api_sort_by_first_name() ? ' ORDER BY firstname, lastname, username' : ' ORDER BY lastname, firstname, username';
 
 if (api_is_multiple_url_enabled()) {
-    $tbl_access_rel_user= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
+    $tbl_access_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
     $access_url_id = api_get_current_access_url_id();
     $sql = "SELECT u.user_id,lastname,firstname,username
             FROM $tbl_user u
@@ -152,7 +152,7 @@ api_display_tool_title($tool_name);
     <div class="col-md-12">
         <div class="title"></div>
         <?php
-            if(!empty($errorMsg)) {
+            if (!empty($errorMsg)) {
                 echo Display::return_message($errorMsg);
             }
         ?>
@@ -166,13 +166,13 @@ api_display_tool_title($tool_name);
 
         <select name="id_coach[]" class="form-control" multiple>
             <option value="0">----- <?php echo get_lang("Choose") ?> -----</option>
-            <option value="0" <?php if(count($arr_infos) == 0) echo 'selected="selected"'; ?>>
+            <option value="0" <?php if (count($arr_infos) == 0) echo 'selected="selected"'; ?>>
                 <?php echo get_lang('None') ?>
             </option>
             <?php
             foreach ($coaches as $enreg) {
                 ?>
-                <option value="<?php echo $enreg['user_id']; ?>" <?php if(((is_array($arr_infos) && in_array($enreg['user_id'], $arr_infos)))) echo 'selected="selected"'; ?>>
+                <option value="<?php echo $enreg['user_id']; ?>" <?php if (((is_array($arr_infos) && in_array($enreg['user_id'], $arr_infos)))) echo 'selected="selected"'; ?>>
                     <?php echo api_get_person_name($enreg['firstname'], $enreg['lastname']).' ('.$enreg['username'].')'; ?>
                 </option>
             <?php

+ 5 - 5
main/webservices/courses_list.rest.php

@@ -81,11 +81,11 @@ if (empty($_POST['security-key']) || empty($_POST['visibility'])) {
     $courses_list = courses_list($_POST['security-key'], $_POST['visibility']);
     foreach ($courses_list as $code => $cd) {
         echo '<course>';
-        echo '<code>' , $code , '</code>';
-        echo '<title>' , $cd['title'] , '</title>';
-        echo '<url>' , $cd['url'] , '</url>';
-        echo '<teacher>' , $cd['teacher'] , '</teacher>';
-        echo '<language>' , $cd['language'] , '</language>';
+        echo '<code>', $code, '</code>';
+        echo '<title>', $cd['title'], '</title>';
+        echo '<url>', $cd['url'], '</url>';
+        echo '<teacher>', $cd['teacher'], '</teacher>';
+        echo '<language>', $cd['language'], '</language>';
         echo '</course>';
     }
 }

+ 1 - 1
main/webservices/webservice.php

@@ -212,7 +212,7 @@ class WS
     protected function getSessionId($session_id_field_name, $session_id_value)
     {
         if ($session_id_field_name == "chamilo_session_id") {
-            $session = SessionManager::fetch((int)$session_id_value);
+            $session = SessionManager::fetch((int) $session_id_value);
             if (!empty($session)) {
                 return intval($session_id_value);
             } else {

+ 3 - 3
main/webservices/webservice_course.php

@@ -330,13 +330,13 @@ class WSCourse extends WS
                 $attributes['course_language'] = $language;
             }
             if ($visibility != '') {
-                $attributes['visibility'] = (int)$visibility;
+                $attributes['visibility'] = (int) $visibility;
             }
             if ($subscribe != '') {
-                $attributes['subscribe'] = (int)$subscribe;
+                $attributes['subscribe'] = (int) $subscribe;
             }
             if ($unsubscribe != '') {
-                $attributes['unsubscribe'] = (int)$unsubscribe;
+                $attributes['unsubscribe'] = (int) $unsubscribe;
             }
             if (!empty($visual_code)) {
                 $attributes['visual_code'] = $visual_code;

+ 1 - 1
main/webservices/webservice_session.php

@@ -287,7 +287,7 @@ class WSSession extends WS
                 $coachEndDate,
                 $user_id,
                 0,
-                (int)$visibility
+                (int) $visibility
             );
             if (!is_int($result_id)) {
                 return new WSError(302, 'Could not edit the session');