Juan Carlos Raña 15 years ago
parent
commit
3005131f3f

+ 49 - 38
main/course_description/index.php

@@ -36,19 +36,20 @@ include_once api_get_path(LIBRARY_PATH).'WCAG/WCAG_rendering.php';
 
 $interbreadcrumb[] = array ("url" => "index.php", "name" => get_lang('CourseProgram'));
 
+$description_type = isset ($_REQUEST['description_type']) ? Security::remove_XSS($_REQUEST['description_type']) : null;
 $description_id = isset ($_REQUEST['description_id']) ? Security::remove_XSS($_REQUEST['description_id']) : null;
 $action = isset($_GET['action'])?Security::remove_XSS($_GET['action']):'';
 $edit = isset($_POST['edit'])?Security::remove_XSS($_POST['edit']):'';
 $add = isset($_POST['add'])?Security::remove_XSS($_POST['add']):'';
 
-if(intval($description_id) == 1) $interbreadcrumb[] = array ("url" => "#", "name" => get_lang('GeneralDescription'));
-if(intval($description_id) == 2) $interbreadcrumb[] = array ("url" => "#", "name" => get_lang('Objectives'));
-if(intval($description_id) == 3) $interbreadcrumb[] = array ("url" => "#", "name" => get_lang('Topics'));
-if(intval($description_id) == 4) $interbreadcrumb[] = array ("url" => "#", "name" => get_lang('Methodology'));
-if(intval($description_id) == 5) $interbreadcrumb[] = array ("url" => "#", "name" => get_lang('CourseMaterial'));
-if(intval($description_id) == 6) $interbreadcrumb[] = array ("url" => "#", "name" => get_lang('HumanAndTechnicalResources'));
-if(intval($description_id) == 7) $interbreadcrumb[] = array ("url" => "#", "name" => get_lang('Assessment'));
-if(intval($description_id) >= 8) $interbreadcrumb[] = array ("url" => "#", "name" => get_lang('NewBloc'));
+if(intval($description_type) == 1) $interbreadcrumb[] = array ("url" => "#", "name" => get_lang('GeneralDescription'));
+if(intval($description_type) == 2) $interbreadcrumb[] = array ("url" => "#", "name" => get_lang('Objectives'));
+if(intval($description_type) == 3) $interbreadcrumb[] = array ("url" => "#", "name" => get_lang('Topics'));
+if(intval($description_type) == 4) $interbreadcrumb[] = array ("url" => "#", "name" => get_lang('Methodology'));
+if(intval($description_type) == 5) $interbreadcrumb[] = array ("url" => "#", "name" => get_lang('CourseMaterial'));
+if(intval($description_type) == 6) $interbreadcrumb[] = array ("url" => "#", "name" => get_lang('HumanAndTechnicalResources'));
+if(intval($description_type) == 7) $interbreadcrumb[] = array ("url" => "#", "name" => get_lang('Assessment'));
+if(intval($description_type) >= 8) $interbreadcrumb[] = array ("url" => "#", "name" => get_lang('NewBloc'));
 
 api_protect_course_script(true);
 $nameTools = get_lang('CourseProgram');
@@ -129,17 +130,25 @@ $default_description_title_editable[7] = true;
 */
 
 $condition_session = api_get_session_condition($session_id, false);
+$current_session_id = api_get_session_id();
+
+
+$sql = "SELECT description_type,title FROM $tbl_course_description $condition_session ORDER BY description_type ";
 
-$sql = "SELECT id,title FROM $tbl_course_description $condition_session ORDER BY id ";
 $result = Database::query($sql, __FILE__, __LINE__);
 while ($row = Database::fetch_array($result)) {
-  $default_description_titles[$row['id']] = $row['title'];
+  $default_description_titles[$row['description_type']] = $row['title'];
 }
 
-if (api_is_allowed_to_edit(null,true) && !is_null($description_id) || $action =='add') {
+$actions = array('add','delete','edit');
+
+if ((api_is_allowed_to_edit(null,true) && !is_null($description_type)) || in_array($action,$actions)) {
+	
 	$description_id = intval($description_id);
+	$description_type = intval($description_type);
+
 	// Delete a description block
-	if ($action == 'delete') {
+	if ($action == 'delete') {	
 		$sql = "DELETE FROM $tbl_course_description WHERE id='".$description_id."'";
 		Database::query($sql, __FILE__, __LINE__);
 		//update item_property (delete)
@@ -148,31 +157,32 @@ if (api_is_allowed_to_edit(null,true) && !is_null($description_id) || $action ==
 	}
 	// Add or edit a description block
 	else {
-		if (!empty($description_id)) {
-		$sql = "SELECT * FROM $tbl_course_description WHERE id='".$description_id."'";
-		$result = Database::query($sql, __FILE__, __LINE__);
+
+		if (!empty($description_type)) {			
+			$sql = "SELECT * FROM $tbl_course_description WHERE description_type='$description_type' AND session_id='$current_session_id'";		
+			$result = Database::query($sql, __FILE__, __LINE__);					
 			if ($description = Database::fetch_array($result)) {
-				$default_description_titles[$description_id] = $description['title'];
+				$default_description_titles[$description_type] = $description['title'];
 				$description_content = $description['content'];
 
 			} else {
-				$current_title = $default_description_titles[$description_id];
+				$current_title = $default_description_titles[$description_type];
 			}
 
 		} else {
-			$sql = "SELECT MAX(id) as MAX FROM $tbl_course_description $condition_session";
+			$sql = "SELECT MAX(description_type) as MAX FROM $tbl_course_description $condition_session";			
 			$result = Database::query($sql, __FILE__, __LINE__);
 			$max= Database::fetch_array($result);
-			$description_id = $max['MAX']+1;
-			if ($description_id < ADD_BLOCK) {
-					$description_id=8;
-			}
+			$description_type = $max['MAX']+1;
+			if ($description_type < ADD_BLOCK) {
+					$description_type=8;
+			}			
 		}
 		//Se borro: echo ' <style> .row{} <\style> por que hacia conflicto en apartado personalizado con los estilos propios del formvalidator
 		// Build the form
 		$form = new FormValidator('course_description','POST','index.php?'.api_get_cidreq(),'','style="width: 100%;"');
-		$form->addElement('header', '', $default_description_titles[$description_id]);
-		$form->addElement('hidden', 'description_id');
+		$form->addElement('header', '', $default_description_titles[$description_type]);
+		$form->addElement('hidden', 'description_type');
 
 		if ($action == 'edit' || intval($edit) == 1 ) {
 			$form->addElement('hidden', 'edit','1');
@@ -182,7 +192,7 @@ if (api_is_allowed_to_edit(null,true) && !is_null($description_id) || $action ==
 			$form->addElement('hidden', 'add','1');
 		}
 
-		if (($description_id >= ADD_BLOCK) || $default_description_title_editable[$description_id] || $action == 'add' || intval($edit) == 1) {
+		if (($description_type >= ADD_BLOCK) || $default_description_title_editable[$description_type] || $action == 'add' || intval($edit) == 1) {
 			$form->add_textfield('title', get_lang('Title'), true, array('size'=>'width: 350px;'));
 			$form->applyFilter('title','html_filter');
 		}
@@ -194,9 +204,10 @@ if (api_is_allowed_to_edit(null,true) && !is_null($description_id) || $action ==
 		}
 		$form->addElement('style_submit_button', null, get_lang('Save'), 'class="save"');
 		// Set some default values
-		$default['title'] = $default_description_titles[$description_id];
+		$default['title'] = $default_description_titles[$description_type];
 		$default['contentDescription'] = $description_content;
 		$default['description_id'] = $description_id;
+		$default['description_type'] = $description_type;
 		//if ($description_id >= ADD_BLOCK) {
 			//$default['description_id'] = ADD_BLOCK;
 		//}
@@ -210,23 +221,23 @@ if (api_is_allowed_to_edit(null,true) && !is_null($description_id) || $action ==
 				$content = $description['contentDescription'];
 			}
 			$title = $description['title'];
-			if ($description['description_id'] >= ADD_BLOCK) {
+			if ($description['description_type'] >= ADD_BLOCK) {
 				if ($description['add']=='1') { //if this element has been submitted for addition
 					$result = Database::query($sql, __FILE__, __LINE__);
-					$sql = "INSERT IGNORE INTO $tbl_course_description SET id = '".$description_id."', title = '".Database::escape_string(Security::remove_XSS($title,COURSEMANAGERLOWSECURITY))."', content = '".Database::escape_string(Security::remove_XSS($content,COURSEMANAGERLOWSECURITY))."', session_id = ".intval($session_id)." ";
+					$sql = "INSERT IGNORE INTO $tbl_course_description SET description_type='$description_type', title = '".Database::escape_string(Security::remove_XSS($title,COURSEMANAGERLOWSECURITY))."', content = '".Database::escape_string(Security::remove_XSS($content,COURSEMANAGERLOWSECURITY))."', session_id = '$current_session_id' ";
 					Database::query($sql, __FILE__, __LINE__);
 				} else {
-					$sql = "UPDATE $tbl_course_description SET  title = '".Database::escape_string(Security::remove_XSS($title,COURSEMANAGERLOWSECURITY))."', content = '".Database::escape_string(Security::remove_XSS($content,COURSEMANAGERLOWSECURITY))."' WHERE id = '".$description_id."' ";
+					$sql = "UPDATE $tbl_course_description SET  title = '".Database::escape_string(Security::remove_XSS($title,COURSEMANAGERLOWSECURITY))."', content = '".Database::escape_string(Security::remove_XSS($content,COURSEMANAGERLOWSECURITY))."' WHERE description_type='$description_type' AND session_id = '$current_session_id'";
 					Database::query($sql, __FILE__, __LINE__);
 				}
 			} else {
 				//if title is not editable, then use default title
-				if (!$default_description_title_editable[$description_id]) {
-					$title = $default_description_titles[$description_id];
+				if (!$default_description_title_editable[$description_type]) {
+					$title = $default_description_titles[$description_type];
 				}
-				$sql = "DELETE FROM $tbl_course_description WHERE id = '".$description_id."'";
+				$sql = "DELETE FROM $tbl_course_description WHERE description_type = '".$description_type."' AND session_id = '$current_session_id'";
 				Database::query($sql, __FILE__, __LINE__);
-				$sql = "INSERT INTO $tbl_course_description SET id = '".$description_id."', title = '".Database::escape_string(Security::remove_XSS($title,COURSEMANAGERLOWSECURITY))."', content = '".Database::escape_string(Security::remove_XSS($content,COURSEMANAGERLOWSECURITY))."', session_id = ".intval($session_id)." ";
+				$sql = "INSERT INTO $tbl_course_description SET description_type = '".$description_type."', title = '".Database::escape_string(Security::remove_XSS($title,COURSEMANAGERLOWSECURITY))."', content = '".Database::escape_string(Security::remove_XSS($content,COURSEMANAGERLOWSECURITY))."', session_id = '$current_session_id' ";
 				Database::query($sql, __FILE__, __LINE__);
 			}
 			$id = Database::insert_id();
@@ -256,7 +267,7 @@ if (api_is_allowed_to_edit(null,true) && !is_null($description_id) || $action ==
 						echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&action=add">'.Display::return_icon($default_description_icon[$id], $title, array('height'=>'22')).' '.$title.'</a>';
 						break;
 					} else {
-						echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&description_id='.$id.'">'.Display::return_icon($default_description_icon[$id], $title, array('height'=>'22')).' '.$title.'</a>&nbsp;&nbsp;';
+						echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&description_type='.$id.'">'.Display::return_icon($default_description_icon[$id], $title, array('height'=>'22')).' '.$title.'</a>&nbsp;&nbsp;';
 						$i++;
 					}
 				}
@@ -288,9 +299,9 @@ if ($show_description_list) {
 	$result = Database::query($sql, __FILE__, __LINE__);
 	$descriptions = array();
 	while ($description = Database::fetch_object($result)) {
-		$descriptions[$description->id] = $description;
+		$descriptions[$description->description_type] = $description;
 		//reload titles to ensure we have the last version (after edition)
-		$default_description_titles[$description->id] = $description->title;
+		$default_description_titles[$description->description_type] = $description->title;
 	}
 	if (api_is_allowed_to_edit(null,true)) {
 		$categories = array ();
@@ -308,7 +319,7 @@ if ($show_description_list) {
 				echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&action=add">'.Display::return_icon($default_description_icon[$id], $title, array('height'=>'22')).' '.$title.'</a>';
 				break;
 			} else {
-				echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&description_id='.$id.'">'.Display::return_icon($default_description_icon[$id], $title, array('height'=>'22')).' '.$title.'</a>&nbsp;&nbsp;';
+				echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&description_type='.$id.'">'.Display::return_icon($default_description_icon[$id], $title, array('height'=>'22')).' '.$title.'</a>&nbsp;&nbsp;';
 				$i++;
 			}
 		}
@@ -324,7 +335,7 @@ if ($show_description_list) {
 				echo '</a> ';
 
 				//edit
-				echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&amp;description_id='.$description->id.'">';
+				echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&amp;action=edit&amp;description_id='.$description->id.'&amp;description_type='.$description->description_type.'">';
 				echo Display::return_icon('edit.gif', get_lang('Edit'), array('style' => 'vertical-align:middle;float:right; padding-right:4px;'));
 				echo '</a> ';
 			}

+ 1 - 0
main/inc/lib/add_course.lib.inc.php

@@ -691,6 +691,7 @@ function update_Db_course($courseDbName)
 		title VARCHAR(255),
 		content TEXT,
 		session_id smallint default 0,
+		description_type tinyint unsigned NOT NULL default 0,		
 		UNIQUE (id)
 		)";
 	Database::query($sql, __FILE__, __LINE__);

+ 2 - 1
main/install/migrate-db-1.8.6.1-1.8.6.2-pre.sql

@@ -59,4 +59,5 @@ ALTER TABLE item_property DROP INDEX idx_item_property_toolref, ADD INDEX idx_it
 ALTER TABLE quiz ADD COLUMN expired_time int NOT NULL DEFAULT '0' AFTER feedback_type;
 ALTER TABLE group_info ADD COLUMN chat_state TINYINT DEFAULT 1, ADD INDEX (chat_state);
 ALTER TABLE group_category ADD COLUMN chat_state TINYINT DEFAULT 1, ADD INDEX (chat_state);
-ALTER TABLE student_publication ADD COLUMN weight float(6,2) UNSIGNED NOT NULL DEFAULT 0;
+ALTER TABLE student_publication ADD COLUMN weight float(6,2) UNSIGNED NOT NULL DEFAULT 0;
+ALTER TABLE course_description ADD COLUMN description_type TINYINT NOT NULL DEFAULT 0;

+ 26 - 0
main/install/update-db-1.8.6.1-1.8.6.2.inc.php

@@ -407,6 +407,32 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 							}
 						}
 					}					
+					
+					// fill description type into course_description table
+					
+					$t_course_description = $row_course['db_name'].".course_description";
+
+                    if($singleDbForm)
+                    {                    	
+                        $t_course_description = "$prefix{$row_course['db_name']}_course_description";
+                    }
+
+					// get all ids and update description_type field with them from course_description table
+					$sql_sel = "SELECT id FROM $t_course_description";
+					$rs_sel = mysql_query($sql_sel);
+					
+					if ($rs_sel === false) {
+				    	error_log('Could not query course_description ids table: '.mysql_error());
+					} else { 											
+						if (mysql_num_rows($rs_sel) > 0) {													
+							while ($row_ids = mysql_fetch_array($rs_sel)) {
+								$description_id = $row_ids['id']; 								
+								$sql_upd = "UPDATE $t_course_description SET description_type='$description_id' WHERE id='$description_id'";
+								mysql_query($sql_upd);
+							}							
+						}						
+					}
+										
    				}
 			}
 		}

+ 2 - 0
main/lang/english/admin.inc.php

@@ -1091,4 +1091,6 @@ $IsNotAdministrator = "Is not administrator";
 $AddTimeLimit = "Add time limit";
 $EditTimeLimit = "Edit time limit";
 $TheTimeLimitsAreReferential = "The time limit of a category is referential, will not affect the boundaries of a training session";
+$ShowGlossaryInExtraToolsTitle = "Show the glossary terms in extra tools";
+$ShowGlossaryInExtraToolsComment = "From here you can configure how to add the glossary terms in extra tools as learning path and exercice tool";
 ?>

+ 2 - 0
main/lang/spanish/admin.inc.php

@@ -1091,4 +1091,6 @@ $IsNotAdministrator = "No es administrador";
 $AddTimeLimit = "Añadir límite de tiempo";
 $EditTimeLimit = "Editar límite de tiempo";
 $TheTimeLimitsAreReferential = "El plazo de una categoría es referencial, no afectará a los límites de una sesión de formación";
+$ShowGlossaryInExtraToolsTitle = "Muestra los términos del glosario en las herramientas lecciones(scorm) y ejercicios";
+$ShowGlossaryInExtraToolsComment = "Desde aquí usted puede configurar como añadir  los términos del glosario en herramientas como lecciones(scorm) y ejercicios";
 ?>

+ 0 - 2
main/work/work.php

@@ -402,7 +402,6 @@ if (!empty ($_POST['changeProperties'])) {
 	$query = "SELECT * FROM " . $table_course_setting . " WHERE variable = 'student_delete_own_publication'";
 	$result = Database::query($query, __FILE__, __LINE__);
 	$number_of_setting = Database::num_rows($result);
-	echo $number_of_setting;
 	
 	if ($number_of_setting == 1){
 		$query = "UPDATE " . $table_course_setting . " SET value='" . Database::escape_string($_POST['student_delete_own_publication']) . "' WHERE variable='student_delete_own_publication'";
@@ -411,7 +410,6 @@ if (!empty ($_POST['changeProperties'])) {
 		$query = "INSERT INTO " . $table_course_setting . " (variable, value, category) VALUES ('student_delete_own_publication','" . Database::escape_string($_POST['student_delete_own_publication']) . "','work')";
 		Database::query($query, __FILE__, __LINE__);			
 	}
-	echo $query;
 
 	$_course['show_score'] = $uploadvisibledisabled;
 } else {

+ 22 - 22
whoisonline.php

@@ -231,36 +231,36 @@ function display_individual_user($user_id) {
 			$big_image_height = $big_image_size[1];
 			$url_big_image = $big_image.'?rnd='.time();
 			echo '<input type="image" src="'.$fullurl.'" alt="'.$alt.'" onclick="javascript: return show_image(\''.$url_big_image.'\',\''.$big_image_width.'\',\''.$big_image_height.'\');"/><br />';
-			global $user_anonymous;
-			if (api_get_setting('allow_social_tool') == 'true' && api_get_user_id() <> $user_anonymous && api_get_user_id() <> 0) {
-				echo '<br />';
-				echo '<a href="'.api_get_path(WEB_CODE_PATH).'social/profile.php?u='.$safe_user_id.'">'.get_lang('ViewSharedProfile').'</a>';
-				echo '<br />';
-								
-				$user_anonymous = api_get_anonymous_id();
-				
-				if ($safe_user_id != api_get_user_id() && !api_is_anonymous($safe_user_id)) {
-					$user_relation = UserFriend::get_relation_between_contacts(api_get_user_id(), $safe_user_id);
-					if ($user_relation == 0 || $user_relation == 6) {
-						echo  '<a href="main/messages/send_message_to_userfriend.inc.php?view_panel=2&height=300&width=610&user_friend='.$safe_user_id.'" class="thickbox" title="'.get_lang('SendInvitation').'">'.Display :: return_icon('add_multiple_users.gif', get_lang('SocialInvitationToFriends')).'&nbsp;'.get_lang('SendInvitation').'</a><br />
-								<a href="main/messages/send_message_to_userfriend.inc.php?view_panel=1&height=310&width=610&user_friend='.$safe_user_id.'" class="thickbox" title="'.get_lang('SendAMessage').'">'.Display :: return_icon('mail_send.png', get_lang('SendAMessage')).'&nbsp;'.get_lang('SendAMessage').'</a>';
-					} else {
-						echo  '<a href="main/messages/send_message_to_userfriend.inc.php?view_panel=1&height=310&width=610&user_friend='.$safe_user_id.'" class="thickbox" title="'.get_lang('SendAMessage').'">'.Display :: return_icon('mail_send.png', get_lang('SendAMessage')).'&nbsp;'.get_lang('SendAMessage').'</a>';
-					}
-				}	
-					
-				
-				
-			}
 		} else {
 			echo Display::return_icon('unknown.jpg', get_lang('Unknown'));
 			echo '<br />';
 		}
+		
+		echo '<br />'.$status.'<br />';
+		
+		global $user_anonymous;
+		if (api_get_setting('allow_social_tool') == 'true' && api_get_user_id() <> $user_anonymous && api_get_user_id() <> 0) {
+			echo '<br />';
+			echo '<a href="'.api_get_path(WEB_CODE_PATH).'social/profile.php?u='.$safe_user_id.'">'.get_lang('ViewSharedProfile').'</a>';
+			echo '<br />';
+							
+			$user_anonymous = api_get_anonymous_id();
+			
+			if ($safe_user_id != api_get_user_id() && !api_is_anonymous($safe_user_id)) {
+				$user_relation = UserFriend::get_relation_between_contacts(api_get_user_id(), $safe_user_id);
+				if ($user_relation == 0 || $user_relation == 6) {
+					echo  '<a href="main/messages/send_message_to_userfriend.inc.php?view_panel=2&height=300&width=610&user_friend='.$safe_user_id.'" class="thickbox" title="'.get_lang('SendInvitation').'">'.Display :: return_icon('add_multiple_users.gif', get_lang('SocialInvitationToFriends')).'&nbsp;'.get_lang('SendInvitation').'</a><br />
+						   <a href="main/messages/send_message_to_userfriend.inc.php?view_panel=1&height=310&width=610&user_friend='.$safe_user_id.'" class="thickbox" title="'.get_lang('SendAMessage').'">'.Display :: return_icon('mail_send.png', get_lang('SendAMessage')).'&nbsp;'.get_lang('SendAMessage').'</a>';
+				} else {
+					echo  '<a href="main/messages/send_message_to_userfriend.inc.php?view_panel=1&height=310&width=610&user_friend='.$safe_user_id.'" class="thickbox" title="'.get_lang('SendAMessage').'">'.Display :: return_icon('mail_send.png', get_lang('SendAMessage')).'&nbsp;'.get_lang('SendAMessage').'</a>';
+				}
+			}
+		}
 
 		if (api_get_setting('show_email_addresses') == 'true') {
 			echo Display::encrypted_mailto_link($user_object->email,$user_object->email).'<br />';
 		}
-		echo $status.'<br />';
+		
 		echo '</div>';
 		if ($user_object->competences) {
 			echo '<dt><div class="actions-message"><strong>'.get_lang('MyCompetences').'</strong></div></dt>';