The CoreRecord class is used in conjunction with the models to store a single data record. It has basic get() and set() methods and can be extended for custom functionality. For example when setting a birthdate year, month and day from 3 separate dropdowns it could then combine them all into a single field.
require_once('php/core/CoreRecord.class.php');
class UserRecord extends CoreRecord {
public function set($strProperty, $mxdValue) {
$this->$strProperty = $mxdValue;
switch ($strProperty) {
case 'password_plaintext':
if ($mxdValue) {
$this->set('password', md5($mxdValue . AppConfig::get('PasswordSalt')));
}
break;
case 'birthdate':
if (preg_match('/([0-9]{4})-([0-9]{2})-([0-9]{2})/', $mxdValue, $arrMatches)) {
$this->birthdate_year = $arrMatches[1];
$this->birthdate_month = $arrMatches[2];
$this->birthdate_day = $arrMatches[3];
}
break;
case 'birthdate_year':
case 'birthdate_month':
case 'birthdate_day':
if (($intYear = $this->get('birthdate_year')) && ($intMonth = $this->get('birthdate_month')) && ($intDay = $this->get('birthdate_day'))) {
$this->birthdate = sprintf('%04d-%02d-%02d', $intYear, $intMonth, $intDay);
} else {
$this->birthdate = null;
}
break;
}
return $this->$strProperty;
}
}