function insert(array $p_aRecord) { if (!isset($p_aRecord['created'])) { $p_aRecord['created'] = time(); } return parent::insert($p_aRecord); }
function putRecord(array $aData) { $oConfig = PPI_Helper::getConfig(); // If its an insert if (!array_key_exists($this->_iTableIndex, $aData)) { $plainPass = $aData['password']; if (!array_key_exists($oConfig->system->usernameField, $aData)) { throw new PPI_Exception('Unable to locate username field when creating user'); } $aData['active'] = isset($oConfig->system->defaultUserActive) && $oConfig->system->defaultUserActive != false ? 1 : 0; $aData['created'] = time(); $aData['activation_code'] = base64_encode(time()); // ----- Password Stuff ---- if (isset($aData['salt'])) { $sSalt = $aData['salt']; unset($aData['salt']); // If no salt has been set then we get it from the config. } else { $sSalt = $oConfig->system->userAuthSalt; } if (empty($sSalt)) { throw new PPI_Exception('No salt found when trying to register user'); } $aData['password'] = $this->encryptPassword($sSalt, $aData['password']); // If no role_id has been set, lets set it from the config. if (!isset($aData['role_id'])) { if (!isset($oConfig->system->defaultUserRole)) { throw new PPI_Exception('Missing config value system.defaultUserRole'); } $aData['role_id'] = PPI_Model_Helper::getRoleIDFromName($oConfig->system->defaultUserRole); } } else { //if password is being passed in for re-set, we need to encrypt it if (isset($aData['password'], $aData['salt'])) { $aData['password'] = $this->encryptPassword($aData['salt'], $aData['password']); unset($aData[$oConfig->system->usernameField]); unset($aData['salt']); } } return parent::putRecord($aData); // set the system log here // send acitvation email here //$oEmail = new PPI_Model_Email(); /*$oEmail->setTemplate('User Registration', array( 'site_name' => $oConfig->site_name, 'username' => $aData[$oConfig->usernameField], 'password' => $plainPass ))->sendMail();*/ }
function __construct() { parent::__construct($this->_table, $this->_primary); }