[svn r17362] logic changes - Implemented make the user Image clickable (see FS#456)

skala
Cristian Fasanando 17 years ago
parent 1bf8dc39ff
commit 6237d0215d
  1. 65
      main/admin/user_add.php
  2. 57
      main/admin/user_edit.php
  3. 71
      main/auth/profile.php
  4. 4
      main/inc/lib/usermanager.lib.php
  5. 34
      main/mySpace/myStudents.php
  6. 21
      whoisonline.php

@ -1,4 +1,4 @@
<?php // $Id: user_add.php 17075 2008-12-04 22:49:14Z cfasanando $
<?php // $Id: user_add.php 17362 2008-12-17 23:21:17Z cfasanando $
/*
==============================================================================
Dokeos - elearning and course management software
@ -34,11 +34,11 @@ $cidReset = true;
// including necessary libraries
require ('../inc/global.inc.php');
$libpath = api_get_path(LIBRARY_PATH);
include_once ($libpath.'fileManage.lib.php');
include_once ($libpath.'fileUpload.lib.php');
include_once ($libpath.'usermanager.lib.php');
require_once ($libpath.'fileManage.lib.php');
require_once ($libpath.'fileUpload.lib.php');
require_once ($libpath.'usermanager.lib.php');
require_once ($libpath.'formvalidator/FormValidator.class.php');
require_once (api_get_path(LIBRARY_PATH).'image.lib.php');
// section for the tabs
$this_section=SECTION_PLATFORM_ADMIN;
@ -48,7 +48,7 @@ api_protect_admin_script();
// Database table definitions
$table_admin = Database :: get_main_table(TABLE_MAIN_ADMIN);
$table_user = Database :: get_main_table(TABLE_MAIN_USER);
$database = Database::get_main_database();
$htmlHeadXtra[] = '
<script language="JavaScript" type="text/JavaScript">
@ -305,6 +305,7 @@ $form->setDefaults($defaults);
// Submit button
$form->addElement('submit', 'submit', get_lang('Add'));
$form->addElement('submit', 'submit_plus', get_lang('Add').'+');
// Validate form
if( $form->validate())
{
@ -315,19 +316,55 @@ if( $form->validate())
$picture_element = & $form->getElement('picture');
$picture = $picture_element->getValue();
$picture_uri = '';
if (strlen($picture['name']) > 0)
{
if(!is_dir(api_get_path(SYS_CODE_PATH).'upload/users/')){
if(mkdir(api_get_path(SYS_CODE_PATH).'upload/users/'))
{
// get the next id from a user
$sql = "SHOW TABLE STATUS FROM $database LIKE 'user'";
$result = api_sql_query($sql,__FILE__,__LINE__);
$array = Database::fetch_array($result);
$auto_increment = $array['Auto_increment'];
// picture path
$picture_path = api_get_path(SYS_CODE_PATH).'upload/users/'.$auto_increment.'/';
if (strlen($picture['name']) > 0 ) {
if (!is_dir($picture_path)) {
if (mkdir($picture_path)) {
$perm = api_get_setting('permissions_for_new_directories');
$perm = octdec(!empty($perm)?$perm:'0770');
chmod(api_get_path(SYS_CODE_PATH).'upload/users/');
chmod($picture_path,$perm);
}
}
$picture_uri = uniqid('').'_'.replace_dangerous_char($picture['name']);
$picture_location = api_get_path(SYS_CODE_PATH).'upload/users/'.$picture_uri;
move_uploaded_file($picture['tmp_name'], $picture_location);
$picture_location = $picture_path.$picture_uri;
$big_picture_location = $picture_path.'big_'.$picture_uri;
// get the picture and resize it 100x150
$temp = new image($_FILES['picture']['tmp_name']);
$picture_infos=getimagesize($_FILES['picture']['tmp_name']);
$thumbwidth = IMAGE_THUMBNAIL_WIDTH;
if (empty($thumbwidth) or $thumbwidth==0) {
$thumbwidth=150;
}
$new_height = round(($thumbwidth/$picture_infos[0])*$picture_infos[1]);
$temp->resize($thumbwidth,$new_height,0);
$type=$picture_infos[2];
// original picture
$big_temp = new image($_FILES['picture']['tmp_name']);
switch (!empty($type)) {
case 2 : $temp->send_image('JPG',$picture_location);
$big_temp->send_image('JPG',$big_picture_location);
break;
case 3 : $temp->send_image('PNG',$picture_location);
$big_temp->send_image('JPG',$big_picture_location);
break;
case 1 : $temp->send_image('GIF',$picture_location);
$big_temp->send_image('JPG',$big_picture_location);
break;
}
}
$lastname = $user['lastname'];
$firstname = $user['firstname'];

@ -1,4 +1,4 @@
<?php // $Id: user_edit.php 16708 2008-11-10 22:14:49Z yannoo $
<?php // $Id: user_edit.php 17362 2008-12-17 23:21:17Z cfasanando $
/*
==============================================================================
Dokeos - elearning and course management software
@ -54,14 +54,22 @@ function display_drh_list(){
document.getElementById("drh_select").options[0].selected="selected";
}
}
function show_image(image,width,height) {
width = parseInt(width) + 20;
height = parseInt(height) + 20;
window_x = window.open(\'\',\'windowX\',\'width=\'+ width + \', height=\'+ height + \'\');
window_x.document.write("<img src=\'"+image+"?rand='.time().'\'/>");
}
//-->
</script>';
include(api_get_path(LIBRARY_PATH).'fileManage.lib.php');
include(api_get_path(LIBRARY_PATH).'fileUpload.lib.php');
include(api_get_path(LIBRARY_PATH).'usermanager.lib.php');
require_once(api_get_path(LIBRARY_PATH).'fileManage.lib.php');
require_once(api_get_path(LIBRARY_PATH).'fileUpload.lib.php');
require_once(api_get_path(LIBRARY_PATH).'usermanager.lib.php');
require_once (api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php');
require_once (api_get_path(LIBRARY_PATH).'image.lib.php');
$user_id=isset($_GET['user_id']) ? intval($_GET['user_id']) : intval($_POST['user_id']);
$noPHP_SELF=true;
$tool_name=get_lang('ModifyUserInfo');
@ -300,7 +308,7 @@ if( $form->validate())
//get the picture directory
$picture_paths = UserManager::get_user_picture_path_by_id($user_id,'system',true);
$picture_location = $picture_paths['dir'];
$big_picture_location = $picture_paths['dir'];
if (strlen($picture['name']) > 0)
{
$picture_uri = uniqid('').'_'.replace_dangerous_char($picture['name']);
@ -309,7 +317,36 @@ if( $form->validate())
mkpath($picture_location);
}
$picture_location .= $picture_uri;
move_uploaded_file($picture['tmp_name'], $picture_location);
$big_picture_location .= 'big_'.$picture_uri;
// get the picture and resize it 100x150
$temp = new image($_FILES['picture']['tmp_name']);
$picture_infos=getimagesize($_FILES['picture']['tmp_name']);
$thumbwidth = IMAGE_THUMBNAIL_WIDTH;
if (empty($thumbwidth) or $thumbwidth==0) {
$thumbwidth=150;
}
$new_height = round(($thumbwidth/$picture_infos[0])*$picture_infos[1]);
$temp->resize($thumbwidth,$new_height,0);
$type=$picture_infos[2];
// original picture
$big_temp = new image($_FILES['picture']['tmp_name']);
switch (!empty($type)) {
case 2 : $temp->send_image('JPG',$picture_location);
$big_temp->send_image('JPG',$big_picture_location);
break;
case 3 : $temp->send_image('PNG',$picture_location);
$big_temp->send_image('JPG',$big_picture_location);
break;
case 1 : $temp->send_image('GIF',$picture_location);
$big_temp->send_image('JPG',$big_picture_location);
break;
}
}
elseif(isset($user['delete_picture']))
{
@ -426,7 +463,13 @@ $img_attributes = 'src="'.$image_file.'?rand='.time().'" '
if ($image_size[0] > 300) //limit display width to 300px
$img_attributes .= 'width="300" ';
echo '<img '.$img_attributes.'/>';
// get the path,width and height from original picture
$big_image = $image_dir.'big_'.$image;
$big_image_size = @getimagesize($big_image);
$big_image_width= $big_image_size[0];
$big_image_height= $big_image_size[1];
echo '<input type="image" '.$img_attributes.' onclick="return show_image(\''.$big_image.'\',\''.$big_image_width.'\',\''.$big_image_height.'\');"/>';
// Display form
$form->display();

@ -1,4 +1,4 @@
<?php // $Id: profile.php 17222 2008-12-10 23:09:20Z iflorespaz $
<?php // $Id: profile.php 17362 2008-12-17 23:21:17Z cfasanando $
/*
==============================================================================
Dokeos - elearning and course management software
@ -56,6 +56,14 @@ function confirmation(name)
else
{return false;}
}
function show_image(image,width,height) {
width = parseInt(width) + 20;
height = parseInt(height) + 20;
window_x = window.open(\'\',\'windowX\',\'width=\'+ width + \', height=\'+ height + \'\');
window_x.document.write("<img src=\'"+image+"?rand='.time().'\'/>");
}
</script>';
if (!empty ($_GET['coursePath']))
@ -439,65 +447,56 @@ function upload_user_image($user_id)
$file_extension = explode('.', $_FILES['picture']['name']);
$file_extension = strtolower($file_extension[count($file_extension) - 1]);
if (!file_exists($image_repository))
{
//error_log('Making path '.$image_repository,0);
if (!file_exists($image_repository)) {
mkpath($image_repository);
}
else
{
//error_log('Path '.$image_repository.' exists',0);
}
if ($existing_image != '')
{
if (KEEP_THE_NAME_WHEN_CHANGE_IMAGE)
{
if ($existing_image != '') {
if (KEEP_THE_NAME_WHEN_CHANGE_IMAGE) {
$picture_filename = $existing_image;
$old_picture_filename = 'saved_'.date('Y_m_d_H_i_s').'_'.uniqid('').'_'.$existing_image;
}
else
{
} else {
$old_picture_filename = $existing_image;
$picture_filename = (PREFIX_IMAGE_FILENAME_WITH_UID ? 'u'.$user_id.'_' : '').uniqid('').'.'.$file_extension;
}
if (KEEP_THE_OLD_IMAGE_AFTER_CHANGE)
{
if (KEEP_THE_OLD_IMAGE_AFTER_CHANGE) {
@rename($image_repository.$existing_image, $image_repository.$old_picture_filename);
}
else
{
} else {
@unlink($image_repository.$existing_image);
}
}
else
{
} else {
$picture_filename = (PREFIX_IMAGE_FILENAME_WITH_UID ? $user_id.'_' : '').uniqid('').'.'.$file_extension;
}
// get the picture and resize it 200x200
$temp = new image($_FILES['picture']['tmp_name']);
$picture_infos=getimagesize($_FILES['picture']['tmp_name']);
$thumbwidth = IMAGE_THUMBNAIL_WIDTH;
if(empty($thumbwidth) or $thumbwidth==0)
{
$thumbwidth=100;
$thumbwidth = 200;
if (empty($thumbwidth) or $thumbwidth==0) {
$thumbwidth=200;
}
$new_height = round(($thumbwidth/$picture_infos[0])*$picture_infos[1]);
$temp->resize($thumbwidth,$new_height,0);
$type=$picture_infos[2];
switch ($type) {
// original picture
$big_temp = new image($_FILES['picture']['tmp_name']);
switch (!empty($type)) {
case 2 : $temp->send_image('JPG',$image_repository.$picture_filename);
$big_temp->send_image('JPG',$image_repository.'big_'.$picture_filename);
break;
case 3 : $temp->send_image('PNG',$image_repository.$picture_filename);
$big_temp->send_image('JPG',$image_repository.'big_'.$picture_filename);
break;
case 1 : $temp->send_image('GIF',$image_repository.$picture_filename);
$big_temp->send_image('JPG',$image_repository.'big_'.$picture_filename);
break;
}
return $picture_filename;
}
/**
@ -749,10 +748,18 @@ $img_attributes = 'src="'.$image_file.'?rand='.time().'" '
.'alt="'.$user_data['lastname'].' '.$user_data['firstname'].'" '
.'style="float:'.($text_dir == 'rtl' ? 'left' : 'right').'; padding:5px;" ';
if ($image_size[0] > 300) //limit display width to 300px
if ($image_size[0] > 300) {
//limit display width to 300px
$img_attributes .= 'width="300" ';
}
// get the path,width and height from original picture
$big_image = $image_dir.'big_'.$image;
$big_image_size = @getimagesize($big_image);
$big_image_width= $big_image_size[0];
$big_image_height= $big_image_size[1];
echo '<img '.$img_attributes.'/>';
echo '<input type="image" '.$img_attributes.' onclick="return show_image(\''.$big_image.'\',\''.$big_image_width.'\',\''.$big_image_height.'\');"/>';
$form->display();

@ -1,4 +1,4 @@
<?php // $Id: usermanager.lib.php 17144 2008-12-08 23:49:52Z yannoo $
<?php // $Id: usermanager.lib.php 17362 2008-12-17 23:21:17Z cfasanando $
/*
==============================================================================
Dokeos - elearning and course management software
@ -209,7 +209,7 @@ class UserManager
$user_info = api_get_user_info($user_id);
if(strlen($user_info['picture_uri']) > 0)
{
$img_path = api_get_path(SYS_CODE_PATH).'upload/users/'.$user_info['picture_uri'];
$img_path = api_get_path(SYS_CODE_PATH).'upload/users/'.$user_id.'/'.$user_info['picture_uri'];
unlink($img_path);
}

@ -1,4 +1,4 @@
<?php //$Id: myStudents.php 16820 2008-11-20 09:14:14Z elixir_inter $
<?php //$Id: myStudents.php 17362 2008-12-17 23:21:17Z cfasanando $
/* For licensing terms, see /dokeos_license.txt */
/**
* Implements the tracking of students in the Reporting pages
@ -15,6 +15,18 @@ require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
require_once api_get_path(LIBRARY_PATH).'course.lib.php';
require_once '../newscorm/learnpath.class.php';
$htmlHeadXtra[] = '<script type="text/javascript">
function show_image(image,width,height) {
width = parseInt(width) + 20;
height = parseInt(height) + 20;
window_x = window.open(\'\',\'windowX\',\'width=\'+ width + \', height=\'+ height + \'\');
window_x.document.write("<img src=\'"+image+"?rand='.time().'\'/>");
}
</script>';
$export_csv = isset($_GET['export']) && $_GET['export'] == 'csv' ? true : false;
if ($export_csv) {
@ -182,7 +194,6 @@ if(!empty($_GET['student']))
<a href="'.api_get_self().'?'.$_SERVER['QUERY_STRING'].'&export=csv"><img src="../img/excel.gif">&nbsp;'.get_lang('ExportAsCSV').'</a>
</div>';
// is the user online ?
$statistics_database = Database :: get_statistic_database();
$a_usersOnline = WhoIsOnline($_GET['student'], $statistics_database, 30);
@ -199,8 +210,6 @@ if(!empty($_GET['student']))
}
}
$avg_student_progress = $avg_student_score = $nb_courses = 0;
$sql = 'SELECT course_code FROM '.$tbl_course_user.' WHERE user_id='.$a_infosUser['user_id'];
$rs = api_sql_query($sql, __FILE__, __LINE__);
@ -218,7 +227,6 @@ if(!empty($_GET['student']))
$a_courses[$row['course_code']] = $row['course_code'];
}
foreach ($a_courses as $key=>$course_code)
{
if(!CourseManager::is_user_subscribed_in_course($a_infosUser['user_id'], $course_code, true))
@ -268,7 +276,20 @@ if(!empty($_GET['student']))
<?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">';
// get the path,width and height from original picture
$image_file = $image_array['dir'].$image_array['file'];
$big_image = $image_array['dir'].'big_'.$image_array['file'];
$big_image_size = @getimagesize($big_image);
$big_image_width= $big_image_size[0];
$big_image_height= $big_image_size[1];
$img_attributes = 'src="'.$image_file.'?rand='.time().'" '
.'alt="'.$a_infosUser['lastname'].' '.$a_infosUser['firstname'].'" '
.'style="float:'.($text_dir == 'rtl' ? 'left' : 'right').'; padding:5px;" ';
echo '<input type="image" '.$img_attributes.' onclick="return show_image(\''.$big_image.'\',\''.$big_image_width.'\',\''.$big_image_height.'\');"/>';
echo '</td>';
?>
@ -1064,4 +1085,3 @@ if($export_csv)
==============================================================================
*/
Display::display_footer();
?>

@ -1,4 +1,4 @@
<?php // $Id: whoisonline.php 16703 2008-11-10 15:36:25Z elixir_inter $
<?php // $Id: whoisonline.php 17362 2008-12-17 23:21:17Z cfasanando $
/*
==============================================================================
Dokeos - elearning and course management software
@ -40,6 +40,16 @@ require_once (api_get_path(LIBRARY_PATH).'usermanager.lib.php');
// table definitions
$track_user_table = Database::get_main_table(TABLE_MAIN_USER);
$htmlHeadXtra[] = '<script type="text/javascript">
function show_image(image,width,height) {
width = parseInt(width) + 20;
height = parseInt(height) + 20;
window_x = window.open(\'\',\'windowX\',\'width=\'+ width + \', height=\'+ height + \'\');
window_x.document.write("<img src=\'"+image+"?rand='.time().'\'/>");
}
</script>';
if ($_GET['chatid'] != '')
{
@ -117,6 +127,7 @@ function display_individual_user($user_id)
global $interbreadcrumb;
$safe_user_id = Database::escape_string($user_id);
// to prevent a hacking attempt: http://www.dokeos.com/forum/viewtopic.php?t=5363
$user_table=Database::get_main_table(TABLE_MAIN_USER);
$sql = "SELECT * FROM $user_table WHERE user_id='".$safe_user_id."'";
@ -144,8 +155,12 @@ function display_individual_user($user_id)
$height += 30;
$width += 30;
$window_name = 'window'.uniqid('');
$onclick = $window_name."=window.open('".$fullurl."','".$window_name."','alwaysRaised=yes, alwaysLowered=no,alwaysOnTop=yes,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=".$width.",height=".$height.",left=200,top=20'); return false;";
echo '<a href="#" onclick="'.$onclick.'" ><img src="'.$fullurl.'" '.$resizing.' alt="'.$alt.'"/></a><br />';
// get the path,width and height from original picture
$big_image = $webdir.'big_'.$user_object->picture_uri;
$big_image_size = @getimagesize($big_image);
$big_image_width= $big_image_size[0];
$big_image_height= $big_image_size[1];
echo '<input type="image" src="'.$fullurl.'" alt="'.$alt.'" onclick="return show_image(\''.$big_image.'\',\''.$big_image_width.'\',\''.$big_image_height.'\');"/><br />';
}
if (api_get_setting("show_email_addresses") == "true")
{

Loading…
Cancel
Save