@ -266,7 +266,7 @@ function get_calendar_items($month, $year)
} // you are a student
//echo "< pre > ".$sql."< / pre > ";
$result=Database::query($sql,__FILE__,__LINE__ ) or die(Database::error());
$result=Database::query($sql) or die(Database::error());
/////////////////
$data=array();
@ -446,7 +446,7 @@ function display_monthcalendar($month, $year)
$start_time= date("H:i",strtotime($value['start_date']));
$end_time= date("H:i",strtotime($value['end_date']));
if ($value['end_date']=='0000-00-00 00:00:00'){
if ($value['end_date']=='0000-00-00 00:00:00'){
$dayheader .= '< br / > '.get_lang("Work").'< br / > ';
$dayheader .= $value['title'];
$dayheader .= '< br / > ';
@ -666,7 +666,7 @@ function selectAll(cbList,bSelect,showwarning)
msg_err2 = document.getElementById(\"err_start_date\");
msg_err3 = document.getElementById(\"err_end_date\");
msg_err4 = document.getElementById(\"err_title\");
if (start_date > ends_date) {
msg_err1.style.display =\"block\";
msg_err1.innerHTML=\"".get_lang('EndDateCannotBeBeforeTheStartDate')."\";
@ -779,7 +779,7 @@ function get_course_users()
FROM $tbl_user as u, $tbl_courseUser as cu
WHERE cu.course_code = '".$_cid."'
AND cu.user_id = u.user_id $courseadmin_filter".$order_clause;
$result = Database::query($sql,__FILE__,__LINE__ );
$result = Database::query($sql);
while($user=Database::fetch_array($result)){
$users[$user[0]] = $user;
}
@ -792,7 +792,7 @@ function get_course_users()
WHERE id_session='".intval($_SESSION['id_session'])."'
AND course_code='$_cid'";
$result = Database::query($sql,__FILE__,__LINE__ );
$result = Database::query($sql);
while($user=Database::fetch_array($result)){
$users[$user[0]] = $user;
}
@ -845,7 +845,7 @@ function show_to_form($to_already_selected)
"value=\" class=\"arrow\" \" />";
*/
?>
< button class = "arrowr" type = "button" onclick = "move(document.getElementById('not_selected_form'), document.getElementById('selected_form'))" onclick = "move(document.getElementById('not_selected_form'), document.getElementById('selected_form'))" > < / button >
< button class = "arrowr" type = "button" onclick = "move(document.getElementById('not_selected_form'), document.getElementById('selected_form'))" onclick = "move(document.getElementById('not_selected_form'), document.getElementById('selected_form'))" > < / button >
< br / > < br / >
< button class = "arrowl" type = "button" onclick = "move(document.getElementById('selected_form'), document.getElementById('not_selected_form'))" onclick = "move(document.getElementById('selected_form'), document.getElementById('not_selected_form'))" > < / button >
<?php
@ -1013,7 +1013,7 @@ function store_new_agenda_item() {
(title,content, start_date, end_date)
VALUES
('".$title."','".$content."', '".$start_date."','".$end_date."')";
$result = Database::query($sql,__FILE__,__LINE__ );
$result = Database::query($sql);
$last_id = Database::insert_id();
// store in last_tooledit (first the groups, then the users
@ -1055,7 +1055,7 @@ function store_new_agenda_item() {
if ($end > $now & & in_array($type,array('daily','weekly','monthlyByDate','monthlyByDay','monthlyByDayR','yearly'))) {
$sql = "INSERT INTO $t_agenda_repeat (cal_id, cal_type, cal_end)" .
" VALUES ($last_id,'$type',$end)";
$res = Database::query($sql,__FILE__,__LINE__ );
$res = Database::query($sql);
}
}
}
@ -1076,13 +1076,13 @@ function store_agenda_item_as_announcement($item_id){
$item_id=Database::escape_string($item_id);
$sql = "SELECT * FROM $table_agenda WHERE id = '".$item_id."'";
$res = Database::query($sql,__FILE__,__LINE__ );
$res = Database::query($sql);
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 = Database::query($sql_max,__FILE__,__LINE__ );
$res_max = Database::query($sql_max);
$row_max = Database::fetch_array($res_max);
$max = $row_max[0]+1;
//build the announcement text
@ -1091,7 +1091,7 @@ function store_agenda_item_as_announcement($item_id){
$session_id = api_get_session_id();
$sql_ins = "INSERT INTO $table_ann (title,content,end_date,display_order,session_id) " .
"VALUES ('".Security::remove_XSS($row['title'])."','".$content."','".$row['end_date']."','$max','$session_id')";
$res_ins = Database::query($sql_ins,__FILE__,__LINE__ );
$res_ins = Database::query($sql_ins);
if($res > 0)
{
$ann_id = Database::insert_id();
@ -1099,7 +1099,7 @@ function store_agenda_item_as_announcement($item_id){
//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 = Database::query($sql_props,__FILE__,__LINE__ );
$res_props = Database::query($sql_props);
if(Database::num_rows($res_props)>0)
{
while($row_props = Database::fetch_array($res_props))
@ -1116,7 +1116,7 @@ function store_agenda_item_as_announcement($item_id){
"'$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 = Database::query($sql_ins_props,__FILE__,__LINE__ );
$res_ins_props = Database::query($sql_ins_props);
if($res_ins_props < = 0){
error_log('SQL Error in '.__FILE__.' at line '.__LINE__.': '.$sql_ins_props);
}else{
@ -1181,7 +1181,7 @@ function sent_to($tool, $id)
$id=Database::escape_string($id);
$sql="SELECT * FROM $TABLE_ITEM_PROPERTY WHERE tool='".$tool."' AND ref='".$id."'";
$result=Database::query($sql,__FILE__,__LINE__ );
$result=Database::query($sql);
while ($row=Database::fetch_array($result))
{
// if to_group_id is null then it is sent to a specific user
@ -1408,7 +1408,7 @@ function load_edit_users($tool, $id)
$TABLE_ITEM_PROPERTY = Database::get_course_table(TABLE_ITEM_PROPERTY);
$sql="SELECT * FROM $TABLE_ITEM_PROPERTY WHERE tool='$tool' AND ref='$id'";
$result=Database::query($sql,__FILE__,__LINE__ ) or die (Database::error());
$result=Database::query($sql) or die (Database::error());
while ($row=Database::fetch_array($result))
{
$to_group=$row['to_group_id'];
@ -1443,7 +1443,7 @@ function change_visibility($tool,$id,$visibility)
$id=Database::escape_string($id);
/*
$sql="SELECT * FROM $TABLE_ITEM_PROPERTY WHERE tool='".TOOL_CALENDAR_EVENT."' AND ref='$id'";
$result=Database::query($sql,__FILE__,__LINE__ ) or die (Database::error());
$result=Database::query($sql) or die (Database::error());
$row=Database::fetch_array($result);
*/
if ($visibility == 0)
@ -1539,7 +1539,7 @@ function get_agenda_item($id)
}
if(empty($id)){return $item;}
$sql = "SELECT * FROM ".$TABLEAGENDA." WHERE id='".$id."'";
$result = Database::query($sql,__FILE__,__LINE__ );
$result = Database::query($sql);
$entry_to_edit = Database::fetch_array($result);
$item['title'] = $entry_to_edit["title"];
$item['content'] = $entry_to_edit["content"];
@ -1557,7 +1557,7 @@ function get_agenda_item($id)
}
$item['repeat'] = false;
$sql = "SELECT * FROM $t_agenda_repeat WHERE cal_id = $id";
$res = Database::query($sql,__FILE__,__LINE__ );
$res = Database::query($sql);
if(Database::num_rows($res)>0)
{
//this event is repetitive
@ -1609,7 +1609,7 @@ function store_edited_agenda_item($id_attach,$file_comment)
// 2.a. delete everything for the users
$sql_delete="DELETE FROM ".$TABLE_ITEM_PROPERTY." WHERE ref='$id' AND tool='".TOOL_CALENDAR_EVENT."'";
$result = Database::query($sql_delete,__FILE__,__LINE__ ) or die (Database::error());
$result = Database::query($sql_delete) or die (Database::error());
// 2.b. storing the new users/groups
if (!is_null($to)) // !is_null($to): when no user is selected we send it to everyone
{
@ -1667,7 +1667,7 @@ function save_edit_agenda_item($id,$title,$content,$start_date,$end_date)
start_date='".$start_date."',
end_date='".$end_date."'
WHERE id='".$id."'";
$result = Database::query($sql,__FILE__,__LINE__ ) or die (Database::error());
$result = Database::query($sql) or die (Database::error());
return true;
}
@ -1692,11 +1692,11 @@ function delete_agenda_item($id)
$t_agenda_r = Database::get_course_table(TABLE_AGENDA_REPEAT);
$id=(int)addslashes($_GET['id']);
$sql = "SELECT * FROM $t_agenda_r WHERE cal_id = $id";
$res = Database::query($sql,__FILE__,__LINE__ );
$res = Database::query($sql);
if(Database::num_rows($res)>0)
{
$sql_children = "SELECT * FROM $t_agenda WHERE parent_event_id = $id";
$res_children = Database::query($sql_children,__FILE__,__LINE__ );
$res_children = Database::query($sql_children);
if(Database::num_rows($res_children)>0)
{
while ($row_child = Database::fetch_array($res_children))
@ -1705,11 +1705,11 @@ function delete_agenda_item($id)
}
}
$sql_del = "DELETE FROM $t_agenda_r WHERE cal_id = $id";
$res_del = Database::query($sql_del,__FILE__,__LINE__ );
$res_del = Database::query($sql_del);
}
//$sql = "DELETE FROM ".$TABLEAGENDA." WHERE id='$id'";
//$sql= "UPDATE ".$TABLE_ITEM_PROPERTY." SET visibility='2' WHERE tool='Agenda' and ref='$id'";
//$result = Database::query($sql,__FILE__,__LINE__ ) or die (Database::error());
//$result = Database::query($sql) or die (Database::error());
api_item_property_update($_course,TOOL_CALENDAR_EVENT,$id,'delete',api_get_user_id());
// delete the resources that were added to this agenda item
@ -1903,12 +1903,12 @@ function display_agenda_items()
$session_condition
GROUP BY ip.ref
ORDER BY start_date ".$_SESSION['sort'];
//removed - > AND toolitemproperties.visibility='1'
//removed - > AND toolitemproperties.visibility='1'
}
// A.3 you are a course admin without any group or user filter
else
{
// A.3.a you are a course admin without user or group filter but WITH studentview
// => see all the messages of all the users and groups without editing possibilities
if ($_GET['isStudentView']=='true')
@ -2011,7 +2011,7 @@ function display_agenda_items()
if ($_user['user_id'])
{
$sql="SELECT
agenda.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.ref
agenda.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.ref
FROM ".$TABLEAGENDA." agenda, ".$TABLE_ITEM_PROPERTY." ip
WHERE agenda.id = ip.ref ".$show_all_current."
AND ip.tool='".TOOL_CALENDAR_EVENT."'
@ -2036,7 +2036,7 @@ function display_agenda_items()
} // you are a student
//echo "< pre > ".$sql."< / pre > ";
$result=Database::query($sql,__FILE__,__LINE__ ) or die(Database::error());
$result=Database::query($sql) or die(Database::error());
$number_items=Database::num_rows($result);
/*--------------------------------------------------
@ -2147,7 +2147,7 @@ function display_agenda_items()
echo get_lang("EndTimeWindow").": ";
echo api_ucfirst(format_locale_date($dateFormatLong,strtotime($myrow["end_date"])))." ";
echo api_ucfirst(strftime($timeNoSecFormat,strtotime($myrow["end_date"])))."";
}
}
echo "< / td > \n";
// attachment list
@ -2303,7 +2303,7 @@ function get_attachment($agenda_id) {
$agenda_id=Database::escape_string($agenda_id);
$row=array();
$sql = 'SELECT id,path, filename,comment FROM '. $agenda_table_attachment.' WHERE agenda_id = '.(int)$agenda_id.'';
$result=Database::query($sql, __FILE__, __LINE__ );
$result=Database::query($sql);
if (Database::num_rows($result)!=0) {
$row=Database::fetch_array($result);
}
@ -2340,12 +2340,12 @@ function display_one_agenda_item($agenda_id)
AND ip.tool='".TOOL_CALENDAR_EVENT."'
AND ip.visibility='1'
AND agenda.id='$agenda_id'";
$result=Database::query($sql,__FILE__,__LINE__ ) or die(Database::error());
$result=Database::query($sql) or die(Database::error());
$number_items=Database::num_rows($result);
$myrow=Database::fetch_array($result); // there should be only one item so no need for a while loop
$sql_rep = "SELECT * FROM $TABLEAGENDA WHERE id = $agenda_id AND parent_event_id IS NOT NULL AND parent_event_id !=0";
$res_rep = Database::query($sql_rep,__FILE__,__LINE__ );
$res_rep = Database::query($sql_rep);
$repeat = false;
$repeat_id = 0;
if(Database::num_rows($res_rep)>0)
@ -3104,7 +3104,7 @@ function get_agendaitems($month, $year)
}
$mycourse = api_get_course_info();
$result = Database::query($sqlquery, __FILE__, __LINE__ );
$result = Database::query($sqlquery);
global $_configuration;
$root_url = $_configuration['root_web'];
if ($_configuration['multiple_access_urls']==true) {
@ -3194,7 +3194,7 @@ function display_upcoming_events()
ORDER BY start_date ";
}
}
$result = Database::query($sqlquery, __FILE__, __LINE__ );
$result = Database::query($sqlquery);
$counter = 0;
while ($item = Database::fetch_array($result,'ASSOC'))
{
@ -3471,7 +3471,7 @@ function get_day_agendaitems($courses_dbs, $month, $year, $day)
//$sqlquery = "SELECT * FROM $agendadb WHERE DAYOFMONTH(day)='$day' AND month(day)='$month' AND year(day)='$year'";
//echo "abc";
//echo $sqlquery;
$result = Database::query($sqlquery, __FILE__, __LINE__ );
$result = Database::query($sqlquery);
//echo Database::num_rows($result);
while ($item = Database::fetch_array($result))
{
@ -3599,7 +3599,7 @@ function get_week_agendaitems($courses_dbs, $month, $year, $week = '')
// $sqlquery = "SELECT * FROM $agendadb WHERE (DAYOFMONTH(day)>='$start_day' AND DAYOFMONTH(day)< ='$end_day')
// AND (MONTH(day)>='$start_month' AND MONTH(day)< ='$end_month')
// AND (YEAR(day)>='$start_year' AND YEAR(day)< ='$end_year')";
$result = Database::query($sqlquery, __FILE__, __LINE__ );
$result = Database::query($sqlquery);
while ($item = Database::fetch_array($result))
{
$agendaday = date("j",strtotime($item['start_date']));
@ -3685,7 +3685,7 @@ function get_repeated_events_day_view($course_info,$start=0,$end=0,$params)
.(!empty($params['conditions'])?$params['conditions']:'')
.(!empty($params['groupby'])?' GROUP BY '.$params['groupby']:'')
.(!empty($params['orderby'])?' ORDER BY '.$params['orderby']:'');
$res = Database::query($sql,__FILE__,__LINE__ );
$res = Database::query($sql);
if(Database::num_rows($res)>0)
{
while($row = Database::fetch_array($res))
@ -3812,7 +3812,7 @@ function get_repeated_events_week_view($course_info,$start=0,$end=0,$params)
.(!empty($params['conditions'])?$params['conditions']:'')
.(!empty($params['groupby'])?' GROUP BY '.$params['groupby']:'')
.(!empty($params['orderby'])?' ORDER BY '.$params['orderby']:'');
$res = Database::query($sql,__FILE__,__LINE__ );
$res = Database::query($sql);
if(Database::num_rows($res)>0)
{
while($row = Database::fetch_array($res))
@ -3943,7 +3943,7 @@ function get_repeated_events_month_view($course_info,$start=0,$end=0,$params)
.(!empty($params['conditions'])?$params['conditions']:'')
.(!empty($params['groupby'])?' GROUP BY '.$params['groupby']:'')
.(!empty($params['orderby'])?' ORDER BY '.$params['orderby']:'');
$res = Database::query($sql,__FILE__,__LINE__ );
$res = Database::query($sql);
if(Database::num_rows($res)>0)
{
while($row = Database::fetch_array($res))
@ -4114,7 +4114,7 @@ function get_repeated_events_list_view($course_info,$start=0,$end=0,$params)
.(!empty($params['conditions'])?$params['conditions']:'')
.(!empty($params['groupby'])?' GROUP BY '.$params['groupby']:'')
.(!empty($params['orderby'])?' ORDER BY '.$params['orderby']:'');
$res = Database::query($sql,__FILE__,__LINE__ );
$res = Database::query($sql);
if(Database::num_rows($res)>0)
{
while($row = Database::fetch_array($res))
@ -4293,7 +4293,7 @@ function is_repeated_event($id,$course=null)
$id = (int) $id;
$t_agenda_repeat = Database::get_course_table(TABLE_AGENDA_REPEAT,$course);
$sql = "SELECT * FROM $t_agenda_repeat WHERE cal_id = $id";
$res = Database::query($sql,__FILE__,__LINE__ );
$res = Database::query($sql);
if(Database::num_rows($res)>0)
{
return true;
@ -4383,7 +4383,7 @@ function agenda_add_item($course_info, $title, $content, $db_start_date, $db_end
AND item_property.ref = agenda.id
AND item_property.visibility < > 2
";
$result = Database::query($sql,__FILE__,__LINE__ );
$result = Database::query($sql);
$count = Database::num_rows($result);
if ($count > 0) {
return false;
@ -4394,7 +4394,7 @@ function agenda_add_item($course_info, $title, $content, $db_start_date, $db_end
VALUES
('".$title."','".$content."', '".$start_date."','".$end_date."'".(!empty($parent_id)?','.((int)$parent_id):'').", '".$id_session."')";
$result = Database::query($sql,__FILE__,__LINE__ ) or die (Database::error());
$result = Database::query($sql) or die (Database::error());
$last_id=Database::insert_id();
// add a attachment file in agenda
@ -4573,7 +4573,7 @@ function agenda_add_repeat_item($course_info,$orig_id,$type,$end,$orig_dest,$fil
$t_agenda_r = Database::get_course_table(TABLE_AGENDA_REPEAT,$course_info['dbName']);
//$sql = "SELECT title, content, UNIX_TIMESTAMP(start_date) as sd, UNIX_TIMESTAMP(end_date) as ed FROM $t_agenda WHERE id = $orig_id";
$sql = 'SELECT title, content, start_date as sd, end_date as ed FROM '. $t_agenda.' WHERE id ="'.Database::escape_string($orig_id).'" ';
$res = Database::query($sql,__FILE__,__LINE__ );
$res = Database::query($sql);
if(Database::num_rows($res)!==1){return false;}
$row = Database::fetch_array($res);
//$orig_start = $row['sd'];
@ -4617,7 +4617,7 @@ function agenda_add_repeat_item($course_info,$orig_id,$type,$end,$orig_dest,$fil
{
$sql = "INSERT INTO $t_agenda_r (cal_id, cal_type, cal_end)" .
" VALUES ($orig_id,'$type',$end)";
$res = Database::query($sql,__FILE__,__LINE__ );
$res = Database::query($sql);
switch($type)
{
case 'daily':
@ -4763,7 +4763,7 @@ function get_global_agenda_items($agendaitems, $day = "", $month = "", $year = "
$end_filter = $year."-".$month."-".$day." 23:59:59";
$sql = " SELECT * FROM ".$tbl_global_agenda." WHERE start_date>='".$start_filter."' AND start_date< ='".$end_filter."'";
}
$result = Database::query($sql, __FILE__, __LINE__ );
$result = Database::query($sql);
while ($item = Database::fetch_array($result))
{
// we break the date field in the database into a date and a time part