/** * Returns the front controller instance * * @return Redokes_Controller_Front */ public static function getInstance() { if (!isset(self::$_instance)) { $c = __CLASS__; self::$_instance = new $c; } return self::$_instance; }
public function _forward($module, $controller, $action){ echo "forward in main action controller"; die(); return; $this->frontController->module = $module; $this->frontController->controller = $controller; $this->frontController->action = $action; $this->frontController->run(); }
public function setDefault() { $db = Redokes_Controller_Front::getInstance()->getDbAdapter(); $data = array('isDefault' => 0); $db->update($this->table, $data, 'isDefault = 1'); $this->row->isDefault = 1; $this->process(); }
public function getTrackHtmlAction() { $track = new Navigation_Model_Track(getParam('trackId', 0)); $format = getParam('format', 'html'); $urlField = 'url'; if ($_POST['urlField'] == 'editUrl') { $urlField = 'editUrl'; } $navId = Redokes_Controller_Front::getInstance()->getParam('navId', 'defaultNav'); $navClass = Redokes_Controller_Front::getInstance()->getParam('navClass', 'defaultNav'); if ($track->row['trackId']) { if ($format == 'html') { $this->setParam('html', $track->getHtml($navId, $navClass, 0, $urlField)); } else if ($format == 'json') { $this->setParam('json', $track->getJson(0, $urlField)); } } }
define('MODULE_PATH', PUBLIC_PATH . 'modules/'); define('LIBRARY_PATH', ROOT_PATH . 'lib/'); define('CACHE_PATH', ROOT_PATH . 'cache/'); //Set the include path set_include_path(get_include_path() . PATH_SEPARATOR . LIBRARY_PATH); function __autoload($name) { $parts = explode('_', $name); $num = count($parts) - 1; $upperFile = implode('/', $parts). '.php'; for ($i = 0; $i < $num; $i++) { $parts[$i] = strtolower($parts[$i]); } $lowerFile = implode('/', $parts) . '.php'; if (is_file(LIBRARY_PATH . $upperFile)) { include_once LIBRARY_PATH . $upperFile; } else if (is_file(MODULE_PATH . $lowerFile)) { include_once MODULE_PATH . $lowerFile; } } function show_array($array) { echo '<pre>'; print_r($array); echo '</pre>'; } $frontController = Redokes_Controller_Front::getInstance(); $frontController->run();
public function validate() { // make sure email is unique $query = "SELECT COUNT(*) total FROM user WHERE email = '{$this->row->email}' AND userId <> '{$this->row->userId}'"; $row = $this->table->fetchRow($query); if ($row['total']) { $this->addError("Please choose a different email address. Email is already in use"); } // if (!valid_email($this->row['email'])) { // $this->addError("Please enter a valid email address"); // } if (strlen($this->row->password) < 5) { $this->addError("Password must be 5 characters or longer"); } $confirmPassword = Redokes_Controller_Front::getInstance()->getParam('confirmPassword'); if ($this->row->password != $confirmPassword) { $this->addError("Passwords don't match. Please confirm your password."); } parent::validate(); return $this->errors; // don't let a non papercut user edit a papercut user // if ($this->row['userId']) { // // // check if edited user has papercut access // if (User_Class_User::hasAccess('papercut', 0, $this->row['userId'])) { // // // check if the user doing the editing has papercut access // if (!User_Class_User::hasAccess('papercut')) { // $this->addError('You do not have access to edit a Papercut user account'); // } // } // } // make sure email is unique $query = "SELECT COUNT(*) total FROM user WHERE email = '{$this->row['email']}' AND userId <> '{$this->row['userId']}'"; $rows = $db->fetchAll($query); $numRows = count($rows); if ($numRows) { if ($rows[0]['total']) { $this->addError("Please choose a different email address. Email is already in use"); } } // check length if (!valid_email($this->row['email'])) { $this->addError("Please enter a valid email address"); } if (!$this->row['userId']) { // make sure passwords match if ($this->row['password'] != $this->cpassword) { $this->addError("Please retype your password."); } if (strlen($this->row['password']) < 5) { $this->addError("Password must be atleast 5 characters."); } } // clean access ids $accessIds = array(); for ($i = 0; $i < count($this->accessIds); $i++) { if (intval($this->accessIds[$i])) { $accessIds[] = intval($this->accessIds[$i]); } } $this->accessIds = $accessIds; // clean group ids $groupIds = array(); for ($i = 0; $i < count($this->groupIds); $i++) { if (intval($this->groupIds[$i])) { $groupIds[] = intval($this->groupIds[$i]); } } $this->groupIds = $groupIds; return $this->errors; }