Julio Montoya 15 роки тому
батько
коміт
74392e1803
88 змінених файлів з 1694 додано та 2129 видалено
  1. 37 86
      main/course_info/infocours.php
  2. 10 41
      main/course_info/maintenance.php
  3. 3 32
      main/coursecopy/backup.php
  4. 2 9
      main/coursecopy/copy_course.php
  5. 2 5
      main/coursecopy/copy_course_session.php
  6. 10 38
      main/coursecopy/create_backup.php
  7. 6 41
      main/coursecopy/import_backup.php
  8. 8 36
      main/coursecopy/recycle_course.php
  9. 68 21
      main/document/create_document.php
  10. 50 8
      main/document/document.inc.php
  11. 92 21
      main/document/document.php
  12. 36 7
      main/document/edit_document.php
  13. 29 11
      main/document/upload.php
  14. 50 79
      main/exercice/answer.class.php
  15. 2 2
      main/exercice/exercice.php
  16. 16 10
      main/exercice/exercise.class.php
  17. 42 36
      main/exercice/question.class.php
  18. 57 22
      main/exercice/question_pool.php
  19. 2 2
      main/glossary/index.php
  20. 2 24
      main/gradebook/exercise_jump.php
  21. 40 20
      main/gradebook/gradebook.php
  22. 2 5
      main/gradebook/gradebook_add_cat.php
  23. 5 27
      main/gradebook/gradebook_add_eval.php
  24. 6 33
      main/gradebook/gradebook_add_link.php
  25. 2 24
      main/gradebook/gradebook_add_link_select_course.php
  26. 2 27
      main/gradebook/gradebook_add_result.php
  27. 12 12
      main/gradebook/gradebook_add_user.php
  28. 86 0
      main/gradebook/gradebook_display_certificate.php
  29. 20 48
      main/gradebook/gradebook_edit_all.php
  30. 3 25
      main/gradebook/gradebook_edit_cat.php
  31. 2 24
      main/gradebook/gradebook_edit_eval.php
  32. 4 27
      main/gradebook/gradebook_edit_link.php
  33. 1 23
      main/gradebook/gradebook_edit_result.php
  34. 1 1
      main/gradebook/gradebook_flatview.php
  35. 1 17
      main/gradebook/gradebook_result.class.php
  36. 1 23
      main/gradebook/gradebook_scoring_system.php
  37. 1 23
      main/gradebook/gradebook_showlog_eval.php
  38. 9 39
      main/gradebook/gradebook_showlog_link.php
  39. 1 23
      main/gradebook/gradebook_statistics.php
  40. 1 23
      main/gradebook/gradebook_view_result.php
  41. 96 41
      main/gradebook/index.php
  42. 1 23
      main/gradebook/lib/be.inc.php
  43. 38 55
      main/gradebook/lib/be/abstractlink.class.php
  44. 10 10
      main/gradebook/lib/be/attendancelink.class.php
  45. 11 29
      main/gradebook/lib/be/category.class.php
  46. 3 25
      main/gradebook/lib/be/dropboxlink.class.php
  47. 2 24
      main/gradebook/lib/be/evallink.class.php
  48. 28 32
      main/gradebook/lib/be/evaluation.class.php
  49. 2 24
      main/gradebook/lib/be/exerciselink.class.php
  50. 2 24
      main/gradebook/lib/be/forumthreadlink.class.php
  51. 2 23
      main/gradebook/lib/be/gradebookitem.class.php
  52. 2 24
      main/gradebook/lib/be/learnpathlink.class.php
  53. 3 24
      main/gradebook/lib/be/linkfactory.class.php
  54. 2 24
      main/gradebook/lib/be/result.class.php
  55. 2 24
      main/gradebook/lib/be/studentpublicationlink.class.php
  56. 1 23
      main/gradebook/lib/fe/catform.class.php
  57. 2 24
      main/gradebook/lib/fe/dataform.class.php
  58. 8 27
      main/gradebook/lib/fe/displaygradebook.php
  59. 1 23
      main/gradebook/lib/fe/evalform.class.php
  60. 1 23
      main/gradebook/lib/fe/exportgradebook.php
  61. 1 23
      main/gradebook/lib/fe/flatviewtable.class.php
  62. 144 43
      main/gradebook/lib/fe/gradebooktable.class.php
  63. 1 23
      main/gradebook/lib/fe/linkaddeditform.class.php
  64. 1 23
      main/gradebook/lib/fe/linkform.class.php
  65. 1 23
      main/gradebook/lib/fe/resulttable.class.php
  66. 1 23
      main/gradebook/lib/fe/scoredisplayform.class.php
  67. 1 23
      main/gradebook/lib/fe/userform.class.php
  68. 1 23
      main/gradebook/lib/fe/usertable.class.php
  69. 1 23
      main/gradebook/lib/flatview_data_generator.class.php
  70. 2 24
      main/gradebook/lib/gradebook_data_generator.class.php
  71. 132 20
      main/gradebook/lib/gradebook_functions.inc.php
  72. 1 23
      main/gradebook/lib/gradebook_functions_users.inc.php
  73. 1 23
      main/gradebook/lib/results_data_generator.class.php
  74. 1 24
      main/gradebook/lib/scoredisplay.class.php
  75. 1 1
      main/gradebook/lib/user_data_generator.class.php
  76. 1 23
      main/gradebook/open_document.php
  77. 2 24
      main/gradebook/user_info.php
  78. 1 23
      main/gradebook/user_stats.php
  79. 14 16
      main/group/group.php
  80. BIN
      main/img/certificate.png
  81. BIN
      main/img/nocertificate.png
  82. 73 82
      main/inc/lib/database.lib.php
  83. 202 0
      main/inc/lib/document.lib.php
  84. 109 11
      main/inc/lib/usermanager.lib.php
  85. 33 46
      main/user/subscribe_user.php
  86. 13 20
      main/user/user.php
  87. 10 28
      main/user/userInfo.php
  88. 5 13
      main/user/user_add.php

+ 37 - 86
main/course_info/infocours.php

@@ -1,32 +1,6 @@
-<?php // $Id: infocours.php 21873 2009-07-08 08:35:57Z herodoto $
-
-/*
-==============================================================================
-	Dokeos - elearning and course management software
-
-	Copyright (c) 2004-2009 Dokeos SPRL
-	Copyright (c) 2003 Ghent University (UGent)
-	Copyright (c) 2001 Universite catholique de Louvain (UCL)
-	Copyright (c) Hugues Peeters
-	Copyright (c) Roan Embrechts (Vrije Universiteit Brussel)
-	Copyright (c) Olivier Brouckaert
-	Copyright (c) Bart Mollet, Hogeschool Gent
-
-	For a full list of contributors, see "credits.txt".
-	The full license can be read in "license.txt".
-
-	This program is free software; you can redistribute it and/or
-	modify it under the terms of the GNU General Public License
-	as published by the Free Software Foundation; either version 2
-	of the License, or (at your option) any later version.
-
-	See the GNU General Public License for more details.
-
-	Contact: Dokeos, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com
-==============================================================================
-*/
+<?php
+/* For licensing terms, see /license.txt */
 /**
-==============================================================================
 *	Code to display the course settings form (for the course admin)
 *	and activate the changes.
 *
@@ -36,35 +10,22 @@
 * @author Patrick Cool <patrick.cool@UGent.be>
 * @author Roan Embrechts, refactoring
 * and improved course visibility|subscribe|unsubscribe options
-* @package dokeos.course_info
-==============================================================================
-*/
-/*
-==============================================================================
-	   INIT SECTION
-==============================================================================
+* @package chamilo.course_info
 */
+/*	   INIT SECTION 	*/
 // name of the language file that needs to be included
 $language_file = array ('create_course', 'course_info');
-include ('../inc/global.inc.php');
+require_once '../inc/global.inc.php';
 $this_section = SECTION_COURSES;
 
 $nameTools = get_lang("ModifInfo");
 
-/*
------------------------------------------------------------
-	Libraries
------------------------------------------------------------
-*/
-require_once (api_get_path(LIBRARY_PATH).'course.lib.php');
-require_once (api_get_path(INCLUDE_PATH)."conf/course_info.conf.php");
-require_once (api_get_path(INCLUDE_PATH)."lib/debug.lib.inc.php");
-require_once (api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php');
-/*
------------------------------------------------------------
-	Constants and variables
------------------------------------------------------------
-*/
+/*	Libraries	*/
+require_once api_get_path(LIBRARY_PATH).'course.lib.php';
+require_once api_get_path(INCLUDE_PATH)."conf/course_info.conf.php";
+require_once api_get_path(INCLUDE_PATH)."lib/debug.lib.inc.php";
+require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php';
+/*	Constants and variables	*/
 define("MODULE_HELP_NAME", "Settings");
 define("COURSE_CHANGE_PROPERTIES", "COURSE_CHANGE_PROPERTIES");
 $TABLECOURSE 				= Database :: get_main_table(TABLE_MAIN_COURSE);
@@ -76,11 +37,8 @@ $currentCourseID 			= $_course['sysCode'];
 $currentCourseRepository 	= $_course["path"];
 $is_allowedToEdit 			= $is_courseAdmin || $is_platformAdmin;
 $course_setting_table 		= Database::get_course_table(TABLE_COURSE_SETTING);
-/*
-==============================================================================
-		LOGIC FUNCTIONS
-==============================================================================
-*/
+
+/*		LOGIC FUNCTIONS		*/
 function is_settings_editable()
 {
 	return $GLOBALS["course_info_is_editable"];
@@ -89,9 +47,7 @@ $course_code = $_course["sysCode"];
 $course_access_settings = CourseManager :: get_access_settings($course_code);
 
 /*
-==============================================================================
 		MAIN CODE
-==============================================================================
 */
 
 if (!$is_allowedToEdit)
@@ -254,8 +210,7 @@ $form->addElement('radio', 'allow_open_chat_window', null, get_lang('AllowOpenCh
 $form->addElement('style_submit_button', null, get_lang('SaveSettings'), 'class="save"');
 
 // COURSE THEME PICKER
-if (api_get_setting('allow_course_theme') == 'true')
-{
+if (api_get_setting('allow_course_theme') == 'true') {
 	$form->addElement('html','<div class="sectiontitle" style="margin-top: 40px;"><a href="#header" style="float:right;">'.Display::return_icon('top.gif',get_lang('Top')).'</a><a name="theme" id="theme"></a>'.Display::return_icon('theme.gif',get_lang('Theming')).' '.get_lang('Theming').'</div><div style="clear:both;"></div>');
 
 	//Allow Learning path
@@ -268,17 +223,14 @@ if (api_get_setting('allow_course_theme') == 'true')
 	$form -> addElement('html',$linebreak);
 }
 
-if (is_settings_editable())
-	{
+if (is_settings_editable()) {
 	$form->addElement('style_submit_button', null, get_lang('SaveSettings'), 'class="save"');
-	}
-else
-{
+} else {
 	// is it allowed to edit the course settings?
 	if (!is_settings_editable())
 		$disabled_output = "disabled";
 	$form->freeze();
-	}
+}
 
 // get all the course information
 $all_course_information =  CourseManager::get_course_information($_course['sysCode']);
@@ -328,18 +280,19 @@ if ($form->validate() && is_settings_editable()) {
 		$update_values[$index] = Database::escape_string($value);
 	}
 	$table_course = Database :: get_main_table(TABLE_MAIN_COURSE);
-	$sql = "UPDATE $table_course SET title 			= '".Security::remove_XSS($update_values['title'])."',
-										 visual_code 	= '".$update_values['visual_code']."',
-										 course_language = '".$update_values['course_language']."',
-										 category_code  = '".$update_values['category_code']."',
-										 department_name  = '".Security::remove_XSS($update_values['department_name'])."',
-										 department_url  = '".Security::remove_XSS($update_values['department_url'])."',
-										 visibility  = '".$update_values['visibility']."',
-										 subscribe  = '".$update_values['subscribe']."',
-										 unsubscribe  = '".$update_values['unsubscribe']."',
-										 tutor_name     = '".$update_values['tutor_name']."',
-										 registration_code = '".$update_values['course_registration_password']."'
-									WHERE code = '".$course_code."'";
+	$sql = "UPDATE $table_course SET
+				title 				= '".Security::remove_XSS($update_values['title'])."',
+				visual_code 		= '".$update_values['visual_code']."',
+				course_language 	= '".$update_values['course_language']."',
+				category_code 		= '".$update_values['category_code']."',
+				department_name  	= '".Security::remove_XSS($update_values['department_name'])."',
+				department_url  	= '".Security::remove_XSS($update_values['department_url'])."',
+				visibility  		= '".$update_values['visibility']."',
+				subscribe  			= '".$update_values['subscribe']."',
+				unsubscribe  		= '".$update_values['unsubscribe']."',
+				tutor_name     		= '".$update_values['tutor_name']."',
+				registration_code 	= '".$update_values['course_registration_password']."'
+			WHERE code = '".$course_code."'";
 	Database::query($sql);
 
 	//update course_settings table - this assumes those records exist, otherwise triggers an error
@@ -425,8 +378,11 @@ echo '</div>';
 
 // Display the form
 $form->display();
-	if ($showDiskQuota && $currentCourseDiskQuota != "")
-	{
+
+//@todo this code is out dated should 
+
+	if ($showDiskQuota && $currentCourseDiskQuota != "") {
+		
 ?>
 <table>
 	<tr>
@@ -511,11 +467,6 @@ $form->display();
 
 	}
 
-/*
-==============================================================================
-		FOOTER
-==============================================================================
-*/
+/*		FOOTER	*/
 Display::display_footer();
-?>
-
+?>

+ 10 - 41
main/course_info/maintenance.php

@@ -1,31 +1,5 @@
 <?php // $Id: infocours.php 14956 2008-04-20 14:21:32Z yannoo $
-
-/*
-==============================================================================
-	Dokeos - elearning and course management software
-
-	Copyright (c) 2004 Dokeos S.A.
-	Copyright (c) 2003 Ghent University (UGent)
-	Copyright (c) 2001 Universite catholique de Louvain (UCL)
-	Copyright (c) Hugues Peeters
-	Copyright (c) Roan Embrechts (Vrije Universiteit Brussel)
-	Copyright (c) Olivier Brouckaert
-	Copyright (c) Bart Mollet, Hogeschool Gent
-
-	For a full list of contributors, see "credits.txt".
-	The full license can be read in "license.txt".
-
-	This program is free software; you can redistribute it and/or
-	modify it under the terms of the GNU General Public License
-	as published by the Free Software Foundation; either version 2
-	of the License, or (at your option) any later version.
-
-	See the GNU General Public License for more details.
-
-	Contact: Dokeos, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com
-==============================================================================
-*/
-
+/* For licensing terms, see /license.txt */
 
 /*
  * Created on 18 October 2006 by Elixir Interactive http://www.elixir-interactive.com
@@ -33,30 +7,25 @@
 // name of the language file that needs to be included
 $language_file = array ('admin','create_course', 'course_info', 'coursebackup');
 
-require ('../inc/global.inc.php');
-
+require_once '../inc/global.inc.php';
 $this_section = SECTION_COURSES;
-
 $nameTools= get_lang('Maintenance');
-
 api_block_anonymous_users();
-
 Display :: display_header($nameTools);
-
 api_display_tool_title($nameTools);
 
 ?>
 
 <div class="sectiontitle"><?php Display::display_icon('save_import.gif', get_lang("backup")); ?>&nbsp;&nbsp;<a href="../coursecopy/backup.php?<?php echo api_get_cidreq();?>"><?php echo get_lang("backup");?></a></div>
 <div class="sectioncomment">
-			<ul>
-			    <li><a href="../coursecopy/create_backup.php?<?php echo api_get_cidreq();?>"><?php echo get_lang('CreateBackup')  ?></a><br/>
-			    <?php echo get_lang('CreateBackupInfo') ?>
-			    </li>
-			    <li><a href="../coursecopy/import_backup.php?<?php echo api_get_cidreq();?>"><?php echo get_lang('ImportBackup')  ?></a><br/>
-			    <?php echo get_lang('ImportBackupInfo') ?>
-			    </li>
-		    </ul>
+		<ul>
+		    <li><a href="../coursecopy/create_backup.php?<?php echo api_get_cidreq();?>"><?php echo get_lang('CreateBackup')  ?></a><br/>
+		    <?php echo get_lang('CreateBackupInfo') ?>
+		    </li>
+		    <li><a href="../coursecopy/import_backup.php?<?php echo api_get_cidreq();?>"><?php echo get_lang('ImportBackup')  ?></a><br/>
+		    <?php echo get_lang('ImportBackupInfo') ?>
+		    </li>
+	    </ul>
 </div>
 
 <div class="sectiontitle"><?php Display::display_icon('copy.gif', get_lang("CopyCourse")); ?>&nbsp;&nbsp;<a href="../coursecopy/copy_course.php?<?php echo api_get_cidreq();?>"><?php echo get_lang("CopyCourse");?></a></div>

+ 3 - 32
main/coursecopy/backup.php

@@ -1,35 +1,10 @@
 <?php
-// $Id: backup.php 12219 2007-05-01 18:46:59Z yannoo $
-/*
-==============================================================================
-	Dokeos - elearning and course management software
-
-	Copyright (c) 2004 Dokeos S.A.
-	Copyright (c) 2003 Ghent University (UGent)
-	Copyright (c) 2001 Universite catholique de Louvain (UCL)
-	Copyright (c) Bart Mollet (bart.mollet@hogent.be)
-
-	For a full list of contributors, see "credits.txt".
-	The full license can be read in "license.txt".
-
-	This program is free software; you can redistribute it and/or
-	modify it under the terms of the GNU General Public License
-	as published by the Free Software Foundation; either version 2
-	of the License, or (at your option) any later version.
-
-	See the GNU General Public License for more details.
-
-	Contact address: Dokeos, 44 rue des palais, B-1030 Brussels, Belgium
-	Mail: info@dokeos.com
-==============================================================================
-*/
+/* For licensing terms, see /license.txt */
 /**
- * ==============================================================================
  * Create a backup.
  *
  * @author Bart Mollet <bart.mollet@hogent.be>
- * @package dokeos.backup
- * ==============================================================================
+ * @package chamilo.backup
  */
 
 // name of the language file that needs to be included
@@ -56,11 +31,7 @@ Display::display_header($nameTools);
 // Display the tool title
 api_display_tool_title($nameTools);
 
-/*
-==============================================================================
-		MAIN CODE
-==============================================================================
-*/
+/*		MAIN CODE	*/
 ?>
 
   <ul>

+ 2 - 9
main/coursecopy/copy_course.php

@@ -1,5 +1,4 @@
 <?php // $Id: copy_course.php 22204 2009-07-17 20:31:35Z iflorespaz $
-
 /* For licensing terms, see /dokeos_license.txt */
 
 // name of the language file that needs to be included
@@ -9,7 +8,7 @@ $language_file = array('exercice', 'coursebackup', 'admin');
 require_once '../inc/global.inc.php';
 
 // including additional libraries
-include_once api_get_path(LIBRARY_PATH) . 'fileManage.lib.php';
+require_once api_get_path(LIBRARY_PATH) . 'fileManage.lib.php';
 require_once 'classes/CourseBuilder.class.php';
 require_once 'classes/CourseRestorer.class.php';
 require_once 'classes/CourseSelectForm.class.php';
@@ -37,9 +36,7 @@ $this_section=SECTION_COURSES;
 Display::display_header(get_lang('CopyCourse'));
 //api_display_tool_title($nameTools);
 /*
-==============================================================================
 		MAIN CODE
-==============================================================================
 */
 // If a CourseSelectForm is posted or we should copy all resources, then copy them
 if ((isset ($_POST['action']) && $_POST['action'] == 'course_select_form') || (isset ($_POST['copy_option']) && $_POST['copy_option'] == 'full_copy')) {
@@ -117,10 +114,6 @@ if ((isset ($_POST['action']) && $_POST['action'] == 'course_select_form') || (i
 	}
 
 }
-/*
-==============================================================================
-		FOOTER
-==============================================================================
-*/
+/*		FOOTER	*/
 Display::display_footer();
 ?>

+ 2 - 5
main/coursecopy/copy_course_session.php

@@ -1,13 +1,10 @@
 <?php
-/* For licensing terms, see /dokeos_license.txt */
-
+/* For licensing terms, see /license.txt */
 /**
- * ==============================================================================
  * Copy resources from one course in a session to another one.
  *
  * @author Christian Fasanando <christian.fasanando@dokeos.com>
- * @package dokeos.backup
- * ==============================================================================
+ * @package chamilo.backup
  */
 
 /*  INIT SECTION  */

+ 10 - 38
main/coursecopy/create_backup.php

@@ -1,42 +1,18 @@
 <?php
 // $Id: create_backup.php 20084 2009-04-24 20:10:43Z aportugal $
-/*
-==============================================================================
-	Dokeos - elearning and course management software
-
-	Copyright (c) 2004 Dokeos SPRL
-	Copyright (c) 2003 Ghent University (UGent)
-	Copyright (c) 2001 Universite catholique de Louvain (UCL)
-	Copyright (c) Bart Mollet (bart.mollet@hogent.be)
-
-	For a full list of contributors, see "credits.txt".
-	The full license can be read in "license.txt".
-
-	This program is free software; you can redistribute it and/or
-	modify it under the terms of the GNU General Public License
-	as published by the Free Software Foundation; either version 2
-	of the License, or (at your option) any later version.
-
-	See the GNU General Public License for more details.
-
-	Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
-	Mail: info@dokeos.com
-==============================================================================
-*/
+/* For licensing terms, see /license.txt */
 /**
- * ==============================================================================
  * Create a backup.
  *
  * @author Bart Mollet <bart.mollet@hogent.be>
- * @package dokeos.backup
- * ==============================================================================
+ * @package chamilo.backup
  */
 
 // name of the language file that needs to be included
 $language_file = array ('exercice', 'admin', 'coursebackup');
 
 // including the global file
-include ('../inc/global.inc.php');
+require_once ('../inc/global.inc.php');
 
 // Check access rights (only teachers are allowed here)
 if (!api_is_allowed_to_edit())
@@ -62,11 +38,11 @@ $nameTools = get_lang('CreateBackup');
 Display::display_header($nameTools);
 
 // include additional libraries
-include_once(api_get_path(LIBRARY_PATH) . 'fileManage.lib.php');
-require_once ('classes/CourseBuilder.class.php');
-require_once ('classes/CourseArchiver.class.php');
-require_once ('classes/CourseRestorer.class.php');
-require_once ('classes/CourseSelectForm.class.php');
+require_once api_get_path(LIBRARY_PATH) . 'fileManage.lib.php';
+require_once 'classes/CourseBuilder.class.php';
+require_once 'classes/CourseArchiver.class.php';
+require_once 'classes/CourseRestorer.class.php';
+require_once 'classes/CourseSelectForm.class.php';
 
 // Display the tool title
 api_display_tool_title($nameTools);
@@ -121,7 +97,7 @@ else
 	{
 		echo get_lang('SelectOptionForBackup');
 
-		include_once (api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php');
+		require_once (api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php');
 		$form = new FormValidator('create_backup_form','POST');
 		$renderer = $form->defaultRenderer();
 		$renderer->setElementTemplate('<div>{element}</div> ');
@@ -138,10 +114,6 @@ else
 		$form->display();
 	}
 }
-/*
-==============================================================================
-		FOOTER
-==============================================================================
-*/
+/*		FOOTER		*/
 Display::display_footer();
 ?>

+ 6 - 41
main/coursecopy/import_backup.php

@@ -1,40 +1,13 @@
 <?php // $Id: import_backup.php 20448 2009-05-10 10:17:22Z ivantcholakov $
-/*
-==============================================================================
-	Dokeos - elearning and course management software
+/* For licensing terms, see /license.txt */
 
-	Copyright (c) 2004-2008 Dokeos SPRL
-	Copyright (c) 2003 Ghent University (UGent)
-	Copyright (c) 2001 Universite catholique de Louvain (UCL)
-	Copyright (c) Bart Mollet (bart.mollet@hogent.be)
-
-	For a full list of contributors, see "credits.txt".
-	The full license can be read in "license.txt".
-
-	This program is free software; you can redistribute it and/or
-	modify it under the terms of the GNU General Public License
-	as published by the Free Software Foundation; either version 2
-	of the License, or (at your option) any later version.
-
-	See the GNU General Public License for more details.
-
-	Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
-	Mail: info@dokeos.com
-==============================================================================
-*/
 /**
- * ==============================================================================
  * Import a backup.
  *
  * @author Bart Mollet <bart.mollet@hogent.be>
- * @package dokeos.backup
- * ==============================================================================
+ * @package chamilo.backup
  */
-/*
-==============================================================================
-		INIT SECTION
-==============================================================================
-*/
+/*		INIT SECTION	*/
 // name of the language file that needs to be included
 $language_file = array('exercice', 'coursebackup', 'admin');
 
@@ -75,11 +48,7 @@ require_once('classes/CourseSelectForm.class.php');
 api_display_tool_title($nameTools);
 
 
-/*
-==============================================================================
-		MAIN CODE
-==============================================================================
-*/
+/*		MAIN CODE		*/
 
 if((isset($_POST['action']) && $_POST['action'] == 'course_select_form' ) || (isset($_POST['import_option']) && $_POST['import_option'] == 'full_backup' )) {
 	$error=false;
@@ -207,10 +176,6 @@ if((isset($_POST['action']) && $_POST['action'] == 'course_select_form' ) || (is
 	$form->display();
 
 }
-/*
-==============================================================================
-		FOOTER
-==============================================================================
-*/
+/*	FOOTER	*/
 Display::display_footer();
-?>
+?>

+ 8 - 36
main/coursecopy/recycle_course.php

@@ -1,41 +1,17 @@
 <?php // $Id: recycle_course.php 19948 2009-04-21 17:27:59Z juliomontoya $
-/*
-==============================================================================
-	Dokeos - elearning and course management software
-
-	Copyright (c) 2004 Dokeos S.A.
-	Copyright (c) 2003 Ghent University (UGent)
-	Copyright (c) 2001 Universite catholique de Louvain (UCL)
-	Copyright (c) Bart Mollet (bart.mollet@hogent.be)
-
-	For a full list of contributors, see "credits.txt".
-	The full license can be read in "license.txt".
-
-	This program is free software; you can redistribute it and/or
-	modify it under the terms of the GNU General Public License
-	as published by the Free Software Foundation; either version 2
-	of the License, or (at your option) any later version.
-
-	See the GNU General Public License for more details.
-
-	Contact address: Dokeos, 44 rue des palais, B-1030 Brussels, Belgium
-	Mail: info@dokeos.com
-==============================================================================
-*/
+/* For licensing terms, see /license.txt */
 /**
- * ==============================================================================
  * Delete resources from a course.
  *
  * @author Bart Mollet <bart.mollet@hogent.be>
- * @package dokeos.backup
- * ==============================================================================
+ * @package chamilo.backup
  */
 
 // name of the language file that needs to be included
 $language_file = array ('exercice', 'admin', 'course_info', 'coursebackup');
 
 // including the global file
-include ('../inc/global.inc.php');
+require_once '../inc/global.inc.php';
 
 // Check access rights (only teachers are allowed here)
 if( ! api_is_allowed_to_edit()) {
@@ -52,19 +28,15 @@ $nameTools = get_lang('RecycleCourse');
 Display::display_header($nameTools);
 
 // include additional libraries
-require_once('classes/CourseBuilder.class.php');
-require_once('classes/CourseArchiver.class.php');
-require_once('classes/CourseRecycler.class.php');
-require_once('classes/CourseSelectForm.class.php');
+require_once 'classes/CourseBuilder.class.php';
+require_once 'classes/CourseArchiver.class.php';
+require_once 'classes/CourseRecycler.class.php';
+require_once 'classes/CourseSelectForm.class.php';
 
 // Display the tool title
 api_display_tool_title($nameTools);
 
-/*
-==============================================================================
-		MAIN CODE
-==============================================================================
-*/
+/*		MAIN CODE	*/
 if(  (isset($_POST['action']) && $_POST['action'] == 'course_select_form' ) || (isset($_POST['recycle_option']) && $_POST['recycle_option'] == 'full_backup' ) ) {
 	if(isset($_POST['action']) && $_POST['action'] == 'course_select_form' ) {
 		$course = CourseSelectForm::get_posted_course();

+ 68 - 21
main/document/create_document.php

@@ -167,6 +167,12 @@ require_once api_get_path(LIBRARY_PATH).'fileUpload.lib.php';
 require_once api_get_path(LIBRARY_PATH).'document.lib.php';
 require_once api_get_path(LIBRARY_PATH).'groupmanager.lib.php';
 require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php';
+require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
+if (isset($_REQUEST['certificate'])) {
+	$nameTools = get_lang('CreateCertificate');	
+} else {
+	$nameTools = get_lang('CreateDocument');	
+}
 
 $nameTools = get_lang('CreateDocument');
 
@@ -198,11 +204,12 @@ if ($dir[strlen($dir) - 1] != '/') {
 	$dir .= '/';
 }
 
-// Configuration for the online editor
-$doc_tree = explode('/', $dir);
-$count_dir = count($doc_tree) - 2; // "2" because at the begin and end there are 2 "/"
+// Configuration for the FCKEDITOR
+$doc_tree= explode('/', $dir);
+$count_dir = count($doc_tree) -2; // "2" because at the begin and end there are 2 "/"
 // Level correction for group documents.
-if (!empty($group_properties['directory'])) {
+if (!empty($group_properties['directory']))
+{
 	$count_dir = $count_dir > 0 ? $count_dir - 1 : 0;
 }
 $relative_url = '';
@@ -236,20 +243,31 @@ if (!is_dir($filepath)) {
 	$dir = '/';
 }
 
+//I'm in the certification module?  
+$is_certificate_mode = false;
+$is_certificate_array = explode('/',$_GET['dir']);
+array_shift($is_certificate_array);
+if ($is_certificate_array[0]=='certificates') {
+	$is_certificate_mode = true;
+}
 $to_group_id = 0;
 
-if (isset($_SESSION['_gid']) && $_SESSION['_gid'] != '') {
-	$req_gid = '&amp;gidReq='.$_SESSION['_gid'];
-	$interbreadcrumb[] = array('url' => '../group/group_space.php?gidReq='.$_SESSION['_gid'], 'name' => get_lang('GroupSpace'));
-	$noPHP_SELF = true;
-	$to_group_id = $_SESSION['_gid'];
-	$group = GroupManager :: get_group_properties($to_group_id);
-	$path = explode('/', $dir);
-	if ('/'.$path[1] != $group['directory']) {
-		api_not_allowed(true);
+if (!$is_certificate_mode) {
+	if (isset ($_SESSION['_gid']) && $_SESSION['_gid'] != '') {
+		$req_gid = '&amp;gidReq='.$_SESSION['_gid'];
+		$interbreadcrumb[] = array ("url" => "../group/group_space.php?gidReq=".$_SESSION['_gid'], "name" => get_lang('GroupSpace'));
+		$noPHP_SELF = true;
+		$to_group_id = $_SESSION['_gid'];
+		$group = GroupManager :: get_group_properties($to_group_id);
+		$path = explode('/', $dir);
+		if ('/'.$path[1] != $group['directory']) {
+			api_not_allowed(true);
+		}
 	}
+	$interbreadcrumb[] = array ("url" => "./document.php?curdirpath=".urlencode($_GET['dir']).$req_gid, "name" => get_lang('Documents'));
+} else {
+	$interbreadcrumb[]= array (	'url' => '../gradebook/'.$_SESSION['gradebook_dest'], 'name' => get_lang('Gradebook'));	
 }
-$interbreadcrumb[] = array('url' => './document.php?curdirpath='.urlencode($_GET['dir']).$req_gid, 'name' => get_lang('Documents'));
 
 if (!$is_allowed_in_course) {
 	api_not_allowed(true);
@@ -270,11 +288,17 @@ if (isset ($group)) {
 }
 
 // Create a new form
-$form = new FormValidator('create_document');
+$form = new FormValidator('create_document','post',api_get_self().'?dir='.Security::remove_XSS(urlencode($_GET['dir'])).'&selectcat='.Security::remove_XSS($_GET['selectcat']));
 
 // form title
 $form->addElement('header', '', $nameTools);
 
+if (isset($_REQUEST['certificate'])) {//added condition for certicate in gradebook
+	$form->addElement('hidden','certificate','true',array('id'=>'certificate'));
+	if (isset($_GET['selectcat']))
+		$form->addElement('hidden','selectcat',intval($_GET['selectcat']));	
+	
+}
 $renderer = & $form->defaultRenderer();
 
 // Hidden element with current directory
@@ -338,7 +362,11 @@ if (!empty($_SESSION['_gid'])) {
 }
 
 // Add group to the form
-$form->addGroup($group, 'filename_group', api_get_setting('use_document_title') == 'true' ? get_lang('Title') : get_lang('FileName') ,'&nbsp;&nbsp;&nbsp;', false);
+if ($is_certificate_mode)
+	$form->addGroup($group, 'filename_group', get_lang('CertificateName') ,'&nbsp;&nbsp;&nbsp;', false);
+else
+	$form->addGroup($group, 'filename_group', api_get_setting('use_document_title') == 'true' ? get_lang('Title') : get_lang('FileName') ,'&nbsp;&nbsp;&nbsp;', false);
+	
 $form->addRule('filename_group', get_lang('ThisFieldIsRequired'), 'required');
 
 if (api_get_setting('use_document_title') == 'true') {
@@ -367,7 +395,11 @@ $form->add_html_editor('content','', false, false, $html_editor_config);
 // Comment-field
 
 //$form->addElement('textarea', 'comment', get_lang('Comment'), array ('rows' => 5, 'cols' => 50));
-$form->addElement('style_submit_button', 'submit', get_lang('langCreateDoc'), 'class="save"');
+if ($is_certificate_mode)
+	$form->addElement('style_submit_button', 'submit', get_lang('CreateCertificate'), 'class="save"');
+else 
+	$form->addElement('style_submit_button', 'submit', get_lang('langCreateDoc'), 'class="save"');
+	
 $form->setDefaults($default);
 
 // HTML
@@ -452,8 +484,11 @@ if ($form->validate()) {
 					$ct .= ", title='$new_title'";
 				Database::query("UPDATE $TABLE_DOCUMENT SET".substr($ct, 1)." WHERE id = '$document_id'");
 			}
-			$dir = substr($dir, 0, -1);
-			header('Location: document.php?curdirpath='.urlencode($dir));
+			$dir= substr($dir,0,-1);
+			$selectcat = '';			
+			if (isset($_REQUEST['selectcat']))
+				$selectcat = "&selectcat=".Security::remove_XSS($_REQUEST['selectcat']);
+			header('Location: document.php?curdirpath='.urlencode($dir).$selectcat); 
 			exit ();
 		} else {
 			Display :: display_header($nameTools, 'Doc');
@@ -470,9 +505,21 @@ if ($form->validate()) {
 	Display :: display_header($nameTools, "Doc");
 	//api_display_tool_title($nameTools);
 	// actions
+	if (isset($_REQUEST['certificate'])) {
+		$all_information_by_create_certificate=DocumentManager::get_all_info_to_certificate();
+		$str_info='';
+		foreach ($all_information_by_create_certificate[0] as $info_value) {
+			$str_info.=$info_value.'<br/>';
+		}
+		$create_certificate=get_lang('CreateCertificateWithTags');
+		Display::display_normal_message($create_certificate.': <br /><br/>'.$str_info,false);
+	}
 	echo '<div class="actions">';
-	// Link back to the documents overview
-	echo '<a href="document.php?curdirpath='.Security::remove_XSS($_GET['dir']).'">'.Display::return_icon('back.png', get_lang('Back').' '.get_lang('To').' '.get_lang('DocumentsOverview')).get_lang('BackTo').' '.get_lang('DocumentsOverview').'</a>';
+	// link back to the documents overview
+	if ($is_certificate_mode) 
+		echo '<a href="document.php?curdirpath='.Security::remove_XSS($_GET['dir']).'&selectcat=' . Security::remove_XSS($_GET['selectcat']).'">'.Display::return_icon('back.png',get_lang('Back').' '.get_lang('To').' '.get_lang('CertificateOverview')).get_lang('Back').' '.get_lang('To').' '.get_lang('CertificateOverview').'</a>';
+	else 
+		echo '<a href="document.php?curdirpath='.Security::remove_XSS($_GET['dir']).'">'.Display::return_icon('back.png',get_lang('Back').' '.get_lang('To').' '.get_lang('DocumentsOverview')).get_lang('BackTo').' '.get_lang('DocumentsOverview').'</a>';	
 	echo '</div>';
 	$form->display();
 	Display :: display_footer();

+ 50 - 8
main/document/document.inc.php

@@ -250,6 +250,7 @@ function build_edit_icons($curdirpath, $type, $path, $visibility, $id, $is_templ
 	$visibility_command = ($visibility == 0) ? 'set_visible' : 'set_invisible';
 	$curdirpath = urlencode($curdirpath);
 
+	$is_certificate_mode = DocumentManager::is_certificate_mode($path);	
 	$modify_icons = '';
 	$cur_ses = api_get_session_id();
 	// If document is read only *or* we're in a session and the document
@@ -260,19 +261,60 @@ function build_edit_icons($curdirpath, $type, $path, $visibility, $id, $is_templ
 		$modify_icons .= '&nbsp;'.Display::return_icon('deplacer_fichier_na.gif', get_lang('Move'));
 		$modify_icons .= '&nbsp;'.Display::return_icon($visibility_icon.'_na.gif', get_lang('VisibilityCannotBeChanged'));
 	} else {
-		$modify_icons = '<a href="edit_document.php?'.api_get_cidreq().'&curdirpath='.$curdirpath.'&amp;file='.urlencode($path).$req_gid.'"><img src="../img/edit.gif" border="0" title="'.get_lang('Modify').'" alt="" /></a>';
-		if (in_array($path, array('/audio', '/flash', '/images', '/shared_folder', '/video', '/chat_files'))) {
-			$modify_icons .= '&nbsp;'.Display::return_icon('delete_na.gif', get_lang('ThisFolderCannotBeDeleted'));
+		if ($is_certificate_mode) {
+			$modify_icons = '<a href="edit_document.php?'.api_get_cidreq().'&curdirpath='.$curdirpath.'&amp;file='.urlencode($path).$req_gid.'&selectcat='.$gradebook_category.'"><img src="../img/edit.gif" border="0" title="'.get_lang('Modify').'" alt="" /></a>';
 		} else {
-			$modify_icons .= '&nbsp;<a href="'.api_get_self().'?'.api_get_cidreq().'&curdirpath='.$curdirpath.'&amp;delete='.urlencode($path).$req_gid.'&amp;'.$sort_params.'" onclick="javascript: return confirmation(\''.basename($path).'\');"><img src="../img/delete.gif" border="0" title="'.get_lang('Delete').'" alt="" /></a>';
-		}
-		$modify_icons .= '&nbsp;<a href="'.api_get_self().'?'.api_get_cidreq().'&curdirpath='.$curdirpath.'&amp;move='.urlencode($path).$req_gid.'"><img src="../img/deplacer_fichier.gif" border="0" title="'.get_lang('Move').'" alt="" /></a>';
-		$modify_icons .= '&nbsp;<a href="'.api_get_self().'?'.api_get_cidreq().'&curdirpath='.$curdirpath.'&amp;'.$visibility_command.'='.$id.$req_gid.'&amp;'.$sort_params.'"><img src="../img/'.$visibility_icon.'.gif" border="0" title="'.get_lang('Visible').'" alt="" /></a>';
+			$modify_icons = '<a href="edit_document.php?'.api_get_cidreq().'&curdirpath='.$curdirpath.'&amp;file='.urlencode($path).$req_gid.'"><img src="../img/edit.gif" border="0" title="'.get_lang('Modify').'" alt="" /></a>';
+		}						
+        
+        if (strcmp($path,'/audio')===0 or strcmp($path,'/flash')===0 or strcmp($path,'/images')===0 or strcmp($path,'/shared_folder')===0 or strcmp($path,'/video')===0) { 
+        	$modify_icons .= '&nbsp;'.Display::return_icon('delete_na.gif',get_lang('ThisFolderCannotBeDeleted'));
+        } else {
+        	
+			if (isset($_GET['curdirpath']) && $_GET['curdirpath']=='/certificates' && DocumentManager::get_default_certificate_id(api_get_course_id())==$id) {
+								
+        		$modify_icons .= '&nbsp;<a href="'.api_get_self().'?'.api_get_cidreq().'&curdirpath='.$curdirpath.'&amp;delete='.urlencode($path).$req_gid.'&amp;'.$sort_params.'delete_certificate_id='.$id.'&selectcat='.$gradebook_category.' " onclick="return confirmation(\''.basename($path).'\');"><img src="../img/delete.gif" border="0" title="'.get_lang('Delete').'" alt="" /></a>';				
+			} else {								
+				if ($is_certificate_mode) {		
+        			$modify_icons .= '&nbsp;<a href="'.api_get_self().'?'.api_get_cidreq().'&curdirpath='.$curdirpath.'&amp;delete='.urlencode($path).$req_gid.'&amp;'.$sort_params.'&selectcat='.$gradebook_category.'" onclick="return confirmation(\''.basename($path).'\');"><img src="../img/delete.gif" border="0" title="'.get_lang('Delete').'" alt="" /></a>';
+				} else {
+					$modify_icons .= '&nbsp;<a href="'.api_get_self().'?'.api_get_cidreq().'&curdirpath='.$curdirpath.'&amp;delete='.urlencode($path).$req_gid.'&amp;'.$sort_params.'" onclick="return confirmation(\''.basename($path).'\');"><img src="../img/delete.gif" border="0" title="'.get_lang('Delete').'" alt="" /></a>';
+				}
+			}
+        }
+        
+        if ($is_certificate_mode) {
+        	$modify_icons .= '&nbsp;<a href="'.api_get_self().'?'.api_get_cidreq().'&curdirpath='.$curdirpath.'&amp;move='.urlencode($path).$req_gid.'&selectcat='.$gradebook_category.'"><img src="../img/deplacer_fichier.gif" border="0" title="'.get_lang('Move').'" alt="" /></a>';
+        	$modify_icons .= '&nbsp;<a href="'.api_get_self().'?'.api_get_cidreq().'&curdirpath='.$curdirpath.'&amp;'.$visibility_command.'='.$id.$req_gid.'&amp;'.$sort_params.'&selectcat='.$gradebook_category.'"><img src="../img/'.$visibility_icon.'.gif" border="0" title="'.get_lang('Visible').'" alt="" /></a>';
+        } else {
+        	$modify_icons .= '&nbsp;<a href="'.api_get_self().'?'.api_get_cidreq().'&curdirpath='.$curdirpath.'&amp;move='.urlencode($path).$req_gid.'"><img src="../img/deplacer_fichier.gif" border="0" title="'.get_lang('Move').'" alt="" /></a>';
+        	$modify_icons .= '&nbsp;<a href="'.api_get_self().'?'.api_get_cidreq().'&curdirpath='.$curdirpath.'&amp;'.$visibility_command.'='.$id.$req_gid.'&amp;'.$sort_params.'"><img src="../img/'.$visibility_icon.'.gif" border="0" title="'.get_lang('Visible').'" alt="" /></a>';	
+        }
 	}
 
 	if ($type == 'file' && pathinfo($path, PATHINFO_EXTENSION) == 'html') {
 		if ($is_template == 0) {
-			$modify_icons .= '&nbsp;<a href="'.api_get_self().'?'.api_get_cidreq().'&curdirpath='.$curdirpath.'&amp;add_as_template='.$id.$req_gid.'&amp;'.$sort_params.'"><img src="../img/wizard_small.gif" border="0" title="'.get_lang('AddAsTemplate').'" alt="'.get_lang('AddAsTemplate').'" /></a>';
+			if ((isset($_GET['curdirpath']) && $_GET['curdirpath']<>'/certificates') || !isset($_GET['curdirpath'])) {
+					$modify_icons .= '&nbsp;<a href="'.api_get_self().'?'.api_get_cidreq().'&curdirpath='.$curdirpath.'&amp;add_as_template='.$id.$req_gid.'&amp;'.$sort_params.'"><img src="../img/wizard_small.gif" border="0" title="'.get_lang('AddAsTemplate').'" alt="'.get_lang('AddAsTemplate').'" /></a>';
+				}
+				if (isset($_GET['curdirpath']) && $_GET['curdirpath']=='/certificates') {//allow attach certificate to course
+					  $visibility_icon_certificate='nocertificate';
+					  if (DocumentManager::get_default_certificate_id(api_get_course_id())==$id) {
+					  	$visibility_icon_certificate='certificate';
+					  	$certificate=get_lang('DefaultCertificate');
+					  	$preview=get_lang('PreviewCertificate');
+						$is_preview=true;
+					  } else {
+					  	$is_preview=false;
+					  	$certificate=get_lang('NoDefaultCertificate');
+					  }	
+					  if (isset($_GET['selectcat'])) {
+					  	$modify_icons .= '&nbsp;<a href="'.api_get_self().'?'.api_get_cidreq().'&curdirpath='.$curdirpath.'&amp;selectcat='.Security::remove_XSS($_GET['selectcat']).'&amp;set_certificate='.$id.$req_gid.'&amp;'.$sort_params.'"><img src="../img/'.$visibility_icon_certificate.'.png" border="0" title="'.$certificate.'" alt="" /></a>';				  	
+						if ($is_preview) {
+						 	$modify_icons .= '&nbsp;<a target="_blank"  href="'.api_get_self().'?'.api_get_cidreq().'&curdirpath='.$curdirpath.'&amp;set_preview='.$id.$req_gid.'&amp;'.$sort_params.'" ><img src="../img/search.gif" border="0" title="'.$preview.'" alt="" width="16" height="16"/></a>';
+							}
+					  }
+				}			
 		} else {
 			$modify_icons .= '&nbsp;<a href="'.api_get_self().'?'.api_get_cidreq().'&curdirpath='.$curdirpath.'&amp;remove_as_template='.$id.$req_gid.'&amp;'.$sort_params.'"><img src="../img/wizard_gray_small.gif" border="0" title="'.get_lang('RemoveAsTemplate').'" alt=""'.get_lang('RemoveAsTemplate').'" /></a>';
 		}

+ 92 - 21
main/document/document.php

@@ -41,9 +41,13 @@ require_once 'document.inc.php';
 $lib_path = api_get_path(LIBRARY_PATH);
 
 require_once $lib_path.'usermanager.lib.php';
+require_once api_get_path(LIBRARY_PATH).'document.lib.php';
+require_once api_get_path(LIBRARY_PATH).'fileUpload.lib.php';
 
 api_protect_course_script(true);
 $htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.js" type="text/javascript" language="javascript"></script>'; //jQuery
+$htmlHeadXtra[] = '<script type="text/javascript" src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/thickbox.js"></script>';
+$htmlHeadXtra[] = '<link rel="stylesheet" href="'.api_get_path(WEB_LIBRARY_PATH).'javascript/thickbox.css" type="text/css" media="projection, screen">';
 $htmlHeadXtra[] = '<script type="text/javascript">
 $(document).ready( function() {
 	for (i=0;i<$(".actions").length;i++) {
@@ -57,6 +61,38 @@ $(document).ready( function() {
 if (isset($_GET['id_session'])) {
 	$_SESSION['id_session'] = Security::remove_XSS($_GET['id_session']);
 }
+//create directory certificates
+$course_id=api_get_course_id();
+DocumentManager::create_directory_certificate_in_course($course_id);
+
+//show preview
+if (isset($_GET['curdirpath']) && $_GET['curdirpath']=='/certificates' && isset($_GET['set_preview']) && $_GET['set_preview']==strval(intval($_GET['set_preview']))) {
+	if (isset($_GET['set_preview'])) {
+			//generate document HTML
+			$course_id=api_get_course_id();
+			$content_html=DocumentManager::replace_user_info_into_html($course_id);
+			
+			$new_content_html=$content_html;
+
+			$path_image=api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document/images/gallery';
+			$new_content_html=str_replace('../images/gallery',$path_image,$new_content_html);
+			
+			$path_image_in_default_course=api_get_path(WEB_CODE_PATH).'default_course_document';
+			$new_content_html=str_replace('/main/default_course_document',$path_image_in_default_course,$new_content_html);
+
+			$path_image_in_dokeos_main=api_get_path(WEB_IMG_PATH);
+			$new_content_html=str_replace('/main/img/',$path_image_in_dokeos_main,$new_content_html);
+			echo '
+			<style media="print" type="text/css">
+				#imprimir {
+				visibility:hidden;
+				}				
+			</style>';
+			echo '<a href="javascript:window.print();" style="float:right; padding:4px;" id="imprimir"><img src="../img/printmgr.gif" alt="' . get_lang('Print') . '" /> ' . get_lang('Print') . '</a>';
+			print_r($new_content_html);
+			exit;
+	}
+}
 
 // Is the document tool visible?
 // Check whether the tool is actually visible
@@ -341,7 +377,13 @@ if ($is_allowed_to_edit || $group_member_with_upload_rights) { // TEACHER ONLY
 
 		require_once api_get_path(LIBRARY_PATH).'fileManage.lib.php';
 
-		if (DocumentManager::delete_document($_course, $_GET['delete'], $base_work_dir)) {
+		if(DocumentManager::delete_document($_course,$_GET['delete'],$base_work_dir))
+		{
+			if ( isset($_GET['delete_certificate_id']) && $_GET['delete_certificate_id']==strval(intval($_GET['delete_certificate_id'])) ) {
+				$course_id=api_get_course_id();
+				$default_certificate_id=$_GET['delete_certificate_id'];
+				DocumentManager::remove_attach_certificate ($course_id,$default_certificate_id);
+			}
 			Display::display_confirmation_message(get_lang('DocDeleted'));
 		} else {
 			Display::display_error_message(get_lang('DocDeleteError'));
@@ -531,6 +573,17 @@ if ($is_allowed_to_edit || $group_member_with_upload_rights) { // TEACHER ONLY
 	}
 } // END is allowed to edit
 
+//attach certificate in the gradebook
+if (isset($_GET['curdirpath']) && $_GET['curdirpath']=='/certificates' && isset($_GET['set_certificate']) && $_GET['set_certificate']==strval(intval($_GET['set_certificate']))) {
+	if (isset($_GET['cidReq'])) {
+		$course_id=Security::remove_XSS($_GET['cidReq']);//course id
+		$document_id=Security::remove_XSS($_GET['set_certificate']);//document id
+		DocumentManager::attach_gradebook_certificate ($course_id,$document_id) ;
+		Display::display_normal_message(get_lang('IsDefaultCertificate'));	
+	}	
+}
+
+
 /*	GET ALL DOCUMENT DATA FOR CURDIRPATH */
 
 $docs_and_folders = DocumentManager::get_all_document_data($_course, $curdirpath, $to_group_id, null, $is_allowed_to_edit || $group_member_with_upload_rights);
@@ -541,15 +594,22 @@ if ($folders === false) {
 
 echo '<div class="actions">';
 
-/* GO TO PARENT DIRECTORY */
-
-if ($curdirpath!= '/'&& $curdirpath!=$group_properties['directory']) {
-?>
-		 <a href="<?php echo api_get_self(); ?>?<?php echo api_get_cidreq();?>&curdirpath=<?php echo urlencode((dirname($curdirpath) == '\\') ? '/' : dirname($curdirpath)).$req_gid; ?>">
+	/* GO TO PARENT DIRECTORY */
+	if ($curdirpath!= '/' && $curdirpath!=$group_properties['directory']&& !$is_certificate_mode)  {		
+	?>
+		 <a href="<?php echo api_get_self(); ?>?<?php echo api_get_cidreq();?>&curdirpath=<?php echo urlencode((dirname($curdirpath)=='\\')?'/':dirname($curdirpath)).$req_gid ?>">
 				<img src="../img/folder_up.gif" border="0" title="<?php echo get_lang('Up'); ?>" alt="" />
 				<?php echo get_lang('Up'); ?></a>&nbsp;
-<?php
-}
+	<?php		
+	}
+	
+	if ($is_certificate_mode & $curdirpath!= '/certificates')  {		
+	?>
+		 <a href="<?php echo api_get_self(); ?>?<?php echo api_get_cidreq();?>&curdirpath=<?php echo urlencode((dirname($curdirpath)=='\\')?'/':dirname($curdirpath)).$req_gid ?>">
+				<img src="../img/folder_up.gif" border="0" title="<?php echo get_lang('Up'); ?>" alt="" />
+				<?php echo get_lang('Up'); ?></a>&nbsp;
+	<?php		
+	}
 
 if (isset($docs_and_folders) && is_array($docs_and_folders)) {
 	//echo('<pre>');
@@ -648,29 +708,39 @@ if ($is_allowed_to_edit || $group_member_with_upload_rights || is_my_shared_fold
 	/* CREATE NEW DOCUMENT OR NEW DIRECTORY / GO TO UPLOAD / DOWNLOAD ZIPPED FOLDER */
 ?>
 			<!-- create new document or directory -->
-<?php
-	if (!is_my_shared_folder($_user['user_id'],$curdirpath)) { ?>
+            <?php if (!$is_certificate_mode && !is_my_shared_folder($_user['user_id'],$curdirpath))
+            {?>
                 <a href="create_document.php?<?php echo api_get_cidreq();?>&dir=<?php echo $curdirpathurl.$req_gid; ?>"><img src="../img/filenew.gif" border="0" alt="" title="<?php echo get_lang('CreateDoc'); ?>" /></a>
                 <a href="create_document.php?<?php echo api_get_cidreq();?>&dir=<?php echo $curdirpathurl.$req_gid; ?>"><?php echo get_lang("CreateDoc"); ?></a>&nbsp;&nbsp;
-<?php
-	}?>
+	        <?php }?>
+	        
+      		<!--create new certificate -->
+			<?php if ($is_certificate_mode) { ?>	
+			<a href="create_document.php?<?php echo api_get_cidreq();?>&dir=<?php echo $curdirpathurl.$req_gid; ?>&certificate=true&<?php echo 'selectcat=' . Security::remove_XSS($_GET['selectcat']); ?>"><img src="../img/filenew.gif" border="0" alt="" title="<?php echo get_lang('CreateCertificate'); ?>" /></a>
+			<a href="create_document.php?<?php echo api_get_cidreq();?>&dir=<?php echo $curdirpathurl.$req_gid; ?>&certificate=true&<?php echo 'selectcat=' . Security::remove_XSS($_GET['selectcat']); ?>"><?php echo get_lang("CreateCertificate"); ?></a>&nbsp;&nbsp;	
+			<?php }?>
+			
 			<!-- file upload link -->
+		<?php
+				$upload_name =  get_lang('UplUploadDocument');
+				if ($is_certificate_mode) { 
+				$upload_name =	 get_lang('UploadCertificate');
+			}?>	
+
 			<a href="upload.php?<?php echo api_get_cidreq();?>&curdirpath=<?php echo $curdirpathurl.$req_gid; ?>"><img src="../img/submit_file.gif" border="0" title="<?php echo get_lang('UplUploadDocument'); ?>" alt="" /></a>
 			<a href="upload.php?<?php echo api_get_cidreq();?>&curdirpath=<?php echo $curdirpathurl.$req_gid; ?>"><?php echo get_lang('UplUploadDocument'); ?></a>&nbsp;
 			<!-- create directory -->
-<?php
-	if (!is_my_shared_folder($_user['user_id'],$curdirpath)) {?>
+            <?php if (!$is_certificate_mode && !is_my_shared_folder($_user['user_id'],$curdirpath))
+            {?>
                 <a href="<?php echo api_get_self(); ?>?<?php echo api_get_cidreq();?>&curdirpath=<?php echo $curdirpathurl.$req_gid; ?>&amp;createdir=1"><img src="../img/folder_new.gif" border="0" title="<?php echo get_lang('CreateDir'); ?>" alt ="" /></a>
-                <a href="<?php echo api_get_self(); ?>?<?php echo api_get_cidreq();?>&curdirpath=<?php echo $curdirpathurl.$req_gid; ?>&amp;createdir=1"><?php echo get_lang('CreateDir'); ?></a>&nbsp;
-                <a href="quota.php?<?php echo api_get_cidreq();?>"><?php Display::display_icon('statistics.gif', get_lang('ShowCourseQuotaUse')); ?><?php echo get_lang('ShowCourseQuotaUse'); ?></a>
-<?php
+                <a href="<?php echo api_get_self(); ?>?<?php echo api_get_cidreq();?>&curdirpath=<?php echo $curdirpathurl.$req_gid; ?>&amp;createdir=1"><?php echo get_lang("CreateDir"); ?></a>&nbsp;
+                <a href="quota.php?<?php echo api_get_cidreq();?>"><?php Display::display_icon('statistics.gif', get_lang("ShowCourseQuotaUse")); ?><?php echo get_lang("ShowCourseQuotaUse"); ?></a>
+		<?php
+			}
 	}
-}
-
 if (!is_null($docs_and_folders)) {
 	global $total_size;
-	if ($total_size != 0 && (api_get_setting('students_download_folders') == 'true' || api_is_allowed_to_edit() || api_is_platform_admin())) {
-?>
+	if (!$is_certificate_mode && $total_size!=0  &&  (api_get_setting('students_download_folders') == 'true' || api_is_allowed_to_edit() || api_is_platform_admin())){ ?>
 	<!-- download zipped folder -->
 			<a href="<?php echo api_get_self(); ?>?<?php echo api_get_cidreq();?>&action=downloadfolder"><img src="../img/zip_save.gif" border="0" title="<?php echo get_lang("Save"); ?> (ZIP)" alt="" /></a>
 			<a href="<?php echo api_get_self(); ?>?<?php echo api_get_cidreq();?>&action=downloadfolder"><?php echo get_lang("Save"); ?> (ZIP)</a>&nbsp;
@@ -684,6 +754,7 @@ if ($image_present) {
 	echo "<a href=\"slideshow.php?".api_get_cidreq()."&curdirpath=".$curdirpathurl."\"><img src=\"../img/images_gallery.gif\" border=\"0\" title=\"".get_lang('ViewSlideshow')."\"/>&nbsp;". get_lang('ViewSlideshow') . "</a>";
 }
 echo '</div>';
+if (!$is_certificate_mode)
 echo build_directory_selector($folders, $curdirpath, (isset($group_properties['directory']) ? $group_properties['directory'] : array()), true);
 
 if (($is_allowed_to_edit || $group_member_with_upload_rights) && count($docs_and_folders) > 1) {

+ 36 - 7
main/document/edit_document.php

@@ -100,6 +100,11 @@ $file = $_GET['file'];
 $doc = basename($file);
 //echo('doc: '.$doc.'<br />');
 $dir = Security::remove_XSS($_GET['curdirpath']);
+
+//I'm in the certification module?  
+$is_certificate_mode = DocumentManager::is_certificate_mode($dir);
+
+
 //echo('dir: '.$dir.'<br />');
 $file_name = $doc;
 //echo('file_name: '.$file_name.'<br />');
@@ -175,7 +180,11 @@ if (!empty($_SESSION['_gid'])) {
 	$noPHP_SELF = true;
 }
 $my_cur_dir_path = Security::remove_XSS($_GET['curdirpath']);
-$interbreadcrumb[] = array('url' => './document.php?curdirpath='.urlencode($my_cur_dir_path).$req_gid, 'name' => get_lang('Documents'));
+if (!$is_certificate_mode)
+	$interbreadcrumb[]=array("url"=>"./document.php?curdirpath=".urlencode($my_cur_dir_path).$req_gid, "name"=> get_lang('Documents'));
+else 
+	$interbreadcrumb[]= array (	'url' => '../gradebook/'.$_SESSION['gradebook_dest'], 'name' => get_lang('Gradebook'));	
+
 
 $is_allowedToEdit = is_allowed_to_edit() || $_SESSION['group_member_with_upload_rights'];
 
@@ -533,8 +542,13 @@ if ($owner_id == $_user['user_id'] || api_is_platform_admin() || $is_allowed_to_
 			$checked->setChecked(true);
 		}
 	}
-	$form->addElement('style_submit_button', 'submit', get_lang('SaveDocument'), 'class="save"');
-
+		if ($is_certificate_mode)
+		$form->addElement('style_submit_button', 'submit', get_lang('SaveCertificate'), 'class="save"');
+	else 
+		$form->addElement('style_submit_button','submit',get_lang('SaveDocument'), 'class="save"');
+	
+	
+	
 	$defaults['filename'] = $filename;
 	$defaults['extension'] = $extension;
 	$defaults['file_path'] = Security::remove_XSS($_GET['file']);
@@ -549,10 +563,25 @@ if ($owner_id == $_user['user_id'] || api_is_platform_admin() || $is_allowed_to_
 	/*
 	$form->addElement('html', '<div id="frmModel" style="display:block; height:525px; width:240px; position:absolute; top:115px; left:1px;"></div>');
 	*/
-	$origin = Security::remove_XSS($_GET['origin']);
-	if ($origin == 'slideshow') {
-		$slide_id = $_GET['origin_opt'];
-		nav_to_slideshow($slide_id);
+if (isset($_REQUEST['curdirpath']) && $_GET['curdirpath']=='/certificates') {
+		$all_information_by_create_certificate=DocumentManager::get_all_info_to_certificate();
+		$str_info='';
+		foreach ($all_information_by_create_certificate[0] as $info_value) {
+			$str_info.=$info_value.'<br/>';
+		}
+		$create_certificate=get_lang('CreateCertificateWithTags');
+		Display::display_normal_message($create_certificate.': <br /><br />'.$str_info,false);
+	}	
+	if ($is_certificate_mode) {
+		echo '<div class="actions">';
+				echo '<a href="document.php?curdirpath='.Security::remove_XSS($_GET['curdirpath']).'&selectcat=' . Security::remove_XSS($_GET['selectcat']).'">'.Display::return_icon('back.png',get_lang('Back').' '.get_lang('To').' '.get_lang('CertificateOverview')).get_lang('Back').' '.get_lang('To').' '.get_lang('CertificateOverview').'</a>';
+		echo '</div>';
+	} else {
+		$origin=Security::remove_XSS($_GET['origin']);
+		if ($origin=='slideshow') {
+			$slide_id=$_GET['origin_opt'];
+			nav_to_slideshow($slide_id);
+		}
 	}
 	$form->display();
 	//Display::display_error_message(get_lang('ReadOnlyFile'));

+ 29 - 11
main/document/upload.php

@@ -211,6 +211,14 @@ if ($to_group_id != 0 && $path == '/') {
 	$path = $group_properties['directory'];
 }
 
+//I'm in the certification module?  
+$is_certificate_mode = false;
+$is_certificate_array = explode('/',$path);
+array_shift($is_certificate_array);
+if ($is_certificate_array[0]=='certificates') {
+	$is_certificate_mode = true;
+}
+
 // If we want to unzip a file, we need the library
 if (isset($_POST['unzip']) && $_POST['unzip'] == 1) {
 	require_once api_get_path(LIBRARY_PATH).'pclzip/pclzip.lib.php';
@@ -223,10 +231,16 @@ $max_filled_space = DocumentManager::get_course_quota();
 if ($to_group_id != 0) { // Add group name after for group documents
 	$add_group_to_title = ' ('.$group_properties['name'].')';
 }
-$nameTools = get_lang('UplUploadDocument').$add_group_to_title;
-
+if (isset($_REQUEST['certificate'])) {
+	$nameTools = get_lang('UploadCertificate').$add_group_to_title;
+} else {
+	$nameTools = get_lang('UplUploadDocument').$add_group_to_title;	
+}
 // Breadcrumbs
-$interbreadcrumb[] = array('url' => './document.php?curdirpath='.urlencode($path).$req_gid, 'name' => get_lang('Documents'));
+if ($is_certificate_mode)
+	$interbreadcrumb[]= array (	'url' => '../gradebook/'.$_SESSION['gradebook_dest'], 'name' => get_lang('Gradebook'));
+else
+	$interbreadcrumb[] = array('url' =>'./document.php?curdirpath='.urlencode($path).$req_gid, 'name'=> get_lang('Documents'));
 
 // Display the header
 Display::display_header($nameTools, 'Doc');
@@ -464,18 +478,22 @@ if (isset($_GET['createdir'])) {
 echo '<div class="actions">';
 
 // Link back to the documents overview
-echo '<a href="document.php?curdirpath='.$path.'">'.Display::return_icon('back.png',get_lang('BackTo').' '.get_lang('DocumentsOverview')).get_lang('BackTo').' '.get_lang('DocumentsOverview').'</a>';
-
-// Link to create a folder
-if (!isset($_GET['createdir']) && !is_my_shared_folder($_user['user_id'], $path)) {
+if ($is_certificate_mode)
+	echo '<a href="document.php?curdirpath='.$path.'&selectcat=' . Security::remove_XSS($_GET['selectcat']).'">'.Display::return_icon('back.png',get_lang('Back').' '.get_lang('To').' '.get_lang('CertificateOverview')).get_lang('Back').' '.get_lang('To').' '.get_lang('CertificateOverview').'</a>';
+else 
+	echo '<a href="document.php?curdirpath='.$path.'">'.Display::return_icon('back.png',get_lang('BackTo').' '.get_lang('DocumentsOverview')).get_lang('BackTo').' '.get_lang('DocumentsOverview').'</a>';
+
+// link to create a folder
+if(!isset($_GET['createdir']) && !is_my_shared_folder($_user['user_id'], $path) && !$is_certificate_mode)
+{
 	echo '<a href="'.api_get_self().'?path='.$path.'&amp;createdir=1">'.Display::return_icon('folder_new.gif', get_lang('CreateDir')).get_lang('CreateDir').'</a>';
 }
 echo '</div>';
 
-// Form to select directory
-$folders = DocumentManager::get_all_document_folders($_course, $to_group_id, $is_allowed_to_edit);
-
-echo build_directory_selector($folders, $path, $group_properties['directory']);
+//form to select directory
+$folders = DocumentManager::get_all_document_folders($_course,$to_group_id,$is_allowed_to_edit);
+if (!$is_certificate_mode)
+	echo(build_directory_selector($folders,$path,$group_properties['directory']));
 
 ?>
 

+ 50 - 79
main/exercice/answer.class.php

@@ -1,35 +1,16 @@
 <?php
-/*
-    DOKEOS - elearning and course management software
-
-    For a full list of contributors, see documentation/credits.html
-
-    This program is free software; you can redistribute it and/or
-    modify it under the terms of the GNU General Public License
-    as published by the Free Software Foundation; either version 2
-    of the License, or (at your option) any later version.
-    See "documentation/licence.html" more details.
-
-    Contact:
-		Dokeos
-		Rue des Palais 44 Paleizenstraat
-		B-1030 Brussels - Belgium
-		Tel. +32 (2) 211 34 56
-*/
-
+/* For licensing terms, see /license.txt */
 
 /**
 *	This class allows to instantiate an object of type Answer
 *	5 arrays are created to receive the attributes of each answer belonging to a specified question
-* 	@package dokeos.exercise
+* 	@package chamilo.exercise
 * 	@author Olivier Brouckaert
 * 	@version $Id: answer.class.php 21172 2009-06-01 20:58:05Z darkvela $
 */
 
-
 if(!class_exists('Answer')):
 
-
 class Answer
 {
 	var $questionId;
@@ -67,51 +48,48 @@ class Answer
 	function Answer($questionId)
 	{
 		//$this->questionType=$questionType;
-		$this->questionId=(int)$questionId;
-		$this->answer=array();
-		$this->correct=array();
-		$this->comment=array();
-		$this->weighting=array();
-		$this->position=array();
-		$this->hotspot_coordinates=array();
-		$this->hotspot_type=array();
-		$this->destination= array();
+		$this->questionId			= (int)$questionId;
+		$this->answer				= array();
+		$this->correct				= array();
+		$this->comment				= array();
+		$this->weighting			= array();
+		$this->position				= array();
+		$this->hotspot_coordinates	= array();
+		$this->hotspot_type 		= array();
+		$this->destination  		= array();
 		// clears $new_* arrays
 		$this->cancel();
 
 		// fills arrays
 		$objExercise = new Exercise();
-		$objExercise->read($_REQUEST['exerciseId']);
-		if($objExercise->random_answers=='1')
-		{
+		$objExercise->read($_REQUEST['exerciseId']);		
+		if($objExercise->random_answers=='1') {
 			$this->readOrderedBy('rand()', '');// randomize answers
-		}
-		else
-		{
+		} else {
 			$this->read(); // natural order
 		}
 	}
 
 	/**
-	 * clears $new_* arrays
+	 * Clears $new_* arrays
 	 *
 	 * @author - Olivier Brouckaert
 	 */
 	function cancel()
 	{
-		$this->new_answer=array();
-		$this->new_correct=array();
-		$this->new_comment=array();
-		$this->new_weighting=array();
-		$this->new_position=array();
-		$this->new_hotspot_coordinates=array();
-		$this->new_hotspot_type=array();
-		$this->new_nbrAnswers=0;
-		$this->new_destination=array();
+		$this->new_answer				= array();
+		$this->new_correct				= array();
+		$this->new_comment				= array();
+		$this->new_weighting			= array();
+		$this->new_position				= array();
+		$this->new_hotspot_coordinates	= array();
+		$this->new_hotspot_type			= array();
+		$this->new_nbrAnswers			= 0;
+		$this->new_destination			= array();
 	}
 
 	/**
-	 * reads answer informations from the data base
+	 * Reads answer informations from the data base
 	 *
 	 * @author - Olivier Brouckaert
 	 */
@@ -131,21 +109,19 @@ class Answer
 		$i=1;
 
 		// while a record is found
-		while($object=Database::fetch_object($result))
-		{
-			$this->id[$i]=$object->id;
-			$this->answer[$i]=$object->answer;
-			$this->correct[$i]=$object->correct;
-			$this->comment[$i]=$object->comment;
-			$this->weighting[$i]=$object->ponderation;
-			$this->position[$i]=$object->position;
-			$this->hotspot_coordinates[$i]=$object->hotspot_coordinates;
-			$this->hotspot_type[$i]=$object->hotspot_type;
-			$this->destination[$i]=$object->destination;
-			$this->autoId[$i]=$object->id_auto;
+		while($object=Database::fetch_object($result)) {
+			$this->id[$i]					= $object->id;
+			$this->answer[$i]				= $object->answer;
+			$this->correct[$i]				= $object->correct;
+			$this->comment[$i]				= $object->comment;
+			$this->weighting[$i]			= $object->ponderation;
+			$this->position[$i]				= $object->position;
+			$this->hotspot_coordinates[$i]	= $object->hotspot_coordinates;
+			$this->hotspot_type[$i]			= $object->hotspot_type;
+			$this->destination[$i]			= $object->destination;
+			$this->autoId[$i]				= $object->id_auto;
 			$i++;
 		}
-
 		$this->nbrAnswers=$i-1;
 	}
 	/**
@@ -158,8 +134,7 @@ class Answer
 	{
 		global $_course;
 		$field = Database::escape_string($field);
-		if(empty($field))
-		{
+		if(empty($field)) {
 			$field = 'position';
 		}
 		if($order != 'ASC' and $order!='DESC')
@@ -182,16 +157,15 @@ class Answer
 		// while a record is found
 		while($object=Database::fetch_object($result))
 		{
-			$this->answer[$i]=$object->answer;
-			$this->correct[$i]=$object->correct;
-			$this->comment[$i]=$object->comment;
-			$this->weighting[$i]=$object->ponderation;
-			$this->position[$i]=$object->position;
-			$this->destination[$i]=$object->destination;
-			$this->autoId[$i]=$object->id_auto;
+			$this->answer[$i]		= $object->answer;
+			$this->correct[$i]		= $object->correct;
+			$this->comment[$i]		= $object->comment;
+			$this->weighting[$i]	= $object->ponderation;
+			$this->position[$i]		= $object->position;
+			$this->destination[$i]	= $object->destination;
+			$this->autoId[$i]		= $object->id_auto;
 			$i++;
 		}
-
 		$this->nbrAnswers=$i-1;
 	}
 
@@ -470,7 +444,7 @@ class Answer
 	}
 
 	/**
-	 * records answers into the data base
+	 * Records answers into the data base
 	 *
 	 * @author - Olivier Brouckaert
 	 */
@@ -489,8 +463,7 @@ class Answer
 				"(id,question_id,answer,correct,comment," .
 				"ponderation,position,hotspot_coordinates,hotspot_type,destination) VALUES";
 
-		for($i=1;$i <= $this->new_nbrAnswers;$i++)
-		{
+		for($i=1;$i <= $this->new_nbrAnswers;$i++) {
 			$answer					= Database::escape_string($this->new_answer[$i]);
 			$correct				= Database::escape_string($this->new_correct[$i]);
 			$comment				= Database::escape_string($this->new_comment[$i]);
@@ -522,7 +495,7 @@ class Answer
 	}
 
 	/**
-	 * duplicates answers by copying them into another question
+	 * Duplicates answers by copying them into another question
 	 *
 	 * @author - Olivier Brouckaert
 	 * @param - integer $newQuestionId - ID of the new question
@@ -532,15 +505,13 @@ class Answer
 		$TBL_REPONSES = Database :: get_course_table(TABLE_QUIZ_ANSWER);
 
 		// if at least one answer
-		if($this->nbrAnswers)
-		{
+		if($this->nbrAnswers) {
 			// inserts new answers into data base
 			$sql="INSERT INTO $TBL_REPONSES" .
 					"(id,question_id,answer,correct,comment," .
 					"ponderation,position,hotspot_coordinates,hotspot_type,destination) VALUES";
 
-			for($i=1;$i <= $this->nbrAnswers;$i++)
-			{
+			for($i=1;$i <= $this->nbrAnswers;$i++) {
 				$answer					= Database::escape_string($this->answer[$i]);
 				$correct				= Database::escape_string($this->correct[$i]);
 				$comment				= Database::escape_string($this->comment[$i]);
@@ -560,4 +531,4 @@ class Answer
 }
 
 endif;
-?>
+?>

+ 2 - 2
main/exercice/exercice.php

@@ -567,11 +567,11 @@ if ($is_allowedToEdit) {
 					case 'clean_results' : //clean student results
 							$quantity_results_deleted= $objExerciseTmp->clean_results();					
 							Display :: display_confirmation_message(sprintf(get_lang('XResultsCleaned'),$quantity_results_deleted));
-						break;
+					break;
 					case 'copy_exercise' : //copy an exercise					
 							$objExerciseTmp->copy_exercise();					
 							Display :: display_confirmation_message(get_lang('ExerciseCopied'));					
-						break;					
+					break;					
 				}
 			}
 		}

+ 16 - 10
main/exercice/exercise.class.php

@@ -1378,7 +1378,7 @@ class Exercise
 		$table_track_e_attempt   = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);	
 		
 		$sql_select = "SELECT exe_id FROM $table_track_e_exercises
-						WHERE exe_cours_id = '".api_get_course_id()."' AND exe_exo_id = ".$this->id." AND orig_lp_id = 0 AND orig_lp_item_id = 0 AND session_id = ".api_get_session_id()."";
+					   WHERE exe_cours_id = '".api_get_course_id()."' AND exe_exo_id = ".$this->id." AND orig_lp_id = 0 AND orig_lp_item_id = 0 AND session_id = ".api_get_session_id()."";
 						
 		$result   = Database::query($sql_select);
 		$exe_list = Database::store_result($result);
@@ -1401,10 +1401,10 @@ class Exercise
 	}
 	
 	/**
-	 * Copies an exercise   
+	 * Copies an exercise (duplicate all questions and answers)
 	*/
 	
-	function copy_exercise() {
+	public function copy_exercise() {
 		$exercise_obj= new Exercise();
 		$exercise_obj = $this;
 		
@@ -1419,15 +1419,21 @@ class Exercise
 		$exercise_obj->updateId(0);
 		$exercise_obj->save();
 		
-		$new_exercise_id = $exercise_obj->selectId();
-		
-		$question_list = $exercise_obj->selectQuestionList();
+		$new_exercise_id = $exercise_obj->selectId();		
+		$question_list 	 = $exercise_obj->selectQuestionList();
 	
-		//creation of question
-		
-		foreach ($question_list as $question_id) {			
-			$new_question_obj = Question::read($question_id);
+		//Question creation 		
+		foreach ($question_list as $old_question_id) {			
+			$old_question_obj = Question::read($old_question_id);
+			$new_id = $old_question_obj->duplicate();
+			
+			$new_question_obj = Question::read($new_id);
+			
 			$new_question_obj->addToList($new_exercise_id);		
+			// This should be moved to the duplicate function				
+			$new_answer_obj = new Answer($old_question_id);
+			$new_answer_obj->read();
+			$new_answer_obj->duplicate($new_id);			
 		}
 	}
 		

+ 42 - 36
main/exercice/question.class.php

@@ -1,10 +1,9 @@
 <?php // $Id: question.class.php 22257 2009-07-20 17:50:09Z juliomontoya $
-
-/* For licensing terms, see /dokeos_license.txt */
+/* For licensing terms, see /license.txt */
 
 /**
 *	File containing the Question class.
-*	@package dokeos.exercise
+*	@package chamilo.exercise
 * 	@author Olivier Brouckaert
 * 	@version $Id: question.class.php 22257 2009-07-20 17:50:09Z juliomontoya $
 */
@@ -13,24 +12,23 @@
 if(!class_exists('Question')):
 
 // answer types
-define('UNIQUE_ANSWER',	1);
-define('MULTIPLE_ANSWER',	2);
-define('FILL_IN_BLANKS',	3);
-define('MATCHING',		4);
-define('FREE_ANSWER',     5);
-define('HOT_SPOT', 		6);
-define('HOT_SPOT_ORDER', 	7);
-define('HOT_SPOT_DELINEATION', 		8);
+define('UNIQUE_ANSWER',					1);
+define('MULTIPLE_ANSWER',				2);
+define('FILL_IN_BLANKS',				3);
+define('MATCHING',						4);
+define('FREE_ANSWER',    				5);
+define('HOT_SPOT', 						6);
+define('HOT_SPOT_ORDER', 				7);
+define('HOT_SPOT_DELINEATION', 			8);
 define('MULTIPLE_ANSWER_COMBINATION', 	9);
 
 /**
-	CLASS QUESTION
+	QUESTION CLASS
  *
  *	This class allows to instantiate an object of type Question
  *
  *	@author Olivier Brouckaert, original author
  *	@author Patrick Cool, LaTeX support
- *	@package dokeos.exercise
  */
 abstract class Question
 {
@@ -47,12 +45,12 @@ abstract class Question
 	static $typePicture = 'new_question.png';
 	static $explanationLangVar = '';
 	static $questionTypes = array(
-							UNIQUE_ANSWER => 				array('unique_answer.class.php' , 'UniqueAnswer'),
+							UNIQUE_ANSWER => 				array('unique_answer.class.php' , 	'UniqueAnswer'),
 							MULTIPLE_ANSWER => 				array('multiple_answer.class.php' , 'MultipleAnswer'),
-							FILL_IN_BLANKS => 				array('fill_blanks.class.php' , 'FillBlanks'),
-							MATCHING => 					array('matching.class.php' , 'Matching'),
-							FREE_ANSWER => 					array('freeanswer.class.php' , 'FreeAnswer'),
-							HOT_SPOT => 					array('hotspot.class.php' , 'HotSpot'),
+							FILL_IN_BLANKS => 				array('fill_blanks.class.php' , 	'FillBlanks'),
+							MATCHING => 					array('matching.class.php' , 		'Matching'),
+							FREE_ANSWER => 					array('freeanswer.class.php' , 		'FreeAnswer'),
+							HOT_SPOT => 					array('hotspot.class.php' , 		'HotSpot'),
 							MULTIPLE_ANSWER_COMBINATION =>	array('multiple_answer_combination.class.php' , 'MultipleAnswerCombination'),
 							);
 
@@ -73,7 +71,7 @@ abstract class Question
 	}
 
 	/**
-	 * reads question informations from the data base
+	 * Reads question informations from the data base
 	 *
 	 * @author - Olivier Brouckaert
 	 * @param - integer $id - question ID
@@ -94,22 +92,21 @@ abstract class Question
 		// if the question has been found
 		if($object=Database::fetch_object($result))
 		{
-			$objQuestion = Question::getInstance($object->type);
-			$objQuestion->id=$id;
-			$objQuestion->question=$object->question;
-			$objQuestion->description=$object->description;
-			$objQuestion->weighting=$object->ponderation;
-			$objQuestion->position=$object->position;
-			$objQuestion->type=$object->type;
-			$objQuestion->picture=$object->picture;
-			$objQuestion->level=(int) $object->level;
+			$objQuestion 				= Question::getInstance($object->type);
+			$objQuestion->id			= $id;
+			$objQuestion->question		= $object->question;
+			$objQuestion->description	= $object->description;
+			$objQuestion->weighting		= $object->ponderation;
+			$objQuestion->position		= $object->position;
+			$objQuestion->type			= $object->type;
+			$objQuestion->picture		= $object->picture;
+			$objQuestion->level			= (int) $object->level;
 
 			$sql="SELECT exercice_id FROM $TBL_EXERCICE_QUESTION WHERE question_id='".intval($id)."'";
 			$result=Database::query($sql);
 
 			// fills the array with the exercises which this question is in
-			while($object=Database::fetch_object($result))
-			{
+			while($object=Database::fetch_object($result)) {
 				$objQuestion->exerciseList[]=$object->exercice_id;
 			}
 
@@ -518,9 +515,18 @@ abstract class Question
 		// saves the picture into a temporary file
 		@move_uploaded_file($Picture,$picturePath.'/tmp.'.$Extension);
 	}
+	
+	/**
+		Sets the title 
+	*/
+	public function setTitle($title)
+	{
+		$this->question = $title; 	
+	}
+	
 
 	/**
-	 * moves the temporary question "tmp" to "quiz-$questionId"
+	 * Moves the temporary question "tmp" to "quiz-$questionId"
 	 * Temporary pictures are used when we don't want to save a picture right after a form submission.
 	 * For example, if we first show a confirmation box.
 	 *
@@ -603,7 +609,8 @@ abstract class Question
                 }
             }
 
-		} else {// creates a new question
+		} else {
+			// creates a new question
 			$sql="SELECT max(position) FROM $TBL_QUESTIONS as question, $TBL_EXERCICE_QUESTION as test_question WHERE question.id=test_question.question_id AND test_question.exercice_id='".Database::escape_string($exerciseId)."'";
 			$result=Database::query($sql);
 			$current_position=Database::result($result,0,0);
@@ -886,7 +893,7 @@ abstract class Question
 	}
 
 	/**
-	 * duplicates the question
+	 * Duplicates the question
 	 *
 	 * @author - Olivier Brouckaert
 	 * @return - integer - ID of the new question
@@ -1150,8 +1157,7 @@ abstract class Question
 	static function updateId()
 	{
 		return self::$questionTypes;
-	}
-	
+	}	
 }
 endif;
-?>
+?>

+ 57 - 22
main/exercice/question_pool.php

@@ -13,9 +13,9 @@
 // name of the language file that needs to be included
 $language_file='exercice';
 
-include('exercise.class.php');
-include('question.class.php');
-include('answer.class.php');
+require_once 'exercise.class.php';
+require_once 'question.class.php';
+require_once 'answer.class.php';
 require_once '../inc/global.inc.php';
 
 $this_section=SECTION_COURSES;
@@ -49,6 +49,11 @@ if(!empty($_GET['page'])){
 	$page = intval($_GET['page']);
 }
 
+$copy_question = 0;
+if(!empty($_GET['copy_question'])){
+	$copy_question = intval($_GET['copy_question']);
+}
+
 //only that type of question
 if(!empty($_GET['type'])){
 	$type = intval($_GET['type']);
@@ -63,23 +68,51 @@ $documentPath=api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
 // picture path
 $picturePath=$documentPath.'/images';
 
-
-if(!($objExcercise instanceOf Exercise) && !empty($fromExercise))
-{
+if(!($objExcercise instanceOf Exercise) && !empty($fromExercise)) {
     $objExercise = new Exercise();
     $objExercise->read($fromExercise);
 }
-if(!($objExcercise instanceOf Exercise) && !empty($exerciseId))
-{
+if(!($objExcercise instanceOf Exercise) && !empty($exerciseId)) {
     $objExercise = new Exercise();
     $objExercise->read($exerciseId);
 }
 
-if($is_allowedToEdit)
-{
+if($is_allowedToEdit) {
+	
+	//copy exercise 
+	if ($copy_question != 0 && isset($fromExercise)) {
+		
+		$old_question_id = $copy_question;
+		$old_question_obj = Question::read($old_question_id);
+		$old_question_obj->updateTitle($old_question_obj->selectTitle().' - '.get_lang('Copy'));
+		$new_id = $old_question_obj->duplicate();
+		
+		$new_question_obj = Question::read($new_id);			
+		$new_question_obj->addToList($fromExercise);			
+								
+		$new_answer_obj = new Answer($old_question_id);
+		$new_answer_obj->read();
+		$new_answer_obj->duplicate($new_id);
+		
+		
+		// destruction of the Question object
+		unset($new_question_obj);
+		unset($old_question_obj);
+
+        if(!$objExcercise instanceOf Exercise) {
+        	$objExercise = new Exercise();
+            $objExercise->read($fromExercise);
+        }
+		// adds the question ID represented by $recup into the list of questions for the current exercise
+		//$objExercise->addToList($new_id);
+		api_session_register('objExercise');
+		
+		header("Location: admin.php?".api_get_cidreq()."&exerciseId=$fromExercise");
+		exit();	
+	}
+	
 	// deletes a question from the data base and all exercises
-	if($delete)
-	{
+	if($delete) {
 		// construction of the Question object
 		// if the question exists
 		if($objQuestionTmp = Question::read($delete))
@@ -90,10 +123,9 @@ if($is_allowedToEdit)
 
 		// destruction of the Question object
 		unset($objQuestionTmp);
-	}
-	// gets an existing question and copies it into a new exercise
-	elseif($recup && $fromExercise)
-	{
+	} elseif($recup && $fromExercise) {
+		// gets an existing question and copies it into a new exercise
+		
 		// if the question exists
 		if($objQuestionTmp = Question :: read($recup))
 		{
@@ -162,7 +194,9 @@ if($is_allowedToEdit)
 <h3><?php echo $nameTools; ?></h3>
 
 <div class="actions">
+	
 	<?php
+	
 	if (isset($type)) {
 		$url = api_get_self().'?type=1';
 	} else {
@@ -222,8 +256,6 @@ if($is_allowedToEdit)
 		//answer type
 		if (!isset($answerType)) $answerType = -1;
 		{
-
-
 			for ($answer_type = -1; $answer_type <=9; $answer_type++) {
 				$selected ='';
 				if ($answer_type!=0) {
@@ -373,9 +405,9 @@ if($is_allowedToEdit)
 	 '<td align="right">';
 
 	if(!empty($page)) {
-	   echo '<a href="',api_get_self(),'?',api_get_cidreq(),'&exerciseId=',$exerciseId,'&fromExercise=',$fromExercise,'&page=',($page-1),'">&lt;&lt; ',get_lang('PreviousPage'),'</a> |';
+	   echo '<a href="',api_get_self(),'?',api_get_cidreq(),'&exerciseId=',$exerciseId,'&fromExercise=',$fromExercise,'&page=',($page-1),'">&lt;&lt; ',get_lang('PreviousPage'),'</a> | ';
 	} elseif($nbrQuestions > $limitQuestPage) {
-	   echo '&lt;&lt; ',get_lang('PreviousPage'),' |';
+	   echo '&lt;&lt; ',get_lang('PreviousPage'),' | ';
 	}
 
 	if($nbrQuestions > $limitQuestPage) {
@@ -432,8 +464,11 @@ if($is_allowedToEdit)
                 //echo $row['level'],'</td>',
 //					'<td><a href="',api_get_self(),'?',api_get_cidreq(),'&recup=',$row['id'],'&fromExercise=',$fromExercise,'"><img src="../img/view_more_stats.gif" border="0" alt="',get_lang('Reuse'),'"></a>';
 				echo $row['level'],'</td>',
-					'<td align="center" ><a href="',api_get_self(),'?',api_get_cidreq(),'&recup=',$row['id'],'&fromExercise=',$fromExercise,'">' .
-							'<img src="../img/view_more_stats.gif" border="0" alt="',get_lang('Reuse'),'"></a>';
+					'<td align="center"><a href="',api_get_self(),'?',api_get_cidreq(),'&recup=',$row['id'],'&fromExercise=',$fromExercise,'">' .
+							'<img src="../img/view_more_stats.gif" border="0" title="'.get_lang('Reuse').'" alt="'.get_lang('Reuse').'"></a>';
+							
+					echo ' <a href="',api_get_self(),'?',api_get_cidreq(),'&copy_question=',$row['id'],'&fromExercise=',$fromExercise,'">' .
+							'<img src="../img/cd.gif" border="0" title="'.get_lang('ReUseACopyInCurrentTest').'" alt="'.get_lang('ReUseACopyInCurrentTest').'"></a>';
 			}
             echo '</td>';
             echo '</tr>';

+ 2 - 2
main/glossary/index.php

@@ -1,7 +1,7 @@
 <?php //$id: $
-/* For licensing terms, see /dokeos_license.txt */
+/* For licensing terms, see /license.txt */
 /**
- * @package dokeos.glossary
+ * @package chamilo.glossary
  * @author Christian Fasanando, initial version
  * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University, Belgium, refactoring and tighter integration in Dokeos
  */

+ 2 - 24
main/gradebook/exercise_jump.php

@@ -1,27 +1,5 @@
 <?php //$id $
-/*
-==============================================================================
-	Dokeos - elearning and course management software
-
-	Copyright (c) 2008 Dokeos Latinoamerica SAC
-	Copyright (c) 2006 Dokeos SPRL
-	Copyright (c) 2006 Ghent University (UGent)
-	Copyright (c) various contributors
-
-	For a full list of contributors, see "credits.txt".
-	The full license can be read in "license.txt".
-
-	This program is free software; you can redistribute it and/or
-	modify it under the terms of the GNU General Public License
-	as published by the Free Software Foundation; either version 2
-	of the License, or (at your option) any later version.
-
-	See the GNU General Public License for more details.
-
-	Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
-	Mail: info@dokeos.com
-==============================================================================
-*/
+/* For licensing terms, see /license.txt */
 /**
  * Sets needed course variables and then jumps to the exercises result page.
  * This intermediate page is needed because the user is not inside a course
@@ -53,7 +31,7 @@ if (isset($_GET['doexercise'])) {
 	exit;
 } else {
 	if (isset($_GET['gradebook'])) {
-		$add_url = '&gradebook=view&exerciseId='.Security::remove_XSS((int)$_GET['exerciseId']);
+		$add_url = '&gradebook=view&exerciseId='.intval($_GET['exerciseId']);
 	}
 	header('Location: ../exercice/exercice.php?cidReq='.Security::remove_XSS($cidReq).'&show=result'.$add_url);
 	exit;

+ 40 - 20
main/gradebook/gradebook.php

@@ -29,8 +29,14 @@ $cidReset= true;
 $_in_course = false;
 //make sure the destination for scripts is index.php instead of gradebook.php
 require_once '../inc/global.inc.php';
-$_SESSION['gradebook_dest'] = 'gradebook.php';
-$this_section = SECTION_MYGRADEBOOK;
+if (!empty($_GET['course'])) {
+	$_SESSION['gradebook_dest'] = 'index.php';	
+	$this_section = SECTION_COURSES;
+} else {
+	$_SESSION['gradebook_dest'] = 'gradebook.php';	
+	$this_section = SECTION_MYGRADEBOOK;
+	unset($_GET['course']);
+}
 require_once 'lib/be.inc.php';
 require_once 'lib/scoredisplay.class.php';
 require_once 'lib/gradebook_functions.inc.php';
@@ -41,6 +47,8 @@ require_once 'lib/gradebook_data_generator.class.php';
 require_once 'lib/fe/gradebooktable.class.php';
 require_once 'lib/fe/displaygradebook.php';
 require_once 'lib/fe/userform.class.php';
+require_once api_get_path(LIBRARY_PATH).'document.lib.php';
+require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
 require_once api_get_path(LIBRARY_PATH).'ezpdf/class.ezpdf.php';
 $htmlHeadXtra[] = '<script src="../inc/lib/javascript/jquery.js" type="text/javascript" language="javascript"></script>'; //jQuery
 $htmlHeadXtra[] = '<script type="text/javascript">
@@ -191,7 +199,7 @@ if (isset ($_GET['visiblecat'])) {
 	} else {
 		$visibility_command= 0;
 	}
-	$cats= Category :: load(Security::remove_XSS($_GET['visiblecat']));
+	$cats= Category :: load($_GET['visiblecat']);
 	$cats[0]->set_visible($visibility_command);
 	$cats[0]->save();
 	$cats[0]->apply_visibility_to_children();
@@ -206,7 +214,7 @@ if (isset ($_GET['visiblecat'])) {
 }
 if (isset ($_GET['deletecat'])) {
 	block_students();
-	$cats= Category :: load(Security::remove_XSS($_GET['deletecat']));
+	$cats= Category :: load($_GET['deletecat']);
 	//delete all categories,subcategories and results
 	if ($cats[0] != null) {
 		if ($cats[0]->get_id() != 0) {
@@ -226,7 +234,7 @@ if (isset ($_GET['visibleeval'])) {
 		$visibility_command= 0;
 	}
 
-	$eval= Evaluation :: load(Security::remove_XSS($_GET['visibleeval']));
+	$eval= Evaluation :: load($_GET['visibleeval']);
 	$eval[0]->set_visible($visibility_command);
 	$eval[0]->save();
 	unset ($eval);
@@ -240,7 +248,7 @@ if (isset ($_GET['visibleeval'])) {
 }
 if (isset ($_GET['deleteeval'])) {
 	block_students();
-	$eval= Evaluation :: load(Security::remove_XSS($_GET['deleteeval']));
+	$eval= Evaluation :: load($_GET['deleteeval']);
 	if ($eval[0] != null) {
 		$eval[0]->delete_with_results();
 	}
@@ -255,7 +263,7 @@ if (isset ($_GET['visiblelink'])) {
 	}else {
 		$visibility_command= 0;
 	}
-	$link= LinkFactory :: load(Security::remove_XSS($_GET['visiblelink']));
+	$link= LinkFactory :: load($_GET['visiblelink']);
 	$link[0]->set_visible($visibility_command);
 	$link[0]->save();
 	unset ($link);
@@ -271,9 +279,9 @@ if (isset ($_GET['deletelink'])) {
 	block_students();
 	//fixing #5229
 	if (!empty($_GET['deletelink'])) {	
-		$link= LinkFactory :: load(Security::remove_XSS($_GET['deletelink']));
+		$link= LinkFactory :: load($_GET['deletelink']);
 		if ($link[0] != null) {
-			$sql='UPDATE '.$tbl_forum_thread.' SET thread_qualify_max=0,thread_weight=0,thread_title_qualify="" WHERE thread_id=(SELECT ref_id FROM '.$tbl_grade_links.' where id='.Security::remove_XSS($_GET['deletelink']).');';
+			$sql='UPDATE '.$tbl_forum_thread.' SET thread_qualify_max=0,thread_weight=0,thread_title_qualify="" WHERE thread_id=(SELECT ref_id FROM '.$tbl_grade_links.' where id='.intval($_GET['deletelink']).');';
 			Database::query($sql);
 			$link[0]->delete();
 		}
@@ -418,23 +426,35 @@ if (!isset($_GET['exportpdf']) and !isset($_GET['export_certificate'])) {
 		Display :: display_header(get_lang('FlatView'));
 	}
 	elseif (isset ($_GET['search'])) {
+			
+		if ($_SESSION['gradebook_dest'] == 'index.php') {
+			$gradebook_dest = Security::remove_XSS($_SESSION['gradebook_dest']).'?cidReq='.Security::remove_XSS($_GET['course']).'&amp;';	
+		} else {
+			$gradebook_dest = Security::remove_XSS($_SESSION['gradebook_dest']);
+		}	
+		
 		$interbreadcrumb[]= array (
-			'url' => $_SESSION['gradebook_dest'].'?selectcat=' . Security::remove_XSS($_GET['selectcat']),
-			'name' => get_lang('ToolGradebook')
-		);
-		Display :: display_header(get_lang('SearchResults'));
-	} else {
-			$interbreadcrumb[]= array (
-				'url' => $_SESSION['gradebook_dest'],
-				'name' => get_lang('ToolGradebook')
-			);
+			'url' => $gradebook_dest,
+			'name' => get_lang('Gradebook')
+		);	
+			
 
 		if ((isset($_GET['selectcat']) && $_GET['selectcat']>0)) {
-			$interbreadcrumb[]= array (
+			
+			if (!empty($_GET['course'])) {
+				$interbreadcrumb[]= array (
+					'url' => $gradebook_dest.'selectcat='.Security::remove_XSS($_GET['selectcat']),
+					'name' => get_lang('Details')
+				);	
+			} else {
+				$interbreadcrumb[]= array (
 				'url' => $_SESSION['gradebook_dest'].'?selectcat=0',
 				'name' => get_lang('Details')
-			);
+				);
+			}
+	
 		}
+		
 	 Display :: display_header('');
 	}
 }

+ 2 - 5
main/gradebook/gradebook_add_cat.php

@@ -74,15 +74,12 @@ if ($form->validate()) {
 	}
 	$cat->set_visible($visible);
 	$cat->add();
-	header('Location: '.$_SESSION['gradebook_dest'].'?addcat=&selectcat=' . $cat->get_parent_id());
+	header('Location: '.Security::remove_XSS($_SESSION['gradebook_dest']).'?addcat=&selectcat=' . $cat->get_parent_id());
 	exit;
 }
 
 if ( !$_in_course ) {
-$interbreadcrumb[] = array (
-	'url' => $_SESSION['gradebook_dest'].'?selectcat='.$get_select_cat,
-	'name' => get_lang('ToolGradebook')
-	);
+	$interbreadcrumb[] = array ('url' => Security::remove_XSS($_SESSION['gradebook_dest']).'?selectcat='.$get_select_cat,'name' => get_lang('Gradebook'));
 }
 Display :: display_header(get_lang('NewCategory'));
 $form->display();

+ 5 - 27
main/gradebook/gradebook_add_eval.php

@@ -1,27 +1,5 @@
 <?php
-/*
-==============================================================================
-	Dokeos - elearning and course management software
-
-	Copyright (c) 2008 Dokeos Latinoamerica SAC
-	Copyright (c) 2006 Dokeos SPRL
-	Copyright (c) 2006 Ghent University (UGent)
-	Copyright (c) various contributors
-
-	For a full list of contributors, see "credits.txt".
-	The full license can be read in "license.txt".
-
-	This program is free software; you can redistribute it and/or
-	modify it under the terms of the GNU General Public License
-	as published by the Free Software Foundation; either version 2
-	of the License, or (at your option) any later version.
-
-	See the GNU General Public License for more details.
-
-	Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
-	Mail: info@dokeos.com
-==============================================================================
-*/
+/* For licensing terms, see /license.txt */
 $language_file = 'gradebook';
 require_once ('../inc/global.inc.php');
 require_once ('lib/be.inc.php');
@@ -35,7 +13,7 @@ $is_allowedToEdit = $is_courseAdmin;
 $evaladd = new Evaluation();
 $evaladd->set_user_id($_user['user_id']);
 if (isset ($_GET['selectcat']) && (!empty ($_GET['selectcat']))) {
-	$evaladd->set_category_id(Database::escape_string($_GET['selectcat']));
+	$evaladd->set_category_id($_GET['selectcat']);
 	$cat = Category :: load($_GET['selectcat']);
 	$evaladd->set_course_code($cat[0]->get_course_code());
 } else {
@@ -66,7 +44,7 @@ if ($form->validate()) {
 			header('Location: gradebook_add_user.php?selecteval=' . $eval->get_id());
 			exit;
 		} else {
-			header('Location: '.$_SESSION['gradebook_dest'].'?selectcat=' . $eval->get_category_id());
+			header('Location: '.Security::remove_XSS($_SESSION['gradebook_dest']).'?selectcat=' . $eval->get_category_id());
 			exit;
 		}
 	} else {
@@ -75,14 +53,14 @@ if ($form->validate()) {
 			header('Location: gradebook_add_result.php?selecteval=' . $eval->get_id());
 			exit;
 		} else {
-			header('Location: '.$_SESSION['gradebook_dest'].'?selectcat=' . $eval->get_category_id());
+			header('Location: '.Security::remove_XSS($_SESSION['gradebook_dest']).'?selectcat=' . $eval->get_category_id());
 			exit;
 		}
 	}
 }
 
 $interbreadcrumb[] = array (
-	'url' => $_SESSION['gradebook_dest'].'?selectcat='.$select_cat,
+	'url' => Security::remove_XSS($_SESSION['gradebook_dest']).'?selectcat='.$select_cat,
 	'name' => get_lang('Gradebook'
 ));
 Display :: display_header(get_lang('NewEvaluation'));

+ 6 - 33
main/gradebook/gradebook_add_link.php

@@ -1,26 +1,5 @@
 <?php
-/*
-==============================================================================
-	Dokeos - elearning and course management software
-
-	Copyright (c) 2006-2008 Dokeos SPRL
-	Copyright (c) 2006 Ghent University (UGent)
-	Copyright (c) various contributors
-
-	For a full list of contributors, see "credits.txt".
-	The full license can be read in "license.txt".
-
-	This program is free software; you can redistribute it and/or
-	modify it under the terms of the GNU General Public License
-	as published by the Free Software Foundation; either version 2
-	of the License, or (at your option) any later version.
-
-	See the GNU General Public License for more details.
-
-	Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
-	Mail: info@dokeos.com
-==============================================================================
-*/
+/* For licensing terms, see /license.txt */
 $language_file = 'gradebook';
 //$cidReset = true;
 require_once ('../inc/global.inc.php');
@@ -64,14 +43,14 @@ if (isset($_GET['typeselected']) && $_GET['typeselected'] != '0') {
 								   intval($_GET['typeselected']),
 								   null,
 								   'add_link',
-								   api_get_self() . '?selectcat=' . $_GET['selectcat']
-														. '&typeselected=' . $_GET['typeselected'] . '&course_code=' . $_GET['course_code']);
+								   api_get_self() . '?selectcat=' . Security::remove_XSS($_GET['selectcat'])
+														. '&typeselected=' . Security::remove_XSS($_GET['typeselected']) . '&course_code=' . Security::remove_XSS($_GET['course_code']));
 	if ($addform->validate()) {
 		$addvalues = $addform->exportValues();
 		$link= LinkFactory :: create($_GET['typeselected']);
 		$link->set_user_id(api_get_user_id());
 		if($category[0]->get_course_code() == '' && !empty($_GET['course_code'])) {
-			$link->set_course_code(Database::escape_string($_GET['course_code']));
+			$link->set_course_code($_GET['course_code']);
 
 		} else {
 			$link->set_course_code($category[0]->get_course_code());
@@ -98,7 +77,6 @@ if (isset($_GET['typeselected']) && $_GET['typeselected'] != '0') {
 		$work_table = Database :: get_course_table(TABLE_STUDENT_PUBLICATION);
 		if ( isset($_GET['typeselected']) && 5==$_GET['typeselected'] && (isset($addvalues['select_link']) && $addvalues['select_link']<>"")) {
 
-
 			$sql1='SELECT thread_title from '.$tbl_forum_thread.' where thread_id='.$addvalues['select_link'].';';
 			$res1=Database::query($sql1);
 			$rowtit=Database::fetch_row($res1);
@@ -121,19 +99,14 @@ if (isset($_GET['typeselected']) && $_GET['typeselected'] != '0') {
 			header('Location: gradebook_add_result.php?selecteval=' . $link->get_ref_id());
 			exit;
 		} else {
-			header('Location: '.$_SESSION['gradebook_dest'].'?linkadded=&selectcat=' . $_GET['selectcat']);
+			header('Location: '.Security::remove_XSS($_SESSION['gradebook_dest']).'?linkadded=&selectcat=' . Security::remove_XSS($_GET['selectcat']));
 			exit;
 		}
-
 	}
 }
 
 
-
-$interbreadcrumb[]= array (
-	'url' => $_SESSION['gradebook_dest'].'?selectcat=' . $_GET['selectcat'],
-	'name' => get_lang('Gradebook'
-));
+$interbreadcrumb[]= array ('url' => $_SESSION['gradebook_dest'].'?selectcat=' .Security::remove_XSS($_GET['selectcat']),'name' => get_lang('Gradebook'));
 
 Display :: display_header(get_lang('MakeLink'));
 if (isset ($typeform)) {

+ 2 - 24
main/gradebook/gradebook_add_link_select_course.php

@@ -1,27 +1,5 @@
 <?php // $Id: $
-/*
-==============================================================================
-	Dokeos - elearning and course management software
-
-	Copyright (c) 2008 Dokeos Latinoamerica SAC
-	Copyright (c) 2007 Dokeos SPRL
-	Copyright (c) 2006 Ghent University (UGent)
-	Copyright (c) various contributors
-
-	For a full list of contributors, see "credits.txt".
-	The full license can be read in "license.txt".
-
-	This program is free software; you can redistribute it and/or
-	modify it under the terms of the GNU General Public License
-	as published by the Free Software Foundation; either version 2
-	of the License, or (at your option) any later version.
-
-	See the GNU General Public License for more details.
-
-	Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
-	Mail: info@dokeos.com
-==============================================================================
-*/
+/* For licensing terms, see /license.txt */
 
 $language_file = 'gradebook';
 //$cidReset = true;
@@ -49,7 +27,7 @@ if ($form->validate()) {
 }
 
 $interbreadcrumb[] = array (
-	'url' => $_SESSION['gradebook_dest'].'?selectcat='.Security::remove_XSS($_GET['selectcat']),
+	'url' => Security::remove_XSS($_SESSION['gradebook_dest']).'?selectcat='.Security::remove_XSS($_GET['selectcat']),
 	'name' => get_lang('Gradebook'
 ));
 Display :: display_header(get_lang('NewCategory'));

+ 2 - 27
main/gradebook/gradebook_add_result.php

@@ -1,27 +1,5 @@
 <?php // $Id: $
-/*
-==============================================================================
-	Dokeos - elearning and course management software
-
-	Copyright (c) 2008 Dokeos Latinoamerica SAC
-	Copyright (c) 2006 Dokeos SPRL
-	Copyright (c) 2006 Ghent University (UGent)
-	Copyright (c) various contributors
-
-	For a full list of contributors, see "credits.txt".
-	The full license can be read in "license.txt".
-
-	This program is free software; you can redistribute it and/or
-	modify it under the terms of the GNU General Public License
-	as published by the Free Software Foundation; either version 2
-	of the License, or (at your option) any later version.
-
-	See the GNU General Public License for more details.
-
-	Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
-	Mail: info@dokeos.com
-==============================================================================
-*/
+/* For licensing terms, see /license.txt */
 $language_file = 'gradebook';
 //$cidReset = true;
 require_once ('../inc/global.inc.php');
@@ -57,10 +35,7 @@ if ($add_result_form->validate()) {
 	header('Location: gradebook_view_result.php?addresult=&selecteval=' . Security::remove_XSS($_GET['selecteval']));
 	exit;
 }
-$interbreadcrumb[] = array (
-	'url' => $_SESSION['gradebook_dest'],
-	'name' => get_lang('Gradebook'
-));
+$interbreadcrumb[] = array ('url' => Security::remove_XSS($_SESSION['gradebook_dest']),'name' => get_lang('Gradebook'));
 Display :: display_header(get_lang('AddResult'));
 DisplayGradebook :: display_header_result ($evaluation[0], null, 0,0);
 echo '<div class="main">';

+ 12 - 12
main/gradebook/gradebook_add_user.php

@@ -1,13 +1,16 @@
 <?php //$Id: gradebook_add_user.php 21153 2009-06-01 01:51:43Z yannoo $
-/* For licensing terms, see /dokeos_license.txt */
+
+/* For licensing terms, see /license.txt */
+
 $language_file = 'gradebook';
 require_once '../inc/global.inc.php';
 $this_section = SECTION_MYGRADEBOOK;
-require_once ('lib/be.inc.php');
-require_once ('lib/fe/displaygradebook.php');
-require_once ('lib/gradebook_functions.inc.php');
-require_once ('lib/fe/evalform.class.php');
-require_once ('lib/scoredisplay.class.php');
+require_once 'lib/be.inc.php';
+require_once 'lib/fe/displaygradebook.php';
+require_once 'lib/gradebook_functions.inc.php';
+require_once 'lib/fe/evalform.class.php';
+require_once 'lib/scoredisplay.class.php';
+
 api_block_anonymous_users();
 block_students();
 
@@ -23,8 +26,8 @@ $add_user_form= new EvalForm(EvalForm :: TYPE_ADD_USERS_TO_EVAL,
 							 null,
 							 'add_users_to_evaluation',
 							 null,
-							 api_get_self() . '?selecteval=' . $_GET['selecteval'],
-							 $_GET['firstletter'],
+							 api_get_self() . '?selecteval=' . Security::remove_XSS($_GET['selecteval']),
+							 Security::remove_XSS($_GET['firstletter']),
 							 $newstudents);
 
 if ( isset($_POST['submit_button']) ) {
@@ -54,10 +57,7 @@ if ( isset($_POST['submit_button']) ) {
 		}
 }
 
-$interbreadcrumb[]= array (
-	'url' => $_SESSION['gradebook_dest'],
-	'name' => get_lang('Gradebook'
-));
+$interbreadcrumb[]= array ('url' => Security::remove_XSS($_SESSION['gradebook_dest']),'name' => get_lang('Gradebook'));
 $interbreadcrumb[]= array (
 	'url' => 'gradebook_view_result.php?selecteval=' .Security::remove_XSS($_GET['selecteval']),
 	'name' => get_lang('ViewResult'

+ 86 - 0
main/gradebook/gradebook_display_certificate.php

@@ -0,0 +1,86 @@
+<?php
+/* For licensing terms, see /license.txt */
+
+$language_file = 'gradebook';
+//$cidReset = true;
+require_once '../inc/global.inc.php';
+require_once 'lib/gradebook_functions.inc.php';
+require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
+
+//extra javascript functions for in html head:
+$htmlHeadXtra[] =
+"<script language='javascript' type='text/javascript'>
+function confirmation()
+{
+	if (confirm(\" ".trim(get_lang('AreYouSureToDelete'))." ?\"))
+		{return true;}
+	else
+		{return false;} 
+}
+</script>";
+api_block_anonymous_users();
+
+if (!api_is_allowed_to_edit()) {
+	api_not_allowed(true);
+}
+$interbreadcrumb[] = array ('url' => Security::remove_XSS($_SESSION['gradebook_dest']).'?',	'name' => get_lang('Gradebook'));
+$interbreadcrumb[] = array ('url' => Security::remove_XSS($_SESSION['gradebook_dest']).'?selectcat='.Security::remove_XSS($_GET['cat_id']),'name' => get_lang('Details'));
+$interbreadcrumb[] = array ('url' => 'gradebook_display_certificate.php?cat_id='.Security::remove_XSS($_GET['cat_id']),'name' => get_lang('GradebookListOfStudentsCertificates'));
+
+Display::display_header('');
+?>
+<?php
+if (isset($_GET['user_id']) && $_GET['user_id']==strval(intval($_GET['user_id'])) && isset($_GET['cat_id']) && $_GET['cat_id']==strval(intval($_GET['cat_id']))) {
+	if($_GET['action'] == 'delete') {
+		$info=delete_certificate($_GET['cat_id'],$_GET['user_id']);
+		if ($info===true) {
+			Display::display_confirmation_message(get_lang('CertificateRemoved'));
+		} else  {
+			Display::display_error_message(get_lang('CertificateNotRemoved'));		
+		}
+	}	
+}
+?>
+<h3 class="actions" ><?php echo get_lang('GradebookListOfStudentsCertificates'); ?></h3>
+
+<table  class="data_table" border="0" width="100%" >
+	<?php
+	$cat_id=isset($_GET['cat_id']) ? (int)$_GET['cat_id'] : null;	
+	$certificate_list = get_list_users_certificates($cat_id);
+	
+	if (count($certificate_list)==0) {
+		echo get_lang('NoResultsAvailable');
+	} else {
+		foreach ($certificate_list as $index=>$value) {
+	?>
+	<tr>
+		<td width="100%" class="actions"><?php echo get_lang('Student').' : '. $value['firstname'].' '.$value['lastname'] ?>
+		</td>
+		
+	</tr>
+	<tr>
+	<td>
+	<table   class="data_table" width="100%" >
+		<?php
+		$list_certificate = get_list_gradebook_certificates_by_user_id ($value['user_id'],$cat_id);		
+		foreach ($list_certificate as $index_certificate=>$value_certificate) {
+			?>
+			<tr >
+			<td width="50%"><?php echo get_lang('Score').' : '.$value_certificate['score_certificate'] ?></td>
+			<td width="30%"><?php echo get_lang('Date').' : '.$value_certificate['date_certificate'] ?></td>
+			<td width="20%"><a  onclick="return confirmation();" href="gradebook_display_certificate.php?action=delete&<?php echo 'user_id='.$value_certificate['user_id'].'&amp;cat_id='.$value_certificate['cat_id'] ?>"><?php echo Display::return_icon('delete.gif',get_lang('Delete')); ?></a></td>
+			</tr>
+			<?php
+		}
+		?>
+		</table>
+	</td>
+	</tr>
+    <?php
+		}
+	}
+    ?>
+</table>
+<?php
+Display::display_footer();
+?>

+ 20 - 48
main/gradebook/gradebook_edit_all.php

@@ -1,75 +1,46 @@
 <?php
-/*
-==============================================================================
-	Dokeos - elearning and course management software
-
-	Copyright (c) 2006-2008 Dokeos SPRL
-	Copyright (c) 2006 Ghent University (UGent)
-	Copyright (c) various contributors
-
-	For a full list of contributors, see "credits.txt".
-	The full license can be read in "license.txt".
+/* For licensing terms, see /license.txt */
 
-	This program is free software; you can redistribute it and/or
-	modify it under the terms of the GNU General Public License
-	as published by the Free Software Foundation; either version 2
-	of the License, or (at your option) any later version.
-
-	See the GNU General Public License for more details.
-
-	Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
-	Mail: info@dokeos.com
-==============================================================================
-*/
 $language_file= 'gradebook';
 $cidReset= true;
-require_once ('../inc/global.inc.php');
+require_once '../inc/global.inc.php';
 $this_section = SECTION_MYGRADEBOOK;
-require_once ('lib/be.inc.php');
-require_once ('lib/scoredisplay.class.php');
-require_once ('lib/gradebook_functions.inc.php');
-require_once ('lib/fe/catform.class.php');
-require_once ('lib/fe/evalform.class.php');
-require_once ('lib/fe/linkform.class.php');
-require_once ('lib/gradebook_data_generator.class.php');
-require_once ('lib/fe/gradebooktable.class.php');
-require_once ('lib/fe/displaygradebook.php');
+
+require_once 'lib/be.inc.php';
+require_once 'lib/scoredisplay.class.php';
+require_once 'lib/gradebook_functions.inc.php';
+require_once 'lib/fe/catform.class.php';
+require_once 'lib/fe/evalform.class.php';
+require_once 'lib/fe/linkform.class.php';
+require_once 'lib/gradebook_data_generator.class.php';
+require_once 'lib/fe/gradebooktable.class.php';
+require_once 'lib/fe/displaygradebook.php';
 require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/gradebook_functions.inc.php';
 
 api_block_anonymous_users();
 if (!api_is_allowed_to_create_course()) {
 	header('Location: /index.php');
+	exit;
 }
 
 $my_selectcat=isset($_GET['selectcat']) ? Security::remove_XSS($_GET['selectcat']) : '';
+
 if (empty($my_selectcat)) {
 	api_not_allowed();
 }
 
-// --------------------------------------------------------------------------------
-// -                       DISPLAY HEADERS AND MESSAGES                           -
-// --------------------------------------------------------------------------------
+// 	DISPLAY HEADERS AND MESSAGES                           -
 
 if (!isset($_GET['exportpdf']) and !isset($_GET['export_certificate'])) {
 	if (isset ($_GET['studentoverview'])) {
-		$interbreadcrumb[]= array (
-			'url' => $_SESSION['gradebook_dest'].'?selectcat=' . Security::remove_XSS($_GET['selectcat']),
-			'name' => get_lang('ToolGradebook')
-		);
+		$interbreadcrumb[]= array ('url' => Security::remove_XSS($_SESSION['gradebook_dest']).'?selectcat=' . Security::remove_XSS($_GET['selectcat']),'name' => get_lang('Gradebook'));
 		Display :: display_header(get_lang('FlatView'));
 	} elseif (isset ($_GET['search'])) {
-		$interbreadcrumb[]= array (
-			'url' => $_SESSION['gradebook_dest'].'?selectcat=' . Security::remove_XSS($_GET['selectcat']),
-			'name' => get_lang('ToolGradebook')
-		);
+		$interbreadcrumb[]= array ('url' => Security::remove_XSS($_SESSION['gradebook_dest']).'?selectcat=' . Security::remove_XSS($_GET['selectcat']),'name' => get_lang('Gradebook'));
 		Display :: display_header(get_lang('SearchResults'));
 	} else {
-		$interbreadcrumb[] = array ('url' => $_SESSION['gradebook_dest'].'?selectcat=1', 'name' => get_lang('ToolGradebook'));
-
-
-		$interbreadcrumb[]= array (
-			'url' => $_SESSION['gradebook_dest'].'?&selectcat='.Security::remove_XSS($_GET['selectcat']),
-			'name' => get_lang('EditAllWeights'));
+		$interbreadcrumb[] = array ('url' => Security::remove_XSS($_SESSION['gradebook_dest']).'?selectcat=1', 'name' => get_lang('Gradebook'));
+		$interbreadcrumb[] = array ('url' => Security::remove_XSS($_SESSION['gradebook_dest']).'?&selectcat='.Security::remove_XSS($_GET['selectcat']),'name' => get_lang('EditAllWeights'));
 
 		Display :: display_header('');
 
@@ -77,6 +48,7 @@ if (!isset($_GET['exportpdf']) and !isset($_GET['export_certificate'])) {
 }
 
 
+
 $table_link = Database::get_main_table(TABLE_MAIN_GRADEBOOK_LINK);
 $table_evaluation = Database::get_main_table(TABLE_MAIN_GRADEBOOK_EVALUATION);
 //$table_forum_thread=Database::get_course_table(TABLE_FORUM_THREAD);

+ 3 - 25
main/gradebook/gradebook_edit_cat.php

@@ -1,27 +1,5 @@
 <?php // $Id:$
-/*
-==============================================================================
-	Dokeos - elearning and course management software
-
-	Copyright (c) 2008 Dokeos Latinoamerica SAC
-	Copyright (c) 2006 Dokeos SPRL
-	Copyright (c) 2006 Ghent University (UGent)
-	Copyright (c) various contributors
-
-	For a full list of contributors, see "credits.txt".
-	The full license can be read in "license.txt".
-
-	This program is free software; you can redistribute it and/or
-	modify it under the terms of the GNU General Public License
-	as published by the Free Software Foundation; either version 2
-	of the License, or (at your option) any later version.
-
-	See the GNU General Public License for more details.
-
-	Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
-	Mail: info@dokeos.com
-==============================================================================
-*/
+/* For licensing terms, see /license.txt */
 $language_file = 'gradebook';
 //$cidReset = true;
 require_once ('../inc/global.inc.php');
@@ -55,12 +33,12 @@ if ($form->validate()) {
 	}
 	$cat->set_visible($visible);
 	$cat->save();
-	header('Location: '.$_SESSION['gradebook_dest'].'?editcat=&selectcat=' . $cat->get_parent_id());
+	header('Location: '.Security::remove_XSS($_SESSION['gradebook_dest']).'?editcat=&selectcat=' . $cat->get_parent_id());
 	exit;
 }
 $selectcat = isset($_GET['selectcat']) ? Security::remove_XSS($_GET['selectcat']) : '';
 $interbreadcrumb[] = array (
-	'url' => $_SESSION['gradebook_dest'].'?selectcat='.$selectcat,
+	'url' => Security::remove_XSS($_SESSION['gradebook_dest']).'?selectcat='.$selectcat,
 	'name' => get_lang('Gradebook'
 ));
 Display :: display_header(get_lang('EditCategory'));

+ 2 - 24
main/gradebook/gradebook_edit_eval.php

@@ -1,27 +1,5 @@
 <?php // $Id: $
-/*
-==============================================================================
-	Dokeos - elearning and course management software
-
-	Copyright (c) 2008 Dokeos Latinoamerica SAC
-	Copyright (c) 2006 Dokeos SPRL
-	Copyright (c) 2006 Ghent University (UGent)
-	Copyright (c) various contributors
-
-	For a full list of contributors, see "credits.txt".
-	The full license can be read in "license.txt".
-
-	This program is free software; you can redistribute it and/or
-	modify it under the terms of the GNU General Public License
-	as published by the Free Software Foundation; either version 2
-	of the License, or (at your option) any later version.
-
-	See the GNU General Public License for more details.
-
-	Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
-	Mail: info@dokeos.com
-==============================================================================
-*/
+/* For licensing terms, see /license.txt */
 $language_file = 'gradebook';
 //$cidReset = true;
 require_once ('../inc/global.inc.php');
@@ -32,7 +10,7 @@ api_block_anonymous_users();
 block_students();
 
 $evaledit = Evaluation :: load($_GET['editeval']);
-$form = new EvalForm(EvalForm :: TYPE_EDIT, $evaledit[0], null, 'edit_eval_form',null,api_get_self() . '?editeval=' . $_GET['editeval']);
+$form = new EvalForm(EvalForm :: TYPE_EDIT, $evaledit[0], null, 'edit_eval_form',null,api_get_self() . '?editeval=' . Security::remove_XSS($_GET['editeval']));
 if ($form->validate()) {
 	$values = $form->exportValues();
 	$eval = new Evaluation();

+ 4 - 27
main/gradebook/gradebook_edit_link.php

@@ -1,25 +1,5 @@
 <?php
-/*
-==============================================================================
-	Dokeos - elearning and course management software
-
-	Copyright (c) 2006 Dokeos S.A.
-	Copyright (c) 2007 Stijn Konings, Bert Stepp� (Hogeschool Gent)
-
-	For a full list of contributors, see "credits.txt".
-	The full license can be read in "license.txt".
-
-	This program is free software; you can redistribute it and/or
-	modify it under the terms of the GNU General Public License
-	as published by the Free Software Foundation; either version 2
-	of the License, or (at your option) any later version.
-
-	See the GNU General Public License for more details.
-
-	Contact address: Dokeos, 44 rue des palais, B-1030 Brussels, Belgium
-	Mail: info@dokeos.com
-==============================================================================
-*/
+/* For licensing terms, see /license.txt */
 $language_file = array('gradebook','link');
 //$cidReset = true;
 require_once ('../inc/global.inc.php');
@@ -66,19 +46,16 @@ if ($form->validate()) {
 	}
 
 	//Update weight into forum thread
-	$sql_t='UPDATE '.$tbl_forum_thread.' SET thread_weight='.$values['weight'].' WHERE thread_id=(SELECT ref_id FROM '.$tbl_grade_links.' where id='.Security::remove_XSS($_GET['editlink']).' and type=5);';
+	$sql_t='UPDATE '.$tbl_forum_thread.' SET thread_weight='.$values['weight'].' WHERE thread_id=(SELECT ref_id FROM '.$tbl_grade_links.' where id='.intval($_GET['editlink']).' and type=5);';
 	Database::query($sql_t);
 	//Update weight into student publication(work)
-	$sql_t='UPDATE '.$tbl_work.' SET weight='.$values['weight'].' WHERE id=(SELECT ref_id FROM '.$tbl_grade_links.' where id='.Security::remove_XSS($_GET['editlink']).' and type=3);';
+	$sql_t='UPDATE '.$tbl_work.' SET weight='.$values['weight'].' WHERE id=(SELECT ref_id FROM '.$tbl_grade_links.' where id='.intval($_GET['editlink']).' and type=3);';
 	Database::query($sql_t);
 	header('Location: '.$_SESSION['gradebook_dest'].'?linkedited=&selectcat=' . $link->get_category_id());
 	exit;
 }
 
-$interbreadcrumb[] = array (
-	'url' => $_SESSION['gradebook_dest'].'?selectcat='.$linkcat,
-	'name' => get_lang('Gradebook'
-));
+$interbreadcrumb[] = array ('url' => Security::remove_XSS($_SESSION['gradebook_dest']).'?selectcat='.$linkcat,'name' => get_lang('Gradebook'));
 
 Display :: display_header(get_lang('EditLink'));
 $form->display();

+ 1 - 23
main/gradebook/gradebook_edit_result.php

@@ -1,27 +1,5 @@
 <?php // $Id: $
-/*
-==============================================================================
-	Dokeos - elearning and course management software
-
-	Copyright (c) 2008 Dokeos Latinoamerica SAC
-	Copyright (c) 2006 Dokeos SPRL
-	Copyright (c) 2006 Ghent University (UGent)
-	Copyright (c) various contributors
-
-	For a full list of contributors, see "credits.txt".
-	The full license can be read in "license.txt".
-
-	This program is free software; you can redistribute it and/or
-	modify it under the terms of the GNU General Public License
-	as published by the Free Software Foundation; either version 2
-	of the License, or (at your option) any later version.
-
-	See the GNU General Public License for more details.
-
-	Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
-	Mail: info@dokeos.com
-==============================================================================
-*/
+/* For licensing terms, see /license.txt */
 $language_file = 'gradebook';
 //$cidReset = true;
 require_once ('../inc/global.inc.php');

+ 1 - 1
main/gradebook/gradebook_flatview.php

@@ -226,7 +226,7 @@ if (isset ($_GET['exportpdf']))	{
 		$pdf =& new Cezpdf('a4',$format); //format is 'portrait' or 'landscape'
 		$clear_printable_data=array();
 		$clear_send_printable_data=array();
-		//var_dump(count($printable_data[1]));
+
 		for ($i=0;$i<count($printable_data[1]);$i++) {
 			for ($k=0;$k<count($printable_data[1][$i]);$k++) {
 				$clear_printable_data[]=strip_tags($printable_data[1][$i][$k]);

+ 1 - 17
main/gradebook/gradebook_result.class.php

@@ -1,21 +1,5 @@
 <?php
-/*
-    DOKEOS - elearning and course management software
-
-    For a full list of contributors, see documentation/credits.html
-
-    This program is free software; you can redistribute it and/or
-    modify it under the terms of the GNU General Public License
-    as published by the Free Software Foundation; either version 2
-    of the License, or (at your option) any later version.
-    See "documentation/licence.html" more details.
-
-    Contact:
-		Dokeos
-		Rue du Corbeau, 108
-		B-1030 Brussels - Belgium
-		info@dokeos.com
-*/
+/* For licensing terms, see /license.txt */
 /**
 *	ExerciseResult class: This class allows to instantiate an object of type ExerciseResult
 *	which allows you to export exercises results in multiple presentation forms

+ 1 - 23
main/gradebook/gradebook_scoring_system.php

@@ -1,27 +1,5 @@
 <?php // $Id: $
-/*
-==============================================================================
-	Dokeos - elearning and course management software
-
-	Copyright (c) 2008 Dokeos Latinoamerica SAC
-	Copyright (c) 2006 Dokeos SPRL
-	Copyright (c) 2006 Ghent University (UGent)
-	Copyright (c) various contributors
-
-	For a full list of contributors, see "credits.txt".
-	The full license can be read in "license.txt".
-
-	This program is free software; you can redistribute it and/or
-	modify it under the terms of the GNU General Public License
-	as published by the Free Software Foundation; either version 2
-	of the License, or (at your option) any later version.
-
-	See the GNU General Public License for more details.
-
-	Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
-	Mail: info@dokeos.com
-==============================================================================
-*/
+/* For licensing terms, see /license.txt */
 $language_file= 'gradebook';
 //$cidReset= true;
 require_once ('../inc/global.inc.php');

+ 1 - 23
main/gradebook/gradebook_showlog_eval.php

@@ -1,27 +1,5 @@
 <?php // $Id: $
-/*
-==============================================================================
-	Dokeos - elearning and course management software
-
-	Copyright (c) 2008 Dokeos Latinoamerica SAC
-	Copyright (c) 2006 Dokeos SPRL
-	Copyright (c) 2006 Ghent University (UGent)
-	Copyright (c) various contributors
-	Copyright (c) Isaac Flores Paz <florespaz@bidsoftperu.com>
-	For a full list of contributors, see "credits.txt".
-	The full license can be read in "license.txt".
-
-	This program is free software; you can redistribute it and/or
-	modify it under the terms of the GNU General Public License
-	as published by the Free Software Foundation; either version 2
-	of the License, or (at your option) any later version.
-
-	See the GNU General Public License for more details.
-
-	Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
-	Mail: info@dokeos.com
-==============================================================================
-*/
+/* For licensing terms, see /license.txt */
 $language_file = 'gradebook';
 //$cidReset = true;
 require_once ('../inc/global.inc.php');

+ 9 - 39
main/gradebook/gradebook_showlog_link.php

@@ -1,49 +1,19 @@
 <?php // $Id: $
-/*
-==============================================================================
-	Dokeos - elearning and course management software
-
-	Copyright (c) 2008 Dokeos Latinoamerica SAC
-	Copyright (c) 2006 Dokeos SPRL
-	Copyright (c) 2006 Ghent University (UGent)
-	Copyright (c) various contributors
-	Copyright (c) Isaac Flores Paz <florespaz@bidsoftperu.com>
-	For a full list of contributors, see "credits.txt".
-	The full license can be read in "license.txt".
-
-	This program is free software; you can redistribute it and/or
-	modify it under the terms of the GNU General Public License
-	as published by the Free Software Foundation; either version 2
-	of the License, or (at your option) any later version.
-
-	See the GNU General Public License for more details.
-
-	Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
-	Mail: info@dokeos.com
-==============================================================================
-*/
+/* For licensing terms, see /license.txt */
 $language_file = 'gradebook';
 //$cidReset = true;
-require_once ('../inc/global.inc.php');
-require_once ('lib/be.inc.php');
-require_once ('lib/gradebook_functions.inc.php');
-require_once ('lib/fe/evalform.class.php');
+require_once '../inc/global.inc.php';
+require_once 'lib/be.inc.php';
+require_once 'lib/gradebook_functions.inc.php';
+require_once 'lib/fe/evalform.class.php';
+
 api_block_anonymous_users();
 block_students();
 
-$interbreadcrumb[] = array (
-	'url' => $_SESSION['gradebook_dest'].'?',
-	'name' => get_lang('Gradebook'
-));
-$interbreadcrumb[] = array (
-	'url' => $_SESSION['gradebook_dest'].'?selectcat='.Security::remove_XSS($_GET['selectcat']),
-	'name' => get_lang('Details'
-));
+$interbreadcrumb[] = array ('url' => Security::remove_XSS($_SESSION['gradebook_dest']).'?','name' => get_lang('Gradebook'));
+$interbreadcrumb[] = array ('url' => Security::remove_XSS($_SESSION['gradebook_dest']).'?selectcat='.Security::remove_XSS($_GET['selectcat']),'name' => get_lang('Details'));
+$interbreadcrumb[] = array ('url' => 'gradebook_showlog_link.php?visiblelink='.Security::remove_XSS($_GET['visiblelink']).'&amp;selectcat='.Security::remove_XSS($_GET['selectcat']),	'name' => get_lang('GradebookQualifyLog'));
 
-$interbreadcrumb[] = array (
-	'url' => 'gradebook_showlog_link.php?visiblelink='.Security::remove_XSS($_GET['visiblelink']).'&amp;selectcat='.Security::remove_XSS($_GET['selectcat']),
-	'name' => get_lang('GradebookQualifyLog')
-);
 Display :: display_header('');
 echo '<div class="clear"></div>';
 echo '<div class="actions">';

+ 1 - 23
main/gradebook/gradebook_statistics.php

@@ -1,27 +1,5 @@
 <?php // $Id: $
-/*
-==============================================================================
-	Dokeos - elearning and course management software
-
-	Copyright (c) 2008 Dokeos Latinoamerica SAC
-	Copyright (c) 2006 Dokeos SPRL
-	Copyright (c) 2006 Ghent University (UGent)
-	Copyright (c) various contributors
-
-	For a full list of contributors, see "credits.txt".
-	The full license can be read in "license.txt".
-
-	This program is free software; you can redistribute it and/or
-	modify it under the terms of the GNU General Public License
-	as published by the Free Software Foundation; either version 2
-	of the License, or (at your option) any later version.
-
-	See the GNU General Public License for more details.
-
-	Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
-	Mail: info@dokeos.com
-==============================================================================
-*/
+/* For licensing terms, see /license.txt */
 $language_file= 'gradebook';
 //$cidReset= true;
 require_once ('../inc/global.inc.php');

+ 1 - 23
main/gradebook/gradebook_view_result.php

@@ -1,27 +1,5 @@
 <?php // $Id: $
-/*
-==============================================================================
-	Dokeos - elearning and course management software
-
-	Copyright (c) 2008 Dokeos Latinoamerica SAC
-	Copyright (c) 2006 Dokeos SPRL
-	Copyright (c) 2006 Ghent University (UGent)
-	Copyright (c) various contributors
-
-	For a full list of contributors, see "credits.txt".
-	The full license can be read in "license.txt".
-
-	This program is free software; you can redistribute it and/or
-	modify it under the terms of the GNU General Public License
-	as published by the Free Software Foundation; either version 2
-	of the License, or (at your option) any later version.
-
-	See the GNU General Public License for more details.
-
-	Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
-	Mail: info@dokeos.com
-==============================================================================
-*/
+/* For licensing terms, see /license.txt */
 $language_file[] = 'gradebook';
 //$cidReset= true;
 require_once ('../inc/global.inc.php');

+ 96 - 41
main/gradebook/index.php

@@ -1,27 +1,5 @@
 <?php // $Id: $
-/*
-==============================================================================
-	Dokeos - elearning and course management software
-
-    Copyright (c) 2008 Dokeos Latinoamerica SAC
-	Copyright (c) 2006-2008 Dokeos SPRL
-	Copyright (c) 2006 Ghent University (UGent)
-	Copyright (c) various contributors
-
-	For a full list of contributors, see "credits.txt".
-	The full license can be read in "license.txt".
-
-	This program is free software; you can redistribute it and/or
-	modify it under the terms of the GNU General Public License
-	as published by the Free Software Foundation; either version 2
-	of the License, or (at your option) any later version.
-
-	See the GNU General Public License for more details.
-
-	Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
-	Mail: info@dokeos.com
-==============================================================================
-*/
+/* For licensing terms, see /license.txt */
 $language_file= 'gradebook';
 // $cidReset : This is the main difference with gradebook.php, here we say,
 // basically, that we are inside a course, and many things depend from that
@@ -37,6 +15,7 @@ if (isset($_GET['cidReq'])) {
 } else {
 	$this_section = SECTION_MYGRADEBOOK;
 }
+
 require_once 'lib/be.inc.php';
 require_once 'lib/scoredisplay.class.php';
 require_once 'lib/gradebook_functions.inc.php';
@@ -48,6 +27,8 @@ require_once 'lib/fe/gradebooktable.class.php';
 require_once 'lib/fe/displaygradebook.php';
 require_once 'lib/fe/userform.class.php';
 require_once api_get_path(LIBRARY_PATH).'ezpdf/class.ezpdf.php';
+require_once api_get_path(LIBRARY_PATH).'document.lib.php';
+require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
 
 $htmlHeadXtra[] = '<script src="../inc/lib/javascript/jquery.js" type="text/javascript" language="javascript"></script>'; //jQuery
 $htmlHeadXtra[] = '<script type="text/javascript">
@@ -139,9 +120,7 @@ if ( (isset($_GET['selectcat']) && $_GET['selectcat']>0) && (isset($_SESSION['st
 }
 
 
-// --------------------------------------------------------------------------------
-// -                                  ACTIONS                                     -
-// --------------------------------------------------------------------------------
+// ACTIONS                                   
 //this is called when there is no data for the course admin
 if (isset ($_GET['createallcategories'])) {
 	block_students();
@@ -470,9 +449,7 @@ if (isset ($_POST['submit']) && isset ($_POST['keyword'])) {
 }
 
 
-// --------------------------------------------------------------------------------
-// -                       DISPLAY HEADERS AND MESSAGES                           -
-// --------------------------------------------------------------------------------
+// DISPLAY HEADERS AND MESSAGES                          
 
 if (!isset($_GET['exportpdf']) and !isset($_GET['export_certificate'])) {
 	if (isset ($_GET['studentoverview'])) {
@@ -492,6 +469,13 @@ if (!isset($_GET['exportpdf']) and !isset($_GET['export_certificate'])) {
 			'url' => $_SESSION['gradebook_dest'],
 			'name' => get_lang('ToolGradebook')
 		);
+		
+			if (!isset($_GET['gradebooklist_direction'])) {
+				$interbreadcrumb[]= array (
+			    'url' => $_SESSION['gradebook_dest'].'?selectcat=' . Security::remove_XSS($_GET['selectcat']),
+			    'name' => get_lang('Details')
+			  );
+			}
 
 		Display :: display_header('');
 	} else {
@@ -552,9 +536,7 @@ if (isset ($move_form)){
 	Display :: display_normal_message($move_form->toHtml(),false);
 }
 
-// --------------------------------------------------------------------------------
-// -                        LOAD DATA & DISPLAY TABLE                             -
-// --------------------------------------------------------------------------------
+// LOAD DATA & DISPLAY TABLE                             
 
 $is_platform_admin= api_is_platform_admin();
 $is_course_admin= api_is_allowed_to_create_course();
@@ -633,6 +615,7 @@ if (isset ($_GET['studentoverview'])) {
 		$scoretotal= $cattotal[0]->calc_score($user_id);
 		$scoretotal_display = (isset($scoretotal) ? $scoredisplay->display_score($scoretotal,SCORE_PERCENT) : get_lang('NoResultsAvailable'));
 
+		global $charset;
 		//prepare all necessary variables:
 		$organization_name = api_get_setting('Institution');
 		$portal_name = api_get_setting('siteName');
@@ -640,9 +623,81 @@ if (isset ($_GET['studentoverview'])) {
 		$stud_ln = $user['lastname'];
 		$certif_text = sprintf(get_lang('CertificateWCertifiesStudentXFinishedCourseYWithGradeZ'),$organization_name,$stud_fn.' '.$stud_ln,$category[0]->get_name(),$scorecourse_display);
 		$certif_text = str_replace("\\n","\n",$certif_text);
-		$date = api_convert_and_format_date(null, DATE_FORMAT_SHORT);
-
-		$pdf= new Cezpdf('a4','landscape');
+		$date = date('d/m/Y',time());
+
+			$path_info= UserManager::get_user_picture_path_by_id($user_id,'system',true);
+			
+			$path_directory_user_certificate=$path_info['dir'].'certificate/';
+			
+			if (!is_dir($path_info['dir'])) {
+				mkdir($path_info['dir'],0777);
+			}	
+			if (!is_dir($path_directory_user_certificate)) {
+				mkdir($path_directory_user_certificate,0777);
+			}
+			if (is_dir($path_directory_user_certificate)) {
+				$user_id=api_get_user_id();
+				$cat_id=$_GET['cat_id'];
+				$name=md5($user_id.$cat_id);
+				
+				//generate document HTML
+				$course_id=api_get_course_id();
+				$content_html=DocumentManager::replace_user_info_into_html($course_id);
+								
+				$new_content=explode('</head>',$content_html);
+				
+		
+				if ($new_content[0]!='') {
+			
+					$new_content_html=$new_content[1];
+					$my_path_certificate=$path_directory_user_certificate.$name.'.html';
+				 	
+					
+					$path_image=api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document/images/gallery';
+					$new_content_html=str_replace('../images/gallery',$path_image,$new_content_html);
+					
+					$path_image_in_default_course=api_get_path(WEB_CODE_PATH).'default_course_document';
+					$new_content_html=str_replace('/main/default_course_document',$path_image_in_default_course,$new_content_html);
+		
+					$path_image_in_dokeos_main=api_get_path(WEB_IMG_PATH);
+					$new_content_html=str_replace('/main/img/',$path_image_in_dokeos_main,$new_content_html);
+					
+					//add print header
+					$print= '
+					<style media="print" type="text/css">
+						#imprimir {
+						visibility:hidden;
+						}				
+					</style>';
+					$print ='<a href="javascript:window.print();" style="float:right; padding:4px;" id="imprimir"><img src="'.api_get_path(WEB_CODE_PATH).'img/printmgr.gif" alt="' . get_lang('Print') . '" /> ' . get_lang('Print') . '</a>';
+
+					//add header
+					$new_content_html=$new_content[0].$print.'</head>'.$new_content_html;
+					
+					if ($cat_id=strval(intval($cat_id))) {
+						if (UserManager::is_user_certified($cat_id,$user_id)===true){ 
+							header('Content-Type: text/html; charset='. $charset);
+							echo $new_content_html;
+							
+							exit;
+						} else {
+							$my_new_content_html=$new_content_html;
+							$my_new_content_html=mb_convert_encoding($my_new_content_html,'UTF-8',$charset);
+							file_put_contents($my_path_certificate,$my_new_content_html);	
+							header('Content-Type: text/html; charset='. $charset);
+							echo $new_content_html;								
+						}
+						$path_certificate='/'.$name.'.html';
+						update_user_info_about_certificate($cat_id,$user_id,$path_certificate);
+						exit;	
+					}
+				} else {
+					Display :: display_reduced_header();
+					Display :: display_warning_message(get_lang('NoCertificateAvailable'));	
+				}
+			}
+		
+		/*$pdf= new Cezpdf('a4','landscape');
 		$pdf->selectFont(api_get_path(LIBRARY_PATH).'ezpdf/fonts/Courier.afm');
 		$pdf->ezSetMargins(30, 30, 50, 50);
 		//line Y coordinates in landscape mode are upside down (500 is on top, 10 is on the bottom)
@@ -806,14 +861,14 @@ if ($category != '0') {
 			$scoretotal= $cattotal[0]->calc_score(api_get_user_id());
 			$scoretotal_display = (isset($scoretotal)? round($scoretotal[0],2).'/'.round($scoretotal[1],2).'('.round(($scoretotal[0] / $scoretotal[1]) * 100,2) . ' %)': '-');
 
+			$my_score_in_gradebook =  round($scoretotal[0],2);	
 			//show certificate
 			$certificate_min_score=$cats[0]->get_certificate_min_score();
-			if (isset($certificate_min_score) && (int)$item_value >= (int)$certificate_min_score) {
-				$certificates = '<a href="'.api_get_path(WEB_CODE_PATH) .'gradebook/'.$_SESSION['gradebook_dest'].'?export_certificate=yes&cat_id='.$cats[0]->get_course_code().'"><img src="'.api_get_path(WEB_CODE_PATH) . 'img/dokeos.gif" />'.get_lang('Certificates').'</a>&nbsp;'.get_lang('langTotal').': '.$scoretotal_display;
-
-			echo '<div class="actions" align="right">';
-			 echo $certificates;
-			echo '</div>';
+			if (isset($certificate_min_score) && (int)$item_value >= (int)$certificate_min_score) {				
+				$certificates = '<a href="'.api_get_path(WEB_CODE_PATH) .'gradebook/'.Security::remove_XSS($_SESSION['gradebook_dest']).'?export_certificate=yes&cat_id='.$cats[0]->get_id().'"><img src="'.api_get_path(WEB_CODE_PATH) . 'img/dokeos.gif" />'.get_lang('Certificates').'</a>&nbsp;'.get_lang('langTotal').': '.$scoretotal_display;
+				echo '<div class="actions" align="right">';
+				echo $certificates;
+				echo '</div>';
 
 			}
 		} //end hack

+ 1 - 23
main/gradebook/lib/be.inc.php

@@ -1,27 +1,5 @@
 <?php
-/*
-==============================================================================
-	Dokeos - elearning and course management software
-
-	Copyright (c) 2008 Dokeos Latinoamerica SAC
-	Copyright (c) 2006 Dokeos SPRL
-	Copyright (c) 2006 Ghent University (UGent)
-	Copyright (c) various contributors
-
-	For a full list of contributors, see "credits.txt".
-	The full license can be read in "license.txt".
-
-	This program is free software; you can redistribute it and/or
-	modify it under the terms of the GNU General Public License
-	as published by the Free Software Foundation; either version 2
-	of the License, or (at your option) any later version.
-
-	See the GNU General Public License for more details.
-
-	Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
-	Mail: info@dokeos.com
-==============================================================================
-*/
+/* For licensing terms, see /license.txt */
 // include this file to have access to all backend classes
 // @author Bert Steppé
 require_once ('be/gradebookitem.class.php');

+ 38 - 55
main/gradebook/lib/be/abstractlink.class.php

@@ -1,34 +1,13 @@
 <?php
-/*
-==============================================================================
-	Dokeos - elearning and course management software
-
-	Copyright (c) 2008 Dokeos Latinoamerica SAC
-	Copyright (c) 2006 Dokeos SPRL
-	Copyright (c) 2006 Ghent University (UGent)
-	Copyright (c) various contributors
-
-	For a full list of contributors, see "credits.txt".
-	The full license can be read in "license.txt".
-
-	This program is free software; you can redistribute it and/or
-	modify it under the terms of the GNU General Public License
-	as published by the Free Software Foundation; either version 2
-	of the License, or (at your option) any later version.
-
-	See the GNU General Public License for more details.
-
-	Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
-	Mail: info@dokeos.com
-==============================================================================
-*/
+/* For licensing terms, see /license.txt */
 /**
  * Defines a gradebook AbstractLink object.
  * To implement specific links,
  * extend this class and define a type in LinkFactory.
  * Use the methods in LinkFactory to create link objects.
  * @author Bert Steppé
- * @package dokeos.gradebook
+ * @author Julio Montoya <gugli100@gmail.com> security improvements
+ * @package chamilo.gradebook
  */
 abstract class AbstractLink implements GradebookItem
 {
@@ -136,19 +115,19 @@ abstract class AbstractLink implements GradebookItem
 		$sql='SELECT id,type,ref_id,user_id,course_code,category_id,created_at,weight,visible FROM '.$tbl_grade_links;
 		$paramcount = 0;
 		if (isset ($id)) {
-			$sql.= ' WHERE id = '.$id;
+			$sql.= ' WHERE id = '.Database::escape_string($id);
 			$paramcount ++;
 		}
 		if (isset ($type)) {
 			if ($paramcount != 0) $sql .= ' AND';
 			else $sql .= ' WHERE';
-			$sql .= ' type = '.$type;
+			$sql .= ' type = '.Database::escape_string($type);
 			$paramcount ++;
 		}
 		if (isset ($ref_id)) {
 			if ($paramcount != 0) $sql .= ' AND';
 			else $sql .= ' WHERE';
-			$sql .= ' ref_id = '.$ref_id;
+			$sql .= ' ref_id = '.intval($ref_id);
 			$paramcount ++;
 		}
 		if (isset ($user_id)) {
@@ -157,7 +136,7 @@ abstract class AbstractLink implements GradebookItem
 			}else {
 			 $sql .= ' WHERE';
 			}
-			$sql .= ' user_id = '.$user_id;
+			$sql .= ' user_id = '.intval($user_id);
 			$paramcount ++;
 		}
 		if (isset ($course_code)) {
@@ -166,7 +145,7 @@ abstract class AbstractLink implements GradebookItem
 			} else {
 			 $sql .= ' WHERE';
 			}
-			$sql .= " course_code = '".$course_code."'";
+			$sql .= " course_code = '".Database::escape_string($course_code)."'";
 			$paramcount ++;
 		}
 		if (isset ($category_id)) {
@@ -175,7 +154,7 @@ abstract class AbstractLink implements GradebookItem
 			}else {
 			 	$sql .= ' WHERE';
 			}
-			$sql .= ' category_id = '.$category_id;
+			$sql .= ' category_id = '.intval($category_id);
 			$paramcount ++;
 		}
 		if (isset ($visible)) {
@@ -184,7 +163,7 @@ abstract class AbstractLink implements GradebookItem
 			} else {
 				 $sql .= ' WHERE';
 			}
-			$sql .= ' visible = '.$visible;
+			$sql .= ' visible = '.intval($visible);
 			$paramcount ++;
 		}
 
@@ -227,20 +206,21 @@ abstract class AbstractLink implements GradebookItem
 			$result_testing=Database::query($sql_testing);
 			$row_testing=Database::fetch_array($result_testing);
 
-			if ($row_testing[0]==0) {
-				$sql = 'INSERT INTO '.$tbl_grade_links.' (type,ref_id,user_id,course_code,category_id,weight,visible,created_at';
-					$sql .= ') VALUES ('
-						.$this->get_type()
-						.','.$this->get_ref_id()
-						.','.$this->get_user_id()
-						.",'".$this->get_course_code()."'"
-						.','.$this->get_category_id()
-						.','.$this->get_weight()
-						.','.$this->is_visible()
-						.",'".api_get_utc_datetime()."')";
-				echo $sql;
-			Database::query($sql);
-			$this->set_id(Database::insert_id());
+						if ($row_testing[0]==0) {
+				$sql = 'INSERT INTO '.$tbl_grade_links.' (type,ref_id,user_id,course_code,category_id,weight,visible';
+				if (isset($this->link_date)) { $sql .= ',date';}
+				$sql .= ') VALUES ('
+					.intval($this->get_type())
+					.','.intval($this->get_ref_id())
+					.','.intval($this->get_user_id())
+					.",'".Database::escape_string($this->get_course_code())."'"
+					.','.intval($this->get_category_id())
+					.','.intval($this->get_weight())
+					.','.intval($this->is_visible());
+				if (isset($this->link_date)) {$sql .= ','.'"'.$date_current=strtotime(date('Y-m-d H:i:s',time())).'"';}
+				$sql .= ")";
+				Database::query($sql);
+				$this->set_id(Database::insert_id());
 		 	}
 		} else {
 			die('Error in AbstractLink add: required field empty');
@@ -255,14 +235,15 @@ abstract class AbstractLink implements GradebookItem
 
 		$tbl_grade_links = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINK);
 		$sql = 'UPDATE '.$tbl_grade_links
-				.' SET type = '.$this->get_type()
-				.', ref_id = '.$this->get_ref_id()
-				.', user_id = '.$this->get_user_id()
-				.", course_code = '".$this->get_course_code()."'"
-				.', category_id = '.$this->get_category_id();
-		$sql .= ', weight = '.$this->get_weight()
-				.', visible = '.$this->is_visible()
-				.' WHERE id = '.$this->id;
+			.' SET type = '.intval($this->get_type())
+				.', ref_id = '.intval($this->get_ref_id())
+				.', user_id = '.intval($this->get_user_id())
+				.", course_code = '".Database::escape_string($this->get_course_code())."'"
+				.', category_id = '.intval($this->get_category_id());
+		$sql .= ', weight = '.intval($this->get_weight())
+				.', visible = '.intval($this->is_visible())
+				.' WHERE id = '.intval($this->id);
+	
 		AbstractLink::add_link_log($this->id);
 		Database::query($sql);
 	}
@@ -281,7 +262,9 @@ abstract class AbstractLink implements GradebookItem
 			$name_log=$arreval['course_code'];
 		}
 		//error_log($name_log);
-		$sql="INSERT INTO ".$tbl_grade_linkeval_log."(id_linkeval_log,name,description,created_at,weight,visible,type,user_id_log)VALUES('".Database::escape_string($arreval['id'])."','".Database::escape_string($name_log)."','".Database::escape_string($description_log)."','".$current_date_server."','".Database::escape_string($arreval['weight'])."','".Database::escape_string($arreval['visible'])."','Link',".api_get_user_id().")";
+		$sql="INSERT INTO ".$tbl_grade_linkeval_log."(id_linkeval_log,name,description,date_log,weight,visible,type,user_id_log)
+			  VALUES('".Database::escape_string($arreval['id'])."','".Database::escape_string($name_log)."','".Database::escape_string($description_log)."','".Database::escape_string($current_date_server)."','".Database::escape_string($arreval['weight'])."','".Database::escape_string($arreval['visible'])."','Link',".api_get_user_id().")";
+	
 		Database::query($sql);
 
 	}
@@ -293,7 +276,7 @@ abstract class AbstractLink implements GradebookItem
 		$this->delete_linked_data();
 
 		$tbl_grade_links = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINK);
-		$sql = 'DELETE FROM '.$tbl_grade_links.' WHERE id = '.$this->id;
+		$sql = 'DELETE FROM '.$tbl_grade_links.' WHERE id = '.intval($this->id);
 		Database::query($sql);
 	}
 

+ 10 - 10
main/gradebook/lib/be/attendancelink.class.php

@@ -3,7 +3,7 @@
 /**
  * Gradebook link to attendance item
  * @author Christian Fasanando (christian1827@gmail.com)
- * @package dokeos.gradebook
+ * @package chamilo.gradebook
  */
 class AttendanceLink extends AbstractLink
 {
@@ -44,7 +44,7 @@ class AttendanceLink extends AbstractLink
 
 		$sql = 'SELECT att.id, att.name, att.attendance_qualify_title
 				FROM '.$this->get_attendance_table().' att
-				WHERE att.id NOT IN (SELECT ref_id FROM '.$tbl_grade_links.' WHERE type = '.LINK_ATTENDANCE.' AND course_code = "'.$this->get_course_code().'")
+				WHERE att.id NOT IN (SELECT ref_id FROM '.$tbl_grade_links.' WHERE type = '.LINK_ATTENDANCE.' AND course_code = "'.Database::escape_string($this->get_course_code()).'")
 				AND att.session_id='.api_get_session_id().'';
 		$result = Database::query($sql);
 
@@ -69,7 +69,7 @@ class AttendanceLink extends AbstractLink
     	}
     	$tbl_attendance = $this->get_attendance_table();
     	$session_id = api_get_session_id();
-    	$sql = 'SELECT att.id, att.name, att.attendance_qualify_title FROM '.$tbl_attendance.' att WHERE att.active = 1 AND att.session_id = '.$session_id.'';
+    	$sql = 'SELECT att.id, att.name, att.attendance_qualify_title FROM '.$tbl_attendance.' att WHERE att.active = 1 AND att.session_id = '.intval($session_id).'';
 		$result = Database::query($sql);
 		while ($data=Database::fetch_array($result)) {
 			if (isset($data['attendance_qualify_title']) && $data['attendance_qualify_title'] != ''){
@@ -89,7 +89,7 @@ class AttendanceLink extends AbstractLink
     public function has_results() {
     	$course_info = api_get_course_info($this->course_code);
     	$tbl_attendance_result = Database :: get_course_table(TABLE_ATTENDANCE_RESULT,$course_info['dbName']);
-		$sql = 'SELECT count(*) AS number FROM '.$tbl_attendance_result." WHERE attendance_id = '".$this->get_ref_id()."'";
+		$sql = 'SELECT count(*) AS number FROM '.$tbl_attendance_result." WHERE attendance_id = '".intval($this->get_ref_id())."'";
     	$result = Database::query($sql);
 		$number = Database::fetch_row($result);
 		return ($number[0] != 0);
@@ -104,14 +104,14 @@ class AttendanceLink extends AbstractLink
 			$session_id = api_get_session_id();
 
 			// get attendance qualify max
-	  		$sql = 'SELECT att.attendance_qualify_max FROM '.$this->get_attendance_table().' att WHERE att.id = '.$this->get_ref_id().' AND att.session_id='.$session_id.'';
+	  		$sql = 'SELECT att.attendance_qualify_max FROM '.$this->get_attendance_table().' att WHERE att.id = '.intval($this->get_ref_id()).' AND att.session_id='.intval($session_id).'';
 			$query = Database::query($sql);
 			$attendance = Database::fetch_array($query);
 
 			// get results
-	  	    $sql = 'SELECT * FROM '.$tbl_attendance_result.' WHERE attendance_id = '.$this->get_ref_id();
+	  	    $sql = 'SELECT * FROM '.$tbl_attendance_result.' WHERE attendance_id = '.intval($this->get_ref_id());
 	    	if (isset($stud_id)) {
-	    		$sql .= ' AND user_id = '.$stud_id;
+	    		$sql .= ' AND user_id = '.intval($stud_id);
 	    	}
 	    	$scores = Database::query($sql);
 			// for 1 student
@@ -208,7 +208,7 @@ class AttendanceLink extends AbstractLink
     public function is_valid_link() {
     	$session_id = api_get_session_id();
         $sql = 'SELECT count(att.id) FROM '.$this->get_attendance_table().' att
-        		 WHERE att.id = '.$this->get_ref_id().' AND att.session_id='.$session_id.'';
+        		 WHERE att.id = '.intval($this->get_ref_id()).' AND att.session_id='.intval($session_id).'';
         $result = Database::query($sql);
         $number = Database::fetch_row($result);
         return ($number[0] != 0);
@@ -224,7 +224,7 @@ class AttendanceLink extends AbstractLink
    		$session_id = api_get_session_id();
    		if ($tbl_name != '') {
     	$sql = 'SELECT * FROM '.$this->get_attendance_table().' att
-    			WHERE att.id = '.$this->get_ref_id().' AND att.session_id = '.$session_id.' ';
+    			WHERE att.id = '.intval($this->get_ref_id()).' AND att.session_id = '.intval($session_id).' ';
 		$result = Database::query($sql);
 		$row    = Database::fetch_array($result,'ASSOC');
 		$attendance_id = $row['id'];
@@ -239,7 +239,7 @@ class AttendanceLink extends AbstractLink
 		if ($tbl_name == '') {
 			return false;
 		} elseif (!isset($this->attendance_data)) {
-			$sql = 'SELECT * FROM '.$this->get_attendance_table().' att WHERE att.id = '.$this->get_ref_id().' AND att.session_id='.$session_id.'';
+			$sql = 'SELECT * FROM '.$this->get_attendance_table().' att WHERE att.id = '.intval($this->get_ref_id()).' AND att.session_id='.intval($session_id).'';
 			$query = Database::query($sql);
 			$this->attendance_data = Database::fetch_array($query);
     	}

+ 11 - 29
main/gradebook/lib/be/category.class.php

@@ -1,33 +1,10 @@
 <?php
-/*
-==============================================================================
-	Dokeos - elearning and course management software
-
-	Copyright (c) 2008 Dokeos Latinoamerica SAC
-	Copyright (c) 2006 Dokeos SPRL
-	Copyright (c) 2006 Ghent University (UGent)
-	Copyright (c) various contributors
-
-	For a full list of contributors, see "credits.txt".
-	The full license can be read in "license.txt".
-
-	This program is free software; you can redistribute it and/or
-	modify it under the terms of the GNU General Public License
-	as published by the Free Software Foundation; either version 2
-	of the License, or (at your option) any later version.
-
-	See the GNU General Public License for more details.
-
-	Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
-	Mail: info@dokeos.com
-==============================================================================
-*/
+/* For licensing terms, see /license.txt */
 /**
  * Defines a gradebook Category object
- * @author Bert Stepp�, Stijn Konings
- * @author Isaac flores, <florespaz@bidsoftperu.com>
- * @package dokeos.gradebook
+ * @package chamilo.gradebook
  */
+ 
 class Category implements GradebookItem
 {
 
@@ -133,6 +110,11 @@ class Category implements GradebookItem
 	public function set_visible ($visible) {
 		$this->visible = $visible;
 	}
+	
+	public function get_type()
+	{
+		return 'category';
+	}
 
 
 // CRUD FUNCTIONS
@@ -161,11 +143,11 @@ class Category implements GradebookItem
 		$paramcount = 0;
 		if (isset($id)) {
 			$id = Database::escape_string($id);
-			$sql.= ' WHERE id = '.$id;
+			$sql.= ' WHERE id = '.intval($id);
 			$paramcount ++;
 		}
 		if (isset($user_id)) {
-			$user_id = Database::escape_string($user_id);
+			$user_id = intval($user_id);
 			if ($paramcount != 0) { $sql .= ' AND';
 			} else {
 			$sql .= ' WHERE';
@@ -1025,7 +1007,7 @@ class Category implements GradebookItem
 		}
 
 		// 1 student
- 		if (isset($stud_id)) {
+		if (isset($stud_id) && !empty($stud_id)) {
 			// special case: this is the root
 			if ($this->id == 0) {
 				$evals = Evaluation::get_evaluations_with_result_for_student(0,$stud_id);

+ 3 - 25
main/gradebook/lib/be/dropboxlink.class.php

@@ -1,31 +1,9 @@
 <?php
-/*
-==============================================================================
-	Dokeos - elearning and course management software
-
-	Copyright (c) 2008 Dokeos Latinoamerica SAC
-	Copyright (c) 2006 Dokeos SPRL
-	Copyright (c) 2006 Ghent University (UGent)
-	Copyright (c) various contributors
-
-	For a full list of contributors, see "credits.txt".
-	The full license can be read in "license.txt".
-
-	This program is free software; you can redistribute it and/or
-	modify it under the terms of the GNU General Public License
-	as published by the Free Software Foundation; either version 2
-	of the License, or (at your option) any later version.
-
-	See the GNU General Public License for more details.
-
-	Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
-	Mail: info@dokeos.com
-==============================================================================
-*/
+/* For licensing terms, see /license.txt */
 /**
  * Gradebook link to dropbox item
  * @author Bert Steppé
- * @package dokeos.gradebook
+ * @package chamilo.gradebook
  */
 class DropboxLink extends EvalLink
 {
@@ -51,7 +29,7 @@ class DropboxLink extends EvalLink
 
 		$sql = 'SELECT filename'
 				.' FROM '.$this->get_dropbox_table()
-				.' WHERE uploader_id = '.$stud_id
+				.' WHERE uploader_id = '.intval($stud_id)
 				." AND title = '".Database::escape_string($eval->get_name())."'";
 
 		$result = Database::query($sql);

+ 2 - 24
main/gradebook/lib/be/evallink.class.php

@@ -1,31 +1,9 @@
 <?php
-/*
-==============================================================================
-	Dokeos - elearning and course management software
-
-	Copyright (c) 2008 Dokeos Latinoamerica SAC
-	Copyright (c) 2006 Dokeos SPRL
-	Copyright (c) 2006 Ghent University (UGent)
-	Copyright (c) various contributors
-
-	For a full list of contributors, see "credits.txt".
-	The full license can be read in "license.txt".
-
-	This program is free software; you can redistribute it and/or
-	modify it under the terms of the GNU General Public License
-	as published by the Free Software Foundation; either version 2
-	of the License, or (at your option) any later version.
-
-	See the GNU General Public License for more details.
-
-	Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
-	Mail: info@dokeos.com
-==============================================================================
-*/
+/* For licensing terms, see /license.txt */
 /**
  * Class to be used as basis for links referring to Evaluation objects.
  * @author Bert Steppé
- * @package dokeos.gradebook
+ * @package chamilo.gradebook
  */
 abstract class EvalLink extends AbstractLink
 {

+ 28 - 32
main/gradebook/lib/be/evaluation.class.php

@@ -1,31 +1,8 @@
 <?php
-/*
-==============================================================================
-	Dokeos - elearning and course management software
-
-	Copyright (c) 2008 Dokeos Latinoamerica SAC
-	Copyright (c) 2006 Dokeos SPRL
-	Copyright (c) 2006 Ghent University (UGent)
-	Copyright (c) various contributors
-
-	For a full list of contributors, see "credits.txt".
-	The full license can be read in "license.txt".
-
-	This program is free software; you can redistribute it and/or
-	modify it under the terms of the GNU General Public License
-	as published by the Free Software Foundation; either version 2
-	of the License, or (at your option) any later version.
-
-	See the GNU General Public License for more details.
-
-	Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
-	Mail: info@dokeos.com
-==============================================================================
-*/
+/* For licensing terms, see /license.txt */
 /**
  * Defines a gradebook Evaluation object
- * @author Bert Stepp�, Stijn Konings
- * @package dokeos.gradebook
+ * @package chamilo.gradebook
  */
 class Evaluation implements GradebookItem
 {
@@ -85,6 +62,10 @@ class Evaluation implements GradebookItem
 	public function get_max() {
 		return $this->eval_max;
 	}
+	
+	public function get_type() {
+		return $this->type;
+	}	
 
 	public function is_visible() {
 		return $this->visible;
@@ -131,6 +112,12 @@ class Evaluation implements GradebookItem
 	}
 
 
+	
+    public function set_type ($type) {
+		$this->type = $type;
+	}
+    
+    
 // CRUD FUNCTIONS
 
 	/**
@@ -144,34 +131,34 @@ class Evaluation implements GradebookItem
 	public function load ($id = null, $user_id = null, $course_code = null, $category_id = null, $visible = null)
 	{
     	$tbl_grade_evaluations = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_EVALUATION);
-		$sql='SELECT id,name,description,user_id,course_code,category_id,created_at,weight,max,visible FROM '.$tbl_grade_evaluations;
+		$sql='SELECT id,name,description,user_id,course_code,category_id,date,weight,max,visible,type FROM '.$tbl_grade_evaluations;
 		$paramcount = 0;
 		if (isset ($id)) {
-			$sql.= ' WHERE id = '.$id;
+			$sql.= ' WHERE id = '.intval($id);
 			$paramcount ++;
 		}
 		if (isset ($user_id)) {
 			if ($paramcount != 0) $sql .= ' AND';
 			else $sql .= ' WHERE';
-			$sql .= ' user_id = '.$user_id;
+			$sql .= ' user_id = '.intval($user_id);
 			$paramcount ++;
 		}
-		if (isset ($course_code)) {
+		if (isset ($course_code) && $course_code <> '-1') {
 			if ($paramcount != 0) $sql .= ' AND';
 			else $sql .= ' WHERE';
-			$sql .= " course_code = '".$course_code."'";
+			$sql .= " course_code = '".Database::escape_string($course_code)."'";
 			$paramcount ++;
 		}
 		if (isset ($category_id)) {
 			if ($paramcount != 0) $sql .= ' AND';
 			else $sql .= ' WHERE';
-			$sql .= ' category_id = '.$category_id;
+			$sql .= ' category_id = '.intval($category_id);
 			$paramcount ++;
 		}
 		if (isset ($visible)) {
 			if ($paramcount != 0) $sql .= ' AND';
 			else $sql .= ' WHERE';
-			$sql .= ' visible = '.$visible;
+			$sql .= ' visible = '.intval($visible);
 			$paramcount ++;
 		}
 
@@ -195,6 +182,8 @@ class Evaluation implements GradebookItem
 			$eval->set_weight($data['weight']);
 			$eval->set_max($data['max']);
 			$eval->set_visible($data['visible']);
+			$eval->set_type($data['type']);
+			
 			$alleval[]=$eval;
 		}
 		return $alleval;
@@ -220,6 +209,7 @@ class Evaluation implements GradebookItem
 			 $sql .= ',category_id';
 			}
 			$sql .= ',created_at';
+			$sql .= ',type';
 			$sql .= ") VALUES ('".Database::escape_string(Security::remove_XSS($this->get_name()))."'"
 					.','.$this->get_user_id()
 					.','.$this->get_weight()
@@ -234,6 +224,12 @@ class Evaluation implements GradebookItem
 			if (isset($this->category)) {
 				 $sql .= ','.$this->get_category_id();
 			}
+if (empty($this->type))
+			{
+				$this->type = 'evaluation';	
+			}
+			$sql .= ',\''.$this->type.'\'';
+
 			$sql .= ", '".api_get_utc_datetime()."'";
 			$sql .= ")";
 			Database::query($sql);

+ 2 - 24
main/gradebook/lib/be/exerciselink.class.php

@@ -1,31 +1,9 @@
 <?php
-/*
-==============================================================================
-	Dokeos - elearning and course management software
-
-	Copyright (c) 2008 Dokeos Latinoamerica SAC
-	Copyright (c) 2006 Dokeos SPRL
-	Copyright (c) 2006 Ghent University (UGent)
-	Copyright (c) various contributors
-
-	For a full list of contributors, see "credits.txt".
-	The full license can be read in "license.txt".
-
-	This program is free software; you can redistribute it and/or
-	modify it under the terms of the GNU General Public License
-	as published by the Free Software Foundation; either version 2
-	of the License, or (at your option) any later version.
-
-	See the GNU General Public License for more details.
-
-	Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
-	Mail: info@dokeos.com
-==============================================================================
-*/
+/* For licensing terms, see /license.txt */
 /**
  * Defines a gradebook ExerciseLink object.
  * @author Bert Steppé
- * @package dokeos.gradebook
+ * @package chamilo.gradebook
  */
 class ExerciseLink extends AbstractLink
 {

+ 2 - 24
main/gradebook/lib/be/forumthreadlink.class.php

@@ -1,31 +1,9 @@
 <?php
-/*
-==============================================================================
-	Dokeos - elearning and course management software
-
-	Copyright (c) 2008 Dokeos Latinoamerica SAC
-	Copyright (c) 2006 Dokeos SPRL
-	Copyright (c) 2006 Ghent University (UGent)
-	Copyright (c) various contributors
-
-	For a full list of contributors, see "credits.txt".
-	The full license can be read in "license.txt".
-
-	This program is free software; you can redistribute it and/or
-	modify it under the terms of the GNU General Public License
-	as published by the Free Software Foundation; either version 2
-	of the License, or (at your option) any later version.
-
-	See the GNU General Public License for more details.
-
-	Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
-	Mail: info@dokeos.com
-==============================================================================
-*/
+/* For licensing terms, see /license.txt */
 /**
  * Gradebook link to student publication item
  * @author Bert Steppé
- * @package dokeos.gradebook
+ * @package chamilo.gradebook
  */
 class ForumThreadLink extends AbstractLink
 {

+ 2 - 23
main/gradebook/lib/be/gradebookitem.class.php

@@ -1,30 +1,9 @@
 <?php
-/*
-==============================================================================
-	Dokeos - elearning and course management software
-
-	Copyright (c) 2008 Dokeos Latinoamerica SAC
-	Copyright (c) 2006 Dokeos SPRL
-	Copyright (c) 2006 Ghent University (UGent)
-	Copyright (c) various contributors
-
-	For a full list of contributors, see "credits.txt".
-	The full license can be read in "license.txt".
-
-	This program is free software; you can redistribute it and/or
-	modify it under the terms of the GNU General Public License
-	as published by the Free Software Foundation; either version 2
-	of the License, or (at your option) any later version.
-
-	See the GNU General Public License for more details.
-
-	Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
-	Mail: info@dokeos.com
-==============================================================================
-*/
+/* For licensing terms, see /license.txt */
 /**
  * Interface for all displayable items in the gradebook.
  * @author Bert Steppé
+ * @package chamilo.gradebook
  */
 interface GradebookItem
 {

+ 2 - 24
main/gradebook/lib/be/learnpathlink.class.php

@@ -1,32 +1,10 @@
 <?php
-/*
-==============================================================================
-	Dokeos - elearning and course management software
-
-	Copyright (c) 2008 Dokeos Latinoamerica SAC
-	Copyright (c) 2006 Dokeos SPRL
-	Copyright (c) 2006 Ghent University (UGent)
-	Copyright (c) various contributors
-
-	For a full list of contributors, see "credits.txt".
-	The full license can be read in "license.txt".
-
-	This program is free software; you can redistribute it and/or
-	modify it under the terms of the GNU General Public License
-	as published by the Free Software Foundation; either version 2
-	of the License, or (at your option) any later version.
-
-	See the GNU General Public License for more details.
-
-	Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
-	Mail: info@dokeos.com
-==============================================================================
-*/
+/* For licensing terms, see /license.txt */
 /**
  * Defines a gradebook LearnpathLink object.
  * @author Yannick Warnier <yannick.warnier@dokeos.com>
  * @author Bert Steppé
- * @package dokeos.gradebook
+ * @package chamilo.gradebook
  */
 class LearnpathLink extends AbstractLink
 {

+ 3 - 24
main/gradebook/lib/be/linkfactory.class.php

@@ -1,33 +1,12 @@
 <?php
-/*
-==============================================================================
-	Dokeos - elearning and course management software
+/* For licensing terms, see /license.txt */
 
-	Copyright (c) 2008 Dokeos Latinoamerica SAC
-	Copyright (c) 2006 Dokeos SPRL
-	Copyright (c) 2006 Ghent University (UGent)
-	Copyright (c) various contributors
-
-	For a full list of contributors, see "credits.txt".
-	The full license can be read in "license.txt".
-
-	This program is free software; you can redistribute it and/or
-	modify it under the terms of the GNU General Public License
-	as published by the Free Software Foundation; either version 2
-	of the License, or (at your option) any later version.
-
-	See the GNU General Public License for more details.
-
-	Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
-	Mail: info@dokeos.com
-==============================================================================
-*/
 // To add your new link type here:
 // - define a unique type id
 // - add include
 // - change create() and get_all_types()
 // Please do not change existing values, they are used in the database !
-define('LINK_EXERCISE',1);
+define('LINK_EXERCISE',		1);
 define('LINK_DROPBOX',2);
 define('LINK_STUDENTPUBLICATION',3);
 define('LINK_LEARNPATH',4);
@@ -46,7 +25,7 @@ require_once 'attendancelink.class.php';
 /**
  * Factory for link objects
  * @author Bert Steppé
- * @package dokeos.gradebook
+ * @package chamilo.gradebook
  */
 class LinkFactory
 {

+ 2 - 24
main/gradebook/lib/be/result.class.php

@@ -1,31 +1,9 @@
 <?php
-/*
-==============================================================================
-	Dokeos - elearning and course management software
-
-	Copyright (c) 2008 Dokeos Latinoamerica SAC
-	Copyright (c) 2006 Dokeos SPRL
-	Copyright (c) 2006 Ghent University (UGent)
-	Copyright (c) various contributors
-
-	For a full list of contributors, see "credits.txt".
-	The full license can be read in "license.txt".
-
-	This program is free software; you can redistribute it and/or
-	modify it under the terms of the GNU General Public License
-	as published by the Free Software Foundation; either version 2
-	of the License, or (at your option) any later version.
-
-	See the GNU General Public License for more details.
-
-	Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
-	Mail: info@dokeos.com
-==============================================================================
-*/
+/* For licensing terms, see /license.txt */
 /**
  * Defines a gradebook Result object
  * @author Bert Steppé, Stijn Konings
- * @package dokeos.gradebook
+ * @package chamilo.gradebook
  */
 class Result
 {

+ 2 - 24
main/gradebook/lib/be/studentpublicationlink.class.php

@@ -1,31 +1,9 @@
 <?php
-/*
-==============================================================================
-	Dokeos - elearning and course management software
-
-	Copyright (c) 2008 Dokeos Latinoamerica SAC
-	Copyright (c) 2006 Dokeos SPRL
-	Copyright (c) 2006 Ghent University (UGent)
-	Copyright (c) various contributors
-
-	For a full list of contributors, see "credits.txt".
-	The full license can be read in "license.txt".
-
-	This program is free software; you can redistribute it and/or
-	modify it under the terms of the GNU General Public License
-	as published by the Free Software Foundation; either version 2
-	of the License, or (at your option) any later version.
-
-	See the GNU General Public License for more details.
-
-	Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
-	Mail: info@dokeos.com
-==============================================================================
-*/
+/* For licensing terms, see /license.txt */
 /**
  * Gradebook link to student publication item
  * @author Bert Steppé
- * @package dokeos.gradebook
+ * @package chamilo.gradebook
  */
 class StudentPublicationLink extends AbstractLink
 {

+ 1 - 23
main/gradebook/lib/fe/catform.class.php

@@ -1,27 +1,5 @@
 <?php
-/*
-==============================================================================
-	Dokeos - elearning and course management software
-
-	Copyright (c) 2008 Dokeos Latinoamerica SAC
-	Copyright (c) 2006 Dokeos SPRL
-	Copyright (c) 2006 Ghent University (UGent)
-	Copyright (c) various contributors
-
-	For a full list of contributors, see "credits.txt".
-	The full license can be read in "license.txt".
-
-	This program is free software; you can redistribute it and/or
-	modify it under the terms of the GNU General Public License
-	as published by the Free Software Foundation; either version 2
-	of the License, or (at your option) any later version.
-
-	See the GNU General Public License for more details.
-
-	Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
-	Mail: info@dokeos.com
-==============================================================================
-*/
+/* For licensing terms, see /license.txt */
 require_once (dirname(__FILE__).'/../../../inc/global.inc.php');
 require_once (dirname(__FILE__).'/../be.inc.php');
 require_once (api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php');

+ 2 - 24
main/gradebook/lib/fe/dataform.class.php

@@ -1,27 +1,5 @@
 <?php
-/*
-==============================================================================
-	Dokeos - elearning and course management software
-
-	Copyright (c) 2008 Dokeos Latinoamerica SAC
-	Copyright (c) 2006 Dokeos SPRL
-	Copyright (c) 2006 Ghent University (UGent)
-	Copyright (c) various contributors
-
-	For a full list of contributors, see "credits.txt".
-	The full license can be read in "license.txt".
-
-	This program is free software; you can redistribute it and/or
-	modify it under the terms of the GNU General Public License
-	as published by the Free Software Foundation; either version 2
-	of the License, or (at your option) any later version.
-
-	See the GNU General Public License for more details.
-
-	Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
-	Mail: info@dokeos.com
-==============================================================================
-*/
+/* For licensing terms, see /license.txt */
 require_once (dirname(__FILE__).'/../../../inc/global.inc.php');
 require_once (dirname(__FILE__).'/../be.inc.php');
 require_once (dirname(__FILE__).'/../gradebook_functions.inc.php');
@@ -71,7 +49,7 @@ class DataForm extends FormValidator {
 		$this->addElement('static','label','',get_lang('ChooseOrientation'));
 		$this->addElement('radio', 'orientation', null, get_lang('Portrait'), 'portrait');
 		$this->addElement('radio', 'orientation', null, get_lang('Landscape'), 'landscape');
-		$this->addElement('submit', 'submit', get_lang('Ok'));
+		$this->addElement('style_submit_button', 'submit', get_lang('Ok'), 'class="save"');
 		$this->setDefaults(array (
 			'orientation' => 'portrait'
 		));

+ 8 - 27
main/gradebook/lib/fe/displaygradebook.php

@@ -1,27 +1,5 @@
 <?php
-/*
-==============================================================================
-	Dokeos - elearning and course management software
-
-	Copyright (c) 2008 Dokeos Latinoamerica SAC
-	Copyright (c) 2006 Dokeos SPRL
-	Copyright (c) 2006 Ghent University (UGent)
-	Copyright (c) various contributors
-
-	For a full list of contributors, see "credits.txt".
-	The full license can be read in "license.txt".
-
-	This program is free software; you can redistribute it and/or
-	modify it under the terms of the GNU General Public License
-	as published by the Free Software Foundation; either version 2
-	of the License, or (at your option) any later version.
-
-	See the GNU General Public License for more details.
-
-	Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
-	Mail: info@dokeos.com
-==============================================================================
-*/
+/* For licensing terms, see /license.txt */
 class DisplayGradebook
 {
 	/**
@@ -35,7 +13,7 @@ class DisplayGradebook
 		$status=CourseManager::get_user_in_course_status(api_get_user_id(), api_get_course_id());
 		if ($shownavbar == '1' && $status==1) {
 			$header = '<div class="actions">';
-			$header .= '<a href="'.$_SESSION['gradebook_dest'].'?selectcat=' . $selectcat . '">'. Display::return_icon(('back.png'),get_lang('FolderView')) . get_lang('FolderView') . '</a>';
+			$header .= '<a href="'.Security::remove_XSS($_SESSION['gradebook_dest']).'?selectcat=' . $selectcat . '">'. Display::return_icon(('back.png'),get_lang('FolderView')) . get_lang('FolderView') . '</a>';
 			if ($evalobj->get_course_code() == null) {
 				$header .= '<a href="gradebook_add_user.php?selecteval=' . $evalobj->get_id() . '"><img src="../img/add_user_big.gif" alt="' . get_lang('AddStudent') . '" align="absmiddle" /> ' . get_lang('AddStudent') . '</a>';
 			}
@@ -93,7 +71,7 @@ class DisplayGradebook
 	*/
 	function display_header_flatview($catobj, $showeval, $showlink,$simple_search_form) {
 		$header= '<table border="0" cellpadding="5">';
-		$header .= '<td style="vertical-align: top;"><a href="'.$_SESSION['gradebook_dest'].'?selectcat=' . Security::remove_XSS($_GET['selectcat']) . '">' . Display::return_icon('gradebook.gif') . get_lang('Gradebook') . '</a></td>';
+		$header .= '<td style="vertical-align: top;"><a href="'.Security::remove_XSS($_SESSION['gradebook_dest']).'?selectcat=' . Security::remove_XSS($_GET['selectcat']) . '">' . Display::return_icon('gradebook.gif') . get_lang('Gradebook') . '</a></td>';
 		$header .= '<td style="vertical-align: top;">' . get_lang('FilterCategory') . '</td><td style="vertical-align: top;"><form name="selector"><select name="selectcat" onchange="document.selector.submit()">';
 		$cats= Category :: load();
 		$tree= $cats[0]->get_tree();
@@ -135,7 +113,7 @@ class DisplayGradebook
 	*/
 	function display_header_reduce_flatview($catobj, $showeval, $showlink,$simple_search_form) {
 		$header = '<div class="actions">';		
-		$header .= '<a href="'.$_SESSION['gradebook_dest'].'?'.api_get_cidreq().'">'. Display::return_icon('back.png',get_lang('FolderView')) . get_lang('FolderView') . '</a>';
+		$header .= '<a href="'.Security::remove_XSS($_SESSION['gradebook_dest']).'?'.api_get_cidreq().'">'. Display::return_icon('back.png',get_lang('FolderView')) . get_lang('FolderView') . '</a>';
 //		$header .= '<td style="vertical-align: top;"><a href="' . api_get_self() . '?exportpdf=&offset='.Security::remove_XSS($_GET['offset']).'&search=' . Security::remove_XSS($_GET['search']).'&selectcat=' . $catobj->get_id() . '"><img src=../img/file_pdf.gif alt=' . get_lang('ExportPDF') . '/> ' . get_lang('ExportPDF') . '</a>';
 
 		// this MUST be a GET variable not a POST
@@ -320,13 +298,16 @@ class DisplayGradebook
 
                 if ($message_resource===false ) {
                 	$myname=$catobj->shows_all_information_an_category($catobj->get_id());
-                 	$header .= '<td><a href="gradebook_edit_all.php?id_session='.$_SESSION['id_session'].'&amp;'.$my_api_cidreq.'&selectcat=' . $catobj->get_id() . '">'.Display::return_icon('statistics.gif', get_lang('EditAllWeights')).' ' . get_lang('EditAllWeights') . '</a>';
+                 	$header .= '<td><a href="gradebook_edit_all.php?id_session='.intval($_SESSION['id_session']).'&amp;'.$my_api_cidreq.'&selectcat=' . $catobj->get_id() . '">'.Display::return_icon('statistics.gif', get_lang('EditAllWeights')).' ' . get_lang('EditAllWeights') . '</a>';
                 	$my_course_id=api_get_course_id();
                 	$my_file= substr($_SESSION['gradebook_dest'],0,5);
                 	if (($my_file!='index' || $status_user==1) || api_is_platform_admin()) {
 	                	$header .= '<td style="vertical-align: top;"><a href="gradebook_flatview.php?'.$my_api_cidreq.'&selectcat=' . $catobj->get_id() . '">'.Display::return_icon('stats_access.gif', get_lang('FlatView')).' ' . get_lang('FlatView') . '</a>';
 						if (/*($is_course_admin && $message_resource===false && $status_user==1) ||*/ api_is_platform_admin()) {
 							$header .= '<td style="vertical-align: top;"><a href="gradebook_scoring_system.php?'.$my_api_cidreq.'&selectcat=' . $catobj->get_id() .'">'.Display::return_icon('acces_tool.gif', get_lang('ScoreEdit')).' ' . get_lang('ScoreEdit') . '</a>';
+							$header .= '<td style="vertical-align: top;"><a href="../document/document.php?curdirpath=/certificates&'.$my_api_cidreq.'&origin=gradebook&selectcat=' . $catobj->get_id() . '">'.Display::return_icon('acces_tool.gif', get_lang('AttachCertificate')).' ' . get_lang('AttachCertificate') . '</a>';
+							$header .= '<td style="vertical-align: top;"><a href="gradebook_display_certificate.php?'.$my_api_cidreq.'&amp;cat_id='.(int)$_GET['selectcat'].'">'.Display::return_icon('acces_tool.gif', get_lang('Certificate')).' ' . get_lang('GradebookSeeListOfStudentsCertificates') . '</a>';
+					
 						}
 					}
                 }

+ 1 - 23
main/gradebook/lib/fe/evalform.class.php

@@ -1,27 +1,5 @@
 <?php
-/*
-==============================================================================
-	Dokeos - elearning and course management software
-
-	Copyright (c) 2008 Dokeos Latinoamerica SAC
-	Copyright (c) 2006 Dokeos SPRL
-	Copyright (c) 2006 Ghent University (UGent)
-	Copyright (c) various contributors
-
-	For a full list of contributors, see "credits.txt".
-	The full license can be read in "license.txt".
-
-	This program is free software; you can redistribute it and/or
-	modify it under the terms of the GNU General Public License
-	as published by the Free Software Foundation; either version 2
-	of the License, or (at your option) any later version.
-
-	See the GNU General Public License for more details.
-
-	Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
-	Mail: info@dokeos.com
-==============================================================================
-*/
+/* For licensing terms, see /license.txt */
 require_once (dirname(__FILE__).'/../../../inc/global.inc.php');
 require_once (dirname(__FILE__).'/../be.inc.php');
 require_once (dirname(__FILE__).'/../gradebook_functions.inc.php');

+ 1 - 23
main/gradebook/lib/fe/exportgradebook.php

@@ -1,27 +1,5 @@
 <?php
-/*
-==============================================================================
-	Dokeos - elearning and course management software
-
-	Copyright (c) 2008 Dokeos Latinoamerica SAC
-	Copyright (c) 2006 Dokeos SPRL
-	Copyright (c) 2006 Ghent University (UGent)
-	Copyright (c) various contributors
-
-	For a full list of contributors, see "credits.txt".
-	The full license can be read in "license.txt".
-
-	This program is free software; you can redistribute it and/or
-	modify it under the terms of the GNU General Public License
-	as published by the Free Software Foundation; either version 2
-	of the License, or (at your option) any later version.
-
-	See the GNU General Public License for more details.
-
-	Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
-	Mail: info@dokeos.com
-==============================================================================
-*/
+/* For licensing terms, see /license.txt */
 /**
  * Prints an HTML page with a table containing the gradebook data
  * @param	array 	Array containing the data to be printed in the table

+ 1 - 23
main/gradebook/lib/fe/flatviewtable.class.php

@@ -1,27 +1,5 @@
 <?php
-/*
-==============================================================================
-	Dokeos - elearning and course management software
-
-	Copyright (c) 2009 Dokeos Latinoamerica SAC
-	Copyright (c) 2006 Dokeos SPRL
-	Copyright (c) 2006 Ghent University (UGent)
-	Copyright (c) various contributors
-
-	For a full list of contributors, see "credits.txt".
-	The full license can be read in "license.txt".
-
-	This program is free software; you can redistribute it and/or
-	modify it under the terms of the GNU General Public License
-	as published by the Free Software Foundation; either version 2
-	of the License, or (at your option) any later version.
-
-	See the GNU General Public License for more details.
-
-	Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
-	Mail: info@dokeos.com
-==============================================================================
-*/
+/* For licensing terms, see /license.txt */
 require_once (dirname(__FILE__).'/../../../inc/global.inc.php');
 require_once (dirname(__FILE__).'/../be.inc.php');
 set_time_limit(0);

+ 144 - 43
main/gradebook/lib/fe/gradebooktable.class.php

@@ -1,25 +1,5 @@
 <?php
-/*
-==============================================================================
-	Dokeos - elearning and course management software
-
-	Copyright (c) 2008 Dokeos SPRL
-
-	For a full list of contributors, see "credits.txt".
-	The full license can be read in "license.txt".
-
-	This program is free software; you can redistribute it and/or
-	modify it under the terms of the GNU General Public License
-	as published by the Free Software Foundation; either version 2
-	of the License, or (at your option) any later version.
-
-	See the GNU General Public License for more details.
-
-	Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
-	Mail: info@dokeos.com
-==============================================================================
-*/
-
+/* For licensing terms, see license.txt */
 
 require_once (dirname(__FILE__).'/../../../inc/global.inc.php');
 require_once (dirname(__FILE__).'/../be.inc.php');
@@ -28,7 +8,7 @@ require_once (dirname(__FILE__).'/../be.inc.php');
  * Table to display categories, evaluations and links
  * @author Stijn Konings
  * @author Bert Steppé (refactored, optimised)
- * @author Isaac flores (refactored, optimised)
+ * 
  */
 class GradebookTable extends SortableTable
 {
@@ -137,15 +117,16 @@ class GradebookTable extends SortableTable
 		$course_code=api_get_course_id();
 		$status_user=api_get_status_of_user_in_course ($user_id,$course_code);
 		$data_array = $this->datagen->get_data($sorting, $from, $this->per_page);
-		//error_log(print_r($data_array,true));
 		// generate the data to display
 		$sortable_data = array();
+		$weight_total_links = 0;		
+		
 		foreach ($data_array as $data) {
 			$row = array ();
 			$item = $data[0];
 			$id = $item->get_id();
-			if (empty($_GET['selectcat'])) {
-			$certificate_min_score = $this->build_certificate_min_score($item);
+			if (empty($_GET['selectcat']) ) {
+				$certificate_min_score = $this->build_certificate_min_score($item);
 			}
 			//if the item is invisible, wrap it in a span with class invisible
 			$invisibility_span_open = (api_is_allowed_to_create_course() && $item->is_visible() == '0') ? '<span class="invisible">' : '';
@@ -155,12 +136,12 @@ class GradebookTable extends SortableTable
 				$row[] = $this->build_id_column ($item);
 			}
 
-			//$row[] = $this->build_id_column ($item);
 			$row[] = $this->build_type_column ($item);
 			$row[] = $invisibility_span_open . $this->build_name_link ($item) . $invisibility_span_close;
 			$row[] = $invisibility_span_open . $data[2] . $invisibility_span_close;
 			if (($status_user==1 || is_null($status_user)) && api_is_allowed_to_create_course()) {
-			$row[] = $invisibility_span_open . $data[3] . $invisibility_span_close;
+				$row[] = $invisibility_span_open . $data[3] . $invisibility_span_close;
+				$weight_total_links += intval($data[3]);
 			} else {
 
 				if (empty($_GET['selectcat'])) {
@@ -185,39 +166,132 @@ class GradebookTable extends SortableTable
 					$scoretotal= $cattotal[0]->calc_score(api_get_user_id());
 					$scoretotal_display = (isset($scoretotal)? round($scoretotal[0],2).'/'.round($scoretotal[1],2).'('.round(($scoretotal[0] / $scoretotal[1]) * 100,2) . ' %)': '-');
 					$row[] = $item_value;
+					
 				} else {
 			   		$row[] = $invisibility_span_open . $data[3] . $invisibility_span_close;
 			   	}
 			}
 				$row[] = $invisibility_span_open . str_replace(' ','&nbsp;',$data[4]) . $invisibility_span_close;
-
+			
 			//admins get an edit column
 			if (($status_user==1 || is_null($status_user)) && api_is_allowed_to_create_course() && ($_SESSION['studentview']<>'studentview' || (isset($_GET['isStudentView']) && $_GET['isStudentView']=='false'))) {
 				$cat=new Category();
-				$show_message=$cat->show_message_resource_delete($item->get_course_code());
-
+				$show_message=$cat->show_message_resource_delete($item->get_course_code());				
 				if ($show_message===false) {
 					$row[] = $this->build_edit_column ($item);
 				}
-
-			} else {
-			//students get the results and certificates columns
+			} else {				
+				//students get the results and certificates columns				
 				if (count($this->evals_links)>0 && $status_user!=1 ) {
 					$value_data=isset($data[5]) ? $data[5] : null;
 					if (!is_null($value_data)) {
 						$row[] = $value_data;
 					}
 				}
+				//variables load in index.php
+				global $my_score_in_gradebook, $certificate_min_score, $item_value, $certificate_min_score;
+				
 				if (empty($_GET['selectcat'])) {
-					if (isset($certificate_min_score) && (int)$item_value >= (int)$certificate_min_score) {
-						$certificates = '<a href="'.api_get_path(WEB_CODE_PATH) .'gradebook/'.$_SESSION['gradebook_dest'].'?export_certificate=yes&cat_id='.$id.'"><img src="'.api_get_path(WEB_CODE_PATH) . 'img/dokeos.gif" /></a>&nbsp;'.$scoretotal_display;
+					if (isset($certificate_min_score) && (int)$item_value >= (int)$certificate_min_score) {						
+						$certificates = '<a href="'.api_get_path(WEB_CODE_PATH) .'gradebook/'.$_SESSION['gradebook_dest'].'?export_certificate=yes&cat_id='.$id.'" target="_blank">
+										 <img src="'.api_get_path(WEB_CODE_PATH) . 'img/dokeos.gif" /></a>&nbsp;'.$scoretotal_display;
+						
+						//register gradebook certificate
+						$current_user_id=api_get_user_id();
+						$date_certificate=date('Y-m-d H:i:s',time());
+						register_user_info_about_certificate($id,$current_user_id,$my_score_in_gradebook,$date_certificate); 	
+					
 					} else {
 						$certificates = '-';
 					}
-				$row[] = $certificates;
+					//show certificate date
+					$get_date=get_certificate_date_by_user_id($id,$current_user_id);
+					if ($get_date=='' || is_null($get_date)) {					
+							$row[4]='-';					
+					} else {					
+							$row[4] = date('d/m/y H:i:s',strtotime($get_date));						
+					}				
+					$row[] = $certificates;
+				} elseif ($_GET['selectcat'] == 1) {
+					if (isset($certificate_min_score) && (int)$item_value >= (int)$certificate_min_score) {		
+						//register gradebook certificate
+						$current_user_id=api_get_user_id();
+						$date_certificate=date('Y-m-d H:i:s',time());						
+						register_user_info_about_certificate($id,$current_user_id,$my_score_in_gradebook,$date_certificate);
+					} 
+					
 				}
 			}
 			$sortable_data[] = $row;
+		}	
+		
+		// warning messages		
+		
+		if (api_is_allowed_to_edit()) {
+						
+			if (isset($_GET['selectcat']) && $_GET['selectcat'] > 0 && $_GET['view'] <> 'presence') {		
+				$id_cat = intval($_GET['selectcat']);			
+				$category = Category :: load($id_cat);
+				$weight_category = intval($this->build_weight($category[0]));
+				$course_code = $this->build_course_code($category[0]);
+														
+				if ($weight_total_links > $weight_category) {
+					$warning_message = get_lang('TotalWeightMustNotBeMoreThan').'&nbsp;'.$weight_category;
+					Display::display_warning_message($warning_message,false);				
+				}
+							
+				$content_html=DocumentManager::replace_user_info_into_html($course_code);	
+					
+				$new_content=explode('</head>',$content_html);
+							
+				if (empty($new_content[0])) {
+					$warning_message = get_lang('ThereIsNotACertificateAvailableByDefault');
+					Display::display_warning_message($warning_message);				
+				}
+								
+			}
+			
+			if (empty($_GET['selectcat'])) {
+				
+				$categories = Category :: load();
+				$weight_categories = $certificate_min_scores = $course_codes = array();
+
+				foreach ($categories as $category) {
+					$course_code_category = $this->build_course_code($category);													
+					if (!empty($course_code)) {						
+						if ($course_code_category == $course_code) {						
+							$weight_categories[] = intval($this->build_weight($category));
+							$certificate_min_scores[] = intval($this->build_certificate_min_score($category));
+							$course_codes[] = $course_code;
+							break;
+						}													
+					} else {
+						$weight_categories[] = intval($this->build_weight($category));
+						$certificate_min_scores[] = intval($this->build_certificate_min_score($category));
+						$course_codes[] = $course_code_category;	
+					}										
+				}												
+
+				if (is_array($weight_categories) && is_array($certificate_min_scores) && is_array($course_codes)) {					
+					$warning_message = '';
+					for ($x = 0; $x<count($weight_categories);$x++) {						
+						$weight_category = intval($weight_categories[$x]);
+						$certificate_min_score = intval($certificate_min_scores[$x]);
+						$course_code = $course_codes[$x];
+						
+						if (empty($certificate_min_score) || ($certificate_min_score > $weight_category)) {
+							$warning_message .= $course_code .'&nbsp;-&nbsp;'.get_lang('CertificateMinimunScoreIsRequiredAndMustNotBeMoreThan').'&nbsp;'.$weight_category.'<br />';											
+						}
+
+					}
+					
+					if (!empty($warning_message)) {
+						Display::display_warning_message($warning_message,false);
+					}
+					
+					
+				}				
+			}			
 		}
 
 		return $sortable_data;
@@ -229,6 +303,14 @@ private function build_certificate_min_score ($item) {
 	return $item->get_certificate_min_score();
 }
 
+private function build_weight ($item) {
+	return $item->get_weight();
+}
+
+private function build_course_code ($item) {
+	return $item->get_course_code();
+}
+
 private function build_id_column ($item) {
 		switch ($item->get_item_type()) {
 			// category
@@ -252,7 +334,8 @@ private function build_id_column ($item) {
 		switch ($item->get_item_type()) {
 			// category
 			case 'C' :
-				$prms_uri='?selectcat=' . $item->get_id();
+				$prms_uri='?selectcat=' . $item->get_id() . '&amp;view='.Security::remove_XSS($_GET['view']);
+				
 				if (isset($_GET['isStudentView'])) {
 					if ( isset($is_student) || ( isset($_SESSION['studentview']) && $_SESSION['studentview']=='studentview') ) {
 						$prms_uri=$prms_uri.'&amp;isStudentView='.Security::remove_XSS($_GET['isStudentView']);
@@ -262,7 +345,7 @@ private function build_id_column ($item) {
 				$cat=new Category();
 				$show_message=$cat->show_message_resource_delete($item->get_course_code());
 
-				return '&nbsp;<a href="'.$_SESSION['gradebook_dest'].$prms_uri.'">'
+				return '&nbsp;<a href="'.Security::remove_XSS($_SESSION['gradebook_dest']).$prms_uri.'">'
 				 		. $item->get_name()
 				 		. '</a>'
 				 		. ($item->is_course() ? ' &nbsp;[' . $item->get_course_code() . ']'.$show_message : '');
@@ -276,12 +359,30 @@ private function build_id_column ($item) {
 				$show_message=$cat->show_message_resource_delete($course_id);
 
 				// course/platform admin can go to the view_results page
-				if (api_is_allowed_to_create_course() && $show_message===false) {
 
-					return '&nbsp;'
-						. '<a href="gradebook_view_result.php?cidReq='.$course_id.'&amp;selecteval=' . $item->get_id() . '">'
-						. $item->get_name()
-						. '</a>&nbsp;['.get_lang('Evaluation').']';
+				if (api_is_allowed_to_create_course() && $show_message===false) {
+		
+					if ($item->get_type() == 'presence')
+					{
+						return '&nbsp;'
+							. '<a href="gradebook_view_result.php?cidReq='.$course_id.'&amp;selecteval=' . $item->get_id() . '">'
+							. $item->get_name()
+							. '</a>';						
+						/*return '&nbsp;'
+							. '<a href="gradebook_add_result.php?selectcat'.Security::remove_XSS($_GET['selectcat']).'&amp;selecteval=' . $item->get_id() . '">'
+							. $item->get_name()
+							. '</a>';
+							*/
+					}
+					else 
+					{
+					
+					
+						return '&nbsp;'
+							. '<a href="gradebook_view_result.php?cidReq='.$course_id.'&amp;selecteval=' . $item->get_id() . '">'
+							. $item->get_name()
+							. '</a>&nbsp;['.get_lang('Evaluation').']';
+					}
 				} elseif (ScoreDisplay :: instance()->is_custom() && $show_message===false) {
 					// students can go to the statistics page (if custom display enabled)
 					return '&nbsp;'

+ 1 - 23
main/gradebook/lib/fe/linkaddeditform.class.php

@@ -1,27 +1,5 @@
 <?php
-/*
-==============================================================================
-	Dokeos - elearning and course management software
-
-	Copyright (c) 2008 Dokeos Latinoamerica SAC
-	Copyright (c) 2006 Dokeos SPRL
-	Copyright (c) 2006 Ghent University (UGent)
-	Copyright (c) various contributors
-
-	For a full list of contributors, see "credits.txt".
-	The full license can be read in "license.txt".
-
-	This program is free software; you can redistribute it and/or
-	modify it under the terms of the GNU General Public License
-	as published by the Free Software Foundation; either version 2
-	of the License, or (at your option) any later version.
-
-	See the GNU General Public License for more details.
-
-	Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
-	Mail: info@dokeos.com
-==============================================================================
-*/
+/* For licensing terms, see /license.txt */
 require_once (dirname(__FILE__).'/../../../inc/global.inc.php');
 require_once (dirname(__FILE__).'/../be.inc.php');
 require_once (dirname(__FILE__).'/../gradebook_functions.inc.php');

+ 1 - 23
main/gradebook/lib/fe/linkform.class.php

@@ -1,27 +1,5 @@
 <?php
-/*
-==============================================================================
-	Dokeos - elearning and course management software
-
-	Copyright (c) 2008 Dokeos Latinoamerica SAC
-	Copyright (c) 2006 Dokeos SPRL
-	Copyright (c) 2006 Ghent University (UGent)
-	Copyright (c) various contributors
-
-	For a full list of contributors, see "credits.txt".
-	The full license can be read in "license.txt".
-
-	This program is free software; you can redistribute it and/or
-	modify it under the terms of the GNU General Public License
-	as published by the Free Software Foundation; either version 2
-	of the License, or (at your option) any later version.
-
-	See the GNU General Public License for more details.
-
-	Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
-	Mail: info@dokeos.com
-==============================================================================
-*/
+/* For licensing terms, see /license.txt */
 require_once (dirname(__FILE__).'/../../../inc/global.inc.php');
 require_once (dirname(__FILE__).'/../be.inc.php');
 require_once (dirname(__FILE__).'/../gradebook_functions.inc.php');

+ 1 - 23
main/gradebook/lib/fe/resulttable.class.php

@@ -1,27 +1,5 @@
 <?php
-/*
-==============================================================================
-	Dokeos - elearning and course management software
-
-	Copyright (c) 2008 Dokeos Latinoamerica SAC
-	Copyright (c) 2006 Dokeos SPRL
-	Copyright (c) 2006 Ghent University (UGent)
-	Copyright (c) various contributors
-
-	For a full list of contributors, see "credits.txt".
-	The full license can be read in "license.txt".
-
-	This program is free software; you can redistribute it and/or
-	modify it under the terms of the GNU General Public License
-	as published by the Free Software Foundation; either version 2
-	of the License, or (at your option) any later version.
-
-	See the GNU General Public License for more details.
-
-	Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
-	Mail: info@dokeos.com
-==============================================================================
-*/
+/* For licensing terms, see /license.txt */
 require_once (dirname(__FILE__).'/../../../inc/global.inc.php');
 require_once (dirname(__FILE__).'/../be.inc.php');
 

+ 1 - 23
main/gradebook/lib/fe/scoredisplayform.class.php

@@ -1,27 +1,5 @@
 <?php
-/*
-==============================================================================
-	Dokeos - elearning and course management software
-
-	Copyright (c) 2008 Dokeos Latinoamerica SAC
-	Copyright (c) 2006 Dokeos SPRL
-	Copyright (c) 2006 Ghent University (UGent)
-	Copyright (c) various contributors
-
-	For a full list of contributors, see "credits.txt".
-	The full license can be read in "license.txt".
-
-	This program is free software; you can redistribute it and/or
-	modify it under the terms of the GNU General Public License
-	as published by the Free Software Foundation; either version 2
-	of the License, or (at your option) any later version.
-
-	See the GNU General Public License for more details.
-
-	Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
-	Mail: info@dokeos.com
-==============================================================================
-*/
+/* For licensing terms, see /license.txt */
 require_once (dirname(__FILE__).'/../../../inc/global.inc.php');
 require_once (dirname(__FILE__).'/../gradebook_functions.inc.php');
 require_once (api_get_path(LIBRARY_PATH) . 'groupmanager.lib.php');

+ 1 - 23
main/gradebook/lib/fe/userform.class.php

@@ -1,27 +1,5 @@
 <?php
-/*
-==============================================================================
-	Dokeos - elearning and course management software
-
-	Copyright (c) 2008 Dokeos Latinoamerica SAC
-	Copyright (c) 2006 Dokeos SPRL
-	Copyright (c) 2006 Ghent University (UGent)
-	Copyright (c) various contributors
-
-	For a full list of contributors, see "credits.txt".
-	The full license can be read in "license.txt".
-
-	This program is free software; you can redistribute it and/or
-	modify it under the terms of the GNU General Public License
-	as published by the Free Software Foundation; either version 2
-	of the License, or (at your option) any later version.
-
-	See the GNU General Public License for more details.
-
-	Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
-	Mail: info@dokeos.com
-==============================================================================
-*/
+/* For licensing terms, see /license.txt */
 require_once (dirname(__FILE__).'/../../../inc/global.inc.php');
 require_once (dirname(__FILE__).'/../be.inc.php');
 require_once (dirname(__FILE__).'/../gradebook_functions.inc.php');

+ 1 - 23
main/gradebook/lib/fe/usertable.class.php

@@ -1,27 +1,5 @@
 <?php
-/*
-==============================================================================
-	Dokeos - elearning and course management software
-
-	Copyright (c) 2008 Dokeos Latinoamerica SAC
-	Copyright (c) 2006 Dokeos SPRL
-	Copyright (c) 2006 Ghent University (UGent)
-	Copyright (c) various contributors
-
-	For a full list of contributors, see "credits.txt".
-	The full license can be read in "license.txt".
-
-	This program is free software; you can redistribute it and/or
-	modify it under the terms of the GNU General Public License
-	as published by the Free Software Foundation; either version 2
-	of the License, or (at your option) any later version.
-
-	See the GNU General Public License for more details.
-
-	Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
-	Mail: info@dokeos.com
-==============================================================================
-*/
+/* For licensing terms, see /license.txt */
 require_once (dirname(__FILE__).'/../../../inc/global.inc.php');
 require_once (dirname(__FILE__).'/../be.inc.php');
 

+ 1 - 23
main/gradebook/lib/flatview_data_generator.class.php

@@ -1,27 +1,5 @@
 <?php
-/*
-==============================================================================
-	Dokeos - elearning and course management software
-
-	Copyright (c) 2008 Dokeos Latinoamerica SAC
-	Copyright (c) 2006 Dokeos SPRL
-	Copyright (c) 2006 Ghent University (UGent)
-	Copyright (c) various contributors
-
-	For a full list of contributors, see "credits.txt".
-	The full license can be read in "license.txt".
-
-	This program is free software; you can redistribute it and/or
-	modify it under the terms of the GNU General Public License
-	as published by the Free Software Foundation; either version 2
-	of the License, or (at your option) any later version.
-
-	See the GNU General Public License for more details.
-
-	Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
-	Mail: info@dokeos.com
-==============================================================================
-*/
+/* For licensing terms, see /license.txt */
 /**
  * Class to select, sort and transform object data into array data,
  * used for the teacher's flat view

+ 2 - 24
main/gradebook/lib/gradebook_data_generator.class.php

@@ -1,27 +1,5 @@
 <?php
-/*
-==============================================================================
-	Dokeos - elearning and course management software
-
-	Copyright (c) 2008 Dokeos Latinoamerica SAC
-	Copyright (c) 2006 Dokeos SPRL
-	Copyright (c) 2006 Ghent University (UGent)
-	Copyright (c) various contributors
-
-	For a full list of contributors, see "credits.txt".
-	The full license can be read in "license.txt".
-
-	This program is free software; you can redistribute it and/or
-	modify it under the terms of the GNU General Public License
-	as published by the Free Software Foundation; either version 2
-	of the License, or (at your option) any later version.
-
-	See the GNU General Public License for more details.
-
-	Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
-	Mail: info@dokeos.com
-==============================================================================
-*/
+/* For licensing terms, see /license.txt */
 /**
  * Class to select, sort and transform object data into array data,
  * used for the general gradebook view
@@ -136,7 +114,7 @@ class GradebookDataGenerator
 	function get_certificate_link($item) {
 		if(is_a($item, 'Category')) {
 			if($item->is_certificate_available(api_get_user_id())) {
-				$link = '<a href="'.$_SESSION['gradebook_dest'].'?export_certificate=1&cat='.$item->get_id().'&user='.api_get_user_id().'">'.get_lang('Certificate').'</a>';
+				$link = '<a href="'.Security::remove_XSS($_SESSION['gradebook_dest']).'?export_certificate=1&cat='.$item->get_id().'&user='.api_get_user_id().'">'.get_lang('Certificate').'</a>';
 				return $link;
 			}
 		}

+ 132 - 20
main/gradebook/lib/gradebook_functions.inc.php

@@ -1,24 +1,5 @@
 <?php
-/*
-==============================================================================
-	Dokeos - elearning and course management software
-
-	Copyright (c) 2008 Dokeos SPRL
-
-	For a full list of contributors, see "credits.txt".
-	The full license can be read in "license.txt".
-
-	This program is free software; you can redistribute it and/or
-	modify it under the terms of the GNU General Public License
-	as published by the Free Software Foundation; either version 2
-	of the License, or (at your option) any later version.
-
-	See the GNU General Public License for more details.
-
-	Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
-	Mail: info@dokeos.com
-==============================================================================
-*/
+/* For licensing terms, see /license.txt */
 /*
 * These are functions used in gradebook
 *
@@ -411,3 +392,134 @@ function parse_xml_data($file) {
 	xml_parser_free($parser);
 	return $users;
 }
+/**
+  * update user info about certificate
+  * @param int The category id
+  * @param int The user id
+  * @param string the path name of the certificate
+  * @return void() 
+  */
+  function update_user_info_about_certificate ($cat_id,$user_id,$path_certificate) {
+  	$table_certificate = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CERTIFICATE);
+  	if (!UserManager::is_user_certified($cat_id,$user_id)) {
+  		$sql='UPDATE '.$table_certificate.' SET path_certificate="'.$path_certificate.'"  
+		WHERE cat_id="'.$cat_id.'" AND user_id="'.$user_id.'" ';
+		$rs=Database::query($sql,__FILE__,__LINE__);
+  	}
+  }
+  
+  /**
+  * register user info about certificate
+  * @param int The category id
+  * @param int The user id
+  * @param float The score obtained for certified
+  * @param Datetime The date when you obtained the certificate  
+  * @return void() 
+  */
+  function register_user_info_about_certificate ($cat_id,$user_id,$score_certificate, $date_certificate) {
+  	$table_certificate = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CERTIFICATE);
+  	$sql_exist='SELECT COUNT(*) as count FROM '.$table_certificate.' gc 
+				WHERE gc.cat_id="'.$cat_id.'" AND user_id="'.$user_id.'" ';
+	$rs_exist=Database::query($sql_exist,__FILE__,__LINE__);
+	$row=Database::fetch_array($rs_exist);
+	if ($row['count']==0) {
+		echo $sql='INSERT INTO '.$table_certificate.' (cat_id,user_id,score_certificate,date_certificate)
+			  VALUES("'.$cat_id.'","'.$user_id.'","'.$score_certificate.'","'.$date_certificate.'")';
+		$rs=Database::query($sql,__FILE__,__LINE__);  
+	}
+	
+  }
+  /**
+  * Get date of user certificate
+  * @param int The category id
+  * @param int The user id
+  * @return Datetime The date when you obtained the certificate   
+  */  
+  function get_certificate_date_by_user_id ($cat_id,$user_id) {
+    	$table_certificate = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CERTIFICATE);
+    	$sql_get_date='SELECT date_certificate FROM '.$table_certificate.' WHERE cat_id="'.$cat_id.'" AND user_id="'.$user_id.'"';
+    	$rs_get_date=Database::query($sql_get_date,__FILE__,__LINE__);
+    	$row_get_date=Database::fetch_array($rs_get_date,'ASSOC');
+    	return $row_get_date['date_certificate'];
+  }
+  
+  /**
+  * Get list of users certificates
+  * @param int The category id
+  * @return array
+  */
+  function get_list_users_certificates ($cat_id=null) {
+    $table_certificate = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CERTIFICATE); 	
+    $table_user = Database::get_main_table(TABLE_MAIN_USER);
+  	$sql='SELECT DISTINCT u.user_id,u.lastname,u.firstname,u.username FROM '.$table_user.' u INNER JOIN '.$table_certificate.' gc 
+			ON u.user_id=gc.user_id ';
+	if (!is_null($cat_id) && $cat_id>0) {
+  		$sql.=' WHERE cat_id='.Database::escape_string($cat_id);
+  	}
+  	$sql.=' ORDER BY u.firstname';
+	$rs=Database::query($sql,__FILE__,__LINE__);
+	$list_users=array();
+	while ($row=Database::fetch_array($rs)) {
+		$list_users[]=$row;
+	}
+	return $list_users;
+  }
+
+  /**
+  *Gets the certificate list by user id
+  *@param int The user id
+  *@param int The category id
+  *@retun array
+  */
+  function get_list_gradebook_certificates_by_user_id ($user_id,$cat_id=null) {
+  	$table_certificate = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CERTIFICATE); 	
+  	$sql='SELECT gc.score_certificate,gc.date_certificate,gc.path_certificate,gc.cat_id,gc.user_id FROM  '.$table_certificate.' gc 
+		  WHERE gc.user_id="'.Database::escape_string($user_id).'" ';
+	if (!is_null($cat_id) && $cat_id>0) {
+  		$sql.=' AND cat_id='.Database::escape_string($cat_id);
+  	}
+  	$rs = Database::query($sql,__FILE__,__LINE__);
+  	$list_certificate=array();
+  	while ($row=Database::fetch_array($rs)) {
+  		$list_certificate[]=$row;
+  	}
+  	return $list_certificate;
+  }
+  /**
+  * Deletes a certificate
+  * @param int The category id
+  * @param int The user id
+  * @return boolean
+  */
+  function delete_certificate ($cat_id,$user_id) {
+  	
+    $table_certificate = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CERTIFICATE); 		
+  	$sql_verified='SELECT count(*) AS count,path_certificate as path,user_id FROM '.$table_certificate.' gc WHERE cat_id="'.Database::escape_string($cat_id).'" AND user_id="'.Database::escape_string($user_id).'" GROUP BY user_id,cat_id';
+  	$rs_verified=Database::query($sql_verified,__FILE__,__LINE__);
+  	$path=Database::result($rs_verified,0,'path');
+  	$user_id=Database::result($rs_verified,0,'user_id');
+  	if (!is_null($path) || $path!='' || strlen($path)) {
+  			$path_info= UserManager::get_user_picture_path_by_id($user_id,'system',true);
+			$path_directory_user_certificate=$path_info['dir'].'certificate'.$path;
+			if (is_file($path_directory_user_certificate)) {
+				@unlink($path_directory_user_certificate);
+				if (is_file($path_directory_user_certificate)===false) {
+					$delete_db=true;
+				} else {
+					$delete_db=false;
+				}
+			}
+	  	if (Database::result($rs_verified,0,'count')==1 && $delete_db===true) {
+	  		$sql_delete='DELETE FROM '.$table_certificate.' WHERE cat_id="'.Database::escape_string($cat_id).'" AND user_id="'.Database::escape_string($user_id).'" ';
+	  		$rs_delete=Database::query($sql_delete,__FILE__,__LINE__);
+	  		return true;
+	  	} else {
+	  		return false;
+	  	}
+  	} else {
+  		//path is not generate delete only the DB record
+  		$sql_delete='DELETE FROM '.$table_certificate.' WHERE cat_id="'.Database::escape_string($cat_id).'" AND user_id="'.Database::escape_string($user_id).'" ';
+	  	$rs_delete=Database::query($sql_delete,__FILE__,__LINE__);
+	  	return true;
+  	}
+  }

+ 1 - 23
main/gradebook/lib/gradebook_functions_users.inc.php

@@ -1,27 +1,5 @@
 <?php
-/*
-==============================================================================
-	Dokeos - elearning and course management software
-
-	Copyright (c) 2008 Dokeos Latinoamerica SAC
-	Copyright (c) 2006 Dokeos SPRL
-	Copyright (c) 2006 Ghent University (UGent)
-	Copyright (c) various contributors
-
-	For a full list of contributors, see "credits.txt".
-	The full license can be read in "license.txt".
-
-	This program is free software; you can redistribute it and/or
-	modify it under the terms of the GNU General Public License
-	as published by the Free Software Foundation; either version 2
-	of the License, or (at your option) any later version.
-
-	See the GNU General Public License for more details.
-
-	Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
-	Mail: info@dokeos.com
-==============================================================================
-*/
+/* For licensing terms, see /license.txt */
 /**
  * Various user related functions
  * @package dokeos.gradebook

+ 1 - 23
main/gradebook/lib/results_data_generator.class.php

@@ -1,27 +1,5 @@
 <?php
-/*
-==============================================================================
-	Dokeos - elearning and course management software
-
-	Copyright (c) 2008 Dokeos Latinoamerica SAC
-	Copyright (c) 2006 Dokeos SPRL
-	Copyright (c) 2006 Ghent University (UGent)
-	Copyright (c) various contributors
-
-	For a full list of contributors, see "credits.txt".
-	The full license can be read in "license.txt".
-
-	This program is free software; you can redistribute it and/or
-	modify it under the terms of the GNU General Public License
-	as published by the Free Software Foundation; either version 2
-	of the License, or (at your option) any later version.
-
-	See the GNU General Public License for more details.
-
-	Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
-	Mail: info@dokeos.com
-==============================================================================
-*/
+/* For licensing terms, see /license.txt */
 /**
  * Class to select, sort and transform object data into array data,
  * used for the teacher's evaluation results view

+ 1 - 24
main/gradebook/lib/scoredisplay.class.php

@@ -1,27 +1,5 @@
 <?php
-/*
-==============================================================================
-	Dokeos - elearning and course management software
-
-	Copyright (c) 2008 Dokeos Latinoamerica SAC
-	Copyright (c) 2006 Dokeos SPRL
-	Copyright (c) 2006 Ghent University (UGent)
-	Copyright (c) various contributors
-
-	For a full list of contributors, see "credits.txt".
-	The full license can be read in "license.txt".
-
-	This program is free software; you can redistribute it and/or
-	modify it under the terms of the GNU General Public License
-	as published by the Free Software Foundation; either version 2
-	of the License, or (at your option) any later version.
-
-	See the GNU General Public License for more details.
-
-	Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
-	Mail: info@dokeos.com
-==============================================================================
-*/
+/* For licensing terms, see /license.txt */
 // Score display types constants
 define('SCORE_DIV',1);
 define('SCORE_PERCENT',2);
@@ -339,7 +317,6 @@ class ScoreDisplay
 	private function get_custom_displays() {
     	$tbl_display = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_SCORE_DISPLAY);
 		$sql = 'SELECT * FROM '.$tbl_display.' ORDER BY score';
-		//echo $sql;
 		$result = Database::query($sql);
 		return Database::store_result($result);
 	}

+ 1 - 1
main/gradebook/lib/user_data_generator.class.php

@@ -1,5 +1,5 @@
 <?php
-
+/* For licensing terms, see /license.txt */
 /**
  * Class to select, sort and transform object data into array data,
  * used for a student's general view

+ 1 - 23
main/gradebook/open_document.php

@@ -1,27 +1,5 @@
 <?php
-/*
-==============================================================================
-	Dokeos - elearning and course management software
-
-	Copyright (c) 2008 Dokeos Latinoamerica SAC
-	Copyright (c) 2006 Dokeos SPRL
-	Copyright (c) 2006 Ghent University (UGent)
-	Copyright (c) various contributors
-
-	For a full list of contributors, see "credits.txt".
-	The full license can be read in "license.txt".
-
-	This program is free software; you can redistribute it and/or
-	modify it under the terms of the GNU General Public License
-	as published by the Free Software Foundation; either version 2
-	of the License, or (at your option) any later version.
-
-	See the GNU General Public License for more details.
-
-	Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
-	Mail: info@dokeos.com
-==============================================================================
-*/
+/* For licensing terms, see /license.txt */
 require_once ('../inc/global.inc.php');
 require_once ('../inc/lib/document.lib.php');
 api_block_anonymous_users();

+ 2 - 24
main/gradebook/user_info.php

@@ -1,27 +1,5 @@
 <?php // $Id: $
-/*
-==============================================================================
-	Dokeos - elearning and course management software
-
-	Copyright (c) 2008 Dokeos Latinoamerica SAC
-	Copyright (c) 2006 Dokeos SPRL
-	Copyright (c) 2006 Ghent University (UGent)
-	Copyright (c) various contributors
-
-	For a full list of contributors, see "credits.txt".
-	The full license can be read in "license.txt".
-
-	This program is free software; you can redistribute it and/or
-	modify it under the terms of the GNU General Public License
-	as published by the Free Software Foundation; either version 2
-	of the License, or (at your option) any later version.
-
-	See the GNU General Public License for more details.
-
-	Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
-	Mail: info@dokeos.com
-==============================================================================
-*/
+/* For licensing terms, see /license.txt */
 $language_file = 'gradebook';
 //$cidReset = true;
 require_once ('../inc/global.inc.php');
@@ -46,7 +24,7 @@ require_once ('lib/gradebook_functions.inc.php');
 require_once ('lib/fe/userform.class.php');
 block_students();
 
-$form = new UserForm(UserForm :: TYPE_USER_INFO, $user, 'user_info_form', null, api_get_self() . '?userid=' . $user_id . '&selectcat=' . $_GET['selectcat']);
+$form = new UserForm(UserForm :: TYPE_USER_INFO, $user, 'user_info_form', null, api_get_self() . '?userid=' . $user_id . '&selectcat=' . Security::remove_XSS($_GET['selectcat']));
 if ($form->validate()) {
 	header('Location: user_stats.php?selectcat=' . Security::remove_XSS($_GET['selectcat']).'&userid=' .$user_id);
 	exit;

+ 1 - 23
main/gradebook/user_stats.php

@@ -1,27 +1,5 @@
 <?php // $Id: $
-/*
-==============================================================================
-	Dokeos - elearning and course management software
-
-	Copyright (c) 2008 Dokeos Latinoamerica SAC
-	Copyright (c) 2006 Dokeos SPRL
-	Copyright (c) 2006 Ghent University (UGent)
-	Copyright (c) various contributors
-
-	For a full list of contributors, see "credits.txt".
-	The full license can be read in "license.txt".
-
-	This program is free software; you can redistribute it and/or
-	modify it under the terms of the GNU General Public License
-	as published by the Free Software Foundation; either version 2
-	of the License, or (at your option) any later version.
-
-	See the GNU General Public License for more details.
-
-	Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
-	Mail: info@dokeos.com
-==============================================================================
-*/
+/* For licensing terms, see /license.txt */
 $language_file= 'gradebook';
 //$cidReset= true;
 require_once ('../inc/global.inc.php');

+ 14 - 16
main/group/group.php

@@ -1,22 +1,20 @@
-<?php
+<?php // $Id: group.php 22201 2009-07-17 19:57:03Z cfasanando $
 /* For licensing terms, see /license.txt */
 
 /**
- *	Main page for the group module.
- *	This script displays the general group settings,
- *	and a list of groups with buttons to view, edit...
- *
- *	@author Thomas Depraetere, Hugues Peeters, Christophe Gesche: initial versions
- *	@author Bert Vanderkimpen, improved self-unsubscribe for cvs
- *	@author Patrick Cool, show group comment under the group name
- *	@author Roan Embrechts, initial self-unsubscribe code, code cleaning, virtual course support
- *	@author Bart Mollet, code cleaning, use of Display-library, list of courseAdmin-tools, use of GroupManager
- *	@author Isaac Flores, code cleaning and improvements
- *	@package chamilo.group
- */
-
-/*	INIT SECTION */
-
+*	Main page for the group module.
+*	This script displays the general group settings,
+*	and a list of groups with buttons to view, edit...
+*
+*	@author Thomas Depraetere, Hugues Peeters, Christophe Gesche: initial versions
+*	@author Bert Vanderkimpen, improved self-unsubscribe for cvs
+*	@author Patrick Cool, show group comment under the group name
+*	@author Roan Embrechts, initial self-unsubscribe code, code cleaning, virtual course support
+*	@author Bart Mollet, code cleaning, use of Display-library, list of courseAdmin-tools, use of GroupManager
+*	@author Isaac Flores, code cleaning and improvements
+*	@package chamilo.group
+*/
+/*		INIT SECTION	*/
 // Name of the language file that needs to be included
 $language_file = 'group';
 

BIN
main/img/certificate.png


BIN
main/img/nocertificate.png


+ 73 - 82
main/inc/lib/database.lib.php

@@ -1,7 +1,7 @@
 <?php // $Id: database.lib.php 22265 2009-07-20 23:26:43Z juliomontoya $
 /* See license terms in /license.txt */
 /**
-*	This is the main database library for Dokeos.
+*	This is the main database library for Chamilo.
 *	Include/require it in your code to use its functionality.
 *   Because this library contains all the basic database calls, it could be
 *   replaced by another library for say, PostgreSQL, to actually use Dokeos
@@ -50,8 +50,9 @@ define('TABLE_MAIN_GRADEBOOK_RESULT', 		'gradebook_result');
 define('TABLE_MAIN_GRADEBOOK_RESULT_LOG', 	'gradebook_result_log');
 define('TABLE_MAIN_GRADEBOOK_LINK', 		'gradebook_link');
 define('TABLE_MAIN_GRADEBOOK_SCORE_DISPLAY','gradebook_score_display');
+define('TABLE_MAIN_GRADEBOOK_CERTIFICATE', 	'gradebook_certificate');
 
-// Profiling
+//Profiling
 define('TABLE_MAIN_USER_FIELD',			'user_field');
 define('TABLE_MAIN_USER_FIELD_OPTIONS',	'user_field_options');
 define('TABLE_MAIN_USER_FIELD_VALUES',	'user_field_values');
@@ -60,13 +61,11 @@ define('TABLE_MAIN_USER_FIELD_VALUES',	'user_field_values');
 define('TABLE_MAIN_TAG',				'tag');
 define('TABLE_MAIN_USER_REL_TAG',		'user_rel_tag');
 
-
 //User groups
 define('TABLE_MAIN_GROUP',				'groups');
 define('TABLE_MAIN_USER_REL_GROUP',		'group_rel_user');
 define('TABLE_MAIN_GROUP_REL_TAG',		'group_rel_tag');
 
-
 // Search engine
 define('TABLE_MAIN_SPECIFIC_FIELD',			'specific_field');
 define('TABLE_MAIN_SPECIFIC_FIELD_VALUES',	'specific_field_values');
@@ -82,11 +81,11 @@ define('TABLE_MAIN_ACCESS_URL_REL_SESSION', 'access_url_rel_session');
 define('TABLE_MAIN_SYSTEM_CALENDAR', 'sys_calendar');
 
 // Reservation System
-define('TABLE_MAIN_RESERVATION_ITEM', 'reservation_item');
-define('TABLE_MAIN_RESERVATION_RESERVATION', 'reservation_main');
-define('TABLE_MAIN_RESERVATION_SUBSCRIBTION', 'reservation_subscription');
-define('TABLE_MAIN_RESERVATION_CATEGORY', 'reservation_category');
-define('TABLE_MAIN_RESERVATION_ITEM_RIGHTS', 'reservation_item_rights');
+define('TABLE_MAIN_RESERVATION_ITEM', 			'reservation_item');
+define('TABLE_MAIN_RESERVATION_RESERVATION', 	'reservation_main');
+define('TABLE_MAIN_RESERVATION_SUBSCRIBTION', 	'reservation_subscription');
+define('TABLE_MAIN_RESERVATION_CATEGORY', 		'reservation_category');
+define('TABLE_MAIN_RESERVATION_ITEM_RIGHTS', 	'reservation_item_rights');
 
 // Social networking
 define('TABLE_MAIN_USER_REL_USER', 'user_rel_user');
@@ -130,54 +129,54 @@ define('TABLE_SCORM_MAIN', 'scorm_main');
 define('TABLE_SCORM_SCO_DATA', 'scorm_sco_data');
 
 // Course tables
-define('TABLE_AGENDA', 'calendar_event');
-define('TABLE_AGENDA_REPEAT', 'calendar_event_repeat');
-define('TABLE_AGENDA_REPEAT_NOT', 'calendar_event_repeat_not');
-define('TABLE_AGENDA_ATTACHMENT', 'calendar_event_attachment');
-define('TABLE_ANNOUNCEMENT', 'announcement');
-define('TABLE_ANNOUNCEMENT_ATTACHMENT', 'announcement_attachment');
-define('TABLE_CHAT_CONNECTED', 'chat_connected'); // @todo: probably no longer in use !!!
-define('TABLE_COURSE_DESCRIPTION', 'course_description');
-define('TABLE_DOCUMENT', 'document');
-define('TABLE_ITEM_PROPERTY', 'item_property');
-define('TABLE_LINK', 'link');
-define('TABLE_LINK_CATEGORY', 'link_category');
-define('TABLE_TOOL_LIST', 'tool');
-define('TABLE_TOOL_INTRO', 'tool_intro');
-define('TABLE_SCORMDOC', 'scormdocument');
-define('TABLE_STUDENT_PUBLICATION', 'student_publication');
-define('TABLE_STUDENT_PUBLICATION_ASSIGNMENT', 'student_publication_assignment');
-define('CHAT_CONNECTED_TABLE', 'chat_connected');
+define('TABLE_AGENDA',				 			'calendar_event');
+define('TABLE_AGENDA_REPEAT', 					'calendar_event_repeat');
+define('TABLE_AGENDA_REPEAT_NOT', 				'calendar_event_repeat_not');
+define('TABLE_AGENDA_ATTACHMENT', 				'calendar_event_attachment');
+define('TABLE_ANNOUNCEMENT', 					'announcement');
+define('TABLE_ANNOUNCEMENT_ATTACHMENT', 		'announcement_attachment');
+define('TABLE_CHAT_CONNECTED',			 		'chat_connected'); // @todo: probably no longer in use !!!
+define('TABLE_COURSE_DESCRIPTION',		 		'course_description');
+define('TABLE_DOCUMENT', 						'document');
+define('TABLE_ITEM_PROPERTY', 					'item_property');
+define('TABLE_LINK', 							'link');
+define('TABLE_LINK_CATEGORY', 					'link_category');
+define('TABLE_TOOL_LIST', 						'tool');
+define('TABLE_TOOL_INTRO', 						'tool_intro');
+define('TABLE_SCORMDOC', 						'scormdocument');
+define('TABLE_STUDENT_PUBLICATION', 			'student_publication');
+define('TABLE_STUDENT_PUBLICATION_ASSIGNMENT',	'student_publication_assignment');
+define('CHAT_CONNECTED_TABLE',					'chat_connected');
 
 // Course forum tables
-define('TABLE_FORUM_CATEGORY', 'forum_category');
-define('TABLE_FORUM', 'forum_forum');
-define('TABLE_FORUM_THREAD', 'forum_thread');
-define('TABLE_FORUM_POST', 'forum_post');
-define('TABLE_FORUM_ATTACHMENT', 'forum_attachment');
-define('TABLE_FORUM_MAIL_QUEUE', 'forum_mailcue');
-define('TABLE_FORUM_THREAD_QUALIFY', 'forum_thread_qualify');
-define('TABLE_FORUM_THREAD_QUALIFY_LOG', 'forum_thread_qualify_log');
-define('TABLE_FORUM_NOTIFICATION', 'forum_notification');
+define('TABLE_FORUM_CATEGORY', 				'forum_category');
+define('TABLE_FORUM', 						'forum_forum');
+define('TABLE_FORUM_THREAD',	 			'forum_thread');
+define('TABLE_FORUM_POST', 					'forum_post');
+define('TABLE_FORUM_ATTACHMENT', 			'forum_attachment');
+define('TABLE_FORUM_MAIL_QUEUE', 			'forum_mailcue');
+define('TABLE_FORUM_THREAD_QUALIFY', 		'forum_thread_qualify');
+define('TABLE_FORUM_THREAD_QUALIFY_LOG', 	'forum_thread_qualify_log');
+define('TABLE_FORUM_NOTIFICATION', 			'forum_notification');
 
 // Course group tables
-define('TABLE_GROUP', 'group_info');
-define('TABLE_GROUP_USER', 'group_rel_user');
-define('TABLE_GROUP_TUTOR', 'group_rel_tutor');
-define('TABLE_GROUP_CATEGORY', 'group_category');
+define('TABLE_GROUP', 			'group_info');
+define('TABLE_GROUP_USER', 		'group_rel_user');
+define('TABLE_GROUP_TUTOR', 	'group_rel_tutor');
+define('TABLE_GROUP_CATEGORY', 	'group_category');
 
 // Course dropbox tables
-define('TABLE_DROPBOX_CATEGORY', 'dropbox_category');
-define('TABLE_DROPBOX_FEEDBACK', 'dropbox_feedback');
-define('TABLE_DROPBOX_POST', 'dropbox_post');
-define('TABLE_DROPBOX_FILE', 'dropbox_file');
-define('TABLE_DROPBOX_PERSON', 'dropbox_person');
+define('TABLE_DROPBOX_CATEGORY','dropbox_category');
+define('TABLE_DROPBOX_FEEDBACK','dropbox_feedback');
+define('TABLE_DROPBOX_POST', 	'dropbox_post');
+define('TABLE_DROPBOX_FILE', 	'dropbox_file');
+define('TABLE_DROPBOX_PERSON', 	'dropbox_person');
 
 // Course quiz (or test, or exercice) tables
-define('TABLE_QUIZ_QUESTION', 'quiz_question');
-define('TABLE_QUIZ_TEST', 'quiz');
-define('TABLE_QUIZ_ANSWER', 'quiz_answer');
-define('TABLE_QUIZ_TEST_QUESTION', 'quiz_rel_question');
+define('TABLE_QUIZ_QUESTION', 		'quiz_question');
+define('TABLE_QUIZ_TEST', 			'quiz');
+define('TABLE_QUIZ_ANSWER', 		'quiz_answer');
+define('TABLE_QUIZ_TEST_QUESTION', 	'quiz_rel_question');
 
 // Linked resource table
 define('TABLE_LINKED_RESOURCES', 'resource');
@@ -213,42 +212,42 @@ define('TABLE_BLOGS_TASKS_PERMISSIONS', 'permission_task');
 //end of Smartblogs
 
 // User information tables
-define('TABLE_USER_INFO', 'userinfo_def');
-define('TABLE_USER_INFO_CONTENT', 'userinfo_content');
+define('TABLE_USER_INFO', 			'userinfo_def');
+define('TABLE_USER_INFO_CONTENT', 	'userinfo_content');
 
 // Course settings table
 define('TABLE_COURSE_SETTING', 'course_setting');
 
 // Course online tables
-define('TABLE_ONLINE_LINK', 'online_link');
-define('TABLE_ONLINE_CONNECTED', 'online_connected');
+define('TABLE_ONLINE_LINK', 	'online_link');
+define('TABLE_ONLINE_CONNECTED','online_connected');
 
 // User database
-define('TABLE_PERSONAL_AGENDA', 'personal_agenda');
-define('TABLE_PERSONAL_AGENDA_REPEAT', 'personal_agenda_repeat');
-define('TABLE_PERSONAL_AGENDA_REPEAT_NOT', 'personal_agenda_repeat_not');
-define('TABLE_USER_COURSE_CATEGORY', 'user_course_category');
+define('TABLE_PERSONAL_AGENDA', 			'personal_agenda');
+define('TABLE_PERSONAL_AGENDA_REPEAT', 		'personal_agenda_repeat');
+define('TABLE_PERSONAL_AGENDA_REPEAT_NOT', 	'personal_agenda_repeat_not');
+define('TABLE_USER_COURSE_CATEGORY', 		'user_course_category');
 
 // Survey
 // @TODO: Are these MAIN tables or course tables?
 // @TODO: Probably these constants are obsolete.
-define('TABLE_MAIN_SURVEY', 'survey');
+define('TABLE_MAIN_SURVEY', 		'survey');
 define('TABLE_MAIN_SURVEYQUESTION', 'questions');
 
 // Survey
-define('TABLE_SURVEY', 'survey');
-define('TABLE_SURVEY_QUESTION', 'survey_question');
-define('TABLE_SURVEY_QUESTION_OPTION', 'survey_question_option');
-define('TABLE_SURVEY_INVITATION', 'survey_invitation');
-define('TABLE_SURVEY_ANSWER', 'survey_answer');
-define('TABLE_SURVEY_QUESTION_GROUP', 'survey_group');
-define('TABLE_SURVEY_REPORT', 'survey_report');
+define('TABLE_SURVEY', 					'survey');
+define('TABLE_SURVEY_QUESTION', 		'survey_question');
+define('TABLE_SURVEY_QUESTION_OPTION', 	'survey_question_option');
+define('TABLE_SURVEY_INVITATION', 		'survey_invitation');
+define('TABLE_SURVEY_ANSWER', 			'survey_answer');
+define('TABLE_SURVEY_QUESTION_GROUP', 	'survey_group');
+define('TABLE_SURVEY_REPORT', 			'survey_report');
 
 // Wiki tables
-define('TABLE_WIKI', 'wiki');
-define('TABLE_WIKI_CONF', 'wiki_conf');
-define('TABLE_WIKI_DISCUSS', 'wiki_discuss');
-define('TABLE_WIKI_MAILCUE', 'wiki_mailcue');
+define('TABLE_WIKI', 			'wiki');
+define('TABLE_WIKI_CONF', 		'wiki_conf');
+define('TABLE_WIKI_DISCUSS', 	'wiki_discuss');
+define('TABLE_WIKI_MAILCUE', 	'wiki_mailcue');
 
 // Glossary
 define('TABLE_GLOSSARY', 'glossary');
@@ -264,23 +263,16 @@ define('TABLE_MESSAGE_ATTACHMENT', 'message_attachment');
 define('TABLE_METADATA', 'metadata');
 
 // Attendance Sheet
-define('TABLE_ATTENDANCE','attendance');
+define('TABLE_ATTENDANCE',			'attendance');
 define('TABLE_ATTENDANCE_CALENDAR', 'attendance_calendar');
-define('TABLE_ATTENDANCE_SHEET','attendance_sheet');
-define('TABLE_ATTENDANCE_RESULT', 'attendance_result');
+define('TABLE_ATTENDANCE_SHEET',	'attendance_sheet');
+define('TABLE_ATTENDANCE_RESULT', 	'attendance_result');
 
 
-/*
-==============================================================================
-		DATABASE CLASS
+/*		DATABASE CLASS
 		the class and its functions
-==============================================================================
 */
 
-/**
- *	@package chamilo.library
- */
-
 class Database {
 
 	/*
@@ -1321,6 +1313,5 @@ class Database {
 	public static function get_last_insert_id() {
 		return mysql_insert_id();
 	}
-
 }
-//end class Database
+//end class Database

+ 202 - 0
main/inc/lib/document.lib.php

@@ -967,7 +967,209 @@ class DocumentManager {
 		return $_SESSION ['is_allowed_in_course'] || api_is_platform_admin();
 	}
 
+	/**
+	 * Allow attach certificate to course
+	 * @param string The course id
+	 * @param int The document id
+	 * @return void()
+	 */
+	 function attach_gradebook_certificate ($course_id,$document_id) {
+	 	$tbl_category=Database :: get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY);
+	 	$session_id=api_get_session_id();
+	 	if ($session_id==0 || is_null($session_id)) {
+	 		$sql_session='AND (session_id='.Database::escape_string($session_id).' OR isnull(session_id)) ';
+	 	} elseif ($session_id>0) {
+	 		$sql_session='AND session_id='.Database::escape_string($session_id);
+	 	} else {
+	 		$sql_session='';
+	 	}
+	 	$sql='UPDATE '.$tbl_category.' SET document_id="'.Database::escape_string($document_id).'" 
+	 	WHERE course_code="'.Database::escape_string($course_id).'" '.$sql_session;
+	 	$rs=Database::query($sql,__FILE__,__LINE__);
+	 }
+	 /**
+	  * get the document id of default certificate
+	  * @param string The course id
+	  * @return int The default certificate id
+	  */
+	 function get_default_certificate_id ($course_id) {
+	 	$tbl_category=Database :: get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY);	 	
+	 	$session_id=api_get_session_id();
+	 	if ($session_id==0 || is_null($session_id)) {
+	 		$sql_session='AND (session_id='.Database::escape_string($session_id).' OR isnull(session_id)) ';
+	 	} elseif ($session_id>0) {
+	 		$sql_session='AND session_id='.Database::escape_string($session_id);
+	 	} else {
+	 		$sql_session='';
+	 	}	 	
+	 	$sql='SELECT document_id FROM '.$tbl_category.'  
+	 	WHERE course_code="'.Database::escape_string($course_id).'" '.$sql_session;
+	 	$rs=Database::query($sql,__FILE__,__LINE__);
+	 	$row=Database::fetch_array($rs);
+	 	return $row['document_id'];
+	 }
+	 /**
+	  * allow replace user info in file html
+	  * @param string The course id
+	  * @return string The html content of the certificate
+	  */
+	  function replace_user_info_into_html($course_id) {
+	  	global $_course;
+
+	  	$course_info = api_get_course_info($course_id);	  		  	
+	  	$tbl_document=Database::get_course_table(TABLE_DOCUMENT,$course_info['dbName']);
+	  	$document_id=self::get_default_certificate_id($course_id);	  		  	
+	  	
+	  	$sql='SELECT path FROM '.$tbl_document.' WHERE id="'.Database::escape_string($document_id).'" ';	  		  	
+	  	
+	  	$rs=Database::query($sql,__FILE__,__LINE__);
+	  	$new_content = '';
+	  	if (Database::num_rows($rs)) {
+		  	$row=Database::fetch_array($rs);
+		  	$filepath = api_get_path('SYS_COURSE_PATH').$course_info['path'].'/document'.$row['path'];
+		  	
+		  	if (is_file($filepath)) {
+		  		$my_content_html=file_get_contents($filepath);
+		  	}
+			$all_user_info=self::get_all_info_to_certificate();
+			$info_to_be_replaced_in_content_html=$all_user_info[0];
+			$info_to_replace_in_content_html=$all_user_info[1];
+			$new_content=str_replace($info_to_be_replaced_in_content_html,$info_to_replace_in_content_html,$my_content_html);	  	
+	  	}
+	  	
+	  	return $new_content;
+	  }
+	  
+	  /**
+	   * return all content to replace and all content to be replace
+	   */
+	  function get_all_info_to_certificate () {
+	  	
+		global $charset,$dateFormatLong;
+		$info_list	= array();
+	  	$user_id	= api_get_user_id();
+	  	$course_id	= api_get_course_id();
+	  	
+		//info portal	
+		$organization_name = api_get_setting('Institution');
+		$portal_name = api_get_setting('siteName');
+
+		//info extra user data
+		$extra_user_info_data=UserManager::get_extra_user_data($user_id,false,false);
+
+		//info student
+		$user_info=api_get_user_info($user_id); 		
+		$first_name=($user_info['firstName']);
+		$last_name=($user_info['lastName']);
+		$official_code=($user_info['official_code']);
+			
+		//info teacher
+		$info_teacher_id=UserManager::get_user_id_of_course_admin_or_session_admin($course_id);
+		$teacher_info=api_get_user_info($info_teacher_id);
+		$teacher_first_name=($teacher_info['firstName']);
+		$teacher_last_name=($teacher_info['lastName']);
+		
+		// info gradebook certificate
+		$info_grade_certificate = UserManager::get_info_gradebook_certificate($course_id,$user_id);
+		$date_certificate = $info_grade_certificate['date_certificate'];
+		$date_long_certificate = '';
+		
+		if (!empty($date_certificate)) {
+			$date_long_certificate = api_ucfirst(format_locale_date($dateFormatLong,convert_mysql_date($date_certificate)));	
+		}
 
+		//replace content
+		$info_to_replace_in_content_html=array($first_name,$last_name,$organization_name,$portal_name,$teacher_first_name,$teacher_last_name, $official_code, $date_long_certificate);
+		$info_to_be_replaced_in_content_html=array('((user_firstname))','((user_lastname))','((gradebook_institution))',
+		'((gradebook_sitename))','((teacher_firstname))','((teacher_lastname))','((official_code))','((date_certificate))');
+		foreach ($extra_user_info_data as $key_extra=>$value_extra) {
+			$info_to_be_replaced_in_content_html[]='(('.strtolower($key_extra).'))';
+			$info_to_replace_in_content_html[]=$value_extra;
+		}
+		$info_list[]=$info_to_be_replaced_in_content_html;
+		$info_list[]=$info_to_replace_in_content_html;
+		return $info_list;
+	  }
+	  /**
+	   * Remove default certificate
+	   * @param string The course id
+	   * @param int The document id of the default certificate
+	   * @return void()
+	   */
+	   function remove_attach_certificate ($course_id,$default_certificate_id) {
+	   		$default_certificate=self::get_default_certificate_id($course_id);
+	   		if ((int)$default_certificate==(int)$default_certificate_id) {
+			   	$tbl_category=Database :: get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY);
+			 	$session_id=api_get_session_id();
+			 	if ($session_id==0 || is_null($session_id)) {
+			 		$sql_session='AND (session_id='.Database::escape_string($session_id).' OR isnull(session_id)) ';
+			 	} elseif ($session_id>0) {
+			 		$sql_session='AND session_id='.Database::escape_string($session_id);
+			 	} else {
+			 		$sql_session='';
+			 	}
+			 	
+			 	$sql='UPDATE '.$tbl_category.' SET document_id=null 
+			 	WHERE course_code="'.Database::escape_string($course_id).'" AND document_id="'.$default_certificate_id.'" '.$sql_session;
+			 	$rs=Database::query($sql,__FILE__,__LINE__);
+	   		}
+	   }
+	   
+	    /**
+	    * Create directory certificate
+	    * @param string The course id
+	    * @return void() 
+	    */
+	    function create_directory_certificate_in_course ($course_id) {
+	    	
+	    	global $_course;
+	    	global $_user;
+	    	$to_group_id=0;
+	    	$to_user_id=null;
+	    	$course_dir   = $_course['path']."/document/";
+			$sys_course_path = api_get_path(SYS_COURSE_PATH);
+	    	$base_work_dir=$sys_course_path.$course_dir;
+	    	$base_work_dir_test=$base_work_dir.'certificates';
+	    	$dir_name='/certificates';
+	    	$post_dir_name='certificates';
+	    	$visibility_command='invisible';
+	    	if (!is_dir($base_work_dir_test)) {
+				$created_dir = create_unexisting_directory($_course,$_user['user_id'],$to_group_id,$to_user_id,$base_work_dir,$dir_name,$post_dir_name);
+	    		$update_id=DocumentManager::get_document_id_of_directory_certificate();
+	    		api_item_property_update($_course, TOOL_DOCUMENT, $update_id, $visibility_command, $_user['user_id']);
+	    	}
+	    }
+	    /**
+	     * Get the document id of the directory certificate
+	     * @param string The course id
+	     * @return int The document id of the directory certificate
+	     */
+	    function get_document_id_of_directory_certificate () {
+	    	global $_course;
+	  		$tbl_document=Database::get_course_table(TABLE_DOCUMENT);
+	    	$sql='SELECT id FROM '.$tbl_document.' WHERE path="/certificates" ';
+	    	$rs=Database::query($sql,__FILE__,__LINE__);
+	    	$row=Database::fetch_array($rs);
+	    	return $row['id'];
+	    	
+	    }
+
+		 /**
+	     * Check if a directory given is for certificate 
+	     * @param string path of directory
+	     * @return bool  true if is a certificate or false otherwise
+	     */	    
+	    function is_certificate_mode($dir) {
+	    	//I'm in the certification module?  
+			$is_certificate_mode = false;
+			$is_certificate_array = explode('/',$dir);
+			array_shift($is_certificate_array);
+			if ($is_certificate_array[0]=='certificates') {
+				$is_certificate_mode = true;
+			}	
+			return $is_certificate_mode;
+	    }
+	   
 	/**
 	 * Gets the list of included resources as a list of absolute or relative paths from a html file or string html
 	 * This allows for a better SCORM export or replace urls inside content html from copy course

+ 109 - 11
main/inc/lib/usermanager.lib.php

@@ -9,17 +9,17 @@
 */
 
 // Constants for user extra field types.
-define('USER_FIELD_TYPE_TEXT', 1);
-define('USER_FIELD_TYPE_TEXTAREA', 2);
-define('USER_FIELD_TYPE_RADIO',3);
-define('USER_FIELD_TYPE_SELECT',4);
-define('USER_FIELD_TYPE_SELECT_MULTIPLE', 5);
-define('USER_FIELD_TYPE_DATE', 6);
-define('USER_FIELD_TYPE_DATETIME', 7);
-define('USER_FIELD_TYPE_DOUBLE_SELECT', 8);
-define('USER_FIELD_TYPE_DIVIDER', 9);
-define('USER_FIELD_TYPE_TAG', 10);
-define('USER_FIELD_TYPE_TIMEZONE', 11);
+define('USER_FIELD_TYPE_TEXT',		 		1);
+define('USER_FIELD_TYPE_TEXTAREA',			2);
+define('USER_FIELD_TYPE_RADIO',				3);
+define('USER_FIELD_TYPE_SELECT',			4);
+define('USER_FIELD_TYPE_SELECT_MULTIPLE',	5);
+define('USER_FIELD_TYPE_DATE', 				6);
+define('USER_FIELD_TYPE_DATETIME', 			7);
+define('USER_FIELD_TYPE_DOUBLE_SELECT', 	8);
+define('USER_FIELD_TYPE_DIVIDER', 			9);
+define('USER_FIELD_TYPE_TAG', 				10);
+define('USER_FIELD_TYPE_TIMEZONE', 			11);
 
 //User image sizes
 define('USER_IMAGE_SIZE_ORIGINAL',	1);
@@ -2995,6 +2995,104 @@ class UserManager
 		return $result;
 		
 	}
+	/**
+	 * get user id of teacher or session administrator
+	 * @param string The course id
+	 * @return int The user id
+	 */
+	 function get_user_id_of_course_admin_or_session_admin ($course_id) {
+	 	$session=api_get_session_id();
+		$table_user = Database::get_main_table(TABLE_MAIN_USER);
+		$table_course_user = Database::get_main_table(TABLE_MAIN_COURSE_USER);
+		$table_session_user = Database::get_main_table(TABLE_MAIN_SESSION_USER);	 			 	
+	 	if ($session==0 || is_null($session)) {
+	 		$sql='SELECT u.user_id FROM '.$table_user.' u
+					INNER JOIN '.$table_course_user.' ru ON ru.user_id=u.user_id
+					WHERE ru.status=1 AND ru.course_code="'.Database::escape_string($course_id).'" ';
+			$rs=Database::query($sql,__FILE__,__LINE__);
+			$num_rows=Database::num_rows($rs);
+			if ($num_rows==1) {
+				$row=Database::fetch_array($rs);
+				return $row['user_id'];
+			} else {
+				$my_num_rows=$num_rows;
+				$my_user_id=Database::result($rs,$my_num_rows-1,'user_id');
+				return $my_user_id;
+			}		
+		} elseif ($session>0) {
+			$sql='SELECT u.user_id FROM '.$table_user.' u
+				INNER JOIN '.$table_session_user.' sru
+				ON sru.id_coach=u.user_id WHERE sru.course_code="'.Database::escape_string($course_id).'" ';
+			$rs=Database::query($sql,__FILE__,__LINE__);
+			$row=Database::fetch_array($rs);
+			return $row['user_id'];
+		 	}
+		 }
+	 
+  /**
+   * Determines if a user is certified
+   * @param int The category id of gradebook
+   * @param int The user id
+   * @return boolean 
+   */
+  function is_user_certified($cat_id,$user_id) {
+  	$table_certificate = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CERTIFICATE);
+  	$sql='SELECT path_certificate FROM '.$table_certificate.' WHERE cat_id="'.Database::escape_string($cat_id).'" AND user_id="'.Database::escape_string($user_id).'" ';
+  	$rs=Database::query($sql,__FILE__,__LINE__);
+  	$row=Database::fetch_array($rs);
+  	if ($row['path_certificate']=='' || is_null($row['path_certificate'])) {
+  		return false;
+  	} else {
+  		return true;
+  	}
+  }
+
+   /**
+   * Gets the info about a gradebook certificate for a user by course 
+   * @param string The course code
+   * @param int The user id
+   * @return array  if there is not information return false 
+   */
+  function get_info_gradebook_certificate($course_code,$user_id) {
+  	$tbl_grade_certificate 	= Database::get_main_table(TABLE_MAIN_GRADEBOOK_CERTIFICATE);
+  	$tbl_grade_category 	= Database::get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY);
+  	$sql='SELECT * FROM '.$tbl_grade_certificate.' WHERE cat_id= (SELECT id FROM '.$tbl_grade_category.' WHERE course_code = "'.Database::escape_string($course_code).'" ) AND user_id="'.Database::escape_string($user_id).'" ';
+  	$rs = Database::query($sql,__FILE__,__LINE__);
+  	$row= Database::fetch_array($rs);
+  	if (Database::num_rows($rs) > 0) 
+  		return $row;  		
+  	else 
+  		return false;
+  }
+
+ /**
+  * Gets the user path of user certificated
+  * @param int The user id
+  * @return array  containing path_certificate and cat_id
+  */
+ function get_user_path_certificate($user_id) {
+ 	$my_certificate = array();
+	$table_certificate 			= Database::get_main_table(TABLE_MAIN_GRADEBOOK_CERTIFICATE);
+	$table_gradebook_category 	= Database::get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY);
+		 	
+ 	$session_id = api_get_session_id();
+ 	$user_id = intval($user_id);
+ 	if ($session_id==0 || is_null($session_id)) {
+ 		$sql_session='AND (session_id='.Database::escape_string($session_id).' OR isnull(session_id)) ';
+ 	} elseif ($session_id>0) {
+ 		$sql_session='AND session_id='.Database::escape_string($session_id);
+ 	} else {
+ 		$sql_session='';
+ 	}
+ 	$sql= "SELECT tc.path_certificate,tc.cat_id,tgc.course_code,tgc.name FROM $table_certificate tc, $table_gradebook_category tgc 
+	WHERE tgc.id = tc.cat_id AND tc.user_id='$user_id'  ORDER BY tc.date_certificate DESC limit 5";		
+
+ 	$rs=Database::query($sql,__FILE__,__LINE__);
+ 	while ($row=Database::fetch_array($rs)) {
+ 		$my_certificate[]=$row;
+ 	}
+ 	return $my_certificate;
+ }
 
 
 }

+ 33 - 46
main/user/subscribe_user.php

@@ -1,24 +1,18 @@
 <?php // $Id: subscribe_user.php 20412 2009-05-08 16:09:34Z herodoto $
-/* For licensing terms, see /license.txt
+/* For licensing terms, see /license.txt*/
 
 /**
-==============================================================================
 *	This script allows teachers to subscribe existing users
 *	to their course.
-*
-*	@package dokeos.user
-==============================================================================
-*/
-/*
-==============================================================================
-		INIT SECTION
-==============================================================================
+*	@package chamilo.user
 */
+
+/*			INIT SECTION		*/
 // name of the language file that needs to be included
 $language_file = array('registration','admin');
 
 // including the global Dokeos file
-include ('../inc/global.inc.php');
+require_once '../inc/global.inc.php';
 
 // the section (for the tabs)
 $this_section = SECTION_COURSES;
@@ -26,24 +20,17 @@ $this_section = SECTION_COURSES;
 if (!api_is_allowed_to_edit()) {
 	 api_not_allowed(true);
 }
+
 // including additional libraries
-require_once (api_get_path(LIBRARY_PATH).'course.lib.php');
-require_once (api_get_path(LIBRARY_PATH).'sessionmanager.lib.php');
-require_once (api_get_path(LIBRARY_PATH).'sortabletable.class.php');
-require_once (api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php');
-require_once (api_get_path(LIBRARY_PATH).'usermanager.lib.php');
+require_once api_get_path(LIBRARY_PATH).'course.lib.php';
+require_once api_get_path(LIBRARY_PATH).'sessionmanager.lib.php';
+require_once api_get_path(LIBRARY_PATH).'sortabletable.class.php';
+require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php';
+require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
 
-/*
-==============================================================================
-		MAIN CODE
-==============================================================================
-*/
+/*	MAIN CODE	*/
 
-/*
------------------------------------------------------------
-	Header
------------------------------------------------------------
-*/
+/*	Header	*/
 
 $tool_name = get_lang("SubscribeUserToCourse");
 if ($_REQUEST['type']=='teacher') {
@@ -512,23 +499,23 @@ function get_user_data($from, $number_of_items, $column, $direction) {
 			if ($_configuration['multiple_access_urls']==true) {
 				$url_access_id = api_get_current_access_url_id();
 				if ($url_access_id !=-1) {
+					
 					$tbl_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
 					$sql = "SELECT
-					u.user_id AS col0,
-					u.official_code AS col1,
-					".($is_western_name_order
-					? "u.firstname  AS col2,
-					u.lastname AS col3,"
-					: "u.lastname  AS col2,
-					u.firstname AS col3,")."
-					u.email 	AS col4,
-					u.active 	AS col5,
-					u.user_id   AS col6
-					FROM $user_table u
-					LEFT JOIN $course_user_table cu on u.user_id = cu.user_id and course_code='".$_SESSION['_course']['id']."'
-					INNER JOIN  $tbl_url_rel_user as url_rel_user
-					ON (url_rel_user.user_id = u.user_id)
-					WHERE cu.user_id IS NULL AND u.status<>".DRH." AND access_url_id= $url_access_id ";
+						u.user_id AS col0,
+						u.official_code AS col1,
+						".($is_western_name_order
+						? "u.firstname  AS col2,
+						u.lastname AS col3,"
+						: "u.lastname  AS col2,
+						u.firstname AS col3,")."
+						u.email 	AS col4,
+						u.active 	AS col5,
+						u.user_id   AS col6
+						FROM $user_table u
+						LEFT JOIN $course_user_table cu on u.user_id = cu.user_id and course_code='".$_SESSION['_course']['id']."'
+						INNER JOIN  $tbl_url_rel_user as url_rel_user
+						ON (url_rel_user.user_id = u.user_id) ";
 
 
 					// applying the filter of the additional user profile fields
@@ -539,11 +526,11 @@ function get_user_data($from, $number_of_items, $column, $direction) {
 								ON field_values.user_id = u.user_id
 							WHERE cu.user_id IS NULL AND u.status<>".DRH."
 								AND field_values.field_id = '".Database::escape_string($field_identification[0])."'
-								AND field_values.field_value = '".Database::escape_string($field_identification[1])."'";
+								AND field_values.field_value = '".Database::escape_string($field_identification[1])."' AND access_url_id= $url_access_id  ";
 					} else	{
-						$sql .=	"WHERE cu.user_id IS NULL AND u.status<>".DRH." AND access_url_id= $url_access_id ";
-					}
-
+						$sql .=	"WHERE  cu.user_id IS NULL AND u.status<>".DRH." AND access_url_id= $url_access_id ";
+					}					
+				
 				}
 			}
 		}
@@ -573,6 +560,7 @@ function get_user_data($from, $number_of_items, $column, $direction) {
 	// Sorting and pagination (used by the sortable table)
 	$sql .= " ORDER BY col$column $direction ";
 	$sql .= " LIMIT $from,$number_of_items";
+	
 	$res = Database::query($sql);
 	$users = array ();
 	while ($user = Database::fetch_row($res)) {
@@ -593,7 +581,6 @@ function get_user_data($from, $number_of_items, $column, $direction) {
 				}
 			}
 		}
-
 	}
 	return $users;
 }

+ 13 - 20
main/user/user.php

@@ -2,7 +2,6 @@
 /* For licensing terms, see /license.txt */
 
 /**
-==============================================================================
 *	This script displays a list of the users of the current course.
 *	Course admins can change user perimssions, subscribe and unsubscribe users...
 *
@@ -19,14 +18,11 @@
 *	@todo display table functions need support for align and valign (e.g. to center text in cells) (this is now possible)
 *	@author Roan Embrechts, refactoring + virtual courses support
 *	@author Julio Montoya Armas Several fixes
-*	@package dokeos.user
-==============================================================================
-*/
-/*
-==============================================================================
-	   INIT SECTION
-==============================================================================
+*	@package chamilo.user
 */
+
+
+/*	   INIT SECTION	*/
 // name of the language file that needs to be included
 $language_file = array('registration', 'admin', 'userInfo');
 $use_anonymous = true;
@@ -36,19 +32,8 @@ $this_section = SECTION_COURSES;
 // notice for unauthorized people.
 api_protect_course_script(true);
 
-if (!api_is_platform_admin(true)) {
-	if (!api_is_course_admin() && !api_is_coach()) { 
-		if (api_get_course_setting('allow_user_view_user_list')) {
-			api_not_allowed(true);
-		}
-	}	
-};
 
-/*
------------------------------------------------------------
-	Libraries
------------------------------------------------------------
-*/
+/*		Libraries	*/
 require_once api_get_path(LIBRARY_PATH).'debug.lib.inc.php';
 require_once api_get_path(LIBRARY_PATH).'export.lib.inc.php';
 require_once api_get_path(LIBRARY_PATH).'course.lib.php';
@@ -62,6 +47,14 @@ if (!isset ($_cid)) {
 	header('location: '.$_configuration['root_web']);
 }
 
+if (!api_is_platform_admin(true)) {
+	if (!api_is_course_admin() && !api_is_coach()) {
+		if (api_get_course_setting('allow_user_view_user_list')) {
+			api_not_allowed(true);
+		}
+	}	
+}
+
 /*
 -----------------------------------------------------------
 	Constants and variables

+ 10 - 28
main/user/userInfo.php

@@ -2,7 +2,6 @@
 /* For licensing terms, see /license.txt	*/
 
 /**
-==============================================================================
 *	This script displays info about one specific user, specified through
 *	a GET parameter, e.g. uInfo=2
 *
@@ -13,22 +12,17 @@
 *	@author original author (unknown, probably thomas,hugues,moosh)
 *	@author Roan Embrechts, minor modification: virtual courses support
 *	@author Julio Montoya Armas Several fixes
-*	@package dokeos.user
-==============================================================================
+*	@package chamilo.user
 */
 
-/*
-==============================================================================
-	   INIT SECTION
-==============================================================================
-*/
+/*	   INIT SECTION		*/
 
 // name of the language file that needs to be included
 $language_file = array ('registration', 'userInfo');
 
-include ("../inc/global.inc.php");
-require_once (api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php');
-require_once (api_get_path(LIBRARY_PATH).'usermanager.lib.php');
+require_once '../inc/global.inc.php';
+require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php';
+require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
 require_once api_get_path(LIBRARY_PATH).'tracking.lib.php';
 
 $htmlHeadXtra[] = '<script type="text/javascript">
@@ -49,8 +43,7 @@ $nameTools = get_lang('Users');
 api_protect_course_script(true);
 $tool_info = api_get_tool_information_by_name(TOOL_USER);
 
-if(api_is_anonymous())
-{
+if(api_is_anonymous()) {
 	api_not_allowed(true);
 }
 
@@ -108,7 +101,7 @@ $allowedToEditDef = api_is_allowed_to_edit();
 $is_allowedToTrack = api_is_allowed_to_edit() && $_configuration['tracking_enabled'];
 
 // Library connection
-include ("userInfoLib.php");
+require_once ("userInfoLib.php");
 
 /*
 ==============================================================================
@@ -261,14 +254,9 @@ if ($allowedToEditContent)
 	}
 }
 
-/*
-==============================================================================
-	   DISPLAY MODES
-==============================================================================
-*/
+/*	   DISPLAY MODES	*/
 // Back button for each display mode (Top)
 
-
 if (api_is_allowed_to_edit()) {
 	echo '<div class="actions">';
 	echo '<a href="user.php?'.api_get_cidreq().'&amp;origin='.$origin.'">'.Display::return_icon('back.png',get_lang('BackUser')).get_lang('BackUser').'</a>';	
@@ -280,8 +268,6 @@ if (api_is_allowed_to_edit()) {
 	echo '<a href="../mySpace/myStudents.php?'.api_get_cidreq().'&amp;origin=user_course&amp;student='.$userIdViewed.'&amp;details=true&amp;course='.$_course['id'].'">'.Display::return_icon('statistics.gif',get_lang('UserStatistics')).get_lang('UserStatistics').'</a>';
 	echo '</div>';
 } else {
-	
-	
 	if ($tool_info['visibility'] == 1 ) {
 		echo '<div class="actions">';
 		echo '<a href="user.php?'.api_get_cidreq().'&amp;origin='.$origin.'">'.Display::return_icon('back.png',get_lang('BackUser')).get_lang('BackUser').'</a>';
@@ -628,10 +614,6 @@ elseif ($displayMode == "viewContentList") // default display
 
 // Back button for each display mode (bottom)
 //echo "<div class=\"actions\"><a href=\"user.php?".api_get_cidreq()."&amp;origin=".$origin."\">".get_lang('BackUser')."</a></div>\n";
-/*
-==============================================================================
-		FOOTER
-==============================================================================
-*/
+/*		FOOTER	*/
 Display :: display_footer();
-?>
+?>

+ 5 - 13
main/user/user_add.php

@@ -1,15 +1,10 @@
 <?php
 /* For licensing terms, see /license.txt*/
-
 /**
-==============================================================================
-*	@package dokeos.user
-==============================================================================
+*	@package chamilo.user
 */
 
-/*==========================
-            INIT
-  ==========================*/
+/* INIT	*/
 
 // name of the language file that needs to be included
 $language_file="registration";
@@ -28,17 +23,14 @@ $tbl_courseUser    = "course_rel_user";
 
 
 
-/*==========================
-         DATA CHECKING
-  ==========================*/
+/* DATA CHECKING	*/
 
-if($register)
-{
+if($register) {
 	/*
 	 * Fields Checking
 	 */
 
-	$lastname_form      = trim($lastname_form);
+	$lastname_form    = trim($lastname_form);
 	$firstname_form   = trim($firstname_form);
 	$password_form = trim($password_form);
 	$username_form = trim($username_form);