Skip to content

Commit

Permalink
Merge branch 'danbarretodev-CT7381' into 1.9.x
Browse files Browse the repository at this point in the history
  • Loading branch information
ywarnier committed Nov 17, 2014
2 parents a90a752 + 987474d commit 8eab6cb
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
27 changes: 24 additions & 3 deletions main/calendar/agenda_list.php
Expand Up @@ -31,19 +31,40 @@
null,
'array'
);
$url = api_get_path(WEB_CODE_PATH).'calendar/agenda_list.php?'.api_get_cidreq();
$tpl->assign('url', $url);
if (!empty($GLOBALS['_cid']) && $GLOBALS['_cid'] != -1) {
// Agenda is inside a course tool
$url = api_get_self() . '?' . api_get_cidreq();

} else {
// Agenda is out of the course tool (e.g personal agenda)
$url = false;
foreach ($events as &$event) {
$event['url'] = api_get_self() . '?course_id=' . $event['course_id'];
}
}

$tpl->assign('agenda_events', $events);

$actions = $agenda->displayActions('list');
$tpl->assign('url', $url);
$tpl->assign('actions', $actions);
$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();
if (empty($courseInfo)) {
// This happens when list agenda is not inside a course
if (
isset($_GET['course_id']) &&
intval($_GET['course_id']) !== 0
) {
// Just needs course ID
$courseInfo = array('real_id' => intval($_GET['course_id']));
}
}
$agenda->changeVisibility($_GET['id'], $_GET['visibility'], $courseInfo);
header('Location: '.$url);
header('Location: '. api_get_self());
exit;
}
}
Expand Down
4 changes: 2 additions & 2 deletions main/template/default/agenda/event_list.tpl
Expand Up @@ -36,11 +36,11 @@
{% if is_allowed_to_edit %}
<td>
{% if event.visibility == 1 %}
<a class="btn" href="{{ url }}&action=change_visibility&visibility=0&id={{ event.real_id }}">
<a class="btn" href="{% if url %}{{ url }}{% else %}{{ event.url }}{% endif %}&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 }}">
<a class="btn" href="{% if url %}{{ url }}{% else %}{{ event.url }}{% endif %}&action=change_visibility&visibility=1&id={{ event.real_id }}">
<img title="{{ 'Visible' }}" src="{{'invisible.png'|icon(32)}} ">
</a>
{% endif %}
Expand Down

0 comments on commit 8eab6cb

Please sign in to comment.