Skip to content

Instantly share code, notes, and snippets.

@alfredwesterveld
Forked from shadowhand/user_model.php
Created March 11, 2009 09:04
Show Gist options
  • Save alfredwesterveld/77380 to your computer and use it in GitHub Desktop.
Save alfredwesterveld/77380 to your computer and use it in GitHub Desktop.
<?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