/** * * @param $forums * @return unknown_type */ public static function getForumTree($forums = false) { if ($forums === false) { $forums = f_forums::getAll("f_forums"); } $forumTree = array(); $tempForums = $forums; $count = 0; //Convert array to tree. At the end of the loop, the $forums array will hold the forum tree, where each node is an array of its child nodes while (sizeof($tempForums) > 0 && $count++ < 1000) { //$count is put here to prevent infinite loops $node = current($tempForums); //Get the key/node pairs of the first array element $key = key($tempForums); $parent_id = $node['parent_id']; $forumTree[$parent_id][] = $node['id']; //Append to the tree array, at the forum id index, the id of its child if (!isset($forumTree[$node['id']])) { $forumTree[$node['id']] = array(); } $forums[$node['id']] = $node; //Copy node to forums, which will be used later as forums source unset($tempForums[$key]); //We visited the node, so delete it from the (array) graph reset($tempForums); //Fixed issue in getForumTree()(#1354) } return $forumTree; }
} if (!$currentUser->coreAccess['forum'] || $currentUser->coreAccess['forum'] == 'change') { $_change_ = 1; } try { if ($_SESSION['s_type'] != 'administrator' && $_SESSION['s_current_branch']) { //this applies to supervisors only $currentBranch = new EfrontBranch($_SESSION['s_current_branch']); } if (!EfrontUser::isOptionVisible('forum')) { eF_redirect(basename($_SERVER['PHP_SELF']) . "?ctg=control_panel&message=" . urlencode(_UNAUTHORIZEDACCESS) . "&message_type=failure"); } $loadScripts[] = 'includes/forum'; $roles = EfrontUser::getRoles(true); $smarty->assign("T_USERROLES", $roles); $forums = f_forums::getAll("f_forums"); foreach ($forums as $value) { $forums_to_lessons[$value['lessons_ID']] = $value['id']; } $lessons = EFrontLesson::getLessons(false, true); $res = eF_getTableData("lessons", "id,options"); foreach ($res as $value) { $options = unserialize($value['options']); if (!empty($options) && !$options['forum']) { unset($forums[$forums_to_lessons[$value['id']]]); } } //pr($forums); if (!$_admin_) { $userLessons = $currentUser->getEligibleLessons(); foreach ($forums as $key => $value) {