/** * Get a single section and all his sub sections */ public function get_section_tree($id, RDResource $res, $number = 1, $text = false) { global $xoopsUser; $db = XoopsDatabaseFactory::getDatabaseConnection(); if (get_class($res) != 'RDResource') { return; } $sql = "SELECT * FROM " . $db->prefix("rd_sections") . " WHERE " . ($res->id() > 0 ? "id_res='" . $res->id() . "' AND" : '') . "\n id_sec='{$id}'"; $result = $db->query($sql); if ($db->getRowsNum($result) <= 0) { return; } $sec = new RDSection(); $row = $db->fetchArray($result); $sec->assignVars($row); $sections[0] = array('id' => $sec->id(), 'title' => $sec->getVar('title'), 'nameid' => $sec->getVar('nameid'), 'jump' => 0, 'link' => $sec->permalink(), 'order' => $sec->getVar('order'), 'author' => $sec->getVar('uid'), 'author_name' => $sec->getVar('uname'), 'created' => $sec->getVar('created'), 'modified' => $sec->getVar('modified'), 'number' => $number, 'comments' => $sec->getVar('comments'), 'edit' => !$xoopsUser ? 0 : ($xoopsUser->isAdmin() ? true : $res->isEditor($xoopsUser->uid())), 'resource' => $sec->getVar('id_res'), 'metas' => $sec->metas()); if ($text) { $sections[0]['content'] = $sec->getVar('content'); } self::sections_tree_index($sec->id(), 1, $res, '', $number, false, $sections, $text); return $sections; }