diff --git a/main/admin/calendar.lib.php b/main/admin/calendar.lib.php index 399602a07c..46b3902311 100644 --- a/main/admin/calendar.lib.php +++ b/main/admin/calendar.lib.php @@ -253,108 +253,6 @@ function MM_jumpMenu(targ,selObj,restore){ "; } -/** -* this function gets all the users of the current course -* @author Patrick Cool , Ghent University -* @return array: associative array where the key is the id of the user and the value is an array containing - the first name, the last name, the user id -*/ -function get__users() -{/* -global $tbl_user; -global $tbl_courseUser, $tbl_session_course_user; -global $_cid; - -// not 100% if this is necessary, this however prevents a notice -if (!isset($courseadmin_filter)) - {$courseadmin_filter='';} - -$sql = "SELECT u.user_id uid, u.lastname lastName, u.firstname firstName - FROM $tbl_user as u, $tbl_courseUser as cu - WHERE cu.course_code = '".$_cid."' - AND cu.user_id = u.user_id $courseadmin_filter - ORDER BY u.lastname, u.firstname"; -$result = api_sql_query($sql,__FILE__,__LINE__); -while($user=Database::fetch_array($result)){ - $users[$user[0]] = $user; -} - -if(!empty($_SESSION['id_session'])){ - $sql = "SELECT u.user_id uid, u.lastname lastName, u.firstName firstName - FROM $tbl_session_course_user AS session_course_user - INNER JOIN $tbl_user u - ON u.user_id = session_course_user.id_user - WHERE id_session='".$_SESSION['id_session']."' - AND course_code='$_cid'"; - - $result = api_sql_query($sql,__FILE__,__LINE__); - while($user=Database::fetch_array($result)){ - $users[$user[0]] = $user; - } - -} - -return $users; -*/ -} - -/** -* this function gets all the groups of the course -* @author Patrick Cool , Ghent University -* @return array -*/ -function get_course_groups() -{/* - global $tbl_group; - global $tbl_groupUser; - $group_list = array(); - - $sql = "SELECT g.id, g.name, COUNT(gu.id) userNb - FROM ".$tbl_group." AS g LEFT JOIN ".$tbl_groupUser." gu - ON g.id = gu.group_id - GROUP BY g.id"; - - $result = api_sql_query($sql,__FILE__,__LINE__); - while ($group_data = Database::fetch_array($result)) - { - $group_list [$group_data['id']] = $group_data; - } - return $group_list;*/ -} -/** -* this function shows the form for sending a message to a specific group or user. -* @author: Patrick Cool , Ghent University -* @return html code -*/ -function show_to_form($to_already_selected) -{ -/*$user_list=get_course_users(); -$group_list=get_course_groups(); - -echo "\n\n"; - echo "\t\n"; - // the form containing all the groups and all the users of the course - echo "\t\t\n"; - // the buttons for adding or removing groups/users - echo "\n\t\t\n"; - echo "\n\t\t\n"; - echo "\t\n"; -echo "
\n"; - construct_not_selected_select_form($group_list,$user_list,$to_already_selected); - echo "\t\t\n"; - echo "\t\t", - - "\n\t\t

 

", - - "\n\t\t"; - echo "\t\t
\n"; - construct_selected_select_form($group_list,$user_list,$to_already_selected); - echo "\t\t
";*/ -} function display_monthcalendar($month, $year) { @@ -452,78 +350,6 @@ echo ""; * @author: Patrick Cool , Ghent University * @return html code */ -function construct_not_selected_select_form($group_list=null, $user_list=null,$to_already_selected=array()) -{ - /*echo "\t\t\n";*/ -} -/** -* This function shows the form with the user that were selected -* @author: Patrick Cool , Ghent University -* @return html code -*/ -function construct_selected_select_form($group_list=null, $user_list=null,$to_already_selected) -{ -/* // we separate the $to_already_selected array (containing groups AND users into - // two separate arrays - if (is_array($to_already_selected)) - { - $groupuser=separate_users_groups($to_already_selected); - } - $groups_to_already_selected=$groupuser['groups']; - $users_to_already_selected=$groupuser['users']; - - // we load all the groups and all the users into a reference array that we use to search the name of the group / user - $ref_array_groups=get_course_groups(); - $ref_array_users=get_course_users(); - - // we construct the form of the already selected groups / users - echo "\t\t\n";*/ -} /** * This function stores the Agenda Item in the table calendar_event and updates the item_property table also * @author: Patrick Cool , Ghent University @@ -603,128 +429,15 @@ function store_new_agenda_item() } return $last_id;*/ } -/** - * Stores the given agenda item as an announcement (unlinked copy) - * @param integer Agenda item's ID - * @return integer New announcement item's ID - */ -function store_agenda_item_as_announcement($item_id){/* - $table_agenda = Database::get_main_table(TABLE_MAIN_SYSTEM_CALENDAR); - $table_ann = Database::get_course_table(TABLE_ANNOUNCEMENT); - //check params - if(empty($item_id) or $item_id != strval(intval($item_id))){return -1;} - //get the agenda item - $sql = "SELECT * FROM $table_agenda WHERE id = '".$item_id."'"; - $res = api_sql_query($sql,__FILE__,__LINE__); - if(Database::num_rows($res)>0){ - $row = Database::fetch_array($res); - //we have the agenda event, copy it - //get the maximum value for display order in announcement table - $sql_max = "SELECT MAX(display_order) FROM $table_ann"; - $res_max = api_sql_query($sql_max,__FILE__,__LINE__); - $row_max = Database::fetch_array($res_max); - $max = $row_max[0]+1; - //build the announcement text - $content = $row['start_date']." - ".$row['end_date']."\n\n".$row['content']; - //insert announcement - - $sql_ins = "INSERT INTO $table_ann (title,content,end_date,display_order) " . - "VALUES ('".$row['title']."','$content','".$row['end_date']."','$max')"; - $res_ins = api_sql_query($sql_ins,__FILE__,__LINE__); - if($res > 0) - { - $ann_id = Database::get_last_insert_id(); - //Now also get the list of item_properties rows for this agenda_item (calendar_event) - //and copy them into announcement item_properties - $table_props = Database::get_course_table(TABLE_ITEM_PROPERTY); - $sql_props = "SELECT * FROM $table_props WHERE tool = 'calendar_event' AND ref='$item_id'"; - $res_props = api_sql_query($sql_props,__FILE__,__LINE__); - if(Database::num_rows($res_props)>0) - { - while($row_props = Database::fetch_array($res_props)) - { - //insert into announcement item_property - $time = date("Y-m-d H:i:s", time()); - $sql_ins_props = "INSERT INTO $table_props " . - "(tool, insert_user_id, insert_date, " . - "lastedit_date, ref, lastedit_type," . - "lastedit_user_id, to_group_id, to_user_id, " . - "visibility, start_visible, end_visible)" . - " VALUES " . - "('announcement','".$row_props['insert_user_id']."','".$time."'," . - "'$time','$ann_id','AnnouncementAdded'," . - "'".$row_props['last_edit_user_id']."','".$row_props['to_group_id']."','".$row_props['to_user_id']."'," . - "'".$row_props['visibility']."','".$row_props['start_visible']."','".$row_props['end_visible']."')"; - $res_ins_props = api_sql_query($sql_ins_props,__FILE__,__LINE__); - if($res_ins_props <= 0){ - error_log('SQL Error in '.__FILE__.' at line '.__LINE__.': '.$sql_ins_props); - }else{ - //copy was a success - return $ann_id; - } - } - } - }else{ - return -1; - } - } - return -1;*/ -} -/** -* This function separates the users from the groups -* users have a value USER:XXX (with XXX the dokeos id -* groups have a value GROUP:YYY (with YYY the group id) -* @author: Patrick Cool , Ghent University -* @return array -*/ -function separate_users_groups($to) -{ -/* $grouplist = array(); - $userlist = array(); - if(is_array($to) && count($to)>0) - { - foreach($to as $to_item) - { - list($type, $id) = explode(':', $to_item); - - switch($type) - { - case 'GROUP': - $grouplist[] =$id; - break; - case 'USER': - $userlist[] =$id; - break; - } - } - $send_to['groups']=$grouplist; - $send_to['users']=$userlist; - } - return $send_to;*/ -} - -/** -* returns all the users and all the groups a specific Agenda item has been sent to -* @author: Patrick Cool , Ghent University -* @return array -*/ -function sent_to($tool, $id) -{ -} - -function load_edit_users($tool, $id) -{} -/** -* This functions swithes the visibility a course resource using the visible field in 'last_tooledit' values: 0 = invisible -* @author: Patrick Cool , Ghent University -*/ -function change_visibility($tool,$id) -{} /** * The links that allows the student AND course administrator to show all agenda items and sort up/down * @author Patrick Cool , Ghent University */ +function display_courseadmin_links() { + echo "".Display::return_icon('calendar_personal_add.gif', get_lang('AgendaAdd'))." ".get_lang('AgendaAdd').""; + +} function display_student_links() { global $show; @@ -1556,7 +1269,6 @@ function show_add_form($id = '') - @@ -3261,20 +2973,7 @@ function agenda_add_repeat_item($course_info,$orig_id,$type,$end,$orig_dest) * @param array Course info * @return boolean True on success, false otherwise */ -function display_courseadmin_links() -{ - echo "".Display::return_icon('calendar_add.gif', get_lang('AgendaAdd'))." ".get_lang('AgendaAdd').""; -/* - if (empty ($_SESSION['toolgroup'])) - { - echo "
  • ".get_lang('UserGroupFilter')."
    "; - echo "
    "; - show_user_group_filter_form(); - echo ""; - } -*/ -} function agenda_import_ical($course_info,$file) { require_once(api_get_path(LIBRARY_PATH).'fileUpload.lib.php'); diff --git a/main/admin/calendar.php b/main/admin/calendar.php index cb0222ac7b..9f0624becb 100644 --- a/main/admin/calendar.php +++ b/main/admin/calendar.php @@ -253,11 +253,13 @@ if (empty($select_year) && empty($select_month)) $select_month = $today['mon']; } -echo '
    '; +echo '
    '; if (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_edit_agenda') && !api_is_anonymous())) { + display_student_links(); display_courseadmin_links(); } + echo '


    '; @@ -292,7 +294,7 @@ $fck_attribute['ToolbarSet'] = 'Middle'; // THE RIGHT PART echo '
  •  
     
    '; echo '
    '; -display_student_links(); + echo '
    '; if (api_is_allowed_to_edit(false,true)) { diff --git a/main/calendar/agenda.inc.php b/main/calendar/agenda.inc.php index fda8d5a26d..fbc18e3315 100644 --- a/main/calendar/agenda.inc.php +++ b/main/calendar/agenda.inc.php @@ -1,4 +1,4 @@ -0)) $numberofdays[2] = 29; @@ -291,8 +291,11 @@ function display_monthcalendar($month, $year) $dayheader .= '
    '.substr($value['start_date'],11,8).''; $dayheader .= ' - '; $dayheader .= $value['title']; + //$agendaitems = get_global_agenda_items($agendaitems, $curday, $month, $year, $startdayofweek, "month_view"); + //echo $agendaitems['title']; } - } + + } } if (($curday==$today['mday'])&&($year ==$today['year'])&&($month == $today['mon'])) @@ -433,6 +436,7 @@ function plus_repeated_event() { } } + // End --> "; } @@ -641,8 +645,7 @@ function construct_selected_select_form($group_list=null, $user_list=null,$to_al * @author: Patrick Cool , Ghent University * @return integer the id of the last added agenda item */ -function store_new_agenda_item() -{ +function store_new_agenda_item() { global $_user, $_course; $TABLEAGENDA = Database::get_course_table(TABLE_AGENDA); $t_agenda_repeat = Database::get_course_Table(TABLE_AGENDA_REPEAT); @@ -674,23 +677,19 @@ function store_new_agenda_item() { $send_to=separate_users_groups($to); // storing the selected groups - if (is_array($send_to['groups'])) - { - foreach ($send_to['groups'] as $group) - { + if (is_array($send_to['groups'])) { + foreach ($send_to['groups'] as $group) { api_item_property_update($_course, TOOL_CALENDAR_EVENT, $last_id,"AgendaAdded", $_user['user_id'], $group,'',$start_date, $end_date); } } // storing the selected users - if (is_array($send_to['users'])) - { - foreach ($send_to['users'] as $user) - { + if (is_array($send_to['users'])) { + foreach ($send_to['users'] as $user) { api_item_property_update($_course, TOOL_CALENDAR_EVENT, $last_id,"AgendaAdded", $_user['user_id'],'',$user, $start_date,$end_date); } } } - else // the message is sent to everyone, so we set the group to 0 + else // the message is sent to everyone, so we set the group to 0 { api_item_property_update($_course, TOOL_CALENDAR_EVENT, $last_id,"AgendaAdded", $_user['user_id'], '','',$start_date,$end_date); } @@ -698,10 +697,8 @@ function store_new_agenda_item() store_resources($_SESSION['source_type'],$last_id); //if repetitive, insert element into agenda_repeat table - if(!empty($_POST['repeat']) && !empty($_POST['repeat_type'])) - { - if(!empty($_POST['repeat_end_year']) && !empty($_POST['repeat_end_month']) && !empty($_POST['repeat_end_day'])) - { + if(!empty($_POST['repeat']) && !empty($_POST['repeat_type'])) { + if(!empty($_POST['repeat_end_year']) && !empty($_POST['repeat_end_month']) && !empty($_POST['repeat_end_day'])) { $end_y = intval($_POST['repeat_end_year']); $end_m = intval($_POST['repeat_end_month']); $end_d = intval($_POST['repeat_end_day']); @@ -1008,13 +1005,15 @@ function show_user_group_filter_form() // Groups echo "\n\t"; - $group_list=get_course_groups(); - foreach($group_list as $this_group) - { - // echo ""; - echo "\n\t\t"; + if(isset($group_list)){ + $group_list=get_course_groups(); + foreach($group_list as $this_group) + { + // echo ""; + echo "\n\t\t"; + } } echo "\n\t"; @@ -1105,8 +1104,6 @@ function change_visibility($tool,$id) */ function display_courseadmin_links() { - echo "".Display::return_icon('calendar_add.gif', get_lang('AgendaAdd'))." ".get_lang('AgendaAdd')." | "; - if (empty ($_SESSION['toolgroup'])) { echo get_lang('UserGroupFilter'); @@ -1114,6 +1111,7 @@ function display_courseadmin_links() { show_user_group_filter_form(); echo " "; } + echo "".Display::return_icon('calendar_add.gif', get_lang('AgendaAdd'))." ".get_lang('AgendaAdd').""; } @@ -2171,7 +2169,6 @@ function show_add_form($id = '') -
     
     
    '')?get_lang('ModifyCalendarItem'):get_lang("AddCalendarItem"); ?> @@ -4097,8 +4094,6 @@ function add_agenda_attachment_file($file_comment,$last_id) { } } } - - /** * This function edit a attachment file into agenda * @param string a comment about file @@ -4397,7 +4392,8 @@ function get_global_agenda_items($agendaitems, $day = "", $month = "", $year = " { $halfhour = $halfhour +1; } - $agendaitems[$halfhour] .= "
    $hour:$minute".get_lang('Evento Global'). ": ".$item['title']."
    "; + //$agendaitems[$halfhour] .= "
    $hour:$minute ".get_lang('Evento Global'). ": ".$item['title']."
    "; + $agendaitems[$halfhour] .= "
    $hour:$minute ".get_lang('Evento Global'). ": ".$item['title']."
    "; } } //print_r($agendaitems); diff --git a/main/calendar/agenda.php b/main/calendar/agenda.php index 73b5a1c047..c58965284a 100644 --- a/main/calendar/agenda.php +++ b/main/calendar/agenda.php @@ -1,4 +1,4 @@ -'; +echo '
    '; +display_student_links(); if (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_edit_agenda') && !api_is_anonymous())) { display_courseadmin_links(); @@ -305,8 +306,7 @@ else // THE RIGHT PART echo '
    '; -echo '
    '; -display_student_links(); +echo '
    '; echo '
    '; if (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_edit_agenda') && !api_is_anonymous())) {