From 03d263a9a6fc0949ff44c4a7267a6ef6a37cf94c Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Fri, 24 Apr 2015 16:00:54 +0200 Subject: [PATCH] Improve code to load user picture. Remove calls from gravatar and centralize in UserManager --- main/admin/group_edit.php | 2 +- main/admin/user_edit.php | 47 +-- main/admin/user_information.php | 40 +- main/admin/user_list.php | 11 +- main/auth/profile.php | 53 +-- main/chat/chat_functions.lib.php | 21 +- main/chat/chat_whoisonline.php | 13 +- main/cron/import_csv.php | 2 +- main/cron/user_import/client.php | 8 +- main/document/document.php | 8 +- main/forum/forumfunction.inc.php | 4 +- main/forum/viewthread_flat.inc.php | 46 ++- main/gradebook/lib/fe/displaygradebook.php | 21 +- main/gradebook/user_info.php | 66 --- main/gradebook/user_stats.php | 8 +- main/group/group_space.php | 20 +- main/inc/ajax/social.ajax.php | 4 +- main/inc/lib/api.lib.php | 50 +-- main/inc/lib/attendance.lib.php | 13 +- main/inc/lib/diagnoser.lib.php | 24 +- main/inc/lib/document.lib.php | 10 +- main/inc/lib/events.lib.php | 1 - main/inc/lib/extra_field_value.lib.php | 26 +- main/inc/lib/group_portal_manager.lib.php | 63 +-- main/inc/lib/message.lib.php | 52 ++- main/inc/lib/social.lib.php | 171 +++----- main/inc/lib/usermanager.lib.php | 381 +++++++++--------- main/inc/lib/userportal.lib.php | 25 +- main/install/install.lib.php | 2 +- main/messages/new_message.php | 1 + main/mySpace/myStudents.php | 26 +- main/mySpace/user_add.php | 29 +- main/social/friends.php | 4 +- main/social/group_invitation.php | 14 +- main/social/group_members.php | 35 +- main/social/groups.php | 16 +- main/social/invitations.php | 54 +-- main/social/message_for_group_form.inc.php | 14 - main/social/profile.php | 2 +- .../social/profile_friends_and_groups.inc.php | 12 +- main/social/search.php | 37 +- main/template/default/layout/footer.tpl | 6 +- main/template/default/layout/head.tpl | 1 - main/user/user.php | 37 +- main/webservices/cm_webservice_user.php | 63 +-- main/webservices/registration.soap.php | 31 +- main/wiki/wiki.inc.php | 70 ++-- main/work/work.lib.php | 8 +- .../ajax/advanced_subscription.ajax.php | 27 +- plugin/advanced_subscription/test/mails.php | 4 +- plugin/ticket/src/new_ticket.php | 22 +- plugin/ticket/src/report.php | 24 +- .../Migrations/Schema/V110/Version110.php | 4 + tests/main/inc/lib/social.lib.test.php | 11 - tests/main/inc/lib/usermanager.lib.test.php | 4 +- 55 files changed, 677 insertions(+), 1071 deletions(-) delete mode 100755 main/gradebook/user_info.php diff --git a/main/admin/group_edit.php b/main/admin/group_edit.php index 5cce04b3a0..a0737ad717 100755 --- a/main/admin/group_edit.php +++ b/main/admin/group_edit.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'); diff --git a/main/admin/user_edit.php b/main/admin/user_edit.php index 6915f9fae5..f6cbd14ed9 100755 --- a/main/admin/user_edit.php +++ b/main/admin/user_edit.php @@ -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 .= ''; -$content = null; -if ($image == '') { - $content .= ''; -} else { - $content .= ''; -} // Display form -$content .= $form->return_form(); +$content .= $form->returnForm(); $tpl = new Template($tool_name); $tpl->assign('message', $message); diff --git a/main/admin/user_information.php b/main/admin/user_information.php index e53301600b..58ce04a8aa 100755 --- a/main/admin/user_information.php +++ b/main/admin/user_information.php @@ -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 '
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 '
'; -echo '
'; -echo '' - .'
'; +echo '
'; +echo '' + .'
'; echo '
'; echo $message; -echo '
'; +echo '
'; echo $userInformation; echo '
'; -echo '
'; +echo '
'; echo $trackingInformation; echo '
'; echo '
'; diff --git a/main/admin/user_list.php b/main/admin/user_list.php index f610ea089d..34c96251a9 100755 --- a/main/admin/user_list.php +++ b/main/admin/user_list.php @@ -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 = '
- '.api_get_person_name($user[2],$user[3]).'
'; - } else { - $photo = '
'.api_get_person_name($user[2], $user[3]).'
'; - } + $userPicture = UserManager::getUserPicture($user[0], USER_IMAGE_SIZE_SMALL); + $photo = ''.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]); diff --git a/main/auth/profile.php b/main/auth/profile.php index 41d6487466..70a9afbeb8 100755 --- a/main/auth/profile.php +++ b/main/auth/profile.php @@ -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 = '
'; + $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 .= ''; - } else { - $imageToShow .= ''; - } + $imageToShow = '
'; + $imageToShow .= ''; $imageToShow .= '
'; $content = $imageToShow.$form->returnForm(); - $tpl->assign('content', $form->returnForm()); + $tpl->assign('content', $content); $tpl->display_one_col_template(); } diff --git a/main/chat/chat_functions.lib.php b/main/chat/chat_functions.lib.php index ac46b479c1..1e504fba72 100755 --- a/main/chat/chat_functions.lib.php +++ b/main/chat/chat_functions.lib.php @@ -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 = ''; diff --git a/main/chat/chat_whoisonline.php b/main/chat/chat_whoisonline.php index 86f38f164d..1f697a6e6b 100755 --- a/main/chat/chat_whoisonline.php +++ b/main/chat/chat_whoisonline.php @@ -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'].'&'; ?>
  • diff --git a/main/cron/import_csv.php b/main/cron/import_csv.php index 500e4a770b..8006fb36ac 100755 --- a/main/cron/import_csv.php +++ b/main/cron/import_csv.php @@ -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); } diff --git a/main/cron/user_import/client.php b/main/cron/user_import/client.php index 016a150397..69031e36c3 100755 --- a/main/cron/user_import/client.php +++ b/main/cron/user_import/client.php @@ -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; diff --git a/main/document/document.php b/main/document/document.php index ae02f7164d..9e18471a67 100755 --- a/main/document/document.php +++ b/main/document/document.php @@ -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)) { diff --git a/main/forum/forumfunction.inc.php b/main/forum/forumfunction.inc.php index b65063d201..cf6d65b9fc 100755 --- a/main/forum/forumfunction.inc.php +++ b/main/forum/forumfunction.inc.php @@ -3182,10 +3182,8 @@ function display_user_image($user_id, $name, $origin = '') $userInfo = api_get_user_info($user_id); $link = ''; 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.''.$name.''; + return $link.''.$name.''; } else { return $link.''.$name.''; } diff --git a/main/forum/viewthread_flat.inc.php b/main/forum/viewthread_flat.inc.php index 5e0de98e97..7aaf0c73dd 100755 --- a/main/forum/viewthread_flat.inc.php +++ b/main/forum/viewthread_flat.inc.php @@ -1,14 +1,20 @@ 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 ''; // 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 ""; echo ""; // 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 ''; $html .= '
    '; @@ -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.= ''; - $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.= '
    '.$name.'
    '; + $userPicture = $user_sender_info['avatar']; + $main_content.= '
    '.$name.'
    '; $user_link = ''.$name.' '; $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.= ''; - $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.= '
    '.$name.'
    '; + $userPicture = $user_sender_info['avatar']; + + $html_items.= '
    '.$name.'
    '; $user_link = ''.$name.' '; $date = ''; diff --git a/main/inc/lib/social.lib.php b/main/inc/lib/social.lib.php index 1bb51f9d6b..94df1b52da 100755 --- a/main/inc/lib/social.lib.php +++ b/main/inc/lib/social.lib.php @@ -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').'
    '; } } 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 .= ' '; - } else { - $html .= ''; - } + $big_image = UserManager::getUserPicture($user_id, USER_IMAGE_SIZE_BIG); + $normal_image = UserManager::getUserPicture($user_id, USER_IMAGE_SIZE_ORIGINAL); + $html .= ' '; } $html .= ''; @@ -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 = ''.$name.''; + $img = ''.$name.''; $name = ''.$status_icon.$user_status.$name.''; $html .= '
    @@ -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 ? ' ('.get_lang('Me').')' : ''); + $userInfo = api_get_user_info($user_id); + $alt = $userInfo['complete_name'].($currentUserId == $user_id ? ' ('.get_lang('Me').')' : ''); $status = get_status_from_code($user_object->status); $interbreadcrumb[] = array('url' => 'whoisonline.php', 'name' => get_lang('UsersOnLineList')); $html .= '
    '; + $fullurl = $userInfo['avatar']; + + $html .= ''.$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 ''; - $html .= ''.$alt.''; - } else { - $html .= api_get_configuration_value('gravatar_enabled') ? - ''.$alt.'' : - Display::return_icon('unknown.jpg', get_lang('Unknown')); - } if (!empty($status)) { $html .= '
    '.$status.'
    '; } @@ -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" /> '.get_lang('Post').' '; $formattedList .= '
    '; + 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 = ''; } @@ -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.= '
  • '; // 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.= ''; + $friends_profile = UserManager::getUserPicture($friend['friend_user_id'], USER_IMAGE_SIZE_SMALL); + $friendHtml.= ''; $link_shared = (empty($link_shared)) ? '' : '&'.$link_shared; $friendHtml.= $statusIcon .'' . $name_user .''; $friendHtml.= '
  • '; diff --git a/main/inc/lib/usermanager.lib.php b/main/inc/lib/usermanager.lib.php index 228e8e0a5a..1d04f3b21b 100755 --- a/main/inc/lib/usermanager.lib.php +++ b/main/inc/lib/usermanager.lib.php @@ -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 @@ -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']); } } diff --git a/main/inc/lib/userportal.lib.php b/main/inc/lib/userportal.lib.php index 3d384ddbf5..6692b23629 100755 --- a/main/inc/lib/userportal.lib.php +++ b/main/inc/lib/userportal.lib.php @@ -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 .= ''; + $content .= ' + '; } else { - $profile_content .= ''; + $content .= ' + '; } + $html = self::show_right_block( null, - $profile_content, + $content, 'user_image_block', array('style' => 'text-align:center;') ); } + return $html; } diff --git a/main/install/install.lib.php b/main/install/install.lib.php index 3b9c99232d..7d82385416 100755 --- a/main/install/install.lib.php +++ b/main/install/install.lib.php @@ -900,7 +900,7 @@ function display_requirements(
    - + diff --git a/main/messages/new_message.php b/main/messages/new_message.php index 9669b904a7..593fde1282 100755 --- a/main/messages/new_message.php +++ b/main/messages/new_message.php @@ -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; } diff --git a/main/mySpace/myStudents.php b/main/mySpace/myStudents.php index 878965d3ca..4471265d45 100755 --- a/main/mySpace/myStudents.php +++ b/main/mySpace/myStudents.php @@ -467,31 +467,9 @@ if (!empty($student_id)) { echo '
    "; @@ -45,15 +51,15 @@ if (isset($current_thread['thread_id'])) { } echo display_user_link($row['user_id'], $name, '', $username).'
    '; } else { - echo Display::tag('span', $name, array('title'=>api_htmlentities($username, ENT_QUOTES))).'
    '; + echo Display::tag('span', $name, array('title' => api_htmlentities($username, ENT_QUOTES))).'
    '; } $group_id = api_get_group_id(); echo api_convert_and_format_date($row['post_date']).'

    '; // 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 "".Display::return_icon('delete.png', get_lang('Delete'),array(), ICON_SIZE_SMALL).""; } } - 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 "
    '; - $realname=$attachment['path']; + $realname = $attachment['path']; $user_filename=$attachment['filename']; echo Display::return_icon('attachment.gif',get_lang('Attachment')); diff --git a/main/gradebook/lib/fe/displaygradebook.php b/main/gradebook/lib/fe/displaygradebook.php index a0620eac59..e5f5fb9d62 100755 --- a/main/gradebook/lib/fe/displaygradebook.php +++ b/main/gradebook/lib/fe/displaygradebook.php @@ -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 = '
    '; - $info .= '
    '; + $info = '
    '; + $info .= '
    '; $info .= '
    '; - $info .= '
    '; + $info .= '
    '; $info .= get_lang('Name') . ' : ' . $user['complete_name'] . '
    '; diff --git a/main/gradebook/user_info.php b/main/gradebook/user_info.php deleted file mode 100755 index f623536083..0000000000 --- a/main/gradebook/user_info.php +++ /dev/null @@ -1,66 +0,0 @@ -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 ''; -$form->display(); -Display :: display_footer(); diff --git a/main/gradebook/user_stats.php b/main/gradebook/user_stats.php index d9067628b6..1b3cad32da 100755 --- a/main/gradebook/user_stats.php +++ b/main/gradebook/user_stats.php @@ -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); } diff --git a/main/group/group_space.php b/main/group/group_space.php index d1e11f7155..01c033ce45 100755 --- a/main/group/group_space.php +++ b/main/group/group_space.php @@ -330,17 +330,14 @@ if (count($tutors) == 0) { isset($origin) ? $my_origin = $origin:$my_origin=''; $tutor_info .= '
      '; 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 = ''.$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 = ''.$completeName.''; $tutor_info .= '
    • '; $tutor_info .= Display::url( - $tab_user_info['complete_name'], - $tab_user_info['profile_url'] + $userInfo['complete_name'], + $userInfo['profile_url'] ); $tutor_info .= '
    • '; } @@ -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 = '
      '.$userInfo['complete_name'].'
      '; + $photo = ''.$userInfo['complete_name'].''; return Display::url($photo, $userInfo['profile_url']); } diff --git a/main/inc/ajax/social.ajax.php b/main/inc/ajax/social.ajax.php index 0a58d48b16..d7743f47fb 100755 --- a/main/inc/ajax/social.ajax.php +++ b/main/inc/ajax/social.ajax.php @@ -88,9 +88,9 @@ switch ($action) { $friend_html.='
    • '; $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.='
      '; - $friend_html.=''; + $friend_html.=''; $friend_html.='
      '; $friend_html.='
      '.$user_name.'
      '; $friend_html.='

      '; diff --git a/main/inc/lib/api.lib.php b/main/inc/lib/api.lib.php index 1e88b610cd..b7b05709b3 100644 --- a/main/inc/lib/api.lib.php +++ b/main/inc/lib/api.lib.php @@ -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; diff --git a/main/inc/lib/attendance.lib.php b/main/inc/lib/attendance.lib.php index d1634c90cf..a59324080a 100755 --- a/main/inc/lib/attendance.lib.php +++ b/main/inc/lib/attendance.lib.php @@ -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 = '
      - '.api_get_person_name($user_data['firstname'], $user_data['lastname']).'
      '; - } else { - $photo = '
      '.api_get_person_name($user_data['firstname'], $user_data['lastname']).'
      '; - } + $photo = ''; $value['photo'] = $photo; $value['firstname'] = $user_data['firstname']; diff --git a/main/inc/lib/diagnoser.lib.php b/main/inc/lib/diagnoser.lib.php index c7915ac906..a0794ef286 100755 --- a/main/inc/lib/diagnoser.lib.php +++ b/main/inc/lib/diagnoser.lib.php @@ -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'); diff --git a/main/inc/lib/document.lib.php b/main/inc/lib/document.lib.php index 408c4c1dba..1775e107ae 100755 --- a/main/inc/lib/document.lib.php +++ b/main/inc/lib/document.lib.php @@ -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_')) { diff --git a/main/inc/lib/events.lib.php b/main/inc/lib/events.lib.php index 2be25453dd..b82a5ae871 100644 --- a/main/inc/lib/events.lib.php +++ b/main/inc/lib/events.lib.php @@ -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']); diff --git a/main/inc/lib/extra_field_value.lib.php b/main/inc/lib/extra_field_value.lib.php index 8444d2f1c1..1d174f2798 100755 --- a/main/inc/lib/extra_field_value.lib.php +++ b/main/inc/lib/extra_field_value.lib.php @@ -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], diff --git a/main/inc/lib/group_portal_manager.lib.php b/main/inc/lib/group_portal_manager.lib.php index 0514a0249f..892b54957f 100755 --- a/main/inc/lib/group_portal_manager.lib.php +++ b/main/inc/lib/group_portal_manager.lib.php @@ -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'] = ''; + $picture = UserManager::getUserPicture($row['user_id']); + $row['image'] = ''; } $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 .= '
    • '.Display::return_icon('compose_message.png', get_lang('NewTopic'), array('hspace'=>'6')).'
    • '; - //$links .= '
    • '. Display::return_icon('message_list.png', get_lang('MessageList'), array('hspace'=>'6')).''.get_lang('MessageList').'
    • '; - //$links .= '
    • '. Display::return_icon('member_list.png', get_lang('MemberList'), array('hspace'=>'6')).''.get_lang('MemberList').'
    • '; if ($group_info['visibility'] == GROUP_PERMISSION_CLOSED) { $links .= '
    • '.Display::return_icon('waiting_list.png', get_lang('WaitingList'), array('hspace' => '6')).''.get_lang('WaitingList').'
    • '; } diff --git a/main/inc/lib/message.lib.php b/main/inc/lib/message.lib.php index 983752834d..03a28f9be8 100755 --- a/main/inc/lib/message.lib.php +++ b/main/inc/lib/message.lib.php @@ -53,6 +53,7 @@ class MessageManager GetFullUserName($uid). ""; } + 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 .= '
      '; @@ -1090,13 +1088,17 @@ class MessageManager $html .= '
      '; $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 = '
      '.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 .= '
      '.get_lang('LastUpdate').' '.date_to_str_ago($topic['update_date']).'
      '; } } else { @@ -1105,12 +1107,10 @@ class MessageManager $html .= $date.$actions; $html .= '
      '; - $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 = '
    '.$name.' '; - $user_info .= '
    '.$name.'
    '; + $user_info .= '
    '.$name.'
    '; $user_info .= '
    '.api_get_path(SYS_APP_PATH).'upload/users/'.check_writable(api_get_path(SYS_CODE_PATH).'upload/users/').''.check_writable(api_get_path(SYS_APP_PATH).'upload/users/').'
    '.api_get_path(SYS_APP_PATH).'upload/sessions/
    '; echo ''; - $gravatarEnabled = api_get_configuration_value('gravatar_enabled'); - $image_array = UserManager :: get_user_picture_path_by_id($user_info['user_id'], 'web', false, true); - echo ''; ?>
    '; - - // 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 ''; - if ($image_array['file'] == 'unknown.jpg') { - echo ''; - } else { - echo ''; - } echo ' diff --git a/main/mySpace/user_add.php b/main/mySpace/user_add.php index 9d521e3659..4471678819 100755 --- a/main/mySpace/user_add.php +++ b/main/mySpace/user_add.php @@ -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()) { diff --git a/main/social/friends.php b/main/social/friends.php index 6345e70c10..6ad5c4e8da 100755 --- a/main/social/friends.php +++ b/main/social/friends.php @@ -117,9 +117,9 @@ if (count($friends) == 0) { $friend_html.='
  • '; $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.='
    '; - $friend_html.=' '; + $friend_html.=' '; $friend_html.='
    '.$user_name.'
    '; $friend_html.='

    diff --git a/main/social/group_invitation.php b/main/social/group_invitation.php index 4d21ecaac2..25ff13b431 100755 --- a/main/social/group_invitation.php +++ b/main/social/group_invitation.php @@ -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'] = ''; + $userPicture = UserManager::getUserPicture($member['user_id']); + $member['image'] = ''; } $social_right_content .= '

    ' . get_lang('UsersAlreadyInvited') . '

    '; $social_right_content .= Display::return_sortable_grid( diff --git a/main/social/group_members.php b/main/social/group_members.php index 33233ce2df..1651c13576 100755 --- a/main/social/group_members.php +++ b/main/social/group_members.php @@ -122,13 +122,13 @@ $social_right_content .= '
    '; 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'] = '' . Display::return_icon( + $user['link'] = '' . + Display::return_icon( 'delete.png', get_lang('DeleteFromGroup') ) . '' . - '' . Display::return_icon( + '' . + Display::return_icon( 'social_moderator_add.png', get_lang('AddModerator') ) . ''; } break; - case GROUP_USER_PERMISSION_PENDING_INVITATION: - $user['link'] = '' . Display::return_icon( + case GROUP_USER_PERMISSION_PENDING_INVITATION: + $user['link'] = '' . + Display::return_icon( 'pending_invitation.png', get_lang('PendingInvitation') ) . ''; 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'] .= '' . Display::return_icon( + $user['link'] .= ''. + Display::return_icon( 'social_moderator_delete.png', get_lang('DeleteModerator') ) . ''; @@ -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'] = ''; - + $userPicture = UserManager::getUserPicture($user['user_id']); + $user['image'] = ''; $new_member_list[] = $user; } if (count($new_member_list) > 0) { diff --git a/main/social/groups.php b/main/social/groups.php index f22df53ec7..0e0aaf77f3 100755 --- a/main/social/groups.php +++ b/main/social/groups.php @@ -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 .= '
    '; $member_name = Display::url( @@ -418,7 +408,7 @@ if ($group_id != 0) { 'profile.php?u=' . $member['user_id'] ); $member_content .= Display::div( - ' ' . $member_name + ' ' . $member_name ); $member_content .= '
    '; diff --git a/main/social/invitations.php b/main/social/invitations.php index d8cc3f1fb2..15de4c71c6 100755 --- a/main/social/invitations.php +++ b/main/social/invitations.php @@ -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 = '
    '; $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 .= ''; + $socialInvitationsBlock .= ''; } 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 .= '
    '; - $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 .= '
    '; $socialInvitationsBlock .= '
    '; - $socialInvitationsBlock .= ''; + $socialInvitationsBlock .= ''; $socialInvitationsBlock .= '
    '; $socialInvitationsBlock .= '
    '; $socialInvitationsBlock .= '

    - '.api_get_person_name($user_info['firstName'], $user_info['lastName']).': + '.$user_info['complete_name'].':

    '; $socialInvitationsBlock .= '
    '.$content.'
    '; $socialInvitationsBlock .= '
    '.get_lang('DateSend').' : '.$date.'
    '; @@ -150,23 +155,20 @@ if (count($list_get_invitation_sent) > 0) { $socialInvitationsBlock .= '
    '; foreach ($list_get_invitation_sent as $invitation) { $sender_user_id = $invitation['user_receiver_id']; + $user_info = api_get_user_info($sender_user_id); $socialInvitationsBlock .= '
    '; - $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 .= '
    '; $socialInvitationsBlock .= '
    '; - $socialInvitationsBlock .= ''; + $socialInvitationsBlock .= ''; $socialInvitationsBlock .= '
    '; $socialInvitationsBlock .= '
    '; - $socialInvitationsBlock .= '

    '.api_get_person_name($user_info['firstName'], $user_info['lastName']).'

    '; + $socialInvitationsBlock .= '

    '.$user_info['complete_name'].'

    '; $socialInvitationsBlock .= '
    '.$title.' : '.$content.'
    '; $socialInvitationsBlock .= '
    '. get_lang('DateSend').' : '.$date.'
    '; $socialInvitationsBlock .= '
    '; diff --git a/main/social/message_for_group_form.inc.php b/main/social/message_for_group_form.inc.php index 516cd40536..83fc458f9d 100755 --- a/main/social/message_for_group_form.inc.php +++ b/main/social/message_for_group_form.inc.php @@ -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; diff --git a/main/social/profile.php b/main/social/profile.php index bb10fb2e6b..ef5fa33589 100755 --- a/main/social/profile.php +++ b/main/social/profile.php @@ -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); } diff --git a/main/social/profile_friends_and_groups.inc.php b/main/social/profile_friends_and_groups.inc.php index 1e2eca9167..828b80beb5 100755 --- a/main/social/profile_friends_and_groups.inc.php +++ b/main/social/profile_friends_and_groups.inc.php @@ -55,17 +55,11 @@ if (isset($_GET['view']) && in_array($_GET['view'], $views)) { $friend['lastName'] ); $friend_html .= '
    '; - // 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 .= ''; - $friend_html .= ''; + $friend_html .= ''; $friend_html .= '
    '; $friend_html .= '
    ' . $name_user . '
    '; $friend_html .= '
    '; diff --git a/main/social/search.php b/main/social/search.php index 42331d58f1..f65042f693 100755 --- a/main/social/search.php +++ b/main/social/search.php @@ -74,10 +74,9 @@ if ($query != '' || ($query_vars['search_type']=='1' && count($query_vars)>2) ) $results .= '
    '; $buttonClass = 'btn btn-default btn-sm'; foreach ($users as $user) { - - $send_inv = ''; + $send_inv = ''; $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 = ' '.get_lang('SendMessage').''; - if (empty($user['picture_uri'])) { - $picture['file'] = api_get_path(WEB_CODE_PATH).'img/unknown.jpg'; - $img = ''; - } else { - $picture = UserManager::get_picture_user( - $user['user_id'], - $user['picture_uri'], - 50, - USER_IMAGE_SIZE_ORIGINAL - ); - $img = ''; - } + + $img = ''; 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 .= '
      '; 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 = ''; - $url_close = ''; - $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 = ''; + $url_close = ''; + $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'] = ''; diff --git a/main/template/default/layout/footer.tpl b/main/template/default/layout/footer.tpl index 38097a82e5..946d88bc3e 100755 --- a/main/template/default/layout/footer.tpl +++ b/main/template/default/layout/footer.tpl @@ -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 diff --git a/main/template/default/layout/head.tpl b/main/template/default/layout/head.tpl index 82be94604f..676a252e17 100755 --- a/main/template/default/layout/head.tpl +++ b/main/template/default/layout/head.tpl @@ -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); }); }); diff --git a/main/user/user.php b/main/user/user.php index 8667208a26..df281068f5 100755 --- a/main/user/user.php +++ b/main/user/user.php @@ -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( - ''.api_get_person_name($o_course_user['firstname'], $o_course_user['lastname']).'', - $userInfo['profile_url'] - ); - } else { - $photo = ''.api_get_person_name($o_course_user['firstname'], $o_course_user['lastname']).''; - } + $photo = ''.$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= ''.api_get_person_name($o_course_user['firstname'], $o_course_user['lastname']).''; - } + $userPicture = $userInfo['avatar']; + + $photo= ''.$userInfo['complete_name'].''; + $temp[] = $user_id; $temp[] = $photo; $temp[] = $o_course_user['official_code']; diff --git a/main/webservices/cm_webservice_user.php b/main/webservices/cm_webservice_user.php index 66c9b1c40b..9757c466c2 100755 --- a/main/webservices/cm_webservice_user.php +++ b/main/webservices/cm_webservice_user.php @@ -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")); */ - -?> diff --git a/main/webservices/registration.soap.php b/main/webservices/registration.soap.php index d39a5b405e..863e05ee75 100755 --- a/main/webservices/registration.soap.php +++ b/main/webservices/registration.soap.php @@ -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; } diff --git a/main/wiki/wiki.inc.php b/main/wiki/wiki.inc.php index 3dfda2874f..80f1c5ad4d 100755 --- a/main/wiki/wiki.inc.php +++ b/main/wiki/wiki.inc.php @@ -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= ''.$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 = '' . $name . ''; - } + $photo = '' . $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='
      + // first: teacher name, photo, and assignment description (original content) + $content_orig_A = '
      '.get_lang('AssignmentDesc').'
      '.$photo.'
      '.Display::tag('span', api_get_person_name($userinfo['firstname'], $userinfo['lastname']), array('title'=>$username)).'
      '; - $content_orig_B='
      '.get_lang('AssignmentDescription').': '.$title_orig.'

      '.$_POST['content']; + + $content_orig_B = '
      '.get_lang('AssignmentDescription').': '.$title_orig.'

      '.$_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= ''.$name.''; + $photo= ''.$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'] = '
      @@ -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 '
      '; - //echo '
      '; 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= ''.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= ''.api_htmlentities($name).''; - } + $author_photo= ''.api_htmlentities($name).''; //stars $p_score=$row['p_score']; diff --git a/main/work/work.lib.php b/main/work/work.lib.php index 63e20b19ac..31f2c15448 100755 --- a/main/work/work.lib.php +++ b/main/work/work.lib.php @@ -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)) { diff --git a/plugin/advanced_subscription/ajax/advanced_subscription.ajax.php b/plugin/advanced_subscription/ajax/advanced_subscription.ajax.php index 979f961934..33a1b949d3 100644 --- a/plugin/advanced_subscription/ajax/advanced_subscription.ajax.php +++ b/plugin/advanced_subscription/ajax/advanced_subscription.ajax.php @@ -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)) { diff --git a/plugin/advanced_subscription/test/mails.php b/plugin/advanced_subscription/test/mails.php index 617eea1b9d..8eaec4d157 100644 --- a/plugin/advanced_subscription/test/mails.php +++ b/plugin/advanced_subscription/test/mails.php @@ -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)) { diff --git a/plugin/ticket/src/new_ticket.php b/plugin/ticket/src/new_ticket.php index 8c29143fff..7518849b78 100755 --- a/plugin/ticket/src/new_ticket.php +++ b/plugin/ticket/src/new_ticket.php @@ -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 = '
      ' . api_get_person_name($user[2], $user[3]) . '
      '; - } else { - $photo = '
      ' . api_get_person_name($user[2], $user[3]) . '
      '; - } + $userPicture = UserManager::getUserPicture($user_id); + $photo = '' . api_get_person_name($user[2], $user[3]) . ''; $button = '' . Display::return_icon('view_more_stats.gif', get_lang('Info')) . '  '; - $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; } diff --git a/plugin/ticket/src/report.php b/plugin/ticket/src/report.php index 023138f3e9..47d86b7aa7 100755 --- a/plugin/ticket/src/report.php +++ b/plugin/ticket/src/report.php @@ -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 = '
      ' . api_get_person_name($user[2], $user[3]) . '
      '; - } else { - $photo = '
      ' . api_get_person_name($user[2], $user[3]) . '
      '; - } + $userPicture = UserManager::getUserPicture($user[0]); + $photo = '' . api_get_person_name($user[2], $user[3]) . ''; $user_id = $user[0]; - $button = '' . Display::return_icon('view_more_stats.gif', get_lang('Info')) . ''; $button = ' ' . get_lang('Courses') . '   '; - $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; } diff --git a/src/Chamilo/CoreBundle/Migrations/Schema/V110/Version110.php b/src/Chamilo/CoreBundle/Migrations/Schema/V110/Version110.php index 8dcec6cb20..0b6ac0bc76 100644 --- a/src/Chamilo/CoreBundle/Migrations/Schema/V110/Version110.php +++ b/src/Chamilo/CoreBundle/Migrations/Schema/V110/Version110.php @@ -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'"); diff --git a/tests/main/inc/lib/social.lib.test.php b/tests/main/inc/lib/social.lib.test.php index 3294c4654a..4bb4aa29d3 100755 --- a/tests/main/inc/lib/social.lib.test.php +++ b/tests/main/inc/lib/social.lib.test.php @@ -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); diff --git a/tests/main/inc/lib/usermanager.lib.test.php b/tests/main/inc/lib/usermanager.lib.test.php index 018c8dc797..b074b32467 100755 --- a/tests/main/inc/lib/usermanager.lib.test.php +++ b/tests/main/inc/lib/usermanager.lib.test.php @@ -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)); }
      '.get_lang('AssignmentWork').'