Merge pull request #748 from AngelFQC/BT9901

Create tpl for Social tool - refs BT#9901 #TMI
1.10.x
Angel Fernando Quiroz Campos 10 years ago
commit 0ef8d24282
  1. 2
      main/admin/skill_badge.php
  2. 11
      main/inc/lib/api.lib.php
  3. 78
      main/inc/lib/social.lib.php
  4. 83
      main/social/home.php
  5. 71
      main/social/profile.php
  6. 19
      main/template/default/social/avatar_block.tpl
  7. 41
      main/template/default/social/skills_block.tpl
  8. 5
      plugin/advanced_subscription/src/admin_view.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;
}

@ -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);

@ -548,38 +548,50 @@ class SocialManager extends UserManager
'browse_groups'
);
$html = '<div class="avatar-profile">';
$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(
'<img src='.$big['file'].' class="social-groups-image" /> </a><br /><br />',
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 .= '<div id="edit_image">
<a href="'.api_get_path(WEB_CODE_PATH).'social/group_edit.php?id='.$group_id.'">'.
get_lang('EditGroup').'</a></div>';
}
} else {
$big_image = UserManager::getUserPicture($user_id, USER_IMAGE_SIZE_BIG);
$normal_image = UserManager::getUserPicture($user_id, USER_IMAGE_SIZE_ORIGINAL);
$html .= '<a class="expand-image" href="'.$big_image.'"><img class="img-responsive" src='.$normal_image.' /> </a>';
$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 .= '</div>';
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);
}
}

@ -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 = '<div class="btn-group pull-right">
<a class="btn btn-default dropdown-toggle" data-toggle="dropdown" href="#">
<span class="caret"></span></a>
<ul class="dropdown-menu">';
if (api_is_student() || api_is_student_boss() || api_is_drh()) {
$extra .= '<li>' . Display::url(
get_lang('SkillsReport'),
api_get_path(WEB_CODE_PATH) . 'social/my_skills_report.php'
) . '</li>';
}
$extra.= '<li>' . Display::url(
get_lang('SkillsWheel'),
api_get_path(WEB_CODE_PATH) . 'social/skills_wheel.php'
) . '</li>';
$extra .= '<li>' . Display::url(
sprintf(get_lang('YourSkillRankingX'), $ranking),
api_get_path(WEB_CODE_PATH) . 'social/skills_ranking.php'
) . '</li>';
$extra .= '</ul></div>';
$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 .
'<div class="badges-name">' . $skill['name'] . '</div>'
);
}
$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);

@ -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 = '<div class="panel panel-default social-skill">';
$social_skill_block .= '<div class="panel-heading">' . get_lang('Skills');
$social_skill_block .= '<div class="btn-group pull-right"> <a class="btn btn-xs btn-default dropdown-toggle" data-toggle="dropdown" href="#">
<span class="caret"></span></a>
<ul class="dropdown-menu">';
if (api_is_student() || api_is_student_boss() || api_is_drh()) {
$social_skill_block .= '<li>' . Display::url(
get_lang('SkillsReport'),
api_get_path(WEB_CODE_PATH) . 'social/my_skills_report.php'
) . '</li>';
}
$social_skill_block .= '<li>' . Display::url(
get_lang('SkillsWheel'),
api_get_path(WEB_CODE_PATH) . 'social/skills_wheel.php'
) . '</li>';
$social_skill_block .= '<li>' . Display::url(
sprintf(get_lang('YourSkillRankingX'), $ranking),
api_get_path(WEB_CODE_PATH) . 'social/skills_ranking.php'
) . '</li>';
$social_skill_block .= '</ul></div></div>';
$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 .
'<div class="badges-name">' . $skill['name'] . '</div>'
);
}
$social_skill_block .= '<div class="panel-body">';
$social_skill_block .= Display::tag('ul', $lis, array('class' => 'list-badges'));
$social_skill_block .= '</div>';
} else {
$social_skill_block .= '<div class="panel-body">';
$social_skill_block .= '<p>'. get_lang("WithoutAchievedSkills") . '</p>';
$social_skill_block .= '<p>' . Display::url(get_lang('SkillsWheel'),api_get_path(WEB_CODE_PATH) . 'social/skills_wheel.php').'</p>';
$social_skill_block .= '</div>';
}
$social_skill_block.='</div>';
}
// 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);

@ -0,0 +1,19 @@
<div class="avatar-profile">
{% if show_group %}
<a href="{{ _p.web_main ~ 'social/group_view.php?id=' ~ group_id }}">
<img src="{{ user_group_image.file }}" class="social-groups-image">
</a>
{% if user_is_group_admin %}
<div id="edit_image">
<a href="{{ _p.web_main ~ 'social/group_edit.php?id=' ~ group_id }}">
{{ 'EditGroup'|get_lang }}
</a>
</div>
{% endif %}
{% elseif show_user %}
<a href="{{ user_image.big }}" class="expand-image">
<img class="img-responsive" src="{{ user_image.normal }}">
</a>
{% endif %}
</div>

@ -0,0 +1,41 @@
<div class="panel panel-default social-skill">
<div class="panel-heading">
{{ 'Skills'|get_lang }}
<div class="btn-group pull-right">
<a class="btn btn-xs btn-default dropdown-toggle" data-toggle="dropdown" href="#">
<span class="caret"></span>
</a>
<ul class="dropdown-menu">
{% if show_skills_report_link %}
<li>
<a href="{{ _p.web_main ~ 'social/my_skills_report.php' }}"> {{'SkillsReport'|get_lang }}</a>
</li>
{% endif %}
<li>
<a href="{{ _p.web_main ~ 'social/skills_wheel.php' }}"> {{ 'SkillsWheel'|get_lang }}</a>
</li>
<li>
<a href="{{ _p.web_main ~ 'social/skills_ranking.php' }}"> {{ 'YourSkillRankingX'|get_lang|format(ranking) }}</a>
</li>
</ul>
</div>
</div>
<div class="panel-body">
{% if skills %}
<ul class="list-badges">
{% for skill in skills %}
<li>
<img title="{{ skill.name }}" src="{{ skill.icon ? skill.web_icon_thumb_path : 'badges-default.png'|icon(64) }}" alt="{{ skill.name }}">
<div class="badges-name">{{ skill.name }}</div>
</li>
{% endfor %}
</ul>
{% else %}
<p>{{ 'WithoutAchievedSkills'|get_lang }}</p>
<p>
<a href="{{ _p.web_main ~ 'social/skills_wheel.php' }}">{{ 'SkillsWheel'|get_lang }}</a>
</p>
{% endif %}
</div>
</div>

@ -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;

Loading…
Cancel
Save