Remove userInfo.php references, add function to load user profile

1.10.x
Julio Montoya 10 years ago
parent 8cf694bccf
commit cbca63b4d4
  1. 5
      main/document/document.php
  2. 32
      main/dropbox/dropbox_functions.inc.php
  3. 3
      main/dropbox/index.php
  4. 9
      main/forum/forumfunction.inc.php
  5. 17
      main/forum/viewforum.php
  6. 22
      main/group/group_space.php
  7. 5
      main/inc/lib/database.constants.inc.php
  8. 18
      main/inc/lib/document.lib.php
  9. 40
      main/inc/lib/myspace.lib.php
  10. 7
      main/inc/lib/social.lib.php
  11. 9
      main/inc/lib/tracking.lib.php
  12. 26
      main/inc/lib/usermanager.lib.php
  13. 21
      main/survey/survey_invitation.php
  14. 10
      main/user/user.php
  15. 123
      main/wiki/wiki.inc.php
  16. 14
      tests/main/work/work.lib.test.php

@ -27,7 +27,8 @@
* @package chamilo.document
*/
use \ChamiloSession as Session;
use ChamiloSession as Session;
require_once '../inc/global.inc.php';
$current_course_tool = TOOL_DOCUMENT;
$this_section = SECTION_COURSES;
@ -1711,7 +1712,7 @@ if (isset($documentAndFolders) && is_array($documentAndFolders)) {
$user_info = UserManager::get_user_info_by_id($document_data['insert_user_id']);
$user_name = api_get_person_name($user_info['firstname'], $user_info['lastname']);
$user_link = '<div class="document_owner">'.
get_lang('Owner').': '.DocumentManager::display_user_link_document($document_data['insert_user_id'], $user_name).'</div>';
get_lang('Owner').': '.UserManager::displayUserProfile($user_info).'</div>';
}
}

@ -922,35 +922,6 @@ function store_add_dropbox()
return get_lang('FileUploadSucces');
}
/**
* This function displays the firstname and lastname of the user as a link to the user tool.
*
* @see this is the same function as in the new forum, so this probably has to move to a user library.
*
* @todo move this function to the user library (there is a duplicate in work.lib.php)
*
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
* @version march 2006
*/
function display_user_link_work($user_id, $name = '') {
if ($user_id != 0) {
if (empty($name)) {
$table_user = Database::get_main_table(TABLE_MAIN_USER);
$sql = "SELECT * FROM $table_user WHERE user_id = ".intval($user_id)."";
$result = Database::query($sql);
$row = Database::fetch_array($result);
return '<a href="../user/userInfo.php?uInfo='.$row['user_id'].'">'.api_get_person_name($row['firstname'], $row['lastname']).'</a>';
} else {
$user_id = intval($user_id);
return '<a href="../user/userInfo.php?uInfo='.$user_id.'">'.Security::remove_XSS($name).'</a>';
}
} else {
return $name.' ('.get_lang('Anonymous').')';
}
}
/**
* this function transforms the array containing all the feedback into something visually attractive.
*
@ -979,7 +950,8 @@ function feedback($array) {
*/
function format_feedback($feedback)
{
$output = display_user_link_work($feedback['author_user_id']);
$userInfo = api_get_user_info($feedback['author_user_id']);
$output = UserManager::getUserProfileLink($userInfo);
$output .= '&nbsp;&nbsp;'.api_convert_and_format_date($feedback['feedback_date'], DATE_TIME_FORMAT_LONG).'<br />';
$output .= '<div style="padding-top:6px">'.nl2br($feedback['feedback']).'</div><hr size="1" noshade/><br />';
return $output;

@ -531,7 +531,8 @@ if ($action != 'add') {
$dropbox_file_data[] = format_file_size($file_size);
$receivers_celldata = null;
foreach ($dropbox_file->recipients as $recipient) {
$receivers_celldata = display_user_link_work($recipient['user_id'], $recipient['name']).', '.$receivers_celldata;
$userInfo = api_get_user_info($recipient['user_id']);
$receivers_celldata = UserManager::getUserProfileLink($userInfo).', '.$receivers_celldata;
}
$receivers_celldata = trim(trim($receivers_celldata), ','); // Removing the trailing comma.
$dropbox_file_data[] = $receivers_celldata;

@ -22,7 +22,7 @@
* @todo complete the missing phpdoc the correct order should be
*/
use \ChamiloSession as Session;
use ChamiloSession as Session;
define('FORUM_NEW_POST', 0);
@ -3085,7 +3085,9 @@ function store_edit_post($values)
function display_user_link($user_id, $name, $origin = '', $in_title = '')
{
if ($user_id != 0) {
return '<a title="'.api_htmlentities($in_title, ENT_QUOTES).'" href="../user/userInfo.php?uInfo='.$user_id.'" '.(!empty($origin) ? 'target="_self"' : '').'>'.$name.'</a>';
$userInfo = api_get_user_info($user_id);
return '<a href="'.$userInfo['profile_url'].'">'.Security::remove_XSS($userInfo['complete_name']).'</a>';
} else {
return $name.' ('.get_lang('Anonymous').')';
}
@ -3100,7 +3102,8 @@ function display_user_link($user_id, $name, $origin = '', $in_title = '')
*/
function display_user_image($user_id, $name, $origin = '')
{
$link = '<a href="../user/userInfo.php?uInfo='.$user_id.'" '.(!empty($origin) ? 'target="_self"' : '').'>';
$userInfo = api_get_user_info($user_id);
$link = '<a href="'.$userInfo['profile_url'].'" '.(!empty($origin) ? 'target="_self"' : '').'>';
if ($user_id != 0) {
$image_path = UserManager::get_user_picture_path_by_id($user_id, 'web', false, true);
$friends_profile = UserManager::get_picture_user($user_id, $image_path['file'], 0, USER_IMAGE_SIZE_MEDIUM, 'width="96" height="96" ');

@ -22,7 +22,7 @@
* @package chamilo.forum
*/
use \ChamiloSession as Session;
use ChamiloSession as Session;
// Including the global initialization file.
require_once '../inc/global.inc.php';
@ -165,7 +165,11 @@ if ($my_action == 'notify' AND isset($_GET['content']) AND isset($_GET['id']) &&
// Student list
if ($my_action == 'liststd' AND isset($_GET['content']) AND isset($_GET['id']) AND (api_is_allowed_to_edit(null, true) || $is_group_tutor)) {
if ($my_action == 'liststd' &&
isset($_GET['content']) &&
isset($_GET['id']) &&
(api_is_allowed_to_edit(null, true) || $is_group_tutor)
) {
$active = null;
switch ($_GET['list']) {
case 'qualify':
@ -223,15 +227,16 @@ if ($my_action == 'liststd' AND isset($_GET['content']) AND isset($_GET['id']) A
if (Database::num_rows($student_list) > 0) {
while ($row_student_list=Database::fetch_array($student_list)) {
$userInfo = api_get_user_info($row_student_list['user_id']);
if ($counter_stdlist % 2 == 0) {
$class_stdlist = 'row_odd';
} else {
$class_stdlist = 'row_even';
}
$name_user_theme = api_get_person_name($row_student_list['firstname'], $row_student_list['lastname']);
$table_list .= '<tr class="'.$class_stdlist.'"><td>
<a href="'.api_get_path(WEB_CODE_PATH).'user/userInfo.php?uInfo='.$row_student_list['user_id'].'&amp;tipo=sdtlist&amp;'.api_get_cidreq().'&amp;forum='.Security::remove_XSS($my_forum).$origin_string.'">
'.$name_user_theme.'</a></td>';
$table_list .= '<tr class="'.$class_stdlist.'"><td>';
$table_list .= UserManager::getUserProfileLink($userInfo);
$table_list .= '</td>';
if ($_GET['list'] == 'qualify') {
$table_list .= '<td>'.$row_student_list['qualify'].'/'.$max_qualify.'</td>';
}

@ -335,10 +335,14 @@ if (count($tutors) == 0) {
$image_path = UserManager::get_user_picture_path_by_id($tutor['user_id'], 'web', false, true);
$image_repository = $image_path['dir'];
$existing_image = $image_path['file'];
$completeName = api_get_person_name($tutor['firstname'], $tutor['lastname']);
$completeName = $tab_user_info['complete_name'];
$photo = '<img src="'.$image_repository.$existing_image.'" alt="'.$completeName.'" width="32" height="32" title="'.$completeName.'" />';
$tutor_info .= '<li><a href="'.api_get_path(WEB_CODE_PATH).'user/userInfo.php?origin='.$my_origin.'&uInfo='.$tutor['user_id'].'">'.
$photo.'&nbsp;'.$completeName.'</a></li>';
$tutor_info .= '<li>';
$tutor_info .= Display::url(
$tab_user_info['complete_name'],
$tab_user_info['profile_url']
);
$tutor_info .= '</li>';
}
$tutor_info .= '</ul>';
}
@ -510,13 +514,12 @@ function email_filter($email)
*/
function user_icon_filter($user_id)
{
global $origin;
$userinfo = api_get_user_info($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="'.$userinfo['complete_name'].'" width="22" height="22" title="'.$userinfo['complete_name'].'" /></center>';
return '<a href="../user/userInfo.php?origin='.$origin.'&uInfo='.$user_id.'">'.$photo;
$photo = '<center><img src="'.$image_repository.$existing_image.'" alt="'.$userInfo['complete_name'].'" width="22" height="22" title="'.$userInfo['complete_name'].'" /></center>';
return Display::url($photo, $userInfo['profile_url']);
}
/**
@ -531,9 +534,8 @@ function user_icon_filter($user_id)
*/
function user_name_filter($name, $url_params, $row)
{
$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].'&'.$url_params.'" title="'.$username.'">'.$name.'</a>';
$userInfo = api_get_user_info($row[0]);
return UserManager::getUserProfileLink($userInfo);
}
// Footer

@ -237,11 +237,6 @@ define('TABLE_BLOGS_TASKS_REL_USER', 'blog_task_rel_user');
define('TABLE_BLOGS_RATING', 'blog_rating');
define('TABLE_BLOGS_ATTACHMENT', 'blog_attachment');
define('TABLE_BLOGS_TASKS_PERMISSIONS', 'permission_task');
//end of Smartblogs
// User information tables
define('TABLE_USER_INFO', 'userinfo_def');
define('TABLE_USER_INFO_CONTENT', 'userinfo_content');
// Course settings table
define('TABLE_COURSE_SETTING', 'course_setting');

@ -5748,24 +5748,6 @@ class DocumentManager
return $path_displayed;
}
/**
* This function displays the name of the user and makes the link tothe user tool.
*
* @param $user_id
* @param $name
* @return a link to the userInfo.php
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
* @version february 2006, dokeos 1.8
*/
public static function display_user_link_document($user_id, $name)
{
if ($user_id != 0) {
return '<a href="../user/userInfo.php?uInfo=' . $user_id . '">' . $name . '</a>';
} else {
return get_lang('Anonymous');
}
}
/**
* Creates form that asks for the directory name.
* @return string html-output text for the form

@ -2509,8 +2509,8 @@ class MySpace
foreach ($users as $index => $user) {
$user = MySpace::complete_missing_data($user);
// coach only will registered users
$default_status = '5';
if ($user['create'] == '1') {
$default_status = STUDENT;
if ($user['create'] == COURSEMANAGER) {
$user['id'] = UserManager:: create_user(
$user['FirstName'],
$user['LastName'],
@ -2544,7 +2544,7 @@ class MySpace
$sql = "INSERT IGNORE INTO $tbl_session_rel_course_rel_user(session_id, c_id, user_id)
VALUES('$id_session','$enreg_course','$userid')";
$course_session = array('course' => $enreg_course, 'added' => 1);
//$user['added_at_session'] = $course_session;
$result = Database::query($sql);
if (Database::affected_rows($result)) {
$nbr_users++;
@ -2565,14 +2565,12 @@ class MySpace
$sql_update = "UPDATE $tbl_session SET nbr_users= '$nbr_users' WHERE id='$id_session'";
Database::query($sql_update);
}
// We don't delete the users (thoughts while dreaming)
//$sql_delete = "DELETE FROM $tbl_session_rel_user WHERE id_session = '$id_session'";
//Database::query($sql_delete);
$new_users = array();
foreach ($users as $index => $user) {
$userid = $user['id'];
$sql_insert = "INSERT IGNORE INTO $tbl_session_rel_user(session_id, user_id) VALUES('$id_session','$userid')";
$sql_insert = "INSERT IGNORE INTO $tbl_session_rel_user(session_id, user_id)
VALUES ('$id_session','$userid')";
Database::query($sql_insert);
$user['added_at_session'] = 1;
$new_users[] = $user;
@ -2586,7 +2584,17 @@ class MySpace
$i = 0;
foreach ($users as $index => $user) {
$emailsubject = '['.api_get_setting('siteName').'] '.get_lang('YourReg').' '.api_get_setting('siteName');
$emailbody = get_lang('Dear').' '.api_get_person_name($user['FirstName'], $user['LastName']).",\n\n".get_lang('YouAreReg')." ".api_get_setting('siteName')." ".get_lang('WithTheFollowingSettings')."\n\n".get_lang('Username')." : $user[UserName]\n".get_lang('Pass')." : $user[Password]\n\n".get_lang('Address')." ".api_get_setting('siteName')." ".get_lang('Is')." : ".api_get_path(WEB_PATH)." \n\n".get_lang('Problem')."\n\n".get_lang('SignatureFormula').",\n\n".api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'))."\n".get_lang('Manager')." ".api_get_setting('siteName')."\nT. ".api_get_setting('administratorTelephone')."\n".get_lang('Email')." : ".api_get_setting('emailAdministrator')."";
$emailbody = get_lang('Dear').' '.
api_get_person_name($user['FirstName'], $user['LastName']).",\n\n".
get_lang('YouAreReg')." ".api_get_setting('siteName')." ".get_lang('WithTheFollowingSettings')."\n\n".
get_lang('Username')." : $user[UserName]\n".
get_lang('Pass')." : $user[Password]\n\n".
get_lang('Address')." ".api_get_setting('siteName')." ".get_lang('Is')." : ".api_get_path(WEB_PATH)." \n\n".
get_lang('Problem')."\n\n".
get_lang('SignatureFormula').",\n\n".
api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'))."\n".
get_lang('Manager')." ".api_get_setting('siteName')."\nT. ".
api_get_setting('administratorTelephone')."\n".get_lang('Email')." : ".api_get_setting('emailAdministrator');
api_mail_html(
api_get_person_name($user['FirstName'], $user['LastName'], null, PERSON_NAME_EMAIL_ADDRESS),
@ -2594,6 +2602,7 @@ class MySpace
$emailsubject,
$emailbody
);
$userInfo = api_get_user_info($user['id']);
if (($user['added_at_platform'] == 1 && $user['added_at_session'] == 1) || $user['added_at_session'] == 1) {
if ($user['added_at_platform'] == 1) {
@ -2605,15 +2614,18 @@ class MySpace
if ($user['added_at_session'] == 1) {
$addedto .= get_lang('UserInSession');
}
$registered_users .= "<a href=\"../user/userInfo.php?uInfo=".$user['id']."\">".api_get_person_name($user['FirstName'], $user['LastName'])."</a> - ".$addedto.'<br />';
} else {
$addedto = get_lang('UserNotAdded');
$registered_users .= "<a href=\"../user/userInfo.php?uInfo=".$user['id']."\">".api_get_person_name($user['FirstName'], $user['LastName'])."</a> - ".$addedto.'<br />';
}
$registered_users .= UserManager::getUserProfileLink($userInfo)." - ".$addedto.'<br />';
}
} else {
$i = 0;
foreach ($users as $index => $user) {
$userInfo = api_get_user_info($user['id']);
if (($user['added_at_platform'] == 1 && $user['added_at_session'] == 1) || $user['added_at_session'] == 1) {
if ($user['added_at_platform'] == 1) {
$addedto = get_lang('UserCreatedPlatform');
@ -2624,19 +2636,15 @@ class MySpace
if ($user['added_at_session'] == 1) {
$addedto .= ' '.get_lang('UserInSession');
}
$registered_users .= "<a href=\"../user/userInfo.php?uInfo=".$user['id']."\">".api_get_person_name($user['FirstName'], $user['LastName'])."</a> - ".$addedto.'<br />';
} else {
$addedto = get_lang('UserNotAdded');
$registered_users .= "<a href=\"../user/userInfo.php?uInfo=".$user['id']."\">".api_get_person_name($user['FirstName'], $user['LastName'])."</a> - ".$addedto.'<br />';
}
$registered_users .= "<a href=\"../user/userInfo.php?uInfo=".$user['id']."\">".api_get_person_name($user['FirstName'], $user['LastName'])."</a> - ".$addedto.'<br />';
}
}
header('Location: course.php?id_session='.$id_session.'&action=show_message&message='.urlencode($registered_users));
exit ();
//header('Location: resume_session.php?id_session='.$id_session);
exit;
}
/**

@ -553,11 +553,12 @@ class SocialManager extends UserManager
if (!$nosession) {
$session = '';
$active = false;
if (!empty($my_course['session_name'])) {
if (!empty($my_course['session_name']) && !empty($my_course['id_session'])) {
// Request for the name of the general coach
$sql = 'SELECT lastname, firstname
FROM '.$tbl_session.' ts LEFT JOIN '.$main_user_table.' tu
FROM '.$tbl_session.' ts
LEFT JOIN '.$main_user_table.' tu
ON ts.id_coach = tu.user_id
WHERE ts.id='.(int) $my_course['id_session'].' LIMIT 1';
$rs = Database::query($sql);
@ -585,7 +586,7 @@ class SocialManager extends UserManager
} else {
$output = array($my_course['user_course_cat'], $result);
}
//$my_course['creation_date'];
return $output;
}

@ -1,9 +1,9 @@
<?php
/* For licensing terms, see /license.txt */
use CpChart\Classes\pCache as pCache;
use CpChart\Classes\pData as pData;
use CpChart\Classes\pImage as pImage;
use CpChart\Classes\pCache as pCache;
/**
* Class Tracking
@ -5594,7 +5594,8 @@ class TrackingCourseLog
if (in_array($row['col0'], array('thematic_plan', 'thematic_advance'))) {
$tbl_thematic = Database :: get_course_table(TABLE_THEMATIC);
$sql = "SELECT thematic_id FROM $table_tool WHERE c_id = $course_id AND id = $ref";
$sql = "SELECT thematic_id FROM $table_tool
WHERE c_id = $course_id AND id = $ref";
$rs_thematic = Database::query($sql);
if (Database::num_rows($rs_thematic)) {
$row_thematic = Database::fetch_array($rs_thematic);
@ -5739,9 +5740,11 @@ class TrackingCourseLog
}
$row[2] = $row2;
if (!empty($row['col3'])) {
$userInfo = api_get_user_info($row['user_id']);
$row['col3'] = Display::url(
$row['col3'],
api_get_path(WEB_CODE_PATH).'user/userInfo.php?'.api_get_cidreq().'&origin=tracking&uInfo='.$row['user_id']
$userInfo['profile_url']
);
$row[3] = $row['col3'];

@ -5328,4 +5328,30 @@ EOF;
}
return $userPath;
}
/**
* Displays the name of the user and makes the link to the user profile
* @param $userInfo
*/
public static function getUserProfileLink($userInfo)
{
if (isset($userInfo) && isset($userInfo['user_id'])) {
return Display::url($userInfo['complete_name'], $userInfo['profile_url']);
} else {
return get_lang('Anonymous');
}
}
/**
* Displays the name of the user and makes the link to the user profile
* @param $userInfo
* @todo
*/
public static function getUserProfileLinkWithPicture($userInfo)
{
$imagePath = UserManager::get_user_picture_path_by_id($userInfo['id'], 'web', false, true);
$userProfile = UserManager::get_picture_user($userInfo['id'], $imagePath['file'], 22, USER_IMAGE_SIZE_SMALL, ' width="22" height="22" ');
return Display::url(Display::img($userProfile['file']), $userInfo['profile_url']);
}
}

@ -104,25 +104,36 @@ $course_id = api_get_course_int_id();
$sql = "SELECT survey_invitation.*, user.firstname, user.lastname, user.email
FROM $table_survey_invitation survey_invitation
LEFT JOIN $table_user user ON (survey_invitation.user = user.user_id AND survey_invitation.c_id = $course_id)
WHERE survey_invitation.survey_code = '".Database::escape_string($survey_data['code'])."' ";
LEFT JOIN $table_user user
ON (survey_invitation.user = user.user_id AND survey_invitation.c_id = $course_id)
WHERE
survey_invitation.survey_code = '".Database::escape_string($survey_data['code'])."' ";
$res = Database::query($sql);
while ($row = Database::fetch_assoc($res)) {
if (!$_GET['view'] || $_GET['view'] == 'invited' || ($_GET['view'] == 'answered' && in_array($row['user'], $answered_data)) || ($_GET['view'] == 'unanswered' && !in_array($row['user'], $answered_data))) {
if (!$_GET['view'] ||
$_GET['view'] == 'invited' ||
($_GET['view'] == 'answered' && in_array($row['user'], $answered_data)) ||
($_GET['view'] == 'unanswered' && !in_array($row['user'], $answered_data))
) {
echo '<tr>';
if (is_numeric($row['user'])) {
echo ' <td><a href="'.api_get_path(WEB_CODE_PATH).'user/userInfo.php?editMainUserInfo='.$row['user'].'">'.api_get_person_name($row['firstname'], $row['lastname']).'</a></td>';
$userInfo = api_get_user_info($row['user']);
echo '<td>';
echo UserManager::getUserProfileLink($userInfo);
echo '</td>';
} else {
echo ' <td>'.$row['user'].'</td>';
echo '<td>'.$row['user'].'</td>';
}
echo ' <td>'.$row['invitation_date'].'</td>';
echo ' <td>';
if (in_array($row['user'], $answered_data)) {
echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/reporting.php?action=userreport&amp;survey_id='.$survey_id.'&amp;user='.$row['user'].'">'.get_lang('ViewAnswers').'</a>';
} else {
echo '-';
}
echo ' </td>';
echo '</tr>';
}

@ -706,8 +706,12 @@ function get_user_data($from, $number_of_items, $column, $direction)
USER_IMAGE_SIZE_SMALL,
' width="22" height="22" '
);
$userInfo = api_get_user_info($user_id);
if (!api_is_anonymous()) {
$photo = '<a href="userInfo.php?'.api_get_cidreq().'&origin='.$origin.'&amp;uInfo='.$user_id.'" title="'.get_lang('Info').'" ><img src="'.$user_profile['file'].'" '.$user_profile['style'].' alt="'.api_get_person_name($o_course_user['firstname'], $o_course_user['lastname']).'" title="'.api_get_person_name($o_course_user['firstname'], $o_course_user['lastname']).'" /></a>';
$photo = Display::url(
'<img src="'.$user_profile['file'].'" '.$user_profile['style'].' alt="'.api_get_person_name($o_course_user['firstname'], $o_course_user['lastname']).'" title="'.api_get_person_name($o_course_user['firstname'], $o_course_user['lastname']).'" />',
$userInfo['profile_url']
);
} else {
$photo = '<img src="'.$user_profile['file'].'" '.$user_profile['style'].' alt="'.api_get_person_name($o_course_user['firstname'], $o_course_user['lastname']).'" title="'.api_get_person_name($o_course_user['firstname'], $o_course_user['lastname']).'" />';
}
@ -758,13 +762,13 @@ function get_user_data($from, $number_of_items, $column, $direction)
$temp[] = $user_id;
$temp['is_tutor'] = isset($o_course_user['is_tutor']) ? $o_course_user['is_tutor'] : '';
$temp['user_status_in_course'] = isset($o_course_user['status_rel']) ? $o_course_user['status_rel'] : '';
$temp['user_status_in_course_session'] = $o_course_user['status_session'];
} else {
$image_path = UserManager::get_user_picture_path_by_id($user_id, 'web', false, true);
$image_repository = $image_path['dir'];
$existing_image = $image_path['file'];
$userInfo = api_get_user_info($user_id);
if (!api_is_anonymous()) {
$photo= '<a href="userInfo.php?'.api_get_cidreq().'&origin='.$origin.'&amp;uInfo='.$user_id.'" title="'.get_lang('Info').'" ><img src="'.$image_repository.$existing_image.'" alt="'.api_get_person_name($o_course_user['firstname'], $o_course_user['lastname']).'" width="22" height="22" title="'.api_get_person_name($o_course_user['firstname'], $o_course_user['lastname']).'" /></a>';
$photo = UserManager::getUserProfileLinkWithPicture($userInfo);
} else {
$photo= '<img src="'.$image_repository.$existing_image.'" alt="'.api_get_person_name($o_course_user['firstname'], $o_course_user['lastname']).'" width="22" height="22" title="'.api_get_person_name($o_course_user['firstname'], $o_course_user['lastname']).'" />';
}

@ -1,7 +1,7 @@
<?php
/* For licensing terms, see /license.txt */
use \ChamiloSession as Session;
use ChamiloSession as Session;
/**
* Class Wiki
@ -2134,8 +2134,8 @@ class Wiki
$obj->title.'</a>';
}
$row[] = $obj->user_id <>0 ? '<a href="'.api_get_path(WEB_CODE_PATH).'user/userInfo.php?uInfo='.$userinfo['user_id'].'">'.
api_htmlentities($userinfo['complete_name']).'</a>' : get_lang('Anonymous').' ('.$obj->user_ip.')';
$row[] = $obj->user_id < >0 ? UserManager::getUserProfileLink($userinfo) : get_lang('Anonymous').' ('.$obj->user_ip.')';
$row[] = $year.'-'.$month.'-'.$day.' '.$hours.":".$minutes.":".$seconds;
if ($all_vers=='1') {
@ -3005,9 +3005,8 @@ class Wiki
$username = api_htmlentities(sprintf(get_lang('LoginX'), $userinfo['username']), ENT_QUOTES);
$row = array();
if ($obj->user_id <> 0) {
$row[] = '<a href="'.api_get_path(WEB_CODE_PATH).'user/userInfo.php?uInfo='.$userinfo['user_id'].'">'.
Display::tag('span', api_htmlentities(api_get_person_name($userinfo['firstname'], $userinfo['lastname'])), array('title'=>$username)).
'</a><a href="'.api_get_self().'?cidReq='.$_course['code'].'&action=usercontrib&user_id='.urlencode($obj->user_id).
$row[] = UserManager::getUserProfileLink($userinfo).'
<a href="'.api_get_self().'?cidReq='.$_course['code'].'&action=usercontrib&user_id='.urlencode($obj->user_id).
'&session_id='.api_htmlentities($_GET['session_id']).'&group_id='.api_htmlentities($_GET['group_id']).'"></a>';
} else {
$row[] = get_lang('Anonymous').' ('.$obj->user_ip.')';
@ -3017,7 +3016,14 @@ class Wiki
}
$table = new SortableTableFromArrayConfig($rows,1,10,'MostActiveUsersA_table','','','DESC');
$table->set_additional_parameters(array('cidReq' =>Security::remove_XSS($_GET['cidReq']),'action'=>Security::remove_XSS($action),'session_id'=>Security::remove_XSS($_GET['session_id']),'group_id'=>Security::remove_XSS($_GET['group_id'])));
$table->set_additional_parameters(
array(
'cidReq' => Security::remove_XSS($_GET['cidReq']),
'action' => Security::remove_XSS($action),
'session_id' => Security::remove_XSS($_GET['session_id']),
'group_id' => Security::remove_XSS($_GET['group_id'])
)
);
$table->set_header(0,get_lang('Author'), true);
$table->set_header(1,get_lang('Contributions'), true,array ('style' => 'width:30px;'));
$table->display();
@ -3044,9 +3050,12 @@ class Wiki
return;
}
//first extract the date of last version
// First extract the date of last version
$sql = 'SELECT * FROM '.$tbl_wiki.'
WHERE c_id = '.$course_id.' AND reflink="'.Database::escape_string($page).'" AND '.$groupfilter.$condition_session.'
WHERE
c_id = '.$course_id.' AND
reflink = "'.Database::escape_string($page).'" AND
'.$groupfilter.$condition_session.'
ORDER BY id DESC';
$result=Database::query($sql);
$row=Database::fetch_array($result);
@ -3056,7 +3065,10 @@ class Wiki
//select page to discuss
$sql = 'SELECT * FROM '.$tbl_wiki.'
WHERE c_id = '.$course_id.' AND reflink="'.Database::escape_string($page).'" AND '.$groupfilter.$condition_session.'
WHERE
c_id = '.$course_id.' AND
reflink="'.Database::escape_string($page).'" AND
'.$groupfilter.$condition_session.'
ORDER BY id ASC';
$result=Database::query($sql);
$row=Database::fetch_array($result);
@ -3066,18 +3078,24 @@ class Wiki
//mode assignment: previous to show page type
$icon_assignment = null;
if ($row['assignment']==1) {
$icon_assignment=Display::return_icon('wiki_assignment.png', get_lang('AssignmentDescExtra'),'',ICON_SIZE_SMALL);
$icon_assignment = Display::return_icon('wiki_assignment.png', get_lang('AssignmentDescExtra'),'',ICON_SIZE_SMALL);
} elseif($row['assignment']==2) {
$icon_assignment=Display::return_icon('wiki_work.png', get_lang('AssignmentWorkExtra'),'',ICON_SIZE_SMALL);
$icon_assignment = Display::return_icon('wiki_work.png', get_lang('AssignmentWorkExtra'),'',ICON_SIZE_SMALL);
}
$countWPost = null;
$avg_WPost_score = null;
//Show title and form to discuss if page exist
// Show title and form to discuss if page exist
if ($id!='') {
//Show discussion to students if isn't hidden. Show page to all teachers if is hidden. Mode assignments: If is hidden, show pages to student only if student is the author
if ($row['visibility_disc']==1 || api_is_allowed_to_edit(false,true) || api_is_platform_admin() || ($row['assignment']==2 && $row['visibility_disc']==0 && (api_get_user_id()==$row['user_id']))) {
// Show discussion to students if isn't hidden.
// Show page to all teachers if is hidden.
// Mode assignments: If is hidden, show pages to student only if student is the author
if ($row['visibility_disc']==1 ||
api_is_allowed_to_edit(false,true) ||
api_is_platform_admin() ||
($row['assignment']==2 && $row['visibility_disc']==0 && (api_get_user_id()==$row['user_id']))
) {
echo '<div id="wikititle">';
// discussion action: protecting (locking) the discussion
@ -3144,9 +3162,7 @@ class Wiki
echo $icon_assignment.'&nbsp;&nbsp;&nbsp;'.api_htmlentities($row['title']);
echo ' ('.get_lang('MostRecentVersionBy').' <a href="'.api_get_path(WEB_CODE_PATH).'user/userInfo.php?uInfo='.$lastuserinfo['user_id'].'">'.
Display::tag('span', api_htmlentities(api_get_person_name($lastuserinfo['firstname'], $lastuserinfo['lastname'])), array('title'=>$username)).
'</a> '.$lastversiondate.$countWPost.')'.$avg_WPost_score.' '; //TODO: read average score
echo ' ('.get_lang('MostRecentVersionBy').' '.UserManager::getUserProfileLink($lastuserinfo).' '.$lastversiondate.$countWPost.')'.$avg_WPost_score.' '; //TODO: read average score
echo '</div>';
@ -3305,9 +3321,7 @@ class Wiki
echo '<p><table>';
echo '<tr>';
echo '<td rowspan="2">'.$author_photo.'</td>';
echo '<td style=" color:#999999"><a href="'.api_get_path(WEB_CODE_PATH).'user/userInfo.php?uInfo='.$userinfo['user_id'].'">'.
Display::tag('span', api_htmlentities($userinfo['complete_name'])).
'</a> ('.$author_status.') '.
echo '<td style=" color:#999999">'.UserManager::getUserProfileLink($userinfo).' ('.$author_status.') '.
api_get_local_time($row['dtime'], null, date_default_timezone_get()).
' - '.get_lang('Rating').': '.$row['p_score'].' '.$imagerating.' </td>';
echo '</tr>';
@ -3383,12 +3397,10 @@ class Wiki
$row[] = '<a href="'.api_get_self().'?cidReq='.$_course['code'].'&action=showpage&title='.api_htmlentities(urlencode($obj->reflink)).'&session_id='.api_htmlentities($_GET['session_id']).'&group_id='.api_htmlentities($_GET['group_id']).'">
'.api_htmlentities($obj->title).'</a>';
if ($obj->user_id <>0) {
$row[] = '<a href="'.api_get_path(WEB_CODE_PATH).'user/userInfo.php?uInfo='.$userinfo['user_id'].'">'.
Display::tag('span', api_htmlentities(api_get_person_name($userinfo['firstname'], $userinfo['lastname'])), array('title'=>$username)).
'</a>';
$row[] = UserManager::getUserProfileLink($userinfo);
}
else {
$row[] = get_lang('Anonymous').' ('.api_htmlentities($obj->user_ip).')';
$row[] = get_lang('Anonymous').' ('.api_htmlentities($obj->user_ip).')';
}
$row[] = api_get_local_time($obj->dtime, null, date_default_timezone_get());
@ -3496,13 +3508,11 @@ class Wiki
$row = array();
$row[] = api_get_local_time($obj->dtime, null, date_default_timezone_get());
$row[] = $ShowAssignment.$icon_task;
$row[] = '<a href="'.api_get_self().'?cidReq='.$_course['code'].'&action=showpage&title='.api_htmlentities(urlencode($obj->reflink)).'&amp;view='.$obj->id.'&session_id='.api_get_session_id().'&group_id='.api_get_group_id().'">'.
$row[] = '<a href="'.api_get_self().'?'.api_get_cidreq().'&action=showpage&title='.api_htmlentities(urlencode($obj->reflink)).'&amp;view='.$obj->id.'&session_id='.api_get_session_id().'&group_id='.api_get_group_id().'">'.
api_htmlentities($obj->title).'</a>';
$row[] = $obj->version>1 ? get_lang('EditedBy') : get_lang('AddedBy');
if ($obj->user_id <> 0 ) {
$row[] = '<a href="'.api_get_path(WEB_CODE_PATH).'user/userInfo.php?uInfo='.$userinfo['user_id'].'">'.
Display::tag('span', api_htmlentities(api_get_person_name($userinfo['firstname'], $userinfo['lastname'])), array('title'=>$username)).
'</a>';
$row[] = UserManager::getUserProfileLink($userinfo);
} else {
$row[] = get_lang('Anonymous').' ('.api_htmlentities($obj->user_ip).')';
}
@ -3625,8 +3635,7 @@ class Wiki
$row[] = '<a href="'.api_get_self().'?cidReq='.$_course['code'].'&action=showpage&title='.api_htmlentities(urlencode($obj->reflink)).'&session_id='.api_htmlentities($_GET['session_id']).'&group_id='.api_htmlentities($_GET['group_id']).'">'.
api_htmlentities($obj->title).'</a>';
if ($obj->user_id <>0) {
$row[] = '<a href="'.api_get_path(WEB_CODE_PATH).'user/userInfo.php?uInfo='.$userinfo['user_id'].'">'.
Display::tag('span', api_htmlentities($userinfo['complete_name_with_username'])).'</a>';
$row[] = UserManager::getUserProfileLink($userinfo);
}
else {
$row[] = get_lang('Anonymous').' ('.$obj->user_ip.')';
@ -3711,10 +3720,10 @@ class Wiki
$userinfo = api_get_user_info($userId);
$username = api_htmlentities(sprintf(get_lang('LoginX'), $userinfo['username']), ENT_QUOTES);
echo '<div class="actions">'.get_lang('UserContributions').': <a href="'.api_get_path(WEB_CODE_PATH).'user/userInfo.php?uInfo='.$userinfo['user_id'].'">'.
Display::tag('span', api_htmlentities($userinfo['complete_name']), array('title'=>$username)).
'</a><a href="'.api_get_self().'?cidReq='.$_course['code'].'&action=usercontrib&user_id='.$userId.
'&session_id='.$this->session_id.'&group_id='.$this->group_id.'"></a></div>';
echo '<div class="actions">'.get_lang('UserContributions').': '.UserManager::getUserProfileLink($userinfo).
'<a href="'.api_get_self().'?cidReq='.$_course['code'].'&action=usercontrib&user_id='.$userId.
'&session_id='.$this->session_id.'&group_id='.$this->group_id.'">
</a></div>';
if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
//only by professors if page is hidden
@ -3852,6 +3861,8 @@ class Wiki
}
/**
* Restore page
* @return bool
*/
public function restorePage()
{
@ -3868,7 +3879,7 @@ class Wiki
/* Only teachers and platform admin can edit the index page.
Only teachers and platform admin can edit an assignment teacher*/
if (($current_row['reflink']=='index' || $current_row['reflink']=='' || $current_row['assignment'] == 1) &&
if (($current_row['reflink'] == 'index' || $current_row['reflink'] == '' || $current_row['assignment'] == 1) &&
(!api_is_allowed_to_edit(false,true) && $this->group_id == 0)
) {
self::setMessage(
@ -3897,9 +3908,7 @@ class Wiki
//$icon_assignment = null;
if ($current_row['assignment'] == 1) {
self::setMessage(Display::display_normal_message(get_lang('EditAssignmentWarning'), false, true));
//$icon_assignment = Display::return_icon('wiki_assignment.png', get_lang('AssignmentDescExtra'),'',ICON_SIZE_SMALL);
} elseif($current_row['assignment']==2) {
//$icon_assignment = Display::return_icon('wiki_work.png', get_lang('AssignmentWorkExtra'),'',ICON_SIZE_SMALL);
if (($userId == $current_row['user_id'])==false) {
if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
$PassEdit = true;
@ -3914,7 +3923,9 @@ class Wiki
//show editor if edit is allowed
if ($PassEdit) {
if ($current_row['editlock'] == 1 && (api_is_allowed_to_edit(false,true)==false || api_is_platform_admin()==false)) {
if ($current_row['editlock'] == 1 &&
(api_is_allowed_to_edit(false,true)==false || api_is_platform_admin()==false)
) {
self::setMessage(Display::display_normal_message(get_lang('PageLockedExtra'), false, true));
} else {
if ($last_row['is_editing']!=0 && $last_row['is_editing'] != $userId) {
@ -3924,7 +3935,7 @@ class Wiki
$max_edit_time = 1200; // 20 minutes
$rest_time = $max_edit_time - $time_editing;
$userinfo = api_get_user_info($last_row['is_editing']);
$is_being_edited = get_lang('ThisPageisBeginEditedBy').' <a href='.api_get_path(WEB_CODE_PATH).'user/userInfo.php?uInfo='.$userinfo['user_id'].'>'.
$is_being_edited = get_lang('ThisPageisBeginEditedBy').' <a href='.$userinfo['profile_url'].'>'.
Display::tag('span', $userinfo['complete_name_with_username']).
get_lang('ThisPageisBeginEditedTryLater').' '.date( "i",$rest_time).' '.get_lang('MinMinutes');
self::setMessage(Display::display_normal_message($is_being_edited, false, true));
@ -4504,8 +4515,8 @@ class Wiki
$default_table_for_content_Start='<table align="center" border="0"><tr><td align="center">';
$default_table_for_content_End='</td></tr></table>';
$content = $default_table_for_content_Start.sprintf(get_lang('DefaultContent'),api_get_path(WEB_IMG_PATH)).$default_table_for_content_End;
$title=get_lang('DefaultTitle');
$page_id=0;
$title = get_lang('DefaultTitle');
$page_id = 0;
} else {
$content = api_html_entity_decode($row['content']);
$title = api_html_entity_decode($row['title']);
@ -4618,25 +4629,27 @@ class Wiki
} else {
$message_task_delayedsubmit=get_lang('Yes');
}
if ($row['max_version']==0) {
$message_task_max_version=get_lang('No');
} else {
$message_task_max_version=$row['max_version'];
}
if ($row['max_text']==0) {
$message_task_max_text=get_lang('No');
} else {
$message_task_max_text=$row['max_text'];
}
//comp message
// Comp message
$message_task='<b>'.get_lang('DescriptionOfTheTask').'</b><p>'.$row['task'].'</p><hr>';
$message_task.='<p>'.get_lang('StartDate').': '.$message_task_startdate.'</p>';
$message_task.='<p>'.get_lang('EndDate').': '.$message_task_enddate;
$message_task.=' ('.get_lang('AllowLaterSends').') '.$message_task_delayedsubmit.'</p>';
$message_task.='<p>'.get_lang('OtherSettings').': '.get_lang('NMaxVersion').': '.$message_task_max_version;
$message_task.=' '.get_lang('NMaxWords').': '.$message_task_max_text;
//display message
// Display message
self::setMessage(Display::display_normal_message($message_task, false, true));
}
@ -4655,22 +4668,22 @@ class Wiki
if ($row['is_editing']==0) {
self::setMessage(Display::display_normal_message(get_lang('WarningMaxEditingTime'), false, true));
$time_edit = date("Y-m-d H:i:s");
$sql = 'UPDATE '.$tbl_wiki.' SET is_editing="'.$userId.'", time_edit="'.$time_edit.'"
$sql = 'UPDATE '.$tbl_wiki.' SET
is_editing = "'.$userId.'",
time_edit = "'.$time_edit.'"
WHERE c_id = '.$course_id.' AND id="'.$row['id'].'"';
Database::query($sql);
} elseif ($row['is_editing']!= $userId) {
$timestamp_edit=strtotime($row['time_edit']);
$time_editing=time()-$timestamp_edit;
$max_edit_time=1200; // 20 minutes
$rest_time=$max_edit_time-$time_editing;
$time_editing = time() - $timestamp_edit;
$max_edit_time = 1200; // 20 minutes
$rest_time = $max_edit_time - $time_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').
' <a href='.api_get_path(WEB_CODE_PATH).'user/userInfo.php?uInfo='.$userinfo['user_id'].'>'.
Display::tag('span', api_htmlentities(api_get_person_name($userinfo['firstname'], $userinfo['lastname'])), array('title'=>$username)).
'</a>. '.get_lang('ThisPageisBeginEditedTryLater').' '.date( "i",$rest_time).' '.get_lang('MinMinutes').'';
$is_being_edited = get_lang('ThisPageisBeginEditedBy').' '.UserManager::getUserProfileLink($userinfo).'
'.get_lang('ThisPageisBeginEditedTryLater').' '.date( "i",$rest_time).' '.get_lang('MinMinutes').'';
self::setMessage(Display::display_normal_message($is_being_edited, false, true));
$this->redirectHome();
}
@ -4818,10 +4831,8 @@ class Wiki
echo '</a>';
echo ' ('.get_lang('Version').' '.$row['version'].')';
echo ' '.get_lang('By').' ';
if ($row['user_id']<>0) {
echo '<a href="'.api_get_path(WEB_CODE_PATH).'user/userInfo.php?uInfo='.$userinfo['user_id'].'">'.
Display::tag('span', api_htmlentities(api_get_person_name($userinfo['firstname'], $userinfo['lastname'])), array('title'=>$username)).
'</a>';
if ($row['user_id'] <> 0) {
echo UserManager::getUserProfileLink($userinfo);
} else {
echo get_lang('Anonymous').' ('.api_htmlentities($row['user_ip']).')';
}

@ -177,20 +177,6 @@ class TestWork extends UnitTestCase {
//var_dump($res);
}
/**
* This function displays the firstname and lastname of the user as a link to the user tool.
* @see this is the same function as in the new forum, so this probably has to move to a user library.
* @todo move this function to the user library
*/
function testdisplay_user_link_work() {
global $_otherusers;
$user_id=1;
$res=display_user_link_work($user_id, $name='');
$this->assertTrue(is_string($res));
//var_dump($res);
}
/**
* create a group of select from a date
*/

Loading…
Cancel
Save