Browse Source

Merge pull request #1923 from chamilo/scrutinizer-patch-1

Scrutinizer Auto-Fixes
Julio Montoya 7 years ago
parent
commit
ddd0cdeda2

+ 1 - 1
main/admin/career_dashboard.php

@@ -82,7 +82,7 @@ $actionleft .= Display::url(
         ICON_SIZE_MEDIUM),
     'promotions.php');
 
-$actions = Display::toolbarAction('toolbar-career', array( 0 => $actionleft));
+$actions = Display::toolbarAction('toolbar-career', array(0 => $actionleft));
 
 $html .= $form->return_form();
 

+ 20 - 20
main/admin/user_list.php

@@ -124,10 +124,10 @@ function clear_session_list(div_session) {
 function display_advanced_search_form () {
     if ($("#advanced_search_form").css("display") == "none") {
         $("#advanced_search_form").css("display","block");
-        $("#img_plus_and_minus").html(\' '. Display::returnFontAwesomeIcon('arrow-down') . ' '. get_lang('AdvancedSearch').'\');
+        $("#img_plus_and_minus").html(\' '. Display::returnFontAwesomeIcon('arrow-down').' '.get_lang('AdvancedSearch').'\');
     } else {
         $("#advanced_search_form").css("display","none");
-        $("#img_plus_and_minus").html(\' '. Display::returnFontAwesomeIcon('arrow-right') . ' '.get_lang('AdvancedSearch').'\');
+        $("#img_plus_and_minus").html(\' '. Display::returnFontAwesomeIcon('arrow-right').' '.get_lang('AdvancedSearch').'\');
     }
 }
 
@@ -204,7 +204,7 @@ function prepare_user_sql_query($is_count)
     // adding the filter to see the user's only of the current access_url
     if ((api_is_platform_admin() || api_is_session_admin()) && api_get_multiple_access_url()) {
         $access_url_rel_user_table = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
-        $sql.= " INNER JOIN $access_url_rel_user_table url_rel_user ON (u.id=url_rel_user.user_id)";
+        $sql .= " INNER JOIN $access_url_rel_user_table url_rel_user ON (u.id=url_rel_user.user_id)";
     }
 
     $keywordList = array(
@@ -243,7 +243,7 @@ function prepare_user_sql_query($is_count)
     */
 
     if (isset($_GET['keyword']) && !empty($_GET['keyword'])) {
-        $keywordFiltered = Database::escape_string("%". $_GET['keyword'] ."%");
+        $keywordFiltered = Database::escape_string("%".$_GET['keyword']."%");
         $sql .= " WHERE (
                     u.firstname LIKE '$keywordFiltered' OR
                     u.lastname LIKE '$keywordFiltered' OR
@@ -277,13 +277,13 @@ function prepare_user_sql_query($is_count)
         */
         $sql .= " $query_admin_table
             WHERE (
-                u.firstname LIKE '". Database::escape_string("%".$keywordListValues['keyword_firstname']."%")."' AND
+                u.firstname LIKE '".Database::escape_string("%".$keywordListValues['keyword_firstname']."%")."' AND
                 u.lastname LIKE '". Database::escape_string("%".$keywordListValues['keyword_lastname']."%")."' AND
                 u.username LIKE '". Database::escape_string("%".$keywordListValues['keyword_username']."%")."' AND
                 u.email LIKE '". Database::escape_string("%".$keywordListValues['keyword_email']."%")."' AND
                 u.status LIKE '".Database::escape_string($keywordListValues['keyword_status'])."' ";
         if (!empty($keywordListValues['keyword_officialcode'])) {
-            $sql .= " AND u.official_code LIKE '" . Database::escape_string("%" . $keywordListValues['keyword_officialcode'] . "%") . "' ";
+            $sql .= " AND u.official_code LIKE '".Database::escape_string("%".$keywordListValues['keyword_officialcode']."%")."' ";
         }
         $sql .= "
             $keyword_admin
@@ -470,7 +470,7 @@ function get_number_of_users()
 function get_user_data($from, $number_of_items, $column, $direction)
 {
     $sql = prepare_user_sql_query(false);
-    if (!in_array($direction, array('ASC','DESC'))) {
+    if (!in_array($direction, array('ASC', 'DESC'))) {
         $direction = 'ASC';
     }
     $column = intval($column);
@@ -581,8 +581,8 @@ function modify_filter($user_id, $url_params, $row)
 					<div class="blackboard_hide" id="div_s_'.$user_id.'">&nbsp;&nbsp;</div>
 					</a>';
 	} else {
-		$result .= Display::return_icon('course_na.png',get_lang('Courses')).'&nbsp;&nbsp;';
-		$result .= Display::return_icon('course_na.png',get_lang('Sessions')).'&nbsp;&nbsp;';
+		$result .= Display::return_icon('course_na.png', get_lang('Courses')).'&nbsp;&nbsp;';
+		$result .= Display::return_icon('course_na.png', get_lang('Sessions')).'&nbsp;&nbsp;';
 	}
 
     if (api_is_platform_admin()) {
@@ -617,7 +617,7 @@ function modify_filter($user_id, $url_params, $row)
     if (api_is_platform_admin(true)) {
         $editProfileUrl = Display::getProfileEditionLink($user_id, true);
         if (!$user_is_anonymous && api_global_admin_can_edit_admin($user_id, null, true)) {
-            $result .= '<a href="' . $editProfileUrl . '">'.Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL).'</a>&nbsp;';
+            $result .= '<a href="'.$editProfileUrl.'">'.Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL).'</a>&nbsp;';
         } else {
             $result .= Display::return_icon('edit_na.png', get_lang('Edit'), array(), ICON_SIZE_SMALL).'</a>&nbsp;';
         }
@@ -628,7 +628,7 @@ function modify_filter($user_id, $url_params, $row)
     if ($allowAssignSkill) {
         $result .= Display::url(
             Display::return_icon('skill-badges.png', get_lang('AssignSkill'), null, ICON_SIZE_SMALL),
-            api_get_path(WEB_CODE_PATH) . 'badge/assign.php?' . http_build_query(['user' => $user_id])
+            api_get_path(WEB_CODE_PATH).'badge/assign.php?'.http_build_query(['user' => $user_id])
         );
     }
 
@@ -768,10 +768,10 @@ if (!empty($action)) {
             case 'add_user_to_my_url':
                 $user_id = $_REQUEST["user_id"];
                 $result = UrlManager::add_user_to_url($user_id, $current_access_url_id);
-                if ($result ) {
+                if ($result) {
                     $user_info = api_get_user_info($user_id);
                     $message = get_lang('UserAdded').' '.$user_info['firstname'].' '.$user_info['lastname'].' ('.$user_info['username'].')';
-                    $message  = Display::return_message($message, 'confirmation');
+                    $message = Display::return_message($message, 'confirmation');
                 }
                 break;
 			case 'delete_user':
@@ -830,7 +830,7 @@ $form->addButtonSearch(get_lang('Search'));
 $searchAdvanced = '
 <a id="advanced_params" href="javascript://" class = "btn btn-default advanced_options" onclick="display_advanced_search_form();">
     <span id="img_plus_and_minus">&nbsp;
-    '. Display::returnFontAwesomeIcon('arrow-right') . ' '.get_lang('AdvancedSearch').'
+    '. Display::returnFontAwesomeIcon('arrow-right').' '.get_lang('AdvancedSearch').'
     </span>
 </a>';
 $actionsLeft = '';
@@ -838,7 +838,7 @@ $actionsCenter = '';
 $actionsRight  = '';
 if (api_is_platform_admin()) {
 	$actionsRight .= '<a class="pull-right" href="'.api_get_path(WEB_CODE_PATH).'admin/user_add.php">'.
-         Display::return_icon('new_user.png',get_lang('AddUsers'),'',ICON_SIZE_MEDIUM).'</a>';
+         Display::return_icon('new_user.png', get_lang('AddUsers'), '', ICON_SIZE_MEDIUM).'</a>';
 }
 
 $actionsLeft .= $form->returnForm();
@@ -864,7 +864,7 @@ Session::write('admin_list', $_admins_list);
 // Display Advanced search form.
 $form = new FormValidator('advanced_search', 'get', '', '', array(), FormValidator::LAYOUT_HORIZONTAL);
 
-$form->addElement('html','<div id="advanced_search_form" style="display:none;">');
+$form->addElement('html', '<div id="advanced_search_form" style="display:none;">');
 $form->addElement('header', get_lang('AdvancedSearch'));
 $form->addText('keyword_firstname', get_lang('FirstName'), false);
 $form->addText('keyword_lastname', get_lang('LastName'), false);
@@ -903,7 +903,7 @@ $defaults = array();
 $defaults['keyword_active'] = 1;
 $defaults['keyword_inactive'] = 1;
 $form->setDefaults($defaults);
-$form->addElement('html','</div>');
+$form->addElement('html', '</div>');
 
 $form = $form->returnForm();
 
@@ -984,10 +984,10 @@ if ($table->get_total_number_of_items() == 0) {
                 }
                 if ($add_user) {
                     $row_table = array();
-                    $row_table[] =  api_get_person_name($user['firstname'], $user['lastname']).' ('.$user['username'].') ';
-                    $row_table[] =  $access_info_to_string;
+                    $row_table[] = api_get_person_name($user['firstname'], $user['lastname']).' ('.$user['username'].') ';
+                    $row_table[] = $access_info_to_string;
                     $url = api_get_self().'?action=add_user_to_my_url&user_id='.$user['id'].'&sec_token='.$_SESSION['sec_token'];
-                    $row_table[] =  Display::url(get_lang('AddUserToMyURL'), $url, array('class' => 'btn'));
+                    $row_table[] = Display::url(get_lang('AddUserToMyURL'), $url, array('class' => 'btn'));
 
                     foreach ($row_table as $cell) {
                         $table->setCellContents($row, $column, $cell);

+ 8 - 8
main/document/create_audio.php

@@ -328,33 +328,33 @@ function downloadMP3_google($filepath, $dir)
     $clean_title = trim($_POST['title']);
     $clean_text = trim($_POST['text']);
     if (empty($clean_title) || empty($clean_text)) {
-        echo '<script>window.location.href="' . $location . '"</script>';
+        echo '<script>window.location.href="'.$location.'"</script>';
 
         return;
     }
     $clean_title = Security::remove_XSS($clean_title);
     $clean_title = Database::escape_string($clean_title);
-    $clean_title = str_replace(' ', '_', $clean_title);//compound file names
+    $clean_title = str_replace(' ', '_', $clean_title); //compound file names
 
     $clean_text = Security::remove_XSS($clean_text);
     $clean_lang = Security::remove_XSS($_POST['lang']);
 
     $extension = 'mp3';
-    $audio_filename = $clean_title . '.' . $extension;
+    $audio_filename = $clean_title.'.'.$extension;
     $audio_title = str_replace('_', ' ', $clean_title);
 
     //prevent duplicates
-    if (file_exists($filepath . '/' . $clean_title . '.' . $extension)) {
+    if (file_exists($filepath.'/'.$clean_title.'.'.$extension)) {
         $i = 1;
-        while (file_exists($filepath . '/' . $clean_title . '_' . $i . '.' . $extension)) {
+        while (file_exists($filepath.'/'.$clean_title.'_'.$i.'.'.$extension)) {
             $i++;
         }
-        $audio_filename = $clean_title . '_' . $i . '.' . $extension;
-        $audio_title = $clean_title . '_' . $i . '.' . $extension;
+        $audio_filename = $clean_title.'_'.$i.'.'.$extension;
+        $audio_title = $clean_title.'_'.$i.'.'.$extension;
         $audio_title = str_replace('_', ' ', $audio_title);
     }
 
-    $documentPath = $filepath . '/' . $audio_filename;
+    $documentPath = $filepath.'/'.$audio_filename;
     $clean_text = api_replace_dangerous_char($clean_text);
 
     // adding the file

File diff suppressed because it is too large
+ 168 - 168
main/exercise/exercise.class.php


+ 35 - 35
main/exercise/exercise_submit_modal.php

@@ -117,7 +117,7 @@ if (empty($choice_value)) {
 }
 
 $choice = array();
-$questionid= $questionList[$questionNum];
+$questionid = $questionList[$questionNum];
 // $choice_value => value of the user selection
 $choice[$questionid] = isset($choice_value) ? $choice_value : null;
 
@@ -193,9 +193,9 @@ if (!empty($choice_value)) {
         $numAnswer = $objAnswerTmp->selectAutoId($answerId);
 
         //delineation
-        $delineation_cord  = $objAnswerTmp->selectHotspotCoordinates(1);
+        $delineation_cord = $objAnswerTmp->selectHotspotCoordinates(1);
         $answer_delineation_destination = $objAnswerTmp->selectDestination(1);
-        if ($dbg_local>0) { error_log(__LINE__.' answerId: '.$answerId.'('.$answerType.') - user delineation_cord: '.$delineation_cord.' - $answer_delineation_destination: '.$answer_delineation_destination,0);}
+        if ($dbg_local > 0) { error_log(__LINE__.' answerId: '.$answerId.'('.$answerType.') - user delineation_cord: '.$delineation_cord.' - $answer_delineation_destination: '.$answer_delineation_destination, 0); }
 
         switch ($answerType) {
             // for unique answer
@@ -230,7 +230,7 @@ if (!empty($choice_value)) {
             }
         } elseif ($answerType == HOT_SPOT_DELINEATION) {
             if ($next) {
-                if ($dbg_local>0) { error_log(__LINE__.' - next',0);}
+                if ($dbg_local > 0) { error_log(__LINE__.' - next', 0); }
                 $hot_spot_load = true; //apparently the script is called twice
                 $user_answer = $user_array;
                 $_SESSION['exerciseResultCoordinates'][$questionid] = $user_answer; //needed for exercise_result.php
@@ -265,7 +265,7 @@ if (!empty($choice_value)) {
                 }
 
                 //$overlap = round(polygons_overlap($poly_answer,$poly_user)); //this is an area in pixels
-                if ($dbg_local>0) { error_log(__LINE__.' - Polygons results are '.print_r($poly_results,1),0);}
+                if ($dbg_local > 0) { error_log(__LINE__.' - Polygons results are '.print_r($poly_results, 1), 0); }
                 if ($overlap < 1) {
                     //shortcut to avoid complicated calculations
                     $final_overlap = 0;
@@ -273,14 +273,14 @@ if (!empty($choice_value)) {
                     $final_excess  = 100;
                 } else {
                     // the final overlap is the percentage of the initial polygon that is overlapped by the user's polygon
-                    $final_overlap = round(((float)$overlap / (float)$poly_answer_area)*100);
-                    if ($dbg_local>1) { error_log(__LINE__.' - Final overlap is '.$final_overlap,0);}
+                    $final_overlap = round(((float) $overlap / (float) $poly_answer_area) * 100);
+                    if ($dbg_local > 1) { error_log(__LINE__.' - Final overlap is '.$final_overlap, 0); }
                     // the final missing area is the percentage of the initial polygon that is not overlapped by the user's polygon
                     $final_missing = 100 - $final_overlap;
-                    if ($dbg_local>1) { error_log(__LINE__.' - Final missing is '.$final_missing,0);}
+                    if ($dbg_local > 1) { error_log(__LINE__.' - Final missing is '.$final_missing, 0); }
                     // the final excess area is the percentage of the initial polygon's size that is covered by the user's polygon outside of the initial polygon
-                    $final_excess = round((((float)$poly_user_area-(float)$overlap)/(float)$poly_answer_area)*100);
-                    if ($dbg_local>1) { error_log(__LINE__.' - Final excess is '.$final_excess,0);}
+                    $final_excess = round((((float) $poly_user_area - (float) $overlap) / (float) $poly_answer_area) * 100);
+                    if ($dbg_local > 1) { error_log(__LINE__.' - Final excess is '.$final_excess, 0); }
                 }
 
                 $destination_items = explode('@@', $answerDestination);
@@ -288,10 +288,10 @@ if (!empty($choice_value)) {
                 $threadhold_items = explode(';', $threadhold_total);
                 $threadhold1 = $threadhold_items[0]; // overlap
                 $threadhold2 = $threadhold_items[1]; // excess
-                $threadhold3 = $threadhold_items[2];     //missing
+                $threadhold3 = $threadhold_items[2]; //missing
 
                 // if is delineation
-                if ($answerId===1) {
+                if ($answerId === 1) {
                     //setting colors
                     if ($final_overlap >= $threadhold1) {
                         $overlap_color = true; //echo 'a';
@@ -307,11 +307,11 @@ if (!empty($choice_value)) {
 
                     // if pass
                     //if ($final_overlap>=$threadhold1 && $final_missing<=$threadhold2 && $final_excess<=$threadhold3) {
-                    if ($final_overlap>=$threadhold1 && $final_missing<=$threadhold3 && $final_excess<=$threadhold2) {
-                        $next=1; //go to the oars
-                        $result_comment=get_lang('Acceptable');
+                    if ($final_overlap >= $threadhold1 && $final_missing <= $threadhold3 && $final_excess <= $threadhold2) {
+                        $next = 1; //go to the oars
+                        $result_comment = get_lang('Acceptable');
                     } else {
-                        $next=1; //Go to the oars. If $next =  0 we will show this message: "One (or more) area at risk has been hit" instead of the table resume with the results
+                        $next = 1; //Go to the oars. If $next =  0 we will show this message: "One (or more) area at risk has been hit" instead of the table resume with the results
                         $wrong_results = true;
                         $result_comment = get_lang('Unacceptable');
                         $special_comment = $comment = $answerDestination = $objAnswerTmp->selectComment(1);
@@ -324,12 +324,12 @@ if (!empty($choice_value)) {
                     }
                 } elseif ($answerId > 1) {
                     if ($objAnswerTmp->selectHotspotType($answerId) == 'noerror') {
-                        if ($dbg_local>0) { error_log(__LINE__.' - answerId is of type noerror',0);}
+                        if ($dbg_local > 0) { error_log(__LINE__.' - answerId is of type noerror', 0); }
                         //type no error shouldn't be treated
                         $next = 1;
                         continue;
                     }
-                    if ($dbg_local>0) { error_log(__LINE__.' - answerId is >1 so we\'re probably in OAR',0);}
+                    if ($dbg_local > 0) { error_log(__LINE__.' - answerId is >1 so we\'re probably in OAR', 0); }
                     //check the intersection between the oar and the user
                     //echo 'user';	print_r($x_user_list);		print_r($y_user_list);
                     //echo 'official';print_r($x_list);print_r($y_list);
@@ -353,7 +353,7 @@ if (!empty($choice_value)) {
                             $poly_user,
                             $max_coord,
                             $test
-                        );//$poly_user is already set when answerid = 1
+                        ); //$poly_user is already set when answerid = 1
                         $poly_answer_compiled = poly_compile(
                             $poly_answer,
                             $max_coord,
@@ -395,7 +395,7 @@ if (!empty($choice_value)) {
                 }
             } else {
                 // the first delineation feedback
-                if ($dbg_local>0) { error_log(__LINE__.' first',0);}
+                if ($dbg_local > 0) { error_log(__LINE__.' first', 0); }
             }
         }
     }
@@ -440,18 +440,18 @@ if (!empty($choice_value)) {
 	<tr class="row_even">
 		<td><b>'.get_lang('Overlap').'</b></td>
 		<td>'.get_lang('Min').' '.$threadhold1.'</td>
-		<td><div style="color:'.$overlap_color.'">'.(($final_overlap < 0)?0:intval($final_overlap)).'</div></td>
+		<td><div style="color:'.$overlap_color.'">'.(($final_overlap < 0) ? 0 : intval($final_overlap)).'</div></td>
 	</tr>
 	<tr>
 		<td><b>'.get_lang('Excess').'</b></td>
 		<td>'.get_lang('Max').' '.$threadhold2.'</td>
-		<td><div style="color:'.$excess_color.'">'.(($final_excess < 0)?0:intval($final_excess)).'</div></td>
+		<td><div style="color:'.$excess_color.'">'.(($final_excess < 0) ? 0 : intval($final_excess)).'</div></td>
 	</tr>
 
 	<tr class="row_even">
 		<td><b>'.get_lang('Missing').'</b></td>
 		<td>'.get_lang('Max').' '.$threadhold3.'</td>
-		<td><div style="color:'.$missing_color.'">'.(($final_missing < 0)?0:intval($final_missing)).'</div></td>
+		<td><div style="color:'.$missing_color.'">'.(($final_missing < 0) ? 0 : intval($final_missing)).'</div></td>
 	</tr>
 	</table>';
 }
@@ -499,7 +499,7 @@ if ($answerType != HOT_SPOT_DELINEATION) {
 }
 
 // the link to retry the question
-if (isset($try) && $try==1) {
+if (isset($try) && $try == 1) {
     $num_value_array = array_keys($questionList, $questionid);
     $links .= Display:: return_icon(
         'reload.gif',
@@ -510,7 +510,7 @@ if (isset($try) && $try==1) {
 
 // the link to theory (a learning path)
 if (!empty($lp)) {
-	$lp_url= api_get_path(WEB_CODE_PATH) . 'lp/lp_controller.php?'.api_get_cidreq().'&action=view&lp_id='.$lp;
+	$lp_url = api_get_path(WEB_CODE_PATH).'lp/lp_controller.php?'.api_get_cidreq().'&action=view&lp_id='.$lp;
 	$list = new LearnpathList(api_get_user_id());
 	$flat_list = $list->get_flat_list();
     $links .= Display:: return_icon(
@@ -539,10 +539,10 @@ if ($destinationid == -1) {
         ).'<a onclick="SendEx(-1);" href="#">'.get_lang('EndActivity').'</a><br /><br />';
 } else {
 	// the link to other question
-	if (in_array($destinationid,$questionList)) {
+	if (in_array($destinationid, $questionList)) {
 		$objQuestionTmp = Question :: read($destinationid);
-		$questionName=$objQuestionTmp->selectTitle();
-		$num_value_array= (array_keys($questionList, $destinationid));
+		$questionName = $objQuestionTmp->selectTitle();
+		$num_value_array = (array_keys($questionList, $destinationid));
         $links .= Display:: return_icon(
                 'quiz.png',
                 '',
@@ -570,15 +570,15 @@ if ($links != '') {
 		if ($organs_at_risk_hit > 0) {
 			//$message='<p>'.get_lang('YourDelineation').'</p>';
 			//$message.=$table_resume;
-			$message.='<br />'.get_lang('ResultIs').' <b>'.get_lang('Unacceptable').'</b><br />';
+			$message .= '<br />'.get_lang('ResultIs').' <b>'.get_lang('Unacceptable').'</b><br />';
 			//if ($wrong_results) { }
-			$message.='<p style="color:#DC0A0A;"><b>'.get_lang('OARHit').'</b></p>';
-			$message.='<p>'.$comment.'</p>';
+			$message .= '<p style="color:#DC0A0A;"><b>'.get_lang('OARHit').'</b></p>';
+			$message .= '<p>'.$comment.'</p>';
 		} else {
-			$message='<p>'.get_lang('YourDelineation').'</p>';
-			$message.=$table_resume;
-			$message.='<br />'.get_lang('ResultIs').' <b>'.$result_comment.'</b><br />';
-			$message.='<p>'.$comment.'</p>';
+			$message = '<p>'.get_lang('YourDelineation').'</p>';
+			$message .= $table_resume;
+			$message .= '<br />'.get_lang('ResultIs').' <b>'.$result_comment.'</b><br />';
+			$message .= '<p>'.$comment.'</p>';
 		}
 		echo $message;
 	} else {

+ 2 - 2
main/exercise/export/aiken/aiken_import.inc.php

@@ -16,7 +16,7 @@ function aiken_display_form()
 {
     $name_tools = get_lang('ImportAikenQuiz');
     $form  = '<div class="actions">';
-    $form .= '<a href="exercise.php?show=test&'.api_get_cidreq().'">' .
+    $form .= '<a href="exercise.php?show=test&'.api_get_cidreq().'">'.
         Display::return_icon(
             'back.png',
             get_lang('BackToExercisesList'),
@@ -314,7 +314,7 @@ function aiken_parse_file(&$exercise_info, $exercisePath, $file, $questionFile)
                     $exercise_info['question'][$question_index]['title'] = $info;
                 } else {
                     //Question itself (use a 100-chars long title and a larger description)
-                    $exercise_info['question'][$question_index]['title'] = trim(substr($info, 0, 100)) . '...';
+                    $exercise_info['question'][$question_index]['title'] = trim(substr($info, 0, 100)).'...';
                     $exercise_info['question'][$question_index]['description'] = $info;
                 }
             } else {

+ 60 - 60
main/gradebook/index.php

@@ -11,7 +11,7 @@
 //$cidReset = false;
 $_in_course = true;
 require_once __DIR__.'/../inc/global.inc.php';
-$current_course_tool  = TOOL_GRADEBOOK;
+$current_course_tool = TOOL_GRADEBOOK;
 
 api_protect_course_script(true);
 
@@ -75,9 +75,9 @@ $(document).ready(function() {
 });
 </script>';
 api_block_anonymous_users();
-$htmlHeadXtra[]= '<script type="text/javascript">
+$htmlHeadXtra[] = '<script type="text/javascript">
 function confirmation() {
-	if (confirm("' . get_lang('DeleteAll') . '?")) {
+	if (confirm("' . get_lang('DeleteAll').'?")) {
 		return true;
 	} else {
 		return false;
@@ -133,7 +133,7 @@ if (isset($_GET['isStudentView'])) {
 //this is called when there is no data for the course admin
 if (isset($_GET['createallcategories'])) {
     GradebookUtils::block_students();
-    $coursecat= Category::get_not_created_course_categories($stud_id);
+    $coursecat = Category::get_not_created_course_categories($stud_id);
     if (!count($coursecat) == 0) {
         foreach ($coursecat as $row) {
             $cat = new Category();
@@ -154,26 +154,26 @@ if (isset($_GET['createallcategories'])) {
 
 //show logs evaluations
 if (isset($_GET['visiblelog'])) {
-    header('Location: ' . api_get_self().'/gradebook_showlog_eval.php');
+    header('Location: '.api_get_self().'/gradebook_showlog_eval.php');
     exit;
 }
 
 //move a category
 if (isset($_GET['movecat'])) {
     GradebookUtils::block_students();
-    $cats= Category :: load($_GET['movecat']);
+    $cats = Category :: load($_GET['movecat']);
     if (!isset($_GET['targetcat'])) {
-        $move_form= new CatForm(
+        $move_form = new CatForm(
             CatForm :: TYPE_MOVE,
             $cats[0],
             'move_cat_form',
             null,
-            api_get_self() . '?movecat=' . intval($_GET['movecat']). '&selectcat=' . $selectCat
+            api_get_self().'?movecat='.intval($_GET['movecat']).'&selectcat='.$selectCat
         );
         if ($move_form->validate()) {
-            header('Location: ' . api_get_self() . '?selectcat=' . $selectCat
-                . '&movecat=' . intval($_GET['movecat'])
-                . '&targetcat=' . $move_form->exportValue('move_cat'));
+            header('Location: '.api_get_self().'?selectcat='.$selectCat
+                . '&movecat='.intval($_GET['movecat'])
+                . '&targetcat='.$move_form->exportValue('move_cat'));
             exit;
         }
     } else {
@@ -182,7 +182,7 @@ if (isset($_GET['movecat'])) {
 
         if (!($course_to_crsind && !isset($_GET['confirm']))) {
             $cats[0]->move_to_cat($targetcat[0]);
-            header('Location: ' . api_get_self() . '?categorymoved=&selectcat=' . $selectCat);
+            header('Location: '.api_get_self().'?categorymoved=&selectcat='.$selectCat);
             exit;
         }
         unset($targetcat);
@@ -193,30 +193,30 @@ if (isset($_GET['movecat'])) {
 //move an evaluation
 if (isset($_GET['moveeval'])) {
     GradebookUtils::block_students();
-    $evals= Evaluation :: load($_GET['moveeval']);
+    $evals = Evaluation :: load($_GET['moveeval']);
     if (!isset($_GET['targetcat'])) {
-        $move_form= new EvalForm(
+        $move_form = new EvalForm(
             EvalForm :: TYPE_MOVE,
             $evals[0],
             null,
             'move_eval_form',
             null,
-            api_get_self() . '?moveeval=' . Security::remove_XSS($_GET['moveeval']). '&selectcat=' . $selectCat
+            api_get_self().'?moveeval='.Security::remove_XSS($_GET['moveeval']).'&selectcat='.$selectCat
         );
 
         if ($move_form->validate()) {
-            header('Location: ' .api_get_self() . '?selectcat='.$selectCat
-                . '&moveeval=' . Security::remove_XSS($_GET['moveeval'])
-                . '&targetcat=' . $move_form->exportValue('move_cat'));
+            header('Location: '.api_get_self().'?selectcat='.$selectCat
+                . '&moveeval='.Security::remove_XSS($_GET['moveeval'])
+                . '&targetcat='.$move_form->exportValue('move_cat'));
             exit;
         }
     } else {
-        $targetcat= Category :: load($_GET['targetcat']);
+        $targetcat = Category :: load($_GET['targetcat']);
         $course_to_crsind = ($evals[0]->get_course_code() != null && $targetcat[0]->get_course_code() == null);
 
         if (!($course_to_crsind && !isset($_GET['confirm']))) {
             $evals[0]->move_to_cat($targetcat[0]);
-            header('Location: ' . api_get_self() . '?evaluationmoved=&selectcat=' . $selectCat);
+            header('Location: '.api_get_self().'?evaluationmoved=&selectcat='.$selectCat);
             exit;
         }
         unset($targetcat);
@@ -227,21 +227,21 @@ if (isset($_GET['moveeval'])) {
 //move a link
 if (isset($_GET['movelink'])) {
     GradebookUtils::block_students();
-    $link= LinkFactory :: load($_GET['movelink']);
+    $link = LinkFactory :: load($_GET['movelink']);
     $move_form = new LinkForm(
         LinkForm :: TYPE_MOVE,
         null,
         $link[0],
         'move_link_form',
         null,
-        api_get_self() . '?movelink=' . $_GET['movelink'] . '&selectcat=' . $selectCat
+        api_get_self().'?movelink='.$_GET['movelink'].'&selectcat='.$selectCat
     );
 
     if ($move_form->validate()) {
-        $targetcat= Category :: load($move_form->exportValue('move_cat'));
+        $targetcat = Category :: load($move_form->exportValue('move_cat'));
         $link[0]->move_to_cat($targetcat[0]);
         unset($link);
-        header('Location: ' . api_get_self(). '?linkmoved=&selectcat=' . $selectCat);
+        header('Location: '.api_get_self().'?linkmoved=&selectcat='.$selectCat);
         exit;
     }
 }
@@ -288,11 +288,11 @@ if (isset($_GET['deletecat'])) {
 if (isset($_GET['visibleeval'])) {
     GradebookUtils::block_students();
     if (isset($_GET['set_visible'])) {
-        $visibility_command= 1;
+        $visibility_command = 1;
     } else {
-        $visibility_command= 0;
+        $visibility_command = 0;
     }
-    $eval= Evaluation :: load($_GET['visibleeval']);
+    $eval = Evaluation :: load($_GET['visibleeval']);
     $eval[0]->set_visible($visibility_command);
     $eval[0]->save();
     unset($eval);
@@ -326,7 +326,7 @@ if (isset($_GET['lockedeval'])) {
 
 if (isset($_GET['deleteeval'])) {
     GradebookUtils::block_students();
-    $eval= Evaluation :: load($_GET['deleteeval']);
+    $eval = Evaluation :: load($_GET['deleteeval']);
     if ($eval[0] != null) {
         $eval[0]->delete_with_results();
     }
@@ -398,9 +398,9 @@ if (!empty($course_to_crsind) && !isset($_GET['confirm'])) {
     if (!isset($_GET['movecat']) && !isset($_GET['moveeval'])) {
         die ('Error: movecat or moveeval not defined');
     }
-    $button = '<form name="confirm" method="post" action="'.api_get_self() .'?confirm='
-        .(isset($_GET['movecat']) ? '&movecat=' . intval($_GET['movecat'])
-            : '&moveeval=' . Security::remove_XSS($_GET['moveeval'])).'&selectcat=' . $selectCat.'&targetcat=' . Security::remove_XSS($_GET['targetcat']).'">
+    $button = '<form name="confirm" method="post" action="'.api_get_self().'?confirm='
+        .(isset($_GET['movecat']) ? '&movecat='.intval($_GET['movecat'])
+            : '&moveeval='.Security::remove_XSS($_GET['moveeval'])).'&selectcat='.$selectCat.'&targetcat='.Security::remove_XSS($_GET['targetcat']).'">
 			   <input type="submit" value="'.get_lang('Ok').'">
 			   </form>';
     $warning_message = get_lang('MoveWarning').'<br><br>'.$button;
@@ -431,7 +431,7 @@ switch ($action) {
 //actions on the sortabletable
 if (isset($_POST['action'])) {
     GradebookUtils::block_students();
-    $number_of_selected_items= count($_POST['id']);
+    $number_of_selected_items = count($_POST['id']);
 
     if ($number_of_selected_items == '0') {
         $warning_message = get_lang('NoItemsSelected');
@@ -439,19 +439,19 @@ if (isset($_POST['action'])) {
     } else {
         switch ($_POST['action']) {
             case 'deleted':
-                $number_of_deleted_categories= 0;
-                $number_of_deleted_evaluations= 0;
-                $number_of_deleted_links= 0;
+                $number_of_deleted_categories = 0;
+                $number_of_deleted_evaluations = 0;
+                $number_of_deleted_links = 0;
                 foreach ($_POST['id'] as $indexstr) {
                     if (substr($indexstr, 0, 4) == 'CATE') {
-                        $cats= Category :: load(substr($indexstr, 4));
+                        $cats = Category :: load(substr($indexstr, 4));
                         if ($cats[0] != null) {
                             $cats[0]->delete_all();
                         }
                         $number_of_deleted_categories++;
                     }
                     if (substr($indexstr, 0, 4) == 'EVAL') {
-                        $eval= Evaluation :: load(substr($indexstr, 4));
+                        $eval = Evaluation :: load(substr($indexstr, 4));
                         if ($eval[0] != null) {
                             $eval[0]->delete_with_results();
                         }
@@ -462,7 +462,7 @@ if (isset($_POST['action'])) {
                         //fixing #5229
                         $id = substr($indexstr, 4);
                         if (!empty($id)) {
-                            $link= LinkFactory :: load($id);
+                            $link = LinkFactory :: load($id);
                             if ($link[0] != null) {
                                 $link[0]->delete();
                             }
@@ -470,7 +470,7 @@ if (isset($_POST['action'])) {
                         }
                     }
                 }
-                $confirmation_message = get_lang('DeletedCategories') . ' : <b>' . $number_of_deleted_categories . '</b><br />' . get_lang('DeletedEvaluations') . ' : <b>' . $number_of_deleted_evaluations . '</b><br />' . get_lang('DeletedLinks') . ' : <b>' . $number_of_deleted_links . '</b><br /><br />' . get_lang('TotalItems') . ' : <b>' . $number_of_selected_items . '</b>';
+                $confirmation_message = get_lang('DeletedCategories').' : <b>'.$number_of_deleted_categories.'</b><br />'.get_lang('DeletedEvaluations').' : <b>'.$number_of_deleted_evaluations.'</b><br />'.get_lang('DeletedLinks').' : <b>'.$number_of_deleted_links.'</b><br /><br />'.get_lang('TotalItems').' : <b>'.$number_of_selected_items.'</b>';
                 $filter_confirm_msg = false;
                 break;
             case 'setvisible':
@@ -482,12 +482,12 @@ if (isset($_POST['action'])) {
                         $cats[0]->apply_visibility_to_children();
                     }
                     if (substr($indexstr, 0, 4) == 'EVAL') {
-                        $eval= Evaluation :: load(substr($indexstr, 4));
+                        $eval = Evaluation :: load(substr($indexstr, 4));
                         $eval[0]->set_visible(1);
                         $eval[0]->save();
                     }
                     if (substr($indexstr, 0, 4) == 'LINK') {
-                        $link= LinkFactory :: load(substr($indexstr, 4));
+                        $link = LinkFactory :: load(substr($indexstr, 4));
                         $link[0]->set_visible(1);
                         $link[0]->save();
                     }
@@ -504,12 +504,12 @@ if (isset($_POST['action'])) {
                         $cats[0]->apply_visibility_to_children();
                     }
                     if (substr($indexstr, 0, 4) == 'EVAL') {
-                        $eval= Evaluation :: load(substr($indexstr, 4));
+                        $eval = Evaluation :: load(substr($indexstr, 4));
                         $eval[0]->set_visible(0);
                         $eval[0]->save();
                     }
                     if (substr($indexstr, 0, 4) == 'LINK') {
-                        $link= LinkFactory :: load(substr($indexstr, 4));
+                        $link = LinkFactory :: load(substr($indexstr, 4));
                         $link[0]->set_visible(0);
                         $link[0]->save();
                     }
@@ -522,7 +522,7 @@ if (isset($_POST['action'])) {
 }
 
 if (isset ($_POST['submit']) && isset ($_POST['keyword'])) {
-    header('Location: ' . api_get_self() . '?selectcat=' . $selectCat. '&search='.Security::remove_XSS($_POST['keyword']));
+    header('Location: '.api_get_self().'?selectcat='.$selectCat.'&search='.Security::remove_XSS($_POST['keyword']));
     exit;
 }
 
@@ -553,19 +553,19 @@ if (isset ($_GET['editeval'])) {
 if (isset ($_GET['linkedited'])) {
     Display::addFlash(Display::return_message(get_lang('LinkEdited'), 'confirmation', false));
 }
-if (isset ($_GET['nolinkitems'])){
+if (isset ($_GET['nolinkitems'])) {
     Display::addFlash(Display::return_message(get_lang('NoLinkItems'), 'warning', false));
 }
-if (isset ($_GET['addallcat'])){
+if (isset ($_GET['addallcat'])) {
     Display::addFlash(Display::return_message(get_lang('AddAllCat'), 'normal', false));
 }
-if (isset ($confirmation_message)){
+if (isset ($confirmation_message)) {
     Display::addFlash(Display::return_message($confirmation_message, 'confirmation', $filter_confirm_msg));
 }
-if (isset ($warning_message)){
+if (isset ($warning_message)) {
     Display::addFlash(Display::return_message($warning_message, 'warning', $filter_warning_msg));
 }
-if (isset ($move_form)){
+if (isset ($move_form)) {
     Display::addFlash(Display::return_message($move_form->toHtml(), 'normal', false));
 }
 
@@ -583,7 +583,7 @@ if (!isset($_GET['exportpdf'])) {
             'name' => get_lang('ToolGradebook')
         );
         Display :: display_header(get_lang('SearchResults'));
-    } elseif(!empty($selectCat)) {
+    } elseif (!empty($selectCat)) {
         $interbreadcrumb[] = array(
             'url' => '#',
             'name' => get_lang('ToolGradebook')
@@ -609,7 +609,7 @@ if (isset($_GET['studentoverview'])) {
     $alleval = $cats[0]->get_evaluations($stud_id, true);
     $alllink = $cats[0]->get_links($stud_id, true);
     if (isset ($_GET['exportpdf'])) {
-        $datagen = new GradebookDataGenerator($allcat,$alleval, $alllink);
+        $datagen = new GradebookDataGenerator($allcat, $alleval, $alllink);
         $header_names = array(
             get_lang('Name'),
             get_lang('Description'),
@@ -627,13 +627,13 @@ if (isset($_GET['studentoverview'])) {
         foreach ($data_array as $data) {
             $newarray[] = array_slice($data, 1);
         }
-        $pdf= new Cezpdf();
+        $pdf = new Cezpdf();
         $pdf->selectFont(api_get_path(LIBRARY_PATH).'ezpdf/fonts/Courier.afm');
         $pdf->ezSetMargins(30, 30, 50, 30);
         $pdf->ezSetY(810);
-        $pdf->ezText(get_lang('FlatView').' ('. api_convert_and_format_date(null, DATE_FORMAT_SHORT). ' ' . api_convert_and_format_date(null, TIME_NO_SEC_FORMAT) .')',12,array('justification'=>'center'));
-        $pdf->line(50,790,550,790);
-        $pdf->line(50,40,550,40);
+        $pdf->ezText(get_lang('FlatView').' ('.api_convert_and_format_date(null, DATE_FORMAT_SHORT).' '.api_convert_and_format_date(null, TIME_NO_SEC_FORMAT).')', 12, array('justification'=>'center'));
+        $pdf->line(50, 790, 550, 790);
+        $pdf->line(50, 40, 550, 40);
         $pdf->ezSetY(750);
         $pdf->ezTable(
             $newarray,
@@ -732,10 +732,10 @@ if (isset($_GET['studentoverview'])) {
     $addparams['studentoverview'] = '';
 }
 //$addparams['cidReq']='';
-if (isset($_GET['cidReq']) && $_GET['cidReq']!='') {
+if (isset($_GET['cidReq']) && $_GET['cidReq'] != '') {
     $addparams['cidReq'] = Security::remove_XSS($_GET['cidReq']);
 } else {
-    $addparams['cidReq']='';
+    $addparams['cidReq'] = '';
 }
 
 $no_qualification = false;
@@ -817,7 +817,7 @@ if (api_is_allowed_to_edit(null, true)) {
     }
 }
 
-if (isset($first_time) && $first_time == 1 && api_is_allowed_to_edit(null,true)) {
+if (isset($first_time) && $first_time == 1 && api_is_allowed_to_edit(null, true)) {
     echo '<meta http-equiv="refresh" content="0;url='.api_get_self().'?'.api_get_cidreq().'" />';
 } else {
     $cats = Category::load(
@@ -862,7 +862,7 @@ if (isset($first_time) && $first_time == 1 && api_is_allowed_to_edit(null,true))
                         $components = $obj->get_components($value);
 
                         foreach ($components as $component) {
-                            $gradebook =  new Gradebook();
+                            $gradebook = new Gradebook();
                             $params = array();
 
                             $params['name'] = $component['acronym'];
@@ -918,7 +918,7 @@ if (isset($first_time) && $first_time == 1 && api_is_allowed_to_edit(null,true))
                     $certificate
                 );
 
-                if (api_is_allowed_to_edit(null,true) &&
+                if (api_is_allowed_to_edit(null, true) &&
                     api_get_setting('gradebook_enable_grade_model') === 'true'
                 ) {
                     //Showing the grading system

+ 48 - 48
main/gradebook/lib/be/category.class.php

@@ -205,7 +205,7 @@ class Category implements GradebookItem
      */
     public function set_session_id($session_id = 0)
     {
-        $this->session_id = (int)$session_id;
+        $this->session_id = (int) $session_id;
     }
 
     /**
@@ -294,7 +294,7 @@ class Category implements GradebookItem
         $skills = $this->get_skills();
         $skill_select = array();
         if (!empty($skills)) {
-            foreach($skills as $skill) {
+            foreach ($skills as $skill) {
                 $skill_select[$skill['id']] = $skill['name'];
             }
         }
@@ -328,7 +328,7 @@ class Category implements GradebookItem
      */
     public static function load_session_categories($id = null, $session_id = null)
     {
-        if (isset($id) && (int)$id === 0) {
+        if (isset($id) && (int) $id === 0) {
             $cats = array();
             $cats[] = self::create_root_category();
             return $cats;
@@ -341,7 +341,7 @@ class Category implements GradebookItem
         if (!empty($session_id)) {
             $tbl_grade_categories = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY);
             $sql = 'SELECT id, course_code
-                    FROM '.$tbl_grade_categories. '
+                    FROM '.$tbl_grade_categories.'
                     WHERE session_id = '.$session_id;
             $result_session = Database::query($sql);
             if (Database::num_rows($result_session) > 0) {
@@ -383,7 +383,7 @@ class Category implements GradebookItem
     ) {
         //if the category given is explicitly 0 (not null), then create
         // a root category object (in memory)
-        if (isset($id) && (int)$id === 0) {
+        if (isset($id) && (int) $id === 0) {
             $cats = array();
             $cats[] = self::create_root_category();
 
@@ -394,8 +394,8 @@ class Category implements GradebookItem
         $sql = 'SELECT * FROM '.$tbl_grade_categories;
         $paramcount = 0;
         if (isset($id)) {
-            $sql.= ' WHERE id = '.intval($id);
-            $paramcount ++;
+            $sql .= ' WHERE id = '.intval($id);
+            $paramcount++;
         }
 
         if (isset($user_id)) {
@@ -431,10 +431,10 @@ class Category implements GradebookItem
             if (empty($session_id)) {
                 $sql .= ' AND (session_id IS NULL OR session_id = 0) ';
             } else {
-                $sql .= ' AND session_id = '.(int)$session_id.' ';
+                $sql .= ' AND session_id = '.(int) $session_id.' ';
             }
             //}
-            $paramcount ++;
+            $paramcount++;
         }
 
         if (isset($parent_id)) {
@@ -601,7 +601,7 @@ class Category implements GradebookItem
                             $default_weight = $default_weight_setting;
                         }
                         foreach ($components as $component) {
-                            $gradebook =  new Gradebook();
+                            $gradebook = new Gradebook();
                             $params = array();
 
                             $params['name'] = $component['acronym'];
@@ -618,7 +618,7 @@ class Category implements GradebookItem
                 }
             }
 
-            $gradebook= new Gradebook();
+            $gradebook = new Gradebook();
             $gradebook->update_skills_to_gradebook(
                 $this->id,
                 $this->get_skills(false)
@@ -693,7 +693,7 @@ class Category implements GradebookItem
             }
         }
 
-        $gradebook= new Gradebook();
+        $gradebook = new Gradebook();
         $gradebook->update_skills_to_gradebook(
             $this->id,
             $this->get_skills(false),
@@ -819,9 +819,9 @@ class Category implements GradebookItem
         }
 
         if (!isset($parent)) {
-            $sql.= ' AND parent_id is null';
+            $sql .= ' AND parent_id is null';
         } else {
-            $sql.= ' AND parent_id = '.intval($parent);
+            $sql .= ' AND parent_id = '.intval($parent);
         }
 
         $result = Database::query($sql);
@@ -923,7 +923,7 @@ class Category implements GradebookItem
                     }
 
                     if (isset($score) && !empty($score[1]) && !empty($catweight)) {
-                        $ressum += $score[0]/$score[1] * $catweight;
+                        $ressum += $score[0] / $score[1] * $catweight;
                     }
                 }
             }
@@ -1017,7 +1017,7 @@ class Category implements GradebookItem
                     }
 
                     if (isset($score) && !empty($score[1]) && !empty($catweight)) {
-                        $ressum += $score[0]/$score[1] * $catweight;
+                        $ressum += $score[0] / $score[1] * $catweight;
 
                         if ($ressum > $bestResult) {
                             $bestResult = $ressum;
@@ -1185,7 +1185,7 @@ class Category implements GradebookItem
                 // session, we don't check his registration to these, but this
                 // could be an improvement
                 if (!empty($session_id)) {
-                    $sql .= " AND course_code = '".Database::escape_string($course_code)."' AND session_id = ".(int)$session_id;
+                    $sql .= " AND course_code = '".Database::escape_string($course_code)."' AND session_id = ".(int) $session_id;
                 } else {
                     $sql .= " AND course_code = '".Database::escape_string($course_code)."' AND session_id is null OR session_id=0";
                 }
@@ -1209,9 +1209,9 @@ class Category implements GradebookItem
                 // could be an improvement
                 $sql .= " AND course_code  = '".Database::escape_string($course_code)."'";
                 if (!empty($session_id)) {
-                    $sql .= " AND session_id = ".(int)$session_id;
+                    $sql .= " AND session_id = ".(int) $session_id;
                 } else {
-                    $sql .="AND session_id IS NULL OR session_id=0";
+                    $sql .= "AND session_id IS NULL OR session_id=0";
                 }
             } else {
                 $sql .= ' AND course_code IN
@@ -1225,10 +1225,10 @@ class Category implements GradebookItem
                     )';
             }
         } elseif (api_is_platform_admin()) {
-            if (isset($session_id) && $session_id!=0) {
-                $sql.=' AND session_id='.intval($session_id);
+            if (isset($session_id) && $session_id != 0) {
+                $sql .= ' AND session_id='.intval($session_id);
             } else {
-                $sql.=' AND coalesce(session_id,0)=0';
+                $sql .= ' AND coalesce(session_id,0)=0';
             }
         }
         $result = Database::query($sql);
@@ -1269,7 +1269,7 @@ class Category implements GradebookItem
         if (!empty($course_code)) {
             $sql .= " AND course_code = '".Database::escape_string($course_code)."' ";
             if (!empty($session_id)) {
-                $sql .= " AND session_id = ".(int)$session_id;
+                $sql .= " AND session_id = ".(int) $session_id;
             }
         } else {
             $sql .= ' AND course_code in
@@ -1338,8 +1338,8 @@ class Category implements GradebookItem
                 $crscats = self::load(null, null, $this->course_code, 0);
                 foreach ($crscats as $cat) {
                     if ($this->can_be_moved_to_cat($cat)) {
-                        $targets[] = array ($cat->get_id(), $cat->get_name(), $level+1);
-                        $targets = $this->add_target_subcategories($targets, $level+1, $cat->get_id());
+                        $targets[] = array($cat->get_id(), $cat->get_name(), $level + 1);
+                        $targets = $this->add_target_subcategories($targets, $level + 1, $cat->get_id());
                     }
                 }
             }
@@ -1347,8 +1347,8 @@ class Category implements GradebookItem
             $indcats = self::load(null, $user, 0, 0);
             foreach ($indcats as $cat) {
                 if ($this->can_be_moved_to_cat($cat)) {
-                    $targets[] = array ($cat->get_id(), $cat->get_name(), $level+1);
-                    $targets = $this->add_target_subcategories($targets, $level+1, $cat->get_id());
+                    $targets[] = array($cat->get_id(), $cat->get_name(), $level + 1);
+                    $targets = $this->add_target_subcategories($targets, $level + 1, $cat->get_id());
                 }
             }
 
@@ -1369,8 +1369,8 @@ class Category implements GradebookItem
         $subcats = self::load(null, null, null, $catid);
         foreach ($subcats as $cat) {
             if ($this->can_be_moved_to_cat($cat)) {
-                $targets[] = array ($cat->get_id(), $cat->get_name(), $level+1);
-                $targets = $this->add_target_subcategories($targets, $level+1, $cat->get_id());
+                $targets[] = array($cat->get_id(), $cat->get_name(), $level + 1);
+                $targets = $this->add_target_subcategories($targets, $level + 1, $cat->get_id());
             }
         }
 
@@ -1412,7 +1412,7 @@ class Category implements GradebookItem
     {
         $cats = self::load(null, null, null, $this->id, null);
         $evals = Evaluation::load(null, null, null, $this->id, null);
-        $links = LinkFactory::load(null,null,null,null,null,$this->id,null);
+        $links = LinkFactory::load(null, null, null, null, null, $this->id, null);
 
         foreach ($cats as $cat) {
             $cat->set_course_code($this->get_course_code());
@@ -1445,15 +1445,15 @@ class Category implements GradebookItem
             $user = (api_is_platform_admin() ? null : api_get_user_id());
             $cats = self::get_root_categories_for_teacher($user);
             foreach ($cats as $cat) {
-                $targets[] = array ($cat->get_id(), $cat->get_name(), $level+1);
-                $targets = self::add_subtree($targets, $level+1, $cat->get_id(),null);
+                $targets[] = array($cat->get_id(), $cat->get_name(), $level + 1);
+                $targets = self::add_subtree($targets, $level + 1, $cat->get_id(), null);
             }
         } else {
             // student
             $cats = self::get_root_categories_for_student(api_get_user_id());
             foreach ($cats as $cat) {
-                $targets[] = array ($cat->get_id(), $cat->get_name(), $level+1);
-                $targets = self::add_subtree($targets, $level+1, $cat->get_id(), 1);
+                $targets[] = array($cat->get_id(), $cat->get_name(), $level + 1);
+                $targets = self::add_subtree($targets, $level + 1, $cat->get_id(), 1);
             }
         }
 
@@ -1467,12 +1467,12 @@ class Category implements GradebookItem
      */
     private function add_subtree($targets, $level, $catid, $visible)
     {
-        $subcats = self::load(null,null,null,$catid,$visible);
+        $subcats = self::load(null, null, null, $catid, $visible);
 
         if (!empty($subcats)) {
             foreach ($subcats as $cat) {
-                $targets[] = array ($cat->get_id(), $cat->get_name(), $level+1);
-                $targets = self::add_subtree($targets, $level+1, $cat->get_id(),$visible);
+                $targets[] = array($cat->get_id(), $cat->get_name(), $level + 1);
+                $targets = self::add_subtree($targets, $level + 1, $cat->get_id(), $visible);
             }
         }
 
@@ -1484,7 +1484,7 @@ class Category implements GradebookItem
      * @param integer $user_id
      * @return array 2-dimensional array - every element contains 2 subelements (code, title)
      */
-    public function get_not_created_course_categories ($user_id)
+    public function get_not_created_course_categories($user_id)
     {
         $tbl_main_courses = Database::get_main_table(TABLE_MAIN_COURSE);
         $tbl_main_course_user = Database::get_main_table(TABLE_MAIN_COURSE_USER);
@@ -1520,7 +1520,7 @@ class Category implements GradebookItem
      * @param integer $user_id
      * @return array 2-dimensional array - every element contains 2 subelements (code, title)
      */
-    public function get_all_courses ($user_id)
+    public function get_all_courses($user_id)
     {
         $tbl_main_courses = Database::get_main_table(TABLE_MAIN_COURSE);
         $tbl_main_course_user = Database::get_main_table(TABLE_MAIN_COURSE_USER);
@@ -1534,7 +1534,7 @@ class Category implements GradebookItem
         $result = Database::query($sql);
         $cats = array();
         while ($data = Database::fetch_array($result)) {
-            $cats[] = array ($data['code'], $data['title']);
+            $cats[] = array($data['code'], $data['title']);
         }
 
         return $cats;
@@ -1547,7 +1547,7 @@ class Category implements GradebookItem
     {
         $cats = self::load(null, null, null, $this->id, null);
         $evals = Evaluation::load(null, null, null, $this->id, null);
-        $links = LinkFactory::load(null,null,null,null,null,$this->id,null);
+        $links = LinkFactory::load(null, null, null, null, null, $this->id, null);
         if (!empty($cats)) {
             foreach ($cats as $cat) {
                 $cat->set_visible($this->is_visible());
@@ -1945,9 +1945,9 @@ class Category implements GradebookItem
                 }
             }
 
-            $link_to_lock= $this->get_links();
+            $link_to_lock = $this->get_links();
             if (!empty($link_to_lock)) {
-                foreach ($link_to_lock as $item ) {
+                foreach ($link_to_lock as $item) {
                     $item->lock($locked);
                 }
             }
@@ -2044,7 +2044,7 @@ class Category implements GradebookItem
                 return [
                     'badge_link' => Display::toolbarButton(
                         get_lang('ExportBadges'),
-                        api_get_path(WEB_CODE_PATH) . "gradebook/get_badges.php?user=$user_id",
+                        api_get_path(WEB_CODE_PATH)."gradebook/get_badges.php?user=$user_id",
                         'external-link'
                     ),
                 ];
@@ -2075,7 +2075,7 @@ class Category implements GradebookItem
             $fileWasGenerated = $certificate_obj->html_file_is_generated();
 
             if (!empty($fileWasGenerated)) {
-                $url = api_get_path(WEB_PATH) . 'certificates/index.php?id=' . $my_certificate['id'];
+                $url = api_get_path(WEB_PATH).'certificates/index.php?id='.$my_certificate['id'];
                 $certificates = Display::toolbarButton(
                     get_lang('DisplayCertificate'),
                     $url,
@@ -2095,7 +2095,7 @@ class Category implements GradebookItem
 
                 $hideExportLink = api_get_setting('hide_certificate_export_link');
                 $hideExportLinkStudent = api_get_setting('hide_certificate_export_link_students');
-                if ($hideExportLink === 'true' || (api_is_student() && $hideExportLinkStudent === 'true') ) {
+                if ($hideExportLink === 'true' || (api_is_student() && $hideExportLinkStudent === 'true')) {
                     $exportToPDF = null;
                 }
 
@@ -2108,7 +2108,7 @@ class Category implements GradebookItem
                 if ($skillToolEnabled && $userHasSkills) {
                     $html['badge_link'] = Display::toolbarButton(
                         get_lang('ExportBadges'),
-                        api_get_path(WEB_CODE_PATH) . "gradebook/get_badges.php?user=$user_id",
+                        api_get_path(WEB_CODE_PATH)."gradebook/get_badges.php?user=$user_id",
                         'external-link'
                     );
                 }
@@ -2166,7 +2166,7 @@ class Category implements GradebookItem
                     $certificate_obj = new Certificate($value_certificate['id']);
                     $certificate_obj->generate(array('hide_print_button' => true));
                     if ($certificate_obj->html_file_is_generated()) {
-                        $certificate_path_list[]= $certificate_obj->html_file;
+                        $certificate_path_list[] = $certificate_obj->html_file;
                     }
                 }
             }

+ 50 - 50
main/inc/lib/AnnouncementManager.php

@@ -271,7 +271,7 @@ class AnnouncementManager
                             ip.tool='announcement' AND
                             (
                                 ip.toUser = $userId OR
-                                ip.group IN ('0', '" . implode("', '", $group_list) . "') OR
+                                ip.group IN ('0', '".implode("', '", $group_list)."') OR
                                 ip.group IS NULL
                             ) AND
                             ip.visibility = '1' AND                       
@@ -338,13 +338,13 @@ class AnnouncementManager
         $content = $announcement->getContent();
 
         $html .= "<table height=\"100\" width=\"100%\" cellpadding=\"5\" cellspacing=\"0\" class=\"data_table\">";
-        $html .= "<tr><td><h2>" . $title . "</h2></td></tr>";
+        $html .= "<tr><td><h2>".$title."</h2></td></tr>";
 
         if (api_is_allowed_to_edit(false, true) ||
             (api_get_course_setting('allow_user_edit_announcement') && !api_is_anonymous())
         ) {
-            $modify_icons = "<a href=\"" . api_get_self() . "?" . api_get_cidreq() . "&action=modify&id=" . $id . "\">" .
-                Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_SMALL) . "</a>";
+            $modify_icons = "<a href=\"".api_get_self()."?".api_get_cidreq()."&action=modify&id=".$id."\">".
+                Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_SMALL)."</a>";
 
             if ($itemProperty->getVisibility() === 1) {
                 $image_visibility = 'visible';
@@ -355,12 +355,12 @@ class AnnouncementManager
             }
             global $stok;
 
-            $modify_icons .= "<a href=\"" . api_get_self() . "?" . api_get_cidreq() . "&action=showhide&id=" . $id . "&sec_token=" . $stok . "\">" .
-                Display::return_icon($image_visibility . '.png', $alt_visibility, '', ICON_SIZE_SMALL) . "</a>";
+            $modify_icons .= "<a href=\"".api_get_self()."?".api_get_cidreq()."&action=showhide&id=".$id."&sec_token=".$stok."\">".
+                Display::return_icon($image_visibility.'.png', $alt_visibility, '', ICON_SIZE_SMALL)."</a>";
 
             if (api_is_allowed_to_edit(false, true)) {
-                $modify_icons .= "<a href=\"" . api_get_self() . "?" . api_get_cidreq() . "&action=delete&id=" . $id . "&sec_token=" . $stok . "\" onclick=\"javascript:if(!confirm('" . addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES, $charset)) . "')) return false;\">" .
-                    Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL) .
+                $modify_icons .= "<a href=\"".api_get_self()."?".api_get_cidreq()."&action=delete&id=".$id."&sec_token=".$stok."\" onclick=\"javascript:if(!confirm('".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES, $charset))."')) return false;\">".
+                    Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL).
                     "</a>";
             }
             $html .= "<tr><th style='text-align:right'>$modify_icons</th></tr>";
@@ -379,10 +379,10 @@ class AnnouncementManager
         $lastEdit = $itemProperty->getLasteditDate();
 
         $html .= "<tr><td>$content</td></tr>";
-        $html .= "<tr><td class=\"announcements_datum\">" . get_lang('LastUpdateDate') . " : " .
+        $html .= "<tr><td class=\"announcements_datum\">".get_lang('LastUpdateDate')." : ".
             Display::dateToStringAgoAndLongDate(
                 !empty($lastEdit) ? $lastEdit->format('Y-m-d h:i:s') : ''
-            ) . "</td></tr>";
+            )."</td></tr>";
 
         if ($itemProperty->getGroup() !== null) {
             $sent_to_icon = Display::return_icon('group.gif', get_lang('AnnounceSentToUserSelection'));
@@ -393,7 +393,7 @@ class AnnouncementManager
             $sent_to_form = self::sent_to_form($sent_to);
             $html .= Display::tag(
                 'td',
-                get_lang('SentTo').': ' . $sent_to_form,
+                get_lang('SentTo').': '.$sent_to_form,
                 array('class' => 'announcements_datum')
             );
         }
@@ -403,15 +403,15 @@ class AnnouncementManager
             $html .= "<tr><td>";
             $realname = $attachment_list['path'];
             $user_filename = $attachment_list['filename'];
-            $full_file_name = 'download.php?'.api_get_cidreq().'&file=' . $realname;
+            $full_file_name = 'download.php?'.api_get_cidreq().'&file='.$realname;
             $html .= '<br/>';
             $html .= Display::return_icon('attachment.gif', get_lang('Attachment'));
-            $html .= '<a href="' . $full_file_name . ' "> ' . $user_filename . ' </a>';
-            $html .= ' - <span class="forum_attach_comment" >' . $attachment_list['comment'] . '</span>';
+            $html .= '<a href="'.$full_file_name.' "> '.$user_filename.' </a>';
+            $html .= ' - <span class="forum_attach_comment" >'.$attachment_list['comment'].'</span>';
             if (api_is_allowed_to_edit(false, true)) {
                 $html .= Display::url(
                     Display::return_icon('delete.png', get_lang('Delete'), '', 16),
-                    api_get_self() . "?" . api_get_cidreq() . "&action=delete_attachment&id_attach=" . $attachment_list['id'] . "&sec_token=" . $stok
+                    api_get_self()."?".api_get_cidreq()."&action=delete_attachment&id_attach=".$attachment_list['id']."&sec_token=".$stok
                 );
             }
             $html .= '</td></tr>';
@@ -442,7 +442,7 @@ class AnnouncementManager
         $order = 0;
         if (Database::num_rows($res_max)) {
             $row_max = Database::fetch_array($res_max);
-            $order = intval($row_max[0])+1;
+            $order = intval($row_max[0]) + 1;
         }
 
         return $order;
@@ -914,8 +914,8 @@ class AnnouncementManager
             $result = array();
             if ($num_rows > 0) {
                 while ($myrow = Database::fetch_array($rs)) {
-                    $content.= '<strong>' . $myrow['title'] . '</strong><br /><br />';
-                    $content.= $myrow['content'];
+                    $content .= '<strong>'.$myrow['title'].'</strong><br /><br />';
+                    $content .= $myrow['content'];
                     $i++;
                 }
                 $result['content'] = $content;
@@ -1012,14 +1012,14 @@ class AnnouncementManager
             switch ($to_group) {
                 // it was send to one specific user
                 case null:
-                    $to[] = "USER:" . $row['to_user_id'];
+                    $to[] = "USER:".$row['to_user_id'];
                     break;
                 // it was sent to everyone
                 case 0:
                     return "everyone";
                     break;
                 default:
-                    $to[] = "GROUP:" . $row['to_group_id'];
+                    $to[] = "GROUP:".$row['to_group_id'];
             }
         }
 
@@ -1083,10 +1083,10 @@ class AnnouncementManager
                 $sent_to_array['groups'][0] !== 0
             ) {
                 $group_id = $sent_to_array['groups'][0];
-                $output[] = "&nbsp;" . $group_names[$group_id]['name'];
+                $output[] = "&nbsp;".$group_names[$group_id]['name'];
             }
             if (empty($sent_to_array['groups']) and empty($sent_to_array['users'])) {
-                $output[] = "&nbsp;" . get_lang('Everybody');
+                $output[] = "&nbsp;".get_lang('Everybody');
             }
         }
 
@@ -1119,7 +1119,7 @@ class AnnouncementManager
 
         $sql = "SELECT to_group_id, to_user_id
                 FROM $tbl_item_property
-                WHERE c_id = $course_id AND tool = '$tool' AND ref=" . $id;
+                WHERE c_id = $course_id AND tool = '$tool' AND ref=".$id;
         $result = Database::query($sql);
 
         while ($row = Database::fetch_array($result)) {
@@ -1161,8 +1161,8 @@ class AnnouncementManager
         $course_id = api_get_course_int_id();
         $row = array();
         $sql = 'SELECT id, path, filename, comment 
-                FROM ' . $tbl_announcement_attachment . '
-				WHERE c_id = ' . $course_id . ' AND announcement_id = ' . $announcementId;
+                FROM ' . $tbl_announcement_attachment.'
+				WHERE c_id = ' . $course_id.' AND announcement_id = '.$announcementId;
         $result = Database::query($sql);
         if (Database::num_rows($result) != 0) {
             $row = Database::fetch_array($result, 'ASSOC');
@@ -1187,9 +1187,9 @@ class AnnouncementManager
 
         if (is_array($file) && $file['error'] == 0) {
             // TODO: This path is obsolete. The new document repository scheme should be kept in mind here.
-            $courseDir = $_course['path'] . '/upload/announcements';
+            $courseDir = $_course['path'].'/upload/announcements';
             $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(stripslashes($file['name']), $file['type']);
@@ -1201,7 +1201,7 @@ class AnnouncementManager
                 Display::display_error_message(get_lang('UplUnableToSaveFileFilteredExtension'));
             } else {
                 $new_file_name = uniqid('');
-                $new_path = $updir . '/' . $new_file_name;
+                $new_path = $updir.'/'.$new_file_name;
 
                 // This file is copy here but its cleaned in api_mail_html in api.lib.php
                 copy($file['tmp_name'], $new_path);
@@ -1244,9 +1244,9 @@ class AnnouncementManager
 
         if (is_array($file) && $file['error'] == 0) {
             // TODO: This path is obsolete. The new document repository scheme should be kept in mind here.
-            $courseDir = $_course['path'] . '/upload/announcements';
+            $courseDir = $_course['path'].'/upload/announcements';
             $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(stripslashes($file['name']), $file['type']);
@@ -1258,7 +1258,7 @@ class AnnouncementManager
                 Display::display_error_message(get_lang('UplUnableToSaveFileFilteredExtension'));
             } else {
                 $new_file_name = uniqid('');
-                $new_path = $updir . '/' . $new_file_name;
+                $new_path = $updir.'/'.$new_file_name;
                 copy($file['tmp_name'], $new_path);
                 $safe_file_comment = Database::escape_string($file_comment);
                 $safe_file_name = Database::escape_string($file_name);
@@ -1268,7 +1268,7 @@ class AnnouncementManager
                             filename = '$safe_file_name', 
                             comment = '$safe_file_comment', 
                             path = '$safe_new_file_name', 
-                            size ='" . intval($file['size']) . "'
+                            size ='".intval($file['size'])."'
 					 	WHERE c_id = $course_id AND id = '$id_attach'";
                 $result = Database::query($sql);
                 if ($result === false) {
@@ -1595,8 +1595,8 @@ class AnnouncementManager
                 if ($myrow['email_sent'] == '1') {
                     $sent_to_icon = ' '.Display::return_icon('email.gif', get_lang('AnnounceSentByEmail'));
                 }
-                $groupReference = ($myrow['to_group_id'] > 0) ? ' <span class="label label-info">' . get_lang('Group') . '</span> ' : '' ;
-                $title = $myrow['title'] . $groupReference . $sent_to_icon;
+                $groupReference = ($myrow['to_group_id'] > 0) ? ' <span class="label label-info">'.get_lang('Group').'</span> ' : '';
+                $title = $myrow['title'].$groupReference.$sent_to_icon;
                 $item_visibility = api_get_item_visibility($_course, TOOL_ANNOUNCEMENT, $myrow['id'], $session_id);
                 $myrow['visibility'] = $item_visibility;
 
@@ -1604,8 +1604,8 @@ class AnnouncementManager
                 $attachment_list = self::get_attachment($myrow['id']);
 
                 $attachment_icon = '';
-                if (count($attachment_list)>0) {
-                    $attachment_icon = ' '.Display::return_icon('attachment.gif',get_lang('Attachment'));
+                if (count($attachment_list) > 0) {
+                    $attachment_icon = ' '.Display::return_icon('attachment.gif', get_lang('Attachment'));
                 }
 
                 /* TITLE */
@@ -1624,16 +1624,16 @@ class AnnouncementManager
                     || (api_get_course_setting('allow_user_edit_announcement') && !api_is_anonymous())
                 ) {
                     $modify_icons = "<a href=\"".$actionUrl."&action=modify&id=".$myrow['id']."\">".
-                        Display::return_icon('edit.png', get_lang('Edit'),'',ICON_SIZE_SMALL)."</a>";
-                    if ($myrow['visibility']==1) {
-                        $image_visibility="visible";
-                        $alt_visibility=get_lang('Hide');
+                        Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_SMALL)."</a>";
+                    if ($myrow['visibility'] == 1) {
+                        $image_visibility = "visible";
+                        $alt_visibility = get_lang('Hide');
                     } else {
-                        $image_visibility="invisible";
-                        $alt_visibility=get_lang('Visible');
+                        $image_visibility = "invisible";
+                        $alt_visibility = get_lang('Visible');
                     }
-                    $modify_icons .=  "<a href=\"".$actionUrl."&action=showhide&id=".$myrow['id']."&sec_token=".$stok."\">".
-                        Display::return_icon($image_visibility.'.png', $alt_visibility,'',ICON_SIZE_SMALL)."</a>";
+                    $modify_icons .= "<a href=\"".$actionUrl."&action=showhide&id=".$myrow['id']."&sec_token=".$stok."\">".
+                        Display::return_icon($image_visibility.'.png', $alt_visibility, '', ICON_SIZE_SMALL)."</a>";
 
                     // DISPLAY MOVE UP COMMAND only if it is not the top announcement
                     if ($iterator != 1) {
@@ -1648,12 +1648,12 @@ class AnnouncementManager
                     } else {
                         $modify_icons .= Display::return_icon('down_na.gif', get_lang('Down'));
                     }
-                    if (api_is_allowed_to_edit(false,true)) {
-                        $modify_icons .= "<a href=\"".$actionUrl."&action=delete&id=".$myrow['id']."&sec_token=".$stok."\" onclick=\"javascript:if(!confirm('".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'),ENT_QUOTES,api_get_system_encoding()))."')) return false;\">".
-                            Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_SMALL).
+                    if (api_is_allowed_to_edit(false, true)) {
+                        $modify_icons .= "<a href=\"".$actionUrl."&action=delete&id=".$myrow['id']."&sec_token=".$stok."\" onclick=\"javascript:if(!confirm('".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES, api_get_system_encoding()))."')) return false;\">".
+                            Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL).
                             "</a>";
                     }
-                    $iterator ++;
+                    $iterator++;
                 } else {
                     $modify_icons = Display::url(
                         Display::return_icon('default.png'),
@@ -1699,7 +1699,7 @@ class AnnouncementManager
             'announcement.session_id'
         );
 
-        if (api_is_allowed_to_edit(false,true))  {
+        if (api_is_allowed_to_edit(false, true)) {
             // check teacher status
             if (empty($_GET['origin']) or $_GET['origin'] !== 'learnpath') {
 
@@ -1768,7 +1768,7 @@ class AnnouncementManager
 
                 // the user is member of several groups => display personal announcements AND
                 // his group announcements AND the general announcements
-                if (is_array($group_memberships) && count($group_memberships)>0) {
+                if (is_array($group_memberships) && count($group_memberships) > 0) {
                     $sql = "SELECT announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id
                             FROM $tbl_announcement announcement 
                             INNER JOIN $tbl_item_property ip

File diff suppressed because it is too large
+ 140 - 140
main/inc/lib/sessionmanager.lib.php


+ 53 - 53
main/inc/lib/thematic.lib.php

@@ -75,7 +75,7 @@ class Thematic
         $from = intval($from);
         $number_of_items = intval($number_of_items);
 
-        if (!in_array($direction, array('ASC','DESC'))) {
+        if (!in_array($direction, array('ASC', 'DESC'))) {
             $direction = 'ASC';
         }
 
@@ -98,24 +98,24 @@ class Thematic
             $thematic[1] = '<a href="index.php?'.api_get_cidreq().'&action=thematic_details&thematic_id='.$thematic[0].'">'.
                 Security::remove_XSS($thematic[1], STUDENT).$session_star.'</a>';
             if (api_is_allowed_to_edit(null, true)) {
-                $actions  = '';
+                $actions = '';
 
                 if (api_get_session_id()) {
                     if (api_get_session_id() == $thematic[3]) {
                         $actions .= '<a href="index.php?'.api_get_cidreq().'&action=thematic_plan_list&thematic_id='.$thematic[0].'">'.
-                            Display::return_icon('lesson_plan.png',get_lang('ThematicPlan'),'',ICON_SIZE_SMALL).'</a>&nbsp;';
+                            Display::return_icon('lesson_plan.png', get_lang('ThematicPlan'), '', ICON_SIZE_SMALL).'</a>&nbsp;';
                         $actions .= '<a href="index.php?'.api_get_cidreq().'&action=thematic_advance_list&thematic_id='.$thematic[0].'">'.
-                            Display::return_icon('lesson_plan_calendar.png',get_lang('ThematicAdvance'),'',ICON_SIZE_SMALL).'</a>&nbsp;';
+                            Display::return_icon('lesson_plan_calendar.png', get_lang('ThematicAdvance'), '', ICON_SIZE_SMALL).'</a>&nbsp;';
 
                         $actions .= '<a href="index.php?'.api_get_cidreq().'&action=thematic_edit&thematic_id='.$thematic[0].'">'.
-                            Display::return_icon('edit.png',get_lang('Edit'),'',ICON_SIZE_SMALL).'</a>';
+                            Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_SMALL).'</a>';
                         $actions .= '<a onclick="javascript:if(!confirm(\''.get_lang('AreYouSureToDelete').'\')) return false;" href="index.php?'.api_get_cidreq().'&action=thematic_delete&thematic_id='.$thematic[0].'">'.
-                            Display::return_icon('delete.png',get_lang('Delete'),'',ICON_SIZE_SMALL).'</a>';
+                            Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL).'</a>';
                     } else {
-                        $actions .= Display::return_icon('lesson_plan_na.png',get_lang('ThematicPlan'),'',ICON_SIZE_SMALL).'&nbsp;';
-                        $actions .= Display::return_icon('lesson_plan_calendar_na.png',get_lang('ThematicAdvance'),'',ICON_SIZE_SMALL).'&nbsp;';
-                        $actions .= Display::return_icon('edit_na.png',get_lang('Edit'),'',ICON_SIZE_SMALL);
-                        $actions .= Display::return_icon('delete_na.png',get_lang('Delete'),'',ICON_SIZE_SMALL).'&nbsp;';
+                        $actions .= Display::return_icon('lesson_plan_na.png', get_lang('ThematicPlan'), '', ICON_SIZE_SMALL).'&nbsp;';
+                        $actions .= Display::return_icon('lesson_plan_calendar_na.png', get_lang('ThematicAdvance'), '', ICON_SIZE_SMALL).'&nbsp;';
+                        $actions .= Display::return_icon('edit_na.png', get_lang('Edit'), '', ICON_SIZE_SMALL);
+                        $actions .= Display::return_icon('delete_na.png', get_lang('Delete'), '', ICON_SIZE_SMALL).'&nbsp;';
                         $actions .= Display::url(
                             Display::return_icon('cd.gif', get_lang('Copy')),
                             'index.php?'.api_get_cidreq().'&action=thematic_copy&thematic_id='.$thematic[0]
@@ -123,26 +123,26 @@ class Thematic
                     }
                 } else {
                     $actions .= '<a href="index.php?'.api_get_cidreq().'&action=thematic_plan_list&thematic_id='.$thematic[0].'">'.
-                        Display::return_icon('lesson_plan.png',get_lang('ThematicPlan'),'',ICON_SIZE_SMALL).'</a>&nbsp;';
+                        Display::return_icon('lesson_plan.png', get_lang('ThematicPlan'), '', ICON_SIZE_SMALL).'</a>&nbsp;';
                     $actions .= '<a href="index.php?'.api_get_cidreq().'&action=thematic_advance_list&thematic_id='.$thematic[0].'">'.
-                        Display::return_icon('lesson_plan_calendar.png',get_lang('ThematicAdvance'),'',ICON_SIZE_SMALL).'</a>&nbsp;';
+                        Display::return_icon('lesson_plan_calendar.png', get_lang('ThematicAdvance'), '', ICON_SIZE_SMALL).'</a>&nbsp;';
 
                     if ($thematic[2] > 1) {
                         $actions .= '<a href="'.api_get_self().'?action=moveup&'.api_get_cidreq().'&thematic_id='.$thematic[0].'">'.
-                            Display::return_icon('up.png', get_lang('Up'),'',ICON_SIZE_SMALL).'</a>';
+                            Display::return_icon('up.png', get_lang('Up'), '', ICON_SIZE_SMALL).'</a>';
                     } else {
-                        $actions .= Display::return_icon('up_na.png','&nbsp;','',ICON_SIZE_SMALL);
+                        $actions .= Display::return_icon('up_na.png', '&nbsp;', '', ICON_SIZE_SMALL);
                     }
                     if ($thematic[2] < self::get_max_thematic_item()) {
                         $actions .= '<a href="'.api_get_self().'?action=movedown&a'.api_get_cidreq().'&thematic_id='.$thematic[0].'">'.
-                            Display::return_icon('down.png',get_lang('Down'),'',ICON_SIZE_SMALL).'</a>';
+                            Display::return_icon('down.png', get_lang('Down'), '', ICON_SIZE_SMALL).'</a>';
                     } else {
-                        $actions .= Display::return_icon('down_na.png','&nbsp;','',ICON_SIZE_SMALL);
+                        $actions .= Display::return_icon('down_na.png', '&nbsp;', '', ICON_SIZE_SMALL);
                     }
                     $actions .= '<a href="index.php?'.api_get_cidreq().'&action=thematic_edit&thematic_id='.$thematic[0].'">'.
-                        Display::return_icon('edit.png',get_lang('Edit'),'',ICON_SIZE_SMALL).'</a>';
+                        Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_SMALL).'</a>';
                     $actions .= '<a onclick="javascript:if(!confirm(\''.get_lang('AreYouSureToDelete').'\')) return false;" href="index.php?'.api_get_cidreq().'&action=thematic_delete&thematic_id='.$thematic[0].'">'.
-                        Display::return_icon('delete.png',get_lang('Delete'),'',ICON_SIZE_SMALL).'</a>';
+                        Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL).'</a>';
                 }
                 $thematics[] = array($thematic[0], $thematic[1], $actions);
             }
@@ -499,7 +499,7 @@ class Thematic
         $column = intval($column);
         $from   = intval($from);
         $number_of_items = intval($number_of_items);
-        if (!in_array($direction, array('ASC','DESC'))) {
+        if (!in_array($direction, array('ASC', 'DESC'))) {
             $direction = 'ASC';
         }
         $data = array();
@@ -529,8 +529,8 @@ class Thematic
                     $thematic_advance[1] = api_get_local_time($thematic_advance[1]);
                     $thematic_advance[1] = api_format_date($thematic_advance[1], DATE_TIME_FORMAT_LONG);
                     $actions  = '';
-                    $actions .= '<a href="index.php?'.api_get_cidreq().'&action=thematic_advance_edit&thematic_id='.$thematic_id.'&thematic_advance_id='.$thematic_advance[0].'">'.Display::return_icon('edit.png',get_lang('Edit'),'',22).'</a>';
-                    $actions .= '<a onclick="javascript:if(!confirm(\''.get_lang('AreYouSureToDelete').'\')) return false;" href="index.php?'.api_get_cidreq().'&action=thematic_advance_delete&thematic_id='.$thematic_id.'&thematic_advance_id='.$thematic_advance[0].'">'.Display::return_icon('delete.png',get_lang('Delete'),'',22).'</a></center>';
+                    $actions .= '<a href="index.php?'.api_get_cidreq().'&action=thematic_advance_edit&thematic_id='.$thematic_id.'&thematic_advance_id='.$thematic_advance[0].'">'.Display::return_icon('edit.png', get_lang('Edit'), '', 22).'</a>';
+                    $actions .= '<a onclick="javascript:if(!confirm(\''.get_lang('AreYouSureToDelete').'\')) return false;" href="index.php?'.api_get_cidreq().'&action=thematic_advance_delete&thematic_id='.$thematic_id.'&thematic_advance_id='.$thematic_advance[0].'">'.Display::return_icon('delete.png', get_lang('Delete'), '', 22).'</a></center>';
                     $data[] = array($i, $thematic_advance[1], $thematic_advance[2], $thematic_advance[3], $actions);
                     $i++;
                 }
@@ -593,7 +593,7 @@ class Thematic
             foreach ($thematic_advance_data as $key => $thematic_advance) {
                 $session_star = '';
                 if (api_is_allowed_to_edit(null, true)) {
-                    if ($thematic_advance['session_id'] !=0) {
+                    if ($thematic_advance['session_id'] != 0) {
                         $session_star = api_get_session_image(api_get_session_id(), $uinfo['status']);
                     }
                 }
@@ -619,13 +619,13 @@ class Thematic
 
         foreach ($data as $thematic_id => $thematic_plan_data) {
             $new_thematic_plan_data = array();
-            foreach($thematic_plan_data as $thematic_item) {
+            foreach ($thematic_plan_data as $thematic_item) {
                 $thematic_simple_list[] = $thematic_item['description_type'];
                 $new_thematic_plan_data[$thematic_item['description_type']] = $thematic_item;
             }
 
             if (!empty($thematic_simple_list)) {
-                foreach($thematic_simple_list as $item) {
+                foreach ($thematic_simple_list as $item) {
                     $default_thematic_plan_title[$item] = $new_thematic_plan_data[$item]['title'];
                 }
             }
@@ -641,7 +641,7 @@ class Thematic
                     }
                     if (!empty($data[$thematic_id][$id]['title']) && !empty($data[$thematic_id][$id]['description'])) {
                         if (api_is_allowed_to_edit(null, true)) {
-                            if ($data[$thematic_id][$id]['session_id'] !=0) {
+                            if ($data[$thematic_id][$id]['session_id'] != 0) {
                                 $session_star = api_get_session_image(api_get_session_id(), $uinfo['status']);
                             }
                         }
@@ -865,18 +865,18 @@ class Thematic
             api_get_session_id()
         );
 
-        $thematic_plan_complete_list  = array();
+        $thematic_plan_complete_list = array();
         $thematic_plan_id_list = array();
 
         if (!empty($items_from_course)) {
-            foreach($items_from_course as $item) {
+            foreach ($items_from_course as $item) {
                 $thematic_plan_id_list[] = $item['ref'];
                 $thematic_plan_complete_list[$item['ref']] = $item;
             }
         }
 
         if (!empty($items_from_session)) {
-            foreach($items_from_session as $item) {
+            foreach ($items_from_session as $item) {
                 $thematic_plan_id_list[] = $item['ref'];
                 $thematic_plan_complete_list[$item['ref']] = $item;
             }
@@ -899,7 +899,7 @@ class Thematic
                 if (!isset($thematic_id) && !isset($description_type)) {
                     // group all data group by thematic id
                     $tmp = array();
-                    while ($row = Database::fetch_array($rs,'ASSOC')) {
+                    while ($row = Database::fetch_array($rs, 'ASSOC')) {
                         $tmp[] = $row['thematic_id'];
                         if (in_array($row['thematic_id'], $tmp)) {
                             $row['session_id'] = $thematic_plan_complete_list[$row['id']];
@@ -907,7 +907,7 @@ class Thematic
                         }
                     }
                 } else {
-                    while ($row = Database::fetch_array($rs,'ASSOC')) {
+                    while ($row = Database::fetch_array($rs, 'ASSOC')) {
                         $row['session_id'] = $thematic_plan_complete_list[$row['id']];
                         $data[] = $row;
                     }
@@ -942,8 +942,8 @@ class Thematic
         );
 
         $elements_to_show = array();
-        foreach($list as $value) {
-            $elements_to_show[]= $value['ref'];
+        foreach ($list as $value) {
+            $elements_to_show[] = $value['ref'];
         }
         $condition = '';
         if (!empty($elements_to_show)) {
@@ -955,7 +955,7 @@ class Thematic
                     c_id = $course_id AND
                     thematic_id = $thematic_id AND
                     description_type = '$description_type'";
-        $rs	 = Database::query($sql);
+        $rs = Database::query($sql);
 
         $affected_rows = 0;
         if (Database::num_rows($rs) > 0) {
@@ -1193,7 +1193,7 @@ class Thematic
             $diff = array_diff($all, $a_thematic_advance_ids);
             if (!empty($diff)) {
                 $upd = "UPDATE $tbl_thematic_advance SET done_advance = 0
-                        WHERE c_id = $course_id AND id IN(".implode(',',$diff).") ";
+                        WHERE c_id = $course_id AND id IN(".implode(',', $diff).") ";
                 Database::query($upd);
             }
 
@@ -1308,7 +1308,7 @@ class Thematic
             $course_code = api_get_course_id();
         }
         if (api_get_session_id()) {
-            $thematic_data = $this->get_thematic_list(null, $course_code );
+            $thematic_data = $this->get_thematic_list(null, $course_code);
         } else {
             $thematic_data = $this->get_thematic_list(null, $course_code, 0);
         }
@@ -1365,7 +1365,7 @@ class Thematic
             }
             // calculate average by thematic
             $count_total_advances = count($advances);
-            $average = round(($count_done_advances*100)/$count_total_advances);
+            $average = round(($count_done_advances * 100) / $count_total_advances);
         }
 
         return $average;
@@ -1456,12 +1456,12 @@ class Thematic
     public function get_default_thematic_plan_title()
     {
         $default_thematic_plan_titles = array();
-        $default_thematic_plan_titles[1]= get_lang('Objectives');
-        $default_thematic_plan_titles[2]= get_lang('SkillToAcquire');
-        $default_thematic_plan_titles[3]= get_lang('Methodology');
-        $default_thematic_plan_titles[4]= get_lang('Infrastructure');
-        $default_thematic_plan_titles[5]= get_lang('Assessment');
-        $default_thematic_plan_titles[6]= get_lang('Others');
+        $default_thematic_plan_titles[1] = get_lang('Objectives');
+        $default_thematic_plan_titles[2] = get_lang('SkillToAcquire');
+        $default_thematic_plan_titles[3] = get_lang('Methodology');
+        $default_thematic_plan_titles[4] = get_lang('Infrastructure');
+        $default_thematic_plan_titles[5] = get_lang('Assessment');
+        $default_thematic_plan_titles[6] = get_lang('Others');
 
         return $default_thematic_plan_titles;
     }
@@ -1473,12 +1473,12 @@ class Thematic
     public function get_default_thematic_plan_icon()
     {
         $default_thematic_plan_icon = array();
-        $default_thematic_plan_icon[1]= 'icons/32/objective.png';
-        $default_thematic_plan_icon[2]= 'icons/32/skills.png';
-        $default_thematic_plan_icon[3]= 'icons/32/strategy.png';
-        $default_thematic_plan_icon[4]= 'icons/32/laptop.png';
-        $default_thematic_plan_icon[5]= 'icons/32/assessment.png';
-        $default_thematic_plan_icon[6]= 'icons/32/wizard.png';
+        $default_thematic_plan_icon[1] = 'icons/32/objective.png';
+        $default_thematic_plan_icon[2] = 'icons/32/skills.png';
+        $default_thematic_plan_icon[3] = 'icons/32/strategy.png';
+        $default_thematic_plan_icon[4] = 'icons/32/laptop.png';
+        $default_thematic_plan_icon[5] = 'icons/32/assessment.png';
+        $default_thematic_plan_icon[6] = 'icons/32/wizard.png';
 
         return $default_thematic_plan_icon;
     }
@@ -1490,11 +1490,11 @@ class Thematic
     public function get_default_question()
     {
         $question = array();
-        $question[1]= get_lang('ObjectivesQuestions');
-        $question[2]= get_lang('SkillToAcquireQuestions');
-        $question[3]= get_lang('MethodologyQuestions');
-        $question[4]= get_lang('InfrastructureQuestions');
-        $question[5]= get_lang('AssessmentQuestions');
+        $question[1] = get_lang('ObjectivesQuestions');
+        $question[2] = get_lang('SkillToAcquireQuestions');
+        $question[3] = get_lang('MethodologyQuestions');
+        $question[4] = get_lang('InfrastructureQuestions');
+        $question[5] = get_lang('AssessmentQuestions');
 
         return $question;
     }

+ 8 - 8
main/lp/openoffice_text.class.php

@@ -129,7 +129,7 @@ class OpenofficeText extends OpenofficeDocument {
             if (empty($matches[1][$i]))
                 continue;
 
-            $content = strstr($content,$matches[0][$i]);
+            $content = strstr($content, $matches[0][$i]);
             if ($i + 1 !== count($matches[0])) {
                 $dir_content = substr($content, 0, strpos($content, $matches[0][$i + 1]));
             } else {
@@ -261,7 +261,7 @@ class OpenofficeText extends OpenofficeDocument {
                         foreach ($specific_fields as $specific_field) {
                             if (isset($_REQUEST[$specific_field['code']])) {
                                 $sterms = trim($_REQUEST[$specific_field['code']]);
-                                $all_specific_terms .= ' '. $sterms;
+                                $all_specific_terms .= ' '.$sterms;
                                 if (!empty($sterms)) {
                                     $sterms = explode(',', $sterms);
                                     foreach ($sterms as $sterm) {
@@ -270,10 +270,10 @@ class OpenofficeText extends OpenofficeDocument {
                                 }
                             }
                         }
-                        $page_content = $all_specific_terms .' '. $page_content;
+                        $page_content = $all_specific_terms.' '.$page_content;
                         $ic_slide->addValue('content', $page_content);
                         // Add a comment to say terms separated by commas.
-                        $courseid=api_get_course_id();
+                        $courseid = api_get_course_id();
                         $ic_slide->addCourseId($courseid);
                         $ic_slide->addToolId(TOOL_LEARNPATH);
                         $lp_id = $this->lp_id;
@@ -281,7 +281,7 @@ class OpenofficeText extends OpenofficeDocument {
                             SE_COURSE_ID => $courseid,
                             SE_TOOL_ID => TOOL_LEARNPATH,
                             SE_DATA => array('lp_id' => $lp_id, 'lp_item'=> $previous, 'document_id' => $document_id),
-                            SE_USER => (int)api_get_user_id(),
+                            SE_USER => (int) api_get_user_id(),
                         );
                         $ic_slide->xapian_data = serialize($xapian_data);
                         $di->addChunk($ic_slide);
@@ -305,7 +305,7 @@ class OpenofficeText extends OpenofficeDocument {
      * Returns additional Java command parameters
      * @return	string	The additional parameters to be used in the Java call
      */
-    public function add_command_parameters(){
+    public function add_command_parameters() {
         return ' -d woogie "'.$this->base_work_dir.'/'.$this->file_path.'"  "'.$this->base_work_dir.$this->created_dir.'/'.$this->file_name.'.html"';
     }
 
@@ -317,7 +317,7 @@ class OpenofficeText extends OpenofficeDocument {
      */
     public function format_page_content($header, $content) {
         // Limit the width of the doc.
-        list($max_width, $max_height) = explode('x',api_get_setting('service_ppt2lp','size'));
+        list($max_width, $max_height) = explode('x', api_get_setting('service_ppt2lp', 'size'));
 
         $content = preg_replace("|<body[^>]*>|i", "\\0\r\n<div style=\"width:".$max_width."\">", $content, -1, $count);
         if ($count < 1) {
@@ -350,7 +350,7 @@ class OpenofficeText extends OpenofficeDocument {
                 }
 
             } elseif ($img_width > $max_width - 10) {
-                $picture_resized = str_ireplace('width='.$img_width, 'width="'.($max_width-10).'"', $images[0][$key]);
+                $picture_resized = str_ireplace('width='.$img_width, 'width="'.($max_width - 10).'"', $images[0][$key]);
                 $content = str_replace($images[0][$key], $picture_resized, $content);
             }
         }

+ 17 - 17
main/survey/survey.php

@@ -13,7 +13,7 @@ use ChamiloSession as Session;
 require_once __DIR__.'/../inc/global.inc.php';
 
 $this_section = SECTION_COURSES;
-$current_course_tool  = TOOL_SURVEY;
+$current_course_tool = TOOL_SURVEY;
 
 api_protect_course_script(true);
 
@@ -57,7 +57,7 @@ $interbreadcrumb[] = array(
 // Getting the survey information
 if (!empty($_GET['survey_id'])) {
     $course_code = api_get_course_id();
-    if ($course_code!=-1) {
+    if ($course_code != -1) {
         $survey_data = SurveyManager::get_survey($survey_id);
     } else {
         api_not_allowed(true);
@@ -132,12 +132,12 @@ if (!empty($survey_data['survey_version'])) {
 SurveyUtil::check_first_last_question($_GET['survey_id']);
 
 // Action links
-$survey_actions = '<a href="'.api_get_path(WEB_CODE_PATH).'survey/create_new_survey.php?'.api_get_cidreq().'&amp;action=edit&amp;survey_id='.$survey_id.'">'.Display::return_icon('edit.png', get_lang('EditSurvey'),'',ICON_SIZE_MEDIUM).'</a>';
-$survey_actions .= '<a href="'.api_get_path(WEB_CODE_PATH).'survey/survey_list.php?'.api_get_cidreq().'&amp;action=delete&amp;survey_id='.$survey_id.'" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang('DeleteSurvey').'?', ENT_QUOTES)).'\')) return false;">'.Display::return_icon('delete.png', get_lang('DeleteSurvey'),'',ICON_SIZE_MEDIUM).'</a>';
+$survey_actions = '<a href="'.api_get_path(WEB_CODE_PATH).'survey/create_new_survey.php?'.api_get_cidreq().'&amp;action=edit&amp;survey_id='.$survey_id.'">'.Display::return_icon('edit.png', get_lang('EditSurvey'), '', ICON_SIZE_MEDIUM).'</a>';
+$survey_actions .= '<a href="'.api_get_path(WEB_CODE_PATH).'survey/survey_list.php?'.api_get_cidreq().'&amp;action=delete&amp;survey_id='.$survey_id.'" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang('DeleteSurvey').'?', ENT_QUOTES)).'\')) return false;">'.Display::return_icon('delete.png', get_lang('DeleteSurvey'), '', ICON_SIZE_MEDIUM).'</a>';
 //$survey_actions .= '<a href="'.api_get_path(WEB_CODE_PATH).'survey/create_survey_in_another_language.php?id_survey='.$survey_id.'">'.Display::return_icon('copy.gif', get_lang('Copy')).'</a>';
-$survey_actions .= '<a href="'.api_get_path(WEB_CODE_PATH).'survey/preview.php?'.api_get_cidreq().'&amp;survey_id='.$survey_id.'">'.Display::return_icon('preview_view.png', get_lang('Preview'),'',ICON_SIZE_MEDIUM).'</a>';
-$survey_actions .= '<a href="'.api_get_path(WEB_CODE_PATH).'survey/survey_invite.php?'.api_get_cidreq().'&amp;survey_id='.$survey_id.'">'.Display::return_icon('mail_send.png', get_lang('Publish'),'',ICON_SIZE_MEDIUM).'</a>';
-$survey_actions .= '<a href="'.api_get_path(WEB_CODE_PATH).'survey/reporting.php?'.api_get_cidreq().'&amp;survey_id='.$survey_id.'">'.Display::return_icon('stats.png', get_lang('Reporting'),'',ICON_SIZE_MEDIUM).'</a>';
+$survey_actions .= '<a href="'.api_get_path(WEB_CODE_PATH).'survey/preview.php?'.api_get_cidreq().'&amp;survey_id='.$survey_id.'">'.Display::return_icon('preview_view.png', get_lang('Preview'), '', ICON_SIZE_MEDIUM).'</a>';
+$survey_actions .= '<a href="'.api_get_path(WEB_CODE_PATH).'survey/survey_invite.php?'.api_get_cidreq().'&amp;survey_id='.$survey_id.'">'.Display::return_icon('mail_send.png', get_lang('Publish'), '', ICON_SIZE_MEDIUM).'</a>';
+$survey_actions .= '<a href="'.api_get_path(WEB_CODE_PATH).'survey/reporting.php?'.api_get_cidreq().'&amp;survey_id='.$survey_id.'">'.Display::return_icon('stats.png', get_lang('Reporting'), '', ICON_SIZE_MEDIUM).'</a>';
 echo '<div class="actions">'.$survey_actions.'</div>';
 
 if ($survey_data['survey_type'] == 0) {
@@ -221,15 +221,15 @@ while ($row = Database::fetch_array($result, 'ASSOC')) {
     echo '<td>'.$tool_name.'</td>';
     echo '<td>'.$row['number_of_options'].'</td>';
     echo '<td>';
-    echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&action=edit&type='.$row['type'].'&survey_id='.$survey_id.'&question_id='.$row['question_id'].'">'.Display::return_icon('edit.png', get_lang('Edit'),'',ICON_SIZE_SMALL).'</a>';
-    echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/survey.php?'.api_get_cidreq().'&action=delete&survey_id='.$survey_id.'&question_id='.$row['question_id'].'" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("DeleteSurveyQuestion").'?',ENT_QUOTES,$charset)).'\')) return false;">'.Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_SMALL).'</a>';
+    echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&action=edit&type='.$row['type'].'&survey_id='.$survey_id.'&question_id='.$row['question_id'].'">'.Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_SMALL).'</a>';
+    echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/survey.php?'.api_get_cidreq().'&action=delete&survey_id='.$survey_id.'&question_id='.$row['question_id'].'" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("DeleteSurveyQuestion").'?', ENT_QUOTES, $charset)).'\')) return false;">'.Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL).'</a>';
     if ($question_counter > 1) {
-        echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/survey.php?'.api_get_cidreq().'&action=moveup&survey_id='.$survey_id.'&question_id='.$row['question_id'].'">'.Display::return_icon('up.png', get_lang('MoveUp'),'',ICON_SIZE_SMALL).'</a>';
+        echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/survey.php?'.api_get_cidreq().'&action=moveup&survey_id='.$survey_id.'&question_id='.$row['question_id'].'">'.Display::return_icon('up.png', get_lang('MoveUp'), '', ICON_SIZE_SMALL).'</a>';
     } else {
-        Display::display_icon('up_na.png','&nbsp;','',ICON_SIZE_SMALL);
+        Display::display_icon('up_na.png', '&nbsp;', '', ICON_SIZE_SMALL);
     }
     if ($question_counter < $question_counter_max) {
-        echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/survey.php?'.api_get_cidreq().'&action=movedown&survey_id='.$survey_id.'&question_id='.$row['question_id'].'">'.Display::return_icon('down.png', get_lang('MoveDown'),'',ICON_SIZE_SMALL).'</a>';
+        echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/survey.php?'.api_get_cidreq().'&action=movedown&survey_id='.$survey_id.'&question_id='.$row['question_id'].'">'.Display::return_icon('down.png', get_lang('MoveDown'), '', ICON_SIZE_SMALL).'</a>';
     } else {
         Display::display_icon('down_na.png', '&nbsp;', '', ICON_SIZE_SMALL);
     }
@@ -237,8 +237,8 @@ while ($row = Database::fetch_array($result, 'ASSOC')) {
     $question_counter++;
 
     if ($is_survey_type_1) {
-        echo '<td>'.(($row['survey_group_pri']==0)?get_lang('Secondary'):get_lang('Primary')).'</td>';
-        echo '<td>'.(($row['survey_group_pri']==0)?$groups[$row['survey_group_sec1']].'-'.$groups[$row['survey_group_sec2']]:$groups[$row['survey_group_pri']]).'</td>';
+        echo '<td>'.(($row['survey_group_pri'] == 0) ? get_lang('Secondary') : get_lang('Primary')).'</td>';
+        echo '<td>'.(($row['survey_group_pri'] == 0) ? $groups[$row['survey_group_sec1']].'-'.$groups[$row['survey_group_sec2']] : $groups[$row['survey_group_pri']]).'</td>';
     }
     echo '</tr>';
 }
@@ -291,9 +291,9 @@ if ($is_survey_type_1) {
     while ($row = Database::fetch_array($rs, 'ASSOC')) {
         $grouplist .= '<tr><td>'.$row['name'].'</td><td>'.$row['description'].'</td><td>'.
         '<a href="'.api_get_path(WEB_CODE_PATH).'survey/survey.php?survey_id='.$survey_id.'&gid='.$row['id'].'&action=editgroup">'.
-        Display::return_icon('edit.png', get_lang('Edit'),'',ICON_SIZE_SMALL).'</a> '.
-        '<a href="'.api_get_path(WEB_CODE_PATH).'survey/survey.php?survey_id='.$survey_id.'&gid='.$row['id'].'&action=deletegroup" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(sprintf(get_lang('DeleteSurveyGroup'),$row['name']).'?',ENT_QUOTES)).'\')) return false;">'.
-        Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_SMALL).'</a>'.
+        Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_SMALL).'</a> '.
+        '<a href="'.api_get_path(WEB_CODE_PATH).'survey/survey.php?survey_id='.$survey_id.'&gid='.$row['id'].'&action=deletegroup" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(sprintf(get_lang('DeleteSurveyGroup'), $row['name']).'?', ENT_QUOTES)).'\')) return false;">'.
+        Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL).'</a>'.
         '</td></tr>';
     }
     echo $grouplist.'</table>';

File diff suppressed because it is too large
+ 189 - 189
main/wiki/wiki.inc.php


+ 67 - 67
main/work/work.lib.php

@@ -36,27 +36,27 @@ function display_action_links($id, $cur_dir_path, $action)
 
     if (!empty($id)) {
         $display_output .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&gradebook='.$gradebook.'&id='.$my_back_id.'">'.
-            Display::return_icon('back.png', get_lang('BackToWorksList'),'',ICON_SIZE_MEDIUM).'</a>';
+            Display::return_icon('back.png', get_lang('BackToWorksList'), '', ICON_SIZE_MEDIUM).'</a>';
     }
 
     if (api_is_allowed_to_edit(null, true) && $origin != 'learnpath') {
         // Create dir
         if (empty($id)) {
             $display_output .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&action=create_dir&gradebook='.$gradebook.'">';
-            $display_output .= Display::return_icon('new_work.png', get_lang('CreateAssignment'),'',ICON_SIZE_MEDIUM).'</a>';
+            $display_output .= Display::return_icon('new_work.png', get_lang('CreateAssignment'), '', ICON_SIZE_MEDIUM).'</a>';
         }
         if (empty($id)) {
             // Options
             $display_output .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&action=settings&gradebook='.$gradebook.'">';
-            $display_output .= Display::return_icon('settings.png', get_lang('EditToolOptions'),'',ICON_SIZE_MEDIUM).'</a>';
+            $display_output .= Display::return_icon('settings.png', get_lang('EditToolOptions'), '', ICON_SIZE_MEDIUM).'</a>';
         }
-        $display_output .= '<a id="open-view-list" href="#">' . Display::return_icon('listwork.png', get_lang('ViewStudents'),'',ICON_SIZE_MEDIUM) . '</a>';
+        $display_output .= '<a id="open-view-list" href="#">'.Display::return_icon('listwork.png', get_lang('ViewStudents'), '', ICON_SIZE_MEDIUM).'</a>';
 
     }
 
     if (api_is_allowed_to_edit(null, true) && $origin != 'learnpath' && api_is_allowed_to_session_edit(false, true)) {
         // Delete all files
-        if (api_get_setting('permanently_remove_deleted_files') == 'true'){
+        if (api_get_setting('permanently_remove_deleted_files') == 'true') {
             $message = get_lang('ConfirmYourChoiceDeleteAllfiles');
         } else {
             $message = get_lang('ConfirmYourChoice');
@@ -526,10 +526,10 @@ function showStudentWorkGrid()
 
     $columnModel = array(
         array('name'=>'type', 'index'=>'type', 'width'=>'30', 'align'=>'center', 'sortable' => 'false'),
-        array('name'=>'title', 'index'=>'title', 'width'=>'250',   'align'=>'left'),
-        array('name'=>'expires_on', 'index'=>'expires_on', 'width'=>'80',  'align'=>'center', 'sortable'=>'false'),
-        array('name'=>'feedback', 'index'=>'feedback', 'width'=>'80',  'align'=>'center', 'sortable'=>'false'),
-        array('name'=>'last_upload', 'index'=>'feedback', 'width'=>'125',  'align'=>'center', 'sortable'=>'false')
+        array('name'=>'title', 'index'=>'title', 'width'=>'250', 'align'=>'left'),
+        array('name'=>'expires_on', 'index'=>'expires_on', 'width'=>'80', 'align'=>'center', 'sortable'=>'false'),
+        array('name'=>'feedback', 'index'=>'feedback', 'width'=>'80', 'align'=>'center', 'sortable'=>'false'),
+        array('name'=>'last_upload', 'index'=>'feedback', 'width'=>'125', 'align'=>'center', 'sortable'=>'false')
     );
 
     if ($courseInfo['show_score'] == 0) {
@@ -566,10 +566,10 @@ function showTeacherWorkGrid()
 {
     $columnModel = array(
         array('name'=>'type', 'index'=>'type', 'width'=>'35', 'align'=>'center', 'sortable' => 'false'),
-        array('name'=>'title', 'index'=>'title',  'width'=>'300',   'align'=>'left', 'wrap_cell' => "true"),
-        array('name'=>'sent_date', 'index'=>'sent_date', 'width'=>'125',  'align'=>'center'),
-        array('name'=>'expires_on', 'index'=>'expires_on', 'width'=>'125',  'align'=>'center'),
-        array('name'=>'amount', 'index'=>'amount', 'width'=>'110',  'align'=>'center', 'sortable' => 'false'),
+        array('name'=>'title', 'index'=>'title', 'width'=>'300', 'align'=>'left', 'wrap_cell' => "true"),
+        array('name'=>'sent_date', 'index'=>'sent_date', 'width'=>'125', 'align'=>'center'),
+        array('name'=>'expires_on', 'index'=>'expires_on', 'width'=>'125', 'align'=>'center'),
+        array('name'=>'amount', 'index'=>'amount', 'width'=>'110', 'align'=>'center', 'sortable' => 'false'),
         array('name'=>'actions', 'index'=>'actions', 'width'=>'110', 'align'=>'left', 'sortable'=>'false')
     );
 
@@ -770,7 +770,7 @@ function deleteDirWork($id)
         return false;
     }
 
-    $base_work_dir = api_get_path(SYS_COURSE_PATH) .$_course['path'].'/work';
+    $base_work_dir = api_get_path(SYS_COURSE_PATH).$_course['path'].'/work';
     $work_data_url = $base_work_dir.$work_data['url'];
     $check = Security::check_abs_path($work_data_url.'/', $base_work_dir.'/');
 
@@ -901,7 +901,7 @@ function deleteDirWork($id)
 function get_work_path($id)
 {
     $table = Database::get_course_table(TABLE_STUDENT_PUBLICATION);
-    $course_id  = api_get_course_int_id();
+    $course_id = api_get_course_int_id();
     $sql = 'SELECT url FROM '.$table.'
             WHERE c_id = '.$course_id.' AND id='.intval($id);
     $res = Database::query($sql);
@@ -1024,9 +1024,9 @@ function directory_to_array($directory)
     if ($handle = @opendir($directory)) {
         while (false !== ($file = readdir($handle))) {
             if ($file != '.' && $file != '..') {
-                if (is_dir($directory. '/' . $file)) {
-                    $array_items = array_merge($array_items, directory_to_array($directory. '/' . $file));
-                    $file = $directory . '/' . $file;
+                if (is_dir($directory.'/'.$file)) {
+                    $array_items = array_merge($array_items, directory_to_array($directory.'/'.$file));
+                    $file = $directory.'/'.$file;
                     $array_items[] = preg_replace("/\/\//si", '/', $file);
                 }
             }
@@ -1102,7 +1102,7 @@ function count_dir($path_dir, $recurse)
             if (is_dir($path_dir.'/'.$entry)) {
                 $count_dir++;
                 if ($recurse) {
-                    $count += count_dir($path_dir . '/' . $entry, $recurse);
+                    $count += count_dir($path_dir.'/'.$entry, $recurse);
                 }
             } else {
                 $count++;
@@ -1384,11 +1384,11 @@ function getWorkListStudent(
         $courseInfo
     );
 
-    if (!in_array($direction, array('asc','desc'))) {
+    if (!in_array($direction, array('asc', 'desc'))) {
         $direction = 'desc';
     }
     if (!empty($where_condition)) {
-        $where_condition = ' AND ' . $where_condition;
+        $where_condition = ' AND '.$where_condition;
     }
 
     $column = !empty($column) ? Database::escape_string($column) : 'sent_date';
@@ -1549,7 +1549,7 @@ function getWorkListTeacher(
         $direction = 'desc';
     }
     if (!empty($where_condition)) {
-        $where_condition = ' AND ' . $where_condition;
+        $where_condition = ' AND '.$where_condition;
     }
 
     $column = !empty($column) ? Database::escape_string($column) : 'sent_date';
@@ -1608,7 +1608,7 @@ function getWorkListTeacher(
             );
 
             $work['amount'] = Display::label(
-                $countUniqueAttempts . '/' .
+                $countUniqueAttempts.'/'.
                 $totalUsers,
                 'success'
             );
@@ -1657,7 +1657,7 @@ function getWorkListTeacher(
                         array(),
                         ICON_SIZE_SMALL
                     ),
-                    api_get_path(WEB_CODE_PATH) . 'work/downloadfolder.inc.php?id=' . $workId . '&' . api_get_cidreq()
+                    api_get_path(WEB_CODE_PATH).'work/downloadfolder.inc.php?id='.$workId.'&'.api_get_cidreq()
                 );
             } else {
                 $downloadLink = Display::url(
@@ -1741,7 +1741,7 @@ function get_work_user_list_from_documents(
     $userCondition = " AND u.user_id = $studentId ";
     $sessionCondition = api_get_session_condition($sessionId, true, false, 'w.session_id');
     $workCondition = " AND w_rel.work_id = $workId";
-    $workParentCondition  = " AND w.parent_id = $workId";
+    $workParentCondition = " AND w.parent_id = $workId";
 
     $sql = "(
                 $select1 FROM $userTable u
@@ -1848,7 +1848,7 @@ function get_work_user_list_from_documents(
         }
 
         if ($allowEdition && !empty($itemId)) {
-            $deleteLink  = Display::url($deleteIcon, $urlDelete.'&item_id='.$itemId.'&id='.$workId);
+            $deleteLink = Display::url($deleteIcon, $urlDelete.'&item_id='.$itemId.'&id='.$workId);
         } else {
             $deleteLink = null;
         }
@@ -1931,7 +1931,7 @@ function get_work_user_list(
     $start = intval($start);
     $limit = intval($limit);
 
-    if (!in_array($direction, array('asc','desc'))) {
+    if (!in_array($direction, array('asc', 'desc'))) {
         $direction = 'desc';
     }
 
@@ -2011,7 +2011,7 @@ function get_work_user_list(
         $work_assignment = get_work_assignment_by_id($work_id, $courseId);
 
         if (!empty($studentId)) {
-            $where_condition.= " AND u.user_id = ".intval($studentId);
+            $where_condition .= " AND u.user_id = ".intval($studentId);
         }
 
         $sql = " $select
@@ -2023,7 +2023,7 @@ function get_work_user_list(
                     $extra_conditions 
                     $where_condition 
                     $condition_session
-                    AND u.status != " . INVITEE . "
+                    AND u.status != ".INVITEE."
                 ORDER BY $column $direction";
 
         if (!empty($start) && !empty($limit)) {
@@ -2201,8 +2201,8 @@ function get_work_user_list(
                     $action .= '<a href="'.$url.'view.php?'.api_get_cidreq().'&id='.$item_id.'" title="'.get_lang('View').'">'.$rateIcon.'</a> ';
 
                     if ($unoconv && empty($work['contains_file'])) {
-                        $action .=  '<a href="'.$url.'work_list_all.php?'.api_get_cidreq().'&id='.$work_id.'&action=export_to_doc&item_id='.$item_id.'" title="'.get_lang('ExportToDoc').'" >'.
-                            Display::return_icon('export_doc.png', get_lang('ExportToDoc'),array(), ICON_SIZE_SMALL).'</a> ';
+                        $action .= '<a href="'.$url.'work_list_all.php?'.api_get_cidreq().'&id='.$work_id.'&action=export_to_doc&item_id='.$item_id.'" title="'.get_lang('ExportToDoc').'" >'.
+                            Display::return_icon('export_doc.png', get_lang('ExportToDoc'), array(), ICON_SIZE_SMALL).'</a> ';
                     }
 
                     $alreadyUploaded = '';
@@ -2261,7 +2261,7 @@ function get_work_user_list(
 
                     if ($locked) {
                         if ($qualification_exists) {
-                            $action .= Display::return_icon('edit_na.png', get_lang('CorrectAndRate'),array(), ICON_SIZE_SMALL);
+                            $action .= Display::return_icon('edit_na.png', get_lang('CorrectAndRate'), array(), ICON_SIZE_SMALL);
                         } else {
                             $action .= Display::return_icon('edit_na.png', get_lang('Comment'), array(), ICON_SIZE_SMALL);
                         }
@@ -2285,23 +2285,23 @@ function get_work_user_list(
                             );
                         } else {
                             $action .= '<a href="'.$url.'work.php?'.api_get_cidreq().'&action=move&item_id='.$item_id.'&id='.$work['parent_id'].'" title="'.get_lang('Move').'">'.
-                                Display::return_icon('move.png', get_lang('Move'),array(), ICON_SIZE_SMALL).'</a>';
+                                Display::return_icon('move.png', get_lang('Move'), array(), ICON_SIZE_SMALL).'</a>';
                         }
                     }
 
                     if ($work['accepted'] == '1') {
                         $action .= '<a href="'.$url.'work_list_all.php?'.api_get_cidreq().'&id='.$work_id.'&action=make_invisible&item_id='.$item_id.'" title="'.get_lang('Invisible').'" >'.
-                            Display::return_icon('visible.png', get_lang('Invisible'),array(), ICON_SIZE_SMALL).'</a>';
+                            Display::return_icon('visible.png', get_lang('Invisible'), array(), ICON_SIZE_SMALL).'</a>';
                     } else {
                         $action .= '<a href="'.$url.'work_list_all.php?'.api_get_cidreq().'&id='.$work_id.'&action=make_visible&item_id='.$item_id.'" title="'.get_lang('Visible').'" >'.
-                            Display::return_icon('invisible.png', get_lang('Visible'),array(), ICON_SIZE_SMALL).'</a> ';
+                            Display::return_icon('invisible.png', get_lang('Visible'), array(), ICON_SIZE_SMALL).'</a> ';
                     }
 
                     if ($locked) {
                         $action .= Display::return_icon('delete_na.png', get_lang('Delete'), '', ICON_SIZE_SMALL);
                     } else {
-                        $action .= '<a href="'.$url.'work_list_all.php?'.api_get_cidreq().'&id='.$work_id.'&action=delete&item_id='.$item_id.'" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'),ENT_QUOTES))."'".')) return false;" title="'.get_lang('Delete').'" >'.
-                            Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_SMALL).'</a>';
+                        $action .= '<a href="'.$url.'work_list_all.php?'.api_get_cidreq().'&id='.$work_id.'&action=delete&item_id='.$item_id.'" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES))."'".')) return false;" title="'.get_lang('Delete').'" >'.
+                            Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL).'</a>';
                     }
                 } elseif ($is_author && (empty($work['qualificator_id']) || $work['qualificator_id'] == 0)) {
                     $action .= '<a href="'.$url.'view.php?'.api_get_cidreq().'&id='.$item_id.'" title="'.get_lang('View').'">'.
@@ -2312,8 +2312,8 @@ function get_work_user_list(
                             $action .= '<a href="'.$url.'edit.php?'.api_get_cidreq().'&item_id='.$item_id.'&id='.$work['parent_id'].'" title="'.get_lang('Modify').'">'.
                                 Display::return_icon('edit.png', get_lang('Comment'), array(), ICON_SIZE_SMALL).'</a>';
                         }
-                        $action .= ' <a href="'.$url.'work_list.php?'.api_get_cidreq().'&action=delete&item_id='.$item_id.'&id='.$work['parent_id'].'" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'),ENT_QUOTES))."'".')) return false;" title="'.get_lang('Delete').'"  >'.
-                            Display::return_icon('delete.png',get_lang('Delete'),'',ICON_SIZE_SMALL).'</a>';
+                        $action .= ' <a href="'.$url.'work_list.php?'.api_get_cidreq().'&action=delete&item_id='.$item_id.'&id='.$work['parent_id'].'" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES))."'".')) return false;" title="'.get_lang('Delete').'"  >'.
+                            Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL).'</a>';
                     }
                 } else {
                     $action .= '<a href="'.$url.'view.php?'.api_get_cidreq().'&id='.$item_id.'" title="'.get_lang('View').'">'.
@@ -2349,7 +2349,7 @@ function send_reminder_users_without_publication($task_data)
     $_course = api_get_course_info();
     $task_id = $task_data['id'];
     $task_title = !empty($task_data['title']) ? $task_data['title'] : basename($task_data['url']);
-    $subject = '[' . api_get_setting('siteName') . '] ';
+    $subject = '['.api_get_setting('siteName').'] ';
 
     // The body can be as long as you wish, and any combination of text and variables
     $content = get_lang('ReminderToSubmitPendingTask')."\n".get_lang('CourseName').' : '.$_course['name']."\n";
@@ -2358,7 +2358,7 @@ function send_reminder_users_without_publication($task_data)
     $mails_sent_to = array();
     foreach ($list_users as $user) {
         $name_user = api_get_person_name($user[1], $user[0], null, PERSON_NAME_EMAIL_ADDRESS);
-        $dear_line = get_lang('Dear')." ".api_get_person_name($user[1], $user[0]) .", \n\n";
+        $dear_line = get_lang('Dear')." ".api_get_person_name($user[1], $user[0]).", \n\n";
         $body      = $dear_line.$content;
         MessageManager::send_message($user[3], $subject, $body);
         $mails_sent_to[] = $name_user;
@@ -2387,22 +2387,22 @@ function send_email_on_homework_creation($courseId, $sessionId = 0, $workId)
     } else {
         $students = CourseManager::get_student_list_from_course_code($courseCode, true, $sessionId);
     }
-    $emailsubject = '[' . api_get_setting('siteName') . '] '.get_lang('HomeworkCreated');
+    $emailsubject = '['.api_get_setting('siteName').'] '.get_lang('HomeworkCreated');
     $currentUser = api_get_user_info(api_get_user_id());
     if (!empty($students)) {
-        foreach($students as $student) {
+        foreach ($students as $student) {
             $user_info = api_get_user_info($student["user_id"]);
-            if(!empty($user_info["mail"])) {
+            if (!empty($user_info["mail"])) {
                 $name_user = api_get_person_name(
                     $user_info["firstname"],
                     $user_info["lastname"],
                     null,
                     PERSON_NAME_EMAIL_ADDRESS
                 );
-                $link = api_get_path(WEB_CODE_PATH) . 'work/work_list_all.php?' . api_get_cidreq() . '&id=' . $workId;
+                $link = api_get_path(WEB_CODE_PATH).'work/work_list_all.php?'.api_get_cidreq().'&id='.$workId;
                 $emailbody = get_lang('Dear')." ".$name_user.",\n\n";
                 $emailbody .= get_lang('HomeworkHasBeenCreatedForTheCourse')." ".$courseCode.". "."\n\n".
-                    '<a href="'. $link . '">' . get_lang('PleaseCheckHomeworkPage') . '</a>';
+                    '<a href="'.$link.'">'.get_lang('PleaseCheckHomeworkPage').'</a>';
                 $emailbody .= "\n\n".api_get_person_name($currentUser["firstname"], $currentUser["lastname"]);
 
                 $additionalParameters = array(
@@ -2444,7 +2444,7 @@ function is_work_exist_by_url($url)
     $url = Database::escape_string($url);
     $sql = "SELECT id FROM $work_table WHERE url='$url'";
     $result = Database::query($sql);
-    if (Database::num_rows($result)> 0) {
+    if (Database::num_rows($result) > 0) {
         $row = Database::fetch_row($result);
         if (empty($row)) {
             return false;
@@ -2565,7 +2565,7 @@ function get_list_users_without_publication($task_id, $studentId = null)
     }
 
     if (!empty($studentId)) {
-        $sql_users.= " AND u.user_id = ".intval($studentId);
+        $sql_users .= " AND u.user_id = ".intval($studentId);
     }
 
     $group_id = api_get_group_id();
@@ -2575,7 +2575,7 @@ function get_list_users_without_publication($task_id, $studentId = null)
         $groupInfo = GroupManager::get_group_properties($group_id);
         $group_user_list = GroupManager::get_subscribed_users($groupInfo);
         if (!empty($group_user_list)) {
-            foreach($group_user_list as $group_user) {
+            foreach ($group_user_list as $group_user) {
                 $new_group_user_list[] = $group_user['user_id'];
             }
         }
@@ -2996,7 +2996,7 @@ function getWorkDescriptionToolbar()
 function getWorkComments($work)
 {
     $commentTable = Database::get_course_table(TABLE_STUDENT_PUBLICATION_ASSIGNMENT_COMMENT);
-    $userTable= Database::get_main_table(TABLE_MAIN_USER);
+    $userTable = Database::get_main_table(TABLE_MAIN_USER);
 
     $courseId = intval($work['c_id']);
     $workId = intval($work['id']);
@@ -3258,7 +3258,7 @@ function formatWorkScore($score, $weight)
     }
 
     return Display::label(
-    api_number_format($score, 1) . ' / '.$weight,
+    api_number_format($score, 1).' / '.$weight,
         $label
     );
 }
@@ -3746,7 +3746,7 @@ function sendAlertToUsers($workId, $courseInfo, $session_id)
             null,
             PERSON_NAME_EMAIL_ADDRESS
         );
-        $subject = "[" . api_get_setting('siteName') . "] ".get_lang('SendMailBody')."\n ".get_lang('CourseName').": ".$courseInfo['name']."  ";
+        $subject = "[".api_get_setting('siteName')."] ".get_lang('SendMailBody')."\n ".get_lang('CourseName').": ".$courseInfo['name']."  ";
         foreach ($user_list as $user_data) {
             $to_user_id = $user_data['user_id'];
             $user_info = api_get_user_info($to_user_id);
@@ -3823,7 +3823,7 @@ function processWorkForm(
 
     $title = $values['title'];
     $description = $values['description'];
-    $contains_file = isset($values['contains_file']) && !empty($values['contains_file']) ? intval($values['contains_file']): 0;
+    $contains_file = isset($values['contains_file']) && !empty($values['contains_file']) ? intval($values['contains_file']) : 0;
 
     $saveWork = true;
     $filename = null;
@@ -4045,7 +4045,7 @@ function addDir($formValues, $user_id, $courseInfo, $groupId, $session_id)
     $enableEndDate = isset($formValues['enableEndDate']) ? true : false;
     $enableExpiryDate = isset($formValues['enableExpiryDate']) ? true : false;
 
-    if ($enableEndDate && $enableExpiryDate ) {
+    if ($enableEndDate && $enableExpiryDate) {
         if ($formValues['expires_on'] > $formValues['ends_on']) {
             Display::addFlash(
                 Display::return_message(
@@ -4619,7 +4619,7 @@ function getFormWork($form, $defaults = array(), $workId = 0)
     $htmlHeadXtra[] = '
         <script>
         $(function() {
-            ' . $extra['jquery_ready_content'] . '
+            ' . $extra['jquery_ready_content'].'
         });
         </script>';
 
@@ -4683,8 +4683,8 @@ function updateSettings($courseInfo, $showScore, $studentDeleteOwnPublication)
     $number_of_setting = Database::num_rows($result);
 
     if ($number_of_setting == 1) {
-        $query = "UPDATE " . $table_course_setting . " SET
-                  value='" . Database::escape_string($studentDeleteOwnPublication) . "'
+        $query = "UPDATE ".$table_course_setting." SET
+                  value='" . Database::escape_string($studentDeleteOwnPublication)."'
                   WHERE variable = 'student_delete_own_publication' AND c_id = $courseId";
         Database::query($query);
     } else {
@@ -4723,9 +4723,9 @@ function makeInvisible($item_id, $course_info)
     $work_table = Database::get_course_table(TABLE_STUDENT_PUBLICATION);
     $item_id = intval($item_id);
     $course_id = $course_info['real_id'];
-    $sql = "UPDATE  " . $work_table . "
+    $sql = "UPDATE  ".$work_table."
             SET accepted = 0
-            WHERE c_id = $course_id AND id = '" . $item_id . "'";
+            WHERE c_id = $course_id AND id = '".$item_id."'";
     Database::query($sql);
     api_item_property_update(
         $course_info,
@@ -4877,7 +4877,7 @@ function getWorkUserList($courseCode, $sessionId, $groupId, $start, $limit, $sid
                 $courseCode,
                 $sessionId,
                 $limitString,
-                $orderBy ,
+                $orderBy,
                 STUDENT,
                 $getCount
             );
@@ -5224,8 +5224,8 @@ function exportAllStudentWorkFromPublication(
     if (!empty($sessionId)) {
         $sessionInfo = api_get_session_info($sessionId);
         if (!empty($sessionInfo)) {
-            $header .= ' - ' . $sessionInfo['name'];
-            $header .= '<br />' . $sessionInfo['description'];
+            $header .= ' - '.$sessionInfo['name'];
+            $header .= '<br />'.$sessionInfo['description'];
             $teachers = SessionManager::getCoachesByCourseSessionToString(
                 $sessionId,
                 $courseInfo['real_id']
@@ -5241,12 +5241,12 @@ function exportAllStudentWorkFromPublication(
     $expiresOn = null;
 
     if (!empty($assignment) && isset($assignment['expires_on'])) {
-        $content .= '<br /><strong>' . get_lang('ExpirationDate') . '</strong>: ' . api_get_local_time($assignment['expires_on']);
+        $content .= '<br /><strong>'.get_lang('ExpirationDate').'</strong>: '.api_get_local_time($assignment['expires_on']);
         $expiresOn = api_get_local_time($assignment['expires_on']);
     }
 
     if (!empty($workData['description'])) {
-        $content .= '<br /><strong>' . get_lang('Description') . '</strong>: ' . $workData['description'];
+        $content .= '<br /><strong>'.get_lang('Description').'</strong>: '.$workData['description'];
     }
 
     $workList = get_work_user_list(null, null, null, null, $workId);
@@ -5267,7 +5267,7 @@ function exportAllStudentWorkFromPublication(
                 );
 
                 $column = 0;
-                foreach($headers as $header) {
+                foreach ($headers as $header) {
                     $table->setHeaderContents(0, $column, $header);
                     $column++;
                 }
@@ -5312,7 +5312,7 @@ function exportAllStudentWorkFromPublication(
 
                 if (!empty($content)) {
                     $params = array(
-                        'filename' => $workData['title'] . '_' . api_get_local_time(),
+                        'filename' => $workData['title'].'_'.api_get_local_time(),
                         'pdf_title' => api_replace_dangerous_char($workData['title']),
                         'course_code' => $courseInfo['code'],
                     );
@@ -5342,7 +5342,7 @@ function downloadAllFilesPerUser($userId, $courseInfo)
     $tempZipFile = api_get_path(SYS_ARCHIVE_PATH).api_get_unique_id().".zip";
     $coursePath = api_get_path(SYS_COURSE_PATH).$courseInfo['path'].'/work/';
 
-    $zip  = new PclZip($tempZipFile);
+    $zip = new PclZip($tempZipFile);
 
     $workPerUser = getWorkPerUser($userId);
 

Some files were not shown because too many files changed in this diff