diff --git a/sources/identify.php b/sources/identify.php index 46b697ef4..0b08a0781 100644 --- a/sources/identify.php +++ b/sources/identify.php @@ -675,6 +675,7 @@ function identifyUser($sentData) $_SESSION['list_restricted_folders_for_items'] = array(); $_SESSION['nb_folders'] = 1; $_SESSION['nb_roles'] = 0; + $_SESSION['fonction_id'] = 0; } // Get some more elements $_SESSION['screenHeight'] = $dataReceived['screenHeight']; diff --git a/sources/tree.php b/sources/tree.php index 4de30430a..9c5dce6f6 100644 --- a/sources/tree.php +++ b/sources/tree.php @@ -87,14 +87,14 @@ // build the tree to be displayed if (isset($_GET['id']) && is_numeric(intval($_GET['id'])) && isset($_SESSION['user_settings']['treeloadstrategy']) && $_SESSION['user_settings']['treeloadstrategy'] == "sequential") { - buildNodeTree($_GET['id']); + buildNodeTree($_GET['id']); } else if (isset($_SESSION['user_settings']['treeloadstrategy']) && $_SESSION['user_settings']['treeloadstrategy'] == "sequential") { - buildNodeTree(0); + buildNodeTree(0); } else { - $completTree = $tree->getTreeWithChildren(); - foreach ($completTree[0]->children as $child) { - $data = recursiveTree($child); - } + $completTree = $tree->getTreeWithChildren(); + foreach ($completTree[0]->children as $child) { + $data = recursiveTree($child); + } } /* @@ -102,10 +102,10 @@ */ function buildNodeTree($nodeId) { - global $ret_json, $listFoldersLimitedKeys, $listRestrictedFoldersForItemsKeys, $tree, $LANG; - - - // Be sure that user can only see folders he/she is allowed to + global $ret_json, $listFoldersLimitedKeys, $listRestrictedFoldersForItemsKeys, $tree, $LANG; + + + // Be sure that user can only see folders he/she is allowed to if ( !in_array($nodeId, $_SESSION['forbiden_pfs']) || in_array($nodeId, $_SESSION['groupes_visibles']) @@ -115,122 +115,122 @@ function buildNodeTree($nodeId) $displayThisNode = false; $hide_node = false; $nbChildrenItems = 0; - - // Check if any allowed folder is part of the descendants of this node - $nodeDescendants = $tree->getDescendants($nodeId, false, true, false); - foreach ($nodeDescendants as $node) { - $displayThisNode = false; - if ( - (!in_array($node->id, $_SESSION['forbiden_pfs']) - || in_array($node->id, $_SESSION['groupes_visibles']) - || in_array($node->id, $listFoldersLimitedKeys) - || in_array($node->id, $listRestrictedFoldersForItemsKeys)) && ( - in_array( - $node->id, - array_merge($_SESSION['groupes_visibles'], $_SESSION['list_restricted_folders_for_items']) - ) - || @in_array($node->id, $listFoldersLimitedKeys) - || @in_array($node->id, $listRestrictedFoldersForItemsKeys) - ) - ) { - $displayThisNode = true; - } - - if ($displayThisNode == true) { - $hide_node = $show_but_block = $eye_icon = false; - $text = $title = ""; - - // get info about current folder - DB::query( - "SELECT * FROM ".prefix_table("items")." - WHERE inactif=%i AND id_tree = %i", - 0, - $node->id - ); - $itemsNb = DB::count(); - - // get info about current folder - DB::query( - "SELECT * FROM ".prefix_table("nested_tree")." - WHERE parent_id = %i", - $node->id - ); - $childrenNb = DB::count(); - - // If personal Folder, convert id into user name - if ($node->title == $_SESSION['user_id'] && $node->nlevel == 1) { - $node->title = $_SESSION['login']; - } - - // if required, separate the json answer for each folder - if (!empty($ret_json)) $ret_json .= ", "; - - // prepare json return for current node - if ($node->parent_id==0) $parent = "#"; - else $parent = "li_".$node->parent_id; + + // Check if any allowed folder is part of the descendants of this node + $nodeDescendants = $tree->getDescendants($nodeId, false, true, false); + foreach ($nodeDescendants as $node) { + $displayThisNode = false; + if ( + (!in_array($node->id, $_SESSION['forbiden_pfs']) + || in_array($node->id, $_SESSION['groupes_visibles']) + || in_array($node->id, $listFoldersLimitedKeys) + || in_array($node->id, $listRestrictedFoldersForItemsKeys)) && ( + in_array( + $node->id, + array_merge($_SESSION['groupes_visibles'], $_SESSION['list_restricted_folders_for_items']) + ) + || @in_array($node->id, $listFoldersLimitedKeys) + || @in_array($node->id, $listRestrictedFoldersForItemsKeys) + ) + ) { + $displayThisNode = true; + } + + if ($displayThisNode == true) { + $hide_node = $show_but_block = $eye_icon = false; + $text = $title = ""; + + // get info about current folder + DB::query( + "SELECT * FROM ".prefix_table("items")." + WHERE inactif=%i AND id_tree = %i", + 0, + $node->id + ); + $itemsNb = DB::count(); + + // get info about current folder + DB::query( + "SELECT * FROM ".prefix_table("nested_tree")." + WHERE parent_id = %i", + $node->id + ); + $childrenNb = DB::count(); + + // If personal Folder, convert id into user name + if ($node->title == $_SESSION['user_id'] && $node->nlevel == 1) { + $node->title = $_SESSION['login']; + } + + // if required, separate the json answer for each folder + if (!empty($ret_json)) $ret_json .= ", "; + + // prepare json return for current node + if ($node->parent_id==0) $parent = "#"; + else $parent = "li_".$node->parent_id; - // special case for READ-ONLY folder - if ($_SESSION['user_read_only'] == true && !in_array($node->id, $_SESSION['personal_folders'])) { - $eye_icon = true; - $title = $LANG['read_only_account']; - } - $text .= str_replace("&", "&", $node->title); - $restricted = "0"; - $folderClass = "folder"; - - if (in_array($node->id, $_SESSION['groupes_visibles'])) { - if (in_array($node->id, $_SESSION['read_only_folders'])) { - $text = " ".$text; - $title = $LANG['read_only_account']; - $restricted = 1; - $folderClass = "folder_not_droppable"; - } - $text .= ' (id.'\'>'.$itemsNb.''; - // display tree counters - if (isset($_SESSION['settings']['tree_counters']) && $_SESSION['settings']['tree_counters'] == 1) { - $text .= '|'.$nbChildrenItems.'|'.(count($nodeDescendants)-1); - } - $text .= ')'; - } elseif (in_array($node->id, $listFoldersLimitedKeys)) { - $restricted = "1"; - $text .= ' (id.'">'.count($_SESSION['list_folders_limited'][$node->id]).''; - } elseif (in_array($node->id, $listRestrictedFoldersForItemsKeys)) { - $restricted = "1"; - $text .= ' (id.'">'.count($_SESSION['list_restricted_folders_for_items'][$node->id]).''; - } else { - $restricted = "1"; - $folderClass = "folder_not_droppable"; - if (isset($_SESSION['settings']['show_only_accessible_folders']) && $_SESSION['settings']['show_only_accessible_folders'] == 1) { - // folder is not visible - $hide_node = true; - } else { - // folder is visible but not accessible by user - $show_but_block = true; - } - } - - // json - if ($hide_node == false && $show_but_block == false) { - $ret_json .= '{'. - '"id":"li_'.$node->id.'"'. - ', "parent":"'.$parent.'"'. - ', "children":'. ($childrenNb == 0 ? "false" : "true"). - ', "text":"'. ($eye_icon == true ? " " : "") . $text.'"'. - ', "li_attr":{"class":"jstreeopen", "title":"ID ['.$node->id.'] '.$title.'"}'. - ', "a_attr":{"id":"fld_'.$node->id.'", "class":"'.$folderClass.'" , "onclick":"ListerItems(\''.$node->id.'\', \''.$restricted.'\', 0)"}'. - '}'; - } else if ($show_but_block == true) { - $ret_json .= '{'. - '"id":"li_'.$node->id.'"'. - ', "parent":"'.$parent.'"'. - ', "children":'. ($childrenNb == 0 ? "false" : "true"). - ', "text":" '.$text.'"'. - ', "li_attr":{"class":"", "title":"ID ['.$node->id.'] '.$LANG['no_access'].'"}'. - '}'; - } - } - } - } + // special case for READ-ONLY folder + if ($_SESSION['user_read_only'] == true && !in_array($node->id, $_SESSION['personal_folders'])) { + $eye_icon = true; + $title = $LANG['read_only_account']; + } + $text .= str_replace("&", "&", $node->title); + $restricted = "0"; + $folderClass = "folder"; + + if (in_array($node->id, $_SESSION['groupes_visibles'])) { + if (in_array($node->id, $_SESSION['read_only_folders'])) { + $text = " ".$text; + $title = $LANG['read_only_account']; + $restricted = 1; + $folderClass = "folder_not_droppable"; + } + $text .= ' (id.'\'>'.$itemsNb.''; + // display tree counters + if (isset($_SESSION['settings']['tree_counters']) && $_SESSION['settings']['tree_counters'] == 1) { + $text .= '|'.$nbChildrenItems.'|'.(count($nodeDescendants)-1); + } + $text .= ')'; + } elseif (in_array($node->id, $listFoldersLimitedKeys)) { + $restricted = "1"; + $text .= ' (id.'">'.count($_SESSION['list_folders_limited'][$node->id]).''; + } elseif (in_array($node->id, $listRestrictedFoldersForItemsKeys)) { + $restricted = "1"; + $text .= ' (id.'">'.count($_SESSION['list_restricted_folders_for_items'][$node->id]).''; + } else { + $restricted = "1"; + $folderClass = "folder_not_droppable"; + if (isset($_SESSION['settings']['show_only_accessible_folders']) && $_SESSION['settings']['show_only_accessible_folders'] == 1) { + // folder is not visible + $hide_node = true; + } else { + // folder is visible but not accessible by user + $show_but_block = true; + } + } + + // json + if ($hide_node == false && $show_but_block == false) { + $ret_json .= '{'. + '"id":"li_'.$node->id.'"'. + ', "parent":"'.$parent.'"'. + ', "children":'. ($childrenNb == 0 ? "false" : "true"). + ', "text":"'. ($eye_icon == true ? " " : "") . $text.'"'. + ', "li_attr":{"class":"jstreeopen", "title":"ID ['.$node->id.'] '.$title.'"}'. + ', "a_attr":{"id":"fld_'.$node->id.'", "class":"'.$folderClass.'" , "onclick":"ListerItems(\''.$node->id.'\', \''.$restricted.'\', 0)"}'. + '}'; + } else if ($show_but_block == true) { + $ret_json .= '{'. + '"id":"li_'.$node->id.'"'. + ', "parent":"'.$parent.'"'. + ', "children":'. ($childrenNb == 0 ? "false" : "true"). + ', "text":" '.$text.'"'. + ', "li_attr":{"class":"", "title":"ID ['.$node->id.'] '.$LANG['no_access'].'"}'. + '}'; + } + } + } + } } /* @@ -238,9 +238,9 @@ function buildNodeTree($nodeId) */ function recursiveTree($nodeId) { - global $completTree, $ret_json, $listFoldersLimitedKeys, $listRestrictedFoldersForItemsKeys, $tree, $LANG; - - // Be sure that user can only see folders he/she is allowed to + global $completTree, $ret_json, $listFoldersLimitedKeys, $listRestrictedFoldersForItemsKeys, $tree, $LANG; + + // Be sure that user can only see folders he/she is allowed to if ( !in_array($completTree[$nodeId]->id, $_SESSION['forbiden_pfs']) || in_array($completTree[$nodeId]->id, $_SESSION['groupes_visibles']) @@ -250,7 +250,7 @@ function recursiveTree($nodeId) $displayThisNode = false; $hide_node = false; $nbChildrenItems = 0; - + // Check if any allowed folder is part of the descendants of this node $nodeDescendants = $tree->getDescendants($completTree[$nodeId]->id, true, false, true); foreach ($nodeDescendants as $node) { @@ -277,91 +277,91 @@ function recursiveTree($nodeId) } if ($displayThisNode == true) { - $hide_node = $show_but_block = $eye_icon = false; - $text = $title = ""; - - // get info about current folder - DB::query( + $hide_node = $show_but_block = $eye_icon = false; + $text = $title = ""; + + // get info about current folder + DB::query( "SELECT * FROM ".prefix_table("items")." WHERE inactif=%i AND id_tree = %i", 0, $completTree[$nodeId]->id ); $itemsNb = DB::count(); - + // If personal Folder, convert id into user name if ($completTree[$nodeId]->title == $_SESSION['user_id'] && $completTree[$nodeId]->nlevel == 1) { $completTree[$nodeId]->title = $_SESSION['login']; } - - // if required, separate the json answer for each folder - if (!empty($ret_json)) $ret_json .= ", "; - - // prepare json return for current node - if ($completTree[$nodeId]->parent_id==0) $parent = "#"; - else $parent = "li_".$completTree[$nodeId]->parent_id; + + // if required, separate the json answer for each folder + if (!empty($ret_json)) $ret_json .= ", "; + + // prepare json return for current node + if ($completTree[$nodeId]->parent_id==0) $parent = "#"; + else $parent = "li_".$completTree[$nodeId]->parent_id; - // special case for READ-ONLY folder - if ($_SESSION['user_read_only'] == true && !in_array($completTree[$nodeId]->id, $_SESSION['personal_folders'])) { - $eye_icon = true; - $title = $LANG['read_only_account']; - } - $text .= str_replace("&", "&", $completTree[$nodeId]->title); - $restricted = "0"; - $folderClass = "folder"; - - if (in_array($completTree[$nodeId]->id, $_SESSION['groupes_visibles'])) { + // special case for READ-ONLY folder + if ($_SESSION['user_read_only'] == true && !in_array($completTree[$nodeId]->id, $_SESSION['personal_folders'])) { + $eye_icon = true; + $title = $LANG['read_only_account']; + } + $text .= str_replace("&", "&", $completTree[$nodeId]->title); + $restricted = "0"; + $folderClass = "folder"; + + if (in_array($completTree[$nodeId]->id, $_SESSION['groupes_visibles'])) { if (in_array($completTree[$nodeId]->id, $_SESSION['read_only_folders'])) { $text = " ".$text; - $title = $LANG['read_only_account']; + $title = $LANG['read_only_account']; $restricted = 1; $folderClass = "folder_not_droppable"; } - $text .= ' (id.'\'>'.$itemsNb.''; - // display tree counters + $text .= ' (id.'\'>'.$itemsNb.''; + // display tree counters if (isset($_SESSION['settings']['tree_counters']) && $_SESSION['settings']['tree_counters'] == 1) { $text .= '|'.$nbChildrenItems.'|'.(count($nodeDescendants)-1); } $text .= ')'; - } elseif (in_array($completTree[$nodeId]->id, $listFoldersLimitedKeys)) { - $restricted = "1"; - $text .= ' (id.'">'.count($_SESSION['list_folders_limited'][$completTree[$nodeId]->id]).''; + } elseif (in_array($completTree[$nodeId]->id, $listFoldersLimitedKeys)) { + $restricted = "1"; + $text .= ' (id.'">'.count($_SESSION['list_folders_limited'][$completTree[$nodeId]->id]).''; } elseif (in_array($completTree[$nodeId]->id, $listRestrictedFoldersForItemsKeys)) { - $restricted = "1"; - $text .= ' (id.'">'.count($_SESSION['list_restricted_folders_for_items'][$completTree[$nodeId]->id]).''; + $restricted = "1"; + $text .= ' (id.'">'.count($_SESSION['list_restricted_folders_for_items'][$completTree[$nodeId]->id]).''; } else { - $restricted = "1"; - $folderClass = "folder_not_droppable"; + $restricted = "1"; + $folderClass = "folder_not_droppable"; if (isset($_SESSION['settings']['show_only_accessible_folders']) && $_SESSION['settings']['show_only_accessible_folders'] == 1) { - // folder is not visible + // folder is not visible $hide_node = true; } else { - // folder is visible but not accessible by user - $show_but_block = true; - } + // folder is visible but not accessible by user + $show_but_block = true; + } } - - // json - if ($hide_node == false && $show_but_block == false) { - $ret_json .= '{'. - '"id":"li_'.$completTree[$nodeId]->id.'"'. - ', "parent":"'.$parent.'"'. - ', "text":"'. ($eye_icon == true ? " " : "") . $text.'"'. - ', "li_attr":{"class":"jstreeopen", "title":"ID ['.$completTree[$nodeId]->id.'] '.$title.'"}'. - ', "a_attr":{"id":"fld_'.$completTree[$nodeId]->id.'", "class":"'.$folderClass.'" , "onclick":"ListerItems(\''.$completTree[$nodeId]->id.'\', \''.$restricted.'\', 0)", "ondblclick":"LoadTreeNode(\''.$completTree[$nodeId]->id.'\')"}'. - '}'; - } else if ($show_but_block == true) { - $ret_json .= '{'. - '"id":"li_'.$completTree[$nodeId]->id.'"'. - ', "parent":"'.$parent.'"'. - ', "text":" '.$text.'"'. - ', "li_attr":{"class":"", "title":"ID ['.$completTree[$nodeId]->id.'] '.$LANG['no_access'].'"}'. - '}'; - } - foreach ($completTree[$nodeId]->children as $child) { - recursiveTree($child); - } - } - } + + // json + if ($hide_node == false && $show_but_block == false) { + $ret_json .= '{'. + '"id":"li_'.$completTree[$nodeId]->id.'"'. + ', "parent":"'.$parent.'"'. + ', "text":"'. ($eye_icon == true ? " " : "") . $text.'"'. + ', "li_attr":{"class":"jstreeopen", "title":"ID ['.$completTree[$nodeId]->id.'] '.$title.'"}'. + ', "a_attr":{"id":"fld_'.$completTree[$nodeId]->id.'", "class":"'.$folderClass.'" , "onclick":"ListerItems(\''.$completTree[$nodeId]->id.'\', \''.$restricted.'\', 0)", "ondblclick":"LoadTreeNode(\''.$completTree[$nodeId]->id.'\')"}'. + '}'; + } else if ($show_but_block == true) { + $ret_json .= '{'. + '"id":"li_'.$completTree[$nodeId]->id.'"'. + ', "parent":"'.$parent.'"'. + ', "text":" '.$text.'"'. + ', "li_attr":{"class":"", "title":"ID ['.$completTree[$nodeId]->id.'] '.$LANG['no_access'].'"}'. + '}'; + } + foreach ($completTree[$nodeId]->children as $child) { + recursiveTree($child); + } + } + } } echo '['.$ret_json.']'; \ No newline at end of file