Add session filter see #7756

1.10.x
Julio Montoya 11 years ago
parent 63283be06e
commit 63266a1ffa
  1. 5
      main/calendar/agenda_js.php
  2. 5
      main/inc/ajax/agenda.ajax.php
  3. 81
      main/inc/lib/agenda.lib.php
  4. 40
      main/inc/lib/formvalidator/FormValidator.class.php
  5. 39
      main/inc/lib/pear/HTML/QuickForm/reset.php
  6. 12
      main/template/default/agenda/month.tpl

@ -194,6 +194,11 @@ if (!empty($userId)) {
} else {
$agenda_ajax_url = api_get_path(WEB_AJAX_PATH).'agenda.ajax.php?type='.$type;
}
if (isset($_GET['session_id'])) {
$agenda_ajax_url .= '&session_id='.intval($_GET['session_id']);
}
$tpl->assign('web_agenda_ajax_url', $agenda_ajax_url);
$course_code = api_get_course_id();

@ -94,6 +94,7 @@ switch ($action) {
break;
case 'get_events':
$filter = isset($_REQUEST['user_id']) ? $_REQUEST['user_id'] : null;
$sessionId = isset($_REQUEST['session_id']) ? $_REQUEST['session_id'] : null;
$result = $agenda->parseAgendaFilter($filter);
$groupId = current($result['groups']);
$userId = current($result['users']);
@ -101,6 +102,10 @@ switch ($action) {
$start = isset($_REQUEST['start']) ? api_strtotime($_REQUEST['start']) : null;
$end = isset($_REQUEST['end']) ? api_strtotime($_REQUEST['end']) : null;
if ($type == 'personal' && !empty($sessionId)) {
$agenda->setSessionId($sessionId);
}
$events = $agenda->getEvents(
$start,
$end,

@ -905,11 +905,19 @@ class Agenda
break;
case 'personal':
default:
// Getting personal events
$this->getPersonalEvents($start, $end);
$sessionFilterActive = false;
// Getting platform/admin events
$this->getPlatformEvents($start, $end);
if (!empty($this->sessionId)) {
$sessionFilterActive = true;
}
if ($sessionFilterActive == false) {
// Getting personal events
$this->getPersonalEvents($start, $end);
// Getting platform/admin events
$this->getPlatformEvents($start, $end);
}
// Getting course events
$my_course_list = array();
@ -944,19 +952,18 @@ class Agenda
$session_list[] = $sessionInfo;
}
}
//var_dump($session_list);
/*$courseList = SessionManager::getAllCoursesFollowedByUser(
api_get_user_id(),
null
);
var_dump($courseList);*/
}
}
if (!empty($session_list)) {
foreach ($session_list as $session_item) {
if ($sessionFilterActive) {
if ($this->sessionId != $session_item['session_id']) {
continue;
}
}
$my_courses = $session_item['courses'];
$my_session_id = $session_item['session_id'];
if (!empty($my_courses)) {
@ -968,7 +975,7 @@ class Agenda
}
}
if (!empty($my_course_list)) {
if (!empty($my_course_list) && $sessionFilterActive == false) {
foreach ($my_course_list as $course_info_item) {
if (isset($course_id) && !empty($course_id)) {
if ($course_info_item['real_id'] == $course_id) {
@ -979,6 +986,7 @@ class Agenda
}
}
}
break;
}
@ -2291,8 +2299,8 @@ class Agenda
$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
if (api_is_allowed_to_edit(false, true) ||
(api_get_course_setting('allow_user_edit_agenda') && !api_is_anonymous()) && api_is_allowed_to_session_edit(false, true) ||
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())
) {
@ -2324,6 +2332,49 @@ class Agenda
}
}
}
if (api_is_platform_admin() ||
api_is_teacher() ||
api_is_student_boss() ||
api_is_drh() ||
api_is_session_admin() ||
api_is_coach()
) {
if ($this->type == 'personal') {
$form = null;
if (!isset($_GET['action'])) {
$form = new FormValidator(
'form-search',
'get',
api_get_self().'?type=personal&',
'',
array(),
FormValidator::LAYOUT_INLINE
);
$sessions = SessionManager::get_sessions_by_user(api_get_user_id());
$form->addHidden('type', 'personal');
$sessions = array_column($sessions, 'session_name', 'session_id');
$sessions = ['0' => get_lang('SelectAnOption')] + $sessions;
$form->addSelect(
'session_id',
get_lang('Session'),
$sessions,
['id' => 'session_id']
);
$form->addButtonFilter(get_lang('Filter'));
$form->addButtonReset(get_lang('Reset'));
$form = $form->returnForm();
}
if ($view == 'calendar') {
$actions .= $form;
}
}
}
return $actions;
}

@ -494,6 +494,46 @@ EOT;
);
}
/**
* Shortcut to reset button
* @param string $label Text appearing on the button
* @param string $name Element name (for form treatment purposes)
* @param bool $createElement Whether to use the create or add method
* @return HTML_QuickForm_button
*/
public function addButtonReset($label, $name = 'reset', $createElement = false)
{
$icon = 'eraser';
$style = 'default';
$size = 'default';
$class = null;
$attributes = array();
if ($createElement) {
return $this->createElement(
'reset',
$name,
$label,
$icon,
$style,
$size,
$class,
$attributes
);
}
return $this->addElement(
'reset',
$name,
$label,
$icon,
$style,
$size,
$class,
$attributes
);
}
/**
* Returns a button with the primary color and an upload icon
* @param string $label Text appearing on the button

@ -1,38 +1,6 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* HTML class for a reset type element
*
* PHP versions 4 and 5
*
* LICENSE: This source file is subject to version 3.01 of the PHP license
* that is available through the world-wide-web at the following URI:
* http://www.php.net/license/3_01.txt If you did not receive a copy of
* the PHP License and are unable to obtain it through the web, please
* send a note to license@php.net so we can mail you a copy immediately.
*
* @category HTML
* @package HTML_QuickForm
* @author Adam Daniel <adaniel1@eesus.jnj.com>
* @author Bertrand Mansion <bmansion@mamasam.com>
* @copyright 2001-2009 The PHP Group
* @license http://www.php.net/license/3_01.txt PHP License 3.01
* @version CVS: $Id: reset.php,v 1.6 2009/04/04 21:34:04 avb Exp $
* @link http://pear.php.net/package/HTML_QuickForm
*/
/**
* HTML class for a reset type element
*
* @category HTML
* @package HTML_QuickForm
* @author Adam Daniel <adaniel1@eesus.jnj.com>
* @author Bertrand Mansion <bmansion@mamasam.com>
* @version Release: 3.2.11
* @since 1.0
*/
class HTML_QuickForm_reset extends HTML_QuickForm_input
class HTML_QuickForm_reset extends HTML_QuickForm_button
{
// {{{ constructor
@ -47,7 +15,7 @@ class HTML_QuickForm_reset extends HTML_QuickForm_input
* @access public
* @return void
*/
function HTML_QuickForm_reset($elementName=null, $value=null, $attributes=null)
public function __construct($elementName=null, $value=null, $attributes=null)
{
parent::__construct($elementName, null, $attributes);
$this->setValue($value);
@ -70,5 +38,4 @@ class HTML_QuickForm_reset extends HTML_QuickForm_input
// }}}
} //end class HTML_QuickForm_reset
?>
}

@ -25,6 +25,11 @@ $(document).ready(function() {
var m = date.getMonth()+1;
var y = date.getFullYear();
// Reset button.
$("button[type=reset]").click(function() {
$("#session_id").find('option').removeAttr("selected");
});
$("#dialog-form").dialog({
autoOpen: false,
modal : false,
@ -337,10 +342,9 @@ $(document).ready(function() {
window.location.href = url;
$("#dialog-form").dialog( "close" );
},
'{{ "Delete"|get_lang }}': function() {
if (calEvent.parent_event_id || calEvent.has_children != '' ) {
if (calEvent.parent_event_id || calEvent.has_children != '') {
var newDiv = $(document.createElement('div'));
newDiv.dialog({
@ -425,8 +429,8 @@ $(document).ready(function() {
}
});
} else {
//Simple form
//my_start_month = calEvent.start.getMonth() +1;
// Simple form
// my_start_month = calEvent.start.getMonth() +1;
$('#simple_start_date').html(calEvent.start.format("YY-MM-DD"));
if (end_date != '') {

Loading…
Cancel
Save