/** * * @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; }
private function removeLessonForums() { $lessonsForums = eF_getTableData("f_forums", "*", "lessons_ID=" . $this->lesson['id']); foreach ($lessonsForums as $value) { $forum = new f_forums($value); $forum->delete(); } }
} if (isset($_GET['topic']) && !in_array($_GET['topic'], $legalTopicValues)) { eF_redirect(basename($_SERVER['PHP_SELF']) . "?ctg=forum&message=" . urlencode(_UNPRIVILEGEDATTEMPT) . "&message_type=failure"); } if (isset($_GET['topic_id']) && !in_array($_GET['topic_id'], $legalTopicValues)) { eF_redirect(basename($_SERVER['PHP_SELF']) . "?ctg=forum&message=" . urlencode(_UNPRIVILEGEDATTEMPT) . "&message_type=failure"); } //Get forum configuration values $forum_config = eF_getTableDataFlat("f_configuration", "*"); sizeof($forum_config) > 0 ? $forum_config = array_combine($forum_config['name'], $forum_config['value']) : ($forum_config = array()); $smarty->assign("T_FORUM_CONFIG", $forum_config); $user_type = eF_getUserBasicType($_SESSION['s_login']); $smarty->assign("T_USER", $user_type); if ($_GET['type'] == 'forum' && isset($_GET['delete']) && in_array($_GET['delete'], $legalForumValues)) { try { $forum = new f_forums($_GET['delete']); $forum->delete(); } catch (Exception $e) { header("HTTP/1.0 500 "); echo rawurlencode($e->getMessage()) . ' (' . $e->getCode() . ')'; } exit; } else { if ($_GET['type'] == 'topic' && isset($_GET['delete']) && in_array($_GET['delete'], $legalTopicValues)) { try { $topic = new f_topics($_GET['delete']); $topic->delete(); } catch (Exception $e) { header("HTTP/1.0 500 "); echo rawurlencode($e->getMessage()) . ' (' . $e->getCode() . ')'; }