Improve code to load user picture.

Remove calls from gravatar and centralize in UserManager
1.10.x
Julio Montoya 10 years ago
parent f6096b1b2c
commit 03d263a9a6
  1. 2
      main/admin/group_edit.php
  2. 47
      main/admin/user_edit.php
  3. 40
      main/admin/user_information.php
  4. 11
      main/admin/user_list.php
  5. 53
      main/auth/profile.php
  6. 21
      main/chat/chat_functions.lib.php
  7. 13
      main/chat/chat_whoisonline.php
  8. 2
      main/cron/import_csv.php
  9. 8
      main/cron/user_import/client.php
  10. 8
      main/document/document.php
  11. 4
      main/forum/forumfunction.inc.php
  12. 46
      main/forum/viewthread_flat.inc.php
  13. 21
      main/gradebook/lib/fe/displaygradebook.php
  14. 66
      main/gradebook/user_info.php
  15. 8
      main/gradebook/user_stats.php
  16. 20
      main/group/group_space.php
  17. 4
      main/inc/ajax/social.ajax.php
  18. 50
      main/inc/lib/api.lib.php
  19. 13
      main/inc/lib/attendance.lib.php
  20. 24
      main/inc/lib/diagnoser.lib.php
  21. 10
      main/inc/lib/document.lib.php
  22. 1
      main/inc/lib/events.lib.php
  23. 26
      main/inc/lib/extra_field_value.lib.php
  24. 63
      main/inc/lib/group_portal_manager.lib.php
  25. 52
      main/inc/lib/message.lib.php
  26. 171
      main/inc/lib/social.lib.php
  27. 381
      main/inc/lib/usermanager.lib.php
  28. 25
      main/inc/lib/userportal.lib.php
  29. 2
      main/install/install.lib.php
  30. 1
      main/messages/new_message.php
  31. 26
      main/mySpace/myStudents.php
  32. 29
      main/mySpace/user_add.php
  33. 4
      main/social/friends.php
  34. 14
      main/social/group_invitation.php
  35. 35
      main/social/group_members.php
  36. 16
      main/social/groups.php
  37. 54
      main/social/invitations.php
  38. 14
      main/social/message_for_group_form.inc.php
  39. 2
      main/social/profile.php
  40. 12
      main/social/profile_friends_and_groups.inc.php
  41. 37
      main/social/search.php
  42. 6
      main/template/default/layout/footer.tpl
  43. 1
      main/template/default/layout/head.tpl
  44. 37
      main/user/user.php
  45. 63
      main/webservices/cm_webservice_user.php
  46. 31
      main/webservices/registration.soap.php
  47. 70
      main/wiki/wiki.inc.php
  48. 8
      main/work/work.lib.php
  49. 27
      plugin/advanced_subscription/ajax/advanced_subscription.ajax.php
  50. 4
      plugin/advanced_subscription/test/mails.php
  51. 22
      plugin/ticket/src/new_ticket.php
  52. 24
      plugin/ticket/src/report.php
  53. 4
      src/Chamilo/CoreBundle/Migrations/Schema/V110/Version110.php
  54. 11
      tests/main/inc/lib/social.lib.test.php
  55. 4
      tests/main/inc/lib/usermanager.lib.test.php

@ -120,7 +120,7 @@ if ( $form->validate()) {
Display::display_header($tool_name);
// Group picture
$image_path = GroupPortalManager::get_group_picture_path_by_id($group_id,'web');
$image_path = GroupPortalManager::get_group_picture_path_by_id($group_id, 'web');
$image_dir = $image_path['dir'];
$image = $image_path['file'];
$image_file = ($image != '' ? $image_dir.$image : api_get_path(WEB_CODE_PATH).'img/unknown_group.jpg');

@ -309,7 +309,11 @@ if ($form->validate()) {
if (isset($user['delete_picture']) && $user['delete_picture']) {
$picture_uri = UserManager::delete_user_picture($user_id);
} elseif (!empty($picture['name'])) {
$picture_uri = UserManager::update_user_picture($user_id, $_FILES['picture']['name'], $_FILES['picture']['tmp_name']);
$picture_uri = UserManager::update_user_picture(
$user_id,
$_FILES['picture']['name'],
$_FILES['picture']['tmp_name']
);
}
$lastname = $user['lastname'];
@ -429,46 +433,15 @@ if ($error_drh) {
$message = Display::return_message($err_msg, 'error');
}
$gravatarEnabled = api_get_configuration_value('gravatar_enabled');
// USER PICTURE
$image_path = UserManager::get_user_picture_path_by_id($user_id,'web');
$image_dir = $image_path['dir'];
$image = $image_path['file'];
$image_file = ($image != '' ? $image_dir.$image : api_get_path(WEB_CODE_PATH).'img/unknown.jpg');
$image_size = api_getimagesize($image_file);
if (!$gravatarEnabled) {
$image_file .= '?rand='.time();
}
$img_attributes = 'src="'.$image_file.'" '
.'alt="'.api_get_person_name($user_data['firstname'], $user_data['lastname']).'" '
.'style="float:'.($text_dir == 'rtl' ? 'left' : 'right').'; padding:5px;" ';
if ($image_size['width'] > 300) { //limit display width to 300px
$img_attributes .= 'width="300" ';
}
$content = null;
// get the path,width and height from original picture
$big_image = $image_dir.'big_'.$image;
$big_image_size = api_getimagesize($big_image);
$big_image_width = $big_image_size['width'];
$big_image_height = $big_image_size['height'];
$url_big_image = $image_file;
if (!$gravatarEnabled) {
$url_big_image = $big_image.'?rnd='.time();
}
$bigImage = Usermanager::getUserPicture(api_get_user_id(), USER_IMAGE_SIZE_BIG);
$normalImage = Usermanager::getUserPicture(api_get_user_id(), USER_IMAGE_SIZE_ORIGINAL);
$content .= '<a class="expand-image" href="'.$bigImage.'" /><img src="'.$normalImage.'"></a>';
$content = null;
if ($image == '') {
$content .= '<img '.$img_attributes.' />';
} else {
$content .= '<input type="image" '.$img_attributes.' onclick="javascript: return show_image(\''.$url_big_image.'\',\''.$big_image_width.'\',\''.$big_image_height.'\');"/>';
}
// Display form
$content .= $form->return_form();
$content .= $form->returnForm();
$tpl = new Template($tool_name);
$tpl->assign('message', $message);

@ -50,24 +50,6 @@ if (api_is_platform_admin()) {
);
}
// Getting the user image
$sysdir_array = UserManager::get_user_picture_path_by_id($user['user_id'], 'system', false, true);
$sysdir = $sysdir_array['dir'];
$webdir_array = UserManager::get_user_picture_path_by_id($user['user_id'], 'web', false, true);
$webdir = $webdir_array['dir'];
$fullurl = $webdir.$webdir_array['file'];
$system_image_path = $sysdir.$webdir_array['file'];
list($width, $height, $type, $attr) = @getimagesize($system_image_path);
$resizing = (($height > 200) ? 'height="200"' : '');
$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;";
// Show info about who created this user and when
$creatorId = $user['creator_id'];
$creatorInfo = api_get_user_info($creatorId);
@ -411,19 +393,31 @@ echo '<div class="actions">
echo Display::page_header($tool_name);
$fullUrlBig = Usermanager::getUserPicture(
$user['user_id'],
USER_IMAGE_SIZE_BIG
);
$fullUrl = Usermanager::getUserPicture(
$user['user_id'],
USER_IMAGE_SIZE_ORIGINAL
);
echo '<div class="row">';
echo '<div class="span2">';
echo '<a href="javascript: void(0);" onclick="'.$onclick.'" >'
.'<img src="'.$fullurl.'" '.$resizing.' /></a><br />';
echo '<div class="col-md-2">';
echo '<a class="expand-image" href="'.$fullUrlBig.'">'
.'<img src="'.$fullUrl.'" /></a><br />';
echo '</div>';
echo $message;
echo '<div class="span5">';
echo '<div class="col-md-5">';
echo $userInformation;
echo '</div>';
echo '<div class="span5">';
echo '<div class="col-md-5">';
echo $trackingInformation;
echo '</div>';
echo '</div>';

@ -422,14 +422,9 @@ function get_user_data($from, $number_of_items, $column, $direction) {
$users = array ();
$t = time();
while ($user = Database::fetch_row($res)) {
$image_path = UserManager::get_user_picture_path_by_id($user[0], 'web', false, true);
$user_profile = UserManager::get_picture_user($user[0], $image_path['file'], 22, USER_IMAGE_SIZE_SMALL, ' width="22" height="22" ');
if (!api_is_anonymous()) {
$photo = '<center><a href="'.api_get_path(WEB_PATH).'whoisonline.php?origin=user_list&id='.$user[0].'" title="'.get_lang('Info').'">
<img src="'.$user_profile['file'].'" '.$user_profile['style'].' alt="'.api_get_person_name($user[2],$user[3]).'" title="'.api_get_person_name($user[2], $user[3]).'" /></a></center>';
} else {
$photo = '<center><img src="'.$user_profile['file'].'" '.$user_profile['style'].' alt="'.api_get_person_name($user[2], $user[3]).'" title="'.api_get_person_name($user[2], $user[3]).'" /></center>';
}
$userPicture = UserManager::getUserPicture($user[0], USER_IMAGE_SIZE_SMALL);
$photo = '<img src="'.$userPicture.'" width="22" height="22" alt="'.api_get_person_name($user[2], $user[3]).'" title="'.api_get_person_name($user[2], $user[3]).'" />';
if ($user[7] == 1 && !empty($user[10])) {
// check expiration date
$expiration_time = convert_sql_date($user[10]);

@ -691,60 +691,37 @@ if (!empty($msg_is_not_password)){
Display::addFlash(Display :: return_message($warning_msg, 'warning', false));
}
$gravatarEnabled = api_get_configuration_value('gravatar_enabled');
// User picture size is calculated from SYSTEM path
$image_syspath = UserManager::get_user_picture_path_by_id(api_get_user_id(), 'system', false, true);
$image_syspath['dir'].$image_syspath['file'];
//Web path
$image_path = UserManager::get_user_picture_path_by_id(api_get_user_id(), 'web', false, true);
$image_dir = $image_path['dir'];
$image = $image_path['file'];
$image_file = $image_dir.$image;
if (!$gravatarEnabled) {
$image_file .= '?rand='.time();
}
$img_attributes = 'src="'.$image_file.'" '
.'alt="'.api_get_person_name($user_data['firstname'], $user_data['lastname']).'" '
.'style="float:'.($text_dir == 'rtl' ? 'left' : 'right').'; margin-top:0px;padding:5px;" ';
// get the path,width and height from original picture
$big_image = $image_dir.'big_'.$image;
$big_image_size = api_getimagesize($big_image);
$big_image_width = $big_image_size['width'];
$big_image_height = $big_image_size['height'];
$url_big_image = $image_file;
if (!$gravatarEnabled) {
$url_big_image = $big_image.'?rnd='.time();
}
$show_delete_account_button = api_get_setting('platform_unsubscribe_allowed') == 'true' ? true : false;
$tpl = new Template(get_lang('ModifyProfile'));
$tpl->assign('actions', $actions);
//$tpl->assign('message', Display::getFlashToString());
SocialManager::setSocialUserBlock($tpl, $user_id, 'messages');
if (api_get_setting('allow_social_tool') == 'true') {
SocialManager::setSocialUserBlock($tpl, api_get_user_id(), 'home');
$tpl->assign('social_menu_block', SocialManager::show_social_menu('home', null, api_get_user_id(), false, $show_delete_account_button));
$menu = SocialManager::show_social_menu(
'home',
null,
api_get_user_id(),
false,
$show_delete_account_button
);
$tpl->assign('social_menu_block', $menu);
$tpl->assign('social_right_content', $form->returnForm());
$social_layout = $tpl->get_template('social/inbox.tpl');
$tpl->display($social_layout);
} else {
// Style position:absolute has been removed for Opera-compatibility.
$imageToShow = '<div id="image-message-container" style="float:right;display:inline;padding:3px;width:230px;" >';
$bigImage = Usermanager::getUserPicture(api_get_user_id(), USER_IMAGE_SIZE_BIG);
$normalImage = Usermanager::getUserPicture(api_get_user_id(), USER_IMAGE_SIZE_ORIGINAL);
if ($image == 'unknown.jpg') {
$imageToShow .= '<img '.$img_attributes.' />';
} else {
$imageToShow .= '<input type="image" '.$img_attributes.' onclick="javascript: return show_image(\''.$url_big_image.'\',\''.$big_image_width.'\',\''.$big_image_height.'\');"/>';
}
$imageToShow = '<div id="image-message-container">';
$imageToShow .= '<a class="expand-image" href="'.$bigImage.'" /><img src="'.$normalImage.'"></a>';
$imageToShow .= '</div>';
$content = $imageToShow.$form->returnForm();
$tpl->assign('content', $form->returnForm());
$tpl->assign('content', $content);
$tpl->display_one_col_template();
}

@ -3,8 +3,7 @@
/**
* @package chamilo.chat
*/
use \Michelf\MarkdownExtra;
use \Michelf\Markdown;
use Michelf\MarkdownExtra;
/**
* @author isaac flores paz
@ -157,7 +156,6 @@ function saveMessage($message, $userId, $_course, $session_id, $group_id, $previ
if (!api_is_anonymous()) {
if (!empty($message)) {
Emojione\Emojione::$imagePathPNG = api_get_path(WEB_LIBRARY_PATH).'javascript/emojione/png/';
//Emojione\Emojione::$imagePathSVG = api_get_path(WEB_LIBRARY_PATH).'javascript/emojione/svg/';
Emojione\Emojione::$ascii = true;
// Parsing emojis
@ -209,22 +207,15 @@ function saveMessage($message, $userId, $_course, $session_id, $group_id, $previ
$userId
);
} else {
$doc_id = DocumentManager::get_document_id($_course, $basepath_chat.'/'.$basename_chat.'.log.html');
$doc_id = DocumentManager::get_document_id(
$_course,
$basepath_chat.'/'.$basename_chat.'.log.html'
);
}
$fp = fopen($chat_path.$basename_chat.'.log.html', 'a');
// view user picture
$userImage = UserManager::get_user_picture_path_by_id($userId, 'web', false, true);
if (substr($userImage['file'],0,7) != 'unknown') {
$userPhoto = $userImage['dir'].'medium_'.$userImage['file'];
} else {
$userPhoto = $userImage['dir'].$userImage['file'];
}
if (api_get_configuration_value('gravatar_enabled')) {
$userPhoto = $userImage['file'];
}
$userPhoto = Usermanager::getUserPicture($userId, USER_IMAGE_SIZE_MEDIUM);
$filePhoto = '<img class="chat-image" src="'.$userPhoto.'"/>';

@ -127,18 +127,7 @@ if (!empty($course)) {
} else {
$status = CourseManager::is_course_teacher($user['user_id'], $_SESSION['_course']['id']) ? 1 : 5;
}
$userImage = UserManager::get_user_picture_path_by_id($user['user_id'], 'web', false, true);
if (substr($userImage['file'],0,7) != 'unknown') {
$fileUrl = $userImage['dir'].'medium_'.$userImage['file'];
} else {
$fileUrl = $userImage['dir'].$userImage['file'];
}
if (api_get_configuration_value('gravatar_enabled')) {
$fileUrl = $userImage['file'];
}
$email = $user['email'];
$fileUrl = Usermanager::getUserPicture($user['user_id'], USER_IMAGE_SIZE_MEDIUM);
$url_user_profile=api_get_path(WEB_CODE_PATH).'social/profile.php?u='.$user['user_id'].'&';
?>
<li class="list-group-item">

@ -1483,7 +1483,7 @@ if (isset($_configuration['import_csv_fix_permissions']) &&
echo "Executing: ".$command.PHP_EOL;
system($command);
$command = "sudo find ".api_get_path(SYS_CODE_PATH)."upload/users -type d -exec chmod 777 {} \;";
$command = "sudo find ".api_get_path(SYS_APP_PATH)."upload/users -type d -exec chmod 777 {} \;";
echo "Executing: ".$command.PHP_EOL;
system($command);
}

@ -23,5 +23,11 @@ if (php_sapi_name()!='cli') {
$client = new nusoap_client(api_get_path(WEB_CODE_PATH).'cron/user_import/service.php');
// call import_user method
$response = $client->call('import_users', array('filepath' => api_get_path(SYS_CODE_PATH)."upload/users_import.csv", 'security_key'=>$_configuration['security_key']));
$response = $client->call(
'import_users',
array(
'filepath' => api_get_path(SYS_APP_PATH)."upload/users_import.csv",
'security_key' => $_configuration['security_key'],
)
);
echo $response;

@ -345,16 +345,12 @@ switch ($action) {
$document_info = DocumentManager::get_document_data_by_id(
$document_id,
api_get_course_id(),
true,
0
);
}
$parent_id = $document_info['parent_id'];
$my_path = UserManager::get_user_picture_path_by_id(
api_get_user_id(),
'system'
);
$user_folder = $my_path['dir'].'my_files/';
$my_path = UserManager::getUserPathById(api_get_user_id());
$user_folder = $my_path.'my_files/';
$my_path = null;
if (!file_exists($user_folder)) {

@ -3182,10 +3182,8 @@ function display_user_image($user_id, $name, $origin = '')
$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" ');
return $link.'<img src="'.$friends_profile['file'].'" '.$friends_profile['style'].' alt="'.$name.'" title="'.$name.'" /></a>';
return $link.'<img src="'.$userInfo['avatar'].'" alt="'.$name.'" title="'.$name.'" /></a>';
} else {
return $link.'<img src="'.api_get_path(WEB_CODE_PATH)."img/unknown.jpg".'" alt="'.$name.'" title="'.$name.'" /></a>';
}

@ -1,14 +1,20 @@
<?php
/* For licensing terms, see /license.txt */
/**
* This script manages the display of forum threads in flat view
* @copyright Julio Montoya <gugli100@gmail.com> UI Improvements + lots of bugfixes
* @package chamilo.forum
*/
//delete attachment file
if ((isset($_GET['action']) && $_GET['action']=='delete_attach') && isset($_GET['id_attach'])) {
if ((isset($_GET['action']) &&
$_GET['action']=='delete_attach') &&
isset($_GET['id_attach'])
) {
delete_attachment(0,$_GET['id_attach']);
}
if (isset($current_thread['thread_id'])) {
$rows = get_posts($current_thread['thread_id']);
$increment = 0;
@ -21,13 +27,13 @@ if (isset($current_thread['thread_id'])) {
echo '<table width="100%" class="forum_table" cellspacing="5" border="0">';
// the style depends on the status of the message: approved or not
if ($row['visible']=='0') {
$titleclass='forum_message_post_title_2_be_approved';
$messageclass='forum_message_post_text_2_be_approved';
$leftclass='forum_message_left_2_be_approved';
$titleclass = 'forum_message_post_title_2_be_approved';
$messageclass = 'forum_message_post_text_2_be_approved';
$leftclass = 'forum_message_left_2_be_approved';
} else {
$titleclass='forum_message_post_title';
$messageclass='forum_message_post_text';
$leftclass='forum_message_left';
$titleclass = 'forum_message_post_title';
$messageclass = 'forum_message_post_text';
$leftclass = 'forum_message_left';
}
echo "<tr>";
echo "<td rowspan=\"3\" class=\"$leftclass\">";
@ -45,15 +51,15 @@ if (isset($current_thread['thread_id'])) {
}
echo display_user_link($row['user_id'], $name, '', $username).'<br />';
} else {
echo Display::tag('span', $name, array('title'=>api_htmlentities($username, ENT_QUOTES))).'<br />';
echo Display::tag('span', $name, array('title' => api_htmlentities($username, ENT_QUOTES))).'<br />';
}
$group_id = api_get_group_id();
echo api_convert_and_format_date($row['post_date']).'<br /><br />';
// get attach id
$attachment_list=get_attachment($row['post_id']);
$id_attach = !empty($attachment_list)?$attachment_list['id']:'';
$attachment_list = get_attachment($row['post_id']);
$id_attach = !empty($attachment_list) ? $attachment_list['id'] : '';
// The user who posted it can edit his thread only if the course admin allowed this in the properties of the forum
// The course admin him/herself can do this off course always
if (
@ -74,7 +80,9 @@ if (isset($current_thread['thread_id'])) {
echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&amp;forum=".$clean_forum_id."&amp;thread=".$clean_thread_id."&amp;action=delete&amp;content=post&amp;id=".$row['post_id']."&amp;origin=".$origin."\" onclick=\"javascript:if(!confirm('".addslashes(api_htmlentities(get_lang('DeletePost'), ENT_QUOTES))."')) return false;\">".Display::return_icon('delete.png', get_lang('Delete'),array(), ICON_SIZE_SMALL)."</a>";
}
}
if (api_is_allowed_to_edit(false,true) && !(api_is_course_coach() && $current_forum['session_id']!=$_SESSION['id_session'])) {
if (api_is_allowed_to_edit(false,true) &&
!(api_is_course_coach() && $current_forum['session_id'] != $_SESSION['id_session'])
) {
display_visible_invisible_icon('post', $row['post_id'], $row['visible'],array('forum'=>$clean_forum_id,'thread'=>$clean_thread_id, 'origin'=>$origin ));
echo "";
if ($increment>0) {
@ -120,13 +128,17 @@ if (isset($current_thread['thread_id'])) {
}
echo "</td>";
// prepare the notification icon
if (isset($whatsnew_post_info[$current_forum['forum_id']][$current_thread['thread_id']][$row['post_id']]) && !empty($whatsnew_post_info[$current_forum['forum_id']][$current_thread['thread_id']][$row['post_id']]) and !empty($whatsnew_post_info[$_GET['forum']][$row['thread_id']])) {
$post_image=Display::return_icon('forumpostnew.gif');
if (isset($whatsnew_post_info[$current_forum['forum_id']][$current_thread['thread_id']][$row['post_id']]) &&
!empty($whatsnew_post_info[$current_forum['forum_id']][$current_thread['thread_id']][$row['post_id']]) &&
!empty($whatsnew_post_info[$_GET['forum']][$row['thread_id']])
) {
$post_image = Display::return_icon('forumpostnew.gif');
} else {
$post_image=Display::return_icon('forumpost.gif');
$post_image = Display::return_icon('forumpost.gif');
}
if ($row['post_notification']=='1' && $row['poster_id']==$_user['user_id']) {
$post_image.=Display::return_icon('forumnotification.gif',get_lang('YouWillBeNotified'));
if ($row['post_notification']=='1' && $row['poster_id'] == $_user['user_id']) {
$post_image .= Display::return_icon('forumnotification.gif', get_lang('YouWillBeNotified'));
}
// The post title
@ -151,7 +163,7 @@ if (isset($current_thread['thread_id'])) {
if (!empty($attachment_list) && is_array($attachment_list)) {
foreach ($attachment_list as $attachment) {
echo '<tr><td colspan="2" height="50%">';
$realname=$attachment['path'];
$realname = $attachment['path'];
$user_filename=$attachment['filename'];
echo Display::return_icon('attachment.gif',get_lang('Attachment'));

@ -716,25 +716,12 @@ class DisplayGradebook
$scoretotal = $cattotal[0]->calc_score($user_id);
$scoretotal_display = (isset($scoretotal) ? $scoredisplay->display_score($scoretotal, SCORE_PERCENT) : get_lang('NoResultsAvailable'));
$image_syspath = UserManager::get_user_picture_path_by_id($userid, 'system', false, true);
$image_size = getimagesize($image_syspath['dir'] . $image_syspath['file']);
//Web path
$image_path = UserManager::get_user_picture_path_by_id($userid, 'web', false, true);
$image_file = $image_path['dir'] . $image_path['file'];
if (!api_get_configuration_value('gravatar_enabled')) {
$image_file .= '?rand='.time();
}
$imageUrl = UserManager::getUserPicture($userid);
$img_attributes = 'src="' . $image_file . '" ' . 'alt="' . $user['complete_name'] . '" ';
if ($image_size[0] > 200) {
//limit display width to 200px
$img_attributes .= 'width="200" ';
}
$info = '<div class="row"><div class="span3">';
$info .= '<div class="thumbnail"><img ' . $img_attributes . '/></div>';
$info = '<div class="row"><div class="col-md-3">';
$info .= '<div class="thumbnail"><img src="' . $imageUrl . '" /></div>';
$info .= '</div>';
$info .= '<div class="span6">';
$info .= '<div class="col-md-6">';
$info .= get_lang('Name') . ' : <a target="_blank" href="' . api_get_path(WEB_CODE_PATH) . 'social/profile.php?u=' . $userid . '"> ' .
$user['complete_name'] . '</a><br />';

@ -1,66 +0,0 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Script
* @package chamilo.gradebook
*/
//$cidReset = true;
require_once '../inc/global.inc.php';
api_block_anonymous_users();
if (isset($_GET['userid'])) {
$user_id = Security::remove_XSS($_GET['userid']);
$user = UserManager::get_user_info_by_id($user_id);
if (!$user) {
api_not_allowed();
}
} else {
api_not_allowed();
}
GradebookUtils::block_students();
$form = new UserForm(
UserForm :: TYPE_USER_INFO,
$user,
'user_info_form',
null,
api_get_self() . '?userid=' . $user_id . '&selectcat=' . Security::remove_XSS($_GET['selectcat']).'&'.api_get_cidreq()
);
if ($form->validate()) {
header('Location: user_stats.php?selectcat=' . Security::remove_XSS($_GET['selectcat']).'&userid=' .$user_id.'&'.api_get_cidreq());
exit;
}
$interbreadcrumb[] = array (
'url' => $_SESSION['gradebook_dest'],
'name' => get_lang('Gradebook'
));
Display :: display_header(get_lang('UserInfo'));
//User picture size is calculated from SYSTEM path
$image_syspath = UserManager::get_user_picture_path_by_id($user_id,'system',false,true);
$image_size = getimagesize($image_syspath['dir'].$image_syspath['file']);
//Web path
$image_path = UserManager::get_user_picture_path_by_id($user_id,'web',false,true);
$image_file = $image_path['dir'].$image_path['file'];
if (!api_get_configuration_value('gravatar_enabled')) {
$image_file .= '?rand='.time();
}
$img_attributes = 'src="'.$image_file.'" '
.'alt="'.api_get_person_name($user_data['firstname'], $user_data['lastname']).'" '
.'style="float:left; padding:5px;" ';
if ($image_size[0] > 300) {
//limit display width to 300px
$img_attributes .= 'width="300" ';
}
//@todo need a "makeup"
echo '<img '.$img_attributes.'/>';
$form->display();
Display :: display_footer();

@ -41,10 +41,10 @@ if ($_GET['selectcat'] != null) {
$user_table = new UserTable($my_user_id, $allevals, $alllinks, $addparams);
if (isset ($_GET['exportpdf'])) {
$datagen = new UserDataGenerator($my_user_id, $allevals, $alllinks);
$data_array = $datagen->get_data(UserDataGenerator :: UDG_SORT_NAME, 0, null, true);
$newarray = array ();
$displayscore = ScoreDisplay :: instance();
$datagen = new UserDataGenerator($my_user_id, $allevals, $alllinks);
$data_array = $datagen->get_data(UserDataGenerator :: UDG_SORT_NAME, 0, null, true);
$newarray = array();
$displayscore = ScoreDisplay :: instance();
foreach ($data_array as $data) {
$newarray[] = array_slice($data, 1);
}

@ -330,17 +330,14 @@ if (count($tutors) == 0) {
isset($origin) ? $my_origin = $origin:$my_origin='';
$tutor_info .= '<ul class="thumbnails">';
foreach ($tutors as $index => $tutor) {
$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'];
$existing_image = $image_path['file'];
$completeName = $tab_user_info['complete_name'];
$photo = '<img src="'.$image_repository.$existing_image.'" alt="'.$completeName.'" width="32" height="32" title="'.$completeName.'" />';
$userInfo = api_get_user_info($tutor['user_id']);
$username = api_htmlentities(sprintf(get_lang('LoginX'), $userInfo['username']), ENT_QUOTES);
$completeName = $userInfo['complete_name'];
$photo = '<img src="'.$userInfo['avatar'].'" alt="'.$completeName.'" width="32" height="32" title="'.$completeName.'" />';
$tutor_info .= '<li>';
$tutor_info .= Display::url(
$tab_user_info['complete_name'],
$tab_user_info['profile_url']
$userInfo['complete_name'],
$userInfo['profile_url']
);
$tutor_info .= '</li>';
}
@ -515,10 +512,7 @@ function email_filter($email)
function user_icon_filter($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>';
$photo = '<img src="'.$userInfo['avatar'].'" alt="'.$userInfo['complete_name'].'" width="22" height="22" title="'.$userInfo['complete_name'].'" />';
return Display::url($photo, $userInfo['profile_url']);
}

@ -88,9 +88,9 @@ switch ($action) {
$friend_html.='<li class="span2">';
$friend = $friends[$j];
$user_name = api_xml_http_response_encode($friend['firstName'].' '.$friend['lastName']);
$friends_profile = SocialManager::get_picture_user($friend['friend_user_id'], $friend['image'], 92);
$userPicture = UserManager::getUserPicture($friend['friend_user_id']);
$friend_html.='<div class="thumbnail" onMouseover="show_icon_delete(this)" onMouseout="hide_icon_delete(this)" class="image-social-content" id=div_'.$friends[$j]['friend_user_id'].'>';
$friend_html.='<img src="'.$friends_profile['file'].'" id="imgfriend_'.$friend['friend_user_id'].'" title="'.$user_name.'" />';
$friend_html.='<img src="'.$userPicture.'" id="imgfriend_'.$friend['friend_user_id'].'" title="'.$user_name.'" />';
$friend_html.='<div class="caption">';
$friend_html.='<a href="profile.php?u='.$friend['friend_user_id'].'"><h5>'.$user_name.'</h5></a>';
$friend_html.='<p><button class="btn btn-danger" onclick="delete_friend(this)" id=img_'.$friend['friend_user_id'].'>'.get_lang('Delete').'</button></p>';

@ -333,10 +333,10 @@ define('COURSE_RELATION_TYPE_RRHH', 1);
define('SESSION_RELATION_TYPE_RRHH', 1);
//User image sizes
define('USER_IMAGE_SIZE_ORIGINAL', 1);
define('USER_IMAGE_SIZE_BIG', 2);
define('USER_IMAGE_SIZE_MEDIUM', 3);
define('USER_IMAGE_SIZE_SMALL', 4);
define('USER_IMAGE_SIZE_ORIGINAL', 1);
define('USER_IMAGE_SIZE_BIG', 2);
define('USER_IMAGE_SIZE_MEDIUM', 3);
define('USER_IMAGE_SIZE_SMALL', 4);
// Relation type between users
define('USER_UNKNOW', 0);
@ -1423,40 +1423,14 @@ function _api_format_user($user, $add_password = false)
$result['lastLogin'] = $last_login;
// Getting user avatar.
$picture_filename = trim($result['picture_uri']);
$result['avatar'] = api_get_path(WEB_CODE_PATH).'img/unknown.jpg';
$result['avatar_small'] = api_get_path(WEB_CODE_PATH).'img/unknown_22.jpg';
$result['avatar_sys_path'] = api_get_path(SYS_CODE_PATH).'img/unknown.jpg';
$dir = 'upload/users/'.$user_id.'/';
//if (!empty($picture_filename) && api_is_anonymous() ) { //Why you have to be anonymous?
if (!empty($picture_filename)) {
if (api_get_setting('split_users_upload_directory') === 'true') {
$dir = 'upload/users/'.substr((string)$user_id, 0, 1).'/'.$user_id.'/';
}
}
$image_sys_path = api_get_path(SYS_CODE_PATH).$dir.$picture_filename;
if ($picture_filename && file_exists($image_sys_path)) {
$result['avatar'] = api_get_path(WEB_CODE_PATH).$dir.$picture_filename;
$result['avatar_small'] = api_get_path(WEB_CODE_PATH).$dir.'small_'.$picture_filename;
$result['avatar_sys_path'] = api_get_path(SYS_CODE_PATH).$dir.$picture_filename;
} else if (api_get_configuration_value('gravatar_enabled')) {
$userEmail = isset($user['email']) ? $user['email'] : '';
$gravatarType = api_get_configuration_value('gravatar_type');
$avatarPaths = array(
'avatar' => $result['avatar'],
'avatar_small' => $result['avatar_small'],
'avatar_sys_path' => $result['avatar_sys_path']
);
foreach ($avatarPaths as $key => $value) {
$avatarSize = api_getimagesize($value);
$avatarSize = $avatarSize['width'] > $avatarSize['height'] ?
$avatarSize['width'] :
$avatarSize['height'];
$result[$key] = UserManager::getGravatar($userEmail, $avatarSize, $gravatarType);
}
}
$picture_filename = trim($result['picture_uri']);
$originalFile = UserManager::getUserPicture($user_id, USER_IMAGE_SIZE_ORIGINAL, $result);
$smallFile = UserManager::getUserPicture($user_id, USER_IMAGE_SIZE_SMALL, $result);
$result['avatar'] = $originalFile;
$result['avatar_small'] = $smallFile;
//$result['avatar_sys_path'] = api_get_path(SYS_CODE_PATH).'img/unknown.jpg';
if (isset($user['user_is_online'])) {
$result['user_is_online'] = $user['user_is_online'] == true ? 1 : 0;

@ -615,6 +615,8 @@ class Attendance
foreach ($a_course_users as $key => $user_data) {
$value = array();
$uid = $user_data['user_id'];
$userInfo = api_get_user_info($uid);
$status = $user_data['status'];
if (!empty($groupId)) {
@ -654,16 +656,7 @@ class Attendance
$value['result_color_bar'] = $user_faults['color_bar'];
}
// user's picture
$image_path = UserManager::get_user_picture_path_by_id($uid, 'web', false);
$user_profile = UserManager::get_picture_user($uid, $image_path['file'], 22, USER_IMAGE_SIZE_SMALL, ' width="22" height="22" ');
if (!empty($image_path['file'])) {
$photo = '<center><a class="ajax" href="'.$image_path['dir'].$image_path['file'].'" >
<img src="'.$user_profile['file'].'" '.$user_profile['style'].' alt="'.api_get_person_name($user_data['firstname'], $user_data['lastname']).'" title="'.api_get_person_name($user_data['firstname'], $user_data['lastname']).'" /></a></center>';
} else {
$photo = '<center><img src="'.$user_profile['file'].'" '.$user_profile['style'].' alt="'.api_get_person_name($user_data['firstname'], $user_data['lastname']).'" title="'.api_get_person_name($user_data['firstname'], $user_data['lastname']).'" /></center>';
}
$photo = '<img src ="'.$userInfo['avatar_small'].'" />';
$value['photo'] = $photo;
$value['firstname'] = $user_data['firstname'];

@ -67,13 +67,29 @@ class Diagnoser
* Functions to get the data for the chamilo diagnostics
* @return array of data
*/
function get_chamilo_data() {
function get_chamilo_data()
{
$array = array();
$writable_folders = array('archive', 'courses', 'home', 'main/upload/users/', 'main/default_course_document/images/');
$writable_folders = array(
api_get_path(SYS_APP_PATH) .'cache',
api_get_path(SYS_APP_PATH) .'courses',
api_get_path(SYS_APP_PATH) .'home',
api_get_path(SYS_APP_PATH) .'upload/users/',
api_get_path(SYS_PATH) .'main/default_course_document/images/',
);
foreach ($writable_folders as $index => $folder) {
$writable = is_writable(api_get_path(SYS_PATH) . $folder);
$writable = is_writable($folder);
$status = $writable ? self :: STATUS_OK : self :: STATUS_ERROR;
$array[] = $this->build_setting($status, '[FILES]', get_lang('IsWritable') . ': ' . $folder, 'http://be2.php.net/manual/en/function.is-writable.php', $writable, 1, 'yes_no', get_lang('DirectoryMustBeWritable'));
$array[] = $this->build_setting(
$status,
'[FILES]',
get_lang('IsWritable').': '.$folder,
'http://be2.php.net/manual/en/function.is-writable.php',
$writable,
1,
'yes_no',
get_lang('DirectoryMustBeWritable')
);
}
$exists = file_exists(api_get_path(SYS_CODE_PATH).'install');

@ -5301,15 +5301,7 @@ class DocumentManager
}
} elseif (strstr($basename, 'sf_user_')) {
$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') {
$icon = $image_path['file'];
} else {
//$icon = '../upload/users/' . substr($basename, 8) . '/' . $image_path['file'];
$user_image = true;
$icon = $image_path['dir'] . $image_path['file'];
}
$icon = $userinfo['avatar'];
$basename = get_lang('UserFolder') . ' ' . $userinfo['complete_name'];
} elseif (strstr($path, 'shared_folder_session_')) {

@ -675,7 +675,6 @@ class Event
unset($event_value['firstName']);
unset($event_value['lastName']);
unset($event_value['avatar_small']);
unset($event_value['avatar_sys_path']);
unset($event_value['avatar']);
unset($event_value['mail']);
unset($event_value['password']);

@ -163,29 +163,28 @@ class ExtraFieldValue extends Model
break;
case ExtraField::FIELD_TYPE_FILE_IMAGE:
$dirPermissions = api_get_permissions_for_new_directories();
$sysCodePath = api_get_path(SYS_CODE_PATH);
switch ($this->type) {
case 'course':
$fileDir = "upload/courses/";
$fileDir = api_get_path(SYS_APP_PATH)."upload/courses/";
break;
case 'session':
$fileDir = "upload/sessions/";
$fileDir = api_get_path(SYS_APP_PATH)."upload/sessions/";
break;
case 'user':
$fileDir = UserManager::getUserPathById($this->handler_id);
$fileDir = UserManager::getUserPathById($this->handler_id, 'system');
break;
}
$fileName = ExtraField::FIELD_TYPE_FILE_IMAGE . "_{$params[$this->handler_id]}.png";
if (!file_exists($sysCodePath . $fileDir)) {
mkdir($sysCodePath . $fileDir, $dirPermissions, true);
if (!file_exists($fileDir)) {
mkdir($fileDir, $dirPermissions, true);
}
if ($value['error'] == 0) {
$imageExtraField = new Image($value['tmp_name']);
$imageExtraField->send_image($sysCodePath . $fileDir . $fileName, -1, 'png');
$imageExtraField->send_image($fileDir . $fileName, -1, 'png');
$new_params = array(
$this->handler_id => $params[$this->handler_id],
@ -202,29 +201,28 @@ class ExtraFieldValue extends Model
break;
case ExtraField::FIELD_TYPE_FILE:
$dirPermissions = api_get_permissions_for_new_directories();
$sysCodePath = api_get_path(SYS_CODE_PATH);
switch ($this->type) {
case 'course':
$fileDir = "upload/courses/";
$fileDir = api_get_path(SYS_APP_PATH)."upload/courses/";
break;
case 'session':
$fileDir = "upload/sessions/";
$fileDir = api_get_path(SYS_APP_PATH)."upload/sessions/";
break;
case 'user':
$fileDir = UserManager::getUserPathById($this->handler_id);
$fileDir = UserManager::getUserPathById($this->handler_id, 'system');
break;
}
$cleanedName = api_replace_dangerous_char($value['name']);
$fileName = ExtraField::FIELD_TYPE_FILE . "_{$params[$this->handler_id]}_$cleanedName";
if (!file_exists($sysCodePath . $fileDir)) {
mkdir($sysCodePath . $fileDir, $dirPermissions, true);
if (!file_exists($fileDir)) {
mkdir($fileDir, $dirPermissions, true);
}
if ($value['error'] == 0) {
moveUploadedFile($value, $sysCodePath . $fileDir . $fileName);
moveUploadedFile($value, $fileDir . $fileName);
$new_params = array(
$this->handler_id => $params[$this->handler_id],

@ -530,7 +530,6 @@ class GroupPortalManager
$limit = null,
$image_conf = array('size' => USER_IMAGE_SIZE_MEDIUM, 'height' => 80)
) {
$where = '';
$table_group_rel_user = Database::get_main_table(TABLE_MAIN_USER_REL_GROUP);
$tbl_user = Database::get_main_table(TABLE_MAIN_USER);
$group_id = intval($group_id);
@ -559,22 +558,29 @@ class GroupPortalManager
$where_relation_condition = "AND gu.relation_type IN ($relation_type) ";
}
$sql = "SELECT picture_uri as image, u.user_id, u.firstname, u.lastname, relation_type
$sql = "SELECT
picture_uri as image,
u.user_id,
u.firstname,
u.lastname,
relation_type
FROM $tbl_user u INNER JOIN $table_group_rel_user gu
ON (gu.user_id = u.user_id)
WHERE gu.group_id= $group_id $where_relation_condition
WHERE
gu.group_id= $group_id
$where_relation_condition
ORDER BY relation_type, firstname $limit_text";
$result = Database::query($sql);
$array = array();
while ($row = Database::fetch_array($result, 'ASSOC')) {
if ($with_image) {
$image_path = UserManager::get_user_picture_path_by_id($row['user_id'], 'web', false, true);
$picture = UserManager::get_picture_user($row['user_id'], $image_path['file'], $image_conf['height'], $image_conf['size']);
$row['image'] = '<img src="'.$picture['file'].'" '.$picture['style'].' />';
$picture = UserManager::getUserPicture($row['user_id']);
$row['image'] = '<img src="'.$picture.'" />';
}
$array[$row['user_id']] = $row;
}
return $array;
}
@ -936,29 +942,25 @@ class GroupPortalManager
* with dirname() or the file with basename(). This also works for the
* functions dealing with the user's productions, as they are located in
* the same directory.
* @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
* @param integer $id
* @param string $type Type of path to return (can be 'system', 'web')
* @param bool $preview 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)
* @param bool If we want that the function returns the /main/img/unknown.jpg image set it at true
* @param bool $anonymous 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
*/
public static function get_group_picture_path_by_id($id, $type = 'none', $preview = false, $anonymous = false)
public static function get_group_picture_path_by_id($id, $type = 'web', $preview = false, $anonymous = false)
{
switch ($type) {
case 'system': // Base: absolute system path.
$base = api_get_path(SYS_CODE_PATH);
break;
case 'rel': // Base: semi-absolute web path (no server base).
$base = api_get_path(REL_CODE_PATH);
$base = api_get_path(SYS_APP_PATH);
break;
case 'web': // Base: absolute web path.
$base = api_get_path(WEB_CODE_PATH);
default:
$base = api_get_path(WEB_PATH).'app/';
break;
case 'none':
default: // Base: empty, the result path below will be relative.
$base = '';
}
$noPicturePath = array('dir' => $base.'img/', 'file' => 'unknown.jpg');
@ -1025,16 +1027,20 @@ class GroupPortalManager
/**
* Gets the current group image
* @param string group id
* @param string picture group name
* @param string height
* @param string picture size it can be small_, medium_ or big_
* @param string style css
* @param string $id group id
* @param string $picture_file picture group name
* @param string $height
* @param string $size_picture picture size it can be small_, medium_or big_
* @param string $style css
* @return array with the file and the style of an image i.e $array['file'] $array['style']
*/
public static function get_picture_group($id, $picture_file, $height, $size_picture = GROUP_IMAGE_SIZE_MEDIUM, $style = '')
{
$patch_profile = 'upload/users/groups/';
public static function get_picture_group(
$id,
$picture_file,
$height,
$size_picture = GROUP_IMAGE_SIZE_MEDIUM,
$style = ''
) {
$picture = array();
$picture['style'] = $style;
if ($picture_file == 'unknown.jpg') {
@ -1205,9 +1211,6 @@ class GroupPortalManager
break;
case GROUP_USER_PERMISSION_MODERATOR:
$relation_group_title = get_lang('IAmAModerator');
//$links .= '<li><a href="'.api_get_path(WEB_CODE_PATH).'social/message_for_group_form.inc.php?view_panel=1&height=400&width=610&&user_friend='.api_get_user_id().'&group_id='.$group_id.'&action=add_message_group" class="thickbox" title="'.get_lang('ComposeMessage').'">'.Display::return_icon('compose_message.png', get_lang('NewTopic'), array('hspace'=>'6')).'<span class="social-menu-text4" >'.get_lang('NewTopic').'</span></a></li>';
//$links .= '<li><a href="groups.php?id='.$group_id.'">'. Display::return_icon('message_list.png', get_lang('MessageList'), array('hspace'=>'6')).'<span class="'.($show=='messages_list'?'social-menu-text-active':'social-menu-text4').'" >'.get_lang('MessageList').'</span></a></li>';
//$links .= '<li><a href="group_members.php?id='.$group_id.'">'. Display::return_icon('member_list.png', get_lang('MemberList'), array('hspace'=>'6')).'<span class="'.($show=='member_list'?'social-menu-text-active':'social-menu-text4').'" >'.get_lang('MemberList').'</span></a></li>';
if ($group_info['visibility'] == GROUP_PERMISSION_CLOSED) {
$links .= '<li><a href="group_waiting_list.php?id='.$group_id.'">'.Display::return_icon('waiting_list.png', get_lang('WaitingList'), array('hspace' => '6')).'<span class="'.($show == 'waiting_list' ? 'social-menu-text-active' : 'social-menu-text4').'" >'.get_lang('WaitingList').'</span></a></li>';
}

@ -53,6 +53,7 @@ class MessageManager
GetFullUserName($uid).
"</b>";
}
return Display::return_message(api_xml_http_response_encode($success), 'confirmation', false);
}
@ -877,10 +878,9 @@ class MessageManager
$title = Security::remove_XSS($row['title'], STUDENT, true);
$content = Security::remove_XSS($row['content'], STUDENT, true);
$from_user = UserManager::get_user_info_by_id($user_sender_id);
$name = api_get_person_name($from_user['firstname'], $from_user['lastname']);
$user_image = UserManager::get_picture_user($row['user_sender_id'], $from_user['picture_uri'], 80);
$user_image = Display::img($user_image['file'], $name, array('title' => $name));
$from_user = api_get_user_info($user_sender_id);
$name = $from_user['complete_name'];
$user_image = Display::img($from_user['avatar'], $name, array('title' => $name));
$message_content = Display::page_subheader(str_replace("\\", "", $title));
@ -1060,16 +1060,14 @@ class MessageManager
$value['count'] = $count;
$new_topics[$id] = $value;
}
//$new_topics = sort_column($new_topics,'count');
$param_names = array_keys($_GET);
$array_html = array();
foreach ($new_topics as $index => $topic) {
$html = '';
// topics
//$indent = 0;
$user_sender_info = UserManager::get_user_info_by_id($topic['user_sender_id']);
//$files_attachments = self::get_links_message_attachment_files($topic['id']);
$user_sender_info = api_get_user_info($topic['user_sender_id']);
$name = api_get_person_name($user_sender_info['firstname'], $user_sender_info['lastname']);
$html .= '<div class="row">';
@ -1090,13 +1088,17 @@ class MessageManager
$html .= '<div class="span4">';
$html .= Display::tag('h4', Display::url(Security::remove_XSS($topic['title'], STUDENT, true), 'group_topics.php?id='.$group_id.'&topic_id='.$topic['id']));
if ($my_group_role == GROUP_USER_PERMISSION_ADMIN || $my_group_role == GROUP_USER_PERMISSION_MODERATOR) {
if ($my_group_role == GROUP_USER_PERMISSION_ADMIN ||
$my_group_role == GROUP_USER_PERMISSION_MODERATOR
) {
$actions = '<br />'.Display::url(get_lang('Delete'), api_get_path(WEB_CODE_PATH).'social/group_topics.php?action=delete&id='.$group_id.'&topic_id='.$topic['id'], array('class' => 'btn btn-default'));
}
$date = '';
if ($topic['send_date'] != $topic['update_date']) {
if (!empty($topic['update_date']) && $topic['update_date'] != '0000-00-00 00:00:00') {
if (!empty($topic['update_date']) &&
$topic['update_date'] != '0000-00-00 00:00:00'
) {
$date .= '<div class="message-group-date" > <i>'.get_lang('LastUpdate').' '.date_to_str_ago($topic['update_date']).'</i></div>';
}
} else {
@ -1105,12 +1107,10 @@ class MessageManager
$html .= $date.$actions;
$html .= '</div>';
$image_path = UserManager::get_user_picture_path_by_id($topic['user_sender_id'], 'web', false, true);
$image_repository = $image_path['dir'];
$existing_image = $image_path['file'];
$image = $user_sender_info['avatar'];
$user_info = '<td valign="top"><a href="'.api_get_path(WEB_PATH).'main/social/profile.php?u='.$topic['user_sender_id'].'">'.$name.'&nbsp;</a>';
$user_info .= '<div class="message-group-author"><img src="'.$image_repository.$existing_image.'" alt="'.$name.'" width="32" height="32" title="'.$name.'" /></div>';
$user_info .= '<div class="message-group-author"><img src="'.$image.'" alt="'.$name.'" width="32" height="32" title="'.$name.'" /></div>';
$user_info .= '</td>';
$html .= '<div class="span2">';
@ -1120,6 +1120,7 @@ class MessageManager
$array_html[] = array($html);
}
// grids for items and topics with paginations
$html_messages .= Display::return_sortable_grid(
'topics',
@ -1177,9 +1178,9 @@ class MessageManager
}
$html .= Display::page_subheader(Security::remove_XSS($main_message['title'].$delete_button, STUDENT, true));
$user_sender_info = UserManager::get_user_info_by_id($main_message['user_sender_id']);
$user_sender_info = api_get_user_info($main_message['user_sender_id']);
$files_attachments = self::get_links_message_attachment_files($main_message['id']);
$name = api_get_person_name($user_sender_info['firstname'], $user_sender_info['lastname']);
$name = $user_sender_info['complete_name'];
$topic_page_nr = isset($_GET['topics_page_nr']) ? intval($_GET['topics_page_nr']) : null;
$links.= '<div id="message-reply-link">';
@ -1191,10 +1192,8 @@ class MessageManager
$links.= Display :: return_icon('talk.png', get_lang('Reply')).'</a>';
$links.= '</div>';
$image_path = UserManager::get_user_picture_path_by_id($main_message['user_sender_id'], 'web', false, true);
$image_repository = $image_path['dir'];
$existing_image = $image_path['file'];
$main_content.= '<div class="message-group-author"><img src="'.$image_repository.$existing_image.'" alt="'.$name.'" width="32" height="32" title="'.$name.'" /></div>';
$userPicture = $user_sender_info['avatar'];
$main_content.= '<div class="message-group-author"><img src="'.$userPicture.'" alt="'.$name.'" width="32" height="32" title="'.$name.'" /></div>';
$user_link = '<a href="'.api_get_path(WEB_PATH).'main/social/profile.php?u='.$main_message['user_sender_id'].'">'.$name.'&nbsp;</a>';
$date = '';
@ -1225,9 +1224,9 @@ class MessageManager
$user_link = '';
$links = '';
$html_items = '';
$user_sender_info = UserManager::get_user_info_by_id($topic['user_sender_id']);
$user_sender_info = api_get_user_info($topic['user_sender_id']);
$files_attachments = self::get_links_message_attachment_files($topic['id']);
$name = api_get_person_name($user_sender_info['firstname'], $user_sender_info['lastname']);
$name = $user_sender_info['complete_name'];
$links.= '<div id="message-reply-link">';
if (($my_group_role == GROUP_USER_PERMISSION_ADMIN || $my_group_role == GROUP_USER_PERMISSION_MODERATOR) || $topic['user_sender_id'] == $current_user_id) {
@ -1237,10 +1236,9 @@ class MessageManager
$links.= Display :: return_icon('talk.png', get_lang('Reply')).'</a>';
$links.= '</div>';
$image_path = UserManager::get_user_picture_path_by_id($topic['user_sender_id'], 'web', false, true);
$image_repository = $image_path['dir'];
$existing_image = $image_path['file'];
$html_items.= '<div class="message-group-author"><img src="'.$image_repository.$existing_image.'" alt="'.$name.'" width="32" height="32" title="'.$name.'" /></div>';
$userPicture = $user_sender_info['avatar'];
$html_items.= '<div class="message-group-author"><img src="'.$userPicture.'" alt="'.$name.'" width="32" height="32" title="'.$name.'" /></div>';
$user_link = '<a href="'.api_get_path(WEB_PATH).'main/social/profile.php?u='.$topic['user_sender_id'].'">'.$name.'&nbsp;</a>';
$date = '';

@ -126,14 +126,13 @@ class SocialManager extends UserManager
$res = Database::query($sql);
while ($row = Database::fetch_array($res, 'ASSOC')) {
if ($load_extra_info) {
$path = UserManager::get_user_picture_path_by_id($row['friend_user_id'], 'web', false, true);
$my_user_info = api_get_user_info($row['friend_user_id']);
$list_ids_friends[] = array(
'friend_user_id' => $row['friend_user_id'],
'firstName' => $my_user_info['firstName'],
'lastName' => $my_user_info['lastName'],
'username' => $my_user_info['username'],
'image' => $path['file']
'image' => $my_user_info['avatar']
);
} else {
$list_ids_friends[] = $row;
@ -143,56 +142,26 @@ class SocialManager extends UserManager
return $list_ids_friends;
}
/**
* get list web path of contacts by user id
* @param int user id
* @param int group id
* @param string name to search
* @param array
* @author isaac flores paz
*/
public static function get_list_path_web_by_user_id($user_id, $id_group = null, $search_name = null)
{
$combine_friend = array();
$list_ids = self::get_friends($user_id, $id_group, $search_name);
if (is_array($list_ids)) {
foreach ($list_ids as $values_ids) {
$list_path_image_friend[] = UserManager::get_user_picture_path_by_id(
$values_ids['friend_user_id'],
'web',
false,
true
);
$combine_friend = array(
'id_friend' => $list_ids,
'path_friend' => $list_path_image_friend
);
}
}
return $combine_friend;
}
/**
* get web path of user invitate
* @author isaac flores paz
* @author Julio Montoya setting variable array
* @param int user id
*
* @return array
*/
public static function get_list_web_path_user_invitation_by_user_id($user_id)
{
$list_ids = self::get_list_invitation_of_friends_by_user_id((int) $user_id);
$list_path_image_friend = array();
$list_ids = self::get_list_invitation_of_friends_by_user_id($user_id);
$list = array();
foreach ($list_ids as $values_ids) {
$list_path_image_friend[] = UserManager::get_user_picture_path_by_id(
$list[] = UserManager::get_user_picture_path_by_id(
$values_ids['user_sender_id'],
'web',
false,
true
'web'
);
}
return $list_path_image_friend;
return $list;
}
/**
@ -219,20 +188,19 @@ class SocialManager extends UserManager
$now = api_get_utc_datetime();
$sql_exist = 'SELECT COUNT(*) AS count FROM '.$tbl_message.'
WHERE
user_sender_id='.$user_id.' AND
user_receiver_id='.$friend_id.' AND
msg_status IN(5,6,7);
';
$res_exist = Database::query($sql_exist);
$sql = 'SELECT COUNT(*) AS count FROM '.$tbl_message.'
WHERE
user_sender_id='.$user_id.' AND
user_receiver_id='.$friend_id.' AND
msg_status IN(5,6,7);
';
$res_exist = Database::query($sql);
$row_exist = Database::fetch_array($res_exist, 'ASSOC');
if ($row_exist['count'] == 0) {
$sql = ' INSERT INTO '.$tbl_message.'(user_sender_id,user_receiver_id,msg_status,send_date,title,content)
VALUES('.$user_id.','.$friend_id.','.MESSAGE_STATUS_INVITATION_PENDING.',"'.$now.'","'.$clean_message_title.'","'.$clean_message_content.'") ';
$sql = 'INSERT INTO '.$tbl_message.'(user_sender_id,user_receiver_id,msg_status,send_date,title,content)
VALUES('.$user_id.','.$friend_id.','.MESSAGE_STATUS_INVITATION_PENDING.',"'.$now.'","'.$clean_message_title.'","'.$clean_message_content.'") ';
Database::query($sql);
$sender_info = api_get_user_info($user_id);
@ -247,7 +215,7 @@ class SocialManager extends UserManager
return true;
} else {
//invitation already exist
// invitation already exist
$sql_if_exist = 'SELECT COUNT(*) AS count, id FROM '.$tbl_message.'
WHERE user_sender_id='.$user_id.' AND user_receiver_id='.$friend_id.' AND msg_status = 7';
$res_if_exist = Database::query($sql_if_exist);
@ -278,6 +246,7 @@ class SocialManager extends UserManager
msg_status='.MESSAGE_STATUS_INVITATION_PENDING;
$res = Database::query($sql);
$row = Database::fetch_array($res, 'ASSOC');
return $row['count_message_in_box'];
}
@ -285,21 +254,22 @@ class SocialManager extends UserManager
* Get invitation list received by user
* @author isaac flores paz
* @param int user id
* @return array()
* @return array
*/
public static function get_list_invitation_of_friends_by_user_id($user_id)
{
$tbl_message = Database::get_main_table(TABLE_MESSAGE);
$sql = 'SELECT user_sender_id,send_date,title,content
$sql = 'SELECT user_sender_id, send_date, title, content
FROM '.$tbl_message.'
WHERE
user_receiver_id='.intval($user_id).' AND
user_receiver_id = '.intval($user_id).' AND
msg_status = '.MESSAGE_STATUS_INVITATION_PENDING;
$res = Database::query($sql);
$list_friend_invitation = array();
while ($row = Database::fetch_array($res, 'ASSOC')) {
$list_friend_invitation[] = $row;
}
return $list_friend_invitation;
}
@ -641,23 +611,10 @@ class SocialManager extends UserManager
get_lang('EditGroup').'</a></div>';
}
} else {
$img_array = UserManager::get_user_picture_path_by_id($user_id, 'web', true, true);
$big_image = UserManager::get_picture_user($user_id, $img_array['file'], '', USER_IMAGE_SIZE_BIG);
$big_image = $big_image['file'];
$normal_image = $img_array['dir'].$img_array['file'];
if (!api_get_configuration_value('gravatar_enabled')) {
$big_image .= '?'.uniqid();
$normal_image .= '?'.uniqid();
}
//--- User image
if ($img_array['file'] != 'unknown.jpg') {
$html .= '<a class="expand-image" href="'.$big_image.'"><img class="img-responsive" src='.$normal_image.' /> </a>';
} else {
$html .= '<img src='.$normal_image.' width="110px" />';
}
$big_image = UserManager::getUserPicture($user_id, USER_IMAGE_SIZE_BIG);
$normal_image = UserManager::getUserPicture($user_id, USER_IMAGE_SIZE_ORIGINAL);
$html .= '<a class="expand-image" href="'.$big_image.'"><img class="img-responsive" src='.$normal_image.' /> </a>';
}
$html .= '</div>';
@ -933,6 +890,8 @@ class SocialManager extends UserManager
foreach ($user_list as $uid) {
$user_info = api_get_user_info($uid);
$name = $user_info['complete_name'];
// Anonymous users can't have access to the profile
if (!api_is_anonymous()) {
if (api_get_setting('allow_social_tool') == 'true') {
@ -943,21 +902,12 @@ class SocialManager extends UserManager
} else {
$url = '#';
}
$image_array = UserManager::get_user_picture_path_by_id($uid, 'system', false, true);
// reduce image
$name = $user_info['complete_name'];
$status_icon = Display::span('', array('class' => 'online_user_in_text'));
$user_status = $user_info['status'] == 1 ? Display::span('', array('class' => 'teacher_online')) : Display::span('', array('class' => 'student_online'));
$status_icon = Display::span('', array('class' => 'online_user_in_text'));
$userPicture = $user_info['avatar'];
$friends_profile = UserManager::get_picture_user($uid, $image_array['file'], 80, USER_IMAGE_SIZE_ORIGINAL);
if (($image_array['file'] == 'unknown.jpg'
|| !file_exists($image_array['dir'].$image_array['file'])) &&
!api_get_configuration_value('gravatar_enabled')) {
$friends_profile['file'] = api_get_path(WEB_CODE_PATH).'img/unknown_180_100.jpg';
}
$img = '<img title = "'.$name.'" alt="'.$name.'" src="'.$friends_profile['file'].'">';
$img = '<img title = "'.$name.'" alt="'.$name.'" src="'.$userPicture.'">';
$name = '<a href="'.$url.'">'.$status_icon.$user_status.$name.'</a>';
$html .= '<div class="col-md-4">
@ -993,6 +943,7 @@ class SocialManager extends UserManager
{
global $interbreadcrumb;
$safe_user_id = intval($user_id);
$currentUserId = api_get_user_id();
$user_table = Database::get_main_table(TABLE_MAIN_USER);
$sql = "SELECT * FROM $user_table WHERE user_id = ".$safe_user_id;
@ -1000,38 +951,16 @@ class SocialManager extends UserManager
$html = null;
if (Database::num_rows($result) == 1) {
$user_object = Database::fetch_object($result);
$alt = GetFullUserName($user_id).($_SESSION['_uid'] == $user_id ? '&nbsp;('.get_lang('Me').')' : '');
$userInfo = api_get_user_info($user_id);
$alt = $userInfo['complete_name'].($currentUserId == $user_id ? '&nbsp;('.get_lang('Me').')' : '');
$status = get_status_from_code($user_object->status);
$interbreadcrumb[] = array('url' => 'whoisonline.php', 'name' => get_lang('UsersOnLineList'));
$html .= '<div class ="thumbnail">';
$fullurl = $userInfo['avatar'];
$html .= '<img src="'.$fullurl.'" alt="'.$alt.'" />';
$sysdir_array = UserManager::get_user_picture_path_by_id($safe_user_id, 'system');
$sysdir = $sysdir_array['dir'];
$webdir_array = UserManager::get_user_picture_path_by_id($safe_user_id, 'web');
if (strlen(trim($user_object->picture_uri)) > 0) {
$webdir = $webdir_array['dir'];
$fullurl = $webdir;
$fullurl .= api_get_configuration_value('gravatar_enabled') ?
$webdir_array['file'] :
$user_object->picture_uri;
$system_image_path = $sysdir.$user_object->picture_uri;
list($width, $height, $type, $attr) = @getimagesize($system_image_path);
$height += 30;
$width += 30;
// get the path,width and height from original picture
$big_image = $webdir.'big_'.$user_object->picture_uri;
$big_image_size = api_getimagesize($big_image);
$big_image_width = $big_image_size['width'];
$big_image_height = $big_image_size['height'];
$url_big_image = $big_image.'?rnd='.time();
//echo '<a href="javascript:void()" onclick="javascript: return show_image(\''.$url_big_image.'\',\''.$big_image_width.'\',\''.$big_image_height.'\');" >';
$html .= '<img src="'.$fullurl.'" alt="'.$alt.'" />';
} else {
$html .= api_get_configuration_value('gravatar_enabled') ?
'<img src="'.$webdir_array['file'].'" alt="'.$alt.'" />' :
Display::return_icon('unknown.jpg', get_lang('Unknown'));
}
if (!empty($status)) {
$html .= '<div class="caption">'.$status.'</div>';
}
@ -1073,7 +1002,7 @@ class SocialManager extends UserManager
*/
public static function display_productions($user_id)
{
$webdir_array = UserManager::get_user_picture_path_by_id($user_id, 'web', true);
$webdir_array = UserManager::get_user_picture_path_by_id($user_id, 'web');
$sysdir = UserManager::getUserPathById($user_id, 'system');
$webdir = UserManager::getUserPathById($user_id, 'web');
@ -1355,6 +1284,7 @@ class SocialManager extends UserManager
class="pull-right btn btn-default" /><i class="fa fa-pencil"></i> '.get_lang('Post').'</button>
</form>';
$formattedList .= '</div>';
return $formattedList;
}
@ -1377,7 +1307,6 @@ class SocialManager extends UserManager
$users = array();
$data = array();
foreach ($messages as $key => $message) {
$date = api_get_local_time($message['send_date']);
$userIdLoop = $message['user_sender_id'];
$userFriendIdLoop = $message['user_receiver_id'];
@ -1414,7 +1343,7 @@ class SocialManager extends UserManager
* @param boolean $isOwnWall Determines if the author is in its own social wall or not
* @return string $html The formatted header message post
*/
private static function headerMessagePost($authorId, $receiverId, $users, $message, $isOwnWall = false)
private static function headerMessagePost($authorId, $receiverId, $users, $message, $isOwnWall = false)
{
$date = api_get_local_time($message['send_date']);
$avatarAuthor = $users[$authorId]['avatar'];
@ -1423,8 +1352,7 @@ class SocialManager extends UserManager
$users[$authorId]['firstname'],
$users[$authorId]['lastname']
);
// Deprecated since 2014-10-29
//$avatarReceiver = $users[$receiverId]['avatar'];
$urlReceiver = api_get_path(WEB_CODE_PATH).'social/profile.php?u='.$receiverId;
$nameCompleteReceiver = api_get_person_name(
$users[$receiverId]['firstname'],
@ -1438,14 +1366,9 @@ class SocialManager extends UserManager
$wallImage = '';
if (!empty($message['path'])) {
$pathUserInfo = UserManager::get_user_picture_path_by_id($authorId, 'web', true);
$imageBig = $pathUserInfo['file'];
$imageSmall = $pathUserInfo['file'];
if (!api_get_configuration_value('gravatar_enabled')) {
$pathImg = UserManager::getUserPathById($authorId, 'web').'message_attachments';
$imageBig = $pathImg .self::getImagePath($message['path'], IMAGE_WALL_BIG);
$imageSmall = $pathImg. self::getImagePath($message['path'], IMAGE_WALL_SMALL);
}
$imageBig = UserManager::getUserPicture($authorId, USER_IMAGE_SIZE_BIG);
$imageSmall = UserManager::getUserPicture($authorId, USER_IMAGE_SIZE_SMALL);
$wallImage = '<a class="thumbnail ajax" href="'.$imageBig.'"><img src="'.$imageSmall.'"></a>';
}
@ -1628,7 +1551,7 @@ class SocialManager extends UserManager
if (isset($friends[$k])) {
$friend = $friends[$k];
$name_user = api_get_person_name($friend['firstName'], $friend['lastName']);
$name_user = api_get_person_name($friend['firstName'], $friend['lastName']);
$user_info_friend = api_get_user_info($friend['friend_user_id'], true);
if ($user_info_friend['user_is_online']) {
@ -1639,8 +1562,8 @@ class SocialManager extends UserManager
$friendHtml.= '<li class="">';
// the height = 92 must be the same in the image_friend_network span style in default.css
$friends_profile = SocialManager::get_picture_user($friend['friend_user_id'], $friend['image'], 20, USER_IMAGE_SIZE_SMALL);
$friendHtml.= '<img src="'.$friends_profile['file'].'" id="imgfriend_'.$friend['friend_user_id'].'" title="'.$name_user.'"/>';
$friends_profile = UserManager::getUserPicture($friend['friend_user_id'], USER_IMAGE_SIZE_SMALL);
$friendHtml.= '<img src="'.$friends_profile.'" id="imgfriend_'.$friend['friend_user_id'].'" title="'.$name_user.'"/>';
$link_shared = (empty($link_shared)) ? '' : '&'.$link_shared;
$friendHtml.= $statusIcon .'<a href="profile.php?' .'u=' . $friend['friend_user_id'] . $link_shared . '">' . $name_user .'</a>';
$friendHtml.= '</li>';

@ -410,10 +410,10 @@ class UserManager
// Delete user picture
/* TODO: Logic about api_get_setting('split_users_upload_directory') == 'true'
a user has 4 differnt sized photos to be deleted. */
a user has 4 different sized photos to be deleted. */
$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_id.'/'.$user_info['picture_uri'];
$img_path = api_get_path(SYS_APP_PATH).'upload/users/'.$user_id.'/'.$user_info['picture_uri'];
if (file_exists($img_path))
unlink($img_path);
}
@ -1175,7 +1175,7 @@ class UserManager
* @param string The id
* @param boolean Whether to return the user's extra fields (defaults to false)
* @return array All user information as an associative array
* @todo Use api_get_user_info() instead
* @deprecated Use api_get_user_info() instead
*/
public static function get_user_info_by_id($user_id, $user_fields = false)
{
@ -1191,7 +1191,9 @@ class UserManager
$resf = Database::query($sqlf);
if (Database::num_rows($resf) > 0) {
while ($rowf = Database::fetch_array($resf)) {
$sqlv = "SELECT * FROM $t_ufv WHERE field_id = ".$rowf['id']." AND user_id = ".$user['user_id']." ORDER BY id DESC";
$sqlv = "SELECT * FROM $t_ufv
WHERE field_id = ".$rowf['id']." AND user_id = ".$user['user_id']."
ORDER BY id DESC";
$resv = Database::query($sqlv);
if (Database::num_rows($resv) > 0) {
//There should be only one value for a field and a user
@ -1213,93 +1215,194 @@ class UserManager
* with dirname() or the file with basename(). This also works for the
* functions dealing with the user's productions, as they are located in
* the same directory.
* @param integer User ID
* @param string Type of path to return (can be 'none', 'system', 'rel', 'web')
* @param bool deprecated see #7110
* @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 er's
* @param integer $id User ID
* @param string $type Type of path to return (can be 'system', 'web')
* @param array $userInfo user information to avoid query the DB
* 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
*/
public static function get_user_picture_path_by_id($id, $type = 'none', $preview = false, $anonymous = false)
public static function get_user_picture_path_by_id($id, $type = 'web', $userInfo = [])
{
switch ($type) {
case 'system': // Base: absolute system path.
$base = api_get_path(SYS_CODE_PATH);
break;
case 'rel': // Base: semi-absolute web path (no server base).
$base = api_get_path(REL_CODE_PATH);
break;
case 'web': // Base: absolute web path.
default:
$base = api_get_path(WEB_CODE_PATH);
break;
case 'none':
default: // Base: empty, the result path below will be relative.
$base = '';
}
$gravatarEnabled = api_get_configuration_value('gravatar_enabled');
$noPicturePath = array('dir' => $base.'img/', 'file' => 'unknown.jpg');
if ((empty($id) || empty($type)) && !$gravatarEnabled) {
return $anonymous ? $noPicturePath : array('dir' => '', 'file' => '');
}
$anonymousPath = array(
'dir' => $base.'img/',
'file' => 'unknown.jpg',
'email' => '',
);
$user_id = intval($id);
if ((empty($id) || empty($type))) {
return $anonymousPath;
}
$user_table = Database :: get_main_table(TABLE_MAIN_USER);
$sql = "SELECT email, picture_uri FROM $user_table WHERE user_id=".$user_id;
$res = Database::query($sql);
$id = intval($id);
if (empty($userInfo)) {
$user_table = Database:: get_main_table(TABLE_MAIN_USER);
$sql = "SELECT email, picture_uri FROM $user_table
WHERE user_id=".$id;
$res = Database::query($sql);
if (!Database::num_rows($res) && !$gravatarEnabled) {
return $anonymous ? $noPicturePath : array('dir' => '', 'file' => '');
if (!Database::num_rows($res)) {
return $anonymousPath;
}
$user = Database::fetch_array($res);
} else {
$user = $userInfo;
}
$user = Database::fetch_array($res);
$pictureFilename = trim($user['picture_uri']);
$dir = self::getUserPathById($id, $type);
$picture_filename = trim($user['picture_uri']);
return array(
'dir' => $dir,
'file' => $pictureFilename,
'email' => $user['email'],
);
}
/**
* Get user path from user ID (returns an array).
* The return format is a complete path to a folder ending with "/"
* @param integer $id User ID
* @param string $type Type of path to return (can be 'system', 'web')
* @return string User folder path (i.e. /var/www/chamilo/main/upload/users/1/1/)
*/
public static function getUserPathById($id, $type)
{
$id = intval($id);
if (!$id) {
return null;
}
$userPath = "upload/users/$id/";
if (api_get_setting('split_users_upload_directory') === 'true') {
$userPath = 'upload/users/'.substr((string) $user_id, 0, 1).'/'.$user_id.'/';
$systemImagePath = api_get_path(SYS_CODE_PATH).$userPath;
$dir = $base.$userPath;
} else {
$userPath = 'upload/users/'.$user_id.'/';
$systemImagePath = api_get_path(SYS_CODE_PATH).$userPath;
$dir = $base.$userPath;
$userPath = 'upload/users/'.substr((string) $id, 0, 1).'/'.$id.'/';
}
switch ($type) {
case 'system': // Base: absolute system path.
$userPath = api_get_path(SYS_APP_PATH).$userPath;
break;
case 'web': // Base: absolute web path.
$userPath = api_get_path(WEB_PATH).'app/'.$userPath;
break;
}
return $userPath;
}
/**
* Gets the current user image
* @param string $user_id
* @param string $size it can be USER_IMAGE_SIZE_SMALL,
* USER_IMAGE_SIZE_MEDIUM, USER_IMAGE_SIZE_BIG or USER_IMAGE_SIZE_ORIGINAL
* @param bool $addRandomId
* @param array $userInfo to avoid query the DB
*
* @return string
*/
public static function getUserPicture(
$user_id,
$size = USER_IMAGE_SIZE_MEDIUM,
$addRandomId = true,
$userInfo = []
) {
$imageWebPath = self::get_user_picture_path_by_id($user_id, 'web', $userInfo);
$pictureWebFile = $imageWebPath['file'];
$pictureWebDir = $imageWebPath['dir'];
switch ($size) {
case USER_IMAGE_SIZE_SMALL:
$pictureAnonymous = 'unknown_22.jpg';
$realSizeName = 'small_';
$gravatarSize = 22;
break;
case USER_IMAGE_SIZE_MEDIUM:
$pictureAnonymous = 'unknown_50_50.jpg';
$realSizeName = 'medium_';
$gravatarSize = 50;
break;
case USER_IMAGE_SIZE_ORIGINAL:
$pictureAnonymous = 'unknown.jpg';
$realSizeName = '';
$gravatarSize = 108;
break;
case USER_IMAGE_SIZE_BIG:
$pictureAnonymous = 'unknown.jpg';
$realSizeName = 'big_';
$gravatarSize = 200;
break;
}
$gravatarEnabled = api_get_configuration_value('gravatar_enabled');
if ($gravatarEnabled) {
$avatarSize = api_getimagesize($noPicturePath['dir'].$noPicturePath['file']);
$avatarSize = $avatarSize['width'] > $avatarSize['height'] ?
$avatarSize['width'] :
$avatarSize['height'];
return array(
'dir' => '',
'file' => self::getGravatar(
$user['email'],
$avatarSize,
api_get_configuration_value('gravatar_type')
)
$file = self::getGravatar(
$imageWebPath['email'],
$gravatarSize,
api_get_configuration_value('gravatar_type')
);
if ($addRandomId) {
$file .= '&rand='.uniqid();
}
return $file;
}
$anonymousPath = api_get_path(WEB_CODE_PATH).'img/'.$pictureAnonymous;
if ($pictureWebFile == 'unknown.jpg') {
return $anonymousPath;
}
$pictureSysPath = self::get_user_picture_path_by_id($user_id, 'system');
$file = $pictureSysPath['dir'].$realSizeName.$pictureWebFile;
$picture = '';
if (file_exists($file)) {
$picture = $pictureWebDir.$realSizeName.$pictureWebFile;
} else {
$file = $pictureSysPath['dir'].$pictureWebFile;
if (file_exists($file) && !is_dir($file)) {
$picture = $pictureWebFile['dir'].$pictureWebFile;
}
}
if (empty($picture)) {
return $anonymousPath;
}
if (empty($picture_filename) && $anonymous) {
return $noPicturePath;
if ($addRandomId) {
$picture .= '?rand='.uniqid();
}
return array('dir' => $dir, 'file' => $picture_filename);
return $picture;
}
/**
* Creates new user photos in various sizes of a user, or deletes user photos.
* Note: This method relies on configuration setting from main/inc/conf/profile.conf.php
* @param int $user_id The user internal identification number.
* @param string $file The common file name for the newly created photos.
* It will be checked and modified for compatibility with the file system.
* If full name is provided, path component is ignored.
* If an empty name is provided, then old user photos are deleted only,
* @param int $user_id The user internal identification number.
* @param string $file The common file name for the newly created photos.
* It will be checked and modified for compatibility with the file system.
* If full name is provided, path component is ignored.
* If an empty name is provided, then old user photos are deleted only,
* @see UserManager::delete_user_picture() as the prefered way for deletion.
* @param string $source_file The full system name of the image from which user photos will be created.
* @return string/bool Returns the resulting common file name of created images which usually should be stored in database.
* When deletion is recuested returns empty string. In case of internal error or negative validation returns FALSE.
* @param string $source_file The full system name of the image from which user photos will be created.
* @return string/bool Returns the resulting common file name of created images which usually should be stored in database.
* When deletion is requested returns empty string. In case of internal error or negative validation returns FALSE.
*/
public static function update_user_picture($user_id, $file = null, $source_file = null)
{
@ -1312,11 +1415,12 @@ class UserManager
}
// User-reserved directory where photos have to be placed.
$path_info = self::get_user_picture_path_by_id($user_id, 'system', true);
$path_info = self::get_user_picture_path_by_id($user_id, 'system');
$path = $path_info['dir'];
// If this directory does not exist - we create it.
if (!file_exists($path)) {
@mkdir($path, api_get_permissions_for_new_directories(), true);
mkdir($path, api_get_permissions_for_new_directories(), true);
}
// The old photos (if any).
@ -1358,7 +1462,7 @@ class UserManager
$filename = in_array($old_extension, $allowed_types) ? substr($old_file, 0, -strlen($old_extension)) : $old_file;
$filename = (substr($filename, -1) == '.') ? $filename.$extension : $filename.'.'.$extension;
} else {
$filename = replace_dangerous_char($filename);
$filename = api_replace_dangerous_char($filename);
if (PREFIX_IMAGE_FILENAME_WITH_UID) {
$filename = uniqid('').'_'.$filename;
}
@ -1406,7 +1510,7 @@ class UserManager
}
// User-reserved directory where extra file have to be placed.
$path_info = self::get_user_picture_path_by_id($user_id, 'system', true);
$path_info = self::get_user_picture_path_by_id($user_id, 'system');
$path = $path_info['dir'];
if (!empty($extra_field)) {
$path .= $extra_field . '/';
@ -1450,7 +1554,7 @@ class UserManager
* productions on the filesystem before the removal request has been carried
* out because they'll have to be re-read afterwards anyway.
*
* @param $user_id User id
* @param int $user_id User id
* @param $force Optional parameter to force building after a removal request
* @return A string containing the XHTML code to dipslay the production list, or FALSE
*/
@ -1489,7 +1593,7 @@ class UserManager
* Returns an array with the user's productions.
*
* @param $user_id User id
* @return An array containing the user's productions
* @return array An array containing the user's productions
*/
public static function get_user_productions($user_id)
{
@ -1847,7 +1951,7 @@ class UserManager
return false;
}
$path_info = self::get_user_picture_path_by_id($user_id, 'web', true);
$path_info = self::get_user_picture_path_by_id($user_id, 'web');
$path = $path_info['dir'];
$del_image = api_get_path(WEB_CODE_PATH).'img/delete.png';
$del_text = get_lang('Delete');
@ -1879,7 +1983,7 @@ class UserManager
if (!$full_path) {
// Nothing to do
} else {
$path_info = self::get_user_picture_path_by_id($user_id, 'system', true);
$path_info = self::get_user_picture_path_by_id($user_id, 'system');
$path = $path_info['dir'];
}
$extra_data = self::get_extra_user_data_by_field($user_id, $extra_field);
@ -1914,7 +2018,7 @@ class UserManager
public static function remove_user_extra_file($user_id, $extra_field, $extra_file)
{
$extra_file = Security::filter_filename($extra_file);
$path_info = self::get_user_picture_path_by_id($user_id, 'system', true);
$path_info = self::get_user_picture_path_by_id($user_id, 'system');
if (strpos($extra_file, $extra_field) !== false) {
$path_extra_file = $path_info['dir'].$extra_file;
} else {
@ -3239,97 +3343,7 @@ class UserManager
return $temp;
}
/**
* Gets the current user image
* @param string user id
* @param string picture user name
* @param string height
* @param string picture size it can be USER_IMAGE_SIZE_SMALL, USER_IMAGE_SIZE_MEDIUM, USER_IMAGE_SIZE_BIG or USER_IMAGE_SIZE_ORIGINAL
* @param string style css
* @return array with the file and the style of an image i.e $array['file'] $array['style']
*/
public static function get_picture_user($user_id, $picture_file, $height, $size_picture = USER_IMAGE_SIZE_MEDIUM, $style = '')
{
$gravatarEnabled = api_get_configuration_value('gravatar_enabled');
$picture = array();
$picture['style'] = $style;
if ($picture_file == 'unknown.jpg') {
switch ($size_picture) {
case USER_IMAGE_SIZE_ORIGINAL :
case USER_IMAGE_SIZE_BIG :
case USER_IMAGE_SIZE_MEDIUM :
$picture_file = 'unknown.jpg';
break;
case USER_IMAGE_SIZE_SMALL:
$picture_file = 'unknown_22.jpg';
break;
}
$picture['file'] = api_get_path(WEB_CODE_PATH).'img/'.$picture_file;
if (!$gravatarEnabled) {
return $picture;
}
}
switch ($size_picture) {
case USER_IMAGE_SIZE_ORIGINAL :
$size_picture = '';
break;
case USER_IMAGE_SIZE_BIG :
$size_picture = 'big_';
break;
case USER_IMAGE_SIZE_MEDIUM :
$size_picture = 'medium_';
break;
case USER_IMAGE_SIZE_SMALL :
$size_picture = 'small_';
break;
default:
$size_picture = 'medium_';
}
$image_array_sys = self::get_user_picture_path_by_id($user_id, 'system', false, true);
$image_array = self::get_user_picture_path_by_id($user_id, 'web', false, true);
$file = $image_array_sys['dir'].$size_picture.$picture_file;
if (file_exists($file)) {
$picture['file'] = $image_array['dir'].$size_picture.$picture_file;
$picture['style'] = '';
if ($height > 0) {
$dimension = api_getimagesize($picture['file']);
$margin = (($height - $dimension['width']) / 2);
//@ todo the padding-top should not be here
$picture['style'] = ' style="padding-top:'.$margin.'px; width:'.$dimension['width'].'px; height:'.$dimension['height'].'px;" ';
$picture['original_height'] = $dimension['width'];
$picture['original_width'] = $dimension['height'];
}
} else {
$file = $image_array_sys['dir'].$picture_file;
if (file_exists($file) && !is_dir($file)) {
$picture['file'] = $image_array['dir'].$picture_file;
} else {
switch ($size_picture) {
case 'big_' :
$picture['file'] = api_get_path(WEB_CODE_PATH).'img/unknown.jpg';
break;
case 'medium_' :
$picture['file'] = api_get_path(WEB_CODE_PATH).'img/unknown_50_50.jpg';
break;
case 'small_' :
$picture['file'] = api_get_path(WEB_CODE_PATH).'img/unknown.jpg';
break;
default:
$picture['file'] = api_get_path(WEB_CODE_PATH).'img/unknown.jpg';
break;
}
}
}
if ($gravatarEnabled) {
$picture['file'] = $image_array['file'];
}
return $picture;
}
/**
* @author Isaac flores <isaac.flores@dokeos.com>
@ -5287,7 +5301,14 @@ EOF;
* @return String containing either just a URL or a complete image tag
* @source http://gravatar.com/site/implement/images/php/
*/
public static function getGravatar( $email, $s = 80, $d = 'mm', $r = 'g', $img = false, $atts = array() ) {
private static function getGravatar(
$email,
$s = 80,
$d = 'mm',
$r = 'g',
$img = false,
$atts = array()
) {
$url = 'http://www.gravatar.com/avatar/';
$url .= md5( strtolower( trim( $email ) ) );
$url .= "?s=$s&d=$d&r=$r";
@ -5300,40 +5321,13 @@ EOF;
return $url;
}
/**
* Get user path from user ID (returns an array).
* The return format is a complete path to a folder ending with "/"
* @param integer User ID
* @param string Optional. Type of path to return (can be 'system', 'rel', 'web')
* @return string User folder path (i.e. /var/www/chamilo/main/upload/users/1/1/)
*/
public static function getUserPathById($id, $type = null)
{
$user_id = intval($id);
if (!$user_id) {
return null;
}
$userPath = "upload/users/$user_id/";
if (api_get_setting('split_users_upload_directory') === 'true') {
$userPath = 'upload/users/'.substr((string) $user_id, 0, 1).'/'.$user_id.'/';
}
switch ($type) {
case 'system': // Base: absolute system path.
$userPath = api_get_path(SYS_CODE_PATH).$userPath;
break;
case 'rel': // Base: semi-absolute web path (no server base).
$userPath = api_get_path(REL_CODE_PATH).$userPath;
break;
case 'web': // Base: absolute web path.
$userPath = api_get_path(WEB_CODE_PATH).$userPath;
break;
}
return $userPath;
}
/**
* Displays the name of the user and makes the link to the user profile
* @param $userInfo
* @param array $userInfo
*
* @return string
*/
public static function getUserProfileLink($userInfo)
{
@ -5346,14 +5340,13 @@ EOF;
/**
* Displays the name of the user and makes the link to the user profile
*
* @param $userInfo
* @todo
*
* @return string
*/
public static function getUserProfileLinkWithPicture($userInfo)
{
$imagePath = UserManager::get_user_picture_path_by_id($userInfo['user_id'], 'web', false, true);
$userProfile = UserManager::get_picture_user($userInfo['user_id'], $imagePath['file'], 22, USER_IMAGE_SIZE_SMALL, ' width="22" height="22" ');
return Display::url(Display::img($userProfile['file']), $userInfo['profile_url']);
return Display::url(Display::img($userInfo['avatar']), $userInfo['profile_url']);
}
}

@ -853,30 +853,25 @@ class IndexManager
{
$html = null;
if (!api_is_anonymous()) {
$img_array = UserManager::get_user_picture_path_by_id(
api_get_user_id(),
'web', true, true
);
$img_array = UserManager::get_picture_user(
api_get_user_id(),
$img_array['file'],
50,
USER_IMAGE_SIZE_MEDIUM,
' width="90" height="90" '
);
$profile_content = null;
$userPicture = UserManager::getUserPicture(api_get_user_id());
$content = null;
if (api_get_setting('allow_social_tool') == 'true') {
$profile_content .= '<a style="text-align:center" href="' . api_get_path(WEB_PATH) . 'main/social/home.php"><img src="' . $img_array['file'] . '" ' . $img_array['style'] . ' ></a>';
$content .= '<a style="text-align:center" href="' . api_get_path(WEB_PATH) . 'main/social/home.php">
<img src="' . $userPicture . '" ></a>';
} else {
$profile_content .= '<a style="text-align:center" href="' . api_get_path(WEB_PATH) . 'main/auth/profile.php"><img title="' . get_lang('EditProfile') . '" src="' . $img_array['file'] . '" ' . $img_array['style'] . '></a>';
$content .= '<a style="text-align:center" href="' . api_get_path(WEB_PATH) . 'main/auth/profile.php">
<img title="' . get_lang('EditProfile') . '" src="' . $userPicture. '" ></a>';
}
$html = self::show_right_block(
null,
$profile_content,
$content,
'user_image_block',
array('style' => 'text-align:center;')
);
}
return $html;
}

@ -900,7 +900,7 @@ function display_requirements(
</tr>
<tr>
<td class="requirements-item">'.api_get_path(SYS_APP_PATH).'upload/users/</td>
<td class="requirements-value">'.check_writable(api_get_path(SYS_CODE_PATH).'upload/users/').'</td>
<td class="requirements-value">'.check_writable(api_get_path(SYS_APP_PATH).'upload/users/').'</td>
</tr>
<tr>
<td class="requirements-item">'.api_get_path(SYS_APP_PATH).'upload/sessions/</td>

@ -268,6 +268,7 @@ function manage_form($default, $select_from_user_list = null, $sent_to = null)
$form->setConstants(array('sec_token' => $token));
$html .= $form->returnForm();
}
return $html;
}

@ -467,31 +467,9 @@ if (!empty($student_id)) {
echo '<table width="100%" border="0">';
echo '<tr>';
$gravatarEnabled = api_get_configuration_value('gravatar_enabled');
$image_array = UserManager :: get_user_picture_path_by_id($user_info['user_id'], 'web', false, true);
echo '<td class="borderRight" width="10%" valign="top">';
// 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 = api_getimagesize($big_image);
$big_image_width = $big_image_size['width'];
$big_image_height = $big_image_size['height'];
$url_big_image = $image_file;
if (!$gravatarEnabled) {
$url_big_image = $big_image.'?rnd=' . time();
$image_file .= '?rnd=' . time();
}
$img_attributes = 'src="' . $image_file . '" ' .
'alt="' . $user_info['complete_name']. '" ' .
'style="float:' . ($text_dir == 'rtl' ? 'right' : 'left') . '; padding:5px;" ';
$userPicture = UserManager::getUserPicture($user_info['user_id']);
echo '<img src="' . $userPicture . '" />';
if ($image_array['file'] == 'unknown.jpg') {
echo '<img ' . $img_attributes . ' />';
} else {
echo '<input type="image" ' . $img_attributes . ' onclick="javascript: return show_image(\'' . $url_big_image . '\',\'' . $big_image_width . '\',\'' . $big_image_height . '\');"/>';
}
echo '</td>';
?>
<td width="40%" valign="top">

@ -129,9 +129,9 @@ $form->addRule('email', get_lang('EmailWrong'), 'required');
// Phone
$form->addElement('text', 'phone', get_lang('PhoneNumber'));
// Picture
$form->addElement('file', 'picture', get_lang('AddPicture'));
/*$form->addElement('file', 'picture', get_lang('AddPicture'));
$allowed_picture_types = array ('jpg', 'jpeg', 'png', 'gif');
$form->addRule('picture', get_lang('OnlyImagesAllowed').' ('.implode(',', $allowed_picture_types).')', 'filetype', $allowed_picture_types);
$form->addRule('picture', get_lang('OnlyImagesAllowed').' ('.implode(',', $allowed_picture_types).')', 'filetype', $allowed_picture_types);*/
// Username
$form->addElement('text', 'username', get_lang('LoginName'), array('maxlength' => USERNAME_MAX_LENGTH));
$form->addRule('username', get_lang('ThisFieldIsRequired'), 'required');
@ -226,14 +226,6 @@ 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/')) {
mkdir(api_get_path(SYS_CODE_PATH).'upload/users/', api_get_permissions_for_new_directories());
}
$picture_uri = uniqid('').'_'.api_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);
}
$lastname = $user['lastname'];
$firstname = $user['firstname'];
$official_code = $user['official_code'];
@ -261,7 +253,22 @@ if ($form->validate()) {
// default status = student
$status = 5;
//create user
$user_id = UserManager::create_user($firstname, $lastname, $status, $email, $username, $password, $official_code, api_get_setting('platformLanguage'), $phone, $picture_uri, $auth_source, $expiration_date, $active, $hr_dept_id);
$user_id = UserManager::create_user(
$firstname,
$lastname,
$status,
$email,
$username,
$password,
$official_code,
api_get_setting('platformLanguage'),
$phone,
$picture_uri,
$auth_source,
$expiration_date,
$active,
$hr_dept_id
);
//adding to the session
if (api_is_session_admin()) {

@ -117,9 +117,9 @@ if (count($friends) == 0) {
$friend_html.='<li class="span2">';
$friend = $friends[$j];
$user_name = api_xml_http_response_encode($friend['firstName'].' '.$friend['lastName']);
$friends_profile = SocialManager::get_picture_user($friend['friend_user_id'], $friend['image'], 92);
$userPicture = UserManager::getUserPicture($friend['friend_user_id']);
$friend_html.='<div class="thumbnail" onMouseover="show_icon_delete(this)" onMouseout="hide_icon_delete(this)" class="image-social-content" id=div_'.$friends[$j]['friend_user_id'].'>';
$friend_html.='<img src="'.$friends_profile['file'].'" id="imgfriend_'.$friend['friend_user_id'].'" title="'.$user_name.'" /> ';
$friend_html.='<img src="'.$userPicture.'" id="imgfriend_'.$friend['friend_user_id'].'" title="'.$user_name.'" /> ';
$friend_html.='<div class="caption">
<a href="profile.php?u='.$friend['friend_user_id'].'"> <h5>'.$user_name.'</h5></a>';
$friend_html.='<p><button onclick="delete_friend(this)" id=img_'.$friend['friend_user_id'].' />'.get_lang('Delete').'</button></p>

@ -499,18 +499,8 @@ $members = GroupPortalManager::get_users_by_group(
);
if (is_array($members) && count($members) > 0) {
foreach ($members as &$member) {
$image_path = UserManager::get_user_picture_path_by_id(
$member['user_id'],
'web',
false,
true
);
$picture = UserManager::get_picture_user(
$member['user_id'],
$image_path['file'],
80
);
$member['image'] = '<img src="' . $picture['file'] . '" width="50px" height="50px" />';
$userPicture = UserManager::getUserPicture($member['user_id']);
$member['image'] = '<img src="' . $userPicture . '" width="50px" height="50px" />';
}
$social_right_content .= '<h3>' . get_lang('UsersAlreadyInvited') . '</h3>';
$social_right_content .= Display::return_sortable_grid(

@ -122,13 +122,13 @@ $social_right_content .= '<div style="width:90%">';
foreach ($users as $user) {
switch ($user['relation_type']) {
case GROUP_USER_PERMISSION_ADMIN:
case GROUP_USER_PERMISSION_ADMIN:
$user['link'] = Display::return_icon(
'social_group_admin.png',
get_lang('Admin')
);
break;
case GROUP_USER_PERMISSION_READER:
case GROUP_USER_PERMISSION_READER:
if (in_array(
$user_role,
array(
@ -137,30 +137,34 @@ foreach ($users as $user) {
)
)
) {
$user['link'] = '<a href="group_members.php?id=' . $group_id . '&u=' . $user['user_id'] . '&action=delete">' . Display::return_icon(
$user['link'] = '<a href="group_members.php?id=' . $group_id . '&u=' . $user['user_id'] . '&action=delete">' .
Display::return_icon(
'delete.png',
get_lang('DeleteFromGroup')
) . '</a>' .
'<a href="group_members.php?id=' . $group_id . '&u=' . $user['user_id'] . '&action=set_moderator">' . Display::return_icon(
'<a href="group_members.php?id=' . $group_id . '&u=' . $user['user_id'] . '&action=set_moderator">' .
Display::return_icon(
'social_moderator_add.png',
get_lang('AddModerator')
) . '</a>';
}
break;
case GROUP_USER_PERMISSION_PENDING_INVITATION:
$user['link'] = '<a href="group_members.php?id=' . $group_id . '&u=' . $user['user_id'] . '&action=add">' . Display::return_icon(
case GROUP_USER_PERMISSION_PENDING_INVITATION:
$user['link'] = '<a href="group_members.php?id=' . $group_id . '&u=' . $user['user_id'] . '&action=add">' .
Display::return_icon(
'pending_invitation.png',
get_lang('PendingInvitation')
) . '</a>';
break;
case GROUP_USER_PERMISSION_MODERATOR:
case GROUP_USER_PERMISSION_MODERATOR:
$user['link'] = Display::return_icon(
'social_group_moderator.png',
get_lang('Moderator')
);
//only group admin can manage moderators
if ($user_role == GROUP_USER_PERMISSION_ADMIN) {
$user['link'] .= '<a href="group_members.php?id=' . $group_id . '&u=' . $user['user_id'] . '&action=delete_moderator">' . Display::return_icon(
$user['link'] .= '<a href="group_members.php?id=' . $group_id . '&u=' . $user['user_id'] . '&action=delete_moderator">'.
Display::return_icon(
'social_moderator_delete.png',
get_lang('DeleteModerator')
) . '</a>';
@ -168,19 +172,8 @@ foreach ($users as $user) {
break;
}
$image_path = UserManager::get_user_picture_path_by_id(
$user['user_id'],
'web',
false,
true
);
$picture = UserManager::get_picture_user(
$user['user_id'],
$image_path['file'],
80
);
$user['image'] = '<img src="' . $picture['file'] . '" width="50px" height="50px" />';
$userPicture = UserManager::getUserPicture($user['user_id']);
$user['image'] = '<img src="' . $userPicture . '" width="50px" height="50px" />';
$new_member_list[] = $user;
}
if (count($new_member_list) > 0) {

@ -396,18 +396,8 @@ if ($group_id != 0) {
} else {
$icon = '';
}
$image_path = UserManager::get_user_picture_path_by_id(
$member['user_id'],
'web',
false,
true
);
$picture = UserManager::get_picture_user(
$member['user_id'],
$image_path['file'],
60,
USER_IMAGE_SIZE_MEDIUM
);
$userPicture = UserManager::getUserPicture($member['user_id']);
$member_content .= '<div class="">';
$member_name = Display::url(
@ -418,7 +408,7 @@ if ($group_id != 0) {
'profile.php?u=' . $member['user_id']
);
$member_content .= Display::div(
'<img height="44" border="2" align="middle" vspace="10" class="social-groups-image" src="' . $picture['file'] . '"/>&nbsp' . $member_name
'<img height="44" border="2" align="middle" vspace="10" class="social-groups-image" src="' . $userPicture . '"/>&nbsp' . $member_name
);
$member_content .= '</div>';

@ -87,23 +87,28 @@ if (is_array($_GET) && count($_GET)>0) {
}
}
}
//Block Avatar Social
$userInfo = UserManager::get_user_info_by_id($user_id);
//Block Menu Social
// Block Menu Social
$social_menu_block = SocialManager::show_social_menu('invitations');
//Block Invitations
// Block Invitations
$socialInvitationsBlock = '<div id="id_response" align="center"></div>';
$user_id = api_get_user_id();
$list_get_invitation = SocialManager::get_list_invitation_of_friends_by_user_id($user_id);
$list_get_invitation_sent = SocialManager::get_list_invitation_sent_by_user_id($user_id);
$pending_invitations = GroupPortalManager::get_groups_by_user($user_id, GROUP_USER_PERMISSION_PENDING_INVITATION);
$number_loop = count($list_get_invitation);
$list_get_invitation = SocialManager::get_list_invitation_of_friends_by_user_id($user_id);
$list_get_invitation_sent = SocialManager::get_list_invitation_sent_by_user_id($user_id);
$pending_invitations = GroupPortalManager::get_groups_by_user($user_id, GROUP_USER_PERMISSION_PENDING_INVITATION);
$number_loop = count($list_get_invitation);
$total_invitations = $number_loop + count($list_get_invitation_sent) + count($pending_invitations);
if ($total_invitations == 0 && count($_GET) <= 0) {
$socialInvitationsBlock .= '<div class="row"><div class="col-md-12"><a class="btn btn-default" href="search.php">'.get_lang('TryAndFindSomeFriends').'</a></div></div>';
$socialInvitationsBlock .= '<div class="row">
<div class="col-md-12">
<a class="btn btn-default" href="search.php">'.
get_lang('TryAndFindSomeFriends').'
</a>
</div>
</div>';
}
if ($number_loop != 0) {
@ -113,21 +118,21 @@ if ($number_loop != 0) {
foreach ($list_get_invitation as $invitation) {
$sender_user_id = $invitation['user_sender_id'];
$user_info = api_get_user_info($sender_user_id);
$userPicture = $user_info['avatar'];
$socialInvitationsBlock .= '<div id="id_'.$sender_user_id.'" class="well">';
$picture = UserManager::get_user_picture_path_by_id($sender_user_id, 'web', false, true);
$friends_profile = SocialManager::get_picture_user($sender_user_id, $picture['file'], 92);
$user_info = api_get_user_info($sender_user_id);
$title = Security::remove_XSS($invitation['title'], STUDENT, true);
$content = Security::remove_XSS($invitation['content'], STUDENT, true);
$date = api_convert_and_format_date($invitation['send_date'], DATE_TIME_FORMAT_LONG);
$title = Security::remove_XSS($invitation['title'], STUDENT, true);
$content = Security::remove_XSS($invitation['content'], STUDENT, true);
$date = api_convert_and_format_date($invitation['send_date'], DATE_TIME_FORMAT_LONG);
$socialInvitationsBlock .= '<div class="row">';
$socialInvitationsBlock .= '<div class="col-md-2">';
$socialInvitationsBlock .= '<a href="profile.php?u='.$sender_user_id.'"><img src="'.$friends_profile['file'].'"/></a>';
$socialInvitationsBlock .= '<a href="profile.php?u='.$sender_user_id.'"><img src="'.$userPicture.'"/></a>';
$socialInvitationsBlock .= '</div>';
$socialInvitationsBlock .= '<div class="col-md-10">';
$socialInvitationsBlock .= '<h4 class="title-profile"><a href="profile.php?u='.$sender_user_id.'">
'.api_get_person_name($user_info['firstName'], $user_info['lastName']).'</a>:
'.$user_info['complete_name'].'</a>:
</h4>';
$socialInvitationsBlock .= '<div class="content-invitation">'.$content.'</div>';
$socialInvitationsBlock .= '<div class="date-invitation">'.get_lang('DateSend').' : '.$date.'</div>';
@ -150,23 +155,20 @@ if (count($list_get_invitation_sent) > 0) {
$socialInvitationsBlock .= '<div class="panel-body">';
foreach ($list_get_invitation_sent as $invitation) {
$sender_user_id = $invitation['user_receiver_id'];
$user_info = api_get_user_info($sender_user_id);
$socialInvitationsBlock .= '<div id="id_'.$sender_user_id.'" class="well">';
$picture = UserManager::get_user_picture_path_by_id($sender_user_id, 'web', false, true);
$friends_profile = SocialManager::get_picture_user($sender_user_id, $picture['file'], 92);
$user_info = api_get_user_info($sender_user_id);
$title = Security::remove_XSS($invitation['title'], STUDENT, true);
$content = Security::remove_XSS($invitation['content'], STUDENT, true);
$date = api_convert_and_format_date($invitation['send_date'], DATE_TIME_FORMAT_LONG);
$title = Security::remove_XSS($invitation['title'], STUDENT, true);
$content = Security::remove_XSS($invitation['content'], STUDENT, true);
$date = api_convert_and_format_date($invitation['send_date'], DATE_TIME_FORMAT_LONG);
$socialInvitationsBlock .= '<div class="row">';
$socialInvitationsBlock .= '<div class="col-md-2">';
$socialInvitationsBlock .= '<a href="profile.php?u='.$sender_user_id.'"><img src="'.$friends_profile['file'].'" /></a>';
$socialInvitationsBlock .= '<a href="profile.php?u='.$sender_user_id.'"><img src="'.$user_info['avatar'].'" /></a>';
$socialInvitationsBlock .= '</div>';
$socialInvitationsBlock .= '<div class="col-md-10">';
$socialInvitationsBlock .= '<h4 class="title-profile"><a class="profile_link" href="profile.php?u='.$sender_user_id.'">'.api_get_person_name($user_info['firstName'], $user_info['lastName']).'</a></h4>';
$socialInvitationsBlock .= '<h4 class="title-profile"><a class="profile_link" href="profile.php?u='.$sender_user_id.'">'.$user_info['complete_name'].'</a></h4>';
$socialInvitationsBlock .= '<div class="content-invitation">'.$title.' : '.$content.'</div>';
$socialInvitationsBlock .= '<div class="date-invitation">'. get_lang('DateSend').' : '.$date.'</div>';
$socialInvitationsBlock .= '</div>';

@ -15,20 +15,6 @@ if (api_get_setting('allow_social_tool') != 'true') {
$tok = Security::get_token();
if (isset($_REQUEST['user_friend'])) {
$userfriend_id = intval($_REQUEST['user_friend']);
// panel=1 send message
// panel=2 send invitation
$panel = Security::remove_XSS($_REQUEST['view_panel']);
$info_user_friend = api_get_user_info($userfriend_id);
$info_path_friend = UserManager::get_user_picture_path_by_id(
$userfriend_id,
'web',
false,
true
);
}
$group_id = intval($_GET['group_id']);
$message_id = isset($_GET['message_id']) ? intval($_GET['message_id']) : null;

@ -627,7 +627,7 @@ if ($show_full_profile) {
$count_pending_invitations = 0;
if (!isset($_GET['u']) || (isset($_GET['u']) && $_GET['u']==api_get_user_id())) {
$pending_invitations = SocialManager::get_list_invitation_of_friends_by_user_id(api_get_user_id());
$list_get_path_web = SocialManager::get_list_web_path_user_invitation_by_user_id(api_get_user_id());
$list_get_path_web = SocialManager::get_list_web_path_user_invitation_by_user_id(api_get_user_id());
$count_pending_invitations = count($pending_invitations);
}

@ -55,17 +55,11 @@ if (isset($_GET['view']) && in_array($_GET['view'], $views)) {
$friend['lastName']
);
$friend_html .= '<div id=div_' . $friend['friend_user_id'] . ' class="image_friend_network" ><span><center>';
// the height = 92 must be the sqme in the image_friend_network span style in default.css
$friends_profile = SocialManager::get_picture_user(
$friend['friend_user_id'],
$friend['image'],
92,
USER_IMAGE_SIZE_MEDIUM,
'width="85" height="90" '
);
$userPicture = UserManager::getUserPicture($friend['friend_user_id']);
$friend_html .= '<a href="profile.php?u=' . $friend['friend_user_id'] . '&amp;' . $link_shared . '">';
$friend_html .= '<img src="' . $friends_profile['file'] . '" ' . $friends_profile['style'] . ' id="imgfriend_' . $friend['friend_user_id'] . '" title="' . $name_user . '" />';
$friend_html .= '<img src="' . $userPicture . '" id="imgfriend_' . $friend['friend_user_id'] . '" title="' . $name_user . '" />';
$friend_html .= '</center></span>';
$friend_html .= '<center class="friend">' . $name_user . '</a></center>';
$friend_html .= '</div>';

@ -74,10 +74,9 @@ if ($query != '' || ($query_vars['search_type']=='1' && count($query_vars)>2) )
$results .= '<div class="row">';
$buttonClass = 'btn btn-default btn-sm';
foreach ($users as $user) {
$send_inv = '<button class="'.$buttonClass.' disabled "><i class="fa fa-user"></i> '.get_lang('SendInvitation').'</button>';
$send_inv = '<button class="'.$buttonClass.' disabled "><i class="fa fa-user"></i> '.get_lang('SendInvitation').'</button>';
$relation_type = intval(SocialManager::get_relation_between_contacts(api_get_user_id(), $user['user_id']));
$user_info = api_get_user_info($user['user_id'], true);
$user_info = api_get_user_info($user['user_id'], true);
$url = api_get_path(WEB_PATH).'main/social/profile.php?u='.$user['user_id'];
// Show send invitation icon if they are not friends yet
@ -87,18 +86,8 @@ if ($query != '' || ($query_vars['search_type']=='1' && count($query_vars)>2) )
}
$send_msg = '<a href="#" class="btn-to-send-message '.$buttonClass.'" data-send-to="' . $user['user_id'] . '">
<i class="fa fa-envelope"></i> '.get_lang('SendMessage').'</a>';
if (empty($user['picture_uri'])) {
$picture['file'] = api_get_path(WEB_CODE_PATH).'img/unknown.jpg';
$img = '<img src="'.$picture['file'].'">';
} else {
$picture = UserManager::get_picture_user(
$user['user_id'],
$user['picture_uri'],
50,
USER_IMAGE_SIZE_ORIGINAL
);
$img = '<img src="'.$picture['file'].'" width="100" height="100">';
}
$img = '<img src="'.$user_info['avatar'].'" width="100" height="100">';
if ($user_info['user_is_online']) {
$status_icon = Display::span('', array('class' => 'online_user_in_text'));
@ -152,20 +141,20 @@ if ($query != '' || ($query_vars['search_type']=='1' && count($query_vars)>2) )
$social_right_content .= '<ul class="thumbnails">';
foreach ($groups as $group) {
$group['name'] = Security::remove_XSS($group['name'], STUDENT, true);
$group['description'] = Security::remove_XSS($group['description'], STUDENT, true);
$id = $group['id'];
$url_open = '<a href="groups.php?id='.$id.'">';
$url_close = '</a>';
$name = cut($group['name'], 60, true);
$count_users_group = count(GroupPortalManager::get_all_users_by_group($id));
$group['name'] = Security::remove_XSS($group['name'], STUDENT, true);
$group['description'] = Security::remove_XSS($group['description'], STUDENT, true);
$id = $group['id'];
$url_open = '<a href="groups.php?id='.$id.'">';
$url_close = '</a>';
$name = cut($group['name'], 60, true);
$count_users_group = count(GroupPortalManager::get_all_users_by_group($id));
if ($count_users_group == 1) {
$count_users_group = $count_users_group.' '.get_lang('Member');
} else {
$count_users_group = $count_users_group.' '.get_lang('Members');
}
$picture = GroupPortalManager::get_picture_group($group['id'], $group['picture_uri'], 80);
$tags = GroupPortalManager::get_group_tags($group['id']);
$picture = GroupPortalManager::get_picture_group($group['id'], $group['picture_uri'], 80);
$tags = GroupPortalManager::get_group_tags($group['id']);
$group['picture_uri'] = '<img src="'.$picture['file'].'" width="50" />';

@ -86,16 +86,18 @@
/* Makes row highlighting possible */
$(document).ready( function() {
// Date time settings.
moment.locale('{{ locale }}');
$.datepicker.setDefaults($.datepicker.regional["{{ locale }}"]);
$.datepicker.regional["local"] = $.datepicker.regional["{{ locale }}"];
// Bootstrap tabs.
$('.tab-wrapper a').click(function (e) {
e.preventDefault()
e.preventDefault();
$(this).tab('show');
//$('#tabs a:first').tab('show') // Select first tab
})
});
/**
* Advanced options

@ -342,7 +342,6 @@ $(function() {
var text = $(this).val();
var name = $(this).attr('name');
$(this).after(this.outerHTML).remove();
//var has_string = $(name).find(":contains('[')");
$('input[name=' + name + ']').val(text);
});
});

@ -692,30 +692,11 @@ function get_user_data($from, $number_of_items, $column, $direction)
$groupsNameList = GroupManager::getAllGroupPerUserSubscription($user_id);
$temp = array();
if (api_is_allowed_to_edit(null, true)) {
$temp[] = $user_id;
$image_path = UserManager::get_user_picture_path_by_id(
$user_id,
'web',
false,
true
);
$user_profile = UserManager::get_picture_user(
$user_id,
$image_path['file'],
22,
USER_IMAGE_SIZE_SMALL,
' width="22" height="22" '
);
$userInfo = api_get_user_info($user_id);
if (!api_is_anonymous()) {
$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']).'" />';
}
$photo = '<img src="'.$userInfo['avatar_small'].'" alt="'.$userInfo['complete_name'].'" title="'.$userInfo['complete_name'].'" />';
$temp[] = $user_id;
$temp[] = $photo;
$temp[] = $o_course_user['official_code'];
@ -763,15 +744,11 @@ function get_user_data($from, $number_of_items, $column, $direction)
$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'] : '';
} 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 = 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']).'" />';
}
$userPicture = $userInfo['avatar'];
$photo= '<img src="'.$userPicture.'" alt="'.$userInfo['complete_name'].'" width="22" height="22" title="'.$userInfo['complete_name'].'" />';
$temp[] = $user_id;
$temp[] = $photo;
$temp[] = $o_course_user['official_code'];

@ -17,7 +17,7 @@ class WSCMUser extends WSCM {
{
$listResult = "#";
$listArrayResult = Array();
$listArray = Array();
@ -52,24 +52,23 @@ class WSCMUser extends WSCM {
public function get_link_user_picture($username, $password, $id)
{
if($this->verifyUserPass($username, $password) == "valid")
{
$userPic = UserManager::get_user_picture_path_by_id($id, "web");
if(empty ($userPic['file']))
if ($this->verifyUserPass($username, $password) == "valid") {
$userPic = UserManager::getUserPicture($id);
if (empty ($userPic)) {
return "0";
return $userPic['dir'].$userPic['file'];
}
return $userPic;
}
return "0";
}
public function get_user_name($username, $password, $id, $field)
{
if($this->verifyUserPass($username, $password) == "valid")
{
if($this->verifyUserPass($username, $password) == "valid") {
$userInfo = UserManager::get_user_info_by_id($id);
switch ($field)
{
switch ($field) {
case 'firstname':
return $userInfo['firstname'];
break;
@ -85,49 +84,52 @@ class WSCMUser extends WSCM {
default :
return $userInfo['firstname'];
}
return "0";
}
return "0";
}
public function send_invitation($username, $password, $userfriend_id, $content_message = '')
{
global $charset;
if($this->verifyUserPass($username, $password) == "valid")
{
$user_id = UserManager::get_user_id_from_username($username);
$message_title = get_lang('Invitation');
$count_is_true = SocialManager::send_invitation_friend($user_id,$userfriend_id, $message_title, $content_message);
if ($count_is_true) {
return Display::display_normal_message(api_htmlentities(get_lang('InvitationHasBeenSent'), ENT_QUOTES,$charset),false);
}else {
return Display::display_error_message(api_htmlentities(get_lang('YouAlreadySentAnInvitation'), ENT_QUOTES,$charset),false);
}
if ($this->verifyUserPass($username, $password) == "valid") {
$user_id = UserManager::get_user_id_from_username($username);
$message_title = get_lang('Invitation');
$count_is_true = SocialManager::send_invitation_friend($user_id,$userfriend_id, $message_title, $content_message);
if ($count_is_true) {
return Display::display_normal_message(api_htmlentities(get_lang('InvitationHasBeenSent'), ENT_QUOTES,$charset),false);
} else {
return Display::display_error_message(api_htmlentities(get_lang('YouAlreadySentAnInvitation'), ENT_QUOTES,$charset),false);
}
}
return get_lang('InvalidId');
}
public function accept_friend($username, $password, $userfriend_id)
{
if($this->verifyUserPass($username, $password) == "valid")
{
if ($this->verifyUserPass($username, $password) == "valid") {
$user_id = UserManager::get_user_id_from_username($username);
UserManager::relate_users($userfriend_id, $user_id, USER_RELATION_TYPE_FRIEND);
SocialManager::invitation_accepted($userfriend_id, $user_id);
return get_lang('AddedContactToList');
}
return get_lang('InvalidId');
}
public function denied_invitation($username, $password, $userfriend_id)
{
if($this->verifyUserPass($username, $password) == "valid")
{
if ($this->verifyUserPass($username, $password) == "valid") {
$user_id = UserManager::get_user_id_from_username($username);
SocialManager::invitation_denied($userfriend_id, $user_id);
return get_lang('InvitationDenied');
}
return get_lang('InvalidId');
}
@ -141,7 +143,8 @@ class WSCMUser extends WSCM {
*@todo Use the UserManager class
* @todo security filter order by
*/
private static function get_user_list_like_start($conditions = array(), $order_by = array()) {
private static function get_user_list_like_start($conditions = array(), $order_by = array())
{
$user_table = Database :: get_main_table(TABLE_MAIN_USER);
$return_array = array();
$sql_query = "SELECT * FROM $user_table";
@ -161,7 +164,7 @@ class WSCMUser extends WSCM {
if (count($order_by) > 0) {
$sql_query .= ' ORDER BY '.$order;
}
$sql_result = Database::query($sql_query);
while ($result = Database::fetch_array($sql_result)) {
$return_array[] = $result;
@ -169,7 +172,7 @@ class WSCMUser extends WSCM {
return $return_array;
}
}
/*
@ -180,5 +183,3 @@ $aqui = new WSCMUser();
//print_r($aqui->send_invitation("marco", "c4ca4238a0b923820dcc509a6f75849b", "1", "oia ai"));
print_r($aqui->denied_invitation("admin", "c4ca4238a0b923820dcc509a6f75849b", "3"));
*/
?>

@ -5856,11 +5856,22 @@ function WSCertificatesList($startingDate = '', $endingDate = '')
$certificateTable = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CERTIFICATE);
$userTable = Database::get_main_table(TABLE_MAIN_USER);
$categoryTable = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY);
$query = "SELECT certificate.id, user.username, category.course_code, category.session_id,
certificate.user_id, certificate.cat_id, certificate.created_at, certificate.path_certificate
FROM $certificateTable AS certificate
JOIN $userTable AS user ON certificate.user_id = user.user_id
JOIN $categoryTable AS category ON certificate.cat_id = category.id";
$query = "SELECT
certificate.id,
user.username,
category.course_code,
category.session_id,
certificate.user_id,
certificate.cat_id,
certificate.created_at,
certificate.path_certificate
FROM $certificateTable AS certificate
JOIN $userTable AS user
ON certificate.user_id = user.user_id
JOIN $categoryTable AS category
ON certificate.cat_id = category.id";
if (!empty($startingDate) && !empty($endingDate)) {
$query .= " WHERE certificate.created_at BETWEEN '$startingDate' AND '$endingDate'";
} else if (!empty($startingDate)) {
@ -5868,16 +5879,14 @@ function WSCertificatesList($startingDate = '', $endingDate = '')
} else if (!empty($endingDate)) {
$query .= " WHERE certificate.created_at <= '$endingDate'";
}
$queryResult = Database::query($query);
$basePath = api_get_path(WEB_CODE_PATH).'upload/users/';
while ($row = Database::fetch_array($queryResult)) {
$certificatePath = $basePath;
if (api_get_setting('split_users_upload_directory') === 'true') {
$certificatePath .= substr((string) $row['user_id'], 0, 1).'/';
}
$row['path_certificate'] = $certificatePath.$row['user_id'].'/certificate'.$row['path_certificate'];
$userPath = USermanager::getUserPathById($row['user_id'], 'web');
$row['path_certificate'] = $userPath.'/certificate'.$row['path_certificate'];
$result[] = $row;
}
return $result;
}

@ -1873,8 +1873,6 @@ class Wiki
public function auto_add_page_users($values)
{
$assignment_type = $values['assignment'];
//$assig_user_id is need to identify end reflinks
$session_id = $this->session_id;
$groupId = api_get_group_id();
@ -1900,53 +1898,47 @@ class Wiki
$all_students_pages = array();
//data about teacher
// Data about teacher
$userId = api_get_user_id();
$userinfo = api_get_user_info($userId);
$username = api_htmlentities(sprintf(get_lang('LoginX'), $userinfo['username'], ENT_QUOTES));
$name = $userinfo['complete_name']." - ".$username;
$photo= '<img src="'.api_get_path(WEB_CODE_PATH)."img/unknown.jpg".'" alt="'.$name.'" width="40" height="50" align="top" title="'.$name.'" />';
if ($userId) {
$image_path = UserManager::get_user_picture_path_by_id($userId, 'web', false, true);
$image_repository = $image_path['dir'];
$existing_image = $image_path['file'];
$photo = '<img src="' . $image_repository . $existing_image . '" alt="' . $name . '" width="40" height="50" align="top" title="' . $name . '" />';
}
$photo = '<img src="' . $userinfo['avatar'] . '" alt="' . $name . '" width="40" height="50" align="top" title="' . $name . '" />';
//teacher assignment title
// teacher assignment title
$title_orig = $values['title'];
//teacher assignment reflink
// teacher assignment reflink
$link2teacher = $values['title'] = $title_orig."_uass".$userId;
//first: teacher name, photo, and assignment description (original content)
$content_orig_A='<div align="center" style="background-color: #F5F8FB; border:solid; border-color: #E6E6E6">
// first: teacher name, photo, and assignment description (original content)
$content_orig_A = '<div align="center" style="background-color: #F5F8FB; border:solid; border-color: #E6E6E6">
<table border="0">
<tr><td style="font-size:24px">'.get_lang('AssignmentDesc').'</td></tr>
<tr><td>'.$photo.'<br />'.Display::tag('span', api_get_person_name($userinfo['firstname'], $userinfo['lastname']), array('title'=>$username)).'</td></tr>
</table></div>';
$content_orig_B='<br/><div align="center" style="font-size:24px">'.get_lang('AssignmentDescription').': '.$title_orig.'</div><br/>'.$_POST['content'];
$content_orig_B = '<br/><div align="center" style="font-size:24px">'.get_lang('AssignmentDescription').': '.$title_orig.'</div><br/>'.$_POST['content'];
//Second: student list (names, photo and links to their works).
//Third: Create Students work pages.
foreach ($a_users_to_add as $o_user_to_add) {
if ($o_user_to_add['user_id'] != $userId) {
//except that puts the task
$assig_user_id = $o_user_to_add['user_id']; //identifies each page as created by the student, not by teacher
$image_path = UserManager::get_user_picture_path_by_id($assig_user_id,'web',false, true);
$image_repository = $image_path['dir'];
$existing_image = $image_path['file'];
// except that puts the task
$assig_user_id = $o_user_to_add['user_id'];
// identifies each page as created by the student, not by teacher
$userPicture = UserManager::getUserPicture($assig_user_id);
$username = api_htmlentities(sprintf(get_lang('LoginX'), $o_user_to_add['username'], ENT_QUOTES));
$name = api_get_person_name($o_user_to_add['firstname'], $o_user_to_add['lastname'])." . ".$username;
$photo= '<img src="'.$image_repository.$existing_image.'" alt="'.$name.'" width="40" height="50" align="bottom" title="'.$name.'" />';
$photo= '<img src="'.$userPicture.'" alt="'.$name.'" width="40" height="50" align="bottom" title="'.$name.'" />';
$is_tutor_of_group = GroupManager::is_tutor_of_group($assig_user_id,$groupId); //student is tutor
$is_tutor_and_member = (GroupManager::is_tutor_of_group($assig_user_id,$groupId) && GroupManager::is_subscribed($assig_user_id, $groupId));
//student is tutor and member
$is_tutor_of_group = GroupManager::is_tutor_of_group($assig_user_id, $groupId); //student is tutor
$is_tutor_and_member = GroupManager::is_tutor_of_group($assig_user_id, $groupId) && GroupManager::is_subscribed($assig_user_id, $groupId);
// student is tutor and member
if($is_tutor_and_member) {
if ($is_tutor_and_member) {
$status_in_group=get_lang('GroupTutorAndMember');
} else {
if($is_tutor_of_group) {
@ -1958,7 +1950,6 @@ class Wiki
if ($assignment_type==1) {
$values['title']= $title_orig;
//$values['comment'] = get_lang('AssignmentFirstComToStudent');
$values['content'] = '<div align="center" style="background-color: #F5F8FB; border:solid; border-color: #E6E6E6">
<table border="0">
<tr><td style="font-size:24px">'.get_lang('AssignmentWork').'</td></tr>
@ -3236,9 +3227,9 @@ class Wiki
if (isset($_POST['Submit']) && self::double_post($_POST['wpost_id'])) {
$dtime = date( "Y-m-d H:i:s" );
$message_author = api_get_user_id();
$sql="INSERT INTO $tbl_wiki_discuss (c_id, publication_id, userc_id, comment, p_score, dtime) VALUES
($course_id, '".$id."','".$message_author."','".Database::escape_string($_POST['comment'])."','".Database::escape_string($_POST['rating'])."','".$dtime."')";
$result = Database::query($sql);
$sql = "INSERT INTO $tbl_wiki_discuss (c_id, publication_id, userc_id, comment, p_score, dtime)
VALUES ($course_id, '".$id."','".$message_author."','".Database::escape_string($_POST['comment'])."','".Database::escape_string($_POST['rating'])."','".$dtime."')";
Database::query($sql);
self::check_emailcue($id, 'D', $dtime, $message_author);
}
}//end discuss lock
@ -3280,13 +3271,16 @@ class Wiki
echo ' - '.get_lang('RatingMedia').': '.$avg_WPost_score; // average rating
$sql = 'UPDATE '.$tbl_wiki.' SET score="'.Database::escape_string($avg_WPost_score).'"
WHERE c_id = '.$course_id.' AND reflink="'.Database::escape_string($page).'" AND '.$groupfilter.$condition_session;
$sql = 'UPDATE '.$tbl_wiki.' SET
score="'.Database::escape_string($avg_WPost_score).'"
WHERE
c_id = '.$course_id.' AND
reflink="'.Database::escape_string($page).'" AND
'.$groupfilter.$condition_session;
// check if work ok. TODO:
Database::query($sql);
echo '<hr noshade size="1">';
//echo '<div style="overflow:auto; height:170px;">';
while ($row=Database::fetch_array($result)) {
$userinfo = api_get_user_info($row['userc_id']);
@ -3296,17 +3290,9 @@ class Wiki
$author_status=get_lang('Teacher');
}
$user_id = $row['userc_id'];
$name = $userinfo['complete_name'];
$author_photo= '<img src="'.api_get_path(WEB_CODE_PATH)."img/unknown.jpg".'" alt="'.api_htmlentities($name).'" width="40" height="50" align="top" title="'.api_htmlentities($name).'" />';
if ($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'];
$author_photo= '<img src="'.$image_repository.$existing_image.'" alt="'.api_htmlentities($name).'" width="40" height="50" align="top" title="'.api_htmlentities($name).'" />';
}
$author_photo= '<img src="'.$userinfo['avatar'].'" alt="'.api_htmlentities($name).'" width="40" height="50" align="top" title="'.api_htmlentities($name).'" />';
//stars
$p_score=$row['p_score'];

@ -3188,13 +3188,7 @@ function getWorkComments($work)
$comments = Database::store_result($result, 'ASSOC');
if (!empty($comments)) {
foreach ($comments as &$comment) {
$pictureInfo = UserManager::get_picture_user(
$comment['user_id'],
$comment['picture_uri'],
24,
USER_IMAGE_SIZE_SMALL
);
$comment['picture'] = $pictureInfo['file'];
$comment['picture'] = UserManager::getUserPicture($comment['user_id']);
$commentInfo = getWorkComment($comment['id']);
if (!empty($commentInfo)) {

@ -106,18 +106,8 @@ if ($verified) {
}
// Get student data
$studentArray = api_get_user_info($data['studentUserId']);
$studentArray['picture'] = UserManager::get_user_picture_path_by_id(
$studentArray['user_id'],
'web',
false,
true
);
$studentArray['picture'] = UserManager::get_picture_user(
$studentArray['user_id'],
$studentArray['picture']['file'],
22,
USER_IMAGE_SIZE_MEDIUM
);
$studentArray['picture'] = $studentArray['avatar'];
// Get superior data if exist
$superiorId = UserManager::getStudentBoss($data['studentUserId']);
if (!empty($superiorId)) {
@ -272,18 +262,7 @@ if ($verified) {
}
// Prepare student data
$studentArray = api_get_user_info($data['studentUserId']);
$studentArray['picture'] = UserManager::get_user_picture_path_by_id(
$studentArray['user_id'],
'web',
false,
true
);
$studentArray['picture'] = UserManager::get_picture_user(
$studentArray['user_id'],
$studentArray['picture']['file'],
22,
USER_IMAGE_SIZE_MEDIUM
);
$studentArray['picture'] = $studentArray['avatar'];
// Prepare superior data
$superiorId = UserManager::getStudentBoss($data['studentUserId']);
if (!empty($superiorId)) {

@ -56,8 +56,8 @@ foreach ($sessionFieldValueList as $sessionFieldValue) {
}
// Get student data
$studentArray = api_get_user_info($data['studentUserId']);
$studentArray['picture'] = UserManager::get_user_picture_path_by_id($studentArray['user_id'], 'web', false, true);
$studentArray['picture'] = UserManager::get_picture_user($studentArray['user_id'], $studentArray['picture']['file'], 22, USER_IMAGE_SIZE_MEDIUM);
$studentArray['picture'] = $studentArray['avatar'];
// Get superior data if exist
$superiorId = UserManager::getStudentBoss($data['studentUserId']);
if (!empty($superiorId)) {

@ -547,25 +547,29 @@ function get_user_data($from, $number_of_items, $column, $direction)
$number_of_items = intval($number_of_items);
$sql .= " ORDER BY col$column $direction ";
$sql .= " LIMIT $from,$number_of_items";
$sql .= " LIMIT $from, $number_of_items";
$res = Database::query($sql);
$users = array();
while ($user = Database::fetch_row($res)) {
$user_id = $user[0];
$image_path = UserManager::get_user_picture_path_by_id($user_id, 'web', false, true);
$user_profile = UserManager::get_picture_user($user_id, $image_path['file'], 22, USER_IMAGE_SIZE_SMALL, ' width="22" height="22" ');
if (!api_is_anonymous()) {
$photo = '<center><a href="' . api_get_path(WEB_PATH) . 'whoisonline.php?origin=user_list&id=' . $user_id . '" title="' . get_lang('Info') . '"><img src="' . $user_profile['file'] . '" ' . $user_profile['style'] . ' alt="' . api_get_person_name($user[2], $user[3]) . '" title="' . api_get_person_name($user[2], $user[3]) . '" /></a></center>';
} else {
$photo = '<center><img src="' . $user_profile['file'] . '" ' . $user_profile['style'] . ' alt="' . api_get_person_name($user[2], $user[3]) . '" title="' . api_get_person_name($user[2], $user[3]) . '" /></center>';
}
$userPicture = UserManager::getUserPicture($user_id);
$photo = '<img src="' . $userPicture. '" alt="' . api_get_person_name($user[2], $user[3]) . '" title="' . api_get_person_name($user[2], $user[3]) . '" />';
$button = '<a href="javascript:void(0)" onclick="load_course_list(\'div_' . $user_id . '\',' . $user_id . ', \'' . $user[5] . '\')">'
. Display::return_icon('view_more_stats.gif', get_lang('Info')) .
'</a>&nbsp;&nbsp;';
$users[] = array($photo, $user_id, $user[2], $user[3], $user[4], $user[5], $button);
$users[] = array(
$photo,
$user_id,
$user[2],
$user[3],
$user[4],
$user[5],
$button,
);
}
return $users;
}

@ -215,28 +215,30 @@ function get_user_data($from, $number_of_items, $column, $direction)
$number_of_items = intval($number_of_items);
$sql .= " ORDER BY col$column $direction ";
$sql .= " LIMIT $from,$number_of_items";
$sql .= " LIMIT $from, $number_of_items";
$res = Database::query($sql);
$users = array();
$webPath = api_get_path(WEB_PATH);
$selfPath = api_get_self();
while ($user = Database::fetch_row($res)) {
$image_path = UserManager::get_user_picture_path_by_id($user[0], 'web', false, true);
$user_profile = UserManager::get_picture_user($user[0], $image_path['file'], 22, USER_IMAGE_SIZE_SMALL, ' width="22" height="22" ');
if (!api_is_anonymous()) {
$photo = '<center><a href="' . $webPath . 'whoisonline.php?origin=user_list&id=' . $user[0] . '" title="' . get_lang('Info') . '"><img src="' . $user_profile['file'] . '" ' . $user_profile['style'] . ' alt="' . api_get_person_name($user[2], $user[3]) . '" title="' . api_get_person_name($user[2], $user[3]) . '" /></a></center>';
} else {
$photo = '<center><img src="' . $user_profile['file'] . '" ' . $user_profile['style'] . ' alt="' . api_get_person_name($user[2], $user[3]) . '" title="' . api_get_person_name($user[2], $user[3]) . '" /></center>';
}
$userPicture = UserManager::getUserPicture($user[0]);
$photo = '<img src="' . $userPicture . '" alt="' . api_get_person_name($user[2], $user[3]) . '" title="' . api_get_person_name($user[2], $user[3]) . '" />';
$user_id = $user[0];
$button = '<a href="' . $selfPath . '?user_request=' . $user[0] . '">' . Display::return_icon('view_more_stats.gif', get_lang('Info')) . '</a>';
$button = '<a href="javascript:void(0)" onclick="load_course_list(\'div_' . $user_id . '\',' . $user_id . ')">
<img onclick="load_course_list(\'div_' . $user_id . '\',' . $user_id . ')" src="' . $webPath . 'img/view_more_stats.gif" title="' . get_lang('Courses') . '" alt="' . get_lang('Courses') . '"/>
</a>&nbsp;&nbsp;';
$users[] = array($photo, $user[1], $user[2], $user[3], $user[4], $user[5], $button);
$users[] = array(
$photo,
$user[1],
$user[2],
$user[3],
$user[4],
$user[5],
$button,
);
}
return $users;
}

@ -441,6 +441,10 @@ class Version110 extends AbstractMigrationChamilo
$this->addSql("INSERT INTO settings_options (variable, value, display_text) VALUES ('enabled_mathjax', 'true', 'Yes')");
$this->addSql("INSERT INTO settings_options (variable, value, display_text) VALUES ('enabled_mathjax', 'false', 'No')");
$this->addSql("INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('enabled_mathjax', NULL, 'radio', 'Editor', 'false', 'EnableMathJaxTitle', 'EnableMathJaxComment', NULL, NULL, 0)");
$this->addSql("INSERT INTO settings_options (variable, value, display_text) VALUES ('enabled_mathjax', 'true', 'Yes')");
$this->addSql("INSERT INTO settings_options (variable, value, display_text) VALUES ('enabled_mathjax', 'false', 'No')");
$this->addSql("INSERT INTO language (original_name, english_name, isocode, dokeos_folder, available) VALUES ('Føroyskt', 'faroese', 'fo', 'faroese', 0), ('Tagalog', 'tagalog', 'tl', 'tagalog',1), ('Tibetan', 'tibetan', 'bo', 'tibetan', 0), ('isiXhosa', 'xhosa', 'xh', 'xhosa', 0)");
$this->addSql("DELETE FROM settings_options WHERE variable = 'show_glossary_in_extra_tools'");

@ -57,17 +57,6 @@ class TestSocial extends UnitTestCase{
}
public function testGetListPathWebByUserId(){
$user_id=1;
$id_group=null;
$search_name=null;
$res = SocialManager::get_list_path_web_by_user_id($user_id,$id_group,$search_name);
if(!($res===true)):
$this->assertTrue(is_array($res));
endif;
//var_dump($res);
}
public function testGetListWebPathUserInvitationByUserId(){
$user_id=1;
$res = SocialManager::get_list_web_path_user_invitation_by_user_id($user_id);

@ -201,7 +201,7 @@ class TestUserManager extends UnitTestCase {
}
function testGetPictureUser() {
$res=UserManager::get_picture_user(1, 'unknown.jpg', 200, null, null);
$res=UserManager::getUserPicture(1, 'unknown.jpg');
$this->assertFalse(!(bool)$res);
}
@ -236,7 +236,7 @@ class TestUserManager extends UnitTestCase {
function testGetUserPicturePathById() {
$id=5;
$res=UserManager::get_user_picture_path_by_id($id,null,null,null);
$res=UserManager::get_user_picture_path_by_id($id,null,null);
$this->assertTrue(is_array($res));
}

Loading…
Cancel
Save