Browse Source

More code cleaning

Julio Montoya 15 years ago
parent
commit
539093eb0e
2 changed files with 43 additions and 48 deletions
  1. 23 20
      main/calendar/agenda.inc.php
  2. 20 28
      main/calendar/myagenda.inc.php

+ 23 - 20
main/calendar/agenda.inc.php

@@ -731,17 +731,16 @@ function plus_ical() {
 * @author: Patrick Cool <patrick.cool@UGent.be>, Ghent University
 * @return javascript code
 */
-function user_group_filter_javascript()
-{
-return "<script language=\"JavaScript\" type=\"text/JavaScript\">
-<!--
-function MM_jumpMenu(targ,selObj,restore){
-  eval(targ+\".location='\"+selObj.options[selObj.selectedIndex].value+\"'\");
-  if (restore) selObj.selectedIndex=0;
-}
-//-->
-</script>
-";
+function user_group_filter_javascript() {
+	return "<script language=\"JavaScript\" type=\"text/JavaScript\">
+	<!--
+	function MM_jumpMenu(targ,selObj,restore){
+	  eval(targ+\".location='\"+selObj.options[selObj.selectedIndex].value+\"'\");
+	  if (restore) selObj.selectedIndex=0;
+	}
+	//-->
+	</script>
+	";
 }
 
 
@@ -1457,10 +1456,9 @@ function change_visibility($tool,$id,$visibility)
 function display_courseadmin_links() {
 	//echo "<a href='".api_get_self()."?".api_get_cidreq()."&action=add&amp;view=".(($_SESSION['view']=='month')?"list":Security::remove_XSS($_SESSION['view'])."&amp;origin=".Security::remove_XSS($_GET['origin']))."'>".Display::return_icon('calendar_add.gif', get_lang('AgendaAdd'))." ".get_lang('AgendaAdd')."</a>";
 	  echo "<a href='".api_get_self()."?".api_get_cidreq()."&amp;sort=asc&amp;toolgroup=".Security::remove_XSS($_GET['toolgroup'])."&action=add&amp;view=".(($_SESSION['view']=='month')?"list":Security::remove_XSS($_SESSION['view'])."&amp;origin=".Security::remove_XSS($_GET['origin']))."'>".Display::return_icon('calendar_add.gif', get_lang('AgendaAdd'))." ".get_lang('AgendaAdd')."</a>";
-	if (empty ($_SESSION['toolgroup']))
-	{
+	if (empty ($_SESSION['toolgroup'])) {
 		echo get_lang('UserGroupFilter');
-		echo "<form name=\"filter\" style=\"display:inline;\">";
+		echo "&nbsp;&nbsp;<form name=\"filter\" style=\"display:inline;\">";
 		show_user_group_filter_form();
 		echo "</form> ";
 	}
@@ -2065,16 +2063,19 @@ function display_agenda_items($select_month, $select_year) {
     	// we add the groups icon
     	// 2do: if it is sent to groups we display the group icon, if it is sent to a user we show the user icon
     	if ($myrow['calendar_type'] != 'personal') {
-    		echo '<div style="padding-left:5px; font-size:130%; float:left;">';    		
-    		Display::display_icon('agenda.gif', get_lang('Agenda'));
+    		  		
+    		Display::display_icon('agenda.gif', get_lang('Agenda'));    		  
     		if ($myrow['to_group_id']!=='0') {
     			echo Display::return_icon('group.gif', get_lang('ItemForUserSelection'));
     		}    		
+    		echo '<span style="padding-left:5px; font-size:130%; ">';
     		echo $myrow['title'];
-    		echo '</div>';
+    		echo '</span>';
     	} else {
-    		Display::display_icon('calendar_personal.gif', get_lang('Personal'));    		
-    		echo $myrow['title'];    		
+    		Display::display_icon('calendar_personal.gif', get_lang('Personal'));
+    		echo '<span style="padding-left:5px; font-size:130%; ">';    		
+    		echo $myrow['title'];
+    		echo '</span>';    		
     	}    	
     	echo '</th>';
     	
@@ -2089,12 +2090,14 @@ function display_agenda_items($select_month, $select_year) {
 			echo '<th>'.get_lang('Personal').'</th>';	
 		}
 		
-    	if (!$is_repeated && (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_edit_agenda') && !api_is_anonymous()))) {
+    	if (!$is_repeated && (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_edit_agenda') && !api_is_anonymous())) && $myrow['calendar_type'] != 'personal' ) {
     		if( ! (api_is_course_coach() && !api_is_element_in_the_session(TOOL_AGENDA, $myrow['id'] ) ) ) { 
     			// a coach can only delete an element belonging to his session
 	    		echo '<th>'.get_lang('Modify');
 	    		echo '</th></tr>';
 			}
+    	} else {
+    		echo '<th></th></tr>';
     	}
 
         /*	display: the title	*/

+ 20 - 28
main/calendar/myagenda.inc.php

@@ -688,19 +688,17 @@ function get_personal_agenda_item($id) {
  * these items in one list (ordered by date and grouped by month (the month_bar)
  */
 function show_personal_agenda() {
-	global $MonthsLong, $charset;
-	global $_user;
+	global $MonthsLong, $charset;	
 	
 	$tbl_personal_agenda = Database :: get_user_personal_table(TABLE_PERSONAL_AGENDA);
 	
 	// The SQL statement that retrieves all the personal agenda items of this user
-	$sql = "SELECT * FROM ".$tbl_personal_agenda." WHERE user='".$_user['user_id']."' ORDER BY date DESC";
+	$sql = "SELECT * FROM ".$tbl_personal_agenda." WHERE user='".api_get_user_id()."' ORDER BY date DESC";
 	$result = Database::query($sql);
 	// variable initialisation
 	$month_bar = "";
 	// setting the default day, month and year
-	if (!$_GET['day'] AND !$_GET['month'] AND !$_GET['year'])
-	{
+	if (!$_GET['day'] AND !$_GET['month'] AND !$_GET['year']) {
 		$today = getdate();
 		$year = $today['year'];
 		$month = $today['mon'];
@@ -711,32 +709,33 @@ function show_personal_agenda() {
 	$export_icon_high = 'export_high_fade.png';
 
 	// starting the table output
-	echo "<table class=\"data_table\">";
+	echo '<table class="data_table">';
 
-	if (Database::num_rows($result) > 0)
-	{
-		while ($myrow = Database::fetch_array($result))
-		{
-			/*--------------------------------------------------
-					display: the month bar
-			  --------------------------------------------------*/
-			if ($month_bar != date("m", strtotime($myrow["date"])).date("Y", strtotime($myrow["date"])))
-			{
+	if (Database::num_rows($result) > 0) {
+		while ($myrow = Database::fetch_array($result)) {
+			/* 	display: the month bar		*/
+			if ($month_bar != date("m", strtotime($myrow["date"])).date("Y", strtotime($myrow["date"]))) {
 				$month_bar = date("m", strtotime($myrow["date"])).date("Y", strtotime($myrow["date"]));
 				echo "<tr><th class=\"title\" colspan=\"2\" class=\"month\" valign=\"top\">".$MonthsLong[date("n", strtotime($myrow["date"])) - 1]." ".date("Y", strtotime($myrow["date"]))."</th></tr>";
 			}
 			// highlight: if a date in the small calendar is clicked we highlight the relevant items
 			$db_date = (int) date("d", strtotime($myrow["date"])).date("n", strtotime($myrow["date"])).date("Y", strtotime($myrow["date"]));
-			if ($_GET["day"].$_GET["month"].$_GET["year"] <> $db_date)
-			{
+			if ($_GET["day"].$_GET["month"].$_GET["year"] <> $db_date) {
 				$style = "data";
 				$text_style = "text";
-			}
-			else
-			{
+			} else {
 				$style = "datanow";
 				$text_style = "text";
 			}
+			
+			/*	display: the title	*/
+			
+			echo "<tr>";
+			echo '<td class="'.$style.'" colspan="2">';
+			echo $myrow['title'];
+			echo "</td>";
+			echo "</tr>";
+			
 			/*--------------------------------------------------
 			 			display: date and time
 			  --------------------------------------------------*/
@@ -754,14 +753,7 @@ function show_personal_agenda() {
 			//echo '<a class="ical_export" href="ical_export.php?type=personal&id='.$myrow['id'].'&class=public" title="'.get_lang('ExportiCalPublic').'">'.Display::return_icon($export_icon, get_lang('ExportiCalPublic')).'</a>';
 			//echo "</td>";
 			echo "</tr>";
-			/*--------------------------------------------------
-			 			display: the title
-			  --------------------------------------------------*/
-			echo "<tr>";
-			echo '<td class="'.$style.'" colspan="2">';
-			echo $myrow['title'];
-			echo "</td>";
-			echo "</tr>";
+
 			/*--------------------------------------------------
 			 			display: the content
 			  --------------------------------------------------*/