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;
}
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);
diff --git a/main/inc/lib/social.lib.php b/main/inc/lib/social.lib.php
index 56cfc47ae4..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);
}
/**
@@ -1487,7 +1499,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);
@@ -1603,4 +1615,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 = '';
- $social_skill_block .= '
' . get_lang('Skills');
- $social_skill_block .= '
';
-
- $lis = '';
- if (!empty($skills)) {
- foreach ($skills as $skill) {
- $badgeImage = null;
-
- if (!empty($skill['icon'])) {
- $badgeImage = Display::img(
- api_get_path(WEB_DATA_PATH) . $skill['icon'],
- $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'] . '
'
- );
- }
- $social_skill_block .= '
';
- $social_skill_block .= Display::tag('ul', $lis, array('class' => 'list-badges'));
- $social_skill_block .= '
';
- } else {
-
- $social_skill_block .= '
';
- $social_skill_block .= '
'. get_lang("WithoutAchievedSkills") . '
';
- $social_skill_block .= '
' . Display::url(get_lang('SkillsWheel'),api_get_path(WEB_CODE_PATH) . 'social/skills_wheel.php').'
';
- $social_skill_block .= '
';
- }
- $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/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 %}
+
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 @@
+
+
+ {{ 'Skills'|get_lang }}
+
+
+
+ {% if skills %}
+
+ {% for skill in skills %}
+ -
+
+
{{ skill.name }}
+
+ {% endfor %}
+
+ {% else %}
+
{{ 'WithoutAchievedSkills'|get_lang }}
+
+ {{ 'SkillsWheel'|get_lang }}
+
+ {% endif %}
+
+
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;