mirror of
https://github.com/nuxsmin/sysPass.git
synced 2026-03-06 08:34:16 +01:00
* [ADD] Closes #81. Accounts main group can be changed by admins. Thanks to @cfinch
This commit is contained in:
@@ -58,11 +58,11 @@ $accountNotes = SP\Request::analyze('notes');
|
||||
$accountUrl = SP\Request::analyze('url');
|
||||
$accountGroupEditEnabled = SP\Request::analyze('geditenabled', 0, false, 1);
|
||||
$accountUserEditEnabled = SP\Request::analyze('ueditenabled', 0, false, 1);
|
||||
$accountMainGroupId = SP\Request::analyze('mainGroupId', SP\Session::getUserGroupId());
|
||||
$accountChangesHash = SP\Request::analyze('hash');
|
||||
|
||||
// Datos del Usuario
|
||||
$currentUserId = SP\Session::getUserId();
|
||||
$currentGroupId = SP\Session::getUserGroupId();
|
||||
|
||||
if ($actionId === \SP\Controller\ActionsInterface::ACTION_ACC_NEW) {
|
||||
// Comprobaciones para nueva cuenta
|
||||
@@ -148,7 +148,7 @@ switch ($actionId) {
|
||||
$account->setAccountIV($accounEncPassIV);
|
||||
$account->setAccountNotes($accountNotes);
|
||||
$account->setAccountUserId($currentUserId);
|
||||
$account->setAccountUserGroupId($currentGroupId);
|
||||
$account->setAccountUserGroupId($accountMainGroupId);
|
||||
$account->setAccountUsersId($accountOtherUsers);
|
||||
$account->setAccountUserGroupsId($accountOtherGroups);
|
||||
$account->setAccountOtherUserEdit($accountUserEditEnabled);
|
||||
@@ -187,6 +187,10 @@ switch ($actionId) {
|
||||
$account->setAccountOtherUserEdit($accountUserEditEnabled);
|
||||
$account->setAccountOtherGroupEdit($accountGroupEditEnabled);
|
||||
|
||||
// Cambiar el grupo principal si el usuario es Admin
|
||||
if (SP\Session::getUserIsAdminApp() || SP\Session::getUserIsAdminAcc()) {
|
||||
$account->setAccountUserGroupId($accountMainGroupId);
|
||||
}
|
||||
|
||||
// Comprobar si han habido cambios
|
||||
if ($accountChangesHash == $account->calcChangesHash()) {
|
||||
|
||||
@@ -136,6 +136,7 @@ class Account extends AccountBase implements AccountInterface
|
||||
. 'account_url = :accountUrl,'
|
||||
. 'account_notes = :accountNotes,'
|
||||
. 'account_userEditId = :accountUserEditId,'
|
||||
. 'account_userGroupId = :accountUserGroupId,'
|
||||
. 'account_dateEdit = NOW(),'
|
||||
. 'account_otherUserEdit = :accountOtherUserEdit,'
|
||||
. 'account_otherGroupEdit = :accountOtherGroupEdit '
|
||||
@@ -148,6 +149,7 @@ class Account extends AccountBase implements AccountInterface
|
||||
$data['accountUrl'] = $this->getAccountUrl();
|
||||
$data['accountNotes'] = $this->getAccountNotes();
|
||||
$data['accountUserEditId'] = $this->getAccountUserEditId();
|
||||
$data['accountUserGroupId'] = ($this->getAccountUserGroupId()) ? $this->getAccountUserGroupId() : 'account_userGroupId';
|
||||
$data['accountOtherUserEdit'] = intval($this->getAccountOtherUserEdit());
|
||||
$data['accountOtherGroupEdit'] = intval($this->getAccountOtherGroupEdit());
|
||||
$data['accountId'] = $this->getAccountId();
|
||||
|
||||
@@ -199,6 +199,21 @@
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<?php if($userIsAdminApp || $userIsAdminAcc):?>
|
||||
<tr>
|
||||
<td class="descField"><?php echo _('Grupo Principal'); ?></td>
|
||||
<td class="valField">
|
||||
<select id="selMainGroupId" name="mainGroupId" class="select-box sel-chosen-usergroup" required>
|
||||
<option value="0"></option>
|
||||
<?php foreach ($otherGroups as $id => $name): ?>
|
||||
<option
|
||||
value="<?php echo $id; ?>" <?php echo ($gotData && $id == $accountData->account_userGroupId) ? 'selected' : ''; ?>><?php echo $name; ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($showform): ?>
|
||||
|
||||
Reference in New Issue
Block a user