00001 <?php
00002
00012 class AuthGenGroup extends AuthModelBase {
00014 public static $ATTRIBUTES = array(
00015 'id' => array(
00016 'nullable' => false,
00017 'commit' => SModel2::COMMIT_NEVER,
00018 'type' => 'int'
00019 ),
00020 'ldapGroupId' => array(
00021 'type' => 'int'
00022 ),
00023 'name' => array(
00024 'nullable' => false,
00025 'type' => 'string'
00026 )
00027 );
00028
00037 public function __construct($constraints = null) {
00038 parent::__construct();
00039
00040 $this->registerAttributes(self::$ATTRIBUTES);
00041 $this->registerTableName('GenGroup');
00042 $this->registerPrimaryKey('id', true);
00043
00044 if($constraints !== null)
00045 $this->populate($constraints);
00046 }
00047
00059 public static function retrieve($constraints = array(), $checkOnly = false) {
00060 $list = self::getList($constraints, array(1), array(), $checkOnly);
00061 if(!$list || count($list) == 0)
00062 return $checkOnly ? false : null;
00063 else if($checkOnly)
00064 return $list > 0;
00065 else
00066 return $list[0];
00067 }
00068
00077 public static function exists($constraints = array()) {
00078 return self::retrieve($constraints, true);
00079 }
00080
00094 public static function getList($constraints = array(), $limit = array(), $order = array(), $count = false) {
00095 return parent::getListBase(self::getDBI(), $constraints, $limit, $order, $count, 'AuthGenGroup', true);
00096 }
00097
00107 public static function getAttributesStatic() {
00108 return self::$ATTRIBUTES;
00109 }
00110
00116 public static function getTableNameStatic() {
00117 return 'GenGroup';
00118 }
00119
00120
00137 public function listGenGroupToPermissions($constraints = array(), $limit = array(), $order = array(), $count = false) {
00138 return parent::getListBase(self::getDBI(),
00139 array_merge($constraints, array('GenGroupToPermission.genGroupId' => $this->id)),
00140 $limit, $order, $count, 'AuthGenGroupToPermission', true);
00141 }
00142
00161 public function listGenGroupToPermissionsMulti($constraints = array(), $limit = array(), $order = array(), $count = false, $depth = 1) {
00162 return parent::getListBaseMulti(self::getDBI(),
00163 array_merge($constraints, array('Base.genGroupId' => $this->id)),
00164 $limit, $order, $count, 'AuthGenGroupToPermission', true, $depth);
00165 }
00166
00181 public function addGenGroupToPermission($permission) {
00182 $obj = new AuthGenGroupToPermission();
00183
00184 $obj->genGroupId = $this->id;
00185 if(is_object($permission))
00186 $obj->permission = $permission;
00187 else
00188 $obj->permissionId = $permission;
00189
00190 if(!$obj->commit())
00191 return null;
00192
00193 return $obj;
00194 }
00195
00212 public function listUserToGenGroups($constraints = array(), $limit = array(), $order = array(), $count = false) {
00213 return parent::getListBase(self::getDBI(),
00214 array_merge($constraints, array('UserToGenGroup.genGroupId' => $this->id)),
00215 $limit, $order, $count, 'AuthUserToGenGroup', true);
00216 }
00217
00236 public function listUserToGenGroupsMulti($constraints = array(), $limit = array(), $order = array(), $count = false, $depth = 1) {
00237 return parent::getListBaseMulti(self::getDBI(),
00238 array_merge($constraints, array('Base.genGroupId' => $this->id)),
00239 $limit, $order, $count, 'AuthUserToGenGroup', true, $depth);
00240 }
00241
00256 public function addUserToGenGroup($user) {
00257 $obj = new AuthUserToGenGroup();
00258
00259 if(is_object($user))
00260 $obj->user = $user;
00261 else
00262 $obj->userId = $user;
00263 $obj->genGroupId = $this->id;
00264
00265 if(!$obj->commit())
00266 return null;
00267
00268 return $obj;
00269 }
00270 }
00271
00272 ?>