diff --git a/main/calendar/agenda.lib.php b/main/calendar/agenda.lib.php index e6e9fcb82f..2c87f5f0a8 100755 --- a/main/calendar/agenda.lib.php +++ b/main/calendar/agenda.lib.php @@ -6,7 +6,6 @@ * * @author: Julio Montoya */ - class Agenda { public $events = array(); @@ -19,7 +18,7 @@ class Agenda public $course; /** - * + * Constructor */ public function __construct() { @@ -2347,7 +2346,7 @@ class Agenda $messages = implode('
', $messages); } else { $messages = get_lang('NoAgendaItems'); - + } return $messages; diff --git a/main/calendar/allagendas.php b/main/calendar/allagendas.php index fc88db328c..7f9368065f 100755 --- a/main/calendar/allagendas.php +++ b/main/calendar/allagendas.php @@ -2,12 +2,12 @@ /* For licensing terms, see /license.txt */ /** - * + * * Get the all events by session/course - * @author Julio Montoya cleaning code, chamilo code style changes, all agenda feature work with courses and sessions, only admins and rrhh users can see this page - * - * - * @author Carlos Brolo First code submittion + * @author Julio Montoya cleaning code, chamilo code style changes, + * all agenda feature work with courses and sessions, + * only admins and rrhh users can see this page + * @author Carlos Brolo First code submittion */ // name of the language file that needs to be included @@ -56,7 +56,7 @@ if (!empty ($course_path)) { // showing the header Display::display_header(get_lang('MyAgenda')); -function display_mymonthcalendar_2($agendaitems, $month, $year, $weekdaynames=array(), $monthName, $session_id) { +function display_mymonthcalendar_2($agendaitems, $month, $year, $weekdaynames=array(), $monthName, $session_id) { global $DaysShort, $course_path; //Handle leap year $numberofdays = array (0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); @@ -108,22 +108,22 @@ function display_mymonthcalendar_2($agendaitems, $month, $year, $weekdaynames=ar echo "\n"; } -function get_agenda_items_by_course_list($course_list, $month, $year, $session_id = 0) { +function get_agenda_items_by_course_list($course_list, $month, $year, $session_id = 0) { global $setting_agenda_link; //echo $sql = 'SELECT name FROM chamilo_main.class WHERE name = "'.$grado.'" ORDER BY name ASC'; //$result = Database::query($sql); //while ($row = Database::fetch_array($result, 'ASSOC')) { - - $agendaitems = array (); + + $agendaitems = array (); $course_name_list = array(); foreach ($course_list as $course) { - + $db_name = $course['db_name']; $code = $course['code']; $title = $course['title']; - $course_name_list[] = $title; + $course_name_list[] = $title; //$sql2 = 'SELECT code, db_name, title FROM chamilo_main.course WHERE category_code = "'.$course_name.'" '; -// $courses_dbs = Database::query($sql2); +// $courses_dbs = Database::query($sql2); $items = array (); // $courses_dbs = array(); @@ -132,8 +132,8 @@ function get_agenda_items_by_course_list($course_list, $month, $year, $session_i //$db_name = $row2['db_name']; //$code = $row2['code']; //$title = $row2['title']; - //echo "

".$db_name."

"; - + //echo "

".$db_name."

"; + //databases of the courses $TABLEAGENDA = Database :: get_course_table(TABLE_AGENDA, $db_name); $TABLE_ITEMPROPERTY = Database :: get_course_table(TABLE_ITEM_PROPERTY, $db_name); @@ -143,9 +143,9 @@ function get_agenda_items_by_course_list($course_list, $month, $year, $session_i $session_condition = ''; if ($session_id != 0) { $session_id = intval($session_id); - $session_condition = "AND session_id = $session_id"; + $session_condition = "AND session_id = $session_id"; } - + $sqlquery = "SELECT DISTINCT agenda.*, item_property.* FROM ".$TABLEAGENDA." agenda, ".$TABLE_ITEMPROPERTY." item_property @@ -155,11 +155,11 @@ function get_agenda_items_by_course_list($course_list, $month, $year, $session_i AND item_property.tool='".TOOL_CALENDAR_EVENT."' AND item_property.visibility='1' $session_condition GROUP BY agenda.id - ORDER BY start_date "; + ORDER BY start_date "; $result = Database::query($sqlquery); while ($item = Database::fetch_array($result,'ASSOC')) { //taking the day - $agendaday = date("j",strtotime($item['start_date'])); + $agendaday = date("j",strtotime($item['start_date'])); if(!isset($items[$agendaday])){$items[$agendaday]=array();} //taking the time $time = date("H:i",strtotime($item['start_date'])); @@ -174,12 +174,12 @@ function get_agenda_items_by_course_list($course_list, $month, $year, $session_i if(!isset($items[$agendaday][$item['start_date']])) { $items[$agendaday][$item['start_date']] = ''; } - + $items[$agendaday][$item['start_date']] .= "".get_lang('StartTimeWindow')." ".$time.""." - ".get_lang("EndTimeWindow")." ".$end_time." "; $items[$agendaday][$item['start_date']] .= '
'."".$agenda_link." ".Security::remove_XSS($item['title'])."
"; $items[$agendaday][$item['start_date']] .= '
'; } - + if (is_array($items) && count($items) > 0) { while (list ($agendaday, $tmpitems) = each($items)) { if(!isset($agendaitems[$agendaday])) { @@ -253,25 +253,25 @@ $my_session_id = intval($_GET['session']); $my_course_list = array(); if(!empty($my_session_id)) { - $_SESSION['my_course_list'] = array(); + $_SESSION['my_course_list'] = array(); $my_course_list = array(); } else { - $my_course_list = $_SESSION['my_course_list']; + $my_course_list = $_SESSION['my_course_list']; $my_course_list_keys = array_keys($my_course_list); - if (!in_array($my_course_id, $my_course_list_keys)) { + if (!in_array($my_course_id, $my_course_list_keys)) { $course_info = api_get_course_info_by_id($my_course_id); - $_SESSION['my_course_list'][$my_course_id] = $course_info; + $_SESSION['my_course_list'][$my_course_id] = $course_info; $my_course_list = $_SESSION['my_course_list']; //echo $my_course_id.'added '; } - + if (isset($_GET['delete_course_option'])) { - $course_id_to_delete = intval($_GET['delete_course_option']); - unset($_SESSION['my_course_list'][$course_id_to_delete]); + $course_id_to_delete = intval($_GET['delete_course_option']); + unset($_SESSION['my_course_list'][$course_id_to_delete]); $my_course_list = $_SESSION['my_course_list']; } //clean the array - $my_course_list = array_filter($my_course_list); + $my_course_list = array_filter($my_course_list); } /* OUTPUT */ @@ -309,24 +309,24 @@ if (isset ($_user['user_id'])) { if (api_is_platform_admin()) { $courses = array(); - $sessions = SessionManager::get_sessions_list(); - + $sessions = SessionManager::get_sessions_list(); + } elseif(api_is_drh()) { - $courses = CourseManager::get_courses_followed_by_drh(api_get_user_id()); + $courses = CourseManager::get_courses_followed_by_drh(api_get_user_id()); $sessions = SessionManager::get_sessions_followed_by_drh(api_get_user_id()); } echo ''; echo ''; - + // output: the small calendar item on the left and the view / add links echo ''; - + // the divider // OlivierB : the image has a white background, which causes trouble if the portal has another background color. Image should be transparent. ----> echo ""; echo ""; // the main area: day, week, month view echo '
'; - + echo '
'; if (count($courses) > 0) { echo '

'.get_lang('SelectACourse').'

'; - - foreach ($courses as $row_course) { + + foreach ($courses as $row_course) { $course_code = $row_course['id']; $title = $row_course['title']; $my_course_list_keys = array_keys($my_course_list); @@ -339,37 +339,37 @@ if (isset ($_user['user_id'])) { } if (count($sessions) > 0) { echo '

'.get_lang('SelectASession').'

'; - foreach ($sessions as $session) { + foreach ($sessions as $session) { $id = $session['id']; $name = $session['name']; - echo ''.$name.'
'; + echo ''.$name.'
'; } } echo '
  '; - + //@todo hardcoding option $process = 'month_view'; - + switch ($process) { case "month_view" : $session_id = 0; //By courses if (is_array($my_course_list) && count($my_course_list) > 0) { - $course_list = $my_course_list; + $course_list = $my_course_list; } else { //session $course_list = SessionManager::get_course_list_by_session_id($my_session_id); - $session_id = $my_session_id; - echo '

'.$sessions[$session_id]['name'].'

'; + $session_id = $my_session_id; + echo '

'.$sessions[$session_id]['name'].'

'; } if (is_array($course_list) && count($course_list) > 0) { - + $agendaitems = get_agenda_items_by_course_list($course_list, $month, $year, $session_id); //$agendaitems = get_global_agenda_items($agendaitems, $day, $month, $year, $week, "month_view"); display_mymonthcalendar_2($agendaitems, $month, $year, array(), $monthName, $session_id); @@ -380,4 +380,4 @@ if (isset ($_user['user_id'])) { } } echo "
"; -Display :: display_footer(); \ No newline at end of file +Display :: display_footer();