Browse Source

Minor - improving usability in group list

Julio Montoya 13 years ago
parent
commit
cc60cd7e9d

+ 51 - 39
main/group/group.php

@@ -268,42 +268,51 @@ foreach ($group_cats as $index => $category) {
 			} else {
 				$row[] = $this_group['name'].'<br />'.stripslashes(trim($this_group['description']));
 			}
-			// Self-registration / unregistration
-			if (!api_is_allowed_to_edit(false, true)) {
-				if (GroupManager :: is_self_registration_allowed($_user['user_id'], $this_group['id'])) {
-					$row[] = '<a href="group.php?'.api_get_cidreq().'&category='.$category['id'].'&amp;action=self_reg&amp;group_id='.$this_group['id'].'" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES, $charset))."'".')) return false;">'.get_lang('GroupSelfRegInf').'</a>';
-				} elseif (GroupManager :: is_self_unregistration_allowed($_user['user_id'], $this_group['id'])) {
-					$row[] = '<a href="group.php?'.api_get_cidreq().'&category='.$category['id'].'&amp;action=self_unreg&amp;group_id='.$this_group['id'].'" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES, $charset))."'".')) return false;">'.get_lang('GroupSelfUnRegInf').'</a>';
-				} else {
-					$row[] = '-';
-				}
-			}
+            
+            
+            
+            // Tutor name
+            $tutor_info = '';
+
+            if (count($tutorsids_of_group) > 0) {
+                foreach ($tutorsids_of_group as $tutor_id) {
+                    $tutor = api_get_user_info($tutor_id);
+                    if (api_get_setting('show_email_addresses') == 'true') {
+                        $tutor_info .= Display::encrypted_mailto_link($tutor['mail'], api_get_person_name($tutor['firstName'], $tutor['lastName'])).', ';
+                    } else {
+                        if (api_is_allowed_to_edit()) {
+                            $tutor_info .= Display::encrypted_mailto_link($tutor['mail'], api_get_person_name($tutor['firstName'], $tutor['lastName'])).', ';
+                        } else {
+                            $tutor_info .= api_get_person_name($tutor['firstName'], $tutor['lastName']).', ';
+                        }
+                    }
+                }
+            }
+            $tutor_info = api_substr($tutor_info, 0, api_strlen($tutor_info) - 2);
+            $row[] = $tutor_info;
+            
+		
+            // Max number of members in group
+            $max_members = ($this_group['maximum_number_of_members'] == MEMBER_PER_GROUP_NO_LIMIT ? '-' : $this_group['maximum_number_of_members']);
+            
+            
 			// Number of members in group
-			$row[] = $this_group['number_of_members'];
-			// Max number of members in group
-			$row[] = ($this_group['maximum_number_of_members'] == MEMBER_PER_GROUP_NO_LIMIT ? '-' : $this_group['maximum_number_of_members']);
-			// Tutor name
-			$tutor_info = '';
-
-			if (count($tutorsids_of_group) > 0) {
-				foreach ($tutorsids_of_group as $tutor_id) {
-					$tutor = api_get_user_info($tutor_id);
-					if (api_get_setting('show_email_addresses') == 'true') {
-						$tutor_info .= Display::encrypted_mailto_link($tutor['mail'], api_get_person_name($tutor['firstName'], $tutor['lastName'])).', ';
-					} else {
-						if (api_is_allowed_to_edit()) {
-							$tutor_info .= Display::encrypted_mailto_link($tutor['mail'], api_get_person_name($tutor['firstName'], $tutor['lastName'])).', ';
-						} else {
-							$tutor_info .= api_get_person_name($tutor['firstName'], $tutor['lastName']).', ';
-						}
-					}
-				}
-			}
-			$tutor_info = api_substr($tutor_info, 0, api_strlen($tutor_info) - 2);
-			$row[] = $tutor_info;
+			$row[] = $this_group['number_of_members'].'/'.$max_members;
+			
+                // Self-registration / unregistration
+            if (!api_is_allowed_to_edit(false, true)) {
+                if (GroupManager :: is_self_registration_allowed($_user['user_id'], $this_group['id'])) {
+                    $row[] = '<a class = "a_button gray small" href="group.php?'.api_get_cidreq().'&category='.$category['id'].'&amp;action=self_reg&amp;group_id='.$this_group['id'].'" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES, $charset))."'".')) return false;">'.get_lang('GroupSelfRegInf').'</a>';
+                } elseif (GroupManager :: is_self_unregistration_allowed($_user['user_id'], $this_group['id'])) {
+                    $row[] = '<a class = "a_button gray small" href="group.php?'.api_get_cidreq().'&category='.$category['id'].'&amp;action=self_unreg&amp;group_id='.$this_group['id'].'" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES, $charset))."'".')) return false;">'.get_lang('GroupSelfUnRegInf').'</a>';
+                } else {
+                    $row[] = '-';
+                }
+            }
+
 			// Edit-links
 			if (api_is_allowed_to_edit(false, true)  && !(api_is_course_coach() && intval($this_group['session_id']) != intval($_SESSION['id_session']))) {
-				$edit_actions = '<a href="group_edit.php?'.api_get_cidreq().'&gidReq='.$this_group['id'].'"  title="'.get_lang('Edit').'">'.Display::return_icon('settings.png', get_lang('EditGroup'),'','22').'</a>&nbsp;';								
+				$edit_actions = '<a href="group_edit.php?'.api_get_cidreq().'&gidReq='.$this_group['id'].'"  title="'.get_lang('Edit').'">'.Display::return_icon('edit.png', get_lang('EditGroup'),'','22').'</a>&nbsp;';								
 				$edit_actions .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&category='.$category['id'].'&amp;action=empty_one&amp;id='.$this_group['id'].'" onclick="javascript: if(!confirm('."'".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES))."'".')) return false;" title="'.get_lang('EmptyGroup').'">'.Display::return_icon('clean.png',get_lang('EmptyGroup'),'','22').'</a>&nbsp;';				
 				$edit_actions .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&category='.$category['id'].'&amp;action=fill_one&amp;id='.$this_group['id'].'" onclick="javascript: if(!confirm('."'".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES))."'".')) return false;" title="'.get_lang('FillGroup').'">'.Display::return_icon('fill.png',get_lang('FillGroup'),'','22').'</a>&nbsp;';
 				$edit_actions .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&category='.$category['id'].'&amp;action=delete_one&amp;id='.$this_group['id'].'" onclick="javascript: if(!confirm('."'".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES))."'".')) return false;" title="'.get_lang('Delete').'">'.Display::return_icon('delete.png', get_lang('Delete'),'','22').'</a>&nbsp;';
@@ -327,13 +336,16 @@ foreach ($group_cats as $index => $category) {
 		if (api_is_allowed_to_edit(false, true) and count($group_list) > 1) {
 			$table->set_header($column++, '', false);
 		}
-		$table->set_header($column++, get_lang('ExistingGroups'));
+		$table->set_header($column++, get_lang('Groups'));
+        $table->set_header($column++, get_lang('GroupTutor'));
+        		
+		$table->set_header($column++, get_lang('Registered'), false);
+		
 		if (!api_is_allowed_to_edit(false, true)) { // If self-registration allowed
-			$table->set_header($column++, get_lang('GroupSelfRegistration'));
-		}
-		$table->set_header($column++, get_lang('Registered'));
-		$table->set_header($column++, get_lang('MaximumOfParticipants'));
-		$table->set_header($column++, get_lang('GroupTutor'));
+            $table->set_header($column++, get_lang('GroupSelfRegistration'), false);
+        }
+		//$table->set_header($column++, get_lang('MaximumOfParticipants'));
+		
 		if (api_is_allowed_to_edit(false, true)) { // Only for course administrator
 			$table->set_header($column++, get_lang('Modify'), false);
 			$form_actions = array();

+ 2 - 1
main/group/group_creation.php

@@ -161,7 +161,7 @@ elseif (isset($_POST['number_of_groups'])) {
 
 EOT;
 		$renderer->setElementTemplate($element_template);
-		$form->addElement('header', '', $nameTools);
+		//$form->addElement('header', '', $nameTools);
 
 		$form->addElement('hidden', 'action');
 		$form->addElement('hidden', 'number_of_groups');
@@ -216,6 +216,7 @@ EOT;
 		$defaults['number_of_groups'] = intval($_POST['number_of_groups']);
 		$form->setDefaults($defaults);
 		$form->addElement('style_submit_button', 'submit', get_lang('CreateGroup'), 'class="save"');
+        echo Display::tag('h2',$nameTools);
 		$form->display();
 	}
 } else {

+ 34 - 25
main/group/group_overview.php

@@ -78,38 +78,47 @@ if (!isset ($_GET['origin']) || $_GET['origin'] != 'learnpath') {
 
 // Action links
 echo '<div class="actions">';
-echo '<a href="group_creation.php?'.api_get_cidreq().'">'.Display::return_icon('new_group.png', get_lang('NewGroupCreate'),'','32').'</a>';
-echo '<a href="group.php?'.api_get_cidreq().'">'.Display::return_icon('group.png', get_lang('Groups'),'','32').'</a>';
-if (api_get_setting('allow_group_categories') == 'true') {
-	echo '<a href="group_category.php?'.api_get_cidreq().'&action=add_category">'.Display::return_icon('new_folder.png', get_lang('AddCategory'),'','32').'</a>';
-} else {
-	//echo '<a href="group_category.php?'.api_get_cidreq().'&id=2">'.Display::return_icon('edit_group.gif').'&nbsp;'.get_lang('PropModify').'</a>&nbsp;';
-	echo '<a href="group_category.php?'.api_get_cidreq().'&id=2">'.Display::return_icon('settings.png', get_lang('PropModify'),'','32').'</a>';
-}
-//echo Display::return_icon('csv.gif', get_lang('ExportAsCSV')).'<a href="group_overview.php?'.api_get_cidreq().'&action=export&type=csv">'.get_lang('ExportAsCSV').'</a> ';
-echo '<a href="group_overview.php?'.api_get_cidreq().'&action=export&type=xls">'.Display::return_icon('export_excel.png', get_lang('ExportAsXLS'),'','32').'</a>';
+    echo '<a href="group_creation.php?'.api_get_cidreq().'">'.Display::return_icon('new_group.png', get_lang('NewGroupCreate'),'','32').'</a>';
+    echo '<a href="group.php?'.api_get_cidreq().'">'.Display::return_icon('group.png', get_lang('Groups'),'','32').'</a>';
+    if (api_get_setting('allow_group_categories') == 'true') {
+    	echo '<a href="group_category.php?'.api_get_cidreq().'&action=add_category">'.Display::return_icon('new_folder.png', get_lang('AddCategory'),'','32').'</a>';
+    } else {
+    	//echo '<a href="group_category.php?'.api_get_cidreq().'&id=2">'.Display::return_icon('edit_group.gif').'&nbsp;'.get_lang('PropModify').'</a>&nbsp;';
+    	echo '<a href="group_category.php?'.api_get_cidreq().'&id=2">'.Display::return_icon('settings.png', get_lang('PropModify'),'','32').'</a>';
+    }
+    //echo Display::return_icon('csv.gif', get_lang('ExportAsCSV')).'<a href="group_overview.php?'.api_get_cidreq().'&action=export&type=csv">'.get_lang('ExportAsCSV').'</a> ';
+    echo '<a href="group_overview.php?'.api_get_cidreq().'&action=export&type=xls">'.Display::return_icon('export_excel.png', get_lang('ExportAsXLS'),'','32').'</a>';
 echo '</div>';
 
 $categories = GroupManager::get_categories();
+
 foreach ($categories as $index => $category) {
 	if (api_get_setting('allow_group_categories') == 'true') {
-		echo '<h3>'.$category['title'].'</h3>';
+		echo '<h2>'.$category['title'].'</h2>';
 	}
 	$groups = GroupManager::get_group_list($category['id']);
-	echo '<ul>';
-	foreach ($groups as $index => $group) {
-		echo '<li>';
-		echo stripslashes($group['name']);
-		echo '<ul>';
-		$users = GroupManager::get_users($group['id']);
-		foreach ($users as $index => $user) {
-			$user_info = api_get_user_info($user);
-			echo '<li>'.api_get_person_name($user_info['firstName'], $user_info['lastName']).'</li>';
-		}
-		echo '</ul>';
-		echo '</li>';
-	}
-	echo '</ul>';
+    echo '<ul>';
+	if (!empty($groups)) {    	
+    	foreach ($groups as $index => $group) {
+    		echo '<li>';
+        		echo Display::tag('h3', Security::remove_XSS($group['name']));
+        		echo '<ul>';
+        		$users = GroupManager::get_users($group['id']);
+                if (!empty($users)) {
+            		foreach ($users as $index => $user) {
+            			$user_info = api_get_user_info($user);
+            			echo '<li>'.api_get_person_name($user_info['firstName'], $user_info['lastName']).'</li>';
+            		}            	
+                } else {
+                    //echo Display::tag('li', get_lang('NoStudents'));            
+                }
+                echo '</ul>';
+    		echo '</li>';
+    	}    	
+    } else {        
+        //echo Display::tag('li', get_lang('NoData'));   
+    }    
+    echo '</ul>';
 }
 
 /*	FOOTER */

+ 16 - 11
main/group/group_space.php

@@ -80,26 +80,21 @@ if (!empty($_GET['selfUnReg']) && GroupManager :: is_self_unregistration_allowed
 }
 echo '<div class="actions">';
 echo '<a href="group.php">'.Display::return_icon('back.png',get_lang('BackToGroupList'),'','32').'</a>';
-/*
- * Edit the group
- */
-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 : '';
-	echo '<a href="group_edit.php?origin='.$my_origin.'&gidReq='.api_get_group_id().'">'.Display::return_icon('settings.png', get_lang('EditGroup'),'','32').'</a>';
-}
 
 /*
  * Register to group
  */
+$subscribe_group = '';
 if (GroupManager :: is_self_registration_allowed($_SESSION['_user']['user_id'], $current_group['id'])) {
-	echo '<a href="'.api_get_self().'?selfReg=1&amp;group_id='.$current_group['id'].'" onclick="javascript: if(!confirm('."'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"), ENT_QUOTES))."'".')) return false;">'.Display::return_icon('groupadd.gif').get_lang("RegIntoGroup").'</a>';
+	$subscribe_group = '<a class="a_button gray small" href="'.api_get_self().'?selfReg=1&amp;group_id='.$current_group['id'].'" onclick="javascript: if(!confirm('."'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"), ENT_QUOTES))."'".')) return false;">'.get_lang("RegIntoGroup").'</a>';
 }
 
 /*
  * Unregister from group
  */
+$unsubscribe_group = '';
 if (GroupManager :: is_self_unregistration_allowed($_SESSION['_user']['user_id'], $current_group['id'])) {
-	echo '<a href="'.api_get_self().'?selfUnReg=1" onclick="javascript: if(!confirm('."'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES))."'".')) return false;">'.Display::return_icon('group_delete.gif').get_lang("StudentUnsubscribe").'</a>';
+	$unsubscribe_group = '<a class="a_button gray small" href="'.api_get_self().'?selfUnReg=1" onclick="javascript: if(!confirm('."'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES))."'".')) return false;">'.get_lang("StudentUnsubscribe").'</a>';
 }
 echo '&nbsp;</div>';
 
@@ -119,10 +114,20 @@ $is_course_member = CourseManager :: is_user_subscribed_in_real_or_linked_course
 /*
  * Group title and comment
  */
-echo Display::tag('h2', stripslashes($current_group['name']));
+
+ /*
+ * Edit the group
+ */
+$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'),'','22').'</a>';
+}
+
+echo Display::tag('h2', Security::remove_XSS($current_group['name']).' '.$edit_url.' '.$subscribe_group.' '.$unsubscribe_group);
 
 if (!empty($current_group['description'])) {
-	echo '<p>'.stripslashes($current_group['description']).'</p>';
+	echo '<p>'.Security::remove_XSS($current_group['description']).'</p>';
 }
 
 /*

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

@@ -205,7 +205,7 @@ class GroupManager {
 			//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
+		 $sql = "INSERT INTO ".$table_group." SET
 				c_id = $course_id , 
 				category_id='".Database::escape_string($category_id)."', 
 				max_student = '".$places."',