Revert "Fix Skill Wheel that showing disabled skills - Refs #8370"

remotes/angel/1.11.x
José Loguercio 8 years ago committed by GitHub
parent 033bfd98b3
commit 6639d4f292
  1. 2
      main/inc/ajax/skill.ajax.php
  2. 25
      main/inc/lib/skill.lib.php

@ -140,7 +140,7 @@ switch ($action) {
$userId = isset($_REQUEST['load_user']) && $_REQUEST['load_user'] == 1 ? api_get_user_id() : 0;
$skill_id = isset($_REQUEST['skill_id']) ? intval($_REQUEST['skill_id']) : 0;
$depth = isset($_REQUEST['main_depth']) ? intval($_REQUEST['main_depth']) : 2;
$all = $skill->get_skills_tree_json($userId, $skill_id, false, $depth, true);
$all = $skill->get_skills_tree_json($userId, $skill_id, false, $depth);
echo $all;
break;
case 'get_user_skill':

@ -1089,30 +1089,20 @@ class Skill extends Model
* @param int skill id
* @param bool return a flat array or not
* @param int depth of the skills
* @param bool filter status
* @return json
*
*/
public function get_skills_tree_json($user_id = null, $skill_id = null, $return_flat_array = false, $main_depth = 2, $filter_status = false)
public function get_skills_tree_json($user_id = null, $skill_id = null, $return_flat_array = false, $main_depth = 2)
{
$tree = $this->get_skills_tree($user_id, $skill_id, $return_flat_array, true);
$simple_tree = array();
if (!empty($tree['children'])) {
foreach ($tree['children'] as $element) {
if ($filter_status) {
if (intval($element['status'])) {
$simple_tree[] = array(
'name' => $element['name'],
'children' => $this->get_skill_json($element['children'], 1, $main_depth, $filter_status)
);
}
} else {
$simple_tree[] = array(
'name' => $element['name'],
'children' => $this->get_skill_json($element['children'], 1, $main_depth)
);
}
}
}
return json_encode($simple_tree[0]['children']);
}
@ -1122,28 +1112,21 @@ class Skill extends Model
* @param array $subtree
* @param int $depth
* @param int $max_depth
* @param bool $filter_status
* @return array|null
*/
public function get_skill_json($subtree, $depth = 1, $max_depth = 2, $filter_status = false)
public function get_skill_json($subtree, $depth = 1, $max_depth = 2)
{
$simple_sub_tree = array();
if (is_array($subtree)) {
$counter = 1;
foreach ($subtree as $elem) {
if ($filter_status) {
if (!intval($elem['status'])) {
break 1;
}
}
$tmp = array();
$tmp['name'] = $elem['name'];
$tmp['id'] = $elem['id'];
$tmp['isSearched'] = self::isSearched($elem['id']);
if (isset($elem['children']) && is_array($elem['children'])) {
$tmp['children'] = $this->get_skill_json($elem['children'], $depth + 1, $max_depth, $filter_status);
$tmp['children'] = $this->get_skill_json($elem['children'], $depth + 1, $max_depth);
} else {
//$tmp['colour'] = $this->colours[$depth][rand(0,3)];
}

Loading…
Cancel
Save