Juan Carlos Raña 14 years ago
parent
commit
8b8ccde302

+ 60 - 41
main/announcements/announcements.inc.php

@@ -16,10 +16,12 @@ class AnnouncementManager  {
 	 * @param	int session id
 	 * @return	array html with the content and count of announcements or false otherwise
 	 */
-	public static function get_all_annoucement_by_course($course_db, $session = 0) {
+	public static function get_all_annoucement_by_course($course_db, $session_id = 0) {
 		if (empty($course_db)) {
 			return false;
 		}
+		$session_id = intval($session_id);
+		
 		$tbl_announcement	= Database::get_course_table(TABLE_ANNOUNCEMENT, $course_db['db_name']);
 		$tbl_item_property  = Database::get_course_table(TABLE_ITEM_PROPERTY, $course_db['db_name']);
 		/*
@@ -35,7 +37,7 @@ class AnnouncementManager  {
 				FROM $tbl_announcement announcement, $tbl_item_property toolitemproperties
 				WHERE announcement.id = toolitemproperties.ref
 				AND toolitemproperties.tool='announcement'				
-				AND announcement.session_id  = '$session'
+				AND announcement.session_id  = '$session_id'
 				ORDER BY display_order DESC";
 		$rs = Database::query($sql);
 		$num_rows = Database::num_rows($rs);
@@ -119,22 +121,44 @@ class AnnouncementManager  {
 							AND toolitemproperties.visibility='1'";
 		}
 		$sql_result = Database::query($sql_query);
-		$result		= Database::fetch_array($sql_result);
-	
-		if ($result !== false) { // A sanity check.
-			$title		 = $result['title'];
-			$content	 = $result['content'];
-			$content     = make_clickable($content);
-			$content     = text_filter($content);
-			$last_post_datetime = $result['insert_date'];// post time format  datetime de mysql
-			list($last_post_date, $last_post_time) = split(" ", $last_post_datetime);
+		if (Database::num_rows($sql_result) > 0 ) {
+    		$result		= Database::fetch_array($sql_result);
+    	
+    		if ($result !== false) { // A sanity check.
+    			$title		 = $result['title'];
+    			$content	 = $result['content'];
+    			$content     = make_clickable($content);
+    			$content     = text_filter($content);
+    			$last_post_datetime = $result['insert_date'];// post time format  datetime de mysql
+    			list($last_post_date, $last_post_time) = split(" ", $last_post_datetime);
+    		}
+    	
+    		echo "<table height=\"100\" width=\"100%\" cellpadding=\"5\" cellspacing=\"0\" id=\"agenda_list\">";
+    		echo "<tr class=\"data\"><td><h2>" . $title . "</h2></td></tr>";
+    		    		
+    		echo "<tr class=\"text\"><td>$content</td></tr>";
+    		
+    		echo "<tr><td class=\"announcements_datum\">" . get_lang('AnnouncementPublishedOn') . " : " . api_convert_and_format_date($result['end_date'], DATE_FORMAT_LONG) . "</td></tr>";
+            echo "<tr><td class=\"announcements_datum\">" . get_lang('LastUpdateDate') . " : " . api_convert_and_format_date($last_post_datetime, DATE_TIME_FORMAT_LONG) . "</td></tr>";
+            
+    		echo "<tr><td>";
+    	    $attachment_list = AnnouncementManager::get_attachment($announcement_id);
+        
+            if (count($attachment_list)>0) {
+                $realname=$attachment_list['path'];
+                $user_filename=$attachment_list['filename'];
+                $full_file_name = 'download.php?file='.$realname;
+                echo '<br/>';                
+                echo Display::return_icon('attachment.gif',get_lang('Attachment'));
+                echo '<a href="'.$full_file_name.' "> '.$user_filename.' </a>';
+                echo '<span class="forum_attach_comment" >'.$attachment_list['comment'].'</span>';
+            }
+            echo '</td></tr>';
+                        
+    		echo "</table>";
+		} else {
+		    api_not_allowed();
 		}
-	
-		echo "<table height=\"100\" width=\"100%\" border=\"1\" cellpadding=\"5\" cellspacing=\"0\" id=\"agenda_list\">";
-		echo "<tr class=\"data\"><td>" . $title . "</td></tr>";
-		echo "<tr><td class=\"announcements_datum\">" . get_lang('AnnouncementPublishedOn') . " : " . api_convert_and_format_date($last_post_datetime, null, date_default_timezone_get()) . "</td></tr>";
-		echo "<tr class=\"text\"><td>$content</td></tr>";
-		echo "</table>";
 	}	
 	
 		
@@ -659,8 +683,7 @@ class AnnouncementManager  {
 		  if (restore) selObj.selectedIndex=0;
 		}
 		//-->
-		</script>
-		";
+		</script>";
 	}
 	
 	
@@ -774,24 +797,22 @@ class AnnouncementManager  {
 		}
 	
 	
-		function selectAll(cbList,bSelect,showwarning)
-		{
+		function selectAll(cbList, bSelect, showwarning) {
 	
 			if (document.getElementById('emailTitle').value==''){
 				document.getElementById('msg_error').innerHTML='".get_lang('FieldRequired')."';
 				document.getElementById('msg_error').style.display='block';
 				document.getElementById('emailTitle').focus();
-			}else {
+			} else {			
 				if (cbList.length <	1) {
 					if (!confirm(\"".get_lang('Send2All')."\")) {
 						return false;
 					}
-				}
+				}				
 				for	(var i=0; i<cbList.length; i++)
-				cbList[i].selected = cbList[i].checked = bSelect;
+				cbList[i].selected = cbList[i].checked = bSelect;				
 				document.f1.submit();
-			}
-	
+			}	
 		}
 	
 		function reverseAll(cbList)
@@ -836,8 +857,7 @@ class AnnouncementManager  {
 	*/
 	public static function sent_to_form($sent_to_array) {
 		// we find all the names of the groups
-		$group_names = self::get_course_groups();
-		count($sent_to_array);
+		$group_names = self::get_course_groups();		
 	
 		// we count the number of users and the number of groups
 		if (isset($sent_to_array['users'])) {
@@ -850,11 +870,11 @@ class AnnouncementManager  {
 		} else {
 				$number_groups=0;
 		}
-		$total_numbers=$number_users+$number_groups;
+		$total_numbers = $number_users + $number_groups;
 	
 		// starting the form if there is more than one user/group
 		
-		if ($total_numbers >1) {
+		if ($total_numbers > 1 ) {
 			$output="<select name=\"sent to\">";
 			$output.="<option>".get_lang("SentTo")."</option>";
 			// outputting the name of the groups
@@ -878,19 +898,18 @@ class AnnouncementManager  {
 			// there is only one user/group
 			if (isset($sent_to_array['users']) and is_array($sent_to_array['users'])) {
 				$user_info = api_get_user_info($sent_to_array['users'][0]);
-				echo api_get_person_name($user_info['firstname'], $user_info['lastname']);
+				$output = api_get_person_name($user_info['firstname'], $user_info['lastname']);
 			}
 			if (isset($sent_to_array['groups']) and is_array($sent_to_array['groups']) and isset($sent_to_array['groups'][0]) and $sent_to_array['groups'][0]!==0) {
 				$group_id=$sent_to_array['groups'][0];
-				echo "&nbsp;".$group_names[$group_id]['name'];
+				$output .= "&nbsp;".$group_names[$group_id]['name'];
 			}
 			if (empty($sent_to_array['groups']) and empty($sent_to_array['users'])) {
-				echo "&nbsp;".get_lang('Everybody');
+				$output .= "&nbsp;".get_lang('Everybody');
 			}
 		}	
-		if(!empty($output))
-		{
-			echo $output;
+		if (!empty($output)) {
+			return $output;
 		}
 	}
 	
@@ -983,9 +1002,9 @@ class AnnouncementManager  {
 	
 	public static function get_attachment($announcement_id) {
 		$tbl_announcement_attachment = Database::get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT);
-		$announcement_id=Database::escape_string($announcement_id);
+		$announcement_id= intval($announcement_id);
 		$row=array();
-		$sql = 'SELECT id,path, filename,comment FROM '. $tbl_announcement_attachment.' WHERE announcement_id = '.(int)$announcement_id.'';
+		$sql = 'SELECT id,path, filename,comment FROM '. $tbl_announcement_attachment.' WHERE announcement_id = '.$announcement_id.'';
 		$result=Database::query($sql);
 		if (Database::num_rows($result)!=0) {
 			$row = Database::fetch_array($result,'ASSOC');
@@ -1092,9 +1111,9 @@ class AnnouncementManager  {
 	public static function delete_announcement_attachment_file($id) {
 		global $_course;
 		$tbl_announcement_attachment = Database::get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT);
-		$id=Database::escape_string($id);
-		$sql="DELETE FROM $tbl_announcement_attachment WHERE id = $id";
-		$result=Database::query($sql);
+		$id = intval($id);
+		$sql = "DELETE FROM $tbl_announcement_attachment WHERE id = $id";
+		$result = Database::query($sql);
 		// update item_property
 		//api_item_property_update($_course, 'announcement_attachment',  $id,'AnnouncementAttachmentDeleted', api_get_user_id());
 	}

+ 184 - 206
main/announcements/announcements.php

@@ -171,7 +171,7 @@ function setFocus(){
     $("#emailTitle").focus();
 }
 $(document).ready(function () {
-  setFocus();
+    setFocus();
 });
 </script>';
 
@@ -236,21 +236,25 @@ if (!empty($_SESSION['toolgroup'])){
 // showing the header if we are not in the learning path, if we are in
 // the learning path, we do not include the banner so we have to explicitly
 // include the stylesheet, which is normally done in the header
+//$display_specific_announcement = true;
+$announcement_id = intval($_GET['id']);
+
 if (empty($_GET['origin']) or $_GET['origin'] !== 'learnpath') {
 	//we are not in the learning path
 	Display::display_header($nameTools,get_lang('Announcements'));
 } else {
-	//we are in the learning path, only display central data and change css
+    
+	/*//we are in the learning path, only display central data and change css
 	$display_title_list = false;
 	$display_announcement_list = false;
 	$display_specific_announcement = true;
 	$announcement_id = $_REQUEST['ann_id'];
 	?> <link rel="stylesheet" type="text/css" href="<?php echo api_get_path(WEB_CODE_PATH).'css/'.$my_style; ?>/default.css">
-	<?php
+	<?php*/
 }
 
 // inserting an anchor (top) so one can jump back to the top of the page
-echo "<a name=\"top\"></a>";
+//echo "<a name=\"top\"></a>";
 
 /*		ACTION HANDLING*/
 
@@ -299,6 +303,12 @@ if (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_ed
 			}
 		}
 	}
+	
+    //delete attachment file
+    if ($_GET['action'] == 'delete') {
+        $id = $_GET['id_attach'];
+        AnnouncementManager::delete_announcement_attachment_file($id);
+    }    
 
 	/*
 		Delete all announcements
@@ -316,6 +326,7 @@ if (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_ed
 	/*
 		Modify announcement
 	*/
+	
 	if (!empty($_GET['action']) and $_GET['action']=='modify' AND isset($_GET['id'])) {
 		if (api_get_session_id()!=0 && api_is_allowed_to_session_edit(false,true)==false) {
 			api_not_allowed();
@@ -390,12 +401,8 @@ if (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_ed
 			if ($thisAnnouncementOrderFound) {
 				$nextAnnouncementId = $announcementId;
 				$nextAnnouncementOrder = $announcementOrder;
-				Database::query("UPDATE $tbl_announcement " .
-						"SET display_order = '$nextAnnouncementOrder' " .
-						"WHERE id =  '$thisAnnouncementId'");
-				Database::query("UPDATE $tbl_announcement " .
-						"SET display_order = '$thisAnnouncementOrder' " .
-						"WHERE id =  '$nextAnnouncementId.'");
+				Database::query("UPDATE $tbl_announcement SET display_order = '$nextAnnouncementOrder'  WHERE id =  '$thisAnnouncementId'");
+				Database::query("UPDATE $tbl_announcement  SET display_order = '$thisAnnouncementOrder' WHERE id =  '$nextAnnouncementId.'");
 				break;
 			}
 			// STEP 1 : FIND THE ORDER OF THE ANNOUNCEMENT
@@ -428,7 +435,7 @@ if (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_ed
 		$content_to_modify = $newContent;
 	} else if ($submitAnnouncement) {
 
-		if (isset($id)&&$id) {
+		if (isset($id) && $id) {
 			// there is an Id => the announcement already exists => update mode
 			if ($ctok == $_POST['sec_token']) {
 				$file_comment = $_POST['file_comment'];
@@ -801,30 +808,30 @@ $announcement_number = Database::num_rows($result);
 $show_actions = false;
 if ((api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_edit_announcement') && !api_is_anonymous())) and (empty($_GET['origin']) or $_GET['origin'] !== 'learnpath')) {
 	echo '<div class="actions">';
-	echo "<a href='".api_get_self()."?".api_get_cidreq()."&action=add&origin=".(empty($_GET['origin'])?'':$_GET['origin'])."'>".Display::return_icon('new_announce.png',get_lang('AddAnnouncement'),'','32')."</a>";
+	if (in_array($_GET['action'], array('add', 'modify','view'))) {
+        echo "<a href='".api_get_self()."?".api_get_cidreq()."&origin=".(empty($_GET['origin'])?'':$_GET['origin'])."'>".Display::return_icon('back.png',get_lang('Back'),'','32')."</a>";
+	} else {
+	   echo "<a href='".api_get_self()."?".api_get_cidreq()."&action=add&origin=".(empty($_GET['origin'])?'':$_GET['origin'])."'>".Display::return_icon('new_announce.png',get_lang('AddAnnouncement'),'','32')."</a>";
+	}
 	$show_actions = true;
 }
 
 if (api_is_allowed_to_edit() && $announcement_number > 1) {
 	if (api_get_group_id() == 0 ) {
-		if (!$show_actions)
+		if (!$show_actions) 
 			echo '<div class="actions">';
-		echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&action=delete_all\" onclick=\"javascript:if(!confirm('".get_lang("ConfirmYourChoice")."')) return false;\">".Display::return_icon('delete_announce.png',get_lang('AnnouncementDeleteAll'),'','32')."</a>";	}	// if announcementNumber > 1
-	}
-	if ($show_actions)
-			echo '</div>';
+			if (!in_array($_GET['action'], array('add', 'modify','view')))		    
+                echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&action=delete_all\" onclick=\"javascript:if(!confirm('".get_lang("ConfirmYourChoice")."')) return false;\">".Display::return_icon('delete_announce.png',get_lang('AnnouncementDeleteAll'),'','32')."</a>";	
+    	}	// if announcementNumber > 1    
+}
 
+if ($show_actions)
+    echo '</div>';
 
-if (empty($_GET['origin']) OR $_GET['origin'] !== 'learnpath') {
-	echo "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
-	echo "<tr>";
-	echo "<td width=\"20%\" valign=\"top\">";
-}
 
-/*
-		ANNOUNCEMENTS LIST
-*/
+//	ANNOUNCEMENTS LIST
 
+/*
 if ($display_title_list) {
 	echo "<table>";
 	while ($myrow = Database::fetch_array($result)) {
@@ -850,17 +857,16 @@ if ($display_title_list) {
 	}
 	echo "</table>";
 } // end $display_title_list
-
+*/
+        /*
 if (empty($_GET['origin']) or $_GET['origin'] !== 'learnpath') {
 	echo   "</td>";
 	echo "<td width=\"20\" background=\"../img/verticalruler.gif\">&nbsp;</td>";
 	// START RIGHT PART
 	echo	"<td valign=\"top\">";
-}
+}*/
 
-/*
-		DISPLAY ACTION MESSAGE
-*/
+/*		DISPLAY ACTION MESSAGE  */
 
 if ($message) {
 	Display::display_confirmation_message($message);
@@ -1005,11 +1011,14 @@ if ($display_form) {
 
 	$oFCKeditor->Value		= $content_to_modify;
 
+	echo '<div class="row"><div class="formw">';
+	
 	echo $oFCKeditor->CreateHtml();
+	echo '</div></div>';
 
 	//File attachment
 
-	echo '	<div style="float:left; padding:5px 5px;" >
+	echo '	<div class="row">
 				<div class="label">
 					<a href="javascript://" onclick="return plus_attachment();"><span id="plus"><img style="vertical-align:middle;" src="../img/div_show.gif" alt="" />&nbsp;'.get_lang('AddAnAttachment').'</span></a>
 				</div>
@@ -1032,6 +1041,8 @@ if ($display_form) {
 			</div>';
 	
 	echo'<br />';
+	echo '<div class="row"><div class="formw">';
+	
 	if (empty($_SESSION['toolgroup'])) {
 		echo '<input type="hidden" name="submitAnnouncement" value="OK">';
 		echo '<input type="hidden" name="sec_token" value="'.$stok.'" />';
@@ -1041,6 +1052,7 @@ if ($display_form) {
 		echo '<input type="hidden" name="sec_token" value="'.$stok.'" />';
 		echo '<button class="save" type="button"  value="'.'  '.get_lang('Send').'  '.'" onclick="selectAll(this.form.elements[4],true)" >'.get_lang('ButtonPublishAnnouncement').'</button><br /><br />';
 	}
+	echo '</div></div>';
 	echo '</form><br />';
 
 	if ((isset($_GET['action']) && isset($_GET['id']) && is_array($to))||isset($_GET['remindallinactives'])||isset($_GET['remind_inactive'])) {
@@ -1215,187 +1227,153 @@ if ($display_announcement_list && !$surveyid) {
 	$result		= Database::query($sql);
 	$num_rows 	= Database::num_rows($result);
 
-/*		DISPLAY: NO ITEMS */
+    // DISPLAY: NO ITEMS 
 
+	if (!in_array($_GET['action'], array('add', 'modify','view')))
 	if ($num_rows == 0) {
 		Display::display_warning_message(get_lang('NoAnnouncements'));
+	} else {    
+    	$iterator = 1;
+    	$bottomAnnouncement = $announcement_number;
+    
+    	echo '<table width="100%" class="data_table">';
+    	
+        $ths = Display::tag('th', get_lang('Title'));
+        //$ths .= Display::tag('th', get_lang('Content'));
+        $ths .= Display::tag('th', get_lang('SentTo') );
+        $ths .= Display::tag('th', get_lang('By') );
+        $ths .= Display::tag('th', get_lang('AnnouncementPublishedOn') );    
+        if (api_is_allowed_to_edit() OR (api_is_course_coach() && api_is_element_in_the_session(TOOL_ANNOUNCEMENT,$myrow['id'])) 
+                 OR (api_get_course_setting('allow_user_edit_announcement') && !api_is_anonymous())) {
+                $ths .= Display::tag('th', get_lang('Modify'));
+        }
+        
+    	echo Display::tag('tr', $ths);    
+    	$displayed = array();    
+    	
+    	while ($myrow = Database::fetch_array($result)) {    
+    		if (!in_array($myrow['id'], $displayed)) {
+    			$title		 = $myrow['title'];
+    			$content	 = $myrow['content'];
+    
+    			$content     = make_clickable($content);
+    			$content     = text_filter($content);
+    
+    			/* DATE */    
+    			$last_post_datetime = $myrow['end_date'];    
+    		
+    			// the styles
+    			if ($myrow['visibility']=='0') {
+    				$style='invisible';
+    			} else {
+    				$style = '';
+    			}
+    
+    			echo "<tr>";
+    			
+    		    // show attachment list
+                $attachment_list = array();
+                $attachment_list = AnnouncementManager::get_attachment($myrow['id']);
+                
+                
+                $attachment = '';
+                $attachment_icon = '';
+                if (count($attachment_list)>0) {
+                    $attachment_icon = ' '.Display::return_icon('attachment.gif',get_lang('Attachment'));
+                    /*
+                    $realname=$attachment_list['path'];
+                    $user_filename=$attachment_list['filename'];
+                    $full_file_name = 'download.php?file='.$realname;
+                         
+                    $attachment .= Display::return_icon('attachment.gif',get_lang('Attachment'));
+                    $attachment .= '<a href="'.$full_file_name.'"> '.$user_filename.' </a>';
+                    $attachment .= '<span class="forum_attach_comment" >'.$attachment_list['comment'].'</span>';
+    
+                    if (api_is_allowed_to_edit()) {
+                        $attachment .= '&nbsp;&nbsp;<a href="'.api_get_self().'?'.api_get_cidreq().'&action=delete&id_attach='.$attachment_list['id'].'" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)).'\')) return false;">'.Display::return_icon('delete.png',get_lang('Delete'),'',22).'</a><br />';
+                    }*/
+                }
+                /* TITLE */
+    		    $title = Display::url($title.$attachment_icon, '?action=view&id='.$myrow['id']);
+                echo Display::tag('td', Security::remove_XSS($title), array('class' => $style));
+                
+                //echo Display::tag('td', Security::remove_XSS($content).$attachment);
+    			
+                 // User or group icon
+                $sent_to_icon = '';
+                if ($myrow['to_group_id']!== '0' and $myrow['to_group_id']!== 'NULL') {
+                    $sent_to_icon = Display::return_icon('group.gif', get_lang('AnnounceSentToUserSelection'));
+                }
+                // the email icon
+                if ($myrow['email_sent'] == '1') {
+                    $sent_to_icon .= Display::return_icon('email.gif', get_lang('AnnounceSentByEmail'));
+                }
+    
+    			$sent_to		= AnnouncementManager::sent_to('announcement', $myrow['id']);
+    			$sent_to_form	= AnnouncementManager::sent_to_form($sent_to);
+    			$user_info		= api_get_user_info($myrow['insert_user_id']);
+    			
+    			echo Display::tag('td', $sent_to_icon.$sent_to_form);			
+    			echo Display::tag('td', api_get_person_name($user_info['firstName'], $user_info['lastName']));			
+                echo Display::tag('td', api_convert_and_format_date($myrow['end_date'], DATE_FORMAT_LONG));
+    						
+    
+    			/* RESOURCES */
+    
+    			//echo "<tr class='row_odd'><td colspan=\"3\">";
+    			/*
+    			if (check_added_resources("Ad_Valvas", $myrow["id"])) {
+    				echo "<i>".get_lang('AddedResources')."</i><br />";
+    				display_added_resources("Ad_Valvas", $myrow["id"]);
+    			}
+    			*/
+    			// we can edit if : we are the teacher OR the element belongs to the session we are coaching OR the option to allow users to edit is on
+    			$modify_icons = '';
+    			if (api_is_allowed_to_edit() OR (api_is_course_coach() && api_is_element_in_the_session(TOOL_ANNOUNCEMENT,$myrow['id'])) 
+    			     OR (api_get_course_setting('allow_user_edit_announcement') && !api_is_anonymous())) {
+    
+    				/* SHOW MOD/DEL/VIS FUNCTIONS */
+    				$modify_icons = "<a href=\"".api_get_self()."?".api_get_cidreq()."&action=modify&id=".$myrow['id']."\">".
+    						Display::return_icon('edit.png', get_lang('Edit'),'',22).
+    						"</a>";
+    				if ($myrow['visibility']==1) {
+    					$image_visibility="visible";
+    					$alt_visibility=get_lang('Hide');
+    				} else {
+    					$image_visibility="invisible";
+    					$alt_visibility=get_lang('Visible');
+    				}
+    
+    				$modify_icons .=  	"<a href=\"".api_get_self()."?".api_get_cidreq()."&origin=".(!empty($_GET['origin'])?Security::remove_XSS($_GET['origin']):'')."&action=showhide&id=".$myrow['id']."&sec_token=".$stok."\">".
+    						Display::return_icon($image_visibility.'.png', $alt_visibility,'',22)."</a>";
+    
+    				// DISPLAY MOVE UP COMMAND only if it is not the top announcement
+    				if ($iterator != 1) {
+    					$modify_icons .= 	"<a href=\"".api_get_self()."?".api_get_cidreq()."&up=".$myrow["id"]."&sec_token=".$stok."\">".Display::return_icon('up.gif', get_lang('Up'))."</a>";
+    				}
+    
+    				if ($iterator < $bottomAnnouncement) {
+    					$modify_icons .= 	"<a href=\"".api_get_self()."?".api_get_cidreq()."&down=".$myrow["id"]."&sec_token=".$stok."\">".Display::return_icon('down.gif', get_lang('Down'))."</a>";
+    				}
+    
+    			     if (api_is_allowed_to_edit(false,true)) {
+                        $modify_icons .= "<a href=\"".api_get_self()."?".api_get_cidreq()."&action=delete&id=".$myrow['id']."&sec_token=".$stok."\" onclick=\"javascript:if(!confirm('".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'),ENT_QUOTES,$charset))."')) return false;\">".
+                            Display::return_icon('delete.png', get_lang('Delete'),'',22).
+                            "</a>";
+                    }                    
+                    echo Display::tag('td', $modify_icons);    
+    				$iterator ++;
+    			}
+    			echo "</tr>";
+    		}
+    		$displayed[]=$myrow['id'];
+    	}	// end while
+    	echo "</table>";
 	}
-
-	$iterator = 1;
-	$bottomAnnouncement = $announcement_number;
-
-	echo "<table width=\"100%\" class=\"data_table\">";
-
-	$displayed=array();
-
-	while ($myrow = Database::fetch_array($result)) {
-
-		if (!in_array($myrow['id'], $displayed)) {
-			$title		 = $myrow['title'];
-			$content	 = $myrow['content'];
-
-			$content     = make_clickable($content);
-			$content     = text_filter($content);
-
-			/* DATE */
-
-			$last_post_datetime = $myrow['end_date'];
-
-			list($last_post_date, $last_post_time) = split(" ", $last_post_datetime);
-			list($year, $month, $day) = explode("-", $last_post_date);
-			list($hour, $min) = explode(":", $last_post_time);
-			$announceDate = mktime((int)$hour, (int)$min, 0, (int)$month, (int)$day, (int)$year);
-
-			// the styles
-			if ($myrow['visibility']=='0') {
-				$style='invisible';
-			} else {
-				$style = '';
-			}
-
-			echo	"<tr class=\"".$style."\">";
-
-			/* THE ICONS */
-
-			echo "<th>";
-			// anchoring
-			echo "<a name=\"".(int)($myrow["id"])."\"></a>";
-			// User or group icon
-			if ($myrow['to_group_id']!== '0' and $myrow['to_group_id']!== 'NULL') {
-				echo Display::return_icon('group.gif', get_lang('AnnounceSentToUserSelection'));
-			}
-			// the email icon
-			if ($myrow['email_sent'] == '1') {
-				echo Display::return_icon('email.gif', get_lang('AnnounceSentByEmail'));
-			}
-			echo "</th>";
-
-			/* TITLE */
-
-			echo "<th>".Security::remove_XSS($title)."</th>";
-			echo "<th>" . get_lang("SentTo") . " : &nbsp; ";
-
-			$sent_to		= AnnouncementManager::sent_to('announcement', $myrow['id']);
-			$sent_to_form	= AnnouncementManager::sent_to_form($sent_to);
-			$user_info		= api_get_user_info($myrow['insert_user_id']);
-
-			echo '&nbsp;&nbsp;&nbsp;'.get_lang('By').' : &nbsp;'.str_replace(' ', '&nbsp;', api_get_person_name($user_info['firstName'], $user_info['lastName']));
-			echo "</th></tr>";
-			echo "<tr class='row_odd'><td class=\"announcements_datum\" colspan=\"3\">";
-			echo get_lang('AnnouncementPublishedOn')," : ", api_convert_and_format_date($last_post_datetime, DATE_FORMAT_LONG, date_default_timezone_get());
-			echo "</td></tr>";
-
-			/* CONTENT */
-
-			echo "<tr class=\"$text_style\"><td colspan=\"3\">";
-			echo $content."</td></tr>";
-
-			/* RESOURCES */
-
-			echo "<tr class='row_odd'><td colspan=\"3\">";
-			/*
-			if (check_added_resources("Ad_Valvas", $myrow["id"])) {
-				echo "<i>".get_lang('AddedResources')."</i><br />";
-				display_added_resources("Ad_Valvas", $myrow["id"]);
-			}
-			*/
-			// we can edit if : we are the teacher OR the element belongs to the session we are coaching OR the option to allow users to edit is on
-			if (api_is_allowed_to_edit() OR (api_is_course_coach() && api_is_element_in_the_session(TOOL_ANNOUNCEMENT,$myrow['id'])) OR (api_get_course_setting('allow_user_edit_announcement') && !api_is_anonymous())) {
-
-				/* SHOW MOD/DEL/VIS FUNCTIONS */
-				echo	"<a href=\"".api_get_self()."?".api_get_cidreq()."&action=modify&id=".$myrow['id']."\">",
-						Display::return_icon('edit.png', get_lang('Edit'),'',22),
-						"</a>";
-
-				if (api_is_allowed_to_edit(false,true)) {
-					echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&action=delete&id=".$myrow['id']."&sec_token=".$stok."\" onclick=\"javascript:if(!confirm('".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'),ENT_QUOTES,$charset))."')) return false;\">",
-						Display::return_icon('delete.png', get_lang('Delete'),'',22),
-						"</a>";
-				}
-
-				if ($myrow['visibility']==1) {
-						$image_visibility="visible";
-						$alt_visibility=get_lang('Hide');
-				} else {
-						$image_visibility="invisible";
-						$alt_visibility=get_lang('Visible');
-				}
-
-				echo 	"<a href=\"".api_get_self()."?".api_get_cidreq()."&origin=".(!empty($_GET['origin'])?Security::remove_XSS($_GET['origin']):'')."&action=showhide&id=".$myrow['id']."&sec_token=".$stok."\">".
-						Display::return_icon($image_visibility.'.png', $alt_visibility,'',22)."</a>";
-
-				// DISPLAY MOVE UP COMMAND only if it is not the top announcement
-				if ($iterator != 1) {
-					echo	"<a href=\"".api_get_self()."?".api_get_cidreq()."&up=".$myrow["id"]."&sec_token=".$stok."\">",
-							Display::return_icon('up.gif', get_lang('Up'))."</a>";
-				}
-
-				if ($iterator < $bottomAnnouncement) {
-					echo	"<a href=\"".api_get_self()."?".api_get_cidreq()."&down=".$myrow["id"]."&sec_token=".$stok."\">".
-							Display::return_icon('down.gif', get_lang('Down'))."</a>";
-				}
-
-				//delete attachment file
-				if($_GET['action'] == 'delete') {
-					$id = $_GET['id_attach'];
-					AnnouncementManager::delete_announcement_attachment_file($id);
-				}
-
-				// show attachment list
-				$attachment_list = array();
-				$attachment_list = AnnouncementManager::get_attachment($myrow['id']);
-
-				if (count($attachment_list)>0) {
-					$realname=$attachment_list['path'];
-					$user_filename=$attachment_list['filename'];
-					$full_file_name = 'download.php?file='.$realname;
-					echo '<br/>';
-					echo '<br/>';
-					echo Display::return_icon('attachment.gif',get_lang('Attachment'));
-					echo '<a href="'.$full_file_name.'';
-					echo ' "> '.$user_filename.' </a>';
-					echo '<span class="forum_attach_comment" >'.$attachment_list['comment'].'</span>';
-
-					if (api_is_allowed_to_edit()) {
-						echo '&nbsp;&nbsp;<a href="'.api_get_self().'?'.api_get_cidreq().'&action=delete&id_attach='.$attachment_list['id'].'" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)).'\')) return false;">'.Display::return_icon('delete.png',get_lang('Delete'),'',22).'</a><br />';
-					}
-				}
-
-
-				echo "</td></tr>";
-
-				$iterator ++;
-			} else { // end of is_allowed_to_edit
-				//students view
-				// show attachment list
-				$attachment_list = array();
-				$attachment_list = AnnouncementManager::get_attachment($myrow['id']);
-
-				if (count($attachment_list)>0) {
-					$realname=$attachment_list['path'];
-					$user_filename=$attachment_list['filename'];
-					$full_file_name = 'download.php?file='.$realname;
-					echo '<br/>';
-					echo '<br/>';
-					echo Display::return_icon('attachment.gif',get_lang('Attachment'));
-					echo '<a href="'.$full_file_name.'';
-					echo ' "> '.$user_filename.' </a>';
-					echo '<span class="forum_attach_comment" >'.$attachment_list['comment'].'</span>';
-				}
-			}
-
-			echo "<tr><td width=\"100%\" colspan=\"3\"><a href=\"#top\">".Display::return_icon('top.gif', get_lang('Top'))."</a></td></tr>";
-
-		}
-		$displayed[]=$myrow['id'];
-	}	// end while ($myrow = Database::fetch_array($result))
-
-	echo "</table>";
-
 }	// end: if ($displayAnnoucementList)
 
-echo "</table>";
-if (!empty($display_specific_announcement)) {
+
+if ($_GET['action'] == 'view') {
 	AnnouncementManager::display_announcement($announcement_id);
 }
 

+ 1 - 1
main/calendar/myagenda.inc.php

@@ -496,7 +496,7 @@ function show_new_personal_item_form($id = "") {
 	echo '</div>';
 	// ********** The Submit button********** \\
 	echo '<div>';
-	echo '<button type="submit" class="add" name="Submit" value="'.get_lang('AddEvent').'" >'.get_lang('AddEvent').'</button>';
+	echo '<br /><button type="submit" class="add" name="Submit" value="'.get_lang('AddEvent').'" >'.get_lang('AddEvent').'</button>';
 	echo '</div>';
 	echo '</div>';
 	echo '</form>';

+ 32 - 0
main/css/base.css

@@ -307,3 +307,35 @@ a.tag {
     text-decoration: none;
     white-space: nowrap;
 }
+
+/* New button style experimental */ 
+button {
+    border:1px solid #ccc;
+	
+	-opera-border-radius: 8px;
+	-webkit-border-radius: 8px;	
+    border-radius: 8px;
+	
+	-opera-shadow: 2px 2px 1px rgba(0, 0, 0, 0.5);    
+	-webkit-shadow: 2px 2px 1px rgba(0, 0, 0, 0.5);
+	box-shadow: 2px 2px 1px rgba(0, 0, 0, 0.5);
+	
+	font-weight:bold;
+	font-size: 105%;	
+}
+
+button:hover {
+    color:#000;
+    border-style: inset;
+    background-color:#eee;
+    border:1px solid #ccc;	
+}
+
+/* Makes the course elements more readable */ 
+.userportal-course-item{
+	padding:15px;
+}
+
+.session_course_item {
+    padding: 6px 0px 6px 5px ;
+}

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

@@ -43,14 +43,18 @@ body {
     margin: 0px auto;
     width: 90%;
     min-height: 320px;
-    padding:12px;
+    padding:13px;
+	
+	-moz-border-radius:0px 0px 10px 10px;
+	border-radius:0px 0px 10px 10px;
+	
+    box-shadow: 3px 3px 10px #ddd;
+	-moz-box-shadow: 3px 3px 10px #ddd;
+	
 
 }
 .item {
-    -moz-border-radius-bottomleft:5px;
-    -moz-border-radius-bottomright:5px;
-    -moz-border-radius-topleft:5px;
-    -moz-border-radius-topright:5px;
+    -moz-border-radius:5px;
     border:1px solid #E1E1E0;
 }
 

+ 27 - 10
main/inc/lib/course.lib.php

@@ -2746,13 +2746,20 @@ class CourseManager {
     
             // Show a hyperlink to the course, unless the course is closed and user is not course admin.
             $course_visibility = $course['visibility'];
+            $course_title_url = '';
             if ($course_visibility != COURSE_VISIBILITY_CLOSED || $course['status'] == COURSEMANAGER) {
-                $course_title = '<a href="'.api_get_path(WEB_COURSE_PATH).$course['directory'].'/?id_session=0">'.$course['title'].'</a>';
+                $course_title_url = api_get_path(WEB_COURSE_PATH).$course['directory'].'/?id_session=0';
+                $course_title = Display::url($course['title'], $course_title_url);
+                
             } else {
                 $course_title = $course['title']." ".Display::tag('span',get_lang('CourseClosed'), array('class'=>'item_closed'));
             }
+            if (!empty($course_title_url)) {
+                $status_icon = Display::url($status_icon, $course_title_url);
+            }
             // Start displaying the course block itself.
             echo '<div style="float: left; margin-right: 10px;">'.$status_icon.'</div><span class="userportal-course-item-title">'.$course_title.'</span><br />';
+            
             if (api_get_setting('display_coursecode_in_courselist') == 'true') {
                 echo $course_display_code;
             }
@@ -2903,9 +2910,7 @@ class CourseManager {
     
         $s_course_status = $my_course['status'];
         $is_coach = api_is_coach($my_course['id_session'],$course['code']);
-    
-        $s_htlm_status_icon = '';
-    
+            
         $s_htlm_status_icon = Display::return_icon('blackboard_blue.png', get_lang('Course'), array('width' => '48px'));
         /*
         if ($s_course_status == 1) {
@@ -2919,8 +2924,10 @@ class CourseManager {
         }
         */
         // Display course entry.
-        $result .= '<li class="'.$class.'"><div class="coursestatusicons">'.$s_htlm_status_icon.'</div>';
+        
         // Show a hyperlink to the course, unless the course is closed and user is not course admin.
+        $session_url = '';
+        $session_title = '';
         if ($session_accessible) {
             if ($course_visibility != COURSE_VISIBILITY_CLOSED || $user_in_course_status == COURSEMANAGER) {
                 if (api_get_setting('use_session_mode') == 'true' && !$nosession) {
@@ -2928,17 +2935,27 @@ class CourseManager {
                         $my_course['id_session'] = 0;
                     }
                     if ($user_in_course_status == COURSEMANAGER || ($date_start <= $now && $date_end >= $now) || $date_start == '0000-00-00') {
-                        $result .= '<a href="'.api_get_path(WEB_COURSE_PATH).$course_directory.'/?id_session='.$my_course['id_session'].'">'.$course_display_title.'</a>';
+                        $session_url = api_get_path(WEB_COURSE_PATH).$course_directory.'/?id_session='.$my_course['id_session'];
+                        $session_title = '<a href="'.api_get_path(WEB_COURSE_PATH).$course_directory.'/?id_session='.$my_course['id_session'].'">'.$course_display_title.'</a>';
                     }
                 } else {
-                    $result .= '<a href="'.api_get_path(WEB_COURSE_PATH).$course_directory.'/">'.$course_display_title.'</a>';
+                    $session_url   = api_get_path(WEB_COURSE_PATH).$course_directory.'/';
+                    $session_title = '<a href="'.api_get_path(WEB_COURSE_PATH).$course_directory.'/">'.$course_display_title.'</a>';
                 }
             } else {
-                $result .= $course_display_title.' '.Display::tag('span',get_lang('CourseClosed'), array('class'=>'item_closed'));                
+                $session_title = $course_display_title.' '.Display::tag('span',get_lang('CourseClosed'), array('class'=>'item_closed'));                
             }
         } else {
-        	$result .= $course_display_title;
-        }    
+        	$session_title = $course_display_title;
+        }
+        
+        if (!empty($session_url)) {
+            $s_htlm_status_icon = Display::url($s_htlm_status_icon, $session_url);
+        }
+        
+        $result .= '<li class="'.$class.'"><div class="coursestatusicons">'.$s_htlm_status_icon.'</div>';
+        $result .= $session_title;
+        
         // Show the course_code and teacher if chosen to display this.
         if (api_get_setting('display_coursecode_in_courselist') == 'true' || api_get_setting('display_teacher_in_courselist') == 'true') {
             $result .= '<br />';

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

@@ -60,7 +60,7 @@ function display_action_links($cur_dir_path, $always_show_tool_options, $always_
 	}
 
 	if (api_is_allowed_to_edit(null, true) && $origin != 'learnpath' && api_is_allowed_to_session_edit(false, true)) {
-		// delete all files
+		// Delete all files
 		if (api_get_setting('permanently_remove_deleted_files') == 'true'){
 			$message = get_lang('ConfirmYourChoiceDeleteAllfiles');
 		} else {

+ 50 - 10
main/work/work.php

@@ -747,25 +747,65 @@ else {
 			api_not_allowed();
 		}
 		if ($delete == 'all' && api_is_allowed_to_edit(null, true)) {
-
-			$queryString1 = "SELECT url FROM ".$work_table."";
-			$queryString2 = "DELETE FROM  ".$work_table."";
-			$queryString3 = "DELETE FROM  ".$TSTDPUBASG. "";
-
+			
+		    $path = $currentCourseRepositorySys;
+		    $t_agenda   = Database::get_course_table(TABLE_AGENDA);
+		    
+		    $sql = "SELECT id, url, filetype FROM  ".$work_table." WHERE session_id = ".api_get_session_id().' ORDER BY url DESC'; // do not change the "order by", otherwise the work assignments will not be renamed
+		    $result = Database::query($sql);
+		    
+		    while($row = Database::fetch_array($result)) {
+		        $url = $row['url'];
+		        //Deleting works		        
+                $delete_query = "DELETE FROM  ".$work_table." WHERE id  = ".$row['id'];
+                Database::query($delete_query);
+                
+                //Deleting agenda calendar for that work assignment
+                $sql_agenda = "SELECT add_to_calendar FROM  ".$TSTDPUBASG." WHERE publication_id = ".$row['id'];
+                
+                $rs_agenda = Database::query($sql_agenda);                
+                while ($row_agenda = Database::fetch_array($rs_agenda)) {
+                    if (!empty($row_agenda['add_to_calendar'])) {
+                        $delete_agenda = "DELETE FROM  ".$t_agenda." WHERE id = ".$row_agenda['add_to_calendar'];                        
+                        Database::query($delete_agenda);
+                    }                    
+                }                
+                //Deleting the work assignment
+                $delete_query = "DELETE FROM  ".$TSTDPUBASG. " WHERE publication_id = ".$row['id'];
+                Database::query($delete_query);
+                
+                if ($row['filetype'] == 'folder') {
+                    $url = 'work'.$url;
+                }                
+                
+                if (api_get_setting('permanently_remove_deleted_files') == 'true') {
+                    if (file_exists($path.$url)) {                        
+                        rmdirr($path.$url);
+                    }
+                } else {
+                    if ($row['filetype'] == 'folder') {
+                        $new_file = $path.'work/DELETED_'.basename($url);    
+                    } else {
+                        $new_file = $path.dirname($url).'/DELETED_'.basename($url);
+                    }              
+                    if (file_exists($path.$url)) {      
+                        rename($path.$url, $new_file);
+                    }
+                }                             
+		    }			
+/*
 			$sql_agenda = "SELECT add_to_calendar FROM ".$TSTDPUBASG." WHERE add_to_calendar <> 0";
 			$rs_agenda = Database::query($sql_agenda);
 			$t_agenda   = Database::get_course_table(TABLE_AGENDA);
 			while ($row_agenda=Database::fetch_array($rs_agenda)) {
 				$deleteagenda = "DELETE FROM  ".$t_agenda." WHERE id='".$row_agenda['add_to_calendar']."'";
 				$rsdeleteagenda = Database::query($deleteagenda);
-
 			}
-
-			$result1 = Database::query($queryString1);
+			
 			$result2 = Database::query($queryString2);
 			$result3 = Database::query($queryString3);
 
-			$path = $currentCourseRepositorySys.'work/';
+			
 			$d = dir($path);
 
 			if (api_get_setting('permanently_remove_deleted_files') == 'true') {
@@ -779,7 +819,7 @@ else {
 					$new_file = 'DELETED_'.$entry;
 					rename($path.$entry, $path.$new_file);
 				}
-			}
+			}*/			
 		} else {
             $file_deleted = false;
 			//Get the author ID for that document from the item_property table