* Copyright (c) 2006, Cake Software Foundation, Inc. * 1785 E. Sahara Avenue, Suite 490-204 * Las Vegas, Nevada 89104 * * Licensed under The MIT License * Redistributions of files must retain the above copyright notice. * * @filesource * @copyright Copyright (c) 2006, Cake Software Foundation, Inc. * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project * @package cake * @subpackage cake.app * @since CakePHP v 0.2.9 * @version $Revision: 2958 $ * @modifiedby $LastChangedBy: phpnut $ * @lastmodified $Date: 2006-05-26 00:29:17 -0500 (Fri, 26 May 2006) $ * @license http://www.opensource.org/licenses/mit-license.php The MIT License */ /** * Short description for class. * * Add your application-wide methods in the class below, your controllers * will inherit them. * * @package cake * @subpackage cake.app */ class AppController extends Controller { var $beforeFilter = array('checkAdmin', 'checkLogin'); var $helpers = array('Html','Javascript'); //var $helpers = array('Html','Javascript','Head'); var $components = array('Auth'); // Removed Security component include because it was going to blank page on form submits with habtm multiple checkboxes var $uses = array("User", "Consultant"); function beforeFilter(){ $this->checkAdmin(); $this->checkLogin(); $this->set('Auth', $this->Auth); $this->set('User', $this->User); $this->set('Controller', $this); } /** * checkAdmin() - check for admin area access */ function checkAdmin() { //vendor('dumpr'); // check beginning of action name to determine if it's an admin request if (substr($this->action, 0, 6) == 'admin_') { // if so set a flag and change the layout $this->set('is_admin_request', true); $this->layout = 'admin'; if (!$this->Auth->check_authenticated(null, "Employee")) { $this->redirect('/admin_login'); exit(); } else { $this->set('authenticated', true); $this->set('admin', true); } } } /** * checkLogin() - check for login */ function checkLogin() { //vendor('dumpr'); // if so set a flag and change the layout //$this->set('is_admin_request', true); if ($this->Auth->check_authenticated(null, "User")) { $this->set('authenticated', true); return true; echo "yes"; }else{ return false; echo "no"; } } function encryptEmail($email, $at = "[[at]]", $spoof = false) { $value = ""; $amp = "@"; $pre = ""; for ($i = 0; $i < strlen($email); $i++) { $letter = substr($email, $i, 1); if ($letter == "@") { $pre = $value; $value = ""; } else { $value .= "" . ord($letter) . ";"; } } $suf = $value; // Return the encrypted email $encrypted = ($spoof) ? $pre.$at.$suf : $pre.$amp.$suf; return $encrypted; } function _message($message, $url = false, $value = false, $error = false) { if ($value) { $message = sprintf($message, '' . $value . ''); } if ($error) { $message = '
'; } else { $message = ''; } $this->Session->setFlash($message, ''); if ($url) { $this->redirect($url); } } function habtm_array($array){ $selected = array(); foreach($array AS $arr) { $selected[$arr["id"]] = $arr["name"]; } return $selected; } function get_states(){ return array( 'AL' => 'AL', 'AK' => 'AK', 'AZ' => 'AZ', 'AR' => 'AR', 'CA' => 'CA', 'CO' => 'CO', 'CT' => 'CT', 'DE' => 'DE', 'DC' => 'DC', 'FL' => 'FL', 'GA' => 'GA', 'HI' => 'HI', 'ID' => 'ID', 'IL' => 'IL', 'IN' => 'IN', 'IA' => 'IA', 'KS' => 'KS', 'KY' => 'KY', 'LA' => 'LA', 'ME' => 'ME', 'MD' => 'MD', 'MA' => 'MA', 'MI' => 'MI', 'MN' => 'MN', 'MS' => 'MS', 'MO' => 'MO', 'MT' => 'MT', 'NE' => 'NE', 'NV' => 'NV', 'NH' => 'NH', 'NJ' => 'NJ', 'NM' => 'NM', 'NY' => 'NY', 'NC' => 'NC', 'ND' => 'ND', 'OH' => 'OH', 'OK' => 'OK', 'OR' => 'OR', 'PA' => 'PA', 'RI' => 'RI', 'SC' => 'SC', 'SD' => 'SD', 'TN' => 'TN', 'TX' => 'TX', 'UT' => 'UT', 'VT' => 'VT', 'VA' => 'VA', 'WA' => 'WA', 'WV' => 'WV', 'WI' => 'WI', 'WY' => 'WY' ); } } ?>