Add multiple attachment in agenda see BT#10952

ofaj
Julio 10 years ago
parent aa83c1fe12
commit 10729dea98
  1. 74
      main/calendar/agenda.php
  2. 170
      main/inc/lib/agenda.lib.php
  3. 134
      main/inc/lib/blog.lib.php

@ -57,6 +57,33 @@ function plus_repeated_event() {
</script> </script>
"; ";
$htmlHeadXtra[] = '<script type="text/javascript">
var counter_image = 1;
function add_image_form() {
// Multiple filepaths for image form
var filepaths = document.getElementById("filepaths");
if (document.getElementById("filepath_"+counter_image)) {
counter_image = counter_image + 1;
} else {
counter_image = counter_image;
}
var elem1 = document.createElement("div");
elem1.setAttribute("id","filepath_"+counter_image);
filepaths.appendChild(elem1);
id_elem1 = "filepath_"+counter_image;
id_elem1 = "\'"+id_elem1+"\'";
document.getElementById("filepath_"+counter_image).innerHTML = "<input type=\"file\" name=\"attach_"+counter_image+"\" />&nbsp; <br />'.get_lang('Description').'&nbsp;&nbsp;<input type=\"text\" name=\"legend[]\" /><br /><br />";
if (filepaths.childNodes.length == 6) {
var link_attach = document.getElementById("link-more-attach");
if (link_attach) {
link_attach.innerHTML="";
}
}
}
</script>';
// setting the name of the tool // setting the name of the tool
$nameTools = get_lang('Agenda'); $nameTools = get_lang('Agenda');
@ -90,8 +117,8 @@ $content = null;
if (api_is_allowed_to_edit(false, true) || if (api_is_allowed_to_edit(false, true) ||
(api_get_course_setting('allow_user_edit_agenda') && (api_get_course_setting('allow_user_edit_agenda') &&
!api_is_anonymous() && !api_is_anonymous() &&
api_is_allowed_to_session_edit(false, true)) || api_is_allowed_to_session_edit(false, true)) ||
GroupManager::user_has_access(api_get_user_id(), $group_id, GroupManager::GROUP_TOOL_CALENDAR) && GroupManager::user_has_access(api_get_user_id(), $group_id, GroupManager::GROUP_TOOL_CALENDAR) &&
GroupManager::is_tutor_of_group(api_get_user_id(), $group_id) GroupManager::is_tutor_of_group(api_get_user_id(), $group_id)
) { ) {
@ -106,10 +133,9 @@ if (api_is_allowed_to_edit(false, true) ||
$sendEmail = isset($values['add_announcement']) ? true : false; $sendEmail = isset($values['add_announcement']) ? true : false;
$allDay = isset($values['all_day']) ? 'true' : 'false'; $allDay = isset($values['all_day']) ? 'true' : 'false';
$sendAttachment = isset($_FILES['user_upload']) ? true : false; $sendAttachment = isset($_FILES) && !empty($_FILES) ? true : false;
$attachment = $sendAttachment ? $_FILES['user_upload'] : null; $attachmentList = $sendAttachment ? $_FILES : null;
$attachmentComment = isset($values['file_comment']) ? $values['file_comment'] : null; $attachmentCommentList = isset($values['legend']) ? $values['legend'] : null;
$comment = isset($values['comment']) ? $values['comment'] : null; $comment = isset($values['comment']) ? $values['comment'] : null;
$startDate = $values['date_range_start']; $startDate = $values['date_range_start'];
@ -124,8 +150,8 @@ if (api_is_allowed_to_edit(false, true) ||
$values['users_to_send'], $values['users_to_send'],
$sendEmail, $sendEmail,
null, null,
$attachment, $attachmentList,
$attachmentComment, $attachmentCommentList,
$comment $comment
); );
@ -167,12 +193,14 @@ if (api_is_allowed_to_edit(false, true) ||
$values = $form->getSubmitValues(); $values = $form->getSubmitValues();
$allDay = isset($values['all_day']) ? 'true' : 'false'; $allDay = isset($values['all_day']) ? 'true' : 'false';
$sendEmail = isset($values['add_announcement']) ? true : false;
$startDate = $values['date_range_start']; $startDate = $values['date_range_start'];
$endDate = $values['date_range_end']; $endDate = $values['date_range_end'];
$sendEmail = isset($values['add_announcement']) ? true : false;
$sendAttachment = isset($_FILES['user_upload']) ? true : false; $sendAttachment = isset($_FILES) && !empty($_FILES) ? true : false;
$attachment = $sendAttachment ? $_FILES['user_upload'] : null; $attachmentList = $sendAttachment ? $_FILES : null;
$attachmentComment = isset($values['file_comment']) ? $values['file_comment'] : null; $attachmentCommentList = isset($values['legend']) ? $values['legend'] : null;
$comment = isset($values['comment']) ? $values['comment'] : null; $comment = isset($values['comment']) ? $values['comment'] : null;
// This is a sub event. Delete the current and create another BT#7803 // This is a sub event. Delete the current and create another BT#7803
@ -189,8 +217,8 @@ if (api_is_allowed_to_edit(false, true) ||
$values['users_to_send'], $values['users_to_send'],
false, false,
null, null,
$attachment, $attachmentList,
$attachmentComment, $attachmentCommentList,
$comment $comment
); );
@ -209,8 +237,8 @@ if (api_is_allowed_to_edit(false, true) ||
$values['title'], $values['title'],
$values['content'], $values['content'],
$values['users_to_send'], $values['users_to_send'],
$attachment, $attachmentList,
$attachmentComment, $attachmentCommentList,
$comment, $comment,
'', '',
$sendEmail $sendEmail
@ -227,13 +255,15 @@ if (api_is_allowed_to_edit(false, true) ||
); );
} }
$deleteAttachment = isset($values['delete_attachment']) ? true : false; $deleteAttachmentList = isset($values['delete_attachment']) ? $values['delete_attachment'] : array();
if ($deleteAttachment && isset($event['attachment']) && !empty($event['attachment'])) { if (!empty($deleteAttachmentList)) {
$agenda->deleteAttachmentFile( foreach ($deleteAttachmentList as $deleteAttachmentId => $value) {
$event['attachment']['id'], $agenda->deleteAttachmentFile(
$agenda->course $deleteAttachmentId,
); $agenda->course
);
}
} }
$message = Display::return_message(get_lang('Updated'), 'confirmation'); $message = Display::return_message(get_lang('Updated'), 'confirmation');

@ -48,6 +48,7 @@ class Agenda
$this->event_session_color = '#00496D'; // kind of green $this->event_session_color = '#00496D'; // kind of green
$this->eventOtherSessionColor = '#999'; $this->eventOtherSessionColor = '#999';
$this->event_personal_color = 'steel blue'; //steel blue $this->event_personal_color = 'steel blue'; //steel blue
} }
/** /**
@ -120,8 +121,8 @@ class Agenda
* @param array $usersToSend array('everyone') or a list of user/group ids * @param array $usersToSend array('everyone') or a list of user/group ids
* @param bool $addAsAnnouncement event as a *course* announcement * @param bool $addAsAnnouncement event as a *course* announcement
* @param int $parentEventId * @param int $parentEventId
* @param array $attachmentArray $_FILES[''] * @param array $attachmentArray array of $_FILES['']
* @param string $attachmentComment * @param array $attachmentCommentList
* @param string $eventComment * @param string $eventComment
* @param string $color * @param string $color
* *
@ -137,8 +138,8 @@ class Agenda
$addAsAnnouncement = false, $addAsAnnouncement = false,
$parentEventId = null, $parentEventId = null,
$attachmentArray = array(), $attachmentArray = array(),
$attachmentComment = '', $attachmentCommentList = array(),
$eventComment = '', $eventComment = null,
$color = '' $color = ''
) { ) {
$start = api_get_utc_datetime($start); $start = api_get_utc_datetime($start);
@ -294,12 +295,16 @@ class Agenda
// Add attachment. // Add attachment.
if (isset($attachmentArray) && !empty($attachmentArray)) { if (isset($attachmentArray) && !empty($attachmentArray)) {
$this->addAttachment( $counter = 0;
$id, foreach ($attachmentArray as $attachmentItem) {
$attachmentArray, $this->addAttachment(
$attachmentComment, $id,
$this->course $attachmentItem,
); $attachmentCommentList[$counter],
$this->course
);
$counter++;
}
} }
} }
break; break;
@ -555,7 +560,7 @@ class Agenda
* @param string $content * @param string $content
* @param array $usersToSend * @param array $usersToSend
* @param array $attachmentArray * @param array $attachmentArray
* @param string $attachmentComment * @param array $attachmentCommentList
* @param string $comment * @param string $comment
* @param string $color * @param string $color
* @param bool $addAnnouncement * @param bool $addAnnouncement
@ -571,8 +576,8 @@ class Agenda
$content, $content,
$usersToSend = array(), $usersToSend = array(),
$attachmentArray = array(), $attachmentArray = array(),
$attachmentComment = '', $attachmentCommentList = array(),
$comment = '', $comment = null,
$color = '', $color = '',
$addAnnouncement = false $addAnnouncement = false
) { ) {
@ -781,12 +786,17 @@ class Agenda
// Add attachment. // Add attachment.
if (isset($attachmentArray) && !empty($attachmentArray)) { if (isset($attachmentArray) && !empty($attachmentArray)) {
$this->updateAttachment( $counter = 0;
$id, foreach ($attachmentArray as $attachmentItem) {
$attachmentArray, $this->updateAttachment(
$attachmentComment, $attachmentItem['id'],
$this->course $id,
); $attachmentItem,
$attachmentCommentList[$counter],
$this->course
);
$counter++;
}
} }
} }
break; break;
@ -828,10 +838,11 @@ class Agenda
break; break;
case 'course': case 'course':
$course_id = api_get_course_int_id(); $course_id = api_get_course_int_id();
if (!empty($course_id) && api_is_allowed_to_edit(null, true)) { if (!empty($course_id) && api_is_allowed_to_edit(null, true)) {
// Delete // Delete
$eventInfo = $this->get_event($id);
if ($deleteAllItemsFromSerie) { if ($deleteAllItemsFromSerie) {
$eventInfo = $this->get_event($id);
/* This is one of the children. /* This is one of the children.
Getting siblings and delete 'Em all + the father! */ Getting siblings and delete 'Em all + the father! */
if (isset($eventInfo['parent_event_id']) && !empty($eventInfo['parent_event_id'])) { if (isset($eventInfo['parent_event_id']) && !empty($eventInfo['parent_event_id'])) {
@ -874,6 +885,12 @@ class Agenda
$this->table_repeat, $this->table_repeat,
array('cal_id = ? AND c_id = ?' => array($id, $course_id)) array('cal_id = ? AND c_id = ?' => array($id, $course_id))
); );
if (isset($eventInfo['attachment']) && !empty($eventInfo['attachment'])) {
foreach ($eventInfo['attachment'] as $attachment) {
self::deleteAttachmentFile($attachment['id'], $this->course);
}
}
} }
break; break;
case 'admin': case 'admin':
@ -1207,7 +1224,7 @@ class Agenda
$event['parent_info'] = $this->get_event($event['parent_event_id']); $event['parent_info'] = $this->get_event($event['parent_event_id']);
} }
$event['attachment'] = $this->getAttachment($id, $this->course); $event['attachment'] = $this->getAttachmentList($id, $this->course);
} }
} }
break; break;
@ -1368,15 +1385,15 @@ class Agenda
if (!empty($courses)) { if (!empty($courses)) {
foreach ($courses as $course) { foreach ($courses as $course) {
//if (api_is_coach($sessionId, $course['real_id'])) { //if (api_is_coach($sessionId, $course['real_id'])) {
$this->getCourseEvents( $this->getCourseEvents(
$start, $start,
$end, $end,
$course, $course,
0, 0,
$sessionId, $sessionId,
0, 0,
$color $color
); );
//} //}
} }
} }
@ -1600,15 +1617,16 @@ class Agenda
); );
$group_to_array = $items['groups']; $group_to_array = $items['groups'];
$user_to_array = $items['users']; $user_to_array = $items['users'];
$attachment = $this->getAttachment($row['id'], $courseInfo); $attachmentList = $this->getAttachmentList($row['id'], $courseInfo);
$event['attachment'] = '';
if (!empty($attachment)) {
$has_attachment = Display::return_icon('attachment.gif', get_lang('Attachment')); if (!empty($attachmentList)) {
$user_filename = $attachment['filename']; foreach ($attachmentList as $attachment) {
$url = api_get_path(WEB_CODE_PATH).'calendar/download.php?file='.$attachment['path'].'&course_id='.$course_id.'&'.api_get_cidreq(); $has_attachment = Display::return_icon('attachment.gif', get_lang('Attachment'));
$event['attachment'] = $has_attachment.Display::url($user_filename, $url); $user_filename = $attachment['filename'];
} else { $url = api_get_path(WEB_CODE_PATH).'calendar/download.php?file='.$attachment['path'].'&course_id='.$course_id.'&'.api_get_cidreq();
$event['attachment'] = ''; $event['attachment'] .= $has_attachment.Display::url($user_filename, $url).'<br />';
}
} }
$event['title'] = $row['title']; $event['title'] = $row['title'];
@ -2122,21 +2140,38 @@ class Agenda
if ($this->type == 'course') { if ($this->type == 'course') {
$form->addElement('textarea', 'comment', get_lang('Comment')); $form->addElement('textarea', 'comment', get_lang('Comment'));
$form->addElement('file', 'user_upload', get_lang('AddAnAttachment')); $form->addLabel(
if ($showAttachmentForm) { get_lang('FilesAttachment'),
if (isset($params['attachment']) && !empty($params['attachment'])) { '<span id="filepaths">
$attachment = $params['attachment']; <div id="filepath_1">
<input type="file" name="attach_1"/><br />
'.get_lang('Description').'&nbsp;&nbsp;<input type="text" name="legend[]" /><br /><br />
</div>
</span>'
);
$form->addLabel('',
'<span id="link-more-attach"><a href="javascript://" onclick="return add_image_form()">'.get_lang('AddOneMoreFile').'</a></span>&nbsp;('.sprintf(get_lang('MaximunFileSizeX'),format_file_size(api_get_setting('message_max_upload_filesize'))).')');
//if ($showAttachmentForm) {
if (isset($params['attachment']) && !empty($params['attachment'])) {
$attachmentList = $params['attachment'];
foreach ($attachmentList as $attachment) {
$params['file_comment'] = $attachment['comment']; $params['file_comment'] = $attachment['comment'];
if (!empty($attachment['path'])) { if (!empty($attachment['path'])) {
$form->addElement( $form->addElement(
'checkbox', 'checkbox',
'delete_attachment', 'delete_attachment['.$attachment['id'].']',
null, null,
get_lang('DeleteAttachment').' '.$attachment['filename'] get_lang('DeleteAttachment').': '.$attachment['filename']
); );
} }
} }
} }
// }
$form->addElement('textarea', 'file_comment', get_lang('FileComment')); $form->addElement('textarea', 'file_comment', get_lang('FileComment'));
} }
@ -2257,18 +2292,50 @@ class Agenda
* @param array $courseInfo * @param array $courseInfo
* @return array with the post info * @return array with the post info
*/ */
public function getAttachment($eventId, $courseInfo) public function getAttachmentList($eventId, $courseInfo)
{ {
$tableAttachment = Database::get_course_table(TABLE_AGENDA_ATTACHMENT); $tableAttachment = Database::get_course_table(TABLE_AGENDA_ATTACHMENT);
$courseId = intval($courseInfo['real_id']); $courseId = intval($courseInfo['real_id']);
$eventId = intval($eventId); $eventId = intval($eventId);
$row = array();
$sql = "SELECT id, path, filename, comment $sql = "SELECT id, path, filename, comment
FROM $tableAttachment FROM $tableAttachment
WHERE WHERE
c_id = $courseId AND c_id = $courseId AND
agenda_id = $eventId"; agenda_id = $eventId";
$result = Database::query($sql); $result = Database::query($sql);
$list = array();
if (Database::num_rows($result) != 0) {
$list = Database::store_result($result, 'ASSOC');
}
return $list;
}
/**
* Show a list with all the attachments according to the post's id
* @param int $attachmentId
* @param int $eventId
* @param array $courseInfo
* @return array with the post info
*/
public function getAttachment($attachmentId, $eventId, $courseInfo)
{
$tableAttachment = Database::get_course_table(TABLE_AGENDA_ATTACHMENT);
$courseId = intval($courseInfo['real_id']);
$eventId = intval($eventId);
$attachmentId = intval($attachmentId);
$row = array();
$sql = "SELECT id, path, filename, comment
FROM $tableAttachment
WHERE
c_id = $courseId AND
agenda_id = $eventId AND
id = $attachmentId
";
$result = Database::query($sql);
if (Database::num_rows($result) != 0) { if (Database::num_rows($result) != 0) {
$row = Database::fetch_array($result, 'ASSOC'); $row = Database::fetch_array($result, 'ASSOC');
} }
@ -2349,16 +2416,17 @@ class Agenda
} }
/** /**
* @param int $attachmentId
* @param int $eventId * @param int $eventId
* @param array $fileUserUpload * @param array $fileUserUpload
* @param string $comment * @param string $comment
* @param array $courseInfo * @param array $courseInfo
*/ */
public function updateAttachment($eventId, $fileUserUpload, $comment, $courseInfo) public function updateAttachment($attachmentId, $eventId, $fileUserUpload, $comment, $courseInfo)
{ {
$attachment = $this->getAttachment($eventId, $courseInfo); $attachment = $this->getAttachment($attachmentId, $eventId, $courseInfo);
if (!empty($attachment)) { if (!empty($attachment)) {
$this->deleteAttachmentFile($attachment['id'], $courseInfo); $this->deleteAttachmentFile($attachmentId, $courseInfo);
} }
$this->addAttachment($eventId, $fileUserUpload, $comment, $courseInfo); $this->addAttachment($eventId, $fileUserUpload, $comment, $courseInfo);
} }
@ -3176,7 +3244,7 @@ class Agenda
if (!empty($agendaitems[$curday])) { if (!empty($agendaitems[$curday])) {
$items = $agendaitems[$curday]; $items = $agendaitems[$curday];
$items = msort($items, 'start_date_tms'); $items = msort($items, 'start_date_tms');
foreach($items as $value) { foreach($items as $value) {
$value['title'] = Security::remove_XSS($value['title']); $value['title'] = Security::remove_XSS($value['title']);
$start_time = api_format_date($value['start_date'], TIME_NO_SEC_FORMAT); $start_time = api_format_date($value['start_date'], TIME_NO_SEC_FORMAT);

@ -26,7 +26,6 @@ class Blog
$course_id = api_get_course_int_id(); $course_id = api_get_course_int_id();
if (is_numeric($blog_id)) { if (is_numeric($blog_id)) {
// init
$tbl_blogs = Database::get_course_table(TABLE_BLOGS); $tbl_blogs = Database::get_course_table(TABLE_BLOGS);
$sql = "SELECT blog_name $sql = "SELECT blog_name
@ -35,6 +34,7 @@ class Blog
$result = Database::query($sql); $result = Database::query($sql);
$blog = Database::fetch_array($result); $blog = Database::fetch_array($result);
return stripslashes($blog['blog_name']); return stripslashes($blog['blog_name']);
} }
} }
@ -96,8 +96,8 @@ class Blog
/** /**
* Creates a new blog in the given course * Creates a new blog in the given course
* @author Toon Keppens * @author Toon Keppens
* @param Integer $course_id Id * @param int $course_id Id
* @param String $title * @param string $title
* @param Text $description * @param Text $description
*/ */
public static function create_blog($title, $subtitle) public static function create_blog($title, $subtitle)
@ -111,7 +111,6 @@ class Blog
$tbl_blogs = Database::get_course_table(TABLE_BLOGS); $tbl_blogs = Database::get_course_table(TABLE_BLOGS);
$tbl_tool = Database::get_course_table(TABLE_TOOL_LIST); $tbl_tool = Database::get_course_table(TABLE_TOOL_LIST);
$tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS);
$tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
//verified if exist blog //verified if exist blog
$sql = 'SELECT COUNT(*) as count FROM '.$tbl_blogs.' $sql = 'SELECT COUNT(*) as count FROM '.$tbl_blogs.'
@ -186,9 +185,9 @@ class Blog
/** /**
* Update title and subtitle of a blog in the given course * Update title and subtitle of a blog in the given course
* @author Toon Keppens * @author Toon Keppens
* @param Integer $course_id Id * @param int $course_id Id
* @param String $title * @param string $title
* @param Text $description * @param string $description
*/ */
public static function edit_blog($blog_id, $title, $subtitle) public static function edit_blog($blog_id, $title, $subtitle)
{ {
@ -238,7 +237,6 @@ class Blog
$tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
$tbl_tool = Database::get_course_table(TABLE_TOOL_LIST); $tbl_tool = Database::get_course_table(TABLE_TOOL_LIST);
$tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING); $tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING);
$tbl_blogs_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT);
$course_id = api_get_course_int_id(); $course_id = api_get_course_int_id();
$blog_id = intval($blog_id); $blog_id = intval($blog_id);
@ -545,7 +543,6 @@ class Blog
*/ */
public static function create_task($blog_id, $title, $description, $articleDelete, $articleEdit, $commentsDelete, $color) public static function create_task($blog_id, $title, $description, $articleDelete, $articleEdit, $commentsDelete, $color)
{ {
// Init
$tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
$tbl_tasks_permissions = Database::get_course_table(TABLE_BLOGS_TASKS_PERMISSIONS); $tbl_tasks_permissions = Database::get_course_table(TABLE_BLOGS_TASKS_PERMISSIONS);
@ -1395,11 +1392,11 @@ class Blog
echo '<span class="blogpost_title">' . get_lang('TaskList') . '</span><br />'; echo '<span class="blogpost_title">' . get_lang('TaskList') . '</span><br />';
echo "<table class=\"data_table\">"; echo "<table class=\"data_table\">";
echo "<tr bgcolor=\"$color2\" align=\"center\" valign=\"top\">", echo "<tr bgcolor=\"$color2\" align=\"center\" valign=\"top\">",
"<th width='240'><b>",get_lang('Title'),"</b></th>\n", "<th width='240'><b>",get_lang('Title'),"</b></th>",
"<th><b>",get_lang('Description'),"</b></th>\n", "<th><b>",get_lang('Description'),"</b></th>",
"<th><b>",get_lang('Color'),"</b></th>\n", "<th><b>",get_lang('Color'),"</b></th>",
"<th width='50'><b>",get_lang('Modify'),"</b></th>\n", "<th width='50'><b>",get_lang('Modify'),"</b></th>",
"</tr>\n"; "</tr>";
$sql = " SELECT $sql = " SELECT
@ -1415,29 +1412,29 @@ class Blog
ORDER BY system_task, title"; ORDER BY system_task, title";
$result = Database::query($sql); $result = Database::query($sql);
while ($task = Database::fetch_array($result)) {
while($task = Database::fetch_array($result)) {
$counter++; $counter++;
$css_class = (($counter % 2) == 0) ? "row_odd" : "row_even"; $css_class = (($counter % 2) == 0) ? "row_odd" : "row_even";
$delete_icon = ($task['system_task'] == '1') ? "delete_na.gif" : "delete.gif"; $delete_icon = ($task['system_task'] == '1') ? "delete_na.png" : "delete.png";
$delete_title = ($task['system_task'] == '1') ? get_lang('DeleteSystemTask') : get_lang('DeleteTask'); $delete_title = ($task['system_task'] == '1') ? get_lang('DeleteSystemTask') : get_lang('DeleteTask');
$delete_link = ($task['system_task'] == '1') ? '#' : api_get_self() . '?action=manage_tasks&blog_id=' . $task['blog_id'] . '&do=delete&task_id=' . $task['task_id']; $delete_link = ($task['system_task'] == '1') ? '#' : api_get_self() . '?action=manage_tasks&blog_id=' . $task['blog_id'] . '&do=delete&task_id=' . $task['task_id'];
$delete_confirm = ($task['system_task'] == '1') ? '' : 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;"'; $delete_confirm = ($task['system_task'] == '1') ? '' : 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;"';
echo '<tr class="' . $css_class . '" valign="top">', echo '<tr class="' . $css_class . '" valign="top">';
'<td width="240">' . Security::remove_XSS($task['title']) . '</td>', echo '<td width="240">'.Security::remove_XSS($task['title']).'</td>';
'<td>' . Security::remove_XSS($task['description']) . '</td>', echo '<td>'.Security::remove_XSS($task['description']).'</td>';
'<td><span style="background-color: #' . $task['color'] . '">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></td>', echo '<td><span style="background-color: #'.$task['color'].'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></td>';
'<td width="50">', echo '<td width="50">';
'<a href="' .api_get_self(). '?action=manage_tasks&blog_id=' . $task['blog_id'] . '&do=edit&task_id=' . $task['task_id'] . '">', echo '<a href="'.api_get_self().'?action=manage_tasks&blog_id='.$task['blog_id'].'&do=edit&task_id='.$task['task_id'].'">',
'<img src="../img/edit.gif" border="0" title="' . get_lang('EditTask') . '" />', echo Display::return_icon('edit.png', get_lang('EditTask'));
"</a>\n", echo "</a>";
'<a href="' . $delete_link . '"', echo '<a href="'.$delete_link.'"';
$delete_confirm, echo $delete_confirm;
'><img src="../img/' . $delete_icon . '" border="0" title="' . $delete_title . '" />', echo '>';
"</a>\n", echo Display::return_icon($delete_icon, $delete_title);
'</td>', echo "</a>";
'</tr>'; echo '</td>';
echo '</tr>';
} }
echo "</table>"; echo "</table>";
} }
@ -1461,11 +1458,11 @@ class Blog
echo '<span class="blogpost_title">' . get_lang('AssignedTasks') . '</span><br />'; echo '<span class="blogpost_title">' . get_lang('AssignedTasks') . '</span><br />';
echo "<table class=\"data_table\">"; echo "<table class=\"data_table\">";
echo "<tr bgcolor=\"$color2\" align=\"center\" valign=\"top\">", echo "<tr bgcolor=\"$color2\" align=\"center\" valign=\"top\">",
"<th width='240'><b>",get_lang('Member'),"</b></th>\n", "<th width='240'><b>",get_lang('Member'),"</b></th>",
"<th><b>",get_lang('Task'),"</b></th>\n", "<th><b>",get_lang('Task'),"</b></th>",
"<th><b>",get_lang('Description'),"</b></th>\n", "<th><b>",get_lang('Description'),"</b></th>",
"<th><b>",get_lang('TargetDate'),"</b></th>\n", "<th><b>",get_lang('TargetDate'),"</b></th>",
"<th width='50'><b>",get_lang('Modify'),"</b></th>\n", "<th width='50'><b>",get_lang('Modify'),"</b></th>",
"</tr>"; "</tr>";
$course_id = api_get_course_int_id(); $course_id = api_get_course_int_id();
@ -1484,28 +1481,32 @@ class Blog
while ($assignment = Database::fetch_array($result)) { while ($assignment = Database::fetch_array($result)) {
$counter++; $counter++;
$css_class = (($counter % 2)==0) ? "row_odd" : "row_even"; $css_class = (($counter % 2)==0) ? "row_odd" : "row_even";
$delete_icon = ($assignment['system_task'] == '1') ? "delete_na.gif" : "delete.gif"; $delete_icon = ($assignment['system_task'] == '1') ? "delete_na.png" : "delete.png";
$delete_title = ($assignment['system_task'] == '1') ? get_lang('DeleteSystemTask') : get_lang('DeleteTask'); $delete_title = ($assignment['system_task'] == '1') ? get_lang('DeleteSystemTask') : get_lang('DeleteTask');
$delete_link = ($assignment['system_task'] == '1') ? '#' : api_get_self() . '?action=manage_tasks&blog_id=' . $assignment['blog_id'] . '&do=delete&task_id=' . $assignment['task_id']; $delete_link = ($assignment['system_task'] == '1') ? '#' : api_get_self() . '?action=manage_tasks&blog_id=' . $assignment['blog_id'] . '&do=delete&task_id=' . $assignment['task_id'];
$delete_confirm = ($assignment['system_task'] == '1') ? '' : 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;"'; $delete_confirm = ($assignment['system_task'] == '1') ? '' : 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;"';
$username = api_htmlentities(sprintf(get_lang('LoginX'), $assignment['username']), ENT_QUOTES); $username = api_htmlentities(sprintf(get_lang('LoginX'), $assignment['username']), ENT_QUOTES);
echo '<tr class="' . $css_class . '" valign="top">', echo '<tr class="'.$css_class.'" valign="top">';
'<td width="240">' . Display::tag('span', api_get_person_name($assignment['firstname'], $assignment['lastname']), array('title'=>$username)) . '</td>', echo '<td width="240">'.Display::tag(
'<td>'.stripslashes($assignment['title']) . '</td>', 'span',
'<td>'.stripslashes($assignment['description']) . '</td>', api_get_person_name($assignment['firstname'], $assignment['lastname']),
'<td>' . $assignment['target_date'] . '</td>', array('title' => $username)
'<td width="50">', ).'</td>';
'<a href="' .api_get_self(). '?action=manage_tasks&blog_id=' . $assignment['blog_id'] . '&do=edit_assignment&task_id=' . $assignment['task_id'] . '&user_id=' . $assignment['user_id'] . '">', echo '<td>'.stripslashes($assignment['title']).'</td>';
'<img src="../img/edit.gif" border="0" title="' . get_lang('EditTask') . '" />', echo '<td>'.stripslashes($assignment['description']).'</td>';
"</a>\n", echo '<td>'.$assignment['target_date'].'</td>';
'<a href="' .api_get_self(). '?action=manage_tasks&blog_id=' . $assignment['blog_id'] . '&do=delete_assignment&task_id=' . $assignment['task_id'] . '&user_id=' . $assignment['user_id'] . '" ', echo '<td width="50">';
'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;"', echo '<a href="'.api_get_self().'?action=manage_tasks&blog_id='.$assignment['blog_id'].'&do=edit_assignment&task_id='.$assignment['task_id'].'&user_id='.$assignment['user_id'].'">',
'<img src="../img/' . $delete_icon . '" border="0" title="' . $delete_title . '" />', echo Display::return_icon('edit.png', get_lang('EditTask'));
"</a>\n", echo "</a>";
'</td>', echo '<a href="'.api_get_self().'?action=manage_tasks&blog_id='.$assignment['blog_id'].'&do=delete_assignment&task_id='.$assignment['task_id'].'&user_id='.$assignment['user_id'].'" ';
'</tr>'; echo 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"), ENT_QUOTES, $charset)).'\')) return false;"';
echo Display::return_icon($delete_icon, $delete_title);
echo "</a>";
echo '</td>';
echo '</tr>';
} }
echo "</table>"; echo "</table>";
} }
@ -2396,12 +2397,12 @@ class Blog
} }
echo '<table id="smallcalendar" class="table table-responsive">', echo '<table id="smallcalendar" class="table table-responsive">',
"<tr id=\"title\">\n", "<tr id=\"title\">",
"<th width=\"10%\"><a href=\"", $backwardsURL, "\">&laquo;</a></th>\n", "<th width=\"10%\"><a href=\"", $backwardsURL, "\">&laquo;</a></th>",
"<th align=\"center\" width=\"80%\" colspan=\"5\">", $monthName, " ", $year, "</th>\n", "<th align=\"center\" width=\"80%\" colspan=\"5\">", $monthName, " ", $year, "</th>",
"<th width=\"10%\" align=\"right\"><a href=\"", $forewardsURL, "\">&raquo;</a></th>\n", "</tr>"; "<th width=\"10%\" align=\"right\"><a href=\"", $forewardsURL, "\">&raquo;</a></th>", "</tr>";
echo "<tr>\n"; echo "<tr>";
for($ii = 1; $ii < 8; $ii ++) for($ii = 1; $ii < 8; $ii ++)
echo "<td class=\"weekdays\">", $DaysShort[$ii % 7], "</td>"; echo "<td class=\"weekdays\">", $DaysShort[$ii % 7], "</td>";
@ -2438,8 +2439,9 @@ class Blog
if (isset($tasks[$curday]) && is_array($tasks[$curday])) { if (isset($tasks[$curday]) && is_array($tasks[$curday])) {
// Add tasks to calendar // Add tasks to calendar
foreach ($tasks[$curday] as $task) { foreach ($tasks[$curday] as $task) {
echo '<a href="blog.php?action=execute_task&blog_id=' . $task['blog_id'] . '&task_id='.stripslashes($task['task_id']) . '" title="' . $task['title'] . ' : ' . get_lang('InBlog') . ' : ' . $task['blog_name'] . ' - ' . get_lang('ExecuteThisTask') . '"> echo '<a href="blog.php?action=execute_task&blog_id=' . $task['blog_id'] . '&task_id='.stripslashes($task['task_id']) . '" title="' . $task['title'] . ' : ' . get_lang('InBlog') . ' : ' . $task['blog_name'] . ' - ' . get_lang('ExecuteThisTask') . '">';
<img src="../img/blog_task.gif" alt="Task" title="' . get_lang('ExecuteThisTask') . '" /></a>'; echo Display::return_icon('blog_task.gif', get_lang('ExecuteThisTask'));
echo '</a>';
} }
} }
} }
@ -2527,7 +2529,6 @@ class Blog
//condition for the session //condition for the session
$session_id = api_get_session_id(); $session_id = api_get_session_id();
$condition_session = api_get_session_condition($session_id, false);
$sql = "SELECT blog_name, blog_subtitle, visibility, blog_id, session_id $sql = "SELECT blog_name, blog_subtitle, visibility, blog_id, session_id
FROM $tbl_blogs WHERE c_id = $course_id FROM $tbl_blogs WHERE c_id = $course_id
@ -2561,27 +2562,22 @@ class Blog
$my_image = '<a href="' .api_get_self(). '?action=edit&blog_id=' . $info_log[3] . '">'; $my_image = '<a href="' .api_get_self(). '?action=edit&blog_id=' . $info_log[3] . '">';
$my_image.= Display::return_icon('edit.png', get_lang('EditBlog')); $my_image.= Display::return_icon('edit.png', get_lang('EditBlog'));
$my_image.= "</a>\n"; $my_image.= "</a>";
$my_image.= '<a href="' .api_get_self(). '?action=delete&blog_id=' . $info_log[3] . '" '; $my_image.= '<a href="' .api_get_self(). '?action=delete&blog_id=' . $info_log[3] . '" ';
$my_image.= 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;" >'; $my_image.= 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;" >';
$my_image.= Display::return_icon('delete.png', get_lang('DeleteBlog')); $my_image.= Display::return_icon('delete.png', get_lang('DeleteBlog'));
$my_image.= "</a>\n"; $my_image.= "</a>";
$my_image.= '<a href="' .api_get_self(). '?action=visibility&blog_id=' . $info_log[3] . '">'; $my_image.= '<a href="' .api_get_self(). '?action=visibility&blog_id=' . $info_log[3] . '">';
$my_image.= Display::return_icon($visibility_icon . '.gif', get_lang($visibility_info)); $my_image.= Display::return_icon($visibility_icon . '.gif', get_lang($visibility_info));
$my_image.= "</a>\n"; $my_image.= "</a>";
$list_body_blog[]=$my_image; $list_body_blog[]=$my_image;
$list_content_blog[]=$list_body_blog; $list_content_blog[]=$list_body_blog;
$list_body_blog = array(); $list_body_blog = array();
} }
$parameters='';
//$parameters=array('action'=>Security::remove_XSS($_GET['action']));
$table = new SortableTableFromArrayConfig($list_content_blog, 1,20,'project'); $table = new SortableTableFromArrayConfig($list_content_blog, 1,20,'project');
//$table->set_additional_parameters($parameters);
$table->set_header(0, get_lang('Title')); $table->set_header(0, get_lang('Title'));
$table->set_header(1, get_lang('SubTitle')); $table->set_header(1, get_lang('SubTitle'));
$table->set_header(2, get_lang('Modify')); $table->set_header(2, get_lang('Modify'));

Loading…
Cancel
Save