Fix badge icon paths.

1.10.x
Julio Montoya 11 years ago
parent a235d18213
commit 5ad8a41541
  1. 4
      main/admin/skill_badge_create.php
  2. 49
      main/inc/lib/skill.lib.php
  3. 39
      main/social/home.php
  4. 38
      main/social/skills_wheel.php
  5. 2
      main/template/default/skill/badge_create.tpl
  6. 2
      main/template/default/skill/badge_list.tpl
  7. 22
      main/template/default/skill/skill_wheel_student.tpl

@ -45,13 +45,13 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
if ($existsBadgesDirectory) {
/*if (!empty($skill['icon'])) {
if (!empty($skill['icon'])) {
$iconFileAbsolutePath = $badgePath . $skill['icon'];
if (Security::check_abs_path($iconFileAbsolutePath, $badgePath)) {
unlink($badgePath . $skill['icon']);
}
}*/
}
$skillImagePath = sprintf("%s%s.png", $badgePath, $fileName);

@ -534,6 +534,20 @@ class Skill extends Model
$this->sessionTable = Database::get_main_table(TABLE_MAIN_SESSION);
}
/**
* Gets an element
* @param int $id
*
* @return array|mixed
*/
public function get($id)
{
$result = parent::get($id);
$result['web_icon_path'] = api_get_path(WEB_UPLOAD_PATH).'badges/'.$result['icon'];
return $result;
}
/**
* @param int $id
* @return array
@ -589,7 +603,14 @@ class Skill extends Model
}
}
$sql = "SELECT s.id, s.name, s.description, ss.parent_id, ss.relation_type, s.icon, s.short_code
$sql = "SELECT
s.id,
s.name,
s.description,
ss.parent_id,
ss.relation_type,
s.icon,
s.short_code
FROM {$this->table} s
INNER JOIN {$this->table_skill_rel_skill} ss
ON (s.id = ss.skill_id) $id_condition
@ -597,18 +618,19 @@ class Skill extends Model
$result = Database::query($sql);
$skills = array();
$webPath = api_get_path(WEB_UPLOAD_PATH);
if (Database::num_rows($result)) {
while ($row = Database::fetch_array($result, 'ASSOC')) {
$skill_rel_skill = new SkillRelSkill();
$a = $skill_rel_skill->get_skill_parents($row['id']);
$row['level'] = count($a) - 1;
$row['gradebooks'] = self::get_gradebooks_by_skill($row['id']);
$skill_rel_skill = new SkillRelSkill();
$parents = $skill_rel_skill->get_skill_parents($row['id']);
$row['level'] = count($parents) - 1;
$row['gradebooks'] = self::get_gradebooks_by_skill($row['id']);
$row['web_icon_path'] = $webPath.'badges/'.$row['icon'];
$skills[$row['id']] = $row;
}
}
//Load all children of the parent_id
// Load all children of the parent_id
if (!empty($skills) && !empty($parent_id)) {
foreach ($skills as $skill) {
$children = self::get_all($load_user_data, $user_id, $id, $skill['id']);
@ -848,6 +870,7 @@ class Skill extends Model
* Get user's skills
*
* @param int $userId User's id
* @param bool $get_skill_data
*/
public function get_user_skills($user_id, $get_skill_data = false)
{
@ -860,23 +883,30 @@ class Skill extends Model
$result = Database::query($sql);
$skills = Database::store_result($result, 'ASSOC');
$uploadPath = api_get_path(WEB_UPLOAD_PATH);
$clean_skill = array();
if (!empty($skills)) {
foreach ($skills as $skill) {
if ($get_skill_data) {
$iconThumb = null;
$iconPath = null;
if (!empty($skill['icon'])) {
$iconThumb = sprintf(
"badges/%s-small.png",
sha1($skill['name'])
);
$iconPath = sprintf(
"badges/%s.png",
sha1($skill['name'])
);
}
$clean_skill[$skill['id']] = array_merge(
$skill,
array(
'iconThumb' => $iconThumb
'web_icon_thumb_path' => $uploadPath.$iconThumb,
'web_icon_path' => $uploadPath.$iconPath
)
);
} else {
@ -884,6 +914,7 @@ class Skill extends Model
}
}
}
return $clean_skill;
}

@ -11,7 +11,6 @@
$cidReset = true;
require_once '../inc/global.inc.php';
require_once api_get_path(LIBRARY_PATH) . 'skill.lib.php';
$user_id = api_get_user_id();
$show_full_profile = true;
@ -25,7 +24,6 @@ if (api_get_setting('allow_social_tool') != 'true') {
$url = api_get_path(WEB_CODE_PATH) . 'auth/profile.php';
header('Location: ' . $url);
exit;
api_not_allowed();
}
//fast upload image
@ -98,8 +96,6 @@ if (api_get_setting('allow_skills_tool') == 'true') {
$ranking = $skill->get_user_skill_ranking(api_get_user_id());
$skills = $skill->get_user_skills(api_get_user_id(), true);
//$social_skill_block = '<div class="panel panel-default social-skill">';
//$social_skill_block .= '<div class="panel-heading">' . get_lang('Skills');
$extra = '<div class="btn-group pull-right">
<a class="btn btn-default dropdown-toggle" data-toggle="dropdown" href="#">
<span class="caret"></span></a>
@ -123,7 +119,13 @@ if (api_get_setting('allow_skills_tool') == 'true') {
$extra .= '</ul></div>';
$social_skill_block = Display::panel($content, get_lang('Skills'),null,null,$extra);
$social_skill_block = Display::panel(
null,
get_lang('Skills'),
null,
null,
$extra
);
$lis = '';
if (!empty($skills)) {
@ -132,7 +134,7 @@ if (api_get_setting('allow_skills_tool') == 'true') {
if (!empty($skill['icon'])) {
$badgeImage = Display::img(
api_get_path(WEB_DATA_PATH) . $skill['icon'],
$skill['web_icon_thumb_path'],
$skill['name']
);
} else {
@ -149,30 +151,23 @@ if (api_get_setting('allow_skills_tool') == 'true') {
'<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>';*/
$content .= Display::tag('ul', $lis, array('class' => 'list-badges'));
$social_skill_block = Display::panel($content, get_lang('Skills'),null,null,$extra);
$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'),
Display::url(get_lang('SkillsWheel'), api_get_path(WEB_CODE_PATH) . 'social/skills_wheel.php'),
get_lang('WithoutAchievedSkills')
);
/*$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>';*/
}
}
//Group box by age
/*$social_group_block = '<div class="panel panel-default social-group">';
$social_group_block .= '<div class="panel-heading">'.get_lang('Group').'</div>';
$social_group_block .= '<div class="panel-body">';*/
$results = GroupPortalManager::get_groups_by_age(1, false);

@ -27,32 +27,12 @@ $htmlHeadXtra[] = '<link href="'.api_get_path(WEB_LIBRARY_PATH).'javascript/tag
$tpl = new Template(null, false, false);
$load_user = api_get_user_id();
$userId = api_get_user_id();
$userInfo = api_get_user_info();
$skill = new Skill();
$ranking = $skill->get_user_skill_ranking($load_user);
$countSkill = count($skill->get_all());
$mySkills = $skill->get_user_skills($user_id, true);
$skill_condition = '';
if (isset($_GET['skill_id'])) {
$skill_condition = '&skill_id='.intval($_GET['skill_id']);
$tpl->assign('skill_id_to_load', $_GET['skill_id']);
}
$url = api_get_path(WEB_AJAX_PATH)."skill.ajax.php?a=get_skills_tree_json&load_user=$load_user";
$tpl->assign('wheel_url', $url);
$url = api_get_path(WEB_AJAX_PATH).'skill.ajax.php?1=1';
$tpl->assign('url', $url);
$tpl->assign('userInfo', $userInfo);
$tpl->assign('ranking', $ranking);
$tpl->assign('countSkill', $countSkill);
$tpl->assign('mySkills', $mySkills);
$ranking = $skill->get_user_skill_ranking($userId);
$skills = $skill->get_user_skills($userId, true);
$dialogForm = new FormValidator('form', 'post', null, null, ['id' => 'add_item']);
$dialogForm->addLabel(
@ -78,6 +58,16 @@ $dialogForm->addLabel(
$tpl->assign('dialogForm', $dialogForm->returnForm());
$url = api_get_path(WEB_AJAX_PATH)."skill.ajax.php?a=get_skills_tree_json&load_user=$userId";
$tpl->assign('wheel_url', $url);
$url = api_get_path(WEB_AJAX_PATH).'skill.ajax.php?1=1';
$tpl->assign('url', $url);
$tpl->assign('user_info', $userInfo);
$tpl->assign('ranking', $ranking);
$tpl->assign('skills', $mySkills);
$content = $tpl->fetch('default/skill/skill_wheel_student.tpl');
$tpl->assign('content', $content);
$tpl->display_no_layout_template();
$tpl->display_no_layout_template();

@ -111,7 +111,7 @@
</div>
<p class="openbadges-text">{{'BadgePreview' | get_lang }}</p>
<div class="openbadges-img {{ skill.icon ? '' : 'hide' }}" id="badge-container">
<img id="badge-preview" alt="{{ 'BadgePreview' | get_lang }}" src="{{ skill.icon ? [_p.web_upload, skill.icon] | join('') : '' }}">
<img id="badge-preview" alt="{{ 'BadgePreview' | get_lang }}" src="{{ skill.icon ? skill.web_icon_path : '' }}">
</div>
</div>
</div>

@ -33,7 +33,7 @@
{% if skill.icon is empty %}
<img src="{{ 'badges-default.png' | icon(128) }}" width="50" alt="{{ skill.name }}">
{% else %}
<img src="{{ [_p.web_upload, 'badges/', skill.icon] | join('') }}" width="50" alt="{{ skill.name }}">
<img src="{{ skill.web_icon_path }}" width="50" alt="{{ skill.name }}">
{% endif %}
{{ skill.name }}

@ -156,26 +156,28 @@ $(document).ready(function() {
<div class="row">
<div class="col-md-3 skill-options">
<div class="skill-home">
<a class="btn btn-large btn-block btn-success" href="{{ _p.web }}user_portal.php"><i class="fa fa-home"></i> {{ "ReturnToCourseList"|get_lang }}</a>
<a class="btn btn-large btn-block btn-success" href="{{ _p.web }}user_portal.php">
<i class="fa fa-home"></i> {{ "ReturnToCourseList"|get_lang }}</a>
</div>
<div class="skill-profile">
<div class="avatar">
<img width="100px" src="{{ userInfo.avatar }}" style="text-align: center">
<img width="100px" src="{{ user_info.avatar }}" style="text-align: center">
</div>
<div class="info-user">
<h4 class="title-skill">{{ userInfo.complete_name }}</h4>
<h4 class="title-skill">{{ user_info.complete_name }}</h4>
<p>
<a href="{{ _p.web_main }}social/skills_ranking.php" class="btn btn-default btn-block" target="_blank">{{ 'YourSkillRankingX' | get_lang | format(ranking) }}</a>
</p>
{% if mySkills is not empty %}
{%for skill in mySkills %}
{% if skill.iconThumb is empty %}
{% if skills is not empty %}
{% for skill in skills %}
{% if skill.icon is empty %}
<img src="{{ 'badges.png' | icon(32) }}" alt="{{ skill.name }}" title="{{ skill.name }}">
{% else %}
<img src="{{ _p.web_upload }}{{ skill.iconThumb }}" alt="{{ skill.name }}" title="{{ skill.name }}">
<img src="{{ skill.web_icon_thumb_path }}" alt="{{ skill.name }}" title="{{ skill.name }}">
{% endif %}
{% endfor %}
{% endif %}
{% for i in 1..(9 - ranking) %}
<img src="{{ 'badges-default.png' | icon(32) }}">
{% endfor %}
@ -249,8 +251,6 @@ $(document).ready(function() {
</div>
</div>
<!-- END ACCORDEON -->
</div>
<div id="wheel_container" class="col-md-9">
<div id="skill_wheel">
@ -274,7 +274,9 @@ $(document).ready(function() {
{{ dialogForm }}
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" data-dismiss="modal">{{ "Close" | get_lang }}</button>
<button type="button" class="btn btn-primary" data-dismiss="modal">
{{ "Close" | get_lang }}
</button>
</div>
</div>
</div>

Loading…
Cancel
Save