Julio Montoya 14 years ago
parent
commit
89c6cfef88
53 changed files with 2814 additions and 1226 deletions
  1. 3 1
      documentation/changelog.html
  2. 92 97
      index.php
  3. 213 225
      main/admin/course_list.php
  4. 92 30
      main/admin/course_request_accepted.php
  5. 116 43
      main/admin/course_request_rejected.php
  6. 147 83
      main/admin/course_request_review.php
  7. 1 1
      main/create_course/add_course.php
  8. 25 10
      main/document/create_drawing.php
  9. 3 16
      main/document/document.inc.php
  10. 15 13
      main/document/document.php
  11. 30 10
      main/document/edit_drawing.php
  12. 1 1
      main/document/upload.php
  13. BIN
      main/img/draw.png
  14. BIN
      main/img/draw_new.png
  15. BIN
      main/img/new.png
  16. BIN
      main/img/request_info.gif
  17. 1051 0
      main/inc/lib/browser/Browser.php
  18. 215 10
      main/inc/lib/course_request.lib.php
  19. 6 1
      main/inc/lib/diagnoser.lib.php
  20. 2 0
      main/inc/lib/document.lib.php
  21. 1 1
      main/inc/lib/fileDisplay.lib.php
  22. 176 190
      main/inc/lib/mail.lib.inc.php
  23. 41 1
      main/inc/lib/main_api.lib.php
  24. 2 1
      main/inc/lib/svg-edit/extensions/ext-imagelib.js
  25. 13 30
      main/inc/lib/svg-edit/extensions/fileopen.php
  26. 27 36
      main/inc/lib/svg-edit/extensions/filesave.php
  27. BIN
      main/inc/lib/svg-edit/images/mascot.png
  28. 2 2
      main/inc/lib/svg-edit/svg-editor.js
  29. 9 4
      main/inc/lib/svg-edit/svg-editor.php
  30. 1 0
      main/install/install.lib.php
  31. 1 1
      main/install/migrate-db-1.8.7-1.8.8-pre.sql
  32. 2 0
      main/lang/bulgarian/admin.inc.php
  33. 28 2
      main/lang/bulgarian/create_course.inc.php
  34. 3 0
      main/lang/english/admin.inc.php
  35. 29 3
      main/lang/english/create_course.inc.php
  36. 1 0
      main/lang/english/trad4all.inc.php
  37. 5 0
      main/lang/galician/admin.inc.php
  38. 1 0
      main/lang/galician/courses.inc.php
  39. 10 0
      main/lang/galician/create_course.inc.php
  40. 2 0
      main/lang/galician/tracking.inc.php
  41. 16 0
      main/lang/galician/trad4all.inc.php
  42. 1 0
      main/lang/galician/userInfo.inc.php
  43. 3 0
      main/lang/italian/admin.inc.php
  44. 6 0
      main/lang/italian/create_course.inc.php
  45. 3 3
      main/lang/italian/exercice.inc.php
  46. 5 0
      main/lang/italian/trad4all.inc.php
  47. 6 5
      main/lang/spanish/admin.inc.php
  48. 6 2
      main/lang/spanish/create_course.inc.php
  49. 1 1
      main/lang/spanish/registration.inc.php
  50. 2 0
      main/lang/spanish/trad4all.inc.php
  51. 5 1
      main/newscorm/resourcelinker.inc.php
  52. 172 172
      main/user/user_add.php
  53. 222 230
      user_portal.php

+ 3 - 1
documentation/changelog.html

@@ -27,9 +27,11 @@
    <li>Now showing teachers results in exercises results list (was confusing for most teachers)</li>
    <li>Update Google Maps plugin to 1.98 (Feature #1925)</li>
    <li>Add a personal portfolio to Social Network (Feature #1853)</li>
-   <li>Students can copy some files from several courses in his personal portfolio (Feature #1853)</li>
+   <li>Students can copy some files from several courses in his personal portfolio</li>
    <li>Students can create a document into a course inside his shared folder (Feature #2076)</li>
    <li>Learning Path: New LP exercises reports added for teachers and admins (Feature BT#1634)</li>
+   <li><span id="result_box" lang="en" xml:lang="en"><span title="">New tool to create, edit and import vectorial images, and export to png images</span></span> (Feature # 2044)</li>
+   <li>The documents tool and the learn path tool can display vectorial images</li>
 </ul>
 <h3>Debugging</h3>
 <ul>

+ 92 - 97
index.php

@@ -2,11 +2,10 @@
 /* For licensing terms, see /license.txt */
 
 /**
- *	@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
+ * @package chamilo.main
+ * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University, Refactoring
+ * @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
@@ -16,13 +15,13 @@ define('DOKEOS_HOMEPAGE', true);
 
 $language_file = array('courses', 'index');
 
-/* Flag forcing the 'current course' reset, as we're not inside a course anymore */
+/* 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();
 $cidReset = true;
 
-/* 	Included libraries */
+/* Included libraries */
 
-/** @todo make all the library files consistent, use filename.lib.php and not filename.lib.inc.php */
+/** @todo Make all the library files consistent, use filename.lib.php and not filename.lib.inc.php. */
 require_once 'main/inc/global.inc.php';
 
 require_once api_get_path(LIBRARY_PATH).'course.lib.php';
@@ -35,16 +34,16 @@ require_once 'main/chat/chat_functions.lib.php';
 $loginFailed = isset($_GET['loginFailed']) ? true : isset($loginFailed);
 $setting_show_also_closed_courses = api_get_setting('show_closed_courses') == 'true';
 
-// the section (for the tabs)
+// The section (for the tabs).
 $this_section = SECTION_CAMPUS;
 unset($_SESSION['this_section']);//for hmtl editor repository
 
-/*	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
- * 			this can be usefull when you are on an open course and you need to log in to edit something and you immediately want to check how anonymous users
- * 			will see it.
+/** @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
+ *          this can be usefull when you are on an open course and you need to log in to edit something and you immediately want to check how anonymous users
+ *          will see it.
  */
 $my_user_id = api_get_user_id();
 
@@ -52,26 +51,27 @@ if (!empty($_GET['logout'])) {
     logout();
 }
 
-/* 	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);
+/* 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 */
-/** @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 */
+/* Constants and CONFIGURATION parameters */
+/** @todo these configuration settings should move to the Chamilo config settings. */
+
+/** Defines wether or not anonymous visitors can see a list of the courses on the Chamilo homepage that are open to the world. */
 $_setting['display_courses_to_anonymous_users'] = 'true';
 
-/** @todo remove this piece of code because this is not used */
+/** @todo Remove this piece of code because this is not used. */
 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.
- * @todo consider removing this piece of code because does nothing.
+ * @todo Consider removing this piece of code because does nothing.
  */
 if (isset($_GET['submitAuth']) && $_GET['submitAuth'] == 1) {
     // nice lie!!!
@@ -88,13 +88,13 @@ if (api_get_setting('allow_terms_conditions') == 'true') {
 
 /**
  * @todo This piece of code should probably move to local.inc.php where the actual login procedure is handled.
- * @todo check if this code is used. I think this code is never executed because after clicking the submit button
- * 		 the code does the stuff in local.inc.php and then redirects to index.php or user_portal.php depending
- * 		 on api_get_setting('page_after_login')
+ * @todo Check if this code is used. I think this code is never executed because after clicking the submit button
+ *       the code does the stuff in local.inc.php and then redirects to index.php or user_portal.php depending
+ *       on api_get_setting('page_after_login').
  */
 
 if (!empty($_POST['submitAuth'])) {
-    // the user is already authenticated, we now find the last login of the user.
+    // The user has been already authenticated, we are now to find the last login of the user.
     if (isset ($_user['user_id'])) {
         $sql_last_login = "SELECT UNIX_TIMESTAMP(login_date)
                                 FROM $track_login_table
@@ -118,13 +118,13 @@ if (!empty($_POST['submitAuth'])) {
         }
     }
 
-} // end login -- if ($_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.
+    // Only if login form was not sent because if the form is sent the user was already on the page.
     event_open();
 }
 
-// the header
+// The header.
 $header_title = get_lang('Homepage');
 $sitename = api_get_setting('siteName');
 if (!empty($sitename)) {
@@ -132,13 +132,11 @@ if (!empty($sitename)) {
 }
 Display::display_header($header_title);
 
-/*
-    MAIN CODE
-*/
+/* MAIN CODE */
 
 echo '<div class="maincontent" id="content">';
 
-// Plugins for loginpage_main AND campushomepage_main
+// Plugins for loginpage_main AND campushomepage_main.
 if (!api_get_user_id()) {
     api_plugin('loginpage_main');
 } else {
@@ -191,7 +189,7 @@ if (!empty($_GET['include']) && preg_match('/^[a-zA-Z0-9_-]*\.html$/', $_GET['in
             $home_top_temp = file_get_contents($home.'home_top.html');
         }
     }
-    if(trim($home_top_temp)=='') {
+    if (trim($home_top_temp) == '') {
         $home_top_temp = get_lang('PortalHomepageDefaultIntroduction');
     }
     $open = str_replace('{rel_path}', api_get_path(REL_PATH), $home_top_temp);
@@ -199,20 +197,20 @@ if (!empty($_GET['include']) && preg_match('/^[a-zA-Z0-9_-]*\.html$/', $_GET['in
     echo $open;
 }
 
-// Display courses and category list
+// Display courses and category list.
 if (!$page_included) {
-    
+
     // Display System announcements
     $announcement = isset($_GET['announcement']) ? $_GET['announcement'] : -1;
     $announcement = intval($announcement);
-    
+
     if (isset($_user['user_id'])) {
         $visibility = api_is_allowed_to_create_course() ? VISIBLE_TEACHER : VISIBLE_STUDENT;
         SystemAnnouncementManager :: display_announcements($visibility, $announcement);
     } else {
         SystemAnnouncementManager :: display_announcements(VISIBLE_GUEST, $announcement);
     }
-    
+
     if (api_get_setting('display_categories_on_homepage') == 'true') {
         echo '<div class="home_cats">';
         display_anonymous_course_list();
@@ -221,15 +219,16 @@ 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 */
+/* Functions */
 
 /**
  * This function handles the logout and is called whenever there is a $_GET['logout']
@@ -238,17 +237,17 @@ Display :: display_footer();
  */
 function logout() {
     global $_configuration, $extAuthSource;
-    // variable initialisation
+    // Variable initialisation.
     $query_string = '';
 
     if (!empty($_SESSION['user_language_choice'])) {
         $query_string = '?language='.$_SESSION['user_language_choice'];
     }
 
-    // Database table definition
+    // Database table definition.
     $tbl_track_login = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_LOGIN);
 
-    // selecting the last login of the user
+    // 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);
@@ -261,13 +260,13 @@ function logout() {
         $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);
     }
-    LoginDelete($uid, $_configuration['statistics_database']); //from inc/lib/online.inc.php - removes the "online" status
+    LoginDelete($uid, $_configuration['statistics_database']); // From inc/lib/online.inc.php - removes the "online" status.
 
-    //the following code enables the use of an external logout function.
-    //example: define a $extAuthSource['ldap']['logout']="file.php" in configuration.php
-    // then a function called ldap_logout() inside that file
+    // The following code enables the use of an external logout function.
+    // Example: define a $extAuthSource['ldap']['logout'] = 'file.php' in configuration.php.
+    // Then a function called ldap_logout() inside that file
     // (using *authent_name*_logout as the function name) and the following code
-    // will find and execute it
+    // will find and execute it.
     $uinfo = api_get_user_info($uid);
     if (($uinfo['auth_source'] != PLATFORM_AUTH_SOURCE) && is_array($extAuthSource)) {
         if (is_array($extAuthSource[$uinfo['auth_source']])) {
@@ -309,7 +308,7 @@ function category_has_open_courses($category) {
             }
         } else {
             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
+                return true; // At least one course (it does not matter weither it's open or not because $setting_show_also_closed_courses = true).
             }
         }
     }
@@ -351,7 +350,7 @@ function display_anonymous_right_menu() {
     $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();
@@ -377,8 +376,7 @@ function display_anonymous_right_menu() {
         }
     }
 
-
-    // My Account section
+    // My Account section.
     if (isset($_SESSION['_user']['user_id']) && $_SESSION['_user']['user_id'] != 0) {
         // tabs that are deactivated are added here
 
@@ -421,7 +419,7 @@ function display_anonymous_right_menu() {
             echo '</ul></div>';
         }
 
-        // Deleting the myprofile link
+        // Deleting the myprofile link.
         if (api_get_setting('allow_social_tool') == 'true') {
             unset($menu_navigation['myprofile']);
         }
@@ -438,8 +436,8 @@ function display_anonymous_right_menu() {
         }
     }
 
-    // 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;
@@ -471,7 +469,7 @@ function display_anonymous_right_menu() {
         echo '</div>';
     }
 
-    // includes for any files to be displayed below anonymous right menu
+    // Includes for any files to be displayed below anonymous right menu.
 
     $home_notice = @(string)file_get_contents($sys_path.$home.'home_notice_'.$user_selected_language.'.html');
     if (empty($home_notice)) {
@@ -486,11 +484,11 @@ function display_anonymous_right_menu() {
 }
 
 /**
-*	Reacts on a failed login:
-*	Displays an explanation with a link to the registration form.
-*
-*	@version 1.0.1
-*/
+ * Reacts on a failed login:
+ * 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');
@@ -523,9 +521,9 @@ function handle_login_failed() {
 }
 
 /**
-*	Adds a form to let users login
-*	@version 1.1
-*/
+ * Adds a form to let users login
+ * @version 1.1
+ */
 function display_login_form() {
     $form = new FormValidator('formLogin');
     $form->addElement('text', 'login', get_lang('UserName'), array('size' => 17));
@@ -558,24 +556,24 @@ function display_anonymous_course_list() {
     $ctok = $_SESSION['sec_token'];
     $stok = Security::get_token();
 
-    //init
+    // Initialization.
     $user_identified = (api_get_user_id() > 0 && !api_is_anonymous());
     $web_course_path = api_get_path(WEB_COURSE_PATH);
     $category = Database::escape_string($_GET['category']);
     global $setting_show_also_closed_courses;
 
-    // Database table definitions
-    $main_course_table 		= Database :: get_main_table(TABLE_MAIN_COURSE);
-    $main_category_table 	= Database :: get_main_table(TABLE_MAIN_CATEGORY);
+    // Database table definitions.
+    $main_course_table      = Database :: get_main_table(TABLE_MAIN_COURSE);
+    $main_category_table    = Database :: get_main_table(TABLE_MAIN_CATEGORY);
 
     $platformLanguage = api_get_setting('platformLanguage');
 
-    //get list of courses in category $category
+    // 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'])."'
                                 ORDER BY title, UPPER(visual_code)";
 
-    //showing only the courses of the current access_url_id
+    // Showing only the courses of the current access_url_id.
     global $_configuration;
     if ($_configuration['multiple_access_urls']) {
         $url_access_id = api_get_current_access_url_id();
@@ -596,7 +594,7 @@ function display_anonymous_course_list() {
 
     $platform_visible_courses = '';
     // $setting_show_also_closed_courses
-    if($user_identified) {
+    if ($user_identified) {
         if ($setting_show_also_closed_courses) {
             $platform_visible_courses = '';
         } else {
@@ -618,7 +616,7 @@ 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']) {
         $url_access_id = api_get_current_access_url_id();
@@ -645,7 +643,7 @@ function display_anonymous_course_list() {
 
                 $category_has_open_courses = category_has_open_courses($catLine['code']);
                 if ($category_has_open_courses) {
-                    // The category contains courses accessible to anonymous visitors
+                    // 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') {
@@ -654,21 +652,19 @@ function display_anonymous_course_list() {
                     $htmlListCat .= "</li>\n";
                     $thereIsSubCat = true;
                 } elseif ($catLine['children_count'] > 0) {
-                    // The category has children, subcategories
+                    // The category has children, subcategories.
                     $htmlListCat .= '<li>';
                     $htmlListCat .= '<a href="'.api_get_self().'?category='.$catLine['code'].'">'.$catLine['name'].'</a>';
                     $htmlListCat .= "</li>\n";
                     $thereIsSubCat = true;
                 }
-                /************************************************************************
-                 end changed code to eliminate the (0 courses) after empty categories
-                 ************************************************************************/
+                /* End changed code to eliminate the (0 courses) after empty categories. */
                 elseif (api_get_setting('show_empty_course_categories') == 'true') {
                     $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 don't set thereIsSubCat to true to avoid printing things if not requested.
             } else {
                 $htmlTitre = '<p>';
                 if (api_get_setting('show_back_link_on_top_of_tree') == 'true') {
@@ -709,11 +705,10 @@ function display_anonymous_course_list() {
 
         foreach ($course_list as $course) {
             // $setting_show_also_closed_courses
-
             if (!$setting_show_also_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
+                // 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";
@@ -734,12 +729,12 @@ function display_anonymous_course_list() {
                 }
             }
             // 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
-            // 4. the user is logged in and the user is course admin of te course (regardless of the course visibility setting)
-            // 5. the user is the platform admin api_is_platform_admin()
+            // 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;
+            // 4. the user is logged in and the user is course admin of te course (regardless of the course visibility setting);
+            // 5. the user is the platform admin api_is_platform_admin().
             //
             else {
                 $courses_shown++;
@@ -774,9 +769,9 @@ function display_anonymous_course_list() {
                 if (api_get_setting('show_different_course_language') == 'true' && $course['course_language'] != api_get_setting('platformLanguage')) {
                     $courses_list_string .= ' - '.$course['course_language'];
                 }
-                // We display a subscription link if
+                // We display a subscription link if:
                 // 1. it is allowed to register for the course and if the course is not already in the courselist of the user and if the user is identiefied
-                // 2
+                // 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='.Security::remove_XSS($_GET['category']).'" method="post">';
@@ -792,10 +787,10 @@ 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)
+    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 != '') {
@@ -810,8 +805,8 @@ function display_anonymous_course_list() {
  * @return array an array containing all the information of the courses of the given user
 */
 function get_courses_of_user($user_id) {
-    $table_course		= Database::get_main_table(TABLE_MAIN_COURSE);
-    $table_course_user	= Database::get_main_table(TABLE_MAIN_COURSE_USER);
+    $table_course       = Database::get_main_table(TABLE_MAIN_COURSE);
+    $table_course_user  = Database::get_main_table(TABLE_MAIN_COURSE_USER);
     // Secondly we select the courses that are in a category (user_course_cat <> 0) and sort these according to the sort of the category
     $user_id = intval($user_id);
     $sql_select_courses = "SELECT course.code k, course.visual_code  vc, course.subscribe subscr, course.unsubscribe unsubscr,
@@ -826,7 +821,7 @@ function get_courses_of_user($user_id) {
     $result = Database::query($sql_select_courses);
     $courses = array();
     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;

+ 213 - 225
main/admin/course_list.php

@@ -1,14 +1,16 @@
-<?php // $Id: course_list.php 21855 2009-07-07 18:26:10Z juliomontoya $
+<?php
 /* For licensing terms, see /license.txt */
+
 /**
  * This script shows a list of courses and allows searching for courses codes
  * and names
  * @package chamilo.admin
  */
+
 /*	INIT SECTION	*/
 
-// name of the language file that needs to be included
-$language_file = array('admin','courses');
+// Language files that need to be included.
+$language_file = array('admin', 'courses');
 $cidReset = true;
 require_once '../inc/global.inc.php';
 $this_section = SECTION_PLATFORM_ADMIN;
@@ -19,204 +21,191 @@ 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() {
-	$course_table = Database :: get_main_table(TABLE_MAIN_COURSE);
-	$sql = "SELECT COUNT(code) AS total_number_of_items FROM $course_table";
+    $course_table = Database :: get_main_table(TABLE_MAIN_COURSE);
+    $sql = "SELECT COUNT(code) AS total_number_of_items FROM $course_table";
 
-	global $_configuration;
-    if ((api_is_platform_admin() || api_is_session_admin()) && $_configuration['multiple_access_urls'] && api_get_current_access_url_id()!=-1) {
-    	$access_url_rel_course_table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
-    	$sql.= " INNER JOIN $access_url_rel_course_table url_rel_course ON (code=url_rel_course.course_code)";
+    global $_configuration;
+    if ((api_is_platform_admin() || api_is_session_admin()) && $_configuration['multiple_access_urls'] && api_get_current_access_url_id() != -1) {
+        $access_url_rel_course_table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
+        $sql.= " INNER JOIN $access_url_rel_course_table url_rel_course ON (code=url_rel_course.course_code)";
     }
 
-	if (isset ($_GET['keyword']))
-	{
-		$keyword = Database::escape_string($_GET['keyword']);
-		$sql .= " WHERE (title LIKE '%".$keyword."%' OR code LIKE '%".$keyword."%' OR visual_code LIKE '%".$keyword."%')";
-	}
-	elseif (isset ($_GET['keyword_code']))
-	{
-		$keyword_code = Database::escape_string($_GET['keyword_code']);
-		$keyword_title = Database::escape_string($_GET['keyword_title']);
-		$keyword_category = Database::escape_string($_GET['keyword_category']);
-		$keyword_language = Database::escape_string($_GET['keyword_language']);
-		$keyword_visibility = Database::escape_string($_GET['keyword_visibility']);
-		$keyword_subscribe = Database::escape_string($_GET['keyword_subscribe']);
-		$keyword_unsubscribe = Database::escape_string($_GET['keyword_unsubscribe']);
-		$sql .= " WHERE (code LIKE '%".$keyword_code."%' OR visual_code LIKE '%".$keyword_code."%') AND title LIKE '%".$keyword_title."%' AND category_code LIKE '%".$keyword_category."%'  AND course_language LIKE '%".$keyword_language."%'   AND visibility LIKE '%".$keyword_visibility."%'    AND subscribe LIKE '".$keyword_subscribe."'AND unsubscribe LIKE '".$keyword_unsubscribe."'";
-	}
+    if (isset ($_GET['keyword'])) {
+        $keyword = Database::escape_string($_GET['keyword']);
+        $sql .= " WHERE (title LIKE '%".$keyword."%' OR code LIKE '%".$keyword."%' OR visual_code LIKE '%".$keyword."%')";
+    }
+    elseif (isset ($_GET['keyword_code'])) {
+        $keyword_code = Database::escape_string($_GET['keyword_code']);
+        $keyword_title = Database::escape_string($_GET['keyword_title']);
+        $keyword_category = Database::escape_string($_GET['keyword_category']);
+        $keyword_language = Database::escape_string($_GET['keyword_language']);
+        $keyword_visibility = Database::escape_string($_GET['keyword_visibility']);
+        $keyword_subscribe = Database::escape_string($_GET['keyword_subscribe']);
+        $keyword_unsubscribe = Database::escape_string($_GET['keyword_unsubscribe']);
+        $sql .= " WHERE (code LIKE '%".$keyword_code."%' OR visual_code LIKE '%".$keyword_code."%') AND title LIKE '%".$keyword_title."%' AND category_code LIKE '%".$keyword_category."%'  AND course_language LIKE '%".$keyword_language."%'   AND visibility LIKE '%".$keyword_visibility."%'    AND subscribe LIKE '".$keyword_subscribe."'AND unsubscribe LIKE '".$keyword_unsubscribe."'";
+    }
 
-	 // 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'] && api_get_current_access_url_id()!=-1) {
-    		$sql.= " AND url_rel_course.access_url_id=".api_get_current_access_url_id();
+     // 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'] && api_get_current_access_url_id() != -1) {
+        $sql.= " AND url_rel_course.access_url_id=".api_get_current_access_url_id();
     }
 
-	$res = Database::query($sql);
-	$obj = Database::fetch_object($res);
-	return $obj->total_number_of_items;
+    $res = Database::query($sql);
+    $obj = Database::fetch_object($res);
+    return $obj->total_number_of_items;
 }
+
 /**
  * Get course data to display
  */
-function get_course_data($from, $number_of_items, $column, $direction)
-{
-	$course_table = Database :: get_main_table(TABLE_MAIN_COURSE);
-	$users_table = Database :: get_main_table(TABLE_MAIN_USER);
-	$course_users_table = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
-	$sql = "SELECT code AS col0, visual_code AS col1, title AS col2, course_language AS col3, category_code AS col4, subscribe AS col5, unsubscribe AS col6, tutor_name as col7, code AS col8, visibility AS col9,directory as col10 FROM $course_table";
-	//$sql = "SELECT code AS col0, visual_code AS col1, title AS col2, course_language AS col3, category_code AS col4, subscribe AS col5, unsubscribe AS col6, code AS col7, tutor_name as col8, code AS col9, visibility AS col10,directory as col11 FROM $course_table";
-	global $_configuration;
-    if ((api_is_platform_admin() || api_is_session_admin()) && $_configuration['multiple_access_urls'] && api_get_current_access_url_id()!=-1) {
-    	$access_url_rel_course_table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
-    	$sql.= " INNER JOIN $access_url_rel_course_table url_rel_course ON (code=url_rel_course.course_code)";
+function get_course_data($from, $number_of_items, $column, $direction) {
+    $course_table = Database :: get_main_table(TABLE_MAIN_COURSE);
+    $users_table = Database :: get_main_table(TABLE_MAIN_USER);
+    $course_users_table = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
+    $sql = "SELECT code AS col0, visual_code AS col1, title AS col2, course_language AS col3, category_code AS col4, subscribe AS col5, unsubscribe AS col6, tutor_name as col7, code AS col8, visibility AS col9,directory as col10 FROM $course_table";
+    //$sql = "SELECT code AS col0, visual_code AS col1, title AS col2, course_language AS col3, category_code AS col4, subscribe AS col5, unsubscribe AS col6, code AS col7, tutor_name as col8, code AS col9, visibility AS col10,directory as col11 FROM $course_table";
+    global $_configuration;
+    if ((api_is_platform_admin() || api_is_session_admin()) && $_configuration['multiple_access_urls'] && api_get_current_access_url_id() != -1) {
+        $access_url_rel_course_table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
+        $sql.= " INNER JOIN $access_url_rel_course_table url_rel_course ON (code=url_rel_course.course_code)";
     }
 
-	if (isset ($_GET['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']))
-	{
-		$keyword_code = Database::escape_string($_GET['keyword_code']);
-		$keyword_title = Database::escape_string($_GET['keyword_title']);
-		$keyword_category = Database::escape_string($_GET['keyword_category']);
-		$keyword_language = Database::escape_string($_GET['keyword_language']);
-		$keyword_visibility = Database::escape_string($_GET['keyword_visibility']);
-		$keyword_subscribe = Database::escape_string($_GET['keyword_subscribe']);
-		$keyword_unsubscribe = Database::escape_string($_GET['keyword_unsubscribe']);
-		$sql .= " WHERE (code LIKE '%".$keyword_code."%' OR visual_code LIKE '%".$keyword_code."%') AND title LIKE '%".$keyword_title."%' AND category_code LIKE '%".$keyword_category."%'  AND course_language LIKE '%".$keyword_language."%'   AND visibility LIKE '%".$keyword_visibility."%'    AND subscribe LIKE '".$keyword_subscribe."'AND unsubscribe LIKE '".$keyword_unsubscribe."'";
-	}
+    if (isset ($_GET['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'])) {
+        $keyword_code = Database::escape_string($_GET['keyword_code']);
+        $keyword_title = Database::escape_string($_GET['keyword_title']);
+        $keyword_category = Database::escape_string($_GET['keyword_category']);
+        $keyword_language = Database::escape_string($_GET['keyword_language']);
+        $keyword_visibility = Database::escape_string($_GET['keyword_visibility']);
+        $keyword_subscribe = Database::escape_string($_GET['keyword_subscribe']);
+        $keyword_unsubscribe = Database::escape_string($_GET['keyword_unsubscribe']);
+        $sql .= " WHERE (code LIKE '%".$keyword_code."%' OR visual_code LIKE '%".$keyword_code."%') AND title LIKE '%".$keyword_title."%' AND category_code LIKE '%".$keyword_category."%'  AND course_language LIKE '%".$keyword_language."%'   AND visibility LIKE '%".$keyword_visibility."%'    AND subscribe LIKE '".$keyword_subscribe."'AND unsubscribe LIKE '".$keyword_unsubscribe."'";
+    }
 
-	 // 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'] && api_get_current_access_url_id()!=-1) {
-    		$sql.= " AND url_rel_course.access_url_id=".api_get_current_access_url_id();
+    // 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'] && api_get_current_access_url_id() != -1) {
+        $sql.= " AND url_rel_course.access_url_id=".api_get_current_access_url_id();
     }
 
-	$sql .= " ORDER BY col$column $direction ";
-	$sql .= " LIMIT $from,$number_of_items";
-	$res = Database::query($sql);
-	$courses = array ();
-	while ($course = Database::fetch_row($res))
-	{
-		//place colour icons in front of courses
-		//$course[1] = '<nobr>'.get_course_visibility_icon($course[9]).'<a href="'.api_get_path(WEB_COURSE_PATH).$course[9].'/index.php">'.$course[1].'</a></nobr>';
-		$course[1] = '<nobr>'.get_course_visibility_icon($course[9]).'<a href="'.api_get_path(WEB_COURSE_PATH).$course[8].'/index.php">'.$course[1].'</a></nobr>';
-		$course[5] = $course[5] == SUBSCRIBE_ALLOWED ? get_lang('Yes') : get_lang('No');
-		$course[6] = $course[6] == UNSUBSCRIBE_ALLOWED ? get_lang('Yes') : get_lang('No');
-		//$course[7] = CourseManager :: is_virtual_course_from_system_code($course[7]) ? get_lang('Yes') : get_lang('No');
-		//$course_rem = array($course[0],$course[1],$course[2],$course[3],$course[4],$course[5],$course[6],$course[7],$course[8],$course[9]);
-		$course_rem = array($course[0],$course[1],$course[2],$course[3],$course[4],$course[5],$course[6],$course[7],$course[8]);
-		$courses[] = $course_rem;
-	}
-	return $courses;
+    $sql .= " ORDER BY col$column $direction ";
+    $sql .= " LIMIT $from,$number_of_items";
+    $res = Database::query($sql);
+    $courses = array ();
+    while ($course = Database::fetch_row($res)) {
+        // Place colour icons in front of courses.
+        //$course[1] = '<nobr>'.get_course_visibility_icon($course[9]).'<a href="'.api_get_path(WEB_COURSE_PATH).$course[9].'/index.php">'.$course[1].'</a></nobr>';
+        $course[1] = '<nobr>'.get_course_visibility_icon($course[9]).'<a href="'.api_get_path(WEB_COURSE_PATH).$course[8].'/index.php">'.$course[1].'</a></nobr>';
+        $course[5] = $course[5] == SUBSCRIBE_ALLOWED ? get_lang('Yes') : get_lang('No');
+        $course[6] = $course[6] == UNSUBSCRIBE_ALLOWED ? get_lang('Yes') : get_lang('No');
+        //$course[7] = CourseManager :: is_virtual_course_from_system_code($course[7]) ? get_lang('Yes') : get_lang('No');
+        //$course_rem = array($course[0], $course[1], $course[2], $course[3], $course[4], $course[5], $course[6], $course[7], $course[8], $course[9]);
+        $course_rem = array($course[0], $course[1], $course[2], $course[3], $course[4], $course[5], $course[6], $course[7], $course[8]);
+        $courses[] = $course_rem;
+    }
+    return $courses;
 }
+
 /**
  * Filter to display the edit-buttons
  */
-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;'.
-		//'<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;';
-
+function modify_filter($code) {
+        return
+        '<a href="course_information.php?code='.$code.'">'.Display::return_icon('synthese_view.gif', get_lang('Info')).'</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))."'".')) 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
  */
-function get_course_visibility_icon($v)
-{
-	$path = api_get_path(REL_CODE_PATH);
-	$style = 'margin-bottom:-5px;margin-right:5px;';
-	switch($v)
-	{
-		case 0:
-			return Display::return_icon('bullet_red.gif', get_lang('CourseVisibilityClosed'), array('style'=>$style));
-			break;
-		case 1:
-			return Display::return_icon('bullet_orange.gif', get_lang('Private'), array('style'=>$style));
-			break;
-		case 2:
-			return Display::return_icon('bullet_green.gif', get_lang('OpenToThePlatform'), array('style'=>$style));
-			break;
-		case 3:
-			return Display::return_icon('bullet_blue.gif', get_lang('OpenToTheWorld'), array('style'=>$style));
-			break;
-		default:
-			return '';
-	}
+function get_course_visibility_icon($v) {
+    $path = api_get_path(REL_CODE_PATH);
+    $style = 'margin-bottom:-5px;margin-right:5px;';
+    switch($v) {
+        case 0:
+            return Display::return_icon('bullet_red.gif', get_lang('CourseVisibilityClosed'), array('style' => $style));
+            break;
+        case 1:
+            return Display::return_icon('bullet_orange.gif', get_lang('Private'), array('style' => $style));
+            break;
+        case 2:
+            return Display::return_icon('bullet_green.gif', get_lang('OpenToThePlatform'), array('style' => $style));
+            break;
+        case 3:
+            return Display::return_icon('bullet_blue.gif', get_lang('OpenToTheWorld'), array('style' => $style));
+            break;
+        default:
+            return '';
+    }
 }
 
-if (isset ($_POST['action']))
-{
-	switch ($_POST['action'])
-	{
-		// Delete selected courses
-		case 'delete_courses' :
-			$course_codes = $_POST['course'];
-			if (count($course_codes) > 0)
-			{
-				foreach ($course_codes as $index => $course_code)
-				{
-					CourseManager :: delete_course($course_code);
-					$obj_cat=new Category();
-					$obj_cat->update_category_delete($course_code);
-				}
-			}
-			break;
-	}
+if (isset ($_POST['action'])) {
+    switch ($_POST['action']) {
+        // Delete selected courses
+        case 'delete_courses' :
+            $course_codes = $_POST['course'];
+            if (count($course_codes) > 0) {
+                foreach ($course_codes as $index => $course_code) {
+                    CourseManager :: delete_course($course_code);
+                    $obj_cat=new Category();
+                    $obj_cat->update_category_delete($course_code);
+                }
+            }
+            break;
+    }
 }
 
 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'));
-	$interbreadcrumb[] = array ("url" => 'course_list.php', "name" => get_lang('CourseList'));
-	$tool_name = get_lang('SearchACourse');
-	Display :: display_header($tool_name);
-	//api_display_tool_title($tool_name);
-	$form = new FormValidator('advanced_course_search', 'get');
-	$form->addElement('header', '', $tool_name);
-	$form->add_textfield('keyword_code', get_lang('CourseCode'), false);
-	$form->add_textfield('keyword_title', get_lang('Title'), false);
-	$categories = array();
-	$categories_select = $form->addElement('select', 'keyword_category', get_lang('CourseFaculty'), $categories);
-	CourseManager::select_and_sort_categories($categories_select);
-	$el = & $form->addElement('select_language', 'keyword_language', get_lang('CourseLanguage'));
-	$el->addOption(get_lang('All'), '%');
-	$form->addElement('radio', 'keyword_visibility', get_lang("CourseAccess"), get_lang('OpenToTheWorld'), COURSE_VISIBILITY_OPEN_WORLD);
-	$form->addElement('radio', 'keyword_visibility', null, get_lang('OpenToThePlatform'), COURSE_VISIBILITY_OPEN_PLATFORM);
-	$form->addElement('radio', 'keyword_visibility', null, get_lang('Private'), COURSE_VISIBILITY_REGISTERED);
-	$form->addElement('radio', 'keyword_visibility', null, get_lang('CourseVisibilityClosed'), COURSE_VISIBILITY_CLOSED);
-	$form->addElement('radio', 'keyword_visibility', null, get_lang('All'), '%');
-	$form->addElement('radio', 'keyword_subscribe', get_lang('Subscription'), get_lang('Allowed'), 1);
-	$form->addElement('radio', 'keyword_subscribe', null, get_lang('Denied'), 0);
-	$form->addElement('radio', 'keyword_subscribe', null, get_lang('All'), '%');
-	$form->addElement('radio', 'keyword_unsubscribe', get_lang('Unsubscription'), get_lang('AllowedToUnsubscribe'), 1);
-	$form->addElement('radio', 'keyword_unsubscribe', null, get_lang('NotAllowedToUnsubscribe'), 0);
-	$form->addElement('radio', 'keyword_unsubscribe', null, get_lang('All'), '%');
-	$form->addElement('style_submit_button', 'submit', get_lang('SearchCourse'),'class="search"');
-	$defaults['keyword_language'] = '%';
-	$defaults['keyword_visibility'] = '%';
-	$defaults['keyword_subscribe'] = '%';
-	$defaults['keyword_unsubscribe'] = '%';
-	$form->setDefaults($defaults);
-	$form->display();
-}
-else
-{
-	$interbreadcrumb[] = array ("url" => 'index.php', "name" => get_lang('PlatformAdmin'));
-	$tool_name = get_lang('CourseList');
-	Display :: display_header($tool_name);
+    // Get all course categories
+    $table_course_category = Database :: get_main_table(TABLE_MAIN_CATEGORY);
+    $interbreadcrumb[] = array('url' => 'index.php', 'name' => get_lang('PlatformAdmin'));
+    $interbreadcrumb[] = array('url' => 'course_list.php', 'name' => get_lang('CourseList'));
+    $tool_name = get_lang('SearchACourse');
+    Display :: display_header($tool_name);
+    //api_display_tool_title($tool_name);
+    $form = new FormValidator('advanced_course_search', 'get');
+    $form->addElement('header', '', $tool_name);
+    $form->add_textfield('keyword_code', get_lang('CourseCode'), false);
+    $form->add_textfield('keyword_title', get_lang('Title'), false);
+    $categories = array();
+    $categories_select = $form->addElement('select', 'keyword_category', get_lang('CourseFaculty'), $categories);
+    CourseManager::select_and_sort_categories($categories_select);
+    $el = & $form->addElement('select_language', 'keyword_language', get_lang('CourseLanguage'));
+    $el->addOption(get_lang('All'), '%');
+    $form->addElement('radio', 'keyword_visibility', get_lang("CourseAccess"), get_lang('OpenToTheWorld'), COURSE_VISIBILITY_OPEN_WORLD);
+    $form->addElement('radio', 'keyword_visibility', null, get_lang('OpenToThePlatform'), COURSE_VISIBILITY_OPEN_PLATFORM);
+    $form->addElement('radio', 'keyword_visibility', null, get_lang('Private'), COURSE_VISIBILITY_REGISTERED);
+    $form->addElement('radio', 'keyword_visibility', null, get_lang('CourseVisibilityClosed'), COURSE_VISIBILITY_CLOSED);
+    $form->addElement('radio', 'keyword_visibility', null, get_lang('All'), '%');
+    $form->addElement('radio', 'keyword_subscribe', get_lang('Subscription'), get_lang('Allowed'), 1);
+    $form->addElement('radio', 'keyword_subscribe', null, get_lang('Denied'), 0);
+    $form->addElement('radio', 'keyword_subscribe', null, get_lang('All'), '%');
+    $form->addElement('radio', 'keyword_unsubscribe', get_lang('Unsubscription'), get_lang('AllowedToUnsubscribe'), 1);
+    $form->addElement('radio', 'keyword_unsubscribe', null, get_lang('NotAllowedToUnsubscribe'), 0);
+    $form->addElement('radio', 'keyword_unsubscribe', null, get_lang('All'), '%');
+    $form->addElement('style_submit_button', 'submit', get_lang('SearchCourse'),'class="search"');
+    $defaults['keyword_language'] = '%';
+    $defaults['keyword_visibility'] = '%';
+    $defaults['keyword_subscribe'] = '%';
+    $defaults['keyword_unsubscribe'] = '%';
+    $form->setDefaults($defaults);
+    $form->display();
+} else {
+    $interbreadcrumb[] = array ('url' => 'index.php', "name" => get_lang('PlatformAdmin'));
+    $tool_name = get_lang('CourseList');
+    Display :: display_header($tool_name);
     if (isset($_GET['action'])) {
         switch ($_GET['action']) {
             case 'show_msg':
@@ -224,73 +213,72 @@ else
                     Display::display_warning_message(urldecode($_GET['warn']));
                 }
                 if (!empty($_GET['msg'])) {
-                	Display::display_normal_message(urldecode($_GET['msg']));
+                    Display::display_normal_message(urldecode($_GET['msg']));
                 }
                 break;
             default:
                 break;
         }
     }
-	//api_display_tool_title($tool_name);
-	if (isset ($_GET['delete_course']))
-	{
-
-		CourseManager :: delete_course($_GET['delete_course']);
+    //api_display_tool_title($tool_name);
+    if (isset ($_GET['delete_course'])) {
 
-		$obj_cat=new Category();
-		$obj_cat->update_category_delete($_GET['delete_course']);
+        CourseManager :: delete_course($_GET['delete_course']);
+        $obj_cat = new Category();
+        $obj_cat->update_category_delete($_GET['delete_course']);
 
-	}
-	// Create a search-box
-	$form = new FormValidator('search_simple','get','','','width=200px',false);
-	$renderer =& $form->defaultRenderer();
-	$renderer->setElementTemplate('<span>{element}</span> ');
-	$form->addElement('text','keyword',get_lang('keyword'));
-	$form->addElement('style_submit_button', 'submit', get_lang('SearchCourse'),'class="search"');
-	$form->addElement('static','search_advanced_link',null,'<a href="course_list.php?search=advanced">'.get_lang('AdvancedSearch').'</a>');
-	echo '<div style="float:right;margin-top:5px;margin-right:5px;">
-			  <a href="'.api_get_path(WEB_CODE_PATH).'admin/course_add.php">'.Display::return_icon('course_add.gif',get_lang('AddCourse')).get_lang('AddCourse').'</a>
-		 </div>';
+    }
+    // Create a search-box
+    $form = new FormValidator('search_simple', 'get', '', '', 'width=200px', false);
+    $renderer =& $form->defaultRenderer();
+    $renderer->setElementTemplate('<span>{element}</span> ');
+    $form->addElement('text', 'keyword', get_lang('keyword'));
+    $form->addElement('style_submit_button', 'submit', get_lang('SearchCourse'), 'class="search"');
+    $form->addElement('static', 'search_advanced_link', null, '<a href="course_list.php?search=advanced">'.get_lang('AdvancedSearch').'</a>');
+    echo '<div style="float: right; margin-top: 5px; margin-right: 5px;">';
+    if (api_get_setting('course_validation') != 'true') {
+        echo '<a href="course_add.php">'.Display::return_icon('course_add.gif', get_lang('AddCourse')).get_lang('AddCourse').'</a>';
+    } else {
+        echo '<a href="course_request_review.php">'.Display::return_icon('course_request_pending.png', get_lang('ReviewCourseRequests')).'&nbsp;'.get_lang('ReviewCourseRequests').'</a>';
+    }
+    echo '</div>';
 
-	echo '<div class="actions">';
-		$form->display();
-	echo '</div>';
-	// Create a sortable table with the course data
-	$table = new SortableTable('courses', 'get_number_of_courses', 'get_course_data',2);
-	$parameters=array();
+    echo '<div class="actions">';
+        $form->display();
+    echo '</div>';
+    // Create a sortable table with the course data
+    $table = new SortableTable('courses', 'get_number_of_courses', 'get_course_data', 2);
+    $parameters=array();
 
-	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']);
-	}
+    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']);
+    }
 
-	$table->set_additional_parameters($parameters);
+    $table->set_additional_parameters($parameters);
 
-	$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'), true, 'width="70px"');
-	$table->set_header(4, get_lang('Category'));
-	$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="145px"');
-	$table->set_column_filter(8,'modify_filter');
-	$table->set_form_actions(array ('delete_courses' => get_lang('DeleteCourse')),'course');
-	$table->display();
+    $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'), true, 'width="70px"');
+    $table->set_header(4, get_lang('Category'));
+    $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="145px"');
+    $table->set_column_filter(8, 'modify_filter');
+    $table->set_form_actions(array('delete_courses' => get_lang('DeleteCourse')), 'course');
+    $table->display();
 }
-/*
-==============================================================================
-		FOOTER
-==============================================================================
-*/
+
+/* FOOTER */
+
 Display :: display_footer();
-?>

+ 92 - 30
main/admin/course_request_accepted.php

@@ -37,36 +37,88 @@ require api_get_path(CONFIGURATION_PATH).'add_course.conf.php';
 // Include additional libraries
 require_once api_get_path(LIBRARY_PATH).'fileManage.lib.php';
 
+// A check whether the course validation feature is enabled.
+$course_validation_feature = api_get_setting('course_validation') == 'true';
+
+// Filltering passed to this page parameters.
+$delete_course_request = intval($_GET['delete_course_request']);
+$message = trim(Security::remove_XSS(stripslashes(urldecode($_GET['message']))));
+$is_error_message = !empty($_GET['is_error_message']);
+
+if ($course_validation_feature) {
+
+    /**
+     * Deletion of a course request.
+     */
+    if (!empty($delete_course_request)) {
+        $course_request_code = CourseRequestManager::get_course_request_code($delete_course_request);
+        $result = CourseRequestManager::delete_course_request($delete_course_request);
+        if ($result) {
+            $message = sprintf(get_lang('CourseRequestDeleted'), $course_request_code);
+            $is_error_message = false;
+        } else {
+            $message = sprintf(get_lang('CourseRequestDeletionFailed'), $course_request_code);
+            $is_error_message = true;
+        }
+    }
+
+    /**
+     * Form actions: delete.
+     */
+    elseif (isset($_POST['action'])) {
+        switch ($_POST['action']) {
+            // Delete selected courses
+            case 'delete_course_requests' :
+                $course_requests = $_POST['course_request'];
+                if (is_array($_POST['course_request']) && !empty($_POST['course_request'])) {
+                    $success = true;
+                    foreach ($_POST['course_request'] as $index => $course_request_id) {
+                        $success &= CourseRequestManager::delete_course_request($course_request_id);
+                    }
+                    $message = $success ? get_lang('SelectedCourseRequestsDeleted') : get_lang('SomeCourseRequestsNotDeleted');
+                    $is_error_message = !$success;
+                }
+                break;
+        }
+    }
+
+} else {
+
+   $link_to_setting = api_get_path(WEB_CODE_PATH).'admin/settings.php?category=Platform#course_validation';
+   $message = sprintf(get_lang('PleaseActivateCourseValidationFeature'), sprintf('<strong><a href="%s">%s</a></strong>', $link_to_setting, get_lang('EnableCourseValidation')));
+   $is_error_message = true;
+
+}
 
 /**
  * Get the number of courses which will be displayed.
  */
-function get_number_of_courses() {
+function get_number_of_requests() {
     return CourseRequestManager::count_course_requests(COURSE_REQUEST_ACCEPTED);
 }
 
 /**
  * Get course data to display
  */
-function get_course_data($from, $number_of_items, $column, $direction) {
+function get_request_data($from, $number_of_items, $column, $direction) {
     $course_table = Database :: get_main_table(TABLE_MAIN_COURSE_REQUEST);
     $users_table = Database :: get_main_table(TABLE_MAIN_USER);
     $course_users_table = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
 
-    $sql = "SELECT code AS col0,
-
-                   title AS col1,
-                   category_code AS col2,
-                   tutor_name AS col3,
-                   request_date AS col4,
-                   id AS col5
+    $sql = "SELECT id AS col0,
+                   code AS col1,
+                   title AS col2,
+                   category_code AS col3,
+                   tutor_name AS col4,
+                   request_date AS col5,
+                   id  AS col6
                    FROM $course_table WHERE status = ".COURSE_REQUEST_ACCEPTED;
 
     $sql .= " ORDER BY col$column $direction ";
     $sql .= " LIMIT $from,$number_of_items";
     $res = Database :: query($sql);
-    $courses = array();
 
+    $courses = array();
     while ($course = Database :: fetch_row($res)) {
         $courses[] = $course;
     }
@@ -75,42 +127,52 @@ function get_course_data($from, $number_of_items, $column, $direction) {
 }
 
 /**
- * Actions in the list: edit.
+ * Actions in the list: edit, accept, delete.
  */
 function modify_filter($id) {
-    return
-        '<a href="editar_curso.php?id='.$id.'"><img src="../img/edit.gif" border="0" style="vertical-align: middle" title="'.get_lang('Edit').'" alt="'.get_lang('Edit').'"/></a>&nbsp;';
+    $code = CourseRequestManager::get_course_request_code($id);
+    $result = '<a href="editar_curso.php?id='.$id.'">'.Display::return_icon('edit.gif', get_lang('Edit'), array('style' => 'vertical-align: middle;')).'</a>'.
+        '&nbsp;<a href="?delete_course_request='.$id.'">'.Display::return_icon('delete.gif', get_lang('DeleteThisCourseRequest'), array('style' => 'vertical-align: middle;', 'onclick' => 'javascript: if (!confirm(\''.addslashes(api_htmlentities(sprintf(get_lang('ACourseRequestWillBeDeleted'), $code), ENT_QUOTES)).'\')) return false;')).'</a>';
+    return $result;
 }
 
 $interbreadcrumb[] = array('url' => 'index.php', 'name' => get_lang('PlatformAdmin'));
 $tool_name = get_lang('AcceptedCourseRequests');
 Display :: display_header($tool_name);
 
-//api_display_tool_title($tool_name);
-if (isset ($_GET['delete_course'])) {
-    //CourseManager :: delete_course($_GET['delete_course']);
+// Display confirmation or error message.
+if (!empty($message)) {
+    if ($is_error_message) {
+        Display::display_error_message($message, false);
+    } else {
+        Display::display_normal_message($message, false);
+    }
+}
+
+if (!$course_validation_feature) {
+    Display :: display_footer();
+    exit;
 }
 
 // The action bar.
 echo '<div class="actions">';
-echo '<a href="'.api_get_path(WEB_CODE_PATH).'admin/course_request_review.php">'.Display::return_icon('course_request_pending.png', get_lang('ReviewCourseRequests')).get_lang('ReviewCourseRequests').'</a>';
-echo '<a href="'.api_get_path(WEB_CODE_PATH).'admin/course_request_rejected.php">'.Display::return_icon('course_request_rejected.gif', get_lang('RejectedCourseRequests')).get_lang('RejectedCourseRequests').'</a>';
+echo '<a href="course_list.php">'.Display::return_icon('courses.gif', get_lang('CourseList')).get_lang('CourseList').'</a>';
+echo '<a href="course_request_review.php">'.Display::return_icon('course_request_pending.png', get_lang('ReviewCourseRequests')).get_lang('ReviewCourseRequests').'</a>';
+echo '<a href="course_request_rejected.php">'.Display::return_icon('course_request_rejected.gif', get_lang('RejectedCourseRequests')).get_lang('RejectedCourseRequests').'</a>';
 echo '</div>';
 
 // Create a sortable table with the course data
-$table = new SortableTable('courses', 'get_number_of_courses', 'get_course_data', 2);
+$table = new SortableTable('course_requests', 'get_number_of_requests', 'get_request_data', 2);
 $table->set_additional_parameters($parameters);
-//$table->set_header(0, '', false);
-$table->set_header(0, get_lang('Code'));
-$table->set_header(1, get_lang('Title'));
-$table->set_header(2, get_lang('Category'));
-//$table->set_header(3, get_lang('Teacher'), false);
-//$table->set_header(4, get_lang('CourseRequestDate'), false);
-$table->set_header(3, get_lang('Teacher'));
-$table->set_header(4, get_lang('CourseRequestDate'));
-$table->set_header(5, '', false);
-$table->set_column_filter(5, 'modify_filter');
-//$table->set_form_actions(array('delete_courses' => get_lang('DeleteCourse')), 'course');
+$table->set_header(0, '', false);
+$table->set_header(1, get_lang('Code'));
+$table->set_header(2, get_lang('Title'));
+$table->set_header(3, get_lang('Category'));
+$table->set_header(4, get_lang('Teacher'));
+$table->set_header(5, get_lang('CourseRequestDate'));
+$table->set_header(6, '', false);
+$table->set_column_filter(6, 'modify_filter');
+$table->set_form_actions(array('delete_course_requests' => get_lang('DeleteCourseRequests')), 'course_request');
 $table->display();
 
 /* FOOTER */

+ 116 - 43
main/admin/course_request_rejected.php

@@ -38,62 +38,121 @@ require api_get_path(CONFIGURATION_PATH).'add_course.conf.php';
 // Including additional libraries.
 require_once api_get_path(LIBRARY_PATH).'fileManage.lib.php';
 
+// A check whether the course validation feature is enabled.
+$course_validation_feature = api_get_setting('course_validation') == 'true';
+
 // Filltering passed to this page parameters.
 $accept_course_request = intval($_GET['accept_course_request']);
+$delete_course_request = intval($_GET['delete_course_request']);
 $request_info = intval($_GET['request_info']);
+$message = trim(Security::remove_XSS(stripslashes(urldecode($_GET['message']))));
+$is_error_message = !empty($_GET['is_error_message']);
 
+if ($course_validation_feature) {
 
 /**
  * Acceptance and creation of the requested course.
  */
-if (!empty($accept_course_request)) {
+    if (!empty($accept_course_request)) {
+        $course_request_code = CourseRequestManager::get_course_request_code($accept_course_request);
+        $course_id = CourseRequestManager::accept_course_request($accept_course_request);
+        if ($course_id) {
+            $course_code = CourseManager::get_course_code_from_course_id($course_id);
+            $message = sprintf(get_lang('CourseRequestAccepted'), $course_request_code, $course_code);
+            $is_error_message = false;
+        } else {
+            $message = sprintf(get_lang('CourseRequestAcceptanceFailed'), $course_request_code);
+            $is_error_message = true;
+        }
+    }
 
-    $course_id = CourseRequestManager::accept_course_request($accept_course_request);
+    /**
+     * Sending to the teacher a request for additional information about the proposed course.
+     */
+    elseif (!empty($request_info)) {
+        $course_request_code = CourseRequestManager::get_course_request_code($request_info);
+        $result = CourseRequestManager::ask_for_additional_info($request_info);
+        if ($result) {
+            $message = sprintf(get_lang('CourseRequestInfoAsked'), $course_request_code);
+            $is_error_message = false;
+        } else {
+            $message = sprintf(get_lang('CourseRequestInfoFailed'), $course_request_code);
+            $is_error_message = true;
+        }
+    }
 
-    if ($course_id) {
-        // TODO: Prepare a confirmation message.
-    } else {
-        // Prepare an error message.
+    /**
+     * Deletion of a course request.
+     */
+    elseif (!empty($delete_course_request)) {
+        $course_request_code = CourseRequestManager::get_course_request_code($delete_course_request);
+        $result = CourseRequestManager::delete_course_request($delete_course_request);
+        if ($result) {
+            $message = sprintf(get_lang('CourseRequestDeleted'), $course_request_code);
+            $is_error_message = false;
+        } else {
+            $message = sprintf(get_lang('CourseRequestDeletionFailed'), $course_request_code);
+            $is_error_message = true;
+        }
     }
 
-}
+    /**
+     * Form actions: delete.
+     */
+    elseif (isset($_POST['action'])) {
+        switch ($_POST['action']) {
+            // Delete selected courses
+            case 'delete_course_requests' :
+                $course_requests = $_POST['course_request'];
+                if (is_array($_POST['course_request']) && !empty($_POST['course_request'])) {
+                    $success = true;
+                    foreach ($_POST['course_request'] as $index => $course_request_id) {
+                        $success &= CourseRequestManager::delete_course_request($course_request_id);
+                    }
+                    $message = $success ? get_lang('SelectedCourseRequestsDeleted') : get_lang('SomeCourseRequestsNotDeleted');
+                    $is_error_message = !$success;
+                }
+                break;
+        }
+    }
+
+} else {
+
+   $link_to_setting = api_get_path(WEB_CODE_PATH).'admin/settings.php?category=Platform#course_validation';
+   $message = sprintf(get_lang('PleaseActivateCourseValidationFeature'), sprintf('<strong><a href="%s">%s</a></strong>', $link_to_setting, get_lang('EnableCourseValidation')));
+   $is_error_message = true;
 
-/**
- * Sending to the teacher a request for additional information about the proposed course.
- */
-if (!empty($request_info)) {
-    CourseRequestManager::ask_for_additional_info($request_info);
 }
 
 /**
  * Get the number of courses which will be displayed.
  */
-function get_number_of_courses() {
+function get_number_of_requests() {
     return CourseRequestManager::count_course_requests(COURSE_REQUEST_REJECTED);
 }
 
 /**
  * Get course data to display
  */
-function get_course_data($from, $number_of_items, $column, $direction) {
+function get_request_data($from, $number_of_items, $column, $direction) {
     $course_table = Database :: get_main_table(TABLE_MAIN_COURSE_REQUEST);
     $users_table = Database :: get_main_table(TABLE_MAIN_USER);
     $course_users_table = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
 
-    $sql = "SELECT code AS col0,
-
-                   title AS col1,
-                   category_code AS col2,
-                   tutor_name AS col3,
-                   request_date AS col4,
-                   id  AS col5
+    $sql = "SELECT id AS col0,
+                   code AS col1,
+                   title AS col2,
+                   category_code AS col3,
+                   tutor_name AS col4,
+                   request_date AS col5,
+                   id  AS col6
                    FROM $course_table WHERE status = ".COURSE_REQUEST_REJECTED;
 
     $sql .= " ORDER BY col$column $direction ";
     $sql .= " LIMIT $from,$number_of_items";
     $res = Database :: query($sql);
-    $courses = array();
 
+    $courses = array();
     while ($course = Database :: fetch_row($res)) {
         $courses[] = $course;
     }
@@ -102,43 +161,57 @@ function get_course_data($from, $number_of_items, $column, $direction) {
 }
 
 /**
- * Actions in the list: edit.
+ * Actions in the list: edit, accept, delete, request additional information.
  */
 function modify_filter($id) {
-    return
-        '<a href="editar_curso.php?id='.$id.'"><img src="../img/edit.gif" border="0" style="vertical-align: middle" title="'.get_lang('Edit').'" alt="'.get_lang('Edit').'"/></a>&nbsp;'.' '.
-        '<a href="?accept_course_request='.$id.'"  onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang('ANewCourseWillBeCreated'), ENT_QUOTES))."'".')) return false;"><img src="../img/right.gif" border="0" style="vertical-align: middle" title="'.get_lang('AcceptThisCourseRequest').'" alt="'.get_lang('AcceptThisCourseRequest').'"/></a>';
+    $code = CourseRequestManager::get_course_request_code($id);
+    $result = '<a href="editar_curso.php?id='.$id.'">'.Display::return_icon('edit.gif', get_lang('Edit'), array('style' => 'vertical-align: middle;')).'</a>'.
+        '&nbsp;<a href="?accept_course_request='.$id.'">'.Display::return_icon('action_accept.gif', get_lang('AcceptThisCourseRequest'), array('style' => 'vertical-align: middle;', 'onclick' => 'javascript: if (!confirm(\''.addslashes(api_htmlentities(sprintf(get_lang('ANewCourseWillBeCreated'), $code), ENT_QUOTES)).'\')) return false;')).'</a>';
+    if (!CourseRequestManager::additional_info_asked($id)) {
+        $result .= '&nbsp;<a href="?request_info='.$id.'">'.Display::return_icon('request_info.gif', get_lang('AskAdditionalInfo'), array('style' => 'vertical-align: middle;', 'onclick' => 'javascript: if (!confirm(\''.addslashes(api_htmlentities(sprintf(get_lang('AdditionalInfoWillBeAsked'), $code), ENT_QUOTES)).'\')) return false;')).'</a>';
+    }
+    $result .= '&nbsp;<a href="?delete_course_request='.$id.'">'.Display::return_icon('delete.gif', get_lang('DeleteThisCourseRequest'), array('style' => 'vertical-align: middle;', 'onclick' => 'javascript: if (!confirm(\''.addslashes(api_htmlentities(sprintf(get_lang('ACourseRequestWillBeDeleted'), $code), ENT_QUOTES)).'\')) return false;')).'</a>';
+
+    return $result;
 }
 
 $interbreadcrumb[] = array('url' => 'index.php', 'name' => get_lang('PlatformAdmin'));
 $tool_name = get_lang('RejectedCourseRequests');
 Display :: display_header($tool_name);
 
-//api_display_tool_title($tool_name);
-if (isset($_GET['delete_course'])) {
-    CourseManager :: delete_course($_GET['delete_course']);
+// Display confirmation or error message.
+if (!empty($message)) {
+    if ($is_error_message) {
+        Display::display_error_message($message, false);
+    } else {
+        Display::display_normal_message($message, false);
+    }
+}
+
+if (!$course_validation_feature) {
+    Display :: display_footer();
+    exit;
 }
 
 // The action bar.
 echo '<div class="actions">';
-echo '<a href="'.api_get_path(WEB_CODE_PATH).'admin/course_request_review.php">'.Display::return_icon('course_request_pending.png', get_lang('ReviewCourseRequests')).get_lang('ReviewCourseRequests').'</a>';
-echo '<a href="'.api_get_path(WEB_CODE_PATH).'admin/course_request_accepted.php">'.Display::return_icon('course_request_accepted.gif', get_lang('AcceptedCourseRequests')).get_lang('AcceptedCourseRequests').'</a>';
+echo '<a href="course_list.php">'.Display::return_icon('courses.gif', get_lang('CourseList')).get_lang('CourseList').'</a>';
+echo '<a href="course_request_review.php">'.Display::return_icon('course_request_pending.png', get_lang('ReviewCourseRequests')).get_lang('ReviewCourseRequests').'</a>';
+echo '<a href="course_request_accepted.php">'.Display::return_icon('course_request_accepted.gif', get_lang('AcceptedCourseRequests')).get_lang('AcceptedCourseRequests').'</a>';
 echo '</div>';
 
 // Create a sortable table with the course data
-$table = new SortableTable('courses', 'get_number_of_courses', 'get_course_data', 2);
+$table = new SortableTable('course_requests', 'get_number_of_requests', 'get_request_data', 2);
 $table->set_additional_parameters($parameters);
-//$table->set_header(0, '', false);
-$table->set_header(0, get_lang('Code'));
-$table->set_header(1, get_lang('Title'));
-$table->set_header(2, get_lang('Category'));
-//$table->set_header(3, get_lang('Teacher'), false);
-//$table->set_header(4, get_lang('CourseRequestDate'), false);
-$table->set_header(3, get_lang('Teacher'));
-$table->set_header(4, get_lang('CourseRequestDate'));
-$table->set_header(5, '', false);
-$table->set_column_filter(5, 'modify_filter');
-//$table->set_form_actions(array('delete_courses' => get_lang('DeleteCourse')), 'course');
+$table->set_header(0, '', false);
+$table->set_header(1, get_lang('Code'));
+$table->set_header(2, get_lang('Title'));
+$table->set_header(3, get_lang('Category'));
+$table->set_header(4, get_lang('Teacher'));
+$table->set_header(5, get_lang('CourseRequestDate'));
+$table->set_header(6, '', false);
+$table->set_column_filter(6, 'modify_filter');
+$table->set_form_actions(array('delete_course_requests' => get_lang('DeleteCourseRequests')), 'course_request');
 $table->display();
 
 /* FOOTER */

+ 147 - 83
main/admin/course_request_review.php

@@ -37,65 +37,129 @@ require_once api_get_path(CONFIGURATION_PATH).'add_course.conf.php';
 // Including additional libraries.
 require_once api_get_path(LIBRARY_PATH).'fileManage.lib.php';
 
+// The delete action should be deactivated in this page.
+// Better reject the target request, after that you can delete it.
+define(DELETE_ACTION_ENABLED, false);
+
+// A check whether the course validation feature is enabled.
+$course_validation_feature = api_get_setting('course_validation') == 'true';
+
 // Filltering passed to this page parameters.
 $accept_course_request = intval($_GET['accept_course_request']);
 $reject_course_request = intval($_GET['reject_course_request']);
 $request_info = intval($_GET['request_info']);
-
-/**
- * Coutse acceptance and creation.
- */
-if (!empty($accept_course_request)) {
-
-    $course_id = CourseRequestManager::accept_course_request($accept_course_request);
-
-    if ($course_id) {
-        // TODO: Prepare a confirmation message.
-    } else {
-        // Prepare an error message.
+$delete_course_request = intval($_GET['delete_course_request']);
+$message = trim(Security::remove_XSS(stripslashes(urldecode($_GET['message']))));
+$is_error_message = !empty($_GET['is_error_message']);
+
+if ($course_validation_feature) {
+
+    /**
+     * Course acceptance and creation.
+     */
+    if (!empty($accept_course_request)) {
+        $course_request_code = CourseRequestManager::get_course_request_code($accept_course_request);
+        $course_id = CourseRequestManager::accept_course_request($accept_course_request);
+        if ($course_id) {
+            $course_code = CourseManager::get_course_code_from_course_id($course_id);
+            $message = sprintf(get_lang('CourseRequestAccepted'), $course_request_code, $course_code);
+            $is_error_message = false;
+        } else {
+            $message = sprintf(get_lang('CourseRequestAcceptanceFailed'), $course_request_code);
+            $is_error_message = true;
+        }
     }
 
-}
+    /**
+     * Course rejection
+     */
+    elseif (!empty($reject_course_request)) {
+        $course_request_code = CourseRequestManager::get_course_request_code($reject_course_request);
+        $result = CourseRequestManager::reject_course_request($reject_course_request);
+        if ($result) {
+            $message = sprintf(get_lang('CourseRequestRejected'), $course_request_code);
+            $is_error_message = false;
+        } else {
+            $message = sprintf(get_lang('CourseRequestRejectionFailed'), $course_request_code);
+            $is_error_message = true;
+        }
+    }
 
-/**
- * Course rejection
- */
-if (isset($_GET['reject_course_request']) && $_GET['reject_course_request'] != '') {
+    /**
+     * Sending to the teacher a request for additional information about the proposed course.
+     */
+    elseif (!empty($request_info)) {
+        $course_request_code = CourseRequestManager::get_course_request_code($request_info);
+        $result = CourseRequestManager::ask_for_additional_info($request_info);
+        if ($result) {
+            $message = sprintf(get_lang('CourseRequestInfoAsked'), $course_request_code);
+            $is_error_message = false;
+        } else {
+            $message = sprintf(get_lang('CourseRequestInfoFailed'), $course_request_code);
+            $is_error_message = true;
+        }
+    }
 
-    $result = CourseRequestManager::reject_course_request($reject_course_request);
+    /**
+     * Deletion of a course request.
+     */
+    elseif (!empty($delete_course_request)) {
+        $course_request_code = CourseRequestManager::get_course_request_code($delete_course_request);
+        $result = CourseRequestManager::delete_course_request($delete_course_request);
+        if ($result) {
+            $message = sprintf(get_lang('CourseRequestDeleted'), $course_request_code);
+            $is_error_message = false;
+        } else {
+            $message = sprintf(get_lang('CourseRequestDeletionFailed'), $course_request_code);
+            $is_error_message = true;
+        }
+    }
 
-    if ($result) {
-        // TODO: Prepare a confirmation message.
-    } else {
-        // Prepare an error message.
+    /**
+     * Form actions: delete.
+     */
+    elseif (DELETE_ACTION_ENABLED && isset($_POST['action'])) {
+        switch ($_POST['action']) {
+            // Delete selected courses
+            case 'delete_course_requests' :
+                $course_requests = $_POST['course_request'];
+                if (is_array($_POST['course_request']) && !empty($_POST['course_request'])) {
+                    $success = true;
+                    foreach ($_POST['course_request'] as $index => $course_request_id) {
+                        $success &= CourseRequestManager::delete_course_request($course_request_id);
+                    }
+                    $message = $success ? get_lang('SelectedCourseRequestsDeleted') : get_lang('SomeCourseRequestsNotDeleted');
+                    $is_error_message = !$success;
+                }
+                break;
+        }
     }
-}
 
-/**
- * Sending to the teacher a request for additional information about the proposed course.
- */
-if (!empty($request_info)) {
-    CourseRequestManager::ask_for_additional_info($request_info);
-}
+} else {
 
+   $link_to_setting = api_get_path(WEB_CODE_PATH).'admin/settings.php?category=Platform#course_validation';
+   $message = sprintf(get_lang('PleaseActivateCourseValidationFeature'), sprintf('<strong><a href="%s">%s</a></strong>', $link_to_setting, get_lang('EnableCourseValidation')));
+   $is_error_message = true;
 
+}
 
 /**
  * Get the number of courses which will be displayed.
  */
-function get_number_of_courses() {
+function get_number_of_requests() {
     return CourseRequestManager::count_course_requests(COURSE_REQUEST_PENDING);
 }
 
 /**
  * Get course data to display
  */
-function get_course_data($from, $number_of_items, $column, $direction) {
+function get_request_data($from, $number_of_items, $column, $direction) {
     $course_table = Database :: get_main_table(TABLE_MAIN_COURSE_REQUEST);
     $users_table = Database :: get_main_table(TABLE_MAIN_USER);
     $course_users_table = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
 
-    $sql = "SELECT code AS col0,
+    if (DELETE_ACTION_ENABLED) {
+        $sql = "SELECT id AS col0,
                    code AS col1,
                    title AS col2,
                    category_code AS col3,
@@ -103,12 +167,22 @@ function get_course_data($from, $number_of_items, $column, $direction) {
                    request_date AS col5,
                    id  AS col6
                    FROM $course_table WHERE status = ".COURSE_REQUEST_PENDING;
+    } else {
+        $sql = "SELECT
+                   code AS col0,
+                   title AS col1,
+                   category_code AS col2,
+                   tutor_name AS col3,
+                   request_date AS col4,
+                   id  AS col5
+                   FROM $course_table WHERE status = ".COURSE_REQUEST_PENDING;
+    }
 
     $sql .= " ORDER BY col$column $direction ";
     $sql .= " LIMIT $from,$number_of_items";
     $res = Database::query($sql);
-    $courses = array();
 
+    $courses = array();
     while ($course = Database::fetch_row($res)) {
         $courses[] = $course;
     }
@@ -130,72 +204,62 @@ function email_filter($teacher) {
  * Actions in the list: edit, accept, reject, request additional information.
  */
 function modify_filter($id) {
-    /*
-    return
-    '<a href="editar_curso.php?id='.$id.'"><img src="../img/edit.gif" border="0" style="vertical-align: middle" title="'.get_lang('Edit').'" alt="'.get_lang('Edit').'"/></a>&nbsp;'.' '.'<a href="?reject_course_request='.$id.'"  onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES))."'".')) return false;"><img src="../img/delete.gif" border="0" style="vertical-align: middle" title="'.get_lang('Delete').'" alt="'.get_lang('Delete').'"/></a>'.'  '.'<a href="?request_info='.$id.'" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang('AdditionalInfoWillBeAsked'), ENT_QUOTES))."'".')) return false;"><img src="../img/cesga_question.gif" border="0" style="vertical-align: middle" title="'.get_lang('AskAdditionalInfo').'" alt="'.get_lang('AskAdditionalInfo').'"/></a>&nbsp;'.'  '.'<a href="?accept_course_request='.$id.'" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang('ANewCourseWillBeCreated'), ENT_QUOTES))."'".')) return false;"><img src="../img/right.gif" border="0" style="vertical-align: middle" title="'.get_lang('AcceptThisCourseRequest').'" alt="'.get_lang('AcceptThisCourseRequest').'"/></a>&nbsp;';
-    */
-    $sql_request_info = "SELECT * FROM ".Database :: get_main_table(TABLE_MAIN_COURSE_REQUEST)." WHERE (id = ".$id." AND info = 1)";
-    $res_request_info = Database::query($sql_request_info);
-
-    if (Database::num_rows($res_request_info) > 0) { //Si ya se le ha pedido información, no se muestra esa opción
-
-        return
-            '<a href="editar_curso.php?id='.$id.'"><img src="../img/edit.gif" border="0" style="vertical-align: middle" title="'.get_lang('Edit').'" alt="'.get_lang('Edit').'"/></a>&nbsp;'.' '.'<a href="?reject_course_request='.$id.'"  onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES))."'".')) return false;"><img src="../img/delete.gif" border="0" style="vertical-align: middle" title="'.get_lang('Delete').'" alt="'.get_lang('Delete').'"/></a>'.'  '.'<a href="?accept_course_request='.$id.'" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang('ANewCourseWillBeCreated'), ENT_QUOTES))."'".')) return false;"><img src="../img/right.gif" border="0" style="vertical-align: middle" title="'.get_lang('AcceptThisCourseRequest').'" alt="'.get_lang('AcceptThisCourseRequest').'"/></a>&nbsp;';
-
-    } else {
-
-        return
-            '<a href="editar_curso.php?id='.$id.'"><img src="../img/edit.gif" border="0" style="vertical-align: middle" title="'.get_lang('Edit').'" alt="'.get_lang('Edit').'"/></a>&nbsp;'.'  '.'<a href="?reject_course_request='.$id.'"  onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES))."'".')) return false;"><img src="../img/delete.gif" border="0" style="vertical-align: middle" title="'.get_lang('Delete').'" alt="'.get_lang('Delete').'"/></a>'.'  '.'<a href="?accept_course_request='.$id.'" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang('ANewCourseWillBeCreated'), ENT_QUOTES))."'".')) return false;"><img src="../img/right.gif" border="0" style="vertical-align: middle" title="'.get_lang('AcceptThisCourseRequest').'" alt="'.get_lang('AcceptThisCourseRequest').'"/></a>'.'  '.'<a href="?request_info='.$id.'" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang('AdditionalInfoWillBeAsked'), ENT_QUOTES))."'".')) return false;"><img src="../img/cesga_question.gif" border="0" style="vertical-align: middle" title="'.get_lang('AskAdditionalInfo').'" alt="'.get_lang('AskAdditionalInfo').'"/></a>&nbsp;&nbsp;';
+    $code = CourseRequestManager::get_course_request_code($id);
+    $result = '<a href="editar_curso.php?id='.$id.'">'.Display::return_icon('edit.gif', get_lang('Edit'), array('style' => 'vertical-align: middle;')).'</a>'.
+        '&nbsp;<a href="?accept_course_request='.$id.'">'.Display::return_icon('action_accept.gif', get_lang('AcceptThisCourseRequest'), array('style' => 'vertical-align: middle;', 'onclick' => 'javascript: if (!confirm(\''.addslashes(api_htmlentities(sprintf(get_lang('ANewCourseWillBeCreated'), $code), ENT_QUOTES)).'\')) return false;')).'</a>'.
+        '&nbsp;<a href="?reject_course_request='.$id.'">'.Display::return_icon('action_reject.gif', get_lang('RejectThisCourseRequest'), array('style' => 'vertical-align: middle;', 'onclick' => 'javascript: if (!confirm(\''.addslashes(api_htmlentities(sprintf(get_lang('ACourseRequestWillBeRejected'), $code), ENT_QUOTES)).'\')) return false;')).'</a>';
+    if (!CourseRequestManager::additional_info_asked($id)) {
+        $result .= '&nbsp;<a href="?request_info='.$id.'">'.Display::return_icon('request_info.gif', get_lang('AskAdditionalInfo'), array('style' => 'vertical-align: middle;', 'onclick' => 'javascript: if (!confirm(\''.addslashes(api_htmlentities(sprintf(get_lang('AdditionalInfoWillBeAsked'), $code), ENT_QUOTES)).'\')) return false;')).'</a>';
     }
-}
-
-if (isset ($_POST['action'])) {
-    switch ($_POST['action']) {
-        // Delete selected courses
-        case 'delete_courses' :
-            $course_codes = $_POST['course'];
-            if (count($course_codes) > 0) {
-                foreach ($course_codes as $index => $course_code) {
-                    //CourseManager :: delete_course($course_code);
-                    $sql = "DELETE FROM ".Database :: get_main_table(TABLE_MAIN_COURSE_REQUEST)." WHERE code LIKE '".$course_code."'";
-                    //echo $sql;
-                    $result = Database::query($sql);
-                }
-            }
-            break;
+    if (DELETE_ACTION_ENABLED) {
+        $result .= '&nbsp;<a href="?delete_course_request='.$id.'">'.Display::return_icon('delete.gif', get_lang('DeleteThisCourseRequest'), array('style' => 'vertical-align: middle;', 'onclick' => 'javascript: if (!confirm(\''.addslashes(api_htmlentities(sprintf(get_lang('ACourseRequestWillBeDeleted'), $code), ENT_QUOTES)).'\')) return false;')).'</a>';
     }
+    return $result;
 }
 
 $interbreadcrumb[] = array('url' => 'index.php', 'name' => get_lang('PlatformAdmin'));
 $tool_name = get_lang('ReviewCourseRequests');
 Display :: display_header($tool_name);
 
-//api_display_tool_title($tool_name);
-if (isset ($_GET['delete_course'])) {
-    //CourseManager :: delete_course($_GET['delete_course']);
+// Display confirmation or error message.
+if (!empty($message)) {
+    if ($is_error_message) {
+        Display::display_error_message($message, false);
+    } else {
+        Display::display_normal_message($message, false);
+    }
+}
+
+if (!$course_validation_feature) {
+    Display :: display_footer();
+    exit;
 }
 
 // The action bar.
 echo '<div class="actions">';
-echo '<a href="'.api_get_path(WEB_CODE_PATH).'admin/course_request_accepted.php">'.Display::return_icon('course_request_accepted.gif', get_lang('AcceptedCourseRequests')).get_lang('AcceptedCourseRequests').'</a>';
-echo '<a href="'.api_get_path(WEB_CODE_PATH).'admin/course_request_rejected.php">'.Display::return_icon('course_request_rejected.gif', get_lang('RejectedCourseRequests')).get_lang('RejectedCourseRequests').'</a>';
+echo '<a href="course_list.php">'.Display::return_icon('courses.gif', get_lang('CourseList')).get_lang('CourseList').'</a>';
+echo '<a href="course_request_accepted.php">'.Display::return_icon('course_request_accepted.gif', get_lang('AcceptedCourseRequests')).get_lang('AcceptedCourseRequests').'</a>';
+echo '<a href="course_request_rejected.php">'.Display::return_icon('course_request_rejected.gif', get_lang('RejectedCourseRequests')).get_lang('RejectedCourseRequests').'</a>';
 echo '</div>';
 
 // Create a sortable table with the course data
-$table = new SortableTable('courses', 'get_number_of_courses', 'get_course_data', 2);
+$offet = DELETE_ACTION_ENABLED ? 1 : 0;
+$table = new SortableTable('course_requests', 'get_number_of_requests', 'get_request_data', 1 + $offet);
 $table->set_additional_parameters($parameters);
-$table->set_header(0, '', false);
-$table->set_header(1, get_lang('Code'));
-$table->set_header(2, get_lang('Title'));
-$table->set_header(3, get_lang('Category'));
-//$table->set_header(4, get_lang('Teacher'), false);
-//$table->set_header(5, get_lang('CourseRequestDate'), false);
-$table->set_header(4, get_lang('Teacher'));
-$table->set_header(5, get_lang('CourseRequestDate'));
-$table->set_header(6, '', false);
-$table->set_column_filter(4,'email_filter');
-$table->set_column_filter(6,'modify_filter');
-$table->set_form_actions(array('delete_courses' => get_lang('DeleteCourse')), 'course');
+if (DELETE_ACTION_ENABLED) {
+    $table->set_header(0, '', false);
+}
+$table->set_header(0 + $offet, get_lang('Code'));
+$table->set_header(1 + $offet, get_lang('Title'));
+$table->set_header(2 + $offet, get_lang('Category'));
+$table->set_header(3 + $offet, get_lang('Teacher'));
+$table->set_header(4 + $offet, get_lang('CourseRequestDate'));
+$table->set_header(5 + $offet, '', false);
+$table->set_column_filter(3 + $offet, 'email_filter');
+$table->set_column_filter(5 + $offet, 'modify_filter');
+if (DELETE_ACTION_ENABLED) {
+    $table->set_form_actions(array('delete_course_requests' => get_lang('DeleteCourseRequests')), 'course_request');
+}
 $table->display();
 
 /* FOOTER */

+ 1 - 1
main/create_course/add_course.php

@@ -97,7 +97,7 @@ $form->add_textfield('wanted_code', get_lang('Code'), false, array('size' => '$m
 $form->applyFilter('wanted_code', 'html_filter');
 $form->addRule('wanted_code', get_lang('Max'), 'maxlength', $maxlength);
 
-$titular = & $form->add_textfield('tutor_name', get_lang('Professors'), null, array('size' => '60', 'disabled' => 'disabled'));
+$titular = & $form->add_textfield('tutor_name', get_lang('Professor'), null, array('size' => '60', 'disabled' => 'disabled'));
 $form->addElement('static', null, null, get_lang('ExplicationTrainers'));
 //$form->applyFilter('tutor_name', 'html_filter');
 

+ 25 - 10
main/document/create_drawing.php

@@ -28,9 +28,17 @@ $nameTools = get_lang('Draw');
 api_protect_course_script();
 api_block_anonymous_users();
 
-
+if (!isset($_GET['dir'])){
+	api_not_allowed(true);
+}
 /*	Constants and variables */
 
+//path for svg-edit save
+$_SESSION['draw_dir']=Security::remove_XSS($_GET['dir']);
+if($_SESSION['draw_dir']=='/'){
+	$_SESSION['draw_dir']='';
+}
+
 $dir = isset($_GET['dir']) ? Security::remove_XSS($_GET['dir']) : Security::remove_XSS($_POST['dir']);
 $is_allowed_to_edit = api_is_allowed_to_edit(null, true);
 
@@ -117,13 +125,6 @@ if (isset ($group)) {
 		}
 		$dir_acum .= $dir_array[$i].'/';
 	}
-	
-//path for svg-edit save
-$_SESSION['draw_dir']=Security::remove_XSS($_GET['dir']);
-if($_SESSION['draw_dir']=='/'){
-	$_SESSION['draw_dir']='';
-}
-
 //
 Display :: display_header($nameTools, 'Doc');
 
@@ -131,8 +132,22 @@ echo '<div class="actions">';
 		echo '<a href="document.php?curdirpath='.Security::remove_XSS($_GET['dir']).'">'.Display::return_icon('back.png',get_lang('BackTo').' '.get_lang('DocumentsOverview')).get_lang('BackTo').' '.get_lang('DocumentsOverview').'</a>';
 echo '</div>';
 
-echo '<iframe style=\'height: 500px; width: 100%;\' scrolling=\'no\' frameborder=\'0\' src=\''.api_get_path(WEB_LIBRARY_PATH).'svg-edit/svg-editor.php\'>';
-echo '</iframe>';
+if (api_support_svg()){
+	
+	//automatic loading the course language
+	$svgedit_code_translation_table = array('' => 'en', 'pt' => 'pt-Pt', 'sr' => 'sr_latn');
+	$langsvgedit  = api_get_language_isocode();
+	$langsvgedit = isset($svgedit_code_translation_table[$langsvgedit]) ? $svgedit_code_translation_table[$langsvgedit] : $langsvgedit;
+	$langsvgedit = file_exists(api_get_path(LIBRARY_PATH).'svg-edit/locale/lang.'.$langsvgedit.'.js') ? $langsvgedit : 'en';
+	
+	//editor
+	echo '<iframe style=\'height: 500px; width: 100%;\' scrolling=\'no\' frameborder=\'0\' src=\''.api_get_path(WEB_LIBRARY_PATH).'svg-edit/svg-editor.php?lang='.$langsvgedit.'\'>';
+	echo '</iframe>';
+
+}else{
+	
+	Display::display_error_message(get_lang('BrowserDontSupportsSVG'));
+}
 
 Display :: display_footer();
 ?>

+ 3 - 16
main/document/document.inc.php

@@ -13,6 +13,7 @@
  * @param	boolean	Whether to change the renderer (this will add a template <span> to the QuickForm object displaying the form)
  * @return string html form
  */
+
 function build_directory_selector($folders, $curdirpath, $group_dir = '', $change_renderer = false) {
 	$folder_titles = array();
 	if (api_get_setting('use_document_title') == 'true') {
@@ -124,7 +125,7 @@ function create_document_link($www, $title, $path, $filetype, $size, $visibility
 		$ext = strtolower($ext[sizeof($ext) - 1]);
 		
 		// "htmlfiles" are shown in a frameset
-		if ($ext == 'htm' || $ext == 'html' || $ext == 'gif' || $ext == 'jpg' || $ext == 'jpeg' || $ext == 'png' || $ext == 'pdf' || $ext == 'swf' || $ext == 'mp3' || ($ext == 'svg' && support_svg())) {
+		if ($ext == 'htm' || $ext == 'html' || $ext == 'gif' || $ext == 'jpg' || $ext == 'jpeg' || $ext == 'png' || $ext == 'pdf' || $ext == 'swf' || $ext == 'mp3' || ($ext == 'svg' || $ext =='svgz' && api_support_svg())) {
 			$url = 'showinframes.php?'.api_get_cidreq().'&amp;file='.$url_path.$req_gid;
 		} else {
 			// url-encode for problematic characters (we may not call them dangerous characters...)
@@ -299,7 +300,7 @@ function build_edit_icons($curdirpath, $type, $path, $visibility, $id, $is_templ
 		if ($is_certificate_mode) {
 			$modify_icons = '<a href="edit_document.php?'.api_get_cidreq().'&curdirpath='.$curdirpath.'&amp;file='.urlencode($path).$req_gid.'&selectcat='.$gradebook_category.'"><img src="../img/edit.gif" border="0" title="'.get_lang('Modify').'" alt="" /></a>';
 		}else {
-			if($extension=='svg' && support_svg()){			
+			if($extension=='svg' && api_support_svg()){
 				$modify_icons = '<a href="edit_drawing.php?'.api_get_cidreq().'&curdirpath='.$curdirpath.'&amp;file='.urlencode($path).$req_gid.'"><img src="../img/edit.gif" border="0" title="'.get_lang('Modify').'" alt="" /></a>';		
 			}else{			
 				$modify_icons = '<a href="edit_document.php?'.api_get_cidreq().'&curdirpath='.$curdirpath.'&amp;file='.urlencode($path).$req_gid.'"><img src="../img/edit.gif" border="0" title="'.get_lang('Modify').'" alt="" /></a>';
@@ -573,18 +574,4 @@ function search_keyword($document_name, $keyword) {
 	}
 }
 
-/**
- * Check brosers support for svg files
- * @return return bool Return true
- */
-function support_svg() {	
-	$browser_info = get_browser($_SERVER["HTTP_USER_AGENT"], true);
-	//print_r($browser_info);
-	if (($browser_info[browser]=='IE' && $browser_info[majorver]>8) || ($browser_info[browser]=='Firefox' && $browser_info[majorver]>2)||($browser_info[browser]=='Safari' && $browser_info[majorver]>4) || $browser_info[browser]=='Chrome' || ($browser_info[browser]=='Opera' && $browser_info[majorver]>9)){
-		return true;
-	}else{
-		return false;
-	}	
-}
-
 ?>

+ 15 - 13
main/document/document.php

@@ -604,7 +604,7 @@ if ($is_allowed_to_edit || $group_member_with_upload_rights) { // TEACHER ONLY
 
 		// Update item_property to change visibility
 		if (api_item_property_update($_course, TOOL_DOCUMENT, $update_id, $visibility_command, $_user['user_id'], null, null, null, null, $current_session_id)) {
-			Display::display_confirmation_message(get_lang('ViMod'));
+			Display::display_confirmation_message(get_lang('VisibilityChanged'));//don't use ViMod because firt is load ViMdod (Gradebook). VisibilityChanged (trad4all)
 		} else {
 			Display::display_error_message(get_lang('ViModProb'));
 		}
@@ -849,18 +849,20 @@ if ($is_allowed_to_edit || $group_member_with_upload_rights || is_my_shared_fold
 
 	// Create new document
 	if (!$is_certificate_mode) {
-?>
-	<a href="create_document.php?<?php echo api_get_cidreq(); ?>&dir=<?php echo $curdirpathurl.$req_gid; ?>">
-		<?php Display::display_icon('filenew.gif', get_lang('CreateDoc')); echo get_lang('CreateDoc'); ?></a>&nbsp;
-<?php
-	}
-
-	// Create new draw
-	if (support_svg()){
-	?>
-		<a href="create_drawing.php?<?php echo api_get_cidreq(); ?>&dir=<?php echo $curdirpathurl.$req_gid; ?>">
-			<?php Display::display_icon('draw.png', get_lang('Draw')); echo get_lang('Draw'); ?></a>&nbsp;
-	<?php	
+		?>
+		<a href="create_document.php?<?php echo api_get_cidreq(); ?>&dir=<?php echo $curdirpathurl.$req_gid; ?>">
+			<?php Display::display_icon('filenew.gif', get_lang('CreateDoc')); echo get_lang('CreateDoc'); ?></a>&nbsp;
+		<?php		
+	
+		// Create new draw
+		if (api_support_svg()){
+		?>
+			<a href="create_drawing.php?<?php echo api_get_cidreq(); ?>&dir=<?php echo $curdirpathurl.$req_gid; ?>">
+				<?php Display::display_icon('draw_new.png', get_lang('Draw')); echo get_lang('Draw'); ?></a>&nbsp;
+		<?php	
+		}else{
+			Display::display_icon('draw_new.png', get_lang('BrowserDontSupportsSVG')); echo get_lang('Draw').'&nbsp;';
+		}
 	}
 	
 	// Create new certificate

+ 30 - 10
main/document/edit_drawing.php

@@ -22,9 +22,24 @@ $this_section = SECTION_COURSES;
 require_once api_get_path(SYS_CODE_PATH).'document/document.inc.php';
 require_once api_get_path(LIBRARY_PATH).'groupmanager.lib.php';
 
+//
+api_protect_course_script();
+api_block_anonymous_users();
+
+if (!isset($_GET['curdirpath']) || !isset($_GET['file'])){
+	api_not_allowed(true);
+}
 
 /* Constants & Variables */
 
+//path for svg-edit save
+$_SESSION['draw_dir']=Security::remove_XSS($_GET['curdirpath']);
+if($_SESSION['draw_dir']=='/'){
+	$_SESSION['draw_dir']='';
+}
+$_SESSION['draw_file']=basename(Security::remove_XSS($_GET['file']));
+
+//
 $get_file = Security::remove_XSS($_GET['file']);
 
 $file = basename($get_file);
@@ -89,23 +104,28 @@ if (!$is_allowedToEdit) {
 	api_not_allowed(true);
 }
 
-
 event_access_tool(TOOL_DOCUMENT);
 
-//path for svg-edit save
-$_SESSION['draw_dir']=Security::remove_XSS($_GET['curdirpath']);
-if($_SESSION['draw_dir']=='/'){
-	$_SESSION['draw_dir']='';
-}
-$_SESSION['draw_file']=basename(Security::remove_XSS($_GET['file']));
-
 Display :: display_header($nameTools, 'Doc');
 echo '<div class="actions">';
 		echo '<a href="document.php?curdirpath='.Security::remove_XSS($_GET['curdirpath']).'">'.Display::return_icon('back.png',get_lang('BackTo').' '.get_lang('DocumentsOverview')).get_lang('BackTo').' '.get_lang('DocumentsOverview').'</a>';
 echo '</div>';
 
-echo '<iframe style=\'height: 500px; width: 100%;\' scrolling=\'no\' frameborder=\'0\' src=\''.api_get_path(WEB_LIBRARY_PATH).'svg-edit/svg-editor.php?url=../../../../courses/'.$courseDir.$dir.$file.'\'>';
-echo '</iframe>';
+if (api_support_svg()){
+	
+	//automatic loading the course language
+	$svgedit_code_translation_table = array('' => 'en', 'pt' => 'pt-Pt', 'sr' => 'sr_latn');
+	$langsvgedit  = api_get_language_isocode();
+	$langsvgedit = isset($svgedit_code_translation_table[$langsvgedit]) ? $svgedit_code_translation_table[$langsvgedit] : $langsvgedit;
+	$langsvgedit = file_exists(api_get_path(LIBRARY_PATH).'svg-edit/locale/lang.'.$langsvgedit.'.js') ? $langsvgedit : 'en';
+	
+	echo '<iframe style=\'height: 500px; width: 100%;\' scrolling=\'no\' frameborder=\'0\' src=\''.api_get_path(WEB_LIBRARY_PATH).'svg-edit/svg-editor.php?url=../../../../courses/'.$courseDir.$dir.$file.'&lang='.$langsvgedit.'\'>';	
+	echo '</iframe>';
+
+}else{
+	
+	Display::display_error_message(get_lang('BrowserDontSupportsSVG'));
+}
 
 Display::display_footer();
 ?>

+ 1 - 1
main/document/upload.php

@@ -482,7 +482,7 @@ echo '<div class="actions">';
 
 // Link back to the documents overview
 if ($is_certificate_mode) {
-	echo '<a href="document.php?curdirpath='.$path.'&selectcat=' . Security::remove_XSS($_GET['selectcat']).'">'.Display::return_icon('back.png',get_lang('Back').' '.get_lang('To').' '.get_lang('CertificateOverview')).get_lang('Back').' '.get_lang('To').' '.get_lang('CertificateOverview').'</a>';
+	echo '<a href="document.php?curdirpath='.$path.'&selectcat=' . Security::remove_XSS($_GET['selectcat']).'">'.Display::return_icon('back.png',get_lang('BackTo').' '.get_lang('CertificateOverview')).get_lang('BackTo').' '.get_lang('CertificateOverview').'</a>';
 } else {
 	echo '<a href="document.php?curdirpath='.$path.'">'.Display::return_icon('back.png',get_lang('BackTo').' '.get_lang('DocumentsOverview')).get_lang('BackTo').' '.get_lang('DocumentsOverview').'</a>';
 }

BIN
main/img/draw.png


BIN
main/img/draw_new.png


BIN
main/img/new.png


BIN
main/img/request_info.gif


+ 1051 - 0
main/inc/lib/browser/Browser.php

@@ -0,0 +1,1051 @@
+<?php
+	/**
+	 * File: Browser.php
+	 * Author: Chris Schuld (http://chrisschuld.com/)
+	 * Last Modified: August 20th, 2010
+	 * @version 1.9
+	 * @package PegasusPHP
+	 *
+	 * Copyright (C) 2008-2010 Chris Schuld  (chris@chrisschuld.com)
+	 *
+	 * 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.
+	 *
+	 * This program is distributed in the hope that it will be useful,
+	 * but WITHOUT ANY WARRANTY; without even the implied warranty of
+	 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+	 * GNU General Public License for more details at:
+	 * http://www.gnu.org/copyleft/gpl.html
+	 *
+	 *
+	 * Typical Usage:
+	 *
+	 *   $browser = new Browser();
+	 *   if( $browser->getBrowser() == Browser::BROWSER_FIREFOX && $browser->getVersion() >= 2 ) {
+	 *   	echo 'You have FireFox version 2 or greater';
+	 *   }
+	 *
+	 * User Agents Sampled from: http://www.useragentstring.com/
+	 *
+	 * This implementation is based on the original work from Gary White
+	 * http://apptools.com/phptools/browser/
+	 *
+	 * UPDATES:
+	 *
+	 * 2010-08-20 (v1.9):
+	 *  + Added MSN Explorer Browser (legacy)
+	 *  + Added Bing/MSN Robot (Thanks Rob MacDonald)
+	 *  + Added the Android Platform (PLATFORM_ANDROID)
+	 *  + Fixed issue with Android 1.6/2.2 (Thanks Tom Hirashima)
+	 *
+	 * 2010-04-27 (v1.8):
+	 *  + Added iPad Support
+	 *
+	 * 2010-03-07 (v1.7):
+	 *  + *MAJOR* Rebuild (preg_match and other "slow" routine removal(s))
+	 *  + Almost allof Gary's original code has been replaced
+	 *  + Large PHPUNIT testing environment created to validate new releases and additions
+	 *  + Added FreeBSD Platform
+	 *  + Added OpenBSD Platform
+	 *  + Added NetBSD Platform
+	 *  + Added SunOS Platform
+	 *  + Added OpenSolaris Platform
+	 *  + Added support of the Iceweazel Browser
+	 *  + Added isChromeFrame() call to check if chromeframe is in use
+	 *  + Moved the Opera check in front of the Firefox check due to legacy Opera User Agents
+	 *  + Added the __toString() method (Thanks Deano)
+	 *
+	 * 2009-11-15:
+	 *  + Updated the checkes for Firefox
+	 *  + Added the NOKIA platform
+	 *  + Added Checks for the NOKIA brower(s)
+	 *  
+	 * 2009-11-08:
+	 *  + PHP 5.3 Support
+	 *  + Added support for BlackBerry OS and BlackBerry browser
+	 *  + Added support for the Opera Mini browser
+	 *  + Added additional documenation
+	 *  + Added support for isRobot() and isMobile()
+	 *  + Added support for Opera version 10
+	 *  + Added support for deprecated Netscape Navigator version 9
+	 *  + Added support for IceCat
+	 *  + Added support for Shiretoko
+	 *
+	 * 2010-04-27 (v1.8):
+	 *  + Added iPad Support
+	 *
+	 * 2009-08-18:
+	 *  + Updated to support PHP 5.3 - removed all deprecated function calls
+	 *  + Updated to remove all double quotes (") -- converted to single quotes (')
+	 *
+	 * 2009-04-27:
+	 *  + Updated the IE check to remove a typo and bug (thanks John)
+	 *
+	 * 2009-04-22:
+	 *  + Added detection for GoogleBot
+	 *  + Added detection for the W3C Validator.
+	 *  + Added detection for Yahoo! Slurp
+	 *
+	 * 2009-03-14:
+	 *  + Added detection for iPods.
+	 *  + Added Platform detection for iPhones
+	 *  + Added Platform detection for iPods
+	 *
+	 * 2009-02-16: (Rick Hale)
+	 *  + Added version detection for Android phones.
+	 *
+	 * 2008-12-09:
+	 *  + Removed unused constant
+	 *
+	 * 2008-11-07:
+	 *  + Added Google's Chrome to the detection list
+	 *  + Added isBrowser(string) to the list of functions special thanks to
+	 *    Daniel 'mavrick' Lang for the function concept (http://mavrick.id.au)
+	 *
+	 *
+	 * Gary White noted: "Since browser detection is so unreliable, I am
+	 * no longer maintaining this script. You are free to use and or
+	 * modify/update it as you want, however the author assumes no
+	 * responsibility for the accuracy of the detected values."
+	 *
+	 * Anyone experienced with Gary's script might be interested in these notes:
+	 *
+	 *   Added class constants
+	 *   Added detection and version detection for Google's Chrome
+	 *   Updated the version detection for Amaya
+	 *   Updated the version detection for Firefox
+	 *   Updated the version detection for Lynx
+	 *   Updated the version detection for WebTV
+	 *   Updated the version detection for NetPositive
+	 *   Updated the version detection for IE
+	 *   Updated the version detection for OmniWeb
+	 *   Updated the version detection for iCab
+	 *   Updated the version detection for Safari
+	 *   Updated Safari to remove mobile devices (iPhone)
+	 *   Added detection for iPhone
+	 *   Added detection for robots
+	 *   Added detection for mobile devices
+	 *   Added detection for BlackBerry
+	 *   Removed Netscape checks (matches heavily with firefox & mozilla)
+	 *
+	 */
+
+	class Browser {
+		private $_agent = '';
+		private $_browser_name = '';
+		private $_version = '';
+		private $_platform = '';
+		private $_os = '';
+		private $_is_aol = false;
+		private $_is_mobile = false;
+		private $_is_robot = false;
+		private $_aol_version = '';
+
+		const BROWSER_UNKNOWN = 'unknown';
+		const VERSION_UNKNOWN = 'unknown';
+
+		const BROWSER_OPERA = 'Opera';                            // http://www.opera.com/
+		const BROWSER_OPERA_MINI = 'Opera Mini';                  // http://www.opera.com/mini/
+		const BROWSER_WEBTV = 'WebTV';                            // http://www.webtv.net/pc/
+		const BROWSER_IE = 'Internet Explorer';                   // http://www.microsoft.com/ie/
+		const BROWSER_POCKET_IE = 'Pocket Internet Explorer';     // http://en.wikipedia.org/wiki/Internet_Explorer_Mobile
+		const BROWSER_KONQUEROR = 'Konqueror';                    // http://www.konqueror.org/
+		const BROWSER_ICAB = 'iCab';                              // http://www.icab.de/
+		const BROWSER_OMNIWEB = 'OmniWeb';                        // http://www.omnigroup.com/applications/omniweb/
+		const BROWSER_FIREBIRD = 'Firebird';                      // http://www.ibphoenix.com/
+		const BROWSER_FIREFOX = 'Firefox';                        // http://www.mozilla.com/en-US/firefox/firefox.html
+		const BROWSER_ICEWEASEL = 'Iceweasel';                    // http://www.geticeweasel.org/
+		const BROWSER_SHIRETOKO = 'Shiretoko';                    // http://wiki.mozilla.org/Projects/shiretoko
+		const BROWSER_MOZILLA = 'Mozilla';                        // http://www.mozilla.com/en-US/
+		const BROWSER_AMAYA = 'Amaya';                            // http://www.w3.org/Amaya/
+		const BROWSER_LYNX = 'Lynx';                              // http://en.wikipedia.org/wiki/Lynx
+		const BROWSER_SAFARI = 'Safari';                          // http://apple.com
+		const BROWSER_IPHONE = 'iPhone';                          // http://apple.com
+		const BROWSER_IPOD = 'iPod';                              // http://apple.com
+		const BROWSER_IPAD = 'iPad';                              // http://apple.com
+		const BROWSER_CHROME = 'Chrome';                          // http://www.google.com/chrome
+		const BROWSER_ANDROID = 'Android';                        // http://www.android.com/
+		const BROWSER_GOOGLEBOT = 'GoogleBot';                    // http://en.wikipedia.org/wiki/Googlebot
+		const BROWSER_SLURP = 'Yahoo! Slurp';                     // http://en.wikipedia.org/wiki/Yahoo!_Slurp
+		const BROWSER_W3CVALIDATOR = 'W3C Validator';             // http://validator.w3.org/
+		const BROWSER_BLACKBERRY = 'BlackBerry';                  // http://www.blackberry.com/
+		const BROWSER_ICECAT = 'IceCat';                          // http://en.wikipedia.org/wiki/GNU_IceCat
+		const BROWSER_NOKIA_S60 = 'Nokia S60 OSS Browser';        // http://en.wikipedia.org/wiki/Web_Browser_for_S60
+		const BROWSER_NOKIA = 'Nokia Browser';                    // * all other WAP-based browsers on the Nokia Platform
+		const BROWSER_MSN = 'MSN Browser';                        // http://explorer.msn.com/
+		const BROWSER_MSNBOT = 'MSN Bot';                         // http://search.msn.com/msnbot.htm
+		                                                          // http://en.wikipedia.org/wiki/Msnbot  (used for Bing as well)
+		
+		const BROWSER_NETSCAPE_NAVIGATOR = 'Netscape Navigator';  // http://browser.netscape.com/ (DEPRECATED)
+		const BROWSER_GALEON = 'Galeon';                          // http://galeon.sourceforge.net/ (DEPRECATED)
+		const BROWSER_NETPOSITIVE = 'NetPositive';                // http://en.wikipedia.org/wiki/NetPositive (DEPRECATED)
+		const BROWSER_PHOENIX = 'Phoenix';                        // http://en.wikipedia.org/wiki/History_of_Mozilla_Firefox (DEPRECATED)
+
+		const PLATFORM_UNKNOWN = 'unknown';
+		const PLATFORM_WINDOWS = 'Windows';
+		const PLATFORM_WINDOWS_CE = 'Windows CE';
+		const PLATFORM_APPLE = 'Apple';
+		const PLATFORM_LINUX = 'Linux';
+		const PLATFORM_OS2 = 'OS/2';
+		const PLATFORM_BEOS = 'BeOS';
+		const PLATFORM_IPHONE = 'iPhone';
+		const PLATFORM_IPOD = 'iPod';
+		const PLATFORM_IPAD = 'iPad';
+		const PLATFORM_BLACKBERRY = 'BlackBerry';
+		const PLATFORM_NOKIA = 'Nokia';
+		const PLATFORM_FREEBSD = 'FreeBSD';
+		const PLATFORM_OPENBSD = 'OpenBSD';
+		const PLATFORM_NETBSD = 'NetBSD';
+		const PLATFORM_SUNOS = 'SunOS';
+		const PLATFORM_OPENSOLARIS = 'OpenSolaris';
+		const PLATFORM_ANDROID = 'Android';
+		
+		const OPERATING_SYSTEM_UNKNOWN = 'unknown';
+
+		public function Browser($useragent="") {
+			$this->reset();
+			if( $useragent != "" ) {
+				$this->setUserAgent($useragent);
+			}
+			else {
+				$this->determine();
+			}
+		}
+
+		/**
+		* Reset all properties
+		*/
+		public function reset() {
+			$this->_agent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : "";
+			$this->_browser_name = self::BROWSER_UNKNOWN;
+			$this->_version = self::VERSION_UNKNOWN;
+			$this->_platform = self::PLATFORM_UNKNOWN;
+			$this->_os = self::OPERATING_SYSTEM_UNKNOWN;
+			$this->_is_aol = false;
+			$this->_is_mobile = false;
+			$this->_is_robot = false;
+			$this->_aol_version = self::VERSION_UNKNOWN;
+		}
+
+		/**
+		* Check to see if the specific browser is valid
+		* @param string $browserName
+		* @return True if the browser is the specified browser
+		*/
+		function isBrowser($browserName) { return( 0 == strcasecmp($this->_browser_name, trim($browserName))); }
+
+		/**
+		* The name of the browser.  All return types are from the class contants
+		* @return string Name of the browser
+		*/
+		public function getBrowser() { return $this->_browser_name; }
+		/**
+		* Set the name of the browser
+		* @param $browser The name of the Browser
+		*/
+		public function setBrowser($browser) { return $this->_browser_name = $browser; }
+		/**
+		* The name of the platform.  All return types are from the class contants
+		* @return string Name of the browser
+		*/
+		public function getPlatform() { return $this->_platform; }
+		/**
+		* Set the name of the platform
+		* @param $platform The name of the Platform
+		*/
+		public function setPlatform($platform) { return $this->_platform = $platform; }
+		/**
+		* The version of the browser.
+		* @return string Version of the browser (will only contain alpha-numeric characters and a period)
+		*/
+		public function getVersion() { return $this->_version; }
+		/**
+		* Set the version of the browser
+		* @param $version The version of the Browser
+		*/
+		public function setVersion($version) { $this->_version = preg_replace('/[^0-9,.,a-z,A-Z-]/','',$version); }
+		/**
+		* The version of AOL.
+		* @return string Version of AOL (will only contain alpha-numeric characters and a period)
+		*/
+		public function getAolVersion() { return $this->_aol_version; }
+		/**
+		* Set the version of AOL
+		* @param $version The version of AOL
+		*/
+		public function setAolVersion($version) { $this->_aol_version = preg_replace('/[^0-9,.,a-z,A-Z]/','',$version); }
+		/**
+		* Is the browser from AOL?
+		* @return boolean True if the browser is from AOL otherwise false
+		*/
+		public function isAol() { return $this->_is_aol; }
+		/**
+		* Is the browser from a mobile device?
+		* @return boolean True if the browser is from a mobile device otherwise false
+		*/
+		public function isMobile() { return $this->_is_mobile; }
+		/**
+		* Is the browser from a robot (ex Slurp,GoogleBot)?
+		* @return boolean True if the browser is from a robot otherwise false
+		*/
+		public function isRobot() { return $this->_is_robot; }
+		/**
+		* Set the browser to be from AOL
+		* @param $isAol
+		*/
+		public function setAol($isAol) { $this->_is_aol = $isAol; }
+		/**
+		 * Set the Browser to be mobile
+		 * @param boolean $value is the browser a mobile brower or not
+		 */
+		protected function setMobile($value=true) { $this->_is_mobile = $value; }
+		/**
+		 * Set the Browser to be a robot
+		 * @param boolean $value is the browser a robot or not
+		 */
+		protected function setRobot($value=true) { $this->_is_robot = $value; }
+		/**
+		* Get the user agent value in use to determine the browser
+		* @return string The user agent from the HTTP header
+		*/
+		public function getUserAgent() { return $this->_agent; }
+		/**
+		* Set the user agent value (the construction will use the HTTP header value - this will overwrite it)
+		* @param $agent_string The value for the User Agent
+		*/
+		public function setUserAgent($agent_string) {
+			$this->reset();
+			$this->_agent = $agent_string;
+			$this->determine();
+		}
+		/**
+		 * Used to determine if the browser is actually "chromeframe"
+		 * @since 1.7
+		 * @return boolean True if the browser is using chromeframe
+		 */
+		public function isChromeFrame() {
+			return( strpos($this->_agent,"chromeframe") !== false );
+		}
+		/**
+		* Returns a formatted string with a summary of the details of the browser.
+		* @return string formatted string with a summary of the browser
+		*/
+		public function __toString() {
+			return "<strong>Browser Name:</strong>{$this->getBrowser()}<br/>\n" .
+			       "<strong>Browser Version:</strong>{$this->getVersion()}<br/>\n" .
+			       "<strong>Browser User Agent String:</strong>{$this->getUserAgent()}<br/>\n" .
+			       "<strong>Platform:</strong>{$this->getPlatform()}<br/>";
+		}
+		/**
+		 * Protected routine to calculate and determine what the browser is in use (including platform)
+		 */
+		protected function determine() {
+			$this->checkPlatform();
+			$this->checkBrowsers();
+			$this->checkForAol();
+		}
+		/**
+		 * Protected routine to determine the browser type
+		 * @return boolean True if the browser was detected otherwise false
+		 */
+		 protected function checkBrowsers() {
+			return (
+				// well-known, well-used
+				// Special Notes:
+				// (1) Opera must be checked before FireFox due to the odd
+				//     user agents used in some older versions of Opera
+				// (2) WebTV is strapped onto Internet Explorer so we must
+				//     check for WebTV before IE
+				// (3) (deprecated) Galeon is based on Firefox and needs to be
+				//     tested before Firefox is tested
+				// (4) OmniWeb is based on Safari so OmniWeb check must occur
+				//     before Safari
+				// (5) Netscape 9+ is based on Firefox so Netscape checks
+				//     before FireFox are necessary
+				$this->checkBrowserWebTv() ||
+				$this->checkBrowserInternetExplorer() ||
+				$this->checkBrowserOpera() ||
+				$this->checkBrowserGaleon() ||
+				$this->checkBrowserNetscapeNavigator9Plus() ||
+				$this->checkBrowserFirefox() ||
+				$this->checkBrowserChrome() ||
+				$this->checkBrowserOmniWeb() ||
+
+				// common mobile
+				$this->checkBrowserAndroid() ||
+				$this->checkBrowseriPad() ||
+				$this->checkBrowseriPod() ||
+				$this->checkBrowseriPhone() ||
+				$this->checkBrowserBlackBerry() ||
+				$this->checkBrowserNokia() ||
+
+				// common bots
+				$this->checkBrowserGoogleBot() ||
+				$this->checkBrowserMSNBot() ||
+				$this->checkBrowserSlurp() ||
+
+				// WebKit base check (post mobile and others)
+				$this->checkBrowserSafari() ||
+				
+				// everyone else
+				$this->checkBrowserNetPositive() ||
+				$this->checkBrowserFirebird() ||
+				$this->checkBrowserKonqueror() ||
+				$this->checkBrowserIcab() ||
+				$this->checkBrowserPhoenix() ||
+				$this->checkBrowserAmaya() ||
+				$this->checkBrowserLynx() ||
+				$this->checkBrowserShiretoko() ||
+				$this->checkBrowserIceCat() ||
+				$this->checkBrowserW3CValidator() ||
+				$this->checkBrowserMozilla() /* Mozilla is such an open standard that you must check it last */
+			);
+	    }
+
+	    /**
+	     * Determine if the user is using a BlackBerry (last updated 1.7)
+	     * @return boolean True if the browser is the BlackBerry browser otherwise false
+	     */
+	    protected function checkBrowserBlackBerry() {
+		    if( stripos($this->_agent,'blackberry') !== false ) {
+			    $aresult = explode("/",stristr($this->_agent,"BlackBerry"));
+			    $aversion = explode(' ',$aresult[1]);
+			    $this->setVersion($aversion[0]);
+			    $this->_browser_name = self::BROWSER_BLACKBERRY;
+			    $this->setMobile(true);
+			    return true;
+		    }
+		    return false;
+	    }
+
+	    /**
+	     * Determine if the user is using an AOL User Agent (last updated 1.7)
+	     * @return boolean True if the browser is from AOL otherwise false
+	     */
+	    protected function checkForAol() {
+			$this->setAol(false);
+			$this->setAolVersion(self::VERSION_UNKNOWN);
+
+			if( stripos($this->_agent,'aol') !== false ) {
+			    $aversion = explode(' ',stristr($this->_agent, 'AOL'));
+			    $this->setAol(true);
+			    $this->setAolVersion(preg_replace('/[^0-9\.a-z]/i', '', $aversion[1]));
+			    return true;
+		    }
+		    return false;
+	    }
+
+	    /**
+	     * Determine if the browser is the GoogleBot or not (last updated 1.7)
+	     * @return boolean True if the browser is the GoogletBot otherwise false
+	     */
+	    protected function checkBrowserGoogleBot() {
+		    if( stripos($this->_agent,'googlebot') !== false ) {
+				$aresult = explode('/',stristr($this->_agent,'googlebot'));
+				$aversion = explode(' ',$aresult[1]);
+				$this->setVersion(str_replace(';','',$aversion[0]));
+				$this->_browser_name = self::BROWSER_GOOGLEBOT;
+				$this->setRobot(true);
+				return true;
+		    }
+		    return false;
+	    }
+
+		/**
+	     * Determine if the browser is the MSNBot or not (last updated 1.9)
+	     * @return boolean True if the browser is the MSNBot otherwise false
+	     */
+		protected function checkBrowserMSNBot() {
+			if( stripos($this->_agent,"msnbot") !== false ) {
+				$aresult = explode("/",stristr($this->_agent,"msnbot"));
+				$aversion = explode(" ",$aresult[1]);
+				$this->setVersion(str_replace(";","",$aversion[0]));
+				$this->_browser_name = self::BROWSER_MSNBOT;
+				$this->setRobot(true);
+				return true;
+			}
+			return false;
+		}	    
+	    
+	    /**
+	     * Determine if the browser is the W3C Validator or not (last updated 1.7)
+	     * @return boolean True if the browser is the W3C Validator otherwise false
+	     */
+	    protected function checkBrowserW3CValidator() {
+		    if( stripos($this->_agent,'W3C-checklink') !== false ) {
+			    $aresult = explode('/',stristr($this->_agent,'W3C-checklink'));
+			    $aversion = explode(' ',$aresult[1]);
+			    $this->setVersion($aversion[0]);
+			    $this->_browser_name = self::BROWSER_W3CVALIDATOR;
+			    return true;
+		    }
+		    else if( stripos($this->_agent,'W3C_Validator') !== false ) {
+				// Some of the Validator versions do not delineate w/ a slash - add it back in
+				$ua = str_replace("W3C_Validator ", "W3C_Validator/", $this->_agent);
+			    $aresult = explode('/',stristr($ua,'W3C_Validator'));
+			    $aversion = explode(' ',$aresult[1]);
+			    $this->setVersion($aversion[0]);
+			    $this->_browser_name = self::BROWSER_W3CVALIDATOR;
+			    return true;
+		    }
+		    return false;
+	    }
+
+	    /**
+	     * Determine if the browser is the Yahoo! Slurp Robot or not (last updated 1.7)
+	     * @return boolean True if the browser is the Yahoo! Slurp Robot otherwise false
+	     */
+	    protected function checkBrowserSlurp() {
+		    if( stripos($this->_agent,'slurp') !== false ) {
+			    $aresult = explode('/',stristr($this->_agent,'Slurp'));
+			    $aversion = explode(' ',$aresult[1]);
+			    $this->setVersion($aversion[0]);
+			    $this->_browser_name = self::BROWSER_SLURP;
+				$this->setRobot(true);
+				$this->setMobile(false);
+			    return true;
+		    }
+		    return false;
+	    }
+
+	    /**
+	     * Determine if the browser is Internet Explorer or not (last updated 1.7)
+	     * @return boolean True if the browser is Internet Explorer otherwise false
+	     */
+	    protected function checkBrowserInternetExplorer() {
+
+		    // Test for v1 - v1.5 IE
+		    if( stripos($this->_agent,'microsoft internet explorer') !== false ) {
+			    $this->setBrowser(self::BROWSER_IE);
+			    $this->setVersion('1.0');
+			    $aresult = stristr($this->_agent, '/');
+			    if( preg_match('/308|425|426|474|0b1/i', $aresult) ) {
+				    $this->setVersion('1.5');
+			    }
+				return true;
+		    }
+		    // Test for versions > 1.5
+		    else if( stripos($this->_agent,'msie') !== false && stripos($this->_agent,'opera') === false ) {
+		    	// See if the browser is the odd MSN Explorer
+		    	if( stripos($this->_agent,'msnb') !== false ) {
+			    	$aresult = explode(' ',stristr(str_replace(';','; ',$this->_agent),'MSN'));
+				    $this->setBrowser( self::BROWSER_MSN );
+				    $this->setVersion(str_replace(array('(',')',';'),'',$aresult[1]));
+				    return true;
+		    	}
+		    	$aresult = explode(' ',stristr(str_replace(';','; ',$this->_agent),'msie'));
+		    	$this->setBrowser( self::BROWSER_IE );
+		    	$this->setVersion(str_replace(array('(',')',';'),'',$aresult[1]));
+		    	return true;
+		    }
+		    // Test for Pocket IE
+		    else if( stripos($this->_agent,'mspie') !== false || stripos($this->_agent,'pocket') !== false ) {
+			    $aresult = explode(' ',stristr($this->_agent,'mspie'));
+			    $this->setPlatform( self::PLATFORM_WINDOWS_CE );
+			    $this->setBrowser( self::BROWSER_POCKET_IE );
+			    $this->setMobile(true);
+
+			    if( stripos($this->_agent,'mspie') !== false ) {
+				    $this->setVersion($aresult[1]);
+			    }
+			    else {
+				    $aversion = explode('/',$this->_agent);
+				    $this->setVersion($aversion[1]);
+			    }
+			    return true;
+		    }
+			return false;
+	    }
+
+	    /**
+	     * Determine if the browser is Opera or not (last updated 1.7)
+	     * @return boolean True if the browser is Opera otherwise false
+	     */
+	    protected function checkBrowserOpera() {
+		    if( stripos($this->_agent,'opera mini') !== false ) {
+			    $resultant = stristr($this->_agent, 'opera mini');
+			    if( preg_match('/\//',$resultant) ) {
+				    $aresult = explode('/',$resultant);
+				    $aversion = explode(' ',$aresult[1]);
+				    $this->setVersion($aversion[0]);
+				}
+			    else {
+				    $aversion = explode(' ',stristr($resultant,'opera mini'));
+				    $this->setVersion($aversion[1]);
+			    }
+			    $this->_browser_name = self::BROWSER_OPERA_MINI;
+				$this->setMobile(true);
+				return true;
+		    }
+		    else if( stripos($this->_agent,'opera') !== false ) {
+			    $resultant = stristr($this->_agent, 'opera');
+			    if( preg_match('/Version\/(10.*)$/',$resultant,$matches) ) {
+				    $this->setVersion($matches[1]);
+			    }
+			    else if( preg_match('/\//',$resultant) ) {
+				    $aresult = explode('/',str_replace("("," ",$resultant));
+				    $aversion = explode(' ',$aresult[1]);
+				    $this->setVersion($aversion[0]);
+			    }
+			    else {
+				    $aversion = explode(' ',stristr($resultant,'opera'));
+				    $this->setVersion(isset($aversion[1])?$aversion[1]:"");
+			    }
+			    $this->_browser_name = self::BROWSER_OPERA;
+			    return true;
+		    }
+			return false;
+	    }
+
+	    /**
+	     * Determine if the browser is Chrome or not (last updated 1.7)
+	     * @return boolean True if the browser is Chrome otherwise false
+	     */
+	    protected function checkBrowserChrome() {
+		    if( stripos($this->_agent,'Chrome') !== false ) {
+			    $aresult = explode('/',stristr($this->_agent,'Chrome'));
+			    $aversion = explode(' ',$aresult[1]);
+			    $this->setVersion($aversion[0]);
+			    $this->setBrowser(self::BROWSER_CHROME);
+			    return true;
+		    }
+		    return false;
+	    }
+
+
+	    /**
+	     * Determine if the browser is WebTv or not (last updated 1.7)
+	     * @return boolean True if the browser is WebTv otherwise false
+	     */
+	    protected function checkBrowserWebTv() {
+		    if( stripos($this->_agent,'webtv') !== false ) {
+			    $aresult = explode('/',stristr($this->_agent,'webtv'));
+			    $aversion = explode(' ',$aresult[1]);
+			    $this->setVersion($aversion[0]);
+			    $this->setBrowser(self::BROWSER_WEBTV);
+			    return true;
+		    }
+		    return false;
+	    }
+
+	    /**
+	     * Determine if the browser is NetPositive or not (last updated 1.7)
+	     * @return boolean True if the browser is NetPositive otherwise false
+	     */
+	    protected function checkBrowserNetPositive() {
+		    if( stripos($this->_agent,'NetPositive') !== false ) {
+			    $aresult = explode('/',stristr($this->_agent,'NetPositive'));
+			    $aversion = explode(' ',$aresult[1]);
+			    $this->setVersion(str_replace(array('(',')',';'),'',$aversion[0]));
+			    $this->setBrowser(self::BROWSER_NETPOSITIVE);
+			    return true;
+		    }
+		    return false;
+	    }
+
+	    /**
+	     * Determine if the browser is Galeon or not (last updated 1.7)
+	     * @return boolean True if the browser is Galeon otherwise false
+	     */
+	    protected function checkBrowserGaleon() {
+		    if( stripos($this->_agent,'galeon') !== false ) {
+			    $aresult = explode(' ',stristr($this->_agent,'galeon'));
+			    $aversion = explode('/',$aresult[0]);
+			    $this->setVersion($aversion[1]);
+			    $this->setBrowser(self::BROWSER_GALEON);
+			    return true;
+		    }
+		    return false;
+	    }
+
+	    /**
+	     * Determine if the browser is Konqueror or not (last updated 1.7)
+	     * @return boolean True if the browser is Konqueror otherwise false
+	     */
+	    protected function checkBrowserKonqueror() {
+		    if( stripos($this->_agent,'Konqueror') !== false ) {
+			    $aresult = explode(' ',stristr($this->_agent,'Konqueror'));
+			    $aversion = explode('/',$aresult[0]);
+			    $this->setVersion($aversion[1]);
+			    $this->setBrowser(self::BROWSER_KONQUEROR);
+			    return true;
+		    }
+		    return false;
+	    }
+
+	    /**
+	     * Determine if the browser is iCab or not (last updated 1.7)
+	     * @return boolean True if the browser is iCab otherwise false
+	     */
+	    protected function checkBrowserIcab() {
+		    if( stripos($this->_agent,'icab') !== false ) {
+			    $aversion = explode(' ',stristr(str_replace('/',' ',$this->_agent),'icab'));
+			    $this->setVersion($aversion[1]);
+			    $this->setBrowser(self::BROWSER_ICAB);
+			    return true;
+		    }
+		    return false;
+	    }
+
+	    /**
+	     * Determine if the browser is OmniWeb or not (last updated 1.7)
+	     * @return boolean True if the browser is OmniWeb otherwise false
+	     */
+	    protected function checkBrowserOmniWeb() {
+		    if( stripos($this->_agent,'omniweb') !== false ) {
+			    $aresult = explode('/',stristr($this->_agent,'omniweb'));
+			    $aversion = explode(' ',isset($aresult[1])?$aresult[1]:"");
+			    $this->setVersion($aversion[0]);
+			    $this->setBrowser(self::BROWSER_OMNIWEB);
+			    return true;
+		    }
+		    return false;
+	    }
+
+	    /**
+	     * Determine if the browser is Phoenix or not (last updated 1.7)
+	     * @return boolean True if the browser is Phoenix otherwise false
+	     */
+	    protected function checkBrowserPhoenix() {
+		    if( stripos($this->_agent,'Phoenix') !== false ) {
+			    $aversion = explode('/',stristr($this->_agent,'Phoenix'));
+			    $this->setVersion($aversion[1]);
+			    $this->setBrowser(self::BROWSER_PHOENIX);
+			    return true;
+		    }
+		    return false;
+	    }
+
+	    /**
+	     * Determine if the browser is Firebird or not (last updated 1.7)
+	     * @return boolean True if the browser is Firebird otherwise false
+	     */
+	    protected function checkBrowserFirebird() {
+		    if( stripos($this->_agent,'Firebird') !== false ) {
+			    $aversion = explode('/',stristr($this->_agent,'Firebird'));
+			    $this->setVersion($aversion[1]);
+			    $this->setBrowser(self::BROWSER_FIREBIRD);
+				return true;
+		    }
+		    return false;
+	    }
+
+	    /**
+	     * Determine if the browser is Netscape Navigator 9+ or not (last updated 1.7)
+		 * NOTE: (http://browser.netscape.com/ - Official support ended on March 1st, 2008)
+	     * @return boolean True if the browser is Netscape Navigator 9+ otherwise false
+	     */
+	    protected function checkBrowserNetscapeNavigator9Plus() {
+		    if( stripos($this->_agent,'Firefox') !== false && preg_match('/Navigator\/([^ ]*)/i',$this->_agent,$matches) ) {
+			    $this->setVersion($matches[1]);
+			    $this->setBrowser(self::BROWSER_NETSCAPE_NAVIGATOR);
+			    return true;
+		    }
+		    else if( stripos($this->_agent,'Firefox') === false && preg_match('/Netscape6?\/([^ ]*)/i',$this->_agent,$matches) ) {
+			    $this->setVersion($matches[1]);
+			    $this->setBrowser(self::BROWSER_NETSCAPE_NAVIGATOR);
+			    return true;
+		    }
+		    return false;
+	    }
+
+	    /**
+	     * Determine if the browser is Shiretoko or not (https://wiki.mozilla.org/Projects/shiretoko) (last updated 1.7)
+	     * @return boolean True if the browser is Shiretoko otherwise false
+	     */
+	    protected function checkBrowserShiretoko() {
+		    if( stripos($this->_agent,'Mozilla') !== false && preg_match('/Shiretoko\/([^ ]*)/i',$this->_agent,$matches) ) {
+			    $this->setVersion($matches[1]);
+			    $this->setBrowser(self::BROWSER_SHIRETOKO);
+			    return true;
+		    }
+		    return false;
+	    }
+
+	    /**
+	     * Determine if the browser is Ice Cat or not (http://en.wikipedia.org/wiki/GNU_IceCat) (last updated 1.7)
+	     * @return boolean True if the browser is Ice Cat otherwise false
+	     */
+	    protected function checkBrowserIceCat() {
+		    if( stripos($this->_agent,'Mozilla') !== false && preg_match('/IceCat\/([^ ]*)/i',$this->_agent,$matches) ) {
+			    $this->setVersion($matches[1]);
+			    $this->setBrowser(self::BROWSER_ICECAT);
+			    return true;
+		    }
+		    return false;
+	    }
+
+	    /**
+	     * Determine if the browser is Nokia or not (last updated 1.7)
+	     * @return boolean True if the browser is Nokia otherwise false
+	     */
+	    protected function checkBrowserNokia() {
+		    if( preg_match("/Nokia([^\/]+)\/([^ SP]+)/i",$this->_agent,$matches) ) {
+			    $this->setVersion($matches[2]);
+				if( stripos($this->_agent,'Series60') !== false || strpos($this->_agent,'S60') !== false ) {
+					$this->setBrowser(self::BROWSER_NOKIA_S60);
+				}
+				else {
+					$this->setBrowser( self::BROWSER_NOKIA );
+				}
+			    $this->setMobile(true);
+			    return true;
+		    }
+			return false;
+	    }
+
+	    /**
+	     * Determine if the browser is Firefox or not (last updated 1.7)
+	     * @return boolean True if the browser is Firefox otherwise false
+	     */
+	    protected function checkBrowserFirefox() {
+		    if( stripos($this->_agent,'safari') === false ) {
+				if( preg_match("/Firefox[\/ \(]([^ ;\)]+)/i",$this->_agent,$matches) ) {
+					$this->setVersion($matches[1]);
+					$this->setBrowser(self::BROWSER_FIREFOX);
+					return true;
+				}
+				else if( preg_match("/Firefox$/i",$this->_agent,$matches) ) {
+					$this->setVersion("");
+					$this->setBrowser(self::BROWSER_FIREFOX);
+					return true;
+				}
+			}
+		    return false;
+	    }
+
+		/**
+	     * Determine if the browser is Firefox or not (last updated 1.7)
+	     * @return boolean True if the browser is Firefox otherwise false
+	     */
+	    protected function checkBrowserIceweasel() {
+			if( stripos($this->_agent,'Iceweasel') !== false ) {
+				$aresult = explode('/',stristr($this->_agent,'Iceweasel'));
+				$aversion = explode(' ',$aresult[1]);
+				$this->setVersion($aversion[0]);
+				$this->setBrowser(self::BROWSER_ICEWEASEL);
+				return true;
+			}
+			return false;
+		}
+	    /**
+	     * Determine if the browser is Mozilla or not (last updated 1.7)
+	     * @return boolean True if the browser is Mozilla otherwise false
+	     */
+	    protected function checkBrowserMozilla() {
+		    if( stripos($this->_agent,'mozilla') !== false  && preg_match('/rv:[0-9].[0-9][a-b]?/i',$this->_agent) && stripos($this->_agent,'netscape') === false) {
+			    $aversion = explode(' ',stristr($this->_agent,'rv:'));
+			    preg_match('/rv:[0-9].[0-9][a-b]?/i',$this->_agent,$aversion);
+			    $this->setVersion(str_replace('rv:','',$aversion[0]));
+			    $this->setBrowser(self::BROWSER_MOZILLA);
+			    return true;
+		    }
+		    else if( stripos($this->_agent,'mozilla') !== false && preg_match('/rv:[0-9]\.[0-9]/i',$this->_agent) && stripos($this->_agent,'netscape') === false ) {
+			    $aversion = explode('',stristr($this->_agent,'rv:'));
+			    $this->setVersion(str_replace('rv:','',$aversion[0]));
+			    $this->setBrowser(self::BROWSER_MOZILLA);
+			    return true;
+		    }
+		    else if( stripos($this->_agent,'mozilla') !== false  && preg_match('/mozilla\/([^ ]*)/i',$this->_agent,$matches) && stripos($this->_agent,'netscape') === false ) {
+			    $this->setVersion($matches[1]);
+			    $this->setBrowser(self::BROWSER_MOZILLA);
+			    return true;
+		    }
+			return false;
+	    }
+
+	    /**
+	     * Determine if the browser is Lynx or not (last updated 1.7)
+	     * @return boolean True if the browser is Lynx otherwise false
+	     */
+	    protected function checkBrowserLynx() {
+		    if( stripos($this->_agent,'lynx') !== false ) {
+			    $aresult = explode('/',stristr($this->_agent,'Lynx'));
+			    $aversion = explode(' ',(isset($aresult[1])?$aresult[1]:""));
+			    $this->setVersion($aversion[0]);
+			    $this->setBrowser(self::BROWSER_LYNX);
+			    return true;
+		    }
+		    return false;
+	    }
+
+	    /**
+	     * Determine if the browser is Amaya or not (last updated 1.7)
+	     * @return boolean True if the browser is Amaya otherwise false
+	     */
+	    protected function checkBrowserAmaya() {
+		    if( stripos($this->_agent,'amaya') !== false ) {
+			    $aresult = explode('/',stristr($this->_agent,'Amaya'));
+			    $aversion = explode(' ',$aresult[1]);
+			    $this->setVersion($aversion[0]);
+			    $this->setBrowser(self::BROWSER_AMAYA);
+			    return true;
+		    }
+		    return false;
+	    }
+
+	    /**
+	     * Determine if the browser is Safari or not (last updated 1.7)
+	     * @return boolean True if the browser is Safari otherwise false
+	     */
+	    protected function checkBrowserSafari() {
+		    if( stripos($this->_agent,'Safari') !== false && stripos($this->_agent,'iPhone') === false && stripos($this->_agent,'iPod') === false ) {
+			    $aresult = explode('/',stristr($this->_agent,'Version'));
+			    if( isset($aresult[1]) ) {
+				    $aversion = explode(' ',$aresult[1]);
+				    $this->setVersion($aversion[0]);
+			    }
+			    else {
+				    $this->setVersion(self::VERSION_UNKNOWN);
+			    }
+			    $this->setBrowser(self::BROWSER_SAFARI);
+			    return true;
+		    }
+		    return false;
+	    }
+
+	    /**
+	     * Determine if the browser is iPhone or not (last updated 1.7)
+	     * @return boolean True if the browser is iPhone otherwise false
+	     */
+	    protected function checkBrowseriPhone() {
+		    if( stripos($this->_agent,'iPhone') !== false ) {
+			    $aresult = explode('/',stristr($this->_agent,'Version'));
+			    if( isset($aresult[1]) ) {
+				    $aversion = explode(' ',$aresult[1]);
+				    $this->setVersion($aversion[0]);
+			    }
+			    else {
+				    $this->setVersion(self::VERSION_UNKNOWN);
+			    }
+			    $this->setMobile(true);
+			    $this->setBrowser(self::BROWSER_IPHONE);
+			    return true;
+		    }
+		    return false;
+	    }
+
+	    /**
+	     * Determine if the browser is iPod or not (last updated 1.7)
+	     * @return boolean True if the browser is iPod otherwise false
+	     */
+	    protected function checkBrowseriPad() {
+		    if( stripos($this->_agent,'iPad') !== false ) {
+			    $aresult = explode('/',stristr($this->_agent,'Version'));
+			    if( isset($aresult[1]) ) {
+				    $aversion = explode(' ',$aresult[1]);
+				    $this->setVersion($aversion[0]);
+			    }
+			    else {
+				    $this->setVersion(self::VERSION_UNKNOWN);
+			    }
+			    $this->setMobile(true);
+			    $this->setBrowser(self::BROWSER_IPAD);
+			    return true;
+		    }
+		    return false;
+	    }
+
+	    /**
+	     * Determine if the browser is iPod or not (last updated 1.7)
+	     * @return boolean True if the browser is iPod otherwise false
+	     */
+	    protected function checkBrowseriPod() {
+		    if( stripos($this->_agent,'iPod') !== false ) {
+			    $aresult = explode('/',stristr($this->_agent,'Version'));
+			    if( isset($aresult[1]) ) {
+				    $aversion = explode(' ',$aresult[1]);
+				    $this->setVersion($aversion[0]);
+			    }
+			    else {
+				    $this->setVersion(self::VERSION_UNKNOWN);
+			    }
+			    $this->setMobile(true);
+			    $this->setBrowser(self::BROWSER_IPOD);
+			    return true;
+		    }
+		    return false;
+	    }
+
+	    /**
+	     * Determine if the browser is Android or not (last updated 1.7)
+	     * @return boolean True if the browser is Android otherwise false
+	     */
+	    protected function checkBrowserAndroid() {
+		    if( stripos($this->_agent,'Android') !== false ) {
+			    $aresult = explode(' ',stristr($this->_agent,'Android'));
+			    if( isset($aresult[1]) ) {
+				    $aversion = explode(' ',$aresult[1]);
+				    $this->setVersion($aversion[0]);
+			    }
+			    else {
+				    $this->setVersion(self::VERSION_UNKNOWN);
+			    }
+			    $this->setMobile(true);
+			    $this->setBrowser(self::BROWSER_ANDROID);
+			    return true;
+		    }
+		    return false;
+	    }
+
+	    /**
+	     * Determine the user's platform (last updated 1.7)
+	     */
+	    protected function checkPlatform() {
+		    if( stripos($this->_agent, 'windows') !== false ) {
+			    $this->_platform = self::PLATFORM_WINDOWS;
+		    }
+		    else if( stripos($this->_agent, 'iPad') !== false ) {
+			    $this->_platform = self::PLATFORM_IPAD;
+		    }
+		    else if( stripos($this->_agent, 'iPod') !== false ) {
+			    $this->_platform = self::PLATFORM_IPOD;
+		    }
+		    else if( stripos($this->_agent, 'iPhone') !== false ) {
+			    $this->_platform = self::PLATFORM_IPHONE;
+		    }
+		    elseif( stripos($this->_agent, 'mac') !== false ) {
+			    $this->_platform = self::PLATFORM_APPLE;
+		    }
+		    elseif( stripos($this->_agent, 'android') !== false ) {
+			    $this->_platform = self::PLATFORM_ANDROID;
+		    }
+		    elseif( stripos($this->_agent, 'linux') !== false ) {
+			    $this->_platform = self::PLATFORM_LINUX;
+		    }
+		    else if( stripos($this->_agent, 'Nokia') !== false ) {
+			    $this->_platform = self::PLATFORM_NOKIA;
+		    }
+		    else if( stripos($this->_agent, 'BlackBerry') !== false ) {
+			    $this->_platform = self::PLATFORM_BLACKBERRY;
+		    }
+		    elseif( stripos($this->_agent,'FreeBSD') !== false ) {
+			    $this->_platform = self::PLATFORM_FREEBSD;
+		    }
+		    elseif( stripos($this->_agent,'OpenBSD') !== false ) {
+			    $this->_platform = self::PLATFORM_OPENBSD;
+		    }
+		    elseif( stripos($this->_agent,'NetBSD') !== false ) {
+			    $this->_platform = self::PLATFORM_NETBSD;
+		    }
+		    elseif( stripos($this->_agent, 'OpenSolaris') !== false ) {
+			    $this->_platform = self::PLATFORM_OPENSOLARIS;
+		    }
+		    elseif( stripos($this->_agent, 'SunOS') !== false ) {
+			    $this->_platform = self::PLATFORM_SUNOS;
+		    }
+		    elseif( stripos($this->_agent, 'OS\/2') !== false ) {
+			    $this->_platform = self::PLATFORM_OS2;
+		    }
+		    elseif( stripos($this->_agent, 'BeOS') !== false ) {
+			    $this->_platform = self::PLATFORM_BEOS;
+		    }
+		    elseif( stripos($this->_agent, 'win') !== false ) {
+			    $this->_platform = self::PLATFORM_WINDOWS;
+		    }
+
+	    }
+    }
+?>

+ 215 - 10
main/inc/lib/course_request.lib.php

@@ -103,7 +103,58 @@ class CourseRequestManager {
         }
         $last_insert_id = Database::get_last_insert_id();
 
-        // TODO: Prepare and send notification e-mail messages.
+        // E-mail notifications.
+
+        // E-mail language: The platform language seems to be the best choice.
+        //$email_language = $course_language;
+        //$email_language = api_get_interface_language();
+        $email_language = api_get_setting('platformLanguage');
+
+        $email_subject = sprintf(get_lang('CourseRequestEmailSubject', null, $email_language), '['.api_get_setting('siteName').']', $code);
+
+        $email_body = get_lang('CourseRequestMailOpening', null, $email_language)."\n\n";
+        $email_body .= get_lang('CourseName', null, $email_language).': '.$title."\n";
+        $email_body .= get_lang('Fac', null, $email_language).': '.$category_code."\n";
+        $email_body .= get_lang('CourseCode', null, $email_language).': '.$code."\n";
+        $email_body .= get_lang('Professor', null, $email_language).': '.api_get_person_name($user_info['firstname'], $user_info['lastname'], null, null, $email_language)."\n";
+        $email_body .= get_lang('Email', null, $email_language).': '.$user_info['mail']."\n";
+        $email_body .= get_lang('Description', null, $email_language).': '.$description."\n";
+        $email_body .= get_lang('Objectives', null, $email_language).': '.$objetives."\n";
+        $email_body .= get_lang('TargetAudience', null, $email_language).': '.$target_audience."\n";
+        $email_body .= get_lang('Ln', null, $email_language).': '.$course_language."\n";
+
+        // Sending an e-mail to the platform administrator.
+
+        $email_body_admin = $email_body;
+        $email_body_admin .= "\n".get_lang('CourseRequestPageForApproval', null, $email_language).' '.api_get_path(WEB_CODE_PATH).'admin/course_request_review.php'."\n";
+        $email_body_admin .= "\n".get_lang('CourseRequestLegalNote', null, $email_language)."\n";
+
+        $sender_name_teacher = api_get_person_name($user_info['firstname'], $user_info['lastname'], null, PERSON_NAME_EMAIL_ADDRESS);
+        $sender_email_teacher = $user_info['mail'];
+        $recipient_name_admin = api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'), null, PERSON_NAME_EMAIL_ADDRESS);
+        $recipient_email_admin = get_setting('emailAdministrator');
+
+        @api_mail($recipient_name_admin, $recipient_email_admin, $email_subject, $email_body_admin, $sender_name_teacher, $sender_email_teacher);
+
+        // Sending an e-mail to the requestor.
+
+        $email_body_teacher = get_lang('Dear', null, $email_language).' ';
+        $email_body_teacher .= api_get_person_name($user_info['firstname'], $user_info['lastname'], null, null, $email_language).",\n\n";
+        $email_body_teacher .= $email_body;
+        $email_body_teacher .= "\n".get_lang('Formula', null, $email_language)."\n";
+        $email_body_teacher .= api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'), null, null, $email_language)."\n";
+        $email_body_teacher .= get_lang('Manager', null, $email_language).' '.api_get_setting('siteName')."\n";
+        $email_body_teacher .= get_lang('Phone', null, $email_language).': '.api_get_setting('administratorTelephone')."\n";
+        $email_body_teacher .= get_lang('Email', null, $email_language).': '.api_get_setting('emailAdministrator', null, $email_language)."\n";
+        $email_body_teacher .= "\n".get_lang('CourseRequestLegalNote', null, $email_language)."\n";
+
+        // Swap the sender and the recipient.
+        $sender_name_admin = $recipient_name_admin;
+        $sender_email_admin = $recipient_email_admin;
+        $recipient_name_teacher = $sender_name_teacher;
+        $recipient_email_teacher = $sender_email_teacher;
+
+        @api_mail($recipient_name_teacher, $recipient_email_teacher, $email_subject, $email_body_teacher, $sender_name_admin, $sender_email_admin);
 
         return $last_insert_id;
 
@@ -137,7 +188,7 @@ class CourseRequestManager {
     }
 
     /**
-     * Gets all the information about a course request using its database id as access key.
+     * Gets all the information about a course request using its database id as an access key.
      * @param int/string $id              The id (an integer number) of the corresponding database record.
      * @return array/bool                 Returns the requested data as an array or FALSE on failure.
      */
@@ -151,6 +202,24 @@ class CourseRequestManager {
         return false;
     }
 
+    /**
+     * Gets the code of a given course request using its database id as an access key.
+     * @param int/string $id              The id (an integer number) of the corresponding database record.
+     * @return string/bool                Returns the requested requested code or FALSE on failure.
+     */
+    public static function get_course_request_code($id) {
+        $id = (int)$id;
+        $sql = "SELECT code FROM ".Database :: get_main_table(TABLE_MAIN_COURSE_REQUEST)." WHERE id = ".$id;
+        $result = Database::query($sql);
+        if (Database::num_rows($result) > 0) {
+            $result_array = Database::fetch_array($result, 'NUM');
+            if (is_array($result_array)) {
+                return $result_array[0];
+            }
+        }
+        return false;
+    }
+
     /**
      * Accepts a given by its id course request. The requested course gets created immediately after the request acceptance.
      * @param int/string $id              The id (an integer number) of the corresponding database record.
@@ -208,10 +277,34 @@ class CourseRequestManager {
         $sql = "UPDATE ".Database :: get_main_table(TABLE_MAIN_COURSE_REQUEST)." SET status = ".COURSE_REQUEST_ACCEPTED." WHERE id = ".$id;
         Database::query($sql);
 
-        // TODO: Prepare and send notification e-mail messages.
+        // E-mail notification.
 
-        return $code;
+        // E-mail language: The platform language seems to be the best choice.
+        //$email_language = $course_language;
+        //$email_language = api_get_interface_language();
+        $email_language = api_get_setting('platformLanguage');
+
+        $email_subject = sprintf(get_lang('CourseRequestAcceptedEmailSubject', null, $email_language), '['.api_get_setting('siteName').']', $wanted_code);
+
+        $email_body = get_lang('Dear', null, $email_language).' ';
+        $email_body .= api_get_person_name($user_info['firstname'], $user_info['lastname'], null, null, $email_language).",\n\n";
+        $email_body .= sprintf(get_lang('CourseRequestAcceptedEmailText', null, $email_language), $wanted_code, $code, api_get_path(WEB_COURSE_PATH).$directory.'/')."\n";
+        $email_body .= "\n".get_lang('Formula', null, $email_language)."\n";
+        $email_body .= api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'), null, null, $email_language)."\n";
+        $email_body .= get_lang('Manager', null, $email_language).' '.api_get_setting('siteName')."\n";
+        $email_body .= get_lang('Phone', null, $email_language).': '.api_get_setting('administratorTelephone')."\n";
+        $email_body .= get_lang('Email', null, $email_language).': '.api_get_setting('emailAdministrator', null, $email_language)."\n";
+        $email_body .= "\n".get_lang('CourseRequestLegalNote', null, $email_language)."\n";
+
+        $sender_name = api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'), null, PERSON_NAME_EMAIL_ADDRESS);
+        $sender_email = get_setting('emailAdministrator');
+        $recipient_name = api_get_person_name($user_info['firstname'], $user_info['lastname'], null, PERSON_NAME_EMAIL_ADDRESS);
+        $recipient_email = $user_info['mail'];
+        $extra_headers = 'Bcc: '.$sender_email;
 
+        @api_mail($recipient_name, $recipient_email, $email_subject, $email_body, $sender_name, $sender_email);
+
+        return $code;
     }
 
     /**
@@ -222,28 +315,140 @@ class CourseRequestManager {
     public static function reject_course_request($id) {
 
         $id = (int)$id;
+
+        // Retrieve request's data
+        $course_request_info = CourseRequestManager::get_course_request_info($id);
+        if (!is_array($course_request_info)) {
+            return false;
+        }
+
+        $user_id = intval($course_request_info['user_id']);
+        if ($user_id <= 0) {
+            return false;
+        }
+
+        $user_info = api_get_user_info($user_id);
+        if (!is_array($user_info)) {
+            return false;
+        }
+
+        $code = $course_request_info['code'];
+
         $sql = "UPDATE ".Database :: get_main_table(TABLE_MAIN_COURSE_REQUEST)." SET status = ".COURSE_REQUEST_REJECTED." WHERE id = ".$id;
-        $result = Database::query($sql) !== false;
+        if (Database::query($sql) === false) {
+            return false;
+        }
 
-        // TODO: Prepare and send notification e-mail messages.
+        // E-mail notification.
 
-        return $result;
+        // E-mail language: The platform language seems to be the best choice.
+        //$email_language = $course_language;
+        //$email_language = api_get_interface_language();
+        $email_language = api_get_setting('platformLanguage');
+
+        $email_subject = sprintf(get_lang('CourseRequestRejectedEmailSubject', null, $email_language), '['.api_get_setting('siteName').']', $code);
+
+        $email_body = get_lang('Dear', null, $email_language).' ';
+        $email_body .= api_get_person_name($user_info['firstname'], $user_info['lastname'], null, null, $email_language).",\n\n";
+        $email_body .= sprintf(get_lang('CourseRequestRejectedEmailText', null, $email_language), $code)."\n";
+        $email_body .= "\n".get_lang('Formula', null, $email_language)."\n";
+        $email_body .= api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'), null, null, $email_language)."\n";
+        $email_body .= get_lang('Manager', null, $email_language).' '.api_get_setting('siteName')."\n";
+        $email_body .= get_lang('Phone', null, $email_language).': '.api_get_setting('administratorTelephone')."\n";
+        $email_body .= get_lang('Email', null, $email_language).': '.api_get_setting('emailAdministrator', null, $email_language)."\n";
+        $email_body .= "\n".get_lang('CourseRequestLegalNote', null, $email_language)."\n";
+
+        $sender_name = api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'), null, PERSON_NAME_EMAIL_ADDRESS);
+        $sender_email = get_setting('emailAdministrator');
+        $recipient_name = api_get_person_name($user_info['firstname'], $user_info['lastname'], null, PERSON_NAME_EMAIL_ADDRESS);
+        $recipient_email = $user_info['mail'];
+        $extra_headers = 'Bcc: '.$sender_email;
+
+        @api_mail($recipient_name, $recipient_email, $email_subject, $email_body, $sender_name, $sender_email);
+
+        return true;
     }
 
     /**
-     * Asks the author (through e-mail) for additional info about the given course request.
+     * Asks the author (through e-mail) for additional information about the given course request.
      * @param int/string $id              The database primary id of the given request.
      * @return array/bool                 Returns TRUE on success or FALSE on failure.
      */
     public static function ask_for_additional_info($id) {
 
         $id = (int)$id;
+
+        // Retrieve request's data
+        $course_request_info = CourseRequestManager::get_course_request_info($id);
+        if (!is_array($course_request_info)) {
+            return false;
+        }
+
+        $user_id = intval($course_request_info['user_id']);
+        if ($user_id <= 0) {
+            return false;
+        }
+
+        $user_info = api_get_user_info($user_id);
+        if (!is_array($user_info)) {
+            return false;
+        }
+
+        $code = $course_request_info['code'];
+        $info = intval($course_request_info['info']);
+
+        // Error is to be returned on a repeated attempt for asking additional information.
+        if (!empty($info)) {
+            return false;
+        }
+
+        // E-mail notification.
+
+        // E-mail language: The platform language seems to be the best choice.
+        //$email_language = $course_language;
+        //$email_language = api_get_interface_language();
+        $email_language = api_get_setting('platformLanguage');
+
+        $email_subject = sprintf(get_lang('CourseRequestAskInfoEmailSubject', null, $email_language), '['.api_get_setting('siteName').']', $code);
+
+        $email_body = get_lang('Dear', null, $email_language).' ';
+        $email_body .= api_get_person_name($user_info['firstname'], $user_info['lastname'], null, null, $email_language).",\n\n";
+        $email_body .= sprintf(get_lang('CourseRequestAskInfoEmailText', null, $email_language), $code)."\n";
+        $email_body .= "\n".get_lang('Formula', null, $email_language)."\n";
+        $email_body .= api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'), null, null, $email_language)."\n";
+        $email_body .= get_lang('Manager', null, $email_language).' '.api_get_setting('siteName')."\n";
+        $email_body .= get_lang('Phone', null, $email_language).': '.api_get_setting('administratorTelephone')."\n";
+        $email_body .= get_lang('Email', null, $email_language).': '.api_get_setting('emailAdministrator', null, $email_language)."\n";
+        $email_body .= "\n".get_lang('CourseRequestLegalNote', null, $email_language)."\n";
+
+        $sender_name = api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'), null, PERSON_NAME_EMAIL_ADDRESS);
+        $sender_email = get_setting('emailAdministrator');
+        $recipient_name = api_get_person_name($user_info['firstname'], $user_info['lastname'], null, PERSON_NAME_EMAIL_ADDRESS);
+        $recipient_email = $user_info['mail'];
+        $extra_headers = 'Bcc: '.$sender_email;
+
+        $result = @api_mail($recipient_name, $recipient_email, $email_subject, $email_body, $sender_name, $sender_email);
+        if (!$result) {
+            return false;
+        }
+
+        // Marking the fact that additional information about the request has been asked.
         $sql = "UPDATE ".Database :: get_main_table(TABLE_MAIN_COURSE_REQUEST)." SET info = 1 WHERE id = ".$id;
         $result = Database::query($sql) !== false;
 
-        // TODO: Send the e-mail.
-
         return $result;
     }
 
+    /**
+     * Checks whether additional information about the given course request has been asked.
+     * @param int/string $id              The database primary id of the given request.
+     * @return array/bool                 Returns TRUE if additional information has been asked or FALSE otherwise.
+     */
+    public static function additional_info_asked($id) {
+        $id = (int)$id;
+        $sql = "SELECT id FROM ".Database :: get_main_table(TABLE_MAIN_COURSE_REQUEST)." WHERE (id = ".$id." AND info = 1)";
+        $result = Database::num_rows(Database::query($sql));
+        return !empty($result);
+    }
+
 }

+ 6 - 1
main/inc/lib/diagnoser.lib.php

@@ -80,7 +80,7 @@ class Diagnoser
         }
 
         $exists = ! file_exists(api_get_path(SYS_PATH) . '/install');
-        $status = $exists ? self :: STATUS_OK : self :: STATUS_WARNING;
+        $status = $exists ? self :: STATUS_WARNING : self :: STATUS_OK;
         $array[] = $this->build_setting($status, '[FILES]', get_lang('DirectoryExists') . ': /install', 'http://be2.php.net/file_exists', $writable, 0, 'yes_no', get_lang('DirectoryShouldBeRemoved'));
 
         return $array;
@@ -195,6 +195,11 @@ class Diagnoser
         $req_setting = '4320';
         $status = $setting == $req_setting ? self :: STATUS_OK : self :: STATUS_WARNING;
         $array[] = $this->build_setting($status, '[SESSION]', 'session.gc_maxlifetime', 'http://www.php.net/manual/en/ini.core.php#session.gc-maxlifetime', $setting, $req_setting, null, get_lang('SessionGCMaxLifetimeInfo'));
+		
+		if (api_check_browscap()){$setting = true;}else{$setting=false;}		
+		$req_setting = true;
+        $status = $setting == $req_setting ? self :: STATUS_OK : self :: STATUS_WARNING;
+        $array[] = $this->build_setting($status, '[INI]', 'browscap', 'http://www.php.net/manual/en/misc.configuration.php#ini.browscap', $setting, $req_setting, 'on_off', get_lang('BrowscapInfo'));
 
         //Extensions
         $extensions = array('gd' => 'http://www.php.net/gd', 'mysql' => 'http://www.php.net/mysql', 'pcre' => 'http://www.php.net/pcre', 'session' => 'http://www.php.net/session', 'standard' => 'http://www.php.net/spl', 'zlib' => 'http://www.php.net/zlib', 'xsl' => 'http://be2.php.net/xsl');

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

@@ -12,6 +12,7 @@
  */
 
 require_once api_get_path(LIBRARY_PATH).'course.lib.php';
+require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
 
 /* CONSTANTS */
 
@@ -196,6 +197,7 @@ class DocumentManager {
 			'sv4crc' => 'application/x-sv4crc',
 			'svf' => 'application/vnd.svf',
 			'svg' => 'image/svg+xml',
+			'svgz'=> 'image/svg+xml',
 			'swf' => 'application/x-shockwave-flash',
 			'sxc' => 'application/vnd.sun.xml.calc',
 			'sxi' => 'application/vnd.sun.xml.impress',

+ 1 - 1
main/inc/lib/fileDisplay.lib.php

@@ -53,7 +53,7 @@ function choose_image($file_name)
 		$type['word'      ] = array('doc', 'dot',  'rtf', 'mcw',  'wps', 'psw', 'docm', 'docx', 'dotm',  'dotx');
 		$type['web'       ] = array('htm', 'html', 'htx', 'xml',  'xsl',  'php', 'xhtml');
 		$type['image'     ] = array('gif', 'jpg',  'png', 'bmp',  'jpeg');
-		$type['image_vect'] = array('svg');
+		$type['image_vect'] = array('svg','svgz');
 		$type['audio'     ] = array('wav', 'mid',  'mp2', 'mp3',  'midi', 'sib', 'amr', 'kar');
 		$type['video'     ] = array('mp4', 'mov',  'rm',  'pls',  'mpg',  'mpeg', 'au', 'flv', 'avi', 'wmv', 'asf', '3gp');
 		$type['excel'     ] = array('xls', 'xlt',  'xls', 'xlt', 'pxl', 'xlsx', 'xlsm', 'xlam', 'xlsb', 'xltm', 'xltx');

+ 176 - 190
main/inc/lib/mail.lib.inc.php

@@ -4,8 +4,8 @@
 require_once api_get_path(LIBRARY_PATH).'phpmailer/class.phpmailer.php';
 require_once api_get_path(CONFIGURATION_PATH).'mail.conf.php';
 
-//regular expression to test for valid email address
-// this should actually be revised to use the complete RFC3696 description
+// A regular expression for testing against valid email addresses.
+// It should actually be revised for using the complete RFC3696 description:
 // http://tools.ietf.org/html/rfc3696#section-3
 $regexp_rfc3696 = "^[0-9a-z_\.+-]+@(([0-9]{1,3}\.){3}[0-9]{1,3}|([0-9a-z][0-9a-z-]*[0-9a-z]\.)+[a-z]{2,3})$";
 
@@ -23,78 +23,69 @@ $regexp_rfc3696 = "^[0-9a-z_\.+-]+@(([0-9]{1,3}\.){3}[0-9]{1,3}|([0-9a-z][0-9a-z
  * @return                  returns true if mail was sent
  * @see                     class.phpmailer.php
  */
-function api_mail($recipient_name, $recipient_email, $subject, $message, $sender_name="", $sender_email="", $extra_headers="") {
-
-	global $regexp_rfc3696;
-	global $platform_email;
-
-	$mail = new PHPMailer();
-	$mail->Mailer  = $platform_email['SMTP_MAILER'];
-	$mail->Host    = $platform_email['SMTP_HOST'];
-	$mail->Port    = $platform_email['SMTP_PORT'];
-	$mail->CharSet = $platform_email['SMTP_CHARSET'];
-	$mail->WordWrap = 200; // stay far below SMTP protocol 980 chars limit
-
-	if($platform_email['SMTP_AUTH'])
-	{
-		$mail->SMTPAuth = 1;
-		$mail->Username = $platform_email['SMTP_USER'];
-		$mail->Password = $platform_email['SMTP_PASS'];
-	}
-
-	$mail->Priority = 3; // 5=low, 1=high
-	$mail->AddCustomHeader("Errors-To: ".$platform_email['SMTP_FROM_EMAIL']."");
-	$mail->IsHTML(0);
-	$mail->SMTPKeepAlive = true;
-
-	// attachments
-	// $mail->AddAttachment($path);
-	// $mail->AddAttachment($path,$filename);
-
-	if ($sender_email!="")
-	{
-		$mail->From         = $sender_email;
-		$mail->Sender       = $sender_email;
-		//$mail->ConfirmReadingTo = $sender_email; //Disposition-Notification
-	}
-	else
-	{
-		$mail->From         = $platform_email['SMTP_FROM_EMAIL'];
-		$mail->Sender       = $platform_email['SMTP_FROM_EMAIL'];
-		//$mail->ConfirmReadingTo = $platform_email['SMTP_FROM_EMAIL']; //Disposition-Notification
-	}
-
-	if ($sender_name!="")
-	{
-		$mail->FromName = $sender_name;
-	}
-	else
-	{
-		$mail->FromName = $platform_email['SMTP_FROM_NAME'];
-	}
-	$mail->Subject = $subject;
-	$mail->Body    = $message;
-
-	//only valid address
-	if(eregi( $regexp_rfc3696, $recipient_email ))
-	{
-		$mail->AddAddress($recipient_email, $recipient_name);
-	}
-
-	if ($extra_headers != ""){
-		$mail->AddCustomHeader($extra_headers);
-	}
-
-	//send mail
-	if (!$mail->Send())
-	{
-		//echo "ERROR: mail not sent to ".$recipient_name." (".$recipient_email.") because of ".$mail->ErrorInfo."<br>";
-		return 0;
-	}
-
-	// Clear all addresses
-	$mail->ClearAddresses();
-	return 1;
+function api_mail($recipient_name, $recipient_email, $subject, $message, $sender_name = '', $sender_email = '', $extra_headers = '') {
+
+    global $regexp_rfc3696;
+    global $platform_email;
+
+    $mail = new PHPMailer();
+    $mail->Mailer  = $platform_email['SMTP_MAILER'];
+    $mail->Host    = $platform_email['SMTP_HOST'];
+    $mail->Port    = $platform_email['SMTP_PORT'];
+    $mail->CharSet = $platform_email['SMTP_CHARSET'];
+    $mail->WordWrap = 200; // Stay far below SMTP protocol 980 chars limit.
+
+    if ($platform_email['SMTP_AUTH']) {
+        $mail->SMTPAuth = 1;
+        $mail->Username = $platform_email['SMTP_USER'];
+        $mail->Password = $platform_email['SMTP_PASS'];
+    }
+
+    $mail->Priority = 3; // 5 = low, 1 = high
+    $mail->AddCustomHeader('Errors-To: '.$platform_email['SMTP_FROM_EMAIL']);
+    $mail->IsHTML(0);
+    $mail->SMTPKeepAlive = true;
+
+    // Attachments
+    // $mail->AddAttachment($path);
+    // $mail->AddAttachment($path, $filename);
+
+    if ($sender_email != '') {
+        $mail->From         = $sender_email;
+        $mail->Sender       = $sender_email;
+        //$mail->ConfirmReadingTo = $sender_email; // Disposition-Notification
+    } else {
+        $mail->From         = $platform_email['SMTP_FROM_EMAIL'];
+        $mail->Sender       = $platform_email['SMTP_FROM_EMAIL'];
+        //$mail->ConfirmReadingTo = $platform_email['SMTP_FROM_EMAIL']; // Disposition-Notification
+    }
+
+    if ($sender_name != '') {
+        $mail->FromName = $sender_name;
+    } else {
+        $mail->FromName = $platform_email['SMTP_FROM_NAME'];
+    }
+    $mail->Subject = $subject;
+    $mail->Body    = $message;
+
+    // Only valid addresses are accepted.
+    if (eregi($regexp_rfc3696, $recipient_email)) {
+        $mail->AddAddress($recipient_email, $recipient_name);
+    }
+
+    if ($extra_headers != '') {
+        $mail->AddCustomHeader($extra_headers);
+    }
+
+    // Send the mail message.
+    if (!$mail->Send()) {
+        //echo 'ERROR: mail not sent to '.$recipient_name.' ('.$recipient_email.') because of '.$mail->ErrorInfo.'<br />';
+        return 0;
+    }
+
+    // Clear all the addresses.
+    $mail->ClearAddresses();
+    return 1;
 }
 
 /**
@@ -118,61 +109,61 @@ function api_mail($recipient_name, $recipient_email, $subject, $message, $sender
  * @return          returns true if mail was sent
  * @see             class.phpmailer.php
  */
-function api_mail_html($recipient_name, $recipient_email, $subject, $message, $sender_name = "", $sender_email = "", $extra_headers = null, $data_file = array(), $embedded_image = false) {
-
-	global $regexp_rfc3696;
-	global $platform_email;
-
-	$mail = new PHPMailer();
-	$mail->Mailer  = $platform_email['SMTP_MAILER'];
-	$mail->Host    = $platform_email['SMTP_HOST'];
-	$mail->Port    = $platform_email['SMTP_PORT'];
-	$mail->CharSet = $platform_email['SMTP_CHARSET'];
-	$mail->WordWrap = 200; // stay far below SMTP protocol 980 chars limit
-
-	if ($platform_email['SMTP_AUTH']) {
-		$mail->SMTPAuth = 1;
-		$mail->Username = $platform_email['SMTP_USER'];
-		$mail->Password = $platform_email['SMTP_PASS'];
-	}
-
-	$mail->Priority = 3; // 5=low, 1=high
-	$mail->AddCustomHeader("Errors-To: ".$platform_email['SMTP_FROM_EMAIL']."");
-	$mail->IsHTML(0);
-	$mail->SMTPKeepAlive = true;
-
-	if (($sender_email != "") && ($sender_name != "")) {
-		$mail->AddReplyTo ($sender_email,$sender_name);
-	}
-
-	// attachments
-	// $mail->AddAttachment($path);
-	// $mail->AddAttachment($path,$filename);
-
-	if ($sender_email!="") {
-		$mail->From         = $sender_email;
-		$mail->Sender       = $sender_email;
-		//$mail->ConfirmReadingTo = $sender_email; //Disposition-Notification
-	} else {
-		$mail->From         = $platform_email['SMTP_FROM_EMAIL'];
-		$mail->Sender       = $platform_email['SMTP_FROM_EMAIL'];
-		//$mail->ConfirmReadingTo = $platform_email['SMTP_FROM_EMAIL']; //Disposition-Notification
-	}
-
-	if ($sender_name!="") {
-		$mail->FromName = $sender_name;
-	} else {
-		$mail->FromName = $platform_email['SMTP_FROM_NAME'];
-	}
-	$mail->Subject = $subject;
-
-	$mail->AltBody = strip_tags(str_replace('<br />',"\n", api_html_entity_decode($message)));
-
-        // send embedded image
+function api_mail_html($recipient_name, $recipient_email, $subject, $message, $sender_name = '', $sender_email = '', $extra_headers = null, $data_file = array(), $embedded_image = false) {
+
+    global $regexp_rfc3696;
+    global $platform_email;
+
+    $mail = new PHPMailer();
+    $mail->Mailer  = $platform_email['SMTP_MAILER'];
+    $mail->Host    = $platform_email['SMTP_HOST'];
+    $mail->Port    = $platform_email['SMTP_PORT'];
+    $mail->CharSet = $platform_email['SMTP_CHARSET'];
+    $mail->WordWrap = 200; // Stay far below SMTP protocol 980 chars limit.
+
+    if ($platform_email['SMTP_AUTH']) {
+        $mail->SMTPAuth = 1;
+        $mail->Username = $platform_email['SMTP_USER'];
+        $mail->Password = $platform_email['SMTP_PASS'];
+    }
+
+    $mail->Priority = 3; // 5 = low, 1 = high
+    $mail->AddCustomHeader('Errors-To: '.$platform_email['SMTP_FROM_EMAIL']);
+    $mail->IsHTML(0);
+    $mail->SMTPKeepAlive = true;
+
+    if (($sender_email != '') && ($sender_name != '')) {
+        $mail->AddReplyTo($sender_email, $sender_name);
+    }
+
+    // Attachments
+    // $mail->AddAttachment($path);
+    // $mail->AddAttachment($path, $filename);
+
+    if ($sender_email != '') {
+        $mail->From         = $sender_email;
+        $mail->Sender       = $sender_email;
+        //$mail->ConfirmReadingTo = $sender_email; // Disposition-Notification
+    } else {
+        $mail->From         = $platform_email['SMTP_FROM_EMAIL'];
+        $mail->Sender       = $platform_email['SMTP_FROM_EMAIL'];
+        //$mail->ConfirmReadingTo = $platform_email['SMTP_FROM_EMAIL']; // Disposition-Notification
+    }
+
+    if ($sender_name != '') {
+        $mail->FromName = $sender_name;
+    } else {
+        $mail->FromName = $platform_email['SMTP_FROM_NAME'];
+    }
+    $mail->Subject = $subject;
+
+    $mail->AltBody = strip_tags(str_replace('<br />',"\n", api_html_entity_decode($message)));
+
+        // Send embedded image.
         if ($embedded_image) {
-           // get all images html inside content
-           preg_match_all("/<img\s+.*?src=[\"\']?([^\"\' >]*)[\"\']?[^>]*>/i",$message,$m);
-           // prepare new tag images
+           // Get all images html inside content.
+           preg_match_all("/<img\s+.*?src=[\"\']?([^\"\' >]*)[\"\']?[^>]*>/i", $message, $m);
+           // Prepare new tag images.
            $new_images_html = array();
            $i = 1;
            if (!empty($m[1])) {
@@ -187,7 +178,7 @@ function api_mail_html($recipient_name, $recipient_email, $subject, $message, $s
                    $i++;
                }
            }
-           // replace origin image for new embedded image html
+           // Replace origin image for new embedded image html.
            $x = 0;
            if (!empty($m[0])) {
                foreach ($m[0] as $orig_img) {
@@ -197,65 +188,60 @@ function api_mail_html($recipient_name, $recipient_email, $subject, $message, $s
            }
         }
 
-	$mail->Body = '<html><head></head><body>'.$message.'</body></html>';
-
-	// attachment ...
-	if (!empty($data_file)) {
-		$mail->AddAttachment($data_file['path'], $data_file['filename']);
-	}
-
-	// only valid address
-	if(is_array($recipient_email)) {
-		foreach($recipient_email as $dest) {
-			if(eregi( $regexp_rfc3696, $dest )) {
-				$mail->AddAddress($dest, $recipient_name);
-				//$mail->AddAddress($dest, ($i>1?'':$recipient_name));
-			}
-		}
-	} else {
-		if(eregi( $regexp_rfc3696, $recipient_email ))
-		{
-			$mail->AddAddress($recipient_email, $recipient_name);
-		} else {
-			return 0;
-		}
-	}
-
-	if (is_array($extra_headers) && count($extra_headers)>0){
-		foreach($extra_headers as $key=>$value)
-		{
-			switch(strtolower($key)){
-				case 'encoding':
-				case 'content-transfer-encoding':
-					$mail->Encoding = $value;
-					break;
-				case 'charset':
-					$mail->Charset = $value;
-					break;
-				case 'contenttype':
-				case 'content-type':
-					$mail->ContentType = $value;
-					break;
-				default:
-					$mail->AddCustomHeader($key.':'.$value);
-					break;
-			}
-		}
-	}
-
-	// WordWrap the html body (phpMailer only fixes AltBody) FS#2988
-	$mail->Body = $mail->WrapText($mail->Body, $mail->WordWrap);
-
-	//send mail
-	if (!$mail->Send())
-	{
-		//echo "ERROR: mail not sent to ".$recipient_name." (".$recipient_email.") because of ".$mail->ErrorInfo."<br>";
-		return 0;
-	}
-
-	// Clear all addresses
-	$mail->ClearAddresses();
-	return 1;
-}
+    $mail->Body = '<html><head></head><body>'.$message.'</body></html>';
+
+    // Attachment ...
+    if (!empty($data_file)) {
+        $mail->AddAttachment($data_file['path'], $data_file['filename']);
+    }
 
-?>
+    // Only valid addresses are accepted.
+    if (is_array($recipient_email)) {
+        foreach ($recipient_email as $dest) {
+            if (eregi($regexp_rfc3696, $dest)) {
+                $mail->AddAddress($dest, $recipient_name);
+                //$mail->AddAddress($dest, ($i > 1 ? '' : $recipient_name));
+            }
+        }
+    } else {
+        if (eregi($regexp_rfc3696, $recipient_email)) {
+            $mail->AddAddress($recipient_email, $recipient_name);
+        } else {
+            return 0;
+        }
+    }
+
+    if (is_array($extra_headers) && count($extra_headers) > 0) {
+        foreach ($extra_headers as $key => $value) {
+            switch (strtolower($key)) {
+                case 'encoding':
+                case 'content-transfer-encoding':
+                    $mail->Encoding = $value;
+                    break;
+                case 'charset':
+                    $mail->Charset = $value;
+                    break;
+                case 'contenttype':
+                case 'content-type':
+                    $mail->ContentType = $value;
+                    break;
+                default:
+                    $mail->AddCustomHeader($key.':'.$value);
+                    break;
+            }
+        }
+    }
+
+    // WordWrap the html body (phpMailer only fixes AltBody) FS#2988
+    $mail->Body = $mail->WrapText($mail->Body, $mail->WordWrap);
+
+    // Send the mail message.
+    if (!$mail->Send()) {
+        //echo 'ERROR: mail not sent to '.$recipient_name.' ('.$recipient_email.') because of '.$mail->ErrorInfo.'<br />';
+        return 0;
+    }
+
+    // Clear all the addresses.
+    $mail->ClearAddresses();
+    return 1;
+}

+ 41 - 1
main/inc/lib/main_api.lib.php

@@ -4640,4 +4640,44 @@ function api_get_template($path_type = 'rel') {
     }
     $actived_theme_path = $template_path.$actived_theme.DIRECTORY_SEPARATOR;
     return $actived_theme_path;
-}
+}
+
+/**
+ * Check browser support for svg files
+ * @return bool
+ *
+ * @author Juan Carlos Raña Trabado
+ */
+function api_support_svg() {
+	require_once api_get_path(LIBRARY_PATH).'browser/Browser.php';
+	$browser = new Browser();
+	//print_r($browser);
+	$current_browser=$browser->getBrowser();		
+	$a_versiontemp = explode(".",$browser->getVersion());
+	$current_majorver= $a_versiontemp[0];
+
+	if (($current_browser=='Internet Explorer' && $current_majorver>8) || ($current_browser=='Firefox' && $current_majorver>1)||($current_browser=='Safari' && $current_majorver>=4) || ($current_browser=='Chrome' && $current_majorver >=1) || ($current_browser=='Opera' && $current_majorver>9)){
+		return true;
+	}else{
+		return false;
+	}
+}
+
+/**
+ * This function checks if exist path and file browscap.ini
+ * @return bool
+ *
+ * @author Juan Carlos Raña Trabado
+ */
+function api_check_browscap(){
+	$setting = ini_get('browscap');
+	$browser = get_browser($_SERVER['HTTP_USER_AGENT'], true);
+	
+	if (strpos($setting, 'browscap.ini') && !empty($browser)){
+		return true;
+	}else{
+		return false;
+	}	
+}
+
+?>

+ 2 - 1
main/inc/lib/svg-edit/extensions/ext-imagelib.js

@@ -12,7 +12,8 @@ svgEditor.addExtension("imagelib", function() {
 	var img_libs = [{
 			name: 'Local library',
 			url: 'extensions/imagelib/index.php',
-			description: 'Demonstration library for SVG-edit on this server'
+			//description: 'Demonstration library for SVG-edit on this server'// Chamilo change this line by below
+			description: 'Course gallery'
 		}, 
 		{
 			name: 'IAN Symbol Libraries',

+ 13 - 30
main/inc/lib/svg-edit/extensions/fileopen.php

@@ -17,31 +17,13 @@ require_once api_get_path(LIBRARY_PATH).'fileUpload.lib.php';
 
 api_protect_course_script();
 api_block_anonymous_users();
-//Adding Chamilo style because Display :: display_error_message() dont run well.
-?>
-<style type="text/css">
-<!--
-.error-message {
-	position: relative;
-	margin-top: 10px;
-	margin-bottom: 10px;
-	border-width: 1px;
-	border-style: solid;
-	-moz-border-radius: 10px;
-	padding: 6px;
-	border: 1px solid #FF0000;
-	color: #440000;
-	background-color: #FFD1D1;
-	min-height: 30px;
-}
--->
-</style>
 
-<?php
 if(!isset($_FILES['svg_file']['tmp_name'])) {
-	echo '<div class="error-message">'. get_lang('lang_no_access_here').'</div>';// from Chamilo
+	api_not_allowed(false);//from Chamilo
 	die();
 }
+
+
 ?>
 <!doctype html>
 <?php
@@ -62,24 +44,25 @@ if(!isset($_FILES['svg_file']['tmp_name'])) {
 		$prefix = 'data:' . $info['mime'] . ';base64,';
 	}
 	
-//a bit title security
+//check the extension
+$extension = explode('.', $file);
+$extension = strtolower($extension[sizeof($extension) - 1]);	
 
+//a bit title security
 $filename = addslashes(trim($file));
 $filename = Security::remove_XSS($filename);
 $filename = replace_dangerous_char($filename, 'strict');
-$filename = disable_dangerous_file($filename);
-
-
+$filename = disable_dangerous_file($filename);	
+	
 //a bit mime security
-$finfo = new finfo(FILEINFO_MIME);
-$current_mime=$finfo->buffer($contents);
-
+$current_mime = $_FILES['svg_file']['type'];
 $mime_svg='image/svg+xml';
 $mime_xml='application/xml';//hack for svg-edit because original code return application/xml; charset=us-ascii.
-
+		
 if(strpos($current_mime, $mime_svg)===false && strpos($current_mime, $mime_xml)===false && $extension=='svg'){
-	die();//File extension does not match its content
+	// die();//File extension does not match its content disabled to check into chamilo dev campus TODO:enabled
 }
+
 ?>
 
 <script>

+ 27 - 36
main/inc/lib/svg-edit/extensions/filesave.php

@@ -19,29 +19,8 @@ require_once api_get_path(LIBRARY_PATH).'fileUpload.lib.php';
 api_protect_course_script();
 api_block_anonymous_users();
 
-//Adding Chamilo style because Display :: display_error_message() dont run well.
-?>
-<style type="text/css">
-<!--
-.error-message {
-	position: relative;
-	margin-top: 10px;
-	margin-bottom: 10px;
-	border-width: 1px;
-	border-style: solid;
-	-moz-border-radius: 10px;
-	padding: 6px;
-	border: 1px solid #FF0000;
-	color: #440000;
-	background-color: #FFD1D1;
-	min-height: 30px;
-}
--->
-</style>
-<?php
-
 if(!isset($_POST['output_svg']) && !isset($_POST['output_png'])) {
-	echo '<div class="error-message">'. get_lang('lang_no_access_here').'</div>';// from Chamilo
+	api_not_allowed(false);//from Chamilo
 	die();
 }
 
@@ -79,9 +58,10 @@ $title = Database::escape_string(str_replace('_',' ',$filename));
 
 //get Chamilo variables 
 
-if(!isset($_SESSION['draw_dir']) ||!isset($_SESSION['whereami']) )
+if(!isset($_SESSION['draw_dir']) || !isset($_SESSION['whereami']) )
 {
-	die();
+	api_not_allowed(false);//from Chamilo
+	die();	
 }
 
 $current_session_id = api_get_session_id();
@@ -99,18 +79,28 @@ $filename = replace_dangerous_char($filename, 'strict');
 $filename = disable_dangerous_file($filename);
 
 //a bit mime security
-$finfo = new finfo(FILEINFO_MIME);
-$current_mime=$finfo->buffer($contents);
-$mime_png='image/png';//svg-edit return image/png; charset=binary 
-$mime_svg='image/svg+xml';
-$mime_xml='application/xml';//hack for svg-edit because original code return application/xml; charset=us-ascii. See
-  
-if(strpos($current_mime, $mime_png)===false && $extension=='png')
-{
-	die();//File extension does not match its content
-}elseif(strpos($current_mime, $mime_svg)===false && strpos($current_mime, $mime_xml)===false && $extension=='svg')
-{
-	die();//File extension does not match its content
+
+if (phpversion() >= '5.3') {
+	$finfo = new finfo(FILEINFO_MIME);
+	$current_mime=$finfo->buffer($contents);
+	finfo_close($finfo);
+	$mime_png='image/png';//svg-edit return image/png; charset=binary 
+	$mime_svg='image/svg+xml';
+	$mime_xml='application/xml';//hack for svg-edit because original code return application/xml; charset=us-ascii. See	  
+	if(strpos($current_mime, $mime_png)===false && $extension=='png')
+	{
+		//die();//File extension does not match its content //disabled to check into chamilo dev campus 
+	}elseif(strpos($current_mime, $mime_svg)===false && strpos($current_mime, $mime_xml)===false && $extension=='svg')
+	{
+		//die();//File extension does not match its content //disabled to check into chamilo dev campus TODO:enabled
+	}
+	
+}else{
+	
+	if($suffix!= 'svg' || $suffix!= 'png')
+	{
+		//die();//disabled to check into chamilo dev campus 
+	}
 }
 
 //checks if the file exists, then rename the new
@@ -136,6 +126,7 @@ if($currentTool=='document/createdraw'){
 
 	//check path
 	if(!isset($_SESSION['draw_file'])){
+		api_not_allowed(false);//from Chamilo
 		die();
 	}
 	if($_SESSION['draw_file']==$drawFileName){		

BIN
main/inc/lib/svg-edit/images/mascot.png


+ 2 - 2
main/inc/lib/svg-edit/svg-editor.js

@@ -468,7 +468,7 @@
 				path = svgCanvas.pathActions,
 				undoMgr = svgCanvas.undoMgr,
 				Utils = svgCanvas.Utils,
-				default_img_url = curConfig.imgPath + "logo.png",
+				default_img_url = curConfig.imgPath + "mascot.png",
 				workarea = $("#workarea"),
 				canv_menu = $("#cmenu_canvas"),
 				layer_menu = $("#cmenu_layers"),
@@ -3319,7 +3319,7 @@
 			
 			// Test for embedImage support (use timeout to not interfere with page load)
 			setTimeout(function() {
-				svgCanvas.embedImage('images/logo.png', function(datauri) {
+				svgCanvas.embedImage('images/mascot.png', function(datauri) {
 					if(!datauri) {
 						// Disable option
 						$('#image_save_opts [value=embed]').attr('disabled','disabled');

+ 9 - 4
main/inc/lib/svg-edit/svg-editor.php

@@ -666,19 +666,24 @@ script type="text/javascript" src="locale/locale.min.js"></script-->
 			<legend id="svginfo_editor_prefs">Editor Preferences</legend>
 
 			<label><span id="svginfo_lang">Language:</span>
-				<!-- Source: http://en.wikipedia.org/wiki/Language_names -->
+				<!-- Source: http://en.wikipedia.org/wiki/Language_names --><!-- Add for Chamilo bulgarian, (Български), italian (Italiano), hungarian (Magyar), indonesian (Bahasa Indonesia) -->
 				<select id="lang_select">
 				  <option id="lang_ar" value="ar">العربية</option>
-					<option id="lang_cs" value="cs">Čeština</option>
+                  
+                  	<option id="lang_id" value="id">Bahasa Indonesia</option>
+                  	<option id="lang_bg" value="bg">Български</option>
+            		<option id="lang_cs" value="cs">Čeština</option>
 					<option id="lang_de" value="de">Deutsch</option>
 					<option id="lang_en" value="en" selected="selected">English</option>
-					<option id="lang_es" value="es">Español</option>
+					<option id="lang_es" value="es">Español</option>                    
 					<option id="lang_fa" value="fa">فارسی</option>
 					<option id="lang_fr" value="fr">Français</option>
 					<option id="lang_fy" value="fy">Frysk</option>
 					<option id="lang_hi" value="hi">&#2361;&#2367;&#2344;&#2381;&#2342;&#2368;, &#2361;&#2367;&#2306;&#2342;&#2368;</option>
-					<option id="lang_ja" value="ja">日本語</option>
+					<option id="lang_it" value="it">Italiano</option>
+                    <option id="lang_ja" value="ja">日本語</option>
 					<option id="lang_nl" value="nl">Nederlands</option>
+                    <option id="lang_hu" value="hu">Magyar</option>
 					<option id="lang_pt-BR" value="pt-BR">Português (BR)</option>
 					<option id="lang_ro" value="ro">Româneşte</option>
 					<option id="lang_ru" value="ru">Русский</option>

+ 1 - 0
main/install/install.lib.php

@@ -207,6 +207,7 @@ function detect_browser_language() {
 	return 'english';
 }
 
+
 /*		FILESYSTEM RELATED FUNCTIONS */
 
 /**

+ 1 - 1
main/install/migrate-db-1.8.7-1.8.8-pre.sql

@@ -39,7 +39,7 @@ UPDATE settings_current SET selected_value='1' WHERE variable='allow_message_too
 INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('course_validation', NULL, 'radio', 'Platform', 'false', 'EnableCourseValidation', 'EnableCourseValidationComment', NULL, NULL, 0);
 INSERT INTO settings_options (variable, value, display_text) VALUES ('course_validation', 'true', 'Yes');
 INSERT INTO settings_options (variable, value, display_text) VALUES ('course_validation', 'false', 'No');
-
+UPDATE settings_current SET selected_value='1' WHERE variable='advanced_filemanager';
 -- xxSTATSxx
 ALTER TABLE track_e_exercices ADD COLUMN orig_lp_item_view_id INT NOT NULL DEFAULT 0;
 

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

@@ -1207,4 +1207,6 @@ $MyTextHere = "Въведете вашия текст тук...";
 $ReviewCourseRequests = "Преглед на заявките за нови курсове";
 $AcceptedCourseRequests = "Одобрени заявки за курсове";
 $RejectedCourseRequests = "Отхвърлени заявки за курсове";
+$EnableCourseValidation = "Одобряване на новите курсове";
+$EnableCourseValidationComment = "Когато функцията \"Одобряване на новите курсове\" е активирана, преподавател не може да създава нов курс. Той/тя попълва заявка за нов курс. Администраторът на системата преглежда заявката и или я одобрява, или я отхвърля.<br />Тази функция силно зависи от автоматично генерирани e-mail съобщения; настройте достъп на системата до e-mail сървър чрез специално открит за нея акаунт.";
 ?>

+ 28 - 2
main/lang/bulgarian/create_course.inc.php

@@ -113,7 +113,33 @@ $CourseRequestCreated = "Вашата заявка за нов курс е из
 $CreateThisCourseRequest = "Създаване на заявката";
 $CourseRequestDate = "Дата на заявката";
 $AcceptThisCourseRequest = "Одобряване и създаване на курса";
-$ANewCourseWillBeCreated = "Ще се създаде нов курс. Да се направи ли това?";
-$AdditionalInfoWillBeAsked = "Ще се изпрати e-mail с искане за допълнителна информация относно заявката. Да се направи ли това?";
+$ANewCourseWillBeCreated = "Ще се създаде нов курс %s. Да се изпълни ли това действие?";
+$AdditionalInfoWillBeAsked = "Ще се изпрати e-mail с искане за допълнителна информация относно заявката %s. Да се изпълни ли това действие?";
 $AskAdditionalInfo = "Искане на допълнителна информация";
+$DeleteThisCourseRequest = "Изтриване на заявката";
+$ACourseRequestWillBeDeleted = "Заявката %s ще бъде изтрита. Да се изпълни ли това действие?";
+$RejectThisCourseRequest = "Отхвърляне на заявката";
+$ACourseRequestWillBeRejected = "Заявката %s ще бъде отхвърлена. Да се изпълни ли това действие?";
+$CourseRequestAccepted = "Заявката %s е одобрена. Създаден е нов курс %s.";
+$CourseRequestAcceptanceFailed = "Заявката %s не можа да бъде одобрена поради появила се грешка.";
+$CourseRequestRejected = "Заявката %s е отхвърлена.";
+$CourseRequestRejectionFailed = "Заявката %s не можа да бъде отхвърлена поради появила се грешка.";
+$CourseRequestInfoAsked = "Изпратено е искане за допълнителна информация по заявката %s.";
+$CourseRequestInfoFailed = "Искане за допълнителна информация по заявката %s не беше изпратено поради появила се грешка.";
+$CourseRequestDeleted = "Заявката %s е изтрита.";
+$CourseRequestDeletionFailed = "Заявката %s не можа да бъде изтрита поради появила се грешка.";
+$DeleteCourseRequests = "Изтриване на избраните заявки за курсове";
+$SelectedCourseRequestsDeleted = "Избраните заявки за курсове са изтрити.";
+$SomeCourseRequestsNotDeleted = "Някои от избраните заявки за курсове не са изтрити поради появила се грешка.";
+$CourseRequestEmailSubject = "%s Заявка за нов курс %s";
+$CourseRequestMailOpening = "Регистрирана е следната заявка за нов курс:";
+$CourseRequestPageForApproval = "Тази заявка може да бъде одобрена на страницата:";
+$PleaseActivateCourseValidationFeature = "Функцията \"Одобряване на курсове\" не е активна в момента. За да я активирате използвайте настройката %s.";
+$CourseRequestLegalNote = "Информацията в тази заявка е защитена; тя може да служи само за обслужване на процедурата по откриване на нов учебен курс в нашия учебен портал; тя не може да бъде разкривана пред трети страни.";
+$CourseRequestAskInfoEmailSubject = "%s Искане за допълнителна информация относно заявката за нов курс %s";
+$CourseRequestAskInfoEmailText = "Получихме вашата заявка за нов курс с код %s. За да я разгледаме за одобрение, ние се нуждаем от допълнителна информация.\n\nМоля, изпратете ни информация относно съдържанието на курса (описание), относно целите на курса и относно курсистите (целевата аудитория). Ако е приложимо, споменете институцията или организационното звено, от чието име сте подали заявката.";
+$CourseRequestAcceptedEmailSubject = "%s Заявката за нов курс %s е одобрена";
+$CourseRequestAcceptedEmailText = "Вашата заявка %s е одобрена. Създаден е нов курс %s за който сте регистрирани като преподавател.\n\nМожете да получите достъп до своя курс оттук: %s";
+$CourseRequestRejectedEmailSubject = "%s Заявката за нов курс %s е отхвърлена";
+$CourseRequestRejectedEmailText = "За съжаление Вашата заявка за нов курс %s е отхвърлена, тъй като не отговаря на нашите Условия за ползване.";
 ?>

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

@@ -1274,4 +1274,7 @@ $AllowUsersCopyFilesComment = "Allows users to copy files from a course in your
 $ReviewCourseRequests = "Review incoming training requests";
 $AcceptedCourseRequests = "Accepted training requests";
 $RejectedCourseRequests = "Rejected training requests";
+$BrowscapInfo = "Browscap loading browscap.ini file that contains a large amount of data on the browser and its capabilities, so it can be used by the function get_browser () PHP";
+$EnableCourseValidation = "Training validation";
+$EnableCourseValidationComment = "When \"Training validation\" feature is activated, a teacher is not able to create a training alone. He/she fills a training request. The platform administrator reviews the request and approves it or rejects it.<br />This feature relies on automated e-mail messages; set Chamilo to access an e-mail server and to use a dedicated an e-mail account.";
 ?>

+ 29 - 3
main/lang/english/create_course.inc.php

@@ -110,10 +110,36 @@ $Objectives = "Objectives";
 $TargetAudience = "Target audience";
 $YouHaveToAcceptTermsAndConditions = "You have to accept our Terms and Conditions in order to request a new training.";
 $CourseRequestCreated = "Your request for a new training has been sent successfully. You may receive a reply soon, within one or two days.";
-$CreateThisCourseRequest = "Create this course request";
+$CreateThisCourseRequest = "Create this training request";
 $CourseRequestDate = "Request date";
 $AcceptThisCourseRequest = "Accept this training";
-$ANewCourseWillBeCreated = "A new training is going to be created. Is it OK to proceed?";
-$AdditionalInfoWillBeAsked = "Additional information about this training request is going to be asked through an e-mail message. Is it OK to proceed?";
+$ANewCourseWillBeCreated = "A new training %s is going to be created. Is it OK to proceed?";
+$AdditionalInfoWillBeAsked = "Additional information about %s training request is going to be asked through an e-mail message. Is it OK to proceed?";
 $AskAdditionalInfo = "Ask for additional information";
+$DeleteThisCourseRequest = "Delete this training request";
+$ACourseRequestWillBeDeleted = "The training request %s is going to be deleted. Is it OK to proceed?";
+$RejectThisCourseRequest = "Reject this training request";
+$ACourseRequestWillBeRejected = "The training request %s is going to be rejected. Is it OK to proceed?";
+$CourseRequestAccepted = "The course request %s has been accepted. A new training %s has been created.";
+$CourseRequestAcceptanceFailed = "The course request %s has not been accepted due to internal error.";
+$CourseRequestRejected = "The training request %s has been rejected.";
+$CourseRequestRejectionFailed = "The training request %s has not been rejected due to internal error.";
+$CourseRequestInfoAsked = "Additional information about the training request %s has been asked.";
+$CourseRequestInfoFailed = "Additional information about the training request %s has not been asked due to internal error.";
+$CourseRequestDeleted = "The training request %s has been deleted.";
+$CourseRequestDeletionFailed = "The training request %s has not been deleted due to internal error.";
+$DeleteCourseRequests = "Delete selected training request(s)";
+$SelectedCourseRequestsDeleted = "The selected course requests have been deleted.";
+$SomeCourseRequestsNotDeleted = "Some of the selected course requests have not been deleted due to internal error.";
+$CourseRequestEmailSubject = "%s A request for a new training %s";
+$CourseRequestMailOpening = "We registered the following request for a new training:";
+$CourseRequestPageForApproval = "This training request can be accepted (approved) at the following page:";
+$PleaseActivateCourseValidationFeature = "The \"Training validation\" feature is not active at the moment. In order to use this feature, please, activate it by using the setting %s.";
+$CourseRequestLegalNote = "The information of this training request is considered as protected; it can be used only for serving the procedure of opening a new training within our training portal; it should not be revealed to third parties.";
+$CourseRequestAskInfoEmailSubject = "%s A request for additional information about the training request %s";
+$CourseRequestAskInfoEmailText = "We have received your request for a new training with code %s. But before we consider it for approval we need some additional information.\n\nPlease, provide brief information about the training content (description), the objectives, the students or the users that are to be involved in the proposed training. If it is applicable, mention the name of the institution or the unit on which behalf you made the training request.";
+$CourseRequestAcceptedEmailSubject = "%s The training request %s has been approved";
+$CourseRequestAcceptedEmailText = "Your training request %s has been approved. A new course %s has been created and you are registered in it as a teacher.\n\nYou can access your newly created course from: %s";
+$CourseRequestRejectedEmailSubject = "%s The training request %s has been rejected";
+$CourseRequestRejectedEmailText = "To our regret we have to inform you that the training request %s has been rejected due to not conforming to the requirements of our Terms and Conditions.";
 ?>

+ 1 - 0
main/lang/english/trad4all.inc.php

@@ -968,4 +968,5 @@ $TermsAndConditions = "Terms and Conditions";
 $ReadTermsAndConditions = "Read the Terms and Conditions";
 $IAcceptTermsAndConditions = "I have read and I accept the Terms and Conditions";
 $YouHaveToAcceptTermsAndConditions = "You have to accept our Terms and Conditions to proceed.";
+$BrowserDontSupportsSVG = "Your browser does not support SVG files. To use the drawing tool you must have an advanced browser like: Firefox 1.5+, Chrome 1+, Safari 4+, Opera 9.50+ or IE9";
 ?>

+ 5 - 0
main/lang/galician/admin.inc.php

@@ -1269,4 +1269,9 @@ $ErrorReadingZip = "Erro lendo arquivo ZIP";
 $ErrorStylesheetFilesExtensionsInsideZip = "As únicas extensións aceptadas no ZIP son jpg, jpeg, png, gif e css.";
 $MyTextHere = "Introduza o seu texto aquí...";
 $FieldTypeSocialProfile = "Ligazón da rede social";
+$AllowUsersCopyFilesTitle = "Permitir aos usuarios copiar arquivos dun curso na súa área de arquivos peroais";
+$AllowUsersCopyFilesComment = "Permite aos usuarios copiar arquivos dun curso na súa área persoal, visible a través da ferramente de Rede Social ou mediante o editor HTML canso se atopa fóra dun curso";
+$ReviewCourseRequests = "Validar cursos";
+$AcceptedCourseRequests = "Cursos validados";
+$RejectedCourseRequests = "Cursos rexeitados";
 ?>

+ 1 - 0
main/lang/galician/courses.inc.php

@@ -83,4 +83,5 @@ $Collapse = "Contraer";
 $CourseDetails = "Descrición do curso";
 $GroupPendingInvitations = "Invitacións de grupo pendentes";
 $Compose = "Redactar";
+$ThereAreNoCoursesInThisCategory = "Non existen cursos na categoria actual";
 ?>

+ 10 - 0
main/lang/galician/create_course.inc.php

@@ -106,4 +106,14 @@ $Create = "Crear";
 $MessageOfNewCourseToAdmin = "Esta mensaxe é para informarte que se ven de crear un novo curso na plataforma";
 $NewCourseCreatedIn = "Novo curso creado en";
 $ExplicationTrainers = "O profesor está definido como vostede por agora. Poderá cambialo na páxina de configuración do curso.";
+$Objectives = "Obxectivos";
+$TargetAudience = "Destinatarios";
+$YouHaveToAcceptTermsAndConditions = "Debe aceptar as condicións do servizo para poder solicitar un curso";
+$CourseRequestCreated = "Recibiuse correctamente a súa solicitude de curso. En breve ( un ou dous días laborais) recibirá resposta sobre a mesma";
+$CreateThisCourseRequest = "Solicitude de novo curso";
+$CourseRequestDate = "Data de solicitude";
+$AcceptThisCourseRequest = "Validar este curso";
+$ANewCourseWillBeCreated = "Crearase o curso indicado";
+$AdditionalInfoWillBeAsked = "Enviar un correo-e solicitando información adicional";
+$AskAdditionalInfo = "Pedir máis información";
 ?>

+ 2 - 0
main/lang/galician/tracking.inc.php

@@ -273,4 +273,6 @@ $DisplayCourseOverview = "Vista xeral de cursos";
 $DisplaySessionOverview = "Vista xeral de sesións";
 $TotalNumberOfMessages = "Número total de mensaxes";
 $TotalNumberOfAssignments = "Número total de tarefas";
+$LastLogins = "Última conexión";
+$AllLogins = "Todas as conexións";
 ?>

+ 16 - 0
main/lang/galician/trad4all.inc.php

@@ -955,4 +955,20 @@ $QualifyInGradebook = "Cualificación no libro de cualificacións";
 $SessionSpecificResource = "Recurso específico da sesión";
 $EditionNotAvailableFromSession = "Edición non dispoñible dende a sesión, por favor edite dende o propio curso.";
 $HandingOverOfTaskX = "Porcentaxe completada da tarefa %s";
+$ProtectedDocument = "Documento protexido";
+$ConnectionsLastMonth = "Conexións o mes pasado";
+$TotalStudents = "Alumnos totais";
+$FilteringWithScoreX = "Filtrado con resultado%s";
+$ExamTaken = "Tomado";
+$ExamNotTaken = "Non tomado";
+$ExamPassX = "Aprobado con mínimo de %s";
+$ExamFail = "Suspenso";
+$ExamTracking = "Seguimento exames";
+$NoAttempt = "Sen intentar";
+$PassExam = "Aprobado";
+$CreateCourseRequest = "Solicitude de novo curso";
+$TermsAndConditions = "Termos e condicións";
+$ReadTermsAndConditions = "Ler as condicións do servizo";
+$IAcceptTermsAndConditions = "Lin e acepto as condicións do servizo";
+$YouHaveToAcceptTermsAndConditions = "Aceptaches os nosos Termos e Condicións para continuar";
 ?>

+ 1 - 0
main/lang/galician/userInfo.inc.php

@@ -194,4 +194,5 @@ $YouNeedToHaveFriendsInYourSocialNetwork = "Precisa ter amigos na súa rede soci
 $SeeAllMyGroups = "Ver tódolos meus grupos";
 $YouAlreadyInviteAllYourContacts = "Xa invitou a tódolos seus contactos";
 $YouShouldCreateAGroup = "Debería crear un grupo";
+$MyFiles = "Os meus arquivos";
 ?>

+ 3 - 0
main/lang/italian/admin.inc.php

@@ -1276,4 +1276,7 @@ $MyTextHere = "Scrivi qui dentro...";
 $FieldTypeSocialProfile = "Collegamento alla rete sociale";
 $AllowUsersCopyFilesTitle = "Consenti agli utenti di fare una copia di file del corso nella propria area personale";
 $AllowUsersCopyFilesComment = "Consenti agli utenti di fare una copia di file del corso nell'area personale, rendendoli visibili tramite la rete sociale o un browser/editor, nel caso siano esterni al corso";
+$ReviewCourseRequests = "Attivare i corsi richiesti";
+$AcceptedCourseRequests = "Corsi confermati";
+$RejectedCourseRequests = "Corsi non confermati";
 ?>

+ 6 - 0
main/lang/italian/create_course.inc.php

@@ -106,4 +106,10 @@ $Create = "Crea";
 $MessageOfNewCourseToAdmin = "Caro %s, nn questo messaggio ti informa che sulla piattaforma %s - %s nn è stato creato il nuovo corson Titolo: %s n Categoria: %s n Creato da: %s n Lingua: %s\";";
 $NewCourseCreatedIn = "Nuovo corso creato in";
 $ExplicationTrainers = "Ora sei tu il docente del corso; in seguito potrai configurare altre persone come docenti.";
+$Objectives = "Obiettivi";
+$TargetAudience = "Destinatari";
+$YouHaveToAcceptTermsAndConditions = "Per poter richiedere un corso devi accettare i Termini e le Condizioni d'uso";
+$CourseRequestCreated = "La tua richiesta di attivazione di un corso è stata inviata correttamente. Riceverai entro pochi giorni una risposta dal responsabile.";
+$CreateThisCourseRequest = "Invia la richiesta di attivazione";
+$CourseRequestDate = "Data della richiesta";
 ?>

+ 3 - 3
main/lang/italian/exercice.inc.php

@@ -33,7 +33,7 @@ $langUsedInSeveralExercises = "Attenzione! Questo quesito e le rispettive rispos
 $langModifyInAllExercises = "in tutti i Test";
 $langModifyInThisExercise = "solo in questo Test";
 $langAnswerType = "Tipologia di risposta";
-$langMultipleSelect = "Risposta multipla";
+$langMultipleSelect = "Risposte multiple";
 $langFillBlanks = "Riempimento";
 $langMatching = "Abbinamento";
 $langAddPicture = "Aggiungi un'immagine";
@@ -358,8 +358,8 @@ $RandomAnswers = "Mescola le risposte";
 $NotMarkActivity = "Non è possibile valutare l'attività";
 $YouHaveToCreateAtLeastOneAnswer = "Devi indicare almeno una risposta valida";
 $ExerciseAttempted = "Quesito affrontato";
-$MultipleSelectCombination = "Selezione multipla";
-$MultipleAnswerCombination = "Risposta multipla";
+$MultipleSelectCombination = "Selezione esatta";
+$MultipleAnswerCombination = "Combinazione esatta";
 $ExerciceExpiredTimeMessage = "Il tempo assegnato allo svolgimento dell'esercizio è scaduto; i quesiti completati saranno comunque presi in considerazione.";
 $CopyExercise = "Duplica il quesito creandone una copia";
 $CleanStudentResults = "Cancella i risultati attribuiti a tutti i corsisti per questo quesito";

+ 5 - 0
main/lang/italian/trad4all.inc.php

@@ -968,4 +968,9 @@ $ExamFail = "Non superato";
 $ExamTracking = "Storico esami";
 $NoAttempt = "Nessun tentativo";
 $PassExam = "Superato";
+$CreateCourseRequest = "Richiedi un nuovo corso";
+$TermsAndConditions = "Termini e Condizioni";
+$ReadTermsAndConditions = "Leggi i Termini e le Condizioni";
+$IAcceptTermsAndConditions = "Ho letto e accettato i Termini e le Condizioni del servizio";
+$YouHaveToAcceptTermsAndConditions = "Per procedere devi accettare i Termini e le Condizioni del servizio";
 ?>

+ 6 - 5
main/lang/spanish/admin.inc.php

@@ -1160,10 +1160,10 @@ $GraphicNotAvailable = "Gráfico no disponible";
 $AttendancesFaults = "Faltas de asistencia";
 $Minutes = "Minutos";
 $SystemStatus = "Información del sistema";
-$IsWritable = "Se puede escribir en él";
+$IsWritable = "La escritura es posible en";
 $DirectoryExists = "El directorio existe";
-$DirectoryMustBeWritable = "El directorio debe permitir al servidor web escribir en él";
-$DirectoryShouldBeRemoved = "El directorio debería ser eliminado (ya no es necesario)";
+$DirectoryMustBeWritable = "El Servidor Web tiene que poder escribir en este directorio";
+$DirectoryShouldBeRemoved = "Es conveniente que elimine este directorio (ya no es necesario)";
 $Section = "Sección";
 $Expected = "Esperado";
 $Setting = "Parámetro";
@@ -1184,7 +1184,7 @@ $MemoryLimitInfo = "Límite máximo de memoria para  la ejecución de un script.
 $MagicQuotesGpcInfo = "Permite escapar automaticamente valores de GET, POST y COOKIES. Una característica similar es provista para  los datos requeridos en este software, así que su uso provoca una doble barra de escape en los valores.";
 $VariablesOrderInfo = "El orden de preferencia de las variables del Entorno, GET, POST, COOKIES y SESSION";
 $MaxExecutionTimeInfo = "Tiempo máximo que un script puede tomar para su ejecución. Si se utiliza más, el script es abandonado para evitar la ralentización de otros usuarios.";
-$ExtensionMustBeLoaded = "Esta extensión debe ser cargada.";
+$ExtensionMustBeLoaded = "Esta extensión debe estar cargada.";
 $MysqlProtoInfo = "Protocolo MySQL";
 $MysqlHostInfo = "Servidor MySQL";
 $MysqlServerInfo = "Información del servidor MySQL";
@@ -1246,7 +1246,7 @@ $AllUsersAreAutomaticallyRegistered = "Todos los usuarios serán agregados autom
 $AssignCoach = "Asignar tutor";
 $chamilo = "chamilo";
 $php = "php";
-$Off = "Apagado";
+$Off = "Desactivado";
 $minimum = "mínimo";
 $webserver = "Webserver";
 $mysql = "mysql";
@@ -1274,4 +1274,5 @@ $AllowUsersCopyFilesComment = "Permite a los usuarios copiar archivos de un curs
 $ReviewCourseRequests = "Validar Cursos";
 $AcceptedCourseRequests = "Cursos Validados";
 $RejectedCourseRequests = "Cursos Rechazados";
+$BrowscapInfo = "Browscap carga el archivo browscap.ini que contiene una gran cantidad de datos sobre los navegadores y sus capacidades, para que pueda ser usada por la función get_browser() de PHP";
 ?>

+ 6 - 2
main/lang/spanish/create_course.inc.php

@@ -113,7 +113,11 @@ $CourseRequestCreated = "Se recibió correctamente su solicitud de curso. En bre
 $CreateThisCourseRequest = "Solicitud de nuevo curso";
 $CourseRequestDate = "Fecha Solicitud";
 $AcceptThisCourseRequest = "Validar este curso";
-$ANewCourseWillBeCreated = "Se creará un curso indicado.";
-$AdditionalInfoWillBeAsked = "Enviar un e-mail solicitando información adicional.";
+$ANewCourseWillBeCreated = "Se creará un curso indicado (%s).";
+$AdditionalInfoWillBeAsked = "Enviar un e-mail solicitando información adicional (%s).";
 $AskAdditionalInfo = "Pedir más información";
+$CourseRequestEmailSubject = "%s Solicitud de nuevo curso %s";
+$CourseRequestMailOpening = "Se registró la siguiente solicitud para un curso nuevo:";
+$CourseRequestPageForApproval = "Puede validar la solicitud en:";
+$CourseRequestAskInfoEmailSubject = "%s Solicitud de informacion %s";
 ?>

+ 1 - 1
main/lang/spanish/registration.inc.php

@@ -138,7 +138,7 @@ $MyProgress = "Mi progreso";
 $ProgressIntroduction = "Seleccione una sesión del curso.<br/>Podrá ver su progreso en cada uno de los cursos en los que esté inscrito.";
 $Select = "Seleccionar";
 $NeverExpires = "Nunca caduca";
-$On = "En";
+$On = "Activado";
 $ExpirationDate = "Fecha de caducidad";
 $ActiveAccount = "Activar cuenta";
 $YourAccountHasToBeApproved = "Su registro deberá ser aprobado posteriormente";

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

@@ -968,4 +968,6 @@ $CreateCourseRequest = "Solicitud de nuevo curso";
 $TermsAndConditions = "Términos y condiciones";
 $ReadTermsAndConditions = "Leer las condiciones del servicio";
 $IAcceptTermsAndConditions = "He leido y acepto las condiciones del servicio";
+$YouHaveToAcceptTermsAndConditions = "Para continuar debe aceptar nuestros términos y condiciones";
+$BrowserDontSupportsSVG = "Su navegador no soporta archivos SVG. Para poder utilizar esta herramienta debe tener instalado un navegador avanzado del tipo: Firefox 1.5+, Chrome 1+, Safari 4+, Opera 9.50+ o IE9";
 ?>

+ 5 - 1
main/newscorm/resourcelinker.inc.php

@@ -271,7 +271,11 @@ function display_addedresource_link($type, $id, $style = '') {
             $ext = explode('.', $filename);
             $ext = strtolower($ext[sizeof($ext)-1]);
             $myrow['path'] = rawurlencode($myrow['path']);
-            $in_frames = in_array($ext, array('htm', 'html', 'gif', 'jpg', 'jpeg', 'png'));
+			if (api_support_svg()){
+            	$in_frames = in_array($ext, array('htm', 'html', 'gif', 'jpg', 'jpeg', 'png', 'svg','svgz'));
+			}else{
+				$in_frames = in_array($ext, array('htm', 'html', 'gif', 'jpg', 'jpeg', 'png'));
+			}
             echo '<img src="../img/'.$image.'" align="middle" /> <a href="../document/'.($in_frames ? 'showinframes.php?file=' : 'download.php?doc_url=').$myrow['path'].'"'.$styling.'>'.$filename."</a><br />\n";
             break;
         case 'Externallink':

+ 172 - 172
main/user/user_add.php

@@ -26,75 +26,75 @@ $tbl_courseUser    = "course_rel_user";
 /* DATA CHECKING	*/
 
 if($register) {
-	/*
-	 * Fields Checking
-	 */
+    /*
+     * Fields Checking
+     */
 
-	$lastname_form    = trim($lastname_form);
-	$firstname_form   = trim($firstname_form);
-	$password_form = trim($password_form);
-	$username_form = trim($username_form);
-	$email_form    = trim($email_form);
-	$official_code_form = trim($official_code_form);
+    $lastname_form    = trim($lastname_form);
+    $firstname_form   = trim($firstname_form);
+    $password_form = trim($password_form);
+    $username_form = trim($username_form);
+    $email_form    = trim($email_form);
+    $official_code_form = trim($official_code_form);
 
-	// empty field checking
+    // empty field checking
 
-	if(empty($lastname_form) || empty($firstname_form) || empty($password_form) || empty($username_form) || empty($email_form))
-	{
-		$dataChecked = false;
-		$message     = get_lang('Filled');
-	}
+    if(empty($lastname_form) || empty($firstname_form) || empty($password_form) || empty($username_form) || empty($email_form))
+    {
+        $dataChecked = false;
+        $message     = get_lang('Filled');
+    }
 
-	// valid mail address checking
+    // valid mail address checking
 
-	elseif(!eregi('^[0-9a-z_.-]+@([0-9a-z-]+\.)+([0-9a-z]){2,4}$',$email_form))
-	{
-		$dataChecked = false;
-		$message     = get_lang('EmailWrong');
-	}
-	else
-	{
-		$dataChecked = true;
-	}
+    elseif(!eregi('^[0-9a-z_.-]+@([0-9a-z-]+\.)+([0-9a-z]){2,4}$',$email_form))
+    {
+        $dataChecked = false;
+        $message     = get_lang('EmailWrong');
+    }
+    else
+    {
+        $dataChecked = true;
+    }
 
-	// prevent conflict with existing user account
+    // prevent conflict with existing user account
 
-	if($dataChecked)
-	{
-		$result=Database::query("SELECT user_id,
-		                       (username='$username_form') AS loginExists,
-		                       (lastname='$lastname_form' AND firstname='$firstname_form' AND email='$email_form') AS userExists
-		                     FROM $tbl_user
-		                     WHERE username='$username_form' OR (lastname='$lastname_form' AND firstname='$firstname_form' AND email='$email_form')
-		                     ORDER BY userExists DESC, loginExists DESC");
+    if($dataChecked)
+    {
+        $result=Database::query("SELECT user_id,
+                               (username='$username_form') AS loginExists,
+                               (lastname='$lastname_form' AND firstname='$firstname_form' AND email='$email_form') AS userExists
+                             FROM $tbl_user
+                             WHERE username='$username_form' OR (lastname='$lastname_form' AND firstname='$firstname_form' AND email='$email_form')
+                             ORDER BY userExists DESC, loginExists DESC");
 
-		if(Database::num_rows($result))
-		{
-			while($user=Database::fetch_array($result))
-			{
-				// check if the user is already registered to the platform
+        if(Database::num_rows($result))
+        {
+            while($user=Database::fetch_array($result))
+            {
+                // check if the user is already registered to the platform
 
-				if($user['userExists'])
-				{
-					$userExists = true;
-					$userId     = $user['user_id'];
-					break;
-				}
+                if($user['userExists'])
+                {
+                    $userExists = true;
+                    $userId     = $user['user_id'];
+                    break;
+                }
 
-				// check if the login name choosen is already taken by another user
+                // check if the login name choosen is already taken by another user
 
-				if($user['loginExists'])
-				{
-					$loginExists = true;
-					$userId      = 0;
+                if($user['loginExists'])
+                {
+                    $loginExists = true;
+                    $userId      = 0;
 
-					$message     = get_lang('UserNo')." (".stripslashes($username_form).") ".get_lang('Taken');
+                    $message     = get_lang('UserNo')." (".stripslashes($username_form).") ".get_lang('Taken');
 
-					break;
-				}
-			}				// end while $result
-		}					// end if num rows
-	}						// end if datachecked
+                    break;
+                }
+            }				// end while $result
+        }					// end if num rows
+    }						// end if datachecked
 
 
 
@@ -104,118 +104,118 @@ if($register) {
   NEW USER REGISTRATION PROCESS
   =============================*/
 
-	if($dataChecked && !$userExists && !$loginExists)
-	{
-			/*---------------------------
-			      PLATFORM REGISTRATION
-			  ----------------------------*/
-
-		if ($_cid) $platformStatus = STUDENT;          // course registrartion context...
-		else       $platformStatus = $platformStatus; // admin section of the platform context...
-
-		//if ($userPasswordCrypted) $pw = md5($password_form);
-		//else                      $pw = $password_form;
-		$pw = api_get_encrypted_password($password_form);
-		$result = Database::query("INSERT INTO $tbl_user
-		                       SET lastname       = '$lastname_form',
-		                           firstname    = '$firstname_form',
-		                           username  = '$username_form',
-		                           password  = '$pw',
-		                           email     = '$email_form',
-		                           status    = '$platformStatus',
-		                           official_code = '$official_code_form',
-		                           creator_id = '".$_user['user_id']."'");
-
-		$userId = Database::insert_id();
-
-		if ($userId) $platformRegSucceed = true;
-	}
-
-	if($userId && $_cid)
-	{
-		/*
-		  Note : As we temporarly use this script in the platform administration
-		  section to also add user to the platform, We have to prevent course
-		  registration. That's why we check if $_cid is initialized, it gives us
-		  an hint about the use context of the script
-		*/
-
-			/*---------------------------
-			      COURSE REGISTRATION
-			  ----------------------------*/
-
-		/*
-		 * check the return value of the query
-		 * if 0, the user is already registered to the course
-		 */
-
-		if (Database::query("INSERT INTO $tbl_courseUser
-						SET user_id     = '$userId',
-							course_code  = '$currentCourseID',
-							status      = '$admin_form',
-							tutor_id       = '$tutor_form'"))
-		{
-			$courseRegSucceed = true;
-		}
-	} // if $platformRegSucceed && $_cid
-
-
-	/*---------------------------
-	   MAIL NOTIFICATION TO NEW USER
-	  ----------------------------*/
-
-	if ($platformRegSucceed)
-	{
-
-		$emailto       = "$lastname_form $firstname_form <$email_form>";
-		$emailfromaddr = $administratorEmail;
-		$emailfromname = api_get_setting('siteName');
-		$emailsubject  = get_lang('YourReg').' '.api_get_setting('siteName');
-
-		$emailheaders  = "From: ".api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'), null, PERSON_NAME_EMAIL_ADDRESS)." <".$administratorEmail.">\n";
-		$emailheaders .= "Reply-To: ".$administratorEmail."\n";
-		$emailheaders .= "Return-Path: ".$administratorEmail."\n";
-		$emailheaders .= "charset: ".api_get_system_encoding()."\n";
-		$emailheaders .= "X-Mailer: PHP/" . phpversion() . "\n";
-		$emailheaders .= "X-Sender-IP: $REMOTE_ADDR"; // (small security precaution...)
-		$recipient_name = api_get_person_name($firstname_form, $lastname_form, null, PERSON_NAME_EMAIL_ADDRESS);
-		$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');
-
-		$portal_url = $_configuration['root_web'];
-		if ($_configuration['multiple_access_urls']) {
-			$access_url_id = api_get_current_access_url_id();
-			if ($access_url_id != -1 ){
-				$url = api_get_access_url($access_url_id);
-				$portal_url = $url['url'];
-			}
-		}
-
-		if ($courseRegSucceed)
-		{
-			$emailbody = get_lang('Dear')." ".stripslashes(api_get_person_name($firstname_form, $lastname_form)).",\n".get_lang('OneResp')." $currentCourseName ".get_lang('RegYou')." ".api_get_setting('siteName')." ".get_lang('WithTheFollowingSettings')."\n\n".get_lang('Username')." : $username_form\n".get_lang('Pass').": $password_form\n".get_lang('Address')." ".api_get_setting('siteName')." ".get_lang('Is').": ".$portal_url."\n".get_lang('Problem')."\n".get_lang('Formula').",\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')."\n";
-			$message = get_lang('TheU')." ".stripslashes(api_get_person_name($firstname_form, $lastname_form))." ".get_lang('AddedToCourse')."<a href=\"user.php\">".get_lang('BackUser')."</a>\n";
-		}
-		else
-		{
-			$emailbody = get_lang('Dear')." ".api_get_person_name($firstname_form, $lastname_form).",\n ".get_lang('YouAreReg')."  ".api_get_setting('siteName')."  ".get_lang('WithTheFollowingSettings')."\n\n".get_lang('Username')." : $username_form\n".get_lang('Pass').": $password_form\n".get_lang('Address')." ".api_get_setting('siteName')." ".get_lang('Is').": ".$portal_url."\n".get_lang('Problem')."\n".get_lang('Formula').",\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')."\n";
-
-			$message = stripslashes(api_get_person_name($firstname_form, $lastname_form))." ".get_lang('AddedU');
-		}
-
-		@api_mail($recipient_name, $email_form, $emailsubject, $emailbody, $sender_name,$email_admin);
-
-		/*
-		 * remove <form> variables to prevent any pre-filled fields
-		 */
-
-		unset($lastname_form, $firstname_form, $username_form, $password_form, $email_form, $admin_form, $tutor_form);
-
-	} 	// end if ($platformRegSucceed)
-	//else
-	//{
-	//	$message = get_lang('UserAlreadyRegistered');
-	//}
+    if($dataChecked && !$userExists && !$loginExists)
+    {
+            /*---------------------------
+                  PLATFORM REGISTRATION
+              ----------------------------*/
+
+        if ($_cid) $platformStatus = STUDENT;          // course registrartion context...
+        else       $platformStatus = $platformStatus; // admin section of the platform context...
+
+        //if ($userPasswordCrypted) $pw = md5($password_form);
+        //else                      $pw = $password_form;
+        $pw = api_get_encrypted_password($password_form);
+        $result = Database::query("INSERT INTO $tbl_user
+                               SET lastname       = '$lastname_form',
+                                   firstname    = '$firstname_form',
+                                   username  = '$username_form',
+                                   password  = '$pw',
+                                   email     = '$email_form',
+                                   status    = '$platformStatus',
+                                   official_code = '$official_code_form',
+                                   creator_id = '".$_user['user_id']."'");
+
+        $userId = Database::insert_id();
+
+        if ($userId) $platformRegSucceed = true;
+    }
+
+    if($userId && $_cid)
+    {
+        /*
+          Note : As we temporarly use this script in the platform administration
+          section to also add user to the platform, We have to prevent course
+          registration. That's why we check if $_cid is initialized, it gives us
+          an hint about the use context of the script
+        */
+
+            /*---------------------------
+                  COURSE REGISTRATION
+              ----------------------------*/
+
+        /*
+         * check the return value of the query
+         * if 0, the user is already registered to the course
+         */
+
+        if (Database::query("INSERT INTO $tbl_courseUser
+                        SET user_id     = '$userId',
+                            course_code  = '$currentCourseID',
+                            status      = '$admin_form',
+                            tutor_id       = '$tutor_form'"))
+        {
+            $courseRegSucceed = true;
+        }
+    } // if $platformRegSucceed && $_cid
+
+
+    /*---------------------------
+       MAIL NOTIFICATION TO NEW USER
+      ----------------------------*/
+
+    if ($platformRegSucceed)
+    {
+
+        $emailto       = "$lastname_form $firstname_form <$email_form>";
+        $emailfromaddr = $administratorEmail;
+        $emailfromname = api_get_setting('siteName');
+        $emailsubject  = get_lang('YourReg').' '.api_get_setting('siteName');
+
+        $emailheaders  = "From: ".api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'), null, PERSON_NAME_EMAIL_ADDRESS)." <".$administratorEmail.">\n";
+        $emailheaders .= "Reply-To: ".$administratorEmail."\n";
+        $emailheaders .= "Return-Path: ".$administratorEmail."\n";
+        $emailheaders .= "charset: ".api_get_system_encoding()."\n";
+        $emailheaders .= "X-Mailer: PHP/" . phpversion() . "\n";
+        $emailheaders .= "X-Sender-IP: $REMOTE_ADDR"; // (small security precaution...)
+        $recipient_name = api_get_person_name($firstname_form, $lastname_form, null, PERSON_NAME_EMAIL_ADDRESS);
+        $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');
+
+        $portal_url = $_configuration['root_web'];
+        if ($_configuration['multiple_access_urls']) {
+            $access_url_id = api_get_current_access_url_id();
+            if ($access_url_id != -1 ){
+                $url = api_get_access_url($access_url_id);
+                $portal_url = $url['url'];
+            }
+        }
+
+        if ($courseRegSucceed)
+        {
+            $emailbody = get_lang('Dear')." ".stripslashes(api_get_person_name($firstname_form, $lastname_form)).",\n".get_lang('OneResp')." $currentCourseName ".get_lang('RegYou')." ".api_get_setting('siteName')." ".get_lang('WithTheFollowingSettings')."\n\n".get_lang('Username')." : $username_form\n".get_lang('Pass').": $password_form\n".get_lang('Address')." ".api_get_setting('siteName')." ".get_lang('Is').": ".$portal_url."\n".get_lang('Problem')."\n".get_lang('Formula').",\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')."\n";
+            $message = get_lang('TheU')." ".stripslashes(api_get_person_name($firstname_form, $lastname_form))." ".get_lang('AddedToCourse')."<a href=\"user.php\">".get_lang('BackUser')."</a>\n";
+        }
+        else
+        {
+            $emailbody = get_lang('Dear')." ".api_get_person_name($firstname_form, $lastname_form).",\n ".get_lang('YouAreReg')."  ".api_get_setting('siteName')."  ".get_lang('WithTheFollowingSettings')."\n\n".get_lang('Username')." : $username_form\n".get_lang('Pass').": $password_form\n".get_lang('Address')." ".api_get_setting('siteName')." ".get_lang('Is').": ".$portal_url."\n".get_lang('Problem')."\n".get_lang('Formula').",\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')."\n";
+
+            $message = stripslashes(api_get_person_name($firstname_form, $lastname_form))." ".get_lang('AddedU');
+        }
+
+        @api_mail($recipient_name, $email_form, $emailsubject, $emailbody, $sender_name,$email_admin);
+
+        /*
+         * remove <form> variables to prevent any pre-filled fields
+         */
+
+        unset($lastname_form, $firstname_form, $username_form, $password_form, $email_form, $admin_form, $tutor_form);
+
+    } 	// end if ($platformRegSucceed)
+    //else
+    //{
+    //	$message = get_lang('UserAlreadyRegistered');
+    //}
 
 } // end if register request
 
@@ -259,7 +259,7 @@ if(!empty($message))
   <td colspan="2">
 
 <?php
-	Display::display_normal_message($message); //main API
+    Display::display_normal_message($message); //main API
 ?>
 
   </td>
@@ -327,7 +327,7 @@ if ($_cid) // if we're inside a course, then it's a course registration
 <?php
 
 }			// end if $_cid - for the case we're not in a course registration
-			// but a platform registration
+            // but a platform registration
 else
 {
 
@@ -360,11 +360,11 @@ else
 
 if($is_platformAdmin)
 {
-	echo "<a href=\"".$rootAdminWeb."importUserList.php\">".get_lang('UserMany')."</a>";
+    echo "<a href=\"".$rootAdminWeb."importUserList.php\">".get_lang('UserMany')."</a>";
 } // if is_platformAdmin
 else
 {
-	echo "<p>".get_lang('IfYouWantToAddManyUsers')."</p>";
+    echo "<p>".get_lang('IfYouWantToAddManyUsers')."</p>";
 }
 
 Display::display_footer();

File diff suppressed because it is too large
+ 222 - 230
user_portal.php


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