Fixing agenda CRUD see BT#7803

1.9.x
Julio Montoya 11 years ago
parent 72dbfdcd3c
commit 7b42bfe403
  1. 1
      main/calendar/agenda.inc.php
  2. 222
      main/calendar/agenda.lib.php
  3. 12
      main/calendar/agenda.php
  4. 72
      main/calendar/agenda_js.php
  5. 14
      main/css/base.css
  6. BIN
      main/img/icons/32/week.png
  7. 14
      main/inc/ajax/agenda.ajax.php
  8. 13
      main/inc/lib/formvalidator/FormValidator.class.php
  9. 112
      main/template/default/agenda/month.tpl

@ -1969,6 +1969,7 @@ function get_attachment($agenda_id, $course_id = null)
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
* @param integer id, the id of the agenda item we are editing. By default this is empty which means that we are adding an
* agenda item.
* @deprecated
*/
function show_add_form($id = '', $type = null)
{

@ -273,7 +273,7 @@ class Agenda
/**
* @param int $eventId
* @param string $type
* @param string $end date time
* @param string $end in local time
* @param array $sentTo
*
* @return bool
@ -282,10 +282,15 @@ class Agenda
{
$t_agenda = Database::get_course_table(TABLE_AGENDA);
$t_agenda_r = Database::get_course_table(TABLE_AGENDA_REPEAT);
if (empty($this->course)) {
return false;
}
$course_id = $this->course['real_id'];
$eventId = intval($eventId);
$sql = "SELECT title, content, start_date as sd, end_date as ed, all_day
$sql = "SELECT title, content, start_date, end_date, all_day
FROM $t_agenda
WHERE c_id = $course_id AND id = $eventId";
$res = Database::query($sql);
@ -295,13 +300,14 @@ class Agenda
}
$row = Database::fetch_array($res);
$orig_start = api_strtotime($row['sd']);
$orig_end = api_strtotime($row['ed']);
$origStartDate = api_strtotime($row['start_date'], 'UTC');
$origEndDate = api_strtotime($row['end_date'], 'UTC');
$diff = $origEndDate - $origStartDate;
$diff = $orig_end - $orig_start;
$title = $row['title'];
$content = $row['content'];
$allDay = $row['all_day'];
$now = time();
$type = Database::escape_string($type);
$end = api_strtotime($end);
@ -311,13 +317,13 @@ class Agenda
//and that he wants us to calculate the end date with that (particularly in case of imports from ical)
switch ($type) {
case 'daily':
$end = $orig_start + (86400 * $end);
$end = $origStartDate + (86400 * $end);
break;
case 'weekly':
$end = $this->addWeek($orig_start, $end);
$end = $this->addWeek($origStartDate, $end);
break;
case 'monthlyByDate':
$end = $this->addMonth($orig_start, $end);
$end = $this->addMonth($origStartDate, $end);
break;
case 'monthlyByDay':
//TODO
@ -326,7 +332,7 @@ class Agenda
//TODO
break;
case 'yearly':
$end = $this->addYear($orig_start, $end);
$end = $this->addYear($origStartDate, $end);
break;
}
}
@ -341,7 +347,7 @@ class Agenda
switch ($type) {
// @todo improve loop.
case 'daily':
for ($i = $orig_start + 86400; $i <= $end; $i += 86400) {
for ($i = $origStartDate + 86400; $i <= $end; $i += 86400) {
$start = date('Y-m-d H:i:s', $i);
$repeatEnd = date('Y-m-d H:i:s', $i + $diff);
$this->add_event(
@ -357,7 +363,7 @@ class Agenda
}
break;
case 'weekly':
for ($i = $orig_start + 604800; $i <= $end; $i += 604800) {
for ($i = $origStartDate + 604800; $i <= $end; $i += 604800) {
$start = date('Y-m-d H:i:s', $i);
$repeatEnd = date('Y-m-d H:i:s', $i + $diff);
$this->add_event(
@ -373,7 +379,7 @@ class Agenda
}
break;
case 'monthlyByDate':
$next_start = $this->addMonth($orig_start);
$next_start = $this->addMonth($origStartDate);
while ($next_start <= $end) {
$start = date('Y-m-d H:i:s', $next_start);
$repeatEnd = date('Y-m-d H:i:s', $next_start + $diff);
@ -397,7 +403,7 @@ class Agenda
//not yet implemented
break;
case 'yearly':
$next_start = $this->addYear($orig_start);
$next_start = $this->addYear($origStartDate);
while ($next_start <= $end) {
$start = date('Y-m-d H:i:s', $next_start);
$repeatEnd = date('Y-m-d H:i:s', $next_start + $diff);
@ -416,6 +422,7 @@ class Agenda
break;
}
}
return true;
}
@ -482,7 +489,6 @@ class Agenda
$title,
$content,
$usersToSend = array(),
$editRepeatType = 1,
$attachmentArray = array(),
$attachmentComment = null
) {
@ -681,9 +687,6 @@ class Agenda
$this->store_agenda_item_as_announcement($id);
}*/
// Repeat
//$editRepeatType = null;
// Add attachment.
if (isset($attachmentArray) && !empty($attachmentArray)) {
$this->updateAttachment(
@ -1144,6 +1147,9 @@ class Agenda
$start = isset($start) && !empty($start) ? api_get_utc_datetime(intval($start)) : null;
$end = isset($end) && !empty($end) ? api_get_utc_datetime(intval($end)) : null;
if (empty($courseInfo)) {
return array();
}
$course_id = $courseInfo['real_id'];
if (empty($course_id)) {
return array();
@ -1466,13 +1472,17 @@ class Agenda
* @param FormValidator $form
* @param array $groupList
* @param array $userList
* @param array $sendTo array('users' => [1, 2], 'groups' => [3, 4]
* @param array $sendTo array('users' => [1, 2], 'groups' => [3, 4])
* @param array $attributes
* @param bool $addOnlyItemsInSendTo
*/
public static function construct_not_selected_select_form_validator(
public function setSendToSelect(
$form,
$groupList = null,
$userList = null,
$sendTo = array()
$sendTo = array(),
$attributes = array(),
$addOnlyItemsInSendTo = false
) {
$params = array(
'id' => 'users_to_send_id',
@ -1482,8 +1492,16 @@ class Agenda
'class' => 'chzn-select'
);
if (!empty($attributes)) {
$params = array_merge($params, $attributes);
if (empty($params['multiple'])) {
unset($params['multiple']);
}
}
$sendToGroups = isset($sendTo['groups']) ? $sendTo['groups'] : array();
$sendToUsers = isset($sendTo['users']) ? $sendTo['users'] : array();
/** @var HTML_QuickForm_select $select */
$select = $form->addElement('select', 'users_to_send', get_lang('To'), null, $params);
@ -1507,7 +1525,14 @@ class Agenda
if ($selected) {
$option['selected'] = 'selected';
}
$options[] = $option;
if ($addOnlyItemsInSendTo) {
if ($selected) {
$options[] = $option;
}
} else {
$options[] = $option;
}
}
$select->addOptGroup($options, get_lang('Groups'));
}
@ -1520,11 +1545,18 @@ class Agenda
'text' => api_get_person_name($user['firstname'], $user['lastname']).' ('.$user['username'].')',
'value' => "USER:".$user['user_id']
);
$selected = in_array($user['user_id'], $sendToUsers) ? true : false;
if ($selected) {
$option['selected'] = 'selected';
}
$options[] = $option;
if ($addOnlyItemsInSendTo) {
if ($selected) {
$options[] = $option;
}
} else {
$options[] = $option;
}
}
$select->addOptGroup($options, get_lang('Users'));
}
@ -1582,6 +1614,7 @@ class Agenda
} else {
$url = api_get_self().'?action='.$action.'&id='.$id.'&type='.$this->type;
}
$form = new FormValidator(
'add_event',
'post',
@ -1605,6 +1638,32 @@ class Agenda
$form->addElement('hidden', 'id', $id);
$form->addElement('hidden', 'action', $action);
$form->addElement('hidden', 'id_attach', $idAttach);
$isSubEventEdition = false;
$isParentFromSerie = false;
$showAttachmentForm = true;
if ($this->type == 'course') {
// Edition mode.
if (!empty($id)) {
$showAttachmentForm = false;
if (isset($params['parent_event_id']) && !empty($params['parent_event_id'])) {
$isSubEventEdition = true;
}
if (!empty($params['repeat_info'])) {
$isParentFromSerie = true;
}
}
}
if ($isSubEventEdition) {
$form->addElement(
'label',
null,
Display::return_message(get_lang('EditingThisEventWillRemoveItFromTheSerie'), 'warning')
);
}
$form->addElement('text', 'title', get_lang('ItemTitle'));
if (isset($groupId) && !empty($groupId)) {
@ -1613,43 +1672,33 @@ class Agenda
} else {
$sendTo = isset($params['send_to']) ? $params['send_to'] : null;
if ($this->type == 'course') {
self::show_to_form($form, $sendTo);
$this->showToForm($form, $sendTo);
}
}
//$form->addElement('date_time_picker', 'start_date', get_lang('StartDate'), array('id' => 'start_date_form'));
//$form->addElement('date_time_picker', 'end_date', get_lang('EndDate'), array('id' => 'end_date_form'));
$form->addDateRangePicker('date_range', get_lang('StartDate'), false, array('id' => 'date_range'));
$form->addElement('checkbox', 'all_day', null, get_lang('AllDay'));
$showRepeatWarning = false;
$showAttachmentForm = true;
if ($this->type == 'course') {
$repeat = $form->addElement('checkbox', 'repeat', null, get_lang('RepeatEvent'), array('onclick' => 'return plus_repeated_event();'));
$form->addElement('html', '<div id="options2" style="display:none">');
$form->addElement('select', 'repeat_type', get_lang('RepeatType'), self::getRepeatTypes());
$form->addElement('date_picker', 'repeat_end_day', get_lang('RepeatEnd'), array('id' => 'repeat_end_date_form'));
if (!empty($id)) {
if (isset($params['parent_event_id']) && !empty($params['parent_event_id'])) {
if ($isSubEventEdition || $isParentFromSerie) {
if ($isSubEventEdition) {
$parentEvent = $params['parent_info'];
$repeatInfo = $parentEvent['repeat_info'];
$params['repeat'] = 1;
$params['repeat_type'] = $repeatInfo['cal_type'];
$params['repeat_end_day'] = substr(api_get_local_time($repeatInfo['cal_end']), 0, 10);
/*$group = array(
$form->createElement('radio', 'edit_repeat_type', null, get_lang('EditThisEvent'), 1),
$form->createElement('radio', 'edit_repeat_type', null, get_lang('RemoveThisEventAndCreateANewOne'), 2),
);
$params['edit_repeat_type'] = 1;
$form->addGroup($group);*/
$form->freeze(array('repeat_type', 'repeat_end_day'));
$repeat->_attributes['disabled'] = 'disabled';
$showRepeatWarning = true;
$showAttachmentForm = false;
} else {
$repeatInfo = $params['repeat_info'];
}
$params['repeat'] = 1;
$params['repeat_type'] = $repeatInfo['cal_type'];
$params['repeat_end_day'] = substr(api_get_local_time($repeatInfo['cal_end']), 0, 10);
$form->freeze(array('repeat_type', 'repeat_end_day'));
$repeat->_attributes['disabled'] = 'disabled';
}
$form->addElement('html', '</div>');
@ -1709,13 +1758,6 @@ class Agenda
);
}
if ($showRepeatWarning) {
$form->addElement(
'label',
null,
Display::return_message(get_lang('EditingThisEventWillRemoveItFromTheSerie'))
);
}
$form->addElement('button', 'submit', $button);
$form->setDefaults($params);
@ -1727,10 +1769,16 @@ class Agenda
/**
* @param FormValidator $form
* @param array $sendTo
* @param array $sendTo array('users' => [1, 2], 'groups' => [3, 4])
* @param array $attributes
* @param bool $addOnlyItemsInSendTo
* @return bool
*/
static function show_to_form($form, $sendTo = array())
public function showToForm($form, $sendTo = array(), $attributes = array(), $addOnlyItemsInSendTo = false)
{
if ($this->type != 'course') {
return false;
}
$order = 'lastname';
if (api_is_western_name_order()) {
$order = 'firstname';
@ -1747,12 +1795,16 @@ class Agenda
api_get_session_id()
);
self::construct_not_selected_select_form_validator(
$this->setSendToSelect(
$form,
$groupList,
$userList,
$sendTo
$sendTo,
$attributes,
$addOnlyItemsInSendTo
);
return true;
}
/**
@ -2031,31 +2083,30 @@ class Agenda
*/
public function displayActions($view, $filter = 0)
{
if ($view == 'calendar') {
$actions = "<a href='".api_get_path(WEB_CODE_PATH)."calendar/agenda_list.php?type={$this->type}&".api_get_cidreq()."'>".
Display::return_icon('week.png', get_lang('AgendaList'), '', ICON_SIZE_MEDIUM)."</a>";
} else {
$actions = "<a href='".api_get_path(WEB_CODE_PATH)."calendar/agenda_js.php?type={$this->type}'>".
Display::return_icon('calendar.png', get_lang('Calendar'), '', ICON_SIZE_MEDIUM)."</a>";
}
$actions = "<a href='".api_get_path(WEB_CODE_PATH)."calendar/agenda_js.php?type={$this->type}'>".
Display::return_icon('calendar.png', get_lang('Calendar'), '', ICON_SIZE_MEDIUM)."</a>";
$actions .= "<a href='".api_get_path(WEB_CODE_PATH)."calendar/agenda_list.php?type={$this->type}&".api_get_cidreq()."'>".
Display::return_icon('week.png', get_lang('AgendaList'), '', ICON_SIZE_MEDIUM)."</a>";
if (api_is_allowed_to_edit(false, true) OR
(api_get_course_setting('allow_user_edit_agenda') && !api_is_anonymous()) && api_is_allowed_to_session_edit(false, true) OR
GroupManager::user_has_access(api_get_user_id(), api_get_group_id(), GroupManager::GROUP_TOOL_CALENDAR) &&
GroupManager::is_tutor_of_group(api_get_user_id(), api_get_group_id())
) {
if ($this->type == 'course') {
$form = null;
if (!isset($_GET['action'])) {
$form = show_to($filter, 'select_form_id_search');
/*$actions .= "<a href='".api_get_path(WEB_CODE_PATH)."calendar/agenda_js.php?type=course&".api_get_cidreq()."'>".
Display::return_icon('calendar_na.png', get_lang('Agenda'), '', ICON_SIZE_MEDIUM)."</a>";*/
} else {
/* $actions .= "<a href='".api_get_path(WEB_CODE_PATH)."calendar/agenda_js.php?type=course&".api_get_cidreq()."'>".
Display::return_icon('calendar.png', get_lang('Agenda'), '', ICON_SIZE_MEDIUM)."</a>";*/
}
$form = new FormValidator('form-search');
$attributes = array(
'multiple' => false,
'id' => 'select_form_id_search'
);
$selectedValues = $this->parseAgendaFilter($filter);
$this->showToForm($form, $selectedValues, $attributes);
$form = $form->return_form();
}
$actions .= "<a href='".api_get_path(WEB_CODE_PATH)."calendar/agenda.php?".api_get_cidreq()."&action=add&type=course'>".
Display::return_icon('new_event.png', get_lang('AgendaAdd'), '', ICON_SIZE_MEDIUM)."</a>";
$actions .= "<a href='".api_get_path(WEB_CODE_PATH)."calendar/agenda.php?".api_get_cidreq()."&action=importical&type=course'>".
@ -2195,5 +2246,36 @@ class Agenda
return $messages;
}
/**
* Parse filter turns USER:12 to ['users' => [12])] or G:1 ['groups' => [1]]
* @param $filter
* @return array
*/
public function parseAgendaFilter($filter)
{
$everyone = false;
$groupId = null;
$userId = null;
if ($filter == 'everyone') {
$everyone = true;
} else {
if (substr($filter, 0, 1) == 'G') {
$groupId = str_replace('GROUP:', '', $filter);
} else {
$userId = str_replace('USER:', '', $filter);
}
}
if (empty($userId) && empty($groupId)) {
$everyone = true;
}
return array(
'everyone' => $everyone,
'users' => array($userId),
'groups' => array($groupId)
);
}
}

@ -168,7 +168,7 @@ if (api_is_allowed_to_edit(false, true) OR
$allDay = isset($values['all_day']) ? 'true' : 'false';
$startDate = $values['date_range_start'];
$endDate = $values['date_range_end'];
$repeatType = isset($values['edit_repeat_type']) ? $values['edit_repeat_type'] : null;
//$repeatType = isset($values['edit_repeat_type']) ? $values['edit_repeat_type'] : null;
$sendAttachment = isset($_FILES['user_upload']) ? true : false;
$attachment = $sendAttachment ? $_FILES['user_upload'] : null;
$attachmentComment = isset($values['file_comment']) ? $values['file_comment'] : null;
@ -207,7 +207,6 @@ if (api_is_allowed_to_edit(false, true) OR
$values['title'],
$values['content'],
$values['users_to_send'],
$repeatType,
$attachment,
$attachmentComment
);
@ -232,15 +231,6 @@ if (api_is_allowed_to_edit(false, true) OR
);
}
if (!empty($values['repeat']) && !empty($eventId)) {
$agenda->addRepeatedItem(
$eventId,
$values['repeat_type'],
$values['repeat_end_day'],
$values['users_to_send']
);
}
$message = Display::return_message(get_lang('Updated'), 'confirmation');
Session::write('message', $message);
header("Location: $agendaUrl");

@ -16,6 +16,7 @@ $use_anonymous = true;
// Calendar type
$type = isset($_REQUEST['type']) && in_array($_REQUEST['type'], array('personal', 'course', 'admin', 'platform')) ? $_REQUEST['type'] : 'personal';
$userId = isset($_REQUEST['user_id']) ? $_REQUEST['user_id'] : null;
if ($type == 'personal') {
$cidReset = true; // fixes #5162
@ -144,8 +145,7 @@ $tpl->assign(
Display::return_icon($export_icon_high, get_lang('ExportiCalConfidential'))
);
$filter = null;
$actions = $agenda->displayActions('calendar', $filter);
$actions = $agenda->displayActions('calendar', $userId);
$tpl->assign('actions', $actions);
@ -180,58 +180,44 @@ $tpl->assign('type_event_class', $type_event_class);
// Current user can add event?
$tpl->assign('can_add_events', $can_add_events);
//Setting AJAX caller
if (isset($_GET['user_id'])) {
$user_id = $_GET['user_id'];
$agenda_ajax_url = api_get_path(WEB_AJAX_PATH).'agenda.ajax.php?user_id='.$user_id.'&type='.$type;
// Setting AJAX caller
if (!empty($userId)) {
$agenda_ajax_url = api_get_path(WEB_AJAX_PATH).'agenda.ajax.php?user_id='.$userId.'&type='.$type;
} else {
$agenda_ajax_url = api_get_path(WEB_AJAX_PATH).'agenda.ajax.php?type='.$type;
}
$tpl->assign('web_agenda_ajax_url', $agenda_ajax_url);
$course_code = api_get_course_id();
if ((api_is_allowed_to_edit() || $is_group_tutor) && $course_code != '-1' && $type == 'course') {
$order = 'lastname';
if (api_is_western_name_order()) {
$order = 'firstname';
}
//if ((api_is_allowed_to_edit() || $is_group_tutor) && $course_code != '-1' && $type == 'course') {
if (!empty($group_id)) {
$group_list = array($group_id => $group_properties);
$user_list = GroupManager::get_subscribed_users($group_id);
} else {
$user_list = CourseManager::get_user_list_from_course_code(api_get_course_id(), api_get_session_id(), null, $order);
$group_list = CourseManager::get_group_list_of_course(api_get_course_id(), api_get_session_id());
$form = new FormValidator('form', 'get', null, null, array('id' => 'add_event_form'));
$form->addElement('html', '<div id="visible_to_input">');
$sendTo = $agenda->parseAgendaFilter($userId);
$showAll = false;
if ($sendTo == 'everyone') {
$showAll = true;
}
// This will fill the select called #users_to_send_id.
if (isset($_REQUEST['user_id'])) {
if (in_array($_REQUEST['user_id'], array_keys($user_list))) {
$userInfo = api_get_user_info($_REQUEST['user_id']);
if (!empty($userInfo)) {
$user_list = array($userInfo['user_id'] => $userInfo);
$group_list = array();
}
}
$param = explode(':', $_REQUEST['user_id']);
if (isset($param[1]) && in_array($param[1], array_keys($group_list))) {
$groupInfo = GroupManager::get_group_properties($param[1]);
if ($groupInfo) {
$group_list = array($groupInfo['id'] => $groupInfo);
$user_list = array();
}
}
$agenda->showToForm($form, $sendTo, array(), $showAll);
$form->addElement('html', '</div>');
$form->addElement('html', '<div id="visible_to_read_only" style="display: none">');
$form->addElement('label', get_lang('To'), '<div id="visible_to_read_only_users"></div>');
$form->addElement('html', '</div>');
$form->addElement('label', get_lang('Agenda'), '<div id ="color_calendar"></div>');
$form->addElement('label', get_lang('Date'), '<span id="start_date"></span><span id="end_date"></span>');
$form->addElement('text', 'title', get_lang('Title'), array('id' => 'title'));
$form->addElement('textarea', 'content', get_lang('Description'), array('id' => 'content'));
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>');
}
$select = $agenda->construct_not_selected_select_form(
$group_list,
$user_list,
array()
);
$tpl->assign('visible_to', $select);
}
$tpl->assign('form_add', $form->return_form());
//}
// Loading Agenda template.
$content = $tpl->fetch('default/agenda/month.tpl');

@ -2257,7 +2257,7 @@ div.admin_section h4 {
}
.actions span {
margin-right:0px;
/* margin-right:0px; */
}
#courseintro_empty {
@ -2411,7 +2411,7 @@ div.admin_section h4 {
/* chosen javascript checkbox select width fix */
.chzn-select {
min-width: 173px;
/*min-width: 173px; */
}
.lp_tree {
@ -4766,4 +4766,12 @@ i.size-32.icon-new-work{
.text-h5 {
font-size: 12px;
font-weight: normal;
}
}
.chosen-container {
min-width: 250px;
}
.chzn-container-single .chzn-search {
z-index: 1010;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 658 B

After

Width:  |  Height:  |  Size: 664 B

@ -91,11 +91,11 @@ switch ($action) {
$agenda->move_event($id, $day_delta, $minute_delta);
break;
case 'get_events':
$user_id = isset($_REQUEST['user_id']) ? $_REQUEST['user_id'] : null;
if (substr($user_id, 0, 1) == 'G') {
$length = strlen($user_id);
$group_id = substr($user_id, 2, $length-1);
}
$filter = isset($_REQUEST['user_id']) ? $_REQUEST['user_id'] : null;
$result = $agenda->parseAgendaFilter($filter);
$groupId = current($result['groups']);
$userId = current($result['users']);
$start = isset($_REQUEST['start']) ? $_REQUEST['start'] : null;
$end = isset($_REQUEST['end']) ? $_REQUEST['end'] : null;
@ -103,8 +103,8 @@ switch ($action) {
$start,
$end,
api_get_course_int_id(),
$group_id,
$user_id
$groupId,
$userId
);
echo $events;
break;

@ -255,6 +255,14 @@ EOT;
}
}
/**
* date_range_picker element creates 2 hidden fields
* elementName + "_start" elementName "_end"
* @param string $name
* @param string $label
* @param bool $required
* @param array $attributes
*/
public function addDateRangePicker($name, $label, $required = true, $attributes = array())
{
$this->addElement('date_range_picker', $name, $label, $attributes);
@ -266,7 +274,10 @@ EOT;
}
}
/**
* @param string $name
* @param string $value
*/
function add_hidden($name, $value)
{
$this->addElement('hidden', $name, $value);

@ -2,8 +2,8 @@
function checkLength( o, n, min, max ) {
if ( o.val().length > max || o.val().length < min ) {
o.addClass( "ui-state-error" );
updateTips( "Length of " + n + " must be between " +
min + " and " + max + "." );
/*updateTips( "Length of " + n + " must be between " +
min + " and " + max + "." );*/
return false;
} else {
return true;
@ -11,10 +11,11 @@ function checkLength( o, n, min, max ) {
}
function clean_user_select() {
//Cleans the selected attr
$('#users_to_send_id')
$("#users_to_send_id").val('').trigger("chosen:updated");
/*$('#users_to_send_id')
.find('option')
.removeAttr('selected')
.end();
.end();*/
}
var region_value = '{{ region_value }}';
@ -67,7 +68,7 @@ $(document).ready(function() {
deleted_items = true;
}*/
$("#users_to_send_id").trigger("liszt:updated");
//$("#users_to_send_id").trigger("chosen:updated");
/*
if (selected_counts >= 1) {
$('#users_to_send_id option').eq(0).removeAttr('selected');
@ -133,14 +134,14 @@ $(document).ready(function() {
$('#add_as_announcement_div').show();
$('#visible_to_read_only').hide();
//Cleans the selected attr
// Cleans the selected attr
clean_user_select();
//Sets the 1st item selected by default
//$('#users_to_send_id option').eq(0).attr('selected', 'selected');
//Update chz-select
$("#users_to_send_id").trigger("liszt:updated");
// Update chz-select
//$("#users_to_send_id").trigger("chosen:updated");
if ({{ can_add_events }} == 1) {
var url = '{{ web_agenda_ajax_url }}&a=add_event&start='+start_date+'&end='+end_date+'&all_day='+allDay+'&view='+view.name;
@ -172,7 +173,7 @@ $(document).ready(function() {
buttons: {
'{{ "Add" | get_lang }}' : function() {
var bValid = true;
bValid = bValid && checkLength( title, "title", 1, 255 );
bValid = bValid && checkLength(title, "title", 1, 255);
//bValid = bValid && checkLength( content, "content", 1, 255 );
var params = $("#add_event_form").serialize();
@ -266,7 +267,7 @@ $(document).ready(function() {
}
}
//Edit event
// Edit event.
if (calEvent.editable) {
$('#visible_to_input').hide();
@ -274,6 +275,7 @@ $(document).ready(function() {
{% if type != 'admin' %}
$('#visible_to_read_only').show();
console.log(calEvent.sent_to);
$("#visible_to_read_only_users").html(calEvent.sent_to);
{% endif %}
@ -296,7 +298,17 @@ $(document).ready(function() {
/*$("#title").attr('value', calEvent.title);
$("#content").attr('value', calEvent.description);*/
if ($("#title").parent().find('#title_edit').length == 0) {
$("#title").parent().append('<div id="title_edit"></div>');
}
$("#title_edit").html(calEvent.title);
if ($("#content").parent().find('#content_edit').length == 0) {
$("#content").parent().append('<div id="content_edit"></div>');
}
$("#content_edit").html(calEvent.description);
$("#title_edit").show();
@ -500,26 +512,33 @@ $(document).ready(function() {
});
});
</script>
{{ actions_div }}
{{ actions_div }}
<div id="simple-dialog-form" style="display:none;">
<div style="width:500px">
<form name="form-simple" class="form-vertical" >
<div style="width:500px">d sqd qs
<form name="form-simple" class="form-vertical">
<div class="control-group">
<label class="control-label"><b>{{ "Date" |get_lang}}</b></label>
<label class="control-label">
<b>{{ "Date" |get_lang}}</b>
</label>
<div class="controls">
<span id="simple_start_date"></span><span id="simple_end_date"></span>
<span id="simple_start_date"></span>
<span id="simple_end_date"></span>
</div>
</div>
<div class="control-group">
<label class="control-label"><b>{{ "Title" |get_lang}}</b></label>
<label class="control-label">
<b>{{ "Title" |get_lang}}</b>
</label>
<div class="controls">
<div id="simple_title"></div>
</div>
</div>
<div class="control-group">
<label class="control-label"><b>{{ "Description" |get_lang}}</b></label>
<label class="control-label">
<b>{{ "Description" |get_lang}}</b>
</label>
<div class="controls">
<div id="simple_content"></div>
</div>
@ -530,64 +549,7 @@ $(document).ready(function() {
<div id="dialog-form" style="display:none;">
<div style="width:500px">
<form class="form-horizontal" id="add_event_form" name="form">
{% if visible_to is not null %}
<div id="visible_to_input" class="control-group">
<label class="control-label">{{ "To"|get_lang }}</label>
<div class="controls">
{{ visible_to }}
</div>
</div>
{% endif %}
<div id="visible_to_read_only" class="control-group" style="display:none">
<label class="control-label">{{ "To"|get_lang }}</label>
<div class="controls">
<div id="visible_to_read_only_users"></div>
</div>
</div>
<div class="control-group">
<label class="control-label">{{ "Agenda"|get_lang }}</label>
<div class="controls">
<div id="color_calendar"></div>
</div>
</div>
<div class="control-group">
<label class="control-label" for="end_date">{{"Date"|get_lang}}</label>
<div class="controls">
<span id="start_date"></span><span id="end_date"></span>
</div>
</div>
<div class="control-group">
<label class="control-label" for="title">{{ "Title"|get_lang }}</label>
<div class="controls">
<input type="text" name="title" id="title" size="40" />
<span id="title_edit"></span>
</div>
</div>
<div class="control-group">
<label class="control-label" for="content">{{ "Description"|get_lang }}</label>
<div class="controls">
<textarea name="content" id="content" class="span3" rows="5"></textarea>
<span id="content_edit"></span>
</div>
</div>
{% if type == 'course' %}
<div id="add_as_announcement_div">
<div class="control-group">
<label></label>
<div class="controls">
<label class="checkbox inline" for="add_as_annonuncement">
{{ "AddAsAnnouncement"|get_lang }} ({{ "SendEmail" | get_lang }})
<input type="checkbox" name="add_as_annonuncement" id="add_as_annonuncement" />
</label>
</div>
</div>
</div>
{% endif %}
</form>
{{ form_add }}
</div>
</div>
<div id="loading" style="margin-left:150px;position:absolute;display:none">

Loading…
Cancel
Save