public static function getMenuAdmin() { echo '</pre>'; $menu = new menuModel(self::$doctrineService); echo '<pre>'; print_r($menu->findAll()); echo '</pre>'; }
public function getPages($menu_id) { if (empty(self::$conn)) { self::$conn = $this->connect_pdo(); } $sql = "SELECT p.id,p.name,p.des,p.image_icon,p.des,p.time_on,CONCAT_WS(' ',first_name,last_name) AS user_name,p.author_id\n\t\t\t\t\tFROM pages AS p \n\t\t\t\t\tLEFT JOIN page_menu AS pmn\n\t\t\t\t\t\tON p.id=pmn.page_id \n\t\t\t\t\tLEFT JOIN users AS u\n\t\t\t\t\t\tON u.id=p.author_id\n\t\t\t\t\tWHERE pmn.menu_id =?"; $stmt = self::$conn->prepare($sql); $stmt->bindParam(1, $menu_id); $stmt->execute(); $stmt->setFetchMode(PDO::FETCH_ASSOC); $i = 0; $pages = array(array()); while ($row = $stmt->fetch()) { $pages[$i++] = $row; } $i--; return $pages; }
public function delete($id) { // Connect to database ... if (empty(self::$conn)) { self::$conn = $this->connect_pdo(); } $stmt = self::$conn->prepare('DELETE FROM menu WHERE id=?'); $stmt->bindParam(1, $id); if ($stmt->execute()) { return true; } else { return false; } }
public function geramenu() { $objMenu = new menuModel(); //die_a($_SESSION['user']['controllers_autorizados']); $retorno = $objMenu->getMenuByUsurio($_SESSION['user']['controllers_autorizados']); $menu_pai = null; foreach ($retorno as $key => $value) { if ($value['tipo'] == 1) { $menu_pai[] = array('id' => $value['id_menu'], 'descricao' => $value['descricao'], 'link' => $value['url']); } } $menu_filho = null; foreach ($retorno as $key => $value1) { if ($value1['parent_menu'] != 0) { $menu_filho[] = array('id_pai' => $value1['parent_menu'], 'descricao' => $value1['descricao'], 'link' => $value1['url']); } } $menu_principal = null; foreach ($menu_pai as $key => $value) { $menu_principal[] = array('id' => $value['id'], 'id_pai' => 0, 'id_filho' => 0, 'descricao' => $value['descricao'], 'link' => $value['link']); if (isset($menu_filho)) { foreach ($menu_filho as $key1 => $value1) { if ($value['id'] == $value1['id_pai']) { $menu_principal[$key]['filhos'][] = array('id' => $key1, 'id_pai' => $value1['id_pai'], 'id_filho' => 0, 'descricao' => $value1['descricao'], 'link' => $value1['link']); } } } } $this->smarty->assign('dados_menu', $menu_principal); $_SESSION['user']['menu_sidebar'] = $this->smarty->fetch('comuns/sidebar_dinamico.tpl'); $menu = $_SESSION['user']['menu_sidebar']; return $menu; }