/** * @Decorated */ public function index() { $this->page_decorator->setPageMetaTag("description", "Home page"); $this->page_decorator->setPageMetaTag("keywords", "Home page"); $this->page_decorator->setPageMetaTag("author", "Trieu Nguyen"); $this->page_decorator->setPageTitle("Job Management System at DRD"); $this->load->helper('random_password'); $ran_pass = get_random_password(10, 12, TRUE, TRUE, FALSE); ApplicationHook::logInfo($ran_pass); $data = array(); $this->load->view("decorator/body", $data); }
/** * @Decorated */ public function index() { $this->page_decorator->setPageMetaTag("description", "Home page"); $this->page_decorator->setPageMetaTag("keywords", "Home page"); $this->page_decorator->setPageMetaTag("author", "Trieu Nguyen"); $this->page_decorator->setPageTitle("Job Management System at DRD"); $this->load->helper('random_password'); $ran_pass = get_random_password(10, 12, TRUE, TRUE, FALSE); //ApplicationHook::logInfo($ran_pass); $this->load->database(); $this->db->cache_on(); $query = $this->db->query("SELECT COUNT(id) as number FROM users"); $this->db->cache_off(); foreach ($query->result() as $row) { ApplicationHook::logInfo($row->number); } $data = array(); $this->load->view("decorator/body", $data); }
/** * Check role of user, if no authentication, redirect to Login Page * */ public function checkRole() { $this->setSiteLanguage(); if ($this->shouldApplyDecorator()) { $reflection = $this->getReflectedController(); $this->is_logged_in = $this->CI->redux_auth->logged_in(); if ($reflection != NULL) { if ($reflection->hasAnnotation('Secured')) { $actionURI = $this->controllerName . "/" . $this->controllerMethod; ApplicationHook::logInfo("-> CheckRole for " . $this->controllerName . "." . $this->controllerMethod); $annotation = $reflection->getAnnotation('Secured'); //var_dump(); //TODO if ($this->is_logged_in) { $profile = $this->CI->redux_auth->profile(); // echo '$profile->group: ' . $profile->group; // echo '<br> $annotation->role: ' . $annotation->role; // echo '<br>'; // echo 'strcasecmp($methodRole, $userRole): ' . strcasecmp($profile->group, $annotation->role); // exit; if (!$this->checkPermission($annotation->role, $profile->group)) { redirect(site_url('user_account/no_permission?user_role=' . $profile->group . '&require_role=' . $annotation->role . '&action_uri=' . $actionURI)); } } else { redirect(ApplicationHook::$LOGIN_URL . $this->controllerRequest); } } } } }
/** * Decorate the final view and response to client * */ public function decoratePage() { if ($this->isValidControllerRequest()) { $reflection = $this->getReflectedController(); if ($reflection != NULL) { if ($reflection->hasAnnotation('Decorated')) { ApplicationHook::logInfo("->Decorate page for " . $this->controllerName . "." . $this->controllerMethod); $this->setSiteLanguage(); $data = $this->processFinalViewData(); echo trim($this->CI->load->view("decorator/page_template", $data, TRUE)); return; } } } echo $this->CI->output->get_output(); $this->CI->benchmark->mark('code_end'); //ApplicationHook::logInfo("Rendering time: ".$this->CI->benchmark->elapsed_time('code_start', 'code_end')); }