door manager

This commit is contained in:
Schneider Roland
2022-05-04 19:41:18 +02:00
parent fb39d6599e
commit 946799a598
20 changed files with 8872 additions and 220 deletions

View File

@@ -26,7 +26,7 @@ class User extends ActiveRecord implements IdentityInterface
{
const STATUS_DELETED = 0;
const STATUS_ACTIVE = 10;
const ROLE_RECEPTION = 'receptionist';
/**
@@ -192,18 +192,18 @@ class User extends ActiveRecord implements IdentityInterface
{
$this->password_reset_token = null;
}
public function getUserAccountAssignments(){
return $this->hasMany(UserAccountAssignment::className(), ['id_user' =>'id']);
}
static function statuses() {
return [
self::STATUS_ACTIVE => Yii::t('app', 'Aktív'),
self::STATUS_DELETED => Yii::t('app', 'Inaktív'),
] ;
}
public function getStatusHuman(){
$result = null;
$s = self::statuses($this->status);
@@ -212,8 +212,8 @@ class User extends ActiveRecord implements IdentityInterface
}
return $result;
}
public function attributeLabels(){
return [
'status' => 'Státusz',
@@ -224,14 +224,14 @@ class User extends ActiveRecord implements IdentityInterface
'statusHuman' => Yii::t('backend/user', 'Status'),
];
}
/**
*
*
*
*
* @return \yii\rbac\Role[]*/
public function getRoles(){
$roles = \Yii::$app->authManager->getRolesByUser($this->id );
return $roles;
return $roles;
}
/**
@@ -239,28 +239,28 @@ class User extends ActiveRecord implements IdentityInterface
* */
public function getRoleString(){
$roles = \Yii::$app->authManager->getRolesByUser($this->id );
return implode(', ', array_map(function ($role) { return sprintf("%s", RoleDefinition::getRoleLabel($role->name)); }, $roles ));
}
/**
* $param int $forceIncludeAccount id warehouse, that should be included in list, even if it is inactive
* */
public static function read($forceIncludeObjectWithId = null){
$users = null;
$query = User::find();
if ( RoleDefinition::isReception()){
$query->andWhere(['id' => Yii::$app->user->id ]);
}
if ( $forceIncludeObjectWithId == null){
$users = $query->andWhere(['status' => User::STATUS_ACTIVE])->all();
}else{
$users = $query->andWhere( ['or', ['status' => User::STATUS_ACTIVE], ['id' => $forceIncludeObjectWithId ] ])->all();
}
return $users;
}
}