public static function isValidContext($contextDesc) { $db = Zend_Registry::get('my_db'); $context = new Contexts($db); $where = "lower(context_desc) = lower('{$contextDesc}')"; $result = $context->fetchAll($where); if ($result->count() > 0) { return true; } else { return false; } }
public static function checkContextExist($contextName) { $db = Zend_Registry::get('my_db'); $c = new Contexts($db); $quotedName = $db->quote($contextName); $result = $c->fetchAll("upper(context_desc) = upper({$quotedName})"); $rows = $result->count(); if ($rows == 0) { return false; } else { switch (DB_TYPE) { case 'mysql': $_SESSION['CONTEXT_ID'] = $result[0]->context_id; break; case 'oci8': $_SESSION['CONTEXT_ID'] = $result[0]->CONTEXT_ID; break; } return true; } }
<a href="<?php echo site_url('logout'); ?> "><?php echo lang('bf_action_logout'); ?> </a> </div> </div> </li> </ul> </div> </div> <?php echo Contexts::render_menu('text', 'normal'); ?> </div> <!-- END OF nav-collapse --> </div><!-- /container --> <div style="clearfix"></div> </div><!-- /topbar-inner --> </div><!-- /topbar --> <div class="subnav navbar-fixed-top" > <div class="container-fluid"> <?php if (isset($toolbar_title)) { ?>
/** * Return a list of the contexts specified for the application. * * @param boolean $landingPageFilter If true, only returns contexts which have * a landing page (index.php) available. * * @return array The context values array. */ function list_contexts($landingPageFilter = false) { // While limiting the number of files loaded is good, only the Contexts // library should be determining required and available contexts. if (!class_exists('Contexts', false)) { $ci =& get_instance(); $ci->load->library('ui/contexts'); } return Contexts::getContexts($landingPageFilter); }
/** * Build out the HTML for the menu. * * @param string $context The context to build the nav for. * @param boolean $ignore_ul If true, the list will be returned without being * placed into the template. * * @return string HTML for the sub menu. */ public static function build_sub_menu($context, $ignore_ul = false) { $search = array('{submenu_class}', '{url}', '{display}', '{child_class}', '{view}'); $list = ''; foreach (self::$menu as $topic_name => $topic) { if (count($topic) <= 1) { foreach ($topic as $module => $vals) { $list .= self::buildItem($module, $vals['title'], $vals['display_name'], $context, $vals['menu_view']); } } else { // If there is more than one item in the topic, build out a menu // based on the multiple items. $subMenu = ''; foreach ($topic as $module => $vals) { if (empty($vals['menu_view'])) { // If it has no sub-menu, add the item. $subMenu .= self::buildItem($module, $vals['title'], $vals['display_name'], $context, $vals['menu_view']); } else { // Otherwise, echo out the sub-menu only. To maintain backwards // compatility, strip out any <ul> tags. $subMenu .= str_ireplace(array('<ul>', '</ul>'), array('', ''), self::$ci->load->view($vals['menu_view'], null, true)); } } // Handle localization of the topic name, if needed. if (strpos($topic_name, 'lang:') === 0) { $topic_name = self::$ci->lang->line(str_replace('lang:', '', $topic_name)); } $list .= str_replace($search, array(self::$submenu_class, '#', ucwords($topic_name), self::$child_class, $subMenu), self::$templateSubMenu); } } self::$menu = array(); if ($ignore_ul) { return $list; } return str_replace(array('{class}', '{extra}', '{menu}'), array(self::$child_class, '', $list), self::$templateContextNav); }
/** * Edit a role record * * @return void */ public function edit() { $this->auth->restrict($this->permissionEdit); $id = (int) $this->uri->segment(5); if (empty($id)) { Template::set_message(lang('role_invalid_id'), 'error'); redirect(SITE_AREA . '/settings/roles'); } if (isset($_POST['save'])) { if ($this->saveRole('update', $id)) { Template::set_message(lang('role_edit_success'), 'success'); redirect(SITE_AREA . '/settings/roles'); } if (!empty($this->role_model->error)) { Template::set_message(lang('role_edit_error') . $this->role_model->error, 'error'); } } elseif (isset($_POST['delete'])) { if ($this->role_model->delete($id)) { Template::set_message(lang('role_delete_success'), 'success'); redirect(SITE_AREA . '/settings/roles'); } if (!empty($this->role_model->error)) { Template::set_message(lang('role_delete_error') . $this->role_model->error, 'error'); } } if (!class_exists('Contexts', false)) { $this->load->library('ui/contexts'); } $title = lang('bf_action_edit') . ' ' . lang('matrix_role'); $role = $this->role_model->find($id); Template::set_view('settings/role_form'); Template::set('contexts', Contexts::getContexts(true)); Template::set('role', $role); Template::set('toolbar_title', isset($role->role_name) ? "{$title}: {$role->role_name}" : $title); Template::render(); }
/** * Build out the HTML for the menu. * * @param string $context The context to build the nav for. * @param bool $ignore_ul * * @return string HTML for the sub menu */ public static function build_sub_menu($context, $ignore_ul = false) { $list = ''; $childClass = self::$child_class; $search = array('{submenu_class}', '{url}', '{display}', '{child_class}', '{view}'); foreach (self::$menu as $topic_name => $topic) { // If there is more than one item in the topic, we need to build out // a menu based on the multiple items. if (count($topic) > 1) { $subMenu = ''; foreach ($topic as $module => $vals) { // If it has no sub-menu, add it like normal if (empty($vals['menu_view'])) { $subMenu .= self::build_item($module, $vals['title'], $vals['display_name'], $context, $vals['menu_view']); } else { $view = self::$ci->load->view($vals['menu_view'], null, true); // To maintain backwards compatility, strip out any <ul> tags $subMenu .= str_ireplace(array('<ul>', '</ul>'), array('', ''), $view); } } // Handle localization of the topic name, if needed. if (strpos($topic_name, 'lang:') === 0) { $topic_name = lang(str_replace('lang:', '', $topic_name)); } $replace = array(self::$submenu_class, '#', ucwords($topic_name), $childClass, $subMenu); $list .= str_replace($search, $replace, self::$templateSubMenu); } else { foreach ($topic as $module => $vals) { $list .= self::build_item($module, $vals['title'], $vals['display_name'], $context, $vals['menu_view']); } } } self::$menu = array(); if ($ignore_ul) { return $list; } return str_replace(array('{class}', '{extra}', '{menu}'), array($childClass, '', $list), self::$templateContextNav); }
private function buildContexts($domElement, $dom) { $db = ZitDBAdapter::getDBAdapter(); $contexts = new Contexts($db); // $query = "select context_desc from context"; // $result = $db->fetchAll($query); $result = $contexts->fetchAll(); foreach ($result as $row) { $contextNode = $dom->createElement('SIF_Context'); switch (DB_TYPE) { case 'mysql': $contextNode->appendChild($dom->createTextNode($row->context_desc)); break; case 'oci8': $contextNode->appendChild($dom->createTextNode($row->CONTEXT_DESC)); break; } $domElement->appendChild($contextNode); } return $domElement; }
/** * Display the form which allows the user to create a context. * * @return void */ public function create_context() { // Form submittal? if (isset($_POST['build'])) { $this->form_validation->set_rules('context_name', 'lang:mb_context_name', 'required|trim|alpha_numeric'); if ($this->form_validation->run() !== false) { // Validated! $name = $this->input->post('context_name'); $for_roles = $this->input->post('roles'); $migrate = $this->input->post('migrate') == 'on'; // Try to save the context, using the UI/Context helper $this->load->library('ui/contexts'); if (Contexts::create_context($name, $for_roles, $migrate)) { Template::set_message(lang('mb_context_create_success'), 'success'); redirect(SITE_AREA . '/developer/builder'); } // Creating the context failed Template::set_message(lang('mb_context_create_error') . Contexts::errors(), 'error'); } } // Load roles for display in the form. $this->load->model('roles/role_model'); $this->role_model->select(array('role_id', 'role_name'))->where('deleted', 0); Template::set('roles', $this->role_model->find_all()); Template::set('toolbar_title', lang('mb_create_a_context')); Template::render(); }
echo site_url('logout'); ?> " style="float: right">Logout</a> <h1><?php e(settings_item('site.title')); ?> </h1> <div class="clearfix"></div> </div> <?php echo Contexts::render_menu('both', true); ?> </div><!-- /container --> <div class="clearfix"></div> <?php echo Contexts::render_mobile_navs(); ?> </div><!-- /topbar-inner --> </div><!-- /topbar --> <div id="nav-bar"> <div class="container"> <?php if (isset($toolbar_title)) { ?> <h1><?php echo $toolbar_title; ?> </h1> <?php } ?>
/** * Displays the create a context form. * * @access public * * @return void */ public function create_context() { // Load our roles for display in the form. $this->load->model('roles/role_model'); $roles = $this->role_model->select('role_id, role_name')->find_all(); Template::set('roles', $roles); // Form submittal? if ($this->input->post('submit')) { $this->form_validation->set_rules('context_name', 'Context Name', 'required|trim|alpha_numeric|xss_clean'); if ($this->form_validation->run() !== false) { /* Validated! */ $name = $this->input->post('context_name'); $for_roles = $this->input->post('roles'); $migrate = $this->input->post('migrate') == 'on' ? true : false; // Try to save the context, using the UI/Context helper $this->load->library('ui/contexts'); if (Contexts::create_context($name, $for_roles, $migrate)) { Template::set_message('Context succesfully created.', 'success'); redirect(SITE_AREA . '/developer/builder'); } else { Template::set_message('Error creating Context: ' . Contexts::errors(), 'error'); } } } Template::set('toolbar_title', lang('mb_create_a_context')); Template::render(); }
/** * Handles building out the HTML for the menu. * * @access public * @static * * @param string $context The context to build the nav for. * @param bool $ignore_ul * * @return string HTML for the sub menu */ public static function build_sub_menu($context, $ignore_ul = FALSE) { $list = ''; // Build a ul to return if (!$ignore_ul) { $list = "<ul class='" . self::$child_class . "'>\n"; } foreach (self::$menu as $topic_name => $topic) { // If the topic has other items, we're not closed. $closed = TRUE; // If there is more than one item in the topic, we need to build // out a menu based on the multiple items. if (count($topic) > 1) { $list .= '<li class="no-link parent-menu"><a href="#" class="no-link parent-menu">' . ucwords($topic_name) . '</a>'; $list .= '<ul>'; foreach ($topic as $module => $vals) { $class = $module == self::$ci->uri->segment(3) ? ' class="active"' : ''; // If it has a sub-menu, echo out that menu only… if (isset($vals['menu_view']) && !empty($vals['menu_view'])) { $view = self::$ci->load->view($vals['menu_view'], NULL, TRUE); // To maintain backwards compatility, strip out and <ul> tags $view = str_ireplace('<ul>', '', $view); $view = str_ireplace('</ul>', '', $view); $list .= $view; } else { $list .= self::build_item($module, $vals['title'], $vals['display_name'], $context, $vals['menu_view']); } } $list .= '</ul></li>'; } else { foreach ($topic as $module => $vals) { $list .= self::build_item($module, $vals['title'], $vals['display_name'], $context, $vals['menu_view']); } } //end if } //end foreach if (!$ignore_ul) { $list .= "</ul>\n"; } self::$menu = array(); return $list; }