Browse Source

Using the new js calendar

Julio Montoya 13 years ago
parent
commit
f52a911079

+ 0 - 9
main/admin/calendar.lib.php

@@ -459,15 +459,6 @@ function store_new_agenda_item() {
 	return $last_id;
 }
 
-/**
-* The links that allows the student AND course administrator to show all agenda items and sort up/down
-* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
-*/
-function display_courseadmin_links() {
-	echo "<a href='".api_get_self()."?".api_get_cidreq()."&action=add&amp;origin=".Security::remove_XSS($_GET['origin'])."'>".Display::return_icon('new_platform_event.png', get_lang('AgendaAdd'),'','32')."</a>";
-
-}
-
 function display_student_links() {
 	if ($_SESSION['view'] <> 'month') {
 		echo '<a href="'.api_get_self().'?action=view&amp;view=month">'.

+ 19 - 10
main/calendar/agenda.inc.php

@@ -1544,15 +1544,22 @@ function change_visibility($tool,$id,$visibility)
 * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
 */
 function display_courseadmin_links() {
-	echo "<a href='".api_get_self()."?".api_get_cidreq()."&amp;sort=asc&amp;toolgroup=".api_get_group_id()."&action=add&amp;view=".(($_SESSION['view']=='month')?"list":Security::remove_XSS($_SESSION['view'])."&amp;origin=".Security::remove_XSS($_GET['origin']))."'>".Display::return_icon('new_event.png', get_lang('AgendaAdd'),'','32')."</a>";
-	echo "<a href='".api_get_self()."?".api_get_cidreq()."&action=importical&amp;view=".(($_SESSION['view']=='month')?"list":Security::remove_XSS($_SESSION['view'])."&amp;origin=".Security::remove_XSS($_GET['origin']))."'>".Display::return_icon('import_calendar.png', get_lang('ICalFileImport'),'','32')."</a>";
+	if (!isset($_GET['action'])) {
+		$actions = "<a href='agenda_js.php?type=course&".api_get_cidreq()."'>".Display::return_icon('calendar_na.png', get_lang('Agenda'),'','32')."</a>";
+	} else {
+		$actions = "<a href='agenda_js.php?type=course&".api_get_cidreq()."'>".Display::return_icon('calendar.png', get_lang('Agenda'),'','32')."</a>";
+	}
+	$actions .= "<a href='agenda.php?".api_get_cidreq()."&amp;sort=asc&amp;toolgroup=".api_get_group_id()."&action=add&amp;view=".(($_SESSION['view']=='month')?"list":Security::remove_XSS($_SESSION['view'])."&amp;origin=".Security::remove_XSS($_GET['origin']))."'>".Display::return_icon('new_event.png', get_lang('AgendaAdd'),'','32')."</a>";
+	$actions .= "<a href='agenda.php?".api_get_cidreq()."&action=importical&amp;view=".(($_SESSION['view']=='month')?"list":Security::remove_XSS($_SESSION['view'])."&amp;origin=".Security::remove_XSS($_GET['origin']))."'>".Display::return_icon('import_calendar.png', get_lang('ICalFileImport'),'','32')."</a>";
 	
+	return $actions;
+	/*
 	if (empty ($_SESSION['toolgroup'])) {
 		echo get_lang('SentTo');
 		echo "&nbsp;&nbsp;<form name=\"filter\" style=\"display:inline;\">";
 		show_user_group_filter_form();
 		echo "</form> ";
-	}
+	}*/
 }
 
 
@@ -2455,7 +2462,7 @@ function show_add_form($id = '') {
 	echo 	'	</div>
 			</div>';
 	
-	echo 	'<div class="row">
+	/*echo 	'<div class="row">
 	<div class="label">
 	</div><div class="formw">';
 	if ($default_no_empty_end_date) {
@@ -2463,9 +2470,9 @@ function show_add_form($id = '') {
 	} else {
 		$params = array('id'=>'empty_end_date');
 	}
-	echo Display::input('checkbox', 'empty_end_date', 0, $params).' '.get_lang('DisableEndDate');
+	//echo Display::input('checkbox', 'empty_end_date', 0, $params).' '.get_lang('DisableEndDate');
 	
-	echo 	'</div></div>';
+	echo 	'</div></div>';*/
 	echo '<script>
 				$(function() {				
 					$("#empty_end_date").click(function(){
@@ -4259,10 +4266,12 @@ function edit_agenda_attachment_file($file_comment, $agenda_id, $id_attach) {
  * @return  boolean False if error, True otherwise
  */
 function agenda_add_repeat_item($course_info, $orig_id, $type, $end, $orig_dest, $file_comment='') {
-	$t_agenda   = Database::get_course_table(TABLE_AGENDA,$course_info['dbName']);
-    $t_agenda_r = Database::get_course_table(TABLE_AGENDA_REPEAT,$course_info['dbName']);
+	$t_agenda   = Database::get_course_table(TABLE_AGENDA);
+    $t_agenda_r = Database::get_course_table(TABLE_AGENDA_REPEAT);
+	
+	$course_id = $course_info['real_id'];
 
-    $sql = 'SELECT title, content, start_date as sd, end_date as ed FROM '. $t_agenda.' WHERE id ="'.intval($orig_id).'" ';
+    $sql = 'SELECT title, content, start_date as sd, end_date as ed FROM '. $t_agenda.' WHERE c_id = '.$course_id.' AND id ="'.intval($orig_id).'" ';
     $res = Database::query($sql);
     if(Database::num_rows($res)!==1){return false;}
     $row = Database::fetch_array($res);
@@ -4300,7 +4309,7 @@ function agenda_add_repeat_item($course_info, $orig_id, $type, $end, $orig_dest,
                 break;
         }
     }
-    $course_id = api_get_course_int_id();
+    
     if ($end > $now
         && in_array($type,array('daily','weekly','monthlyByDate','monthlyByDay','monthlyByDayR','yearly'))) {
        $sql = "INSERT INTO $t_agenda_r (c_id, cal_id, cal_type, cal_end) VALUES ($course_id, '$orig_id','$type',$end)";

+ 15 - 57
main/calendar/agenda.php

@@ -25,10 +25,15 @@ if(isset($_GET['id_session'])) {
 $action = isset($_GET['action']) ? $_GET['action'] : null;
 $origin = isset($_GET['origin']) ? $_GET['origin'] : null; 
 
-$this_section=SECTION_COURSES;
+$this_section = SECTION_COURSES;
 
 require_once api_get_path(LIBRARY_PATH).'groupmanager.lib.php';
 
+if (empty($action)) {
+	header('Location: agenda_js.php?type=course');
+	exit;
+}
+
 /* 	Resource linker */
 $_SESSION['source_type'] = 'Agenda';
 require_once '../resourcelinker/resourcelinker.inc.php';
@@ -183,40 +188,13 @@ if (empty($select_month)) {
 }
 
 echo '<div class="actions">';
+
 if (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_edit_agenda') && !api_is_anonymous()) && api_is_allowed_to_session_edit(false,true)) {
-	display_courseadmin_links();
+	echo display_courseadmin_links();
 }
-display_student_links();
-echo '</div>';
-
-
-// Getting agenda items
 
-$agenda_items = get_calendar_items($select_month, $select_year);
-
-if ($_SESSION['view'] != 'month') {
-	echo '<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr>';
-
-	// THE LEFT PART
-	if (empty($origin) or $origin !='learnpath') {
-		echo '<td width="220" height="19" valign="top">';
-		// the small calendar
-		if (api_get_setting('display_mini_month_calendar') == 'true') {
-			display_minimonthcalendar($agenda_items, $select_month, $select_year);
-		}
-		echo '<br />';
-		if (api_get_setting('display_upcoming_events') == 'true') {
-			display_upcoming_events();
-		}
-		echo '</td>';
-		echo '<td width="20" background="../img/verticalruler.gif">&nbsp;</td>';
-	}
-
-	// THE RIGHT PART
-	echo '<td valign="top">';
-	echo '<div class="sort" style="float:left">';
-	echo '</div>';
-}
+//display_student_links();
+echo '</div>';
 
 $event_id = isset($_GET['id']) ? $_GET['id'] : null;
 $course_info = api_get_course_info(); 
@@ -241,7 +219,9 @@ if (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_ed
 					$end   = mktime(23, 59, 59, $end_m, $end_d, $end_y);
 					$res   = agenda_add_repeat_item($course_info,$id, $_POST['repeat_type'], $end,$_POST['selectedform'], $safe_file_comment);
 				}
-				$action = 'view';
+				
+				Display::display_confirmation_message(get_lang('AddSuccess'));
+				
 			} else {
 				show_add_form();
 			}
@@ -315,33 +295,11 @@ if (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_ed
 				delete_attachment_file($id_attach);
 				$action = 'view';
 			}			
-			break;
+			break;		
+			
 	}
 }
 
-$agenda_items = get_calendar_items($select_month, $select_year);
-
-// this is for students and whenever the courseaministrator has not chosen any action. It is in fact the default behaviour
-
-if ($action == "view" || empty($action)) {    
-	if ($origin != 'learnpath') {	    
-		if ($_SESSION['view'] == 'month') {
-		    display_monthcalendar($select_month, $select_year, $agenda_items);            
-		} else {
-		  if (!empty($_GET['agenda_id'])) {
-                display_one_agenda_item($_GET['agenda_id']);
-            } else {
-                $month_name = $MonthsLong[$select_month -1];                
-                echo Display::tag('h2', $select_day.' '.$month_name.' '.$select_year);                
-                display_agenda_items($agenda_items, $select_day);
-            }
-		}
-	} 	
-}	
-
-echo '</td></tr></table>';
-
-/*		FOOTER */
 // The footer is displayed only if we are not in the learnpath
 if ($origin != 'learnpath') {
 	Display::display_footer();

+ 9 - 2
main/calendar/agenda_js.php

@@ -16,6 +16,8 @@ $use_anonymous = true;
 require_once '../inc/global.inc.php';
 require_once 'agenda.lib.php';
 
+require_once 'agenda.inc.php';
+
 $htmlHeadXtra[] = api_get_jquery_ui_js();
 $htmlHeadXtra[] = api_get_js('qtip2/jquery.qtip.min.js');
 $htmlHeadXtra[] = api_get_js('fullcalendar/fullcalendar.min.js');
@@ -69,6 +71,13 @@ $tpl->assign('button_text', 		json_encode(array(	'today'	=> get_lang('Today'),
 														'month'	=> get_lang('Month'), 
 														'week'	=> get_lang('Week'), 
 														'day'	=> get_lang('Day'))));
+
+if (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_edit_agenda') && !api_is_anonymous()) && api_is_allowed_to_session_edit(false,true)) {
+	$actions = display_courseadmin_links();
+
+	$tpl->assign('actions', $actions);
+}
+
 //Calendar Type : course, admin, personal
 $tpl->assign('type', $type);
 //Calendar type label
@@ -100,7 +109,5 @@ if (api_is_allowed_to_edit() && $course_code != '-1' && $type == 'course') {
 $content = $tpl->fetch('default/agenda/month.tpl');
 $tpl->assign('content', $content);
 
-
-
 //Loading main Chamilo 1 col template
 $tpl->display_one_col_template();

+ 3 - 3
main/css/base.css

@@ -3781,12 +3781,12 @@ form div.error input, form div.error textarea {
   background-color: #bfbfbf;
   font-size: 9.75px;
   font-weight: bold;
-  color: #ffffff;
-  text-transform: uppercase;
+  color: #ffffff;  
   -webkit-border-radius: 3px;
   -moz-border-radius: 3px;
   border-radius: 3px;
-    width:134px;
+  text-align: center;
+  width: 155px;
 }
 
 .label_tag.personal_event { 

BIN
main/img/icons/32/calendar_na.png


+ 3 - 5
main/template/default/agenda/month.tpl

@@ -293,10 +293,7 @@ $(document).ready(function() {
                 <div class="formw">
                     <div id="visible_to_read_only_users"></div>                  
                 </div>                  
-         </div>
-        
-          
-        	
+         </div>        	
 		<div class="row">		
 			<div class="label">
 				<label for="date">{"Agenda"|get_lang}</label>
@@ -335,7 +332,7 @@ $(document).ready(function() {
 		<div id="add_as_announcement_div">
     		 <div class="row">
                 <div class="label">                    
-                </div>      
+                </div>
                 <div class="formw">
                     <input type="checkbox" name="add_as_annonuncement" id="add_as_annonuncement" />
                     <label for="add_as_annonuncement">{"AddAsAnnouncement"|get_lang}</label>
@@ -346,5 +343,6 @@ $(document).ready(function() {
 	</form>
 	</div>
 </div>
+
 <div id='loading' style='left:180px;top:10px;position:absolute; display:none'>{"Loading"|get_lang}...</div>
 <div id='calendar'></div>