[svn r14583] Enable the user image at the Reporting and User Information module. (see FS#2343)

skala
Julio Montoya 17 years ago
parent a72558767c
commit 5b91aad767
  1. 96
      main/inc/lib/usermanager.lib.php
  2. 21
      main/mySpace/myStudents.php
  3. 31
      main/user/userInfo.php

@ -365,6 +365,7 @@ class UserManager
}
echo "</select>";
}
/**
* Get user picture URL or path from user ID (returns an array).
* The return format is a complete path, enabling recovery of the directory
@ -374,31 +375,109 @@ class UserManager
* @param integer User ID
* @param string Type of path to return (can be 'none','system','rel','web')
* @param bool Whether we want to have the directory name returned 'as if' there was a file or not (in the case we want to know which directory to create - otherwise no file means no split subdir)
* @return array Array of 2 elements: 'dir' and 'file' which contain the dir and file as the name implies
* @param bool If we want that the function returns the /main/img/unknown.jpg image set it at true
* @return array Array of 2 elements: 'dir' and 'file' which contain the dir and file as the name implies if image does not exist it will return the unknow image if anonymous parameter is true if not it returns an empty array
*/
function get_user_picture_path_by_id($id,$type='none',$preview=false)
function get_user_picture_path_by_id($id,$type='none',$preview=false,$anonymous=false)
{
if(empty($id) or empty($type))
{
//$error = 'Insufficient parameters';
return array('dir'=>'','file'=>'');
if ($anonymous)
{
$dir='';
switch($type)
{
case 'system': //return the complete path to the file, from root
$dir = api_get_path(SYS_CODE_PATH).'img/';
break;
case 'rel': //return the relative path to the file, from the Dokeos base dir
$dir = api_get_path(REL_CODE_PATH).'img/';
break;
case 'web': //return the complete web URL to the file
$dir = api_get_path(WEB_CODE_PATH).'img/';
break;
case 'none': //return only the picture_uri (as is, without subdir)
default:
break;
}
$file_anonymous='unknown.jpg';
return array('dir'=>$dir,'file'=>$file_anonymous);
}
else
{
return array('dir'=>'','file'=>'');
}
}
$user_id = intval($id);
$user_table = Database :: get_main_table(TABLE_MAIN_USER);
$sql = "SELECT picture_uri FROM $user_table WHERE user_id=".$user_id;
$res = api_sql_query($sql,__FILE__,__LINE__);
$user=array();
if(Database::num_rows($res)>0)
{
$user = Database::fetch_array($res);
$user = Database::fetch_array($res);
}
else
{
$user = false;
return array('dir'=>'','file'=>'');
{
if ($anonymous)
{
$dir='';
switch($type)
{
case 'system': //return the complete path to the file, from root
$dir = api_get_path(SYS_CODE_PATH).'img/';
break;
case 'rel': //return the relative path to the file, from the Dokeos base dir
$dir = api_get_path(REL_CODE_PATH).'img/';
break;
case 'web': //return the complete web URL to the file
$dir = api_get_path(WEB_CODE_PATH).'img/';
break;
case 'none': //return only the picture_uri (as is, without subdir)
default:
break;
}
$file_anonymous='unknown.jpg';
return array('dir'=>$dir,'file'=>$file_anonymous);
}
else
{
return array('dir'=>'','file'=>'');
}
}
$path = trim($user['picture_uri']);
if (empty($path))
{
if ($anonymous)
{
switch($type)
{
case 'system': //return the complete path to the file, from root
$dir = api_get_path(SYS_CODE_PATH).'img/';
break;
case 'rel': //return the relative path to the file, from the Dokeos base dir
$dir = api_get_path(REL_CODE_PATH).'img/';
break;
case 'web': //return the complete web URL to the file
$dir = api_get_path(WEB_CODE_PATH).'img/';
break;
case 'none': //return only the picture_uri (as is, without subdir)
default:
break;
}
$file_anonymous='unknown.jpg';
return array('dir'=>$dir,'file'=>$file_anonymous);
}
}
$dir = '';
$first = '';
if(api_get_setting('split_users_upload_directory') === 'true')
{
if(!empty($path))
@ -414,6 +493,7 @@ class UserManager
{
$first = $user_id.'/';
}
switch($type)
{
case 'system': //return the complete path to the file, from root

@ -255,7 +255,6 @@ if(!empty($_GET['student']))
$csv_content[] = array(strip_tags($first_connection_date),strip_tags($last_connection_date), $time_spent_on_the_platform , $avg_student_progress.' %',$avg_student_score.' %');
?>
<a name="infosStudent"></a>
<table class="data_table">
<tr>
@ -263,21 +262,11 @@ if(!empty($_GET['student']))
<table width="100%" border="0" >
<tr>
<?php
if(!empty($a_infosUser['picture_uri']))
{
echo ' <td class="borderRight" width="10%" valign="top">
<img src="../upload/users/'.$a_infosUser['picture_uri'].'" width="100" />
</td>
';
}
else{
echo ' <td class="borderRight" width="10%" valign="top">
<img src="../img/unknown.jpg" />
</td>
';
}
<?php
$image_array=UserManager::get_user_picture_path_by_id($a_infosUser['user_id'],'web',false, true);
echo '<td class="borderRight" width="10%" valign="top">';
echo '<img src="'.$image_array['dir'].$image_array['file'].'" border="1">';
echo '</td>';
?>
<td class="none" width="40%" valign="top">

@ -215,7 +215,6 @@ if ($allowedToEditContent)
DISPLAY MODES
==============================================================================
*/
// Back button for each display mode (Top)
echo "<div align=\"right\"><a href=\"user.php?".api_get_cidreq()."&amp;origin=".$origin."\">".get_lang('BackUser')."</a></div>\n";
if ($displayMode == "viewDefEdit")
@ -312,17 +311,10 @@ elseif ($displayMode == "viewMainInfoEdit")
{
($mainUserInfo['status'] == 1) ? $courseAdminChecked = "checked" : $courseAdminChecked = "";
($mainUserInfo['tutor_id'] == 1) ? $tutorChecked = "checked" : $tutorChecked = "";
if ($mainUserInfo['picture'] != '')
{
$size = @ getImageSize('../upload/users/'.$mainUserInfo['picture']);
$vertical_space = (($size[1] > 200) ? 'height="200"' : '');
echo "<img src=\"../upload/users/".$mainUserInfo['picture']."\" $vertical_space border=\"1\">";
}
else
{
Display::display_icon('unknown.jpg', get_lang('Unknown'));
}
$image_array=UserManager::get_user_picture_path_by_id($userIdViewed,'web',false,true);
echo '<img src="'.$image_array['dir'].$image_array['file'].'" border="1">';
echo "<form action=\"".api_get_self()."\" method=\"post\">\n",
"<input type=\"hidden\" name=\"submitMainUserInfo\" value=\"$userIdViewed\" />\n",
@ -382,17 +374,10 @@ elseif ($displayMode == "viewContentList") // default display
if ($mainUserInfo)
{
if ($mainUserInfo['picture'] != '')
{
$size = @ getImageSize('../upload/users/'.$mainUserInfo['picture']);
$vertical_space = (($size[1] > 200) ? 'height="200"' : '');
echo "<img src=\"../upload/users/".$mainUserInfo['picture']."\" $vertical_space border=\"1\">";
}
else
{
Display::display_icon('unknown.jpg', get_lang('Unknown'));
}
$image_array=UserManager::get_user_picture_path_by_id($userIdViewed,'web',false,true);
echo '<img src="'.$image_array['dir'].$image_array['file'].'" border="1">';
//DISPLAY TABLE HEADING
if ($origin == 'learnpath') { $allowedToEditDef=false; $is_allowedToTrack=false; }
echo "<table width=\"80%\" border=\"0\">",

Loading…
Cancel
Save