-
-
Save alfredwesterveld/77380 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php defined('SYSPATH') or die('No direct script access.'); | |
class User_Model extends ORM { | |
protected $ignored_columns = array('birthday_day', 'birthday_month', 'birthday_year'); | |
public function validate(array & $array, $save = FALSE) | |
{ | |
$array = Validation::factory($array) | |
->pre_filter('trim') | |
->add_rules('username', 'required', 'chars[a-z_.]') | |
->add_rules('password', 'required', 'length[5,127]') | |
->add_rules('birthday_day', 'required', 'digit') | |
->add_rules('birthday_month', 'required', 'digit') | |
->add_rules('birthday_year', 'required', 'digit'); | |
->add_callbacks('birthday_year', array($this, 'check_birthday')); | |
return parent::validate($array, $save); | |
} | |
public function check_birthday(Validation $array, $field) | |
{ | |
if (isset($array['birthday_day']) AND isset($array['birthday_month']) AND isset($array['birthday_year'])) | |
{ | |
// Create the birthday as a UNIX timestamp | |
$this->birthday = mktime(0, 0, 0, $array['birthday_month'], $array['birthday_month'], $array['birthday_year']); | |
} | |
} | |
} // End User |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment