cfasanando 15 년 전
부모
커밋
e7599354f6
100개의 변경된 파일6325개의 추가작업 그리고 5826개의 파일을 삭제
  1. 1 0
      chamilo_license.txt
  2. 982 887
      documentation/changelog.html
  3. 63 38
      documentation/credits.html
  4. 2 2
      documentation/default.css
  5. 8 8
      documentation/dependencies.html
  6. 6 6
      documentation/index.html
  7. 3 3
      documentation/install_red5.txt
  8. 117 145
      documentation/installation_guide.html
  9. 106 116
      documentation/installation_guide_es_ES.html
  10. 2 2
      documentation/license.html
  11. 28 50
      documentation/readme.html
  12. 1 26
      dokeos_license.txt
  13. BIN
      favicon.ico
  14. 1 1
      home/home_menu.html
  15. 1 1
      home/home_news.html
  16. 0 2
      home/home_top.html
  17. BIN
      home/large_dokeos_logo.gif
  18. 166 196
      index.php
  19. 27 0
      license.txt
  20. 12 44
      main/admin/access_url_add_courses_to_url.php
  21. 12 45
      main/admin/access_url_add_sessions_to_url.php
  22. 16 54
      main/admin/access_url_add_users_to_url.php
  23. 23 44
      main/admin/access_url_edit.php
  24. 11 60
      main/admin/access_url_edit_courses_to_url.php
  25. 11 58
      main/admin/access_url_edit_sessions_to_url.php
  26. 10 64
      main/admin/access_url_edit_users_to_url.php
  27. 19 57
      main/admin/access_urls.php
  28. 21 120
      main/admin/add_courses_to_session.php
  29. 9 35
      main/admin/add_many_session_to_category.php
  30. 274 274
      main/admin/add_users_to_group.php
  31. 29 29
      main/admin/add_users_to_session.php
  32. 124 121
      main/admin/calendar.lib.php
  33. 11 23
      main/admin/calendar.php
  34. 5 22
      main/admin/calendar_view.php
  35. 3 5
      main/admin/calendar_view_print.php
  36. 3 2
      main/admin/class_list.php
  37. 4 4
      main/admin/class_user_import.php
  38. 25 54
      main/admin/configure_extensions.php
  39. 310 373
      main/admin/configure_homepage.php
  40. 313 330
      main/admin/configure_inscription.php
  41. 2 2
      main/admin/course_add.php
  42. 23 23
      main/admin/course_category.php
  43. 1 1
      main/admin/course_create_content.php
  44. 19 20
      main/admin/course_edit.php
  45. 24 24
      main/admin/course_export.php
  46. 16 16
      main/admin/course_import.php
  47. 31 38
      main/admin/course_information.php
  48. 30 37
      main/admin/course_list.php
  49. 39 85
      main/admin/course_user_import.php
  50. 1 1
      main/admin/course_virtual.php
  51. 297 0
      main/admin/dashboard_add_courses_to_user.php
  52. 295 0
      main/admin/dashboard_add_sessions_to_user.php
  53. 291 0
      main/admin/dashboard_add_users_to_user.php
  54. 18 5
      main/admin/group_add.php
  55. 24 11
      main/admin/group_edit.php
  56. 44 50
      main/admin/group_list.php
  57. 71 68
      main/admin/index.php
  58. 5 4
      main/admin/languages.php
  59. 3 3
      main/admin/ldap_import_students_to_session.php
  60. 10 10
      main/admin/ldap_synchro.php
  61. 18 34
      main/admin/legal_add.php
  62. 19 19
      main/admin/resume_session.php
  63. 4 4
      main/admin/session_add.php
  64. 4 3
      main/admin/session_category_edit.php
  65. 5 5
      main/admin/session_category_list.php
  66. 6 6
      main/admin/session_course_edit.php
  67. 6 6
      main/admin/session_course_list.php
  68. 11 13
      main/admin/session_course_user.php
  69. 10 5
      main/admin/session_course_user_list.php
  70. 6 6
      main/admin/session_edit.php
  71. 41 41
      main/admin/session_export.php
  72. 85 85
      main/admin/session_import.php
  73. 62 54
      main/admin/session_list.php
  74. 876 0
      main/admin/settings.lib.php
  75. 94 970
      main/admin/settings.php
  76. 13 13
      main/admin/special_exports.php
  77. 9 8
      main/admin/specific_fields.php
  78. 27 9
      main/admin/statistics/index.php
  79. 81 48
      main/admin/statistics/statistics.lib.php
  80. 19 21
      main/admin/style_preview.php
  81. 42 30
      main/admin/sub_language.class.php
  82. 1 0
      main/admin/sub_language.php
  83. 98 68
      main/admin/sub_language_add.php
  84. 1 1
      main/admin/sub_language_ajax.inc.php
  85. 2 2
      main/admin/subscribe_class2course.php
  86. 3 3
      main/admin/subscribe_user2class.php
  87. 3 3
      main/admin/subscribe_user2course.php
  88. 36 74
      main/admin/system_announcements.php
  89. 88 0
      main/admin/system_status.php
  90. 19 18
      main/admin/user_add.php
  91. 120 97
      main/admin/user_edit.php
  92. 6 5
      main/admin/user_export.php
  93. 14 12
      main/admin/user_fields.php
  94. 2 1
      main/admin/user_fields_add.php
  95. 10 9
      main/admin/user_fields_options.php
  96. 12 11
      main/admin/user_import.php
  97. 85 53
      main/admin/user_list.php
  98. 159 174
      main/announcements/announcements.inc.php
  99. 223 213
      main/announcements/announcements.php
  100. 2 3
      main/announcements/download.php

+ 1 - 0
chamilo_license.txt

@@ -0,0 +1 @@
+For license terms, please see the license.txt file in this same directory

+ 982 - 887
documentation/changelog.html

@@ -1,887 +1,982 @@
-<!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="en" lang="en"><head>
-  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-
-  <title>Dokeos Changelog</title><link rel="stylesheet" href="default.css" type="text/css" media="screen,projection" />
-  <link rel="shortcut icon" href="./favicon.ico" type="image/x-icon" />
-  <style type="text/css">
-	<!--
-		@page { size: 21cm 29.7cm; margin: 2cm }
-		pre { font-family: "Courier New", monospace }
-		p { margin-bottom: 0.21cm }
-		.code {margin: 1em 1em 1em 2em; padding: 0.5em; background-color: rgb(229, 229, 229); vertical-align: top; border: 1px solid #999999;}
-	--></style></head>
-
-<body>
-<div id="header1">
-<h1>Dokeos&nbsp;Changelog</h1>
-</div>
-<a href="index.html">Documentation</a> &gt; Changelog
-<div id="outerframe">
-<div id="main">
-<h1>Dokeos 1.8.6.2 - .............</h1>
-<h3>Release notes - summary</h3>
-<h3>New Features</h3> 
-<ul>
-  <li>Implemented by-session content creation tools updates</li>
-  <li>Added tabs editor (from admin)</li>
-  <li>Added courses catalog</li>
-  <li>Added a link to export course in the (platform administrator -> course list) (DT#4257)</li> 
-  <li>Added sessions history (optional access to previous sessions in read-only for students)</li>
-  <li>Added advanced search  in sessions: you can also search by session name, session category, tutor and visibility. (DT#5541)</li>
-  <li>Added an option to configure courses as "auto-registered" (every user has it in his courses list and is automatically subscribed)</li>
-  <li>Added chat tool to the groups(DT#3318)</li>
-  <li>Allowed password to be recovered using username *or* e-mail</li>
-  <li>Added editable section to the registration form</li>
-  <li>Reporting: notification of user who have never been active yet</li>
-  <li>Reporting: the additional user profiles (defined by the platform administrator through platform administration > profiling) can now be displayed also. </li>
-  <li>Subscribing users in a course: you can also filter on a certain addtional user profile field or search inside the values of the additional user profiles fields when subscribing a user in a course (through user/subscribe_user.php) </li>
-  <li>Added Send a email to a portal administrator upon course creation (DT#3489)</li>
-  <li>Added Chat tool is now private when are in sessions or groups (DT#5558)</li>
-  <li>Wiki: Posibility to definition of wiki pages as tasks for students. Add feedback to student wiki pages, sincronized with their progress in the task. Posibility to establish a time limit for each wiki page. Posibility to establish a max number of words into each wiki page. Posibility to establish a max number versions for each page. Improve control of concurrent users. Improvements in the use of wiki pages such as portfolios of student (individual task)</li>
-  <li>Added when a user is enrolled only in one course, go directly to the course after the login (defined by the platform administrator through platform administration > configuration setting > training)- DT#3466</li>
-  <li>Added user' photo into user list interface - DT#5496</li>
-  <li>Disabled field trainers(tutor name) in create course form from user portal, by default is current user's name, you can modify this field into setting course - DT#5496 </li>
-  <li>Added option to export the trainings list to CSV file in Administration>Trainings - DT#4256</li>
-  <li>Gradebook automatic deleted bug of a link fixed DT#5229</li>
-  <li>User tags added DT#5508</li>
-  <li>Who is online look revamped DT#5490</li>
-  <li>New search tool added DT#5610 </li>	
-  <li>User groups added  DT#5611 </li>  
-  <li>Social network tab added</li>
-  <li>Easy construction of presentations with the images of document tool</li>
-
-  <li>Performance improvement when getting a list of users (for instance in the dropbox when sending a new document)</li>
-  <li>Platform setting (in User category) that determines how the users should be sorted: by first name or by last name</li>
-</ul>
-<h3>Debugging</h3>
-<ul>
-  <li>Online editor: A upgrade from FCKEditor 2.6.4.1 to <strong>FCKEditor 2.6.5, Build 23959</strong> has been implemented. (#2867)</li>
-  <li>Fixed a bug in course homepage always showing a box even when no tools were shown (r8747:3ad59f6aed1f)</li>
-  <li>Score result in reporting is expressed as a percentage</li>
-  <li>CSV export of reporting no longer contains html code in the last column</li>
-  <li>The course list is now sorted like you have defined on the course management page</li>
-</ul>
-<br />
-<h3>CSS changes</h3>
-<ul>
-  <li>No major change, no old styles update required</li>
-</ul>
-<h3>Known issues</h3>
-<ul>
-  <li>In Hotspot under Windows® (server-side), uploading a PNG file results in an unstable exercise</li>
-</ul>
-<h3>Deprecated files</h3>
-<ul>
-  <li>No important file removed, no change required</li>
-</ul>
-<br />
-<h1>Dokeos 1.8.6.1 - August 2009</h1>
-<h3>Release notes - summary</h3>
-<p>Dokeos 1.8.6.1 is a minor&nbsp;release including just a few new features, mostly focused on internationalization, and several bugfixes.</p>
-<h3>New Features</h3>
-<ul>
-  <li>Implemented new sub-language feature by which language terms redefinition becomes possible through the admin section (FS#4321)</li>
-  <li>Admin: Terms and conditions added DT#4320</li>
-  <li>Improvements in document tool, allow seeing glossary terms (FS#4337)</li>
-  <li>Small improvements in SCORM export(FS#4300)</li>
-  <li>At the beginning of the installation script, added an imperative check for PHP 5 has been added. (FS#4296)</li>
-  <li>When the system Dokeos is switched into "Test server" mode, a clickable indicator appears in the footer. This indicator is visible by platform administrators only. (FS#4341)</li>
-  <li>A transliteration function has been added. Currently, it is used in uploading files. Files with non-English names get names that contain ASCII letters only, remaining readable in the corresponding language. Rationale: The PHP5 run-time environment does not manage file name encodings, adding such a non-native feature involves too much work. For avoiding character encoding problems, transliteration of file names is the possible solution. (FS#306)</li>
-  <li>An internationalization option has been added for improving sorting in arbitrary language. When the <a href="http://php.net/manual/en/book.intl.php" target="_blank">intl</a> php-extension has been installed, various sorting routines exploit it for better sorting. Rationale: The PHP5 run-time environment does not provide native and reliable way of sorting UTF-8 strings. (FS#306)</li>
-  <li>Installation script: The page about system requilements has been updated. Also, at the very beginning, a check has been added whether the <a href="http://php.net/manual/en/book.mbstring.php" target="_blank">mbstring</a> php-extension is installed - see <a href="http://dokeos.com/forum/viewtopic.php?t=29548" target="_blank">the related forum topic</a>. (FS#306)</li>
-  <li>A new php-based configuration for the online editor has been implemented, see <i>dokeos/main/inc/lib/fckeditor/myconfig.php</i>. Also, toolbar definitions have been split in separate php-files within the directory <i>dokeos/main/inc/lib/fckeditor/toolbars/</i> . Customization of the editor is more convenient and flexible now. (FS#2867)</li>
-  <li>Online editor: A upgrade from FCKEditor 2.6.4 to <strong>FCKEditor 2.6.4.1</strong> has been implemented. (FS#4383)</li>
-  <li>Online editor: Blocking copy/paste for trainees has been added. The feature is configurable through editing the toolbar definition files within the directory <i>dokeos/main/inc/lib/fckeditor/toolbars/</i> . (FS#2867)</li>
-  <li>Online editor: Preview tabs have been added to the dialogs for inserting video, flv-video, and YouTube video. (FS#2867)</li>
-  <li>Online editor: The <strong>audio</strong> plugin has been activated by default as an implementation of the "Insert audio / Audio properties" dialog. This new plugin is intended to replace the "MP3" plugin. (FS#2867)</li>
-  <li>Online editor: The simple file manager, the advanced file manager and the image manager have been integrated by default with the editor's dialog system. Thus, they work faster and in a more secure way. (FS#2867)</li>
-  <li>Online editor: Configuration of the <strong>mimetex</strong> plugin has been reworked to gain simplicity. The procedure for configuration has been updated, see <a href="http://www.dokeos.com/forum/viewtopic.php?t=29594" target="_blank">the related forum topic</a>. (FS#2867)</li>
-  <li>Online editor: A new <strong>asciimath</strong> plugin for inserting mathematical formulas has been added. It is based on the <a href="http://mathcs.chapman.edu/~jipsen/mathml/asciimath.html" target="_blank">ASCIIMathML.js</a> library. (FS#2867)</li>
-  <li>Social: Added possibility to define RSS feeds inside personal page of social network (need to define an 'rssfeeds' extra user text field)</li>
-</ul>
-<h3>Debugging</h3>
-<ul>
-  <li>Online editor: Several known bug-fixes from FCKEditor 2.6.5 SVN have been implemented, tickets <a href="http://dev.fckeditor.net/ticket/1537" target="_blank">#1537</a>, <a href="http://dev.fckeditor.net/ticket/2156" target="_blank">#2156</a>, <a href="http://dev.fckeditor.net/ticket/2689" target="_blank">#2689</a>, <a href="http://dev.fckeditor.net/ticket/2821" target="_blank">#2821</a>, <a href="http://dev.fckeditor.net/ticket/2856" target="_blank">#2856</a>, <a href="http://dev.fckeditor.net/ticket/2874" target="_blank">#2874</a>, <a href="http://dev.fckeditor.net/ticket/2915" target="_blank">#2915</a>, <a href="http://dev.fckeditor.net/ticket/3120" target="_blank">#3120</a>, <a href="http://dev.fckeditor.net/ticket/3181" target="_blank">#3181</a>, <a href="http://dev.fckeditor.net/ticket/3427" target="_blank">#3427</a>, <a href="http://dev.fckeditor.net/ticket/3429" target="_blank">#3429</a>, <a href="http://dev.fckeditor.net/ticket/3439" target="_blank">#3439</a>, <a href="http://dev.fckeditor.net/ticket/3446" target="_blank">#3446</a>, <a href="http://dev.fckeditor.net/ticket/3481" target="_blank">#3481</a>, <a href="http://dev.fckeditor.net/ticket/3677" target="_blank">#3677</a>, <a href="http://dev.fckeditor.net/ticket/3818" target="_blank">#3818</a>, <a href="http://dev.fckeditor.net/ticket/3880" target="_blank">#3880</a>, <a href="http://dev.fckeditor.net/ticket/3925" target="_blank">#3925</a>. (FS#2867)</li>
-  <li>Online editor: The toolbar icons have been upgraded to those from FCKEditor 3.0. (FS#2867)</li>
-  <li>A solution has been implemented for fixing the <a href="http://bugs.adobe.com/jira/browse/FP-529" target="_blank">"__flash__removeCallback" bug</a>, which affects the media player on Internet Explorer browser. (FS#4378 and FS#2867)</li>
-  <li>Quiz: fixed bug in multiple-choice/single-answer questions results (whereby the wrong answer was saved)</li>
-  <li>Admin: Added courses from sessions inside AJAX popup of courses list in users list (SVN#22398)</li>
-  <li>Admin: Showing full-length course titles in list of courses while adding to sessions(SVN#22399)</li>
-  <li>Admin: Added session name in title of session edition pages(SVN#22400)</li>
-</ul>
-<br />
-<h3>CSS changes</h3>
-<ul>
-  <li>Sticky footer now available in all Dokeos stylesheets. If you own a custom stylesheet you will need to update it, see <a href="https://bts.dokeos.com/issues/show/3549">DT#3549</a> for further details.</li>
-</ul>
-
-<br />
-<h3>Known issues</h3>
-<br />
-<h3>Deprecated files</h3>
-<ul>
-  <li>The whole main/inc/lib/fckeditor/editor/filemanager/browser/default/connectors/ directory should be removed for security reasons</li>
-</ul>
-<br />
-<h1>Dokeos 1.8.6 <span style="font-style: italic;">Svalbard</span> - June 2009</h1>
-<h3>Release notes - summary</h3>
-<p>Dokeos 1.8.6 Svalbard is a major&nbsp;release including new features.&nbsp;</p>
-<h3>New Features</h3>
-<ul>
-  <li>FCKEditor 2.6.4, build 21629 added (FS#2528 and FS#2867)</li>
-  <li>Improvements to the profiling tool (previously called "User fields") to improve presentation and flexibility, and allow edition</li>
-  <li>Added new authorized charsets for learning path tool</li>
-  <li>Official code available in My Reporting (FS#2640)</li>
-  <li>Added possibility to switch fill-in-the-blanks answers (FS#2683)</li>
-  <li>Now hiding database password field with *** in install/upgrade procedure (FS#2680)</li>
-  <li>Added attempts limit to tests</li>
-  <li>Hide language form if only one language available</li>
-  <li>Added possibility for the course teacher and tutor to delete quiz attempts by users</li>
-  <li>Added possibility for session coaches to register external users directly to their session (FS#2700)</li>
-  <li>Added possibility to allow coach to access a defined number of days before and after a session (FS#2724)</li>
-  <li>Activates unique (ajax) and multiple (multiple select) inscriptions for courses and users in sessions (FS#2719)</li>
-  <li>Handling of sessions in tools has been improved : for example we can't see anymore an annoucment of another session (FS#2743)</li>
-  <li>Tests : In students results page, set the question comment in red when the student's answer is wrong. Set in green when the answer id good</li>
-  <li>New audio recorder in learning path</li>
-  <li>New mp3 player (FS#2977)</li>
-  <li>New Glossary tool (FS#3248)</li>
-  <li>Integrated the gradebook at course level (FS#3173)</li>
-  <li>New wiki tool (considerably improved, built on CoolWiki plugin) (FS#2873)</li>
-  <li>Remove possibility to delete system directories in documents tool (FS#1522)</li>
-  <li>Database server: no more need for special SQL modes for MySQL 5.0 to be turned off through the "sql_mode" setting. The Dokeos system does it internally (FS#2787)</li>
-  <li>Some low-level functions that intensively use the language translation sub-system have been optimized for speed (FS#3260)</li>
-  <li>Documents tool: The document-type icons have been made clickable (FS#3296)</li>
-  <li>Documents tool: Online editor has been disabled for HotPotatoes tests in order their functionality to be preserved (FS#3345)</li>
-  <li>Allow ZIP export of assignments for teacher and tutor </li>
-  <li>Added attach documents to Agenda</li>
-  <li>Added Web Services Interface (SOAP)</li>
-  <li>Added Google Maps support</li>
-  <li>Added Imagemap editor</li>
-  <li>Online editor: Inserting links to YouTube streaming service has been added (FS#2867)</li>
-  <li>Improved chat (open in new window option, smileys, teacher/learner difference and time indication for each message, user picture showing directly, possibility to hold several conversations in several courses at the same time)</li>
-  <li>Option to hide/show e-mail addresses to all users (FS#3244)</li>
-  <li>Added an introduction section for each group area (FS#3200)</li>
-  <li>New Global Agenda (FS#3391)</li>
-  <li>New Notebook tool in courses</li>
-  <li>Added reporting on the last connections of a user in the chat</li>
-  <li>Added link create course message to go directly to the course(SVN#17497)</li>
-  <li>Added ability to take partial surveys and finish them later (FS#2510)</li>
-  <li>New Survey Feature: Surveys without invitation mail (FS#3403)</li>
-  <li>Added Booking system (a.k.a Reservation 2 Extension) (FS#821)</li>
-  <li>Added user profiling fields in auto-registration page (FS#2666)</li>
-  <li>Added check for writeable status of session save path in installation directory (FS#2970)</li>
-  <li>Allow forum threads to be moved (FS#3460)</li>
-  <li>Minor - Added update information for quizzes (FS#3417)</li>
-  <li>Sending e-mails to all admin on user account creation confirmation (FS#3475)</li>
-  <li>Changed user profile setting defaults to make phone field disabled and picture enabled (FS#3474)</li>
-  <li>Added intermediary buttons in platform settings pages to avoid scrolling too much to apply atomic changes (FS#3473)</li>
-  <li>Simplify default platform language choice by adding quick icon (FS#3472)</li>
-  <li>Session admins can now add users to the portal (FS#3476)</li>
-  <li>Added Advanced File Manager (FCKEditor plugin) to improve flexibility in files upload (FS#2970)</li>
-  <li>Added New Message Tool (a.k.a Message 2 Plugin) (FS#3503)</li>
-  <li>Added Question difficulty level in Exercises (FS#3515)</li>
-  <li>Added Removed buggy audio recorder and added new MP3 player with easy upload (FS#3515)</li>
-  <li>Improved Survey export (SVN#17927)</li>
-  <li>Students can now view their uploaded works in Work tool (FS#3486)</li>
-  <li>Implemented
-add to calendar an assignment with the date when it is completely
-closed, also when you remove it from assignment tool, it's removed into
-calendar too, the same case when it's edited, for that I had to change
-the value of add_calendar field into student_publication_assignment
-table, now when it's sent to calendar this value is the id into
-calendar_event table, instead this value is 0.</li>
-  <li>Added Social tool + friend list (FS#3383)</li>
-  <li>Added introduction section to blog and course description (FS#3165)</li>
-  <li>Added import/export (CSV/XML) of extra user fields</li>
-  <li>Added ability to import users in XML and subscribe to visual code (FS#3552)</li>
-  <li>Added pChart v1.1.2 library to manage charts in Gradebook tool(FS#3718) and the Access details of a user </li>
-  <li>Added SHA1 as a possibility to encrypt user passwords (FS#3798)</li>
-  <li>Added global templates to use between courses (SVN#18955)</li>
-  <li>Added To change your password, you must enter your current password (SVN#19225)</li>
-  <li>Added New Dokeos stylesheets </li>
-  <li>Improvements to the User profile</li>
-  <li>Improvements to the Learning path display view (no more frames)</li>
-  <li>Added HTML Purifier</li>
-  <li>Added tracking/logging of admin activity FS#842</li>
-</ul>
-<br />
-<h3>Debugging</h3>
-<ul>
-  <li>Improved security in exercises module</li>
-  <li>Fixed issue in dropbox documents zipping feature - see <a href="http://www.dokeos.com/forum/viewtopic.php?t=13345">related forum post</a></li>
-  <li>Increased size of php_session data field to allow for reasonable-sized session to be kept in the database (FS#2657)</li>
-  <li>Fixed a few issues in mailing and codes for survey tool (FS#2662)</li>
-  <li>Considerably improved migration of SCORM learning paths from Dokeos 1.6.x to 1.8.x</li>
-  <li>Added student-view link for platform admin</li>
-  <li>Fixed bug about last access reporting in dropbox tool (FS#2458)</li>
-  <li>Saving survey invitation's mail subject (FS#2662)</li>
-  <li>Various improvements in clone cleanliness - avoiding many notice-level error reports</li>
-  <li>Fixed user picture problems in admin pages</li>
-  <li>Mysql error fixed in Reporting in a single DB installation (FS#2638)</li>
-  <li>Fixed phone number field missing during registration (FS#2639)</li>
-  <li>Fixed breadcrumb in portal administration (FS#2642)</li>
-  <li>Fixed issues in FCKeditor edition of documents with video, flash and mp3 included (FS#2679)</li>
-  <li>Fixed security issue affecting Windows servers with system file inclusion on homepage (FS#2692)</li>
-  <li>Fixed one-question-per-page view in Quiz tool (FS#2678)</li>
-  <li>Removed possible risk of having a database code too large for the course.db_name field (FS#2426)</li>
-  <li>Added missing online help for blogs (FS#811)</li>
-  <li>Fixed bug showing whole article as link in blog (FS#811)</li>
-  <li>Fixed bug whereby the course permissions were not updated when using the multiple-action mode in course users list</li>
-  <li>Fixed bug preventing opening of a learning path item following a failed prerequisite condition (SVN#15853)</li>
-  <li>Fixed bug preventing the activation of plugins (FS#2771)</li>
-  <li>Fixed bug adding double comments in dropbox tool in IE only (FS#2757)</li>
-  <li>Fixed IMS/QTI2 little export problem (FS#2634)</li>
-  <li>The learners can't send files anymore to other learners if "Do not allow
-students to send documents to other students within a course" is false
-(FS#2780)</li>
-  <li>The mails sent in exercises tool are sent from the address defined in admin (FS#2712)</li>
-  <li>"Next" and "Previous" page now works when searching a session (FS#2721)</li>
-  <li>Fixed bug when launching a quiz with one question per page (FS#2738)</li>
-  <li>Fixed javascript bug with swap menu in ie6 (FS#2815)</li>
-  <li>Fixed bug in surveys when we want to display answers of an invited person (FS#2731)</li>
-  <li>Fixed
-bug when copying a course with surveys. There is now a check for
-existing surveys with the same code and language (FS#2734)</li>
-  <li>Fixed bug when seeing matching results in quiz tool (SVN#15987)</li>
-  <li>Added filtering of SCORM objectives when writing to DB (SVN#16437)</li>
-  <li>Removed duplication of database write operations for SCORM objectives (SVN#16438)</li>
-  <li>Fixed HTTP_REFERER bug in ical_export (FS#3041)</li>
-  <li>Fixed bug in SQL queries for new installs, preventing the creation of the course_module table (FS#3040)</li>
-  <li>Fixed
-the fact that the password was never sent by e-mail when encrypted,
-even when it had just been changed for a user, causing a useless e-mail
-to be sent (SVN#16673)</li>
-  <li>Fixed bug in users pictures display when using the tuning setting of splitting users dirs (SVN#16673)</li>
-  <li>Fixed bug in documents picture gallery preventing uppercase image extensions to be seen (SVN#16755)</li>
-  <li>Fixed bug whereby the repeated agenda items in groups were visible to all (FS#3095)</li>
-  <li>Fixed bug whereby e-mails sent did not have the standard syntax (SVN#16708)</li>
-  <li>Fixed bug whereby an empty institution name gave a useless output in the header (SVN#16710)</li>
-  <li>Fixed bug whereby questions ordering was broken when deleting one question in the middle (SVN#16879)</li>
-  <li>Fixed
-bug in user fields, not displayed the default value in profile and add
-user, and you could modify this values(see FS#3307) </li><li>Fixed bug in link (see FS#3306)</li>
-  <li>Improved display of human resource manager option (see FS#3304)</li>
-  <li>Documents tool, folder selector: Fixed a bug that prevented Home (root) folder to be shown (FS#3089)</li>
-  <li>Users tool: Fixed a bug preventing detailed information about a user to be shown or edited (FS#3009)</li>
-  <li>Fixed a bug causing various problems due to improper priority order of loading PEAR packages (FS#3237)</li>
-  <li>The
-PclZip library has been upgraded to version 2.6. Additionally, a known
-bug has been fixed - improper processing of the option
-PCLZIP_OPT_REMOVE_PATH on Windows (FS#3243)</li>
-  <li>Fixed a bug causing improper numeric sorting of data displayed in various tables (FS#3282)</li>
-  <li>Agenda tool: Fixed a wrong range for hour selection. The bug has been reported and solved in a forum by TL (FS#3324)</li>
-  <li>Agenda tool: style changes - Align drop-down lists in date and time when you add a new calendar event and modify it</li>
-  <li>Fixed Date Validation  when you add a new exercises and modify it (FS#3249)</li>
-  <li>Tests tool: Fixed broken filter on orphan questions in questions pool, reported and solved in the forums by mark111 (FS#3329)</li>
-  <li>Fixed security flaw allowing anonymous user to enter "open to the platform" courses (FS#3359 - SVN#17499)</li>
-  <li>Fixed forum visibility bug for private groups forum (FS#3327)</li>
-  <li>Fixed many links bugs when using a forum inside a learning path (FS#3256)</li>
-  <li>Fixed: dropbox changed notification icon appears while dropbox inaccessable (FS#3395)</li>
-  <li>Fixed: access to a hidden document was possible (FS#2835)</li>
-  <li>Dropbox fix: move multiple selected files to category feature is back. (FS#3005)</li>
-  <li>Fixed: Long lines in Announcements did not show up in email (FS#2988)</li>
-  <li>Fixed: the productions users aren't saved in the the correct directory (FS#3456)</li>
-  <li>Fixed error in install/htaccess.dist whereby the url-append was not set correctly (SVN#17791)</li>
-  <li>Fixed missing check on cDir in local.inc.php (SVN#17793)</li>
-  <li>Removed possibility to create sub-directories in the dropbox tool - wasn't working anyway for various versions (FS#3434)</li>
-  <li>Improved access control for group tool (FS#3209)</li>
-  <li>Fixed profiling date field popup bug (FS#2985)</li>
-  <li>Added check on max members in group before subscribing new people (FS#3453)</li>
-  <li>Changed usage of mail functions to use api_mail() everywhere and fix mail headers problems (FS#2445)</li>
-  <li>Fixed bug changing the language to false in platform settings (FS#3472)</li>
-  <li>Fixed various HTTPS + IE related bugs, related to caching in general (SVN#17795)</li>
-  <li>Fixed 31 bugs in file/image/sounds/flash uploads/delete/permissions in profile/homepage/agenda edition pages</li>
-  <li>Fixed a bug in migration for several versions at once whereby new course tools were repeated several times (SVN#17935)</li>
-  <li>Fixed security issue allowing users to upload php files on the server through FCKEditor (FS#2970)</li>
-  <li>Fixed folders by default into document tool must not be removed - see FS#3611</li>
-  <li>Fixed qualification of themes into forum tool - see FS#3609</li>
-  <li>allow show results with floating point,in exercice tool - (partial FS#3630) - SVN#18367</li>
-  <li>Fixed event into agenda when it's sent from assignment and Improved display form when you create an assignment - see FS#3583</li>
-  <li>Fixed difficulty of the question lost - see FS#3659</li>
-  <li>Fixed XML user import for single courses import (related to FS#3552)</li>
-  <li>Fixed bug with user image not showing in upgrade from previous versions</li>
-  <li>Fixed bugs causing wrong attempts to translate some icons on course homepage when the server is in testing mode (FS#3285)</li>
-  <li>A
-fix for the Oogie converter to work on Windows OS has been applied.
-Initial code has been proposed in the Dokeos forums by Øyvind Johansen
-(oyvind) and wilbrod - see FS#3969</li>
-  <li>Fixed Windows-related
-bugs preventing creation of SCORM packages from presentations, see
-FS#3972. The problem has been reported in the Dokeos forums by
-irvienhooi</li>
-  <li>Some minor bugs have been fixed in "Document Metadata" form (FS#4030)</li>
-  <li>Fixed a bug preventing updating dates of group documents after edition. Many thanks to Ludwig Theunis, nickname: TL (FS#4072)</li>
-</ul>
-<br />
-<h3>CSS changes</h3>
-<ul>
-  <li>Added classes glossary-term, glossary-term-title, glossary-term-desc, glossary-term-action-links for the glossary tool</li>
-  <li>Added personal-notes tool-related styles</li>
-  <li>Changed many things in the public-admin style (Dokeos default) to improve
-design - will probably affect other styles a little despite efforts not to</li>
-  <li>Added new styles</li>
-
-</ul>
-<br />
-<h3>Important language changes</h3>
-<ul>
-  <li>Changed "courses" to "trainings" in English and "Cours" to
-"Formations" in French. This change is likely to be very confusing to
-most users! Please either update your language files or warn your users
-if you are willing to keep that change.</li>
-  <li>Changed "Learning Path" link to "Course" in English and French</li>
-  <li>Changed and unified work/assignment/student publications tool as "assignments"</li>
-  <li>Changed "Dropbox" tool to "Documents sharing" (or "Documents sharing space" when referring to one's own space in the tool)</li>
-  <li>Changed "Student View" link to "Teacher view" and vice-versa</li>
-  <li>Many buttons now have more defined action names</li>
-</ul>
-<br />
-<h3>Known issues</h3>
-<ul>
-  <li>Inserting the same exercise twice in one learning path may generate score inconsistencies</li>
-</ul>
-<br />
-<h3>Deprecated files</h3>
-<ul>
-  <li>The whole main/inc/lib/xajax/tests/ should be removed</li>
-</ul>
-<br />
-<h1>Dokeos 1.8.5 <span style="font-style: italic;">Valparaiso</span>, June 2008</h1>
-<h3>Release notes - summary</h3>
-<p>Dokeos 1.8.5 is a major debugging release but includes interesting new features as well.&nbsp;</p>
-<h3>New Features</h3>
-
-<ul>
-	<li>Considerable security improvements - 2 major and 1 minor security patches have been applied since the latest stable version</li>
-	<li>SCORM
-export improvement (now generates SCORM 1.2 compliant packages and
-transforms Dokeos quizzes into SCO items, using interactions as a bonus)</li>
-	<li>Possibility to filter extension of submitted files all around Dokeos</li>
-	<li>OpenID authentication support</li>
-	<li>Possibility to import Word documents</li>
-	<li>Possibility to import docx and pptx documents (new MS-Office format)</li>
-	<li>Grades,
-evaluations and success certificates available thanks to the
-integration of the gradebook extension. Activating this module will
-clash with a gradebook extension installation made previously</li>
-	<li>Coloured icons added to courses list in administration panel to show access permissions</li>
-	<li>Logout button now shows the username of the current user</li>
-	<li>Student view re-activated and fully-functional</li>
-	<li>Searching
-the forum is now possible so you can use the forum as a knowledge base.
-The search results are highlighted throughout the forum and you can
-search on multiple words also. </li>
-    <li>Group members are now displayed in a sortable table</li>
-	<li>Possibility to export survey results in XLS format</li>
-	<li>Documents, Works and Dropbox tools usability has been improved in many ways</li>
-    <li>In the agenda, you can display the X upcoming events (can be configured by the platform admin)</li>
-    <li>The course agenda now has a month view like the my agenda</li>
-    <li>In
-the user list of the platform administration you can now quickly see
-for what courses the user is subscribed by hovering over the courses
-icon</li>
-    <li>The platform system announcements can now be sent through email also</li>
-	<li>User
-fields have been added globally, allowing you to add user data like
-birthdate, mother tongue, city or whatever data you want to ask your
-users</li>
-	<li>LDAP
-		<ul>
-			<li>The LDAP code has changed. If you had some customisations there, you might want to save them and re-apply them after the upgrade</li>
-			<li>Functions renamed to respect coding conventions and use ldap_ namespace</li>
-			<li>Most
-parameters moved to the administration panel. You will need to
-configure the administration panel with the settings that were
-previously in ldap_var.inc.php</li>
-			<li>Added non-anonymous mode (just add a login and a password in the configuration panel)</li>
-			<li>Added search domain configuration through panel</li>
-			<li>Added customizable field-check for student-teacher switch</li>
-			<li>The installation guide has been updated to help you find your way through the new LDAP configuration panel</li>
-			<li>You still need to activate LDAP by uncommenting two lines in configuration.php</li>
-	    </ul>
-	</li>
-    <li>New stylesheets can be added through the platform administration interface</li>
-    <li>Notification
-by email has been improved in the forum. You can now indicate that you
-want to be informed of messages on the forum level or on the thread
-level, even if you did not participate in the discussion yet. </li>
-    <li>The
-platform administrator can decide to display the courses that are not
-open on the login page. When these courses are displayed on the campus
-startpage then the user that is logged in can quickly subscribe to this
-course.</li>
-    <li>When creating a new group you can decide to create
-a public or private forum or no forum at all. These are group category
-settings.</li>
-    <li>Group forum is also displayed in the group space</li>
-    <li>Surveys that are not based on invitation but open to all (or certain) members of the course are now available</li>
-    <li>Agenda
-    	<ul>
-    		<li>iCal import and export of course events, with a choice of public, private or confidential markers</li>
-    		<li>Repetitive
-course events can be created (and exported to iCal). Repetitions types
-supported are: daily, weekly, monthly by date (e.g. the 5th of each
-month) and yearly by date</li>
-   		</ul>
-	</li>
-	<li>Document templates have been greatly improved to speed-up custom course content creation</li>
-	<li>Audiorecorder
-(depending on streaming server) now records sounds in the
-document/audio directory, making them easily reusable by the course
-admin</li>
-	<li>Audiorecorder is not loaded by default (took too long) and you can load it with a simple click</li>
-	<li>W3C - Compliance with XHTML 1.0 Transitional has been improved</li>
-	<li>Tracking - A new page to display access details by user is available under the Reporting tab, in the user details in a course</li>
-	<li>Removed header from learning path tool. It was taking too much space and was not flexible enough for CSS styling</li>
-	<li>Improved speed of 1.6 to 1.8 migration by adding indexes</li>
-    </ul>
-<br />
-<h3>Debugging</h3>
-<ul>
-	<li>Prerequisites management in learning paths fixed (includes quizzes, hotpotatoes and SCORM)</li>
-	<li>Various minor bugs fixed in the learning path tool (scoring, copy, re-ordering)</li>
-	<li>Various minor bugs fixed in the session handling</li>
-	<li>Fixes to the survey tool (date management, questions order in export)</li>
-	<li>Fixes to the calendar tool (access by students)</li>
-	<li>Fixes to the announcement tool (access by students)</li>
-	<li>Fixes to the group tool (default group settings)</li>
-	<li>Bugfix: complete export in survey tool displayed the question of all the surveys and not only those of the selected survey</li>
-    <li>Bugfix:
-registering a new user resulted in the language field of the user being
-empty which resulted in an english profile by default. This has now
-been changed to the platform language. </li>
-    <li>Performance improvement in the user list of the platform administration </li>
-	<li>Bugfix: group tutors were not migrated from 1.6 to 1.8</li>
-	<li>SCORM export: fixes in export method</li>
-	<li>Documentation is now fully XHTML 1.0 Transitional compliant</li>
-	<li>Fix FCKeditor Flash upload lack of usability and problems with IE</li>
-</ul>
-<br />
-<h3>Known issues</h3>
-<ul>
-    <li>Audiorecorder takes a few seconds to write the audio file
-back to the document directory, so the page shouldn't be changed too
-quickly after recording a sound track</li>
-    <li>When migrating from 1.6 to 1.8, some SCORM learning paths might need to be re-imported, which means their tracking is lost</li>
-</ul>
-<hr style="width: 100%; height: 2px;" />
-
-<h1>Dokeos 1.8.4 - September 2007</h1>
-<h3>Release notes - summary</h3>
-<p>Dokeos
-1.8.4 is both a features and debuggingmajor release.&nbsp;</p>
-<h3>New Features</h3>
-<ul>
-  <li>Templates. See <a href="http://www.dokeos.com/templates.php">http://www.dokeos.com/templates.php</a></li>
-  <li>Wide Hotspots tests to allow real-life situations simulation</li>
-
-  <li>Flash video import and streaming</li>
-
-  <li>Installation guide renewed. See&nbsp;<a href="http://www.dokeos.com/doc/installation_guide.html">http://www.dokeos.com/doc/installation_guide.html</a></li>
-
-  <li>Added animated Mr Dokeos character : <a href="http://www.dokeos.com/mrdokeos.php">http://www.dokeos.com/mrdokeos.php</a></li>
-
-  <li>English and Dutch teacher manual added</li>
-
-  <li>Assignments form now fills automatically with document title and user name</li>
-
-  <li>Document authoring space now bigger</li>
-
-  <li>IMS/QTI export of tests</li>
-  <li>Export of media (images, Flash, Audio) and tests in SCORM export</li>
-  <li>Agenda default time management for an event improved</li>
-  <li>Oogie PowerPoint converter setup simplified</li>
-  <li>Improved support for other character sets (enabling better support for
-UTF-8 and russian and asian fonts)</li>
-
-</ul>
-
-<br />
-
-<h3>Debugging</h3>
-
-<ul>
-
-  <li>Upgrade script improved : now possible to upgrade direct from 1.6 to 1.8.4.&nbsp;</li>
-  <li>Blogs user rights</li>
-
-  <li>FCK Editor image import</li>
-
-  <li>Videoconferencing slides now include Documents directory of course</li>
-
-  <li>SCORM content can be displayed Full Screen</li>
-
-  <li>SCORM interactions now properly running</li>
-
-  <li>Hotspots tests redesigned and bigger hotspots zone</li>
-
-  <li>Alphabetical sorting of lists fixed</li>
-
-  <li>Excel export in reporting now removes HTML tags</li>
-
-  <li>My profile page display layout</li>
-
-  <li>Import HotPotatoes tests scoring</li>
-
-  <li>Images gallery in Documents bad display</li>
-
-  <li>Agenda default date now more relevant</li>
-
-  <li>Tests random questions order option clarified</li>
-
-  <li>Templates editing and media removal now easier</li>
-
-  <li>Apostrophe bug in Learning path Build mode</li>
-
-  <li>Table of contents wider in Learning path</li>
-
-  <li>Audio player now autostarts</li>
-
-  <li>Spelling mistakes in French and English</li>
-
-  <li>Group features now related to group, not generic</li>
-
-  <li>Blogs SQL errors fixed</li>
-
-  <li>Introduction images were missing in tests reporting</li>
-
-  <li>SCORM export now working</li>
-
-  <li>My agenda Personal events editor bug fixed</li>
-  <li>Oogie PowerPoint import installation easier</li>
-  <li>Time spent on platform tracking improved</li>
-  <li>Course Backup/restore bugs fixed</li>
-  <li>Course copy bugs fixed</li>
-  <li>Default visibility status of learning paths fixed</li>
-  <li>Images gallery display reordering</li>
-  <li>Agenda default time management for an event improved</li>
-  <li>Groups display alphabetical sorting fixed</li>
-
-</ul>
-
-<h1></h1>
-
-<hr style="width: 100%; height: 2px;" />
-<h1>Dokeos 1.8 - May 2007</h1>
-
-
-
-<h3>Release notes - summary</h3>
-
-
-
-<p>Dokeos 1.8 is a major release. The software becomes a complete suite
-including not only a learning management system and a learners
-administration dashboard, but also an easy-to-use authoring system and
-a simple videoconferencing interface.</p>
-
-
-
-<h3>New Features</h3>
-
-
-
-<ul>
-
-
-      <li> Ms-PowerPoint® to Learning Path conversion</li>
-
-
-      <li>Integrated Live Conferencing&nbsp;</li>
-
-
-      <li>Templates and styles for rapid online authoring</li>
-
-
-      <li>Search engine&nbsp;</li>
-
-
-      <li>New question types: hotspots and&nbsp;open answers</li>
-
-
-      <li>Reporting dashboard with export to Ms-Excel</li>
-
-
-      <li>Surveys</li>
-
-
-      <li>Educational blogs</li>
-
-
-      <li>Learning Path: better import and export of SCORM, IMS and  AICC </li>
-
-
-      <li>Documents tool: PowerPoint and Word into HTML file type  conversion</li>
-
-
-      <li>Tests tool: less sequential and more user-friendly</li>
-
-
-      <li>Forum : better admin and content management</li>
-
-
-      <li>code cleanup </li>
-
-
-      <li>new nice looking icons</li>
-
-
-      <li>new layout for the course homepage</li>
-
-
-      <li>Version check: be informed when a new Dokeos release is available.  </li>
-
-
-      <li>Platform Statistics so you can boast with your campus. </li>
-
-
-
-</ul>
-
-
-
-<h1></h1>
-
-<hr style="width: 100%; height: 2px;" />
-<h1>Dokeos 1.6.5 - July 2006 </h1>
-
-
-
-<h3>Release notes - summary</h3>
-
-
-
-<p>Security Release. 1 bug has been fixed. Click the link below to see the complete list of bugfixes<br />
-
-
-      <a href="http://www.dokeos.com/wiki/index.php/Dokeos_1.6.5_release_notes_and_changelog">http://www.dokeos.com/wiki/index.php/Dokeos_1.6.5_release_notes_and_changelog</a></p>
-
-
-
-<h1>Dokeos 1.6.4 April 2006 </h1>
-
-
-
-<h3>Release notes - summary</h3>
-
-
-
-<p>Bugfix release. 2 bugs have been fixed. One security hole has been fixed <br />
-
-
-    Click the link below to see the complete list of bugfixes<br />
-
-
-    <a href="http://www.dokeos.com/wiki/index.php/Dokeos_1.6.4_release_notes_and_changelog">http://www.dokeos.com/wiki/index.php/Dokeos_1.6.4_release_notes_and_changelog</a></p>
-
-
-
-<h1>Dokeos 1.6.3 February 2006 </h1>
-
-
-
-<h3>Release notes - summary</h3>
-
-
-
-<p>Bugfix release. 44 bugs have been fixed. Click the link below to see the complete list of bugfixes<br />
-
-
-    <a href="http://www.dokeos.com/wiki/index.php/Dokeos_1.6.3_release_notes_and_changelog">http://www.dokeos.com/wiki/index.php/Dokeos_1.6.3_release_notes_and_changelog</a> </p>
-
-
-
-<h1>Dokeos 1.6.2 - September 2005</h1>
-
-
-
-<h3>Release notes - summary</h3>
-
-
-
-<p>Bugfix release. 14 bugs have been fixed. Click the link below to see the complete list of bugfixes<br />
-
-
-    <a href="http://www.dokeos.com/wiki/index.php/Dokeos_1.6.2_release_notes_and_changelog">http://www.dokeos.com/wiki/index.php/Dokeos_1.6.2_release_notes_and_changelog</a></p>
-
-
-
-<h1>Dokeos 1.6.1 - August 2005</h1>
-
-
-
-<h3>Release notes - summary</h3>
-
-
-
-<p>Bugfix release. 31 bugs have been fixed. Click the link below to see the complete list of bugfixes<br />
-
-
-    <a href="http://www.dokeos.com/wiki/index.php/Dokeos_1.6.1_release_notes_and_changelog">http://www.dokeos.com/wiki/index.php/Dokeos_1.6.1_release_notes_and_changelog</a></p>
-
-
-
-<h1>Dokeos 1.6 - July 2005</h1>
-
-
-
-<h3>Release notes - summary</h3>
-
-
-
-<p>In Dokeos 1.6, security and interoperability have been improved. Protection<br />
-
-
-      for documents has improved, and courses have more accessibility options.<br />
-
-
-      Password encryption is enabled by default. The php.ini setting <br />
-
-
-    "register globals" does not have be on anymore.<br />
-
-
-    <a href="http://www.dokeos.com/wiki/index.php/Dokeos_1.6_release_notes">http://www.dokeos.com/wiki/index.php/Dokeos_1.6_release_notes </a></p>
-
-
-
-<h3>New Features</h3>
-
-
-
-<ul>
-
-
-      <li>Campus home page can be edited online</li>
-
-
-      <li> Improved translations, made with the new Dokeos translation tool</li>
-
-
-      <li> Language switch - when you enter the portal, you can choose your language.</li>
-
-
-      <li> Who is online: a list of users who are logged in, you can click to see
-        their pictures and portfolio, or click to talk to them through our built-in web chat tool.</li>
-
-
-      <li>Learning path - import and export of SCORM packages, improved layout,
-        prerequisites based on score in tests</li>
-
-
-      <li> Agenda - many new options, e.g. every user can add personal agenda items.</li>
-
-
-      <li>Document tool - many new options, improved layout, improved HtmlArea</li>
-
-
-      <li> Security - PHP register globals setting don't need to be on anymore</li>
-
-
-      <li> Administration section - all functions are easier to access, you can
-        configure many options through the web interface instead of by digging through the code. </li>
-
-
-      <li> Improved course management - completely rewritten course import/export
-        functions, easily copy content from one course to another</li>
-
-
-      <li> Plugins and modularity - new system to add plugins to Dokeos more easily</li>
-
-
-      <li> API libraries - our function libraries have been expanded and improved</li>
-
-
-      <li>Interoperability: support for SCORM import/export, XML import/export for
-        some features, IEEE LOM Metadata support in documents and groups, import of
-        Hotpotatoes, connection with QuestionMark (this last one will be available
-        as plugin).</li>
-
-
-
-</ul>
-
-
-
-<h3>Roadmap</h3>
-
-
-
-<p><a href="http://www.dokeos.com/wiki/index.php/Roadmap_1.6">http://www.dokeos.com/wiki/index.php/Roadmap_1.6</a></p>
-
-
-
-<h1>Dokeos 1.5.5   </h1>
-
-
-
-<ul>
-
-
-      <li>Learning path : Scorm content import tool</li>
-
-
-      <li> WYSIWYG editor : create content on the fly</li>
-
-
-      <li> Table of contents : structure content on the fly</li>
-
-
-      <li> Dropbox : peer2peer content sharing management</li>
-
-
-      <li> Links categories : structure links catalogue</li>
-
-
-      <li>New navigation : one click to tool</li>
-
-
-      <li> Events since my last visit : be informed of what has changed since your last login</li>
-
-
-      <li> My agenda : synthetic weekly view of all the events related to you</li>
-
-
-      <li> Add a picture to my profile : see who is who</li>
-
-
-      <li> Security : privacy and anti-cracking protection</li>
-
-
-      <li> 5 more languages : russian, catalan, vietnamese, brazilian, thai and a revised chinese</li>
-
-
-      <li> New chat tool : real-time textual discussion</li>
-
-
-      <li> Audio &amp; video conference : real-time live broadcasting of events + textual interaction with ore than 200 people.</li>
-
-
-      <li> Announcements to some users or some groups only</li>
-
-
-      <li> Time-based learning management : add resources to time line in Agenda</li>
-
-
-      <li> Audio &amp; video in Tests tool : create listening comprehensions, situation-based questions on the fly</li>
-
-
-      <li> Forum thread/flat view : see discussions in more detail</li>
-
-
-      <li>Forum email notification : get an email when your forum topic is active</li>
-
-
-      <li> language revision : dokeos vocabulary has been generalised to be adapted
-        to different types of organisations and not only universities</li>
-
-</ul>
-  </div>
-</div>
-<hr />
-    <a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-xhtml10-blue" alt="Valid XHTML 1.0 Transitional" style="margin: 1em; float: right;" height="31" width="88" /></a>
-	<a href="http://jigsaw.w3.org/css-validator/">
-		<img src="http://jigsaw.w3.org/css-validator/images/vcss-blue" style="margin: 1em; float: right;" alt="Valid CSS" />
-	</a>
-</body></html>
+<!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="en" lang="en"><head>
+  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+
+  <title>Chamilo Changelog</title><link rel="stylesheet" href="default.css" type="text/css" media="screen,projection" />
+  <link rel="shortcut icon" href="./favicon.ico" type="image/x-icon" />
+  <style type="text/css">
+	<!--
+		@page { size: 21cm 29.7cm; margin: 2cm }
+		pre { font-family: "Courier New", monospace }
+		p { margin-bottom: 0.21cm }
+		.code {margin: 1em 1em 1em 2em; padding: 0.5em; background-color: rgb(229, 229, 229); vertical-align: top; border: 1px solid #999999;}
+	--></style></head>
+<body>
+<div id="header1">
+<h1>Chamilo&nbsp;Changelog</h1>
+</div>
+<a href="index.html">Documentation</a> &gt; Changelog
+<div id="outerframe">
+<div id="main">
+
+<h1>Chamilo 1.8.7 - ? ?</h1>
+<h3>Release notes - summary</h3>
+<p>Chamilo 1.8.7 is a intermediate&nbsp;release including a lot of new features, mostly focused on social network, the handling of sessions (which will help many educational institutions, public or private, to manage their contents in a more flexible way) and visual style, and a few important bugfixes. It lays the first stable stone in the Chamilo software project.</p>
+<h3>New Features</h3>
+<ul>
+  <li>New tool: Class attendance (usable in Gradebook)</li>
+  <li>New Tool: Student certificate </li>
+  <li>Thematic advance option added in course description (shown on course homepage)</li>
+  <li>Timezone management at user and platform level (Feature #599)</li>
+  <li>Upgraded PclZip library to version 2.8.2 (Feature #553)</li>
+  <li>Upgraded PHPMailer library to version 5.1 (Feature #272)</li>
+  <li>Exercise tool: Copy exercise feature added</li>
+  <li>Exercise tool: Teachers can delete students results of an exercise (NOT LP results)</li>
+  <li>pChart Horizontal bars library added thanks to gferri see (Feature #790)</li>
+  <li>Exercice tool: Shuffle answers</li>
+  <li>Exercice tool: Copy exercises</li>
+</ul>
+
+<h3>Debugging</h3>
+<ul>
+  <li>Fixed major course copy drawback by which exercise contents were keeping links to the old course (thanks to Ludovic Gasc and SANTEXCEL - BT#658)</li>
+  <li>Some PHP short tags fixed. Reported by Sicabol, see <a href="http://www.chamilo.org/node/114" target="_blank">http://www.chamilo.org/node/114</a> (Feature #347)</li>
+  <li>Student publications deleted when an user is unsubscribed of a course. Reported and fixed by André Boivin</li>
+  <li>Fixed bug reported by Carlosbrolotobar in <a href="http://www.chamilo.org/node/135" target="_blank">http://www.chamilo.org/node/135</a> whereby normal students don't can't see their social profile section in the right menu if they can't see the courses catalog.</li>
+  <li>Corrected mailing functions, now they load the file <em>mail.conf.php</em>. Previously the file <em>mail.conf.dist.php</em> was to be loaded by mistake. (Feature #272)</li>
+  <li>Online editor: A new configuration option about editor's background has been proposed by Wofganag Schneider and it has been implemented. See <a href="http://www.chamilo.org/node/107" target="_blank">http://www.chamilo.org/node/107</a> (Feature #347)</li>
+  <li>Online editor: IE proprietary commenting tags are desactivated before loading the edited text. This fix has been proposed by Hubert Borderiou. (Bug #573)</li>
+  <li>Online editor: Upgraded from FCKEditor 2.6.5 to FCKEditor 2.6.6, Build 25427 - Feature #626</li>
+  <li>Fixed bugs caused by the undefined constant REL_SYS_PATH and by the declared twice constant TABLE_MAIN_GROUP. Problems have been reporded by krikrizzz and Knightly. See the related forum topics <a href="http://www.chamilo.org/en/node/190" target="_blank">http://www.chamilo.org/en/node/190</a> and <a href="http://www.chamilo.org/en/node/154" target="_blank">http://www.chamilo.org/en/node/154</a> (Feature #347)</li>
+  <li>Fixed course copy table lp_item audio not copied. Reported by Henri Hedman (Bug #575)</li>
+  <li>Fixed Added an option to cancel prerequisites in a course (Learning path). Fixed by aboivin in <a href="http://www.chamilo.org/node/146" target="_blank">http://www.chamilo.org/node/146</a> </li>
+  <li>Empty extra user fields are now deleted from the database</li>
+  <li>Quiz tool: Answer list fixed when using "matching" question type (BT#801). Reported by Noa Orizales</li>
+  <li>Quiz tool + LP : Fixed bug when adding a exercise twice in the same LP with multiple attempts or not.</li>
+  <li>Quiz tool + LP + Multiple attempts : Pre requisites will work the first time a student pass the LP. 
+ 	  If an student finished all steps correctly he will view all steps, prerequisites will not work here.</li>
+  <li>Learning Path (Courses): PHP sessions of a LP are destroyed when visiting the main course page.</li>
+  <li>Assignment tool: Work.php deletes all homeworks bugs fixed. Reported and fixed by carlosbrolotobar <a href="http://www.chamilo.org/node/143" target="_blank">http://www.chamilo.org/node/143</a></li>
+</ul>
+<br />
+<h3>CSS changes</h3>
+<ul>
+  <li>Z</li>
+</ul>
+<h3>Known issues</h3>
+<ul>
+  <li>Timezone functionality is not available in the most recent versions of PHP available for CentOS/RHEL ( 5.1.6-23.2.el5_3 ) (see http://www.php.net/manual/en/function.timezone-identifiers-list.php)</li>
+  <li>when the user published an event as announcement, this same announce can be repeat many times</li>  
+</ul>
+  
+<h3>Deprecated files</h3>
+<ul>
+  <li>Online editor: The plugins "Flash" (obsolete) and "placeholder" (non-relevant to the finished product) have been removed. (Feature #347)</li>
+</ul>
+
+<br />
+
+<h1>Chamilo 1.8.6.2  <span style="font-style: italic;">Salto</span> - January 2010</h1>
+<h3>Release notes - summary</h3>
+<p>Chamilo 1.8.6.2 is a intermediate&nbsp;release including a lot of new features, mostly focused on social network, the handling of sessions (which will help many educational institutions, public or private, to manage their contents in a more flexible way) and visual style, and a few important bugfixes. It lays the first stable stone in the Chamilo software project.</p>
+<h3>New Features</h3>
+<ul>
+  <li>Implemented by-session content creation tools updates</li>
+  <li>Added tabs editor (from admin)</li>
+  <li>Added course catalogue</li>
+  <li>Added a link to export courses in the "platform administrator &gt; courses list" entry (DT#4257)</li>
+  <li>Added sessions history (optional access to previous sessions in read-only or read-write, for students)</li>
+  <li>Added advanced search in sessions: you can also search by session name, session category, tutor and visibility. (DT#5541)</li>
+  <li>Added an option to configure courses as "auto-registered" (every user has it in his courses list and is automatically subscribed)</li>
+  <li>Added chat tool to the groups(DT#3318)</li>
+  <li>Allowed password to be recovered using username *or* e-mail</li>
+  <li>Added editable section to the registration form</li>
+  <li>Added option to send a email to a portal administrator upon course creation (DT#3489)</li>
+  <li>Added privacy for the chat tool in a sessions or groups context (DT#5558)</li>
+  <li>Added possibility to view glossary terms in exercises and learning paths (courses)</li>
+  <li>Reporting: notification of users who have never been active yet</li>
+  <li>Reporting: the additional user profile fields (defined by the platform administrator through platform administration &gt; profiling) can now be shown in the reporting screens</li>
+  <li>Subscribing users in a course: you can now filter on addtional user profile fields when subscribing a user in a course (through user/subscribe_user.php) </li>
+  <li>Definition of wiki pages as tasks for students is now possible</li>
+  <li>Added feedback to student wiki pages, synchronized with their progress in the task</li>
+  <li>Added posibility to establish a time limit for each wiki page</li>
+  <li>Added posibility to establish a max number of words into each wiki page</li>
+  <li>Added posibility to establish a max number of versions for each wiki page</li>
+  <li>Improved control of concurrent users in wiki</li>
+  <li>Improved the use of wiki pages such as student's portfolios (individual task)</li>
+  <li>Added an immediate redirection to the course after login when a user is enrolled only in one course (defined by the platform administrator through platform administration &gt; configuration settings &gt; training)- DT#3466</li>
+  <li>Added user's photo into users list interface - DT#5496</li>
+  <li>Disabled trainer/tutor name field in create course form, set to current user's name by default. Can be modified into course settings - DT#5496 </li>
+  <li>Added option to export the training list to CSV in Administration &gt; Training - DT#4256</li>
+  <li>Added user tags in social network - DT#5508</li>
+  <li>Revamped "Who is online" look - DT#5490</li>
+  <li>Added new search tool - DT#5610 </li>
+  <li>Added user groups at platform level (social network) with posibility to send group messages, add moderators, readers, etc - DT#5611</li>
+  <li>Made construction of presentations with the images of document tool easier</li>
+  <li>Upgraded from FCKEditor 2.6.4.1 to FCKEditor 2.6.5, Build 23959 - DT#2867</li>
+  <li>Added settings for WYSIWYG editor into the Platform Admin Area (instead of files)</li>
+  <li>Upgraded html2pdf libray to 3.26</li>
+  <li>Upgraded mimetex to 1.71</li>
+  <li>Rebuilt social network menu interface</li>
+  <li>Improved messages tool: Easier to use, no annoying ajax menun makes it faster and more reliable</li>
+  <li>Added multiple attachments to messages sending</li>
+  <li>Added possibility to send emails to multiple users</li>
+  <li>Improved user portal page when Social Network is enabled: User image, and subscriptions links are shown</li>
+  <li>Added inc/ajax library folder to structurer AJAX calls - see CT#431. All new jQuery + AJAX reponses should be located there</li>
+  <li>RSS Feed added by default to the extra fields, as well as the user tag. Still requires manual visibility change to be enabled</li>
+  <li>Improved reporting tab performance tenfolds (main/mySpace/courseLog.php file)</li>
+  <li>Added list of students who have not submitted an assignment yet, and  the possibility to send them a reminder by email - BT#487 BT#489</li>
+  <li>Added new question type in exercise tool: Multiple answer combination a.k.a "Exact answer" - CT#402</li>
+  <li>Added e-mail notifications when a student answers an exercise</li>
+  <li>Added extensible footer style, allowing for much more information to be shown there</li>
+  <li>List of course improved when using Course categories in user_portal.php </li>
+</ul>
+
+<h3>Debugging</h3>
+<ul>
+  <li>Simplified SCORM engine, making it more reliable but supporting less SCORM messages (interactions and objectives disabled for now)</li>
+  <li>Fixed a bug in course homepage always showing a box even when no tools were shown (r8747:3ad59f6aed1f)</li>
+  <li>Score result in reporting is expressed as a percentage</li>
+  <li>CSV export of reporting no longer contains html code in the last column</li>
+  <li>The course list is now sorted like you have defined on the course management page</li>
+  <li>Display order in LP fixed (Organize view) #5668</li>
+  <li>Automatic deletion of a link in gradebook fixed - DT#5229</li>
+</ul>
+<br />
+<h3>CSS changes</h3>
+<ul>
+  <li>New Chamilo themes added</li>
+  <li>Fixed older styles support</li>
+  <li>Added iepngfix hack to support png images in IE6</li>
+  <li>Changed footer to allow for extensible height</li>
+  <li>Added many CSS elements to support new tools (social network, glossary, etc)</li>
+</ul>
+<h3>Known issues</h3>
+<ul>
+  <li>In Hotspot under Windows® (server-side), uploading a PNG file results in an unstable exercise</li>
+  <li>Scorm: Objectives and interactions are not supported</li>
+  <li>Scorm: Hotspot and Exact type of questions can't be exported in a SCORM package</li>
+  <li>Course backup: When trying to generate a backup the image/video paths are not update with the new course code see CT#521</li>
+  <li>If the "Show glossary terms" option is selected for the lessons tool (SCORM) and exercises, the description of the exercise might contain the answers to the question. Need human intelligence to avoid this.</li>
+</ul>
+
+<h3>Deprecated files</h3>
+<ul>
+  <li>main/btf_functions.php file deleted. All functions are in the new class inc/lib/course_home.lib.php</li>
+  <li>main/messages/message.class.php moved to inc/lib/message.lib.php in messages tool</li>
+  <li>main/messages/message.css is now useless</li>
+  <li>main/messages/cookies.js is now useless</li>
+  <li>message_for_group_form_inc.php in social tool moved to the inc/ajax library</li>
+  <li>main/social/select_options.php moved to inc/ajax library</li>
+</ul>
+
+<br />
+<h1>Dokeos 1.8.6.1 - August 2009</h1>
+<h3>Release notes - summary</h3>
+<p>Dokeos 1.8.6.1 is a minor&nbsp;release including just a few new features, mostly focused on internationalization, and several bugfixes.</p>
+<h3>New Features</h3>
+<ul>
+  <li>Implemented new sub-language feature by which language terms redefinition becomes possible through the admin section (FS#4321)</li>
+  <li>Admin: Terms and conditions added DT#4320</li>
+  <li>Improvements in document tool, allow seeing glossary terms (FS#4337)</li>
+  <li>Small improvements in SCORM export(FS#4300)</li>
+  <li>At the beginning of the installation script, added an imperative check for PHP 5 has been added. (FS#4296)</li>
+  <li>When the system Dokeos is switched into "Test server" mode, a clickable indicator appears in the footer. This indicator is visible by platform administrators only. (FS#4341)</li>
+  <li>A transliteration function has been added. Currently, it is used in uploading files. Files with non-English names get names that contain ASCII letters only, remaining readable in the corresponding language. Rationale: The PHP5 run-time environment does not manage file name encodings, adding such a non-native feature involves too much work. For avoiding character encoding problems, transliteration of file names is the possible solution. (FS#306)</li>
+  <li>An internationalization option has been added for improving sorting in arbitrary language. When the <a href="http://php.net/manual/en/book.intl.php" target="_blank">intl</a> php-extension has been installed, various sorting routines exploit it for better sorting. Rationale: The PHP5 run-time environment does not provide native and reliable way of sorting UTF-8 strings. (FS#306)</li>
+  <li>Installation script: The page about system requilements has been updated. Also, at the very beginning, a check has been added whether the <a href="http://php.net/manual/en/book.mbstring.php" target="_blank">mbstring</a> php-extension is installed - see <a href="http://dokeos.com/forum/viewtopic.php?t=29548" target="_blank">the related forum topic</a>. (FS#306)</li>
+  <li>A new php-based configuration for the online editor has been implemented, see <i>dokeos/main/inc/lib/fckeditor/myconfig.php</i>. Also, toolbar definitions have been split in separate php-files within the directory <i>dokeos/main/inc/lib/fckeditor/toolbars/</i> . Customization of the editor is more convenient and flexible now. (FS#2867)</li>
+  <li>Online editor: A upgrade from FCKEditor 2.6.4 to <strong>FCKEditor 2.6.4.1</strong> has been implemented. (FS#4383)</li>
+  <li>Online editor: Blocking copy/paste for trainees has been added. The feature is configurable through editing the toolbar definition files within the directory <i>dokeos/main/inc/lib/fckeditor/toolbars/</i> . (FS#2867)</li>
+  <li>Online editor: Preview tabs have been added to the dialogs for inserting video, flv-video, and YouTube video. (FS#2867)</li>
+  <li>Online editor: The <strong>audio</strong> plugin has been activated by default as an implementation of the "Insert audio / Audio properties" dialog. This new plugin is intended to replace the "MP3" plugin. (FS#2867)</li>
+  <li>Online editor: The simple file manager, the advanced file manager and the image manager have been integrated by default with the editor's dialog system. Thus, they work faster and in a more secure way. (FS#2867)</li>
+  <li>Online editor: Configuration of the <strong>mimetex</strong> plugin has been reworked to gain simplicity. The procedure for configuration has been updated, see <a href="http://www.dokeos.com/forum/viewtopic.php?t=29594" target="_blank">the related forum topic</a>. (FS#2867)</li>
+  <li>Online editor: A new <strong>asciimath</strong> plugin for inserting mathematical formulas has been added. It is based on the <a href="http://mathcs.chapman.edu/~jipsen/mathml/asciimath.html" target="_blank">ASCIIMathML.js</a> library. (FS#2867)</li>
+  <li>Social: Added possibility to define RSS feeds inside personal page of social network (need to define an 'rssfeeds' extra user text field)</li>
+</ul>
+<h3>Debugging</h3>
+<ul>
+  <li>Online editor: Several known bug-fixes from FCKEditor 2.6.5 SVN have been implemented, tickets <a href="http://dev.fckeditor.net/ticket/1537" target="_blank">#1537</a>, <a href="http://dev.fckeditor.net/ticket/2156" target="_blank">#2156</a>, <a href="http://dev.fckeditor.net/ticket/2689" target="_blank">#2689</a>, <a href="http://dev.fckeditor.net/ticket/2821" target="_blank">#2821</a>, <a href="http://dev.fckeditor.net/ticket/2856" target="_blank">#2856</a>, <a href="http://dev.fckeditor.net/ticket/2874" target="_blank">#2874</a>, <a href="http://dev.fckeditor.net/ticket/2915" target="_blank">#2915</a>, <a href="http://dev.fckeditor.net/ticket/3120" target="_blank">#3120</a>, <a href="http://dev.fckeditor.net/ticket/3181" target="_blank">#3181</a>, <a href="http://dev.fckeditor.net/ticket/3427" target="_blank">#3427</a>, <a href="http://dev.fckeditor.net/ticket/3429" target="_blank">#3429</a>, <a href="http://dev.fckeditor.net/ticket/3439" target="_blank">#3439</a>, <a href="http://dev.fckeditor.net/ticket/3446" target="_blank">#3446</a>, <a href="http://dev.fckeditor.net/ticket/3481" target="_blank">#3481</a>, <a href="http://dev.fckeditor.net/ticket/3677" target="_blank">#3677</a>, <a href="http://dev.fckeditor.net/ticket/3818" target="_blank">#3818</a>, <a href="http://dev.fckeditor.net/ticket/3880" target="_blank">#3880</a>, <a href="http://dev.fckeditor.net/ticket/3925" target="_blank">#3925</a>. (FS#2867)</li>
+  <li>Online editor: The toolbar icons have been upgraded to those from FCKEditor 3.0. (FS#2867)</li>
+  <li>A solution has been implemented for fixing the <a href="http://bugs.adobe.com/jira/browse/FP-529" target="_blank">"__flash__removeCallback" bug</a>, which affects the media player on Internet Explorer browser. (FS#4378 and FS#2867)</li>
+  <li>Quiz: fixed bug in multiple-choice/single-answer questions results (whereby the wrong answer was saved)</li>
+  <li>Admin: Added courses from sessions inside AJAX popup of courses list in users list (SVN#22398)</li>
+  <li>Admin: Showing full-length course titles in list of courses while adding to sessions(SVN#22399)</li>
+  <li>Admin: Added session name in title of session edition pages(SVN#22400)</li>
+</ul>
+<br />
+<h3>CSS changes</h3>
+<ul>
+  <li>Sticky footer now available in all Dokeos stylesheets. If you own a custom stylesheet you will need to update it, see <a href="https://bts.dokeos.com/issues/show/3549">DT#3549</a> for further details.</li>
+</ul>
+
+<br />
+<h3>Known issues</h3>
+<br />
+<h3>Deprecated files</h3>
+<ul>
+  <li>The whole main/inc/lib/fckeditor/editor/filemanager/browser/default/connectors/ directory should be removed for security reasons</li>
+</ul>
+<br />
+<h1>Dokeos 1.8.6 <span style="font-style: italic;">Svalbard</span> - June 2009</h1>
+<h3>Release notes - summary</h3>
+<p>Dokeos 1.8.6 Svalbard is a major&nbsp;release including new features.&nbsp;</p>
+<h3>New Features</h3>
+<ul>
+  <li>FCKEditor 2.6.4, build 21629 added (FS#2528 and FS#2867)</li>
+  <li>Improvements to the profiling tool (previously called "User fields") to improve presentation and flexibility, and allow edition</li>
+  <li>Added new authorized charsets for learning path tool</li>
+  <li>Official code available in My Reporting (FS#2640)</li>
+  <li>Added possibility to switch fill-in-the-blanks answers (FS#2683)</li>
+  <li>Now hiding database password field with *** in install/upgrade procedure (FS#2680)</li>
+  <li>Added attempts limit to tests</li>
+  <li>Hide language form if only one language available</li>
+  <li>Added possibility for the course teacher and tutor to delete quiz attempts by users</li>
+  <li>Added possibility for session coaches to register external users directly to their session (FS#2700)</li>
+  <li>Added possibility to allow coach to access a defined number of days before and after a session (FS#2724)</li>
+  <li>Activates unique (ajax) and multiple (multiple select) inscriptions for courses and users in sessions (FS#2719)</li>
+  <li>Handling of sessions in tools has been improved : for example we can't see anymore an annoucment of another session (FS#2743)</li>
+  <li>Tests : In students results page, set the question comment in red when the student's answer is wrong. Set in green when the answer id good</li>
+  <li>New audio recorder in learning path</li>
+  <li>New mp3 player (FS#2977)</li>
+  <li>New Glossary tool (FS#3248)</li>
+  <li>Integrated the gradebook at course level (FS#3173)</li>
+  <li>New wiki tool (considerably improved, built on CoolWiki plugin) (FS#2873)</li>
+  <li>Remove possibility to delete system directories in documents tool (FS#1522)</li>
+  <li>Database server: no more need for special SQL modes for MySQL 5.0 to be turned off through the "sql_mode" setting. The Dokeos system does it internally (FS#2787)</li>
+  <li>Some low-level functions that intensively use the language translation sub-system have been optimized for speed (FS#3260)</li>
+  <li>Documents tool: The document-type icons have been made clickable (FS#3296)</li>
+  <li>Documents tool: Online editor has been disabled for HotPotatoes tests in order their functionality to be preserved (FS#3345)</li>
+  <li>Allow ZIP export of assignments for teacher and tutor </li>
+  <li>Added attach documents to Agenda</li>
+  <li>Added Web Services Interface (SOAP)</li>
+  <li>Added Google Maps support</li>
+  <li>Added Imagemap editor</li>
+  <li>Online editor: Inserting links to YouTube streaming service has been added (FS#2867)</li>
+  <li>Improved chat (open in new window option, smileys, teacher/learner difference and time indication for each message, user picture showing directly, possibility to hold several conversations in several courses at the same time)</li>
+  <li>Option to hide/show e-mail addresses to all users (FS#3244)</li>
+  <li>Added an introduction section for each group area (FS#3200)</li>
+  <li>New Global Agenda (FS#3391)</li>
+  <li>New Notebook tool in courses</li>
+  <li>Added reporting on the last connections of a user in the chat</li>
+  <li>Added link create course message to go directly to the course(SVN#17497)</li>
+  <li>Added ability to take partial surveys and finish them later (FS#2510)</li>
+  <li>New Survey Feature: Surveys without invitation mail (FS#3403)</li>
+  <li>Added Booking system (a.k.a Reservation 2 Extension) (FS#821)</li>
+  <li>Added user profiling fields in auto-registration page (FS#2666)</li>
+  <li>Added check for writeable status of session save path in installation directory (FS#2970)</li>
+  <li>Allow forum threads to be moved (FS#3460)</li>
+  <li>Minor - Added update information for quizzes (FS#3417)</li>
+  <li>Sending e-mails to all admin on user account creation confirmation (FS#3475)</li>
+  <li>Changed user profile setting defaults to make phone field disabled and picture enabled (FS#3474)</li>
+  <li>Added intermediary buttons in platform settings pages to avoid scrolling too much to apply atomic changes (FS#3473)</li>
+  <li>Simplify default platform language choice by adding quick icon (FS#3472)</li>
+  <li>Session admins can now add users to the portal (FS#3476)</li>
+  <li>Added Advanced File Manager (FCKEditor plugin) to improve flexibility in files upload (FS#2970)</li>
+  <li>Added New Message Tool (a.k.a Message 2 Plugin) (FS#3503)</li>
+  <li>Added Question difficulty level in Exercises (FS#3515)</li>
+  <li>Added Removed buggy audio recorder and added new MP3 player with easy upload (FS#3515)</li>
+  <li>Improved Survey export (SVN#17927)</li>
+  <li>Students can now view their uploaded works in Work tool (FS#3486)</li>
+  <li>Implemented
+add to calendar an assignment with the date when it is completely
+closed, also when you remove it from assignment tool, it's removed into
+calendar too, the same case when it's edited, for that I had to change
+the value of add_calendar field into student_publication_assignment
+table, now when it's sent to calendar this value is the id into
+calendar_event table, instead this value is 0.</li>
+  <li>Added Social tool + friend list (FS#3383)</li>
+  <li>Added introduction section to blog and course description (FS#3165)</li>
+  <li>Added import/export (CSV/XML) of extra user fields</li>
+  <li>Added ability to import users in XML and subscribe to visual code (FS#3552)</li>
+  <li>Added pChart v1.1.2 library to manage charts in Gradebook tool(FS#3718) and the Access details of a user </li>
+  <li>Added SHA1 as a possibility to encrypt user passwords (FS#3798)</li>
+  <li>Added global templates to use between courses (SVN#18955)</li>
+  <li>Added To change your password, you must enter your current password (SVN#19225)</li>
+  <li>Added New Dokeos stylesheets </li>
+  <li>Improvements to the User profile</li>
+  <li>Improvements to the Learning path display view (no more frames)</li>
+  <li>Added HTML Purifier</li>
+  <li>Added tracking/logging of admin activity FS#842</li>
+</ul>
+<br />
+<h3>Debugging</h3>
+<ul>
+  <li>Improved security in exercises module</li>
+  <li>Fixed issue in dropbox documents zipping feature - see <a href="http://www.dokeos.com/forum/viewtopic.php?t=13345">related forum post</a></li>
+  <li>Increased size of php_session data field to allow for reasonable-sized session to be kept in the database (FS#2657)</li>
+  <li>Fixed a few issues in mailing and codes for survey tool (FS#2662)</li>
+  <li>Considerably improved migration of SCORM learning paths from Dokeos 1.6.x to 1.8.x</li>
+  <li>Added student-view link for platform admin</li>
+  <li>Fixed bug about last access reporting in dropbox tool (FS#2458)</li>
+  <li>Saving survey invitation's mail subject (FS#2662)</li>
+  <li>Various improvements in clone cleanliness - avoiding many notice-level error reports</li>
+  <li>Fixed user picture problems in admin pages</li>
+  <li>Mysql error fixed in Reporting in a single DB installation (FS#2638)</li>
+  <li>Fixed phone number field missing during registration (FS#2639)</li>
+  <li>Fixed breadcrumb in portal administration (FS#2642)</li>
+  <li>Fixed issues in FCKeditor edition of documents with video, flash and mp3 included (FS#2679)</li>
+  <li>Fixed security issue affecting Windows servers with system file inclusion on homepage (FS#2692)</li>
+  <li>Fixed one-question-per-page view in Quiz tool (FS#2678)</li>
+  <li>Removed possible risk of having a database code too large for the course.db_name field (FS#2426)</li>
+  <li>Added missing online help for blogs (FS#811)</li>
+  <li>Fixed bug showing whole article as link in blog (FS#811)</li>
+  <li>Fixed bug whereby the course permissions were not updated when using the multiple-action mode in course users list</li>
+  <li>Fixed bug preventing opening of a learning path item following a failed prerequisite condition (SVN#15853)</li>
+  <li>Fixed bug preventing the activation of plugins (FS#2771)</li>
+  <li>Fixed bug adding double comments in dropbox tool in IE only (FS#2757)</li>
+  <li>Fixed IMS/QTI2 little export problem (FS#2634)</li>
+  <li>The learners can't send files anymore to other learners if "Do not allow
+students to send documents to other students within a course" is false
+(FS#2780)</li>
+  <li>The mails sent in exercises tool are sent from the address defined in admin (FS#2712)</li>
+  <li>"Next" and "Previous" page now works when searching a session (FS#2721)</li>
+  <li>Fixed bug when launching a quiz with one question per page (FS#2738)</li>
+  <li>Fixed javascript bug with swap menu in ie6 (FS#2815)</li>
+  <li>Fixed bug in surveys when we want to display answers of an invited person (FS#2731)</li>
+  <li>Fixed
+bug when copying a course with surveys. There is now a check for
+existing surveys with the same code and language (FS#2734)</li>
+  <li>Fixed bug when seeing matching results in quiz tool (SVN#15987)</li>
+  <li>Added filtering of SCORM objectives when writing to DB (SVN#16437)</li>
+  <li>Removed duplication of database write operations for SCORM objectives (SVN#16438)</li>
+  <li>Fixed HTTP_REFERER bug in ical_export (FS#3041)</li>
+  <li>Fixed bug in SQL queries for new installs, preventing the creation of the course_module table (FS#3040)</li>
+  <li>Fixed
+the fact that the password was never sent by e-mail when encrypted,
+even when it had just been changed for a user, causing a useless e-mail
+to be sent (SVN#16673)</li>
+  <li>Fixed bug in users pictures display when using the tuning setting of splitting users dirs (SVN#16673)</li>
+  <li>Fixed bug in documents picture gallery preventing uppercase image extensions to be seen (SVN#16755)</li>
+  <li>Fixed bug whereby the repeated agenda items in groups were visible to all (FS#3095)</li>
+  <li>Fixed bug whereby e-mails sent did not have the standard syntax (SVN#16708)</li>
+  <li>Fixed bug whereby an empty institution name gave a useless output in the header (SVN#16710)</li>
+  <li>Fixed bug whereby questions ordering was broken when deleting one question in the middle (SVN#16879)</li>
+  <li>Fixed
+bug in user fields, not displayed the default value in profile and add
+user, and you could modify this values(see FS#3307) </li><li>Fixed bug in link (see FS#3306)</li>
+  <li>Improved display of human resource manager option (see FS#3304)</li>
+  <li>Documents tool, folder selector: Fixed a bug that prevented Home (root) folder to be shown (FS#3089)</li>
+  <li>Users tool: Fixed a bug preventing detailed information about a user to be shown or edited (FS#3009)</li>
+  <li>Fixed a bug causing various problems due to improper priority order of loading PEAR packages (FS#3237)</li>
+  <li>The
+PclZip library has been upgraded to version 2.6. Additionally, a known
+bug has been fixed - improper processing of the option
+PCLZIP_OPT_REMOVE_PATH on Windows (FS#3243)</li>
+  <li>Fixed a bug causing improper numeric sorting of data displayed in various tables (FS#3282)</li>
+  <li>Agenda tool: Fixed a wrong range for hour selection. The bug has been reported and solved in a forum by TL (FS#3324)</li>
+  <li>Agenda tool: style changes - Align drop-down lists in date and time when you add a new calendar event and modify it</li>
+  <li>Fixed Date Validation  when you add a new exercises and modify it (FS#3249)</li>
+  <li>Tests tool: Fixed broken filter on orphan questions in questions pool, reported and solved in the forums by mark111 (FS#3329)</li>
+  <li>Fixed security flaw allowing anonymous user to enter "open to the platform" courses (FS#3359 - SVN#17499)</li>
+  <li>Fixed forum visibility bug for private groups forum (FS#3327)</li>
+  <li>Fixed many links bugs when using a forum inside a learning path (FS#3256)</li>
+  <li>Fixed: dropbox changed notification icon appears while dropbox inaccessable (FS#3395)</li>
+  <li>Fixed: access to a hidden document was possible (FS#2835)</li>
+  <li>Dropbox fix: move multiple selected files to category feature is back. (FS#3005)</li>
+  <li>Fixed: Long lines in Announcements did not show up in email (FS#2988)</li>
+  <li>Fixed: the productions users aren't saved in the the correct directory (FS#3456)</li>
+  <li>Fixed error in install/htaccess.dist whereby the url-append was not set correctly (SVN#17791)</li>
+  <li>Fixed missing check on cDir in local.inc.php (SVN#17793)</li>
+  <li>Removed possibility to create sub-directories in the dropbox tool - wasn't working anyway for various versions (FS#3434)</li>
+  <li>Improved access control for group tool (FS#3209)</li>
+  <li>Fixed profiling date field popup bug (FS#2985)</li>
+  <li>Added check on max members in group before subscribing new people (FS#3453)</li>
+  <li>Changed usage of mail functions to use api_mail() everywhere and fix mail headers problems (FS#2445)</li>
+  <li>Fixed bug changing the language to false in platform settings (FS#3472)</li>
+  <li>Fixed various HTTPS + IE related bugs, related to caching in general (SVN#17795)</li>
+  <li>Fixed 31 bugs in file/image/sounds/flash uploads/delete/permissions in profile/homepage/agenda edition pages</li>
+  <li>Fixed a bug in migration for several versions at once whereby new course tools were repeated several times (SVN#17935)</li>
+  <li>Fixed security issue allowing users to upload php files on the server through FCKEditor (FS#2970)</li>
+  <li>Fixed folders by default into document tool must not be removed - see FS#3611</li>
+  <li>Fixed qualification of themes into forum tool - see FS#3609</li>
+  <li>allow show results with floating point,in exercice tool - (partial FS#3630) - SVN#18367</li>
+  <li>Fixed event into agenda when it's sent from assignment and Improved display form when you create an assignment - see FS#3583</li>
+  <li>Fixed difficulty of the question lost - see FS#3659</li>
+  <li>Fixed XML user import for single courses import (related to FS#3552)</li>
+  <li>Fixed bug with user image not showing in upgrade from previous versions</li>
+  <li>Fixed bugs causing wrong attempts to translate some icons on course homepage when the server is in testing mode (FS#3285)</li>
+  <li>A
+fix for the Oogie converter to work on Windows OS has been applied.
+Initial code has been proposed in the Dokeos forums by Øyvind Johansen
+(oyvind) and wilbrod - see FS#3969</li>
+  <li>Fixed Windows-related
+bugs preventing creation of SCORM packages from presentations, see
+FS#3972. The problem has been reported in the Dokeos forums by
+irvienhooi</li>
+  <li>Some minor bugs have been fixed in "Document Metadata" form (FS#4030)</li>
+  <li>Fixed a bug preventing updating dates of group documents after edition. Many thanks to Ludwig Theunis, nickname: TL (FS#4072)</li>
+</ul>
+<br />
+<h3>CSS changes</h3>
+<ul>
+  <li>Added classes glossary-term, glossary-term-title, glossary-term-desc, glossary-term-action-links for the glossary tool</li>
+  <li>Added personal-notes tool-related styles</li>
+  <li>Changed many things in the public-admin style (Dokeos default) to improve
+design - will probably affect other styles a little despite efforts not to</li>
+  <li>Added new styles</li>
+
+</ul>
+<br />
+<h3>Important language changes</h3>
+<ul>
+  <li>Changed "courses" to "trainings" in English and "Cours" to
+"Formations" in French. This change is likely to be very confusing to
+most users! Please either update your language files or warn your users
+if you are willing to keep that change.</li>
+  <li>Changed "Learning Path" link to "Course" in English and French</li>
+  <li>Changed and unified work/assignment/student publications tool as "assignments"</li>
+  <li>Changed "Dropbox" tool to "Documents sharing" (or "Documents sharing space" when referring to one's own space in the tool)</li>
+  <li>Changed "Student View" link to "Teacher view" and vice-versa</li>
+  <li>Many buttons now have more defined action names</li>
+</ul>
+<br />
+<h3>Known issues</h3>
+<ul>
+  <li>Inserting the same exercise twice in one learning path may generate score inconsistencies</li>
+</ul>
+<br />
+<h3>Deprecated files</h3>
+<ul>
+  <li>The whole main/inc/lib/xajax/tests/ should be removed</li>
+</ul>
+<br />
+<h1>Dokeos 1.8.5 <span style="font-style: italic;">Valparaiso</span>, June 2008</h1>
+<h3>Release notes - summary</h3>
+<p>Dokeos 1.8.5 is a major debugging release but includes interesting new features as well.&nbsp;</p>
+<h3>New Features</h3>
+
+<ul>
+	<li>Considerable security improvements - 2 major and 1 minor security patches have been applied since the latest stable version</li>
+	<li>SCORM
+export improvement (now generates SCORM 1.2 compliant packages and
+transforms Dokeos quizzes into SCO items, using interactions as a bonus)</li>
+	<li>Possibility to filter extension of submitted files all around Dokeos</li>
+	<li>OpenID authentication support</li>
+	<li>Possibility to import Word documents</li>
+	<li>Possibility to import docx and pptx documents (new MS-Office format)</li>
+	<li>Grades,
+evaluations and success certificates available thanks to the
+integration of the gradebook extension. Activating this module will
+clash with a gradebook extension installation made previously</li>
+	<li>Coloured icons added to courses list in administration panel to show access permissions</li>
+	<li>Logout button now shows the username of the current user</li>
+	<li>Student view re-activated and fully-functional</li>
+	<li>Searching
+the forum is now possible so you can use the forum as a knowledge base.
+The search results are highlighted throughout the forum and you can
+search on multiple words also. </li>
+    <li>Group members are now displayed in a sortable table</li>
+	<li>Possibility to export survey results in XLS format</li>
+	<li>Documents, Works and Dropbox tools usability has been improved in many ways</li>
+    <li>In the agenda, you can display the X upcoming events (can be configured by the platform admin)</li>
+    <li>The course agenda now has a month view like the my agenda</li>
+    <li>In
+the user list of the platform administration you can now quickly see
+for what courses the user is subscribed by hovering over the courses
+icon</li>
+    <li>The platform system announcements can now be sent through email also</li>
+	<li>User
+fields have been added globally, allowing you to add user data like
+birthdate, mother tongue, city or whatever data you want to ask your
+users</li>
+	<li>LDAP
+		<ul>
+			<li>The LDAP code has changed. If you had some customisations there, you might want to save them and re-apply them after the upgrade</li>
+			<li>Functions renamed to respect coding conventions and use ldap_ namespace</li>
+			<li>Most
+parameters moved to the administration panel. You will need to
+configure the administration panel with the settings that were
+previously in ldap_var.inc.php</li>
+			<li>Added non-anonymous mode (just add a login and a password in the configuration panel)</li>
+			<li>Added search domain configuration through panel</li>
+			<li>Added customizable field-check for student-teacher switch</li>
+			<li>The installation guide has been updated to help you find your way through the new LDAP configuration panel</li>
+			<li>You still need to activate LDAP by uncommenting two lines in configuration.php</li>
+	    </ul>
+	</li>
+    <li>New stylesheets can be added through the platform administration interface</li>
+    <li>Notification
+by email has been improved in the forum. You can now indicate that you
+want to be informed of messages on the forum level or on the thread
+level, even if you did not participate in the discussion yet. </li>
+    <li>The
+platform administrator can decide to display the courses that are not
+open on the login page. When these courses are displayed on the campus
+startpage then the user that is logged in can quickly subscribe to this
+course.</li>
+    <li>When creating a new group you can decide to create
+a public or private forum or no forum at all. These are group category
+settings.</li>
+    <li>Group forum is also displayed in the group space</li>
+    <li>Surveys that are not based on invitation but open to all (or certain) members of the course are now available</li>
+    <li>Agenda
+    	<ul>
+    		<li>iCal import and export of course events, with a choice of public, private or confidential markers</li>
+    		<li>Repetitive
+course events can be created (and exported to iCal). Repetitions types
+supported are: daily, weekly, monthly by date (e.g. the 5th of each
+month) and yearly by date</li>
+   		</ul>
+	</li>
+	<li>Document templates have been greatly improved to speed-up custom course content creation</li>
+	<li>Audiorecorder
+(depending on streaming server) now records sounds in the
+document/audio directory, making them easily reusable by the course
+admin</li>
+	<li>Audiorecorder is not loaded by default (took too long) and you can load it with a simple click</li>
+	<li>W3C - Compliance with XHTML 1.0 Transitional has been improved</li>
+	<li>Tracking - A new page to display access details by user is available under the Reporting tab, in the user details in a course</li>
+	<li>Removed header from learning path tool. It was taking too much space and was not flexible enough for CSS styling</li>
+	<li>Improved speed of 1.6 to 1.8 migration by adding indexes</li>
+    </ul>
+<br />
+<h3>Debugging</h3>
+<ul>
+	<li>Prerequisites management in learning paths fixed (includes quizzes, hotpotatoes and SCORM)</li>
+	<li>Various minor bugs fixed in the learning path tool (scoring, copy, re-ordering)</li>
+	<li>Various minor bugs fixed in the session handling</li>
+	<li>Fixes to the survey tool (date management, questions order in export)</li>
+	<li>Fixes to the calendar tool (access by students)</li>
+	<li>Fixes to the announcement tool (access by students)</li>
+	<li>Fixes to the group tool (default group settings)</li>
+	<li>Bugfix: complete export in survey tool displayed the question of all the surveys and not only those of the selected survey</li>
+    <li>Bugfix:
+registering a new user resulted in the language field of the user being
+empty which resulted in an english profile by default. This has now
+been changed to the platform language. </li>
+    <li>Performance improvement in the user list of the platform administration </li>
+	<li>Bugfix: group tutors were not migrated from 1.6 to 1.8</li>
+	<li>SCORM export: fixes in export method</li>
+	<li>Documentation is now fully XHTML 1.0 Transitional compliant</li>
+	<li>Fix FCKeditor Flash upload lack of usability and problems with IE</li>
+</ul>
+<br />
+<h3>Known issues</h3>
+<ul>
+    <li>Audiorecorder takes a few seconds to write the audio file
+back to the document directory, so the page shouldn't be changed too
+quickly after recording a sound track</li>
+    <li>When migrating from 1.6 to 1.8, some SCORM learning paths might need to be re-imported, which means their tracking is lost</li>
+</ul>
+<hr style="width: 100%; height: 2px;" />
+
+<h1>Dokeos 1.8.4 - September 2007</h1>
+<h3>Release notes - summary</h3>
+<p>Dokeos
+1.8.4 is both a features and debuggingmajor release.&nbsp;</p>
+<h3>New Features</h3>
+<ul>
+  <li>Templates. See <a href="http://www.dokeos.com/templates.php">http://www.dokeos.com/templates.php</a></li>
+  <li>Wide Hotspots tests to allow real-life situations simulation</li>
+
+  <li>Flash video import and streaming</li>
+
+  <li>Installation guide renewed. See&nbsp;<a href="http://www.dokeos.com/doc/installation_guide.html">http://www.dokeos.com/doc/installation_guide.html</a></li>
+
+  <li>Added animated Mr Dokeos character : <a href="http://www.dokeos.com/mrdokeos.php">http://www.dokeos.com/mrdokeos.php</a></li>
+
+  <li>English and Dutch teacher manual added</li>
+
+  <li>Assignments form now fills automatically with document title and user name</li>
+
+  <li>Document authoring space now bigger</li>
+
+  <li>IMS/QTI export of tests</li>
+  <li>Export of media (images, Flash, Audio) and tests in SCORM export</li>
+  <li>Agenda default time management for an event improved</li>
+  <li>Oogie PowerPoint converter setup simplified</li>
+  <li>Improved support for other character sets (enabling better support for
+UTF-8 and russian and asian fonts)</li>
+
+</ul>
+
+<br />
+
+<h3>Debugging</h3>
+
+<ul>
+
+  <li>Upgrade script improved : now possible to upgrade direct from 1.6 to 1.8.4.&nbsp;</li>
+  <li>Blogs user rights</li>
+
+  <li>FCK Editor image import</li>
+
+  <li>Videoconferencing slides now include Documents directory of course</li>
+
+  <li>SCORM content can be displayed Full Screen</li>
+
+  <li>SCORM interactions now properly running</li>
+
+  <li>Hotspots tests redesigned and bigger hotspots zone</li>
+
+  <li>Alphabetical sorting of lists fixed</li>
+
+  <li>Excel export in reporting now removes HTML tags</li>
+
+  <li>My profile page display layout</li>
+
+  <li>Import HotPotatoes tests scoring</li>
+
+  <li>Images gallery in Documents bad display</li>
+
+  <li>Agenda default date now more relevant</li>
+
+  <li>Tests random questions order option clarified</li>
+
+  <li>Templates editing and media removal now easier</li>
+
+  <li>Apostrophe bug in Learning path Build mode</li>
+
+  <li>Table of contents wider in Learning path</li>
+
+  <li>Audio player now autostarts</li>
+
+  <li>Spelling mistakes in French and English</li>
+
+  <li>Group features now related to group, not generic</li>
+
+  <li>Blogs SQL errors fixed</li>
+
+  <li>Introduction images were missing in tests reporting</li>
+
+  <li>SCORM export now working</li>
+
+  <li>My agenda Personal events editor bug fixed</li>
+  <li>Oogie PowerPoint import installation easier</li>
+  <li>Time spent on platform tracking improved</li>
+  <li>Course Backup/restore bugs fixed</li>
+  <li>Course copy bugs fixed</li>
+  <li>Default visibility status of learning paths fixed</li>
+  <li>Images gallery display reordering</li>
+  <li>Agenda default time management for an event improved</li>
+  <li>Groups display alphabetical sorting fixed</li>
+
+</ul>
+
+<h1></h1>
+
+<hr style="width: 100%; height: 2px;" />
+<h1>Dokeos 1.8 - May 2007</h1>
+
+
+
+<h3>Release notes - summary</h3>
+
+
+
+<p>Dokeos 1.8 is a major release. The software becomes a complete suite
+including not only a learning management system and a learners
+administration dashboard, but also an easy-to-use authoring system and
+a simple videoconferencing interface.</p>
+
+
+
+<h3>New Features</h3>
+
+
+
+<ul>
+
+
+      <li> Ms-PowerPoint® to Learning Path conversion</li>
+
+
+      <li>Integrated Live Conferencing&nbsp;</li>
+
+
+      <li>Templates and styles for rapid online authoring</li>
+
+
+      <li>Search engine&nbsp;</li>
+
+
+      <li>New question types: hotspots and&nbsp;open answers</li>
+
+
+      <li>Reporting dashboard with export to Ms-Excel</li>
+
+
+      <li>Surveys</li>
+
+
+      <li>Educational blogs</li>
+
+
+      <li>Learning Path: better import and export of SCORM, IMS and  AICC </li>
+
+
+      <li>Documents tool: PowerPoint and Word into HTML file type  conversion</li>
+
+
+      <li>Tests tool: less sequential and more user-friendly</li>
+
+
+      <li>Forum : better admin and content management</li>
+
+
+      <li>code cleanup </li>
+
+
+      <li>new nice looking icons</li>
+
+
+      <li>new layout for the course homepage</li>
+
+
+      <li>Version check: be informed when a new Dokeos release is available.  </li>
+
+
+      <li>Platform Statistics so you can boast with your campus. </li>
+
+
+
+</ul>
+
+
+
+<h1></h1>
+
+<hr style="width: 100%; height: 2px;" />
+<h1>Dokeos 1.6.5 - July 2006 </h1>
+
+
+
+<h3>Release notes - summary</h3>
+
+
+
+<p>Security Release. 1 bug has been fixed. Click the link below to see the complete list of bugfixes<br />
+
+
+      <a href="http://www.dokeos.com/wiki/index.php/Dokeos_1.6.5_release_notes_and_changelog">http://www.dokeos.com/wiki/index.php/Dokeos_1.6.5_release_notes_and_changelog</a></p>
+
+
+
+<h1>Dokeos 1.6.4 April 2006 </h1>
+
+
+
+<h3>Release notes - summary</h3>
+
+
+
+<p>Bugfix release. 2 bugs have been fixed. One security hole has been fixed <br />
+
+
+    Click the link below to see the complete list of bugfixes<br />
+
+
+    <a href="http://www.dokeos.com/wiki/index.php/Dokeos_1.6.4_release_notes_and_changelog">http://www.dokeos.com/wiki/index.php/Dokeos_1.6.4_release_notes_and_changelog</a></p>
+
+
+
+<h1>Dokeos 1.6.3 February 2006 </h1>
+
+
+
+<h3>Release notes - summary</h3>
+
+
+
+<p>Bugfix release. 44 bugs have been fixed. Click the link below to see the complete list of bugfixes<br />
+
+
+    <a href="http://www.dokeos.com/wiki/index.php/Dokeos_1.6.3_release_notes_and_changelog">http://www.dokeos.com/wiki/index.php/Dokeos_1.6.3_release_notes_and_changelog</a> </p>
+
+
+
+<h1>Dokeos 1.6.2 - September 2005</h1>
+
+
+
+<h3>Release notes - summary</h3>
+
+
+
+<p>Bugfix release. 14 bugs have been fixed. Click the link below to see the complete list of bugfixes<br />
+
+
+    <a href="http://www.dokeos.com/wiki/index.php/Dokeos_1.6.2_release_notes_and_changelog">http://www.dokeos.com/wiki/index.php/Dokeos_1.6.2_release_notes_and_changelog</a></p>
+
+
+
+<h1>Dokeos 1.6.1 - August 2005</h1>
+
+
+
+<h3>Release notes - summary</h3>
+
+
+
+<p>Bugfix release. 31 bugs have been fixed. Click the link below to see the complete list of bugfixes<br />
+
+
+    <a href="http://www.dokeos.com/wiki/index.php/Dokeos_1.6.1_release_notes_and_changelog">http://www.dokeos.com/wiki/index.php/Dokeos_1.6.1_release_notes_and_changelog</a></p>
+
+
+
+<h1>Dokeos 1.6 - July 2005</h1>
+
+
+
+<h3>Release notes - summary</h3>
+
+
+
+<p>In Dokeos 1.6, security and interoperability have been improved. Protection<br />
+
+
+      for documents has improved, and courses have more accessibility options.<br />
+
+
+      Password encryption is enabled by default. The php.ini setting <br />
+
+
+    "register globals" does not have be on anymore.<br />
+
+
+    <a href="http://www.dokeos.com/wiki/index.php/Dokeos_1.6_release_notes">http://www.dokeos.com/wiki/index.php/Dokeos_1.6_release_notes </a></p>
+
+
+
+<h3>New Features</h3>
+
+
+
+<ul>
+
+
+      <li>Campus home page can be edited online</li>
+
+
+      <li> Improved translations, made with the new Dokeos translation tool</li>
+
+
+      <li> Language switch - when you enter the portal, you can choose your language.</li>
+
+
+      <li> Who is online: a list of users who are logged in, you can click to see
+        their pictures and portfolio, or click to talk to them through our built-in web chat tool.</li>
+
+
+      <li>Learning path - import and export of SCORM packages, improved layout,
+        prerequisites based on score in tests</li>
+
+
+      <li> Agenda - many new options, e.g. every user can add personal agenda items.</li>
+
+
+      <li>Document tool - many new options, improved layout, improved HtmlArea</li>
+
+
+      <li> Security - PHP register globals setting don't need to be on anymore</li>
+
+
+      <li> Administration section - all functions are easier to access, you can
+        configure many options through the web interface instead of by digging through the code. </li>
+
+
+      <li> Improved course management - completely rewritten course import/export
+        functions, easily copy content from one course to another</li>
+
+
+      <li> Plugins and modularity - new system to add plugins to Dokeos more easily</li>
+
+
+      <li> API libraries - our function libraries have been expanded and improved</li>
+
+
+      <li>Interoperability: support for SCORM import/export, XML import/export for
+        some features, IEEE LOM Metadata support in documents and groups, import of
+        Hotpotatoes, connection with QuestionMark (this last one will be available
+        as plugin).</li>
+
+
+
+</ul>
+
+
+
+<h3>Roadmap</h3>
+
+
+
+<p><a href="http://www.dokeos.com/wiki/index.php/Roadmap_1.6">http://www.dokeos.com/wiki/index.php/Roadmap_1.6</a></p>
+
+
+
+<h1>Dokeos 1.5.5   </h1>
+
+
+
+<ul>
+
+
+      <li>Learning path : Scorm content import tool</li>
+
+
+      <li> WYSIWYG editor : create content on the fly</li>
+
+
+      <li> Table of contents : structure content on the fly</li>
+
+
+      <li> Dropbox : peer2peer content sharing management</li>
+
+
+      <li> Links categories : structure links catalogue</li>
+
+
+      <li>New navigation : one click to tool</li>
+
+
+      <li> Events since my last visit : be informed of what has changed since your last login</li>
+
+
+      <li> My agenda : synthetic weekly view of all the events related to you</li>
+
+
+      <li> Add a picture to my profile : see who is who</li>
+
+
+      <li> Security : privacy and anti-cracking protection</li>
+
+
+      <li> 5 more languages : russian, catalan, vietnamese, brazilian, thai and a revised chinese</li>
+
+
+      <li> New chat tool : real-time textual discussion</li>
+
+
+      <li> Audio &amp; video conference : real-time live broadcasting of events + textual interaction with ore than 200 people.</li>
+
+
+      <li> Announcements to some users or some groups only</li>
+
+
+      <li> Time-based learning management : add resources to time line in Agenda</li>
+
+
+      <li> Audio &amp; video in Tests tool : create listening comprehensions, situation-based questions on the fly</li>
+
+
+      <li> Forum thread/flat view : see discussions in more detail</li>
+
+
+      <li>Forum email notification : get an email when your forum topic is active</li>
+
+
+      <li> language revision : dokeos vocabulary has been generalised to be adapted
+        to different types of organisations and not only universities</li>
+
+</ul>
+  </div>
+</div>
+<hr />
+    <a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-xhtml10-blue" alt="Valid XHTML 1.0 Transitional" style="margin: 1em; float: right;" height="31" width="88" /></a>
+	<a href="http://jigsaw.w3.org/css-validator/">
+		<img src="http://jigsaw.w3.org/css-validator/images/vcss-blue" style="margin: 1em; float: right;" alt="Valid CSS" />
+	</a>
+</body></html>

+ 63 - 38
documentation/credits.html

@@ -2,7 +2,7 @@
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head>
   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 
-  <title>Dokeos Credits</title><link rel="stylesheet" href="default.css" type="text/css" media="screen,projection" />
+  <title>Chamilo Credits</title><link rel="stylesheet" href="default.css" type="text/css" media="screen,projection" />
   <link rel="shortcut icon" href="./favicon.ico" type="image/x-icon" />
   <style type="text/css">
 	<!--
@@ -14,18 +14,26 @@
 
 <body>
 <div id="header1">
-  <h1>Dokeos Credits</h1>
+  <h1>Chamilo Credits</h1>
 </div>
 <a href="index.html">Documentation</a> &gt; Credits
-<h1>Creator</h1>
+<h1>Creator (2000)</h1>
 
-Thomas De Praetere (thomas.depraetere@dokeos.com)
+Thomas De Praetere (thomas.depraetere@dokeos.com) 
 
 <h1>Core developers</h1>
 <ol>
-  <li>Dokeos.com
+  <li>BeezNest Latino (aka Dokeos Latinoamérica) (2008-2010)
+  <ul>
+    <li>Yannick Warnier (ywarnier@beeznest.org) - Lead developer</li>
+    <li>Julio Allen Montoya Armas (gugli100@gmail.com) - Lead latino developer</li>
+    <li>Christian Fasanando (christian534@hotmail.com)</li>
+    <li>Isaac Flores (florespaz_isaac@hotmail.com)</li>
+    <li>Carlos Vargas</li>
+  </ul>
+  </li>
+  <li>Dokeos (2004-2009)
   <ul>
-    <li>Yannick Warnier (ywarnier@beeznest.org)</li>
     <li>Arnaud Ligot (arnaud@cblue.be)</li>
     <li>Noel Dieschburg (noel@cblue.be)</li>
     <li>Frédéric Burlet (fburlet@cblue.be)</li>
@@ -42,7 +50,7 @@ Thomas De Praetere (thomas.depraetere@dokeos.com)
   </ul>
   </li>
 
-  <li>Ghent University
+  <li>Ghent University (2004-2007)
     <ul>
       <li>Patrick Cool (patrick.cool@ugent.be)</li>
       <li>Bert Vanderkimpen (bert.vanderkimpen@ugent.be)</li>
@@ -51,31 +59,27 @@ Thomas De Praetere (thomas.depraetere@dokeos.com)
     </ul>
   </li>
 
-  <li>Hogeschool Gent
+  <li>Hogeschool Gent (2004-2007)
   <ul>
     <li> Bart Mollet (bart.mollet@hogent.be)</li>
   </ul>
   </li>
 
-  <li>Independent
+  <li>Independent (2008-2010)
   <ul>
     <li> Juan Carlos Raña Trabado - considerable work on the wiki integration and improvements, and the FCKEditor/Mimetex extension as well as *many* FCKEditor's file manager and other modules improvements, as well as a continuous stream of recommendations that helped shape 1.8.5 and 1.8.6.*</li>
     <li> Ivan Tcholakov - various bugfixes in 1.8.6.*, very accurate bug reporting contributions and a considerable work in the integration of a new version of FCKEditor, along with a bunch of useful plugins and an exceptional work on internationalization</li>
   </ul>
   </li>
-  <li>Dokeos Latinoamerica
-  <ul>
-    <li>Julio Allen Montoya Armas (gugli100@gmail.com)</li>
-    <li>Isaac Flores (florespaz_isaac@hotmail.com)</li>
-    <li>Christian Fasanando (christian534@hotmail.com)</li>
-  </ul>
-  </li>
 </ol>
 
+<h1>Quality Assurance</h1>
+<ul>
+  <li>Arthur Portugal</li>
+  <li>Ricardo Rodriguez</li>
+</ul>
 
-<h1>System performance and Reliability improvements</h1>
-
-
+<h1>System performance</h1>
 <ul>
   <li>Arnaud Ligot (arnaud.ligot@dokeos.com)</li>
   <li>Jérôme Warnier (jerome.warnier@dokeos.com)</li>
@@ -86,22 +90,24 @@ Thomas De Praetere (thomas.depraetere@dokeos.com)
 <h1>Developments</h1>
 <h2>Announcement tool </h2>
 
-first versions by
+First versions by
 <ul>
   <li>Pablo Rey (prey@cesga.es)</li>
-  <li> Roan Embrechts  (roan.embrechts@vub.ac.be)</li>
+  <li>Roan Embrechts  (roan.embrechts@vub.ac.be)</li>
 </ul>
 
 rewritten by
 <ul>
   <li>Patrick Cool (patrick.cool@ugent.be)</li>
-  <li> Frederik Vermeire </li>
+  <li>Frederik Vermeire </li>
 </ul>
 
 
 <h2>Agenda</h2>
 <ul>
   <li>Patrick Cool (patrick.cool@UGent.be)</li>
+  <li>Carlos Vargas (global agenda)</li>
+  <li>Yannick Warnier (web services)</li>
 </ul>
 
 
@@ -113,8 +119,6 @@ rewritten by
 
 
 <h2>Course navigation menu</h2>
-
-
 <ul>
   <li>Sandra Mathijs</li>
   <li> Roan Embrechts  (roan.embrechts@vub.ac.be)</li>
@@ -123,8 +127,6 @@ rewritten by
 
 
 <h2>Course copy</h2>
-
-
 <ul>
   <li>Bart Mollet (bart.mollet@hogent.be)</li>
   <li>Yannick Warnier (yannick.warnier@dokeos.com)</li>
@@ -166,8 +168,7 @@ rewritten by
   <li>Patrick Cool (patrick.cool@UGent.be)</li>
 </ul>
 
-<h2>Extensions and plugins</h2>
-see also http://www.dokeos.com/extensions/
+<h2>Extensions and plugins</h2>see also http://www.dokeos.com/extensions/
 <ul>
   <li>Yannick Warnier (yannick.warnier@dokeos.com)</li>
   <li>Patrick Cool (patrick.cool@UGent.be)</li>
@@ -179,6 +180,7 @@ see also http://www.dokeos.com/extensions/
   <li>First version:</li>
   <li>Adapted from PHPBB 1.4 (http://www.phpbb.com)</li>
   <li>Modifications: Patrick Cool (patrick.cool@ugent.be)</li>
+  <li>Julio Montoya Armas (gugli100@gmail.com)</li>
   <li>Management of scoring of threads:</li>
   <li>Christian Fasanando</li>
   <li>Isaac Flores</li>
@@ -212,6 +214,7 @@ see also http://www.dokeos.com/extensions/
 </ul>
 <h2>Interface and CSS</h2>
 <ul>
+  <li>Julio Montoya Armas (gugli100@gmail.com)</li>
   <li>Noa Orizales Iglesias (noa@contidosdixitais.com)</li>
   <li>Sandra Matthys</li>
   <li>Wolfgang Schneider (webmaster@bibelcenter.de)</li>
@@ -241,10 +244,11 @@ see also http://www.dokeos.com/extensions/
 
 <h2>LDAP</h2>
 <ul>
-  <li>Main code: L'université Jean Monnet de Saint Etienne</li>
+  <li>Main code: University Jean Monnet of Saint Etienne</li>
   <li>Updates and improvements:</li>
   <li>Evie Embrechts</li>
   <li>Yannick Warnier</li>
+  <li>Mustapha Alouani - Université Paris 1 (Sorbonne)</li>
 </ul>
 
 <h2>Link tool</h2>
@@ -341,11 +345,18 @@ see also http://www.dokeos.com/extensions/
 
 <h2>Social Network</h2>
 <ul>
+  <li>Thanks to Universidad San Ignacio de Loyola, Lima for the sponsoring of this development</li>
   <li>Julio Montoya Armas (gugli100@gmail.com)</li>
   <li>Isaac Flores</li>
+  <li>Christian Fasanando</li>
 </ul>
 
-
+<h2>Platform group tool</h2>
+<ul>
+  <li>Thanks to Universidad San Ignacio de Loyola, Lima for the sponsoring of this development</li>
+  <li>Julio Montoya Armas (gugli100@gmail.com)</li>
+  <li>Christian Fasanando</li>
+</ul>
 
 <h2>User Image</h2>
 <ul>
@@ -397,19 +408,35 @@ see also http://www.dokeos.com/extensions/
   <li>Patrick Cool (patrick.cool@UGent.be)</li>
   <li>Eric Marguin</li>
   <li>Yannick Warnier</li>
+  <li>Social network improvements: Julio Montoya Armas (gugli100@gmail.com)</li>
+</ul>
+
+<h2>Web services</h2>
+<ul>
+  <li>Yannick Warnier</li>
+  <li>Christian Fasanando</li>
+</ul>
+
+<h2>Conectivity with CMS (Drupal, Joomla)</h2>
+<ul>
+  <li>Fernando P. García</li>
+  <li>Marco Villegas Vega</li>
+  <li>Yannick Warnier</li>
+  <li>Furio Petrossi (for the hint on JFusion)</li>
+  <li>Carlos Vargas (for extending the JFusion plugin to Dokeos 1.8.6)</li>
 </ul>
 
 <h1>Online Authoring</h1>
 <ul>
   <li>First integration: HTMLArea</li>
   <li>Second integration: FCKEditor</li>
-  <li>Update to FCKEditor 2.6.2: Julio Montoya Armas</li>
+  <li>Update to FCKEditor 2.6.2: Julio Montoya Armas(gugli100@gmail.com)</li>
   <li>Update to FCKEditor 2.6.4 and addition of other plugins: Ivan Tcholakov</li>
 </ul>
 
 <h1>Translations</h1>
 There are too much translators to list them all. <br />
-Please see http://www.dokeos.com/DLTT/ to see a list of the translators.
+Please see http://www.chamilo.com/DLTT/ to see a list of the translators.
 
 <h1>Documentation</h1>
 <ul>
@@ -455,10 +482,8 @@ Please see http://www.dokeos.com/DLTT/ to see a list of the translators.
   <li> Mustapha Alouani for his work on dynamic LDAP import tool</li>
   <li> Simon Zalar for a patch to FCKeditor 2.2 allowing linking in FF3</li>
   <li> Daniel Enrique Perales Gomez, for various bugfixes in various tools</li>
-  <li> Arthur Jonathan Portugal Guerrero, for his patient work on the
-technical documentation and his thorough testing of 1.8.6 features and implementing the first browser-based tests set</li>
-  <li> Michela Karina Mosquera Guardamino, for helping improve the visibility
-of Dokeos in the Latin American area, patiently answering crazy amounts
+  <li> Arthur Jonathan Portugal Guerrero, for his patient work on the technical documentation and his thorough testing of 1.8.6 features and implementing the first browser-based tests set</li>
+  <li> Michela Karina Mosquera Guardamino, for helping improve the visibility of Dokeos in the Latin American area, patiently answering crazy amounts
 of information requests and organizing great community events</li>
   <li> Jhon Rhoos Hinojosa Portuguez, for various bugfixes in 1.8.6</li>
   <li> Carlos Vargas, for a huge amount of bugfixes in 1.8.6</li>
@@ -467,7 +492,7 @@ of information requests and organizing great community events</li>
   <li> Ricardo Rodriguez, for implementing the first set of unit tests in 1.8.6, and manual testing and reporting</li>
   <li> Franco Cedillo, for minor bugfixes in 1.8.6</li>
   <li> Ruben Pereira, Ana Elena Olivera and all the kids from the Joaquin Sant'Anna school for being an inspiration to all of us.</li>
-
+  <li> Wolfgang Schneider for various bugfixes in various tools</li>
 </ul>
 
 <h1>Removed developments</h1>
@@ -488,4 +513,4 @@ of information requests and organizing great community events</li>
 	<a href="http://jigsaw.w3.org/css-validator/">
 		<img src="http://jigsaw.w3.org/css-validator/images/vcss-blue" style="margin: 1em; float: right;" alt="Valid CSS" />
 	</a>
-</body></html>
+</body></html>

+ 2 - 2
documentation/default.css

@@ -1,4 +1,4 @@
-/* Default Style Sheet for Dokeos  (in progress ...)
+/* Default Style Sheet for Chamilo
    2004-07-18 by Wolfgang Schneider
    (info@ws-webservice.de / webmaster@bibelcenter.de)
    updated on 2005-02-25 by Olivier Brouckaert
@@ -593,7 +593,7 @@ div.admin_section h4 {
 	padding: 5px;
 }
 
-/* Styles for the Dokeos Config Settings of the platform admin section*/
+/* Styles for the Chamilo Config Settings of the platform admin section*/
 .settingtitle{
 	background-color: #EFEFEF;
 	border: 1px solid #cccccc;

+ 8 - 8
documentation/dependencies.html

@@ -2,7 +2,7 @@
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head>
   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 
-  <title>Dokeos 1.8.6 Server Dependencies</title><link rel="stylesheet" href="default.css" type="text/css" media="screen,projection" />
+  <title>Chamilo 1.8.6.2 Server Dependencies</title><link rel="stylesheet" href="default.css" type="text/css" media="screen,projection" />
   <link rel="shortcut icon" href="./favicon.ico" type="image/x-icon" />
   <style type="text/css">
 	<!--
@@ -14,16 +14,16 @@
 
 <body>
 <div id="header1">
-<h1>Dokeos 1.8.6 Svalbard : Server Dependencies</h1>
+<h1>Chamilo 1.8.6.2 Salto : Server Dependencies</h1>
 </div>
 <a href="index.html">Documentation</a> &gt;Dependencies
 <h2>Introduction</h2>
-<p>In the ever-evoluting web environment, Dokeos has to rely on state-of-the-art third-party
+<p>In the ever-evoluting web environment, Chamilo has to rely on state-of-the-art third-party
   software in order to provide you with useful and practical features. Some of this third-party software
   usually come bundled with your operating system, but some don't. This means that if that software is
-  not installed on your Dokeos server, along with Dokeos, you might not enjoy the best possible
-  experience with your Dokeos platform. To avoid this problem, most of the sofware we used is bundled
-  into a typical Dokeos install.</p><p>
+  not installed on your Chamilo server, along with Chamilo, you might not enjoy the best possible
+  experience with your Chamilo platform. To avoid this problem, most of the sofware we used is bundled
+  into a typical Chamilo install.</p><p>
   However, if such a third-party software is too big to be included, or if it doesn't make sense to
   includ it for whatever reason, you must make sure it is installed on your system.
   This is the goal of this list: to help you keep a track of what software is needed and,
@@ -34,8 +34,8 @@
 <ul>
   <li> Apache 1.3 or 2</li>
   <li> PHP5.0.0+ with MySQL bindings and php-gd extension to allow
-Dokeos to resize pictures. Progressive upload bar only works with
-PHP5.2.0+. </li>
+Chamilo to resize pictures. Progressive upload bar only works with
+PHP5.2.0+. Chamilo doesn't officially support PHP 5.3 for now.</li>
   <li> MySQL database server 4 or 5</li>
 </ul><br />
 <a name="included_dependencies"></a>

+ 6 - 6
documentation/index.html

@@ -2,7 +2,7 @@
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head>
   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 
-  <title>Dokeos 1.8.6.1</title><link rel="stylesheet" href="default.css" type="text/css" media="screen,projection" />
+  <title>Chamilo 1.8.6.2</title><link rel="stylesheet" href="default.css" type="text/css" media="screen,projection" />
   <link rel="shortcut icon" href="./favicon.ico" type="image/x-icon" />
   <style type="text/css">
 	<!--
@@ -14,19 +14,19 @@
 
 <body>
 <div id="header1">
-<h1>Dokeos FREE 1.8.6.1 <span style="font-style: italic;">Babel</span> - Documentation</h1>
+<h1>Chamilo 1.8.6.2 <span style="font-style: italic;"></span> - Documentation</h1>
 </div>
 
 <div id="outerframe">
 <div id="main">
-<h1>About Dokeos</h1>
-<p><a href="readme.html">About Dokeos</a>     </p>
+<h1>About Chamilo</h1>
+<p><a href="readme.html">About Chamilo</a>     </p>
 <h1>Installing and upgrading</h1>
 <a href="installation_guide.html">English installation guide</a>
 <a href="installation_guide_es_ES.html">Spanish installation guide</a>
-<p> Are you interested in translating the installation guide to your own language? The best way to proceed is to ask us on the <a href="http://www.dokeos.com/forum/">Dokeos forum</a>
+<p> Are you interested in translating the installation guide to your own language? The best way to proceed is to ask us on the <a href="http://forum.chamilo.org">Chamilo forum</a>
 for the latest version – there may be updates to the guide since
-this version was released – and send new translations off to the <a href="mailto:translation@dokeos.com">translation@dokeos.com</a> email address. </p>
+this version was released – and send new translations off to the <a href="mailto:translation@chamilo.com">translation@chamilo.com</a> email address. </p>
 
 <h1>License</h1>
 <a href="license.html">GNU General Public License Version 2</a>

+ 3 - 3
documentation/install_red5.txt

@@ -1,11 +1,11 @@
-Dokeos Red5 applications
+Chamilo Red5 applications
 ========================
 
 Table of contents
 -----------------
 1. Installation
 1.1. Red5
-1.2. Dokeos Red5 Application
+1.2. Chamilo Red5 Application
 
 2. Configuration
 
@@ -29,7 +29,7 @@ From now on, we will refer to red5 home directory by $RED5_HOME.
 
 [1] http://osflash.org/red5
 
-1.2. Dokeos Red5 Application
+1.2. Chamilo Red5 Application
 
 To install either the recorder or the videoconference application, the only step that needs to be done is to copy the .war file in the $RED5_HOME/webapps directory.
 You have to restart red5 to get the applications deployed inside red5. You can install both applications inside red5. They can run together

+ 117 - 145
documentation/installation_guide.html

@@ -2,7 +2,7 @@
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
 	<head>
 	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-	<title>Dokeos 1.8.6.2 Installation Guide</title><link rel="stylesheet" href="default.css" type="text/css" media="screen,projection" />
+	<title>Chamilo 1.8.6.2 Installation Guide</title><link rel="stylesheet" href="default.css" type="text/css" media="screen,projection" />
 	<link rel="shortcut icon" href="./favicon.ico" type="image/x-icon" />
 	<style type="text/css">
 	<!--
@@ -10,13 +10,13 @@
 		pre { font-family: "Courier New", monospace }
 		p { margin-bottom: 0.21cm }
 		.code {margin: 1em 1em 1em 2em; padding: 0.5em; background-color: rgb(229, 229, 229); vertical-align: top; border: 1px solid #999999;}
-	--></style>
+	-->
+	</style>
 	</head>
 <body>
 
-
 <div id="header1">
-	<h1>Dokeos 1.8.6.2 FREE : Installation Guide</h1>
+	<h1>Chamilo 1.8.6.2 : Installation Guide</h1>
 </div>
 
 <a href="index.html">Documentation</a> &gt; Installation Guide
@@ -24,19 +24,13 @@
 <div id="main">
 <p></p>
 
-
-<p>Thank you for downloading Dokeos Babel FREE.</p>
-
-
+<p>Thank you for downloading Chamilo 1.8.6.2.</p>
 <ul>
-
-  <li>Quick preview of <a href="http://www.dokeos.com/en/node/58">Dokeos features&nbsp;</a></li>
-
-  <li>Test Dokeos on <a href="http://campus.dokeos.com">Free Campus</a></li>
+  <li>Test Chamilo on <a href="http://campus.chamilo.org">Free Campus</a></li>
 </ul>
 
 
-<p>This guide explains how to install Dokeos FREE. Please read this fully before proceeding with the installation.</p>Check <a href="http://www.dokeos.com/en/buy.php">Dokeos PRO</a> and <a href="http://www.dokeos.com/en/buy.php">Dokeos MEDICAL</a> for a complete learning suite with a Service Level Agreement. <br />
+<p>This guide explains how to install Chamilo FREE. Please read this fully before proceeding with the installation.</p>
 
 
 <h2><b>Contents</b></h2>
@@ -44,35 +38,26 @@
 <ol>
 
   <li><a href="#1._Pre-requisites">Pre-requisites</a></li>
-
-  <li><a href="#2._Installation_of_Dokeos_LMS">Installation of Dokeos LMS</a></li>
-
-  <li><a href="#3._Upgrade_from_a_previous_version_of">Upgrade from a previous version of Dokeos</a></li>
-
+  <li><a href="#2._Installation_of_Chamilo_LMS">Installation of Chamilo LMS</a></li>
+  <li><a href="#3._Upgrade_from_a_previous_version_of">Upgrade from a previous version of Chamilo/Dokeos</a></li>
   <li><a href="#4._Troubleshooting">Troubleshooting</a></li>
-
   <li><a href="#5._Administration_section">Administration section</a></li>
-
   <li><a href="#6._LDAP">LDAP&nbsp;</a></li>
-
   <li><a href="#7._Mathematical_formulas">Mathematical formulas with LaTeX</a></li>
 </ol>
 
-
 <br />
-
 <hr style="width: 100%; height: 2px;" />
 <h2><a name="1._Pre-requisites"></a>1. Pre-requisites</h2>
 
-
-Dokeos
+Chamilo
 can be installed on Windows, Linux, Mac OS X and UNIX servers
 indifferently. However, we recommend the use of Linux server for
 optimal flexibility, remote control and scalability. <br />
 
 <br />
 
-Dokeos is mainly a LMS running <span style="font-weight: bold;">Apache 1.3, 2.0</span>, <span style="font-weight: bold;">MySQL 5.1</span> and <span style="font-weight: bold;">PHP 5.1</span> (the so called <span style="font-weight: bold;">AMP</span> trilogy). <br />
+Chamilo is mainly a LMS running <span style="font-weight: bold;">Apache 1.3, 2.0</span>, <span style="font-weight: bold;">MySQL 5.1</span> and <span style="font-weight: bold;">PHP 5.1</span> (the so called <span style="font-weight: bold;">AMP</span> trilogy). <br />
 
 
 <br />
@@ -81,7 +66,7 @@ All these software are open source and freely available. <br />
 
 <br />
 
-To run Dokeos <span style="font-weight: bold;">LMS</span> on your server, you need to install WAMP, LAMP or MAMP:
+To run Chamilo <span style="font-weight: bold;">LMS</span> on your server, you need to install WAMP, LAMP or MAMP:
 <ul>
 
   <li>To install <span style="font-weight: bold;">WAMP</span> (AMP on Windows), we recommend the <a href="http://www.apachefriends.org/en/xampp.html">XAMPP</a> .exe installer<a href="http://www.apachefriends.org/en/xampp.html"></a></li>
@@ -101,29 +86,28 @@ For instance, on a Ubuntu server,&nbsp;use Shell or Synaptic following the
 <h3><span style="font-weight: bold;">MySQL database server</span></h3>
 
 You will need a login and password allowing to administrate and create
-at least one database. By default, Dokeos will create a new database
+at least one database. By default, Chamilo will create a new database
 for each course created. It means your host should allow you to create
-and administrate several databases. You can also install Dokeos using
+and administrate several databases. You can also install Chamilo using
 only one database, in that case you have to select this option during
 the installation.<span style="font-weight: bold;"><br />
 
 </span>
 <hr style="width: 100%; height: 2px;" />
-<h2><a name="2._Installation_of_Dokeos_LMS"></a><span style="font-weight: bold;">2. Installation of Dokeos LMS</span></h2>
+<h2><a name="2._Installation_of_Chamilo_LMS"></a><span style="font-weight: bold;">2. Installation of Chamilo LMS</span></h2>
 
-<a href="http://www.dokeos.com/download.php"></a>
 <ul>
 
-  <li><a href="http://www.dokeos.com/node/33">Download Dokeos LMS</a></li>
+  <li><a href="http://www.chamilo.org/download">Download Chamilo LMS</a></li>
 
   <li>Unzip it</li>
 
-  <li>Copy the dokeos directory in your Apache web directory. This can be
+  <li>Copy the Chamilo directory in your Apache web directory. This can be
     <span style="font-weight: bold;">C:\xampp\htdocs\</span> on a Windows server or <span style="font-weight: bold;">/var/www/html/</span> on a Linux server</li>
 
   <li>Open your web browser (Internet Explorer, Firefox...) and type
-    <span style="font-weight: bold;">http://localhost/dokeos/</span> if you install locally or
-    <span style="font-weight: bold;">http://www.domain.com/dokeos/</span> if you install remotely</li>
+    <span style="font-weight: bold;">http://localhost/chamilo/</span> if you install locally or
+    <span style="font-weight: bold;">http://www.domain.com/chamilo/</span> if you install remotely</li>
 
   <li>Follow the web installation process. You can accept all default
 values. Consider changing the admin password to remember it.&nbsp;</li>
@@ -135,15 +119,15 @@ values. Consider changing the admin password to remember it.&nbsp;</li>
 The following directories need to be readable, writeable and executable for everyone:
 <ul>
 
-  <li>dokeos/main/inc/conf/</li>
-  <li>dokeos/main/upload/users/</li>
-  <li>dokeos/main/default_course_document/</li>
-  <li>dokeos/archive/</li>
-  <li>dokeos/courses/</li>
-  <li>dokeos/home/</li>
+  <li>chamilo/main/inc/conf/</li>
+  <li>chamilo/main/upload/users/</li>
+  <li>chamilo/main/default_course_document/</li>
+  <li>chamilo/archive/</li>
+  <li>chamilo/courses/</li>
+  <li>chamilo/home/</li>
 </ul>
 
-(where 'dokeos' is the directory in which you installed Dokeos)
+(where 'chamilo' is the directory in which you installed Chamilo)
 <p>On Linux, Mac OS X and BSD operating systems you can use the CHMOD
 777 command for this (although we recommend you seek advice from an
 experienced system administrator).
@@ -156,7 +140,7 @@ only during the installation process:</p>
 
 <ul>
 
-  <li>dokeos/main/inc/conf/configuration.php (if present)</li>
+  <li>chamilo/main/inc/conf/configuration.php (if present)</li>
 </ul>
 
 
@@ -173,7 +157,7 @@ folders (by right-clicking on them).</p>
 <b>NOTES:</b><br />
 
 Do not modify the home_*.html files directly. Instead,
-choose "Configure the homepage" in the Dokeos administration section.</p>
+choose "Configure the homepage" in the Chamilo administration section.</p>
 
 <p><span style="font-weight: bold;">Windows</span> : with combination packages like XAMPP, out of the box, login and password
    for MySQL should probably remain empty.</p>
@@ -186,14 +170,14 @@ choose "Configure the homepage" in the Dokeos administration section.</p>
 <ul>
 
   <li><strong>Protect your configuration file: </strong>
-make sure no one can overwrite it. You can find the config file in <em>(dokeos folder)</em>/main/inc/conf/configuration.php.
+make sure no one can overwrite it. You can find the config file in <em>(chamilo folder)</em>/main/inc/conf/configuration.php.
 Make it read-only (windows/xwindows: right-click the file to edit the
 properties. linux/bsd/macosx: use the chmod 444 command). The config
 file is created by Apache so you may need to be root user to change its
 permissions.</li>
 
   <li><strong>Protect your installation folder: </strong>
-if the <em>(dokeos folder)</em>/main/install
+if the <em>(chamilo folder)</em>/main/install
 folder is still accessible, someone could install over your existing
 version (you could lose your data that way). Move the folder somewhere
 out of the web directories so it is not accessible, change its name, or
@@ -203,17 +187,17 @@ edit its properties so no one can read or execute it.</li>
 making the files world-writable will help you install, and solves many
 issues for people without much admin experience. However, it's better
 security to make the owner of the apache process (often called apache
-or www-data) also owner of all the dokeos files and folders. Ths way,
+or www-data) also owner of all the chamilo files and folders. Ths way,
 these files need only be readable and writable by the Apache process
 owner, not by the entire world.</li>
 
-  <li><strong>Configure your Dokeos installation: </strong>
-in the administration section of Dokeos, you can use the Dokeos Config Settings to adjust the behavior of your installation.</li>
+  <li><strong>Configure your Chamilo installation: </strong>
+in the administration section of Chamilo, you can use the Chamilo Config Settings to adjust the behavior of your installation.</li>
 
-  <li><strong>Configure Dokeos mail: </strong>
-most of Dokeos uses the mail settings from the php.ini file. However,
+  <li><strong>Configure Chamilo mail: </strong>
+most of Chamilo uses the mail settings from the php.ini file. However,
 the announcements tool uses phpMailer (another free software project)
-and the settings for this tool can be adjusted in <em>(dokeos folder)</em>/main/inc/conf/mail.conf.php.</li>
+and the settings for this tool can be adjusted in <em>(chamilo folder)</em>/main/inc/conf/mail.conf.php.</li>
 </ul>
 
 <br />
@@ -222,7 +206,7 @@ and the settings for this tool can be adjusted in <em>(dokeos folder)</em>/main/
 <h3>PHP configuration</h3>
 
 
-To get the best of Dokeos, you need to finetune PHP settings. Consider : <br />
+To get the best of Chamilo, you need to finetune PHP settings. Consider : <br />
 
 <ul>
 
@@ -236,70 +220,59 @@ To get the best of Dokeos, you need to finetune PHP settings. Consider : <br />
 
 
 <div class="code">
-			  max_execution_time = 300&nbsp;&nbsp;&nbsp; ; Maximum execution time of each script, in seconds<br />
-
-			  max_input_time = 600 ; Maximum amount of time each script may spend parsing request data<br />
-
-			  memory_limit = 256M&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ; Maximum amount of memory a script may consume (128MB)<br />
-
-			  post_max_size = 64M<br />
-
-			  upload_max_filesize = 100M</div>
-
-
+	  max_execution_time = 300&nbsp;&nbsp;&nbsp; ; Maximum execution time of each script, in seconds<br />
+	  max_input_time = 600 ; Maximum amount of time each script may spend parsing request data<br />
+	  memory_limit = 256M&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ; Maximum amount of memory a script may consume (128MB)<br />
+	  post_max_size = 64M<br />
+	  upload_max_filesize = 100M
+</div>
 
-<p>
-Some users could meet problems if their PHP settings don't fit
+<p>Some users could meet problems if their PHP settings don't fit
 these ones:</p>
 
 <ul>
-
   <li>short_open_tag       = On</li>
-
   <li>safe_mode            = Off</li>
-
   <li>magic_quotes_gpc     = On</li>
-
   <li>magic_quotes_runtime = Off</li>
 </ul>
 
-
-
 <p>
-Past Dokeos versions required register_globals to be set to On. This is
-no longer necessary, this can be set to Off and Dokeos will work fine.</p>
+Past Chamilo versions required register_globals to be set to On. This is
+no longer necessary, this can be set to Off and Chamilo will work fine.</p>
 
+<p><strong>Note:</strong> if you are using PHP 5.3 or higher, you need to set your <em>date.timezone</em> setting to whatever your server's timezone is.
+For example, if your server is in the 'America/New_York' timezone, set this in your php.ini:</p>
+
+<div class="code">
+date.timezone = 'America/New_York'
+</div>
 
 <p><strong>BSD users:</strong> these php libraries have to be included during php installation:</p>
 
 <ul>
   <li>php-mysql The mysql shared extension for php</li>
-
   <li>php-pcre The pcre shared extension for php</li>
-
   <li>php-session The session shared extension for php</li>
-
-  <li>php-zlib The zlib shared extension for php</li>
-    
+  <li>php-zlib The zlib shared extension for php</li>    
   <li>(optional) php-ldap if you want to be able to use LDAP authentication</li>
 </ul>
 
 <p>You might also add the following php modules and packages:</p>
 <ul>
-<li>php-ctype</li>
-<li>php-gd</li>
-<li>php-iconv</li>
-<li>php-json</li> 
-<li>php-mbstring</li>
-<ul>
-<p><a href="http://dev.mysql.com/doc/mysql/en/index.html"></a><br />
-</p>
+	<li>php-ctype</li>
+	<li>php-gd</li>
+	<li>php-iconv</li>
+	<li>php-json</li> 
+	<li>php-mbstring</li>
+</ul>
+<p><a href="http://dev.mysql.com/doc/mysql/en/index.html"></a><br /></p>
 
 
 <hr />
-<h2><a name="3._Upgrade_from_a_previous_version_of"></a>3. Upgrade from a previous version of Dokeos</h2>
+<h2><a name="3._Upgrade_from_a_previous_version_of"></a>3. Upgrade from a previous version of Chamilo/Dokeos</h2>
 Before upgrading we <b>heavily</b> recommend you do a full backup of the previous
-Dokeos directories and databases. If you are unsure how to achieve this
+Chamilo/Dokeos directories and databases. If you are unsure how to achieve this
 please ask your hosting provider for advice.<br />
 
 <p></p>
@@ -311,8 +284,8 @@ please ask your hosting provider for advice.<br />
 <em>If you upgrade from Dokeos 1.8.x</em> :&nbsp;
 <ul>
   <li> check that you haven't left any customised stylesheet or image*</li>
-  <li> download the Dokeos 1.8.6 Svalbard install package from the <a href="http://www.dokeos.com/en/node/33">Dokeos download page</a></li>
-  <li> unzip the new files of Dokeos 1.8.6 over the files of the older version</li>
+  <li> download the Chamilo 1.8.6.2 Salto install package from the <a href="http://www.chamilo.org/download">Chamilo download page</a></li>
+  <li> unzip the new files of Chamilo 1.8.6.2 over the files of the older version (or unzip the files in one folder and then copy the files from there to the older version's directory)</li>
   <li> point your browser on your portal URL + main/install/</li>
   <li> choose your language and click&nbsp;<span style="font-style: italic;">Upgrade from 1.8.x</span></li>
 </ul>
@@ -340,7 +313,7 @@ to the old ones which will be deprecated shortly (not maintained).</font>
 and most important thing to do is to *move* your current directory to another
 place.<br />
 An easy way to do that is to create a subdirectory called "old_version"
-in your current Dokeos directory and move everything in there using a
+in your current Chamilo/Dokeos directory and move everything in there using a
 simple "move" command (i.e. under Linux: mkdir old_version; mv *
 old_verion/), then make the old_version/ directory writeable by the web
 server so that courses/ and upload/ directories can be moved from the
@@ -352,11 +325,11 @@ The complete process is as follow:
     <em>old_version</em> and make it writeable by the web server. This
 is important to allow the move of the courses/ and upload/ directories
 to the new install</li>
-  <li> download the Dokeos 1.8.6 install package from the
-    <a href="http://www.dokeos.com/en/node/33">Dokeos download page</a></li>
-  <li> unzip the new files of Dokeos 1.8.6 in the main Dokeos directory. The
+  <li> download the Chamilo 1.8.6.2 install package from the
+    <a href="http://www.chamilo.org/download">Chamilo download page</a></li>
+  <li> unzip the new files of Chamilo 1.8.6.2 in the main Chamilo/Dokeos directory. The
 new directory <em>main</em> should be located directly inside your
-Dokeos root folder</li>
+Chamilo/Dokeos root folder</li>
   <li> point your browser on your portal URL</li>
   <li> choose your language and click&nbsp;<span style="font-style: italic;">Upgrade from 1.6.x</span> and confirm the
 current directory of the old version</li>
@@ -377,7 +350,7 @@ all the 1.8.x versions
 <p>
 <b>WARNING:</b><br />
 
-Do not delete the previous Dokeos installation directory before installing
+Do not delete the previous Chamilo/Dokeos installation directory before installing
 the new one. When the update is successfully finished, you can remove
 the old path.</p>
 
@@ -386,24 +359,24 @@ the old path.</p>
 <b>NOTE:</b><br />
 
 Do not modify the home_*.html files directly. Instead,
-choose "Configure the homepage" in the Dokeos administration section.</p>
+choose "Configure the homepage" in the Chamilo administration section.</p>
 
 <p></p>
 <h3>3.3 In both cases</h3>
 
 The following directories need to be readable, writeable and executable for the web server:
 <ul>
-  <li>dokeos/main/inc/conf/</li>
-  <li>dokeos/main/upload/users/</li>
-  <li>dokeos/main/default_course_document/</li>
-  <li>dokeos/archive/</li>
-  <li>dokeos/courses/</li>
-  <li>dokeos/home/</li>
+  <li>chamilo/main/inc/conf/</li>
+  <li>chamilo/main/upload/users/</li>
+  <li>chamilo/main/default_course_document/</li>
+  <li>chamilo/archive/</li>
+  <li>chamilo/courses/</li>
+  <li>chamilo/home/</li>
 </ul>
 
 On Linux, Mac OS X and BSD operating systems you can quick-fix this using the
 CHMOD 777 command, but if you are unsure, we recommend you seek advice for
-your own OS on <a href="http://www.dokeos.com/en/node/66">our forum</a>.
+your own OS on <a href="http://www.chamilo.org/forum">our forum</a>.
 In Windows, you may need to check the properties of the folders.
 <p></p>
 <h3>3.4 Quick-upgrade from 1.6.x guide for Linux</h3>
@@ -411,8 +384,8 @@ In Windows, you may need to check the properties of the folders.
 
 The following quick-upgrade guide assumes that:
 <ul>
-  <li>the Dokeos database username (for MySQL) is "dokeos_db_user" and your login is "dokeos_user"</li>
-  <li>the Dokeos installation is currently in /var/www/dokeos/ and it has 777 permissions</li>
+  <li>the Chamilo database username (for MySQL) is "chamilo_db_user" and your login is "chamilo_user"</li>
+  <li>the chamilo installation is currently in /var/www/chamilo/ and it has 777 permissions</li>
   <li>your portal's URL is http://www.portalurl.com/</li>
 </ul>
 
@@ -422,16 +395,16 @@ The following quick-upgrade guide assumes that:
 On the command-line, type:
 <ul>
   <li>cd /tmp</li>
-  <li>mysqldump -u dokeos_db_user -p --all-databases --result-file=/home/dokeos_user/dokeos_old.sql</li>
-  <li>cp -ra /var/www/dokeos /home/dokeos_user/backup_dokeos</li>
-  <li>mkdir /var/www/dokeos/old_version</li>
-  <li>mv /var/www/dokeos/* /var/www/dokeos/old_version/</li>
-  <li>chmod -R 0777 /var/www/dokeos/old_version/</li>
-  <li>wget http://www.dokeos.com/download/dokeos-1.8.6.tar.gz</li>
-  <li>tar zxvf dokeos-1.8.6.tar.gz</li>
-  <li>sudo cp -ra dokeos-1.8.6/* /var/www/dokeos/</li>
-  <li>rm dokeos-1.8.6.tar.gz</li>
-  <li>sudo rm -r dokeos-1.8.6/</li>
+  <li>mysqldump -u chamilo_db_user -p --all-databases --result-file=/home/chamilo_user/chamilo_old.sql</li>
+  <li>cp -ra /var/www/chamilo /home/chamilo_user/backup_chamilo</li>
+  <li>mkdir /var/www/chamilo/old_version</li>
+  <li>mv /var/www/chamilo/* /var/www/chamilo/old_version/</li>
+  <li>chmod -R 0777 /var/www/chamilo/old_version/</li>
+  <li>wget http://www.chamilo.org/files/chamilo-1.8.6.2.tar.gz</li>
+  <li>tar zxvf chamilo-1.8.6.2.tar.gz</li>
+  <li>sudo cp -ra chamilo-1.8.6.2/* /var/www/chamilo/</li>
+  <li>rm chamilo-1.8.6.2.tar.gz</li>
+  <li>sudo rm -r chamilo-1.8.6.2/</li>
 </ul>
 
 <br />
@@ -453,10 +426,10 @@ Then:
 <h2><a name="4._Troubleshooting"></a>4. Troubleshooting</h2>
 
 
-<p>If you have&nbsp;problems, go to the <a href="http://www.dokeos.com">Dokeos website</a> and ask a question on the
-<a href="http://www.dokeos.com/en/node/66">support forum</a>. Please read the previous messages first to see if there is
+<p>If you have&nbsp;problems, go to the <a href="http://www.chamilo.org">Chamilo website</a> and ask a question on the
+<a href="http://forum.chamilo.org">support forum</a>. Please read the previous messages first to see if there is
 already an answer to your question. We also maintain a list of
-<a href="http://www.dokeos.com/wiki/index.php/FAQ">Frequently Asked Questions</a>.</p>
+<a href="http://wiki.chamilo.org">Frequently Asked Questions</a>.</p>
 
 
 <h2></h2>
@@ -465,8 +438,8 @@ already an answer to your question. We also maintain a list of
 <hr style="width: 100%; height: 2px;" />
 <h2><a name="5._Administration_section"></a>5. Administration section</h2>
 
-<p>To access the Dokeos administration section, open browser,
-go to your Dokeos adress and log in with the admin user.
+<p>To access the Chamilo administration section, open browser,
+go to your Chamilo adress and log in with the admin user.
 Then you will see a "Platform admin section" link in the header of the
 web page. There you can manage users, courses, sessions, portal look
 and feel, homepage content, course categories etc.&nbsp;</p>
@@ -478,7 +451,7 @@ and feel, homepage content, course categories etc.&nbsp;</p>
 <p>
 <i>This part is optional, only organisations with an LDAP server will need to read this.</i><br />
 
-An LDAP module is already provided in Dokeos, but it has to be configured to make it work.</p>
+An LDAP module is already provided in Chamilo, but it has to be configured to make it work.</p>
 
 
 <h3><b>Compiling</b></h3>
@@ -488,11 +461,11 @@ Linux servers: It's possible that you have to recompile php with ldap support.
 Newer distributions also allow downloading rpms for additional packages.</p>
 
 
-<h3><b>Activating LDAP in Dokeos</b></h3>
+<h3><b>Activating LDAP in Chamilo</b></h3>
 
 
 <p>
-In (dokeos folder)/main/inc/conf/configuration.php, around line 90, you see<br />
+In (chamilo folder)/main/inc/conf/configuration.php, around line 90, you see<br />
 
 //for new login module<br />
 
@@ -522,7 +495,7 @@ Ask the LDAP server admin for the settings:</p>
   <li>ldap dc</li>
 </ul>
 Since 1.8.5, you have to change the LDAP settings inside the "Portal
-administration" panel, under "Dokeos configuration settings", section
+administration" panel, under "Chamilo configuration settings", section
 "LDAP".
 <br />
 
@@ -540,7 +513,7 @@ LDAP domain: "dc=xx, dc=yy, dc=zz"; //domain<br />
 <h3><b>Teacher/student status</b></h3>
 
 <p>
-By default, Dokeos will check if the "employeenumber" field has a value. If it has, then Dokeos will
+By default, Chamilo will check if the "employeenumber" field has a value. If it has, then Chamilo will
 consider this user as being a teacher.<br />
 
 If you want to change this behaviour, you can edit main/auth/ldap/authldap.php, function ldap_put_user_info_locally(),
@@ -555,7 +528,7 @@ You can also remove this check by removing the condition and leaving only the <e
 <p>
 Some LDAP servers do not support anonymous use of the directory services.<br />
 In this case, you should fill in the appropriate fields in the
-administration panel (e.g. "manager" and "mypassword") and Dokeos will
+administration panel (e.g. "manager" and "mypassword") and Chamilo will
 try to authenticate using these, or fall back to anonymous mode before
 giving up.</p>
 
@@ -563,15 +536,15 @@ giving up.</p>
 <h3>LDAP import into sessions</h3>
 
 <p>There is a new set of scripts now that allow you to insert users
-from LDAP directly into a Dokeos session. This, however, relies on a
+from LDAP directly into a Chamilo session. This, however, relies on a
 set of static choices in the LDAP contact attributes.<br />
 
-The fields used intensively by the Dokeos module are:<br />
+The fields used intensively by the Chamlio module are:<br />
 </p>
 
 <ul>
 
-	<li>uid, which is matched to the username in Dokeos</li>
+	<li>uid, which is matched to the username in Chamilo</li>
 
 	<li>userPassword, which is matched to the user password, although
 this part will only work for non-encrypted passwords for now, but it
@@ -581,11 +554,11 @@ shouldn't be necessary if using the LDAP server as authentication</li>
 criteria you will use to filter users, so that they can be retrieved on
 that criteria</li>
 
-	<li>sn is used as the lastname field in Dokeos</li>
+	<li>sn is used as the lastname field in Chamilo</li>
 
-	<li>givenName is used as the firstname field in Dokeos</li>
+	<li>givenName is used as the firstname field in Chamilo</li>
 
-	<li>mail is used as the email field in Dokeos</li>
+	<li>mail is used as the email field in Chamilo</li>
 </ul>
 
 
@@ -594,15 +567,15 @@ that criteria</li>
 
 <i>This part is optional, only organisations planning to use mathematical formulas inside the online editor might want to read this.</i><br /><br />
 
-You can enable mathematical equations writing inside the Dokeos online editor (FCKEditor) by applying the following steps:
+You can enable mathematical equations writing inside the Chamilo online editor (FCKEditor) by applying the following steps:
 <ul>
 
 	<li>1. Configure your Apache installation to add a cgi-bin directory that contains a symbolic link to the mimetex.cgi in
-<i>dokeos/main/inc/lib/mimetex/</i> (*see below, step 4)</li>
+<i>chamilo/main/inc/lib/mimetex/</i> (*see below, step 4)</li>
 
 	<li>2. Reload your Apache configuration</li>
 
-	<li>3. Edit the online editor's configuration file <i>dokeos/main/inc/lib/fckeditor/myconfig.php</i> and
+	<li>3. Edit the online editor's configuration file <i>chamilo/main/inc/lib/fckeditor/myconfig.php</i> and
 
     <ul>
 			<li>3.1. Enable the mimetex plugin, find the line //$config['LoadPlugin'][] = 'mimetex'; and modify it to be:
@@ -615,7 +588,7 @@ In rare cases these options might need to be twicked, see the acccompanying comm
 these options within the file <i>myconfig.php</i></li>
 
 			<li>3.3. Once the plugin has been activated, almost in all toolbars the corresponding button appears.
-If you need to edit some toolbars, see the configuration files (php) within the directory <i>dokeos/main/inc/lib/fckeditor/toolbars/</i> .
+If you need to edit some toolbars, see the configuration files (php) within the directory <i>chamilo/main/inc/lib/fckeditor/toolbars/</i> .
 Here is an example:
         <div class="code">$config['ToolbarSets']['Normal'] = array(<br />
 &nbsp;&nbsp;array('FitWindow','Bold','Image','Link','PasteWord','MP3',<b>'mimetex'</b>,'Table','Subscript','Superscript','ShowBlocks')<br />
@@ -647,27 +620,26 @@ Here is an example:
 
 </p>
 <div class="code">
-  <p>ln -s /var/www/dokeos/main/inc/lib/mimetex/mimetex.cgi /var/www/cgi-bin/mimetex.cgi</p>
+  <p>ln -s /var/www/chamilo/main/inc/lib/mimetex/mimetex.cgi /var/www/cgi-bin/mimetex.cgi</p>
 </div>
 <p>If you are reluctant to modify your Apache configuration, alternately you may do at step 4 the following:
-copy mimetex.exe (for windows) or mimetex.cgi (for linux) from <i>dokeos/main/inc/lib/mimetex/</i> directory to your <i>cgi-bin/</i></p>
+copy mimetex.exe (for windows) or mimetex.cgi (for linux) from <i>chamilo/main/inc/lib/mimetex/</i> directory to your <i>cgi-bin/</i></p>
     <li>5. Make sure that the file mimetex.cgi (or mimetex.exe) has right to be executed by the web-server process. For example, on a Ubuntu Linux system you may write a command like the following:</li>
 <div class="code">
   <p>sudo chmod a+x mimetex.cgi</p>
 </div>
 	</ul>
 
-<p>As a result of this procedure, a new button becomes available in your Dokeos online editor, that gives you possibility
+<p>As a result of this procedure, a new button becomes available in your Chamilo online editor, that gives you possibility
 to insert mathematical formulas into your documents.<br />
 
 
   <br />
   <br />
-  Contact address: Dokeos, Rue Victor Hugo, 201,&nbsp;B-1030 Brussels, Belgium<br />
+  Contact address<br />
 
-  Mail: info@dokeos.com<br />
+  Mail: info@chamilo.org<br />
 
-  Tel. +32 (0)2 669 69 55<br />
   <br />
 
 </p>
@@ -681,4 +653,4 @@ to insert mathematical formulas into your documents.<br />
 	<a href="http://jigsaw.w3.org/css-validator/">
 		<img src="http://jigsaw.w3.org/css-validator/images/vcss-blue" style="margin: 1em; float: right;" alt="Valid CSS" />
 	</a>
-</body></html>
+</body></html>

+ 106 - 116
documentation/installation_guide_es_ES.html

@@ -2,7 +2,7 @@
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
 <head>
 	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-	<title>Guia de Instalación de Dokeos 1.8.6.2 Babel</title>
+	<title>Guia de Instalación de Chamilo 1.8.6.2</title>
 	<link rel="stylesheet" href="default.css" type="text/css" media="screen,projection" />
 	<link rel="shortcut icon" href="./favicon.ico" type="image/x-icon" />
 	<style type="text/css">
@@ -19,7 +19,7 @@
 
 
 <div id="header1">
-<h1>Guía de Instalación de Dokeos 1.8.6.2 Babel</h1>
+<h1>Guía de Instalación de Chamilo 1.8.6.2</h1>
 
 </div>
 
@@ -29,24 +29,16 @@
 <p></p>
 
 
-<p>Gracias por descargar Dokeos, la suite de aprendizaje de código abierto profesional.</p>
-
-
-<ul>
-
-  <li>Vista rápida de las <a href="http://www.dokeos.com/en/node/58">Características de Dokeos&nbsp;</a></li>
-
-  <li>Prueba Dokeos en <a href="http://campus.dokeos.com">Free Campus</a></li>
-
+<p>Gracias por descargar Chamilo, la suite de aprendizaje de código abierto profesional.</p>
+<ul>  
+  <li>Prueba Chamilo en <a href="http://campus.chamilo.org">Free Campus</a></li>
 </ul>
 
 
-<p>Esta guía explica como instalar el Sistema de Gestión de Aprendizaje de Dokeos. Explica como instalar la conversión a PowerPoint Dokeos Oogie
-y la videoconferencia de Dokeos, aunque estos paquetes
-no son requeridos para usar Dokeos LMS. &nbsp;Por favor, lea completamente este documento antes de proceder con la instalación. </p>
-
+<p>Esta guía explica como instalar el Sistema de Gestión de Aprendizaje Chamilo. Explica como instalar la conversión a PowerPoint Chamilo Oogie
+y la videoconferencia de Chamilo, aunque estos paquetes
+no son requeridos para usar Chamilo LMS. &nbsp;Por favor, lea completamente este documento antes de proceder con la instalación. </p>
 
-Si desea ahorrar tiempo, problemas y dinero, alternativamente puede tener su Portal de Dokeos <a href="http://www.dokeos.com/en/node/6">desplegado</a> o <a href="http://www.dokeos.com/en/node/32">instalado</a> por Dokeos o alguno de sus socios.<br />
 
 
 <h2><b>Contenidos</b></h2>
@@ -54,19 +46,12 @@ Si desea ahorrar tiempo, problemas y dinero, alternativamente puede tener su Por
 <ol>
 
   <li><a href="#1._Pre-requisites">Prerrequisitos</a></li>
-
-  <li><a href="#2._Installation_of_Dokeos_LMS">Instalación de Dokeos LMS</a></li>
-
-  <li><a href="#3._Upgrade_from_a_previous_version_of">Actualizar desde una versión previa de Dokeos</a></li>
-
+  <li><a href="#2._Installation_of_Chamilo_LMS">Instalación de Chamilo LMS</a></li>
+  <li><a href="#3._Upgrade_from_a_previous_version_of">Actualizar desde una versión previa de Chamilo o Dokeos</a></li>
   <li><a href="#4._Troubleshooting">Solución de Problemas</a></li>
-
   <li><a href="#5._Administration_section">Sección de administración</a></li>
-
   <li><a href="#6._LDAP">LDAP&nbsp;</a></li>
-
   <li><a href="#7._Mathematical_formulas">Fórmulas Matemáticas con LaTeX</a></li>
-
 </ol>
 
 
@@ -76,20 +61,19 @@ Si desea ahorrar tiempo, problemas y dinero, alternativamente puede tener su Por
 <h2><a name="1._Pre-requisites"></a>1. Prerrequisitos</h2>
 
 
-Dokeos
-puede ser instalado indiferentemente en servidores Windows, Linux, Mac OS X y UNIX.
+Chamilo puede ser instalado indiferentemente en servidores Windows, Linux, Mac OS X y UNIX.
 Sin embargo, nosotros recomendamos el uso de un servidor Linux para una óptima flexibilidad,
 control remoto y escalabilidad. <br />
 
 <br />
 
-Dokeos es  un LMS que se ejecuta con <span style="font-weight: bold;">Apache 1.3, 2.0</span>, <span style="font-weight: bold;">MySQL 5.1</span> y <span style="font-weight: bold;">PHP 5.1</span> (trilogía también llamada  <span style="font-weight: bold;">AMP</span>).<br />
+Chamilo es  un LMS que se ejecuta con <span style="font-weight: bold;">Apache 1.3, 2.0</span>, <span style="font-weight: bold;">MySQL 5.1</span> y <span style="font-weight: bold;">PHP 5.1</span> (trilogía también llamada  <span style="font-weight: bold;">AMP</span>).<br />
 
 <br />
 
 
 Puede ser enriquecida con la conversión a &nbsp;PowerPoint (característica llamada Dokeos
-Oogie) mediante el uso de <span style="font-weight: bold;">OpenOffice.org</span> + Java. Quizás  también quiera agregar el plugin de Videoconferencia de Dokeos mediante el uso de <span style="font-weight: bold;">RED5</span>
+Oogie) mediante el uso de <span style="font-weight: bold;">OpenOffice.org</span> + Java. Quizás  también quiera agregar el plugin de Videoconferencia de Chamilo mediante el uso de <span style="font-weight: bold;">RED5</span>
 servidor de código abierto de Flash. <br />
 
 
@@ -99,7 +83,7 @@ Todo este software es software de código abierto y está disponible libremente.
 
 <br />
 
-Para ejecutar Dokeos <span style="font-weight: bold;">LMS</span> en su servidor,  necesita instalar WAMP, LAMP o MAMP:
+Para ejecutar Chamilo <span style="font-weight: bold;">LMS</span> en su servidor,  necesita instalar WAMP, LAMP o MAMP:
 <ul>
 
   <li>Para instalar <span style="font-weight: bold;">WAMP</span> (AMP en Windows),  recomendamos el instalador <a href="http://www.apachefriends.org/en/xampp.html">XAMPP</a> .exe<a href="http://www.apachefriends.org/en/xampp.html"></a></li>
@@ -120,9 +104,9 @@ Por ejemplo, en un servidor Ubuntu,&nbsp;use Shell o Synaptic siguiendo la
 <h3><span style="font-weight: bold;">Servidor de Base de Datos MySQL</span></h3>
 
 Usted necesitará una cuenta de acceso y una contraseña que le permita administrar y crear
-al menos una base de datos. De manera predeterminada, Dokeos creará una nueva base de datos
+al menos una base de datos. De manera predeterminada, Chamilo creará una nueva base de datos
 para cada curso. Esto significa que su proveedor deberá permitirle crear y
-administrar varias bases de datos. Usted también puede instalar Dokeos con una sola base de datos, en ese caso,  deberá seleccionar esta opción durante
+administrar varias bases de datos. Usted también puede instalar Chamilo con una sola base de datos, en ese caso,  deberá seleccionar esta opción durante
 la instalación.
 <br />
 
@@ -143,7 +127,7 @@ Para aprovechar la ventaja de la conversión <span style="font-weight: bold;">Oo
 
 <br />
 
-Para aprovechar la ventaja de la <span style="font-weight: bold;">Videoconferencia</span> de Dokeos, necesita:<br />
+Para aprovechar la ventaja de la <span style="font-weight: bold;">Videoconferencia</span> de Chamilo, necesita:<br />
 
 
 <ul>
@@ -157,21 +141,21 @@ Para aprovechar la ventaja de la <span style="font-weight: bold;">Videoconferenc
 
 </span>
 <hr style="width: 100%; height: 2px;" />
-<h2><a name="2._Installation_of_Dokeos_LMS"></a><span style="font-weight: bold;">2. Instalación de Dokeos LMS</span></h2>
+<h2><a name="2._Installation_of_Chamilo_LMS"></a><span style="font-weight: bold;">2. Instalación de Chamilo LMS</span></h2>
 
-<a href="http://www.dokeos.com/download.php"></a>
+<a href="http://www.chamilo.org/"></a>
 <ul>
 
-  <li><a href="http://www.dokeos.com/node/33">Descargar Dokeos LMS</a></li>
+  <li><a href="http://www.chamilo.org/">Descargar Chamilo LMS</a></li>
 
   <li>Descomprimirlo.</li>
 
-  <li>Copiar el directorio de Dokeos en su directorio web de Apache. Este puede ser
+  <li>Copiar el directorio de Chamilo en su directorio web de Apache. Este puede ser
     <span style="font-weight: bold;">C:\xampp\htdocs\</span> en un servidor Windows o <span style="font-weight: bold;">/var/www/html/</span> en un servidor Linux.</li>
 
   <li>Abrir su navegador web (Internet Explorer, Firefox...) y escribir
-    <span style="font-weight: bold;">http://localhost/dokeos/</span> si se instala de manera local o
-    <span style="font-weight: bold;">http://www.domain.com/dokeos/</span> si se instala remotamente.</li>
+    <span style="font-weight: bold;">http://localhost/chamilo/</span> si se instala de manera local o
+    <span style="font-weight: bold;">http://www.domain.com/chamilo/</span> si se instala remotamente.</li>
 
   <li>Seguir el proceso de instalación web. Usted puede aceptar todos los valores
 predeterminados. Considere cambiar la contraseña de administrador y recuérdela.&nbsp;</li>
@@ -183,15 +167,15 @@ predeterminados. Considere cambiar la contraseña de administrador y recuérdela
 
 Los siguientes directorios necesitan tener permisos de lectura, escritura y ejecución para todos el mundo:
 <ul>
-  <li>dokeos/main/inc/conf/</li>
-  <li>dokeos/main/upload/users/</li>
-  <li>dokeos/main/default_course_document/</li>
-  <li>dokeos/archive/</li>
-  <li>dokeos/courses/</li>
-  <li>dokeos/home/</li>
+  <li>chamilo/main/inc/conf/</li>
+  <li>chamilo/main/upload/users/</li>
+  <li>chamilo/main/default_course_document/</li>
+  <li>chamilo/archive/</li>
+  <li>chamilo/courses/</li>
+  <li>chamilo/home/</li>
 </ul>
 
-(donde 'dokeos' es el directorio en el cual usted instaló Dokeos)
+(donde 'chamilo' es el directorio en el cual usted instaló Chamilo)
 <p>En Linux, Mac OS X y sistemas operativos BSD  puede usar el comando CHMOD
 777 para esto (aunque nosotros recomendamos que busque la ayuda de un
 administrador de sistemas con experiencia).
@@ -201,12 +185,12 @@ del clic derecho en ellos).
 
 <p>
 2.5. Los siguientes archivos necesitan tener permisos de lectura y escritura
-para el navegador web, sólo durante la instalación de Dokeos:
+para el navegador web, sólo durante la instalación de Chamilo:
 </p>
 
 <ul>
 
-  <li>dokeos/main/inc/conf/configuration.php (si está presente)</li>
+  <li>chamilo/main/inc/conf/configuration.php (si está presente)</li>
 
 </ul>
 
@@ -226,7 +210,7 @@ del clic derecho en ellos).
 <b>NOTAS:</b><br />
 
 No modifique los archivos home_*.html directamente. En vez de hacer esto,
-seleccione "Configurar la página de inicio" en la sección de administración de Dokeos.</p>
+seleccione "Configurar la página de inicio" en la sección de administración de Chamilo.</p>
 
 <p><span style="font-weight: bold;">Windows</span> : con paquetes combinados como XAMPP, disponibles por todo lado, la cuenta de acceso y contraseña
    para MySQL probablemente permanecerá vacía.</p>
@@ -239,14 +223,14 @@ seleccione "Configurar la página de inicio" en la sección de administración d
 <ul>
 
   <li><strong>Proteger su archivo de configuración: </strong>
-asegurarse que nadie pueda sobrescribirlo. Usted puede encontrar el archivo de configuración en el <em>(directorio de Dokeos)</em>/main/inc/conf/configuration.php.
+asegurarse que nadie pueda sobrescribirlo. Usted puede encontrar el archivo de configuración en el <em>(directorio de Chamilo)</em>/main/inc/conf/configuration.php.
 Hacerlo de solo lectura (windows/xwindows: clic derecho en el archivo para editar las propiedades.
 linux/bsd/macosx: usar el comando chmod 444). El archivo de
 configuración es creado por Apache, por lo tanto usted necesita ser administrador para cambiar sus
 permisos.</li>
 
   <li><strong>Proteger su directorio de instalación: </strong>
-si el <em>(directorio de Dokeos)</em> directorio /main/install
+si el <em>(directorio de Chamilo)</em> directorio /main/install
 sigue accesible, alguien podría instalar de nuevo sobre la versión existente
 (usted puede perder sus datos de esta manera). Por ello es muy importante que mueva el directorio a algún lugar
 fuera de los directorios web para que no se encuentre accesible, cambie su nombre, o
@@ -256,17 +240,17 @@ edite sus propiedades para que nadie pueda leerlo o ejecutarlo.</li>
 hacer que todos los archivos posean permisos de escritura facilita la instalación y resuelve muchas
 dudas a las personas con poca experiencia en administración. Sin embargo, en lugar de esto, es más seguro
 hacer que el propietario del proceso de Apache (usualmente llamado apache
-o www-data) sea también propietario de todos los archivos y carpetas de Dokeos. De esta manera,
+o www-data) sea también propietario de todos los archivos y carpetas de Chamilo. De esta manera,
 estos archivos sólo tendrán permisos de lectura y escritura para el propietario
 del proceso Apache y  no para todo el mundo.</li>
 
-  <li><strong>Configurar su instalación de Dokeos: </strong>
-en la sección de administración de Dokeos, usted puede usar las Opciones de Configuración de Dokeos para ajustar el comportamiento de su instalación.</li>
+  <li><strong>Configurar su instalación de Chamilo: </strong>
+en la sección de administración de Chamilo, usted puede usar las Opciones de Configuración de Chamilo para ajustar el comportamiento de su instalación.</li>
 
-  <li><strong>Configurar correo de Dokeos: </strong>
-por lo general Dokeos usa las configuraciones de correo del archivo php.ini. Sin embargo,
+  <li><strong>Configurar correo de Chamilo: </strong>
+por lo general Chamilo usa las configuraciones de correo del archivo php.ini. Sin embargo,
 la herramienta de anuncios usa phpMailer (otro proyecto de software libre)
-y las configuraciones para esta herramienta pueden ser ajustadas en <em>(directorio de dokeos)</em>/main/inc/conf/mail.conf.php.</li>
+y las configuraciones para esta herramienta pueden ser ajustadas en <em>(directorio de chamilo)</em>/main/inc/conf/mail.conf.php.</li>
 
 
 </ul>
@@ -277,7 +261,7 @@ y las configuraciones para esta herramienta pueden ser ajustadas en <em>(directo
 <h3>Configuración PHP</h3>
 
 
-Para obtener lo mejor de Dokeos, necesita ajustar la configuración de PHP. Considere: <br />
+Para obtener lo mejor de Chamilo, necesita ajustar la configuración de PHP. Considere: <br />
 
 <ul>
 
@@ -324,10 +308,17 @@ se ajustan a las siguientes:</p>
 
 
 <p>
-En versiones de Dokeos anteriores se requería que register_globals estuviera configurada en On. Esto ya no
-necesario, puede estar configurado en Off y Dokeos funcionará bien.
+En versiones de Chamilo/Dokeos anteriores se requería que register_globals estuviera configurada en On. Esto ya no
+necesario, puede estar configurado en Off y Chamilo funcionará bien.
 </p>
 
+<p><strong>Nota:</strong> si se usa PHP 5.3 o superior, se necesita configurar la variable <em>date.timezone</em> a la zona horaria de su servidor.
+Por ejemplo, si su servidor está en la zona horaria 'America/Lima', modificar en el php.ini:</p>
+
+<div class="code">
+date.timezone = 'America/Lima'
+</div>
+
 
 <p><strong>Usuarios BSD:</strong> estas bibliotecas de php tienen que ser incluidas durante la instalación de php:</p>
 
@@ -352,7 +343,7 @@ necesario, puede estar configurado en Off y Dokeos funcionará bien.
 <li>php-iconv</li>
 <li>php-json</li> 
 <li>php-mbstring</li>
-<ul>
+</ul>
 
 <p><a href="http://dev.mysql.com/doc/mysql/en/index.html"></a><br />
 
@@ -361,9 +352,9 @@ necesario, puede estar configurado en Off y Dokeos funcionará bien.
 
 
 <hr />
-<h2><a name="3._Upgrade_from_a_previous_version_of"></a>3. Actualizar desde una versión previa de Dokeos</h2>
+<h2><a name="3._Upgrade_from_a_previous_version_of"></a>3. Actualizar desde una versión previa de Chamilo/Dokeos</h2>
 Antes de actualizar, le recomendamos <b>seriamente</b> que haga una copia de seguridad de los directorios
-y bases de datos de Dokeos que previamente haya en su servidor. Si no está seguro de cómo hacer esto solicite
+y bases de datos de Chamilo/Dokeos que previamente haya en su servidor. Si no está seguro de cómo hacer esto solicite
 asistencia a su proveedor de servicios de almacenamiento.<br />
 
 <p></p>
@@ -375,8 +366,8 @@ asistencia a su proveedor de servicios de almacenamiento.<br />
 <em>Si usted actualiza desde Dokeos 1.8.x</em> :&nbsp;
 <ul>
   <li> Revisar que  no ha dejado alguna hoja de estilo personalizada o imagen*</li>
-  <li> Descargar el paquete de instalación de Dokeos 1.8.6 desde la <a href="http://www.dokeos.com/en/node/33">página de descarga de Dokeos</a></li>
-  <li> Descomprimir los nuevos archivos de Dokeos 1.8.6 sobre los archivos de la version anterior</li>
+  <li> Descargar el paquete de instalación de Chamilo 1.8.6.2 desde la <a href="http://www.chamilo.org/download">página de descarga de Chamilo</a></li>
+  <li> Descomprimir los nuevos archivos de Chamilo 1.8.6.2 sobre los archivos de la version anterior (o descomprimirlos en una nueva carpeta y después copiarlos sobre los archivos de la versión anterior)</li>
   <li> Apunte su navegador a su portal URL + main/install/</li>
   <li> Escoja su idioma y haga clic en&nbsp;<span style="font-style: italic;">Actualizar desde 1.8.x</span></li>
 </ul>
@@ -415,11 +406,11 @@ El proceso completo es como sigue:
     <em>version_antigua</em> y darle permisos de escritura por el servidor web. Esto
 es importante para permitir mover los directorios courses/ y upload/
 a la nueva instalacion</li>
-  <li> Descargar el paquete de instalacion de Dokeos 1.8.6 desde la
-    <a href="http://www.dokeos.com/en/node/33">página de descarga de Dokeos</a></li>
-  <li> descomprimir los nuevos archivos de Dokeos 1.8.6 en el directorio principal de Dokeos. El nuevo
+  <li> Descargar el paquete de instalacion de Chamilo 1.8.6.2 desde la
+    <a href="http://www.chamilo.org/download">página de descarga de Chamilo</a></li>
+  <li> descomprimir los nuevos archivos de Chamilo 1.8.6.2 en el directorio principal de Chamilo. El nuevo
 directorio <em>principal</em> debe estar ubicado directamente dentro de su
-directorio raiz de Dokeos</li>
+directorio raiz de Chamilo</li>
   <li> Apuntar su navegador a la URL de su portal</li>
   <li> Escoja su idioma y haga clic en&nbsp;<span style="font-style: italic;">Actualizar desde 1.6.x</span> y confirme el
 directorio actual de la versión antigua</li>
@@ -440,7 +431,7 @@ todas las versiones 1.8.x
 <p>
 <b>ADVERTENCIA:</b><br />
 
-No elimine el directorio de instalación previo de Dokeos antes de instalar
+No elimine el directorio de instalación previo de Chamilo/Dokeos antes de instalar
 el nuevo. Usted puede eliminar la ruta antigua, cuando la actualización haya finalizado satisfactoriamente.
 </p>
 
@@ -449,7 +440,7 @@ el nuevo. Usted puede eliminar la ruta antigua, cuando la actualización haya fi
 <b>NOTA:</b><br />
 
 No modifique los archivos de home_*.html directamente. En lugar de ello,
-seleccione "Configurar la página de inicio" en la sección de administración de Dokeos.
+seleccione "Configurar la página de inicio" en la sección de administración de Chamilo.
 </p>
 
 <p>
@@ -458,17 +449,17 @@ seleccione "Configurar la página de inicio" en la sección de administración d
 
 Los siguientes directorios necesitan permisos de lectura, escritura y ejecución para el servidor web:
 <ul>
-  <li>dokeos/main/inc/conf/</li>
-  <li>dokeos/main/upload/users/</li>
-  <li>dokeos/main/default_course_document/</li>
-  <li>dokeos/archive/</li>
-  <li>dokeos/courses/</li>
-  <li>dokeos/home/</li>
+  <li>chamilo/main/inc/conf/</li>
+  <li>chamilo/main/upload/users/</li>
+  <li>chamilo/main/default_course_document/</li>
+  <li>chamilo/archive/</li>
+  <li>chamilo/courses/</li>
+  <li>chamilo/home/</li>
 </ul>
 
 En Linux, Mac OS X y sistemas operativos BSD esto se puede arreglar rápidamente  mediante el uso
 del comando CHMOD 777, sin embargo si usted no está seguro,  le recomandamos que busque
-asistencia para su propio SO en <a href="http://www.dokeos.com/en/node/66">nuestro foro</a>.
+asistencia para su propio SO en <a href="http://www.chamilo.org/forum">nuestro foro</a>.
 En Windows, quizás necesite revisar las propiedades de las carpetas.
 <p>
 </p>
@@ -477,8 +468,8 @@ En Windows, quizás necesite revisar las propiedades de las carpetas.
 
 La siguiente guía de actualización rápida rapida asume lo siguiente:
 <ul>
-  <li>El nombre de usuario de la base de datos de Dokeos (para MySQL) es "dokeos_db_user" y su acceso es "dokeos_user"</li>
-  <li>Actualmente la instalacion de Dokeos esta en /var/www/dokeos/ y tiene permisos 777</li>
+  <li>El nombre de usuario de la base de datos de Chamilo (para MySQL) es "chamilo_db_user" y su acceso es "chamilo_user"</li>
+  <li>Actualmente la instalacion de Chamilo/Dokeos esta en /var/www/chamilo/ y tiene permisos 777</li>
   <li>La URL de su portal es http://www.portalurl.com/</li>
 </ul>
 
@@ -488,16 +479,16 @@ La siguiente guía de actualización rápida rapida asume lo siguiente:
 Escribir en la línea de comandos:
 <ul>
   <li>cd /tmp</li>
-  <li>mysqldump -u dokeos_db_user -p --all-databases --result-file=/home/dokeos_user/dokeos_old.sql</li>
-  <li>cp -ra /var/www/dokeos /home/dokeos_user/backup_dokeos</li>
-  <li>mkdir /var/www/dokeos/version_antigua</li>
-  <li>mv /var/www/dokeos/* /var/www/dokeos/version_antigua/</li>
-  <li>chmod -R 0777 /var/www/dokeos/version_antigua/</li>
-  <li>wget http://www.dokeos.com/download/dokeos-1.8.6.tar.gz</li>
-  <li>tar zxvf dokeos-1.8.6.tar.gz</li>
-  <li>sudo cp -ra dokeos-1.8.6/* /var/www/dokeos/</li>
-  <li>rm dokeos-1.8.6.tar.gz</li>
-  <li>sudo rm -r dokeos-1.8.6/</li>
+  <li>mysqldump -u chamilo_db_user -p --all-databases --result-file=/home/chamilo_user/chamilo_old.sql</li>
+  <li>cp -ra /var/www/chamilo /home/chamilo_user/backup_chamilo</li>
+  <li>mkdir /var/www/chamilo/version_antigua</li>
+  <li>mv /var/www/chamilo/* /var/www/chamilo/version_antigua/</li>
+  <li>chmod -R 0777 /var/www/chamilo/version_antigua/</li>
+  <li>wget http://www.chamilo.org/files/chamilo-1.8.6.2.tar.gz</li>
+  <li>tar zxvf chamilo-1.8.6.2.tar.gz</li>
+  <li>sudo cp -ra chamilo-1.8.6.2/* /var/www/chamilo/</li>
+  <li>rm chamilo-1.8.6.2.tar.gz</li>
+  <li>sudo rm -r chamilo-1.8.6.2/</li>
 </ul>
 
 <br />
@@ -519,10 +510,10 @@ Luego:
 <h2><a name="4._Troubleshooting"></a>4. Solución de problemas</h2>
 
 
-<p>Si usted tiene problemas, vaya al <a href="http://www.dokeos.com">Sitio Web de Dokeos</a> y haga una pregunta en el
-<a href="http://www.dokeos.com/en/node/66">foro de soporte</a>. Por favor, primero lea los mensajes previos para ver si existe ya
+<p>Si usted tiene problemas, vaya al <a href="http://www.chamilo.org">Sitio Web de Chamilo</a> y haga una pregunta en el
+<a href="http://www.chamilo.org/forum">foro de soporte</a>. Por favor, primero lea los mensajes previos para ver si existe ya
 una respuesta a su pregunta. Nosotros también mantenemos una lista de
-<a href="http://www.dokeos.com/wiki/index.php/FAQ">Preguntas Frecuentes</a>.
+<a href="http://www.chamilo.org/FAQ">Preguntas Frecuentes</a>.
 </p>
 
 
@@ -532,8 +523,8 @@ una respuesta a su pregunta. Nosotros también mantenemos una lista de
 <hr style="width: 100%; height: 2px;" />
 <h2><a name="5._Administration_section"></a>5. Sección de Administración</h2>
 
-<p>Para acceder a la sección de administración de Dokeos, abra el navegador,
-diríjase a su dirección de Dokeos y acceda a el con el usuario admin.
+<p>Para acceder a la sección de administración de Chamilo, abra el navegador,
+diríjase a su dirección de Chamilo y acceda a el con el usuario admin.
 Luego usted verá un enlace a la "Seccion de administracion de la plataforma" en la parte superior
 de la página web. En ese lugar usted puede administrar usuarios, cursos, secciones, apariencia del portal
 contenido de la página principal, categorías de cursos, entre otros.</p>
@@ -546,7 +537,7 @@ contenido de la página principal, categorías de cursos, entre otros.</p>
 <p>
 <i>Esta parte es opcional, solamente organizaciones con un servidor LDAP necesitan leer esto.</i><br />
 
-Un modulo LDAP está ya implementado en Dokeos, pero debe ser configurado para que tenga un correcto funcionamiento.
+Un modulo LDAP está ya implementado en Chamilo, pero debe ser configurado para que tenga un correcto funcionamiento.
 </p>
 
 
@@ -558,11 +549,11 @@ Distribuciones nuevas también permiten descargar rpms para los paquetes adicion
 </p>
 
 
-<h3><b>Activar LDAP en Dokeos</b></h3>
+<h3><b>Activar LDAP en Chamilo</b></h3>
 
 
 <p>
-En (la carpeta de Dokeos)/main/inc/conf/configuration.php, aproximadamente en la line 90, se puede ver<br />
+En (la carpeta de Chamilo)/main/inc/conf/configuration.php, aproximadamente en la line 90, se puede ver<br />
 
 //for new login module<br />
 
@@ -595,7 +586,7 @@ Solicitar al administrador del servidor LDAP los siguientes datos:
 
 </ul>
 Desde 1.8.5, usted tiene que cambiar las configuraciones de LDAP dentro del panel
-"Administración del Portal", bajo "Opciones de configuración de Dokeos", sección
+"Administración del Portal", bajo "Opciones de configuración de Chamilo", sección
 "LDAP".
 <br />
 
@@ -613,7 +604,7 @@ dominio LDAP: "dc=xx, dc=yy, dc=zz"; //dominio<br />
 <h3><b>Estado Profesor/Estudiante</b></h3>
 
 <p>
-De manera predeterminada, Dokeos revisará si el campo "employeenumber" tiene un valor. Si lo tiene, entonces Dokeos
+De manera predeterminada, Chamilo revisará si el campo "employeenumber" tiene un valor. Si lo tiene, entonces Chamilo
 considerará que este usuario es profesor.<br />
 
 Si usted desea cambiar este comportamiento, usted puede editar main/auth/ldap/authldap.php, la función ldap_put_user_info_locally(),
@@ -629,34 +620,34 @@ Adicionalmente usted puede suprimir esta revisión, eliminando la condición y d
 <p>
 Algunos servidores LDAP no permiten usos anónimos de los servicios del directorio.<br />
 En este caso, usted debe rellenar los campos apropiados en el
-panel de administración (ej. "manager" y "mypassword") y Dokeos tratará
+panel de administración (ej. "manager" y "mypassword") y Chamilo tratará
 de autentificarse usando esto, o volver al modo anónimo antes de darse por vencido.</p>
 
 
 <h3>Importar LDAP en sesiones</h3>
 
 <p>Existe un nuevo grupo de scripts que permiten  insertar usuarios
-desde LDAP directamente a una sesión de Dokeos. Sin embargo, esto se basa en un
+desde LDAP directamente a una sesión de Chamilo. Sin embargo, esto se basa en un
 conjunto de opciones estáticas en los atributos de contacto de LDAP.<br />
 
-Los campos usados intensivamente por el módulo de Dokeos son:<br />
+Los campos usados intensivamente por el módulo de Chamilo son:<br />
 
 </p>
 
 <ul>
 
-	<li>uid, el cual se corresponde con el username en Dokeos</li>
+	<li>uid, el cual se corresponde con el username en Chamilo</li>
 	<li>userPassword, el cual se corresponde con la contraseña del usuario. Aunque esta parte, por ahora, solamente funcionará con contraseñas no encriptadas,  no será necesaria si se usa el servidor LDAP para la autentificación.</li>
 
 	<li>ou debe terminar con el año de registro de la persona o cualquier
 criterio que usted use para filtrar a los usuarios, de manera que ellos puedan obtenerse
 con ese criterio</li>
 
-	<li>sn es usadl como el campo lastname en Dokeos</li>
+	<li>sn es usado como el campo lastname en Chamilo</li>
 
-	<li>givenName es usado como el campo firstname en Dokeos</li>
+	<li>givenName es usado como el campo firstname en Chamilo</li>
 
-	<li>mail es usado como el campo email en Dokeos</li>
+	<li>mail es usado como el campo email en Chamilo</li>
 
 </ul>
 
@@ -666,14 +657,14 @@ con ese criterio</li>
 
 <i>Esta parte es opcional, sólo interesa a las organizaciones que deseen usar fórmulas matemáticas dentro del editor en línea.</i><br />
 
-Usted puede habilitar la escritura de ecuaciones matemáticas dentro del editor en línea de Dokeos (FCKEditor) aplicando los siguientes pasos:
+Usted puede habilitar la escritura de ecuaciones matemáticas dentro del editor en línea de Chamilo (FCKEditor) aplicando los siguientes pasos:
 <ul>
 
-	<li>1. Configurar su instalación de Apache para agregar un directorio cgi-bin que contenga un enlace simbólico a mimetex.cgi en <i>dokeos/main/inc/lib/mimetex/</i>(*ver debajo)</li>
+	<li>1. Configurar su instalación de Apache para agregar un directorio cgi-bin que contenga un enlace simbólico a mimetex.cgi en <i>chamilo/main/inc/lib/mimetex/</i>(*ver debajo)</li>
 
 	<li>2. Recargar su configuración de Apache</li>
 
-	<li>3. Editar <i>dokeos/main/inc/lib/fckeditor/myconfig.js</i> y
+	<li>3. Editar <i>chamilo/main/inc/lib/fckeditor/myconfig.js</i> y
 
     <ul>
 
@@ -693,7 +684,7 @@ FCKConfig.ToolbarSets donde usted desee que el icono de LaTeX aparezca
     </ul>
 	  </li>
 
-	<li>4. En raras ocasiones puede ser necesario realizar ajustes manuales editando el fichero /dokeos/main/inc/lib/fckeditor/fckeditor.php</li>
+	<li>4. En raras ocasiones puede ser necesario realizar ajustes manuales editando el fichero /chamilo/main/inc/lib/fckeditor/fckeditor.php</li>
 
 	<li>5. Limpiar la cache de su navegador para probarlo (muy importante). Esto se puede hacer mediante el uso de la página de configuraciones de su navegador</li>
 
@@ -724,10 +715,10 @@ FCKConfig.ToolbarSets donde usted desee que el icono de LaTeX aparezca
 acceso directo al archivo mimetex.exe desde el directorio cgi-bin, o bajo
 Linux usando el siguiente comando:</i>
 
-<div class="code">ln -s /var/www/dokeos/main/inc/lib/mimetex/mimetex.cgi /var/www/cgi-bin/mimetex.cgi</div>
+<div class="code">ln -s /var/www/chamilo/main/inc/lib/mimetex/mimetex.cgi /var/www/cgi-bin/mimetex.cgi</div>
 <p>Si no quiere modificar su Apache, alternativamente a  este punto 6: copie mimetex.exe (para Windows) o mimetex.cgi (para Linux) en su cgi-bin/ </p>
 <p>&nbsp;</p>
-<p>Este procedimiento creará un nuevo icono en su editor en línea de Dokeos, el cual hará posible la inserción de fórmulas matemáticas en sus documentos.<br />
+<p>Este procedimiento creará un nuevo icono en su editor en línea de Chamilo, el cual hará posible la inserción de fórmulas matemáticas en sus documentos.<br />
   <br />
 
 
@@ -735,11 +726,10 @@ Linux usando el siguiente comando:</i>
   <br />
   <br />
 
-  Dirección de Contacto: Dokeos, Rue du Corbeau, 108, B-1030 Brussels, Belgium<br />
+  Dirección de Contacto: Chamilo<br />
 
-  Correo: info@dokeos.com<br />
+  Correo: info@chamilo.org<br />
 
-  Tel. +32 (0)2 669 69 55<br />
   <br />
 
 </p>

+ 2 - 2
documentation/license.html

@@ -2,7 +2,7 @@
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
 <head>
   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-  <title>Dokeos License</title>
+  <title>Chamilo License</title>
   <link rel="stylesheet" href="default.css" type="text/css" media="screen,projection" />
   <link rel="shortcut icon" href="./favicon.ico" type="image/x-icon" />
   <style type="text/css">
@@ -15,7 +15,7 @@
 </head>
 <body>
 <div id="header1">
-<h1>Dokeos License</h1>
+<h1>Chamilo License</h1>
 </div>
 <a href="index.html">Documentation</a> &gt; Gnu General Public License
 <div id="outerframe">

+ 28 - 50
documentation/readme.html

@@ -1,18 +1,8 @@
 <!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="en" lang="en"><head>
-
-
   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-
-
-
-
-  <title>Dokeos Information</title><link rel="stylesheet" href="default.css" type="text/css" media="screen,projection" />
-
-
+  <title>Chamilo Information</title><link rel="stylesheet" href="default.css" type="text/css" media="screen,projection" />
   <link rel="shortcut icon" href="./favicon.ico" type="image/x-icon" />
-
-
   <style type="text/css">
 	<!--
 		@page { size: 21cm 29.7cm; margin: 2cm }
@@ -20,25 +10,23 @@
 		p { margin-bottom: 0.21cm }
 		.code {margin: 1em 1em 1em 2em; padding: 0.5em; background-color: rgb(229, 229, 229); vertical-align: top; border: 1px solid #999999;}
 	--></style></head>
-
 <body>
-
 <div id="header1">
-<h1>About Dokeos</h1>
+<h1>About Chamilo</h1>
 
 </div>
 
-<a href="index.html">Documentation</a> &gt; About Dokeos
+<a href="index.html">Documentation</a> &gt; About Chamilo
 <div id="outerframe">
 <div id="main">
-<p>Dokeos is an elearning and course management web application,<br />
+<p>Chamilo is an elearning and course management web application,<br />
 
-      and is free software (GNU GPL). It's translated into 30 languages,<br />
+      and is free software (GNU/GPLv2). It's translated into more 30 languages,<br />
 
-      SCORM compliant, and light and flexible.</p>
+      SCORM compatible, light and flexible.</p>
 
 
-<p>Dokeos supports many different kinds of learning and collaboration activities.<br />
+<p>Chamilo supports many different kinds of learning and collaboration activities.<br />
 
       Teachers/trainers can create, manage and publish their courses through the web.<br />
 
@@ -47,32 +35,34 @@
       through groups, forums, chat.</p>
 
 
-<p>Technically, Dokeos is a web application written in PHP that stores data in a <br />
+<p>Technically, Chamilo is a web application written in PHP that stores data in a <br />
 
-      MySQL database. Users access it using a web browser.</p>
+      MySQL database. Users access it using a web browser. The first stable version of Chamilo, 1.8.6.2 Salto, is based on the Dokeos 1.8.6.1 code and is meant to be the next software step for institutions currently using Dokeos.</p>
 
 
 <p>If you would like to know more or help develop this software, please visit<br />
 
-      our homepage at <a href="http://www.dokeos.com">http://www.dokeos.com</a></p>
+      our homepage at <a href="http://www.chamilo.org">http://www.chamilo.org</a></p>
 
 
 <h1>SCORM</h1>
 
-    Dokeos FREE imports Scorm 1.2 contents.<br />
+    Chamilo FREE imports Scorm 1.2 contents.<br />
 
     For more information on Scorm normalisation, see http://www.adlnet.org<br />
+    
+    Chamilo does not implement the full set of SCORM 1.2 specifications, as many are not mandatory. Check our website for more details.<br />
 
-<h1>Licence</h1>
+<h1>License</h1>
 
-<p>Dokeos is distributed under the GNU General Public license (GPL).<br />
+<p>Chamilo is distributed under the GNU General Public license (GNU/GPLv2).<br />
 
       Read the <a href="licence.html">GNU General Public license (GPL)</a> .</p>
 
 
 <h1>Portability</h1>
 
-<p>Dokeos is an AMP software. This means it should work on any platform running Apache<br />
+<p>Chamilo is an AMP software. This means it should work on any platform running Apache<br />
 
       + MySQL + PHP. It is then supposed to work on the following Operating Systems :</p>
 
@@ -102,56 +92,44 @@
       <li> Mac OS X 10.3</li>
 
 </ul>
+We officially recommend Debian and Ubuntu operating systems for their security, community and availability to the public.<br />
 
-<p>Email functions remain silent on systems where there is no mail sending software<br />
+<p>E-mail functions remain silent on systems where there is no mail sending software<br />
 
       (Sendmail, Postfix, Hamster...), which is the case by default on a Windows machine.</p>
 
 
 <h1>Interoperability</h1>
 
-<p>Dokeos imports Scorm compliant learning contents. It imports then "On the shelve"<br />
+<p>Chamilo imports SCORM 1.2 compliant learning contents. It imports then "On the shelve"<br />
 
-      contents from many companies : NETg, Skillsoft, Explio, Microsoft, Macromedia, etc.</p>
+ contents from many companies : NETg, Skillsoft, Explio, Microsoft, Macromedia, etc.</p>
 
 <p>Admin interface imports users through CSV and XML. You can create a CSV file from<br />
 
-      a list of users in MS Excel. OpenOffice can export to both CSV and XML formats.<br />
+      a list of users in MS-Excel. OpenOffice can export to both CSV and XML formats.<br />
 
       Many database management systems, like Oracle, SAP, Access, SQL-Server, LDAP ...<br />
 
       export to CSV and/or XML.</p>
 
-<p>Dokeos includes a LDAP module that allows admin to deactivate MySQL authentication<br />
+<p>Chamilo includes a LDAP module that allows admin to disable database authentication<br />
 
       and replace it by connection to a LDAP directory.</p>
 
-<p>Client side, Dokeos runs on any browser : Firefox, MS Internet Explorer (5.0+), Netscape (4.7+),<br />
-
-      Mozilla (1.2+), Safari, Opera, ...</p>
+<p>Client side, Chamilo runs on any browser : Firefox, MS Internet Explorer (5.0+), Netscape (4.7+),<br />
 
-<h1>Dokeos.com</h1>
+      Mozilla (1.2+), Safari, Opera, ...<br />For better user experience, we recommend Firefox 3.5+ (you can download it freely from <a href="http://getfirefox.com">http://getfirefox.com</a>).</p>
 
-<p>Dokeos is also a consulting company helping companies in their e-learning projects and selling Dokeos PRO and Dokeos MEDICAL.<br />
+<h1>Chamilo.org</h1>
 
-      <br />
-
-      You can find more information on our services on <a href="http://www.dokeos.com/en/node/61">http://www.dokeos.com/en/node/61</a><a href="http://www.dokeos.com/services.php"></a></p>
+<p>Chamilo is also an association, backed up by a network of private partners to help companies in their e-learning projects. This network also promotes professional versions of Chamilo, which include additional features and a complete package of services (see http://www.chamilo.org/providers for more details)</p>
 
 <p>
-<em>Contact address</em>: <br />
-
-      Dokeos<br />Rue Victor Hugo, 201<br />
-
-      B-1030 Brussels - Belgium<br />
-
-      Tel. +32 (2) 669 69 55<br />
-
-      Mail: <a href="mailto:info@dokeos.com">info@dokeos.com</a>
+<em>Association Contact address</em>: <br />
+Mail: <a href="mailto:info@chamilo.org">info@chamilo.org</a>
 </p>
-
 </div>
-
 </div>
 
 <hr />

+ 1 - 26
dokeos_license.txt

@@ -1,26 +1 @@
-===============================================================================
-	Dokeos - elearning and course management software
-
-	Copyright (c) 2004-2009 Dokeos SPRL
-    Copyright (c) 2009 Dokeos Latinoamérica SAC
-	Copyright (c) 2003-2007 Ghent University (UGent)
-	Copyright (c) 2001 Universite catholique de Louvain (UCL)
-	Copyright (c) 2003-2008 Vrije Universiteit Brussel (VUB)
-	Copyright (c) 2004-2008 Hoogeschool Gent (HoGent)
-	Copyright (c) Denes Nagy (darkden@freemail.hu)
-	For a full list of contributors detaining copyrights over parts of
-	the Dokeos software, see "documentation/credits.html".
-	The full license can be read in "documentation/license.html".
-
-	This program is free software; you can redistribute it and/or
-	modify it under the terms of the GNU General Public License
-	as published by the Free Software Foundation; either version 2
-	of the License, or (at your option) any later version.
-
-	See the GNU General Public License for more details.
-
-	Contact address: Dokeos, Rue du Corbeau, 108, B-1030 Brussels, Belgium
-	Mail: info@dokeos.com
-===============================================================================
-This license is referenced throughout the code using the following header line:
-/* For licensing terms, see /dokeos_license.txt */
+For license terms, please see the license.txt file in this same directory

BIN
favicon.ico


+ 1 - 1
home/home_menu.html

@@ -1 +1 @@
-<li><a href="http://www.dokeos.com/forum/" target="_self">Forum</a></li>
+<li><a href="http://www.chamilo.org/forum" target="_self">Forum</a></li>

+ 1 - 1
home/home_news.html

@@ -1,2 +1,2 @@
-<b>Dokeos News</b><br/><br/>
+<b>Portal News</b><br/><br/>
 To add, modify, remove news, go to the administration area of the portal.

+ 0 - 2
home/home_top.html

@@ -1,2 +0,0 @@
-<br/>
-<img src="{rel_path}home/large_dokeos_logo.gif" alt="Dokeos logo" />

BIN
home/large_dokeos_logo.gif


+ 166 - 196
index.php

@@ -1,64 +1,36 @@
-<?php // $Id: index.php 22368 2009-07-24 23:25:57Z iflorespaz $
-
-/*
-==============================================================================
-	Dokeos - elearning and course management software
-
-	Copyright (c) 2004-2009 Dokeos SPRL
-	Copyright (c) 2003 Ghent University (UGent)
-	Copyright (c) 2001 Universite catholique de Louvain (UCL)
-	Copyright (c) various contributors
-
-	For a full list of contributors, see "credits.txt".
-	The full license can be read in "license.txt".
-
-	This program is free software; you can redistribute it and/or
-	modify it under the terms of the GNU General Public License
-	as published by the Free Software Foundation; either version 2
-	of the License, or (at your option) any later version.
-
-	See the GNU General Public License for more details.
-
-	Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
-	Mail: info@dokeos.com
-==============================================================================
-*/
+<?php
+/* For licensing terms, see /license.txt */
 
 /**
- *	@package dokeos.main
+ *	@package chamilo.main
  *	@author Patrick Cool <patrick.cool@UGent.be>, Ghent University, Refactoring
  *	@version $Id: index.php 22368 2009-07-24 23:25:57Z iflorespaz $
  *	@todo check the different @todos in this page and really do them
  *	@todo check if the news management works as expected
  */
 
-// only this script should have this constant defined. This is used to activate the javascript that
+// Only this script should have this constant defined. This is used to activate the javascript that
 // gives the login name automatic focus in header.inc.html.
 /** @todo Couldn't this be done using the $HtmlHeadXtra array? */
 define('DOKEOS_HOMEPAGE', true);
 
-// the language file
-$language_file = array ('courses', 'index');
+$language_file = array('courses', 'index');
 
 /* Flag forcing the 'current course' reset, as we're not inside a course anymore */
-// maybe we should change this into an api function? an example: Coursemanager::unset();
+// Maybe we should change this into an api function? an example: Coursemanager::unset();
 $cidReset = true;
 
-
-/*
------------------------------------------------------------
-	Included libraries
------------------------------------------------------------
-*/
+/* 	Included libraries */
 
 /** @todo make all the library files consistent, use filename.lib.php and not filename.lib.inc.php */
 require_once 'main/inc/global.inc.php';
-include_once api_get_path(LIBRARY_PATH).'course.lib.php';
-include_once api_get_path(LIBRARY_PATH).'debug.lib.inc.php';
-include_once api_get_path(LIBRARY_PATH).'events.lib.inc.php';
-include_once api_get_path(LIBRARY_PATH).'system_announcements.lib.php';
-include_once api_get_path(LIBRARY_PATH).'groupmanager.lib.php';
-include_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php';
+
+require_once api_get_path(LIBRARY_PATH).'course.lib.php';
+require_once api_get_path(LIBRARY_PATH).'debug.lib.inc.php';
+require_once api_get_path(LIBRARY_PATH).'events.lib.inc.php';
+require_once api_get_path(LIBRARY_PATH).'system_announcements.lib.php';
+require_once api_get_path(LIBRARY_PATH).'groupmanager.lib.php';
+require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php';
 require_once 'main/chat/chat_functions.lib.php';
 
 $loginFailed = isset($_GET['loginFailed']) ? true : isset($loginFailed);
@@ -67,11 +39,7 @@ $setting_show_also_closed_courses = api_get_setting('show_closed_courses') == 't
 // the section (for the tabs)
 $this_section = SECTION_CAMPUS;
 
-/*
------------------------------------------------------------
-	Action Handling
------------------------------------------------------------
-*/
+/*	Action Handling */
 
 /** @todo 	Wouldn't it make more sense if this would be done in local.inc.php so that local.inc.php become the only place where authentication is done?
  * 			by doing this you could logout from any page instead of only from index.php. From the moment there is a logout=true in the url you will be logged out
@@ -84,20 +52,12 @@ if (!empty($_GET['logout'])) {
 	logout();
 }
 
-/*
------------------------------------------------------------
-	Table definitions
------------------------------------------------------------
-*/
+/* 	Table definitions */
 $main_course_table 		= Database :: get_main_table(TABLE_MAIN_COURSE);
 $main_category_table 	= Database :: get_main_table(TABLE_MAIN_CATEGORY);
 $track_login_table 		= Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_LOGIN);
 
-/*
------------------------------------------------------------
-	Constants and CONFIGURATION parameters
------------------------------------------------------------
-*/
+/* 	Constants and CONFIGURATION parameters */
 /** @todo these configuration settings should move to the dokeos config settings */
 /** defines wether or not anonymous visitors can see a list of the courses on the Dokeos homepage that are open to the world */
 $_setting['display_courses_to_anonymous_users'] = 'true';
@@ -107,11 +67,7 @@ if (isset($_user['user_id'])) {
 	$nameTools = api_get_setting('siteName');
 }
 
-/*
-==============================================================================
-		LOGIN
-==============================================================================
-*/
+/* 		LOGIN  	*/
 
 /**
  * @todo This piece of code should probably move to local.inc.php where the actual login / logout procedure is handled.
@@ -124,8 +80,8 @@ if (isset($_GET['submitAuth']) && $_GET['submitAuth'] == 1) {
 	die();
 }
 
-//Delete session neccesary for legal terms
-if (api_get_setting('allow_terms_conditions')=='true') {
+// Delete session neccesary for legal terms
+if (api_get_setting('allow_terms_conditions') == 'true') {
 	unset($_SESSION['update_term_and_condition']);
 	unset($_SESSION['info_current_user']);
 }
@@ -144,7 +100,7 @@ if (!empty($_POST['submitAuth'])) {
 								FROM $track_login_table
 								WHERE login_user_id = '".$_user['user_id']."'
 								ORDER BY login_date DESC LIMIT 1";
-		$result_last_login = Database::query($sql_last_login, __FILE__, __LINE__);
+		$result_last_login = Database::query($sql_last_login);
 		if (!$result_last_login) {
 			if (Database::num_rows($result_last_login) > 0) {
 				$user_last_login_datetime = Database::fetch_array($result_last_login);
@@ -152,7 +108,7 @@ if (!empty($_POST['submitAuth'])) {
 				api_session_register('user_last_login_datetime');
 			}
 		}
-		mysql_free_result($result_last_login);
+		Database::free_result($result_last_login);
 
 		//event_login();
 		if (api_is_platform_admin()) {
@@ -165,17 +121,14 @@ if (!empty($_POST['submitAuth'])) {
 } // end login -- if ($_POST['submitAuth'])
 else {
 	// only if login form was not sent because if the form is sent the user was already on the page.
-
 	event_open();
 }
 
 // the header
-Display :: display_header('', 'dokeos');
+Display::display_header(get_lang('Homepage'));
 
 /*
-==============================================================================
-		MAIN CODE
-==============================================================================
+	MAIN CODE
 */
 
 echo '<div class="maincontent" id="content">';
@@ -192,13 +145,12 @@ if ($_configuration['multiple_access_urls']) {
 	$access_url_id = api_get_current_access_url_id();
 	if ($access_url_id != -1){
 		$url_info = api_get_access_url($access_url_id);
-		// "http://" and the final "/" replaced
-		$url = substr($url_info['url'], 7, strlen($url_info['url']) - 8);
+		$url = api_remove_trailing_slash(preg_replace('/https?:\/\//i', '', $url_info['url']));
 		$clean_url = replace_dangerous_char($url);
 		$clean_url = str_replace('/', '-', $clean_url);
-		$clean_url = $clean_url.'/';
+		$clean_url .= '/';
 		$home_old = 'home/';
-		$home= 'home/'.$clean_url;
+		$home = 'home/'.$clean_url;
 	}
 }
 
@@ -206,7 +158,9 @@ if ($_configuration['multiple_access_urls']) {
 $page_included = false;
 
 if (!empty($_GET['include']) && preg_match('/^[a-zA-Z0-9_-]*\.html$/', $_GET['include'])) {
-	include './'.$home.$_GET['include'];
+	$open = @(string)file_get_contents(api_get_path(SYS_PATH).$home.$_GET['include']);
+	$open = api_to_system_encoding($open, api_detect_encoding(strip_tags($open)));
+	echo $open;
 	$page_included = true;
 } else {
 
@@ -225,17 +179,19 @@ if (!empty($_GET['include']) && preg_match('/^[a-zA-Z0-9_-]*\.html$/', $_GET['in
 			$home_top_temp = file($home_old.'home_top.html');
 		}
 		$home_top_temp = implode('', $home_top_temp);
-		$open = str_replace('{rel_path}', api_get_path(REL_PATH), $home_top_temp);
-		echo $open;
 	} else {
 		if (file_exists($home.'home_top_'.$user_selected_language.'.html')) {
 			$home_top_temp = file_get_contents($home.'home_top_'.$user_selected_language.'.html');
 		} else {
 			$home_top_temp = file_get_contents($home.'home_top.html');
 		}
-		$open = str_replace('{rel_path}', api_get_path(REL_PATH), $home_top_temp);
-		echo $open;
 	}
+	if(trim($home_top_temp)=='') {
+		$home_top_temp = get_lang('PortalHomepageDefaultIntroduction');
+	}
+    $open = str_replace('{rel_path}', api_get_path(REL_PATH), $home_top_temp);
+    $open = api_to_system_encoding($open, api_detect_encoding(strip_tags($open)));
+    echo $open;
 }
 
 // Display System announcements
@@ -259,25 +215,26 @@ if (!$page_included) {
 }
 echo '</div>';
 
-// display right menu: language form, login section + useful weblinks
+// Display right menu: language form, login section + useful weblinks
 echo '<div class="menu" id="menu">';
 display_anonymous_right_menu();
 echo '</div>';
 
 /*
-==============================================================================
-		FOOTER
-==============================================================================
+	Footer
 */
 Display :: display_footer();
 
+/*
+	Functions
+*/
+
 /**
  * This function handles the logout and is called whenever there is a $_GET['logout']
  *
  * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
  */
-function logout()
-{
+function logout() {
 	global $_configuration, $extAuthSource;
 	// variable initialisation
 	$query_string = '';
@@ -292,7 +249,7 @@ function logout()
 	// selecting the last login of the user
 	$uid = intval($_GET['uid']);
 	$sql_last_connection = "SELECT login_id, login_date FROM $tbl_track_login WHERE login_user_id='$uid' ORDER BY login_date DESC LIMIT 0,1";
-	$q_last_connection = Database::query($sql_last_connection, __FILE__, __LINE__);
+	$q_last_connection = Database::query($sql_last_connection);
 	if (Database::num_rows($q_last_connection) > 0) {
 		$i_id_last_connection = Database::result($q_last_connection, 0, 'login_id');
 	}
@@ -300,7 +257,7 @@ function logout()
 	if (!isset($_SESSION['login_as'])) {
 		$current_date = date('Y-m-d H:i:s', time());
 		$s_sql_update_logout_date = "UPDATE $tbl_track_login SET logout_date='".$current_date."' WHERE login_id='$i_id_last_connection'";
-		Database::query($s_sql_update_logout_date, __FILE__, __LINE__);
+		Database::query($s_sql_update_logout_date);
 	}
 	LoginDelete($uid, $_configuration['statistics_database']); //from inc/lib/online.inc.php - removes the "online" status
 
@@ -340,7 +297,7 @@ function category_has_open_courses($category) {
 	$user_identified = (api_get_user_id() > 0 && !api_is_anonymous());
 	$main_course_table = Database :: get_main_table(TABLE_MAIN_COURSE);
 	$sql_query = "SELECT * FROM $main_course_table WHERE category_code='$category'";
-	$sql_result = Database::query($sql_query, __FILE__, __LINE__);
+	$sql_result = Database::query($sql_query);
 	while ($course = Database::fetch_array($sql_result)) {
 		if (!$setting_show_also_closed_courses) {
 			if ((api_get_user_id() > 0
@@ -349,7 +306,7 @@ function category_has_open_courses($category) {
 				return true; //at least one open course
 			}
 		} else {
-			if (isset($course['visibility'])){
+			if (isset($course['visibility'])) {
 				return true; //at least one course (does not matter weither it's open or not because $setting_show_also_closed_courses = true
 			}
 		}
@@ -357,12 +314,25 @@ function category_has_open_courses($category) {
 	return false;
 }
 
+/**
+ * Display create course link
+ */
 function display_create_course_link() {
-	echo "<li><a href=\"main/create_course/add_course.php\">".get_lang("CourseCreate")."</a></li>";
+	echo '<li><a href="main/create_course/add_course.php">'.get_lang('CourseCreate').'</a></li>';
 }
 
+/**
+ * Display edit course list links
+ */
 function display_edit_course_list_links() {
-	echo "<li><a href=\"main/auth/courses.php\">".get_lang("CourseManagement")."</a></li>";
+	echo '<li><a href="main/auth/courses.php">'.get_lang('CourseManagement').'</a></li>';
+}
+
+/**
+ * Display dashboard link
+ */
+function display_dashboard_link() {
+	echo '<li><a href="main/dashboard/index.php">'.get_lang('Dashboard').'</a></li>';
 }
 
 /**
@@ -376,8 +346,9 @@ function display_anonymous_right_menu() {
 	global $loginFailed, $_plugins, $_user, $menu_navigation;
 
 	$platformLanguage = api_get_setting('platformLanguage');
+	$sys_path = api_get_path(SYS_PATH);
 
-	if (!($_user['user_id']) || api_is_anonymous($_user['user_id']) ) { // only display if the user isn't logged in
+	if (!($_user['user_id']) || api_is_anonymous($_user['user_id']) ) { // Only display if the user isn't logged in
 		api_display_language_form(true);
 		echo '<br />';
 		display_login_form();
@@ -388,7 +359,7 @@ function display_anonymous_right_menu() {
 		}
 		if (api_get_setting('allow_lostpassword') == 'true' || api_get_setting('allow_registration') == 'true') {
 			echo '<div class="menusection"><span class="menusectioncaption">'.get_lang('MenuUser').'</span><ul class="menulist">';
-			if (api_get_setting('allow_registration') <> 'false') {
+			if (api_get_setting('allow_registration') != 'false') {
 				echo '<li><a href="main/auth/inscription.php">'.get_lang('Reg').'</a></li>';
 			}
 			if (api_get_setting('allow_lostpassword') == 'true') {
@@ -412,7 +383,7 @@ function display_anonymous_right_menu() {
 		$show_create_link = false;
 		$show_course_link = false;
 
-		$display_add_course_link = api_is_allowed_to_create_course() && ($_SESSION["studentview"] != "studentenview");
+		$display_add_course_link = api_is_allowed_to_create_course() && ($_SESSION['studentview'] != 'studentenview');
 
 		if ($display_add_course_link) {
 			//display_create_course_link();
@@ -421,8 +392,8 @@ function display_anonymous_right_menu() {
 		}
 
 		if (api_is_platform_admin() || api_is_course_admin() || api_is_allowed_to_create_course()) {
-				$show_menu = true;
-				$show_course_link = true;
+			$show_menu = true;
+			$show_course_link = true;
 		} else {
 			if (api_get_setting('allow_students_to_browse_courses') == 'true') {
 				$show_menu = true;
@@ -430,38 +401,42 @@ function display_anonymous_right_menu() {
 			}
 		}
 
-		if ($show_menu){
-			echo "<div class=\"menusection\">";
-			echo "<span class=\"menusectioncaption\">".get_lang("MenuUser")."</span>";
-			echo "<ul class=\"menulist\">";
+		if ($show_menu) {
+			echo '<div class="menusection">';
+			echo '<span class="menusectioncaption">'.get_lang('MenuUser').'</span>';
+			echo '<ul class="menulist">';
 			if ($show_create_link) {
 				display_create_course_link();
 			}
 			if ($show_course_link) {
-				display_edit_course_list_links();
+				if (!api_is_drh() && !api_is_session_admin()) {
+					display_edit_course_list_links();
+				} else {
+					display_dashboard_link();
+				}
 			}
-			echo "</ul>";
-			echo "</div>";
+			echo '</ul></div>';
+		}
+
+		// Deleting the myprofile link
+		if (api_get_setting('allow_social_tool') == true) {
+			unset($menu_navigation['myprofile']);
 		}
 
 		if (!empty($menu_navigation)) {
-			echo "<div class=\"menusection\">";
-			echo "<span class=\"menusectioncaption\">".get_lang("MainNavigation")."</span>";
-			echo "<ul class=\"menulist\">";
+			echo '<div class="menusection">';
+			echo '<span class="menusectioncaption">'.get_lang('MainNavigation').'</span>';
+			echo '<ul class="menulist">';
 			foreach ($menu_navigation as $section => $navigation_info) {
 				$current = $section == $GLOBALS['this_section'] ? ' id="current"' : '';
-				echo '<li'.$current.'>';
-				echo '<a href="'.$navigation_info['url'].'" target="_self">'.$navigation_info['title'].'</a>';
-				echo '</li>';
-				echo "\n";
+				echo '<li'.$current.'><a href="'.$navigation_info['url'].'" target="_self">'.$navigation_info['title'].'</a></li>', "\n";
 			}
-			echo "</ul>";
-			echo '</div>';
+			echo '</ul></div>';
 		}
 	}
 
-	// help section
-	/*** hide right menu "general" and other parts on anonymous right menu *****/
+	// Help section
+	/*** Hide right menu "general" and other parts on anonymous right menu *****/
 
 	$user_selected_language = api_get_interface_language();
 	global $home, $home_old;
@@ -469,23 +444,22 @@ function display_anonymous_right_menu() {
 		$user_selected_language = $platformLanguage;
 	}
 
-	if (!file_exists($home.'home_menu_'.$user_selected_language.'.html') && file_exists($home.'home_menu.html') && file_get_contents($home.'home_menu.html') != '') {
-		echo "<div class=\"menusection\">", "<span class=\"menusectioncaption\">".get_lang("MenuGeneral")."</span>";
-	 	echo "<ul class=\"menulist\">";
-		if (file_exists($home.'home_menu.html')) {
-			include ($home.'home_menu.html');
-		} else {
-			include ($home_old.'home_menu.html');
-		}
-		echo '</ul>';
-		echo '</div>';
+	$home_menu = @(string)file_get_contents($sys_path.$home.'home_menu_'.$user_selected_language.'.html');
+	if (empty($home_menu)) {
+		$home_menu = @(string)file_get_contents($sys_path.$home_old.'home_menu_'.$user_selected_language.'.html');
 	}
-	elseif(file_exists($home.'home_menu_'.$user_selected_language.'.html') && file_get_contents($home.'home_menu_'.$user_selected_language.'.html') != '') {
-		echo "<div class=\"menusection\">", "<span class=\"menusectioncaption\">".get_lang("MenuGeneral")."</span>";
-	 	echo "<ul class=\"menulist\">";
-		include ($home.'home_menu_'.$user_selected_language.'.html');
-		echo '</ul>';
-		echo '</div>';
+	if (empty($home_menu)) {
+		$home_menu = @(string)file_get_contents($sys_path.$home.'home_menu.html');
+	}
+	if (empty($home_menu)) {
+		$home_menu = @(string)file_get_contents($sys_path.$home_old.'home_menu.html');
+	}
+	if (!empty($home_menu)) {
+		echo '<div class="menusection">', '<span class="menusectioncaption">'.get_lang('MenuGeneral').'</span>';
+	 	echo '<ul class="menulist">';
+	 	$home_menu = api_to_system_encoding($home_menu, api_detect_encoding(strip_tags($home_menu)));
+	 	echo $home_menu;
+		echo '</ul></div>';
 	}
 
 	if ($_user['user_id'] && api_number_of_plugins('campushomepage_menu') > 0) {
@@ -496,34 +470,29 @@ function display_anonymous_right_menu() {
 
 	// includes for any files to be displayed below anonymous right menu
 
-	if (!file_exists($home.'home_notice_'.$user_selected_language.'.html') && file_exists($home.'home_notice.html') && file_get_contents($home.'home_notice.html') != '') {
-		echo '<div class="note">';
-		if (file_exists($home.'home_notice.html')) {
-			include ($home.'home_notice.html');
-		} else {
-			include ($home_old.'home_notice.html');
-		}
-		echo '</div>';
+	$home_notice = @(string)file_get_contents($sys_path.$home.'home_notice_'.$user_selected_language.'.html');
+	if (empty($home_notice)) {
+		$home_notice = @(string)file_get_contents($sys_path.$home.'home_notice.html');
 	}
-	elseif(file_exists($home.'home_notice_'.$user_selected_language.'.html') && file_get_contents($home.'home_notice_'.$user_selected_language.'.html') != '') {
+	if (!empty($home_notice)) {
 		echo '<div class="note">';
-		include($home.'home_notice_'.$user_selected_language.'.html');
+		$home_notice = api_to_system_encoding($home_notice, api_detect_encoding(strip_tags($home_notice)));
+	 	echo $home_notice;
 		echo '</div>';
 	}
 }
 
 /**
 *	Reacts on a failed login:
-*	displays an explanation with
-*	a link to the registration form.
+*	Displays an explanation with a link to the registration form.
 *
 *	@version 1.0.1
 */
 function handle_login_failed() {
 	if (!isset($_GET['error'])) {
-		$message = get_lang("InvalidId");
+		$message = get_lang('InvalidId');
 		if (api_is_self_registration_allowed()) {
-			$message = get_lang("InvalidForSelfRegistration");
+			$message = get_lang('InvalidForSelfRegistration');
 		}
 	} else {
 		switch ($_GET['error']) {
@@ -547,7 +516,7 @@ function handle_login_failed() {
 				break;
 		}
 	}
-	echo "<div id=\"login_fail\">".$message."</div>";
+	echo '<div id="login_fail">'.$message.'</div>';
 }
 
 /**
@@ -558,7 +527,7 @@ function display_login_form() {
 	$form = new FormValidator('formLogin');
 	$form->addElement('text', 'login', get_lang('UserName'), array('size' => 17));
 	$form->addElement('password', 'password', get_lang('Pass'), array('size' => 17));
-	$form->addElement('style_submit_button','submitAuth', get_lang('langEnter'), array('class' => 'login'));
+	$form->addElement('style_submit_button','submitAuth', get_lang('LoginEnter'), array('class' => 'login'));
 	$renderer =& $form->defaultRenderer();
 	$renderer->setElementTemplate('<div><label>{label}</label></div><div>{element}</div>');
 	$form->display();
@@ -572,7 +541,7 @@ function display_login_form() {
  * Displays a link to the lost password section
  */
 function display_lost_password_info() {
-	echo "<li><a href=\"main/auth/lostPassword.php\">".get_lang("LostPassword")."</a></li>";
+	echo '<li><a href="main/auth/lostPassword.php">'.get_lang('LostPassword').'</a></li>';
 }
 
 /**
@@ -600,23 +569,23 @@ function display_anonymous_course_list() {
 
 	//get list of courses in category $category
 	$sql_get_course_list = "SELECT * FROM $main_course_table cours
-								WHERE category_code = '".Database::escape_string($_GET["category"])."'
+								WHERE category_code = '".Database::escape_string($_GET['category'])."'
 								ORDER BY title, UPPER(visual_code)";
 
 	//showing only the courses of the current access_url_id
 	global $_configuration;
 	if ($_configuration['multiple_access_urls'] == true) {
 		$url_access_id = api_get_current_access_url_id();
-		if ($url_access_id !=-1) {
+		if ($url_access_id != -1) {
 			$tbl_url_rel_course = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
 			$sql_get_course_list = "SELECT * FROM $main_course_table as course INNER JOIN $tbl_url_rel_course as url_rel_course
 					ON (url_rel_course.course_code=course.code)
-					WHERE access_url_id = $url_access_id AND category_code = '".Database::escape_string($_GET["category"])."' ORDER BY title, UPPER(visual_code)";
+					WHERE access_url_id = $url_access_id AND category_code = '".Database::escape_string($_GET['category'])."' ORDER BY title, UPPER(visual_code)";
 		}
 	}
 
-	//removed: AND cours.visibility='".COURSE_VISIBILITY_OPEN_WORLD."'
-	$sql_result_courses = Database::query($sql_get_course_list, __FILE__, __LINE__);
+	// Removed: AND cours.visibility='".COURSE_VISIBILITY_OPEN_WORLD."'
+	$sql_result_courses = Database::query($sql_get_course_list);
 
 	while ($course_result = Database::fetch_array($sql_result_courses)) {
 		$course_list[] = $course_result;
@@ -646,9 +615,9 @@ function display_anonymous_course_list() {
 				GROUP BY t1.name,t1.code,t1.parent_id,t1.children_count ORDER BY t1.tree_pos, t1.name";
 
 
-	//showing only the category of courses of the current access_url_id
+	// Showing only the category of courses of the current access_url_id
 	global $_configuration;
-	if ($_configuration['multiple_access_urls'] == true) {
+	if ($_configuration['multiple_access_urls']) {
 		$url_access_id = api_get_current_access_url_id();
 		if ($url_access_id != -1) {
 			$tbl_url_rel_course = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
@@ -664,27 +633,27 @@ function display_anonymous_course_list() {
 		}
 	}
 
-	$resCats = Database::query($sqlGetSubCatList, __FILE__, __LINE__);
+	$resCats = Database::query($sqlGetSubCatList);
 	$thereIsSubCat = false;
 	if (Database::num_rows($resCats) > 0) {
-		$htmlListCat = "<h4 style=\"margin-top: 0px;\">".get_lang("CatList")."</h4>"."<ul>";
+		$htmlListCat = '<h4 style="margin-top: 0px;">'.get_lang('CatList').'</h4><ul>';
 		while ($catLine = Database::fetch_array($resCats)) {
 			if ($catLine['code'] != $category) {
 
 				$category_has_open_courses = category_has_open_courses($catLine['code']);
 				if ($category_has_open_courses) {
-					//the category contains courses accessible to anonymous visitors
-					$htmlListCat .= "<li>";
-					$htmlListCat .= "<a href=\"".api_get_self()."?category=".$catLine['code']."\">".$catLine['name']."</a>";
+					// The category contains courses accessible to anonymous visitors
+					$htmlListCat .= '<li>';
+					$htmlListCat .= '<a href="'.api_get_self().'?category='.$catLine['code'].'">'.$catLine['name'].'</a>';
 					if (api_get_setting('show_number_of_courses') == 'true') {
-						$htmlListCat .= " (".$catLine['nbCourse']." ".get_lang("Courses").")";
+						$htmlListCat .= ' ('.$catLine['nbCourse'].' '.get_lang('Courses').')';
 					}
 					$htmlListCat .= "</li>\n";
 					$thereIsSubCat = true;
 				} elseif ($catLine['children_count'] > 0) {
-					//the category has children, subcategories
-					$htmlListCat .= "<li>";
-					$htmlListCat .= "<a href=\"".api_get_self()."?category=".$catLine['code']."\">".$catLine['name']."</a>";
+					// The category has children, subcategories
+					$htmlListCat .= '<li>';
+					$htmlListCat .= '<a href="'.api_get_self().'?category='.$catLine['code'].'">'.$catLine['name'].'</a>';
 					$htmlListCat .= "</li>\n";
 					$thereIsSubCat = true;
 				}
@@ -692,24 +661,24 @@ function display_anonymous_course_list() {
 				 end changed code to eliminate the (0 courses) after empty categories
 				 ************************************************************************/
 				elseif (api_get_setting('show_empty_course_categories') == 'true') {
-					$htmlListCat .= "<li>";
+					$htmlListCat .= '<li>';
 					$htmlListCat .= $catLine['name'];
 					$htmlListCat .= "</li>\n";
 					$thereIsSubCat = true;
 				} //else don't set thereIsSubCat to true to avoid printing things if not requested
 			} else {
-				$htmlTitre = "<p>";
+				$htmlTitre = '<p>';
 				if (api_get_setting('show_back_link_on_top_of_tree') == 'true') {
-					$htmlTitre .= "<a href=\"".api_get_self()."\">"."&lt;&lt; ".get_lang("BackToHomePage")."</a>";
+					$htmlTitre .= '<a href="'.api_get_self().'">&lt;&lt; '.get_lang('BackToHomePage').'</a>';
 				}
-				if (!is_null($catLine['parent_id']) || (api_get_setting('show_back_link_on_top_of_tree') <> 'true' && !is_null($catLine['code']))) {
-					$htmlTitre .= "<a href=\"".api_get_self()."?category=".$catLine['parent_id']."\">"."&lt;&lt; ".get_lang('Up')."</a>";
+				if (!is_null($catLine['parent_id']) || (api_get_setting('show_back_link_on_top_of_tree') != 'true' && !is_null($catLine['code']))) {
+					$htmlTitre .= '<a href="'.api_get_self().'?category='.$catLine['parent_id'].'">&lt;&lt; '.get_lang('Up').'</a>';
 				}
 				$htmlTitre .= "</p>\n";
 				if ($category != "" && !is_null($catLine['code'])) {
-					$htmlTitre .= "<h3>".$catLine['name']."</h3>\n";
+					$htmlTitre .= '<h3>'.$catLine['name']."</h3>\n";
 				} else {
-					$htmlTitre .= "<h3>".get_lang("Categories")."</h3>\n";
+					$htmlTitre .= '<h3>'.get_lang('Categories')."</h3>\n";
 				}
 			}
 		}
@@ -720,7 +689,7 @@ function display_anonymous_course_list() {
 		echo $htmlListCat;
 	}
 	while ($categoryName = Database::fetch_array($resCats)) {
-		echo "<h3>", $categoryName['name'], "</h3>\n";
+		echo '<h3>', $categoryName['name'], "</h3>\n";
 	}
 	$numrows = Database::num_rows($sql_result_courses);
 	$courses_list_string = '';
@@ -729,7 +698,7 @@ function display_anonymous_course_list() {
 		if ($thereIsSubCat) {
 			$courses_list_string .= "<hr size=\"1\" noshade=\"noshade\">\n";
 		}
-		$courses_list_string .= "<h4 style=\"margin-top: 0px;\">".get_lang("CourseList")."</h4>\n"."<ul>\n";
+		$courses_list_string .= '<h4 style="margin-top: 0px;">'.get_lang('CourseList')."</h4>\n<ul>\n";
 
 		if (api_get_user_id()) {
 			$courses_of_user = get_courses_of_user(api_get_user_id());
@@ -739,30 +708,30 @@ function display_anonymous_course_list() {
 			// $setting_show_also_closed_courses
 
 			if ($setting_show_also_closed_courses == false) {
-				// if we do not show the closed courses
+				// If we do not show the closed courses
 				// we only show the courses that are open to the world (to everybody)
 				// and the courses that are open to the platform (if the current user is a registered user
 				if( ($user_identified && $course['visibility'] == COURSE_VISIBILITY_OPEN_PLATFORM) || ($course['visibility'] == COURSE_VISIBILITY_OPEN_WORLD)) {
 					$courses_shown++;
 					$courses_list_string .= "<li>\n";
-				$courses_list_string .= "<a href=\"".$web_course_path.$course['directory']."/\">".$course['title']."</a><br />";
-				if (api_get_setting('display_coursecode_in_courselist') == 'true') {
-					$courses_list_string .= $course['visual_code'];
-				}
-				if (api_get_setting('display_coursecode_in_courselist') == 'true' && api_get_setting('display_teacher_in_courselist') == 'true') {
-					$courses_list_string .= ' - ';
-				}
-				if (api_get_setting('display_teacher_in_courselist') == 'true') {
-					$courses_list_string .= $course['tutor_name'];
-				}
+					$courses_list_string .= '<a href="'.$web_course_path.$course['directory'].'/">'.$course['title'].'</a><br />';
+					if (api_get_setting('display_coursecode_in_courselist') == 'true') {
+						$courses_list_string .= $course['visual_code'];
+					}
+					if (api_get_setting('display_coursecode_in_courselist') == 'true' && api_get_setting('display_teacher_in_courselist') == 'true') {
+						$courses_list_string .= ' - ';
+					}
+					if (api_get_setting('display_teacher_in_courselist') == 'true') {
+						$courses_list_string .= $course['tutor_name'];
+					}
 					if (api_get_setting('show_different_course_language') == 'true' && $course['course_language'] != api_get_setting('platformLanguage')) {
 						$courses_list_string .= ' - '.$course['course_language'];
 					}
 					$courses_list_string .= "</li>\n";
 				}
 			}
-			// we DO show the closed courses.
-			// the course is accessible if (link to the course homepage)
+			// We DO show the closed courses.
+			// The course is accessible if (link to the course homepage)
 			// 1. the course is open to the world (doesn't matter if the user is logged in or not): $course['visibility'] == COURSE_VISIBILITY_OPEN_WORLD)
 			// 2. the user is logged in and the course is open to the world or open to the platform: ($user_identified && $course['visibility'] == COURSE_VISIBILITY_OPEN_PLATFORM)
 			// 3. the user is logged in and the user is subscribed to the course and the course visibility is not COURSE_VISIBILITY_CLOSED
@@ -777,7 +746,7 @@ function display_anonymous_course_list() {
 						|| ($user_identified && key_exists($course['code'], $courses_of_user) && $course['visibility'] != COURSE_VISIBILITY_CLOSED)
 						|| $courses_of_user[$course['code']]['status'] == '1'
 						|| api_is_platform_admin()) {
-					$courses_list_string .= "<a href=\"".$web_course_path.$course['directory']."/\">";
+					$courses_list_string .= '<a href="'.$web_course_path.$course['directory'].'/">';
 				}
 				$courses_list_string .= $course['title'];
 				if ($course['visibility'] == COURSE_VISIBILITY_OPEN_WORLD
@@ -785,7 +754,7 @@ function display_anonymous_course_list() {
 						|| ($user_identified && key_exists($course['code'], $courses_of_user) && $course['visibility'] != COURSE_VISIBILITY_CLOSED)
 						|| $courses_of_user[$course['code']]['status'] == '1'
 						|| api_is_platform_admin()) {
-					$courses_list_string .= "</a><br />";
+					$courses_list_string .= '</a><br />';
 				}
 				if (api_get_setting('display_coursecode_in_courselist') == 'true') {
 					$courses_list_string .= $course['visual_code'];
@@ -807,12 +776,12 @@ function display_anonymous_course_list() {
 				// 2
 				if ($user_identified && !key_exists($course['code'], $courses_of_user)) {
 					if ($course['subscribe'] == '1') {
-						$courses_list_string .= "<form action=\"main/auth/courses.php?action=subscribe&category=".$_GET['category']."\" method=\"post\">";
+						$courses_list_string .= '<form action="main/auth/courses.php?action=subscribe&category='.Security::remove_XSS($_GET['category']).'" method="post">';
 						$courses_list_string .= '<input type="hidden" name="sec_token" value="'.$stok.'">';
-						$courses_list_string .= "<input type=\"hidden\" name=\"subscribe\" value=\"".$course['code']."\" />";
-						$courses_list_string .= "<input type=\"image\" name=\"unsub\" src=\"main/img/enroll.gif\" alt=\"".get_lang("Subscribe")."\" />".get_lang("Subscribe")."</form>";
+						$courses_list_string .= '<input type="hidden" name="subscribe" value="'.$course['code'].'" />';
+						$courses_list_string .= '<input type="image" name="unsub" src="main/img/enroll.gif" alt="'.get_lang('Subscribe').'" />'.get_lang('Subscribe').'</form>';
 					} else {
-						$courses_list_string .= '<br />'.get_lang("SubscribingNotAllowed");
+						$courses_list_string .= '<br />'.get_lang('SubscribingNotAllowed');
 					}
 				}
 				$courses_list_string .= "</li>\n";
@@ -820,14 +789,14 @@ function display_anonymous_course_list() {
 		}
 		$courses_list_string .= "</ul>\n";
 	} else {
-		// echo "<blockquote>",get_lang('_No_course_publicly_available'),"</blockquote>\n";
+		// echo '<blockquote>', get_lang('_No_course_publicly_available'), "</blockquote>\n";
 	}
 	if ($courses_shown > 0) { //only display the list of courses and categories if there was more than
 		// 0 courses visible to the world (we're in the anonymous list here)
 		echo $courses_list_string;
 	}
 	if ($category != '') {
-		echo "<p>", "<a href=\"".api_get_self()."\"> ", Display :: return_icon('back.png', get_lang('BackToHomePage')), get_lang("BackToHomePage"), "</a>", "</p>\n";
+		echo '<p><a href="'.api_get_self().'"> ', Display :: return_icon('back.png', get_lang('BackToHomePage')), get_lang('BackToHomePage'), '</a></p>', "\n";
 	}
 }
 
@@ -850,10 +819,11 @@ function get_courses_of_user($user_id) {
 										$table_course_user  course_rel_user
 								WHERE course.code = course_rel_user.course_code
 								AND   course_rel_user.user_id = '".$user_id."'
+								AND course_rel_user.relation_type<>".COURSE_RELATION_TYPE_RRHH."
 								ORDER BY course_rel_user.sort ASC";
-	$result = Database::query($sql_select_courses, __FILE__, __LINE__);
+	$result = Database::query($sql_select_courses);
 	while ($row = Database::fetch_array($result)) {
-		// we only need the database name of the course
+		// We only need the database name of the course
 		$courses[$row['k']] = array('db' => $row['db'], 'code' => $row['k'], 'visual_code' => $row['vc'], 'title' => $row['i'], 'directory' => $row['dir'], 'status' => $row['status'], 'tutor' => $row['t'], 'subscribe' => $row['subscr'], 'unsubscribe' => $row['unsubscr'], 'sort' => $row['sort'], 'user_course_category' => $row['user_course_cat']);
 	}
 	return $courses;

+ 27 - 0
license.txt

@@ -0,0 +1,27 @@
+===============================================================================
+Chamilo - elearning and course management software
+
+Copyright (c) 2008-2010 Dokeos Latinoamérica SAC / BeezNest Latino SAC
+Copyright (c) 2004-2009 Dokeos SPRL
+Copyright (c) 2003-2007 Ghent University (UGent)
+Copyright (c) 2001 Universite catholique de Louvain (UCL)
+Copyright (c) 2003-2008 Vrije Universiteit Brussel (VUB)
+Copyright (c) 2004-2008 Hoogeschool Gent (HoGent)
+Copyright (c) Bart Mollet, Hogeschool Gent
+Copyright (c) Facultad de Matematicas, UADY (México) (Message plugin)
+	
+For a full list of contributors detaining copyrights over parts of
+the Chamilo software, see "documentation/credits.html".
+The full license can be read in "documentation/license.html".
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+See the GNU General Public License for more details.
+
+Mail: info@chamilo.org
+===============================================================================
+This license is referenced throughout the code using the following header line:
+/* For licensing terms, see /license.txt */

+ 12 - 44
main/admin/access_url_add_courses_to_url.php

@@ -1,49 +1,28 @@
 <?php
-/*
-==============================================================================
-	Dokeos - elearning and course management software
-
-	Copyright (c) 2009 Dokeos SPRL
-	Copyright (c) 2009 Julio Montoya Armas <gugli100@gmail.com>
-
-	For a full list of contributors, see "credits.txt".
-	The full license can be read in "license.txt".
-
-	This program is free software; you can redistribute it and/or
-	modify it under the terms of the GNU General Public License
-	as published by the Free Software Foundation; either version 2
-	of the License, or (at your option) any later version.
-
-	See the GNU General Public License for more details.
-
-	Contact address: Dokeos, 44 rue des palais, B-1030 Brussels, Belgium
-	Mail: info@dokeos.com
-==============================================================================
-*/
+/* For licensing terms, see /license.txt */
 /**
-==============================================================================
 *	This script allows platform admins to add users to urls.
 *	It displays a list of users and a list of courses;
 *	you can select multiple users and courses and then click on
-*	@package dokeos.admin
-==============================================================================
+*	@package chamilo.admin
+*	@author Julio Montoya <gugli100@gmail.com>
 */
 
 // name of the language file that needs to be included
 $language_file = 'admin';
 $cidReset = true;
-require ('../inc/global.inc.php');
+require_once '../inc/global.inc.php';
 $this_section=SECTION_PLATFORM_ADMIN;
 
 require_once (api_get_path(LIBRARY_PATH).'urlmanager.lib.php');
 api_protect_admin_script();
-if (!$_configuration['multiple_access_urls'])
+if (!$_configuration['multiple_access_urls']) {
 	header('Location: index.php');
+	exit;
+}
 
 /*
------------------------------------------------------------
 	Global constants and variables
------------------------------------------------------------
 */
 
 $form_sent = 0;
@@ -67,9 +46,7 @@ $interbreadcrumb[] = array ('url' => 'index.php', 'name' => get_lang('PlatformAd
 $interbreadcrumb[] = array ('url' => 'access_urls.php', 'name' => get_lang('MultipleAccessURLs'));
 
 /*
-==============================================================================
 		MAIN CODE
-==============================================================================
 */
 
 Display :: display_header($tool_name);
@@ -95,27 +72,20 @@ if ($_POST['form_sent']) {
 	if ($form_sent == 1) {
 		if ( count($courses) == 0 || count($url_list) == 0) {
 			Display :: display_error_message(get_lang('AtLeastOneCourseAndOneURL'));
-			//header('Location: access_urls.php?action=show_message&message='.get_lang('AtLeastOneUserAndOneURL'));
 		} else {
 			UrlManager::add_courses_to_urls($courses,$url_list);
 			Display :: display_confirmation_message(get_lang('CourseBelongURL'));
-			//header('Location: access_urls.php?action=show_message&message='.get_lang('UsersBelongURL'));
 		}
 	}
 }
 
 
 
-/*
------------------------------------------------------------
-	Display GUI
------------------------------------------------------------
-*/
+/*	Display GUI */
 
-if(empty($first_letter_user))
-{
+if(empty($first_letter_user)) {
 	$sql = "SELECT count(*) as num_courses FROM $tbl_course";
-	$result = Database::query($sql, __FILE__, __LINE__);
+	$result = Database::query($sql);
 	$num_row = Database::fetch_array($result);
 	if($num_row['num_courses']>1000)
 	{//if there are too much num_courses to gracefully handle with the HTML select list,
@@ -130,12 +100,12 @@ $sql = "SELECT code, title FROM $tbl_course
 		WHERE title LIKE '".$first_letter_course."%' OR title LIKE '".api_strtolower($first_letter_course)."%'
 		ORDER BY title, code DESC ";
 
-$result = Database::query($sql, __FILE__, __LINE__);
+$result = Database::query($sql);
 $db_courses = Database::store_result($result);
 unset($result);
 
 $sql = "SELECT id, url FROM $tbl_access_url  WHERE active=1 ORDER BY url";
-$result = Database::query($sql, __FILE__, __LINE__);
+$result = Database::query($sql);
 $db_urls = Database::store_result($result);
 unset($result);
 ?>
@@ -192,9 +162,7 @@ unset($result);
 </form>
 <?php
 /*
-==============================================================================
 		FOOTER
-==============================================================================
 */
 Display :: display_footer();
 ?>

+ 12 - 45
main/admin/access_url_add_sessions_to_url.php

@@ -1,49 +1,28 @@
 <?php
-/*
-==============================================================================
-	Dokeos - elearning and course management software
-
-	Copyright (c) 2009 Dokeos SPRL
-	Copyright (c) 2009 Julio Montoya Armas <gugli100@gmail.com>
-
-	For a full list of contributors, see "credits.txt".
-	The full license can be read in "license.txt".
-
-	This program is free software; you can redistribute it and/or
-	modify it under the terms of the GNU General Public License
-	as published by the Free Software Foundation; either version 2
-	of the License, or (at your option) any later version.
-
-	See the GNU General Public License for more details.
-
-	Contact address: Dokeos, 44 rue des palais, B-1030 Brussels, Belgium
-	Mail: info@dokeos.com
-==============================================================================
-*/
+/* For licensing terms, see /license.txt */
 /**
-==============================================================================
 *	This script allows platform admins to add users to urls.
 *	It displays a list of users and a list of courses;
 *	you can select multiple users and courses and then click on
-*	@package dokeos.admin
-==============================================================================
+*	@package chamilo.admin
+*	@author Julio Montoya <gugli100@gmail.com>
 */
 
 // name of the language file that needs to be included
 $language_file = 'admin';
 $cidReset = true;
-require ('../inc/global.inc.php');
+require_once '../inc/global.inc.php';
 $this_section=SECTION_PLATFORM_ADMIN;
 
 require_once (api_get_path(LIBRARY_PATH).'urlmanager.lib.php');
 api_protect_admin_script();
-if (!$_configuration['multiple_access_urls'])
+if (!$_configuration['multiple_access_urls']) {
 	header('Location: index.php');
+	exit;
+}
 
 /*
------------------------------------------------------------
 	Global constants and variables
------------------------------------------------------------
 */
 
 $form_sent = 0;
@@ -57,20 +36,12 @@ $tbl_access_url 			= Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
 $tbl_user 					= Database :: get_main_table(TABLE_MAIN_USER);
 $tbl_session				= Database :: get_main_table(TABLE_MAIN_SESSION);
 
-/*
------------------------------------------------------------
-	Header
------------------------------------------------------------
-*/
+/*	Header	*/
 $tool_name = get_lang('AddSessionToURL');
 $interbreadcrumb[] = array ('url' => 'index.php', 'name' => get_lang('PlatformAdmin'));
 $interbreadcrumb[] = array ('url' => 'access_urls.php', 'name' => get_lang('MultipleAccessURLs'));
 
-/*
-==============================================================================
-		MAIN CODE
-==============================================================================
-*/
+/*		MAIN CODE	*/
 
 Display :: display_header($tool_name);
 echo '<div class="actions" style="height:22px;">';
@@ -106,14 +77,12 @@ if ($_POST['form_sent']) {
 
 
 /*
------------------------------------------------------------
 	Display GUI
------------------------------------------------------------
 */
 /*
 if(empty($first_letter_user)) {
 	$sql = "SELECT count(*) as num_courses FROM $tbl_course";
-	$result = Database::query($sql, __FILE__, __LINE__);
+	$result = Database::query($sql);
 	$num_row = Database::fetch_array($result);
 	if($num_row['num_courses']>1000)
 	{//if there are too much num_courses to gracefully handle with the HTML select list,
@@ -128,12 +97,12 @@ $sql = "SELECT id, name FROM $tbl_session
 		WHERE name LIKE '".$first_letter_session."%' OR name LIKE '".api_strtolower($first_letter_session)."%'
 		ORDER BY name DESC ";
 
-$result = Database::query($sql, __FILE__, __LINE__);
+$result = Database::query($sql);
 $db_sessions = Database::store_result($result);
 unset($result);
 
 $sql = "SELECT id, url FROM $tbl_access_url  WHERE active=1 ORDER BY url";
-$result = Database::query($sql, __FILE__, __LINE__);
+$result = Database::query($sql);
 $db_urls = Database::store_result($result);
 unset($result);
 ?>
@@ -194,9 +163,7 @@ unset($result);
 </form>
 <?php
 /*
-==============================================================================
 		FOOTER
-==============================================================================
 */
 Display :: display_footer();
 ?>

+ 16 - 54
main/admin/access_url_add_users_to_url.php

@@ -1,48 +1,28 @@
 <?php
-/*
-==============================================================================
-	Dokeos - elearning and course management software
-
-	Copyright (c) 2009 Dokeos SPRL
-	Copyright (c) 2009 Julio Montoya Armas <gugli100@gmail.com>
-
-	For a full list of contributors, see "credits.txt".
-	The full license can be read in "license.txt".
-
-	This program is free software; you can redistribute it and/or
-	modify it under the terms of the GNU General Public License
-	as published by the Free Software Foundation; either version 2
-	of the License, or (at your option) any later version.
-
-	See the GNU General Public License for more details.
-
-	Contact: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium, info@dokeos.com
-==============================================================================
-*/
-/**
-==============================================================================
-*	This script allows platform admins to add users to urls.
+/* For licensing terms, see /license.txt */
+/**	
+* This script allows platform admins to add users to urls.
 *	It displays a list of users and a list of courses;
 *	you can select multiple users and courses and then click on
-*	@package dokeos.admin
-==============================================================================
+*	@package chamilo.admin
+*	@author Julio Montoya <gugli100@gmail.com>
 */
 
 // name of the language file that needs to be included
 $language_file = 'admin';
 $cidReset = true;
-require ('../inc/global.inc.php');
+require_once '../inc/global.inc.php';
 $this_section=SECTION_PLATFORM_ADMIN;
 
 require_once (api_get_path(LIBRARY_PATH).'urlmanager.lib.php');
 api_protect_admin_script();
-if (!$_configuration['multiple_access_urls'])
+if (!$_configuration['multiple_access_urls']) {
 	header('Location: index.php');
+	exit;
+}
 
 /*
------------------------------------------------------------
 	Global constants and variables
------------------------------------------------------------
 */
 
 $form_sent = 0;
@@ -56,21 +36,13 @@ $tbl_access_url_rel_user = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_
 $tbl_access_url = Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
 $tbl_user 		= Database :: get_main_table(TABLE_MAIN_USER);
 
-/*
------------------------------------------------------------
-	Header
------------------------------------------------------------
-*/
+/*	Header	*/
 $tool_name = get_lang('AddUsersToURL');
 $interbreadcrumb[] = array ('url' => 'index.php', 'name' => get_lang('PlatformAdmin'));
 $interbreadcrumb[] = array ('url' => 'access_urls.php', 'name' => get_lang('MultipleAccessURLs'));
 
 
-/*
-==============================================================================
-		MAIN CODE
-==============================================================================
-*/
+/*		MAIN CODE	*/
 
 Display :: display_header($tool_name);
 
@@ -82,8 +54,6 @@ echo '</div>';
 
 api_display_tool_title($tool_name);
 
-
-
 if ($_POST['form_sent']) {
 	$form_sent = $_POST['form_sent'];
 	$users = is_array($_POST['user_list']) ? $_POST['user_list'] : array() ;
@@ -109,16 +79,12 @@ if ($_POST['form_sent']) {
 
 
 
-/*
------------------------------------------------------------
-	Display GUI
------------------------------------------------------------
-*/
+/*	Display GUI	*/
 
 
 if(empty($first_letter_user)) {
 	$sql = "SELECT count(*) as nb_users FROM $tbl_user";
-	$result = Database::query($sql, __FILE__, __LINE__);
+	$result = Database::query($sql);
 	$num_row = Database::fetch_array($result);
 	if($num_row['nb_users']>1000) {
 		//if there are too much users to gracefully handle with the HTML select list,
@@ -133,12 +99,12 @@ $target_name = api_sort_by_first_name() ? 'firstname' : 'lastname';
 $sql = "SELECT user_id,lastname,firstname,username FROM $tbl_user
 	    WHERE ".$target_name." LIKE '".$first_letter_user."%' OR ".$target_name." LIKE '".api_strtolower($first_letter_user)."%'
 		ORDER BY ". (count($users) > 0 ? "(user_id IN(".implode(',', $users).")) DESC," : "")." ".$target_name;
-$result = Database::query($sql, __FILE__, __LINE__);
+$result = Database::query($sql);
 $db_users = Database::store_result($result);
 unset($result);
 
 $sql = "SELECT id, url FROM $tbl_access_url  WHERE active=1 ORDER BY url";
-$result = Database::query($sql, __FILE__, __LINE__);
+$result = Database::query($sql);
 $db_urls = Database::store_result($result);
 unset($result);
 ?>
@@ -193,10 +159,6 @@ unset($result);
  </table>
 </form>
 <?php
-/*
-==============================================================================
-		FOOTER
-==============================================================================
-*/
+/*		FOOTER	*/
 Display :: display_footer();
 ?>

+ 23 - 44
main/admin/access_url_edit.php

@@ -1,43 +1,23 @@
 <?php
-/*
-==============================================================================
-	Dokeos - elearning and course management software
-
-	Copyright (c) 2009 Dokeos SPRL
-	Copyright (c) 2009 Julio Montoya Armas <gugli100@gmail.com>
-
-	For a full list of contributors, see "credits.txt".
-	The full license can be read in "license.txt".
-
-	This program is free software; you can redistribute it and/or
-	modify it under the terms of the GNU General Public License
-	as published by the Free Software Foundation; either version 2
-	of the License, or (at your option) any later version.
-
-	See the GNU General Public License for more details.
-
-	Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
-	Mail: info@dokeos.com
-==============================================================================
-*/
+/* For licensing terms, see /license.txt */
 /**
-==============================================================================
-*	@package dokeos.admin
-==============================================================================
+*	@package chamilo.admin
+*	@author Julio Montoya <gugli100@gmail.com>
 */
 
 $language_file = 'admin';
 $cidReset = true;
-require ('../inc/global.inc.php');
+require_once '../inc/global.inc.php';
 $this_section = SECTION_PLATFORM_ADMIN;
 
 api_protect_admin_script();
-if (!$_configuration['multiple_access_urls'])
+if (!$_configuration['multiple_access_urls']) {
 	header('Location: index.php');
+}
 
-require_once (api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php');
-require_once (api_get_path(LIBRARY_PATH).'security.lib.php');
-require_once (api_get_path(LIBRARY_PATH).'urlmanager.lib.php');
+require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php';
+require_once api_get_path(LIBRARY_PATH).'security.lib.php';
+require_once api_get_path(LIBRARY_PATH).'urlmanager.lib.php';
 
 // Create the form
 $form = new FormValidator('add_url');
@@ -85,9 +65,7 @@ if( $form->validate()) {
 		header('Location: '.$url_to_go.'?action=show_message&message='.urlencode($message).'&sec_token='.$tok);
 		exit();
 	}
-}
-else
-{
+} else {
 	if(isset($_POST['submit'])) {
 		Security::clear_token();
 	}
@@ -96,23 +74,27 @@ else
 	$form->setConstants(array('sec_token' => $token));
 }
 
+
 $form->addElement('text','url',get_lang('URL'),array('size'=>'30'));
 $form->addRule('url', get_lang('ThisFieldIsRequired'), 'required');
 $form->addRule('url', '', 'maxlength',254);
 $form->addElement('textarea','description',get_lang('Description'));
-$form->addElement('checkbox','active',get_lang('Active'));
-$form->addRule('checkbox', get_lang('ThisFieldIsRequired'), 'required');
+
+//the first url with id = 1 will be always active
+if ($_GET['url_id'] != 1) {
+	$form->addElement('checkbox','active',get_lang('Active'));
+}
+
+//$form->addRule('checkbox', get_lang('ThisFieldIsRequired'), 'required');
 
 $defaults['url']='http://';
 $form->setDefaults($defaults);
 
 $submit_name = get_lang('Add');
-if (isset($_GET['url_id']))
-{
+if (isset($_GET['url_id'])) {
 	$url_id = Database::escape_string($_GET['url_id']);
 	$num_url_id = UrlManager::url_id_exist($url_id);
-	if($num_url_id != 1)
-	{
+	if($num_url_id != 1) {
 		header('Location: access_urls.php');
 		exit();
 	}
@@ -130,10 +112,8 @@ $interbreadcrumb[] = array ("url" => 'index.php', "name" => get_lang('PlatformAd
 $interbreadcrumb[] = array ("url" => 'access_urls.php', "name" => get_lang('MultipleAccessURLs'));
 Display :: display_header($tool_name);
 
-if (isset ($_GET['action']))
-{
-	switch ($_GET['action'])
-	{
+if (isset ($_GET['action'])) {
+	switch ($_GET['action']) {
 		case 'show_message' :
 			Display :: display_normal_message(stripslashes($_GET['message']));
 			break;
@@ -141,6 +121,5 @@ if (isset ($_GET['action']))
 }
 
 // Submit button
-$form->addElement('submit', 'submit', $submit_name);
+$form->addElement('style_submit_button', 'submit', $submit_name, 'class="add"');
 $form->display();
-?>

+ 11 - 60
main/admin/access_url_edit_courses_to_url.php

@@ -1,30 +1,11 @@
 <?php
-/*
-==============================================================================
-	Dokeos - elearning and course management software
-
-	Copyright (c) 2009 Dokeos SPRL
-	Copyright (c) 2009 Julio Montoya Armas <gugli100@gmail.com>
-
-	For a full list of contributors, see "credits.txt".
-	The full license can be read in "license.txt".
-
-	This program is free software; you can redistribute it and/or
-	modify it under the terms of the GNU General Public License
-	as published by the Free Software Foundation; either version 2
-	of the License, or (at your option) any later version.
-
-	See the GNU General Public License for more details.
-
-	Contact: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium, info@dokeos.com
-==============================================================================
-*/
+/* For licensing terms, see /license.txt */
 /**
-==============================================================================
-*	@package dokeos.admin
-==============================================================================
+*	@package chamilo.admin
+*	@author Julio Montoya <gugli100@gmail.com>
 */
 
+
 // name of the language file that needs to be included
 $language_file='admin';
 
@@ -32,10 +13,11 @@ $language_file='admin';
 $cidReset=true;
 
 // including some necessary dokeos files
-require('../inc/global.inc.php');
+require_once '../inc/global.inc.php';
 
 require_once (api_get_path(LIBRARY_PATH).'urlmanager.lib.php');
-require_once ('../inc/lib/xajax/xajax.inc.php');
+require_once (api_get_path(LIBRARY_PATH).'access_url_edit_courses_to_url_functions.lib.php');
+
 $xajax = new xajax();
 //$xajax->debugOn();
 $xajax -> registerFunction ('search_courses');
@@ -45,8 +27,10 @@ $this_section = SECTION_PLATFORM_ADMIN;
 
 // Access restrictions
 api_protect_admin_script();
-if (!$_configuration['multiple_access_urls'])
+if (!$_configuration['multiple_access_urls']) {
 	header('Location: index.php');
+	exit;
+}
 
 
 // Database Table Definitions
@@ -70,39 +54,6 @@ if(isset($_REQUEST['access_url_id']) && $_REQUEST['access_url_id']!=''){
 	$access_url_id = Security::remove_XSS($_REQUEST['access_url_id']);
 }
 
-function search_courses($needle, $id)
-{
-	global $tbl_course;
-	$xajax_response = new XajaxResponse();
-	$return = '';
-
-	if(!empty($needle)) {
-		// xajax send utf8 datas... datas in db can be non-utf8 datas
-		$charset = api_get_setting('platform_charset');
-		$needle = api_convert_encoding($needle, $charset, 'utf-8');
-		$needle = Database::escape_string($needle);
-		// search courses where username or firstname or lastname begins likes $needle
-		$sql = 'SELECT code, title FROM '.$tbl_course.' u
-				WHERE (title LIKE "'.$needle.'%"
-				OR code LIKE "'.$needle.'%"
-				)
-				ORDER BY title, code
-				LIMIT 11';
-		$rs = Database::query($sql, __FILE__, __LINE__);
-        $i=0;
-		while ($course = Database :: fetch_array($rs)) {
-			$i++;
-            if ($i<=10) {
-			     $return .= '<a href="javascript: void(0);" onclick="javascript: add_user_to_url(\''.addslashes($course['code']).'\',\''.addslashes($course['title']).' ('.addslashes($course['code']).')'.'\')">'.$course['title'].' ('.$course['code'].')</a><br />';
-            } else {
-            	$return .= '...<br />';
-            }
-		}
-	}
-	$xajax_response -> addAssign('ajax_list_courses','innerHTML',api_utf8_encode($return));
-	return $xajax_response;
-}
-
 $xajax -> processRequests();
 $htmlHeadXtra[] = $xajax->getJavascript('../inc/lib/xajax/');
 $htmlHeadXtra[] = '
@@ -197,7 +148,7 @@ if($ajax_search) {
 	$sql="SELECT code, title
 	  	  	FROM $tbl_course u
 			ORDER BY title, code";
-	$result=Database::query($sql,__FILE__,__LINE__);
+	$result=Database::query($sql);
 	$courses=Database::store_result($result);
 	$course_list_leys = array_keys($course_list);
 	foreach($courses as $course) {

+ 11 - 58
main/admin/access_url_edit_sessions_to_url.php

@@ -1,30 +1,11 @@
 <?php
-/*
-==============================================================================
-	Dokeos - elearning and course management software
-
-	Copyright (c) 2009 Dokeos SPRL
-	Copyright (c) 2009 Julio Montoya Armas <gugli100@gmail.com>
-
-	For a full list of contributors, see "credits.txt".
-	The full license can be read in "license.txt".
-
-	This program is free software; you can redistribute it and/or
-	modify it under the terms of the GNU General Public License
-	as published by the Free Software Foundation; either version 2
-	of the License, or (at your option) any later version.
-
-	See the GNU General Public License for more details.
-
-	Contact: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium, info@dokeos.com
-==============================================================================
-*/
+/* For licensing terms, see /license.txt */
 /**
-==============================================================================
-*	@package dokeos.admin
-==============================================================================
+*	@package chamilo.admin
+*	@author Julio Montoya <gugli100@gmail.com>
 */
 
+
 // name of the language file that needs to be included
 $language_file='admin';
 
@@ -32,10 +13,10 @@ $language_file='admin';
 $cidReset=true;
 
 // including some necessary dokeos files
-require('../inc/global.inc.php');
-
+require_once '../inc/global.inc.php';
 require_once (api_get_path(LIBRARY_PATH).'urlmanager.lib.php');
-require_once ('../inc/lib/xajax/xajax.inc.php');
+require_once (api_get_path(LIBRARY_PATH).'access_url_edit_sessions_to_url_functions.lib.php');
+
 $xajax = new xajax();
 //$xajax->debugOn();
 $xajax -> registerFunction ('search_sessions');
@@ -45,8 +26,10 @@ $this_section = SECTION_PLATFORM_ADMIN;
 
 // Access restrictions
 api_protect_admin_script();
-if (!$_configuration['multiple_access_urls'])
+if (!$_configuration['multiple_access_urls']) {
 	header('Location: index.php');
+	exit;
+}
 
 
 // Database Table Definitions
@@ -69,36 +52,6 @@ if(isset($_REQUEST['access_url_id']) && $_REQUEST['access_url_id']!=''){
 	$access_url_id = Security::remove_XSS(intval($_REQUEST['access_url_id']));
 }
 
-function search_sessions($needle, $id)
-{
-	global $tbl_session;
-	$xajax_response = new XajaxResponse();
-	$return = '';
-
-	if(!empty($needle)) {
-		// xajax send utf8 datas... datas in db can be non-utf8 datas
-		$charset = api_get_setting('platform_charset');
-		$needle = api_convert_encoding($needle, $charset, 'utf-8');
-		$needle = Database::escape_string($needle);
-		// search sessiones where username or firstname or lastname begins likes $needle
-		$sql = 'SELECT id, name FROM '.$tbl_session.' u
-				WHERE (name LIKE "'.$needle.'%")
-				ORDER BY name, id
-				LIMIT 11';
-		$rs = Database::query($sql, __FILE__, __LINE__);
-        $i=0;
-		while ($session = Database :: fetch_array($rs)) {
-			$i++;
-            if ($i<=10) {
-			     $return .= '<a href="#" onclick="add_user_to_url(\''.addslashes($session['id']).'\',\''.addslashes($session['name']).' ('.addslashes($session['id']).')'.'\')">'.$session['name'].' </a><br />';
-            } else {
-            	$return .= '...<br />';
-            }
-		}
-	}
-	$xajax_response -> addAssign('ajax_list_courses','innerHTML',api_utf8_encode($return));
-	return $xajax_response;
-}
 
 $xajax -> processRequests();
 $htmlHeadXtra[] = $xajax->getJavascript('../inc/lib/xajax/');
@@ -193,7 +146,7 @@ if($ajax_search) {
 	$sql="SELECT id, name
 	  	  	FROM $tbl_session u
 			ORDER BY name, id";
-	$result=Database::query($sql,__FILE__,__LINE__);
+	$result=Database::query($sql);
 	$sessions=Database::store_result($result);
 	$session_list_leys = array_keys($session_list);
 	foreach($sessions as $session) {

+ 10 - 64
main/admin/access_url_edit_users_to_url.php

@@ -1,30 +1,11 @@
 <?php
-/*
-==============================================================================
-	Dokeos - elearning and course management software
-
-	Copyright (c) 2009 Dokeos SPRL
-	Copyright (c) 2009 Julio Montoya Armas <gugli100@gmail.com>
-
-	For a full list of contributors, see "credits.txt".
-	The full license can be read in "license.txt".
-
-	This program is free software; you can redistribute it and/or
-	modify it under the terms of the GNU General Public License
-	as published by the Free Software Foundation; either version 2
-	of the License, or (at your option) any later version.
-
-	See the GNU General Public License for more details.
-
-	Contact: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium, info@dokeos.com
-==============================================================================
-*/
+/* For licensing terms, see /license.txt */
 /**
-==============================================================================
-*	@package dokeos.admin
-==============================================================================
+*	@package chamilo.admin
+*	@author Julio Montoya <gugli100@gmail.com>
 */
 
+
 // name of the language file that needs to be included
 $language_file='admin';
 
@@ -32,8 +13,7 @@ $language_file='admin';
 $cidReset=true;
 
 // including some necessary dokeos files
-require('../inc/global.inc.php');
-
+require_once '../inc/global.inc.php';
 require_once (api_get_path(LIBRARY_PATH).'urlmanager.lib.php');
 require_once ('../inc/lib/xajax/xajax.inc.php');
 $xajax = new xajax();
@@ -45,8 +25,10 @@ $this_section = SECTION_PLATFORM_ADMIN;
 
 // Access restrictions
 api_protect_admin_script();
-if (!$_configuration['multiple_access_urls'])
+if (!$_configuration['multiple_access_urls']) {
 	header('Location: index.php');
+	exit;
+}
 
 
 // Database Table Definitions
@@ -69,42 +51,6 @@ if(isset($_REQUEST['access_url_id']) && $_REQUEST['access_url_id']!=''){
 	$access_url_id = Security::remove_XSS($_REQUEST['access_url_id']);
 }
 
-function search_users($needle, $id)
-{
-	global $tbl_user, $tbl_access_url_rel_user;
-	$xajax_response = new XajaxResponse();
-	$return = '';
-
-	if(!empty($needle)) {
-		// xajax send utf8 datas... datas in db can be non-utf8 datas
-		$charset = api_get_setting('platform_charset');
-		$needle = api_convert_encoding($needle, $charset, 'utf-8');
-		$needle = Database::escape_string($needle);
-		// search users where username or firstname or lastname begins likes $needle
-		$order_clause = api_sort_by_first_name() ? ' ORDER BY firstname, lastname, username' : ' ORDER BY lastname, firstname, username';
-		$sql = 'SELECT u.user_id, username, lastname, firstname FROM '.$tbl_user.' u
-				WHERE (username LIKE "'.$needle.'%"
-				OR firstname LIKE "'.$needle.'%"
-				OR lastname LIKE "'.$needle.'%")'.
-				$order_clause.
-				' LIMIT 11';
-
-		$rs = Database::query($sql, __FILE__, __LINE__);
-        $i=0;
-
-		while ($user = Database :: fetch_array($rs)) {
-			$i++;
-            if ($i<=10) {
-			    $return .= '<a href="javascript: void(0);" onclick="javascript: add_user_to_url(\''.addslashes($user['user_id']).'\',\''.api_get_person_name(addslashes($user['firstname']), addslashes($user['lastname'])).' ('.addslashes($user['username']).')'.'\')">'.api_get_person_name($user['firstname'], $user['lastname']).' ('.$user['username'].')</a><br />';
-            } else {
-            	$return .= '...<br />';
-            }
-		}
-	}
-	$xajax_response -> addAssign('ajax_list_users','innerHTML',api_utf8_encode($return));
-	return $xajax_response;
-}
-
 $xajax -> processRequests();
 $htmlHeadXtra[] = $xajax->getJavascript('../inc/lib/xajax/');
 $htmlHeadXtra[] = '
@@ -193,9 +139,9 @@ if($ajax_search) {
 	}
 	$order_clause = api_sort_by_first_name() ? ' ORDER BY firstname, lastname, username' : ' ORDER BY lastname, firstname, username';
 	$sql="SELECT u.user_id, lastname, firstname, username
-	  	  	FROM $tbl_user u".
+	  	  	FROM $tbl_user u WHERE status <> ".ANONYMOUS." ".
 			$order_clause;
-	$result=Database::query($sql,__FILE__,__LINE__);
+	$result=Database::query($sql);
 	$Users=Database::store_result($result);
 	$user_list_leys = array_keys($sessionUsersList);
 	foreach($Users as $user) {

+ 19 - 57
main/admin/access_urls.php

@@ -1,49 +1,31 @@
 <?php
-/*
-==============================================================================
-	Dokeos - elearning and course management software
-
-	Copyright (c) 2009 Dokeos SPRL
-	Copyright (c) 2009 Julio Montoya Armas <gugli100@gmail.com>
-
-	For a full list of contributors, see "credits.txt".
-	The full license can be read in "license.txt".
-
-	This program is free software; you can redistribute it and/or
-	modify it under the terms of the GNU General Public License
-	as published by the Free Software Foundation; either version 2
-	of the License, or (at your option) any later version.
-
-	See the GNU General Public License for more details.
-
-	Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
-	Mail: info@dokeos.com
-==============================================================================
-*/
+/* For licensing terms, see /license.txt */
 /**
-==============================================================================
-*	@package dokeos.admin
-==============================================================================
+*	@package chamilo.admin
+*	@author Julio Montoya <gugli100@gmail.com>
 */
 
 // name of the language file that needs to be included
 $language_file = 'admin';
 $cidReset = true;
-require ('../inc/global.inc.php');
+require_once '../inc/global.inc.php';
+require_once api_get_path(LIBRARY_PATH).'sortabletable.class.php';
 $this_section = SECTION_PLATFORM_ADMIN;
 
 api_protect_admin_script();
-if (!$_configuration['multiple_access_urls'])
+if (!$_configuration['multiple_access_urls']) {
 	header('Location: index.php');
+	exit;
+}
 
-$interbreadcrumb[] = array ("url" => 'index.php', "name" => get_lang('PlatformAdmin'));
+$interbreadcrumb[] = array ("url" => 'index.php', 'name' => get_lang('PlatformAdmin'));
 $tool_name = get_lang('MultipleAccessURLs');
 Display :: display_header($tool_name);
 
-require_once (api_get_path(LIBRARY_PATH).'sortabletable.class.php');
-require_once (api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php');
-require_once (api_get_path(LIBRARY_PATH).'security.lib.php');
-require_once (api_get_path(LIBRARY_PATH).'urlmanager.lib.php');
+require_once api_get_path(LIBRARY_PATH).'sortabletable.class.php';
+require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php';
+require_once api_get_path(LIBRARY_PATH).'security.lib.php';
+require_once api_get_path(LIBRARY_PATH).'urlmanager.lib.php';
 
 $my_user_url_list = api_get_access_url_from_user(api_get_user_id());
 $current_access_url_id = api_get_current_access_url_id();
@@ -83,7 +65,7 @@ if (isset ($_GET['action'])) {
 						foreach($url_list as $my_url) {
 							if (!in_array($my_url['id'],$my_user_url_list)){
 								UrlManager::add_user_to_url(api_get_user_id(),$my_url['id']);
-									$url_str.=$my_url['url'].' ';
+									$url_str.=$my_url['url'].' <br />';
 							}
 						}
 						Display :: display_normal_message(get_lang('AdminUserRegisteredToThisURL').': '.$url_str.'<br />',false);
@@ -104,11 +86,11 @@ $url_string='';
 $my_user_url_list = api_get_access_url_from_user(api_get_user_id());
 foreach($url_list as $my_url) {
 	if (!in_array($my_url['id'],$my_user_url_list)){
-		$url_string.=$my_url['url'].' ';
+		$url_string.=$my_url['url'].' <br />';
 	}
 }
 if(!empty($url_string)) {
-	Display :: display_warning_message(get_lang('AdminShouldBeRegisterInSite').':<br />'.$url_string,false);
+	Display :: display_warning_message(get_lang('AdminShouldBeRegisterInSite').'<br />'.$url_string,false);
 }
 
 // checking the current installation
@@ -138,30 +120,14 @@ $table->set_header(0, '', false);
 $table->set_header(1, get_lang('URL'));
 $table->set_header(2, get_lang('Description'));
 $table->set_header(3, get_lang('Active'));
-//$table->set_header(4, get_lang('Status'));
 $table->set_header(4, get_lang('Modify'));
 
 $table->set_column_filter(3, 'active_filter');
-//$table->set_column_filter(4, 'status_filter');
 $table->set_column_filter(4, 'modify_filter');
 
-//$table->set_form_actions(array ('delete' => get_lang('DeleteFromPlatform')));
+
 $table->display();
-/*
-function status_filter($active, $url_params, $row) {
-	$url_id =UrlManager::get_url_id($row[1]);
-	if ($row[0] == $url_id ) {
-		$action='lock';
-		$image='right';
-	} else {
-		$image='wrong';
-	}
-	// you cannot lock the default
-	$result = Display::return_icon($image.'.gif', get_lang(ucfirst($action)));
 
-	return $result;
-}
-*/
 function modify_filter($active, $url_params, $row) {
 	global $charset;
 	$url_id = $row['0'];
@@ -199,10 +165,6 @@ function url_count_mask() {
 	return UrlManager::url_count();
 }
 
-/*
-==============================================================================
-		FOOTER
-==============================================================================
-*/
+/*		FOOTER	*/
 Display :: display_footer();
-?>
+?>

+ 21 - 120
main/admin/add_courses_to_session.php

@@ -1,11 +1,9 @@
 <?php //$id: $
-/* For licensing terms, see /dokeos_license.txt */
-/**
-==============================================================================
-*	@package dokeos.admin
-* 	@todo use formvalidator
-==============================================================================
-*/
+/* For licensing terms, see /license.txt */
+/**	
+ * @package chamilo.admin
+ * @todo use formvalidator
+ */
 
 // name of the language file that needs to be included
 $language_file='admin';
@@ -14,11 +12,14 @@ $language_file='admin';
 $cidReset=true;
 
 // including some necessary dokeos files
-require '../inc/global.inc.php';
+require_once('../inc/global.inc.php');
 
 // including additonal libraries
-require_once '../inc/lib/xajax/xajax.inc.php';
+
 require_once api_get_path(LIBRARY_PATH).'sessionmanager.lib.php';
+require_once (api_get_path(LIBRARY_PATH).'add_courses_to_session_functions.lib.php');
+
+
 $xajax = new xajax();
 //$xajax->debugOn();
 $xajax -> registerFunction ('search_courses');
@@ -51,108 +52,12 @@ if(isset($_GET['add_type']) && $_GET['add_type']!=''){
 
 if (!api_is_platform_admin()) {
 	$sql = 'SELECT session_admin_id FROM '.Database :: get_main_table(TABLE_MAIN_SESSION).' WHERE id='.$id_session;
-	$rs = Database::query($sql,__FILE__,__LINE__);
+	$rs = Database::query($sql);
 	if (Database::result($rs,0,0)!=$_user['user_id']) {
 		api_not_allowed(true);
 	}
 }
 
-function search_courses($needle,$type)
-{
-	global $tbl_course, $tbl_session_rel_course, $id_session;
-
-	$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_setting('platform_charset');
-		$needle = api_convert_encoding($needle, $charset, 'utf-8');
-
-		$cond_course_code = '';
-		if (!empty($id_session)) {
-		$id_session = Database::escape_string($id_session);
-			// check course_code from session_rel_course table
-			$sql = 'SELECT course_code FROM '.$tbl_session_rel_course.' WHERE id_session ="'.(int)$id_session.'"';
-			$res = Database::query($sql,__FILE__,__LINE__);
-			$course_codes = '';
-			if (Database::num_rows($res) > 0) {
-				while ($row = Database::fetch_row($res)) {
-					$course_codes .= '\''.$row[0].'\',';
-				}
-				$course_codes = substr($course_codes,0,(strlen($course_codes)-1));
-
-				$cond_course_code = ' AND course.code NOT IN('.$course_codes.') ';
-			}
-		}
-
-		if ($type=='single') {
-		// search users where username or firstname or lastname begins likes $needle
-		$sql = 'SELECT course.code, course.visual_code, course.title, session_rel_course.id_session
-				FROM '.$tbl_course.' course
-				LEFT JOIN '.$tbl_session_rel_course.' session_rel_course
-					ON course.code = session_rel_course.course_code
-					AND session_rel_course.id_session = '.intval($id_session).'
-				WHERE course.visual_code LIKE "'.$needle.'%"
-				OR course.title LIKE "'.$needle.'%"';
-		} else {
-
-		$sql = 'SELECT course.code, course.visual_code, course.title
-				FROM '.$tbl_course.' course
-				WHERE course.visual_code LIKE "'.$needle.'%" '.$cond_course_code.' ORDER BY course.code ';
-		}
-
-		global $_configuration;
-		if ($_configuration['multiple_access_urls']==true) {
-			$tbl_course_rel_access_url= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
-			$access_url_id = api_get_current_access_url_id();
-			if ($access_url_id != -1){
-
-				if ($type=='single') {
-					$sql = 'SELECT course.code, course.visual_code, course.title, session_rel_course.id_session
-							FROM '.$tbl_course.' course
-							LEFT JOIN '.$tbl_session_rel_course.' session_rel_course
-								ON course.code = session_rel_course.course_code
-								AND session_rel_course.id_session = '.intval($id_session).'
-							INNER JOIN '.$tbl_course_rel_access_url.' url_course ON (url_course.course_code=course.code)
-							WHERE access_url_id = '.$access_url_id.' AND (course.visual_code LIKE "'.$needle.'%"
-							OR course.title LIKE "'.$needle.'%" )';
-				} else {
-					$sql = 'SELECT course.code, course.visual_code, course.title
-							FROM '.$tbl_course.' course, '.$tbl_course_rel_access_url.' url_course
-							WHERE url_course.course_code=course.code AND access_url_id = '.$access_url_id.'
-							AND course.visual_code LIKE "'.$needle.'%" '.$cond_course_code.' ORDER BY course.code ';
-				}
-			}
-		}
-
-		$rs = Database::query($sql, __FILE__, __LINE__);
-		$course_list = array();
-		if ($type=='single') {
-
-			while($course = Database :: fetch_array($rs)) {
-				$course_list[] = $course['code'];
-				$course_title=str_replace("'","\'",$course_title);
-				$return .= '<a href="javascript: void(0);" onclick="javascript: add_course_to_session(\''.$course['code'].'\',\''.$course_title.' ('.$course['visual_code'].')'.'\')">'.$course['title'].' ('.$course['visual_code'].')</a><br />';
-			}
-
-			$xajax_response -> addAssign('ajax_list_courses_single','innerHTML',api_utf8_encode($return));
-
-		} else {
-
-			$return .= '<select id="origin" name="NoSessionCoursesList[]" multiple="multiple" size="20" style="width:340px;">';
-			while($course = Database :: fetch_array($rs)) {
-				$course_list[] = $course['code'];
-				$course_title=str_replace("'","\'",$course_title);
-				$return .= '<option value="'.$course['code'].'" title="'.htmlspecialchars($course['title'].' ('.$course['visual_code'].')',ENT_QUOTES).'">'.$course['title'].' ('.$course['visual_code'].')</option>';
-			}
-			$return .= '</select>';
-
-			$xajax_response -> addAssign('ajax_list_courses_multiple','innerHTML',api_utf8_encode($return));
-		}
-	}
-	$_SESSION['course_list'] = $course_list;
-	return $xajax_response;
-}
 $xajax -> processRequests();
 
 $htmlHeadXtra[] = $xajax->getJavascript('../inc/lib/xajax/');
@@ -214,8 +119,8 @@ if ($_POST['formSent']) {
 
 	$sql="SELECT id_user
 		FROM $tbl_session_rel_user
-		WHERE id_session = $id_session";
-	$result=Database::query($sql,__FILE__,__LINE__);
+		WHERE id_session = $id_session AND relation_type=".COURSE_RELATION_TYPE_RRHH." ";
+	$result=Database::query($sql);
 	$UserList=Database::store_result($result);
 
 
@@ -229,19 +134,19 @@ if ($_POST['formSent']) {
 		}
 		if(!$exists) {
 			$sql_insert_rel_course= "INSERT INTO $tbl_session_rel_course(id_session,course_code) VALUES('$id_session','$enreg_course')";
-			Database::query($sql_insert_rel_course ,__FILE__,__LINE__);
+			Database::query($sql_insert_rel_course );
 			//We add in the existing courses table the current course, to not try to add another time the current course
 			$existingCourses[]=array('course_code'=>$enreg_course);
 			$nbr_users=0;
 			foreach ($UserList as $enreg_user) {
 				$enreg_user = Database::escape_string($enreg_user['id_user']);
 				$sql_insert = "INSERT IGNORE INTO $tbl_session_rel_course_rel_user(id_session,course_code,id_user) VALUES('$id_session','$enreg_course','$enreg_user')";
-				Database::query($sql_insert,__FILE__,__LINE__);
+				Database::query($sql_insert);
 				if(Database::affected_rows()) {
 					$nbr_users++;
 				}
 			}
-			Database::query("UPDATE $tbl_session_rel_course SET nbr_users=$nbr_users WHERE id_session='$id_session' AND course_code='$enreg_course'",__FILE__,__LINE__);
+			Database::query("UPDATE $tbl_session_rel_course SET nbr_users=$nbr_users WHERE id_session='$id_session' AND course_code='$enreg_course'");
 		}
 
 	}
@@ -254,7 +159,7 @@ if ($_POST['formSent']) {
 		}
 	}
 	$nbr_courses=count($CourseList);
-	Database::query("UPDATE $tbl_session SET nbr_courses=$nbr_courses WHERE id='$id_session'",__FILE__,__LINE__);
+	Database::query("UPDATE $tbl_session SET nbr_courses=$nbr_courses WHERE id='$id_session'");
 
 	if(isset($_GET['add']))
 		header('Location: add_users_to_session.php?id_session='.$id_session.'&add=true');
@@ -289,7 +194,7 @@ echo '<div class="row"><div class="form_header">'.$tool_name.' ('.$session_info[
 
 
 /*$sql = 'SELECT COUNT(1) FROM '.$tbl_course;
-$rs = Database::query($sql, __FILE__, __LINE__);
+$rs = Database::query($sql);
 $count_courses = Database::result($rs, 0, 0);*/
 
 $ajax_search = $add_type == 'unique' ? true : false;
@@ -320,7 +225,7 @@ if ($ajax_search) {
 		}
 	}
 
-	$result=Database::query($sql,__FILE__,__LINE__);
+	$result=Database::query($sql);
 	$Courses=Database::store_result($result);
 
 	foreach($Courses as $course) {
@@ -350,7 +255,7 @@ if ($ajax_search) {
 		}
 	}
 
-	$result=Database::query($sql,__FILE__,__LINE__);
+	$result=Database::query($sql);
 	$Courses=Database::store_result($result);
 	foreach($Courses as $course) {
 		if ($course['id_session'] == $id_session) {
@@ -529,10 +434,6 @@ function valide(){
 
 </script>
 <?php
-/*
-==============================================================================
-		FOOTER
-==============================================================================
-*/
+/*		FOOTER 	*/
 Display::display_footer();
 ?>

+ 9 - 35
main/admin/add_many_session_to_category.php

@@ -11,12 +11,12 @@
 $language_file='admin';
 // resetting the course id
 $cidReset=true;
+require_once('../inc/global.inc.php');
 
 // including some necessary dokeos files
-require '../inc/global.inc.php';
 
 // including additonal libraries
-require_once '../inc/lib/xajax/xajax.inc.php';
+require_once api_get_path(LIBRARY_PATH).'add_many_session_to_category_functions.lib.php';
 require_once api_get_path(LIBRARY_PATH).'sessionmanager.lib.php';
 $xajax = new xajax();
 $xajax -> registerFunction ('search_courses');
@@ -50,40 +50,14 @@ if(isset($_GET['add_type']) && $_GET['add_type']!=''){
 	$add_type = Security::remove_XSS($_REQUEST['add_type']);
 }
 
-if (!api_is_platform_admin()) {
+if (!api_is_platform_admin() && !api_is_session_admin()) {
 	$sql = 'SELECT session_admin_id FROM '.Database :: get_main_table(TABLE_MAIN_SESSION).' WHERE id='.$id_session;
-	$rs = Database::query($sql,__FILE__,__LINE__);
+	$rs = Database::query($sql);
 	if (Database::result($rs,0,0)!=$_user['user_id']) {
 		api_not_allowed(true);
 	}
 }
 
-function search_courses($needle,$type) {
-	global $tbl_course, $tbl_session, $id_session;
-
-	$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_setting('platform_charset');
-		$needle = api_convert_encoding($needle, $charset, 'utf-8');
-
-		$sql = 'SELECT * FROM '.$tbl_session.' WHERE name LIKE "'.$needle.'%" ORDER BY id';
-
-		$rs = Database::query($sql, __FILE__, __LINE__);
-		$course_list = array();
-
-		$return .= '<select id="origin" name="NoSessionCategoryList[]" multiple="multiple" size="20" style="width:340px;">';
-		while($course = Database :: fetch_array($rs)) {
-			$course_list[] = $course['id'];
-			$return .= '<option value="'.$course['id'].'" title="'.htmlspecialchars($course['name'],ENT_QUOTES).'">'.$course['name'].'</option>';
-		}
-		$return .= '</select>';
-		$xajax_response -> addAssign('ajax_list_courses_multiple','innerHTML',api_utf8_encode($return));
-	}
-	$_SESSION['course_list'] = $course_list;
-	return $xajax_response;
-}
 $xajax -> processRequests();
 $htmlHeadXtra[] = $xajax->getJavascript('../inc/lib/xajax/');
 $htmlHeadXtra[] = '
@@ -132,7 +106,7 @@ if ($_POST['formSent']) {
 	if($Categoryid != 0 && count($SessionCategoryList)>0 ){
 		$session_id = join(',', $SessionCategoryList);
 		$sql = "UPDATE $tbl_session SET session_category_id = $Categoryid WHERE id in ($session_id) ";
-		Database::query($sql,__FILE__,__LINE__);
+		Database::query($sql);
 		header('Location: session_list.php?id_category='.$Categoryid);
 	} else {
 		header('Location: add_many_session_to_category.php?msg=error');
@@ -153,19 +127,19 @@ $rows_category_session = array();
 if(isset($_POST['CategorySessionId']) && $_POST['formSent'] == 0 ){
 	$where = 'WHERE session_category_id !='.intval($_POST['CategorySessionId']);
 	$sql = 'SELECT id, name  FROM '.$tbl_session .' WHERE session_category_id ='.intval($_POST['CategorySessionId']).' ORDER BY name';
-	$result=Database::query($sql,__FILE__,__LINE__);
+	$result=Database::query($sql);
 	$rows_category_session = Database::store_result($result);
 }
 
 $sql = "SELECT id, name  FROM $tbl_session_category ORDER BY name";
-$result=Database::query($sql,__FILE__,__LINE__);
+$result=Database::query($sql);
 $rows_session_category = Database::store_result($result);
 
 $sql = "SELECT id, name  FROM $tbl_session $where ORDER BY name";
-$result=Database::query($sql,__FILE__,__LINE__);
+$result=Database::query($sql);
 $rows_session = Database::store_result($result);
 ?>
-<form name="formulaire" method="post" action="<?php echo api_get_self(); ?>?page=<?php echo $_GET['page']; if(!empty($_GET['add'])) echo '&add=true' ; ?>" style="margin:0px;" <?php if($ajax_search){echo ' onsubmit="valide();"';}?>>
+<form name="formulaire" method="post" action="<?php echo api_get_self(); ?>?page=<?php echo Security::remove_XSS($_GET['page']); if(!empty($_GET['add'])) echo '&add=true' ; ?>" style="margin:0px;" <?php if($ajax_search){echo ' onsubmit="valide();"';}?>>
 <input type="hidden" name="formSent" value="1" />
 <?php
 if(!empty($errorMsg))

+ 274 - 274
main/admin/add_users_to_group.php

@@ -13,12 +13,10 @@ $language_file=array('admin','registration');
 $cidReset=true;
 
 // including some necessary dokeos files
-require('../inc/global.inc.php');
-
-require_once ('../inc/lib/xajax/xajax.inc.php');
-$xajax = new xajax();
-//$xajax->debugOn();
-$xajax -> registerFunction ('search_users');
+require_once '../inc/global.inc.php';
+require_once '../inc/lib/xajax/xajax.inc.php';
+require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
+require_once api_get_path(LIBRARY_PATH).'group_portal_manager.lib.php';
 
 // setting the section (for the tabs)
 $this_section = SECTION_PLATFORM_ADMIN;
@@ -45,14 +43,67 @@ if(isset($_REQUEST['add_type']) && $_REQUEST['add_type']!=''){
 }
 
 //checking for extra field with filter on
-include_once (api_get_path(LIBRARY_PATH).'usermanager.lib.php');
-include_once (api_get_path(LIBRARY_PATH).'group_portal_manager.lib.php');
-
-function search_users($needle,$type)
-{
-	global $tbl_user,$tbl_group_rel_user,$group_id;
+$xajax = new xajax();
+$xajax->registerFunction('search_users');
+function search_users($needle,$type,$relation_type) {
+	global $tbl_user,$tbl_group_rel_user,$group_id,$_configuration;
 	$xajax_response = new XajaxResponse();
-	$return = '';
+	$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.") ";
+		$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_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)) {
 
@@ -61,96 +112,73 @@ function search_users($needle,$type)
 		$needle = Database::escape_string($needle);
 		$needle = api_convert_encoding($needle, $charset, 'utf-8');
 		$user_anonymous=api_get_anonymous_id();
+		$tbl_user_rel_access_url= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
 
 		$order_clause = api_sort_by_first_name() ? ' ORDER BY firstname, lastname, username' : ' ORDER BY lastname, firstname, username';
-		$cond_user_id = '';
-		if (!empty($id_session)) {
-		$group_id = Database::escape_string($group_id);
-			// check id_user from session_rel_user table
-			$sql = 'SELECT id_user FROM '.$tbl_group_rel_user.' WHERE group_id ="'.(int)$group_id.'"';
-			$res = Database::query($sql,__FILE__,__LINE__);
-			$user_ids = array();
-			if (Database::num_rows($res) > 0) {
-				while ($row = Database::fetch_row($res)) {
-					$user_ids[] = (int)$row[0];
-				}
-			}
-			if (count($user_ids) > 0){
-				$cond_user_id = ' AND user_id NOT IN('.implode(",",$user_ids).')';
-			}
-		}
-
 		if ($type == 'single') {
-			// 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.'"'.
-				$order_clause.
-				' LIMIT 11';
-		} else {
-			$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.'"'.$cond_user_id.
-					$order_clause;
-		}
-
-		global $_configuration;
-		if ($_configuration['multiple_access_urls']==true) {
-			$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){
-				if ($type == 'single') {
-					$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.'"'.
-					$order_clause.
-					' LIMIT 11';
-				} else {
-					$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.'"'.$cond_user_id.
-					$order_clause;
+			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']==true) {
+					$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 = Database::query($sql, __FILE__, __LINE__);
-        $i=0;
-		if ($type=='single') {
-			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(\''.$user['user_id'].'\',\''.$person_name.' ('.$user['username'].')'.'\')">'.$person_name.' ('.$user['username'].')</a><br />';
-	            } else {
-	            	$return .= '...<br />';
-	            }
+				$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');
 			}
 
-			$xajax_response -> addAssign('ajax_list_users_single','innerHTML',api_utf8_encode($return));
-
 		} else {
-			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>';
+			// 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']==true) {
+					$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 .= '</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 (code, content) {
@@ -194,197 +222,150 @@ $UserList=$SessionList=array();
 $users=$sessions=array();
 $noPHP_SELF=true;
 
-
 $group_info = GroupPortalManager::get_group_data($group_id);
-Display::display_header($tool_name);
-//api_display_tool_title($tool_name.' ('.$session_info['name'].')');
+$group_name = $group_info['name'];
 
+Display::display_header($group_name);
 
 if($_POST['form_sent']) {
+
 	$form_sent			= $_POST['form_sent'];
 	$firstLetterUser	= $_POST['firstLetterUser'];
-	$firstLetterSession	= $_POST['firstLetterSession'];
 	$UserList			= $_POST['sessionUsersList'];
-	$ClassList			= $_POST['sessionClassesList'];	
 	$group_id			= intval($_POST['id']);
-	
+	$relation_type		= intval($_POST['relation']);
+
 	if(!is_array($UserList)) {
 		$UserList=array();
 	}
-	if ($form_sent == 1) {		
-		GroupPortalManager::delete_users($group_id);
-		$result = GroupPortalManager::add_users_to_groups($UserList, array($group_id));
+	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'));
 	}
 }
 
 $nosessionUsersList = $sessionUsersList = array();
-/*$sql = 'SELECT COUNT(1) FROM '.$tbl_user;
-$rs = Database::query($sql, __FILE__, __LINE__);
-$count_courses = Database::result($rs, 0, 0);*/
 $ajax_search = $add_type == 'unique' ? true : false;
-global $_configuration;
 
 $order_clause = api_sort_by_first_name() ? ' ORDER BY firstname, lastname, username' : ' ORDER BY lastname, firstname, username';
 
 if ($ajax_search) {
-	$sql="SELECT  u.user_id, lastname, firstname, username, group_id
-				FROM $tbl_user u
-				LEFT JOIN $tbl_group_rel_user gu
-				ON (gu.user_id = u.user_id) WHERE gu.group_id = $group_id ".
-			$order_clause;
 
-	if ($_configuration['multiple_access_urls']==true) {
-		$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
-			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.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
-				$order_clause";
-		}
-	}	
-	$result=Database::query($sql,__FILE__,__LINE__);
-	$Users=Database::store_result($result);
-	foreach ($Users as $user) {
-		$sessionUsersList[$user['user_id']] = $user ;
-	}
-} else {
-		/*
-		//Filter by Extra Fields
-		$use_extra_fields = false;
-		if (is_array($extra_field_list)) {
-			if (is_array($new_field_list) && count($new_field_list)>0 ) {
-				$result_list=array();
-				foreach ($new_field_list as $new_field) {
-					$varname = 'field_'.$new_field['variable'];
-					if (Usermanager::is_extra_field_available($new_field['variable'])) {
-						if (isset($_POST[$varname]) && $_POST[$varname]!='0') {
-							$use_extra_fields = true;
-							$extra_field_result[]= Usermanager::get_extra_user_data_by_value($new_field['variable'], $_POST[$varname]);
-						}
-					}
-				}
-			}
-		}
-		*/
-		$use_extra_fields =false;
-		
-		if ($use_extra_fields) {
-			$final_result = array();
-			if (count($extra_field_result)>1) {
-				for($i=0;$i<count($extra_field_result)-1;$i++) {
-					if (is_array($extra_field_result[$i+1])) {
-						$final_result  = array_intersect($extra_field_result[$i],$extra_field_result[$i+1]);
-					}
-				}
-			} else {
-				$final_result = $extra_field_result[0];
-			}
+	// 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 = "";
 
-			$where_filter ='';
-			if ($_configuration['multiple_access_urls']==true) {
-				if (is_array($final_result) && count($final_result)>0) {
-					$where_filter = " AND u.user_id IN  ('".implode("','",$final_result)."') ";
-				} else {
-					//no results
-					$where_filter = " AND u.user_id  = -1";
-				}
-			} else {
-				if (is_array($final_result) && count($final_result)>0) {
-					$where_filter = " WHERE u.user_id IN  ('".implode("','",$final_result)."') ";
-				} else {
-					//no results
-					$where_filter = " WHERE u.user_id  = -1";
-				}
-			}
+		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' ";
 		}
 
-		if ($use_extra_fields) {
-			$sql="SELECT  user_id, lastname, firstname, username, group_id
-				FROM $tbl_user u
-				LEFT JOIN $tbl_session_rel_user
-				ON $tbl_session_rel_user.id_user = u.user_id AND id_session = '$id_session'
-				$where_filter
-			$order_clause";			
-		} else {			
-			$sql="SELECT  u.user_id, lastname, firstname, username, group_id
-				FROM $tbl_user u
-				LEFT JOIN $tbl_group_rel_user gu
-				ON (gu.user_id = u.user_id) AND gu.group_id = $group_id
-			$order_clause";
-		}
-		
-		if ($_configuration['multiple_access_urls']==true) {
-			$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
-				FROM $tbl_user u
-				LEFT JOIN $tbl_session_rel_user
-					ON $tbl_session_rel_user.id_user = u.user_id AND id_session = '$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  $where_filter
-			$order_clause";
+		$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 ;
 			}
 		}
+	}
 
-		$result = Database::query($sql,__FILE__,__LINE__);
-		$Users	= Database::store_result($result);
+} else {
 
-		foreach ($Users as $user) {
-			if($user['group_id'] != $group_id)
-				$nosessionUsersList[$user['user_id']] = $user ;
+	$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']==true) {
+		$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 = Database::fetch_row($rs_count);
+	if ($row_count > 2) $many_users = true;
+
+	// data for origin list
+	if (isset($_POST['id']) && isset($_POST['firstLetterUser'])) {
+		$id = intval($_POST['id']);
+		$needle = Database::escape_string($_POST['firstLetterUser']);
+		$needle = api_convert_encoding($needle, $charset, 'utf-8');
 		$user_anonymous=api_get_anonymous_id();
-		foreach($nosessionUsersList as $key_user_list =>$value_user_list) {
-			if ($nosessionUsersList[$key_user_list]['user_id']==$user_anonymous) {
-				unset($nosessionUsersList[$key_user_list]);
+		// 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.") ";
+		$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_id NOT IN(".implode(',',$user_ids).") ";
 		}
 
-		//filling the correct users in list
-		$sql="SELECT u.user_id, lastname, firstname, username, group_id
-			FROM $tbl_user u
-			LEFT JOIN $tbl_group_rel_user
-			ON $tbl_group_rel_user.user_id = u.user_id AND group_id = '$group_id'
-			$order_clause";
-
+		$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']==true) {
-			$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
-				FROM $tbl_user u
-				LEFT JOIN $tbl_session_rel_user
-					ON $tbl_session_rel_user.id_user = u.user_id AND id_session = '$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
-				$order_clause";
+			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 ";
 			}
 		}
-		
-		$result=Database::query($sql,__FILE__,__LINE__);
-		$Users=Database::store_result($result);
-		
-		foreach($Users as $key_user_list =>$value_user_list) {
-			if ($Users[$key_user_list]['user_id']==$user_anonymous) {
-				unset($Users[$key_user_list]);
-				}
+		$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;
 		}
-		
-		foreach ($Users as $user) {
-			if($user['group_id'] == $group_id) {
-				$sessionUsersList[$user['user_id']] = $user;
-				if (array_key_exists($user['user_id'],$nosessionUsersList))
-		            unset($nosessionUsersList[$user['user_id']]);
+	}
+
+	// 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 ;
 			}
 		}
+	}
 }
 
 if ($add_type == 'multiple') {
@@ -404,6 +385,17 @@ if ($add_type == 'multiple') {
 
 <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 if ($add_type=='multiple') { ?>
+<select name="relation" id="relation" onchange="xajax_search_users(document.getElementById('firstLetterUser').value,'multiple',this.value)">
+<?php } else { ?>
+<select name="relation" id="relation" onchange="xajax_search_users(document.getElementById('user_to_add').value,'single',this.value);">
+<?php } ?>
+<option value=""><?php echo get_lang('ChooseRelationType')?></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_MODERATOR ?>" <?php echo ((isset($_POST['relation']) && $_POST['relation']==GROUP_USER_PERMISSION_MODERATOR)?'selected=selected':'') ?> > <?php echo get_lang('Moderator') ?></option>
+</select>
+
 <?php
 if ($add_type=='multiple') {
 	if (is_array($extra_field_list)) {
@@ -434,8 +426,8 @@ if ($add_type=='multiple') {
 ?>
 
 <input type="hidden" name="form_sent" value="1" />
-<input type="hidden" name="id" value="<?=$group_id?>" />
-<input type="hidden" name="add_type"  />
+<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)) {
@@ -448,7 +440,7 @@ if(!empty($errorMsg)) {
 <tr>
   <td align="center"><b><?php echo get_lang('UserListInPlatform') ?> :</b>
   </td>
-  <td></td>
+  <td>&nbsp;</td>
   <td align="center"><b><?php echo get_lang('UserListInGroup') ?> :</b></td>
 </tr>
 
@@ -457,36 +449,40 @@ if(!empty($errorMsg)) {
 <td align="center">
 
 <?php echo get_lang('FirstLetterUser'); ?> :
-     <select name="firstLetterUser" onchange = "xajax_search_users(this.value,'multiple')" >
-      <option value = "%">--</option>
-      <?php
-        echo Display :: get_alphabet_options();
-      ?>
-     </select>
+	<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>
+     </div>
 </td>
 <td align="center">&nbsp;</td>
 </tr>
 <?php } ?>
-
-
 <tr>
   <td align="center">
   <div id="content_source">
   	  <?php
   	  if (!($add_type=='multiple')) {
   	  	?>
-		<input type="text" id="user_to_add" onkeyup="xajax_search_users(this.value,'single')" />
+		<input type="text" id="user_to_add" onkeyup="xajax_search_users(this.value,'single',document.getElementById('relation').value)" />
 		<div id="ajax_list_users_single"></div>
 		<?php
   	  } else {
   	  ?>
-  	  <div id="ajax_list_users_multiple">
+  	  <div id="ajax_origin_list_multiple">
 	  <select id="origin_users" name="nosessionUsersList[]" multiple="multiple" size="15" style="width:360px;">
 		<?php
-		foreach($nosessionUsersList as $enreg) {
-		?>
-			<option value="<?php echo $enreg['user_id']; ?>" <?php if(in_array($enreg['user_id'],$UserList)) echo 'selected="selected"'; ?>><?php echo api_get_person_name($enreg['firstname'], $enreg['lastname']).' ('.$enreg['username'].')'; ?></option>
-		<?php
+
+		if (!empty($nosessionUsersList)) {
+			foreach($nosessionUsersList as $enreg) {
+			?>
+				<option value="<?php echo $enreg['user_id']; ?>"  > <?php echo $enreg['firstname'].' '.$enreg['lastname'].' ('.$enreg['username'].')'; ?></option>
+			<?php
+			}
 		}
 		?>
 	  </select>
@@ -514,20 +510,17 @@ if(!empty($errorMsg)) {
 	<br /><br /><br /><br /><br />
   </td>
   <td align="center">
+  <div id="ajax_destination_list">
   <select id="destination_users" name="sessionUsersList[]" multiple="multiple" size="15" style="width:360px;">
-
-<?php
-foreach($sessionUsersList as $enreg) {
-?>
-	<option value="<?php echo $enreg['user_id']; ?>"><?php echo $enreg['firstname'].' '.$enreg['lastname'].' ('.$enreg['username'].')'; ?></option>
-
-<?php
-}
-
-unset($sessionUsersList);
-?>
-
-  </select></td>
+	<?php
+	if (!empty($sessionUsersList)) {
+		foreach($sessionUsersList as $enreg) { ?>
+			<option value="<?php echo $enreg['user_id']; ?>"><?php echo $enreg['firstname'].' '.$enreg['lastname'].' ('.$enreg['username'].')'; ?></option>
+	<?php }
+	} unset($sessionUsersList);?>
+  </select>
+  </div>
+  </td>
 </tr>
 <tr>
 	<td colspan="3" align="center">
@@ -579,11 +572,18 @@ function mysort(a, b){
 	return 0;
 }
 
-function valide(){
-	var options = document.getElementById('destination_users').options;
-	for (i = 0 ; i<options.length ; i++)
-		options[i].selected = true;
-	document.forms.formulaire.submit();
+function valide() {
+
+	var relation_select = document.getElementById('relation');
+	if (relation_select && relation_select.value=="") {
+		alert("<?php echo get_lang('YouMustChooseARelationType')?>");
+		return false;
+	} else {
+		var options = document.getElementById('destination_users').options;
+		for (i = 0 ; i<options.length ; i++)
+			options[i].selected = true;
+		document.forms.formulaire.submit();
+	}
 }
 
 

+ 29 - 29
main/admin/add_users_to_session.php

@@ -53,7 +53,7 @@ if(isset($_REQUEST['add_type']) && $_REQUEST['add_type']!=''){
 
 if (!api_is_platform_admin()) {
 	$sql = 'SELECT session_admin_id FROM '.Database :: get_main_table(TABLE_MAIN_SESSION).' WHERE id='.$id_session;
-	$rs = Database::query($sql,__FILE__,__LINE__);
+	$rs = Database::query($sql);
 	if(Database::result($rs,0,0)!=$_user['user_id']) {
 		api_not_allowed(true);
 	}
@@ -92,8 +92,8 @@ function search_users($needle,$type)
 		if (!empty($id_session)) {
 		$id_session = Database::escape_string($id_session);
 			// check id_user from session_rel_user table
-			$sql = 'SELECT id_user FROM '.$tbl_session_rel_user.' WHERE id_session ="'.(int)$id_session.'"';
-			$res = Database::query($sql,__FILE__,__LINE__);
+			$sql = 'SELECT id_user FROM '.$tbl_session_rel_user.' WHERE id_session ="'.(int)$id_session.'" AND relation_type<>'.SESSION_RELATION_TYPE_RRHH.' ';
+			$res = Database::query($sql);
 			$user_ids = array();
 			if (Database::num_rows($res) > 0) {
 				while ($row = Database::fetch_row($res)) {
@@ -110,12 +110,12 @@ function search_users($needle,$type)
 			$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.'"'.
+				OR lastname LIKE "'.$needle.'%") AND user_id<>"'.$user_anonymous.'"   AND user.status<>'.DRH.''. 
 				$order_clause.
 				' LIMIT 11';
 		} else {
 			$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.'"'.$cond_user_id.
+					WHERE '.(api_sort_by_first_name() ? 'firstname' : 'lastname').' LIKE "'.$needle.'%" AND user.status<>'.DRH.' AND user_id<>"'.$user_anonymous.'"'.$cond_user_id.
 					$order_clause;
 		}
 
@@ -129,21 +129,21 @@ function search_users($needle,$type)
 					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.'"'.
+					OR lastname LIKE "'.$needle.'%") AND user.user_id<>"'.$user_anonymous.'" AND user.status<>'.DRH.' '.
 					$order_clause.
 					' LIMIT 11';
 				} else {
 					$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.'"'.$cond_user_id.
+					AND '.(api_sort_by_first_name() ? 'firstname' : 'lastname').' LIKE "'.$needle.'%" AND user.status<>'.DRH.' AND user.user_id<>"'.$user_anonymous.'"'.$cond_user_id.
 					$order_clause;
 				}
 
 			}
 		}
 
-		$rs = Database::query($sql, __FILE__, __LINE__);
+		$rs = Database::query($sql);
         $i=0;
 		if ($type=='single') {
 			while ($user = Database :: fetch_array($rs)) {
@@ -264,7 +264,7 @@ Display::display_header($tool_name);
 
 $nosessionUsersList = $sessionUsersList = array();
 /*$sql = 'SELECT COUNT(1) FROM '.$tbl_user;
-$rs = Database::query($sql, __FILE__, __LINE__);
+$rs = Database::query($sql);
 $count_courses = Database::result($rs, 0, 0);*/
 $ajax_search = $add_type == 'unique' ? true : false;
 global $_configuration;
@@ -274,9 +274,9 @@ if ($ajax_search) {
 	$sql="SELECT user_id, lastname, firstname, username, id_session
 			FROM $tbl_user
 			INNER JOIN $tbl_session_rel_user
-				ON $tbl_session_rel_user.id_user = $tbl_user.user_id
-				AND $tbl_session_rel_user.id_session = ".intval($id_session).
-			$order_clause;
+				ON $tbl_session_rel_user.id_user = $tbl_user.user_id AND $tbl_session_rel_user.relation_type<>".SESSION_RELATION_TYPE_RRHH."
+				AND $tbl_session_rel_user.id_session = ".intval($id_session)."
+			    WHERE status<>".DRH." $order_clause";
 
 	if ($_configuration['multiple_access_urls']==true) {
 		$tbl_user_rel_access_url= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
@@ -285,14 +285,14 @@ if ($ajax_search) {
 			$sql="SELECT u.user_id, lastname, firstname, username, id_session
 			FROM $tbl_user u
 			INNER JOIN $tbl_session_rel_user
-				ON $tbl_session_rel_user.id_user = u.user_id
+				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
+				WHERE access_url_id = $access_url_id AND u.status<>".DRH."
 				$order_clause";
 		}
 	}
-	$result=Database::query($sql,__FILE__,__LINE__);
+	$result=Database::query($sql);
 	$Users=Database::store_result($result);
 	foreach ($Users as $user) {
 		$sessionUsersList[$user['user_id']] = $user ;
@@ -349,15 +349,16 @@ if ($ajax_search) {
 			$sql="SELECT  user_id, lastname, firstname, username, id_session
 				FROM $tbl_user u
 				LEFT JOIN $tbl_session_rel_user
-				ON $tbl_session_rel_user.id_user = u.user_id AND id_session = '$id_session'
-				$where_filter
+				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."
 			$order_clause";
 
 		} else {
 			$sql="SELECT  user_id, lastname, firstname, username, id_session
 				FROM $tbl_user u
 				LEFT JOIN $tbl_session_rel_user
-				ON $tbl_session_rel_user.id_user = u.user_id AND id_session = '$id_session'
+				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."
 			$order_clause";
 		}
 		if ($_configuration['multiple_access_urls']==true) {
@@ -367,14 +368,14 @@ if ($ajax_search) {
 				$sql="SELECT  u.user_id, lastname, firstname, username, id_session
 				FROM $tbl_user u
 				LEFT JOIN $tbl_session_rel_user
-					ON $tbl_session_rel_user.id_user = u.user_id AND id_session = '$id_session'
+					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
+				WHERE access_url_id = $access_url_id  $where_filter AND u.status<>".DRH."
 			$order_clause";
 			}
 		}
-		
-		$result=Database::query($sql,__FILE__,__LINE__);
+
+		$result=Database::query($sql);
 		$Users=Database::store_result($result);
 		//var_dump($_REQUEST['id_session']);
 		foreach ($Users as $user) {
@@ -391,8 +392,8 @@ if ($ajax_search) {
 		$sql="SELECT  user_id, lastname, firstname, username, id_session
 			FROM $tbl_user u
 			LEFT JOIN $tbl_session_rel_user
-			ON $tbl_session_rel_user.id_user = u.user_id AND id_session = '$id_session'
-			$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 u.status<>".DRH." $order_clause";
 
 		if ($_configuration['multiple_access_urls']==true) {
 			$tbl_user_rel_access_url= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
@@ -401,13 +402,13 @@ if ($ajax_search) {
 				$sql="SELECT  u.user_id, lastname, firstname, username, id_session
 				FROM $tbl_user u
 				LEFT JOIN $tbl_session_rel_user
-					ON $tbl_session_rel_user.id_user = u.user_id AND id_session = '$id_session'
+					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 access_url_id = $access_url_id AND u.status<>".DRH."
 				$order_clause";
 			}
 		}
-	$result=Database::query($sql,__FILE__,__LINE__);
+	$result=Database::query($sql);
 	$Users=Database::store_result($result);
 
 	foreach($Users as $key_user_list =>$value_user_list) {
@@ -422,8 +423,7 @@ if ($ajax_search) {
 			if (array_key_exists($user['user_id'],$nosessionUsersList))
                 unset($nosessionUsersList[$user['user_id']]);
 		}
-/*		else if ( $sessionUsersList[$user['user_id']]['id_session']!=$id_session )
-			$nosessionUsersList[$user['user_id']] = $user ;*/
+
 	}
 }
 

+ 124 - 121
main/admin/calendar.lib.php

@@ -1,8 +1,8 @@
 <?php // $id: $
-/* For licensing terms, see /dokeos_license.txt */
+/* For licensing terms, see /license.txt */
 /**
 ==============================================================================
-*	@package dokeos.admin
+*	@package chamilo.admin
 *	@author Carlos Vargas
 *	This file is the calendar/agenda.inc.php
 ==============================================================================
@@ -425,7 +425,7 @@ function store_new_agenda_item()
 					        VALUES
 					        ('".$title."','".$content."', '".$start_date."','".$end_date."')";
 
-	$result = Database::query($sql,__FILE__,__LINE__) or die (Database::error());
+	$result = Database::query($sql) or die (Database::error());
 	$last_id=Database::insert_id();
 
 	// store in last_tooledit (first the groups, then the users
@@ -475,11 +475,12 @@ function store_new_agenda_item()
             {
         	   $sql = "INSERT INTO $t_agenda_repeat (cal_id, cal_type, cal_end)" .
                     " VALUES ($last_id,'$type',$end)";
-               $res = Database::query($sql,__FILE__,__LINE__);
+               $res = Database::query($sql);
             }
         }
     }
 	return $last_id;*/
+	return $last_id;
 }
 
 /**
@@ -521,17 +522,14 @@ function get_agenda_item($id)
 	$TABLEAGENDA = Database::get_main_table(TABLE_MAIN_SYSTEM_CALENDAR);
     //$t_agenda_repeat = Database::get_course_table(TABLE_AGENDA_REPEAT);
     $item = array();
-	if(empty($id))
-    {
-        $id=(int)addslashes($_GET['id']);
-    }
-    else
-    {
-    	$id = (int) $id;
+	if(empty($id)) {
+        $id=intval($_GET['id']);
+    } else {
+    	$id = intval($id);
     }
     if(empty($id)){return $item;}
 	$sql 					= "SELECT * FROM ".$TABLEAGENDA." WHERE id='".$id."'";
-	$result					= Database::query($sql,__FILE__,__LINE__);
+	$result					= Database::query($sql);
 	$entry_to_edit 			= Database::fetch_array($result);
 	$item['title']			= $entry_to_edit["title"];
 	$item['content']		= $entry_to_edit["content"];
@@ -597,7 +595,7 @@ function save_edit_agenda_item($id,$title,$content,$start_date,$end_date)
 									start_date='".$start_date."',
 									end_date='".$end_date."'
 								WHERE id='".$id."'";
-	$result = Database::query($sql,__FILE__,__LINE__) or die (Database::error());
+	$result = Database::query($sql) or die (Database::error());
 	return true;
 }
 
@@ -609,31 +607,24 @@ function save_edit_agenda_item($id,$title,$content,$start_date,$end_date)
 * by the course administrator
 * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
 * @param integer the id of the agenda item wa are deleting
+* @return bool true if it's success or false otherwise
 */
 function delete_agenda_item($id)
 {
 	global $_course;
-	$id=Database::escape_string($id);
-	if (is_allowed_to_edit()  && !api_is_anonymous())
-	{
-		if (!empty($_GET['id']) && isset($_GET['action']) && $_GET['action']=="delete")
-		{
-		    $t_agenda     = Database::get_main_table(TABLE_MAIN_SYSTEM_CALENDAR);
-            $id=(int)addslashes($_GET['id']);
-            $sql = "SELECT * FROM $t_agenda WHERE id = $id";
-            $res = Database::query($sql,__FILE__,__LINE__);
-            if(Database::num_rows($res)>0)
-            {
-                $sql = "DELETE FROM ".$t_agenda." WHERE id='$id'";
-                $result = Database::query($sql,__FILE__,__LINE__) or die (Database::error());
-            }
-			api_item_property_update($_course,TOOL_CALENDAR_EVENT,$id,'delete',api_get_user_id());
-			$id=null;
-			echo '<br />';
-			Display::display_normal_message(get_lang("AgendaDeleteSuccess"));
-		}
-	}
 
+	$t_agenda = Database::get_main_table(TABLE_MAIN_SYSTEM_CALENDAR);
+	$id = intval($id);
+	$sql = "SELECT * FROM $t_agenda WHERE id = '$id'";
+    $res = Database::query($sql);
+    if(Database::num_rows($res) > 0)
+    {
+        $sql = "DELETE FROM ".$t_agenda." WHERE id='$id'";
+        $result = Database::query($sql) or die (Database::error());
+        api_item_property_update($_course,TOOL_CALENDAR_EVENT,$id,'delete',api_get_user_id());
+        return true;
+    }
+    return false;
 }
 /**
 * Makes an agenda item visible or invisible for a student
@@ -715,7 +706,7 @@ function display_agenda_items()
 	if (is_allowed_to_edit() && !api_is_anonymous()) {
 		$sql="SELECT * FROM ".$TABLEAGENDA.' ORDER BY start_date '.$_SESSION['sort'];
 		//echo "<pre>".$sql."</pre>";
-		$result=Database::query($sql,__FILE__,__LINE__) or die(Database::error());
+		$result=Database::query($sql) or die(Database::error());
 		$number_items=Database::num_rows($result);
 	} else {
 		$number_items = 0;
@@ -748,12 +739,13 @@ function display_agenda_items()
         /*--------------------------------------------------
         		display: the month bar
          --------------------------------------------------*/
-        // Make the month bar appear only once.
-        if ($month_bar != date("m",strtotime($myrow["start_date"])).date("Y",strtotime($myrow["start_date"])))
+
+        $myrow["start_date"] = api_get_local_time($myrow["start_date"], null, date_default_timezone_get());
+        if ($month_bar != api_format_date($myrow["start_date"], "%m%Y"))
 		{
-            $month_bar = date("m",strtotime($myrow["start_date"])).date("Y",strtotime($myrow["start_date"]));
+            $month_bar = api_format_date($myrow["start_date"], "%m%Y");
 			echo "\t<tr>\n\t\t<td class=\"agenda_month_divider\" colspan=\"3\" valign=\"top\">".
-			api_ucfirst(format_locale_date("%B %Y",strtotime($myrow["start_date"]))).
+			api_format_date($myrow["start_date"], "%B %Y").
 			"</td>\n\t</tr>\n";
 		}
 
@@ -763,7 +755,7 @@ function display_agenda_items()
     	echo '<tr>';
 
     	// highlight: if a date in the small calendar is clicked we highlight the relevant items
-    	$db_date=(int)date("d",strtotime($myrow["start_date"])).date("n",strtotime($myrow["start_date"])).date("Y",strtotime($myrow["start_date"]));
+    	$db_date = (int)api_format_date($myrow["start_date"], "%d").intval(api_format_date($myrow["start_date"], "%m")).api_format_date($myrow["start_date"], "%Y");
     	if ($_GET["day"].$_GET["month"].$_GET["year"] <>$db_date)
     	{
     		if ($myrow['visibility']=='0')
@@ -822,15 +814,13 @@ function display_agenda_items()
          --------------------------------------------------*/
     	echo "<tr class='row_odd'>";
     	echo "\t\t<td>".get_lang("StartTimeWindow").": ";
-    	echo api_ucfirst(format_locale_date($dateFormatLong,strtotime($myrow["start_date"])))."&nbsp;&nbsp;&nbsp;";
-    	echo ucfirst(strftime($timeNoSecFormat,strtotime($myrow["start_date"])))."";
+    	echo api_format_date($myrow["start_date"]);
     	echo "</td>\n";
     	echo "\t\t<td>";
     	if ($myrow["end_date"]<>"0000-00-00 00:00:00")
     	{
     		echo get_lang("EndTimeWindow").": ";
-    		echo api_ucfirst(format_locale_date($dateFormatLong,strtotime($myrow["end_date"])))."&nbsp;&nbsp;&nbsp;";
-    		echo ucfirst(strftime($timeNoSecFormat,strtotime($myrow["end_date"])))."";
+    		echo api_convert_and_format_date($myrow["end_date"], null, date_default_timezone_get());
     	}
     	echo "</td>\n";
 
@@ -856,29 +846,29 @@ function display_agenda_items()
 	    		echo Display::return_icon('delete.gif', get_lang('Delete'))."</a>";
 			}
 
-    	if (!$is_repeated && (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_edit_agenda') && !api_is_anonymous())))
-    	{
-    		if( ! (api_is_course_coach() && !api_is_element_in_the_session(TOOL_AGENDA, $myrow['id'] ) ) )
-			{ // a coach can only delete an element belonging to his session
-    			$td_colspan= '<td colspan="3">';
-			}
-			else
-			{
-				$td_colspan= '<td colspan="2">';
-			}
-    	}
-    	else
-    	{
-    		$td_colspan= '<td colspan="2">';
-    	}
-    	$mylink = 'calendar_ical_export.php?'.api_get_cidreq().'&amp;type=course&amp;id='.$myrow['id'];
-		echo '<a class="ical_export" href="'.$mylink.'&amp;class=confidential" title="'.get_lang('ExportiCalConfidential').'">'.Display::return_icon($export_icon_high, get_lang('ExportiCalConfidential')).'</a> ';
-    	echo '<a class="ical_export" href="'.$mylink.'&amp;class=private" title="'.get_lang('ExportiCalPrivate').'">'.Display::return_icon($export_icon_low, get_lang('ExportiCalPrivate')).'</a> ';
-    	echo '<a class="ical_export" href="'.$mylink.'&amp;class=public" title="'.get_lang('ExportiCalPublic').'">'.Display::return_icon($export_icon, get_lang('ExportiCalPublic')).'</a> ';
-	    echo '<a href="#" onclick="javascript:win_print=window.open(\'calendar_view_print.php?id='.$myrow['id'].'\',\'popup\',\'left=100,top=100,width=700,height=500,scrollbars=1,resizable=0\'); win_print.focus(); return false;">'.Display::return_icon('print.gif', get_lang('Print')).'</a>&nbsp;';
-    	echo '</td>';
-    	echo '</tr>';
-}
+	    	if (!$is_repeated && (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_edit_agenda') && !api_is_anonymous())))
+	    	{
+	    		if( ! (api_is_course_coach() && !api_is_element_in_the_session(TOOL_AGENDA, $myrow['id'] ) ) )
+				{ // a coach can only delete an element belonging to his session
+	    			$td_colspan= '<td colspan="3">';
+				}
+				else
+				{
+					$td_colspan= '<td colspan="2">';
+				}
+	    	}
+	    	else
+	    	{
+	    		$td_colspan= '<td colspan="2">';
+	    	}
+	    	$mylink = 'calendar_ical_export.php?'.api_get_cidreq().'&amp;type=course&amp;id='.$myrow['id'];
+			echo '<a class="ical_export" href="'.$mylink.'&amp;class=confidential" title="'.get_lang('ExportiCalConfidential').'">'.Display::return_icon($export_icon_high, get_lang('ExportiCalConfidential')).'</a> ';
+	    	echo '<a class="ical_export" href="'.$mylink.'&amp;class=private" title="'.get_lang('ExportiCalPrivate').'">'.Display::return_icon($export_icon_low, get_lang('ExportiCalPrivate')).'</a> ';
+	    	echo '<a class="ical_export" href="'.$mylink.'&amp;class=public" title="'.get_lang('ExportiCalPublic').'">'.Display::return_icon($export_icon, get_lang('ExportiCalPublic')).'</a> ';
+		    echo '<a href="#" onclick="javascript:win_print=window.open(\'calendar_view_print.php?id='.$myrow['id'].'\',\'popup\',\'left=100,top=100,width=700,height=500,scrollbars=1,resizable=0\'); win_print.focus(); return false;">'.Display::return_icon('print.gif', get_lang('Print')).'</a>&nbsp;';
+	    	echo '</td>';
+	    	echo '</tr>';
+		}
 
         /*--------------------------------------------------
      			display: the content
@@ -981,12 +971,12 @@ function display_one_agenda_item($agenda_id)
 	  --------------------------------------------------*/
 
 	$sql="SELECT *	FROM ".$TABLEAGENDA;
-	$result=Database::query($sql,__FILE__,__LINE__) or die(Database::error());
+	$result=Database::query($sql) or die(Database::error());
 	$number_items=Database::num_rows($result);
 	$myrow=Database::fetch_array($result); // there should be only one item so no need for a while loop
 
     $sql_rep = "SELECT * FROM $TABLEAGENDA WHERE id = $agenda_id";
-    $res_rep = Database::query($sql_rep,__FILE__,__LINE__);
+    $res_rep = Database::query($sql_rep);
     $repeat = false;
     $repeat_id = 0;
     if(Database::num_rows($res_rep)>0)
@@ -1015,8 +1005,9 @@ function display_one_agenda_item($agenda_id)
 	echo "\t<tr>\n";
 
 	// highlight: if a date in the small calendar is clicked we highlight the relevant items
-	$db_date=(int)date("d",strtotime($myrow["start_date"])).date("n",strtotime($myrow["start_date"])).date("Y",strtotime($myrow["start_date"]));
-	if ($_GET["day"].$_GET["month"].$_GET["year"] <>$db_date)
+	$myrow["start_date"] = api_get_local_time($myrow["start_date"], null, date_default_timezone_get());
+	$db_date = (int)api_format_date($myrow["start_date"], "%d").intval(api_format_date($myrow["start_date"], "%m")).api_format_date($myrow["start_date"], "%Y");
+    if ($_GET["day"].$_GET["month"].$_GET["year"] <>$db_date)
 	{
 		if ($myrow['visibility']=='0')
 		{
@@ -1057,9 +1048,9 @@ function display_one_agenda_item($agenda_id)
 
 	// the message has been sent to
 	echo "\t\t<td class=\"".$stylenotbold."\">".get_lang("SentTo").": ".get_lang('AllUsersOfThePlatform');
-	$sent_to=sent_to(TOOL_CALENDAR_EVENT, $myrow["ref"]);
-	$sent_to_form=sent_to_form($sent_to);
-	echo $sent_to_form;
+	//$sent_to = sent_to(TOOL_CALENDAR_EVENT, $myrow["ref"]);
+	//sent_to_form=sent_to_form($sent_to);
+	//echo $sent_to_form;
 	echo "</td>\n\t</tr>\n";
 
 	/*--------------------------------------------------
@@ -1067,12 +1058,10 @@ function display_one_agenda_item($agenda_id)
 	  --------------------------------------------------*/
 	echo "\t<tr class=\"".$stylenotbold."\">\n";
 	echo "\t\t<td>".get_lang("StartTime").": ";
-	echo api_ucfirst(format_locale_date($dateFormatLong,strtotime($myrow["start_date"])))."&nbsp;&nbsp;&nbsp;";
-	echo ucfirst(strftime($timeNoSecFormat,strtotime($myrow["start_date"])))."";
+	echo api_format_date($myrow["start_date"]);
 	echo "</td>\n";
 	echo "\t\t<td>".get_lang("EndTime").": ";
-	echo api_ucfirst(format_locale_date($dateFormatLong,strtotime($myrow["end_date"])))."&nbsp;&nbsp;&nbsp;";
-	echo ucfirst(strftime($timeNoSecFormat,strtotime($myrow["end_date"])))."";
+	echo api_convert_and_format_date($myrow["end_date"], null, date_default_timezone_get());
 	echo "</td>\n";
 	echo "\n\t</tr>\n";
 
@@ -1097,6 +1086,7 @@ function display_one_agenda_item($agenda_id)
 	/*--------------------------------------------------
 	 			DISPLAY: the added resources
 	  --------------------------------------------------*/
+	/*
 	if (check_added_resources("Agenda", $myrow["id"]))
 		{
 		echo "<tr><td colspan='2'>";
@@ -1108,7 +1098,7 @@ function display_one_agenda_item($agenda_id)
 		display_added_resources("Agenda", $myrow["id"], $addedresource_style);
 		echo "</td></tr>";
 		}
-
+	*/
 	/*--------------------------------------------------
 		DISPLAY: edit delete button (course admin only)
 	  --------------------------------------------------*/
@@ -1146,6 +1136,7 @@ function display_one_agenda_item($agenda_id)
 		"</table>";
 }
 /**
+ * (This function is probably deprecated for this module)
 * Show the form for adding a new agenda item. This is the same function that is used whenever we are editing an
 * agenda item. When the id parameter is empty (default behaviour), then we show an empty form, else we are editing and
 * we have to retrieve the information that is in the database and use this information in the forms.
@@ -1155,7 +1146,8 @@ function display_one_agenda_item($agenda_id)
 */
 function show_group_filter_form()
 {
-$group_list=get_course_groups();
+/** @todo this select missing to implement */
+//$group_list=get_course_groups();
 
 echo "<select name=\"select\" onchange=\"MM_jumpMenu('parent',this,0)\">";
 echo "<option value=\"agenda.php?group=none\">show all groups</option>";
@@ -1165,16 +1157,19 @@ echo "<option value=\"agenda.php?group=none\">show all groups</option>";
 	echo "<option value=\"agenda.php?group=".$this_group['id']."\" ";
 	echo ($this_group['id']==$_SESSION['group'])? " selected":"" ;
 	echo ">".$this_group['name']."</option>";
-	}*/
+	}
+*/
 echo "</select>";
 }
 
 function show_user_filter_form()
 {
-$user_list=get_course_users();
 
-//echo "<select name=\"select\" onchange=\"MM_jumpMenu('parent',this,0)\">";
-//echo "<option value=\"agenda.php?user=none\">show all users</option>";
+/** @todo this select missing to implement */
+
+//$user_list=get_course_users();
+echo "<select name=\"select\" onchange=\"MM_jumpMenu('parent',this,0)\">";
+echo "<option value=\"agenda.php?user=none\">show all users</option>";
 /*foreach($user_list as $this_user)
 	{
 	// echo "<option value=\"agenda.php?isStudentView=true&amp;user=".$this_user['uid']."\">".$this_user['lastName']." ".$this_user['firstName']."</option>";
@@ -1187,12 +1182,13 @@ echo "</select>";
 
 function show_user_group_filter_form()
 {
+	/** @todo this select missing to implement */
 	echo "\n<select name=\"select\" onchange=\"MM_jumpMenu('parent',this,0)\">";
 	echo "\n\t<option value=\"agenda.php?user=none\">".get_lang("ShowAll")."</option>";
 
 	// Groups
 	echo "\n\t<optgroup label=\"".get_lang("Groups")."\">";
-	$group_list=get_course_groups();
+	//$group_list=get_course_groups();
 /*	foreach($group_list as $this_group)
 	{
 		// echo "<option value=\"agenda.php?isStudentView=true&amp;group=".$this_group['id']."\">".$this_group['name']."</option>";
@@ -1204,7 +1200,7 @@ function show_user_group_filter_form()
 
 	// Users
 	echo "\n\t<optgroup label=\"".get_lang("Users")."\">";
-	$user_list=get_course_users();
+	//$user_list=get_course_users();
 /*	foreach($user_list as $this_user)
 		{
 		// echo "<option value=\"agenda.php?isStudentView=true&amp;user=".$this_user['uid']."\">".$this_user['lastName']." ".$this_user['firstName']."</option>";
@@ -1317,9 +1313,9 @@ function show_add_form($id = '')
 ?>
 
 <!-- START OF THE FORM  -->
-<form enctype="multipart/form-data"  action="<?php echo api_get_self().'?origin='.$_GET['origin'].'&amp;action='.$_GET['action']; ?>" method="post" name="new_calendar_item">
+<form enctype="multipart/form-data"  action="<?php echo api_get_self().'?origin='.Security::remove_XSS($_GET['origin']).'&amp;action='.Security::remove_XSS($_GET['action']); ?>" method="post" name="new_calendar_item">
 <input type="hidden" name="id" value="<?php if (isset($id)) echo $id; ?>" />
-<input type="hidden" name="action" value="<?php if (isset($_GET['action'])) echo $_GET['action']; ?>" />
+<input type="hidden" name="action" value="<?php if (isset($_GET['action'])) echo Security::remove_XSS($_GET['action']); ?>" />
 <input type="hidden" name="sort" value="asc" />
 <input type="hidden" name="submit_event" value="ok" />
 <?php
@@ -1617,7 +1613,7 @@ function get_agendaitems($month, $year)
 	$items = array ();
 
 	//databases of the courses
-	$TABLEAGENDA = Database :: get_course_table(TABLE_MAIN_SYSTEM_CALENDAR);
+	$TABLEAGENDA = Database :: get_main_table(TABLE_MAIN_SYSTEM_CALENDAR);
 	//$TABLE_ITEMPROPERTY = Database :: get_course_table(TABLE_ITEM_PROPERTY);
 
 	//$group_memberships = GroupManager :: get_group_ids(Database::get_current_course_database(), $_user['user_id']);
@@ -1625,7 +1621,7 @@ function get_agendaitems($month, $year)
 	//if (api_is_allowed_to_edit())
 	//{
 		//echo "course admin";
-		$sqlquery = "SELECT
+	$sqlquery = "SELECT
 						DISTINCT *
 						FROM ".$TABLEAGENDA."
 						WHERE
@@ -1670,11 +1666,12 @@ function get_agendaitems($month, $year)
 		}
 	}
 
-    $result = Database::query($sqlquery, __FILE__, __LINE__);
+    $result = Database::query($sqlquery);
 	while ($item = Database::fetch_array($result))
 	{
-		$agendaday = date('j',strtotime($item['start_date']));
-		$time= date('H:i',strtotime($item['start_date']));
+		$agendaday_string = api_convert_and_format_date($item['start_date'], "%d", date_default_timezone_get());
+		$agendaday = intval($agendaday_string);
+		$time = api_convert_and_format_date($item['start_date'], TIME_NO_SEC_FORMAT, date_default_timezone_get());
 		$URL = $portal_url.'main/admin/agenda.php?day='.$agendaday."&amp;month=".$month."&amp;year=".$year; // RH  //Patrick Cool: to highlight the relevant agenda item
 		$items[$agendaday][$item['start_time']] .= '<i>'.$time.'</i> <a href="'.$URL.'" title="'.$item['title'].'<br />';
 	}
@@ -1714,7 +1711,7 @@ function display_upcoming_events()
 						ORDER BY start_date ";
 	//}
 	// if the user is not an administrator of that course
-	$result = Database::query($sqlquery, __FILE__, __LINE__);
+	$result = Database::query($sqlquery);
 	$counter = 0;
 	while ($item = Database::fetch_array($result,'ASSOC'))
 	{
@@ -1980,7 +1977,7 @@ function get_day_agendaitems($courses_dbs, $month, $year, $day)
 		//$sqlquery = "SELECT * FROM $agendadb WHERE DAYOFMONTH(day)='$day' AND month(day)='$month' AND year(day)='$year'";
 		//echo "abc";
 		//echo $sqlquery;
-		$result = Database::query($sqlquery, __FILE__, __LINE__);
+		$result = Database::query($sqlquery);
 		$portal_url = $_configuration['root_web'];
 		if ($_configuration['multiple_access_urls']==true) {
 			$access_url_id = api_get_current_access_url_id();
@@ -1995,6 +1992,7 @@ function get_day_agendaitems($courses_dbs, $month, $year, $day)
 		{
 			// in the display_daycalendar function we use $i (ranging from 0 to 47) for each halfhour
 			// we want to know for each agenda item for this day to wich halfhour it must be assigned
+			$item['start_date'] = api_get_local_time($item['start_date'], null, date_default_timezone_get());
 			list ($datepart, $timepart) = split(" ", $item['start_date']);
 			list ($year, $month, $day) = explode("-", $datepart);
 			list ($hours, $minutes, $seconds) = explode(":", $timepart);
@@ -2091,7 +2089,7 @@ function get_week_agendaitems($courses_dbs, $month, $year, $week = '')
 		// $sqlquery = "SELECT * FROM $agendadb WHERE (DAYOFMONTH(day)>='$start_day' AND DAYOFMONTH(day)<='$end_day')
 		//				AND (MONTH(day)>='$start_month' AND MONTH(day)<='$end_month')
 		//				AND (YEAR(day)>='$start_year' AND YEAR(day)<='$end_year')";
-		$result = Database::query($sqlquery, __FILE__, __LINE__);
+		$result = Database::query($sqlquery);
 
 		$portal_url = $_configuration['root_web'];
 		if ($_configuration['multiple_access_urls']==true) {
@@ -2104,8 +2102,9 @@ function get_week_agendaitems($courses_dbs, $month, $year, $week = '')
 
 		while ($item = Database::fetch_array($result))
 		{
-			$agendaday = date("j",strtotime($item['start_date']));
-			$time= date("H:i",strtotime($item['start_date']));
+			$agendaday_string = api_convert_and_format_date($item['start_date'], "%d", date_default_timezone_get());
+			$agendaday = intval($agendaday_string);
+			$time = api_convert_and_format_date($item['start_date'], TIME_NO_SEC_FORMAT, date_default_timezone_get());
 
 			if ($setting_agenda_link == 'coursecode')
 			{
@@ -2170,7 +2169,7 @@ function get_repeated_events_day_view($course_info,$start=0,$end=0,$params)
 	//$db_end = date('Y-m-d H:i:s',$end);
 
 	$t_cal = Database::get_main_table(TABLE_MAIN_SYSTEM_CALENDAR,$course_info['dbName']);
-	//$t_cal_repeat = Database::get_course_table(TABLE_AGENDA_REPEAT,$course_info['dbName']);
+	$t_cal_repeat = Database::get_course_table(TABLE_AGENDA_REPEAT,$course_info['dbName']);
     $t_ip = Database::get_course_table(TABLE_ITEM_PROPERTY,$course_info['dbName']);
 	$sql = "SELECT c.id, c.title, c.content, " .
 			" UNIX_TIMESTAMP(c.start_date) as orig_start, UNIX_TIMESTAMP(c.end_date) as orig_end, " .
@@ -2184,13 +2183,13 @@ function get_repeated_events_day_view($course_info,$start=0,$end=0,$params)
             .(!empty($params['conditions'])?$params['conditions']:'')
             .(!empty($params['groupby'])?' GROUP BY '.$params['groupby']:'')
             .(!empty($params['orderby'])?' ORDER BY '.$params['orderby']:'');
-	$res = Database::query($sql,__FILE__,__LINE__);
+	$res = Database::query($sql);
 	if(Database::num_rows($res)>0)
 	{
 		while($row = Database::fetch_array($res))
 		{
 			$orig_start = $row['orig_start'];
-			$orig_end = $row['orig_end'];
+			$orig_end = $row['orig_start'];
 			$repeat_type = $row['cal_type'];
 			switch($repeat_type)
 			{
@@ -2298,14 +2297,14 @@ function get_repeated_events_week_view($course_info,$start=0,$end=0,$params)
 	$t_cal = Database::get_main_table(TABLE_MAIN_SYSTEM_CALENDAR);
 	//$t_cal_repeat = Database::get_course_table(TABLE_AGENDA_REPEAT,$course_info['dbName']);
     //$t_ip = Database::get_course_table(TABLE_ITEM_PROPERTY,$course_info['dbName']);
-    $sql = "SELECT c.id, c.title, c.content " .
-            " UNIX_TIMESTAMP(c.start_date) as orig_start, UNIX_TIMESTAMP(c.end_date) as orig_end, " .
-            " FROM". $t_cal ."
-             WHERE c.start_date <= '$db_start' "
+    $sql = "SELECT c.id, c.title, c.content, " .
+            " UNIX_TIMESTAMP(c.start_date) as orig_start, UNIX_TIMESTAMP(c.end_date) as orig_end " .
+            " FROM ". $t_cal ."
+             AS c WHERE c.start_date <= '$db_start' "
             .(!empty($params['conditions'])?$params['conditions']:'')
             .(!empty($params['groupby'])?' GROUP BY '.$params['groupby']:'')
             .(!empty($params['orderby'])?' ORDER BY '.$params['orderby']:'');
-	$res = Database::query($sql,__FILE__,__LINE__);
+	$res = Database::query($sql);
 	if(Database::num_rows($res)>0)
 	{
 		while($row = Database::fetch_array($res))
@@ -2422,8 +2421,8 @@ function get_repeated_events_month_view($course_info,$start=0,$end=0,$params)
 	//$db_end = date('Y-m-d H:i:s',$end);
 
 	$t_cal = Database::get_main_table(TABLE_MAIN_SYSTEM_CALENDAR);
-	//$t_cal_repeat = Database::get_course_table(TABLE_AGENDA_REPEAT,$course_info['dbName']);
-    //$t_ip = Database::get_course_table(TABLE_ITEM_PROPERTY,$course_info['dbName']);
+	$t_cal_repeat = Database::get_course_table(TABLE_AGENDA_REPEAT,$course_info['dbName']);
+    $t_ip = Database::get_course_table(TABLE_ITEM_PROPERTY,$course_info['dbName']);
     $sql = "SELECT c.id, c.title, c.content, " .
             " UNIX_TIMESTAMP(c.start_date) as orig_start, UNIX_TIMESTAMP(c.end_date) as orig_end, " .
             " cr.cal_type, cr.cal_end " .
@@ -2436,7 +2435,7 @@ function get_repeated_events_month_view($course_info,$start=0,$end=0,$params)
             .(!empty($params['conditions'])?$params['conditions']:'')
             .(!empty($params['groupby'])?' GROUP BY '.$params['groupby']:'')
             .(!empty($params['orderby'])?' ORDER BY '.$params['orderby']:'');
-	$res = Database::query($sql,__FILE__,__LINE__);
+	$res = Database::query($sql);
 	if(Database::num_rows($res)>0)
 	{
 		while($row = Database::fetch_array($res))
@@ -2593,8 +2592,8 @@ function get_repeated_events_list_view($course_info,$start=0,$end=0,$params)
     //$db_end = date('Y-m-d H:i:s',$end);
 
     $t_cal = Database::get_main_table(TABLE_MAIN_SYSTEM_CALENDAR,$course_info['dbName']);
-    //$t_cal_repeat = Database::get_course_table(TABLE_AGENDA_REPEAT,$course_info['dbName']);
-    //$t_ip = Database::get_course_table(TABLE_ITEM_PROPERTY,$course_info['dbName']);
+    $t_cal_repeat = Database::get_course_table(TABLE_AGENDA_REPEAT,$course_info['dbName']);
+    $t_ip = Database::get_course_table(TABLE_ITEM_PROPERTY,$course_info['dbName']);
     $sql = "SELECT c.id, c.title, c.content, " .
             " UNIX_TIMESTAMP(c.start_date) as orig_start, UNIX_TIMESTAMP(c.end_date) as orig_end, " .
             " cr.cal_type, cr.cal_end " .
@@ -2607,7 +2606,7 @@ function get_repeated_events_list_view($course_info,$start=0,$end=0,$params)
             .(!empty($params['conditions'])?$params['conditions']:'')
             .(!empty($params['groupby'])?' GROUP BY '.$params['groupby']:'')
             .(!empty($params['orderby'])?' ORDER BY '.$params['orderby']:'');
-    $res = Database::query($sql,__FILE__,__LINE__);
+    $res = Database::query($sql);
     if(Database::num_rows($res)>0)
     {
         while($row = Database::fetch_array($res))
@@ -2786,7 +2785,7 @@ function is_repeated_event($id,$course=null)
     $id = (int) $id;
 	//$t_agenda_repeat = Database::get_course_table(TABLE_AGENDA_REPEAT,$course);
     $sql = "SELECT * FROM $t_agenda_repeat WHERE cal_id = $id";
-    $res = Database::query($sql,__FILE__,__LINE__);
+    $res = Database::query($sql);
     if(Database::num_rows($res)>0)
     {
     	return true;
@@ -2863,7 +2862,7 @@ function agenda_add_item($course_info, $title, $content, $db_start_date, $db_end
     // check if exists in calendar_event table
     $sql = "SELECT * FROM $t_agenda WHERE title='$title' AND content = '$content' AND start_date = '$start_date'
     		AND end_date = '$end_date' ".(!empty($parent_id)? "AND parent_event_id = '$parent_id'":"");
-    $result = Database::query($sql,__FILE__,__LINE__);
+    $result = Database::query($sql);
     $count = Database::num_rows($result);
     if ($count > 0) {
     	return false;
@@ -2874,7 +2873,7 @@ function agenda_add_item($course_info, $title, $content, $db_start_date, $db_end
                             VALUES
                             ('".$title."','".$content."', '".$start_date."','".$end_date."')";
 
-    $result = Database::query($sql,__FILE__,__LINE__) or die (Database::error());
+    $result = Database::query($sql) or die (Database::error());
     $last_id=Database::insert_id();
 
     // add a attachment file in agenda
@@ -2883,7 +2882,9 @@ function agenda_add_item($course_info, $title, $content, $db_start_date, $db_end
 
     // store in last_tooledit (first the groups, then the users
     $done = false;
-    if ((!is_null($to))or (!empty($_SESSION['toolgroup']))) // !is_null($to): when no user is selected we send it to everyone
+
+   //(This part of this code is not been used)
+   /* if ((!is_null($to))or (!empty($_SESSION['toolgroup']))) // !is_null($to): when no user is selected we send it to everyone
     {
         $send_to=separate_users_groups($to);
         // storing the selected groups
@@ -2913,7 +2914,7 @@ function agenda_add_item($course_info, $title, $content, $db_start_date, $db_end
     // storing the resources
     if (!empty($_SESSION['source_type']) && !empty($last_id)) {
     //store_resources($_SESSION['source_type'],$last_id);
-    }
+    }*/
     return $last_id;
 }
 /**
@@ -2945,13 +2946,13 @@ function agenda_add_item($course_info, $title, $content, $db_start_date, $db_end
     $repeats = array();
     $data=array();
 	if (is_allowed_to_edit()) {
-		$sql="SELECT
+	$sql="SELECT
 			DISTINCT *
 			FROM ".$TABLEAGENDA." agenda
 			WHERE MONTH(start_date)='".$month."' AND YEAR(start_date)='".$year."'
 			GROUP BY id ".
 			"ORDER BY  start_date ";
-		$result=Database::query($sql,__FILE__,__LINE__);
+		$result=Database::query($sql);
 
 		while ($row=Database::fetch_array($result)) {
 			$datum_item=(int)substr($row["start_date"],8,2);
@@ -2960,14 +2961,16 @@ function agenda_add_item($course_info, $title, $content, $db_start_date, $db_end
 	}
 	return $data;
 }
-
+/**
+ * This function is not been used or deprecated
+ */
 function agenda_add_repeat_item($course_info,$orig_id,$type,$end,$orig_dest)
 {/*
 	$t_agenda   = Database::get_main_table(TABLE_MAIN_SYSTEM_CALENDAR,$course_info['dbName']);
    // $t_agenda_r = Database::get_course_table(TABLE_AGENDA_REPEAT,$course_info['dbName']);
     //$sql = "SELECT title, content, UNIX_TIMESTAMP(start_date) as sd, UNIX_TIMESTAMP(end_date) as ed FROM $t_agenda WHERE id = $orig_id";
     $sql = "SELECT title, content, start_date as sd, end_date as ed FROM $t_agenda WHERE id = $orig_id";
-    $res = Database::query($sql,__FILE__,__LINE__);
+    $res = Database::query($sql);
     if(Database::num_rows($res)!==1){return false;}
     $row = Database::fetch_array($res);
     //$orig_start = $row['sd'];
@@ -3011,7 +3014,7 @@ function agenda_add_repeat_item($course_info,$orig_id,$type,$end,$orig_dest)
     {
        $sql = "INSERT INTO $t_agenda_r (cal_id, cal_type, cal_end)" .
             " VALUES ($orig_id,'$type',$end)";
-       $res = Database::query($sql,__FILE__,__LINE__);
+       $res = Database::query($sql);
         switch($type)
         {
             case 'daily':

+ 11 - 23
main/admin/calendar.php

@@ -1,23 +1,5 @@
 <?php // $id: $
-/*
-==============================================================================
-	Dokeos - elearning and course management software
-
-	Copyright (c) 2008 Dokeos S.A.
-
-	For a full list of contributors, see "credits.txt".
-	The full license can be read in "license.txt".
-
-	This program is free software; you can redistribute it and/or
-	modify it under the terms of the GNU General Public License
-	as published by the Free Software Foundation; either version 2
-	of the License, or (at your option) any later version.
-
-	See the GNU General Public License for more details.
-
-	Contact: Dokeos, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com
-==============================================================================
-*/
+/* For licensing terms, see /license.txt */
 /**
 ==============================================================================
 *	@package dokeos.admin
@@ -60,7 +42,7 @@ $id_session=intval($_GET['id_session']);
 if(!api_is_platform_admin())
 {
 	$sql = 'SELECT session_admin_id FROM '.Database :: get_main_table(TABLE_MAIN_SESSION).' WHERE id='.$id_session;
-	$rs = Database::query($sql,__FILE__,__LINE__);
+	$rs = Database::query($sql);
 	if(Database::result($rs,0,0)!=$_user['user_id'])
 	{
 		api_not_allowed(true);
@@ -157,7 +139,6 @@ else
   			SETTING SOME VARIABLES
 ============================================================================== */
 // Variable definitions
-$dateNow 			= format_locale_date($dateTimeFormatLong);
 // Defining the shorts for the days. We use camelcase because these are arrays of language variables
 $DaysShort = api_get_week_days_short();
 // Defining the days of the week to allow translation of the days. We use camelcase because these are arrays of language variables
@@ -320,7 +301,14 @@ if (api_is_allowed_to_edit(false,true))
 			$id=(int)$_GET['id'];
 			if( ! (api_is_course_coach() && !api_is_element_in_the_session(TOOL_AGENDA, $id ) ) )
 			{ // a coach can only delete an element belonging to his session
-				delete_agenda_item($id);
+				if (is_allowed_to_edit()  && !api_is_anonymous()) {
+					if (!empty($id)) {
+						$res_del = delete_agenda_item($id);
+						if ($res_del) {
+							Display::display_normal_message(get_lang("AgendaDeleteSuccess"));
+						}
+					}
+				}
 			}
 				if (api_get_setting('display_upcoming_events') == 'true') {
 					display_upcoming_events();
@@ -407,4 +395,4 @@ if ($_GET['origin'] != 'learnpath')
 	Display::display_footer();
 
 }
-?>
+?>

+ 5 - 22
main/admin/calendar_view.php

@@ -1,23 +1,5 @@
 <?php // $id: $
-/*
-==============================================================================
-	Dokeos - elearning and course management software
-
-	Copyright (c) 2008 Dokeos S.A.
-
-	For a full list of contributors, see "credits.txt".
-	The full license can be read in "license.txt".
-
-	This program is free software; you can redistribute it and/or
-	modify it under the terms of the GNU General Public License
-	as published by the Free Software Foundation; either version 2
-	of the License, or (at your option) any later version.
-
-	See the GNU General Public License for more details.
-
-	Contact: Dokeos, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com
-==============================================================================
-*/
+/* For licensing terms, see /license.txt */
 /**
 ==============================================================================
 *	@package dokeos.admin
@@ -28,11 +10,12 @@
 // name of the language file that needs to be included
 $language_file = 'agenda';
 // including the claroline global
-include('../inc/global.inc.php');
+require_once '../inc/global.inc.php';
 
 //session
-if(isset($_GET['id_session']))
-	$_SESSION['id_session'] = $_GET['id_session'];
+if(isset($_GET['id_session'])) {
+	$_SESSION['id_session'] = intval($_GET['id_session']);
+}
 
 // the variables for the days and the months
 // Defining the shorts for the days

+ 3 - 5
main/admin/calendar_view_print.php

@@ -48,7 +48,7 @@ require('../inc/global.inc.php');
 $TABLEAGENDA 		= Database::get_main_table(TABLE_MAIN_SYSTEM_CALENDAR);
 
 $sql 			= "SELECT * FROM $TABLEAGENDA WHERE id IN($id) ORDER BY start_date DESC";
-$result			= Database::query($sql,__FILE__,__LINE__);
+$result			= Database::query($sql);
 ?>
 
 <html>
@@ -82,15 +82,13 @@ while($row=Database::fetch_array($result))
 
 	echo get_lang('StartTime').' : ';
 
-	echo api_ucfirst(format_locale_date($dateFormatLong,strtotime($row["start_date"])))."&nbsp;&nbsp;&nbsp;";
-	echo ucfirst(strftime($timeNoSecFormat,strtotime($row["start_date"])))."";
+	echo api_convert_and_format_date($row["start_date"], null, date_default_timezone_get());
 
 	echo '<br />';
 
 	echo get_lang('EndTime').' : ';
 
-	echo api_ucfirst(format_locale_date($dateFormatLong,strtotime($row["end_date"])))."&nbsp;&nbsp;&nbsp;";
-	echo ucfirst(strftime($timeNoSecFormat,strtotime($row["end_date"])))."";
+	echo api_convert_and_format_date($row["end_date"], null, date_default_timezone_get());
 
 	echo '<br /><br />';
 

+ 3 - 2
main/admin/class_list.php

@@ -32,6 +32,7 @@ $language_file = 'admin';
 
 $cidReset = true;
 require '../inc/global.inc.php';
+require_once api_get_path(LIBRARY_PATH).'sortabletable.class.php';
 
 $this_section = SECTION_PLATFORM_ADMIN;
 api_protect_admin_script();
@@ -45,7 +46,7 @@ function get_number_of_classes() {
 	if (isset ($_GET['keyword'])) {
 		$sql .= " WHERE (name LIKE '%".Database::escape_string(trim($_GET['keyword']))."%')";
 	}
-	$res = Database::query($sql, __FILE__, __LINE__);
+	$res = Database::query($sql);
 	$obj = Database::fetch_object($res);
 	return $obj->number_of_classes;
 }
@@ -71,7 +72,7 @@ function get_class_data($from, $number_of_items, $column, $direction) {
 		$sql .= " WHERE (name LIKE '%".Database::escape_string(trim($_GET['keyword']))."%')";
 	}
 	$sql .= " GROUP BY id,name ORDER BY col$column $direction LIMIT $from,$number_of_items";
-	$res = Database::query($sql, __FILE__, __LINE__);
+	$res = Database::query($sql);
 	$classes = array ();
 	while ($class = Database::fetch_row($res)) {
 		$classes[] = $class;

+ 4 - 4
main/admin/class_user_import.php

@@ -52,7 +52,7 @@ function validate_data($user_classes) {
 				// 2.1.1 Check whether code exists in DB.
 				$class_table = Database :: get_main_table(TABLE_MAIN_CLASS);
 				$sql = "SELECT * FROM $class_table WHERE name = '".Database::escape_string($user_class['ClassName'])."'";
-				$res = Database::query($sql, __FILE__, __LINE__);
+				$res = Database::query($sql);
 				if (Database::num_rows($res) == 0) {
 					$user_class['error'] = get_lang('CodeDoesNotExists');
 					$errors[] = $user_class;
@@ -95,10 +95,10 @@ function save_data($users_classes) {
 	$csv_data = array ();
 	foreach ($users_classes as $index => $user_class) {
 		$sql1 = "SELECT user_id FROM $user_table WHERE username = '".Database::escape_string(UserManager::purify_username($user_class['UserName'], $purification_option_for_usernames))."'";
-		$res1 = Database::query($sql1, __FILE__, __LINE__);
+		$res1 = Database::query($sql1);
 		$obj1 = Database::fetch_object($res1);
 		$sql2 = "SELECT id FROM $class_table WHERE name = '".Database::escape_string(trim($user_class['ClassName']))."'";
-		$res2 = Database::query($sql2, __FILE__, __LINE__);
+		$res2 = Database::query($sql2);
 		$obj2 = Database::fetch_object($res2);
 		if ($obj1 && $obj2) {
 			$csv_data[$obj1->user_id][$obj2->id] = 1;
@@ -109,7 +109,7 @@ function save_data($users_classes) {
 	$db_subscriptions = array();
 	foreach ($csv_data as $user_id => $csv_subscriptions) {
 		$sql = "SELECT class_id FROM $class_user_table cu WHERE cu.user_id = $user_id";
-		$res = Database::query($sql, __FILE__, __LINE__);
+		$res = Database::query($sql);
 		while ($obj = Database::fetch_object($res)) {
 			$db_subscriptions[$obj->class_id] = 1;
 		}

+ 25 - 54
main/admin/configure_extensions.php

@@ -1,47 +1,18 @@
 <?php // $Id: configure_homepage.php 9246 2006-09-25 13:24:53 +0000 (lun., 25 sept. 2006) bmol $
-/*
-==============================================================================
-	Dokeos - elearning and course management software
-
-	Copyright (c) 2008 Dokeos SPRL
-
-	For a full list of contributors, see "credits.txt".
-	The full license can be read in "license.txt".
-
-	This program is free software; you can redistribute it and/or
-	modify it under the terms of the GNU General Public License
-	as published by the Free Software Foundation; either version 2
-	of the License, or (at your option) any later version.
-
-	See the GNU General Public License for more details.
-
-	Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
-	Mail: info@dokeos.com
-==============================================================================
-*/
+/* For licensing terms, see /chamilo_license.txt */
 
 // name of the language file that needs to be included
 $language_file='admin';
-
 $cidReset=true;
-
-include('../inc/global.inc.php');
-
-
+require_once '../inc/global.inc.php';
 $this_section=SECTION_PLATFORM_ADMIN;
-
 api_protect_admin_script();
-
 $interbreadcrumb[] = array ('url' => 'index.php', 'name' => get_lang('PlatformAdmin'));
-
 // Database Table Definitions
 $tbl_settings_current = Database::get_main_table(TABLE_MAIN_SETTINGS_CURRENT);
-
 $message = '';
 
-require api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php';
-
-
+require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php';
 
 if(isset($_POST['activeExtension'])){
 
@@ -52,19 +23,19 @@ if(isset($_POST['activeExtension'])){
 					selected_value="true"
 					WHERE variable="service_visio"
 					AND subkey="active"';
-			$rs = Database::query($sql, __FILE__, __LINE__);
+			$rs = Database::query($sql);
 			if(Database::affected_rows()>0)
 			{
 
 				// select all the courses and insert the tool inside
 				$sql = 'SELECT db_name FROM '.Database::get_main_table(TABLE_MAIN_COURSE);
-				$rs = Database::query($sql, __FILE__, __LINE__);
+				$rs = Database::query($sql);
 				while($row = Database::fetch_array($rs)){
 					if(!empty($_POST['visio_host']))
 					{
 						$tool_table = Database::get_course_table(TABLE_TOOL_LIST,$row['db_name']);
 						$select = "SELECT id FROM $tool_table WHERE name='".TOOL_VISIO_CONFERENCE."'";
-						$selectres = Database::query($select,__FILE__, __LINE__);
+						$selectres = Database::query($select);
 						if(Database::num_rows($selectres)<1)
 						{
 							$sql = 'INSERT INTO '.$tool_table.' SET
@@ -76,10 +47,10 @@ if(isset($_POST['activeExtension'])){
 									address="squaregrey.gif",
 									target="_self",
 									category="interaction"';
-							Database::query($sql, __FILE__, __LINE__);
+							Database::query($sql);
 						}
 						$select = "SELECT id FROM $tool_table WHERE name='".TOOL_VISIO_CLASSROOM."'";
-						$selectres = Database::query($select,__FILE__, __LINE__);
+						$selectres = Database::query($select);
 						if(Database::num_rows($selectres)<1)
 						{
 							$sql = 'INSERT INTO '.$tool_table.' SET
@@ -91,7 +62,7 @@ if(isset($_POST['activeExtension'])){
 									address="squaregrey.gif",
 									target="_self",
 									category="authoring"';
-							Database::query($sql, __FILE__, __LINE__);
+							Database::query($sql);
 						}
 					}
 				}
@@ -102,25 +73,25 @@ if(isset($_POST['activeExtension'])){
 					selected_value="'.Database::escape_string($_POST['visio_host']).'"
 					WHERE variable="service_visio"
 					AND subkey="visio_host"';
-			$rs = Database::query($sql, __FILE__, __LINE__);
+			$rs = Database::query($sql);
 
 			$sql = 'UPDATE '.$tbl_settings_current.' SET
 					selected_value="'.Database::escape_string($_POST['visio_port']).'"
 					WHERE variable="service_visio"
 					AND subkey="visio_port"';
-			$rs = Database::query($sql, __FILE__, __LINE__);
+			$rs = Database::query($sql);
 
 			$sql = 'UPDATE '.$tbl_settings_current.' SET
 					selected_value="'.Database::escape_string($_POST['visio_pass']).'"
 					WHERE variable="service_visio"
 					AND subkey="visio_pass"';
-			$rs = Database::query($sql, __FILE__, __LINE__);
+			$rs = Database::query($sql);
 
 			$sql = 'UPDATE '.$tbl_settings_current.' SET
 					selected_value="'.($_POST['visio_use_rtmpt']=='true'?'true':'false').'"
 					WHERE variable="service_visio"
 					AND subkey="visio_use_rtmpt"';
-			$rs = Database::query($sql, __FILE__, __LINE__);
+			$rs = Database::query($sql);
 
 			if(empty($message))
 			{
@@ -138,7 +109,7 @@ if(isset($_POST['activeExtension'])){
 					WHERE variable="service_ppt2lp"
 					AND subkey="active"';
 
-			$rs = Database::query($sql, __FILE__, __LINE__);
+			$rs = Database::query($sql);
 
 			if(Database::affected_rows()>0){
 				$message = get_lang('ServiceActivated');
@@ -148,37 +119,37 @@ if(isset($_POST['activeExtension'])){
 					selected_value="'.addslashes($_POST['host']).'"
 					WHERE variable="service_ppt2lp"
 					AND subkey="host"';
-			Database::query($sql, __FILE__, __LINE__);
+			Database::query($sql);
 
 			$sql = 'UPDATE '.$tbl_settings_current.' SET
 					selected_value="'.addslashes($_POST['port']).'"
 					WHERE variable="service_ppt2lp"
 					AND subkey="port"';
-			Database::query($sql, __FILE__, __LINE__);
+			Database::query($sql);
 
 			$sql = 'UPDATE '.$tbl_settings_current.' SET
 					selected_value="'.addslashes($_POST['ftp_password']).'"
 					WHERE variable="service_ppt2lp"
 					AND subkey="ftp_password"';
-			Database::query($sql, __FILE__, __LINE__);
+			Database::query($sql);
 
 			$sql = 'UPDATE '.$tbl_settings_current.' SET
 					selected_value="'.addslashes($_POST['user']).'"
 					WHERE variable="service_ppt2lp"
 					AND subkey="user"';
-			Database::query($sql, __FILE__, __LINE__);
+			Database::query($sql);
 
 			$sql = 'UPDATE '.$tbl_settings_current.' SET
 					selected_value="'.addslashes($_POST['path_to_lzx']).'"
 					WHERE variable="service_ppt2lp"
 					AND subkey="path_to_lzx"';
-			Database::query($sql, __FILE__, __LINE__);
+			Database::query($sql);
 
 			$sql = 'UPDATE '.$tbl_settings_current.' SET
 					selected_value="'.addslashes($_POST['size']).'"
 					WHERE variable="service_ppt2lp"
 					AND subkey="size"';
-			Database::query($sql, __FILE__, __LINE__);
+			Database::query($sql);
 
 			break;
 	}
@@ -191,7 +162,7 @@ $listActiveServices = array();
 // get the list of active services
 $sql = 'SELECT variable FROM '.$tbl_settings_current.' WHERE variable LIKE "service_%" AND subkey="active" and selected_value="true"';
 
-$rs = Database::query($sql, __FILE__, __LINE__);
+$rs = Database::query($sql);
 while($row = Database::fetch_array($rs)){
 	$listActiveServices[] = $row['variable'];
 }
@@ -291,7 +262,7 @@ Display::display_header($nameTool);
 					<td align="center">
 						<?php Display::display_icon('screenshot_conf.jpg', get_lang('Visioconf')); ?>
 					</td>
-					<!--td align="center" width="50%">
+					<td align="center" width="50%">
 						<?php
 						$form = new FormValidator('visio');
 						$form -> addElement('text', 'visio_host', get_lang('VisioHost'));
@@ -315,7 +286,7 @@ Display::display_header($nameTool);
 						{
 							$sql = 'SELECT subkey, selected_value FROM '.$tbl_settings_current.'
 									WHERE variable = "service_visio"';
-							$rs = Database::query($sql, __FILE__, __LINE__);
+							$rs = Database::query($sql);
 							while($row = Database::fetch_array($rs,'ASSOC'))
 							{
 								$defaults[$row['subkey']] = $row['selected_value'];
@@ -328,7 +299,7 @@ Display::display_header($nameTool);
 						$form -> setDefaults($defaults);
 						$form -> display();
 						?>
-					</td-->
+					</td>
 				</tr>
 			</table>
 		</div>
@@ -382,7 +353,7 @@ Display::display_header($nameTool);
 							$sql = 'SELECT subkey, selected_value FROM '.$tbl_settings_current.'
 									WHERE variable = "service_ppt2lp"
 									AND subkey <> "active"';
-							$rs = Database::query($sql, __FILE__, __LINE__);
+							$rs = Database::query($sql);
 							while($row = Database::fetch_array($rs,'ASSOC'))
 							{
 								$defaults[$row['subkey']] = $row['selected_value'];

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 310 - 373
main/admin/configure_homepage.php


+ 313 - 330
main/admin/configure_inscription.php

@@ -1,167 +1,157 @@
 <?php
-/* For licensing terms, see /dokeos_license.txt */
+/* For licensing terms, see /license.txt */
+
 /**
-==============================================================================
-*	This script displays a form for registering new users.
-*	@package	 dokeos.auth
-==============================================================================
-*/
-// name of the language file that needs to be included
-$language_file = array('registration','admin');
-$cidReset = true;
-include ("../inc/global.inc.php");
+ *	This script displays a form for registering new users.
+ *	@package	 chamilo.admin
+ */
 
-require_once (api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php');
-require_once (api_get_path(LIBRARY_PATH).'usermanager.lib.php');
-require_once (api_get_path(CONFIGURATION_PATH).'profile.conf.php');
-require_once(api_get_path(INCLUDE_PATH).'lib/mail.lib.inc.php');
-require_once(api_get_path(INCLUDE_PATH).'lib/legal.lib.php');
+$language_file = array('registration', 'admin');
+$cidReset = true;
+include '../inc/global.inc.php';
 
-//require_once(api_get_path(LIBRARY_PATH).'fileManage.lib.php');
-//require_once(api_get_path(LIBRARY_PATH).'fileUpload.lib.php');
-//require_once (api_get_path(LIBRARY_PATH).'image.lib.php');
+require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php';
+require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
+require_once api_get_path(CONFIGURATION_PATH).'profile.conf.php';
+require_once api_get_path(INCLUDE_PATH).'lib/mail.lib.inc.php';
+require_once api_get_path(INCLUDE_PATH).'lib/legal.lib.php';
 
 // Load terms & conditions from the current lang
-if (get_setting('allow_terms_conditions')=='true') {	
+if (get_setting('allow_terms_conditions') == 'true') {
 	$get = array_keys($_GET);
 	if (isset($get)) {
-		if ($get[0]=='legal'){				
-			//$language = api_get_setting('platformLanguage');
+		if ($get[0] == 'legal') {
 			$language = api_get_interface_language();
 			$language = api_get_language_id($language);
-			$term_preview= LegalManager::get_last_condition($language);
-			if ($term_preview==false) {
+			$term_preview = LegalManager::get_last_condition($language);
+			if ($term_preview == false) {
 				//look for the default language
-				$language = api_get_setting('platformLanguage');				
+				$language = api_get_setting('platformLanguage');
 				$language = api_get_language_id($language);
 				$term_preview= LegalManager::get_last_condition($language);
-			}					
+			}
 			$tool_name = get_lang('TermsAndConditions');
 			Display :: display_header('');
 			echo '<div class="actions-title">';
 			echo $tool_name;
 			echo '</div>';
-			if (!empty($term_preview['content']))
+			if (!empty($term_preview['content'])) {
 				echo $term_preview['content'];
-			else 
+			} else {
 				echo get_lang('ComingSoon');
+			}
 			Display :: display_footer();
 			exit;
 		}
 	}
 }
 
-$action=Security::remove_XSS($_GET['action']);
-$interbreadcrumb[]=array('url' => 'index.php',"name" => get_lang('PlatformAdmin'));
+$action = Security::remove_XSS($_GET['action']);
+$interbreadcrumb[] = array('url' => 'index.php', 'name' => get_lang('PlatformAdmin'));
 $tool_name = get_lang('ConfigureInscription');
-if(!empty($action)){
-	$interbreadcrumb[]=array('url' => 'configure_inscription.php',"name" => get_lang('ConfigureInscription'));
-	switch($action){
-		case "edit_top":
-			$tool_name=get_lang("EditTopRegister");
+if (!empty($action)) {
+	$interbreadcrumb[] = array('url' => 'configure_inscription.php', 'name' => get_lang('ConfigureInscription'));
+	switch($action) {
+		case 'edit_top':
+			$tool_name = get_lang('EditTopRegister');
 			break;
 	}
 }
 
 $lang = ''; //el for "Edit Language"
-if(!empty($_SESSION['user_language_choice'])) {
-	$lang=$_SESSION['user_language_choice'];
-} elseif(!empty($_SESSION['_user']['language'])) {
-	$lang=$_SESSION['_user']['language'];
+if (!empty($_SESSION['user_language_choice'])) {
+	$lang = $_SESSION['user_language_choice'];
+} elseif (!empty($_SESSION['_user']['language'])) {
+	$lang = $_SESSION['_user']['language'];
 } else {
-	$lang=get_setting('platformLanguage');
+	$lang = get_setting('platformLanguage');
 }
 
 // ----- Ensuring availability of main files in the corresponding language -----
-if ($_configuration['multiple_access_urls']==true) {
-	$access_url_id = api_get_current_access_url_id();										 
-	if ($access_url_id != -1){						
+if ($_configuration['multiple_access_urls']) {
+	$access_url_id = api_get_current_access_url_id();
+	if ($access_url_id != -1) {
 		$url_info = api_get_access_url($access_url_id);
-		// "http://" and the final "/" replaced						
-		$url = substr($url_info['url'],7,strlen($url_info['url'])-8);						
+		$url = api_remove_trailing_slash(preg_replace('/https?:\/\//i', '', $url_info['url']));
 		$clean_url = replace_dangerous_char($url);
-		$clean_url = str_replace('/','-',$clean_url);
-		$clean_url = $clean_url.'/';
-		
-		$homep = '../../home/'; //homep for Home Path			
-		$homep_new = '../../home/'.$clean_url; //homep for Home Path added the url				
+		$clean_url = str_replace('/', '-', $clean_url);
+		$clean_url .= '/';
+
+		$homep = api_get_path(SYS_PATH).'home/'; //homep for Home Path
+		$homep_new = api_get_path(SYS_PATH).'home/'.$clean_url; //homep for Home Path added the url
 		$new_url_dir = api_get_path(SYS_PATH).'home/'.$clean_url;
 		//we create the new dir for the new sites
-		if (!is_dir($new_url_dir)){		
-			umask(0);
-			$perm = api_get_setting('permissions_for_new_directories');
-			$perm = octdec(!empty($perm)?$perm:'0755');
-			mkdir($new_url_dir, $perm);
-		}							
+		if (!is_dir($new_url_dir)){
+			mkdir($new_url_dir, api_get_permissions_for_new_directories());
+		}
 	}
-} else {			
-	$homep_new ='';		
-	$homep = '../../home/'; //homep for Home Path
+} else {
+	$homep_new = '';
+	$homep = api_get_path(SYS_PATH).'home/'; //homep for Home Path
 }
 
-
-
 $topf 	 = 'register_top'; //topf for Top File
 $ext 	 = '.html'; //ext for HTML Extension - when used frequently, variables are
 $homef = array($topf);
 
 // If language-specific file does not exist, create it by copying default file
-foreach($homef as $my_file) {
-	if ($_configuration['multiple_access_urls']==true) {
+foreach ($homef as $my_file) {
+	if ($_configuration['multiple_access_urls']) {
 		if (!file_exists($homep_new.$my_file.'_'.$lang.$ext)) {
-			copy($homep.$my_file.$ext,$homep_new.$my_file.'_'.$lang.$ext);
-		}		
-	} else {	
+			copy($homep.$my_file.$ext, $homep_new.$my_file.'_'.$lang.$ext);
+		}
+	} else {
 		if (!file_exists($homep.$my_file.'_'.$lang.$ext)) {
-			copy($homep.$my_file.$ext,$homep.$my_file.'_'.$lang.$ext);
+			copy($homep.$my_file.$ext, $homep.$my_file.'_'.$lang.$ext);
 		}
 	}
 }
 
-if(!empty($action)) {
-	if($_POST['formSent']) {
-		switch($action) {
+if (!empty($action)) {
+	if ($_POST['formSent']) {
+		switch ($action) {
 			case 'edit_top':
 				// Filter
-				$home_top='';
-				if (api_get_setting('wcag_anysurfer_public_pages')=='true') {
-					$home_top=WCAG_Rendering::prepareXHTML();
+				$home_top = '';
+				if (api_get_setting('wcag_anysurfer_public_pages') == 'true') {
+					$home_top = WCAG_Rendering::prepareXHTML();
 				} else {
-					$home_top=trim(stripslashes($_POST['register_top']));
+					$home_top = trim(stripslashes($_POST['register_top']));
 				}
 				// Write
 				if (file_exists($homep.$topf.'_'.$lang.$ext)) {
-					if(is_writable($homep.$topf.'_'.$lang.$ext)) {						
-						$fp=fopen($homep.$topf.'_'.$lang.$ext,"w");
-						fputs($fp,$home_top);
+					if (is_writable($homep.$topf.'_'.$lang.$ext)) {
+						$fp = fopen($homep.$topf.'_'.$lang.$ext, 'w');
+						fputs($fp, $home_top);
 						fclose($fp);
 					} else {
-						$errorMsg=get_lang('HomePageFilesNotWritable');
+						$errorMsg = get_lang('HomePageFilesNotWritable');
 					}
 				} else {
-					//File does not exist					
-					$fp=fopen($homep.$topf.'_'.$lang.$ext,"w");
-					fputs($fp,$home_top);
+					//File does not exist
+					$fp = fopen($homep.$topf.'_'.$lang.$ext, 'w');
+					fputs($fp, $home_top);
 					fclose($fp);
 				}
 				break;
 		}
-		if(empty($errorMsg)) {
+		if (empty($errorMsg)) {
 			header('Location: '.api_get_self());
 			exit();
 		}
 	} else {
-		switch($action) {
+		switch ($action) {
 			case 'edit_top':
 				// This request is only the preparation for the update of the home_top
 				$home_top = '';
-				if(is_file($homep.$topf.'_'.$lang.$ext) && is_readable($homep.$topf.'_'.$lang.$ext)) {
-					$home_top=file_get_contents($homep.$topf.'_'.$lang.$ext);
-				} elseif(is_file($homep.$topf.$lang.$ext) && is_readable($homep.$topf.$lang.$ext)) {
-					$home_top=file_get_contents($homep.$topf.$lang.$ext);
+				if (is_file($homep.$topf.'_'.$lang.$ext) && is_readable($homep.$topf.'_'.$lang.$ext)) {
+					$home_top = @(string)file_get_contents($homep.$topf.'_'.$lang.$ext);
+				} elseif (is_file($homep.$topf.$lang.$ext) && is_readable($homep.$topf.$lang.$ext)) {
+					$home_top = @(string)file_get_contents($homep.$topf.$lang.$ext);
 				} else {
-					$errorMsg=get_lang('HomePageFilesNotReadable');
-				}		
+					$errorMsg = get_lang('HomePageFilesNotReadable');
+				}
+				$home_top = api_to_system_encoding($home_top, api_detect_encoding(strip_tags($home_top)));
 				break;
 		}
 	}
@@ -178,303 +168,304 @@ if (get_setting('allow_registration') == 'false') {
 	api_not_allowed();
 }
 //api_display_tool_title($tool_name);
-if (get_setting('allow_registration')=='approval') {
+if (get_setting('allow_registration') == 'approval') {
 	Display::display_normal_message(get_lang('YourAccountHasToBeApproved'));
 }
 //if openid was not found
 if (!empty($_GET['openid_msg']) && $_GET['openid_msg'] == 'idnotfound') {
-	Display::display_warning_message(get_lang('OpenIDCouldNotBeFoundPleaseRegister'));	
+	Display::display_warning_message(get_lang('OpenIDCouldNotBeFoundPleaseRegister'));
 }
 
 $form = new FormValidator('registration');
-if (get_setting('allow_terms_conditions')=='true') {
-	if (!isset($_SESSION['update_term_and_condition'][1])) {
-		$display_all_form=true;
-	} else {
-		$display_all_form=false;
-	}
+if (get_setting('allow_terms_conditions') == 'true') {
+	$display_all_form = !isset($_SESSION['update_term_and_condition'][1]);
 } else {
-	$display_all_form=true;
-}
-if ($display_all_form===true) {
-	
-//	LAST NAME and FIRST NAME
-$form->addElement('text', 'lastname',  get_lang('LastName'),  array('size' => 40, 'disabled' => 'disabled'));
-$form->applyFilter('lastname','trim');
-$form->addElement('text', 'firstname', get_lang('FirstName'), array('size' => 40, 'disabled' => 'disabled'));
-$form->applyFilter('firstname','trim');
-$form->addRule('lastname',  get_lang('ThisFieldIsRequired'), 'required');
-$form->addRule('firstname', get_lang('ThisFieldIsRequired'), 'required');
-//	EMAIL
-$form->addElement('text', 'email', get_lang('Email'), array('size' => 40, 'disabled' => 'disabled'));
-if (api_get_setting('registration', 'email') == 'true')
-	$form->addRule('email', get_lang('ThisFieldIsRequired'), 'required');
-$form->addRule('email', get_lang('EmailWrong'), 'email');
-if (api_get_setting('openid_authentication')=='true') {
-	$form->addElement('text', 'openid', get_lang('OpenIDURL'), array('size' => 40, 'disabled' => 'disabled'));	
+	$display_all_form = true;
 }
 
-//	USERNAME
-$form->addElement('text', 'username', get_lang('UserName'), array('size' => 20, 'disabled' => 'disabled'));
-$form->addRule('username', get_lang('ThisFieldIsRequired'), 'required');
-$form->addRule('username', get_lang('UsernameWrong'), 'username');
-$form->addRule('username', get_lang('UserTaken'), 'username_available');
-$form->addRule('username', sprintf(get_lang('UsernameMaxXCharacters'),'20'), 'maxlength',20);
-//	PASSWORD
-$form->addElement('password', 'pass1', get_lang('Pass'),         array('size' => 40, 'disabled' => 'disabled'));
-$form->addElement('password', 'pass2', get_lang('Confirmation'), array('size' => 40, 'disabled' => 'disabled'));
-$form->addRule('pass1', get_lang('ThisFieldIsRequired'), 'required');
-$form->addRule('pass2', get_lang('ThisFieldIsRequired'), 'required');
-$form->addRule(array('pass1', 'pass2'), get_lang('PassTwo'), 'compare');
-if (CHECK_PASS_EASY_TO_FIND)
-	$form->addRule('password1', get_lang('PassTooEasy').': '.api_generate_password(), 'callback', 'api_check_password');
-
-//	PHONE
-$form->addElement('text', 'phone', get_lang('Phone'), array('size' => 40, 'disabled' => 'disabled'));
-if (api_get_setting('registration', 'phone') == 'true')
-	$form->addRule('phone', get_lang('ThisFieldIsRequired'), 'required');
-
-//	LANGUAGE
-if (get_setting('registration', 'language') == 'true') {
-	$form->addElement('select_language', 'language', get_lang('Language'), '', array('disabled' => 'disabled'));
-}
-//	STUDENT/TEACHER
-if (get_setting('allow_registration_as_teacher') <> 'false') {
-	$form->addElement('radio', 'status', get_lang('Status'), get_lang('RegStudent'), STUDENT, array('disabled' => 'disabled'));
-	$form->addElement('radio', 'status', null, get_lang('RegAdmin'), COURSEMANAGER, array('disabled' => 'disabled'));
-}
+if ($display_all_form) {
 
-//	EXTENDED FIELDS
-if (api_get_setting('extended_profile') == 'true' AND api_get_setting('extendedprofile_registration','mycomptetences') == 'true')
-{
-	$form->add_html_editor('competences', get_lang('MyCompetences'), false, false, array('ToolbarSet' => 'Profile', 'Width' => '100%', 'Height' => '130'));
-}
-if (api_get_setting('extended_profile') == 'true' AND api_get_setting('extendedprofile_registration','mydiplomas') == 'true')
-{
-	$form->add_html_editor('diplomas', get_lang('MyDiplomas'), false, false, array('ToolbarSet' => 'Profile', 'Width' => '100%', 'Height' => '130'));
-}
-if (api_get_setting('extended_profile') == 'true' AND api_get_setting('extendedprofile_registration','myteach') == 'true')
-{
-	$form->add_html_editor('teach', get_lang('MyTeach'), false, false, array('ToolbarSet' => 'Profile', 'Width' => '100%', 'Height' => '130'));
-}
-if (api_get_setting('extended_profile') == 'true' AND api_get_setting('extendedprofile_registration','mypersonalopenarea') == 'true')
-{
-	$form->add_html_editor('openarea', get_lang('MyPersonalOpenArea'), false, false, array('ToolbarSet' => 'Profile', 'Width' => '100%', 'Height' => '130'));
-}
-if (api_get_setting('extended_profile') == 'true')
-{
-	if (api_get_setting('extendedprofile_registrationrequired','mycomptetences') == 'true')
-	{
-		$form->addRule('competences', get_lang('ThisFieldIsRequired'), 'required');
+	if (api_is_western_name_order()) {
+		//	FIRST NAME and LAST NAME
+		$form->addElement('text', 'lastname',  get_lang('LastName'),  array('size' => 40, 'disabled' => 'disabled'));
+		$form->addElement('text', 'firstname', get_lang('FirstName'), array('size' => 40, 'disabled' => 'disabled'));
+	} else {
+		//	LAST NAME and FIRST NAME
+		$form->addElement('text', 'lastname',  get_lang('LastName'),  array('size' => 40, 'disabled' => 'disabled'));
+		$form->addElement('text', 'firstname', get_lang('FirstName'), array('size' => 40, 'disabled' => 'disabled'));
 	}
-	if (api_get_setting('extendedprofile_registrationrequired','mydiplomas') == 'true')
-	{
-		$form->addRule('diplomas', get_lang('ThisFieldIsRequired'), 'required');
+	$form->applyFilter('firstname', 'trim');
+	$form->applyFilter('lastname', 'trim');
+	$form->addRule('lastname',  get_lang('ThisFieldIsRequired'), 'required');
+	$form->addRule('firstname', get_lang('ThisFieldIsRequired'), 'required');
+
+	//	EMAIL
+	$form->addElement('text', 'email', get_lang('Email'), array('size' => 40, 'disabled' => 'disabled'));
+	if (api_get_setting('registration', 'email') == 'true') {
+		$form->addRule('email', get_lang('ThisFieldIsRequired'), 'required');
 	}
-	if (api_get_setting('extendedprofile_registrationrequired','myteach') == 'true')
-	{
-		$form->addRule('teach', get_lang('ThisFieldIsRequired'), 'required');
+	$form->addRule('email', get_lang('EmailWrong'), 'email');
+	if (api_get_setting('openid_authentication') == 'true') {
+		$form->addElement('text', 'openid', get_lang('OpenIDURL'), array('size' => 40, 'disabled' => 'disabled'));
 	}
-	if (api_get_setting('extendedprofile_registrationrequired','mypersonalopenarea') == 'true')
-	{
-		$form->addRule('openarea', get_lang('ThisFieldIsRequired'), 'required');
+
+	//	USERNAME
+	$form->addElement('text', 'username', get_lang('UserName'), array('size' => USERNAME_MAX_LENGTH, 'disabled' => 'disabled'));
+	$form->addRule('username', get_lang('ThisFieldIsRequired'), 'required');
+	$form->addRule('username', get_lang('UsernameWrong'), 'username');
+	$form->addRule('username', get_lang('UserTaken'), 'username_available');
+	$form->addRule('username', sprintf(get_lang('UsernameMaxXCharacters'), (string)USERNAME_MAX_LENGTH), 'maxlength', USERNAME_MAX_LENGTH);
+
+	//	PASSWORD
+	$form->addElement('password', 'pass1', get_lang('Pass'),         array('size' => 40, 'disabled' => 'disabled'));
+	$form->addElement('password', 'pass2', get_lang('Confirmation'), array('size' => 40, 'disabled' => 'disabled'));
+	$form->addRule('pass1', get_lang('ThisFieldIsRequired'), 'required');
+	$form->addRule('pass2', get_lang('ThisFieldIsRequired'), 'required');
+	$form->addRule(array('pass1', 'pass2'), get_lang('PassTwo'), 'compare');
+	if (CHECK_PASS_EASY_TO_FIND) {
+		$form->addRule('password1', get_lang('PassTooEasy').': '.api_generate_password(), 'callback', 'api_check_password');
 	}
-}
-// EXTRA FIELDS
-$extra = UserManager::get_extra_fields(0,50,5,'ASC');
-$extra_data = UserManager::get_extra_user_data(api_get_user_id(),true);
-foreach ($extra as $id => $field_details) {
-	if ($field_details[6] == 0) {
-		continue;
+
+	//	PHONE
+	$form->addElement('text', 'phone', get_lang('Phone'), array('size' => 40, 'disabled' => 'disabled'));
+	if (api_get_setting('registration', 'phone') == 'true') {
+		$form->addRule('phone', get_lang('ThisFieldIsRequired'), 'required');
 	}
-	switch($field_details[2]) {
-		case USER_FIELD_TYPE_TEXT:
-			$form->addElement('text', 'extra_'.$field_details[1], $field_details[3], array('size' => 40));
-			$form->applyFilter('extra_'.$field_details[1], 'stripslashes');
-			$form->applyFilter('extra_'.$field_details[1], 'trim');
-			if ($field_details[7] == 0)	$form->freeze('extra_'.$field_details[1]);
-			break;
-		case USER_FIELD_TYPE_TEXTAREA:
-			$form->add_html_editor('extra_'.$field_details[1], $field_details[3], false, false, array('ToolbarSet' => 'Profile', 'Width' => '100%', 'Height' => '130'));
-			//$form->addElement('textarea', 'extra_'.$field_details[1], $field_details[3], array('size' => 80));
-			$form->applyFilter('extra_'.$field_details[1], 'stripslashes');
-			$form->applyFilter('extra_'.$field_details[1], 'trim');
-			if ($field_details[7] == 0)	$form->freeze('extra_'.$field_details[1]);
-			break;
-		case USER_FIELD_TYPE_RADIO:
-			$group = array();
-			foreach ($field_details[9] as $option_id => $option_details) {
-				$options[$option_details[1]] = $option_details[2];
-				$group[] =& HTML_QuickForm::createElement('radio', 'extra_'.$field_details[1], $option_details[1],$option_details[2].'<br />',$option_details[1]);
-			}
-			$form->addGroup($group, 'extra_'.$field_details[1], $field_details[3], '');
-			if ($field_details[7] == 0)	$form->freeze('extra_'.$field_details[1]);	
-			break;
-		case USER_FIELD_TYPE_SELECT:
-			$options = array();
-			foreach($field_details[9] as $option_id => $option_details) {
-				$options[$option_details[1]] = $option_details[2];
-			}
-			$form->addElement('select','extra_'.$field_details[1],$field_details[3],$options,'');	
-			if ($field_details[7] == 0)	$form->freeze('extra_'.$field_details[1]);			
-			break;
-		case USER_FIELD_TYPE_SELECT_MULTIPLE:
-			$options = array();
-			foreach ($field_details[9] as $option_id => $option_details) {
-				$options[$option_details[1]] = $option_details[2];
-			}
-			$form->addElement('select','extra_'.$field_details[1],$field_details[3],$options,array('multiple' => 'multiple'));
-			if ($field_details[7] == 0)	$form->freeze('extra_'.$field_details[1]);	
-			break;
-		case USER_FIELD_TYPE_DATE:
-			$form->addElement('datepickerdate', 'extra_'.$field_details[1], $field_details[3],array('form_name'=>'registration'));
-			$form->_elements[$form->_elementIndex['extra_'.$field_details[1]]]->setLocalOption('minYear',1900);
-			$defaults['extra_'.$field_details[1]] = date('Y-m-d 12:00:00');
-			$form -> setDefaults($defaults);
-			if ($field_details[7] == 0)	$form->freeze('extra_'.$field_details[1]);
-			$form->applyFilter('theme', 'trim');
-			break;
-		case USER_FIELD_TYPE_DATETIME:
-			$form->addElement('datepicker', 'extra_'.$field_details[1], $field_details[3],array('form_name'=>'registration'));
-			$form->_elements[$form->_elementIndex['extra_'.$field_details[1]]]->setLocalOption('minYear',1900);
-			$defaults['extra_'.$field_details[1]] = date('Y-m-d 12:00:00');
-			$form -> setDefaults($defaults);
-			if ($field_details[7] == 0)	$form->freeze('extra_'.$field_details[1]);
-			$form->applyFilter('theme', 'trim');
-			break;
-		case USER_FIELD_TYPE_DOUBLE_SELECT:
-			foreach ($field_details[9] as $key=>$element) {
-				if ($element[2][0] == '*') {
-					$values['*'][$element[0]] = str_replace('*','',$element[2]);
-				} else {
-					$values[0][$element[0]] = $element[2];
+
+	//	LANGUAGE
+	if (get_setting('registration', 'language') == 'true') {
+		$form->addElement('select_language', 'language', get_lang('Language'), '', array('disabled' => 'disabled'));
+	}
+
+	//	STUDENT/TEACHER
+	if (get_setting('allow_registration_as_teacher') != 'false') {
+		$form->addElement('radio', 'status', get_lang('Status'), get_lang('RegStudent'), STUDENT, array('disabled' => 'disabled'));
+		$form->addElement('radio', 'status', null, get_lang('RegAdmin'), COURSEMANAGER, array('disabled' => 'disabled'));
+	}
+
+	//	EXTENDED FIELDS
+	if (api_get_setting('extended_profile') == 'true' && api_get_setting('extendedprofile_registration','mycomptetences') == 'true') {
+		$form->add_html_editor('competences', get_lang('MyCompetences'), false, false, array('ToolbarSet' => 'Profile', 'Width' => '100%', 'Height' => '130'));
+	}
+	if (api_get_setting('extended_profile') == 'true' && api_get_setting('extendedprofile_registration','mydiplomas') == 'true') {
+		$form->add_html_editor('diplomas', get_lang('MyDiplomas'), false, false, array('ToolbarSet' => 'Profile', 'Width' => '100%', 'Height' => '130'));
+	}
+	if (api_get_setting('extended_profile') == 'true' && api_get_setting('extendedprofile_registration','myteach') == 'true') {
+		$form->add_html_editor('teach', get_lang('MyTeach'), false, false, array('ToolbarSet' => 'Profile', 'Width' => '100%', 'Height' => '130'));
+	}
+	if (api_get_setting('extended_profile') == 'true' && api_get_setting('extendedprofile_registration','mypersonalopenarea') == 'true') {
+		$form->add_html_editor('openarea', get_lang('MyPersonalOpenArea'), false, false, array('ToolbarSet' => 'Profile', 'Width' => '100%', 'Height' => '130'));
+	}
+	if (api_get_setting('extended_profile') == 'true') {
+		if (api_get_setting('extendedprofile_registrationrequired', 'mycomptetences') == 'true') {
+			$form->addRule('competences', get_lang('ThisFieldIsRequired'), 'required');
+		}
+		if (api_get_setting('extendedprofile_registrationrequired', 'mydiplomas') == 'true') {
+			$form->addRule('diplomas', get_lang('ThisFieldIsRequired'), 'required');
+		}
+		if (api_get_setting('extendedprofile_registrationrequired', 'myteach') == 'true') {
+			$form->addRule('teach', get_lang('ThisFieldIsRequired'), 'required');
+		}
+		if (api_get_setting('extendedprofile_registrationrequired', 'mypersonalopenarea') == 'true') {
+			$form->addRule('openarea', get_lang('ThisFieldIsRequired'), 'required');
+		}
+	}
+
+	// EXTRA FIELDS
+	$extra = UserManager::get_extra_fields(0, 50, 5, 'ASC');
+	$extra_data = UserManager::get_extra_user_data(api_get_user_id(), true);
+	foreach ($extra as $id => $field_details) {
+		if ($field_details[6] == 0) {
+			continue;
+		}
+		switch($field_details[2]) {
+			case USER_FIELD_TYPE_TEXT:
+				$form->addElement('text', 'extra_'.$field_details[1], $field_details[3], array('size' => 40));
+				$form->applyFilter('extra_'.$field_details[1], 'stripslashes');
+				$form->applyFilter('extra_'.$field_details[1], 'trim');
+				if ($field_details[7] == 0)	$form->freeze('extra_'.$field_details[1]);
+				break;
+			case USER_FIELD_TYPE_TEXTAREA:
+				$form->add_html_editor('extra_'.$field_details[1], $field_details[3], false, false, array('ToolbarSet' => 'Profile', 'Width' => '100%', 'Height' => '130'));
+				//$form->addElement('textarea', 'extra_'.$field_details[1], $field_details[3], array('size' => 80));
+				$form->applyFilter('extra_'.$field_details[1], 'stripslashes');
+				$form->applyFilter('extra_'.$field_details[1], 'trim');
+				if ($field_details[7] == 0)	$form->freeze('extra_'.$field_details[1]);
+				break;
+			case USER_FIELD_TYPE_RADIO:
+				$group = array();
+				foreach ($field_details[9] as $option_id => $option_details) {
+					$options[$option_details[1]] = $option_details[2];
+					$group[] =& HTML_QuickForm::createElement('radio', 'extra_'.$field_details[1], $option_details[1],$option_details[2].'<br />',$option_details[1]);
 				}
-			}
-			
-			$group='';
-			$group[] =& HTML_QuickForm::createElement('select', 'extra_'.$field_details[1],'',$values[0],'');
-			$group[] =& HTML_QuickForm::createElement('select', 'extra_'.$field_details[1].'*','',$values['*'],'');
-			$form->addGroup($group, 'extra_'.$field_details[1], $field_details[3], '&nbsp;');
-			if ($field_details[7] == 0)	$form->freeze('extra_'.$field_details[1]);
-
-			// recoding the selected values for double : if the user has selected certain values, we have to assign them to the correct select form
-			if (key_exists('extra_'.$field_details[1], $extra_data)) {
-				// exploding all the selected values (of both select forms)
-				$selected_values = explode(';',$extra_data['extra_'.$field_details[1]]);
-				$extra_data['extra_'.$field_details[1]]  =array();
-				
-				// looping through the selected values and assigning the selected values to either the first or second select form
-				foreach ($selected_values as $key=>$selected_value) {
-					if (key_exists($selected_value,$values[0])) {
-						$extra_data['extra_'.$field_details[1]]['extra_'.$field_details[1]] = $selected_value;
+				$form->addGroup($group, 'extra_'.$field_details[1], $field_details[3], '');
+				if ($field_details[7] == 0)	$form->freeze('extra_'.$field_details[1]);
+				break;
+			case USER_FIELD_TYPE_SELECT:
+				$options = array();
+				foreach($field_details[9] as $option_id => $option_details) {
+					$options[$option_details[1]] = $option_details[2];
+				}
+				$form->addElement('select','extra_'.$field_details[1], $field_details[3], $options, '');
+				if ($field_details[7] == 0)	$form->freeze('extra_'.$field_details[1]);
+				break;
+			case USER_FIELD_TYPE_SELECT_MULTIPLE:
+				$options = array();
+				foreach ($field_details[9] as $option_id => $option_details) {
+					$options[$option_details[1]] = $option_details[2];
+				}
+				$form->addElement('select','extra_'.$field_details[1], $field_details[3], $options, array('multiple' => 'multiple'));
+				if ($field_details[7] == 0)	$form->freeze('extra_'.$field_details[1]);
+				break;
+			case USER_FIELD_TYPE_DATE:
+				$form->addElement('datepickerdate', 'extra_'.$field_details[1], $field_details[3], array('form_name' => 'registration'));
+				$form->_elements[$form->_elementIndex['extra_'.$field_details[1]]]->setLocalOption('minYear', 1900);
+				$defaults['extra_'.$field_details[1]] = date('Y-m-d 12:00:00');
+				$form -> setDefaults($defaults);
+				if ($field_details[7] == 0)	$form->freeze('extra_'.$field_details[1]);
+				$form->applyFilter('theme', 'trim');
+				break;
+			case USER_FIELD_TYPE_DATETIME:
+				$form->addElement('datepicker', 'extra_'.$field_details[1], $field_details[3], array('form_name' => 'registration'));
+				$form->_elements[$form->_elementIndex['extra_'.$field_details[1]]]->setLocalOption('minYear', 1900);
+				$defaults['extra_'.$field_details[1]] = date('Y-m-d 12:00:00');
+				$form -> setDefaults($defaults);
+				if ($field_details[7] == 0)	$form->freeze('extra_'.$field_details[1]);
+				$form->applyFilter('theme', 'trim');
+				break;
+			case USER_FIELD_TYPE_DOUBLE_SELECT:
+				foreach ($field_details[9] as $key => $element) {
+					if ($element[2][0] == '*') {
+						$values['*'][$element[0]] = str_replace('*', '', $element[2]);
 					} else {
-						$extra_data['extra_'.$field_details[1]]['extra_'.$field_details[1].'*'] = $selected_value;
+						$values[0][$element[0]] = $element[2];
 					}
 				}
-			}
-			break;
-		case USER_FIELD_TYPE_DIVIDER:
-			$form->addElement('static',$field_details[1], '<br /><strong>'.$field_details[3].'</strong>');
-			break;
+
+				$group = '';
+				$group[] =& HTML_QuickForm::createElement('select', 'extra_'.$field_details[1], '', $values[0], '');
+				$group[] =& HTML_QuickForm::createElement('select', 'extra_'.$field_details[1].'*', '', $values['*'], '');
+				$form->addGroup($group, 'extra_'.$field_details[1], $field_details[3], '&nbsp;');
+				if ($field_details[7] == 0)	$form->freeze('extra_'.$field_details[1]);
+
+				// recoding the selected values for double : if the user has selected certain values, we have to assign them to the correct select form
+				if (key_exists('extra_'.$field_details[1], $extra_data)) {
+					// exploding all the selected values (of both select forms)
+					$selected_values = explode(';', $extra_data['extra_'.$field_details[1]]);
+					$extra_data['extra_'.$field_details[1]] = array();
+
+					// looping through the selected values and assigning the selected values to either the first or second select form
+					foreach ($selected_values as $key => $selected_value) {
+						if (key_exists($selected_value,$values[0])) {
+							$extra_data['extra_'.$field_details[1]]['extra_'.$field_details[1]] = $selected_value;
+						} else {
+							$extra_data['extra_'.$field_details[1]]['extra_'.$field_details[1].'*'] = $selected_value;
+						}
+					}
+				}
+				break;
+			case USER_FIELD_TYPE_DIVIDER:
+				$form->addElement('static', $field_details[1], '<br /><strong>'.$field_details[3].'</strong>');
+				break;
+		}
 	}
-}
 
 }
-//------------ Terms and conditions
-if (get_setting('allow_terms_conditions')=='true') {	
-	//$language = api_get_setting('platformLanguage');
+
+// Terms and conditions
+if (get_setting('allow_terms_conditions') == 'true') {
 	$language = api_get_interface_language();
 	$language = api_get_language_id($language);
-	$term_preview= LegalManager::get_last_condition($language);	
-	
-	if ($term_preview==false) { 
+	$term_preview = LegalManager::get_last_condition($language);
+
+	if (!$term_preview) {
 		//we load from the platform
 		$language = api_get_setting('platformLanguage');
 		$language = api_get_language_id($language);
-		$term_preview= LegalManager::get_last_condition($language);
+		$term_preview = LegalManager::get_last_condition($language);
 		//if is false we load from english
-		if ($term_preview==false){
+		if (!$term_preview) {
 			$language = api_get_language_id('english'); //this must work
-			$term_preview= LegalManager::get_last_condition($language);	
-		}					
-	}	
+			$term_preview = LegalManager::get_last_condition($language);
+		}
+	}
 	// Version and language //password
-	$form->addElement('hidden', 'legal_accept_type',$term_preview['version'].':'.$term_preview['language_id']);
-	$form->addElement('hidden', 'legal_info',$term_preview['legal_id'].':'.$term_preview['language_id']);	
+	$form->addElement('hidden', 'legal_accept_type', $term_preview['version'].':'.$term_preview['language_id']);
+	$form->addElement('hidden', 'legal_info', $term_preview['legal_id'].':'.$term_preview['language_id']);
 	if (isset($_SESSION['info_current_user'][1]) && isset($_SESSION['info_current_user'][2])) {
-		$form->addElement('hidden', 'login',$_SESSION['info_current_user'][1]);
-		$form->addElement('hidden', 'password',$_SESSION['info_current_user'][2]);	
+		$form->addElement('hidden', 'login', $_SESSION['info_current_user'][1]);
+		$form->addElement('hidden', 'password', $_SESSION['info_current_user'][2]);
 	}
-	if($term_preview['type'] == 1) {
-		$form->addElement('checkbox', 'legal_accept', null, get_lang('IHaveReadAndAgree').'&nbsp;<a href="inscription.php?legal" target="_blank">'.get_lang('TermsAndConditions').'</a>');		
+	if ($term_preview['type'] == 1) {
+		$form->addElement('checkbox', 'legal_accept', null, get_lang('IHaveReadAndAgree').'&nbsp;<a href="inscription.php?legal" target="_blank">'.get_lang('TermsAndConditions').'</a>');
 		$form->addRule('extra_legal_accept',  get_lang('ThisFieldIsRequired'), 'required');
 	} else {
-		if (!empty($term_preview['content'])) {			
+		if (!empty($term_preview['content'])) {
 			$preview = LegalManager::show_last_condition($term_preview);
-			$term_preview  = '<div class="row">
+			$term_preview = '<div class="row">
 					<div class="label">'.get_lang('TermsAndConditions').'</div>
 					<div class="formw">
 					'.$preview.'
-					<br />				
+					<br />
 					</div>
-					</div>';		
+					</div>';
 			$form->addElement('html', $term_preview);
-		}		
+		}
 	}
 }
 
-$form->addElement('style_submit_button', 'submit', get_lang('RegisterUser'),array('class' => 'save', 'disabled' => 'disabled'));
+$form->addElement('style_submit_button', 'submit', get_lang('RegisterUser'), array('class' => 'save', 'disabled' => 'disabled'));
+
 $defaults['status'] = STUDENT;
-$form->setDefaults($defaults);
-if(isset($_SESSION["user_language_choice"]) && $_SESSION["user_language_choice"]!=""){
-	$defaults['language'] = $_SESSION["user_language_choice"];
-}
-else{
+
+if (isset($_SESSION['user_language_choice']) && $_SESSION['user_language_choice'] != '') {
+	$defaults['language'] = $_SESSION['user_language_choice'];
+} else {
 	$defaults['language'] = api_get_setting('platformLanguage');
 }
-if(!empty($_GET['username']))
-{
+
+if (!empty($_GET['username'])) {
 	$defaults['username'] = Security::remove_XSS($_GET['username']);
 }
-if(!empty($_GET['email']))
-{
+
+if (!empty($_GET['email'])) {
 	$defaults['email'] = Security::remove_XSS($_GET['email']);
 }
 
-if(!empty($_GET['phone']))
-{
+if (!empty($_GET['phone'])) {
 	$defaults['phone'] = Security::remove_XSS($_GET['phone']);
 }
 
-if (api_get_setting('openid_authentication')=='true' && !empty($_GET['openid']))
-{
-	$defaults['openid'] = Security::remove_XSS($_GET['openid']);	
+if (api_get_setting('openid_authentication') == 'true' && !empty($_GET['openid'])) {
+	$defaults['openid'] = Security::remove_XSS($_GET['openid']);
 }
 
-switch($action){
+$form->setDefaults($defaults);
+
+switch ($action){
 	case 'edit_top':
-		if($action == 'edit_top') {
-			$name= $topf;
+		if ($action == 'edit_top') {
+			$name = $topf;
 			$open = $home_top;
 		} else {
 			$name = $newsf;
-			$open=@file_get_contents($homep.$newsf.'_'.$lang.$ext);
-
+			$open = @(string)file_get_contents($homep.$newsf.'_'.$lang.$ext);
+			$open = api_to_system_encoding($open, api_detect_encoding(strip_tags($open)));
 		}
 
-		if(!empty($errorMsg)) {
-			Display::display_normal_message($errorMsg); //main API
+		if (!empty($errorMsg)) {
+			Display::display_normal_message($errorMsg);
 		}
 
 		$default = array();
-		$form = new FormValidator('configure_homepage_'.$action, 'post', api_get_self().'?action='.$action, '', array('style' => 'margin: 0px;'));
+		$form = new FormValidator('configure_inscription_'.$action, 'post', api_get_self().'?action='.$action, '', array('style' => 'margin: 0px;'));
 		$renderer =& $form->defaultRenderer();
 		$renderer->setHeaderTemplate('');
 		$renderer->setFormTemplate('<form{attributes}><table border="0" cellpadding="5" cellspacing="0" width="100%">{content}</table></form>');
 		$renderer->setElementTemplate('<tr><td>{element}</td></tr>');
 		$renderer->setRequiredNoteTemplate('');
 		$form->addElement('hidden', 'formSent', '1');
-		if (api_get_setting('wcag_anysurfer_public_pages')=='true') {
+		if (api_get_setting('wcag_anysurfer_public_pages') == 'true') {
 			//TODO: review these lines
 			// Print WCAG-specific HTML editor
 			$html = '<tr><td>';
@@ -490,30 +481,22 @@ switch($action){
 		$form->display();
 		break;
 	default:
-		/*******************************/
 		//Form of language
 		api_display_language_form();
-		
 		echo '&nbsp;&nbsp;<a href="'.api_get_self().'?action=edit_top">'.Display::display_icon('edit.gif', get_lang('Edit')).'</a> <a href="'.api_get_self().'?action=edit_top">'.get_lang('EditNotice').'</a>';
-		echo '<div class="note">';
-		$home_notice = '';
-		if(file_exists($homep.$topf.'_'.$lang.$ext)) {
-		$home_notice = @file_get_contents($homep.$topf.'_'.$lang.$ext);
+		//echo '<div class="note">';
+		echo '<div style="border:1px solid #E1E1E1; padding:2px;">';
+		$open = '';
+		if (file_exists($homep.$topf.'_'.$lang.$ext)) {
+			$open = @(string)file_get_contents($homep.$topf.'_'.$lang.$ext);
 		} else {
-			$home_notice = @file_get_contents($homep.$topf.$ext);
+			$open = @(string)file_get_contents($homep.$topf.$ext);
 		}
-		echo $home_notice;
-		echo '</div>'; 
-		/*******************************/
+		$open = api_to_system_encoding($open, api_detect_encoding(strip_tags($open)));
+		echo $open;
+		echo '</div>';
 		$form->display();
 		break;
 }
 
-/*
-==============================================================================
-		FOOTER
-==============================================================================
-*/
-
 Display :: display_footer();
-?>

+ 2 - 2
main/admin/course_add.php

@@ -48,7 +48,7 @@ if ($_configuration['multiple_access_urls']==true){
 			ON (u.user_id=url_rel_user.user_id) WHERE url_rel_user.access_url_id=".api_get_current_access_url_id()." AND status=1".$order_clause;
 }
 
-$res = Database::query($sql,__FILE__,__LINE__);
+$res = Database::query($sql);
 $teachers = array();
 $teachers[0] = '-- '.get_lang('NoManager').' --';
 while($obj = Database::fetch_object($res))
@@ -164,7 +164,7 @@ if( $form->validate()) {
 		fill_Db_course($currentCourseDbName, $currentCourseRepository, $course_language,$pictures_array);
 		register_course($currentCourseId, $currentCourseCode, $currentCourseRepository, $currentCourseDbName, $tutor_name, $category, $title, $course_language, $teacher_id, $expiration_date,$course_teachers);
 		$sql = "UPDATE $table_course SET disk_quota = '".$disk_quota."', visibility = '".Database::escape_string($course['visibility'])."', subscribe = '".Database::escape_string($course['subscribe'])."', unsubscribe='".Database::escape_string($course['unsubscribe'])."' WHERE code = '".$currentCourseId."'";
-		Database::query($sql,__FILE__,__LINE__);
+		Database::query($sql);
 		header('Location: course_list.php');
 		exit ();
 	}

+ 23 - 23
main/admin/course_category.php

@@ -90,7 +90,7 @@ if(!empty($action))
 	{
 		$categoryCode=Database::escape_string($_GET['id']);
 
-		$result=Database::query("SELECT name,auth_course_child FROM $tbl_category WHERE code='$categoryCode'",__FILE__,__LINE__);
+		$result=Database::query("SELECT name,auth_course_child FROM $tbl_category WHERE code='$categoryCode'");
 
 		list($categoryName,$canHaveCourses)=Database::fetch_row($result);
 
@@ -117,7 +117,7 @@ Display::display_header($tool_name);
 if(!empty($category))
 {
 	$myquery = "SELECT * FROM $tbl_category WHERE code ='$category'";
-	$result	= Database::query($myquery,__FILE__,__LINE__);
+	$result	= Database::query($myquery);
 	if(Database::num_rows($result)==0)
 	{
 		$category = '';
@@ -127,7 +127,7 @@ if(!empty($category))
 if(empty($action))
 {
 	$myquery="SELECT t1.name,t1.code,t1.parent_id,t1.tree_pos,t1.children_count,COUNT(DISTINCT t3.code) AS nbr_courses FROM $tbl_category t1 LEFT JOIN $tbl_category t2 ON t1.code=t2.parent_id LEFT JOIN $tbl_course t3 ON t3.category_code=t1.code WHERE t1.parent_id ".(empty($category)?"IS NULL":"='$category'")." GROUP BY t1.name,t1.code,t1.parent_id,t1.tree_pos,t1.children_count ORDER BY t1.tree_pos";
-	$result=Database::query($myquery,__FILE__,__LINE__);
+	$result=Database::query($myquery);
 
 	$Categories=Database::store_result($result);
 }
@@ -221,7 +221,7 @@ else
 if(!empty($category) && empty($action))
 {
 	$myquery = "SELECT parent_id FROM $tbl_category WHERE code='$category'";
-	$result=Database::query($myquery,__FILE__,__LINE__);
+	$result=Database::query($myquery);
 	$parent_id = 0;
 	if(Database::num_rows($result)>0){
 		$parent_id=Database::fetch_array($result);
@@ -283,23 +283,23 @@ function deleteNode($node)
 	global $tbl_category, $tbl_course;
 	$node = Database::escape_string($node);
 
-	$result=Database::query("SELECT parent_id,tree_pos FROM $tbl_category WHERE code='$node'",__FILE__,__LINE__);
+	$result=Database::query("SELECT parent_id,tree_pos FROM $tbl_category WHERE code='$node'");
 
 	if($row=Database::fetch_array($result))
 	{
 		if(!empty($row['parent_id']))
 		{
-			Database::query("UPDATE $tbl_course SET category_code='".$row['parent_id']."' WHERE category_code='$node'",__FILE__,__LINE__);
-			Database::query("UPDATE $tbl_category SET parent_id='".$row['parent_id']."' WHERE parent_id='$node'",__FILE__,__LINE__);
+			Database::query("UPDATE $tbl_course SET category_code='".$row['parent_id']."' WHERE category_code='$node'");
+			Database::query("UPDATE $tbl_category SET parent_id='".$row['parent_id']."' WHERE parent_id='$node'");
 		}
 		else
 		{
-			Database::query("UPDATE $tbl_course SET category_code='' WHERE category_code='$node'",__FILE__,__LINE__);
-			Database::query("UPDATE $tbl_category SET parent_id=NULL WHERE parent_id='$node'",__FILE__,__LINE__);
+			Database::query("UPDATE $tbl_course SET category_code='' WHERE category_code='$node'");
+			Database::query("UPDATE $tbl_category SET parent_id=NULL WHERE parent_id='$node'");
 		}
 
-		Database::query("UPDATE $tbl_category SET tree_pos=tree_pos-1 WHERE tree_pos > '".$row['tree_pos']."'",__FILE__,__LINE__);
-		Database::query("DELETE FROM $tbl_category WHERE code='$node'",__FILE__,__LINE__);
+		Database::query("UPDATE $tbl_category SET tree_pos=tree_pos-1 WHERE tree_pos > '".$row['tree_pos']."'");
+		Database::query("DELETE FROM $tbl_category WHERE code='$node'");
 
 		if(!empty($row['parent_id']))
 		{
@@ -317,20 +317,20 @@ function addNode($code,$name,$canHaveCourses,$parent_id)
 	$name 			= Database::escape_string($name);
 	$parent_id		= Database::escape_string($parent_id);
 
-	$result=Database::query("SELECT 1 FROM $tbl_category WHERE code='$code'",__FILE__,__LINE__);
+	$result=Database::query("SELECT 1 FROM $tbl_category WHERE code='$code'");
 
 	if(Database::num_rows($result))
 	{
 		return false;
 	}
 
-	$result=Database::query("SELECT MAX(tree_pos) AS maxTreePos FROM $tbl_category",__FILE__,__LINE__);
+	$result=Database::query("SELECT MAX(tree_pos) AS maxTreePos FROM $tbl_category");
 
 	$row=Database::fetch_array($result);
 
 	$tree_pos=$row['maxTreePos']+1;
 
-	Database::query("INSERT INTO $tbl_category(name,code,parent_id,tree_pos,children_count,auth_course_child) VALUES('$name','$code',".(empty($parent_id)?"NULL":"'$parent_id'").",'$tree_pos','0','$canHaveCourses')",__FILE__,__LINE__);
+	Database::query("INSERT INTO $tbl_category(name,code,parent_id,tree_pos,children_count,auth_course_child) VALUES('$name','$code',".(empty($parent_id)?"NULL":"'$parent_id'").",'$tree_pos','0','$canHaveCourses')");
 
 	updateFils($parent_id);
 
@@ -348,7 +348,7 @@ function editNode($code,$name,$canHaveCourses,$old_code)
 
 	if($code != $old_code)
 	{
-		$result=Database::query("SELECT 1 FROM $tbl_category WHERE code='$code'",__FILE__,__LINE__);
+		$result=Database::query("SELECT 1 FROM $tbl_category WHERE code='$code'");
 
 		if(Database::num_rows($result))
 		{
@@ -356,7 +356,7 @@ function editNode($code,$name,$canHaveCourses,$old_code)
 		}
 	}
 
-	Database::query("UPDATE $tbl_category SET name='$name',code='$code',auth_course_child='$canHaveCourses' WHERE code='$old_code'",__FILE__,__LINE__);
+	Database::query("UPDATE $tbl_category SET name='$name',code='$code',auth_course_child='$canHaveCourses' WHERE code='$old_code'");
 
 	return true;
 }
@@ -368,11 +368,11 @@ function moveNodeUp($code,$tree_pos,$parent_id)
 	$tree_pos 	= Database::escape_string($tree_pos);
 	$parent_id	= Database::escape_string($parent_id);
 
-	$result=Database::query("SELECT code,tree_pos FROM $tbl_category WHERE parent_id ".(empty($parent_id)?"IS NULL":"='$parent_id'")." AND tree_pos<'$tree_pos' ORDER BY tree_pos DESC LIMIT 0,1",__FILE__,__LINE__);
+	$result=Database::query("SELECT code,tree_pos FROM $tbl_category WHERE parent_id ".(empty($parent_id)?"IS NULL":"='$parent_id'")." AND tree_pos<'$tree_pos' ORDER BY tree_pos DESC LIMIT 0,1");
 
 	if(!$row=Database::fetch_array($result))
 	{
-		$result=Database::query("SELECT code,tree_pos FROM $tbl_category WHERE parent_id ".(empty($parent_id)?"IS NULL":"='$parent_id'")." AND tree_pos>'$tree_pos' ORDER BY tree_pos DESC LIMIT 0,1",__FILE__,__LINE__);
+		$result=Database::query("SELECT code,tree_pos FROM $tbl_category WHERE parent_id ".(empty($parent_id)?"IS NULL":"='$parent_id'")." AND tree_pos>'$tree_pos' ORDER BY tree_pos DESC LIMIT 0,1");
 
 		if(!$row=Database::fetch_array($result))
 		{
@@ -380,15 +380,15 @@ function moveNodeUp($code,$tree_pos,$parent_id)
 		}
 	}
 
-	Database::query("UPDATE $tbl_category SET tree_pos='".$row['tree_pos']."' WHERE code='$code'",__FILE__,__LINE__);
-	Database::query("UPDATE $tbl_category SET tree_pos='$tree_pos' WHERE code='$row[code]'",__FILE__,__LINE__);
+	Database::query("UPDATE $tbl_category SET tree_pos='".$row['tree_pos']."' WHERE code='$code'");
+	Database::query("UPDATE $tbl_category SET tree_pos='$tree_pos' WHERE code='$row[code]'");
 }
 
 function updateFils($category)
 {
 	global $tbl_category;
 	$category = Database::escape_string($category);
-	$result=Database::query("SELECT parent_id FROM $tbl_category WHERE code='$category'",__FILE__,__LINE__);
+	$result=Database::query("SELECT parent_id FROM $tbl_category WHERE code='$category'");
 
 	if($row=Database::fetch_array($result))
 	{
@@ -397,14 +397,14 @@ function updateFils($category)
 
 	$children_count=compterFils($category,0)-1;
 
-	Database::query("UPDATE $tbl_category SET children_count='$children_count' WHERE code='$category'",__FILE__,__LINE__);
+	Database::query("UPDATE $tbl_category SET children_count='$children_count' WHERE code='$category'");
 }
 
 function compterFils($pere,$cpt)
 {
 	global $tbl_category;
 	$pere = Database::escape_string($pere);
-	$result=Database::query("SELECT code FROM $tbl_category WHERE parent_id='$pere'",__FILE__,__LINE__);
+	$result=Database::query("SELECT code FROM $tbl_category WHERE parent_id='$pere'");
 
 	while($row=Database::fetch_array($result))
 	{

+ 1 - 1
main/admin/course_create_content.php

@@ -61,7 +61,7 @@ elseif( isset($_POST['action']))
 else
 {
 	echo get_lang('DummyCourseDescription');
-	echo '<form method="post"><input type="hidden" name="course_code" value="'.$_GET['course_code'].'"/><input type="submit" name="action" value="'.get_lang('Ok').'"/></form>';
+	echo '<form method="post"><input type="hidden" name="course_code" value="'.Security::remove_XSS($_GET['course_code']).'"/><input type="submit" name="action" value="'.get_lang('Ok').'"/></form>';
 }
 /*
 ==============================================================================

+ 19 - 20
main/admin/course_edit.php

@@ -53,7 +53,7 @@ $table_user = Database :: get_main_table(TABLE_MAIN_USER);
 
 //Get the course infos
 $sql = "SELECT * FROM $course_table WHERE code='".Database::escape_string($course_code)."'";
-$result = Database::query($sql, __FILE__, __LINE__);
+$result = Database::query($sql);
 if (Database::num_rows($result) != 1)
 {
 	header('Location: course_list.php');
@@ -65,7 +65,7 @@ $course = Database::fetch_array($result,'ASSOC');
 $table_course_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
 $order_clause = api_sort_by_first_name() ? ' ORDER BY firstname, lastname' : ' ORDER BY lastname, firstname';
 $sql = "SELECT user.user_id,lastname,firstname FROM $table_user as user,$table_course_user as course_user WHERE course_user.status='1' AND course_user.user_id=user.user_id AND course_user.course_code='".$course_code."'".$order_clause;
-$res = Database::query($sql,__FILE__,__LINE__);
+$res = Database::query($sql);
 $course_teachers = array();
 while($obj = Database::fetch_object($res))
 {
@@ -74,7 +74,7 @@ while($obj = Database::fetch_object($res))
 
 // Get all possible teachers without the course teachers
 $sql = "SELECT user_id,lastname,firstname FROM $table_user WHERE status='1'".$order_clause;
-$res = Database::query($sql,__FILE__,__LINE__);
+$res = Database::query($sql);
 $teachers = array();
 
 $platform_teachers[0] = '-- '.get_lang('NoManager').' --';
@@ -89,13 +89,13 @@ while($obj = Database::fetch_object($res))
 		$course['tutor_name']=$obj->user_id;
 	}
 	//We add in the array platform teachers
-	$platform_teachers[$obj->user_id] = api_get_person_name($obj->firstname, $obj->lastname);
+	$platform_teachers[$obj->user_id] = $obj->firstname.' '.$obj->lastname;
 }
 
 //Case where there is no teacher in the course
 if(count($course_teachers)==0){
 	$sql='SELECT tutor_name FROM '.$course_table.' WHERE code="'.$course_code.'"';
-	$res = Database::query($sql,__FILE__,__LINE__);
+	$res = Database::query($sql);
 	$tutor_name=Database::result($res,0,0);
 	$course['tutor_name']=array_search($tutor_name,$platform_teachers);
 }
@@ -180,7 +180,7 @@ foreach($list_course_extra_field as $extra_field){
 			$checked = (array_key_exists('extra_field_value', $extra_field) && $extra_field['extra_field_value'] == 1)? array('checked'=>'checked'): '';
 			$form->addElement('hidden', '_extra_'.$extra_field['field_variable'], 0);
 			$field_display_text=$extra_field['field_display_text'];
-			$form->addElement('checkbox', 'extra_'.$extra_field['field_variable'],get_lang($field_display_text) , get_lang($extra_field['field_default_value']), $checked);
+			$form->addElement('checkbox', 'extra_'.$extra_field['field_variable'],get_lang('SpecialCourse') , get_lang($extra_field['field_default_value']), $checked);
 			break;
 		/* case USER_FIELD_TYPE_SELECT_MULTIPLE:
 		case USER_FIELD_TYPE_DATE:
@@ -205,12 +205,11 @@ if( $form->validate())
 
     // Check if the visual code is already used by *another* course
     $visual_code_is_used = false;
-    error_log($visual_code);
+
     $warn = get_lang('TheFollowingCoursesAlreadyUseThisVisualCode').':';
     if (!empty($visual_code)) {
         $list = CourseManager::get_courses_info_from_visual_code($visual_code);
         foreach ($list as $course_temp) {
-            error_log($course_temp['code']);
         	if ($course_temp['code'] != $course_code) {
         	   $visual_code_is_used = true;
                $warn .= ' '.$course_temp['title'].' ('.$course_temp['code'].'),';
@@ -221,14 +220,14 @@ if( $form->validate())
     // an extra field
     $extras = array();
     foreach($course as $key => $value) {
-	    if(substr($key,0,6)=='extra_') {  
+	    if(substr($key,0,6)=='extra_') {
 			$extras[substr($key,6)] = $value;
 		}
 		if(substr($key,0,7)=='_extra_') {
 			if(!array_key_exists(substr($key,7), $extras)) $extras[substr($key,7)] = $value;
 		}
     }
-    
+
 	$tutor_id = $course['tutor_name'];
 	$tutor_name=$platform_teachers[$tutor_id];
 
@@ -259,32 +258,32 @@ if( $form->validate())
 								subscribe = '".Database::escape_string($subscribe)."',
 								unsubscribe='".Database::escape_string($unsubscribe)."'
 							WHERE code='".Database::escape_string($course_code)."'";
-	Database::query($sql, __FILE__, __LINE__);
-	
+	Database::query($sql);
+
 	//update the extra fields
-	if(count($extras) > 0){ 
+	if(count($extras) > 0){
 		foreach($extras as $key => $value) {
 			CourseManager::update_course_extra_field_value($course_code, $key, $value);
 		}
 	}
-	
+
 	//Delete only teacher relations that doesn't match the selected teachers
 	$cond='';
 	if(count($teachers)>0){
 		foreach($teachers as $key) $cond.=" AND user_id<>'".$key."'";
 	}
 	$sql='DELETE FROM '.$course_user_table.' WHERE course_code="'.Database::escape_string($course_code).'" AND status="1"'.$cond;
-	Database::query($sql, __FILE__, __LINE__);
+	Database::query($sql);
 
 	if(count($teachers)>0){
 		foreach($teachers as $key){
 
 			//We check if the teacher is already subscribed in this course
-			$sql_select_teacher = 'SELECT 1 FROM '.$course_user_table.' WHERE user_id = "'.$key.'" AND course_code = "'.$course_code.'"';
-			$result = Database::query($sql_select_teacher, __FILE__, __LINE__);
+			$sql_select_teacher = 'SELECT 1 FROM '.$course_user_table.' WHERE user_id = "'.$key.'" AND course_code = "'.$course_code.'" ';
+			$result = Database::query($sql_select_teacher);
 
 			if(Database::num_rows($result) == 1){
-				$sql = 'UPDATE '.$course_user_table.' SET status = "1" WHERE course_code = "'.$course_code.'" AND user_id = "'.$key.'"';
+				$sql = 'UPDATE '.$course_user_table.' SET status = "1" WHERE course_code = "'.$course_code.'" AND user_id = "'.$key.'"  ';
 			}
 			else{
 				$sql = "INSERT INTO ".$course_user_table . " SET
@@ -296,7 +295,7 @@ if( $form->validate())
 					sort='0',
 					user_course_cat='0'";
 			}
-			Database::query($sql, __FILE__, __LINE__);
+			Database::query($sql);
 
 		}
 
@@ -310,7 +309,7 @@ if( $form->validate())
 				tutor_id='0',
 				sort='0',
 				user_course_cat='0'";
-	Database::query($sql, __FILE__, __LINE__);
+	Database::query($sql);
 
 	$forum_config_table = Database::get_course_table(TOOL_FORUM_CONFIG_TABLE,$course_db_name);
 	$sql = "UPDATE ".$forum_config_table." SET default_lang='".Database::escape_string($course_language)."'";

+ 24 - 24
main/admin/course_export.php

@@ -23,55 +23,55 @@ $interbreadcrumb[] = array ('url' => 'index.php', 'name' => get_lang('PlatformAd
 set_time_limit(0);
 Display :: display_header($tool_name);
 
-$archivePath=api_get_path(SYS_PATH).$archiveDirName.'/';
-$archiveURL=api_get_path(WEB_CODE_PATH).'course_info/download.php?archive=';
+$archivePath = api_get_path(SYS_ARCHIVE_PATH);
+$archiveURL = api_get_path(WEB_CODE_PATH).'course_info/download.php?archive=';
 
 $course_list = CourseManager::get_courses_list();
 
 if($_POST['formSent'])
-{			
+{
 	$formSent	=$_POST['formSent'];
 	$select_type=intval($_POST['select_type']);
-	$file_type = 'csv';	
+	$file_type = 'csv';
 	$courses = $selected_courses = array();
-	
+
 	if ($select_type == 2) {
-		// Get selected courses from courses list in form sent 
+		// Get selected courses from courses list in form sent
 		$selected_courses = $_POST['course_code'];
-		if (is_array($selected_courses)) {		
-			foreach ($course_list as $course) {			
+		if (is_array($selected_courses)) {
+			foreach ($course_list as $course) {
 				if (!in_array($course['code'],$selected_courses)) continue;
 				$courses[] = $course;
 			}
-		}				
+		}
 	} else {
 		// Get all courses
 		$courses = $course_list;
 	}
 
-	if (!empty($courses)) {			
-		if(!file_exists($archivePath)) {
-			mkpath($archivePath);
-		}				
-		$archiveFile='export_courses_list_'.date('Y-m-d_H-i-s').'.'.$file_type;
-		$fp=fopen($archivePath.$archiveFile,'w');	
-		if ($file_type == 'csv') {		
-			$add = "Code;Title;CourseCategory;Teacher;Language;".PHP_EOL;						
+	if (!empty($courses)) {
+		if (!file_exists($archivePath)) {
+			mkdir($archivePath, api_get_permissions_for_new_directories(), true);
+		}
+		$archiveFile = 'export_courses_list_'.date('Y-m-d_H-i-s').'.'.$file_type;
+		$fp = fopen($archivePath.$archiveFile,'w');
+		if ($file_type == 'csv') {
+			$add = "Code;Title;CourseCategory;Teacher;Language;".PHP_EOL;
 			foreach($courses as $course) {
 				$course['code'] = str_replace(';',',',$course['code']);
 				$course['title'] = str_replace(';',',',$course['title']);
 				$course['category_code'] = str_replace(';',',',$course['category_code']);
-				$course['tutor_name'] = str_replace(';',',',$course['tutor_name']);						
+				$course['tutor_name'] = str_replace(';',',',$course['tutor_name']);
 				$course['course_language'] = str_replace(';',',',$course['course_language']);
-				
-				$add.= $course['code'].';'.$course['title'].';'.$course['category_code'].';'.$course['tutor_name'].';'.$course['course_language'].';'.PHP_EOL;			
-			}		
+
+				$add.= $course['code'].';'.$course['title'].';'.$course['category_code'].';'.$course['tutor_name'].';'.$course['course_language'].';'.PHP_EOL;
+			}
 			fputs($fp, $add);
-		}	
+		}
 		fclose($fp);
-		$msg=get_lang('CoursesListHasBeenExported').'<br/><a href="'.$archiveURL.$archiveFile.'">'.get_lang('ClickHereToDownloadTheFile').'</a>';
+		$msg = get_lang('CoursesListHasBeenExported').'<br/><a href="'.$archiveURL.$archiveFile.'">'.get_lang('ClickHereToDownloadTheFile').'</a>';
 	} else {
-		$msg=get_lang('ThereAreNotSelectedCoursesOrCoursesListIsEmpty');
+		$msg = get_lang('ThereAreNotSelectedCoursesOrCoursesListIsEmpty');
 	}
 }
 

+ 16 - 16
main/admin/course_import.php

@@ -65,14 +65,14 @@ function validate_data($courses) {
 			else {
 				$course_table = Database :: get_main_table(TABLE_MAIN_COURSE);
 				$sql = "SELECT * FROM $course_table WHERE code = '".Database::escape_string($course['Code'])."'";
-				$res = Database::query($sql, __FILE__, __LINE__);
+				$res = Database::query($sql);
 				if (Database::num_rows($res) > 0) {
 					$course['error'] = get_lang('CodeExists');
 					$errors[] = $course;
 				}
 			}
 			$coursecodes[$course['Code']] = 1;
-		}				
+		}
 		/*
 		// 3. Check whether teacher exists.
 		if (!UserManager::is_username_empty($course['Teacher'])) {
@@ -82,12 +82,12 @@ function validate_data($courses) {
 				$errors[] = $course;
 			}
 		}
-		*/		
+		*/
 		// 4. Check whether course category exists.
 		if (isset ($course['CourseCategory']) && strlen($course['CourseCategory']) != 0) {
 			$category_table = Database :: get_main_table(TABLE_MAIN_CATEGORY);
 			$sql = "SELECT * FROM $category_table WHERE code = '".Database::escape_string($course['CourseCategory'])."'";
-			$res = Database::query($sql, __FILE__, __LINE__);
+			$res = Database::query($sql);
 			if (Database::num_rows($res) == 0) {
 				$course['error'] = get_lang('UnkownCategoryCourseCode').' ('.$course['CourseCategory'].')';
 				$errors[] = $course;
@@ -104,32 +104,32 @@ function validate_data($courses) {
 function save_data($courses) {
 	global $_configuration, $firstExpirationDelay;
 	global $purification_option_for_usernames;
-	
-	$user_table = Database::get_main_table(TABLE_MAIN_USER);	
+
+	$user_table = Database::get_main_table(TABLE_MAIN_USER);
 	$msg = '';
 	foreach ($courses as $index => $course) {
 		$course_language = api_get_valid_language($course['Language']);
 		$keys = define_course_keys($course['Code'], '', $_configuration['db_prefix']);
-		
+
 		$titular = $uidCreator = $username = '';
-		
+
 		// get username from name (firstname lastname)
 		if (!UserManager::is_username_empty($course['Teacher'])) {
 			$teacher = UserManager::purify_username($course['Teacher'], $purification_option_for_usernames);
-			if (UserManager::is_username_available($teacher)) {				
-				$sql 	= "SELECT username FROM $user_table WHERE ".(api_is_western_name_order(null, $course_language) ? "CONCAT(firstname,' ',lastname)" : "CONCAT(lastname,' ',firstname)")." = '{$course['Teacher']}' LIMIT 1";	
-				$rs 	= Database::query($sql,__FILE__,__LINE__);
+			if (UserManager::is_username_available($teacher)) {
+				$sql 	= "SELECT username FROM $user_table WHERE ".(api_is_western_name_order(null, $course_language) ? "CONCAT(firstname,' ',lastname)" : "CONCAT(lastname,' ',firstname)")." = '{$course['Teacher']}' LIMIT 1";
+				$rs 	= Database::query($sql);
 				$user   = Database::fetch_object($rs);
-				$username = $user->username;								
+				$username = $user->username;
 			} else {
 				$username = $teacher;
-			} 
+			}
 		}
 
 		// get name and uid creator from username
-		if (!empty($username)) {			
+		if (!empty($username)) {
 				$sql = "SELECT user_id, ".(api_is_western_name_order(null, $course_language) ? "CONCAT(firstname,' ',lastname)" : "CONCAT(lastname,' ',firstname)")." AS name FROM $user_table WHERE username = '".Database::escape_string(UserManager::purify_username($username, $purification_option_for_usernames))."'";
-				$res = Database::query($sql,__FILE__,__LINE__);
+				$res = Database::query($sql);
 				$teacher 	= Database::fetch_object($res);
 				$titular 	= $teacher->name;
 				$uidCreator = $teacher->user_id;
@@ -137,7 +137,7 @@ function save_data($courses) {
 				$titular 	= $course['Teacher'];
 				$uidCreator = 1;
 		}
-		
+
 		$visual_code = $keys['currentCourseCode'];
 		$code = $keys['currentCourseId'];
 		$db_name = $keys['currentCourseDbName'];

+ 31 - 38
main/admin/course_information.php

@@ -5,54 +5,51 @@
  * @author Bart Mollet
  * @package dokeos.admin
 */
-/*
-==============================================================================
-		INIT SECTION
-==============================================================================
-*/
+/*		INIT SECTION */
 
 // name of the language file that needs to be included
 $language_file = 'admin';
 $cidReset = true;
-require ('../inc/global.inc.php');
-require_once(api_get_path(LIBRARY_PATH).'sortabletable.class.php');
+require_once '../inc/global.inc.php';
+require_once api_get_path(LIBRARY_PATH).'sortabletable.class.php';
+require_once api_get_path(LIBRARY_PATH).'course.lib.php';
 $this_section=SECTION_PLATFORM_ADMIN;
 
 api_protect_admin_script();
 /**
  *
  */
-function get_course_usage($course_code)
+function get_course_usage($course_code, $session_id = 0)
 {
 	$table = Database::get_main_table(TABLE_MAIN_COURSE);
     $course_code = Database::escape_string($course_code);
 	$sql = "SELECT * FROM $table WHERE code='".$course_code."'";
-	$res = Database::query($sql,__FILE__,__LINE__);
+	$res = Database::query($sql);
 	$course = Database::fetch_object($res);
 	// Learnpaths
 	$table = Database :: get_course_table(TABLE_LP_MAIN, $course->db_name);
-	$usage[] = array (get_lang(ucfirst(TOOL_LEARNPATH)), Database::count_rows($table));
+	$usage[] = array (get_lang(ucfirst(TOOL_LEARNPATH)), CourseManager::count_rows_course_table($table,$session_id));
 	// Forums
 	$table = Database :: get_course_table(TABLE_FORUM, $course->db_name);
-	$usage[] = array (get_lang('Forums'), Database::count_rows($table));
+	$usage[] = array (get_lang('Forums'), CourseManager::count_rows_course_table($table,$session_id));
 	// Quizzes
 	$table = Database :: get_course_table(TABLE_QUIZ_TEST, $course->db_name);
-	$usage[] = array (get_lang(ucfirst(TOOL_QUIZ)), Database::count_rows($table));
+	$usage[] = array (get_lang(ucfirst(TOOL_QUIZ)), CourseManager::count_rows_course_table($table,$session_id));
 	// Documents
 	$table = Database :: get_course_table(TABLE_DOCUMENT, $course->db_name);
-	$usage[] = array (get_lang(ucfirst(TOOL_DOCUMENT)), Database::count_rows($table));
+	$usage[] = array (get_lang(ucfirst(TOOL_DOCUMENT)), CourseManager::count_rows_course_table($table,$session_id));
 	// Groups
 	$table = Database :: get_course_table(TABLE_GROUP, $course->db_name);
-	$usage[] = array (get_lang(ucfirst(TOOL_GROUP)), Database::count_rows($table));
+	$usage[] = array (get_lang(ucfirst(TOOL_GROUP)), CourseManager::count_rows_course_table($table,$session_id));
 	// Calendar
 	$table = Database :: get_course_table(TABLE_AGENDA, $course->db_name);
-	$usage[] = array (get_lang(ucfirst(TOOL_CALENDAR_EVENT)), Database::count_rows($table));
+	$usage[] = array (get_lang(ucfirst(TOOL_CALENDAR_EVENT)), CourseManager::count_rows_course_table($table,$session_id));
 	// Link
 	$table = Database::get_course_table(TABLE_LINK, $course->db_name);
-	$usage[] = array(get_lang(ucfirst(TOOL_LINK)), Database::count_rows($table));
+	$usage[] = array(get_lang(ucfirst(TOOL_LINK)), CourseManager::count_rows_course_table($table,$session_id));
 	// Announcements
 	$table = Database::get_course_table(TABLE_ANNOUNCEMENT, $course->db_name);
-	$usage[] = array(get_lang(ucfirst(TOOL_ANNOUNCEMENT)), Database::count_rows($table));
+	$usage[] = array(get_lang(ucfirst(TOOL_ANNOUNCEMENT)), CourseManager::count_rows_course_table($table,$session_id));
 	return $usage;
 }
 /*****************************************************************/
@@ -65,18 +62,17 @@ $interbreadcrumb[] = array ("url" => 'course_list.php', "name" => get_lang('Cour
 $table_course = Database :: get_main_table(TABLE_MAIN_COURSE);
 $code = Database::escape_string($_GET['code']);
 $sql = "SELECT * FROM $table_course WHERE code = '".$code."'";
-$res = Database::query($sql,__FILE__,__LINE__);
+$res = Database::query($sql);
 $course = Database::fetch_object($res);
 $tool_name = $course->title.' ('.$course->visual_code.')';
 Display::display_header($tool_name);
-//api_display_tool_title($tool_name);
+
 ?>
-<p>
+<div class="actions">
 <a href="<?php echo api_get_path(WEB_COURSE_PATH).$course->directory; ?>"><?php Display::display_icon('course_home.gif', get_lang('CourseHomepage')); ?> <?php echo get_lang('CourseHomepage'); ?></a>
-<br/>
+</div>
 <?php
-if(api_get_setting('server_type') == 'test')
-{
+if(api_get_setting('server_type') == 'test') {
 	?>
 	<a href="course_create_content.php?course_code=<?php echo $course->code ?>"><?php echo get_lang('AddDummyContentToCourse') ?></a>
 	<?php
@@ -87,8 +83,10 @@ if(api_get_setting('server_type') == 'test')
 
 echo '<h4>'.get_lang('CourseUsage').'</h4>';
 echo '<blockquote>';
-$table = new SortableTableFromArray(get_course_usage($course->code),0,20,'usage_table');
-$table->set_additional_parameters(array ('code' => $_GET['code']));
+
+$id_session = intval($_GET['id_session']);
+$table = new SortableTableFromArray(get_course_usage($course->code,$id_session),0,20,'usage_table');
+$table->set_additional_parameters(array ('code' => Security::remove_XSS($_GET['code'])));
 $table->set_other_tables(array('user_table','class_table'));
 $table->set_header(0,get_lang('Tool'), true);
 $table->set_header(1,get_lang('NumberOfItems'), true);
@@ -101,14 +99,13 @@ echo '<h4>'.get_lang('Users').'</h4>';
 echo '<blockquote>';
 $table_course_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
 $table_user = Database :: get_main_table(TABLE_MAIN_USER);
-$sql = "SELECT *,cu.status as course_status FROM $table_course_user cu, $table_user u WHERE cu.user_id = u.user_id AND cu.course_code = '".$code."'";
-$res = Database::query($sql,__FILE__,__LINE__);
+$sql = "SELECT *,cu.status as course_status FROM $table_course_user cu, $table_user u WHERE cu.user_id = u.user_id AND cu.course_code = '".$code."' AND cu.relation_type <> ".COURSE_RELATION_TYPE_RRHH." ";
+$res = Database::query($sql);
 $is_western_name_order = api_is_western_name_order();
 if (Database::num_rows($res) > 0)
 {
 	$users = array ();
-	while ($obj = Database::fetch_object($res))
-	{
+	while ($obj = Database::fetch_object($res)) {
 		$user = array ();
 		$user[] = $obj->official_code;
 		if ($is_western_name_order)
@@ -150,13 +147,15 @@ else
 	echo get_lang('NoUsersInCourse');
 }
 echo '</blockquote>';
+
+/*@todo This should be dissapear classes are a deprecated feature*/ 
 /**
  * Show all classes subscribed in this course
  */
 $table_course_class = Database :: get_main_table(TABLE_MAIN_COURSE_CLASS);
 $table_class = Database :: get_main_table(TABLE_MAIN_CLASS);
 $sql = "SELECT * FROM $table_course_class cc, $table_class c WHERE cc.class_id = c.id AND cc.course_code = '".$code."'";
-$res = Database::query($sql,__FILE__,__LINE__);
+$res = Database::query($sql);
 if (Database::num_rows($res) > 0)
 {
 	$data = array ();
@@ -176,15 +175,9 @@ if (Database::num_rows($res) > 0)
 	$table->set_header(1,'');
 	$table->display();
 	echo '</blockquote>';
-}
-else
-{
+} else {
 	echo '<p>'.get_lang('NoClassesForThisCourse').'</p>';
 }
-/*
-==============================================================================
-		FOOTER
-==============================================================================
-*/
+/*	FOOTER	*/
 Display::display_footer();
 ?>

+ 30 - 37
main/admin/course_list.php

@@ -1,33 +1,28 @@
 <?php // $Id: course_list.php 21855 2009-07-07 18:26:10Z juliomontoya $
-/* For licensing terms, see /dokeos_license.txt */
+/* For licensing terms, see /license.txt */
 /**
  * This script shows a list of courses and allows searching for courses codes
  * and names
- * @package dokeos.admin
+ * @package chamilo.admin
  */
-/*
-==============================================================================
-		INIT SECTION
-==============================================================================
-*/
+/*	INIT SECTION	*/
 
 // name of the language file that needs to be included
 $language_file = array('admin','courses');
 $cidReset = true;
-require ('../inc/global.inc.php');
+require_once '../inc/global.inc.php';
 $this_section = SECTION_PLATFORM_ADMIN;
 
 api_protect_admin_script();
-require_once (api_get_path(LIBRARY_PATH).'course.lib.php');
-require_once (api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php');
-require_once (api_get_path(LIBRARY_PATH).'sortabletable.class.php');
+require_once api_get_path(LIBRARY_PATH).'course.lib.php';
+require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php';
+require_once api_get_path(LIBRARY_PATH).'sortabletable.class.php';
 require_once '../gradebook/lib/be/gradebookitem.class.php';
 require_once '../gradebook/lib/be/category.class.php';
 /**
  * Get the number of courses which will be displayed
  */
-function get_number_of_courses()
-{
+function get_number_of_courses() {
 	$course_table = Database :: get_main_table(TABLE_MAIN_COURSE);
 	$sql = "SELECT COUNT(code) AS total_number_of_items FROM $course_table";
 
@@ -59,7 +54,7 @@ function get_number_of_courses()
     		$sql.= " AND url_rel_course.access_url_id=".api_get_current_access_url_id();
     }
 
-	$res = Database::query($sql, __FILE__, __LINE__);
+	$res = Database::query($sql);
 	$obj = Database::fetch_object($res);
 	return $obj->total_number_of_items;
 }
@@ -81,8 +76,8 @@ function get_course_data($from, $number_of_items, $column, $direction)
 
 	if (isset ($_GET['keyword']))
 	{
-		$keyword = Database::escape_string($_GET['keyword']);
-		$sql .= " WHERE (title LIKE '%".$keyword."%' OR code LIKE '%".$keyword."%' OR visual_code LIKE '%".$keyword."%')";
+		$keyword = Database::escape_string(trim($_GET['keyword']));
+		$sql .= " WHERE title LIKE '%".$keyword."%' OR code LIKE '%".$keyword."%' OR visual_code LIKE '%".$keyword."%'";
 	}
 	elseif (isset ($_GET['keyword_code']))
 	{
@@ -103,11 +98,10 @@ function get_course_data($from, $number_of_items, $column, $direction)
 
 	$sql .= " ORDER BY col$column $direction ";
 	$sql .= " LIMIT $from,$number_of_items";
-	$res = Database::query($sql, __FILE__, __LINE__);
+	$res = Database::query($sql);
 	$courses = array ();
 	while ($course = Database::fetch_row($res))
 	{
-		/** @todo this should be done using a filter in the sortable table like we did for the sortable table. Code has apparently been written by somebody who did not understand the sortable table */
 		//place colour icons in front of courses
 		//$course[1] = get_course_visibility_icon($course[9]).'<a href="'.api_get_path(WEB_COURSE_PATH).$course[9].'/index.php">'.$course[1].'</a>';
 		$course[1] = get_course_visibility_icon($course[9]).'<a href="'.api_get_path(WEB_COURSE_PATH).$course[8].'/index.php">'.$course[1].'</a>';
@@ -123,20 +117,18 @@ function get_course_data($from, $number_of_items, $column, $direction)
 /**
  * Filter to display the edit-buttons
  */
-function modify_filter($code,$url_params,$row)
+function modify_filter($code)
 {
 	global $charset;
 		return
 		'<a href="course_information.php?code='.$code.'">'.Display::return_icon('synthese_view.gif', get_lang('Info')).'</a>&nbsp;'.
-		// This is not the preferable way to go to the homepage. But for the moment the only one because the directory is not in the $row of the sortable table and
-		// visual code or code is not necessarily identical to $code
-		'<a href="../course_home/course_home.php?cidReq='.$code.'">'.Display::return_icon('course_home.gif', get_lang('CourseHomepage')).'</a>&nbsp;'. 
-		//'<a href="'.api_get_path(WEB_COURSE_PATH).$row[11].'/index.php">'.Display::return_icon('course_home.gif', get_lang('CourseHomepage')).'</a>&nbsp;'.
+		//'<a href="../course_home/course_home.php?cidReq='.$code.'">'.Display::return_icon('course_home.gif', get_lang('CourseHomepage')).'</a>&nbsp;'. // This is not the preferable way to go to the homepage.
+		'<a href="'.api_get_path(WEB_COURSE_PATH).$code.'/index.php">'.Display::return_icon('course_home.gif', get_lang('CourseHomepage')).'</a>&nbsp;'.
 		'<a href="../tracking/courseLog.php?cidReq='.$code.'">'.Display::return_icon('statistics.gif', get_lang('Tracking')).'</a>&nbsp;'.
 		'<a href="course_edit.php?course_code='.$code.'">'.Display::return_icon('edit.gif', get_lang('Edit')).'</a>&nbsp;'.
 		'<a href="course_list.php?delete_course='.$code.'"  onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset))."'".')) return false;">'.Display::return_icon('delete.gif', get_lang('Delete')).'</a>'.
 		'<a href="../coursecopy/backup.php?cidReq='.$code.'">'.Display::return_icon('backup.gif', get_lang('CreateBackup')).'</a>&nbsp;';
-	
+
 }
 /**
  * Return an icon representing the visibility of the course
@@ -183,8 +175,8 @@ if (isset ($_POST['action']))
 			break;
 	}
 }
-if (isset ($_GET['search']) && $_GET['search'] == 'advanced')
-{
+
+if (isset ($_GET['search']) && $_GET['search'] == 'advanced') {
 	// Get all course categories
 	$table_course_category = Database :: get_main_table(TABLE_MAIN_CATEGORY);
 	$interbreadcrumb[] = array ("url" => 'index.php', "name" => get_lang('PlatformAdmin'));
@@ -270,26 +262,27 @@ else
 	if (isset ($_GET['keyword'])) {
 		$parameters = array ('keyword' => Security::remove_XSS($_GET['keyword']));
 	} elseif (isset ($_GET['keyword_code'])) {
-		$parameters['keyword_code'] =  Security::remove_XSS($_GET['keyword_code']);
-	 	$parameters['keyword_title'] = Security::remove_XSS($_GET['keyword_title']);
-		$parameters['keyword_category'] = Security::remove_XSS($_GET['keyword_category']);
-		$parameters['keyword_language'] = Security::remove_XSS($_GET['keyword_language']);
-		$parameters['keyword_visibility'] = Security::remove_XSS($_GET['keyword_visibility']);
-		$parameters['keyword_subscribe'] = Security::remove_XSS($_GET['keyword_subscribe']);
-		$parameters['keyword_unsubscribe'] = Security::remove_XSS($_GET['keyword_unsubscribe']);
+		$parameters['keyword_code'] 		= Security::remove_XSS($_GET['keyword_code']);
+	 	$parameters['keyword_title'] 		= Security::remove_XSS($_GET['keyword_title']);
+		$parameters['keyword_category'] 	= Security::remove_XSS($_GET['keyword_category']);
+		$parameters['keyword_language'] 	= Security::remove_XSS($_GET['keyword_language']);
+		$parameters['keyword_visibility'] 	= Security::remove_XSS($_GET['keyword_visibility']);
+		$parameters['keyword_subscribe'] 	= Security::remove_XSS($_GET['keyword_subscribe']);
+		$parameters['keyword_unsubscribe'] 	= Security::remove_XSS($_GET['keyword_unsubscribe']);
 	}
 
 	$table->set_additional_parameters($parameters);
-	$table->set_header(0, '', false);
+	
+	$table->set_header(0, '', false, 'width="8px"');
 	$table->set_header(1, get_lang('Code'));
 	$table->set_header(2, get_lang('Title'));
-	$table->set_header(3, get_lang('Language'));
+	$table->set_header(3, get_lang('Language'), true, 'width="70px"');
 	$table->set_header(4, get_lang('Category'));
-	$table->set_header(5, get_lang('SubscriptionAllowed'));
+	$table->set_header(5, get_lang('SubscriptionAllowed'), true,'width="60px"');
 	$table->set_header(6, get_lang('UnsubscriptionAllowed'),false,'width="50px"');
 	//$table->set_header(7, get_lang('IsVirtualCourse'));
 	$table->set_header(7, get_lang('Teacher'));
-	$table->set_header(8, get_lang('Action'), false,'width="130px"');
+	$table->set_header(8, get_lang('Action'), false,'width="145px"');
 	$table->set_column_filter(8,'modify_filter');
 	$table->set_form_actions(array ('delete_courses' => get_lang('DeleteCourse')),'course');
 	$table->display();

+ 39 - 85
main/admin/course_user_import.php

@@ -31,7 +31,7 @@ function validate_data($users_courses) {
 				// 2.1.1 Check whether course with this code exists in the system.
 				$course_table = Database :: get_main_table(TABLE_MAIN_COURSE);
 				$sql = "SELECT * FROM $course_table WHERE code = '".Database::escape_string($user_course['CourseCode'])."'";
-				$res = Database::query($sql, __FILE__, __LINE__);
+				$res = Database::query($sql);
 				if (Database::num_rows($res) == 0) {
 					$user_course['error'] = get_lang('CodeDoesNotExists');
 					$errors[] = $user_course;
@@ -66,40 +66,24 @@ function save_data($users_courses) {
 	$user_table= Database::get_main_table(TABLE_MAIN_USER);
 	$course_user_table= Database::get_main_table(TABLE_MAIN_COURSE_USER);
 	$csv_data = array();
-	
 	foreach ($users_courses as $index => $user_course) {
 		$csv_data[$user_course['UserName']][$user_course['CourseCode']] = $user_course['Status'];
 	}
-	
 	foreach($csv_data as $username => $csv_subscriptions) {
-		
-		
 		$user_id = 0;
 		$sql = "SELECT * FROM $user_table u WHERE u.username = '".Database::escape_string($username)."'";
-		$res = Database::query($sql, __FILE__, __LINE__);
+		$res = Database::query($sql);
 		$obj = Database::fetch_object($res);
 		$user_id = $obj->user_id;
-		$to_subscribe = $to_unsubscribe = array();
-		
-		if ($_POST['subscribe']) {			
-			$sql = "SELECT * FROM $course_user_table WHERE user_id = $user_id ";
-			$res_suscribe = Database::query($sql, __FILE__, __LINE__);
-			$db_subscriptions = array();
-			while($obj_suscribe = Database::fetch_object($res_suscribe)) {			
-				$db_subscriptions[$obj_suscribe->course_code] = $obj_suscribe->user_id;
-			}
-			$to_subscribe = array_diff(array_keys($csv_subscriptions),array_keys($db_subscriptions));
+		$sql = "SELECT * FROM $course_user_table cu WHERE cu.user_id = $user_id AND cu.relation_type<>".COURSE_RELATION_TYPE_RRHH." ";
+		$res = Database::query($sql);
+		$db_subscriptions = array();
+		while($obj = Database::fetch_object($res)) {
+			$db_subscriptions[$obj->course_code] = $obj->status;
 		}
-	
-		if ($_POST['unsubscribe']) {
-			$sql = "SELECT * FROM $course_user_table WHERE user_id NOT IN ($user_id) ";
-			$res_unsubscribe = Database::query($sql, __FILE__, __LINE__);
-			$db_unsubscriptions = array();
-			while($obj_unsubscribe = Database::fetch_object($res_unsubscribe)) {			
-				$db_unsubscriptions[$obj_unsubscribe->course_code] = $obj_unsubscribe->user_id;
-			}
-			$to_unsubscribe = $db_unsubscriptions;				
-		} 
+
+		$to_subscribe = array_diff(array_keys($csv_subscriptions),array_keys($db_subscriptions));
+		$to_unsubscribe = array_diff(array_keys($db_subscriptions),array_keys($csv_subscriptions));
 
         global $inserted_in_course;
         if (!isset($inserted_in_course)) {
@@ -108,9 +92,8 @@ function save_data($users_courses) {
 		if($_POST['subscribe'])	{
 			foreach($to_subscribe as $index => $course_code) {
                 if(CourseManager :: course_exists($course_code)) {
-         
                     CourseManager::add_user_to_course($user_id,$course_code,$csv_subscriptions[$course_code]);
-                    $course_info = CourseManager::get_course_information($course_code);                    
+                    $course_info = CourseManager::get_course_information($course_code);
                     $inserted_in_course[$course_code] = $course_info['title'];
                 }
                 if (CourseManager :: course_exists($course_code,true)) {
@@ -125,12 +108,10 @@ function save_data($users_courses) {
                         }
                     }
                 }
-			}			
+			}
 		}
-		
 		if($_POST['unsubscribe']) {
-			
-			foreach($to_unsubscribe as $course_code => $user_id) {
+			foreach($to_unsubscribe as $index => $course_code) {
                 if(CourseManager :: course_exists($course_code)) {
                     CourseManager::unsubscribe_user($user_id,$course_code);
                     $course_info = CourseManager::get_course_information($course_code);
@@ -193,66 +174,39 @@ set_time_limit(0);
 // Creating the form.
 $form = new FormValidator('course_user_import');
 $form->addElement('header', '', $tool_name);
-$form->addElement('file', 'import_file', get_lang('ImportCSVFileLocation'));
+$form->addElement('file', 'import_file', get_lang('ImportFileLocation'));
 $form->addElement('checkbox', 'subscribe', get_lang('Action'), get_lang('SubscribeUserIfNotAllreadySubscribed'));
 $form->addElement('checkbox', 'unsubscribe', '', get_lang('UnsubscribeUserIfSubscriptionIsNotInFile'));
 $form->addElement('style_submit_button', 'submit',get_lang('Import'),'class="save"');
-
-$error_message = $message = '';
-$inserted_in_course = array();
-if ($form->validate() && $_FILES['import_file']['size'] !== 0) {
-	
-	
-	$allowed_file_mimetype = array('csv');
-	$ext_import_file = substr($_FILES['import_file']['name'],(strrpos($_FILES['import_file']['name'],'.')+1));
-	
-	if (!in_array($ext_import_file,$allowed_file_mimetype)) {
-		$error_message = get_lang('YouMustImportAFileAccordingToSelectedOption');
-	} else if (!isset($_POST['subscribe']) && !isset($_POST['unsubscribe'])) {
-		$error_message = get_lang('YouMustSelectAnAction');
-	} else {
-
-		$users_courses = parse_csv_data($_FILES['import_file']['tmp_name']);
-		$errors = validate_data($users_courses);
-
-		if (count($errors) == 0) {	        
-			save_data($users_courses);
-	        // Build the alert message in case there were visual codes subscribed to.
-	        $warn = '';
-	        if (count($inserted_in_course) > 1) {	        	
-	        	if ($_POST['subscribe']) {
-		            $warn = get_lang('UsersSubscribedToBecauseVisualCode').': ';
-		        } else {
-		            $warn = get_lang('UsersUnsubscribedFromBecauseVisualCode').': ';
-		        }	        	
-	        	// The users have been inserted in more than one course.
-	            foreach ($inserted_in_course as $code => $info) {
-	            	$warn .= ' '.$info.' ('.$code.'),';
-	            }
-	            $warn = substr($warn,0,-1);
-	        }
-	        
-	        Security::clear_token();
-	        $tok = Security::get_token();
-	        $message = get_lang('FileImported');
-			//header('Location: user_list.php?action=show_message&message='.urlencode(get_lang('FileImported')).'&warn='.urlencode($warn).'&sec_token='.$tok);
-			//exit ();
-		}
-	}	
+if ($form->validate()) {
+	$users_courses = parse_csv_data($_FILES['import_file']['tmp_name']);
+	$errors = validate_data($users_courses);
+	if (count($errors) == 0) {
+        $inserted_in_course = array();
+		save_data($users_courses);
+        // Build the alert message in case there were visual codes subscribed to.
+        if ($_POST['subscribe']) {
+            $warn = get_lang('UsersSubscribedToBecauseVisualCode').': ';
+        } else {
+            $warn = get_lang('UsersUnsubscribedFromBecauseVisualCode').': ';
+        }
+        if (count($inserted_in_course) > 1) {
+        	// The users have been inserted in more than one course.
+            foreach ($inserted_in_course as $code => $info) {
+            	$warn .= ' '.$info.' ('.$code.'),';
+            }
+            $warn = substr($warn,0,-1);
+        }
+        Security::clear_token();
+        $tok = Security::get_token();
+		header('Location: user_list.php?action=show_message&message='.urlencode(get_lang('FileImported')).'&warn='.urlencode($warn).'&sec_token='.$tok);
+		exit ();
+	}
 }
 
 // Displaying the header.
 Display :: display_header($tool_name);
 
-if (!empty($error_message)) {
-	Display :: display_error_message($error_message);
-} else if (!empty($message)) {	
-	if (!empty($warn)) {
-		Display :: display_warning_message($warn);
-	}
-	Display :: display_normal_message($message);
-}
-
 // Displaying the tool title.
 // api_display_tool_title($tool_name);
 
@@ -264,7 +218,7 @@ if (count($errors) != 0) {
 		$error_message .= '</li>';
 	}
 	$error_message .= '</ul>';
-	Display :: display_error_message($error_message,false);
+	Display :: display_error_message($error_message);
 }
 
 // Displaying the form.

+ 1 - 1
main/admin/course_virtual.php

@@ -225,7 +225,7 @@ function display_create_virtual_course_form()
 									FROM $category_table
 									WHERE auth_course_child ='TRUE'
 									ORDER BY tree_pos";
-			$category_result = Database::query($sql_query, __FILE__, __LINE__);
+			$category_result = Database::query($sql_query);
 
 			while ($current_category = Database::fetch_array($category_result))
 			{

+ 297 - 0
main/admin/dashboard_add_courses_to_user.php

@@ -0,0 +1,297 @@
+<?php
+/* For licensing terms, see /license.txt */
+
+/**
+==============================================================================
+*	Interface for assigning courses to Human Resources Manager
+*	@package chamilo.admin
+==============================================================================
+*/
+
+// name of the language file that needs to be included
+$language_file='admin';
+// resetting the course id
+$cidReset=true;
+
+// including some necessary dokeos files
+require_once '../inc/global.inc.php';
+require_once '../inc/lib/xajax/xajax.inc.php';
+require_once api_get_path(LIBRARY_PATH).'course.lib.php';
+require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
+
+// create an ajax object
+$xajax = new xajax();
+$xajax -> registerFunction ('search_courses');
+
+// setting the section (for the tabs)
+$this_section = SECTION_PLATFORM_ADMIN;
+
+// Access restrictions
+api_protect_admin_script(true);
+
+// setting breadcrumbs
+$interbreadcrumb[] = array('url' => 'index.php', 'name' => get_lang('PlatformAdmin'));
+$interbreadcrumb[] = array('url' => 'user_list.php','name' => get_lang('UserList'));
+
+// Database Table Definitions
+$tbl_course 			= 	Database::get_main_table(TABLE_MAIN_COURSE);
+$tbl_course_rel_user 	= 	Database::get_main_table(TABLE_MAIN_COURSE_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();
+
+// setting the name of the tool
+if (UserManager::is_admin($user_id)) {
+	$tool_name= get_lang('AssignCoursesToPlatformAdministrator');
+} else if ($user_info['status'] == SESSIONADMIN) {
+	$tool_name= get_lang('AssignCoursesToSessionsAdministrator');
+} else {
+	$tool_name= get_lang('AssignCoursesToHumanResourcesManager');
+}
+
+$add_type = 'multiple';
+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);
+}
+
+function search_courses($needle,$type) {
+	global $tbl_course, $tbl_course_rel_user, $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_setting('platform_charset');
+		$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).")";
+		}
+
+		$sql = "SELECT c.code, c.title FROM $tbl_course c
+				WHERE  c.code LIKE '$needle%' $without_assigned_courses ";
+		$rs	= Database::query($sql);
+
+		$return .= '<select id="origin" name="NoAssignedCoursesList[]" multiple="multiple" size="20" style="width:340px;">';
+		while($course = Database :: fetch_array($rs)) {
+			$return .= '<option value="'.$course['code'].'" title="'.htmlspecialchars($course['title'],ENT_QUOTES).'">'.$course['title'].' ('.$course['code'].')</option>';
+		}
+		$return .= '</select>';
+		$xajax_response -> addAssign('ajax_list_courses_multiple','innerHTML',api_utf8_encode($return));
+	}
+	return $xajax_response;
+}
+
+$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) {
+			destination.options[destination.length] = new Option(origin.options[i].text,origin.options[i].value);
+			origin.options[i]=null;
+			i = i-1;
+		}
+	}
+	destination.selectedIndex = -1;
+	sortOptions(destination.options);
+}
+function sortOptions(options) {
+	var newOptions = new Array();
+	for (i = 0 ; i<options.length ; i++) {
+		newOptions[i] = options[i];
+	}
+	newOptions = newOptions.sort(mysort);
+	options.length = 0;
+	for(i = 0 ; i < newOptions.length ; i++){
+		options[i] = newOptions[i];
+	}
+}
+function mysort(a, b) {
+	if (a.text.toLowerCase() > b.text.toLowerCase()) {
+		return 1;
+	}
+	if (a.text.toLowerCase() < b.text.toLowerCase()) {
+		return -1;
+	}
+	return 0;
+}
+
+function valide() {
+	var options = document.getElementById("destination").options;
+	for (i = 0 ; i<options.length ; i++) {
+		options[i].selected = true;
+	}
+	document.forms.formulaire.submit();
+}
+function remove_item(origin) {
+	for(var i = 0 ; i<origin.options.length ; i++) {
+		if(origin.options[i].selected) {
+			origin.options[i]=null;
+			i = i-1;
+		}
+	}
+}
+-->
+</script>';
+
+$formSent=0;
+$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');
+	}
+}
+
+// display header
+Display::display_header($tool_name);
+
+// actions
+echo '<div class="actions" style="height:22px;">
+<span style="float: right;margin:0px;padding:0px;">
+<a href="dashboard_add_users_to_user.php?user='.$user_id.'">'.Display::return_icon('add_user_big.gif', get_lang('AssignUsers'), array('style'=>'vertical-align:middle')).' '.get_lang('AssignUsers').'</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>
+<span style="vertical-align:middle">'.sprintf(get_lang('AssignCoursesToX'), api_get_person_name($user_info['firstname'], $user_info['lastname'])).'</span></div>';
+
+// *******************
+
+$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).")";
+}
+
+$needle = '%';
+if (isset($_POST['firstLetterCourse'])) {
+	$needle = Database::escape_string($_POST['firstLetterCourse']);
+	$needle = "$needle%";
+}
+
+$sql 	= " SELECT c.code, c.title FROM $tbl_course c
+			WHERE  c.code LIKE '$needle' $without_assigned_courses ";
+$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" />
+<?php
+if(!empty($msg)) {
+	Display::display_normal_message($msg); //main API
+}
+?>
+<table border="0" cellpadding="5" cellspacing="0" width="100%" align="center">
+<tr>
+	<td align="left"></td>
+	<td align="left"></td>
+	<td width="" align="center"> &nbsp;	</td>
+</tr>
+<tr>
+  <td width="45%" align="center"><b><?php echo get_lang('CoursesListInPlatform') ?> :</b></td>
+  <td width="10%">&nbsp;</td>
+  <td align="center" width="45%"><b>
+  	<?php   	
+	  	if (UserManager::is_admin($user_id)) {
+			echo get_lang('AssignedCoursesListToPlatformAdministrator');
+		} else if ($user_info['status'] == SESSIONADMIN) {
+			echo get_lang('AssignedCoursesListToSessionsAdministrator');		
+		} else {
+			echo get_lang('AssignedCoursesListToHumanResourcesManager');
+		}  	
+  	?> 
+  	:</b></td>
+</tr>
+
+<?php if($add_type == 'multiple') { ?>
+<tr><td width="45%" align="center">
+ <?php echo get_lang('FirstLetterCourse');?> :
+     <select name="firstLetterCourse" onchange = "xajax_search_course(this.value,'multiple')">
+      <option value="%">--</option>
+      <?php
+      echo Display :: get_alphabet_options($_POST['firstLetterCourse']);
+      ?>
+     </select>
+</td>
+<td>&nbsp;</td></tr>
+<?php } ?>
+<tr>
+  <td width="45%" align="center">
+	<div id="ajax_list_courses_multiple">
+	<select id="origin" name="NoAssignedCoursesList[]" multiple="multiple" size="20" style="width:340px;">
+	<?php
+	while ($enreg = Database::fetch_array($result)) {
+	?>
+		<option value="<?php echo $enreg['code']; ?>" <?php echo 'title="'.htmlspecialchars($enreg['title'],ENT_QUOTES).'"';?>><?php echo $enreg['title'].' ('.$enreg['code'].')'; ?></option>
+	<?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
+  }
+  ?>
+	<br /><br /><br /><br /><br /><br />
+	<?php
+		echo '<button class="save" type="button" value="" onclick="valide()" >'.$tool_name.'</button>';
+	?>
+  </td>
+  <td width="45%" align="center">
+  <select id='destination' name="CoursesList[]" multiple="multiple" size="20" style="width:320px;">
+	<?php
+	if (is_array($assigned_courses_to_hrm)) {
+		foreach($assigned_courses_to_hrm as $enreg) {
+	?>
+		<option value="<?php echo $enreg['code']; ?>" <?php echo 'title="'.htmlspecialchars($enreg['title'],ENT_QUOTES).'"'; ?>><?php echo $enreg['title'].' ('.$enreg['code'].')'; ?></option>
+	<?php }
+	}?>
+  </select></td>
+</tr>
+</table>
+
+</form>
+
+<?php
+/*
+==============================================================================
+		FOOTER
+==============================================================================
+*/
+Display::display_footer();
+?>

+ 295 - 0
main/admin/dashboard_add_sessions_to_user.php

@@ -0,0 +1,295 @@
+<?php
+/* For licensing terms, see /license.txt */
+
+/**
+==============================================================================
+*	Interface for assigning sessions to Human Resources Manager
+*	@package chamilo.admin
+==============================================================================
+*/
+
+// name of the language file that needs to be included
+$language_file='admin';
+// resetting the course id
+$cidReset=true;
+
+// including some necessary dokeos files
+require_once '../inc/global.inc.php';
+require_once api_get_path(LIBRARY_PATH).'xajax/xajax.inc.php';
+require_once api_get_path(LIBRARY_PATH).'sessionmanager.lib.php';
+require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
+
+// create an ajax object
+$xajax = new xajax();
+$xajax->registerFunction('search_sessions');
+
+// setting the section (for the tabs)
+$this_section = SECTION_PLATFORM_ADMIN;
+
+// Access restrictions
+api_protect_admin_script(true);
+
+// setting breadcrumbs
+$interbreadcrumb[] = array('url' => 'index.php', 'name' => get_lang('PlatformAdmin'));
+$interbreadcrumb[] = array('url' => 'user_list.php','name' => get_lang('UserList'));
+
+// Database Table Definitions
+$tbl_session 			= 	Database::get_main_table(TABLE_MAIN_SESSION);
+$tbl_session_rel_user 	= 	Database::get_main_table(TABLE_MAIN_SESSION_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();
+
+// setting the name of the tool
+if (UserManager::is_admin($user_id)) {
+	$tool_name= get_lang('AssignSessionsToPlatformAdministrator');
+} else if ($user_info['status'] == SESSIONADMIN) {
+	$tool_name= get_lang('AssignSessionsToSessionsAdministrator');
+} else {
+	$tool_name= get_lang('AssignSessionsToHumanResourcesManager');
+}
+
+$add_type = 'multiple';
+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);
+}
+
+function search_sessions($needle,$type) {
+	global $tbl_session, $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_setting('platform_charset');
+		$needle = api_convert_encoding($needle, $charset, 'utf-8');
+		$assigned_sessions_to_hrm = SessionManager::get_sessions_followed_by_drh($user_id);
+		$assigned_sessions_id = array_keys($assigned_sessions_to_hrm);
+
+		$without_assigned_sessions = '';
+		if (count($assigned_sessions_id) > 0) {
+			$without_assigned_sessions = " AND s.id NOT IN(".implode(',',$assigned_sessions_id).")";
+		}
+
+		$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>';
+		}
+		$return .= '</select>';
+		$xajax_response->addAssign('ajax_list_sessions_multiple','innerHTML',api_utf8_encode($return));
+	}
+	return $xajax_response;
+}
+
+$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) {
+			destination.options[destination.length] = new Option(origin.options[i].text,origin.options[i].value);
+			origin.options[i]=null;
+			i = i-1;
+		}
+	}
+	destination.selectedIndex = -1;
+	sortOptions(destination.options);
+}
+function sortOptions(options) {
+	var newOptions = new Array();
+	for (i = 0 ; i<options.length ; i++) {
+		newOptions[i] = options[i];
+	}
+	newOptions = newOptions.sort(mysort);
+	options.length = 0;
+	for(i = 0 ; i < newOptions.length ; i++){
+		options[i] = newOptions[i];
+	}
+}
+function mysort(a, b) {
+	if (a.text.toLowerCase() > b.text.toLowerCase()) {
+		return 1;
+	}
+	if (a.text.toLowerCase() < b.text.toLowerCase()) {
+		return -1;
+	}
+	return 0;
+}
+
+function valide() {
+	var options = document.getElementById("destination").options;
+	for (i = 0 ; i<options.length ; i++) {
+		options[i].selected = true;
+	}
+	document.forms.formulaire.submit();
+}
+function remove_item(origin) {
+	for(var i = 0 ; i<origin.options.length ; i++) {
+		if(origin.options[i].selected) {
+			origin.options[i]=null;
+			i = i-1;
+		}
+	}
+}
+-->
+</script>';
+
+$formSent=0;
+$errorMsg = $firstLetterSession = '';
+$UserList = array();
+
+$msg = '';
+if (intval($_POST['formSent']) == 1) {
+	$sessions_list = $_POST['SessionsList'];
+	$affected_rows = SessionManager::suscribe_sessions_to_hr_manager($user_id,$sessions_list);
+	if ($affected_rows)	{
+		$msg = get_lang('AssignedSessionsHaveBeenUpdatedSuccessfully');
+	}
+}
+
+// display header
+Display::display_header($tool_name);
+
+// actions
+echo '<div class="actions" style="height:22px;">';
+if ($user_info['status'] != SESSIONADMIN) {
+	echo 	'<span style="float: right;margin:0px;padding:0px;">
+				<a href="dashboard_add_users_to_user.php?user='.$user_id.'">'.Display::return_icon('add_user_big.gif', get_lang('AssignUsers'), array('style'=>'vertical-align:middle')).' '.get_lang('AssignUsers').'</a>
+				<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>
+			</span>
+			<span style="vertical-align:middle">'.sprintf(get_lang('AssignSessionsToX'),api_get_person_name($user_info['firstname'], $user_info['lastname'])).'</span>';
+} else {
+	echo '<span>'.sprintf(get_lang('AssignSessionsToX'),api_get_person_name($user_info['firstname'], $user_info['lastname'])).'</span>';
+}
+echo '</div>';
+
+// *******************
+
+$assigned_sessions_to_hrm = SessionManager::get_sessions_followed_by_drh($user_id);
+$assigned_sessions_id = array_keys($assigned_sessions_to_hrm);
+$without_assigned_sessions = '';
+if (count($assigned_sessions_id) > 0) {
+	$without_assigned_sessions = " AND s.id NOT IN(".implode(',',$assigned_sessions_id).")";
+}
+
+$needle = '%';
+if (isset($_POST['firstLetterSession'])) {
+	$needle = Database::escape_string($_POST['firstLetterSession']);
+	$needle = "$needle%";
+}
+
+$sql 	= " SELECT s.id, s.name FROM $tbl_session s
+			WHERE  s.name LIKE '$needle%' $without_assigned_sessions ";
+$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" />
+<?php
+if(!empty($msg)) {
+	Display::display_normal_message($msg); //main API
+}
+?>
+<table border="0" cellpadding="5" cellspacing="0" width="100%" align="center">
+<tr>
+	<td align="left"></td>
+	<td align="left"></td>
+	<td width="" align="center"> &nbsp;	</td>
+</tr>
+<tr>
+  <td width="45%" align="center"><b><?php echo get_lang('SessionsListInPlatform') ?> :</b></td>
+  <td width="10%">&nbsp;</td>
+  <td align="center" width="45%"><b>
+  <?php 
+  	if (UserManager::is_admin($user_id)) {
+		echo get_lang('AssignedSessionsListToPlatformAdministrator');
+	} else if ($user_info['status'] == SESSIONADMIN) {
+		echo get_lang('AssignedSessionsListToSessionsAdministrator');		
+	} else {
+		echo get_lang('AssignedSessionsListToHumanResourcesManager');
+	}   
+  ?> 
+  : </b></td>
+</tr>
+
+<?php if($add_type == 'multiple') { ?>
+<tr><td width="45%" align="center">
+ <?php echo get_lang('FirstLetterSession');?> :
+     <select name="firstLetterSession" onchange = "xajax_search_sessions(this.value, 'multiple')">
+      <option value="%">--</option>
+      <?php
+      echo Display :: get_alphabet_options($_POST['firstLetterSession']);
+      ?>
+     </select>
+</td>
+<td>&nbsp;</td></tr>
+<?php } ?>
+<tr>
+  <td width="45%" align="center">
+	<div id="ajax_list_sessions_multiple">
+	<select id="origin" name="NoAssignedSessionsList[]" multiple="multiple" size="20" style="width:340px;">
+	<?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>
+	<?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
+  }
+  ?>
+	<br /><br /><br /><br /><br /><br />
+	<?php
+		echo '<button class="save" type="button" value="" onclick="valide()" >'.$tool_name.'</button>';
+	?>
+  </td>
+  <td width="45%" align="center">
+  <select id='destination' name="SessionsList[]" multiple="multiple" size="20" style="width:320px;">
+	<?php
+	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>
+	<?php }
+	}?>
+  </select></td>
+</tr>
+</table>
+
+</form>
+
+<?php
+/*
+==============================================================================
+		FOOTER
+==============================================================================
+*/
+Display::display_footer();
+?>

+ 291 - 0
main/admin/dashboard_add_users_to_user.php

@@ -0,0 +1,291 @@
+<?php
+/* For licensing terms, see /license.txt */
+
+/**
+==============================================================================
+*	Interface for assigning users to Human Resources Manager
+*	@package chamilo.admin
+==============================================================================
+*/
+
+// name of the language file that needs to be included
+$language_file='admin';
+// resetting the course id
+$cidReset=true;
+
+// including some necessary dokeos files
+require_once '../inc/global.inc.php';
+require_once '../inc/lib/xajax/xajax.inc.php';
+require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
+
+// create an ajax object
+$xajax = new xajax();
+$xajax -> registerFunction ('search_users');
+
+// setting the section (for the tabs)
+$this_section = SECTION_PLATFORM_ADMIN;
+
+// Access restrictions
+api_protect_admin_script(true);
+
+// setting breadcrumbs
+$interbreadcrumb[] = array('url' => 'index.php', 'name' => get_lang('PlatformAdmin'));
+$interbreadcrumb[] = array('url' => 'user_list.php','name' => get_lang('UserList'));
+
+// Database Table Definitions
+$tbl_user 			= 	Database::get_main_table(TABLE_MAIN_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();
+
+// setting the name of the tool
+if (UserManager::is_admin($user_id)) {
+	$tool_name= get_lang('AssignUsersToPlatformAdministrator');
+} else if ($user_info['status'] == SESSIONADMIN) {
+	$tool_name= get_lang('AssignUsersToSessionsAdministrator');
+} else {
+	$tool_name= get_lang('AssignUsersToHumanResourcesManager');
+}
+
+$add_type = 'multiple';
+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);
+}
+
+function search_users($needle,$type) {
+	global $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_setting('platform_charset');
+		$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_id NOT IN(".implode(',',$assigned_users_id).")";
+		}
+
+		$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";
+		$rs	= Database::query($sql);
+
+		$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();
+$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) {
+			destination.options[destination.length] = new Option(origin.options[i].text,origin.options[i].value);
+			origin.options[i]=null;
+			i = i-1;
+		}
+	}
+	destination.selectedIndex = -1;
+	sortOptions(destination.options);
+}
+function sortOptions(options) {
+	var newOptions = new Array();
+	for (i = 0 ; i<options.length ; i++) {
+		newOptions[i] = options[i];
+	}
+	newOptions = newOptions.sort(mysort);
+	options.length = 0;
+	for(i = 0 ; i < newOptions.length ; i++){
+		options[i] = newOptions[i];
+	}
+}
+function mysort(a, b) {
+	if (a.text.toLowerCase() > b.text.toLowerCase()) {
+		return 1;
+	}
+	if (a.text.toLowerCase() < b.text.toLowerCase()) {
+		return -1;
+	}
+	return 0;
+}
+
+function valide() {
+	var options = document.getElementById("destination").options;
+	for (i = 0 ; i<options.length ; i++) {
+		options[i].selected = true;
+	}
+	document.forms.formulaire.submit();
+}
+function remove_item(origin) {
+	for(var i = 0 ; i<origin.options.length ; i++) {
+		if(origin.options[i].selected) {
+			origin.options[i]=null;
+			i = i-1;
+		}
+	}
+}
+-->
+</script>';
+
+$formSent=0;
+$errorMsg = $firstLetterUser = '';
+$UserList = array();
+
+$msg = '';
+if (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');
+	}
+}
+
+// display header
+Display::display_header($tool_name);
+
+// actions
+echo '<div class="actions" style="height:22px;">
+<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>
+<span style="vertical-align:middle">'.sprintf(get_lang('AssignUsersToX'), api_get_person_name($user_info['firstname'], $user_info['lastname'])).'</span></div>';	
+
+// *******************
+
+$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 = " user_id NOT IN(".implode(',',$assigned_users_id).") AND ";
+}
+
+$search_user = '';
+if (isset($_POST['firstLetterUser'])) {
+	$needle = Database::escape_string($_POST['firstLetterUser']);
+	$search_user ="AND ".(api_sort_by_first_name() ? 'firstname' : 'lastname')." LIKE '$needle%'";
+}
+
+$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 ";
+$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" />
+<?php
+if(!empty($msg)) {
+	Display::display_normal_message($msg); //main API
+}
+?>
+<table border="0" cellpadding="5" cellspacing="0" width="100%" align="center">
+<tr>
+	<td align="left"></td>
+	<td align="left"></td>
+	<td width="" align="center"> &nbsp;	</td>
+</tr>
+<tr>
+  <td width="45%" align="center"><b><?php echo get_lang('UserListInPlatform') ?> :</b></td>
+  <td width="10%">&nbsp;</td>
+  <td align="center" width="45%"><b>
+  <?php 
+	if (UserManager::is_admin($user_id)) {
+		echo get_lang('AssignedUsersListToPlatformAdministrator');
+	} else if ($user_info['status'] == SESSIONADMIN) {
+		echo get_lang('AssignedUsersListToSessionsAdministrator');		
+	} else {
+		echo get_lang('AssignedUsersListToHumanResourcesManager');
+	}
+  ?>
+   :</b></td>
+</tr>
+
+<?php if($add_type == 'multiple') { ?>
+<tr><td width="45%" align="center">
+ <?php echo get_lang('FirstLetterUser');?> :
+     <select name="firstLetterUser" onchange = "xajax_search_users(this.value,'multiple')">
+      <option value="%">--</option>
+      <?php
+      echo Display :: get_alphabet_options($_POST['firstLetterUser']);
+      ?>
+     </select>
+</td>
+<td>&nbsp;</td></tr>
+<?php } ?>
+<tr>
+  <td width="45%" align="center">
+	<div id="ajax_list_users_multiple">
+	<select id="origin" name="NoAssignedUsersList[]" multiple="multiple" size="20" style="width:340px;">
+	<?php
+	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>
+	<?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
+  }
+  ?>
+	<br /><br /><br /><br /><br /><br />
+	<?php
+		echo '<button class="save" type="button" value="" onclick="valide()" >'.$tool_name.'</button>';
+	?>
+  </td>
+  <td width="45%" align="center">
+  <select id='destination' name="UsersList[]" multiple="multiple" size="20" style="width:320px;">
+	<?php
+	if (is_array($assigned_users_to_hrm)) {
+		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>
+	<?php }
+	}?>
+  </select></td>
+</tr>
+</table>
+
+</form>
+
+<?php
+/*
+==============================================================================
+		FOOTER
+==============================================================================
+*/
+Display::display_footer();
+?>

+ 18 - 5
main/admin/group_add.php

@@ -7,7 +7,7 @@
 */
 
 // Language files that should be included
-$language_file = array('admin', 'registration');
+$language_file = array('admin', 'registration','userInfo');
 
 $cidReset = true;
 
@@ -26,6 +26,20 @@ $this_section = SECTION_PLATFORM_ADMIN;
 // User permissions
 api_protect_admin_script();
 
+$htmlHeadXtra[] = '<script type="text/javascript" src="/main/inc/lib/javascript/jquery.js"></script>';
+$htmlHeadXtra[] = '<script type="text/javascript">
+textarea = "";
+num_characters_permited = 255;
+function text_longitud(){
+   num_characters = document.forms[0].description.value.length;
+  if (num_characters > num_characters_permited){
+      document.forms[0].description.value = textarea;
+   }else{
+      textarea = document.forms[0].description.value;
+   } 
+} 
+</script>';
+
 // Database table definitions
 $table_admin 	= Database :: get_main_table(TABLE_MAIN_ADMIN);
 $table_user 	= Database :: get_main_table(TABLE_MAIN_USER);
@@ -43,19 +57,18 @@ $form = new FormValidator('group_add');
 $form->addElement('header', '', $tool_name);
 
 // name
-$form->addElement('text', 'name', get_lang('Name'));
+$form->addElement('text', 'name', get_lang('Name'), array('size'=>60, 'maxlength'=>120));
 $form->applyFilter('name', 'html_filter');
 $form->applyFilter('name', 'trim');
 $form->addRule('name', get_lang('ThisFieldIsRequired'), 'required');
 
 // Description
-$form->addElement('text', 'description', get_lang('Description'));
+$form->addElement('textarea', 'description', get_lang('Description'), array('rows'=>3, 'cols'=>58, onKeyDown => "text_longitud()", onKeyUp => "text_longitud()"));
 $form->applyFilter('description', 'html_filter');
 $form->applyFilter('description', 'trim');
 
-
 // url
-$form->addElement('text', 'url', get_lang('URL'));
+$form->addElement('text', 'url', get_lang('URL'), array('size'=>35));
 $form->applyFilter('url', 'html_filter');
 $form->applyFilter('url', 'trim');
 

+ 24 - 11
main/admin/group_edit.php

@@ -6,7 +6,7 @@
 ==============================================================================
 */
 // Language files that should be included
-$language_file = array('admin');
+$language_file = array('admin','userInfo');
 $cidReset = true;
 include '../inc/global.inc.php';
 $this_section = SECTION_PLATFORM_ADMIN;
@@ -28,8 +28,22 @@ $interbreadcrumb[] = array('url' => 'group_list.php','name' => get_lang('GroupLi
 
 $table_group = Database::get_main_table(TABLE_MAIN_GROUP);
 
+$htmlHeadXtra[] = '<script type="text/javascript" src="/main/inc/lib/javascript/jquery.js"></script>';
+$htmlHeadXtra[] = '<script type="text/javascript">
+textarea = "";
+num_characters_permited = 255;
+function text_longitud(){
+   num_characters = document.forms[0].description.value.length;
+  if (num_characters > num_characters_permited){
+      document.forms[0].description.value = textarea;
+   }else{
+      textarea = document.forms[0].description.value;
+   }
+}
+</script>';
+
 $sql = "SELECT * FROM $table_group WHERE id = '".$group_id."'";
-$res = Database::query($sql, __FILE__, __LINE__);
+$res = Database::query($sql);
 if (Database::num_rows($res) != 1) {
 	header('Location: group_list.php');
 	exit;
@@ -43,21 +57,20 @@ $form->addElement('header', '', $tool_name);
 $form->addElement('hidden', 'id', $group_id);
 
 // name
-$form->addElement('text', 'name', get_lang('Name'));
+$form->addElement('text', 'name', get_lang('Name'), array('size'=>60, 'maxlength'=>120));
 $form->applyFilter('name', 'html_filter');
 $form->applyFilter('name', 'trim');
 $form->addRule('name', get_lang('ThisFieldIsRequired'), 'required');
 
 // Description
-$form->addElement('text', 'description', get_lang('Description'));
+$form->addElement('textarea', 'description', get_lang('Description'), array('rows'=>3, 'cols'=>58, onKeyDown => "text_longitud()", onKeyUp => "text_longitud()"));
 $form->applyFilter('description', 'html_filter');
 $form->applyFilter('description', 'trim');
 
 // url
-$form->addElement('text', 'url', get_lang('URL'));
+$form->addElement('text', 'url', get_lang('URL'), array('size'=>35));
 $form->applyFilter('url', 'html_filter');
 $form->applyFilter('url', 'trim');
-
 // Picture
 $form->addElement('file', 'picture', get_lang('AddPicture'));
 $allowed_picture_types = array ('jpg', 'jpeg', 'png', 'gif');
@@ -83,7 +96,7 @@ $form->setDefaults($group_data);
 // Validate form
 if ( $form->validate()) {
 	$group = $form->exportValues();
-	
+
 	$picture_element = & $form->getElement('picture');
 	$picture = $picture_element->getValue();
 
@@ -94,13 +107,13 @@ if ( $form->validate()) {
 	elseif (!empty($picture['name'])) {
 		$picture_uri = GroupPortalManager::update_group_picture($group_id, $_FILES['picture']['name'], $_FILES['picture']['tmp_name']);
 	}
-	
+
 	$name 			= $group['name'];
 	$description	= $group['description'];
-	$url 			= $group['url'];	
+	$url 			= $group['url'];
 	$status 		= intval($group['visibility']);
-	
-	GroupPortalManager::update($group_id, $name, $description, $url, $status, $picture_uri);	
+
+	GroupPortalManager::update($group_id, $name, $description, $url, $status, $picture_uri);
 	$tok = Security::get_token();
 	header('Location: group_list.php?action=show_message&message='.urlencode(get_lang('GroupUpdated')).'&sec_token='.$tok);
 	exit();

+ 44 - 50
main/admin/group_list.php

@@ -8,7 +8,7 @@
 */
 
 // name of the language file that needs to be included
-$language_file = array ('registration','admin');
+$language_file = array ('registration','admin','userInfo');
 $cidReset = true;
 require ('../inc/global.inc.php');
 require_once (api_get_path(LIBRARY_PATH).'sortabletable.class.php');
@@ -40,8 +40,8 @@ function get_number_of_groups()
     }
 */
 	if ( isset ($_GET['keyword'])) {
-		$keyword = Database::escape_string($_GET['keyword']);
-		$sql .= " WHERE (g.name LIKE '%".$keyword."%' OR g.description LIKE '%".$keyword."%'  OR  g.url LIKE '%".$keyword."%' )";	
+		$keyword = Database::escape_string(trim($_GET['keyword']));
+		$sql .= " WHERE (g.name LIKE '%".$keyword."%' OR g.description LIKE '%".$keyword."%'  OR  g.url LIKE '%".$keyword."%' )";
 	}
 
     // adding the filter to see the user's only of the current access_url
@@ -50,7 +50,7 @@ function get_number_of_groups()
     		$sql.= " AND url_rel_user.access_url_id=".api_get_current_access_url_id();
     }*/
 
-	$res = Database::query($sql, __FILE__, __LINE__);
+	$res = Database::query($sql);
 	$obj = Database::fetch_object($res);
 	return $obj->total_number_of_items;
 }
@@ -65,10 +65,10 @@ function get_number_of_groups()
 function get_group_data($from, $number_of_items, $column, $direction)
 {
 	$group_table = Database :: get_main_table(TABLE_MAIN_GROUP);
-	
+
 	$sql = "SELECT
                  g.id			AS col0,
-                 g.name			AS col1,                 
+                 g.name			AS col1,
                  g.description 	AS col2,
                  g.visibility 	AS col3,
                  g.id			AS col4
@@ -82,9 +82,9 @@ function get_group_data($from, $number_of_items, $column, $direction)
     }*/
 
 	if (isset ($_GET['keyword'])) {
-		$keyword = Database::escape_string($_GET['keyword']);
+		$keyword = Database::escape_string(trim($_GET['keyword']));
 		$sql .= " WHERE (g.name LIKE '%".$keyword."%' OR g.description LIKE '%".$keyword."%'  OR  g.url LIKE '%".$keyword."%' )";
-	} 
+	}
 	/*
     // adding the filter to see the user's only of the current access_url
 	if ((api_is_platform_admin() || api_is_session_admin()) && $_configuration['multiple_access_urls']==true && api_get_current_access_url_id()!=-1) {
@@ -101,12 +101,19 @@ function get_group_data($from, $number_of_items, $column, $direction)
 	$sql .= " ORDER BY col$column $direction ";
 	$sql .= " LIMIT $from,$number_of_items";
 
-	$res = Database::query($sql, __FILE__, __LINE__);
+	$res = Database::query($sql);
 
 	$users = array ();
     $t = time();
-	while ($group = Database::fetch_row($res)) {		
-		$group['1'] = '<a href="/main/social/groups.php?id='.$group['0'].'">'.$group['1'].'</a>';      
+
+    // Status
+	$status = array();
+	$status[GROUP_PERMISSION_OPEN] 		= get_lang('Open');
+	$status[GROUP_PERMISSION_CLOSED]	= get_lang('Closed');
+
+	while ($group = Database::fetch_row($res)) {
+		$group[3] = $status[$group[3]];
+		$group['1'] = '<a href="'.api_get_path(WEB_CODE_PATH).'social/groups.php?id='.$group['0'].'">'.$group['1'].'</a>';
         $groups[] = $group;
 	}
 	return $groups;
@@ -116,10 +123,10 @@ function get_group_data($from, $number_of_items, $column, $direction)
 function get_recent_group_data($from =0 , $number_of_items = 5, $column, $direction)
 {
 	$group_table = Database :: get_main_table(TABLE_MAIN_GROUP);
-	
+
 	$sql = "SELECT
                  g.id			AS col0,
-                 g.name			AS col1,                 
+                 g.name			AS col1,
                  g.description 	AS col2,
                  g.visibility 	AS col3,
                  g.id			AS col4
@@ -133,9 +140,9 @@ function get_recent_group_data($from =0 , $number_of_items = 5, $column, $direct
     }*/
 
 	if (isset ($_GET['keyword'])) {
-		$keyword = Database::escape_string($_GET['keyword']);
+		$keyword = Database::escape_string(trim($_GET['keyword']));
 		$sql .= " WHERE (g.name LIKE '%".$keyword."%' OR g.description LIKE '%".$keyword."%'  OR  g.url LIKE '%".$keyword."%' )";
-	} 
+	}
 	/*
     // adding the filter to see the user's only of the current access_url
 	if ((api_is_platform_admin() || api_is_session_admin()) && $_configuration['multiple_access_urls']==true && api_get_current_access_url_id()!=-1) {
@@ -152,12 +159,12 @@ function get_recent_group_data($from =0 , $number_of_items = 5, $column, $direct
 	$sql .= " ORDER BY col$column $direction ";
 	$sql .= " LIMIT $from,$number_of_items";
 
-	$res = Database::query($sql, __FILE__, __LINE__);
+	$res = Database::query($sql);
 
 	$users = array ();
     $t = time();
 	while ($group = Database::fetch_row($res)) {
-        // forget about the expiration date field		      
+        // forget about the expiration date field
         $groups[] = $group;
 	}
 	return $groups;
@@ -240,7 +247,7 @@ function lock_unlock_user($status,$user_id)
 	if(($status_db=='1' OR $status_db=='0') AND is_numeric($user_id))
 	{
 		$sql="UPDATE $user_table SET active='".Database::escape_string($status_db)."' WHERE user_id='".Database::escape_string($user_id)."'";
-		$result = Database::query($sql, __FILE__, __LINE__);
+		$result = Database::query($sql);
 	}
 
 	if ($result)
@@ -274,7 +281,7 @@ $action = $_GET["action"];
 
 if (isset ($_GET['search']) && $_GET['search'] == 'advanced') {
 	$interbreadcrumb[] = array ("url" => 'index.php', "name" => get_lang('PlatformAdmin'));
-	$interbreadcrumb[] = array ("url" => 'user_list.php', "name" => get_lang('UserList'));
+	$interbreadcrumb[] = array ("url" => 'group_list.php', "name" => get_lang('GroupList'));
 	$tool_name = get_lang('SearchAUser');
 	Display :: display_header($tool_name);
 	//api_display_tool_title($tool_name);
@@ -304,7 +311,7 @@ if (isset ($_GET['search']) && $_GET['search'] == 'advanced') {
 else
 {
 	$interbreadcrumb[] = array ("url" => 'index.php', "name" => get_lang('PlatformAdmin'));
-	$tool_name = get_lang('UserList');
+	$tool_name = get_lang('GroupList');
 	Display :: display_header($tool_name, "");
 
 	//api_display_tool_title($tool_name);
@@ -317,7 +324,7 @@ else
                     	// to prevent too long messages
                     	if ($_GET['warn'] == 'session_message'){
                     		$_GET['warn'] = $_SESSION['session_message_import_users'];
-                    	} 
+                    	}
                     	Display::display_warning_message(urldecode($_GET['warn']),false);
                     }
                     if (!empty($_GET['message'])) {
@@ -346,37 +353,24 @@ else
 			Security::clear_token();
 		}
 	}
-	if (isset ($_POST['action']))
-	{
+	if (isset ($_POST['action'])) {
 		$check = Security::check_token('get');
-		if($check)
-		{
-			switch ($_POST['action'])
-			{
+		if ($check) {
+			switch ($_POST['action']) {
 				case 'delete' :
 					if (api_is_platform_admin()) {
-						$number_of_selected_users = count($_POST['id']);
-						$number_of_deleted_users = 0;
-						if (is_array($_POST['id'])) {
-							foreach ($_POST['id'] as $index => $user_id)
-							{
-								if($user_id != $_user['user_id'])
-								{
-									if(UserManager :: delete_user($user_id))
-									{
-										$number_of_deleted_users++;
-									}
-								}
+						$number_of_selected_groups = count($_POST['id']);
+						$number_of_deleted_groups = 0;
+						foreach ($_POST['id'] as $index => $group_id) {
+							if (GroupPortalManager :: delete($group_id)) {
+								$number_of_deleted_groups++;
 							}
 						}
-						if($number_of_selected_users == $number_of_deleted_users)
-						{
-							Display :: display_confirmation_message(get_lang('SelectedUsersDeleted'));
-						}
-						else
-						{
-							Display :: display_error_message(get_lang('SomeUsersNotDeleted'));
-						}
+					}
+					if ($number_of_selected_groups == $number_of_deleted_groups) {
+						Display :: display_confirmation_message(get_lang('SelectedGroupsDeleted'));
+					} else {
+						Display :: display_error_message(get_lang('SomeGroupsNotDeleted'));
 					}
 					break;
 			}
@@ -393,7 +387,7 @@ else
 	echo '<div class="actions" style="width:100%;">';
 	if (api_is_platform_admin()) {
 		echo '<span style="float:right; padding-top:7px;">'.
-			 '<a href="'.api_get_path(WEB_CODE_PATH).'admin/group_add.php">'.Display::return_icon('add_user_big.gif',get_lang('AddUsers')).get_lang('AddGroups').'</a>'.			 
+			 '<a href="'.api_get_path(WEB_CODE_PATH).'admin/group_add.php">'.Display::return_icon('groupadd.gif',get_lang('AddGroups')).get_lang('AddGroups').'</a>'.
 			 '</span>';
 	}
 	$form->display();
@@ -413,13 +407,13 @@ else
 		$_admins_list[] = $row_admin[0];
 	}
 
-	$table = new SortableTable('users', 'get_number_of_groups', 'get_group_data', 2);
+	$table = new SortableTable('group_list', 'get_number_of_groups', 'get_group_data', 2);
 	$table->set_additional_parameters($parameters);
 	$table->set_header(0, '', false);
 	$table->set_header(1, get_lang('Name'));
 	$table->set_header(2, get_lang('Description'));
 	$table->set_header(3, get_lang('Visibility'));
-	$table->set_header(4, '', false);	
+	$table->set_header(4, '', false);
 	$table->set_column_filter(4, 'modify_filter');
 	//$table->set_column_filter(6, 'status_filter');
 	//$table->set_column_filter(7, 'active_filter');

+ 71 - 68
main/admin/index.php

@@ -1,11 +1,9 @@
 <?php // $Id: index.php 22269 2009-07-21 15:06:15Z juliomontoya $
-/* For licensing terms, see /dokeos_license.txt */
+/* For licensing terms, see /license.txt */
 /**
-==============================================================================
 *	Index of the admin tools
 *
-*	@package dokeos.admin
-==============================================================================
+*	@package chamilo.admin
 */
 // name of the language file that needs to be included <br />
 $language_file=array('admin','tracking');
@@ -13,9 +11,9 @@ $language_file=array('admin','tracking');
 // resetting the course id
 $cidReset=true;
 
-// including some necessary dokeos files
-require('../inc/global.inc.php');
-require_once(api_get_path(LIBRARY_PATH).'security.lib.php');
+// including some necessary chamilo files
+require_once '../inc/global.inc.php';
+require_once api_get_path(LIBRARY_PATH).'security.lib.php';
 
 // setting the section (for the tabs)
 $this_section=SECTION_PLATFORM_ADMIN;
@@ -34,8 +32,7 @@ $tool_name=get_lang('PlatformAdmin');
 Display::display_header($nameTools);
 
 
-if(api_is_platform_admin())
-{
+if(api_is_platform_admin()) {
 	if(is_dir(api_get_path(SYS_CODE_PATH).'install/') && is_readable(api_get_path(SYS_CODE_PATH).'install/index.php'))
 	{
 		Display::display_normal_message(get_lang('InstallDirAccessibleSecurityThreat'));
@@ -63,32 +60,33 @@ if (api_is_platform_admin()) {
 	?>
 		<div class="admin_section">
 	<h4><?php Display::display_icon('members.gif', get_lang('Users')); ?> <?php echo api_ucfirst(get_lang('Users')); ?></h4>
-	<ul>
-		<li style="list-style-type:none"><form method="get" action="user_list.php">
+
+		<div style="list-style-type:none"><form method="get" action="user_list.php">
 			<input type="text" name="keyword" value="<?php echo $keyword_url; ?>"/>
 			<button class="search" type="submit"> <?php echo get_lang('Search');?>
 			</button>
 			</form>
-		</li>
-		<li><a href="user_list.php?search=advanced"><?php echo api_ucfirst(get_lang('AdvancedSearch')); ?></a></li>
+		</div>
+	<ul>
+		<!-- <li><a href="user_list.php?search=advanced"><?php echo api_ucfirst(get_lang('AdvancedSearch')); ?></a></li> -->
 		<li><a href="user_list.php">	<?php echo get_lang('UserList') ?></a></li>
 		<li><a href="user_add.php">		<?php echo get_lang('AddUsers') ?></a></li>
 		<li><a href="user_export.php">	<?php echo get_lang('ExportUserListXMLCSV') ?></a></li>
 		<li><a href="user_import.php">	<?php echo get_lang('ImportUserListXMLCSV') ?></a></li>
 		<?php if (api_get_setting('allow_social_tool')=='true') { ?>
-			<li><a href="group_add.php">	<?php echo get_lang('AddGroups') ?></a></li>  
-			<li><a href="group_list.php">	<?php echo get_lang('GroupList') ?></a></li>		
+			<li><a href="group_add.php">	<?php echo get_lang('AddGroups') ?></a></li>
+			<li><a href="group_list.php">	<?php echo get_lang('GroupList') ?></a></li>
 		<?php
 		}
 		if(isset($extAuthSource) && isset($extAuthSource['ldap']) && count($extAuthSource['ldap'])>0){
 			?>
 			<!-- dynamic ldap code -->
-			  <li><a href="ldap_users_list.php"><?php echo get_lang('ImportLDAPUsersIntoPlatform');?></a></li> 
+			  <li><a href="ldap_users_list.php"><?php echo get_lang('ImportLDAPUsersIntoPlatform');?></a></li>
 			<!-- dynamic ldap code -->
 			<?php
 			}
 		?>
-		<li><a href="user_fields.php">	<?php echo get_lang('ManageUserFields'); ?></a></li>	
+		<li><a href="user_fields.php">	<?php echo get_lang('ManageUserFields'); ?></a></li>
 		</ul>
 		</div>
 <?php
@@ -112,19 +110,22 @@ if(api_is_platform_admin()) {
 ?>
 	<div class="admin_section">
 <h4><?php Display::display_icon('course.gif', get_lang('Courses')); ?> <?php echo api_ucfirst(get_lang('Courses')); ?></h4>
-		<ul><li style="list-style-type:none"><form method="get" action="course_list.php">
+		<div style="list-style-type:none"><form method="get" action="course_list.php">
 		<input type="text" name="keyword" value="<?php echo $keyword_url; ?>"/>
 		<button class="search" type="submit"> <?php echo get_lang('Search');?>
 			</button>
-		</form></li>
+		</form></div>
+
+
+		<ul>
 		<li>
-		<a href="course_list.php?search=advanced"><?php echo api_ucfirst(get_lang('AdvancedSearch')); ?></a>
+		<!-- <a href="course_list.php?search=advanced"><?php echo api_ucfirst(get_lang('AdvancedSearch')); ?></a> -->
 
 	</li>
 	<li><a href="course_list.php"><?php echo get_lang('CourseList') ?></a></li>
 	<li><a href="course_add.php"><?php echo get_lang('AddCourse') ?></a></li>
 	<li><a href="course_export.php"><?php echo get_lang('ExportCourses'); ?></a></li>
-	<li><a href="course_import.php"><?php echo get_lang('ImportCourses'); ?></a></li>	
+	<li><a href="course_import.php"><?php echo get_lang('ImportCourses'); ?></a></li>
 	<!--<li><a href="course_virtual.php"><?php //echo get_lang('AdminManageVirtualCourses') ?></a></li>-->
 	<li><a href="course_category.php"><?php echo get_lang('AdminCategories'); ?></a></li>
 	<li><a href="subscribe_user2course.php"><?php echo get_lang('AddUsersToACourse'); ?></a></li>
@@ -141,7 +142,7 @@ if(api_is_platform_admin()) {
 		<?php
 		}
 	?>
-	
+
 	</ul>
 	</div>
 
@@ -154,7 +155,7 @@ if(api_is_platform_admin()) {
 	  <li><a href="languages.php"><?php echo get_lang('Languages'); ?></a></li>
 	  <li><a href="configure_homepage.php"><?php echo get_lang('ConfigureHomePage'); ?></a></li>
 	  <li><a href="configure_inscription.php"><?php echo get_lang('ConfigureInscription'); ?></a></li>
-	  <li><a href="statistics/index.php"><?php echo get_lang('ToolName'); ?> </a></li>
+	  <li><a href="statistics/index.php"><?php echo get_lang('Statistics'); ?> </a></li>
 	  <li><a href="calendar.php"><?php echo get_lang('GlobalAgenda'); ?> </a></li>
 	  <?php if(!empty($phpMyAdminPath)) { ?>
 	  <li><a href="<?php echo $phpMyAdminPath; ?>" target="_blank"><?php echo get_lang("AdminDatabases"); ?></a><br />(<?php echo get_lang("DBManagementOnlyForServerAdmin"); ?>)</li>
@@ -172,6 +173,10 @@ if(api_is_platform_admin()) {
   	  if (api_get_setting('allow_terms_conditions')=='true') {
 		  	echo '<li><a href="legal_add.php">'.get_lang('TermsAndConditions').'</a></li>';
 	  }
+	  
+	  //@todo Translations needed in order to see a better explanation of issues
+	  echo '<li><a href="system_status.php">'.get_lang('SystemStatus').'</a></li>';
+	  
 
 	  ?>
 	 </ul>
@@ -186,14 +191,15 @@ if(api_get_setting('use_session_mode')=='true')
 
 <div class="admin_section">
  <h4><?php Display::display_icon('agenda.gif', get_lang('Sessions')); ?> <?php echo get_lang('Sessions') ?></h4>
- <ul>
- <li style="list-style-type:none"><form method="POST" action="session_list.php">
+ <div style="list-style-type:none"><form method="POST" action="session_list.php">
 	<input type="text" name="keyword_name" value="<?php echo $keyword_url; ?>"/>
 	<button class="search" type="submit"> <?php echo get_lang('Search');?>
 			</button>
 	</form>
-</li>
-  <li><a href="session_list.php?search=advanced"><?php echo api_ucfirst(get_lang('AdvancedSearch')); ?></a></li>
+</div>
+
+ <ul>
+  <!--  <li><a href="session_list.php?search=advanced"><?php echo api_ucfirst(get_lang('AdvancedSearch')); ?></a></li> -->
   <li><a href="session_list.php"><?php echo get_lang('ListSession') ?></a></li>
   <li><a href="session_category_list.php"><?php echo get_lang('ListSessionCategory') ?></a></li>
   <li><a href="session_add.php"><?php echo get_lang('AddSession') ?></a></li>
@@ -220,13 +226,13 @@ else if(api_is_platform_admin())
 
 <div class="admin_section">
 <h4><?php Display::display_icon('group.gif', get_lang('AdminClasses')); ?> <?php echo api_ucfirst(get_lang('AdminClasses')); ?></h4>
-<ul>
-<li style="list-style-type:none"><form method="get" action="class_list.php">
+<div style="list-style-type:none"><form method="get" action="class_list.php">
 
 	<input type="text" name="keyword" value="<?php echo $keyword_url; ?>"/>
 	<input class="search" type="submit" value="<?php echo get_lang('Search'); ?>"/>
 	</form>
-</li>
+</div>
+<ul>
 <li><a href="class_list.php"><?php echo get_lang('ClassList'); ?></a></li>
 <li><a href="class_add.php"><?php echo get_lang('AddClasses'); ?></a></li>
 <li><a href="class_import.php"><?php echo get_lang('ImportClassListCSV'); ?></a></li>
@@ -273,20 +279,19 @@ if(api_is_platform_admin()){
 	}*/
 ?>
 <div class="admin_section">
- <h4><?php Display::display_icon('dokeos.gif', 'Dokeos'); ?> Dokeos.com</h4>
+ <h4><?php Display::display_icon('logo.gif', 'Chamilo'); ?> Chamilo.org</h4>
  <ul>
-  <li><a href="http://www.dokeos.com/" target="_blank"><?php echo get_lang('DokeosHomepage'); ?></a></li>
-  <li><a href="http://www.dokeos.com/forum/" target="_blank"><?php echo get_lang('DokeosForum'); ?></a></li>
-  <li><a href="http://www.dokeos.com/extensions/" target="_blank"><?php echo get_lang('DokeosExtensions'); ?></a></li>
-  <li>
+  <li><a href="http://www.chamilo.org/" target="_blank"><?php echo get_lang('ChamiloHomepage'); ?></a></li>
+  <li><a href="http://forum.chamilo.org/" target="_blank"><?php echo get_lang('ChamiloForum'); ?></a></li>
+  <li><a href="http://www.chamilo.org/extensions" target="_blank"><?php echo get_lang('ChamiloExtensions'); ?></a></li>
+
   <?php
-  //try to display a maximum before we check the dokeos version and all that
+  //try to display a maximum before we check the chamilo version and all that
   	//session_write_close(); //close session to avoid blocking concurrent access
 	flush(); //send data to client as much as allowed by the web server
 	//ob_flush();
-	echo get_lang('VersionCheck').': '.version_check();
+	echo '<br />'.get_lang('VersionCheck').': '.version_check().'';
   ?>
-  </li>
  </ul>
 </div>
 <?php
@@ -304,7 +309,7 @@ function version_check()
 {
 	$tbl_settings = Database :: get_main_table(TABLE_MAIN_SETTINGS_CURRENT);
 	$sql = 'SELECT selected_value FROM  '.$tbl_settings.' WHERE variable="registered" ';
-	$result = Database::query($sql,__FILE__,__LINE__);
+	$result = Database::query($sql);
 	$row=Database::fetch_array($result,'ASSOC');
 
 	// The site has not been registered yet
@@ -325,7 +330,7 @@ function version_check()
 		/*
 		if ((api_get_setting('registered') + 15552000) > mktime())
 		{
-			$return = 'It has been a long time since about your campus has been updated on Dokeos.com';
+			$return = 'It has been a long time since about your campus has been updated on chamilo.org';
 			$return .= '<form action="'.api_get_self().'" id="VersionCheck" name="VersionCheck" method="post">';
 			$return .= '<input type="submit" name="Register" value="Enable Version Check" id="register" />';
 			$return .= '</form>';
@@ -334,7 +339,7 @@ function version_check()
 		{
 		*/
 		$return = 'site registered. ';
-		$return .= check_dokeos_version2();
+		$return .= check_system_version2();
 		//}
 	}
 	return $return;
@@ -355,13 +360,13 @@ function register_site()
 
 	// the SQL statment
 	$sql = "UPDATE $tbl_settings SET selected_value='true' WHERE variable='registered'";
-	$result = Database::query($sql,__FILE__,__LINE__);
+	$result = Database::query($sql);
 
 	//
 	if ($_POST['donotlistcampus'])
 	{
 		$sql = "UPDATE $tbl_settings SET selected_value='true' WHERE variable='donotlistcampus'";
-		$result = Database::query($sql,__FILE__,__LINE__);
+		$result = Database::query($sql);
 	}
 
 	// reload the settings
@@ -375,36 +380,37 @@ function register_site()
 * @copyright (C) 2001 The phpBB Group
 * @return language string with some layout (color)
 */
-function check_dokeos_version2()
+function check_system_version2()
 {
 	global $_configuration;
-	$dokeos_version = trim($_configuration['dokeos_version']); // the dokeos version of your installation
+	$system_version = trim($_configuration['system_version']); // the chamilo version of your installation
 
 	if (ini_get('allow_url_fopen')==1)
 	{
 		// the number of courses
 		$sql="SELECT count(code) FROM ".Database::get_main_table(TABLE_MAIN_COURSE);
-		$result=Database::query($sql,__FILE__,__LINE__);
+		$result=Database::query($sql);
 		$row = Database::fetch_array($result);
 		$number_of_courses = $row[0];
 
 		// the number of users
 		$sql="SELECT count(user_id) FROM ".Database::get_main_table(TABLE_MAIN_USER);
-		$result=Database::query($sql,__FILE__,__LINE__);
+		$result=Database::query($sql);
 		$row = Database::fetch_array($result);
 		$number_of_users = $row[0];
 
-		$version_url= 'http://www.dokeos.com/version.php?url='.urlencode(api_get_path(WEB_PATH)).'&campus='.urlencode(api_get_setting('siteName')).'&contact='.urlencode(api_get_setting('emailAdministrator')).'&version='.urlencode($dokeos_version).'&numberofcourses='.urlencode($number_of_courses).'&numberofusers='.urlencode($number_of_users).'&donotlistcampus='.api_get_setting('donotlistcampus').'&organisation='.urlencode(api_get_setting('Institution')).'&adminname='.urlencode(api_get_setting('administratorName').' '.api_get_setting('administratorSurname'));
+		$version_url= 'http://version.chamilo.org/version.php?url='.urlencode(api_get_path(WEB_PATH)).'&campus='.urlencode(api_get_setting('siteName')).'&contact='.urlencode(api_get_setting('emailAdministrator')).'&version='.urlencode($system_version).'&numberofcourses='.urlencode($number_of_courses).'&numberofusers='.urlencode($number_of_users).'&donotlistcampus='.api_get_setting('donotlistcampus').'&organisation='.urlencode(api_get_setting('Institution')).'&adminname='.urlencode(api_get_setting('administratorName').' '.api_get_setting('administratorSurname'));
 		$handle=@fopen($version_url,'r');
-		$version_info=trim(@fread($handle, 1024));
+		if ($handle !== false) {
+			$version_info=trim(@fread($handle, 1024));
 
-		if ($dokeos_version<>$version_info)
-		{
-			$output='<br /><span style="color:red">' . get_lang('YourVersionNotUpToDate') . '. '.get_lang('LatestVersionIs').' <b>Dokeos '.$version_info.'</b>. '.get_lang('YourVersionIs').' <b>Dokeos '.$dokeos_version. '</b>. '.str_replace('http://www.dokeos.com','<a href="http://www.dokeos.com">http://www.dokeos.com</a>',get_lang('PleaseVisitDokeos')).'</span>';
-		}
-		else
-		{
-			$output = '<br /><span style="color:green">'.get_lang('VersionUpToDate').': Dokeos '.$version_info.'</span>';
+			if ($system_version <> $version_info) {
+				$output='<br /><span style="color:red">' . get_lang('YourVersionNotUpToDate') . '. '.get_lang('LatestVersionIs').' <b>Chamilo '.$version_info.'</b>. '.get_lang('YourVersionIs').' <b>Chamilo '.$system_version. '</b>. '.str_replace('http://www.chamilo.org','<a href="http://www.chamilo.org">http://www.chamilo.org</a>',get_lang('PleaseVisitDokeos')).'</span>';
+			} else {
+				$output = '<br /><span style="color:green">'.get_lang('VersionUpToDate').': Chamilo '.$version_info.'</span>';
+			}
+		} else {
+            $output = '<span style="color:red">' . get_lang('ImpossibleToContactVersionServerPleaseTryAgain') . '</span>';
 		}
 	}
 	else
@@ -425,15 +431,15 @@ function check_dokeos_version2()
 				the http://www.dokeos.com/version.php page (instead of version.txt) . That's why I chose to use fopen which requires however
 				that allow_url_open is set to true
 */
-function check_dokeos_version()
+function check_system_version()
 {
-	global $_configuration; // the dokeos version of your installation
-	$dokeos_version = $_configuration['dokeos_version'];
+	global $_configuration; // the chamilo version of your installation
+	$system_version = $_configuration['system_version'];
 
-	if ($fsock = @fsockopen('www.dokeos.com', 80, $errno, $errstr))
+	if ($fsock = @fsockopen('www.chamilo.org', 80, $errno, $errstr))
 	{
 		@fputs($fsock, "GET /version.php HTTP/1.1\r\n");
-		@fputs($fsock, "HOST: www.dokeos.com\r\n");
+		@fputs($fsock, "HOST: www.chamilo.org\r\n");
 		@fputs($fsock, "Connection: close\r\n\r\n");
 
 		$get_info = false;
@@ -453,13 +459,10 @@ function check_dokeos_version()
 		}
 		@fclose($fsock);
 
-		if (trim($dokeos_version)<>trim($version_info))
-		{
-			$output='<span style="color:red">' . get_lang('YourVersionNotUpToDate') . '. '.get_lang('LatestVersionIs').' <b>Dokeos '.$version_info.'</b>. '.get_lang('YourVersionIs').' <b>Dokeos '.$dokeos_version. '</b>. '.str_replace('http://www.dokeos.com','<a href="http://www.dokeos.com">http://www.dokeos.com</a>',get_lang('PleaseVisitDokeos')).'</span>';
-		}
-		else
-		{
-			$output = '<span style="color:green">'.get_lang('VersionUpToDate').': Dokeos '.$version_info.'</span>';
+		if (trim($system_version) <> trim($version_info)) {
+			$output='<span style="color:red">' . get_lang('YourVersionNotUpToDate') . '. '.get_lang('LatestVersionIs').' <b>Chamilo '.$version_info.'</b>. '.get_lang('YourVersionIs').' <b>Dokeos '.$system_version. '</b>. '.str_replace('http://www.chamilo.org','<a href="http://www.chamilo.org">http://www.chamilo.org</a>',get_lang('PleaseVisitDokeos')).'</span>';
+		} else {
+			$output = '<span style="color:green">'.get_lang('VersionUpToDate').': Chamilo '.$version_info.'</span>';
 		}
 	}
 	else

+ 5 - 4
main/admin/languages.php

@@ -27,6 +27,7 @@ $cidReset = true;
 
 // include global script
 require_once '../inc/global.inc.php';
+require_once api_get_path(LIBRARY_PATH).'sortabletable.class.php';
 require_once 'sub_language.class.php';
 $this_section = SECTION_PLATFORM_ADMIN;
 
@@ -168,7 +169,7 @@ elseif (isset($_POST['action']))
 					$ids[] = Database::escape_string($id);
 				}
 				$sql = "UPDATE $tbl_admin_languages SET available='1' WHERE id IN ('".implode("','", $ids)."')";
-				Database::query($sql,__FILE__,__LINE__);
+				Database::query($sql);
 			}
 			break;
 		case 'makeunavailable' :
@@ -180,7 +181,7 @@ elseif (isset($_POST['action']))
 					$ids[] = Database::escape_string($id);
 				}
 				$sql = "UPDATE $tbl_admin_languages SET available='0' WHERE id IN ('".implode("','", $ids)."')";
-				Database::query($sql,__FILE__,__LINE__);
+				Database::query($sql);
 			}
 			break;
 	}
@@ -212,7 +213,7 @@ $sql_select = "SELECT * FROM $tbl_admin_languages";
 $result_select = Database::query($sql_select);
 
 $sql_select_lang = "SELECT * FROM $tbl_settings_current WHERE  category='Languages'";
-$result_select_lang = Database::query($sql_select_lang,__FILE__,__LINE__);
+$result_select_lang = Database::query($sql_select_lang);
 $row_lang=Database::fetch_array($result_select_lang);
 
 /*
@@ -233,7 +234,7 @@ while ($row = Database::fetch_array($result_select)) {
 			$checked = ' checked="checked" ';
 		}
 
-		$row_td[] = '<input type="hidden" name="edit_id" value="'.$_GET['id'].'" /><input type="text" name="txt_name" value="'.$row['original_name'].'" /> '
+		$row_td[] = '<input type="hidden" name="edit_id" value="'.Security::remove_XSS($_GET['id']).'" /><input type="text" name="txt_name" value="'.$row['original_name'].'" /> '
 			. '<input type="checkbox" '.$checked.'name="platformlanguage" id="platformlanguage" value="'.$row['english_name'].'" /><label for="platformlanguage">'.$row['original_name'].' '.get_lang('AsPlatformLanguage').'</label> <input type="submit" name="Submit" value="'.get_lang('Ok').'" /><a name="value" />';
 	} else 	{
 		$row_td[] = $row['original_name'];

+ 3 - 3
main/admin/ldap_import_students_to_session.php

@@ -92,7 +92,7 @@ elseif(!empty($annee) && empty($id_session))
 	$sql = "SELECT id,name,nbr_courses,date_start,date_end " .
 		" FROM $tbl_session ".
 		" ORDER BY name";
-	$result = Database::query($sql,__FILE__,__LINE__);
+	$result = Database::query($sql);
 
 	$sessions=Database::store_result($result);
 	$nbr_results=count($sessions);
@@ -184,7 +184,7 @@ elseif (!empty($annee) && !empty($id_session) && ($_POST['confirmed']=='yes'))
 			$sql = 'INSERT INTO '.$tbl_session_user.' SET
 					id_user="'.intval($user_id).'",
 					id_session = "'.intval($id_session).'"';
-			$res_user = Database::query($sql,__FILE__,__LINE__);
+			$res_user = Database::query($sql);
 			if($res_user != false)
 			{
 				$num++;
@@ -193,7 +193,7 @@ elseif (!empty($annee) && !empty($id_session) && ($_POST['confirmed']=='yes'))
 		if($num>0)
 		{
 			$sql = 'UPDATE '.$tbl_session.' SET nbr_users = (nbr_users + '.$num.') WHERE id = '.intval($id_session);
-			$res = Database::query($sql,__FILE__,__LINE__);
+			$res = Database::query($sql);
 		}
 		header('Location: resume_session.php?id_session='.Security::remove_XSS($_POST['id_session']));
 	}

+ 10 - 10
main/admin/ldap_synchro.php

@@ -60,10 +60,10 @@ $tbl_session_rel_etape 				= "session_rel_etape";
 
 $message="";
 
-$result=Database::query("SELECT id, name FROM $tbl_session",__FILE__,__LINE__);
+$result=Database::query("SELECT id, name FROM $tbl_session");
 $Sessions=Database::store_result($result);
 
-$result=Database::query($sql,__FILE__,__LINE__);
+$result=Database::query($sql);
 $users=Database::store_result($result);
 
 foreach($Sessions as $session){
@@ -152,7 +152,7 @@ foreach($Sessions as $session){
 
 		// Une fois les utilisateurs importer dans la base des utilisateurs, on peux les affecter a� la session
 		$result=Database::query("SELECT course_code FROM $tbl_session_rel_course " .
-				"WHERE id_session='$id_session'",__FILE__,__LINE__);
+				"WHERE id_session='$id_session'");
 		$CourseList=array();
 		while($row=Database::fetch_array($result))
 		{
@@ -163,29 +163,29 @@ foreach($Sessions as $session){
 			// On ajoute la relation entre l'utilisateur et le cours
 			foreach($UserList as $enreg_user)
 			{
-				Database::query("INSERT IGNORE INTO $tbl_session_rel_course_rel_user(id_session,course_code,id_user) VALUES('$id_session','$enreg_course','$enreg_user')",__FILE__,__LINE__);
+				Database::query("INSERT IGNORE INTO $tbl_session_rel_course_rel_user(id_session,course_code,id_user) VALUES('$id_session','$enreg_course','$enreg_user')");
 			}
 			$sql = "SELECT COUNT(id_user) as nbUsers " .
 					"FROM $tbl_session_rel_course_rel_user " .
 					"WHERE id_session='$id_session' AND course_code='$enreg_course'";
-			$rs = Database::query($sql, __FILE__, __LINE__);
+			$rs = Database::query($sql);
 			list($nbr_users) = Database::fetch_array($rs);
 			$sql = "UPDATE $tbl_session_rel_course SET nbr_users=$nbr_users WHERE id_session='$id_session' AND course_code='$enreg_course'";
-			Database::query($sql,__FILE__,__LINE__);
+			Database::query($sql);
 		}
 		// On ajoute la relation entre l'utilisateur et la session
 		foreach($UserList as $enreg_user){
 			$sql = "INSERT IGNORE INTO $tbl_session_rel_user(id_session, id_user) " .
 					"VALUES('$id_session','$enreg_user')";
-			Database::query($sql,__FILE__,__LINE__);
+			Database::query($sql);
 		}
 		$sql = "SELECT COUNT(id_user) as nbUsers " .
 				"FROM $tbl_session_rel_user " .
-				"WHERE id_session='$id_session'";
-		$rs = Database::query($sql, __FILE__, __LINE__);
+				"WHERE id_session='$id_session' AND relation_type<>".SESSION_RELATION_TYPE_RRHH."";
+		$rs = Database::query($sql);
 		list($nbr_users) = Database::fetch_array($rs);
 		$sql = "UPDATE $tbl_session SET nbr_users=$nbr_users WHERE id='$id_session'";
-		Database::query($sql,__FILE__,__LINE__);
+		Database::query($sql);
 	}
 }
 ?>

+ 18 - 34
main/admin/legal_add.php

@@ -1,19 +1,20 @@
-<?php // $Id: user_list.php 22041 2009-07-13 18:29:45Z juliomontoya $
-/* For licensing terms, see /dokeos_license.txt */
+<?php
+/* For licensing terms, see /license.txt */
 
 $language_file = array('admin','registration');
 $cidReset = true;
-require '../inc/global.inc.php';
+require_once '../inc/global.inc.php';
 $this_section = SECTION_PLATFORM_ADMIN;
 
 api_protect_admin_script();
+
 require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php';
 require_once api_get_path(LIBRARY_PATH).'security.lib.php';
 require_once api_get_path(LIBRARY_PATH).'legal.lib.php';
-//var_dump($_POST);
+
 // Create the form
 $form = new FormValidator('addlegal');
-//var_dump($_POST);// var_dump($_GET);
+
 $defaults=array();
 if( $form->validate()) {
 	$check = Security::check_token('post');
@@ -36,9 +37,8 @@ if( $form->validate()) {
 				} elseif (isset($values['back'])) {
 					$submit	='back';
 				}
-			}else {
+			} else {
 				$submit  = $values['send'];
-
 			}
 
 			$default[content]=$content;
@@ -97,7 +97,7 @@ if( $form->validate()) {
 	}*/
 }
 $form->setDefaults($default);
-//var_dump($term_preview);
+
 if(isset($_POST['send'])) {
 	Security::clear_token();
 }
@@ -120,8 +120,8 @@ $form->addElement('html',$text);
 
 if (isset($_POST['language'])) {
 //$form->addElement('html_editor', 'content', null, null, array('ToolbarSet' => 'Basic', 'Width' => '100%', 'Height' => '250'));
-	$form->addElement('static', $_POST['language']);
-	$form->addElement('hidden', 'language',$_POST['language']);
+	$form->addElement('static', Security::remove_XSS($_POST['language']));
+	$form->addElement('hidden', 'language',Security::remove_XSS($_POST['language']));
 	$form->add_html_editor('content', get_lang('Content'), true, false, array('ToolbarSet' => 'terms_and_conditions', 'Width' => '100%', 'Height' => '250'));
 	//$form->addElement('textarea', 'content', get_lang('Content'),array('cols'=>'120','rows'=>'10'));
 	$form->addElement('radio', 'type', '', get_lang('HTMLText') ,'0');
@@ -143,15 +143,14 @@ if (isset($_POST['language'])) {
 		$navigator_info = api_get_navigator();
 		//ie6 fix
 	if ($navigator_info['name']=='Internet Explorer' &&  $navigator_info['version']=='6') {
-
-	$buttons = '<div class="row" align="center">
-			<div class="formw">
-			<input type="submit" name="back"  value="'.get_lang('Back').'"/>
-			<input type="submit" name="preview"  value="'.get_lang('Preview').'"/>
-			<input type="submit" name="save"  value="'.get_lang('Save').'"/>
-			</div>
-		</div>';
-		$form->addElement('html',$buttons);
+		$buttons = '<div class="row" align="center">
+				<div class="formw">
+				<input type="submit" name="back"  value="'.get_lang('Back').'"/>
+				<input type="submit" name="preview"  value="'.get_lang('Preview').'"/>
+				<input type="submit" name="save"  value="'.get_lang('Save').'"/>
+				</div>
+			</div>';
+			$form->addElement('html',$buttons);
 	} else {
 	$buttons = '<div class="row" align="center">
 					<div class="formw">
@@ -162,15 +161,6 @@ if (isset($_POST['language'])) {
 				</div>';
 		$form->addElement('html',$buttons);
 	}
-
-/*	$buttons = '<div class="row">
-					<div class="formw">
-					<button type="submit" class="back" 	 name="send" value="back">'.get_lang('Back').'</button>
-					<button type="submit" class="search" name="send" value="preview">'.get_lang('Preview').'</button>
-					<button type="submit" class="save" 	 name="send" value="save">'.get_lang('Save').'</button>
-					</div>
-				</div>';	*/
-
 } else {
 	$form->addElement('select_language', 'language', get_lang('Language'),null,array());
 	$buttons = '<div class="row">
@@ -181,8 +171,6 @@ if (isset($_POST['language'])) {
 	$form->addElement('html',$buttons);
 
 }
-//var_dump($defaults);
-
 
 $tool_name = get_lang('AddTermsAndConditions');
 $interbreadcrumb[] = array ("url" => 'index.php', "name" => get_lang('PlatformAdmin'));
@@ -191,7 +179,6 @@ Display :: display_header($tool_name);
 echo '<script>
 function sendlang(){
 	//document.addlegal.send.value=\'load\';
-//	alert(document.addlegal.send.value);
 	document.addlegal.sec_token.value=\''.$token.'\';
 	document.addlegal.submit();
 }
@@ -212,9 +199,6 @@ if (isset ($_GET['action'])) {
 	}
 }
 
-
-//var_dump($defaults);
-
 $form->setDefaults($defaults);
 $form->display();
 ?>

+ 19 - 19
main/admin/resume_session.php

@@ -45,7 +45,7 @@ $sql = 'SELECT name, nbr_courses, nbr_users, nbr_classes, DATE_FORMAT(date_start
 			ON id_coach = user_id
 		WHERE '.$tbl_session.'.id='.$id_session;
 
-$rs = Database::query($sql, __FILE__, __LINE__);
+$rs = Database::query($sql);
 $session = Database::store_result($rs);
 $session = $session[0];
 
@@ -55,7 +55,7 @@ if(!api_is_platform_admin() && $session['session_admin_id']!=$_user['user_id'])
 }
 
 $sql = 'SELECT name FROM  '.$tbl_session_category.' WHERE id = "'.intval($session['session_category_id']).'"';
-$rs = Database::query($sql, __FILE__, __LINE__);
+$rs = Database::query($sql);
 $session_category = '';
 if(Database::num_rows($rs)>0) {
 	$rows_session_category = Database::store_result($rs);
@@ -75,32 +75,32 @@ if($_GET['action'] == 'delete')
 
 		$idChecked="'".implode("','",$idChecked)."'";
 
-		Database::query("DELETE FROM $tbl_session_rel_course WHERE id_session='$id_session' AND course_code IN($idChecked)",__FILE__,__LINE__);
+		Database::query("DELETE FROM $tbl_session_rel_course WHERE id_session='$id_session' AND course_code IN($idChecked)");
 
 		$nbr_affected_rows=Database::affected_rows();
 
-		Database::query("DELETE FROM $tbl_session_rel_course_rel_user WHERE id_session='$id_session' AND course_code IN($idChecked)",__FILE__,__LINE__);
+		Database::query("DELETE FROM $tbl_session_rel_course_rel_user WHERE id_session='$id_session' AND course_code IN($idChecked)");
 
-		Database::query("UPDATE $tbl_session SET nbr_courses=nbr_courses-$nbr_affected_rows WHERE id='$id_session'",__FILE__,__LINE__);
+		Database::query("UPDATE $tbl_session SET nbr_courses=nbr_courses-$nbr_affected_rows WHERE id='$id_session'");
 	}
 
 	if(!empty($_GET['class'])){
-		Database::query("DELETE FROM $tbl_session_rel_class WHERE session_id='$id_session' AND class_id=".Database::escape_string($_GET['class']),__FILE__,__LINE__);
+		Database::query("DELETE FROM $tbl_session_rel_class WHERE session_id='$id_session' AND class_id=".Database::escape_string($_GET['class']));
 
 		$nbr_affected_rows=Database::affected_rows();
 
-		Database::query("UPDATE $tbl_session SET nbr_classes=nbr_classes-$nbr_affected_rows WHERE id='$id_session'",__FILE__,__LINE__);
+		Database::query("UPDATE $tbl_session SET nbr_classes=nbr_classes-$nbr_affected_rows WHERE id='$id_session'");
 
 	}
 
 	if (!empty($_GET['user'])) {
-		Database::query("DELETE FROM $tbl_session_rel_user WHERE id_session='$id_session' AND id_user=".intval($_GET['user']),__FILE__,__LINE__);
+		Database::query("DELETE FROM $tbl_session_rel_user WHERE relation_type<>".SESSION_RELATION_TYPE_RRHH." AND id_session='$id_session' AND id_user=".intval($_GET['user']));
 		$nbr_affected_rows=Database::affected_rows();
-		Database::query("UPDATE $tbl_session SET nbr_users=nbr_users-$nbr_affected_rows WHERE id='$id_session'",__FILE__,__LINE__);
+		Database::query("UPDATE $tbl_session SET nbr_users=nbr_users-$nbr_affected_rows WHERE id='$id_session'");
 
-		Database::query("DELETE FROM $tbl_session_rel_course_rel_user WHERE id_session='$id_session' AND id_user=".intval($_GET['user']),__FILE__,__LINE__);
+		Database::query("DELETE FROM $tbl_session_rel_course_rel_user WHERE id_session='$id_session' AND id_user=".intval($_GET['user']));
 		$nbr_affected_rows=Database::affected_rows();
-		Database::query("UPDATE $tbl_session_rel_course SET nbr_users=nbr_users-$nbr_affected_rows WHERE id_session='$id_session'",__FILE__,__LINE__);
+		Database::query("UPDATE $tbl_session_rel_course SET nbr_users=nbr_users-$nbr_affected_rows WHERE id_session='$id_session'");
 	}
 }
 
@@ -203,28 +203,28 @@ if($session['nbr_courses']==0){
 else {
 	// select the courses
 	$sql = "SELECT code,title,visual_code, nbr_users
-			FROM $tbl_course,$tbl_session_rel_course			
-			WHERE course_code = code			
+			FROM $tbl_course,$tbl_session_rel_course
+			WHERE course_code = code
 			AND	id_session='$id_session'
 			ORDER BY title";
 
-	$result=Database::query($sql,__FILE__,__LINE__);
+	$result=Database::query($sql);
 	$courses=Database::store_result($result);
 	foreach($courses as $course){
 		//select the number of users
 
 		$sql = " SELECT count(*) FROM $tbl_session_rel_user sru, $tbl_session_rel_course_rel_user srcru
 				WHERE srcru.id_user = sru.id_user AND srcru.id_session = sru.id_session AND srcru.course_code = '".Database::escape_string($course['code'])."'
-				AND srcru.id_session = '".intval($id_session)."'";
+				AND sru.relation_type<>".SESSION_RELATION_TYPE_RRHH." AND srcru.id_session = '".intval($id_session)."'";
 
-		$rs = Database::query($sql, __FILE__, __LINE__);
+		$rs = Database::query($sql);
 		$course['nbr_users'] = Database::result($rs,0,0);
 
 		// Get coachs of the courses in session
 
 		$sql = "SELECT user.lastname,user.firstname,user.username FROM $tbl_session_rel_course_rel_user session_rcru, $tbl_user user
 				WHERE session_rcru.id_user = user.user_id AND session_rcru.id_session = '".intval($id_session)."' AND session_rcru.course_code ='".Database::escape_string($course['code'])."' AND session_rcru.status=2";
-		$rs = Database::query($sql,__FILE__,__LINE__);
+		$rs = Database::query($sql);
 
 		$coachs = array();
 		if (Database::num_rows($rs) > 0) {
@@ -284,10 +284,10 @@ else {
 	$sql = 'SELECT '.$tbl_user.'.user_id, lastname, firstname, username
 			FROM '.$tbl_user.'
 			INNER JOIN '.$tbl_session_rel_user.'
-				ON '.$tbl_user.'.user_id = '.$tbl_session_rel_user.'.id_user
+				ON '.$tbl_user.'.user_id = '.$tbl_session_rel_user.'.id_user AND '.$tbl_session_rel_user.'.relation_type<>'.SESSION_RELATION_TYPE_RRHH.'
 				AND '.$tbl_session_rel_user.'.id_session = '.$id_session.$order_clause;
 
-	$result=Database::query($sql,__FILE__,__LINE__);
+	$result=Database::query($sql);
 	$users=Database::store_result($result);
 	$orig_param = '&origin=resume_session&id_session='.$id_session; // change breadcrumb in destination page
 	foreach($users as $user){

+ 4 - 4
main/admin/session_add.php

@@ -80,7 +80,7 @@ function search_coachs($needle)
 			}
 		}
 
-		$rs = Database::query($sql, __FILE__, __LINE__);
+		$rs = Database::query($sql);
 		while ($user = Database :: fetch_array($rs)) {
 			$return .= '<a href="javascript: void(0);" onclick="javascript: fill_coach_field(\''.$user['username'].'\')">'.api_get_person_name($user['firstname'], $user['lastname']).' ('.$user['username'].')</a><br />';
 		}
@@ -161,7 +161,7 @@ if (!empty($return)) {
 <?php
 
 $sql = 'SELECT COUNT(1) FROM '.$tbl_user.' WHERE status=1';
-$rs = Database::query($sql, __FILE__, __LINE__);
+$rs = Database::query($sql);
 $count_users = Database::result($rs, 0, 0);
 
 if (intval($count_users)<50) {
@@ -178,7 +178,7 @@ if (intval($count_users)<50) {
 		}
 	}
 
-	$result=Database::query($sql,__FILE__,__LINE__);
+	$result=Database::query($sql);
 	$Coaches=Database::store_result($result);
 	?>
 	<select name="coach_username" value="true" style="width:250px;">
@@ -202,7 +202,7 @@ if (intval($count_users)<50) {
 	$id_session_category = '';
 	$tbl_session_category = Database::get_main_table(TABLE_MAIN_SESSION_CATEGORY);
 	$sql = 'SELECT id, name FROM '.$tbl_session_category.' ORDER BY name ASC';
-	$result = Database::query($sql,__FILE__,__LINE__);
+	$result = Database::query($sql);
 	$Categories = Database::store_result($result);
 ?>
 <tr>

+ 4 - 3
main/admin/session_category_edit.php

@@ -37,7 +37,7 @@ $tool_name = get_lang('EditSessionCategory');
 $interbreadcrumb[]=array('url' => 'index.php',"name" => get_lang('PlatformAdmin'));
 $interbreadcrumb[]=array('url' => "session_category_list.php","name" => get_lang('ListSessionCategory'));
 $sql = "SELECT * FROM $tbl_session_category WHERE id='".$id."' ORDER BY name";
-$result=Database::query($sql,__FILE__,__LINE__);
+$result=Database::query($sql);
 if (!$infos=Database::fetch_array($result)) {
 	header('Location: session_list.php');
 	exit();
@@ -45,9 +45,10 @@ if (!$infos=Database::fetch_array($result)) {
 list($year_start,$month_start,$day_start)=explode('-',$infos['date_start']);
 list($year_end,$month_end,$day_end)=explode('-',$infos['date_end']);
 
-if (!api_is_platform_admin() && $infos['session_admin_id']!=$_user['user_id']) {
+if (!api_is_platform_admin() && $infos['session_admin_id']!=$_user['user_id'] && !api_is_session_admin()) {
 	api_not_allowed(true);
 }
+
 if ($_POST['formSent']) {
 	$formSent=1;
 	$name= $_POST['name'];
@@ -73,7 +74,7 @@ if (!empty($return)) {
 	Display::display_error_message($return,false);
 }
 ?>
-<form method="post" name="form" action="<?php echo api_get_self(); ?>?page=<?php echo $_GET['page'] ?>&id=<?php echo $id; ?>" style="margin:0px;">
+<form method="post" name="form" action="<?php echo api_get_self(); ?>?page=<?php echo Security::remove_XSS($_GET['page']) ?>&id=<?php echo $id; ?>" style="margin:0px;">
 <input type="hidden" name="formSent" value="1">
 <div class="row"><div class="form_header"><?php echo $tool_name; ?></div></div>
 <table border="0" cellpadding="5" cellspacing="0" width="550">

+ 5 - 5
main/admin/session_category_list.php

@@ -66,10 +66,10 @@ if (isset ($_GET['search']) && $_GET['search'] == 'advanced') {
 	$from = $page * $limit;
 	//if user is crfp admin only list its sessions
 	if(!api_is_platform_admin()) {
-		$where .= (empty($_REQUEST['keyword']) ? " " : " WHERE name LIKE '%".addslashes($_REQUEST['keyword'])."%'");
+		$where .= (empty($_REQUEST['keyword']) ? " " : " WHERE name LIKE '%".Database::escape_string(trim($_REQUEST['keyword']))."%'");
 	}
 	else {
-		$where .= (empty($_REQUEST['keyword']) ? " " : " WHERE name LIKE '%".addslashes($_REQUEST['keyword'])."%'");
+		$where .= (empty($_REQUEST['keyword']) ? " " : " WHERE name LIKE '%".Database::escape_string(trim($_REQUEST['keyword']))."%'");
 	}
 
 	$query = "SELECT sc.*, (select count(id) FROM $tbl_session WHERE session_category_id = sc.id) as nbr_session
@@ -82,10 +82,10 @@ if (isset ($_GET['search']) && $_GET['search'] == 'advanced') {
 				FROM $tbl_session_category sc $where ";
 
 	$order = ($order == 'ASC')? 'DESC': 'ASC';
-	$result_rows = Database::query($query_rows,__FILE__,__LINE__);
+	$result_rows = Database::query($query_rows);
 	$recorset = Database::fetch_array($result_rows);
 	$num = $recorset['total_rows'];
-	$result = Database::query($query,__FILE__,__LINE__);
+	$result = Database::query($query);
 	$Sessions = Database::store_result($result);
 	$nbr_results = sizeof($Sessions);
 	$tool_name = get_lang('ListSessionCategory');
@@ -159,7 +159,7 @@ if (isset ($_GET['search']) && $_GET['search'] == 'advanced') {
 				break;
 			}
 		$sql = 'SELECT COUNT(session_category_id) FROM '.$tbl_session.' WHERE session_category_id = '.intval($enreg['id']);
-		$rs = Database::query($sql, __FILE__, __LINE__);
+		$rs = Database::query($sql);
 		list($nb_courses) = Database::fetch_array($rs);
 		?>
 		<tr class="<?php echo $i?'row_odd':'row_even'; ?>">

+ 6 - 6
main/admin/session_course_edit.php

@@ -12,9 +12,9 @@ $cidReset=true;
 require '../inc/global.inc.php';
 require_once '../inc/lib/sessionmanager.lib.php';
 // setting the section (for the tabs)
-$this_section=SECTION_PLATFORM_ADMIN;
+/*$this_section=SECTION_PLATFORM_ADMIN;
 
-api_protect_admin_script();
+api_protect_admin_script();*/
 
 $id_session=intval($_GET['id_session']);
 $course_code=trim(stripslashes($_GET['course_code']));
@@ -37,7 +37,7 @@ $interbreadcrumb[]=array('url' => "session_list.php","name" => get_lang("Session
 $interbreadcrumb[]=array('url' => "../admin/resume_session.php?id_session=".Security::remove_XSS($_REQUEST['id_session']),"name" => get_lang('SessionOverview'));
 $interbreadcrumb[]=array('url' => "session_course_list.php?id_session=$id_session","name" =>api_htmlentities($session_name,ENT_QUOTES,$charset));
 
-$result=Database::query("SELECT name,title FROM $tbl_session_course,$tbl_session,$tbl_course WHERE id_session=id AND course_code=code AND id_session='$id_session' AND course_code='".addslashes($course_code)."'",__FILE__,__LINE__);
+$result = Database::query("SELECT s.name, c.title FROM $tbl_session_course sc,$tbl_session s,$tbl_course c WHERE sc.id_session=s.id AND sc.course_code=c.code AND sc.id_session='$id_session' AND sc.course_code='".addslashes($course_code)."'");
 
 if (!list($session_name,$course_title)=Database::fetch_row($result)) {
 	header('Location: session_course_list.php?id_session='.$id_session);
@@ -50,7 +50,7 @@ if ($_POST['formSent']) {
 
 	// get all tutor by course_code in the session
 	$sql = "SELECT id_user FROM $tbl_session_rel_course_rel_user WHERE id_session = '$id_session' AND course_code = '$course_code' AND status = 2";
-	$rs_coachs = Database::query($sql,__FILE__,__LINE__);
+	$rs_coachs = Database::query($sql);
 
 	$coachs_course_session = array();
 	if (Database::num_rows($rs_coachs) > 0){
@@ -83,7 +83,7 @@ if ($_POST['formSent']) {
 }else {
 
 	$sql = "SELECT id_user FROM $tbl_session_rel_course_rel_user WHERE id_session = '$id_session' AND course_code = '$course_code' AND status = 2 ";
-	$rs = Database::query($sql,__FILE__,__LINE__);
+	$rs = Database::query($sql);
 
 	if (Database::num_rows($rs) > 0) {
 		while ($infos = Database::fetch_array($rs)) {
@@ -95,7 +95,7 @@ if ($_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;
 
-$result=Database::query($sql,__FILE__,__LINE__);
+$result=Database::query($sql);
 
 $coaches=Database::store_result($result);
 

+ 6 - 6
main/admin/session_course_list.php

@@ -15,7 +15,7 @@ include('../inc/global.inc.php');
 // setting the section (for the tabs)
 $this_section=SECTION_PLATFORM_ADMIN;
 
-api_protect_admin_script();
+api_protect_admin_script(true);
 
 // Database Table Definitions
 $tbl_course							= Database::get_main_table(TABLE_MAIN_COURSE);
@@ -28,7 +28,7 @@ $page=intval($_GET['page']);
 $action=$_REQUEST['action'];
 $sort=in_array($_GET['sort'],array('title','nbr_users'))?$_GET['sort']:'title';
 
-$result=Database::query("SELECT name FROM $tbl_session WHERE id='$id_session'",__FILE__,__LINE__);
+$result=Database::query("SELECT name FROM $tbl_session WHERE id='$id_session'");
 
 if(!list($session_name)=Database::fetch_row($result))
 {
@@ -45,11 +45,11 @@ if($action == 'delete') {
 		}
 		$idChecked = $my_temp;
 		$idChecked="'".implode("','",$idChecked)."'";
-		Database::query("DELETE FROM $tbl_session_rel_course WHERE id_session='$id_session' AND course_code IN($idChecked)",__FILE__,__LINE__);
+		Database::query("DELETE FROM $tbl_session_rel_course WHERE id_session='$id_session' AND course_code IN($idChecked)");
 		$nbr_affected_rows=Database::affected_rows();
-		Database::query("DELETE FROM $tbl_session_rel_course_rel_user WHERE id_session='$id_session' AND course_code IN($idChecked)",__FILE__,__LINE__);
+		Database::query("DELETE FROM $tbl_session_rel_course_rel_user WHERE id_session='$id_session' AND course_code IN($idChecked)");
 
-		Database::query("UPDATE $tbl_session SET nbr_courses=nbr_courses-$nbr_affected_rows WHERE id='$id_session'",__FILE__,__LINE__);
+		Database::query("UPDATE $tbl_session SET nbr_courses=nbr_courses-$nbr_affected_rows WHERE id='$id_session'");
 	}
 
 	header('Location: '.api_get_self().'?id_session='.$id_session.'&sort='.$sort);
@@ -59,7 +59,7 @@ if($action == 'delete') {
 $limit=20;
 $from=$page * $limit;
 
-$result=Database::query("SELECT code,title,nbr_users FROM $tbl_session_rel_course,$tbl_course WHERE course_code=code AND id_session='$id_session' ORDER BY $sort LIMIT $from,".($limit+1),__FILE__,__LINE__);
+$result=Database::query("SELECT code,title,nbr_users FROM $tbl_session_rel_course,$tbl_course WHERE course_code=code AND id_session='$id_session' ORDER BY $sort LIMIT $from,".($limit+1));
 $Courses=Database::store_result($result);
 $nbr_results=sizeof($Sessions);
 $tool_name = api_htmlentities($session_name,ENT_QUOTES,$charset).' : '.get_lang('CourseListInSession');

+ 11 - 13
main/admin/session_course_user.php

@@ -1,9 +1,7 @@
 <?php //$id: $
-/* For licensing terms, see /dokeos_license.txt */
+/* For licensing terms, see /license.txt */
 /**
-==============================================================================
-*	@package dokeos.admin
-==============================================================================
+*	@package chamilo.admin
 */
 
 // name of the language file that needs to be included
@@ -13,7 +11,7 @@ $language_file='admin';
 $cidReset=true;
 
 // including some necessary dokeos files
-require '../inc/global.inc.php';
+require_once '../inc/global.inc.php';
 
 // including additonal libraries
 require_once api_get_path(LIBRARY_PATH).'sessionmanager.lib.php';
@@ -47,7 +45,7 @@ if (empty($id_user) || empty($id_session)) {
 
 if (!api_is_platform_admin()) {
 	$sql = 'SELECT session_admin_id FROM '.Database :: get_main_table(TABLE_MAIN_SESSION).' WHERE id='.$id_session;
-	$rs = Database::query($sql, __FILE__, __LINE__);
+	$rs = Database::query($sql);
 	if (Database::result($rs,0,0)!=$_user['user_id']) {
 		api_not_allowed(true);
 	}
@@ -73,7 +71,7 @@ if ($_POST['formSent']) {
 			ON (srcru.id_session =  session_rel_course.id_session)
 			WHERE id_user = $id_user and session_rel_course.id_session = $id_session";
 
-	$rs = Database::query($sql, __FILE__, __LINE__);
+	$rs = Database::query($sql);
 	$existingCourses = Database::store_result($rs);
 	if (count($CourseList) == count($existingCourses)) {
 		header('Location: session_course_user.php?id_session='.$id_session.'&id_user='.$id_user.'&msg='.get_lang('MaybeYouWantToDeleteThisUserFromSession'));
@@ -90,11 +88,11 @@ if ($_POST['formSent']) {
 			$enreg_course = Database::escape_string($enreg_course);
 			$sql_delete = "DELETE FROM $tbl_session_rel_course_rel_user
 							WHERE id_user='".$id_user."'  AND course_code='".$enreg_course."' AND id_session=$id_session";
-			Database::query($sql_delete,__FILE__, __LINE__);
+			Database::query($sql_delete);
 			if(Database::affected_rows()) {
 				//update session rel course table
 				$sql_update  = "UPDATE $tbl_session_rel_course SET nbr_users= nbr_users - 1 WHERE id_session='$id_session' AND course_code='$enreg_course'";
-				Database::query($sql_update,__FILE__, __LINE__);
+				Database::query($sql_update);
 			}
 		}
 	}
@@ -103,11 +101,11 @@ if ($_POST['formSent']) {
 		if(!in_array($existingCourse['code'], $CourseList)){
 			$existingCourse = Database::escape_string($existingCourse['code']);
 			$sql_insert = "INSERT IGNORE INTO $tbl_session_rel_course_rel_user(id_session,course_code,id_user) VALUES('$id_session','$existingCourse','$id_user')";
-			Database::query($sql_insert,__FILE__, __LINE__);
+			Database::query($sql_insert);
 			if(Database::affected_rows()) {
 				//update session rel course table
 				$sql_update  = "UPDATE $tbl_session_rel_course SET nbr_users= nbr_users + 1 WHERE id_session='$id_session' AND course_code='$existingCourse'";
-				Database::query($sql_update,__FILE__, __LINE__);
+				Database::query($sql_update);
 			}
 
 		}
@@ -170,10 +168,10 @@ if ($_configuration['multiple_access_urls']==true) {
 	}
 }*/
 
-$result=Database::query($sql,__FILE__,__LINE__);
+$result=Database::query($sql);
 $Courses=Database::store_result($result);
 
-$result=Database::query($sql_all,__FILE__,__LINE__);
+$result=Database::query($sql_all);
 $CoursesAll=Database::store_result($result);
 
 $course_temp = array();

+ 10 - 5
main/admin/session_course_user_list.php

@@ -9,7 +9,7 @@
 $language_file='admin';
 $cidReset=true;
 include('../inc/global.inc.php');
-api_protect_admin_script();
+api_protect_admin_script(true);
 $tbl_user=Database::get_main_table(TABLE_MAIN_USER);
 $tbl_course=Database::get_main_table(TABLE_MAIN_COURSE);
 $tbl_session=Database::get_main_table(TABLE_MAIN_SESSION);
@@ -29,8 +29,13 @@ if (is_array($idChecked)) {
 	}
 	$idChecked = $my_temp;
 }
-$result=Database::query("SELECT name,title FROM $tbl_session,$tbl_course WHERE id='$id_session' AND code='".addslashes($course_code)."'",__FILE__,__LINE__);
 
+$sql = "SELECT s.name, c.title  FROM $tbl_session_rel_course src 
+		INNER JOIN $tbl_session s ON s.id = src.id_session
+		INNER JOIN $tbl_course c ON c.code = src.course_code
+		WHERE src.id_session='$id_session' AND src.course_code='".Database::escape_string($course_code)."' "; 
+
+$result=Database::query($sql);
 if(!list($session_name,$course_title)=Database::fetch_row($result))
 {
 	header('Location: session_course_list.php?id_session='.$id_session);
@@ -40,9 +45,9 @@ if(!list($session_name,$course_title)=Database::fetch_row($result))
 if($action == 'delete') {
 	if(is_array($idChecked) && count($idChecked)>0 ) {
 		$idChecked=implode(',',$idChecked);
-		Database::query("DELETE FROM $tbl_session_rel_course_rel_user WHERE id_session='$id_session' AND course_code='".addslashes($course_code)."' AND id_user IN($idChecked)",__FILE__,__LINE__);
+		Database::query("DELETE FROM $tbl_session_rel_course_rel_user WHERE id_session='$id_session' AND course_code='".addslashes($course_code)."' AND id_user IN($idChecked)");
 		$nbr_affected_rows=Database::affected_rows();
-		Database::query("UPDATE $tbl_session_rel_course SET nbr_users=nbr_users-$nbr_affected_rows WHERE id_session='$id_session' AND course_code='".addslashes($course_code)."'",__FILE__,__LINE__);
+		Database::query("UPDATE $tbl_session_rel_course SET nbr_users=nbr_users-$nbr_affected_rows WHERE id_session='$id_session' AND course_code='".addslashes($course_code)."'");
 	}
 	header('Location: '.api_get_self().'?id_session='.$id_session.'&course_code='.urlencode($course_code).'&sort='.$sort);
 	exit();
@@ -52,7 +57,7 @@ $limit=20;
 $from=$page * $limit;
 $is_western_name_order = api_is_western_name_order();
 
-$result=Database::query("SELECT user_id,".($is_western_name_order ? 'firstname,lastname' : 'lastname,firstname').",username FROM $tbl_session_rel_course_rel_user,$tbl_user WHERE user_id=id_user AND id_session='$id_session' AND course_code='".addslashes($course_code)."' ORDER BY $sort LIMIT $from,".($limit+1),__FILE__,__LINE__);
+$result=Database::query("SELECT u.user_id,".($is_western_name_order ? 'u.firstname, u.lastname' : 'u.lastname, u.firstname').", u.username FROM $tbl_session_rel_course_rel_user scru, $tbl_user u WHERE u.user_id=scru.id_user AND scru.id_session='$id_session' AND scru.status<>2 AND scru.course_code='".addslashes($course_code)."' ORDER BY $sort LIMIT $from,".($limit+1));
 $Users=Database::store_result($result);
 
 $nbr_results=sizeof($Users);

+ 6 - 6
main/admin/session_edit.php

@@ -1,11 +1,11 @@
 <?php
-/* For licensing terms, see /dokeos_license.txt */
+/* For licensing terms, see /license.txt */
 
 // name of the language file that needs to be included
 $language_file ='admin';
 $cidReset=true;
-include('../inc/global.inc.php');
-require_once (api_get_path(LIBRARY_PATH).'sessionmanager.lib.php');
+require_once '../inc/global.inc.php';
+require_once api_get_path(LIBRARY_PATH).'sessionmanager.lib.php';
 
 // setting the section (for the tabs)
 $this_section=SECTION_PLATFORM_ADMIN;
@@ -27,7 +27,7 @@ $tool_name = get_lang('EditSession');
 $interbreadcrumb[]=array('url' => 'index.php',"name" => get_lang('PlatformAdmin'));
 $interbreadcrumb[]=array('url' => "session_list.php","name" => get_lang('SessionList'));
 
-$result=Database::query("SELECT name,date_start,date_end,id_coach, session_admin_id, nb_days_access_before_beginning, nb_days_access_after_end, session_category_id, visibility FROM $tbl_session WHERE id='$id'",__FILE__,__LINE__);
+$result=Database::query("SELECT name,date_start,date_end,id_coach, session_admin_id, nb_days_access_before_beginning, nb_days_access_after_end, session_category_id, visibility FROM $tbl_session WHERE id='$id'");
 
 if (!$infos=Database::fetch_array($result)) {
 	header('Location: session_list.php');
@@ -76,7 +76,7 @@ if ($_configuration['multiple_access_urls']==true){
 	}
 }
 
-$result=Database::query($sql,__FILE__,__LINE__);
+$result=Database::query($sql);
 
 $Coaches=Database::store_result($result);
 $thisYear=date('Y');
@@ -126,7 +126,7 @@ unset($Coaches);
 	$tbl_session_category = Database::get_main_table(TABLE_MAIN_SESSION_CATEGORY);
 	//$access_url_id = api_get_current_access_url_id();
 	$sql = 'SELECT id, name FROM '.$tbl_session_category.' ORDER BY name ASC';
-	$result = Database::query($sql,__FILE__,__LINE__);
+	$result = Database::query($sql);
 	$Categories = Database::store_result($result);
 ?>
 <tr>

+ 41 - 41
main/admin/session_export.php

@@ -27,21 +27,21 @@
 ==============================================================================
 */
 // name of the language file that needs to be included
-$language_file='admin';
+$language_file = 'admin';
 
-$cidReset=true;
+$cidReset = true;
 
-include('../inc/global.inc.php');
+include '../inc/global.inc.php';
 
 // setting the section (for the tabs)
-$this_section=SECTION_PLATFORM_ADMIN;
+$this_section = SECTION_PLATFORM_ADMIN;
 
 api_protect_admin_script(true);
-include(api_get_path(LIBRARY_PATH).'/fileManage.lib.php');
+include api_get_path(LIBRARY_PATH).'/fileManage.lib.php';
 
-$session_id=$_GET['session_id'];
-$formSent=0;
-$errorMsg='';
+$session_id = intval($_GET['session_id']);
+$formSent = 0;
+$errorMsg = '';
 
 // Database Table Definitions
 $tbl_user					= Database::get_main_table(TABLE_MAIN_USER);
@@ -53,21 +53,21 @@ $tbl_session_course      	= Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
 $tbl_session_course_user 	= Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
 
 
-$archivePath=api_get_path(SYS_PATH).$archiveDirName.'/';
-$archiveURL=api_get_path(WEB_CODE_PATH).'course_info/download.php?archive=';
+$archivePath = api_get_path(SYS_ARCHIVE_PATH);
+$archiveURL = api_get_path(WEB_CODE_PATH).'course_info/download.php?archive=';
 
-$tool_name=get_lang('ExportSessionListXMLCSV');
+$tool_name = get_lang('ExportSessionListXMLCSV');
 
-$interbreadcrumb[]=array('url' => 'index.php',"name" => get_lang('PlatformAdmin'));
+$interbreadcrumb[] = array('url' => 'index.php',"name" => get_lang('PlatformAdmin'));
 
 set_time_limit(0);
 
-if($_POST['formSent'] )
+if ($_POST['formSent'] )
 {
-	$formSent=$_POST['formSent'];
-	$file_type=($_POST['file_type'] == 'csv')?'csv':'xml';
-	$session_id=$_POST['session_id'];
-	if(empty($session_id))
+	$formSent = $_POST['formSent'];
+	$file_type = ($_POST['file_type'] == 'csv')?'csv':'xml';
+	$session_id = $_POST['session_id'];
+	if (empty($session_id))
 	{
 		$sql = "SELECT id,name,id_coach,username,date_start,date_end,visibility,session_category_id FROM $tbl_session INNER JOIN $tbl_user
 					ON $tbl_user.user_id = $tbl_session.id_coach ORDER BY id";
@@ -84,7 +84,7 @@ if($_POST['formSent'] )
 
 			}
 		}
-		$result=Database::query($sql,__FILE__,__LINE__);
+		$result=Database::query($sql);
 	}
 	else
 	{
@@ -94,7 +94,7 @@ if($_POST['formSent'] )
 					ON $tbl_user.user_id = $tbl_session.id_coach
 				WHERE id='$session_id'";
 
-		$result = Database::query($sql,__FILE__,__LINE__);
+		$result = Database::query($sql);
 
 	}
 
@@ -102,7 +102,7 @@ if($_POST['formSent'] )
 	{
 		if(!file_exists($archivePath))
 		{
-			mkpath($archivePath);
+			mkdir($archivePath, api_get_permissions_for_new_directories(), true);
 		}
 
 		if(!file_exists($archivePath.'index.html'))
@@ -130,7 +130,7 @@ if($_POST['formSent'] )
 		else
 		{
 			$cvs = false;
-			fputs($fp,"<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n<Sessions>\n");
+			fputs($fp, "<?xml version=\"1.0\" encoding=\"".api_get_system_encoding()."\"?>\n<Sessions>\n");
 		}
 
 		while($row=Database::fetch_array($result))
@@ -158,10 +158,10 @@ if($_POST['formSent'] )
 			//users
 			$sql = "SELECT DISTINCT $tbl_user.username FROM $tbl_user
 					INNER JOIN $tbl_session_user
-						ON $tbl_user.user_id = $tbl_session_user.id_user
+						ON $tbl_user.user_id = $tbl_session_user.id_user AND $tbl_session_user.relation_type<>".SESSION_RELATION_TYPE_RRHH."
 						AND $tbl_session_user.id_session = '".$row['id']."'";
 
-			$rsUsers = Database::query($sql,__FILE__,__LINE__);
+			$rsUsers = Database::query($sql);
 			$users = '';
 			while($rowUsers = Database::fetch_array($rsUsers)){
 				if($cvs){
@@ -180,33 +180,33 @@ if($_POST['formSent'] )
 			$add .= $users;
 
 			//courses
-			$sql = "SELECT DISTINCT $tbl_course.code 
+			$sql = "SELECT DISTINCT $tbl_course.code
 					FROM $tbl_course
 					INNER JOIN $tbl_session_course_user
-						ON $tbl_course.code = $tbl_session_course_user.course_code								
+						ON $tbl_course.code = $tbl_session_course_user.course_code
 						AND $tbl_session_course_user.id_session = '".$row['id']."'";
-													
-			$rsCourses = Database::query($sql,__FILE__,__LINE__);
+
+			$rsCourses = Database::query($sql);
 
 			$courses = '';
 			while($rowCourses = Database::fetch_array($rsCourses)){
 
 				// get coachs from a course
-				$sql = "SELECT u.username 
+				$sql = "SELECT u.username
 					FROM $tbl_session_course_user scu
-					INNER JOIN $tbl_user u ON u.user_id = scu.id_user		
+					INNER JOIN $tbl_user u ON u.user_id = scu.id_user
 					WHERE scu.course_code = '{$rowCourses['code']}'
-						AND scu.id_session = '".$row['id']."' AND scu.status = 2 ";				
+						AND scu.id_session = '".$row['id']."' AND scu.status = 2 ";
 
-				$rs_coachs = Database::query($sql,__FILE__,__LINE__);
+				$rs_coachs = Database::query($sql);
 				$coachs = array();
 				while ($row_coachs = Database::fetch_array($rs_coachs)) {
-					$coachs[] = $row_coachs['username']; 
+					$coachs[] = $row_coachs['username'];
 				}
-				
-				$coachs = implode(",",$coachs); 					
-								
-				if($cvs){										
+
+				$coachs = implode(",",$coachs);
+
+				if($cvs){
 					$courses .= str_replace(';',',',$rowCourses['code']);
 					$courses .= '['.str_replace(';',',',$coachs).'][';
 				}
@@ -219,16 +219,16 @@ if($_POST['formSent'] )
 				// rel user courses
 				$sql = "SELECT DISTINCT u.username
 						FROM $tbl_session_course_user scu
-						INNER JOIN $tbl_session_user su ON scu.id_user = su.id_user AND scu.id_session = su.id_session		
+						INNER JOIN $tbl_session_user su ON scu.id_user = su.id_user AND scu.id_session = su.id_session AND su.relation_type<>".SESSION_RELATION_TYPE_RRHH."
 						INNER JOIN $tbl_user u
 						ON scu.id_user = u.user_id
 						AND scu.course_code='".$rowCourses['code']."'
-						AND scu.id_session='".$row['id']."'";				
+						AND scu.id_session='".$row['id']."'";
 
-				$rsUsersCourse = Database::query($sql,__FILE__,__LINE__);
+				$rsUsersCourse = Database::query($sql);
 				$userscourse = '';
 				while($rowUsersCourse = Database::fetch_array($rsUsersCourse)){
-					
+
 					if($cvs){
 						$userscourse .= str_replace(';',',',$rowUsersCourse['username']).',';
 					}
@@ -291,7 +291,7 @@ if ($_configuration['multiple_access_urls']==true) {
 }
 
 
-$result=Database::query($sql,__FILE__,__LINE__);
+$result=Database::query($sql);
 
 $Sessions=Database::store_result($result);
 ?>

+ 85 - 85
main/admin/session_import.php

@@ -69,7 +69,7 @@ if ($_POST['formSent']) {
 			// $root = @simplexml_load_string(api_utf8_encode_xml(file_get_contents($_FILES['import_file']['tmp_name'])));
 			// To ease debugging let us use:
 			$content = file_get_contents($_FILES['import_file']['tmp_name']);
-			
+
 			$content = api_utf8_encode_xml($content);
 			$root = @simplexml_load_string($content);
 			unset($content);
@@ -113,7 +113,7 @@ if ($_POST['formSent']) {
 									status = '".Database::escape_string($status)."'";
 
 							// When it is applicable, adding the access_url rel user relationship too.
-							Database::query($sql, __FILE__, __LINE__);
+							Database::query($sql);
 							$return = Database::insert_id();
 							global $_configuration;
 							require_once api_get_path(LIBRARY_PATH).'urlmanager.lib.php';
@@ -160,7 +160,7 @@ if ($_POST['formSent']) {
 									status = '".Database::escape_string($status)."'
 								WHERE username = '".Database::escape_string($username)."'";
 
-							Database::query($sql, __FILE__, __LINE__);
+							Database::query($sql);
 						}
 					}
 				}
@@ -176,7 +176,7 @@ if ($_POST['formSent']) {
 
 						// Looking up for the teacher.
 						$sql = "SELECT user_id, lastname, firstname FROM $tbl_user WHERE username='$username'";
-						$rs = Database::query($sql, __FILE__, __LINE__);
+						$rs = Database::query($sql);
 						list($user_id, $lastname, $firstname) = Database::fetch_array($rs);
 						global $_configuration;
 						$keys = define_course_keys($course_code, '', $_configuration['db_prefix']);
@@ -223,7 +223,7 @@ if ($_POST['formSent']) {
 										tutor_name = '".api_get_person_name($firstname, $lastname, null, null, $language)."',
 										visual_code = '".$current_course_code."'";
 
-								Database::query($sql, __FILE__, __LINE__);
+								Database::query($sql);
 
 								$sql = "INSERT INTO ".$tbl_course_user." SET
 										course_code = '".$current_course_id."',
@@ -234,7 +234,7 @@ if ($_POST['formSent']) {
 										sort='". ($sort + 1)."',
 										user_course_cat='0'";
 
-								Database::query($sql, __FILE__, __LINE__);
+								Database::query($sql);
 							}
 						}
 					}
@@ -242,7 +242,7 @@ if ($_POST['formSent']) {
 
 				// Creating sessions from <Sessions> base node.
 				if (count($root->Session) > 0) {
-					
+
 					foreach ($root->Session as $node_session) {
 
 						$course_counter = 0;
@@ -302,7 +302,7 @@ if ($_POST['formSent']) {
 									$suffix = ' - '.$i;
 								}
 								$sql = 'SELECT 1 FROM '.$tbl_session.' WHERE name="'.Database::escape_string($session_name.$suffix).'"';
-								$rs = Database::query($sql, __FILE__, __LINE__);
+								$rs = Database::query($sql);
 								if (Database::result($rs, 0, 0)) {
 									$i++;
 								} else {
@@ -317,9 +317,9 @@ if ($_POST['formSent']) {
 									date_start = '$date_start',
 									date_end = '$date_end',
 									visibility = '$visibility',
-									session_category_id = '$session_category_id',		
+									session_category_id = '$session_category_id',
 									session_admin_id=".intval($_user['user_id']);
-							$rs_session = Database::query($sql_session, __FILE__, __LINE__);
+							$rs_session = Database::query($sql_session);
 							$session_id = Database::insert_id();
 							$session_counter++;
 
@@ -334,9 +334,9 @@ if ($_POST['formSent']) {
 										date_start = '$date_start',
 										date_end = '$date_end',
 										visibility = '$visibility',
-										session_category_id = '$session_category_id',		
+										session_category_id = '$session_category_id',
 										session_admin_id=".intval($_user['user_id']);
-								$rs_session = Database::query($sql_session, __FILE__, __LINE__);
+								$rs_session = Database::query($sql_session);
 								$session_id = Database::insert_id();
 								$session_counter++;
 							} else {
@@ -346,14 +346,14 @@ if ($_POST['formSent']) {
 										date_start = '$date_start',
 										date_end = '$date_end',
 										visibility = '$visibility',
-										session_category_id = '$session_category_id'		
+										session_category_id = '$session_category_id'
 									WHERE name = '$session_name'";
-								$rs_session = Database::query($sql_session, __FILE__, __LINE__);
-								$session_id = Database::query("SELECT id FROM $tbl_session WHERE name='$session_name'", __FILE__, __LINE__);
+								$rs_session = Database::query($sql_session);
+								$session_id = Database::query("SELECT id FROM $tbl_session WHERE name='$session_name'");
 								list($session_id) = Database::fetch_array($session_id);
-								Database::query("DELETE FROM $tbl_session_user WHERE id_session='$session_id'", __FILE__, __LINE__);
-								Database::query("DELETE FROM $tbl_session_course WHERE id_session='$session_id'", __FILE__, __LINE__);
-								Database::query("DELETE FROM $tbl_session_course_user WHERE id_session='$session_id'", __FILE__, __LINE__);
+								Database::query("DELETE FROM $tbl_session_user WHERE id_session='$session_id'");
+								Database::query("DELETE FROM $tbl_session_course WHERE id_session='$session_id'");
+								Database::query("DELETE FROM $tbl_session_course_user WHERE id_session='$session_id'");
 							}
 						}
 
@@ -378,34 +378,34 @@ if ($_POST['formSent']) {
 								$sql = "INSERT IGNORE INTO $tbl_session_user SET
 										id_user='$user_id',
 										id_session = '$session_id'";
-								$rs_user = Database::query($sql, __FILE__, __LINE__);
+								$rs_user = Database::query($sql);
 								$user_counter++;
 							}
 						}
 
 
 						// Adding courses to a session.
-						
-						
-						
+
+
+
 						foreach ($node_session->Course as $node_course) {
 							$course_code = Database::escape_string(trim(api_utf8_decode($node_course->CourseCode)));
 							// Verify that the course pointed by the course code node exists.
 							if (CourseManager::course_exists($course_code)) {
 								// If the course exists we continue.
 								$course_info = CourseManager::get_course_information($course_code);
-							
+
 								$session_course_relation = SessionManager::relation_session_course_exist($session_id, $course_code);
 								if (!$session_course_relation) {
 									$sql_course = "INSERT INTO $tbl_session_course SET
-											course_code = '$course_code',											
+											course_code = '$course_code',
 											id_session='$session_id'";
-									$rs_course = Database::query($sql_course, __FILE__, __LINE__);
+									$rs_course = Database::query($sql_course);
 								}
-								
+
 								$course_coachs = explode(",",$node_course->Coach);
-																
-								// adding coachs to session course user							
+
+								// adding coachs to session course user
 								foreach ($course_coachs as $course_coach) {
 									$coach_id = UserManager::purify_username(api_utf8_decode($course_coach), $purification_option_for_usernames);
 									$coach_id = UserManager::get_user_id_from_username($course_coach);
@@ -415,15 +415,15 @@ if ($_POST['formSent']) {
 												course_code='$course_code',
 												id_session = '$session_id',
 												status = 2 ";
-										$rs_coachs = Database::query($sql, __FILE__, __LINE__);
+										$rs_coachs = Database::query($sql);
 									} else {
 										$error_message .= get_lang('UserDoesNotExist').' : '.$user.'<br />';
 									}
 								}
-								
+
 								// adding users
 								$course_counter++;
-								$users_in_course_counter = 0;									
+								$users_in_course_counter = 0;
 								foreach ($node_course->User as $node_user) {
 									$username = UserManager::purify_username(api_utf8_decode($node_user), $purification_option_for_usernames);
 									$user_id = UserManager::get_user_id_from_username($username);
@@ -432,21 +432,21 @@ if ($_POST['formSent']) {
 										$sql = "INSERT IGNORE INTO $tbl_session_user SET
 												id_user='$user_id',
 												id_session = '$session_id'";
-										$rs_user = Database::query($sql, __FILE__, __LINE__);
+										$rs_user = Database::query($sql);
 										$user_counter++;
 										// Adding to session_rel_user_rel_course table.
 										$sql = "INSERT IGNORE INTO $tbl_session_course_user SET
 												id_user='$user_id',
 												course_code='$course_code',
 												id_session = '$session_id'";
-										$rs_users = Database::query($sql, __FILE__, __LINE__);
+										$rs_users = Database::query($sql);
 										$users_in_course_counter++;
 									} else {
 										$error_message .= get_lang('UserDoesNotExist').' : '.$username.'<br />';
 									}
 								}
 								$update_session_course = "UPDATE $tbl_session_course SET nbr_users='$users_in_course_counter' WHERE course_code='$course_code'";
-								Database::query($update_session_course, __FILE__, __LINE__);
+								Database::query($update_session_course);
 								$inserted_in_course[$course_code] = $course_info['title'];
 
 							}
@@ -459,15 +459,15 @@ if ($_POST['formSent']) {
 									if ($vcourse['code'] == $course_code) {
 										// Ignore, this has already been inserted.
 									} else {
-										
+
 										$sql_course = "INSERT INTO $tbl_session_course SET
 												course_code = '".$vcourse['code']."',
 												id_session='$session_id'";
-										$rs_course = Database::query($sql_course, __FILE__, __LINE__);
-										
+										$rs_course = Database::query($sql_course);
+
 										$course_coachs = explode(",",$node_course->Coach);
-																
-										// adding coachs to session course user							
+
+										// adding coachs to session course user
 										foreach ($course_coachs as $course_coach) {
 											$coach_id = UserManager::purify_username(api_utf8_decode($course_coach), $purification_option_for_usernames);
 											$coach_id = UserManager::get_user_id_from_username($course_coach);
@@ -477,15 +477,15 @@ if ($_POST['formSent']) {
 														course_code='{$vcourse['code']}',
 														id_session = '$session_id',
 														status = 2 ";
-												$rs_coachs = Database::query($sql, __FILE__, __LINE__);
+												$rs_coachs = Database::query($sql);
 											} else {
 												$error_message .= get_lang('UserDoesNotExist').' : '.$user.'<br />';
 											}
 										}
-								
+
 										// adding users
 										$course_counter++;
-										$users_in_course_counter = 0;									
+										$users_in_course_counter = 0;
 										foreach ($node_course->User as $node_user) {
 											$username = UserManager::purify_username(api_utf8_decode($node_user), $purification_option_for_usernames);
 											$user_id = UserManager::get_user_id_from_username($username);
@@ -494,21 +494,21 @@ if ($_POST['formSent']) {
 												$sql = "INSERT IGNORE INTO $tbl_session_user SET
 														id_user='$user_id',
 														id_session = '$session_id'";
-												$rs_user = Database::query($sql, __FILE__, __LINE__);
+												$rs_user = Database::query($sql);
 												$user_counter++;
 												// Adding to session_rel_user_rel_course table.
 												$sql = "INSERT IGNORE INTO $tbl_session_course_user SET
 														id_user='$user_id',
 														course_code='{$vcourse['code']}',
 														id_session = '$session_id'";
-												$rs_users = Database::query($sql, __FILE__, __LINE__);
+												$rs_users = Database::query($sql);
 												$users_in_course_counter++;
 											} else {
 												$error_message .= get_lang('UserDoesNotExist').' : '.$username.'<br />';
 											}
 										}
 										$update_session_course = "UPDATE $tbl_session_course SET nbr_users='$users_in_course_counter' WHERE course_code='$course_code'";
-										Database::query($update_session_course, __FILE__, __LINE__);
+										Database::query($update_session_course);
 										$inserted_in_course[$course_code] = $course_info['title'];
 
 									}
@@ -520,7 +520,7 @@ if ($_POST['formSent']) {
 								$error_message .= get_lang('CourseDoesNotExist').' : '.$course_code.'<br />';
 							}
 						}
-						Database::query("UPDATE $tbl_session SET nbr_users='$user_counter', nbr_courses='$course_counter' WHERE id='$session_id'", __FILE__, __LINE__);
+						Database::query("UPDATE $tbl_session SET nbr_users='$user_counter', nbr_courses='$course_counter' WHERE id='$session_id'");
 					}
 
 				}
@@ -551,7 +551,7 @@ if ($_POST['formSent']) {
 						}
 					} else {
 						foreach ($enreg as $tag_name) {
-							$tag_names[] = api_eregi_replace('[^a-z0-9_-]', '', $tag_name);
+							$tag_names[] = api_preg_replace('/[^a-zA-Z0-9_\-]/', '', $tag_name);
 						}
 						if (!in_array('SessionName', $tag_names) || !in_array('DateStart', $tag_names) || !in_array('DateEnd', $tag_names)) {
 							$error_message = get_lang('NoNeededData');
@@ -559,7 +559,7 @@ if ($_POST['formSent']) {
 						}
 					}
 				}
-				
+
 				// looping the sessions
 				foreach ($sessions as $enreg) {
 					$user_counter = 0;
@@ -592,7 +592,7 @@ if ($_POST['formSent']) {
 								$suffix = ' - '.$i;
 							}
 							$sql = 'SELECT 1 FROM '.$tbl_session.' WHERE name="'.Database::escape_string($session_name.$suffix).'"';
-							$rs = Database::query($sql, __FILE__, __LINE__);
+							$rs = Database::query($sql);
 
 							if (Database::result($rs, 0, 0)) {
 								$i++;
@@ -609,9 +609,9 @@ if ($_POST['formSent']) {
 								date_start = '$date_start',
 								date_end = '$date_end',
 								visibility = '$visibility',
-								session_category_id = '$session_category_id',				
+								session_category_id = '$session_category_id',
 								session_admin_id=".intval($_user['user_id']);
-						$rs_session = Database::query($sql_session, __FILE__, __LINE__);
+						$rs_session = Database::query($sql_session);
 						$session_id = Database::insert_id();
 						$session_counter++;
 					} else {
@@ -626,8 +626,8 @@ if ($_POST['formSent']) {
 									date_end = '$date_end',
 									visibility = '$visibility',
 									session_category_id = '$session_category_id'";
-								
-							$rs_session = Database::query($sql_session, __FILE__, __LINE__);
+
+							$rs_session = Database::query($sql_session);
 							// We get the last insert id.
 							$my_session_result = SessionManager::get_session_by_name($session_name);
 							$session_id = $my_session_result['id'];
@@ -639,14 +639,14 @@ if ($_POST['formSent']) {
 									date_start = '$date_start',
 									date_end = '$date_end',
 									visibility = '$visibility',
-									session_category_id = '$session_category_id'		
+									session_category_id = '$session_category_id'
 								WHERE name = '$session_name'";
-							$rs_session = Database::query($sql_session, __FILE__, __LINE__);
-							$session_id = Database::query("SELECT id FROM $tbl_session WHERE name='$session_name'", __FILE__, __LINE__);
+							$rs_session = Database::query($sql_session);
+							$session_id = Database::query("SELECT id FROM $tbl_session WHERE name='$session_name'");
 							list($session_id) = Database::fetch_array($session_id);
-							Database::query("DELETE FROM $tbl_session_user WHERE id_session='$session_id'", __FILE__, __LINE__);
-							Database::query("DELETE FROM $tbl_session_course WHERE id_session='$session_id'", __FILE__, __LINE__);
-							Database::query("DELETE FROM $tbl_session_course_user WHERE id_session='$session_id'", __FILE__, __LINE__);
+							Database::query("DELETE FROM $tbl_session_user WHERE id_session='$session_id'");
+							Database::query("DELETE FROM $tbl_session_course WHERE id_session='$session_id'");
+							Database::query("DELETE FROM $tbl_session_course_user WHERE id_session='$session_id'");
 						}
 						$session_counter++;
 					}
@@ -662,7 +662,7 @@ if ($_POST['formSent']) {
 								$sql = "INSERT IGNORE INTO $tbl_session_user SET
 										id_user='$user_id',
 										id_session = '$session_id'";
-								$rs_user = Database::query($sql, __FILE__, __LINE__);
+								$rs_user = Database::query($sql);
 								$user_counter++;
 							}
 						}
@@ -691,22 +691,22 @@ if ($_POST['formSent']) {
 							}
 							// Adding the course to a session
 							$sql_course = "INSERT IGNORE INTO $tbl_session_course SET
-									course_code = '$course_code',									
+									course_code = '$course_code',
 									id_session='$session_id'";
-							$rs_course = Database::query($sql_course, __FILE__, __LINE__);
+							$rs_course = Database::query($sql_course);
 							$course_counter++;
 
-							$course_split = array();							
-							$tok = strtok($course, "[]");							
+							$course_split = array();
+							$tok = strtok($course, "[]");
 							while ($tok !== false) {
 							    $course_split[] = $tok;
 							    $tok = strtok("[]");
 							}
-							
+
 							$course_coachs = explode(",",$course_split[1]);
 							$course_users = explode(",",$course_split[2]);
-							
-							// adding coachs to session course user							
+
+							// adding coachs to session course user
 							foreach ($course_coachs as $course_coach) {
 								$coach_id = UserManager::get_user_id_from_username($course_coach);
 								if ($coach_id !== false) {
@@ -715,12 +715,12 @@ if ($_POST['formSent']) {
 											course_code='$course_code',
 											id_session = '$session_id',
 											status = 2 ";
-									$rs_coachs = Database::query($sql, __FILE__, __LINE__);
+									$rs_coachs = Database::query($sql);
 								} else {
 									$error_message .= get_lang('UserDoesNotExist').' : '.$user.'<br />';
 								}
 							}
-														
+
 							$users_in_course_counter = 0;
 							// Adding the relationship "Session - Course - User".
 							foreach ($course_users as $user) {
@@ -730,14 +730,14 @@ if ($_POST['formSent']) {
 											id_user='$user_id',
 											course_code='$course_code',
 											id_session = '$session_id'";
-									$rs_users = Database::query($sql, __FILE__, __LINE__);
+									$rs_users = Database::query($sql);
 									$users_in_course_counter++;
 								} else {
 									$error_message .= get_lang('UserDoesNotExist').' : '.$user.'<br />';
 								}
 							}
 							$sql = "UPDATE $tbl_session_course SET nbr_users='$users_in_course_counter' WHERE course_code='$course_code'";
-							Database::query($sql,__FILE__,__LINE__);
+							Database::query($sql);
 
 							$course_info = CourseManager::get_course_information($course_code);
 							$inserted_in_course[$course_code] = $course_info['title'];
@@ -748,23 +748,23 @@ if ($_POST['formSent']) {
 						if (CourseManager::course_exists($course_code, true)) {
 
 							$list = CourseManager :: get_courses_info_from_visual_code($course_code);
-							
+
 							foreach ($list as $vcourse) {
-								if ($vcourse['code'] == $course_code) {									
+								if ($vcourse['code'] == $course_code) {
 									// Ignore, this has already been inserted.
 								} else {
-									
+
 									$coach = api_strstr($course, '[');
 									$coach = api_substr($coach, 1, api_strpos($coach,']') - 1);
-																		
+
 									// Adding the relationship "Session - Course".
 									$sql_course = "INSERT IGNORE INTO $tbl_session_course SET
 													course_code = '".$vcourse['code']."',
 													id_session='$session_id'";
-									
-									$rs_course = Database::query($sql_course, __FILE__, __LINE__);
-									
-									// adding coachs to session course user							
+
+									$rs_course = Database::query($sql_course);
+
+									// adding coachs to session course user
 									foreach ($course_coachs as $course_coach) {
 										$coach_id = UserManager::get_user_id_from_username($course_coach);
 										if ($coach_id !== false) {
@@ -773,12 +773,12 @@ if ($_POST['formSent']) {
 													course_code='{$vcourse['code']}',
 													id_session = '$session_id',
 													status = 2 ";
-											$rs_coachs = Database::query($sql, __FILE__, __LINE__);
+											$rs_coachs = Database::query($sql);
 										} else {
 											$error_message .= get_lang('UserDoesNotExist').' : '.$user.'<br />';
 										}
 									}
-																
+
 									$users_in_course_counter = 0;
 									// Adding the relationship "Session - Course - User".
 									foreach ($course_users as $user) {
@@ -788,21 +788,21 @@ if ($_POST['formSent']) {
 													id_user='$user_id',
 													course_code='{$vcourse['code']}',
 													id_session = '$session_id'";
-											$rs_users = Database::query($sql, __FILE__, __LINE__);
+											$rs_users = Database::query($sql);
 											$users_in_course_counter++;
 										} else {
 											$error_message .= get_lang('UserDoesNotExist').' : '.$user.'<br />';
 										}
 									}
-									Database::query("UPDATE $tbl_session_course SET nbr_users='$users_in_course_counter' WHERE course_code='".$vcourse['code']."'", __FILE__, __LINE__);	
+									Database::query("UPDATE $tbl_session_course SET nbr_users='$users_in_course_counter' WHERE course_code='".$vcourse['code']."'");
 								}
 							}
 							$inserted_in_course[$vcourse['code']] = $vcourse['title'];
 						}
 					}
-												
+
 					$sql_update_users = "UPDATE $tbl_session SET nbr_users='$user_counter', nbr_courses='$course_counter' WHERE id='$session_id'";
-					Database::query($sql_update_users, __FILE__, __LINE__);
+					Database::query($sql_update_users);
 				}
 			}
 		}

+ 62 - 54
main/admin/session_list.php

@@ -1,13 +1,15 @@
 <?php
-/* For licensing terms, see /dokeos_license.txt */
+/* For licensing terms, see /license.txt */
 $language_file='admin';
 $cidReset=true;
 
-include('../inc/global.inc.php');
-require_once (api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php');
-require_once (api_get_path(LIBRARY_PATH).'sessionmanager.lib.php');
+require_once '../inc/global.inc.php';
+
+require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php';
+require_once api_get_path(LIBRARY_PATH).'sessionmanager.lib.php';
 
 $this_section = SECTION_PLATFORM_ADMIN;
+
 api_protect_admin_script(true);
 
 $htmlHeadXtra[] = '<script language="javascript">
@@ -28,12 +30,12 @@ $htmlHeadXtra[] = '<script language="javascript">
 				</script>
 		';
 
-$tbl_session=Database::get_main_table(TABLE_MAIN_SESSION);
-$tbl_session_category=Database::get_main_table(TABLE_MAIN_SESSION_CATEGORY);
-$tbl_session_rel_course=Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
+$tbl_session			= Database::get_main_table(TABLE_MAIN_SESSION);
+$tbl_session_category	= Database::get_main_table(TABLE_MAIN_SESSION_CATEGORY);
+$tbl_session_rel_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
 $tbl_session_rel_course_rel_user=Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
-$tbl_session_rel_user=Database::get_main_table(TABLE_MAIN_SESSION_USER);
-$tbl_user = Database::get_main_table(TABLE_MAIN_USER);
+$tbl_session_rel_user 	= Database::get_main_table(TABLE_MAIN_SESSION_USER);
+$tbl_user 				= Database::get_main_table(TABLE_MAIN_USER);
 
 $page=intval($_GET['page']);
 $action=$_REQUEST['action'];
@@ -51,7 +53,7 @@ $interbreadcrumb[]=array("url" => "index.php","name" => get_lang('PlatformAdmin'
 
 //table for the search
 if (isset ($_GET['search']) && $_GET['search'] == 'advanced') {
-	
+
 	$interbreadcrumb[] = array ("url" => 'session_list.php', "name" => get_lang('SessionList'));
 	$tool_name = get_lang('SearchASession');
 	Display :: display_header($tool_name);
@@ -82,39 +84,39 @@ if (isset ($_GET['search']) && $_GET['search'] == 'advanced') {
 	$limit=20;
 	$from=$page * $limit;
 	$where = 'WHERE 1=1 ';
-	
+
 	//Prevent hacking keyword
 	if ( isset ($_GET['keyword'])) {
-		$keyword = Database::escape_string($_GET['keyword']);
+		$keyword = Database::escape_string(trim($_GET['keyword']));
 		} else if (isset ($_GET['keyword_name'])) {
-			$keyword_name = Database::escape_string($_GET['keyword_name']);
-			$keyword_category = Database::escape_string($_GET['keyword_category']);
-			$keyword_visibility = Database::escape_string($_GET['keyword_visibility']);
-			$keyword_firstname = Database::escape_string($_GET['keyword_firstname']);
-			$keyword_lastname = Database::escape_string($_GET['keyword_lastname']);
+			$keyword_name = Database::escape_string(trim($_GET['keyword_name']));
+			$keyword_category = Database::escape_string(trim($_GET['keyword_category']));
+			$keyword_visibility = Database::escape_string(trim($_GET['keyword_visibility']));
+			$keyword_firstname = Database::escape_string(trim($_GET['keyword_firstname']));
+			$keyword_lastname = Database::escape_string(trim($_GET['keyword_lastname']));
 			}
-	
+
 	//Process for the search advanced
 	if (!empty($_REQUEST['keyword_name'])) {
 		$where .= " AND s.name LIKE '%".$keyword_name."%'";
-	} 
-	
+	}
+
 	if (!empty($_REQUEST['keyword_category'])) {
 		$where .= " AND sc.name LIKE '%".$keyword_category."%'";
 	}
-	
+
 	if (!empty($_REQUEST['keyword_visibility']) AND $_REQUEST['keyword_visibility']!='%') {
 		$where .= " AND s.visibility LIKE '%".$keyword_visibility."%'";
 	}
-	
+
 	if (!empty($_REQUEST['keyword_firstname'])) {
 		$where .= " AND u.firstname LIKE '%".$keyword_firstname."%'";
 	}
-	
+
 	if (!empty($_REQUEST['keyword_lastname'])) {
 		$where .= " AND u.lastname LIKE '%".$keyword_lastname."%'";
 	}
-	
+
 	if (isset($_REQUEST['active']) && isset($_REQUEST['inactive'] )) {
 		// if both are set we search all sessions
 		$cond_url = '&amp;active='.Security::remove_XSS($_REQUEST['active']);
@@ -129,56 +131,62 @@ if (isset ($_GET['search']) && $_GET['search'] == 'advanced') {
 			$cond_url = '&amp;inactive='.Security::remove_XSS($_REQUEST['inactive']);
 		}
 	}
-	
+
 	if(isset($_GET['id_category'])){
 		$where.= ' AND ';
-		$id_category = Security::remove_XSS($id_category); 
+		$id_category = Security::remove_XSS($id_category);
 		$where.= ' session_category_id = "'.$id_category.'" ';
-		$cond_url.= '&amp;id_category='.$id_category;	
+		$cond_url.= '&amp;id_category='.$id_category;
+	}
+	
+	$user_id= $_user['user_id'];
+	if (api_is_session_admin()==true) {
+		$where.=" AND s.session_admin_id = $user_id ";
 	}
 	
 	//Get list sessions
 	$sort = ($sort != "name_category")?  's.'.$sort : 'category_name';
 	$query = "SELECT s.id, s.name, s.nbr_courses, s.date_start, s.date_end, u.firstname, u.lastname , sc.name as category_name, s.visibility
-			 FROM $tbl_session s 
-			 	LEFT JOIN  $tbl_session_category sc ON s.session_category_id = sc.id 
+			 FROM $tbl_session s
+			 	LEFT JOIN  $tbl_session_category sc ON s.session_category_id = sc.id
 			 	INNER JOIN $tbl_user u ON s.id_coach = u.user_id 
-			 $where 
+			 $where
 			 ORDER BY $sort ";
 	//query which allows me to get a record without taking into account the page
-	$query_rows = "SELECT count(*) as total_rows 
-			 FROM $tbl_session s 
+	$query_rows = "SELECT count(*) as total_rows
+			 FROM $tbl_session s
 			 	LEFT JOIN  $tbl_session_category sc ON s.session_category_id = sc.id
 			 	INNER JOIN $tbl_user u ON s.id_coach = u.user_id 
 			 $where ";
-
+			 
 //filtering the session list by access_url
 	if ($_configuration['multiple_access_urls'] == true){
-		$table_access_url_rel_session= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);	
+		$table_access_url_rel_session= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
 		$access_url_id = api_get_current_access_url_id();
 		if ($access_url_id != -1) {
 			$where.= " AND ar.access_url_id = $access_url_id ";
 			$query = "SELECT s.id, s.name, s.nbr_courses, s.date_start, s.date_end, u.firstname, u.lastname , sc.name as category_name , s.visibility
-			 FROM $tbl_session s 
+			 FROM $tbl_session s
 			 	LEFT JOIN  $tbl_session_category sc ON s.session_category_id = sc.id
-			 	INNER JOIN $tbl_user u ON s.id_coach = u.user_id 
+			 	INNER JOIN $tbl_user u ON s.id_coach = u.user_id
 				INNER JOIN $table_access_url_rel_session ar ON ar.session_id = s.id
-			 $where 
+			 $where
 			 ORDER BY $sort LIMIT $from,".($limit+1);
 
-			$query_rows = "SELECT count(*) as total_rows 
-			 FROM $tbl_session s 
-			 	LEFT JOIN  $tbl_session_category sc ON s.session_category_id = sc.id  
-			 	INNER JOIN $tbl_user u ON s.id_coach = u.user_id 
-			 	INNER JOIN $table_access_url_rel_session ar ON ar.session_id = s.id 
+			$query_rows = "SELECT count(*) as total_rows
+			 FROM $tbl_session s
+			 	LEFT JOIN  $tbl_session_category sc ON s.session_category_id = sc.id
+			 	INNER JOIN $tbl_user u ON s.id_coach = u.user_id
+			 	INNER JOIN $table_access_url_rel_session ar ON ar.session_id = s.id
 			 $where ";
 		}
 	}
+	
 
-	$result_rows = Database::query($query_rows,__FILE__,__LINE__);
+	$result_rows = Database::query($query_rows);
 	$recorset = Database::fetch_array($result_rows);
 	$num = $recorset['total_rows'];
-	$result=Database::query($query,__FILE__,__LINE__);
+	$result=Database::query($query);
 	$Sessions=Database::store_result($result);
 	$nbr_results=sizeof($Sessions);
 	$tool_name = get_lang('SessionList');
@@ -196,8 +204,8 @@ if (isset ($_GET['search']) && $_GET['search'] == 'advanced') {
 	<?php
 
 	echo '<div style="float:right;">
+		<a href="'.api_get_path(WEB_CODE_PATH).'admin/session_add.php">'.Display::return_icon('view_more_stats.gif',get_lang('AddSession')).get_lang('AddSession').'</a>
 		<a href="'.api_get_path(WEB_CODE_PATH).'admin/add_many_session_to_category.php">'.Display::return_icon('view_more_stats.gif',get_lang('AddSessionsInCategories')).get_lang('AddSessionsInCategories').'</a>
-		<a href="'.api_get_path(WEB_CODE_PATH).'admin/session_add.php">'.Display::return_icon('view_more_stats.gif',get_lang('AddSession')).get_lang('AddSession').'</a>									
 	  </div>';
 	?>
 	<form method="POST" action="session_list.php">
@@ -218,7 +226,7 @@ if (isset ($_GET['search']) && $_GET['search'] == 'advanced') {
 		if($num>$limit){
 			if($page) {
 			?>
-			<a href="<?php echo api_get_self(); ?>?page=<?php echo $page-1; ?>&sort=<?php echo $sort; ?>&keyword=<?php echo $_REQUEST['keyword']; ?><?php echo @$cond_url; ?>"><?php echo get_lang('Previous'); ?></a>
+			<a href="<?php echo api_get_self(); ?>?page=<?php echo $page-1; ?>&sort=<?php echo $sort; ?>&keyword=<?php echo Security::remove_XSS($_REQUEST['keyword']); ?><?php echo @$cond_url; ?>"><?php echo get_lang('Previous'); ?></a>
 			<?php
 			} else {
 				echo get_lang('Previous');
@@ -228,7 +236,7 @@ if (isset ($_GET['search']) && $_GET['search'] == 'advanced') {
 			<?php
 			if($nbr_results > $limit) {
 				?>
-				<a href="<?php echo api_get_self(); ?>?page=<?php echo $page+1; ?>&sort=<?php echo $sort; ?>&keyword=<?php echo $_REQUEST['keyword']; ?><?php echo @$cond_url; ?>"><?php echo get_lang('Next'); ?></a>
+				<a href="<?php echo api_get_self(); ?>?page=<?php echo $page+1; ?>&sort=<?php echo $sort; ?>&keyword=<?php echo Security::remove_XSS($_REQUEST['keyword']); ?><?php echo @$cond_url; ?>"><?php echo get_lang('Next'); ?></a>
 				<?php
 			} else {
 				echo get_lang('Next');
@@ -259,7 +267,7 @@ if (isset ($_GET['search']) && $_GET['search'] == 'advanced') {
 			}
 			$sql = 'SELECT COUNT(course_code) FROM '.$tbl_session_rel_course.' WHERE id_session='.intval($enreg['id']);
 
-		  	$rs = Database::query($sql, __FILE__, __LINE__);
+		  	$rs = Database::query($sql);
 		  	list($nb_courses) = Database::fetch_array($rs);
 
 		?>
@@ -273,7 +281,7 @@ if (isset ($_GET['search']) && $_GET['search'] == 'advanced') {
 	      <td><?php echo api_htmlentities($enreg['date_end'],ENT_QUOTES,$charset); ?></td>
 	      <td><?php echo api_htmlentities(api_get_person_name($enreg['firstname'], $enreg['lastname']),ENT_QUOTES,$charset); ?></td>
 		  <td><?php
-		  
+
 		  switch (intval($enreg['visibility'])) {
 				case SESSION_VISIBLE_READ_ONLY: //1
 					echo get_lang('ReadOnly');
@@ -283,10 +291,10 @@ if (isset ($_GET['search']) && $_GET['search'] == 'advanced') {
 				break;
 				case SESSION_INVISIBLE:			//3
 					echo api_ucfirst(get_lang('Invisible'));
-				break;				 
+				break;
 		  }
-		   
-		  
+
+
 		  ?></td>
 		  <td>
 			<a href="add_users_to_session.php?page=session_list.php&id_session=<?php echo $enreg['id']; ?>"><?php Display::display_icon('add_user_big.gif', get_lang('SubscribeUsersToSession')); ?></a>
@@ -318,7 +326,7 @@ if (isset ($_GET['search']) && $_GET['search'] == 'advanced') {
 			{
 			?>
 
-			<a href="<?php echo api_get_self(); ?>?page=<?php echo $page-1; ?>&sort=<?php echo $sort; ?>&keyword=<?php echo $_REQUEST['keyword']; ?><?php echo @$cond_url; ?>"><?php echo get_lang('Previous'); ?></a>
+			<a href="<?php echo api_get_self(); ?>?page=<?php echo $page-1; ?>&sort=<?php echo $sort; ?>&keyword=<?php echo Security::remove_XSS($_REQUEST['keyword']); ?><?php echo @$cond_url; ?>"><?php echo get_lang('Previous'); ?></a>
 
 			<?php
 			}
@@ -335,7 +343,7 @@ if (isset ($_GET['search']) && $_GET['search'] == 'advanced') {
 			{
 			?>
 
-			<a href="<?php echo api_get_self(); ?>?page=<?php echo $page+1; ?>&sort=<?php echo $sort; ?>&keyword=<?php echo $_REQUEST['keyword']; ?><?php echo @$cond_url; ?>"><?php echo get_lang('Next'); ?></a>
+			<a href="<?php echo api_get_self(); ?>?page=<?php echo $page+1; ?>&sort=<?php echo $sort; ?>&keyword=<?php echo Security::remove_XSS($_REQUEST['keyword']); ?><?php echo @$cond_url; ?>"><?php echo get_lang('Next'); ?></a>
 
 			<?php
 			}

+ 876 - 0
main/admin/settings.lib.php

@@ -0,0 +1,876 @@
+<?php
+/* For licensing terms, see /license.txt */
+/**
+* Library of the settings.php file
+*
+* @author Julio Montoya <gugli100@gmail.com>
+* @author Guillaume Viguier <guillaume@viguierjust.com>
+* 
+* @since Chamilo 1.8.7
+* @package chamilo.admin
+*/
+
+/**
+ * The function that retrieves all the possible settings for a certain config setting
+ * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
+*/
+function get_settings_options($var)
+{
+	$table_settings_options = Database :: get_main_table(TABLE_MAIN_SETTINGS_OPTIONS);
+	$sql = "SELECT * FROM $table_settings_options WHERE variable='$var'";
+	$result = Database::query($sql);
+	while ($row = Database::fetch_array($result))
+	{
+		$temp_array = array ('value' => $row['value'], 'display_text' => $row['display_text']);
+		$settings_options_array[] = $temp_array;
+	}
+	return $settings_options_array;
+}
+
+/**
+ * This function allows easy activating and inactivating of plugins
+ * @todo: a similar function needs to be written to activate or inactivate additional tools.
+ * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
+*/
+function handle_plugins()
+{
+	global $SettingsStored;
+	$userplugins = array();
+	$table_settings_current = Database :: get_main_table(TABLE_MAIN_SETTINGS_CURRENT);
+
+	if (isset($_POST['submit_plugins']))
+	{
+		store_plugins();
+		// add event to system log
+		$time = time();
+		$user_id = api_get_user_id();
+		$category = $_GET['category'];
+		event_system(LOG_CONFIGURATION_SETTINGS_CHANGE, LOG_CONFIGURATION_SETTINGS_CATEGORY, $category, $time, $user_id);
+
+		Display :: display_confirmation_message(get_lang('SettingsStored'));
+	}
+
+	//echo get_lang('AvailablePlugins')."<br/>
+	echo '<br />';
+
+	/* We scan the plugin directory. Each folder is a potential plugin. */
+	$pluginpath = api_get_path(SYS_PLUGIN_PATH);
+
+	$handle = @opendir($pluginpath);
+	while (false !== ($file = readdir($handle)))
+	{
+		if ($file <> '.' AND $file <> '..' AND is_dir(api_get_path(SYS_PLUGIN_PATH).$file))
+		{
+			$possibleplugins[] = $file;
+		}
+	}
+	@closedir($handle);
+
+	/* 	for each of the possible plugin dirs we check if a file plugin.php (that contains all the needed information about this plugin)
+	 	can be found in the dir.
+		this plugin.php file looks like
+		$plugin_info['title']='The title of the plugin'; //
+		$plugin_info['comment']="Some comment about the plugin";
+		$plugin_info['location']=array("loginpage_menu", "campushomepage_menu","banner"); // the possible locations where the plugins can be used
+		$plugin_info['version']='0.1 alpha'; // The version number of the plugin
+		$plugin_info['author']='Patrick Cool'; // The author of the plugin
+	*/
+	echo '<form name="plugins" method="post" action="'.api_get_self().'?category='.$_GET['category'].'">';
+	echo "<table class=\"data_table\">\n";
+	echo "\t<tr>\n";
+	echo "\t\t<th>\n";
+	echo get_lang('Plugin');
+	echo "\t\t</th>\n";
+	echo "\t\t<th>\n";
+	echo get_lang('LoginPageMainArea');
+	echo "\t\t</th>\n";
+	echo "\t\t<th>\n";
+	echo get_lang('LoginPageMenu');
+	echo "\t\t</th>\n";
+	echo "\t\t<th>\n";
+	echo get_lang('CampusHomepageMainArea');
+	echo "\t\t</th>\n";
+	echo "\t\t<th>\n";
+	echo get_lang('CampusHomepageMenu');
+	echo "\t\t</th>\n";
+	echo "\t\t<th>\n";
+	echo get_lang('MyCoursesMainArea');
+	echo "\t\t</th>\n";
+	echo "\t\t<th>\n";
+	echo get_lang('MyCoursesMenu');
+	echo "\t\t</th>\n";
+	echo "\t\t<th>\n";
+	echo get_lang('Header');
+	echo "\t\t</th>\n";
+	echo "\t\t<th>\n";
+	echo get_lang('Footer');
+	echo "\t\t</th>\n";
+	echo "\t</tr>\n";
+
+	/* We retrieve all the active plugins. */
+	//$sql = "SELECT * FROM $table_settings_current WHERE category='Plugins'";
+	//$result = Database::query($sql);
+	$result = api_get_settings('Plugins');
+	//while ($row = Database::fetch_array($result))
+	foreach($result as $row)
+	{
+		$usedplugins[$row['variable']][] = $row['selected_value'];
+	}
+
+	/* We display all the possible plugins and the checkboxes */
+	foreach ($possibleplugins as $testplugin)
+	{
+		$plugin_info_file = api_get_path(SYS_PLUGIN_PATH).$testplugin."/plugin.php";
+		if (file_exists($plugin_info_file))
+		{
+			$plugin_info = array();
+			include ($plugin_info_file);
+
+			echo "\t<tr>\n";
+			echo "\t\t<td>\n";
+			foreach ($plugin_info as $key => $value)
+			{
+				if ($key <> 'location')
+				{
+					if ($key == 'title')
+					{
+						$value = '<strong>'.$value.'</strong>';
+					}
+					echo get_lang(ucwords($key)).': '.$value.'<br />';
+				}
+			}
+			if (file_exists(api_get_path(SYS_PLUGIN_PATH).$testplugin.'/readme.txt'))
+			{
+				echo "<a href='".api_get_path(WEB_PLUGIN_PATH).$testplugin."/readme.txt'>readme.txt</a>";
+			}
+			echo "\t\t</td>\n";
+
+			// column: LoginPageMainArea
+			if(empty($usedplugins))
+			{
+				$usedplugins = array();
+			}
+			display_plugin_cell('loginpage_main', $plugin_info, $testplugin, $usedplugins);
+			display_plugin_cell('loginpage_menu', $plugin_info, $testplugin, $usedplugins);
+			display_plugin_cell('campushomepage_main', $plugin_info, $testplugin, $usedplugins);
+			display_plugin_cell('campushomepage_menu', $plugin_info, $testplugin, $usedplugins);
+			display_plugin_cell('mycourses_main', $plugin_info, $testplugin, $usedplugins);
+			display_plugin_cell('mycourses_menu', $plugin_info, $testplugin, $usedplugins);
+			display_plugin_cell('header', $plugin_info, $testplugin, $usedplugins);
+			display_plugin_cell('footer', $plugin_info, $testplugin, $usedplugins);
+			echo "\t</tr>\n";
+				}
+				}
+	echo '</table>';
+	echo '<br />';
+	echo '<button class="save" type="submit" name="submit_plugins">'.get_lang('EnablePlugins').'</button></form>';
+	echo '<br />';
+}
+
+
+function display_plugin_cell($location, $plugin_info, $current_plugin, $active_plugins)
+{
+	echo "\t\t<td align=\"center\">\n";
+	if (in_array($location, $plugin_info['location']))
+	{
+		if (isset($active_plugins[$location]) && is_array($active_plugins[$location])
+			&& in_array($current_plugin, $active_plugins[$location]))
+		{
+			$checked = "checked";
+		}
+		else
+		{
+			$checked = '';
+		}
+		echo '<input type="checkbox" name="'.$current_plugin.'-'.$location.'" value="true" '.$checked.'/>';
+	}
+	echo "\t\t</td>\n";
+}
+
+/**
+ * This function allows the platform admin to choose the default stylesheet
+ * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
+ * @author Julio Montoya <gugli100@gmail.com>, Chamilo
+*/
+function handle_stylesheets()
+{
+	global $_configuration;
+	// Current style
+	$currentstyle = api_get_setting('stylesheets');
+	$is_style_changeable=false;
+
+	if ($_configuration['access_url']!=1) {
+		$style_info = api_get_settings('stylesheets','',1,0);
+		$url_info = api_get_access_url($_configuration['access_url']);
+		if ($style_info[0]['access_url_changeable']==1 && $url_info['active']==1) {
+			$is_style_changeable=true;
+			echo '<div class="actions" id="stylesheetuploadlink">';
+			Display::display_icon('theme_add.gif');
+			echo '<a href="" onclick="document.getElementById(\'newstylesheetform\').style.display = \'block\'; document.getElementById(\'stylesheetuploadlink\').style.display = \'none\';return false; ">'.get_lang('UploadNewStylesheet').'</a>';
+			echo '</div>';
+		}
+	} else {
+		$is_style_changeable=true;
+		echo '<div class="actions" id="stylesheetuploadlink">';
+		Display::display_icon('theme_add.gif');
+		echo '<a href="" onclick="document.getElementById(\'newstylesheetform\').style.display = \'block\'; document.getElementById(\'stylesheetuploadlink\').style.display = \'none\';return false; ">'.get_lang('UploadNewStylesheet').'</a>';
+		echo '</div>';
+	}
+
+	$form = new FormValidator('stylesheet_upload','post','settings.php?category=stylesheets&showuploadform=true');
+	$form->addElement('text','name_stylesheet',get_lang('NameStylesheet'),array('size' => '40', 'maxlength' => '40'));
+	$form->addRule('name_stylesheet', get_lang('ThisFieldIsRequired'), 'required');
+	$form->addElement('file', 'new_stylesheet', get_lang('UploadNewStylesheet'));
+	$allowed_file_types = array ('css');
+	$form->addRule('new_stylesheet', get_lang('InvalidExtension').' ('.implode(',', $allowed_file_types).')', 'filetype', $allowed_file_types);
+	$form->addRule('new_stylesheet', get_lang('ThisFieldIsRequired'), 'required');
+	$form->addElement('style_submit_button', 'stylesheet_upload', get_lang('Ok'), array('class'=>'save'));
+	if( $form->validate() AND is_writable(api_get_path(SYS_CODE_PATH).'css/')) {
+		$values = $form->exportValues();
+		$picture_element = & $form->getElement('new_stylesheet');
+		$picture = $picture_element->getValue();
+		upload_stylesheet($values, $picture);
+
+		// add event to system log
+		$time = time();
+		$user_id = api_get_user_id();
+		$category = $_GET['category'];
+		event_system(LOG_CONFIGURATION_SETTINGS_CHANGE, LOG_CONFIGURATION_SETTINGS_CATEGORY, $category, $time, $user_id);
+
+		Display::display_confirmation_message(get_lang('StylesheetAdded'));
+	} else {
+		if (!is_writable(api_get_path(SYS_CODE_PATH).'css/'))
+		{
+			Display::display_error_message(api_get_path(SYS_CODE_PATH).'css/'.get_lang('IsNotWritable'));
+		}
+		else
+		{
+			if ($_GET['showuploadform'] == 'true')
+			{
+				echo '<div id="newstylesheetform">';
+			}
+			else
+			{
+				echo '<div id="newstylesheetform" style="display: none;">';
+			}
+				// uploading a new stylesheet
+			if ($_configuration['access_url']==1)
+			{
+				$form->display();
+			}
+			else
+			{
+				if ($is_style_changeable)
+				{
+					$form->display();
+				}
+			}
+			echo '</div>';
+		}
+	}
+
+	// Preview of the stylesheet
+	echo '<div><iframe src="style_preview.php" width="100%" height="300" name="preview"></iframe></div>';
+
+?>
+	<script type="text/javascript">
+	function load_preview(selectobj){
+		var style_dir = selectobj.options[selectobj.selectedIndex].value;
+	 	parent.preview.location='style_preview.php?style=' + style_dir;
+	}
+	</script>
+<?php
+	echo '<form name="stylesheets" method="post" action="'.api_get_self().'?category='.Security::remove_XSS($_GET['category']).'">';
+	echo '<br /><select name="style" onChange="load_preview(this)" >';
+	
+	$list_of_styles = array();
+	$list_of_names  = array();
+	
+	if ($handle = @opendir(api_get_path(SYS_PATH).'main/css/')) {
+		$counter=1;
+		while (false !== ($style_dir = readdir($handle))) {
+			if(substr($style_dir,0,1)=='.') { //skip dirs starting with a '.'
+				continue;
+			}
+			$dirpath = api_get_path(SYS_PATH).'main/css/'.$style_dir;
+			if (is_dir($dirpath)) {
+				if ($style_dir != '.' && $style_dir != '..') {
+					if ($currentstyle == $style_dir OR ($style_dir == 'dokeos_classic' AND !$currentstyle)) {
+						$selected = 'selected="true"';
+					} else {
+						$selected = '';
+					}
+					$show_name=ucwords(str_replace('_',' ', $style_dir));
+
+					if ($is_style_changeable) {
+						$list_of_styles[$style_dir] = "<option  value=\"".$style_dir."\" ".$selected." /> $show_name </option>";
+						$list_of_names[$style_dir]  = $show_name;						
+						//echo "<input type=\"radio\" name=\"style\" value=\"".$style_dir."\" ".$selected." onClick=\"parent.preview.location='style_preview.php?style=".$style_dir."';\"/>";
+						//echo '<a href="style_preview.php?style='.$style_dir.'" target="preview">'.$show_name.'</a>';
+					} else {
+						echo '<a href="style_preview.php?style='.$style_dir.'" target="preview">'.$show_name.'</a>';
+					}
+					echo "<br />\n";
+					$counter++;
+				}
+			}
+		}
+		@closedir($handle);
+	}
+	//Sort styles in alphabetical order
+	asort($list_of_names);	
+	foreach($list_of_names as $style_dir=>$item) {
+		echo $list_of_styles[$style_dir];
+	}
+	
+	echo '</select><br />';
+	//var_dump($list_of_names);
+	if ($is_style_changeable){
+		echo '<button class="save" type="submit" name="submit_stylesheets"> '.get_lang('SaveSettings').' </button></form>';
+	}
+}
+
+/**
+ * creates the folder (if needed) and uploads the stylesheet in it
+ *
+ * @param array $values the values of the form
+ * @param array $picture the values of the uploaded file
+ *
+ * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University, Belgium
+ * @version May 2008
+ * @since Dokeos 1.8.5
+ */
+function upload_stylesheet($values,$picture)
+{
+	// valid name for the stylesheet folder
+	$style_name = api_preg_replace('/[^A-Za-z0-9]/', '', $values['name_stylesheet']);
+
+	// create the folder if needed
+	if (!is_dir(api_get_path(SYS_CODE_PATH).'css/'.$style_name.'/'))
+	{
+		mkdir(api_get_path(SYS_CODE_PATH).'css/'.$style_name.'/', api_get_permissions_for_new_directories());
+	}
+
+	// move the file in the folder
+	move_uploaded_file($picture['tmp_name'], api_get_path(SYS_CODE_PATH).'css/'.$style_name.'/'.$picture['name']);
+}
+
+/**
+ * This function allows easy activating and inactivating of plugins
+ * @todo: a similar function needs to be written to activate or inactivate additional tools.
+ * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
+*/
+function store_plugins()
+{
+	$table_settings_current = Database :: get_main_table(TABLE_MAIN_SETTINGS_CURRENT);
+	global $_configuration;
+
+	// Step 1 : we remove all the plugins
+	//$sql = "DELETE FROM $table_settings_current WHERE category='Plugins'";
+	//Database::query($sql);
+	$r = api_delete_category_settings('Plugins',$_configuration['access_url']);
+
+	// step 2: looping through all the post values we only store these which are really a valid plugin location.
+	foreach ($_POST as $form_name => $formvalue)
+	{
+		$form_name_elements = explode("-", $form_name);
+		if (is_valid_plugin_location($form_name_elements[1]))
+		{
+			//$sql = "INSERT into $table_settings_current (variable,category,selected_value) VALUES ('".$form_name_elements['1']."','Plugins','".$form_name_elements['0']."')";
+			//Database::query($sql);
+			api_add_setting($form_name_elements['0'],$form_name_elements['1'],$form_name_elements['0'],null,'Plugins',$form_name_elements['0'],null,null,null,$_configuration['access_url'],1);
+		}
+	}
+}
+
+/**
+ * Check if the post information is really a valid plugin location.
+ * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
+*/
+function is_valid_plugin_location($location)
+{
+	$valid_locations=array('loginpage_main', 'loginpage_menu', 'campushomepage_main', 'campushomepage_menu', 'mycourses_main', 'mycourses_menu','header', 'footer');
+	if (in_array($location, $valid_locations))
+	{
+		return true;
+	}
+	else
+	{
+		return false;
+	}
+}
+
+
+/**
+ * This function allows the platform admin to choose which should be the default stylesheet
+ * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
+*/
+function store_stylesheets()
+{
+	global $_configuration;
+	// Database Table Definitions
+	$table_settings_current = Database :: get_main_table(TABLE_MAIN_SETTINGS_CURRENT);
+
+	// Insert the stylesheet
+	$style = Database::escape_string($_POST['style']);
+	if (is_style($style))
+	{
+		/*
+		$sql = 'UPDATE '.$table_settings_current.' SET
+				selected_value = "'.$style.'"
+				WHERE variable = "stylesheets"
+				AND category = "stylesheets"';
+
+		Database::query($sql);
+		*/
+
+		api_set_setting('stylesheets',$style,null,'stylesheets',$_configuration['access_url']);
+	}
+
+	return true;
+}
+
+/**
+ * This function checks if the given style is a recognize style that exists in the css directory as
+ * a standalone directory.
+ * @param	string	Style
+ * @return	bool	True if this style is recognized, false otherwise
+ */
+function is_style($style)
+{
+	$dir = api_get_path(SYS_PATH).'main/css/';
+	$dirs = scandir($dir);
+	$style = str_replace(array('/','\\'),array('',''),$style); //avoid slashes or backslashes
+	if (in_array($style,$dirs) && is_dir($dir.$style))
+	{
+		return true;
+	}
+	return false;
+}
+
+/**
+ * Search options
+ * TODO: support for multiple site. aka $_configuration['access_url'] == 1
+ * @author Marco Villegas <marvil07@gmail.com>
+ */
+function handle_search() {
+    global $SettingsStored, $_configuration;
+
+    $search_enabled = api_get_setting('search_enabled');
+    $settings = api_get_settings('Search');
+
+    if ($search_enabled !== 'true' || count($settings) < 1) {
+        Display::display_error_message(get_lang('SearchFeatureNotEnabledComment'));
+        return;
+    }
+
+    require_once api_get_path(LIBRARY_PATH) . 'specific_fields_manager.lib.php';
+
+    $form = new FormValidator('search-options', 'post', api_get_self().'?category=Search');
+    $renderer = & $form->defaultRenderer();
+    $renderer->setHeaderTemplate('<div class="sectiontitle">{header}</div>'."\n");
+    $renderer->setElementTemplate('<div class="sectioncomment">{label}</div>'."\n".'<div class="sectionvalue">{element}</div>'."\n");
+
+    //search_show_unlinked_results
+    $form->addElement('header', null, get_lang('SearchShowUnlinkedResultsTitle'));
+    $form->addElement('label', null, get_lang('SearchShowUnlinkedResultsComment'));
+    $values = get_settings_options('search_show_unlinked_results');
+    $group = array ();
+    foreach ($values as $key => $value) {
+        $element = & $form->createElement('radio', 'search_show_unlinked_results', '', get_lang($value['display_text']), $value['value']);
+        $group[] = $element;
+    }
+    $form->addGroup($group, 'search_show_unlinked_results', get_lang('SearchShowUnlinkedResultsComment'), '<br />', false);
+    $default_values['search_show_unlinked_results'] = api_get_setting('search_show_unlinked_results');
+
+    //search_prefilter_prefix
+    $form->addElement('header', null, get_lang('SearchPrefilterPrefix'));
+    $form->addElement('label', null, get_lang('SearchPrefilterPrefixComment'));
+    $specific_fields = get_specific_field_list();
+    $sf_values = array();
+    foreach ($specific_fields as $sf) {
+       $sf_values[$sf['code']] = $sf['name'];
+    }
+    $group = array ();
+    $form->addElement('select', 'search_prefilter_prefix', get_lang('SearchPrefilterPrefix'), $sf_values, '');
+    $default_values['search_prefilter_prefix'] = api_get_setting('search_prefilter_prefix');
+
+    //$form->addRule('search_show_unlinked_results', get_lang('ThisFieldIsRequired'), 'required');
+    $form->addElement('style_submit_button', 'search-options-save', get_lang('Ok'));
+    $form->setDefaults($default_values);
+
+    if( $form->validate()) {
+        $formvalues = $form->exportValues();
+        $r = api_set_settings_category('Search','false',$_configuration['access_url']);
+        // Save the settings
+        foreach ($formvalues as $key => $value)
+        {
+        	$result = api_set_setting($key, $value, null, null);
+        }
+
+        Display :: display_confirmation_message($SettingsStored);
+    } else {
+        echo '<div id="search-options-form">';
+        $form->display();
+        echo '</div>';
+    }
+}
+
+/**
+ * wrapper for the templates
+ *
+ * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University, Belgium
+ * @version August 2008
+ * @since Dokeos 1.8.6
+ */
+function handle_templates()
+{
+	if ($_GET['action'] != 'add') {
+		echo "\n<div class=\"actions\" style=\"margin-left:1px\" >";
+		echo '<a href="settings.php?category=Templates&amp;action=add">'.Display::return_icon('template_add.gif', get_lang('AddTemplate')).get_lang('AddTemplate').'</a>';
+		echo "\n</div>";
+	}
+
+	if ($_GET['action'] == 'add' OR ( $_GET['action'] == 'edit' AND is_numeric($_GET['id']))) {
+		add_edit_template();
+
+		// add event to system log
+		$time = time();
+		$user_id = api_get_user_id();
+		$category = $_GET['category'];
+		event_system(LOG_CONFIGURATION_SETTINGS_CHANGE, LOG_CONFIGURATION_SETTINGS_CATEGORY, $category, $time, $user_id);
+
+	} else {
+		if ($_GET['action'] == 'delete' and is_numeric($_GET['id'])) {
+			delete_template($_GET['id']);
+
+			// add event to system log
+			$time = time();
+			$user_id = api_get_user_id();
+			$category = $_GET['category'];
+			event_system(LOG_CONFIGURATION_SETTINGS_CHANGE, LOG_CONFIGURATION_SETTINGS_CATEGORY, $category, $time, $user_id);
+		}
+		display_templates();
+	}
+}
+
+/**
+ * Display a sortable table with all the templates that the platform administrator has defined.
+ *
+ * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University, Belgium
+ * @version August 2008
+ * @since Dokeos 1.8.6
+ */
+function display_templates()
+{
+	$table = new SortableTable('templates', 'get_number_of_templates', 'get_template_data',1);
+	$table->set_additional_parameters(array('category'=>Security::remove_XSS($_GET['category'])));
+	$table->set_header(0, get_lang('Image'), true, array ('style' => 'width:101px;'));
+	$table->set_header(1, get_lang('Title'));
+	$table->set_header(2, get_lang('Actions'), false, array ('style' => 'width:50px;'));
+	$table->set_column_filter(2,'actions_filter');
+	$table->set_column_filter(0,'image_filter');
+	$table->display();
+}
+
+/**
+ * Get the number of templates that are defined by the platform admin.
+ *
+ * @return integer
+ *
+ * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University, Belgium
+ * @version August 2008
+ * @since Dokeos 1.8.6
+ */
+function get_number_of_templates()
+{
+	// Database table definition
+	$table_system_template = Database :: get_main_table('system_template');
+
+	// The sql statement
+	$sql = "SELECT COUNT(id) AS total FROM $table_system_template";
+	$result = Database::query($sql);
+	$row = Database::fetch_array($result);
+
+	// returning the number of templates
+	return $row['total'];
+}
+
+/**
+ * Get all the template data for the sortable table
+ *
+ * @param integer $from the start of the limit statement
+ * @param integer $number_of_items the number of elements that have to be retrieved from the database
+ * @param integer $column the column that is
+ * @param string $direction the sorting direction (ASC or DESC�
+ * @return array
+ *
+ * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University, Belgium
+ * @version August 2008
+ * @since Dokeos 1.8.6
+ */
+function get_template_data($from, $number_of_items, $column, $direction)
+{
+	// Database table definition
+	$table_system_template = Database :: get_main_table('system_template');
+
+	// the sql statement
+	$sql = "SELECT image as col0, title as col1, id as col2 FROM $table_system_template";
+	$sql .= " ORDER BY col$column $direction ";
+	$sql .= " LIMIT $from,$number_of_items";
+	$result = Database::query($sql);
+	while ($row = Database::fetch_array($result)) {
+		$row['1'] = get_lang($row['1']);
+		$return[] = $row;
+	}
+	// returning all the information for the sortable table
+	return $return;
+}
+
+/**
+ * display the edit and delete icons in the sortable table
+ *
+ * @param integer $id the id of the template
+ * @return html code for the link to edit and delete the template
+ *
+ * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University, Belgium
+ * @version August 2008
+ * @since Dokeos 1.8.6
+ */
+function actions_filter($id)
+{
+	$return .= '<a href="settings.php?category=Templates&amp;action=edit&amp;id='.Security::remove_XSS($id).'">'.Display::return_icon('edit.gif', get_lang('Edit')).'</a>';
+	$return .= '<a href="settings.php?category=Templates&amp;action=delete&amp;id='.Security::remove_XSS($id).'" onclick="javascript:if(!confirm('."'".get_lang("ConfirmYourChoice")."'".')) return false;">'.Display::return_icon('delete.gif', get_lang('Delete')).'</a>';
+	return $return;
+}
+
+/**
+ * Display the image of the template in the sortable table
+ *
+ * @param string $image the image
+ * @return html code for the image
+ *
+ * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University, Belgium
+ * @version August 2008
+ * @since Dokeos 1.8.6
+ */
+function image_filter($image)
+{
+	if (!empty($image))
+	{
+		return '<img src="'.api_get_path(WEB_PATH).'home/default_platform_document/template_thumb/'.$image.'" alt="'.get_lang('TemplatePreview').'"/>';
+	}
+	else
+	{
+		return '<img src="'.api_get_path(WEB_PATH).'home/default_platform_document/template_thumb/noimage.gif" alt="'.get_lang('NoTemplatePreview').'"/>';
+	}
+}
+
+/**
+ * Add (or edit) a template. This function displays the form and also takes care of uploading the image and storing the information in the database
+ *
+ * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University, Belgium
+ * @version August 2008
+ * @since Dokeos 1.8.6
+ */
+function add_edit_template()
+{
+	// initiate the object
+	$form = new FormValidator('template', 'post', 'settings.php?category=Templates&action='.Security::remove_XSS($_GET['action']).'&id='.Security::remove_XSS($_GET['id']));
+
+	// settting the form elements: the header
+	if ($_GET['action'] == 'add') {
+		$title = get_lang('AddTemplate');
+	}
+	else
+	{
+		$title = get_lang('EditTemplate');
+	}
+	$form->addElement('header', '', $title);
+
+	// settting the form elements: the title of the template
+	$form->add_textfield('title', get_lang('Title'), false);
+
+	// settting the form elements: the content of the template (wysiwyg editor)
+	$form->addElement('html_editor', 'template_text', get_lang('Text'), null, array('ToolbarSet' => 'AdminTemplates', 'Width' => '100%', 'Height' => '400'));
+
+	// settting the form elements: the form to upload an image to be used with the template
+	$form->addElement('file','template_image',get_lang('Image'),'');
+
+	// settting the form elements: a little bit information about the template image
+	$form->addElement('static', 'file_comment', '', get_lang('TemplateImageComment100x70'));
+
+	// getting all the information of the template when editing a template
+	if ($_GET['action'] == 'edit') {
+		// Database table definition
+		$table_system_template = Database :: get_main_table('system_template');
+		$sql = "SELECT * FROM $table_system_template WHERE id = '".Database::escape_string($_GET['id'])."'";
+		$result = Database::query($sql);
+		$row = Database::fetch_array($result);
+
+		$defaults['template_id'] 	= intval($_GET['id']);
+		$defaults['template_text'] 	= $row['content'];
+		//forcing a get_lang
+		$defaults['title'] 			= get_lang($row['title']);
+
+		// adding an extra field: a hidden field with the id of the template we are editing
+		$form->addElement('hidden','template_id');
+
+		// adding an extra field: a preview of the image that is currently used
+		if (!empty($row['image']))
+		{
+			$form->addElement('static','template_image_preview', '', '<img src="'.api_get_path(WEB_PATH).'home/default_platform_document/template_thumb/'.$row['image'].'" alt="'.get_lang('TemplatePreview').'"/>');
+		}
+		else
+		{
+			$form->addElement('static','template_image_preview', '', '<img src="'.api_get_path(WEB_PATH).'home/default_platform_document/template_thumb/noimage.gif" alt="'.get_lang('NoTemplatePreview').'"/>');
+		}
+
+		// setting the information of the template that we are editing
+		$form->setDefaults($defaults);
+	}
+		// settting the form elements: the submit button
+	$form->addElement('style_submit_button' , 'submit', get_lang('Ok') ,'class="save"');
+
+	// setting the rules: the required fields
+	$form->addRule('title', '<div class="required">'.get_lang('ThisFieldIsRequired'), 'required');
+	$form->addRule('template_text', '<div class="required">'.get_lang('ThisFieldIsRequired'), 'required');
+
+	// if the form validates (complies to all rules) we save the information, else we display the form again (with error message if needed)
+	if( $form->validate() )
+	{
+
+		$check = Security::check_token('post');
+		if ($check) {
+			// exporting the values
+			$values = $form->exportValues();
+			// upload the file
+			if (!empty($_FILES['template_image']['name']))
+			{
+				include_once (api_get_path(LIBRARY_PATH).'fileUpload.lib.php');
+				$upload_ok = process_uploaded_file($_FILES['template_image']);
+
+				if ($upload_ok)
+				{
+					// Try to add an extension to the file if it hasn't one
+					$new_file_name = add_ext_on_mime(stripslashes($_FILES['template_image']['name']), $_FILES['template_image']['type']);
+
+					// upload dir
+					$upload_dir = api_get_path(SYS_PATH).'home/default_platform_document/template_thumb/';
+
+					// create dir if not exists
+					if (!is_dir($upload_dir)) {
+						mkdir($upload_dir, api_get_permissions_for_new_directories());
+					}
+
+					// resize image to max default and upload
+					require_once (api_get_path(LIBRARY_PATH).'image.lib.php');
+					$temp = new image($_FILES['template_image']['tmp_name']);
+					$picture_infos=@getimagesize($_FILES['template_image']['tmp_name']);
+
+					$max_width_for_picture = 100;
+
+					if ($picture_infos[0]>$max_width_for_picture)
+					{
+						$thumbwidth = $max_width_for_picture;
+						if (empty($thumbwidth) or $thumbwidth==0) {
+						  $thumbwidth=$max_width_for_picture;
+						}
+						$new_height = round(($thumbwidth/$picture_infos[0])*$picture_infos[1]);
+
+						$temp->resize($thumbwidth,$new_height,0);
+					}
+
+					$type=$picture_infos[2];
+
+					switch (!empty($type))
+					{
+						case 2 : $temp->send_image('JPG',$upload_dir.$new_file_name);
+								 break;
+						case 3 : $temp->send_image('PNG',$upload_dir.$new_file_name);
+								 break;
+						case 1 : $temp->send_image('GIF',$upload_dir.$new_file_name);
+								 break;
+					}
+				}
+		   }
+
+		   // store the information in the database (as insert or as update)
+		   $table_system_template = Database :: get_main_table('system_template');
+		   if ($_GET['action'] == 'add') {
+		   		$content_template = '<head>{CSS}<style type="text/css">.text{font-weight: normal;}</style></head><body>'.Database::escape_string($values['template_text']).'</body>';
+			   	$sql = "INSERT INTO $table_system_template (title, content, image) VALUES ('".Database::escape_string($values['title'])."','".$content_template."','".Database::escape_string($new_file_name)."')";
+			   	$result = Database::query($sql);
+
+			   	// display a feedback message
+			   	Display::display_confirmation_message(get_lang('TemplateAdded'));
+			   	echo '<a href="settings.php?category=Templates&amp;action=add">'.Display::return_icon('template_add.gif', get_lang('AddTemplate')).get_lang('AddTemplate').'</a>';
+		   } else {
+		   		$content_template = '<head>{CSS}<style type="text/css">.text{font-weight: normal;}</style></head><body>'.Database::escape_string($values['template_text']).'</body>';
+			   	$sql = "UPDATE $table_system_template set title = '".Database::escape_string($values['title'])."',
+												   		  content = '".$content_template."'";
+			   	if (!empty($new_file_name))
+			   	{
+			   		$sql .= ", image = '".Database::escape_string($new_file_name)."'";
+			   	}
+			   	$sql .= " WHERE id='".Database::escape_string($_GET['id'])."'";
+			   	$result = Database::query($sql);
+
+			   	// display a feedback message
+			   	Display::display_confirmation_message(get_lang('TemplateEdited'));
+		   }
+
+		}
+	   Security::clear_token();
+	   display_templates();
+	}
+	else
+	{
+		$token = Security::get_token();
+		$form->addElement('hidden','sec_token');
+		$form->setConstants(array('sec_token' => $token));
+		// display the form
+		$form->display();
+	}
+}
+
+/**
+ * Delete a template
+ *
+ * @param integer $id the id of the template that has to be deleted
+ *
+ * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University, Belgium
+ * @version August 2008
+ * @since Dokeos 1.8.6
+ */
+function delete_template($id)
+{
+	// first we remove the image
+	$table_system_template = Database :: get_main_table('system_template');
+	$sql = "SELECT * FROM $table_system_template WHERE id = '".Database::escape_string($id)."'";
+	$result = Database::query($sql);
+	$row = Database::fetch_array($result);
+	if (!empty($row['image']))
+	{
+		@unlink(api_get_path(SYS_PATH).'home/default_platform_document/template_thumb/'.$row['image']);
+	}
+
+	// now we remove it from the database
+	$sql = "DELETE FROM $table_system_template WHERE id = '".Database::escape_string($id)."'";
+	$result = Database::query($sql);
+
+	// display a feedback message
+	Display::display_confirmation_message(get_lang('TemplateDeleted'));
+}
+
+/**
+ * Returns the list of timezone identifiers used to populate the select
+ *
+ * @return array List of timezone identifiers
+ *
+ * @author Guillaume Viguier <guillaume.viguier@beeznest.com>
+ * @since Chamilo 1.8.7
+ */
+function select_timezone_value() {
+	return api_get_timezones();
+}

+ 94 - 970
main/admin/settings.php

@@ -1,46 +1,15 @@
-<?php // $Id: settings.php 22316 2009-07-23 16:18:33Z cfasanando $
-/*
-==============================================================================
-	Dokeos - elearning and course management software
-
-	Copyright (c) 2004-2009 Dokeos SPRL
-	Copyright (c) 2003 Ghent University
-	Copyright (c) Patrick Cool, Ghent University
-	Copyright (c) Julio Montoya, Dokeos
-	Copyright (c) Roan Embrechts, Vrije Universiteit Brussel
-	Copyright (c) Bart Mollet, Hogeschool Gent
-
-	For a full list of contributors, see "credits.txt".
-	The full license can be read in "license.txt".
-
-	This program is free software; you can redistribute it and/or
-	modify it under the terms of the GNU General Public License
-	as published by the Free Software Foundation; either version 2
-	of the License, or (at your option) any later version.
-
-	See the GNU General Public License for more details.
-
-	Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
-	Mail: info@dokeos.com
-==============================================================================
-*/
+<?php
+/* For licensing terms, see /license.txt */
 /**
-==============================================================================
 * With this tool you can easily adjust non critical configuration settings.
 * Non critical means that changing them will not result in a broken campus.
 *
 * @author Patrick Cool
-* @since Dokeos 1.6
 * @author Julio Montoya - Multiple URL site
-* @package dokeos.admin
-==============================================================================
+* @package chamilo.admin
 */
 
-/*
-==============================================================================
-		INIT SECTION
-==============================================================================
-*/
+/*		INIT SECTION	*/
 // name of the language file that needs to be included
 if ($_GET['category']=='Templates') {
 	$language_file = array('admin','document');
@@ -50,10 +19,13 @@ if ($_GET['category']=='Templates') {
 // resetting the course id
 $cidReset=true;
 // including some necessary dokeos files
-include_once ('../inc/global.inc.php');
-require_once (api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php');
-require_once (api_get_path(LIBRARY_PATH).'fileManage.lib.php');
-require_once (api_get_path(LIBRARY_PATH).'fileUpload.lib.php');
+require_once '../inc/global.inc.php';
+require_once api_get_path(LIBRARY_PATH).'sortabletable.class.php';
+require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php';
+require_once api_get_path(LIBRARY_PATH).'fileManage.lib.php';
+require_once api_get_path(LIBRARY_PATH).'fileUpload.lib.php';
+require_once api_get_path(LIBRARY_PATH).'dashboard.lib.php';
+require_once 'settings.lib.php';
 
 // setting the section (for the tabs)
 $this_section = SECTION_PLATFORM_ADMIN;
@@ -63,8 +35,7 @@ $_SESSION['this_section'] = $this_section;
 api_protect_admin_script();
 
 // Submit Stylesheets
-if (isset($_POST['submit_stylesheets']))
-{
+if (isset($_POST['submit_stylesheets'])) {
 	$message = store_stylesheets();
 	header("Location: ".api_get_self()."?category=stylesheets");
 	exit;
@@ -80,8 +51,7 @@ $interbreadcrumb[] = array ("url" => 'index.php', "name" => get_lang('PlatformAd
 $tool_name = get_lang('DokeosConfigSettings');
 
 // Build the form
-if (!empty($_GET['category']) && !in_array($_GET['category'], array('Plugins', 'stylesheets', 'Search')))
-{
+if (!empty($_GET['category']) && !in_array($_GET['category'], array('Plugins', 'stylesheets', 'Search'))) {
 	$form = new FormValidator('settings', 'post', 'settings.php?category='.$_GET['category']);
 	$renderer = & $form->defaultRenderer();
 	$renderer->setHeaderTemplate('<div class="sectiontitle">{header}</div>'."\n");
@@ -89,18 +59,14 @@ if (!empty($_GET['category']) && !in_array($_GET['category'], array('Plugins', '
 	$my_category = Database::escape_string($_GET['category']);
 
 	$sqlcountsettings = "SELECT COUNT(*) FROM $table_settings_current WHERE category='".$my_category."' AND type<>'checkbox'";
-	$resultcountsettings = Database::query($sqlcountsettings, __FILE__, __LINE__);
+	$resultcountsettings = Database::query($sqlcountsettings);
 	$countsetting = Database::fetch_array($resultcountsettings);
 
-	if ($_configuration['access_url']==1)
-	{
+	if ($_configuration['access_url']==1) {
 		$settings = api_get_settings($my_category,'group',$_configuration['access_url']);
-	}
-	else
-	{
+	} else {
 		$url_info = api_get_access_url($_configuration['access_url']);
-		if ($url_info['active']==1)
-		{
+		if ($url_info['active']==1) {
 			//the default settings of Dokeos
 			$settings = api_get_settings($my_category,'group',1,0);
 			//the settings that are changeable from a particular site
@@ -127,22 +93,24 @@ if (!empty($_GET['category']) && !in_array($_GET['category'], array('Plugins', '
 
 	//print_r($settings_by_access_list);echo '</pre>';
 	//$sqlsettings = "SELECT DISTINCT * FROM $table_settings_current WHERE category='$my_category' GROUP BY variable ORDER BY id ASC";
-	//$resultsettings = Database::query($sqlsettings, __FILE__, __LINE__);
+	//$resultsettings = Database::query($sqlsettings);
 	//while ($row = Database::fetch_array($resultsettings))
 	$default_values = array();
 	foreach($settings as $row) {
-		if ($row['variable'] == 'search_enabled') { continue; }
+		// Settings to avoid
+		$rows_to_avoid = array('search_enabled', 'gradebook_enable');		
+		if (in_array($row['variable'], $rows_to_avoid)) { continue; }
+		
 		$anchor_name = $row['variable'].(!empty($row['subkey']) ? '_'.$row['subkey'] : '');
 		$form->addElement('html',"\n<a name=\"$anchor_name\"></a>\n");
 
 		($countsetting['0']%10) < 5 ?$b=$countsetting['0']-10:$b=$countsetting['0'];
-		if ($i % 10 == 0 and $i<$b){
-			if ($_GET['category'] <> "Languages"){
-				$form->addElement('html','<div align="right">');
-				$form->addElement('style_submit_button', null,get_lang('SaveSettings'), 'class="save"');
-				$form->addElement('html','</div>');
-			}
+		if ($i % 10 == 0 and $i<$b) {
+			$form->addElement('html','<div align="right">');
+			$form->addElement('style_submit_button', null,get_lang('SaveSettings'), 'class="save"');
+			$form->addElement('html','</div>');
 		}
+		
 		$i++;
 
 		$form->addElement('header', null, get_lang($row['title']));
@@ -153,16 +121,12 @@ if (!empty($_GET['category']) && !in_array($_GET['category'], array('Plugins', '
 
 		$hideme=array();
 		$hide_element=false;
-		if ($_configuration['access_url']!=1)
-		{
-			if ($row['access_url_changeable']==0)
-			{
+		if ($_configuration['access_url']!=1) {
+			if ($row['access_url_changeable']==0) {
 				//we hide the element in other cases (checkbox, radiobutton) we 'freeze' the element
 				$hide_element=true;
 				$hideme=array('disabled');
-			}
-			elseif($url_info['active']==1)
-			{
+			} elseif($url_info['active']==1) {
 				// we show the elements
 				if (empty($row['variable']))
 					$row['variable']=0;
@@ -171,8 +135,7 @@ if (!empty($_GET['category']) && !in_array($_GET['category'], array('Plugins', '
 				if (empty($row['category']))
 					$row['category']=0;
 
-				if (is_array ($settings_by_access_list[ $row['variable'] ] [ $row['subkey'] ]	[ $row['category'] ]))
-				{
+				if (is_array ($settings_by_access_list[ $row['variable'] ] [ $row['subkey'] ]	[ $row['category'] ])) {
 					// we are sure that the other site have a selected value
 					if ($settings_by_access_list[ $row['variable'] ] [ $row['subkey'] ]	[ $row['category'] ]['selected_value']!='')
 						$row['selected_value']	=$settings_by_access_list[$row['variable']] [$row['subkey']]	[ $row['category'] ]['selected_value'];
@@ -206,18 +169,20 @@ if (!empty($_GET['category']) && !in_array($_GET['category'], array('Plugins', '
 						}
 					}
 					foreach ($valid_encodings as $key => &$encoding) {
-						$encoding = api_is_encoding_supported($key) ? $key : $key.' (n.a.)';
+						if (api_is_encoding_supported($key) && Database::is_encoding_supported($key)) {
+							$encoding = $key;
+						} else {
+							//$encoding = $key.' (n.a.)';
+							unset($valid_encodings[$key]);
+						}
 					}
 					$form->addElement('select', $row['variable'], get_lang($row['comment']), $valid_encodings);
 					$default_values[$row['variable']] = $current_system_encoding;
-				//
-
 				} else {
 					$form->addElement('text', $row['variable'], get_lang($row['comment']),$hideme);
 					$form->applyFilter($row['variable'],'html_filter');
 					$default_values[$row['variable']] = $row['selected_value'];
 				}
-
 				break;
 			case 'textarea' :
 				$form->addElement('textarea', $row['variable'], get_lang($row['comment']),$hideme);
@@ -242,17 +207,23 @@ if (!empty($_GET['category']) && !in_array($_GET['category'], array('Plugins', '
 				//1. we collect all the options of this variable
 				$sql = "SELECT * FROM settings_current WHERE variable='".$row['variable']."' AND access_url =  1";
 
-				$result = Database::query($sql, __FILE__, __LINE__);
+				$result = Database::query($sql);
 				$group = array ();
 				while ($rowkeys = Database::fetch_array($result)) {
  					if ($rowkeys['variable'] == 'course_create_active_tools' && $rowkeys['subkey'] == 'enable_search') {continue;}
+
+ 					// profile tab option hide, if the social tool is enabled
+ 					if (api_get_setting('allow_social_tool') == 'true') {
+ 						if ($rowkeys['variable'] == 'show_tabs' && $rowkeys['subkey'] == 'my_profile') {continue;}
+ 					}
+
 					$element = & $form->createElement('checkbox', $rowkeys['subkey'], '', get_lang($rowkeys['subkeytext']));
 					if ($row['access_url_changeable']==1) {
 						//2. we look into the DB if there is a setting for a specific access_url
 						$access_url = $_configuration['access_url'];
 						if(empty($access_url )) $access_url =1;
 						$sql = "SELECT selected_value FROM settings_current WHERE variable='".$rowkeys['variable']."' AND subkey='".$rowkeys['subkey']."'  AND  subkeytext='".$rowkeys['subkeytext']."' AND access_url =  $access_url";
-						$result_access = Database::query($sql, __FILE__, __LINE__);
+						$result_access = Database::query($sql);
 						$row_access = Database::fetch_array($result_access);
 						if ($row_access['selected_value'] == 'true' && ! $form->isSubmitted()) {
 							$element->setChecked(true);
@@ -270,45 +241,55 @@ if (!empty($_GET['category']) && !in_array($_GET['category'], array('Plugins', '
 				$form->addGroup($group, $row['variable'], get_lang($row['comment']), '<br />'."\n");
 				break;
 			case "link" :
-				$form->addElement('static', null, get_lang($row['comment']), get_lang('CurrentValue').' : '.$row['selected_value'],$hideme);
+				$form->addElement('static', null, get_lang($row['comment']), get_lang('CurrentValue').' : '.$row['selected_value'], $hideme);
+				break;
+			/*
+			 * To populate its list of options, the select type dynamically calls a function that must be called select_ + the name of the variable being displayed
+			 * The functions being called must be added to the file settings.lib.php
+			 */
+			case "select":
+				$form->addElement('select', $row['variable'], get_lang($row['comment']), call_user_func('select_'.$row['variable']), $hideme);
+				$default_values[$row['variable']] = $row['selected_value'];
+				break;
 		}
 	}
-	if ($_GET['category'] <> "Languages"){
+
 		$form->addElement('html','<div align="right">');
 		$form->addElement('style_submit_button', null,get_lang('SaveSettings'), 'class="save"');
 		$form->addElement('html','</div>');
-	}
+
 	$form->setDefaults($default_values);
-	if ($form->validate())
-	{
+	if ($form->validate()) {
 		$values = $form->exportValues();
+
+		// set true for allow_message_tool variable if social tool is actived
+		if ($values['allow_social_tool'] == 'true') {
+			$values['allow_message_tool'] = 'true';
+		}
+
 		// the first step is to set all the variables that have type=checkbox of the category
 		// to false as the checkbox that is unchecked is not in the $_POST data and can
 		// therefore not be set to false.
 		// This, however, also means that if the process breaks on the third of five checkboxes, the others
 		// will be set to false.
-		$r = api_set_settings_category($my_category,'false',$_configuration['access_url']);
+		$r = api_set_settings_category($my_category,'false',$_configuration['access_url'],array('checkbox','radio'));
 		//$sql = "UPDATE $table_settings_current SET selected_value='false' WHERE category='$my_category' AND type='checkbox'";
-		//$result = Database::query($sql, __FILE__, __LINE__);
+		//$result = Database::query($sql);
 		// Save the settings
 		$keys = array();
-		foreach ($values as $key => $value)
-		{
-			if (!is_array($value))
-			{
+		foreach ($values as $key => $value) {
+			if (!is_array($value)) {
 				//$sql = "UPDATE $table_settings_current SET selected_value='".Database::escape_string($value)."' WHERE variable='$key'";
-				//$result = Database::query($sql, __FILE__, __LINE__);
+				//$result = Database::query($sql);
 
 				if (api_get_setting($key) != $value) $keys[] = $key;
 
 				$result = api_set_setting($key,$value,null,null,$_configuration['access_url']);
 
-			}
-			else
-			{
+			} else {
 
 				$sql = "SELECT subkey FROM $table_settings_current WHERE variable = '$key'";
-				$res = Database::query($sql,__FILE__,__LINE__);
+				$res = Database::query($sql);
 				$subkeys = array();
 				while ($row_subkeys = Database::fetch_array($res)) {
 					// if subkey is changed
@@ -323,7 +304,7 @@ if (!empty($_GET['category']) && !in_array($_GET['category'], array('Plugins', '
 				{
 
 					//$sql = "UPDATE $table_settings_current SET selected_value='true' WHERE variable='$key' AND subkey = '$subkey'";
-					//$result = Database::query($sql, __FILE__, __LINE__);
+					//$result = Database::query($sql);
 
 					$result = api_set_setting($key,'true',$subkey,null,$_configuration['access_url']);
 
@@ -355,13 +336,12 @@ Display :: display_header($tool_name);
 //api_display_tool_title($tool_name);
 
 // displaying the message that the settings have been stored
-if (!empty($_GET['action']) && $_GET['action'] == "stored")
-{
+if (!empty($_GET['action']) && $_GET['action'] == 'stored') {
 	Display :: display_confirmation_message(get_lang('SettingsStored'));
 }
 
 // the action images
-$action_images['platform'] 		= 'dokeos.gif';
+$action_images['platform'] 		= 'logo.gif';
 $action_images['course'] 		= 'course.gif';
 $action_images['tools'] 		= 'reference.gif';
 $action_images['user'] 			= 'students.gif';
@@ -375,15 +355,15 @@ $action_images['stylesheets'] 	= 'theme.gif';
 $action_images['templates'] 	= 'template.gif';
 $action_images['search']        = 'search.gif';
 $action_images['editor']		= 'html.png';
+$action_images['timezones']		= 'timezones.png';
 
 // grabbing the categories
 //$selectcategories = "SELECT DISTINCT category FROM ".$table_settings_current." WHERE category NOT IN ('stylesheets','Plugins')";
-//$resultcategories = Database::query($selectcategories, __FILE__, __LINE__);
+//$resultcategories = Database::query($selectcategories);
 $resultcategories = api_get_settings_categories(array('stylesheets','Plugins', 'Templates', 'Search'));
 echo "\n<div class=\"actions\">";
 //while ($row = Database::fetch_array($resultcategories))
-foreach($resultcategories as $row)
-{
+foreach($resultcategories as $row) {
 	echo "\n\t<a href=\"".api_get_self()."?category=".$row['category']."\">".Display::return_icon($action_images[strtolower($row['category'])], api_ucfirst(get_lang($row['category']))).api_ucfirst(get_lang($row['category']))."</a>";
 }
 echo "\n\t<a href=\"".api_get_self()."?category=Plugins\">".Display::return_icon($action_images['plugins'], api_ucfirst(get_lang('Plugins'))).api_ucfirst(get_lang('Plugins'))."</a>";
@@ -392,14 +372,27 @@ echo "\n\t<a href=\"".api_get_self()."?category=Templates\">".Display::return_ic
 echo "\n\t<a href=\"".api_get_self()."?category=Search\">".Display::return_icon($action_images['search'], api_ucfirst(get_lang('Search'))).api_ucfirst(get_lang('Search'))."</a>";
 echo "\n</div>";
 
-if (!empty($_GET['category']))
-{
-	switch ($_GET['category'])
-	{
+if (!empty($_GET['category'])) {
+	switch ($_GET['category']) {
 		// displaying the extensions: plugins
 		// this will be available to all the sites (access_urls)
 		case 'Plugins' :
+
+			if (isset($_POST['submit_dashboard_plugins'])) {
+				$affected_rows = DashboardManager::store_dashboard_plugins($_POST);
+				if ($affected_rows) {
+					// add event to system log
+					$time = time();
+					$user_id = api_get_user_id();
+					$category = $_GET['category'];
+					event_system(LOG_CONFIGURATION_SETTINGS_CHANGE, LOG_CONFIGURATION_SETTINGS_CATEGORY, $category, $time, $user_id);
+					Display :: display_confirmation_message(get_lang('DashboardPluginsHaveBeenUpdatedSucesslly'));
+				}
+			}
+
 			handle_plugins();
+			DashboardManager::handle_dashboard_plugins();
+
 			break;
 			// displaying the extensions: Stylesheets
 		case 'stylesheets' :
@@ -417,875 +410,6 @@ if (!empty($_GET['category']))
 }
 
 /*
-==============================================================================
 		FOOTER
-==============================================================================
 */
 Display :: display_footer();
-
-
-
-/*
-==============================================================================
-		FUNCTIONS
-==============================================================================
-*/
-/**
- * The function that retrieves all the possible settings for a certain config setting
- * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
-*/
-function get_settings_options($var)
-{
-	$table_settings_options = Database :: get_main_table(TABLE_MAIN_SETTINGS_OPTIONS);
-	$sql = "SELECT * FROM $table_settings_options WHERE variable='$var'";
-	$result = Database::query($sql, __FILE__, __LINE__);
-	while ($row = Database::fetch_array($result))
-	{
-		$temp_array = array ('value' => $row['value'], 'display_text' => $row['display_text']);
-		$settings_options_array[] = $temp_array;
-	}
-	return $settings_options_array;
-}
-
-/**
- * This function allows easy activating and inactivating of plugins
- * @todo: a similar function needs to be written to activate or inactivate additional tools.
- * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
-*/
-function handle_plugins()
-{
-	global $SettingsStored;
-	$userplugins = array();
-	$table_settings_current = Database :: get_main_table(TABLE_MAIN_SETTINGS_CURRENT);
-
-	if (isset($_POST['submit_plugins']))
-	{
-		store_plugins();
-		// add event to system log
-		$time = time();
-		$user_id = api_get_user_id();
-		$category = $_GET['category'];
-		event_system(LOG_CONFIGURATION_SETTINGS_CHANGE, LOG_CONFIGURATION_SETTINGS_CATEGORY, $category, $time, $user_id);
-
-		Display :: display_confirmation_message(get_lang('SettingsStored'));
-	}
-
-	echo get_lang('AvailablePlugins')."<br/><br/>";
-
-	/* We scan the plugin directory. Each folder is a potential plugin. */
-	$pluginpath = api_get_path(SYS_PLUGIN_PATH);
-
-	$handle = @opendir($pluginpath);
-	while (false !== ($file = readdir($handle)))
-	{
-		if ($file <> '.' AND $file <> '..' AND is_dir(api_get_path(SYS_PLUGIN_PATH).$file))
-		{
-			$possibleplugins[] = $file;
-		}
-	}
-	@closedir($handle);
-
-	/* 	for each of the possible plugin dirs we check if a file plugin.php (that contains all the needed information about this plugin)
-	 	can be found in the dir.
-		this plugin.php file looks like
-		$plugin_info['title']='The title of the plugin'; //
-		$plugin_info['comment']="Some comment about the plugin";
-		$plugin_info['location']=array("loginpage_menu", "campushomepage_menu","banner"); // the possible locations where the plugins can be used
-		$plugin_info['version']='0.1 alpha'; // The version number of the plugin
-		$plugin_info['author']='Patrick Cool'; // The author of the plugin
-	*/
-	echo '<form name="plugins" method="post" action="'.api_get_self().'?category='.$_GET['category'].'">';
-	echo "<table class=\"data_table\">\n";
-	echo "\t<tr>\n";
-	echo "\t\t<th>\n";
-	echo get_lang('Plugin');
-	echo "\t\t</th>\n";
-	echo "\t\t<th>\n";
-	echo get_lang('LoginPageMainArea');
-	echo "\t\t</th>\n";
-	echo "\t\t<th>\n";
-	echo get_lang('LoginPageMenu');
-	echo "\t\t</th>\n";
-	echo "\t\t<th>\n";
-	echo get_lang('CampusHomepageMainArea');
-	echo "\t\t</th>\n";
-	echo "\t\t<th>\n";
-	echo get_lang('CampusHomepageMenu');
-	echo "\t\t</th>\n";
-	echo "\t\t<th>\n";
-	echo get_lang('MyCoursesMainArea');
-	echo "\t\t</th>\n";
-	echo "\t\t<th>\n";
-	echo get_lang('MyCoursesMenu');
-	echo "\t\t</th>\n";
-	echo "\t\t<th>\n";
-	echo get_lang('Header');
-	echo "\t\t</th>\n";
-	echo "\t\t<th>\n";
-	echo get_lang('Footer');
-	echo "\t\t</th>\n";
-	echo "\t</tr>\n";
-
-	/* We retrieve all the active plugins. */
-	//$sql = "SELECT * FROM $table_settings_current WHERE category='Plugins'";
-	//$result = Database::query($sql);
-	$result = api_get_settings('Plugins');
-	//while ($row = Database::fetch_array($result))
-	foreach($result as $row)
-	{
-		$usedplugins[$row['variable']][] = $row['selected_value'];
-	}
-
-	/* We display all the possible plugins and the checkboxes */
-	foreach ($possibleplugins as $testplugin)
-	{
-		$plugin_info_file = api_get_path(SYS_PLUGIN_PATH).$testplugin."/plugin.php";
-		if (file_exists($plugin_info_file))
-		{
-			$plugin_info = array();
-			include ($plugin_info_file);
-
-			echo "\t<tr>\n";
-			echo "\t\t<td>\n";
-			foreach ($plugin_info as $key => $value)
-			{
-				if ($key <> 'location')
-				{
-					if ($key == 'title')
-					{
-						$value = '<strong>'.$value.'</strong>';
-					}
-					echo get_lang(ucwords($key)).': '.$value.'<br />';
-				}
-			}
-			if (file_exists(api_get_path(SYS_PLUGIN_PATH).$testplugin.'/readme.txt'))
-			{
-				echo "<a href='".api_get_path(WEB_PLUGIN_PATH).$testplugin."/readme.txt'>readme.txt</a>";
-			}
-			echo "\t\t</td>\n";
-
-			// column: LoginPageMainArea
-			if(empty($usedplugins))
-			{
-				$usedplugins = array();
-			}
-			display_plugin_cell('loginpage_main', $plugin_info, $testplugin, $usedplugins);
-			display_plugin_cell('loginpage_menu', $plugin_info, $testplugin, $usedplugins);
-			display_plugin_cell('campushomepage_main', $plugin_info, $testplugin, $usedplugins);
-			display_plugin_cell('campushomepage_menu', $plugin_info, $testplugin, $usedplugins);
-			display_plugin_cell('mycourses_main', $plugin_info, $testplugin, $usedplugins);
-			display_plugin_cell('mycourses_menu', $plugin_info, $testplugin, $usedplugins);
-			display_plugin_cell('header', $plugin_info, $testplugin, $usedplugins);
-			display_plugin_cell('footer', $plugin_info, $testplugin, $usedplugins);
-			echo "\t</tr>\n";
-				}
-				}
-	echo '</table>';
-
-	echo '<button class="save" type="submit" name="submit_plugins">'.get_lang('EnablePlugins').'</button></form>';
-			}
-
-
-function display_plugin_cell($location, $plugin_info, $current_plugin, $active_plugins)
-{
-	echo "\t\t<td align=\"center\">\n";
-	if (in_array($location, $plugin_info['location']))
-	{
-		if (isset($active_plugins[$location]) && is_array($active_plugins[$location])
-			&& in_array($current_plugin, $active_plugins[$location]))
-		{
-			$checked = "checked";
-		}
-		else
-		{
-			$checked = '';
-		}
-		echo '<input type="checkbox" name="'.$current_plugin.'-'.$location.'" value="true" '.$checked.'/>';
-	}
-	echo "\t\t</td>\n";
-}
-
-/**
- * This function allows the platform admin to choose the default stylesheet
- * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
-*/
-function handle_stylesheets()
-{
-	global $_configuration;
-	// Current style
-	$currentstyle = api_get_setting('stylesheets');
-	$is_style_changeable=false;
-
-
-	if ($_configuration['access_url']!=1)
-	{
-		$style_info = api_get_settings('stylesheets','',1,0);
-		$url_info = api_get_access_url($_configuration['access_url']);
-		if ($style_info[0]['access_url_changeable']==1 && $url_info['active']==1)
-		{
-			$is_style_changeable=true;
-			echo '<div class="actions" id="stylesheetuploadlink">';
-			Display::display_icon('theme_add.gif');
-			echo '<a href="" onclick="document.getElementById(\'newstylesheetform\').style.display = \'block\'; document.getElementById(\'stylesheetuploadlink\').style.display = \'none\';return false; ">'.get_lang('UploadNewStylesheet').'</a>';
-			echo '</div>';
-		}
-	}
-	else
-	{
-		$is_style_changeable=true;
-		echo '<div class="actions" id="stylesheetuploadlink">';
-		Display::display_icon('theme_add.gif');
-		echo '<a href="" onclick="document.getElementById(\'newstylesheetform\').style.display = \'block\'; document.getElementById(\'stylesheetuploadlink\').style.display = \'none\';return false; ">'.get_lang('UploadNewStylesheet').'</a>';
-		echo '</div>';
-	}
-
-	$form = new FormValidator('stylesheet_upload','post','settings.php?category=stylesheets&showuploadform=true');
-	$form->addElement('text','name_stylesheet',get_lang('NameStylesheet'),array('size' => '40', 'maxlength' => '40'));
-	$form->addRule('name_stylesheet', get_lang('ThisFieldIsRequired'), 'required');
-	$form->addElement('file', 'new_stylesheet', get_lang('UploadNewStylesheet'));
-	$allowed_file_types = array ('css');
-	$form->addRule('new_stylesheet', get_lang('InvalidExtension').' ('.implode(',', $allowed_file_types).')', 'filetype', $allowed_file_types);
-	$form->addRule('new_stylesheet', get_lang('ThisFieldIsRequired'), 'required');
-	$form->addElement('style_submit_button', 'stylesheet_upload', get_lang('Ok'), array('class'=>'save'));
-	if( $form->validate() AND is_writable(api_get_path(SYS_CODE_PATH).'css/'))
-	{
-		$values = $form->exportValues();
-		$picture_element = & $form->getElement('new_stylesheet');
-		$picture = $picture_element->getValue();
-		upload_stylesheet($values, $picture);
-
-		// add event to system log
-		$time = time();
-		$user_id = api_get_user_id();
-		$category = $_GET['category'];
-		event_system(LOG_CONFIGURATION_SETTINGS_CHANGE, LOG_CONFIGURATION_SETTINGS_CATEGORY, $category, $time, $user_id);
-
-		Display::display_confirmation_message(get_lang('StylesheetAdded'));
-	}
-	else
-	{
-		if (!is_writable(api_get_path(SYS_CODE_PATH).'css/'))
-		{
-			Display::display_error_message(api_get_path(SYS_CODE_PATH).'css/'.get_lang('IsNotWritable'));
-		}
-		else
-		{
-			if ($_GET['showuploadform'] == 'true')
-			{
-				echo '<div id="newstylesheetform">';
-			}
-			else
-			{
-				echo '<div id="newstylesheetform" style="display: none;">';
-			}
-				// uploading a new stylesheet
-			if ($_configuration['access_url']==1)
-			{
-				$form->display();
-			}
-			else
-			{
-				if ($is_style_changeable)
-				{
-					$form->display();
-				}
-			}
-			echo '</div>';
-		}
-	}
-
-	// Preview of the stylesheet
-	echo '<div><iframe src="style_preview.php" width="100%" height="300" name="preview"></iframe></div>';
-
-	echo '<form name="stylesheets" method="post" action="'.api_get_self().'?category='.Security::remove_XSS($_GET['category']).'">';
-	if ($handle = @opendir(api_get_path(SYS_PATH).'main/css/'))
-	{
-		$counter=1;
-		while (false !== ($style_dir = readdir($handle)))
-		{
-			if(substr($style_dir,0,1)=='.') //skip dirs starting with a '.'
-			{
-				continue;
-			}
-			$dirpath = api_get_path(SYS_PATH).'main/css/'.$style_dir;
-			if (is_dir($dirpath))
-			{
-				if ($style_dir != '.' && $style_dir != '..')
-				{
-					if ($currentstyle == $style_dir OR ($style_dir == 'dokeos_classic' AND !$currentstyle))
-					{
-						$selected = 'checked="checked"';
-					}
-					else
-					{
-						$selected = '';
-					}
-					$show_name=get_lang(str_replace(' ','', ucwords(str_replace('_',' ', $style_dir))), '');
-
-					if ($is_style_changeable)
-					{
-						echo "<input type=\"radio\" name=\"style\" value=\"".$style_dir."\" ".$selected." onClick=\"parent.preview.location='style_preview.php?style=".$style_dir."';\"/>";
-						echo '<a href="style_preview.php?style='.$style_dir.'" target="preview">'.$show_name.'</a>';
-					}
-					else
-						echo '<a href="style_preview.php?style='.$style_dir.'" target="preview">'.$show_name.'</a>';
-					//echo '<div id="Layer'.$counter.'" style="position:relative; width:687px; z-index:2; visibility: hidden;">';
-					//echo '<a href="#" onClick="MM_showHideLayers(\'Layer'.$counter.'\',\'\',\'hide\')">'.get_lang('Close').'</a>';
-					//echo '<iframe src="style_preview.php?style='.$file.'" width="100%" style="float:right;"></iframe></div>';
-					echo "<br />\n";
-					$counter++;
-				}
-			}
-		}
-		@closedir($handle);
-	}
-	if ($is_style_changeable)
-	{
-		echo '<button class="save" type="submit" name="submit_stylesheets"> '.get_lang('SaveSettings').' </button></form>';
-	}
-}
-
-/**
- * creates the folder (if needed) and uploads the stylesheet in it
- *
- * @param array $values the values of the form
- * @param array $picture the values of the uploaded file
- *
- * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University, Belgium
- * @version May 2008
- * @since Dokeos 1.8.5
- */
-function upload_stylesheet($values,$picture)
-{
-	// valid name for the stylesheet folder
-	$style_name = api_ereg_replace("[^A-Za-z0-9]", "", $values['name_stylesheet'] );
-
-	// create the folder if needed
-	if(!is_dir(api_get_path(SYS_CODE_PATH).'css/'.$style_name.'/'))
-	{
-		if(mkdir(api_get_path(SYS_CODE_PATH).'css/'.$style_name.'/'))
-		{
-			$perm = api_get_setting('permissions_for_new_directories');
-			$perm = octdec(!empty($perm)?$perm:'0770');
-			chmod(api_get_path(SYS_CODE_PATH).'css/'.$style_name.'/', $perm);
-		}
-	}
-
-	// move the file in the folder
-	move_uploaded_file($picture['tmp_name'], api_get_path(SYS_CODE_PATH).'css/'.$style_name.'/'.$picture['name']);
-}
-
-/**
- * This function allows easy activating and inactivating of plugins
- * @todo: a similar function needs to be written to activate or inactivate additional tools.
- * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
-*/
-function store_plugins()
-{
-	$table_settings_current = Database :: get_main_table(TABLE_MAIN_SETTINGS_CURRENT);
-	global $_configuration;
-
-	// Step 1 : we remove all the plugins
-	//$sql = "DELETE FROM $table_settings_current WHERE category='Plugins'";
-	//Database::query($sql, __LINE__, __FILE__);
-	$r = api_delete_category_settings('Plugins',$_configuration['access_url']);
-
-	// step 2: looping through all the post values we only store these which are really a valid plugin location.
-	foreach ($_POST as $form_name => $formvalue)
-	{
-		$form_name_elements = explode("-", $form_name);
-		if (is_valid_plugin_location($form_name_elements[1]))
-		{
-			//$sql = "INSERT into $table_settings_current (variable,category,selected_value) VALUES ('".$form_name_elements['1']."','Plugins','".$form_name_elements['0']."')";
-			//Database::query($sql, __LINE__, __FILE__);
-			api_add_setting($form_name_elements['0'],$form_name_elements['1'],$form_name_elements['0'],null,'Plugins',$form_name_elements['0'],null,null,null,$_configuration['access_url'],1);
-		}
-	}
-}
-
-/**
- * Check if the post information is really a valid plugin location.
- * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
-*/
-function is_valid_plugin_location($location)
-{
-	$valid_locations=array('loginpage_main', 'loginpage_menu', 'campushomepage_main', 'campushomepage_menu', 'mycourses_main', 'mycourses_menu','header', 'footer');
-	if (in_array($location, $valid_locations))
-	{
-		return true;
-	}
-	else
-	{
-		return false;
-	}
-}
-
-
-/**
- * This function allows the platform admin to choose which should be the default stylesheet
- * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
-*/
-function store_stylesheets()
-{
-	global $_configuration;
-	// Database Table Definitions
-	$table_settings_current = Database :: get_main_table(TABLE_MAIN_SETTINGS_CURRENT);
-
-	// Insert the stylesheet
-	$style = Database::escape_string($_POST['style']);
-	if (is_style($style))
-	{
-		/*
-		$sql = 'UPDATE '.$table_settings_current.' SET
-				selected_value = "'.$style.'"
-				WHERE variable = "stylesheets"
-				AND category = "stylesheets"';
-
-		Database::query($sql, __LINE__, __FILE__);
-		*/
-
-		api_set_setting('stylesheets',$style,null,'stylesheets',$_configuration['access_url']);
-	}
-
-	return true;
-}
-
-/**
- * This function checks if the given style is a recognize style that exists in the css directory as
- * a standalone directory.
- * @param	string	Style
- * @return	bool	True if this style is recognized, false otherwise
- */
-function is_style($style)
-{
-	$dir = api_get_path(SYS_PATH).'main/css/';
-	$dirs = scandir($dir);
-	$style = str_replace(array('/','\\'),array('',''),$style); //avoid slashes or backslashes
-	if (in_array($style,$dirs) && is_dir($dir.$style))
-	{
-		return true;
-	}
-	return false;
-}
-
-/**
- * Search options
- * TODO: support for multiple site. aka $_configuration['access_url'] == 1
- * @author Marco Villegas <marvil07@gmail.com>
- */
-function handle_search() {
-    global $SettingsStored, $_configuration;
-
-    $search_enabled = api_get_setting('search_enabled');
-    $settings = api_get_settings('Search');
-
-    if ($search_enabled !== 'true' || count($settings) < 1) {
-        Display::display_error_message(get_lang('SearchFeatureNotEnabledComment'));
-        return;
-    }
-
-    require_once api_get_path(LIBRARY_PATH) . 'specific_fields_manager.lib.php';
-
-    $form = new FormValidator('search-options', 'post', api_get_self().'?category=Search');
-    $renderer = & $form->defaultRenderer();
-    $renderer->setHeaderTemplate('<div class="sectiontitle">{header}</div>'."\n");
-    $renderer->setElementTemplate('<div class="sectioncomment">{label}</div>'."\n".'<div class="sectionvalue">{element}</div>'."\n");
-
-    //search_show_unlinked_results
-    $form->addElement('header', null, get_lang('SearchShowUnlinkedResultsTitle'));
-    $form->addElement('label', null, get_lang('SearchShowUnlinkedResultsComment'));
-    $values = get_settings_options('search_show_unlinked_results');
-    $group = array ();
-    foreach ($values as $key => $value) {
-        $element = & $form->createElement('radio', 'search_show_unlinked_results', '', get_lang($value['display_text']), $value['value']);
-        $group[] = $element;
-    }
-    $form->addGroup($group, 'search_show_unlinked_results', get_lang('SearchShowUnlinkedResultsComment'), '<br />', false);
-    $default_values['search_show_unlinked_results'] = api_get_setting('search_show_unlinked_results');
-
-    //search_prefilter_prefix
-    $form->addElement('header', null, get_lang('SearchPrefilterPrefix'));
-    $form->addElement('label', null, get_lang('SearchPrefilterPrefixComment'));
-    $specific_fields = get_specific_field_list();
-    $sf_values = array();
-    foreach ($specific_fields as $sf) {
-       $sf_values[$sf['code']] = $sf['name'];
-    }
-    $group = array ();
-    $form->addElement('select', 'search_prefilter_prefix', get_lang('SearchPrefilterPrefix'), $sf_values, '');
-    $default_values['search_prefilter_prefix'] = api_get_setting('search_prefilter_prefix');
-
-    //$form->addRule('search_show_unlinked_results', get_lang('ThisFieldIsRequired'), 'required');
-    $form->addElement('style_submit_button', 'search-options-save', get_lang('Ok'));
-    $form->setDefaults($default_values);
-
-    if( $form->validate()) {
-        $formvalues = $form->exportValues();
-        $r = api_set_settings_category('Search','false',$_configuration['access_url']);
-        // Save the settings
-        foreach ($formvalues as $key => $value)
-        {
-                $result = api_set_setting($key,$value,null,null);
-        }
-
-        Display :: display_confirmation_message($SettingsStored);
-    } else {
-        echo '<div id="search-options-form">';
-        $form->display();
-        echo '</div>';
-    }
-}
-
-/**
- * wrapper for the templates
- *
- * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University, Belgium
- * @version August 2008
- * @since Dokeos 1.8.6
- */
-function handle_templates()
-{
-	if ($_GET['action'] != 'add') {
-		echo "\n<div class=\"actions\" style=\"margin-left:1px\" >";
-		echo '<a href="settings.php?category=Templates&amp;action=add">'.Display::return_icon('template_add.gif', get_lang('AddTemplate')).get_lang('AddTemplate').'</a>';
-		echo "\n</div>";
-	}
-
-	if ($_GET['action'] == 'add' OR ( $_GET['action'] == 'edit' AND is_numeric($_GET['id']))) {
-		add_edit_template();
-
-		// add event to system log
-		$time = time();
-		$user_id = api_get_user_id();
-		$category = $_GET['category'];
-		event_system(LOG_CONFIGURATION_SETTINGS_CHANGE, LOG_CONFIGURATION_SETTINGS_CATEGORY, $category, $time, $user_id);
-
-	} else {
-		if ($_GET['action'] == 'delete' and is_numeric($_GET['id'])) {
-			delete_template($_GET['id']);
-
-			// add event to system log
-			$time = time();
-			$user_id = api_get_user_id();
-			$category = $_GET['category'];
-			event_system(LOG_CONFIGURATION_SETTINGS_CHANGE, LOG_CONFIGURATION_SETTINGS_CATEGORY, $category, $time, $user_id);
-		}
-		display_templates();
-	}
-}
-
-/**
- * Display a sortable table with all the templates that the platform administrator has defined.
- *
- * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University, Belgium
- * @version August 2008
- * @since Dokeos 1.8.6
- */
-function display_templates()
-{
-	$table = new SortableTable('templates', 'get_number_of_templates', 'get_template_data',1);
-	$table->set_additional_parameters(array('category'=>Security::remove_XSS($_GET['category'])));
-	$table->set_header(0, get_lang('Image'), true, array ('style' => 'width:101px;'));
-	$table->set_header(1, get_lang('Title'));
-	$table->set_header(2, get_lang('Actions'), false, array ('style' => 'width:50px;'));
-	$table->set_column_filter(2,'actions_filter');
-	$table->set_column_filter(0,'image_filter');
-	$table->display();
-}
-
-/**
- * Get the number of templates that are defined by the platform admin.
- *
- * @return integer
- *
- * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University, Belgium
- * @version August 2008
- * @since Dokeos 1.8.6
- */
-function get_number_of_templates()
-{
-	// Database table definition
-	$table_system_template = Database :: get_main_table('system_template');
-
-	// The sql statement
-	$sql = "SELECT COUNT(id) AS total FROM $table_system_template";
-	$result = Database::query($sql, __FILE__, __LINE__);
-	$row = Database::fetch_array($result);
-
-	// returning the number of templates
-	return $row['total'];
-}
-
-/**
- * Get all the template data for the sortable table
- *
- * @param integer $from the start of the limit statement
- * @param integer $number_of_items the number of elements that have to be retrieved from the database
- * @param integer $column the column that is
- * @param string $direction the sorting direction (ASC or DESC�
- * @return array
- *
- * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University, Belgium
- * @version August 2008
- * @since Dokeos 1.8.6
- */
-function get_template_data($from, $number_of_items, $column, $direction)
-{
-	// Database table definition
-	$table_system_template = Database :: get_main_table('system_template');
-
-	// the sql statement
-	$sql = "SELECT image as col0, title as col1, id as col2 FROM $table_system_template";
-	$sql .= " ORDER BY col$column $direction ";
-	$sql .= " LIMIT $from,$number_of_items";
-	$result = Database::query($sql, __FILE__, __LINE__);
-	while ($row = Database::fetch_array($result)) {
-		$row['1'] = get_lang($row['1']);
-		$return[]=$row;
-	}
-	// returning all the information for the sortable table
-	return $return;
-}
-
-/**
- * display the edit and delete icons in the sortable table
- *
- * @param integer $id the id of the template
- * @return html code for the link to edit and delete the template
- *
- * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University, Belgium
- * @version August 2008
- * @since Dokeos 1.8.6
- */
-function actions_filter($id)
-{
-	$return .= '<a href="settings.php?category=Templates&amp;action=edit&amp;id='.Security::remove_XSS($id).'">'.Display::return_icon('edit.gif', get_lang('Edit')).'</a>';
-	$return .= '<a href="settings.php?category=Templates&amp;action=delete&amp;id='.Security::remove_XSS($id).'" onclick="javascript:if(!confirm('."'".get_lang("ConfirmYourChoice")."'".')) return false;">'.Display::return_icon('delete.gif', get_lang('Delete')).'</a>';
-	return $return;
-}
-
-/**
- * Display the image of the template in the sortable table
- *
- * @param string $image the image
- * @return html code for the image
- *
- * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University, Belgium
- * @version August 2008
- * @since Dokeos 1.8.6
- */
-function image_filter($image)
-{
-	if (!empty($image))
-	{
-		return '<img src="'.api_get_path(WEB_PATH).'home/default_platform_document/template_thumb/'.$image.'" alt="'.get_lang('TemplatePreview').'"/>';
-	}
-	else
-	{
-		return '<img src="'.api_get_path(WEB_PATH).'home/default_platform_document/template_thumb/noimage.gif" alt="'.get_lang('NoTemplatePreview').'"/>';
-	}
-}
-
-/**
- * Add (or edit) a template. This function displays the form and also takes care of uploading the image and storing the information in the database
- *
- * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University, Belgium
- * @version August 2008
- * @since Dokeos 1.8.6
- */
-function add_edit_template()
-{
-	// initiate the object
-	$form = new FormValidator('template', 'post', 'settings.php?category=Templates&action='.$_GET['action'].'&id='.$_GET['id']);
-
-	// settting the form elements: the header
-	if ($_GET['action'] == 'add') {
-		$title = get_lang('AddTemplate');
-	}
-	else
-	{
-		$title = get_lang('EditTemplate');
-	}
-	$form->addElement('header', '', $title);
-
-	// settting the form elements: the title of the template
-	$form->add_textfield('title', get_lang('Title'), false);
-
-	// settting the form elements: the content of the template (wysiwyg editor)
-	$form->addElement('html_editor', 'template_text', get_lang('Text'), null, array('ToolbarSet' => 'AdminTemplates', 'Width' => '100%', 'Height' => '400'));
-
-	// settting the form elements: the form to upload an image to be used with the template
-	$form->addElement('file','template_image',get_lang('Image'),'');
-
-	// settting the form elements: a little bit information about the template image
-	$form->addElement('static', 'file_comment', '', get_lang('TemplateImageComment100x70'));
-
-	// getting all the information of the template when editing a template
-	if ($_GET['action'] == 'edit') {
-		// Database table definition
-		$table_system_template = Database :: get_main_table('system_template');
-		$sql = "SELECT * FROM $table_system_template WHERE id = '".Database::escape_string($_GET['id'])."'";
-		$result = Database::query($sql, __FILE__, __LINE__);
-		$row = Database::fetch_array($result);
-
-		$defaults['template_id'] 	= intval($_GET['id']);
-		$defaults['template_text'] 	= $row['content'];
-		//forcing a get_lang
-		$defaults['title'] 			= get_lang($row['title']);
-
-		// adding an extra field: a hidden field with the id of the template we are editing
-		$form->addElement('hidden','template_id');
-
-		// adding an extra field: a preview of the image that is currently used
-		if (!empty($row['image']))
-		{
-			$form->addElement('static','template_image_preview', '', '<img src="'.api_get_path(WEB_PATH).'home/default_platform_document/template_thumb/'.$row['image'].'" alt="'.get_lang('TemplatePreview').'"/>');
-		}
-		else
-		{
-			$form->addElement('static','template_image_preview', '', '<img src="'.api_get_path(WEB_PATH).'home/default_platform_document/template_thumb/noimage.gif" alt="'.get_lang('NoTemplatePreview').'"/>');
-		}
-
-		// setting the information of the template that we are editing
-		$form->setDefaults($defaults);
-	}
-		// settting the form elements: the submit button
-	$form->addElement('style_submit_button' , 'submit', get_lang('Ok') ,'class="save"');
-
-	// setting the rules: the required fields
-	$form->addRule('title', '<div class="required">'.get_lang('ThisFieldIsRequired'), 'required');
-	$form->addRule('template_text', '<div class="required">'.get_lang('ThisFieldIsRequired'), 'required');
-
-	// if the form validates (complies to all rules) we save the information, else we display the form again (with error message if needed)
-	if( $form->validate() )
-	{
-
-		$check = Security::check_token('post');
-		if ($check) {
-			// exporting the values
-			$values = $form->exportValues();
-
-			// upload the file
-			if (!empty($_FILES['template_image']['name']))
-			{
-				include_once (api_get_path(LIBRARY_PATH).'fileUpload.lib.php');
-				$upload_ok = process_uploaded_file($_FILES['template_image']);
-
-				if ($upload_ok)
-				{
-					// Try to add an extension to the file if it hasn't one
-					$new_file_name = add_ext_on_mime(stripslashes($_FILES['template_image']['name']), $_FILES['template_image']['type']);
-
-					// upload dir
-					$upload_dir = api_get_path(SYS_PATH).'home/default_platform_document/template_thumb/';
-
-					// create dir if not exists
-	                if (!is_dir($upload_dir)) {
-	                    $perm = api_get_setting('permissions_for_new_directories');
-	                    $perm = octdec(!empty($perm)?$perm:'0770');
-	                	$res = @mkdir($upload_dir,$perm);
-	                }
-
-					// resize image to max default and upload
-					require_once (api_get_path(LIBRARY_PATH).'image.lib.php');
-					$temp = new image($_FILES['template_image']['tmp_name']);
-					$picture_infos=@getimagesize($_FILES['template_image']['tmp_name']);
-
-					$max_width_for_picture = 100;
-
-					if ($picture_infos[0]>$max_width_for_picture)
-					{
-						$thumbwidth = $max_width_for_picture;
-						if (empty($thumbwidth) or $thumbwidth==0) {
-						  $thumbwidth=$max_width_for_picture;
-						}
-						$new_height = round(($thumbwidth/$picture_infos[0])*$picture_infos[1]);
-
-						$temp->resize($thumbwidth,$new_height,0);
-					}
-
-					$type=$picture_infos[2];
-
-					switch (!empty($type))
-					{
-						case 2 : $temp->send_image('JPG',$upload_dir.$new_file_name);
-								 break;
-						case 3 : $temp->send_image('PNG',$upload_dir.$new_file_name);
-								 break;
-						case 1 : $temp->send_image('GIF',$upload_dir.$new_file_name);
-								 break;
-					}
-				}
-		   }
-
-		   // store the information in the database (as insert or as update)
-		   $table_system_template = Database :: get_main_table('system_template');
-		   if ($_GET['action'] == 'add') {
-		   		$content_template = '<head>{CSS}<style type="text/css">.text{font-weight: normal;}</style></head><body>'.Database::escape_string($values['template_text']).'</body>';
-			   	$sql = "INSERT INTO $table_system_template (title, content, image) VALUES ('".Database::escape_string($values['title'])."','".$content_template."','".Database::escape_string($new_file_name)."')";
-			   	$result = Database::query($sql, __FILE__, __LINE__);
-
-			   	// display a feedback message
-			   	Display::display_confirmation_message(get_lang('TemplateAdded'));
-			   	echo '<a href="settings.php?category=Templates&amp;action=add">'.Display::return_icon('template_add.gif', get_lang('AddTemplate')).get_lang('AddTemplate').'</a>';
-		   } else {
-		   		$content_template = '<head>{CSS}<style type="text/css">.text{font-weight: normal;}</style></head><body>'.Database::escape_string($values['template_text']).'</body>';
-			   	$sql = "UPDATE $table_system_template set title = '".Database::escape_string($values['title'])."',
-												   		  content = '".$content_template."'";
-			   	if (!empty($new_file_name))
-			   	{
-			   		$sql .= ", image = '".Database::escape_string($new_file_name)."'";
-			   	}
-			   	$sql .= " WHERE id='".Database::escape_string($_GET['id'])."'";
-			   	$result = Database::query($sql, __FILE__, __LINE__);
-
-			   	// display a feedback message
-			   	Display::display_confirmation_message(get_lang('TemplateEdited'));
-		   }
-
-		}
-	   Security::clear_token();
-	   display_templates();
-
-
-
-	}
-	else
-	{
-		$token = Security::get_token();
-		$form->addElement('hidden','sec_token');
-		$form->setConstants(array('sec_token' => $token));
-		// display the form
-		$form->display();
-	}
-}
-
-/**
- * Delete a template
- *
- * @param integer $id the id of the template that has to be deleted
- *
- * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University, Belgium
- * @version August 2008
- * @since Dokeos 1.8.6
- */
-function delete_template($id)
-{
-	// first we remove the image
-	$table_system_template = Database :: get_main_table('system_template');
-	$sql = "SELECT * FROM $table_system_template WHERE id = '".Database::escape_string($id)."'";
-	$result = Database::query($sql, __FILE__, __LINE__);
-	$row = Database::fetch_array($result);
-	if (!empty($row['image']))
-	{
-		unlink(api_get_path(SYS_PATH).'home/default_platform_document/template_thumb/'.$row['image']);
-	}
-
-	// now we remove it from the database
-	$sql = "DELETE FROM $table_system_template WHERE id = '".Database::escape_string($id)."'";
-	$result = Database::query($sql, __FILE__, __LINE__);
-
-	// display a feedback message
-	Display::display_confirmation_message(get_lang('TemplateDeleted'));
-}
-?>

+ 13 - 13
main/admin/special_exports.php

@@ -59,9 +59,9 @@ if ((isset ($_POST['action']) && $_POST['action'] == 'course_select_form') || (i
 		$to_group_id = 0;
 		$code_course = '';
 		$sql_session = "SELECT id, name FROM $tbl_session ";
-		$query_session = Database::query($sql_session, __FILE__, __LINE__);
+		$query_session = Database::query($sql_session);
 		$ListSession = array();
-		while($rows_session = mysql_fetch_assoc($query_session)) {
+		while ($rows_session = Database::fetch_assoc($query_session)) {
 			$ListSession[$rows_session['id']] = $rows_session['name'];
 		}
 		$zip_folder=new PclZip($FileZip['TEMP_FILE_ZIP']);
@@ -82,8 +82,8 @@ if ((isset ($_POST['action']) && $_POST['action'] == 'course_select_form') || (i
 						AND `docs`.`session_id` = '0'
 						AND `props`.`visibility`<>'2'
 						AND `props`.`to_group_id`=".$to_group_id."";
-				$query = Database::query($sql ,__FILE__,__LINE__);
-				while($rows_course_file = mysql_fetch_assoc($query)) {
+				$query = Database::query($sql );
+				while ($rows_course_file = Database::fetch_assoc($query)) {
 					$zip_folder->add($FileZip['PATH_COURSE'].$_course['directory']."/document".$rows_course_file['path'],
 									 PCLZIP_OPT_ADD_PATH, $_course['directory'],
 									 PCLZIP_OPT_REMOVE_PATH, $FileZip['PATH_COURSE'].$_course['directory']."/document".$FileZip['PATH_REMOVE']
@@ -100,8 +100,8 @@ if ((isset ($_POST['action']) && $_POST['action'] == 'course_select_form') || (i
 							AND `docs`.`session_id` = '$session_id'
 							AND `props`.`visibility`<>'2'
 							AND `props`.`to_group_id`=".$to_group_id."";
-					$query_session_doc = Database::query($sql_session_doc, __FILE__, __LINE__);
-					while($rows_course_session_file = mysql_fetch_assoc($query_session_doc)) {
+					$query_session_doc = Database::query($sql_session_doc);
+					while ($rows_course_session_file = Database::fetch_assoc($query_session_doc)) {
 						$zip_folder->add($FileZip['PATH_COURSE'].$_course['directory'].'/document'.$rows_course_session_file['path'],
 										 PCLZIP_OPT_ADD_PATH, $_course['directory']."/".$ListSession[$session_id],
 										 PCLZIP_OPT_REMOVE_PATH, $FileZip['PATH_COURSE'].$_course['directory'].'/document'.$FileZip['PATH_REMOVE']
@@ -135,7 +135,7 @@ function create_zip(){
 	$sys_course_path = api_get_path(SYS_COURSE_PATH);
 	$temp_zip_dir = $sys_archive_path."temp";
 	if(!is_dir($temp_zip_dir)) {
-		mkdir($temp_zip_dir);
+		mkdir($temp_zip_dir, api_get_permissions_for_new_directories());
 	} else {
 		$handle=opendir($temp_zip_dir);
 		while (false!==($file = readdir($handle))) {
@@ -194,8 +194,8 @@ function fullexportspecial(){
 					AND `docs`.`session_id` = '0'
 					AND `props`.`visibility`<>'2'
 					AND `props`.`to_group_id`=".$to_group_id."";
-			$query = Database::query($sql ,__FILE__,__LINE__);
-			while($rows_course_file = mysql_fetch_assoc($query)) {
+			$query = Database::query($sql );
+			while ($rows_course_file = Database::fetch_assoc($query)) {
 				$rows_course_file['path'];
 				$zip_folder->add($FileZip['PATH_COURSE'].$_course['directory']."/document".$rows_course_file['path'],
 								 PCLZIP_OPT_ADD_PATH, $_course['directory'],
@@ -207,8 +207,8 @@ function fullexportspecial(){
 			$sql_session = "SELECT id, name, course_code  FROM $tbl_session_course
 				INNER JOIN  $tbl_session ON id_session = id
 				WHERE course_code = '$code_course' ";
-			$query_session = Database::query($sql_session, __FILE__, __LINE__);
-			while($rows_session = mysql_fetch_assoc($query_session)) {
+			$query_session = Database::query($sql_session);
+			while ($rows_session = Database::fetch_assoc($query_session)) {
 				$session_id = $rows_session['id'];
 				$sql_session_doc = "SELECT path FROM $tbl_document AS docs,$tbl_property AS props
 					WHERE `props`.`tool`='".TOOL_DOCUMENT."'
@@ -218,8 +218,8 @@ function fullexportspecial(){
 						AND `docs`.`session_id` = '$session_id'
 						AND `props`.`visibility`<>'2'
 						AND `props`.`to_group_id`=".$to_group_id."";
-				$query_session_doc = Database::query($sql_session_doc, __FILE__, __LINE__);
-				while($rows_course_session_file = mysql_fetch_assoc($query_session_doc)) {
+				$query_session_doc = Database::query($sql_session_doc);
+				while ($rows_course_session_file = Database::fetch_assoc($query_session_doc)) {
 					$zip_folder->add($FileZip['PATH_COURSE'].$_course['directory'].'/document'.$rows_course_session_file['path'],
 									 PCLZIP_OPT_ADD_PATH, $_course['directory']."/".$rows_session['name'],
 									 PCLZIP_OPT_REMOVE_PATH, $FileZip['PATH_COURSE'].$_course['directory'].'/document'.$FileZip['PATH_REMOVE']

+ 9 - 8
main/admin/specific_fields.php

@@ -24,19 +24,20 @@
  * @package dokeos.admin
  */
 $language_file[] = 'admin';
-// including some necessary dokeos files
-require('../inc/global.inc.php');
+// Including some necessary chamilo files
+require '../inc/global.inc.php';
 
-// user permissions
+// User permissions
 api_protect_admin_script();
 
-// breadcrumb
-$interbreadcrumb[] = array ("url" => 'index.php', "name" => get_lang('PlatformAdmin'));
-$interbreadcrumb[] = array ("url" => 'specific_fields.php', "name" => get_lang('SpecificSearchFields'));
+// Breadcrumb
+$interbreadcrumb[] = array ('url' => 'index.php', 'name' => get_lang('PlatformAdmin'));
+$interbreadcrumb[] = array ('url' => 'specific_fields.php', 'name' => get_lang('SpecificSearchFields'));
 
 $libpath = api_get_path(LIBRARY_PATH);
-include_once ($libpath.'specific_fields_manager.lib.php');
-require_once ($libpath.'formvalidator/FormValidator.class.php');
+require_once $libpath.'sortabletable.class.php';
+include_once $libpath.'specific_fields_manager.lib.php';
+require_once $libpath.'formvalidator/FormValidator.class.php';
 
 // Create an add-field box
 $form = new FormValidator('add_field','post','','',null,false);

+ 27 - 9
main/admin/statistics/index.php

@@ -25,16 +25,17 @@
 * @package dokeos.statistics
 ==============================================================================
 */
-// name of the language file that needs to be included
-$language_file=array('admin','tracking');
+// Language files that need to be included
+$language_file = array('admin', 'tracking');
 $cidReset = true;
 
-include('../../inc/global.inc.php');
+require '../../inc/global.inc.php';
+require_once api_get_path(LIBRARY_PATH).'sortabletable.class.php';
 api_protect_admin_script();
 
-$interbreadcrumb[] = array ("url" => "../index.php", "name" => get_lang('PlatformAdmin'));
+$interbreadcrumb[] = array ('url' => '../index.php', 'name' => get_lang('PlatformAdmin'));
 
-$tool_name = get_lang('ToolName');
+$tool_name = get_lang('Statistics');
 Display::display_header($tool_name);
 api_display_tool_title($tool_name);
 
@@ -50,14 +51,15 @@ require_once ('statistics.lib.php');
 $strCourse  = get_lang('Courses');
 $strUsers = get_lang('Users');
 $strSystem = get_lang('System');
+$strSocial = get_lang('Social');
 
-
+// courses ...
 $tools[$strCourse]['action=courses'] = get_lang('CountCours');
 $tools[$strCourse]['action=tools'] = get_lang('PlatformToolAccess');
 $tools[$strCourse]['action=courselastvisit'] = get_lang('LastAccess');
 $tools[$strCourse]['action=coursebylanguage'] = get_lang('CountCourseByLanguage');
 
-
+// users ...
 $tools[$strUsers]['action=users'] = get_lang('CountUsers');
 $tools[$strUsers]['action=recentlogins'] = get_lang('Logins');
 $tools[$strUsers]['action=logins&amp;type=month'] = get_lang('Logins').' ('.get_lang('PeriodMonth').')';
@@ -65,8 +67,13 @@ $tools[$strUsers]['action=logins&amp;type=day'] = get_lang('Logins').' ('.get_la
 $tools[$strUsers]['action=logins&amp;type=hour'] = get_lang('Logins').' ('.get_lang('PeriodHour').')';
 $tools[$strUsers]['action=pictures'] = get_lang('CountUsers').' ('.get_lang('UserPicture').')';
 
+// system ...
 $tools[$strSystem]['action=activities'] = get_lang('ImportantActivities');
 
+// social ...
+$tools[$strSocial]['action=messagesent'] = get_lang('MessagesSent');
+$tools[$strSocial]['action=messagereceived'] = get_lang('MessagesReceived');
+$tools[$strSocial]['action=friends'] = get_lang('CountFriends');
 
 echo '<table><tr>';
 foreach($tools as $section => $items)
@@ -94,7 +101,6 @@ switch($_GET['action'])
 		}
 		// courses for each course category
 		statistics::print_stats(get_lang('CountCours'),$courses);
-
 		break;
 	case 'users':
 		// total amount of users
@@ -115,7 +121,6 @@ switch($_GET['action'])
 		statistics::print_stats(get_lang('Teachers'),$teachers);
 		// students for each course category
 		statistics::print_stats(get_lang('Students'),$students);
-
 		break;
 	case 'coursebylanguage':
 		statistics::print_course_by_language_stats();
@@ -138,6 +143,19 @@ switch($_GET['action'])
 	case 'activities':
 		statistics::print_activities_stats();
 		break;
+	case 'messagesent':
+		$messages_sent = statistics::get_messages('sent');
+		statistics::print_stats(get_lang('MessagesSent'), $messages_sent);
+		break;
+	case 'messagereceived':
+		$messages_received = statistics::get_messages('received');
+		statistics::print_stats(get_lang('MessagesReceived'), $messages_received);
+		break;
+	case 'friends':
+		// total amount of friends
+		$friends = statistics::get_friends();
+		statistics::print_stats(get_lang('CountFriends'), $friends);
+		break;
 }
 
 Display::display_footer();

+ 81 - 48
main/admin/statistics/statistics.lib.php

@@ -1,24 +1,5 @@
 <?php
-// $Id: index.php 8216 2006-11-3 18:03:15 NushiFirefox $
-/*
-==============================================================================
-	Dokeos - elearning and course management software
-
-	Copyright (c) 2006 Bart Mollet <bart.mollet@hogent.be>
-
-	For a full list of contributors, see "credits.txt".
-	The full license can be read in "license.txt".
-
-	This program is free software; you can redistribute it and/or
-	modify it under the terms of the GNU General Public License
-	as published by the Free Software Foundation; either version 2
-	of the License, or (at your option) any later version.
-
-	See the GNU General Public License for more details.
-
-	Contact: Dokeos, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com
-==============================================================================
-*/
+/* For licensing terms, see /license.txt */
 require_once (api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php');
 /**
 ==============================================================================
@@ -49,11 +30,10 @@ class Statistics
 	{
 		$course_table = Database :: get_main_table(TABLE_MAIN_COURSE);
 		$sql = "SELECT COUNT(*) AS number FROM ".$course_table." ";
-		if (isset ($category_code))
-		{
+		if (isset ($category_code)) {
 			$sql .= " WHERE category_code = '".Database::escape_string($category_code)."'";
 		}
-		$res = Database::query($sql, __FILE__, __LINE__);
+		$res = Database::query($sql);
 		$obj = Database::fetch_object($res);
 		return $obj->number;
 	}
@@ -72,11 +52,10 @@ class Statistics
 		$user_table 		= Database :: get_main_table(TABLE_MAIN_USER);
 
 		$sql = "SELECT COUNT(DISTINCT(user_id)) AS number FROM $user_table WHERE status = ".intval(Database::escape_string($status))." ";
-		if (isset ($category_code))
-		{
-			$sql = "SELECT COUNT(DISTINCT(cu.user_id)) AS number FROM $course_user_table cu, $course_table c WHERE cu.status = ".intval(Database::escape_string($status))." AND c.code = cu.course_code AND c.category_code = '".Database::escape_string($category_code)."'";
+		if (isset ($category_code)) {
+			$sql = "SELECT COUNT(DISTINCT(cu.user_id)) AS number FROM $course_user_table cu, $course_table c WHERE cu.status = ".intval(Database::escape_string($status))." AND c.code = cu.course_code AND c.category_code = '".Database::escape_string($category_code)."'  ";
 		}
-		$res = Database::query($sql, __FILE__, __LINE__);
+		$res = Database::query($sql);
 		$obj = Database::fetch_object($res);
 		return $obj->number;
 	}
@@ -89,15 +68,15 @@ class Statistics
 	{
 		// Database table definitions
 		$track_e_default  = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_DEFAULT);
-
+		$table_user = Database::get_main_table(TABLE_MAIN_USER);
 		$sql = "SELECT count(default_id) AS total_number_of_items FROM $track_e_default, $table_user user WHERE default_user_id = user.user_id ";
 
 		if (isset($_GET['keyword'])) {
-		$keyword = Database::escape_string($_GET['keyword']);
-		$sql .= " AND (user.username LIKE '%".$keyword."%' OR default_event_type LIKE '%".$keyword."%' OR default_value_type LIKE '%".$keyword."%' OR default_value LIKE '%".$keyword."%') ";
+			$keyword = Database::escape_string(trim($_GET['keyword']));
+			$sql .= " AND (user.username LIKE '%".$keyword."%' OR default_event_type LIKE '%".$keyword."%' OR default_value_type LIKE '%".$keyword."%' OR default_value LIKE '%".$keyword."%') ";
 		}
 
-		$res = Database::query($sql, __FILE__, __LINE__);
+		$res = Database::query($sql);
 		$obj = Database::fetch_object($res);
 		return $obj->total_number_of_items;
 	}
@@ -110,18 +89,26 @@ class Statistics
 		$track_e_default 	= Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_DEFAULT);
 		$table_user = Database::get_main_table(TABLE_MAIN_USER);
 		$table_course = Database::get_main_table(TABLE_MAIN_COURSE);
+		
+		$column 		 = intval($column);
+		$from 			 = intval($from);
+		$number_of_items = intval($number_of_items);
+		
+		if(!in_array($direction, array('ASC','DESC'))){
+        	$direction = 'DESC';
+		}        	
 
 		$sql = "SELECT
 				 	default_event_type  as col0,
 					default_value_type	as col1,
 					default_value		as col2,
-					user.username 	as col3,
-					default_date 	as col4
+					user.username 		as col3,
+					default_date 		as col4
 				FROM $track_e_default track_default, $table_user user
 				WHERE track_default.default_user_id = user.user_id ";
 
 		if (isset($_GET['keyword'])) {
-		$keyword = Database::escape_string($_GET['keyword']);
+		$keyword = Database::escape_string(trim($_GET['keyword']));
 		$sql .= " AND (user.username LIKE '%".$keyword."%' OR default_event_type LIKE '%".$keyword."%' OR default_value_type LIKE '%".$keyword."%' OR default_value LIKE '%".$keyword."%') ";
 		}
 
@@ -132,10 +119,10 @@ class Statistics
 		}
 		$sql .=	" LIMIT $from,$number_of_items ";
 
-		$res = Database::query($sql, __FILE__, __LINE__);
+		$res = Database::query($sql);
 		$activities = array ();
 		while ($row = Database::fetch_row($res)) {
-			$row[4] = api_format_date(DATE_TIME_FORMAT_LONG, strtotime($row[4]));
+			$row[4] = api_get_local_time($row[4], null, date_default_timezone_get());
 			$activities[] = $row;
 		}
 		return $activities;
@@ -148,8 +135,8 @@ class Statistics
 	function get_course_categories()
 	{
 		$category_table = Database :: get_main_table(TABLE_MAIN_CATEGORY);
-		$sql = "SELECT * FROM $category_table ORDER BY tree_pos";
-		$res = Database::query($sql, __FILE__, __LINE__);
+		$sql = "SELECT code, name FROM $category_table ORDER BY tree_pos";
+		$res = Database::query($sql);
 		$categories = array ();
 		while ($category = Database::fetch_object($res))
 		{
@@ -263,7 +250,7 @@ class Statistics
 				$sql = "SELECT DATE_FORMAT( login_date, '%w' ) AS stat_date , count( login_id ) AS number_of_logins FROM ".$table." GROUP BY stat_date ORDER BY DATE_FORMAT( login_date, '%w' ) ";
 				break;
 		}
-		$res = Database::query($sql,__FILE__,__LINE__);
+		$res = Database::query($sql);
 		$result = array();
 		while($obj = Database::fetch_object($res))
 		{
@@ -296,7 +283,7 @@ class Statistics
 		$sql[get_lang('Total')] 	 = "SELECT count(login_user_id) AS number  FROM $table";
 		foreach($sql as $index => $query)
 		{
-			$res = Database::query($query,__FILE__,__LINE__);
+			$res = Database::query($query);
 			$obj = Database::fetch_object($res);
 			$total_logins[$index] = $obj->number;
 		}
@@ -314,7 +301,7 @@ class Statistics
 			$tool_names[$tool] = get_lang(ucfirst($tool), '');
 		}
 		$sql = "SELECT access_tool, count( access_id ) AS number_of_logins FROM $table WHERE access_tool IN ('".implode("','",$tools)."') GROUP BY access_tool ";
-		$res = Database::query($sql,__FILE__,__LINE__);
+		$res = Database::query($sql);
 		$result = array();
 		while($obj = Database::fetch_object($res))
 		{
@@ -329,7 +316,7 @@ class Statistics
 	{
 		$table = Database::get_main_table(TABLE_MAIN_COURSE);
 		$sql = "SELECT course_language, count( code ) AS number_of_courses FROM $table GROUP BY course_language ";
-		$res = Database::query($sql,__FILE__,__LINE__);
+		$res = Database::query($sql);
 		$result = array();
 		while($obj = Database::fetch_object($res))
 		{
@@ -344,10 +331,10 @@ class Statistics
 	{
 		$user_table = Database :: get_main_table(TABLE_MAIN_USER);
 		$sql = "SELECT COUNT(*) AS n FROM $user_table";
-		$res = Database::query($sql,__FILE__,__LINE__);
+		$res = Database::query($sql);
 		$count1 = Database::fetch_object($res);
 		$sql = "SELECT COUNT(*) AS n FROM $user_table WHERE LENGTH(picture_uri) > 0";
-		$res = Database::query($sql,__FILE__,__LINE__);
+		$res = Database::query($sql);
 		$count2 = Database::fetch_object($res);
 		$result[get_lang('No')] = $count1->n - $count2->n; // #users without picture
 		$result[get_lang('Yes')] = $count2->n; // #users with picture
@@ -416,7 +403,7 @@ class Statistics
 		if (!isset($_GET['date_diff'])) {
 			$defaults['date_diff'] = 60;
 		} else {
-			$defaults['date_diff'] = Security::Remove_XSS($_GET['date_diff']);
+			$defaults['date_diff'] = Security::remove_XSS($_GET['date_diff']);
 		}
 		$form->setDefaults($defaults);
 		$form->display();
@@ -424,13 +411,13 @@ class Statistics
 		$date_diff = $values['date_diff'];
 		$table = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_LASTACCESS);
 		$sql = "SELECT * FROM $table GROUP BY access_cours_code HAVING access_cours_code <> '' AND DATEDIFF( NOW() , access_date ) <= ". $date_diff;
-		$res = Database::query($sql,__FILE__,__LINE__);
+		$res = Database::query($sql);
 		$number_of_courses = Database::num_rows($res);
 		$sql .= ' ORDER BY '.$columns[$column].' '.$sql_order[$direction];
 		$from = ($page_nr -1) * $per_page;
 		$sql .= ' LIMIT '.$from.','.$per_page;
 		echo '<p>'.get_lang('LastAccess').' &gt;= '.$date_diff.' '.get_lang('Days').'</p>';
-		$res = Database::query($sql, __FILE__, __LINE__);
+		$res = Database::query($sql);
 		if (Database::num_rows($res) > 0)
 		{
 			$courses = array ();
@@ -438,7 +425,7 @@ class Statistics
 			{
 				$course = array ();
 				$course[]= '<a href="'.api_get_path(WEB_PATH).'courses/'.$obj->access_cours_code.'">'.$obj->access_cours_code.' <a>';
-				$course[] = $obj->access_date;
+				$course[] = api_convert_and_format_date($obj->access_date, null, date_default_timezone_get());
 				$courses[] = $course;
 			}
 			$parameters['action'] = 'courselastvisit';
@@ -453,5 +440,51 @@ class Statistics
 			echo get_lang('NoSearchResults');
 		}
 	}
+
+	/**
+	 * Displays the statistics of the messages sent and received by each user in the social network
+	 * @param string	Type of message sent or received
+	 * @return array	Message list
+	 */
+	function get_messages($message_type) {
+		$message_table = Database::get_main_table(TABLE_MAIN_MESSAGE);
+		$user_table = Database::get_main_table(TABLE_MAIN_USER);
+		switch ($message_type) {
+			case 'sent':
+				$field = 'user_sender_id';
+				break;
+			case 'received':
+				$field = 'user_receiver_id';
+				break;
+		}
+		$sql = "SELECT lastname, firstname, username, COUNT($field) AS count_message
+					FROM ".$message_table." m LEFT JOIN ".$user_table." u ON m.$field = u.user_id
+				GROUP BY m.$field";
+		$res = Database::query($sql);
+		$messages_sent = array();
+		while ($messages = Database::fetch_array($res)) {
+			$users = $messages['firstname'].' '.$messages['lastname'].' ('.$messages['username'].')';
+			$messages_sent[$users] = $messages['count_message'];
+		}
+		return $messages_sent;
+	}
+
+	/**
+	 * Count the number of friends for social network users
+	 */
+	function get_friends() {
+		$user_friend_table = Database::get_main_table(TABLE_MAIN_USER_REL_USER);
+		$user_table = Database::get_main_table(TABLE_MAIN_USER);
+		$sql = "SELECT lastname, firstname, username, COUNT(friend_user_id) AS count_friend
+					FROM ".$user_friend_table." uf LEFT JOIN ".$user_table." u ON uf.user_id = u.user_id WHERE uf.relation_type <> '".USER_RELATION_TYPE_RRHH."'
+				GROUP BY uf.user_id";
+		$res = Database::query($sql);
+		$list_friends = array();
+		while ($friends = Database::fetch_array($res)) {
+			$users = $friends['firstname'].' '.$friends['lastname'].' ('.$friends['username'].')';
+			$list_friends[$users] = $friends['count_friend'];
+		}
+		return $list_friends;
+	}
 }
 ?>

+ 19 - 21
main/admin/style_preview.php

@@ -1,32 +1,34 @@
 <?php
-include_once('../inc/global.inc.php');
-if (isset($_GET['style']) AND $_GET['style']<>'')
-{
-	$style=Security::remove_XSS($_GET['style']);
-	//$htmlHeadXtra[] = '<link href="../css/'.$_GET['style'].'/default.css" rel="stylesheet" type="text/css">';
-	echo '<link href="../css/'.$style.'/default.css" rel="stylesheet" type="text/css">';
-}
-else
-{
+/* For licensing terms, see /chamilo_license.txt */
+require_once '../inc/global.inc.php';
+
+if (isset($_GET['style']) AND $_GET['style']<>'') {
+	$style=Security::remove_XSS($_GET['style']);	
+	$all_styles = api_get_themes();
+	if (in_array($style, $all_styles[0])) {
+		echo '<link href="../css/'.$style.'/default.css" rel="stylesheet" type="text/css">';
+	}
+} else {
 	$currentstyle = api_get_setting('stylesheets');
 	echo '<link href="../css/'.$currentstyle.'/default.css" rel="stylesheet" type="text/css">';
 }
 
-
 //Display::display_header($tool_name);
-include(api_get_path(INCLUDE_PATH).'banner.inc.php');
+require_once api_get_path(INCLUDE_PATH).'banner.inc.php';
 
 ?>
 <!-- start of #main wrapper for #content and #menu divs -->
   <!--   Begin Of script Output   -->
   <div class="maincontent">
-    <h3>tool title</h3>
+    <h3>Tool title</h3>
     <div id="courseintro">
       <p>This is the introduction text.
     </div>
     <div id="courseintro_icons">
     <a href="#"><?php Display::display_icon('edit.gif', get_lang('Edit')); ?></a><a href="#"><?php Display::display_icon('delete.gif', get_lang('Delete')); ?></a></div>
     <div class="normal-message"> Normal Message </div>
+    <div class="confirmation-message"> Confirmation Message </div>
+    <div class="warning-message"> Warning Message </div>
     <div class="error-message"> Error Message </div>
     <table width="750">
       <tr>
@@ -119,18 +121,14 @@ include(api_get_path(INCLUDE_PATH).'banner.inc.php');
             <tr>
               <th style="width:100px"><a href="#">Firstname</a>&nbsp;&#8595; </th>
               <th style="width:100px"><a href="#">Lastname</a></th>
-            </tr>
-            <tr class="row_even">
-              <td >Firstname</td>
-              <td >Lastname</td>
-            </tr>
+            </tr>           
             <tr class="row_odd">
-              <td >Julio</td>
-              <td >Montoya</td>
+              <td>Julio</td>
+              <td>Montoya</td>
             </tr>
             <tr class="row_even">
-              <td >Patrick</td>
-              <td >Cool</td>
+              <td>Yannick</td>
+              <td>Warnier</td>
             </tr>
           </table>
           <table width="100%">

+ 42 - 30
main/admin/sub_language.class.php

@@ -1,5 +1,5 @@
 <?php
-/* For licensing terms, see /dokeos_license.txt */
+/* For licensing terms, see /license.txt */
 /**
 ==================================================================================
 	@author Isaac flores paz <florespaz@bidsoftperu.com> - Added 9 july of 2009
@@ -52,7 +52,7 @@ class SubLanguageManager {
 	public static function get_all_information_of_sub_language ($parent_id,$sub_language_id) {
 		$tbl_admin_languages 	= Database :: get_main_table(TABLE_MAIN_LANGUAGE);
 	 	$sql='SELECT * FROM '.$tbl_admin_languages.' WHERE parent_id="'.Database::escape_string($parent_id).'" AND id="'.Database::escape_string($sub_language_id).'"';
-		$rs=Database::query($sql,__FILE__,__LINE__);
+		$rs=Database::query($sql);
 		$all_information=array();
 		while ($row=Database::fetch_array($rs,'ASSOC')) {
 			$all_information=$row;
@@ -67,7 +67,7 @@ class SubLanguageManager {
    public static function get_all_information_of_language ($parent_id) {
  		$tbl_admin_languages 	= Database :: get_main_table(TABLE_MAIN_LANGUAGE);
 		$sql='SELECT * FROM '.$tbl_admin_languages.' WHERE id="'.Database::escape_string($parent_id).'"';
-		$rs=Database::query($sql,__FILE__,__LINE__);
+		$rs=Database::query($sql);
 		$all_information=array();
 		while ($row=Database::fetch_array($rs,'ASSOC')) {
 			$all_information=$row;
@@ -119,12 +119,8 @@ class SubLanguageManager {
      * @return boolean
      */
    public static function add_directory_of_sub_language($path_sub_language) {
-   		$rs=@mkdir($path_sub_language,0777);
-		if ($rs) {
-			return true;
-		} else {
-			return false;
-		}
+   		//return @mkdir($path_sub_language, 0777) !== false;
+   		return @mkdir($path_sub_language, api_get_permissions_for_new_directories()) !== false;
    }
 	 /**
 	 * Delete sub-language
@@ -132,9 +128,9 @@ class SubLanguageManager {
 	 * @return void()
 	 */
    public static function removed_sub_language ($parent_id,$sub_language_id) {
-   		$tbl_admin_languages 	= Database :: get_main_table(TABLE_MAIN_LANGUAGE);
-		$sql='DELETE FROM '.$tbl_admin_languages.' WHERE parent_id="'.Database::escape_string($parent_id).'" AND id="'.Database::escape_string($sub_language_id).'" ';
-    	$rs=Database::query($sql,__FILE__,__LINE__);
+   		$tbl_admin_languages = Database :: get_main_table(TABLE_MAIN_LANGUAGE);
+		$sql = 'DELETE FROM '.$tbl_admin_languages.' WHERE parent_id="'.Database::escape_string($parent_id).'" AND id="'.Database::escape_string($sub_language_id).'" ';
+    	Database::query($sql);
    }
    	/**
 	 * check if language exist by id
@@ -144,7 +140,7 @@ class SubLanguageManager {
 	public static function check_if_exist_language_by_id ($language_id) {
 		$tbl_admin_languages 	= Database :: get_main_table(TABLE_MAIN_LANGUAGE);
 		$sql='SELECT count(*) as count FROM '.$tbl_admin_languages.' WHERE id="'.Database::escape_string($language_id).'"';
-		$rs=Database::query($sql,__FILE__,__LINE__);
+		$rs=Database::query($sql);
 		if (Database::num_rows($rs)>0) {
 			if (Database::result($rs,0,'count') ==1) {
 				return true;
@@ -164,7 +160,7 @@ class SubLanguageManager {
 	public static function get_name_of_language_by_id ($language_id) {
 		$tbl_admin_languages 	= Database :: get_main_table(TABLE_MAIN_LANGUAGE);
 		$sql='SELECT original_name FROM '.$tbl_admin_languages.' WHERE id="'.Database::escape_string($language_id).'"';
-		$rs=Database::query($sql,__FILE__,__LINE__);
+		$rs=Database::query($sql);
 		if (Database::num_rows($rs)>0) {
 			return Database::result($rs,0,'original_name');
 		} else {
@@ -180,7 +176,7 @@ class SubLanguageManager {
 	public static function check_if_language_is_sub_language ($language_id) {
 	$tbl_admin_languages 	= Database :: get_main_table(TABLE_MAIN_LANGUAGE);
 	$sql='SELECT count(*) AS count FROM '.$tbl_admin_languages.' WHERE id="'.Database::escape_string($language_id).'" AND NOT ISNULL(parent_id)';
-    $rs=Database::query($sql,__FILE__,__LINE__);
+    $rs=Database::query($sql);
 
     if (Database::num_rows($rs)>0 && Database::result($rs,'0','count')==1) {
     	return true;
@@ -196,7 +192,7 @@ class SubLanguageManager {
 	public static function check_if_language_is_father ($language_id) {
 		$tbl_admin_languages 	= Database :: get_main_table(TABLE_MAIN_LANGUAGE);
 		$sql='SELECT count(*) AS count FROM '.$tbl_admin_languages.' WHERE parent_id="'.Database::escape_string($language_id).'" AND NOT ISNULL(parent_id);';
-	    $rs=Database::query($sql,__FILE__,__LINE__);
+	    $rs=Database::query($sql);
 
 	    if (Database::num_rows($rs)>0 && Database::result($rs,'0','count')==1) {
 	    	return true;
@@ -212,31 +208,47 @@ class SubLanguageManager {
 	public static function make_unavailable_language ($language_id) {
 		$tbl_admin_languages= Database :: get_main_table(TABLE_MAIN_LANGUAGE);
 		$sql_make_unavailable = "UPDATE $tbl_admin_languages SET available='0' WHERE id='".Database::escape_string($language_id)."'";
-		$result = Database::query($sql_make_unavailable,__FILE__,__LINE__);
+		$result = Database::query($sql_make_unavailable);
 	}
 	/**
 	 * Make available the language
 	 * @param Integer The language id
-	 * @return void()
+	 * @return void
 	 */
-	 public static function make_available_language ($language_id) {
+	public static function make_available_language ($language_id) {
 	 	$tbl_admin_languages= Database :: get_main_table(TABLE_MAIN_LANGUAGE);
 	 	$sql_make_available = "UPDATE $tbl_admin_languages SET available='1' WHERE id='".Database::escape_string($language_id)."'";
-		$result = Database::query($sql_make_available,__FILE__,__LINE__);
-	 }
-	 /**
-	  * Set platform language
-	  * @param Integer The language id
-	  * @return void()
-	  */
-	  public static function set_platform_language ($language_id) {
-		$tbl_admin_languages= Database :: get_main_table(TABLE_MAIN_LANGUAGE);
+		$result = Database::query($sql_make_available);
+	}
+	/**
+	 * Set platform language
+	 * @param Integer The language id
+	 * @return void()
+	 */
+    public static function set_platform_language ($language_id) {
+		$tbl_admin_languages = Database :: get_main_table(TABLE_MAIN_LANGUAGE);
 		$tbl_settings_current 	= Database :: get_main_table(TABLE_MAIN_SETTINGS_CURRENT);
 		$sql_update = "SELECT english_name FROM ". $tbl_admin_languages." WHERE id='".Database::escape_string($language_id)."'";
-		$result = Database::query($sql_update,__FILE__,__LINE__);
+		$result = Database::query($sql_update);
 		$lang=Database::fetch_array($result);
 		$sql_update_2 = "UPDATE ".$tbl_settings_current." SET selected_value='".$lang['english_name']."' WHERE variable='platformLanguage'";
 		$result_2 = Database::query($sql_update_2);
-	  }
+    }
+	/**
+	 * Get parent language path (or null if no parent)
+	 * @param    string  Children language path
+	 * @return   string  Parent language path or null
+	 */
+    public static function get_parent_language_path ($language_path) {
+        $tbl_admin_languages = Database :: get_main_table(TABLE_MAIN_LANGUAGE);
+        $tbl_settings_current   = Database :: get_main_table(TABLE_MAIN_SETTINGS_CURRENT);
+        $sql_update = "SELECT dokeos_folder FROM ". $tbl_admin_languages." WHERE id=(SELECT parent_id FROM ". $tbl_admin_languages." WHERE dokeos_folder = '".Database::escape_string($language_path)."')";
+        $result = Database::query($sql_update);
+        if (Database::num_rows($result) == 0) {
+        	return null;
+        }
+        $row = Database::fetch_array($result);
+        return $row['dokeos_folder'];
+    }
 }
 ?>

+ 1 - 0
main/admin/sub_language.php

@@ -9,6 +9,7 @@
 $language_file = 'admin';
 $cidReset = true;
 require_once '../inc/global.inc.php';
+require_once api_get_path(LIBRARY_PATH).'sortabletable.class.php';
 require_once 'sub_language.class.php';
 require_once api_get_path(LIBRARY_PATH).'array.lib.php';
 $this_section=SECTION_PLATFORM_ADMIN;

+ 98 - 68
main/admin/sub_language_add.php

@@ -1,24 +1,23 @@
 <?php
 /* For licensing terms, see /dokeos_license.txt */
-/*
-==============================================================================
-		INIT SECTION
-==============================================================================
-*/
+/**
+ * This script allows for the addition of sub-languages
+ * @package chamilo.admin
+ */
+/**
+ * Initialization section
+ */
 // name of the language file that needs to be included
 $language_file = 'admin';
 $cidReset = true;
 require_once '../inc/global.inc.php';
 require_once 'sub_language.class.php';
-$this_section=SECTION_PLATFORM_ADMIN;
-
+$this_section = SECTION_PLATFORM_ADMIN;
 api_protect_admin_script();
 
-/*
-==============================================================================
-		MAIN CODE
-==============================================================================
-*/
+/**
+ *		MAIN CODE
+ */
 // setting the name of the tool
 $tool_name = get_lang('CreateSubLanguage');
 
@@ -29,26 +28,42 @@ $interbreadcrumb[] = array ('url' => 'languages.php', 'name' => get_lang('Platfo
 require_once api_get_path(LIBRARY_PATH).'text.lib.php';
 require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php';
 
-/*declare functions*/
 /**
  * Add sub-language
+ * @param   string  Original language name (Occitan, Wallon, Vlaams)
+ * @param   string  English language name (occitan, wallon, flanders)
+ * @param   string  ISO code (fr_FR, ...)
+ * @param   int     Whether the sublanguage is published (0=unpublished, 1=published)
+ * @param   int     ID del idioma padre
+ * @return  void
  */
 function add_sub_language ($original_name,$english_name,$isocode,$sublanguage_available,$parent_id) {
 	$tbl_admin_languages 	= Database :: get_main_table(TABLE_MAIN_LANGUAGE);
 	$sql='INSERT INTO '.$tbl_admin_languages.'(original_name,english_name,isocode,dokeos_folder,available,parent_id) VALUES ("'.api_htmlentities($original_name).'","'.$english_name.'","'.$isocode.'","'.$english_name.'","'.$sublanguage_available.'","'.$parent_id.'")';
-	Database::query($sql,__FILE__,__LINE__);
+	Database::query($sql);
 }
 /**
- * check if language exists
+ * Check if language exists
+ * @param   string  Original language name (Occitan, Wallon, Vlaams)
+ * @param   string  English language name (occitan, wallon, flanders)
+ * @param   string  ISO code (fr_FR, ...)
+ * @param   int     Whether the sublanguage is published (0=unpublished, 1=published)
+ * @return  array   Array describing the number of items found that match the 
+ *                  current language insert attempt (original_name => true, 
+ *                  english_name => true, isocode => true, 
+ *                  execute_add => true/false). If execute_add is true, then we
+ *                  can proceed.
+ * @todo This function is not transaction-safe and should probably be included
+ *       inside the add_sub_language function.
  */
 function check_if_language_exist ($original_name,$english_name,$isocode,$sublanguage_available) {
 	$tbl_admin_languages 	= Database :: get_main_table(TABLE_MAIN_LANGUAGE);
 	$sql_original_name='SELECT count(*) AS count_original_name FROM '.$tbl_admin_languages.' WHERE original_name="'.Database::escape_string(api_htmlentities($original_name)).'" ';
 	$sql_english_name='SELECT count(*) AS count_english_name FROM '.$tbl_admin_languages.' WHERE english_name="'.Database::escape_string($english_name).'" ';
 	$sql_isocode='SELECT count(*) AS count_isocode FROM '.$tbl_admin_languages.' WHERE isocode="'.Database::escape_string($isocode).'" ';
-	$rs_original_name=Database::query($sql_original_name,__FILE__,__LINE__);
-	$rs_english_name=Database::query($sql_english_name,__FILE__,__LINE__);
-	$rs_isocode=Database::query($sql_isocode,__FILE__,__LINE__);
+	$rs_original_name=Database::query($sql_original_name);
+	$rs_english_name=Database::query($sql_english_name);
+	$rs_isocode=Database::query($sql_isocode);
 	$count_original_name=Database::result($rs_original_name,0,'count_original_name');
 	$count_english_name=Database::result($rs_english_name,0,'count_english_name');
 	$count_isocode=Database::result($rs_isocode,0,'count_isocode');
@@ -78,23 +93,33 @@ function check_if_language_exist ($original_name,$english_name,$isocode,$sublang
 }
 
 /**
- * get name of language by id
+ * Get the name of a language by id. This is just a wrapper for the 
+ * SubLanguageManager::get_name_of_language_by_id() method and should not exist
+ * @param   int     Language ID
+ * @return  string  Language name
+ * @todo    deprecate this function and use the static method directly
  */
 function get_name_of_language_by_id ($language_id) {
 	return SubLanguageManager::get_name_of_language_by_id($language_id);
 }
 /**
- * check if language exist by id
+ * Check if language exist, given its ID. This is just a wrapper for the 
+ * SubLanguageManager::check_if_exist_language_by_id() method and should not exist
+ * @param   int     Language ID
+ * @return  bool
+ * @todo    deprecate this function and use the static method directly
  */
 function check_if_exist_language_by_id ($language_id) {
 	return SubLanguageManager::check_if_exist_language_by_id($language_id);
 }
 /**
- * check if is parent of sub-language
+ * Check if the given language is a parent of any sub-language
+ * @param   int     Language ID of the presumed parent
+ * @return  bool    True if this language has children, false otherwise
  */
 function ckeck_if_is_parent_of_sub_language ($parent_id) {
 	$sql='SELECT count(*) AS count FROM language WHERE parent_id="'.Database::escape_string($parent_id).'"';
-	$rs=Database::query($sql,__FILE__,__LINE__);
+	$rs=Database::query($sql);
 	if (Database::num_rows($rs)>0 && Database::result($rs,0,'count')==1) {
 		return true;
 	} else {
@@ -103,6 +128,9 @@ function ckeck_if_is_parent_of_sub_language ($parent_id) {
 }
 /**
  * Get all information of sub-language
+ * @param   int     Parent language ID
+ * @param   int     Child language ID
+ * @return  array
  */
 function allow_get_all_information_of_sub_language ($parent_id,$sub_language_id) {
 	return SubLanguageManager::get_all_information_of_sub_language($parent_id,$sub_language_id);
@@ -110,30 +138,34 @@ function allow_get_all_information_of_sub_language ($parent_id,$sub_language_id)
 
 /**
  * Add directory for sub-language
+ * @param   string  Path of new sub-language
+ * @return
  */
 function add_directory_of_sub_language ($path_sub_language) {
 	return SubLanguageManager::add_directory_of_sub_language($path_sub_language);
 }
 /**
  * Remove directory of sub-language
+ * @param   string  Path of new sub_language
+ * @return  bool    True on success, false otherwise
  */
 function remove_directory_of_sub_language ($path) {
-	$content=SubLanguageManager::get_all_data_of_dokeos_folder($path);
+	$content = SubLanguageManager::get_all_data_of_dokeos_folder($path);
 
 	if (count($content)>0) {
 		foreach ($content as $value_content) {
-			$path_file=$path.'/'.$value_content;
+			$path_file = $path.'/'.$value_content;
 			unlink($path_file);
 		}
-		$rs=@rmdir($path);
-		if ($rs===true) {
+		$rs = @rmdir($path);
+		if ($rs === true) {
 			return true;
 		} else {
 			return false;
 		}
 	} else {
-		$rs=@rmdir($path);
-		if ($rs===true) {
+		$rs = @rmdir($path);
+		if ($rs === true) {
 			return true;
 		} else {
 			return false;
@@ -225,11 +257,13 @@ if (isset($_POST['SubmitAddNewLanguage'])) {
 			$path=api_get_path('SYS_LANG_PATH').$english_name;
 
 			$mkdir_result=add_directory_of_sub_language($path);
-			if ($mkdir_result===true) {
+			if ($mkdir_result) {
 			  	add_sub_language($original_name,$english_name,$isocode,$sublanguage_available,$parent_id);
-			  	Display::display_confirmation_message(get_lang('TheNewSubLanguageHasBeenAdd').$str_info,false);
+			  	$link = '<br /><br /><a href="languages.php">'.get_lang('ReturnToLanguagesList').'</a>';
+			  	Display::display_confirmation_message(get_lang('TheNewSubLanguageHasBeenAdded').$str_info.$link,false);
+			  	$succeeded = true;
 			} else {
-				  Display::display_error_message(get_lang('LanguageDirectoryNotWriteableContactAdmin'));
+			    Display::display_error_message(get_lang('LanguageDirectoryNotWriteableContactAdmin'));
 			}
 		} else {
 			if ($language_id_exist===false) {
@@ -237,7 +271,7 @@ if (isset($_POST['SubmitAddNewLanguage'])) {
 			}
 		}
 	} else {
-			Display::display_error_message(get_lang('FormHasErrorsPleaseComplete'));
+        Display::display_error_message(get_lang('FormHasErrorsPleaseComplete'));
 	}
 }
 if (isset($_POST['SubmitAddDeleteLanguage'])) {
@@ -251,43 +285,39 @@ if (isset($_POST['SubmitAddDeleteLanguage'])) {
 
 	}
 }
-     // ckeck_if_is_parent_of_sub_language($parent_id)===false
-	//
-	if (isset($_GET['action']) && $_GET['action']=='definenewsublanguage') {
+// ckeck_if_is_parent_of_sub_language($parent_id)===false
+//
+if (isset($_GET['action']) && $_GET['action']=='definenewsublanguage') {
+	$text = $language_name;
+	$form = new FormValidator('addsublanguage', 'post', 'sub_language_add.php?id='.Security::remove_XSS($_GET['id']).'&action=definenewsublanguage');
+	$class='add';
+	$form->addElement('header', '', $text);
+	$form->addElement('text', 'original_name', get_lang('OriginalName'),'class="input_titles"');
+	$form->addRule('original_name', get_lang('ThisFieldIsRequired'), 'required');
+	$form->addElement('text', 'english_name', get_lang('EnglishName'),'class="input_titles"');
+	$form->addRule('english_name', get_lang('ThisFieldIsRequired'), 'required');
+	$form->addElement('text', 'isocode', get_lang('ISOCode'),'class="input_titles"');
+	$form->addRule('isocode', get_lang('ThisFieldIsRequired'), 'required');
+	$form->addElement('checkbox', 'sub_language_is_visible', '', get_lang('Visibility'));
+	$form->addElement('style_submit_button', 'SubmitAddNewLanguage', get_lang('CreateSubLanguage'), 'class="'.$class.'"');
+	$form->display();
+} else {
+	if (isset($_GET['action']) && $_GET['action']=='deletesublanguage') {
 		$text=$language_name;
-		$form = new FormValidator('addsublanguage', 'post', 'sub_language_add.php?id='.Security::remove_XSS($_GET['id']).'&action=definenewsublanguage');
-		$class='add';
+		$form = new FormValidator('deletesublanguage', 'post', 'sub_language_add.php?id='.Security::remove_XSS($_GET['id']).'&sub_language_id='.Security::remove_XSS($_GET['sub_language_id']));
+		$class='minus';
 		$form->addElement('header', '', $text);
-		$form->addElement('text', 'original_name', get_lang('OriginalName'),'class="input_titles"');
-		$form->addRule('original_name', get_lang('ThisFieldIsRequired'), 'required');
-		$form->addElement('text', 'english_name', get_lang('EnglishName'),'class="input_titles"');
-		$form->addRule('english_name', get_lang('ThisFieldIsRequired'), 'required');
-		$form->addElement('text', 'isocode', get_lang('PlatformCharsetTitle'),'class="input_titles"');
-		$form->addRule('isocode', get_lang('ThisFieldIsRequired'), 'required');
-		$form->addElement('checkbox', 'sub_language_is_visible', '', get_lang('Visibility'));
-		$form->addElement('style_submit_button', 'SubmitAddNewLanguage', get_lang('CreateSubLanguage'), 'class="'.$class.'"');
+		$form->addElement('static', '', get_lang('OriginalName'),$original_name);
+		$form->addElement('static', '', get_lang('EnglishName'),$english_name);
+		$form->addElement('static', '', get_lang('PlatformCharsetTitle'),$isocode);
+		$form->addElement('style_submit_button', 'SubmitAddDeleteLanguage', get_lang('DeleteSubLanguage'), 'class="'.$class.'"');
 		$form->display();
-	} else {
-		if (isset($_GET['action']) && $_GET['action']=='deletesublanguage') {
-			$text=$language_name;
-			$form = new FormValidator('deletesublanguage', 'post', 'sub_language_add.php?id='.Security::remove_XSS($_GET['id']).'&sub_language_id='.Security::remove_XSS($_GET['sub_language_id']));
-			$class='minus';
-			$form->addElement('header', '', $text);
-			$form->addElement('static', '', get_lang('OriginalName'),$original_name);
-			$form->addElement('static', '', get_lang('EnglishName'),$english_name);
-			$form->addElement('static', '', get_lang('PlatformCharsetTitle'),$isocode);
-			$form->addElement('style_submit_button', 'SubmitAddDeleteLanguage', get_lang('DeleteSubLanguage'), 'class="'.$class.'"');
-			$form->display();
-		}
-		if (isset($_GET['action']) && $_GET['action']=='definenewsublanguage') {
-			Display::display_normal_message(get_lang('TheSubLanguageForThisLanguageHasBeenAdd'));
-		}
 	}
-
-/*
-==============================================================================
-		FOOTER
-==============================================================================
-*/
-Display :: display_footer();
-?>
+	if (isset($_GET['action']) && $_GET['action']=='definenewsublanguage') {
+		Display::display_normal_message(get_lang('TheSubLanguageForThisLanguageHasBeenAdded'));
+	}
+}
+/**
+ * Footer
+ */
+Display :: display_footer();

+ 1 - 1
main/admin/sub_language_ajax.inc.php

@@ -22,7 +22,7 @@ if (isset($new_language) && isset($language_variable) && isset($file_id)) {
 	SubLanguageManager::add_file_in_language_directory ($dokeos_path_folder);
 
 	//update variable language
-	$all_file_of_directory[$language_variable]="\"".mb_convert_encoding($new_language,$charset,'UTF-8')."\";";
+	$all_file_of_directory[$language_variable]="\"".api_convert_encoding($new_language,$charset,'UTF-8')."\";";
 
 	foreach ($all_file_of_directory as $key_value=>$value_info) {
 		SubLanguageManager::write_data_in_file ($dokeos_path_folder,$value_info,$key_value);

+ 2 - 2
main/admin/subscribe_class2course.php

@@ -99,10 +99,10 @@ if ($_POST['formSent'])
 }
 
 $sql = "SELECT id,name FROM $tbl_class WHERE name LIKE '".$first_letter_class."%' ORDER BY ". (count($classes) > 0 ? "(id IN('".implode("','", $classes)."')) DESC," : "")." name";
-$result = Database::query($sql, __FILE__, __LINE__);
+$result = Database::query($sql);
 $db_classes = Database::store_result($result);
 $sql = "SELECT code,visual_code,title FROM $tbl_course WHERE visual_code LIKE '".$first_letter_course."%' ORDER BY ". (count($courses) > 0 ? "(code IN('".implode("','", $courses)."')) DESC," : "")." visual_code";
-$result = Database::query($sql, __FILE__, __LINE__);
+$result = Database::query($sql);
 $db_courses = Database::store_result($result);
 if (!empty ($error_message))
 {

+ 3 - 3
main/admin/subscribe_user2class.php

@@ -53,7 +53,7 @@ $tbl_class_user = Database :: get_main_table(TABLE_MAIN_CLASS_USER);
 $tbl_user 		= Database :: get_main_table(TABLE_MAIN_USER);
 
 $sql = "SELECT name FROM $tbl_class WHERE id='$class_id'";
-$result = Database::query($sql, __FILE__, __LINE__);
+$result = Database::query($sql);
 
 if (!list ($class_name) = Database::fetch_row($result))
 {
@@ -115,10 +115,10 @@ Display :: display_header($tool_name);
 //api_display_tool_title($tool_name);
 $target_name = api_sort_by_first_name() ? 'firstname' : 'lastname';
 $sql = "SELECT u.user_id,lastname,firstname,username FROM $tbl_user u LEFT JOIN $tbl_class_user cu ON u.user_id=cu.user_id AND class_id='$class_id' WHERE ".$target_name." LIKE '".$first_letter_left."%' AND class_id IS NULL ORDER BY ". (count($left_user_list) > 0 ? "(user_id IN(".implode(',', $left_user_list).")) DESC," : "")." ".$target_name;
-$result = Database::query($sql, __FILE__, __LINE__);
+$result = Database::query($sql);
 $left_users = Database::store_result($result);
 $sql = "SELECT u.user_id,lastname,firstname,username FROM $tbl_user u,$tbl_class_user cu WHERE cu.user_id=u.user_id AND class_id='$class_id' AND ".$target_name." LIKE '".$first_letter_right."%' ORDER BY ". (count($right_user_list) > 0 ? "(user_id IN(".implode(',', $right_user_list).")) DESC," : "")." ".$target_name;
-$result = Database::query($sql, __FILE__, __LINE__);
+$result = Database::query($sql);
 $right_users = Database::store_result($result);
 if (!empty ($error_message))
 {

+ 3 - 3
main/admin/subscribe_user2course.php

@@ -162,7 +162,7 @@ if ($_POST['form_sent']) {
 */
 if(empty($first_letter_user)) {
 	$sql = "SELECT count(*) as nb_users FROM $tbl_user";
-	$result = Database::query($sql, __FILE__, __LINE__);
+	$result = Database::query($sql);
 	$num_row = Database::fetch_array($result);
 	if($num_row['nb_users']>1000)
 	{//if there are too much users to gracefully handle with the HTML select list,
@@ -238,7 +238,7 @@ if ($_configuration['multiple_access_urls']==true) {
 	}
 }
 
-$result = Database::query($sql, __FILE__, __LINE__);
+$result = Database::query($sql);
 $db_users = Database::store_result($result);
 unset($result);
 
@@ -256,7 +256,7 @@ if ($_configuration['multiple_access_urls']==true) {
 	}
 }
 
-$result = Database::query($sql, __FILE__, __LINE__);
+$result = Database::query($sql);
 $db_courses = Database::store_result($result);
 unset($result);
 

+ 36 - 74
main/admin/system_announcements.php

@@ -1,38 +1,10 @@
 <?php // $Id: system_announcements.php 22243 2009-07-20 15:08:31Z ivantcholakov $
-/*
-==============================================================================
-	Dokeos - elearning and course management software
-
-	Copyright (c) 2004-2008 Dokeos SPRL
-	Copyright (c) 2003 Ghent University (UGent)
-	Copyright (c) 2001 Universite catholique de Louvain (UCL)
-	Copyright (c) 2005 Bart Mollet, Hogeschool Gent
-
-	For a full list of contributors, see "credits.txt".
-	The full license can be read in "license.txt".
-
-	This program is free software; you can redistribute it and/or
-	modify it under the terms of the GNU General Public License
-	as published by the Free Software Foundation; either version 2
-	of the License, or (at your option) any later version.
-
-	See the GNU General Public License for more details.
-
-	Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
-	Mail: info@dokeos.com
-==============================================================================
-*/
+/* For licensing terms, see /license.txt */
 /**
-==============================================================================
 *	This page allows the administrator to manage the system announcements.
-*	@package dokeos.admin
-==============================================================================
-*/
-/*
-==============================================================================
-		INIT SECTION
-==============================================================================
+*	@package chamilo.admin
 */
+/*		INIT SECTION */
 // name of the language file that needs to be included
 $language_file = array ('admin', 'agenda');
 
@@ -40,13 +12,14 @@ $language_file = array ('admin', 'agenda');
 $cidReset = true;
 
 // including the global dokeos files
-include ('../inc/global.inc.php');
+require '../inc/global.inc.php';
 
 // including additional libraries
+require_once api_get_path(LIBRARY_PATH).'sortabletable.class.php';
 require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php';
-include (api_get_path(LIBRARY_PATH).'system_announcements.lib.php');
-include_once(api_get_path(LIBRARY_PATH).'WCAG/WCAG_rendering.php');
-require_once (api_get_path(LIBRARY_PATH).'mail.lib.inc.php');
+require_once api_get_path(LIBRARY_PATH).'system_announcements.lib.php';
+require_once api_get_path(LIBRARY_PATH).'WCAG/WCAG_rendering.php';
+require_once api_get_path(LIBRARY_PATH).'mail.lib.inc.php';
 
 // setting the section (for the tabs)
 $this_section=SECTION_PLATFORM_ADMIN;
@@ -60,9 +33,8 @@ $interbreadcrumb[] = array ("url" => 'index.php', "name" => get_lang('PlatformAd
 
 $tool_name = get_lang('SystemAnnouncements');
 
-if(empty($_GET['lang']))
-{
-    $_GET['lang']=$_SESSION['user_language_choice'];
+if(empty($_GET['lang'])) {
+    $_GET['lang']=	$_SESSION['user_language_choice'];
 }
 
 // displaying the header
@@ -74,8 +46,7 @@ Display :: display_header($tool_name);
 ==============================================================================
 */
 
-if($_GET['action'] != 'add' && $_GET['action'] != 'edit')
-{
+if($_GET['action'] != 'add' && $_GET['action'] != 'edit') {
 	echo '<div class="actions">';
 	echo '<a href="?action=add">'.Display::return_icon('announce_add.gif', get_lang('langAddAnnouncement')).get_lang('langAddAnnouncement').'</a>';
 	echo '</div>';
@@ -97,10 +68,9 @@ if (isset ($_GET['action']) && $_GET['action'] == 'make_visible')
 			break;
 	}
 }
-if (isset ($_GET['action']) && $_GET['action'] == 'make_invisible')
-{
-	switch ($_GET['person'])
-	{
+
+if (isset ($_GET['action']) && $_GET['action'] == 'make_invisible') {
+	switch ($_GET['person']) {
 		case VISIBLE_TEACHER :
 			SystemAnnouncementManager :: set_visibility($_GET['id'], VISIBLE_TEACHER, false);
 			break;
@@ -114,30 +84,25 @@ if (isset ($_GET['action']) && $_GET['action'] == 'make_invisible')
 }
 
 // Form was posted?
-if (isset ($_POST['action']))
-{
+if (isset ($_POST['action'])) {
 	$action_todo = true;
 }
 
 // Delete an announcement
-if (isset ($_GET['action']) && $_GET['action'] == 'delete')
-{
+if (isset ($_GET['action']) && $_GET['action'] == 'delete') {
 	SystemAnnouncementManager :: delete_announcement($_GET['id']);
 	Display :: display_confirmation_message(get_lang('AnnouncementDeleted'));
 }
 // Delete selected announcements
-if (isset ($_POST['action']) && $_POST['action'] == 'delete_selected')
-{
-	foreach($_POST['id'] as $index => $id)
-	{
+if (isset ($_POST['action']) && $_POST['action'] == 'delete_selected') {
+	foreach($_POST['id'] as $index => $id) {
 		SystemAnnouncementManager :: delete_announcement($id);
 	}
 	Display :: display_confirmation_message(get_lang('AnnouncementDeleted'));
 	$action_todo = false;
 }
 // Add an announcement
-if (isset ($_GET['action']) && $_GET['action'] == 'add')
-{
+if (isset ($_GET['action']) && $_GET['action'] == 'add') {
 	$values['action'] = 'add';
 	// Set default time window: NOW -> NEXT WEEK
 	$values['start'] = date('Y-m-d H:i:s');
@@ -145,24 +110,23 @@ if (isset ($_GET['action']) && $_GET['action'] == 'add')
 	$action_todo = true;
 }
 // Edit an announcement
-if (isset ($_GET['action']) && $_GET['action'] == 'edit')
-{
-	$announcement = SystemAnnouncementManager :: get_announcement($_GET['id']);
-	$values['id'] = $announcement->id;
-	$values['title'] = $announcement->title;
-	$values['content'] = $announcement->content;
-	$values['start'] = $announcement->date_start;
-	$values['end'] = $announcement->date_end;
-	$values['visible_teacher'] = $announcement->visible_teacher;
-	$values['visible_student'] = $announcement->visible_student ;
-	$values['visible_guest'] = $announcement->visible_guest ;
-	$values['lang'] = $announcement->lang;
-	$values['action'] = 'edit';
+if (isset ($_GET['action']) && $_GET['action'] == 'edit') {
+
+	$announcement 				= SystemAnnouncementManager :: get_announcement($_GET['id']);
+	$values['id'] 				= $announcement->id;
+	$values['title'] 			= $announcement->title;
+	$values['content']			= $announcement->content;
+	$values['start'] 			= $announcement->date_start;
+	$values['end'] 				= $announcement->date_end;
+	$values['visible_teacher'] 	= $announcement->visible_teacher;
+	$values['visible_student'] 	= $announcement->visible_student ;
+	$values['visible_guest'] 	= $announcement->visible_guest ;
+	$values['lang'] 			= $announcement->lang;
+	$values['action']			= 'edit';
 	$action_todo = true;
 }
 
-if ($action_todo)
-{
+if ($action_todo) {
 	if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'add') {
 		$form_title = get_lang('AddNews');
 	} elseif (isset($_REQUEST['action']) && $_REQUEST['action'] == 'edit') {
@@ -238,9 +202,7 @@ if ($action_todo)
 				if(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']))
 				{
 					Display :: display_confirmation_message(get_lang('AnnouncementAdded'));
-				}
-				else
-				{
+				} else {
 					$show_announcement_list = false;
 					$form->display();
 				}
@@ -284,8 +246,8 @@ 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->date_start;
-		$row[] = $announcement->date_end;
+		$row[] = api_convert_and_format_date($announcement->date_start, null, date_default_timezone_get());
+		$row[] = api_convert_and_format_date($announcement->date_end, null, date_default_timezone_get());
 		$row[] = "<a href=\"?id=".$announcement->id."&amp;person=".VISIBLE_TEACHER."&amp;action=". ($announcement->visible_teacher ? 'make_invisible' : 'make_visible')."\">".Display::return_icon(($announcement->visible_teacher  ? 'visible.gif' : 'invisible.gif'), get_lang('show_hide'))."</a>";
 		$row[] = "<a href=\"?id=".$announcement->id."&amp;person=".VISIBLE_STUDENT."&amp;action=". ($announcement->visible_student  ? 'make_invisible' : 'make_visible')."\">".Display::return_icon(($announcement->visible_student  ? 'visible.gif' : 'invisible.gif'), get_lang('show_hide'))."</a>";
 		$row[] = "<a href=\"?id=".$announcement->id."&amp;person=".VISIBLE_GUEST."&amp;action=". ($announcement->visible_guest ? 'make_invisible' : 'make_visible')."\">".Display::return_icon(($announcement->visible_guest  ? 'visible.gif' : 'invisible.gif'), get_lang('show_hide'))."</a>";

+ 88 - 0
main/admin/system_status.php

@@ -0,0 +1,88 @@
+<?php
+/* For licensing terms, see /license.txt */
+/**
+*	@package chamilo.admin
+* 	@author Julio Montoya <gugli100@gmail.com>
+*/
+
+// Language files that should be included
+$language_file = array('admin', 'registration');
+$cidReset = true;
+
+require_once '../inc/global.inc.php';
+$this_section = SECTION_PLATFORM_ADMIN;
+require_once api_get_path(LIBRARY_PATH).'diagnoser.lib.php';
+require_once api_get_path(LIBRARY_PATH).'sortabletable.class.php';
+
+// User permissions
+api_protect_admin_script();
+$interbreadcrumb[] = array ('url' => 'index.php', 'name' => get_lang('PlatformAdmin'));
+Display :: display_header(get_lang('SystemStatus'));
+
+/* @todo this will be moved to default.css */
+?>
+<style>
+/*****************************************************
+ *  SEMANTIC TABBES PANE STYLES                      *
+ *****************************************************/
+.tabbed-pane {
+	clear: both;
+}
+
+.tabbed-pane-tabs {
+	list-style: none;
+	margin: 0;
+	padding: 0 0 0 1em;
+	height: 0; /* for IE */
+}
+
+.tabbed-pane-tabs li {
+	display: inline;
+	float: left;
+	margin: 0 0.5ex 0 0;
+	padding: 0;
+}
+
+.tabbed-pane-tabs li a {
+	display: block;
+	margin: 0.25em 0 -1px 0;
+	padding: 0.25em 1em;
+	background: #E5EDF9;
+	color: #4171b5;
+	text-decoration: none;
+	border: 1px solid #4271b5;
+	-moz-border-radius-topleft: 5px;
+	-moz-border-radius-topright: 5px;
+	-webkit-border-top-left-radius: 5px;
+	-webkit-border-top-right-radius: 5px;
+}
+
+.tabbed-pane-tabs li a:hover,.tabbed-pane-tabs li a.current {
+	background: white;
+	margin-top: 0;
+	padding-bottom: 0.5em;
+	border-bottom-color: white;
+	color: #4171b5;
+}
+
+.tabbed-pane-tabs li a:active,.tabbed-pane-tabs li a.current,.tabbed-pane-tabs li a.current:hover {
+	color: black;
+}
+
+.tabbed-pane-content {
+	clear: both;
+	border: 1px solid #4271b5;
+	margin: 0;
+	padding: 1em;
+	min-height: 15em;
+	-moz-border-radius-topright: 10px;
+	-moz-border-radius-bottomleft: 10px;
+	-webkit-border-top-right-radius: 10px;
+	-webkit-border-bottom-left-radius: 10px;
+}
+</style>
+<?php
+$diag = new Diagnoser();
+$diag->show_html();
+
+Display :: display_footer();

+ 19 - 18
main/admin/user_add.php

@@ -1,18 +1,17 @@
 <?php
-/* For licensing terms, see /dokeos_license.txt */
+/* For licensing terms, see /license.txt */
 /**
 ==============================================================================
-*	@package dokeos.admin
+*	@package chamilo.admin
 ==============================================================================
 */
 
 // Language files that should be included
 $language_file = array('admin', 'registration');
-
 $cidReset = true;
 
 // Including necessary libraries.
-require '../inc/global.inc.php';
+require_once '../inc/global.inc.php';
 $libpath = api_get_path(LIBRARY_PATH);
 require_once $libpath.'fileManage.lib.php';
 require_once $libpath.'fileUpload.lib.php';
@@ -55,11 +54,15 @@ function display_drh_list(){
 		document.getElementById("drh_list").style.display="block";
 		document.getElementById("id_platform_admin").style.display="none";
 	}
+	else if (document.getElementById("status_select").value=='.COURSEMANAGER.')
+	{
+		document.getElementById("drh_list").style.display="none";
+		document.getElementById("id_platform_admin").style.display="block";	
+	}
 	else
 	{
 		document.getElementById("drh_list").style.display="none";
-		document.getElementById("id_platform_admin").style.display="block";
-		document.getElementById("drh_select").options[0].selected="selected";
+		document.getElementById("id_platform_admin").style.display="none";
 	}
 }
 
@@ -148,14 +151,16 @@ $form->addElement('select', 'status', get_lang('Status'), $status, array('id' =>
 $form->addElement('select_language', 'language', get_lang('Language'));
 //drh list (display only if student)
 $display = ($_POST['status'] == STUDENT || !isset($_POST['status'])) ? 'block' : 'none';
+
+
 $form->addElement('html', '<div id="drh_list" style="display:'.$display.';">');
-$drh_select = $form->addElement('select', 'hr_dept_id', get_lang('Drh'), array(), 'id="drh_select"');
+/*$drh_select = $form->addElement('select', 'hr_dept_id', get_lang('Drh'), array(), 'id="drh_select"');
 $drh_list = UserManager :: get_user_list(array('status' => DRH), api_sort_by_first_name() ? array('firstname', 'lastname') : array('lastname', 'firstname'));
 if (count($drh_list) == 0) {
 	$drh_select->addOption('- '.get_lang('ThereIsNotStillAResponsible', '').' -', 0);
 } else {
 	$drh_select->addOption('- '.get_lang('SelectAResponsible').' -', 0);
-}
+}*/
 
 if (is_array($drh_list)) {
 	foreach ($drh_list as $drh) {
@@ -164,6 +169,8 @@ if (is_array($drh_list)) {
 }
 $form->addElement('html', '</div>');
 
+
+
 // Platform admin
 $group = array();
 $group[] =& HTML_QuickForm::createElement('radio', 'platform_admin', 'id="id_platform_admin"', get_lang('Yes'), 1);
@@ -296,10 +303,6 @@ $defaults = array_merge($defaults, $extra_data);
 $form->setDefaults($defaults);
 
 // Submit button
-/*
-$form->addElement('style_submit_button', 'submit', get_lang('Add'), 'class="add"');
-$form->addElement('style_submit_button', 'submit_plus', get_lang('Add').'+', 'class="add"');
-*/
 $select_level = array ();
 $html_results_enabled[] = FormValidator :: createElement ('style_submit_button', 'submit_plus', get_lang('Add').'+', 'class="add"');
 $html_results_enabled[] = FormValidator :: createElement ('style_submit_button', 'submit', get_lang('Add'), 'class="add"');
@@ -313,9 +316,7 @@ if( $form->validate()) {
 
 		$picture_element = & $form->getElement('picture');
 		$picture = $picture_element->getValue();
-
 		$picture_uri = '';
-
 		$lastname = $user['lastname'];
 		$firstname = $user['firstname'];
 		$official_code = $user['official_code'];
@@ -358,7 +359,7 @@ if( $form->validate()) {
 
 		if ($platform_admin) {
 			$sql = "INSERT INTO $table_admin SET user_id = '".$user_id."'";
-			Database::query($sql,__FILE__,__LINE__);
+			Database::query($sql);
 		}
 		if (!empty($email) && $send_mail) {
 			$recipient_name = api_get_person_name($firstname, $lastname, null, PERSON_NAME_EMAIL_ADDRESS);
@@ -369,7 +370,7 @@ if( $form->validate()) {
 
 			if ($_configuration['multiple_access_urls'] == true) {
 				$access_url_id = api_get_current_access_url_id();
-				if ($access_url_id != -1) { 
+				if ($access_url_id != -1) {
 					$url = api_get_access_url($access_url_id);
 					$emailbody = get_lang('Dear')." ".stripslashes(api_get_person_name($firstname, $lastname)).",\n\n".get_lang('YouAreReg')." ".api_get_setting('siteName') ." ".get_lang('WithTheFollowingSettings')."\n\n".get_lang('Username')." : ". $username ."\n". get_lang('Pass')." : ".stripslashes($password)."\n\n" .get_lang('Address') ." ". api_get_setting('siteName') ." ". get_lang('Is') ." : ". $url['url'] ."\n\n". get_lang('Problem'). "\n\n". get_lang('Formula').",\n\n".api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'))."\n". get_lang('Manager'). " ".api_get_setting('siteName')."\nT. ".api_get_setting('administratorTelephone')."\n" .get_lang('Email') ." : ".api_get_setting('emailAdministrator');
 				}
@@ -383,7 +384,7 @@ if( $form->validate()) {
 		if (isset($user['submit_plus'])) {
 			//we want to add more. Prepare report message and redirect to the same page (to clean the form)
 			$tok = Security::get_token();
-			header('Location: user_add.php?message='.urlencode(get_lang('UserAdded')).'&sec_token='.$tok);
+			header('Location: user_add.php?message='.urlencode(get_lang('UserAdded')).'&sec_token='.$tok);			
 			exit ();
 		} else {
 			$tok = Security::get_token();
@@ -409,4 +410,4 @@ if(!empty($message)){
 $form->display();
 
 // Footer
-Display::display_footer();
+Display::display_footer();

+ 120 - 97
main/admin/user_edit.php

@@ -35,14 +35,17 @@ function password_switch_radio_button(){
 }
 
 function display_drh_list(){
-	if(document.getElementById("status_select").value=='.STUDENT.')
+	if(document.getElementById("status_select").value=='.COURSEMANAGER.')
 	{
-		document.getElementById("drh_list").style.display="block";
+		document.getElementById("id_platform_admin").style.display="block";
+	}
+	else if (document.getElementById("status_select").value=='.STUDENT.')
+	{
+		document.getElementById("id_platform_admin").style.display="none";	
 	}
 	else
 	{
-		document.getElementById("drh_list").style.display="none";
-		document.getElementById("drh_select").options[0].selected="selected";
+		document.getElementById("id_platform_admin").style.display="none";
 	}
 }
 
@@ -72,7 +75,7 @@ $interbreadcrumb[] = array('url' => "user_list.php","name" => get_lang('UserList
 $table_user = Database::get_main_table(TABLE_MAIN_USER);
 $table_admin = Database::get_main_table(TABLE_MAIN_ADMIN);
 $sql = "SELECT u.*, a.user_id AS is_admin FROM $table_user u LEFT JOIN $table_admin a ON a.user_id = u.user_id WHERE u.user_id = '".$user_id."'";
-$res = Database::query($sql, __FILE__, __LINE__);
+$res = Database::query($sql);
 if (Database::num_rows($res) != 1) {
 	header('Location: user_list.php');
 	exit;
@@ -82,6 +85,8 @@ $user_data = Database::fetch_array($res, 'ASSOC');
 $user_data['platform_admin'] = is_null($user_data['is_admin']) ? 0 : 1;
 $user_data['send_mail'] = 0;
 $user_data['old_password'] = $user_data['password'];
+//Convert the registration date of the user
+$user_data['registration_date'] = api_get_local_time($user_data['registration_date'], null, date_default_timezone_get());
 unset($user_data['password']);
 
 $user_data = array_merge($user_data, Usermanager :: get_extra_user_data($user_id, true));
@@ -168,13 +173,20 @@ $group[] =& HTML_QuickForm::createElement('password', 'password', null, array('o
 $form->addGroup($group, 'password', null, '', false);
 
 // Status
-$status = api_get_status_langvars();
+$status = array();
+$status[COURSEMANAGER] = get_lang('Teacher');
+$status[STUDENT] = get_lang('Learner');
+$status[DRH] = get_lang('Drh');
+$status[SESSIONADMIN] = get_lang('SessionsAdmin');
+
 $form->addElement('select', 'status', get_lang('Status'), $status, array('id' => 'status_select', 'onchange' => 'javascript: display_drh_list();'));
 
 //Language
 $form->addElement('select_language', 'language', get_lang('Language'));
 
 $display = $user_data['status'] == STUDENT || $_POST['status'] == STUDENT ? 'block' : 'none';
+
+/*
 $form->addElement('html', '<div id="drh_list" style="display:'.$display.';">');
 $drh_select = $form->addElement('select', 'hr_dept_id', get_lang('Drh'), array(), 'id="drh_select"');
 $drh_list = UserManager :: get_user_list(array('status' => DRH), api_sort_by_first_name() ? array('firstname', 'lastname') : array('lastname', 'firstname'));
@@ -189,17 +201,21 @@ foreach($drh_list as $drh) {
 	$drh_select->addOption(api_get_person_name($drh['firstname'], $drh['lastname']), $drh['user_id']);
 }
 $form->addElement('html', '</div>');
+*/
 
 // Platform admin
 // Only when changing another user!
-if ($user_id != $_SESSION['_uid']) {
+//if ($user_id != $_user['user_id']) {
 	$group = array();
 	$group[] =& HTML_QuickForm::createElement('radio', 'platform_admin', null, get_lang('Yes'), 1);
 	$group[] =& HTML_QuickForm::createElement('radio', 'platform_admin', null, get_lang('No'), 0);
-	if ($user_data['status'] <> 5) {
-		$form->addGroup($group, 'admin', get_lang('PlatformAdmin'), '&nbsp;', false);
-	}
-}
+	
+	$user_data['status'] == 1 ? $display = 'block':$display = 'none';
+	
+	$form->addElement('html', '<div id="id_platform_admin" style="display:'.$display.'">');
+	$form->addGroup($group, 'admin', get_lang('PlatformAdmin'), null, false);
+	$form->addElement('html', '</div>');
+//}
 
 // Send email
 $group = array();
@@ -302,108 +318,115 @@ if ($expiration_date == '0000-00-00 00:00:00') {
 }
 $form->setDefaults($user_data);
 
+$error_drh = false;
 // Validate form
 if ( $form->validate()) {
+	
 	$user = $form->exportValues();
-
-	$picture_element = & $form->getElement('picture');
-	$picture = $picture_element->getValue();
-
-	$picture_uri = $user_data['picture_uri'];
-	if ($user['delete_picture']) {
-		$picture_uri = UserManager::delete_user_picture($user_id);
+	$is_user_subscribed_in_course = CourseManager::is_user_subscribed_in_course($user['user_id']);
+	
+	if ($user['status'] == DRH && $is_user_subscribed_in_course) {
+		$error_drh = true;	
+	} else {		
+		$picture_element = & $form->getElement('picture');
+		$picture = $picture_element->getValue();
+	
+		$picture_uri = $user_data['picture_uri'];
+		if ($user['delete_picture']) {
+			$picture_uri = UserManager::delete_user_picture($user_id);
+			}
+		elseif (!empty($picture['name'])) {
+			$picture_uri = UserManager::update_user_picture($user_id, $_FILES['picture']['name'], $_FILES['picture']['tmp_name']);
 		}
-	elseif (!empty($picture['name'])) {
-		$picture_uri = UserManager::update_user_picture($user_id, $_FILES['picture']['name'], $_FILES['picture']['tmp_name']);
-	}
-
-	$lastname = $user['lastname'];
-	$firstname = $user['firstname'];
-	$official_code = $user['official_code'];
-	$email = $user['email'];
-	$phone = $user['phone'];
-	$username = $user['username'];
-	$status = intval($user['status']);
-	$platform_admin = intval($user['platform_admin']);
-	$send_mail = intval($user['send_mail']);
-	$reset_password = intval($user['reset_password']);
-	$hr_dept_id = intval($user['hr_dept_id']);
-	$language = $user['language'];
-	if ($user['radio_expiration_date'] == '1' && !$user_data['platform_admin']) {
-		$expiration_date=$user['expiration_date'];
-	} else {
-		$expiration_date='0000-00-00 00:00:00';
-	}
-	$active = $user_data['platform_admin'] ? 1 : intval($user['active']);
-
-	if ($reset_password == 0) {
-		$password = null;
-		$auth_source = $user_data['auth_source'];
-	}
-	elseif($reset_password == 1) {
-		$password = api_generate_password();
-		$auth_source = PLATFORM_AUTH_SOURCE;
-	}
-	elseif($reset_password == 2) {
-		$password = $user['password'];
-		$auth_source = PLATFORM_AUTH_SOURCE;
-	}
-	elseif($reset_password == 3) {
-		$password = $user['password'];
-		$auth_source = $user['auth_source'];
-	}
-	UserManager::update_user($user_id, $firstname, $lastname, $username, $password, $auth_source, $email, $status, $official_code, $phone, $picture_uri, $expiration_date, $active, null, $hr_dept_id, null, $language);
-	if (api_get_setting('openid_authentication') == 'true' && !empty($user['openid'])) {
-		$up = UserManager::update_openid($user_id,$user['openid']);
-	}
-	if ($user_id != $_SESSION['_uid']) {
-		if ($platform_admin == 1) {
-			$sql = "INSERT IGNORE INTO $table_admin SET user_id = '".$user_id."'";
-			Database::query($sql, __FILE__, __LINE__);
+	
+		$lastname = $user['lastname'];
+		$firstname = $user['firstname'];
+		$official_code = $user['official_code'];
+		$email = $user['email'];
+		$phone = $user['phone'];
+		$username = $user['username'];
+		$status = intval($user['status']);
+		$platform_admin = intval($user['platform_admin']);
+		$send_mail = intval($user['send_mail']);
+		$reset_password = intval($user['reset_password']);
+		$hr_dept_id = intval($user['hr_dept_id']);
+		$language = $user['language'];
+		if ($user['radio_expiration_date'] == '1' && !$user_data['platform_admin']) {
+			$expiration_date=$user['expiration_date'];
 		} else {
-			$sql = "DELETE FROM $table_admin WHERE user_id = '".$user_id."'";
-			Database::query($sql, __FILE__, __LINE__);
+			$expiration_date='0000-00-00 00:00:00';
 		}
-	}
-
-	$extras = array();
-	foreach($user as $key => $value) {
-		if(substr($key, 0, 6) == 'extra_') { //an extra field
-			$myres = UserManager::update_extra_field_value($user_id, substr($key, 6), $value);
+		$active = $user_data['platform_admin'] ? 1 : intval($user['active']);
+	
+		if ($reset_password == 0) {
+			$password = null;
+			$auth_source = $user_data['auth_source'];
 		}
-	}
-
-	if (!empty ($email) && $send_mail) {
-		$recipient_name = api_get_person_name($firstname, $lastname, null, PERSON_NAME_EMAIL_ADDRESS);
-		$emailsubject = '['.api_get_setting('siteName').'] '.get_lang('YourReg').' '.api_get_setting('siteName');
-		$sender_name = api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'), null, PERSON_NAME_EMAIL_ADDRESS);
-		$email_admin = api_get_setting('emailAdministrator');
-
-		if ($_configuration['multiple_access_urls'] == true) {
-			$access_url_id = api_get_current_access_url_id();
-			if ($access_url_id != -1) {
-				$url = api_get_access_url($access_url_id);
-				$emailbody = get_lang('Dear')." ".stripslashes(api_get_person_name($firstname, $lastname)).",\n\n".get_lang('YouAreReg')." ". api_get_setting('siteName') ." ".get_lang('WithTheFollowingSettings')."\n\n".get_lang('Username')." : ". $username ."\n". get_lang('Pass')." : ".stripslashes($password)."\n\n" .get_lang('Address') ." ". api_get_setting('siteName') ." ". get_lang('Is') ." : ". $url['url'] ."\n\n". get_lang('Problem'). "\n\n". get_lang('Formula').",\n\n".api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'))."\n". get_lang('Manager'). " ".api_get_setting('siteName')."\nT. ".api_get_setting('administratorTelephone')."\n" .get_lang('Email') ." : ".api_get_setting('emailAdministrator');
+		elseif($reset_password == 1) {
+			$password = api_generate_password();
+			$auth_source = PLATFORM_AUTH_SOURCE;
+		}
+		elseif($reset_password == 2) {
+			$password = $user['password'];
+			$auth_source = PLATFORM_AUTH_SOURCE;
+		}
+		elseif($reset_password == 3) {
+			$password = $user['password'];
+			$auth_source = $user['auth_source'];
+		}
+		UserManager::update_user($user_id, $firstname, $lastname, $username, $password, $auth_source, $email, $status, $official_code, $phone, $picture_uri, $expiration_date, $active, null, $hr_dept_id, null, $language);
+		if (api_get_setting('openid_authentication') == 'true' && !empty($user['openid'])) {
+			$up = UserManager::update_openid($user_id,$user['openid']);
+		}
+		if ($user_id != $_SESSION['_uid']) {
+			if ($platform_admin == 1) {
+				$sql = "INSERT IGNORE INTO $table_admin SET user_id = '".$user_id."'";
+				Database::query($sql);
+			} else {
+				$sql = "DELETE FROM $table_admin WHERE user_id = '".$user_id."'";
+				Database::query($sql);
 			}
 		}
-		else {
-			$emailbody=get_lang('Dear')." ".stripslashes(api_get_person_name($firstname, $lastname)).",\n\n".get_lang('YouAreReg')." ". api_get_setting('siteName') ." ".get_lang('WithTheFollowingSettings')."\n\n".get_lang('Username')." : ". $username ."\n". get_lang('Pass')." : ".stripslashes($password)."\n\n" .get_lang('Address') ." ". api_get_setting('siteName') ." ". get_lang('Is') ." : ". $_configuration['root_web'] ."\n\n". get_lang('Problem'). "\n\n". get_lang('Formula').",\n\n".api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'))."\n". get_lang('Manager'). " ".api_get_setting('siteName')."\nT. ".api_get_setting('administratorTelephone')."\n" .get_lang('Email') ." : ".api_get_setting('emailAdministrator');
+	
+		$extras = array();
+		foreach($user as $key => $value) {
+			if(substr($key, 0, 6) == 'extra_') { //an extra field
+				$myres = UserManager::update_extra_field_value($user_id, substr($key, 6), $value);
+			}
 		}
-
-		$emailbody = get_lang('Dear')." ".stripslashes("$firstname $lastname").",\n\n".get_lang('YouAreReg')." ". api_get_setting('siteName') ." ".get_lang('WithTheFollowingSettings')."\n\n".get_lang('Username')." : ". $username;
-		// Send password by e-mail if it has been modified, even if encrypted in DB (it doesn't make sense to send an e-mail with login info without the password, even if the password is encrypted)
-		if ($reset_password > 0) {
-			$emailbody .= "\n".get_lang('Pass')." : ".stripslashes($password);
+	
+		if (!empty ($email) && $send_mail) {
+			$recipient_name = api_get_person_name($firstname, $lastname, null, PERSON_NAME_EMAIL_ADDRESS);
+			$emailsubject = '['.api_get_setting('siteName').'] '.get_lang('YourReg').' '.api_get_setting('siteName');
+			$sender_name = api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'), null, PERSON_NAME_EMAIL_ADDRESS);
+			$email_admin = api_get_setting('emailAdministrator');
+	
+			if ($_configuration['multiple_access_urls'] == true) {
+				$access_url_id = api_get_current_access_url_id();
+				if ($access_url_id != -1) {
+					$url = api_get_access_url($access_url_id);
+					$emailbody = get_lang('Dear')." ".stripslashes(api_get_person_name($firstname, $lastname)).",\n\n".get_lang('YouAreReg')." ". api_get_setting('siteName') ." ".get_lang('WithTheFollowingSettings')."\n\n".get_lang('Username')." : ". $username . (($reset_password > 0) ? "\n". get_lang('Pass')." : ".stripslashes($password) : "") . "\n\n" .get_lang('Address') ." ". api_get_setting('siteName') ." ". get_lang('Is') ." : ". $url['url'] ."\n\n". get_lang('Problem'). "\n\n". get_lang('Formula').",\n\n".api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'))."\n". get_lang('Manager'). " ".api_get_setting('siteName')."\nT. ".api_get_setting('administratorTelephone')."\n" .get_lang('Email') ." : ".api_get_setting('emailAdministrator');
+				}
+			}
+			else {
+				$emailbody=get_lang('Dear')." ".stripslashes(api_get_person_name($firstname, $lastname)).",\n\n".get_lang('YouAreReg')." ". api_get_setting('siteName') ." ".get_lang('WithTheFollowingSettings')."\n\n".get_lang('Username')." : ". $username . (($reset_password > 0) ? "\n". get_lang('Pass')." : ".stripslashes($password) : "") . "\n\n" .get_lang('Address') ." ". api_get_setting('siteName') ." ". get_lang('Is') ." : ". $_configuration['root_web'] ."\n\n". get_lang('Problem'). "\n\n". get_lang('Formula').",\n\n".api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'))."\n". get_lang('Manager'). " ".api_get_setting('siteName')."\nT. ".api_get_setting('administratorTelephone')."\n" .get_lang('Email') ." : ".api_get_setting('emailAdministrator');
+			}
+	
+			@api_mail($recipient_name, $email, $emailsubject, $emailbody, $sender_name, $email_admin);
 		}
-		@api_mail($recipient_name, $email, $emailsubject, $emailbody, $sender_name, $email_admin);
+		$tok = Security::get_token();
+		header('Location: user_list.php?action=show_message&message='.urlencode(get_lang('UserUpdated')).'&sec_token='.$tok);
+		exit();				
 	}
-	$tok = Security::get_token();
-	header('Location: user_list.php?action=show_message&message='.urlencode(get_lang('UserUpdated')).'&sec_token='.$tok);
-	exit();
 }
 
 Display::display_header($tool_name);
 
+if ($error_drh) {	
+	$err_msg = get_lang('StatusCanNotBeChangedToHumanResourcesManager');
+	Display::display_error_message($err_msg);	
+}
+
 // USER PICTURE
 $image_path = UserManager::get_user_picture_path_by_id($user_id,'web');
 $image_dir = $image_path['dir'];

+ 6 - 5
main/admin/user_export.php

@@ -67,7 +67,7 @@ if ($_configuration['multiple_access_urls']==true) {
 		ORDER BY visual_code";
 	}
 }
-$result = Database::query($sql, __FILE__, __LINE__);
+$result = Database::query($sql);
 while ($course = Database::fetch_object($result))
 {
 	$courses[$course->code] = $course->visual_code.' - '.$course->title;
@@ -100,7 +100,7 @@ if ($form->validate())
 					u.official_code	AS OfficialCode,
 					u.phone		AS Phone";
 	if (strlen($course_code) > 0) {
-		$sql .= " FROM $user_table u, $course_user_table cu WHERE u.user_id = cu.user_id AND course_code = '$course_code' ORDER BY lastname,firstname";
+		$sql .= " FROM $user_table u, $course_user_table cu WHERE u.user_id = cu.user_id AND course_code = '$course_code' AND cu.relation_type<>".COURSE_RELATION_TYPE_RRHH." ORDER BY lastname,firstname";
 		$filename = 'export_users_'.$course_code.'_'.date('Y-m-d_H-i-s');
 	} else {
 		global $_configuration;
@@ -134,7 +134,7 @@ if ($form->validate())
 		}
 
 	}
-	$res = Database::query($sql,__FILE__,__LINE__);
+	$res = Database::query($sql);
 	while($user = Database::fetch_array($res,'ASSOC')) {
 		$student_data= UserManager :: get_extra_user_data($user['UserId'],true,false);
 		foreach($student_data as $key=>$value) {
@@ -148,13 +148,14 @@ if ($form->validate())
 		$data[] = $user	;
 	}
 
-	switch($file_type)
-	{
+	switch($file_type) {
 		case 'xml':
 			Export::export_table_xml($data,$filename,'Contact','Contacts');
+			exit;
 			break;
 		case 'csv':
 			Export::export_table_csv($data,$filename);
+			exit;
 			break;
 	}
 }

+ 14 - 12
main/admin/user_fields.php

@@ -6,14 +6,15 @@
 ==============================================================================
 */
 // name of the language file that needs to be included
-$language_file = array('admin','registration');
+$language_file = array('admin', 'registration');
 $cidReset = true;
 
 // including necessary libraries
-require ('../inc/global.inc.php');
+require '../inc/global.inc.php';
 $libpath = api_get_path(LIBRARY_PATH);
-include_once ($libpath.'usermanager.lib.php');
-require_once ($libpath.'formvalidator/FormValidator.class.php');
+require_once $libpath.'sortabletable.class.php';
+require_once $libpath.'usermanager.lib.php';
+require_once $libpath.'formvalidator/FormValidator.class.php';
 
 // section for the tabs
 $this_section=SECTION_PLATFORM_ADMIN;
@@ -212,6 +213,7 @@ function type_filter($type)
 	$types[USER_FIELD_TYPE_DOUBLE_SELECT] 		= get_lang('FieldTypeDoubleSelect');
 	$types[USER_FIELD_TYPE_DIVIDER] 			= get_lang('FieldTypeDivider');
 	$types[USER_FIELD_TYPE_TAG] 				= get_lang('FieldTypeTag');
+	$types[USER_FIELD_TYPE_TIMEZONE]			= get_lang('FieldTypeTimezone');
 	return $types[$type];
 }
 
@@ -319,7 +321,7 @@ function move_user_field($direction,$field_id)
 	$found = false;
 
 	$sql = "SELECT id, field_order FROM $table_user_field ORDER BY field_order $sortdirection";
-	$result = Database::query($sql,__FILE__,__LINE__);
+	$result = Database::query($sql);
 	while($row = Database::fetch_array($result))
 	{
 		if ($found)
@@ -339,8 +341,8 @@ function move_user_field($direction,$field_id)
 
 	$sql1 = "UPDATE ".$table_user_field." SET field_order = '".Database::escape_string($next_order)."' WHERE id =  '".Database::escape_string($this_id)."'";
 	$sql2 = "UPDATE ".$table_user_field." SET field_order = '".Database::escape_string($this_order)."' WHERE id =  '".Database::escape_string($next_id)."'";
-	Database::query($sql1,__FILE__,__LINE__);
-	Database::query($sql2,__FILE__,__LINE__);
+	Database::query($sql1);
+	Database::query($sql2);
 
 	return true;
 }
@@ -364,26 +366,26 @@ function delete_user_fields($field_id)
 
 	// delete the fields
 	$sql = "DELETE FROM $table_user_field WHERE id = '".Database::escape_string($field_id)."'";
-	$result = Database::query($sql,__FILE__,__LINE__);
+	$result = Database::query($sql);
 	if (Database::affected_rows() == 1)
 	{
 		// delete the field options
 		$sql = "DELETE FROM $table_user_field_options WHERE field_id = '".Database::escape_string($field_id)."'";
-		$result = Database::query($sql,__FILE__,__LINE__);
+		$result = Database::query($sql);
 
 		// delete the field values
 		$sql = "DELETE FROM $table_user_field_values WHERE field_id = '".Database::escape_string($field_id)."'";
-		$result = Database::query($sql,__FILE__,__LINE__);
+		$result = Database::query($sql);
 
 		// recalculate the field_order because the value is used to show/hide the up/down icon
 		// and the field_order value cannot be bigger than the number of fields
 		$sql = "SELECT * FROM $table_user_field ORDER BY field_order ASC";
-		$result = Database::query($sql,__FILE__,__LINE__);
+		$result = Database::query($sql);
 		$i = 1;
 		while($row = Database::fetch_array($result))
 		{
 			$sql_reorder = "UPDATE $table_user_field SET field_order = '".Database::escape_string($i)."' WHERE id = '".Database::escape_string($row['id'])."'";
-			$result_reorder = Database::query($sql_reorder,__FILE__,__LINE__);
+			$result_reorder = Database::query($sql_reorder);
 			$i++;
 		}
 

+ 2 - 1
main/admin/user_fields_add.php

@@ -138,6 +138,7 @@ $types[USER_FIELD_TYPE_DATETIME] = get_lang('FieldTypeDatetime');
 $types[USER_FIELD_TYPE_DOUBLE_SELECT] 	= get_lang('FieldTypeDoubleSelect');
 $types[USER_FIELD_TYPE_DIVIDER] 		= get_lang('FieldTypeDivider');
 $types[USER_FIELD_TYPE_TAG] 		= get_lang('FieldTypeTag');
+$types[USER_FIELD_TYPE_TIMEZONE]	= get_lang('FieldTypeTimezone');
 
 $form->addElement('select','fieldtype',get_lang('FieldType'),$types,array('onchange'=>'change_image_user_field(this.value)'));
 $form->addRule('fieldtype', get_lang('ThisFieldIsRequired'), 'required');
@@ -295,4 +296,4 @@ echo '</div>';
 
 // footer
 Display::display_footer();
-?>
+?>

+ 10 - 9
main/admin/user_fields_options.php

@@ -24,18 +24,19 @@
 ==============================================================================
 */
 // name of the language file that needs to be included
-$language_file = array('admin','registration');
+$language_file = array('admin', 'registration');
 
 // resetting the course information
 $cidReset = true;
 
 // including the global library
-require ('../inc/global.inc.php');
+require '../inc/global.inc.php';
 
 // including additional libraries
 $libpath = api_get_path(LIBRARY_PATH);
-include_once ($libpath.'usermanager.lib.php');
-require_once ($libpath.'formvalidator/FormValidator.class.php');
+require_once $libpath.'sortabletable.class.php';
+include_once $libpath.'usermanager.lib.php';
+require_once $libpath.'formvalidator/FormValidator.class.php';
 
 // section for the tabs
 $this_section=SECTION_PLATFORM_ADMIN;
@@ -132,7 +133,7 @@ function get_options_data($from, $number_of_items, $column, $direction)
 				id 					AS col2
 			FROM $table_userfields_options WHERE field_id='".Database::escape_string($_GET['field_id'])."' ORDER BY option_order ASC";
 	$sql .= " LIMIT $from,$number_of_items";
-	$res = Database::query($sql, __FILE__, __LINE__);
+	$res = Database::query($sql);
 	$return = array ();
 	while ($option = Database::fetch_row($res))
 	{
@@ -148,7 +149,7 @@ function get_number_of_options($from=null, $number_of_items=null, $column=null,
 
 	// The sql statement
 	$sql = "SELECT count(id) as total FROM $table_userfields_options WHERE field_id='".Database::escape_string($_GET['field_id'])."' ";
-	$res = Database::query($sql, __FILE__, __LINE__);
+	$res = Database::query($sql);
 	$row = Database::fetch_row($res);
 	return $row[0];
 }
@@ -208,7 +209,7 @@ function move_user_field_option($direction,$option_id)
 	$found = false;
 
 	$sql = "SELECT id, option_order FROM $table_userfields_options  WHERE field_id='".Database::escape_string($_GET['field_id'])."' ORDER BY option_order $sortdirection";
-	$result = Database::query($sql,__FILE__,__LINE__);
+	$result = Database::query($sql);
 	while($row = Database::fetch_array($result))
 	{
 		if ($found)
@@ -228,8 +229,8 @@ function move_user_field_option($direction,$option_id)
 
 	$sql1 = "UPDATE ".$table_userfields_options." SET option_order = '".Database::escape_string($next_order)."' WHERE id =  '".Database::escape_string($this_id)."'";
 	$sql2 = "UPDATE ".$table_userfields_options." SET option_order = '".Database::escape_string($this_order)."' WHERE id =  '".Database::escape_string($next_id)."'";
-	Database::query($sql1,__FILE__,__LINE__);
-	Database::query($sql2,__FILE__,__LINE__);
+	Database::query($sql1);
+	Database::query($sql2);
 
 	return true;
 }

+ 12 - 11
main/admin/user_import.php

@@ -113,7 +113,7 @@ $result=Database::query("SELECT DISTINCT id, name, date_start, date_end
 							FROM session_rel_user, session
 							WHERE id_session=id AND id_user=$user_id
 							AND (date_start <= NOW() AND date_end >= NOW() OR date_start='0000-00-00')
-							ORDER BY date_start, date_end, name",__FILE__,__LINE__);
+							ORDER BY date_start, date_end, name");
 
 $sessions=Database::store_result($result);
 
@@ -123,7 +123,7 @@ $result=Database::query("SELECT DISTINCT id, name, date_start, date_end
 						INNER JOIN $tbl_session_course as session_rel_course
 							ON session_rel_course.id_coach = $user_id
 						AND (date_start <= NOW() AND date_end >= NOW() OR date_start='0000-00-00')
-						ORDER BY date_start, date_end, name",__FILE__,__LINE__);
+						ORDER BY date_start, date_end, name");
 
 $session_is_coach = Database::store_result($result);
 
@@ -158,14 +158,15 @@ if(count($sessions)>0){
 									 ORDER BY i";
 		*/
 		// this query is very similar to the above query, but it will check the session_rel_course_user table if there are courses registered to our user or not
-		$personal_course_list_sql = "SELECT distinct course.code k, course.directory d, course.visual_code c, course.db_name db, course.title i, ".(api_is_western_name_order() ? "CONCAT(user.firstname,' ',user.lastname)" : "CONCAT(user.lastname,' ',user.firstname)")." t, email, course.course_language l, 1 sort, category_code user_course_cat, date_start, date_end, session.id as id_session, session.name as session_name, IF(session_course.id_coach = 3,'2', '5')
+		$personal_course_list_sql = "SELECT distinct course.code k, course.directory d, course.visual_code c, course.db_name db, course.title i, ".(api_is_western_name_order() ? "CONCAT(user.firstname,' ',user.lastname)" : "CONCAT(user.lastname,' ',user.firstname)")." t, email, course.course_language l, 1 sort, category_code user_course_cat, date_start, date_end, session.id as id_session, session.name as session_name, IF(session_course_user.id_user = 3,'2', '5')
 										FROM $tbl_session_course_user as session_course_user INNER JOIN $tbl_course AS course
-										ON course.code = session_course_user.course_code AND session_course_user.id_session = $id_session INNER JOIN $tbl_session as session ON session_course_user.id_session = session.id
+										ON course.code = session_course_user.course_code AND session_course_user.id_session = $id_session
+										INNER JOIN $tbl_session as session ON session_course_user.id_session = session.id
 										INNER JOIN $tbl_session_course as session_course
-										LEFT JOIN $tbl_user as user ON user.user_id = session_course.id_coach
+										LEFT JOIN $tbl_user as user ON user.user_id = session_course_user.id_user AND session_course_user.status = 2
 										WHERE session_course_user.id_user = $user_id  ORDER BY i";
 
-		$course_list_sql_result = Database::query($personal_course_list_sql, __FILE__, __LINE__);
+		$course_list_sql_result = Database::query($personal_course_list_sql);
 
 		while ($result_row = Database::fetch_array($course_list_sql_result)){
 			$key = $result_row['id_session'].' - '.$result_row['k'];
@@ -183,9 +184,9 @@ if(count($sessions)>0){
 			$row[] = $my_course['k'];
 			$row[] = $my_course['i'];
 			$row[] = $my_course['s'] == STUDENT ? get_lang('Student') : get_lang('Teacher');
-			$tools = '<a href="course_information.php?code='.$my_course['k'].'">'.Display::return_icon('synthese_view.gif', get_lang('Overview')).'</a>'.
+			$tools = '<a href="course_information.php?code='.$my_course['k'].'&id_session='.$id_session.'">'.Display::return_icon('synthese_view.gif', get_lang('Overview')).'</a>'.
 					'<a href="'.api_get_path(WEB_COURSE_PATH).$my_course['d'].'?id_session='.$id_session.'">'.Display::return_icon('course_home.gif', get_lang('CourseHomepage')).'</a>' .
-					'<a href="course_edit.php?course_code='.$my_course['k'].'">'.Display::return_icon('edit.gif', get_lang('Edit')).'</a>';
+					'<a href="session_course_edit.php?id_session='.$id_session.'&course_code='.$my_course['k'].'">'.Display::return_icon('edit.gif', get_lang('Edit')).'</a>';
 
 			if( $my_course->status == STUDENT ){
 				$tools .= '<a href="user_information.php?action=unsubscribe&course_code='.$my_course['k'].'&user_id='.$user['user_id'].'">'.Display::return_icon('delete.gif', get_lang('Delete')).'</a>';
@@ -212,8 +213,8 @@ echo '</blockquote>';
 /**
  * Show the courses in which this user is subscribed
  */
-$sql = 'SELECT * FROM '.$table_course_user.' cu, '.$table_course.' c WHERE cu.user_id = '.$user['user_id'].' AND cu.course_code = c.code';
-$res = Database::query($sql,__FILE__,__LINE__);
+$sql = 'SELECT * FROM '.$table_course_user.' cu, '.$table_course.' c WHERE cu.user_id = '.$user['user_id'].' AND cu.course_code = c.code AND cu.relation_type <> '.COURSE_RELATION_TYPE_RRHH.' ';
+$res = Database::query($sql);
 if (Database::num_rows($res) > 0)
 {
 	$header=array();
@@ -255,7 +256,7 @@ else
 $table_class_user = Database :: get_main_table(TABLE_MAIN_CLASS_USER);
 $table_class = Database :: get_main_table(TABLE_MAIN_CLASS);
 $sql = 'SELECT * FROM '.$table_class_user.' cu, '.$table_class.' c WHERE cu.user_id = '.$user['user_id'].' AND cu.class_id = c.id';
-$res = Database::query($sql,__FILE__,__LINE__);
+$res = Database::query($sql);
 if (Database::num_rows($res) > 0)
 {
 	$header = array();

+ 85 - 53
main/admin/user_list.php

@@ -1,21 +1,20 @@
 <?php // $Id: user_list.php 22292 2009-07-22 18:32:32Z herodoto $
-/* For licensing terms, see /dokeos_license.txt */
+/* For licensing terms, see /license.txt */
 /**
-==============================================================================
 	@author Bart Mollet
-*	@package dokeos.admin
-==============================================================================
+*	@package chamilo.admin
 */
 
 // name of the language file that needs to be included
 $language_file = array ('registration','admin');
 $cidReset = true;
-require ('../inc/global.inc.php');
-require_once (api_get_path(LIBRARY_PATH).'sortabletable.class.php');
-require_once (api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php');
-require_once (api_get_path(LIBRARY_PATH).'security.lib.php');
-require_once(api_get_path(LIBRARY_PATH).'xajax/xajax.inc.php');
-require_once (api_get_path(LIBRARY_PATH).'usermanager.lib.php');
+require_once '../inc/global.inc.php';
+require_once api_get_path(LIBRARY_PATH).'sortabletable.class.php';
+require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php';
+require_once api_get_path(LIBRARY_PATH).'security.lib.php';
+require_once api_get_path(LIBRARY_PATH).'xajax/xajax.inc.php';
+require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
+
 $htmlHeadXtra[] = '<script src="../inc/lib/javascript/jquery.js" type="text/javascript" language="javascript"></script>';
 $htmlHeadXtra[] = '<script type="text/javascript">
 function load_course_list (div_course,my_user_id) {
@@ -162,7 +161,7 @@ function login_user($user_id) {
     }
 
 	$sql_query = "SELECT * FROM $main_user_table WHERE user_id='$user_id'";
-	$sql_result = Database::query($sql_query, __FILE__, __LINE__);
+	$sql_result = Database::query($sql_query);
 	$result = Database :: fetch_array($sql_result);
 
     // check if the user is allowed to 'login_as'
@@ -202,7 +201,7 @@ function login_user($user_id) {
 				WHERE user.user_id = '".$user_id."'";
 		}
 
-		$sql_result = Database::query($sql_query, __FILE__, __LINE__);
+		$sql_result = Database::query($sql_query);
 
 
 		if (Database::num_rows($sql_result) > 0) {
@@ -269,8 +268,8 @@ function get_number_of_users()
     }
 
 	if ( isset ($_GET['keyword'])) {
-		$keyword = Database::escape_string($_GET['keyword']);
-		$sql .= " WHERE (u.firstname LIKE '%".$keyword."%' OR u.lastname LIKE '%".$keyword."%'  OR u.username LIKE '%".$keyword."%' OR u.email LIKE '%".$keyword."%'  OR u.official_code LIKE '%".$keyword."%') ";
+		$keyword = Database::escape_string(trim($_GET['keyword']));
+		$sql .= " WHERE (u.firstname LIKE '%".$keyword."%' OR u.lastname LIKE '%".$keyword."%'  OR concat(u.firstname,' ',u.lastname) LIKE '%".$keyword."%'  OR concat(u.lastname,' ',u.firstname) LIKE '%".$keyword."%' OR u.username LIKE '%".$keyword."%' OR u.email LIKE '%".$keyword."%'  OR u.official_code LIKE '%".$keyword."%') ";
 	} elseif (isset ($_GET['keyword_firstname'])) {
 		$admin_table = Database :: get_main_table(TABLE_MAIN_ADMIN);
 		$keyword_firstname = Database::escape_string($_GET['keyword_firstname']);
@@ -309,7 +308,7 @@ function get_number_of_users()
     		$sql.= " AND url_rel_user.access_url_id=".api_get_current_access_url_id();
     }
 
-	$res = Database::query($sql, __FILE__, __LINE__);
+	$res = Database::query($sql);
 	$obj = Database::fetch_object($res);
 	return $obj->total_number_of_items;
 }
@@ -324,34 +323,34 @@ function get_number_of_users()
 function get_user_data($from, $number_of_items, $column, $direction)
 {
 	global $_configuration,$origin;
-	
+
 	$user_table = Database :: get_main_table(TABLE_MAIN_USER);
 	$admin_table = Database :: get_main_table(TABLE_MAIN_ADMIN);
 	$sql = "SELECT
                  u.user_id				AS col0,
-                 u.official_code		AS col1,
+                 u.official_code		AS col2,
 				 ".(api_is_western_name_order()
-                 ? "u.firstname 			AS col2,
-                 u.lastname 			AS col3,"
-                 : "u.lastname 			AS col2,
-                 u.firstname 			AS col3,")."
-                 u.username				AS col4,
-                 u.email				AS col5,
-                 u.status				AS col6,
-                 u.active				AS col7,
-                 u.user_id				AS col8 ".
+                 ? "u.firstname 			AS col3,
+                 u.lastname 			AS col4,"
+                 : "u.lastname 			AS col3,
+                 u.firstname 			AS col4,")."
+                 u.username				AS col5,
+                 u.email				AS col6,
+                 u.status				AS col7,
+                 u.active				AS col8,
+                 u.user_id				AS col9 ".
                  ", u.expiration_date      AS exp ".
             " FROM $user_table u ";
 
-    // adding the filter to see the user's only of the current access_url    
+    // adding the filter to see the user's only of the current access_url
     if ((api_is_platform_admin() || api_is_session_admin()) && $_configuration['multiple_access_urls']==true && api_get_current_access_url_id()!=-1) {
     	$access_url_rel_user_table= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
     	$sql.= " INNER JOIN $access_url_rel_user_table url_rel_user ON (u.user_id=url_rel_user.user_id)";
     }
 
 	if (isset ($_GET['keyword'])) {
-		$keyword = Database::escape_string($_GET['keyword']);
-		$sql .= " WHERE (u.firstname LIKE '%".$keyword."%' OR u.lastname LIKE '%".$keyword."%'  OR u.username LIKE '%".$keyword."%'  OR u.official_code LIKE '%".$keyword."%' OR u.email LIKE '%".$keyword."%' )";
+		$keyword = Database::escape_string(trim($_GET['keyword']));
+		$sql .= " WHERE (u.firstname LIKE '%".$keyword."%' OR u.lastname LIKE '%".$keyword."%' OR concat(u.firstname,' ',u.lastname) LIKE '%".$keyword."%' OR concat(u.lastname,' ',u.firstname) LIKE '%".$keyword."%' OR u.username LIKE '%".$keyword."%'  OR u.official_code LIKE '%".$keyword."%' OR u.email LIKE '%".$keyword."%' )";
 	} elseif (isset ($_GET['keyword_firstname'])) {
 		$keyword_firstname = Database::escape_string($_GET['keyword_firstname']);
 		$keyword_lastname = Database::escape_string($_GET['keyword_lastname']);
@@ -399,19 +398,20 @@ function get_user_data($from, $number_of_items, $column, $direction)
 
 	$sql .= " ORDER BY col$column $direction ";
 	$sql .= " LIMIT $from,$number_of_items";
-	$res = Database::query($sql, __FILE__, __LINE__);
+
+	$res = Database::query($sql);
 
 	$users = array ();
     $t = time();
 	while ($user = Database::fetch_row($res)) {
 
 		$image_path = UserManager::get_user_picture_path_by_id($user[0], 'web', false, true);
-		$user_profile = UserManager::get_picture_user($user[0], $image_path['file'], 22, 'small_', ' width="22" height="22" ');
+		$user_profile = UserManager::get_picture_user($user[0], $image_path['file'], 22, USER_IMAGE_SIZE_SMALL, ' width="22" height="22" ');
 		if (!api_is_anonymous()) {
 			$photo = '<center><a href="'.api_get_path(WEB_PATH).'whoisonline.php?origin=user_list&id='.$user[0].'" title="'.get_lang('Info').'"  ><img src="'.$user_profile['file'].'" '.$user_profile['style'].' alt="'.api_get_person_name($user[2],$user[3]).'"  title="'.api_get_person_name($user[2], $user[3]).'" /></a></center>';
 		} else {
 			$photo = '<center><img src="'.$user_profile['file'].'" '.$user_profile['style'].' alt="'.api_get_person_name($user[2], $user[3]).'" title="'.api_get_person_name($user[2], $user[3]).'" /></center>';
-		}				
+		}
 
         if ($user[7] == 1 && $user[9] != '0000-00-00 00:00:00') {
             // check expiration date
@@ -421,7 +421,7 @@ function get_user_data($from, $number_of_items, $column, $direction)
         	   $user[7] = '-1';
             }
         }
-        // forget about the expiration date field		      
+        // forget about the expiration date field
         $users[] = array($user[0],$photo,$user[1],$user[2],$user[3],$user[4],$user[5],$user[6],$user[7],$user[8]);
 	}
 	return $users;
@@ -433,8 +433,19 @@ function get_user_data($from, $number_of_items, $column, $direction)
 */
 function email_filter($email)
 {
-	return Display :: encrypted_mailto_link($email, $email);
+	return Display :: encrypted_mailto_link($email, $email);	
+}
+
+/**
+* Returns a mailto-link
+* @param string $email An email-address
+* @return string HTML-code with a mailto-link
+*/
+function user_filter($name, $params, $row) {	
+	return '<a href="'.api_get_path(WEB_PATH).'whoisonline.php?origin=user_list&id='.$row[0].'">'.$name.'</a>';	
+	
 }
+
 /**
  * Build the modify-column of the table
  * @param   int     The user id
@@ -450,7 +461,7 @@ function modify_filter($user_id,$url_params,$row)
 	$is_admin = in_array($user_id,$_admins_list);
 	$statusname = api_get_status_langvars();
 	$user_is_anonymous = false;
-	if ($row['6'] == $statusname[ANONYMOUS]) {
+	if ($row['7'] == $statusname[ANONYMOUS]) {
 		$user_is_anonymous =true;
 	}
 	if (!$user_is_anonymous) {
@@ -471,7 +482,7 @@ function modify_filter($user_id,$url_params,$row)
 	}
 
     //only allow platform admins to login_as, or session admins only for students (not teachers nor other admins)
-    if (api_is_platform_admin() || (api_is_session_admin() && $row['6'] == $statusname[STUDENT])) {
+    if (api_is_platform_admin() || (api_is_session_admin() && $row['7'] == $statusname[STUDENT])) {
     	if (!$user_is_anonymous) {
         	$result .= '<a href="user_list.php?action=login_as&amp;user_id='.$user_id.'&amp;sec_token='.$_SESSION['sec_token'].'">'.Display::return_icon('login_as.gif', get_lang('LoginAs')).'</a>&nbsp;&nbsp;';
     	} else {
@@ -480,7 +491,7 @@ function modify_filter($user_id,$url_params,$row)
     } else {
     	$result .= Display::return_icon('login_as_na.gif', get_lang('LoginAs')).'&nbsp;&nbsp;';
     }
-	if ($row['6'] != $statusname[STUDENT]) {
+	if ($row['7'] != $statusname[STUDENT]) {
 		$result .= Display::return_icon('statistics_na.gif', get_lang('Reporting')).'&nbsp;&nbsp;';
 	} else {
 		$result .= '<a href="../mySpace/myStudents.php?student='.$user_id.'">'.Display::return_icon('statistics.gif', get_lang('Reporting')).'</a>&nbsp;&nbsp;';
@@ -500,12 +511,28 @@ function modify_filter($user_id,$url_params,$row)
 			$result .= Display::return_icon('delete_na.gif', get_lang('Delete'));
 		}
 	}
-		if ($is_admin) {
-			$result .= Display::return_icon('admin_star.png', get_lang('IsAdministrator'),array('width'=> 22, 'heigth'=> 22));
-		
-		} else {
-			$result .= Display::return_icon('admin_star_na.png', get_lang('IsNotAdministrator'));		
+	if ($is_admin) {
+		$result .= Display::return_icon('admin_star.png', get_lang('IsAdministrator'),array('width'=> 22, 'heigth'=> 22));
+
+	} else {
+		$result .= Display::return_icon('admin_star_na.png', get_lang('IsNotAdministrator'));
+	}
+	
+	// actions for assigning sessions, courses or users
+	if (api_is_session_admin()) {
+		if ($row[0] == api_get_user_id()) {			
+			$result .= '<a href="dashboard_add_sessions_to_user.php?user='.$user_id.'">'.Display::return_icon('view_more_stats.gif', get_lang('AssignSessions')).'</a>&nbsp;&nbsp;';
 		}
+	} else {
+		if ($row['7'] == $statusname[DRH] || UserManager::is_admin($row[0])) {
+			$result .= '<a href="dashboard_add_users_to_user.php?user='.$user_id.'">'.Display::return_icon('add_user_big.gif', get_lang('AssignUsers')).'</a>&nbsp;&nbsp;';
+			$result .= '<a href="dashboard_add_courses_to_user.php?user='.$user_id.'">'.Display::return_icon('course_add.gif', get_lang('AssignCourses')).'</a>&nbsp;&nbsp;';
+			$result .= '<a href="dashboard_add_sessions_to_user.php?user='.$user_id.'">'.Display::return_icon('view_more_stats.gif', get_lang('AssignSessions')).'</a>&nbsp;&nbsp;';	
+		} else if ($row['7'] == $statusname[SESSIONADMIN]) {
+			$result .= '<a href="dashboard_add_sessions_to_user.php?user='.$user_id.'">'.Display::return_icon('view_more_stats.gif', get_lang('AssignSessions')).'</a>&nbsp;&nbsp;';
+		}
+	}
+
 	return $result;
 }
 
@@ -565,7 +592,7 @@ function lock_unlock_user($status,$user_id)
 	if(($status_db=='1' OR $status_db=='0') AND is_numeric($user_id))
 	{
 		$sql="UPDATE $user_table SET active='".Database::escape_string($status_db)."' WHERE user_id='".Database::escape_string($user_id)."'";
-		$result = Database::query($sql, __FILE__, __LINE__);
+		$result = Database::query($sql);
 	}
 
 	if ($result)
@@ -624,6 +651,7 @@ if (isset ($_GET['search']) && $_GET['search'] == 'advanced')
 	$status_options['%'] = get_lang('All');
 	$status_options[STUDENT] = get_lang('Student');
 	$status_options[COURSEMANAGER] = get_lang('Teacher');
+	$status_options[DRH] = get_lang('Drh');
 	$status_options[SESSIONADMIN] = get_lang('Administrator');//
 	$form->addElement('select','keyword_status',get_lang('Status'),$status_options);
 	$active_group = array();
@@ -652,7 +680,7 @@ else
                     	// to prevent too long messages
                     	if ($_GET['warn'] == 'session_message'){
                     		$_GET['warn'] = $_SESSION['session_message_import_users'];
-                    	} 
+                    	}
                     	Display::display_warning_message(urldecode($_GET['warn']),false);
                     }
                     if (!empty($_GET['message'])) {
@@ -756,18 +784,18 @@ else
 		$_admins_list[] = $row_admin[0];
 	}
 
-				$image_path = UserManager::get_user_picture_path_by_id($user_id, 'web', false, true);
-				$user_profile = UserManager::get_picture_user($user_id, $image_path['file'], 22, 'small_', ' width="22" height="22" ');
-				if (!api_is_anonymous()) {
-					$photo = '<center><a href="userInfo.php?'.api_get_cidreq().'&origin='.$origin.'&amp;uInfo='.$user_id.'" title="'.get_lang('Info').'"  ><img src="'.$user_profile['file'].'" '.$user_profile['style'].' alt="'.api_get_person_name($o_course_user['firstname'], $o_course_user['lastname']).'"  title="'.api_get_person_name($o_course_user['firstname'], $o_course_user['lastname']).'" /></a></center>';
-				} else {
-					$photo = '<center><img src="'.$user_profile['file'].'" '.$user_profile['style'].' alt="'.api_get_person_name($o_course_user['firstname'], $o_course_user['lastname']).'" title="'.api_get_person_name($o_course_user['firstname'], $o_course_user['lastname']).'" /></center>';
-				}
+	$image_path = UserManager::get_user_picture_path_by_id($user_id, 'web', false, true);
+	$user_profile = UserManager::get_picture_user($user_id, $image_path['file'], 22, USER_IMAGE_SIZE_SMALL, ' width="22" height="22" ');
+	if (!api_is_anonymous()) {
+		$photo = '<center><a href="userInfo.php?'.api_get_cidreq().'&origin='.$origin.'&amp;uInfo='.$user_id.'" title="'.get_lang('Info').'"  ><img src="'.$user_profile['file'].'" '.$user_profile['style'].' alt="'.api_get_person_name($o_course_user['firstname'], $o_course_user['lastname']).'"  title="'.api_get_person_name($o_course_user['firstname'], $o_course_user['lastname']).'" /></a></center>';
+	} else {
+		$photo = '<center><img src="'.$user_profile['file'].'" '.$user_profile['style'].' alt="'.api_get_person_name($o_course_user['firstname'], $o_course_user['lastname']).'" title="'.api_get_person_name($o_course_user['firstname'], $o_course_user['lastname']).'" /></center>';
+	}
 
 	$table = new SortableTable('users', 'get_number_of_users', 'get_user_data', (api_is_western_name_order() xor api_sort_by_first_name()) ? 3 : 2);
 	$table->set_additional_parameters($parameters);
 	$table->set_header(0, '', false);
-	$table->set_header(1, get_lang('Photo'));	
+	$table->set_header(1, get_lang('Photo'), false);
 	$table->set_header(2, get_lang('OfficialCode'));
 	if (api_is_western_name_order()) {
 		$table->set_header(3, get_lang('FirstName'));
@@ -780,7 +808,11 @@ else
 	$table->set_header(6, get_lang('Email'));
 	$table->set_header(7, get_lang('Status'));
 	$table->set_header(8, get_lang('Active'));
-	$table->set_header(9, get_lang('Action'), false,'width="170px"');
+	$table->set_header(9, get_lang('Action'), false,'width="200px"');
+	
+	$table->set_column_filter(3, 'user_filter');
+	$table->set_column_filter(4, 'user_filter');
+	
 	$table->set_column_filter(6, 'email_filter');
 	$table->set_column_filter(7, 'status_filter');
 	$table->set_column_filter(8, 'active_filter');

+ 159 - 174
main/announcements/announcements.inc.php

@@ -1,25 +1,5 @@
 <?php //$Id: announcements.inc.php 21903 2009-07-08 17:28:02Z juliomontoya $
-/*
-==============================================================================
-	Dokeos - elearning and course management software
-
-	Copyright (c) 2004-2008 Dokeos SPRL
-	Copyright (c) various contributors
-
-	For a full list of contributors, see "credits.txt".
-	The full license can be read in "license.txt".
-
-	This program is free software; you can redistribute it and/or
-	modify it under the terms of the GNU General Public License
-	as published by the Free Software Foundation; either version 2
-	of the License, or (at your option) any later version.
-
-	See the GNU General Public License for more details.
-
-	Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
-	Mail: info@dokeos.com
-==============================================================================
-*/
+/* For licensing terms, see /license.txt */
 /**
 ==============================================================================
 * Include file with functions for the announcements module.
@@ -56,13 +36,11 @@ function display_announcement($announcement_id)
 						WHERE announcement.id = toolitemproperties.ref
 						AND announcement.id = '$announcement_id'
 						AND toolitemproperties.tool='announcement'
-						AND (toolitemproperties.to_user_id='".$_user['user_id']."' OR toolitemproperties.to_group_id='0')
+						AND (toolitemproperties.to_user_id='".intval($_user['user_id'])."' OR toolitemproperties.to_group_id='0')
 						AND toolitemproperties.visibility='1'
 						ORDER BY display_order DESC";
 
-	}
-	else
-	{
+	} else {
 		$sql_query = "	SELECT announcement.*, toolitemproperties.*
 						FROM $tbl_announcement announcement, $tbl_item_property toolitemproperties
 						WHERE announcement.id = toolitemproperties.ref
@@ -71,11 +49,10 @@ function display_announcement($announcement_id)
 						AND toolitemproperties.to_group_id='0'
 						AND toolitemproperties.visibility='1'";
 	}
-	$sql_result = Database::query($sql_query,__FILE__,__LINE__);
+	$sql_result = Database::query($sql_query);
 	$result = Database::fetch_array($sql_result);
 
-	if ($result !== false) // A sanity check.
-	{
+	if ($result !== false) { // A sanity check.
 		$title		 = $result['title'];
 		$content	 = $result['content'];
 		$content     = make_clickable($content);
@@ -86,7 +63,7 @@ function display_announcement($announcement_id)
 
 	echo "<table height=\"100\" width=\"100%\" border=\"1\" cellpadding=\"5\" cellspacing=\"0\" id=\"agenda_list\">\n";
 	echo "<tr class=\"data\"><td>" . $title . "</td></tr>\n";
-	echo "<tr><td class=\"announcements_datum\">" . get_lang('AnnouncementPublishedOn') . " : " . api_ucfirst(format_locale_date($dateFormatLong,strtotime($last_post_date) ) ) . "</td></tr>\n";
+	echo "<tr><td class=\"announcements_datum\">" . get_lang('AnnouncementPublishedOn') . " : " . api_convert_and_format_date($last_post_datetime, null, date_default_timezone_get()) . "</td></tr>\n";
 	echo "<tr class=\"text\"><td>$content</td></tr>\n";
 	echo "</table>";
 }
@@ -125,9 +102,9 @@ function show_to_form($to_already_selected)
 				"\n\t\t<input	type=\"button\"",
 				"onClick=\"javascript: move(this.form.elements[3],this.form.elements[0])\" ",
 				"value=\"   <<   \">";*/
-				
+
 ?>
-<button class="arrowr" type="button" onClick="javascript: move(this.form.elements[0], this.form.elements[3])" onClick="javascript: move(this.form.elements[0], this.form.elements[3])"></button>	
+<button class="arrowr" type="button" onClick="javascript: move(this.form.elements[0], this.form.elements[3])" onClick="javascript: move(this.form.elements[0], this.form.elements[3])"></button>
 <br /> <br />
 <button class="arrowl" type="button" onClick="javascript: move(this.form.elements[3], this.form.elements[0])" onClick="javascript: move(this.form.elements[3], this.form.elements[0])"></button>
 <?php
@@ -172,17 +149,18 @@ function construct_not_selected_select_form($group_list=null, $user_list=null,$t
 		echo	"\t\t<option value=\"\">---------------------------------------------------------</option>\n";
 	}
 	// adding the individual users to the select form
-	foreach($user_list as $this_user)
-	{
-		if (is_array($to_already_selected)) {
-			if (!(in_array("USER:".$this_user["user_id"],$to_already_selected))) // $to_already_selected is the array containing the users (and groups) that are already selected
-			{
-				echo	"\t\t<option value=\"USER:",$this_user["user_id"],"\">",
-					"", api_get_person_name($this_user['firstname'], $this_user['lastname']),
-					"</option>\n";
+	if ($user_list) {
+		foreach($user_list as $this_user)
+		{
+			if (is_array($to_already_selected)) {
+				if (!in_array("USER:".$this_user['user_id'],$to_already_selected)) // $to_already_selected is the array containing the users (and groups) that are already selected
+				{
+					echo	"\t\t<option value=\"USER:".$this_user['user_id']."\">",
+						"", api_get_person_name($this_user['firstname'], $this_user['lastname']),
+						"</option>\n";
+				}
 			}
 		}
-
 	}
 	echo "\t\t</select>\n";
 }
@@ -253,7 +231,7 @@ function construct_selected_select_form($group_list=null, $user_list=null,$to_al
 				if (!is_array($to_already_selected) || !in_array("USER:".$this_user['user_id'],$to_already_selected)) // $to_already_selected is the array containing the users (and groups) that are already selected
 				{
 					echo	"\t\t<option value=\"USER:",$this_user['user_id'],"\">",
-						"", api_get_person_name($this_user['lastname'], $this_user['firstname']),
+						"", api_get_person_name($this_user['firstname'], $this_user['lastname']),
 						"</option>\n";
 				}
 			}
@@ -294,12 +272,12 @@ function show_to_form_group($group_id)
 				"\n\t\t<input	type=\"button\"",
 				"onClick=\"move(this.form.elements[4],this.form.elements[1])\" ",
 				"value=\"   <<   \">";*/
-				
+
 ?>
-<button class="arrowr" type="button" onClick="javascript: move(this.form.elements[1], this.form.elements[4])" onClick="javascript: move(this.form.elements[1], this.form.elements[4])"></button>	
+<button class="arrowr" type="button" onClick="javascript: move(this.form.elements[1], this.form.elements[4])" onClick="javascript: move(this.form.elements[1], this.form.elements[4])"></button>
 <br /> <br />
 <button class="arrowl" type="button" onClick="javascript: move(this.form.elements[4], this.form.elements[1])" onClick="javascript: move(this.form.elements[4], this.form.elements[1])"></button>
-<?php				
+<?php
 	echo "\t\t</td>\n";
 	echo "\n\t\t<td>\n";
 
@@ -326,8 +304,14 @@ function get_course_users()
 {
 	//this would return only the users from real courses:
 	//$user_list = CourseManager::get_user_list_from_course_code(api_get_course_id());
+	$session_id = api_get_session_id();
+	
+	if ($session_id != 0) {
+		$user_list = CourseManager::get_real_and_linked_user_list(api_get_course_id(), true, $session_id);
+	} else {
+		$user_list = CourseManager::get_real_and_linked_user_list(api_get_course_id(), false, 0);
+	}
 
-	$user_list = CourseManager::get_real_and_linked_user_list(api_get_course_id(), true, $_SESSION['id_session']);
 	return $user_list;
 }
 
@@ -336,8 +320,14 @@ function get_course_users()
 * not including linked courses
 */
 function get_course_groups()
-{
-	$new_group_list = CourseManager::get_group_list_of_course(api_get_course_id(), intval($_SESSION['id_session']));
+{	
+	$session_id = api_get_session_id();
+	
+	if ($session_id != 0) {
+		$new_group_list = CourseManager::get_group_list_of_course(api_get_course_id(), intval($session_id));
+	} else {	
+		$new_group_list = CourseManager::get_group_list_of_course(api_get_course_id(), 0);
+	}
 	return $new_group_list;
 }
 
@@ -356,9 +346,9 @@ function load_edit_users($tool, $id)
 	$tool = Database::escape_string($tool);
 	$id = Database::escape_string($id);
 
-	$sql="SELECT * FROM $tbl_item_property WHERE tool='$tool' AND ref='$id'";
-	$result=Database::query($sql,__FILE__,__LINE__) or die (mysql_error());
-	while ($row=Database::fetch_array($result))
+	$sql = "SELECT * FROM $tbl_item_property WHERE tool='$tool' AND ref='$id'";
+	$result = Database::query($sql) or die(Database::error());
+	while ($row = Database::fetch_array($result))
 	{
 		$to_group=$row['to_group_id'];
 		switch ($to_group)
@@ -542,8 +532,8 @@ function to_javascript()
 			cbList[i].selected = !(cbList[i].selected)
 		}
 	}
-	
-	
+
+
 function plus_attachment() {
 				if (document.getElementById('options').style.display == 'none') {
 					document.getElementById('options').style.display = 'block';
@@ -553,10 +543,10 @@ function plus_attachment() {
 				document.getElementById('plus').innerHTML='&nbsp;<img style=\"vertical-align:middle;\" src=\"../img/div_show.gif\" alt=\"\" />&nbsp;".get_lang('AddAnAttachment')."';
 				}
 }
-	
-	
-	
-	
+
+
+
+
 	//	End	-->
 	</script>";
 }
@@ -634,7 +624,7 @@ function sent_to_form($sent_to_array)
 		if (isset($sent_to_array['users']) and is_array($sent_to_array['users']))
 		{
 			$user_info = api_get_user_info($sent_to_array['users'][0]);
-			echo api_get_person_name($user_info['firstName'], $user_info['lastName']);
+			echo api_get_person_name($user_info['firstname'], $user_info['lastname']);
 		}
 		if (isset($sent_to_array['groups']) and is_array($sent_to_array['groups']) and $sent_to_array['groups'][0]!==0)
 		{
@@ -692,7 +682,7 @@ function separate_users_groups($to)
 * has been sent to
 * @param    string  The tool (announcement, agenda, ...)
 * @param    int     ID of the element of the corresponding type
-* @return   array   Array of users and groups to whom the element has been sent 
+* @return   array   Array of users and groups to whom the element has been sent
 */
 function sent_to($tool, $id)
 {
@@ -706,7 +696,7 @@ function sent_to($tool, $id)
 	$sent_to = array();
 
 	$sql="SELECT * FROM $tbl_item_property WHERE tool='$tool' AND ref='".$id."'";
-	$result = Database::query($sql,__FILE__,__LINE__);
+	$result = Database::query($sql);
 
 
 	while ($row=Database::fetch_array($result)) {
@@ -753,10 +743,10 @@ function change_visibility_announcement($tool,$id)
 	$tool = Database::escape_string($tool);
 	$id = Database::escape_string($id);
 
-	$sql="SELECT * FROM $tbl_item_property WHERE tool='$tool' AND ref='$id'";
+	$sql = "SELECT * FROM $tbl_item_property WHERE tool='$tool' AND ref='$id'";
 
-	$result=Database::query($sql,__FILE__,__LINE__) or die (mysql_error());
-	$row=Database::fetch_array($result);
+	$result = Database::query($sql) or die(Database::error());
+	$row = Database::fetch_array($result);
 
 	if ($row['visibility']=='1')
 	{
@@ -766,8 +756,8 @@ function change_visibility_announcement($tool,$id)
 	{
 		$sql_visibility="UPDATE $tbl_item_property SET visibility='1' WHERE tool='$tool' AND ref='$id'";
 	}
-    $result=Database::query($sql_visibility,__FILE__,__LINE__);
-    if ($result === false) { 
+    $result=Database::query($sql_visibility);
+    if ($result === false) {
         return false;
     }
     return true;
@@ -778,11 +768,12 @@ function change_visibility_announcement($tool,$id)
  * @param string    Announcement title (pure text)
  * @param string    Content of the announcement (can be HTML)
  * @param int       Display order in the list of announcements
- * @param array     Array of users and groups to send the announcement to 
+ * @param array     Array of users and groups to send the announcement to
+ * @param array	    uploaded file $_FILES
  * @param string    Comment describing the attachment
- * @return int      false on failure, ID of the announcement on success 
+ * @return int      false on failure, ID of the announcement on success
  */
-function store_advalvas_item($emailTitle, $newContent, $order, $to, $file_comment='') {
+function store_advalvas_item($emailTitle, $newContent, $order, $to, $file = array(), $file_comment='') {
 
 	global $_course;
 	global $nameTools;
@@ -795,18 +786,20 @@ function store_advalvas_item($emailTitle, $newContent, $order, $to, $file_commen
 	$emailTitle = Database::escape_string($emailTitle);
 	$newContent = Database::escape_string($newContent);
 	$order = intval($order);
-	
+
 	// store in the table announcement
 	$sql = "INSERT INTO $tbl_announcement SET content = '$newContent', title = '$emailTitle', end_date = NOW(), display_order ='$order', session_id=".intval($_SESSION['id_session']);
-	$result = Database::query($sql,__FILE__,__LINE__);
+	$result = Database::query($sql);
 	if ($result === false) {
 		return false;
 	}
-	
+
 	//store the attach file
 	$last_id = Database::insert_id();
-	$save_attachment = add_announcement_attachment_file($last_id, $file_comment, $_FILES['user_upload']);
-	
+	if (!empty($file)) {
+		$save_attachment = add_announcement_attachment_file($last_id, $file_comment, $_FILES['user_upload']);
+	}
+
 	// store in item_property (first the groups, then the users
 	if (!is_null($to)) // !is_null($to): when no user is selected we send it to everyone
 	{
@@ -837,32 +830,35 @@ function store_advalvas_item($emailTitle, $newContent, $order, $to, $file_commen
 }
 
 
-function store_advalvas_group_item($emailTitle,$newContent, $order, $to, $to_users, $file_comment='')
+function store_advalvas_group_item($emailTitle,$newContent, $order, $to, $to_users, $file = array(), $file_comment='')
 {
 	global $_course;
 	global $nameTools;
 	global $_user;
-	
+
 	// database definitions
 	$tbl_announcement = Database::get_course_table(TABLE_ANNOUNCEMENT);
 	$tbl_item_property = Database::get_course_table(TABLE_ITEM_PROPERTY);
-	
+
 	$newContent=stripslashes($newContent);
 	$emailTitle = Database::escape_string($emailTitle);
-	$newContent = Database::escape_string($newContent,COURSEMANAGERLOWSECURITY);
+	$newContent = Database::escape_string($newContent);
 	$order = intval($order);
-	
+
 	// store in the table announcement
 	$sql = "INSERT INTO $tbl_announcement SET content = '$newContent', title = '$emailTitle', end_date = NOW(), display_order ='$order', session_id=".intval($_SESSION['id_session']);
-	$result = Database::query($sql,__FILE__,__LINE__) or die (mysql_error());
+	$result = Database::query($sql) or die(Database::error());
 	if ($result === false) {
 		return false;
 	}
-	
+
 	//store the attach file
 	$last_id = Database::insert_id();
-	$save_attachment = add_announcement_attachment_file($last_id, $file_comment, $_FILES['user_upload']);
-	
+	if (empty($file)) {
+		$save_attachment = add_announcement_attachment_file($last_id, $file_comment, $file);
+	}
+
+
 	// store in item_property (first the groups, then the users
 	if (!isset($to_users)) // !isset($to): when no user is selected we send it to everyone
 	{
@@ -900,7 +896,7 @@ function store_advalvas_group_item($emailTitle,$newContent, $order, $to, $to_use
 * This function stores the announcement Item in the table announcement
 * and updates the item_property also
 */
-function edit_advalvas_item($id,$emailTitle,$newContent,$to, $file_comment='')
+function edit_advalvas_item($id,$emailTitle,$newContent,$to,$file = array(), $file_comment='')
 {
 
 	global $_course;
@@ -911,27 +907,30 @@ function edit_advalvas_item($id,$emailTitle,$newContent,$to, $file_comment='')
 	global $tbl_item_property;
 
 	$newContent=stripslashes($newContent);
-	$emailTitle = Database::escape_string($emailTitle);
-	$newContent = Database::escape_string($newContent,COURSEMANAGERLOWSECURITY);
+	$emailTitle = Database::escape_string(Security::remove_XSS($emailTitle));
+	$newContent = Database::escape_string(Security::remove_XSS($newContent,COURSEMANAGERLOWSECURITY));
 	$order = intval($order);
-	
+
 	// store the modifications in the table announcement
  	$sql = "UPDATE $tbl_announcement SET content='$newContent', title = '$emailTitle' WHERE id='$id'";
-	$result = Database::query($sql,__FILE__,__LINE__) or die (mysql_error());
-	
-	if(empty($last_id)){
-		$last_id = $id;
-	$save_attachment = add_announcement_attachment_file($last_id, $file_comment, $_FILES['user_upload']);
-	
+	$result = Database::query($sql) or die(Database::error());
+
+	// save attachment file
+	$row_attach = get_attachment($id);
+	$id_attach = intval($row_attach['id']);
+
+	if (!empty($file)) {
+		if (empty($id_attach)) {
+		add_announcement_attachment_file($id,$file_comment,$file);
+		} else {
+			edit_announcement_attachment_file($id_attach,$file,$file_comment);
+		}
 	}
-	
-	$last_id = $id;
-	$edit_attachment = edit_announcement_attachment_file($last_id, $_FILES['user_upload'], $file_comment);
 
 	// we remove everything from item_property for this
 	$sql_delete="DELETE FROM $tbl_item_property WHERE ref='$id' AND tool='announcement'";
-	$result = Database::query($sql_delete,__FILE__,__LINE__) or die (mysql_error());
-	
+	$result = Database::query($sql_delete) or die(Database::error());
+
 	// store in item_property (first the groups, then the users
 	if (!is_null($to)) // !is_null($to): when no user is selected we send it to everyone
 	{
@@ -949,7 +948,7 @@ function edit_advalvas_item($id,$emailTitle,$newContent,$to, $file_comment='')
 		{
 			foreach ($send_to['users'] as $user)
 			{
-					api_item_property_update($_course, TOOL_ANNOUNCEMENT, $id, "AnnouncementUpdated", $_user['user_id'], '', $user);
+					api_item_property_update($_course, TOOL_ANNOUNCEMENT, $id, "AnnouncementUpdated", $_user['user_id'], 0, $user);
 			}
 		}
 	}
@@ -972,29 +971,19 @@ function edit_advalvas_item($id,$emailTitle,$newContent,$to, $file_comment='')
 */
 function send_announcement_email($user_list, $course_code, $_course, $mail_title, $mail_content)
 {
-	global $charset;
 	global $_user;
 
 	foreach ($user_list as $this_user) {
-		/*  Header : Bericht van uw lesgever - GES ($course_code) - Morgen geen les! ($mail_title)
-			Body :  John Doe (prenom + nom) <john_doe@hotmail.com> (email)
-					Morgen geen les! ($mail_title)
-					Morgen is er geen les, de les wordt geschrapt wegens vergadering (newContent)
-		*/
+
 		$mail_subject = get_lang('professorMessage').' - '.$_course['official_code'].' - '.$mail_title;
 
 		$mail_body = '['.$_course['official_code'].'] - ['.$_course['name']."]\n";
-		$mail_body .= api_get_person_name($this_user['firstname'], $this_user['lastname'], null, PERSON_NAME_EMAIL_ADDRESS).' <'.$this_user["email"]."> \n\n".stripslashes($mail_title)."\n\n".trim(stripslashes(api_html_entity_decode(strip_tags(str_replace(array('<p>','</p>','<br />'),array('',"\n","\n"),$mail_content)), ENT_QUOTES, $charset)))." \n\n-- \n";
-		$mail_body .= api_get_person_name($_user['firstName'], $_user['lastName'], null, PERSON_NAME_EMAIL_ADDRESS).' ';
+		$mail_body .= api_get_person_name($this_user['firstname'], $this_user['lastname'], null, PERSON_NAME_EMAIL_ADDRESS).' <'.$this_user["email"]."> \n\n".stripslashes($mail_title)."\n\n".trim(stripslashes(api_html_entity_decode(strip_tags(str_replace(array('<p>','</p>','<br />'),array('',"\n","\n"),$mail_content)), ENT_QUOTES, api_get_system_encoding())))." \n\n-- \n";
+		$mail_body .= api_get_person_name($_user['firstname'], $_user['lastname'], null, PERSON_NAME_EMAIL_ADDRESS).' ';
 		$mail_body .= '<'.$_user['mail'].">\n";
 		$mail_body .= $_course['official_code'].' '.$_course['name'];
 
-		//set the charset and use it for the encoding of the email - small fix, not really clean (should check the content encoding origin first)
-		//here we use the encoding used for the webpage where the text is encoded (ISO-8859-1 in this case)
-		if(empty($charset)){$charset='ISO-8859-1';}
-		$encoding = 'Content-Type: text/plain; charset='. $charset;
-
-		$newmail = api_mail(api_get_person_name($this_user['firstname'], $this_user['lastname'], null, PERSON_NAME_EMAIL_ADDRESS), $this_user['email'], $mail_subject, $mail_body, api_get_person_name($_SESSION['_user']['firstName'], $_SESSION['_user']['lastName'], null, PERSON_NAME_EMAIL_ADDRESS), $_SESSION['_user']['mail'], $encoding);
+		@api_mail(api_get_person_name($this_user['firstname'], $this_user['lastname'], null, PERSON_NAME_EMAIL_ADDRESS), $this_user['email'], $mail_subject, $mail_body, api_get_person_name($_SESSION['_user']['firstname'], $_SESSION['_user']['lastname'], null, PERSON_NAME_EMAIL_ADDRESS), $_SESSION['_user']['mail']);
 	}
 }
 
@@ -1006,50 +995,54 @@ function update_mail_sent($insert_id)
 	$insert_id = Database::escape_string($insert_id);
 	// store the modifications in the table tbl_annoucement
 	$sql = "UPDATE $tbl_announcement SET email_sent='1' WHERE id='$insert_id'";
-	Database::query($sql,__FILE__,__LINE__);
+	Database::query($sql);
 }
 
 /**
  * Gets all announcements from a user by course
  * @param	string course db
  * @param	int user id
- * @return	string an html with the content
+ * @return	array html with the content and count of announcements or false otherwise
  */
 function get_all_annoucement_by_user_course($course_db, $user_id)
 {
+	if (empty($course_db) || empty($user_id)) {
+		return false;
+	}
 	$tbl_announcement		= Database::get_course_table(TABLE_ANNOUNCEMENT, $course_db);
 	$tbl_item_property  	= Database::get_course_table(TABLE_ITEM_PROPERTY, $course_db);
 	if (!empty($user_id) && is_numeric($user_id)) {
-		$user_id = Database::escape_string($user_id);
-		$sql="SELECT announcement.*, toolitemproperties.*
+		$user_id = intval($user_id);
+		$sql="SELECT DISTINCT announcement.title, announcement.content
 						FROM $tbl_announcement announcement, $tbl_item_property toolitemproperties
 						WHERE announcement.id = toolitemproperties.ref
 						AND toolitemproperties.tool='announcement'
-						AND (toolitemproperties.insert_user_id='".$user_id."' AND toolitemproperties.to_group_id='0')
+						AND (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";
-		$result = Database::query($sql,__FILE__,__LINE__);
-		$num_rows = Database::num_rows($result);
+		$rs = Database::query($sql);
+		$num_rows = Database::num_rows($rs);
 		$content = '';
 		$i=0;
-		if (Database::num_rows($result)>0) {
-			while ($myrow = Database::fetch_array($result)) {
-				if ($i<=4) {
+		$result = array();
+		if ($num_rows>0) {
+			while ($myrow = Database::fetch_array($rs)) {
+				//if ($i<=4) {
 					$content.= '<strong>'.$myrow['title'].'</strong><br /><br />';
 					$content.= $myrow['content'];
-				} else {
+				/*} else {
 					break;
-				}
+				}*/
 				$i++;
 			}
-			return $content;
-		} else {
-			return $content;
+			$result['content'] = $content;
+			$result['count'] = $i;
+			return $result;
 		}
-	} else {
-		return '';
+		return false;
 	}
+	return false;
 }
 
 /*
@@ -1060,19 +1053,19 @@ function get_all_annoucement_by_user_course($course_db, $user_id)
 
 /**
  * Show a list with all the attachments according to the post's id
- * @param the post's id
+ * @param int announcement id
  * @return array with the post info
  * @author Arthur Portugal
  * @version November 2009, dokeos 1.8.6.2
  */
- 
+
 function get_attachment($announcement_id) {
-	
+
 	$tbl_announcement_attachment = Database::get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT);
 	$announcement_id=Database::escape_string($announcement_id);
 	$row=array();
 	$sql = 'SELECT id,path, filename,comment FROM '. $tbl_announcement_attachment.' WHERE announcement_id = '.(int)$announcement_id.'';
-	$result=Database::query($sql, __FILE__, __LINE__);
+	$result=Database::query($sql);
 	if (Database::num_rows($result)!=0) {
 		$row=Database::fetch_array($result,ASSOC);
 	}
@@ -1081,26 +1074,28 @@ function get_attachment($announcement_id) {
 
 /**
  * This function add a attachment file into announcement
- * @param string  a comment about file
- * @param int last id from announcement table
+ * @param int  announcement id
+ * @param string file comment
+ * @param array  uploaded file $_FILES
  * @return int  -1 if failed, 0 if unknown (should not happen), 1 if success
  */
 
-function add_announcement_attachment_file($last_id, $file_comment, $file = array()) {
+function add_announcement_attachment_file($announcement_id, $file_comment, $file) {
+
 	global $_course;
 	$tbl_announcement_attachment = Database::get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT);
 	$return = 0;
-	$last_id = intval($last_id);
-	
+	$announcement_id = intval($announcement_id);
+
 	if (is_array($file) && $file['error'] == 0 ) {
-		$courseDir   = $_course['path'].'/upload/announcements';
+		$courseDir   = $_course['path'].'/upload/announcements'; // TODO: This path is obsolete. The new document repository scheme should be kept in mind here.
 		$sys_course_path = api_get_path(SYS_COURSE_PATH);
 		$updir = $sys_course_path.$courseDir;
-		
+
 		// Try to add an extension to the file if it hasn't one
-		$new_file_name = add_ext_on_mime(stripslashes($_FILES['user_upload']['name']), $_FILES['user_upload']['type']);
+		$new_file_name = add_ext_on_mime(stripslashes($file['name']), $file['type']);
 		// user's file name
-		$file_name = $_FILES['user_upload']['name'];
+		$file_name = $file['name'];
 
 		if (!filter_extension($new_file_name))  {
 			$return = -1;
@@ -1108,21 +1103,15 @@ function add_announcement_attachment_file($last_id, $file_comment, $file = array
 		} else {
 			$new_file_name = uniqid('');
 			$new_path           = $updir.'/'.$new_file_name;
-			$result             = @move_uploaded_file($_FILES['user_upload']['tmp_name'], $new_path);
+			$result             = @move_uploaded_file($file['tmp_name'], $new_path);
 			$safe_file_comment  = Database::escape_string($file_comment);
 			$safe_file_name     = Database::escape_string($file_name);
 			$safe_new_file_name = Database::escape_string($new_file_name);
 			// Storing the attachments if any
-			//if ($result) {
-				$sql = 'INSERT INTO '.$tbl_announcement_attachment.'(filename, comment, path, announcement_id, size) '.
-					   "VALUES ( '$safe_file_name', '$file_comment', '$safe_new_file_name' , '$last_id', '".intval($_FILES['user_upload']['size'])."' )";
-				$result = Database::query($sql, __LINE__, __FILE__);
-				//$message .= ' / '.get_lang('FileUploadSucces').'<br />';
-                $return = 1;
-				//$last_id_file=Database::insert_id();
-				//api_item_property_update($_course, 'announcement_attachment', $last_id_file ,'AnnouncementAttachmentAdded', api_get_user_id());
-
-			//}
+			$sql = 'INSERT INTO '.$tbl_announcement_attachment.'(filename, comment, path, announcement_id, size) '.
+				   "VALUES ( '$safe_file_name', '$file_comment', '$safe_new_file_name' , '$announcement_id', '".intval($file['size'])."' )";
+			$result = Database::query($sql);
+            $return = 1;
 		}
 	}
 	return $return;
@@ -1130,49 +1119,46 @@ function add_announcement_attachment_file($last_id, $file_comment, $file = array
 
 /**
  * This function edit a attachment file into announcement
- * @param string  a comment about file
- * @param int Agenda Id
- * @param int attachment file Id
+ * @param int attach id
+ * @param array uploaded file $_FILES
+ * @param string file comment
+ * @return int
  */
-function edit_announcement_attachment_file($last_id, $file = array(), $file_comment) {
+function edit_announcement_attachment_file($id_attach, $file, $file_comment) {
 	global $_course;
 	$tbl_announcement_attachment = Database::get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT);
     $return = 0;
-	// Storing the attachments
-
-    if(!empty($_FILES['user_upload'])) {
-		$upload_ok = process_uploaded_file($_FILES['user_upload']);
-	}
 
-	if (!empty($upload_ok)) {
-		$courseDir   = $_course['path'].'/upload/announcements';
+	if (is_array($file) && $file['error'] == 0 ) {
+		$courseDir   = $_course['path'].'/upload/announcements'; // TODO: This path is obsolete. The new document repository scheme should be kept in mind here.
 		$sys_course_path = api_get_path(SYS_COURSE_PATH);
 		$updir = $sys_course_path.$courseDir;
 
 		// Try to add an extension to the file if it hasn't one
-		$new_file_name = add_ext_on_mime(stripslashes($_FILES['user_upload']['name']), $_FILES['user_upload']['type']);
+		$new_file_name = add_ext_on_mime(stripslashes($file['name']), $file['type']);
 		// user's file name
-		$file_name =$_FILES['user_upload'] ['name'];
+		$file_name =$file ['name'];
+
 		if (!filter_extension($new_file_name)) {
 			$return -1;
 			Display :: display_error_message(get_lang('UplUnableToSaveFileFilteredExtension'));
 		} else {
 			$new_file_name = uniqid('');
 			$new_path = $updir.'/'.$new_file_name;
-			$result = @move_uploaded_file($_FILES['user_upload']['tmp_name'], $new_path);
+			$result = @move_uploaded_file($file['tmp_name'], $new_path);
 			$safe_file_comment = Database::escape_string($file_comment);
 			$safe_file_name = Database::escape_string($file_name);
-			$safe_new_file_name = Database::escape_string($new_file_name);	
-			$sql = "UPDATE $tbl_announcement_attachment SET filename = '$safe_file_name', comment = '$safe_file_comment', path = '$safe_new_file_name', announcement_id = '$last_id', size ='".intval($_FILES['user_upload']['size'])."'
-				 WHERE announcement_id = '$last_id'";
-			$result = Database::query($sql, __FILE__,__LINE__);
+			$safe_new_file_name = Database::escape_string($new_file_name);
+			$id_attach = intval($id_attach);
+			$sql = "UPDATE $tbl_announcement_attachment SET filename = '$safe_file_name', comment = '$safe_file_comment', path = '$safe_new_file_name', size ='".intval($file['size'])."'
+				 WHERE id = '$id_attach'";
+			$result = Database::query($sql);
 			if ($result === false) {
 				$return = -1;
                 Display :: display_error_message(get_lang('UplUnableToSaveFile'));
 			} else {
                 $return = 1;
 			}
-			//$message .= ' / '.get_lang('FileUploadSucces').'<br />';
 		}
 	}
 	return $return;
@@ -1187,10 +1173,9 @@ function delete_announcement_attachment_file($id) {
 
 	global $_course;
 	$tbl_announcement_attachment = Database::get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT);
-	$id=Database::escape_string($id);	
+	$id=Database::escape_string($id);
 	$sql="DELETE FROM $tbl_announcement_attachment WHERE id = $id";
-	error_log($sql);
-	$result=Database::query($sql, __FILE__,__LINE__);
+	$result=Database::query($sql);
 	// update item_property
 	//api_item_property_update($_course, 'announcement_attachment',  $id,'AnnouncementAttachmentDeleted', api_get_user_id());
 }

+ 223 - 213
main/announcements/announcements.php

@@ -1,5 +1,5 @@
 <?php //$Id: announcements.php 2009-11-13 18:56:45Z aportugal $
-/* For licensing terms, see /dokeos_license.txt */
+/* For licensing terms, see /license.txt */
 /**
  * @author Frederik Vermeire <frederik.vermeire@pandora.be>, UGent Internship
  * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University: code cleaning
@@ -25,15 +25,15 @@ $language_file[] = 'survey';
 $use_anonymous = true;
 
 // setting the global file that gets the general configuration, the databases, the languages, ...
-include('../inc/global.inc.php');
+require_once '../inc/global.inc.php';
 $this_section=SECTION_COURSES;
 
-$nameTools = get_lang('Announcement');
+$nameTools = get_lang('ToolAnnouncement');
 
 
 //session
 if(isset($_GET['id_session'])) {
-	$_SESSION['id_session'] = Security::remove_XSS($_GET['id_session']);
+	$_SESSION['id_session'] = intval($_GET['id_session']);
 }
 
 /* ------------	ACCESS RIGHTS ------------ */
@@ -46,8 +46,8 @@ api_protect_course_script();
 -----------------------------------------------------------
 */
 // Configuration settings
-$display_announcement_list = true;
-$display_form             = false;
+$display_announcement_list	 = true;
+$display_form				 = false;
 $display_title_list 		 = true;
 
 // Maximum title messages to display
@@ -124,7 +124,6 @@ $lib = api_get_path(LIBRARY_PATH); //avoid useless function calls
 require_once($lib.'groupmanager.lib.php');
 require_once('announcements.inc.php');
 require_once($lib.'mail.lib.inc.php');
-require_once(api_get_path(INCLUDE_PATH).'conf/mail.conf.php');
 require_once($lib.'debug.lib.inc.php');
 require_once($lib.'tracking.lib.php');
 require_once($lib.'fckeditor/fckeditor.php');
@@ -140,20 +139,17 @@ $safe_newContent = $_POST['newContent'];
 
 if (!empty($_POST['To']))
 {
-	if (api_get_session_id()!=0 && api_is_allowed_to_session_edit(false,true)==false) {		 
+	if (api_get_session_id()!=0 && api_is_allowed_to_session_edit(false,true)==false) {
 		api_not_allowed();
 	}
 	$display_form = true;
 
-	$form_elements= array ('emailTitle'=>$safe_emailTitle, 'newContent'=>$safe_newContent, 'id'=>Security::remove_XSS($_POST['id']), 'emailoption'=>Security::remove_XSS($_POST['email_ann']));
-    $_SESSION['formelements']=$form_elements;
+	$form_elements = array ('emailTitle'=>$safe_emailTitle, 'newContent'=>$safe_newContent, 'id'=>Security::remove_XSS($_POST['id']), 'emailoption'=>Security::remove_XSS($_POST['email_ann']));
+    $_SESSION['formelements'] = $form_elements;
 
     $form_elements            	= $_SESSION['formelements'];
-
 	$title_to_modify            = $form_elements["emailTitle"];
-
 	$content_to_modify          = $form_elements["newContent"];
-
 	$announcement_to_modify     = $form_elements["id"];
 }
 
@@ -166,16 +162,16 @@ if (!empty($_POST['To']))
 $setting_select_groupusers = true;
 if (empty($_POST['To']) and !$_SESSION['select_groupusers'])
 {
-	$_SESSION['select_groupusers']="hide";
+	$_SESSION['select_groupusers'] = "hide";
 }
 $select_groupusers_status=$_SESSION['select_groupusers'];
 if (!empty($_POST['To']) and ($select_groupusers_status=="hide"))
 {
-	$_SESSION['select_groupusers']="show";
+	$_SESSION['select_groupusers'] = "show";
 }
 if (!empty($_POST['To']) and ($select_groupusers_status=="show"))
 {
-	$_SESSION['select_groupusers']="hide";
+	$_SESSION['select_groupusers'] = "hide";
 }
 
 /*
@@ -187,7 +183,7 @@ if (!empty($_POST['To']) and ($select_groupusers_status=="show"))
 // display the form
 if (((!empty($_GET['action']) && $_GET['action'] == 'add') && $_GET['origin'] == "") || (!empty($_GET['action']) && $_GET['action'] == 'edit') || !empty($_POST['To']))
 {
-	if (api_get_session_id()!=0 && api_is_allowed_to_session_edit(false,true)==false) {		 
+	if (api_get_session_id()!=0 && api_is_allowed_to_session_edit(false,true)==false) {
 		api_not_allowed();
 	}
 	$display_form = true;
@@ -208,6 +204,15 @@ if ((empty($originalresource) || ($originalresource!=='no')) and (!empty($action
 */
 
 $htmlHeadXtra[] = to_javascript();
+$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.js" type="text/javascript" language="javascript"></script>'; //jQuery
+$htmlHeadXtra[] = '<script type="text/javascript">
+function setFocus(){
+$("#emailTitle").focus();
+}
+$(document).ready(function () {
+  setFocus();
+});
+</script>';
 
 /*
 -----------------------------------------------------------
@@ -265,23 +270,22 @@ if($surveyid)
 {
 	$db_name=Database::escape_string($_REQUEST['db_name']);
 	$sql_temp = "SELECT * FROM $db_name.survey WHERE survey_id='$surveyid'";
-	$res_temp = Database::query($sql_temp, __FILE__, __LINE__);
+	$res_temp = Database::query($sql_temp);
 	$obj=@Database::fetch_object($res_temp);
 	$template=$obj->template;
 }
 
 if (!empty($_SESSION['toolgroup'])){
-	$_clean['toolgroup']=(int)$_SESSION['toolgroup'];
-	$group_properties  = GroupManager :: get_group_properties($_clean['toolgroup']);
+	$_clean_toolgroup=intval($_SESSION['toolgroup']);
+	$group_properties  = GroupManager :: get_group_properties($_clean_toolgroup);
 	$interbreadcrumb[] = array ("url" => "../group/group.php", "name" => get_lang('Groups'));
-	$interbreadcrumb[] = array ("url"=>"../group/group_space.php?gidReq=".$_SESSION['toolgroup'], "name"=> get_lang('GroupSpace').' ('.$group_properties['name'].')');
+	$interbreadcrumb[] = array ("url"=>"../group/group_space.php?gidReq=".$_clean_toolgroup, "name"=> get_lang('GroupSpace').' ('.$group_properties['name'].')');
 } else {
 	if($surveyid) {
-
-			$interbreadcrumb[] = array ("url" => "../survey/survey_list.php?cidReq=$cidReq", "name" => get_lang('Survey'));
-			$nameTools = get_lang('PublishSurvey');
-	}else {
-		$nameTools = get_lang('Announcement');
+		$interbreadcrumb[] = array ("url" => "../survey/survey_list.php?cidReq=$cidReq", "name" => get_lang('ToolSurvey'));
+		$nameTools = get_lang('PublishSurvey');
+	} else {
+		$nameTools = get_lang('ToolAnnouncement');
 		$nameTools12 = get_lang('PublishSurvey');
 	}
 }
@@ -300,9 +304,7 @@ if (empty($_GET['origin']) or $_GET['origin'] !== 'learnpath')
 {
 	//we are not in the learning path
 	Display::Display_header($nameTools,"Announcements");
-}
-else
-{
+} else {
 	//we are in the learning path, only display central data and change css
 	$display_title_list = false;
 	$display_announcement_list = false;
@@ -332,10 +334,10 @@ if (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_ed
 	// change visibility -> studentview -> course manager view
 	if (!isset($_GET['isStudentView']) || $_GET['isStudentView']!='false') {
 		if (isset($_GET['id']) AND $_GET['id'] AND isset($_GET['action']) AND $_GET['action']=="showhide") {
-			if (api_get_session_id()!=0 && api_is_allowed_to_session_edit(false,true)==false) {		 
+			if (api_get_session_id()!=0 && api_is_allowed_to_session_edit(false,true)==false) {
 				api_not_allowed();
 			}
-			
+
 			$id=intval($_GET['id']);
 			if (!api_is_course_coach() || api_is_element_in_the_session(TOOL_ANNOUNCEMENT, $id)) {
 				if ($ctok == $_GET['sec_token']) {
@@ -352,17 +354,17 @@ if (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_ed
 	-----------------------------------------------------------
 	*/
 	if (!empty($_GET['action']) AND $_GET['action']=='delete' AND isset($_GET['id'])) {
-		//Database::query("DELETE FROM  $tbl_announcement WHERE id='$delete'",__FILE__,__LINE__);
+		//Database::query("DELETE FROM  $tbl_announcement WHERE id='$delete'");
 		$id=intval(addslashes($_GET['id']));
-		if (api_get_session_id()!=0 && api_is_allowed_to_session_edit(false,true)==false) {		 
+		if (api_get_session_id()!=0 && api_is_allowed_to_session_edit(false,true)==false) {
 			api_not_allowed();
 		}
-				
+
 		if (!api_is_course_coach() || api_is_element_in_the_session(TOOL_ANNOUNCEMENT, $id)) {
 
 			// tooledit : visibility = 2 : only visibile for platform administrator
 			if ($ctok == $_GET['sec_token']) {
-				Database::query("UPDATE $tbl_item_property SET visibility='2' WHERE tool='".TOOL_ANNOUNCEMENT."' and ref='".$id."'",__FILE__,__LINE__);
+				Database::query("UPDATE $tbl_item_property SET visibility='2' WHERE tool='".TOOL_ANNOUNCEMENT."' and ref='".$id."'");
 
 				delete_added_resource("Ad_Valvas", $delete);
 
@@ -382,9 +384,9 @@ if (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_ed
 	*/
 	if (!empty($_GET['action']) and $_GET['action']=='delete_all') {
 
-		//Database::query("DELETE FROM $tbl_announcement",__FILE__,__LINE__);
+		//Database::query("DELETE FROM $tbl_announcement");
 		if (api_is_allowed_to_edit()) {
-			Database::query("UPDATE $tbl_item_property SET visibility='2' WHERE tool='".TOOL_ANNOUNCEMENT."'",__FILE__,__LINE__);
+			Database::query("UPDATE $tbl_item_property SET visibility='2' WHERE tool='".TOOL_ANNOUNCEMENT."'");
 
 			delete_all_resources_type("Ad_Valvas");
 
@@ -402,25 +404,24 @@ if (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_ed
 	-----------------------------------------------------------
 	*/
 	if (!empty($_GET['action']) and $_GET['action']=='modify' AND isset($_GET['id'])) {
-		if (api_get_session_id()!=0 && api_is_allowed_to_session_edit(false,true)==false) {		 
+		if (api_get_session_id()!=0 && api_is_allowed_to_session_edit(false,true)==false) {
 			api_not_allowed();
 		}
-			
+
 		$display_form = true;
 
 		// RETRIEVE THE CONTENT OF THE ANNOUNCEMENT TO MODIFY
-		$id = intval(addslashes($_GET['id']));
+		$id = intval($_GET['id']);
 
 		if (!api_is_course_coach() || api_is_element_in_the_session(TOOL_ANNOUNCEMENT, $id)) {
 			$sql="SELECT * FROM  $tbl_announcement WHERE id='$id'";
-			$result = Database::query($sql,__FILE__,__LINE__);
-			$myrow = Database::fetch_array($result);
+			$rs = Database::query($sql);
+			$myrow = Database::fetch_array($rs);
 			$last_id = $id;
 			$edit_attachment = edit_announcement_attachment_file($last_id, $_FILES['user_upload'], $file_comment);
 			if ($myrow) {
 				$announcement_to_modify 	= $myrow['id'];
-				$content_to_modify 		= $myrow['content'];
-
+				$content_to_modify 			= $myrow['content'];
 				$title_to_modify 			= $myrow['title'];
 
 				if ($originalresource!=="no")  {
@@ -432,12 +433,9 @@ if (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_ed
 				$display_announcement_list = false;
 			}
 
-			if ($to=="everyone" OR !empty($_SESSION['toolgroup']))
-			{
+			if ($to=="everyone" OR !empty($_SESSION['toolgroup'])) {
 				$_SESSION['select_groupusers']="hide";
-			}
-			else
-			{
+			} else {
 				$_SESSION['select_groupusers']="show";
 			}
 		}
@@ -472,7 +470,7 @@ if (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_ed
 				"AND itemproperty.tool='".TOOL_ANNOUNCEMENT."' " .
 				"AND itemproperty.visibility<>2 " .
 				"ORDER BY display_order $sortDirection";
-		$result = Database::query($my_sql,__FILE__,__LINE__);
+		$result = Database::query($my_sql);
 
 		while (list ($announcementId, $announcementOrder) = Database::fetch_row($result)) {
 			// STEP 2 : FOUND THE NEXT ANNOUNCEMENT ID AND ORDER.
@@ -483,10 +481,10 @@ if (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_ed
 				$nextAnnouncementOrder = $announcementOrder;
 				Database::query("UPDATE $tbl_announcement " .
 						"SET display_order = '$nextAnnouncementOrder' " .
-						"WHERE id =  '$thisAnnouncementId'",__FILE__,__LINE__);
+						"WHERE id =  '$thisAnnouncementId'");
 				Database::query("UPDATE $tbl_announcement " .
 						"SET display_order = '$thisAnnouncementOrder' " .
-						"WHERE id =  '$nextAnnouncementId.'",__FILE__,__LINE__);
+						"WHERE id =  '$nextAnnouncementId.'");
 
 				break;
 			}
@@ -511,7 +509,7 @@ if (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_ed
 
 	$emailTitle=(!empty($_POST['emailTitle'])?$safe_emailTitle:'');
 	$newContent=(!empty($_POST['newContent'])?$safe_newContent:'');
-	
+
 	$submitAnnouncement=isset($_POST['submitAnnouncement'])?$_POST['submitAnnouncement']:0;
 
 	$id = 0;
@@ -527,7 +525,9 @@ if (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_ed
 		if (isset($id)&&$id) {
 			// there is an Id => the announcement already exists => update mode
 			if ($ctok == $_POST['sec_token']) {
-				$edit_id = edit_advalvas_item($id,$emailTitle,$newContent,$_POST['selectedform']);
+				$file_comment = $_POST['file_comment'];
+				$file = $_FILES['user_upload'];
+				$edit_id = edit_advalvas_item($id,$emailTitle,$newContent,$_POST['selectedform'],$file,$file_comment);
 				if (!$delete) {
 				    update_added_resources("Ad_Valvas", $id);
 				}
@@ -536,16 +536,18 @@ if (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_ed
 		} else {
 			//insert mode
 			if ($ctok == $_POST['sec_token']) {
-				
+
 				if (!$surveyid) {
-					$result = Database::query("SELECT MAX(display_order) FROM $tbl_announcement WHERE session_id=".intval($_SESSION['id_session'])." OR session_id=0",__FILE__,__LINE__);
+					$result = Database::query("SELECT MAX(display_order) FROM $tbl_announcement WHERE session_id=".intval($_SESSION['id_session'])." OR session_id=0");
 					list($orderMax) = Database::fetch_row($result);
 					$order = $orderMax + 1;
+					$file = $_FILES['user_upload'];
+					$file_comment = $_POST['file_comment'];
 					if (!empty($_SESSION['toolgroup'])) {
-						$insert_id=store_advalvas_group_item($safe_emailTitle,$safe_newContent,$order,array('GROUP:'.$_SESSION['toolgroup']),$_POST['selectedform']);
+						$insert_id=store_advalvas_group_item($safe_emailTitle,$safe_newContent,$order,array('GROUP:'.$_SESSION['toolgroup']),$_POST['selectedform'],$file,$file_comment);
 					} else {
-						$insert_id=store_advalvas_item($safe_emailTitle,$safe_newContent,$order,$_POST['selectedform'],$_POST['file_comment']);
-					}					
+						$insert_id=store_advalvas_item($safe_emailTitle,$safe_newContent,$order,$_POST['selectedform'],$file,$file_comment);
+					}
 				    store_resources($_SESSION['source_type'],$insert_id);
 				    $_SESSION['select_groupusers']="hide";
 				    $message = get_lang('AnnouncementAdded');
@@ -579,12 +581,12 @@ if (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_ed
 
 						    $sender_name = api_get_person_name($_SESSION['_user']['lastName'], $_SESSION['_user']['firstName'], null, PERSON_NAME_EMAIL_ADDRESS);
 						    $email = $_SESSION['_user']['mail'];
-							$headers="From:$sender_name\r\nReply-to: $email\r\nContent-type: text/html; charset=iso-8859-15";
+							$headers="From:$sender_name\r\nReply-to: $email";
 							//@mail($to,$subject,$message,$headers);
 							//api_send_mail($to,$subject,$message,$headers);
-							api_mail('',$to,$subject,$message,$sender_name,$email,$headers);
+							@api_mail('',$to,$subject,$message,$sender_name,$email,$headers);
 							$sql_date="SELECT * FROM $db_name.survey WHERE survey_id='$surveyid'";
-							$res_date=Database::query($sql_date, __FILE__, __LINE__);
+							$res_date=Database::query($sql_date);
 							$obj_date=Database::fetch_object($res_date);
 							$end_date=$obj_date->avail_till;
 							$table_reminder = Database :: get_main_table(TABLE_MAIN_SURVEY_REMINDER); // TODO: To be checked. TABLE_MAIN_SURVEY_REMINDER has not been defined.
@@ -593,19 +595,19 @@ if (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_ed
 								$time = $time['yday'];
 								$time = $time+7;
 								$sql_insert="INSERT INTO $table_reminder(sid,db_name,email,subject,content,reminder_choice,reminder_time,avail_till) values('$surveyid','$db_name','$to','".addslashes($subject)."','".addslashes($message)."','1','$time','$end_date')";
-								Database::query($sql_insert, __FILE__, __LINE__);
+								Database::query($sql_insert);
 							} else if ($_REQUEST['reminder']=="2") {
 								$time=getdate();
 								$time = $time['yday'];
 								$time = $time+14;
 								$sql_insert="INSERT INTO $table_reminder(sid,db_name,email,subject,content,reminder_choice,reminder_time,avail_till) values('$surveyid','$db_name','$to','".addslashes($subject)."','".addslashes($message)."','1','$time','$end_date')";
-								Database::query($sql_insert, __FILE__, __LINE__);
+								Database::query($sql_insert);
 							} else if($_REQUEST['reminder']=="3") {
 								$time=getdate();
 								$time = $time['yday'];
 								$time = $time+30;
 								$sql_insert="INSERT INTO $table_reminder(sid,db_name,email,subject,content,reminder_choice,reminder_time,avail_till) values('$surveyid','$db_name','$to','".addslashes($subject)."','".addslashes($message)."','1','$time','$end_date')";
-								Database::query($sql_insert, __FILE__, __LINE__);
+								Database::query($sql_insert);
 							}
 						}
 					}
@@ -630,7 +632,7 @@ if (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_ed
 								WHERE gu.group_id IN (".$grouplist.")";
 
 
-						$groupMemberResult = Database::query($sql,__FILE__,__LINE__);
+						$groupMemberResult = Database::query($sql);
 
 
 						if ($groupMemberResult) {
@@ -654,7 +656,7 @@ if (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_ed
 				    		$sqlmail = "SELECT user.user_id, user.email, user.lastname, user.firstname
 					                     FROM $tbl_course_user, $tbl_user
 					                     WHERE course_code='".Database::escape_string($_course['sysCode'])."'
-					                     AND course_rel_user.user_id = user.user_id";
+					                     AND course_rel_user.user_id = user.user_id AND relation_type <>".COURSE_RELATION_TYPE_RRHH." ";
 			    		} else {
 			    			$sqlmail = "SELECT user.user_id, user.email, user.lastname, user.firstname
 					                     FROM $tbl_user
@@ -666,16 +668,13 @@ if (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_ed
 			    		}
 			    	}
 
-					if ($sqlmail!='') {
-						$result = Database::query($sqlmail,__FILE__,__LINE__);
-
+					if ($sqlmail != '') {
+						$rs_mail = Database::query($sqlmail);
 				    	/*=================================================================================
 							    				send email one by one to avoid antispam
 					    =================================================================================*/
-
-
 						$db_name = Database::get_course_table(TABLE_MAIN_SURVEY);
-						while ($myrow = Database::fetch_array($result)) {
+						while ($myrow = Database::fetch_array($rs_mail)) {
 							/*    Header : Bericht van uw lesgever - GES ($_cid)
 
 								  Body :   John Doe (prenom + nom) <john_doe@hotmail.com> (email)
@@ -695,14 +694,11 @@ if (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_ed
 	                            $newContentfive=str_replace("#db_name#",$db_name,$newContentfour);
 								$newContentsix=str_replace("#uid#",$myrow["user_id"],$newContentfive);
 	                			$message=stripslashes($newContentsix);
-
 							    $sender_name = api_get_person_name($_SESSION['_user']['lastName'], $_SESSION['_user']['firstName'], null, PERSON_NAME_EMAIL_ADDRESS);
 							    $email = $_SESSION['_user']['mail'];
-
-
-								$headers="From:$sender_name\r\nReply-to: $email\r\nContent-type: text/html; charset=iso-8859-15";
+								$headers="From:$sender_name\r\nReply-to: $email";
 								//@mail($myrow["email"],stripslashes($emailTitle),$message,$headers);
-								api_mail('',$myrow["email"],stripslashes($emailTitle),$message,$sender_name,$email);
+								@api_mail('',$myrow["email"],stripslashes($emailTitle),$message,$sender_name,$email);
 	                        } else {
 	                            // intro of the email: receiver name and subject
 								$mail_body = api_get_person_name($myrow["lastname"], $myrow["firstname"], null, PERSON_NAME_EMAIL_ADDRESS)."<br />\n".stripslashes($emailTitle)."<br />";
@@ -716,29 +712,28 @@ if (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_ed
 	                            $mail_body .= "<br /> \n<a href=\"".api_get_path(WEB_COURSE_PATH).$_course['id']."\">";
 	                            $mail_body .= $_course['official_code'].' '.$_course['name'] . "</a>";
 
-								//set the charset and use it for the encoding of the email - small fix, not really clean (should check the content encoding origin first)
-								//here we use the encoding used for the webpage where the text is encoded (ISO-8859-1 in this case)
-								
-								$recipient_name	= api_get_person_name($myrow["lastname"], $myrow["firstname"], null, PERSON_NAME_EMAIL_ADDRESS);
+								$recipient_name	= api_get_person_name($myrow["firstname"], $myrow["lastname"], null, PERSON_NAME_EMAIL_ADDRESS);
 		                        $mailid = $myrow["email"];
-		                        $sender_name = api_get_person_name($_SESSION['_user']['lastName'], $_SESSION['_user']['firstName'], null, PERSON_NAME_EMAIL_ADDRESS);
+
+		                        $sender_name = api_get_person_name($_SESSION['_user']['firstName'], $_SESSION['_user']['lastName'], null, PERSON_NAME_EMAIL_ADDRESS);
 		                        $sender_email = $_SESSION['_user']['mail'];
+
+								// send attachment file
 								$data_file = array();
-								if (!empty($_FILES['user_upload'])) {
-									$courseDir = $_course['path'].'/upload/announcements/';
-									$sys_course_path = api_get_path(SYS_COURSE_PATH);
-									$sql = 'SELECT path, filename FROM '.$tbl_announcement_attachment.'
-									  	    WHERE announcement_id  = "'.$insert_id.'"';
-									$result = Database::query($sql, __FILE__, __LINE__);
-									$row = Database::fetch_array($result);
-									$data_file = array('path' => $sys_course_path.$courseDir.$row['path'],
-													   'filename' => $row['filename']);
-								}								
-								api_mail_html($recipient_name, $mailid, stripslashes($emailSubject), $mail_body, $sender_name, $sender_email, null, $data_file);
+								$sql = 'SELECT path, filename FROM '.$tbl_announcement_attachment.' WHERE announcement_id = "'.$insert_id.'"';
+								$rs_attach = Database::query($sql);
+								if (Database::num_rows($rs_attach) > 0) {
+									$row_attach  = Database::fetch_array($rs_attach);
+									$path_attach = api_get_path(SYS_COURSE_PATH).$_course['path'].'/upload/announcements/'.$row_attach['path'];
+									$filename_attach = $row_attach['filename'];
+									$data_file = array('path' => $path_attach,'filename' => $filename_attach);
+								}
+
+								@api_mail_html($recipient_name, $mailid, stripslashes($emailSubject), $mail_body, $sender_name, $sender_email, null, $data_file);
 	                        }
 
 							$sql_date="SELECT * FROM $db_name WHERE survey_id='$surveyid'";
-							$res_date=Database::query($sql_date, __FILE__, __LINE__);
+							$res_date=Database::query($sql_date);
 							$obj_date=Database::fetch_object($res_date);
 							$end_date=$obj_date->avail_till;
 							$table_reminder = Database :: get_main_table(TABLE_MAIN_SURVEY_REMINDER); // TODO: To be checked. TABLE_MAIN_SURVEY_REMINDER has not been defined.
@@ -748,20 +743,20 @@ if (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_ed
 								$time = $time['yday'];
 								$time = $time+7;
 								$sql="INSERT INTO $table_reminder(sid,db_name,email,subject,content,reminder_choice,reminder_time,avail_till) values('$surveyid','$db_name','$mailid','".addslashes($emailSubject)."','".addslashes($mail_body)."','1','$time','$end_date')";
-								Database::query($sql, __FILE__, __LINE__);
+								Database::query($sql);
 							} else if ($_REQUEST['reminder']=="2") {
 								$time=getdate();
 								$time = $time['yday'];
 								$time = $time+14;
 								$sql="INSERT INTO $table_reminder(sid,db_name,email,subject,content,reminder_choice,reminder_time,avail_till) values('$surveyid','$db_name','$mailid','".addslashes($emailSubject)."','".addslashes($mail_body)."','1','$time','$end_date')";
-								Database::query($sql, __FILE__, __LINE__);
+								Database::query($sql);
 
 							} else if ($_REQUEST['reminder']=="3") {
 								$time=getdate();
 								$time = $time['yday'];
 								$time = $time+30;
 								$sql="INSERT INTO $table_reminder(sid,db_name,email,subject,content,reminder_choice,reminder_time,avail_till) values('$surveyid','$db_name','$mailid','".addslashes($emailSubject)."','".addslashes($mail_body)."','1','$time','$end_date')";
-								Database::query($sql, __FILE__, __LINE__);
+								Database::query($sql);
 							}
 						}
 						update_mail_sent($insert_id);
@@ -785,8 +780,6 @@ if (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_ed
 		unset($content_to_modify);
 		unset($title_to_modify);
 
-
-
 		if($_REQUEST['publish_survey']) {
 
 		 $surveyid=$_REQUEST['surveyid'];
@@ -828,13 +821,13 @@ if(api_is_allowed_to_edit(false,true))  {
   	if (empty($_GET['origin']) or $_GET['origin'] !== 'learnpath') {
 
 		$sql="SELECT
-				announcement.*, toolitemproperties.*
-				FROM $tbl_announcement announcement, $tbl_item_property toolitemproperties
-				WHERE announcement.id = toolitemproperties.ref
-				AND toolitemproperties.tool='announcement'
-				AND toolitemproperties.visibility<>'2'
+				announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id
+				FROM $tbl_announcement announcement, $tbl_item_property ip
+				WHERE announcement.id = ip.ref
+				AND ip.tool='announcement'
+				AND ip.visibility<>'2'
 				$condition_session
-				GROUP BY toolitemproperties.ref
+				GROUP BY ip.ref
 				ORDER BY display_order DESC
 				LIMIT 0,$maximum";
 	}
@@ -846,24 +839,24 @@ if(api_is_allowed_to_edit(false,true))  {
 			$group_memberships=GroupManager::get_group_ids($_course['dbName'], $_user['user_id']);
 
 			if ((api_get_course_setting('allow_user_edit_announcement') && !api_is_anonymous())) {
-				$cond_user_id = " AND (toolitemproperties.lastedit_user_id = '".api_get_user_id()."' OR ( toolitemproperties.to_user_id='".$_user['user_id']."'" .
-						"OR toolitemproperties.to_group_id IN (0, ".implode(", ", $group_memberships)."))) ";
+				$cond_user_id = " AND (ip.lastedit_user_id = '".api_get_user_id()."' OR ( ip.to_user_id='".$_user['user_id']."'" .
+						"OR ip.to_group_id IN (0, ".implode(", ", $group_memberships)."))) ";
 			} else {
-				$cond_user_id = " AND ( toolitemproperties.to_user_id='".$_user['user_id']."'" .
-						"OR toolitemproperties.to_group_id IN (0, ".implode(", ", $group_memberships).")) ";
+				$cond_user_id = " AND ( ip.to_user_id='".$_user['user_id']."'" .
+						"OR ip.to_group_id IN (0, ".implode(", ", $group_memberships).")) ";
 			}
 
 			// the user is member of several groups => display personal announcements AND his group announcements AND the general announcements
 			if (is_array($group_memberships) && count($group_memberships)>0) {
 				$sql="SELECT
-					announcement.*, toolitemproperties.*
-					FROM $tbl_announcement announcement, $tbl_item_property toolitemproperties
-					WHERE announcement.id = toolitemproperties.ref
-					AND toolitemproperties.tool='announcement'
-					AND toolitemproperties.visibility='1'
+					announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id
+					FROM $tbl_announcement announcement, $tbl_item_property ip
+					WHERE announcement.id = ip.ref
+					AND ip.tool='announcement'
+					AND ip.visibility='1'
 					$cond_user_id
 					$condition_session
-					GROUP BY toolitemproperties.ref
+					GROUP BY ip.ref
 					ORDER BY display_order DESC
 					LIMIT 0,$maximum";
 			} else {
@@ -872,41 +865,41 @@ if(api_is_allowed_to_edit(false,true))  {
 				if ($_user['user_id']) {
 
 					if ((api_get_course_setting('allow_user_edit_announcement') && !api_is_anonymous())) {
-						$cond_user_id = " AND (toolitemproperties.lastedit_user_id = '".api_get_user_id()."' OR ( toolitemproperties.to_user_id='".$_user['user_id']."' OR toolitemproperties.to_group_id='0')) ";
+						$cond_user_id = " AND (ip.lastedit_user_id = '".api_get_user_id()."' OR ( ip.to_user_id='".$_user['user_id']."' OR ip.to_group_id='0')) ";
 					} else {
-						$cond_user_id = " AND ( toolitemproperties.to_user_id='".$_user['user_id']."' OR toolitemproperties.to_group_id='0') ";
+						$cond_user_id = " AND ( ip.to_user_id='".$_user['user_id']."' OR ip.to_group_id='0') ";
 					}
 
 
 					$sql="SELECT
-						announcement.*, toolitemproperties.*
-						FROM $tbl_announcement announcement, $tbl_item_property toolitemproperties
-						WHERE announcement.id = toolitemproperties.ref
-						AND toolitemproperties.tool='announcement'
-						AND toolitemproperties.visibility='1'
+						announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id
+						FROM $tbl_announcement announcement, $tbl_item_property ip
+						WHERE announcement.id = ip.ref
+						AND ip.tool='announcement'
+						AND ip.visibility='1'
 						$cond_user_id
 						$condition_session
-						GROUP BY toolitemproperties.ref
+						GROUP BY ip.ref
 						ORDER BY display_order DESC
 						LIMIT 0,$maximum";
 				} else {
 
 					if (api_get_course_setting('allow_user_edit_announcement')) {
-						$cond_user_id = " AND (toolitemproperties.lastedit_user_id = '".api_get_user_id()."' OR toolitemproperties.to_group_id='0') ";
+						$cond_user_id = " AND (ip.lastedit_user_id = '".api_get_user_id()."' OR ip.to_group_id='0') ";
 					} else {
-						$cond_user_id = " AND toolitemproperties.to_group_id='0' ";
+						$cond_user_id = " AND ip.to_group_id='0' ";
 					}
 
 					// the user is not identiefied => show only the general announcements
 					$sql="SELECT
-						announcement.*, toolitemproperties.*
-						FROM $tbl_announcement announcement, $tbl_item_property toolitemproperties
-						WHERE announcement.id = toolitemproperties.ref
-						AND toolitemproperties.tool='announcement'
-						AND toolitemproperties.visibility='1'
-						AND toolitemproperties.to_group_id='0'
+						announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id
+						FROM $tbl_announcement announcement, $tbl_item_property ip
+						WHERE announcement.id = ip.ref
+						AND ip.tool='announcement'
+						AND ip.visibility='1'
+						AND ip.to_group_id='0'
 						$condition_session
-						GROUP BY toolitemproperties.ref
+						GROUP BY ip.ref
 						ORDER BY display_order DESC
 						LIMIT 0,$maximum";
 				}
@@ -916,7 +909,7 @@ if(api_is_allowed_to_edit(false,true))  {
 
 }
 
-$result = Database::query($sql,__FILE__,__LINE__);
+$result = Database::query($sql);
 $announcement_number = Database::num_rows($result);
 
 /*----------------------------------------------------
@@ -963,10 +956,8 @@ if (!$surveyid) {
 			}
 			//validation when belongs to a session
 			$session_img = api_get_session_image($myrow['session_id'], $_user['status']);
-			
-			
-			
-			echo "\t\t\t\t\t\t".Display::return_icon('lp_announcement.png', api_ucfirst(format_locale_date($dateFormatLong,strtotime($myrow['end_date']))), array('align' => 'absmiddle', 'Width' => '10', 'Height' => '10'))."  <a style=\"text-decoration:none\" href=\"announcements.php?".api_get_cidreq()."#".$myrow['id']."\" ".$class.">" . api_trunc_str($title, $length) . "</a>\n" . $session_img;
+
+			echo "\t\t\t\t\t\t".Display::return_icon('lp_announcement.png', api_convert_and_format_date($myrow['end_date'], DATE_FORMAT_LONG), array('align' => 'absmiddle', 'Width' => '10', 'Height' => '10'))."  <a style=\"text-decoration:none\" href=\"announcements.php?".api_get_cidreq()."#".$myrow['id']."\" ".$class.">" . api_trunc_str($title, $length) . "</a>\n" . $session_img;
 			echo "\t\t\t\t\t</td>\n\t\t\t\t</tr>\n";
 		}
 		echo "\t\t\t</table>\n";
@@ -1001,8 +992,8 @@ if (!empty($error_message)) {
 
 if ($display_form == true) {
 
-	$content_to_modify=stripslashes($content_to_modify);
-	$title_to_modify=stripslashes($title_to_modify);
+	$content_to_modify = stripslashes($content_to_modify);
+	$title_to_modify = stripslashes($title_to_modify);
 
 	// DISPLAY ADD ANNOUNCEMENT COMMAND
 	echo '<form method="post" name="f1" enctype = "multipart/form-data" action="'.api_get_self().'?publish_survey='.Security::remove_XSS($surveyid).'&id='.Security::remove_XSS($_GET['id']).'&db_name='.$db_name.'&cidReq='.Security::remove_XSS($_GET['cidReq']).'" style="margin:0px;">'."\n";
@@ -1041,7 +1032,7 @@ if ($display_form == true) {
 			// setting the variables for the form elements: the message has to be sent by email
 			$email_ann = '1';
 			// setting the variables for the form elements: the title of the email
-			$title_to_modify = sprintf(get_lang('RemindInactiveLearnersMailSubject'),api_get_setting('siteName'),' > ',$_course['name']);				
+			$title_to_modify = sprintf(get_lang('RemindInactiveLearnersMailSubject'),api_get_setting('siteName'),' > ',$_course['name']);
 			// setting the variables for the form elements: the message of the email
 			$content_to_modify = sprintf(get_lang('RemindInactiveLearnersMailContent'),api_get_setting('siteName'),' > ',$_course['name'],$since);
 			// when we want to remind the users who have never been active then we have a different subject and content for the announcement
@@ -1219,22 +1210,22 @@ if ($display_announcement_list && !$surveyid) {
 		if (isset($_SESSION['user'])) {
 			if (is_array($group_memberships) && count($group_memberships)>0) {
 				$sql="SELECT
-					announcement.*, toolitemproperties.*
-					FROM $tbl_announcement announcement, $tbl_item_property toolitemproperties
-					WHERE announcement.id = toolitemproperties.ref
-					AND toolitemproperties.tool='announcement'
-					AND	(toolitemproperties.to_user_id=$user_id OR toolitemproperties.to_group_id IN (0, ".implode(", ", $group_memberships).") )
+					announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id
+					FROM $tbl_announcement announcement, $tbl_item_property ip
+					WHERE announcement.id = ip.ref
+					AND ip.tool='announcement'
+					AND	(ip.to_user_id=$user_id OR ip.to_group_id IN (0, ".implode(", ", $group_memberships).") )
 					$condition_session
 					ORDER BY display_order DESC";
 
 			} else {
 				$sql="SELECT
-					announcement.*, toolitemproperties.*
-					FROM $tbl_announcement announcement, $tbl_item_property toolitemproperties
-					WHERE announcement.id = toolitemproperties.ref
-					AND toolitemproperties.tool='announcement'
-					AND (toolitemproperties.to_user_id=$user_id OR toolitemproperties.to_group_id='0')
-					AND toolitemproperties.visibility='1'
+					announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id
+					FROM $tbl_announcement announcement, $tbl_item_property ip
+					WHERE announcement.id = ip.ref
+					AND ip.tool='announcement'
+					AND (ip.to_user_id=$user_id OR ip.to_group_id='0')
+					AND ip.visibility='1'
 					$condition_session
 					ORDER BY display_order DESC";
 
@@ -1244,13 +1235,13 @@ if ($display_announcement_list && !$surveyid) {
 			// => see only the messages of this specific group
 
 			$sql="SELECT
-				announcement.*, toolitemproperties.*
-				FROM $tbl_announcement announcement, $tbl_item_property toolitemproperties
-				WHERE announcement.id = toolitemproperties.ref
-				AND toolitemproperties.tool='announcement'
-				AND (toolitemproperties.to_group_id=$group_id OR toolitemproperties.to_group_id='0')
+				announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id
+				FROM $tbl_announcement announcement, $tbl_item_property ip
+				WHERE announcement.id = ip.ref
+				AND ip.tool='announcement'
+				AND (ip.to_group_id=$group_id OR ip.to_group_id='0')
 				$condition_session
-				GROUP BY toolitemproperties.ref
+				GROUP BY ip.ref
 				ORDER BY display_order DESC";
 		} else {
 			// A.3 you are a course admin without any group or user filter
@@ -1260,25 +1251,25 @@ if ($display_announcement_list && !$surveyid) {
 			if (isset($isStudentView) and $isStudentView=="true") {
 
 				$sql="SELECT
-					announcement.*, toolitemproperties.*
-					FROM $tbl_announcement announcement, $tbl_item_property toolitemproperties
-					WHERE announcement.id = toolitemproperties.ref
-					AND toolitemproperties.tool='announcement'
-					AND toolitemproperties.visibility='1'
+					announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id
+					FROM $tbl_announcement announcement, $tbl_item_property ip
+					WHERE announcement.id = ip.ref
+					AND ip.tool='announcement'
+					AND ip.visibility='1'
 					$condition_session
-					GROUP BY toolitemproperties.ref
+					GROUP BY ip.ref
 					ORDER BY display_order DESC";
 			} else {
 				// A.3.a you are a course admin without user or group filter and WTIHOUT studentview (= the normal course admin view)
 				// => see all the messages of all the users and groups with editing possibilities
 				$sql="SELECT
-					announcement.*, toolitemproperties.*
-					FROM $tbl_announcement announcement, $tbl_item_property toolitemproperties
-					WHERE announcement.id = toolitemproperties.ref
-					AND toolitemproperties.tool='announcement'
-					AND (toolitemproperties.visibility='0' or toolitemproperties.visibility='1')
+					announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id
+					FROM $tbl_announcement announcement, $tbl_item_property ip
+					WHERE announcement.id = ip.ref
+					AND ip.tool='announcement'
+					AND (ip.visibility='0' or ip.visibility='1')
 					$condition_session
-					GROUP BY toolitemproperties.ref
+					GROUP BY ip.ref
 					ORDER BY display_order DESC";
 
 			}
@@ -1288,60 +1279,63 @@ if ($display_announcement_list && !$surveyid) {
 			if (is_array($group_memberships) && count($group_memberships)>0) {
 
 				if ((api_get_course_setting('allow_user_edit_announcement') && !api_is_anonymous())) {
-					$cond_user_id = " AND (toolitemproperties.lastedit_user_id = '".api_get_user_id()."' OR (toolitemproperties.to_user_id=$user_id OR toolitemproperties.to_group_id IN (0, ".implode(", ", $group_memberships).") )) ";
+					$cond_user_id = " AND (ip.lastedit_user_id = '".api_get_user_id()."' OR (ip.to_user_id=$user_id OR ip.to_group_id IN (0, ".implode(", ", $group_memberships).") )) ";
 				} else {
-					$cond_user_id = " AND (toolitemproperties.to_user_id=$user_id OR toolitemproperties.to_group_id IN (0, ".implode(", ", $group_memberships).")) ";
+					$cond_user_id = " AND (ip.to_user_id=$user_id OR ip.to_group_id IN (0, ".implode(", ", $group_memberships).")) ";
 				}
 
 				$sql="SELECT
-					announcement.*, toolitemproperties.*
-					FROM $tbl_announcement announcement, $tbl_item_property toolitemproperties
-					WHERE announcement.id = toolitemproperties.ref
-					AND toolitemproperties.tool='announcement'
+					announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id
+					FROM $tbl_announcement announcement, $tbl_item_property ip
+					WHERE announcement.id = ip.ref
+					AND ip.tool='announcement'
 					$cond_user_id
-					AND toolitemproperties.visibility='1'
+					$condition_session
+					AND ip.visibility='1'
 					ORDER BY display_order DESC";
 			} else {
 
 				if ($_user['user_id']) {
 
 					if ((api_get_course_setting('allow_user_edit_announcement') && !api_is_anonymous())) {
-						$cond_user_id = " AND (toolitemproperties.lastedit_user_id = '".api_get_user_id()."' OR (toolitemproperties.to_user_id='".$_user['user_id']."' OR toolitemproperties.to_group_id='0')) ";
+						$cond_user_id = " AND (ip.lastedit_user_id = '".api_get_user_id()."' OR (ip.to_user_id='".$_user['user_id']."' OR ip.to_group_id='0')) ";
 					} else {
-						$cond_user_id = " AND (toolitemproperties.to_user_id='".$_user['user_id']."' OR toolitemproperties.to_group_id='0') ";
+						$cond_user_id = " AND (ip.to_user_id='".$_user['user_id']."' OR ip.to_group_id='0') ";
 					}
 
 					$sql="SELECT
-						announcement.*, toolitemproperties.*
-						FROM $tbl_announcement announcement, $tbl_item_property toolitemproperties
-						WHERE announcement.id = toolitemproperties.ref
-						AND toolitemproperties.tool='announcement'
+						announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id
+						FROM $tbl_announcement announcement, $tbl_item_property ip
+						WHERE announcement.id = ip.ref
+						AND ip.tool='announcement'
 						$cond_user_id
-						AND toolitemproperties.visibility='1'
+						$condition_session
+						AND ip.visibility='1'
 						AND announcement.session_id IN(0,".intval($_SESSION['id_session']).")
 						ORDER BY display_order DESC";
 				} else {
 
 					if ((api_get_course_setting('allow_user_edit_announcement') && !api_is_anonymous())) {
-						$cond_user_id = " AND (toolitemproperties.lastedit_user_id = '".api_get_user_id()."' OR toolitemproperties.to_group_id='0' ) ";
+						$cond_user_id = " AND (ip.lastedit_user_id = '".api_get_user_id()."' OR ip.to_group_id='0' ) ";
 					} else {
-						$cond_user_id = " AND toolitemproperties.to_group_id='0' ";
+						$cond_user_id = " AND ip.to_group_id='0' ";
 					}
 
 					$sql="SELECT
-						announcement.*, toolitemproperties.*
-						FROM $tbl_announcement announcement, $tbl_item_property toolitemproperties
-						WHERE announcement.id = toolitemproperties.ref
-						AND toolitemproperties.tool='announcement'
+						announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id
+						FROM $tbl_announcement announcement, $tbl_item_property ip
+						WHERE announcement.id = ip.ref
+						AND ip.tool='announcement'
 						$cond_user_id
-						AND toolitemproperties.visibility='1'
+						$condition_session
+						AND ip.visibility='1'
 						AND announcement.session_id IN(0,".intval($_SESSION['id_session']).")";
 				}
 			}
 
 	}
 
-	$result = Database::query($sql,__FILE__,__LINE__);
+	$result = Database::query($sql);
 	$num_rows = Database::num_rows($result);
 
 	/*=================================================
@@ -1413,7 +1407,7 @@ if ($display_announcement_list && !$surveyid) {
 			echo '&nbsp;&nbsp;&nbsp;'.get_lang('By').' : &nbsp;'.str_replace(' ', '&nbsp;', api_get_person_name($user_info['firstName'], $user_info['lastName']));
 			echo "\t\t\t\t\t</th>\n","\t\t\t\t</tr>\n";
 			echo "\t\t\t\t<tr class='row_odd'>\n\t\t\t\t\t<td class=\"announcements_datum\" colspan=\"3\">";
-			echo get_lang('AnnouncementPublishedOn')," : ",api_ucfirst(format_locale_date($dateFormatLong,strtotime($last_post_date)));
+			echo get_lang('AnnouncementPublishedOn')," : ", api_convert_and_format_date($last_post_datetime, DATE_FORMAT_LONG, date_default_timezone_get());
 			echo "</td>\n\t\t\t\t</tr>\n";
 
 			/* CONTENT */
@@ -1465,39 +1459,55 @@ if ($display_announcement_list && !$surveyid) {
 					echo	"<a href=\"".api_get_self()."?".api_get_cidreq()."&down=".$myrow["id"]."&sec_token=".$stok."\">".
 							Display::return_icon('down.gif', get_lang('Down'))."</a>";
 				}
-				
+
 				//delete attachment file
 				if($_GET['action'] == 'delete') {
 					$id = $_GET['id_attach'];
 					delete_announcement_attachment_file($id);
 				}
-					
+
 				// show attachment list
 				$attachment_list = array();
 				$attachment_list = get_attachment($myrow['id']);
-								
+
 				if (count($attachment_list)>0) {
-				$realname=$attachment_list['path'];
-				$user_filename=$attachment_list['filename'];
-				$full_file_name = 'download.php?file='.$realname;
-				echo '<br/>';
-				echo '<br/>';
-				echo Display::return_icon('attachment.gif',get_lang('Attachment'));
-				echo '<a href="'.$full_file_name.'';
-				echo ' "> '.$user_filename.' </a>';
-				echo '<span class="forum_attach_comment" >'.$attachment_list['comment'].'</span>';
-				
-				if (api_is_allowed_to_edit()) {
-					echo '&nbsp;&nbsp;<a href="'.api_get_self().'?'.api_get_cidreq().'&action=delete&id_attach='.$attachment_list['id'].'" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)).'\')) return false;">'.Display::return_icon('delete.gif',get_lang('Delete')).'</a><br />';
+					$realname=$attachment_list['path'];
+					$user_filename=$attachment_list['filename'];
+					$full_file_name = 'download.php?file='.$realname;
+					echo '<br/>';
+					echo '<br/>';
+					echo Display::return_icon('attachment.gif',get_lang('Attachment'));
+					echo '<a href="'.$full_file_name.'';
+					echo ' "> '.$user_filename.' </a>';
+					echo '<span class="forum_attach_comment" >'.$attachment_list['comment'].'</span>';
+
+					if (api_is_allowed_to_edit()) {
+						echo '&nbsp;&nbsp;<a href="'.api_get_self().'?'.api_get_cidreq().'&action=delete&id_attach='.$attachment_list['id'].'" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)).'\')) return false;">'.Display::return_icon('delete.gif',get_lang('Delete')).'</a><br />';
+					}
 				}
-				
-			}					
-	    		
-																	
+
+
 				echo "</td>\n</tr>\n";
 
 				$iterator ++;
-			} // is_allowed_to_edit
+			} else { // end of is_allowed_to_edit
+				//students view
+				// show attachment list
+				$attachment_list = array();
+				$attachment_list = get_attachment($myrow['id']);
+
+				if (count($attachment_list)>0) {
+					$realname=$attachment_list['path'];
+					$user_filename=$attachment_list['filename'];
+					$full_file_name = 'download.php?file='.$realname;
+					echo '<br/>';
+					echo '<br/>';
+					echo Display::return_icon('attachment.gif',get_lang('Attachment'));
+					echo '<a href="'.$full_file_name.'';
+					echo ' "> '.$user_filename.' </a>';
+					echo '<span class="forum_attach_comment" >'.$attachment_list['comment'].'</span>';
+				}
+			}
 
 			echo "<tr><td width=\"100%\" colspan=\"3\"><a href=\"#top\">".Display::return_icon('top.gif', get_lang('Top'))."</a></td></tr>";
 

+ 2 - 3
main/announcements/download.php

@@ -68,7 +68,7 @@ if (is_dir($full_file_name))
 {
 	//remove last slash if present
 	//$doc_url = ($doc_url{strlen($doc_url)-1}=='/')?substr($doc_url,0,strlen($doc_url)-1):$doc_url;
-	//mod_rewrite can change /some/path/ to /some/path// in some cases, so clean them all off (Ren)
+	//mod_rewrite can change /some/path/ to /some/path// in some cases, so clean them all off (René)
 	while ($doc_url{$dul = strlen($doc_url)-1}=='/') $doc_url = substr($doc_url,0,$dul);
 	//create the path
 	$document_explorer = api_get_path(WEB_COURSE_PATH).api_get_course_path(); // home course path
@@ -84,10 +84,9 @@ event_download($doc_url);
 $sql='SELECT filename FROM '.$tbl_announcement_attachment.'
   	  WHERE path LIKE BINARY "'.$doc_url.'"';
 
-$result= Database::query($sql, __FILE__, __LINE__);
+$result= Database::query($sql);
 $row= Database::fetch_array($result);
 $title = str_replace(' ','_', $row['filename']);
 DocumentManager::file_send_for_download($full_file_name,TRUE, $title);
-
 exit;
 ?>

이 변경점에서 너무 많은 파일들이 변경되어 몇몇 파일들은 표시되지 않았습니다.