public function authenticate() { $login = $_REQUEST['login']; $password = md5($_REQUEST['password']); if ($login == '' || $password == '') { $user = new PEAR_Error('authentication_error_blank'); } else { $user = new Administrator(); $user->whereAdd("login = '******'"); $user->whereAdd("password = '******'"); $user->find(); if ($user->N != 1) { $user = new PEAR_Error('authentication_error_invalid'); } else { $user->fetch(); } } return $user; }
private function setAdministratorData() { if (isset($this->phkRequestData['administrator_id']) && !isset($this->phkRequestData['administrator_text'])) { App::import("Model", "Administrator"); $administrator = new Administrator(); $administrator->contain('Entity'); $result = $administrator->find("first", array('conditions' => array('Administrator.id' => $this->phkRequestData['administrator_id']))); $this->phkRequestData['administrator_id'] = $result['Administrator']['id']; $this->phkRequestData['administrator_text'] = $result['Entity']['name']; } }