forked from ZwiiCMS-Team/ZwiiCampus
protection des profils utilisés
This commit is contained in:
parent
06c2dfcc3f
commit
f2f291dbbc
@ -561,8 +561,19 @@ class user extends common
|
|||||||
*/
|
*/
|
||||||
public function profil()
|
public function profil()
|
||||||
{
|
{
|
||||||
foreach ($this->getData(['profil']) as $groupId => $groupData) {
|
|
||||||
|
|
||||||
|
// Ne pas supprimer un profil utililsé
|
||||||
|
// recherche les membres du groupe
|
||||||
|
$groups = helper::arrayColumn($this->getData(['user']), 'group');
|
||||||
|
$groups = array_keys($groups, $this->getUrl(2));
|
||||||
|
$profilUsed = true;
|
||||||
|
// Stoppe si le profil est affecté
|
||||||
|
foreach ($groups as $userId) {
|
||||||
|
if ((string) $this->getData(['user', $userId, 'profil']) === $this->getUrl(3)) {
|
||||||
|
$profilUsed= false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foreach ($this->getData(['profil']) as $groupId => $groupData) {
|
||||||
// Membres sans permissions spécifiques
|
// Membres sans permissions spécifiques
|
||||||
if (
|
if (
|
||||||
$groupId == self::GROUP_BANNED ||
|
$groupId == self::GROUP_BANNED ||
|
||||||
@ -605,7 +616,7 @@ class user extends common
|
|||||||
'href' => helper::baseUrl() . 'user/profilDelete/' . $groupId . '/' . $profilId,
|
'href' => helper::baseUrl() . 'user/profilDelete/' . $groupId . '/' . $profilId,
|
||||||
'value' => template::ico('trash'),
|
'value' => template::ico('trash'),
|
||||||
'help' => 'Supprimer',
|
'help' => 'Supprimer',
|
||||||
'disabled' => $profilData['permanent'],
|
'disabled' => $profilData['permanent'] && $profilUsed,
|
||||||
])
|
])
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@ -927,6 +938,17 @@ class user extends common
|
|||||||
|
|
||||||
public function profilDelete()
|
public function profilDelete()
|
||||||
{
|
{
|
||||||
|
// Ne pas supprimer un profil utililsé
|
||||||
|
// recherche les membres du groupe
|
||||||
|
$groups = helper::arrayColumn($this->getData(['user']), 'group');
|
||||||
|
$groups = array_keys($groups, $this->getUrl(2));
|
||||||
|
$flag= true;
|
||||||
|
// Stoppe si le profil est affecté
|
||||||
|
foreach ($groups as $userId) {
|
||||||
|
if ((string) $this->getData(['user', $userId, 'profil']) === $this->getUrl(3)) {
|
||||||
|
$flag= false;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (
|
if (
|
||||||
$this->getUser('permission', __CLASS__, __FUNCTION__) !== true ||
|
$this->getUser('permission', __CLASS__, __FUNCTION__) !== true ||
|
||||||
$this->getData(['profil', $this->getUrl(2), $this->getUrl(3)]) === null ||
|
$this->getData(['profil', $this->getUrl(2), $this->getUrl(3)]) === null ||
|
||||||
@ -938,12 +960,15 @@ class user extends common
|
|||||||
]);
|
]);
|
||||||
// Suppression
|
// Suppression
|
||||||
} else {
|
} else {
|
||||||
|
if ($flag) {
|
||||||
$this->deleteData(['profil', $this->getUrl(2), $this->getUrl(3)]);
|
$this->deleteData(['profil', $this->getUrl(2), $this->getUrl(3)]);
|
||||||
|
}
|
||||||
|
|
||||||
// Valeurs en sortie
|
// Valeurs en sortie
|
||||||
$this->addOutput([
|
$this->addOutput([
|
||||||
'redirect' => helper::baseUrl() . $this->getUrl(0) . '/profil',
|
'redirect' => helper::baseUrl() . $this->getUrl(0) . '/profil',
|
||||||
'notification' => helper::translate('Profil supprimé'),
|
'notification' => $flag ? helper::translate('Profil supprimé') : helper::translate('Action interdite'),
|
||||||
'state' => true
|
'state' => $flag
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user