Browse Source

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

Yannick Warnier 10 years ago
parent
commit
f67e77a5f8
51 changed files with 1908 additions and 1820 deletions
  1. 1 0
      .gitignore
  2. 1 2
      main/announcements/announcements.php
  3. 52 52
      main/auth/profile.php
  4. 2 2
      main/calendar/agenda_list.php
  5. 3 3
      main/css/base.css
  6. 1 5
      main/css/chamilo/default.css
  7. 1 1
      main/exercice/exercise.class.php
  8. 17 9
      main/exercice/question_list_admin.inc.php
  9. 6 6
      main/gradebook/gradebook_add_user.php
  10. 6 6
      main/gradebook/gradebook_edit_result.php
  11. 3 3
      main/gradebook/gradebook_statistics.php
  12. 7 5
      main/gradebook/gradebook_view_result.php
  13. 1 1
      main/gradebook/lib/GradebookUtils.php
  14. 3 0
      main/gradebook/lib/be/result.class.php
  15. 209 205
      main/gradebook/lib/fe/flatviewtable.class.php
  16. 8 4
      main/gradebook/lib/fe/resulttable.class.php
  17. 41 15
      main/inc/lib/AnnouncementManager.php
  18. 44 5
      main/inc/lib/display.lib.php
  19. 4 1
      main/inc/lib/events.lib.inc.php
  20. 1 1
      main/inc/lib/formvalidator/Element/DateRangePicker.php
  21. 0 1
      main/inc/lib/formvalidator/FormValidator.class.php
  22. 46 93
      main/inc/lib/internationalization.lib.php
  23. 9 1
      main/inc/lib/message.lib.php
  24. 3 1
      main/inc/lib/pear/HTML/QuickForm/advmultiselect.php
  25. 7 3
      main/inc/lib/pear/HTML/QuickForm/checkbox.php
  26. 13 12
      main/inc/lib/social.lib.php
  27. 6 6
      main/inc/lib/template.lib.php
  28. 10 8
      main/inc/lib/usermanager.lib.php
  29. 0 1245
      main/install/course.sql
  30. 1247 4
      main/install/database.sql
  31. 1 1
      main/install/install.lib.php
  32. 1 3
      main/install/install_db.inc.php
  33. 3 1
      main/install/migrate-db-1.9.0-1.10.0-pre.sql
  34. 0 3
      main/install/update-db-1.8.8-1.9.0.inc.php
  35. 2 3
      main/messages/inbox.php
  36. 3 3
      main/messages/new_message.php
  37. 12 18
      main/messages/outbox.php
  38. 3 2
      main/messages/view_message.php
  39. 1 1
      main/newscorm/lp_controller.php
  40. 2 3
      main/social/friends.php
  41. 6 6
      main/social/groups.php
  42. 37 27
      main/social/home.php
  43. 2 6
      main/social/invitations.php
  44. 3 8
      main/social/myfiles.php
  45. 4 5
      main/social/profile.php
  46. 3 3
      main/social/search.php
  47. 60 19
      main/survey/survey.lib.php
  48. 2 2
      main/survey/survey.php
  49. 8 3
      main/survey/survey_invite.php
  50. 2 2
      main/template/default/social/myfiles.tpl
  51. 1 1
      main/template/default/social/user_block.tpl

+ 1 - 0
.gitignore

@@ -49,6 +49,7 @@ plugin/bbb/config.vm.php
 main/cron/incoming/*
 
 # Stuff updated through composer
+composer.lock
 vendor
 web/assets/*
 

+ 1 - 2
main/announcements/announcements.php

@@ -54,6 +54,7 @@ $tbl_item_property = Database::get_course_table(TABLE_ITEM_PROPERTY);
 
 $course_id = api_get_course_int_id();
 $_course = api_get_course_info();
+$group_id = api_get_group_id();
 
 api_protect_course_group(GroupManager::GROUP_TOOL_ANNOUNCEMENT);
 
@@ -454,8 +455,6 @@ if (api_is_allowed_to_edit(false,true) OR
 
 $htmlHeadXtra[] = AnnouncementManager::to_javascript();
 
-$group_id = api_get_group_id();
-
 if (!empty($group_id)) {
     $group_properties  = GroupManager :: get_group_properties($group_id);
     $interbreadcrumb[] = array("url" => "../group/group.php?".api_get_cidreq(), "name" => get_lang('Groups'));

+ 52 - 52
main/auth/profile.php

@@ -84,18 +84,16 @@ if (!empty($_GET['fe'])) {
 $jquery_ready_content = '';
 if (api_get_setting('allow_message_tool') == 'true') {
     $jquery_ready_content = <<<EOF
-            $(".message-content .message-delete").click(function(){
-                $(this).parents(".message-content").animate({ opacity: "hide" }, "slow");
-                $(".message-view").animate({ opacity: "show" }, "slow");
-            });
+    $(".message-content .message-delete").click(function(){
+        $(this).parents(".message-content").animate({ opacity: "hide" }, "slow");
+        $(".message-view").animate({ opacity: "show" }, "slow");
+    });
 EOF;
 }
 
 $tool_name = is_profile_editable() ? get_lang('ModifProfile') : get_lang('ViewProfile');
 $table_user = Database :: get_main_table(TABLE_MAIN_USER);
 
-/*    Form    */
-
 /*
  * Get initial values for all fields.
  */
@@ -117,7 +115,13 @@ if ($user_data !== false) {
 /*
  * Initialize the form.
  */
-$form = new FormValidator('profile', 'post', api_get_self()."?".str_replace('&fe=1', '', $_SERVER['QUERY_STRING']), null, array('style' => 'width: 70%; float: '.($text_dir == 'rtl' ? 'right;' : 'left;')));
+$form = new FormValidator(
+    'profile',
+    'post',
+    api_get_self()."?".str_replace('&fe=1', '', Security::remove_XSS($_SERVER['QUERY_STRING'])),
+    null,
+    array('style' => 'width: 70%; float: '.($text_dir == 'rtl' ? 'right;' : 'left;'))
+);
 
 if (api_is_western_name_order()) {
     //    FIRST NAME and LAST NAME
@@ -226,7 +230,6 @@ if (is_profile_editable() && api_get_setting('user_selected_theme') == 'true') {
     $form->applyFilter('theme', 'trim');
 }
 
-
 //    EXTENDED PROFILE  this make the page very slow!
 if (api_get_setting('extended_profile') == 'true') {
     $width_extended_profile = 500;
@@ -248,7 +251,6 @@ if (api_get_setting('extended_profile') == 'true') {
     $form->addHtmlEditor('openarea', get_lang('MyPersonalOpenArea'), false, false, array('ToolbarSet' => 'Profile', 'Width' => $width_extended_profile, 'Height' => '350'));
     $form->applyFilter(array('competences', 'diplomas', 'teach', 'openarea'), 'stripslashes');
     $form->applyFilter(array('competences', 'diplomas', 'teach'), 'trim'); // openarea is untrimmed for maximum openness
-
 }
 
 //    PASSWORD, if auth_source is platform
@@ -294,9 +296,6 @@ if (is_profile_editable()) {
 $user_data = array_merge($user_data, $extra_data);
 $form->setDefaults($user_data);
 
-/*        FUNCTIONS   */
-
-
 /**
  * Is user auth_source is platform ?
  *
@@ -351,7 +350,6 @@ function upload_user_production($user_id) {
  * @uses Gets user ID from global variable
  */
 function check_user_password($password) {
-    global $_user;
     $user_id = api_get_user_id();
     if ($user_id != strval(intval($user_id)) || empty($password)) { return false; }
     $table_user = Database :: get_main_table(TABLE_MAIN_USER);
@@ -405,9 +403,7 @@ if (is_platform_authentication()) {
 }
 
 if ($form->validate()) {
-
     $wrong_current_password = false;
-//    $user_data = $form->exportValues();
     $user_data = $form->getSubmitValues(1);
 
     // set password if a new one was provided
@@ -431,17 +427,13 @@ if ($form->validate()) {
         $allow_users_to_change_email_with_no_password = false;
     }
 
-
-
-
-    //If user sending the email to be changed (input available and not frozen )
+    // If user sending the email to be changed (input available and not frozen )
     if (api_get_setting('profile', 'email') == 'true') {
         if ($allow_users_to_change_email_with_no_password) {
             if (!check_user_email($user_data['email'])) {
                 $changeemail = $user_data['email'];
                 //$_SESSION['change_email'] = 'success';
             }
-
         } else {
             //Normal behaviour
             if (!check_user_email($user_data['email']) && !empty($user_data['password0']) && !$wrong_current_password) {
@@ -454,10 +446,15 @@ if ($form->validate()) {
         }
     }
 
-
     // Upload picture if a new one is provided
     if ($_FILES['picture']['size']) {
-        if ($new_picture = UserManager::update_user_picture(api_get_user_id(), $_FILES['picture']['name'], $_FILES['picture']['tmp_name'])) {
+        $new_picture = UserManager::update_user_picture(
+            api_get_user_id(),
+            $_FILES['picture']['name'],
+            $_FILES['picture']['tmp_name']
+        );
+
+        if ($new_picture) {
             $user_data['picture_uri'] = $new_picture;
             $_SESSION['image_uploaded'] = 'success';
         }
@@ -485,7 +482,8 @@ if ($form->validate()) {
     if ($_FILES['production']['size']) {
         $res = upload_user_production(api_get_user_id());
         if (!$res) {
-            //it's a bit excessive to assume the extension is the reason why upload_user_production() returned false, but it's true in most cases
+            //it's a bit excessive to assume the extension is the reason why
+            // upload_user_production() returned false, but it's true in most cases
             $filtered_extension = true;
         } else {
             $_SESSION['production_uploaded'] = 'success';
@@ -494,7 +492,7 @@ if ($form->validate()) {
 
     // remove values that shouldn't go in the database
     unset($user_data['password0'],$user_data['password1'], $user_data['password2'], $user_data['MAX_FILE_SIZE'],
-    $user_data['remove_picture'], $user_data['apply_change'],$user_data['email'] );
+    $user_data['remove_picture'], $user_data['apply_change'], $user_data['email'] );
 
     // Following RFC2396 (http://www.faqs.org/rfcs/rfc2396.html), a URI uses ':' as a reserved character
     // we can thus ensure the URL doesn't contain any scheme name by searching for ':' in the string
@@ -605,7 +603,6 @@ if ($form->validate()) {
     $sql .= " WHERE user_id  = '".api_get_user_id()."'";
     Database::query($sql);
 
-
     // User tag process
     //1. Deleting all user tags
     $list_extra_field_type_tag = UserManager::get_all_extra_field_by_type(UserManager::USER_FIELD_TYPE_TAG);
@@ -617,7 +614,6 @@ if ($form->validate()) {
     }
 
     //2. Update the extra fields and user tags if available
-
     if (is_array($extras) && count($extras)> 0) {
         foreach ($extras as $key => $value) {
             //3. Tags are process in the UserManager::update_extra_field_value by the UserManager::process_tags function
@@ -651,32 +647,31 @@ if ($form->validate()) {
 }
 
 // the header
-Display::display_header(get_lang('ModifyProfile'));
 
+$actions = null;
 if (api_get_setting('allow_social_tool') != 'true') {
-
     if (api_get_setting('extended_profile') == 'true') {
-        echo '<div class="actions">';
+        $actions .= '<div class="actions">';
 
         if (api_get_setting('allow_social_tool') == 'true' && api_get_setting('allow_message_tool') == 'true') {
-            echo '<a href="'.api_get_path(WEB_PATH).'main/social/profile.php">'.Display::return_icon('shared_profile.png', get_lang('ViewSharedProfile')).'</a>';
+            $actions .= '<a href="'.api_get_path(WEB_PATH).'main/social/profile.php">'.Display::return_icon('shared_profile.png', get_lang('ViewSharedProfile')).'</a>';
         }
         if (api_get_setting('allow_message_tool') == 'true') {
-            echo '<a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php">'.Display::return_icon('inbox.png', get_lang('Messages')).'</a>';
+            $actions .= '<a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php">'.Display::return_icon('inbox.png', get_lang('Messages')).'</a>';
         }
         $show = isset($_GET['show']) ? '&amp;show='.Security::remove_XSS($_GET['show']) : '';
 
         if (isset($_GET['type']) && $_GET['type'] == 'extended') {
-            echo '<a href="profile.php?type=reduced'.$show.'">'.Display::return_icon('edit.png', get_lang('EditNormalProfile'),'',16).'</a>';
+            $actions .= '<a href="profile.php?type=reduced'.$show.'">'.Display::return_icon('edit.png', get_lang('EditNormalProfile'),'',16).'</a>';
         } else {
-            echo '<a href="profile.php?type=extended'.$show.'">'.Display::return_icon('edit.png', get_lang('EditExtendProfile'),'',16).'</a>';
+            $actions .= '<a href="profile.php?type=extended'.$show.'">'.Display::return_icon('edit.png', get_lang('EditExtendProfile'),'',16).'</a>';
         }
-        echo '</div>';
+        $actions .= '</div>';
     }
 }
 
 if (!empty($file_deleted)) {
-    Display :: display_confirmation_message(get_lang('FileDeleted'), false);
+    Display::addFlash(Display :: return_message(get_lang('FileDeleted'), 'normal', false));
 } elseif (!empty($update_success)) {
     $message = get_lang('ProfileReg');
 
@@ -687,17 +682,17 @@ if (!empty($file_deleted)) {
     if ($upload_production_success) {
         $message.='<br />'.get_lang('ProductionUploaded');
     }
-    Display :: display_confirmation_message($message, false);
+    Display::addFlash(Display :: return_message($message, 'normal', false));
 }
 
 if (!empty($msg_fail_changue_email)){
     $errormail=get_lang('ToChangeYourEmailMustTypeYourPassword');
-    Display :: display_error_message($errormail, false);
+    Display::addFlash(Display :: return_message($errormail, 'error', false));
 }
 
 if (!empty($msg_is_not_password)){
     $warning_msg = get_lang('CurrentPasswordEmptyOrIncorrect');
-    Display :: display_warning_message($warning_msg, false);
+    Display::addFlash(Display :: return_message($warning_msg, 'warning', false));
 }
 
 // User picture size is calculated from SYSTEM path
@@ -723,25 +718,30 @@ $url_big_image      = $big_image.'?rnd='.time();
 
 $show_delete_account_button = api_get_setting('platform_unsubscribe_allowed') == 'true' ? true : false;
 
+$tpl = new Template(get_lang('ModifyProfile'));
+$tpl->assign('actions', $actions);
+//$tpl->assign('message', Display::getFlashToString());
+
+SocialManager::setSocialUserBlock($tpl, $user_id, 'messages');
 if (api_get_setting('allow_social_tool') == 'true') {
-    echo '<div class="row">';
-        echo '<div class="col-md-3">';
-        echo SocialManager::getSocialUserBlock(api_get_user_id(), 'home');
-        echo SocialManager::show_social_menu('home', null, api_get_user_id(), false, $show_delete_account_button);
-        echo '</div>';
-        echo '<div class="col-md-9">';
-        $form->display();
-    echo '</div>';
+    SocialManager::setSocialUserBlock($tpl, api_get_user_id(), 'home');
+    $tpl->assign('social_menu_block', SocialManager::show_social_menu('home', null, api_get_user_id(), false, $show_delete_account_button));
+    $tpl->assign('social_right_content', $form->returnForm());
+    $social_layout = $tpl->get_template('social/inbox.tpl');
+    $tpl->display($social_layout);
 } else {
     // Style position:absolute has been removed for Opera-compatibility.
-    echo '<div id="image-message-container" style="float:right;display:inline;padding:3px;width:230px;" >';
+    $imageToShow = '<div id="image-message-container" style="float:right;display:inline;padding:3px;width:230px;" >';
 
     if ($image == 'unknown.jpg') {
-        echo '<img '.$img_attributes.' />';
+        $imageToShow .= '<img '.$img_attributes.' />';
     } else {
-        echo '<input type="image" '.$img_attributes.' onclick="javascript: return show_image(\''.$url_big_image.'\',\''.$big_image_width.'\',\''.$big_image_height.'\');"/>';
+        $imageToShow .= '<input type="image" '.$img_attributes.' onclick="javascript: return show_image(\''.$url_big_image.'\',\''.$big_image_width.'\',\''.$big_image_height.'\');"/>';
     }
-    echo '</div>';
-    $form->display();
+    $imageToShow .= '</div>';
+
+    $content = $imageToShow.$form->returnForm();
+
+    $tpl->assign('content', $form->returnForm());
+    $tpl->display_one_col_template();
 }
-Display :: display_footer();

+ 2 - 2
main/calendar/agenda_list.php

@@ -37,8 +37,8 @@ if (!empty($GLOBALS['_cid']) && $GLOBALS['_cid'] != -1) {
     // Agenda is out of the course tool (e.g personal agenda)
     $url = false;
     foreach ($events as &$event) {
-        $event['url'] = api_get_self() . '?cid=' . $event['course_id'] .
-        '&type=' . $event['type'];
+        $courseId = isset($event['course_id']) ? $event['course_id'] : '';
+        $event['url'] = api_get_self().'?cid='.$courseId.'&type='.$event['type'];
     }
 }
 

+ 3 - 3
main/css/base.css

@@ -7,7 +7,7 @@
 /* when doing a var_dump*/
 
 pre {
-    margin-top:40px;
+    margin-top:50px !important;
 }
 html,body{
   height: 100%;
@@ -2396,7 +2396,7 @@ div.admin_section h4 {
 }
 
 #question_list .header_operations {
-    height:40px;
+    height:45px;
     margin-bottom:5px;
     clear: both;
 }
@@ -5580,4 +5580,4 @@ ul.holder li.bit-box a.closebutton{
   #learning_path_main{
     margin-top: 5px;
   }
-}
+}

+ 1 - 5
main/css/chamilo/default.css

@@ -283,11 +283,7 @@ footer a{
     border: 1px solid #ddd !important;
   }
 }
-@font-face {
-  font-family: 'Glyphicons Halflings';
-  src: url('../fonts/glyphicons-halflings-regular.eot');
-  src: url('../fonts/glyphicons-halflings-regular.eot?#iefix') format('embedded-opentype'), url('../fonts/glyphicons-halflings-regular.woff2') format('woff2'), url('../fonts/glyphicons-halflings-regular.woff') format('woff'), url('../fonts/glyphicons-halflings-regular.ttf') format('truetype'), url('../fonts/glyphicons-halflings-regular.svg#glyphicons_halflingsregular') format('svg');
-}
+
 .glyphicon {
   position: relative;
   top: 1px;

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

@@ -1851,7 +1851,7 @@ class Exercise
                 if ($this->type == ONE_PER_PAGE) {
                     if ($questionNum != 1) {
                         $prev_question = $questionNum - 2;
-                        $all_button .= '<a href="javascript://" class="btn" onclick="previous_question_and_save('.$prev_question.', '.$question_id.' ); ">'.get_lang('PreviousQuestion').'</a>';
+                        $all_button .= '<a href="javascript://" class="btn btn-default" onclick="previous_question_and_save('.$prev_question.', '.$question_id.' ); ">'.get_lang('PreviousQuestion').'</a>';
                     }
 
                     //Next question

+ 17 - 9
main/exercice/question_list_admin.inc.php

@@ -150,7 +150,6 @@ if (!$inATest) {
     echo "</table>";
     echo "</div>";
 
-
     echo '<div id="question_list">';
     if ($nbrQuestions) {
         //Always getting list from DB
@@ -158,10 +157,10 @@ if (!$inATest) {
 
         // Style for columns
         $styleQuestion = "width:50%; float:left;";
-        $styleType = "width:4%; float:left; padding-top:4px; text-align:center;";
-        $styleCat = "width:22%; float:left; padding-top:8px; text-align:center;";
-        $styleLevel = "width:6%; float:left; padding-top:8px; text-align:center;";
-        $styleScore = "width:4%; float:left; padding-top:8px; text-align:center;";
+        $styleType = "width:4%; float:left; text-align:center;";
+        $styleCat = "width:22%; float:left; text-align:center;";
+        $styleLevel = "width:6%; float:left; text-align:center;";
+        $styleScore = "width:4%; float:left; text-align:center;";
 
         if (is_array($questionList)) {
             foreach ($questionList as $id) {
@@ -202,16 +201,24 @@ if (!$inATest) {
                 $edit_link   = Display::tag('div', $edit_link,   array('style'=>'float:left; padding:0px; margin:0px'));
                 $clone_link  = Display::tag('div', $clone_link,  array('style'=>'float:left; padding:0px; margin:0px'));
                 $delete_link = Display::tag('div', $delete_link, array('style'=>'float:left; padding:0px; margin:0px'));
-                $actions     = Display::tag('div', $edit_link.$clone_link.$delete_link, array('class'=>'edition','style'=>'width:100px; right:10px; margin-top: 0px; position: absolute; top: 10%;'));
+                $actions = Display::tag(
+                    'div',
+                    $edit_link.$clone_link.$delete_link,
+                    array('class'=>'edition','style'=>'width:100px; right:10px; margin-top: 8px; position: absolute; top: 10%;')
+                );
 
                 $title = Security::remove_XSS($objQuestionTmp->selectTitle());
-                $move = Display::return_icon('all_directions.png',get_lang('Move'), array('class'=>'moved', 'style'=>'margin-bottom:-0.5em;'));
+                $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 = "'.Security::remove_XSS($title).'">'.$move.' '.cut($title, 42).'</a>',
-                    array('style'=>$styleQuestion)
+                    array('style' => $styleQuestion)
                 );
 
                 // Question type
@@ -223,7 +230,8 @@ if (!$inATest) {
                 if (empty($txtQuestionCat)) {
                     $txtQuestionCat = "-";
                 }
-                $questionCategory = Display::tag('div', '<a href="#" style="padding:0px; margin:0px;" title="'.$txtQuestionCat.'">'.cut($txtQuestionCat, 42).'</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;

+ 6 - 6
main/gradebook/gradebook_add_user.php

@@ -21,7 +21,7 @@ $evaluation= Evaluation :: load($_GET['selecteval']);
 $newstudents = $evaluation[0]->get_not_subscribed_students();
 
 if (count($newstudents) == '0') {
-	header('Location: gradebook_view_result.php?nouser=&selecteval=' . Security::remove_XSS($_GET['selecteval']));
+	header('Location: gradebook_view_result.php?nouser=&selecteval=' . Security::remove_XSS($_GET['selecteval']).'&'.api_get_cidreq());
 	exit;
 }
 $add_user_form= new EvalForm(EvalForm :: TYPE_ADD_USERS_TO_EVAL,
@@ -50,7 +50,7 @@ if ( isset($_POST['submit_button']) ) {
 			$result->add();
 			}
 		}
-	header('Location: gradebook_view_result.php?adduser=&selecteval=' .Security::remove_XSS($_GET['selecteval']));
+	header('Location: gradebook_view_result.php?adduser=&selecteval=' .Security::remove_XSS($_GET['selecteval']).'&'.api_get_cidreq());
 	exit;
 	} elseif ($_POST['firstLetterUser']) {
 		$firstletter= $_POST['firstLetterUser'];
@@ -61,10 +61,10 @@ if ( isset($_POST['submit_button']) ) {
 }
 
 $interbreadcrumb[]= array ('url' => Security::remove_XSS($_SESSION['gradebook_dest']),'name' => get_lang('Gradebook'));
-$interbreadcrumb[]= array (
-	'url' => 'gradebook_view_result.php?selecteval=' .Security::remove_XSS($_GET['selecteval']),
-	'name' => get_lang('ViewResult'
-));
+$interbreadcrumb[]= array(
+	'url' => 'gradebook_view_result.php?selecteval=' .Security::remove_XSS($_GET['selecteval']).'&'.api_get_cidreq()
+	'name' => get_lang('ViewResult')
+);
 Display :: display_header(get_lang('AddUserToEval'));
 if (isset ($_GET['erroroneuser'])){
 	Display :: display_warning_message(get_lang('AtLeastOneUser'),false);

+ 6 - 6
main/gradebook/gradebook_edit_result.php

@@ -32,18 +32,18 @@ if ($edit_result_form->validate()) {
         }
         next($scores);
     }
-    header('Location: gradebook_view_result.php?selecteval='.$select_eval.'&editallresults=');
+    header('Location: gradebook_view_result.php?selecteval='.$select_eval.'&editallresults=&'.api_get_cidreq());
     exit;
 }
 
 $interbreadcrumb[] = array (
     'url' => $_SESSION['gradebook_dest'],
-    'name' => get_lang('Gradebook'
-    ));
+    'name' => get_lang('Gradebook')
+);
 $interbreadcrumb[]= array (
-    'url' => 'gradebook_view_result.php?selecteval='.$select_eval,
-    'name' => get_lang('ViewResult'
-    ));
+    'url' => 'gradebook_view_result.php?selecteval='.$select_eval.'&'.api_get_cidreq()
+    'name' => get_lang('ViewResult')
+);
 Display :: display_header(get_lang('EditResult'));
 DisplayGradebook :: display_header_result ($evaluation[0],null,0,0);
 echo $table;

+ 3 - 3
main/gradebook/gradebook_statistics.php

@@ -26,9 +26,9 @@ $interbreadcrumb[]= array (
 
 if (api_is_allowed_to_edit()) {
     $interbreadcrumb[]= array (
-        'url' => 'gradebook_view_result.php?selecteval=' . Security::remove_XSS($_GET['selecteval']),
-        'name' => get_lang('ViewResult'
-    ));
+        'url' => 'gradebook_view_result.php?selecteval=' . Security::remove_XSS($_GET['selecteval']).'&'.api_get_cidreq(),
+        'name' => get_lang('ViewResult')
+    );
 }
 $displayscore = ScoreDisplay :: instance();
 

+ 7 - 5
main/gradebook/gradebook_view_result.php

@@ -63,8 +63,7 @@ if (isset($_GET['editres'])) {
         $resultedit[0],
         'edit_result_form',
         null,
-        api_get_self() . '?editres=' . $resultedit[0]->get_id(
-        ) . '&selecteval=' . $select_eval_edit
+        api_get_self() . '?editres=' . $resultedit[0]->get_id() . '&selecteval=' . $select_eval_edit.'&'.api_get_cidreq()
     );
     if ($edit_res_form->validate()) {
 
@@ -76,18 +75,21 @@ if (isset($_GET['editres'])) {
         $result->set_user_id($values['hid_user_id']);
         $result->set_evaluation_id($select_eval_edit);
         $row_value = isset($values['score']) ? (float) $values['score'] : 0;
-        if ((!empty($row_value)) || ($row_value == 0)) {
+        if (!empty($row_value) || $row_value == 0) {
             $result->set_score(floatval(number_format($row_value, api_get_setting('gradebook_number_decimals'))));
         }
         $result->save();
         unset($result);
-        header('Location: gradebook_view_result.php?selecteval=' . $select_eval_edit . '&editresmessage=');
+        header('Location: gradebook_view_result.php?selecteval=' . $select_eval_edit . '&editresmessage=&'.api_get_cidreq());
         exit;
     }
 }
 $file_type = null;
 if (isset($_GET['import'])) {
-    $interbreadcrumb[] = array('url' => 'gradebook_view_result.php?selecteval=' . Security::remove_XSS($_GET['selecteval']), 'name' => get_lang('ViewResult'));
+    $interbreadcrumb[] = array(
+        'url' => 'gradebook_view_result.php?selecteval=' . Security::remove_XSS($_GET['selecteval']).'&'.api_get_cidreq(),
+        'name' => get_lang('ViewResult')
+    );
     $import_result_form = new DataForm(
         DataForm :: TYPE_IMPORT,
         'import_result_form',

+ 1 - 1
main/gradebook/lib/GradebookUtils.php

@@ -292,7 +292,7 @@ class GradebookUtils
             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_eval.php?editeval=' . $eval->get_id() . ' &amp;cidReq=' . $eval->get_course_code() . '&id_session='.$eval->getSessionId(). '">' .
+                $modify_icons = '<a href="gradebook_edit_eval.php?editeval=' . $eval->get_id() . '&cidReq=' . $eval->get_course_code() . '&id_session='.$eval->getSessionId(). '">' .
                     Display::return_icon('edit.png', get_lang('Modify'), '', ICON_SIZE_SMALL) . '</a>';
             }
 

+ 3 - 0
main/gradebook/lib/be/result.class.php

@@ -64,6 +64,9 @@ class Result
         $this->created_at = $creation_date;
     }
 
+    /**
+     * @param float $score
+     */
     public function set_score($score)
     {
         $this->score = $score;

+ 209 - 205
main/gradebook/lib/fe/flatviewtable.class.php

@@ -84,231 +84,235 @@ class FlatViewTable extends SortableTable
     }
 
     /**
-     *
+     * Display gradebook graphs
      */
     public function display_graph_by_resource()
     {
         $headerName = $this->datagen->get_header_names();
         $total_users = $this->datagen->get_total_users_count();
 
-        if ($this->datagen->get_total_items_count() > 0 && $total_users > 0) {
-            //Removing first name
-            array_shift($headerName);
-            //Removing last name
-            array_shift($headerName);
+        $displayscore = ScoreDisplay::instance();
+        $customdisplays = $displayscore->get_custom_score_display_settings();
 
-            $displayscore = ScoreDisplay::instance();
-            $customdisplays = $displayscore->get_custom_score_display_settings();
+        if (empty($customdisplays)) {
+            echo get_lang('ToViewGraphScoreRuleMustBeEnabled');
+            return '';
+        }
 
-            if (is_array($customdisplays) && count(($customdisplays))) {
+        $user_results = $this->datagen->get_data_to_graph2(false);
 
-                $user_results = $this->datagen->get_data_to_graph2(false);
-                $pre_result = $new_result = array();
-                foreach ($user_results as $result) {
-                    for ($i = 0; $i < count($headerName); $i++) {
-                        if (isset($result[$i + 1])) {
-                            $pre_result[$i + 3][] = $result[$i + 1];
-                        }
-                    }
-                }
+        //if (empty($this->datagen->get_total_items_count()) || empty($total_users)) {
+        if (empty($user_results) || empty($total_users)) {
+
+            echo get_lang('NoResults');
+            return '';
+        }
 
-                $i = 0;
-                $show_draw = false;
-                $resource_list = array();
-                $pre_result2 = array();
+        // Removing first name
+        array_shift($headerName);
+        // Removing last name
+        array_shift($headerName);
 
-                foreach ($pre_result as $key => $res_array) {
-                    rsort($res_array);
-                    $pre_result2[] = $res_array;
+        $pre_result = $new_result = array();
+        foreach ($user_results as $result) {
+            for ($i = 0; $i < count($headerName); $i++) {
+                if (isset($result[$i + 1])) {
+                    $pre_result[$i + 3][] = $result[$i + 1];
                 }
+            }
+        }
+
+        $i = 0;
+        $show_draw = false;
+        $resource_list = array();
+        $pre_result2 = array();
 
-                //@todo when a display custom does not exist the order of the color does not match
-                //filling all the answer that are not responded with 0
-                rsort($customdisplays);
-
-                if ($total_users > 0) {
-                    foreach ($pre_result2 as $key => $res_array) {
-                        $key_list = array();
-                        foreach ($res_array as $user_result) {
-                            $userResult = isset($user_result[1]) ? $user_result[1] : null;
-                            if (!isset($resource_list[$key][$userResult])) {
-                                $resource_list[$key][$userResult] = 0;
-                            }
-                            $resource_list[$key][$userResult] += 1;
-                            $key_list[] = $userResult;
-                        }
-
-                        foreach ($customdisplays as $display) {
-                            if (!in_array($display['display'], $key_list))
-                                $resource_list[$key][$display['display']] = 0;
-                        }
-                        $i++;
+        foreach ($pre_result as $key => $res_array) {
+            rsort($res_array);
+            $pre_result2[] = $res_array;
+        }
+
+        //@todo when a display custom does not exist the order of the color does not match
+        //filling all the answer that are not responded with 0
+        rsort($customdisplays);
+
+        if ($total_users > 0) {
+            foreach ($pre_result2 as $key => $res_array) {
+                $key_list = array();
+                foreach ($res_array as $user_result) {
+                    $userResult = isset($user_result[1]) ? $user_result[1] : null;
+                    if (!isset($resource_list[$key][$userResult])) {
+                        $resource_list[$key][$userResult] = 0;
                     }
+                    $resource_list[$key][$userResult] += 1;
+                    $key_list[] = $userResult;
                 }
 
-                //fixing $resource_list
-                $max = 0;
-                $new_list = array();
-                foreach ($resource_list as $key => $value) {
-                    $new_value = array();
-
-                    foreach ($customdisplays as $item) {
-                        if ($value[$item['display']] > $max) {
-                            $max = $value[$item['display']];
-                        }
-                        $new_value[$item['display']] = strip_tags($value[$item['display']]);
-                    }
-                    $new_list[] = $new_value;
+                foreach ($customdisplays as $display) {
+                    if (!in_array($display['display'], $key_list))
+                        $resource_list[$key][$display['display']] = 0;
                 }
-                $resource_list = $new_list;
-
-                $i = 1;
-
-                foreach ($resource_list as $key => $resource) {
-                    // Reverse array, otherwise we get highest values first
-                    $resource = array_reverse($resource, true);
-
-                    $dataSet = new pData();
-                    $dataSet->addPoints($resource, 'Serie');
-                    $dataSet->addPoints(array_keys($resource), 'Labels');
-                    $dataSet->setSerieDescription('Labels', strip_tags($headerName[$i - 1]));
-                    $dataSet->setAbscissa('Labels');
-                    $dataSet->setAbscissaName(get_lang('GradebookSkillsRanking'));
-                    $dataSet->setAxisName(0, get_lang('Students'));
-                    $palette = array(
-                        '0' => array('R' => 186, 'G' => 206, 'B' => 151, 'Alpha' => 100),
-                        '1' => array('R' => 210, 'G' => 148, 'B' => 147, 'Alpha' => 100),
-                        '2' => array('R' => 148, 'G' => 170, 'B' => 208, 'Alpha' => 100),
-                        '3' => array('R' => 221, 'G' => 133, 'B' => 61, 'Alpha' => 100),
-                        '4' => array('R' => 65, 'G' => 153, 'B' => 176, 'Alpha' => 100),
-                        '5' => array('R' => 114, 'G' => 88, 'B' => 144, 'Alpha' => 100),
-                        '6' => array('R' => 138, 'G' => 166, 'B' => 78, 'Alpha' => 100),
-                        '7' => array('R' => 171, 'G' => 70, 'B' => 67, 'Alpha' => 100),
-                        '8' => array('R' => 69, 'G' => 115, 'B' => 168, 'Alpha' => 100),
-                    );
-                    // Cache definition
-                    $cachePath = api_get_path(SYS_ARCHIVE_PATH);
-                    $myCache = new pCache(array('CacheFolder' => substr($cachePath, 0, strlen($cachePath) - 1)));
-                    $chartHash = $myCache->getHash($dataSet);
-                    if ($myCache->isInCache($chartHash)) {
-                        $imgPath = api_get_path(SYS_ARCHIVE_PATH) . $chartHash;
-                        $myCache->saveFromCache($chartHash, $imgPath);
-                        $imgPath = api_get_path(WEB_ARCHIVE_PATH) . $chartHash;
-                    } else {
-                        /* Create the pChart object */
-                        $widthSize = 480;
-                        $heightSize = 250;
-
-                        $myPicture = new pImage($widthSize, $heightSize, $dataSet);
-
-                        /* Turn of Antialiasing */
-                        $myPicture->Antialias = false;
-
-                        /* Add a border to the picture */
-                        $myPicture->drawRectangle(
-                            0,
-                            0,
-                            $widthSize - 1,
-                            $heightSize - 1,
-                            array(
-                                'R' => 0,
-                                'G' => 0,
-                                'B' => 0
-                            )
-                        );
-
-                        /* Set the default font */
-                        $myPicture->setFontProperties(
-                            array(
-                                'FontName' => api_get_path(SYS_FONTS_PATH) . 'opensans/OpenSans-Regular.ttf',
-                                'FontSize' => 10
-                            )
-                        );
-
-                        /* Write the chart title */
-                        $myPicture->drawText(
-                            250,
-                            30,
-                            strip_tags($headerName[$i - 1]),
-                            array(
-                                'FontSize' => 12,
-                                'Align' => TEXT_ALIGN_BOTTOMMIDDLE
-                            )
-                        );
-
-                        /* Define the chart area */
-                        $myPicture->setGraphArea(50, 40, $widthSize - 20, $heightSize - 50);
-
-                        /* Draw the scale */
-                        $scaleSettings = array(
-                            'GridR' => 200,
-                            'GridG' => 200,
-                            'GridB' => 200,
-                            'DrawSubTicks' => true,
-                            'CycleBackground' => true,
-                            'Mode' => SCALE_MODE_START0
-                        );
-                        $myPicture->drawScale($scaleSettings);
-
-                        /* Turn on shadow computing */
-                        $myPicture->setShadow(
-                            true,
-                            array(
-                                'X' => 1,
-                                'Y' => 1,
-                                'R' => 0,
-                                'G' => 0,
-                                'B' => 0,
-                                'Alpha' => 10
-                            )
-                        );
-
-                        /* Draw the chart */
-                        $myPicture->setShadow(
-                            true,
-                            array(
-                                'X' => 1,
-                                'Y' => 1,
-                                'R' => 0,
-                                'G' => 0,
-                                'B' => 0,
-                                'Alpha' => 10
-                            )
-                        );
-                        $settings = array(
-                            'OverrideColors' => $palette,
-                            'Gradient' => false,
-                            'GradientMode' => GRADIENT_SIMPLE,
-                            'DisplayPos' => LABEL_POS_TOP,
-                            'DisplayValues' => true,
-                            'DisplayR' => 0,
-                            'DisplayG' => 0,
-                            'DisplayB' => 0,
-                            'DisplayShadow' => true,
-                            'Surrounding' => 10,
-                        );
-                        $myPicture->drawBarChart($settings);
-
-                        /* Render the picture (choose the best way) */
-
-                        $myCache->writeToCache($chartHash, $myPicture);
-                        $imgPath = api_get_path(SYS_ARCHIVE_PATH) . $chartHash;
-                        $myCache->saveFromCache($chartHash, $imgPath);
-                        $imgPath = api_get_path(WEB_ARCHIVE_PATH) . $chartHash;
-                    }
-                    echo '<img src="' . $imgPath . '" >';
-                    if ($i % 2 == 0 && $i != 0) {
-                        echo '<br /><br />';
-                    } else {
-                        echo '&nbsp;&nbsp;&nbsp;';
-                    }
-                    $i++;
+                $i++;
+            }
+        }
+
+        //fixing $resource_list
+        $max = 0;
+        $new_list = array();
+        foreach ($resource_list as $key => $value) {
+            $new_value = array();
+
+            foreach ($customdisplays as $item) {
+                if ($value[$item['display']] > $max) {
+                    $max = $value[$item['display']];
                 }
+                $new_value[$item['display']] = strip_tags($value[$item['display']]);
+            }
+            $new_list[] = $new_value;
+        }
+        $resource_list = $new_list;
+
+        $i = 1;
+
+        foreach ($resource_list as $key => $resource) {
+            // Reverse array, otherwise we get highest values first
+            $resource = array_reverse($resource, true);
+
+            $dataSet = new pData();
+            $dataSet->addPoints($resource, 'Serie');
+            $dataSet->addPoints(array_keys($resource), 'Labels');
+            $dataSet->setSerieDescription('Labels', strip_tags($headerName[$i - 1]));
+            $dataSet->setAbscissa('Labels');
+            $dataSet->setAbscissaName(get_lang('GradebookSkillsRanking'));
+            $dataSet->setAxisName(0, get_lang('Students'));
+            $palette = array(
+                '0' => array('R' => 186, 'G' => 206, 'B' => 151, 'Alpha' => 100),
+                '1' => array('R' => 210, 'G' => 148, 'B' => 147, 'Alpha' => 100),
+                '2' => array('R' => 148, 'G' => 170, 'B' => 208, 'Alpha' => 100),
+                '3' => array('R' => 221, 'G' => 133, 'B' => 61, 'Alpha' => 100),
+                '4' => array('R' => 65, 'G' => 153, 'B' => 176, 'Alpha' => 100),
+                '5' => array('R' => 114, 'G' => 88, 'B' => 144, 'Alpha' => 100),
+                '6' => array('R' => 138, 'G' => 166, 'B' => 78, 'Alpha' => 100),
+                '7' => array('R' => 171, 'G' => 70, 'B' => 67, 'Alpha' => 100),
+                '8' => array('R' => 69, 'G' => 115, 'B' => 168, 'Alpha' => 100),
+            );
+            // Cache definition
+            $cachePath = api_get_path(SYS_ARCHIVE_PATH);
+            $myCache = new pCache(array('CacheFolder' => substr($cachePath, 0, strlen($cachePath) - 1)));
+            $chartHash = $myCache->getHash($dataSet);
+            if ($myCache->isInCache($chartHash)) {
+                $imgPath = api_get_path(SYS_ARCHIVE_PATH) . $chartHash;
+                $myCache->saveFromCache($chartHash, $imgPath);
+                $imgPath = api_get_path(WEB_ARCHIVE_PATH) . $chartHash;
             } else {
-                echo get_lang('ToViewGraphScoreRuleMustBeEnabled');
+                /* Create the pChart object */
+                $widthSize = 480;
+                $heightSize = 250;
+
+                $myPicture = new pImage($widthSize, $heightSize, $dataSet);
+
+                /* Turn of Antialiasing */
+                $myPicture->Antialias = false;
+
+                /* Add a border to the picture */
+                $myPicture->drawRectangle(
+                    0,
+                    0,
+                    $widthSize - 1,
+                    $heightSize - 1,
+                    array(
+                        'R' => 0,
+                        'G' => 0,
+                        'B' => 0
+                    )
+                );
+
+                /* Set the default font */
+                $myPicture->setFontProperties(
+                    array(
+                        'FontName' => api_get_path(SYS_FONTS_PATH) . 'opensans/OpenSans-Regular.ttf',
+                        'FontSize' => 10
+                    )
+                );
+
+                /* Write the chart title */
+                $myPicture->drawText(
+                    250,
+                    30,
+                    strip_tags($headerName[$i - 1]),
+                    array(
+                        'FontSize' => 12,
+                        'Align' => TEXT_ALIGN_BOTTOMMIDDLE
+                    )
+                );
+
+                /* Define the chart area */
+                $myPicture->setGraphArea(50, 40, $widthSize - 20, $heightSize - 50);
+
+                /* Draw the scale */
+                $scaleSettings = array(
+                    'GridR' => 200,
+                    'GridG' => 200,
+                    'GridB' => 200,
+                    'DrawSubTicks' => true,
+                    'CycleBackground' => true,
+                    'Mode' => SCALE_MODE_START0
+                );
+                $myPicture->drawScale($scaleSettings);
+
+                /* Turn on shadow computing */
+                $myPicture->setShadow(
+                    true,
+                    array(
+                        'X' => 1,
+                        'Y' => 1,
+                        'R' => 0,
+                        'G' => 0,
+                        'B' => 0,
+                        'Alpha' => 10
+                    )
+                );
+
+                /* Draw the chart */
+                $myPicture->setShadow(
+                    true,
+                    array(
+                        'X' => 1,
+                        'Y' => 1,
+                        'R' => 0,
+                        'G' => 0,
+                        'B' => 0,
+                        'Alpha' => 10
+                    )
+                );
+                $settings = array(
+                    'OverrideColors' => $palette,
+                    'Gradient' => false,
+                    'GradientMode' => GRADIENT_SIMPLE,
+                    'DisplayPos' => LABEL_POS_TOP,
+                    'DisplayValues' => true,
+                    'DisplayR' => 0,
+                    'DisplayG' => 0,
+                    'DisplayB' => 0,
+                    'DisplayShadow' => true,
+                    'Surrounding' => 10,
+                );
+                $myPicture->drawBarChart($settings);
+
+                /* Render the picture (choose the best way) */
+
+                $myCache->writeToCache($chartHash, $myPicture);
+                $imgPath = api_get_path(SYS_ARCHIVE_PATH) . $chartHash;
+                $myCache->saveFromCache($chartHash, $imgPath);
+                $imgPath = api_get_path(WEB_ARCHIVE_PATH) . $chartHash;
             }
-        } else {
-            echo get_lang('NoResults');
+            echo '<img src="' . $imgPath . '" >';
+            if ($i % 2 == 0 && $i != 0) {
+                echo '<br /><br />';
+            } else {
+                echo '&nbsp;&nbsp;&nbsp;';
+            }
+            $i++;
         }
     }
 

+ 8 - 4
main/gradebook/lib/fe/resulttable.class.php

@@ -137,12 +137,16 @@ class ResultTable extends SortableTable
 		return $sortable_data;
 	}
 
-	private function build_edit_column ($item) {
+	private function build_edit_column ($item)
+	{
 		$status=CourseManager::get_user_in_course_status(api_get_user_id(), api_get_course_id());
 		$locked_status = $this->evaluation->get_locked();
-		if (api_is_allowed_to_edit(null, true) && $locked_status == 0) {//api_is_course_admin()
-			$edit_column = '<a href="' . api_get_self() . '?editres=' . $item['result_id'] . '&selecteval=' . $this->evaluation->get_id() . '">'.Display::return_icon('edit.png', get_lang('Modify'),'','22').'</a>';
-			$edit_column .= ' <a href="' . api_get_self() . '?delete_mark=' . $item['result_id'] . '&selecteval=' . $this->evaluation->get_id() . '">'.Display::return_icon('delete.png', get_lang('Delete'),'','22').'</a>';
+		if (api_is_allowed_to_edit(null, true) && $locked_status == 0) {
+			//api_is_course_admin()
+			$edit_column = '<a href="' . api_get_self() . '?editres=' . $item['result_id'] . '&selecteval=' . $this->evaluation->get_id().'&'.api_get_cidreq().'">'.
+				Display::return_icon('edit.png', get_lang('Modify'),'','22').'</a>';
+			$edit_column .= ' <a href="' . api_get_self() . '?delete_mark=' . $item['result_id'] . '&selecteval=' . $this->evaluation->get_id().'&'.api_get_cidreq().'">'.
+				Display::return_icon('delete.png', get_lang('Delete'),'','22').'</a>';
 		}
 		if ($this->evaluation->get_course_code() == null) {
 			$edit_column.= '&nbsp;<a href="' . api_get_self() . '?resultdelete=' . $item['result_id'] . '&selecteval=' . $this->evaluation->get_id() . '" onclick="return confirmationuser();">

+ 41 - 15
main/inc/lib/AnnouncementManager.php

@@ -423,8 +423,15 @@ class AnnouncementManager
      * @param string $file_comment
      * @return bool|int
      */
-    public static function add_group_announcement($emailTitle, $newContent, $to, $to_users, $file = array(), $file_comment = '', $sendToUsersInSession = false)
-    {
+    public static function add_group_announcement(
+        $emailTitle,
+        $newContent,
+        $to,
+        $to_users,
+        $file = array(),
+        $file_comment = '',
+        $sendToUsersInSession = false
+    ) {
         $_course = api_get_course_info();
 
         // Database definitions
@@ -457,14 +464,22 @@ class AnnouncementManager
             self::add_announcement_attachment_file($last_id, $file_comment, $file);
         }
 
-        // store in item_property (first the groups, then the users
+        // Store in item_property (first the groups, then the users
 
-        if (!isset($to_users)) { // !isset($to): when no user is selected we send it to everyone
+        if (!isset($to_users)) {
+            // when no user is selected we send it to everyone
             $send_to = CourseManager::separateUsersGroups($to);
             // storing the selected groups
             if (is_array($send_to['groups'])) {
                 foreach ($send_to['groups'] as $group) {
-                    api_item_property_update($_course, TOOL_ANNOUNCEMENT, $last_id, "AnnouncementAdded", api_get_user_id(), $group);
+                    api_item_property_update(
+                        $_course,
+                        TOOL_ANNOUNCEMENT,
+                        $last_id,
+                        "AnnouncementAdded",
+                        api_get_user_id(),
+                        $group
+                    );
                 }
             }
         } else {
@@ -472,7 +487,15 @@ class AnnouncementManager
             // storing the selected users
             if (is_array($to_users)) {
                 foreach ($to_users as $user) {
-                    api_item_property_update($_course, TOOL_ANNOUNCEMENT, $last_id, "AnnouncementAdded", api_get_user_id(), '', $user);
+                    api_item_property_update(
+                        $_course,
+                        TOOL_ANNOUNCEMENT,
+                        $last_id,
+                        "AnnouncementAdded",
+                        api_get_user_id(),
+                        '',
+                        $user
+                    );
                 }
             }
         }
@@ -1297,7 +1320,9 @@ class AnnouncementManager
         ) {
             // A.1. you are a course admin with a USER filter
             // => see only the messages of this specific user + the messages of the group (s)he is member of.
-            if (!empty($user_id)) {
+
+            //if (!empty($user_id)) {
+            if (0) {
                 if (is_array($group_memberships) && count($group_memberships) > 0 ) {
                     $sql = "SELECT announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.insert_date
                             FROM $tbl_announcement announcement, $tbl_item_property ip
@@ -1306,11 +1331,14 @@ class AnnouncementManager
                                 ip.c_id = $course_id AND
                                 announcement.id = ip.ref AND
                                 ip.tool = 'announcement' AND
-                                (ip.to_user_id = $user_id OR ip.to_group_id IS NULL OR ip.to_group_id IN (0, ".implode(", ", $group_memberships).") )
+                                (
+                                    ip.to_user_id = $user_id OR
+                                    ip.to_group_id IS NULL OR
+                                    ip.to_group_id IN (0, ".implode(", ", $group_memberships).")
+                                ) AND
+                                ip.visibility IN ('1', '0')
                                 $condition_session
-
                             ORDER BY display_order DESC";
-
                 } else {
                     $sql = "SELECT announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.insert_date
                             FROM $tbl_announcement announcement, $tbl_item_property ip
@@ -1320,12 +1348,11 @@ class AnnouncementManager
                                 announcement.id = ip.ref AND
                                 ip.tool ='announcement' AND
                                 (ip.to_user_id = $user_id OR ip.to_group_id='0' OR ip.to_group_id IS NULL) AND
-                                ip.visibility='1'
+                                ip.visibility IN ('1', '0')
                             $condition_session
                             ORDER BY display_order DESC";
-
                 }
-            } elseif (api_get_group_id() != 0 ) {
+            } elseif ($group_id != 0) {
                 // A.2. you are a course admin with a GROUP filter
                 // => see only the messages of this specific group
                 $sql = "SELECT announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.insert_date
@@ -1345,7 +1372,6 @@ class AnnouncementManager
                 // A.3 you are a course admin without any group or user filter
                 // A.3.a you are a course admin without user or group filter but WITH studentview
                 // => see all the messages of all the users and groups without editing possibilities
-
                 if (isset($isStudentView) and $isStudentView=="true") {
                     $sql="SELECT
                         announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.insert_date
@@ -1376,7 +1402,7 @@ class AnnouncementManager
                 }
             }
         } else {
-            //STUDENT
+            // STUDENT
             if (is_array($group_memberships) && count($group_memberships)>0) {
                 if ($allowUserEditSetting && !api_is_anonymous()) {
                     if (api_get_group_id() == 0) {

+ 44 - 5
main/inc/lib/display.lib.php

@@ -2016,10 +2016,12 @@ class Display
      */
     public static function getProfileEditionLink($userId, $asAdmin = false)
     {
-        $editProfileUrl = api_get_path(WEB_CODE_PATH) . 'auth/profile.php';
+        $editProfileUrl = api_get_path(WEB_CODE_PATH).'auth/profile.php';
 
         if ($asAdmin) {
-            $editProfileUrl = api_get_path(WEB_CODE_PATH) . "admin/user_edit.php?user_id=" . intval($userId);
+            $editProfileUrl = api_get_path(
+                    WEB_CODE_PATH
+                )."admin/user_edit.php?user_id=".intval($userId);
         }
 
         if (api_get_setting('sso_authentication') === 'true') {
@@ -2028,18 +2030,55 @@ class Display
             $objSSO = null;
 
             if (!empty($subSSOClass)) {
-                require_once api_get_path(SYS_CODE_PATH) . "auth/sso/sso.$subSSOClass.class.php";
+                require_once api_get_path(
+                        SYS_CODE_PATH
+                    )."auth/sso/sso.$subSSOClass.class.php";
 
-                $subSSOClass = 'sso' . $subSSOClass;
+                $subSSOClass = 'sso'.$subSSOClass;
                 $objSSO = new $subSSOClass();
             } else {
                 $objSSO = new sso();
             }
 
-            $editProfileUrl = $objSSO->generateProfileEditingURL($userId, $asAdmin);
+            $editProfileUrl = $objSSO->generateProfileEditingURL(
+                $userId,
+                $asAdmin
+            );
         }
 
         return $editProfileUrl;
     }
 
+    /**
+     * @param string $content
+     * @param string $title
+     * @param string $footer
+     * @param string $style
+     * @return string
+     */
+    public static function panel($content, $title = '', $footer = '', $style = '')
+    {
+        $title = !empty($title) ? '<div class="panel-heading"><h3 class="panel-title">'.$title.'</h3></div>' : '';
+        $footer = !empty($footer) ? '<div class="panel-footer">'.$footer.'</div>' : '';
+
+        return '
+            <div class="panel panel-default">
+                '.$title.'
+                '.self::contentPanel($content).'
+                '.$footer.'
+            </div>'
+        ;
+    }
+
+    /**
+     * @param string $content
+     * @return string
+     */
+    public static function contentPanel($content)
+    {
+        return '<div class="panel-body">
+                '.$content.'
+                </div>';
+    }
+
 }

+ 4 - 1
main/inc/lib/events.lib.inc.php

@@ -643,7 +643,8 @@ class Event
         $event_value,
         $datetime = null,
         $user_id = null,
-        $course_code = null
+        $course_code = null,
+        $sessionId = 0
     ) {
         $TABLETRACK_DEFAULT = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DEFAULT);
 
@@ -673,6 +674,7 @@ class Event
 
         $event_value = Database::escape_string($event_value);
         $course_info = api_get_course_info($course_code);
+        $sessionId = empty($sessionId) ? api_get_session_id() : intval($sessionId);
 
         if (!empty($course_info)) {
             $course_id = $course_info['real_id'];
@@ -698,6 +700,7 @@ class Event
             'default_event_type' => $event_type,
             'default_value_type' => $event_value_type,
             'default_value' => $event_value,
+            'session_id' => $sessionId
         );
         Database::insert($TABLETRACK_DEFAULT, $params);
         return true;

+ 1 - 1
main/inc/lib/formvalidator/Element/DateRangePicker.php

@@ -9,7 +9,7 @@ class DateRangePicker extends HTML_QuickForm_text
     /**
     * Constructor
     */
-    public function DateRangePicker($elementName = null, $elementLabel = null, $attributes = null)
+    public function __construct($elementName = null, $elementLabel = null, $attributes = null)
     {
         if (!isset($attributes['id'])) {
             $attributes['id'] = $elementName;

+ 0 - 1
main/inc/lib/formvalidator/FormValidator.class.php

@@ -185,7 +185,6 @@ EOT;
         $this->layout = $layout;
     }
 
-
     /**
      * Adds a text field to the form.
      * A trim-filter is attached to the field.

+ 46 - 93
main/inc/lib/internationalization.lib.php

@@ -664,11 +664,8 @@ function api_strtotime($time, $timezone = null) {
  *
  * @link http://php.net/manual/en/function.strftime.php
  */
-function api_format_date($time, $format = null, $language = null) {
-
-    $system_timezone = date_default_timezone_get();
-    date_default_timezone_set(_api_get_timezone());
-
+function api_format_date($time, $format = null, $language = null)
+{
     if (is_string($time)) {
         $time = strtotime($time);
     }
@@ -683,116 +680,72 @@ function api_format_date($time, $format = null, $language = null) {
     if (is_int($format)) {
         switch ($format) {
             case DATE_FORMAT_ONLY_DAYNAME:
-                $date_format = get_lang('dateFormatOnlyDayName', '', $language);
-                if (INTL_INSTALLED) {
-        			$datetype = IntlDateFormatter::SHORT;
-        			$timetype = IntlDateFormatter::NONE;
-        		}
+                $datetype = IntlDateFormatter::SHORT;
+                $timetype = IntlDateFormatter::NONE;
                 break;
             case DATE_FORMAT_NUMBER_NO_YEAR:
-                $date_format = get_lang('dateFormatShortNumberNoYear', '', $language);
-        		if (INTL_INSTALLED) {
-        			$datetype = IntlDateFormatter::SHORT;
-        			$timetype = IntlDateFormatter::NONE;
-        		}
+                $datetype = IntlDateFormatter::SHORT;
+                $timetype = IntlDateFormatter::NONE;
+                break;
+            case DATE_FORMAT_NUMBER:
+                $datetype = IntlDateFormatter::SHORT;
+                $timetype = IntlDateFormatter::NONE;
                 break;
-        	case DATE_FORMAT_NUMBER:
-        		$date_format = get_lang('dateFormatShortNumber', '', $language);
-        		if (INTL_INSTALLED) {
-        			$datetype = IntlDateFormatter::SHORT;
-        			$timetype = IntlDateFormatter::NONE;
-        		}
-        		break;
             case TIME_NO_SEC_FORMAT:
-                $date_format = get_lang('timeNoSecFormat', '', $language);
-                if (INTL_INSTALLED) {
-                    $datetype = IntlDateFormatter::NONE;
-                    $timetype = IntlDateFormatter::SHORT;
-                }
+                $datetype = IntlDateFormatter::NONE;
+                $timetype = IntlDateFormatter::SHORT;
                 break;
             case DATE_FORMAT_SHORT:
-                $date_format = get_lang('dateFormatShort', '', $language);
-                if (INTL_INSTALLED) {
-                    $datetype = IntlDateFormatter::LONG;
-                    $timetype = IntlDateFormatter::NONE;
-                }
+                $datetype = IntlDateFormatter::LONG;
+                $timetype = IntlDateFormatter::NONE;
                 break;
             case DATE_FORMAT_LONG:
-                $date_format = get_lang('dateFormatLong', '', $language);
-                if (INTL_INSTALLED) {
-                    $datetype = IntlDateFormatter::FULL;
-                    $timetype = IntlDateFormatter::NONE;
-                }
+                $datetype = IntlDateFormatter::FULL;
+                $timetype = IntlDateFormatter::NONE;
                 break;
             case DATE_TIME_FORMAT_LONG:
-                $date_format = get_lang('dateTimeFormatLong', '', $language);
-                if (INTL_INSTALLED) {
-                    $datetype = IntlDateFormatter::FULL;
-                    $timetype = IntlDateFormatter::SHORT;
-                }
+                $datetype = IntlDateFormatter::FULL;
+                $timetype = IntlDateFormatter::SHORT;
                 break;
             case DATE_FORMAT_LONG_NO_DAY:
-                $date_format = get_lang('dateFormatLongNoDay', '', $language);
-                if (INTL_INSTALLED) {
-                    $datetype = IntlDateFormatter::FULL;
-                    $timetype = IntlDateFormatter::SHORT;
-                }
+                $datetype = IntlDateFormatter::FULL;
+                $timetype = IntlDateFormatter::SHORT;
                 break;
-			case DATE_TIME_FORMAT_SHORT:
-                $date_format = get_lang('dateTimeFormatShort', '', $language);
-                if (INTL_INSTALLED) {
-                    $datetype = IntlDateFormatter::FULL;
-                    $timetype = IntlDateFormatter::SHORT;
-                }
+            case DATE_TIME_FORMAT_SHORT:
+                $datetype = IntlDateFormatter::FULL;
+                $timetype = IntlDateFormatter::SHORT;
                 break;
-			case DATE_TIME_FORMAT_SHORT_TIME_FIRST:
-                $date_format = get_lang('dateTimeFormatShortTimeFirst', '', $language);
-                if (INTL_INSTALLED) {
-                    $datetype = IntlDateFormatter::FULL;
-                    $timetype = IntlDateFormatter::SHORT;
-                }
+            case DATE_TIME_FORMAT_SHORT_TIME_FIRST:
+                $datetype = IntlDateFormatter::FULL;
+                $timetype = IntlDateFormatter::SHORT;
                 break;
             case DATE_TIME_FORMAT_LONG_24H:
-                $date_format = get_lang('dateTimeFormatLong24H', '', $language);
-                if (INTL_INSTALLED) {
-                    $datetype = IntlDateFormatter::FULL;
-                    $timetype = IntlDateFormatter::SHORT;
-                }
+                $datetype = IntlDateFormatter::FULL;
+                $timetype = IntlDateFormatter::SHORT;
                 break;
             default:
-                $date_format = get_lang('dateTimeFormatLong', '', $language);
-                if (INTL_INSTALLED) {
-                    $datetype = IntlDateFormatter::FULL;
-                    $timetype = IntlDateFormatter::SHORT;
-                }
+                $datetype = IntlDateFormatter::FULL;
+                $timetype = IntlDateFormatter::SHORT;
         }
-    } else {
-        $date_format = $format;
     }
 
-    if (0) {
-        //if using PHP 5.3 format dates like: $dateFormatShortNumber, can't be used
-        //
-        // Use ICU
-        if (is_null($language)) {
-            $language = api_get_language_isocode();
-        }
-        $date_formatter = new IntlDateFormatter($language, $datetype, $timetype, date_default_timezone_get());
-        //$date_formatter->setPattern($date_format);
-        $formatted_date = api_to_system_encoding($date_formatter->format($time), 'UTF-8');
-
-    } else {
-        // We replace %a %A %b %B masks of date format with translated strings
-        $translated = &_api_get_day_month_names($language);
-        $date_format = str_replace(array('%A', '%a', '%B', '%b'),
-        array($translated['days_long'][(int)strftime('%w', $time )],
-            $translated['days_short'][(int)strftime('%w', $time)],
-            $translated['months_long'][(int)strftime('%m', $time) - 1],
-            $translated['months_short'][(int)strftime('%m', $time) - 1]),
-        $date_format);
-        $formatted_date = api_to_system_encoding(strftime($date_format, $time), 'UTF-8');
+    // Use ICU
+    if (is_null($language)) {
+        $language = api_get_language_isocode();
     }
-    date_default_timezone_set($system_timezone);
+
+    $date_formatter = new IntlDateFormatter(
+        $language,
+        $datetype,
+        $timetype,
+        date_default_timezone_get()
+    );
+
+    $formatted_date = api_to_system_encoding(
+        $date_formatter->format($time),
+        'UTF-8'
+    );
+
     return $formatted_date;
 }
 

+ 9 - 1
main/inc/lib/message.lib.php

@@ -1494,7 +1494,14 @@ class MessageManager
         }
 
         // display sortable table with messages of the current user
-        $table = new SortableTable('message_outbox', array('MessageManager', 'get_number_of_messages_sent'), array('MessageManager', 'get_message_data_sent'), 3, 20, 'DESC');
+        $table = new SortableTable(
+            'message_outbox',
+            array('MessageManager', 'get_number_of_messages_sent'),
+            array('MessageManager', 'get_message_data_sent'),
+            3,
+            20,
+            'DESC'
+        );
 
         $parameters['f'] = isset($_GET['f']) && $_GET['f'] == 'social' ? 'social' : null;
         $table->set_additional_parameters($parameters);
@@ -1506,6 +1513,7 @@ class MessageManager
 
         $table->set_form_actions(array('delete' => get_lang('DeleteSelectedMessages')));
         $html .= $table->return_table();
+
         return $html;
     }
 

+ 3 - 1
main/inc/lib/pear/HTML/QuickForm/advmultiselect.php

@@ -1013,9 +1013,11 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select
         if ($this->selectAllCheckBox) {
             $strHtml .= '
                     <div class="col-sm-8">
-                    <label class="checkbox" >'.get_lang('SelectAll').'
+
+                    <label >'.get_lang('SelectAll').'
                     <input type="checkbox" class="advmultiselect_checkbox" id="'.$selectId.'_select_all'.'">
                     </label>
+
                     </div>
             ';
         }

+ 7 - 3
main/inc/lib/pear/HTML/QuickForm/checkbox.php

@@ -134,9 +134,13 @@ class HTML_QuickForm_checkbox extends HTML_QuickForm_input
         } elseif ($this->_flagFrozen) {
             $label = $this->_text;
         } else {
-            $label = '<label class="checkbox '.$this->getAttribute('label-class').' ">' .
-                HTML_QuickForm_input::toHtml().$this->_text
-                . '</label>';
+            $label =
+                '<div class="checkbox">
+                <label '.$this->getAttribute('label-class').' ">' .
+                    HTML_QuickForm_input::toHtml().$this->_text.
+                '</label>
+                </div>
+                ';
 
             return $label;
         }

+ 13 - 12
main/inc/lib/social.lib.php

@@ -609,10 +609,10 @@ class SocialManager extends UserManager
                             <a href="'.api_get_path(WEB_CODE_PATH).'social/group_edit.php?id='.$group_id.'">'.
                     get_lang('EditGroup').'</a></div>';
             }
-
         } else {
             $img_array = UserManager::get_user_picture_path_by_id($user_id, 'web', true, true);
             $big_image = UserManager::get_picture_user($user_id, $img_array['file'], '', USER_IMAGE_SIZE_BIG);
+
             $big_image = $big_image['file'].'?'.uniqid();
             $normal_image = $img_array['dir'].$img_array['file'].'?'.uniqid();
 
@@ -625,6 +625,7 @@ class SocialManager extends UserManager
 
         }
         $html .= '</div>';
+
         return $html;
     }
 
@@ -1523,28 +1524,28 @@ class SocialManager extends UserManager
     /**
      * Generate the social block for a user
      * @param int $userId The user id
-     * @param string $groupBlock Optional. Highlight link possible values: group_add, home, messages, messages_inbox,
-     *                          messages_compose ,messages_outbox ,invitations, shared_profile, friends, groups search
+     * @param string $groupBlock Optional. Highlight link possible values:
+     * group_add, home, messages, messages_inbox, messages_compose,
+     * messages_outbox, invitations, shared_profile, friends, groups, search
      * @param int $groupId Optional. Group ID
      * @return string The HTML code with the social block
      */
-    public static function getSocialUserBlock($userId, $groupBlock = '', $groupId = 0)
+    public static function setSocialUserBlock($template, $userId, $groupBlock = '', $groupId = 0)
     {
-        $userInfo = api_get_user_info($userId, true);
-        $socialAvarBlock = SocialManager::show_social_avatar_block($groupBlock, $groupId, $userId);
+        if (api_get_setting('allow_social_tool') != 'true') {
+            return '';
+        }
+        $socialAvatarBlock = SocialManager::show_social_avatar_block($groupBlock, $groupId, $userId);
 
         $profileEditionLink = null;
-
         if (api_get_user_id() == $userId) {
             $profileEditionLink = Display::getProfileEditionLink($userId);
         }
 
-        $template = new Template();
+        $userInfo = api_get_user_info($userId, true);
         $template->assign('user', $userInfo);
-        $template->assign('socialAvatarBlock', $socialAvarBlock);
+        $template->assign('socialAvatarBlock', $socialAvatarBlock);
         $template->assign('profileEditionLink', $profileEditionLink);
-
-        return $template->fetch('default/social/user_block.tpl');
+        $template->assign('social_avatar_block', $template->fetch('default/social/user_block.tpl'));
     }
-
 }

+ 6 - 6
main/inc/lib/template.lib.php

@@ -404,11 +404,11 @@ class Template
      */
     private function set_user_parameters()
     {
-        $user_info               = array();
-        $user_info['logged']     = 0;
+        $user_info = array();
+        $user_info['logged'] = 0;
         $this->user_is_logged_in = false;
         if (api_user_is_login()) {
-            $user_info           = api_get_user_info(api_get_user_id());
+            $user_info = api_get_user_info(api_get_user_id(), true);
             $user_info['logged'] = 1;
 
             $user_info['is_admin'] = 0;
@@ -417,9 +417,9 @@ class Template
             }
 
             $user_info['messages_count'] = MessageManager::get_new_messages();
-            $this->user_is_logged_in     = true;
+            $this->user_is_logged_in = true;
         }
-        //Setting the $_u array that could be use in any template
+        // Setting the $_u array that could be use in any template
         $this->assign('_u', $user_info);
     }
 
@@ -607,10 +607,10 @@ class Template
         $bowerJsFiles = [
             'modernizr/modernizr.js',
             'jquery/dist/jquery.min.js',
+            'moment/min/moment-with-locales.min.js',
             'jquery-ui/jquery-ui.min.js',
             'bootstrap/dist/js/bootstrap.min.js',
             'ckeditor/ckeditor.js',
-            'moment/min/moment-with-locales.min.js',
             'bootstrap-daterangepicker/daterangepicker.js',
             'jquery-timeago/jquery.timeago.js',
             'mediaelement/build/mediaelement-and-player.min.js',

+ 10 - 8
main/inc/lib/usermanager.lib.php

@@ -1265,20 +1265,22 @@ class UserManager
         $picture_filename = trim($user['picture_uri']);
 
         if (api_get_setting('split_users_upload_directory') === 'true') {
-            /*if (!empty($picture_filename) or $preview) {
-                $dir = $base.'upload/users/'.substr((string) $user_id, 0, 1).'/'.$user_id.'/';
-            } else {
-                $dir = $base.'upload/users/'.$user_id.'/';
-            }*/
-            $dir = $base.'upload/users/'.substr((string) $user_id, 0, 1).'/'.$user_id.'/';
+            $userPath = 'upload/users/'.substr((string) $user_id, 0, 1).'/'.$user_id.'/';
+            $systemImagePath = api_get_path(SYS_CODE_PATH).$userPath;
+            $dir = $base.$userPath;
         } else {
-            $dir = $base.'upload/users/'.$user_id.'/';
+            $userPath = 'upload/users/'.$user_id.'/';
+            $systemImagePath = api_get_path(SYS_CODE_PATH).$userPath;
+            $dir = $base.$userPath;
         }
 
-        if (!$picture_filename || ($picture_filename && !file_exists($dir.$picture_filename))) {
+        if (empty($picture_filename) ||
+            (!empty($picture_filename) && !file_exists($systemImagePath.$picture_filename))
+        ) {
             if ($anonymous) {
                 return $noPicturePath;
             }
+
             if (api_get_configuration_value('gravatar_enabled')) {
                 $avatarSize = api_getimagesize($noPicturePath['dir'].$noPicturePath['file']);
                 $avatarSize = $avatarSize['width'] > $avatarSize['height'] ?

+ 0 - 1245
main/install/course.sql

@@ -1,1245 +0,0 @@
-
-CREATE TABLE c_announcement(
-  id int unsigned NOT NULL auto_increment,
-  c_id INT NOT NULL,
-  title text,
-  content mediumtext,
-  end_date date default NULL,
-  display_order mediumint NOT NULL default 0,
-  email_sent tinyint default 0,
-  session_id int default 0,
-  PRIMARY KEY (id, c_id)
-);
-
-ALTER TABLE c_announcement ADD INDEX ( session_id );
-
-CREATE TABLE c_announcement_attachment (
-    id int NOT NULL auto_increment,
-    c_id INT NOT NULL,
-    path varchar(255) NOT NULL,
-    comment text,
-    size int NOT NULL default 0,
-    announcement_id int NOT NULL,
-    filename varchar(255) NOT NULL,
-    PRIMARY KEY (id, c_id)
-);
-
-CREATE TABLE c_resource (
-    id int unsigned NOT NULL auto_increment,
-    c_id INT NOT NULL,
-    source_type varchar(50) default NULL,
-    source_id int unsigned default NULL,
-    resource_type varchar(50) default NULL,
-    resource_id int unsigned default NULL,
-    PRIMARY KEY (id, c_id)
-);
-
-CREATE TABLE c_userinfo_content (
-  id int unsigned NOT NULL auto_increment,
-  c_id INT NOT NULL,
-  user_id int unsigned NOT NULL,
-  definition_id int unsigned NOT NULL,
-  editor_ip varchar(39) default NULL,
-  edition_time datetime default NULL,
-  content text NOT NULL,
-  PRIMARY KEY (id, c_id),
-  KEY user_id (user_id)
-);
-
-CREATE TABLE c_userinfo_def (
-  id int unsigned NOT NULL auto_increment,
-  c_id INT NOT NULL,
-  title varchar(80) NOT NULL default '',
-  comment text,
-  line_count tinyint unsigned NOT NULL default 5,
-  rank tinyint unsigned NOT NULL default 0,
-  PRIMARY KEY (id, c_id)
-);
-
-CREATE TABLE c_forum_category(
- cat_id int NOT NULL auto_increment,
- c_id INT NOT NULL,
- cat_title varchar(255) NOT NULL default '',
- cat_comment text,
- cat_order int NOT NULL default 0,
- locked int NOT NULL default 0,
- session_id int unsigned NOT NULL default 0,
- PRIMARY KEY (cat_id, c_id)
-);
-
-ALTER TABLE c_forum_category ADD INDEX ( session_id );
-
-CREATE TABLE c_forum_forum(
-  forum_id int NOT NULL auto_increment,
-  c_id INT NOT NULL,
-  forum_title varchar(255) NOT NULL default '',
-  forum_comment text,
-  forum_threads int default 0,
-  forum_posts int default 0,
-  forum_last_post int default 0,
-  forum_category int default NULL,
-  allow_anonymous int default NULL,
-  allow_edit int default NULL,
-  approval_direct_post varchar(20) default NULL,
-  allow_attachments int default NULL,
-  allow_new_threads int default NULL,
-  default_view varchar(20) default NULL,
-  forum_of_group varchar(20) default NULL,
-  forum_group_public_private varchar(20) default 'public',
-  forum_order int default NULL,
-  locked int NOT NULL default 0,
-  session_id int NOT NULL default 0,
-  forum_image varchar(255) NOT NULL default '',
-  start_time datetime NOT NULL default '0000-00-00 00:00:00',
-  end_time datetime NOT NULL default '0000-00-00 00:00:00',
-  PRIMARY KEY (forum_id, c_id)
-);
-
-CREATE TABLE c_forum_thread  (
- thread_id int NOT NULL auto_increment,
- c_id INT NOT NULL,
- thread_title varchar(255) default NULL,
- forum_id int default NULL,
- thread_replies int default 0,
- thread_poster_id int default NULL,
- thread_poster_name varchar(100) default '',
- thread_views int default 0,
- thread_last_post int default NULL,
- thread_date datetime default '0000-00-00 00:00:00',
- thread_sticky tinyint unsigned default 0,
- locked int NOT NULL default 0,
- session_id int unsigned default NULL,
- thread_title_qualify varchar(255) default '',
- thread_qualify_max float(6,2) UNSIGNED NOT NULL default 0,
- thread_close_date datetime default '0000-00-00 00:00:00',
- thread_weight float(6,2) UNSIGNED NOT NULL default 0,
- PRIMARY KEY (thread_id, c_id)
-);
-
-ALTER TABLE c_forum_thread ADD INDEX idx_forum_thread_forum_id (forum_id);
-
-CREATE TABLE c_forum_post (
-    post_id int NOT NULL auto_increment,
-    c_id INT NOT NULL,
-    post_title varchar(250) default NULL,
-    post_text text,
-    thread_id int default 0,
-    forum_id int default 0,
-    poster_id int default 0,
-    poster_name varchar(100) default '',
-    post_date datetime default '0000-00-00 00:00:00',
-    post_notification tinyint default 0,
-    post_parent_id int default 0,
-    visible tinyint default 1,
-    PRIMARY KEY (post_id, c_id),
-    KEY poster_id (poster_id),
-    KEY forum_id (forum_id)
-);
-
-ALTER TABLE c_forum_post ADD INDEX idx_forum_post_thread_id (thread_id);
-ALTER TABLE c_forum_post ADD INDEX idx_forum_post_visible (visible);
-
-CREATE TABLE c_forum_mailcue  (
- id int NOT NULL auto_increment,
- c_id INT NOT NULL,
- user_id int default NULL,
- thread_id int default NULL,
- post_id int default NULL,
- PRIMARY KEY (id, c_id, thread_id, user_id, post_id )
-);
-
-CREATE TABLE  c_forum_attachment  (
-  id int NOT NULL auto_increment,
-  c_id INT NOT NULL,
-  path varchar(255) NOT NULL,
-  comment text,
-  size int NOT NULL default 0,
-  post_id int NOT NULL,
-  filename varchar(255) NOT NULL,
-  PRIMARY KEY (id, c_id)
-);
-
-CREATE TABLE c_forum_notification(
-    id int NOT NULL auto_increment,
-    c_id INT NOT NULL,
-    user_id int,
-    forum_id int,
-    thread_id int,
-    post_id int,
-    KEY user_id (user_id),
-    KEY forum_id (forum_id),
-    PRIMARY KEY (id, c_id, user_id, forum_id, thread_id, post_id )
-);
-
-CREATE TABLE c_forum_thread_qualify  (
-  id int unsigned AUTO_INCREMENT,
-  c_id INT NOT NULL,
-  user_id int unsigned NOT NULL,
-  thread_id int NOT NULL,
-  qualify float(6,2) NOT NULL default 0,
-  qualify_user_id int  default NULL,
-  qualify_time datetime default '0000-00-00 00:00:00',
-  session_id int  default NULL,
-  PRIMARY KEY (id, c_id)
-);
-
-ALTER TABLE c_forum_thread_qualify ADD INDEX (user_id, thread_id);
-
-CREATE TABLE c_forum_thread_qualify_log  (
-  id int unsigned AUTO_INCREMENT,
-  c_id INT NOT NULL,
-  user_id int unsigned NOT NULL,
-  thread_id int NOT NULL,
-  qualify float(6,2) NOT NULL default 0,
-  qualify_user_id int default NULL,
-  qualify_time datetime default '0000-00-00 00:00:00',
-  session_id int default NULL,
-  PRIMARY KEY (id, c_id)
-);
-
-ALTER TABLE c_forum_thread_qualify_log  ADD INDEX (user_id, thread_id);
-
-CREATE TABLE c_quiz (
-  id int unsigned NOT NULL auto_increment,
-  c_id INT NOT NULL,
-  title varchar(255) NOT NULL,
-  description text default NULL,
-  sound varchar(255) default NULL,
-  type tinyint unsigned NOT NULL default 1,
-  random int NOT NULL default 0,
-  random_answers tinyint unsigned NOT NULL default 0,
-  active tinyint NOT NULL default 0,
-  results_disabled INT UNSIGNED NOT NULL DEFAULT 0,
-  access_condition TEXT DEFAULT NULL,
-  max_attempt int NOT NULL default 0,
-  start_time datetime NOT NULL default '0000-00-00 00:00:00',
-  end_time datetime NOT NULL default '0000-00-00 00:00:00',
-  feedback_type int NOT NULL default 0,
-  expired_time int NOT NULL default '0',
-  session_id int default 0,
-  propagate_neg INT NOT NULL DEFAULT 0,
-  review_answers INT NOT NULL DEFAULT 0,
-  random_by_category INT NOT NULL DEFAULT 0,
-  text_when_finished TEXT default NULL,
-  display_category_name INT NOT NULL DEFAULT 1,
-  pass_percentage INT DEFAULT NULL,
-  PRIMARY KEY (id, c_id)
-);
-
-ALTER TABLE c_quiz  ADD INDEX ( session_id );
-
-CREATE TABLE c_quiz_question(
-  id int unsigned NOT NULL auto_increment,
-  question TEXT NOT NULL,
-  description text default NULL,
-  ponderation float(6,2) NOT NULL default 0,
-  position mediumint unsigned NOT NULL default 1,
-  type    tinyint unsigned NOT NULL default 2,
-  picture varchar(50) default NULL,
-  level   int unsigned NOT NULL default 0,
-  extra   varchar(255) default NULL,
-  question_code char(10) default '',
-  c_id INT NOT NULL,
-  PRIMARY KEY (id, c_id)
-);
-
-ALTER TABLE c_quiz_question  ADD INDEX (position);
-
-CREATE TABLE c_quiz_answer(
-  id int unsigned NOT NULL,
-  c_id INT NOT NULL,
-  id_auto int NOT NULL AUTO_INCREMENT,
-  question_id int unsigned NOT NULL,
-  answer text NOT NULL,
-  correct mediumint unsigned default NULL,
-  comment text default NULL,
-  ponderation float(6,2) NOT NULL default 0,
-  position mediumint unsigned NOT NULL default 1,
-  hotspot_coordinates text,
-  hotspot_type enum('square','circle','poly','delineation','oar') default NULL,
-  destination text NOT NULL,
-  answer_code char(10) default '',
-  PRIMARY KEY (id_auto, c_id)
-);
-
-CREATE TABLE c_quiz_question_option  (
-  id          int NOT NULL auto_increment,
-  c_id INT NOT NULL,
-  question_id int NOT NULL,
-  name        varchar(255),
-  position    int unsigned NOT NULL,
-  PRIMARY KEY (id, c_id)
-);
-
-CREATE TABLE c_quiz_rel_question  (
-  c_id INT NOT NULL,
-  question_id int unsigned NOT NULL,
-  exercice_id int unsigned NOT NULL,
-  question_order int unsigned NOT NULL default 1,
-  PRIMARY KEY (c_id, question_id, exercice_id)
-);
-
-CREATE TABLE c_quiz_question_category  (
-  id int NOT NULL AUTO_INCREMENT,
-  c_id INT NOT NULL,
-  title varchar(255) NOT NULL,
-  description text NOT NULL,
-  PRIMARY KEY (id, c_id)
-);
-
-CREATE TABLE c_quiz_question_rel_category  (
-  c_id INT NOT NULL,
-  question_id int NOT NULL,
-  category_id int NOT NULL,
-  PRIMARY KEY (c_id,question_id)
-);
-
-CREATE TABLE c_course_description(
-  id int UNSIGNED NOT NULL auto_increment,
-  c_id INT NOT NULL,
-  title VARCHAR(255),
-  content TEXT,
-  session_id int default 0,
-  description_type tinyint unsigned NOT NULL default 0,
-  progress INT NOT NULL default 0,
-  PRIMARY KEY (id, c_id)
-);
-
-ALTER TABLE c_course_description  ADD INDEX ( session_id );
-
-CREATE TABLE c_tool(
-  id int unsigned NOT NULL auto_increment,
-  c_id INT NOT NULL,
-  name varchar(255) NOT NULL,
-  link varchar(255) NOT NULL,
-  image varchar(255) default NULL,
-  visibility tinyint unsigned default 0,
-  admin varchar(255) default NULL,
-  address varchar(255) default NULL,
-  added_tool tinyint unsigned default 1,
-  target enum('_self','_blank') NOT NULL default '_self',
-  category varchar(20) not null default 'authoring',
-  session_id int default 0,
-  PRIMARY KEY (id, c_id)
-);
-
-ALTER TABLE c_tool ADD INDEX ( session_id );
-
-CREATE TABLE c_calendar_event(
-  id int unsigned NOT NULL auto_increment,
-  c_id INT NOT NULL,
-  title varchar(255) NOT NULL,
-  content text,
-  start_date datetime NOT NULL default '0000-00-00 00:00:00',
-  end_date datetime NOT NULL default '0000-00-00 00:00:00',
-  parent_event_id INT NULL,
-  session_id int unsigned NOT NULL default 0,
-  all_day INT NOT NULL DEFAULT 0,
-  PRIMARY KEY (id, c_id)
-);
-
-ALTER TABLE c_calendar_event ADD INDEX ( session_id );
-
-CREATE TABLE c_calendar_event_repeat(
-  c_id INT NOT NULL,
-  cal_id INT DEFAULT 0 NOT NULL,
-  cal_type VARCHAR(20),
-  cal_end INT,
-  cal_frequency INT DEFAULT 1,
-  cal_days CHAR(7),
-  PRIMARY KEY (c_id, cal_id)
-);
-
-CREATE TABLE c_calendar_event_repeat_not  (
-  c_id INT NOT NULL,
-  cal_id INT NOT NULL,
-  cal_date INT NOT NULL,
-  PRIMARY KEY (c_id, cal_id, cal_date )
-);
-
-CREATE TABLE  c_calendar_event_attachment  (
-  id int NOT NULL auto_increment,
-  c_id INT NOT NULL,
-  path varchar(255) NOT NULL,
-  comment text,
-  size int NOT NULL default 0,
-  agenda_id int NOT NULL,
-  filename varchar(255) NOT NULL,
-  PRIMARY KEY (id, c_id)
-);
-
-CREATE TABLE c_document (
-    id int unsigned NOT NULL auto_increment,
-    c_id INT NOT NULL,
-    path varchar(255) NOT NULL default '',
-    comment text,
-    title varchar(255) default NULL,
-    filetype set('file','folder') NOT NULL default 'file',
-    size int NOT NULL default 0,
-    readonly TINYINT UNSIGNED NOT NULL,
-    session_id int UNSIGNED NOT NULL default 0,
-    PRIMARY KEY (id, c_id)
-);
-
-CREATE TABLE c_student_publication  (
-  id int unsigned NOT NULL auto_increment,
-  c_id INT NOT NULL,
-  url varchar(255) default NULL,
-  title varchar(255) default NULL,
-  description text default NULL,
-  author varchar(255) default NULL,
-  active tinyint default NULL,
-  accepted tinyint default 0,
-  post_group_id int DEFAULT 0 NOT NULL,
-  sent_date datetime NOT NULL default '0000-00-00 00:00:00',
-  filetype set('file','folder') NOT NULL default 'file',
-  has_properties int UNSIGNED NOT NULL DEFAULT 0,
-  view_properties tinyint NULL,
-  qualification float(6,2) UNSIGNED NOT NULL DEFAULT 0,
-  date_of_qualification datetime NOT NULL default '0000-00-00 00:00:00',
-  parent_id INT UNSIGNED NOT NULL DEFAULT 0,
-  qualificator_id INT UNSIGNED NOT NULL DEFAULT 0,
-  weight float(6,2) UNSIGNED NOT NULL default 0,
-  session_id INT UNSIGNED NOT NULL default 0,
-  user_id INTEGER  NOT NULL,
-  allow_text_assignment INTEGER NOT NULL DEFAULT 0,
-  contains_file INTEGER NOT NULL DEFAULT 0,
-  PRIMARY KEY (id, c_id)
-);
-
-CREATE TABLE c_student_publication_assignment(
-  id int NOT NULL auto_increment,
-  c_id INT NOT NULL,
-  expires_on datetime NOT NULL default '0000-00-00 00:00:00',
-  ends_on datetime NOT NULL default '0000-00-00 00:00:00',
-  add_to_calendar tinyint NOT NULL,
-  enable_qualification tinyint NOT NULL,
-  publication_id int NOT NULL,
-  PRIMARY KEY (id, c_id)
-);
-
-ALTER TABLE c_student_publication  ADD INDEX ( session_id );
-
-CREATE TABLE c_link(
-  id int unsigned NOT NULL auto_increment,
-  c_id INT NOT NULL,
-  url TEXT NOT NULL,
-  title varchar(150) default NULL,
-  description text,
-  category_id int unsigned default NULL,
-  display_order int unsigned NOT NULL default 0,
-  on_homepage enum('0','1') NOT NULL default '0',
-  target char(10) default '_self',
-  session_id int default 0,
-  PRIMARY KEY (id, c_id)
-);
-
-ALTER TABLE c_link  ADD INDEX ( session_id );
-
-CREATE TABLE c_link_category (
-  id int unsigned NOT NULL auto_increment,
-  c_id INT NOT NULL,
-  category_title varchar(255) NOT NULL,
-  description text,
-  display_order mediumint unsigned NOT NULL default 0,
-  session_id int default 0,
-  PRIMARY KEY (id, c_id)
-);
-
-ALTER TABLE c_link_category  ADD INDEX ( session_id );
-
-CREATE TABLE c_wiki(
-  id int NOT NULL auto_increment,
-  c_id INT NOT NULL,
-  page_id int NOT NULL default 0,
-  reflink varchar(255) NOT NULL default 'index',
-  title varchar(255) NOT NULL,
-  content mediumtext NOT NULL,
-  user_id int NOT NULL default 0,
-  group_id int DEFAULT NULL,
-  dtime datetime NOT NULL default '0000-00-00 00:00:00',
-  addlock int NOT NULL default 1,
-  editlock int NOT NULL default 0,
-  visibility int NOT NULL default 1,
-  addlock_disc int NOT NULL default 1,
-  visibility_disc int NOT NULL default 1,
-  ratinglock_disc int NOT NULL default 1,
-  assignment int NOT NULL default 0,
-  comment text NOT NULL,
-  progress text NOT NULL,
-  score int NULL default 0,
-  version int default NULL,
-  is_editing int NOT NULL default 0,
-  time_edit datetime NOT NULL default '0000-00-00 00:00:00',
-  hits int default 0,
-  linksto text NOT NULL,
-  tag text NOT NULL,
-  user_ip varchar(39) NOT NULL,
-  session_id int default 0,
-  PRIMARY KEY (id, c_id),
-  KEY reflink (reflink),
-  KEY group_id (group_id),
-  KEY page_id (page_id),
-  KEY session_id (session_id)
-);
-
-CREATE TABLE c_wiki_conf  (
-  c_id INT NOT NULL,
-  page_id int NOT NULL default 0,
-  task text NOT NULL,
-  feedback1 text NOT NULL,
-  feedback2 text NOT NULL,
-  feedback3 text NOT NULL,
-  fprogress1 varchar(3) NOT NULL,
-  fprogress2 varchar(3) NOT NULL,
-  fprogress3 varchar(3) NOT NULL,
-  max_size int default NULL,
-  max_text int default NULL,
-  max_version int default NULL,
-  startdate_assig datetime NOT NULL default '0000-00-00 00:00:00',
-  enddate_assig datetime  NOT NULL default '0000-00-00 00:00:00',
-  delayedsubmit int NOT NULL default 0,
-  KEY page_id (page_id),
-  PRIMARY KEY  ( c_id, page_id )
-);
-
-CREATE TABLE c_wiki_discuss  (
-  id int NOT NULL auto_increment,
-  c_id INT NOT NULL,
-  publication_id int NOT NULL default 0,
-  userc_id int NOT NULL default 0,
-  comment text NOT NULL,
-  p_score varchar(255) default NULL,
-  dtime datetime NOT NULL default '0000-00-00 00:00:00',
-  PRIMARY KEY (id, c_id)
-);
-
-CREATE TABLE c_wiki_mailcue  (
-  c_id INT NOT NULL,
-  id int NOT NULL,
-  user_id int NOT NULL,
-  type text NOT NULL,
-  group_id int DEFAULT NULL,
-  session_id int default 0,
-  KEY (c_id, id),
-  PRIMARY KEY  ( c_id, id, user_id )
-);
-
-CREATE TABLE c_online_connected  (
-  c_id INT NOT NULL,
-  user_id int unsigned NOT NULL,
-  last_connection datetime NOT NULL default '0000-00-00 00:00:00',
-  PRIMARY KEY (c_id, user_id)
-);
-
-CREATE TABLE c_online_link (
-  id int unsigned NOT NULL auto_increment,
-  c_id INT NOT NULL,
-  name char(50) NOT NULL default '',
-  url char(100) NOT NULL,
-  PRIMARY KEY (id, c_id)
-);
-
-CREATE TABLE c_chat_connected (
-  id int unsigned NOT NULL auto_increment,
-  c_id INT NOT NULL,
-  user_id int unsigned NOT NULL default '0',
-  last_connection datetime NOT NULL default '0000-00-00 00:00:00',
-  session_id  INT NOT NULL default 0,
-  to_group_id INT NOT NULL default 0,
-  PRIMARY KEY  (id, c_id, user_id, last_connection)
-);
-
-ALTER TABLE c_chat_connected ADD INDEX char_connected_index(user_id, session_id, to_group_id);
-
-CREATE TABLE c_group_info(
-  id int unsigned NOT NULL auto_increment,
-  c_id INT NOT NULL,
-  name varchar(100) default NULL,
-  status tinyint DEFAULT 1,
-  category_id int unsigned NOT NULL default 0,
-  description text,
-  max_student int unsigned NOT NULL default 8,
-  doc_state tinyint unsigned NOT NULL default 1,
-  calendar_state tinyint unsigned NOT NULL default 0,
-  work_state tinyint unsigned NOT NULL default 0,
-  announcements_state tinyint unsigned NOT NULL default 0,
-  forum_state tinyint unsigned NOT NULL default 0,
-  wiki_state tinyint unsigned NOT NULL default 1,
-  chat_state tinyint unsigned NOT NULL default 1,
-  secret_directory varchar(255) default NULL,
-  self_registration_allowed tinyint unsigned NOT NULL default '0',
-  self_unregistration_allowed tinyint unsigned NOT NULL default '0',
-  session_id int unsigned NOT NULL default 0,
-  PRIMARY KEY (id, c_id)
-);
-
-ALTER TABLE c_group_info ADD INDEX ( session_id );
-
-CREATE TABLE c_group_category(
-  id int unsigned NOT NULL auto_increment,
-  c_id INT NOT NULL,
-  title varchar(255) NOT NULL default '',
-  description text NOT NULL,
-  doc_state tinyint unsigned NOT NULL default 1,
-  calendar_state tinyint unsigned NOT NULL default 1,
-  work_state tinyint unsigned NOT NULL default 1,
-  announcements_state tinyint unsigned NOT NULL default 1,
-  forum_state tinyint unsigned NOT NULL default 1,
-  wiki_state tinyint unsigned NOT NULL default 1,
-  chat_state tinyint unsigned NOT NULL default 1,
-  max_student int unsigned NOT NULL default 8,
-  self_reg_allowed tinyint unsigned NOT NULL default 0,
-  self_unreg_allowed tinyint unsigned NOT NULL default 0,
-  groups_per_user int unsigned NOT NULL default 0,
-  display_order int unsigned NOT NULL default 0,
-  PRIMARY KEY (id, c_id)
-);
-
-CREATE TABLE c_group_rel_user(
-  id int unsigned NOT NULL auto_increment,
-  c_id INT NOT NULL,
-  user_id int unsigned NOT NULL,
-  group_id int unsigned NOT NULL default 0,
-  status int NOT NULL default 0,
-  role char(50) NOT NULL,
-  PRIMARY KEY (id, c_id)
-);
-
-CREATE TABLE c_group_rel_tutor(
-  id int NOT NULL auto_increment,
-  c_id INT NOT NULL,
-  user_id int NOT NULL,
-  group_id int NOT NULL default 0,
-  PRIMARY KEY (id, c_id)
-);
-
-CREATE TABLE c_item_property(
-  id int NOT NULL auto_increment,
-  c_id INT NOT NULL,
-  tool varchar(100) NOT NULL default '',
-  insert_user_id int unsigned NOT NULL default '0',
-  insert_date datetime NOT NULL default '0000-00-00 00:00:00',
-  lastedit_date datetime NOT NULL default '0000-00-00 00:00:00',
-  ref int NOT NULL default '0',
-  lastedit_type varchar(100) NOT NULL default '',
-  lastedit_user_id int unsigned NOT NULL default '0',
-  to_group_id int unsigned default NULL,
-  to_user_id int unsigned default NULL,
-  visibility tinyint NOT NULL default '1',
-  start_visible datetime NOT NULL default '0000-00-00 00:00:00',
-  end_visible datetime NOT NULL default '0000-00-00 00:00:00',
-  id_session INT NOT NULL DEFAULT 0,
-  PRIMARY KEY (id, c_id)
-);
-
-ALTER TABLE c_item_property ADD INDEX idx_item_property_toolref (tool,ref);
-
-CREATE TABLE c_tool_intro(
-  id varchar(50) NOT NULL,
-  c_id INT NOT NULL,
-  intro_text MEDIUMTEXT NOT NULL,
-  session_id INT  NOT NULL DEFAULT 0,
-  PRIMARY KEY (id, c_id, session_id)
-);
-
-CREATE TABLE c_dropbox_file  (
-  id int unsigned NOT NULL auto_increment,
-  c_id INT NOT NULL,
-  uploader_id int unsigned NOT NULL default 0,
-  filename varchar(250) NOT NULL default '',
-  filesize int unsigned NOT NULL,
-  title varchar(250) default '',
-  description varchar(250) default '',
-  author varchar(250) default '',
-  upload_date datetime NOT NULL default '0000-00-00 00:00:00',
-  last_upload_date datetime NOT NULL default '0000-00-00 00:00:00',
-  cat_id int NOT NULL default 0,
-  session_id int UNSIGNED NOT NULL,
-  PRIMARY KEY (id, c_id),
-  UNIQUE KEY UN_filename (filename)
-);
-
-ALTER TABLE c_dropbox_file ADD INDEX ( session_id );
-
-CREATE TABLE c_dropbox_post  (
-  c_id INT NOT NULL,
-  file_id int unsigned NOT NULL,
-  dest_user_id int unsigned NOT NULL default 0,
-  feedback_date datetime NOT NULL default '0000-00-00 00:00:00',
-  feedback text default '',
-  cat_id int NOT NULL default 0,
-  session_id int UNSIGNED NOT NULL,
-  PRIMARY KEY (c_id, file_id, dest_user_id)
-);
-
-ALTER TABLE c_dropbox_post ADD INDEX ( session_id );
-
-CREATE TABLE c_dropbox_person  (
-  c_id INT NOT NULL,
-  file_id int unsigned NOT NULL,
-  user_id int unsigned NOT NULL default 0,
-  PRIMARY KEY (c_id, file_id, user_id)
-);
-
-CREATE TABLE c_dropbox_category  (
-  cat_id int NOT NULL auto_increment,
-  c_id INT NOT NULL,
-  cat_name text NOT NULL,
-  received tinyint unsigned NOT NULL default 0,
-  sent tinyint unsigned NOT NULL default 0,
-  user_id int NOT NULL default 0,
-  session_id int NOT NULL default 0,
-  PRIMARY KEY(cat_id, c_id)
-);
-
-ALTER TABLE c_dropbox_category ADD INDEX ( session_id );
-
-CREATE TABLE c_dropbox_feedback (
-  feedback_id int NOT NULL auto_increment,
-  c_id INT NOT NULL,
-  file_id int NOT NULL default 0,
-  author_user_id int NOT NULL default 0,
-  feedback text NOT NULL,
-  feedback_date datetime NOT NULL default '0000-00-00 00:00:00',
-  PRIMARY KEY  (feedback_id, c_id),
-  KEY file_id (file_id),
-  KEY author_user_id (author_user_id)
-);
-
-CREATE TABLE IF NOT EXISTS c_lp (
-  id             int unsigned        auto_increment,
-  c_id INT NOT NULL,
-  lp_type        int unsigned   not null,
-  name           varchar(255)        not null,
-  ref            tinytext            null,
-  description    text                null,
-  path           text                not null,
-  force_commit   tinyint unsigned    not null default 0,
-  default_view_mod   char(32)        not null default 'embedded',
-  default_encoding   char(32)        not null default 'UTF-8',
-  display_order  int unsigned        not null default 0,
-  content_maker  tinytext            not null default '',
-  content_local  varchar(32)         not null default 'local',
-  content_license    text            not null default '',
-  prevent_reinit tinyint unsigned    not null default 1,
-  js_lib         tinytext            not null default '',
-  debug          tinyint unsigned    not null default 0,
-  theme          varchar(255)        not null default '',
-  preview_image  varchar(255)        not null default '',
-  author         varchar(255)        not null default '',
-  session_id     int unsigned        not null default 0,
-  prerequisite   int unsigned        not null default 0,
-  hide_toc_frame tinyint             NOT NULL DEFAULT 0,
-  seriousgame_mode tinyint           NOT NULL DEFAULT 0,
-  use_max_score  int unsigned        not null default 1,
-  autolunch      int unsigned        not null default 0,
-  created_on     DATETIME            NOT NULL DEFAULT '0000-00-00 00:00:00',
-  modified_on    DATETIME            NOT NULL DEFAULT '0000-00-00 00:00:00',
-  publicated_on  DATETIME            NOT NULL DEFAULT '0000-00-00 00:00:00',
-  expired_on     DATETIME            NOT NULL DEFAULT '0000-00-00 00:00:00',
-  PRIMARY KEY  (id, c_id)
-);
-
-CREATE TABLE IF NOT EXISTS c_lp_view (
-  id             int unsigned        auto_increment,
-  c_id INT NOT NULL,
-  lp_id          int unsigned        not null,
-  user_id        int unsigned        not null,
-  view_count     int unsigned   not null default 0,
-  last_item      int unsigned        not null default 0,
-  progress       int unsigned        default 0,
-  session_id     int                 not null default 0,
-  PRIMARY KEY  (id, c_id)
-);
-
-ALTER TABLE c_lp_view ADD INDEX (lp_id);
-ALTER TABLE c_lp_view ADD INDEX (user_id);
-ALTER TABLE c_lp_view ADD INDEX (session_id);
-
-CREATE TABLE IF NOT EXISTS c_lp_item (
-  id              int unsigned       auto_increment,
-  c_id INT NOT NULL,
-  lp_id          int unsigned        not null,
-  item_type      char(32)            not null default 'dokeos_document',
-  ref            tinytext            not null default '',
-  title          varchar(511)        not null,
-  description    varchar(511)        not null default '',
-  path           text                not null,
-  min_score      float unsigned      not null default 0,
-  max_score      float unsigned      default 100,
-  mastery_score  float unsigned      null,
-  parent_item_id     int unsigned    not null default 0,
-  previous_item_id   int unsigned    not null default 0,
-  next_item_id       int unsigned    not null default 0,
-  display_order      int unsigned    not null default 0,
-  prerequisite   text                null default null,
-  parameters     text                null,
-  launch_data    text                not null default '',
-  max_time_allowed   char(13)        NULL default '',
-  terms          TEXT                NULL,
-  search_did     INT                 NULL,
-  audio          VARCHAR(250),
-  prerequisite_min_score float,
-  prerequisite_max_score float,
-  PRIMARY KEY  (id, c_id)
-);
-
-ALTER TABLE c_lp_item ADD INDEX (lp_id);
-ALTER TABLE c_lp_item ADD INDEX idx_c_lp_item_cid_lp_id (c_id, lp_id);
-
-CREATE TABLE IF NOT EXISTS c_lp_item_view (
-  id bigint unsigned auto_increment,
-  c_id INT NOT NULL,
-  lp_item_id     int unsigned    not null,
-  lp_view_id     int unsigned    not null,
-  view_count     int unsigned    not null default 0,
-  start_time     int unsigned    not null,
-  total_time     int unsigned    not null default 0,
-  score          float unsigned  not null default 0,
-  status         char(32)        not null default 'not attempted',
-  suspend_data   longtext null default '',
-  lesson_location    text        null default '',
-  core_exit      varchar(32)     not null default 'none',
-  max_score      varchar(8)      default '',
-  PRIMARY KEY  (id, c_id)
-);
-
-ALTER TABLE c_lp_item_view ADD INDEX (lp_item_id);
-ALTER TABLE c_lp_item_view ADD INDEX (lp_view_id);
-ALTER TABLE c_lp_item_view ADD INDEX idx_c_lp_item_view_cid_lp_view_id_lp_item_id (c_id, lp_view_id, lp_item_id);
-
-CREATE TABLE IF NOT EXISTS c_lp_iv_interaction(
-  id             bigint unsigned     auto_increment,
-  c_id INT NOT NULL,
-  order_id       int unsigned   not null default 0,
-  lp_iv_id       bigint unsigned     not null,
-  interaction_id varchar(255)        not null default '',
-  interaction_type   varchar(255)    not null default '',
-  weighting          double          not null default 0,
-  completion_time    varchar(16)     not null default '',
-  correct_responses  text            not null default '',
-  student_response   text            not null default '',
-  result         varchar(255)        not null default '',
-  latency        varchar(16)         not null default '',
-  PRIMARY KEY (id, c_id)
-);
-
-ALTER TABLE c_lp_iv_interaction ADD INDEX (lp_iv_id);
-
-CREATE TABLE IF NOT EXISTS c_lp_iv_objective(
-  id             bigint unsigned     auto_increment,
-  c_id INT NOT NULL,
-  lp_iv_id       bigint unsigned     not null,
-  order_id       int unsigned   not null default 0,
-  objective_id   varchar(255)        not null default '',
-  score_raw      float unsigned      not null default 0,
-  score_max      float unsigned      not null default 0,
-  score_min      float unsigned      not null default 0,
-  status         char(32)            not null default 'not attempted',
-  PRIMARY KEY (id, c_id)
-);
-
-ALTER TABLE c_lp_iv_objective ADD INDEX (lp_iv_id);
-
-CREATE TABLE c_blog (
-  blog_id int NOT NULL AUTO_INCREMENT ,
-  c_id INT NOT NULL,
-  blog_name varchar( 250 ) NOT NULL default '',
-  blog_subtitle varchar( 250 ) default NULL ,
-  date_creation datetime NOT NULL default '0000-00-00 00:00:00',
-  visibility tinyint unsigned NOT NULL default 0,
-  session_id int default 0,
-  PRIMARY KEY (blog_id, c_id)
-);
-
-ALTER TABLE c_blog  ADD INDEX ( session_id );
-
-CREATE TABLE c_blog_comment (
-    comment_id int NOT NULL AUTO_INCREMENT ,
-    c_id INT NOT NULL,
-    title varchar( 250 ) NOT NULL default '',
-    comment longtext NOT NULL ,
-    author_id int NOT NULL default 0,
-    date_creation datetime NOT NULL default '0000-00-00 00:00:00',
-    blog_id int NOT NULL default 0,
-    post_id int NOT NULL default 0,
-    task_id int default NULL ,
-    parent_comment_id int NOT NULL default 0,
-    PRIMARY KEY (comment_id, c_id)
-);
-
-CREATE TABLE c_blog_post(
-    post_id int NOT NULL AUTO_INCREMENT ,
-    c_id INT NOT NULL,
-    title varchar( 250 ) NOT NULL default '',
-    full_text longtext NOT NULL ,
-    date_creation datetime NOT NULL default '0000-00-00 00:00:00',
-    blog_id int NOT NULL default 0,
-    author_id int NOT NULL default 0,
-    PRIMARY KEY (post_id, c_id)
-);
-
-CREATE TABLE c_blog_rating(
-    rating_id int NOT NULL AUTO_INCREMENT ,
-    c_id INT NOT NULL,
-    blog_id int NOT NULL default 0,
-    rating_type enum( 'post', 'comment' ) NOT NULL default 'post',
-    item_id int NOT NULL default 0,
-    user_id int NOT NULL default 0,
-    rating int NOT NULL default 0,
-    PRIMARY KEY (rating_id, c_id)
-);
-
-CREATE TABLE c_blog_rel_user(
-    c_id INT NOT NULL,
-    blog_id int NOT NULL default 0,
-    user_id int NOT NULL default 0,
-    PRIMARY KEY (c_id, blog_id , user_id )
-);
-
-CREATE TABLE c_blog_task(
-    task_id int NOT NULL AUTO_INCREMENT ,
-    c_id INT NOT NULL,
-    blog_id int NOT NULL default 0,
-    title varchar( 250 ) NOT NULL default '',
-    description text NOT NULL ,
-    color varchar( 10 ) NOT NULL default '',
-    system_task tinyint unsigned NOT NULL default 0,
-    PRIMARY KEY (task_id, c_id)
-);
-
-CREATE TABLE c_blog_task_rel_user  (
-    c_id INT NOT NULL,
-    blog_id int NOT NULL default 0,
-    user_id int NOT NULL default 0,
-    task_id int NOT NULL default 0,
-    target_date date NOT NULL default '0000-00-00',
-    PRIMARY KEY (c_id, blog_id , user_id , task_id )
-);
-
-CREATE TABLE  c_blog_attachment  (
-  id int unsigned NOT NULL auto_increment,
-  c_id INT NOT NULL,
-  path varchar(255) NOT NULL COMMENT 'the real filename',
-  comment text,
-  size int NOT NULL default '0',
-  post_id int NOT NULL,
-  filename varchar(255) NOT NULL COMMENT 'the user s file name',
-  blog_id int NOT NULL,
-  comment_id int NOT NULL default '0',
-  PRIMARY KEY (id, c_id)
-);
-
-CREATE TABLE c_permission_group  (
-    id int NOT NULL AUTO_INCREMENT,
-    c_id INT NOT NULL,
-    group_id int NOT NULL default 0,
-    tool varchar( 250 ) NOT NULL default '',
-    action varchar( 250 ) NOT NULL default '',
-    PRIMARY KEY (id, c_id)
-);
-
-CREATE TABLE c_permission_user  (
-    id int NOT NULL AUTO_INCREMENT ,
-    c_id INT NOT NULL,
-    user_id int NOT NULL default 0,
-    tool varchar( 250 ) NOT NULL default '',
-    action varchar( 250 ) NOT NULL default '',
-    PRIMARY KEY (id, c_id)
-);
-
-CREATE TABLE c_permission_task(
-    id int NOT NULL AUTO_INCREMENT,
-    c_id INT NOT NULL,
-    task_id int NOT NULL default 0,
-    tool varchar( 250 ) NOT NULL default '',
-    action varchar( 250 ) NOT NULL default '',
-    PRIMARY KEY (id, c_id)
-);
-
-CREATE TABLE c_role(
-    role_id int NOT NULL AUTO_INCREMENT,
-    c_id INT NOT NULL,
-    role_name varchar( 250 ) NOT NULL default '',
-    role_comment text,
-    default_role tinyint default 0,
-    PRIMARY KEY (role_id, c_id)
-);
-
-CREATE TABLE c_role_group(
-    id int NOT NULL AUTO_INCREMENT,
-    c_id INT NOT NULL,
-    role_id int NOT NULL default 0,
-    scope varchar( 20 ) NOT NULL default 'course',
-    group_id int NOT NULL default 0,
-    PRIMARY KEY  (id, c_id, group_id )
-);
-
-CREATE TABLE c_role_permissions(
-    id int NOT NULL AUTO_INCREMENT,
-    c_id INT NOT NULL,
-    role_id int NOT NULL default 0,
-    tool varchar( 250 ) NOT NULL default '',
-    action varchar( 50 ) NOT NULL default '',
-    default_perm tinyint NOT NULL default 0,
-    PRIMARY KEY  (id, c_id, role_id, tool, action )
-);
-
-CREATE TABLE c_role_user  (
-    c_id INT NOT NULL,
-    role_id int NOT NULL default 0,
-    scope varchar( 20 ) NOT NULL default 'course',
-    user_id int NOT NULL default 0,
-    PRIMARY KEY  ( c_id, role_id, user_id )
-);
-
-CREATE TABLE c_course_setting  (
-  id          int unsigned NOT NULL auto_increment,
-  c_id INT NOT NULL,
-  variable    varchar(255) NOT NULL default '',
-  subkey      varchar(255) default NULL,
-  type        varchar(255) default NULL,
-  category    varchar(255) default NULL,
-  value       varchar(255) NOT NULL default '',
-  title       varchar(255) NOT NULL default '',
-  comment     varchar(255) default NULL,
-  subkeytext  varchar(255) default NULL,
-  PRIMARY KEY (id, c_id)
-);
-
-CREATE TABLE c_survey  (
-  survey_id int unsigned NOT NULL auto_increment,
-  c_id INT NOT NULL,
-  code varchar(20) default NULL,
-  title text default NULL,
-  subtitle text default NULL,
-  author varchar(20) default NULL,
-  lang varchar(20) default NULL,
-  avail_from date default NULL,
-  avail_till date default NULL,
-  is_shared char(1) default '1',
-  template varchar(20) default NULL,
-  intro text,
-  surveythanks text,
-  creation_date datetime NOT NULL default '0000-00-00 00:00:00',
-  invited int NOT NULL,
-  answered int NOT NULL,
-  invite_mail text NOT NULL,
-  reminder_mail text NOT NULL,
-  mail_subject VARCHAR( 255 ) NOT NULL,
-  anonymous enum('0','1') NOT NULL default '0',
-  access_condition TEXT DEFAULT NULL,
-  shuffle bool NOT NULL default '0',
-  one_question_per_page bool NOT NULL default '0',
-  survey_version varchar(255) NOT NULL default '',
-  parent_id int unsigned NOT NULL,
-  survey_type int NOT NULL default 0,
-  show_form_profile int NOT NULL default 0,
-  form_fields TEXT NOT NULL,
-  session_id int unsigned NOT NULL default 0,
-  visible_results int unsigned DEFAULT 0,
-  PRIMARY KEY  (survey_id, c_id)
-);
-
-ALTER TABLE c_survey  ADD INDEX ( session_id );
-CREATE TABLE c_survey_invitation(
-  survey_invitation_id int unsigned NOT NULL auto_increment,
-  c_id INT NOT NULL,
-  survey_code varchar(20) NOT NULL,
-  user varchar(250) NOT NULL,
-  invitation_code varchar(250) NOT NULL,
-  invitation_date datetime NOT NULL,
-  reminder_date datetime NOT NULL,
-  answered int NOT NULL default 0,
-  session_id int UNSIGNED NOT NULL default 0,
-  group_id INT NOT NULL,
-  PRIMARY KEY (survey_invitation_id, c_id)
-);
-
-CREATE TABLE c_survey_question  (
-  question_id int unsigned NOT NULL auto_increment,
-  c_id INT NOT NULL,
-  survey_id int unsigned NOT NULL,
-  survey_question text NOT NULL,
-  survey_question_comment text NOT NULL,
-  type varchar(250) NOT NULL,
-  display varchar(10) NOT NULL,
-  sort int NOT NULL,
-  shared_question_id int,
-  max_value int,
-  survey_group_pri int unsigned NOT NULL default '0',
-  survey_group_sec1 int unsigned NOT NULL default '0',
-  survey_group_sec2 int unsigned NOT NULL default '0',
-  PRIMARY KEY (question_id, c_id)
-);
-
-CREATE TABLE c_survey_question_option  (
-  question_option_id int unsigned NOT NULL auto_increment,
-  c_id INT NOT NULL,
-  question_id int unsigned NOT NULL,
-  survey_id int unsigned NOT NULL,
-  option_text text NOT NULL,
-  sort int NOT NULL,
-  value int NOT NULL default '0',
-  PRIMARY KEY  (question_option_id, c_id)
-);
-
-CREATE TABLE c_survey_answer  (
-  answer_id int unsigned NOT NULL auto_increment,
-  c_id INT NOT NULL,
-  survey_id int unsigned NOT NULL,
-  question_id int unsigned NOT NULL,
-  option_id TEXT NOT NULL,
-  value int unsigned NOT NULL,
-  user varchar(250) NOT NULL,
-  PRIMARY KEY  (answer_id, c_id)
-);
-
-CREATE TABLE c_survey_group(
-  id int unsigned NOT NULL auto_increment,
-  c_id INT NOT NULL,
-  name varchar(20) NOT NULL,
-  description varchar(255) NOT NULL,
-  survey_id int unsigned NOT NULL,
-  PRIMARY KEY  (id, c_id)
-);
-
-CREATE TABLE c_glossary(
-  glossary_id int unsigned NOT NULL auto_increment,
-  c_id INT NOT NULL,
-  name varchar(255) NOT NULL,
-  description text not null,
-  display_order int,
-  session_id int default 0,
-  PRIMARY KEY (glossary_id, c_id)
-);
-
-ALTER TABLE c_glossary ADD INDEX ( session_id );
-
-CREATE TABLE c_notebook (
-  notebook_id int unsigned NOT NULL auto_increment,
-  c_id INT NOT NULL,
-  user_id int unsigned NOT NULL,
-  course varchar(40) not null,
-  session_id int NOT NULL default 0,
-  title varchar(255) NOT NULL,
-  description text NOT NULL,
-  creation_date datetime NOT NULL default '0000-00-00 00:00:00',
-  update_date datetime NOT NULL default '0000-00-00 00:00:00',
-  status int,
-  PRIMARY KEY (notebook_id, c_id)
-);
-
-CREATE TABLE c_attendance(
-    id int NOT NULL auto_increment,
-    c_id INT NOT NULL,
-    name text NOT NULL,
-    description TEXT NULL,
-    active tinyint NOT NULL default 1,
-    attendance_qualify_title varchar(255) NULL,
-    attendance_qualify_max int NOT NULL default 0,
-    attendance_weight float(6,2) NOT NULL default '0.0',
-    session_id int NOT NULL default 0,
-    locked int NOT NULL default 0,
-    PRIMARY KEY (id, c_id)
-);
-
-ALTER TABLE c_attendance ADD INDEX (session_id);
-ALTER TABLE c_attendance ADD INDEX (active);
-
-CREATE TABLE c_attendance_sheet  (
-    c_id INT NOT NULL,
-    user_id int NOT NULL,
-    attendance_calendar_id int NOT NULL,
-    presence tinyint NOT NULL DEFAULT 0,
-    PRIMARY KEY(c_id, user_id, attendance_calendar_id)
-);
-
-ALTER TABLE c_attendance_sheet  ADD INDEX (presence);
-
-CREATE TABLE c_attendance_calendar(
-    id int NOT NULL auto_increment,
-    c_id INT NOT NULL,
-    attendance_id int NOT NULL ,
-    date_time datetime NOT NULL default '0000-00-00 00:00:00',
-    done_attendance tinyint NOT NULL default 0,
-    PRIMARY KEY(id, c_id)
-);
-
-ALTER TABLE c_attendance_calendar ADD INDEX (attendance_id);
-ALTER TABLE c_attendance_calendar ADD INDEX (done_attendance);
-
-CREATE TABLE c_attendance_result(
-    id int NOT NULL auto_increment,
-    c_id INT NOT NULL,
-    user_id int NOT NULL,
-    attendance_id int NOT NULL,
-    score int NOT NULL DEFAULT 0,
-    PRIMARY KEY  (id, c_id)
-);
-
-ALTER TABLE c_attendance_result ADD INDEX (attendance_id);
-ALTER TABLE c_attendance_result ADD INDEX (user_id);
-
-CREATE TABLE c_attendance_sheet_log(
-  id int  NOT NULL auto_increment,
-  c_id INT NOT NULL,
-  attendance_id int  NOT NULL DEFAULT 0,
-  lastedit_date datetime  NOT NULL DEFAULT '0000-00-00 00:00:00',
-  lastedit_type varchar(200)  NOT NULL,
-  lastedit_user_id int  NOT NULL DEFAULT 0,
-  calendar_date_value datetime NULL,
-  PRIMARY KEY (id, c_id)
-);
-
-CREATE TABLE c_thematic(
-  id int NOT NULL auto_increment,
-  c_id INT NOT NULL,
-  title varchar(255) NOT NULL,
-  content text NULL,
-  display_order int unsigned NOT NULL DEFAULT 0,
-  active tinyint NOT NULL DEFAULT 0,
-  session_id int NOT NULL DEFAULT 0,
-  PRIMARY KEY (id, c_id)
-);
-
-ALTER TABLE c_thematic ADD INDEX (active, session_id);
-
-CREATE TABLE c_thematic_plan(
-  id int NOT NULL auto_increment,
-  c_id INT NOT NULL,
-  thematic_id int NOT NULL,
-  title varchar(255) NOT NULL,
-  description text NULL,
-  description_type int NOT NULL,
-  PRIMARY KEY (id, c_id)
-);
-
-ALTER TABLE c_thematic_plan ADD INDEX (thematic_id, description_type);
-
-CREATE TABLE c_thematic_advance(
-  id int NOT NULL auto_increment,
-  c_id INT NOT NULL,
-  thematic_id int NOT NULL,
-  attendance_id int NOT NULL DEFAULT 0,
-  content text NULL,
-  start_date datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
-  duration int NOT NULL DEFAULT 0,
-  done_advance tinyint NOT NULL DEFAULT 0,
-  PRIMARY KEY (id, c_id)
-);
-
-ALTER TABLE c_thematic_advance ADD INDEX (thematic_id);
-
-CREATE TABLE IF NOT EXISTS c_metadata (
-  c_id INT NOT NULL,
-  eid VARCHAR(250) NOT NULL,
-  mdxmltext TEXT default '',
-  md5 CHAR(32) default '',
-  htmlcache1 TEXT default '',
-  htmlcache2 TEXT default '',
-  indexabletext TEXT default '',
-  PRIMARY KEY (c_id, eid)
-);
-

File diff suppressed because it is too large
+ 1247 - 4
main/install/database.sql


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

@@ -12,7 +12,7 @@
 
 /*      CONSTANTS */
 
-define('SYSTEM_MAIN_DATABASE_FILE', 'main.sql');
+define('SYSTEM_MAIN_DATABASE_FILE', 'database.sql');
 define('COUNTRY_DATA_FILENAME', 'country_data.csv');
 define('COURSES_HTACCESS_FILENAME', 'htaccess.dist');
 define('SYSTEM_CONFIG_FILENAME', 'configuration.dist.php');

+ 1 - 3
main/install/install_db.inc.php

@@ -114,11 +114,9 @@ $installation_settings['{PLATFORM_AUTH_SOURCE}']            = PLATFORM_AUTH_SOUR
 $installation_settings['{ADMINLANGUAGE}']                   = $languageForm;
 $installation_settings['{HASHFUNCTIONMODE}']                = $encryptPassForm;
 
-load_main_database($installation_settings);
-
 AddCourse::drop_course_tables();
 
-load_database_script('course.sql');
+load_main_database($installation_settings);
 
 $track_countries_table = "track_c_countries";
 fill_track_countries_table($track_countries_table);

+ 3 - 1
main/install/migrate-db-1.9.0-1.10.0-pre.sql

@@ -49,6 +49,8 @@ ALTER TABLE track_e_course_access ADD COLUMN c_id int NOT NULL;
 ALTER TABLE track_e_online ADD COLUMN c_id int NOT NULL;
 ALTER TABLE track_e_attempt ADD COLUMN c_id int NOT NULL;
 
+ALTER TABLE track_e_default ADD COLUMN session_id int NOT NULL;
+
 DELETE FROM settings_current WHERE variable = 'wcag_anysurfer_public_pages';
 DELETE FROM settings_options WHERE variable = 'wcag_anysurfer_public_pages';
 DELETE FROM settings_current WHERE variable = 'advanced_filemanager';
@@ -105,4 +107,4 @@ CREATE TABLE IF NOT EXISTS c_student_publication_comment (id INT PRIMARY KEY NOT
 CREATE TABLE IF NOT EXISTS c_attendance_calendar_rel_group (id int NOT NULL auto_increment PRIMARY KEY, c_id INT NOT NULL, group_id INT NOT NULL, calendar_id INT NOT NULL);
 
 -- Do not move this query
-UPDATE settings_current SET selected_value = '1.10.0.22' WHERE variable = 'chamilo_database_version';
+UPDATE settings_current SET selected_value = '1.10.0.24' WHERE variable = 'chamilo_database_version';

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

@@ -296,9 +296,6 @@ if (defined('SYSTEM_INSTALLATION')) {
 
     global $_configuration;
 
-    AddCourse::drop_course_tables();
-    load_database_script('course.sql');
-
     $prefix = '';
     if ($singleDbForm) {
         $prefix =  get_config_param('table_prefix');

+ 2 - 3
main/messages/inbox.php

@@ -130,8 +130,6 @@ if (isset($_GET['f']) && $_GET['f'] == 'social' || api_get_setting('allow_social
 $userInfo    = UserManager::get_user_info_by_id($user_id);
 //LEFT CONTENT
 if (api_get_setting('allow_social_tool') == 'true') {
-    //Block Social Avatar
-    $social_avatar_block = SocialManager::getSocialUserBlock($user_id, 'messages');
     //Block Social Menu
     $social_menu_block = SocialManager::show_social_menu('messages');
 }
@@ -168,8 +166,9 @@ if (api_get_setting('allow_social_tool') == 'true') {
 }
 
 $tpl = new Template(null);
+// Block Social Avatar
+SocialManager::setSocialUserBlock($tpl, $user_id, 'messages');
 if (api_get_setting('allow_social_tool') == 'true') {
-    $tpl->assign('social_avatar_block', $social_avatar_block);
     $tpl->assign('social_menu_block', $social_menu_block);
     $tpl->assign('social_right_content', $social_right_content);
     $social_layout = $tpl->get_template('social/inbox.tpl');

+ 3 - 3
main/messages/new_message.php

@@ -313,8 +313,6 @@ if ($group_id != 0) {
 $social_left_content = null;
 $userInfo    = UserManager::get_user_info_by_id($user_id);
 if (api_get_setting('allow_social_tool') == 'true') {
-    //Block Social Avatar
-    $social_avatar_block = SocialManager::getSocialUserBlock($user_id, 'messages');
     //Block Social Menu
     $social_menu_block = SocialManager::show_social_menu('messages');
     $social_right_content .= '<div class="row">';
@@ -374,8 +372,10 @@ if (api_get_setting('allow_social_tool') == 'true') {
 }
 
 $tpl = new Template(get_lang('ComposeMessage'));
+// Block Social Avatar
+SocialManager::setSocialUserBlock($tpl, $user_id, 'messages');
+
 if (api_get_setting('allow_social_tool') == 'true') {
-    $tpl->assign('social_avatar_block', $social_avatar_block);
     $tpl->assign('social_menu_block', $social_menu_block);
     $tpl->assign('social_right_content', $social_right_content);
     $social_layout = $tpl->get_template('social/inbox.tpl');

+ 12 - 18
main/messages/outbox.php

@@ -85,12 +85,12 @@ if ($_GET['f']=='social') {
 	}
 }
 
-$info_delete_outbox=array();
-$info_delete_outbox=explode(',',$_GET['form_delete_outbox']);
-$count_delete_outbox=(count($info_delete_outbox)-1);
+$info_delete_outbox =array();
+$info_delete_outbox = isset($_GET['form_delete_outbox']) ? explode(',',$_GET['form_delete_outbox']) : '';
+$count_delete_outbox = count($info_delete_outbox) - 1;
 
-if( trim($info_delete_outbox[0])=='delete' ) {
-	for ($i=1;$i<=$count_delete_outbox;$i++) {
+if (isset($info_delete_outbox[0]) && trim($info_delete_outbox[0])=='delete') {
+    for ($i = 1; $i <= $count_delete_outbox; $i++) {
 		MessageManager::delete_message_by_user_sender(api_get_user_id(),$info_delete_outbox[$i]);
 	}
     $message_box=get_lang('SelectedMessagesDeleted').
@@ -110,16 +110,12 @@ if (isset($_REQUEST['action'])) {
 $social_right_content = '';
 $userInfo    = UserManager::get_user_info_by_id($user_id);
 if (api_get_setting('allow_social_tool') == 'true') {
-    //Block Social Avatar
-    $social_avatar_block = SocialManager::getSocialUserBlock($user_id, 'messages');
     //Block Social Menu
     $social_menu_block = SocialManager::show_social_menu('messages');
-    $social_right_content .= '<div class="span9">';
-        $social_right_content .= '<div class="actions">';
-        $social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php?f=social">'.Display::return_icon('back.png', get_lang('Back'), array(), 32).'</a>';
-        $social_right_content .= '</div>';
+
+    $social_right_content .= '<div class="actions">';
+    $social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php?f=social">'.Display::return_icon('back.png', get_lang('Back'), array(), 32).'</a>';
     $social_right_content .= '</div>';
-    $social_right_content .= '<div class="span9">';
 }
 //MAIN CONTENT
 if ($action == 'delete') {
@@ -146,16 +142,14 @@ if ($action == 'delete') {
     $social_right_content .= MessageManager::outbox_display();
 }
 
-if (api_get_setting('allow_social_tool') == 'true') {
-    $social_right_content .= '</div>';
-}
-
 $tpl = new Template(get_lang('ComposeMessage'));
+// Block Social Avatar
+SocialManager::setSocialUserBlock($tpl, $user_id, 'messages');
 if (api_get_setting('allow_social_tool') == 'true') {
-    $tpl->assign('social_avatar_block', $social_avatar_block);
+
     $tpl->assign('social_menu_block', $social_menu_block);
     $tpl->assign('social_right_content', $social_right_content);
-    $social_layout = $tpl->get_template('social/home.tpl');
+    $social_layout = $tpl->get_template('social/inbox.tpl');
     $tpl->display($social_layout);
 } else {
     $content = $social_right_content;

+ 3 - 2
main/messages/view_message.php

@@ -55,8 +55,6 @@ $message  = '';
 //LEFT COLUMN
 $userInfo    = UserManager::get_user_info_by_id($user_id);
 if (api_get_setting('allow_social_tool') == 'true') {
-    //Block Social Avatar
-    $social_avatar_block = SocialManager::getSocialUserBlock($user_id, $show_menu);
     //Block Social Menu
     $social_menu_block = SocialManager::show_social_menu($show_menu);
     $message .='<div class="span9">';
@@ -74,6 +72,9 @@ if (!empty($message)) {
     api_not_allowed();
 }
 $tpl = new Template(get_lang('View'));
+// Block Social Avatar
+SocialManager::setSocialUserBlock($tpl, $user_id, $show_menu);
+
 if (api_get_setting('allow_social_tool') == 'true') {
     $tpl->assign('social_avatar_block', $social_avatar_block);
     $tpl->assign('social_menu_block', $social_menu_block);

+ 1 - 1
main/newscorm/lp_controller.php

@@ -528,7 +528,7 @@ switch ($action) {
                     // TODO: Maybe create a first module directly to avoid bugging the user with useless queries
                     $_SESSION['oLP'] = new learnpath(api_get_course_id(),$new_lp_id,api_get_user_id());
                     //require 'lp_build.php';
-                    $url = api_get_self().'?action=add_item&type=step&lp_id='.intval($new_lp_id);
+                    $url = api_get_self().'?action=add_item&type=step&lp_id='.intval($new_lp_id).'&'.api_get_cidreq();
                     header("Location: $url&isStudentView=false");
                     exit;
                 }

+ 2 - 3
main/social/friends.php

@@ -82,7 +82,6 @@ $interbreadcrumb[] = array('url' => 'profile.php', 'name' => get_lang('SocialNet
 $interbreadcrumb[] = array('url' => '#', 'name' => get_lang('Friends'));
 //Block Social Avatar
 $user_info    = UserManager::get_user_info_by_id($user_id);
-$social_avatar_block = SocialManager::getSocialUserBlock($user_id, 'friends');
 //Block Social Menu
 $social_menu_block = SocialManager::show_social_menu('friends');
 
@@ -138,9 +137,9 @@ if (count($friends) == 0) {
 }
 $social_right_content .= '</div>';
 
-
 $tpl = new Template(get_lang('Social'));
-$tpl->assign('social_avatar_block', $social_avatar_block);
+SocialManager::setSocialUserBlock($tpl, $user_id, 'friends');
+
 $tpl->assign('social_menu_block', $social_menu_block);
 $tpl->assign('social_right_content', $social_right_content);
 

+ 6 - 6
main/social/groups.php

@@ -217,11 +217,13 @@ if ($group_id != 0) {
         }
     }
 }
+
+$tpl = new Template();
+
 $create_thread_link = '';
 $userInfo = api_get_user_info(api_get_user_id(), true);
 if ($group_id != 0) {
-    //Block Social Avatar
-    $social_avatar_block = SocialManager::getSocialUserBlock($user_id, 'groups', $group_id);
+    SocialManager::setSocialUserBlock($tpl, $user_id, 'groups', $group_id);
     //Block Social Menu
     $social_menu_block = SocialManager::show_social_menu('groups', $group_id);
 } else {
@@ -229,8 +231,8 @@ if ($group_id != 0) {
     if (isset($_GET['view']) && $_GET['view'] == 'mygroups') {
         $show_menu = $_GET['view'];
     }
-    //Block Social Avatar
-    $social_avatar_block = SocialManager::getSocialUserBlock($user_id, $show_menu, $group_id);
+    // Block Social Avatar
+    SocialManager::setSocialUserBlock($tpl, $user_id, $show_menu, $group_id);
     $social_menu_block = SocialManager::show_social_menu($show_menu, $group_id);
 }
 
@@ -877,9 +879,7 @@ if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'show_message' && $_REQ
     $show_message = Display::return_message(get_lang('Deleted'), 'success');
 }
 
-$tpl = new Template();
 $tpl->set_help('Groups');
-$tpl->assign('social_avatar_block', $social_avatar_block);
 $tpl->assign('social_menu_block', $social_menu_block);
 $tpl->assign('social_right_content', $social_right_content);
 

+ 37 - 27
main/social/home.php

@@ -83,17 +83,18 @@ if (api_get_setting('profile', 'picture') == 'true') {
     }
 }
 
-$social_avatar_block = SocialManager::getSocialUserBlock(api_get_user_id(), 'home');
 //Block Menu
 $social_menu_block = SocialManager::show_social_menu('home');
 
-//Search box
-$social_search_block = '<div class="panel panel-default social-search">';
+// Search box
+/*$social_search_block = '<div class="panel panel-default social-search">';
 $social_search_block .= '<div class="panel-heading">'.get_lang("SearchUsers").'</div>';
 $social_search_block .= '<div class="panel-body">';
 $social_search_block.= UserManager::get_search_form('');
 $social_search_block.= '</div>';
-$social_search_block.= '</div>';
+$social_search_block.= '</div>';*/
+
+$social_search_block = Display::panel(UserManager::get_search_form(''), get_lang("SearchUsers"));
 
 //BLock Social Skill
 $social_skill_block = '';
@@ -104,29 +105,32 @@ if (api_get_setting('allow_skills_tool') == 'true') {
     $ranking = $skill->get_user_skill_ranking(api_get_user_id());
     $skills = $skill->get_user_skills(api_get_user_id(), true);
 
-    $social_skill_block = '<div class="panel panel-default social-skill">';
-    $social_skill_block .= '<div class="panel-heading">' . get_lang('Skills');
-    $social_skill_block .= '<div class="btn-group pull-right"> <a class="btn dropdown-toggle" data-toggle="dropdown" href="#">
-                            <span class="caret"></span></a>
-                             <ul class="dropdown-menu">';
+    //$social_skill_block = '<div class="panel panel-default social-skill">';
+    //$social_skill_block .= '<div class="panel-heading">' . get_lang('Skills');
+    $content = '<div class="btn-group pull-right">
+                <a class="btn dropdown-toggle" data-toggle="dropdown" href="#">
+                <span class="caret"></span></a>
+                 <ul class="dropdown-menu">';
     if (api_is_student() || api_is_student_boss() || api_is_drh()) {
-        $social_skill_block .= '<li>' . Display::url(
+        $content .= '<li>' . Display::url(
             get_lang('SkillsReport'),
             api_get_path(WEB_CODE_PATH) . 'social/my_skills_report.php'
             ) . '</li>';
     }
 
-    $social_skill_block .= '<li>' . Display::url(
+    $content .= '<li>' . Display::url(
         get_lang('SkillsWheel'),
         api_get_path(WEB_CODE_PATH) . 'social/skills_wheel.php'
         ) . '</li>';
 
-    $social_skill_block .= '<li>' . Display::url(
+    $content .= '<li>' . Display::url(
         sprintf(get_lang('YourSkillRankingX'), $ranking),
         api_get_path(WEB_CODE_PATH) . 'social/skills_ranking.php'
     ) . '</li>';
 
-    $social_skill_block .= '</ul></div></div>';
+    $content .= '</ul></div>';
+
+    $social_skill_block = Display::panel($content, get_lang('Skills'));
 
     $lis = '';
     if (!empty($skills)) {
@@ -142,7 +146,7 @@ if (api_get_setting('allow_skills_tool') == 'true') {
                 $badgeImage = Display::return_icon(
                     'badges-default.png',
                     $skill['name'],
-                    array('title' => $skill['name']),ICON_SIZE_BIG
+                    array('title' => $skill['name']), ICON_SIZE_BIG
                 );
             }
 
@@ -152,25 +156,28 @@ if (api_get_setting('allow_skills_tool') == 'true') {
                 '<div class="badges-name">' . $skill['name'] . '</div>'
             );
         }
-        $social_skill_block .= '<div class="panel-body">';
+        /*$social_skill_block .= '<div class="panel-body">';
         $social_skill_block .= Display::tag('ul', $lis, array('class' => 'list-badges'));
-        $social_skill_block .= '</div>';
-    }else{
+        $social_skill_block .= '</div>';*/
+        $social_skill_block .= Display::panel(Display::tag('ul', $lis, array('class' => 'list-badges')));
+    } else {
+
+        $social_skill_block .= Display::panel(
+            Display::url(get_lang('SkillsWheel'),api_get_path(WEB_CODE_PATH) . 'social/skills_wheel.php'),
+            get_lang('WithoutAchievedSkills')
+        );
 
-        $social_skill_block .= '<div class="panel-body">';
+        /*$social_skill_block .= '<div class="panel-body">';
         $social_skill_block .= '<p>'. get_lang("WithoutAchievedSkills") . '</p>';
         $social_skill_block .= '<p>' . Display::url(get_lang('SkillsWheel'),api_get_path(WEB_CODE_PATH) . 'social/skills_wheel.php').'</p>';
-        $social_skill_block .= '</div>';
+        $social_skill_block .= '</div>';*/
     }
-    $social_skill_block.='</div>';
 }
 
-
-
 //Group box by age
-$social_group_block = '<div class="panel panel-default social-group">';
+/*$social_group_block =  '<div class="panel panel-default social-group">';
 $social_group_block .= '<div class="panel-heading">'.get_lang('Group').'</div>';
-$social_group_block .= '<div class="panel-body">';
+$social_group_block .= '<div class="panel-body">';*/
 
 $results = GroupPortalManager::get_groups_by_age(1, false);
 
@@ -249,7 +256,7 @@ foreach ($results as $result) {
 }
 
 $list=count($groups_newest);
-
+$social_group_block = null;
 if ($list > 0) {
     $social_group_block .= '<div class="list-group-newest">';
     $social_group_block .= '<div class="group-title">' . get_lang('Newest') . '</div>';
@@ -274,6 +281,7 @@ if ($list > 0) {
         $social_group_block.= $groups_pop[$i][2] . '</div>';
         $social_group_block.="</div>";
     }
+    $social_group_block.= "</div>";
 
     /*$social_group_block .= Display::return_sortable_grid(
         'home_group',
@@ -285,10 +293,12 @@ if ($list > 0) {
         array(true, true, true, true, true)
     );*/
 }
-$social_group_block .= '</div>';
+
+$social_group_block = Display::panel($social_group_block, get_lang('Group'));
 
 $tpl = new Template(get_lang('SocialNetwork'));
-$tpl->assign('social_avatar_block', $social_avatar_block);
+SocialManager::setSocialUserBlock($tpl, api_get_user_id(), 'home');
+
 $tpl->assign('social_menu_block', $social_menu_block);
 $tpl->assign('social_search_block', $social_search_block);
 $tpl->assign('social_skill_block', $social_skill_block);

+ 2 - 6
main/social/invitations.php

@@ -4,9 +4,7 @@
  * @package chamilo.social
  * @author Julio Montoya <gugli100@gmail.com>
  */
-/**
- * Initialization
- */
+
 $language_file = array('userInfo');
 $cidReset=true;
 require_once '../inc/global.inc.php';
@@ -93,8 +91,6 @@ if (is_array($_GET) && count($_GET)>0) {
 }
 //Block Avatar Social
 $userInfo    = UserManager::get_user_info_by_id($user_id);
-
-$social_avatar_block = SocialManager::getSocialUserBlock($user_id, invitations);
 //Block Menu Social
 $social_menu_block = SocialManager::show_social_menu('invitations');
 //Block Invitations
@@ -210,7 +206,7 @@ if (count($pending_invitations) > 0) {
 }
 
 $tpl = new Template(null);
-$tpl->assign('social_avatar_block', $social_avatar_block);
+SocialManager::setSocialUserBlock($tpl, $user_id, 'invitations');
 $tpl->assign('social_menu_block', $social_menu_block);
 $tpl->assign('social_invitations_block',$socialInvitationsBlock);
 $tpl->assign('message', $show_message);

+ 3 - 8
main/social/myfiles.php

@@ -131,7 +131,7 @@ if (is_array($_GET) && count($_GET) > 0) {
 }
 //Social Avatar BLock
 $user_info    = UserManager::get_user_info_by_id($user_id);
-$social_avatar_block = SocialManager::getSocialUserBlock($user_id, 'myfiles');
+
 //Social Menu Block
 $social_menu_block = SocialManager::show_social_menu('myfiles');
 $actions = null;
@@ -155,17 +155,12 @@ if (isset($_GET['cidReq'])) {
         ) . '</a>';
 }
 $tpl = new Template();
+SocialManager::setSocialUserBlock($tpl, $user_id, 'myfiles');
 $editor = new \Chamilo\CoreBundle\Component\Editor\Editor();
-
 $editor = $tpl->fetch('default/'.$editor->getEditorStandAloneTemplate());
-$social_right_content = '<div class="span9">';
-$social_right_content .= $editor;
-$social_right_content .= '</div>';
 
-$tpl->assign('social_avatar_block', $social_avatar_block);
+$tpl->assign('social_right_content', $editor);
 $tpl->assign('social_menu_block', $social_menu_block);
-$tpl->assign('social_right_content', $social_right_content);
-
 $tpl->assign('actions', $actions);
 $tpl->assign('message', $show_message);
 

+ 4 - 5
main/social/profile.php

@@ -222,8 +222,7 @@ if (is_array($personal_course_list)) {
     //to avoid repeted courses
     $course_list_code = array_unique_dimensional($course_list_code);
 }
-//Block Avatar Social
-$social_avatar_block = SocialManager::getSocialUserBlock($user_id, 'shared_profile');
+
 //Social Block Menu
 $social_menu_block = SocialManager::show_social_menu('shared_profile', null, $user_id, $show_full_profile);
 
@@ -727,10 +726,10 @@ if ($show_full_profile) {
     }
 }
 
-
-
 $tpl = new Template(get_lang('Social'));
-$tpl->assign('social_avatar_block', $social_avatar_block);
+// Block Avatar Social
+SocialManager::setSocialUserBlock($tpl, $user_id, 'shared_profile');
+
 $tpl->assign('social_menu_block', $social_menu_block);
 $tpl->assign('social_wall_block', $social_wall_block);
 $tpl->assign('social_post_wall_block', $social_post_wall_block);

+ 3 - 3
main/social/search.php

@@ -35,8 +35,7 @@ if (!empty($extra_fields)) {
     }
 }
 $user_info = UserManager::get_user_info_by_id($user_id);
-//Block Social Avatar
-$social_avatar_block = SocialManager::getSocialUserBlock($user_id, 'search');
+
 //Block Social Menu
 $social_menu_block = SocialManager::show_social_menu('search');
 $social_right_content = '';
@@ -214,7 +213,8 @@ if ($query != '' || ($query_vars['search_type']=='1' && count($query_vars)>2) )
 }
 
 $tpl = new Template($tool_name);
-$tpl->assign('social_avatar_block', $social_avatar_block);
+// Block Social Avatar
+SocialManager::setSocialUserBlock($tpl, $user_id, 'search');
 $tpl->assign('social_menu_block', $social_menu_block);
 $tpl->assign('social_right_content', $social_right_content);
 $tpl->assign('search_form', $searchForm);

+ 60 - 19
main/survey/survey.lib.php

@@ -3414,7 +3414,16 @@ class SurveyUtil
                 'group_id' => $groupId,
                 'survey_code' => $survey_data['code']
             );
-            self::save_invitation($params);
+
+            $invitationExists = self::invitationExists(
+                $course_id,
+                $session_id,
+                $groupId,
+                $survey_data['code']
+            );
+            if (empty($invitationExists)) {
+                self::save_invitation($params);
+            }
         }
 
         $users_array = array_unique($users_array);
@@ -3428,6 +3437,7 @@ class SurveyUtil
             if (in_array($value, $exclude_users)) {
                 continue;
             }
+
             // Get the unique invitation code if we already have it
             if ($reminder == 1 && array_key_exists($value, $survey_invitations)) {
                 $invitation_code = $survey_invitations[$value]['invitation_code'];
@@ -3476,16 +3486,46 @@ class SurveyUtil
      * @param $params
      * @return bool|int
      */
-    static function save_invitation($params)
+    public static function save_invitation($params)
     {
         // Database table to store the invitations data
-        $table_survey_invitation = Database::get_course_table(TABLE_SURVEY_INVITATION);
-        if (!empty($params['c_id']) && (!empty($params['user']) || !empty($params['group_id'])) && !empty($params['survey_code'])) {
-            return Database::insert($table_survey_invitation, $params);
+        $table = Database::get_course_table(TABLE_SURVEY_INVITATION);
+        if (!empty($params['c_id']) &&
+            (!empty($params['user']) || !empty($params['group_id'])) &&
+            !empty($params['survey_code'])
+        ) {
+            return Database::insert($table, $params);
         }
         return false;
     }
 
+    /**
+     * @param int $courseId
+     * @param int $sessionId
+     * @param int $groupId
+     * @param string $surveyCode
+     * @return int
+     */
+    public static function invitationExists($courseId, $sessionId, $groupId, $surveyCode)
+    {
+        $table = Database::get_course_table(TABLE_SURVEY_INVITATION);
+        $courseId = intval($courseId);
+        $sessionId = intval($sessionId);
+        $groupId = intval($groupId);
+        $surveyCode = Database::escape_string($surveyCode);
+
+        $sql = "SELECT survey_invitation_id FROM $table
+                WHERE
+                    c_id = $courseId AND
+                    session_id = $sessionId AND
+                    group_id = $groupId AND
+                    survey_code = '$surveyCode'
+                ";
+        $result = Database::query($sql);
+
+        return Database::num_rows($result);
+    }
+
     /**
      * Send the invitation by mail.
      *
@@ -3493,7 +3533,7 @@ class SurveyUtil
      * $param string $invitation_code - the unique invitation code for the URL
      * @return	void
      */
-    static function send_invitation_mail($invitedUser, $invitation_code, $invitation_title, $invitation_text)
+    public static function send_invitation_mail($invitedUser, $invitation_code, $invitation_title, $invitation_text)
     {
         $_user = api_get_user_info();
         $_course = api_get_course_info();
@@ -3579,8 +3619,13 @@ class SurveyUtil
         $table_survey 				= Database :: get_course_table(TABLE_SURVEY);
 
         // Counting the number of people that are invited
-        $sql = "SELECT count(user) as total FROM $table_survey_invitation
-		        WHERE c_id = $course_id AND survey_code = '".Database::escape_string($survey_code)."'";
+        $sql = "SELECT count(user) as total
+                FROM $table_survey_invitation
+		        WHERE
+		            c_id = $course_id AND
+		            survey_code = '".Database::escape_string($survey_code)."' AND
+		            user <> ''
+                ";
         $result = Database::query($sql);
         $row = Database::fetch_array($result);
         $total_invited = $row['total'];
@@ -3588,7 +3633,10 @@ class SurveyUtil
         // Updating the field in the survey table
         $sql = "UPDATE $table_survey
 		        SET invited = '".Database::escape_string($total_invited)."'
-		        WHERE c_id = $course_id AND code = '".Database::escape_string($survey_code)."'";
+		        WHERE
+		            c_id = $course_id AND
+		            code = '".Database::escape_string($survey_code)."'
+                ";
         Database::query($sql);
     }
 
@@ -3605,7 +3653,7 @@ class SurveyUtil
      * @author Julio Montoya, adding c_id fixes - Dec 2012
      * @version January 2007
      */
-    static function get_invited_users($survey_code, $course_code = '', $session_id = 0)
+    public static function get_invited_users($survey_code, $course_code = '', $session_id = 0)
     {
         if (!empty($course_code)) {
             $course_info = api_get_course_info($course_code);
@@ -3646,7 +3694,8 @@ class SurveyUtil
                     $defaults['additional_users'][] = $row['user'];
                 }
             }
-            if (isset($row['group_id'])) {
+
+            if (isset($row['group_id']) && !empty($row['group_id'])) {
                 $defaults['users'][] = 'GROUP:'.$row['group_id'];
             }
         }
@@ -3665,7 +3714,6 @@ class SurveyUtil
         if (!empty($defaults['additional_users'])) {
             $defaults['additional_users'] = implode(';', $defaults['additional_users']);
         }
-        //error_log(print_r($defaults, 1));
         return $defaults;
     }
 
@@ -4342,7 +4390,6 @@ class SurveyUtil
                     }
                     break;
                 case UserManager::USER_FIELD_TYPE_RADIO:
-
                     $field_list_array['extra_'.$field_details[1]]['name'] = $field_details[3];
                     if ($field_details[7] == 0) {
                         $field_list_array['extra_'.$field_details[1]]['visibility'] = 0;
@@ -4350,7 +4397,6 @@ class SurveyUtil
                         $field_list_array['extra_'.$field_details[1]]['visibility'] = 1;
                     }
                     break;
-
                 case UserManager::USER_FIELD_TYPE_SELECT:
                     $get_lang_variables = false;
                     if (in_array($field_details[1], array('mail_notify_message', 'mail_notify_invitation', 'mail_notify_group_message'))) {
@@ -4369,7 +4415,6 @@ class SurveyUtil
                         $field_list_array['extra_'.$field_details[1]]['visibility'] = 1;
                     }
                     break;
-
                 case UserManager::USER_FIELD_TYPE_SELECT_MULTIPLE:
                     $field_list_array['extra_'.$field_details[1]]['name'] = $field_details[3];
                     if ($field_details[7] == 0) {
@@ -4378,7 +4423,6 @@ class SurveyUtil
                         $field_list_array['extra_'.$field_details[1]]['visibility'] = 1;
                     }
                     break;
-
                 case UserManager::USER_FIELD_TYPE_DATE:
                     $field_list_array['extra_'.$field_details[1]]['name'] = $field_details[3];
                     if ($field_details[7] == 0) {
@@ -4387,7 +4431,6 @@ class SurveyUtil
                         $field_list_array['extra_'.$field_details[1]]['visibility'] = 1;
                     }
                     break;
-
                 case UserManager::USER_FIELD_TYPE_DATETIME:
                     $field_list_array['extra_'.$field_details[1]]['name'] = $field_details[3];
                     if ($field_details[7] == 0) {
@@ -4396,7 +4439,6 @@ class SurveyUtil
                         $field_list_array['extra_'.$field_details[1]]['visibility'] = 1;
                     }
                     break;
-
                 case UserManager::USER_FIELD_TYPE_DOUBLE_SELECT:
                     $field_list_array['extra_'.$field_details[1]]['name'] = $field_details[3];
                     if ($field_details[7] == 0) {
@@ -4432,7 +4474,6 @@ class SurveyUtil
 
         $course_id = api_get_course_int_id();
 
-
         $sql  = 'SELECT COUNT(*) as count FROM '.$table_survey_invitation.'
 		          WHERE user='.$user_id.' AND survey_code="'.$survey_code.'" AND answered="1" AND c_id = '.$course_id.' ';
 

+ 2 - 2
main/survey/survey.php

@@ -150,7 +150,7 @@ $survey_actions .= '<a href="'.api_get_path(WEB_CODE_PATH).'survey/reporting.php
 echo '<div class="actions">'.$survey_actions.'</div>';
 
 if ($survey_data['survey_type'] == 0) {
-	echo '<div class="actionsbig">';
+	echo '<div class="well actions">';
 	echo '<a style="padding-left:0px;" href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&amp;action=add&type=yesno&amp;survey_id='.$survey_id.'">'.Display::return_icon('yesno.png', get_lang('YesNo'), null, ICON_SIZE_BIG).'</a>';
 	echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&amp;action=add&type=multiplechoice&amp;survey_id='.$survey_id.'">'.Display::return_icon('mcua.png', get_lang('UniqueSelect'), null, ICON_SIZE_BIG).'<br /></a>';
 	echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&amp;action=add&type=multipleresponse&amp;survey_id='.$survey_id.'">'.Display::return_icon('mcma.png', get_lang('MultipleResponse'), null, ICON_SIZE_BIG).'</a>';
@@ -162,7 +162,7 @@ if ($survey_data['survey_type'] == 0) {
 	echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&amp;action=add&type=pagebreak&amp;survey_id='.$survey_id.'">'.Display::return_icon('page_end.png', get_lang('Pagebreak'), null, ICON_SIZE_BIG).'</a>';
 	echo '</div>';
 } else {
-	echo '<div class="actionsbig">';
+	echo '<div class="well actions">';
 	echo '<a style="padding-left:0px;" href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&amp;action=add&type=personality&amp;survey_id='.$survey_id.'"><img src="../img/yesno.gif" /></a></div>';
 	echo '</div>';
 }

+ 8 - 3
main/survey/survey_invite.php

@@ -235,14 +235,19 @@ if ($form->validate()) {
     $table_survey = Database :: get_course_table(TABLE_SURVEY);
 	// Counting the number of people that are invited
 	$sql = "SELECT * FROM $table_survey
-	        WHERE c_id = $course_id AND code = '".Database::escape_string($survey_data['code'])."'";
+	        WHERE
+	        	c_id = $course_id AND
+	        	code = '".Database::escape_string($survey_data['code'])."'
+			";
 	$result = Database::query($sql);
 	$row = Database::fetch_array($result);
 	$total_invited = $row['invited'];
     if ($total_invited > 0) {
-    	$message  = '<a href="'.api_get_path(WEB_CODE_PATH).'survey/survey_invitation.php?view=answered&amp;survey_id='.$survey_data['survey_id'].'">'.$survey_data['answered'].'</a> ';
+    	$message  = '<a href="'.api_get_path(WEB_CODE_PATH).'survey/survey_invitation.php?view=answered&amp;survey_id='.$survey_data['survey_id'].'">'.
+			$survey_data['answered'].'</a> ';
     	$message .= get_lang('HaveAnswered').' ';
-    	$message .= '<a href="'.api_get_path(WEB_CODE_PATH).'survey/survey_invitation.php?view=invited&amp;survey_id='.$survey_data['survey_id'].'">'.$total_invited.'</a> ';
+    	$message .= '<a href="'.api_get_path(WEB_CODE_PATH).'survey/survey_invitation.php?view=invited&amp;survey_id='.$survey_data['survey_id'].'">'.
+			$total_invited.'</a> ';
     	$message .= get_lang('WereInvited');
     	Display::display_normal_message($message, false);
     	Display::display_confirmation_message($total_count.' '.get_lang('InvitationsSend'));

+ 2 - 2
main/template/default/social/myfiles.tpl

@@ -12,7 +12,7 @@
         <div class="row">
             <div class="col-md-12">
                 <div id="message_ajax_reponse" class=""></div>
-            </div>-
+            </div>
         </div>
         <div class="row">
             {{ social_right_content}}
@@ -21,4 +21,4 @@
         {{ socialAutoExtendLink }}
     </div>
 </div>
-{% endblock %}
+{% endblock %}

+ 1 - 1
main/template/default/social/user_block.tpl

@@ -3,7 +3,7 @@
     <p class="lead">{{ user.complete_name }}</p>
     <p>
         <img src="{{ "instant_message.png" | icon }}" atl="{{ "Email" | get_lang }}">
-        {{ user.email}}  
+        {{ user.email}}
     </p>
     {% if user.user_is_online_in_chat != 0 %}
         <p>

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