00001 <?php
00002
00012 class AuthHashType extends AuthModelBase {
00014 public static $ATTRIBUTES = array(
00015 'id' => array(
00016 'nullable' => false,
00017 'commit' => SModel2::COMMIT_NEVER,
00018 'type' => 'int'
00019 ),
00020 'name' => array(
00021 'nullable' => false,
00022 'type' => 'string'
00023 )
00024 );
00025
00034 public function __construct($constraints = null) {
00035 parent::__construct();
00036
00037 $this->registerAttributes(self::$ATTRIBUTES);
00038 $this->registerTableName('HashType');
00039 $this->registerPrimaryKey('id', true);
00040
00041 if($constraints !== null)
00042 $this->populate($constraints);
00043 }
00044
00056 public static function retrieve($constraints = array(), $checkOnly = false) {
00057 $list = self::getList($constraints, array(1), array(), $checkOnly);
00058 if(!$list || count($list) == 0)
00059 return $checkOnly ? false : null;
00060 else if($checkOnly)
00061 return $list > 0;
00062 else
00063 return $list[0];
00064 }
00065
00074 public static function exists($constraints = array()) {
00075 return self::retrieve($constraints, true);
00076 }
00077
00091 public static function getList($constraints = array(), $limit = array(), $order = array(), $count = false) {
00092 return parent::getListBase(self::getDBI(), $constraints, $limit, $order, $count, 'AuthHashType', true);
00093 }
00094
00104 public static function getAttributesStatic() {
00105 return self::$ATTRIBUTES;
00106 }
00107
00113 public static function getTableNameStatic() {
00114 return 'HashType';
00115 }
00116
00117
00134 public function listUsers($constraints = array(), $limit = array(), $order = array(), $count = false) {
00135 return parent::getListBase(self::getDBI(),
00136 array_merge($constraints, array('User.hashTypeId' => $this->id)),
00137 $limit, $order, $count, 'AuthUser', true);
00138 }
00139
00158 public function listUsersMulti($constraints = array(), $limit = array(), $order = array(), $count = false, $depth = 1) {
00159 return parent::getListBaseMulti(self::getDBI(),
00160 array_merge($constraints, array('Base.hashTypeId' => $this->id)),
00161 $limit, $order, $count, 'AuthUser', true, $depth);
00162 }
00163
00185 public function addUser($salt, $password, $username, $firstName, $lastName, $email, $ldapUserId = '', $emailConfirmed = 'false;') {
00186 $obj = new AuthUser();
00187
00188 if($ldapUserId != '')
00189 $obj->ldapUserId = $ldapUserId;
00190 $obj->salt = $salt;
00191 $obj->password = $password;
00192 $obj->username = $username;
00193 $obj->hashTypeId = $this->id;
00194 $obj->firstName = $firstName;
00195 $obj->lastName = $lastName;
00196 $obj->email = $email;
00197 $obj->emailConfirmed = $emailConfirmed;
00198
00199 if(!$obj->commit())
00200 return null;
00201
00202 return $obj;
00203 }
00204 }
00205
00206 ?>