00001 <?php
00002
00012 class AuthResetPassword extends AuthModelBase {
00014 public static $ATTRIBUTES = array(
00015 'userId' => array(
00016 'nullable' => false,
00017 'commit' => SModel2::COMMIT_CHANGED,
00018 'type' => 'int',
00019 'foreign' => array('table' => 'User', 'on' => 'id', 'object' => 'user')
00020 ),
00021 'hash' => array(
00022 'nullable' => false,
00023 'type' => 'string'
00024 ),
00025 'requestTime' => array(
00026 'commit' => SModel2::COMMIT_CHANGED,
00027 'type' => 'time',
00028 'default' => ''
00029 ),
00030 'user' => array(
00031 'commit' => SModel2::COMMIT_FOREIGN,
00032 'type' => 'AuthUser'
00033 )
00034 );
00035
00045 public function __construct($constraints = null, $multi = false) {
00046 parent::__construct();
00047
00048 $this->registerAttributes(self::$ATTRIBUTES);
00049 $this->registerTableName('ResetPassword');
00050 $this->registerPrimaryKey('userId');
00051
00052 if($constraints !== null)
00053 $this->populate($constraints, $multi);
00054 }
00055
00065 public static function getAttributesStatic() {
00066 return self::$ATTRIBUTES;
00067 }
00068
00074 public static function getTableNameStatic() {
00075 return 'ResetPassword';
00076 }
00077
00089 public static function retrieve($constraints = array(), $checkOnly = false) {
00090 $list = self::getList($constraints, array(1), array(), $checkOnly);
00091 if(!$list || count($list) == 0)
00092 return $checkOnly ? false : null;
00093 else if($checkOnly)
00094 return $list > 0;
00095 else
00096 return $list[0];
00097 }
00098
00107 public static function exists($constraints = array()) {
00108 return self::retrieve($constraints, true);
00109 }
00110
00123 public static function retrieveMulti($constraints = array(), $checkOnly = false, $depth = 1) {
00124 $list = self::getListMulti($constraints, array(1), array(), $checkOnly, $depth);
00125 if(!$list || count($list) == 0)
00126 return $checkOnly ? false : null;
00127 else if($checkOnly)
00128 return $list > 0;
00129 else
00130 return $list[0];
00131 }
00132
00141 public static function existsMulti($constraints = array()) {
00142 return self::retrieveMulti($constraints, true);
00143 }
00144
00158 public static function getList($constraints = array(), $limit = array(), $order = array(), $count = false) {
00159 return parent::getListBase(self::getDBI(), $constraints, $limit, $order, $count, 'AuthResetPassword', true);
00160 }
00161
00177 public static function getListMulti($constraints = array(), $limit = array(), $order = array(), $count = false, $depth = 1) {
00178 return parent::getListBaseMulti(self::getDBI(), $constraints, $limit, $order, $count,
00179 'AuthResetPassword', true, $depth);
00180 }
00181
00182
00191 public function getParentUser() {
00192 return AuthUser::retrieve(array('User.id' => $this->userId));
00193 }
00194
00204 public function getParentUserMulti($depth = 1) {
00205 return AuthUser::retrieveMulti(array('Base.id' => $this->userId), $depth);
00206 }
00207 }
00208
00209 ?>