Adding event comments see BT#7802

Requires DB change + configuration setting 'allow_agenda_event_comment'
1.9.x
Julio Montoya 10 years ago
parent c7955a6c0d
commit 3a7cf71e15
  1. 36
      main/calendar/agenda.lib.php
  2. 12
      main/calendar/agenda.php
  3. 8
      main/calendar/agenda_js.php
  4. 4
      main/calendar/agenda_list.php
  5. 46
      main/cron/import_csv.php
  6. 2
      main/install/configuration.dist.php
  7. 8
      main/template/default/agenda/event_list.tpl
  8. 36
      main/template/default/agenda/month.tpl

@ -16,6 +16,7 @@ class Agenda
public $senderId;
/** @var array */
public $course;
public $comment;
/**
* Constructor
@ -114,6 +115,7 @@ class Agenda
* @param int $parentEventId
* @param array $attachmentArray $_FILES['']
* @param string $attachmentComment
* @param string $eventComment
*
* @return int
*/
@ -127,7 +129,8 @@ class Agenda
$addAsAnnouncement = false,
$parentEventId = null,
$attachmentArray = array(),
$attachmentComment = null
$attachmentComment = null,
$eventComment = null
) {
$start = api_get_utc_datetime($start);
$end = api_get_utc_datetime($end);
@ -160,6 +163,12 @@ class Agenda
'c_id' => $this->course['real_id']
);
$allow = api_get_configuration_value('allow_agenda_event_comment');
if ($allow) {
$attributes['comment'] = $eventComment;
}
if (!empty($parentEventId)) {
$attributes['parent_event_id'] = $parentEventId;
}
@ -533,6 +542,7 @@ class Agenda
* @param int $editRepeatType
* @param array $attachmentArray
* @param string $attachmentComment
* @param string $comment
*
* @return bool
*/
@ -545,7 +555,8 @@ class Agenda
$content,
$usersToSend = array(),
$attachmentArray = array(),
$attachmentComment = null
$attachmentComment = null,
$comment = null
) {
$start = api_get_utc_datetime($start);
$end = api_get_utc_datetime($end);
@ -594,6 +605,12 @@ class Agenda
'all_day' => $allDay
);
$allow = api_get_configuration_value('allow_agenda_event_comment');
if ($allow) {
$attributes['comment'] = $comment;
}
Database::update(
$this->tbl_course_agenda,
$attributes,
@ -1322,6 +1339,7 @@ class Agenda
}
$sql .= $dateCondition;
$allowComments = api_get_configuration_value('allow_agenda_event_comment');
$result = Database::query($sql);
if (Database::num_rows($result)) {
@ -1428,9 +1446,16 @@ class Agenda
$event['parent_event_id'] = $row['parent_event_id'];
$event['has_children'] = $this->hasChildren($row['id'], $course_id) ? 1 : 0;
if ($allowComments) {
$event['comment'] = $row['comment'];
} else {
$event['comment'] = null;
}
$this->events[] = $event;
}
}
return $this->events;
}
@ -1822,6 +1847,11 @@ class Agenda
);
if ($this->type == 'course') {
$allow = api_get_configuration_value('allow_agenda_event_comment');
if ($allow) {
$form->addElement('textarea', 'comment', get_lang('Comment'));
}
$form->addElement('file', 'user_upload', get_lang('AddAnAttachment'));
if ($showAttachmentForm) {
@ -1839,7 +1869,7 @@ class Agenda
}
}
$form->addElement('textarea', 'file_comment', get_lang('Comment'));
$form->addElement('textarea', 'file_comment', get_lang('FileComment'));
}
if (empty($id)) {

@ -114,6 +114,8 @@ if (api_is_allowed_to_edit(false, true) OR
$attachment = $sendAttachment ? $_FILES['user_upload'] : null;
$attachmentComment = isset($values['file_comment']) ? $values['file_comment'] : null;
$comment = isset($values['comment']) ? $values['comment'] : null;
$startDate = $values['date_range_start'];
$endDate = $values['date_range_end'];
@ -127,7 +129,8 @@ if (api_is_allowed_to_edit(false, true) OR
$sendEmail,
null,
$attachment,
$attachmentComment
$attachmentComment,
$comment
);
if (!empty($values['repeat']) && !empty($eventId)) {
@ -174,6 +177,7 @@ if (api_is_allowed_to_edit(false, true) OR
$sendAttachment = isset($_FILES['user_upload']) ? true : false;
$attachment = $sendAttachment ? $_FILES['user_upload'] : null;
$attachmentComment = isset($values['file_comment']) ? $values['file_comment'] : null;
$comment = isset($values['comment']) ? $values['comment'] : null;
// This is a sub event. Delete the current and create another BT#7803
@ -190,7 +194,8 @@ if (api_is_allowed_to_edit(false, true) OR
false,
null,
$attachment,
$attachmentComment
$attachmentComment,
$comment
);
$message = Display::return_message(get_lang('Updated'), 'confirmation');
@ -209,7 +214,8 @@ if (api_is_allowed_to_edit(false, true) OR
$values['content'],
$values['users_to_send'],
$attachment,
$attachmentComment
$attachmentComment,
$comment
);
if (!empty($values['repeat']) && !empty($eventId)) {

@ -1,5 +1,6 @@
<?php
/* For licensing terms, see /license.txt */
/**
* @package chamilo.calendar
*/
@ -221,10 +222,15 @@ $form->addElement('label', get_lang('Date'), '<span id="start_date"></span><span
$form->addElement('text', 'title', get_lang('Title'), array('id' => 'title'));
$form->addElement('textarea', 'content', get_lang('Description'), array('id' => 'content'));
$allowEventComment = api_get_configuration_value('allow_agenda_event_comment');
if ($agenda->type == 'course') {
$form->addElement('html', '<div id="add_as_announcement_div" style="display: none">');
$form->addElement('checkbox', 'add_as_annonuncement', null, get_lang('AddAsAnnouncement'));
$form->addElement('html', '</div>');
if ($allowEventComment) {
$form->addElement('textarea', 'comment', get_lang('Comment'), array('id' => 'comment'));
}
}
$tpl->assign('form_add', $form->return_form());
@ -234,6 +240,8 @@ $content = $tpl->fetch('default/agenda/month.tpl');
$message = Session::read('message');
$tpl->assign('message', $message);
$tpl->assign('allow_agenda_event_comment', $allowEventComment);
Session::erase('message');
$tpl->assign('content', $content);

@ -3,9 +3,7 @@
/**
* @package chamilo.calendar
*/
/**
* INIT SECTION
*/
// name of the language file that needs to be included
$language_file = array('agenda', 'group', 'announcements');

@ -644,17 +644,47 @@ class ImportCsv
{
$data = Import::csv_to_array($file);
if ($this->getDumpValues()) {
// Remove all calendar items
$truncateTables = array(
Database::get_course_table(TABLE_AGENDA),
Database::get_course_table(TABLE_AGENDA_ATTACHMENT),
Database::get_course_table(TABLE_AGENDA_REPEAT),
Database::get_course_table(TABLE_AGENDA_REPEAT_NOT),
Database::get_main_table(TABLE_PERSONAL_AGENDA),
Database::get_main_table(TABLE_PERSONAL_AGENDA_REPEAT_NOT),
Database::get_main_table(TABLE_PERSONAL_AGENDA_REPEAT)
);
foreach ($truncateTables as $table) {
$sql = "TRUNCATE $table";
Database::query($sql);
}
$table = Database::get_course_table(TABLE_ITEM_PROPERTY);
$sql = "DELETE FROM $table WHERE tool = 'calendar_event'";
Database::query($sql);
}
if (!empty($data)) {
$this->logger->addInfo(count($data) . " records found.");
$eventsToCreate = array();
$errorFound = false;
foreach ($data as $row) {
$sessionId = null;
$externalSessionId = null;
if (isset($row['external_sessionID'])) {
$externalSessionId = $row['external_sessionID'];
$sessionId = SessionManager::get_session_id_from_original_id(
$row['external_sessionID'],
$externalSessionId,
$this->extraFieldIdNameList['session']
);
}
$courseCode = null;
if (isset($row['coursecode'])) {
$courseCode = $row['coursecode'];
}
$courseInfo = api_get_course_info($courseCode);
if (empty($courseInfo)) {
@ -662,7 +692,7 @@ class ImportCsv
}
if (empty($sessionId)) {
$this->logger->addInfo("external_sessionID: ".$row['external_sessionID']." does not exists.");
$this->logger->addInfo("external_sessionID: ".$externalSessionId." does not exists.");
}
$teacherId = null;
@ -793,6 +823,12 @@ class ImportCsv
$agenda->setSessionId($event['session_id']);
$agenda->setSenderId($event['sender_id']);
$eventComment = $event['comment'];
// To use the event comment you need
// ALTER TABLE c_calendar_event ADD COLUMN comment TEXT;
// add in configuration.php allow_agenda_event_comment = true
if (empty($courseInfo)) {
$this->logger->addInfo(
"No course found for added: #".$event['course_id']." Skipping ..."
@ -814,7 +850,11 @@ class ImportCsv
$event['title'],
$content,
array('everyone'), // send to
false //$addAsAnnouncement = false
false, //$addAsAnnouncement = false
null, // $parentEventId
array(), //$attachmentArray = array(),
null, //$attachmentComment = null,
$eventComment
);
if (!empty($eventId)) {

@ -284,3 +284,5 @@ $_configuration['system_stable'] = NEW_VERSION_STABLE;
//);
// Shows a warning message explaining that the site uses cookies
//$_configuration['cookie_warning'] = false;
// Allows a comment field in the course calendar events. Requires DB change
//$_configuration['allow_agenda_event_comment'] = false;

@ -29,7 +29,15 @@
</td>
<td style="width:50%">
{{ event.title }}
{% if event.description %}
<p>{{ event.description}}</p>
{% endif %}
{% if event.comment %}
<p>{{ event.comment}}</p>
{% endif %}
{{ event.attachment }}
</td>

@ -230,21 +230,25 @@ $(document).ready(function() {
delay: 2000
},
content: event.attachment,
position: { at:'top right' , my:'bottom right'},
position: { at:'top right' , my:'bottom right'}
}).removeData('qtip'); // this is an special hack to add multiple qtip in the same target
}
if (event.description) {
var comment = '';
if (event.comment) {
comment = event.comment;
}
element.qtip({
hide: {
delay: 2000
},
content: event.description,
content: event.description + ' ' + comment,
position: { at:'top left' , my:'bottom left'}
});
}
},
eventClick: function(calEvent, jsEvent, view) {
//var start_date = Math.round(calEvent.start.getTime() / 1000);
var start_date = $.datepicker.formatDate("yy-mm-dd", calEvent.start) + " " + calEvent.start.toTimeString().substr(0, 8);
if (calEvent.allDay == 1) {
@ -293,14 +297,21 @@ $(document).ready(function() {
if ($("#content").parent().find('#content_edit').length == 0) {
$("#content").parent().append('<div id="content_edit"></div>');
}
$("#content_edit").html(calEvent.description);
if ($("#comment").parent().find('#comment_edit').length == 0) {
$("#comment").parent().append('<div id="comment_edit"></div>');
}
$("#comment_edit").html(calEvent.comment);
$("#title_edit").show();
$("#content_edit").show();
$("#comment_edit").show();
$("#title").hide();
$("#content").hide();
$("#comment").hide();
allFields.removeClass( "ui-state-error" );
@ -337,7 +348,6 @@ $(document).ready(function() {
calEvent.end = calEvent.end;
calEvent.allDay = calEvent.allDay;
calEvent.description = $("#content").val();
calendar.fullCalendar('updateEvent',
calEvent,
true // make the event "stick"
@ -450,13 +460,14 @@ $(document).ready(function() {
$("#simple_title").html(calEvent.title);
$("#simple_content").html(calEvent.description);
$("#simple_comment").html(calEvent.comment);
$("#simple-dialog-form").dialog("open");
$("#simple-dialog-form").dialog({
buttons: {
'{{"ExportiCalConfidential"|get_lang}}' : function() {
url = "ical_export.php?id=" + calEvent.id+'&course_id='+calEvent.course_id+"&class=confidential";
window.location.href = url;
},
'{{"ExportiCalPrivate"|get_lang}}': function() {
url = "ical_export.php?id=" + calEvent.id+'&course_id='+calEvent.course_id+"&class=private";
@ -528,6 +539,17 @@ $(document).ready(function() {
<div id="simple_content"></div>
</div>
</div>
{% if allow_agenda_event_comment %}
<div class="control-group">
<label class="control-label">
<b>{{ "Comment" |get_lang}}</b>
</label>
<div class="controls">
<div id="simple_comment"></div>
</div>
</div>
{% endif %}
</form>
</div>
</div>
@ -538,6 +560,6 @@ $(document).ready(function() {
</div>
</div>
<div id="loading" style="margin-left:150px;position:absolute;display:none">
{{ "Loading"|get_lang }}...
{{ "Loading" | get_lang }}...
</div>
<div id="calendar"></div>

Loading…
Cancel
Save