From 6b5ef8b70e227f71d6443852f782ce2b792ec6ef Mon Sep 17 00:00:00 2001 From: Angel Fernando Quiroz Campos Date: Fri, 26 Jun 2015 16:56:48 -0500 Subject: [PATCH 1/6] Minor - Fix call to function - refs BT#9901 #TMI --- main/admin/skill_badge.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main/admin/skill_badge.php b/main/admin/skill_badge.php index 3bb43b3c11..60c65de9c0 100644 --- a/main/admin/skill_badge.php +++ b/main/admin/skill_badge.php @@ -16,7 +16,7 @@ if (!api_is_platform_admin() || api_get_setting('allow_skills_tool') !== 'true') } $backpack = 'https://backpack.openbadges.org/'; -$configBackpack = api_get_seeting('openbadges_backpack'); +$configBackpack = api_get_setting('openbadges_backpack'); if (strcmp($backpack, $configBackpack) !== 0) { $backpack = $configBackpack; } From 640edd74b58910938abde50648350fb750953f0a Mon Sep 17 00:00:00 2001 From: Angel Fernando Quiroz Campos Date: Fri, 26 Jun 2015 16:57:24 -0500 Subject: [PATCH 2/6] Create tpl for skills block - refs BT#9901 #TMI --- main/inc/lib/social.lib.php | 30 +++++++ main/social/home.php | 83 +------------------ main/social/profile.php | 71 +--------------- main/template/default/social/skills_block.tpl | 41 +++++++++ 4 files changed, 73 insertions(+), 152 deletions(-) create mode 100644 main/template/default/social/skills_block.tpl diff --git a/main/inc/lib/social.lib.php b/main/inc/lib/social.lib.php index 56cfc47ae4..13c00cc4a0 100755 --- a/main/inc/lib/social.lib.php +++ b/main/inc/lib/social.lib.php @@ -1603,4 +1603,34 @@ class SocialManager extends UserManager return $html; } + + /** + * Get HTML code block for user skills + * @param int $userId The user ID + * @return string + */ + public static function getSkillBlock($userId) + { + if (api_get_setting('allow_skills_tool') !== 'true') { + return null; + } + + $skill = new Skill(); + + $ranking = $skill->get_user_skill_ranking($userId); + $skills = $skill->get_user_skills($userId, true); + + $template = new Template(null, false, false, false, false, false); + $template->assign('ranking', $ranking); + $template->assign('skills', $skills); + $template->assign( + 'show_skills_report_link', + api_is_student() || api_is_student_boss() || api_is_drh() + ); + + $skillBlock = $template->get_template('social/skills_block.tpl'); + + return $template->fetch($skillBlock); + } + } diff --git a/main/social/home.php b/main/social/home.php index 6113bbcc26..baeeb7be62 100755 --- a/main/social/home.php +++ b/main/social/home.php @@ -80,87 +80,6 @@ if (api_get_setting('profile', 'picture') == 'true') { $social_menu_block = SocialManager::show_social_menu('home'); $social_search_block = Display::panel(UserManager::get_search_form(''), get_lang("SearchUsers")); -//BLock Social Skill -$social_skill_block = ''; - -if (api_get_setting('allow_skills_tool') == 'true') { - $skill = new Skill(); - - $ranking = $skill->get_user_skill_ranking(api_get_user_id()); - $skills = $skill->get_user_skills(api_get_user_id(), true); - - $extra = '
- - -
'; - - $social_skill_block = Display::panel( - null, - get_lang('Skills'), - null, - null, - $extra - ); - - $lis = ''; - if (!empty($skills)) { - foreach ($skills as $skill) { - $badgeImage = null; - - if (!empty($skill['icon'])) { - $badgeImage = Display::img( - $skill['web_icon_thumb_path'], - $skill['name'] - ); - } else { - $badgeImage = Display::return_icon( - 'badges-default.png', - $skill['name'], - array('title' => $skill['name']), ICON_SIZE_BIG - ); - } - - $lis .= Display::tag( - 'li', - $badgeImage . - '
' . $skill['name'] . '
' - ); - } - $content = Display::tag('ul', $lis, array('class' => 'list-badges')); - $social_skill_block = Display::panel( - $content, - get_lang('Skills'), - null, - null, - $extra - ); - - } else { - $social_skill_block .= Display::panel( - Display::url(get_lang('SkillsWheel'), api_get_path(WEB_CODE_PATH) . 'social/skills_wheel.php'), - get_lang('WithoutAchievedSkills') - ); - } -} - $results = $userGroup->get_groups_by_age(1, false); $groups_newest = array(); @@ -277,7 +196,7 @@ SocialManager::setSocialUserBlock($tpl, api_get_user_id(), 'home'); $tpl->assign('social_menu_block', $social_menu_block); $tpl->assign('social_search_block', $social_search_block); -$tpl->assign('social_skill_block', $social_skill_block); +$tpl->assign('social_skill_block', SocialManager::getSkillBlock($user_id)); $tpl->assign('social_group_block', $social_group_block); $social_layout = $tpl->get_template('social/home.tpl'); $tpl->display($social_layout); diff --git a/main/social/profile.php b/main/social/profile.php index 6d65fa5e8e..ce2586de13 100755 --- a/main/social/profile.php +++ b/main/social/profile.php @@ -34,7 +34,6 @@ $social_extra_info_block = null; $social_course_block = null; $social_group_info_block = null; $social_rss_block = null; -$social_skill_block = null; $social_session_block = null; if (!empty($_POST['social_wall_new_msg_main']) || !empty($_FILES['picture']['tmp_name'])) { @@ -501,74 +500,6 @@ if ($show_full_profile) { $social_rss_block = Display::panel($user_feeds, get_lang('RSSFeeds')); } - //BLock Social Skill - if (api_get_setting('allow_skills_tool') == 'true') { - $skill = new Skill(); - - $ranking = $skill->get_user_skill_ranking($my_user_id); - $skills = $skill->get_user_skills($my_user_id, true); - - $social_skill_block = ''; - } - // Productions $production_list = UserManager::build_production_list($user_id); @@ -691,7 +622,7 @@ $tpl->assign('social_extra_info_block', $social_extra_info_block); $tpl->assign('social_course_block', $social_course_block); $tpl->assign('social_group_info_block', $social_group_info_block); $tpl->assign('social_rss_block', $social_rss_block); -$tpl->assign('social_skill_block', $social_skill_block); +$tpl->assign('social_skill_block', SocialManager::getSkillBlock($my_user_id)); $tpl->assign('social_session_block', $social_session_block); $tpl->assign('social_right_information', $socialRightInformation); $tpl->assign('social_auto_extend_link', $socialAutoExtendLink); diff --git a/main/template/default/social/skills_block.tpl b/main/template/default/social/skills_block.tpl new file mode 100644 index 0000000000..6bc641e7bc --- /dev/null +++ b/main/template/default/social/skills_block.tpl @@ -0,0 +1,41 @@ + From 837e95b8404f039445f4921bbcd665ff7cf53a37 Mon Sep 17 00:00:00 2001 From: Angel Fernando Quiroz Campos Date: Fri, 26 Jun 2015 17:28:29 -0500 Subject: [PATCH 3/6] Get all user extra fields - refs BT#9901 #TMI --- main/inc/lib/api.lib.php | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/main/inc/lib/api.lib.php b/main/inc/lib/api.lib.php index 48cd3aa8bc..d28e02e41d 100644 --- a/main/inc/lib/api.lib.php +++ b/main/inc/lib/api.lib.php @@ -1509,14 +1509,11 @@ function api_get_user_info( } if ($loadExtraData) { - $extraFieldValues = new ExtraFieldValue('user'); - $values = $extraFieldValues->getAllValuesByItem($user_id); + $fieldValue = new ExtraFieldValue('user'); - if (!empty($values)) { - foreach ($values as $value) { - $result_array['extra'][$value['variable']] = $value['value']; - } - } + $result_array['extra'] = $fieldValue->getAllValuesForAnItem( + $user_id + ); } $user = _api_format_user($result_array, $showPassword); From d13812fec79a4f8960d0044c638feab299b0b2c2 Mon Sep 17 00:00:00 2001 From: Angel Fernando Quiroz Campos Date: Fri, 26 Jun 2015 17:28:53 -0500 Subject: [PATCH 4/6] Fix Get user extra field on Advanced Subscription plugin - refs BT#9901 #TMI --- plugin/advanced_subscription/src/admin_view.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/plugin/advanced_subscription/src/admin_view.php b/plugin/advanced_subscription/src/admin_view.php index b66b35bb8d..ad6e7c1310 100644 --- a/plugin/advanced_subscription/src/admin_view.php +++ b/plugin/advanced_subscription/src/admin_view.php @@ -68,7 +68,10 @@ if (!empty($sessionId)) { $studentId = intval($student['user_id']); $data['studentUserId'] = $studentId; - $student['area'] = api_get_user_info($studentId, false, false, true)['extra']['area']; + $fieldValue = new ExtraFieldValue('user'); + $areaField = $foo->get_values_by_handler_and_field_variable($studentId, 'area', true); + + $student['area'] = $areaField['value']; $student['userLink'] = api_get_path(WEB_CODE_PATH).'social/profile.php?u='.$studentId; $data['queueId'] = intval($student['queue_id']); $data['newStatus'] = ADVANCED_SUBSCRIPTION_QUEUE_STATUS_ADMIN_APPROVED; From 3314509c005c80dc79b8af2c4cec766c7489b3c8 Mon Sep 17 00:00:00 2001 From: Angel Fernando Quiroz Campos Date: Fri, 26 Jun 2015 17:35:28 -0500 Subject: [PATCH 5/6] Get user extra fields on Social tool - refs BT#9901 #TMI --- main/inc/lib/social.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main/inc/lib/social.lib.php b/main/inc/lib/social.lib.php index 13c00cc4a0..eccaf47ef9 100755 --- a/main/inc/lib/social.lib.php +++ b/main/inc/lib/social.lib.php @@ -1487,7 +1487,7 @@ class SocialManager extends UserManager $profileEditionLink = Display::getProfileEditionLink($userId); } - $userInfo = api_get_user_info($userId, true); + $userInfo = api_get_user_info($userId, true, false, true); $template->assign('user', $userInfo); $template->assign('socialAvatarBlock', $socialAvatarBlock); $template->assign('profileEditionLink', $profileEditionLink); From a110d65013ba513fca3a9db69dc1d53c62bb3500 Mon Sep 17 00:00:00 2001 From: Angel Fernando Quiroz Campos Date: Fri, 26 Jun 2015 18:00:06 -0500 Subject: [PATCH 6/6] Create tpl for user avatar block - refs BT#9901 #TMI --- main/inc/lib/social.lib.php | 46 ++++++++++++------- main/template/default/social/avatar_block.tpl | 19 ++++++++ 2 files changed, 48 insertions(+), 17 deletions(-) create mode 100644 main/template/default/social/avatar_block.tpl diff --git a/main/inc/lib/social.lib.php b/main/inc/lib/social.lib.php index eccaf47ef9..b6a7e4d655 100755 --- a/main/inc/lib/social.lib.php +++ b/main/inc/lib/social.lib.php @@ -548,38 +548,50 @@ class SocialManager extends UserManager 'browse_groups' ); - $html = '
'; + $template = new Template(null, false, false, false, false, false); + if (in_array($show, $show_groups) && !empty($group_id)) { // Group image $userGroup = new UserGroup(); $group_info = $userGroup->get($group_id); - $big = $userGroup->get_picture_group( + $userGroupImage = $userGroup->get_picture_group( $group_id, $group_info['picture'], 160, GROUP_IMAGE_SIZE_BIG ); - $html .= Display::url( - '

', - api_get_path(WEB_CODE_PATH).'social/group_view.php?id='.$group_id + $template->assign('show_group', true); + $template->assign('group_id', $group_id); + $template->assign('user_group_image', $userGroupImage); + $template->assign( + 'user_is_group_admin', + $userGroup->is_group_admin( + $group_id, + api_get_user_id() + ) ); - - if ($userGroup->is_group_admin($group_id, api_get_user_id())) { - $html .= ''; - } } else { - $big_image = UserManager::getUserPicture($user_id, USER_IMAGE_SIZE_BIG); - $normal_image = UserManager::getUserPicture($user_id, USER_IMAGE_SIZE_ORIGINAL); - - $html .= ' '; + $template->assign('show_user', true); + $template->assign( + 'user_image', + [ + 'big' => UserManager::getUserPicture( + $user_id, + USER_IMAGE_SIZE_BIG + ), + 'normal' => UserManager::getUserPicture( + $user_id, + USER_IMAGE_SIZE_ORIGINAL + ) + ] + ); } - $html .= '
'; - return $html; + $skillBlock = $template->get_template('social/avatar_block.tpl'); + + return $template->fetch($skillBlock); } /** diff --git a/main/template/default/social/avatar_block.tpl b/main/template/default/social/avatar_block.tpl new file mode 100644 index 0000000000..cfea3a60bd --- /dev/null +++ b/main/template/default/social/avatar_block.tpl @@ -0,0 +1,19 @@ +
+ {% if show_group %} + + + + + {% if user_is_group_admin %} + + {% endif %} + {% elseif show_user %} + + + + {% endif %} +