[svn r15362] Minor - code cleanup

skala
Yannick Warnier 17 years ago
parent cbce8a49be
commit 1f7f257a87
  1. 143
      main/calendar/agenda.inc.php
  2. 40
      main/calendar/myagenda.inc.php

@ -1,4 +1,4 @@
<?php //$Id: agenda.inc.php 15360 2008-05-22 18:07:51Z yannoo $ <?php //$Id: agenda.inc.php 15362 2008-05-22 18:27:41Z yannoo $
/* /*
============================================================================== ==============================================================================
Dokeos - elearning and course management software Dokeos - elearning and course management software
@ -122,7 +122,7 @@ function get_calendar_items($month, $year)
} }
$result=api_sql_query($sql,__FILE__,__LINE__); $result=api_sql_query($sql,__FILE__,__LINE__);
$data=array(); $data=array();
while ($row=mysql_fetch_array($result)) while ($row=Database::fetch_array($result))
{ {
$datum_item=(int)substr($row["start_date"],8,2); $datum_item=(int)substr($row["start_date"],8,2);
//$dag_item=date("d",strtotime($datum_item)); //$dag_item=date("d",strtotime($datum_item));
@ -451,7 +451,7 @@ $sql = "SELECT u.user_id uid, u.lastname lastName, u.firstname firstName
AND cu.user_id = u.user_id $courseadmin_filter AND cu.user_id = u.user_id $courseadmin_filter
ORDER BY u.lastname, u.firstname"; ORDER BY u.lastname, u.firstname";
$result = api_sql_query($sql,__FILE__,__LINE__); $result = api_sql_query($sql,__FILE__,__LINE__);
while($user=mysql_fetch_array($result)){ while($user=Database::fetch_array($result)){
$users[$user[0]] = $user; $users[$user[0]] = $user;
} }
@ -464,7 +464,7 @@ if(!empty($_SESSION['id_session'])){
AND course_code='$_cid'"; AND course_code='$_cid'";
$result = api_sql_query($sql,__FILE__,__LINE__); $result = api_sql_query($sql,__FILE__,__LINE__);
while($user=mysql_fetch_array($result)){ while($user=Database::fetch_array($result)){
$users[$user[0]] = $user; $users[$user[0]] = $user;
} }
@ -491,8 +491,8 @@ function get_course_groups()
ON g.id = gu.group_id ON g.id = gu.group_id
GROUP BY g.id"; GROUP BY g.id";
$result = api_sql_query($sql,__FILE__,__LINE__) or die(mysql_error()); $result = api_sql_query($sql,__FILE__,__LINE__) or die(Database::error());
while ($group_data = mysql_fetch_array($result)) while ($group_data = Database::fetch_array($result))
{ {
$group_list [$group_data['id']] = $group_data; $group_list [$group_data['id']] = $group_data;
} }
@ -641,8 +641,8 @@ function store_new_agenda_item()
VALUES VALUES
('".$title."','".$content."', '".$start_date."','".$end_date."')"; ('".$title."','".$content."', '".$start_date."','".$end_date."')";
$result = api_sql_query($sql,__FILE__,__LINE__) or die (mysql_error()); $result = api_sql_query($sql,__FILE__,__LINE__) or die (Database::error());
$last_id=mysql_insert_id(); $last_id=Database::insert_id();
// store in last_tooledit (first the groups, then the users // store in last_tooledit (first the groups, then the users
$to=$_POST['selectedform']; $to=$_POST['selectedform'];
@ -786,7 +786,7 @@ $TABLE_ITEM_PROPERTY = Database::get_course_table(TABLE_ITEM_PROPERTY);
$sql="SELECT * FROM $TABLE_ITEM_PROPERTY WHERE tool='".$tool."' AND ref='".$id."'"; $sql="SELECT * FROM $TABLE_ITEM_PROPERTY WHERE tool='".$tool."' AND ref='".$id."'";
$result=api_sql_query($sql,__FILE__,__LINE__); $result=api_sql_query($sql,__FILE__,__LINE__);
while ($row=mysql_fetch_array($result)) while ($row=Database::fetch_array($result))
{ {
// if to_group_id is null then it is sent to a specific user // if to_group_id is null then it is sent to a specific user
// if to_group_id = 0 then it is sent to everybody // if to_group_id = 0 then it is sent to everybody
@ -991,8 +991,8 @@ global $_course;
$TABLE_ITEM_PROPERTY = Database::get_course_table(TABLE_ITEM_PROPERTY); $TABLE_ITEM_PROPERTY = Database::get_course_table(TABLE_ITEM_PROPERTY);
$sql="SELECT * FROM $TABLE_ITEM_PROPERTY WHERE tool='$tool' AND ref='$id'"; $sql="SELECT * FROM $TABLE_ITEM_PROPERTY WHERE tool='$tool' AND ref='$id'";
$result=api_sql_query($sql,__FILE__,__LINE__) or die (mysql_error()); $result=api_sql_query($sql,__FILE__,__LINE__) or die (Database::error());
while ($row=mysql_fetch_array($result)) while ($row=Database::fetch_array($result))
{ {
$to_group=$row['to_group_id']; $to_group=$row['to_group_id'];
switch ($to_group) switch ($to_group)
@ -1025,8 +1025,8 @@ function change_visibility($tool,$id)
$TABLE_ITEM_PROPERTY = Database::get_course_table(TABLE_ITEM_PROPERTY); $TABLE_ITEM_PROPERTY = Database::get_course_table(TABLE_ITEM_PROPERTY);
$sql="SELECT * FROM $TABLE_ITEM_PROPERTY WHERE tool='".TOOL_CALENDAR_EVENT."' AND ref='$id'"; $sql="SELECT * FROM $TABLE_ITEM_PROPERTY WHERE tool='".TOOL_CALENDAR_EVENT."' AND ref='$id'";
$result=api_sql_query($sql,__FILE__,__LINE__) or die (mysql_error()); $result=api_sql_query($sql,__FILE__,__LINE__) or die (Database::error());
$row=mysql_fetch_array($result); $row=Database::fetch_array($result);
if ($row['visibility']=='1') if ($row['visibility']=='1')
{ {
@ -1111,7 +1111,7 @@ function get_agenda_item($id)
$id=(int)addslashes($_GET['id']); $id=(int)addslashes($_GET['id']);
$sql = "SELECT * FROM ".$TABLEAGENDA." WHERE id='".$id."'"; $sql = "SELECT * FROM ".$TABLEAGENDA." WHERE id='".$id."'";
$result = api_sql_query($sql,__FILE__,__LINE__); $result = api_sql_query($sql,__FILE__,__LINE__);
$entry_to_edit = mysql_fetch_array($result); $entry_to_edit = Database::fetch_array($result);
$item['title'] = $entry_to_edit["title"]; $item['title'] = $entry_to_edit["title"];
$item['content'] = $entry_to_edit["content"]; $item['content'] = $entry_to_edit["content"];
$item['start_date'] = $entry_to_edit["start_date"]; $item['start_date'] = $entry_to_edit["start_date"];
@ -1160,7 +1160,7 @@ function store_edited_agenda_item()
// 2.a. delete everything for the users // 2.a. delete everything for the users
$sql_delete="DELETE FROM ".$TABLE_ITEM_PROPERTY." WHERE ref='$id' AND tool='".TOOL_CALENDAR_EVENT."'"; $sql_delete="DELETE FROM ".$TABLE_ITEM_PROPERTY." WHERE ref='$id' AND tool='".TOOL_CALENDAR_EVENT."'";
$result = api_sql_query($sql_delete,__FILE__,__LINE__) or die (mysql_error()); $result = api_sql_query($sql_delete,__FILE__,__LINE__) or die (Database::error());
// 2.b. storing the new users/groups // 2.b. storing the new users/groups
if (!is_null($to)) // !is_null($to): when no user is selected we send it to everyone if (!is_null($to)) // !is_null($to): when no user is selected we send it to everyone
{ {
@ -1212,7 +1212,7 @@ function save_edit_agenda_item($id,$title,$content,$start_date,$end_date)
start_date='".$start_date."', start_date='".$start_date."',
end_date='".$end_date."' end_date='".$end_date."'
WHERE id='".$id."'"; WHERE id='".$id."'";
$result = api_sql_query($sql,__FILE__,__LINE__) or die (mysql_error()); $result = api_sql_query($sql,__FILE__,__LINE__) or die (Database::error());
return true; return true;
} }
@ -1234,7 +1234,7 @@ function delete_agenda_item($id)
{ {
//$sql = "DELETE FROM ".$TABLEAGENDA." WHERE id='$id'"; //$sql = "DELETE FROM ".$TABLEAGENDA." WHERE id='$id'";
//$sql= "UPDATE ".$TABLE_ITEM_PROPERTY." SET visibility='2' WHERE tool='Agenda' and ref='$id'"; //$sql= "UPDATE ".$TABLE_ITEM_PROPERTY." SET visibility='2' WHERE tool='Agenda' and ref='$id'";
//$result = api_sql_query($sql,__FILE__,__LINE__) or die (mysql_error()); //$result = api_sql_query($sql,__FILE__,__LINE__) or die (Database::error());
$id=(int)addslashes($_GET['id']); $id=(int)addslashes($_GET['id']);
api_item_property_update($_course,TOOL_CALENDAR_EVENT,$id,"delete"); api_item_property_update($_course,TOOL_CALENDAR_EVENT,$id,"delete");
@ -1447,8 +1447,8 @@ function display_agenda_items()
} // you are a student } // you are a student
//echo "<pre>".$sql."</pre>"; //echo "<pre>".$sql."</pre>";
$result=api_sql_query($sql,__FILE__,__LINE__) or die(mysql_error()); $result=api_sql_query($sql,__FILE__,__LINE__) or die(Database::error());
$number_items=mysql_num_rows($result); $number_items=Database::num_rows($result);
/*-------------------------------------------------- /*--------------------------------------------------
@ -1469,7 +1469,7 @@ function display_agenda_items()
$export_icon = api_get_path('WEB_IMG_PATH').'export.png'; $export_icon = api_get_path('WEB_IMG_PATH').'export.png';
$export_icon_low = api_get_path('WEB_IMG_PATH').'export_low_fade.png'; $export_icon_low = api_get_path('WEB_IMG_PATH').'export_low_fade.png';
$export_icon_high = api_get_path('WEB_IMG_PATH').'export_high_fade.png'; $export_icon_high = api_get_path('WEB_IMG_PATH').'export_high_fade.png';
while ($myrow=mysql_fetch_array($result)) while ($myrow=Database::fetch_array($result))
{ {
echo "<table class=\"data_table\">\n"; echo "<table class=\"data_table\">\n";
/*-------------------------------------------------- /*--------------------------------------------------
@ -1649,7 +1649,7 @@ echo '<tr class="row_even">';
echo $td_colspan; echo $td_colspan;
echo "<a href=\"#top\"><img src=\"../img/top.gif\" border=\"0\" alt=\"to top\" align=\"right\" /></a></td></tr>"; echo "<a href=\"#top\"><img src=\"../img/top.gif\" border=\"0\" alt=\"to top\" align=\"right\" /></a></td></tr>";
echo "</table><br /><br />"; echo "</table><br /><br />";
} // end while ($myrow=mysql_fetch_array($result)) } // end while ($myrow=Database::fetch_array($result))
if(!empty($event_list)) if(!empty($event_list))
@ -1698,9 +1698,9 @@ function display_one_agenda_item($agenda_id)
AND toolitemproperties.tool='".TOOL_CALENDAR_EVENT."' AND toolitemproperties.tool='".TOOL_CALENDAR_EVENT."'
AND toolitemproperties.visibility='1' AND toolitemproperties.visibility='1'
AND agenda.id='$agenda_id'"; AND agenda.id='$agenda_id'";
$result=api_sql_query($sql,__FILE__,__LINE__) or die(mysql_error()); $result=api_sql_query($sql,__FILE__,__LINE__) or die(Database::error());
$number_items=mysql_num_rows($result); $number_items=Database::num_rows($result);
$myrow=mysql_fetch_array($result); // there should be only one item so no need for a while loop $myrow=Database::fetch_array($result); // there should be only one item so no need for a while loop
/*-------------------------------------------------- /*--------------------------------------------------
DISPLAY: NO ITEMS DISPLAY: NO ITEMS
@ -2252,7 +2252,7 @@ function show_add_form($id = '')
$TBL_LANGUAGES = Database::get_main_table(TABLE_MAIN_LANGUAGE); $TBL_LANGUAGES = Database::get_main_table(TABLE_MAIN_LANGUAGE);
$sql="SELECT isocode FROM ".$TBL_LANGUAGES." WHERE english_name='".$_SESSION["_course"]["language"]."'"; $sql="SELECT isocode FROM ".$TBL_LANGUAGES." WHERE english_name='".$_SESSION["_course"]["language"]."'";
$result_sql=api_sql_query($sql); $result_sql=api_sql_query($sql);
$isocode_language=mysql_result($result_sql,0,0); $isocode_language=Database::result($result_sql,0,0);
$oFCKeditor->Config['DefaultLanguage'] = $isocode_language; $oFCKeditor->Config['DefaultLanguage'] = $isocode_language;
$return = $oFCKeditor->CreateHtml(); $return = $oFCKeditor->CreateHtml();
@ -2316,13 +2316,13 @@ function get_agendaitems($month, $year)
DISTINCT agenda.*, item_property.* DISTINCT agenda.*, item_property.*
FROM ".$TABLEAGENDA." agenda, FROM ".$TABLEAGENDA." agenda,
".$TABLE_ITEMPROPERTY." item_property ".$TABLE_ITEMPROPERTY." item_property
WHERE agenda.id = item_property.ref ".$show_all_current." WHERE agenda.id = item_property.ref
AND MONTH(agenda.start_date)='".$month."' AND MONTH(agenda.start_date)='".$month."'
AND YEAR(agenda.start_date)='".$year."' AND YEAR(agenda.start_date)='".$year."'
AND item_property.tool='".TOOL_CALENDAR_EVENT."' AND item_property.tool='".TOOL_CALENDAR_EVENT."'
AND item_property.visibility='1' AND item_property.visibility='1'
GROUP BY agenda.id GROUP BY agenda.id
ORDER BY start_date ".$sort; ORDER BY start_date ";
} }
// if the user is not an administrator of that course // if the user is not an administrator of that course
else else
@ -2334,13 +2334,13 @@ function get_agendaitems($month, $year)
agenda.*, item_property.* agenda.*, item_property.*
FROM ".$TABLEAGENDA." agenda, FROM ".$TABLEAGENDA." agenda,
".$TABLE_ITEMPROPERTY." item_property ".$TABLE_ITEMPROPERTY." item_property
WHERE agenda.id = item_property.ref ".$show_all_current." WHERE agenda.id = item_property.ref
AND MONTH(agenda.start_date)='".$month."' AND MONTH(agenda.start_date)='".$month."'
AND YEAR(agenda.start_date)='".$year."' AND YEAR(agenda.start_date)='".$year."'
AND item_property.tool='".TOOL_CALENDAR_EVENT."' AND item_property.tool='".TOOL_CALENDAR_EVENT."'
AND ( item_property.to_user_id='".$_user['user_id']."' OR item_property.to_group_id IN (0, ".implode(", ", $group_memberships).") ) AND ( item_property.to_user_id='".$_user['user_id']."' OR item_property.to_group_id IN (0, ".implode(", ", $group_memberships).") )
AND item_property.visibility='1' AND item_property.visibility='1'
ORDER BY start_date ".$sort; ORDER BY start_date ";
} }
else else
{ {
@ -2348,23 +2348,24 @@ function get_agendaitems($month, $year)
agenda.*, item_property.* agenda.*, item_property.*
FROM ".$TABLEAGENDA." agenda, FROM ".$TABLEAGENDA." agenda,
".$TABLE_ITEMPROPERTY." item_property ".$TABLE_ITEMPROPERTY." item_property
WHERE agenda.id = item_property.ref ".$show_all_current." WHERE agenda.id = item_property.ref
AND MONTH(agenda.start_date)='".$month."' AND MONTH(agenda.start_date)='".$month."'
AND YEAR(agenda.start_date)='".$year."' AND YEAR(agenda.start_date)='".$year."'
AND item_property.tool='".TOOL_CALENDAR_EVENT."' AND item_property.tool='".TOOL_CALENDAR_EVENT."'
AND ( item_property.to_user_id='".$_user['user_id']."' OR item_property.to_group_id='0') AND ( item_property.to_user_id='".$_user['user_id']."' OR item_property.to_group_id='0')
AND item_property.visibility='1' AND item_property.visibility='1'
ORDER BY start_date ".$sort; ORDER BY start_date ";
} }
} }
$result = api_sql_query($sqlquery, __FILE__, __LINE__); $mycourse = api_get_course_info();
while ($item = mysql_fetch_array($result)) $result = api_sql_query($sqlquery, __FILE__, __LINE__);
while ($item = Database::fetch_array($result))
{ {
$agendaday = date("j",strtotime($item['start_date'])); $agendaday = date('j',strtotime($item['start_date']));
$time= date("H:i",strtotime($item['start_date'])); $time= date('H:i',strtotime($item['start_date']));
$URL = $_configuration['root_web']."main/calendar/agenda.php?cidReq=".urlencode($array_course_info["code"])."&amp;day=$agendaday&amp;month=$month&amp;year=$year#$agendaday"; // RH //Patrick Cool: to highlight the relevant agenda item $URL = $_configuration['root_web'].'main/calendar/agenda.php?cidReq='.$mycourse['id']."&amp;day=$agendaday&amp;month=$month&amp;year=$year#$agendaday"; // RH //Patrick Cool: to highlight the relevant agenda item
$items[$agendaday][$item['start_time']] .= "<i>".$time."</i> <a href=\"$URL\" title=\"".$array_course_info["name"]."\">".$array_course_info["visual_code"]."</a> ".$item['title']."<br />"; $items[$agendaday][$item['start_time']] .= '<i>'.$time.'</i> <a href="'.$URL.'" title="'.$mycourse['name'].'">'.$mycourse['official_code'].'</a> '.$item['title'].'<br />';
} }
// sorting by hour for every day // sorting by hour for every day
@ -2388,8 +2389,10 @@ function display_upcoming_events()
//databases of the courses //databases of the courses
$TABLEAGENDA = Database :: get_course_table(TABLE_AGENDA); $TABLEAGENDA = Database :: get_course_table(TABLE_AGENDA);
$TABLE_ITEMPROPERTY = Database :: get_course_table(TABLE_ITEM_PROPERTY); $TABLE_ITEMPROPERTY = Database :: get_course_table(TABLE_ITEM_PROPERTY);
$mycourse = api_get_course_info();
$myuser = api_get_user_info();
$group_memberships = GroupManager :: get_group_ids($array_course_info["db"], $_user['user_id']); $group_memberships = GroupManager :: get_group_ids($mycourse['dbName'], $myuser['user_id']);
// if the user is administrator of that course we show all the agenda items // if the user is administrator of that course we show all the agenda items
if (api_is_allowed_to_edit()) if (api_is_allowed_to_edit())
{ {
@ -2398,12 +2401,12 @@ function display_upcoming_events()
DISTINCT agenda.*, item_property.* DISTINCT agenda.*, item_property.*
FROM ".$TABLEAGENDA." agenda, FROM ".$TABLEAGENDA." agenda,
".$TABLE_ITEMPROPERTY." item_property ".$TABLE_ITEMPROPERTY." item_property
WHERE agenda.id = item_property.ref ".$show_all_current." WHERE agenda.id = item_property.ref
AND item_property.tool='".TOOL_CALENDAR_EVENT."' AND item_property.tool='".TOOL_CALENDAR_EVENT."'
AND item_property.visibility='1' AND item_property.visibility='1'
AND agenda.start_date > NOW() AND agenda.start_date > NOW()
GROUP BY agenda.id GROUP BY agenda.id
ORDER BY start_date ".$sort; ORDER BY start_date ";
} }
// if the user is not an administrator of that course // if the user is not an administrator of that course
else else
@ -2415,12 +2418,12 @@ function display_upcoming_events()
agenda.*, item_property.* agenda.*, item_property.*
FROM ".$TABLEAGENDA." agenda, FROM ".$TABLEAGENDA." agenda,
".$TABLE_ITEMPROPERTY." item_property ".$TABLE_ITEMPROPERTY." item_property
WHERE agenda.id = item_property.ref ".$show_all_current." WHERE agenda.id = item_property.ref
AND item_property.tool='".TOOL_CALENDAR_EVENT."' AND item_property.tool='".TOOL_CALENDAR_EVENT."'
AND ( item_property.to_user_id='".$_user['user_id']."' OR item_property.to_group_id IN (0, ".implode(", ", $group_memberships).") ) AND ( item_property.to_user_id='".$myuser['user_id']."' OR item_property.to_group_id IN (0, ".implode(", ", $group_memberships).") )
AND item_property.visibility='1' AND item_property.visibility='1'
AND agenda.start_date > NOW() AND agenda.start_date > NOW()
ORDER BY start_date ".$sort; ORDER BY start_date ";
} }
else else
{ {
@ -2428,21 +2431,21 @@ function display_upcoming_events()
agenda.*, item_property.* agenda.*, item_property.*
FROM ".$TABLEAGENDA." agenda, FROM ".$TABLEAGENDA." agenda,
".$TABLE_ITEMPROPERTY." item_property ".$TABLE_ITEMPROPERTY." item_property
WHERE agenda.id = item_property.ref ".$show_all_current." WHERE agenda.id = item_property.ref
AND item_property.tool='".TOOL_CALENDAR_EVENT."' AND item_property.tool='".TOOL_CALENDAR_EVENT."'
AND ( item_property.to_user_id='".$_user['user_id']."' OR item_property.to_group_id='0') AND ( item_property.to_user_id='".$myuser['user_id']."' OR item_property.to_group_id='0')
AND item_property.visibility='1' AND item_property.visibility='1'
AND agenda.start_date > NOW() AND agenda.start_date > NOW()
ORDER BY start_date ".$sort; ORDER BY start_date ";
} }
} }
$result = api_sql_query($sqlquery, __FILE__, __LINE__); $result = api_sql_query($sqlquery, __FILE__, __LINE__);
$counter = 0; $counter = 0;
while ($item = mysql_fetch_assoc($result)) while ($item = Database::fetch_array($result,'ASSOC'))
{ {
if ($counter < $number_of_items_to_show) if ($counter < $number_of_items_to_show)
{ {
echo $item['start_date'].' - '.$item['title'].'<br />'; echo $item['start_date'],' - ',$item['title'],'<br />';
$counter++; $counter++;
} }
} }
@ -2631,7 +2634,7 @@ function display_weekcalendar($agendaitems, $month, $year, $weekdaynames, $month
} }
echo "\t<td ".$class.">"; echo "\t<td ".$class.">";
echo "<span class=\"agendaitem\">".$agendaitems[date("j", $value)]."&nbsp;</span> "; echo "<span class=\"agendaitem\">".$agendaitems[date('j', $value)]."&nbsp;</span> ";
echo "</td>\n"; echo "</td>\n";
$counter ++; $counter ++;
} }
@ -2654,11 +2657,11 @@ function get_day_agendaitems($courses_dbs, $month, $year, $day)
foreach ($courses_dbs as $key => $array_course_info) foreach ($courses_dbs as $key => $array_course_info)
{ {
//databases of the courses //databases of the courses
$TABLEAGENDA = Database :: get_course_table(TABLE_AGENDA, $array_course_info["db"]); $TABLEAGENDA = Database :: get_course_table(TABLE_AGENDA, $array_course_info['db']);
$TABLE_ITEMPROPERTY = Database :: get_course_table(TABLE_ITEM_PROPERTY, $array_course_info["db"]); $TABLE_ITEMPROPERTY = Database :: get_course_table(TABLE_ITEM_PROPERTY, $array_course_info['db']);
// getting all the groups of the user for the current course // getting all the groups of the user for the current course
$group_memberships = GroupManager :: get_group_ids($array_course_info["db"], $_user['user_id']); $group_memberships = GroupManager :: get_group_ids($array_course_info['db'], $_user['user_id']);
// if the user is administrator of that course we show all the agenda items // if the user is administrator of that course we show all the agenda items
if ($array_course_info['status'] == '1') if ($array_course_info['status'] == '1')
{ {
@ -2667,12 +2670,12 @@ function get_day_agendaitems($courses_dbs, $month, $year, $day)
DISTINCT agenda.*, item_property.* DISTINCT agenda.*, item_property.*
FROM ".$TABLEAGENDA." agenda, FROM ".$TABLEAGENDA." agenda,
".$TABLE_ITEMPROPERTY." item_property ".$TABLE_ITEMPROPERTY." item_property
WHERE `agenda`.`id` = `item_property`.`ref` ".$show_all_current." WHERE agenda.id = item_property.ref
AND DAYOFMONTH(start_date)='".$day."' AND MONTH(start_date)='".$month."' AND YEAR(start_date)='".$year."' AND DAYOFMONTH(start_date)='".$day."' AND MONTH(start_date)='".$month."' AND YEAR(start_date)='".$year."'
AND `item_property`.`tool`='".TOOL_CALENDAR_EVENT."' AND item_property.tool='".TOOL_CALENDAR_EVENT."'
AND `item_property`.`visibility`='1' AND item_property.visibility='1'
GROUP BY agenda.id GROUP BY agenda.id
ORDER BY start_date ".$sort; ORDER BY start_date ";
} }
// if the user is not an administrator of that course // if the user is not an administrator of that course
else else
@ -2684,12 +2687,12 @@ function get_day_agendaitems($courses_dbs, $month, $year, $day)
agenda.*, item_property.* agenda.*, item_property.*
FROM ".$TABLEAGENDA." agenda, FROM ".$TABLEAGENDA." agenda,
".$TABLE_ITEMPROPERTY." item_property ".$TABLE_ITEMPROPERTY." item_property
WHERE `agenda`.`id` = `item_property`.`ref` ".$show_all_current." WHERE agenda.id = item_property.ref
AND DAYOFMONTH(start_date)='".$day."' AND MONTH(start_date)='".$month."' AND YEAR(start_date)='".$year."' AND DAYOFMONTH(start_date)='".$day."' AND MONTH(start_date)='".$month."' AND YEAR(start_date)='".$year."'
AND `item_property`.`tool`='".TOOL_CALENDAR_EVENT."' AND item_property.tool='".TOOL_CALENDAR_EVENT."'
AND ( `item_property`.`to_user_id`='".$_user['user_id']."' OR `item_property`.`to_group_id` IN (0, ".implode(", ", $group_memberships).") ) AND ( item_property.to_user_id='".$_user['user_id']."' OR `item_property`.`to_group_id` IN (0, ".implode(", ", $group_memberships).") )
AND `item_property`.`visibility`='1' AND item_property.visibility='1'
ORDER BY start_date ".$sort; ORDER BY start_date ";
} }
else else
{ {
@ -2697,20 +2700,20 @@ function get_day_agendaitems($courses_dbs, $month, $year, $day)
agenda.*, item_property.* agenda.*, item_property.*
FROM ".$TABLEAGENDA." agenda, FROM ".$TABLEAGENDA." agenda,
".$TABLE_ITEMPROPERTY." item_property ".$TABLE_ITEMPROPERTY." item_property
WHERE `agenda`.`id` = `item_property`.`ref` ".$show_all_current." WHERE agenda.id = item_property.ref
AND DAYOFMONTH(start_date)='".$day."' AND MONTH(start_date)='".$month."' AND YEAR(start_date)='".$year."' AND DAYOFMONTH(start_date)='".$day."' AND MONTH(start_date)='".$month."' AND YEAR(start_date)='".$year."'
AND `item_property`.`tool`='".TOOL_CALENDAR_EVENT."' AND item_property.tool='".TOOL_CALENDAR_EVENT."'
AND ( `item_property`.`to_user_id`='".$_user['user_id']."' OR `item_property`.`to_group_id`='0') AND ( item_property.to_user_id='".$_user['user_id']."' OR item_property.to_group_id='0')
AND `item_property`.`visibility`='1' AND item_property.visibility='1'
ORDER BY start_date ".$sort; ORDER BY start_date ";
} }
} }
//$sqlquery = "SELECT * FROM $agendadb WHERE DAYOFMONTH(day)='$day' AND month(day)='$month' AND year(day)='$year'"; //$sqlquery = "SELECT * FROM $agendadb WHERE DAYOFMONTH(day)='$day' AND month(day)='$month' AND year(day)='$year'";
//echo "abc"; //echo "abc";
//echo $sqlquery; //echo $sqlquery;
$result = api_sql_query($sqlquery, __FILE__, __LINE__); $result = api_sql_query($sqlquery, __FILE__, __LINE__);
//echo mysql_num_rows($result); //echo Database::num_rows($result);
while ($item = mysql_fetch_array($result)) while ($item = Database::fetch_array($result))
{ {
// in the display_daycalendar function we use $i (ranging from 0 to 47) for each halfhour // in the display_daycalendar function we use $i (ranging from 0 to 47) for each halfhour
// we want to know for each agenda item for this day to wich halfhour it must be assigned // we want to know for each agenda item for this day to wich halfhour it must be assigned
@ -2735,7 +2738,7 @@ function get_day_agendaitems($courses_dbs, $month, $year, $day)
} }
//$URL = $_configuration['root_web'].$mycours["dir"]."/"; //$URL = $_configuration['root_web'].$mycours["dir"]."/";
$URL = $_configuration['root_web']."main/calendar/agenda.php?cidReq=".urlencode($array_course_info["code"])."&amp;day=$day&amp;month=$month&amp;year=$year#$day"; // RH //Patrick Cool: to highlight the relevant agenda item $URL = $_configuration['root_web'].'main/calendar/agenda.php?cidReq='.urlencode($array_course_info["code"])."&amp;day=$day&amp;month=$month&amp;year=$year#$day"; // RH //Patrick Cool: to highlight the relevant agenda item
$items[$halfhour][] .= "<i>".$hours.":".$minutes."</i> <a href=\"$URL\" title=\"".$array_course_info['name']."\">".$agenda_link."</a> ".$item['title']."<br />"; $items[$halfhour][] .= "<i>".$hours.":".$minutes."</i> <a href=\"$URL\" title=\"".$array_course_info['name']."\">".$agenda_link."</a> ".$item['title']."<br />";
} }
} }
@ -2837,7 +2840,7 @@ function get_week_agendaitems($courses_dbs, $month, $year, $week = '')
// AND (MONTH(day)>='$start_month' AND MONTH(day)<='$end_month') // AND (MONTH(day)>='$start_month' AND MONTH(day)<='$end_month')
// AND (YEAR(day)>='$start_year' AND YEAR(day)<='$end_year')"; // AND (YEAR(day)>='$start_year' AND YEAR(day)<='$end_year')";
$result = api_sql_query($sqlquery, __FILE__, __LINE__); $result = api_sql_query($sqlquery, __FILE__, __LINE__);
while ($item = mysql_fetch_array($result)) while ($item = Database::fetch_array($result))
{ {
$agendaday = date("j",strtotime($item['start_date'])); $agendaday = date("j",strtotime($item['start_date']));
$time= date("H:i",strtotime($item['start_date'])); $time= date("H:i",strtotime($item['start_date']));

@ -105,13 +105,13 @@ function get_myagendaitems($courses_dbs, $month, $year)
agenda.*, item_property.* agenda.*, item_property.*
FROM ".$TABLEAGENDA." agenda, FROM ".$TABLEAGENDA." agenda,
".$TABLE_ITEMPROPERTY." item_property ".$TABLE_ITEMPROPERTY." item_property
WHERE `agenda`.`id` = `item_property`.`ref` ".$show_all_current." WHERE agenda.id = item_property.ref
AND MONTH(`agenda`.`start_date`)='".$month."' AND MONTH(agenda.start_date)='".$month."'
AND YEAR(`agenda`.`start_date`)='".$year."' AND YEAR(agenda.start_date)='".$year."'
AND `item_property`.`tool`='".TOOL_CALENDAR_EVENT."' AND item_property.tool='".TOOL_CALENDAR_EVENT."'
AND ( `item_property`.`to_user_id`='".$_user['user_id']."' OR `item_property`.`to_group_id` IN (0, ".implode(", ", $group_memberships).") ) AND ( item_property.to_user_id='".$_user['user_id']."' OR item_property.to_group_id IN (0, ".implode(", ", $group_memberships).") )
AND `item_property`.`visibility`='1' AND item_property.visibility='1'
ORDER BY start_date ".$sort; ORDER BY start_date ";
} }
else else
{ {
@ -119,18 +119,18 @@ function get_myagendaitems($courses_dbs, $month, $year)
agenda.*, item_property.* agenda.*, item_property.*
FROM ".$TABLEAGENDA." agenda, FROM ".$TABLEAGENDA." agenda,
".$TABLE_ITEMPROPERTY." item_property ".$TABLE_ITEMPROPERTY." item_property
WHERE `agenda`.`id` = `item_property`.`ref` ".$show_all_current." WHERE agenda.id = item_property.ref
AND MONTH(`agenda`.`start_date`)='".$month."' AND MONTH(agenda.start_date)='".$month."'
AND YEAR(`agenda`.`start_date`)='".$year."' AND YEAR(agenda.start_date)='".$year."'
AND `item_property`.`tool`='".TOOL_CALENDAR_EVENT."' AND item_property.tool='".TOOL_CALENDAR_EVENT."'
AND ( `item_property`.`to_user_id`='".$_user['user_id']."' OR `item_property`.`to_group_id`='0') AND ( item_property.to_user_id='".$_user['user_id']."' OR item_property.to_group_id='0')
AND `item_property`.`visibility`='1' AND item_property.visibility='1'
ORDER BY start_date ".$sort; ORDER BY start_date ";
} }
} }
$result = api_sql_query($sqlquery, __FILE__, __LINE__); $result = api_sql_query($sqlquery, __FILE__, __LINE__);
while ($item = mysql_fetch_array($result)) while ($item = Database::fetch_array($result))
{ {
$agendaday = date("j",strtotime($item['start_date'])); $agendaday = date("j",strtotime($item['start_date']));
if(!isset($items[$agendaday])){$items[$agendaday]=array();} if(!isset($items[$agendaday])){$items[$agendaday]=array();}
@ -332,10 +332,10 @@ function show_new_personal_item_form($id = "")
{ {
$sql = "SELECT * FROM ".$tbl_personal_agenda." WHERE user='".$_user['user_id']."' AND id='".$id."'"; $sql = "SELECT * FROM ".$tbl_personal_agenda." WHERE user='".$_user['user_id']."' AND id='".$id."'";
$result = api_sql_query($sql, __FILE__, __LINE__); $result = api_sql_query($sql, __FILE__, __LINE__);
$aantal = mysql_num_rows($result); $aantal = Database::num_rows($result);
if ($aantal <> 0) if ($aantal <> 0)
{ {
$row = mysql_fetch_array($result); $row = Database::fetch_array($result);
$year = substr($row['date'], 0, 4); $year = substr($row['date'], 0, 4);
$month = substr($row['date'], 5, 2); $month = substr($row['date'], 5, 2);
$day = substr($row['date'], 8, 2); $day = substr($row['date'], 8, 2);
@ -514,7 +514,7 @@ function get_courses_of_user()
WHERE course.code = course_rel_user.course_code WHERE course.code = course_rel_user.course_code
AND course_rel_user.user_id = '".$_user['user_id']."'"; AND course_rel_user.user_id = '".$_user['user_id']."'";
$result = api_sql_query($sql_select_courses); $result = api_sql_query($sql_select_courses);
while ($row = mysql_fetch_array($result)) while ($row = Database::fetch_array($result))
{ {
// we only need the database name of the course // we only need the database name of the course
$courses[] = array ("db" => $row['db'], "code" => $row['k'], "visual_code" => $row['vc'], "title" => $row['i'], "directory" => $row['dir'], "status" => $row['status']); $courses[] = array ("db" => $row['db'], "code" => $row['k'], "visual_code" => $row['vc'], "title" => $row['i'], "directory" => $row['dir'], "status" => $row['status']);
@ -565,7 +565,7 @@ function get_personal_agenda_items($agendaitems, $day = "", $month = "", $year =
//echo $type."<p>"; //echo $type."<p>";
//echo "<pre>".$sql."</pre>"; //echo "<pre>".$sql."</pre>";
$result = api_sql_query($sql, __FILE__, __LINE__); $result = api_sql_query($sql, __FILE__, __LINE__);
while ($item = mysql_fetch_array($result)) while ($item = Database::fetch_array($result))
{ {
// we break the date field in the database into a date and a time part // we break the date field in the database into a date and a time part
$agenda_db_date = explode(" ", $item[date]); $agenda_db_date = explode(" ", $item[date]);
@ -747,7 +747,7 @@ function delete_personal_agenda($id)
{ {
$sql = "SELECT * FROM ".$tbl_personal_agenda." WHERE user='".$_user['user_id']."' AND id='".$id."'"; $sql = "SELECT * FROM ".$tbl_personal_agenda." WHERE user='".$_user['user_id']."' AND id='".$id."'";
$result = api_sql_query($sql, __FILE__, __LINE__); $result = api_sql_query($sql, __FILE__, __LINE__);
$aantal = mysql_num_rows($result); $aantal = Database::num_rows($result);
if ($aantal <> 0) if ($aantal <> 0)
{ {
$sql = "DELETE FROM ".$tbl_personal_agenda." WHERE user='".$_user['user_id']."' AND id='".$id."'"; $sql = "DELETE FROM ".$tbl_personal_agenda." WHERE user='".$_user['user_id']."' AND id='".$id."'";

Loading…
Cancel
Save