浏览代码

Merge branch '1.9.x' of github.com:chamilo/chamilo-lms into 1.9.x

Francis Gonzales 11 年之前
父节点
当前提交
2b72f20691
共有 100 个文件被更改,包括 7657 次插入3161 次删除
  1. 0 125
      .hgignore
  2. 2 0
      documentation/credits.html
  3. 13 0
      documentation/installation_guide.html
  4. 28 0
      documentation/optimization.html
  5. 2 2
      main/admin/access_url_edit.php
  6. 2 2
      main/admin/access_url_edit_courses_to_url.php
  7. 3 2
      main/admin/access_url_edit_users_to_url.php
  8. 13 10
      main/admin/add_courses_to_session.php
  9. 75 61
      main/admin/add_courses_to_usergroup.php
  10. 23 4
      main/admin/add_sessions_to_usergroup.php
  11. 306 363
      main/admin/add_users_to_group.php
  12. 51 34
      main/admin/add_users_to_session.php
  13. 16 9
      main/admin/add_users_to_usergroup.php
  14. 54 54
      main/admin/dashboard_add_courses_to_user.php
  15. 39 34
      main/admin/dashboard_add_sessions_to_user.php
  16. 206 111
      main/admin/dashboard_add_users_to_user.php
  17. 4 3
      main/admin/index.php
  18. 1 2
      main/admin/session_edit.php
  19. 42 14
      main/admin/system_announcements.php
  20. 17 9
      main/admin/user_list.php
  21. 2 2
      main/admin/usergroups.php
  22. 54 26
      main/announcements/announcement_email.class.php
  23. 93 140
      main/announcements/announcements.inc.php
  24. 2 2
      main/announcements/announcements.php
  25. 1 1
      main/attendance/attendance_list.php
  26. 6 6
      main/calendar/agenda.inc.php
  27. 219 12
      main/calendar/agenda.lib.php
  28. 14 14
      main/calendar/agenda.php
  29. 3 1
      main/calendar/agenda_js.php
  30. 24 46
      main/chat/chat.php
  31. 46 51
      main/chat/chat_chat.php
  32. 34 32
      main/chat/chat_functions.lib.php
  33. 17 16
      main/chat/chat_hidden.php
  34. 47 47
      main/chat/chat_message.php
  35. 48 53
      main/chat/chat_whoisonline.php
  36. 28 35
      main/chat/header_frame.inc.php
  37. 5 8
      main/course_description/add.php
  38. 14 0
      main/course_info/infocours.php
  39. 287 291
      main/coursecopy/classes/Course.class.php
  40. 1 1
      main/coursecopy/classes/CourseRestorer.class.php
  41. 1 1
      main/create_course/add_course.php
  42. 163 0
      main/css/academica/scorm.css
  43. 163 0
      main/css/baby_orange/scorm.css
  44. 0 111
      main/css/base.css
  45. 163 0
      main/css/blue_lagoon/scorm.css
  46. 163 0
      main/css/chamilo/scorm.css
  47. 163 0
      main/css/chamilo_electric_blue/scorm.css
  48. 163 0
      main/css/chamilo_green/scorm.css
  49. 269 110
      main/css/chamilo_orange/scorm.css
  50. 163 4
      main/css/chamilo_red/scorm.css
  51. 163 0
      main/css/chamilo_sport_red/scorm.css
  52. 163 2
      main/css/cool_blue/scorm.css
  53. 163 1
      main/css/corporate/scorm.css
  54. 163 1
      main/css/cosmic_campus/scorm.css
  55. 0 0
      main/css/default_scorm.css
  56. 163 0
      main/css/delicious_bordeaux/scorm.css
  57. 163 2
      main/css/dokeos_blue/scorm.css
  58. 163 0
      main/css/dokeos_classic/scorm.css
  59. 163 1
      main/css/dokeos_classic_2D/scorm.css
  60. 163 0
      main/css/empire_green/scorm.css
  61. 163 2
      main/css/fruity_orange/scorm.css
  62. 163 1
      main/css/medical/scorm.css
  63. 163 0
      main/css/public_admin/scorm.css
  64. 163 2
      main/css/royal_purple/scorm.css
  65. 163 2
      main/css/silver_line/scorm.css
  66. 164 2
      main/css/sober_brown/scorm.css
  67. 163 4
      main/css/steel_grey/scorm.css
  68. 163 2
      main/css/tasty_olive/scorm.css
  69. 23 13
      main/dashboard/block.class.php
  70. 6 6
      main/document/document.inc.php
  71. 137 64
      main/document/document.php
  72. 103 106
      main/document/edit_document.php
  73. 13 23
      main/document/record_audio_wami.php
  74. 49 49
      main/document/showinframes.php
  75. 11 6
      main/dropbox/dropbox_download.php
  76. 36 18
      main/dropbox/dropbox_functions.inc.php
  77. 29 25
      main/exercice/admin.php
  78. 2 2
      main/exercice/aiken.php
  79. 44 39
      main/exercice/answer.class.php
  80. 54 6
      main/exercice/exercice.php
  81. 103 65
      main/exercice/exercise.class.php
  82. 61 31
      main/exercice/exercise.lib.php
  83. 114 10
      main/exercice/exercise_report.php
  84. 13 4
      main/exercice/exercise_result.php
  85. 1 1
      main/exercice/exercise_show.php
  86. 69 65
      main/exercice/fill_blanks.class.php
  87. 72 36
      main/exercice/hotpotatoes.lib.php
  88. 31 26
      main/exercice/hotpotatoes.php
  89. 75 178
      main/exercice/hotpotatoes_exercise_report.php
  90. 144 146
      main/exercice/hotpotatoes_exercise_result.class.php
  91. 10 9
      main/exercice/question.class.php
  92. 13 11
      main/exercice/question_admin.inc.php
  93. 二进制
      main/exercice/quiz_template.xls
  94. 7 9
      main/exercice/savescores.php
  95. 35 47
      main/exercice/showinframes.php
  96. 7 7
      main/exercice/tests_category.php
  97. 23 8
      main/exercice/upload_exercise.php
  98. 17 13
      main/forum/forumconfig.inc.php
  99. 317 250
      main/forum/forumfunction.inc.php
  100. 13 17
      main/forum/forumqualify.php

+ 0 - 125
.hgignore

@@ -1,125 +0,0 @@
-#
-#ignoring some file
-syntax: glob
-main/inc/conf
-#main/inc/conf/*
-#!main/inc/conf/index.html
-#!main/inc/conf/*.dist.*
-
-#temp dokeos directories
-archive/*
-!archive/.htaccess
-courses/*
-!courses/index.html
-main/garbage/*
-!main/garbage/index.html
-!main/garbage/Serializer
-
-#Home
-home/*
-#!home/default_platform_document
-#!home/faq.html
-#!home/home_menu.html
-#!home/home_news.html
-#!home/home_notice.html
-#!home/home_top.html
-#!home/index.html
-#!home/large_dokeos_logo.gif
-
-#garbage directory
-
-#Avatar images
-main/upload/users/*
-!main/upload/users/index.html
-
-#Images uploaded by user
-#main/default_course_document/images/*
-#!main/default_course_document/images/board.jpg
-#!main/default_course_document/images/bookcase.jpg
-#!main/default_course_document/images/book_highlight.jpg
-#!main/default_course_document/images/book.jpg
-#!main/default_course_document/images/computer.jpg
-#!main/default_course_document/images/diagrams
-#!main/default_course_document/images/emot_happy.jpg
-#!main/default_course_document/images/emot_neutral.jpg
-#!main/default_course_document/images/emot_sad.jpg
-#!main/default_course_document/images/emot_wink.jpg
-#!main/default_course_document/images/female.jpg
-#!main/default_course_document/images/geometry.jpg
-#!main/default_course_document/images/homework.jpg
-#!main/default_course_document/images/idea.jpg
-#!main/default_course_document/images/interaction.jpg
-#!main/default_course_document/images/logo_dokeos.png
-#!main/default_course_document/images/male.jpg
-#!main/default_course_document/images/maths.jpg
-#!main/default_course_document/images/mechanism.jpg
-#!main/default_course_document/images/mouse.jpg
-#!main/default_course_document/images/mr_dokeos
-#!main/default_course_document/images/newspaper.jpg
-#!main/default_course_document/images/note.jpg
-#!main/default_course_document/images/pencil.png
-#!main/default_course_document/images/presentation.jpg
-#!main/default_course_document/images/redlight.jpg
-#!main/default_course_document/images/science.jpg
-#!main/default_course_document/images/servicesgather.png
-#!main/default_course_document/images/silhouette.png
-#!main/default_course_document/images/small
-#!main/default_course_document/images/speech.jpg
-#!main/default_course_document/images/time.jpg
-#!main/default_course_document/images/trainer
-#!main/default_course_document/images/tutorial.jpg
-#!main/default_course_document/images/twopeople.png
-#!main/default_course_document/images/world.jpg
-#!main/default_course_document/images/write.jpg
-
-#css
-#main/css/*
-#*.css
-#!main/css/academica
-#!main/css/baby_orange
-#!main/css/blue_lagoon
-#!main/css/cool_blue
-#!main/css/corporate
-#!main/css/cosmic_campus
-#!main/css/csshover3.htc
-#!main/css/delicious_bordeaux
-#!main/css/dokeos_blue
-#!main/css/dokeos_classic
-#!main/css/dokeos_classic_2D
-#!main/css/empire_green
-#!main/css/fruity_orange
-#!main/css/index.html
-#!main/css/medical
-#!main/css/public_admin
-#!main/css/royal_purple
-#!main/css/silver_line
-#!main/css/sober_brown
-#!main/css/steel_grey
-#!main/css/tasty_olive
-
-#plugins
-#plugin/*
-#!plugin/date
-#!plugin/index.html
-#!plugin/search
-
-#PHP Storm settings directory
-.idea/*
-.idea/cssxfire.xml
-.idea
-
-# Xapian indexes directory
-searchdb/*
-!searchdb/index.html
-
-main/inc/cache/*
-test_laurent.php
-*.orig
-main/auth/shibboleth/config.php
-syntax: regexp
-^main/upload/users$
-
-syntax: regexp
-^\.settings$
-
-nbproject/*

+ 2 - 0
documentation/credits.html

@@ -683,6 +683,7 @@ Note that we are infinitely grateful to our translators, having made the spread
   <li>Francis Gonzales Tello, for a first draft of the OpenMeetings plugin for 1.9.8</li>
   <li>Maxim Solodovnik, for his help in the development of the OpenMeetings plugin for 1.9.8 - see https://issues.apache.org/jira/browse/OPENMEETINGS-802</li>
   <li>Adolfo Igualada Martínez, for changes to the glossary to PDF export for subdir installs in 1.9.8 (#6929)</li>
+  <li>Kevin Levron, for several contributions to Chamilo LMS 1.9.*</li>
   <li>All the supporting parents, partners, children, friends, colleagues and sometimes students, of the very special geeks that we are, for their continous support and inspiration</li> 
 </ul>
 
@@ -713,6 +714,7 @@ These institutions and companies have either contributed to the Chamilo project
   <li>Universidad de Tocantins, Tocantins, Brazil</li>
   <li>Université de Genève, Geneva, Switzerland</li>
   <li>Université de Grenoble, Grenoble, France</li>
+  <li>Université de Pau, Pau, France</li>
   <li>Unidad Editorial, Spain</li>
   <li>Universidad Autónoma, Chile</li>
   <li>Vall d'Hebron Hospital, Barcelona, Spain</li>

+ 13 - 0
documentation/installation_guide.html

@@ -60,6 +60,7 @@
   <li><a href="#11._Chamilo_rapid_ppt_conversion">Chamilo Rapid - PPT conversion system</a></li>
   <li><a href="#12._Setting_cron_up">Setting chronological tasks</a></li>
   <li><a href="#13._Changing_language_name_order">Changing the language's firstname/lastname order</a></li>
+  <li><a hreg="#14._Improving_files_download">Improving files download time</a></li>
 </ol>
 
 <br />
@@ -820,6 +821,18 @@ Feel free to change this to<br />
 for example. The effect should be immediate.
 </p>
 <hr style="width: 100%; height: 2px;" />
+<h2><a name="14._Improving_files_download"></a>Improving files download efficiency</h2>
+<p>
+File download can be very slow when passing through a PHP script to control permissions. One solution to this
+    is to use the X-Sendfile header, which depends on a module on the webserver. <a href="http://stackoverflow.com/a/3731639/1406662">Check http://stackoverflow.com/a/3731639/1406662 for more details on implementing Sendfile</a>.
+Chamilo LMS 1.9.8 (and following versions) supports the X-Sendfile headers, but requires a specific line of configuration to be
+    added to configuration.php:
+<pre>
+$_configuration['enable_x_sendfile_headers'] = true;
+</pre>
+If you have issues with files taking a long time to download, make sure you reconfigure your webserver and add this line. You should see an notable difference in download time.
+</p>
+<hr style="width: 100%; height: 2px;" />
 <p>
   <br />
   <br />

+ 28 - 0
documentation/optimization.html

@@ -48,6 +48,7 @@
   <li><a href="#6.Zlib-compression">Zlib compressed output</a></li>
   <li><a href="#7.High-numbers-memory">Memory considerations for high numbers of users</a></li>
   <li><a href="#8.Avoid-non-fixed-values">Avoiding non-fixed values</a></li>
+  <li><a href="#9.xsendfile">Speeding file downloads with mod_xsendfile</a></li>
 </ol>
 
 <h2><a name="1.Using-XCache"></a>1. Using xCache or APC</h2>
@@ -172,6 +173,7 @@ If you prefer using <a href="http://php.net/manual/en/book.apc.php">APC</a>, you
         }
      ...
 </pre>
+<p>It is also worth noting that the Université de Genève, Switzerland, observed that the calculation of the total size used by course documents is one of the heaviest queries in Chamilo, so you might want to cache the results of this one as well, using the same technique.</p>
 <hr />
 <h2><a name="2.Slow-queries"></a>2. Slow queries</h2>
 Enable slow_queries in /etc/mysqld/my.cnf, restart MySQL then follow using sudo tail -f /var/log/mysql/mysql-slow.log
@@ -262,6 +264,32 @@ $platform_email['SMTP_MAILER']       = 'mail';
 </pre>
 In fact, the complete loading of mail.conf.php can also be avoided if loaded conditionally (with <i>require_once</i>) when sending an e-mail (which is the only case where it is useful).
 <hr />
+<h2><a name="#9.xsendfile"></a>Speeding file downloads with mod_xsendfile</h2>
+<p>It might have come to your attention that file downloads through Chamilo might get slow, under default conditions, in particular using Apache 2.</p>
+<p>There are several ways to fix this, one of which is removing the .htaccess inside the courses/ directory. This, however, will remove all permissions checks on the files contained in this directory, so... most of the time, not ideal unless your portal is *really* open to the world.</p>
+<p>Another technique, revealed to us by <a href="http://stackoverflow.com/users/46594/virtualblackfox">VirtualBlackFox</a> on <a href="http://stackoverflow.com/questions/3697748/fastest-way-to-serve-a-file-using-php">this Stackoverflow post</a>, is to use the X-SendFile module for Apache 2.2+ (other web servers might offer other solutions, or avoid the problem initially).</p>
+<p>Installing the X-SendFile module will depend on your operating system, but if you use Ubuntu, you'll have to check you are including the "universe" repository inside your packages sources (check /etc/apt/sources.list), then:
+<pre>
+sudo apt-get update
+sudo apt-get install libapache2-mod-xsendfile
+sudo service apache2 restart
+</pre>
+Once you're done with installing, you'll have to configure Chamilo to use it.<br />
+First, edit your VirtualHost or your Apache configuration in general (in Ubuntu, check the /etc/apache2/ or /etc/apache2/sites-available/ folder). This is done by adding the following line inside your configuration, and reloading Apache (example provided on the basis of a virtual host located in /etc/apache2/sites-available/my.chamilo.net.conf) :
+<pre>
+sudo vim /etc/apache2/sites-available/my.chamilo.net.conf
+# add the following line:
+  X-SendFile on
+# exit the file
+sudo service apache2 reload
+</pre>
+Finally, you'll have to got to your Chamilo configuration file, and add the following line at the very bottom of the file main/inc/conf/configuration.php:
+<pre>
+$_configuration['enable_x_sendfile_headers'] = true;
+</pre>
+Done! Now your downloads should go substantially faster. This is still a feature in observation. We're not sure the benefits are sufficient, so don't hesitate to let us know in <a href="https://support.chamilo.org/issues/6853">the related issue in Chamilo's tracking system</a>
+</p>
+<hr />
 <h2>Authors</h2>
 <ul>
 <li>Yannick Warnier, Zend Certified PHP Engineer, BeezNest Belgium SPRL, <a href="mailto:ywarnier@beeznest.net">ywarnier@beeznest.net</a></li>

+ 2 - 2
main/admin/access_url_edit.php

@@ -37,9 +37,9 @@ if ($form->validate()) {
             }
             //checking url
             if (substr($url, strlen($url)-1, strlen($url)) == '/') {
-                UrlManager::udpate($url_id, $url, $description, $active);
+                UrlManager::update($url_id, $url, $description, $active);
             } else {
-                UrlManager::udpate($url_id, $url.'/', $description, $active);
+                UrlManager::update($url_id, $url.'/', $description, $active);
             }
             // URL Images
             $url_images_dir = api_get_path(SYS_PATH).'custompages/url-images/';

+ 2 - 2
main/admin/access_url_edit_courses_to_url.php

@@ -92,7 +92,7 @@ $errorMsg='';
 $UserList=$SessionList=array();
 $users=$sessions=array();
 
-if($_POST['form_sent']) {
+if (isset($_POST['form_sent']) && $_POST['form_sent']) {
 	$form_sent=$_POST['form_sent'];
 	$course_list=$_POST['course_list'];
 
@@ -119,7 +119,7 @@ echo '</div>';
 
 api_display_tool_title($tool_name);
 
-if ($_GET['action'] == 'show_message')
+if (isset($_GET['action']) && $_GET['action'] == 'show_message')
 	Display :: display_normal_message(Security::remove_XSS(stripslashes($_GET['message'])));
 
 $no_course_list = $course_list = array();

+ 3 - 2
main/admin/access_url_edit_users_to_url.php

@@ -92,7 +92,7 @@ $UserList = array();
 
 $message = '';
 
-if ($_POST['form_sent']) {
+if (isset($_POST['form_sent']) && $_POST['form_sent']) {
     $form_sent = $_POST['form_sent'];
     $UserList = $_POST['sessionUsersList'];
 
@@ -102,6 +102,7 @@ if ($_POST['form_sent']) {
     if ($form_sent == 1) {
         if ($access_url_id == 0) {
             header('Location: access_url_edit_users_to_url.php?action=show_message&message=' . get_lang('SelectURL'));
+            exit;
         } elseif (is_array($UserList)) {
             $result = UrlManager::update_urls_rel_user($UserList, $access_url_id);
             $url_info = UrlManager::get_url_data_from_id($access_url_id);
@@ -156,7 +157,7 @@ echo '</div>';
 
 api_display_tool_title($tool_name);
 
-if ($_GET['action'] == 'show_message')
+if (isset($_GET['action']) && $_GET['action'] == 'show_message') {
     Display :: display_normal_message(Security::remove_XSS(stripslashes($_GET['message'])));
 
 $nosessionUsersList = $sessionUsersList = array();

+ 13 - 10
main/admin/add_courses_to_session.php

@@ -5,22 +5,22 @@
  * @todo use formvalidator
  */
 
-// name of the language file that needs to be included
-$language_file='admin';
+// name of the language file that needs to be included.
+$language_file = 'admin';
 
-// resetting the course id
+// resetting the course id.
 $cidReset = true;
 
 require_once '../inc/global.inc.php';
 require_once api_get_path(LIBRARY_PATH).'add_courses_to_session_functions.lib.php';
 
 $id_session = isset($_GET['id_session']) ? intval($_GET['id_session']) : null;
+$add = isset($_GET['add']) ? Security::remove_XSS($_GET['add']) : null;
 
 SessionManager::protect_session_edit($id_session);
 
 $xajax = new xajax();
-//$xajax->debugOn();
-$xajax -> registerFunction (array('search_courses', 'AddCourseToSession', 'search_courses'));
+$xajax->registerFunction (array('search_courses', 'AddCourseToSession', 'search_courses'));
 
 // Setting the section (for the tabs)
 $this_section = SECTION_PLATFORM_ADMIN;
@@ -28,7 +28,7 @@ $this_section = SECTION_PLATFORM_ADMIN;
 // setting breadcrumbs
 $interbreadcrumb[] = array('url' => 'index.php', 'name' => get_lang('PlatformAdmin'));
 $interbreadcrumb[] = array('url' => 'session_list.php','name' => get_lang('SessionList'));
-$interbreadcrumb[] = array('url' => "resume_session.php?id_session=".$id_session,"name" => get_lang('SessionOverview'));
+$interbreadcrumb[] = array('url' => "resume_session.php?id_session=".$id_session, "name" => get_lang('SessionOverview'));
 
 // Database Table Definitions
 $tbl_session_rel_course_rel_user	= Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
@@ -155,10 +155,11 @@ if (isset($_POST['formSent']) && $_POST['formSent']) {
 	$nbr_courses=count($CourseList);
 	Database::query("UPDATE $tbl_session SET nbr_courses=$nbr_courses WHERE id='$id_session'");
 
-	if (isset($_GET['add']))
+	if (isset($add)) {
 		header('Location: add_users_to_session.php?id_session='.$id_session.'&add=true');
-	else
+    } else {
 		header('Location: resume_session.php?id_session='.$id_session);
+    }
     exit;
 }
 
@@ -166,11 +167,13 @@ if (isset($_POST['formSent']) && $_POST['formSent']) {
 Display::display_header($tool_name);
 
 if ($add_type == 'multiple') {
-	$link_add_type_unique = '<a href="'.api_get_self().'?id_session='.$id_session.'&add='.Security::remove_XSS($_GET['add']).'&add_type=unique">'.Display::return_icon('single.gif').get_lang('SessionAddTypeUnique').'</a>';
+	$link_add_type_unique = '<a href="'.api_get_self().'?id_session='.$id_session.'&add='.$add.'&add_type=unique">'.
+        Display::return_icon('single.gif').get_lang('SessionAddTypeUnique').'</a>';
 	$link_add_type_multiple = Display::return_icon('multiple.gif').get_lang('SessionAddTypeMultiple').' ';
 } else {
 	$link_add_type_unique = Display::return_icon('single.gif').get_lang('SessionAddTypeUnique').'&nbsp;&nbsp;&nbsp;';
-	$link_add_type_multiple = '<a href="'.api_get_self().'?id_session='.$id_session.'&add='.Security::remove_XSS($_GET['add']).'&add_type=multiple">'.Display::return_icon('multiple.gif').get_lang('SessionAddTypeMultiple').'</a>';
+	$link_add_type_multiple = '<a href="'.api_get_self().'?id_session='.$id_session.'&add='.$add.'&add_type=multiple">'.
+        Display::return_icon('multiple.gif').get_lang('SessionAddTypeMultiple').'</a>';
 }
 
 // the form header

+ 75 - 61
main/admin/add_courses_to_usergroup.php

@@ -4,47 +4,44 @@
 *   @package chamilo.admin
 */
 
-// name of the language file that needs to be included
-$language_file = array('admin','registration');
+// Name of the language file that needs to be included.
+$language_file = array('admin', 'registration');
 
-// resetting the course id
+// Resetting the course id.
 $cidReset = true;
 
-// including some necessary files
+// Including some necessary files.
 require_once '../inc/global.inc.php';
 require_once '../inc/lib/xajax/xajax.inc.php';
 require_once api_get_path(LIBRARY_PATH).'usergroup.lib.php';
 
 $xajax = new xajax();
-
-//$xajax->debugOn();
 $xajax->registerFunction('search');
 
-// setting the section (for the tabs)
+// Setting the section (for the tabs).
 $this_section = SECTION_PLATFORM_ADMIN;
 
-// Access restrictions
+// Access restrictions.
 api_protect_admin_script(true);
 
-// setting breadcrumbs
-$interbreadcrumb[]=array('url' => 'index.php','name' => get_lang('PlatformAdmin'));
-$interbreadcrumb[]=array('url' => 'usergroups.php','name' => get_lang('Classes'));
-
-// Database Table Definitions
+// Setting breadcrumbs.
+$interbreadcrumb[] = array('url' => 'index.php','name' => get_lang('PlatformAdmin'));
+$interbreadcrumb[] = array('url' => 'usergroups.php','name' => get_lang('Classes'));
 
-// setting the name of the tool
-$tool_name=get_lang('SubscribeClassToCourses');
+// Setting the name of the tool.
+$tool_name = get_lang('SubscribeClassToCourses');
 
 $add_type = 'multiple';
-if(isset($_REQUEST['add_type']) && $_REQUEST['add_type']!=''){
+if (isset($_REQUEST['add_type']) && $_REQUEST['add_type']!=''){
     $add_type = Security::remove_XSS($_REQUEST['add_type']);
 }
 
+$add = isset($_GET['add']) ? Security::remove_XSS($_GET['add']) : null;
+
 $htmlHeadXtra[] = $xajax->getJavascript('../inc/lib/xajax/');
 $htmlHeadXtra[] = '
 <script>
 function add_user_to_session (code, content) {
-
     document.getElementById("user_to_add").value = "";
     document.getElementById("ajax_list_users_single").innerHTML = "";
 
@@ -70,23 +67,23 @@ function remove_item(origin) {
 }
 
 function validate_filter() {
-        document.formulaire.add_type.value = \''.$add_type.'\';
-        document.formulaire.form_sent.value=0;
-        document.formulaire.submit();
+    document.formulaire.add_type.value = \''.$add_type.'\';
+    document.formulaire.form_sent.value=0;
+    document.formulaire.submit();
 }
 </script>';
 
-
 $form_sent  = 0;
 $errorMsg   = '';
-$sessions=array();
+$sessions = array();
 $usergroup = new UserGroup();
 $id = intval($_GET['id']);
-if ($_POST['form_sent']) {
+
+if (isset($_POST['form_sent']) && $_POST['form_sent']) {
     $form_sent = $_POST['form_sent'];
     $elements_posted = $_POST['elements_in_name'];
     if (!is_array($elements_posted)) {
-        $elements_posted=array();
+        $elements_posted = array();
     }
     if ($form_sent == 1) {
         $usergroup->subscribe_courses_to_usergroup($id, $elements_posted);
@@ -94,21 +91,59 @@ if ($_POST['form_sent']) {
         exit;
     }
 }
+
+
+// Filters
+$filters = array(
+    array('type' => 'text', 'name' => 'code', 'label' => get_lang('CourseCode')),
+    array('type' => 'text', 'name' => 'title', 'label' => get_lang('Title')),
+    /*array('type' => 'text', 'name' => 'lastname', 'label' => get_lang('LastName')),
+    array('type' => 'text', 'name' => 'official_code', 'label' => get_lang('OfficialCode')),
+    array('type' => 'text', 'name' => 'email', 'label' => get_lang('Email'))*/
+);
+
+$searchForm = new FormValidator('search', 'get', api_get_self().'?id='.$id);
+$searchForm->add_header(get_lang('AdvancedSearch'));
+$renderer =& $searchForm->defaultRenderer();
+$searchForm->addElement('hidden', 'id', $id);
+foreach ($filters as $param) {
+    $searchForm->addElement($param['type'], $param['name'], $param['label']);
+}
+$searchForm->addElement('button', 'submit', get_lang('Search'));
+
+$filterData = array();
+if ($searchForm->validate()) {
+    $filterData = $searchForm->getSubmitValues();
+}
+
+$conditions = array();
+if (!empty($filters) && !empty($filterData)) {
+    foreach ($filters as $filter) {
+        if (isset($filter['name']) && isset($filterData[$filter['name']])) {
+            $value = $filterData[$filter['name']];
+            if (!empty($value)) {
+                $conditions[$filter['name']] = $value;
+            }
+        }
+    }
+}
+
 $data = $usergroup->get($id);
-$course_list_in = $usergroup->get_courses_by_usergroup($id);
-$course_list = CourseManager::get_courses_list(0, 0, 'title', 'asc', -1, null, api_get_current_access_url_id());
+$course_list_in = $usergroup->get_courses_by_usergroup($id, true);
+$course_list = CourseManager::get_courses_list(0, 0, 'title', 'asc', -1, null, api_get_current_access_url_id(), false, $conditions);
+
+$elements_not_in = $elements_in = array();
 
-$elements_not_in = $elements_in= array();
+foreach ($course_list_in as $course) {
+    $elements_in[$course['id']] = $course['title']." (".$course['visual_code'].")";
+}
 
 if (!empty($course_list)) {
     foreach ($course_list as $item) {
-        if (in_array($item['id'], $course_list_in)) {
-            $elements_in[$item['id']] = $item['title']." (".$item['visual_code'].")";
-        } else {
-            $elements_not_in[$item['id']] = $item['title']." (".$item['visual_code'].")";
-        }
+        $elements_not_in[$item['id']] = $item['title']." (".$item['visual_code'].")";
     }
 }
+
 $ajax_search = $add_type == 'unique' ? true : false;
 
 //checking for extra field with filter on
@@ -168,50 +203,29 @@ $xajax->processRequests();
 Display::display_header($tool_name);
 
 if ($add_type == 'multiple') {
-    $link_add_type_unique = '<a href="'.api_get_self().'?id_session='.$id_session.'&add='.Security::remove_XSS($_GET['add']).'&add_type=unique">'.
+    $link_add_type_unique = '<a href="'.api_get_self().'?add='.$add.'&add_type=unique">'.
         Display::return_icon('single.gif').get_lang('SessionAddTypeUnique').'</a>';
     $link_add_type_multiple = Display::return_icon('multiple.gif').get_lang('SessionAddTypeMultiple');
 } else {
     $link_add_type_unique = Display::return_icon('single.gif').get_lang('SessionAddTypeUnique');
-    $link_add_type_multiple = '<a href="'.api_get_self().'?id_session='.$id_session.'&add='.Security::remove_XSS($_GET['add']).'&add_type=multiple">'.
+    $link_add_type_multiple = '<a href="'.api_get_self().'?add='.$add.'&add_type=multiple">'.
         Display::return_icon('multiple.gif').get_lang('SessionAddTypeMultiple').'</a>';
 }
 
 echo '<div class="actions">';
 echo '<a href="usergroups.php">'.Display::return_icon('back.png',get_lang('Back'), array(), ICON_SIZE_MEDIUM).'</a>';
+echo Display::url(get_lang('AdvancedSearch'), '#', array('class' => 'advanced_options', 'id' => 'advanced_search'));
+echo '</div>';
+
+echo '<div id="advanced_search_options" style="display:none">';
+$searchForm->display();
 echo '</div>';
+
 ?>
 
 <form name="formulaire" method="post" action="<?php echo api_get_self(); ?>?id=<?php echo $id; if(!empty($_GET['add'])) echo '&add=true' ; ?>" style="margin:0px;" <?php if($ajax_search){echo ' onsubmit="valide();"';}?>>
 
 <?php echo '<legend>'.$data['name'].': '.$tool_name.'</legend>';
-
-if ($add_type=='multiple') {
-    if (is_array($extra_field_list)) {
-        if (is_array($new_field_list) && count($new_field_list) > 0) {
-            echo '<h3>'.get_lang('FilterUsers').'</h3>';
-            foreach ($new_field_list as $new_field) {
-                echo $new_field['name'];
-                $varname = 'field_'.$new_field['variable'];
-                echo '&nbsp;<select name="'.$varname.'">';
-                echo '<option value="0">--'.get_lang('Select').'--</option>';
-                foreach ($new_field['data'] as $option) {
-                    $checked='';
-                    if (isset($_POST[$varname])) {
-                        if ($_POST[$varname]==$option[1]) {
-                            $checked = 'selected="true"';
-                        }
-                    }
-                    echo '<option value="'.$option[1].'" '.$checked.'>'.$option[1].'</option>';
-                }
-                echo '</select>';
-                echo '&nbsp;&nbsp;';
-            }
-            echo '<input type="button" value="'.get_lang('Filter').'" onclick="validate_filter()" />';
-            echo '<br /><br />';
-        }
-    }
-}
 echo Display::input('hidden', 'id', $id);
 echo Display::input('hidden', 'form_sent', '1');
 echo Display::input('hidden', 'add_type', null);

+ 23 - 4
main/admin/add_sessions_to_usergroup.php

@@ -69,6 +69,16 @@ function remove_item(origin) {
     }
 }
 
+function display_advanced_search () {
+        if ($("#advancedSearch").css("display") == "none") {
+                $("#advancedSearch").css("display","block");
+                $("#img_plus_and_minus").html(\'&nbsp;'.Display::return_icon('div_hide.gif',get_lang('Hide'),array('style'=>'vertical-align:middle')).'&nbsp;'.get_lang('AdvancedSearch').'\');
+        } else {
+                $("#advancedSearch").css("display","none");
+                $("#img_plus_and_minus").html(\'&nbsp;'.Display::return_icon('div_show.gif',get_lang('Show'),array('style'=>'vertical-align:middle')).'&nbsp;'.get_lang('AdvancedSearch').'\');
+        }
+}
+
 function validate_filter() {
         document.formulaire.add_type.value = \''.$add_type.'\';
         document.formulaire.form_sent.value=0;
@@ -120,7 +130,7 @@ function search_sessions($needle,$type) {
     global $tbl_user,$elements_in;
     $xajax_response = new XajaxResponse();
     $return = '';
-    if (!empty($needle) && !empty($type)) {
+    if (isset($needle) && !empty($type)) {
 
         // xajax send utf8 datas... datas in db can be non-utf8 datas
         $charset = api_get_system_encoding();
@@ -135,9 +145,12 @@ function search_sessions($needle,$type) {
                 OR lastname LIKE "'.$needle.'%") AND user.user_id<>"'.$user_anonymous.'"   AND user.status<>'.DRH.''.
                 $order_clause.
                 ' LIMIT 11';*/
-        } else {
+        } else if ($type == 'searchbox') {
+            $session_list = SessionManager::get_sessions_list(array('s.name LIKE' => "%$needle%"));
+        }
+        else {
             $session_list = SessionManager::get_sessions_list(array('s.name LIKE' => "$needle%"));
-        }     
+        }
         $i=0;        
         if ($type=='single') {
             /*
@@ -178,10 +191,15 @@ if ($add_type == 'multiple') {
 }
 
 echo '<div class="actions">';
-echo '<a href="usergroups.php">'.Display::return_icon('back.png',get_lang('Back'),'',ICON_SIZE_MEDIUM).'</a>';       
+echo '<a href="usergroups.php">'.Display::return_icon('back.png',get_lang('Back'),'',ICON_SIZE_MEDIUM).'</a>'; 
+echo '<a href="javascript://" class="advanced_parameters" style="margin-top: 8px" onclick="display_advanced_search();"><span id="img_plus_and_minus">&nbsp;'.Display::return_icon('div_show.gif',get_lang('Show'),array('style'=>'vertical-align:middle')).' '.get_lang('AdvancedSearch').'</span></a>';
 echo '</div>';
 
 ?>
+
+<?php echo '<div id="advancedSearch" style="display: none">'. get_lang('SearchSessions'); ?> :
+     <input name="SearchSession" onchange = "xajax_search_sessions(this.value,'searchbox')" onkeyup="this.onchange()">
+     </div>
 <form name="formulaire" method="post" action="<?php echo api_get_self(); ?>?id=<?php echo $id; if(!empty($_GET['add'])) echo '&add=true' ; ?>" style="margin:0px;" <?php if($ajax_search){echo ' onsubmit="valide();"';}?>>
 <?php
 echo '<legend>'.$data['name'].': '.$tool_name.'</legend>';
@@ -238,6 +256,7 @@ if(!empty($errorMsg)) {
         echo Display :: get_alphabet_options();
       ?>
      </select>
+<?php echo '<br />'; ?>
 </td>
 <td align="center">&nbsp;</td>
 </tr>

+ 306 - 363
main/admin/add_users_to_group.php

@@ -5,180 +5,180 @@
 */
 
 // name of the language file that needs to be included
-$language_file=array('admin','registration','userInfo');
+$language_file = array('admin','registration','userInfo');
 
 // resetting the course id
-$cidReset=true;
+$cidReset = true;
 
 // including some necessary files
 require_once '../inc/global.inc.php';
 require_once '../inc/lib/xajax/xajax.inc.php';
+require_once '../inc/lib/group_portal_manager.lib.php';
 
 // setting the section (for the tabs)
 $this_section = SECTION_PLATFORM_ADMIN;
 
-global $_configuration;
 // Access restrictions
 api_protect_admin_script(true);
 
 // setting breadcrumbs
-$interbreadcrumb[]=array('url' => 'index.php','name' => get_lang('PlatformAdmin'));
-$interbreadcrumb[]=array('url' => 'group_list.php','name' => get_lang('GroupList'));
+$interbreadcrumb[] = array('url' => 'index.php','name' => get_lang('PlatformAdmin'));
+$interbreadcrumb[] = array('url' => 'group_list.php','name' => get_lang('GroupList'));
 
 // Database Table Definitions
 $tbl_group			= Database::get_main_table(TABLE_MAIN_GROUP);
 $tbl_user			= Database::get_main_table(TABLE_MAIN_USER);
 $tbl_group_rel_user	= Database::get_main_table(TABLE_MAIN_USER_REL_GROUP);
 $tbl_user_rel_access_url= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
+$needle = null;
+$user_anonymous = api_get_anonymous_id();
 
 // setting the name of the tool
 $tool_name = get_lang('SubscribeUsersToGroup');
 $group_id = intval($_GET['id']);
+$without_user_id = null;
 
 $add_type = 'multiple';
-if(isset($_REQUEST['add_type']) && $_REQUEST['add_type']!=''){
-	$add_type = Security::remove_XSS($_REQUEST['add_type']);
+if (isset($_REQUEST['add_type']) && $_REQUEST['add_type'] != '') {
+    $add_type = Security::remove_XSS($_REQUEST['add_type']);
 }
 
 //checking for extra field with filter on
 $xajax = new xajax();
 $xajax->registerFunction('search_users');
-function search_users($needle,$type,$relation_type) {    
-	global $tbl_user,$tbl_user_rel_access_url, $tbl_group_rel_user,$group_id,$_configuration;
-	$xajax_response = new XajaxResponse();
-	$return = $return_origin = $return_destination = '';
-	$without_user_id = $without_user_id = $condition_relation = '';
-
-	if (!empty($group_id) && !empty($relation_type)) {
-		$group_id = intval($group_id);
-		$relation_type = intval($relation_type);
-		// get user_id from relation type and group id
-	    $sql = "SELECT user_id FROM $tbl_group_rel_user
-				WHERE group_id = '$group_id'
-				AND relation_type IN (".GROUP_USER_PERMISSION_ADMIN.",".GROUP_USER_PERMISSION_READER.",".GROUP_USER_PERMISSION_PENDING_INVITATION.",".GROUP_USER_PERMISSION_MODERATOR.", ".GROUP_USER_PERMISSION_HRM.") ";
-		$res = Database::query($sql);
-		$user_ids = array();
-		if (Database::num_rows($res) > 0) {
-			while ($row = Database::fetch_row($res)) {
-				$user_ids[] = $row[0];
-			}
-			$without_user_id = " AND user.user_id NOT IN(".implode(',',$user_ids).") ";
-		}
-
-		if ($relation_type == GROUP_USER_PERMISSION_PENDING_INVITATION) {
-			$condition_relation = " AND groups.relation_type IN (".GROUP_USER_PERMISSION_PENDING_INVITATION.",".GROUP_USER_PERMISSION_READER.") ";
-		} else {
-			$condition_relation = " AND groups.relation_type = '$relation_type' ";
-		}
-
-		// data for destination user list
-		$sql = "SELECT user.user_id, user.username, user.lastname, user.firstname
-				FROM $tbl_group_rel_user groups
-				INNER JOIN  $tbl_user user ON user.user_id = groups.user_id
-				WHERE groups.group_id = '$group_id' $condition_relation ";
-
-		$rs_destination = Database::query($sql);
-		if (Database::num_rows($rs_destination) > 0) {
-			$return_destination .= '<select id="destination_users" name="sessionUsersList[]" multiple="multiple" size="15" style="width:360px;">';
-			while ($row = Database::fetch_array($rs_destination)) {
-				$person_name = api_get_person_name($row['firstname'], $row['lastname']);
-		        $return_destination .= '<option value="'.$row['user_id'].'">'.$person_name.' ('.$row['username'].')</option>';
-			}
-			$return_destination .= '</select>';
-		} else {
-			$return_destination .= '<select id="destination_users" name="sessionUsersList[]" multiple="multiple" size="15" style="width:360px;"></select>';
-		}
-		
-		$xajax_response -> addAssign('ajax_destination_list','innerHTML',api_utf8_encode($return_destination));
-
-	} else {
-		$return_destination .= '<select id="destination_users" name="sessionUsersList[]" multiple="multiple" size="15" style="width:360px;"></select>';
-		$xajax_response -> addAssign('ajax_destination_list','innerHTML',api_utf8_encode($return_destination));
-
-		if ($type == 'single') {
-			$return.= '';
-			$xajax_response -> addAssign('ajax_list_users_single','innerHTML',api_utf8_encode($return));
-		} else {
-			$return_origin .= '<select id="origin_users" name="nosessionUsersList[]" multiple="multiple" size="15" style="width:360px;"></select>';
-			$xajax_response -> addAssign('ajax_origin_list_multiple','innerHTML',api_utf8_encode($return_origin));
-		}
-	}
-
-	if (!empty($needle) && !empty($type)) {
-
-		// xajax send utf8 datas... datas in db can be non-utf8 datas
-		$charset = api_get_system_encoding();
-		$needle = Database::escape_string($needle);
-		$needle = api_convert_encoding($needle, $charset, 'utf-8');
-		$user_anonymous=api_get_anonymous_id();
-		
-
-		$order_clause = api_sort_by_first_name() ? ' ORDER BY firstname, lastname, username' : ' ORDER BY lastname, firstname, username';
-		if ($type == 'single') {
-			if (!empty($group_id) && !empty($relation_type)) {
-				// search users where username or firstname or lastname begins likes $needle
-				$sql = "SELECT user_id, username, lastname, firstname FROM $tbl_user user
-						WHERE (username LIKE '$needle%' OR firstname LIKE '$needle%' OR lastname LIKE '$needle%')
-						AND user_id<>'$user_anonymous' $without_user_id $order_clause LIMIT 11";
-				if ($_configuration['multiple_access_urls']) {
-					$access_url_id = api_get_current_access_url_id();
-					if ($access_url_id != -1) {
-						$sql = "SELECT user.user_id, username, lastname, firstname FROM $tbl_user user
-								INNER JOIN $tbl_user_rel_access_url url_user ON (url_user.user_id=user.user_id)
-								WHERE access_url_id = '$access_url_id'  AND (username LIKE '$needle%' OR firstname LIKE '$needle%' OR lastname LIKE '$needle%')
-								AND user.user_id<>'$user_anonymous' $without_user_id $order_clause LIMIT 11 ";
-					}
-				}
-				$rs_single = Database::query($sql);
-	        	$i=0;
-				while ($user = Database :: fetch_array($rs_single)) {
-		            $i++;
-		            if ($i<=10) {
-		        		$person_name = api_get_person_name($user['firstname'], $user['lastname']);
-						$return .= '<a href="javascript: void(0);" onclick="javascript: add_user(\''.$user['user_id'].'\',\''.$person_name.' ('.$user['username'].')'.'\')">'.$person_name.' ('.$user['username'].')</a><br />';
-		            } else {
-		            	$return .= '...<br />';
-		            }
-				}
-				$xajax_response -> addAssign('ajax_list_users_single','innerHTML',api_utf8_encode($return));
-			} else {
-				$xajax_response ->addAlert(get_lang('YouMustChooseARelationType'));
-				$xajax_response->addClear('user_to_add', 'value');
-			}
-
-		} else {
-			// multiple
-			if (!empty($group_id) && !empty($relation_type)) {
-				$sql = "SELECT user_id, username, lastname, firstname FROM $tbl_user user 
-				        WHERE ".(api_sort_by_first_name() ? 'firstname' : 'lastname')." LIKE '$needle%' AND user_id<>'$user_anonymous' $without_user_id $order_clause ";
-				if ($_configuration['multiple_access_urls']) {
-					$access_url_id = api_get_current_access_url_id();
-					if ($access_url_id != -1) {
-						$sql = "SELECT user.user_id, username, lastname, firstname FROM $tbl_user user
-								INNER JOIN $tbl_user_rel_access_url url_user ON (url_user.user_id=user.user_id)
-								WHERE access_url_id = '$access_url_id'
-								AND ".(api_sort_by_first_name() ? 'firstname' : 'lastname')." LIKE '$needle%'
-								AND user.user_id<>'$user_anonymous' $without_user_id $order_clause ";
-					}
-				}
-				
-				$rs_multiple = Database::query($sql);
-				$return_origin .= '<select id="origin_users" name="nosessionUsersList[]" multiple="multiple" size="15" style="width:360px;">';
-				while ($user = Database :: fetch_array($rs_multiple)) {
-					$person_name = api_get_person_name($user['firstname'], $user['lastname']);
-		            $return_origin .= '<option value="'.$user['user_id'].'">'.$person_name.' ('.$user['username'].')</option>';
-				}
-				$return_origin .= '</select>';
-				$xajax_response -> addAssign('ajax_origin_list_multiple','innerHTML',api_utf8_encode($return_origin));
-			}
-		}
-	}
-	return $xajax_response;
+function search_users($needle, $type, $relation_type)
+{
+    global $tbl_user, $tbl_user_rel_access_url, $tbl_group_rel_user, $group_id;
+    $xajax_response = new XajaxResponse();
+    $return = $return_origin = $return_destination = '';
+    $without_user_id = $without_user_id = $condition_relation = '';
+
+    if (!empty($group_id) && !empty($relation_type)) {
+        $group_id = intval($group_id);
+        $relation_type = intval($relation_type);
+        // get user_id from relation type and group id
+        $sql = "SELECT user_id FROM $tbl_group_rel_user
+                WHERE group_id = '$group_id'
+                AND relation_type IN (".GROUP_USER_PERMISSION_ADMIN.",".GROUP_USER_PERMISSION_READER.",".GROUP_USER_PERMISSION_PENDING_INVITATION.",".GROUP_USER_PERMISSION_MODERATOR.", ".GROUP_USER_PERMISSION_HRM.") ";
+        $res = Database::query($sql);
+        $user_ids = array();
+        if (Database::num_rows($res) > 0) {
+            while ($row = Database::fetch_row($res)) {
+                $user_ids[] = $row[0];
+            }
+            $without_user_id = " AND user.user_id NOT IN(".implode(',', $user_ids).") ";
+        }
+
+        $condition_relation = " AND groups.relation_type = '$relation_type' ";
+
+        // data for destination user list
+        $sql = "SELECT user.user_id, user.username, user.lastname, user.firstname
+                FROM $tbl_group_rel_user groups
+                INNER JOIN  $tbl_user user ON user.user_id = groups.user_id
+                WHERE groups.group_id = '$group_id' $condition_relation ";
+
+        $rs_destination = Database::query($sql);
+        if (Database::num_rows($rs_destination) > 0) {
+            $return_destination .= '<select id="destination_users" name="sessionUsersList[]" multiple="multiple" size="15" style="width:360px;">';
+            while ($row = Database::fetch_array($rs_destination)) {
+                $person_name = api_get_person_name($row['firstname'], $row['lastname']);
+                $return_destination .= '<option value="'.$row['user_id'].'">'.
+                    $person_name.' ('.$row['username'].')</option>';
+            }
+            $return_destination .= '</select>';
+        } else {
+            $return_destination .= '<select id="destination_users" name="sessionUsersList[]" multiple="multiple" size="15" style="width:360px;"></select>';
+        }
+        $xajax_response->addAssign('ajax_destination_list','innerHTML', api_utf8_encode($return_destination));
+    } else {
+        $return_destination .= '<select id="destination_users" name="sessionUsersList[]" multiple="multiple" size="15" style="width:360px;"></select>';
+        $xajax_response->addAssign('ajax_destination_list','innerHTML', api_utf8_encode($return_destination));
+
+        if ($type == 'single') {
+            $return.= '';
+            $xajax_response->addAssign('ajax_list_users_single','innerHTML',api_utf8_encode($return));
+        } else {
+            $return_origin .= '<select id="origin_users" name="nosessionUsersList[]" multiple="multiple" size="15" style="width:360px;"></select>';
+            $xajax_response->addAssign('ajax_origin_list_multiple', 'innerHTML', api_utf8_encode($return_origin));
+        }
+    }
+
+    if (!empty($needle) && !empty($type)) {
+
+        // xajax send utf8 datas... datas in db can be non-utf8 datas
+        $charset = api_get_system_encoding();
+        $needle = Database::escape_string($needle);
+        $needle = api_convert_encoding($needle, $charset, 'utf-8');
+        $user_anonymous = api_get_anonymous_id();
+        $order_clause = api_sort_by_first_name() ? ' ORDER BY firstname, lastname, username' : ' ORDER BY lastname, firstname, username';
+        if ($type == 'single') {
+            if (!empty($group_id) && !empty($relation_type)) {
+                // search users where username or firstname or lastname begins likes $needle
+                $sql = "SELECT user_id, username, lastname, firstname
+                        FROM $tbl_user user
+                        WHERE (username LIKE '$needle%' OR firstname LIKE '$needle%' OR lastname LIKE '$needle%')
+                        AND user_id<>'$user_anonymous' $without_user_id $order_clause LIMIT 11";
+                if (api_is_multiple_url_enabled()) {
+                    $access_url_id = api_get_current_access_url_id();
+                    if ($access_url_id != -1) {
+                        $sql = "SELECT user.user_id, username, lastname, firstname FROM $tbl_user user
+                                INNER JOIN $tbl_user_rel_access_url url_user ON (url_user.user_id=user.user_id)
+                                WHERE access_url_id = '$access_url_id'  AND (username LIKE '$needle%' OR firstname LIKE '$needle%' OR lastname LIKE '$needle%')
+                                AND user.user_id<>'$user_anonymous' $without_user_id $order_clause LIMIT 11 ";
+                    }
+                }
+                $rs_single = Database::query($sql);
+                $i=0;
+                while ($user = Database :: fetch_array($rs_single)) {
+                    $i++;
+                    if ($i<=10) {
+                        $person_name = api_get_person_name($user['firstname'], $user['lastname']);
+                        $return .= '<a href="javascript: void(0);" onclick="javascript: add_user(\''.$user['user_id'].'\',\''.$person_name.' ('.$user['username'].')'.'\')">'.$person_name.' ('.$user['username'].')</a><br />';
+                    } else {
+                        $return .= '...<br />';
+                    }
+                }
+                $xajax_response->addAssign('ajax_list_users_single','innerHTML',api_utf8_encode($return));
+            } else {
+                $xajax_response->addAlert(get_lang('YouMustChooseARelationType'));
+                $xajax_response->addClear('user_to_add', 'value');
+            }
+
+        } else {
+            // multiple
+            if (!empty($group_id) && !empty($relation_type)) {
+                $sql = "SELECT user_id, username, lastname, firstname FROM $tbl_user user
+                        WHERE ".(api_sort_by_first_name() ? 'firstname' : 'lastname')." LIKE '$needle%' AND user_id<>'$user_anonymous' $without_user_id $order_clause ";
+                if (api_is_multiple_url_enabled()) {
+                    $access_url_id = api_get_current_access_url_id();
+                    if ($access_url_id != -1) {
+                        $sql = "SELECT user.user_id, username, lastname, firstname
+                                FROM $tbl_user user
+                                INNER JOIN $tbl_user_rel_access_url url_user ON (url_user.user_id=user.user_id)
+                                WHERE
+                                    access_url_id = '$access_url_id' AND
+                                    ".(api_sort_by_first_name() ? 'firstname' : 'lastname')." LIKE '$needle%' AND
+                                    user.user_id<>'$user_anonymous' $without_user_id $order_clause ";
+                    }
+                }
+
+                $rs_multiple = Database::query($sql);
+                $return_origin .= '<select id="origin_users" name="nosessionUsersList[]" multiple="multiple" size="15" style="width:360px;">';
+                while ($user = Database :: fetch_array($rs_multiple)) {
+                    $person_name = api_get_person_name($user['firstname'], $user['lastname']);
+                    $return_origin .= '<option value="'.$user['user_id'].'">'.
+                        $person_name.' ('.$user['username'].')</option>';
+                }
+                $return_origin .= '</select>';
+                $xajax_response->addAssign('ajax_origin_list_multiple', 'innerHTML', api_utf8_encode($return_origin));
+            }
+        }
+    }
+    return $xajax_response;
 }
 
 $xajax->processRequests();
 $htmlHeadXtra[] = $xajax->getJavascript('../inc/lib/xajax/');
-
 $htmlHeadXtra[] = '
 <script>
 function add_user (code, content) {
@@ -187,18 +187,17 @@ function add_user (code, content) {
 	//document.getElementById("ajax_list_users_single").innerHTML = "";
 
 	destination = document.getElementById("destination_users");
-
 	for (i=0;i<destination.length;i++) {
-		if(destination.options[i].text == content) {
-				return false;
+		if (destination.options[i].text == content) {
+            return false;
 		}
 	}
 
 	destination.options[destination.length] = new Option(content,code);
 	destination.selectedIndex = -1;
 	sortOptions(destination.options);
-
 }
+
 function remove_item(origin)
 {
 	for(var i = 0 ; i<origin.options.length ; i++) {
@@ -210,49 +209,45 @@ function remove_item(origin)
 }
 
 function validate_filter() {
-		document.formulaire.add_type.value = \''.$add_type.'\';
-		document.formulaire.form_sent.value=0;
-		document.formulaire.submit();
+    document.formulaire.add_type.value = \''.$add_type.'\';
+    document.formulaire.form_sent.value=0;
+    document.formulaire.submit();
 }
 </script>';
 
-$form_sent=0;
-$errorMsg=$firstLetterUser=$firstLetterSession='';
-$UserList=$SessionList=array();
-$users=$sessions=array();
-$noPHP_SELF=true;
-
+$form_sent = 0;
+$errorMsg = $firstLetterUser = $firstLetterSession='';
+$UserList = $SessionList = array();
+$users = $sessions = array();
+$noPHP_SELF = true;
 $group_info = GroupPortalManager::get_group_data($group_id);
 $group_name = $group_info['name'];
 
 Display::display_header($group_name);
 
-if ($_POST['form_sent']) {
-
-	$form_sent			= $_POST['form_sent'];
-	$firstLetterUser	= $_POST['firstLetterUser'];
-	$UserList			= $_POST['sessionUsersList'];
-	$group_id			= intval($_POST['id']);
-	$relation_type		= intval($_POST['relation']);
-
-	if(!is_array($UserList)) {
-		$UserList=array();
-	}
-	if ($form_sent == 1) {
-		if ($relation_type == GROUP_USER_PERMISSION_PENDING_INVITATION) {
-			$relations = array(GROUP_USER_PERMISSION_PENDING_INVITATION,GROUP_USER_PERMISSION_READER);
-			$users_by_group      = GroupPortalManager::get_users_by_group($group_id,null,$relations);
-			$user_id_relation    = array_keys($users_by_group);
-			$user_relation_diff  = array_diff($user_id_relation,$UserList);
-			foreach ($user_relation_diff as $user_id) {
-				GroupPortalManager::delete_user_rel_group($user_id,$group_id);
-			}
-		} else {
-			GroupPortalManager::delete_users($group_id, $relation_type);
-		}
-		$result = GroupPortalManager::add_users_to_groups($UserList, array($group_id), $relation_type);
-		Display :: display_confirmation_message(get_lang('UsersEdited'));
-	}
+if (isset($_POST['form_sent']) && $_POST['form_sent']) {
+    $form_sent			= $_POST['form_sent'];
+    $firstLetterUser	= isset($_POST['firstLetterUser']) ? $_POST['firstLetterUser'] : null;
+    $UserList			= $_POST['sessionUsersList'];
+    $group_id			= intval($_POST['id']);
+    $relation_type		= intval($_POST['relation']);
+
+    if (!is_array($UserList)) {
+        $UserList = array();
+    }
+
+    if ($form_sent == 1) {
+        $users_by_group = GroupPortalManager::get_users_by_group($group_id, null, array($relation_type));
+        $user_id_relation    = array_keys($users_by_group);
+        $user_relation_diff  = array_diff($user_id_relation, $UserList);
+        if (!empty($user_relation_diff)) {
+            foreach ($user_relation_diff as $user_id) {
+                GroupPortalManager::delete_user_rel_group($user_id, $group_id);
+            }
+        }
+        $result = GroupPortalManager::add_users_to_groups($UserList, array($group_id), $relation_type);
+        Display :: display_confirmation_message(get_lang('UsersEdited'));
+    }
 }
 
 $nosessionUsersList = $sessionUsersList = array();
@@ -262,123 +257,115 @@ $order_clause = api_sort_by_first_name() ? ' ORDER BY firstname, lastname, usern
 
 if ($ajax_search) {
 
-	// data for destination list
-	if (isset($_POST['id']) && isset($_POST['relation'])) {
-		// data for destination user list
-		$id = intval($_POST['id']);
-		$relation_type = intval($_POST['relation']);
-		$condition_relation = "";
-
-		if ($relation_type==GROUP_USER_PERMISSION_PENDING_INVITATION) {
-			$condition_relation = " AND groups.relation_type IN (".GROUP_USER_PERMISSION_PENDING_INVITATION.",".GROUP_USER_PERMISSION_READER.") ";
-		} else {
-			$condition_relation = " AND groups.relation_type = '$relation_type' ";
-		}
-
-		$sql = "SELECT user.user_id, user.username, user.lastname, user.firstname
-				FROM $tbl_group_rel_user groups
-				INNER JOIN  $tbl_user user ON user.user_id = groups.user_id
-				WHERE groups.group_id = '$id' $condition_relation ";
-		$rs_destination = Database::query($sql);
-		if (Database::num_rows($rs_destination) > 0) {
-			while ($row_destination_list = Database::fetch_array($rs_destination)) {
-				$sessionUsersList[$row_destination_list['user_id']] = $row_destination_list ;
-			}
-		}
-	}
-
+    // data for destination list
+    if (isset($_POST['id']) && isset($_POST['relation'])) {
+        // data for destination user list
+        $id = intval($_POST['id']);
+        $relation_type = intval($_POST['relation']);
+        $condition_relation = " AND groups.relation_type = '$relation_type' ";
+        $sql = "SELECT user.user_id, user.username, user.lastname, user.firstname
+                FROM $tbl_group_rel_user groups
+                INNER JOIN  $tbl_user user ON user.user_id = groups.user_id
+                WHERE groups.group_id = '$id' $condition_relation ";
+        $rs_destination = Database::query($sql);
+        if (Database::num_rows($rs_destination) > 0) {
+            while ($row_destination_list = Database::fetch_array($rs_destination)) {
+                $sessionUsersList[$row_destination_list['user_id']] = $row_destination_list ;
+            }
+        }
+    }
 } else {
 
-	$many_users = false;
-	$sql = "SELECT count(user_id) FROM $tbl_user user
-			WHERE ".(api_sort_by_first_name() ? 'firstname' : 'lastname')." LIKE '$needle%' AND user_id<>'$user_anonymous' $without_user_id ";
-
-	if ($_configuration['multiple_access_urls']) {
-		$access_url_id = api_get_current_access_url_id();
-		if ($access_url_id != -1) {
-			$sql = "SELECT count(user.user_id) FROM $tbl_user user
-					INNER JOIN $tbl_user_rel_access_url url_user ON (url_user.user_id=user.user_id)
-					WHERE access_url_id = '$access_url_id'
-					AND ".(api_sort_by_first_name() ? 'firstname' : 'lastname')." LIKE '$needle%'
-					AND user.user_id<>'$user_anonymous' $without_user_id ";
-		}
-	}
-	$rs_count  = Database::query($sql);
-	$row_count = 0;
-	if (Database::num_rows($rs_count)) {
-	   $row_count = Database::fetch_row($rs_count);
-	   $row_count = $row_count[0];
-	}	
-	if ($row_count > 2) $many_users = true;
-
-	// data for origin list
-	if (isset($_GET['id'])) {
-		$id = intval($_GET['id']);
-		$needle = Database::escape_string($_POST['firstLetterUser']);
-		$needle = api_convert_encoding($needle, $charset, 'utf-8');
-		$user_anonymous=api_get_anonymous_id();
-		// get user_id from relation type and group id
-		$sql = "SELECT user_id FROM $tbl_group_rel_user
-				WHERE group_id = $id
-				AND relation_type IN (".GROUP_USER_PERMISSION_ADMIN.",".GROUP_USER_PERMISSION_READER.",".GROUP_USER_PERMISSION_PENDING_INVITATION.",".GROUP_USER_PERMISSION_MODERATOR.", ".GROUP_USER_PERMISSION_HRM.") ";
-		$res = Database::query($sql);
-		$user_ids = array();
-		if (Database::num_rows($res) > 0) {
-			while ($row = Database::fetch_row($res)) {
-				$user_ids[] = $row[0];
-			}
-			$without_user_id = " AND user.user_id NOT IN(".implode(',',$user_ids).") ";
-		}
-
-		$sql = "SELECT user_id, username, lastname, firstname FROM $tbl_user user
-				WHERE ".(api_sort_by_first_name() ? 'firstname' : 'lastname')." LIKE '$needle%' AND user_id<>'$user_anonymous' $without_user_id $order_clause ";
-		if ($_configuration['multiple_access_urls']) {
-			$access_url_id = api_get_current_access_url_id();
-			if ($access_url_id != -1) {
-				$sql = "SELECT user.user_id, username, lastname, firstname FROM $tbl_user user
-						INNER JOIN $tbl_user_rel_access_url url_user ON (url_user.user_id=user.user_id)
-						WHERE access_url_id = '$access_url_id'
-						AND ".(api_sort_by_first_name() ? 'firstname' : 'lastname')." LIKE '$needle%'
-						AND user.user_id<>'$user_anonymous' $without_user_id $order_clause ";
-			}
-		}
-		$rs_origin_list = Database::query($sql);
-		while ($row_origin_list = Database::fetch_array($rs_origin_list)) {
-			$nosessionUsersList[$row_origin_list['user_id']] = $row_origin_list;
-		}
-	}
-
-	// data for destination list
-	if (isset($_POST['id']) && isset($_POST['relation'])) {
-		// data for destination user list
-		$id = intval($_POST['id']);
-		$relation_type = intval($_POST['relation']);
-
-		if ($relation_type==GROUP_USER_PERMISSION_PENDING_INVITATION) {
-			$condition_relation = " AND groups.relation_type IN (".GROUP_USER_PERMISSION_PENDING_INVITATION.",".GROUP_USER_PERMISSION_READER.") ";
-		} else {
-			$condition_relation = " AND groups.relation_type = '$relation_type' ";
-		}
-
-		$sql = "SELECT user.user_id, user.username, user.lastname, user.firstname
-				FROM $tbl_group_rel_user groups
-				INNER JOIN  $tbl_user user ON user.user_id = groups.user_id
-				WHERE groups.group_id = '$id' $condition_relation ";
-		$rs_destination = Database::query($sql);
-		if (Database::num_rows($rs_destination) > 0) {
-			while ($row_destination_list = Database::fetch_array($rs_destination)) {
-				$sessionUsersList[$row_destination_list['user_id']] = $row_destination_list ;
-			}
-		}
-	}
+    $many_users = false;
+    $sql = "SELECT count(user_id) FROM $tbl_user user
+            WHERE ".(api_sort_by_first_name() ? 'firstname' : 'lastname')." LIKE '$needle%' AND
+            user_id<>'$user_anonymous' $without_user_id ";
+
+    if (api_is_multiple_url_enabled()) {
+        $access_url_id = api_get_current_access_url_id();
+        if ($access_url_id != -1) {
+            $sql = "SELECT count(user.user_id) FROM $tbl_user user
+                    INNER JOIN $tbl_user_rel_access_url url_user ON (url_user.user_id=user.user_id)
+                    WHERE
+                        access_url_id = '$access_url_id' AND
+                        ".(api_sort_by_first_name() ? 'firstname' : 'lastname')." LIKE '$needle%' AND
+                        user.user_id<>'$user_anonymous' $without_user_id ";
+        }
+    }
+    $rs_count  = Database::query($sql);
+    $row_count = 0;
+    if (Database::num_rows($rs_count)) {
+        $row_count = Database::fetch_row($rs_count);
+        $row_count = $row_count[0];
+    }
+
+    if ($row_count > 2) {
+        $many_users = true;
+    }
+
+    // data for origin list
+    if (isset($_GET['id'])) {
+        $id = intval($_GET['id']);
+        $needle = isset($_POST['firstLetterUser']) ? Database::escape_string($_POST['firstLetterUser']) : null;
+        $needle = api_convert_encoding($needle, $charset, 'utf-8');
+        $user_anonymous = api_get_anonymous_id();
+        // get user_id from relation type and group id
+        $sql = "SELECT user_id FROM $tbl_group_rel_user
+                WHERE group_id = $id
+                AND relation_type IN (".GROUP_USER_PERMISSION_ADMIN.", ".GROUP_USER_PERMISSION_READER.",".GROUP_USER_PERMISSION_PENDING_INVITATION.",".GROUP_USER_PERMISSION_MODERATOR.", ".GROUP_USER_PERMISSION_HRM.") ";
+        $res = Database::query($sql);
+        $user_ids = array();
+        if (Database::num_rows($res) > 0) {
+            while ($row = Database::fetch_row($res)) {
+                $user_ids[] = $row[0];
+            }
+            $without_user_id = " AND user.user_id NOT IN(".implode(',', $user_ids).") ";
+        }
+
+        $sql = "SELECT user_id, username, lastname, firstname FROM $tbl_user user
+                WHERE ".(api_sort_by_first_name() ? 'firstname' : 'lastname')." LIKE '$needle%' AND user_id<>'$user_anonymous' $without_user_id $order_clause ";
+        if (api_is_multiple_url_enabled()) {
+            $access_url_id = api_get_current_access_url_id();
+            if ($access_url_id != -1) {
+                $sql = "SELECT user.user_id, username, lastname, firstname FROM $tbl_user user
+                        INNER JOIN $tbl_user_rel_access_url url_user ON (url_user.user_id=user.user_id)
+                        WHERE access_url_id = '$access_url_id'
+                        AND ".(api_sort_by_first_name() ? 'firstname' : 'lastname')." LIKE '$needle%'
+                        AND user.user_id<>'$user_anonymous' $without_user_id $order_clause ";
+            }
+        }
+        $rs_origin_list = Database::query($sql);
+        while ($row_origin_list = Database::fetch_array($rs_origin_list)) {
+            $nosessionUsersList[$row_origin_list['user_id']] = $row_origin_list;
+        }
+    }
+
+    // data for destination list
+    if (isset($_POST['id']) && isset($_POST['relation'])) {
+        // data for destination user list
+        $id = intval($_POST['id']);
+        $relation_type = intval($_POST['relation']);
+        $condition_relation = " AND groups.relation_type = '$relation_type' ";
+
+        $sql = "SELECT user.user_id, user.username, user.lastname, user.firstname
+                FROM $tbl_group_rel_user groups
+                INNER JOIN  $tbl_user user ON user.user_id = groups.user_id
+                WHERE groups.group_id = '$id' $condition_relation ";
+        $rs_destination = Database::query($sql);
+        if (Database::num_rows($rs_destination) > 0) {
+            while ($row_destination_list = Database::fetch_array($rs_destination)) {
+                $sessionUsersList[$row_destination_list['user_id']] = $row_destination_list ;
+            }
+        }
+    }
 }
 
 if ($add_type == 'multiple') {
-	$link_add_type_unique = '<a href="'.api_get_self().'?id='.$group_id.'&add='.Security::remove_XSS($_GET['add']).'&add_type=unique">'.Display::return_icon('single.gif').get_lang('SessionAddTypeUnique').'</a>';
-	$link_add_type_multiple = Display::return_icon('multiple.gif').get_lang('SessionAddTypeMultiple');
+    $link_add_type_unique = '<a href="'.api_get_self().'?id='.$group_id.'&add_type=unique">'.Display::return_icon('single.gif').get_lang('SessionAddTypeUnique').'</a>';
+    $link_add_type_multiple = Display::return_icon('multiple.gif').get_lang('SessionAddTypeMultiple');
 } else {
-	$link_add_type_unique = Display::return_icon('single.gif').get_lang('SessionAddTypeUnique');
-	$link_add_type_multiple = '<a href="'.api_get_self().'?id='.$group_id.'&add='.Security::remove_XSS($_GET['add']).'&add_type=multiple">'.Display::return_icon('multiple.gif').get_lang('SessionAddTypeMultiple').'</a>';
+    $link_add_type_unique = Display::return_icon('single.gif').get_lang('SessionAddTypeUnique');
+    $link_add_type_multiple = '<a href="'.api_get_self().'?id='.$group_id.'&add_type=multiple">'.Display::return_icon('multiple.gif').get_lang('SessionAddTypeMultiple').'</a>';
 }
 ?>
 
@@ -386,8 +373,8 @@ if ($add_type == 'multiple') {
 	<?php echo $link_add_type_unique ?>&nbsp;|&nbsp;<?php echo $link_add_type_multiple ?>
 </div>
 
-<form name="formulaire" method="post" action="<?php echo api_get_self(); ?>?id=<?php echo $group_id; ?><?php if(!empty($_GET['add'])) echo '&add=true' ; ?>" style="margin:0px;" <?php if($ajax_search){echo ' onsubmit="valide();"';}?>>
-<?php echo '<legend>'.$tool_name.' ('.$group_info['name'].')</legend>'; ?>    
+<form name="formulaire" method="post" action="<?php echo api_get_self(); ?>?id=<?php echo $group_id; ?>" style="margin:0px;" <?php if($ajax_search){echo ' onsubmit="valide();"';}?>>
+<?php echo '<legend>'.$tool_name.' ('.$group_info['name'].')</legend>'; ?>
 <?php if ($add_type=='multiple') { ?>
 <select name="relation" id="relation" onchange="xajax_search_users(document.getElementById('firstLetterUser').value,'multiple',this.value)">
 <?php } else { ?>
@@ -395,73 +382,41 @@ if ($add_type == 'multiple') {
 <?php } ?>
 <option value=""><?php echo get_lang('SelectARelationType')?></option>
 <option value="<?php echo GROUP_USER_PERMISSION_ADMIN ?>" <?php echo ((isset($_POST['relation']) && $_POST['relation']==GROUP_USER_PERMISSION_ADMIN)?'selected=selected':'') ?> > <?php echo get_lang('Admin') ?></option>
-<option value="<?php echo GROUP_USER_PERMISSION_PENDING_INVITATION ?>" <?php echo ((isset($_POST['relation']) && $_POST['relation']==GROUP_USER_PERMISSION_PENDING_INVITATION)?'selected=selected':'') ?> > <?php echo get_lang('Reader') ?></option>
+<option value="<?php echo GROUP_USER_PERMISSION_READER ?>" <?php echo ((isset($_POST['relation']) && $_POST['relation']==GROUP_USER_PERMISSION_READER)?'selected=selected':'') ?> > <?php echo get_lang('Reader') ?></option>
+<option value="<?php echo GROUP_USER_PERMISSION_PENDING_INVITATION ?>" <?php echo ((isset($_POST['relation']) && $_POST['relation']==GROUP_USER_PERMISSION_PENDING_INVITATION)?'selected=selected':'') ?> > <?php echo get_lang('PendingInvitation') ?></option>
 <option value="<?php echo GROUP_USER_PERMISSION_MODERATOR ?>" <?php echo ((isset($_POST['relation']) && $_POST['relation']==GROUP_USER_PERMISSION_MODERATOR)?'selected=selected':'') ?> > <?php echo get_lang('Moderator') ?></option>
 <option value="<?php echo GROUP_USER_PERMISSION_HRM ?>" <?php echo ((isset($_POST['relation']) && $_POST['relation']==GROUP_USER_PERMISSION_HRM)?'selected=selected':'') ?> > <?php echo get_lang('Drh') ?></option>
 </select>
-
-<?php
-if ($add_type=='multiple') {
-	if (is_array($extra_field_list)) {
-		if (is_array($new_field_list) && count($new_field_list)>0 ) {
-			echo '<h3>'.get_lang('FilterUsers').'</h3>';
-			foreach ($new_field_list as $new_field) {
-				echo $new_field['name'];
-				$varname = 'field_'.$new_field['variable'];
-				echo '&nbsp;<select name="'.$varname.'">';
-				echo '<option value="0">--'.get_lang('Select').'--</option>';
-				foreach	($new_field['data'] as $option) {
-					$checked='';
-					if (isset($_POST[$varname])) {
-						if ($_POST[$varname]==$option[1]) {
-							$checked = 'selected="true"';
-						}
-					}
-					echo '<option value="'.$option[1].'" '.$checked.'>'.$option[1].'</option>';
-				}
-				echo '</select>';
-				echo '&nbsp;&nbsp;';
-			}
-			echo '<input type="button" value="'.get_lang('Filter').'" onclick="validate_filter()" />';
-			echo '<br /><br />';
-		}
-	}
-}
-?>
-
 <input type="hidden" name="form_sent" value="1" />
 <input type="hidden" name="id" value="<?php echo $group_id ?>" />
 <input type="hidden" name="add_type" value="<?php echo $add_type ?>" />
 
 <?php
-if(!empty($errorMsg)) {
-	Display::display_normal_message($errorMsg); //main API
+if (!empty($errorMsg)) {
+    Display::display_normal_message($errorMsg);
 }
 ?>
 
 <table border="0" cellpadding="5" cellspacing="0" width="100%">
-<!-- Users -->
 <tr>
   <td align="center"><b><?php echo get_lang('UserListInPlatform') ?> :</b>
   </td>
   <td>&nbsp;</td>
   <td align="center"><b><?php echo get_lang('UsersInGroup') ?> :</b></td>
 </tr>
-
 <?php if ($add_type=='multiple') { ?>
 <tr>
 <td align="center">
-
 <?php echo get_lang('FirstLetterUser'); ?> :
 	<div id="firstLetter">
-	     <select name="firstLetterUser" id="firstLetterUser" onchange = "xajax_search_users(this.value,'multiple',document.getElementById('relation').value)" >
-	      <option value = "%"><?php echo get_lang('All') ?></option>
-	      <?php
-	      	$selected_letter = isset($_POST['firstLetterUser'])?$_POST['firstLetterUser']:'';
-	        echo Display :: get_alphabet_options($selected_letter);
-	      ?>
+        <select name="firstLetterUser" id="firstLetterUser" onchange = "xajax_search_users(this.value,'multiple',document.getElementById('relation').value)" >
+            <option value = "%"><?php echo get_lang('All') ?></option>
+              <?php
+                $selected_letter = isset($_POST['firstLetterUser']) ? $_POST['firstLetterUser'] : null;
+                echo Display :: get_alphabet_options($selected_letter);
+              ?>
 	     </select>
-     </div>
+    </div>
 </td>
 <td align="center">&nbsp;</td>
 </tr>
@@ -480,7 +435,6 @@ if(!empty($errorMsg)) {
   	  <div id="ajax_origin_list_multiple">
 	  <select id="origin_users" name="nosessionUsersList[]" multiple="multiple" size="15" style="width:360px;">
 		<?php
-
 		if (!empty($nosessionUsersList)) {
 			foreach($nosessionUsersList as $enreg) {
 			?>
@@ -501,7 +455,7 @@ if(!empty($errorMsg)) {
   <?php
   if ($ajax_search) {
   ?>
-  	<button class="arrowl" type="button" onclick="remove_item(document.getElementById('destination_users'))" ></button>
+    <button class="arrowl" type="button" onclick="remove_item(document.getElementById('destination_users'))" ></button>
   <?php
   } else {
   ?>
@@ -519,9 +473,12 @@ if(!empty($errorMsg)) {
 	<?php
 	if (!empty($sessionUsersList)) {
 		foreach($sessionUsersList as $enreg) { ?>
-			<option value="<?php echo $enreg['user_id']; ?>"><?php echo $enreg['firstname'].' '.$enreg['lastname'].' ('.$enreg['username'].')'; ?></option>
+			<option value="<?php echo $enreg['user_id']; ?>">
+                <?php echo $enreg['firstname'].' '.$enreg['lastname'].' ('.$enreg['username'].')'; ?>
+            </option>
 	<?php }
-	} unset($sessionUsersList);?>
+	} unset($sessionUsersList);
+    ?>
   </select>
   </div>
   </td>
@@ -538,11 +495,9 @@ if(!empty($errorMsg)) {
 </form>
 
 <script>
-<!--
-function moveItem(origin , destination){
-
-	for(var i = 0 ; i<origin.options.length ; i++) {
-		if(origin.options[i].selected) {
+function moveItem(origin , destination) {
+	for (var i = 0 ; i<origin.options.length ; i++) {
+		if (origin.options[i].selected) {
 			destination.options[destination.length] = new Option(origin.options[i].text,origin.options[i].value);
 			origin.options[i]=null;
 			i = i-1;
@@ -554,7 +509,6 @@ function moveItem(origin , destination){
 }
 
 function sortOptions(options) {
-
 	newOptions = new Array();
 	for (i = 0 ; i<options.length ; i++)
 		newOptions[i] = options[i];
@@ -566,18 +520,17 @@ function sortOptions(options) {
 
 }
 
-function mysort(a, b){
-	if(a.text.toLowerCase() > b.text.toLowerCase()){
+function mysort(a, b) {
+	if (a.text.toLowerCase() > b.text.toLowerCase()){
 		return 1;
 	}
-	if(a.text.toLowerCase() < b.text.toLowerCase()){
+	if (a.text.toLowerCase() < b.text.toLowerCase()){
 		return -1;
 	}
 	return 0;
 }
 
 function valide() {
-
 	var relation_select = document.getElementById('relation');
 	if (relation_select && relation_select.value=="") {
 		alert("<?php echo get_lang('YouMustChooseARelationType')?>");
@@ -590,24 +543,19 @@ function valide() {
 	}
 }
 
-
-function loadUsersInSelect(select){
-
+function loadUsersInSelect(select) {
 	var xhr_object = null;
 
-	if(window.XMLHttpRequest) // Firefox
+	if (window.XMLHttpRequest) // Firefox
 		xhr_object = new XMLHttpRequest();
 	else if(window.ActiveXObject) // Internet Explorer
 		xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
 	else  // XMLHttpRequest non supporté par le navigateur
 	alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...");
 
-	//xhr_object.open("GET", "loadUsersInSelect.ajax.php?id_session=<?php echo $id_session ?>&letter="+select.options[select.selectedIndex].text, false);
 	xhr_object.open("POST", "loadUsersInSelect.ajax.php");
-
 	xhr_object.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
 
-
 	nosessionUsers = makepost(document.getElementById('origin_users'));
 	sessionUsers = makepost(document.getElementById('destination_users'));
 	nosessionClasses = makepost(document.getElementById('origin_classes'));
@@ -622,19 +570,14 @@ function loadUsersInSelect(select){
 	}
 }
 
-function makepost(select){
-
+function makepost(select) {
 	var options = select.options;
 	var ret = "";
 	for (i = 0 ; i<options.length ; i++)
 		ret = ret + options[i].value +'::'+options[i].text+";;";
-
 	return ret;
-
 }
--->
-
 </script>
 <?php
-/*  FOOTER */
-Display::display_footer();
+
+Display::display_footer();

+ 51 - 34
main/admin/add_users_to_session.php

@@ -90,7 +90,7 @@ function search_users($needle, $type)
             $id_session = intval($id_session);
             // check id_user from session_rel_user table
             $sql = 'SELECT id_user FROM '.$tbl_session_rel_user.'
-            WHERE id_session ="'.$id_session.'" AND relation_type<>'.SESSION_RELATION_TYPE_RRHH.' ';
+                    WHERE id_session ="'.$id_session.'" AND relation_type<>'.SESSION_RELATION_TYPE_RRHH.' ';
             $res = Database::query($sql);
             $user_ids = array();
             if (Database::num_rows($res) > 0) {
@@ -106,20 +106,21 @@ function search_users($needle, $type)
         switch ($type) {
             case 'single':
                 // search users where username or firstname or lastname begins likes $needle
-                $sql = 'SELECT user.user_id, username, lastname, firstname FROM '.$tbl_user.' user
+                $sql = 'SELECT user.user_id, username, lastname, firstname, official_code
+                        FROM '.$tbl_user.' user
                         WHERE (username LIKE "'.$needle.'%" OR firstname LIKE "'.$needle.'%"
                             OR lastname LIKE "'.$needle.'%") AND user.status<>6 AND user.status<>'.DRH.''.
                             $order_clause.
                             ' LIMIT 11';
                 break;
             case 'multiple':
-                $sql = 'SELECT user.user_id, username, lastname, firstname
+                $sql = 'SELECT user.user_id, username, lastname, firstname, official_code
                         FROM '.$tbl_user.' user
                         WHERE '.(api_sort_by_first_name() ? 'firstname' : 'lastname').' LIKE "'.$needle.'%" AND user.status<>'.DRH.' AND user.status<>6 '.$cond_user_id.
                         $order_clause;
                 break;
             case 'any_session':
-                $sql = 'SELECT DISTINCT user.user_id, username, lastname, firstname
+                $sql = 'SELECT DISTINCT user.user_id, username, lastname, firstname, official_code
                         FROM '.$tbl_user.' user
                         LEFT OUTER JOIN '.$tbl_session_rel_user.' s ON (s.id_user = user.user_id)
                         WHERE   s.id_user IS null AND user.status<>'.DRH.' AND
@@ -134,7 +135,8 @@ function search_users($needle, $type)
             if ($access_url_id != -1) {
                 switch($type) {
                     case 'single':
-                        $sql = 'SELECT user.user_id, username, lastname, firstname FROM '.$tbl_user.' user
+                        $sql = 'SELECT user.user_id, username, lastname, firstname, official_code
+                        FROM '.$tbl_user.' user
                         INNER JOIN '.$tbl_user_rel_access_url.' url_user ON (url_user.user_id=user.user_id)
                         WHERE access_url_id = '.$access_url_id.'  AND (username LIKE "'.$needle.'%"
                         OR firstname LIKE "'.$needle.'%"
@@ -143,7 +145,8 @@ function search_users($needle, $type)
                         ' LIMIT 11';
                         break;
                     case 'multiple':
-                        $sql = 'SELECT user.user_id, username, lastname, firstname FROM '.$tbl_user.' user
+                        $sql = 'SELECT user.user_id, username, lastname, firstname , official_code
+                        FROM '.$tbl_user.' user
                         INNER JOIN '.$tbl_user_rel_access_url.' url_user ON (url_user.user_id=user.user_id)
                         WHERE access_url_id = '.$access_url_id.' AND
                             '.(api_sort_by_first_name() ? 'firstname' : 'lastname').' LIKE "'.$needle.'%" AND
@@ -152,7 +155,7 @@ function search_users($needle, $type)
                         $order_clause;
                         break;
                     case 'any_session' :
-                        $sql = 'SELECT DISTINCT user.user_id, username, lastname, firstname
+                        $sql = 'SELECT DISTINCT user.user_id, username, lastname, firstname, official_code
                             FROM '.$tbl_user.' user
                             LEFT OUTER JOIN '.$tbl_session_rel_user.' s ON (s.id_user = user.user_id)
                             INNER JOIN '.$tbl_user_rel_access_url.' url_user ON (url_user.user_id=user.user_id)
@@ -173,8 +176,8 @@ function search_users($needle, $type)
             while ($user = Database :: fetch_array($rs)) {
                 $i++;
                 if ($i<=10) {
-                    $person_name = api_get_person_name($user['firstname'], $user['lastname']);
-                    $return .= '<a href="javascript: void(0);" onclick="javascript: add_user_to_session(\''.$user['user_id'].'\',\''.$person_name.' ('.$user['username'].')'.'\')">'.$person_name.' ('.$user['username'].')</a><br />';
+                    $person_name = api_get_person_name($user['firstname'], $user['lastname']).' ('.$user['username'].') '.$user['official_code'];
+                    $return .= '<a href="javascript: void(0);" onclick="javascript: add_user_to_session(\''.$user['user_id'].'\',\''.$person_name.' '.'\')">'.$person_name.' </a><br />';
                 } else {
                     $return .= '...<br />';
                 }
@@ -185,8 +188,8 @@ function search_users($needle, $type)
             global $nosessionUsersList;
             $return .= '<select id="origin_users" name="nosessionUsersList[]" multiple="multiple" size="15" style="width:360px;">';
             while ($user = Database :: fetch_array($rs)) {
-                $person_name = api_get_person_name($user['firstname'], $user['lastname']);
-	            $return .= '<option value="'.$user['user_id'].'">'.$person_name.' ('.$user['username'].')</option>';
+                $person_name = api_get_person_name($user['firstname'], $user['lastname']).' ('.$user['username'].') '.$user['official_code'];
+	            $return .= '<option value="'.$user['user_id'].'">'.$person_name.' </option>';
 			}
 			$return .= '</select>';
 			$xajax_response -> addAssign('ajax_list_users_multiple','innerHTML',api_utf8_encode($return));
@@ -277,25 +280,25 @@ $ajax_search = $add_type == 'unique' ? true : false;
 
 $order_clause = api_sort_by_first_name() ? ' ORDER BY firstname, lastname, username' : ' ORDER BY lastname, firstname, username';
 if ($ajax_search) {
-    $sql="SELECT user_id, lastname, firstname, username, id_session
+    $sql = "SELECT user_id, lastname, firstname, username, id_session, official_code
             FROM $tbl_user u
             INNER JOIN $tbl_session_rel_user
                 ON $tbl_session_rel_user.id_user = u.user_id AND $tbl_session_rel_user.relation_type<>".SESSION_RELATION_TYPE_RRHH."
                 AND $tbl_session_rel_user.id_session = ".intval($id_session)."
-                WHERE u.status<>".DRH." AND u.status<>6 $order_clause";
+            WHERE u.status<>".DRH." AND u.status<>6 $order_clause";
 
     if (api_is_multiple_url_enabled()) {
         $tbl_user_rel_access_url= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
         $access_url_id = api_get_current_access_url_id();
         if ($access_url_id != -1) {
-            $sql="SELECT u.user_id, lastname, firstname, username, id_session
+            $sql="SELECT u.user_id, lastname, firstname, username, id_session, official_code
             FROM $tbl_user u
             INNER JOIN $tbl_session_rel_user
                 ON $tbl_session_rel_user.id_user = u.user_id AND $tbl_session_rel_user.relation_type<>".SESSION_RELATION_TYPE_RRHH."
                 AND $tbl_session_rel_user.id_session = ".intval($id_session)."
                 INNER JOIN $tbl_user_rel_access_url url_user ON (url_user.user_id=u.user_id)
-                WHERE access_url_id = $access_url_id AND u.status<>".DRH." AND u.status<>6
-                $order_clause";
+            WHERE access_url_id = $access_url_id AND u.status<>".DRH." AND u.status<>6
+            $order_clause";
         }
     }
     $result = Database::query($sql);
@@ -353,18 +356,22 @@ if ($ajax_search) {
     }
 
     if ($use_extra_fields) {
-        $sql = "SELECT  user_id, lastname, firstname, username, id_session
+        $sql = "SELECT  user_id, lastname, firstname, username, id_session, official_code
                FROM $tbl_user u
                     LEFT JOIN $tbl_session_rel_user
-                    ON $tbl_session_rel_user.id_user = u.user_id AND $tbl_session_rel_user.id_session = '$id_session' AND $tbl_session_rel_user.relation_type<>".SESSION_RELATION_TYPE_RRHH."
-                    $where_filter AND u.status<>".DRH." AND u.status<>6
-                    $order_clause";
+                    ON $tbl_session_rel_user.id_user = u.user_id AND
+                    $tbl_session_rel_user.id_session = '$id_session' AND
+                    $tbl_session_rel_user.relation_type<>".SESSION_RELATION_TYPE_RRHH."
+                $where_filter AND u.status<>".DRH." AND u.status<>6
+                $order_clause";
 
     } else {
-        $sql = "SELECT  user_id, lastname, firstname, username, id_session
+        $sql = "SELECT  user_id, lastname, firstname, username, id_session, official_code
                 FROM $tbl_user u
                 LEFT JOIN $tbl_session_rel_user
-                ON $tbl_session_rel_user.id_user = u.user_id AND $tbl_session_rel_user.id_session = '$id_session' AND $tbl_session_rel_user.relation_type<>".SESSION_RELATION_TYPE_RRHH."
+                ON $tbl_session_rel_user.id_user = u.user_id AND
+                $tbl_session_rel_user.id_session = '$id_session' AND
+                $tbl_session_rel_user.relation_type<>".SESSION_RELATION_TYPE_RRHH."
                 WHERE u.status<>".DRH." AND u.status<>6
                 $order_clause";
     }
@@ -372,42 +379,52 @@ if ($ajax_search) {
         $tbl_user_rel_access_url= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
         $access_url_id = api_get_current_access_url_id();
         if ($access_url_id != -1) {
-            $sql = "SELECT  u.user_id, lastname, firstname, username, id_session
+            $sql = "SELECT  u.user_id, lastname, firstname, username, id_session, official_code
                     FROM $tbl_user u
                     LEFT JOIN $tbl_session_rel_user
-                        ON $tbl_session_rel_user.id_user = u.user_id AND $tbl_session_rel_user.id_session = '$id_session' AND $tbl_session_rel_user.relation_type<>".SESSION_RELATION_TYPE_RRHH."
+                        ON $tbl_session_rel_user.id_user = u.user_id AND
+                        $tbl_session_rel_user.id_session = '$id_session' AND
+                        $tbl_session_rel_user.relation_type <> ".SESSION_RELATION_TYPE_RRHH."
                     INNER JOIN $tbl_user_rel_access_url url_user ON (url_user.user_id=u.user_id)
-                    WHERE access_url_id = $access_url_id  $where_filter AND u.status<>".DRH." AND u.status<>6
+                    WHERE access_url_id = $access_url_id $where_filter AND u.status<>".DRH." AND u.status<>6
                     $order_clause";
         }
     }
 
     $result   = Database::query($sql);
     $users    = Database::store_result($result,'ASSOC');
-
     foreach ($users as $uid => $user) {
         if ($user['id_session'] != $id_session) {
-            $nosessionUsersList[$user['user_id']] = array('fn'=>$user['firstname'],'ln'=>$user['lastname'],'un'=>$user['username']) ;
+            $nosessionUsersList[$user['user_id']] = array(
+                'fn' => $user['firstname'],
+                'ln' => $user['lastname'],
+                'un' => $user['username'],
+                'official_code' => $user['official_code']
+            ) ;
             unset($users[$uid]);
 	}
     }
     unset($users); //clean to free memory
 
     //filling the correct users in list
-    $sql="SELECT  user_id, lastname, firstname, username, id_session
+    $sql="SELECT  user_id, lastname, firstname, username, id_session, official_code
           FROM $tbl_user u
           LEFT JOIN $tbl_session_rel_user
-          ON $tbl_session_rel_user.id_user = u.user_id AND $tbl_session_rel_user.id_session = '$id_session' AND $tbl_session_rel_user.relation_type<>".SESSION_RELATION_TYPE_RRHH."
+          ON $tbl_session_rel_user.id_user = u.user_id AND
+            $tbl_session_rel_user.id_session = '$id_session' AND
+            $tbl_session_rel_user.relation_type<>".SESSION_RELATION_TYPE_RRHH."
           WHERE u.status<>".DRH." AND u.status<>6 $order_clause";
 
     if (api_is_multiple_url_enabled()) {
         $tbl_user_rel_access_url= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
         $access_url_id = api_get_current_access_url_id();
         if ($access_url_id != -1) {
-            $sql="SELECT  u.user_id, lastname, firstname, username, id_session
+            $sql="SELECT  u.user_id, lastname, firstname, username, id_session, official_code
                 FROM $tbl_user u
                 LEFT JOIN $tbl_session_rel_user
-                    ON $tbl_session_rel_user.id_user = u.user_id AND $tbl_session_rel_user.id_session = '$id_session' AND $tbl_session_rel_user.relation_type<>".SESSION_RELATION_TYPE_RRHH."
+                    ON $tbl_session_rel_user.id_user = u.user_id AND
+                    $tbl_session_rel_user.id_session = '$id_session' AND
+                    $tbl_session_rel_user.relation_type<>".SESSION_RELATION_TYPE_RRHH."
                 INNER JOIN $tbl_user_rel_access_url url_user ON (url_user.user_id=u.user_id)
                 WHERE access_url_id = $access_url_id AND u.status<>".DRH." AND u.status<>6
                 $order_clause";
@@ -515,7 +532,7 @@ if (!empty($errorMsg)) {
               foreach ($nosessionUsersList as $uid => $enreg) {
               ?>
                   <option value="<?php echo $uid; ?>" <?php if(in_array($uid,$UserList)) echo 'selected="selected"'; ?>>
-                      <?php echo api_get_person_name($enreg['fn'], $enreg['ln']).' ('.$enreg['un'].')'; ?>
+                      <?php echo api_get_person_name($enreg['fn'], $enreg['ln']).' ('.$enreg['un'].') '.$enreg['official_code']; ?>
                   </option>
               <?php
               }
@@ -566,10 +583,10 @@ if (!empty($errorMsg)) {
         </div>
         <select id="destination_users" name="sessionUsersList[]" multiple="multiple" size="15" class="span5">
         <?php
-        foreach($sessionUsersList as $enreg) {
+        foreach ($sessionUsersList as $enreg) {
         ?>
             <option value="<?php echo $enreg['user_id']; ?>">
-                <?php echo api_get_person_name($enreg['firstname'], $enreg['lastname']).' ('.$enreg['username'].')'; ?>
+                <?php echo api_get_person_name($enreg['firstname'], $enreg['lastname']).' ('.$enreg['username'].') '.$enreg['official_code']; ?>
             </option>
         <?php
         }

+ 16 - 9
main/admin/add_users_to_usergroup.php

@@ -27,7 +27,7 @@ $interbreadcrumb[]= array('url' => 'usergroups.php','name' => get_lang('Classes'
 // Database Table Definitions
 
 // setting the name of the tool
-$tool_name=get_lang('SubscribeUsersToClass');
+$tool_name = get_lang('SubscribeUsersToClass');
 
 $add_type = 'multiple';
 if (isset($_REQUEST['add_type']) && $_REQUEST['add_type']!='') {
@@ -103,6 +103,10 @@ if (is_array($extra_field_list)) {
 
 $usergroup = new UserGroup();
 $id = intval($_GET['id']);
+
+if (empty($id)) {
+    api_not_allowed(true);
+}
 $first_letter_user = '';
 
 if (isset($_POST['form_sent']) && $_POST['form_sent']) {
@@ -153,6 +157,7 @@ if ($use_extra_fields) {
         $final_result = $extra_field_result[0];
     }
 }
+
 // Filters
 $filters = array(
     array('type' => 'text', 'name' => 'username', 'label' => get_lang('Username')),
@@ -163,18 +168,14 @@ $filters = array(
 );
 
 $searchForm = new FormValidator('search', 'get', api_get_self().'?id='.$id);
-//$searchForm->addElement('html', '<table>');
-$searchForm->add_header(get_lang('FilterUser'));
+$searchForm->add_header(get_lang('AdvancedSearch'));
 $renderer =& $searchForm->defaultRenderer();
 
 $searchForm->addElement('hidden', 'id', $id);
 foreach ($filters as $param) {
-    //$searchForm->addElement('html', '<tr>');
     $searchForm->addElement($param['type'], $param['name'], $param['label']);
-    //$searchForm->addElement('html', '</tr>');
 }
 $searchForm->addElement('button', 'submit', get_lang('Search'));
-//$searchForm->addElement('html', '</table>');
 
 $filterData = array();
 if ($searchForm->validate()) {
@@ -223,7 +224,10 @@ if (!empty($complete_user_list)) {
         }
 
         if (in_array($item['user_id'], $list_in)) {
-            $person_name = api_get_person_name($item['firstname'], $item['lastname']).' ('.$item['username'].')';
+            $person_name = api_get_person_name(
+                $item['firstname'],
+                $item['lastname']
+            ).' ('.$item['username'].') '.$item['official_code'];
             $elements_in[$item['user_id']] = $person_name;
         }
     }
@@ -252,7 +256,10 @@ if (!empty($user_list)) {
             }
         }
         if ($item['status'] == 6 ) continue; //avoid anonymous users
-        $person_name = api_get_person_name($item['firstname'], $item['lastname']).' ('.$item['username'].')';
+        $person_name = api_get_person_name(
+            $item['firstname'],
+            $item['lastname']
+        ).' ('.$item['username'].') '.$item['official_code'];
         if (in_array($item['user_id'], $list_in)) {
             //$elements_in[$item['user_id']] = $person_name;
         } else {
@@ -295,7 +302,7 @@ if ($add_type=='multiple') {
                 foreach ($new_field['data'] as $option) {
                     $checked='';
                     if (isset($_POST[$varname])) {
-                        if ($_POST[$varname]==$option[1]) {
+                        if ($_POST[$varname] == $option[1]) {
                             $checked = 'selected="true"';
                         }
                     }

+ 54 - 54
main/admin/dashboard_add_courses_to_user.php

@@ -7,9 +7,9 @@
 */
 
 // name of the language file that needs to be included
-$language_file='admin';
+$language_file = 'admin';
 // resetting the course id
-$cidReset=true;
+$cidReset = true;
 
 // including some necessary dokeos files
 require_once '../inc/global.inc.php';
@@ -17,10 +17,9 @@ require_once '../inc/lib/xajax/xajax.inc.php';
 
 global $_configuration;
 
-
 // create an ajax object
 $xajax = new xajax();
-$xajax -> registerFunction ('search_courses');
+$xajax->registerFunction('search_courses');
 
 // setting the section (for the tabs)
 $this_section = SECTION_PLATFORM_ADMIN;
@@ -33,12 +32,11 @@ $interbreadcrumb[] = array('url' => 'index.php', 'name' => get_lang('PlatformAdm
 $interbreadcrumb[] = array('url' => 'user_list.php','name' => get_lang('UserList'));
 
 // Database Table Definitions
-$tbl_course 			= 	Database::get_main_table(TABLE_MAIN_COURSE);
-$tbl_course_rel_user 	= 	Database::get_main_table(TABLE_MAIN_COURSE_USER);
-$tbl_course_rel_access_url 	= 	Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
+$tbl_course = Database::get_main_table(TABLE_MAIN_COURSE);
+$tbl_course_rel_user = Database::get_main_table(TABLE_MAIN_COURSE_USER);
+$tbl_course_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
 
 // initializing variables
-$id_session=intval($_GET['id_session']);
 $user_id = intval($_GET['user']);
 $user_info = api_get_user_info($user_id);
 $user_anonymous  = api_get_anonymous_id();
@@ -54,7 +52,7 @@ if (UserManager::is_admin($user_id)) {
 }
 
 $add_type = 'multiple';
-if(isset($_GET['add_type']) && $_GET['add_type']!=''){
+if(isset($_GET['add_type']) && $_GET['add_type']!='') {
 	$add_type = Security::remove_XSS($_REQUEST['add_type']);
 }
 
@@ -62,34 +60,34 @@ if (!api_is_platform_admin()) {
 	api_not_allowed(true);
 }
 
-function search_courses($needle,$type) {
-	global $_configuration, $tbl_course, $tbl_course_rel_user, $tbl_course_rel_access_url,$user_id;
-
-	$xajax_response = new XajaxResponse();
-	$return = '';
-	if(!empty($needle) && !empty($type)) {
-		// xajax send utf8 datas... datas in db can be non-utf8 datas
-		$charset = api_get_system_encoding();
-		$needle = api_convert_encoding($needle, $charset, 'utf-8');
-
-		$assigned_courses_to_hrm = CourseManager::get_courses_followed_by_drh($user_id);
-		$assigned_courses_code = array_keys($assigned_courses_to_hrm);
-		foreach ($assigned_courses_code as &$value) {
-			$value = "'".$value."'";
-		}
-		$without_assigned_courses = '';
-		if (count($assigned_courses_code) > 0) {
-			$without_assigned_courses = " AND c.code NOT IN(".implode(',',$assigned_courses_code).")";
-		}
-
-		if ($_configuration['multiple_access_urls']) {
-			$sql = "SELECT c.code, c.title FROM $tbl_course c LEFT JOIN $tbl_course_rel_access_url a ON (a.course_code = c.code)
-				WHERE  c.code LIKE '$needle%' $without_assigned_courses AND access_url_id = ".api_get_current_access_url_id()."";
-		} else {
-			$sql = "SELECT c.code, c.title FROM $tbl_course c
-				WHERE  c.code LIKE '$needle%' $without_assigned_courses ";
-		}
-
+function search_courses($needle,$type)
+{
+    global $_configuration, $tbl_course, $tbl_course_rel_user, $tbl_course_rel_access_url,$user_id;
+
+    $xajax_response = new XajaxResponse();
+    $return = '';
+    if(!empty($needle) && !empty($type)) {
+        // xajax send utf8 datas... datas in db can be non-utf8 datas
+        $charset = api_get_system_encoding();
+        $needle = api_convert_encoding($needle, $charset, 'utf-8');
+
+        $assigned_courses_to_hrm = CourseManager::get_courses_followed_by_drh($user_id);
+        $assigned_courses_code = array_keys($assigned_courses_to_hrm);
+        foreach ($assigned_courses_code as &$value) {
+            $value = "'".$value."'";
+        }
+        $without_assigned_courses = '';
+        if (count($assigned_courses_code) > 0) {
+            $without_assigned_courses = " AND c.code NOT IN(".implode(',',$assigned_courses_code).")";
+        }
+
+        if ($_configuration['multiple_access_urls']) {
+            $sql = "SELECT c.code, c.title FROM $tbl_course c LEFT JOIN $tbl_course_rel_access_url a ON (a.course_code = c.code)
+                WHERE  c.code LIKE '$needle%' $without_assigned_courses AND access_url_id = ".api_get_current_access_url_id()."";
+        } else {
+            $sql = "SELECT c.code, c.title FROM $tbl_course c
+                WHERE  c.code LIKE '$needle%' $without_assigned_courses ";
+        }
 
 		$rs	= Database::query($sql);
 
@@ -103,11 +101,10 @@ function search_courses($needle,$type) {
 	return $xajax_response;
 }
 
-$xajax -> processRequests();
+$xajax->processRequests();
 $htmlHeadXtra[] = $xajax->getJavascript('../inc/lib/xajax/');
 $htmlHeadXtra[] = '
 <script type="text/javascript">
-<!--
 function moveItem(origin , destination) {
 	for(var i = 0 ; i<origin.options.length ; i++) {
 		if(origin.options[i].selected) {
@@ -155,7 +152,6 @@ function remove_item(origin) {
 		}
 	}
 }
--->
 </script>';
 
 $formSent=0;
@@ -163,12 +159,12 @@ $errorMsg = $firstLetterCourse = '';
 $UserList = array();
 
 $msg = '';
-if (intval($_POST['formSent']) == 1) {
-	$courses_list = $_POST['CoursesList'];
-	$affected_rows = CourseManager::suscribe_courses_to_hr_manager($user_id,$courses_list);
-	if ($affected_rows)	{
-		$msg = get_lang('AssignedCoursesHaveBeenUpdatedSuccessfully');
-	}
+if (isset($_POST['formSent']) && intval($_POST['formSent']) == 1) {
+    $courses_list = $_POST['CoursesList'];
+    $affected_rows = CourseManager::suscribe_courses_to_hr_manager($user_id,$courses_list);
+    if ($affected_rows)	{
+        $msg = get_lang('AssignedCoursesHaveBeenUpdatedSuccessfully');
+    }
 }
 
 // display header
@@ -200,15 +196,19 @@ if (isset($_POST['firstLetterCourse'])) {
 	$needle = "$needle%";
 }
 
-if ($_configuration['multiple_access_urls']) {
-	$sql 	= " SELECT c.code, c.title FROM $tbl_course c LEFT JOIN $tbl_course_rel_access_url a ON (a.course_code = c.code)
-                WHERE  c.code LIKE '$needle' $without_assigned_courses AND access_url_id = ".api_get_current_access_url_id()."
-                ORDER BY c.title";
+if (api_is_multiple_url_enabled()) {
+	$sql = " SELECT c.code, c.title
+            FROM $tbl_course c
+            LEFT JOIN $tbl_course_rel_access_url a ON (a.course_code = c.code)
+            WHERE
+                c.code LIKE '$needle' $without_assigned_courses AND
+                access_url_id = ".api_get_current_access_url_id()."
+            ORDER BY c.title";
 
 } else {
-	$sql 	= " SELECT c.code, c.title FROM $tbl_course c
-                WHERE  c.code LIKE '$needle' $without_assigned_courses 
-                ORDER BY c.title";
+	$sql= " SELECT c.code, c.title FROM $tbl_course c
+            WHERE  c.code LIKE '$needle' $without_assigned_courses
+            ORDER BY c.title";
 }
 
 
@@ -304,4 +304,4 @@ if(!empty($msg)) {
 
 </form>
 <?php
-Display::display_footer();
+Display::display_footer();

+ 39 - 34
main/admin/dashboard_add_sessions_to_user.php

@@ -7,7 +7,7 @@
 */
 
 // name of the language file that needs to be included
-$language_file='admin';
+$language_file = 'admin';
 // resetting the course id
 $cidReset = true;
 
@@ -30,41 +30,42 @@ $interbreadcrumb[] = array('url' => 'index.php', 'name' => get_lang('PlatformAdm
 $interbreadcrumb[] = array('url' => 'user_list.php','name' => get_lang('UserList'));
 
 // Database Table Definitions
-$tbl_session 			= 	Database::get_main_table(TABLE_MAIN_SESSION);
-$tbl_session_rel_user 	= 	Database::get_main_table(TABLE_MAIN_SESSION_USER);
-$tbl_session_rel_access_url = 	Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
+$tbl_session 			= Database::get_main_table(TABLE_MAIN_SESSION);
+$tbl_session_rel_user 	= Database::get_main_table(TABLE_MAIN_SESSION_USER);
+$tbl_session_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
 
-// initializing variables
-$id_session = intval($_GET['id_session']);
-$user_id = intval($_GET['user']);
+// Initializing variables
+$user_id = isset($_GET['user']) ? intval($_GET['user']) : null;
 $user_info = api_get_user_info($user_id);
 $user_anonymous = api_get_anonymous_id();
 $current_user_id = api_get_user_id();
+$ajax_search = false;
 
-// setting the name of the tool
+// Setting the name of the tool
 if (UserManager::is_admin($user_id)) {
-	$tool_name= get_lang('AssignSessionsToPlatformAdministrator');
+	$tool_name = get_lang('AssignSessionsToPlatformAdministrator');
 } else if ($user_info['status'] == SESSIONADMIN) {
-	$tool_name= get_lang('AssignSessionsToSessionsAdministrator');
+    $tool_name = get_lang('AssignSessionsToSessionsAdministrator');
 } else {
-	$tool_name= get_lang('AssignSessionsToHumanResourcesManager');
+    $tool_name = get_lang('AssignSessionsToHumanResourcesManager');
 }
 
 $add_type = 'multiple';
-if (isset($_GET['add_type']) && $_GET['add_type']!=''){
+if (isset($_GET['add_type']) && $_GET['add_type']!='') {
     $add_type = Security::remove_XSS($_REQUEST['add_type']);
 }
 
 if (!api_is_platform_admin() && !api_is_session_admin()) {
-	api_not_allowed(true);
+    api_not_allowed(true);
 }
 
-function search_sessions($needle,$type) {
+function search_sessions($needle,$type)
+{
     global $_configuration, $tbl_session_rel_access_url, $tbl_session, $user_id;
 
     $xajax_response = new XajaxResponse();
     $return = '';
-    if(!empty($needle) && !empty($type)) {
+    if (!empty($needle) && !empty($type)) {
         // xajax send utf8 datas... datas in db can be non-utf8 datas
         $charset = api_get_system_encoding();
         $needle = api_convert_encoding($needle, $charset, 'utf-8');
@@ -73,19 +74,18 @@ function search_sessions($needle,$type) {
 
         $without_assigned_sessions = '';
         if (count($assigned_sessions_id) > 0) {
-            $without_assigned_sessions = " AND s.id NOT IN(".implode(',',$assigned_sessions_id).")";
+            $without_assigned_sessions = " AND s.id NOT IN(".implode(',', $assigned_sessions_id).")";
         }
 
         if ($_configuration['multiple_access_urls']) {
-            $sql 	= " SELECT s.id, s.name FROM $tbl_session s LEFT JOIN $tbl_session_rel_access_url a ON (s.id = a.session_id)
+            $sql 	= " SELECT s.id, s.name FROM $tbl_session s
+                        LEFT JOIN $tbl_session_rel_access_url a ON (s.id = a.session_id)
                         WHERE  s.name LIKE '$needle%' $without_assigned_sessions AND access_url_id = ".api_get_current_access_url_id()."";
         } else {
             $sql = "SELECT s.id, s.name FROM $tbl_session s
                     WHERE  s.name LIKE '$needle%' $without_assigned_sessions ";
         }
-
         $rs	= Database::query($sql);
-
         $return .= '<select id="origin" name="NoAssignedSessionsList[]" multiple="multiple" size="20" style="width:340px;">';
         while($session = Database :: fetch_array($rs)) {
             $return .= '<option value="'.$session['id'].'" title="'.htmlspecialchars($session['name'],ENT_QUOTES).'">'.$session['name'].'</option>';
@@ -154,7 +154,7 @@ $errorMsg = $firstLetterSession = '';
 $UserList = array();
 
 $msg = '';
-if (intval($_POST['formSent']) == 1) {
+if (isset($_POST['formSent']) && intval($_POST['formSent']) == 1) {
     $sessions_list = $_POST['SessionsList'];
     $userInfo = api_get_user_info($user_id);
     $affected_rows = SessionManager::suscribe_sessions_to_hr_manager($userInfo, $sessions_list);
@@ -178,7 +178,6 @@ echo '</div>';
 echo Display::page_header(sprintf(get_lang('AssignSessionsToX'), api_get_person_name($user_info['firstname'], $user_info['lastname'])));
 
 $assigned_sessions_to_hrm = SessionManager::get_sessions_followed_by_drh($user_id);
-
 $assigned_sessions_id = array_keys($assigned_sessions_to_hrm);
 
 $without_assigned_sessions = '';
@@ -188,24 +187,26 @@ if (count($assigned_sessions_id) > 0) {
 
 $needle = '%';
 if (isset($_POST['firstLetterSession'])) {
-	$needle = Database::escape_string($_POST['firstLetterSession']);
-	$needle = "$needle%";
+    $needle = Database::escape_string($_POST['firstLetterSession']);
+    $needle = "$needle%";
 }
 
 if (api_is_multiple_url_enabled()) {
-	$sql 	= " SELECT s.id, s.name FROM $tbl_session s LEFT JOIN $tbl_session_rel_access_url a ON (s.id = a.session_id)
-				WHERE  s.name LIKE '$needle%' $without_assigned_sessions AND access_url_id = ".api_get_current_access_url_id()."
-                ORDER BY s.name";
+	$sql = "SELECT s.id, s.name
+	        FROM $tbl_session s
+            LEFT JOIN $tbl_session_rel_access_url a ON (s.id = a.session_id)
+            WHERE
+                s.name LIKE '$needle%' $without_assigned_sessions AND
+                access_url_id = ".api_get_current_access_url_id()."
+            ORDER BY s.name";
 } else {
-    $sql 	= " SELECT s.id, s.name FROM $tbl_session s
-				WHERE  s.name LIKE '$needle%' $without_assigned_sessions
-                ORDER BY s.name
-                ";
+    $sql = "SELECT s.id, s.name FROM $tbl_session s
+		    WHERE  s.name LIKE '$needle%' $without_assigned_sessions
+            ORDER BY s.name";
 }
-
 $result	= Database::query($sql);
 ?>
-<form name="formulaire" method="post" action="<?php echo api_get_self(); ?>?user=<?php echo $user_id ?>" style="margin:0px;" <?php if($ajax_search){echo ' onsubmit="valide();"';}?>>
+<form name="formulaire" method="post" action="<?php echo api_get_self(); ?>?user=<?php echo $user_id ?>" style="margin:0px;" <?php if($ajax_search){ echo ' onsubmit="valide();"';}?>>
 <input type="hidden" name="formSent" value="1" />
 <?php
 if(!empty($msg)) {
@@ -253,7 +254,9 @@ if(!empty($msg)) {
 	<?php
 	while ($enreg = Database::fetch_array($result)) {
 	?>
-		<option value="<?php echo $enreg['id']; ?>" <?php echo 'title="'.htmlspecialchars($enreg['name'],ENT_QUOTES).'"';?>><?php echo $enreg['name']; ?></option>
+		<option value="<?php echo $enreg['id']; ?>" <?php echo 'title="'.htmlspecialchars($enreg['name'],ENT_QUOTES).'"';?>>
+            <?php echo $enreg['name']; ?>
+        </option>
 	<?php } ?>
 	</select></div>
   </td>
@@ -285,7 +288,9 @@ if(!empty($msg)) {
 	if (is_array($assigned_sessions_to_hrm)) {
 		foreach($assigned_sessions_to_hrm as $enreg) {
 	?>
-		<option value="<?php echo $enreg['id']; ?>" <?php echo 'title="'.htmlspecialchars($enreg['name'],ENT_QUOTES).'"'; ?>><?php echo $enreg['name'] ?></option>
+		<option value="<?php echo $enreg['id']; ?>" <?php echo 'title="'.htmlspecialchars($enreg['name'],ENT_QUOTES).'"'; ?>>
+            <?php echo $enreg['name'] ?>
+        </option>
 	<?php }
 	}?>
   </select></td>

+ 206 - 111
main/admin/dashboard_add_users_to_user.php

@@ -7,19 +7,19 @@
 */
 
 // name of the language file that needs to be included
-$language_file='admin';
+$language_file = 'admin';
 // resetting the course id
-$cidReset=true;
+$cidReset = true;
 
 // including some necessary dokeos files
 require_once '../inc/global.inc.php';
 require_once '../inc/lib/xajax/xajax.inc.php';
 
 global $_configuration;
-
+$ajax_search = false;
 // create an ajax object
 $xajax = new xajax();
-$xajax -> registerFunction ('search_users');
+$xajax->registerFunction('search_users');
 
 // setting the section (for the tabs)
 $this_section = SECTION_PLATFORM_ADMIN;
@@ -32,107 +32,135 @@ $interbreadcrumb[] = array('url' => 'index.php', 'name' => get_lang('PlatformAdm
 $interbreadcrumb[] = array('url' => 'user_list.php','name' => get_lang('UserList'));
 
 // Database Table Definitions
-$tbl_user 			= 	Database::get_main_table(TABLE_MAIN_USER);
-$tbl_access_url_rel_user		= 	Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
+$tbl_user = Database::get_main_table(TABLE_MAIN_USER);
+$tbl_access_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
 
 // initializing variables
-$id_session=intval($_GET['id_session']);
 $user_id = intval($_GET['user']);
 $user_info = api_get_user_info($user_id);
 $user_anonymous  = api_get_anonymous_id();
 $current_user_id = api_get_user_id();
 
+$firstLetterUser = isset($_POST['firstLetterUser']) ? $_POST['firstLetterUser'] : null;
+
 // setting the name of the tool
 if (UserManager::is_admin($user_id)) {
-	$tool_name= get_lang('AssignUsersToPlatformAdministrator');
+    $tool_name= get_lang('AssignUsersToPlatformAdministrator');
 } else if ($user_info['status'] == SESSIONADMIN) {
-	$tool_name= get_lang('AssignUsersToSessionsAdministrator');
+    $tool_name= get_lang('AssignUsersToSessionsAdministrator');
 } else {
-	$tool_name= get_lang('AssignUsersToHumanResourcesManager');
+    $tool_name= get_lang('AssignUsersToHumanResourcesManager');
 }
 
 $add_type = 'multiple';
-if(isset($_GET['add_type']) && $_GET['add_type']!=''){
+if(isset($_GET['add_type']) && $_GET['add_type']!='') {
 	$add_type = Security::remove_XSS($_REQUEST['add_type']);
 }
 
 if (!api_is_platform_admin()) {
-	api_not_allowed(true);
+    api_not_allowed(true);
 }
 
-function search_users($needle,$type) {
-	global $_configuration,$tbl_access_url_rel_user,  $tbl_user, $user_anonymous, $current_user_id, $user_id;
-
-	$xajax_response = new XajaxResponse();
-	$return = '';
-	if(!empty($needle) && !empty($type)) {
-		// xajax send utf8 datas... datas in db can be non-utf8 datas
-		$charset = api_get_system_encoding();
-		$needle = api_convert_encoding($needle, $charset, 'utf-8');
-
-		$assigned_users_to_hrm = UserManager::get_users_followed_by_drh($user_id);
-		$assigned_users_id = array_keys($assigned_users_to_hrm);
-		$without_assigned_users = '';
-
-		if (count($assigned_users_id) > 0) {
-			$without_assigned_users = " AND user.user_id NOT IN(".implode(',',$assigned_users_id).")";
-		}
+function search_users($needle,$type)
+{
+    global $tbl_access_url_rel_user,  $tbl_user, $user_anonymous, $current_user_id, $user_id;
+
+    $xajax_response = new XajaxResponse();
+    $return = '';
+    if (!empty($needle) && !empty($type)) {
+        // xajax send utf8 datas... datas in db can be non-utf8 datas
+        $charset = api_get_system_encoding();
+        $needle = api_convert_encoding($needle, $charset, 'utf-8');
+
+        $assigned_users_to_hrm = UserManager::get_users_followed_by_drh($user_id);
+        $assigned_users_id = array_keys($assigned_users_to_hrm);
+        $without_assigned_users = '';
+
+        $westernOrder = api_is_western_name_order();
+        if ($westernOrder) {
+            $order_clause = " ORDER BY firstname, lastname";
+        } else {
+            $order_clause = " ORDER BY lastname, firstname";
+        }
 
-		if ($_configuration['multiple_access_urls']) {
-			$sql = "SELECT user.user_id, username, lastname, firstname FROM $tbl_user user LEFT JOIN $tbl_access_url_rel_user au ON (au.user_id = user.user_id)
-			WHERE  ".(api_sort_by_first_name() ? 'firstname' : 'lastname')." LIKE '$needle%' AND status NOT IN(".DRH.", ".SESSIONADMIN.") AND user.user_id NOT IN ($user_anonymous, $current_user_id, $user_id) $without_assigned_users AND access_url_id = ".api_get_current_access_url_id()."";
+        if (count($assigned_users_id) > 0) {
+            $without_assigned_users = " AND user.user_id NOT IN(".implode(',', $assigned_users_id).")";
+        }
 
-		} else {
-			$sql = "SELECT user_id, username, lastname, firstname FROM $tbl_user user
-			WHERE  ".(api_sort_by_first_name() ? 'firstname' : 'lastname')." LIKE '$needle%' AND status NOT IN(".DRH.", ".SESSIONADMIN.") AND user_id NOT IN ($user_anonymous, $current_user_id, $user_id) $without_assigned_users";
-		}
+        if (api_is_multiple_url_enabled()) {
+            $sql = "SELECT user.user_id, username, lastname, firstname
+                    FROM $tbl_user user
+                    LEFT JOIN $tbl_access_url_rel_user au ON (au.user_id = user.user_id)
+                    WHERE
+                        ".(api_sort_by_first_name() ? 'firstname' : 'lastname')." LIKE '$needle%' AND
+                        status NOT IN(".DRH.", ".SESSIONADMIN.") AND
+                        user.user_id NOT IN ($user_anonymous, $current_user_id, $user_id)
+                        $without_assigned_users AND
+                        access_url_id = ".api_get_current_access_url_id()."
+                    $order_clause
+                    ";
+
+        } else {
+            $sql = "SELECT user_id, username, lastname, firstname
+                    FROM $tbl_user user
+                    WHERE
+                        ".(api_sort_by_first_name() ? 'firstname' : 'lastname')." LIKE '$needle%' AND
+                        status NOT IN(".DRH.", ".SESSIONADMIN.") AND
+                        user_id NOT IN ($user_anonymous, $current_user_id, $user_id)
+                    $without_assigned_users
+                    $order_clause
+            ";
+        }
 
 		$rs	= Database::query($sql);
-
-		$xajax_response -> addAssign('ajax_list_users_multiple','innerHTML',api_utf8_encode($return));
-        
-    if ($type == 'single') {
-        $tbl_user_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
-        $access_url_id = api_get_current_access_url_id();
-        
-        $sql = 'SELECT user.user_id, username, lastname, firstname FROM '.$tbl_user.' user
-                INNER JOIN '.$tbl_user_rel_access_url.' url_user ON (url_user.user_id=user.user_id)
-                WHERE access_url_id = '.$access_url_id.'  AND (username LIKE "'.$needle.'%"
-                OR firstname LIKE "'.$needle.'%"
-                OR lastname LIKE "'.$needle.'%") AND user.status<>6 AND user.status<>'.DRH.' '.
-                $order_clause.
-               ' LIMIT 11';
-        $rs = Database::query($sql);
-        $i = 0;
-        while ($user = Database :: fetch_array($rs)) {
-            $i++;
-            if ($i <= 10) {
+		$xajax_response->addAssign('ajax_list_users_multiple','innerHTML',api_utf8_encode($return));
+
+        if ($type == 'single') {
+            $tbl_user_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
+            $access_url_id = api_get_current_access_url_id();
+
+            $sql = 'SELECT user.user_id, username, lastname, firstname
+                    FROM '.$tbl_user.' user
+                    INNER JOIN '.$tbl_user_rel_access_url.' url_user ON (url_user.user_id=user.user_id)
+                    WHERE
+                        access_url_id = '.$access_url_id.'  AND
+                        (
+                            username LIKE "'.$needle.'%" OR
+                            firstname LIKE "'.$needle.'%" OR
+                            lastname LIKE "'.$needle.'%"
+                        ) AND
+                        user.status<>6 AND user.status<>'.DRH.' '.
+                    $order_clause.
+                   ' LIMIT 11';
+            $rs = Database::query($sql);
+            $i = 0;
+            while ($user = Database :: fetch_array($rs)) {
+                $i++;
+                if ($i <= 10) {
+                    $person_name = api_get_person_name($user['firstname'], $user['lastname']);
+                    $return .= '<a href="javascript: void(0);" onclick="javascript: add_user_to_user(\''.$user['user_id'].'\',\''.$person_name.' ('.$user['username'].')'.'\')">'.$person_name.' ('.$user['username'].')</a><br />';
+                } else {
+                    $return .= '...<br />';
+                }
+            }
+           $xajax_response->addAssign('ajax_list_users_single','innerHTML',api_utf8_encode($return));
+        } else {
+            $return .= '<select id="origin" name="NoAssignedUsersList[]" multiple="multiple" size="20" style="width:340px;">';
+            while($user = Database :: fetch_array($rs)) {
                 $person_name = api_get_person_name($user['firstname'], $user['lastname']);
-                $return .= '<a href="javascript: void(0);" onclick="javascript: add_user_to_user(\''.$user['user_id'].'\',\''.$person_name.' ('.$user['username'].')'.'\')">'.$person_name.' ('.$user['username'].')</a><br />';
-            } else {
-                $return .= '...<br />';
+                $return .= '<option value="'.$user['user_id'].'" title="'.htmlspecialchars($person_name,ENT_QUOTES).'">'.$person_name.' ('.$user['username'].')</option>';
             }
+            $return .= '</select>';
+            $xajax_response->addAssign('ajax_list_users_multiple', 'innerHTML', api_utf8_encode($return));
         }
-
-       $xajax_response -> addAssign('ajax_list_users_single','innerHTML',api_utf8_encode($return));
-    } else {
-        $return .= '<select id="origin" name="NoAssignedUsersList[]" multiple="multiple" size="20" style="width:340px;">';
-	      while($user = Database :: fetch_array($rs)) {
-		        $person_name = api_get_person_name($user['firstname'], $user['lastname']);
-		        $return .= '<option value="'.$user['user_id'].'" title="'.htmlspecialchars($person_name,ENT_QUOTES).'">'.$person_name.' ('.$user['username'].')</option>';
-	      }
-	      $return .= '</select>';
-	      $xajax_response -> addAssign('ajax_list_users_multiple','innerHTML',api_utf8_encode($return));
-    }
 	}
 	return $xajax_response;
 }
 
-$xajax -> processRequests();
+$xajax->processRequests();
 $htmlHeadXtra[] = $xajax->getJavascript('../inc/lib/xajax/');
 $htmlHeadXtra[] = '
 <script type="text/javascript">
-<!--
 function add_user_to_user (code, content) {
 	document.getElementById("user_to_add").value = "";
 	document.getElementById("ajax_list_users_single").innerHTML = "";
@@ -195,33 +223,77 @@ function remove_item(origin) {
 		}
 	}
 }
--->
 </script>';
 
 $formSent=0;
-$errorMsg = $firstLetterUser = '';
+$errorMsg = '';
 $UserList = array();
 
+// Filters
+$filters = array(
+    array('type' => 'text', 'name' => 'username', 'label' => get_lang('Username')),
+    array('type' => 'text', 'name' => 'firstname', 'label' => get_lang('FirstName')),
+    array('type' => 'text', 'name' => 'lastname', 'label' => get_lang('LastName')),
+    array('type' => 'text', 'name' => 'official_code', 'label' => get_lang('OfficialCode')),
+    array('type' => 'text', 'name' => 'email', 'label' => get_lang('Email'))
+);
+
+$searchForm = new FormValidator('search', 'get', api_get_self().'?user='.$user_id);
+$searchForm->add_header(get_lang('AdvancedSearch'));
+$renderer =& $searchForm->defaultRenderer();
+
+$searchForm->addElement('hidden', 'user', $user_id);
+foreach ($filters as $param) {
+    $searchForm->addElement($param['type'], $param['name'], $param['label']);
+}
+$searchForm->addElement('button', 'submit', get_lang('Search'));
+
+$filterData = array();
+if ($searchForm->validate()) {
+    $filterData = $searchForm->getSubmitValues();
+}
+
+$conditions = array();
+if (!empty($filters) && !empty($filterData)) {
+    foreach ($filters as $filter) {
+        if (isset($filter['name']) && isset($filterData[$filter['name']])) {
+            $value = $filterData[$filter['name']];
+            if (!empty($value)) {
+                $conditions[$filter['name']] = $value;
+            }
+        }
+    }
+}
+
 $msg = '';
-if (intval($_POST['formSent']) == 1) {
+if (isset($_POST['formSent']) && intval($_POST['formSent']) == 1) {
 	$user_list = $_POST['UsersList'];
-	$affected_rows = UserManager::suscribe_users_to_hr_manager($user_id,$user_list);
-	if ($affected_rows)	{
-		$msg = get_lang('AssignedUsersHaveBeenUpdatedSuccessfully');
-	}
+    $affected_rows = UserManager::suscribe_users_to_hr_manager($user_id, $user_list);
+    if ($affected_rows)	{
+        $msg = get_lang('AssignedUsersHaveBeenUpdatedSuccessfully');
+    }
 }
 
-// display header
+// Display header
 Display::display_header($tool_name);
 
 // actions
-echo '<div class="actions">
-<span style="float: right;margin:0px;padding:0px;">
-<a href="dashboard_add_courses_to_user.php?user='.$user_id.'">'.Display::return_icon('course_add.gif', get_lang('AssignCourses'), array('style'=>'vertical-align:middle')).' '.get_lang('AssignCourses').'</a>
-<a href="dashboard_add_sessions_to_user.php?user='.$user_id.'">'.Display::return_icon('view_more_stats.gif', get_lang('AssignSessions'), array('style'=>'vertical-align:middle')).' '.get_lang('AssignSessions').'</a></span>
-</div>';
-
-echo Display::page_header(sprintf(get_lang('AssignUsersToX'), api_get_person_name($user_info['firstname'], $user_info['lastname'])));
+echo '<div class="actions">';
+echo '<span style="float: right;margin:0px;padding:0px;">
+<a href="dashboard_add_courses_to_user.php?user='.$user_id.'">'.
+    Display::return_icon('course_add.gif', get_lang('AssignCourses'), array('style'=>'vertical-align:middle')).' '.get_lang('AssignCourses').'</a>
+<a href="dashboard_add_sessions_to_user.php?user='.$user_id.'">'.
+    Display::return_icon('view_more_stats.gif', get_lang('AssignSessions'), array('style'=>'vertical-align:middle')).' '.get_lang('AssignSessions').'</a></span>';
+echo Display::url(get_lang('AdvancedSearch'), '#', array('class' => 'advanced_options', 'id' => 'advanced_search'));
+echo '</div>';
+
+echo '<div id="advanced_search_options" style="display:none">';
+$searchForm->display();
+echo '</div>';
+
+echo Display::page_header(
+    sprintf(get_lang('AssignUsersToX'), api_get_person_name($user_info['firstname'], $user_info['lastname']))
+);
 
 $assigned_users_to_hrm = UserManager::get_users_followed_by_drh($user_id);
 $assigned_users_id = array_keys($assigned_users_to_hrm);
@@ -231,24 +303,49 @@ if (count($assigned_users_id) > 0) {
 }
 
 $search_user = '';
-if (isset($_POST['firstLetterUser'])) {
-	$needle = Database::escape_string($_POST['firstLetterUser']);
+if (!empty($firstLetterUser)) {
+	$needle = Database::escape_string($firstLetterUser);
 	$search_user ="AND ".(api_sort_by_first_name() ? 'firstname' : 'lastname')." LIKE '$needle%'";
 }
 
+$sqlConditions = null;
+if (!empty($conditions)) {
+    $temp_conditions = array();
+    foreach ($conditions as $field => $value) {
+        $field = Database::escape_string($field);
+        $value = Database::escape_string($value);
+        $temp_conditions[] = $field.' LIKE \'%'.$value.'%\'';
+    }
+    if (!empty($temp_conditions)) {
+        $sqlConditions .= implode(' AND ', $temp_conditions);
+    }
+    if (!empty($sqlConditions)) {
+        $sqlConditions = " AND $sqlConditions";
+    }
+}
 
-if ($_configuration['multiple_access_urls']) {
-	$sql = "SELECT user.user_id, username, lastname, firstname FROM $tbl_user user  LEFT JOIN $tbl_access_url_rel_user au ON (au.user_id = user.user_id)
-			WHERE $without_assigned_users user.user_id NOT IN ($user_anonymous, $current_user_id, $user_id) AND status NOT IN(".DRH.", ".SESSIONADMIN.") $search_user AND access_url_id = ".api_get_current_access_url_id()."
+if (api_is_multiple_url_enabled()) {
+	$sql = "SELECT user.user_id, username, lastname, firstname
+	        FROM $tbl_user user  LEFT JOIN $tbl_access_url_rel_user au ON (au.user_id = user.user_id)
+			WHERE
+                $without_assigned_users
+                user.user_id NOT IN ($user_anonymous, $current_user_id, $user_id) AND
+                status NOT IN(".DRH.", ".SESSIONADMIN.") $search_user AND
+                access_url_id = ".api_get_current_access_url_id()."
+                $sqlConditions
             ORDER BY firstname";
 } else {
-	$sql = "SELECT user_id, username, lastname, firstname FROM $tbl_user user
-			WHERE $without_assigned_users user_id NOT IN ($user_anonymous, $current_user_id, $user_id) AND status NOT IN(".DRH.", ".SESSIONADMIN.") $search_user 
+	$sql = "SELECT user_id, username, lastname, firstname
+	        FROM $tbl_user user
+			WHERE
+			    $without_assigned_users
+			    user_id NOT IN ($user_anonymous, $current_user_id, $user_id) AND
+			    status NOT IN(".DRH.", ".SESSIONADMIN.")
+			    $search_user
+			    $sqlConditions
             ORDER BY firstname ";
 }
-
 $result	= Database::query($sql);
-
 ?>
 <form name="formulaire" method="post" action="<?php echo api_get_self(); ?>?user=<?php echo $user_id ?>" style="margin:0px;" <?php if($ajax_search){echo ' onsubmit="valide();"';}?>>
 <input type="hidden" name="formSent" value="1" />
@@ -285,7 +382,7 @@ if(!empty($msg)) {
      <select name="firstLetterUser" onchange = "xajax_search_users(this.value,'multiple')">
       <option value="%">--</option>
       <?php
-      echo Display :: get_alphabet_options($_POST['firstLetterUser']);
+      echo Display::get_alphabet_options($firstLetterUser);
       ?>
      </select>
      <input type="text" id="user_to_add" onkeyup="xajax_search_users(this.value,'single')" onclick="moveItem(document.getElementById('user_to_add'), document.getElementById('destination'))" />
@@ -301,24 +398,20 @@ if(!empty($msg)) {
 	while ($enreg = Database::fetch_array($result)) {
 		$person_name = api_get_person_name($enreg['firstname'], $enreg['lastname']);
 	?>
-		<option value="<?php echo $enreg['user_id']; ?>" <?php echo 'title="'.htmlspecialchars($person_name,ENT_QUOTES).'"';?>><?php echo $person_name.' ('.$enreg['username'].')'; ?></option>
+		<option value="<?php echo $enreg['user_id']; ?>" <?php echo 'title="'.htmlspecialchars($person_name,ENT_QUOTES).'"';?>>
+            <?php echo $person_name.' ('.$enreg['username'].')'; ?>
+        </option>
 	<?php } ?>
 	</select></div>
   </td>
 
   <td width="10%" valign="middle" align="center">
-  <?php
-  if ($ajax_search) {
-  ?>
-  	<button class="arrowl" type="button" onclick="remove_item(document.getElementById('destination'))"></button>
-  <?php
-  }
-  else
-  {
-  ?>
-  	<button class="arrowr" type="button" onclick="moveItem(document.getElementById('origin'), document.getElementById('destination'))" onclick="moveItem(document.getElementById('origin'), document.getElementById('destination'))"></button>
-	<br /><br />
-	<button class="arrowl" type="button" onclick="moveItem(document.getElementById('destination'), document.getElementById('origin'))" onclick="moveItem(document.getElementById('destination'), document.getElementById('origin'))"></button>
+  <?php if ($ajax_search) { ?>
+    <button class="arrowl" type="button" onclick="remove_item(document.getElementById('destination'))"></button>
+  <?php } else { ?>
+    <button class="arrowr" type="button" onclick="moveItem(document.getElementById('origin'), document.getElementById('destination'))" onclick="moveItem(document.getElementById('origin'), document.getElementById('destination'))"></button>
+    <br /><br />
+    <button class="arrowl" type="button" onclick="moveItem(document.getElementById('destination'), document.getElementById('origin'))" onclick="moveItem(document.getElementById('destination'), document.getElementById('origin'))"></button>
   <?php
   }
   ?>
@@ -334,7 +427,9 @@ if(!empty($msg)) {
 		foreach($assigned_users_to_hrm as $enreg) {
 			$person_name = api_get_person_name($enreg['firstname'], $enreg['lastname']);
 	?>
-		<option value="<?php echo $enreg['user_id']; ?>" <?php echo 'title="'.htmlspecialchars($person_name,ENT_QUOTES).'"'; ?>><?php echo $person_name.' ('.$enreg['username'].')'; ?></option>
+		<option value="<?php echo $enreg['user_id']; ?>" <?php echo 'title="'.htmlspecialchars($person_name,ENT_QUOTES).'"'; ?>>
+            <?php echo $person_name.' ('.$enreg['username'].')'; ?>
+        </option>
 	<?php }
 	}?>
   </select></td>
@@ -344,4 +439,4 @@ if(!empty($msg)) {
 </form>
 
 <?php
-Display::display_footer();
+Display::display_footer();

+ 4 - 3
main/admin/index.php

@@ -90,6 +90,9 @@ if (api_is_platform_admin()) {
  		array('url'=>'user_import.php', 'label' => get_lang('ImportUserListXMLCSV')),
  	);
 }
+
+$items[] = array('url'=>'usergroups.php', 	'label' => get_lang('Classes'));
+
 $blocks['users']['items'] = $items;
 $blocks['users']['extra'] = null;
 
@@ -205,8 +208,6 @@ if (api_is_platform_admin()) {
     $items[] = array('url'=>'career_dashboard.php', 	'label' => get_lang('CareersAndPromotions'));
 }
 
-$items[] = array('url'=>'usergroups.php', 	'label' => get_lang('Classes'));
-
 $blocks['sessions']['items'] = $items;
 $blocks['sessions']['extra'] = null;
 
@@ -336,4 +337,4 @@ function register_site() {
     // Reload the settings.
 }
 
-// Note: version checking mechanism has now been moved to main/inc/ajax/admin.ajax.php
+// Note: version checking mechanism has now been moved to main/inc/ajax/admin.ajax.php

+ 1 - 2
main/admin/session_edit.php

@@ -25,7 +25,6 @@ $tbl_session	= Database::get_main_table(TABLE_MAIN_SESSION);
 $id = intval($_GET['id']);
 
 SessionManager::protect_session_edit($id);
-
 $infos = SessionManager::fetch($id);
 
 $id_coach = $infos['id_coach'];
@@ -104,7 +103,7 @@ if (isset($_POST['formSent']) && $_POST['formSent']) {
 $order_clause = api_sort_by_first_name() ? ' ORDER BY firstname, lastname, username' : ' ORDER BY lastname, firstname, username';
 $sql="SELECT user_id,lastname,firstname,username FROM $tbl_user WHERE status='1'".$order_clause;
 
-if ($_configuration['multiple_access_urls']) {
+if (api_is_multiple_url_enabled()) {
 	$table_access_url_rel_user= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
 	$access_url_id = api_get_current_access_url_id();
 	if ($access_url_id != -1) {

+ 42 - 14
main/admin/system_announcements.php

@@ -40,10 +40,10 @@ if (isset($_GET['action'])) {
     $interbreadcrumb[] = array ("url" => "system_announcements.php", "name" => get_lang('SystemAnnouncements'));
     if ($_GET['action'] == 'add') {
         $interbreadcrumb[] = array ("url" => '#', "name" => get_lang('AddAnnouncement'));
-    } 
+    }
     if ($_GET['action'] == 'edit') {
         $interbreadcrumb[] = array ("url" => '#', "name" => get_lang('Edit'));
-    } 
+    }
 } else {
     $tool_name = get_lang('SystemAnnouncements');
 }
@@ -82,7 +82,7 @@ switch($action) {
         SystemAnnouncementManager :: delete_announcement($_GET['id']);
         Display :: display_confirmation_message(get_lang('AnnouncementDeleted'));
         break;
-    
+
     case 'delete_selected':
         foreach($_POST['id'] as $index => $id) {
             SystemAnnouncementManager :: delete_announcement($id);
@@ -141,13 +141,13 @@ if ($action_todo) {
     }
     $form->add_timewindow('start','end',get_lang('StartTimeWindow'),get_lang('EndTimeWindow'));
     $group = array();
-    
+
     $group[]= $form->createElement('checkbox', 'visible_teacher', null, get_lang('Teacher'));
     $group[]= $form->createElement('checkbox', 'visible_student', null, get_lang('Student'));
     $group[]= $form->createElement('checkbox', 'visible_guest', null, get_lang('Guest'));
-    
+
     $form->addGroup($group, null, get_lang('Visible'), '');
-    
+
     $form->addElement('hidden', 'id');
 
     $group_list = GroupPortalManager::get_groups_list();
@@ -155,7 +155,7 @@ if ($action_todo) {
 	$form->addElement('select', 'group',get_lang('AnnouncementForGroup'),$group_list);
     $values['group'] = isset($values['group']) ? $values['group'] : '0';
 
-    $form->addElement('checkbox', 'send_mail', null, get_lang('SendMail'));    
+    $form->addElement('checkbox', 'send_mail', null, get_lang('SendMail'));
 
     if (isset($_REQUEST['action']) && $_REQUEST['action']=='add') {
         $form->addElement('checkbox', 'add_to_calendar', null, get_lang('AddToCalendar'));
@@ -169,6 +169,8 @@ if ($action_todo) {
         $form->addElement('hidden', 'action','edit');
     }
 
+    $form->addElement('checkbox', 'send_email_test', null, get_lang('SendOnlyAnEmailToMySelfToTest'));
+
     $form->addElement('style_submit_button', 'submit', $text,'class="'.$class.'"');
     if (api_get_setting('wcag_anysurfer_public_pages') == 'true') {
         $values['content'] = WCAG_Rendering::HTML_to_text($values['content']);
@@ -189,12 +191,25 @@ if ($action_todo) {
             $values['lang'] = null;
         }
         if (api_get_setting('wcag_anysurfer_public_pages') == 'true') {
-            $values['content'] = WCAG_Rendering::text_to_HTML($values['content']);
+            //$values['content'] = WCAG_Rendering::text_to_HTML($values['content']);
         }
         switch ($values['action']) {
             case 'add':
-                $announcement_id = SystemAnnouncementManager::add_announcement($values['title'],$values['content'],$values['start'],$values['end'],$values['visible_teacher'],$values['visible_student'],$values['visible_guest'], $values['lang'],$values['send_mail'],  $values['add_to_calendar']);
-                if ($announcement_id !== false )  {
+                $announcement_id = SystemAnnouncementManager::add_announcement(
+                    $values['title'],
+                    $values['content'],
+                    $values['start'],
+                    $values['end'],
+                    $values['visible_teacher'],
+                    $values['visible_student'],
+                    $values['visible_guest'],
+                    $values['lang'],
+                    $values['send_mail'],
+                    $values['add_to_calendar'],
+                    $values['send_email_test']
+                );
+
+                if ($announcement_id !== false)  {
                     SystemAnnouncementManager::announcement_for_groups($announcement_id, array($values['group']));
                     Display :: display_confirmation_message(get_lang('AnnouncementAdded'));
                 } else {
@@ -203,7 +218,20 @@ if ($action_todo) {
                 }
                 break;
             case 'edit':
-                if (SystemAnnouncementManager::update_announcement($values['id'], $values['title'], $values['content'], $values['start'], $values['end'], $values['visible_teacher'], $values['visible_student'], $values['visible_guest'], $values['lang'], $values['send_mail'])) {
+                if (SystemAnnouncementManager::update_announcement(
+                    $values['id'],
+                    $values['title'],
+                    $values['content'],
+                    $values['start'],
+                    $values['end'],
+                    $values['visible_teacher'],
+                    $values['visible_student'],
+                    $values['visible_guest'],
+                    $values['lang'],
+                    $values['send_mail'],
+                    $values['send_email_test']
+                )
+                ) {
                     SystemAnnouncementManager::announcement_for_groups($values['id'], array($values['group']));
                     Display :: display_confirmation_message(get_lang('AnnouncementUpdated'));
                 } else {
@@ -234,13 +262,13 @@ if ($show_announcement_list) {
         $row = array();
         $row[] = $announcement->id;
         $row[] = Display::return_icon(($announcement->visible ? 'accept.png' : 'exclamation.png'), ($announcement->visible ? get_lang('AnnouncementAvailable') : get_lang('AnnouncementNotAvailable')));
-        $row[] = $announcement->title;        
+        $row[] = $announcement->title;
         $row[] = api_convert_and_format_date($announcement->date_start);
         $row[] = api_convert_and_format_date($announcement->date_end);
         $row[] = "<a href=\"?id=".$announcement->id."&amp;person=".SystemAnnouncementManager::VISIBLE_TEACHER."&amp;action=". ($announcement->visible_teacher ? 'make_invisible' : 'make_visible')."\">".Display::return_icon(($announcement->visible_teacher  ? 'visible.gif' : 'invisible.gif'), get_lang('ShowOrHide'))."</a>";
         $row[] = "<a href=\"?id=".$announcement->id."&amp;person=".SystemAnnouncementManager::VISIBLE_STUDENT."&amp;action=". ($announcement->visible_student  ? 'make_invisible' : 'make_visible')."\">".Display::return_icon(($announcement->visible_student  ? 'visible.gif' : 'invisible.gif'), get_lang('ShowOrHide'))."</a>";
         $row[] = "<a href=\"?id=".$announcement->id."&amp;person=".SystemAnnouncementManager::VISIBLE_GUEST."&amp;action=". ($announcement->visible_guest ? 'make_invisible' : 'make_visible')."\">".Display::return_icon(($announcement->visible_guest  ? 'visible.gif' : 'invisible.gif'), get_lang('ShowOrHide'))."</a>";
-        
+
         $row[] = $announcement->lang;
         $row[] = "<a href=\"?action=edit&id=".$announcement->id."\">".Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL)."</a> <a href=\"?action=delete&id=".$announcement->id."\"  onclick=\"javascript:if(!confirm('".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"), ENT_QUOTES))."')) return false;\">".Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL)."</a>";
         $announcement_data[] = $row;
@@ -254,7 +282,7 @@ if ($show_announcement_list) {
     $table->set_header(5, get_lang('Teacher'));
     $table->set_header(6, get_lang('Student'));
     $table->set_header(7, get_lang('Guest'));
-    
+
     $table->set_header(8, get_lang('Language'));
     $table->set_header(9, get_lang('Modify'), false, 'width="50px"');
     $form_actions = array();

+ 17 - 9
main/admin/user_list.php

@@ -752,12 +752,21 @@ if (!empty($action)) {
 }
 
 // Create a search-box
-$form = new FormValidator('search_simple','get', '', '', array('class' => 'form-search'),false);
-$renderer =& $form->defaultRenderer();
+$form = new FormValidator('search_simple', 'get', '', '', array('class' => 'form-search'), false);
+$renderer = & $form->defaultRenderer();
 $renderer->setElementTemplate('<span>{element}</span> ');
-$form->addElement('text','keyword',get_lang('keyword'), 'size="25"');
-$form->addElement('style_submit_button', 'submit',get_lang('Search'),'class="btn"');
-$form->addElement('static','search_advanced_link',null,'<a href="javascript://" class = "advanced_parameters" onclick="display_advanced_search_form();"><span id="img_plus_and_minus">&nbsp;'.Display::return_icon('div_show.gif',get_lang('Show'),array('style'=>'vertical-align:middle')).' '.get_lang('AdvancedSearch').'</span></a>');
+$form->addElement('text','keyword', get_lang('keyword'), 'size="25"');
+$form->addElement('style_submit_button', 'submit', get_lang('Search'),'class="btn"');
+$form->addElement(
+    'static',
+    'search_advanced_link',
+    null,
+    '<a href="javascript://" class = "advanced_parameters" onclick="display_advanced_search_form();">
+        <span id="img_plus_and_minus">&nbsp;'.
+        Display::return_icon('div_show.gif', get_lang('Show'), array('style'=>'vertical-align:middle')).' '.get_lang('AdvancedSearch').'
+        </span>
+    </a>'
+);
 
 $actions  = '';
 if (api_is_platform_admin()) {
@@ -765,7 +774,7 @@ if (api_is_platform_admin()) {
 		 '<a href="'.api_get_path(WEB_CODE_PATH).'admin/user_add.php">'.Display::return_icon('new_user.png',get_lang('AddUsers'),'',ICON_SIZE_MEDIUM).'</a>'.
 		 '</span>';
 }
-$actions .=$form->return_form();
+$actions .= $form->return_form();
 
 if (isset ($_GET['keyword'])) {
 	$parameters = array ('keyword' => Security::remove_XSS($_GET['keyword']));
@@ -791,8 +800,8 @@ while ($row_admin = Database::fetch_row($res_admin)) {
 	$_admins_list[] = $row_admin[0];
 }
 
-// display advaced search form
-$form = new FormValidator('advanced_search','get');
+// Display Advanced search form.
+$form = new FormValidator('advanced_search', 'get');
 
 $form->addElement('html','<div id="advanced_search_form" style="display:none;">');
 $form->addElement('header', get_lang('AdvancedSearch'));
@@ -823,7 +832,6 @@ $status_options[DRH] = get_lang('Drh');
 $status_options[SESSIONADMIN] = get_lang('Administrator');
 $form->addElement('select','keyword_status',get_lang('Profile'),$status_options, array('style'=>'margin-left:17px'));
 $form->addElement('html', '</td></tr>');
-
 $form->addElement('html', '<tr><td>');
 $active_group = array();
 $active_group[] = $form->createElement('checkbox','keyword_active','', get_lang('Active'));

+ 2 - 2
main/admin/usergroups.php

@@ -18,7 +18,7 @@ api_protect_admin_script(true);
 $htmlHeadXtra[] = api_get_jqgrid_js();
 // setting breadcrumbs
 $interbreadcrumb[] = array('url' => 'index.php','name' => get_lang('PlatformAdmin'));
-$action = $_GET['action'];
+$action = isset($_GET['action']) ? $_GET['action'] : null;
 if ($action == 'add') {
     $interbreadcrumb[] = array('url' => 'usergroups.php','name' => get_lang('Classes'));
     $interbreadcrumb[] = array('url' => '#','name' => get_lang('Add'));
@@ -30,7 +30,7 @@ if ($action == 'add') {
 }
 
 // The header.
-Display::display_header($tool_name);
+Display::display_header();
 
 // Tool name
 if (isset($_GET['action']) && $_GET['action'] == 'add') {

+ 54 - 26
main/announcements/announcement_email.class.php

@@ -1,14 +1,16 @@
 <?php
-
+/* For licensing terms, see /license.txt */
 /**
  * Announcement Email
  *
- * @license see /license.txt
  * @author Laurent Opprecht <laurent@opprecht.info> for the Univesity of Geneva
  * @author Julio Montoya <gugli100@gmail.com> Adding session support
  */
 class AnnouncementEmail
 {
+    protected $course = null;
+    protected $announcement = null;
+    public $session_id = null;
 
     /**
      *
@@ -17,20 +19,22 @@ class AnnouncementEmail
      *
      * @return AnnouncementEmail
      */
-    public static function create($course, $announcement) {
+    public static function create($course, $announcement)
+    {
         return new self($course, $announcement);
     }
 
-    protected $course = null;
-    protected $announcement = null;
-    public $session_id = null;
-
-    function __construct($course, $announcement) {
+    /**
+     * @param int $course
+     * @param int $announcement
+     */
+    public function __construct($course, $announcement)
+    {
         if (empty($course)) {
             $course = api_get_course_int_id();
             $course = CourseManager::get_course_information_by_id($course);
         } else if (is_numeric($course)) {
-            $course = CourseManager::get_course_information_by_id(intval($course));
+            $course = CourseManager::get_course_information_by_id($course);
         }
         $this->course = $course;
         $this->session_id = api_get_session_id();
@@ -47,9 +51,11 @@ class AnnouncementEmail
      * @param string $key
      * @return array
      */
-    public function course($key = '') {
+    public function course($key = '')
+    {
         $result = $key ? $this->course[$key] : $this->course;
         $result = $key == 'id' ? intval($result) : $result;
+
         return $result;
     }
 
@@ -59,9 +65,11 @@ class AnnouncementEmail
      * @param string $key
      * @return array
      */
-    public function announcement($key = '') {
+    public function announcement($key = '')
+    {
         $result = $key ? $this->announcement[$key] : $this->announcement;
         $result = $key == 'id' ? intval($result) : $result;
+
         return $result;
     }
 
@@ -71,7 +79,8 @@ class AnnouncementEmail
      *
      * @return array
      */
-    public function all_users() {
+    public function all_users()
+    {
         $course_code = $this->course('code');
         if (empty($this->session_id)) {
             $group_id = api_get_group_id();
@@ -88,6 +97,7 @@ class AnnouncementEmail
         } else {
             $user_list = CourseManager::get_user_list_from_course_code($course_code, $this->session_id);
         }
+
         return $user_list;
     }
 
@@ -96,7 +106,8 @@ class AnnouncementEmail
      *
      * @return array Array of users and groups to whom the element has been sent
      */
-    public function sent_to_info() {
+    public function sent_to_info()
+    {
         $result = array();
         $result['groups'] = array();
         $result['users'] = array();
@@ -107,7 +118,13 @@ class AnnouncementEmail
         $id = $this->announcement('id');
         $course_id = $this->course('id');
 
-        $sql = "SELECT to_group_id, to_user_id FROM $tbl_item_property WHERE c_id = $course_id AND tool = '$tool' AND ref = $id AND id_session = {$this->session_id} ";
+        $sql = "SELECT to_group_id, to_user_id
+                FROM $tbl_item_property
+                WHERE
+                    c_id = $course_id AND
+                    tool = '$tool' AND
+                    ref = $id AND
+                    id_session = {$this->session_id} ";
         $rs = Database::query($sql);
 
         while ($row = Database::fetch_array($rs, 'ASSOC')) {
@@ -133,7 +150,8 @@ class AnnouncementEmail
      *
      * @return array
      */
-    public function sent_to() {
+    public function sent_to()
+    {
         $sent_to = $this->sent_to_info();
         $users = $sent_to['users'];
         $users = $users ? $users : array();
@@ -182,7 +200,8 @@ class AnnouncementEmail
      *
      * @return string
      */
-    public function subject() {
+    public function subject()
+    {
         $result = $this->course('title').' - '.$this->announcement('title');
         $result = stripslashes($result);
         return $result;
@@ -190,16 +209,17 @@ class AnnouncementEmail
 
     /**
      * Email message
-     *
+     * @param int $receiverUserId
      * @return string
      */
-    public function message() {
+    public function message($receiverUserId)
+    {
         $title = $this->announcement('title');
         $title = stripslashes($title);
 
         $content = $this->announcement('content');
         $content = stripslashes($content);
-        $content = AnnouncementManager::parseEmailContent($content, $this->course('code'));
+        $content = AnnouncementManager::parse_content($receiverUserId, $content, $this->course('code'));
 
         $user_email = $this->sender('mail');
         $course_param = api_get_cidreq();
@@ -207,7 +227,7 @@ class AnnouncementEmail
 
         $result = "<div>$content</div>";
 
-        //Adding attachment
+        // Adding attachment
         $attachment = $this->attachement();
         if (!empty($attachment)) {
             $result .= '<br />';
@@ -226,7 +246,8 @@ class AnnouncementEmail
      *
      * @return array
      */
-    public function attachement() {
+    public function attachement()
+    {
         $result = array();
         $tbl_announcement_attachment = Database::get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT);
         $id = $this->announcement('id');
@@ -247,16 +268,22 @@ class AnnouncementEmail
     /**
      * Send emails to users.
      */
-    public function send() {
+    public function send()
+    {
         $sender = $this->sender();
         $subject = $this->subject();
-        $message = $this->message();
 
         // Send email one by one to avoid antispam
         $users = $this->sent_to();
 
         foreach ($users as $user) {
-            MessageManager::send_message_simple($user['user_id'], $subject, $message, $sender['user_id']);
+            $message = $this->message($user['user_id']);
+            MessageManager::send_message_simple(
+                $user['user_id'],
+                $subject,
+                $message,
+                $sender['user_id']
+            );
         }
         $this->log_mail_sent();
     }
@@ -264,7 +291,8 @@ class AnnouncementEmail
     /**
      * Store that emails where sent
      */
-    public function log_mail_sent() {
+    public function log_mail_sent()
+    {
         $id = $this->announcement('id');
         $course_id = $this->course('id');
 
@@ -272,4 +300,4 @@ class AnnouncementEmail
         $sql = "UPDATE $tbl_announcement SET email_sent=1 WHERE c_id = $course_id AND id=$id AND session_id = {$this->session_id} ";
         Database::query($sql);
     }
-}
+}

+ 93 - 140
main/announcements/announcements.inc.php

@@ -1,5 +1,4 @@
 <?php
-
 /* For licensing terms, see /license.txt */
 /**
  * Include file with functions for the announcements module.
@@ -11,23 +10,39 @@
  * @author jmontoya
  *
  */
-class AnnouncementManager {
+class AnnouncementManager
+{
 
     public function __construct()
     {
-
     }
 
+    /**
+     * @return array
+     */
     public static function get_tags()
     {
-        return array('((user_name))', '((user_firstname))', '((user_lastname))', '((teacher_name))', '((teacher_email))', '((course_title))', '((course_link))');
+        return array(
+            '((user_name))',
+            '((user_firstname))',
+            '((user_lastname))',
+            '((teacher_name))',
+            '((teacher_email))',
+            '((course_title))',
+            '((course_link))'
+        );
     }
 
-    public static function parse_content($content, $course_code)
+    /**
+     * @param string $content
+     * @param string $course_code
+     * @return mixed
+     */
+    public static function parse_content($userId, $content, $course_code)
     {
-        $reader_info = api_get_user_info(api_get_user_id());
-        $course_info = api_get_course_info($course_code);
-        $teacher_list = CourseManager::get_teacher_list_from_course_code($course_info['code']);
+        $readerInfo = api_get_user_info($userId);
+        $courseInfo = api_get_course_info($course_code);
+        $teacher_list = CourseManager::get_teacher_list_from_course_code($courseInfo['code']);
 
         $teacher_name = '';
         if (!empty($teacher_list)) {
@@ -37,51 +52,17 @@ class AnnouncementManager {
                 break;
             }
         }
-        $course_link = api_get_course_url();
-        
-        $data['user_name'] = $reader_info['username'];
-        $data['user_firstname'] = $reader_info['firstname'];
-        $data['user_lastname'] = $reader_info['lastname'];
+        $courseLink = api_get_course_url();
+        $data['user_name'] = $readerInfo['username'];
+        $data['user_firstname'] = $readerInfo['firstname'];
+        $data['user_lastname'] = $readerInfo['lastname'];
         $data['teacher_name'] = $teacher_name;
         $data['teacher_email'] = $teacher_email;
-        $data['course_title'] = $course_info['name'];
-        $data['course_link'] = Display::url($course_link, $course_link);
-       
-        $content = str_replace(self::get_tags(), $data, $content);
-        return $content;
-    }
-    
-    /**
-     * parse announcement content when sending an email. It parses only teacher data
-     * @author  yoselyn castillo
-     * @param	string content
-     * @param	int course code
-     * @return	string with the parsed content
-     */
-    
-     public static function parseEmailContent($content, $courseCode)
-     {
-        $readerInfo = api_get_user_info(api_get_user_id());
-        $courseInfo = api_get_course_info($courseCode);
-        $teacherList = CourseManager::get_teacher_list_from_course_code($courseInfo['code']);
-        
-        $teacherName = '';
-        if (!empty($teacherList)) {
-            foreach ($teacherList as $teacherData) {
-                $teacherName = api_get_person_name($teacherData['firstname'], $teacherData['lastname']);
-                $teacherEmail = $teacherData['email'];
-                break;
-            }
-        }
-        $data['user_name'] = '((user_name))';
-        $data['user_firstname'] = '((user_firstname))';
-        $data['user_lastname'] = '((user_lastname))';
-        $data['teacher_name'] = $teacherName;
-        $data['teacher_email'] = $teacherEmail;
         $data['course_title'] = $courseInfo['name'];
-        $data['course_link'] = Display::url($course_link, $course_link);       
+        $data['course_link'] = Display::url($courseLink, $courseLink);
 
         $content = str_replace(self::get_tags(), $data, $content);
+
         return $content;
     }
 
@@ -156,25 +137,27 @@ class AnnouncementManager {
     public static function delete_all_announcements($_course)
     {
         $announcements = self::get_all_annoucement_by_course($_course, api_get_session_id());
-
-
-        foreach ($announcements as $annon) {
-            api_item_property_update($_course, TOOL_ANNOUNCEMENT, $annon['id'], 'delete', api_get_user_id());
+        if (!empty($announcements)) {
+            foreach ($announcements as $annon) {
+                api_item_property_update($_course, TOOL_ANNOUNCEMENT, $annon['id'], 'delete', api_get_user_id());
+            }
         }
     }
 
     /**
      * Displays one specific announcement
-     * @param $announcement_id, the id of the announcement you want to display
+     * @param int $announcement_id, the id of the announcement you want to display
      */
     public static function display_announcement($announcement_id)
     {
         if ($announcement_id != strval(intval($announcement_id))) {
             return false;
-        } // potencial sql injection
+        }
+
         global $charset;
         $tbl_announcement = Database::get_course_table(TABLE_ANNOUNCEMENT);
         $tbl_item_property = Database::get_course_table(TABLE_ITEM_PROPERTY);
+
         $course_id = api_get_course_int_id();
 
         if (api_is_allowed_to_edit(false, true) || (api_get_course_setting('allow_user_edit_announcement') && !api_is_anonymous())) {
@@ -247,7 +230,7 @@ class AnnouncementManager {
                 echo "<tr><th style='text-align:right'>$modify_icons</th></tr>";
             }
 
-            $content = self::parse_content($content, api_get_course_id());
+            $content = self::parse_content($result['to_user_id'], $content, api_get_course_id());
 
             echo "<tr><td>$content</td></tr>";
 
@@ -259,11 +242,8 @@ class AnnouncementManager {
                 $sent_to_icon = Display::return_icon('group.gif', get_lang('AnnounceSentToUserSelection'));
             }
             $sent_to = self::sent_to('announcement', $announcement_id);
-
             $sent_to_form = self::sent_to_form($sent_to);
-
             echo Display::tag('td', get_lang('SentTo') . ' : ' . $sent_to_form, array('class' => 'announcements_datum'));
-
             $attachment_list = self::get_attachment($announcement_id);
 
             if (count($attachment_list) > 0) {
@@ -286,6 +266,9 @@ class AnnouncementManager {
         }
     }
 
+    /**
+     * @return int
+     */
     public static function get_last_announcement_order()
     {
         $tbl_announcement = Database::get_course_table(TABLE_ANNOUNCEMENT);
@@ -313,7 +296,7 @@ class AnnouncementManager {
      */
     public static function add_announcement($emailTitle, $newContent, $sent_to, $file = array(), $file_comment = null, $end_date = null)
     {
-        global $_course;
+        $_course = api_get_course_info();
         $tbl_announcement = Database::get_course_table(TABLE_ANNOUNCEMENT);
 
         // filter data
@@ -337,51 +320,57 @@ class AnnouncementManager {
 				title 			= '$emailTitle',
                 end_date        = '$end_date',
 				display_order 	= '$order',
-				session_id		= " . api_get_session_id();
+				session_id		= ".api_get_session_id();
         $result = Database::query($sql);
+
         if ($result === false) {
             return false;
         } else {
-            //Store the attach file
+            // Store the attach file.
             $last_id = Database::insert_id();
             if (!empty($file)) {
                 self::add_announcement_attachment_file($last_id, $file_comment, $_FILES['user_upload']);
             }
 
             // store in item_property (first the groups, then the users
-            if (!is_null($sent_to)) {
-                // !is_null($sent_to): when no user is selected we send it to everyone
+            if (empty($sent_to) || !empty($sent_to) && isset($sent_to[0]) && $sent_to[0] == 'everyone') {
+                // The message is sent to EVERYONE, so we set the group to 0
+                api_item_property_update($_course, TOOL_ANNOUNCEMENT, $last_id, "AnnouncementAdded", api_get_user_id(), '0');
+            } else {
                 $send_to = self::separate_users_groups($sent_to);
-                // storing the selected groups
+
+                // Storing the selected groups
                 if (is_array($send_to['groups'])) {
                     foreach ($send_to['groups'] as $group) {
                         api_item_property_update($_course, TOOL_ANNOUNCEMENT, $last_id, "AnnouncementAdded", api_get_user_id(), $group);
                     }
                 }
 
-                // storing the selected users
+                // Storing the selected users
                 if (is_array($send_to['users'])) {
                     foreach ($send_to['users'] as $user) {
                         api_item_property_update($_course, TOOL_ANNOUNCEMENT, $last_id, "AnnouncementAdded", api_get_user_id(), '', $user);
                     }
                 }
-            } else {
-                // the message is sent to everyone, so we set the group to 0
-                api_item_property_update($_course, TOOL_ANNOUNCEMENT, $last_id, "AnnouncementAdded", api_get_user_id(), '0');
             }
             return $last_id;
         }
     }
 
-    /*
-      STORE ANNOUNCEMENT  GROUP ITEM
+    /**
+     * @param $emailTitle
+     * @param $newContent
+     * @param $to
+     * @param $to_users
+     * @param array $file
+     * @param string $file_comment
+     * @return bool|int
      */
-
     public static function add_group_announcement($emailTitle, $newContent, $to, $to_users, $file = array(), $file_comment = '')
     {
-        global $_course;
+        $_course = api_get_course_info();
 
-        // database definitions
+        // Database definitions
         $tbl_announcement = Database::get_course_table(TABLE_ANNOUNCEMENT);
 
         $emailTitle = Database::escape_string($emailTitle);
@@ -400,6 +389,7 @@ class AnnouncementManager {
                 display_order 	= '$order',
                 session_id		= " . api_get_session_id();
         $result = Database::query($sql);
+
         if ($result === false) {
             return false;
         }
@@ -407,7 +397,7 @@ class AnnouncementManager {
         //store the attach file
         $last_id = Database::insert_id();
         if (!empty($file)) {
-            $save_attachment = self::add_announcement_attachment_file($last_id, $file_comment, $file);
+            self::add_announcement_attachment_file($last_id, $file_comment, $file);
         }
 
         // store in item_property (first the groups, then the users
@@ -432,10 +422,6 @@ class AnnouncementManager {
         return $last_id;
     }
 
-    /*
-      EDIT ANNOUNCEMENT
-     */
-
     /**
      * This function stores the announcement item in the announcement table
      * and updates the item_property table
@@ -446,7 +432,6 @@ class AnnouncementManager {
      * @param array 	users that will receive the announcement
      * @param mixed 	attachment
      * @param string file comment
-     *
      */
     public static function edit_announcement($id, $emailTitle, $newContent, $to, $file = array(), $file_comment = '')
     {
@@ -462,7 +447,7 @@ class AnnouncementManager {
 
         // store the modifications in the table announcement
         $sql = "UPDATE $tbl_announcement SET content = '$newContent', title = '$emailTitle' WHERE c_id = $course_id AND id='$id'";
-        $result = Database::query($sql);
+        Database::query($sql);
 
         // save attachment file
         $row_attach = self::get_attachment($id);
@@ -478,7 +463,7 @@ class AnnouncementManager {
 
         // we remove everything from item_property for this
         $sql_delete = "DELETE FROM $tbl_item_property WHERE c_id = $course_id AND ref='$id' AND tool='announcement'";
-        $result = Database::query($sql_delete);
+        Database::query($sql_delete);
 
         // store in item_property (first the groups, then the users
 
@@ -505,10 +490,10 @@ class AnnouncementManager {
         }
     }
 
-    /*
-      MAIL FUNCTIONS
+    /**
+     * @param int $insert_id
+     * @return bool
      */
-
     public static function update_mail_sent($insert_id)
     {
         $tbl_announcement = Database::get_course_table(TABLE_ANNOUNCEMENT);
@@ -547,7 +532,10 @@ class AnnouncementManager {
 						toolitemproperties.c_id = $course_id AND
 						announcement.id = toolitemproperties.ref AND
 						toolitemproperties.tool='announcement' AND
-						(toolitemproperties.insert_user_id='$user_id' AND (toolitemproperties.to_group_id='0' OR toolitemproperties.to_group_id is null))
+						(
+						  toolitemproperties.insert_user_id='$user_id' AND
+						  (toolitemproperties.to_group_id='0' OR toolitemproperties.to_group_id is null)
+						)
 						AND toolitemproperties.visibility='1'
 						AND announcement.session_id  = 0
 					ORDER BY display_order DESC";
@@ -571,12 +559,9 @@ class AnnouncementManager {
         return false;
     }
 
-    /*
-      SHOW_TO_FORM
-     */
-
     /**
-     * this function shows the form for sending a message to a specific group or user.
+     * This function shows the form for sending a message to a specific group or user.
+     * @param $to_already_selected
      */
     public static function show_to_form($to_already_selected)
     {
@@ -622,9 +607,11 @@ class AnnouncementManager {
         echo "<tr>";
         echo "<td>";
         echo "<select name=\"not_selected_form[]\" size=5 style=\"width:200px\" multiple>";
-        $group_users = GroupManager::get_subscribed_users($group_id);
+        $group_users = GroupManager::getStudentsAndTutors($group_id);
         foreach ($group_users as $user) {
-            echo '<option value="' . $user['user_id'] . '" title="' . sprintf(get_lang('LoginX'), $user['username']) . '" >' . api_get_person_name($user['firstname'], $user['lastname']) . '</option>';
+            echo '<option value="' . $user['user_id'] . '" title="' . sprintf(get_lang('LoginX'), $user['username']) . '" >' .
+                api_get_person_name($user['firstname'], $user['lastname']) .
+                '</option>';
         }
         echo '</select>';
         echo "</td>";
@@ -645,10 +632,6 @@ class AnnouncementManager {
         echo "</table>";
     }
 
-    /*
-      CONSTRUCT_NOT_SELECT_SELECT_FORM
-     */
-
     /**
      * this function shows the form for sending a message to a specific group or user.
      */
@@ -686,10 +669,6 @@ class AnnouncementManager {
         echo "</select>";
     }
 
-    /*
-      CONSTRUCT_SELECTED_SELECT_FORM
-     */
-
     /**
      * this function shows the form for sending a message to a specific group or user.
      */
@@ -816,11 +795,6 @@ class AnnouncementManager {
         return $new_group_list;
     }
 
-    /*
-     *
-      LOAD_EDIT_USERS
-     */
-
     /**
      * This tools loads all the users and all the groups who have received
      * a specific item (in this case an announcement item)
@@ -853,10 +827,6 @@ class AnnouncementManager {
         return $to;
     }
 
-    /*
-      USER_GROUP_FILTER_JAVASCRIPT
-     */
-
     /**
      * returns the javascript for setting a filter
      * this goes into the $htmlHeadXtra[] array
@@ -874,10 +844,6 @@ class AnnouncementManager {
 		</script>";
     }
 
-    /*
-      TO_JAVASCRIPT
-     */
-
     /**
      * returns all the javascript that is required for easily
      * setting the target people/groups
@@ -902,10 +868,6 @@ class AnnouncementManager {
         return $result;
     }
 
-    /*
-      SENT_TO_FORM
-     */
-
     /**
      * constructs the form to display all the groups and users the message has been sent to
      * input: 	$sent_to_array is a 2 dimensional array containing the groups and the users
@@ -976,19 +938,17 @@ class AnnouncementManager {
         }
     }
 
-    /*
-      SEPARATE_USERS_GROUPS
-     */
-
     /**
      * This function separates the users from the groups
-     * users have a value USER:XXX (with XXX the dokeos id
-     * groups have a value GROUP:YYY (with YYY the group id)
+     * users have a value USER:XXX (with XXX the groups id have a value
+     *  GROUP:YYY (with YYY the group id)
      * @param    array   Array of strings that define the type and id of each destination
      * @return   array   Array of groups and users (each an array of IDs)
      */
     public static function separate_users_groups($to)
     {
+        $grouplist = array();
+        $userlist = array();
         foreach ($to as $to_item) {
             list($type, $id) = explode(':', $to_item);
             switch ($type) {
@@ -1006,10 +966,6 @@ class AnnouncementManager {
         return $send_to;
     }
 
-    /*
-      SENT_TO()
-     */
-
     /**
      * Returns all the users and all the groups a specific announcement item
      * has been sent to
@@ -1019,7 +975,6 @@ class AnnouncementManager {
      */
     public static function sent_to($tool, $id)
     {
-        global $_course;
         global $tbl_item_property;
 
         $tool = Database::escape_string($tool);
@@ -1029,7 +984,9 @@ class AnnouncementManager {
         $sent_to = array();
         $course_id = api_get_course_int_id();
 
-        $sql = "SELECT to_group_id, to_user_id FROM $tbl_item_property WHERE c_id = $course_id AND tool = '$tool' AND ref=" . $id;
+        $sql = "SELECT to_group_id, to_user_id
+                FROM $tbl_item_property
+                WHERE c_id = $course_id AND tool = '$tool' AND ref=" . $id;
         $result = Database::query($sql);
 
         while ($row = Database::fetch_array($result)) {
@@ -1052,8 +1009,6 @@ class AnnouncementManager {
         return $sent_to;
     }
 
-    /* 		ATTACHMENT FUNCTIONS	 */
-
     /**
      * Show a list with all the attachments according to the post's id
      * @param int announcement id
@@ -1085,7 +1040,7 @@ class AnnouncementManager {
      */
     public static function add_announcement_attachment_file($announcement_id, $file_comment, $file)
     {
-        global $_course;
+        $_course = api_get_course_info();
         $tbl_announcement_attachment = Database::get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT);
         $return = 0;
         $announcement_id = intval($announcement_id);
@@ -1181,17 +1136,15 @@ class AnnouncementManager {
         $id = intval($id);
         $course_id = api_get_course_int_id();
         $sql = "DELETE FROM $tbl_announcement_attachment WHERE c_id = $course_id AND id = $id";
-        $result = Database::query($sql);
-        // update item_property
-        //api_item_property_update($_course, 'announcement_attachment',  $id,'AnnouncementAttachmentDeleted', api_get_user_id());
+        Database::query($sql);
     }
 
-    public static function send_email($annoucement_id)
+    /**
+     * @param int $id
+     */
+    public static function send_email($id)
     {
-        $email = AnnouncementEmail::create(null, $annoucement_id);
+        $email = AnnouncementEmail::create(null, $id);
         $email->send();
     }
-
 }
-
-//end class

+ 2 - 2
main/announcements/announcements.php

@@ -109,7 +109,7 @@ if (!empty($_POST['To']) and ($select_groupusers_status=="show")) {
 	$_SESSION['select_groupusers'] = "hide";
 }
 
-$origin = empty($_GET['origin']) ? '' : Security::remove_XSS($_GET['origin']);
+$origin = isset($_GET['origin']) ? Security::remove_XSS($_GET['origin']) : null;
 
 /* 	Action handling */
 
@@ -1063,4 +1063,4 @@ if (isset($_GET['action']) && $_GET['action'] == 'view') {
 if (empty($_GET['origin']) or $_GET['origin'] !== 'learnpath') {
 	//we are not in learnpath tool
 	Display::display_footer();
-}
+}

+ 1 - 1
main/attendance/attendance_list.php

@@ -34,7 +34,7 @@ $table->set_header(3, get_lang('CountDoneAttendance'), true, array('style'=>'wid
 
 if (api_is_allowed_to_edit(null, true)) {
 	$table->set_header(4, get_lang('Actions'), false, array('style'=>'text-align:center'));
-	$table->set_form_actions(array ('attendance_delete_select' => get_lang('DeleteAllAttendances')));	
+	$table->set_form_actions(array ('attendance_delete_select' => get_lang('DeleteAllSelectedAttendances')));	
 }
 
 if ($table->get_total_number_of_items() > 0) {

+ 6 - 6
main/calendar/agenda.inc.php

@@ -2306,13 +2306,13 @@ function show_add_form($id = '', $type = null)
         $repeat = !empty($_POST['repeat']) ? true : false;
     }
 
-    $default_no_empty_end_date = 0;
     $course_info = null;
 
+    $agendaObj = new Agenda();
+
     // if the id is set then we are editing an agenda item
     if (!empty($id)) {
         $course_info = api_get_course_info();
-        $agendaObj = new Agenda();
         if (!empty($course_info)) {
             $agendaObj->set_course($course_info);
             $agendaObj->type = 'course';
@@ -2755,8 +2755,8 @@ function show_add_form($id = '', $type = null)
                 </div>
                 <label class="control-label">'.
                     get_lang('Comment').'
-                </label>  
-                <div class="controls">  
+                </label>
+                <div class="controls">
                     <textarea name="file_comment" type="textarea"></textarea>
                 </div>
              </div>';
@@ -4102,9 +4102,9 @@ function show_add_form($id = '', $type = null)
         $sql = "INSERT INTO ".$t_agenda." (c_id, title,content, start_date, end_date".(!empty($parent_id) ? ',parent_event_id' : '').", session_id)
             VALUES($course_id, '".$title."','".$content."', '".$start_date."','".$end_date."'".(!empty($parent_id) ? ','.((int) $parent_id) : '').", '".$id_session."')";
 
-        $result = Database::query($sql);
+        Database::query($sql);
         $last_id = Database::insert_id();
-        
+
         // add a attachment file in agenda
 
         add_agenda_attachment_file($file_comment, $last_id);

+ 219 - 12
main/calendar/agenda.lib.php

@@ -67,7 +67,8 @@ class Agenda
         $title,
         $content,
         $users_to_send = array(),
-        $add_as_announcement = false
+        $add_as_announcement = false,
+        $parentEventId = null
     ) {
         $start = api_get_utc_datetime($start);
         $end = api_get_utc_datetime($end);
@@ -94,6 +95,10 @@ class Agenda
                 $attributes['session_id'] = api_get_session_id();
                 $attributes['c_id'] = $this->course['real_id'];
 
+                if (!empty($parentEventId)) {
+                    $attributes['parent_event_id'] = $parentEventId;
+                }
+
                 //simple course event
                 $id = Database::insert($this->tbl_course_agenda, $attributes);
 
@@ -141,6 +146,158 @@ class Agenda
         return $id;
     }
 
+    /**
+     * @param int $eventId
+     * @param string $type
+     * @param string $end date time
+     * @param array $sentTo
+     * @return bool
+     */
+    public function addRepeatedItem($eventId, $type, $end, $sentTo = array())
+    {
+        $t_agenda = Database::get_course_table(TABLE_AGENDA);
+        $t_agenda_r = Database::get_course_table(TABLE_AGENDA_REPEAT);
+        $course_id = $this->course['real_id'];
+
+        $sql = 'SELECT title, content, start_date as sd, end_date as ed
+                FROM '.$t_agenda.'
+                WHERE c_id = '.$course_id.' AND id ="'.intval($eventId).'" ';
+        $res = Database::query($sql);
+
+        if (Database::num_rows($res) !== 1) {
+            return false;
+        }
+
+        $row = Database::fetch_array($res);
+        $orig_start = api_strtotime(api_get_local_time($row['sd']));
+        $orig_end = api_strtotime(api_get_local_time($row['ed']));
+
+        $diff = $orig_end - $orig_start;
+        $orig_title = $row['title'];
+        $orig_content = $row['content'];
+        $now = time();
+        $type = Database::escape_string($type);
+        $end = intval($end);
+
+        if (1 <= $end && $end <= 500) {
+            //we assume that, with this type of value, the user actually gives a count of repetitions
+            //and that he wants us to calculate the end date with that (particularly in case of imports from ical)
+            switch ($type) {
+                case 'daily':
+                    $end = $orig_start + (86400 * $end);
+                    break;
+                case 'weekly':
+                    $end = self::add_week($orig_start, $end);
+                    break;
+                case 'monthlyByDate':
+                    $end = self::add_month($orig_start, $end);
+                    break;
+                case 'monthlyByDay':
+                    //TODO
+                    break;
+                case 'monthlyByDayR':
+                    //TODO
+                    break;
+                case 'yearly':
+                    $end = self::add_year($orig_start, $end);
+                    break;
+            }
+        }
+
+        $typeList = array('daily', 'weekly', 'monthlyByDate', 'monthlyByDay', 'monthlyByDayR', 'yearly');
+        if ($end > $now && in_array($type, $typeList)) {
+            $sql = "INSERT INTO $t_agenda_r (c_id, cal_id, cal_type, cal_end)
+                    VALUES ($course_id, '$eventId', '$type', '$end')";
+            Database::query($sql);
+
+            switch ($type) {
+                case 'daily':
+                    for ($i = $orig_start + 86400; ($i <= $end); $i += 86400) {
+                        $start = date('Y-m-d H:i:s', $i);
+                        $end = date('Y-m-d H:i:s', $i + $diff);
+                        self::add_event(
+                            $start,
+                            $end,
+                            false,
+                            null,
+                            $orig_title,
+                            $orig_content,
+                            $sentTo,
+                            false,
+                            $eventId
+                        );
+                    }
+                    break;
+                case 'weekly':
+                    for ($i = $orig_start + 604800; ($i <= $end); $i += 604800) {
+                        //agenda_add_item($this->course, $orig_title, $orig_content, date('Y-m-d H:i:s', $i), date('Y-m-d H:i:s', $i + $diff), $orig_dest, $orig_id, $file_comment);
+                        $start = date('Y-m-d H:i:s', $i);
+                        $end = date('Y-m-d H:i:s', $i + $diff);
+                        self::add_event(
+                            $start,
+                            $end,
+                            false,
+                            null,
+                            $orig_title,
+                            $orig_content,
+                            $sentTo,
+                            false,
+                            $eventId
+                        );
+                    }
+                    break;
+                case 'monthlyByDate':
+                    $next_start = add_month($orig_start);
+                    while ($next_start <= $end) {
+                        $start = date('Y-m-d H:i:s', $next_start);
+                        $end = date('Y-m-d H:i:s', $next_start + $diff);
+                        self::add_event(
+                            $start,
+                            $end,
+                            false,
+                            null,
+                            $orig_title,
+                            $orig_content,
+                            $sentTo,
+                            false,
+                            $eventId
+                        );
+
+                        //agenda_add_item($this->course, $orig_title, $orig_content, date('Y-m-d H:i:s', $next_start), date('Y-m-d H:i:s', $next_start + $diff), $orig_dest, $orig_id, $file_comment);
+                        $next_start = self::add_month($next_start);
+                    }
+                    break;
+                case 'monthlyByDay':
+                    //not yet implemented
+                    break;
+                case 'monthlyByDayR':
+                    //not yet implemented
+                    break;
+                case 'yearly':
+                    $next_start = add_year($orig_start);
+                    while ($next_start <= $end) {
+                        $start = date('Y-m-d H:i:s', $next_start);
+                        $end = date('Y-m-d H:i:s', $next_start + $diff);
+                        self::add_event(
+                            $start,
+                            $end,
+                            false,
+                            null,
+                            $orig_title,
+                            $orig_content,
+                            $sentTo,
+                            false,
+                            $eventId
+                        );
+                        //agenda_add_item($this->course, $orig_title, $orig_content, date('Y-m-d H:i:s', $next_start), date('Y-m-d H:i:s', $next_start + $diff), $orig_dest, $orig_id, $file_comment);
+                        $next_start = self::add_year($next_start);
+                    }
+                    break;
+            }
+        }
+        return true;
+    }
+
     /**
      * @param int $item_id
      * @param array $sent_to
@@ -151,22 +308,28 @@ class Agenda
         $table_agenda = Database::get_course_table(TABLE_AGENDA);
         $course_id = api_get_course_int_id();
 
-        //check params
+        // Check params
         if (empty($item_id) or $item_id != strval(intval($item_id))) {
             return -1;
         }
-        //get the agenda item
 
+        // Get the agenda item.
         $item_id = Database::escape_string($item_id);
         $sql = "SELECT * FROM $table_agenda WHERE c_id = $course_id AND id = ".$item_id;
         $res = Database::query($sql);
 
         if (Database::num_rows($res) > 0) {
             $row = Database::fetch_array($res, 'ASSOC');
-
-            //Sending announcement
+            // Sending announcement
             if (!empty($sent_to)) {
-                $id = AnnouncementManager::add_announcement($row['title'], $row['content'], $sent_to, null, null, $row['end_date']);
+                $id = AnnouncementManager::add_announcement(
+                    $row['title'],
+                    $row['content'],
+                    $sent_to,
+                    null,
+                    null,
+                    $row['end_date']
+                );
                 AnnouncementManager::send_email($id);
             }
             return $id;
@@ -591,9 +754,12 @@ class Agenda
                             ip.id_session = $session_id
                     ";
         }
-
+        $dateCondition = null;
         if (!empty($start)  && !empty($end)) {
-            $dateCondition = "((agenda.start_date >= '".$start."' OR agenda.start_date IS NULL) AND (agenda.end_date <= '".$end."' OR agenda.end_date IS NULL) AND )";
+            $dateCondition = "AND (
+                (agenda.start_date >= '".$start."' OR agenda.start_date IS NULL) AND
+                (agenda.end_date <= '".$end."' OR agenda.end_date IS NULL)
+            )";
         }
 
         $result = Database::query($sql);
@@ -606,7 +772,7 @@ class Agenda
                     WHERE   ip.tool         = '".TOOL_CALENDAR_EVENT."' AND
                             ref             = {$row['ref']} AND
                             ip.visibility   = '1' AND
-                            ip.c_id         = $course_id AND
+                            ip.c_id         = $course_id
                             $dateCondition";
                 $sent_to_result = Database::query($sql);
                 $user_to_array = array();
@@ -621,7 +787,6 @@ class Agenda
                 }
 
                 $event = array();
-
                 $event['id'] = 'course_'.$row['id'];
 
                 // To avoid doubles
@@ -630,9 +795,7 @@ class Agenda
                 }
 
                 $events_added[] = $row['id'];
-
                 $attachment = get_attachment($row['id'], $course_id);
-
                 $has_attachment = '';
 
                 if (!empty($attachment)) {
@@ -1022,4 +1185,48 @@ class Agenda
             api_item_property_update($courseInfo, TOOL_CALENDAR_EVENT, $id, "visible", $userId);
         }
     }
+
+
+    /**
+     * Adds x weeks to a UNIX timestamp
+     * @param   int     The timestamp
+     * @param   int     The number of weeks to add
+     * @return  int     The new timestamp
+     */
+    function add_week($timestamp,$num=1)
+    {
+        return $timestamp + $num*604800;
+    }
+
+    /**
+     * Adds x months to a UNIX timestamp
+     * @param   int     The timestamp
+     * @param   int     The number of years to add
+     * @return  int     The new timestamp
+     */
+    function add_month($timestamp,$num=1)
+    {
+        list($y, $m, $d, $h, $n, $s) = split('/',date('Y/m/d/h/i/s',$timestamp));
+        if($m+$num>12)
+        {
+            $y += floor($num/12);
+            $m += $num%12;
+        }
+        else
+        {
+            $m += $num;
+        }
+        return mktime($h, $n, $s, $m, $d, $y);
+    }
+    /**
+     * Adds x years to a UNIX timestamp
+     * @param   int     The timestamp
+     * @param   int     The number of years to add
+     * @return  int     The new timestamp
+     */
+    function add_year($timestamp,$num=1)
+    {
+        list($y, $m, $d, $h, $n, $s) = split('/',date('Y/m/d/h/i/s',$timestamp));
+        return mktime($h, $n, $s, $m, $d, $y+$num);
+    }
 }

+ 14 - 14
main/calendar/agenda.php

@@ -220,11 +220,15 @@ if (!api_is_allowed_to_edit(null, true) && $event_type == 'course') {
 }
 
 $course_info = api_get_course_info();
+$agenda = new Agenda();
 
 if (api_is_allowed_to_edit(false, true) OR
-    (api_get_course_setting('allow_user_edit_agenda') && !api_is_anonymous() && api_is_allowed_to_session_edit(false, true)) OR
-     GroupManager::user_has_access(api_get_user_id(), $group_id,  GroupManager::GROUP_TOOL_CALENDAR) && GroupManager::is_tutor_of_group(api_get_user_id(), $group_id)
-    ) {
+    (api_get_course_setting('allow_user_edit_agenda') &&
+    !api_is_anonymous() &&
+    api_is_allowed_to_session_edit(false, true)) OR
+    GroupManager::user_has_access(api_get_user_id(), $group_id,  GroupManager::GROUP_TOOL_CALENDAR) &&
+    GroupManager::is_tutor_of_group(api_get_user_id(), $group_id)
+) {
     switch ($action) {
         case 'add':
             if (isset($_POST['submit_event']) && $_POST['submit_event']) {
@@ -236,23 +240,19 @@ if (api_is_allowed_to_edit(false, true) OR
                 if ($_POST['empty_end_date'] == 'on') {
                     $event_stop = '0000-00-00 00:00:00';
                 }
-                $id = agenda_add_item($course_info, $safe_title, $_POST['content'], $event_start, $event_stop, $_POST['selected_form'], false, $safe_file_comment);
-                if (!empty($_POST['repeat'])) {
+                $agenda->type = 'course';
+                $sendEmail = isset($_POST['add_announcement']) ? true : false;
+                $eventId = $agenda->add_event($event_start, $event_stop, false, null, $safe_title, $_POST['content'], $_POST['selected_form'], $sendEmail);
+
+                if (!empty($_POST['repeat']) && !empty($eventId)) {
                     $end_y = intval($_POST['repeat_end_year']);
                     $end_m = intval($_POST['repeat_end_month']);
                     $end_d = intval($_POST['repeat_end_day']);
                     $end = mktime(23, 59, 59, $end_m, $end_d, $end_y);
-                    $res = agenda_add_repeat_item($course_info, $id, $_POST['repeat_type'], $end, $_POST['selected_form'], $safe_file_comment);
-                }
-                $mailSent = 0;
-                if (isset($_POST['add_announcement'])) {
-                    $ann_id = store_agenda_item_as_announcement($id);
-                    AnnouncementManager::send_email($ann_id);
-                    $mailSent = 1;
-                    
+                    $agenda->addRepeatedItem($eventId, $_POST['repeat_type'], $end, $_POST['selected_form']);
                 }
                 Display::display_confirmation_message(get_lang('AddSuccess'));
-                if ($mailSent == 1) {
+                if ($sendEmail) {
                     Display::display_confirmation_message(get_lang('AdditionalMailWasSentToSelectedUsers'));
                 }
             } else {

+ 3 - 1
main/calendar/agenda_js.php

@@ -133,9 +133,11 @@ $export_icon_high = '../img/export_high_fade.png';
 $tpl->assign('export_ical_confidential_icon', Display::return_icon($export_icon_high, get_lang('ExportiCalConfidential')));
 
 $actions = null;
+$filter = null;
 
 if (api_is_allowed_to_edit(false, true) OR
-    (api_get_course_setting('allow_user_edit_agenda') && !api_is_anonymous()) && api_is_allowed_to_session_edit(false, true) OR
+    (api_get_course_setting('allow_user_edit_agenda') && !api_is_anonymous()) &&
+    api_is_allowed_to_session_edit(false, true) OR
     $is_group_tutor
 ) {
     if ($type == 'course') {

+ 24 - 46
main/chat/chat.php

@@ -16,19 +16,21 @@ require_once api_get_path(LIBRARY_PATH).'groupmanager.lib.php';
 $this_section = SECTION_COURSES;
 $nameTools = get_lang('ToolChat');
 
-if ($_GET["origin"] != 'whoisonline') {
-	api_protect_course_script(true);
+$origin = isset($_GET["origin"]) ? Security::remove_XSS($_GET["origin"]) : null;
+$target = isset($_GET["target"]) ? Security::remove_XSS($_GET["target"]) : null;
+
+if ($origin != 'whoisonline') {
+    api_protect_course_script(true);
 } else {
-	$origin = $_SESSION['origin'];
-	$target = $_SESSION['target'];
-	$_SESSION['origin']= Security::remove_XSS($_GET["origin"]);
-	$_SESSION['target']= Security::remove_XSS($_GET["target"]);
+    $origin = $_SESSION['origin'];
+    $target = $_SESSION['target'];
+    $_SESSION['origin']= $origin;
+    $_SESSION['target']= $target;
 }
 
 /*  TRACKING */
 
 event_access_tool(TOOL_CHAT);
-
 header('Content-Type: text/html; charset='.api_get_system_encoding());
 
 /*
@@ -43,67 +45,43 @@ if (!empty($mycourseid) && $mycourseid != -1) {
 
 $cidreq = Security::remove_XSS($_GET['cidReq']);
 
-$toolgroup = Security::remove_XSS($_GET['toolgroup']); //fix when change by vertical or horizontal menu from a chat group to chat course.
-if (empty($toolgroup) && empty($open_chat_window)){
-	unset($_SESSION['_gid']);
-}
-
-
 ?>
-<!DOCTYPE html
-     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
-     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo api_get_language_isocode(); ?>" lang="<?php echo api_get_language_isocode(); ?>">
+<!DOCTYPE html>
+<html>
 <head>
-<meta http-equiv="Content-Type" content="text/html; charset=<?php echo api_get_system_encoding(); ?>" />
+<meta charset="<?php echo api_get_system_encoding(); ?>" />
 <?php
 echo'<title>'.get_lang('Chat').' - '.$mycourseid.' - '.api_get_setting('siteName').'</title>';
 
-// If it is a group chat then the breadcrumbs.
-if ($_SESSION['_gid'] OR $_GET['group_id']) {
-
-	if (isset($_SESSION['_gid'])) {
-		$_clean['group_id'] = (int)$_SESSION['_gid'];
-	}
-	if (isset($_GET['group_id'])) {
-		$_clean['group_id'] = (int)Database::escape_string($_GET['group_id']);
-	}
+$groupId = api_get_group_id();
 
-	$group_properties  = GroupManager :: get_group_properties($_clean['group_id']);
+// If it is a group chat then the breadcrumbs.
+if (!empty($groupId)) {
+	$group_properties  = GroupManager :: get_group_properties($groupId);
 	$interbreadcrumb[] = array('url' => '../group/group.php', 'name' => get_lang('Groups'));
-	$interbreadcrumb[] = array('url' => '../group/group_space.php?gidReq='.api_get_group_id(), 'name' => get_lang('GroupSpace').' '.$group_properties['name']);
+	$interbreadcrumb[] = array(
+        'url' => '../group/group_space.php?gidReq='.api_get_group_id(),
+        'name' => get_lang('GroupSpace').' '.$group_properties['name']
+    );
 	$noPHP_SELF = true;
 	$shortBanner = false;
 	$add_group_to_title = ' ('.$group_properties['name'].')';
-	$groupfilter = 'group_id="'.$_clean['group_id'].'"';
-
-	// Ensure this tool in groups whe it's private or deactivated
-	/*if ($group_properties['chat_state'] == 0) {
-		echo api_not_allowed();
-	} elseif ($group_properties['chat_state'] == 2) {
- 		if (!api_is_allowed_to_edit(false,true) and !GroupManager :: is_user_in_group($_user['user_id'], $_SESSION['_gid'])) {
-			echo api_not_allowed();
-		}
-	}*/
-
+	$groupfilter = 'group_id="'.$groupId.'"';
 } else {
 	$groupfilter = 'group_id=0';
 }
 
-//$is_allowed_to_edit = api_is_allowed_to_edit(false, true);
-
-
 if (empty($open_chat_window)) {
-	Display::display_header($tool_name, 'Chat');
+    Display::display_header($tool_name, 'Chat');
 }
 
 echo '<iframe src="chat_whoisonline.php?cidReq='.$cidreq.'" name="chat_whoisonline" scrolling="auto" style="height:320px; width:19%; border: 0px none; float:left"></iframe>';
-echo '<iframe src="chat_chat.php?origin='.Security::remove_XSS($_GET['origin']).'&target='.Security::remove_XSS($_GET['target']).'&amp;cidReq='.$cidreq.'" name="chat_chat" scrolling="auto" height="240" style="width:80%; border: 0px none; float:right"></iframe>';
+echo '<iframe src="chat_chat.php?origin='.$origin.'&target='.$target.'&amp;cidReq='.$cidreq.'" name="chat_chat" scrolling="auto" height="240" style="width:80%; border: 0px none; float:right"></iframe>';
 echo '<iframe src="chat_message.php?cidReq='.$cidreq.'" name="chat_message" scrolling="no" height="80" style="width:80%; border: 0px none; float:right"></iframe>';
 echo '<iframe src="chat_hidden.php?cidReq='.$cidreq.'" name="chat_hidden" height="0" style="border: 0px none"></iframe>';
 
 if (empty($open_chat_window)) {
-	Display::display_footer();
+    Display::display_footer();
 }
 
 echo '</html>';

+ 46 - 51
main/chat/chat_chat.php

@@ -20,52 +20,52 @@ require_once api_get_path(LIBRARY_PATH).'fileUpload.lib.php';
 require_once api_get_path(LIBRARY_PATH).'groupmanager.lib.php';
 
 $course = $_GET['cidReq'];
-$session_id = intval($_SESSION['id_session']);
-$group_id 	= intval($_SESSION['_gid']);
+$session_id = api_get_session_id();
+$group_id 	= api_get_group_id();
 
 // if we have the session set up
 if (!empty($course)) {
-	$reset = (bool)$_GET['reset'];
-	$tbl_user = Database::get_main_table(TABLE_MAIN_USER);
-	$query = "SELECT username FROM $tbl_user WHERE user_id='".intval($_user['user_id'])."'";
-	$result = Database::query($query);
-
-	list($pseudo_user) = Database::fetch_row($result);
-
-	$isAllowed = !(empty($pseudo_user) || !$_cid);
-	$isMaster = (bool)$is_courseAdmin;
-
-	$date_now = date('Y-m-d');
-	$basepath_chat = '';
-	$document_path = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
-	if (!empty($group_id)) {
-		$group_info = GroupManager :: get_group_properties($group_id);
-		$basepath_chat = $group_info['directory'].'/chat_files';
-	} else {
-		$basepath_chat = '/chat_files';
-	}
-	$chat_path = $document_path.$basepath_chat.'/';
-
-	$TABLEITEMPROPERTY = Database::get_course_table(TABLE_ITEM_PROPERTY);
-
-	$course_id = api_get_course_int_id();
-
-	if (!is_dir($chat_path)) {
-		if (is_file($chat_path)) {
-			@unlink($chat_path);
-		}
-
-		if (!api_is_anonymous()) {
-			@mkdir($chat_path, api_get_permissions_for_new_directories());
-			// Save chat files document for group into item property
-			if (!empty($group_id)) {
-				$doc_id = add_document($_course, $basepath_chat, 'folder', 0, 'chat_files');
-				$sql = "INSERT INTO $TABLEITEMPROPERTY (c_id, tool,insert_user_id,insert_date,lastedit_date,ref,lastedit_type,lastedit_user_id,to_group_id,to_user_id,visibility)
-						VALUES ($course_id, 'document',1,NOW(),NOW(),$doc_id,'FolderCreated',1,$group_id,NULL,0)";
-				Database::query($sql);
-			}
-		}
-	}
+    $reset = isset($_GET['reset']) ? (bool)$_GET['reset'] : null;
+    $tbl_user = Database::get_main_table(TABLE_MAIN_USER);
+    $query = "SELECT username FROM $tbl_user WHERE user_id='".intval($_user['user_id'])."'";
+    $result = Database::query($query);
+
+    list($pseudo_user) = Database::fetch_row($result);
+
+    $isAllowed = !(empty($pseudo_user) || !$_cid);
+    $isMaster = (bool)$is_courseAdmin;
+
+    $date_now = date('Y-m-d');
+    $basepath_chat = '';
+    $document_path = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
+    if (!empty($group_id)) {
+        $group_info = GroupManager :: get_group_properties($group_id);
+        $basepath_chat = $group_info['directory'].'/chat_files';
+    } else {
+        $basepath_chat = '/chat_files';
+    }
+    $chat_path = $document_path.$basepath_chat.'/';
+
+    $TABLEITEMPROPERTY = Database::get_course_table(TABLE_ITEM_PROPERTY);
+
+    $course_id = api_get_course_int_id();
+
+    if (!is_dir($chat_path)) {
+        if (is_file($chat_path)) {
+            @unlink($chat_path);
+        }
+
+        if (!api_is_anonymous()) {
+            @mkdir($chat_path, api_get_permissions_for_new_directories());
+            // Save chat files document for group into item property
+            if (!empty($group_id)) {
+                $doc_id = add_document($_course, $basepath_chat, 'folder', 0, 'chat_files');
+                $sql = "INSERT INTO $TABLEITEMPROPERTY (c_id, tool,insert_user_id,insert_date,lastedit_date,ref,lastedit_type,lastedit_user_id,to_group_id,to_user_id,visibility)
+                        VALUES ($course_id, 'document',1,NOW(),NOW(),$doc_id,'FolderCreated',1,$group_id,NULL,0)";
+                Database::query($sql);
+            }
+        }
+    }
 
 	$filename_chat = '';
 	if (!empty($group_id)) {
@@ -132,10 +132,10 @@ if (!empty($course)) {
 	array_splice($content, 0, $remove);
 	require 'header_frame.inc.php';
 
-	if ($_GET['origin'] == 'whoisonline') {  //the caller
+	if (isset($_GET['origin']) && $_GET['origin'] == 'whoisonline') {  //the caller
 		$content[0] = get_lang('CallSent').'<br />'.$content[0];
 	}
-	if ($_GET['origin'] == 'whoisonlinejoin') {   //the joiner (we have to delete the chat request to him when he joins the chat)
+	if (isset($_GET['origin']) && $_GET['origin'] == 'whoisonlinejoin') {   //the joiner (we have to delete the chat request to him when he joins the chat)
 		$track_user_table = Database::get_main_table(TABLE_MAIN_USER);
 		$sql = "UPDATE $track_user_table set chatcall_user_id = '', chatcall_date = '', chatcall_text='' WHERE (user_id = ".$_user['user_id'].")";
 		$result = Database::query($sql);
@@ -146,12 +146,7 @@ if (!empty($course)) {
 		echo strip_tags(api_html_entity_decode($this_line), '<br> <span> <b> <i> <img> <font>');
 	}
 	echo '</div>';
-
-	?>
-
-	<a name="bottom" style="text-decoration:none;">&nbsp;</a>
-
-	<?php
+	echo '<a name="bottom" style="text-decoration:none;">&nbsp;</a>';
 	if ($isMaster || $is_courseCoach) {
 		$rand = mt_rand(1, 1000);
 		echo '<div style="margin-left: 5px;">';

+ 34 - 32
main/chat/chat_functions.lib.php

@@ -3,24 +3,24 @@
 /**
  *	@package chamilo.chat
  */
- 
+
 
 /**
  * @author isaac flores paz
  * @param integer the user id
- * @param string the database name
  * @return boolean
  * @todo this function need more parameters seems not to be use anymore
  * @deprecated fix this function or create another
  */
-function user_connected_in_chat ($user_id) {
+function user_connected_in_chat ($user_id)
+{
  	$tbl_chat_connected = Database::get_course_table(TABLE_CHAT_CONNECTED);
     $user_id 	= intval($user_id);
  	$session_id = api_get_session_id();
-    $group_id   = api_get_group_id();	
-    $course_id  = api_get_course_int_id();    
+    $group_id   = api_get_group_id();
+    $course_id  = api_get_course_int_id();
 	$extra_condition = '';
-	
+
 	if (!empty($group_id)) {
 		$extra_condition = " AND to_group_id = '$group_id'";
 	} else {
@@ -37,13 +37,14 @@ function user_connected_in_chat ($user_id) {
  * @param integer
  * @return void
  */
-function exit_of_chat($user_id) {
-	$user_id = intval($user_id);    
- 	$list_course = CourseManager::get_courses_list_by_user_id($user_id);    
-    
+function exit_of_chat($user_id)
+{
+    $user_id = intval($user_id);
+    $list_course = CourseManager::get_courses_list_by_user_id($user_id);
+
     /*$session_id = api_get_session_id();
-    $group_id   = api_get_group_id();	
-	
+    $group_id   = api_get_group_id();
+
 	$extra_condition = '';
 	if (!empty($group_id)) {
 		$extra_condition = " AND to_group_id = '$group_id'";
@@ -51,28 +52,28 @@ function exit_of_chat($user_id) {
 		$extra_condition = api_get_session_condition($session_id);
 	}
     $extra_condition.= " AND course_id = $course_id";*/
-    
+
     $tbl_chat_connected = Database::get_course_table(TABLE_CHAT_CONNECTED);
-    
- 	foreach ($list_course as $course) {
- 		$response = user_connected_in_chat($user_id);
- 		//if ($response === true) {
- 			$sql = 'DELETE FROM '.$tbl_chat_connected.' WHERE c_id = '.$course['real_id'].' AND user_id = '.$user_id;
- 			Database::query($sql);
- 		//}
- 	}
+
+    foreach ($list_course as $course) {
+        $response = user_connected_in_chat($user_id);
+        //if ($response === true) {
+            $sql = 'DELETE FROM '.$tbl_chat_connected.' WHERE c_id = '.$course['real_id'].' AND user_id = '.$user_id;
+            Database::query($sql);
+        //}
+    }
 }
 
 /**
- * @param string $database_name (optional)
  * @return void
  */
-function disconnect_user_of_chat() {
+function disconnect_user_of_chat()
+{
 	$list_info_user_in_chat = array();
     $course_id = api_get_course_int_id();
     $list_info_user_in_chat = users_list_in_chat();
     $course_id = api_get_course_int_id();
-    
+
 	$cd_date           = date('Y-m-d',time());
 	$cdate_h           = date('H',time());
 	$cdate_m           = date('i',time());
@@ -87,9 +88,10 @@ function disconnect_user_of_chat() {
 			$date_db_s  = date('s', strtotime($list_info_user['last_connection']));
 			$date_count_time_seconds=$date_db_h*3600 + $date_db_m*60 + $date_db_s;
 			if ($cd_date == $date_db_date) {
-				if (($cd_count_time_seconds - $date_count_time_seconds) > 5) {					
-                    $tbl_chat_connected = Database::get_course_table(TABLE_CHAT_CONNECTED);					
-			 		$sql = 'DELETE FROM '.$tbl_chat_connected.' WHERE c_id = '.$course_id.' AND user_id ='.$list_info_user['user_id'];
+				if (($cd_count_time_seconds - $date_count_time_seconds) > 5) {
+                    $tbl_chat_connected = Database::get_course_table(TABLE_CHAT_CONNECTED);
+			 		$sql = 'DELETE FROM '.$tbl_chat_connected.'
+			 		        WHERE c_id = '.$course_id.' AND user_id ='.$list_info_user['user_id'];
 			 		Database::query($sql);
 				}
 			}
@@ -98,17 +100,17 @@ function disconnect_user_of_chat() {
 }
 
 /**
- * @param string $database_name (optional)
  * @return array user list in chat
  */
-function users_list_in_chat() {
+function users_list_in_chat()
+{
 	$list_users_in_chat = array();
  	$tbl_chat_connected = Database::get_course_table(TABLE_CHAT_CONNECTED);
     $course_id = api_get_course_int_id();
-    
+
  	$session_id = api_get_session_id();
     $group_id   = api_get_group_id();
-    
+
 	$extra_condition = '';
 	if (!empty($group_id)) {
 		$extra_condition = " WHERE to_group_id = '$group_id'";
@@ -122,4 +124,4 @@ function users_list_in_chat() {
  		$list_users_in_chat[] = $row;
  	}
  	return $list_users_in_chat;
-}
+}

+ 17 - 16
main/chat/chat_hidden.php

@@ -34,8 +34,8 @@ $isMaster = (bool)$is_courseAdmin;
 
 $date_now = date('Y-m-d');
 
-$group_id = intval($_SESSION['_gid']);
-$session_id = intval($_SESSION['id_session']);
+$group_id = api_get_group_id();
+$session_id = api_get_session_id();
 $session_condition = api_get_session_condition($session_id);
 $group_condition = " AND to_group_id = '$group_id'";
 
@@ -68,7 +68,7 @@ if (!empty($group_id)) {
 	$basename_chat = 'messages-'.$date_now;
 }
 
-$chat_size_old = intval($_POST['chat_size_old']);
+$chat_size_old = isset($_POST['chat_size_old']) ? intval($_POST['chat_size_old']) : null;
 
 $file = $chat_path.$basename_chat.'.log.html';
 $chat_size_new = 0;
@@ -92,7 +92,7 @@ Database::query($query);
 $query = "SELECT COUNT(user_id) FROM $tbl_chat_connected WHERE last_connection>'".date('Y-m-d H:i:s',time()-60*5)."' $extra_condition";
 $result = Database::query($query);
 
-$connected_old = intval($_POST['connected_old']);
+$connected_old = isset($_POST['connected_old']) ? intval($_POST['connected_old']) : null;
 list($connected_new) = Database::fetch_row($result);
 /*disconnected user of chat*/
 disconnect_user_of_chat ();
@@ -104,16 +104,17 @@ require 'header_frame.inc.php';
 </form>
 <?php
 
-if ($_SESSION["origin"] == 'whoisonline') {  //check if our target has denied our request or not
-	$talk_to = $_SESSION["target"];
-	$track_user_table = Database::get_main_table(TABLE_MAIN_USER);
-	$sql = "select chatcall_text from $track_user_table where ( user_id = $talk_to )";
-	$result = Database::query($sql);
-	$row = Database::fetch_array($result);
-	if ($row['chatcall_text'] == 'DENIED') {
-		echo "<script language=\"javascript\" type=\"text/javascript\"> alert('".get_lang('ChatDenied')."'); </script>";
-		$sql = "update $track_user_table set chatcall_user_id = '', chatcall_date = '', chatcall_text='' WHERE (user_id = $talk_to)";
-		$result = Database::query($sql);
-	}
+if (isset($_SESSION["origin"]) && $_SESSION["origin"] == 'whoisonline') {
+    //check if our target has denied our request or not
+    $talk_to = $_SESSION["target"];
+    $track_user_table = Database::get_main_table(TABLE_MAIN_USER);
+    $sql = "select chatcall_text from $track_user_table where ( user_id = $talk_to )";
+    $result = Database::query($sql);
+    $row = Database::fetch_array($result);
+    if ($row['chatcall_text'] == 'DENIED') {
+        echo "<script language=\"javascript\" type=\"text/javascript\"> alert('".get_lang('ChatDenied')."'); </script>";
+        $sql = "update $track_user_table set chatcall_user_id = '', chatcall_date = '', chatcall_text='' WHERE (user_id = $talk_to)";
+        $result = Database::query($sql);
+    }
 }
-require 'footer_frame.inc.php';
+require 'footer_frame.inc.php';

+ 47 - 47
main/chat/chat_message.php

@@ -66,60 +66,60 @@ if (!empty($course) && !empty($_user['user_id'])) {
 
 	/*	Constants and variables */
 
-	$tbl_user	= Database::get_main_table(TABLE_MAIN_USER);
-	$sent 		= $_REQUEST['sent'];
+    $tbl_user	= Database::get_main_table(TABLE_MAIN_USER);
+    $sent 		= isset($_REQUEST['sent']) ? $_REQUEST['sent'] : null;
 
-	/*	MAIN CODE */
+    /*	MAIN CODE */
 
-	$query = "SELECT lastname, firstname, username FROM $tbl_user WHERE user_id='".intval($_user['user_id'])."'";
-	$result = Database::query($query);
+    $query = "SELECT lastname, firstname, username FROM $tbl_user WHERE user_id='".intval($_user['user_id'])."'";
+    $result = Database::query($query);
 
-	list($pseudo_user) = Database::fetch_row($result);
+    list($pseudo_user) = Database::fetch_row($result);
 
-	$isAllowed = !(empty($pseudo_user) || !$_cid);
-	$isMaster = (bool)$is_courseAdmin;
+    $isAllowed = !(empty($pseudo_user) || !$_cid);
+    $isMaster = (bool)$is_courseAdmin;
 
-	$firstname = Database::result($result, 0, 'firstname');
-	$lastname  = Database::result($result, 0, 'lastname');
+    $firstname = Database::result($result, 0, 'firstname');
+    $lastname  = Database::result($result, 0, 'lastname');
 
-	$date_now = date('Y-m-d');
+    $date_now = date('Y-m-d');
 
-	$basepath_chat = '';
-	$document_path = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
-	if (!empty($group_id)) {
-		$group_info = GroupManager :: get_group_properties($group_id);
-		$basepath_chat = $group_info['directory'].'/chat_files';
-	} else {
-		$basepath_chat = '/chat_files';
-	}
-	$chat_path = $document_path.$basepath_chat.'/';
+    $basepath_chat = '';
+    $document_path = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
+    if (!empty($group_id)) {
+        $group_info = GroupManager :: get_group_properties($group_id);
+        $basepath_chat = $group_info['directory'].'/chat_files';
+    } else {
+        $basepath_chat = '/chat_files';
+    }
+    $chat_path = $document_path.$basepath_chat.'/';
 
-	if (!is_dir($chat_path)) {
-		if (is_file($chat_path)) {
-			@unlink($chat_path);
-		}
-	}
+    if (!is_dir($chat_path)) {
+        if (is_file($chat_path)) {
+            @unlink($chat_path);
+        }
+    }
 
-	require 'header_frame.inc.php';
-	$chat_size = 0;
+    require 'header_frame.inc.php';
+    $chat_size = 0;
 
 	// Define emoticons
-	$emoticon_text1 = ':-)';
-	$emoticon_img1  = '<img src="'.api_get_path(WEB_IMG_PATH).'smileys/icon_smile.gif" alt="'.get_lang('Smile').'" title="'.get_lang('Smile').'" />';
-	$emoticon_text2 = ':-D';
-	$emoticon_img2  = '<img src="'.api_get_path(WEB_IMG_PATH).'smileys/icon_biggrin.gif" alt="'.get_lang('BigGrin').'" title="'.get_lang('BigGrin').'" />';
-	$emoticon_text3 = ';-)';
-	$emoticon_img3  = '<img src="'.api_get_path(WEB_IMG_PATH).'smileys/icon_wink.gif" alt="'.get_lang('Wink').'" title="'.get_lang('Wink').'" />';
-	$emoticon_text4 = ':-P';
-	$emoticon_img4  = '<img src="'.api_get_path(WEB_IMG_PATH).'smileys/icon_razz.gif" alt="'.get_lang('Avid').'" title="'.get_lang('Avid').'" />';
-	$emoticon_text5 = '8-)';
-	$emoticon_img5  = '<img src="'.api_get_path(WEB_IMG_PATH).'smileys/icon_cool.gif" alt="'.get_lang('Cool').'" title="'.get_lang('Cool').'" />';
-	$emoticon_text6 = ':-o)';
-	$emoticon_img6  = '<img src="'.api_get_path(WEB_IMG_PATH).'smileys/icon_surprised.gif" alt="'.get_lang('Surprised').'" title="'.get_lang('Surprised').'" />';
-	$emoticon_text7 = '=;';
-	$emoticon_img7  = '<img src="'.api_get_path(WEB_IMG_PATH).'smileys/icon_hand.gif" alt="'.get_lang('Hand').'" title="'.get_lang('Hand').'" />';
-	$emoticon_text8 = '=8-o';
-	$emoticon_img8  = '<img src="'.api_get_path(WEB_IMG_PATH).'smileys/icon_eek.gif" alt="'.get_lang('Amazing').'" title="'.get_lang('Amazing').'" />';
+    $emoticon_text1 = ':-)';
+    $emoticon_img1  = '<img src="'.api_get_path(WEB_IMG_PATH).'smileys/icon_smile.gif" alt="'.get_lang('Smile').'" title="'.get_lang('Smile').'" />';
+    $emoticon_text2 = ':-D';
+    $emoticon_img2  = '<img src="'.api_get_path(WEB_IMG_PATH).'smileys/icon_biggrin.gif" alt="'.get_lang('BigGrin').'" title="'.get_lang('BigGrin').'" />';
+    $emoticon_text3 = ';-)';
+    $emoticon_img3  = '<img src="'.api_get_path(WEB_IMG_PATH).'smileys/icon_wink.gif" alt="'.get_lang('Wink').'" title="'.get_lang('Wink').'" />';
+    $emoticon_text4 = ':-P';
+    $emoticon_img4  = '<img src="'.api_get_path(WEB_IMG_PATH).'smileys/icon_razz.gif" alt="'.get_lang('Avid').'" title="'.get_lang('Avid').'" />';
+    $emoticon_text5 = '8-)';
+    $emoticon_img5  = '<img src="'.api_get_path(WEB_IMG_PATH).'smileys/icon_cool.gif" alt="'.get_lang('Cool').'" title="'.get_lang('Cool').'" />';
+    $emoticon_text6 = ':-o)';
+    $emoticon_img6  = '<img src="'.api_get_path(WEB_IMG_PATH).'smileys/icon_surprised.gif" alt="'.get_lang('Surprised').'" title="'.get_lang('Surprised').'" />';
+    $emoticon_text7 = '=;';
+    $emoticon_img7  = '<img src="'.api_get_path(WEB_IMG_PATH).'smileys/icon_hand.gif" alt="'.get_lang('Hand').'" title="'.get_lang('Hand').'" />';
+    $emoticon_text8 = '=8-o';
+    $emoticon_img8  = '<img src="'.api_get_path(WEB_IMG_PATH).'smileys/icon_eek.gif" alt="'.get_lang('Amazing').'" title="'.get_lang('Amazing').'" />';
 	$emoticon_text9 = ':-|)';
 	$emoticon_img9  = '<img src="'.api_get_path(WEB_IMG_PATH).'smileys/icon_neutral.gif" alt="'.get_lang('Neutral').'" title="'.get_lang('Neutral').'" />';
 	$emoticon_text8 = ':-k';
@@ -165,7 +165,7 @@ if (!empty($course) && !empty($_user['user_id'])) {
 		$message = str_replace($emoticon_text7, $emoticon_img7, $message);
 		$message = str_replace($emoticon_text8, $emoticon_img8, $message);
 		$message = str_replace($emoticon_text9, $emoticon_img9, $message);
-		$message = str_replace($emoticon_text10, $emoticon_img10, $message);
+		//$message = str_replace($emoticon_text10, $emoticon_img10, $message);
 		$message = str_replace($emoticon_text11, $emoticon_img11, $message);
 		$message = str_replace($emoticon_text12, $emoticon_img12, $message);
 		$message = str_replace($emoticon_text13, $emoticon_img13, $message);
@@ -195,7 +195,7 @@ if (!empty($course) && !empty($_user['user_id'])) {
 
 		if (!api_is_anonymous()) {
 			if (!empty($message)) {
-				$message = make_clickable($message);
+				//$message = make_clickable($message);
                 if (!file_exists($chat_path.$basename_chat.'.log.html')) {
 					$doc_id = add_document($_course, $basepath_chat.'/'.$basename_chat.'.log.html', 'file', 0, $basename_chat.'.log.html');
 
@@ -250,7 +250,7 @@ if (!empty($course) && !empty($_user['user_id'])) {
 		echo  "<a href=\"javascript:insert('".$emoticon_text7."')\">".$emoticon_img7."</a>";
 		echo  "<a href=\"javascript:insert('".$emoticon_text8."')\">".$emoticon_img8."</a>";
 		echo  "<a href=\"javascript:insert('".$emoticon_text9."')\">".$emoticon_img9."</a>";
-		echo  "<a href=\"javascript:insert('".$emoticon_text10."')\">".$emoticon_img10."</a>";
+		//echo  "<a href=\"javascript:insert('".$emoticon_text10."')\">".$emoticon_img10."</a>";
 		echo  "<a href=\"javascript:insert('".$emoticon_text11."')\">".$emoticon_img11."</a>";
 		echo  "<a href=\"javascript:insert('".$emoticon_text12."')\">".$emoticon_img12."</a>";
 		echo  "<a href=\"javascript:insert('".$emoticon_text13."')\">".$emoticon_img13."</a>";
@@ -276,4 +276,4 @@ if (!empty($course) && !empty($_user['user_id'])) {
     </form>
 <?php
 }
-require 'footer_frame.inc.php';
+require 'footer_frame.inc.php';

+ 48 - 53
main/chat/chat_whoisonline.php

@@ -15,70 +15,72 @@ $language_file = array('chat');
 require_once '../inc/global.inc.php';
 
 $course = api_get_course_id();
-$group_id = intval($_SESSION['_gid']);
-$session_id = intval($_SESSION['id_session']);
+$group_id = api_get_group_id();
+$session_id = api_get_session_id();
 $session_condition = api_get_session_condition($session_id);
 $group_condition = " AND to_group_id = '$group_id'";
 
 $extra_condition = '';
 if (!empty($group_id)) {
-	$extra_condition = $group_condition;
+    $extra_condition = $group_condition;
 } else {
-	$extra_condition = $session_condition;
+    $extra_condition = $session_condition;
 }
 
 $user_id = api_get_user_id();
 
 if (!empty($course)) {
-	$showPic = intval($_GET['showPic']);
-	$tbl_course_user			= Database::get_main_table(TABLE_MAIN_COURSE_USER);
-	$tbl_session_course_user	= Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
-	$tbl_session				= Database::get_main_table(TABLE_MAIN_SESSION);
-	$tbl_session_course			= Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
-	$tbl_user					= Database::get_main_table(TABLE_MAIN_USER);
-	$tbl_chat_connected			= Database::get_course_table(TABLE_CHAT_CONNECTED);
-
-	$query = "SELECT username FROM $tbl_user WHERE user_id='".$user_id."'";
-	$result = Database::query($query);
-
-	list($pseudo_user) = Database::fetch_array($result);
-
-	$isAllowed = !(empty($pseudo_user) || !$_cid);
-	$isMaster = (bool)$is_courseAdmin;
-
-	$date_inter = date('Y-m-d H:i:s', time() - 120);
-
-	$users = array();
-	$course_id = api_get_course_int_id();
-	
-	if (empty($session_id)) {
-		$query = "SELECT DISTINCT t1.user_id,username,firstname,lastname,picture_uri,t3.status 
-				  FROM $tbl_user t1, $tbl_chat_connected t2, $tbl_course_user t3 
+    $showPic = isset($_GET['showPic']) ? intval($_GET['showPic']) : null;
+    $tbl_course_user			= Database::get_main_table(TABLE_MAIN_COURSE_USER);
+    $tbl_session_course_user	= Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
+    $tbl_session				= Database::get_main_table(TABLE_MAIN_SESSION);
+    $tbl_session_course			= Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
+    $tbl_user					= Database::get_main_table(TABLE_MAIN_USER);
+    $tbl_chat_connected			= Database::get_course_table(TABLE_CHAT_CONNECTED);
+
+    $query = "SELECT username FROM $tbl_user WHERE user_id='".$user_id."'";
+    $result = Database::query($query);
+
+    list($pseudo_user) = Database::fetch_array($result);
+
+    $isAllowed = !(empty($pseudo_user) || !$_cid);
+    $isMaster = (bool)$is_courseAdmin;
+
+    $date_inter = date('Y-m-d H:i:s', time() - 120);
+
+    $users = array();
+    $course_id = api_get_course_int_id();
+
+    if (empty($session_id)) {
+		$query = "SELECT DISTINCT t1.user_id,username,firstname,lastname,picture_uri,t3.status
+				  FROM $tbl_user t1, $tbl_chat_connected t2, $tbl_course_user t3
 				  WHERE t2.c_id = $course_id AND
-				  		t1.user_id=t2.user_id AND 
-				  		t3.user_id=t2.user_id AND 
-						t3.relation_type<>".COURSE_RELATION_TYPE_RRHH." AND 
-						t3.course_code = '".$_course['sysCode']."' AND 
-						t2.last_connection>'".$date_inter."' $extra_condition 
-						ORDER BY username";                        
-		$result = Database::query($query);
-		$users = Database::store_result($result);
+				  		t1.user_id=t2.user_id AND
+				  		t3.user_id=t2.user_id AND
+						t3.relation_type<>".COURSE_RELATION_TYPE_RRHH." AND
+						t3.course_code = '".$_course['sysCode']."' AND
+						t2.last_connection>'".$date_inter."' $extra_condition
+						ORDER BY username";
+        $result = Database::query($query);
+        $users = Database::store_result($result);
 	} else {
 		// select learners
-		$query = "SELECT DISTINCT t1.user_id,username,firstname,lastname,picture_uri FROM $tbl_user t1, $tbl_chat_connected t2, $tbl_session_course_user t3 
+		$query = "SELECT DISTINCT t1.user_id,username,firstname,lastname,picture_uri
+                  FROM $tbl_user t1, $tbl_chat_connected t2, $tbl_session_course_user t3
 		          WHERE
-		          t2.c_id = $course_id AND 
-		          t1.user_id=t2.user_id AND t3.id_user=t2.user_id AND 
-		          t3.id_session = '".$session_id."' AND 
+		          t2.c_id = $course_id AND
+		          t1.user_id=t2.user_id AND t3.id_user=t2.user_id AND
+		          t3.id_session = '".$session_id."' AND
 		          t3.course_code = '".$_course['sysCode']."' AND t2.last_connection>'".$date_inter."' $extra_condition ORDER BY username";
 		$result = Database::query($query);
 		while ($learner = Database::fetch_array($result)) {
-			$users[$learner['user_id']] = $learner;
+            $users[$learner['user_id']] = $learner;
 		}
 
 		// select session coach
-		$query = "SELECT DISTINCT t1.user_id,username,firstname,lastname,picture_uri FROM $tbl_user t1,$tbl_chat_connected t2,$tbl_session t3 
-		          WHERE t2.c_id = $course_id AND 
+		$query = "SELECT DISTINCT t1.user_id,username,firstname,lastname,picture_uri
+		          FROM $tbl_user t1,$tbl_chat_connected t2,$tbl_session t3
+		          WHERE t2.c_id = $course_id AND
 		             t1.user_id=t2.user_id AND t3.id_coach=t2.user_id AND t3.id = '".$session_id."' AND t2.last_connection>'".$date_inter."' $extra_condition ORDER BY username";
 		$result = Database::query($query);
 		if ($coach = Database::fetch_array($result)) {
@@ -89,7 +91,7 @@ if (!empty($course)) {
 		$query = "SELECT DISTINCT t1.user_id,username,firstname,lastname,picture_uri
 				FROM $tbl_user t1,$tbl_chat_connected t2,$tbl_session_course_user t3
 				WHERE
-				t2.c_id = $course_id AND  
+				t2.c_id = $course_id AND
 				t1.user_id=t2.user_id
 				AND t3.id_user=t2.user_id AND t3.status=2
 				AND t3.id_session = '".$session_id."'
@@ -99,17 +101,11 @@ if (!empty($course)) {
 		$result = Database::query($query);
 		$course_coaches = array();
 		while ($coaches = Database::fetch_array($result)) {
-			//$course_coaches[] = $coaches['user_id'];
 			$users[$coaches['user_id']] = $coaches;
 		}
-
-		//if ($coach = Database::fetch_array($result))
-		//	$users[$coach['user_id']] = $coach;
 	}
-
-	$user_id = $enreg['user_id'];
 	require 'header_frame.inc.php';
-	
+
 	?>
 	<table border="0" cellpadding="0" cellspacing="0" width="100%" class="data_table">
 	<tr><th colspan="2"><?php echo get_lang('Connected'); ?></th></tr>
@@ -122,7 +118,6 @@ if (!empty($course)) {
 		}
 		$user_image = UserManager::get_user_picture_path_by_id($user['user_id'], 'web', false, true);
 		$file_url = $user_image['dir'].$user_image['file'];
-
 	?>
     <tr>
 	  <td width="1%" valign="top"><img src="<?php echo $file_url;?>" border="0" width="22" alt="" /></td>
@@ -142,4 +137,4 @@ if (!empty($course)) {
 	</table>
 	<?php
 }
-require 'footer_frame.inc.php';
+require 'footer_frame.inc.php';

+ 28 - 35
main/chat/header_frame.inc.php

@@ -35,37 +35,35 @@ if (empty($mycourseid)) {
  * Choose CSS style (platform's, user's, or course's)
  */
 $my_style = api_get_visual_theme();
+$chat_size_old = isset($chat_size_old) ? $chat_size_old : null;
+$chat_size_new = isset($chat_size_new) ? $chat_size_new : null;
+$connected_new = isset($connected_new) ? $connected_new : null;
+$connected_old = isset($connected_old) ? $connected_old : null;
 
+header('Content-Type: text/html; charset='.api_get_system_encoding());
 
-
-?><!DOCTYPE html
-     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
-     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo api_get_language_isocode(); ?>" lang="<?php echo api_get_language_isocode(); ?>">
+?><!DOCTYPE html>
+<html>
 <head>
-<meta http-equiv="Content-Type" content="text/html; charset=<?php echo api_get_system_encoding(); ?>">
-<title>Chat</title>
-<link rel="stylesheet" type="text/css" href="<?php echo api_get_path(WEB_CSS_PATH).$my_style; ?>/default.css">
-<style>
-	a{
-		font-size: 12px;
-	}
-
-	.background_submit{
-		background: url(../img/chat_little.gif) 2px 2px no-repeat;
-		padding: 2px 1px 1px 20px;
-	}
-	TH{
-		font-size: 12px;
-	}
-</style>
-
-<script type="text/javascript" language="javascript">
-<!--
+    <meta charset="<?php echo api_get_system_encoding(); ?>" />
+    <title>Chat</title>
+    <link rel="stylesheet" type="text/css" href="<?php echo api_get_path(WEB_CSS_PATH).$my_style; ?>/default.css">
+    <style>
+        a {
+            font-size: 12px;
+        }
+        .background_submit {
+            background: url(../img/chat_little.gif) 2px 2px no-repeat;
+            padding: 2px 1px 1px 20px;
+        }
+        th {
+            font-size: 12px;
+        }
+    </style>
+<script>
 function updateChat()
 {
-	if ('<?php echo $chat_size_old; ?>' != '<?php echo $chat_size_new; ?>')
-	{
+	if ('<?php echo $chat_size_old; ?>' != '<?php echo $chat_size_new; ?>') {
 		parent.chat_chat.location.href='chat_chat.php?size=<?php echo $chat_size_new.'&'.api_get_cidreq(); ?>#bottom';
 	}
 }
@@ -85,27 +83,22 @@ function submitHiddenForm()
 
 function eventMessage()
 {
-	<?php if($chat_size): ?>
+	<?php if (isset($chat_size) && $chat_size): ?>
 	parent.chat_hidden.document.formHidden.chat_size_old.value='<?php echo $chat_size; ?>';
 	parent.chat_chat.location.href='chat_chat.php?size=<?php echo $chat_size.'&'.api_get_cidreq(); ?>#bottom';
 	<?php endif; ?>
 	document.formMessage.message.focus();
 }
 
-function send_message(evenement){
-
-    for (prop in evenement)
-    {
+function send_message(evenement) {
+    for (prop in evenement) {
     	if(prop == 'which') touche = evenement.which; else touche = evenement.keyCode;
     }
 
-    if (touche == 13)
-    {
+    if (touche == 13) {
     	document.formMessage.submit();
     }
 }
-
-//-->
 </script>
 </head>
 <body <?php echo $bodyXtra; ?> >

+ 5 - 8
main/course_description/add.php

@@ -2,16 +2,13 @@
 /* For licensing terms, see /license.txt */
 
 /**
-* View (MVC patter) for adding a course description 
+* View (MVC patter) for adding a course description
 * @author Christian Fasanando <christian1827@gmail.com>
 * @package chamilo.course_description
 */
 
 // protect a course script
 api_protect_course_script(true);
-
-//var_dump($_SESSION['studentview']);
-
 // display categories
 $categories = array ();
 foreach ($default_description_titles as $id => $title) {
@@ -35,8 +32,8 @@ foreach ($categories as $id => $title) {
 echo '</div>';
 
 // error messages
-if (isset($error) && intval($error) == 1) {	
-	Display::display_error_message(get_lang('FormHasErrorsPleaseComplete'),false);	
+if (isset($error) && intval($error) == 1) {
+	Display::display_error_message(get_lang('FormHasErrorsPleaseComplete'),false);
 }
 
 // default header title form
@@ -64,7 +61,7 @@ if (api_get_setting('wcag_anysurfer_public_pages')=='true') {
 }
 $form->addElement('style_submit_button', null, get_lang('Save'), 'class="save"');
 
-// display default questions			
+// display default questions
 if (isset ($question[$description_type])) {
 	$message = '<strong>'.get_lang('QuestionPlan').'</strong><br />';
 	$message .= $question[$description_type];
@@ -76,4 +73,4 @@ if (api_get_setting('wcag_anysurfer_public_pages')=='true') {
 $form->display();
 if (api_get_setting('wcag_anysurfer_public_pages')=='true') {
 	echo (WCAG_Rendering::editor_footer());
-}
+}

+ 14 - 0
main/course_info/infocours.php

@@ -331,6 +331,20 @@ $form->addGroup($group, '', array(get_lang("InfoAboutAdvanceInsideHomeCourse")),
 $form->addElement('style_submit_button', null, get_lang('SaveSettings'), 'class="save"');
 $form->addElement('html', '</div></div>');
 
+// Document settings
+$form->addElement('html', '<div><h3>'.Display::return_icon('folder.png', Security::remove_XSS(get_lang('Documents')),'',ICON_SIZE_SMALL).' '.Security::remove_XSS(get_lang('Documents')).'</h3><div>');
+
+$group = array(
+    $form->createElement('radio', 'show_system_folders', null, get_lang('Yes'), 1),
+    $form->createElement('radio', 'show_system_folders', null, get_lang('No'), 2),
+
+);
+$form->addGroup($group, '', array(get_lang("ShowSystemFolders")), '');
+
+$form->addElement('style_submit_button', null, get_lang('SaveSettings'), 'class="save"');
+$form->addElement('html', '</div></div>');
+
+
 // Certificate settings
 if (api_get_setting('allow_public_certificates')=='true') {
     $form->addElement('html', '<div><h3>'.Display::return_icon('certificate.png', Security::remove_XSS(get_lang('Certificates')),'',ICON_SIZE_SMALL).' '.Security::remove_XSS(get_lang('Certificates')).'</h3><div>');

+ 287 - 291
main/coursecopy/classes/Course.class.php

@@ -19,21 +19,21 @@ class Course
     public $destination_db;
     public $encoding;
 
-	/**
-	 * Create a new Course-object
-	 */
-    function __construct()
+    /**
+     * Create a new Course-object
+     */
+    public function __construct()
     {
-		$this->resources    = array();
-		$this->code         = '';
-		$this->path         = '';
-		$this->backup_path  = '';
-		$this->encoding     = api_get_system_encoding();
-	}
-
-	/**
-	 * Check if a resource links to the given resource
-	 */
+        $this->resources    = array();
+        $this->code         = '';
+        $this->path         = '';
+        $this->backup_path  = '';
+        $this->encoding     = api_get_system_encoding();
+    }
+
+    /**
+     * Check if a resource links to the given resource
+     */
     function is_linked_resource(& $resource_to_check)
     {
         foreach ($this->resources as $type => $resources) {
@@ -53,320 +53,316 @@ class Course
         return false;
     }
 
-	/**
-	 * Add a resource from a given type to this course
-	 */
+    /**
+     * Add a resource from a given type to this course
+     */
     function add_resource(& $resource)
     {
-		$this->resources[$resource->get_type()][$resource->get_id()] = $resource;
-	}
-
-	/**
-	 * Does this course has resources?
-	 * @param const $resource_type Check if this course has resources of the
-	 * given type. If no type is given, check if course has resources of any
-	 * type.
-	 */
+        $this->resources[$resource->get_type()][$resource->get_id()] = $resource;
+    }
+
+    /**
+     * Does this course has resources?
+     * @param const $resource_type Check if this course has resources of the
+     * given type. If no type is given, check if course has resources of any
+     * type.
+     */
     function has_resources($resource_type = null)
     {
-		if( $resource_type != null) {
+        if( $resource_type != null) {
             return isset($this->resources[$resource_type]) && is_array($this->resources[$resource_type]) && (count(
                     $this->resources[$resource_type]
                 ) > 0);
-		}
-		return (count($this->resources) > 0);
-	}
+        }
+        return (count($this->resources) > 0);
+    }
 
-	/**
-	 * Show this course resources
-	 */
+    /**
+     * Show this course resources
+     */
     function show()
     { /*
-		echo '<pre>';
-		print_r($this);
-		echo '</pre>';*/
-	}
-
-	/**
-	 * Returns sample text based on the imported course content.
-	 * This sample text is to be used for course language or encoding detection if there is missing (meta)data in the archive.
-	 * @return string	The resulting sample text extracted from some common resources' data fields.
-	 */
+        echo '<pre>';
+        print_r($this);
+        echo '</pre>';*/
+    }
+
+    /**
+     * Returns sample text based on the imported course content.
+     * This sample text is to be used for course language or encoding detection if there is missing (meta)data in the archive.
+     * @return string	The resulting sample text extracted from some common resources' data fields.
+     */
     public function get_sample_text()
     {
+        $sample_text = '';
+        foreach ($this->resources as $type => & $resources) {
+            if (count($resources) > 0) {
+                foreach ($resources as $id => & $resource) {
+                    $title = '';
+                    $description = '';
+                    switch ($type) {
+                        case RESOURCE_ANNOUNCEMENT:
+                            $title = $resource->title;
+                            $description = $resource->content;
+                            break;
+                        case RESOURCE_DOCUMENT:
+                            $title = $resource->title;
+                            $description = $resource->comment;
+                            break;
+                        case RESOURCE_EVENT:
+                            $title = $resource->title;
+                            $description = $resource->content;
+                            break;
+                        case RESOURCE_FORUM:
+                            $title = $resource->title;
+                            $description = $resource->description;
+                            break;
 
-		$sample_text = '';
-		foreach ($this->resources as $type => & $resources) {
-			if (count($resources) > 0) {
-				foreach ($resources as $id => & $resource) {
-					$title = '';
-					$description = '';
-
-					switch ($type) {
-						case RESOURCE_ANNOUNCEMENT:
-							$title = $resource->title;
-							$description = $resource->content;
-							break;
-						case RESOURCE_DOCUMENT:
-							$title = $resource->title;
-							$description = $resource->comment;
-							break;
-						case RESOURCE_EVENT:
-							$title = $resource->title;
-							$description = $resource->content;
-							break;
-						case RESOURCE_FORUM:
-							$title = $resource->title;
-							$description = $resource->description;
-							break;
-
-						case RESOURCE_FORUMCATEGORY:
-							$title = $resource->title;
-							$description = $resource->description;
-							break;
-						case RESOURCE_FORUMPOST:
-							$title = $resource->title;
-							$description = $resource->text;
-							break;
-						case RESOURCE_FORUMTOPIC:
-							$title = $resource->title;
-							break;
-						case RESOURCE_GLOSSARY:
-							$title = $resource->name;
-							$description = $resource->description;
-							break;
-						case RESOURCE_LEARNPATH:
-							$title = $resource->name;
-							$description = $resource->description;
-							break;
-						case RESOURCE_LINK:
-							$title = $resource->title;
-							$description = $resource->description;
-							break;
-						case RESOURCE_LINKCATEGORY:
-							$title = $resource->title;
-							$description = $resource->description;
-							break;
-						case RESOURCE_QUIZ:
-							$title = $resource->title;
-							$description = $resource->description;
-							break;
+                        case RESOURCE_FORUMCATEGORY:
+                            $title = $resource->title;
+                            $description = $resource->description;
+                            break;
+                        case RESOURCE_FORUMPOST:
+                            $title = $resource->title;
+                            $description = $resource->text;
+                            break;
+                        case RESOURCE_FORUMTOPIC:
+                            $title = $resource->title;
+                            break;
+                        case RESOURCE_GLOSSARY:
+                            $title = $resource->name;
+                            $description = $resource->description;
+                            break;
+                        case RESOURCE_LEARNPATH:
+                            $title = $resource->name;
+                            $description = $resource->description;
+                            break;
+                        case RESOURCE_LINK:
+                            $title = $resource->title;
+                            $description = $resource->description;
+                            break;
+                        case RESOURCE_LINKCATEGORY:
+                            $title = $resource->title;
+                            $description = $resource->description;
+                            break;
+                        case RESOURCE_QUIZ:
+                            $title = $resource->title;
+                            $description = $resource->description;
+                            break;
                         case RESOURCE_TEST_CATEGORY:
                             $title = $resource->title;
                             $description = $resource->description;
                             break;
-						case RESOURCE_QUIZQUESTION:
-							$title = $resource->question;
-							$description = $resource->description;
-							break;
-						case RESOURCE_SCORM:
-							$title = $resource->title;
-							break;
-						case RESOURCE_SURVEY:
-							$title = $resource->title;
-							$description = $resource->subtitle;
-							break;
-						case RESOURCE_SURVEYQUESTION:
-							$title = $resource->survey_question;
-							$description = $resource->survey_question_comment;
-							break;
-						case RESOURCE_TOOL_INTRO:
-							$description = $resource->intro_text;
-							break;
-						case RESOURCE_WIKI:
-							$title = $resource->title;
-							$description = $resource->content;
-							break;
-						case RESOURCE_THEMATIC:
-							$title 			= $resource->title;
-							$description 	= $resource->content;
-							break;
-						case RESOURCE_ATTENDANCE:
-							$title 			= $resource->params['name'];
-							$description 	= $resource->params['description'];
-							break;
+                        case RESOURCE_QUIZQUESTION:
+                            $title = $resource->question;
+                            $description = $resource->description;
+                            break;
+                        case RESOURCE_SCORM:
+                            $title = $resource->title;
+                            break;
+                        case RESOURCE_SURVEY:
+                            $title = $resource->title;
+                            $description = $resource->subtitle;
+                            break;
+                        case RESOURCE_SURVEYQUESTION:
+                            $title = $resource->survey_question;
+                            $description = $resource->survey_question_comment;
+                            break;
+                        case RESOURCE_TOOL_INTRO:
+                            $description = $resource->intro_text;
+                            break;
+                        case RESOURCE_WIKI:
+                            $title = $resource->title;
+                            $description = $resource->content;
+                            break;
+                        case RESOURCE_THEMATIC:
+                            $title 			= $resource->title;
+                            $description 	= $resource->content;
+                            break;
+                        case RESOURCE_ATTENDANCE:
+                            $title 			= $resource->params['name'];
+                            $description 	= $resource->params['description'];
+                            break;
                         case RESOURCE_WORK:
                             $title = $resource->title;
                             $description = $resource->description;
                             break;
-						default:
-							break;
-					}
-
-					$title = api_html_to_text($title);
-					$description = api_html_to_text($description);
-
-					if (!empty($title)) {
-						$sample_text .= $title."\n";
-					}
-					if (!empty($description)) {
-						$sample_text .= $description."\n";
-					}
-					if (!empty($title) || !empty($description)) {
-						$sample_text .= "\n";
-					}
-				}
-			}
-		}
-		return $sample_text;
-	}
-
-	/**
-	 * Converts to the system encoding all the language-sensitive fields in the imported course.
-	 */
-	public function to_system_encoding() {
-
-		if (api_equal_encodings($this->encoding, api_get_system_encoding())) {
-			return;
-		}
-
-		foreach ($this->resources as $type => & $resources) {
-			if (count($resources) > 0) {
-				foreach ($resources as $id => & $resource) {
-
-					switch ($type) {
-
-						case RESOURCE_ANNOUNCEMENT:
-							$resource->title = api_to_system_encoding($resource->title, $this->encoding);
-							$resource->content = api_to_system_encoding($resource->content, $this->encoding);
-							break;
-
-						case RESOURCE_DOCUMENT:
-							$resource->title = api_to_system_encoding($resource->title, $this->encoding);
-							$resource->comment = api_to_system_encoding($resource->comment, $this->encoding);
-							break;
-
-						case RESOURCE_EVENT:
-							$resource->title = api_to_system_encoding($resource->title, $this->encoding);
-							$resource->content = api_to_system_encoding($resource->content, $this->encoding);
-							break;
-
-						case RESOURCE_FORUM:
-							$resource->title = api_to_system_encoding($resource->title, $this->encoding);
-							$resource->description = api_to_system_encoding($resource->description, $this->encoding);
-							break;
-
-						case RESOURCE_FORUMCATEGORY:
-							$resource->title = api_to_system_encoding($resource->title, $this->encoding);
-							$resource->description = api_to_system_encoding($resource->description, $this->encoding);
-							break;
-
-						case RESOURCE_FORUMPOST:
-							$resource->title = api_to_system_encoding($resource->title, $this->encoding);
-							$resource->text = api_to_system_encoding($resource->text, $this->encoding);
-							$resource->poster_name = api_to_system_encoding($resource->poster_name, $this->encoding);
-							break;
-
-						case RESOURCE_FORUMTOPIC:
-							$resource->title = api_to_system_encoding($resource->title, $this->encoding);
-							$resource->topic_poster_name = api_to_system_encoding($resource->topic_poster_name, $this->encoding);
-							$resource->title_qualify = api_to_system_encoding($resource->title_qualify, $this->encoding);
-							break;
-
-						case RESOURCE_GLOSSARY:
-							$resource->name = api_to_system_encoding($resource->name, $this->encoding);
-							$resource->description = api_to_system_encoding($resource->description, $this->encoding);
-							break;
-
-						case RESOURCE_LEARNPATH:
-							$resource->name = api_to_system_encoding($resource->name, $this->encoding);
-							$resource->description = api_to_system_encoding($resource->description, $this->encoding);
-							$resource->content_maker = api_to_system_encoding($resource->content_maker, $this->encoding);
-							$resource->content_license = api_to_system_encoding($resource->content_license, $this->encoding);
-							//$resource->author = api_to_system_encoding($resource->author, $this->encoding);  // Needs implamantation.
-							break;
-
-						case RESOURCE_LINK:
-							$resource->title = api_to_system_encoding($resource->title, $this->encoding);
-							$resource->description = api_to_system_encoding($resource->description, $this->encoding);
-							break;
-
-						case RESOURCE_LINKCATEGORY:
-							$resource->title = api_to_system_encoding($resource->title, $this->encoding);
-							$resource->description = api_to_system_encoding($resource->description, $this->encoding);
-							break;
-
-						case RESOURCE_QUIZ:
-							$resource->title = api_to_system_encoding($resource->title, $this->encoding);
-							$resource->description = api_to_system_encoding($resource->description, $this->encoding);
-							break;
-
-						case RESOURCE_QUIZQUESTION:
-							$resource->question = api_to_system_encoding($resource->question, $this->encoding);
-							$resource->description = api_to_system_encoding($resource->description, $this->encoding);
-							if (is_array($resource->answers) && count($resource->answers) > 0) {
-								foreach ($resource->answers as $index => & $answer) {
-									$answer['answer'] = api_to_system_encoding($answer['answer'], $this->encoding);
-									$answer['comment'] = api_to_system_encoding($answer['comment'], $this->encoding);
-								}
-							}
-							break;
+                        default:
+                            break;
+                    }
+
+                    $title = api_html_to_text($title);
+                    $description = api_html_to_text($description);
+
+                    if (!empty($title)) {
+                        $sample_text .= $title."\n";
+                    }
+                    if (!empty($description)) {
+                        $sample_text .= $description."\n";
+                    }
+                    if (!empty($title) || !empty($description)) {
+                        $sample_text .= "\n";
+                    }
+                }
+            }
+        }
+        return $sample_text;
+    }
+
+    /**
+     * Converts to the system encoding all the language-sensitive fields in the imported course.
+     */
+    public function to_system_encoding()
+    {
+        if (api_equal_encodings($this->encoding, api_get_system_encoding())) {
+            return;
+        }
+
+        foreach ($this->resources as $type => & $resources) {
+            if (count($resources) > 0) {
+                foreach ($resources as $id => & $resource) {
+                    switch ($type) {
+                        case RESOURCE_ANNOUNCEMENT:
+                            $resource->title = api_to_system_encoding($resource->title, $this->encoding);
+                            $resource->content = api_to_system_encoding($resource->content, $this->encoding);
+                            break;
+
+                        case RESOURCE_DOCUMENT:
+                            $resource->title = api_to_system_encoding($resource->title, $this->encoding);
+                            $resource->comment = api_to_system_encoding($resource->comment, $this->encoding);
+                            break;
+
+                        case RESOURCE_EVENT:
+                            $resource->title = api_to_system_encoding($resource->title, $this->encoding);
+                            $resource->content = api_to_system_encoding($resource->content, $this->encoding);
+                            break;
+
+                        case RESOURCE_FORUM:
+                            $resource->title = api_to_system_encoding($resource->title, $this->encoding);
+                            $resource->description = api_to_system_encoding($resource->description, $this->encoding);
+                            break;
+
+                        case RESOURCE_FORUMCATEGORY:
+                            $resource->title = api_to_system_encoding($resource->title, $this->encoding);
+                            $resource->description = api_to_system_encoding($resource->description, $this->encoding);
+                            break;
+
+                        case RESOURCE_FORUMPOST:
+                            $resource->title = api_to_system_encoding($resource->title, $this->encoding);
+                            $resource->text = api_to_system_encoding($resource->text, $this->encoding);
+                            $resource->poster_name = api_to_system_encoding($resource->poster_name, $this->encoding);
+                            break;
+
+                        case RESOURCE_FORUMTOPIC:
+                            $resource->title = api_to_system_encoding($resource->title, $this->encoding);
+                            $resource->topic_poster_name = api_to_system_encoding($resource->topic_poster_name, $this->encoding);
+                            $resource->title_qualify = api_to_system_encoding($resource->title_qualify, $this->encoding);
+                            break;
+
+                        case RESOURCE_GLOSSARY:
+                            $resource->name = api_to_system_encoding($resource->name, $this->encoding);
+                            $resource->description = api_to_system_encoding($resource->description, $this->encoding);
+                            break;
+
+                        case RESOURCE_LEARNPATH:
+                            $resource->name = api_to_system_encoding($resource->name, $this->encoding);
+                            $resource->description = api_to_system_encoding($resource->description, $this->encoding);
+                            $resource->content_maker = api_to_system_encoding($resource->content_maker, $this->encoding);
+                            $resource->content_license = api_to_system_encoding($resource->content_license, $this->encoding);
+                            //$resource->author = api_to_system_encoding($resource->author, $this->encoding);  // Needs implamantation.
+                            break;
+
+                        case RESOURCE_LINK:
+                            $resource->title = api_to_system_encoding($resource->title, $this->encoding);
+                            $resource->description = api_to_system_encoding($resource->description, $this->encoding);
+                            break;
+
+                        case RESOURCE_LINKCATEGORY:
+                            $resource->title = api_to_system_encoding($resource->title, $this->encoding);
+                            $resource->description = api_to_system_encoding($resource->description, $this->encoding);
+                            break;
+
+                        case RESOURCE_QUIZ:
+                            $resource->title = api_to_system_encoding($resource->title, $this->encoding);
+                            $resource->description = api_to_system_encoding($resource->description, $this->encoding);
+                            break;
+
+                        case RESOURCE_QUIZQUESTION:
+                            $resource->question = api_to_system_encoding($resource->question, $this->encoding);
+                            $resource->description = api_to_system_encoding($resource->description, $this->encoding);
+                            if (is_array($resource->answers) && count($resource->answers) > 0) {
+                                foreach ($resource->answers as $index => & $answer) {
+                                    $answer['answer'] = api_to_system_encoding($answer['answer'], $this->encoding);
+                                    $answer['comment'] = api_to_system_encoding($answer['comment'], $this->encoding);
+                                }
+                            }
+                            break;
 
                         case RESOURCE_TEST_CATEGORY:
                             $resource->title = api_to_system_encoding($resource->title, $this->encoding);
                             $resource->description = api_to_system_encoding($resource->description, $this->encoding);
                             break;
-						case RESOURCE_SCORM:
-							$resource->title = api_to_system_encoding($resource->title, $this->encoding);
-							break;
-
-						case RESOURCE_SURVEY:
-							$resource->title = api_to_system_encoding($resource->title, $this->encoding);
-							$resource->subtitle = api_to_system_encoding($resource->subtitle, $this->encoding);
-							$resource->author = api_to_system_encoding($resource->author, $this->encoding);
-							$resource->intro = api_to_system_encoding($resource->intro, $this->encoding);
-							$resource->surveythanks = api_to_system_encoding($resource->surveythanks, $this->encoding);
-							break;
-
-						case RESOURCE_SURVEYQUESTION:
-							$resource->survey_question = api_to_system_encoding($resource->survey_question, $this->encoding);
-							$resource->survey_question_comment = api_to_system_encoding($resource->survey_question_comment, $this->encoding);
-							break;
-
-						case RESOURCE_TOOL_INTRO:
-							$resource->intro_text = api_to_system_encoding($resource->intro_text, $this->encoding);
-							break;
-
-						case RESOURCE_WIKI:
-							$resource->title = api_to_system_encoding($resource->title, $this->encoding);
-							$resource->content = api_to_system_encoding($resource->content, $this->encoding);
-							$resource->reflink = api_to_system_encoding($resource->reflink, $this->encoding);
-							break;
+                        case RESOURCE_SCORM:
+                            $resource->title = api_to_system_encoding($resource->title, $this->encoding);
+                            break;
+
+                        case RESOURCE_SURVEY:
+                            $resource->title = api_to_system_encoding($resource->title, $this->encoding);
+                            $resource->subtitle = api_to_system_encoding($resource->subtitle, $this->encoding);
+                            $resource->author = api_to_system_encoding($resource->author, $this->encoding);
+                            $resource->intro = api_to_system_encoding($resource->intro, $this->encoding);
+                            $resource->surveythanks = api_to_system_encoding($resource->surveythanks, $this->encoding);
+                            break;
+
+                        case RESOURCE_SURVEYQUESTION:
+                            $resource->survey_question = api_to_system_encoding($resource->survey_question, $this->encoding);
+                            $resource->survey_question_comment = api_to_system_encoding($resource->survey_question_comment, $this->encoding);
+                            break;
+
+                        case RESOURCE_TOOL_INTRO:
+                            $resource->intro_text = api_to_system_encoding($resource->intro_text, $this->encoding);
+                            break;
+
+                        case RESOURCE_WIKI:
+                            $resource->title = api_to_system_encoding($resource->title, $this->encoding);
+                            $resource->content = api_to_system_encoding($resource->content, $this->encoding);
+                            $resource->reflink = api_to_system_encoding($resource->reflink, $this->encoding);
+                            break;
                         case RESOURCE_WORK:
                             $resource->url = api_to_system_encoding($resource->url, $this->encoding);
                             $resource->title = api_to_system_encoding($resource->title, $this->encoding);
                             $resource->description = api_to_system_encoding($resource->description, $this->encoding);
                             break;
-						default:
-							break;
-					}
-				}
-			}
-		}
-		$this->encoding = api_get_system_encoding();
-	}
+                        default:
+                            break;
+                    }
+                }
+            }
+        }
+        $this->encoding = api_get_system_encoding();
+    }
 
     /**
-	* Serialize the course with the best serializer available
-	*/
+    * Serialize the course with the best serializer available
+    */
     public static function serialize($course)
     {
-		if (extension_loaded('igbinary')) {
-			return igbinary_serialize($course);
-		} else {
-			return serialize($course);
+        if (extension_loaded('igbinary')) {
+            return igbinary_serialize($course);
+        } else {
+            return serialize($course);
         }
-	}
+    }
 
-	/**
-	* Unserialize the course with the best serializer available
-	*/
+    /**
+    * Unserialize the course with the best serializer available
+    */
     public static function unserialize($course)
     {
-		if (extension_loaded('igbinary')) {
-			return igbinary_unserialize($course);
-		} else {
-			return unserialize($course);
-		}
-	}
+        if (extension_loaded('igbinary')) {
+            return igbinary_unserialize($course);
+        } else {
+            return unserialize($course);
+        }
+    }
 }

+ 1 - 1
main/coursecopy/classes/CourseRestorer.class.php

@@ -108,7 +108,7 @@ class CourseRestorer
 	 * Set the file-option
 	 * @param constant $options What to do with files with same name (FILE_SKIP, FILE_RENAME or FILE_OVERWRITE)
 	 */
-    function set_file_option($option=FILE_OVERWRITE)
+    function set_file_option($option = FILE_OVERWRITE)
     {
 		$this->file_option = $option;
 	}

+ 1 - 1
main/create_course/add_course.php

@@ -219,7 +219,7 @@ if ($form->validate()) {
             $params['title']                = $title;
             $params['exemplary_content']    = $exemplary_content;
             $params['wanted_code']          = $wanted_code;
-            $params['category_code']        = $category_code;
+            $params['course_category']        = $category_code;
             $params['course_language']      = $course_language;
             $params['gradebook_model_id']   = isset($course_values['gradebook_model_id']) ? $course_values['gradebook_model_id'] : null;
 

+ 163 - 0
main/css/academica/scorm.css

@@ -1,3 +1,166 @@
+/* copy of default_scorm.css */
+
+.inner_lp_toc {
+    overflow: auto;
+    background-color: white;
+    height: 210px;
+}
+
+.inner_lp_toc .scorm_item a {
+    font-weight: bold;
+    font-size: 14px;
+    margin-right: 1px;
+    padding-bottom: 2px;
+    text-decoration: none;
+    color: #2F3E46;
+}
+
+.inner_lp_toc .scorm_item a.chapter_module {
+    font-weight: normal;
+    margin-right: 10px;
+}
+.inner_lp_toc .scorm_item_highlight {
+    border: 1px solid #999;
+    background:#999;
+    font-weight:bold;
+    text-shadow:0 -1px 1px #666;
+    background-image:-webkit-gradient(linear,left top,left bottom,from(#666),to(#999));
+    background-image:-webkit-linear-gradient(top,#666,#999);
+    background-image:-moz-linear-gradient(top,#666,#999);
+    background-image:-ms-linear-gradient(top,#666,#999);
+    background-image:-o-linear-gradient(top,#666,#999);
+    background-image:linear-gradient(top,#666,#999);
+    margin-right: 0px;
+    padding: 10px 0px 10px 0px;
+    text-decoration: none;
+}
+
+.inner_lp_toc .scorm_item_highlight a {
+    color:#fff;
+    margin-right: 1px;
+    text-decoration: none;
+    font-weight: bold;
+}
+
+.inner_lp_toc .scorm_item_section {
+    border:1px solid #222;
+    background:#333;
+    font-weight:bold;
+    color:#fff;
+    text-shadow:0 -1px 1px #000;
+    background-image:-webkit-gradient(linear,left top,left bottom,from(#555),to(#333));
+    background-image:-webkit-linear-gradient(top,#555,#333);
+    background-image:-moz-linear-gradient(top,#555,#333);
+    background-image:-ms-linear-gradient(top,#555,#333);
+    background-image:-o-linear-gradient(top,#555,#333);
+    background-image:linear-gradient(top,#555,#333);
+    margin-right: 1px;
+    padding: 10px 0px 10px 0px;
+    text-decoration: none;
+}
+
+.inner_lp_toc .scorm_item {
+    font-size: 16px;
+    margin-left: 10px;
+    margin-right:10px;
+    text-decoration: none;
+    border-color: rgba(255, 255, 255, 0.3);
+}
+
+.inner_lp_toc .scorm_item_1 {
+    border-bottom: 1px solid #CCCCCC;
+    background:#eee;
+    font-weight:bold;
+    color:#444;
+    text-shadow:0 1px 1px #f6f6f6;
+    background-image:-webkit-gradient(linear,left top,left bottom,from(#fdfdfd),to(#eee));
+    background-image:-webkit-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-moz-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-ms-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-o-linear-gradient(top,#fdfdfd,#eee);
+    background-image:linear-gradient(top,#fdfdfd,#eee);
+    margin-right: 1px;
+    padding: 10px 0px 10px 0px;
+    text-decoration: none;
+    font-weight: normal;
+    background:#FDFDFD;
+}
+
+.inner_lp_toc .scorm_item_2 {
+    background-image:-webkit-gradient(linear,left top,left bottom,from(#fdfdfd),to(#eee));
+    background-image:-webkit-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-moz-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-ms-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-o-linear-gradient(top,#fdfdfd,#eee);
+    background-image:linear-gradient(top,#fdfdfd,#eee);
+    border-bottom: 1px solid #CCCCCC;
+    color: #444444;
+    font-weight: bold;
+    text-shadow: 0 1px 1px #F6F6F6;
+    margin-right: 1px;
+    padding: 10px 0px 10px 0px;
+    text-decoration: none;
+    font-weight: normal;
+}
+
+.inner_lp_toc .scorm_item_section .scorm_item:before
+{
+    content : url('../../img/lp_section.png');  /* from main/newscorm/lp_controller.php file */
+    vertical-align: text-top;
+    margin-right : 5px;
+}
+
+.scorm_section_level_0 {
+    padding : 0 0 0 0;
+}
+
+.scorm_section_level_1 {
+    padding : 0 0.5em 0 2em;
+}
+
+.scorm_section_level_2 {
+    padding : 0 0.5em 0 4em;
+}
+
+.scorm_section_level_3 {
+    padding : 0 0.5em 0 6em;
+}
+
+.scorm_section_level_4 {
+    padding : 0 0.5em 0 8em;
+}
+
+.scorm_section_level_5 {
+    padding : 0 0.5em 0 10em;
+}
+
+.scorm_item_level_0 {
+    padding : 0 0 0 0;
+}
+
+.scorm_item_level_1 {
+    padding : 0 0.5em 0 1.5em;
+}
+
+.scorm_item_level_2 {
+    padding : 0 0.5em 0 3em;
+}
+
+.scorm_item_level_3 {
+    padding : 0 0.5em 0 4.5em;
+}
+
+.scorm_item_level_4 {
+    padding : 0 0.5em 0 6em;
+}
+
+.scorm_item_level_5 {
+    padding : 0 0.5em 0 7.5em;
+}
+
+/* end of copy of default_scorm.css */
+
+
 .scormpage {
 	height: 100%;
 }

+ 163 - 0
main/css/baby_orange/scorm.css

@@ -1,3 +1,166 @@
+/* copy of default_scorm.css */
+
+.inner_lp_toc {
+    overflow: auto;
+    background-color: white;
+    height: 210px;
+}
+
+.inner_lp_toc .scorm_item a {
+    font-weight: bold;
+    font-size: 14px;
+    margin-right: 1px;
+    padding-bottom: 2px;
+    text-decoration: none;
+    color: #2F3E46;
+}
+
+.inner_lp_toc .scorm_item a.chapter_module {
+    font-weight: normal;
+    margin-right: 10px;
+}
+.inner_lp_toc .scorm_item_highlight {
+    border: 1px solid #999;
+    background:#999;
+    font-weight:bold;
+    text-shadow:0 -1px 1px #666;
+    background-image:-webkit-gradient(linear,left top,left bottom,from(#666),to(#999));
+    background-image:-webkit-linear-gradient(top,#666,#999);
+    background-image:-moz-linear-gradient(top,#666,#999);
+    background-image:-ms-linear-gradient(top,#666,#999);
+    background-image:-o-linear-gradient(top,#666,#999);
+    background-image:linear-gradient(top,#666,#999);
+    margin-right: 0px;
+    padding: 10px 0px 10px 0px;
+    text-decoration: none;
+}
+
+.inner_lp_toc .scorm_item_highlight a {
+    color:#fff;
+    margin-right: 1px;
+    text-decoration: none;
+    font-weight: bold;
+}
+
+.inner_lp_toc .scorm_item_section {
+    border:1px solid #222;
+    background:#333;
+    font-weight:bold;
+    color:#fff;
+    text-shadow:0 -1px 1px #000;
+    background-image:-webkit-gradient(linear,left top,left bottom,from(#555),to(#333));
+    background-image:-webkit-linear-gradient(top,#555,#333);
+    background-image:-moz-linear-gradient(top,#555,#333);
+    background-image:-ms-linear-gradient(top,#555,#333);
+    background-image:-o-linear-gradient(top,#555,#333);
+    background-image:linear-gradient(top,#555,#333);
+    margin-right: 1px;
+    padding: 10px 0px 10px 0px;
+    text-decoration: none;
+}
+
+.inner_lp_toc .scorm_item {
+    font-size: 16px;
+    margin-left: 10px;
+    margin-right:10px;
+    text-decoration: none;
+    border-color: rgba(255, 255, 255, 0.3);
+}
+
+.inner_lp_toc .scorm_item_1 {
+    border-bottom: 1px solid #CCCCCC;
+    background:#eee;
+    font-weight:bold;
+    color:#444;
+    text-shadow:0 1px 1px #f6f6f6;
+    background-image:-webkit-gradient(linear,left top,left bottom,from(#fdfdfd),to(#eee));
+    background-image:-webkit-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-moz-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-ms-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-o-linear-gradient(top,#fdfdfd,#eee);
+    background-image:linear-gradient(top,#fdfdfd,#eee);
+    margin-right: 1px;
+    padding: 10px 0px 10px 0px;
+    text-decoration: none;
+    font-weight: normal;
+    background:#FDFDFD;
+}
+
+.inner_lp_toc .scorm_item_2 {
+    background-image:-webkit-gradient(linear,left top,left bottom,from(#fdfdfd),to(#eee));
+    background-image:-webkit-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-moz-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-ms-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-o-linear-gradient(top,#fdfdfd,#eee);
+    background-image:linear-gradient(top,#fdfdfd,#eee);
+    border-bottom: 1px solid #CCCCCC;
+    color: #444444;
+    font-weight: bold;
+    text-shadow: 0 1px 1px #F6F6F6;
+    margin-right: 1px;
+    padding: 10px 0px 10px 0px;
+    text-decoration: none;
+    font-weight: normal;
+}
+
+.inner_lp_toc .scorm_item_section .scorm_item:before
+{
+    content : url('../../img/lp_section.png');  /* from main/newscorm/lp_controller.php file */
+    vertical-align: text-top;
+    margin-right : 5px;
+}
+
+.scorm_section_level_0 {
+    padding : 0 0 0 0;
+}
+
+.scorm_section_level_1 {
+    padding : 0 0.5em 0 2em;
+}
+
+.scorm_section_level_2 {
+    padding : 0 0.5em 0 4em;
+}
+
+.scorm_section_level_3 {
+    padding : 0 0.5em 0 6em;
+}
+
+.scorm_section_level_4 {
+    padding : 0 0.5em 0 8em;
+}
+
+.scorm_section_level_5 {
+    padding : 0 0.5em 0 10em;
+}
+
+.scorm_item_level_0 {
+    padding : 0 0 0 0;
+}
+
+.scorm_item_level_1 {
+    padding : 0 0.5em 0 1.5em;
+}
+
+.scorm_item_level_2 {
+    padding : 0 0.5em 0 3em;
+}
+
+.scorm_item_level_3 {
+    padding : 0 0.5em 0 4.5em;
+}
+
+.scorm_item_level_4 {
+    padding : 0 0.5em 0 6em;
+}
+
+.scorm_item_level_5 {
+    padding : 0 0.5em 0 7.5em;
+}
+
+/* end of copy of default_scorm.css */
+
+
 .scormpage {
 	height: 100%;
 }

+ 0 - 111
main/css/base.css

@@ -4075,122 +4075,11 @@ footer {
     margin:0;
 }
 
-#scorm_title {
-    background: none repeat scroll 0 0 #EEEEEE;
-    color: #444444;
-    font-size: 16px;
-    font-weight: bold;
-    padding: 1px 5px 3px 8px;
-}
 
 .progresstext {
     text-align: center;
 }
 
-.inner_lp_toc {
-    overflow: auto;
-    background-color: white;
-    height: 210px;
-}
-
-.inner_lp_toc .scorm_item a {
-    font-weight: bold;
-    font-size: 14px;
-    margin-right: 1px;
-    padding-bottom: 2px;
-    text-decoration: none;
-    color: #2F3E46;
-}
-
-.inner_lp_toc .scorm_item a.chapter_module {
-    font-weight: normal;
-    margin-right: 10px;
-}
-.inner_lp_toc .scorm_item_highlight {
-    border: 1px solid #999;
-    background:#999;
-    font-weight:bold;
-    text-shadow:0 -1px 1px #666;
-    background-image:-webkit-gradient(linear,left top,left bottom,from(#666),to(#999));
-    background-image:-webkit-linear-gradient(top,#666,#999);
-    background-image:-moz-linear-gradient(top,#666,#999);
-    background-image:-ms-linear-gradient(top,#666,#999);
-    background-image:-o-linear-gradient(top,#666,#999);
-    background-image:linear-gradient(top,#666,#999);
-    margin-right: 0px;
-    padding: 10px 0px 10px 0px;
-    text-decoration: none;
-}
-
-.inner_lp_toc .scorm_item_highlight a {
-    color:#fff;
-    margin-right: 1px;
-    text-decoration: none;
-    font-weight: bold;
-}
-
-.inner_lp_toc .scorm_item_section {
-    border:1px solid #222;
-    background:#333;
-    font-weight:bold;
-    color:#fff;
-    text-shadow:0 -1px 1px #000;
-    background-image:-webkit-gradient(linear,left top,left bottom,from(#555),to(#333));
-    background-image:-webkit-linear-gradient(top,#555,#333);
-    background-image:-moz-linear-gradient(top,#555,#333);
-    background-image:-ms-linear-gradient(top,#555,#333);
-    background-image:-o-linear-gradient(top,#555,#333);
-    background-image:linear-gradient(top,#555,#333);
-    margin-right: 1px;
-    padding: 10px 0px 10px 0px;
-    text-decoration: none;
-
-}
-
-.inner_lp_toc .scorm_item {
-    font-size: 16px;
-    margin-left: 10px;
-    margin-right:10px;
-    text-decoration: none;
-    border-color: rgba(255, 255, 255, 0.3);
-}
-
-.inner_lp_toc .scorm_item_1 {
-    border-bottom: 1px solid #CCCCCC;
-    background:#eee;
-    font-weight:bold;
-    color:#444;
-    text-shadow:0 1px 1px #f6f6f6;
-    background-image:-webkit-gradient(linear,left top,left bottom,from(#fdfdfd),to(#eee));
-    background-image:-webkit-linear-gradient(top,#fdfdfd,#eee);
-    background-image:-moz-linear-gradient(top,#fdfdfd,#eee);
-    background-image:-ms-linear-gradient(top,#fdfdfd,#eee);
-    background-image:-o-linear-gradient(top,#fdfdfd,#eee);
-    background-image:linear-gradient(top,#fdfdfd,#eee);
-    margin-right: 1px;
-    padding: 10px 0px 10px 0px;
-    text-decoration: none;
-    font-weight: normal;
-    /* background:#FDFDFD; */
-}
-
-.inner_lp_toc .scorm_item_2 {
-    background-image:-webkit-gradient(linear,left top,left bottom,from(#fdfdfd),to(#eee));
-    background-image:-webkit-linear-gradient(top,#fdfdfd,#eee);
-    background-image:-moz-linear-gradient(top,#fdfdfd,#eee);
-    background-image:-ms-linear-gradient(top,#fdfdfd,#eee);
-    background-image:-o-linear-gradient(top,#fdfdfd,#eee);
-    background-image:linear-gradient(top,#fdfdfd,#eee);
-    border-bottom: 1px solid #CCCCCC;
-    color: #444444;
-    font-weight: bold;
-    text-shadow: 0 1px 1px #F6F6F6;
-    margin-right: 1px;
-    padding: 10px 0px 10px 0px;
-    text-decoration: none;
-    font-weight: normal;
-}
-
 .ui-state-highlight_lp {
     border: 1px solid #FEAA18;
     background: #FFB738;

+ 163 - 0
main/css/blue_lagoon/scorm.css

@@ -1,3 +1,166 @@
+/* copy of default_scorm.css */
+
+.inner_lp_toc {
+    overflow: auto;
+    background-color: white;
+    height: 210px;
+}
+
+.inner_lp_toc .scorm_item a {
+    font-weight: bold;
+    font-size: 14px;
+    margin-right: 1px;
+    padding-bottom: 2px;
+    text-decoration: none;
+    color: #2F3E46;
+}
+
+.inner_lp_toc .scorm_item a.chapter_module {
+    font-weight: normal;
+    margin-right: 10px;
+}
+.inner_lp_toc .scorm_item_highlight {
+    border: 1px solid #999;
+    background:#999;
+    font-weight:bold;
+    text-shadow:0 -1px 1px #666;
+    background-image:-webkit-gradient(linear,left top,left bottom,from(#666),to(#999));
+    background-image:-webkit-linear-gradient(top,#666,#999);
+    background-image:-moz-linear-gradient(top,#666,#999);
+    background-image:-ms-linear-gradient(top,#666,#999);
+    background-image:-o-linear-gradient(top,#666,#999);
+    background-image:linear-gradient(top,#666,#999);
+    margin-right: 0px;
+    padding: 10px 0px 10px 0px;
+    text-decoration: none;
+}
+
+.inner_lp_toc .scorm_item_highlight a {
+    color:#fff;
+    margin-right: 1px;
+    text-decoration: none;
+    font-weight: bold;
+}
+
+.inner_lp_toc .scorm_item_section {
+    border:1px solid #222;
+    background:#333;
+    font-weight:bold;
+    color:#fff;
+    text-shadow:0 -1px 1px #000;
+    background-image:-webkit-gradient(linear,left top,left bottom,from(#555),to(#333));
+    background-image:-webkit-linear-gradient(top,#555,#333);
+    background-image:-moz-linear-gradient(top,#555,#333);
+    background-image:-ms-linear-gradient(top,#555,#333);
+    background-image:-o-linear-gradient(top,#555,#333);
+    background-image:linear-gradient(top,#555,#333);
+    margin-right: 1px;
+    padding: 10px 0px 10px 0px;
+    text-decoration: none;
+}
+
+.inner_lp_toc .scorm_item {
+    font-size: 16px;
+    margin-left: 10px;
+    margin-right:10px;
+    text-decoration: none;
+    border-color: rgba(255, 255, 255, 0.3);
+}
+
+.inner_lp_toc .scorm_item_1 {
+    border-bottom: 1px solid #CCCCCC;
+    background:#eee;
+    font-weight:bold;
+    color:#444;
+    text-shadow:0 1px 1px #f6f6f6;
+    background-image:-webkit-gradient(linear,left top,left bottom,from(#fdfdfd),to(#eee));
+    background-image:-webkit-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-moz-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-ms-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-o-linear-gradient(top,#fdfdfd,#eee);
+    background-image:linear-gradient(top,#fdfdfd,#eee);
+    margin-right: 1px;
+    padding: 10px 0px 10px 0px;
+    text-decoration: none;
+    font-weight: normal;
+    background:#FDFDFD;
+}
+
+.inner_lp_toc .scorm_item_2 {
+    background-image:-webkit-gradient(linear,left top,left bottom,from(#fdfdfd),to(#eee));
+    background-image:-webkit-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-moz-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-ms-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-o-linear-gradient(top,#fdfdfd,#eee);
+    background-image:linear-gradient(top,#fdfdfd,#eee);
+    border-bottom: 1px solid #CCCCCC;
+    color: #444444;
+    font-weight: bold;
+    text-shadow: 0 1px 1px #F6F6F6;
+    margin-right: 1px;
+    padding: 10px 0px 10px 0px;
+    text-decoration: none;
+    font-weight: normal;
+}
+
+.inner_lp_toc .scorm_item_section .scorm_item:before
+{
+    content : url('../../img/lp_section.png');  /* from main/newscorm/lp_controller.php file */
+    vertical-align: text-top;
+    margin-right : 5px;
+}
+
+.scorm_section_level_0 {
+    padding : 0 0 0 0;
+}
+
+.scorm_section_level_1 {
+    padding : 0 0.5em 0 2em;
+}
+
+.scorm_section_level_2 {
+    padding : 0 0.5em 0 4em;
+}
+
+.scorm_section_level_3 {
+    padding : 0 0.5em 0 6em;
+}
+
+.scorm_section_level_4 {
+    padding : 0 0.5em 0 8em;
+}
+
+.scorm_section_level_5 {
+    padding : 0 0.5em 0 10em;
+}
+
+.scorm_item_level_0 {
+    padding : 0 0 0 0;
+}
+
+.scorm_item_level_1 {
+    padding : 0 0.5em 0 1.5em;
+}
+
+.scorm_item_level_2 {
+    padding : 0 0.5em 0 3em;
+}
+
+.scorm_item_level_3 {
+    padding : 0 0.5em 0 4.5em;
+}
+
+.scorm_item_level_4 {
+    padding : 0 0.5em 0 6em;
+}
+
+.scorm_item_level_5 {
+    padding : 0 0.5em 0 7.5em;
+}
+
+/* end of copy of default_scorm.css */
+
+
 .scormpage {
 	height: 100%;
 }

+ 163 - 0
main/css/chamilo/scorm.css

@@ -1,3 +1,166 @@
+/* copy of default_scorm.css */
+
+.inner_lp_toc {
+    overflow: auto;
+    background-color: white;
+    height: 210px;
+}
+
+.inner_lp_toc .scorm_item a {
+    font-weight: bold;
+    font-size: 14px;
+    margin-right: 1px;
+    padding-bottom: 2px;
+    text-decoration: none;
+    color: #2F3E46;
+}
+
+.inner_lp_toc .scorm_item a.chapter_module {
+    font-weight: normal;
+    margin-right: 10px;
+}
+.inner_lp_toc .scorm_item_highlight {
+    border: 1px solid #999;
+    background:#999;
+    font-weight:bold;
+    text-shadow:0 -1px 1px #666;
+    background-image:-webkit-gradient(linear,left top,left bottom,from(#666),to(#999));
+    background-image:-webkit-linear-gradient(top,#666,#999);
+    background-image:-moz-linear-gradient(top,#666,#999);
+    background-image:-ms-linear-gradient(top,#666,#999);
+    background-image:-o-linear-gradient(top,#666,#999);
+    background-image:linear-gradient(top,#666,#999);
+    margin-right: 0px;
+    padding: 10px 0px 10px 0px;
+    text-decoration: none;
+}
+
+.inner_lp_toc .scorm_item_highlight a {
+    color:#fff;
+    margin-right: 1px;
+    text-decoration: none;
+    font-weight: bold;
+}
+
+.inner_lp_toc .scorm_item_section {
+    border:1px solid #222;
+    background:#333;
+    font-weight:bold;
+    color:#fff;
+    text-shadow:0 -1px 1px #000;
+    background-image:-webkit-gradient(linear,left top,left bottom,from(#555),to(#333));
+    background-image:-webkit-linear-gradient(top,#555,#333);
+    background-image:-moz-linear-gradient(top,#555,#333);
+    background-image:-ms-linear-gradient(top,#555,#333);
+    background-image:-o-linear-gradient(top,#555,#333);
+    background-image:linear-gradient(top,#555,#333);
+    margin-right: 1px;
+    padding: 10px 0px 10px 0px;
+    text-decoration: none;
+}
+
+.inner_lp_toc .scorm_item {
+    font-size: 16px;
+    margin-left: 10px;
+    margin-right:10px;
+    text-decoration: none;
+    border-color: rgba(255, 255, 255, 0.3);
+}
+
+.inner_lp_toc .scorm_item_1 {
+    border-bottom: 1px solid #CCCCCC;
+    background:#eee;
+    font-weight:bold;
+    color:#444;
+    text-shadow:0 1px 1px #f6f6f6;
+    background-image:-webkit-gradient(linear,left top,left bottom,from(#fdfdfd),to(#eee));
+    background-image:-webkit-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-moz-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-ms-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-o-linear-gradient(top,#fdfdfd,#eee);
+    background-image:linear-gradient(top,#fdfdfd,#eee);
+    margin-right: 1px;
+    padding: 10px 0px 10px 0px;
+    text-decoration: none;
+    font-weight: normal;
+    background:#FDFDFD;
+}
+
+.inner_lp_toc .scorm_item_2 {
+    background-image:-webkit-gradient(linear,left top,left bottom,from(#fdfdfd),to(#eee));
+    background-image:-webkit-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-moz-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-ms-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-o-linear-gradient(top,#fdfdfd,#eee);
+    background-image:linear-gradient(top,#fdfdfd,#eee);
+    border-bottom: 1px solid #CCCCCC;
+    color: #444444;
+    font-weight: bold;
+    text-shadow: 0 1px 1px #F6F6F6;
+    margin-right: 1px;
+    padding: 10px 0px 10px 0px;
+    text-decoration: none;
+    font-weight: normal;
+}
+
+.inner_lp_toc .scorm_item_section .scorm_item:before
+{
+    content : url('../../img/lp_section.png');  /* from main/newscorm/lp_controller.php file */
+    vertical-align: text-top;
+    margin-right : 5px;
+}
+
+.scorm_section_level_0 {
+    padding : 0 0 0 0;
+}
+
+.scorm_section_level_1 {
+    padding : 0 0.5em 0 2em;
+}
+
+.scorm_section_level_2 {
+    padding : 0 0.5em 0 4em;
+}
+
+.scorm_section_level_3 {
+    padding : 0 0.5em 0 6em;
+}
+
+.scorm_section_level_4 {
+    padding : 0 0.5em 0 8em;
+}
+
+.scorm_section_level_5 {
+    padding : 0 0.5em 0 10em;
+}
+
+.scorm_item_level_0 {
+    padding : 0 0 0 0;
+}
+
+.scorm_item_level_1 {
+    padding : 0 0.5em 0 1.5em;
+}
+
+.scorm_item_level_2 {
+    padding : 0 0.5em 0 3em;
+}
+
+.scorm_item_level_3 {
+    padding : 0 0.5em 0 4.5em;
+}
+
+.scorm_item_level_4 {
+    padding : 0 0.5em 0 6em;
+}
+
+.scorm_item_level_5 {
+    padding : 0 0.5em 0 7.5em;
+}
+
+/* end of copy of default_scorm.css */
+
+
 .scormpage {
     height: 100%;
 }

+ 163 - 0
main/css/chamilo_electric_blue/scorm.css

@@ -1,3 +1,166 @@
+/* copy of default_scorm.css */
+
+.inner_lp_toc {
+    overflow: auto;
+    background-color: white;
+    height: 210px;
+}
+
+.inner_lp_toc .scorm_item a {
+    font-weight: bold;
+    font-size: 14px;
+    margin-right: 1px;
+    padding-bottom: 2px;
+    text-decoration: none;
+    color: #2F3E46;
+}
+
+.inner_lp_toc .scorm_item a.chapter_module {
+    font-weight: normal;
+    margin-right: 10px;
+}
+.inner_lp_toc .scorm_item_highlight {
+    border: 1px solid #999;
+    background:#999;
+    font-weight:bold;
+    text-shadow:0 -1px 1px #666;
+    background-image:-webkit-gradient(linear,left top,left bottom,from(#666),to(#999));
+    background-image:-webkit-linear-gradient(top,#666,#999);
+    background-image:-moz-linear-gradient(top,#666,#999);
+    background-image:-ms-linear-gradient(top,#666,#999);
+    background-image:-o-linear-gradient(top,#666,#999);
+    background-image:linear-gradient(top,#666,#999);
+    margin-right: 0px;
+    padding: 10px 0px 10px 0px;
+    text-decoration: none;
+}
+
+.inner_lp_toc .scorm_item_highlight a {
+    color:#fff;
+    margin-right: 1px;
+    text-decoration: none;
+    font-weight: bold;
+}
+
+.inner_lp_toc .scorm_item_section {
+    border:1px solid #222;
+    background:#333;
+    font-weight:bold;
+    color:#fff;
+    text-shadow:0 -1px 1px #000;
+    background-image:-webkit-gradient(linear,left top,left bottom,from(#555),to(#333));
+    background-image:-webkit-linear-gradient(top,#555,#333);
+    background-image:-moz-linear-gradient(top,#555,#333);
+    background-image:-ms-linear-gradient(top,#555,#333);
+    background-image:-o-linear-gradient(top,#555,#333);
+    background-image:linear-gradient(top,#555,#333);
+    margin-right: 1px;
+    padding: 10px 0px 10px 0px;
+    text-decoration: none;
+}
+
+.inner_lp_toc .scorm_item {
+    font-size: 16px;
+    margin-left: 10px;
+    margin-right:10px;
+    text-decoration: none;
+    border-color: rgba(255, 255, 255, 0.3);
+}
+
+.inner_lp_toc .scorm_item_1 {
+    border-bottom: 1px solid #CCCCCC;
+    background:#eee;
+    font-weight:bold;
+    color:#444;
+    text-shadow:0 1px 1px #f6f6f6;
+    background-image:-webkit-gradient(linear,left top,left bottom,from(#fdfdfd),to(#eee));
+    background-image:-webkit-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-moz-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-ms-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-o-linear-gradient(top,#fdfdfd,#eee);
+    background-image:linear-gradient(top,#fdfdfd,#eee);
+    margin-right: 1px;
+    padding: 10px 0px 10px 0px;
+    text-decoration: none;
+    font-weight: normal;
+    background:#FDFDFD;
+}
+
+.inner_lp_toc .scorm_item_2 {
+    background-image:-webkit-gradient(linear,left top,left bottom,from(#fdfdfd),to(#eee));
+    background-image:-webkit-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-moz-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-ms-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-o-linear-gradient(top,#fdfdfd,#eee);
+    background-image:linear-gradient(top,#fdfdfd,#eee);
+    border-bottom: 1px solid #CCCCCC;
+    color: #444444;
+    font-weight: bold;
+    text-shadow: 0 1px 1px #F6F6F6;
+    margin-right: 1px;
+    padding: 10px 0px 10px 0px;
+    text-decoration: none;
+    font-weight: normal;
+}
+
+.inner_lp_toc .scorm_item_section .scorm_item:before
+{
+    content: url("../../img/lp_section.png");  /* from main/newscorm/lp_controller.php file */
+    vertical-align: text-top;
+    margin-right:10px;
+}
+
+.scorm_section_level_0 {
+    padding : 0 0 0 0;
+}
+
+.scorm_section_level_1 {
+    padding : 0 0.5em 0 2em;
+}
+
+.scorm_section_level_2 {
+    padding : 0 0.5em 0 4em;
+}
+
+.scorm_section_level_3 {
+    padding : 0 0.5em 0 6em;
+}
+
+.scorm_section_level_4 {
+    padding : 0 0.5em 0 8em;
+}
+
+.scorm_section_level_5 {
+    padding : 0 0.5em 0 10em;
+}
+
+.scorm_item_level_0 {
+    padding : 0 0 0 0;
+}
+
+.scorm_item_level_1 {
+    padding : 0 0.5em 0 1.5em;
+}
+
+.scorm_item_level_2 {
+    padding : 0 0.5em 0 3em;
+}
+
+.scorm_item_level_3 {
+    padding : 0 0.5em 0 4.5em;
+}
+
+.scorm_item_level_4 {
+    padding : 0 0.5em 0 6em;
+}
+
+.scorm_item_level_5 {
+    padding : 0 0.5em 0 7.5em;
+}
+
+/* end of copy of default_scorm.css */
+
+
 .scormpage {
 	height: 100%;
 }

+ 163 - 0
main/css/chamilo_green/scorm.css

@@ -1,3 +1,166 @@
+/* copy of default_scorm.css */
+
+.inner_lp_toc {
+    overflow: auto;
+    background-color: white;
+    height: 210px;
+}
+
+.inner_lp_toc .scorm_item a {
+    font-weight: bold;
+    font-size: 14px;
+    margin-right: 1px;
+    padding-bottom: 2px;
+    text-decoration: none;
+    color: #2F3E46;
+}
+
+.inner_lp_toc .scorm_item a.chapter_module {
+    font-weight: normal;
+    margin-right: 10px;
+}
+.inner_lp_toc .scorm_item_highlight {
+    border: 1px solid #999;
+    background:#999;
+    font-weight:bold;
+    text-shadow:0 -1px 1px #666;
+    background-image:-webkit-gradient(linear,left top,left bottom,from(#666),to(#999));
+    background-image:-webkit-linear-gradient(top,#666,#999);
+    background-image:-moz-linear-gradient(top,#666,#999);
+    background-image:-ms-linear-gradient(top,#666,#999);
+    background-image:-o-linear-gradient(top,#666,#999);
+    background-image:linear-gradient(top,#666,#999);
+    margin-right: 0px;
+    padding: 10px 0px 10px 0px;
+    text-decoration: none;
+}
+
+.inner_lp_toc .scorm_item_highlight a {
+    color:#fff;
+    margin-right: 1px;
+    text-decoration: none;
+    font-weight: bold;
+}
+
+.inner_lp_toc .scorm_item_section {
+    border:1px solid #222;
+    background:#333;
+    font-weight:bold;
+    color:#fff;
+    text-shadow:0 -1px 1px #000;
+    background-image:-webkit-gradient(linear,left top,left bottom,from(#555),to(#333));
+    background-image:-webkit-linear-gradient(top,#555,#333);
+    background-image:-moz-linear-gradient(top,#555,#333);
+    background-image:-ms-linear-gradient(top,#555,#333);
+    background-image:-o-linear-gradient(top,#555,#333);
+    background-image:linear-gradient(top,#555,#333);
+    margin-right: 1px;
+    padding: 10px 0px 10px 0px;
+    text-decoration: none;
+}
+
+.inner_lp_toc .scorm_item {
+    font-size: 16px;
+    margin-left: 10px;
+    margin-right:10px;
+    text-decoration: none;
+    border-color: rgba(255, 255, 255, 0.3);
+}
+
+.inner_lp_toc .scorm_item_1 {
+    border-bottom: 1px solid #CCCCCC;
+    background:#eee;
+    font-weight:bold;
+    color:#444;
+    text-shadow:0 1px 1px #f6f6f6;
+    background-image:-webkit-gradient(linear,left top,left bottom,from(#fdfdfd),to(#eee));
+    background-image:-webkit-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-moz-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-ms-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-o-linear-gradient(top,#fdfdfd,#eee);
+    background-image:linear-gradient(top,#fdfdfd,#eee);
+    margin-right: 1px;
+    padding: 10px 0px 10px 0px;
+    text-decoration: none;
+    font-weight: normal;
+    background:#FDFDFD;
+}
+
+.inner_lp_toc .scorm_item_2 {
+    background-image:-webkit-gradient(linear,left top,left bottom,from(#fdfdfd),to(#eee));
+    background-image:-webkit-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-moz-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-ms-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-o-linear-gradient(top,#fdfdfd,#eee);
+    background-image:linear-gradient(top,#fdfdfd,#eee);
+    border-bottom: 1px solid #CCCCCC;
+    color: #444444;
+    font-weight: bold;
+    text-shadow: 0 1px 1px #F6F6F6;
+    margin-right: 1px;
+    padding: 10px 0px 10px 0px;
+    text-decoration: none;
+    font-weight: normal;
+}
+
+.inner_lp_toc .scorm_item_section .scorm_item:before
+{
+    content : url('../../img/lp_section.png');  /* from main/newscorm/lp_controller.php file */
+    vertical-align: text-top;
+    margin-right : 5px;
+}
+
+.scorm_section_level_0 {
+    padding : 0 0 0 0;
+}
+
+.scorm_section_level_1 {
+    padding : 0 0.5em 0 2em;
+}
+
+.scorm_section_level_2 {
+    padding : 0 0.5em 0 4em;
+}
+
+.scorm_section_level_3 {
+    padding : 0 0.5em 0 6em;
+}
+
+.scorm_section_level_4 {
+    padding : 0 0.5em 0 8em;
+}
+
+.scorm_section_level_5 {
+    padding : 0 0.5em 0 10em;
+}
+
+.scorm_item_level_0 {
+    padding : 0 0 0 0;
+}
+
+.scorm_item_level_1 {
+    padding : 0 0.5em 0 1.5em;
+}
+
+.scorm_item_level_2 {
+    padding : 0 0.5em 0 3em;
+}
+
+.scorm_item_level_3 {
+    padding : 0 0.5em 0 4.5em;
+}
+
+.scorm_item_level_4 {
+    padding : 0 0.5em 0 6em;
+}
+
+.scorm_item_level_5 {
+    padding : 0 0.5em 0 7.5em;
+}
+
+/* end of copy of default_scorm.css */
+
+
 .scormpage {
 	height: 100%;
 }

+ 269 - 110
main/css/chamilo_orange/scorm.css

@@ -1,166 +1,325 @@
+/* copy of default_scorm.css */
+
+.inner_lp_toc {
+    overflow: auto;
+    background-color: white;
+    height: 210px;
+}
+
+.inner_lp_toc .scorm_item a {
+    font-weight: bold;
+    font-size: 14px;
+    margin-right: 1px;
+    padding-bottom: 2px;
+    text-decoration: none;
+    color: #2F3E46;
+}
+
+.inner_lp_toc .scorm_item a.chapter_module {
+    font-weight: normal;
+    margin-right: 10px;
+}
+.inner_lp_toc .scorm_item_highlight {
+    border: 1px solid #999;
+    background:#999;
+    font-weight:bold;
+    text-shadow:0 -1px 1px #666;
+    background-image:-webkit-gradient(linear,left top,left bottom,from(#666),to(#999));
+    background-image:-webkit-linear-gradient(top,#666,#999);
+    background-image:-moz-linear-gradient(top,#666,#999);
+    background-image:-ms-linear-gradient(top,#666,#999);
+    background-image:-o-linear-gradient(top,#666,#999);
+    background-image:linear-gradient(top,#666,#999);
+    margin-right: 0px;
+    padding: 10px 0px 10px 0px;
+    text-decoration: none;
+}
+
+.inner_lp_toc .scorm_item_highlight a {
+    color:#fff;
+    margin-right: 1px;
+    text-decoration: none;
+    font-weight: bold;
+}
+
+.inner_lp_toc .scorm_item_section {
+    border:1px solid #222;
+    background:#333;
+    font-weight:bold;
+    color:#fff;
+    text-shadow:0 -1px 1px #000;
+    background-image:-webkit-gradient(linear,left top,left bottom,from(#555),to(#333));
+    background-image:-webkit-linear-gradient(top,#555,#333);
+    background-image:-moz-linear-gradient(top,#555,#333);
+    background-image:-ms-linear-gradient(top,#555,#333);
+    background-image:-o-linear-gradient(top,#555,#333);
+    background-image:linear-gradient(top,#555,#333);
+    margin-right: 1px;
+    padding: 10px 0px 10px 0px;
+    text-decoration: none;
+}
+
+.inner_lp_toc .scorm_item {
+    font-size: 16px;
+    margin-left: 10px;
+    margin-right:10px;
+    text-decoration: none;
+    border-color: rgba(255, 255, 255, 0.3);
+}
+
+.inner_lp_toc .scorm_item_1 {
+    border-bottom: 1px solid #CCCCCC;
+    background:#eee;
+    font-weight:bold;
+    color:#444;
+    text-shadow:0 1px 1px #f6f6f6;
+    background-image:-webkit-gradient(linear,left top,left bottom,from(#fdfdfd),to(#eee));
+    background-image:-webkit-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-moz-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-ms-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-o-linear-gradient(top,#fdfdfd,#eee);
+    background-image:linear-gradient(top,#fdfdfd,#eee);
+    margin-right: 1px;
+    padding: 10px 0px 10px 0px;
+    text-decoration: none;
+    font-weight: normal;
+    background:#FDFDFD;
+}
+
+.inner_lp_toc .scorm_item_2 {
+    background-image:-webkit-gradient(linear,left top,left bottom,from(#fdfdfd),to(#eee));
+    background-image:-webkit-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-moz-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-ms-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-o-linear-gradient(top,#fdfdfd,#eee);
+    background-image:linear-gradient(top,#fdfdfd,#eee);
+    border-bottom: 1px solid #CCCCCC;
+    color: #444444;
+    font-weight: bold;
+    text-shadow: 0 1px 1px #F6F6F6;
+    margin-right: 1px;
+    padding: 10px 0px 10px 0px;
+    text-decoration: none;
+    font-weight: normal;
+}
+
+.inner_lp_toc .scorm_item_section .scorm_item:before
+{
+    content : url('../../img/lp_section.png');  /* from main/newscorm/lp_controller.php file */
+    vertical-align: text-top;
+    margin-right : 5px;
+}
+
+.scorm_section_level_0 {
+    padding : 0 0 0 0;
+}
+
+.scorm_section_level_1 {
+    padding : 0 0.5em 0 2em;
+}
+
+.scorm_section_level_2 {
+    padding : 0 0.5em 0 4em;
+}
+
+.scorm_section_level_3 {
+    padding : 0 0.5em 0 6em;
+}
+
+.scorm_section_level_4 {
+    padding : 0 0.5em 0 8em;
+}
+
+.scorm_section_level_5 {
+    padding : 0 0.5em 0 10em;
+}
+
+.scorm_item_level_0 {
+    padding : 0 0 0 0;
+}
+
+.scorm_item_level_1 {
+    padding : 0 0.5em 0 1.5em;
+}
+
+.scorm_item_level_2 {
+    padding : 0 0.5em 0 3em;
+}
+
+.scorm_item_level_3 {
+    padding : 0 0.5em 0 4.5em;
+}
+
+.scorm_item_level_4 {
+    padding : 0 0.5em 0 6em;
+}
+
+.scorm_item_level_5 {
+    padding : 0 0.5em 0 7.5em;
+}
+
+/* end of copy of default_scorm.css */
+
+
 .scormpage {
-	height: 100%;
+    height: 100%;
 }
 .scormpage .menu {
-	width: 180px;
-	float: left;
-	margin: 1px;
-	padding: 0px;
-	margin-top: 0px;
-	padding-top: 0px;
-	font-size: small;
+    width: 180px;
+    float: left;
+    margin: 1px;
+    padding: 0px;
+    margin-top: 0px;
+    padding-top: 0px;
+    font-size: small;
 }
 .lp_toc {
-	background-color: white;
-	height: 380px;
-	width: 99%;
-	border-right: 1px none;
+    background-color: white;
+    height: 380px;
+    width: 99%;
+    border-right: 1px none;
 }
 .inner_lp_toc {
-	overflow: auto;
-	background-color: white;
-	height: 210px;	
+    overflow: auto;
+    background-color: white;
+    height: 210px;
 }
 .inner_lp_toc .scorm_item {
-	font-size: 11px;
-	margin-left: 10px;
-	margin-right:10px;
-	text-decoration: none;
+    font-size: 11px;
+    margin-left: 10px;
+    margin-right:10px;
+    text-decoration: none;
 }
 .inner_lp_toc .scorm_item A {
-	font-size: 11px;
-	margin-right: 1px;
-	padding-bottom: 2px;
-	text-decoration: none;
-	font-weight: normal;
+    font-size: 11px;
+    margin-right: 1px;
+    padding-bottom: 2px;
+    text-decoration: none;
+    font-weight: normal;
 }
 .inner_lp_toc .scorm_item A.chapter_module {
-	font-weight: normal;
-	margin-right: 10px;
+    font-weight: normal;
+    margin-right: 10px;
 }
 .inner_lp_toc .scorm_item_highlight {
-	font-size: 11px;
-	margin-right: 1px;
-	padding-bottom: 2px;
-	text-decoration: none;
-	font-weight: normal;
-	background:#aaa;
+    font-size: 11px;
+    margin-right: 1px;
+    padding-bottom: 2px;
+    text-decoration: none;
+    font-weight: normal;
+    background:#aaa;
 }
 .inner_lp_toc .scorm_item_highlight A {
-	font-size: 11px;
-	margin-right: 1px;
-	text-decoration: none;
-	font-weight: normal;
+    font-size: 11px;
+    margin-right: 1px;
+    text-decoration: none;
+    font-weight: normal;
 }
 .inner_lp_toc .scorm_item_1 {
-	font-size: 11px;
-	margin-right: 1px;
-	padding-bottom: 2px;
-	text-decoration: none;
-	font-weight: normal;
-	background:#ddd;
+    font-size: 11px;
+    margin-right: 1px;
+    padding-bottom: 2px;
+    text-decoration: none;
+    font-weight: normal;
+    background:#ddd;
 }
 .inner_lp_toc .scorm_item_2 {
-	font-size: 11px;
-	margin-right: 1px;
-	padding-bottom: 2px;
-	text-decoration: none;
-	font-weight: normal;
-	background:#eee;
+    font-size: 11px;
+    margin-right: 1px;
+    padding-bottom: 2px;
+    text-decoration: none;
+    font-weight: normal;
+    background:#eee;
 }
 .inner_lp_toc .scorm_title {
-	font-weight: bold;
-	background:#ccc;
-	font-size: 14px;
-	color: #444;
+    font-weight: bold;
+    background:#ccc;
+    font-size: 14px;
+    color: #444;
 }
 .inner_lp_toc .scorm_title_text {
-	margin-left: 10px;
- //padding: 2px;
- //cambiado no existe
+    margin-left: 10px;
 }
 .inner_lp_toc .scorm_status_img {
-	margin:0px;
-	margin-left: -10px;
-	width:10px;
+    margin:0px;
+    margin-left: -10px;
+    width:10px;
 }
 .lp_navigation {
-	overflow: auto;
-	background-color: white;
-	height: 44px;
-	width:180px;
-	padding-top: 4px;
-	padding-bottom:0px;
-	border: none;
-	margin-top: -18px;
-	border-top: 1px dotted black;
-	border-bottom: 1px dotted black;
+    overflow: auto;
+    background-color: white;
+    height: 44px;
+    width:180px;
+    padding-top: 4px;
+    padding-bottom:0px;
+    border: none;
+    margin-top: -18px;
+    border-top: 1px dotted black;
+    border-bottom: 1px dotted black;
 }
 .lp_navigation_elem {
-	padding-left: 15px;
-	padding-top: 0px;
+    padding-left: 15px;
+    padding-top: 0px;
 }
 /*.scormpage .menu */
 .lp_navigation_elem .progresstext {
-	margin-top: -20px;
-	//margin-left: 40%;
-//em  font-size: normal;
+    margin-top: -20px;
 }
 /*.scormpage .menu */
 .lp_navigation_elem .buttons {
-	margin-left: 0px;
-	margin-right: 0em;
-	margin-top: 0.4em;
+    margin-left: 0px;
+    margin-right: 0em;
+    margin-top: 0.4em;
 }
 .scormpage .menu .notification {
-	background-color: white;
-	height: 50px;
+    background-color: white;
+    height: 50px;
 }
 .scormpage .menu .notification .message {
-	background-color: white;
-	height: 50px;
-	width: 180px;
-	border: none;
+    background-color: white;
+    height: 50px;
+    width: 180px;
+    border: none;
 }
 .scormpage .content {
-	/*float: left;
-	width: 60%;*/
-	margin-top: 0px;
-	padding-top: 0px;
-	padding-left: 180px;
-	background-color: white;
+    /*float: left;
+    width: 60%;*/
+    margin-top: 0px;
+    padding-top: 0px;
+    padding-left: 180px;
+    background-color: white;
 }
 .iframe {
-	border: 0px solid black;
-	height: 100%;
-	width: 95%;
-	margin: 0px;
-	padding-right: 0px;
-	overflow: auto;
-	vertical-align: top;
+    border: 0px solid black;
+    height: 100%;
+    width: 95%;
+    margin: 0px;
+    padding-right: 0px;
+    overflow: auto;
+    vertical-align: top;
 }
 .scormpage .footer {
-	clear: both;
+    clear: both;
 }
 #image_preview {
-	padding-left: 17px;
+    padding-left: 17px;
 }
 #author_name {
-	padding-left: 5px;
-	padding-top: 5px;
-	font-size: 11px;
-	color:#888;
+    padding-left: 5px;
+    padding-top: 5px;
+    font-size: 11px;
+    color:#888;
 }
 #msg_div_id {
-	padding-left: 17px;
-	padding-top: 4px;
+    padding-left: 17px;
+    padding-top: 4px;
 }
 .scorm_title_text {
-	margin-left: 10px;
-	font-weight: bold;
-	background:#ccc;
-	font-size: 14px;
-	color: #444;
-	width: 89%;
-	padding: 1px 5px 3px 8px;
+    margin-left: 10px;
+    font-weight: bold;
+    background:#ccc;
+    font-size: 14px;
+    color: #444;
+    width: 89%;
+    padding: 1px 5px 3px 8px;
 }

+ 163 - 4
main/css/chamilo_red/scorm.css

@@ -1,3 +1,166 @@
+/* copy of default_scorm.css */
+
+.inner_lp_toc {
+    overflow: auto;
+    background-color: white;
+    height: 210px;
+}
+
+.inner_lp_toc .scorm_item a {
+    font-weight: bold;
+    font-size: 14px;
+    margin-right: 1px;
+    padding-bottom: 2px;
+    text-decoration: none;
+    color: #2F3E46;
+}
+
+.inner_lp_toc .scorm_item a.chapter_module {
+    font-weight: normal;
+    margin-right: 10px;
+}
+.inner_lp_toc .scorm_item_highlight {
+    border: 1px solid #999;
+    background:#999;
+    font-weight:bold;
+    text-shadow:0 -1px 1px #666;
+    background-image:-webkit-gradient(linear,left top,left bottom,from(#666),to(#999));
+    background-image:-webkit-linear-gradient(top,#666,#999);
+    background-image:-moz-linear-gradient(top,#666,#999);
+    background-image:-ms-linear-gradient(top,#666,#999);
+    background-image:-o-linear-gradient(top,#666,#999);
+    background-image:linear-gradient(top,#666,#999);
+    margin-right: 0px;
+    padding: 10px 0px 10px 0px;
+    text-decoration: none;
+}
+
+.inner_lp_toc .scorm_item_highlight a {
+    color:#fff;
+    margin-right: 1px;
+    text-decoration: none;
+    font-weight: bold;
+}
+
+.inner_lp_toc .scorm_item_section {
+    border:1px solid #222;
+    background:#333;
+    font-weight:bold;
+    color:#fff;
+    text-shadow:0 -1px 1px #000;
+    background-image:-webkit-gradient(linear,left top,left bottom,from(#555),to(#333));
+    background-image:-webkit-linear-gradient(top,#555,#333);
+    background-image:-moz-linear-gradient(top,#555,#333);
+    background-image:-ms-linear-gradient(top,#555,#333);
+    background-image:-o-linear-gradient(top,#555,#333);
+    background-image:linear-gradient(top,#555,#333);
+    margin-right: 1px;
+    padding: 10px 0px 10px 0px;
+    text-decoration: none;
+}
+
+.inner_lp_toc .scorm_item {
+    font-size: 16px;
+    margin-left: 10px;
+    margin-right:10px;
+    text-decoration: none;
+    border-color: rgba(255, 255, 255, 0.3);
+}
+
+.inner_lp_toc .scorm_item_1 {
+    border-bottom: 1px solid #CCCCCC;
+    background:#eee;
+    font-weight:bold;
+    color:#444;
+    text-shadow:0 1px 1px #f6f6f6;
+    background-image:-webkit-gradient(linear,left top,left bottom,from(#fdfdfd),to(#eee));
+    background-image:-webkit-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-moz-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-ms-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-o-linear-gradient(top,#fdfdfd,#eee);
+    background-image:linear-gradient(top,#fdfdfd,#eee);
+    margin-right: 1px;
+    padding: 10px 0px 10px 0px;
+    text-decoration: none;
+    font-weight: normal;
+    background:#FDFDFD;
+}
+
+.inner_lp_toc .scorm_item_2 {
+    background-image:-webkit-gradient(linear,left top,left bottom,from(#fdfdfd),to(#eee));
+    background-image:-webkit-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-moz-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-ms-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-o-linear-gradient(top,#fdfdfd,#eee);
+    background-image:linear-gradient(top,#fdfdfd,#eee);
+    border-bottom: 1px solid #CCCCCC;
+    color: #444444;
+    font-weight: bold;
+    text-shadow: 0 1px 1px #F6F6F6;
+    margin-right: 1px;
+    padding: 10px 0px 10px 0px;
+    text-decoration: none;
+    font-weight: normal;
+}
+
+.inner_lp_toc .scorm_item_section .scorm_item:before
+{
+    content : url('../../img/lp_section.png');  /* from main/newscorm/lp_controller.php file */
+    vertical-align: text-top;
+    margin-right : 5px;
+}
+
+.scorm_section_level_0 {
+    padding : 0 0 0 0;
+}
+
+.scorm_section_level_1 {
+    padding : 0 0.5em 0 2em;
+}
+
+.scorm_section_level_2 {
+    padding : 0 0.5em 0 4em;
+}
+
+.scorm_section_level_3 {
+    padding : 0 0.5em 0 6em;
+}
+
+.scorm_section_level_4 {
+    padding : 0 0.5em 0 8em;
+}
+
+.scorm_section_level_5 {
+    padding : 0 0.5em 0 10em;
+}
+
+.scorm_item_level_0 {
+    padding : 0 0 0 0;
+}
+
+.scorm_item_level_1 {
+    padding : 0 0.5em 0 1.5em;
+}
+
+.scorm_item_level_2 {
+    padding : 0 0.5em 0 3em;
+}
+
+.scorm_item_level_3 {
+    padding : 0 0.5em 0 4.5em;
+}
+
+.scorm_item_level_4 {
+    padding : 0 0.5em 0 6em;
+}
+
+.scorm_item_level_5 {
+    padding : 0 0.5em 0 7.5em;
+}
+
+/* end of copy of default_scorm.css */
+
+
 .scormpage {
 	height: 100%;
 }
@@ -76,8 +239,6 @@
 }
 .inner_lp_toc .scorm_title_text {
 	margin-left: 10px;
- //padding: 2px;
- //cambiado no existe
 }
 .inner_lp_toc .scorm_status_img {
 	margin:0px;
@@ -103,8 +264,6 @@
 /*.scormpage .menu */
 .lp_navigation_elem .progresstext {
 	margin-top: -20px;
-	//margin-left: 40%;
-//em  font-size: normal;
 }
 /*.scormpage .menu */
 .lp_navigation_elem .buttons {

+ 163 - 0
main/css/chamilo_sport_red/scorm.css

@@ -1,3 +1,166 @@
+/* copy of default_scorm.css */
+
+.inner_lp_toc {
+    overflow: auto;
+    background-color: white;
+    height: 210px;
+}
+
+.inner_lp_toc .scorm_item a {
+    font-weight: bold;
+    font-size: 14px;
+    margin-right: 1px;
+    padding-bottom: 2px;
+    text-decoration: none;
+    color: #2F3E46;
+}
+
+.inner_lp_toc .scorm_item a.chapter_module {
+    font-weight: normal;
+    margin-right: 10px;
+}
+.inner_lp_toc .scorm_item_highlight {
+    border: 1px solid #999;
+    background:#999;
+    font-weight:bold;
+    text-shadow:0 -1px 1px #666;
+    background-image:-webkit-gradient(linear,left top,left bottom,from(#666),to(#999));
+    background-image:-webkit-linear-gradient(top,#666,#999);
+    background-image:-moz-linear-gradient(top,#666,#999);
+    background-image:-ms-linear-gradient(top,#666,#999);
+    background-image:-o-linear-gradient(top,#666,#999);
+    background-image:linear-gradient(top,#666,#999);
+    margin-right: 0px;
+    padding: 10px 0px 10px 0px;
+    text-decoration: none;
+}
+
+.inner_lp_toc .scorm_item_highlight a {
+    color:#fff;
+    margin-right: 1px;
+    text-decoration: none;
+    font-weight: bold;
+}
+
+.inner_lp_toc .scorm_item_section {
+    border:1px solid #222;
+    background:#333;
+    font-weight:bold;
+    color:#fff;
+    text-shadow:0 -1px 1px #000;
+    background-image:-webkit-gradient(linear,left top,left bottom,from(#555),to(#333));
+    background-image:-webkit-linear-gradient(top,#555,#333);
+    background-image:-moz-linear-gradient(top,#555,#333);
+    background-image:-ms-linear-gradient(top,#555,#333);
+    background-image:-o-linear-gradient(top,#555,#333);
+    background-image:linear-gradient(top,#555,#333);
+    margin-right: 1px;
+    padding: 10px 0px 10px 0px;
+    text-decoration: none;
+}
+
+.inner_lp_toc .scorm_item {
+    font-size: 16px;
+    margin-left: 10px;
+    margin-right:10px;
+    text-decoration: none;
+    border-color: rgba(255, 255, 255, 0.3);
+}
+
+.inner_lp_toc .scorm_item_1 {
+    border-bottom: 1px solid #CCCCCC;
+    background:#eee;
+    font-weight:bold;
+    color:#444;
+    text-shadow:0 1px 1px #f6f6f6;
+    background-image:-webkit-gradient(linear,left top,left bottom,from(#fdfdfd),to(#eee));
+    background-image:-webkit-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-moz-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-ms-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-o-linear-gradient(top,#fdfdfd,#eee);
+    background-image:linear-gradient(top,#fdfdfd,#eee);
+    margin-right: 1px;
+    padding: 10px 0px 10px 0px;
+    text-decoration: none;
+    font-weight: normal;
+    background:#FDFDFD;
+}
+
+.inner_lp_toc .scorm_item_2 {
+    background-image:-webkit-gradient(linear,left top,left bottom,from(#fdfdfd),to(#eee));
+    background-image:-webkit-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-moz-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-ms-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-o-linear-gradient(top,#fdfdfd,#eee);
+    background-image:linear-gradient(top,#fdfdfd,#eee);
+    border-bottom: 1px solid #CCCCCC;
+    color: #444444;
+    font-weight: bold;
+    text-shadow: 0 1px 1px #F6F6F6;
+    margin-right: 1px;
+    padding: 10px 0px 10px 0px;
+    text-decoration: none;
+    font-weight: normal;
+}
+
+.inner_lp_toc .scorm_item_section .scorm_item:before
+{
+    content : url('../../img/lp_section.png');  /* from main/newscorm/lp_controller.php file */
+    vertical-align: text-top;
+    margin-right : 5px;
+}
+
+.scorm_section_level_0 {
+    padding : 0 0 0 0;
+}
+
+.scorm_section_level_1 {
+    padding : 0 0.5em 0 2em;
+}
+
+.scorm_section_level_2 {
+    padding : 0 0.5em 0 4em;
+}
+
+.scorm_section_level_3 {
+    padding : 0 0.5em 0 6em;
+}
+
+.scorm_section_level_4 {
+    padding : 0 0.5em 0 8em;
+}
+
+.scorm_section_level_5 {
+    padding : 0 0.5em 0 10em;
+}
+
+.scorm_item_level_0 {
+    padding : 0 0 0 0;
+}
+
+.scorm_item_level_1 {
+    padding : 0 0.5em 0 1.5em;
+}
+
+.scorm_item_level_2 {
+    padding : 0 0.5em 0 3em;
+}
+
+.scorm_item_level_3 {
+    padding : 0 0.5em 0 4.5em;
+}
+
+.scorm_item_level_4 {
+    padding : 0 0.5em 0 6em;
+}
+
+.scorm_item_level_5 {
+    padding : 0 0.5em 0 7.5em;
+}
+
+/* end of copy of default_scorm.css */
+
+
 .scormpage {
 	height: 100%;
 }

+ 163 - 2
main/css/cool_blue/scorm.css

@@ -1,3 +1,166 @@
+/* copy of default_scorm.css */
+
+.inner_lp_toc {
+    overflow: auto;
+    background-color: white;
+    height: 210px;
+}
+
+.inner_lp_toc .scorm_item a {
+    font-weight: bold;
+    font-size: 14px;
+    margin-right: 1px;
+    padding-bottom: 2px;
+    text-decoration: none;
+    color: #2F3E46;
+}
+
+.inner_lp_toc .scorm_item a.chapter_module {
+    font-weight: normal;
+    margin-right: 10px;
+}
+.inner_lp_toc .scorm_item_highlight {
+    border: 1px solid #999;
+    background:#999;
+    font-weight:bold;
+    text-shadow:0 -1px 1px #666;
+    background-image:-webkit-gradient(linear,left top,left bottom,from(#666),to(#999));
+    background-image:-webkit-linear-gradient(top,#666,#999);
+    background-image:-moz-linear-gradient(top,#666,#999);
+    background-image:-ms-linear-gradient(top,#666,#999);
+    background-image:-o-linear-gradient(top,#666,#999);
+    background-image:linear-gradient(top,#666,#999);
+    margin-right: 0px;
+    padding: 10px 0px 10px 0px;
+    text-decoration: none;
+}
+
+.inner_lp_toc .scorm_item_highlight a {
+    color:#fff;
+    margin-right: 1px;
+    text-decoration: none;
+    font-weight: bold;
+}
+
+.inner_lp_toc .scorm_item_section {
+    border:1px solid #222;
+    background:#333;
+    font-weight:bold;
+    color:#fff;
+    text-shadow:0 -1px 1px #000;
+    background-image:-webkit-gradient(linear,left top,left bottom,from(#555),to(#333));
+    background-image:-webkit-linear-gradient(top,#555,#333);
+    background-image:-moz-linear-gradient(top,#555,#333);
+    background-image:-ms-linear-gradient(top,#555,#333);
+    background-image:-o-linear-gradient(top,#555,#333);
+    background-image:linear-gradient(top,#555,#333);
+    margin-right: 1px;
+    padding: 10px 0px 10px 0px;
+    text-decoration: none;
+}
+
+.inner_lp_toc .scorm_item {
+    font-size: 16px;
+    margin-left: 10px;
+    margin-right:10px;
+    text-decoration: none;
+    border-color: rgba(255, 255, 255, 0.3);
+}
+
+.inner_lp_toc .scorm_item_1 {
+    border-bottom: 1px solid #CCCCCC;
+    background:#eee;
+    font-weight:bold;
+    color:#444;
+    text-shadow:0 1px 1px #f6f6f6;
+    background-image:-webkit-gradient(linear,left top,left bottom,from(#fdfdfd),to(#eee));
+    background-image:-webkit-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-moz-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-ms-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-o-linear-gradient(top,#fdfdfd,#eee);
+    background-image:linear-gradient(top,#fdfdfd,#eee);
+    margin-right: 1px;
+    padding: 10px 0px 10px 0px;
+    text-decoration: none;
+    font-weight: normal;
+    background:#FDFDFD;
+}
+
+.inner_lp_toc .scorm_item_2 {
+    background-image:-webkit-gradient(linear,left top,left bottom,from(#fdfdfd),to(#eee));
+    background-image:-webkit-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-moz-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-ms-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-o-linear-gradient(top,#fdfdfd,#eee);
+    background-image:linear-gradient(top,#fdfdfd,#eee);
+    border-bottom: 1px solid #CCCCCC;
+    color: #444444;
+    font-weight: bold;
+    text-shadow: 0 1px 1px #F6F6F6;
+    margin-right: 1px;
+    padding: 10px 0px 10px 0px;
+    text-decoration: none;
+    font-weight: normal;
+}
+
+.inner_lp_toc .scorm_item_section .scorm_item:before
+{
+    content : url('../../img/lp_section.png');  /* from main/newscorm/lp_controller.php file */
+    vertical-align: text-top;
+    margin-right : 5px;
+}
+
+.scorm_section_level_0 {
+    padding : 0 0 0 0;
+}
+
+.scorm_section_level_1 {
+    padding : 0 0.5em 0 2em;
+}
+
+.scorm_section_level_2 {
+    padding : 0 0.5em 0 4em;
+}
+
+.scorm_section_level_3 {
+    padding : 0 0.5em 0 6em;
+}
+
+.scorm_section_level_4 {
+    padding : 0 0.5em 0 8em;
+}
+
+.scorm_section_level_5 {
+    padding : 0 0.5em 0 10em;
+}
+
+.scorm_item_level_0 {
+    padding : 0 0 0 0;
+}
+
+.scorm_item_level_1 {
+    padding : 0 0.5em 0 1.5em;
+}
+
+.scorm_item_level_2 {
+    padding : 0 0.5em 0 3em;
+}
+
+.scorm_item_level_3 {
+    padding : 0 0.5em 0 4.5em;
+}
+
+.scorm_item_level_4 {
+    padding : 0 0.5em 0 6em;
+}
+
+.scorm_item_level_5 {
+    padding : 0 0.5em 0 7.5em;
+}
+
+/* end of copy of default_scorm.css */
+
+
 .scormpage {
 	height: 100%;
 }
@@ -76,8 +239,6 @@
 }
 .inner_lp_toc .scorm_title_text {
 	margin-left: 10px;
- //padding: 2px;
- //cambiado no existe
 }
 .inner_lp_toc .scorm_status_img {
 	margin:0px;

+ 163 - 1
main/css/corporate/scorm.css

@@ -1,3 +1,166 @@
+/* copy of default_scorm.css */
+
+.inner_lp_toc {
+    overflow: auto;
+    background-color: white;
+    height: 210px;
+}
+
+.inner_lp_toc .scorm_item a {
+    font-weight: bold;
+    font-size: 14px;
+    margin-right: 1px;
+    padding-bottom: 2px;
+    text-decoration: none;
+    color: #2F3E46;
+}
+
+.inner_lp_toc .scorm_item a.chapter_module {
+    font-weight: normal;
+    margin-right: 10px;
+}
+.inner_lp_toc .scorm_item_highlight {
+    border: 1px solid #999;
+    background:#999;
+    font-weight:bold;
+    text-shadow:0 -1px 1px #666;
+    background-image:-webkit-gradient(linear,left top,left bottom,from(#666),to(#999));
+    background-image:-webkit-linear-gradient(top,#666,#999);
+    background-image:-moz-linear-gradient(top,#666,#999);
+    background-image:-ms-linear-gradient(top,#666,#999);
+    background-image:-o-linear-gradient(top,#666,#999);
+    background-image:linear-gradient(top,#666,#999);
+    margin-right: 0px;
+    padding: 10px 0px 10px 0px;
+    text-decoration: none;
+}
+
+.inner_lp_toc .scorm_item_highlight a {
+    color:#fff;
+    margin-right: 1px;
+    text-decoration: none;
+    font-weight: bold;
+}
+
+.inner_lp_toc .scorm_item_section {
+    border:1px solid #222;
+    background:#333;
+    font-weight:bold;
+    color:#fff;
+    text-shadow:0 -1px 1px #000;
+    background-image:-webkit-gradient(linear,left top,left bottom,from(#555),to(#333));
+    background-image:-webkit-linear-gradient(top,#555,#333);
+    background-image:-moz-linear-gradient(top,#555,#333);
+    background-image:-ms-linear-gradient(top,#555,#333);
+    background-image:-o-linear-gradient(top,#555,#333);
+    background-image:linear-gradient(top,#555,#333);
+    margin-right: 1px;
+    padding: 10px 0px 10px 0px;
+    text-decoration: none;
+}
+
+.inner_lp_toc .scorm_item {
+    font-size: 16px;
+    margin-left: 10px;
+    margin-right:10px;
+    text-decoration: none;
+    border-color: rgba(255, 255, 255, 0.3);
+}
+
+.inner_lp_toc .scorm_item_1 {
+    border-bottom: 1px solid #CCCCCC;
+    background:#eee;
+    font-weight:bold;
+    color:#444;
+    text-shadow:0 1px 1px #f6f6f6;
+    background-image:-webkit-gradient(linear,left top,left bottom,from(#fdfdfd),to(#eee));
+    background-image:-webkit-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-moz-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-ms-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-o-linear-gradient(top,#fdfdfd,#eee);
+    background-image:linear-gradient(top,#fdfdfd,#eee);
+    margin-right: 1px;
+    padding: 10px 0px 10px 0px;
+    text-decoration: none;
+    font-weight: normal;
+    background:#FDFDFD;
+}
+
+.inner_lp_toc .scorm_item_2 {
+    background-image:-webkit-gradient(linear,left top,left bottom,from(#fdfdfd),to(#eee));
+    background-image:-webkit-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-moz-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-ms-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-o-linear-gradient(top,#fdfdfd,#eee);
+    background-image:linear-gradient(top,#fdfdfd,#eee);
+    border-bottom: 1px solid #CCCCCC;
+    color: #444444;
+    font-weight: bold;
+    text-shadow: 0 1px 1px #F6F6F6;
+    margin-right: 1px;
+    padding: 10px 0px 10px 0px;
+    text-decoration: none;
+    font-weight: normal;
+}
+
+.inner_lp_toc .scorm_item_section .scorm_item:before
+{
+    content : url('../../img/lp_section.png');  /* from main/newscorm/lp_controller.php file */
+    vertical-align: text-top;
+    margin-right : 5px;
+}
+
+.scorm_section_level_0 {
+    padding : 0 0 0 0;
+}
+
+.scorm_section_level_1 {
+    padding : 0 0.5em 0 2em;
+}
+
+.scorm_section_level_2 {
+    padding : 0 0.5em 0 4em;
+}
+
+.scorm_section_level_3 {
+    padding : 0 0.5em 0 6em;
+}
+
+.scorm_section_level_4 {
+    padding : 0 0.5em 0 8em;
+}
+
+.scorm_section_level_5 {
+    padding : 0 0.5em 0 10em;
+}
+
+.scorm_item_level_0 {
+    padding : 0 0 0 0;
+}
+
+.scorm_item_level_1 {
+    padding : 0 0.5em 0 1.5em;
+}
+
+.scorm_item_level_2 {
+    padding : 0 0.5em 0 3em;
+}
+
+.scorm_item_level_3 {
+    padding : 0 0.5em 0 4.5em;
+}
+
+.scorm_item_level_4 {
+    padding : 0 0.5em 0 6em;
+}
+
+.scorm_item_level_5 {
+    padding : 0 0.5em 0 7.5em;
+}
+
+/* end of copy of default_scorm.css */
+
+
 .scormpage {
 	height: 100%;
 }
@@ -100,7 +263,6 @@
 .lp_navigation_elem .progresstext {
 	margin-top: -20px;
 	margin-left: 40%;
-//em  font-size: normal;
 }
 /*.scormpage .menu */
 .lp_navigation_elem .buttons {

+ 163 - 1
main/css/cosmic_campus/scorm.css

@@ -1,3 +1,166 @@
+/* copy of default_scorm.css */
+
+.inner_lp_toc {
+    overflow: auto;
+    background-color: white;
+    height: 210px;
+}
+
+.inner_lp_toc .scorm_item a {
+    font-weight: bold;
+    font-size: 14px;
+    margin-right: 1px;
+    padding-bottom: 2px;
+    text-decoration: none;
+    color: #2F3E46;
+}
+
+.inner_lp_toc .scorm_item a.chapter_module {
+    font-weight: normal;
+    margin-right: 10px;
+}
+.inner_lp_toc .scorm_item_highlight {
+    border: 1px solid #999;
+    background:#999;
+    font-weight:bold;
+    text-shadow:0 -1px 1px #666;
+    background-image:-webkit-gradient(linear,left top,left bottom,from(#666),to(#999));
+    background-image:-webkit-linear-gradient(top,#666,#999);
+    background-image:-moz-linear-gradient(top,#666,#999);
+    background-image:-ms-linear-gradient(top,#666,#999);
+    background-image:-o-linear-gradient(top,#666,#999);
+    background-image:linear-gradient(top,#666,#999);
+    margin-right: 0px;
+    padding: 10px 0px 10px 0px;
+    text-decoration: none;
+}
+
+.inner_lp_toc .scorm_item_highlight a {
+    color:#fff;
+    margin-right: 1px;
+    text-decoration: none;
+    font-weight: bold;
+}
+
+.inner_lp_toc .scorm_item_section {
+    border:1px solid #222;
+    background:#333;
+    font-weight:bold;
+    color:#fff;
+    text-shadow:0 -1px 1px #000;
+    background-image:-webkit-gradient(linear,left top,left bottom,from(#555),to(#333));
+    background-image:-webkit-linear-gradient(top,#555,#333);
+    background-image:-moz-linear-gradient(top,#555,#333);
+    background-image:-ms-linear-gradient(top,#555,#333);
+    background-image:-o-linear-gradient(top,#555,#333);
+    background-image:linear-gradient(top,#555,#333);
+    margin-right: 1px;
+    padding: 10px 0px 10px 0px;
+    text-decoration: none;
+}
+
+.inner_lp_toc .scorm_item {
+    font-size: 16px;
+    margin-left: 10px;
+    margin-right:10px;
+    text-decoration: none;
+    border-color: rgba(255, 255, 255, 0.3);
+}
+
+.inner_lp_toc .scorm_item_1 {
+    border-bottom: 1px solid #CCCCCC;
+    background:#eee;
+    font-weight:bold;
+    color:#444;
+    text-shadow:0 1px 1px #f6f6f6;
+    background-image:-webkit-gradient(linear,left top,left bottom,from(#fdfdfd),to(#eee));
+    background-image:-webkit-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-moz-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-ms-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-o-linear-gradient(top,#fdfdfd,#eee);
+    background-image:linear-gradient(top,#fdfdfd,#eee);
+    margin-right: 1px;
+    padding: 10px 0px 10px 0px;
+    text-decoration: none;
+    font-weight: normal;
+    background:#FDFDFD;
+}
+
+.inner_lp_toc .scorm_item_2 {
+    background-image:-webkit-gradient(linear,left top,left bottom,from(#fdfdfd),to(#eee));
+    background-image:-webkit-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-moz-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-ms-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-o-linear-gradient(top,#fdfdfd,#eee);
+    background-image:linear-gradient(top,#fdfdfd,#eee);
+    border-bottom: 1px solid #CCCCCC;
+    color: #444444;
+    font-weight: bold;
+    text-shadow: 0 1px 1px #F6F6F6;
+    margin-right: 1px;
+    padding: 10px 0px 10px 0px;
+    text-decoration: none;
+    font-weight: normal;
+}
+
+.inner_lp_toc .scorm_item_section .scorm_item:before
+{
+    content : url('../../img/lp_section.png');  /* from main/newscorm/lp_controller.php file */
+    vertical-align: text-top;
+    margin-right : 5px;
+}
+
+.scorm_section_level_0 {
+    padding : 0 0 0 0;
+}
+
+.scorm_section_level_1 {
+    padding : 0 0.5em 0 2em;
+}
+
+.scorm_section_level_2 {
+    padding : 0 0.5em 0 4em;
+}
+
+.scorm_section_level_3 {
+    padding : 0 0.5em 0 6em;
+}
+
+.scorm_section_level_4 {
+    padding : 0 0.5em 0 8em;
+}
+
+.scorm_section_level_5 {
+    padding : 0 0.5em 0 10em;
+}
+
+.scorm_item_level_0 {
+    padding : 0 0 0 0;
+}
+
+.scorm_item_level_1 {
+    padding : 0 0.5em 0 1.5em;
+}
+
+.scorm_item_level_2 {
+    padding : 0 0.5em 0 3em;
+}
+
+.scorm_item_level_3 {
+    padding : 0 0.5em 0 4.5em;
+}
+
+.scorm_item_level_4 {
+    padding : 0 0.5em 0 6em;
+}
+
+.scorm_item_level_5 {
+    padding : 0 0.5em 0 7.5em;
+}
+
+/* end of copy of default_scorm.css */
+
+
 .scormpage {
 	height: 100%;
 }
@@ -103,7 +266,6 @@
 .lp_navigation_elem .progresstext {
 	margin-top: -20px;
 	margin-left: 40%;
-//em  font-size: normal;
 }
 /*.scormpage .menu */
 .lp_navigation_elem .buttons {

+ 0 - 0
main/css/default_scorm.css


+ 163 - 0
main/css/delicious_bordeaux/scorm.css

@@ -1,3 +1,166 @@
+/* copy of default_scorm.css */
+
+.inner_lp_toc {
+    overflow: auto;
+    background-color: white;
+    height: 210px;
+}
+
+.inner_lp_toc .scorm_item a {
+    font-weight: bold;
+    font-size: 14px;
+    margin-right: 1px;
+    padding-bottom: 2px;
+    text-decoration: none;
+    color: #2F3E46;
+}
+
+.inner_lp_toc .scorm_item a.chapter_module {
+    font-weight: normal;
+    margin-right: 10px;
+}
+.inner_lp_toc .scorm_item_highlight {
+    border: 1px solid #999;
+    background:#999;
+    font-weight:bold;
+    text-shadow:0 -1px 1px #666;
+    background-image:-webkit-gradient(linear,left top,left bottom,from(#666),to(#999));
+    background-image:-webkit-linear-gradient(top,#666,#999);
+    background-image:-moz-linear-gradient(top,#666,#999);
+    background-image:-ms-linear-gradient(top,#666,#999);
+    background-image:-o-linear-gradient(top,#666,#999);
+    background-image:linear-gradient(top,#666,#999);
+    margin-right: 0px;
+    padding: 10px 0px 10px 0px;
+    text-decoration: none;
+}
+
+.inner_lp_toc .scorm_item_highlight a {
+    color:#fff;
+    margin-right: 1px;
+    text-decoration: none;
+    font-weight: bold;
+}
+
+.inner_lp_toc .scorm_item_section {
+    border:1px solid #222;
+    background:#333;
+    font-weight:bold;
+    color:#fff;
+    text-shadow:0 -1px 1px #000;
+    background-image:-webkit-gradient(linear,left top,left bottom,from(#555),to(#333));
+    background-image:-webkit-linear-gradient(top,#555,#333);
+    background-image:-moz-linear-gradient(top,#555,#333);
+    background-image:-ms-linear-gradient(top,#555,#333);
+    background-image:-o-linear-gradient(top,#555,#333);
+    background-image:linear-gradient(top,#555,#333);
+    margin-right: 1px;
+    padding: 10px 0px 10px 0px;
+    text-decoration: none;
+}
+
+.inner_lp_toc .scorm_item {
+    font-size: 16px;
+    margin-left: 10px;
+    margin-right:10px;
+    text-decoration: none;
+    border-color: rgba(255, 255, 255, 0.3);
+}
+
+.inner_lp_toc .scorm_item_1 {
+    border-bottom: 1px solid #CCCCCC;
+    background:#eee;
+    font-weight:bold;
+    color:#444;
+    text-shadow:0 1px 1px #f6f6f6;
+    background-image:-webkit-gradient(linear,left top,left bottom,from(#fdfdfd),to(#eee));
+    background-image:-webkit-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-moz-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-ms-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-o-linear-gradient(top,#fdfdfd,#eee);
+    background-image:linear-gradient(top,#fdfdfd,#eee);
+    margin-right: 1px;
+    padding: 10px 0px 10px 0px;
+    text-decoration: none;
+    font-weight: normal;
+    background:#FDFDFD;
+}
+
+.inner_lp_toc .scorm_item_2 {
+    background-image:-webkit-gradient(linear,left top,left bottom,from(#fdfdfd),to(#eee));
+    background-image:-webkit-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-moz-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-ms-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-o-linear-gradient(top,#fdfdfd,#eee);
+    background-image:linear-gradient(top,#fdfdfd,#eee);
+    border-bottom: 1px solid #CCCCCC;
+    color: #444444;
+    font-weight: bold;
+    text-shadow: 0 1px 1px #F6F6F6;
+    margin-right: 1px;
+    padding: 10px 0px 10px 0px;
+    text-decoration: none;
+    font-weight: normal;
+}
+
+.inner_lp_toc .scorm_item_section .scorm_item:before
+{
+    content : url('../../img/lp_section.png');  /* from main/newscorm/lp_controller.php file */
+    vertical-align: text-top;
+    margin-right : 5px;
+}
+
+.scorm_section_level_0 {
+    padding : 0 0 0 0;
+}
+
+.scorm_section_level_1 {
+    padding : 0 0.5em 0 2em;
+}
+
+.scorm_section_level_2 {
+    padding : 0 0.5em 0 4em;
+}
+
+.scorm_section_level_3 {
+    padding : 0 0.5em 0 6em;
+}
+
+.scorm_section_level_4 {
+    padding : 0 0.5em 0 8em;
+}
+
+.scorm_section_level_5 {
+    padding : 0 0.5em 0 10em;
+}
+
+.scorm_item_level_0 {
+    padding : 0 0 0 0;
+}
+
+.scorm_item_level_1 {
+    padding : 0 0.5em 0 1.5em;
+}
+
+.scorm_item_level_2 {
+    padding : 0 0.5em 0 3em;
+}
+
+.scorm_item_level_3 {
+    padding : 0 0.5em 0 4.5em;
+}
+
+.scorm_item_level_4 {
+    padding : 0 0.5em 0 6em;
+}
+
+.scorm_item_level_5 {
+    padding : 0 0.5em 0 7.5em;
+}
+
+/* end of copy of default_scorm.css */
+
+
 .scormpage {
 	height: 100%;
 }

+ 163 - 2
main/css/dokeos_blue/scorm.css

@@ -1,3 +1,166 @@
+/* copy of default_scorm.css */
+
+.inner_lp_toc {
+    overflow: auto;
+    background-color: white;
+    height: 210px;
+}
+
+.inner_lp_toc .scorm_item a {
+    font-weight: bold;
+    font-size: 14px;
+    margin-right: 1px;
+    padding-bottom: 2px;
+    text-decoration: none;
+    color: #2F3E46;
+}
+
+.inner_lp_toc .scorm_item a.chapter_module {
+    font-weight: normal;
+    margin-right: 10px;
+}
+.inner_lp_toc .scorm_item_highlight {
+    border: 1px solid #999;
+    background:#999;
+    font-weight:bold;
+    text-shadow:0 -1px 1px #666;
+    background-image:-webkit-gradient(linear,left top,left bottom,from(#666),to(#999));
+    background-image:-webkit-linear-gradient(top,#666,#999);
+    background-image:-moz-linear-gradient(top,#666,#999);
+    background-image:-ms-linear-gradient(top,#666,#999);
+    background-image:-o-linear-gradient(top,#666,#999);
+    background-image:linear-gradient(top,#666,#999);
+    margin-right: 0px;
+    padding: 10px 0px 10px 0px;
+    text-decoration: none;
+}
+
+.inner_lp_toc .scorm_item_highlight a {
+    color:#fff;
+    margin-right: 1px;
+    text-decoration: none;
+    font-weight: bold;
+}
+
+.inner_lp_toc .scorm_item_section {
+    border:1px solid #222;
+    background:#333;
+    font-weight:bold;
+    color:#fff;
+    text-shadow:0 -1px 1px #000;
+    background-image:-webkit-gradient(linear,left top,left bottom,from(#555),to(#333));
+    background-image:-webkit-linear-gradient(top,#555,#333);
+    background-image:-moz-linear-gradient(top,#555,#333);
+    background-image:-ms-linear-gradient(top,#555,#333);
+    background-image:-o-linear-gradient(top,#555,#333);
+    background-image:linear-gradient(top,#555,#333);
+    margin-right: 1px;
+    padding: 10px 0px 10px 0px;
+    text-decoration: none;
+}
+
+.inner_lp_toc .scorm_item {
+    font-size: 16px;
+    margin-left: 10px;
+    margin-right:10px;
+    text-decoration: none;
+    border-color: rgba(255, 255, 255, 0.3);
+}
+
+.inner_lp_toc .scorm_item_1 {
+    border-bottom: 1px solid #CCCCCC;
+    background:#eee;
+    font-weight:bold;
+    color:#444;
+    text-shadow:0 1px 1px #f6f6f6;
+    background-image:-webkit-gradient(linear,left top,left bottom,from(#fdfdfd),to(#eee));
+    background-image:-webkit-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-moz-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-ms-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-o-linear-gradient(top,#fdfdfd,#eee);
+    background-image:linear-gradient(top,#fdfdfd,#eee);
+    margin-right: 1px;
+    padding: 10px 0px 10px 0px;
+    text-decoration: none;
+    font-weight: normal;
+    background:#FDFDFD;
+}
+
+.inner_lp_toc .scorm_item_2 {
+    background-image:-webkit-gradient(linear,left top,left bottom,from(#fdfdfd),to(#eee));
+    background-image:-webkit-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-moz-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-ms-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-o-linear-gradient(top,#fdfdfd,#eee);
+    background-image:linear-gradient(top,#fdfdfd,#eee);
+    border-bottom: 1px solid #CCCCCC;
+    color: #444444;
+    font-weight: bold;
+    text-shadow: 0 1px 1px #F6F6F6;
+    margin-right: 1px;
+    padding: 10px 0px 10px 0px;
+    text-decoration: none;
+    font-weight: normal;
+}
+
+.inner_lp_toc .scorm_item_section .scorm_item:before
+{
+    content : url('../../img/lp_section.png');  /* from main/newscorm/lp_controller.php file */
+    vertical-align: text-top;
+    margin-right : 5px;
+}
+
+.scorm_section_level_0 {
+    padding : 0 0 0 0;
+}
+
+.scorm_section_level_1 {
+    padding : 0 0.5em 0 2em;
+}
+
+.scorm_section_level_2 {
+    padding : 0 0.5em 0 4em;
+}
+
+.scorm_section_level_3 {
+    padding : 0 0.5em 0 6em;
+}
+
+.scorm_section_level_4 {
+    padding : 0 0.5em 0 8em;
+}
+
+.scorm_section_level_5 {
+    padding : 0 0.5em 0 10em;
+}
+
+.scorm_item_level_0 {
+    padding : 0 0 0 0;
+}
+
+.scorm_item_level_1 {
+    padding : 0 0.5em 0 1.5em;
+}
+
+.scorm_item_level_2 {
+    padding : 0 0.5em 0 3em;
+}
+
+.scorm_item_level_3 {
+    padding : 0 0.5em 0 4.5em;
+}
+
+.scorm_item_level_4 {
+    padding : 0 0.5em 0 6em;
+}
+
+.scorm_item_level_5 {
+    padding : 0 0.5em 0 7.5em;
+}
+
+/* end of copy of default_scorm.css */
+
+
 .scormpage {
 	height: 100%;
 }
@@ -76,8 +239,6 @@
 }
 .inner_lp_toc .scorm_title_text {
 	margin-left: 10px;
- //padding: 2px;
- //cambiado no existe
 }
 .inner_lp_toc .scorm_status_img {
 	margin:0px;

+ 163 - 0
main/css/dokeos_classic/scorm.css

@@ -1,3 +1,166 @@
+/* copy of default_scorm.css */
+
+.inner_lp_toc {
+    overflow: auto;
+    background-color: white;
+    height: 210px;
+}
+
+.inner_lp_toc .scorm_item a {
+    font-weight: bold;
+    font-size: 14px;
+    margin-right: 1px;
+    padding-bottom: 2px;
+    text-decoration: none;
+    color: #2F3E46;
+}
+
+.inner_lp_toc .scorm_item a.chapter_module {
+    font-weight: normal;
+    margin-right: 10px;
+}
+.inner_lp_toc .scorm_item_highlight {
+    border: 1px solid #999;
+    background:#999;
+    font-weight:bold;
+    text-shadow:0 -1px 1px #666;
+    background-image:-webkit-gradient(linear,left top,left bottom,from(#666),to(#999));
+    background-image:-webkit-linear-gradient(top,#666,#999);
+    background-image:-moz-linear-gradient(top,#666,#999);
+    background-image:-ms-linear-gradient(top,#666,#999);
+    background-image:-o-linear-gradient(top,#666,#999);
+    background-image:linear-gradient(top,#666,#999);
+    margin-right: 0px;
+    padding: 10px 0px 10px 0px;
+    text-decoration: none;
+}
+
+.inner_lp_toc .scorm_item_highlight a {
+    color:#fff;
+    margin-right: 1px;
+    text-decoration: none;
+    font-weight: bold;
+}
+
+.inner_lp_toc .scorm_item_section {
+    border:1px solid #222;
+    background:#333;
+    font-weight:bold;
+    color:#fff;
+    text-shadow:0 -1px 1px #000;
+    background-image:-webkit-gradient(linear,left top,left bottom,from(#555),to(#333));
+    background-image:-webkit-linear-gradient(top,#555,#333);
+    background-image:-moz-linear-gradient(top,#555,#333);
+    background-image:-ms-linear-gradient(top,#555,#333);
+    background-image:-o-linear-gradient(top,#555,#333);
+    background-image:linear-gradient(top,#555,#333);
+    margin-right: 1px;
+    padding: 10px 0px 10px 0px;
+    text-decoration: none;
+}
+
+.inner_lp_toc .scorm_item {
+    font-size: 16px;
+    margin-left: 10px;
+    margin-right:10px;
+    text-decoration: none;
+    border-color: rgba(255, 255, 255, 0.3);
+}
+
+.inner_lp_toc .scorm_item_1 {
+    border-bottom: 1px solid #CCCCCC;
+    background:#eee;
+    font-weight:bold;
+    color:#444;
+    text-shadow:0 1px 1px #f6f6f6;
+    background-image:-webkit-gradient(linear,left top,left bottom,from(#fdfdfd),to(#eee));
+    background-image:-webkit-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-moz-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-ms-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-o-linear-gradient(top,#fdfdfd,#eee);
+    background-image:linear-gradient(top,#fdfdfd,#eee);
+    margin-right: 1px;
+    padding: 10px 0px 10px 0px;
+    text-decoration: none;
+    font-weight: normal;
+    background:#FDFDFD;
+}
+
+.inner_lp_toc .scorm_item_2 {
+    background-image:-webkit-gradient(linear,left top,left bottom,from(#fdfdfd),to(#eee));
+    background-image:-webkit-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-moz-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-ms-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-o-linear-gradient(top,#fdfdfd,#eee);
+    background-image:linear-gradient(top,#fdfdfd,#eee);
+    border-bottom: 1px solid #CCCCCC;
+    color: #444444;
+    font-weight: bold;
+    text-shadow: 0 1px 1px #F6F6F6;
+    margin-right: 1px;
+    padding: 10px 0px 10px 0px;
+    text-decoration: none;
+    font-weight: normal;
+}
+
+.inner_lp_toc .scorm_item_section .scorm_item:before
+{
+    content : url('../../img/lp_section.png');  /* from main/newscorm/lp_controller.php file */
+    vertical-align: text-top;
+    margin-right : 5px;
+}
+
+.scorm_section_level_0 {
+    padding : 0 0 0 0;
+}
+
+.scorm_section_level_1 {
+    padding : 0 0.5em 0 2em;
+}
+
+.scorm_section_level_2 {
+    padding : 0 0.5em 0 4em;
+}
+
+.scorm_section_level_3 {
+    padding : 0 0.5em 0 6em;
+}
+
+.scorm_section_level_4 {
+    padding : 0 0.5em 0 8em;
+}
+
+.scorm_section_level_5 {
+    padding : 0 0.5em 0 10em;
+}
+
+.scorm_item_level_0 {
+    padding : 0 0 0 0;
+}
+
+.scorm_item_level_1 {
+    padding : 0 0.5em 0 1.5em;
+}
+
+.scorm_item_level_2 {
+    padding : 0 0.5em 0 3em;
+}
+
+.scorm_item_level_3 {
+    padding : 0 0.5em 0 4.5em;
+}
+
+.scorm_item_level_4 {
+    padding : 0 0.5em 0 6em;
+}
+
+.scorm_item_level_5 {
+    padding : 0 0.5em 0 7.5em;
+}
+
+/* end of copy of default_scorm.css */
+
+
 .scormpage {
 	height: 100%;
 }

+ 163 - 1
main/css/dokeos_classic_2D/scorm.css

@@ -1,3 +1,166 @@
+/* copy of default_scorm.css */
+
+.inner_lp_toc {
+    overflow: auto;
+    background-color: white;
+    height: 210px;
+}
+
+.inner_lp_toc .scorm_item a {
+    font-weight: bold;
+    font-size: 14px;
+    margin-right: 1px;
+    padding-bottom: 2px;
+    text-decoration: none;
+    color: #2F3E46;
+}
+
+.inner_lp_toc .scorm_item a.chapter_module {
+    font-weight: normal;
+    margin-right: 10px;
+}
+.inner_lp_toc .scorm_item_highlight {
+    border: 1px solid #999;
+    background:#999;
+    font-weight:bold;
+    text-shadow:0 -1px 1px #666;
+    background-image:-webkit-gradient(linear,left top,left bottom,from(#666),to(#999));
+    background-image:-webkit-linear-gradient(top,#666,#999);
+    background-image:-moz-linear-gradient(top,#666,#999);
+    background-image:-ms-linear-gradient(top,#666,#999);
+    background-image:-o-linear-gradient(top,#666,#999);
+    background-image:linear-gradient(top,#666,#999);
+    margin-right: 0px;
+    padding: 10px 0px 10px 0px;
+    text-decoration: none;
+}
+
+.inner_lp_toc .scorm_item_highlight a {
+    color:#fff;
+    margin-right: 1px;
+    text-decoration: none;
+    font-weight: bold;
+}
+
+.inner_lp_toc .scorm_item_section {
+    border:1px solid #222;
+    background:#333;
+    font-weight:bold;
+    color:#fff;
+    text-shadow:0 -1px 1px #000;
+    background-image:-webkit-gradient(linear,left top,left bottom,from(#555),to(#333));
+    background-image:-webkit-linear-gradient(top,#555,#333);
+    background-image:-moz-linear-gradient(top,#555,#333);
+    background-image:-ms-linear-gradient(top,#555,#333);
+    background-image:-o-linear-gradient(top,#555,#333);
+    background-image:linear-gradient(top,#555,#333);
+    margin-right: 1px;
+    padding: 10px 0px 10px 0px;
+    text-decoration: none;
+}
+
+.inner_lp_toc .scorm_item {
+    font-size: 16px;
+    margin-left: 10px;
+    margin-right:10px;
+    text-decoration: none;
+    border-color: rgba(255, 255, 255, 0.3);
+}
+
+.inner_lp_toc .scorm_item_1 {
+    border-bottom: 1px solid #CCCCCC;
+    background:#eee;
+    font-weight:bold;
+    color:#444;
+    text-shadow:0 1px 1px #f6f6f6;
+    background-image:-webkit-gradient(linear,left top,left bottom,from(#fdfdfd),to(#eee));
+    background-image:-webkit-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-moz-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-ms-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-o-linear-gradient(top,#fdfdfd,#eee);
+    background-image:linear-gradient(top,#fdfdfd,#eee);
+    margin-right: 1px;
+    padding: 10px 0px 10px 0px;
+    text-decoration: none;
+    font-weight: normal;
+    background:#FDFDFD;
+}
+
+.inner_lp_toc .scorm_item_2 {
+    background-image:-webkit-gradient(linear,left top,left bottom,from(#fdfdfd),to(#eee));
+    background-image:-webkit-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-moz-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-ms-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-o-linear-gradient(top,#fdfdfd,#eee);
+    background-image:linear-gradient(top,#fdfdfd,#eee);
+    border-bottom: 1px solid #CCCCCC;
+    color: #444444;
+    font-weight: bold;
+    text-shadow: 0 1px 1px #F6F6F6;
+    margin-right: 1px;
+    padding: 10px 0px 10px 0px;
+    text-decoration: none;
+    font-weight: normal;
+}
+
+.inner_lp_toc .scorm_item_section .scorm_item:before
+{
+    content : url('../../img/lp_section.png');  /* from main/newscorm/lp_controller.php file */
+    vertical-align: text-top;
+    margin-right : 5px;
+}
+
+.scorm_section_level_0 {
+    padding : 0 0 0 0;
+}
+
+.scorm_section_level_1 {
+    padding : 0 0.5em 0 2em;
+}
+
+.scorm_section_level_2 {
+    padding : 0 0.5em 0 4em;
+}
+
+.scorm_section_level_3 {
+    padding : 0 0.5em 0 6em;
+}
+
+.scorm_section_level_4 {
+    padding : 0 0.5em 0 8em;
+}
+
+.scorm_section_level_5 {
+    padding : 0 0.5em 0 10em;
+}
+
+.scorm_item_level_0 {
+    padding : 0 0 0 0;
+}
+
+.scorm_item_level_1 {
+    padding : 0 0.5em 0 1.5em;
+}
+
+.scorm_item_level_2 {
+    padding : 0 0.5em 0 3em;
+}
+
+.scorm_item_level_3 {
+    padding : 0 0.5em 0 4.5em;
+}
+
+.scorm_item_level_4 {
+    padding : 0 0.5em 0 6em;
+}
+
+.scorm_item_level_5 {
+    padding : 0 0.5em 0 7.5em;
+}
+
+/* end of copy of default_scorm.css */
+
+
 .scormpage {
 	height: 100%;
 }
@@ -103,7 +266,6 @@
 .lp_navigation_elem .progresstext {
 	margin-top: -20px;
 	margin-left: 40%;
-//em  font-size: normal;
 }
 /*.scormpage .menu */
 .lp_navigation_elem .buttons {

+ 163 - 0
main/css/empire_green/scorm.css

@@ -1,3 +1,166 @@
+/* copy of default_scorm.css */
+
+.inner_lp_toc {
+    overflow: auto;
+    background-color: white;
+    height: 210px;
+}
+
+.inner_lp_toc .scorm_item a {
+    font-weight: bold;
+    font-size: 14px;
+    margin-right: 1px;
+    padding-bottom: 2px;
+    text-decoration: none;
+    color: #2F3E46;
+}
+
+.inner_lp_toc .scorm_item a.chapter_module {
+    font-weight: normal;
+    margin-right: 10px;
+}
+.inner_lp_toc .scorm_item_highlight {
+    border: 1px solid #999;
+    background:#999;
+    font-weight:bold;
+    text-shadow:0 -1px 1px #666;
+    background-image:-webkit-gradient(linear,left top,left bottom,from(#666),to(#999));
+    background-image:-webkit-linear-gradient(top,#666,#999);
+    background-image:-moz-linear-gradient(top,#666,#999);
+    background-image:-ms-linear-gradient(top,#666,#999);
+    background-image:-o-linear-gradient(top,#666,#999);
+    background-image:linear-gradient(top,#666,#999);
+    margin-right: 0px;
+    padding: 10px 0px 10px 0px;
+    text-decoration: none;
+}
+
+.inner_lp_toc .scorm_item_highlight a {
+    color:#fff;
+    margin-right: 1px;
+    text-decoration: none;
+    font-weight: bold;
+}
+
+.inner_lp_toc .scorm_item_section {
+    border:1px solid #222;
+    background:#333;
+    font-weight:bold;
+    color:#fff;
+    text-shadow:0 -1px 1px #000;
+    background-image:-webkit-gradient(linear,left top,left bottom,from(#555),to(#333));
+    background-image:-webkit-linear-gradient(top,#555,#333);
+    background-image:-moz-linear-gradient(top,#555,#333);
+    background-image:-ms-linear-gradient(top,#555,#333);
+    background-image:-o-linear-gradient(top,#555,#333);
+    background-image:linear-gradient(top,#555,#333);
+    margin-right: 1px;
+    padding: 10px 0px 10px 0px;
+    text-decoration: none;
+}
+
+.inner_lp_toc .scorm_item {
+    font-size: 16px;
+    margin-left: 10px;
+    margin-right:10px;
+    text-decoration: none;
+    border-color: rgba(255, 255, 255, 0.3);
+}
+
+.inner_lp_toc .scorm_item_1 {
+    border-bottom: 1px solid #CCCCCC;
+    background:#eee;
+    font-weight:bold;
+    color:#444;
+    text-shadow:0 1px 1px #f6f6f6;
+    background-image:-webkit-gradient(linear,left top,left bottom,from(#fdfdfd),to(#eee));
+    background-image:-webkit-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-moz-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-ms-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-o-linear-gradient(top,#fdfdfd,#eee);
+    background-image:linear-gradient(top,#fdfdfd,#eee);
+    margin-right: 1px;
+    padding: 10px 0px 10px 0px;
+    text-decoration: none;
+    font-weight: normal;
+    background:#FDFDFD;
+}
+
+.inner_lp_toc .scorm_item_2 {
+    background-image:-webkit-gradient(linear,left top,left bottom,from(#fdfdfd),to(#eee));
+    background-image:-webkit-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-moz-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-ms-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-o-linear-gradient(top,#fdfdfd,#eee);
+    background-image:linear-gradient(top,#fdfdfd,#eee);
+    border-bottom: 1px solid #CCCCCC;
+    color: #444444;
+    font-weight: bold;
+    text-shadow: 0 1px 1px #F6F6F6;
+    margin-right: 1px;
+    padding: 10px 0px 10px 0px;
+    text-decoration: none;
+    font-weight: normal;
+}
+
+.inner_lp_toc .scorm_item_section .scorm_item:before
+{
+    content : url('../../img/lp_section.png');  /* from main/newscorm/lp_controller.php file */
+    vertical-align: text-top;
+    margin-right : 5px;
+}
+
+.scorm_section_level_0 {
+    padding : 0 0 0 0;
+}
+
+.scorm_section_level_1 {
+    padding : 0 0.5em 0 2em;
+}
+
+.scorm_section_level_2 {
+    padding : 0 0.5em 0 4em;
+}
+
+.scorm_section_level_3 {
+    padding : 0 0.5em 0 6em;
+}
+
+.scorm_section_level_4 {
+    padding : 0 0.5em 0 8em;
+}
+
+.scorm_section_level_5 {
+    padding : 0 0.5em 0 10em;
+}
+
+.scorm_item_level_0 {
+    padding : 0 0 0 0;
+}
+
+.scorm_item_level_1 {
+    padding : 0 0.5em 0 1.5em;
+}
+
+.scorm_item_level_2 {
+    padding : 0 0.5em 0 3em;
+}
+
+.scorm_item_level_3 {
+    padding : 0 0.5em 0 4.5em;
+}
+
+.scorm_item_level_4 {
+    padding : 0 0.5em 0 6em;
+}
+
+.scorm_item_level_5 {
+    padding : 0 0.5em 0 7.5em;
+}
+
+/* end of copy of default_scorm.css */
+
+
 .scormpage {
 	height: 100%;
 }

+ 163 - 2
main/css/fruity_orange/scorm.css

@@ -1,3 +1,166 @@
+/* copy of default_scorm.css */
+
+.inner_lp_toc {
+    overflow: auto;
+    background-color: white;
+    height: 210px;
+}
+
+.inner_lp_toc .scorm_item a {
+    font-weight: bold;
+    font-size: 14px;
+    margin-right: 1px;
+    padding-bottom: 2px;
+    text-decoration: none;
+    color: #2F3E46;
+}
+
+.inner_lp_toc .scorm_item a.chapter_module {
+    font-weight: normal;
+    margin-right: 10px;
+}
+.inner_lp_toc .scorm_item_highlight {
+    border: 1px solid #999;
+    background:#999;
+    font-weight:bold;
+    text-shadow:0 -1px 1px #666;
+    background-image:-webkit-gradient(linear,left top,left bottom,from(#666),to(#999));
+    background-image:-webkit-linear-gradient(top,#666,#999);
+    background-image:-moz-linear-gradient(top,#666,#999);
+    background-image:-ms-linear-gradient(top,#666,#999);
+    background-image:-o-linear-gradient(top,#666,#999);
+    background-image:linear-gradient(top,#666,#999);
+    margin-right: 0px;
+    padding: 10px 0px 10px 0px;
+    text-decoration: none;
+}
+
+.inner_lp_toc .scorm_item_highlight a {
+    color:#fff;
+    margin-right: 1px;
+    text-decoration: none;
+    font-weight: bold;
+}
+
+.inner_lp_toc .scorm_item_section {
+    border:1px solid #222;
+    background:#333;
+    font-weight:bold;
+    color:#fff;
+    text-shadow:0 -1px 1px #000;
+    background-image:-webkit-gradient(linear,left top,left bottom,from(#555),to(#333));
+    background-image:-webkit-linear-gradient(top,#555,#333);
+    background-image:-moz-linear-gradient(top,#555,#333);
+    background-image:-ms-linear-gradient(top,#555,#333);
+    background-image:-o-linear-gradient(top,#555,#333);
+    background-image:linear-gradient(top,#555,#333);
+    margin-right: 1px;
+    padding: 10px 0px 10px 0px;
+    text-decoration: none;
+}
+
+.inner_lp_toc .scorm_item {
+    font-size: 16px;
+    margin-left: 10px;
+    margin-right:10px;
+    text-decoration: none;
+    border-color: rgba(255, 255, 255, 0.3);
+}
+
+.inner_lp_toc .scorm_item_1 {
+    border-bottom: 1px solid #CCCCCC;
+    background:#eee;
+    font-weight:bold;
+    color:#444;
+    text-shadow:0 1px 1px #f6f6f6;
+    background-image:-webkit-gradient(linear,left top,left bottom,from(#fdfdfd),to(#eee));
+    background-image:-webkit-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-moz-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-ms-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-o-linear-gradient(top,#fdfdfd,#eee);
+    background-image:linear-gradient(top,#fdfdfd,#eee);
+    margin-right: 1px;
+    padding: 10px 0px 10px 0px;
+    text-decoration: none;
+    font-weight: normal;
+    background:#FDFDFD;
+}
+
+.inner_lp_toc .scorm_item_2 {
+    background-image:-webkit-gradient(linear,left top,left bottom,from(#fdfdfd),to(#eee));
+    background-image:-webkit-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-moz-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-ms-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-o-linear-gradient(top,#fdfdfd,#eee);
+    background-image:linear-gradient(top,#fdfdfd,#eee);
+    border-bottom: 1px solid #CCCCCC;
+    color: #444444;
+    font-weight: bold;
+    text-shadow: 0 1px 1px #F6F6F6;
+    margin-right: 1px;
+    padding: 10px 0px 10px 0px;
+    text-decoration: none;
+    font-weight: normal;
+}
+
+.inner_lp_toc .scorm_item_section .scorm_item:before
+{
+    content : url('../../img/lp_section.png');  /* from main/newscorm/lp_controller.php file */
+    vertical-align: text-top;
+    margin-right : 5px;
+}
+
+.scorm_section_level_0 {
+    padding : 0 0 0 0;
+}
+
+.scorm_section_level_1 {
+    padding : 0 0.5em 0 2em;
+}
+
+.scorm_section_level_2 {
+    padding : 0 0.5em 0 4em;
+}
+
+.scorm_section_level_3 {
+    padding : 0 0.5em 0 6em;
+}
+
+.scorm_section_level_4 {
+    padding : 0 0.5em 0 8em;
+}
+
+.scorm_section_level_5 {
+    padding : 0 0.5em 0 10em;
+}
+
+.scorm_item_level_0 {
+    padding : 0 0 0 0;
+}
+
+.scorm_item_level_1 {
+    padding : 0 0.5em 0 1.5em;
+}
+
+.scorm_item_level_2 {
+    padding : 0 0.5em 0 3em;
+}
+
+.scorm_item_level_3 {
+    padding : 0 0.5em 0 4.5em;
+}
+
+.scorm_item_level_4 {
+    padding : 0 0.5em 0 6em;
+}
+
+.scorm_item_level_5 {
+    padding : 0 0.5em 0 7.5em;
+}
+
+/* end of copy of default_scorm.css */
+
+
 .scormpage {
 	height: 100%;
 }
@@ -76,8 +239,6 @@
 }
 .inner_lp_toc .scorm_title_text {
 	margin-left: 10px;
- //padding: 2px;
- //cambiado no existe
 }
 .inner_lp_toc .scorm_status_img {
 	margin:0px;

+ 163 - 1
main/css/medical/scorm.css

@@ -1,3 +1,166 @@
+/* copy of default_scorm.css */
+
+.inner_lp_toc {
+    overflow: auto;
+    background-color: white;
+    height: 210px;
+}
+
+.inner_lp_toc .scorm_item a {
+    font-weight: bold;
+    font-size: 14px;
+    margin-right: 1px;
+    padding-bottom: 2px;
+    text-decoration: none;
+    color: #2F3E46;
+}
+
+.inner_lp_toc .scorm_item a.chapter_module {
+    font-weight: normal;
+    margin-right: 10px;
+}
+.inner_lp_toc .scorm_item_highlight {
+    border: 1px solid #999;
+    background:#999;
+    font-weight:bold;
+    text-shadow:0 -1px 1px #666;
+    background-image:-webkit-gradient(linear,left top,left bottom,from(#666),to(#999));
+    background-image:-webkit-linear-gradient(top,#666,#999);
+    background-image:-moz-linear-gradient(top,#666,#999);
+    background-image:-ms-linear-gradient(top,#666,#999);
+    background-image:-o-linear-gradient(top,#666,#999);
+    background-image:linear-gradient(top,#666,#999);
+    margin-right: 0px;
+    padding: 10px 0px 10px 0px;
+    text-decoration: none;
+}
+
+.inner_lp_toc .scorm_item_highlight a {
+    color:#fff;
+    margin-right: 1px;
+    text-decoration: none;
+    font-weight: bold;
+}
+
+.inner_lp_toc .scorm_item_section {
+    border:1px solid #222;
+    background:#333;
+    font-weight:bold;
+    color:#fff;
+    text-shadow:0 -1px 1px #000;
+    background-image:-webkit-gradient(linear,left top,left bottom,from(#555),to(#333));
+    background-image:-webkit-linear-gradient(top,#555,#333);
+    background-image:-moz-linear-gradient(top,#555,#333);
+    background-image:-ms-linear-gradient(top,#555,#333);
+    background-image:-o-linear-gradient(top,#555,#333);
+    background-image:linear-gradient(top,#555,#333);
+    margin-right: 1px;
+    padding: 10px 0px 10px 0px;
+    text-decoration: none;
+}
+
+.inner_lp_toc .scorm_item {
+    font-size: 16px;
+    margin-left: 10px;
+    margin-right:10px;
+    text-decoration: none;
+    border-color: rgba(255, 255, 255, 0.3);
+}
+
+.inner_lp_toc .scorm_item_1 {
+    border-bottom: 1px solid #CCCCCC;
+    background:#eee;
+    font-weight:bold;
+    color:#444;
+    text-shadow:0 1px 1px #f6f6f6;
+    background-image:-webkit-gradient(linear,left top,left bottom,from(#fdfdfd),to(#eee));
+    background-image:-webkit-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-moz-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-ms-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-o-linear-gradient(top,#fdfdfd,#eee);
+    background-image:linear-gradient(top,#fdfdfd,#eee);
+    margin-right: 1px;
+    padding: 10px 0px 10px 0px;
+    text-decoration: none;
+    font-weight: normal;
+    background:#FDFDFD;
+}
+
+.inner_lp_toc .scorm_item_2 {
+    background-image:-webkit-gradient(linear,left top,left bottom,from(#fdfdfd),to(#eee));
+    background-image:-webkit-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-moz-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-ms-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-o-linear-gradient(top,#fdfdfd,#eee);
+    background-image:linear-gradient(top,#fdfdfd,#eee);
+    border-bottom: 1px solid #CCCCCC;
+    color: #444444;
+    font-weight: bold;
+    text-shadow: 0 1px 1px #F6F6F6;
+    margin-right: 1px;
+    padding: 10px 0px 10px 0px;
+    text-decoration: none;
+    font-weight: normal;
+}
+
+.inner_lp_toc .scorm_item_section .scorm_item:before
+{
+    content : url('../../img/lp_section.png');  /* from main/newscorm/lp_controller.php file */
+    vertical-align: text-top;
+    margin-right : 5px;
+}
+
+.scorm_section_level_0 {
+    padding : 0 0 0 0;
+}
+
+.scorm_section_level_1 {
+    padding : 0 0.5em 0 2em;
+}
+
+.scorm_section_level_2 {
+    padding : 0 0.5em 0 4em;
+}
+
+.scorm_section_level_3 {
+    padding : 0 0.5em 0 6em;
+}
+
+.scorm_section_level_4 {
+    padding : 0 0.5em 0 8em;
+}
+
+.scorm_section_level_5 {
+    padding : 0 0.5em 0 10em;
+}
+
+.scorm_item_level_0 {
+    padding : 0 0 0 0;
+}
+
+.scorm_item_level_1 {
+    padding : 0 0.5em 0 1.5em;
+}
+
+.scorm_item_level_2 {
+    padding : 0 0.5em 0 3em;
+}
+
+.scorm_item_level_3 {
+    padding : 0 0.5em 0 4.5em;
+}
+
+.scorm_item_level_4 {
+    padding : 0 0.5em 0 6em;
+}
+
+.scorm_item_level_5 {
+    padding : 0 0.5em 0 7.5em;
+}
+
+/* end of copy of default_scorm.css */
+
+
 .scormpage {
 	height: 100%;
 }
@@ -102,7 +265,6 @@
 .lp_navigation_elem .progresstext {
 	margin-top: -20px;
 	margin-left: 40%;
-//em  font-size: normal;
 }
 /*.scormpage .menu */
 .lp_navigation_elem .buttons {

+ 163 - 0
main/css/public_admin/scorm.css

@@ -1,3 +1,166 @@
+/* copy of default_scorm.css */
+
+.inner_lp_toc {
+    overflow: auto;
+    background-color: white;
+    height: 210px;
+}
+
+.inner_lp_toc .scorm_item a {
+    font-weight: bold;
+    font-size: 14px;
+    margin-right: 1px;
+    padding-bottom: 2px;
+    text-decoration: none;
+    color: #2F3E46;
+}
+
+.inner_lp_toc .scorm_item a.chapter_module {
+    font-weight: normal;
+    margin-right: 10px;
+}
+.inner_lp_toc .scorm_item_highlight {
+    border: 1px solid #999;
+    background:#999;
+    font-weight:bold;
+    text-shadow:0 -1px 1px #666;
+    background-image:-webkit-gradient(linear,left top,left bottom,from(#666),to(#999));
+    background-image:-webkit-linear-gradient(top,#666,#999);
+    background-image:-moz-linear-gradient(top,#666,#999);
+    background-image:-ms-linear-gradient(top,#666,#999);
+    background-image:-o-linear-gradient(top,#666,#999);
+    background-image:linear-gradient(top,#666,#999);
+    margin-right: 0px;
+    padding: 10px 0px 10px 0px;
+    text-decoration: none;
+}
+
+.inner_lp_toc .scorm_item_highlight a {
+    color:#fff;
+    margin-right: 1px;
+    text-decoration: none;
+    font-weight: bold;
+}
+
+.inner_lp_toc .scorm_item_section {
+    border:1px solid #222;
+    background:#333;
+    font-weight:bold;
+    color:#fff;
+    text-shadow:0 -1px 1px #000;
+    background-image:-webkit-gradient(linear,left top,left bottom,from(#555),to(#333));
+    background-image:-webkit-linear-gradient(top,#555,#333);
+    background-image:-moz-linear-gradient(top,#555,#333);
+    background-image:-ms-linear-gradient(top,#555,#333);
+    background-image:-o-linear-gradient(top,#555,#333);
+    background-image:linear-gradient(top,#555,#333);
+    margin-right: 1px;
+    padding: 10px 0px 10px 0px;
+    text-decoration: none;
+}
+
+.inner_lp_toc .scorm_item {
+    font-size: 16px;
+    margin-left: 10px;
+    margin-right:10px;
+    text-decoration: none;
+    border-color: rgba(255, 255, 255, 0.3);
+}
+
+.inner_lp_toc .scorm_item_1 {
+    border-bottom: 1px solid #CCCCCC;
+    background:#eee;
+    font-weight:bold;
+    color:#444;
+    text-shadow:0 1px 1px #f6f6f6;
+    background-image:-webkit-gradient(linear,left top,left bottom,from(#fdfdfd),to(#eee));
+    background-image:-webkit-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-moz-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-ms-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-o-linear-gradient(top,#fdfdfd,#eee);
+    background-image:linear-gradient(top,#fdfdfd,#eee);
+    margin-right: 1px;
+    padding: 10px 0px 10px 0px;
+    text-decoration: none;
+    font-weight: normal;
+    background:#FDFDFD;
+}
+
+.inner_lp_toc .scorm_item_2 {
+    background-image:-webkit-gradient(linear,left top,left bottom,from(#fdfdfd),to(#eee));
+    background-image:-webkit-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-moz-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-ms-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-o-linear-gradient(top,#fdfdfd,#eee);
+    background-image:linear-gradient(top,#fdfdfd,#eee);
+    border-bottom: 1px solid #CCCCCC;
+    color: #444444;
+    font-weight: bold;
+    text-shadow: 0 1px 1px #F6F6F6;
+    margin-right: 1px;
+    padding: 10px 0px 10px 0px;
+    text-decoration: none;
+    font-weight: normal;
+}
+
+.inner_lp_toc .scorm_item_section .scorm_item:before
+{
+    content : url('../../img/lp_section.png');  /* from main/newscorm/lp_controller.php file */
+    vertical-align: text-top;
+    margin-right : 5px;
+}
+
+.scorm_section_level_0 {
+    padding : 0 0 0 0;
+}
+
+.scorm_section_level_1 {
+    padding : 0 0.5em 0 2em;
+}
+
+.scorm_section_level_2 {
+    padding : 0 0.5em 0 4em;
+}
+
+.scorm_section_level_3 {
+    padding : 0 0.5em 0 6em;
+}
+
+.scorm_section_level_4 {
+    padding : 0 0.5em 0 8em;
+}
+
+.scorm_section_level_5 {
+    padding : 0 0.5em 0 10em;
+}
+
+.scorm_item_level_0 {
+    padding : 0 0 0 0;
+}
+
+.scorm_item_level_1 {
+    padding : 0 0.5em 0 1.5em;
+}
+
+.scorm_item_level_2 {
+    padding : 0 0.5em 0 3em;
+}
+
+.scorm_item_level_3 {
+    padding : 0 0.5em 0 4.5em;
+}
+
+.scorm_item_level_4 {
+    padding : 0 0.5em 0 6em;
+}
+
+.scorm_item_level_5 {
+    padding : 0 0.5em 0 7.5em;
+}
+
+/* end of copy of default_scorm.css */
+
+
 .scormpage {
 	height: 100%;
 }

+ 163 - 2
main/css/royal_purple/scorm.css

@@ -1,3 +1,166 @@
+/* copy of default_scorm.css */
+
+.inner_lp_toc {
+    overflow: auto;
+    background-color: white;
+    height: 210px;
+}
+
+.inner_lp_toc .scorm_item a {
+    font-weight: bold;
+    font-size: 14px;
+    margin-right: 1px;
+    padding-bottom: 2px;
+    text-decoration: none;
+    color: #2F3E46;
+}
+
+.inner_lp_toc .scorm_item a.chapter_module {
+    font-weight: normal;
+    margin-right: 10px;
+}
+.inner_lp_toc .scorm_item_highlight {
+    border: 1px solid #999;
+    background:#999;
+    font-weight:bold;
+    text-shadow:0 -1px 1px #666;
+    background-image:-webkit-gradient(linear,left top,left bottom,from(#666),to(#999));
+    background-image:-webkit-linear-gradient(top,#666,#999);
+    background-image:-moz-linear-gradient(top,#666,#999);
+    background-image:-ms-linear-gradient(top,#666,#999);
+    background-image:-o-linear-gradient(top,#666,#999);
+    background-image:linear-gradient(top,#666,#999);
+    margin-right: 0px;
+    padding: 10px 0px 10px 0px;
+    text-decoration: none;
+}
+
+.inner_lp_toc .scorm_item_highlight a {
+    color:#fff;
+    margin-right: 1px;
+    text-decoration: none;
+    font-weight: bold;
+}
+
+.inner_lp_toc .scorm_item_section {
+    border:1px solid #222;
+    background:#333;
+    font-weight:bold;
+    color:#fff;
+    text-shadow:0 -1px 1px #000;
+    background-image:-webkit-gradient(linear,left top,left bottom,from(#555),to(#333));
+    background-image:-webkit-linear-gradient(top,#555,#333);
+    background-image:-moz-linear-gradient(top,#555,#333);
+    background-image:-ms-linear-gradient(top,#555,#333);
+    background-image:-o-linear-gradient(top,#555,#333);
+    background-image:linear-gradient(top,#555,#333);
+    margin-right: 1px;
+    padding: 10px 0px 10px 0px;
+    text-decoration: none;
+}
+
+.inner_lp_toc .scorm_item {
+    font-size: 16px;
+    margin-left: 10px;
+    margin-right:10px;
+    text-decoration: none;
+    border-color: rgba(255, 255, 255, 0.3);
+}
+
+.inner_lp_toc .scorm_item_1 {
+    border-bottom: 1px solid #CCCCCC;
+    background:#eee;
+    font-weight:bold;
+    color:#444;
+    text-shadow:0 1px 1px #f6f6f6;
+    background-image:-webkit-gradient(linear,left top,left bottom,from(#fdfdfd),to(#eee));
+    background-image:-webkit-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-moz-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-ms-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-o-linear-gradient(top,#fdfdfd,#eee);
+    background-image:linear-gradient(top,#fdfdfd,#eee);
+    margin-right: 1px;
+    padding: 10px 0px 10px 0px;
+    text-decoration: none;
+    font-weight: normal;
+    background:#FDFDFD;
+}
+
+.inner_lp_toc .scorm_item_2 {
+    background-image:-webkit-gradient(linear,left top,left bottom,from(#fdfdfd),to(#eee));
+    background-image:-webkit-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-moz-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-ms-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-o-linear-gradient(top,#fdfdfd,#eee);
+    background-image:linear-gradient(top,#fdfdfd,#eee);
+    border-bottom: 1px solid #CCCCCC;
+    color: #444444;
+    font-weight: bold;
+    text-shadow: 0 1px 1px #F6F6F6;
+    margin-right: 1px;
+    padding: 10px 0px 10px 0px;
+    text-decoration: none;
+    font-weight: normal;
+}
+
+.inner_lp_toc .scorm_item_section .scorm_item:before
+{
+    content : url('../../img/lp_section.png');  /* from main/newscorm/lp_controller.php file */
+    vertical-align: text-top;
+    margin-right : 5px;
+}
+
+.scorm_section_level_0 {
+    padding : 0 0 0 0;
+}
+
+.scorm_section_level_1 {
+    padding : 0 0.5em 0 2em;
+}
+
+.scorm_section_level_2 {
+    padding : 0 0.5em 0 4em;
+}
+
+.scorm_section_level_3 {
+    padding : 0 0.5em 0 6em;
+}
+
+.scorm_section_level_4 {
+    padding : 0 0.5em 0 8em;
+}
+
+.scorm_section_level_5 {
+    padding : 0 0.5em 0 10em;
+}
+
+.scorm_item_level_0 {
+    padding : 0 0 0 0;
+}
+
+.scorm_item_level_1 {
+    padding : 0 0.5em 0 1.5em;
+}
+
+.scorm_item_level_2 {
+    padding : 0 0.5em 0 3em;
+}
+
+.scorm_item_level_3 {
+    padding : 0 0.5em 0 4.5em;
+}
+
+.scorm_item_level_4 {
+    padding : 0 0.5em 0 6em;
+}
+
+.scorm_item_level_5 {
+    padding : 0 0.5em 0 7.5em;
+}
+
+/* end of copy of default_scorm.css */
+
+
 .scormpage {
 	height: 100%;
 }
@@ -76,8 +239,6 @@
 }
 .inner_lp_toc .scorm_title_text {
 	margin-left: 10px;
- //padding: 2px;
- //cambiado no existe
 }
 .inner_lp_toc .scorm_status_img {
 	margin:0px;

+ 163 - 2
main/css/silver_line/scorm.css

@@ -1,3 +1,166 @@
+/* copy of default_scorm.css */
+
+.inner_lp_toc {
+    overflow: auto;
+    background-color: white;
+    height: 210px;
+}
+
+.inner_lp_toc .scorm_item a {
+    font-weight: bold;
+    font-size: 14px;
+    margin-right: 1px;
+    padding-bottom: 2px;
+    text-decoration: none;
+    color: #2F3E46;
+}
+
+.inner_lp_toc .scorm_item a.chapter_module {
+    font-weight: normal;
+    margin-right: 10px;
+}
+.inner_lp_toc .scorm_item_highlight {
+    border: 1px solid #999;
+    background:#999;
+    font-weight:bold;
+    text-shadow:0 -1px 1px #666;
+    background-image:-webkit-gradient(linear,left top,left bottom,from(#666),to(#999));
+    background-image:-webkit-linear-gradient(top,#666,#999);
+    background-image:-moz-linear-gradient(top,#666,#999);
+    background-image:-ms-linear-gradient(top,#666,#999);
+    background-image:-o-linear-gradient(top,#666,#999);
+    background-image:linear-gradient(top,#666,#999);
+    margin-right: 0px;
+    padding: 10px 0px 10px 0px;
+    text-decoration: none;
+}
+
+.inner_lp_toc .scorm_item_highlight a {
+    color:#fff;
+    margin-right: 1px;
+    text-decoration: none;
+    font-weight: bold;
+}
+
+.inner_lp_toc .scorm_item_section {
+    border:1px solid #222;
+    background:#333;
+    font-weight:bold;
+    color:#fff;
+    text-shadow:0 -1px 1px #000;
+    background-image:-webkit-gradient(linear,left top,left bottom,from(#555),to(#333));
+    background-image:-webkit-linear-gradient(top,#555,#333);
+    background-image:-moz-linear-gradient(top,#555,#333);
+    background-image:-ms-linear-gradient(top,#555,#333);
+    background-image:-o-linear-gradient(top,#555,#333);
+    background-image:linear-gradient(top,#555,#333);
+    margin-right: 1px;
+    padding: 10px 0px 10px 0px;
+    text-decoration: none;
+}
+
+.inner_lp_toc .scorm_item {
+    font-size: 16px;
+    margin-left: 10px;
+    margin-right:10px;
+    text-decoration: none;
+    border-color: rgba(255, 255, 255, 0.3);
+}
+
+.inner_lp_toc .scorm_item_1 {
+    border-bottom: 1px solid #CCCCCC;
+    background:#eee;
+    font-weight:bold;
+    color:#444;
+    text-shadow:0 1px 1px #f6f6f6;
+    background-image:-webkit-gradient(linear,left top,left bottom,from(#fdfdfd),to(#eee));
+    background-image:-webkit-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-moz-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-ms-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-o-linear-gradient(top,#fdfdfd,#eee);
+    background-image:linear-gradient(top,#fdfdfd,#eee);
+    margin-right: 1px;
+    padding: 10px 0px 10px 0px;
+    text-decoration: none;
+    font-weight: normal;
+    background:#FDFDFD;
+}
+
+.inner_lp_toc .scorm_item_2 {
+    background-image:-webkit-gradient(linear,left top,left bottom,from(#fdfdfd),to(#eee));
+    background-image:-webkit-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-moz-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-ms-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-o-linear-gradient(top,#fdfdfd,#eee);
+    background-image:linear-gradient(top,#fdfdfd,#eee);
+    border-bottom: 1px solid #CCCCCC;
+    color: #444444;
+    font-weight: bold;
+    text-shadow: 0 1px 1px #F6F6F6;
+    margin-right: 1px;
+    padding: 10px 0px 10px 0px;
+    text-decoration: none;
+    font-weight: normal;
+}
+
+.inner_lp_toc .scorm_item_section .scorm_item:before
+{
+    content : url('../../img/lp_section.png');  /* from main/newscorm/lp_controller.php file */
+    vertical-align: text-top;
+    margin-right : 5px;
+}
+
+.scorm_section_level_0 {
+    padding : 0 0 0 0;
+}
+
+.scorm_section_level_1 {
+    padding : 0 0.5em 0 2em;
+}
+
+.scorm_section_level_2 {
+    padding : 0 0.5em 0 4em;
+}
+
+.scorm_section_level_3 {
+    padding : 0 0.5em 0 6em;
+}
+
+.scorm_section_level_4 {
+    padding : 0 0.5em 0 8em;
+}
+
+.scorm_section_level_5 {
+    padding : 0 0.5em 0 10em;
+}
+
+.scorm_item_level_0 {
+    padding : 0 0 0 0;
+}
+
+.scorm_item_level_1 {
+    padding : 0 0.5em 0 1.5em;
+}
+
+.scorm_item_level_2 {
+    padding : 0 0.5em 0 3em;
+}
+
+.scorm_item_level_3 {
+    padding : 0 0.5em 0 4.5em;
+}
+
+.scorm_item_level_4 {
+    padding : 0 0.5em 0 6em;
+}
+
+.scorm_item_level_5 {
+    padding : 0 0.5em 0 7.5em;
+}
+
+/* end of copy of default_scorm.css */
+
+
 .scormpage {
 	height: 100%;
 }
@@ -138,8 +301,6 @@ margin-top: 0px;
 	clear: both;
 }
 .preview_image {
- //text-align: right;
- //margin-right: 5px;
 	padding-left: 17px;
 }
 .scorm_title_text {

+ 164 - 2
main/css/sober_brown/scorm.css

@@ -1,3 +1,166 @@
+/* copy of default_scorm.css */
+
+.inner_lp_toc {
+    overflow: auto;
+    background-color: white;
+    height: 210px;
+}
+
+.inner_lp_toc .scorm_item a {
+    font-weight: bold;
+    font-size: 14px;
+    margin-right: 1px;
+    padding-bottom: 2px;
+    text-decoration: none;
+    color: #2F3E46;
+}
+
+.inner_lp_toc .scorm_item a.chapter_module {
+    font-weight: normal;
+    margin-right: 10px;
+}
+.inner_lp_toc .scorm_item_highlight {
+    border: 1px solid #999;
+    background:#999;
+    font-weight:bold;
+    text-shadow:0 -1px 1px #666;
+    background-image:-webkit-gradient(linear,left top,left bottom,from(#666),to(#999));
+    background-image:-webkit-linear-gradient(top,#666,#999);
+    background-image:-moz-linear-gradient(top,#666,#999);
+    background-image:-ms-linear-gradient(top,#666,#999);
+    background-image:-o-linear-gradient(top,#666,#999);
+    background-image:linear-gradient(top,#666,#999);
+    margin-right: 0px;
+    padding: 10px 0px 10px 0px;
+    text-decoration: none;
+}
+
+.inner_lp_toc .scorm_item_highlight a {
+    color:#fff;
+    margin-right: 1px;
+    text-decoration: none;
+    font-weight: bold;
+}
+
+.inner_lp_toc .scorm_item_section {
+    border:1px solid #222;
+    background:#333;
+    font-weight:bold;
+    color:#fff;
+    text-shadow:0 -1px 1px #000;
+    background-image:-webkit-gradient(linear,left top,left bottom,from(#555),to(#333));
+    background-image:-webkit-linear-gradient(top,#555,#333);
+    background-image:-moz-linear-gradient(top,#555,#333);
+    background-image:-ms-linear-gradient(top,#555,#333);
+    background-image:-o-linear-gradient(top,#555,#333);
+    background-image:linear-gradient(top,#555,#333);
+    margin-right: 1px;
+    padding: 10px 0px 10px 0px;
+    text-decoration: none;
+}
+
+.inner_lp_toc .scorm_item {
+    font-size: 16px;
+    margin-left: 10px;
+    margin-right:10px;
+    text-decoration: none;
+    border-color: rgba(255, 255, 255, 0.3);
+}
+
+.inner_lp_toc .scorm_item_1 {
+    border-bottom: 1px solid #CCCCCC;
+    background:#eee;
+    font-weight:bold;
+    color:#444;
+    text-shadow:0 1px 1px #f6f6f6;
+    background-image:-webkit-gradient(linear,left top,left bottom,from(#fdfdfd),to(#eee));
+    background-image:-webkit-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-moz-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-ms-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-o-linear-gradient(top,#fdfdfd,#eee);
+    background-image:linear-gradient(top,#fdfdfd,#eee);
+    margin-right: 1px;
+    padding: 10px 0px 10px 0px;
+    text-decoration: none;
+    font-weight: normal;
+    background:#FDFDFD;
+}
+
+.inner_lp_toc .scorm_item_2 {
+    background-image:-webkit-gradient(linear,left top,left bottom,from(#fdfdfd),to(#eee));
+    background-image:-webkit-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-moz-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-ms-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-o-linear-gradient(top,#fdfdfd,#eee);
+    background-image:linear-gradient(top,#fdfdfd,#eee);
+    border-bottom: 1px solid #CCCCCC;
+    color: #444444;
+    font-weight: bold;
+    text-shadow: 0 1px 1px #F6F6F6;
+    margin-right: 1px;
+    padding: 10px 0px 10px 0px;
+    text-decoration: none;
+    font-weight: normal;
+}
+
+.inner_lp_toc .scorm_item_section .scorm_item:before
+{
+    content : url('../../img/lp_section.png');  /* from main/newscorm/lp_controller.php file */
+    vertical-align: text-top;
+    margin-right : 5px;
+}
+
+.scorm_section_level_0 {
+    padding : 0 0 0 0;
+}
+
+.scorm_section_level_1 {
+    padding : 0 0.5em 0 2em;
+}
+
+.scorm_section_level_2 {
+    padding : 0 0.5em 0 4em;
+}
+
+.scorm_section_level_3 {
+    padding : 0 0.5em 0 6em;
+}
+
+.scorm_section_level_4 {
+    padding : 0 0.5em 0 8em;
+}
+
+.scorm_section_level_5 {
+    padding : 0 0.5em 0 10em;
+}
+
+.scorm_item_level_0 {
+    padding : 0 0 0 0;
+}
+
+.scorm_item_level_1 {
+    padding : 0 0.5em 0 1.5em;
+}
+
+.scorm_item_level_2 {
+    padding : 0 0.5em 0 3em;
+}
+
+.scorm_item_level_3 {
+    padding : 0 0.5em 0 4.5em;
+}
+
+.scorm_item_level_4 {
+    padding : 0 0.5em 0 6em;
+}
+
+.scorm_item_level_5 {
+    padding : 0 0.5em 0 7.5em;
+}
+
+/* end of copy of default_scorm.css */
+
+
 .scormpage {
 	height: 100%;
 }
@@ -103,7 +266,6 @@
 .lp_navigation_elem .progresstext {
 	margin-top: -20px;
 	margin-left: 40%;
-//em  font-size: normal;
 }
 /*.scormpage .menu */
 .lp_navigation_elem .buttons {
@@ -142,7 +304,7 @@
 	clear: both;
 }
 .preview_image {
- padding.left: 17px;
+ padding-left: 17px;
 }
 .scorm_title_text {
 	margin-left: 10px;

+ 163 - 4
main/css/steel_grey/scorm.css

@@ -1,3 +1,166 @@
+/* copy of default_scorm.css */
+
+.inner_lp_toc {
+    overflow: auto;
+    background-color: white;
+    height: 210px;
+}
+
+.inner_lp_toc .scorm_item a {
+    font-weight: bold;
+    font-size: 14px;
+    margin-right: 1px;
+    padding-bottom: 2px;
+    text-decoration: none;
+    color: #2F3E46;
+}
+
+.inner_lp_toc .scorm_item a.chapter_module {
+    font-weight: normal;
+    margin-right: 10px;
+}
+.inner_lp_toc .scorm_item_highlight {
+    border: 1px solid #999;
+    background:#999;
+    font-weight:bold;
+    text-shadow:0 -1px 1px #666;
+    background-image:-webkit-gradient(linear,left top,left bottom,from(#666),to(#999));
+    background-image:-webkit-linear-gradient(top,#666,#999);
+    background-image:-moz-linear-gradient(top,#666,#999);
+    background-image:-ms-linear-gradient(top,#666,#999);
+    background-image:-o-linear-gradient(top,#666,#999);
+    background-image:linear-gradient(top,#666,#999);
+    margin-right: 0px;
+    padding: 10px 0px 10px 0px;
+    text-decoration: none;
+}
+
+.inner_lp_toc .scorm_item_highlight a {
+    color:#fff;
+    margin-right: 1px;
+    text-decoration: none;
+    font-weight: bold;
+}
+
+.inner_lp_toc .scorm_item_section {
+    border:1px solid #222;
+    background:#333;
+    font-weight:bold;
+    color:#fff;
+    text-shadow:0 -1px 1px #000;
+    background-image:-webkit-gradient(linear,left top,left bottom,from(#555),to(#333));
+    background-image:-webkit-linear-gradient(top,#555,#333);
+    background-image:-moz-linear-gradient(top,#555,#333);
+    background-image:-ms-linear-gradient(top,#555,#333);
+    background-image:-o-linear-gradient(top,#555,#333);
+    background-image:linear-gradient(top,#555,#333);
+    margin-right: 1px;
+    padding: 10px 0px 10px 0px;
+    text-decoration: none;
+}
+
+.inner_lp_toc .scorm_item {
+    font-size: 16px;
+    margin-left: 10px;
+    margin-right:10px;
+    text-decoration: none;
+    border-color: rgba(255, 255, 255, 0.3);
+}
+
+.inner_lp_toc .scorm_item_1 {
+    border-bottom: 1px solid #CCCCCC;
+    background:#eee;
+    font-weight:bold;
+    color:#444;
+    text-shadow:0 1px 1px #f6f6f6;
+    background-image:-webkit-gradient(linear,left top,left bottom,from(#fdfdfd),to(#eee));
+    background-image:-webkit-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-moz-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-ms-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-o-linear-gradient(top,#fdfdfd,#eee);
+    background-image:linear-gradient(top,#fdfdfd,#eee);
+    margin-right: 1px;
+    padding: 10px 0px 10px 0px;
+    text-decoration: none;
+    font-weight: normal;
+    background:#FDFDFD;
+}
+
+.inner_lp_toc .scorm_item_2 {
+    background-image:-webkit-gradient(linear,left top,left bottom,from(#fdfdfd),to(#eee));
+    background-image:-webkit-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-moz-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-ms-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-o-linear-gradient(top,#fdfdfd,#eee);
+    background-image:linear-gradient(top,#fdfdfd,#eee);
+    border-bottom: 1px solid #CCCCCC;
+    color: #444444;
+    font-weight: bold;
+    text-shadow: 0 1px 1px #F6F6F6;
+    margin-right: 1px;
+    padding: 10px 0px 10px 0px;
+    text-decoration: none;
+    font-weight: normal;
+}
+
+.inner_lp_toc .scorm_item_section .scorm_item:before
+{
+    content : url('../../img/lp_section.png');  /* from main/newscorm/lp_controller.php file */
+    vertical-align: text-top;
+    margin-right : 5px;
+}
+
+.scorm_section_level_0 {
+    padding : 0 0 0 0;
+}
+
+.scorm_section_level_1 {
+    padding : 0 0.5em 0 2em;
+}
+
+.scorm_section_level_2 {
+    padding : 0 0.5em 0 4em;
+}
+
+.scorm_section_level_3 {
+    padding : 0 0.5em 0 6em;
+}
+
+.scorm_section_level_4 {
+    padding : 0 0.5em 0 8em;
+}
+
+.scorm_section_level_5 {
+    padding : 0 0.5em 0 10em;
+}
+
+.scorm_item_level_0 {
+    padding : 0 0 0 0;
+}
+
+.scorm_item_level_1 {
+    padding : 0 0.5em 0 1.5em;
+}
+
+.scorm_item_level_2 {
+    padding : 0 0.5em 0 3em;
+}
+
+.scorm_item_level_3 {
+    padding : 0 0.5em 0 4.5em;
+}
+
+.scorm_item_level_4 {
+    padding : 0 0.5em 0 6em;
+}
+
+.scorm_item_level_5 {
+    padding : 0 0.5em 0 7.5em;
+}
+
+/* end of copy of default_scorm.css */
+
+
 .scormpage {
 	height: 100%;
 }
@@ -27,7 +190,6 @@
 	font-size: 11px;
 	margin-left: 10px;
 	margin-right:10px;
-//cambiado era 20  padding-bottom: 2px;
 	text-decoration: none;
 }
 .inner_lp_toc .scorm_item A {
@@ -79,8 +241,6 @@
 }
 .inner_lp_toc .scorm_title_text {
 	margin-left: 10px;
- //padding: 2px;
- //cambiado no existe
 }
 .inner_lp_toc .scorm_status_img {
 	margin:0px;
@@ -107,7 +267,6 @@
 .lp_navigation_elem .progresstext {
 	margin-top: -20px;
 	margin-left: 40%;
-//em  font-size: normal;
 }
 /*.scormpage .menu */
 .lp_navigation_elem .buttons {

+ 163 - 2
main/css/tasty_olive/scorm.css

@@ -1,3 +1,166 @@
+/* copy of default_scorm.css */
+
+.inner_lp_toc {
+    overflow: auto;
+    background-color: white;
+    height: 210px;
+}
+
+.inner_lp_toc .scorm_item a {
+    font-weight: bold;
+    font-size: 14px;
+    margin-right: 1px;
+    padding-bottom: 2px;
+    text-decoration: none;
+    color: #2F3E46;
+}
+
+.inner_lp_toc .scorm_item a.chapter_module {
+    font-weight: normal;
+    margin-right: 10px;
+}
+.inner_lp_toc .scorm_item_highlight {
+    border: 1px solid #999;
+    background:#999;
+    font-weight:bold;
+    text-shadow:0 -1px 1px #666;
+    background-image:-webkit-gradient(linear,left top,left bottom,from(#666),to(#999));
+    background-image:-webkit-linear-gradient(top,#666,#999);
+    background-image:-moz-linear-gradient(top,#666,#999);
+    background-image:-ms-linear-gradient(top,#666,#999);
+    background-image:-o-linear-gradient(top,#666,#999);
+    background-image:linear-gradient(top,#666,#999);
+    margin-right: 0px;
+    padding: 10px 0px 10px 0px;
+    text-decoration: none;
+}
+
+.inner_lp_toc .scorm_item_highlight a {
+    color:#fff;
+    margin-right: 1px;
+    text-decoration: none;
+    font-weight: bold;
+}
+
+.inner_lp_toc .scorm_item_section {
+    border:1px solid #222;
+    background:#333;
+    font-weight:bold;
+    color:#fff;
+    text-shadow:0 -1px 1px #000;
+    background-image:-webkit-gradient(linear,left top,left bottom,from(#555),to(#333));
+    background-image:-webkit-linear-gradient(top,#555,#333);
+    background-image:-moz-linear-gradient(top,#555,#333);
+    background-image:-ms-linear-gradient(top,#555,#333);
+    background-image:-o-linear-gradient(top,#555,#333);
+    background-image:linear-gradient(top,#555,#333);
+    margin-right: 1px;
+    padding: 10px 0px 10px 0px;
+    text-decoration: none;
+}
+
+.inner_lp_toc .scorm_item {
+    font-size: 16px;
+    margin-left: 10px;
+    margin-right:10px;
+    text-decoration: none;
+    border-color: rgba(255, 255, 255, 0.3);
+}
+
+.inner_lp_toc .scorm_item_1 {
+    border-bottom: 1px solid #CCCCCC;
+    background:#eee;
+    font-weight:bold;
+    color:#444;
+    text-shadow:0 1px 1px #f6f6f6;
+    background-image:-webkit-gradient(linear,left top,left bottom,from(#fdfdfd),to(#eee));
+    background-image:-webkit-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-moz-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-ms-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-o-linear-gradient(top,#fdfdfd,#eee);
+    background-image:linear-gradient(top,#fdfdfd,#eee);
+    margin-right: 1px;
+    padding: 10px 0px 10px 0px;
+    text-decoration: none;
+    font-weight: normal;
+    background:#FDFDFD;
+}
+
+.inner_lp_toc .scorm_item_2 {
+    background-image:-webkit-gradient(linear,left top,left bottom,from(#fdfdfd),to(#eee));
+    background-image:-webkit-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-moz-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-ms-linear-gradient(top,#fdfdfd,#eee);
+    background-image:-o-linear-gradient(top,#fdfdfd,#eee);
+    background-image:linear-gradient(top,#fdfdfd,#eee);
+    border-bottom: 1px solid #CCCCCC;
+    color: #444444;
+    font-weight: bold;
+    text-shadow: 0 1px 1px #F6F6F6;
+    margin-right: 1px;
+    padding: 10px 0px 10px 0px;
+    text-decoration: none;
+    font-weight: normal;
+}
+
+.inner_lp_toc .scorm_item_section .scorm_item:before
+{
+    content : url('../../img/lp_section.png');  /* from main/newscorm/lp_controller.php file */
+    vertical-align: text-top;
+    margin-right : 5px;
+}
+
+.scorm_section_level_0 {
+    padding : 0 0 0 0;
+}
+
+.scorm_section_level_1 {
+    padding : 0 0.5em 0 2em;
+}
+
+.scorm_section_level_2 {
+    padding : 0 0.5em 0 4em;
+}
+
+.scorm_section_level_3 {
+    padding : 0 0.5em 0 6em;
+}
+
+.scorm_section_level_4 {
+    padding : 0 0.5em 0 8em;
+}
+
+.scorm_section_level_5 {
+    padding : 0 0.5em 0 10em;
+}
+
+.scorm_item_level_0 {
+    padding : 0 0 0 0;
+}
+
+.scorm_item_level_1 {
+    padding : 0 0.5em 0 1.5em;
+}
+
+.scorm_item_level_2 {
+    padding : 0 0.5em 0 3em;
+}
+
+.scorm_item_level_3 {
+    padding : 0 0.5em 0 4.5em;
+}
+
+.scorm_item_level_4 {
+    padding : 0 0.5em 0 6em;
+}
+
+.scorm_item_level_5 {
+    padding : 0 0.5em 0 7.5em;
+}
+
+/* end of copy of default_scorm.css */
+
+
 .scormpage {
 	height: 100%;
 }
@@ -76,8 +239,6 @@
 }
 .inner_lp_toc .scorm_title_text {
 	margin-left: 10px;
- //padding: 2px;
- //cambiado no existe
 }
 .inner_lp_toc .scorm_status_img {
 	margin:0px;

+ 23 - 13
main/dashboard/block.class.php

@@ -2,38 +2,48 @@
 /* For licensing terms, see /license.txt */
 
 /**
- * This file contains class used parent class for blocks plugins 
+ * This file contains class used parent class for blocks plugins
  * @author Christian Fasanando <christian1827@gmail.com>
  * @package chamilo.dashboard
  */
 
 /**
  * Parent class for controller Blocks from dashboard plugin
- * @package chamilo.dashboard 
+ * @package chamilo.dashboard
  */
- 
-class Block {
 
+class Block
+{
 	/**
 	 * Contructor
 	 */
-    public function __construct() {}
-    
+    public function __construct()
+    {
+
+    }
+
     /**
      * Display small blocks, @todo it will be implemented for next version
      */
-    public function display_small() {}
-    
+    public function display_small()
+    {
+
+    }
+
     /**
      * Display larges blocks, @todo it will be implemented for next version
      */
-    public function display_large() {}
-    
-    public function get_block_path(){              
+    public function display_large()
+    {
+
+    }
+
+    public function get_block_path()
+    {
         $result = get_class($this);
+
         return $result;
     }
-    
 }
 
-?>
+?>

+ 6 - 6
main/document/document.inc.php

@@ -186,8 +186,8 @@ function create_document_link($document_data, $show_as_icon = false, $counter =
     } elseif (strstr($path, 'shared_folder_session_')) {
         $tooltip_title_alt = get_lang('UserFolders') . ' (' . api_get_session_name(api_get_session_id()) . ')';
     } elseif (strstr($tooltip_title, 'sf_user_')) {
-        $userinfo = Database::get_user_info_from_id(substr($tooltip_title, 8));
-        $tooltip_title_alt = get_lang('UserFolder') . ' ' . api_get_person_name($userinfo['firstname'], $userinfo['lastname']);
+        $userinfo = api_get_user_info(substr($tooltip_title, 8));
+        $tooltip_title_alt = get_lang('UserFolder') . ' ' . $userinfo['complete_name'];
     } elseif ($path == '/chat_files') {
         $tooltip_title_alt = get_lang('ChatFiles');
     } elseif ($path == '/learning_path') {
@@ -379,7 +379,7 @@ function build_document_icon_tag($type, $path) {
                 $basename = get_lang('UserFolders');
             }
         } elseif (strstr($basename, 'sf_user_')) {
-            $userinfo = Database::get_user_info_from_id(substr($basename, 8));
+            $userinfo = api_get_user_info(substr($basename, 8));
             $image_path = UserManager::get_user_picture_path_by_id(substr($basename, 8), 'web', false, true);
 
             if ($image_path['file'] == 'unknown.jpg') {
@@ -390,7 +390,7 @@ function build_document_icon_tag($type, $path) {
                 $icon = $image_path['dir'] . $image_path['file'];
             }
 
-            $basename = get_lang('UserFolder') . ' ' . api_get_person_name($userinfo['firstname'], $userinfo['lastname']);
+            $basename = get_lang('UserFolder') . ' ' . $userinfo['complete_name'];
         } elseif (strstr($path, 'shared_folder_session_')) {
             if ($is_allowed_to_edit) {
                 $basename = '***(' . api_get_session_name($current_session_id) . ')*** ' . get_lang('HelpUsersFolder');
@@ -557,7 +557,7 @@ function build_edit_icons($document_data, $id, $is_template, $is_read_only = 0,
             }
         }
 
-        //Move button
+        // Move button.
         if ($is_certificate_mode || in_array($path, DocumentManager::get_system_folders())) {
             $modify_icons .= '&nbsp;' . Display::return_icon('move_na.png', get_lang('Move'), array(), ICON_SIZE_SMALL) . '</a>';
         } else {
@@ -586,7 +586,7 @@ function build_edit_icons($document_data, $id, $is_template, $is_read_only = 0,
             }
         }
 
-        //Delete button
+        // Delete button
         if (in_array($path, DocumentManager::get_system_folders())) {
             $modify_icons .= '&nbsp;' . Display::return_icon('delete_na.png', get_lang('ThisFolderCannotBeDeleted'), array(), ICON_SIZE_SMALL);
         } else {

+ 137 - 64
main/document/document.php

@@ -35,6 +35,8 @@ $language_file = array('document', 'slideshow', 'gradebook', 'create_course');
 require_once '../inc/global.inc.php';
 $current_course_tool = TOOL_DOCUMENT;
 $this_section = SECTION_COURSES;
+$to_user_id = null;
+$parent_id = null;
 
 require_once 'document.inc.php';
 $lib_path = api_get_path(LIBRARY_PATH);
@@ -61,6 +63,7 @@ $base_work_dir = $sys_course_path.$course_dir;
 $http_www = api_get_path(WEB_COURSE_PATH).$_course['path'].'/document';
 $document_path = $base_work_dir;
 $plugin_jcapture = api_get_path(WEB_PLUGIN_PATH).'jcapture/lib/jcapture.jar';
+
 //Removing sessions
 unset($_SESSION['draw_dir']);
 unset($_SESSION['paint_dir']);
@@ -91,14 +94,16 @@ if (empty($course_info)) {
 $dbl_click_id = 0; // Used for avoiding double-click
 
 $selectcat = isset($_GET['selectcat']) ? Security::remove_XSS($_GET['selectcat']) : null;
+$moveTo = isset($_POST['move_to']) ? Security::remove_XSS($_POST['move_to']) : null;
 
 /* 	Constants and variables */
 $session_id = api_get_session_id();
 $course_code = api_get_course_id();
-$to_group_id = api_get_group_id();
+$groupId = api_get_group_id();
 
 $is_allowed_to_edit = api_is_allowed_to_edit(null, true);
 $group_member_with_upload_rights = false;
+$groupId = api_get_group_id();
 
 // If the group id is set, we show them group documents
 $group_properties = array();
@@ -126,11 +131,10 @@ if (api_get_group_id()) {
             //they are allowed to upload
             $group_member_with_upload_rights = true;
         } else {
-            $to_group_id = 0;
+            $groupId = 0;
         }
     } elseif ($group_properties['doc_state'] == 1) {
         // Documents are public
-        $to_group_id = api_get_group_id();
         $interbreadcrumb[] = array('url' => '../group/group.php', 'name' => get_lang('Groups'));
         $interbreadcrumb[] = array('url' => '../group/group_space.php?gidReq='.api_get_group_id(), 'name' => get_lang('GroupSpace').' '.$group_properties['name']);
         //allowed to upload?
@@ -138,13 +142,10 @@ if (api_get_group_id()) {
             // Only courseadmin or group members can upload
             $group_member_with_upload_rights = true;
         }
-    } else { // Documents not active for this group
-        $to_group_id = 0;
     }
     $_SESSION['group_member_with_upload_rights'] = $group_member_with_upload_rights;
 } else {
     $_SESSION['group_member_with_upload_rights'] = false;
-    $to_group_id = 0;
 }
 
 //Actions
@@ -283,12 +284,10 @@ if (isset($document_id) && empty($action)) {
         // If there is a session defined and asking for the document *from the session* didn't work, try it from the course (out of a session context)
         $document_data = DocumentManager::get_document_data_by_id($document_id, api_get_course_id(), true, 0);
     }
-    //If the document is not a folder we show the document
+    // If the document is not a folder we show the document.
     if ($document_data) {
         $parent_id = $document_data['parent_id'];
-
-        //$visibility = DocumentManager::is_visible_by_id($document_id, $course_info, $session_id, api_get_user_id());
-        $visibility = DocumentManager::check_visibility_tree($document_id, api_get_course_id(), $session_id, api_get_user_id());
+        $visibility = DocumentManager::check_visibility_tree($document_id, api_get_course_id(), $session_id, api_get_user_id(), $groupId);
 
         if (!empty($document_data['filetype']) && $document_data['filetype'] == 'file') {
             if ($visibility && api_is_allowed_to_session_edit()) {
@@ -351,7 +350,11 @@ if (!$parent_id) {
 $current_folder_id = $document_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['curdirpath']) &&
+    $_GET['curdirpath'] == '/certificates' &&
+    isset($_GET['set_preview']) &&
+    $_GET['set_preview'] == strval(intval($_GET['set_preview']))
+) {
     if (isset($_GET['set_preview'])) {
         // Generate document HTML
         $content_html = DocumentManager::replace_user_info_into_html(api_get_user_id(), api_get_course_id(), true);
@@ -392,7 +395,6 @@ if (isset($_GET['curdirpath']) && $_GET['curdirpath'] == '/certificates' && isse
     }
 }
 
-
 // Is the document tool visible?
 // Check whether the tool is actually visible
 $table_course_tool = Database::get_course_table(TABLE_TOOL_LIST);
@@ -402,7 +404,7 @@ $tool_result = Database::query($tool_sql);
 $tool_row = Database::fetch_array($tool_result);
 $tool_visibility = $tool_row['visibility'];
 
-if ($tool_visibility == '0' && $to_group_id == '0' && !($is_allowed_to_edit || $group_member_with_upload_rights)) {
+if ($tool_visibility == '0' && $groupId == '0' && !($is_allowed_to_edit || $group_member_with_upload_rights)) {
     api_not_allowed(true);
 }
 
@@ -417,7 +419,7 @@ function confirmation (name) {
 </script>";
 
 // If they are looking at group documents they can't see the root
-if ($to_group_id != 0 && $curdirpath == '/') {
+if ($groupId != 0 && $curdirpath == '/') {
     $curdirpath = $group_properties['directory'];
     $curdirpathurl = urlencode($group_properties['directory']);
 }
@@ -438,34 +440,74 @@ if ($session_id == 0) {
     if (!file_exists($base_work_dir.'/shared_folder')) {
         $usf_dir_title = get_lang('UserFolders');
         $usf_dir_name = '/shared_folder';
-        $to_group_id = 0;
+        $groupId = 0;
         $visibility = 0;
-        create_unexisting_directory($_course, api_get_user_id(), $session_id, $to_group_id, $to_user_id, $base_work_dir, $usf_dir_name, $usf_dir_title, $visibility);
+        create_unexisting_directory(
+            $_course,
+            api_get_user_id(),
+            $session_id,
+            $groupId,
+            $to_user_id,
+            $base_work_dir,
+            $usf_dir_name,
+            $usf_dir_title,
+            $visibility
+        );
     }
     // Create dynamic user shared folder
     if (!file_exists($base_work_dir.'/shared_folder/sf_user_'.api_get_user_id())) {
         $usf_dir_title = api_get_person_name($_user['firstName'], $_user['lastName']);
         $usf_dir_name = '/shared_folder/sf_user_'.api_get_user_id();
-        $to_group_id = 0;
+        $groupId = 0;
         $visibility = 1;
-        create_unexisting_directory($_course, api_get_user_id(), $session_id, $to_group_id, $to_user_id, $base_work_dir, $usf_dir_name, $usf_dir_title, $visibility);
+        create_unexisting_directory(
+            $_course,
+            api_get_user_id(),
+            $session_id,
+            $groupId,
+            $to_user_id,
+            $base_work_dir,
+            $usf_dir_name,
+            $usf_dir_title,
+            $visibility
+        );
     }
 } else {
     //Create shared folder session
     if (!file_exists($base_work_dir.'/shared_folder_session_'.$session_id)) {
         $usf_dir_title = get_lang('UserFolders').' ('.api_get_session_name($session_id).')';
         $usf_dir_name = '/shared_folder_session_'.$session_id;
-        $to_group_id = 0;
+        $groupId = 0;
         $visibility = 0;
-        create_unexisting_directory($_course, api_get_user_id(), $session_id, $to_group_id, $to_user_id, $base_work_dir, $usf_dir_name, $usf_dir_title, $visibility);
+        create_unexisting_directory(
+            $_course,
+            api_get_user_id(),
+            $session_id,
+            $groupId,
+            $to_user_id,
+            $base_work_dir,
+            $usf_dir_name,
+            $usf_dir_title,
+            $visibility
+        );
     }
     //Create dynamic user shared folder into a shared folder session
     if (!file_exists($base_work_dir.'/shared_folder_session_'.$session_id.'/sf_user_'.api_get_user_id())) {
         $usf_dir_title = api_get_person_name($_user['firstName'], $_user['lastName']).'('.api_get_session_name($session_id).')';
         $usf_dir_name = '/shared_folder_session_'.$session_id.'/sf_user_'.api_get_user_id();
-        $to_group_id = 0;
+        $groupId = 0;
         $visibility = 1;
-        create_unexisting_directory($_course, api_get_user_id(), $session_id, $to_group_id, $to_user_id, $base_work_dir, $usf_dir_name, $usf_dir_title, $visibility);
+        create_unexisting_directory(
+            $_course,
+            api_get_user_id(),
+            $session_id,
+            $groupId,
+            $to_user_id,
+            $base_work_dir,
+            $usf_dir_name,
+            $usf_dir_title,
+            $visibility
+        );
     }
 }
 
@@ -518,10 +560,16 @@ $js_path = api_get_path(WEB_LIBRARY_PATH).'javascript/';
 
 $htmlHeadXtra[] = '<link rel="stylesheet" href="'.$js_path.'jquery-jplayer/skins/chamilo/jplayer.blue.monday.css" type="text/css">';
 $htmlHeadXtra[] = '<script type="text/javascript" src="'.$js_path.'jquery-jplayer/jquery.jplayer.min.js"></script>';
-//$htmlHeadXtra[] = '<script type="text/javascript" src="'.$js_path.'jquery-jplayer/jquery.jplayer.inspector.js"></script>';
-$to_group_id = api_get_group_id();
 $mediaplayer_path = api_get_path(WEB_LIBRARY_PATH).'mediaplayer/player.swf';
-$docs_and_folders = DocumentManager::get_all_document_data($_course, $curdirpath, $to_group_id, null, $is_allowed_to_edit || $group_member_with_upload_rights, false);
+
+$docs_and_folders = DocumentManager::get_all_document_data(
+    $_course,
+    $curdirpath,
+    $groupId,
+    null,
+    $is_allowed_to_edit || $group_member_with_upload_rights,
+    false
+);
 
 $count = 1;
 $jquery = null;
@@ -531,7 +579,7 @@ if (!empty($docs_and_folders)) {
         if ($file['filetype'] == 'file') {
             $path_info = pathinfo($file['path']);
             $extension = strtolower($path_info['extension']);
-            //@todo use a js loop to autogenerate this code
+            //@todo use a js loop to auto generate this code
             if (in_array($extension, array('ogg', 'mp3', 'wav'))) {
                 // Get the document data from the ID
                 $document_data = DocumentManager::get_document_data_by_id($file['id'], api_get_course_id(), false, $session_id);
@@ -568,7 +616,7 @@ Display::display_header('', 'Doc');
 event_access_tool(TOOL_DOCUMENT);
 
 /* 	DISPLAY */
-if ($to_group_id != 0) { // Add group name after for group documents
+if ($groupId != 0) { // Add group name after for group documents
     $add_group_to_title = ' ('.$group_properties['name'].')';
 }
 
@@ -588,7 +636,7 @@ if (
     $is_allowed_to_edit ||
     $group_member_with_upload_rights ||
     is_my_shared_folder(api_get_user_id(), $curdirpath, $session_id) ||
-    is_my_shared_folder(api_get_user_id(), Security::remove_XSS($_POST['move_to']), $session_id)
+    is_my_shared_folder(api_get_user_id(), $moveTo, $session_id)
 ) {
 
     if (isset($_GET['move']) && $_GET['move'] != '') {
@@ -609,7 +657,7 @@ if (
         $document_to_move = DocumentManager::get_document_data_by_id($my_get_move, api_get_course_id(), false, $session_id);
         $move_path = $document_to_move['path'];
         if (!empty($document_to_move)) {
-            $folders = DocumentManager::get_all_document_folders($_course, $to_group_id, $is_allowed_to_edit || $group_member_with_upload_rights);
+            $folders = DocumentManager::get_all_document_folders($_course, $groupId, $is_allowed_to_edit || $group_member_with_upload_rights);
 
             //filter if is my shared folder. TODO: move this code to build_move_to_selector function
             if (is_my_shared_folder(api_get_user_id(), $curdirpath, $session_id) && !$is_allowed_to_edit) {
@@ -632,7 +680,7 @@ if (
         }
     }
 
-    if (isset($_POST['move_to']) && isset($_POST['move_file'])) {
+    if (!empty($moveTo) && isset($_POST['move_file'])) {
 
         if (!$is_allowed_to_edit) {
             if (DocumentManager::check_readonly($_course, api_get_user_id(), $_POST['move_file'])) {
@@ -651,22 +699,22 @@ if (
         // Security fix: make sure they can't move files that are not in the document table
         if (!empty($document_to_move)) {
 
-            $real_path_target = $base_work_dir.$_POST['move_to'].'/'.basename($document_to_move['path']);
+            $real_path_target = $base_work_dir.$moveTo.'/'.basename($document_to_move['path']);
             $fileExist = false;
             if (file_exists($real_path_target)) {
                 $fileExist = true;
             }
-            if (move($base_work_dir.$document_to_move['path'], $base_work_dir.$_POST['move_to'])) {
-                update_db_info('update', $document_to_move['path'], $_POST['move_to'].'/'.basename($document_to_move['path']));
+            if (move($base_work_dir.$document_to_move['path'], $base_work_dir.$moveTo)) {
+                update_db_info('update', $document_to_move['path'], $moveTo.'/'.basename($document_to_move['path']));
 
                 //update database item property
                 $doc_id = $_POST['move_file'];
 
                 if (is_dir($real_path_target)) {
-                    api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'FolderMoved', api_get_user_id(), $to_group_id, null, null, null, $session_id);
+                    api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'FolderMoved', api_get_user_id(), $groupId, null, null, null, $session_id);
                     Display::display_confirmation_message(get_lang('DirMv'));
                 } elseif (is_file($real_path_target)) {
-                    api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'DocumentMoved', api_get_user_id(), $to_group_id, null, null, null, $session_id);
+                    api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'DocumentMoved', api_get_user_id(), $groupId, null, null, null, $session_id);
                     Display::display_confirmation_message(get_lang('DocMv'));
                 }
 
@@ -692,7 +740,10 @@ if (
 
 /* 	DELETE FILE OR DIRECTORY */
 //Only teacher and all users into their group
-if ($is_allowed_to_edit || $group_member_with_upload_rights || is_my_shared_folder(api_get_user_id(), $curdirpath, $session_id)) {
+if ($is_allowed_to_edit ||
+    $group_member_with_upload_rights ||
+    is_my_shared_folder(api_get_user_id(), $curdirpath, $session_id)
+) {
     if (isset($_GET['deleteid'])) {
         if (!$is_allowed_to_edit) {
             if (api_is_coach()) {
@@ -804,9 +855,11 @@ if ($is_allowed_to_edit || $group_member_with_upload_rights || is_my_shared_fold
 
 /* 	CREATE DIRECTORY */
 //Only teacher and all users into their group and any user into his/her shared folder
-if ($is_allowed_to_edit || $group_member_with_upload_rights || is_my_shared_folder(api_get_user_id(), $curdirpath, $session_id)) {
+if ($is_allowed_to_edit ||
+    $group_member_with_upload_rights ||
+    is_my_shared_folder(api_get_user_id(), $curdirpath, $session_id)
+) {
     // Create directory with $_POST data
-
     if (isset($_POST['create_dir']) && $_POST['dirname'] != '') {
         // Needed for directory creation
         $post_dir_name = $_POST['dirname'];
@@ -828,15 +881,23 @@ if ($is_allowed_to_edit || $group_member_with_upload_rights || is_my_shared_fold
             $dir_name = disable_dangerous_file($dir_name);
             $dir_check = $base_work_dir.$dir_name;
 
-
             if (!is_dir($dir_check)) {
-                $created_dir = create_unexisting_directory($_course, api_get_user_id(), $session_id, $to_group_id, $to_user_id, $base_work_dir, $dir_name, $post_dir_name);
+                $visibility = empty($groupId) ? null : 1;
+
+                $created_dir = create_unexisting_directory(
+                    $_course,
+                    api_get_user_id(),
+                    $session_id,
+                    $groupId,
+                    $to_user_id,
+                    $base_work_dir,
+                    $dir_name,
+                    $post_dir_name,
+                    $visibility
+                );
 
                 if ($created_dir) {
                     Display::display_confirmation_message('<span title="'.$created_dir.'">'.get_lang('DirCr').'</span>', false);
-                    // Uncomment if you want to enter the created dir
-                    //$curdirpath = $created_dir;
-                    //$curdirpathurl = urlencode($curdirpath);
                 } else {
                     Display::display_error_message(get_lang('CannotCreateDir'));
                 }
@@ -854,7 +915,10 @@ if ($is_allowed_to_edit || $group_member_with_upload_rights || is_my_shared_fold
 
 /* 	VISIBILITY COMMANDS */
 if ($is_allowed_to_edit) {
-    if ((isset($_GET['set_invisible']) && !empty($_GET['set_invisible'])) || (isset($_GET['set_visible']) && !empty($_GET['set_visible'])) && $_GET['set_visible'] != '*' && $_GET['set_invisible'] != '*') {
+    if ((isset($_GET['set_invisible']) && !empty($_GET['set_invisible'])) ||
+        (isset($_GET['set_visible']) && !empty($_GET['set_visible'])) &&
+        $_GET['set_visible'] != '*' && $_GET['set_invisible'] != '*'
+    ) {
         // Make visible or invisible?
         if (isset($_GET['set_visible'])) {
             $update_id = intval($_GET['set_visible']);
@@ -886,7 +950,10 @@ if ($is_allowed_to_edit) {
 
 /* 	TEMPLATE ACTION */
 //Only teacher and all users into their group
-if ($is_allowed_to_edit || $group_member_with_upload_rights || is_my_shared_folder(api_get_user_id(), $curdirpath, $session_id)) {
+if ($is_allowed_to_edit ||
+    $group_member_with_upload_rights ||
+    is_my_shared_folder(api_get_user_id(), $curdirpath, $session_id)
+) {
     if (isset($_GET['add_as_template']) && !isset($_POST['create_template'])) {
 
         $document_id_for_template = intval($_GET['add_as_template']);
@@ -974,12 +1041,12 @@ if (isset($_GET['curdirpath']) && $_GET['curdirpath'] == '/certificates' && isse
 
 /* 	GET ALL DOCUMENT DATA FOR CURDIRPATH */
 if (isset($_GET['keyword']) && !empty($_GET['keyword'])) {
-    $docs_and_folders = DocumentManager::get_all_document_data($_course, $curdirpath, $to_group_id, null, $is_allowed_to_edit || $group_member_with_upload_rights, true);
+    $docs_and_folders = DocumentManager::get_all_document_data($_course, $curdirpath, $groupId, null, $is_allowed_to_edit || $group_member_with_upload_rights, true);
 } else {
-    $docs_and_folders = DocumentManager::get_all_document_data($_course, $curdirpath, $to_group_id, null, $is_allowed_to_edit || $group_member_with_upload_rights, false);
+    $docs_and_folders = DocumentManager::get_all_document_data($_course, $curdirpath, $groupId, null, $is_allowed_to_edit || $group_member_with_upload_rights, false);
 }
-if (api_get_group_id() != 0) {
 
+if (api_get_group_id() != 0) {
     if (api_is_allowed_to_edit() || GroupManager::is_subscribed(api_get_user_id(), api_get_group_id()) || GroupManager :: is_tutor_of_group(api_get_user_id(), api_get_group_id())) {
         $folders = DocumentManager::get_all_document_folders($_course, api_get_group_id(), $is_allowed_to_edit || $group_member_with_upload_rights);
     }
@@ -987,10 +1054,10 @@ if (api_get_group_id() != 0) {
     $folders = DocumentManager::get_all_document_folders($_course, api_get_group_id(), $is_allowed_to_edit || $group_member_with_upload_rights);
 }
 
-//$folders = DocumentManager::get_all_document_folders($_course, $to_group_id, $is_allowed_to_edit || $group_member_with_upload_rights);
-if ($folders === false) {
+if (!isset($folders) || $folders === false) {
     $folders = array();
 }
+
 echo '<div id="appletplace"></div>';
 echo '<div class="actions">';
 if (!$is_certificate_mode) {
@@ -1021,7 +1088,10 @@ if ($is_certificate_mode && $curdirpath != '/certificates') {
 
 $column_show = array();
 
-if ($is_allowed_to_edit || $group_member_with_upload_rights || is_my_shared_folder(api_get_user_id(), $curdirpath, $session_id)) {
+if ($is_allowed_to_edit ||
+    $group_member_with_upload_rights ||
+    is_my_shared_folder(api_get_user_id(), $curdirpath, $session_id)
+) {
 
     // TODO:check enable more options for shared folders
     /* CREATE NEW DOCUMENT OR NEW DIRECTORY / GO TO UPLOAD / DOWNLOAD ZIPPED FOLDER */
@@ -1118,17 +1188,18 @@ if ($is_allowed_to_edit || $group_member_with_upload_rights || is_my_shared_fold
 
 $table_footer = '';
 $total_size = 0;
+$sortable_data = array();
 
 if (isset($docs_and_folders) && is_array($docs_and_folders)) {
-    if (
-        api_get_group_id() == 0 ||
-        ( api_is_allowed_to_edit() || GroupManager::is_subscribed(api_get_user_id(), api_get_group_id()) ||
-        GroupManager :: is_tutor_of_group(api_get_user_id(), api_get_group_id()))
+    if (api_get_group_id() == 0 ||
+        (
+            api_is_allowed_to_edit() ||
+            GroupManager::is_subscribed(api_get_user_id(), api_get_group_id()) ||
+            GroupManager :: is_tutor_of_group(api_get_user_id(), api_get_group_id())
+        )
     ) {
-        // Create a sortable table with our data
-        $sortable_data = array();
-
         $count = 1;
+        $countedPaths = array();
         foreach ($docs_and_folders as $key => $document_data) {
             $row = array();
             $row['id'] = $document_data['id'];
@@ -1214,7 +1285,10 @@ if (isset($docs_and_folders) && is_array($docs_and_folders)) {
             $row[] = $size;
             $row[] = $document_name;
 
-            $total_size = $total_size + $size;
+            if (!isset($countedPaths[$document_data['path']])) {
+                $total_size = $total_size + $size;
+                $countedPaths[$document_data['path']] = true;
+            }
 
             if ((isset($_GET['keyword']) && search_keyword($document_name, $_GET['keyword'])) || !isset($_GET['keyword']) || empty($_GET['keyword'])) {
                 $sortable_data[] = $row;
@@ -1227,7 +1301,6 @@ if (isset($docs_and_folders) && is_array($docs_and_folders)) {
 }
 
 if (!is_null($docs_and_folders)) {
-
     // Show download zipped folder icon
     global $total_size;
     if (!$is_certificate_mode && $total_size != 0 && (api_get_setting('students_download_folders') == 'true' || api_is_allowed_to_edit() || api_is_platform_admin())) {
@@ -1254,8 +1327,8 @@ echo '</div>'; //end actions
 if (isset($message)) {
     echo $message;
 }
-if (isset($_POST['move_to'])) {
-    $document_id = DocumentManager::get_document_id($course_info, $_POST['move_to']);
+if (!empty($moveTo)) {
+    $document_id = DocumentManager::get_document_id($course_info, $moveTo);
 }
 
 if (isset($_GET['createdir']) && isset($_POST['dirname']) && $_POST['dirname'] != '') {
@@ -1296,9 +1369,9 @@ if (count($row) == 12) {
 }
 
 $default_column = $is_allowed_to_edit ? 2 : 1;
-$tablename = $is_allowed_to_edit ? 'teacher_table' : 'student_table';
+$tableName = $is_allowed_to_edit ? 'teacher_table' : 'student_table';
 
-$table = new SortableTableFromArrayConfig($sortable_data, $default_column, 20, $tablename, $column_show, $column_order, 'ASC');
+$table = new SortableTableFromArrayConfig($sortable_data, $default_column, 20, $tableName, $column_show, $column_order, 'ASC');
 $query_vars = array();
 if (isset($_GET['keyword'])) {
     $query_vars['keyword'] = Security::remove_XSS($_GET['keyword']);

+ 103 - 106
main/document/edit_document.php

@@ -32,35 +32,34 @@
 $language_file = array('document', 'gradebook');
 
 /*	Included libraries */
-
 require_once '../inc/global.inc.php';
 
 // Template's javascript
 $htmlHeadXtra[] = '
 <script>
-var hide_bar = function() {    
-    $("#template_col").hide(); 
-    $("#doc_form").removeClass("span9"); 
-    $("#doc_form").addClass("span11");   
+var hide_bar = function() {
+    $("#template_col").hide();
+    $("#doc_form").removeClass("span9");
+    $("#doc_form").addClass("span11");
     $("#hide_bar_template").css({"background-image" : \'url("../img/hide2.png")\'})
 }
 
-$(document).ready(function() {   
+$(document).ready(function() {
     if ($(window).width() <= 785 ) {
         hide_bar();
     }
-    
+
     $("#hide_bar_template").toggle(
-        function() { 
+        function() {
             hide_bar();
         },
-        function() { 
-            $("#template_col").show(); 
-            $("#doc_form").removeClass("span11"); 
-            $("#doc_form").addClass("span9"); 
-            $(this).css("background-image", \'url("../img/hide0.png")\'); 
-        }            
-    );    
+        function() {
+            $("#template_col").show();
+            $("#doc_form").removeClass("span11");
+            $("#doc_form").addClass("span9");
+            $(this).css("background-image", \'url("../img/hide0.png")\');
+        }
+    );
 });
 
 function InnerDialogLoaded() {
@@ -113,36 +112,33 @@ if (api_is_in_group()) {
 
 $dir = '/';
 
+$currentDirPath = isset($_GET['curdirpath']) ? Security::remove_XSS($_GET['curdirpath']) : null;
+
 if (isset($_GET['id'])) {
     $document_data  = DocumentManager::get_document_data_by_id($_GET['id'], api_get_course_id(), true);
     $document_id    = $document_data['id'];
     $file           = $document_data['path'];
-    $parent_id      = DocumentManager::get_document_id($course_info, dirname($file));    
-    $dir            = dirname($document_data['path']);    
+    $parent_id      = DocumentManager::get_document_id($course_info, dirname($file));
+    $dir            = dirname($document_data['path']);
     $dir_original   =  $dir;
-    
+
     $doc            = basename($file);
-    $my_cur_dir_path = Security::remove_XSS($_GET['curdirpath']);
     $readonly       = $document_data['readonly'];
 }
 
 if (empty($document_data)) {
     api_not_allowed();
-}  
+}
 
 $is_certificate_mode = DocumentManager::is_certificate_mode($dir);
 
 //Call from
-$call_from_tool = Security::remove_XSS($_GET['origin']);
-$slide_id = Security::remove_XSS($_GET['origin_opt']);
+$call_from_tool = isset($_GET['origin']) ? Security::remove_XSS($_GET['origin']) : null;
+$slide_id = isset($_GET['origin_opt']) ? Security::remove_XSS($_GET['origin_opt']) : null;
 $file_name = $doc;
-
 $group_document = false;
-
 $current_session_id = api_get_session_id();
 $user_id = api_get_user_id();
-
-
 $doc_tree = explode('/', $file);
 $count_dir = count($doc_tree) - 2; // "2" because at the begin and end there are 2 "/"
 
@@ -152,20 +148,20 @@ if (!empty($group_properties['directory'])) {
 }
 $relative_url = '';
 for ($i = 0; $i < ($count_dir); $i++) {
-	$relative_url .= '../';
+    $relative_url .= '../';
 }
 
 $html_editor_config = array(
-	'ToolbarSet' => (api_is_allowed_to_edit(null, true) ? 'Documents' :'DocumentsStudent'),
-	'Width' => '100%',
-	'Height' => '600',
-	'FullPage' => true,
-	'InDocument' => true,
-	'CreateDocumentDir' => $relative_url,
-	'CreateDocumentWebDir' => (empty($group_properties['directory']))
-		? api_get_path(WEB_COURSE_PATH).$_course['path'].'/document/'
-		: api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document'.$group_properties['directory'].'/',
-	'BaseHref' =>  api_get_path(WEB_COURSE_PATH).$_course['path'].'/document'.$dir
+    'ToolbarSet' => (api_is_allowed_to_edit(null, true) ? 'Documents' :'DocumentsStudent'),
+    'Width' => '100%',
+    'Height' => '600',
+    'FullPage' => true,
+    'InDocument' => true,
+    'CreateDocumentDir' => $relative_url,
+    'CreateDocumentWebDir' => (empty($group_properties['directory']))
+        ? api_get_path(WEB_COURSE_PATH).$_course['path'].'/document/'
+        : api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document'.$group_properties['directory'].'/',
+    'BaseHref' =>  api_get_path(WEB_COURSE_PATH).$_course['path'].'/document'.$dir
 );
 
 if ($is_certificate_mode) {
@@ -183,21 +179,21 @@ $dbTable = Database::get_course_table(TABLE_DOCUMENT);
 $course_id = api_get_course_int_id();
 
 if (!empty($group_id)) {
-	$req_gid = '&amp;gidReq='.$group_id;
-	$interbreadcrumb[] = array ('url' => '../group/group_space.php?gidReq='.$group_id, 'name' => get_lang('GroupSpace'));
+	$interbreadcrumb[] = array ('url' => '../group/group_space.php?'.api_get_cidreq(), 'name' => get_lang('GroupSpace'));
 	$group_document = true;
 	$noPHP_SELF = true;
 }
 
-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'));
+if (!$is_certificate_mode) {
+	$interbreadcrumb[]=array("url"=>"./document.php?curdirpath=".urlencode($currentDirPath).'&'.api_get_cidreq(), "name"=> get_lang('Documents'));
+} else {
+    $interbreadcrumb[]= array('url' => '../gradebook/'.$_SESSION['gradebook_dest'], 'name' => get_lang('Gradebook'));
+}
 
 // Interbreadcrumb for the current directory root path
 if (empty($document_data['parents'])) {
     $interbreadcrumb[] = array('url' => '#', 'name' => $document_data['title']);
-} else {    
+} else {
     foreach($document_data['parents'] as $document_sub_data) {
         if ($document_data['title'] == $document_sub_data['title']) {
             continue;
@@ -206,8 +202,8 @@ if (empty($document_data['parents'])) {
     }
 }
 
-if (!is_allowed_to_edit) {
-	api_not_allowed(true);
+if (!api_is_allowed_to_edit()) {
+    api_not_allowed(true);
 }
 
 event_access_tool(TOOL_DOCUMENT);
@@ -224,53 +220,53 @@ if (!is_allowed_to_edit()) {
 /*	Code to change the comment	*/
 
 if (isset($_POST['comment'])) {
-	// Fixing the path if it is wrong	
+	// Fixing the path if it is wrong
 	$comment 	     = trim(Database::escape_string($_POST['comment']));
-	$title 		     = trim(Database::escape_string($_POST['title'])); 
+	$title 		     = trim(Database::escape_string($_POST['title']));
     //Just in case see BT#3525
     if (empty($title)) {
 		$title = $documen_data['title'];
 	}
 	if (empty($title)) {
-		$title = get_document_title($_POST['filename']);		
+		$title = get_document_title($_POST['filename']);
 	}
     if (!empty($document_id)) {
         $query = "UPDATE $dbTable SET comment='".$comment."', title='".$title."' WHERE c_id = $course_id AND id = ".$document_id;
-        Database::query($query);		
+        Database::query($query);
         $info_message     = get_lang('fileModified');
     }
 }
 
 /*	WYSIWYG HTML EDITOR - Program Logic */
 if ($is_allowed_to_edit) {
-	if ($_POST['formSent'] == 1) {
-        
+	if (isset($_POST['formSent']) && $_POST['formSent'] == 1) {
+
 		$filename   = stripslashes($_POST['filename']);
         $extension  = $_POST['extension'];
-        
 		$content    = trim(str_replace(array("\r", "\n"), '', stripslashes($_POST['content'])));
 		$content    = Security::remove_XSS($content, COURSEMANAGERLOWSECURITY);
 
 		if (!strstr($content, '/css/frames.css')) {
 			$content = str_replace('</title></head>', '</title><link rel="stylesheet" href="../css/frames.css" type="text/css" /></head>', $content);
-		}        
+		}
+
         if ($dir == '/') {
             $dir = '';
         }
-        
-		$file = $dir.'/'.$filename.'.'.$extension;        
+
+		$file = $dir.'/'.$filename.'.'.$extension;
 		$read_only_flag = $_POST['readonly'];
 		$read_only_flag = empty($read_only_flag) ? 0 : 1;
-		
+
 		if (empty($filename)) {
 			$msgError = get_lang('NoFileName');
 		} else {
-		    		    
-		    $file_size = filesize($document_data['absolute_path']);	    
-		    		    
+
+		    $file_size = filesize($document_data['absolute_path']);
+
 			if ($read_only_flag == 0) {
 				if (!empty($content)) {
-					if ($fp = @fopen($document_data['absolute_path'], 'w')) {						
+					if ($fp = @fopen($document_data['absolute_path'], 'w')) {
 						// For flv player, change absolute paht temporarely to prevent from erasing it in the following lines
 						$content = str_replace(array('flv=h', 'flv=/'), array('flv=h|', 'flv=/|'), $content);
 
@@ -284,10 +280,10 @@ if ($is_allowed_to_edit) {
 
  						fputs($fp, $content);
 						fclose($fp);
-                        
+
                         $filepath = $document_data['absolute_parent_path'];
-                        
-						if (!is_dir($filepath.'css')) {						    
+
+						if (!is_dir($filepath.'css')) {
 							mkdir($filepath.'css', api_get_permissions_for_new_directories());
 							$doc_id = add_document($_course, $dir.'css', 'folder', 0, 'css');
 							api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'FolderCreated', api_get_user_id(), null, null, null, null, $current_session_id);
@@ -304,14 +300,14 @@ if ($is_allowed_to_edit) {
 							}
 						}
 
-						// "WHAT'S NEW" notification: update table item_property                        
-						$document_id = DocumentManager::get_document_id($_course, $file);   
-                                                
-						if ($document_id) {				
+						// "WHAT'S NEW" notification: update table item_property
+						$document_id = DocumentManager::get_document_id($_course, $file);
+
+						if ($document_id) {
 							update_existing_document($_course, $document_id, $file_size, $read_only_flag);
 							api_item_property_update($_course, TOOL_DOCUMENT, $document_id, 'DocumentUpdated', api_get_user_id(), null, null, null, null, $current_session_id);
 							// Update parent folders
-							item_property_update_on_folder($_course, $dir, api_get_user_id());							                            
+							item_property_update_on_folder($_course, $dir, api_get_user_id());
 							header('Location: document.php?id='.$document_data['parent_id']);
                             exit;
 						} else {
@@ -320,32 +316,29 @@ if ($is_allowed_to_edit) {
 					} else {
 						$msgError = get_lang('Impossible');
 					}
-				} else {					
+				} else {
 					if ($document_id) {
-                        update_existing_document($_course, $document_id, $file_size, $read_only_flag);					
+                        update_existing_document($_course, $document_id, $file_size, $read_only_flag);
 					}
 				}
 			} else {
                 if ($document_id) {
                     update_existing_document($_course, $document_id, $file_size, $read_only_flag);
-                }				
+                }
 			}
 		}
 	}
 }
 
 // Replace relative paths by absolute web paths (e.g. './' => 'http://www.chamilo.org/courses/ABC/document/')
-if (file_exists($document_data['absolute_path'])) {	
+if (file_exists($document_data['absolute_path'])) {
     $path_info = pathinfo($document_data['absolute_path']);
-    $filename = $path_info['filename'];    
+    $filename = $path_info['filename'];
     $extension = $path_info['extension'];
 
 	if (in_array($extension, array('html', 'htm'))) {
 		$content = file($document_data['absolute_path']);
 		$content = implode('', $content);
-		//$path_to_append = api_get_path(WEB_COURSE_PATH).$_course['path'].'/document'.$dir;
-	//	$content = str_replace('="./', '="'.$path_to_append, $content);
-		//$content = str_replace('mp3player.swf?son=.%2F', 'mp3player.swf?son='.urlencode($path_to_append), $content);
 	}
 }
 
@@ -362,7 +355,7 @@ if (isset($msgError)) {
 if (isset($info_message)) {
 	Display::display_confirmation_message($info_message);
 	if (isset($_POST['origin'])) {
-		$slide_id = $_POST['origin_opt'];	
+		$slide_id = $_POST['origin_opt'];
 		$call_from_tool = $_POST['origin'];
 	}
 }
@@ -372,7 +365,7 @@ $document_info  = api_get_item_property_info(api_get_course_int_id(),'document',
 $owner_id       = $document_info['insert_user_id'];
 $last_edit_date = $document_info['lastedit_date'];
 
-if ($owner_id == api_get_user_id() || api_is_platform_admin() || $is_allowed_to_edit || GroupManager :: is_user_in_group(api_get_user_id(), api_get_group_id() )) {	
+if ($owner_id == api_get_user_id() || api_is_platform_admin() || $is_allowed_to_edit || GroupManager :: is_user_in_group(api_get_user_id(), api_get_group_id() )) {
 	$action = api_get_self().'?id='.$document_data['id'];
 	$form = new FormValidator('formEdit', 'post', $action, null, array('class' => 'form-vertical'));
 
@@ -385,15 +378,14 @@ if ($owner_id == api_get_user_id() || api_is_platform_admin() || $is_allowed_to_
 	$form->addElement('hidden', 'showedit');
 	$form->addElement('hidden', 'origin');
 	$form->addElement('hidden', 'origin_opt');
-
     $form->add_textfield('title', get_lang('Title'));
-    
+
 	$defaults['title'] = $document_data['title'];
 
 	$form->addElement('hidden', 'formSent');
 	$defaults['formSent'] = 1;
 
-	$read_only_flag = $_POST['readonly'];
+	$read_only_flag = isset($_POST['readonly']) ? $_POST['readonly'] : null;
 
 	// Desactivation of IE proprietary commenting tags inside the text before loading it on the online editor.
 	// This fix has been proposed by Hubert Borderiou, see Bug #573, http://support.chamilo.org/issues/573
@@ -401,52 +393,57 @@ if ($owner_id == api_get_user_id() || api_is_platform_admin() || $is_allowed_to_
 
 	//if ($extension == 'htm' || $extension == 'html')
 	// HotPotatoes tests are html files, but they should not be edited in order their functionality to be preserved.
-	if (($extension == 'htm' || $extension == 'html') && stripos($dir, '/HotPotatoes_files') === false) {
+
+    $showSystemFolders = api_get_course_setting('show_system_folders');
+    $condition = stripos($dir, '/HotPotatoes_files') === false;
+    if ($showSystemFolders == 1) {
+        $condition = true;
+    }
+	if (($extension == 'htm' || $extension == 'html') && $condition) {
 		if (empty($readonly) && $readonly == 0) {
 			$_SESSION['showedit'] = 1;
-            $form->add_html_editor('content','', false, false, $html_editor_config);
-			//$renderer->setElementTemplate('<div class="row"><div class="label" id="frmModel" style="overflow: visible;"></div><div class="formw">{element}</div></div>', 'content');
-			//$form->add_html_editor('content', '', false, true, $html_editor_config);
+            $form->add_html_editor('content', '', false, false, $html_editor_config);
 		}
 	}
 
-	if (!$group_document && !is_my_shared_folder(api_get_user_id(), $my_cur_dir_path, $current_session_id)) {
+	if (!$group_document && !is_my_shared_folder(api_get_user_id(), $currentDirPath, $current_session_id)) {
 		$metadata_link = '<a href="../metadata/index.php?eid='.urlencode('Document.'.$document_data['id']).'">'.get_lang('AddMetadata').'</a>';
 
 		//Updated on field
 		$last_edit_date = api_get_local_time($last_edit_date);
-        $display_date = date_to_str_ago($last_edit_date).' <span class="dropbox_date">'.api_format_date($last_edit_date).'</span>';        
+        $display_date = date_to_str_ago($last_edit_date).' <span class="dropbox_date">'.api_format_date($last_edit_date).'</span>';
 		$form->addElement('static', null, get_lang('Metadata'), $metadata_link);
 		$form->addElement('static', null, get_lang('UpdatedOn'), $display_date);
 	}
 
 	$form->addElement('textarea', 'comment', get_lang('Comment'), 'rows="3" style="width:300px;"');
-	
-	if ($owner_id == api_get_user_id() || api_is_platform_admin()) {		
+
+	if ($owner_id == api_get_user_id() || api_is_platform_admin()) {
 		$checked =& $form->addElement('checkbox', 'readonly', null, get_lang('ReadOnly'));
 		if ($readonly == 1) {
 			$checked->setChecked(true);
 		}
 	}
-	
-	if ($is_certificate_mode)
+
+	if ($is_certificate_mode) {
 		$form->addElement('style_submit_button', 'submit', get_lang('SaveCertificate'), 'class="save"');
-	else
+    } 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']);
+	$defaults['file_path'] = isset($_GET['file']) ? Security::remove_XSS($_GET['file']) : null;
 	$defaults['commentPath'] = $file;
 	$defaults['renameTo'] = $file_name;
 	$defaults['comment'] = $document_data['comment'];
-	$defaults['origin'] = Security::remove_XSS($_GET['origin']);
-	$defaults['origin_opt'] = Security::remove_XSS($_GET['origin_opt']);
+	$defaults['origin'] = isset($_GET['origin']) ? Security::remove_XSS($_GET['origin']) : null;
+	$defaults['origin_opt'] = isset($_GET['origin_opt']) ? Security::remove_XSS($_GET['origin_opt']) : null;
 
 	$form->setDefaults($defaults);
-	
+
 	show_return($parent_id, $dir_original, $call_from_tool, $slide_id, $is_certificate_mode);
-	
+
 	if ($is_certificate_mode) {
 		$all_information_by_create_certificate=DocumentManager::get_all_info_to_certificate(api_get_user_id(), api_get_course_id());
 		$str_info='';
@@ -456,7 +453,7 @@ if ($owner_id == api_get_user_id() || api_is_platform_admin() || $is_allowed_to_
 		$create_certificate=get_lang('CreateCertificateWithTags');
 		Display::display_normal_message($create_certificate.': <br /><br />'.$str_info,false);
 	}
-	
+
 	if ($extension=='svg' && !api_browser_support('svg') && api_get_setting('enabled_support_svg') == 'true'){
 		Display::display_warning_message(get_lang('BrowserDontSupportsSVG'));
 	}
@@ -489,8 +486,8 @@ Display::display_footer();
 	It returns nothing.
     @todo check if this function is used
 */
-function change_name($base_work_dir, $source_file, $rename_to, $dir, $doc) {    
-    
+function change_name($base_work_dir, $source_file, $rename_to, $dir, $doc) {
+
 	$file_name_for_change = $base_work_dir.$dir.$source_file;
 	//api_display_debug_info("call my_rename: params $file_name_for_change, $rename_to");
     $rename_to = disable_dangerous_file($rename_to); // Avoid renaming to .htaccess file
@@ -524,22 +521,22 @@ function change_name($base_work_dir, $source_file, $rename_to, $dir, $doc) {
 
 //return button back to
 function show_return($document_id, $path, $call_from_tool='', $slide_id=0, $is_certificate_mode=false) {
-    global $parent_id;	
+    global $parent_id;
 	$pathurl = urlencode($path);
 	echo '<div class="actions">';
-	
+
 	if ($is_certificate_mode) {
 		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'),'',ICON_SIZE_MEDIUM).'</a>';
 	} elseif($call_from_tool=='slideshow') {
-		echo '<a href="'.api_get_path(WEB_PATH).'main/document/slideshow.php?slide_id='.$slide_id.'&curdirpath='.Security::remove_XSS(urlencode($_GET['curdirpath'])).'">'.Display::return_icon('slideshow.png', get_lang('BackTo').' '.get_lang('ViewSlideshow'),'',ICON_SIZE_MEDIUM).'</a>';		
+		echo '<a href="'.api_get_path(WEB_PATH).'main/document/slideshow.php?slide_id='.$slide_id.'&curdirpath='.Security::remove_XSS(urlencode($_GET['curdirpath'])).'">'.Display::return_icon('slideshow.png', get_lang('BackTo').' '.get_lang('ViewSlideshow'),'',ICON_SIZE_MEDIUM).'</a>';
 	} elseif($call_from_tool=='editdraw') {
 		echo '<a href="document.php?action=exit_slideshow&id='.$parent_id.'">'.Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('DocumentsOverview'),'',ICON_SIZE_MEDIUM).'</a>';
 		echo '<a href="javascript:history.back(1)">'.Display::return_icon('draw.png', get_lang('BackTo').' '.get_lang('Draw'), array(), 32).'</a>';
 	} elseif($call_from_tool=='editpaint'){
 		echo '<a href="document.php?action=exit_slideshow&id='.$parent_id.'">'.Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('DocumentsOverview'), array(), ICON_SIZE_MEDIUM).'</a>';
-		echo '<a href="javascript:history.back(1)">'.Display::return_icon('paint.png', get_lang('BackTo').' '.get_lang('Paint'), array(), 32).'</a>';		
+		echo '<a href="javascript:history.back(1)">'.Display::return_icon('paint.png', get_lang('BackTo').' '.get_lang('Paint'), array(), 32).'</a>';
 	} else {
 		echo '<a href="document.php?action=exit_slideshow&id='.$parent_id.'">'.Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('DocumentsOverview'),'',ICON_SIZE_MEDIUM).'</a>';
 	}
 	echo '</div>';
-}
+}

+ 13 - 23
main/document/record_audio_wami.php

@@ -34,7 +34,7 @@ api_block_anonymous_users();
 $document_data = DocumentManager::get_document_data_by_id($_GET['id'], api_get_course_id(), true);
 if (empty($document_data)) {
     if (api_is_in_group()) {
-        $group_properties   = GroupManager::get_group_properties(api_get_group_id());        
+        $group_properties   = GroupManager::get_group_properties(api_get_group_id());
         $document_id        = DocumentManager::get_document_id(api_get_course_info(), $group_properties['directory']);
         $document_data      = DocumentManager::get_document_data_by_id($document_id, api_get_course_id());
     }
@@ -48,8 +48,8 @@ $wamidir=$dir;
 if($wamidir=="/"){
  $wamidir="";
 }
-$wamiurlplay=api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document'.$wamidir."/";
-
+$wamiurlplay = api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document'.$wamidir."/";
+$groupId = api_get_group_id();
 
 $is_allowed_to_edit = api_is_allowed_to_edit(null, true);
 
@@ -79,9 +79,8 @@ if (!is_dir($filepath)) {
 }
 
 //groups //TODO: clean
-if (isset ($_SESSION['_gid']) && $_SESSION['_gid'] != 0) {
-	$req_gid = '&amp;gidReq='.$_SESSION['_gid'];
-	$interbreadcrumb[] = array ("url" => "../group/group_space.php?gidReq=".$_SESSION['_gid'], "name" => get_lang('GroupSpace'));
+if (!empty($groupId)) {
+	$interbreadcrumb[] = array ("url" => "../group/group_space.php?".api_get_cidreq(), "name" => get_lang('GroupSpace'));
 	$noPHP_SELF = true;
 	$to_group_id = $_SESSION['_gid'];
 	$group = GroupManager :: get_group_properties($to_group_id);
@@ -91,7 +90,7 @@ if (isset ($_SESSION['_gid']) && $_SESSION['_gid'] != 0) {
 	}
 }
 
-$interbreadcrumb[] = array ("url" => "./document.php?id=".$document_id.$req_gid, "name" => get_lang('Documents'));
+$interbreadcrumb[] = array("url" => "./document.php?id=".$document_id.'&'.api_get_cidreq(), "name" => get_lang('Documents'));
 
 if (!$is_allowed_in_course) {
 	api_not_allowed(true);
@@ -101,7 +100,6 @@ if (!($is_allowed_to_edit || $_SESSION['group_member_with_upload_rights'] || is_
 	api_not_allowed(true);
 }
 
-
 /*	Header */
 event_access_tool(TOOL_DOCUMENT);
 
@@ -114,14 +112,14 @@ if (isset ($group)) {
 }
 
 // Interbreadcrumb for the current directory root path
-$counter = 0;   
+$counter = 0;
 if (isset($document_data['parents'])) {
     foreach($document_data['parents'] as $document_sub_data) {
         //fixing double group folder in breadcrumb
         if (api_get_group_id()) {
             if ($counter == 0) {
                 $counter++;
-                continue;  
+                continue;
             }
         }
         $interbreadcrumb[] = array('url' => $document_sub_data['document_url'], 'name' => $document_sub_data['title']);
@@ -129,16 +127,13 @@ if (isset($document_data['parents'])) {
     }
 }
 
-
 //make some vars
-$wamiuserid=api_get_user_id();
+$wamiuserid = api_get_user_id();
 
 Display :: display_header($nameTools, 'Doc');
 echo '<div class="actions">';
 		echo '<a href="document.php?id='.$document_id.'">'.Display::return_icon('back.png',get_lang('BackTo').' '.get_lang('DocumentsOverview'),'',ICON_SIZE_MEDIUM).'</a>';
 echo '</div>';
-
-
 ?>
 <!-- swfobject is a commonly used library to embed Flash content https://ajax.googleapis.com/ajax/libs/swfobject/2.2/ -->
 <script type="text/javascript" src="<?php echo api_get_path(WEB_LIBRARY_PATH) ?>swfobject/swfobject.js"></script>
@@ -148,9 +143,7 @@ echo '</div>';
 
 <!-- GUI code... take it or leave it -->
 <script type="text/javascript" src="<?php echo api_get_path(WEB_LIBRARY_PATH) ?>wami-recorder/gui.js"></script>
-
 <script type="text/javascript">
-
 	function newNameRecord() {
 		location.reload(true)
 	}
@@ -164,7 +157,7 @@ echo '</div>';
 			document.getElementById('audio_title').readOnly = true;
 			//document.getElementById('audio_title').style.display='none';
 			document.getElementById('audio_button').style.display='none';
-			
+
 			Wami.setup({
 				id : "wami",
 				onReady : setupGUI
@@ -175,7 +168,7 @@ echo '</div>';
 	function setupGUI() {
 		var waminame = document.getElementById("audio_title").value+".wav";//adding name file and extension
 	    var waminame_play=waminame;
-			
+
 		var gui = new Wami.GUI({
 			id : "wami",
 			singleButton : true,
@@ -184,15 +177,12 @@ echo '</div>';
 			buttonUrl : "<?php echo api_get_path(WEB_LIBRARY_PATH) ?>wami-recorder/buttons.png",
 			swfUrl : 	"<?php echo api_get_path(WEB_LIBRARY_PATH) ?>wami-recorder/Wami.swf"
 		});
-	
+
 		gui.setPlayEnabled(false);
 	}
-
 </script>
 
-
 <div id="wami" style="margin-top:10px;"></div>
-
 <div align="center" style="margin-top:150px;">
 <form name="form_wami_recorder">
 <input placeholder="<?php echo get_lang('InputNameHere'); ?>" type="text" id="audio_title"><br/>
@@ -215,4 +205,4 @@ if (navigator.appName == 'Microsoft Internet Explorer') {
 
 <?php
 
-Display :: display_footer();
+Display :: display_footer();

+ 49 - 49
main/document/showinframes.php

@@ -114,7 +114,7 @@ if (isset($group_id) && $group_id != '') {
     $name_to_show = implode('/', $name_to_show);
 }
 
-$interbreadcrumb[] = array('url' => './document.php?curdirpath='.dirname($header_file).$req_gid, 'name' => get_lang('Documents'));
+$interbreadcrumb[] = array('url' => './document.php?curdirpath='.dirname($header_file).'&'.api_get_cidreq(), 'name' => get_lang('Documents'));
 
 if (empty($document_data['parents'])) {
 	if (isset($_GET['createdir'])) {
@@ -158,7 +158,7 @@ if (api_get_setting('show_glossary_in_documents') == 'ismanual') {
                                       { load: [
                                                 {type:"script", id:"_fr1", src:"'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.min.js"},
                                                 {type:"script", id:"_fr4", src:"'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery-ui/smoothness/jquery-ui-1.8.21.custom.min.js"},
-                                                {type:"stylesheet", id:"_fr5", src:"'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery-ui/smoothness/jquery-ui-1.8.21.custom.css"}, 
+                                                {type:"stylesheet", id:"_fr5", src:"'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery-ui/smoothness/jquery-ui-1.8.21.custom.css"},
                                                 {type:"script", id:"_fr2", src:"'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.highlight.js"},
                                                 {type:"script", id:"_fr3", src:"'.api_get_path(WEB_LIBRARY_PATH).'fckeditor/editor/plugins/glossary/fck_glossary_manual.js"}
                                            ]
@@ -174,7 +174,7 @@ if (api_get_setting('show_glossary_in_documents') == 'ismanual') {
                                       { load: [
                                                 {type:"script", id:"_fr1", src:"'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.min.js"},
                                                 {type:"script", id:"_fr4", src:"'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery-ui/smoothness/jquery-ui-1.8.21.custom.min.js"},
-                                                {type:"stylesheet", id:"_fr5", src:"'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery-ui/smoothness/jquery-ui-1.8.21.custom.css"},                                                    
+                                                {type:"stylesheet", id:"_fr5", src:"'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery-ui/smoothness/jquery-ui-1.8.21.custom.css"},
                                                 {type:"script", id:"_fr2", src:"'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.highlight.js"},
                                                 {type:"script", id:"_fr3", src:"'.api_get_path(WEB_LIBRARY_PATH).'fckeditor/editor/plugins/glossary/fck_glossary_automatic.js"}
                                            ]
@@ -186,58 +186,58 @@ if (api_get_setting('show_glossary_in_documents') == 'ismanual') {
 
 $web_odf_supported_files = DocumentManager::get_web_odf_extension_list();
 if (in_array(strtolower($pathinfo['extension']), $web_odf_supported_files)) {
-    $show_web_odf  = true;    
+    $show_web_odf  = true;
     $htmlHeadXtra[] = api_get_js('webodf/webodf.js');
     $htmlHeadXtra[] = api_get_css(api_get_path(WEB_LIBRARY_PATH).'javascript/webodf/webodf.css');
     $htmlHeadXtra[] = '
-    <script charset="utf-8">        
+    <script charset="utf-8">
         function init() {
                 var odfelement = document.getElementById("odf"),
                 odfcanvas = new odf.OdfCanvas(odfelement);
                 odfcanvas.load("'.$file_url_web.'");
         }
-        $(document).ready(function() {        
+        $(document).ready(function() {
             window.setTimeout(init, 0);
-        });        
+        });
   </script>';
 }
 
 $execute_iframe = true;
 
 if ($jplayer_supported) {
-    
+
     $extension = api_strtolower($pathinfo['extension']);
-    
+
     $js_path 		= api_get_path(WEB_LIBRARY_PATH).'javascript/';
     $htmlHeadXtra[] = '<link rel="stylesheet" href="'.$js_path.'jquery-jplayer/skins/blue/jplayer.blue.monday.css" type="text/css">';
     $htmlHeadXtra[] = '<script type="text/javascript" src="'.$js_path.'jquery-jplayer/jquery.jplayer.min.js"></script>';
 
-    $jquery = ' $("#jquery_jplayer_1").jPlayer({                                
-                    ready: function() {                    
-                        $(this).jPlayer("setMedia", {                                        
-                            '.$extension.' : "'.$document_data['direct_url'].'"                                                                                  
+    $jquery = ' $("#jquery_jplayer_1").jPlayer({
+                    ready: function() {
+                        $(this).jPlayer("setMedia", {
+                            '.$extension.' : "'.$document_data['direct_url'].'"
                         });
-                    },                    
+                    },
                     errorAlerts: false,
                     warningAlerts: false,
                     //swfPath: "../inc/lib/javascript/jquery-jplayer",
                      swfPath: "'.$js_path.'jquery-jplayer",
                     //supplied: "m4a, oga, mp3, ogg, wav",
-                    supplied: "'.$extension.'",                        
+                    supplied: "'.$extension.'",
                     //wmode: "window",
-                    solution: "flash, html",  // Do not change this setting 
-                    cssSelectorAncestor: "#jp_container_1", 
+                    solution: "flash, html",  // Do not change this setting
+                    cssSelectorAncestor: "#jp_container_1",
                 });';
-    
+
     $htmlHeadXtra[] = '<script>
-        $(document).ready( function() {            
-            //Experimental changes to preview mp3, ogg files        
-            '.$jquery.'            
+        $(document).ready( function() {
+            //Experimental changes to preview mp3, ogg files
+            '.$jquery.'
         });
     </script>';
     $execute_iframe = false;
 }
-if ($show_web_odf) {      
+if ($show_web_odf) {
     $execute_iframe = false;
 }
 
@@ -252,7 +252,7 @@ if ($is_nanogong_available){
 }
 
 if (!$jplayer_supported && $execute_iframe) {
-    
+
     $htmlHeadXtra[] = '<script type="text/javascript">
     <!--
         var jQueryFrameReadyConfigPath = \''.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.min.js\';
@@ -261,7 +261,7 @@ if (!$jplayer_supported && $execute_iframe) {
     $htmlHeadXtra[] = '<script type="text/javascript" src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.frameready.js"></script>';
     $htmlHeadXtra[] = '<script>
     <!--
-        var updateContentHeight = function() {            
+        var updateContentHeight = function() {
             my_iframe = document.getElementById("mainFrame");
             //this doesnt seem to work in IE 7,8,9
             new_height = my_iframe.contentWindow.document.body.scrollHeight;
@@ -285,43 +285,43 @@ $file_url_web = api_get_path(WEB_COURSE_PATH).$_course['path'].'/document'.$head
 
 if (!$is_nanogong_available) {
     if (in_array(strtolower($pathinfo['extension']) , array('html', "htm"))) {
-        echo '<a class="btn" href="'.$file_url_web.'" target="_blank">'.get_lang('CutPasteLink').'</a>';    
-    } else {    
-        echo '<a class="btn" href="'.$file_url_web.'" target="_blank">'.get_lang('Download').'</a>';     
+        echo '<a class="btn" href="'.$file_url_web.'" target="_blank">'.get_lang('CutPasteLink').'</a>';
+    } else {
+        echo '<a class="btn" href="'.$file_url_web.'" target="_blank">'.get_lang('Download').'</a>';
     }
 }
 
-if ($show_web_odf) {        
+if ($show_web_odf) {
     //echo Display::url(get_lang('Show'), api_get_path(WEB_CODE_PATH).'document/edit_odf.php?id='.$document_data['id'], array('class' => 'btn'));
-    echo '<div id="odf"></div>';    
+    echo '<div id="odf"></div>';
 }
 
 echo '</div>';
-    
-if ($jplayer_supported) { 
+
+if ($jplayer_supported) {
     echo '<br /><div class="span12" style="margin:0 auto; width:100%; text-align:center;">';
     echo DocumentManager::generate_video_preview($document_data);
-    echo '</div>';     
+    echo '</div>';
 }
 
-if ($is_freemind_available) { 
-	?>	
+if ($is_freemind_available) {
+	?>
 	<script type="text/javascript" src="<?php echo api_get_path(WEB_LIBRARY_PATH) ?>swfobject/swfobject.js"></script>
 	<style type="text/css">
 		#flashcontent {
 			height: 500px;
 			padding-top:10px;
 		}
-	</style>		
+	</style>
 	<div id="flashcontent" onmouseover="giveFocus();">
 		 Flash plugin or Javascript are turned off.
 		 Activate both  and reload to view the mindmap
-	</div>		
+	</div>
 	<script>
-        function giveFocus() { 
-		  document.visorFreeMind.focus();  
+        function giveFocus() {
+		  document.visorFreeMind.focus();
 		}
-        
+
 		document.onload=giveFocus;
 		// <![CDATA[
 		// for allowing using http://.....?mindmap.mm mode
@@ -353,7 +353,7 @@ if ($is_freemind_available) {
 		//
 		//extra
 		//fo.addVariable("CSSFile","<?php // echo api_get_path(WEB_LIBRARY_PATH); ?>freeMindFlashBrowser/flashfreemind.css");//
-		//fo.addVariable("baseImagePath","<?php // echo api_get_path(WEB_LIBRARY_PATH); ?>freeMindFlashBrowser/");//		
+		//fo.addVariable("baseImagePath","<?php // echo api_get_path(WEB_LIBRARY_PATH); ?>freeMindFlashBrowser/");//
 		//fo.addVariable("justMap","false");//Hides all the upper control options. Default value "false"
 		//fo.addVariable("noElipseMode","anyvalue");//for changing to old elipseNode edges. Default = not set
 		//fo.addVariable("ShotsWidth","200");//The width of snapshots, in pixels.
@@ -362,10 +362,10 @@ if ($is_freemind_available) {
 		//fo.addVariable("toolTipsBgColor","0xaaeeaa");: bgcolor for tooltips ej;"0xaaeeaa"
 		//fo.addVariable("defaultWordWrap","300"); //default 600
 		//
-		
+
 		fo.write("flashcontent");
 		// ]]>
-	</script>	
+	</script>
 	<?php
 }
 
@@ -390,32 +390,32 @@ if ($is_nanogong_available) {
 		}
 
 		//encript temp name file
-		$name_crip = sha1(uniqid());//encript 
+		$name_crip = sha1(uniqid());//encript
 		$findext= explode(".", $file);
 		$extension= $findext[count($findext)-1];
 		$file_crip=$name_crip.'.'.$extension;
-		
+
 		//copy file to temp/audio directory
 		$from_sys=$file_url_sys;
 		$to_sys=api_get_path(SYS_ARCHIVE_PATH).'temp/audio/'.$file_crip;
-        
+
         if (file_exists($from_sys)) {
             copy($from_sys, $to_sys);
         }
 
 		//get file from tmp directory
 		$to_url = api_get_path(WEB_ARCHIVE_PATH).'temp/audio/'.$file_crip;
-        
+
         echo '<div align="center">';
         echo '<a class="btn" href="'.$file_url_web.'" target="_blank">'.get_lang('Download').'</a>';
         echo '<br/>';
         echo '<br/>';
 
         echo DocumentManager::readNanogongFile($to_url);
-		
+
 		//erase temp file in tmp directory when return to documents
-		$_SESSION['temp_audio_nanogong']=$to_sys;      
-    echo '</div>';    
+		$_SESSION['temp_audio_nanogong']=$to_sys;
+    echo '</div>';
 }
 
 if ($execute_iframe) {

+ 11 - 6
main/dropbox/dropbox_download.php

@@ -26,10 +26,13 @@ require_once api_get_path(LIBRARY_PATH).'document.lib.php';
 
 /*	DOWNLOAD A FOLDER */
 $course_id = api_get_course_int_id();
-
 $user_id = api_get_user_id();
 
-if (isset($_GET['cat_id']) AND is_numeric($_GET['cat_id']) AND $_GET['action'] == 'downloadcategory' AND isset($_GET['sent_received'])) {
+if (isset($_GET['cat_id']) AND
+    is_numeric($_GET['cat_id']) AND
+    $_GET['action'] == 'downloadcategory' AND
+    isset($_GET['sent_received'])
+) {
     /** step 1: constructing the sql statement.
     Due to the nature off the classes of the dropbox the categories for sent files are stored in the table
     dropbox_file while the categories for the received files are stored in dropbox_post.
@@ -40,7 +43,8 @@ if (isset($_GET['cat_id']) AND is_numeric($_GET['cat_id']) AND $_GET['action'] =
     if ($_GET['sent_received'] == 'sent') {
         // here we also incorporate the person table to make sure that deleted sent documents are not included.
         $sql = "SELECT DISTINCT file.id, file.filename, file.title
-                FROM ".$dropbox_cnf['tbl_file']." file INNER JOIN ".$dropbox_cnf['tbl_person']." person
+                FROM ".$dropbox_cnf['tbl_file']." file
+                INNER JOIN ".$dropbox_cnf['tbl_person']." person
                 ON (person.file_id=file.id AND file.c_id = $course_id AND person.c_id = $course_id)
                 WHERE
                     file.uploader_id = $user_id AND
@@ -50,7 +54,8 @@ if (isset($_GET['cat_id']) AND is_numeric($_GET['cat_id']) AND $_GET['action'] =
 
     if ($_GET['sent_received'] == 'received') {
         $sql = "SELECT DISTINCT file.id, file.filename, file.title
-                FROM ".$dropbox_cnf['tbl_file']." file INNER JOIN ".$dropbox_cnf['tbl_person']." person
+                FROM ".$dropbox_cnf['tbl_file']." file
+                INNER JOIN ".$dropbox_cnf['tbl_person']." person
                 ON (person.file_id=file.id AND file.c_id = $course_id AND person.c_id = $course_id)
                 INNER JOIN ".$dropbox_cnf['tbl_post']." post
                 ON (post.file_id = file.id AND post.c_id = $course_id AND file.c_id = $course_id)
@@ -58,7 +63,7 @@ if (isset($_GET['cat_id']) AND is_numeric($_GET['cat_id']) AND $_GET['action'] =
                     post.cat_id = ".intval($_GET['cat_id'])." AND
                     post.dest_user_id = $user_id" ;
     }
-
+    $files_to_download = array();
     $result = Database::query($sql);
     while ($row = Database::fetch_array($result)) {
         $files_to_download[] = $row['id'];
@@ -152,4 +157,4 @@ if (!$allowed_to_download) {
     exit();
 }
 //@todo clean this file the code below is useless there are 2 exits in previous conditions ... maybe a bad copy/paste/merge?
-exit;
+exit;

+ 36 - 18
main/dropbox/dropbox_functions.inc.php

@@ -1034,8 +1034,8 @@ function store_feedback()
 }
 
 /**
-* This function downloads all the files of the inputarray into one zip
-* @param $array an array containing all the ids of the files that have to be downloaded.
+* This function downloads all the files of the input array into one zip
+* @param array $fileList containing all the ids of the files that have to be downloaded.
 * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
 * @todo consider removing the check if the user has received or sent this file (zip download of a folder already sufficiently checks for this).
 * @todo integrate some cleanup function that removes zip files that are older than 2 days
@@ -1044,34 +1044,52 @@ function store_feedback()
 * @author Julio Montoya  Addin c_id support
 * @version march 2006
 */
-function zip_download($array) {
+function zip_download($fileList)
+{
 	$_course = api_get_course_info();
     $dropbox_cnf = getDropboxConf();
-
     $course_id = api_get_course_int_id();
-	$array = array_map('intval', $array);
+    $fileList = array_map('intval', $fileList);
 
 	// note: we also have to add the check if the user has received or sent this file.
 	$sql = "SELECT DISTINCT file.filename, file.title, file.author, file.description
-			FROM ".$dropbox_cnf['tbl_file']." file INNER JOIN ".$dropbox_cnf['tbl_person']." person
+			FROM ".$dropbox_cnf['tbl_file']." file
+			INNER JOIN ".$dropbox_cnf['tbl_person']." person
             ON (person.file_id=file.id AND file.c_id = $course_id AND person.c_id = $course_id)
             INNER JOIN ".$dropbox_cnf['tbl_post']." post
             ON (post.file_id = file.id AND post.c_id = $course_id AND file.c_id = $course_id)
-			WHERE   file.id IN (".implode(', ',$array).") AND
-                    file.id = person.file_id AND
-                    (person.user_id = '".api_get_user_id()."' OR post.dest_user_id = '".api_get_user_id()."' ) ";
+			WHERE
+			    file.id IN (".implode(', ', $fileList).") AND
+                file.id = person.file_id AND
+                (
+                    person.user_id = '".api_get_user_id()."' OR
+                    post.dest_user_id = '".api_get_user_id()."'
+                ) ";
 	$result = Database::query($sql);
+
 	$files = array();
 	while ($row = Database::fetch_array($result)) {
-		$files[$row['filename']] = array('filename' => $row['filename'],'title' => $row['title'], 'author' => $row['author'], 'description' => $row['description']);
+		$files[$row['filename']] = array(
+            'filename' => $row['filename'],
+            'title' => $row['title'],
+            'author' => $row['author'],
+            'description' => $row['description']
+        );
 	}
 
 	// Step 3: create the zip file and add all the files to it
 	$temp_zip_file = api_get_path(SYS_ARCHIVE_PATH).api_get_unique_id().".zip";
-	$zip_folder = new PclZip($temp_zip_file);
+    Session::write('dropbox_files_to_download', $files);
+	$zip = new PclZip($temp_zip_file);
 	foreach ($files as $value) {
-		$zip_folder->add(api_get_path(SYS_COURSE_PATH).$_course['path'].'/dropbox/'.$value['filename'], PCLZIP_OPT_REMOVE_ALL_PATH, PCLZIP_CB_PRE_ADD, 'my_pre_add_callback');
+        $zip->add(
+            api_get_path(SYS_COURSE_PATH).$_course['path'].'/dropbox/'.$value['filename'],
+            PCLZIP_OPT_REMOVE_ALL_PATH,
+            PCLZIP_CB_PRE_ADD,
+            'my_pre_add_callback'
+        );
 	}
+    Session::erase('dropbox_files_to_download');
 	$name = 'dropbox-'.api_get_utc_datetime().'.zip';
 	DocumentManager::file_send_for_download($temp_zip_file, true, $name);
 	@unlink($temp_zip_file);
@@ -1080,19 +1098,19 @@ function zip_download($array) {
 
 /**
 * This is a callback function to decrypt the files in the zip file to their normal filename (as stored in the database)
-* @param $p_event a variable of PCLZip
-* @param $p_header a variable of PCLZip
+* @param array $p_event a variable of PCLZip
+* @param array $p_header a variable of PCLZip
 *
 * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
 * @version march 2006
 */
-function my_pre_add_callback($p_event, &$p_header) {
-	global $files;
+function my_pre_add_callback($p_event, &$p_header)
+{
+    $files = Session::read('dropbox_files_to_download');
 	$p_header['stored_filename'] = $files[$p_header['stored_filename']]['title'];
 	return 1;
 }
 
-
 /**
  * @desc Generates the contents of a html file that gives an overview of all the files in the zip file.
  *		This is to know the information of the files that are inside the zip file (who send it, the comment, ...)
@@ -1222,4 +1240,4 @@ function get_last_tool_access($tool, $course_code = '', $user_id='')
 	$result = Database::query($sql);
 	$row = Database::fetch_array($result);
 	return $row['access_date'];
-}
+}

+ 29 - 25
main/exercice/admin.php

@@ -87,36 +87,40 @@ if($_SERVER['REQUEST_METHOD'] == 'POST') {
 	}
 }
 
-// get vars from GET
-if ( empty ( $exerciseId ) ) {
-    $exerciseId = intval($_GET['exerciseId']);
+if (empty($exerciseId)) {
+    $exerciseId = isset($_GET['exerciseId']) ? intval($_GET['exerciseId']):'0';
 }
-if ( empty ( $newQuestion ) ) {
-    $newQuestion = $_GET['newQuestion'];
-}
-if ( empty ( $modifyAnswers ) ) {
-    $modifyAnswers = $_GET['modifyAnswers'];
+
+if (empty($newQuestion)) {
+    $newQuestion = isset($_GET['newQuestion']) ? $_GET['newQuestion'] : 0;
 }
-if ( empty ( $editQuestion ) ) {
-    $editQuestion = $_GET['editQuestion'];
+if (empty($modifyAnswers)) {
+    $modifyAnswers = isset($_GET['modifyAnswers']) ? $_GET['modifyAnswers'] : 0;
 }
-if ( empty ( $modifyQuestion ) ) {
-    $modifyQuestion = $_GET['modifyQuestion'];
+if (empty($editQuestion)) {
+    $editQuestion = isset($_GET['editQuestion']) ? $_GET['editQuestion'] : 0;
 }
-if ( empty ( $deleteQuestion ) ) {
-    $deleteQuestion = $_GET['deleteQuestion'];
+if (empty($modifyQuestion)) {
+    $modifyQuestion = isset($_GET['modifyQuestion']) ? $_GET['modifyQuestion'] : 0;
 }
-if ( empty ($clone_question) ) {
-	$clone_question = $_GET['clone_question'];
+if (empty($deleteQuestion)) {
+    $deleteQuestion = isset($_GET['deleteQuestion']) ? $_GET['deleteQuestion'] : 0;
 }
-if ( empty ( $questionId ) ) {
-    $questionId = $_SESSION['questionId'];
+$clone_question = isset($_REQUEST['clone_question']) ? $_REQUEST['clone_question'] : 0;
+if (empty($questionId)) {
+    $questionId = isset($_SESSION['questionId']) ? $_SESSION['questionId'] : 0;
 }
-if ( empty ( $modifyExercise ) ) {
-    $modifyExercise = $_GET['modifyExercise'];
+if (empty($modifyExercise)) {
+    $modifyExercise = isset($_GET['modifyExercise']) ? $_GET['modifyExercise'] : null;
 }
 
-//Cleaning all incomplete attempts of the admin/teacher to avoid weird problems when changing the exercise settings, number of questions, etc
+$fromExercise = isset($fromExercise) ? $fromExercise : null;
+$cancelExercise = isset($cancelExercise) ? $cancelExercise : null;
+$cancelAnswers = isset($cancelAnswers) ? $cancelAnswers : null;
+$modifyIn = isset($modifyIn) ? $modifyIn : null;
+$cancelQuestion = isset($cancelQuestion) ? $cancelQuestion : null;
+
+// Cleaning all incomplete attempts of the admin/teacher to avoid weird problems when changing the exercise settings, number of questions, etc
 
 delete_all_incomplete_attempts(api_get_user_id(), $exerciseId, api_get_course_id(), api_get_session_id());
 
@@ -139,7 +143,7 @@ $aType = array(get_lang('UniqueSelect'),get_lang('MultipleSelect'),get_lang('Fil
 
 // tables used in the exercise tool
 
-if ($_GET['action'] == 'exportqti2' && !empty($_GET['questionId'])) {
+if (!empty($_GET['action']) && $_GET['action'] == 'exportqti2' && !empty($_GET['questionId'])) {
 	require_once 'export/qti2/qti2_export.php';
 	$export = export_question($_GET['questionId'],true);
 	$qid = (int)$_GET['questionId'];
@@ -176,9 +180,9 @@ if (!is_object($objExercise)) {
 }
 
 // doesn't select the exercise ID if we come from the question pool
-if(!$fromExercise) {
+if (!$fromExercise) {
 	// gets the right exercise ID, and if 0 creates a new exercise
-	if(!$exerciseId = $objExercise->selectId()) {
+	if (!$exerciseId = $objExercise->selectId()) {
 		$modifyExercise='yes';
 	}
 }
@@ -234,7 +238,7 @@ if ($cancelQuestion) {
 	}
 }
 
-if (isset($clone_question) && !empty($objExercise->id)) {
+if (!empty($clone_question) && !empty($objExercise->id)) {
 	$old_question_obj = Question::read($clone_question);
 	$old_question_obj->question = $old_question_obj->question.' - '.get_lang('Copy');
 

+ 2 - 2
main/exercice/aiken.php

@@ -10,7 +10,7 @@
  * Code
  */
 // name of the language file that needs to be included
-$language_file = 'exercice';
+$language_file = array('exercice', 'gradebook');
 
 // including the global Chamilo file
 require_once '../inc/global.inc.php';
@@ -55,4 +55,4 @@ if ((api_is_allowed_to_edit(null, true))) {
 aiken_display_form($msg);
 
 // display the footer
-Display::display_footer();
+Display::display_footer();

+ 44 - 39
main/exercice/answer.class.php

@@ -99,35 +99,39 @@ class Answer
     }
 
     /**
-     * Reads answer informations from the data base
+     * Reads answer information from the database
      *
      * @author - Olivier Brouckaert
      */
-    function read() {
+    public function read()
+    {
         $TBL_ANSWER = Database::get_course_table(TABLE_QUIZ_ANSWER);
         $questionId = $this->questionId;
 
-        $sql="SELECT id, id_auto, answer,correct,comment,ponderation, position, hotspot_coordinates, hotspot_type, destination  FROM
-              $TBL_ANSWER WHERE c_id = {$this->course_id} AND question_id ='".$questionId."' ORDER BY position";
+        $sql = "SELECT * FROM $TBL_ANSWER
+                WHERE
+                    c_id = {$this->course_id} AND
+                    question_id ='".$questionId."'
+                ORDER BY position";
 
         $result = Database::query($sql);
         $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;
+		$this->nbrAnswers = $i-1;
 	}
 
      /**
@@ -136,27 +140,27 @@ class Answer
      * @author - Yoselyn Castillo
      * @return - array - $id (answer ids)
      */
-    function selectAnswerId()
+    public function selectAnswerId()
     {
-		    $TBL_ANSWER = Database::get_course_table(TABLE_QUIZ_ANSWER);
-		    $questionId = $this->questionId;
+        $TBL_ANSWER = Database::get_course_table(TABLE_QUIZ_ANSWER);
+        $questionId = $this->questionId;
 
-		    $sql="SELECT id FROM
-		          $TBL_ANSWER WHERE c_id = {$this->course_id} AND question_id ='".$questionId."'";
+        $sql="SELECT id FROM
+              $TBL_ANSWER WHERE c_id = {$this->course_id} AND question_id ='".$questionId."'";
 
-		    $result = Database::query($sql);
-		    $id = array();
-		    // while a record is found
+        $result = Database::query($sql);
+        $id = array();
+        // while a record is found
         if (Database::num_rows($result) > 0) {
             while ($object = Database::fetch_array($result)) {
-    			      $id[] = $object['id'];
-    		    }
+                  $id[] = $object['id'];
+            }
         }
-		    return $id;
+        return $id;
 	}
 
     /**
-     * reads answer informations from the data base ordered by parameter
+     * Reads answer information from the data base ordered by parameter
      * @param	string	Field we want to order by
      * @param	string	DESC or ASC
      * @author 	Frederic Vauthier
@@ -185,10 +189,10 @@ class Answer
                "ORDER BY $field $order";
 		$result=Database::query($sql);
 
-		$i=1;
+		$i = 1;
 		// while a record is found
 		$doubt_data = null;
-		while($object=Database::fetch_object($result)) {
+		while($object = Database::fetch_object($result)) {
 		    if ($question_type['type'] == UNIQUE_ANSWER_NO_OPTION && $object->position == 666) {
 		        $doubt_data = $object;
                 continue;
@@ -224,7 +228,7 @@ class Answer
 	 */
 	function selectAutoId($id)
     {
-		return $this->autoId[$id];
+		return isset($this->autoId[$id]) ? $this->autoId[$id] : null;
 	}
 
 	/**
@@ -255,8 +259,9 @@ class Answer
 	 * @author - Julio Montoya
 	 * @return - integer - the question ID
 	 */
-	function selectDestination($id) {
-		return $this->destination[$id];
+	function selectDestination($id)
+    {
+		return isset($this->destination[$id]) ? $this->destination[$id] : null;
 	}
 
     /**
@@ -375,7 +380,7 @@ class Answer
 	 */
 	function isCorrect($id)
 	{
-		return $this->correct[$id];
+		return isset($this->correct[$id]) ? $this->correct[$id] : null;
 	}
 
 	/**
@@ -399,7 +404,7 @@ class Answer
 	 */
 	function selectWeighting($id)
 	{
-		return $this->weighting[$id];
+		return isset($this->weighting[$id]) ? $this->weighting[$id] : null;
 	}
 
 	/**
@@ -411,7 +416,7 @@ class Answer
 	 */
 	function selectPosition($id)
 	{
-		return $this->position[$id];
+		return isset($this->position[$id]) ? $this->position[$id] : null;
 	}
 
 	/**
@@ -423,7 +428,7 @@ class Answer
 	 */
 	function selectHotspotCoordinates($id)
 	{
-		return $this->hotspot_coordinates[$id];
+		return isset($this->hotspot_coordinates[$id]) ? $this->hotspot_coordinates[$id] : null;
 	}
 
 	/**
@@ -435,11 +440,11 @@ class Answer
 	 */
 	function selectHotspotType($id)
 	{
-		return $this->hotspot_type[$id];
+		return isset($this->hotspot_type[$id]) ? $this->hotspot_type[$id] : null;
 	}
 
 	/**
-	 * creates a new answer
+	 * Creates a new answer
 	 *
 	 * @author Olivier Brouckaert
 	 * @param string 	answer title

+ 54 - 6
main/exercice/exercice.php

@@ -202,6 +202,31 @@ HotPotGCt($documentPath, 1, api_get_user_id());
 if ($is_allowedToEdit) {
 
     if (!empty($choice)) {
+
+        // All test choice, clean all test's results
+        if ($choice == 'clean_all_test') {
+            $check = Security::check_token('get');
+            if ($check) {
+                // list des exercices dans un test
+                // we got variable $course_id $course_info session api_get_session_id()
+                $tab_exercise_list = get_all_exercises_for_course_id($course_info, api_get_session_id(), $course_id, false);
+
+                $quantity_results_deleted = 0;
+                foreach ($tab_exercise_list as $exeItem) {
+                    // delete result for test, if not in a gradebook
+                    $exercise_action_locked = api_resource_is_locked_by_gradebook($exeItem['id'], LINK_EXERCISE);
+                    if ($exercise_action_locked == false) {
+                        $objExerciseTmp = new Exercise();
+                        if ($objExerciseTmp->read($exeItem['id'])) {
+                            $quantity_results_deleted += $objExerciseTmp->clean_results(true);
+                        }
+                    }
+                }
+                Display :: display_confirmation_message(sprintf(get_lang('XResultsCleaned'), $quantity_results_deleted));
+            }
+        }
+
+        // single exercise choice
         // construction of Exercise
 
         $objExerciseTmp = new Exercise();
@@ -247,7 +272,7 @@ if ($is_allowedToEdit) {
                         break;
                     case 'clean_results' : //clean student results
                         if ($exercise_action_locked == false) {
-                            $quantity_results_deleted = $objExerciseTmp->clean_results();
+                            $quantity_results_deleted = $objExerciseTmp->clean_results(true);
                             Display :: display_confirmation_message(sprintf(get_lang('XResultsCleaned'), $quantity_results_deleted));
                         }
                         break;
@@ -265,23 +290,33 @@ if ($is_allowedToEdit) {
 
     if (!empty($hpchoice)) {
         switch ($hpchoice) {
-            case 'delete' : // deletes an exercise
+            case 'delete' :
+                // deletes an exercise
                 $imgparams = array();
                 $imgcount = 0;
                 GetImgParams($file, $documentPath, $imgparams, $imgcount);
                 $fld = GetFolderName($file);
+
                 for ($i = 0; $i < $imgcount; $i++) {
                     my_delete($documentPath.$uploadPath."/".$fld."/".$imgparams[$i]);
                     update_db_info("delete", $uploadPath."/".$fld."/".$imgparams[$i]);
                 }
 
-                if (my_delete($documentPath.$file)) {
+                if (!is_dir($documentPath.$uploadPath."/".$fld."/")) {
+                    my_delete($documentPath.$file);
                     update_db_info("delete", $file);
+                } else {
+                    if (my_delete($documentPath.$file)) {
+                        update_db_info("delete", $file);
+                    }
                 }
+
                 // hotpotatoes folder may contains several tests so don't delete folder if not empty : http://support.chamilo.org/issues/2165
+
                 if (!(strstr($uploadPath, DIR_HOTPOTATOES) && !folder_is_empty($documentPath.$uploadPath."/".$fld."/"))) {
                     my_delete($documentPath.$uploadPath."/".$fld."/");
-                } break;
+                }
+                break;
             case 'enable' : // enables an exercise
                 $newVisibilityStatus = "1"; //"visible"
                 $query = "SELECT id FROM $TBL_DOCUMENT WHERE c_id = $course_id AND path='".Database :: escape_string($file)."'";
@@ -365,6 +400,8 @@ if ($is_allowedToEdit) {
 }
 $total = $total_exercises + $hp_count;
 
+
+$token = Security::get_token();
 if ($is_allowedToEdit && $origin != 'learnpath') {
     echo '<a href="exercise_admin.php?'.api_get_cidreq().'">'.Display :: return_icon('new_exercice.png', get_lang('NewEx'), '', ICON_SIZE_MEDIUM).'</a>';
     echo '<a href="question_create.php?'.api_get_cidreq().'">'.Display :: return_icon('new_question.png', get_lang('AddQ'), '', ICON_SIZE_MEDIUM).'</a>';
@@ -383,6 +420,16 @@ if ($is_allowedToEdit && $origin != 'learnpath') {
     echo '<a href="qti2.php?'.api_get_cidreq().'">'.Display :: return_icon('import_qti2.png', get_lang('ImportQtiQuiz'), '', ICON_SIZE_MEDIUM).'</a>';
     echo '<a href="aiken.php?'.api_get_cidreq().'">'.Display :: return_icon('import_aiken.png', get_lang('ImportAikenQuiz'), '', ICON_SIZE_MEDIUM).'</a>';
     echo '<a href="upload_exercise.php?'.api_get_cidreq().'">'.Display :: return_icon('import_excel.png', get_lang('ImportExcelQuiz'), '', ICON_SIZE_MEDIUM).'</a>';
+    echo Display::url(
+        Display::return_icon(
+            'clean_all.png',
+            get_lang('CleanAllStudentsResultsForAllTests'), '', ICON_SIZE_MEDIUM),
+            '',
+            array(
+                'onclick' => "javascript:if(!confirm('".addslashes(api_htmlentities(get_lang('AreYouSureToEmptyAllTestResults'), ENT_QUOTES, $charset))."')) return false;",
+                'href' => 'exercice.php?'.api_get_cidreq().'&choice=clean_all_test&sec_token='.$token
+            )
+    );
 }
 
 if ($is_allowedToEdit) {
@@ -442,7 +489,8 @@ if (!empty($exercise_list)) {
         $mylpid = (empty($learnpath_id) ? '' : '&learnpath_id='.$learnpath_id);
         $mylpitemid = (empty($learnpath_item_id) ? '' : '&learnpath_item_id='.$learnpath_item_id);
 
-        $token = Security::get_token();
+        // $token = Security::get_token(); // has been moved above
+
         $i = 1;
 
         if ($is_allowedToEdit) {
@@ -723,7 +771,7 @@ if (!empty($exercise_list)) {
                                         $attempt_text = sprintf(get_lang('ExerciseWasActivatedFromXToY'), api_convert_and_format_date($row['start_time']), api_convert_and_format_date($row['end_time']));
                                     }
                                 }
-                                            
+
                             } else {
                                 //$attempt_text = get_lang('ExamNotAvailableAtThisTime');
                                 if ($row['start_time'] != '0000-00-00 00:00:00') {

+ 103 - 65
main/exercice/exercise.class.php

@@ -1482,25 +1482,42 @@ class Exercise {
 
     /**
      * Cleans the student's results only for the Exercise tool (Not from the LP)
-     * The LP results are NOT deleted
+     * The LP results are NOT deleted by default, otherwise put $clean_lp_tests = true
      * Works with exercises in sessions
+     * @param bool $clean_lp_tests
+     * @param int $clean_result_before_date
      * @return int quantity of user's exercises deleted
      */
-    function clean_results() {
+    function clean_results($clean_lp_tests = false, $clean_result_before_date = '0') {
         $table_track_e_exercises = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
         $table_track_e_attempt   = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
 
+        $sql_where = '  AND
+                        orig_lp_id = 0 AND
+                        orig_lp_item_id = 0';
+
+        // if we want to delete results from LP too
+        if ($clean_lp_tests) {
+            $sql_where = "";
+        }
+
+        // if we want to delete attempts before date $clean_result_before_date
+        // $clean_result_before_date must be a valid UTC-0 date yyyy-mm-dd
+        if ($clean_result_before_date != '0') {
+            $sql_where .= "  AND exe_date <= '$clean_result_before_date' ";
+        }
+
         $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()."";
+								session_id = ".api_get_session_id()." ".
+                                $sql_where;
 
         $result   = Database::query($sql_select);
         $exe_list = Database::store_result($result);
 
-        //deleting TRACK_E_ATTEMPT table
+        // deleting TRACK_E_ATTEMPT table
+        // check if exe in learning path or not
         $i = 0;
         if (is_array($exe_list) && count($exe_list) > 0) {
             foreach($exe_list as $item) {
@@ -1510,10 +1527,14 @@ class Exercise {
             }
         }
 
-        //delete TRACK_E_EXERCICES table
+        // delete TRACK_E_EXERCICES table
         $sql = "DELETE 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."
+                $sql_where
+                AND session_id = ".api_get_session_id()."";
         Database::query($sql);
+
         return $i;
     }
 
@@ -1934,27 +1955,40 @@ class Exercise {
      * @todo    reduce parameters of this function
      * @return  string  html code
      */
-    public function manage_answer($exeId, $questionId, $choice, $from = 'exercise_show', $exerciseResultCoordinates = array(), $saved_results = true, $from_database = false, $show_result = true, $propagate_neg = 0, $hotspot_delineation_result = array())
-    {
+    public function manage_answer(
+        $exeId,
+        $questionId,
+        $choice,
+        $from = 'exercise_show',
+        $exerciseResultCoordinates = array(),
+        $saved_results = true,
+        $from_database = false,
+        $show_result = true,
+        $propagate_neg = 0,
+        $hotspot_delineation_result = array()
+    ) {
         global $debug;
-        global $learnpath_id, $learnpath_item_id; //needed in order to use in the exercise_attempt() for the time
+        //needed in order to use in the exercise_attempt() for the time
+        global $learnpath_id, $learnpath_item_id;
+        require_once api_get_path(LIBRARY_PATH).'geometry.lib.php';
 
         $feedback_type = $this->selectFeedbackType();
         $results_disabled = $this->selectResultsDisabled();
 
-        require_once api_get_path(LIBRARY_PATH).'geometry.lib.php';
-
-        if ($debug) error_log("<------ manage_answer ------> ");
-        if ($debug) error_log('manage_answer called exe_id: '.$exeId);
-        if ($debug) error_log('manage_answer $from:  '.$from);
-        if ($debug) error_log('manage_answer $saved_results: '.$saved_results);
-        if ($debug) error_log('manage_answer $from_database: '.$from_database);
-        if ($debug) error_log('manage_answer $show_result: '.$show_result);
-        if ($debug) error_log('manage_answer $propagate_neg: '.$propagate_neg);
-        if ($debug) error_log('manage_answer $exerciseResultCoordinates: '.print_r($exerciseResultCoordinates, 1));
-        if ($debug) error_log('manage_answer $hotspot_delineation_result: '.print_r($hotspot_delineation_result, 1));
-        if ($debug) error_log('manage_answer $learnpath_id: '.$learnpath_id);
-        if ($debug) error_log('manage_answer $learnpath_item_id: '.$learnpath_item_id);
+        if ($debug) {
+            error_log("<------ manage_answer ------> ");
+            error_log('exe_id: '.$exeId);
+            error_log('$from:  '.$from);
+            error_log('$saved_results: '.intval($saved_results));
+            error_log('$from_database: '.intval($from_database));
+            error_log('$show_result: '.$show_result);
+            error_log('$propagate_neg: '.$propagate_neg);
+            error_log('$exerciseResultCoordinates: '.print_r($exerciseResultCoordinates, 1));
+            error_log('$hotspot_delineation_result: '.print_r($hotspot_delineation_result, 1));
+            error_log('$learnpath_id: '.$learnpath_id);
+            error_log('$learnpath_item_id: '.$learnpath_item_id);
+            error_log('$choice: '.print_r($choice, 1));
+        }
 
         $extra_data = array();
         $final_overlap = 0;
@@ -1972,8 +2006,8 @@ class Exercise {
 
         $questionId   = intval($questionId);
         $exeId        = intval($exeId);
-        $TBL_TRACK_ATTEMPT      = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
-        $table_ans              = Database::get_course_table(TABLE_QUIZ_ANSWER);
+        $TBL_TRACK_ATTEMPT = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
+        $table_ans = Database::get_course_table(TABLE_QUIZ_ANSWER);
 
         // Creates a temporary Question object
         $course_id              = api_get_course_int_id();
@@ -1991,28 +2025,30 @@ class Exercise {
 
         $next = 1; //not for now
 
-        //Extra information of the question
+        // Extra information of the question
         if (!empty($extra)) {
-            $extra          = explode(':', $extra);
+            $extra = explode(':', $extra);
             if ($debug) error_log(print_r($extra, 1));
-            //Fixes problems with negatives values using intval
-            $true_score     = intval($extra[0]);
-            $false_score    = intval($extra[1]);
-            $doubt_score    = intval($extra[2]);
+            // Fixes problems with negatives values using intval
+            $true_score     = floatval(trim($extra[0]));
+            $false_score    = floatval(trim($extra[1]));
+            $doubt_score    = floatval(trim($extra[2]));
         }
 
         $totalWeighting 		= 0;
         $totalScore				= 0;
 
         // Destruction of the Question object
-        unset ($objQuestionTmp);
+        unset($objQuestionTmp);
 
         // Construction of the Answer object
         $objAnswerTmp = new Answer($questionId);
         $nbrAnswers = $objAnswerTmp->selectNbrAnswers();
 
-        if ($debug) error_log('Count of answers: '.$nbrAnswers);
-        if ($debug) error_log('$answerType: '.$answerType);
+        if ($debug) {
+            error_log('Count of answers: '.$nbrAnswers);
+            error_log('$answerType: '.$answerType);
+        }
 
         if ($answerType == FREE_ANSWER || $answerType == ORAL_EXPRESSION) {
             $nbrAnswers = 1;
@@ -2044,7 +2080,8 @@ class Exercise {
         $user_answer = '';
 
         // Get answer list for matching
-        $sql_answer = 'SELECT id, answer FROM '.$table_ans.' WHERE c_id = '.$course_id.' AND question_id = "'.$questionId.'" ';
+        $sql_answer = 'SELECT id, answer FROM '.$table_ans.'
+                       WHERE c_id = '.$course_id.' AND question_id = "'.$questionId.'"';
         $res_answer = Database::query($sql_answer);
 
         $answer_matching =array();
@@ -2056,7 +2093,6 @@ class Exercise {
         $quiz_question_options = Question::readQuestionOption($questionId, $course_id);
 
         $organs_at_risk_hit = 0;
-
         $questionScore = 0;
 
         if ($debug) error_log('Start answer loop ');
@@ -2064,20 +2100,20 @@ class Exercise {
         $answer_correct_array = array();
 
         for ($answerId = 1; $answerId <= $nbrAnswers; $answerId++) {
-            $answer             = $objAnswerTmp->selectAnswer($answerId);
-            $answerComment      = $objAnswerTmp->selectComment($answerId);
-            $answerCorrect      = $objAnswerTmp->isCorrect($answerId);
-            $answerWeighting    = (float)$objAnswerTmp->selectWeighting($answerId);
-
-            $numAnswer          = $objAnswerTmp->selectAutoId($answerId);
-
+            $answer = $objAnswerTmp->selectAnswer($answerId);
+            $answerComment = $objAnswerTmp->selectComment($answerId);
+            $answerCorrect = $objAnswerTmp->isCorrect($answerId);
+            $answerWeighting = (float)$objAnswerTmp->selectWeighting($answerId);
+            $numAnswer = $objAnswerTmp->selectAutoId($answerId);
             $answer_correct_array[$answerId] = (bool)$answerCorrect;
 
-            if ($debug) error_log("answer auto id: $numAnswer ");
-            if ($debug) error_log("answer correct : $answerCorrect ");
+            if ($debug) {
+                error_log("answer auto id: $numAnswer ");
+                error_log("answer correct: $answerCorrect ");
+            }
 
-            //delineation
-            $delineation_cord   = $objAnswerTmp->selectHotspotCoordinates(1);
+            // Delineation
+            $delineation_cord = $objAnswerTmp->selectHotspotCoordinates(1);
             $answer_delineation_destination=$objAnswerTmp->selectDestination(1);
 
             switch ($answerType) {
@@ -2085,7 +2121,8 @@ class Exercise {
                 case UNIQUE_ANSWER :
                 case UNIQUE_ANSWER_NO_OPTION :
                     if ($from_database) {
-                        $queryans = "SELECT answer FROM ".$TBL_TRACK_ATTEMPT." WHERE exe_id = '".$exeId."' and question_id= '".$questionId."'";
+                        $queryans = "SELECT answer FROM ".$TBL_TRACK_ATTEMPT."
+                        WHERE exe_id = '".$exeId."' and question_id= '".$questionId."'";
                         $resultans = Database::query($queryans);
                         $choice = Database::result($resultans,0,"answer");
 
@@ -2095,7 +2132,7 @@ class Exercise {
                             $totalScore+=$answerWeighting;
                         }
                     } else {
-                        $studentChoice = ($choice == $numAnswer)?1:0;
+                        $studentChoice = ($choice == $numAnswer) ? 1 : 0;
                         if ($studentChoice) {
                             $questionScore+=$answerWeighting;
                             $totalScore+=$answerWeighting;
@@ -2106,32 +2143,33 @@ class Exercise {
                 case MULTIPLE_ANSWER_TRUE_FALSE:
                     if ($from_database) {
                         $choice = array();
-                        $queryans = "SELECT answer FROM ".$TBL_TRACK_ATTEMPT." where exe_id = ".$exeId." and question_id = ".$questionId;
-                        $resultans = Database::query($queryans);
+                        $sql = "SELECT answer FROM ".$TBL_TRACK_ATTEMPT."
+                                WHERE
+                                    exe_id = ".$exeId." AND
+                                    question_id = ".$questionId;
+                        $resultans = Database::query($sql);
                         while ($row = Database::fetch_array($resultans)) {
-                            $ind          = $row['answer'];
-                            $result       = explode(':',$ind);
+                            $ind = $row['answer'];
+                            $result = explode(':', $ind);
                             $my_answer_id = $result[0];
-                            $option       = $result[1];
+                            $option = $result[1];
                             $choice[$my_answer_id] = $option;
                         }
-                        $studentChoice  =$choice[$numAnswer];
-                    } else {
-                        $studentChoice  =$choice[$numAnswer];
                     }
+                    $studentChoice = isset($choice[$numAnswer]) ? $choice[$numAnswer] : null;
 
                     if (!empty($studentChoice)) {
-                        if ($studentChoice == $answerCorrect ) {
+                        if ($studentChoice == $answerCorrect) {
                             $questionScore  += $true_score;
                         } else {
                             if ($quiz_question_options[$studentChoice]['name'] != "Don't know") {
-                                $questionScore   +=  $false_score;
+                                $questionScore += $false_score;
                             } else {
-                                $questionScore  +=  $doubt_score;
+                                $questionScore += $doubt_score;
                             }
                         }
                     } else {
-                        //if no result then the user just hit don't know
+                        // If no result then the user just hit don't know
                         $studentChoice = 3;
                         $questionScore  +=  $doubt_score;
                     }
@@ -2140,7 +2178,8 @@ class Exercise {
                 case MULTIPLE_ANSWER: //2
                     if ($from_database) {
                         $choice = array();
-                        $queryans = "SELECT answer FROM ".$TBL_TRACK_ATTEMPT." WHERE exe_id = '".$exeId."' AND question_id= '".$questionId."'";
+                        $queryans = "SELECT answer FROM ".$TBL_TRACK_ATTEMPT."
+                                     WHERE exe_id = '".$exeId."' AND question_id= '".$questionId."'";
                         $resultans = Database::query($queryans);
                         while ($row = Database::fetch_array($resultans)) {
                             $ind = $row['answer'];
@@ -2161,7 +2200,7 @@ class Exercise {
                             $questionScore  += $answerWeighting;
                         }
                     }
-                    $totalScore     += $answerWeighting;
+                    $totalScore += $answerWeighting;
 
                     if ($debug) error_log("studentChoice: $studentChoice");
                     break;
@@ -2264,7 +2303,6 @@ class Exercise {
                     break;
                 // for fill in the blanks
                 case FILL_IN_BLANKS:
-
                     // the question is encoded like this
                     // [A] B [C] D [E] F::10,10,10@1
                     // number 1 before the "@" means that is a switchable fill in blank question

+ 61 - 31
main/exercice/exercise.lib.php

@@ -883,49 +883,80 @@ function get_count_exam_results($exercise_id, $extra_where_conditions) {
     return $count;
 }
 
+/**
+ * @param string $in_hotpot_path
+ * @return int
+ */
 function get_count_exam_hotpotatoes_results($in_hotpot_path) {
     return get_exam_results_hotpotatoes_data(0, 0, '', '', $in_hotpot_path, true, '');
 }
 
-//function get_exam_results_hotpotatoes_data($from, $number_of_items, $column, $direction, $exercise_id, $extra_where_conditions = null, $get_count = false) {
-function get_exam_results_hotpotatoes_data($in_from, $in_number_of_items, $in_column, $in_direction, $in_hotpot_path, $in_get_count = false, $where_condition = null) {
-
-    $tab_res = array();
+/**
+ * @param int $in_from
+ * @param int $in_number_of_items
+ * @param int $in_column
+ * @param int  $in_direction
+ * @param string $in_hotpot_path
+ * @param bool $in_get_count
+ * @param null $where_condition
+ * @return array|int
+ */
+function get_exam_results_hotpotatoes_data($in_from, $in_number_of_items, $in_column, $in_direction, $in_hotpot_path, $in_get_count = false, $where_condition = null)
+{
     $course_code = api_get_course_id();
     // by default in_column = 1 If parameters given, it is the name of the column witch is the bdd field name
     if ($in_column == 1) {
         $in_column = 'firstname';
     }
+    $in_hotpot_path = Database::escape_string($in_hotpot_path);
+    $in_direction = Database::escape_string($in_direction);
+    $in_column = Database::escape_string($in_column);
+    $in_number_of_items = intval($in_number_of_items);
+    $in_from = intval($in_from);
 
-    $TBL_TRACK_HOTPOTATOES      = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_HOTPOTATOES);
-    $TBL_USER                   = Database :: get_main_table(TABLE_MAIN_USER);
+    $TBL_TRACK_HOTPOTATOES = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_HOTPOTATOES);
+    $TBL_USER = Database :: get_main_table(TABLE_MAIN_USER);
 
-    $sql = "SELECT * FROM $TBL_TRACK_HOTPOTATOES thp JOIN $TBL_USER u ON thp.exe_user_id = u.user_id WHERE thp.exe_cours_id = '$course_code' AND exe_name LIKE '$in_hotpot_path%'";
+    $sql = "SELECT * FROM $TBL_TRACK_HOTPOTATOES thp
+            JOIN $TBL_USER u ON thp.exe_user_id = u.user_id
+            WHERE thp.exe_cours_id = '$course_code' AND exe_name LIKE '$in_hotpot_path%'";
 
     // just count how many answers
     if ($in_get_count) {
         $res = Database::query($sql);
         return Database::num_rows($res);
     }
-
-    $in_column = Database::escape_string($in_column);
-
     // get a number of sorted results
-    $sql .= " $where_condition ORDER BY $in_column $in_direction  LIMIT $in_from, $in_number_of_items";
+    $sql .= " $where_condition
+            ORDER BY $in_column $in_direction
+            LIMIT $in_from, $in_number_of_items";
 
     $res = Database::query($sql);
+    $result = array();
+    $apiIsAllowedToEdit = api_is_allowed_to_edit();
+    $urlBase = api_get_path(WEB_CODE_PATH).'exercice/hotpotatoes_exercise_report.php?action=delete&'.api_get_cidreq().'&id=';
     while ($data = Database::fetch_array($res)) {
-        $tab_one_res = array();
-        $tab_one_res['firstname'] = $data['firstname'];
-        $tab_one_res['lastname'] = $data['lastname'];
-        $tab_one_res['username'] = $data['username'];
-        $tab_one_res['group_name'] = implode("<br/>",GroupManager::get_user_group_name($data['user_id']));
-        $tab_one_res['exe_date'] = $data['exe_date'];
-        $tab_one_res['score'] = $data['exe_result'].'/'.$data['exe_weighting'];
-        $tab_one_res['actions'] = "";
-        $tab_res[] = $tab_one_res;
-    }
-    return $tab_res;
+        $actions = null;
+
+        if ($apiIsAllowedToEdit) {
+            $url = $urlBase.$data['id'].'&path='.$data['exe_name'];
+            $actions = Display::url(
+                Display::return_icon('delete.png', get_lang('Delete')),
+                $url
+            );
+        }
+
+        $result[] = array(
+            'firstname' => $data['firstname'],
+            'lastname' => $data['lastname'],
+            'username' => $data['username'],
+            'group_name' => implode("<br/>", GroupManager::get_user_group_name($data['user_id'])),
+            'exe_date' => $data['exe_date'],
+            'score' => $data['exe_result'].' / '.$data['exe_weighting'],
+            'actions' => $actions,
+        );
+    }
+    return $result;
 }
 
 /**
@@ -950,7 +981,6 @@ function get_exam_results_data($from, $number_of_items, $column, $direction, $ex
     $TBL_EXERCICES              = Database :: get_course_table(TABLE_QUIZ_TEST);
     $TBL_GROUP_REL_USER         = Database :: get_course_table(TABLE_GROUP_USER);
     $TBL_GROUP                  = Database :: get_course_table(TABLE_GROUP);
-
     $TBL_TRACK_EXERCICES        = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
     $TBL_TRACK_HOTPOTATOES      = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_HOTPOTATOES);
     $TBL_TRACK_ATTEMPT_RECORDING= Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT_RECORDING);
@@ -1107,7 +1137,6 @@ function get_exam_results_data($from, $number_of_items, $column, $direction, $ex
                     AND tth.exe_cours_id = '" . api_get_course_id()."'
                     $hotpotatoe_where
                     $sqlWhereOption
-    				AND $where_condition
                 ORDER BY
                     tth.exe_cours_id ASC,
                     tth.exe_date DESC";
@@ -1159,7 +1188,8 @@ function get_exam_results_data($from, $number_of_items, $column, $direction, $ex
         if (is_array($results)) {
 
             $users_array_id = array();
-            if ($_GET['gradebook'] == 'view') {
+            $from_gradebook = false;
+            if (isset($_GET['gradebook']) && $_GET['gradebook'] == 'view') {
                 $from_gradebook = true;
             }
             $sizeof = count($results);
@@ -1447,8 +1477,8 @@ function convert_score($score, $weight) {
  * @param   boolean Check publications dates
  * @param   string  Search exercise name
  * @param   boolean Search exercises in all sessions
- * @param   int     0 = only inactive exercises 
- *                  1 = only active exercises, 
+ * @param   int     0 = only inactive exercises
+ *                  1 = only active exercises,
  *                  2 = all exercises
  * @return  array   array with exercise data
  */
@@ -1475,7 +1505,7 @@ function get_all_exercises($course_info = null, $session_id = 0, $check_publicat
     }
 
     $needle_where   = (!empty($search_exercise)) ? " AND title LIKE '?' "       : '';
-    $needle         = (!empty($search_exercise)) ? "%" . $search_exercise . "%" : ''; 
+    $needle         = (!empty($search_exercise)) ? "%" . $search_exercise . "%" : '';
 
     //Show courses by active status
     $active_sql = '';
@@ -1484,10 +1514,10 @@ function get_all_exercises($course_info = null, $session_id = 0, $check_publicat
     }
 
 
-    if ($search_all_sessions == true) 
+    if ($search_all_sessions == true)
     {
         $conditions = array('where'=>array($active_sql . ' c_id = ? '. $needle_where . $time_conditions => array($course_id, $needle)), 'order'=>'title');
-    } else 
+    } else
     {
         if ($session_id == 0) {
             $conditions = array('where'=>array($active_sql . ' session_id = ? AND c_id = ? '. $needle_where . $time_conditions => array($session_id, $course_id, $needle)), 'order'=>'title');
@@ -1500,7 +1530,7 @@ function get_all_exercises($course_info = null, $session_id = 0, $check_publicat
 /**
  * Get exercise information by id
  * @param int Exercise Id
- * @return array Exercise info 
+ * @return array Exercise info
  */
 function get_exercise_by_id($exerciseId = 0) {
     $TBL_EXERCICES = Database :: get_course_table(TABLE_QUIZ_TEST);

+ 114 - 10
main/exercice/exercise_report.php

@@ -23,6 +23,7 @@ require_once '../gradebook/lib/be.inc.php';
 $this_section = SECTION_COURSES;
 
 $htmlHeadXtra[] = api_get_jqgrid_js();
+$htmlHeadXtra[] = api_get_datepicker_js();
 
 // Access control
 api_protect_course_script(true, false, true);
@@ -42,6 +43,9 @@ require_once api_get_path(LIBRARY_PATH).'statsUtils.lib.inc.php';
 
 // document path
 $documentPath = api_get_path(SYS_COURSE_PATH).$_course['path']."/document";
+$origin = isset($origin) ? $origin : null;
+$gradebook = isset($gradebook) ? $gradebook : null;
+$path = isset($_GET['path']) ? Security::remove_XSS($_GET['path']) : null;
 
 /* 	Constants and variables */
 $is_allowedToEdit = api_is_allowed_to_edit(null, true) || api_is_drh();
@@ -101,7 +105,9 @@ if (!empty($_REQUEST['export_report']) && $_REQUEST['export_report'] == '1') {
 }
 
 //Send student email @todo move this code in a class, library
-if ($_REQUEST['comments'] == 'update' && ($is_allowedToEdit || $is_tutor) && $_GET['exeid'] == strval(intval($_GET['exeid']))) {
+if (isset($_REQUEST['comments']) &&
+    $_REQUEST['comments'] == 'update' &&
+    ($is_allowedToEdit || $is_tutor) && $_GET['exeid'] == strval(intval($_GET['exeid']))) {
     $id = intval($_GET['exeid']); //filtered by post-condition
     $track_exercise_info = get_exercise_track_exercise_info($id);
     if (empty($track_exercise_info)) {
@@ -212,22 +218,37 @@ if ($_REQUEST['comments'] == 'update' && ($is_allowedToEdit || $is_tutor) && $_G
     }
 }
 
-
+$actions = null;
 if ($is_allowedToEdit && $origin != 'learnpath') {
     // the form
     if (api_is_platform_admin() || api_is_course_admin() || api_is_course_tutor() || api_is_course_coach()) {
         $actions .= '<a href="admin.php?exerciseId='.intval($_GET['exerciseId']).'">'.Display :: return_icon('back.png', get_lang('GoBackToQuestionList'), '', ICON_SIZE_MEDIUM).'</a>';
         $actions .='<a href="live_stats.php?'.api_get_cidreq().'&exerciseId='.$exercise_id.'">'.Display :: return_icon('activity_monitor.png', get_lang('LiveResults'), '', ICON_SIZE_MEDIUM).'</a>';
         $actions .='<a href="stats.php?'.api_get_cidreq().'&exerciseId='.$exercise_id.'">'.Display :: return_icon('statistics.png', get_lang('ReportByQuestion'), '', ICON_SIZE_MEDIUM).'</a>';
-        $actions .= '<a id="export_opener" href="'.api_get_self().'?export_report=1&hotpotato_name='.Security::remove_XSS($_GET['path']).'&exerciseId='.intval($_GET['exerciseId']).'" >'.
-            Display::return_icon('save.png', get_lang('Export'), '', ICON_SIZE_MEDIUM).'</a>';
+        $actions .= '<a id="export_opener" href="'.api_get_self().'?export_report=1&hotpotato_name='.$path.'&exerciseId='.intval($_GET['exerciseId']).'" >'.
+        Display::return_icon('save.png', get_lang('Export'), '', ICON_SIZE_MEDIUM).'</a>';
+        // clean result before a selected date icon
+        $actions .= Display::url(
+            Display::return_icon('clean_before_date.png', get_lang('CleanStudentsResultsBeforeDate'), '', ICON_SIZE_MEDIUM),
+            '#',
+            array('onclick' => "javascript:display_date_picker()")
+        );
+        // clean result before a selected date datepicker popup
+        $actions .= Display::span(
+            Display::input('input', 'datepicker_start', get_lang('SelectADateOnTheCalendar'),
+                array('onmouseover'=>'datepicker_input_mouseover()', 'id'=>'datepicker_start', 'onchange'=>'datepicker_input_changed()', 'readonly'=>'readonly')
+            ).
+            Display::button('delete', get_lang('Delete'),
+                array('onclick'=>'submit_datepicker()')),
+            array('style'=>'display:none', 'id'=>'datepicker_span')
+        );
     }
 } else {
     $actions .= '<a href="exercice.php">'.Display :: return_icon('back.png', get_lang('GoBackToQuestionList'), '', ICON_SIZE_MEDIUM).'</a>';
 }
 
 //Deleting an attempt
-if (($is_allowedToEdit || $is_tutor || api_is_coach()) && $_GET['delete'] == 'delete' && !empty($_GET['did']) && $locked == false) {
+if (($is_allowedToEdit || $is_tutor || api_is_coach()) && isset($_GET['delete']) && $_GET['delete'] == 'delete' && !empty($_GET['did']) && $locked == false) {
     $exe_id = intval($_GET['did']);
     if (!empty($exe_id)) {
         $sql = 'DELETE FROM '.$TBL_TRACK_EXERCICES.' WHERE exe_id = '.$exe_id;
@@ -239,6 +260,7 @@ if (($is_allowedToEdit || $is_tutor || api_is_coach()) && $_GET['delete'] == 'de
     }
 }
 
+
 if ($is_allowedToEdit || $is_tutor) {
     $nameTools = get_lang('StudentScore');
     $interbreadcrumb[] = array("url" => "exercice.php?gradebook=$gradebook", "name" => get_lang('Exercices'));
@@ -256,6 +278,26 @@ if ($is_allowedToEdit || $is_tutor) {
 
 Display :: display_header($nameTools);
 
+// Clean all results for this test before the selected date
+if (($is_allowedToEdit || $is_tutor || api_is_coach()) && isset($_GET['delete_before_date']) && $locked == false) {
+    // ask for the date
+    $check = Security::check_token('get');
+    if ($check) {
+        // delete attempts before date $_GET['delete_before_date']
+        $dateUTC = api_get_utc_datetime($_GET['delete_before_date']);
+        if (api_is_valid_date($_GET['delete_before_date'])) {
+            $objExerciseTmp = new Exercise();
+            if ($objExerciseTmp->read($exercise_id)) {
+                $nb_del = $objExerciseTmp->clean_results(true, $_GET['delete_before_date']);
+                Display :: display_confirmation_message(sprintf(get_lang('XResultsCleaned'), $nb_del));
+            }
+        }
+    }
+}
+
+// Security token to protect deletion
+$token = Security::get_token();
+
 $actions = Display::div($actions, array('class' => 'actions'));
 
 $extra = '<script>
@@ -383,6 +425,7 @@ $extra_params['autowidth'] = 'true';
 //height auto
 $extra_params['height'] = 'auto';
 ?>
+
 <script>
 
     function setSearchSelect(columnName) {
@@ -425,11 +468,11 @@ $extra_params['height'] = 'auto';
     }
 
     $(function() {
-<?php
-echo Display::grid_js('results', $url, $columns, $column_model, $extra_params, array(), $action_links, true);
+        <?php
+        echo Display::grid_js('results', $url, $columns, $column_model, $extra_params, array(), $action_links, true);
 
-if ($is_allowedToEdit || $is_tutor) {
-    ?>
+        if ($is_allowedToEdit || $is_tutor) {
+            ?>
 
                 //setSearchSelect("status");
                 //
@@ -471,14 +514,75 @@ if ($is_allowedToEdit || $is_tutor) {
                 var sgrid = $("#results")[0];
                 sgrid.triggerToolbar();
 
-<?php } ?>
+        <?php } ?>
+        });
+
+        // datepicker functions
+        var datapickerInputModified = false;
+
+        /**
+         * return true if the datepicker input has been modified
+         */
+        function datepicker_input_changed() {
+            datapickerInputModified = true;
+        }
+
+        /**
+        * disply the datepicker calendar on mouse over the input
+        */
+        function datepicker_input_mouseover() {
+            $('#datepicker_start').datepicker( "show" );
+        }
+
+        /**
+        * display or hide the datepicker input, calendar and button
+        */
+        function display_date_picker() {
+            if (!$('#datepicker_span').is(":visible")) {
+                $('#datepicker_span').show();
+                $('#datepicker_start').datepicker( "show" );
+            } else {
+                $('#datepicker_start').datepicker( "hide" );
+                $('#datepicker_span').hide();
+            }
+        }
+
+        /**
+        * confirm deletion
+        */
+        function submit_datepicker() {
+            if (datapickerInputModified) {
+                var dateTypeVar = $('#datepicker_start').datepicker('getDate');
+                var dateForBDD = $.datepicker.formatDate('yy-mm-dd', dateTypeVar);
+                // Format the date for confirm box
+                var dateFormat = $( "#datepicker_start" ).datepicker( "option", "dateFormat" );
+                var selectedDate = $.datepicker.formatDate(dateFormat, dateTypeVar);
+                if (confirm("<?php echo convert_double_quote_to_single(get_lang('AreYouSureDeleteTestResultBeforeDateD')); ?>" + selectedDate)) {
+                    self.location.href = "exercise_report.php?<?php echo api_get_cidreq(); ?>&exerciseId=<?php echo $exercise_id; ?>&delete_before_date="+dateForBDD+"&sec_token=<?php echo $token; ?>";
+                }
+            }
+        }
+
+        /**
+        * initiate datepicker
+        */
+        $(function() {
+
+            $( "#datepicker_start" ).datepicker({
+                defaultDate: "",
+                changeMonth: false,
+                numberOfMonths: 1
+            });
+
         });
+
 </script>
 <form id="export_report_form" method="post" action="exercise_report.php">
     <input type="hidden" name="csvBuffer" id="csvBuffer" value="" />
     <input type="hidden" name="export_report" id="export_report" value="1" />
     <input type="hidden" name="exerciseId" id="exerciseId" value="<?php echo $exercise_id ?>" />
 </form>
+
 <?php
 echo Display::grid_html('results');
 Display :: display_footer();

+ 13 - 4
main/exercice/exercise_result.php

@@ -45,12 +45,21 @@ $this_section = SECTION_COURSES;
 /* 	ACCESS RIGHTS  */
 api_protect_course_script(true);
 
-if ($debug){ error_log('Entering exercise_result.php: '.print_r($_POST,1));}
+if ($debug) {
+    error_log('Entering exercise_result.php: '.print_r($_POST, 1));
+}
 
 // general parameters passed via POST/GET
-if ( empty ( $origin ) ) {                  $origin                 = Security::remove_XSS($_REQUEST['origin']);}
-if ( empty ( $objExercise ) ) {             $objExercise            = $_SESSION['objExercise'];}
-if ( empty ( $remind_list ) ) {             $remind_list            = $_REQUEST['remind_list'];}
+// general parameters passed via POST/GET
+if (empty($origin)) {
+    $origin = Security::remove_XSS($_REQUEST['origin']);
+}
+if (empty($objExercise)) {
+    $objExercise = $_SESSION['objExercise'];
+}
+if (empty($remind_list)) {
+    $remind_list = isset($_REQUEST['remind_list']) ? $_REQUEST['remind_list'] : null;
+}
 
 $exe_id = isset($_REQUEST['exe_id']) ? intval($_REQUEST['exe_id']) : 0;
 

+ 1 - 1
main/exercice/exercise_show.php

@@ -29,7 +29,7 @@ require_once 'exercise.lib.php';
 require_once api_get_path(LIBRARY_PATH).'mail.lib.inc.php';
 
 if (empty($origin) ) {
-    $origin = $_REQUEST['origin'];
+    $origin = isset($_REQUEST['origin']) ? $_REQUEST['origin'] : null;
 }
 
 if ($origin == 'learnpath') {

+ 69 - 65
main/exercice/fill_blanks.class.php

@@ -12,77 +12,86 @@
  */
 
 /**
-	CLASS FillBlanks
  *
- *	This class allows to instantiate an object of type MULTIPLE_ANSWER (MULTIPLE CHOICE, MULTIPLE ANSWER),
+ *	This class allows to instantiate an object of type MULTIPLE_ANSWER
+ *  (MULTIPLE CHOICE, MULTIPLE ANSWER),
  *	extending the class question
  *
  *	@author Eric Marguin
  * 	@author Julio Montoya multiple fill in blank option added
  *	@package chamilo.exercise
  **/
-
 class FillBlanks extends Question
 {
 	static $typePicture = 'fill_in_blanks.gif';
 	static $explanationLangVar = 'FillBlanks';
 
-	/**
-	 * Constructor
-	 */
-	function FillBlanks()
-	{
-		parent::question();
-		$this -> type = FILL_IN_BLANKS;
-		$this -> isContent = $this-> getIsContent();
-	}
+    /**
+     * Constructor
+     */
+    public function FillBlanks()
+    {
+        parent::question();
+        $this -> type = FILL_IN_BLANKS;
+        $this -> isContent = $this-> getIsContent();
+    }
+
+    /**
+     * function which redifines Question::createAnswersForm
+     * @param the formvalidator instance
+     */
+    function createAnswersForm($form)
+    {
+        $defaults = array();
 
-	/**
-	 * function which redifines Question::createAnswersForm
-	 * @param the formvalidator instance
-	 */
-	function createAnswersForm ($form) {
-		$defaults = array();
+        if (!empty($this->id)) {
+            $objAnswer = new answer($this->id);
 
-		if (!empty($this->id)) {
-			$objAnswer = new answer($this->id);
+            // the question is encoded like this
+            // [A] B [C] D [E] F::10,10,10@1
+            // number 1 before the "@" means that is a switchable fill in blank question
+            // [A] B [C] D [E] F::10,10,10@ or  [A] B [C] D [E] F::10,10,10
+            // means that is a normal fill blank question
 
-			// the question is encoded like this
-		    // [A] B [C] D [E] F::10,10,10@1
-		    // number 1 before the "@" means that is a switchable fill in blank question
-		    // [A] B [C] D [E] F::10,10,10@ or  [A] B [C] D [E] F::10,10,10
-		    // means that is a normal fill blank question
+            $pre_array = explode('::', $objAnswer->selectAnswer(1));
 
-			$pre_array = explode('::', $objAnswer->selectAnswer(1));
+            //make sure we only take the last bit to find special marks
+            $sz = count($pre_array);
+            $is_set_switchable = explode('@', $pre_array[$sz-1]);
 
-			//make sure we only take the last bit to find special marks
-			$sz = count($pre_array);
-			$is_set_switchable = explode('@', $pre_array[$sz-1]);
+            if ($is_set_switchable[1]) {
+                $defaults['multiple_answer'] = 1;
+            } else {
+                $defaults['multiple_answer'] = 0;
+            }
 
-			if ($is_set_switchable[1]) {
-				$defaults['multiple_answer'] = 1;
-			} else {
-				$defaults['multiple_answer'] = 0;
-			}
+            //Take the complete string except after the last '::'
 
-			//Take the complete string except after the last '::'
+            $defaults['answer'] = '';
+            for ($i=0; $i<($sz-1); $i++) {
+                $defaults['answer'] .= $pre_array[$i];
+            }
+            $a_weightings = explode(',', $is_set_switchable[0]);
+        } else {
+            $defaults['answer'] = get_lang('DefaultTextInBlanks');
+        }
 
-			$defaults['answer'] = '';
-			for ($i=0;$i<($sz-1);$i++) {
-				$defaults['answer'] .= $pre_array[$i];
-			}
-			$a_weightings = explode(',', $is_set_switchable[0]);
-		} else {
-			$defaults['answer'] = get_lang('DefaultTextInBlanks');
-		}
+        $setValues = null;
+
+        if (isset($a_weightings) && count($a_weightings) > 0) {
+            foreach ($a_weightings as $i => $weighting) {
+                $setValues .= 'document.getElementById("weighting['.$i.']").value = "'.$weighting.'";';
+            }
+        }
 
 		// javascript
 		echo '<script>
-			function FCKeditor_OnComplete( editorInstance ) {
+
+			function FCKeditor_OnComplete(editorInstance) {
 				if (window.attachEvent) {
 					editorInstance.EditorDocument.attachEvent("onkeyup", updateBlanks) ;
 				} else {
-					editorInstance.EditorDocument.addEventListener("keyup",updateBlanks,true);
+					editorInstance.EditorDocument.addEventListener("keyup", updateBlanks, true);
 				}
 			}
 
@@ -93,8 +102,9 @@ class FillBlanks extends Question
                     field = document.getElementById("answer");
                     var answer = field.value;
                 } else {
-                    var oEditor = FCKeditorAPI.GetInstance(\'answer\');
-                    answer =  oEditor.GetXHTML( true ) ;
+                    var oEditor = FCKeditorAPI.GetInstance("answer");
+                    //var answer =  oEditor.GetXHTML(true);
+                    var answer = oEditor.EditorDocument.body.innerHTML;
                 }
 
                 var blanks = answer.match(/\[[^\]]*\]/g);
@@ -113,35 +123,30 @@ class FillBlanks extends Question
                 document.getElementById("blanks_weighting").innerHTML = fields + "</table></div></div>";
                 if (firstTime) {
                     firstTime = false;
-			';
-
-            if (count($a_weightings) > 0) {
-                foreach($a_weightings as $i => $weighting) {
-                    echo 'document.getElementById("weighting['.$i.']").value = "'.$weighting.'";';
-                }
-            }
-            echo '}
+                    '.$setValues.'
+			    }
             }
+
             window.onload = updateBlanks;
 		</script>';
 
 		// answer
-		$form -> addElement ('label', null, '<br /><br />'.get_lang('TypeTextBelow').', '.get_lang('And').' '.get_lang('UseTagForBlank'));
-		$form -> addElement ('html_editor', 'answer', '<img src="../img/fill_field.png">','id="answer" cols="122" rows="6" onkeyup="javascript: updateBlanks(this);"', array('ToolbarSet' => 'TestQuestionDescription', 'Width' => '100%', 'Height' => '350'));
+		$form->addElement('label', null, '<br /><br />'.get_lang('TypeTextBelow').', '.get_lang('And').' '.get_lang('UseTagForBlank'));
+		$form->addElement('html_editor', 'answer', '<img src="../img/fill_field.png">','id="answer" cols="122" rows="6" onkeyup="javascript: updateBlanks(this);"', array('ToolbarSet' => 'TestQuestionDescription', 'Width' => '100%', 'Height' => '350'));
 
-		$form -> addRule ('answer',get_lang('GiveText'),'required');
-		$form -> addRule ('answer',get_lang('DefineBlanks'),'regex','/\[.*\]/');
+		$form->addRule('answer', get_lang('GiveText'),'required');
+		$form->addRule('answer', get_lang('DefineBlanks'),'regex','/\[.*\]/');
 
 		//added multiple answers
-		$form -> addElement ('checkbox','multiple_answer','', get_lang('FillInBlankSwitchable'));
+		$form->addElement('checkbox', 'multiple_answer','', get_lang('FillInBlankSwitchable'));
 
-		$form -> addElement('html','<div id="blanks_weighting"></div>');
+		$form->addElement('html', '<div id="blanks_weighting"></div>');
 
 		global $text, $class;
 		// setting the save button here and not in the question class.php
-		$form->addElement('style_submit_button','submitQuestion',$text, 'class="'.$class.'"');
+		$form->addElement('style_submit_button', 'submitQuestion', $text, 'class="'.$class.'"');
 
-		if (!empty($this -> id)) {
+		if (!empty($this->id)) {
 			$form -> setDefaults($defaults);
 		} else {
 			if ($this->isContent == 1) {
@@ -150,10 +155,9 @@ class FillBlanks extends Question
 		}
 	}
 
-
 	/**
 	 * abstract function which creates the form to create / edit the answers of the question
-	 * @param the formvalidator instance
+	 * @param FormValidator $form
 	 */
 	function processAnswersCreation($form)
 	{

+ 72 - 36
main/exercice/hotpotatoes.lib.php

@@ -7,8 +7,9 @@
  * @author Istvan Mandak (original author)
  */
 
-$dbTable = Database::get_course_table(TABLE_DOCUMENT); // TODO: This is a global variable with too simple name, conflicts are possible. Better eliminate it. Correct the test unit too.
-
+/* TODO: This is a global variable with too simple name, conflicts are possible.
+Better eliminate it. Correct the test unit too. */
+$dbTable = Database::get_course_table(TABLE_DOCUMENT);
 
 /**
  * Creates a hotpotato directory.
@@ -17,7 +18,8 @@ $dbTable = Database::get_course_table(TABLE_DOCUMENT); // TODO: This is a global
  * @param   string      Wanted path
  * @return  boolean     Always true so far
  */
-function hotpotatoes_init($base_work_dir) {
+function hotpotatoes_init($base_work_dir)
+{
     //global $_course, $_user;
     $document_path = $base_work_dir.'/';
     if (!is_dir($document_path)) {
@@ -40,12 +42,13 @@ function hotpotatoes_init($base_work_dir) {
 }
 
 /**
- * Gets the title of the quizz file given as parameter.
+ * Gets the title of the quiz file given as parameter.
  * @param   string    File name
  * @param   string    File path
  * @return  string    The exercise title
  */
-function GetQuizName($fname, $fpath) {
+function GetQuizName($fname, $fpath)
+{
     $title = GetComment($fname);
     if (trim($title) == '') {
         if (file_exists($fpath.$fname)) {
@@ -72,9 +75,10 @@ function GetQuizName($fname, $fpath) {
  * @return  string    Comment from the database record
  * Added conditional to the table if is empty.
  */
-function GetComment($path, $course_code = '') {
+function GetComment($path, $course_code = '')
+{
     $dbTable = Database::get_course_table(TABLE_DOCUMENT);
-    $course_info = api_get_course_info($course_code);            
+    $course_info = api_get_course_info($course_code);
     $path = Database::escape_string($path);
     if (!empty($course_info) && !empty($path)) {
         $query = "SELECT comment FROM $dbTable WHERE c_id = {$course_info['real_id']}";
@@ -92,12 +96,14 @@ function GetComment($path, $course_code = '') {
  * @param    string    Comment to set
  * @return   string    Result of the database operation (Database::query will output some message directly on error anyway)
  */
-function SetComment($path, $comment) {
+function SetComment($path, $comment)
+{
     global $dbTable;
     $path = Database::escape_string($path);
     $comment = Database::escape_string($comment);
     $course_id = api_get_course_int_id();
-    $query = "UPDATE $dbTable SET comment='$comment' WHERE $course_id AND path='$path'";
+    $query = "UPDATE $dbTable SET comment='$comment'
+              WHERE $course_id AND path='$path'";
     $result = Database::query($query);
     return $result;
 }
@@ -107,7 +113,8 @@ function SetComment($path, $comment) {
  * @param    string    Urlencoded path
  * @return   string    The file contents or false on security error
  */
-function ReadFileCont($full_file_path) {
+function ReadFileCont($full_file_path)
+{
     if (empty($full_file_path)) {
         return false;
     }
@@ -125,17 +132,20 @@ function ReadFileCont($full_file_path) {
 }
 
 /**
- * Writes the file contents into the given filepath.
+ * Writes the file contents into the given file path.
  * @param    string    Urlencoded path
  * @param    string    The file contents
  * @return   boolean   True on success, false on security error
  */
-function WriteFileCont($full_file_path, $content) {
+function WriteFileCont($full_file_path, $content)
+{
     // Check if this is not an attack, trying to get into other directories or something like that.
     global $_course;
     if (Security::check_abs_path(dirname($full_file_path).'/', api_get_path(SYS_COURSE_PATH).$_course['path'].'/')) {
         // Check if this is not an attack, trying to upload a php file or something like that.
-        if (basename($full_file_path) != Security::filter_filename(basename($full_file_path))) { return false; }
+        if (basename($full_file_path) != Security::filter_filename(basename($full_file_path))) {
+            return false;
+        }
         if (!($fp = fopen(urldecode($full_file_path), 'w'))) {
             //die('Could not open Quiz input.');
         }
@@ -151,7 +161,8 @@ function WriteFileCont($full_file_path, $content) {
  * @param    string    An image tag (<img src="...." ...>)
  * @return   string    The image file name or an empty string
  */
-function GetImgName($imgtag) {
+function GetImgName($imgtag)
+{
     // Select src tag from img tag.
     $match = array();
     //preg_match('/(src=(["\'])1.*(["\'])1)/i', $imgtag, $match);            //src
@@ -182,7 +193,8 @@ function GetImgName($imgtag) {
  * @param    string    An image tag
  * @return   string    The image source or ""
  */
-function GetSrcName($imgtag) {
+function GetSrcName($imgtag)
+{
     // Select src tag from img tag.
     $match = array();
     preg_match("|(src=\".*\" )|U", $imgtag, $match);            //src
@@ -203,7 +215,8 @@ function GetSrcName($imgtag) {
  * @param    reference    Reference to a list of image parameters (emptied, then used to return results)
  * @param    reference    Reference to a counter of images (emptied, then used to return results)
  */
-function GetImgParams($fname, $fpath, &$imgparams, &$imgcount) {
+function GetImgParams($fname, $fpath, &$imgparams, &$imgcount)
+{
     // Select img tags from context.
     $imgparams = array();
     //phpinfo();
@@ -228,7 +241,8 @@ function GetImgParams($fname, $fpath, &$imgparams, &$imgcount) {
  * @param    array    List of image parameters
  * @return   string   String containing the hidden parameters built from the list given
  */
-function GenerateHiddenList($imgparams) {
+function GenerateHiddenList($imgparams)
+{
     $list = '';
     if (is_array($imgparams)) {
         while (list($int, $string) = each($imgparams)) {
@@ -244,7 +258,8 @@ function GenerateHiddenList($imgparams) {
  * @param    string       Node we are looking for in the array
  * @return   mixed        Node name or false if not found
  */
-function myarraysearch(&$array, $node) {
+function myarraysearch(&$array, $node)
+{
     $match = false;
     $tmp_array = array();
     for ($i = 0; $i < count($array); $i++) {
@@ -265,7 +280,8 @@ function myarraysearch(&$array, $node) {
  * @return   mixed            String given if found, false otherwise
  * @uses     myarraysearch    This function is just an additional layer on the myarraysearch() function
  */
-function CheckImageName(&$imgparams, $string) {
+function CheckImageName(&$imgparams, $string)
+{
     $checked = myarraysearch($imgparams, $string);
     return $checked;
 }
@@ -275,17 +291,17 @@ function CheckImageName(&$imgparams, $string) {
  * @param    string    The content to replace
  * @return   string    The modified content
  */
-function ReplaceImgTag($content) {
+function ReplaceImgTag($content)
+{
     $newcontent = $content;
     $matches = array();
     preg_match_all('(<img .*>)', $content, $matches);
-    $imgcount = 0;
     while (list($int, $match) = each($matches)) {
         while (list($key, $imgtag) = each($match)) {
             $imgname = GetSrcName($imgtag);
-            if ($imgname == '') {}                                // Valid or invalid image name.
-            else {
-
+            if ($imgname == '') {
+                // Valid or invalid image name.
+            } else {
                 $prehref = $imgname;
                 $posthref = basename($imgname);
                 $newcontent = str_replace($prehref, $posthref, $newcontent);
@@ -301,7 +317,8 @@ function ReplaceImgTag($content) {
  * @param    integer   Length to reach
  * @return   string    Modified folder name
  */
-function FillFolderName($name, $nsize) {
+function FillFolderName($name, $nsize)
+{
     $str = '';
     for ($i = 0; $i < $nsize - strlen($name); $i++) {
         $str .= '0';
@@ -315,7 +332,8 @@ function FillFolderName($name, $nsize) {
  * @param    string    Folder path
  * @return   string    Folder name (modified)
  */
-function GenerateHpFolder($folder) {
+function GenerateHpFolder($folder)
+{
     $filelist = array();
     if ($dir = @opendir($folder)) {
         while (($file = readdir($dir)) !== false) {
@@ -334,10 +352,12 @@ function GenerateHpFolder($folder) {
         $name = FillFolderName(mt_rand(1, 99999), 6);
         $checked = myarraysearch($filelist, $name);
         // As long as we find the name in the array, continue looping. As soon as we have a new element, quit.
-        if ($checked) { $w = 1;    }
-        else { $w = 0; }
+        if ($checked) {
+            $w = 1;
+        } else {
+            $w = 0;
+        }
     } while ($w == 1);
-
     return $name;
 }
 
@@ -346,18 +366,20 @@ function GenerateHpFolder($folder) {
  * @param    string    Path
  * @return   string    Folder name stripped down
  */
-function GetFolderName($fname) {
+function GetFolderName($fname)
+{
     $name = explode('/', $fname);
     $name = $name[sizeof($name) - 2];
     return $name;
 }
 
 /**
- * Gets the folder path (withouth the name of the folder itself) ?
+ * Gets the folder path (with out the name of the folder itself) ?
  * @param    string    Path
  * @return   string    Path stripped down
  */
-function GetFolderPath($fname) {
+function GetFolderPath($fname)
+{
     $str = '';
     $name = explode('/', $fname);
     for ($i = 0; $i < sizeof($name) - 1; $i++) {
@@ -371,7 +393,8 @@ function GetFolderPath($fname) {
  * @param    string    Path
  * @return   integer   1 if a subfolder was found, 0 otherwise
  */
-function CheckSubFolder($path) {
+function CheckSubFolder($path)
+{
     $folder = GetFolderPath($path);
     $dflag = 0;
     if ($dir = @opendir($folder)) {
@@ -396,7 +419,8 @@ function CheckSubFolder($path) {
  * @param    integer    User id
  * @return   void       No return value, but echoes results
  */
-function HotPotGCt($folder, $flag, $user_id) {
+function HotPotGCt($folder, $flag, $user_id)
+{
     // Garbage Collector
     $filelist = array();
     if ($dir = @opendir($folder)) {
@@ -409,7 +433,7 @@ function HotPotGCt($folder, $flag, $user_id) {
                     } else {
                         $filelist[] = $file;
                     }
-               }
+                }
             }
         }
         closedir($dir);
@@ -423,4 +447,16 @@ function HotPotGCt($folder, $flag, $user_id) {
             }
         }
     }
-}
+}
+
+/**
+ * Deletes an attempt from TABLE_STATISTIC_TRACK_E_HOTPOTATOES
+ * @param int $id
+ */
+function deleteAttempt($id)
+{
+    $table = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_HOTPOTATOES);
+    $id = intval($id);
+    $sql = "DELETE FROM $table WHERE id = $id";
+    Database::query($sql);
+}

+ 31 - 26
main/exercice/hotpotatoes.php

@@ -34,9 +34,9 @@ if (isset($_SESSION['gradebook'])) {
 
 if (!empty($gradebook) && $gradebook == 'view') {
     $interbreadcrumb[] = array(
-            'url' => '../gradebook/'.$_SESSION['gradebook_dest'],
-            'name' => get_lang('ToolGradebook')
-        );
+        'url' => '../gradebook/'.$_SESSION['gradebook_dest'],
+        'name' => get_lang('ToolGradebook')
+    );
 }
 // The breadcrumbs.
 $interbreadcrumb[] = array('url' => './exercice.php', 'name' => get_lang('Exercices'));
@@ -69,35 +69,32 @@ if (api_is_allowed_to_edit(null, true)) {
 /** Display */
 $nameTools = get_lang('HotPotatoesTests');
 
-$form = new FormValidator('hotpotatoes', 'post', api_get_self()."?".api_get_cidreq(), null, array('enctype' => 'multipart/form-data'));    
+$form = new FormValidator('hotpotatoes', 'post', api_get_self()."?".api_get_cidreq(), null, array('enctype' => 'multipart/form-data'));
 $form->addElement('header', $nameTools);
 $form->addElement('hidden', 'uploadPath');
 $form->addElement('hidden', 'fld', $fld);
 $form->addElement('hidden', 'imgcount', $imgcount);
 $form->addElement('hidden', 'finish', $finish);
-
 $form->addElement('html', GenerateHiddenList($imgparams));
-
 $form->addElement('advanced_settings', Display::return_icon('hotpotatoes.jpg', get_lang('HotPotatoes')));
-
 $label = get_lang('DownloadImg').' : ';
 if ($finish == 0) {
     $label = get_lang('DownloadFile').' : ';
-}    
+}
 
 $form->addElement('file', 'userFile', $label);
 $form->addElement('button', 'submit', get_lang('SendFile'));
 
-
 // If finish is set; it's because the user came from this script in the first place (displaying hidden "finish" field).
 if ((api_is_allowed_to_edit(null, true)) && (($finish == 0) || ($finish == 2))) {
-    
 
     // Moved this down here as the upload handling functions give output.
     if ($form->validate()) {
 
-        //initialise $finish
-        if (!isset($finish)) { $finish = 0; }
+        // Initialise $finish
+        if (!isset($finish)) {
+            $finish = 0;
+        }
 
         //if the size is not defined, it's probably because there has been an error or no file was submitted
         if (!$_FILES['userFile']['size']) {
@@ -117,7 +114,7 @@ if ((api_is_allowed_to_edit(null, true)) && (($finish == 0) || ($finish == 2)))
                 //$doc_id = add_document($_course, '/HotPotatoes_files/'.$fld, 'folder', 0, $fld);
                 //api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'FolderCreated', api_get_user_id());
                 @mkdir($document_sys_path.$uploadPath.'/'.$fld, api_get_permissions_for_new_directories());
-                $doc_id = add_document($_course, '/HotPotatoes_files/'.$fld, 'folder', 0, $fld);                    
+                $doc_id = add_document($_course, '/HotPotatoes_files/'.$fld, 'folder', 0, $fld);
                 api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'FolderCreated', api_get_user_id());
             } else {
                 // It is not the first step... get the filename directly from the system params.
@@ -131,8 +128,9 @@ if ((api_is_allowed_to_edit(null, true)) && (($finish == 0) || ($finish == 2)))
                 if ($finish == 2) {
                     $imgparams = $_POST['imgparams'];
                     $checked = CheckImageName($imgparams, $filename);
-                    if ($checked) { $imgcount = $imgcount-1; }
-                    else {
+                    if ($checked) {
+                        $imgcount = $imgcount-1;
+                    } else {
                         $dialogBox .= $filename.' '.get_lang('NameNotEqual');
                         my_delete($document_sys_path.$uploadPath.'/'.$fld.'/'.$filename);
                         update_db_info('delete', $uploadPath.'/'.$fld.'/'.$filename);
@@ -146,15 +144,19 @@ if ((api_is_allowed_to_edit(null, true)) && (($finish == 0) || ($finish == 2)))
                         $finish = 2;
                         // Get number and name of images from the files contents.
                         GetImgParams('/'.$filename, $document_sys_path.$uploadPath.'/'.$fld, $imgparams, $imgcount);
-                        if ($imgcount == 0) // There is no img link, so finish the upload process.
-                            { $finish = 1; }
-                        else // There is still one or more img missing.
-                            { $dialogBox .= get_lang('DownloadEnd'); }
+                        if ($imgcount == 0) {
+                            // There is no img link, so finish the upload process.
+                            $finish = 1;
+                        } else {
+                            // There is still one or more img missing.
+                            $dialogBox .= get_lang('DownloadEnd');
+                        }
                     }
                 }
 
                 $title = @htmlspecialchars(GetQuizName($filename, $document_sys_path.$uploadPath.'/'.$fld.'/'), ENT_COMPAT, api_get_system_encoding());
-                $query = "UPDATE $dbTable SET comment='".Database::escape_string($title)."' WHERE c_id = $course_id AND path=\"".$uploadPath."/".$fld."/".$filename."\"";
+                $query = "UPDATE $dbTable SET comment='".Database::escape_string($title)."'
+                         WHERE c_id = $course_id AND path=\"".$uploadPath."/".$fld."/".$filename."\"";
                 Database::query($query);
                 api_item_property_update($_course, TOOL_QUIZ, $id, 'QuizAdded', api_get_user_id());
 
@@ -163,14 +165,15 @@ if ((api_is_allowed_to_edit(null, true)) && (($finish == 0) || ($finish == 2)))
                     // delete?
                     //$dialogBox .= get_lang('NoImg');
                 }
-                $finish = 0;    // error
+                $finish = 0;
+                // error
                 if (api_failure::get_last_failure() == 'not_enough_space') {
                     $dialogBox .= get_lang('NoSpace');
                 } elseif (api_failure::get_last_failure() == 'php_file_in_zip_file') {
                     $dialogBox .= get_lang('ZipNoPhp');
                 }
             }
-        }        
+        }
     }
     if ($finish == 1) { /** ok -> send to main exercises page */
         header('Location: exercice.php?'.api_get_cidreq());
@@ -180,10 +183,12 @@ if ((api_is_allowed_to_edit(null, true)) && (($finish == 0) || ($finish == 2)))
     Display::display_header($nameTools, get_lang('Exercise'));
 
     echo '<div class="actions">';
-    echo '<a href="exercice.php?show=test">'.Display :: return_icon('back.png', get_lang('BackToExercisesList'),'',ICON_SIZE_MEDIUM).'</a>';
+    echo '<a href="exercice.php?show=test">'.
+        Display :: return_icon('back.png', get_lang('BackToExercisesList'), '', ICON_SIZE_MEDIUM).
+        '</a>';
     echo '</div>';
 
-    if ($finish==2) { // If we are in the img upload process.
+    if ($finish == 2) { // If we are in the img upload process.
         $dialogBox .= get_lang('ImgNote_st').$imgcount.get_lang('ImgNote_en').'<br />';
         while (list($key, $string) = each($imgparams)) {
             $dialogBox .= $string.'; ';
@@ -193,8 +198,8 @@ if ((api_is_allowed_to_edit(null, true)) && (($finish == 0) || ($finish == 2)))
     if ($dialogBox) {
         Display::display_normal_message($dialogBox, false);
     }
-    
-    $form->display();    
+
+    $form->display();
 }
 // Display the footer.
 Display::display_footer();

+ 75 - 178
main/exercice/hotpotatoes_exercise_report.php

@@ -3,12 +3,14 @@
 /**
  *	Exercise list: This script shows the list of exercises for administrators and students.
  *	@package chamilo.exercise
- *	@author hubert.borderiou 
+ *	@author hubert.borderiou
  *
  */
 /**
  * Code
  */
+use ChamiloSession as Session;
+
 // name of the language file that needs to be included
 $language_file = array('exercice');
 
@@ -24,7 +26,6 @@ $htmlHeadXtra[] = api_get_jqgrid_js();
 // Access control
 api_protect_course_script(true, false, true);
 
-
 // including additional libraries
 require_once 'exercise.class.php';
 require_once 'exercise.lib.php';
@@ -39,7 +40,7 @@ require_once api_get_path(LIBRARY_PATH).'mail.lib.inc.php';
 require_once api_get_path(LIBRARY_PATH) . 'statsUtils.lib.inc.php';
 
 // document path
-$documentPath = api_get_path(SYS_COURSE_PATH) . $_course['path'] . "/document";
+$documentPath = api_get_path(SYS_COURSE_PATH).$_course['path']."/document";
 
 /*	Constants and variables */
 $is_allowedToEdit           = api_is_allowed_to_edit(null, true) || api_is_drh();
@@ -54,9 +55,6 @@ $course_id            = api_get_course_int_id();
 $hotpotatoes_path     = isset($_REQUEST['path']) ? $_REQUEST['path'] : null;
 $filter_user          = isset($_REQUEST['filter_by_user']) ? intval($_REQUEST['filter_by_user']) : null;
 
-$locked = api_resource_is_locked_by_gradebook($exercise_id, LINK_EXERCISE);
-
-
 if (empty($hotpotatoes_path)) {
     api_not_allowed();
 }
@@ -69,8 +67,7 @@ if (!empty($_REQUEST['path'])) {
     $parameters['path'] = Security::remove_XSS($_REQUEST['path']);
 }
 
-
-
+$origin = isset($origin) ? $origin : null;
 
 if (!empty($_REQUEST['export_report']) && $_REQUEST['export_report'] == '1') {
     if (api_is_platform_admin() || api_is_course_admin() || api_is_course_tutor() || api_is_course_coach()) {
@@ -78,151 +75,42 @@ if (!empty($_REQUEST['export_report']) && $_REQUEST['export_report'] == '1') {
         if (isset($_REQUEST['extra_data']) && $_REQUEST['extra_data'] == 1) {
             $load_extra_data = true;
         }
-        
+
         require_once 'hotpotatoes_exercise_result.class.php';
-        // @todo make xls export work
-//        switch ($_GET['export_format']) {
-//            case 'xls' :
-//                $export = new ExerciseResult();
-//                $export->exportCompleteReportXLS($documentPath, null, $load_extra_data, null, $_GET['exerciseId'], $_GET['hotpotato_name']);
-//                exit;
-//                break;
-//            case 'csv' :
-//            default :
-                $export = new HotpotatoesExerciseResult();
-                $export->exportCompleteReportCSV($documentPath, $hotpotatoes_path);
-                exit;
-//                break;
-//        }
+        $export = new HotpotatoesExerciseResult();
+        $export->exportCompleteReportCSV($documentPath, $hotpotatoes_path);
+        exit;
     } else {
         api_not_allowed(true);
     }
 }
-
-//Send student email @todo move this code in a class, library
-//if ($_REQUEST['comments'] == 'update' && ($is_allowedToEdit || $is_tutor) && $_GET['exeid']== strval(intval($_GET['exeid']))) {
-//    $id         = intval($_GET['exeid']); //filtered by post-condition
-//    $track_exercise_info = get_exercise_track_exercise_info($id);
-//    if (empty($track_exercise_info)) {
-//        api_not_allowed();
-//    }
-//    $test              = $track_exercise_info['title'];
-//    $student_id        = $track_exercise_info['exe_user_id'];
-//
-//    $session_id        = $track_exercise_info['session_id'];
-//    $lp_id             = $track_exercise_info['orig_lp_id'];
-//    //$lp_item_id        = $track_exercise_info['orig_lp_item_id'];
-//    $lp_item_view_id   = $track_exercise_info['orig_lp_item_view_id'];
-//
-//    // Teacher data
-//    $teacher_info      = api_get_user_info(api_get_user_id());
-//    $user_info         = api_get_user_info($student_id);
-//    $student_email     = $user_info['mail'];
-//    $from              = $teacher_info['mail'];
-//    $from_name         = api_get_person_name($teacher_info['firstname'], $teacher_info['lastname'], null, PERSON_NAME_EMAIL_ADDRESS);
-//
-//    $url               = api_get_path(WEB_CODE_PATH) . 'exercice/exercise_report.php?' . api_get_cidreq() . '&id_session='.$session_id.'&exerciseId='.$exercise_id;
-//
-//    $my_post_info      = array();
-//    $post_content_id   = array();
-//    $comments_exist    = false;
-//
-//    foreach ($_POST as $key_index => $key_value) {
-//        $my_post_info  = explode('_',$key_index);
-//        $post_content_id[]=$my_post_info[1];
-//        if ($my_post_info[0]=='comments') {
-//            $comments_exist=true;
-//        }
-//    }
-//
-//    $loop_in_track=($comments_exist===true) ? (count($_POST)/2) : count($_POST);
-//
-//    $array_content_id_exe=array();
-//    if ($comments_exist===true) {
-//        $array_content_id_exe = array_slice($post_content_id,$loop_in_track);
-//    } else {
-//        $array_content_id_exe = $post_content_id;
-//    }
-//
-//    for ($i=0;$i<$loop_in_track;$i++) {
-//        $my_marks           = Database::escape_string($_POST['marks_'.$array_content_id_exe[$i]]);
-//        $contain_comments   = Database::escape_string($_POST['comments_'.$array_content_id_exe[$i]]);
-//        if (isset($contain_comments)) {
-//            $my_comments    = Database::escape_string($_POST['comments_'.$array_content_id_exe[$i]]);
-//        } else {
-//            $my_comments    = '';
-//        }
-//        $my_questionid = intval($array_content_id_exe[$i]);
-//        $sql = "SELECT question from $TBL_QUESTIONS WHERE c_id = $course_id AND id = '$my_questionid'";
-//        $result =Database::query($sql);
-//        Database::result($result,0,"question");
-//
-//        $query = "UPDATE $TBL_TRACK_ATTEMPT SET marks = '$my_marks',teacher_comment = '$my_comments' WHERE question_id = ".$my_questionid." AND exe_id=".$id;
-//        Database::query($query);
-//
-//        //Saving results in the track recording table
-//        $recording_changes = 'INSERT INTO '.$TBL_TRACK_ATTEMPT_RECORDING.' (exe_id, question_id, marks, insert_date, author, teacher_comment)
-//                              VALUES ('."'$id','".$my_questionid."','$my_marks','".api_get_utc_datetime()."','".api_get_user_id()."'".',"'.$my_comments.'")';
-//        Database::query($recording_changes);
-//    }
-//
-//    $qry = 'SELECT DISTINCT question_id, marks FROM ' . $TBL_TRACK_ATTEMPT . ' WHERE exe_id = '.$id .' GROUP BY question_id';
-//    $res = Database::query($qry);
-//    $tot = 0;
-//    while ($row = Database :: fetch_array($res, 'ASSOC')) {
-//        $tot += $row['marks'];
-//    }
-//
-//    $totquery = "UPDATE $TBL_TRACK_EXERCICES SET exe_result = '".floatval($tot)."' WHERE exe_id = ".$id;
-//    Database::query($totquery);
-//
-//    //@todo move this somewhere else
-//    $subject = get_lang('ExamSheetVCC');
-//
-//    $message  = '<p>'.get_lang('DearStudentEmailIntroduction') . '</p><p>'.get_lang('AttemptVCC');
-//    $message .= '<h3>'.get_lang('CourseName'). '</h3><p>'.Security::remove_XSS($course_info['name']).'';
-//    $message .= '<h3>'.get_lang('Exercise') . '</h3><p>'.Security::remove_XSS($test);
-//
-//    //Only for exercises not in a LP
-//    if ($lp_id == 0) {
-//        $message .= '<p>'.get_lang('ClickLinkToViewComment') . ' <a href="#url#">#url#</a><br />';
-//    }
-//
-//    $message .= '<p>'.get_lang('Regards').'</p>';
-//    $message .= $from_name;
-//
-//    $message = str_replace("#test#", Security::remove_XSS($test), $message);
-//    $message = str_replace("#url#", $url, $message);
-//
-//    @api_mail_html($student_email, $student_email, $subject, $message, $from_name, $from, array('charset'=>api_get_system_encoding()));
-//
-//    //Updating LP score here
-//    if (in_array($origin, array ('tracking_course','user_course','correct_exercise_in_lp'))) {
-//        $sql_update_score = "UPDATE $TBL_LP_ITEM_VIEW SET score = '" . floatval($tot) . "' WHERE c_id = ".$course_id." AND id = " .$lp_item_view_id;
-//        Database::query($sql_update_score);
-//        if ($origin == 'tracking_course') {
-//            //Redirect to the course detail in lp
-//            header('location: exercice.php?course=' . Security :: remove_XSS($_GET['course']));
-//            exit;
-//        } else {
-//            //Redirect to the reporting
-//            header('location: ../mySpace/myStudents.php?origin=' . $origin . '&student=' . $student_id . '&details=true&course=' . $course_id.'&session_id='.$session_id);
-//            exit;
-//        }
-//    }
-//}
-
-
+$actions = null;
 if ($is_allowedToEdit && $origin != 'learnpath') {
     // the form
     if (api_is_platform_admin() || api_is_course_admin() || api_is_course_tutor() || api_is_course_coach()) {
-        $actions .= '<a href="admin.php?exerciseId='.intval($_GET['exerciseId']).'">' . Display :: return_icon('back.png', get_lang('GoBackToQuestionList'),'',ICON_SIZE_MEDIUM).'</a>';
+        //$actions .= '<a href="admin.php?exerciseId='.intval($_GET['exerciseId']).'">' . Display :: return_icon('back.png', get_lang('GoBackToQuestionList'),'',ICON_SIZE_MEDIUM).'</a>';
         $actions .= '<a id="export_opener" href="'.api_get_self().'?export_report=1&path='.Security::remove_XSS($hotpotatoes_path).' ">'.Display::return_icon('save.png',   get_lang('Export'),'',ICON_SIZE_MEDIUM).'</a>';
     }
 } else {
     $actions .= '<a href="exercice.php">' . Display :: return_icon('back.png', get_lang('GoBackToQuestionList'),'',ICON_SIZE_MEDIUM).'</a>';
 }
 
+if ($is_allowedToEdit) {
+    $action = isset($_GET['action']) ? $_GET['action'] : null;
+    switch ($action) {
+        case 'delete':
+            $fileToDelete = isset($_GET['id']) ? $_GET['id'] : null;
+            deleteAttempt($fileToDelete);
+            Session::write('message', Display::return_message(get_lang('ItemDeleted')));
+            $url = api_get_self().'?'.api_get_cidreq().'&path='.$hotpotatoes_path;
+            header("Location: $url");
+            exit;
+            break;
+
+    }
+}
+
+
 //Deleting an attempt
 //if ( ($is_allowedToEdit || $is_tutor || api_is_coach()) && $_GET['delete'] == 'delete' && !empty ($_GET['did']) && $locked == false) {
 //    $exe_id = intval($_GET['did']);
@@ -235,20 +123,21 @@ if ($is_allowedToEdit && $origin != 'learnpath') {
 //        exit;
 //    }
 //}
+$nameTools = get_lang('Results');
 
 if ($is_allowedToEdit || $is_tutor) {
     $nameTools = get_lang('StudentScore');
-    $interbreadcrumb[] = array("url" => "exercice.php?gradebook=$gradebook","name" => get_lang('Exercices'));
+    $interbreadcrumb[] = array("url" => "exercice.php","name" => get_lang('Exercices'));
     $objExerciseTmp = new Exercise();
-    if ($objExerciseTmp->read($exercise_id)) {
+    /*if ($objExerciseTmp->read($exercise_id)) {
         $interbreadcrumb[] = array("url" => "admin.php?exerciseId=".$exercise_id, "name" => $objExerciseTmp->name);
-    }
+    }*/
 } else {
-    $interbreadcrumb[] = array("url" => "exercice.php?gradebook=$gradebook","name" => get_lang('Exercices'));
+    $interbreadcrumb[] = array("url" => "exercice.php","name" => get_lang('Exercices'));
     $objExerciseTmp = new Exercise();
-    if ($objExerciseTmp->read($exercise_id)) {
+    /*if ($objExerciseTmp->read($exercise_id)) {
         $nameTools = get_lang('Results').': '.$objExerciseTmp->name;
-    }
+    }*/
 }
 
 Display :: display_header($nameTools);
@@ -297,17 +186,16 @@ $form->setDefaults(array('export_format' => 'csv'));
 $extra .= $form->return_form();
 $extra .= '</div>';
 
-if ($is_allowedToEdit)
+if ($is_allowedToEdit) {
     echo $extra;
+}
 
 echo $actions;
 
 $url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_hotpotatoes_exercise_results&path='.$hotpotatoes_path.'&filter_by_user='.$filter_user;
-
-//$activeurl = '?sidx=session_active';
 $action_links = '';
 
-//Generating group list
+// Generating group list
 
 $group_list = GroupManager::get_group_list();
 $group_parameters = array('group_all:'.get_lang('All'),'group_none:'.get_lang('None'));
@@ -320,28 +208,34 @@ if (!empty($group_parameters)) {
 }
 
 if ($is_allowedToEdit || $is_tutor) {
-
-	//The order is important you need to check the the $column variable in the model.ajax.php file
-	$columns        = array(get_lang('FirstName'), get_lang('LastName'), get_lang('LoginName'),
-                        get_lang('Group'), get_lang('StartDate'),  get_lang('Score'),  get_lang('Actions'));
+    // The order is important you need to check the the $column variable in the model.ajax.php file
+    $columns = array(
+        get_lang('FirstName'),
+        get_lang('LastName'),
+        get_lang('LoginName'),
+        get_lang('Group'),
+        get_lang('StartDate'),
+        get_lang('Score'),
+        get_lang('Actions')
+    );
 
   //Column config
   // @todo fix search firstname/lastname that doesn't work. rmove search for the moment
 	$column_model   = array(
-                        array('name'=>'firstname',      'index'=>'firstname',		'width'=>'50',   'align'=>'left', 'search' => 'false'),
-                        array('name'=>'lastname',		    'index'=>'lastname',		'width'=>'50',   'align'=>'left', 'formatter'=>'action_formatter', 'search' => 'false'),
-                        array('name'=>'login',          'hidden'=>'true',       'index'=>'username',        'width'=>'40',   'align'=>'left', 'search' => 'false'),
-                        array('name'=>'group_name',		  'index'=>'group_id',    'width'=>'40',   'align'=>'left', 'search' => 'false'),
-            						array('name'=>'exe_date',		    'index'=>'exe_date',		'width'=>'60',   'align'=>'left', 'search' => 'false'),
-            						array('name'=>'score',			    'index'=>'exe_result',	'width'=>'50',   'align'=>'left', 'search' => 'false'),
-            						array('name'=>'actions',        'index'=>'actions',     'width'=>'60',  'align'=>'left', 'search' => 'false')
-                       );
+        array('name'=>'firstname',      'index'=>'firstname',		'width'=>'50',   'align'=>'left', 'search' => 'false'),
+        array('name'=>'lastname',		    'index'=>'lastname',		'width'=>'50',   'align'=>'left', 'formatter'=>'action_formatter', 'search' => 'false'),
+        array('name'=>'login',          'hidden'=>'true',       'index'=>'username',        'width'=>'40',   'align'=>'left', 'search' => 'false'),
+        array('name'=>'group_name',		  'index'=>'group_id',    'width'=>'40',   'align'=>'left', 'search' => 'false'),
+        array('name'=>'exe_date',		    'index'=>'exe_date',		'width'=>'60',   'align'=>'left', 'search' => 'false'),
+        array('name'=>'score',			    'index'=>'exe_result',	'width'=>'50',   'align'=>'left', 'search' => 'false'),
+        array('name'=>'actions',        'index'=>'actions',     'width'=>'60',  'align'=>'left', 'search' => 'false')
+    );
 
     $action_links = '
     // add username as title in lastname filed - ref 4226
     function action_formatter(cellvalue, options, rowObject) {
         // rowObject is firstname,lastname,login,... get the third word
-        var loginx = "'.api_htmlentities(sprintf(get_lang("LoginX"),":::"), ENT_QUOTES).'";
+        var loginx = "'.api_htmlentities(sprintf(get_lang("LoginX"), ":::"), ENT_QUOTES).'";
         var tabLoginx = loginx.split(/:::/);
         // tabLoginx[0] is before and tabLoginx[1] is after :::
         // may be empty string but is defined
@@ -349,15 +243,19 @@ if ($is_allowedToEdit || $is_tutor) {
     }';
 } else {
     //The order is important you need to check the the $column variable in the model.ajax.php file
-	$columns        = array(get_lang('StartDate'),  get_lang('Score'),  get_lang('Actions'));
-
-  //Column config
-  // @todo fix search firstname/lastname that doesn't work. rmove search for the moment
-	$column_model   = array(
-                        array('name'=>'exe_date',		    'index'=>'exe_date',		'width'=>'60',   'align'=>'left', 'search' => 'false'),
-            			array('name'=>'score',			    'index'=>'exe_result',	'width'=>'50',   'align'=>'left', 'search' => 'false'),
-            			array('name'=>'actions',        'index'=>'actions',     'width'=>'60',  'align'=>'left', 'search' => 'false')
-                       );
+    $columns = array(
+        get_lang('StartDate'),
+        get_lang('Score'),
+        get_lang('Actions')
+    );
+
+    //Column config
+    // @todo fix search firstname/lastname that doesn't work. rmove search for the moment
+    $column_model  = array(
+        array('name'=>'exe_date',		    'index'=>'exe_date',		'width'=>'60',   'align'=>'left', 'search' => 'false'),
+        array('name'=>'score',			    'index'=>'exe_result',	'width'=>'50',   'align'=>'left', 'search' => 'false'),
+        array('name'=>'actions',        'index'=>'actions',     'width'=>'60',  'align'=>'left', 'search' => 'false')
+    );
 }
 
 //Autowidth
@@ -365,12 +263,8 @@ $extra_params['autowidth'] = 'true';
 
 //height auto
 $extra_params['height'] = 'auto';
-//$extra_params['excel'] = 'excel';
-//$extra_params['rowList'] = array(20, 50, 100, 500, 1000, 2000, 5000, 10000);
-
 ?>
 <script>
-
 function setSearchSelect(columnName) {
     $("#results").jqGrid('setColProp', columnName,
     {
@@ -411,8 +305,8 @@ function exportExcel() {
 }
 
 $(function() {
-    <?php
-    echo Display::grid_js('results', $url,$columns,$column_model, $extra_params, array(), $action_links, true);
+<?php
+    echo Display::grid_js('results', $url, $columns, $column_model, $extra_params, array(), $action_links, true);
 
     if ($is_allowedToEdit || $is_tutor) { ?>
 
@@ -447,5 +341,8 @@ $(function() {
 </form>
 <?php
 
+$showMessage = Session::read('message');
+Session::erase('message');
+echo isset($showMessage) ? $showMessage : null;
 echo Display::grid_html('results');
-Display :: display_footer();
+Display :: display_footer();

+ 144 - 146
main/exercice/hotpotatoes_exercise_result.class.php

@@ -5,56 +5,54 @@
  * of type HotpotatoesExerciseResult
  * which allows you to export exercises results in multiple presentation forms
  * @package chamilo.exercise
- * @author 
- * @version $Id: $
  */
 /**
  * Code
  */
-if(!class_exists('HotpotatoesExerciseResult')):
 /**
  * Exercise results class
  * @package chamilo.exercise
  */
 class HotpotatoesExerciseResult
 {
-	private $exercises_list = array(); //stores the list of exercises
-	private $results = array(); //stores the results
+    //stores the list of exercises
+    private $exercises_list = array();
 
-	/**
-	 * constructor of the class
-	 */
-	public function ExerciseResult($get_questions=false,$get_answers=false) {
-	}
-
-	/**
-	 * Reads exercises information (minimal) from the data base
-	 * @param	boolean		Whether to get only visible exercises (true) or all of them (false). Defaults to false.
-	 * @return	array		A list of exercises available
-	 */
-	private function _readExercisesList($only_visible = false)
-	{
-		$return = array();
-    	$TBL_EXERCISES          = Database::get_course_table(TABLE_QUIZ_TEST);
+    //stores the results
+    private $results = array();
 
-		$sql="SELECT id,title,type,random,active FROM $TBL_EXERCISES";
-		if($only_visible)
-		{
-			$sql.= ' WHERE active=1';
-		}
-		$sql .= ' ORDER BY title';
-		$result=Database::query($sql);
-
-		// if the exercise has been found
-		while($row=Database::fetch_array($result,'ASSOC'))
-		{
-			$return[] = $row;
-		}
-		// exercise not found
-		return $return;
-	}
+    /**
+     * constructor of the class
+     */
+    public function ExerciseResult($get_questions=false,$get_answers=false)
+    {
+    }
 
+    /**
+     * Reads exercises information (minimal) from the data base
+     * @param	boolean		Whether to get only visible exercises (true) or all of them (false). Defaults to false.
+     * @return	array		A list of exercises available
+     */
+    private function _readExercisesList($only_visible = false)
+    {
+        $return = array();
+        $TBL_EXERCISES          = Database::get_course_table(TABLE_QUIZ_TEST);
+
+        $sql="SELECT id,title,type,random,active FROM $TBL_EXERCISES";
+        if ($only_visible) {
+            $sql.= ' WHERE active=1';
+        }
+        $sql .= ' ORDER BY title';
+        $result=Database::query($sql);
 
+        // if the exercise has been found
+        while($row=Database::fetch_array($result,'ASSOC'))
+        {
+            $return[] = $row;
+        }
+        // exercise not found
+        return $return;
+    }
 
 	/**
 	 * Gets the results of all students (or just one student if access is limited)
@@ -62,99 +60,101 @@ class HotpotatoesExerciseResult
 	 * @param	integer		User ID. Optional. If no user ID is provided, we take all the results. Defauts to null
 	 */
 //	function _getExercisesReporting($document_path, $user_id = null, $filter = 0, $hotpotato_name = null) {
-	function _getExercisesReporting($document_path, $hotpotato_name) {
+	function _getExercisesReporting($document_path, $hotpotato_name)
+    {
 		$return = array();
 
-    $TBL_EXERCISES          = Database::get_course_table(TABLE_QUIZ_TEST);
-    $TBL_USER          	    = Database::get_main_table(TABLE_MAIN_USER);
-    $TBL_TRACK_EXERCISES    	= Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
-    $TBL_TRACK_HOTPOTATOES	= Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_HOTPOTATOES);
-    $TBL_TRACK_ATTEMPT_RECORDING= Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT_RECORDING);
-    
-    $cid             = api_get_course_id();
-    $course_id       = api_get_course_int_id();
-    $user_id         = intval($user_id);
-    $session_id_and  = ' AND te.session_id = ' . api_get_session_id() . ' ';
-    $hotpotato_name  = Database::escape_string($hotpotato_name);
-    
-    
-    if (!empty($exercise_id)) {
-      $session_id_and .= " AND exe_exo_id = $exercise_id ";
-    }
+        $TBL_EXERCISES          = Database::get_course_table(TABLE_QUIZ_TEST);
+        $TBL_USER          	    = Database::get_main_table(TABLE_MAIN_USER);
+        $TBL_TRACK_EXERCISES    	= Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
+        $TBL_TRACK_HOTPOTATOES	= Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_HOTPOTATOES);
+        $TBL_TRACK_ATTEMPT_RECORDING= Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT_RECORDING);
 
-		if (empty($user_id)) {
-    $sql="SELECT firstname as userpart1, lastname as userpart2 ,
-            email,
-            tth.exe_name,
-            tth.exe_result,
-            tth.exe_weighting,
-            tth.exe_date
-            FROM $TBL_TRACK_HOTPOTATOES tth, $TBL_USER tu
-            WHERE   tu.user_id=tth.exe_user_id AND
-                    tth.exe_cours_id = '" . Database :: escape_string($cid) . "' AND
-                    tth.exe_name = '$hotpotato_name'
-            ORDER BY tth.exe_cours_id ASC, tth.exe_date ASC";
-		} else {
-      $user_id_and = ' AND te.exe_user_id = ' . api_get_user_id() . ' ';
-      // get only this user's results
-  
-      $sql = "SELECT '', exe_name, exe_result , exe_weighting, exe_date
-                      FROM $TBL_TRACK_HOTPOTATOES
-                      WHERE   exe_user_id = '" . $user_id . "' AND
-                              exe_cours_id = '" . Database :: escape_string($cid) . "' AND
-                              tth.exe_name = '$hotpotato_name'
-                      ORDER BY exe_cours_id ASC, exe_date ASC";
-		}
+        $cid             = api_get_course_id();
+        $course_id       = api_get_course_int_id();
+        $user_id         = intval($user_id);
+        $session_id_and  = ' AND te.session_id = ' . api_get_session_id() . ' ';
+        $hotpotato_name  = Database::escape_string($hotpotato_name);
 
-		$results = array();
 
-		$resx = Database::query($sql);
-		while ($rowx = Database::fetch_array($resx,'ASSOC')) {
-            $results[] = $rowx;
-		}
+        if (!empty($exercise_id)) {
+          $session_id_and .= " AND exe_exo_id = $exercise_id ";
+        }
 
-		$hpresults = array();
-		$resx = Database::query($sql);
-	    while ($rowx = Database::fetch_array($resx,'ASSOC')) {
-            $hpresults[] = $rowx;
-		}
+        if (empty($user_id)) {
+            $sql="SELECT firstname as userpart1, lastname as userpart2 ,
+                    email,
+                    tth.exe_name,
+                    tth.exe_result,
+                    tth.exe_weighting,
+                    tth.exe_date
+                    FROM $TBL_TRACK_HOTPOTATOES tth, $TBL_USER tu
+                    WHERE   tu.user_id=tth.exe_user_id AND
+                            tth.exe_cours_id = '" . Database :: escape_string($cid) . "' AND
+                            tth.exe_name = '$hotpotato_name'
+                    ORDER BY tth.exe_cours_id ASC, tth.exe_date ASC";
+        } else {
+            $user_id_and = ' AND te.exe_user_id = ' . api_get_user_id() . ' ';
+            // get only this user's results
+
+            $sql = "SELECT '', exe_name, exe_result , exe_weighting, exe_date
+                          FROM $TBL_TRACK_HOTPOTATOES
+                          WHERE   exe_user_id = '" . $user_id . "' AND
+                                  exe_cours_id = '" . Database :: escape_string($cid) . "' AND
+                                  tth.exe_name = '$hotpotato_name'
+                          ORDER BY exe_cours_id ASC, exe_date ASC";
+            }
 
-		if ($filter) {
-			switch ($filter) {
-				case 1 :
-                    $filter_by_not_revised = true;
-                    break;
-				case 2 :
-                    $filter_by_revised = true;
-                    break;
-				default :
-                    null;
-			}
-		}
+            $results = array();
 
-		// Print the Result of Hotpotatoes Tests
-		if (is_array($hpresults)) {
-			for($i = 0; $i < sizeof($hpresults); $i++) {
-				$return[$i] = array();
-				$title = GetQuizName($hpresults[$i]['exe_name'], $document_path);
-				if ($title =='') {
-					$title = basename($hpresults[$i]['exe_name']);
-				}
-				if(empty($user_id)) {
-			    $return[$i]['email'] = $hpresults[$i]['email'];
-					$return[$i]['first_name'] = $hpresults[$i]['userpart1'];
-					$return[$i]['last_name'] = $hpresults[$i]['userpart2'];
-				}
-				$return[$i]['title'] = $title;
-				$return[$i]['exe_date']  = $hpresults[$i]['exe_date'];
+            $resx = Database::query($sql);
+            while ($rowx = Database::fetch_array($resx,'ASSOC')) {
+                $results[] = $rowx;
+            }
 
-				$return[$i]['result'] = $hpresults[$i]['exe_result'];
-				$return[$i]['max'] = $hpresults[$i]['exe_weighting'];
-			}
-		}
-		$this->results = $return;
-		return true;
+            $hpresults = array();
+            $resx = Database::query($sql);
+            while ($rowx = Database::fetch_array($resx,'ASSOC')) {
+                $hpresults[] = $rowx;
+            }
+
+            if ($filter) {
+                switch ($filter) {
+                    case 1 :
+                        $filter_by_not_revised = true;
+                        break;
+                    case 2 :
+                        $filter_by_revised = true;
+                        break;
+                    default :
+                        null;
+                }
+            }
+
+            // Print the Result of Hotpotatoes Tests
+            if (is_array($hpresults)) {
+                for($i = 0; $i < sizeof($hpresults); $i++) {
+                    $return[$i] = array();
+                    $title = GetQuizName($hpresults[$i]['exe_name'], $document_path);
+                    if ($title =='') {
+                        $title = basename($hpresults[$i]['exe_name']);
+                    }
+                    if(empty($user_id)) {
+                    $return[$i]['email'] = $hpresults[$i]['email'];
+                        $return[$i]['first_name'] = $hpresults[$i]['userpart1'];
+                        $return[$i]['last_name'] = $hpresults[$i]['userpart2'];
+                    }
+                    $return[$i]['title'] = $title;
+                    $return[$i]['exe_date']  = $hpresults[$i]['exe_date'];
+
+                    $return[$i]['result'] = $hpresults[$i]['exe_result'];
+                    $return[$i]['max'] = $hpresults[$i]['exe_weighting'];
+                }
+            }
+            $this->results = $return;
+            return true;
 	}
+
 	/**
 	 * Exports the complete report as a CSV file
 	 * @param	string		Document path inside the document tool
@@ -162,7 +162,8 @@ class HotpotatoesExerciseResult
 	 * @param	boolean		Whether to include user fields or not
 	 * @return	boolean		False on error
 	 */
-	public function exportCompleteReportCSV($document_path='', $hotpotato_name) {
+	public function exportCompleteReportCSV($document_path='', $hotpotato_name)
+    {
 		global $charset;
 		$this->_getExercisesReporting($document_path, $hotpotato_name);
 		$filename = 'exercise_results_'.date('YmdGis').'.csv';
@@ -171,22 +172,22 @@ class HotpotatoesExerciseResult
 		}
 		$data = '';
 
-    if (api_is_western_name_order()) {
-        if(!empty($this->results[0]['first_name'])) {
-            $data .= get_lang('FirstName').';';
-        }
-        if(!empty($this->results[0]['last_name'])) {
-            $data .= get_lang('LastName').';';
-        }
-    } else {
-        if(!empty($this->results[0]['last_name'])) {
-            $data .= get_lang('LastName').';';
-        }
-        if(!empty($this->results[0]['first_name'])) {
-            $data .= get_lang('FirstName').';';
+        if (api_is_western_name_order()) {
+            if(!empty($this->results[0]['first_name'])) {
+                $data .= get_lang('FirstName').';';
+            }
+            if(!empty($this->results[0]['last_name'])) {
+                $data .= get_lang('LastName').';';
+            }
+        } else {
+            if(!empty($this->results[0]['last_name'])) {
+                $data .= get_lang('LastName').';';
+            }
+            if(!empty($this->results[0]['first_name'])) {
+                $data .= get_lang('FirstName').';';
+            }
         }
-    }
-    $data .= get_lang('Email').';';
+        $data .= get_lang('Email').';';
 
 		if ($export_user_fields) {
 			//show user fields section with a big th colspan that spans over all fields
@@ -205,15 +206,15 @@ class HotpotatoesExerciseResult
 
 		//results
 		foreach($this->results as $row) {
-      if (api_is_western_name_order()) {
-          $data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)).';';
-          $data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)).';';
-      } else {
-          $data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)).';';
-          $data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)).';';
-      }
+            if (api_is_western_name_order()) {
+              $data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)).';';
+              $data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)).';';
+            } else {
+              $data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)).';';
+              $data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)).';';
+            }
 
-      $data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['email']), ENT_QUOTES, $charset)).';';
+            $data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['email']), ENT_QUOTES, $charset)).';';
 
 			if ($export_user_fields) {
 				//show user fields data, if any, for this user
@@ -283,8 +284,6 @@ class HotpotatoesExerciseResult
 			}
 		}
 
-
-
 		if ($with_column_user) {
 
 		    $worksheet->write($line,$column,get_lang('Email'));
@@ -378,4 +377,3 @@ class HotpotatoesExerciseResult
 		return true;
 	}
 }
-endif;

+ 10 - 9
main/exercice/question.class.php

@@ -1481,7 +1481,7 @@ abstract class Question
      * @param   int     Type of question (see constants at beginning of question.class.php)
      * @param   int     Question level/category
      */
-    function create_question ($quiz_id, $question_name, $max_score = 0, $type = 1, $level = 1) {
+    function create_question ($quiz_id, $question_name, $question_description = "" , $max_score = 0, $type = 1, $level = 1) {
         $course_id = api_get_course_int_id();
 
         $tbl_quiz_question = Database::get_course_table(TABLE_QUIZ_QUESTION);
@@ -1494,30 +1494,31 @@ abstract class Question
 
         // Get the max position
         $sql = "SELECT max(position) as max_position"
-               ." FROM $tbl_quiz_question q INNER JOIN $tbl_quiz_rel_question r"
-               ." ON q.id = r.question_id"
-               ." AND exercice_id = $quiz_id AND q.c_id = $course_id AND r.c_id = $course_id";
+            ." FROM $tbl_quiz_question q INNER JOIN $tbl_quiz_rel_question r"
+            ." ON q.id = r.question_id"
+            ." AND exercice_id = $quiz_id AND q.c_id = $course_id AND r.c_id = $course_id";
         $rs_max = Database::query($sql, __FILE__, __LINE__);
         $row_max = Database::fetch_object($rs_max);
         $max_position = $row_max->max_position +1;
 
         // Insert the new question
-        $sql = "INSERT INTO $tbl_quiz_question (c_id, question, ponderation, position, type, level)
-                VALUES ($course_id, '".Database::escape_string($question_name)."', '$max_score', $max_position, $type, $level)";
+        $sql = "INSERT INTO $tbl_quiz_question (c_id, question, description, ponderation, position, type, level)
+                VALUES ($course_id, '".Database::escape_string($question_name)."', '".Database::escape_string($question_description)."', '$max_score', $max_position, $type, $level)";
+
         $rs = Database::query($sql);
         // Get the question ID
         $question_id = Database::get_last_insert_id();
 
         // Get the max question_order
         $sql = "SELECT max(question_order) as max_order "
-              ."FROM $tbl_quiz_rel_question WHERE c_id = $course_id AND exercice_id = $quiz_id ";
+            ."FROM $tbl_quiz_rel_question WHERE c_id = $course_id AND exercice_id = $quiz_id ";
         $rs_max_order = Database::query($sql);
         $row_max_order = Database::fetch_object($rs_max_order);
         $max_order = $row_max_order->max_order + 1;
         // Attach questions to quiz
         $sql = "INSERT INTO $tbl_quiz_rel_question "
-              ."(c_id, question_id,exercice_id,question_order)"
-              ." VALUES($course_id, $question_id, $quiz_id, $max_order)";
+            ."(c_id, question_id,exercice_id,question_order)"
+            ." VALUES($course_id, $question_id, $quiz_id, $max_order)";
         $rs = Database::query($sql);
         return $question_id;
     }

+ 13 - 11
main/exercice/question_admin.inc.php

@@ -23,7 +23,7 @@ if (isset($_GET['editQuestion'])) {
 
 if (is_object($objQuestion)) {
 	//FORM CREATION
-	$form = new FormValidator('question_admin_form','post', $action);    
+	$form = new FormValidator('question_admin_form','post', $action);
 	if (isset($_GET['editQuestion'])) {
 		$class="btn save";
 		$text=get_lang('ModifyQuestion');
@@ -39,32 +39,32 @@ if (is_object($objQuestion)) {
 
 	// form title
 	$form->addElement('header', $text.': '.$form_title_extra);
-    
+
 	// question form elements
 	$objQuestion->createForm($form);
 
 	// answer form elements
-    
+
 	$objQuestion->createAnswersForm($form);
 
-	// this variable  $show_quiz_edition comes from admin.php blocks the exercise/quiz modifications    
+	// this variable  $show_quiz_edition comes from admin.php blocks the exercise/quiz modifications
 	if ($objExercise->edit_exercise_in_lp == false) {
 		$form->freeze();
 	}
-	
+
 	// FORM VALIDATION
 	if (isset($_POST['submitQuestion']) && $form->validate()) {
 
 		// question
 	    $objQuestion->processCreation($form, $objExercise);
-        
-	    // answers        
+
+	    // answers
 	    $objQuestion->processAnswersCreation($form, $nb_answers);
 
         // TODO: maybe here is the better place to index this tool, including answers text
 
 	    // redirect
-	    if ($objQuestion->type != HOT_SPOT && $objQuestion->type != HOT_SPOT_DELINEATION) {	    	
+	    if ($objQuestion->type != HOT_SPOT && $objQuestion->type != HOT_SPOT_DELINEATION) {
 	    	if(isset($_GET['editQuestion'])) {
 	    		echo '<script type="text/javascript">window.location.href="admin.php?exerciseId='.$exerciseId.'&message=ItemUpdated"</script>';
 	    	} else {
@@ -74,9 +74,11 @@ if (is_object($objQuestion)) {
 	    } else {
 	    	echo '<script type="text/javascript">window.location.href="admin.php?exerciseId='.$exerciseId.'&hotspotadmin='.$objQuestion->id.'"</script>';
 	    }
-	} else {	 
-		echo '<h3>'.$questionName.'</h3>';
-		if(!empty($pictureName)){
+	} else {
+        if (isset($questionName)) {
+		    echo '<h3>'.$questionName.'</h3>';
+        }
+		if (!empty($pictureName)) {
 			echo '<img src="../document/download.php?doc_url=%2Fimages%2F'.$pictureName.'" border="0">';
 		}
 		if(!empty($msgErr)) {

二进制
main/exercice/quiz_template.xls


+ 7 - 9
main/exercice/savescores.php

@@ -1,5 +1,4 @@
 <?php
-
 /* For licensing terms, see /license.txt */
 /**
  * 	Saving the scores.
@@ -24,20 +23,19 @@ if (isset($_GET['origin']) && $_GET['origin'] == 'learnpath') {
 
 require_once '../inc/global.inc.php';
 $this_section = SECTION_COURSES;
-
 require_once api_get_path(LIBRARY_PATH).'fileManage.lib.php';
-
 $documentPath = api_get_path(SYS_COURSE_PATH).$_course['path']."/document";
+
+$test = $_REQUEST['test'];
 $full_file_path = $documentPath.$test;
 
 my_delete($full_file_path.$_user['user_id'].".t.html");
 
 $TABLETRACK_HOTPOTATOES = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_HOTPOTATOES);
-$tbl_learnpath_user = Database::get_course_table(TABLE_LEARNPATH_USER);
 $TABLE_LP_ITEM_VIEW = Database::get_course_table(TABLE_LP_ITEM_VIEW);
 
 $_cid = api_get_course_id();
-$test = $_REQUEST['test'];
+
 $score = $_REQUEST['score'];
 $origin = $_REQUEST['origin'];
 $learnpath_item_id = intval($_REQUEST['learnpath_item_id']);
@@ -54,9 +52,9 @@ $jscript2run = '';
  * @param	integer	Score to save inside the tracking tables (HP and learnpath)
  * @return	void
  */
-function save_scores($file, $score) {
-    global $origin, $_user, $_cid,
-    $TABLETRACK_HOTPOTATOES;
+function save_scores($file, $score)
+{
+    global $origin, $_user, $_cid, $TABLETRACK_HOTPOTATOES;
     // if tracking is disabled record nothing
     $weighting = 100; // 100%
     $date = api_get_utc_datetime();
@@ -107,7 +105,7 @@ if ($origin != 'learnpath') {
     Display::display_reduced_header();
     $update_sql = "UPDATE $TABLE_LP_ITEM_VIEW SET status = 'completed'
                    WHERE c_id = $course_id AND lp_item_id= $learnpath_item_id";
-    Database::query($update_sql); 
+    Database::query($update_sql);
     Display::display_confirmation_message(get_lang('HotPotatoesFinished'));
     Display::display_footer();
 }

+ 35 - 47
main/exercice/showinframes.php

@@ -5,22 +5,19 @@
  *	@package chamilo.exercise
  * 	@author Istvan Mandak
  */
-/**
- * Included libraries
- */
-require '../inc/global.inc.php';
+require_once '../inc/global.inc.php';
 require_once api_get_path(LIBRARY_PATH).'fileManage.lib.php';
 require_once api_get_path(SYS_CODE_PATH).'exercice/hotpotatoes.lib.php';
 
 $time = time();
 $doc_url = str_replace(array('../', '\\', '\\0', '..'), array('', '', '', ''), urldecode($_GET['file']));
-$cid                = api_get_course_id();
+$cid = api_get_course_id();
 $document_path      = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
 $document_web_path  = api_get_path(WEB_COURSE_PATH).$_course['path'].'/document';
-$origin             = $_REQUEST['origin'];
-$learnpath_id       = $_REQUEST['learnpath_id'];
-$learnpath_item_id  = $_REQUEST['learnpath_item_id'];
-$time               = $_REQUEST['time'];
+$origin             = isset($_REQUEST['origin']) ? $_REQUEST['origin'] : null;
+$learnpath_id       = isset($_REQUEST['learnpath_id']) ? $_REQUEST['learnpath_id'] : null;
+$learnpath_item_id  = isset($_REQUEST['learnpath_item_id']) ? $_REQUEST['learnpath_item_id'] : null;
+$time               = isset($_REQUEST['time']) ? $_REQUEST['time'] : null;
 
 $user_id = api_get_user_id();
 $full_file_path = $document_path.$doc_url;
@@ -29,62 +26,53 @@ $content = ReadFileCont($full_file_path.$user_id.'.t.html');
 
 if ($content == '') {
 	$content = ReadFileCont($full_file_path);
+    // Do not move this like:
 	$mit = "function Finish(){";
 	$js_content = "
-        //Code added - start
-        var SaveScoreVariable = 0;
-        function mySaveScore() {
-            if (SaveScoreVariable==0) {
-                SaveScoreVariable = 1;
-                    if (C.ie) {
-                        document.location.href = '".api_get_path(WEB_PATH)."main/exercice/savescores.php?origin=$origin&learnpath_id=$learnpath_id&learnpath_item_id=$learnpath_item_id&time=".Security::remove_XSS($time)."&test=".$doc_url."&uid=".$user_id."&cid=".$cid."&score='+Score;
-						//window.alert(Score);
-                    } else {
-                        window.location.href = '".api_get_path(WEB_PATH)."main/exercice/savescores.php?origin=$origin&learnpath_id=$learnpath_id&learnpath_item_id=$learnpath_item_id&time=".Security::remove_XSS($time)."&test=".$doc_url."&uid=".$user_id."&cid=".$cid."&score='+Score;
-                    }
-						}
-				}
-				function Finish(){
-                    mySaveScore();
-        //Code added - end
+    // Code added - start
+    var SaveScoreVariable = 0;
+    function mySaveScore() {
+        if (SaveScoreVariable==0) {
+            SaveScoreVariable = 1;
+            if (C.ie) {
+                document.location.href = '".api_get_path(WEB_PATH)."main/exercice/savescores.php?origin=$origin&learnpath_id=$learnpath_id&learnpath_item_id=$learnpath_item_id&time=".Security::remove_XSS($time)."&test=".$doc_url."&uid=".$user_id."&cid=".$cid."&score='+Score;
+                //window.alert(Score);
+            } else {
+                window.location.href = '".api_get_path(WEB_PATH)."main/exercice/savescores.php?origin=$origin&learnpath_id=$learnpath_id&learnpath_item_id=$learnpath_item_id&time=".Security::remove_XSS($time)."&test=".$doc_url."&uid=".$user_id."&cid=".$cid."&score='+Score;
+            }
+        }
+    }
+    function Finish() {
+        mySaveScore();
+    // Code added - end
     ";
 
-	$newcontent = str_replace($mit, $js_content, $content);
-	$prehref = "<!-- BeginTopNavButtons -->";
-	$posthref = "<!-- BeginTopNavButtons -->";
-	$newcontent = str_replace($prehref, $posthref, $newcontent);
+    $newcontent = str_replace($mit, $js_content, $content);
+    $prehref = "<!-- BeginTopNavButtons -->";
+    $posthref = "<!-- BeginTopNavButtons -->";
+    $newcontent = str_replace($prehref, $posthref, $newcontent);
 
-	if (CheckSubFolder($full_file_path.$user_id.'.t.html') == 0) {
-		$newcontent = ReplaceImgTag($newcontent);
-	}
+    if (CheckSubFolder($full_file_path.$user_id.'.t.html') == 0) {
+        $newcontent = ReplaceImgTag($newcontent);
+    }
 } else {
-	$newcontent = $content;
+    $newcontent = $content;
 }
 
-
 WriteFileCont($full_file_path.$user_id.'.t.html', $newcontent);
 $doc_url = GetFolderPath($doc_url).urlencode(basename($doc_url));
 
 $documentPath= api_get_path(SYS_COURSE_PATH).$_course['path']."/document";
 $my_file = Security::remove_XSS($_GET['file']);
-$my_file = str_replace(array('../','\\..','\\0','..\\'),array('','','',''),urldecode($my_file));
+$my_file = str_replace(array('../', '\\..', '\\0', '..\\'), array('', '', '', ''),urldecode($my_file));
 
-$title = GetQuizName($my_file,$documentPath);
+$title = GetQuizName($my_file, $documentPath);
 if ($title =='') {
-	$title = basename($my_file);
+    $title = basename($my_file);
 }
 $nameTools = $title;
-$noPHP_SELF=true;
-if (isset($_SESSION['gradebook'])){
-	$gradebook=	$_SESSION['gradebook'];
-}
+$noPHP_SELF = true;
 
-if (!empty($gradebook) && $gradebook=='view') {
-	$interbreadcrumb[]= array (
-        'url'  => '../gradebook/'.$_SESSION['gradebook_dest'],
-        'name' => get_lang('ToolGradebook')
-    );
-}
 $htmlHeadXtra[] = '
 <script>
     $(document).ready( function(){

+ 7 - 7
main/exercice/tests_category.php

@@ -63,27 +63,27 @@ function edit_category_form($in_action) {
         $category_id = Security::remove_XSS($_GET['category_id']);
         $objcat = new Testcategory($category_id);
 
-        // initiate the object		
+        // initiate the object
         $form = new FormValidator('note', 'post', api_get_self() . '?action=' . $in_action . '&category_id=' . $category_id);
 
-        // settting the form elements			
+        // settting the form elements
         $form->addElement('header', get_lang('EditCategory'));
         $form->addElement('hidden', 'category_id');
         $form->addElement('text', 'category_name', get_lang('CategoryName'), array('size' => '95'));
         $form->add_html_editor('category_description', get_lang('CategoryDescription'), false, false, array('ToolbarSet' => 'test_category', 'Width' => '90%', 'Height' => '200'));
         $form->addElement('style_submit_button', 'SubmitNote', get_lang('ModifyCategory'), 'class="add"');
 
-        // setting the defaults		
+        // setting the defaults
         $defaults = array();
         $defaults["category_id"] = $objcat->id;
         $defaults["category_name"] = $objcat->name;
         $defaults["category_description"] = $objcat->description;
         $form->setDefaults($defaults);
 
-        // setting the rules		
+        // setting the rules
         $form->addRule('category_name', get_lang('ThisFieldIsRequired'), 'required');
 
-        // The validation or display		
+        // The validation or display
         if ($form->validate()) {
             $check = Security::check_token('post');
             if ($check) {
@@ -138,7 +138,7 @@ function add_category_form($in_action) {
     $in_action = Security::remove_XSS($in_action);
     // initiate the object
     $form = new FormValidator('note', 'post', api_get_self() . '?action=' . $in_action);
-    // settting the form elements	
+    // Setting the form elements
     $form->addElement('header', get_lang('AddACategory'));
     $form->addElement('text', 'category_name', get_lang('CategoryName'), array('size' => '95'));
     $form->add_html_editor('category_description', get_lang('CategoryDescription'), false, false, array('ToolbarSet' => 'test_category', 'Width' => '90%', 'Height' => '200'));
@@ -227,4 +227,4 @@ function protectJSDialogQuote($in_txt) {
     $res = str_replace("'", "\'", $res);
     $res = str_replace('"', "\'\'", $res); // super astuce pour afficher les " dans les boite de dialogue
     return $res;
-}
+}

+ 23 - 8
main/exercice/upload_exercise.php

@@ -80,10 +80,10 @@ function lp_upload_quiz_actions() {
 }
 
 function lp_upload_quiz_secondary_actions() {
- $lp_id = Security::remove_XSS($_GET['lp_id']);
- $return.= '';
- $return.='<a href="exercise_report.php?' . api_get_cidreq() . '">' . Display :: return_icon('reporting32.png', get_lang('Tracking')) . get_lang('Tracking') . '</a>';
- return $return;
+    $lp_id = Security::remove_XSS($_GET['lp_id']);
+    $return = '';
+    $return.='<a href="exercise_report.php?' . api_get_cidreq() . '">' . Display :: return_icon('reporting32.png', get_lang('Tracking')) . get_lang('Tracking') . '</a>';
+    return $return;
 }
 
 function lp_upload_quiz_main() {
@@ -136,6 +136,7 @@ function lp_upload_quiz_action_handling() {
     $feedback_true_index = array();
     $feedback_false_index = array();
     $number_questions = 0;
+    $question_description_index = array();
     // Reading all the first column items sequencially to create breakpoints
     for ($i = 1; $i <= $data->sheets[0]['numRows']; $i++) {
         if ($data->sheets[0]['cells'][$i][1] == 'Quiz' && $i == 1) {
@@ -151,7 +152,10 @@ function lp_upload_quiz_action_handling() {
             $feedback_true_index[] = $i; // FeedbackTrue position (line)
         } elseif ($data->sheets[0]['cells'][$i][1] == 'FeedbackFalse') {
             $feedback_false_index[] = $i; // FeedbackFalse position (line)
+        } elseif ($data->sheets[0]['cells'][$i][1] == 'EnrichQuestion') {
+            $question_description_index[] = $i;
         }
+
     }
     // Variables
     $quiz = array();
@@ -161,8 +165,9 @@ function lp_upload_quiz_action_handling() {
     $score_list = array();
     $feedback_true_list = array();
     $feedback_false_list = array();
+    $question_description = array();
     // Get questions
-    $k = $z = $q = $l = 0;
+    $k = $z = $q = $l = $m = 0;
     for ($i = 1; $i <= $data->sheets[0]['numRows']; $i++) {
         if (is_array($data->sheets[0]['cells'][$i])) {
             $column_data = $data->sheets[0]['cells'][$i];
@@ -192,6 +197,9 @@ function lp_upload_quiz_action_handling() {
         } elseif (in_array($i, $feedback_false_index)) {
             $feedback_false_list[$l] = $column_data;//a complete line where 1st column is 'FeedbackFalse' for wrong answers
             $l++;
+        } elseif (in_array($i, $question_description_index)) {
+            $question_description[$m] = $column_data; //a complete line where 1st column is 'EnrichQuestion'
+            $m++;
         }
     }
 
@@ -236,12 +244,19 @@ function lp_upload_quiz_action_handling() {
             // Import questions
             for ($i = 0; $i < $number_questions; $i++) {
                 // Create questions
+
+
                 $question_title = $question[$i][2]; // Question name
+                $question_description_text = "<p></p>";
+                if (isset($question_description[$i][2])) {
+                    $question_description_text =  "<p>".$question_description[$i][2]."</p>"; // Question description, if any
+                }
+
                 // Unique answers are the only question types available for now
                 // through xls-format import
                 $unique_answer = new UniqueAnswer();
                 if ($question_title != '') {
-                    $question_id = $unique_answer->create_question($quiz_id, ($question_title));
+                    $question_id = $unique_answer->create_question($quiz_id, $question_title, $question_description_text);
                 }
                 if (is_array($new_answer[$i])) {
                     $id = 1;
@@ -258,13 +273,13 @@ function lp_upload_quiz_action_handling() {
                         } else {
                             $comment = $feedback_false_list[$i][2];
                         }
-    /*
+                        /*
                         if ($id == 1) {
                             $comment = $feedback_true_list[$i][2];
                         } elseif ($id == 2) {
                             $comment = $feedback_false_list[$i][2];
                         }
-    */
+                        */
                         // Create answer
                         $unique_answer->create_answer($id, $question_id, $answer, $comment, $score, $correct);
                         $id++;

+ 17 - 13
main/forum/forumconfig.inc.php

@@ -14,30 +14,34 @@
 /*
     Database Variables
 */
-$table_categories 		= Database :: get_course_table(TABLE_FORUM_CATEGORY);
-$table_forums 			= Database :: get_course_table(TABLE_FORUM);
-$table_threads 			= Database :: get_course_table(TABLE_FORUM_THREAD);
-$table_posts 			= Database :: get_course_table(TABLE_FORUM_POST);
-$table_mailcue			= Database :: get_course_table(TABLE_FORUM_MAIL_QUEUE);
-$table_threads_qualify  = Database :: get_course_table(TABLE_FORUM_THREAD_QUALIFY);
-$table_threads_qualify_historical  = Database :: get_course_table(TABLE_FORUM_THREAD_QUALIFY_LOG);
+$table_categories = Database :: get_course_table(TABLE_FORUM_CATEGORY);
+$table_forums = Database :: get_course_table(TABLE_FORUM);
+$table_threads = Database :: get_course_table(TABLE_FORUM_THREAD);
+$table_posts = Database :: get_course_table(TABLE_FORUM_POST);
+$table_mailcue = Database :: get_course_table(TABLE_FORUM_MAIL_QUEUE);
+$table_threads_qualify = Database :: get_course_table(
+    TABLE_FORUM_THREAD_QUALIFY
+);
+$table_threads_qualify_historical = Database :: get_course_table(
+    TABLE_FORUM_THREAD_QUALIFY_LOG
+);
 
 $forum_table_attachment = Database :: get_course_table(TABLE_FORUM_ATTACHMENT);
-$table_item_property 	= Database :: get_course_table(TABLE_ITEM_PROPERTY);
-$table_users 			= Database :: get_main_table(TABLE_MAIN_USER);
+$table_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY);
+$table_users = Database :: get_main_table(TABLE_MAIN_USER);
 
 /*
     Some configuration settings
     (these can go to the dokeos config settings afterwards)
 */
 // if this setting is true then an I-frame will be displayed when replying
-$forum_setting['show_thread_iframe_on_reply']=true;
+$forum_setting['show_thread_iframe_on_reply'] = true;
 // if this setting is true then students and teachers can check a checkbox so that they receive a mail when somebody replies to the thread
-$forum_setting['allow_post_notification']=true;
+$forum_setting['allow_post_notification'] = true;
 // when this setting is true then the course admin can post threads that are important. These posts remain on top all the time (until made unsticky)
 // these special posts are indicated with a special icon also
-$forum_setting['allow_sticky']=true;
+$forum_setting['allow_sticky'] = true;
 // when this setting is true there will be a column that displays the latest post (date and poster) of the given forum. This requires quite some sql statements that
 // might slow down the page with the fora.
 // note: I'm currently investigating how it would be possible to increase the performance of this part.
-$forum_setting['show_last_post']=false;
+$forum_setting['show_last_post'] = false;

文件差异内容过多而无法显示
+ 317 - 250
main/forum/forumfunction.inc.php


+ 13 - 17
main/forum/forumqualify.php

@@ -3,7 +3,7 @@
 
 /**
  * 	@package chamilo.forum
- *  @todo fix all this qualify files avoid including files, use classes POO jmontoya 
+ *  @todo fix all this qualify files avoid including files, use classes POO jmontoya
  */
 
 // name of the language file that needs to be included
@@ -29,7 +29,7 @@ if (isset($_GET['origin'])) {
 $user_id = isset($_GET['user_id']) ? intval($_GET['user_id']) : null;
 
 api_block_course_item_locked_by_gradebook($_GET['thread'], LINK_FORUM_THREAD);
-           
+
 $nameTools = get_lang('ToolForum');
 
 /*     Including necessary files */
@@ -48,7 +48,7 @@ $current_thread=get_thread_information($_GET['thread']); // note: this has to be
 $current_forum=get_forum_information($current_thread['forum_id']); // note: this has to be validated that it is an existing forum.
 $current_forum_category=get_forumcategory_information($current_forum['forum_category']);
 $group_id = api_get_group_id();
-        
+
 /*
     Header and Breadcrumbs
 */
@@ -96,14 +96,11 @@ if ($origin=='learnpath') {
         }
         // the last element of the breadcrumb navigation is already set in interbreadcrumb, so give empty string
         $interbreadcrumb[]=array("url" => "#","name" => get_lang('QualifyThread'));
-        Display :: display_header('');        
+        Display :: display_header('');
     }
 }
 
-
-/*
-    Is the user allowed here?
-*/
+/* Is the user allowed here? */
 // if the user is not a course administrator and the forum is hidden
 // then the user is not allowed here.
 if (!api_is_allowed_to_edit(false,true) AND ($current_forum['visibility']==0 OR $current_thread['visibility']==0)) {
@@ -113,7 +110,6 @@ if (!api_is_allowed_to_edit(false,true) AND ($current_forum['visibility']==0 OR
     }
 }
 
-
 /*
     Actions
 */
@@ -152,7 +148,7 @@ if ($message<>'PostDeletedSpecial') {// in this case the first and only post of
             //new thread link
             if (api_is_allowed_to_edit(false,true) OR ($current_forum['allow_new_threads']==1 AND isset($_user['user_id'])) OR ($current_forum['allow_new_threads']==1 AND !isset($_user['user_id']) AND $current_forum['allow_anonymous']==1)) {
                 if ($current_forum['locked'] <> 1 AND $current_forum['locked'] <> 1) {
-                    echo '&nbsp;&nbsp;';                    
+                    echo '&nbsp;&nbsp;';
                 } else {
                     echo get_lang('ForumLocked');
                 }
@@ -206,7 +202,7 @@ if ($message<>'PostDeletedSpecial') {// in this case the first and only post of
 } // if ($message<>'PostDeletedSpecial') // in this case the first and only post of the thread is removed
 
 if ($allowed_to_edit) {
-    $current_thread=get_thread_information($_GET['thread']);    
+    $current_thread=get_thread_information($_GET['thread']);
     $threadid=$current_thread['thread_id'];
     //show current qualify in my form
     $qualify=current_qualify_of_thread($threadid, api_get_session_id());
@@ -225,11 +221,11 @@ if ($allowed_to_edit) {
         $return_message = get_lang('QualificationCanNotBeGreaterThanMaxScore');
         Display :: display_error_message($return_message,false);
     }
-    
-    // show qualifications history    
-    $qualify_historic = get_historical_qualify($user_id, $threadid, $_GET['type']);    
+
+    // show qualifications history
+    $qualify_historic = get_historical_qualify($user_id, $threadid, $_GET['type']);
     $counter = count($qualify_historic);
-    
+
     $act_qualify = $_REQUEST['idtextqualify'];
     if ($counter>0) {
         if (isset($_GET['gradebook'])){
@@ -244,7 +240,7 @@ if ($allowed_to_edit) {
                         <a class="btn" href="forumqualify.php?'.api_get_cidreq().'&amp;forum='.Security::remove_XSS($_GET['forum']).'&amp;origin='.$origin.'&amp;thread='.$threadid.'&amp;user='.Security::remove_XSS($_GET['user']).'&amp;user_id='.Security::remove_XSS($_GET['user_id']).'&amp;type=false&amp;idtextqualify='.$act_qualify.$view_gradebook.'#history">'.
                     get_lang('Older').'</a>';
         }
-        
+
         $table_list.= '<br /><div class="btn-group">'.$buttons.'</div>';
         $table_list.= '<br /><table class="data_table">';
         $table_list.= '<tr>';
@@ -272,4 +268,4 @@ if ($allowed_to_edit) {
 /*         FOOTER   */
 if ($origin!='learnpath') {
     Display :: display_footer();
-}
+}

部分文件因为文件数量过多而无法显示