Adding agenda event list see BT#6734

1.9.x
Julio Montoya 12 years ago
parent d05fb11e42
commit b00b6da013
  1. 8
      main/calendar/agenda.inc.php
  2. 45
      main/calendar/agenda.lib.php
  3. 5
      main/calendar/agenda_js.php
  4. 17
      main/calendar/agenda_list.php
  5. 1
      main/inc/lib/main_api.lib.php
  6. 31
      main/template/default/agenda/event_list.tpl

@ -1549,11 +1549,7 @@ function change_visibility($tool, $id, $visibility)
$TABLE_ITEM_PROPERTY = Database::get_course_table(TABLE_ITEM_PROPERTY);
$tool = Database::escape_string($tool);
$id = Database::escape_string($id);
/*
$sql="SELECT * FROM $TABLE_ITEM_PROPERTY WHERE tool='".TOOL_CALENDAR_EVENT."' AND ref='$id'";
$result=Database::query($sql) or die (Database::error());
$row=Database::fetch_array($result);
*/
if ($visibility == 0) {
$sql_visibility = "UPDATE $TABLE_ITEM_PROPERTY SET visibility='0' WHERE tool='$tool' AND ref='$id'";
api_item_property_update($_course, TOOL_CALENDAR_EVENT, $id, "invisible", api_get_user_id());
@ -1584,8 +1580,6 @@ function display_courseadmin_links($filter = 0)
$actions = "<a href='agenda_js.php?type=course&".api_get_cidreq()."'>".Display::return_icon('calendar.png', get_lang('Agenda'), '', ICON_SIZE_MEDIUM)."</a>";
}
// $actions .= "<a href='agenda_list.php?type=course&".api_get_cidreq()."'>".Display::return_icon('list.png', get_lang('Agenda'), '', ICON_SIZE_MEDIUM)."</a>";
$actions .= "<a href='agenda.php?".api_get_cidreq()."&amp;sort=asc&amp;toolgroup=".api_get_group_id()."&action=add'>".Display::return_icon('new_event.png', get_lang('AgendaAdd'), '', ICON_SIZE_MEDIUM)."</a>";
$actions .= "<a href='agenda.php?".api_get_cidreq()."&action=importical'>".Display::return_icon('import_calendar.png', get_lang('ICalFileImport'), '', ICON_SIZE_MEDIUM)."</a>";
$actions .= $form;

@ -9,6 +9,9 @@ class Agenda
public $events = array();
public $type = 'personal'; // personal, admin or course
/**
*
*/
public function __construct()
{
//Table definitions
@ -556,22 +559,23 @@ class Agenda
GROUP BY id";
} else {
$visibilityCondition = "ip.visibility='1' AND";
if (api_is_allowed_to_edit()) {
if ($user_id == 0) {
$where_condition = "";
} else {
$where_condition = "( ip.to_user_id=".$user_id. ") AND ";
}
$visibilityCondition = " (ip.visibility IN ('1', '0')) AND ";
} else {
$where_condition = "( ip.to_user_id=$user_id OR ip.to_group_id='0') AND ";
}
$sql = "SELECT DISTINCT agenda.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.ref, to_user_id
FROM ".$tlb_course_agenda." agenda, ".$tbl_property." ip
WHERE agenda.id = ip.ref AND
ip.tool='".TOOL_CALENDAR_EVENT."' AND
$where_condition
ip.visibility='1' AND
$visibilityCondition
agenda.c_id = $course_id AND
ip.c_id = $course_id AND
agenda.session_id = $session_id AND
@ -659,13 +663,12 @@ class Agenda
}
$event['sent_to'] = '';
//$event['type'] = $this->type;
$event['type'] = 'course';
if ($row['session_id'] != 0) {
$event['type'] = 'session';
}
//Event Sent to a group?
// Event Sent to a group?
if (isset($row['to_group_id']) && !empty($row['to_group_id'])) {
$sent_to = array();
if (!empty($group_to_array)) {
@ -685,7 +688,7 @@ class Agenda
if (!empty($user_to_array)) {
foreach ($user_to_array as $item) {
$user_info = api_get_user_info($item);
// add username as tooltip for $event['sent_to'] - ref #4226
// Add username as tooltip for $event['sent_to'] - ref #4226
$username = api_htmlentities(sprintf(get_lang('LoginX'), $user_info['username']), ENT_QUOTES);
$sent_to[] = "<span title='".$username."'>".$user_info['complete_name']."</span>";
}
@ -701,6 +704,8 @@ class Agenda
}
$event['description'] = $row['content'];
$event['visibility'] = $row['visibility'];
$event['real_id'] = $row['id'];
$event['allDay'] = isset($row['all_day']) && $row['all_day'] == 1 ? $row['all_day'] : 0;
$this->events[] = $event;
@ -764,7 +769,9 @@ class Agenda
/**
* Format needed for the Fullcalendar js lib
* @param string UTC time
*
* @param string $utc_time
* @return bool|string
*/
function format_event_date($utc_time)
{
@ -968,6 +975,10 @@ class Agenda
$form->display();
}
/**
* @param FormValidator $form
* @param $to_already_selected
*/
static function show_to_form($form, $to_already_selected)
{
$order = 'lastname';
@ -979,4 +990,26 @@ class Agenda
self::construct_not_selected_select_form_validator($form, $group_list, $user_list, $to_already_selected);
}
/**
* @param int $id
* @param int $visibility 0= invisible, 1 visible
* @param array $courseInfo
* @param int $userId
*/
public static function changeVisibility($id, $visibility, $courseInfo, $userId = null)
{
$id = Database::escape_string($id);
if (empty($userId)) {
$userId = api_get_user_id();
} else {
$userId = intval($userId);
}
if ($visibility == 0) {
api_item_property_update($courseInfo, TOOL_CALENDAR_EVENT, $id, "invisible", $userId);
} else {
api_item_property_update($courseInfo, TOOL_CALENDAR_EVENT, $id, "visible", $userId);
}
}
}

@ -144,9 +144,12 @@ if (api_is_allowed_to_edit(false, true) OR
}
$actions = display_courseadmin_links($filter);
}
$tpl->assign('actions', $actions);
} else {
$actions = "<a href='agenda_list.php?type=course&".api_get_cidreq()."'>".Display::return_icon('week.png', get_lang('Agenda'), '', ICON_SIZE_MEDIUM)."</a>";
}
$tpl->assign('actions', $actions);
//Calendar Type : course, admin, personal
$tpl->assign('type', $type);

@ -13,12 +13,27 @@ require_once '../inc/global.inc.php';
require_once 'agenda.lib.php';
require_once 'agenda.inc.php';
$tpl = new Template(get_lang('Agenda'));
$interbreadcrumb[] = array("url" => api_get_path(WEB_CODE_PATH)."calendar/agenda_js.php?".api_get_cidreq(), "name" => get_lang('Agenda'));
$tpl = new Template(get_lang('Events'));
$agenda = new Agenda();
$agenda->type = 'course'; //course,admin or personal
$events = $agenda->get_events(null, null, api_get_course_int_id(), api_get_group_id(), null, 'array');
$url = api_get_path(WEB_CODE_PATH).'calendar/agenda_list.php?'.api_get_cidreq();
$tpl->assign('url', $url);
$tpl->assign('agenda_events', $events);
$tpl->assign('is_allowed_to_edit', api_is_allowed_to_edit());
if (api_is_allowed_to_edit()) {
if (isset($_GET['action']) && $_GET['action'] == 'change_visibility') {
$courseInfo = api_get_course_info();
$agenda->changeVisibility($_GET['id'], $_GET['visibility'], $courseInfo);
header('Location: '.$url);
exit;
}
}
// Loading Agenda template
$content = $tpl->fetch('default/agenda/event_list.tpl');

@ -3134,7 +3134,6 @@ function api_item_property_update($_course, $tool, $item_id, $lastedit_type, $us
// Update if possible
$set_type = '';
switch ($lastedit_type) {
case 'delete' : // delete = make item only visible for the platform admin.
$visibility = '2';

@ -9,25 +9,44 @@
<th>
{{ 'Title' | get_lang }}
</th>
{% if is_allowed_to_edit %}
<th>
{{ 'Actions' | get_lang }}
</th>
{% endif %}
</tr>
{% for event in agenda_events %}
<tr>
<td>
{{ event.start }}
<td style="width:20%">
{{ event.start |date("m/d/Y h:i:s") }}
</td>
<td>
<td style="width:20%">
{% if event.allDay %}
{{ 'AllDay' | get_lang }}
{% else %}
{{ event.start }} - {{ event.end }}
{{ event.end |date("m/d/Y h:i:s") }}
{% endif %}
</td>
<td>
<td style="width:50%">
{{ event.title }}
<p>{{ event.description}}</p>
{{ event.className }}
</td>
{% if is_allowed_to_edit %}
<td>
{% if event.visibility == 1 %}
<a class="btn" href="{{ url }}&action=change_visibility&visibility=0&id={{ event.real_id }}">
<img title="{{ 'Invisible' }}" src="{{'visible.png'|icon(32)}} ">
</a>
{% else %}
<a class="btn" href="{{ url }}&action=change_visibility&visibility=1&id={{ event.real_id }}">
<img title="{{ 'Visible' }}" src="{{'invisible.png'|icon(32)}} ">
</a>
{% endif %}
</td>
{% endif %}
</tr>
{% endfor %}
</table>

Loading…
Cancel
Save