mirror of
https://github.com/nuxsmin/sysPass.git
synced 2026-03-06 08:34:16 +01:00
* [DEV] Closes #291. New profile option to allow to change account's permissions.
This commit is contained in:
@@ -272,6 +272,7 @@ if ($actionId === ActionsInterface::ACTION_USR_USERS_NEW
|
||||
$ProfileData->setAccFiles(Request::analyze('profile_accfiles', 0, false, 1));
|
||||
$ProfileData->setAccPublicLinks(Request::analyze('profile_accpublinks', 0, false, 1));
|
||||
$ProfileData->setAccPrivate(Request::analyze('profile_accprivate', 0, false, 1));
|
||||
$ProfileData->setAccPermission(Request::analyze('profile_accpermissions', 0, false, 1));
|
||||
$ProfileData->setConfigGeneral(Request::analyze('profile_config', 0, false, 1));
|
||||
$ProfileData->setConfigEncryption(Request::analyze('profile_configmpw', 0, false, 1));
|
||||
$ProfileData->setConfigBackup(Request::analyze('profile_configback', 0, false, 1));
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
namespace SP\Account;
|
||||
|
||||
use SP\Core\Acl;
|
||||
use SP\Core\Session;
|
||||
use SP\Log\Log;
|
||||
use SP\Util\Checks;
|
||||
|
||||
@@ -99,6 +100,10 @@ class AccountAcl
|
||||
* @var bool
|
||||
*/
|
||||
protected $showCopy = false;
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected $showPermission = false;
|
||||
|
||||
/**
|
||||
* @return boolean
|
||||
@@ -195,7 +200,7 @@ class AccountAcl
|
||||
* @param int $action
|
||||
* @return $this
|
||||
*/
|
||||
public function getAcl (AccountBase $Account, $action)
|
||||
public function getAcl(AccountBase $Account, $action)
|
||||
{
|
||||
$this->Account = $Account;
|
||||
$this->action = $action;
|
||||
@@ -289,6 +294,9 @@ class AccountAcl
|
||||
|| $this->action === Acl::ACTION_ACC_EDIT)
|
||||
&& Acl::checkAccountAccess(Acl::ACTION_ACC_COPY, $aclData)
|
||||
&& Acl::checkUserAccess(Acl::ACTION_ACC_COPY);
|
||||
|
||||
// Cambiar los permisos de la cuenta
|
||||
$this->showPermission = Session::getUserIsAdminAcc() || Session::getUserIsAdminApp() || Session::getUserProfile()->isAccPermission();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -322,4 +330,20 @@ class AccountAcl
|
||||
{
|
||||
return $this->showCopy;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return boolean
|
||||
*/
|
||||
public function isShowPermission()
|
||||
{
|
||||
return $this->showPermission;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param boolean $showPermission
|
||||
*/
|
||||
public function setShowPermission($showPermission)
|
||||
{
|
||||
$this->showPermission = $showPermission;
|
||||
}
|
||||
}
|
||||
@@ -70,6 +70,10 @@ class ProfileData extends ProfileBaseData
|
||||
* @var bool
|
||||
*/
|
||||
protected $accPrivate = false;
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected $accPermission = false;
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
@@ -514,4 +518,20 @@ class ProfileData extends ProfileBaseData
|
||||
{
|
||||
$this->accPrivate = $accPrivate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return boolean
|
||||
*/
|
||||
public function isAccPermission()
|
||||
{
|
||||
return $this->accPermission;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param boolean $accPermission
|
||||
*/
|
||||
public function setAccPermission($accPermission)
|
||||
{
|
||||
$this->accPermission = $accPermission;
|
||||
}
|
||||
}
|
||||
@@ -224,7 +224,6 @@ class CustomField extends CustomFieldBase implements ItemInterface
|
||||
$queryRes = DB::getResults($Data);
|
||||
|
||||
$customFields = [];
|
||||
$customFieldsHash = '';
|
||||
|
||||
foreach ($queryRes as $CustomFieldData) {
|
||||
/**
|
||||
@@ -243,11 +242,8 @@ class CustomField extends CustomFieldBase implements ItemInterface
|
||||
$CustomFieldData->setValue($this->unencryptData($CustomFieldData));
|
||||
|
||||
$customFields[] = $CustomFieldData;
|
||||
$customFieldsHash .= $CustomFieldData->getValue();
|
||||
}
|
||||
|
||||
$customFields['hash'] = md5($customFieldsHash);
|
||||
|
||||
return $customFields;
|
||||
}
|
||||
|
||||
|
||||
@@ -99,6 +99,13 @@
|
||||
<span class="mdl-switch__label"
|
||||
title="<?php echo _('Crear cuenta privada'); ?>"><?php echo _('Privada'); ?></span>
|
||||
</label>
|
||||
<label class="mdl-switch mdl-js-switch mdl-js-ripple-effect" for="profile_accpermissions">
|
||||
<input type="checkbox" id="profile_accpermissions"
|
||||
class="mdl-switch__input mdl-color-text--indigo-400"
|
||||
name="profile_accpermissions" <?php echo $profile->isAccPermission() ? 'CHECKED' : ''; ?> <?php echo $isDisabled; ?>/>
|
||||
<span class="mdl-switch__label"
|
||||
title="<?php echo _('Asignar permisos'); ?>"><?php echo _('Permisos'); ?></span>
|
||||
</label>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -1,54 +1,61 @@
|
||||
<table class="data round extra-info">
|
||||
<tr>
|
||||
<td class="descField"><?php echo _('Permisos'); ?></td>
|
||||
<td class="valField">
|
||||
<div class="account-permissions">
|
||||
<fieldset class="round5">
|
||||
<legend><?php echo _('Usuarios'); ?></legend>
|
||||
<select id="otherUsers" name="otherUsers[]" multiple="multiple">
|
||||
<option value=""><?php echo _('Seleccionar Usuarios'); ?></option>
|
||||
<?php if ($gotData === true): ?>
|
||||
<?php foreach ($accountOtherUsers as $otherUser): ?>
|
||||
<?php /** @var $otherUser \SP\DataModel\UserData */ ?>
|
||||
<option
|
||||
value="<?php echo $otherUser->getUserId(); ?>"
|
||||
selected><?php echo $otherUser->getUserLogin(); ?></option>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</select>
|
||||
<br>
|
||||
<label class="mdl-switch mdl-js-switch mdl-js-ripple-effect" for="userEditEnabled">
|
||||
<input name="userEditEnabled" type="checkbox" id="userEditEnabled"
|
||||
class="mdl-switch__input" <?php echo ($gotData && $accountData->getAccountOtherUserEdit()) ? 'checked' : ''; ?>/>
|
||||
<span class="mdl-switch__label"><?php echo _('Hablitar edición'); ?></span>
|
||||
</label>
|
||||
</fieldset>
|
||||
</div>
|
||||
<div class="account-permissions">
|
||||
<fieldset class="round5">
|
||||
<legend><?php echo _('Grupos'); ?></legend>
|
||||
<select id="otherGroups" name="otherGroups[]" multiple="multiple">
|
||||
<option value=""><?php echo _('Seleccionar Grupos'); ?></option>
|
||||
<?php if ($gotData === true): ?>
|
||||
<?php foreach ($accountOtherGroups as $otherGroup): ?>
|
||||
<?php /** @var $otherGroup \SP\DataModel\GroupData */ ?>
|
||||
<option
|
||||
value="<?php echo $otherGroup->getUsergroupId(); ?>"
|
||||
selected><?php echo $otherGroup->getUsergroupName(); ?></option>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</select>
|
||||
<br>
|
||||
<label class="mdl-switch mdl-js-switch mdl-js-ripple-effect" for="groupEditEnabled">
|
||||
<input name="groupEditEnabled" type="checkbox" id="groupEditEnabled"
|
||||
class="mdl-switch__input" <?php echo ($gotData && $accountData->getAccountOtherGroupEdit()) ? 'checked' : ''; ?>/>
|
||||
<span class="mdl-switch__label"><?php echo _('Hablitar edición'); ?></span>
|
||||
</label
|
||||
<?php
|
||||
/** @var \SP\Account\AccountAcl $AccountAcl */
|
||||
/** @var \SP\DataModel\AccountExtData $accountData */
|
||||
?>
|
||||
|
||||
</fieldset>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<table class="data round extra-info">
|
||||
<?php if ($AccountAcl->isShowPermission()): ?>
|
||||
<tr>
|
||||
<td class="descField"><?php echo _('Permisos'); ?></td>
|
||||
<td class="valField">
|
||||
<div class="account-permissions">
|
||||
<fieldset class="round5">
|
||||
<legend><?php echo _('Usuarios'); ?></legend>
|
||||
<select id="otherUsers" name="otherUsers[]" multiple="multiple">
|
||||
<option value=""><?php echo _('Seleccionar Usuarios'); ?></option>
|
||||
<?php if ($gotData === true): ?>
|
||||
<?php foreach ($accountOtherUsers as $otherUser): ?>
|
||||
<?php /** @var $otherUser \SP\DataModel\UserData */ ?>
|
||||
<option
|
||||
value="<?php echo $otherUser->getUserId(); ?>"
|
||||
selected><?php echo $otherUser->getUserLogin(); ?></option>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</select>
|
||||
<br>
|
||||
<label class="mdl-switch mdl-js-switch mdl-js-ripple-effect" for="userEditEnabled">
|
||||
<input name="userEditEnabled" type="checkbox" id="userEditEnabled"
|
||||
class="mdl-switch__input" <?php echo ($gotData && $accountData->getAccountOtherUserEdit()) ? 'checked' : ''; ?>/>
|
||||
<span class="mdl-switch__label"><?php echo _('Hablitar edición'); ?></span>
|
||||
</label>
|
||||
</fieldset>
|
||||
</div>
|
||||
<div class="account-permissions">
|
||||
<fieldset class="round5">
|
||||
<legend><?php echo _('Grupos'); ?></legend>
|
||||
<select id="otherGroups" name="otherGroups[]" multiple="multiple">
|
||||
<option value=""><?php echo _('Seleccionar Grupos'); ?></option>
|
||||
<?php if ($gotData === true): ?>
|
||||
<?php foreach ($accountOtherGroups as $otherGroup): ?>
|
||||
<?php /** @var $otherGroup \SP\DataModel\GroupData */ ?>
|
||||
<option
|
||||
value="<?php echo $otherGroup->getUsergroupId(); ?>"
|
||||
selected><?php echo $otherGroup->getUsergroupName(); ?></option>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</select>
|
||||
<br>
|
||||
<label class="mdl-switch mdl-js-switch mdl-js-ripple-effect" for="groupEditEnabled">
|
||||
<input name="groupEditEnabled" type="checkbox" id="groupEditEnabled"
|
||||
class="mdl-switch__input" <?php echo ($gotData && $accountData->getAccountOtherGroupEdit()) ? 'checked' : ''; ?>/>
|
||||
<span class="mdl-switch__label"><?php echo _('Hablitar edición'); ?></span>
|
||||
</label
|
||||
|
||||
</fieldset>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
<?php if ($userIsAdminApp || $userIsAdminAcc): ?>
|
||||
<tr>
|
||||
<td class="descField"><?php echo _('Grupo Principal'); ?></td>
|
||||
|
||||
@@ -194,7 +194,7 @@
|
||||
<?php include $this->includeTemplate('account-permissions'); ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($customFields): ?>
|
||||
<?php if (count($customFields) > 0): ?>
|
||||
<table class="data round extra-info secure-info">
|
||||
<?php include $this->includeTemplate('aux-customfields', 'common'); ?>
|
||||
</table>
|
||||
|
||||
@@ -5,46 +5,44 @@ use SP\Mgmt\CustomFields\CustomFieldTypes;
|
||||
/** @var $icons \Theme\Icons */
|
||||
/** @var \SP\DataModel\CustomFieldData $field */
|
||||
|
||||
foreach ($customFields as $index => $field):
|
||||
?>
|
||||
<?php if ($index !== 'hash'): ?>
|
||||
foreach ($customFields as $index => $field):?>
|
||||
<tr>
|
||||
<td class="descField">
|
||||
<?php echo $field->getDefinition()->getName(); ?>
|
||||
<?php if ($field->getDefinition()->getHelp()): ?>
|
||||
<div id="help-<?php echo $field->getDefinition()->getFormId(); ?>"
|
||||
class="icon material-icons <?php echo $icons->getIconHelp()->getClass(); ?>">
|
||||
<?php echo $icons->getIconHelp()->getIcon(); ?>
|
||||
</div>
|
||||
<div class="mdl-tooltip mdl-tooltip--large" for="help-<?php echo $field->getDefinition()->getFormId(); ?>">
|
||||
<p><?php echo $field->getDefinition()->getHelp(); ?></p>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td class="valField">
|
||||
<?php if (!$isView): ?>
|
||||
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
|
||||
<input id="<?php echo $field->getDefinition()->getFormId(); ?>"
|
||||
name="customfield[<?php echo $field->getDefinitionId(); ?>]"
|
||||
type="<?php echo $field->getTypeName(); ?>"
|
||||
class="mdl-textfield__input mdl-color-text--indigo-400 <?php echo ($field->getDefinition()->getType() === CustomFieldTypes::TYPE_PASSWORD) ? 'passwordfield__input-show passwordfield__no-pki' : ''; ?>"
|
||||
maxlength="500"
|
||||
value="<?php echo $field->getCleanValue(); ?>"
|
||||
<?php echo ($field->getDefinition()->isRequired()) ? 'required' : ''; ?>>
|
||||
<label class="mdl-textfield__label"
|
||||
for="<?php echo $field->getDefinition()->getFormId(); ?>"><?php echo $field->getDefinition()->getName(); ?></label>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<?php if ($field->getDefinition()->getType() === CustomFieldTypes::TYPE_PASSWORD && !$showViewPass): ?>
|
||||
****
|
||||
<?php elseif ($field->getDefinition()->getType() === CustomFieldTypes::TYPE_COLOR): ?>
|
||||
<span class="round custom-input-color"
|
||||
style="background-color: <?php echo $field->getValue(); ?>;"></span>
|
||||
<?php else: ?>
|
||||
<?php echo $field->getValue(); ?>
|
||||
<td class="descField">
|
||||
<?php echo $field->getDefinition()->getName(); ?>
|
||||
<?php if ($field->getDefinition()->getHelp()): ?>
|
||||
<div id="help-<?php echo $field->getDefinition()->getFormId(); ?>"
|
||||
class="icon material-icons <?php echo $icons->getIconHelp()->getClass(); ?>">
|
||||
<?php echo $icons->getIconHelp()->getIcon(); ?>
|
||||
</div>
|
||||
<div class="mdl-tooltip mdl-tooltip--large"
|
||||
for="help-<?php echo $field->getDefinition()->getFormId(); ?>">
|
||||
<p><?php echo $field->getDefinition()->getHelp(); ?></p>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</td>
|
||||
<td class="valField">
|
||||
<?php if (!$isView): ?>
|
||||
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
|
||||
<input id="<?php echo $field->getDefinition()->getFormId(); ?>"
|
||||
name="customfield[<?php echo $field->getDefinitionId(); ?>]"
|
||||
type="<?php echo $field->getTypeName(); ?>"
|
||||
class="mdl-textfield__input mdl-color-text--indigo-400 <?php echo ($field->getDefinition()->getType() === CustomFieldTypes::TYPE_PASSWORD) ? 'passwordfield__input-show passwordfield__no-pki' : ''; ?>"
|
||||
maxlength="500"
|
||||
value="<?php echo $field->getCleanValue(); ?>"
|
||||
<?php echo ($field->getDefinition()->isRequired()) ? 'required' : ''; ?>>
|
||||
<label class="mdl-textfield__label"
|
||||
for="<?php echo $field->getDefinition()->getFormId(); ?>"><?php echo $field->getDefinition()->getName(); ?></label>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<?php if ($field->getDefinition()->getType() === CustomFieldTypes::TYPE_PASSWORD && !$showViewPass): ?>
|
||||
****
|
||||
<?php elseif ($field->getDefinition()->getType() === CustomFieldTypes::TYPE_COLOR): ?>
|
||||
<span class="round custom-input-color"
|
||||
style="background-color: <?php echo $field->getValue(); ?>;"></span>
|
||||
<?php else: ?>
|
||||
<?php echo $field->getValue(); ?>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
Reference in New Issue
Block a user