Yannick Warnier 12 years ago
parent
commit
3a5025247e

+ 4 - 5
main/announcements/announcements.php

@@ -37,7 +37,7 @@ if(isset($_GET['id_session'])) {
 }
 
 /* ACCESS RIGHTS */
-api_protect_course_script();
+api_protect_course_script(true);
 
 // Configuration settings
 $display_announcement_list	 = true;
@@ -72,7 +72,6 @@ $course_id = api_get_course_int_id();
 /*	Tracking	*/
 event_access_tool(TOOL_ANNOUNCEMENT);
 
-
 /*	POST TO	*/
 $safe_emailTitle = $_POST['emailTitle'];
 $safe_newContent = $_POST['newContent'];
@@ -81,7 +80,7 @@ $content_to_modify = $title_to_modify 	= '';
 
 if (!empty($_POST['To'])) {
 	if (api_get_session_id()!=0 && api_is_allowed_to_session_edit(false,true)==false) {
-		api_not_allowed();
+		api_not_allowed(true);
 	}
 	$display_form = true;
 
@@ -115,7 +114,7 @@ if (!empty($_POST['To']) and ($select_groupusers_status=="show")) {
 // display the form
 if (((!empty($_GET['action']) && $_GET['action'] == 'add') && $_GET['origin'] == "") || (!empty($_GET['action']) && $_GET['action'] == 'edit') || !empty($_POST['To'])) {
 	if (api_get_session_id()!=0 && api_is_allowed_to_session_edit(false,true)==false) {
-		api_not_allowed();
+		api_not_allowed(true);
 	}
 	$display_form = true;
 }
@@ -1063,4 +1062,4 @@ if (isset($_GET['action']) && $_GET['action'] == 'view') {
 if (empty($_GET['origin']) or $_GET['origin'] !== 'learnpath') {
 	//we are not in learnpath tool
 	Display::display_footer();
-}
+}

+ 347 - 347
main/course_progress/thematic_controller.php

@@ -1,4 +1,5 @@
 <?php
+
 /* For licensing terms, see /license.txt */
 
 /**
@@ -16,118 +17,116 @@
  * the requested action
  * @package chamilo.course_progress 
  */
+class ThematicController {
+
+    /**
+     * Constructor
+     */
+    public function __construct() {
+        $this->toolname = 'course_progress';
+        $this->view = new View($this->toolname);
+    }
+
+    /**
+     * This method is used for thematic control (update, insert or listing)
+     * @param 	string	Action
+     * render to thematic.php 
+     */
+    public function thematic($action) {
+        $thematic = new Thematic();
+        $data = array();
+        $error = false;
+        $msg_add = false;
+
+        $check = Security::check_token('request');
+        $thematic_id = isset($_REQUEST['thematic_id']) ? intval($_REQUEST['thematic_id']) : null;
+
+        if ($check) {
+            switch ($action) {
+                case 'thematic_add':
+                case 'thematic_edit':
+                    // insert or update a thematic		
+                    if (strtoupper($_SERVER['REQUEST_METHOD']) == "POST") {
+                        if (trim($_POST['title']) !== '') {
+                            if (api_is_allowed_to_edit(null, true)) {
 
-class ThematicController
-{
-	
-	/**
-	 * Constructor
-	 */
-	public function __construct() {		
-		$this->toolname = 'course_progress';
-		$this->view = new View($this->toolname);			
-	}
-	
-	/**
-	 * This method is used for thematic control (update, insert or listing)
-	 * @param 	string	Action
-	 * render to thematic.php 
-	 */	
-	public function thematic($action) {		
-		$thematic = new Thematic();		        
-		$data     = array();		
-		$error    = false;
-		$msg_add  = false;
-		
-		$check = Security::check_token('request');		
-		$thematic_id = isset($_REQUEST['thematic_id'])?intval($_REQUEST['thematic_id']):null;
-		
-		if ($check) {
-    		switch ($action) {
-    		    case 'thematic_add':
-    		    case 'thematic_edit':    		        
-        			// insert or update a thematic		
-            		if (strtoupper($_SERVER['REQUEST_METHOD']) == "POST") {        						
-        				if (trim($_POST['title']) !== '') {        		    		
-                            if (api_is_allowed_to_edit(null, true)) {		
-                                		    						    			
-        		    			$id            = $_POST['thematic_id'];
-        		    			$title         = $_POST['title'];
-        		    			$content       = $_POST['content'];
-        		    			$session_id    = api_get_session_id();
-        		    			$thematic->set_thematic_attributes($id, $title, $content, $session_id);	    			
-        						$last_id       = $thematic->thematic_save();
-        						if ($_POST['action'] == 'thematic_add') {
-        							$action = 'thematic_details';
-        							$thematic_id = null;
-        							if ($last_id) {
-        								$data['last_id'] = $last_id;
-        							}
-        						} else {
-        							$action = 'thematic_details';
-        							$thematic_id = null;
-        						}
-                            }	
-        				} else {					
-        					$error = true;
-        					$data['error'] = $error;	
-        					$data['action'] = $_POST['action'];	
-        					$data['thematic_id'] = $_POST['thematic_id'];
-        					// render to the view
-        					$this->view->set_data($data);
-        					$this->view->set_layout('layout'); 
-        					$this->view->set_template('thematic');		       
-        					$this->view->render();					    						    									
-        				}        							    		
-            		}    		        
-    		        break;    		        
-    		    case 'thematic_copy':
+                                $id = $_POST['thematic_id'];
+                                $title = $_POST['title'];
+                                $content = $_POST['content'];
+                                $session_id = api_get_session_id();
+                                $thematic->set_thematic_attributes($id, $title, $content, $session_id);
+                                $last_id = $thematic->thematic_save();
+                                if ($_POST['action'] == 'thematic_add') {
+                                    $action = 'thematic_details';
+                                    $thematic_id = null;
+                                    if ($last_id) {
+                                        $data['last_id'] = $last_id;
+                                    }
+                                } else {
+                                    $action = 'thematic_details';
+                                    $thematic_id = null;
+                                }
+                            }
+                        } else {
+                            $error = true;
+                            $data['error'] = $error;
+                            $data['action'] = $_POST['action'];
+                            $data['thematic_id'] = $_POST['thematic_id'];
+                            // render to the view
+                            $this->view->set_data($data);
+                            $this->view->set_layout('layout');
+                            $this->view->set_template('thematic');
+                            $this->view->render();
+                        }
+                    }
+                    break;
+                case 'thematic_copy':
                     //Copy a thematic to a session
-    		        $thematic->copy($thematic_id);
-    		        $thematic_id = null;
-    		        $action = 'thematic_details';
-    		        break;
-    		    case 'thematic_delete_select':
-    		       //Delete many thematics
-        		    if (strtoupper($_SERVER['REQUEST_METHOD']) == "POST") {    		        
-        				if (api_is_allowed_to_edit(null, true)) {				
-        					$thematic_ids = $_POST['id'];
-        					$affected_rows = $thematic->thematic_destroy($thematic_ids);
-        				}
-        				$action = 'thematic_details';
-        			}
-    		        break;
+                    $thematic->copy($thematic_id);
+                    $thematic_id = null;
+                    $action = 'thematic_details';
+                    break;
+                case 'thematic_delete_select':
+                    //Delete many thematics
+                    if (strtoupper($_SERVER['REQUEST_METHOD']) == "POST") {
+                        if (api_is_allowed_to_edit(null, true)) {
+                            $thematic_ids = $_POST['id'];
+                            $affected_rows = $thematic->thematic_destroy($thematic_ids);
+                        }
+                        $action = 'thematic_details';
+                    }
+                    break;
                 case 'thematic_delete':
                     // Delete a thematic
-                    if (isset($thematic_id)) {	
+                    if (isset($thematic_id)) {
                         if (api_is_allowed_to_edit(null, true)) {
-        				    $affected_rows = $thematic->thematic_destroy($thematic_id);
+                            $affected_rows = $thematic->thematic_destroy($thematic_id);
                         }
                         $thematic_id = null;
-        				$action = 'thematic_details';
+                        $action = 'thematic_details';
                     }
                     break;
                 case 'thematic_import_select':
                     break;
                 case 'thematic_import':
                     $csv_import_array = Import::csv_to_array($_FILES['file']['tmp_name'], 'horizontal');
-                    
+
                     if (isset($_POST['replace']) && $_POST['replace']) {
                         // Remove current thematic.
                         $list = $thematic->get_thematic_list();
                         foreach ($list as $i) {
                             $thematic->thematic_destroy($i);
-                        }                        
+                        }
                     }
-                    
+
                     // Import the progress.
                     $current_thematic = null;
-                    
+
                     foreach ($csv_import_array as $data) {
-                        foreach ($data as $key => $item) {                            
+                        foreach ($data as $key => $item) {
                             if ($key == 'title') {
-                                $thematic->set_thematic_attributes(null, $item[0], $item[1], api_get_session_id ());
-                                $current_thematic = $thematic->thematic_save ();
+                                $thematic->set_thematic_attributes(null, $item[0], $item[1], api_get_session_id());
+                                $current_thematic = $thematic->thematic_save();
                                 $description_type = 0;
                             }
                             if ($key == 'plan') {
@@ -136,9 +135,9 @@ class ThematicController
                                 $description_type++;
                             }
                             if ($key == 'progress') {
-                                $thematic->set_thematic_advance_attributes (null, $current_thematic, 0, $item[2], $item[0], $item[1]);
-                                $thematic->thematic_advance_save ();
-                            }                      
+                                $thematic->set_thematic_advance_attributes(null, $current_thematic, 0, $item[2], $item[0], $item[1]);
+                                $thematic->thematic_advance_save();
+                            }
                         }
                     }
                     $action = 'thematic_details';
@@ -147,14 +146,14 @@ class ThematicController
                     $list = $thematic->get_thematic_list();
                     $csv = array();
                     foreach ($list as $theme) {
-                        $csv[] = array ('title', $theme['title'], $theme['content']);
-                        $data = $thematic->get_thematic_plan_data ($theme['id']);
+                        $csv[] = array('title', $theme['title'], $theme['content']);
+                        $data = $thematic->get_thematic_plan_data($theme['id']);
                         if (!empty($data)) {
                             foreach ($data as $plan) {
-                                $csv[] = array ('plan', $plan['title'], $plan['description']);
+                                $csv[] = array('plan', $plan['title'], $plan['description']);
                             }
                         }
-                        $data = $thematic->get_thematic_advance_by_thematic_id ($theme['id']);
+                        $data = $thematic->get_thematic_advance_by_thematic_id($theme['id']);
                         if (!empty($data)) {
                             foreach ($data as $advance) {
                                 $csv[] = array('progress', $advance['start_date'], $advance['duration'], $advance['content']);
@@ -166,306 +165,307 @@ class ThematicController
                     // Don't continue building a normal page.
                     return;
                 case 'thematic_export_pdf':
-                    $list = $thematic->get_thematic_list();                    
+                    $list = $thematic->get_thematic_list();
                     $table = array();
-                    $table[] = array (get_lang('Thematic'), get_lang('ThematicPlan'), get_lang('ThematicAdvance'));
-                    foreach ($list as $theme) {                        
+                    $table[] = array(get_lang('Thematic'), get_lang('ThematicPlan'), get_lang('ThematicAdvance'));
+                    foreach ($list as $theme) {
                         $data = $thematic->get_thematic_plan_data($theme['id']);
                         $plan_html = null;
                         if (!empty($data)) {
                             foreach ($data as $plan) {
-                                $plan_html .= '<strong>'.$plan['title']. '</strong><br /> '.$plan['description'].'<br />';
+                                $plan_html .= '<strong>' . $plan['title'] . '</strong><br /> ' . $plan['description'] . '<br />';
                             }
                         }
-                        $data = $thematic->get_thematic_advance_by_thematic_id ($theme['id']);
+                        $data = $thematic->get_thematic_advance_by_thematic_id($theme['id']);
                         $advance_html = null;
                         if (!empty($data)) {
-                            foreach ($data as $advance) {
-                                $advance_html .= api_convert_and_format_date($advance['start_date'], DATE_TIME_FORMAT_LONG).' '.$advance['duration'].'<br />'.$advance['content'].'<br />';
+                            foreach ($data as $advance) {                                
+                                //DATE_TIME_FORMAT_LONG
+                                $advance_html .= api_convert_and_format_date($advance['start_date'], DATE_FORMAT_ONLY_DAYNAME) . ' ('.$advance['duration'].' '.get_lang('HourShort').')<br />'.$advance['content'].'<br />';
                             }
-                        }                        
+                        }
                         $table[] = array($theme['title'], $plan_html, $advance_html);
-                    }                    
+                    }
                     $params = array(
-                        'filename' => get_lang('Thematic').'-'.api_get_local_time(),
+                        'filename' => get_lang('Thematic') . '-' . api_get_local_time(),
                         'pdf_title' => get_lang('Thematic'),
                         'add_signatures' => true,
                         'format' => 'A4-L',
-                        'orientation' =>    'L'
-                    );
-                  
+                        'orientation' => 'L'
+                    );                    
                     Export::export_table_pdf($table, $params);
                     break;
                 case 'moveup':
                     $thematic->move_thematic('up', $thematic_id);
-    				$action = 'thematic_details';
-    				$thematic_id = null;                
+                    $action = 'thematic_details';
+                    $thematic_id = null;
                     break;
                 case 'movedown':
                     $thematic->move_thematic('down', $thematic_id);
-    				$action = 'thematic_details';
-    				$thematic_id = null;
-                    break;               
-    		}
-    		Security::clear_token();	
-		} else {
-		    $action = 'thematic_details';
-		    $thematic_id = null;
-		}
-		if (isset($thematic_id)) {	
-			$data['thematic_data'] = $thematic->get_thematic_list($thematic_id);				
-			$data['thematic_id']   = $thematic_id;										
-		}
-
-		if ($action == 'thematic_details') {			
-			if (isset($thematic_id)) {
-				  $thematic_data_result = $thematic->get_thematic_list($thematic_id);				  
-				  if (!empty($thematic_data_result)) {
-				      $thematic_data[$thematic_id] = $thematic_data_result;      
-				  }
-				$data['total_average_of_advances']  = $thematic->get_average_of_advances_by_thematic($thematic_id);				
-			} else {
-				$thematic_data                      = $thematic->get_thematic_list(null, api_get_course_id(), api_get_session_id());	
-				$data['max_thematic_item']          = $thematic->get_max_thematic_item();				
-				$data['last_done_thematic_advance'] = $thematic->get_last_done_thematic_advance();
-				$data['total_average_of_advances']  = $thematic->get_total_average_of_thematic_advances();
-			}
-            
+                    $action = 'thematic_details';
+                    $thematic_id = null;
+                    break;
+            }
+            Security::clear_token();
+        } else {
+            $action = 'thematic_details';
+            $thematic_id = null;
+        }
+        if (isset($thematic_id)) {
+            $data['thematic_data'] = $thematic->get_thematic_list($thematic_id);
+            $data['thematic_id'] = $thematic_id;
+        }
+
+        if ($action == 'thematic_details') {
+            if (isset($thematic_id)) {
+                $thematic_data_result = $thematic->get_thematic_list($thematic_id);
+                if (!empty($thematic_data_result)) {
+                    $thematic_data[$thematic_id] = $thematic_data_result;
+                }
+                $data['total_average_of_advances'] = $thematic->get_average_of_advances_by_thematic($thematic_id);
+            } else {
+                $thematic_data = $thematic->get_thematic_list(null, api_get_course_id(), api_get_session_id());
+                $data['max_thematic_item'] = $thematic->get_max_thematic_item();
+                $data['last_done_thematic_advance'] = $thematic->get_last_done_thematic_advance();
+                $data['total_average_of_advances'] = $thematic->get_total_average_of_thematic_advances();
+            }
+
             //Second column
-			$thematic_plan_data              = $thematic->get_thematic_plan_data();   			 
-                   
+            $thematic_plan_data = $thematic->get_thematic_plan_data();
+
             //Third column
-			$thematic_advance_data           = $thematic->get_thematic_advance_list(null, null, true);
-			
-			$data['thematic_plan_div']       = $thematic->get_thematic_plan_div($thematic_plan_data);
-			
-			$data['thematic_advance_div']    = $thematic->get_thematic_advance_div($thematic_advance_data);
-			
-			
-			$data['thematic_plan_data']      = $thematic_plan_data;			
-			$data['thematic_advance_data']   = $thematic_advance_data;
-			$data['thematic_data']           = $thematic_data;
-		}
-        
-        $data['default_thematic_plan_title'] = $thematic->get_default_thematic_plan_title();        
-
-		$data['action'] = $action;		
-		// render to the view
-		$this->view->set_data($data);
-		$this->view->set_layout('layout'); 
-		$this->view->set_template('thematic');		       
-		$this->view->render();		
-	}
-	
-	/**
-	 * This method is used for thematic plan control (update, insert or listing)
-	 * @param 	string	Action
-	 * render to thematic_plan.php 
-	 */	
-	public function thematic_plan($action) {
-		$thematic= new Thematic();
-	 
-		$data  = array();
-		$error = false;
-	
-		if (strtoupper($_SERVER['REQUEST_METHOD']) == "POST") {   
-    		if (isset($_POST['action']) && ($_POST['action'] == 'thematic_plan_add' || $_POST['action'] == 'thematic_plan_edit')) {            
+            $thematic_advance_data = $thematic->get_thematic_advance_list(null, null, true);
+
+            $data['thematic_plan_div'] = $thematic->get_thematic_plan_div($thematic_plan_data);
+
+            $data['thematic_advance_div'] = $thematic->get_thematic_advance_div($thematic_advance_data);
+
+
+            $data['thematic_plan_data'] = $thematic_plan_data;
+            $data['thematic_advance_data'] = $thematic_advance_data;
+            $data['thematic_data'] = $thematic_data;
+        }
+
+        $data['default_thematic_plan_title'] = $thematic->get_default_thematic_plan_title();
+
+        $data['action'] = $action;
+        // render to the view
+        $this->view->set_data($data);
+        $this->view->set_layout('layout');
+        $this->view->set_template('thematic');
+        $this->view->render();
+    }
+
+    /**
+     * This method is used for thematic plan control (update, insert or listing)
+     * @param 	string	Action
+     * render to thematic_plan.php 
+     */
+    public function thematic_plan($action) {
+        $thematic = new Thematic();
+
+        $data = array();
+        $error = false;
+
+        if (strtoupper($_SERVER['REQUEST_METHOD']) == "POST") {
+            if (isset($_POST['action']) && ($_POST['action'] == 'thematic_plan_add' || $_POST['action'] == 'thematic_plan_edit')) {
                 if (isset($_POST['title'])) {
                     if ($_POST['thematic_plan_token'] == $_SESSION['thematic_plan_token']) {
-                        if (api_is_allowed_to_edit(null, true)) {  
-                            
-                            $title_list         = $_REQUEST['title'];
+                        if (api_is_allowed_to_edit(null, true)) {
+
+                            $title_list = $_REQUEST['title'];
                             //$description_list   = $_REQUEST['desc'];
-                            $description_list   = $_REQUEST['description'];
-                            $description_type   = $_REQUEST['description_type'];
-                            for($i=1;$i<count($title_list)+1; $i++) {
+                            $description_list = $_REQUEST['description'];
+                            $description_type = $_REQUEST['description_type'];
+                            for ($i = 1; $i < count($title_list) + 1; $i++) {
                                 $thematic->set_thematic_plan_attributes($_REQUEST['thematic_id'], $title_list[$i], $description_list[$i], $description_type[$i]);
                                 $affected_rows = $thematic->thematic_plan_save();
-                            }                            
-            				unset($_SESSION['thematic_plan_token']);                    	        	
+                            }
+                            unset($_SESSION['thematic_plan_token']);
                             $data['message'] = 'ok';
                         }
                         $data['action'] = 'thematic_plan_list';
-            		}
-                } else {                         		
-					$error = true;
-					$action                        = $_POST['action'];
-					$data['error']                 = $error;						
-					$data['thematic_plan_data']    = $thematic->get_thematic_plan_data($_POST['thematic_id'], $_POST['description_type']);
-					$data['thematic_id']           = $_POST['thematic_id'];
-					$data['description_type']      = $_POST['description_type'];
-					$data['action']                = $action;
-					$data['default_thematic_plan_title']       = $thematic->get_default_thematic_plan_title();
-					$data['default_thematic_plan_icon']        = $thematic->get_default_thematic_plan_icon();
-					$data['default_thematic_plan_question']    = $thematic->get_default_question();
-					$data['next_description_type']             = $thematic->get_next_description_type($_POST['thematic_id']);
-							
-					// render to the view
-					$this->view->set_data($data);
-					$this->view->set_layout('layout'); 
-					$this->view->set_template('thematic_plan');		       
-					$this->view->render();               									    															
-    			}	    			
+                    }
+                } else {
+                    $error = true;
+                    $action = $_POST['action'];
+                    $data['error'] = $error;
+                    $data['thematic_plan_data'] = $thematic->get_thematic_plan_data($_POST['thematic_id'], $_POST['description_type']);
+                    $data['thematic_id'] = $_POST['thematic_id'];
+                    $data['description_type'] = $_POST['description_type'];
+                    $data['action'] = $action;
+                    $data['default_thematic_plan_title'] = $thematic->get_default_thematic_plan_title();
+                    $data['default_thematic_plan_icon'] = $thematic->get_default_thematic_plan_icon();
+                    $data['default_thematic_plan_question'] = $thematic->get_default_question();
+                    $data['next_description_type'] = $thematic->get_next_description_type($_POST['thematic_id']);
+
+                    // render to the view
+                    $this->view->set_data($data);
+                    $this->view->set_layout('layout');
+                    $this->view->set_template('thematic_plan');
+                    $this->view->render();
+                }
             }
-		}		
-    							
-        											
-    	if ($action == 'thematic_plan_list') {
-    		$data['thematic_plan_data'] = $thematic->get_thematic_plan_data($thematic_id);            
-    	}		
-    	$thematic_id = intval($_GET['thematic_id']);
-    	$description_type = intval($_GET['description_type']);
-    
-    	if (!empty($thematic_id) && !empty($description_type)) {
-    		if ($action == 'thematic_plan_delete') {   
+        }
+
+
+        if ($action == 'thematic_plan_list') {
+            $data['thematic_plan_data'] = $thematic->get_thematic_plan_data($thematic_id);
+        }
+        $thematic_id = intval($_GET['thematic_id']);
+        $description_type = intval($_GET['description_type']);
+
+        if (!empty($thematic_id) && !empty($description_type)) {
+            if ($action == 'thematic_plan_delete') {
                 if (api_is_allowed_to_edit(null, true)) {
                     $affected_rows = $thematic->thematic_plan_destroy($thematic_id, $description_type);
-                }				
-    			$data['thematic_plan_data'] = $thematic->get_thematic_plan_data($thematic_id);
-    			$action = 'thematic_plan_list';
-    		} else {         
-    			$data['thematic_plan_data'] = $thematic->get_thematic_plan_data($thematic_id, $description_type);	
-    		}											
-    		$data['thematic_id'] = $thematic_id;
-    		$data['description_type'] = $description_type;							
-    	} else if (!empty($thematic_id) && $action == 'thematic_plan_list') { 
-    		$data['thematic_plan_data'] = $thematic->get_thematic_plan_data($thematic_id);
-    		$data['thematic_id'] = $thematic_id;
-    	}
-    	              
-    	$data['thematic_id'] = $thematic_id;
-    	$data['action'] = $action;
-    	$data['default_thematic_plan_title']      = $thematic->get_default_thematic_plan_title();
-    	$data['default_thematic_plan_icon']       = $thematic->get_default_thematic_plan_icon();		
-    	$data['next_description_type']            = $thematic->get_next_description_type($thematic_id);		
-    	$data['default_thematic_plan_question']   = $thematic->get_default_question();        
-        $data['thematic_data']                    = $thematic->get_thematic_list($thematic_id);
-        
-		//render to the view
-    	$this->view->set_data($data);
-    	$this->view->set_layout('layout'); 
-    	$this->view->set_template('thematic_plan');		       
-    	$this->view->render();
+                }
+                $data['thematic_plan_data'] = $thematic->get_thematic_plan_data($thematic_id);
+                $action = 'thematic_plan_list';
+            } else {
+                $data['thematic_plan_data'] = $thematic->get_thematic_plan_data($thematic_id, $description_type);
+            }
+            $data['thematic_id'] = $thematic_id;
+            $data['description_type'] = $description_type;
+        } else if (!empty($thematic_id) && $action == 'thematic_plan_list') {
+            $data['thematic_plan_data'] = $thematic->get_thematic_plan_data($thematic_id);
+            $data['thematic_id'] = $thematic_id;
+        }
+
+        $data['thematic_id'] = $thematic_id;
+        $data['action'] = $action;
+        $data['default_thematic_plan_title'] = $thematic->get_default_thematic_plan_title();
+        $data['default_thematic_plan_icon'] = $thematic->get_default_thematic_plan_icon();
+        $data['next_description_type'] = $thematic->get_next_description_type($thematic_id);
+        $data['default_thematic_plan_question'] = $thematic->get_default_question();
+        $data['thematic_data'] = $thematic->get_thematic_list($thematic_id);
+
+        //render to the view
+        $this->view->set_data($data);
+        $this->view->set_layout('layout');
+        $this->view->set_template('thematic_plan');
+        $this->view->render();
         exit;
     }
-    	
+
     /**
      * This method is used for thematic advance control (update, insert or listing)
      * @param 	string	Action
      * render to thematic_advance.php 
-     */	
+     */
     public function thematic_advance($action) {
-    	
-    	$thematic= new Thematic();	
-    	$attendance = new Attendance();
-    	$data = array();
-    			
-    	// get data for attendance input select		
-    	$attendance_list = $attendance->get_attendances_list();		
-    	$attendance_select = array();
-    	$attendance_select[0] = get_lang('SelectAnAttendance');
-    	foreach ($attendance_list as $attendance_id => $attendance_data) {
-    		$attendance_select[$attendance_id] = $attendance_data['name'];
-    	}
-
-		$thematic_id = intval($_REQUEST['thematic_id']);
-		$thematic_advance_id = intval($_REQUEST['thematic_advance_id']);
-        
-		$thematic_advance_data = array();
-		
-            switch ($action) {
-                case 'thematic_advance_delete':
-                    if (!empty($thematic_advance_id)) {	
-                        if (api_is_allowed_to_edit(null, true)) {
-                            $affected_rows = $thematic->thematic_advance_destroy($thematic_advance_id);
-                        }
-                        $action = 'thematic_list';										
-                        header('Location: index.php');
-                        exit;	
+
+        $thematic = new Thematic();
+        $attendance = new Attendance();
+        $data = array();
+
+        // get data for attendance input select		
+        $attendance_list = $attendance->get_attendances_list();
+        $attendance_select = array();
+        $attendance_select[0] = get_lang('SelectAnAttendance');
+        foreach ($attendance_list as $attendance_id => $attendance_data) {
+            $attendance_select[$attendance_id] = $attendance_data['name'];
+        }
+
+        $thematic_id = intval($_REQUEST['thematic_id']);
+        $thematic_advance_id = intval($_REQUEST['thematic_advance_id']);
+
+        $thematic_advance_data = array();
+
+        switch ($action) {
+            case 'thematic_advance_delete':
+                if (!empty($thematic_advance_id)) {
+                    if (api_is_allowed_to_edit(null, true)) {
+                        $affected_rows = $thematic->thematic_advance_destroy($thematic_advance_id);
                     }
-                    break;
-                case 'thematic_advance_list':
-                    if (!api_is_allowed_to_edit(null, true)) {
-                        echo '';
-                        exit;
+                    $action = 'thematic_list';
+                    header('Location: index.php');
+                    exit;
+                }
+                break;
+            case 'thematic_advance_list':
+                if (!api_is_allowed_to_edit(null, true)) {
+                    echo '';
+                    exit;
+                }
+
+                if (($_REQUEST['start_date_type'] == 1 && empty($_REQUEST['start_date_by_attendance'])) || (!empty($_REQUEST['duration_in_hours']) && !is_numeric($_REQUEST['duration_in_hours']))) {
+                    if ($_REQUEST['start_date_type'] == 1 && empty($_REQUEST['start_date_by_attendance'])) {
+                        $start_date_error = true;
+                        $data['start_date_error'] = $start_date_error;
                     }
 
-                    if (($_REQUEST['start_date_type'] == 1 && empty($_REQUEST['start_date_by_attendance'])) || (!empty($_REQUEST['duration_in_hours']) && !is_numeric($_REQUEST['duration_in_hours'])) ) {	    			
-                        if ($_REQUEST['start_date_type'] == 1 && empty($_REQUEST['start_date_by_attendance'])) {
-                            $start_date_error = true;
-                            $data['start_date_error'] = $start_date_error;	
-                        } 
+                    if (!empty($_REQUEST['duration_in_hours']) && !is_numeric($_REQUEST['duration_in_hours'])) {
+                        $duration_error = true;
+                        $data['duration_error'] = $duration_error;
+                    }
 
-                        if (!empty($_REQUEST['duration_in_hours']) && !is_numeric($_REQUEST['duration_in_hours'])) {
-                            $duration_error = true;
-                            $data['duration_error'] = $duration_error;	
-                        }
+                    $data['action'] = $_REQUEST['action'];
+                    $data['thematic_id'] = $_REQUEST['thematic_id'];
+                    $data['attendance_select'] = $attendance_select;
+                    if (isset($_REQUEST['thematic_advance_id'])) {
+                        $data['thematic_advance_id'] = $_REQUEST['thematic_advance_id'];
+                        $thematic_advance_data = $thematic->get_thematic_advance_list($_REQUEST['thematic_advance_id']);
+                        $data['thematic_advance_data'] = $thematic_advance_data;
+                    }
+                } else {
+                    if ($_REQUEST['thematic_advance_token'] == $_SESSION['thematic_advance_token'] && api_is_allowed_to_edit(null, true)) {
 
-                        $data['action'] = $_REQUEST['action'];	
-                        $data['thematic_id'] = $_REQUEST['thematic_id'];				
-                        $data['attendance_select'] = $attendance_select;					
-                        if (isset($_REQUEST['thematic_advance_id'])) {
-                            $data['thematic_advance_id'] = $_REQUEST['thematic_advance_id'];
-                            $thematic_advance_data = $thematic->get_thematic_advance_list($_REQUEST['thematic_advance_id']);
-                            $data['thematic_advance_data'] = $thematic_advance_data;		
-                        }	    			
-                    } else {   				
-                        if ($_REQUEST['thematic_advance_token'] == $_SESSION['thematic_advance_token'] && api_is_allowed_to_edit(null, true)) {    	
-
-                            $thematic_advance_id 	= $_REQUEST['thematic_advance_id'];
-                            $thematic_id 			= $_REQUEST['thematic_id'];	    			
-                            $content 				= $_REQUEST['content'];
-                            $duration				= $_REQUEST['duration_in_hours'];
-                            if (isset($_REQUEST['start_date_type']) && $_REQUEST['start_date_type'] == 2) {
-                                $start_date 	= $thematic->build_datetime_from_array($_REQUEST['custom_start_date']);
-                                $attendance_id 	= 0;	
-                            } else {
-                                $start_date 	= $_REQUEST['start_date_by_attendance'];
-                                $attendance_id 	= $_REQUEST['attendance_select'];
-                            }		    			
-                            $thematic->set_thematic_advance_attributes($thematic_advance_id, $thematic_id,  $attendance_id, $content, $start_date, $duration);	    				    								
-                            $affected_rows = $thematic->thematic_advance_save();			        	
-                            if ($affected_rows) {
-                                // get last done thematic advance before move thematic list
-                                $last_done_thematic_advance = $thematic->get_last_done_thematic_advance();
-                                // update done advances with de current thematic list
-                                if (!empty($last_done_thematic_advance)) {
-                                    $update_done_advances = $thematic->update_done_thematic_advances($last_done_thematic_advance);
-                                }
+                        $thematic_advance_id = $_REQUEST['thematic_advance_id'];
+                        $thematic_id = $_REQUEST['thematic_id'];
+                        $content = $_REQUEST['content'];
+                        $duration = $_REQUEST['duration_in_hours'];
+                        if (isset($_REQUEST['start_date_type']) && $_REQUEST['start_date_type'] == 2) {
+                            $start_date = $thematic->build_datetime_from_array($_REQUEST['custom_start_date']);
+                            $attendance_id = 0;
+                        } else {
+                            $start_date = $_REQUEST['start_date_by_attendance'];
+                            $attendance_id = $_REQUEST['attendance_select'];
+                        }
+                        $thematic->set_thematic_advance_attributes($thematic_advance_id, $thematic_id, $attendance_id, $content, $start_date, $duration);
+                        $affected_rows = $thematic->thematic_advance_save();
+                        if ($affected_rows) {
+                            // get last done thematic advance before move thematic list
+                            $last_done_thematic_advance = $thematic->get_last_done_thematic_advance();
+                            // update done advances with de current thematic list
+                            if (!empty($last_done_thematic_advance)) {
+                                $update_done_advances = $thematic->update_done_thematic_advances($last_done_thematic_advance);
                             }
                         }
                     }
-                    break;
-                default:
-                    $thematic_advance_data = $thematic->get_thematic_advance_list($thematic_advance_id);	
-                    break;	
+                }
+                break;
+            default:
+                $thematic_advance_data = $thematic->get_thematic_advance_list($thematic_advance_id);
+                break;
+        }
+
+
+        // get calendar select by attendance id
+        $calendar_select = array();
+        if (!empty($thematic_advance_data)) {
+            if (!empty($thematic_advance_data['attendance_id'])) {
+                $attendance_calendar = $attendance->get_attendance_calendar($thematic_advance_data['attendance_id']);
+                if (!empty($attendance_calendar)) {
+                    foreach ($attendance_calendar as $calendar) {
+                        $calendar_select[$calendar['date_time']] = $calendar['date_time'];
+                    }
+                }
             }
-		
-		
-		// get calendar select by attendance id
-		$calendar_select = array();
-		if (!empty($thematic_advance_data)) {			
-			if (!empty($thematic_advance_data['attendance_id'])) {
-				$attendance_calendar = $attendance->get_attendance_calendar($thematic_advance_data['attendance_id']);				
-				if (!empty($attendance_calendar)) {								
-					foreach ($attendance_calendar as $calendar) {
-						$calendar_select[$calendar['date_time']] = $calendar['date_time'];	
-					}					
-				}
-			}			
-		}
-		
-		$data['action']                = $action;
-		$data['thematic_id']           = $thematic_id;
-		$data['thematic_advance_id']   = $thematic_advance_id;
-		$data['attendance_select']     = $attendance_select;
-		$data['thematic_advance_data'] = $thematic_advance_data;
-		$data['calendar_select']       = $calendar_select;
-		
-		// render to the view
-		$this->view->set_data($data);
-		$this->view->set_layout('layout'); 
-		$this->view->set_template('thematic_advance');		       
-		$this->view->render();		
-	}
+        }
+
+        $data['action'] = $action;
+        $data['thematic_id'] = $thematic_id;
+        $data['thematic_advance_id'] = $thematic_advance_id;
+        $data['attendance_select'] = $attendance_select;
+        $data['thematic_advance_data'] = $thematic_advance_data;
+        $data['calendar_select'] = $calendar_select;
+
+        // render to the view
+        $this->view->set_data($data);
+        $this->view->set_layout('layout');
+        $this->view->set_template('thematic_advance');
+        $this->view->render();
+    }
+
 }

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

@@ -67,20 +67,22 @@ function build_directory_selector($folders, $document_id, $group_dir = '', $chan
                 }
             }
         }
-    } else {        
-        foreach ($folders as $folder_id => & $folder) {
-            $selected = ($document_id == $folder_id) ? ' selected="selected"' : '';
-            $label = $folder_titles[$folder];
-            if ($folder == $group_dir) {
-                $label = get_lang('Documents');
-            } else {
-                $path_parts = explode('/', str_replace($group_dir, '', $folder));
-                $label = cut($label, 80);
-                $label = str_repeat('&nbsp;&nbsp;&nbsp;', count($path_parts) - 2).' &mdash; '.$label;
-            }
-            $parent_select -> addOption($label, $folder_id);
-            if ($selected != '') {
-                $parent_select->setSelected($folder_id);
+    } else {
+        if (!empty($folders)) {
+            foreach ($folders as $folder_id => & $folder) {
+                $selected = ($document_id == $folder_id) ? ' selected="selected"' : '';
+                $label = $folder_titles[$folder];
+                if ($folder == $group_dir) {
+                    $label = get_lang('Documents');
+                } else {
+                    $path_parts = explode('/', str_replace($group_dir, '', $folder));
+                    $label = cut($label, 80);
+                    $label = str_repeat('&nbsp;&nbsp;&nbsp;', count($path_parts) - 2).' &mdash; '.$label;
+                }
+                $parent_select -> addOption($label, $folder_id);
+                if ($selected != '') {
+                    $parent_select->setSelected($folder_id);
+                }
             }
         }
     }

+ 1 - 1
main/document/document.php

@@ -90,7 +90,7 @@ $dbl_click_id = 0; // Used for avoiding double-click
 $selectcat = isset($_GET['selectcat']) ? Security::remove_XSS($_GET['selectcat']) : null;
 
 /* 	Constants and variables */
-$session_id = api_get_session_id();
+$session_id  = api_get_session_id();
 $course_code = api_get_course_id();
 $to_group_id = api_get_group_id();
 

+ 21 - 9
main/forum/forumfunction.inc.php

@@ -507,23 +507,33 @@ function store_forumcategory($values) {
  * @version february 2006, dokeos 1.8
  */
 function store_forum($values) {
-    global $_course;
-    global $_user;
+    global $_course;    
+    
     $course_id = api_get_course_int_id();
+    $session_id = api_get_session_id();
+    
+    if (isset($values['group_id']) && !empty($values['group_id'])) {
+        $group_id = $values['group_id'];
+    } else {
+        $group_id = api_get_group_id();
+    }
+    
     $table_forums = Database::get_course_table(TABLE_FORUM);
 
     // Find the max forum_order for the given category. The new forum is added at the end => max cat_order + &
     if (is_null($values['forum_category'])) {
         $new_max = null;
     } else {
-        $sql = "SELECT MAX(forum_order) as sort_max FROM ".$table_forums."
-        		WHERE c_id = $course_id AND forum_category='".Database::escape_string($values['forum_category'])."'";
+        $sql = "SELECT MAX(forum_order) as sort_max 
+                FROM ".$table_forums."
+        		WHERE c_id = $course_id AND 
+                      forum_category='".Database::escape_string($values['forum_category'])."'";
         $result = Database::query($sql);
         $row = Database::fetch_array($result);
         $new_max = $row['sort_max'] + 1;
     }
 
-    $session_id = api_get_session_id();
+    
     $clean_title = Database::escape_string($values['forum_title']);
 
     // Forum images
@@ -595,8 +605,10 @@ function store_forum($values) {
                 forum_of_group='".	Database::escape_string($values['group_forum'])."'
             WHERE c_id = $course_id AND forum_id='".Database::escape_string($values['forum_id'])."'";
             Database::query($sql);
-
-            api_item_property_update($_course, TOOL_FORUM, Database::escape_string($values['forum_id']), 'ForumUpdated', api_get_user_id());
+            
+           
+            api_item_property_update($_course, TOOL_FORUM, Database::escape_string($values['forum_id']), 'ForumUpdated', api_get_user_id(), $group_id);
+            
             $return_message = get_lang('ForumEdited');
     } else {
         $sql_image = '';
@@ -626,8 +638,8 @@ function store_forum($values) {
         Database::query($sql);
         $last_id = Database::insert_id();
         if ($last_id > 0) {
-            api_item_property_update($_course, TOOL_FORUM, $last_id, 'ForumAdded', api_get_user_id());
-            api_set_default_visibility($last_id, TOOL_FORUM);
+            api_item_property_update($_course, TOOL_FORUM, $last_id, 'ForumAdded', api_get_user_id(), $group_id);
+            api_set_default_visibility($last_id, TOOL_FORUM, $group_id);
         }
         $return_message = get_lang('ForumAdded');
     }

+ 1 - 1
main/gradebook/index.php

@@ -386,7 +386,7 @@ $course_id = api_get_course_int_id();
 
 if (isset ($_GET['deletelink'])) {
 	block_students();
-	$get_delete_link=Security::remove_XSS($_GET['deletelink']);
+	$get_delete_link = intval($_GET['deletelink']);
 	//fixing #5229
 	if (!empty($get_delete_link)) {
 		$link= LinkFactory :: load($get_delete_link);

+ 1 - 2
main/gradebook/lib/fe/flatviewtable.class.php

@@ -403,7 +403,7 @@ class FlatViewTable extends SortableTable
 	/**
 	 * Function used by SortableTable to get total number of items in the table
 	 */
-	function get_total_number_of_items () {
+	function get_total_number_of_items() {
 		return $this->datagen->get_total_users_count();
 	}
 
@@ -488,7 +488,6 @@ class FlatViewTable extends SortableTable
 			$column++;
 		}
 
-		//$this->set_header($column++, get_lang('Total'));	
 		$data_array = $this->datagen->get_data($users_sorting, $from, $this->per_page, $this->offset, $selectlimit);
 
 		$table_data = array();

+ 29 - 18
main/gradebook/lib/flatview_data_generator.class.php

@@ -322,15 +322,21 @@ class FlatViewDataGenerator
                     $item_value     = $percentage*$item_value;                    
                     $item_total		+= $sub_cat->get_weight();
                     
-                    if ($convert_using_the_global_weight) {
-                        //$score[0] = $main_weight*$score[0]/$sub_cat->get_weight();                        
+                    if ($convert_using_the_global_weight) {                                             
                         $score[0] = $score[0]/$main_weight*$sub_cat->get_weight();                        
                         $score[1] = $main_weight ;
-                    }
-                    
-                    $real_score = $scoredisplay->display_score($real_score, SCORE_DIV_PERCENT, SCORE_ONLY_SCORE);                    
-                    $temp_score = $scoredisplay->display_score($score, SCORE_DIV_SIMPLE_WITH_CUSTOM);
-                    $temp_score = Display::tip($temp_score, $real_score);
+                    }                    
+                                        
+                    if (api_get_setting('gradebook_show_percentage_in_reports') == 'false') {
+                    //if (true) {
+                        $real_score = $scoredisplay->display_score($real_score, SCORE_SIMPLE);    
+                        $temp_score = $scoredisplay->display_score($score, SCORE_DIV_SIMPLE_WITH_CUSTOM);                        
+                        $temp_score = Display::tip($real_score, $temp_score);
+                    } else {                        
+                        $real_score = $scoredisplay->display_score($real_score, SCORE_DIV_PERCENT, SCORE_ONLY_SCORE);                    
+                        $temp_score = $scoredisplay->display_score($score, SCORE_DIV_SIMPLE_WITH_CUSTOM);
+                        $temp_score = Display::tip($temp_score, $real_score);
+                    }                    
                     
                     if (!isset($this->params['only_total_category']) || (isset($this->params['only_total_category']) && $this->params['only_total_category'] == false)) {
                         if (!$show_all) {
@@ -348,6 +354,7 @@ class FlatViewDataGenerator
                 for ($count=0; ($count < $items_count ) && ($items_start + $count < count($this->evals_links)); $count++) {
                     $item  			= $this->evals_links[$count + $items_start];                    
                     $score 			= $item->calc_score($user_id);
+                    $real_score     = $score;
                     $divide			= ( ($score[1])==0 ) ? 1 : $score[1];
                     
                     //sub cat weight
@@ -359,20 +366,24 @@ class FlatViewDataGenerator
                     if ($this->category->get_parent_id() == 0 ) {                        
                         $item_value     = $score[0]/$divide*$item->get_weight();
                     } else {
-                        $item_value     = $item_value*$item->get_weight(); 
-                        //var_dump($item_value.' - '.$item->get_weight());
-                        //$item_value     = $main_weight*$item_value/$item->get_weight();
-                        //$item_value     = $item_value*100/$item->get_weight();
+                        $item_value     = $item_value*$item->get_weight();                         
                     }
                     
-                    $item_total		+= $item->get_weight();                    
-                    $complete_score     = $scoredisplay->display_score($score, SCORE_DIV_PERCENT, SCORE_ONLY_SCORE);
-                    //$temp_score     = $item_value.' - '.$scoredisplay->display_score($score, SCORE_DIV_PERCENT, SCORE_ONLY_SCORE);
-                    //$temp_score     = $item_value;
-                    $temp_score     = $scoredisplay->display_score(array($item_value, null), SCORE_DIV_SIMPLE_WITH_CUSTOM);
-                    
-                    $temp_score = Display::tip($temp_score, $complete_score);
+                    $item_total     += $item->get_weight();                    
+                    /*
+                    $complete_score = $scoredisplay->display_score($score, SCORE_DIV_PERCENT, SCORE_ONLY_SCORE);                    
+                    $temp_score  = $scoredisplay->display_score(array($item_value, null), SCORE_DIV_SIMPLE_WITH_CUSTOM);                    
+                    $temp_score = Display::tip($temp_score, $complete_score);*/
                     
+                    //if (true) {
+                    if (api_get_setting('gradebook_show_percentage_in_reports') == 'false') {
+                        $real_score = $scoredisplay->display_score($real_score, SCORE_SIMPLE);    
+                        $temp_score = $scoredisplay->display_score(array($item_value, null), SCORE_DIV_SIMPLE_WITH_CUSTOM);                        
+                        $temp_score = Display::tip($real_score, $temp_score);
+                    } else {                                             
+                        $temp_score     = $scoredisplay->display_score(array($item_value, null), SCORE_DIV_SIMPLE_WITH_CUSTOM);                    
+                        $temp_score = Display::tip($temp_score, $complete_score);
+                    }
                     
                     if (!isset($this->params['only_total_category']) || (isset($this->params['only_total_category']) && $this->params['only_total_category'] == false)) {
                         if (!$show_all) {                            

File diff suppressed because it is too large
+ 366 - 366
main/gradebook/lib/gradebook_functions.inc.php


+ 1 - 1
main/group/group.php

@@ -250,7 +250,7 @@ foreach ($group_cats as $index => $category) {
 					GroupManager::user_has_access($_user['user_id'], $this_group['id'], GroupManager::GROUP_TOOL_WIKI))
 					&& !(api_is_course_coach() && intval($this_group['session_id']) != intval($_SESSION['id_session']))) {
 				$orig = isset($origin) ? $origin : null;
-				$group_name = '<a href="group_space.php?'.api_get_cidreq().'&amp;origin='.$orig.'&amp;gidReq='.$this_group['id'].'">'.stripslashes($this_group['name']).'</a>';
+				$group_name = '<a href="group_space.php?cidReq='.api_get_course_id().'&amp;origin='.$orig.'&amp;gidReq='.$this_group['id'].'">'.Security::remove_XSS($this_group['name']).'</a>';
 				if (!empty($_SESSION['_user']['user_id']) && !empty($this_group['id_tutor']) && $_SESSION['_user']['user_id'] == $this_group['id_tutor']) {
 					$group_name .= ' ('.get_lang('OneMyGroups').')';
 				} elseif ($this_group['is_member']) {

+ 3 - 3
main/group/group_creation.php

@@ -17,8 +17,6 @@ $current_course_tool  = TOOL_GROUP;
 // Notice for unauthorized people.
 api_protect_course_script(true);
 
-require_once api_get_path(LIBRARY_PATH).'groupmanager.lib.php';
-require_once api_get_path(LIBRARY_PATH).'classmanager.lib.php';
 
 /*	Create the groups */
 
@@ -288,6 +286,7 @@ EOT;
 	/*
 	 * Show form to generate groups from classes subscribed to the course
 	 */
+    /*
 	$classes = ClassManager :: get_classes_in_course($_course['sysCode']);
 	if (count($classes) > 0) {
 		echo '<b>'.get_lang('GroupsFromClasses').'</b>';
@@ -324,7 +323,8 @@ EOT;
 		$create_class_groups_form->setDefaults($defaults);
 		$create_class_groups_form->display();
 		echo '</blockquote>';
-	}
+	}*/
+    
 }
 
 /*	FOOTER */

+ 81 - 34
main/group/group_space.php

@@ -123,7 +123,7 @@ $is_course_member = CourseManager :: is_user_subscribed_in_real_or_linked_course
 $edit_url = '';
 if (api_is_allowed_to_edit(false, true) or GroupManager :: is_tutor_of_group(api_get_user_id(), api_get_group_id())) {
     $my_origin = isset($origin) ? $origin : '';
-    $edit_url =  '<a href="group_edit.php?origin='.$my_origin.'&gidReq='.api_get_group_id().'">'.Display::return_icon('edit.png', get_lang('EditGroup'),'',ICON_SIZE_SMALL).'</a>';
+    $edit_url =  '<a href="group_edit.php?cidReq='.  api_get_course_id().'&origin='.$my_origin.'&gidReq='.api_get_group_id().'">'.Display::return_icon('edit.png', get_lang('EditGroup'),'',ICON_SIZE_SMALL).'</a>';
 }
 
 echo Display::page_header(Security::remove_XSS($current_group['name']).' '.$edit_url.' '.$subscribe_group.' '.$unsubscribe_group);
@@ -136,9 +136,8 @@ if (!empty($current_group['description'])) {
  * Group Tools
  */
 // If the user is subscribed to the group or the user is a tutor of the group then
-if (api_is_allowed_to_edit(false, true) OR GroupManager :: is_user_in_group(api_get_user_id(), $current_group['id'])) {
-	echo '<ul>';
-	$tools = '';
+if (api_is_allowed_to_edit(false, true) OR GroupManager :: is_user_in_group(api_get_user_id(), $current_group['id'])) {	
+	$actions_array = array();
 	// Link to the forum of this group
 	$forums_of_groups = get_forums_of_group($current_group['id']);
     
@@ -146,93 +145,141 @@ if (api_is_allowed_to_edit(false, true) OR GroupManager :: is_user_in_group(api_
 		if ($current_group['forum_state'] != GroupManager::TOOL_NOT_AVAILABLE ) {
 			foreach ($forums_of_groups as $key => $value) {
 				if ($value['forum_group_public_private'] == 'public' || (/*!empty($user_subscribe_to_current_group) && */ $value['forum_group_public_private'] == 'private') || !empty($user_is_tutor) || api_is_allowed_to_edit(false, true)) {
-					$tools .= '<li style="display:inline; margin:5px;"><a href="../forum/viewforum.php?forum='.$value['forum_id'].'&gidReq='.Security::remove_XSS($current_group['id']).'&amp;origin=group">'.Display::return_icon('forum.png', get_lang('Forum').': '.$value['forum_title'] , array(), 32).'</a></li>';
+                    $actions_array[] = array(
+                        'url' => '../forum/viewforum.php?forum='.$value['forum_id'].'&gidReq='.Security::remove_XSS($current_group['id']).'&amp;origin=group',
+                        'content' => Display::return_icon('forum.png', get_lang('Forum').': '.$value['forum_title'] , array(), 32)
+                     );
 				}
 			}
 		}
 	}
 	if ($current_group['doc_state'] != GroupManager::TOOL_NOT_AVAILABLE ) {
-		// Link to the documents area of this group
-		$tools .= '<li style="display:inline; margin:5px;" ><a href="../document/document.php?'.api_get_cidreq().'&amp;gidReq='.$current_group['id'].'">'.Display::return_icon('folder.png', get_lang('GroupDocument'), array(), 32).'</a></li>';
+		// Link to the documents area of this group		
+        $actions_array[] = array(
+                        'url' => '../document/document.php?'.api_get_cidreq(),
+                        'content' => Display::return_icon('folder.png', get_lang('GroupDocument'), array(), 32)
+                     );
 	}
 	if ($current_group['calendar_state'] != GroupManager::TOOL_NOT_AVAILABLE) {
 		// Link to a group-specific part of agenda
-		$tools .= '<li style="display:inline; margin:5px;"><a href="../calendar/agenda.php?'.api_get_cidreq().'&amp;toolgroup='.$current_group['id'].'&amp;group='.$current_group['id'].'&amp;acces=0">'.Display::return_icon('agenda.png', get_lang('GroupCalendar'), array(), 32).'</a></li>';
+        $actions_array[] = array(
+                        'url' => '../calendar/agenda.php?'.api_get_cidreq(),
+                        'content' => Display::return_icon('agenda.png', get_lang('GroupCalendar'), array(), 32)
+        );
 	}
 	if ($current_group['work_state'] != GroupManager::TOOL_NOT_AVAILABLE) {
 		// Link to the works area of this group
-		$tools .= '<li style="display:inline; margin:5px;" ><a href="../work/work.php?'.api_get_cidreq().'&amp;toolgroup='.$current_group['id'].'">'.Display::return_icon('work.png', get_lang('GroupWork'), array(), 32).'</a></li>';
+		 $actions_array[] = array(
+                        'url' => '../work/work.php?'.api_get_cidreq(),
+                        'content' => Display::return_icon('work.png', get_lang('GroupWork'), array(), 32)
+         );
+         
 	}
 	if ($current_group['announcements_state'] != GroupManager::TOOL_NOT_AVAILABLE) {
 		// Link to a group-specific part of announcements
-		$tools .= '<li style="display:inline; margin:5px;"><a href="../announcements/announcements.php?'.api_get_cidreq().'&amp;toolgroup='.$current_group['id'].'">'.Display::return_icon('announce.png', get_lang('GroupAnnouncements'), array(), 32).'</a></li>';
+        $actions_array[] = array(
+                        'url' => '../announcements/announcements.php?'.api_get_cidreq(),
+                        'content' => Display::return_icon('announce.png', get_lang('GroupAnnouncements'), array(), 32)
+        );
 	}
+    
 	if ($current_group['wiki_state'] != GroupManager::TOOL_NOT_AVAILABLE) {
 		// Link to the wiki area of this group
-		$tools .= '<li style="display:inline; margin:5px;"><a href="../wiki/index.php?'.api_get_cidreq().'&amp;toolgroup='.$current_group['id'].'&amp;action=show&amp;title=index&amp;session_id='.api_get_session_id().'&amp;group_id='.$current_group['id'].'">'.Display::return_icon('wiki.png', get_lang('GroupWiki'), array(), 32).'</a></li>';
+        $actions_array[] = array(
+                        'url' => '../wiki/index.php?'.api_get_cidreq().'&amp;action=show&amp;title=index&amp;session_id='.api_get_session_id().'&amp;group_id='.$current_group['id'],
+                        'content' => Display::return_icon('wiki.png', get_lang('GroupWiki'), array(), 32)
+        );		
 	}
 	if ($current_group['chat_state'] != GroupManager::TOOL_NOT_AVAILABLE) {
 		// Link to the chat area of this group
 		if (api_get_course_setting('allow_open_chat_window')) {
-			$tools .= "<li style=\"display:inline; margin:5px;\"><a href=\"javascript: void(0);\" onclick=\"window.open('../chat/chat.php?".api_get_cidreq()."&amp;toolgroup=".$current_group['id']."','window_chat_group_".$_SESSION['_cid']."_".$_SESSION['_gid']."','height=380, width=625, left=2, top=2, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, directories=no, status=no') \" >".Display::return_icon('chat.png', get_lang('Chat'),'',ICON_SIZE_MEDIUM)."</a></li>";
+            $actions_array[] = array(
+                        'url' => "javascript: void(0);\" onclick=\"window.open('../chat/chat.php?".api_get_cidreq()."&amp;toolgroup=".$current_group['id']."','window_chat_group_".$_SESSION['_cid']."_".$_SESSION['_gid']."','height=380, width=625, left=2, top=2, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, directories=no, status=no') \"",
+                        'content' => Display::return_icon('chat.png', get_lang('Chat'), array(), 32)
+            );
 		} else {
-			$tools .= "<li style=\"display:inline; margin:5px;\"><a href=\"../chat/chat.php?".api_get_cidreq()."&amp;toolgroup=".$current_group['id']."\">".Display::return_icon('chat.png', get_lang('Chat'), array(), 32)."</a></li>";
+            $actions_array[] = array(
+                        'url' => "../chat/chat.php?".api_get_cidreq()."&amp;toolgroup=".$current_group['id'],
+                        'content' => Display::return_icon('chat.png', get_lang('Chat'), array(), 32)
+            );
 		}
 	}
-echo '</ul>';
-	echo Display::page_subheader(get_lang('Tools'));
-	if (!empty($tools)) {
-		echo $tools;
+    
+	if (!empty($actions_array)) {
+        echo Display::page_subheader(get_lang('Tools'));
+		echo Display::actions($actions_array);
 	}
 
 } else {
-	echo '<ul>';
-	
-	$tools = '';
+	$actions_array = array();
+    
 	// Link to the forum of this group
 	$forums_of_groups = get_forums_of_group($current_group['id']);
 	if (is_array($forums_of_groups)) {
 		if ( $current_group['forum_state'] == GroupManager::TOOL_PUBLIC ) {
 			foreach ($forums_of_groups as $key => $value) {
-				if ($value['forum_group_public_private'] == 'public' ) {
-					$tools.= '<li style="display:inline; margin:5px;"><a href="../forum/viewforum.php?forum='.$value['forum_id'].'&gidReq='.Security::remove_XSS($current_group['id']).'&amp;origin=group">'.Display::return_icon('forum.png', get_lang('GroupForum'), array(), 32).'</a></li>';
+				if ($value['forum_group_public_private'] == 'public' ) {					                    
+                    $actions_array[] = array(
+                        'url' => '../forum/viewforum.php?cidReq='.api_get_course_id().'&forum='.$value['forum_id'].'&gidReq='.Security::remove_XSS($current_group['id']).'&amp;origin=group',
+                        'content' => Display::return_icon('forum.png', get_lang('GroupForum'), array(), ICON_SIZE_MEDIUM)
+                    );                     
 				}
 			}
 		}
 	}
 	if ($current_group['doc_state'] == GroupManager::TOOL_PUBLIC) {
 		// Link to the documents area of this group
-		$tools .= '<li style="display:inline; margin:5px;"><a href="../document/document.php?'.api_get_cidreq().'&amp;gidReq='.$current_group['id'].'&amp;origin='.$origin.'">'.Display::return_icon('folder.png', get_lang('GroupDocument'), array(), 32).'</a></li>';
+        $actions_array[] = array(
+                        'url' => '../document/document.php?cidReq='.api_get_course_id().'&amp;origin='.$origin,
+                        'content' => Display::return_icon('folder.png', get_lang('GroupDocument'), array(), ICON_SIZE_MEDIUM)
+        );
 	}
 	if ($current_group['calendar_state'] == GroupManager::TOOL_PUBLIC) {
 		// Link to a group-specific part of agenda
-		$tools .= '<li style="display:inline; margin:5px;"><a href="../calendar/agenda.php?'.api_get_cidreq().'&amp;toolgroup='.$current_group['id'].'&amp;group='.$current_group['id'].'">'.Display::return_icon('agenda.png', get_lang('GroupCalendar'), array(), 32).'</a></li>';
+        $actions_array[] = array(
+                        'url' => '../calendar/agenda.php?'.api_get_cidreq(),
+                        'content' => Display::return_icon('agenda.png', get_lang('GroupCalendar'), array(), ICON_SIZE_MEDIUM)
+        );
+        
 	}
 	if ($current_group['work_state'] == GroupManager::TOOL_PUBLIC) {
 		// Link to the works area of this group
-		$tools .= '<li style="display:inline; margin:5px;"><a href="../work/work.php?'.api_get_cidreq().'&amp;toolgroup='.$current_group['id'].'">'.Display::return_icon('work.png', get_lang('GroupWork'), array(), 32).'</a></li>';
+		$actions_array[] = array(
+                        'url' => '../work/work.php?'.api_get_cidreq(),
+                        'content' => Display::return_icon('work.png', get_lang('GroupWork'), array(), ICON_SIZE_MEDIUM)
+         );
 	}
 	if ($current_group['announcements_state'] == GroupManager::TOOL_PUBLIC) {
 		// Link to a group-specific part of announcements
-		$tools .= '<li style="display:inline; margin:5px;"><a href="../announcements/announcements.php?'.api_get_cidreq().'&amp;toolgroup='.$current_group['id'].'&amp;group='.$current_group['id'].'">'.Display::return_icon('announce.png', get_lang('GroupAnnouncements'), array(), 32).'</a></li>';
+		$actions_array[] = array(
+                        'url' => '../announcements/announcements.php?'.api_get_cidreq(),
+                        'content' => Display::return_icon('announce.png', get_lang('GroupAnnouncements'), array(), ICON_SIZE_MEDIUM)
+        );
 	}
 	if ($current_group['wiki_state'] == GroupManager::TOOL_PUBLIC) {
 		// Link to the wiki area of this group
-		$tools .= '<li style="display:inline; margin:5px;"><a href="../wiki/index.php?'.api_get_cidreq().'&amp;toolgroup='.$current_group['id'].'&amp;action=show&amp;title=index&amp;session_id='.api_get_session_id().'&amp;group_id='.$current_group['id'].'">'.Display::return_icon('wiki.png', get_lang('GroupWiki'), array(), 32).'</a></li>';		
+		$actions_array[] = array(
+                        'url' => '../wiki/index.php?'.api_get_cidreq().'&amp;action=show&amp;title=index&amp;session_id='.api_get_session_id().'&amp;group_id='.$current_group['id'],
+                        'content' => Display::return_icon('wiki.png', get_lang('GroupWiki'), array(), 32)
+        );
 	}
 	if ($current_group['chat_state'] == GroupManager::TOOL_PUBLIC ) {
 		// Link to the chat area of this group
 		if (api_get_course_setting('allow_open_chat_window')) {
-			$tools .= "<li style=\"display:inline; margin:5px;\"><a href=\"javascript: void(0);\" onclick=\"window.open('../chat/chat.php?".api_get_cidreq()."&amp;toolgroup=".$current_group['id']."','window_chat_group_".$_SESSION['_cid']."_".$_SESSION['_gid']."','height=380, width=625, left=2, top=2, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, directories=no, status=no') \" >".Display::return_icon('chat.png', get_lang("Chat"), array(), 32)."</a></li>";
+            $actions_array[] = array(
+                        'url' => "javascript: void(0);\" onclick=\"window.open('../chat/chat.php?".api_get_cidreq()."&amp;toolgroup=".$current_group['id']."','window_chat_group_".$_SESSION['_cid']."_".$_SESSION['_gid']."','height=380, width=625, left=2, top=2, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, directories=no, status=no') \"",
+                        'content' => Display::return_icon('chat.png', get_lang('Chat'), array(), 32)
+            );
 		} else {
-			$tools .= "<li style=\"display:inline; margin:5px;\"><a href=\"../chat/chat.php?".api_get_cidreq()."&amp;toolgroup=".$current_group['id']."\">".Display::return_icon('chat.png', get_lang("Chat"), array(), 32)."</a></li>";
+            $actions_array[] = array(
+                        'url' => "../chat/chat.php?".api_get_cidreq()."&amp;toolgroup=".$current_group['id'],
+                        'content' => Display::return_icon('chat.png', get_lang('Chat'), array(), 32)
+            );
 		}
 	}
-	echo '</ul>';
-
-    echo Display::page_subheader(get_lang('Tools'));
-	if (!empty($tools)) {
-		echo $tools;
+	if (!empty($actions_array)) {
+        echo Display::page_subheader(get_lang('Tools'));
+		echo Display::actions($actions_array);
 	}
 }
 

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

@@ -120,7 +120,7 @@ class Attendance
 				FROM $tbl_attendance att
 				WHERE c_id = $course_id AND $active_plus $condition_session
 				ORDER BY col$column $direction LIMIT $from,$number_of_items ";        
-        var_dump($sql);exit;
+        
 		$res = Database::query($sql);
 		$attendances = array ();
 

+ 30 - 32
main/inc/lib/document.lib.php

@@ -457,8 +457,6 @@ class DocumentManager {
         $TABLE_ITEMPROPERTY = Database::get_course_table(TABLE_ITEM_PROPERTY);
         $TABLE_DOCUMENT     = Database::get_course_table(TABLE_DOCUMENT);
         
-        //if to_user_id = NULL -> change query (IS NULL)
-        //$to_user_id = (is_null($to_user_id)) ? 'IS NULL' : '= '.$to_user_id;
         if (!is_null($to_user_id)) {
             $to_field = 'last.to_user_id';
             $to_value = $to_user_id;
@@ -492,28 +490,28 @@ class DocumentManager {
         }
 
         //condition for search (get ALL folders and documents)
-        if ($search) {
-            $sql = "SELECT docs.id, docs.filetype, docs.path, docs.title, docs.comment, docs.size, docs.readonly, docs.session_id, last.id_session item_property_session_id, last.lastedit_date, last.visibility, last.insert_user_id
-                        FROM  ".$TABLE_ITEMPROPERTY."  AS last, ".$TABLE_DOCUMENT."  AS docs
-                        WHERE docs.id = last.ref
-                        AND last.tool = '".TOOL_DOCUMENT."'
-                        AND ".$to_field." = ".$to_value."
-                        AND last.visibility".$visibility_bit . $condition_session." AND
-            			docs.c_id = {$_course['real_id']} AND
-            			last.c_id = {$_course['real_id']}  ";
-        } else {
-            $sql = "SELECT docs.id, docs.filetype, docs.path, docs.title, docs.comment, docs.size, docs.readonly, docs.session_id, last.id_session item_property_session_id, last.lastedit_date, last.visibility, last.insert_user_id
-                        FROM  ".$TABLE_ITEMPROPERTY."  AS last, ".$TABLE_DOCUMENT."  AS docs
-                        WHERE docs.id = last.ref
-                        AND docs.path LIKE '".$path.$added_slash."%'
-                        AND docs.path NOT LIKE '".$path.$added_slash."%/%'
-                        AND last.tool = '".TOOL_DOCUMENT."'
-                        AND ".$to_field." = ".$to_value."
-                        AND last.visibility".$visibility_bit.$condition_session." AND
-            			docs.c_id = {$_course['real_id']} AND
-            			last.c_id = {$_course['real_id']}  ";
-        }
-
+  
+        $sql = "SELECT  docs.id, 
+                        docs.filetype, 
+                        docs.path, 
+                        docs.title, 
+                        docs.comment, 
+                        docs.size, 
+                        docs.readonly, 
+                        docs.session_id, 
+                        last.id_session item_property_session_id, 
+                        last.lastedit_date, 
+                        last.visibility, 
+                        last.insert_user_id
+                    FROM  ".$TABLE_ITEMPROPERTY."  AS last INNER JOIN ".$TABLE_DOCUMENT."  AS docs 
+                        ON (docs.id = last.ref AND docs.c_id = {$_course['real_id']} AND last.c_id = {$_course['real_id']})
+                    WHERE
+                        docs.path LIKE '".$path.$added_slash."%' AND
+                        docs.path NOT LIKE '".$path.$added_slash."%/%' AND
+                        last.tool = '".TOOL_DOCUMENT."' AND
+                        ".$to_field." = ".$to_value." AND 
+                        last.visibility".$visibility_bit.$condition_session;
+       
         $result = Database::query($sql);
 
         $doc_list = array();
@@ -522,7 +520,6 @@ class DocumentManager {
 
         if ($result !== false && Database::num_rows($result) != 0) {
             while ($row = Database::fetch_array($result, 'ASSOC')) {
-
                 if (api_is_coach()) {
                     //Looking for course items that are invisible to hide it in the session
                     if (in_array($row['id'], array_keys($doc_list))) {
@@ -533,7 +530,6 @@ class DocumentManager {
                             }
                         }
                     }
-
                     $doc_list[$row['id']] = $row;
                 }
 
@@ -546,9 +542,9 @@ class DocumentManager {
                     //Templates management
                     $table_template = Database::get_main_table(TABLE_MAIN_TEMPLATES);
                     $sql_is_template = "SELECT id FROM $table_template
-                                        WHERE course_code='".$_course['id']."'
-                                        AND user_id='".api_get_user_id()."'
-                                        AND ref_doc='".$row['id']."'";
+                                        WHERE course_code = '".$_course['code']."'
+                                        AND user_id = '".api_get_user_id()."'
+                                        AND ref_doc = '".$row['id']."'";
                     $template_result = Database::query($sql_is_template);
                     $row['is_template'] = (Database::num_rows($template_result) > 0) ? 1 : 0;
                 }
@@ -556,8 +552,6 @@ class DocumentManager {
                 $document_data[$row['id']] = $row;
             }
 
-
-
             //Only for the student we filter the results see BT#1652
             if (!api_is_coach() && !$is_allowed_to_edit) {
                 $ids_to_remove = array();
@@ -610,7 +604,7 @@ class DocumentManager {
 
                 //Checking parents visibility
                 $final_document_data = array();
-                foreach($document_data as $row) {
+                foreach ($document_data as $row) {
                 	$is_visible = DocumentManager::check_visibility_tree($row['id'], $_course['code'], $current_session_id, api_get_user_id());
                 	if ($is_visible) {
                 		$final_document_data[$row['id']]=$row;
@@ -1415,10 +1409,12 @@ class DocumentManager {
         $date_long_certificate = '';
         if (!empty($date_certificate)) {
             $date_long_certificate = api_convert_and_format_date($date_certificate);
+            $date_no_time = api_convert_and_format_date($date_certificate, DATE_FORMAT_LONG_NO_DAY);
         }
 
         if ($is_preview) {
             $date_long_certificate = api_convert_and_format_date(api_get_utc_datetime());
+            $date_no_time = api_convert_and_format_date(api_get_utc_datetime(), DATE_FORMAT_LONG_NO_DAY);
         }
 
         $url = api_get_path(WEB_PATH).'certificates/index.php?id='.$info_grade_certificate['id'];
@@ -1433,6 +1429,7 @@ class DocumentManager {
                                                      $teacher_last_name,
                                                      $official_code,
                                                      $date_long_certificate,
+                                                     $date_no_time,
                                                      $course_id,
                                                      $course_info['name'],
                                                      $info_grade_certificate['grade'],
@@ -1449,6 +1446,7 @@ class DocumentManager {
                                                      '((teacher_lastname))',
                                                      '((official_code))',
                                                      '((date_certificate))',
+                                                     '((date_certificate_no_time))',
         											 '((course_code))',
                 									 '((course_title))',
         											 '((gradebook_grade))',

+ 5 - 6
main/inc/lib/fileUpload.lib.php

@@ -839,15 +839,14 @@ function filter_extension(&$filename) {
  * @param string $title
  * @return id if inserted document
  */
-function add_document($_course, $path, $filetype, $filesize, $title, $comment = null, $readonly = 0, $save_visibility = true) {
+function add_document($_course, $path, $filetype, $filesize, $title, $comment = null, $readonly = 0, $save_visibility = true, $group_id = null) {
 	$session_id    = api_get_session_id();
 	$readonly      = intval($readonly);
 	$comment       = Database::escape_string($comment);
 	$path          = Database::escape_string($path);
 	$filetype      = Database::escape_string($filetype);
-	$filesize      = intval($filesize);
-    $title         = htmlspecialchars($title);
-    $title         = Database::escape_string($title);
+	$filesize      = intval($filesize);    
+    $title         = Database::escape_string(htmlspecialchars($title));
     $c_id          = $_course['real_id'];
 	
 	$table_document = Database::get_course_table(TABLE_DOCUMENT);
@@ -858,7 +857,7 @@ function add_document($_course, $path, $filetype, $filesize, $title, $comment =
 		$document_id = Database::insert_id();
         if ($document_id) {
             if ($save_visibility) {
-                api_set_default_visibility($document_id, TOOL_DOCUMENT);                
+                api_set_default_visibility($document_id, TOOL_DOCUMENT, $group_id);                
             }
         }        
 		return $document_id;
@@ -1089,7 +1088,7 @@ function create_unexisting_directory($_course, $user_id, $session_id, $to_group_
 	
 		$rs = Database::query($sql);
 		if (Database::num_rows($rs) == 0) {
-			$document_id = add_document($_course, $desired_dir_name.$nb, 'folder', 0, $title);			
+			$document_id = add_document($_course, $desired_dir_name.$nb, 'folder', 0, $title, null, 0, true, $to_group_id);          
 			if ($document_id) {
 				// Update document item_property					
 				if ($visibility !== '') {

+ 60 - 50
main/inc/lib/groupmanager.lib.php

@@ -195,6 +195,7 @@ class GroupManager {
 		}
 		return $groups;
 	}
+    
 	/**
 	 * Create a group
 	 * @param string $name The name for this group
@@ -202,19 +203,21 @@ class GroupManager {
 	 * @param int $places How many people can subscribe to the new group
 	 */
 	public static function create_group ($name, $category_id, $tutor, $places) {
-		global $_course,$_user;
-		isset($_SESSION['id_session'])?$my_id_session = intval($_SESSION['id_session']):$my_id_session=0;
+		global $_course;		
+        $table_group = Database :: get_course_table(TABLE_GROUP);
+        
+        $session_id = api_get_session_id();
+        $course_id  = api_get_course_int_id();
+        
 		$currentCourseRepository = $_course['path'];
-		$table_group = Database :: get_course_table(TABLE_GROUP);
-		$table_forum = Database :: get_course_table(TABLE_FORUM);
-		$category = self :: get_category($category_id);
 		
-		$course_id = api_get_course_int_id();
+		$category = self :: get_category($category_id);
 
 		if (intval($places) == 0) {
 			//if the amount of users per group is not filled in, use the setting from the category
 			$places = $category['max_student'];
 		}
+        
 		 $sql = "INSERT INTO ".$table_group." SET
 				c_id = $course_id , 
 				category_id='".Database::escape_string($category_id)."', 
@@ -228,55 +231,62 @@ class GroupManager {
 				chat_state = '".$category['chat_state']."', 
 				self_registration_allowed = '".$category['self_reg_allowed']."',  
 				self_unregistration_allowed = '".$category['self_unreg_allowed']."', 
-				session_id='".Database::escape_string($my_id_session)."'";
+				session_id='".Database::escape_string($session_id)."'";
 		Database::query($sql);
 		$lastId = Database::insert_id();
+        
+        if ($lastId) {
+            $desired_dir_name= '/'.replace_dangerous_char($name,'strict').'_groupdocs';
+            $my_path = api_get_path(SYS_COURSE_PATH).$currentCourseRepository.'/document';
+            $unique_name = create_unexisting_directory($_course, api_get_user_id(), $session_id, $lastId, NULL, $my_path, $desired_dir_name);               
+       
+            /* Stores the directory path into the group table */
+            $sql = "UPDATE ".$table_group." SET name = '".Database::escape_string($name)."', secret_directory = '".$unique_name."' 
+                    WHERE c_id = $course_id AND id ='".$lastId."'";
 
-		$desired_dir_name= '/'.replace_dangerous_char($name,'strict').'_groupdocs';
-
-		$my_path = api_get_path(SYS_COURSE_PATH).$currentCourseRepository.'/document';
-		$unique_name = create_unexisting_directory($_course,$_user['user_id'], api_get_session_id(), $lastId,NULL,$my_path, $desired_dir_name);
-		/* Stores the directory path into the group table */
-		$sql = "UPDATE ".$table_group." SET name = '".Database::escape_string($name)."', secret_directory = '".$unique_name."' 
-				WHERE c_id = $course_id AND id ='".$lastId."'";
-
-		Database::query($sql);
+            Database::query($sql);
 
-		// create a forum if needed
-		if ($category['forum_state'] >= 0) {
-			require_once api_get_path(SYS_CODE_PATH).'forum/forumconfig.inc.php';
-			require_once api_get_path(SYS_CODE_PATH).'forum/forumfunction.inc.php';
+            // create a forum if needed
+            if ($category['forum_state'] >= 0) {
+                require_once api_get_path(SYS_CODE_PATH).'forum/forumconfig.inc.php';
+                require_once api_get_path(SYS_CODE_PATH).'forum/forumfunction.inc.php';
 
-			$forum_categories = get_forum_categories();
-			$values['forum_title'] = $name;
-			$counter = 0;
-			foreach ($forum_categories as $key=>$value) {
-				if ($counter==0) {
-					$forum_category_id = $key;
-				}
-				$counter++;
-			}
-			// A sanity check.
-			if (empty($forum_category_id)) {
-				$forum_category_id = 0;
-			}
-			$values['forum_category'] = $forum_category_id;
-			$values['allow_anonymous_group']['allow_anonymous'] = 0;
-			$values['students_can_edit_group']['students_can_edit'] = 0;
-			$values['approval_direct_group']['approval_direct'] = 0;
-			$values['allow_attachments_group']['allow_attachments'] = 1;
-			$values['allow_new_threads_group']['allow_new_threads'] = 1;
-			$values['default_view_type_group']['default_view_type']=api_get_setting('default_forum_view');
-			$values['group_forum'] = $lastId;
-			if ($category['forum_state'] == '1') {
-				$values['public_private_group_forum_group']['public_private_group_forum']='public';
-			} elseif  ($category['forum_state'] == '2') {
-				$values['public_private_group_forum_group']['public_private_group_forum']='private';
-			} elseif  ($category['forum_state'] == '0') {
-				$values['public_private_group_forum_group']['public_private_group_forum']='unavailable';
-			}
-			store_forum($values);
-		}
+                $forum_categories = get_forum_categories();
+                
+                $values = array();
+                $values['forum_title'] = $name;                
+                $values['group_id'] = $lastId;
+                
+                $counter = 0;
+                foreach ($forum_categories as $key=>$value) {
+                    if ($counter==0) {
+                        $forum_category_id = $key;
+                    }
+                    $counter++;
+                }
+                // A sanity check.
+                if (empty($forum_category_id)) {
+                    $forum_category_id = 0;
+                }
+                $values['forum_category'] = $forum_category_id;
+                $values['allow_anonymous_group']['allow_anonymous'] = 0;
+                $values['students_can_edit_group']['students_can_edit'] = 0;
+                $values['approval_direct_group']['approval_direct'] = 0;
+                $values['allow_attachments_group']['allow_attachments'] = 1;
+                $values['allow_new_threads_group']['allow_new_threads'] = 1;
+                $values['default_view_type_group']['default_view_type']=api_get_setting('default_forum_view');
+                $values['group_forum'] = $lastId;
+                if ($category['forum_state'] == '1') {
+                    $values['public_private_group_forum_group']['public_private_group_forum']='public';
+                } elseif  ($category['forum_state'] == '2') {
+                    $values['public_private_group_forum_group']['public_private_group_forum']='private';
+                } elseif  ($category['forum_state'] == '0') {
+                    $values['public_private_group_forum_group']['public_private_group_forum']='unavailable';
+                }
+                store_forum($values);
+            }
+        }
+     
 		return $lastId;
 	}
 	/**

+ 20 - 5
main/inc/lib/internationalization.lib.php

@@ -25,15 +25,16 @@ define('SPECIAL_CLOSING_TAG', '=]');
 
 define('TIME_NO_SEC_FORMAT',    0);	// 15:23
 define('DATE_FORMAT_SHORT',     1); // Aug 25, 09 
-define('DATE_FORMAT_LONG',      2);	// Aug 25, 09 
-define('DATE_TIME_FORMAT_LONG', 3);	// August 25, 2009 at 03:28 PM 
+define('DATE_FORMAT_LONG',      2);	// Monday August 25, 09 
+define('DATE_FORMAT_LONG_NO_DAY',     10);	// August 25, 2009
+define('DATE_TIME_FORMAT_LONG', 3);	// Monday August 25, 2009 at 03:28 PM 
 
 define('DATE_FORMAT_NUMBER',        4);	// 25.08.09
-define('DATE_TIME_FORMAT_LONG_24H', 5); // August 25, 2009 at 15:28   
-
+define('DATE_TIME_FORMAT_LONG_24H', 5); // August 25, 2009 at 15:28
 define('DATE_TIME_FORMAT_SHORT', 6);	// Aug 25, 2009 at 03:28 PM 
 define('DATE_TIME_FORMAT_SHORT_TIME_FIRST', 7);	// 03:28 PM, Aug 25 2009
-define('DATE_FORMAT_NUMBER_NO_YEAR',  8);	// 25.08
+define('DATE_FORMAT_NUMBER_NO_YEAR',  8);	// 25.08 dd-mm
+define('DATE_FORMAT_ONLY_DAYNAME',  9);	// Monday, Sunday, etc
 
 // Formatting person's name.
 define('PERSON_NAME_COMMON_CONVENTION', 0);	// Formatting a person's name using the pattern as it has been
@@ -690,6 +691,13 @@ 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 (IS_PHP_53 && INTL_INSTALLED) {
+        			$datetype = IntlDateFormatter::SHORT;
+        			$timetype = IntlDateFormatter::NONE;
+        		}
+                break;
             case DATE_FORMAT_NUMBER_NO_YEAR:
                 $date_format = get_lang('dateFormatShortNumberNoYear', '', $language);                                 		                
         		if (IS_PHP_53 && INTL_INSTALLED) {
@@ -732,6 +740,13 @@ function api_format_date($time, $format = null, $language = null) {
                     $timetype = IntlDateFormatter::SHORT;
                 }
                 break;		
+            case DATE_FORMAT_LONG_NO_DAY:
+                $date_format = get_lang('dateFormatLongNoDay', '', $language);
+                if (IS_PHP_53 && INTL_INSTALLED) {
+                    $datetype = IntlDateFormatter::FULL;
+                    $timetype = IntlDateFormatter::SHORT;
+                }
+                break;     
 			case DATE_TIME_FORMAT_SHORT:
                 $date_format = get_lang('dateTimeFormatShort', '', $language);
                 if (IS_PHP_53 && INTL_INSTALLED) {

+ 6 - 3
main/inc/lib/main_api.lib.php

@@ -6039,7 +6039,7 @@ function api_is_global_chat_enabled(){
 /** 
  * @todo Fix tool_visible_by_default_at_creation labels 
  */
-function api_set_default_visibility($item_id, $tool_id) {
+function api_set_default_visibility($item_id, $tool_id, $group_id = null) {
     $original_tool_id = $tool_id;
     
     switch ($tool_id) {
@@ -6073,7 +6073,10 @@ function api_set_default_visibility($item_id, $tool_id) {
         $visibility = 'invisible';    
         if ($setting[$tool_id] == 'true') {
             $visibility = 'visible';            
-        }
-        api_item_property_update(api_get_course_info(), $original_tool_id, $item_id, $visibility, api_get_user_id(), api_get_group_id(), null, null, null, api_get_session_id());            
+        }        
+        if (empty($group_id)) {
+            $group_id = api_get_group_id();
+        }        
+        api_item_property_update(api_get_course_info(), $original_tool_id, $item_id, $visibility, api_get_user_id(), $group_id, null, null, null, api_get_session_id());            
     }
 }

+ 4 - 10
main/inc/lib/thematic.lib.php

@@ -3,15 +3,11 @@
 
 /**
  * This file contains class used like library, provides functions for thematic option inside attendance tool. It's also used like model to thematic_controller (MVC pattern)
+ * Thematic class can be used to instanciate objects or as a library for thematic control
  * @author Christian Fasanando <christian1827@gmail.com>
  * @author Julio Montoya <gugli100@gmail.com> SQL fixes 
  * @package chamilo.course_progress
  */
-
-/**
- * Thematic class can be used to instanciate objects or as a library for thematic control
- * @package chamilo.course_progress
- */
 class Thematic
 {	
 	private $session_id;
@@ -45,13 +41,11 @@ class Thematic
         }
         $course_id = api_get_course_int_id();
 		$sql = "SELECT COUNT(id) AS total_number_of_items FROM $tbl_thematic WHERE c_id = $course_id AND active = 1 $condition_session ";
-		$res = Database::query($sql);
-		$res = Database::query($sql);
+		$res = Database::query($sql);		
 		$obj = Database::fetch_object($res);
 		return $obj->total_number_of_items;
 	}
 
-
 	/**
 	 * Get the thematics to display on the current page (fill the sortable-table)
 	 * @param   int     offset of first user to recover
@@ -484,8 +478,8 @@ class Thematic
 						$session_star = api_get_session_image(api_get_session_id(), $uinfo['status']);
 					}
 				}
-					
-				$thematic_advance_item  = '<div><strong>'.api_convert_and_format_date($thematic_advance['start_date'], DATE_TIME_FORMAT_LONG).$session_star.'</strong></div>';
+                //DATE_TIME_FORMAT_LONG
+				$thematic_advance_item  = '<div><strong>'.api_convert_and_format_date($thematic_advance['start_date'], DATE_FORMAT_ONLY_DAYNAME).$session_star.'</strong></div>';
 //				$thematic_advance_item .= '<div>'.get_lang('DurationInHours').' : '.$thematic_advance['duration'].'</div>';
 				$thematic_advance_item .= '<div>'.$thematic_advance['duration'].' '.get_lang('HourShort').'</div>';
 				$thematic_advance_item .= '<div>'.Security::remove_XSS($thematic_advance['content'], STUDENT).'</div>';

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

@@ -3345,12 +3345,12 @@ class UserManager {
 	  	    $category_id  = $row['cat_id'];
 	  	    $cat         = Category::load($category_id);	  		  	
 	  	    $displayscore = ScoreDisplay::instance();
-                    $grade = '';
+            $grade = '';
 	  	    if (isset($cat) && $displayscore->is_custom()) {
-                        $grade = $displayscore->display_score(array($score, $cat[0]->get_weight()), SCORE_DIV_PERCENT_WITH_CUSTOM);			
-    	            } else {
-    	  	        $grade = $displayscore->display_score(array($score, $cat[0]->get_weight()));    	  		
-                    }    	  	    	  	    	  	
+                $grade = $displayscore->display_score(array($score, $cat[0]->get_weight()), SCORE_DIV_PERCENT_WITH_CUSTOM);			
+            } else {
+                $grade = $displayscore->display_score(array($score, $cat[0]->get_weight()));    	  		
+            }    	  	    	  	    	  	
 	  	    $row['grade'] = $grade;
 	  	    return $row;
         }

+ 9 - 8
main/lang/english/trad4all.inc.php

@@ -1004,13 +1004,13 @@ $YouMustAcceptLicence = "You must accept the licence";
 $SelectOne = "Select one";
 $ContactInformationHasBeenSent = "Contact information has been sent";
 $UserInactivedSinceX = "User inactive since %s";
-$ContactInformationDescription = "Dear user,<br />
-<br />You are about to start using one of the best open-source e-learning platform on the market. Like many other open-source project, this project is backed up by a large community of students, teachers, developers and content creators who would like to promote the project better.<br />
-<br />
-By knowing a little bit more about you, one of our most important users, who will manage this e-learning system, we will be able to let people know that our software is used and let you know when we organize events that might be relevant to you.<br />
-<br />
-By filling this form, you accept that the Chamilo association or its members might send you information by e-mail about important events or updates in the Chamilo software or community. This will help the community grow as an organized entity where information flow, with a permanent respect of your time and your privacy.<br />
-<br />
+$ContactInformationDescription = "Dear user,<br />
+<br />You are about to start using one of the best open-source e-learning platform on the market. Like many other open-source project, this project is backed up by a large community of students, teachers, developers and content creators who would like to promote the project better.<br />
+<br />
+By knowing a little bit more about you, one of our most important users, who will manage this e-learning system, we will be able to let people know that our software is used and let you know when we organize events that might be relevant to you.<br />
+<br />
+By filling this form, you accept that the Chamilo association or its members might send you information by e-mail about important events or updates in the Chamilo software or community. This will help the community grow as an organized entity where information flow, with a permanent respect of your time and your privacy.<br />
+<br />
 Please note that you are <b>not required</b> to fill this form. If you want to remain anonymous, we will loose the opportunity to offer you all the privileges of being a registered portal administrator, but we will respect your decision. Simply leave this form empty and click \"Next\".<br /><br />";
 $CompanyActivity = "Your company's activity";
 $DateUnLock = "Unlock date";
@@ -1216,7 +1216,7 @@ $SaveForNow = "Save and continue later";
 $NoQuicktime = "Your browser does not have the QuickTime plugin installed. You can still use the platform, but to run a larger number of media file types, we suggest you might want to install it.";
 $NoJavaSun = "Your browser doesn't seem to have the Sun Java plugin installed. You can still use the platform, but you will lose a few of its capabilities.";
 $NoJava = "Your browser does not support Java";
-$JavaSun24 = "Your browser has a Java version not supported by this tool.
+$JavaSun24 = "Your browser has a Java version not supported by this tool.
 To use it you have to install a Java Sun version higher than 24";
 $NoMessageAnywere = "If you do not want to see this message again during this session, click here";
 $Attempts = "Attempts";
@@ -1380,4 +1380,5 @@ $DataTableSearch = "Search";
 $HideColumn = "Hide column";
 $DisplayColumn = "Show column";
 $LegalAgreementAccepted = "Legal agreement accepted";
+$dateFormatLongNoDay = "%d %B %Y";
 ?>

+ 14 - 13
main/lang/spanish/trad4all.inc.php

@@ -841,7 +841,7 @@ $AssignSessions = "Asignar sesiones de formación";
 $Timezone = "Zona horaria";
 $DashboardPluginsHaveBeenUpdatedSucesslly = "Los plugins del panel de control han sido actualizados correctamente";
 $LoginEnter = "Entrar";
-$AttendanceSheetDescription = "Las listas de asistencia permiten registrar las faltas de asistencia de los estudiantes. En caso de ausencia de un estudiante, el profesor deberá registrarlo manualmente en la casilla correspondiente.
+$AttendanceSheetDescription = "Las listas de asistencia permiten registrar las faltas de asistencia de los estudiantes. En caso de ausencia de un estudiante, el profesor deberá registrarlo manualmente en la casilla correspondiente.
 Es posible crear más de una lista de asistencia por cada curso; así por ejemplo, podrá registrar separadamente la asistencia a las clases teóricas y prácticas.";
 $ThereAreNoRegisteredLearnersInsidetheCourse = "No hay estudiantes inscritos en este curso";
 $GoToAttendanceCalendarList = "Ir al calendario de asistencia";
@@ -1005,14 +1005,14 @@ $YouMustAcceptLicence = "Debe aceptar la licencia para poder usar este software"
 $SelectOne = "Seleccione uno";
 $ContactInformationHasBeenSent = "Información de contacto enviada";
 $UserInactivedSinceX = "Usuario inactivo desde %s";
-$ContactInformationDescription = "Estimado usuario,
-
-está a punto de instalar una de las mejores plataformas e-learning de código abierto que existen en el mercado. Al igual de muchos otros proyectos de código abierto, Chamilo está respaldado por una amplia comunidad de profesores, estudiantes, desarrolladores y creadores de contenido.
-
-Si sabemos algo más de quien va a gestionar este sistema e-learning, podremos dar a conocer a otros que nuestro software lo utiliza y a usted podremos informarle sobre eventos que pueden ser de su interés.
-
-Cumplimentar este formulario, implica la aceptación de que la asociación Chamilo o sus miembros puedan enviarle información por correo electrónico sobre eventos importantes o actualizaciones en el software Chamilo. Esto ayudará a crecer a la comunidad como una entidad organizada, donde el flujo de información, se haga con respeto permanente a su tiempo y su privacidad.
-
+$ContactInformationDescription = "Estimado usuario,
+
+está a punto de instalar una de las mejores plataformas e-learning de código abierto que existen en el mercado. Al igual de muchos otros proyectos de código abierto, Chamilo está respaldado por una amplia comunidad de profesores, estudiantes, desarrolladores y creadores de contenido.
+
+Si sabemos algo más de quien va a gestionar este sistema e-learning, podremos dar a conocer a otros que nuestro software lo utiliza y a usted podremos informarle sobre eventos que pueden ser de su interés.
+
+Cumplimentar este formulario, implica la aceptación de que la asociación Chamilo o sus miembros puedan enviarle información por correo electrónico sobre eventos importantes o actualizaciones en el software Chamilo. Esto ayudará a crecer a la comunidad como una entidad organizada, donde el flujo de información, se haga con respeto permanente a su tiempo y su privacidad.
+
 De cualquier forma, tenga en cuenta que no tiene la obligación de rellenar este formulario. Si desea permanecer en el anonimato, perderemos la oportunidad de ofrecerle todos los privilegios de ser un administrador de portal registrado, pero respetaremos su decisión. Basta con dejar vacío este formulario y hacer clic en \"Siguiente\" para seguir instalando Chamilo.";
 $CompanyActivity = "Sector";
 $DateUnLock = "Desbloquear fecha";
@@ -1210,11 +1210,11 @@ $CertificateOnlineLink = "Vínculo al certificado en línea";
 $NewExercises = "Nuevo ejercicio";
 $MyAverage = "Mi promedio";
 $AllAttempts = "Todos los intentos";
-$NoCookies = "Las cookies no están activadas en su navegador.
+$NoCookies = "Las cookies no están activadas en su navegador.
 Chamilo utiliza \"cookies\" para almacenar sus datos de conexión, por lo que no le será posible entrar si las cookies no están habilitadas. Por favor, cambie la configuración de su navegador y recargue esta página.";
-$NoJavascript = "Su navegador no tiene activado JavaScript.
+$NoJavascript = "Su navegador no tiene activado JavaScript.
 Chamilo se sirve de JavaScript para proporcionar un interfaz más dinámico. Es probable que muchas prestaciones sigan funcionando pero otras no lo harán, especialmente las relacionadas con la usabilidad. Le recomendamos que cambie la configuración de su navegador y recargue esta página.";
-$NoFlash = "Su navegador no tiene activado el soporte de Flash.
+$NoFlash = "Su navegador no tiene activado el soporte de Flash.
 Chamilo sólo se apoya en Flash para algunas de sus funciones por lo que su ausencia no le impedirá continuar. Pero si quiere beneficiarse del conjunto de las herramientas de Chamilo, le recomendamos que instale-active el plugin de Flash y reinicialice su navegador.";
 $Attempt = "Intento";
 $SaveForNow = "Guardar y continuar más tarde";
@@ -1294,7 +1294,7 @@ $LoginX = "Nombre de usuario: %s";
 $ChatConnected = "Chat (Conectado)";
 $ChatDisconnected = "Chat (Desconectado)";
 $ThingsToDo = "Actividades por realizar";
-$WamiFlashDialog = "Se mostrará un cuadro de diálogo en el que se le pedirá permiso para poder acceder al micrófono, responda afirmativamente y cierre el cuadro de diálogo (si no desea que vuelva a aparecer, antes de cerrar marque la opción
+$WamiFlashDialog = "Se mostrará un cuadro de diálogo en el que se le pedirá permiso para poder acceder al micrófono, responda afirmativamente y cierre el cuadro de diálogo (si no desea que vuelva a aparecer, antes de cerrar marque la opción
 recordar)";
 $WamiStartRecorder = "Inicie la grabación pulsando el micrófono y deténgala pulsándolo de nuevo. Cada vez que haga esto se generará un archivo.";
 $InputNameHere = "Escriba el nombre aquí";
@@ -1385,4 +1385,5 @@ $DataTableSearch = "Buscar";
 $HideColumn = "Ocultar columna";
 $DisplayColumn = "Mostrar columna";
 $LegalAgreementAccepted = "Condiciones legales aceptadas";
+$dateFormatOnlyDayName = "%A";
 ?>

+ 28 - 27
main/survey/survey.lib.php

@@ -68,6 +68,7 @@ class survey_manager {
 		}
 		$my_course_info = api_get_course_info($my_course_id);
 		$table_survey = Database :: get_course_table(TABLE_SURVEY);
+        
 		if ($shared != 0) {
 			$table_survey	= Database :: get_main_table(TABLE_MAIN_SHARED_SURVEY_QUESTION);
             $sql = "SELECT * FROM $table_survey WHERE survey_id='".Database::escape_string($survey_id)."' ";
@@ -93,17 +94,13 @@ class survey_manager {
 			$return['survey_thanks'] 		= $return['surveythanks'];
 			$return['survey_type'] 		    = $return['survey_type'];
 			$return['one_question_per_page']= $return['one_question_per_page'];
-
 			$return['show_form_profile']	= $return['show_form_profile'];
 			$return['input_name_list']		= $return['input_name_list'];
-
 			$return['shuffle']				= $return['shuffle'];
 			$return['parent_id']			= $return['parent_id'];
 			$return['survey_version']		= $return['survey_version'];
-			return $return;
-		} else {
-			return $return;
-		}
+        }
+        return $return;
 	}
 
 	/**
@@ -3792,9 +3789,7 @@ class SurveyUtil {
 		// Database table to store the invitations data
 		$table_survey_invitation = Database::get_course_table(TABLE_SURVEY_INVITATION);
 
-		$survey_invitations = array();
-		$survey_invitations = SurveyUtil::get_invitations($survey_data['survey_code']);
-		$already_invited = array();
+		$survey_invitations = SurveyUtil::get_invitations($survey_data['survey_code']);		
 		$already_invited = SurveyUtil::get_invited_users($survey_data['code']);
 
 		// Remind unanswered is a special version of remind all reminder
@@ -3854,7 +3849,7 @@ class SurveyUtil {
 	static function send_invitation_mail($invitedUser, $invitation_code, $invitation_title, $invitation_text) {
 		global $_user, $_course, $_configuration;
 
-		$portal_url = api_get_path(WEB_PATH);
+		$portal_url = api_get_path(WEB_CODE_PATH);
 		if ($_configuration['multiple_access_urls']) {
 			$access_url_id = api_get_current_access_url_id();
 			if ($access_url_id != -1) {
@@ -3862,8 +3857,9 @@ class SurveyUtil {
 				$portal_url = $url['url'];
 			}
 		}
+        
 		// Replacing the **link** part with a valid link for the user
-		$survey_link = $portal_url.'main/survey/fillsurvey.php?course='.$_course['sysCode'].'&invitationcode='.$invitation_code;
+		$survey_link = api_get_path(WEB_CODE_PATH).'survey/fillsurvey.php?course='.$_course['code'].'&invitationcode='.$invitation_code;
 		$text_link = '<a href="'.$survey_link.'">'.get_lang('ClickHereToAnswerTheSurvey')."</a><br />\r\n<br />\r\n".get_lang('OrCopyPasteTheFollowingUrl')." <br />\r\n ".$survey_link;
 
 		$replace_count = 0;
@@ -3871,6 +3867,22 @@ class SurveyUtil {
 		if ($replace_count < 1) {
 			$full_invitation_text = $full_invitation_text."<br />\r\n<br />\r\n".$text_link;
 		}
+        
+        // Sending the mail
+		$sender_name  = api_get_person_name($_user['firstName'], $_user['lastName'], null, PERSON_NAME_EMAIL_ADDRESS);
+		$sender_email = $_user['mail'];
+        $sender_user_id = api_get_user_id();
+
+		$replyto = array();
+		if (api_get_setting('survey_email_sender_noreply') == 'noreply') {
+			$noreply = api_get_setting('noreply_email_address');
+			if (!empty($noreply)) {
+				$replyto['Reply-to'] = $noreply;
+				$sender_name = $noreply;
+				$sender_email = $noreply;
+                $sender_user_id = null;
+			}
+		}   
 
 		// Optionally: finding the e-mail of the course user
 		if (is_numeric($invitedUser)) {
@@ -3880,25 +3892,14 @@ class SurveyUtil {
 			$row = Database::fetch_array($result);
 			$recipient_email = $row['email'];
 			$recipient_name = api_get_person_name($row['firstname'], $row['lastname'], null, PERSON_NAME_EMAIL_ADDRESS);
+            
+            MessageManager::send_message($invitedUser, $invitation_title, $full_invitation_text, null, null, null, null, null, null, $sender_user_id);
+            
 		} else {
 			/** @todo check if the address is a valid email	 */
-			$recipient_email = $invitedUser;
+			$recipient_email = $invitedUser;        
+            @api_mail_html($recipient_name, $recipient_email, $invitation_title, $full_invitation_text, $sender_name, $sender_email, $replyto);
 		}
-
-		// Sending the mail
-		$sender_name  = api_get_person_name($_user['firstName'], $_user['lastName'], null, PERSON_NAME_EMAIL_ADDRESS);
-		$sender_email = $_user['mail'];
-
-		$replyto = array();
-		if (api_get_setting('survey_email_sender_noreply') == 'noreply') {
-			$noreply = api_get_setting('noreply_email_address');
-			if (!empty($noreply)) {
-				$replyto['Reply-to'] = $noreply;
-				$sender_name = $noreply;
-				$sender_email = $noreply;
-			}
-		}        
-		@api_mail_html($recipient_name, $recipient_email, $invitation_title, $full_invitation_text, $sender_name, $sender_email, $replyto);
 	}
 
 	/**

+ 8 - 3
main/survey/survey_invitation.php

@@ -49,6 +49,7 @@ if (!isset($_GET['survey_id']) OR !is_numeric($_GET['survey_id'])) {
 
 $survey_id = Security::remove_XSS($_GET['survey_id']);
 $survey_data = survey_manager::get_survey($survey_id);
+
 if (empty($survey_data)) {
 	Display :: display_header($tool_name);
 	Display :: display_error_message(get_lang('InvallidSurvey'), false);
@@ -107,9 +108,13 @@ echo '		<th>'.get_lang('InvitationDate').'</th>';
 echo '		<th>'.get_lang('Answered').'</th>';
 echo '	</tr>';
 
-$sql = "SELECT survey_invitation.*, user.firstname, user.lastname, user.email FROM $table_survey_invitation survey_invitation
-			LEFT JOIN $table_user user ON  survey_invitation.user = user.user_id
-			WHERE survey_invitation.survey_code = '".Database::escape_string($survey_data['code'])."'";
+$course_id = api_get_course_int_id();
+
+$sql = "SELECT survey_invitation.*, user.firstname, user.lastname, user.email 
+            FROM $table_survey_invitation survey_invitation
+			LEFT JOIN $table_user user ON (survey_invitation.user = user.user_id AND survey_invitation.c_id = $course_id)
+			WHERE survey_invitation.survey_code = '".Database::escape_string($survey_data['code'])."' ";
+
 $res = Database::query($sql);
 while ($row = Database::fetch_assoc($res)) {
 	if (!$_GET['view'] || $_GET['view'] == 'invited' || ($_GET['view'] == 'answered' && in_array($row['user'], $answered_data)) || ($_GET['view'] == 'unanswered' && !in_array($row['user'], $answered_data))) {

+ 1 - 1
main/survey/survey_invite.php

@@ -155,7 +155,7 @@ if ($form->validate()) {
 	SurveyUtil::save_invite_mail($values['mail_text'], $values['mail_title'], !empty($survey_data['invite_mail']));
 	// Saving the invitations for the course users
 	$count_course_users = SurveyUtil::save_invitations($values['course_users'], $values['mail_title'],
-		$values['mail_text'], $values['resend_to_all'], $values['send_mail'], $values['remindUnAnswered']);
+    $values['mail_text'], $values['resend_to_all'], $values['send_mail'], $values['remindUnAnswered']);
 	// Saving the invitations for the additional users
 	$values['additional_users'] = $values['additional_users'].';'; 	// This is for the case when you enter only one email
 	$temp = str_replace(',', ';', $values['additional_users']);		// This is to allow , and ; as email separators

+ 7 - 1
main/user/subscribe_user.php

@@ -19,6 +19,12 @@ $this_section = SECTION_COURSES;
 // notice for unauthorized people.
 api_protect_course_script(true);
 
+if (api_get_setting('allow_user_course_subscription_by_course_admin') == 'false') {
+    if (!api_is_platform_admin()) {
+        api_not_allowed(true);
+    }
+}
+
 // access restriction
 if (!api_is_allowed_to_edit()) {
 	 api_not_allowed(true);
@@ -644,7 +650,7 @@ function active_filter($active, $url_params, $row) {
 		$image='error';
 	}
 	if ($row['0']<>$_user['user_id']) { // you cannot lock yourself out otherwise you could disable all the accounts including your own => everybody is locked out and nobody can change it anymore.
-		$result = '<center>'.Display::return_icon($image.'.png',  get_lang(ucfirst($action)), array('border'=>'0', 'style'=>'vertical-align: middle;') , 16).'</center>';
+		$result = Display::return_icon($image.'.png',  get_lang(ucfirst($action)), array() , ICON_SIZE_TINY);
 	}
 	return $result;
 }

+ 9 - 2
main/user/user.php

@@ -404,11 +404,18 @@ if ( api_is_allowed_to_edit(null, true)) {
     }
     $actions .= '<a href="user.php?'.api_get_cidreq().'&action=export&amp;type=csv">'.Display::return_icon('export_csv.png', get_lang('ExportAsCSV'),'',ICON_SIZE_MEDIUM).'</a> ';
     $actions .= '<a href="user.php?'.api_get_cidreq().'&action=export&amp;type=xls">'.Display::return_icon('export_excel.png', get_lang('ExportAsXLS'),'',ICON_SIZE_MEDIUM).'</a> ';
-    $actions .= '<a href="user_import.php?'.api_get_cidreq().'&action=import">'.Display::return_icon('import_csv.png', get_lang('ImportUsersToACourse'),'',ICON_SIZE_MEDIUM).'</a> ';
+    
+    if (api_get_setting('allow_user_course_subscription_by_course_admin') == 'true' or api_is_platform_admin()) {
+        $actions .= '<a href="user_import.php?'.api_get_cidreq().'&action=import">'.Display::return_icon('import_csv.png', get_lang('ImportUsersToACourse'),'',ICON_SIZE_MEDIUM).'</a> ';
+    }
+    
     $actions .= '<a href="user.php?'.api_get_cidreq().'&action=export&type=pdf">'.Display::return_icon('pdf.png', get_lang('ExportToPDF'),'',ICON_SIZE_MEDIUM).'</a> ';
     $actions .= "<a href=\"../group/group.php?".api_get_cidreq()."\">".Display::return_icon('group.png', get_lang("GroupUserManagement"),'',ICON_SIZE_MEDIUM)."</a>";
     
-    $actions .= ' <a class="btn" href="class.php?'.api_get_cidreq().'">'.get_lang('Classes').'</a>';    
+    if (api_get_setting('allow_user_course_subscription_by_course_admin') == 'true' or api_is_platform_admin()) {
+        $actions .= ' <a class="btn" href="class.php?'.api_get_cidreq().'">'.get_lang('Classes').'</a>';    
+    }
+    
     //$actions .= ' <a class="btn" href="social_groups.php?'.api_get_cidreq().'">'.get_lang('SocialGroups').'</a>';
 		
 	// Build search-form

+ 6 - 0
main/user/user_import.php

@@ -11,6 +11,12 @@ $this_section = SECTION_COURSES;
 // notice for unauthorized people.
 api_protect_course_script(true);
 
+if (api_get_setting('allow_user_course_subscription_by_course_admin') == 'false') {
+    if (!api_is_platform_admin()) {
+        api_not_allowed(true);
+    }
+}
+
 $tool_name = get_lang('ImportUsersToACourse');
 
 $interbreadcrumb[] = array ("url" => "user.php", "name" => get_lang("Users"));

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