/** * Day view * * @param int $year * @param int $month * @param int $day */ public function day($year, $month, $day) { $this->tab_id = 'browse'; if (valid::date($year . '-' . $month . '-' . $day)) { $this->type = 'day'; $this->date->setDate($year, $month, $day); $this->page_title = text::title($this->date->format('j.n.Y')); $this->_build_calendar(); } }
/** * Tests the valid::date() function. * @dataProvider date_provider * @group core.helpers.valid.date * @test */ public function date($input_date, $expected_result) { $result = valid::date($input_date); $this->assertEquals($expected_result, $result); }
/** * Attempt to log in a user by using an ORM object and plain-text password. * * @param string username to log in * @param string password to check against * @param boolean enable auto-login * @return boolean */ public function login($user, $password, $remember = FALSE) { //get password field name from config $password_field = $this->config['password']; //$user and $password must set, ane they must be string type if (empty($password) or !is_string($password) or !is_string($user)) { return FALSE; } $user = new Auth_Users_Model(array('username' => $user, 'password' => $password)); //if there is no such user in database, quit if (!$user->check_id()) { return FALSE; } if (is_string($password)) { // Create a hashed password using the secrets from config $password = $this->hash($password); } // If user is active and the passwords match, perform a login if (intval($user->active) === 1 and $user->{$password_field} == $password) { //check if user has not expired if (valid::date($user->active_to)) { $now = date('Y-m-d H:i:s'); if ($user->active_to < $now) { return FALSE; } } if ($remember === TRUE) { // Create a new autologin token $token_model = new Auth_User_Tokens_Model(); // delete old user tokens $token_model->delete_user_tokens($user->id); // Set token data $token_model->user_id = $user->id; $token_model->expires = date('Y-m-d H:i:s', mktime(date('H'), date('i'), date('s') + $this->config['lifetime'], date('m'), date('d'), date('Y'))); //save token $token_model->save(); // Set the autologin cookie cookie::set($this->config['cookie_key'], $token_model->token, $this->config['lifetime']); } // Finish the login $this->complete_login($user); return TRUE; } // Login failed return FALSE; }