'admin', 'plugin' => 'logs', 'controller' => 'logmanager', 'action' => 'index')); Router::connect('/admin/logs/list', array('prefix' => 'admin', 'plugin' => 'logs', 'controller' => 'logmanager', 'action' => 'list')); Router::connect('/admin/logs/getdata', array('prefix' => 'admin', 'plugin' => 'logs', 'controller' => 'logmanager', 'action' => 'getdata')); Router::connect('/logs/logmanager/admin_list/*', array('prefix' => 'admin', 'plugin' => 'logs', 'controller' => 'logmanager', 'action' => 'list')); ?> array( 'authorize' => array('Controller')) ); /** * To check if user is using mobile device or not * * @var array of components */ public $is_mobile = false; public $user_ip; /** * Validates if user has access or not, default false * * @return bool */ public function isAuthorized($user) { return false; } /** * Check if user has access or not for particular module according to role. * * @param User from Auth * @param Module name * @return bool */ function checkUserAccess($user, $module) { $this->loadModel("Modules.Module"); $hasAccess = $this->Module->getModuleForUser($user['role_id'], $module); if ($hasAccess > 0) { return true; } else { return false; } } /** * Function runs after before filter * Sets user id to var $user if user is logged in * * Sets is_mobile to true if user is from mobile device * * Get settings from model and set $javascript_code with contents * * Load calendar class and get days from Notices to highlight */ public function beforeFilter() { if ($this->Auth->User('id')) { $this->set('user', $this->Auth); } if ($this->RequestHandler->isMobile()) { $this->is_mobile = true; $this->set('is_mobile', true); } if (isset($_SERVER["HTTP_CF_CONNECTING_IP"])) { $this->user_ip = $_SERVER["HTTP_CF_CONNECTING_IP"]; } else $this->user_ip = $_SERVER['REMOTE_ADDR']; //load settings model $this->loadModel("Settings.Setting"); $settings = $this->Setting->findById('1'); $this->set('javascript_code', $settings['Setting']['javascript_code']); $this->Auth->allow(); } public function keywords() { $term = $_REQUEST['term']; $this->autoRender = false; $this->loadModel("Product"); $results = $this->Product->find('all', array ( "conditions" => array ( "OR" => array( "Product.name LIKE" => "%$term%", "Product.description LIKE" => "%$term%") ) )); $results2 = array(); foreach ($results as $product) { $results2[] = array('label' => $product['Product']['name']); } echo json_encode($results2); } /** * Get user id from Auth component * * @return int - User id */ public function getUserId() { return $this->Auth->User('id'); } public function isComputer() { if (!$this->RequestHandler->isMobile()) { $this->set('is_computer', true); } $this->autoRender = false; } public function isMobile() { if ($this->RequestHandler->isMobile()) { $this->set('is_mobile', true); } else $this->set('is_mobile', false); $this->autoRender = false; } /** * Before render - runs before anything else is laoded * * Check if website is online or not. * Cache all the data used for the Churches/Notices advanced search * Cache all pages for the menu * Cache all banners * */ public function beforeRender() { $this->loadModel("Category"); $this->set("categories", $this->Category->find('all', array('order' => array('name' => 'asc')))); $this->loadModel("Settings.Setting"); $settings = $this->Setting->findById('1'); //if website is offline if ($settings['Setting']['online'] == 0) { //if user is in admin area $isAdmin = strstr($this->params->url, 'admin'); //die if user is not in admin if (!$isAdmin) die("
Hello!


Thank you for visiting. I am currently undergoing my annual physical checkup.

Will be back soon.

Promise!!!!

Feel free to grab some coffee until this is sorted.
"); } //load all models to cache data $this->loadModel('Pages.Page'); $this->loadModel('Banner'); $banners = Cache::read('banners', 'longterm'); if (!$banners) { $banners = $this->Banner->find('all', array( 'fields' => array('Banner.id', 'Banner.image_path', 'Banner.url'), 'order' => array('Banner.id ASC') )); Cache::write('banners', $banners, 'longterm'); } $this->set('bannersFrontEnd', $banners); if (empty($this->params->url)) { $this->params->url = "home"; $page_url = "home"; } else { $pieces = explode("/", $this->params->url); if ($pieces[0] == "pages") $page_url = array_pop($pieces); else $page_url = $pieces[0]; } //get page title and keywords $currentPage = $this->Page->find('first', array( 'conditions' => array('Page.name' => $page_url), 'fields' => array('Page.id', 'Page.title', 'Page.keywords', 'Page.description') )); if ($currentPage) { if (isset($currentPage['Page']['title'])) $this->set('title_for_layout', $currentPage['Page']['title']); $this->set('meta_keywords', $currentPage['Page']['keywords']); if (isset($currentPage['Page']['description'])) $this->set('meta_description', $currentPage['Page']['description']); $this->set('page_id', $currentPage['Page']['id']); } $pagesForMenu = Cache::read('pagesForMenu', 'longterm'); if (!$pagesForMenu) { $pagesForMenu = $this->Page->find('all', array( 'conditions' => array('Page.showinmenu' => 1, 'online' => 1), 'order' => array('Page.menuorder ASC') )); Cache::write('pagesForMenu', $pagesForMenu, 'longterm'); } $this->set('pagesForMenu', $pagesForMenu); } }