Replacing Database::get_user_info_from_id() (deprecated function) with api_get_user_id().

1.9.x
Julio Montoya 12 years ago
parent bb6ae762ec
commit 8a3f022059
  1. 8
      main/document/document.inc.php
  2. 8
      main/group/group_space.php
  3. 6
      main/inc/lib/banner.lib.php
  4. 4
      main/inc/lib/course.lib.php
  5. 1
      main/inc/lib/database.lib.php
  6. 4
      main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/inc/class.manager.php
  7. 6
      main/tracking/userLog.php
  8. 236
      main/tracking/userlogCSV.php
  9. 22
      main/wiki/index.php
  10. 34
      main/wiki/wiki.inc.php
  11. 6
      tests/main/inc/lib/database.lib.test.php

@ -186,8 +186,8 @@ function create_document_link($document_data, $show_as_icon = false, $counter =
} elseif (strstr($path, 'shared_folder_session_')) {
$tooltip_title_alt = get_lang('UserFolders') . ' (' . api_get_session_name(api_get_session_id()) . ')';
} elseif (strstr($tooltip_title, 'sf_user_')) {
$userinfo = Database::get_user_info_from_id(substr($tooltip_title, 8));
$tooltip_title_alt = get_lang('UserFolder') . ' ' . api_get_person_name($userinfo['firstname'], $userinfo['lastname']);
$userinfo = api_get_user_info(substr($tooltip_title, 8));
$tooltip_title_alt = get_lang('UserFolder') . ' ' . $userinfo['complete_name'];
} elseif ($path == '/chat_files') {
$tooltip_title_alt = get_lang('ChatFiles');
} elseif ($path == '/learning_path') {
@ -379,7 +379,7 @@ function build_document_icon_tag($type, $path) {
$basename = get_lang('UserFolders');
}
} elseif (strstr($basename, 'sf_user_')) {
$userinfo = Database::get_user_info_from_id(substr($basename, 8));
$userinfo = api_get_user_info(substr($basename, 8));
$image_path = UserManager::get_user_picture_path_by_id(substr($basename, 8), 'web', false, true);
if ($image_path['file'] == 'unknown.jpg') {
@ -390,7 +390,7 @@ function build_document_icon_tag($type, $path) {
$icon = $image_path['dir'] . $image_path['file'];
}
$basename = get_lang('UserFolder') . ' ' . api_get_person_name($userinfo['firstname'], $userinfo['lastname']);
$basename = get_lang('UserFolder') . ' ' . $userinfo['complete_name'];
} elseif (strstr($path, 'shared_folder_session_')) {
if ($is_allowed_to_edit) {
$basename = '***(' . api_get_session_name($current_session_id) . ')*** ' . get_lang('HelpUsersFolder');

@ -301,7 +301,7 @@ if (count($tutors) == 0) {
isset($origin) ? $my_origin = $origin:$my_origin='';
$tutor_info .= '<ul class="thumbnails">';
foreach ($tutors as $index => $tutor) {
$tab_user_info = Database::get_user_info_from_id($tutor['user_id']);
$tab_user_info = api_get_user_info($tutor['user_id']);
$username = api_htmlentities(sprintf(get_lang('LoginX'), $tab_user_info['username']), ENT_QUOTES);
$image_path = UserManager::get_user_picture_path_by_id($tutor['user_id'], 'web', false, true);
$image_repository = $image_path['dir'];
@ -477,11 +477,11 @@ function email_filter($email) {
*/
function user_icon_filter($user_id) {
global $origin;
$userinfo = Database::get_user_info_from_id($user_id);
$userinfo = api_get_user_info($user_id);
$image_path = UserManager::get_user_picture_path_by_id($user_id, 'web', false, true);
$image_repository = $image_path['dir'];
$existing_image = $image_path['file'];
$photo = '<center><img src="'.$image_repository.$existing_image.'" alt="'.api_get_person_name($userinfo['firstname'], $userinfo['lastname']).'" width="22" height="22" title="'.api_get_person_name($userinfo['firstname'], $userinfo['lastname']).'" /></center>';
$photo = '<center><img src="'.$image_repository.$existing_image.'" alt="'.$userinfo['complete_name'].'" width="22" height="22" title="'.$userinfo['complete_name'].'" /></center>';
return '<a href="../user/userInfo.php?origin='.$origin.'&amp;uInfo='.$user_id.'">'.$photo;
}
@ -496,7 +496,7 @@ function user_icon_filter($user_id) {
* @return string HTML link
*/
function user_name_filter($name, $url_params, $row) {
$tab_user_info = Database::get_user_info_from_id($row[0]);
$tab_user_info = api_get_user_info($row[0]);
$username = api_htmlentities(sprintf(get_lang('LoginX'), $tab_user_info['username']), ENT_QUOTES);
return '<a href="../user/userInfo.php?uInfo='.$row[0].'&amp;'.$url_params.'" title="'.$username.'">'.$name.'</a>';
}

@ -418,7 +418,7 @@ function return_menu() {
if (api_get_user_id() && !api_is_anonymous()) {
$lis .= $open_mtloggedin;
} else {
$lis .= $open;
$lis .= $open;
}
}
}
@ -516,8 +516,8 @@ function return_breadcrumb($interbreadcrumb, $language_file, $nameTools) {
} elseif(strstr($breadcrumb_step['name'], 'shared_folder_session_')) {
$navigation_item['title'] = get_lang('UserFolders');
} elseif(strstr($breadcrumb_step['name'], 'sf_user_')) {
$userinfo = Database::get_user_info_from_id(substr($breadcrumb_step['name'], 8));
$navigation_item['title'] = api_get_person_name($userinfo['firstname'], $userinfo['lastname']);
$userinfo = api_get_user_info(substr($breadcrumb_step['name'], 8));
$navigation_item['title'] = $userinfo['complete_name'];
} elseif($breadcrumb_step['name'] == 'chat_files') {
$navigation_item['title'] = get_lang('ChatFiles');
} elseif($breadcrumb_step['name'] == 'images') {

@ -1570,7 +1570,7 @@ class CourseManager
$rs = Database::query('SELECT id_user FROM '.Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER).
' WHERE id_session="'.$session_id.'" AND course_code="'.$course_code.'" AND status = 2');
while ($user = Database::fetch_array($rs)) {
$user_info = Database::get_user_info_from_id($user['id_user']);
$user_info = api_get_user_info($user['id_user']);
$user_info['status'] = $user['status'];
$user_info['role'] = $user['role'];
$user_info['tutor_id'] = $user['tutor_id'];
@ -1581,7 +1581,7 @@ class CourseManager
// We get the session coach.
$rs = Database::query('SELECT id_coach FROM '.Database::get_main_table(TABLE_MAIN_SESSION).' WHERE id="'.$session_id.'"');
$session_id_coach = Database::result($rs, 0, 'id_coach');
$user_info = Database::get_user_info_from_id($session_id_coach);
$user_info = api_get_user_info($session_id_coach);
$user_info['status'] = $user['status'];
$user_info['role'] = $user['role'];
$user_info['tutor_id'] = $user['tutor_id'];

@ -236,6 +236,7 @@ class Database {
* @author Patrick Cool <patrick.cool@UGent.be>, expanded to get info for any user
* @author Roan Embrechts, first version + converted to Database API
* @version 30 September 2004
* @deprecated use api_get_user_info();
* @desc find all the information about a specified user. Without parameter this is the current user.
* @todo shouldn't this be in the user.lib.php script?
*/

@ -96,8 +96,8 @@ class manager
if (sizeof($folderInfo)) {
//for Chamilo in a name folder, replace num user by user names
if (preg_match('/sf_user_/', basename($this->getCurrentFolderPath()))) {
$userinfo = Database::get_user_info_from_id(substr(basename($this->getCurrentFolderPath()), 8));
$this->currentFolderInfo['name'] = api_get_person_name($userinfo['firstname'], $userinfo['lastname']);
$userinfo = api_get_user_info(substr(basename($this->getCurrentFolderPath()), 8));
$this->currentFolderInfo['name'] = $userinfo['complete_name'];
} else {
$this->currentFolderInfo['name'] = str_replace('_', ' ', basename($this->getCurrentFolderPath())); //for Chamilo. Prevent long directory name
}

@ -131,11 +131,11 @@ if( ( $is_allowedToTrack || $is_allowedToTrackEverybodyInCourse )) {
echo "<h4>".get_lang('ListStudents')."</h4>";
if( $is_allowedToTrackEverybodyInCourse ) {
// if user can track everybody : list user of course
$sql = "SELECT count(user_id)
FROM $TABLECOURSUSER
WHERE course_code = '".Database::escape_string($_cid)."' AND relation_type<>".COURSE_RELATION_TYPE_RRHH."";
} else {
// if user can only track one group : list users of this group
$sql = "SELECT count(user)
@ -220,7 +220,7 @@ if( ( $is_allowedToTrack || $is_allowedToTrackEverybodyInCourse )) {
if( $is_allowedToTrackEverybodyInCourse ) {
// check if user is in this course
$tracking_is_accepted = $is_course_member;
$tracked_user_info = Database::get_user_info_from_id($uInfo);
$tracked_user_info = api_get_user_info($uInfo);
} else {
// check if user is in the group of this tutor

@ -37,9 +37,11 @@ $is_allowed = true;
/* Libraries */
require_once api_get_path(LIBRARY_PATH).'statsUtils.lib.inc.php';
require_once api_get_path(SYS_CODE_PATH).'resourcelinker/resourcelinker.inc.php';
require_once api_get_path(SYS_CODE_PATH).'exercice/hotpotatoes.lib.php';
require_once api_get_path(LIBRARY_PATH) . 'statsUtils.lib.inc.php';
require_once api_get_path(
SYS_CODE_PATH
) . 'resourcelinker/resourcelinker.inc.php';
require_once api_get_path(SYS_CODE_PATH) . 'exercice/hotpotatoes.lib.php';
/* Header */
@ -48,9 +50,11 @@ $interbreadcrumb[]= array ("url"=>"../group/group.php", "name"=> get_lang('BredC
$interbreadcrumb[]= array ("url"=>"../group/group_space.php?gidReq=$_gid", "name"=> get_lang('BredCrumpGroupSpace'));
*/
if($uInfo)
{
$interbreadcrumb[]= array ("url"=>"../user/userInfo.php?uInfo=$uInfo", "name"=> get_lang('BredCrumpUsers'));
if ($uInfo) {
$interbreadcrumb[] = array(
"url" => "../user/userInfo.php?uInfo=$uInfo",
"name" => get_lang('BredCrumpUsers')
);
}
$nameTools = get_lang('ToolName');
@ -58,15 +62,20 @@ $nameTools = get_lang('ToolName');
/* Constants and variables */
$is_allowedToTrack = $is_courseAdmin;
$is_course_member = CourseManager::is_user_subscribed_in_real_or_linked_course($user_id, $course_id);
$is_course_member = CourseManager::is_user_subscribed_in_real_or_linked_course(
$user_id,
$course_id
);
// Database Table Definitions
$TABLECOURSUSER = Database::get_main_table(TABLE_MAIN_COURSE_USER);
$TABLEUSER = Database::get_main_table(TABLE_MAIN_USER);
$tbl_session_course_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
$tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
$TABLECOURSUSER = Database::get_main_table(TABLE_MAIN_COURSE_USER);
$TABLEUSER = Database::get_main_table(TABLE_MAIN_USER);
$tbl_session_course_user = Database::get_main_table(
TABLE_MAIN_SESSION_COURSE_USER
);
$tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
$TABLECOURSE_GROUPSUSER = Database::get_course_table(TABLE_GROUP_USER);
$TABLECOURSE_GROUPSUSER = Database::get_course_table(TABLE_GROUP_USER);
$sql = "SELECT 1
FROM $tbl_session_course_user AS session_course_user
@ -75,10 +84,10 @@ $sql = "SELECT 1
AND ((date_start<=NOW()
AND date_end>=NOW())
OR (date_start='0000-00-00' AND date_end='0000-00-00'))
WHERE id_session='".$_SESSION['id_session']."' AND course_code='$_cid'";
WHERE id_session='" . $_SESSION['id_session'] . "' AND course_code='$_cid'";
//echo $sql;
$result=Database::query($sql);
if(!Database::num_rows($result)){
$result = Database::query($sql);
if (!Database::num_rows($result)) {
$disabled = true;
}
@ -88,7 +97,7 @@ $tbl_learnpath_item = Database::get_course_table(TABLE_LP_ITEM);
$tbl_learnpath_view = Database::get_course_table(TABLE_LP_VIEW);
$tbl_learnpath_item_view = Database::get_course_table(TABLE_LP_ITEM_VIEW);
$documentPath=api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
$documentPath = api_get_path(SYS_COURSE_PATH) . $_course['path'] . '/document';
// The variables for the days and the months
$DaysShort = api_get_week_days_short();
@ -104,30 +113,25 @@ $is_allowedToTrackEverybodyInCourse = $is_allowedToTrack; // allowed to track al
/* MAIN SECTION */
$title[0]='';
$title[1]='';
$line='';
$title_line='';
$title[0] = '';
$title[1] = '';
$line = '';
$title_line = '';
// check if uid is tutor of this group
if( ( $is_allowedToTrack || $is_allowedToTrackEverybodyInCourse))
{
if(!$uInfo && !isset($uInfo) )
{
if (($is_allowedToTrack || $is_allowedToTrackEverybodyInCourse)) {
if (!$uInfo && !isset($uInfo)) {
/*
* Display list of user of this group
*/
if( $is_allowedToTrackEverybodyInCourse )
{
// if user can track everybody : list user of course
if ($is_allowedToTrackEverybodyInCourse) {
// if user can track everybody : list user of course
$sql = "SELECT count(user_id)
FROM $TABLECOURSUSER
WHERE course_code = '$_cid' AND relation_type<>".COURSE_RELATION_TYPE_RRHH."";
}
else
{
WHERE course_code = '$_cid' AND relation_type<>" . COURSE_RELATION_TYPE_RRHH . "";
} else {
// if user can only track one group : list users of this group
$sql = "SELECT count(user)
FROM $TABLECOURSE_GROUPSUSER
@ -135,47 +139,42 @@ if( ( $is_allowedToTrack || $is_allowedToTrackEverybodyInCourse))
}
$userGroupNb = getOneResult($sql);
$step = 25; // number of student per page
if ($userGroupNb > $step)
{
if(!isset($offset))
{
$offset=0;
if ($userGroupNb > $step) {
if (!isset($offset)) {
$offset = 0;
}
$next = $offset + $step;
$next = $offset + $step;
$previous = $offset - $step;
$navLink = "";
if ($previous >= 0)
{
if ($previous >= 0) {
}
if ($next < $userGroupNb)
{
if ($next < $userGroupNb) {
}
}
else
{
} else {
$offset = 0;
}
echo $navLink;
if (!settype($offset, 'integer') || !settype($step, 'integer')) die('Offset or step variables are not integers.'); //sanity check of integer vars
if( $is_allowedToTrackEverybodyInCourse )
{
if (!settype($offset, 'integer') || !settype(
$step,
'integer'
)
) {
die('Offset or step variables are not integers.');
} //sanity check of integer vars
if ($is_allowedToTrackEverybodyInCourse) {
// list of users in this course
$sql = "SELECT u.user_id, u.firstname,u.lastname
FROM $TABLECOURSUSER cu , $TABLEUSER u
WHERE cu.user_id = u.user_id AND cu.relation_type<>".COURSE_RELATION_TYPE_RRHH."
WHERE cu.user_id = u.user_id AND cu.relation_type<>" . COURSE_RELATION_TYPE_RRHH . "
AND cu.course_code = '$_cid'
LIMIT $offset,$step";
}
else
{
} else {
// list of users of this group
$sql = "SELECT u.user_id, u.firstname,u.lastname
FROM $TABLECOURSE_GROUPSUSER gu , $TABLEUSER u
@ -184,27 +183,22 @@ if( ( $is_allowedToTrack || $is_allowedToTrackEverybodyInCourse))
LIMIT $offset,$step";
}
$list_users = getManyResults3Col($sql);
for($i = 0 ; $i < sizeof($list_users) ; $i++)
{
}
for ($i = 0; $i < sizeof($list_users); $i++) {
}
}
else // if uInfo is set
} else // if uInfo is set
{
/*
* Informations about student uInfo
*/
// these checks exists for security reasons, neither a prof nor a tutor can see statistics of a user from
// another course, or group
if( $is_allowedToTrackEverybodyInCourse )
{
if ($is_allowedToTrackEverybodyInCourse) {
// check if user is in this course
$tracking_is_accepted = $is_course_member;
$tracked_user_info = Database::get_user_info_from_id($uInfo);
$title[0]=$tracked_user_info[1].'_'.$tracked_user_info[2];
}
else
{
$tracked_user_info = api_get_user_info($uInfo);
$title[0] = $tracked_user_info[1] . '_' . $tracked_user_info[2];
} else {
// check if user is in the group of this tutor
$sql = "SELECT u.firstname,u.lastname, u.email
FROM $TABLECOURSE_GROUPSUSER gu , $TABLEUSER u
@ -213,39 +207,61 @@ if( ( $is_allowedToTrack || $is_allowedToTrackEverybodyInCourse))
AND u.user_id = '$uInfo'";
$query = Database::query($sql);
$tracked_user_info = @Database::fetch_assoc($query);
if(is_array($tracked_user_info)) $tracking_is_accepted = true;
if (is_array($tracked_user_info)) {
$tracking_is_accepted = true;
}
$title[0] = $tracked_user_info['firstname'].'_'.$tracked_user_info['lastname'];
$title[0] = $tracked_user_info['firstname'] . '_' . $tracked_user_info['lastname'];
}
if ($tracking_is_accepted)
{
$tracked_user_info['email'] == '' ? $mail_link = get_lang('NoEmail') : $mail_link = Display::encrypted_mailto_link($tracked_user_info['email']);
if ($tracking_is_accepted) {
$tracked_user_info['email'] == '' ? $mail_link = get_lang(
'NoEmail'
) : $mail_link = Display::encrypted_mailto_link(
$tracked_user_info['email']
);
if(!isset($view))
{
$view ='0000000';
if (!isset($view)) {
$view = '0000000';
}
//Logins
list($title_line1, $line1) = TrackingUserLogCSV::display_login_tracking_info($view, $uInfo, $_cid);
list($title_line1, $line1) = TrackingUserLogCSV::display_login_tracking_info(
$view,
$uInfo,
$_cid
);
//Exercise results
list($title_line2, $line2) = TrackingUserLogCSV::display_exercise_tracking_info($view, $uInfo, $_cid);
list($title_line2, $line2) = TrackingUserLogCSV::display_exercise_tracking_info(
$view,
$uInfo,
$_cid
);
//Student publications uploaded
list($title_line3, $line3) = TrackingUserLogCSV::display_student_publications_tracking_info($view, $uInfo, $_cid);
list($title_line3, $line3) = TrackingUserLogCSV::display_student_publications_tracking_info(
$view,
$uInfo,
$_cid
);
//Links usage
list($title_line4, $line4) = TrackingUserLogCSV::display_links_tracking_info($view, $uInfo, $_cid);
list($title_line4, $line4) = TrackingUserLogCSV::display_links_tracking_info(
$view,
$uInfo,
$_cid
);
//Documents downloaded
list($title_line5, $line5) = TrackingUserLogCSV::display_document_tracking_info($view, $uInfo, $_cid);
$title_line = $title_line1.$title_line2.$title_line3.$title_line4.$title_line5;
$line= $line1.$line2.$line3.$line4.$line5;
}
else
{
list($title_line5, $line5) = TrackingUserLogCSV::display_document_tracking_info(
$view,
$uInfo,
$_cid
);
$title_line = $title_line1 . $title_line2 . $title_line3 . $title_line4 . $title_line5;
$line = $line1 . $line2 . $line3 . $line4 . $line5;
} else {
echo get_lang('ErrorUserNotInGroup');
}
@ -253,7 +269,7 @@ if( ( $is_allowedToTrack || $is_allowedToTrackEverybodyInCourse))
/*
* Scorm contents and Learning Path
*/
//TODO: scorm tools is in work and the logs will change in few days...
//TODO: scorm tools is in work and the logs will change in few days...
/*if(substr($view,5,1) == '1')
{
$new_view = substr_replace($view,'0',5,1);
@ -311,42 +327,42 @@ if( ( $is_allowedToTrack || $is_allowedToTrackEverybodyInCourse))
}*/
}
/*
* Export to a CSV file
* force the browser to save the file instead of opening it
*/
/*
* Export to a CSV file
* force the browser to save the file instead of opening it
*/
$len = strlen($title_line.$line);
$len = strlen($title_line . $line);
header('Content-type: application/octet-stream');
//header('Content-Type: application/force-download');
header('Content-length: '.$len);
$filename = html_entity_decode(str_replace(":","",str_replace(" ","_", $title[0].'_'.$title[1].'.csv')));
header('Content-length: ' . $len);
$filename = html_entity_decode(
str_replace(
":",
"",
str_replace(" ", "_", $title[0] . '_' . $title[1] . '.csv')
)
);
$filename = replace_dangerous_char($filename);
if(preg_match("/MSIE 5.5/",$_SERVER['HTTP_USER_AGENT']))
{
header('Content-Disposition: filename= '.$filename);
}
else
{
header('Content-Disposition: attachment; filename= '.$filename);
if (preg_match("/MSIE 5.5/", $_SERVER['HTTP_USER_AGENT'])) {
header('Content-Disposition: filename= ' . $filename);
} else {
header('Content-Disposition: attachment; filename= ' . $filename);
}
if(strpos($_SERVER['HTTP_USER_AGENT'],'MSIE'))
{
if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE')) {
header('Pragma: ');
header('Cache-Control: ');
header('Cache-Control: public'); // IE cannot download from sessions without a cache
header(
'Cache-Control: public'
); // IE cannot download from sessions without a cache
}
header('Content-Description: '.$filename);
header('Content-Description: ' . $filename);
header('Content-transfer-encoding: binary');
echo api_html_entity_decode($title_line, ENT_QUOTES, $charset);
echo api_html_entity_decode($line, ENT_QUOTES, $charset);
exit;
}
// not allowed
else
{
} // not allowed
else {
api_not_allowed();
}

@ -271,7 +271,7 @@ if (isset($_GET['view']) && $_GET['view']) {
$max_edit_time=1200; // 20 minutes
$rest_time=$max_edit_time-$time_editing;
$userinfo = Database::get_user_info_from_id($last_row['is_editing']);
$userinfo = api_get_user_info($last_row['is_editing']);
$username = api_htmlentities(sprintf(get_lang('LoginX'), $userinfo['username']), ENT_QUOTES);
$is_being_edited= get_lang('ThisPageisBeginEditedBy').' <a href=../user/userInfo.php?uInfo='.$userinfo['user_id'].'>'.
@ -1016,7 +1016,7 @@ if ($action =='mactiveusers') {
//show table
if (Database::num_rows($allpages) > 0) {
while ($obj = Database::fetch_object($allpages)) {
$userinfo = Database::get_user_info_from_id($obj->user_id);
$userinfo = api_get_user_info($obj->user_id);
$username = api_htmlentities(sprintf(get_lang('LoginX'), $userinfo['username']), ENT_QUOTES);
$row = array();
if ($obj->user_id <> 0) {
@ -1042,7 +1042,7 @@ if ($action =='mactiveusers') {
// User contributions Juan Carlos Raña Trabado
if ($action =='usercontrib') {
$userinfo=Database::get_user_info_from_id($_GET['user_id']);
$userinfo = api_get_user_info($_GET['user_id']);
$username = api_htmlentities(sprintf(get_lang('LoginX'), $userinfo['username']), ENT_QUOTES);
echo '<div class="actions">'.get_lang('UserContributions').': <a href="../user/userInfo.php?uInfo='.$userinfo['user_id'].'">'.
@ -1063,7 +1063,7 @@ if ($action =='usercontrib') {
$row = array ();
while ($obj = Database::fetch_object($allpages)) {
//get author
$userinfo=Database::get_user_info_from_id($obj->user_id);
$userinfo = api_get_user_info($obj->user_id);
//get time
$year = substr($obj->dtime, 0, 4);
@ -1537,7 +1537,7 @@ if ($action =='links') {
$row = array ();
while ($obj = Database::fetch_object($allpages)) {
//get author
$userinfo=Database::get_user_info_from_id($obj->user_id);
$userinfo = api_get_user_info($obj->user_id);
$username = api_htmlentities(sprintf(get_lang('LoginX'), $userinfo['username']), ENT_QUOTES);
//get time
@ -1802,7 +1802,7 @@ if (isset($action) && $action =='edit') {
$max_edit_time=1200; // 20 minutes
$rest_time=$max_edit_time-$time_editing;
$userinfo=Database::get_user_info_from_id($row['is_editing']);
$userinfo = api_get_user_info($row['is_editing']);
$username = api_htmlentities(sprintf(get_lang('LoginX'), $userinfo['username']), ENT_QUOTES);
$is_being_edited= get_lang('ThisPageisBeginEditedBy').
@ -2054,7 +2054,7 @@ if ($action == 'history' or isset($_POST['HistoryDifferences'])) {
$total_versions=Database::num_rows($result);
while ($row=Database::fetch_array($result)) {
$userinfo=Database::get_user_info_from_id($row['user_id']);
$userinfo = api_get_user_info($row['user_id']);
$username = api_htmlentities(sprintf(get_lang('LoginX'), $userinfo['username']), ENT_QUOTES);
echo '<li style="margin-bottom: 5px;">';
@ -2199,7 +2199,7 @@ if ($action =='recentchanges') {
$row = array ();
while ($obj = Database::fetch_object($allpages)) {
//get author
$userinfo=Database::get_user_info_from_id($obj->user_id);
$userinfo =api_get_user_info($obj->user_id);
$username = api_htmlentities(sprintf(get_lang('LoginX'), $userinfo['username']), ENT_QUOTES);
//get type assignment icon
@ -2271,7 +2271,7 @@ if ($action == 'allpages') {
$row = array ();
while ($obj = Database::fetch_object($allpages)) {
//get author
$userinfo=Database::get_user_info_from_id($obj->user_id);
$userinfo = api_get_user_info($obj->user_id);
$username = api_htmlentities(sprintf(get_lang('LoginX'), $userinfo['username']), ENT_QUOTES);
//get type assignment icon
@ -2342,7 +2342,7 @@ if ($action == 'discuss') {
$result=Database::query($sql);
$row=Database::fetch_array($result);
$lastversiondate=api_get_local_time($row['dtime'], null, date_default_timezone_get());
$lastuserinfo=Database::get_user_info_from_id($row['user_id']);
$lastuserinfo = api_get_user_info($row['user_id']);
$username = api_htmlentities(sprintf(get_lang('LoginX'), $lastuserinfo['username']), ENT_QUOTES);
//select page to discuss
@ -2526,7 +2526,7 @@ if ($action == 'discuss') {
//echo '<div style="overflow:auto; height:170px;">';
while ($row=Database::fetch_array($result)) {
$userinfo=Database::get_user_info_from_id($row['userc_id']);
$userinfo = api_get_user_info($row['userc_id']);
$username = api_htmlentities(sprintf(get_lang('LoginX'), $userinfo['username']), ENT_QUOTES);
if (($userinfo['status'])=="5") {

@ -1438,8 +1438,8 @@ class Wiki
//if modifying a wiki page
//first, current author and time
//Who is the author?
$userinfo= Database::get_user_info_from_id($lastuser);
$email_user_author= get_lang('EditedBy').': '.api_get_person_name($userinfo['firstname'], $userinfo['lastname']);
$userinfo = api_get_user_info($lastuser);
$email_user_author = get_lang('EditedBy').': '.$userinfo['complete_name'];
//When ?
$year = substr($lastime, 0, 4);
@ -1451,7 +1451,9 @@ class Wiki
$email_date_changes=$day.' '.$month.' '.$year.' '.$hours.":".$minutes.":".$seconds;
//second, extract data from first reg
$sql='SELECT * FROM '.$tbl_wiki.' WHERE c_id = '.$course_id.' AND reflink="'.$id_or_ref.'" AND '.$groupfilter.$condition_session.' ORDER BY id ASC'; //id_or_ref is reflink from tblwiki
$sql = 'SELECT * FROM '.$tbl_wiki.'
WHERE c_id = '.$course_id.' AND reflink="'.$id_or_ref.'" AND '.$groupfilter.$condition_session.'
ORDER BY id ASC';
$result=Database::query($sql);
$row=Database::fetch_array($result);
@ -1470,8 +1472,8 @@ class Wiki
//first, current author and time
//Who is the author of last message?
$userinfo= Database::get_user_info_from_id($lastuser);
$email_user_author= get_lang('AddedBy').': '.api_get_person_name($userinfo['firstname'], $userinfo['lastname']);
$userinfo = api_get_user_info($lastuser);
$email_user_author = get_lang('AddedBy').': '.$userinfo['complete_name'];
//When ?
$year = substr($lastime, 0, 4);
@ -1508,8 +1510,8 @@ class Wiki
$email_page_name=$row['title'];
//Who is the author?
$userinfo= Database::get_user_info_from_id($row['user_id']);
$email_user_author= get_lang('AddedBy').': '.api_get_person_name($userinfo['firstname'], $userinfo['lastname']);
$userinfo = api_get_user_info($row['user_id']);
$email_user_author= get_lang('AddedBy').': '.$userinfo['complete_name'];
//When ?
$year = substr($row['dtime'], 0, 4);
@ -1540,10 +1542,8 @@ class Wiki
$allow_send_mail=true;
//Who is the author?
$userinfo= Database::get_user_info_from_id(api_get_user_id()); //current user
$email_user_author= get_lang('DeletedBy').': '.api_get_person_name($userinfo['firstname'], $userinfo['lastname']);
$userinfo = api_get_user_info(api_get_user_id()); //current user
$email_user_author = get_lang('DeletedBy').': '.$userinfo['complete_name'];
//When ?
$today = date('r'); //current time
$email_date_changes=$today;
@ -1556,8 +1556,8 @@ class Wiki
///make and send email
if ($allow_send_mail) {
while ($row=Database::fetch_array($result)) {
$userinfo = Database::get_user_info_from_id($row['user_id']); //$row['user_id'] obtained from tbl_wiki_mailcue
$name_to = api_get_person_name($userinfo['firstname'], $userinfo['lastname'], null, PERSON_NAME_EMAIL_ADDRESS);
$userinfo = api_get_user_info($row['user_id']); //$row['user_id'] obtained from tbl_wiki_mailcue
$name_to = $userinfo['complete_name'];
$email_to = $userinfo['email'];
$sender_name = api_get_setting('emailAdministrator');
$sender_email = api_get_setting('emailAdministrator');
@ -1766,9 +1766,9 @@ class Wiki
$all_students_pages = array();
//data about teacher
$userinfo=Database::get_user_info_from_id(api_get_user_id());
$userinfo = api_get_user_info(api_get_user_id());
$username = api_htmlentities(sprintf(get_lang('LoginX'), $userinfo['username'], ENT_QUOTES));
$name = api_get_person_name($userinfo['firstname'], $userinfo['lastname'])." . ".$username;
$name = $userinfo['complete_name']." - ".$username;
if (api_get_user_id()<>0) {
$image_path = UserManager::get_user_picture_path_by_id(api_get_user_id(),'web',false, true);
$image_repository = $image_path['dir'];
@ -1914,7 +1914,7 @@ class Wiki
if (Database::num_rows($result) > 0) {
while ($obj = Database::fetch_object($result)) {
//get author
$userinfo=Database::get_user_info_from_id($obj->user_id);
$userinfo = api_get_user_info($obj->user_id);
//get time
$year = substr($obj->dtime, 0, 4);
@ -1941,7 +1941,7 @@ class Wiki
$row[] = '<a href="'.api_get_self().'?'.api_get_cidreq().'&action=showpage&title='.api_htmlentities(urlencode($obj->reflink)).'&session_id='.api_htmlentities($_GET['session_id']).'&group_id='.api_htmlentities($_GET['group_id']).'">'.$obj->title.'</a>';
}
$row[] = $obj->user_id <>0 ? '<a href="../user/userInfo.php?uInfo='.$userinfo['user_id'].'">'.api_htmlentities(api_get_person_name($userinfo['firstname'], $userinfo['lastname'])).'</a>' : get_lang('Anonymous').' ('.$obj->user_ip.')';
$row[] = $obj->user_id <>0 ? '<a href="../user/userInfo.php?uInfo='.$userinfo['user_id'].'">'.api_htmlentities($userinfo['complete_name']).'</a>' : get_lang('Anonymous').' ('.$obj->user_ip.')';
$row[] = $year.'-'.$month.'-'.$day.' '.$hours.":".$minutes.":".$seconds;
if ($all_vers=='1') {

@ -152,7 +152,7 @@ class TestDatabase extends UnitTestCase {
$res=$this->dbase->get_course_table($short_table_name,$database_name);
$this->assertTrue(is_string($res));
}
function testGetCourseTablePrefix() {
global $_configuration;
$res=$this->dbase->get_course_table_prefix($_configuration);
@ -204,10 +204,6 @@ class TestDatabase extends UnitTestCase {
$this->assertTrue(is_string($res));
}
function testGetUserInfoFromIdOneIsArray() {
$res=$this->dbase->get_user_info_from_id(1);
$this->assertTrue(is_array($res));
}
/* Fails for some reason on automated tests server
function testGetUserInfoFromIdNullIsFalse() {
// should be returning GLOBALS[_user] (=null) if param is null (in testing context)

Loading…
Cancel
Save