More - Improving UI in agenda an announcements

skala
Julio Montoya 14 years ago
parent 997b412388
commit a712f4dab6
  1. 83
      main/announcements/announcements.inc.php
  2. 45
      main/announcements/announcements.php
  3. 17
      main/calendar/agenda.inc.php

@ -5,6 +5,10 @@
* @package chamilo.announcements
*/
/**
* @author jmontoya
*
*/
class AnnouncementManager {
private function __construct() {
@ -101,13 +105,12 @@ class AnnouncementManager {
$tbl_announcement = Database::get_course_table(TABLE_ANNOUNCEMENT);
$tbl_item_property = Database::get_course_table(TABLE_ITEM_PROPERTY);
if ((api_get_course_setting('allow_user_edit_announcement') && !api_is_anonymous())) {
$sql_query = " SELECT announcement.*, toolitemproperties.*
if (api_is_allowed_to_edit(false,true) || (api_get_course_setting('allow_user_edit_announcement') && !api_is_anonymous())) {
$sql_query = " SELECT announcement.*, toolitemproperties.*
FROM $tbl_announcement announcement, $tbl_item_property toolitemproperties
WHERE announcement.id = toolitemproperties.ref
AND announcement.id = '$announcement_id'
AND toolitemproperties.tool='announcement'
AND (toolitemproperties.to_user_id='".api_get_user_id()."' OR toolitemproperties.to_group_id='0')
AND toolitemproperties.tool='announcement'
ORDER BY display_order DESC";
} else {
if (api_get_user_id() != 0) {
@ -129,29 +132,33 @@ class AnnouncementManager {
AND toolitemproperties.to_group_id='0'
AND toolitemproperties.visibility='1'";
}
}
}
$sql_result = Database::query($sql_query);
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
}
$result = Database::fetch_array($sql_result, 'ASSOC');
$title = $result['title'];
$content = $result['content'];
$content = make_clickable($content);
$content = text_filter($content);
echo "<table height=\"100\" width=\"100%\" cellpadding=\"5\" cellspacing=\"0\" id=\"agenda_list\">";
echo "<tr><td><h2>" . $title . "</h2></td></tr>";
echo "<tr class=\"text\"><td>$content</td></tr>";
echo "<tr><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 class=\"announcements_datum\">" . get_lang('LastUpdateDate') . " : " .api_convert_and_format_date($result['insert_date'], DATE_TIME_FORMAT_LONG). "</td></tr>";
// User or group icon
$sent_to_icon = '';
if ($result['to_group_id']!== '0' and $result['to_group_id']!== 'NULL') {
$sent_to_icon = Display::return_icon('group.gif', get_lang('AnnounceSentToUserSelection'));
}
$sent_to = self::sent_to('announcement', $announcement_id);
$sent_to_form = self::sent_to_form($sent_to);
echo Display::tag('td', get_lang('SentTo').' : '.$sent_to_form, array('class'=>'announcements_datum'));
echo "<tr><td>";
$attachment_list = AnnouncementManager::get_attachment($announcement_id);
$attachment_list = self::get_attachment($announcement_id);
if (count($attachment_list)>0) {
$realname=$attachment_list['path'];
@ -884,14 +891,13 @@ class AnnouncementManager {
$total_numbers = $number_users + $number_groups;
// starting the form if there is more than one user/group
if ($total_numbers > 1 ) {
$output="<select name=\"sent to\">";
$output.="<option>".get_lang("SentTo")."</option>";
$output = array();
if ($total_numbers > 1 ) {
//$output.="<option>".get_lang("SentTo")."</option>";
// outputting the name of the groups
if (is_array($sent_to_array['groups'])) {
foreach ($sent_to_array['groups'] as $group_id) {
$output.="<option value=\"\">G: ".$group_names[$group_id]['name']."</option>";
$output[] = $group_names[$group_id]['name'];
}
}
@ -899,27 +905,26 @@ class AnnouncementManager {
if (is_array($sent_to_array['users'])) {
foreach ($sent_to_array['users'] as $user_id) {
$user_info = api_get_user_info($user_id);
$output.="<option value=\"\">".api_get_person_name($user_info['firstname'], $user_info['lastname'])."</option>";
$output[] = api_get_person_name($user_info['firstname'], $user_info['lastname']);
}
}
}
// ending the form
$output.="</select>";
}
} else {
// 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]);
$output = 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];
$output .= "&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'])) {
$output .= "&nbsp;".get_lang('Everybody');
$output[]= "&nbsp;".get_lang('Everybody');
}
}
}
if (!empty($output)) {
$output = implode(', ', $output);
return $output;
}
}
@ -970,20 +975,18 @@ class AnnouncementManager {
global $tbl_item_property;
$tool = Database::escape_string($tool);
$id = Database::escape_string($id);
$id = intval($id);
$sent_to_group = array();
$sent_to = array();
$sql="SELECT * FROM $tbl_item_property WHERE tool='$tool' AND ref='".$id."'";
$result = Database::query($sql);
$sql="SELECT to_group_id, to_user_id FROM $tbl_item_property WHERE tool = '$tool' AND ref=".$id;
$result = Database::query($sql);
while ($row=Database::fetch_array($result)) {
while ($row = Database::fetch_array($result)) {
// if to_group_id is null then it is sent to a specific user
// if to_group_id = 0 then it is sent to everybody
if ($row['to_group_id'] != 0)
{
if ($row['to_group_id'] != 0) {
$sent_to_group[]=$row['to_group_id'];
}
// if to_user_id <> 0 then it is sent to a specific user

@ -1243,14 +1243,13 @@ if ($display_announcement_list && !$surveyid) {
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('Content'));
$ths .= Display::tag('th', get_lang('By') );
//$ths .= Display::tag('th', get_lang('AnnouncementPublishedOn') );
$ths .= Display::tag('th', get_lang('LastUpdateDate') );
if (api_is_allowed_to_edit() OR (api_is_course_coach() && api_is_element_in_the_session(TOOL_ANNOUNCEMENT,$myrow['id']))
if (api_is_allowed_to_edit(false,true) 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('SentTo'));
//$ths .= Display::tag('th', get_lang('SentTo'));
$ths .= Display::tag('th', get_lang('Modify'));
}
@ -1259,7 +1258,13 @@ if ($display_announcement_list && !$surveyid) {
while ($myrow = Database::fetch_array($result, 'ASSOC')) {
if (!in_array($myrow['id'], $displayed)) {
$title = $myrow['title'];
$sent_to_icon = '';
// the email icon
if ($myrow['email_sent'] == '1') {
$sent_to_icon = ' '.Display::return_icon('email.gif', get_lang('AnnounceSentByEmail'));
}
$title = $myrow['title'].$sent_to_icon;
$content = $myrow['content'];
$content = make_clickable($content);
@ -1294,19 +1299,7 @@ if ($display_announcement_list && !$surveyid) {
//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']);
$user_info = api_get_user_info($myrow['insert_user_id']);
echo Display::tag('td', api_get_person_name($user_info['firstName'], $user_info['lastName']));
echo Display::tag('td', api_convert_and_format_date($myrow['insert_date'], DATE_TIME_FORMAT_LONG));
@ -1322,13 +1315,10 @@ if ($display_announcement_list && !$surveyid) {
*/
// 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']))
if (api_is_allowed_to_edit(false,true) 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>";
$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');
@ -1350,15 +1340,14 @@ if ($display_announcement_list && !$surveyid) {
} else {
$modify_icons .= Display::return_icon('down_na.gif', get_lang('Down'));
}
if (api_is_allowed_to_edit(false,true)) {
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', $sent_to_icon.$sent_to_form);
echo Display::tag('td', $modify_icons);
}
$iterator ++;
echo Display::tag('td', $modify_icons);
}
echo "</tr>";
}

@ -1231,7 +1231,7 @@ function sent_to_form($sent_to_array) {
$number_groups=0;
}
$total_numbers = $number_users + $number_groups;
$output = array();
// starting the form if there is more than one user/group
if ($total_numbers > 1 ) {
//$output.="<option>".get_lang("SentTo")."</option>";
@ -1239,7 +1239,7 @@ function sent_to_form($sent_to_array) {
if (is_array($sent_to_array['groups'])) {
foreach ($sent_to_array['groups'] as $group_id) {
if (isset($group_names[$group_id]['name'])) {
$output.= $group_names[$group_id]['name']."<br />";
$output[]= $group_names[$group_id]['name'];
}
}
}
@ -1247,7 +1247,7 @@ function sent_to_form($sent_to_array) {
if (is_array($sent_to_array['users'])) {
foreach ($sent_to_array['users'] as $user_id) {
$user_info=api_get_user_info($user_id);
$output.=" ".api_get_person_name($user_info['firstName'], $user_info['lastName'])."<br />";
$output[] = api_get_person_name($user_info['firstName'], $user_info['lastName']);
}
}
}
@ -1255,18 +1255,21 @@ function sent_to_form($sent_to_array) {
// there is only one user/group
if (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 (is_array($sent_to_array['groups']) and $sent_to_array['groups'][0]!==0) {
$group_id=$sent_to_array['groups'][0];
echo $group_names[$group_id]['name'];
$output[]= $group_names[$group_id]['name'];
}
if (is_array($sent_to_array['groups']) and $sent_to_array['groups'][0]==0) {
echo get_lang("Everybody");
$output[]= get_lang("Everybody");
}
}
echo $output;
if (!empty($output)) {
$output = implode(', ', $output);
return $output;
}
}

Loading…
Cancel
Save