aCfg = $aCfg; } if (is_null($oDb)) { $this->oDb = new DB_ConLite(); } else { // is it a contenido DB instance? if ($oDb instanceof DB_ConLite) { $this->oDb = $oDb; } else { throw new ConUserException("Given value for \$oDb is not a valid DB_ConLite instance!"); } } if (!is_null($sUserId)) { $bLoaded = $this->load($sUserId); if ($bLoaded == true) { $this->sUserId = $sUserId; } else { throw new ConUserException("No user with given user ID found!"); } } } // /** // * This method checks "the mask" of password $sNewPassword. If // * it matches the administrators rules iConUser::PASS_OK will be // * returned. // * // * In this abstract class, it always returns PASS_OK! // * // * @param string $sNewPassword // * @return int // * // * @see iConUser::checkPasswordMask() // */ // public static function checkPasswordMask($sNewPassword) { // return iConUser::PASS_OK; // } // /** // * Returns true if password $sNewPassword is strong enough. // * // * In this abstract class, it always returns true. // * // * @param string $sNewPassword // * @return int // * // * @see iConUser::checkPasswordStrength() // */ // public static function checkPasswordStrength($sNewPassword) { // return iConUser::PASS_OK; // } /** * Returns user id, currently set. * * @return string */ public function getUserId () { return $this->sUserId; } /** * Sets user ID. * * @param unknown_type $sUserId * * TODO check this */ public function setUserId ($sUserId) { $this->sUserId = $sUserId; } /** * Generates new user id based on current user name. * * @return string */ public function generateUserId () { $sResult = ""; $sCurUserName = $this->getUserName(); if (!empty($sCurUserName)) { $sResult = md5($sCurUserName); } else { throw new ConUserException("No user name set yet"); } $this->sUserId = $sResult; return $sResult; } /** * Returns user name, currently set * * @return string */ public function getUserName () { return $this->sUserName; } /** * Sets up new user name. * * @param string $sUserName */ public function setUserName ($sUserName) { $this->sUserName = $sUserName; } /** * Checks password which has to be set and return PASS_* values (i.e. * on success PASS_OK). * * @param string $sPassword * @return int */ public function setPassword ($sPassword) { $iResult = iConUser::PASS_OK; $iMaskResult = $this->checkPasswordMask($sPassword); if ($iMaskResult != iConUser::PASS_OK) { $iResult = $iMaskResult; } else { $iStrengthResult = $this->checkPasswordStrength($sPassword); if ($iStrengthResult != iConUser::PASS_OK) { $iResult = $iStrengthResult; } else { $this->sPassword = $sPassword; } } return $iResult; } /** * Returns (unencoded!) password. This method should never be public * available! * * @return string */ protected function getPassword () { return $this->sPassword; } } ?>