Browse Source

Merging changes from the 1.9.x branch

Julio Montoya 12 years ago
parent
commit
6547127382
52 changed files with 705 additions and 584 deletions
  1. 1 0
      README.txt
  2. 5 2
      main/admin/settings.lib.php
  3. 12 14
      main/admin/settings.php
  4. 1 2
      main/admin/system_announcements.php
  5. 3 8
      main/announcements/announcement_email.class.php
  6. 1 1
      main/attendance/attendance_sheet.php
  7. 122 46
      main/auth/inscription.php
  8. 4 5
      main/calendar/agenda.lib.php
  9. 7 4
      main/course_info/infocours.php
  10. 25 28
      main/css/base.css
  11. 41 14
      main/document/document_quota.php
  12. 2 7
      main/dropbox/dropbox_download.php
  13. 37 12
      main/dropbox/dropbox_functions.inc.php
  14. 0 2
      main/dropbox/dropbox_init.inc.php
  15. 115 159
      main/exercice/exercise.class.php
  16. 10 10
      main/exercice/exercise.lib.php
  17. 3 6
      main/exercice/exercise_reminder.php
  18. 15 13
      main/exercice/exercise_result.php
  19. 1 3
      main/exercice/exercise_submit.php
  20. 1 1
      main/exercice/global_multiple_answer.class.php
  21. 2 2
      main/exercice/multiple_answer_combination_true_false.class.php
  22. 47 33
      main/exercice/multiple_answer_true_false.class.php
  23. 3 4
      main/exercice/question_list_admin.inc.php
  24. 5 4
      main/gradebook/lib/fe/gradebooktable.class.php
  25. 13 6
      main/gradebook/lib/gradebook_functions.inc.php
  26. 9 9
      main/inc/lib/course.lib.php
  27. 2 4
      main/inc/lib/document.lib.php
  28. 1 0
      main/inc/lib/fckeditor/editor/css/fck_internal.css
  29. 2 2
      main/inc/lib/fckeditor/editor/fckeditor.html
  30. 2 3
      main/inc/lib/formvalidator/Rule/Date.php
  31. 1 4
      main/inc/lib/formvalidator/Rule/Username.php
  32. 7 7
      main/inc/lib/formvalidator/Rule/UsernameAvailable.php
  33. 14 4
      main/inc/lib/groupmanager.lib.php
  34. 1 1
      main/inc/lib/login.lib.php
  35. 17 1
      main/inc/lib/main_api.lib.php
  36. 7 0
      main/inc/lib/message.lib.php
  37. 18 3
      main/inc/lib/notification.lib.php
  38. 1 1
      main/inc/lib/online.inc.php
  39. 4 5
      main/inc/lib/phpmailer/class.phpmailer.php
  40. 1 1
      main/inc/lib/social.lib.php
  41. 21 16
      main/inc/lib/system_announcements.lib.php
  42. 10 12
      main/inc/lib/template.lib.php
  43. 1 1
      main/inc/lib/usermanager.lib.php
  44. 10 1
      main/install/index.php
  45. 6 1
      main/install/install.lib.php
  46. 3 1
      main/install/update-db-1.8.8-1.9.0.inc.php
  47. 4 4
      main/install/version.php
  48. 19 4
      main/newscorm/learnpath.class.php
  49. 8 5
      main/survey/create_new_survey.php
  50. 38 37
      main/user/user.php
  51. 22 71
      main/work/work.php
  52. BIN
      tests/history/1.9.0/640x480/course-home1.png

+ 1 - 0
README.txt

@@ -1 +1,2 @@
 For more information on Chamilo, open documentation/index.html in this directory with a web browser.
+

+ 5 - 2
main/admin/settings.lib.php

@@ -1075,6 +1075,8 @@ function generate_settings_form($settings, $settings_by_access_list) {
     
     $default_values = array();    
     
+    $url_info = api_get_access_url($url_id);
+    
     $i = 0;
     foreach ($settings as $row) {      
     	if (in_array($row['variable'], array_keys($settings_to_avoid))) { continue; } 
@@ -1105,12 +1107,13 @@ function generate_settings_form($settings, $settings_by_access_list) {
 
         $hideme = array();
         $hide_element = false;
+        
         if ($_configuration['access_url'] != 1) {
             if ($row['access_url_changeable'] == 0) {
                 // We hide the element in other cases (checkbox, radiobutton) we 'freeze' the element.
                 $hide_element = true;
                 $hideme = array('disabled');
-            } elseif ($url_info['active'] == 1) {
+            } elseif ($url_info['active'] == 1) {                
                 // We show the elements.
                 if (empty($row['variable']))
                     $row['variable'] = 0;
@@ -1118,7 +1121,7 @@ function generate_settings_form($settings, $settings_by_access_list) {
                     $row['subkey'] = 0;
                 if (empty($row['category']))
                     $row['category'] = 0;
-
+                
                 if (is_array($settings_by_access_list[ $row['variable'] ] [ $row['subkey'] ] [ $row['category'] ])) {
                     // We are sure that the other site have a selected value.
                     if ($settings_by_access_list[ $row['variable'] ] [ $row['subkey'] ] [ $row['category'] ]['selected_value'] != '')

+ 12 - 14
main/admin/settings.php

@@ -93,18 +93,18 @@ $settings = null;
 
 function get_settings($category = null) {
     $url_id = api_get_current_access_url_id();
+    $settings_by_access_list = array();
     
     if ($url_id == 1) {    
         $settings = api_get_settings($category, 'group', $url_id);        
     } else {
-        $url_info = api_get_access_url($url_id);
+        $url_info = api_get_access_url($url_id);    
         if ($url_info['active'] == 1) {
             // The default settings of Chamilo
             $settings = api_get_settings($category, 'group', 1, 0);
             // The settings that are changeable from a particular site.
-            $settings_by_access = api_get_settings($category, 'group', $url_id, 1);
+            $settings_by_access = api_get_settings($category, 'group', $url_id, 1);                        
             
-            $settings_by_access_list = array();
             foreach ($settings_by_access as $row) {
                 if (empty($row['variable']))
                     $row['variable'] = 0;
@@ -120,22 +120,21 @@ function get_settings($category = null) {
                     $settings_by_access_list[ $row['variable'] ] [ $row['subkey'] ] [ $row['category'] ]  = array();
             }
         }
-    }
-    
+    }    
     if (isset($category) && $category== 'search_setting') {  
         if (!empty($_REQUEST['search_field'])) {
             $settings = search_setting($_REQUEST['search_field']);                               
         }
     }
-    return $settings;
+    return array('settings' => $settings, 'settings_by_access_list' => $settings_by_access_list);
 }
 
-
 // Build the form.
 if (!empty($_GET['category']) && !in_array($_GET['category'], array('Plugins', 'stylesheets', 'Search'))) {
     $my_category = isset($_GET['category']) ? $_GET['category'] : null;
-    $settings = get_settings($my_category);
-    
+    $settings_array = get_settings($my_category);
+    $settings = $settings_array['settings'];
+    $settings_by_access_list = $settings_array['settings_by_access_list'];    
     $form = generate_settings_form($settings, $settings_by_access_list);
         
     $message = array();
@@ -146,7 +145,7 @@ if (!empty($_GET['category']) && !in_array($_GET['category'], array('Plugins', '
         $mark_all = false;
         $un_mark_all = false;
         
-        if ( $_configuration['multiple_access_urls']) {        
+        if ($_configuration['multiple_access_urls']) {        
             if (isset($values['buttons_in_action_right']) && isset($values['buttons_in_action_right']['mark_all'])) {
                 $mark_all = true;
             }
@@ -179,7 +178,9 @@ if (!empty($_GET['category']) && !in_array($_GET['category'], array('Plugins', '
                     }
                 }
                 //Reload settings
-                $settings = get_settings($my_category);
+                $settings_array = get_settings($my_category);
+                $settings = $settings_array['settings'];
+                $settings_by_access_list = $settings_array['settings_by_access_list'];
                 $form = generate_settings_form($settings, $settings_by_access_list);
             }
         }                
@@ -380,9 +381,6 @@ $action_images['plugins']       = 'plugins.png';
 $action_images['shibboleth']    = 'shibboleth.png';
 $action_images['facebook']      = 'facebook.png';
 
-// Grabbing the categories.
-//$resultcategories = api_get_settings_categories(array('stylesheets', 'Plugins', 'Templates', 'Search'));
-
 $action_array = array();
 $resultcategories = array();
 

+ 1 - 2
main/admin/system_announcements.php

@@ -19,10 +19,9 @@ require_once '../inc/global.inc.php';
 
 // Including additional libraries.
 require_once api_get_path(LIBRARY_PATH).'WCAG/WCAG_rendering.php';
-require_once api_get_path(LIBRARY_PATH).'mail.lib.inc.php';
 
 // Setting the section (for the tabs).
-$this_section=SECTION_PLATFORM_ADMIN;
+$this_section = SECTION_PLATFORM_ADMIN;
 $_SESSION['this_section']=$this_section;
 
 // Access restrictions

+ 3 - 8
main/announcements/announcement_email.class.php

@@ -255,20 +255,15 @@ class AnnouncementEmail
      */
     public function send()
     {
-        $sender = $this->sender();
-        $sender_name = api_get_person_name($sender['firstName'], $sender['lastName'], null, PERSON_NAME_EMAIL_ADDRESS);
-        $sender_email = $sender['mail'];
-
+        $sender  = $this->sender();                
         $subject = $this->subject();
         $message = $this->message();
     
         // Send email one by one to avoid antispam
         $users = $this->sent_to();
+        
         foreach ($users as $user) {
-            MessageManager::send_message($user['user_id'], $subject, $message, null, null, null, null, null, null, $sender['user_id']);
-            //$recipient_name = api_get_person_name($user['firstname'], $user['lastname'], null, PERSON_NAME_EMAIL_ADDRESS);
-            //$recipient_email = $user['email'];
-            //@api_mail_html($recipient_name, $recipient_email, $subject, $message, $sender_name, $sender_email, null, $attachement, true);
+            MessageManager::send_message_simple($user['user_id'], $subject, $message, $sender['user_id']);
         }
         $this->log_mail_sent();
     }

+ 1 - 1
main/attendance/attendance_sheet.php

@@ -212,7 +212,7 @@ if (api_is_allowed_to_edit(null, true)) {
                             }                                   
                                                 
                             $result .= '<th width="800px">';
-                            $result .= '<center><div style="font-size:10px;width:100px;">'.$datetime.'&nbsp;';                            
+                            $result .= '<center><div style="font-size:10px;width:120px;">'.$datetime.'&nbsp;';                            
                             $result .= '<span id="attendance_lock" style="cursor:pointer">'.(!$is_locked_attendance || api_is_platform_admin()?$img_lock:'').'</span>';
                             
                             if ($is_locked_attendance == false) {

+ 122 - 46
main/auth/inscription.php

@@ -33,7 +33,17 @@ if (api_get_setting('allow_terms_conditions') == 'true') {
     $user_already_registered_show_terms = false;
 }
 
-if ($user_already_registered_show_terms == false) {
+//Direct Link Subscription feature #5299
+$course_code_redirect = isset($_REQUEST['c']) && !empty($_REQUEST['c']) ? $_REQUEST['c'] : null;
+$exercise_redirect = isset($_REQUEST['e']) && !empty($_REQUEST['e']) ? $_REQUEST['e'] : null;
+
+if (!empty($course_code_redirect)) {
+    Session::write('course_redirect',   $course_code_redirect);
+    Session::write('exercise_redirect', $exercise_redirect);
+}
+
+if ($user_already_registered_show_terms == false) {    
+            
     if (api_is_western_name_order()) {
         //	FIRST NAME and LAST NAME
         $form->addElement('text', 'firstname', get_lang('FirstName'), array('size' => 40));
@@ -83,6 +93,7 @@ if ($user_already_registered_show_terms == false) {
         $form->addRule('username', get_lang('UsernameWrong'), 'username');
         $form->addRule('username', get_lang('UserTaken'), 'username_available');
     }
+    
     //	PASSWORD
     $form->addElement('password', 'pass1', get_lang('Pass'),         array('size' => 20, 'autocomplete' => 'off'));
     $form->addElement('password', 'pass2', get_lang('Confirmation'), array('size' => 20, 'autocomplete' => 'off'));
@@ -174,6 +185,8 @@ if (is_array($extra_data)) {
 
 $form->setDefaults($defaults);
 
+$content = null;
+
 if (!CustomPages::enabled()) {
     // Load terms & conditions from the current lang
     if (api_get_setting('allow_terms_conditions') == 'true') {
@@ -209,9 +222,6 @@ if (!CustomPages::enabled()) {
         $tool_name = get_lang('TermsAndConditions');
     }
 
-    Display :: display_header($tool_name);
-    echo Display::page_header($tool_name);
-
     $home = api_get_path(SYS_PATH).'home/';
     if ($_configuration['multiple_access_urls']) {
         $access_url_id = api_get_current_access_url_id();
@@ -231,24 +241,22 @@ if (!CustomPages::enabled()) {
         $open = str_replace('{rel_path}', api_get_path(REL_PATH), $home_top_temp);
         $open = api_to_system_encoding($open, api_detect_encoding(strip_tags($open)));
         if (!empty($open)) {
-            echo '<div class="well_border">'.$open.'</div>';
+            $content =  '<div class="well_border">'.$open.'</div>';
         }
     }
-
-    // Forbidden to self-register
-    /*
+    
+    // Forbidden to self-register    
     if (api_get_setting('allow_registration') == 'false') {
-        api_not_allowed();
-    }*/
-
-    //api_display_tool_title($tool_name);
+        api_not_allowed(true);
+    }
+    
     if (api_get_setting('allow_registration') == 'approval') {
-        Display::display_normal_message(get_lang('YourAccountHasToBeApproved'));
+        $content .= Display::return_message(get_lang('YourAccountHasToBeApproved'));
     }
     
     //if openid was not found
     if (!empty($_GET['openid_msg']) && $_GET['openid_msg'] == 'idnotfound') {
-        Display::display_warning_message(get_lang('OpenIDCouldNotBeFoundPleaseRegister'));
+        $content .= Display::return_message(get_lang('OpenIDCouldNotBeFoundPleaseRegister'));
     }
 }
 
@@ -284,7 +292,7 @@ if (api_get_setting('allow_terms_conditions') == 'true') {
     }
 }
 
-$form->addElement('button', 'submit', get_lang('RegisterUser'));
+$form->addElement('button', 'submit', get_lang('RegisterUser'), array('class' => 'btn btn-primary btn-large'));
 
 if ($form->validate()) {
     
@@ -381,7 +389,7 @@ if ($form->validate()) {
                 }
                 $emailbody		.= get_lang('Email',null,$values['language']).': '.$values['email']."\n";
                 $emailbody		.= get_lang('Status',null,$values['language']).': '.$values['status']."\n\n";
-                $url_edit       = Display::url(api_get_path(WEB_CODE_PATH).'admin/user_edit.php?user_id='.$user_id, api_get_path(WEB_CODE_PATH).'admin/user_edit.php?user_id='.$user_id);
+                $url_edit        = Display::url(api_get_path(WEB_CODE_PATH).'admin/user_edit.php?user_id='.$user_id, api_get_path(WEB_CODE_PATH).'admin/user_edit.php?user_id='.$user_id);
                 $emailbody		.= get_lang('ManageUser',null,$values['language']).": $url_edit";
 
                 $admins = UserManager::get_all_administrators();
@@ -391,10 +399,11 @@ if ($form->validate()) {
                 
                 // 3. exit the page
                 unset($user_id);
-
-                if (!CustomPages::enabled()) {
-                    Display :: display_footer();
-                }
+                
+                Display :: display_header($tool_name);
+                echo Display::page_header($tool_name);    
+                echo $content;
+                Display::display_footer();
                 exit;
             }
         }
@@ -416,6 +425,7 @@ if ($form->validate()) {
     }
 
     /* SESSION REGISTERING */
+    /* @todo move this in a function */
     $_user['firstName'] = stripslashes($values['firstname']);
     $_user['lastName'] 	= stripslashes($values['lastname']);
     $_user['mail'] 		= $values['email'];
@@ -431,44 +441,110 @@ if ($form->validate()) {
 
     // last user login date is now
     $user_last_login_datetime = 0; // used as a unix timestamp it will correspond to : 1 1 1970
-
     Session::write('user_last_login_datetime', $user_last_login_datetime);
     $recipient_name = api_get_person_name($values['firstname'], $values['lastname']);
-    $display_text =  '<p>'.get_lang('Dear',null, $_user['language']).' '.stripslashes(Security::remove_XSS($recipient_name)).',<br /><br />'.get_lang('PersonalSettings',null,$_user['language']).".</p>\n";
-
-    if (api_get_setting('allow_terms_conditions') == 'true' && $user_already_registered_show_terms) {
-        $button_text = get_lang('Next',null,$_user['language']);
-        $action_url = api_get_path(WEB_PATH).'user_portal.php';
+    
+    $text_after_registration = '<p>'.get_lang('Dear', null, $_user['language']).' '.stripslashes(Security::remove_XSS($recipient_name)).',<br /><br />'.get_lang('PersonalSettings',null,$_user['language']).".</p>";
 
+    $form_data = array( 'button' => Display::button('next', get_lang('Next', null, $_user['language']), array('class' => 'btn btn-primary btn-large')),
+                        'message' => null,
+                        'action' => api_get_path(WEB_PATH).'user_portal.php');
+    
+    if (api_get_setting('allow_terms_conditions') == 'true' && $user_already_registered_show_terms) {        
+        $form_data['action'] = api_get_path(WEB_PATH).'user_portal.php';
     } else {
+        
         if (!empty ($values['email'])) {
-            $display_text.= '<p>'.get_lang('MailHasBeenSent',null,$_user['language']).'.</p>';
+            $text_after_registration.= '<p>'.get_lang('MailHasBeenSent',null,$_user['language']).'.</p>';
         }
-        $button_text = '';
-
+        
         if ($is_allowedCreateCourse) {
-            $display_text .= '<p>'. get_lang('NowGoCreateYourCourse',null,$_user['language']). ".</p>";
-            $action_url = '../create_course/add_course.php';
-            $button_text = api_get_setting('course_validation') == 'true'
-                ? get_lang('CreateCourseRequest', null, $_user['language'])
-                : get_lang('CourseCreate', null, $_user['language']);
+            $form_data['message'] = '<p>'. get_lang('NowGoCreateYourCourse',null,$_user['language']). "</p>";            
+            $form_data['action']  = '../create_course/add_course.php';
+            
+            if (api_get_setting('course_validation') == 'true') {                
+                $form_data['button'] = Display::button('next', get_lang('CreateCourseRequest', null, $_user['language']), array('class' => 'btn btn-primary btn-large'));
+            } else {
+                $form_data['button'] = Display::button('next', get_lang('CourseCreate', null, $_user['language']), array('class' => 'btn btn-primary btn-large'));                          
+            }
         } else {
-            if (api_get_setting('allow_students_to_browse_courses') == 'true')
-                $action_url = 'courses.php?action=subscribe';
-            else
-                $action_url = api_get_path(WEB_PATH).'user_portal.php';
-            $display_text.='<p>'. get_lang('NowGoChooseYourCourses',null,$_user['language']). ".</p>";
-            $button_text = get_lang('Next',null,$_user['language']);
+            if (api_get_setting('allow_students_to_browse_courses') == 'true') {
+                $form_data['action']    = 'courses.php?action=subscribe';
+                $form_data['message']   = '<p>'. get_lang('NowGoChooseYourCourses',null,$_user['language']). ".</p>";
+            } else {
+                $form_data['action']  = api_get_path(WEB_PATH).'user_portal.php';                
+            }     
+            $form_data['button'] = Display::button('next', get_lang('Next', null, $_user['language']), array('class' => 'btn btn-primary btn-large'));
         }
     }
-    $display_text .= '<form action="'. $action_url. '"  method="post">
-                    <button type="submit" class="next" name="next" value="'. get_lang('Next', null, $_user['language']). '" validationmsg=" '. get_lang('Next',null,$_user['language']). ' ">'. $button_text. '</button>'. "\n". '</form><br />'. "\n";
-    if (CustomPages::enabled()) {
-        CustomPages::display(CustomPages::REGISTRATION_FEEDBACK, array('info' => $display_text));
+    
+    /* 
+     * Direct course link see #5299
+     * 
+     * You can send to your students an URL like this 
+     * http://chamilodev.beeznest.com/main/auth/inscription.php?c=ABC&e=3
+     * Where "c" is the course code and "e" is the exercise Id, after a succesfull registration the user will be sent to the course or exercise
+     * 
+     */
+    $course_code_redirect = Session::read('course_redirect');
+        
+    if (!empty($course_code_redirect)) {
+        $course_info = api_get_course_info($course_code_redirect);        
+        if (!empty($course_info)) {
+            
+            if (in_array($course_info['visibility'], array(COURSE_VISIBILITY_OPEN_PLATFORM, COURSE_VISIBILITY_OPEN_WORLD))) {
+                $user_id = api_get_user_id();
+                if (CourseManager::subscribe_user($user_id, $course_info['code'])) {
+                                    
+                    $form_data['action'] = $course_info['course_public_url'];            
+                    $form_data['message'] = sprintf(get_lang('YouHaveBeenRegisteredToCourseX'), $course_info['title']);
+                    $form_data['button'] = Display::button('next', get_lang('GoToCourse', null, $_user['language']), array('class' => 'btn btn-primary btn-large'));                    
+                    
+                    $exercise_redirect = intval(Session::read('exercise_redirect'));
+                    
+                    if (!empty($exercise_redirect)) {
+                        $form_data['action'] = api_get_path(WEB_CODE_PATH).'exercice/overview.php?exerciseId='.intval($exercise_redirect).'&cidReq='.$course_info['code'];                                                
+                        $form_data['message'] .= '<br />'.get_lang('YouCanAccessTheExercise');
+                        $form_data['button'] = Display::button('next', get_lang('Go', null, $_user['language']), array('class' => 'btn btn-primary btn-large'));
+                    }
+                    
+                    if (!empty($form_data['action'])) {
+                        header('Location: '.$form_data['action']);
+                        exit;
+                    }
+                }
+            }
+        }
     }
-    echo $display_text;
+    
+    $form_register = new FormValidator('form_register', 'post', $form_data['action']);    
+    if (!empty($form_data['message'])) {
+        $form_register->addElement('html', $form_data['message'].'<br /><br />');
+    }    
+    $form_register->addElement('html', $form_data['button']);    
+    $text_after_registration .= $form_register->return_form();  
+    
+    //Just in case
+    Session::erase('course_redirect');
+    Session::erase('exercise_redirect');
+    
+    Display :: display_header($tool_name);
+    echo Display::page_header($tool_name);
+    
+    echo $content;    
+    echo $text_after_registration;
+    
+    if (CustomPages::enabled()) {
+        CustomPages::display(CustomPages::REGISTRATION_FEEDBACK, array('info' => $text_after_registration));
+    }    
 } else {
-  // Custom pages
+    
+    Display :: display_header($tool_name);
+    echo Display::page_header($tool_name);
+    
+    echo $content;    
+    
+    // Custom pages
     if (CustomPages::enabled()) {
         CustomPages::display(CustomPages::REGISTRATION, array('form' => $form));
     } else {

+ 4 - 5
main/calendar/agenda.lib.php

@@ -610,8 +610,8 @@ class Agenda {
                 
                 //Event Sent to a group?
                 if (isset($row['to_group_id']) && !empty($row['to_group_id'])) {
-                    if (!empty($group_to_array)) {
-                        $sent_to = array();
+                    $sent_to = array();
+                    if (!empty($group_to_array)) {                        
                         foreach($group_to_array as $group_item) {
                             $sent_to[] = $group_name_list[$group_item];        
                         }
@@ -625,9 +625,8 @@ class Agenda {
                 //Event sent to a user?
                 //var_dump($row);
                 if (isset($row['to_user_id'])) {
-                    
-                    if (!empty($user_to_array)) {
-                        $sent_to = array();
+                    $sent_to = array();
+                    if (!empty($user_to_array)) {                        
                         foreach($user_to_array as $item) {
                             $user_info = api_get_user_info($item);   
                             // add username as tooltip for $event['sent_to'] - ref #4226

+ 7 - 4
main/course_info/infocours.php

@@ -9,8 +9,8 @@
  * @todo Move $canBeEmpty from course_info.conf.php to config-settings
  * @todo Take those config settings into account in this script
  * @author Patrick Cool <patrick.cool@UGent.be>
- * @author Roan Embrechts, refactoring
- * and improved course visibility|subscribe|unsubscribe options
+ * @author Roan Embrechts, refactoring and improved course visibility|subscribe|unsubscribe options
+ * @author Julio Montoya <gugli100@gmail.com> Jquery support + lots of fixes
  * @package chamilo.course_info
  */
 
@@ -38,7 +38,7 @@ define('COURSE_CHANGE_PROPERTIES', 'COURSE_CHANGE_PROPERTIES');
 $currentCourseRepository    = $_course['path'];
 $is_allowedToEdit 			= $is_courseAdmin || $is_platformAdmin;
 
-$course_code 				= $_course['sysCode'];
+$course_code 				= api_get_course_id();
 $course_access_settings 	= CourseManager :: get_access_settings($course_code);
 
 //LOGIC FUNCTIONS
@@ -189,6 +189,10 @@ $group[]= $form->createElement('radio', 'visibility', null, get_lang('Private'),
 $group[]= $form->createElement('radio', 'visibility', null, get_lang('CourseVisibilityClosed'), COURSE_VISIBILITY_CLOSED);
 $form->addGroup($group, '', array(get_lang("CourseAccess"), get_lang("CourseAccessConfigTip")), '');
 
+$url = api_get_path(WEB_CODE_PATH)."auth/inscription.php?c=$course_code&e=".get_lang('there');
+$url = Display::url($url, $url);
+$form->addElement('label', get_lang('DirectLink'), sprintf(get_lang('CourseSettingsRegisterDirectLink'), $url));
+
 $group = array();
 $group[]=$form->createElement('radio', 'subscribe', get_lang('Subscription'), get_lang('Allowed'), 1);
 $group[]=$form->createElement('radio', 'subscribe', null, get_lang('Denied'), 0);
@@ -351,7 +355,6 @@ $app_plugin->add_course_settings_form($form);
 // Get all the course information
 $all_course_information =  CourseManager::get_course_information($_course['sysCode']);
 
-
 // Set the default values of the form
 $values = array();
 

+ 25 - 28
main/css/base.css

@@ -2550,14 +2550,12 @@ div.admin_section h4 {
     box-shadow: 0 1px 3px rgba(0,0,0,0.1);   
     position: relative;
     
-    background-image: -ms-linear-gradient(top, #992800, #C83F25);
-    background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#992800), to(#C83F25));
-    background-image: -webkit-linear-gradient(top, #992800, #C83F25);
-    background-image: -o-linear-gradient(top, #992800, #C83F25);
+    background-image: -ms-linear-gradient(top, #FDFDFD, #F3F5F7);
+    background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#FDFDFD), to(#F3F5F7));
+    background-image: -webkit-linear-gradient(top, #FDFDFD, #F3F5F7);
+    background-image: -o-linear-gradient(top, #FDFDFD, #F3F5F7);
     background-image: -moz-linear-gradient(top, #FDFDFD, #F3F5F7);
-    background-image: linear-gradient(top, #992800, #C83F25);
-    
-    
+    background-image: linear-gradient(top, #FDFDFD, #F3F5F7);
 }
 
 .ribbon .rib {    
@@ -2604,8 +2602,7 @@ div.admin_section h4 {
     background-image: -webkit-linear-gradient(top, #992800, #C83F25);
     background-image: -o-linear-gradient(top, #992800, #C83F25);
     background-image: -moz-linear-gradient(top, #992800, #C83F25);
-    background-image: linear-gradient(top, #992800, #C83F25);
-    
+    background-image: linear-gradient(top, #992800, #C83F25);    
     
     border-top: 1px solid #C56E5B;
     border-bottom: 1px solid #7A290F;
@@ -4593,27 +4590,27 @@ data table
 /* Only for Firefox */
 @-moz-document url-prefix() {
     select#question_type_hidden option {
-    padding: 10px 0px 10px 40px;
-    background-repeat:no-repeat;
+        padding: 10px 0px 10px 40px;
+        background-repeat:no-repeat;
+    }
+    select#question_type_hidden option[value="1"] {background-image: url(../img/icons/32/mcua.gif);}
+    select#question_type_hidden option[value="2"] {background-image: url(../img/icons/32/mcma.gif);}
+    select#question_type_hidden option[value="3"] {background-image: url(../img/icons/32/fill_in_blanks.gif);}
+    select#question_type_hidden option[value="4"] {background-image: url(../img/icons/32/matching.gif);}
+    select#question_type_hidden option[value="5"] {background-image: url(../img/icons/32/open_answer.gif);}
+    select#question_type_hidden option[value="6"] {background-image: url(../img/icons/32/hotspot.gif);}
+
+    select#question_type_hidden option[value="7"] {background-image: url(../img/icons/32/mcma.gif);}
+    select#question_type_hidden option[value="8"] {background-image: url(../img/icons/32/mcma.gif);}
+
+    select#question_type_hidden option[value="9"] {background-image: url(../img/icons/32/mcmac.gif);}
+    select#question_type_hidden option[value="10"] {background-image: url(../img/icons/32/mcuao.gif);}
+    select#question_type_hidden option[value="11"] {background-image: url(../img/icons/32/mcmao.gif);}
+    select#question_type_hidden option[value="12"] {background-image: url(../img/icons/32/mcmaco.gif);}
+    select#question_type_hidden option[value="13"] {background-image: url(../img/icons/32/audio_question.png);}
+    select#question_type_hidden option[value="14"] {background-image: url(../img/icons/32/mcmagl.gif);}
 }
 
-select#question_type_hidden option[value="1"] {background-image: url(../img/icons/32/mcua.gif);}
-select#question_type_hidden option[value="2"] {background-image: url(../img/icons/32/mcma.gif);}
-select#question_type_hidden option[value="3"] {background-image: url(../img/icons/32/fill_in_blanks.gif);}
-select#question_type_hidden option[value="4"] {background-image: url(../img/icons/32/matching.gif);}
-select#question_type_hidden option[value="5"] {background-image: url(../img/icons/32/open_answer.gif);}
-select#question_type_hidden option[value="6"] {background-image: url(../img/icons/32/hotspot.gif);}
-
-select#question_type_hidden option[value="7"] {background-image: url(../img/icons/32/mcma.gif);}
-select#question_type_hidden option[value="8"] {background-image: url(../img/icons/32/mcma.gif);}
-
-select#question_type_hidden option[value="9"] {background-image: url(../img/icons/32/mcmac.gif);}
-select#question_type_hidden option[value="10"] {background-image: url(../img/icons/32/mcuao.gif);}
-select#question_type_hidden option[value="11"] {background-image: url(../img/icons/32/mcmao.gif);}
-select#question_type_hidden option[value="12"] {background-image: url(../img/icons/32/mcmaco.gif);}
-select#question_type_hidden option[value="13"] {background-image: url(../img/icons/32/audio_question.png);}
-select#question_type_hidden option[value="14"] {background-image: url(../img/icons/32/mcmagl.gif);}
-}
 
 .btn-success.btn-install{
     float: right;

+ 41 - 14
main/document/document_quota.php

@@ -3,6 +3,9 @@
 $language_file = array('document');
 
 require_once '../inc/global.inc.php';
+
+require_once api_get_path(LIBRARY_PATH).'fileDisplay.lib.php';
+
 $current_course_tool = TOOL_DOCUMENT;
 $this_section = SECTION_COURSES;
 
@@ -15,34 +18,58 @@ $htmlHeadXtra[] = api_get_js('jqplot/plugins/jqplot.pieRenderer.min.js');
 $htmlHeadXtra[] = api_get_js('jqplot/plugins/jqplot.donutRenderer.min.js');
 $htmlHeadXtra[] = api_get_css(api_get_path(WEB_LIBRARY_PATH).'javascript/jqplot/jquery.jqplot.min.css');
 
-$course_id = api_get_course_id();
-$session_id = api_get_session_id();
+$course_code    = api_get_course_id();
+$course_id      = api_get_course_int_id();
+$session_id     = api_get_session_id();
+$group_id   = api_get_group_id();
 
 $session = array();
-$session_list = SessionManager::get_session_by_course($course_id);
-$total_quota = DocumentManager::get_course_quota();
+$session_list = SessionManager::get_session_by_course($course_code);
+
+$total_quota_bytes = DocumentManager::get_course_quota();
 
-$only_base_quota = DocumentManager::documents_total_space(api_get_course_int_id(), 0, 0);
+$quota_bytes = DocumentManager::documents_total_space($course_id, 0 , 0);
 
-$course_quota = round($only_base_quota/$total_quota, 2)*100;
-$session[] = array(get_lang('Course'), $course_quota);
+$quota_percentage = round($quota_bytes/$total_quota_bytes, 2)*100;
 
-$used_quota = $course_quota;
+$session[] = array(get_lang('Course').' ('.format_file_size($quota_bytes).')', $quota_percentage);
+
+$used_quota_bytes = $quota_bytes;
 if (!empty($session_list)) {
     foreach ($session_list as $session_data) {
-        $quota = intval(DocumentManager::documents_total_space(api_get_course_int_id(), null, $session_data['id']));
-        if (!empty($quota))  {
-            $quota = round($quota/$total_quota, 2)*100;
+        $quota_percentage = 0;
+        $quota_bytes = intval(DocumentManager::documents_total_space($course_id, null, $session_data['id']));
+        if (!empty($quota_bytes))  {
+            $quota_percentage = round($quota_bytes/$total_quota_bytes, 2)*100;
         }
         if ($session_id == $session_data['id']) {
             $session_data['name'] = $session_data['name'] . ' * ';
         }
-        $used_quota += $quota;
-        $session[] = array(addslashes($session_data['name']), $quota);
+        $used_quota_bytes += $quota_bytes;        
+        $session[] = array(addslashes(get_lang('Session').': '.$session_data['name']).' ('.format_file_size($quota_bytes).')', $quota_percentage);
+    }
+}
+
+$group_list = GroupManager::get_groups();
+
+if (!empty($group_list)) {
+    foreach ($group_list as $group_data) {
+        $quota_percentage = 0;
+        $my_group_id = $group_data['id'];
+        $quota_bytes = intval(DocumentManager::documents_total_space($course_id, $my_group_id, 0));        
+        if (!empty($quota_bytes))  {
+            $quota_percentage = round($quota_bytes/$total_quota_bytes, 2)*100;
+        }
+        if ($group_id == $my_group_id) {
+            $group_data['name'] = $group_data['name'] . ' * ';
+        }
+        $used_quota_bytes += $quota_bytes;        
+        $session[] = array(addslashes(get_lang('Group').': '.$group_data['name']).' ('.format_file_size($quota_bytes).')', $quota_percentage);
     }
 }
+$quota_percentage = round(($total_quota_bytes - $used_quota_bytes)/$total_quota_bytes, 2)*100;
 
-$session[] = array(addslashes(get_lang('ShowCourseQuotaUse')), 100 - $used_quota);
+$session[] = array(addslashes(get_lang('ShowCourseQuotaUse')).' ('.format_file_size($total_quota_bytes - $used_quota_bytes).') ', $quota_percentage);
 
 $quota_data = json_encode($session);
 

+ 2 - 7
main/dropbox/dropbox_download.php

@@ -83,11 +83,7 @@ if (!isset($_GET['id']) || !is_numeric($_GET['id'])) {
 
 // Check if the user is allowed to download the file
 $allowed_to_download = false;
-
-// Check if the user has sent or received the file.
-$sql = "SELECT * FROM ".$dropbox_cnf['tbl_person']." WHERE c_id = $course_id AND file_id='".intval($_GET['id'])."' AND user_id='".api_get_user_id()."'";
-$result = Database::query($sql);
-if (Database::num_rows($result) > 0) {
+if (user_can_download_file($_GET['id'], api_get_user_id())) {
 	$allowed_to_download = true;
 }
 
@@ -109,8 +105,7 @@ if (!$allowed_to_download) {
     if (!Security::check_abs_path($path, dropbox_cnf('sysPath').'/')) {
     	exit;
     }
-	$file = $work->title;
-	require_once api_get_path(LIBRARY_PATH).'document.lib.php';
+	$file = $work->title;	
 	$mimetype = DocumentManager::file_get_mime_type(true);
 	$fileinfo = pathinfo($file);
 	$extension = $fileinfo['extension'];

+ 37 - 12
main/dropbox/dropbox_functions.inc.php

@@ -968,18 +968,9 @@ function format_feedback($feedback) {
 * @version march 2006
 */
 function feedback_form() {
-    $course_id = api_get_course_int_id();
-
-	global $dropbox_cnf;
-
-	$return = get_lang('AddNewFeedback').'<br />';
-
-	// we now check if the other users have not delete this document yet. If this is the case then it is useless to see the
-	// add feedback since the other users will never get to see the feedback.
-	$sql = "SELECT * FROM ".$dropbox_cnf['tbl_person']." WHERE c_id = $course_id AND file_id = ".intval($_GET['id']);
-	$result = Database::query($sql);
-	$number_users_who_see_file = Database::num_rows($result);
-	if ($number_users_who_see_file > 1) {
+	$return = get_lang('AddNewFeedback').'<br />';	
+	$number_users_who_see_file = check_if_file_exist($_GET['id']);
+	if ($number_users_who_see_file) {
 		$token = Security::get_token();
 		$return .= '<textarea name="feedback" style="width: 80%; height: 80px;"></textarea>';
 		$return .= '<input type="hidden" name="sec_token" value="'.$token.'"/>';
@@ -991,6 +982,40 @@ function feedback_form() {
 	return $return;
 }
 
+function user_can_download_file($id, $user_id) {
+    global $dropbox_cnf;
+    $course_id = api_get_course_int_id();
+    $id = intval($id);
+    $user_id = intval($user_id);
+    
+    $sql = "SELECT file_id FROM ".$dropbox_cnf['tbl_person']." WHERE c_id = $course_id AND user_id = $user_id AND file_id = ".$id;    
+	$result = Database::query($sql);
+	$number_users_who_see_file = Database::num_rows($result);
+    
+    $sql = "SELECT file_id FROM ".$dropbox_cnf["tbl_post"]."  WHERE c_id = $course_id AND dest_user_id = $user_id AND file_id = ".$id;
+    $result = Database::query($sql);
+	$count = Database::num_rows($result);    
+    return $number_users_who_see_file > 0 || $count > 0;
+}
+
+// we now check if the other users have not delete this document yet. If this is the case then it is useless to see the
+	// add feedback since the other users will never get to see the feedback.
+function check_if_file_exist($id) {
+    global $dropbox_cnf;
+    $id = intval($id);
+    $course_id = api_get_course_int_id();
+    $sql = "SELECT file_id FROM ".$dropbox_cnf['tbl_person']." WHERE c_id = $course_id AND file_id = ".$id;    
+	$result = Database::query($sql);
+	$number_users_who_see_file = Database::num_rows($result);
+    
+    $sql = "SELECT file_id FROM ".$dropbox_cnf["tbl_post"]."  WHERE c_id = $course_id AND file_id = ".$id;
+    $result = Database::query($sql);
+	$count = Database::num_rows($result);    
+    return $number_users_who_see_file > 0 || $count > 0;
+}
+
+
+
 /**
 * @return a language string (depending on the success or failure.
 *

+ 0 - 2
main/dropbox/dropbox_init.inc.php

@@ -56,8 +56,6 @@ require_once api_get_path(LIBRARY_PATH).'fileUpload.lib.php';
 api_protect_course_script();
 
 /*	Libraries */
-require_once api_get_path(LIBRARY_PATH).'course.lib.php';
-require_once api_get_path(LIBRARY_PATH).'groupmanager.lib.php';
 
 // including the library for the sortable table
 //require_once api_get_path(LIBRARY_PATH).'tablesort.lib.php';moved to autoload

+ 115 - 159
main/exercice/exercise.class.php

@@ -646,7 +646,7 @@ class Exercise {
 		$sound                  = $this->sound;
 		$type                   = $this->type;
 		$attempts               = $this->attempts;
-		$feedback_type           = $this->feedback_type;
+		$feedback_type          = $this->feedback_type;
 		$random                 = $this->random;
 		$random_answers         = $this->random_answers;
 		$active                 = $this->active;
@@ -854,7 +854,7 @@ class Exercise {
 			$form_title = get_lang('NewEx');
 		}
         
-		$form->addElement('header', '', $form_title);
+		$form->addElement('header', $form_title);
         
 		// title
 		$form->addElement('text', 'exerciseTitle', get_lang('ExerciseName'), array('class' => 'span6','id'=>'exercise_title'));
@@ -1008,7 +1008,7 @@ class Exercise {
 				
 			$var = Exercise::selectTimeLimit();
             
-			if (($this->start_time!='0000-00-00 00:00:00'))
+			if (($this->start_time != '0000-00-00 00:00:00'))
                 $form->addElement('html','<div id="start_date_div" style="display:block;">');
 			else
                 $form->addElement('html','<div id="start_date_div" style="display:none;">');
@@ -1019,7 +1019,7 @@ class Exercise {
 
 			$form->addElement('checkbox', 'activate_end_date_check', null , get_lang('EnableEndTime'), array('onclick' => 'activate_end_date()'));
             
-			if (($this->end_time!='0000-00-00 00:00:00'))
+			if (($this->end_time != '0000-00-00 00:00:00'))
                 $form->addElement('html','<div id="end_date_div" style="display:block;">');
 			else
                 $form->addElement('html','<div id="end_date_div" style="display:none;">');
@@ -1101,7 +1101,7 @@ class Exercise {
 
 		$form->addRule('exerciseTitle', get_lang('GiveExerciseName'), 'required');
         
-		if ($type=='full') {
+		if ($type == 'full') {
 			// rules
 			$form->addRule('exerciseAttempts', get_lang('Numeric'), 'numeric');
 			$form->addRule('start_time', get_lang('InvalidDate'), 'date');
@@ -1132,13 +1132,13 @@ class Exercise {
                 $defaults['display_category_name']  = $this->selectDisplayCategoryName(); //                 
                 $defaults['pass_percentage']        = $this->selectPassPercentage();               
                 
-				if (($this->start_time!='0000-00-00 00:00:00'))
+				if (($this->start_time != '0000-00-00 00:00:00'))
                     $defaults['activate_start_date_check'] = 1;
-				if ($this->end_time!='0000-00-00 00:00:00')
+				if ($this->end_time != '0000-00-00 00:00:00')
                     $defaults['activate_end_date_check'] = 1;
 
-				$defaults['start_time'] = ($this->start_time!='0000-00-00 00:00:00') ? $this->start_time : date('Y-m-d 12:00:00');
-				$defaults['end_time']   = ($this->end_time!='0000-00-00 00:00:00') ? $this->end_time : date('Y-m-d 12:00:00',time()+84600);
+				$defaults['start_time'] = ($this->start_time!='0000-00-00 00:00:00') ? api_get_local_time($this->start_time) : date('Y-m-d 12:00:00');
+				$defaults['end_time']   = ($this->end_time!='0000-00-00 00:00:00') ? api_get_local_time($this->end_time) : date('Y-m-d 12:00:00', time()+84600);
 
 				//Get expired time
 				if($this->expired_time != '0') {					
@@ -1196,6 +1196,10 @@ class Exercise {
 
 		if ($form->getSubmitValue('activate_start_date_check') == 1) {
 			$start_time = $form->getSubmitValue('start_time');
+            $start_time['F'] = sprintf('%02d', $start_time['F']);
+            $start_time['i'] = sprintf('%02d', $start_time['i']);
+            $start_time['d'] = sprintf('%02d', $start_time['d']);
+            
 			$this->start_time = $start_time['Y'].'-'.$start_time['F'].'-'.$start_time['d'].' '.$start_time['H'].':'.$start_time['i'].':00';
 		} else {
 			$this->start_time = '0000-00-00 00:00:00';
@@ -1203,6 +1207,10 @@ class Exercise {
 
 		if ($form->getSubmitValue('activate_end_date_check') == 1) {
 			$end_time = $form->getSubmitValue('end_time');
+            $end_time['F'] = sprintf('%02d', $end_time['F']);
+            $end_time['i'] = sprintf('%02d', $end_time['i']);
+            $end_time['d'] = sprintf('%02d', $end_time['d']);
+            
 			$this->end_time = $end_time['Y'].'-'.$end_time['F'].'-'.$end_time['d'].' '.$end_time['H'].':'.$end_time['i'].':00';
 		} else {
 			$this->end_time   = '0000-00-00 00:00:00';
@@ -1662,8 +1670,7 @@ class Exercise {
                         send_form();
                     }
                 });                
-                $('#clock_warning').dialog('open');
-                
+                $('#clock_warning').dialog('open');                
 
                 $('#counter_to_redirect').epiclock({
                     mode: $.epiclock.modes.countdown,
@@ -1677,7 +1684,12 @@ class Exercise {
             
             function send_form() {
                 //console.log('send_form');
-                $('#exercise_form').submit();
+                if ($('#exercise_form').length) {                
+                    $('#exercise_form').submit();
+                } else {
+                    //In reminder
+                    final_submit();
+                }
             }
            
             function onExpiredTimeExercise() { 
@@ -1858,7 +1870,9 @@ class Exercise {
         if ($debug) error_log('manage_answer $learnpath_id: '.$learnpath_id);        
         if ($debug) error_log('manage_answer $learnpath_item_id: '.$learnpath_item_id);
         			
-		$extra_data = array();        
+		$extra_data = array();    
+        $arrques = null;
+        $arrans  = null;
 				 
 		$questionId   = intval($questionId);
 		$exeId        = intval($exeId);
@@ -2300,8 +2314,8 @@ class Exercise {
 						} else {
 							$totalScore+=$questionScore;
 						}
-						$arrques[] = $questionName;
-						$arrans[]  = $choice;
+						$arrques = $questionName;
+						$arrans  = $choice;
 					} else {
 						$studentChoice = $choice;
 						if ($studentChoice) {
@@ -2324,8 +2338,8 @@ class Exercise {
 						} else {
 							$totalScore+=$questionScore;
 						}
-						$arrques[] = $questionName;
-						$arrans[]  = $choice;
+						$arrques = $questionName;
+						$arrans  = $choice;
 					} else {
 						$studentChoice = $choice;
 						if ($studentChoice) {
@@ -2495,18 +2509,13 @@ class Exercise {
 							if ($origin!='learnpath') {
 								ExerciseShowFunctions::display_fill_in_blanks_answer($answer,0,0);
 							}
-						} elseif($answerType == FREE_ANSWER) {
-							// to store the details of open questions in an array to be used in mail
-							$arrques[] = $questionName;
-							$arrans[]  = $choice;
+						} elseif($answerType == FREE_ANSWER) {						
 							if($origin != 'learnpath') {
 								ExerciseShowFunctions::display_free_answer($choice,0,0);
 							}
 						} elseif($answerType == ORAL_EXPRESSION) {
-							// to store the details of open questions in an array to be used in mail
-							$arrques[] = $questionName;
-							$arrans[]  = $choice;
-							if($origin != 'learnpath') {								
+							// to store the details of open questions in an array to be used in mail							
+							if ($origin != 'learnpath') {								
 								ExerciseShowFunctions::display_oral_expression_answer($choice, 0, 0, $nano);
 							}
 						} elseif($answerType == HOT_SPOT) {
@@ -2744,8 +2753,7 @@ class Exercise {
 								$max_coord 			= poly_get_max($poly_user,$poly_answer);
 								$poly_user_compiled = poly_compile($poly_user,$max_coord);
 								$poly_answer_compiled = poly_compile($poly_answer,$max_coord);
-								$poly_results 		= poly_result($poly_answer_compiled,$poly_user_compiled,$max_coord);
-								 
+								$poly_results 		= poly_result($poly_answer_compiled,$poly_user_compiled,$max_coord);								 
 								 
 								$overlap = $poly_results['both'];
 								$poly_answer_area = $poly_results['s1'];
@@ -3187,7 +3195,13 @@ class Exercise {
 			if ($debug) error_log($sql_update);	
 			Database::query($sql_update);
 		}
-		$return_array = array('score'=>$questionScore, 'weight'=>$questionWeighting,'extra'=>$extra_data);
+        
+		$return_array = array(  'score'         => $questionScore, 
+                                'weight'        => $questionWeighting, 
+                                'extra'         => $extra_data, 
+                                'open_question' => $arrques, 
+                                'open_answer'   => $arrans
+        );        
 		return $return_array;
 	} //End function
 	
@@ -3195,148 +3209,88 @@ class Exercise {
 	 * Sends a notification when a user ends an examn
 	 * 
 	 */
-	function send_notification($arrques, $arrans, $origin) {		
+	function send_notification_for_open_questions($question_list_answers, $origin, $exe_id) {
 		
 		if (api_get_course_setting('email_alert_manager_on_new_quiz') != 1 ) {
-			return '';
-		}
-
+			return null;
+		}     
 		// Email configuration settings
 		$coursecode     = api_get_course_id();
 		$course_info    = api_get_course_info(api_get_course_id());
-		$to = '';
-		$teachers = array();
-		if (api_get_session_id()) {
-			$teachers = CourseManager::get_coach_list_from_course_code($coursecode, api_get_session_id());
-		} else {
-			$teachers = CourseManager::get_teacher_list_from_course_code($coursecode);
-		}
-		$num = count($teachers);
-		if ($num > 1) {
-			$to = array();
-			foreach($teachers as $teacher) {
-				$to[] = $teacher['email'];
-			}
-		} elseif ($num>0){
-			foreach($teachers as $teacher) {
-				$to = $teacher['email'];
-			}
-		} else {
-			//this is a problem (it means that there is no admin for this course)
-		}
-
-		$url_email = api_get_path(WEB_CODE_PATH).'exercice/exercise_report.php?'.api_get_cidreq().'&id_session='.api_get_session_id().'&exerciseId='.$this->id;
+	
+		$url_email = api_get_path(WEB_CODE_PATH).'exercice/exercise_show.php?'.api_get_cidreq().'&id_session='.api_get_session_id().'&id='.$exe_id.'&action=qualify';
 		$user_info = UserManager::get_user_info_by_id(api_get_user_id());
 
-		$mycharset = api_get_system_encoding();
-		$msg = '<html><head>
-                <link rel="stylesheet" href="'.api_get_path(WEB_CODE_PATH).'css/'.api_get_setting('stylesheets').'/default.css" type="text/css">
-                <meta content="text/html; charset='.$mycharset.'" http-equiv="content-type"></head>';
-
-		if (count($arrques) > 0) {
-			$msg .= '<body>
-            <p>'.get_lang('OpenQuestionsAttempted').' :
-            </p>
-            <p>'.get_lang('AttemptDetails').' : <br />
-            </p>
-            <table width="730" height="136" border="0" cellpadding="3" cellspacing="3">
-                                                    <tr>
-                <td width="229" valign="top"><h2>&nbsp;&nbsp;'.get_lang('CourseName').'</h2></td>
-                <td width="469" valign="top"><h2>#course#</h2></td>
-              </tr>
-              <tr>
-                <td width="229" valign="top" class="outerframe">&nbsp;&nbsp;'.get_lang('TestAttempted').'</span></td>
-                <td width="469" valign="top" class="outerframe">#exercise#</td>
-              </tr>
-              <tr>
-                <td valign="top">&nbsp;&nbsp;<span class="style10">'.get_lang('StudentName').'</span></td>
-                <td valign="top" >#firstName# #lastName#</td>
-              </tr>
-              <tr>
-                <td valign="top" >&nbsp;&nbsp;'.get_lang('StudentEmail').' </td>
-                <td valign="top"> #mail#</td>
-            </tr></table>
-            <p><br />'.get_lang('OpenQuestionsAttemptedAre').' :</p>
-             <table width="730" height="136" border="0" cellpadding="3" cellspacing="3">';
-
-			for($i=0;$i<sizeof($arrques);$i++) {
-				$msg.='
+		$msg = '<p>'.get_lang('OpenQuestionsAttempted').' :</p>
+                    <p>'.get_lang('AttemptDetails').' : </p>                     
+                    <table class="data_table">
                         <tr>
-                            <td width="220" valign="top" bgcolor="#E5EDF8">&nbsp;&nbsp;<span class="style10">'.get_lang('Question').'</span></td>
-                            <td width="473" valign="top" bgcolor="#F3F3F3"><span class="style16"> #questionName#</span></td>
+                            <td><h3>'.get_lang('CourseName').'</h3></td>
+                            <td><h3>#course#</h3></td>
                         </tr>
                         <tr>
-                            <td width="220" valign="top" bgcolor="#E5EDF8">&nbsp;&nbsp;<span class="style10">'.get_lang('Answer').' </span></td>
-                            <td valign="top" bgcolor="#F3F3F3"><span class="style16"> #answer#</span></td>
-                        </tr>';
-
-				$msg1   = str_replace("#exercise#",    $this->exercise, $msg);
-				$msg    = str_replace("#firstName#",   $user_info['firstname'],$msg1);
-				$msg1   = str_replace("#lastName#",    $user_info['lastname'],$msg);
-				$msg    = str_replace("#mail#",        $user_info['email'],$msg1);
-				$msg1   = str_replace("#questionName#",$arrques[$i],$msg);
-				$msg    = str_replace("#answer#",      $arrans[$i],$msg1);
-				$msg1   = str_replace("#i#",           $i,$msg);
-				$msg    = str_replace("#course#",      $course_info['name'],$msg1);
-			}
-
-			$msg.='</table><br />';
-			if ($origin != 'learnpath') {
-				$msg.= '<span class="style16">'.get_lang('ClickToCommentAndGiveFeedback').',<br />
-                	            <a href="#url#">#url#</a></span>';
+                            <td>'.get_lang('TestAttempted').'</span></td>
+                            <td>#exercise#</td>
+                        </tr>
+                        <tr>
+                            <td>'.get_lang('StudentName').'</td>
+                            <td>#firstName# #lastName#</td>
+                        </tr>
+                        <tr>
+                            <td>'.get_lang('StudentEmail').'</td>
+                            <td>#mail#</td>
+                        </tr>
+                    </table>';
+            $open_question_list = null;
+			foreach ($question_list_answers as $item) {
+                $question   = $item['question'];
+                $answer     = $item['answer'];
+                
+                if (!empty($question) && !empty($answer)) {                
+                    $open_question_list.='<tr>
+                            <td width="220" valign="top" bgcolor="#E5EDF8">&nbsp;&nbsp;'.get_lang('Question').'</td>
+                            <td width="473" valign="top" bgcolor="#F3F3F3">'.$question.'</td>
+                        </tr>
+                        <tr>
+                            <td width="220" valign="top" bgcolor="#E5EDF8">&nbsp;&nbsp;'.get_lang('Answer').'</td>
+                            <td valign="top" bgcolor="#F3F3F3">'.$answer.'</td>
+                        </tr>';				
+                }
 			}
-			$msg.= '</body></html>';
-
-			$msg1 = str_replace("#url#", $url_email, $msg);
-			$mail_content = $msg1;
-
-			$subject = get_lang('OpenQuestionsAttempted');
+            
+            
+            if (!empty($open_question_list)) {
+                $msg .=  '<p><br />'.get_lang('OpenQuestionsAttemptedAre').' :</p>                        
+                    <table width="730" height="136" border="0" cellpadding="3" cellspacing="3">';
+                $msg .= $open_question_list;
+                $msg.='</table><br />';
+            
+            
+                $msg1   = str_replace("#exercise#",    $this->exercise, $msg);
+                $msg    = str_replace("#firstName#",   $user_info['firstname'],$msg1);
+                $msg1   = str_replace("#lastName#",    $user_info['lastname'],$msg);
+                $msg    = str_replace("#mail#",        $user_info['email'],$msg1);            			
+                $msg    = str_replace("#course#",      $course_info['name'],$msg1);
+
+                if ($origin != 'learnpath') {
+                    $msg.= get_lang('ClickToCommentAndGiveFeedback').', <br />
+                            <a href="#url#">#url#</a>';
+                }			
+                $msg1 = str_replace("#url#", $url_email, $msg);
+                $mail_content = $msg1;
+                $subject = get_lang('OpenQuestionsAttempted');
+
+                $teachers = array();
+                if (api_get_session_id()) {
+                    $teachers = CourseManager::get_coach_list_from_course_code($coursecode, api_get_session_id());
+                } else {
+                    $teachers = CourseManager::get_teacher_list_from_course_code($coursecode);
+                }
 
-			$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');
-			$result = @api_mail_html('', $to, $subject, $mail_content, $sender_name, $email_admin, array('charset'=>$mycharset));
-		} else {
-			$msg .= '<body>
-            <p>'.get_lang('ExerciseAttempted').'</p>
-            <table width="730" height="136" border="0" cellpadding="3" cellspacing="3">
-                <tr>
-                <td width="229" valign="top"><h2>'.get_lang('CourseName').'</h2></td>
-                <td width="469" valign="top"><h2>#course#</h2></td>
-              </tr>
-              <tr>
-                <td width="229" valign="top" class="outerframe">&nbsp;&nbsp;'.get_lang('TestAttempted').'</span></td>
-                <td width="469" valign="top" class="outerframe">#exercise#</td>
-              </tr>
-              <tr>
-                <td valign="top">&nbsp;&nbsp;<span class="style10">'.get_lang('StudentName').'</span></td>
-                '.(api_is_western_name_order() ? '<td valign="top" >#firstName# #lastName#</td>' : '<td valign="top" >#lastName# #firstName#</td>').'
-              </tr>
-              <tr>
-                <td valign="top" >&nbsp;&nbsp;'.get_lang('StudentEmail').' </td>
-                <td valign="top"> #mail#</td>
-            </tr></table>';
-
-			$msg= str_replace("#exercise#",  $this->exercise,$msg);
-			$msg= str_replace("#firstName#", $user_info['firstname'],    $msg);
-			$msg= str_replace("#lastName#",  $user_info['lastname'],     $msg);
-			$msg= str_replace("#mail#",      $user_info['email'],        $msg);
-			$msg= str_replace("#course#",    $course_info['name'],                $msg);
-
-			if ($origin != 'learnpath') {
-
-				$msg.='<br />
-                        <span class="style16">'.get_lang('ClickToCommentAndGiveFeedback').',<br />
-                        <a href="#url#">#url#</a></span>';                
-			}
-			$msg .= '</body></html>';
-
-			$msg = str_replace("#url#", $url_email, $msg);
-			$mail_content = $msg;
-			$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');
-			$subject = get_lang('ExerciseAttempted');
-			$result = @api_mail_html('', $to, $subject, $mail_content, $sender_name, $email_admin, array('charset'=>$mycharset));
-		}		
+                foreach ($teachers as $user_id => $teacher_data) {
+                    MessageManager::send_message_simple($user_id, $subject, $mail_content);    
+                }
+            }
 	}
 
 	function show_exercise_result_header($user_data, $date = null) {
@@ -3659,7 +3613,9 @@ class Exercise {
     }
     
     function return_time_left_div() {       
-        return '<div id="exercise_clock_warning" class="well count_down"></div>';
+        $html  = '<div id="clock_warning" style="display:none">'.Display::return_message(get_lang('ReachedTimeLimit'), 'warning').' '.sprintf(get_lang('YouWillBeRedirectedInXSeconds'), '<span id="counter_to_redirect" class="red_alert"></span>').'</div>';
+        $html .= '<div id="exercise_clock_warning" class="well count_down"></div>';
+        return $html;
     }
 }
 endif;

+ 10 - 10
main/exercice/exercise.lib.php

@@ -1934,8 +1934,6 @@ function delete_chat_exercise_session($exe_id) {
     }    
 }
 
-
-
 function display_question_list_by_attempt($objExercise, $exe_id, $save_user_result = false) {
     global $origin;
     
@@ -1948,8 +1946,7 @@ function display_question_list_by_attempt($objExercise, $exe_id, $save_user_resu
     $counter = 1;
     $total_score = $total_weight = 0;
     
-    $exercise_content = null;
-    
+    $exercise_content = null;    
     
     //Hide results
     $show_results     = false;
@@ -1981,7 +1978,8 @@ function display_question_list_by_attempt($objExercise, $exe_id, $save_user_resu
             echo "<div class='clear'>&nbsp;</div>";
         }
     }
-
+    
+    $question_list_answers = array();
 
     // Loop over all question to show results for each of them, one by one
     if (!empty($question_list)) {
@@ -2002,6 +2000,7 @@ function display_question_list_by_attempt($objExercise, $exe_id, $save_user_resu
             $total_score     += $result['score'];
             $total_weight    += $result['weight'];
             
+            $question_list_answers[]   = array('question' => $result['open_question'], 'answer' => $result['open_answer']);            
             
             $my_total_score  = $result['score'];
             $my_total_weight = $result['weight'];   
@@ -2068,19 +2067,20 @@ function display_question_list_by_attempt($objExercise, $exe_id, $save_user_resu
     
     echo $total_score_text;
     
-    
-    
     if ($save_user_result) {
         
         // Tracking of results
         $learnpath_id           = $exercise_stat_info['orig_lp_id'];
         $learnpath_item_id      = $exercise_stat_info['orig_lp_item_id'];
         $learnpath_item_view_id = $exercise_stat_info['orig_lp_item_view_id'];
+        
         if (api_is_allowed_to_session_edit()) {    
             update_event_exercice($exercise_stat_info['exe_id'], $objExercise->selectId(), $total_score, $total_weight, api_get_session_id(), $learnpath_id, $learnpath_item_id, $learnpath_item_view_id, $exercise_stat_info['exe_duration'], $question_list, '', array(), $end_date);
         }
+        
+        // Send notification ..
+        if (!api_is_allowed_to_edit(null,true)) {
+            $objExercise->send_notification_for_open_questions($question_list_answers, $origin, $exe_id);
+        }
     }
-    
-    
-    
 }

+ 3 - 6
main/exercice/exercise_reminder.php

@@ -112,14 +112,14 @@ if ($time_control) {
 
 echo Display::div('', array('id'=>'message'));
 
-echo '<script>
-		
+echo '<script>		
 		lp_data = $.param({"learnpath_id": '.$learnpath_id.', "learnpath_item_id" : '.$learnpath_item_id.', "learnpath_item_view_id": '.$learnpath_item_view_id.'});    		
       
         function final_submit() {
         	//Normal inputs   
         	window.location = "exercise_result.php?origin='.$origin.'&exe_id='.$exe_id.'&" + lp_data;
-		}		
+		}
+        
 		function review_questions() {
 			var is_checked = 1;
 			$("input[type=checkbox]").each(function () {
@@ -207,7 +207,6 @@ foreach ($question_list as $questionId) {
 	$label_attributes['for'] = $check_id;	
     $label_attributes['class'] = "checkbox";
 	
-	
 	$checkbox          = Display::input('checkbox', 'remind_list['.$questionId.']', '', $attributes);
 	$url               = 'exercise_submit.php?exerciseId='.$objExercise->id.'&num='.$counter.'&reminder=1';
 	
@@ -232,10 +231,8 @@ $exercise_actions = Display::url(get_lang('EndTest'), 'javascript://', array('on
 $exercise_actions .=  '&nbsp;'.Display::url(get_lang('ReviewQuestions'), 'javascript://', array('onclick'=>'review_questions();','class'=>'btn'));
 
 echo Display::div('', array('class'=>'clear'));
-
 echo Display::div($exercise_actions, array('class'=>'form-actions'));
 
-
 if ($origin != 'learnpath') {
 	//we are not in learnpath tool
 	Display::display_footer();

+ 15 - 13
main/exercice/exercise_result.php

@@ -135,7 +135,6 @@ Display :: display_normal_message(get_lang('Saved').'<br />',false);
 
 display_question_list_by_attempt($objExercise, $exe_id, true);
 
-
 //If is not valid
 $session_control_key = get_session_time_control_key($objExercise->id, $learnpath_id, $learnpath_item_id);
 if (isset($session_control_key) && !exercise_time_control_is_valid($objExercise->id, $learnpath_id, $learnpath_item_id)) {
@@ -152,23 +151,26 @@ delete_chat_exercise_session($exe_id);
 if ($origin != 'learnpath') {
     echo '<hr>';
     echo Display::url(get_lang('ReturnToCourseHomepage'), api_get_course_url(), array('class' => 'btn btn-large'));
+    
+    if (api_is_allowed_to_session_edit()) {
+        Session::erase('objExercise');
+        Session::erase('exe_id');
+    }
+
 	Display::display_footer();
 } else {
 	$lp_mode =  $_SESSION['lp_mode'];
 	$url = '../newscorm/lp_controller.php?cidReq='.api_get_course_id().'&action=view&lp_id='.$learnpath_id.'&lp_item_id='.$learnpath_item_id.'&exeId='.$exercise_stat_info['exe_id'].'&fb_type='.$objExercise->feedback_type;
 	//echo $total_score.','.$total_weight;	exit;
-	$href = ($lp_mode == 'fullscreen')?' window.opener.location.href="'.$url.'" ':' top.location.href="'.$url.'" ';
-	echo '<script type="text/javascript">'.$href.'</script>'."\n";
+	$href = ($lp_mode == 'fullscreen')?' window.opener.location.href="'.$url.'" ':' top.location.href="'.$url.'"';
+    
+    if (api_is_allowed_to_session_edit()) {
+        Session::erase('objExercise');
+        Session::erase('exe_id');
+    }
+
+	echo '<script type="text/javascript">'.$href.'</script>';
 	//record the results in the learning path, using the SCORM interface (API)
-	echo '<script type="text/javascript">window.parent.API.void_save_asset('.$total_score.','.$total_weight.');</script>'."\n";
+	echo '<script type="text/javascript">window.parent.API.void_save_asset('.$total_score.','.$total_weight.');</script>';
 	echo '</body></html>';
-}
-
-// Send notification..
-if (!api_is_allowed_to_edit(null,true)) {
-    $objExercise->send_notification($arrques, $arrans, $origin);
-}
-if (api_is_allowed_to_session_edit()) {
-	Session::erase('objExercise');
-	Session::erase('exe_id');
 }

+ 1 - 3
main/exercice/exercise_submit.php

@@ -922,9 +922,7 @@ if (!empty($error)) {
                 return false;
             }
 		</script>';
-    
-    echo '<div id="clock_warning" style="display:none">'.Display::return_message(get_lang('ReachedTimeLimit'), 'warning').' '.sprintf(get_lang('YouWillBeRedirectedInXSeconds'), '<span id="counter_to_redirect" class="red_alert"></span>').'</div>';    
-    
+  
     echo '<form id="exercise_form" method="post" action="'.api_get_self().'?'.api_get_cidreq().'&autocomplete=off&gradebook='.$gradebook."&exerciseId=" . $exerciseId .'" name="frm_exercise" '.$onsubmit.'>
          <input type="hidden" name="formSent"				value="1" />
          <input type="hidden" name="exerciseId" 			value="'.$exerciseId . '" />

+ 1 - 1
main/exercice/global_multiple_answer.class.php

@@ -110,7 +110,7 @@ if (!class_exists('GlobalMultipleAnswer')):
                 $answer_number = $form->addElement('text', 'counter[' . $i . ']', null, 'value="' . $i . '"');
                 $answer_number->freeze();
 
-                $form->addElement('checkbox', 'correct[' . $i . ']', null, null, 'class="checkbox" style="margin-left: 2em;"');
+                $form->addElement('checkbox', 'correct[' . $i . ']', null, null, 'class="checkbox"');
                 $boxes_names[] = 'correct[' . $i . ']';
 
                 $form->addElement('html_editor', 'answer[' . $i . ']', null, 'style="vertical-align:middle"', array('ToolbarSet' => 'TestProposedAnswer', 'Width' => '100%', 'Height' => '100'));

+ 2 - 2
main/exercice/multiple_answer_combination_true_false.class.php

@@ -1,5 +1,5 @@
-<?php // $Id: document.php 16494 2008-10-10 22:07:36Z yannoo $
-/* For licensing terms, see /chamilo_license.txt */
+<?php
+/* For licensing terms, see /license.txt */
 /**
 *	File containing the MultipleAnswer class.
 *	@package chamilo.exercise

+ 47 - 33
main/exercice/multiple_answer_true_false.class.php

@@ -40,33 +40,16 @@ class MultipleAnswerTrueFalse extends Question {
 
 		$nb_answers  = isset($_POST['nb_answers']) ? $_POST['nb_answers'] : 4;  // The previous default value was 2. See task #1759.
 		$nb_answers += (isset($_POST['lessAnswers']) ? -1 : (isset($_POST['moreAnswers']) ? 1 : 0));
+        
+        $course_id = api_get_course_int_id();
 
 		$obj_ex = $_SESSION['objExercise'];
                 
-        $form -> addElement ('html', '<table><tr>');  
         $renderer = & $form->defaultRenderer();
+               
         $defaults = array();
-        //Extra values True, false,  Dont known
-        if (!empty($this->extra)) {
-            $scores = explode(':',$this->extra);
-        
-            if (!empty($scores)) {
-                for ($i = 1; $i <=3; $i++) {
-                    $defaults['option['.$i.']']	= $scores[$i-1];                
-                }        
-            }        
-        }
-        
-        // 3 scores
-        $form->addElement('text', 'option[1]',get_lang('Correct'),   array('size'=>'5','value'=>'1'));
-        $form->addElement('text', 'option[2]',get_lang('Wrong'),     array('size'=>'5','value'=>'-0.5'));        
-        $form->addElement('text', 'option[3]',get_lang('DoubtScore'),array('size'=>'5','value'=>'0'));  
-                
-        $form -> addElement('hidden', 'options_count', 3);
-                    
-        $form -> addElement ('html', '</tr></table>');
                
-		$html.='<table class="data_table">
+		$html = '<table class="data_table">
 					<tr style="text-align: center;">
 						<th>
 							'.get_lang('Number').'
@@ -80,15 +63,15 @@ class MultipleAnswerTrueFalse extends Question {
 						<th>
 							'.get_lang('Answer').'
 						</th>';
-        				// show column comment when feedback is enable
-        				if ($obj_ex->selectFeedbackType() != EXERCISE_FEEDBACK_TYPE_EXAM ) {
-        				    $html .='<th>'.get_lang('Comment').'</th>';
-        				}
-				$html .= '</tr>';
+        // show column comment when feedback is enable
+        if ($obj_ex->selectFeedbackType() != EXERCISE_FEEDBACK_TYPE_EXAM ) {
+            $html .='<th>'.get_lang('Comment').'</th>';
+        }
+        $html .= '</tr>';
         $form -> addElement ('label', get_lang('Answers').'<br /> <img src="../img/fill_field.png">', $html);
 		
 		$correct = 0;
-		if (!empty($this -> id))	{
+		if (!empty($this -> id)) {
 			$answer = new Answer($this -> id);
 			$answer->read();			
 			if (count($answer->nbrAnswers) > 0 && !$form->isSubmitted()) {
@@ -104,8 +87,6 @@ class MultipleAnswerTrueFalse extends Question {
 			Display::display_normal_message(get_lang('YouHaveToCreateAtLeastOneAnswer'));
 		}
 		
-        $course_id = api_get_course_int_id();
-        
         // Can be more options        
         $option_data = Question::readQuestionOption($this->id, $course_id);
           
@@ -161,11 +142,45 @@ class MultipleAnswerTrueFalse extends Question {
 			}
 			$form->addElement ('html', '</tr>');
 		}
-		$form -> addElement ('html', '</table>');
-		$form -> addElement ('html', '<br />');
+        
+		$form->addElement('html', '</table>');
+		$form->addElement('html', '<br />');  
+        
+        $form->addElement('html', '<table><tr><td></td><td>'.get_lang('Correct').'</td><td>'.get_lang('Wrong').'</td><td>'.get_lang('DoubtScore').'</td></tr>');
+               
+        $renderer->setElementTemplate('<tr><td><span class="form_required">*</span>'.get_lang('Score').'&nbsp;&nbsp;&nbsp;&nbsp;</td><td>{element} &nbsp;&nbsp; <br /><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --></td>', 'option[1]');
+        $renderer->setElementTemplate('<td>{element} &nbsp;&nbsp;<br /><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --></td>', 'option[2]');
+        $renderer->setElementTemplate('<td>{element} &nbsp;&nbsp;<br /><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --></td>', 'option[3]');
 
-		//$form -> add_multiple_required_rule ($boxes_names , get_lang('ChooseAtLeastOneCheckbox') , 'multiple_required');
+        // 3 scores
+        $form->addElement('text', 'option[1]', get_lang('Correct'),   array('class'=>'span1','value'=>'1'));
+        $form->addElement('text', 'option[2]', get_lang('Wrong'),     array('class'=>'span1','value'=>'-0.5'));        
+        $form->addElement('text', 'option[3]', get_lang('DoubtScore'),array('class'=>'span1','value'=>'0'));
+        
+        $form->addRule('option[1]', get_lang('ThisFieldIsRequired'), 'required');
+        $form->addRule('option[2]', get_lang('ThisFieldIsRequired'), 'required');
+        $form->addRule('option[3]', get_lang('ThisFieldIsRequired'), 'required');
+                
+        
+        $form -> addElement ('html', '</tr><table>');
+        
+
+        $form -> addElement('hidden', 'options_count', 3);
+                    
+        $form -> addElement ('html', '</table><br /><br />');
+        
+        
+        //Extra values True, false,  Dont known
+        if (!empty($this->extra)) {
+            $scores = explode(':',$this->extra);        
+            if (!empty($scores)) {
+                for ($i = 1; $i <=3; $i++) {
+                    $defaults['option['.$i.']']	= $scores[$i-1];                
+                }        
+            }        
+        }        
 
+		//$form -> add_multiple_required_rule ($boxes_names , get_lang('ChooseAtLeastOneCheckbox') , 'multiple_required');
 
 		$navigator_info = api_get_navigator();
 
@@ -198,7 +213,6 @@ class MultipleAnswerTrueFalse extends Question {
 				$form -> setDefaults($defaults);
 			//}
 		}
-
 		$form->setConstants(array('nb_answers' => $nb_answers));
 	}
 

+ 3 - 4
main/exercice/question_list_admin.inc.php

@@ -196,19 +196,18 @@ if (!$inATest) {
                 $move = Display::return_icon('all_directions.png',get_lang('Move'), array('class'=>'moved', 'style'=>'margin-bottom:-0.5em;'));
 
                 // Question name
-
-				$questionName = Display::tag('div', '<a href="#" title = "'.$title.'">'.$move.' '.cut($title, 60).'</a>', array('style'=>$styleQuestion));
+				$questionName = Display::tag('div', '<a href="#" title = "'.$title.'">'.$move.' '.cut($title, 42).'</a>', array('style'=>$styleQuestion));
 
 				// Question type
 				list($typeImg, $typeExpl) = $objQuestionTmp->get_type_icon_html();
-				$questionType = Display::tag('div', Display::return_icon($typeImg, $typeExpl, array(), 32), array('style'=>$styleType));
+				$questionType = Display::tag('div', Display::return_icon($typeImg, $typeExpl, array(), ICON_SIZE_MEDIUM), array('style'=>$styleType));
 
 				// Question category
 				$txtQuestionCat = Security::remove_XSS(Testcategory::getCategoryNameForQuestion($objQuestionTmp->id));
 				if (empty($txtQuestionCat)) {
 					$txtQuestionCat = "-";
 				}
-				$questionCategory = Display::tag('div', '<a href="#" style="padding:0px; margin:0px;" title="'.$txtQuestionCat.'">'.cut($txtQuestionCat, 55).'</a>', array('style'=>$styleCat));
+				$questionCategory = Display::tag('div', '<a href="#" style="padding:0px; margin:0px;" title="'.$txtQuestionCat.'">'.cut($txtQuestionCat, 42).'</a>', array('style'=>$styleCat));
 
 				// Question level
 				$txtQuestionLevel = $objQuestionTmp->level;

+ 5 - 4
main/gradebook/lib/fe/gradebooktable.class.php

@@ -176,7 +176,8 @@ class GradebookTable extends SortableTable {
 			if (api_is_allowed_to_edit(null, true)) {
                 //id
 				$row[] = $this->build_id_column($item);
-			}		
+			}
+            
             //Type
 			$row[] = $this->build_type_column($item);
 			
@@ -230,7 +231,7 @@ class GradebookTable extends SortableTable {
 			} else {
 				//students get the results and certificates columns                
 				if (count($this->evals_links) > 0 && $status_user != 1) {                    
-					$value_data = isset($data[4]) ? $data[4] : null;
+					$value_data = isset($data[4]) ? $data[4] : null;                    
 					if (!is_null($value_data)) {                        
 						$row[] = Display::tag('h4', $value_data);
 					} else {                        
@@ -315,7 +316,7 @@ class GradebookTable extends SortableTable {
                     
                     $row[] = $invisibility_span_open.$weight.$extra.$invisibility_span_close;
 					
-					if (api_is_allowed_to_edit(null, true)) {						
+					if (api_is_allowed_to_edit(null, true)) {					
 						//$weight_total_links += intval($data[3]);
 					} else {
 						$cattotal   = Category :: load($_GET['selectcat']);
@@ -577,7 +578,7 @@ class GradebookTable extends SortableTable {
 		}
 	}
 	
-	private function build_edit_column($item) {
+	private function build_edit_column($item) {        
 		switch ($item->get_item_type()) {
 			// category
 			case 'C' :

+ 13 - 6
main/gradebook/lib/gradebook_functions.inc.php

@@ -292,15 +292,22 @@ function build_edit_icons_link($link, $selectcat) {
 	$cat = new Category();
 	$message_link = $cat->show_message_resource_delete($link->get_course_code());    
     $is_locked = $link->is_locked();
-        
-	if ($message_link===false) {
-		$visibility_icon= ($link->is_visible() == 0) ? 'invisible' : 'visible';
-		$visibility_command= ($link->is_visible() == 0) ? 'set_visible' : 'set_invisible';
+    
+    $modify_icons = null;
+            
+    if (!api_is_allowed_to_edit(null, true)) {
+        return null;
+    }
+    
+	if ($message_link === false) {
+		$visibility_icon    = ($link->is_visible() == 0) ? 'invisible' : 'visible';
+		$visibility_command = ($link->is_visible() == 0) ? 'set_visible' : 'set_invisible';
         
         if ($is_locked && !api_is_platform_admin()) {
             $modify_icons = Display::return_icon('edit_na.png', get_lang('Modify'),'',ICON_SIZE_SMALL);
-        } else {
-            $modify_icons = '<a href="gradebook_edit_link.php?editlink='.$link->get_id().'&amp;cidReq='.$link->get_course_code().'">'.Display::return_icon('edit.png', get_lang('Modify'),'',ICON_SIZE_SMALL).'</a>';
+        } else {            
+            $modify_icons = '<a href="gradebook_edit_link.php?editlink='.$link->get_id().'&amp;cidReq='.$link->get_course_code().'">'.
+                                 Display::return_icon('edit.png', get_lang('Modify'),'',ICON_SIZE_SMALL).'</a>';            
         }
 
 		//$modify_icons .= '&nbsp;<a href="' . api_get_self() . '?movelink=' . $link->get_id() . '&selectcat=' . $selectcat . '"><img src="../img/deplacer_fichier.gif" border="0" title="' . get_lang('Move') . '" alt="" /></a>';

+ 9 - 9
main/inc/lib/course.lib.php

@@ -86,7 +86,7 @@ class CourseManager {
      * @param   array   with the columns in the main.course table
      * @param   mixed   false if the course was not created, array with the course info
      */
-    function create_course($params) {
+    static function create_course($params) {
         global $_configuration;
         // Check portal limits
         $access_url_id = 1;
@@ -1112,19 +1112,19 @@ class CourseManager {
      *    Return user info array of all users registered in the specified real or virtual course
      *    This only returns the users that are registered in this actual course, not linked courses.
      *
-     * @param string $course_code the code of the course
-     * @param boolean $with_session determines if the course is used in a session or not
-     * @param integer $session_id the id of the session
-     * @param string $limit the LIMIT statement of the sql statement
-     * @param string $order_by the field to order the users by. Valid values are 'lastname', 'firstname', 'username', 'email', 'official_code' OR a part of a SQL statement that starts with ORDER BY ...
-     * @param int   0 or 2 (student, coach) if using the session id, STUDENT or COURSEMANAGER if using session_id = 0
+     * @param string    $course_code the code of the course
+     * @param boolean   $with_session determines if the course is used in a session or not
+     * @param integer   $session_id the id of the session
+     * @param string    $limit the LIMIT statement of the sql statement
+     * @param string    $order_by the field to order the users by. Valid values are 'lastname', 'firstname', 'username', 'email', 'official_code' OR a part of a SQL statement that starts with ORDER BY ...
+     * @param int       if using the session_id: 0 or 2 (student, coach), if using session_id = 0 STUDENT or COURSEMANAGER 
      * @return array
      */
     public static function get_user_list_from_course_code($course_code, $session_id = 0, $limit = '', $order_by = '', $filter_by_status = null) {
         // variable initialisation
         $session_id     = intval($session_id);
-        $course_code     = Database::escape_string($course_code);
-        $where             = array();
+        $course_code    = Database::escape_string($course_code);
+        $where          = array();
 
         // if the $order_by does not contain 'ORDER BY' we have to check if it is a valid field that can be sorted on
         if (!strstr($order_by,'ORDER BY')) {

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

@@ -18,8 +18,7 @@ class DocumentManager {
     }
 
     /**
-     * @return the document folder quota for the current course, in bytes, or the default quota
-     * @todo eliminate globals
+     * @return the document folder quota for the current course, in bytes, or the default quota     
      */
     public static function get_course_quota() {
         $course_info = api_get_course_info();
@@ -2432,8 +2431,7 @@ class DocumentManager {
         $course_quota_m = round($course_quota / 1000000);
         $already_consumed_space_m = round($already_consumed_space / 1000000, 2);
         $percentage = $already_consumed_space / $course_quota * 100;
-        $percentage = round($percentage, 1);
-        //$message = "You are currently using %s (%s) of your %s.";
+        $percentage = round($percentage, 1);        
         $message = get_lang('YouAreCurrentlyUsingXOfYourX');
         $message = sprintf($message, $already_consumed_space_m, $percentage.'%',$course_quota_m.' ');
         echo Display::div($message, array('id'=>'document_quota'));

+ 1 - 0
main/inc/lib/fckeditor/editor/css/fck_internal.css

@@ -33,6 +33,7 @@
 html
 {
     min-height: 100%;
+    font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
 }
 
 table.FCK__ShowTableBorders, table.FCK__ShowTableBorders td, table.FCK__ShowTableBorders th

+ 2 - 2
main/inc/lib/fckeditor/editor/fckeditor.html

@@ -175,7 +175,7 @@ if ( FCKConfig.Debug )
 // CSS minified by http://iceyboard.no-ip.org/projects/css_compressor (see _dev/css_compression.txt).
 // FCK_MP3 and FCK__Video classes added by Julio Montoya.
 var FCK_InternalCSS = FCKTools.FixCssUrls( FCKConfig.BasePath + 'css/',
-'html{min-height:100%}' +
+'html{min-height:100%; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;}' +
 'table.FCK__ShowTableBorders,table.FCK__ShowTableBorders td,table.FCK__ShowTableBorders th{border:#d3d3d3 1px solid}' +
 'form{border:1px dotted #F00;padding:2px}' +
 '.FCK__Flash{border:#a9a9a9 1px solid;background-position:center center;background-image:url(images/fck_flashlogo.gif);background-repeat:no-repeat;width:80px;height:80px}' +
@@ -293,7 +293,7 @@ function WaitForActive( editorInstance, newStatus )
 
 // Gecko and Webkit browsers don't calculate well the IFRAME size so we must
 // recalculate it every time the window size changes.
-if ( FCKBrowserInfo.IsGecko || ( FCKBrowserInfo.IsSafari && !FCKBrowserInfo.IsSafari3 ) )
+if ( FCKBrowserInfo.IsGecko || ( FCKBrowserInfo.IsSafari && !FCKBrowserInfo.IsSafari3 ) )
 {
     window.onresize = function( e )
     {

+ 2 - 3
main/inc/lib/formvalidator/Rule/Date.php

@@ -33,9 +33,8 @@ class HTML_QuickForm_Rule_Date extends HTML_QuickForm_Rule
 	 * @param array $date An array with keys F (month), d (day) and Y (year)
 	 * @return boolean True if date is valid
 	 */
-	function validate($date)
+	function validate($date, $options)
 	{
 		return checkdate($date['F'], $date['d'], $date['Y']);
 	}
-}
-?>
+}

+ 1 - 4
main/inc/lib/formvalidator/Rule/Username.php

@@ -34,10 +34,7 @@ class HTML_QuickForm_Rule_Username extends HTML_QuickForm_Rule {
 	 * @return boolean True if username is of the correct format
 	 * @author Modified by Ivan Tcholakov, 15-SEP-2009. The validation rule is served by the UserManager class as of this moment.
 	 */
-	function validate($username) {
-		if (!class_exists('UserManager')) {
-			require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
-		}
+	function validate($username, $options) {		
 		return UserManager::is_username_valid($username);
 	}
 }

+ 7 - 7
main/inc/lib/formvalidator/Rule/UsernameAvailable.php

@@ -21,7 +21,7 @@
 	Mail: info@dokeos.com
 ==============================================================================
 */
-require_once ('HTML/QuickForm/Rule.php');
+require_once 'HTML/QuickForm/Rule.php';
 /**
  * QuickForm rule to check if a username is available
  */
@@ -34,17 +34,17 @@ class HTML_QuickForm_Rule_UsernameAvailable extends HTML_QuickForm_Rule
 	 * @param string $current_username
 	 * @return boolean True if username is available
 	 */
-	function validate($username,$current_username = null)
-	{
+	function validate($username, $current_username = null) {
 		$user_table = Database::get_main_table(TABLE_MAIN_USER);
+        $username = Database::escape_string($username);        
+        $current_username = Database::escape_string($current_username);
+        
 		$sql = "SELECT * FROM $user_table WHERE username = '$username'";
-		if(!is_null($current_username))
-		{
+		if (!is_null($current_username)) {
 			$sql .= " AND username != '$current_username'";
 		}
 		$res = Database::query($sql);
 		$number = Database::num_rows($res);
 		return $number == 0;
 	}
-}
-?>
+}

+ 14 - 4
main/inc/lib/groupmanager.lib.php

@@ -64,6 +64,17 @@ class GroupManager {
 	//GROUP FUNCTIONS
 	private function __construct() {		
 	}
+    
+    public static function get_groups() {
+        $table_group 		= Database :: get_course_table(TABLE_GROUP);
+        $course_id          = api_get_course_int_id();
+        
+        $sql = "SELECT * FROM $table_group WHERE c_id = $course_id ";
+        $result = Database::query($sql);
+        return Database::store_result($result, 'ASSOC');
+            
+    }
+    
 	/**
 	 * Get list of groups for current course.
 	 * @param int $category The id of the category from which the groups are
@@ -72,8 +83,7 @@ class GroupManager {
 	 * @return array An array with all information about the groups.
 	 */
 	public static function get_group_list ($category = null, $course_code = null) {		
-		$my_user_id = api_get_user_id();
-		$my_status_of_user_in_course = '';
+		$my_user_id = api_get_user_id();		
 		
 		/*
 		if ($course_code != null) {
@@ -1374,10 +1384,10 @@ class GroupManager {
 		}
 		if (!empty($groups)) {
 			 array_filter($groups);
-		}
-		
+		}		
 		return $groups;
 	}
+    
 	/*	
         Group functions - these take virtual/linked courses into account when necessary
 	*/

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

@@ -109,7 +109,7 @@ class Login
         $sender_name = api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'), null, PERSON_NAME_EMAIL_ADDRESS);
         $email_admin = api_get_setting('emailAdministrator');
 
-        if (@api_mail('', $email_to, $email_subject, $email_body, $sender_name, $email_admin) == 1) {
+        if (api_mail_html('', $email_to, $email_subject, $email_body, $sender_name, $email_admin) == 1) {
             return get_lang('your_password_has_been_reset');
         } else {
             $admin_email = Display :: encrypted_mailto_link(api_get_setting('emailAdministrator'), api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname')));            

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

@@ -1331,7 +1331,9 @@ function api_format_course_array($course_data) {
     $_course['department_url']        = $course_data['department_url' ];
     
     $_course['disk_quota']            = $course_data['disk_quota'];
-
+    
+    $_course['course_public_url']     = api_get_path(WEB_COURSE_PATH).$course_data['directory'].'/index.php';
+    
     if (file_exists(api_get_path(SYS_COURSE_PATH).$course_data['directory'].'/course-pic85x85.png')) {
         $url_image = api_get_path(WEB_COURSE_PATH).$course_data['directory'].'/course-pic85x85.png';
     } else {
@@ -5776,6 +5778,10 @@ function api_get_multiple_access_url() {
     return false;
 }
 
+function api_is_multiple_url_enabled() {
+    return api_get_multiple_access_url();
+}
+
 /**
  * Returns a md5 unique id
  * @todo add more parameters
@@ -6007,3 +6013,13 @@ function api_check_user_access_to_legal($course_visibility) {
     $course_visibility_list = array(COURSE_VISIBILITY_OPEN_WORLD, COURSE_VISIBILITY_OPEN_PLATFORM);    
     return in_array($course_visibility, $course_visibility_list) || api_is_drh();
 }
+
+/**
+ * Checks if the global chat is enabled or not
+ * 
+ * @return bool
+ */
+function api_is_global_chat_enabled(){
+    $global_chat_is_enabled = !api_is_anonymous() && api_get_setting('allow_global_chat') == 'true' && api_get_setting('allow_social_tool') == 'true';
+    return $global_chat_is_enabled;
+}

+ 7 - 0
main/inc/lib/message.lib.php

@@ -318,6 +318,13 @@ class MessageManager
         return false;
 	}
 
+    /**
+     * A handy way to send message
+     */
+    public static function send_message_simple($receiver_user_id, $subject, $message, $sender_id = null) {
+        return MessageManager::send_message($receiver_user_id, $subject, $message, null, null, null, null, null, null, $sender_id);
+    }
+    
 	/**
 	 * Update parent ids for other receiver user from current message in groups
 	 * @author Christian Fasanando Flores

+ 18 - 3
main/inc/lib/notification.lib.php

@@ -52,8 +52,15 @@ class Notification extends Model {
     
 	public function __construct() {
         $this->table       = Database::get_main_table(TABLE_NOTIFICATION);
-        $this->admin_name  = api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'), null, PERSON_NAME_EMAIL_ADDRESS); //api_get_setting('siteName')        
-        $this->admin_email = api_get_setting('emailAdministrator');                            
+           
+        $this->admin_email  = api_get_setting('noreply_email_address');
+        $this->admin_name   = api_get_setting('siteName');
+        
+        // If no-reply  email doesn't exist use the admin email
+        if (empty($this->admin_email)) {            
+            $this->admin_email = api_get_setting('emailAdministrator');
+            $this->admin_name  = api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'), null, PERSON_NAME_EMAIL_ADDRESS);            
+        }
 	}  
 	  
     /**
@@ -62,11 +69,19 @@ class Notification extends Model {
      */	
     public function send($frec = NOTIFY_MESSAGE_DAILY) {
         $notifications = $this->find('all',array('where'=>array('sent_at IS NULL AND send_freq = ?'=>$frec)));
+     
+        
         if (!empty($notifications)) {
             foreach ($notifications as $item_to_send) {
                 
                 //Sending email
-                api_mail_html($item_to_send['dest_mail'], $item_to_send['dest_mail'], Security::filter_terms($item_to_send['title']), Security::filter_terms($item_to_send['content']), $this->admin_name, $this->admin_email);                    
+                api_mail_html($item_to_send['dest_mail'], 
+                              $item_to_send['dest_mail'], 
+                              Security::filter_terms($item_to_send['title']), 
+                              Security::filter_terms($item_to_send['content']), 
+                              $this->admin_name, 
+                              $this->admin_email
+                            );
                 if ($this->debug) { error_log('Sending message to: '.$item_to_send['dest_mail']); }
                 
                 //Updating

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

@@ -62,7 +62,7 @@ function online_logout($user_id = null, $logout_redirect = false) {
     }
     
     //Changing global chat status to offline
-    if (api_get_setting('allow_global_chat') == 'true') {
+    if (api_is_global_chat_enabled()) {
         $chat = new Chat();
         $chat->set_user_status(0);
     }

+ 4 - 5
main/inc/lib/phpmailer/class.phpmailer.php

@@ -451,7 +451,7 @@ class PHPMailer {
    */
   private function AddAnAddress($kind, $address, $name = '') {
     if (!preg_match('/^(to|cc|bcc|ReplyTo)$/', $kind)) {
-      echo 'Invalid recipient array: ' . kind;
+      error_log('Invalid recipient array: ' . $kind);
       return false;
     }
     $address = trim($address);
@@ -461,7 +461,7 @@ class PHPMailer {
       if ($this->exceptions) {
         throw new phpmailerException($this->Lang('invalid_address').': '.$address);
       }
-      echo $this->Lang('invalid_address').': '.$address;
+      error_log($this->Lang('invalid_address').': '.$address);
       return false;
     }
     if ($kind != 'ReplyTo') {
@@ -493,7 +493,7 @@ class PHPMailer {
       if ($this->exceptions) {
         throw new phpmailerException($this->Lang('invalid_address').': '.$address);
       }
-      echo $this->Lang('invalid_address').': '.$address;
+      error_log($this->Lang('invalid_address').': '.$address);
       return false;
     }
     $this->From = $address;
@@ -583,7 +583,6 @@ class PHPMailer {
       if ($this->exceptions) {
         throw $e;
       }
-      //echo $e->getMessage()."\n";
       return false;
     }
   }
@@ -1367,7 +1366,7 @@ class PHPMailer {
       if ($this->exceptions) {
         throw $e;
       }
-      echo $e->getMessage()."\n";
+      error_log($e->getMessage()."\n");
       if ( $e->getCode() == self::STOP_CRITICAL ) {
         return false;
       }

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

@@ -664,7 +664,7 @@ class SocialManager extends UserManager {
             }
 
             //@todo check if user is online and if it's a friend to show the chat link
-            if (api_get_setting('allow_global_chat') == 'true' && $user_friend_relation == USER_RELATION_TYPE_FRIEND) {
+            if (api_is_global_chat_enabled() && $user_friend_relation == USER_RELATION_TYPE_FRIEND) {
                 if ($user_id != api_get_user_id()) {
                     //Only show chat if I'm available to talk
                     if ($current_user_info['user_is_online_in_chat'] == 1) {

+ 21 - 16
main/inc/lib/system_announcements.lib.php

@@ -141,17 +141,16 @@ class SystemAnnouncementManager {
 				$sql .= " AND visible_teacher = 1 ";
 				break;
 		}
+        
 	    if (count($groups) > 0 and $ann_group_db_ok ) {
-	      $sql .= " OR id IN (SELECT announcement_id FROM $tbl_announcement_group "
-	        ." WHERE group_id in $groups_string) ";
+            $sql .= " OR id IN (SELECT announcement_id FROM $tbl_announcement_group 
+                              WHERE group_id in $groups_string) ";
 	    }
-		
-		global $_configuration;
-		$current_access_url_id = 1;
-		if ($_configuration['multiple_access_urls']) {
+		        
+		if (api_is_multiple_url_enabled()) {
 			$current_access_url_id = api_get_current_access_url_id();
+            $sql .= " AND access_url_id IN ('1', '$current_access_url_id')";
 		}
-		$sql .= " AND access_url_id = '$current_access_url_id' ";		
 
 		if(!isset($_GET['start']) || $_GET['start'] == 0) {
 			$sql .= " ORDER BY date_start DESC LIMIT ".$start.",20";
@@ -538,15 +537,15 @@ class SystemAnnouncementManager {
 		$user_table = Database :: get_main_table(TABLE_MAIN_USER);
 		
 		if ($teacher <> 0 AND $student == 0) {
-			$sql = "SELECT firstname, lastname, email, status FROM $user_table u $url_condition WHERE status = '1' ";
+			$sql = "SELECT DISTINCT u.user_id FROM $user_table u $url_condition WHERE status = '1' ";
 		}
         
 		if ($teacher == 0 AND $student <> 0) {
-			$sql = "SELECT firstname, lastname, email, status FROM $user_table u $url_condition WHERE status = '5' ";
+			$sql = "SELECT DISTINCT u.user_id FROM $user_table u $url_condition WHERE status = '5' ";
 		}
         
 		if ($teacher<> 0 AND $student <> 0) {
-			$sql = "SELECT firstname, lastname, email FROM $user_table u $url_condition WHERE 1=1 ";
+			$sql = "SELECT DISTINCT u.user_id FROM $user_table u $url_condition WHERE 1 = 1 ";
 		}
         
 		if (!empty($language)) { //special condition because language was already treated for SQL insert before
@@ -571,13 +570,14 @@ class SystemAnnouncementManager {
         
         $title      = api_html_entity_decode(stripslashes($title), ENT_QUOTES, $charset);
         $content    = api_html_entity_decode(stripslashes(str_replace(array('\r\n', '\n', '\r'),'', $content)), ENT_QUOTES, $charset);
-        $admin_name = api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'), null, PERSON_NAME_EMAIL_ADDRESS);
-                
+        
+        $message_sent = false;
+        
 		while ($row = Database::fetch_array($result,'ASSOC')) {
-            $name = api_get_person_name($row['firstname'], $row['lastname'], null, PERSON_NAME_EMAIL_ADDRESS);            
-			$res =  @api_mail_html($name, $row['email'], $title, $content, $admin_name, api_get_setting('emailAdministrator'));            
+            MessageManager::send_message_simple($row['user_id'], $title, $content);
+            $message_sent = true;
 		}
-		return $res; //true if at least one e-mail was sent
+		return $message_sent; //true if at least one e-mail was sent
 	}
 	
 	
@@ -610,7 +610,12 @@ class SystemAnnouncementManager {
         
         if (isset($id) && !empty($id)) {
             $id = intval($id);
-            $sql .= " AND id = $id ";            
+            $sql .= " AND id = $id ";
+        }
+        
+        if (api_is_multiple_url_enabled()) {
+            $current_url_id = api_get_current_access_url_id();
+            $sql .= " AND access_url_id IN ('1', '$current_url_id') ";
         }
         
 		$sql .= " ORDER BY date_start DESC";            	    

+ 10 - 12
main/inc/lib/template.lib.php

@@ -459,14 +459,13 @@ class Template {
             'email_links.lib.js.php',
             'bootstrap/bootstrap.js',
         );
-
-        if (api_get_setting('allow_global_chat') == 'true') {
-            if (!api_is_anonymous()) {
-                //Do not include the global chat in LP
-                if ($this->show_learnpath == false && $this->show_footer == true && $this->hide_global_chat == false) {
-                    $js_files[] = 'chat/js/chat.js';
-                }
-            }
+        
+        
+        if (api_is_global_chat_enabled()) {            
+            //Do not include the global chat in LP
+            if ($this->show_learnpath == false && $this->show_footer == true && $this->hide_global_chat == false) {
+                $js_files[] = 'chat/js/chat.js';
+            }            
         }
 
         if (api_get_setting('accessibility_font_resize') == 'true') {
@@ -487,8 +486,7 @@ class Template {
 
         $css_files = array(
             api_get_path(WEB_LIBRARY_PATH) . 'javascript/thickbox.css',
-            api_get_path(WEB_LIBRARY_PATH) . 'javascript/chosen/chosen.css',
-            //api_get_path(WEB_LIBRARY_PATH) . 'javascript/dtree/dtree.css', not used anymore
+            api_get_path(WEB_LIBRARY_PATH) . 'javascript/chosen/chosen.css'
         );
 
         if ($this->show_learnpath) {
@@ -496,7 +494,7 @@ class Template {
             $css_files[] = api_get_path(WEB_CSS_PATH) . $this->theme . '/scorm.css';
         }
 
-        if (api_get_setting('allow_global_chat') == 'true') {
+        if (api_is_global_chat_enabled()) {
             $css_files[] = api_get_path(WEB_LIBRARY_PATH) . 'javascript/chat/css/chat.css';
         }
 
@@ -596,7 +594,7 @@ class Template {
         $this->assign('logout_link', api_get_path(WEB_PATH).'index.php?logout=logout&&uid='.api_get_user_id());        
         
         //Profile link
-        if (api_get_setting('allow_social_tool')=='true') {
+        if (api_get_setting('allow_social_tool') == 'true') {
             $profile_link = '<a href="'.api_get_path(WEB_CODE_PATH).'social/home.php">'.get_lang('Profile').'</a>';
         } else {
             $profile_link = '<a href="'.api_get_path(WEB_CODE_PATH).'auth/profile.php">'.get_lang('Profile').'</a>';

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

@@ -2821,7 +2821,7 @@ class UserManager {
 	 * @author jmontoya
 	 * @return array
 	 */
-	 public function get_all_administrators() {
+	 public static function get_all_administrators() {
 	 	$table_user = Database::get_main_table(TABLE_MAIN_USER);
 	 	$table_admin = Database::get_main_table(TABLE_MAIN_ADMIN);        
         $tbl_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);

+ 10 - 1
main/install/index.php

@@ -770,7 +770,16 @@ if (@$_POST['step2']) {
 		} elseif ($userPasswordCrypted == '0') {
 			$userPasswordCrypted = 'none';
 		}
-
+        
+        //Setting the single db form
+        if (in_array($_POST['old_version'], $update_from_version_6)) {            
+            $singleDbForm   	= get_config_param('singleDbEnabled');            
+        } else {
+            $singleDbForm   	= isset($_configuration['single_database']) ? $_configuration['single_database'] : false;            
+        }
+        
+        Log::notice("singledbForm: '$singleDbForm'");
+        
 		Database::query("SET storage_engine = MYISAM;");
 
 		if (version_compare($my_old_version, '1.8.7', '>=')) {

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

@@ -1767,10 +1767,15 @@ function display_database_settings_form($installType, $dbHostForm, $dbUsernameFo
     }
     ?>
     <tr>
+        <td></td>
         <td>
-            <button type="submit" class="login" name="step3" value="<?php echo get_lang('CheckDatabaseConnection'); ?>" >
+            <button type="submit" class="btn" name="step3" value="<?php echo get_lang('CheckDatabaseConnection'); ?>" >
                 <?php echo get_lang('CheckDatabaseConnection'); ?></button>
         </td>
+    </tr>    
+    <tr>
+        <td>
+        
         <?php
         
         $dbConnect = test_db_connect($dbHostForm, $dbUsernameForm, $dbPassForm, $singleDbForm, $dbPrefixForm, $dbNameForm);        

+ 3 - 1
main/install/update-db-1.8.8-1.9.0.inc.php

@@ -34,7 +34,7 @@ if (defined('SYSTEM_INSTALLATION')) {
     }
 
     $_configuration['db_glue'] = get_config_param('dbGlu');
-
+    
     if ($singleDbForm) {
         $_configuration['table_prefix'] 	= get_config_param('courseTablePrefix');
         $_configuration['main_database'] 	= get_config_param('mainDbName');
@@ -305,6 +305,8 @@ if (defined('SYSTEM_INSTALLATION')) {
     if ($singleDbForm) {
         $prefix =  get_config_param('table_prefix');
     }
+    
+    Log::notice("Database prefix: '$prefix'");
 
     // Get the courses databases queries list (c_q_list)
     $c_q_list = get_sql_file_contents('migrate-db-'.$old_file_version.'-'.$new_file_version.'-pre.sql', 'course');

+ 4 - 4
main/install/version.php

@@ -11,10 +11,10 @@
 /**
  * Variables used from the main/install/index.php
  */
-$new_version            = '1.9.0';
-$new_version_status     = 'Stable';
+$new_version            = '1.9.2';
+$new_version_status     = 'Unstable';
 $new_version_last_id	= 1;
-$new_version_stable 	= true;
-$new_version_major      = true;
+$new_version_stable 	= false;
+$new_version_major      = false;
 $software_name          = 'Chamilo';
 $software_url           = 'http://www.chamilo.org/';

+ 19 - 4
main/newscorm/learnpath.class.php

@@ -614,7 +614,7 @@ class learnpath {
      * @param	string	Zip file containing the learnpath or directory containing the learnpath
      * @return	integer	The new learnpath ID on success, 0 on failure
      */
-    public function add_lp($course, $name, $description = '', $learnpath = 'guess', $origin = 'zip', $zipname = '', $publicated_on = '', $expired_on = '') {
+    public static function add_lp($course, $name, $description = '', $learnpath = 'guess', $origin = 'zip', $zipname = '', $publicated_on = '', $expired_on = '') {
         global $charset;
         $course_id = api_get_course_int_id();
         $tbl_lp = Database :: get_course_table(TABLE_LP_MAIN);
@@ -649,7 +649,6 @@ class learnpath {
             $expired_on   = Database::escape_string(api_get_utc_datetime($expired_on));
         }
 
-
         while (Database :: num_rows($res_name)) {
             // There is already one such name, update the current one a bit.
             $i++;
@@ -660,7 +659,7 @@ class learnpath {
         }
         // New name does not exist yet; keep it.
         // Escape description.
-        $description = learnpath :: escape_string(api_htmlentities($description, ENT_QUOTES, $charset)); // Kevin: added htmlentities().
+        $description = Database::escape_string(api_htmlentities($description, ENT_QUOTES, $charset)); // Kevin: added htmlentities().
         $type = 1;
         switch ($learnpath) {
             case 'guess':
@@ -7578,6 +7577,22 @@ class learnpath {
             $return .= get_lang('File').': '.$document_data['absolute_path_from_document'];
         }
         
+        if ($item_type == TOOL_DOCUMENT ) {
+            $document_data = DocumentManager::get_document_data_by_id($row['path'], $course_code);            
+            $return .= get_lang('File').': '.$document_data['absolute_path_from_document'];
+        }
+        
+        if ($item_type == TOOL_QUIZ ) {
+            $document_data = DocumentManager::get_document_data_by_id($row['path'], $course_code);            
+            $return .= get_lang('File').': '.$document_data['absolute_path_from_document'];
+        }
+        
+        if ($item_type == TOOL_LINK ) {
+            $document_data = DocumentManager::get_document_data_by_id($row['path'], $course_code);            
+            $return .= get_lang('File').': '.$document_data['absolute_path_from_document'];
+        }
+                
+                
         $return .= '</div>';
         
         if (!empty($audio_player)) {
@@ -9269,4 +9284,4 @@ if (!function_exists('trim_value')) {
     function trim_value(& $value) {
         $value = trim($value);
     }
-}
+}

+ 8 - 5
main/survey/create_new_survey.php

@@ -258,10 +258,6 @@ $form->addRule(array('start_date', 'end_date'), get_lang('StartDateShouldBeBefor
 // Setting the default values
 $form->setDefaults($defaults);
 
-
-// Displaying the header
-Display::display_header($tool_name);
-
 // The validation or display
 if ($form->validate()) {
 	// Exporting the values
@@ -281,6 +277,9 @@ if ($form->validate()) {
 	if ($return['type'] == 'error') {
 		// Display the error
 		Display::display_error_message(get_lang($return['message']), false);
+        
+        // Displaying the header
+        Display::display_header($tool_name);
 
 		// Display the form
 		$form->display();
@@ -307,6 +306,7 @@ if ($form->validate()) {
 			}
 		}
 	}
+    
 	if ($config['survey']['debug']) {
 		// Displaying a feedback message
    		Display::display_confirmation_message($return['message'], false);
@@ -315,7 +315,10 @@ if ($form->validate()) {
    		header('location:survey.php?survey_id='.$return['id'].'&message='.$return['message']);
         exit;
 	}
-} else {		
+} else {
+    // Displaying the header
+    Display::display_header($tool_name);
+
 	$form->display();
 }
 

+ 38 - 37
main/user/user.php

@@ -447,8 +447,7 @@ function search_keyword($firstname, $lastname, $username, $official_code, $keywo
 function get_user_data($from, $number_of_items, $column, $direction) {
 	global $origin;
     global $course_info;
-	global $is_western_name_order;
-	global $sort_by_first_name;
+	global $is_western_name_order;	
     global $session_id;
     
 	$a_users = array();
@@ -461,37 +460,33 @@ function get_user_data($from, $number_of_items, $column, $direction) {
 	if (!in_array($direction, array('ASC', 'DESC'))) {
 		$direction = 'ASC';
 	}
-
-    if (api_is_allowed_to_edit()) {
-        $column--;
-    }
-
+    
 	switch ($column) {
-	    case 1:
+	    case 2: //official code
             $order_by = 'ORDER BY user.official_code '.$direction;
             break;
-		case 2:
+		case 3:
 			if ($is_western_name_order) {
 				$order_by = 'ORDER BY user.firstname '.$direction.', user.lastname '.$direction;
 			} else {
 				$order_by = 'ORDER BY user.lastname '.$direction.', user.firstname '.$direction;
 			}
 			break;
-		case 3:
+		case 4:
 			if ($is_western_name_order) {
 				$order_by = 'ORDER BY user.lastname '.$direction.', user.firstname '.$direction;
 			} else {
 				$order_by = 'ORDER BY user.firstname '.$direction.', user.lastname '.$direction;
 			}
 			break;
-		case 4:
+		case 5: //username
 			$order_by = 'ORDER BY user.username '.$direction;
-			break;
+			break;        
 		default:
-			if ($sort_by_first_name) {
-				$order_by = 'ORDER BY user.firstname '.$direction.', user.lastname '.$direction;
+			if ($is_western_name_order) {
+                $order_by = 'ORDER BY user.lastname '.$direction.', user.firstname '.$direction;				
 			} else {
-				$order_by = 'ORDER BY user.lastname '.$direction.', user.firstname '.$direction;
+				$order_by = 'ORDER BY user.firstname '.$direction.', user.lastname '.$direction;
 			}
 			break;
 	}
@@ -507,16 +502,17 @@ function get_user_data($from, $number_of_items, $column, $direction) {
 			$groups_name = GroupManager :: get_user_group_name($user_id);
 			$temp = array();
 			if (api_is_allowed_to_edit(null, true)) {
-				if (api_get_setting('allow_user_course_subscription_by_course_admin') == 'true') {
+				//if (api_get_setting('allow_user_course_subscription_by_course_admin') == 'true') {
                 	$temp[] = $user_id;
-                }
+                //}
 				$image_path = UserManager::get_user_picture_path_by_id($user_id, 'web', false, true);
 				$user_profile = UserManager::get_picture_user($user_id, $image_path['file'], 22, USER_IMAGE_SIZE_SMALL, ' width="22" height="22" ');
 				if (!api_is_anonymous()) {
-					$photo = '<center><a href="userInfo.php?'.api_get_cidreq().'&origin='.$origin.'&amp;uInfo='.$user_id.'" title="'.get_lang('Info').'"  ><img src="'.$user_profile['file'].'" '.$user_profile['style'].' alt="'.api_get_person_name($o_course_user['firstname'], $o_course_user['lastname']).'"  title="'.api_get_person_name($o_course_user['firstname'], $o_course_user['lastname']).'" /></a></center>';
+					$photo = '<a href="userInfo.php?'.api_get_cidreq().'&origin='.$origin.'&amp;uInfo='.$user_id.'" title="'.get_lang('Info').'"  ><img src="'.$user_profile['file'].'" '.$user_profile['style'].' alt="'.api_get_person_name($o_course_user['firstname'], $o_course_user['lastname']).'"  title="'.api_get_person_name($o_course_user['firstname'], $o_course_user['lastname']).'" /></a>';
 				} else {
-					$photo = '<center><img src="'.$user_profile['file'].'" '.$user_profile['style'].' alt="'.api_get_person_name($o_course_user['firstname'], $o_course_user['lastname']).'" title="'.api_get_person_name($o_course_user['firstname'], $o_course_user['lastname']).'" /></center>';
+					$photo = '<img src="'.$user_profile['file'].'" '.$user_profile['style'].' alt="'.api_get_person_name($o_course_user['firstname'], $o_course_user['lastname']).'" title="'.api_get_person_name($o_course_user['firstname'], $o_course_user['lastname']).'" />';
 				}
+                
 				$temp[] = $photo;
 				$temp[] = $o_course_user['official_code'];
 				
@@ -551,11 +547,11 @@ function get_user_data($from, $number_of_items, $column, $direction) {
 				$image_repository = $image_path['dir'];
 				$existing_image = $image_path['file'];
 				if (!api_is_anonymous()) {
-					$photo= '<center><a href="userInfo.php?'.api_get_cidreq().'&origin='.$origin.'&amp;uInfo='.$user_id.'" title="'.get_lang('Info').'"  ><img src="'.$image_repository.$existing_image.'" alt="'.api_get_person_name($o_course_user['firstname'], $o_course_user['lastname']).'"  width="22" height="22" title="'.api_get_person_name($o_course_user['firstname'], $o_course_user['lastname']).'" /></a></center>';
+					$photo= '<a href="userInfo.php?'.api_get_cidreq().'&origin='.$origin.'&amp;uInfo='.$user_id.'" title="'.get_lang('Info').'"  ><img src="'.$image_repository.$existing_image.'" alt="'.api_get_person_name($o_course_user['firstname'], $o_course_user['lastname']).'"  width="22" height="22" title="'.api_get_person_name($o_course_user['firstname'], $o_course_user['lastname']).'" /></a>';
 				} else {
-					$photo= '<center><img src="'.$image_repository.$existing_image.'" alt="'.api_get_person_name($o_course_user['firstname'], $o_course_user['lastname']).'"  width="22" height="22" title="'.api_get_person_name($o_course_user['firstname'], $o_course_user['lastname']).'" /></center>';
+					$photo= '<img src="'.$image_repository.$existing_image.'" alt="'.api_get_person_name($o_course_user['firstname'], $o_course_user['lastname']).'"  width="22" height="22" title="'.api_get_person_name($o_course_user['firstname'], $o_course_user['lastname']).'" />';
 				}
-                
+                $temp[] = $user_id;
 				$temp[] = $photo;
                 $temp[] = $o_course_user['official_code'];
 
@@ -651,29 +647,30 @@ function modify_filter($user_id) {
                 $result .= '<a class="btn" href="'.api_get_self().'?'.api_get_cidreq().'&unregister=yes&amp;user_id='.$user_id.'" title="'.get_lang('Unreg').' " onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang('ConfirmYourChoice'),ENT_QUOTES,$charset)).'\')) return false;">'.get_lang('Unreg').'</a>&nbsp;';
             }
         }        
-    }
-   
+    }   
 	return $result;
 }
 
-$default_column = ($is_western_name_order xor $sort_by_first_name) ? 3 : 2;
-$default_column = api_is_allowed_to_edit() ? 2 : 1;
+function hide_field() {
+    return null;    
+}
+
+$default_column = 3;
 
 $table = new SortableTable('user_list', 'get_number_of_users', 'get_user_data', $default_column);
 $parameters['keyword'] = isset($_GET['keyword']) ? Security::remove_XSS($_GET['keyword']) : null;
+// Create a sortable table with user-data
+$parameters['sec_token'] = Security::get_token();
+
 $table->set_additional_parameters($parameters);
 $header_nr = 0;
 
-if (api_is_allowed_to_edit(null, true)) {
-    if (api_get_setting('allow_user_course_subscription_by_course_admin') == 'true') {
-        $table->set_header($header_nr++, '', false);
-    }
-}
+$table->set_header($header_nr++, '', false);
 $table->set_header($header_nr++, get_lang('Photo'), false);
 $table->set_header($header_nr++, get_lang('OfficialCode'));
 
 if ($is_western_name_order) {
-	$table->set_header($header_nr++, get_lang('FirstName'));
+	$table->set_header($header_nr++, get_lang('FirstName'));    
 	$table->set_header($header_nr++, get_lang('LastName'));
 } else {
 	$table->set_header($header_nr++, get_lang('LastName'));
@@ -682,16 +679,20 @@ if ($is_western_name_order) {
 $table->set_header($header_nr++, get_lang('LoginName'));  // 
 $table->set_header($header_nr++, get_lang('Description'), false);
 $table->set_header($header_nr++, get_lang('GroupSingle'), false);
-        
-if (api_is_allowed_to_edit(null, true)) {
-	// deprecated feature
-	//$table->set_header($header_nr++, get_lang('Tutor'), false);
+
+if (api_is_allowed_to_edit(null, true) && api_get_setting('allow_user_course_subscription_by_course_admin') == 'true') {
+     
+} else {
+    $table->set_column_filter(0, 'hide_field');    
+}
+
+if (api_is_allowed_to_edit(null, true)) {		
 	$table->set_header($header_nr++, get_lang('Status'), false);
 	$table->set_header($header_nr++, get_lang('Active'), false);
     if (api_get_setting('allow_user_course_subscription_by_course_admin') == 'true') {
         $table->set_column_filter(9, 'active_filter');
     } else {
-        $table->set_column_filter(8, 'active_filter');
+        $table->set_column_filter(9, 'active_filter');
     }
 	//actions column
 	$table->set_header($header_nr++, get_lang('Action'), false);

+ 22 - 71
main/work/work.php

@@ -680,88 +680,39 @@ switch ($action) {
             //Bad token or can't add works
             $error_message = get_lang('IsNotPosibleSaveTheDocument');
         }
-						
+                    
 		if (!empty($succeed) && !empty($id)) {
 			//last value is to check this is not "just" an edit
 			//YW Tis part serve to send a e-mail to the tutors when a new file is sent
 			$send = api_get_course_setting('email_alert_manager_on_new_doc');
-			
+            
 			if ($send > 0) {
-				// Lets predefine some variables. Be sure to change the from address!
-				
-				$emailto = array ();
+				// Lets predefine some variables. Be sure to change the from address!				
 				if (empty($id_session)) {
-					$sql_resp = 'SELECT u.email as myemail FROM ' . $table_course_user . ' cu, ' . $table_user . ' u 
-								 WHERE cu.course_code = ' . "'" . api_get_course_id() . "'" . ' AND cu.status = 1 AND u.user_id = cu.user_id';
-					$res_resp = Database::query($sql_resp);
-					while ($row_email = Database :: fetch_array($res_resp)) {
-						if (!empty ($row_email['myemail'])) {
-                            $emailto[$row_email['myemail']] = $row_email['myemail'];
-						}
-					}
+                    //Teachers
+                    $user_list = CourseManager::get_user_list_from_course_code(api_get_course_id(), null, null, null, COURSEMANAGER);
 				} else {				
-					// coachs of the session
-					$sql_resp = 'SELECT user.email as myemail
-										FROM ' . $table_session . ' session INNER JOIN ' . $table_user . ' user
-										ON user.user_id = session.id_coach
-										WHERE session.id = ' . intval($id_session);
-					$res_resp = Database::query($sql_resp);
-					while ($row_email = Database :: fetch_array($res_resp)) {
-						if (!empty ($row_email['myemail'])) {
-							$emailto[$row_email['myemail']] = $row_email['myemail'];
-						}
-					}
-			
-					//coach of the course
-					$sql_resp = 'SELECT user.email as myemail
-								FROM ' . $table_session_course_user . ' scu
-                                INNER JOIN ' . $table_user . ' user
-                                    ON user.user_id = scu.id_user AND scu.status=2
-                                WHERE scu.id_session = ' . intval($id_session);
-					$res_resp = Database::query($sql_resp);
-					while ($row_email = Database :: fetch_array($res_resp)) {
-						if (!empty ($row_email['myemail'])) {
-							$emailto[$row_email['myemail']] = $row_email['myemail'];
-						}
-					}
+                    //Coaches
+                    $user_list = CourseManager::get_user_list_from_course_code(api_get_course_id(), $session_id, null, null, 2);					
 				}
-			
-				if (count($emailto) > 0) {		
-					$emailto = implode(',', $emailto);				
-					$emailsubject = "[" . api_get_setting('siteName') . "] ";
-					$sender_name = api_get_setting('administratorName').' '.api_get_setting('administratorSurname');
-					$email_admin = api_get_setting('emailAdministrator');
-							// The body can be as long as you wish, and any combination of text and variables
-				
-					$emailbody = get_lang('SendMailBody')."\n".get_lang('CourseName')." : ".$_course['name']."\n";
-					$emailbody .= get_lang('WorkName')." : ".substr($my_cur_dir_path, 0, -1)."\n";
-					$emailbody .= get_lang('UserName')." : ".$currentUserFirstName .' '.$currentUserLastName ."\n";
+                
+                $emailsubject = "[" . api_get_setting('siteName') . "] ".get_lang('SendMailBody')."\n".get_lang('CourseName')." : ".$_course['name']."  ";
+                
+                foreach ($user_list as $user_data) {
+                    $user_id = $user_data;                    
+                    $emailbody = get_lang('SendMailBody')."\n".get_lang('CourseName')." : ".$_course['name']."\n";
+					//$emailbody .= get_lang('WorkName')." : ".substr($my_cur_dir_path, 0, -1)."\n";
+					$emailbody .= get_lang('UserName')." : ".api_get_person_name($user_data['firstname'], $user_data['lastname'])."\n";
 					$emailbody .= get_lang('DateSent')." : ".api_format_date(api_get_local_time())."\n";
-					$emailbody .= get_lang('FileName')." : ".$title."\n\n".get_lang('DownloadLink')."\n";
-					$emailbody .= api_get_path(WEB_CODE_PATH)."work/work.php?".api_get_cidreq()."&amp;curdirpath=".$my_cur_dir_path."\n\n" . api_get_setting('administratorName') . " " . api_get_setting('administratorSurname') . "\n" . get_lang('Manager') . " " . api_get_setting('siteName') . "\n" . get_lang('Email') . " : " . api_get_setting('emailAdministrator');
+					$emailbody .= get_lang('WorkName')." : ".$title."\n\n".get_lang('DownloadLink')."\n";
+                    $url = api_get_path(WEB_CODE_PATH)."work/work.php?".api_get_cidreq()."&amp;id=".$work_id;
+					$emailbody .= Display::url($url, $url)." \n\n" . api_get_setting('administratorName') . " " . api_get_setting('administratorSurname') . "\n" . get_lang('Manager') . " " . api_get_setting('siteName') . "\n" . get_lang('Email') . " : " . api_get_setting('emailAdministrator');
                     
-				    // Here we are forming one large header line
-					// Every header must be followed by a \n except the last
-					@api_mail('', $emailto, $emailsubject, $emailbody, $sender_name,$email_admin);
-				
-					$emailbody_user = get_lang('Dear')." ".$currentUserFirstName .' '.$currentUserLastName .", \n\n";
-					$emailbody_user .= get_lang('MessageConfirmSendingOfTask')."\n".get_lang('CourseName')." : ".$_course['name']."\n";
-					$emailbody_user .= get_lang('WorkName')." : ".substr($my_cur_dir_path, 0, -1)."\n";
-					$emailbody_user .= get_lang('DateSent')." : ".api_format_date(api_get_local_time())."\n";
-					$emailbody_user .= get_lang('FileName')." : ".$title."\n\n".api_get_setting('administratorName')." ".api_get_setting('administratorSurname') . "\n" . get_lang('Manager') . " " . api_get_setting('siteName') . "\n" . get_lang('Email') . " : " . api_get_setting('emailAdministrator');;
-				
-					//Mail to user
-                    //var_dump($currentUserEmail, $emailsubject, $emailbody_user, $sender_name, $email_admin);
-                    
-					@api_mail('', $currentUserEmail, $emailsubject, $emailbody_user, $sender_name, $email_admin);
-				}
-			}
-			$message = get_lang('DocAdd');
-			//stats
-			if (!$Id) {
-				$Id = $insertId;
+                    MessageManager::send_message_simple($user_id, $emailsubject, $emailbody);                    
+                }			
 			}
-			event_upload($Id);			
+			$message = get_lang('DocAdd');			
+			event_upload($id);			
 			Display :: display_confirmation_message(get_lang('DocAdd'), false);
 		} else {
             if (!empty($error_message)) {

BIN
tests/history/1.9.0/640x480/course-home1.png