[svn r9984] replace $_uid with $_user['user_id']

skala
Patrick Cool 19 years ago
parent dcc71cb73d
commit abedd38515
  1. 36
      main/calendar/agenda.inc.php
  2. 58
      main/calendar/myagenda.php

@ -1,4 +1,4 @@
<?php //$Id: agenda.inc.php 9414 2006-10-10 12:59:14Z sbil136 $
<?php //$Id: agenda.inc.php 9984 2006-11-15 00:35:05Z pcool $
/*
==============================================================================
Dokeos - elearning and course management software
@ -63,14 +63,14 @@ $MonthsLong = array (get_lang("JanuaryLong"), get_lang("FebruaryLong"), get_lang
function get_kalender_items($month, $year)
{
global $courseTablePrefix, $dbGlu;
global $_uid, $_course;
global $_user, $_course;
global $is_allowedToEdit;
// database variables
$TABLEAGENDA=Database::get_course_table(AGENDA_TABLE);
$TABLE_ITEM_PROPERTY=Database::get_course_table(LAST_TOOL_EDIT_TABLE);
$group_memberships=GroupManager::get_group_ids($_course['dbName'], $_uid);
$group_memberships=GroupManager::get_group_ids($_course['dbName'], $_user['user_id']);
if (is_allowed_to_edit() OR api_get_course_setting('allow_user_edit_agenda'))
{
@ -98,7 +98,7 @@ function get_kalender_items($month, $year)
WHERE `agenda`.`id` = `toolitemproperties`.`ref` ".$show_all_current."
AND MONTH(`agenda`.`start_date`)='".$month."'
AND `toolitemproperties`.`tool`='".TOOL_CALENDAR_EVENT."'
AND ( `toolitemproperties`.`to_user_id`='".$_uid."' OR `toolitemproperties`.`to_group_id` IN (0, ".implode(", ", $group_memberships).") )
AND ( `toolitemproperties`.`to_user_id`='".$_user['user_id']."' OR `toolitemproperties`.`to_group_id` IN (0, ".implode(", ", $group_memberships).") )
AND `toolitemproperties`.`visibility`='1'
ORDER BY start_date ".$sort;
}
@ -110,7 +110,7 @@ function get_kalender_items($month, $year)
WHERE `agenda`.`id` = `toolitemproperties`.`ref` ".$show_all_current."
AND MONTH(`agenda`.`start_date`)='".$month."'
AND `toolitemproperties`.`tool`='".TOOL_CALENDAR_EVENT."'
AND ( `toolitemproperties`.`to_user_id`='".$_uid."' OR `toolitemproperties`.`to_group_id`='0')
AND ( `toolitemproperties`.`to_user_id`='".$_user['user_id']."' OR `toolitemproperties`.`to_group_id`='0')
AND `toolitemproperties`.`visibility`='1'
ORDER BY start_date ".$sort;
}
@ -604,7 +604,7 @@ function construct_selected_select_form($group_list=null, $user_list=null,$to_al
function store_new_agenda_item()
{
global $TABLEAGENDA;
global $_uid;
global $_user;
// some filtering of the input data
$title=strip_tags(trim($_POST['title'])); // no html allowed in the title
@ -633,7 +633,7 @@ if (($_SESSION['allow_individual_calendar']=="show" and !is_null($to))or (!empty
{
foreach ($send_to['groups'] as $group)
{
api_item_property_update($_course, TOOL_CALENDAR_EVENT, $last_id,"AgendaAdded", $_uid, $group,'',$start_visible, $end_visible);
api_item_property_update($_course, TOOL_CALENDAR_EVENT, $last_id,"AgendaAdded", $_user['user_id'], $group,'',$start_visible, $end_visible);
}
}
// storing the selected users
@ -641,13 +641,13 @@ if (($_SESSION['allow_individual_calendar']=="show" and !is_null($to))or (!empty
{
foreach ($send_to['users'] as $user)
{
api_item_property_update($_course, TOOL_CALENDAR_EVENT, $last_id,"AgendaAdded", $_uid,'',$user, $start_visible,$end_visible);
api_item_property_update($_course, TOOL_CALENDAR_EVENT, $last_id,"AgendaAdded", $_user['user_id'],'',$user, $start_visible,$end_visible);
}
}
}
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", $_uid, '','',$start_visible,$end_visible);
api_item_property_update($_course, TOOL_CALENDAR_EVENT, $last_id,"AgendaAdded", $_user['user_id'], '','',$start_visible,$end_visible);
}
// storing the resources
@ -1109,7 +1109,7 @@ function get_agenda_item($id)
*/
function store_edited_agenda_item()
{
global $_uid;
global $_user;
// database definitions
$TABLE_ITEM_PROPERTY = Database::get_course_table(LAST_TOOL_EDIT_TABLE);
@ -1141,7 +1141,7 @@ function store_edited_agenda_item()
{
foreach ($send_to['groups'] as $group)
{
api_item_property_update($_course, TOOL_CALENDAR_EVENT, $id,"AgendaModified", $_uid, $group,'',$start_visible, $end_visible);
api_item_property_update($_course, TOOL_CALENDAR_EVENT, $id,"AgendaModified", $_user['user_id'], $group,'',$start_visible, $end_visible);
}
}
// storing the selected users
@ -1149,13 +1149,13 @@ function store_edited_agenda_item()
{
foreach ($send_to['users'] as $user)
{
api_item_property_update($_course, TOOL_CALENDAR_EVENT, $id,"AgendaModified", $_uid,'',$user, $start_visible,$end_visible);
api_item_property_update($_course, TOOL_CALENDAR_EVENT, $id,"AgendaModified", $_user['user_id'],'',$user, $start_visible,$end_visible);
}
}
}
else // the message is sent to everyone, so we set the group to 0
{
api_item_property_update($_course, TOOL_CALENDAR_EVENT, $id,"AgendaModified", $_uid, '','',$start_visible,$end_visible);
api_item_property_update($_course, TOOL_CALENDAR_EVENT, $id,"AgendaModified", $_user['user_id'], '','',$start_visible,$end_visible);
}
} //if ($edit_result=true)
@ -1256,10 +1256,10 @@ function display_agenda_items()
global $DaysShort, $DaysLong, $MonthsLong;
global $is_courseAdmin;
global $dateFormatLong, $timeNoSecFormat;
global $_uid;
global $_user;
// getting the group memberships
$group_memberships=GroupManager::get_group_ids($_course['dbName'],$_uid);
$group_memberships=GroupManager::get_group_ids($_course['dbName'],$_user['user_id']);
// getting the name of the groups
$group_names=get_course_groups();
@ -1280,7 +1280,7 @@ function display_agenda_items()
}
// by default we use the id of the current user. The course administrator can see the agenda of other users by using the user / group filter
$user_id=$_uid;
$user_id=$_user['user_id'];
if ($_SESSION['user']!==null)
{
$user_id=$_SESSION['user'];
@ -1391,7 +1391,7 @@ function display_agenda_items()
}
else
{
if ($_uid)
if ($_user['user_id'])
{
$sql="SELECT
agenda.*, toolitemproperties.*
@ -1617,7 +1617,7 @@ function display_one_agenda_item($agenda_id)
global $DaysShort, $DaysLong, $MonthsLong;
global $is_courseAdmin;
global $dateFormatLong, $timeNoSecFormat;
global $_uid;
global $_user;
//echo "displaying agenda items";

@ -197,7 +197,7 @@ if ($_GET['action'] == "delete" AND $_GET['id'])
/* ==============================================================================
OUTPUT
============================================================================== */
if (isset ($_uid))
if (isset ($_user['user_id']))
{
// getting all the courses that this user is subscribed to
$courses_dbs = get_courses_of_user();
@ -320,7 +320,7 @@ Display :: display_footer();
function get_agendaitems($rootWeb, $courses_dbs, $month, $year)
{
global $courseTablePrefix, $dbGlu;
global $_uid;
global $_user;
$items = array ();
// get agenda-items for every course
foreach ($courses_dbs as $key => $array_course_info)
@ -329,7 +329,7 @@ function get_agendaitems($rootWeb, $courses_dbs, $month, $year)
$TABLEAGENDA = Database :: get_course_table(AGENDA_TABLE, $array_course_info["db"]);
$TABLE_ITEMPROPERTY = Database :: get_course_table(LAST_TOOL_EDIT_TABLE, $array_course_info["db"]);
$group_memberships = GroupManager :: get_group_ids($array_course_info["db"], $_uid);
$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 ($array_course_info['status'] == '1')
{
@ -359,7 +359,7 @@ function get_agendaitems($rootWeb, $courses_dbs, $month, $year)
AND MONTH(`agenda`.`start_date`)='".$month."'
AND YEAR(`agenda`.`start_date`)='".$year."'
AND `item_property`.`tool`='".TOOL_CALENDAR_EVENT."'
AND ( `item_property`.`to_user_id`='".$_uid."' 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'
ORDER BY start_date ".$sort;
}
@ -373,7 +373,7 @@ function get_agendaitems($rootWeb, $courses_dbs, $month, $year)
AND MONTH(`agenda`.`start_date`)='".$month."'
AND YEAR(`agenda`.`start_date`)='".$year."'
AND `item_property`.`tool`='".TOOL_CALENDAR_EVENT."'
AND ( `item_property`.`to_user_id`='".$_uid."' 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'
ORDER BY start_date ".$sort;
}
@ -703,7 +703,7 @@ function display_daycalendar($agendaitems, $day, $month, $year, $weekdaynames, $
function get_day_agendaitems($rootWeb, $courses_dbs, $month, $year, $day)
{
global $courseTablePrefix, $dbGlu;
global $_uid;
global $_user;
$items = array ();
// get agenda-items for every course
@ -715,7 +715,7 @@ function get_day_agendaitems($rootWeb, $courses_dbs, $month, $year, $day)
$TABLE_ITEMPROPERTY = Database :: get_course_table(LAST_TOOL_EDIT_TABLE, $array_course_info["db"]);
// getting all the groups of the user for the current course
$group_memberships = GroupManager :: get_group_ids($array_course_info["db"], $_uid);
$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 ($array_course_info['status'] == '1')
{
@ -743,7 +743,7 @@ function get_day_agendaitems($rootWeb, $courses_dbs, $month, $year, $day)
WHERE `agenda`.`id` = `item_property`.`ref` ".$show_all_current."
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`.`to_user_id`='".$_uid."' 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'
ORDER BY start_date ".$sort;
}
@ -756,7 +756,7 @@ function get_day_agendaitems($rootWeb, $courses_dbs, $month, $year, $day)
WHERE `agenda`.`id` = `item_property`.`ref` ".$show_all_current."
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`.`to_user_id`='".$_uid."' 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'
ORDER BY start_date ".$sort;
}
@ -805,7 +805,7 @@ function get_week_agendaitems($rootWeb, $courses_dbs, $month, $year, $week = '')
{
global $courseTablePrefix, $dbGlu;
global $TABLEAGENDA, $TABLE_ITEMPROPERTY;
global $_uid;
global $_user;
$items = array ();
// The default value of the week
if ($week == '')
@ -862,7 +862,7 @@ function get_week_agendaitems($rootWeb, $courses_dbs, $month, $year, $week = '')
$TABLE_ITEMPROPERTY = Database :: get_course_table(LAST_TOOL_EDIT_TABLE, $array_course_info["db"]);
// getting all the groups of the user for the current course
$group_memberships = GroupManager :: get_group_ids($array_course_info["db"], $_uid);
$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 ($array_course_info['status'] == '1')
@ -891,7 +891,7 @@ function get_week_agendaitems($rootWeb, $courses_dbs, $month, $year, $week = '')
WHERE `agenda`.`id` = `item_property`.`ref` ".$show_all_current."
AND start_date>='".$start_filter."' AND start_date<='".$end_filter."'
AND `item_property`.`tool`='".TOOL_CALENDAR_EVENT."'
AND ( `item_property`.`to_user_id`='".$_uid."' 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'
ORDER BY start_date ".$sort;
}
@ -904,7 +904,7 @@ function get_week_agendaitems($rootWeb, $courses_dbs, $month, $year, $week = '')
WHERE `agenda`.`id` = `item_property`.`ref` ".$show_all_current."
AND start_date>='".$start_filter."' AND start_date<='".$end_filter."'
AND `item_property`.`tool`='".TOOL_CALENDAR_EVENT."'
AND ( `item_property`.`to_user_id`='".$_uid."' 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'
ORDER BY start_date ".$sort;
}
@ -946,7 +946,7 @@ function show_new_item_form($id = "")
{
global $year, $MonthsLong;
global $TABLE_PERSONAL_AGENDA;
global $_uid;
global $_user;
// we construct the default time and date data (used if we are not editing a personal agenda item)
$today = getdate();
$day = $today['mday'];
@ -959,7 +959,7 @@ function show_new_item_form($id = "")
// to overwrite the default information)
if ($id <> "")
{
$sql = "SELECT * FROM ".$TABLE_PERSONAL_AGENDA." WHERE user='".$_uid."' AND id='".$id."'";
$sql = "SELECT * FROM ".$TABLE_PERSONAL_AGENDA." WHERE user='".$_user['user_id']."' AND id='".$id."'";
$result = api_sql_query($sql, __FILE__, __LINE__);
$aantal = mysql_num_rows($result);
if ($aantal <> 0)
@ -1114,16 +1114,16 @@ function show_new_item_form($id = "")
function store_personal_item($day, $month, $year, $hour, $minute, $title, $content, $id = "")
{
global $TABLE_PERSONAL_AGENDA;
global $_uid;
global $_user;
//constructing the date
$date = $year."-".$month."-".$day." ".$hour.":".$minute.":00";
if ($id <> "")
{ // we are updating
$sql = "UPDATE ".$TABLE_PERSONAL_AGENDA." SET user='".$_uid."', title='".$title."', text='".$content."', date='".$date."' WHERE id='".$id."'";
$sql = "UPDATE ".$TABLE_PERSONAL_AGENDA." SET user='".$_user['user_id']."', title='".$title."', text='".$content."', date='".$date."' WHERE id='".$id."'";
}
else
{ // we are adding a new item
$sql = "INSERT INTO $TABLE_PERSONAL_AGENDA (user, title, text, date) VALUES ('$_uid','$title', '$content', '$date')";
$sql = "INSERT INTO $TABLE_PERSONAL_AGENDA (user, title, text, date) VALUES ('".$_user['user_id']."','$title', '$content', '$date')";
}
$result = api_sql_query($sql, __FILE__, __LINE__);
}
@ -1136,13 +1136,13 @@ function get_courses_of_user()
{
global $TABLECOURS;
global $TABLECOURSUSER;
global $_uid;
global $_user;
$sql_select_courses = "SELECT course.code k, course.visual_code vc,
course.title i, course.tutor_name t, course.db_name db, course.directory dir, course_rel_user.status status
FROM $TABLECOURS course,
$TABLECOURSUSER course_rel_user
WHERE course.code = course_rel_user.course_code
AND course_rel_user.user_id = '$_uid'";
AND course_rel_user.user_id = '".$_user['user_id']."'";
$result = api_sql_query($sql_select_courses);
while ($row = mysql_fetch_array($result))
{
@ -1158,11 +1158,11 @@ function get_courses_of_user()
function get_personal_agendaitems($rootWeb, $agendaitems, $day = "", $month = "", $year = "", $week = "", $type)
{
global $TABLE_PERSONAL_AGENDA;
global $_uid;
global $_user;
// 1. creating the SQL statement for getting the personal agenda items in MONTH view
if ($type == "month_view" or $type == "") // we are in month view
{
$sql = "SELECT * FROM ".$TABLE_PERSONAL_AGENDA." WHERE user='".$_uid."' and MONTH(date)='".$month."' AND YEAR(date) = '".$year."' ORDER BY date ASC";
$sql = "SELECT * FROM ".$TABLE_PERSONAL_AGENDA." WHERE user='".$_user['user_id']."' and MONTH(date)='".$month."' AND YEAR(date) = '".$year."' ORDER BY date ASC";
}
// 2. creating the SQL statement for getting the personal agenda items in WEEK view
if ($type == "week_view") // we are in week view
@ -1177,7 +1177,7 @@ function get_personal_agendaitems($rootWeb, $agendaitems, $day = "", $month = ""
// in sql statements you have to use year-month-day for date calculations
$start_filter = $start_year."-".$start_month."-".$start_day;
$end_filter = $end_year."-".$end_month."-".$end_day;
$sql = " SELECT * FROM ".$TABLE_PERSONAL_AGENDA." WHERE user='".$_uid."'
$sql = " SELECT * FROM ".$TABLE_PERSONAL_AGENDA." WHERE user='".$_user['user_id']."'
AND date>='".$start_filter."' AND date<='".$end_filter."'";
}
// 3. creating the SQL statement for getting the personal agenda items in DAY view
@ -1186,7 +1186,7 @@ function get_personal_agendaitems($rootWeb, $agendaitems, $day = "", $month = ""
// we could use mysql date() function but this is only available from 4.1 and higher
$start_filter = $year."-".$month."-".$day." 00:00:01";
$end_filter = $year."-".$month."-".$day." 23:59:59";
$sql = " SELECT * FROM ".$TABLE_PERSONAL_AGENDA." WHERE user='".$_uid."' AND date>='".$start_filter."' AND date<='".$end_filter."'";
$sql = " SELECT * FROM ".$TABLE_PERSONAL_AGENDA." WHERE user='".$_user['user_id']."' AND date>='".$start_filter."' AND date<='".$end_filter."'";
}
//echo "day:".$day."/";
//echo "month:".$month."/";
@ -1249,9 +1249,9 @@ function show_personal_agenda()
{
global $TABLE_PERSONAL_AGENDA;
global $MonthsLong;
global $_uid;
global $_user;
// The SQL statement that retrieves all the personal agenda items of this user
$sql = "SELECT * FROM ".$TABLE_PERSONAL_AGENDA." WHERE user='".$_uid."' ORDER BY date DESC";
$sql = "SELECT * FROM ".$TABLE_PERSONAL_AGENDA." WHERE user='".$_user['user_id']."' ORDER BY date DESC";
$result = api_sql_query($sql, __FILE__, __LINE__);
// variable initialisation
$month_bar = "";
@ -1339,15 +1339,15 @@ function show_personal_agenda()
function delete_personal_agenda($id)
{
global $TABLE_PERSONAL_AGENDA;
global $_uid;
global $_user;
if ($id <> '')
{
$sql = "SELECT * FROM ".$TABLE_PERSONAL_AGENDA." WHERE user='".$_uid."' AND id='".$id."'";
$sql = "SELECT * FROM ".$TABLE_PERSONAL_AGENDA." WHERE user='".$_user['user_id']."' AND id='".$id."'";
$result = api_sql_query($sql, __FILE__, __LINE__);
$aantal = mysql_num_rows($result);
if ($aantal <> 0)
{
$sql = "DELETE FROM ".$TABLE_PERSONAL_AGENDA." WHERE user='".$_uid."' AND id='".$id."'";
$sql = "DELETE FROM ".$TABLE_PERSONAL_AGENDA." WHERE user='".$_user['user_id']."' AND id='".$id."'";
$result = api_sql_query($sql, __FILE__, __LINE__);
}
}

Loading…
Cancel
Save