mirror of
https://github.com/nuxsmin/sysPass.git
synced 2026-03-11 19:06:57 +01:00
* [ADD] Permissions for users and groups on accounts could now be set either for viewing or editing.
* [MOD] Improved account ACL performance * [MOD] Improved tags and permissions saving behavior
This commit is contained in:
@@ -118,8 +118,27 @@ class AccountHelper extends HelperBase
|
||||
$selectUserGroups = SelectItemAdapter::factory(UserGroupService::getItemsBasic());
|
||||
$selectTags = SelectItemAdapter::factory(TagService::getItemsBasic());
|
||||
|
||||
$this->view->assign('otherUsers', $selectUsers->getItemsFromModelSelected(SelectItemAdapter::getIdFromArrayOfObjects($accountDetailsResponse->getUsers()), $accountData->getUserId()));
|
||||
$this->view->assign('otherUserGroups', $selectUserGroups->getItemsFromModelSelected(SelectItemAdapter::getIdFromArrayOfObjects($accountDetailsResponse->getUserGroups()), $accountData->getUserGroupId()));
|
||||
$this->view->assign('otherUsersView', $selectUsers->getItemsFromModelSelected(
|
||||
SelectItemAdapter::getIdFromArrayOfObjects(array_filter($accountDetailsResponse->getUsers(), function ($value) {
|
||||
return (int)$value->isEdit === 0;
|
||||
})), $accountData->getUserId()));
|
||||
|
||||
$this->view->assign('otherUsersEdit', $selectUsers->getItemsFromModelSelected(
|
||||
SelectItemAdapter::getIdFromArrayOfObjects(array_filter($accountDetailsResponse->getUsers(), function ($value) {
|
||||
return (int)$value->isEdit === 1;
|
||||
})), $accountData->getUserId()));
|
||||
|
||||
$this->view->assign('otherUserGroupsView', $selectUserGroups->getItemsFromModelSelected(
|
||||
SelectItemAdapter::getIdFromArrayOfObjects(array_filter($accountDetailsResponse->getUserGroups(), function ($value) {
|
||||
return (int)$value->isEdit === 0;
|
||||
})), $accountData->getUserGroupId()));
|
||||
|
||||
$this->view->assign('otherUserGroupsEdit', $selectUserGroups->getItemsFromModelSelected(
|
||||
SelectItemAdapter::getIdFromArrayOfObjects(array_filter($accountDetailsResponse->getUserGroups(), function ($value) {
|
||||
return (int)$value->isEdit === 1;
|
||||
})), $accountData->getUserGroupId()));
|
||||
|
||||
$this->view->assign('users', $selectUsers->getItemsFromModelSelected([$accountData->getUserId()]));
|
||||
$this->view->assign('userGroups', $selectUserGroups->getItemsFromModelSelected([$accountData->getUserGroupId()]));
|
||||
$this->view->assign('tags', $selectTags->getItemsFromModelSelected(SelectItemAdapter::getIdFromArrayOfObjects($accountDetailsResponse->getTags())));
|
||||
|
||||
@@ -177,7 +196,8 @@ class AccountHelper extends HelperBase
|
||||
throw new UnauthorizedPageException(UnauthorizedPageException::INFO);
|
||||
}
|
||||
|
||||
if (!$this->dic->get(MasterPassService::class)->checkUserUpdateMPass($this->context->getUserData()->getLastUpdateMPass())) {
|
||||
if (!$this->dic->get(MasterPassService::class)
|
||||
->checkUserUpdateMPass($this->context->getUserData()->getLastUpdateMPass())) {
|
||||
throw new UpdatedMasterPassException(UpdatedMasterPassException::INFO);
|
||||
}
|
||||
}
|
||||
@@ -200,8 +220,6 @@ class AccountHelper extends HelperBase
|
||||
$accountAclDto->setUserGroupId($accountData->getUserGroupId());
|
||||
$accountAclDto->setUsersId($accountDetailsResponse->getUsers());
|
||||
$accountAclDto->setUserGroupsId($accountDetailsResponse->getUserGroups());
|
||||
$accountAclDto->setOtherUserEdit($accountData->getOtherUserEdit());
|
||||
$accountAclDto->setOtherUserGroupEdit($accountData->getOtherUserGroupEdit());
|
||||
|
||||
$accountAcl = $this->dic->get(AccountAclService::class)->getAcl($this->actionId, $accountAclDto);
|
||||
|
||||
@@ -247,7 +265,7 @@ class AccountHelper extends HelperBase
|
||||
$this->view->assign('readonly', $this->isView ? 'readonly' : '');
|
||||
|
||||
$this->view->assign('showViewCustomPass', $this->accountAcl->isShowViewPass());
|
||||
$this->view->assign('accountAcl', $this->accountAcl ?: $this->accountAcl);
|
||||
$this->view->assign('accountAcl', $this->accountAcl);
|
||||
|
||||
$this->view->assign('deepLink', $this->getDeepLink());
|
||||
}
|
||||
@@ -278,18 +296,24 @@ class AccountHelper extends HelperBase
|
||||
|
||||
$this->checkActionAccess();
|
||||
|
||||
$userProfileData = $this->context->getUserProfile();
|
||||
$userData = $this->context->getUserData();
|
||||
|
||||
$this->accountAcl->showPermission = $userData->getIsAdminApp() || $userData->getIsAdminAcc() || $userProfileData->isAccPermission();
|
||||
|
||||
$selectUsers = SelectItemAdapter::factory(UserService::getItemsBasic());
|
||||
$selectUserGroups = SelectItemAdapter::factory(UserGroupService::getItemsBasic());
|
||||
$selectTags = SelectItemAdapter::factory(TagService::getItemsBasic());
|
||||
|
||||
$this->view->assign('accountPassDateChange', date('Y-m-d', time() + 7776000));
|
||||
$this->view->assign('otherUsers', $selectUsers->getItemsFromModel());
|
||||
$this->view->assign('otherUserGroups', $selectUserGroups->getItemsFromModel());
|
||||
$this->view->assign('otherUsersView', $selectUsers->getItemsFromModel());
|
||||
$this->view->assign('otherUsersEdit', $selectUsers->getItemsFromModel());
|
||||
$this->view->assign('otherUserGroupsView', $selectUserGroups->getItemsFromModel());
|
||||
$this->view->assign('otherUserGroupsEdit', $selectUserGroups->getItemsFromModel());
|
||||
|
||||
$this->view->assign('userGroups', $selectUserGroups->getItemsFromModel());
|
||||
$this->view->assign('tags', $selectTags->getItemsFromModel());
|
||||
|
||||
$userProfileData = $this->context->getUserProfile();
|
||||
|
||||
$this->view->assign('allowPrivate', $userProfileData->isAccPrivate());
|
||||
$this->view->assign('allowPrivateGroup', $userProfileData->isAccPrivateGroup());
|
||||
|
||||
|
||||
@@ -98,7 +98,6 @@ class AccountSearchHelper extends HelperBase
|
||||
* Obtener los resultados de una búsqueda
|
||||
*
|
||||
* @throws \Psr\Container\ContainerExceptionInterface
|
||||
* @throws \SP\Core\Exceptions\SPException
|
||||
*/
|
||||
public function getAccountSearch()
|
||||
{
|
||||
|
||||
@@ -140,7 +140,9 @@ class UserController extends ControllerBase implements CrudControllerInterface
|
||||
$this->view->assign('sk', $this->session->generateSecurityKey());
|
||||
$this->view->assign('nextAction', Acl::getActionRoute(ActionsInterface::ACCESS_MANAGE));
|
||||
|
||||
if ($this->view->isView === true || $user->getLogin() === 'demo') {
|
||||
if ($this->view->isView === true
|
||||
|| ($this->configData->isDemoEnabled() && $user->getLogin() === 'demo')
|
||||
) {
|
||||
$this->view->assign('disabled', 'disabled');
|
||||
$this->view->assign('readonly', 'readonly');
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ namespace SP\Modules\Web\Forms;
|
||||
use SP\Account\AccountRequest;
|
||||
use SP\Core\Acl\ActionsInterface;
|
||||
use SP\Core\Exceptions\ValidationException;
|
||||
use SP\DataModel\AccountPermissionData;
|
||||
use SP\Http\Request;
|
||||
|
||||
/**
|
||||
@@ -96,16 +97,29 @@ class AccountForm extends FormBase implements FormInterface
|
||||
$this->accountRequest->userGroupId = Request::analyzeInt('main_usergroup_id');
|
||||
|
||||
// Arrays
|
||||
$accountOtherGroups = Request::analyzeArray('other_usergroups');
|
||||
$accountOtherUsers = Request::analyzeArray('other_users');
|
||||
$accountOtherGroupsView = Request::analyzeArray('other_usergroups_view');
|
||||
$accountOtherGroupsEdit = Request::analyzeArray('other_usergroups_edit');
|
||||
$accountOtherUsersView = Request::analyzeArray('other_users_view');
|
||||
$accountOtherUsersEdit = Request::analyzeArray('other_users_edit');
|
||||
$accountTags = Request::analyzeArray('tags');
|
||||
|
||||
if ($accountOtherUsers) {
|
||||
$this->accountRequest->users = $accountOtherUsers;
|
||||
$this->accountRequest->updateUserGroupPermissions = Request::analyzeInt('other_usergroups_view_update') === 1 || Request::analyzeInt('other_usergroups_edit_update') === 1;
|
||||
$this->accountRequest->updateUserPermissions = Request::analyzeInt('other_users_view_update') === 1 || Request::analyzeInt('other_users_edit_update') === 1;
|
||||
$this->accountRequest->updateTags = Request::analyzeInt('tags_update') === 1;
|
||||
|
||||
if ($accountOtherUsersView) {
|
||||
$this->accountRequest->usersView = $accountOtherUsersView;
|
||||
}
|
||||
if ($accountOtherUsersEdit) {
|
||||
$this->accountRequest->usersEdit = $accountOtherUsersEdit;
|
||||
}
|
||||
|
||||
if ($accountOtherGroups) {
|
||||
$this->accountRequest->userGroups = $accountOtherGroups;
|
||||
if ($accountOtherGroupsView) {
|
||||
$this->accountRequest->userGroupsView = $accountOtherGroupsView;
|
||||
}
|
||||
|
||||
if ($accountOtherGroupsEdit) {
|
||||
$this->accountRequest->userGroupsEdit = $accountOtherGroupsEdit;
|
||||
}
|
||||
|
||||
if ($accountTags) {
|
||||
|
||||
@@ -380,20 +380,14 @@ body.userpassreset {
|
||||
display: none; }
|
||||
#content .data .account-permissions {
|
||||
width: 100%; }
|
||||
#content .data .account-permissions fieldset {
|
||||
border: 1px solid #c9c9c9;
|
||||
padding: 1em; }
|
||||
#content .data .account-permissions legend {
|
||||
font-weight: bold;
|
||||
color: #999;
|
||||
padding: 0.2em 0; }
|
||||
#content .data .account-permissions fieldset > span {
|
||||
font-weight: bold;
|
||||
color: #999;
|
||||
padding: .2em 0;
|
||||
display: inline-block;
|
||||
width: 100px;
|
||||
text-align: right; }
|
||||
#content .data .account-permissions .tag-list-box {
|
||||
margin-bottom: 1em; }
|
||||
#content .data .account-permissions .tag-list-box .tag-list-header {
|
||||
text-align: left;
|
||||
border-bottom: 1px solid #d9d9d9;
|
||||
color: #607d8b;
|
||||
font-size: 12px;
|
||||
font-weight: bold; }
|
||||
#content span.tag {
|
||||
margin: 0 3px 3px 0;
|
||||
padding: .2em;
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -234,22 +234,15 @@
|
||||
}
|
||||
.account-permissions {
|
||||
width: 100%;
|
||||
fieldset {
|
||||
border: 1px solid #c9c9c9;
|
||||
padding: 1em;
|
||||
}
|
||||
legend {
|
||||
font-weight: bold;
|
||||
color: #999;
|
||||
padding: 0.2em 0;
|
||||
}
|
||||
fieldset > span {
|
||||
font-weight: bold;
|
||||
color: #999;
|
||||
padding: .2em 0;
|
||||
display: inline-block;
|
||||
width: 100px;
|
||||
text-align: right;
|
||||
.tag-list-box {
|
||||
margin-bottom: 1em;
|
||||
.tag-list-header {
|
||||
text-align: left;
|
||||
border-bottom: 1px solid #d9d9d9;
|
||||
color: $color-bluegrey-fg;
|
||||
font-size: 12px;
|
||||
font-weight: bold;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
<?php
|
||||
/** @var \SP\Account\AccountAcl $accountAcl */
|
||||
/** @var \SP\DataModel\AccountExtData $accountData */
|
||||
/** @var $icons \SP\Core\UI\ThemeIcons */
|
||||
/**
|
||||
* @var \SP\Account\AccountAcl $accountAcl
|
||||
* @var \SP\DataModel\AccountExtData $accountData
|
||||
* @var \SP\Core\UI\ThemeIcons $icons
|
||||
*/
|
||||
?>
|
||||
|
||||
<div id="data-accesses">
|
||||
@@ -11,22 +13,37 @@
|
||||
<td class="descField"><?php echo __('Usuarios'); ?></td>
|
||||
<td class="valField">
|
||||
<div class="account-permissions">
|
||||
<select id="other_users" name="other_users[]" multiple="multiple">
|
||||
<option value=""><?php echo __('Seleccionar Usuarios'); ?></option>
|
||||
<?php /** @var \SP\Mvc\View\Components\SelectItem[] $otherUsers */
|
||||
foreach ($otherUsers as $otherUser): ?>
|
||||
<?php if ($otherUser->isSkip()): continue; endif; ?>
|
||||
<option
|
||||
value="<?php echo $otherUser->getId(); ?>"
|
||||
<?php echo $otherUser->isSelected() ? 'selected' : '' ?>><?php echo $otherUser->getName(); ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<br>
|
||||
<label class="mdl-switch mdl-js-switch mdl-js-ripple-effect" for="other_user_edit_enabled">
|
||||
<input name="other_user_edit_enabled" type="checkbox" id="other_user_edit_enabled"
|
||||
class="mdl-switch__input" <?php echo ($gotData && $accountData->getOtherUserEdit()) ? 'checked' : ''; ?>/>
|
||||
<span class="mdl-switch__label"><?php echo __('Hablitar edición'); ?></span>
|
||||
</label>
|
||||
<div class="tag-list-box">
|
||||
<div class="tag-list-header"><?php echo __('Ver'); ?></div>
|
||||
|
||||
<select id="other_users_view" name="other_users_view[]" multiple="multiple"
|
||||
class="select-box-tags" data-current-item-id="<?php echo $userId; ?>">
|
||||
<option value=""><?php echo __('Seleccionar Usuarios'); ?></option>
|
||||
<?php /** @var \SP\Mvc\View\Components\SelectItem[] $otherUsersView */
|
||||
foreach ($otherUsersView as $otherUser): ?>
|
||||
<?php if ($otherUser->isSkip()): continue; endif; ?>
|
||||
<option
|
||||
value="<?php echo $otherUser->getId(); ?>"
|
||||
<?php echo $otherUser->isSelected() ? 'selected' : '' ?>><?php echo $otherUser->getName(); ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="tag-list-box">
|
||||
<div class="tag-list-header"><?php echo __('Editar'); ?></div>
|
||||
|
||||
<select id="other_users_edit" name="other_users_edit[]" multiple="multiple"
|
||||
class="select-box-tags" data-current-item-id="<?php echo $userId; ?>">
|
||||
<option value=""><?php echo __('Seleccionar Usuarios'); ?></option>
|
||||
<?php /** @var \SP\Mvc\View\Components\SelectItem[] $otherUsersEdit */
|
||||
foreach ($otherUsersEdit as $otherUser): ?>
|
||||
<?php if ($otherUser->isSkip()): continue; endif; ?>
|
||||
<option
|
||||
value="<?php echo $otherUser->getId(); ?>"
|
||||
<?php echo $otherUser->isSelected() ? 'selected' : '' ?>><?php echo $otherUser->getName(); ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -34,29 +51,59 @@
|
||||
<td class="descField"><?php echo __('Grupos'); ?></td>
|
||||
<td class="valField">
|
||||
<div class="account-permissions">
|
||||
<select id="other_usergroups" name="other_usergroups[]" multiple="multiple">
|
||||
<option value=""><?php echo __('Seleccionar Grupos'); ?></option>
|
||||
<?php /** @var \SP\Mvc\View\Components\SelectItem[] $otherUserGroups */
|
||||
foreach ($otherUserGroups as $otherUserGroup): ?>
|
||||
<?php if ($otherUserGroup->isSkip()): continue; endif; ?>
|
||||
<option
|
||||
value="<?php echo $otherUserGroup->getId(); ?>"
|
||||
<?php echo $otherUserGroup->isSelected() ? 'selected' : '' ?>><?php echo $otherUserGroup->getName(); ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<br>
|
||||
<label class="mdl-switch mdl-js-switch mdl-js-ripple-effect"
|
||||
for="other_usergroup_edit_enabled">
|
||||
<input name="other_usergroup_edit_enabled" type="checkbox"
|
||||
id="other_usergroup_edit_enabled"
|
||||
class="mdl-switch__input" <?php echo ($gotData && $accountData->getOtherUserGroupEdit()) ? 'checked' : ''; ?>/>
|
||||
<span class="mdl-switch__label"><?php echo __('Hablitar edición'); ?></span>
|
||||
</label
|
||||
<div class="tag-list-box">
|
||||
<div class="tag-list-header"><?php echo __('Ver'); ?></div>
|
||||
|
||||
<select id="other_usergroups_view" name="other_usergroups_view[]" multiple="multiple"
|
||||
class="select-box-tags" data-current-item-id="<?php echo $userGroupId; ?>">
|
||||
<option value=""><?php echo __('Seleccionar Grupos'); ?></option>
|
||||
<?php /** @var \SP\Mvc\View\Components\SelectItem[] $otherUserGroupsView */
|
||||
foreach ($otherUserGroupsView as $otherUserGroup): ?>
|
||||
<?php if ($otherUserGroup->isSkip()): continue; endif; ?>
|
||||
<option
|
||||
value="<?php echo $otherUserGroup->getId(); ?>"
|
||||
<?php echo $otherUserGroup->isSelected() ? 'selected' : '' ?>><?php echo $otherUserGroup->getName(); ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="tag-list-box">
|
||||
<div class="tag-list-header"><?php echo __('Editar'); ?></div>
|
||||
|
||||
<select id="other_usergroups_edit" name="other_usergroups_edit[]" multiple="multiple"
|
||||
class="select-box-tags" data-current-item-id="<?php echo $userGroupId; ?>">
|
||||
<option value=""><?php echo __('Seleccionar Grupos'); ?></option>
|
||||
<?php /** @var \SP\Mvc\View\Components\SelectItem[] $otherUserGroupsEdit */
|
||||
foreach ($otherUserGroupsEdit as $otherUserGroup): ?>
|
||||
<?php if ($otherUserGroup->isSkip()): continue; endif; ?>
|
||||
<option
|
||||
value="<?php echo $otherUserGroup->getId(); ?>"
|
||||
<?php echo $otherUserGroup->isSelected() ? 'selected' : '' ?>><?php echo $otherUserGroup->getName(); ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (isset($editAction) && ($userIsAdminApp || $userIsAdminAcc || $userId === $accountData->getUserId())): ?>
|
||||
<tr>
|
||||
<td class="descField"><?php echo __('Creador'); ?></td>
|
||||
<td class="valField">
|
||||
<select id="owner_id" name="owner_id" class="select-box">
|
||||
<option value=""><?php echo __('Seleccionar Usuario'); ?></option>
|
||||
<?php /** @var \SP\Mvc\View\Components\SelectItem[] $users */
|
||||
foreach ($users as $user): ?>
|
||||
<option
|
||||
value="<?php echo $user->getId(); ?>"
|
||||
<?php echo $user->isSelected() ? 'selected' : ''; ?>><?php echo $user->getName(); ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($userIsAdminApp || $userIsAdminAcc): ?>
|
||||
<tr>
|
||||
<td class="descField"><?php echo __('Grupo Principal'); ?></td>
|
||||
|
||||
@@ -207,7 +207,7 @@ $showCustomFields = count($customFields) > 0;
|
||||
<div class="lowres-title"><?php echo __('Etiquetas'); ?></div>
|
||||
|
||||
<?php if (!$isView): ?>
|
||||
<select id="tags" name="tags[]" multiple="multiple" tabindex="10">
|
||||
<select id="tags" name="tags[]" multiple="multiple" tabindex="10" class="select-box-tags">
|
||||
<option value=""><?php echo __('Seleccionar Etiquetas'); ?></option>
|
||||
<?php /** @var \SP\Mvc\View\Components\SelectItem[] $tags */
|
||||
foreach ($tags as $tag): ?>
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
/**
|
||||
* sysPass
|
||||
*
|
||||
* @author nuxsmin
|
||||
* @link https://syspass.org
|
||||
* @author nuxsmin
|
||||
* @link https://syspass.org
|
||||
* @copyright 2012-2018, Rubén Domínguez nuxsmin@$syspass.org
|
||||
*
|
||||
* This file is part of sysPass.
|
||||
@@ -24,6 +24,8 @@
|
||||
|
||||
namespace SP\Account;
|
||||
|
||||
use SP\DataModel\AccountPermissionData;
|
||||
|
||||
/**
|
||||
* Class AccountRequest
|
||||
*
|
||||
@@ -106,11 +108,19 @@ class AccountRequest
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
public $users;
|
||||
public $usersView;
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
public $userGroups;
|
||||
public $usersEdit;
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
public $userGroupsView;
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
public $userGroupsEdit;
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
@@ -123,4 +133,16 @@ class AccountRequest
|
||||
* @var bool
|
||||
*/
|
||||
public $changePermissions = false;
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
public $updateUserPermissions = false;
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
public $updateUserGroupPermissions = false;
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
public $updateTags = false;
|
||||
}
|
||||
@@ -57,14 +57,6 @@ class AccountAclDto
|
||||
* @var int
|
||||
*/
|
||||
private $dateEdit;
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $otherUserEdit;
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $otherUserGroupEdit;
|
||||
|
||||
/**
|
||||
* @return int
|
||||
@@ -131,7 +123,7 @@ class AccountAclDto
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @return int
|
||||
*/
|
||||
public function getDateEdit()
|
||||
{
|
||||
@@ -139,43 +131,11 @@ class AccountAclDto
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $dateEdit
|
||||
* @param int $dateEdit
|
||||
*/
|
||||
public function setDateEdit($dateEdit)
|
||||
{
|
||||
$this->dateEdit = $dateEdit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getOtherUserEdit()
|
||||
{
|
||||
return $this->otherUserEdit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $otherUserEdit
|
||||
*/
|
||||
public function setOtherUserEdit($otherUserEdit)
|
||||
{
|
||||
$this->otherUserEdit = (int)$otherUserEdit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getOtherUserGroupEdit()
|
||||
{
|
||||
return $this->otherUserGroupEdit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $otherUserGroupEdit
|
||||
*/
|
||||
public function setOtherUserGroupEdit($otherUserGroupEdit)
|
||||
{
|
||||
$this->otherUserGroupEdit = (int)$otherUserGroupEdit;
|
||||
$this->dateEdit = (int)$dateEdit;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
/**
|
||||
* sysPass
|
||||
*
|
||||
* @author nuxsmin
|
||||
* @link https://syspass.org
|
||||
* @author nuxsmin
|
||||
* @link https://syspass.org
|
||||
* @copyright 2012-2018, Rubén Domínguez nuxsmin@$syspass.org
|
||||
*
|
||||
* This file is part of sysPass.
|
||||
@@ -49,7 +49,7 @@ class AccountToUserGroupRepository extends Repository
|
||||
public function getUserGroupsByAccountId($id)
|
||||
{
|
||||
$query = /** @lang SQL */
|
||||
'SELECT G.id, G.name
|
||||
'SELECT G.id, G.name, AUG.isEdit
|
||||
FROM AccountToUserGroup AUG
|
||||
INNER JOIN UserGroup G ON AUG.userGroupId = G.id
|
||||
WHERE AUG.accountId = ?
|
||||
@@ -72,7 +72,7 @@ class AccountToUserGroupRepository extends Repository
|
||||
public function getUserGroupsByUserGroupId($id)
|
||||
{
|
||||
$query = /** @lang SQL */
|
||||
'SELECT G.id, G.name
|
||||
'SELECT G.id, G.name, AUG.isEdit
|
||||
FROM AccountToUserGroup AUG
|
||||
INNER JOIN UserGroup G ON AUG.userGroupId = G.id
|
||||
WHERE AUG.userGroupId = ?
|
||||
@@ -141,12 +141,70 @@ class AccountToUserGroupRepository extends Repository
|
||||
public function add(AccountRequest $accountRequest)
|
||||
{
|
||||
$query = /** @lang SQL */
|
||||
'INSERT INTO AccountToUserGroup (accountId, userGroupId) VALUES ' . $this->getParamsFromArray($accountRequest->userGroups, '(?,?)');
|
||||
'INSERT INTO AccountToUserGroup (accountId, userGroupId, isEdit)
|
||||
VALUES ' . $this->getParamsFromArray($accountRequest->userGroupsView, '(?,?,0)') . '
|
||||
ON DUPLICATE KEY UPDATE isEdit = 0';
|
||||
|
||||
$queryData = new QueryData();
|
||||
$queryData->setQuery($query);
|
||||
|
||||
foreach ($accountRequest->userGroups as $userGroup) {
|
||||
foreach ($accountRequest->userGroupsView as $userGroup) {
|
||||
$queryData->addParam($accountRequest->id);
|
||||
$queryData->addParam($userGroup);
|
||||
}
|
||||
|
||||
$queryData->setOnErrorMessage(__u('Error al actualizar los grupos secundarios'));
|
||||
|
||||
return DbWrapper::getQuery($queryData, $this->db);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AccountRequest $accountRequest
|
||||
* @return $this
|
||||
* @throws \SP\Core\Exceptions\ConstraintException
|
||||
* @throws \SP\Core\Exceptions\QueryException
|
||||
*/
|
||||
public function updateEdit(AccountRequest $accountRequest)
|
||||
{
|
||||
$this->deleteEditByAccountId($accountRequest->id);
|
||||
$this->addEdit($accountRequest);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $id int
|
||||
* @return bool
|
||||
* @throws \SP\Core\Exceptions\ConstraintException
|
||||
* @throws \SP\Core\Exceptions\QueryException
|
||||
*/
|
||||
public function deleteEditByAccountId($id)
|
||||
{
|
||||
$queryData = new QueryData();
|
||||
$queryData->setQuery('DELETE FROM AccountToUserGroup WHERE accountId = ? AND isEdit = 1');
|
||||
$queryData->addParam($id);
|
||||
$queryData->setOnErrorMessage(__u('Error al eliminar grupos asociados a la cuenta'));
|
||||
|
||||
return DbWrapper::getQuery($queryData, $this->db);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AccountRequest $accountRequest
|
||||
* @return bool
|
||||
* @throws \SP\Core\Exceptions\ConstraintException
|
||||
* @throws \SP\Core\Exceptions\QueryException
|
||||
*/
|
||||
public function addEdit(AccountRequest $accountRequest)
|
||||
{
|
||||
$query = /** @lang SQL */
|
||||
'INSERT INTO AccountToUserGroup (accountId, userGroupId, isEdit)
|
||||
VALUES ' . $this->getParamsFromArray($accountRequest->userGroupsEdit, '(?,?,1)') . '
|
||||
ON DUPLICATE KEY UPDATE isEdit = 1';
|
||||
|
||||
$queryData = new QueryData();
|
||||
$queryData->setQuery($query);
|
||||
|
||||
foreach ($accountRequest->userGroupsEdit as $userGroup) {
|
||||
$queryData->addParam($accountRequest->id);
|
||||
$queryData->addParam($userGroup);
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
/**
|
||||
* sysPass
|
||||
*
|
||||
* @author nuxsmin
|
||||
* @link https://syspass.org
|
||||
* @author nuxsmin
|
||||
* @link https://syspass.org
|
||||
* @copyright 2012-2018, Rubén Domínguez nuxsmin@$syspass.org
|
||||
*
|
||||
* This file is part of sysPass.
|
||||
@@ -87,13 +87,78 @@ class AccountToUserRepository extends Repository
|
||||
public function add(AccountRequest $accountRequest)
|
||||
{
|
||||
$query = /** @lang SQL */
|
||||
'INSERT INTO AccountToUser (accountId, userId) VALUES ' . $this->getParamsFromArray($accountRequest->users, '(?,?)');
|
||||
'INSERT INTO AccountToUser (accountId, userId, isEdit)
|
||||
VALUES ' . $this->getParamsFromArray($accountRequest->usersView, '(?,?,0)') . '
|
||||
ON DUPLICATE KEY UPDATE isEdit = 0';
|
||||
|
||||
$queryData = new QueryData();
|
||||
$queryData->setQuery($query);
|
||||
$queryData->setOnErrorMessage(__u('Error al actualizar los usuarios de la cuenta'));
|
||||
|
||||
foreach ($accountRequest->users as $user) {
|
||||
foreach ($accountRequest->usersView as $user) {
|
||||
$queryData->addParam($accountRequest->id);
|
||||
$queryData->addParam($user);
|
||||
}
|
||||
|
||||
return DbWrapper::getQuery($queryData, $this->db);
|
||||
}
|
||||
|
||||
/**
|
||||
* Actualizar la asociación de grupos con cuentas.
|
||||
*
|
||||
* @param AccountRequest $accountRequest
|
||||
* @return bool
|
||||
* @throws \SP\Core\Exceptions\ConstraintException
|
||||
* @throws \SP\Core\Exceptions\QueryException
|
||||
*/
|
||||
public function updateEdit(AccountRequest $accountRequest)
|
||||
{
|
||||
$this->deleteEditByAccountId($accountRequest->id);
|
||||
$this->addEdit($accountRequest);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Eliminar la asociación de grupos con cuentas.
|
||||
*
|
||||
* @param int $id con el Id de la cuenta
|
||||
* @return int
|
||||
* @throws \SP\Core\Exceptions\QueryException
|
||||
* @throws \SP\Core\Exceptions\ConstraintException
|
||||
*/
|
||||
public function deleteEditByAccountId($id)
|
||||
{
|
||||
$queryData = new QueryData();
|
||||
$queryData->setQuery('DELETE FROM AccountToUser WHERE accountId = ? AND isEdit = 1');
|
||||
$queryData->addParam($id);
|
||||
$queryData->setOnErrorMessage(__u('Error al eliminar usuarios asociados a la cuenta'));
|
||||
|
||||
DbWrapper::getQuery($queryData, $this->db);
|
||||
|
||||
return $this->db->getNumRows();
|
||||
}
|
||||
|
||||
/**
|
||||
* Crear asociación de usuarios con cuentas.
|
||||
*
|
||||
* @param AccountRequest $accountRequest
|
||||
* @return bool
|
||||
* @throws \SP\Core\Exceptions\ConstraintException
|
||||
* @throws \SP\Core\Exceptions\QueryException
|
||||
*/
|
||||
public function addEdit(AccountRequest $accountRequest)
|
||||
{
|
||||
$query = /** @lang SQL */
|
||||
'INSERT INTO AccountToUser (accountId, userId, isEdit)
|
||||
VALUES ' . $this->getParamsFromArray($accountRequest->usersEdit, '(?,?,1)') . '
|
||||
ON DUPLICATE KEY UPDATE isEdit = 1';
|
||||
|
||||
$queryData = new QueryData();
|
||||
$queryData->setQuery($query);
|
||||
$queryData->setOnErrorMessage(__u('Error al actualizar los usuarios de la cuenta'));
|
||||
|
||||
foreach ($accountRequest->usersEdit as $user) {
|
||||
$queryData->addParam($accountRequest->id);
|
||||
$queryData->addParam($user);
|
||||
}
|
||||
@@ -110,7 +175,7 @@ class AccountToUserRepository extends Repository
|
||||
public function getUsersByAccountId($id)
|
||||
{
|
||||
$query = /** @lang SQL */
|
||||
'SELECT U.id, U.name, U.login
|
||||
'SELECT U.id, U.name, U.login, AU.isEdit
|
||||
FROM AccountToUser AU
|
||||
INNER JOIN User U ON AU.userId = U.id
|
||||
WHERE AU.accountId = ?
|
||||
|
||||
@@ -67,7 +67,7 @@ class UserToUserGroupRepository extends Repository
|
||||
public function getGroupsForUser($userId)
|
||||
{
|
||||
$queryData = new QueryData();
|
||||
$queryData->setQuery('SELECT userGroupId AS groupId FROM UserToUserGroup WHERE userId = ?');
|
||||
$queryData->setQuery('SELECT userGroupId FROM UserToUserGroup WHERE userId = ?');
|
||||
$queryData->addParam($userId);
|
||||
|
||||
return DbWrapper::getResultsArray($queryData, $this->db);
|
||||
|
||||
@@ -33,7 +33,6 @@ use SP\Services\User\UserLoginResponse;
|
||||
use SP\Services\UserGroup\UserToUserGroupService;
|
||||
use SP\Storage\FileCache;
|
||||
use SP\Storage\FileException;
|
||||
use SP\Util\ArrayUtil;
|
||||
use SP\Util\FileUtil;
|
||||
|
||||
/**
|
||||
@@ -63,6 +62,10 @@ class AccountAclService extends Service
|
||||
* @var FileCache
|
||||
*/
|
||||
protected $fileCache;
|
||||
/**
|
||||
* @var UserLoginResponse
|
||||
*/
|
||||
protected $userData;
|
||||
|
||||
/**
|
||||
* @param $userId
|
||||
@@ -87,15 +90,16 @@ class AccountAclService extends Service
|
||||
public function getAcl($actionId, AccountAclDto $accountAclDto = null, $isHistory = false)
|
||||
{
|
||||
$this->accountAcl = new AccountAcl($actionId, $isHistory);
|
||||
|
||||
$this->accountAcl->showPermission = self::getShowPermission($this->context->getUserData(), $this->context->getUserProfile());
|
||||
|
||||
if ($accountAclDto !== null) {
|
||||
$this->accountAclDto = $accountAclDto;
|
||||
|
||||
$accountAcl = $this->getAclFromCache($accountAclDto->getAccountId(), $actionId);
|
||||
|
||||
if (null !== $accountAcl
|
||||
&& !($this->accountAcl->modified = (int)strtotime($accountAclDto->getDateEdit()) > $accountAcl->getTime())
|
||||
&& !($this->accountAcl->modified = ($accountAclDto->getDateEdit() > $accountAcl->getTime()
|
||||
|| $this->userData->getLastUpdate() > $accountAcl->getTime()))
|
||||
) {
|
||||
debugLog('Account ACL HIT');
|
||||
|
||||
@@ -196,10 +200,13 @@ class AccountAclService extends Service
|
||||
*/
|
||||
protected function compileAccountAccess()
|
||||
{
|
||||
$userData = $this->context->getUserData();
|
||||
$this->accountAcl->resultView = $this->accountAcl->resultEdit = false;
|
||||
|
||||
if ($userData->getIsAdminApp()
|
||||
|| $userData->getIsAdminAcc()
|
||||
// Check out if user is admin or owner/maingroup
|
||||
if ($this->userData->getIsAdminApp()
|
||||
|| $this->userData->getIsAdminAcc()
|
||||
|| $this->userData->getId() === $this->accountAclDto->getUserId()
|
||||
|| $this->userData->getUserGroupId() === $this->accountAclDto->getUserGroupId()
|
||||
) {
|
||||
$this->accountAcl->resultView = true;
|
||||
$this->accountAcl->resultEdit = true;
|
||||
@@ -207,54 +214,88 @@ class AccountAclService extends Service
|
||||
return;
|
||||
}
|
||||
|
||||
$this->accountAcl->userInGroups = $this->getIsUserInGroups();
|
||||
$this->accountAcl->userInUsers = ArrayUtil::checkInObjectArray($this->accountAclDto->getUsersId(), 'id', $userData->getId());
|
||||
// Check out if user is listed in secondary users of the account
|
||||
$userInUsers = $this->getUserInSecondaryUsers($this->userData->getId());
|
||||
$this->accountAcl->userInUsers = count($userInUsers) > 0;
|
||||
|
||||
$this->accountAcl->resultView = ($userData->getId() === $this->accountAclDto->getUserId()
|
||||
|| $userData->getUserGroupId() === $this->accountAclDto->getUserGroupId()
|
||||
|| $this->accountAcl->userInUsers
|
||||
|| $this->accountAcl->userInGroups);
|
||||
if ($this->accountAcl->userInUsers) {
|
||||
$this->accountAcl->resultView = true;
|
||||
$this->accountAcl->resultEdit = (int)$userInUsers[0]->isEdit === 1;
|
||||
|
||||
$this->accountAcl->resultEdit = ($userData->getId() === $this->accountAclDto->getUserId()
|
||||
|| $userData->getUserGroupId() === $this->accountAclDto->getUserGroupId()
|
||||
|| ($this->accountAcl->userInUsers && $this->accountAclDto->getOtherUserEdit() === 1)
|
||||
|| ($this->accountAcl->userInGroups && $this->accountAclDto->getOtherUserGroupEdit() === 1));
|
||||
return;
|
||||
}
|
||||
|
||||
// Analyze user's groups
|
||||
$userToUserGroupService = $this->dic->get(UserToUserGroupService::class);
|
||||
|
||||
// Groups in whinch the user is listed in
|
||||
$userGroups = array_map(function ($value) {
|
||||
return (int)$value->userGroupId;
|
||||
}, $userToUserGroupService->getGroupsForUser($this->userData->getId()));
|
||||
|
||||
// Check out if user groups match with account's main group
|
||||
if ($this->getUserGroupsInMainGroup($userGroups)) {
|
||||
$this->accountAcl->userInGroups = true;
|
||||
$this->accountAcl->resultView = true;
|
||||
$this->accountAcl->resultEdit = true;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Check out if user groups match with account's secondary groups
|
||||
$userGroupsInSecondaryUserGroups = $this->getUserGroupsInSecondaryGroups($userGroups, $this->userData->getUserGroupId());
|
||||
|
||||
$this->accountAcl->userInGroups = count($userGroupsInSecondaryUserGroups) > 0;
|
||||
$this->accountAcl->resultView = true;
|
||||
$this->accountAcl->resultEdit = $this->accountAcl->userInGroups && (int)$userGroupsInSecondaryUserGroups[0]->isEdit === 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the user is listed in the account users
|
||||
*
|
||||
* @param $userId
|
||||
* @return array
|
||||
*/
|
||||
protected function getUserInSecondaryUsers($userId)
|
||||
{
|
||||
return array_filter($this->accountAclDto->getUsersId(), function ($value) use ($userId) {
|
||||
return (int)$value->id === $userId;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Comprobar si los grupos del usuario está vinculado desde el grupo principal de la cuenta
|
||||
*
|
||||
* @param array $userGroups
|
||||
* @return bool
|
||||
*/
|
||||
protected function getUserGroupsInMainGroup(array $userGroups)
|
||||
{
|
||||
// Comprobar si el usuario está vinculado desde el grupo principal de la cuenta
|
||||
return in_array($this->accountAclDto->getUserGroupId(), $userGroups);
|
||||
}
|
||||
|
||||
/**
|
||||
* Comprobar si el usuario o el grupo del usuario se encuentran los grupos asociados a la
|
||||
* cuenta.
|
||||
*
|
||||
* @return bool
|
||||
* @param array $userGroups
|
||||
* @param int $userGroupId
|
||||
* @return bool|array
|
||||
*/
|
||||
protected function getIsUserInGroups()
|
||||
protected function getUserGroupsInSecondaryGroups(array $userGroups, $userGroupId)
|
||||
{
|
||||
$userData = $this->context->getUserData();
|
||||
$userToUserGroupService = $this->dic->get(UserToUserGroupService::class);
|
||||
|
||||
// Comprobar si el usuario está vinculado desde el grupo principal de la cuenta
|
||||
if ($userToUserGroupService->checkUserInGroup($this->accountAclDto->getUserGroupId(), $userData->getId())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Grupos en los que se encuentra el usuario
|
||||
$userGroupIds = $userToUserGroupService->getGroupsForUser($userData->getId());
|
||||
$isAccountFullGroupAccess = $this->config->getConfigData()->isAccountFullGroupAccess();
|
||||
|
||||
// Comprobar si el grupo del usuario está vinculado desde los grupos secundarios de la cuenta
|
||||
foreach ($this->accountAclDto->getUserGroupsId() as $userGroup) {
|
||||
// Consultar el grupo principal del usuario
|
||||
if ((int)$userGroup->id === $userData->getUserGroupId()
|
||||
// o... permitir los grupos que no sean el principal del usuario?
|
||||
|| ($isAccountFullGroupAccess
|
||||
// Comprobar si el usuario está vinculado desde los grupos secundarios de la cuenta
|
||||
&& ArrayUtil::checkInObjectArray($userGroupIds, 'userGroupId', $userGroup->id))
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return array_filter($this->accountAclDto->getUserGroupsId(),
|
||||
function ($value) use ($userGroupId, $isAccountFullGroupAccess, $userGroups) {
|
||||
return (int)$value->id === $userGroupId
|
||||
// o... permitir los grupos que no sean el principal del usuario?
|
||||
|| ($isAccountFullGroupAccess
|
||||
// Comprobar si el usuario está vinculado desde los grupos secundarios de la cuenta
|
||||
&& in_array((int)$value->id, $userGroups));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -321,5 +362,6 @@ class AccountAclService extends Service
|
||||
{
|
||||
$this->acl = $this->dic->get(Acl::class);
|
||||
$this->fileCache = $this->dic->get(FileCache::class);
|
||||
$this->userData = $this->context->getUserData();
|
||||
}
|
||||
}
|
||||
@@ -152,13 +152,11 @@ class AccountSearchService extends Service
|
||||
|
||||
$accountAclDto = new AccountAclDto();
|
||||
$accountAclDto->setAccountId($accountSearchData->getId());
|
||||
$accountAclDto->setDateEdit($accountSearchData->getDateEdit());
|
||||
$accountAclDto->setDateEdit(strtotime($accountSearchData->getDateEdit()));
|
||||
$accountAclDto->setUserId($accountSearchData->getUserId());
|
||||
$accountAclDto->setUserGroupId($accountSearchData->getUserGroupId());
|
||||
$accountAclDto->setUsersId($cache->getUsers());
|
||||
$accountAclDto->setUserGroupsId($cache->getUserGroups());
|
||||
$accountAclDto->setOtherUserEdit($accountSearchData->getOtherUserEdit());
|
||||
$accountAclDto->setOtherUserGroupEdit($accountSearchData->getOtherUserGroupEdit());
|
||||
|
||||
// Obtener la ACL de la cuenta
|
||||
$accountAcl = $accountAclService->getAcl(Acl::ACCOUNT_SEARCH, $accountAclDto);
|
||||
|
||||
@@ -220,11 +220,19 @@ class AccountService extends Service implements AccountServiceInterface
|
||||
{
|
||||
try {
|
||||
if ($accountRequest->changePermissions) {
|
||||
if (is_array($accountRequest->userGroups) && !empty($accountRequest->userGroups)) {
|
||||
if (is_array($accountRequest->userGroupsView) && !empty($accountRequest->userGroupsView)) {
|
||||
$this->accountToUserGroupRepository->add($accountRequest);
|
||||
}
|
||||
|
||||
if (is_array($accountRequest->users) && !empty($accountRequest->users)) {
|
||||
if (is_array($accountRequest->userGroupsEdit) && !empty($accountRequest->userGroupsEdit)) {
|
||||
$this->accountToUserGroupRepository->addEdit($accountRequest);
|
||||
}
|
||||
|
||||
if (is_array($accountRequest->usersView) && !empty($accountRequest->usersView)) {
|
||||
$this->accountToUserRepository->add($accountRequest);
|
||||
}
|
||||
|
||||
if (is_array($accountRequest->usersEdit) && !empty($accountRequest->usersEdit)) {
|
||||
$this->accountToUserRepository->add($accountRequest);
|
||||
}
|
||||
}
|
||||
@@ -264,7 +272,7 @@ class AccountService extends Service implements AccountServiceInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $accountId
|
||||
* @param int $accountId
|
||||
* @param bool $isDelete
|
||||
* @return bool
|
||||
* @throws QueryException
|
||||
@@ -296,23 +304,41 @@ class AccountService extends Service implements AccountServiceInterface
|
||||
try {
|
||||
|
||||
if ($accountRequest->changePermissions) {
|
||||
if (!empty($accountRequest->userGroups)) {
|
||||
$this->accountToUserGroupRepository->update($accountRequest);
|
||||
} else {
|
||||
$this->accountToUserGroupRepository->deleteByAccountId($accountRequest->id);
|
||||
if ($accountRequest->updateUserGroupPermissions) {
|
||||
if (!empty($accountRequest->userGroupsView)) {
|
||||
$this->accountToUserGroupRepository->update($accountRequest);
|
||||
} else {
|
||||
$this->accountToUserGroupRepository->deleteByAccountId($accountRequest->id);
|
||||
}
|
||||
|
||||
if (!empty($accountRequest->userGroupsEdit)) {
|
||||
$this->accountToUserGroupRepository->updateEdit($accountRequest);
|
||||
} else {
|
||||
$this->accountToUserGroupRepository->deleteEditByAccountId($accountRequest->id);
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($accountRequest->users)) {
|
||||
$this->accountToUserRepository->update($accountRequest);
|
||||
} else {
|
||||
$this->accountToUserRepository->deleteByAccountId($accountRequest->id);
|
||||
if ($accountRequest->updateUserPermissions) {
|
||||
if (!empty($accountRequest->usersView)) {
|
||||
$this->accountToUserRepository->update($accountRequest);
|
||||
} else {
|
||||
$this->accountToUserRepository->deleteByAccountId($accountRequest->id);
|
||||
}
|
||||
|
||||
if (!empty($accountRequest->usersEdit)) {
|
||||
$this->accountToUserRepository->updateEdit($accountRequest);
|
||||
} else {
|
||||
$this->accountToUserRepository->deleteEditByAccountId($accountRequest->id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($accountRequest->tags)) {
|
||||
$this->accountToTagRepository->update($accountRequest);
|
||||
} else {
|
||||
$this->accountToTagRepository->deleteByAccountId($accountRequest->id);
|
||||
if ($accountRequest->updateTags) {
|
||||
if (!empty($accountRequest->tags)) {
|
||||
$this->accountToTagRepository->update($accountRequest);
|
||||
} else {
|
||||
$this->accountToTagRepository->deleteByAccountId($accountRequest->id);
|
||||
}
|
||||
}
|
||||
} catch (SPException $e) {
|
||||
debugLog($e->getMessage());
|
||||
@@ -321,7 +347,7 @@ class AccountService extends Service implements AccountServiceInterface
|
||||
|
||||
/**
|
||||
* @param AccountRequest $accountRequest
|
||||
* @param bool $addHistory
|
||||
* @param bool $addHistory
|
||||
* @throws SPException
|
||||
* @throws \Psr\Container\ContainerExceptionInterface
|
||||
* @throws \Psr\Container\NotFoundExceptionInterface
|
||||
|
||||
@@ -56,7 +56,7 @@ class Installer extends Service
|
||||
*/
|
||||
const VERSION = [3, 0, 0];
|
||||
const VERSION_TEXT = '3.0-beta';
|
||||
const BUILD = 18033001;
|
||||
const BUILD = 18040201;
|
||||
|
||||
/**
|
||||
* @var ConfigService
|
||||
|
||||
@@ -121,6 +121,10 @@ class UserLoginResponse
|
||||
* @var int
|
||||
*/
|
||||
private $lastUpdateMPass = 0;
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $lastUpdate;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
@@ -517,4 +521,23 @@ class UserLoginResponse
|
||||
$this->userProfileName = $userProfileName;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getLastUpdate(): int
|
||||
{
|
||||
return $this->lastUpdate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $lastUpdate
|
||||
* @return UserLoginResponse
|
||||
*/
|
||||
public function setLastUpdate(int $lastUpdate)
|
||||
{
|
||||
$this->lastUpdate = $lastUpdate;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -79,7 +79,8 @@ class UserService extends Service
|
||||
->setIsMigrate($userData->isMigrate())
|
||||
->setIsChangedPass($userData->isIsChangedPass())
|
||||
->setIsChangePass($userData->isChangePass())
|
||||
->setIsDisabled($userData->isDisabled());
|
||||
->setIsDisabled($userData->isDisabled())
|
||||
->setLastUpdate((int)strtotime($userData->getLastUpdate()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -61,7 +61,7 @@ class UserToUserGroupService extends Service
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $id
|
||||
* @param int $id
|
||||
* @param array $users
|
||||
* @return UserToUserGroupRepository
|
||||
* @throws \SP\Core\Exceptions\ConstraintException
|
||||
@@ -69,6 +69,10 @@ class UserToUserGroupService extends Service
|
||||
*/
|
||||
public function update($id, array $users)
|
||||
{
|
||||
if (count($users) === 0) {
|
||||
return $this->userToUserGroupRepository->delete($id);
|
||||
}
|
||||
|
||||
return $this->userToUserGroupRepository->update($id, $users);
|
||||
}
|
||||
|
||||
|
||||
@@ -450,6 +450,11 @@ sysPass.Actions = function (Common) {
|
||||
opts.url = ajaxUrl.entrypoint + "?r=" + $obj.data("action-route") + "/" + $obj.data("item-id");
|
||||
opts.data = $obj.serialize();
|
||||
|
||||
// Sets which "select" elements should be updated
|
||||
$("select.select-box-tags[data-hash][data-updated=true]").each(function (index, value) {
|
||||
opts.data += "&" + value.getAttribute("id") + "_update=1";
|
||||
});
|
||||
|
||||
Common.appRequests().getActionCall(opts, function (json) {
|
||||
Common.msg.out(json);
|
||||
|
||||
|
||||
58
public/js/app-actions.min.js
vendored
58
public/js/app-actions.min.js
vendored
@@ -1,5 +1,5 @@
|
||||
var $jscomp={scope:{},findInternal:function(b,e,l){b instanceof String&&(b=String(b));for(var f=b.length,g=0;g<f;g++){var m=b[g];if(e.call(l,m,g,b))return{i:g,v:m}}return{i:-1,v:void 0}}};$jscomp.defineProperty="function"==typeof Object.defineProperties?Object.defineProperty:function(b,e,l){if(l.get||l.set)throw new TypeError("ES3 does not support getters and setters.");b!=Array.prototype&&b!=Object.prototype&&(b[e]=l.value)};
|
||||
$jscomp.getGlobal=function(b){return"undefined"!=typeof window&&window===b?b:"undefined"!=typeof global&&null!=global?global:b};$jscomp.global=$jscomp.getGlobal(this);$jscomp.polyfill=function(b,e,l,f){if(e){l=$jscomp.global;b=b.split(".");for(f=0;f<b.length-1;f++){var g=b[f];g in l||(l[g]={});l=l[g]}b=b[b.length-1];f=l[b];e=e(f);e!=f&&null!=e&&$jscomp.defineProperty(l,b,{configurable:!0,writable:!0,value:e})}};
|
||||
$jscomp.getGlobal=function(b){return"undefined"!=typeof window&&window===b?b:"undefined"!=typeof global?global:b};$jscomp.global=$jscomp.getGlobal(this);$jscomp.polyfill=function(b,e,l,f){if(e){l=$jscomp.global;b=b.split(".");for(f=0;f<b.length-1;f++){var g=b[f];g in l||(l[g]={});l=l[g]}b=b[b.length-1];f=l[b];e=e(f);e!=f&&null!=e&&$jscomp.defineProperty(l,b,{configurable:!0,writable:!0,value:e})}};
|
||||
$jscomp.polyfill("Array.prototype.find",function(b){return b?b:function(b,l){return $jscomp.findInternal(this,b,l).v}},"es6-impl","es3");
|
||||
sysPass.Actions=function(b){var e=b.log,l=0,f={entrypoint:"/index.php"};Object.freeze(f);var g=function(a,c){e.info("getContent");a.isAjax=1;var d=b.appRequests().getRequestOpts();d.url=f.entrypoint;d.method="get";d.type="html";d.addHistory=!0;d.data=a;b.appRequests().getActionCall(d,function(a){var d=$("#content");d.empty().html(a);a=b.triggers().views;a.common(d);if(void 0!==c&&"function"===typeof a[c])a[c]();d=$(".mdl-layout__content");0<d.scrollTop()&&d.animate({scrollTop:0},1E3)})},m=function(a,
|
||||
c){$.magnificPopup.open({items:{src:a||"",type:"inline"},callbacks:{open:function(){var a=$("#box-popup");b.appTriggers().views.common(a);a.find(":input:text:visible:first").focus();void 0!==c&&"function"===typeof c.open&&c.open()},close:function(){void 0!==c&&"function"===typeof c.close&&c.close()}},showCloseBtn:!1})},w=function(a,c){var d=$('<div id="box-popup" class="image">'+c+"</div>"),h=d.find("img");if(0===h.length)return m(c);h.hide();$.magnificPopup.open({items:{src:d,type:"inline"},callbacks:{open:function(){var a=
|
||||
@@ -11,34 +11,34 @@ c){e.info("account:saveFavorite");var d="on"===a.data("status"),h=d?a.data("acti
|
||||
a.data("item-id");c.data=a.serialize();b.appRequests().getActionCall(c,function(a){b.msg.out(a);0===a.status&&void 0!==a.data.nextAction&&g({r:a.data.nextAction.nextAction},"account")})},menu:function(a){a.hide();a.parent().children(".actions-optional").show(250)},sort:function(a){e.info("account:sort");var b=$("#frmSearch");b.find('input[name="skey"]').val(a.data("key"));b.find('input[name="sorder"]').val(a.data("dir"));b.find('input[name="start"]').val(a.data("start"));q.search()},editPass:function(a){e.info("account:editpass");
|
||||
var c=a.data("parent-id"),c=void 0===c?a.data("item-id"):c;g(b.appRequests().getRouteForQuery(a.data("action-route"),c),"account")},saveEditRestore:function(a){e.info("account:restore");var c=b.appRequests().getRequestOpts();c.url=f.entrypoint+"?r="+a.data("action-route")+"/"+a.data("history-id")+"/"+a.data("item-id");c.data=a.serialize();b.appRequests().getActionCall(c,function(a){b.msg.out(a);void 0!==a.data.itemId&&void 0!==a.data.nextAction&&g(b.appRequests().getRouteForQuery(a.data.nextAction,
|
||||
a.data.itemId),"account")})},listFiles:function(a){e.info("account:getfiles");var c=b.appRequests().getRequestOpts();c.method="get";c.type="html";c.url=f.entrypoint;c.data={r:a.data("action-route")+"/"+a.data("item-id"),del:a.data("delete"),sk:b.sk.get()};b.appRequests().getActionCall(c,function(b){a.html(b)})},search:function(a){e.info("account:search");var c=$("#frmSearch");c.find("input[name='sk']").val(b.sk.get());c.find("input[name='skey']").val();c.find("input[name='sorder']").val();void 0!==
|
||||
a&&c.find("input[name='start']").val(0);a=b.appRequests().getRequestOpts();a.url=f.entrypoint+"?r="+c.data("action-route");a.method="get";a.data=c.serialize();b.appRequests().getActionCall(a,function(a){10===a.status&&b.msg.out(a);b.sk.set(a.data.sk);$("#res-content").empty().html(a.data.html)})},save:function(a){e.info("account:save");var c=b.appRequests().getRequestOpts();c.url=f.entrypoint+"?r="+a.data("action-route")+"/"+a.data("item-id");c.data=a.serialize();b.appRequests().getActionCall(c,function(a){b.msg.out(a);
|
||||
void 0!==a.data.itemId&&void 0!==a.data.nextAction&&g(b.appRequests().getRouteForQuery(a.data.nextAction,a.data.itemId),"account")})}},r={get:function(a){e.info("items:get");var c=a[0].selectize;c.clearOptions();c.load(function(d){var h=b.appRequests().getRequestOpts();h.url=f.entrypoint;h.method="get";h.data={r:a.data("action-route")+"/"+a.data("item-id"),sk:a.data("sk")};b.appRequests().getActionCall(h,function(h){d(h.data);c.setValue(a.data("selected-id"),!0);b.appTriggers().updateFormHash()})})},
|
||||
update:function(a){e.info("items:update");var c=$("#"+a.data("item-dst"))[0].selectize;c.clearOptions();c.load(function(c){var d=b.appRequests().getRequestOpts();d.url=f.entrypoint;d.method="get";d.data={r:a.data("item-route"),sk:b.sk.get()};b.appRequests().getActionCall(d,function(a){c(a)})})}},u={logout:function(){b.redirect("index.php?r=login/logout")},login:function(a){e.info("main:login");var c=b.appRequests().getRequestOpts();c.url=f.entrypoint+"?r="+a.data("route");c.method="get";c.data=a.serialize();
|
||||
b.appRequests().getActionCall(c,function(c){var d=$(".extra-hidden");switch(c.status){case 0:b.redirect(c.data.url);break;case 2:b.msg.out(c);a.find("input[type='text'],input[type='password']").val("");a.find("input:first").focus();0<d.length&&d.hide();$("#mpass").prop("disabled",!1).val("");$("#smpass").show();break;case 5:b.msg.out(c);a.find("input[type='text'],input[type='password']").val("");a.find("input:first").focus();0<d.length&&d.hide();$("#oldpass").prop("disabled",!1).val("");$("#soldpass").show();
|
||||
break;default:b.msg.out(c),a.find("input[type='text'],input[type='password']").val(""),a.find("input:first").focus()}})},install:function(a){e.info("main:install");var c=b.appRequests().getRequestOpts();c.url=f.entrypoint+"?r="+a.data("route");c.data=a.serialize();b.appRequests().getActionCall(c,function(a){b.msg.out(a);0===a.status&&setTimeout(function(){b.redirect("index.php?r=login/index")},1E3)})},upgrade:function(a){e.info("main:upgrade");var c='<div id="alert"><p id="alert-text">'+b.config().LANG[59]+
|
||||
"</p></div>";mdlDialog().show({text:c,negative:{title:b.config().LANG[44],onClick:function(a){a.preventDefault();b.msg.error(b.config().LANG[44])}},positive:{title:b.config().LANG[43],onClick:function(c){var d;(c=a.find("input[name='taskId']").val())&&(d=t(c));var e=b.appRequests().getRequestOpts();e.url=f.entrypoint+"?r="+a.data("action-route");e.method="get";e.useFullLoading=!!c;e.data=a.serialize();b.appRequests().getActionCall(e,function(c){b.msg.out(c);0!==c.status?a.find(":input[name=key]").val(""):
|
||||
(void 0!==d&&d.close(),setTimeout(function(){b.redirect("index.php")},5E3))})}}})},getUpdates:function(){e.info("main:getUpdates");var a=b.appRequests().getRequestOpts();a.url=f.entrypoint+"?r=status/checkRelease";a.method="get";a.timeout=1E4;a.useLoading=!1;a.data={isAjax:1};var c=$("#updates");b.appRequests().getActionCall(a,function(a){0===a.status?0<a.data.length?c.html('<a id="link-updates" href="'+a.data.url+'" target="_blank">'+a.data.title+'<div id="help-hasupdates" class="icon material-icons mdl-color-text--indigo-200">cloud_download</div></a><span for="link-updates" class="mdl-tooltip mdl-tooltip--top mdl-tooltip--large">'+
|
||||
a.data.description+"</span>"):c.html('<div id="updates-info" class="icon material-icons mdl-color-text--teal-200">check_circle</div><span for="updates-info" class="mdl-tooltip mdl-tooltip--top mdl-tooltip--large">'+b.config().LANG[68]+"</span>"):c.html('<div id="updates-info" class="icon material-icons mdl-color-text--amber-200">warning</div><span for="updates-info" class="mdl-tooltip mdl-tooltip--top mdl-tooltip--large">'+b.config().LANG[69]+"</span>");void 0!==componentHandler&&componentHandler.upgradeDom()},
|
||||
function(){c.html('<div id="updates-info" class="icon material-icons mdl-color-text--amber-200">warning</div><span for="updates-info" class="mdl-tooltip mdl-tooltip--top mdl-tooltip--large">'+b.config().LANG[69]+"</span>")})},getNotices:function(){e.info("main:getNotices");var a=b.appRequests().getRequestOpts();a.url=f.entrypoint+"?r=status/checkNotices";a.method="get";a.timeout=1E4;a.useLoading=!1;a.data={isAjax:1};var c=$("#notices");b.appRequests().getActionCall(a,function(a){0===a.status&&0<a.data.length&&
|
||||
c.html('<a href="https://github.com/nuxsmin/sysPass/labels/Notices" target="_blank"><div id="notices-info" class="material-icons mdl-badge mdl-badge--overlap mdl-color-text--amber-200" data-badge="'+a.data.length+'">feedback</div></a><span for="notices-info" class="mdl-tooltip mdl-tooltip--top mdl-tooltip--large"><div class="notices-title">'+b.config().LANG[70]+"</div>"+a.data.map(function(a){return a.title}).join("<br>")+"</span>");void 0!==componentHandler&&componentHandler.upgradeDom()})}},k={state:{tab:{index:0,
|
||||
refresh:!0,route:""},itemId:0,update:function(a){var b=$("#content").find("[id^='tabs-'].is-active");0<b.length&&(k.state.tab.refresh=!a.data("item-dst"),k.state.tab.index=b.data("tab-index"),k.state.tab.route=b.data("tab-route"),k.state.itemId=a.data("item-id"))}},save:function(a,c){e.info("tabs:save");k.state.update(a);var d=b.appRequests().getRequestOpts();d.url=f.entrypoint+"?r="+a.data("action-route");d.method=a.data("action-method")||"post";d.data=a.serialize()+"&sk="+b.sk.get();b.appRequests().getActionCall(d,
|
||||
function(d){b.msg.out(d);0===d.status&&("function"===typeof c&&c(),!0===k.state.tab.refresh?g({r:k.state.tab.route,tabIndex:k.state.tab.index}):void 0!==a.data("reload")&&(e.info("reload"),setTimeout(function(){b.redirect("index.php")},2E3)))})}},v={show:function(a){e.info("appMgmt:show");k.state.update(a);var c=b.appRequests().getRequestOpts();c.url=f.entrypoint;c.method="get";c.data={r:a.data("action-route")+"/"+a.data("item-id"),sk:b.sk.get(),isAjax:1};b.appRequests().getActionCall(c,function(c){if(0!==
|
||||
c.status)b.msg.out(c);else{var d=a.data("item-dst");m(c.data.html,{open:function(){d&&(k.state.tab.refresh=!1)},close:function(){d&&r.update(a)}})}})},"delete":function(a){e.info("appMgmt:delete");k.state.update(a);n["delete"](a,function(c){var d=a.data("item-id"),h=b.appRequests().getRequestOpts();h.url=f.entrypoint;h.method="get";h.data={r:a.data("action-route")+(d&&"/"+d),items:c,sk:b.sk.get(),isAjax:1};b.appRequests().getActionCall(h,function(a){b.msg.out(a);g({r:k.state.tab.route,tabIndex:k.state.tab.index})})})},
|
||||
save:function(a){e.info("appMgmt:save");k.save(a,function(){$.magnificPopup.close()})},search:function(a){e.info("appMgmt:search");n.search(a)},nav:function(a){e.info("appMgmt:nav");n.nav(a)}},n={search:function(a){e.info("grid:search");var c=$(a.data("target")),d=b.appRequests().getRequestOpts();d.url=f.entrypoint+"?r="+a.data("action-route");d.method="get";d.data=a.serialize();b.appRequests().getActionCall(d,function(a){0===a.status?c.html(a.data.html):c.html(b.msg.html.error(a.description));b.sk.set(a.csrf)})},
|
||||
nav:function(a,c){e.info("grid:nav");var d=$("#"+a.data("action-form"));d.find("[name='start']").val(a.data("start"));d.find("[name='count']").val(a.data("count"));d.find("[name='sk']").val(b.sk.get());"function"===typeof c?c(d):n.search(d)},"delete":function(a,c){var d='<div id="alert"><p id="alert-text">'+b.config().LANG[12]+"</p></div>",h=a.data("selection"),e=[];if(h&&($(h).find(".is-selected").each(function(){e.push($(this).data("item-id"))}),0===e.length))return;mdlDialog().show({text:d,negative:{title:b.config().LANG[44],
|
||||
onClick:function(a){a.preventDefault();b.msg.error(b.config().LANG[44])}},positive:{title:b.config().LANG[43],onClick:function(a){a.preventDefault();"function"===typeof c&&c(e)}}})}},t=function(a){var c=$("#taskStatus");c.empty().html(b.config().LANG[62]);var d=b.appRequests().getRequestOpts();d.method="get";d.url=f.entrypoint+"?r=task/runTask/"+a;return b.appRequests().getActionEvent(d,function(a){a=a.task+" - "+a.message+" - "+a.time+" - "+a.progress+"%";a+="<br>"+b.config().LANG[62];c.empty().html(a)})};
|
||||
return{doAction:function(a,c){var d={r:a.r+(void 0!==a.itemId?"/"+a.itemId:""),isAjax:1},e=b.appRequests().getRequestOpts();e.url=f.entrypoint;e.method="get";e.type="html";e.addHistory=!0;e.data=d;b.appRequests().getActionCall(e,function(a){var d=$("#content");d.empty().html(a);a=b.triggers().views;a.common(d);if(void 0!==c&&"function"===typeof a[c])a[c]();d=$(".mdl-layout__content");0<d.scrollTop()&&d.animate({scrollTop:0},1E3)})},appMgmt:v,account:q,file:{view:function(a){e.info("file:view");var c=
|
||||
b.appRequests().getRequestOpts();c.url=f.entrypoint;c.method="get";c.data={r:a.data("action-route")+"/"+a.data("item-id"),sk:b.sk.get()};b.appRequests().getActionCall(c,function(c){if(0!==c.status)return b.msg.out(c);w(a,c.data.html)})},download:function(a){e.info("file:download");a={r:a.data("action-route")+"/"+a.data("item-id"),sk:b.sk.get()};$.fileDownload(f.entrypoint,{httpMethod:"GET",data:a})},"delete":function(a){e.info("file:delete");var c='<div id="alert"><p id="alert-text">'+b.config().LANG[15]+
|
||||
"</p></div>";mdlDialog().show({text:c,negative:{title:b.config().LANG[44],onClick:function(a){a.preventDefault();b.msg.error(b.config().LANG[44])}},positive:{title:b.config().LANG[43],onClick:function(c){c=b.appRequests().getRequestOpts();c.url=f.entrypoint;c.method="get";c.data={r:a.data("action-route")+"/"+a.data("item-id"),sk:b.sk.get()};b.appRequests().getActionCall(c,function(a){b.msg.out(a);0===a.status&&q.listFiles($("#list-account-files"))})}}})}},checks:{wiki:function(a){e.info("checks:wiki");
|
||||
a=$(a.data("src"));a.find("[name='sk']").val(b.sk.get());var c=b.appRequests().getRequestOpts();c.url=f.entrypoint;c.data=a.serialize();b.appRequests().getActionCall(c,function(a){b.msg.out(a);0===a.status&&$("#dokuWikiResCheck").html(a.data)})}},config:{save:function(a){e.info("config:save");k.save(a)},masterpass:function(a){var c='<div id="alert"><p id="alert-text">'+b.config().LANG[59]+"</p></div>";mdlDialog().show({text:c,negative:{title:b.config().LANG[44],onClick:function(c){c.preventDefault();
|
||||
b.msg.error(b.config().LANG[44]);a.find(":input[type=password]").val("")}},positive:{title:b.config().LANG[43],onClick:function(c){var d;(c=a.find("input[name='taskId']").val())&&(d=t(c));var e=b.appRequests().getRequestOpts();e.url=f.entrypoint;e.useFullLoading=!!c;e.data=a.serialize();b.appRequests().getActionCall(e,function(c){b.msg.out(c);a.find(":input[type=password]").val("");void 0!==d&&d.close()})}}})},backup:function(a){e.info("config:backup");k.state.update(a);var c=b.appRequests().getRequestOpts();
|
||||
c.url=f.entrypoint+"?r="+a.data("action-route");c.useFullLoading=!0;c.data=a.serialize()+"&sk="+b.sk.get();b.appRequests().getActionCall(c,function(a){b.msg.out(a);0===a.status&&g({r:k.state.tab.route,tabIndex:k.state.tab.index})})},"export":function(a){e.info("config:export");k.save(a)},"import":function(a){e.info("config:import");var c=b.appRequests().getRequestOpts();c.url=f.entrypoint+"?r="+a.data("action-route");c.data=a.serialize()+"&sk="+b.sk.get();b.appRequests().getActionCall(c,function(a){b.msg.out(a)})},
|
||||
refreshMpass:function(a){e.info("config:import");var c=b.appRequests().getRequestOpts();c.url=f.entrypoint+"?r="+a.data("action-route");c.data={sk:a.data("sk"),isAjax:1};b.appRequests().getActionCall(c,function(a){b.msg.out(a)})},mailCheck:function(a){e.info("config:mailCheck");var c=$(a.data("src")),d=b.appRequests().getRequestOpts();d.url=f.entrypoint+"?r="+a.data("action-route");d.data=c.serialize()+"&sk="+b.sk.get();b.appRequests().getActionCall(d,function(a){b.msg.out(a)})}},main:u,user:{showSettings:function(a){e.info("user:showSettings");
|
||||
g({r:a.data("action-route")},"userSettings")},saveSettings:function(a){e.info("user:saveSettings");k.save(a)},password:function(a){e.info("user:password");var c=b.appRequests().getRequestOpts();c.type="html";c.method="get";c.url=f.entrypoint;c.data={r:a.data("action-route")+"/"+a.data("item-id"),sk:b.sk.get(),isAjax:1};b.appRequests().getActionCall(c,function(a){0===a.length?u.logout():m(a)})},passreset:function(a){e.info("user:passreset");var c=b.appRequests().getRequestOpts();c.url=f.entrypoint+
|
||||
"/?r="+a.data("action-route");c.data=a.serialize();b.appRequests().getActionCall(c,function(a){b.msg.out(a);0===a.status&&setTimeout(function(){b.redirect("index.php")},2E3)})}},link:{save:function(a){e.info("link:save");var c=function(c){var d=a.data("item-id"),e=b.appRequests().getRequestOpts();d?e.url=f.entrypoint+"?r="+a.data("action-route")+"/"+d+"/"+c:(e.url=f.entrypoint+"?r="+a.data("action-route"),e.data=a.serialize());b.appRequests().getActionCall(e,function(c){b.msg.out(c);0===c.status&&
|
||||
g({r:a.data("action-next")+"/"+d})})},d='<div id="alert"><p id="alert-text">'+b.config().LANG[48]+"</p></div>";mdlDialog().show({text:d,negative:{title:b.config().LANG[44],onClick:function(a){a.preventDefault();c(0)}},positive:{title:b.config().LANG[43],onClick:function(a){a.preventDefault();c(1)}}})},refresh:function(a){e.info("link:refresh");k.state.update(a);var c=a.data("item-id"),d=b.appRequests().getRequestOpts();d.url=f.entrypoint;d.method="get";d.data={r:a.data("action-route")+"/"+c,sk:b.sk.get(),
|
||||
isAjax:1};b.appRequests().getActionCall(d,function(d){b.msg.out(d);0===d.status&&((d=a.data("action-next"))?g({r:d+"/"+c}):g({r:k.state.tab.route,tabIndex:k.state.tab.index}))})}},eventlog:{search:function(a){e.info("eventlog:search");n.search(a)},nav:function(a){e.info("eventlog:nav");n.nav(a)},clear:function(a){var c='<div id="alert"><p id="alert-text">'+b.config().LANG[20]+"</p></div>";mdlDialog().show({text:c,negative:{title:b.config().LANG[44],onClick:function(a){a.preventDefault();b.msg.error(b.config().LANG[44])}},
|
||||
positive:{title:b.config().LANG[43],onClick:function(c){c.preventDefault();c=b.appRequests().getRequestOpts();c.url=f.entrypoint+"?r="+a.data("action-route");c.method="get";c.data={sk:b.sk.get(),isAjax:1};b.appRequests().getActionCall(c,function(c){b.msg.out(c);0===c.status&&g({r:a.data("nextaction")});b.sk.set(c.csrf)})}}})}},ajaxUrl:f,plugin:{toggle:function(a){e.info("plugin:enable");k.save(a,function(){setTimeout(function(){b.redirect("index.php")},2E3)})},reset:function(a){e.info("plugin:reset");
|
||||
a&&c.find("input[name='start']").val(0);a=b.appRequests().getRequestOpts();a.url=f.entrypoint+"?r="+c.data("action-route");a.method="get";a.data=c.serialize();b.appRequests().getActionCall(a,function(a){10===a.status&&b.msg.out(a);b.sk.set(a.data.sk);$("#res-content").empty().html(a.data.html)})},save:function(a){e.info("account:save");var c=b.appRequests().getRequestOpts();c.url=f.entrypoint+"?r="+a.data("action-route")+"/"+a.data("item-id");c.data=a.serialize();$("select.select-box-tags[data-hash][data-updated=true]").each(function(a,
|
||||
b){c.data+="&"+b.getAttribute("id")+"_update=1"});b.appRequests().getActionCall(c,function(a){b.msg.out(a);void 0!==a.data.itemId&&void 0!==a.data.nextAction&&g(b.appRequests().getRouteForQuery(a.data.nextAction,a.data.itemId),"account")})}},r={get:function(a){e.info("items:get");var c=a[0].selectize;c.clearOptions();c.load(function(d){var h=b.appRequests().getRequestOpts();h.url=f.entrypoint;h.method="get";h.data={r:a.data("action-route")+"/"+a.data("item-id"),sk:a.data("sk")};b.appRequests().getActionCall(h,
|
||||
function(h){d(h.data);c.setValue(a.data("selected-id"),!0);b.appTriggers().updateFormHash()})})},update:function(a){e.info("items:update");var c=$("#"+a.data("item-dst"))[0].selectize;c.clearOptions();c.load(function(c){var d=b.appRequests().getRequestOpts();d.url=f.entrypoint;d.method="get";d.data={r:a.data("item-route"),sk:b.sk.get()};b.appRequests().getActionCall(d,function(a){c(a)})})}},u={logout:function(){b.redirect("index.php?r=login/logout")},login:function(a){e.info("main:login");var c=b.appRequests().getRequestOpts();
|
||||
c.url=f.entrypoint+"?r="+a.data("route");c.method="get";c.data=a.serialize();b.appRequests().getActionCall(c,function(c){var d=$(".extra-hidden");switch(c.status){case 0:b.redirect(c.data.url);break;case 2:b.msg.out(c);a.find("input[type='text'],input[type='password']").val("");a.find("input:first").focus();0<d.length&&d.hide();$("#mpass").prop("disabled",!1).val("");$("#smpass").show();break;case 5:b.msg.out(c);a.find("input[type='text'],input[type='password']").val("");a.find("input:first").focus();
|
||||
0<d.length&&d.hide();$("#oldpass").prop("disabled",!1).val("");$("#soldpass").show();break;default:b.msg.out(c),a.find("input[type='text'],input[type='password']").val(""),a.find("input:first").focus()}})},install:function(a){e.info("main:install");var c=b.appRequests().getRequestOpts();c.url=f.entrypoint+"?r="+a.data("route");c.data=a.serialize();b.appRequests().getActionCall(c,function(a){b.msg.out(a);0===a.status&&setTimeout(function(){b.redirect("index.php?r=login/index")},1E3)})},upgrade:function(a){e.info("main:upgrade");
|
||||
var c='<div id="alert"><p id="alert-text">'+b.config().LANG[59]+"</p></div>";mdlDialog().show({text:c,negative:{title:b.config().LANG[44],onClick:function(a){a.preventDefault();b.msg.error(b.config().LANG[44])}},positive:{title:b.config().LANG[43],onClick:function(c){var d;(c=a.find("input[name='taskId']").val())&&(d=t(c));var e=b.appRequests().getRequestOpts();e.url=f.entrypoint+"?r="+a.data("action-route");e.method="get";e.useFullLoading=!!c;e.data=a.serialize();b.appRequests().getActionCall(e,
|
||||
function(c){b.msg.out(c);0!==c.status?a.find(":input[name=key]").val(""):(void 0!==d&&d.close(),setTimeout(function(){b.redirect("index.php")},5E3))})}}})},getUpdates:function(){e.info("main:getUpdates");var a=b.appRequests().getRequestOpts();a.url=f.entrypoint+"?r=status/checkRelease";a.method="get";a.timeout=1E4;a.useLoading=!1;a.data={isAjax:1};var c=$("#updates");b.appRequests().getActionCall(a,function(a){0===a.status?0<a.data.length?c.html('<a id="link-updates" href="'+a.data.url+'" target="_blank">'+
|
||||
a.data.title+'<div id="help-hasupdates" class="icon material-icons mdl-color-text--indigo-200">cloud_download</div></a><span for="link-updates" class="mdl-tooltip mdl-tooltip--top mdl-tooltip--large">'+a.data.description+"</span>"):c.html('<div id="updates-info" class="icon material-icons mdl-color-text--teal-200">check_circle</div><span for="updates-info" class="mdl-tooltip mdl-tooltip--top mdl-tooltip--large">'+b.config().LANG[68]+"</span>"):c.html('<div id="updates-info" class="icon material-icons mdl-color-text--amber-200">warning</div><span for="updates-info" class="mdl-tooltip mdl-tooltip--top mdl-tooltip--large">'+
|
||||
b.config().LANG[69]+"</span>");void 0!==componentHandler&&componentHandler.upgradeDom()},function(){c.html('<div id="updates-info" class="icon material-icons mdl-color-text--amber-200">warning</div><span for="updates-info" class="mdl-tooltip mdl-tooltip--top mdl-tooltip--large">'+b.config().LANG[69]+"</span>")})},getNotices:function(){e.info("main:getNotices");var a=b.appRequests().getRequestOpts();a.url=f.entrypoint+"?r=status/checkNotices";a.method="get";a.timeout=1E4;a.useLoading=!1;a.data={isAjax:1};
|
||||
var c=$("#notices");b.appRequests().getActionCall(a,function(a){0===a.status&&0<a.data.length&&c.html('<a href="https://github.com/nuxsmin/sysPass/labels/Notices" target="_blank"><div id="notices-info" class="material-icons mdl-badge mdl-badge--overlap mdl-color-text--amber-200" data-badge="'+a.data.length+'">feedback</div></a><span for="notices-info" class="mdl-tooltip mdl-tooltip--top mdl-tooltip--large"><div class="notices-title">'+b.config().LANG[70]+"</div>"+a.data.map(function(a){return a.title}).join("<br>")+
|
||||
"</span>");void 0!==componentHandler&&componentHandler.upgradeDom()})}},k={state:{tab:{index:0,refresh:!0,route:""},itemId:0,update:function(a){var b=$("#content").find("[id^='tabs-'].is-active");0<b.length&&(k.state.tab.refresh=!a.data("item-dst"),k.state.tab.index=b.data("tab-index"),k.state.tab.route=b.data("tab-route"),k.state.itemId=a.data("item-id"))}},save:function(a,c){e.info("tabs:save");k.state.update(a);var d=b.appRequests().getRequestOpts();d.url=f.entrypoint+"?r="+a.data("action-route");
|
||||
d.method=a.data("action-method")||"post";d.data=a.serialize()+"&sk="+b.sk.get();b.appRequests().getActionCall(d,function(d){b.msg.out(d);0===d.status&&("function"===typeof c&&c(),!0===k.state.tab.refresh?g({r:k.state.tab.route,tabIndex:k.state.tab.index}):void 0!==a.data("reload")&&(e.info("reload"),setTimeout(function(){b.redirect("index.php")},2E3)))})}},v={show:function(a){e.info("appMgmt:show");k.state.update(a);var c=b.appRequests().getRequestOpts();c.url=f.entrypoint;c.method="get";c.data={r:a.data("action-route")+
|
||||
"/"+a.data("item-id"),sk:b.sk.get(),isAjax:1};b.appRequests().getActionCall(c,function(c){if(0!==c.status)b.msg.out(c);else{var d=a.data("item-dst");m(c.data.html,{open:function(){d&&(k.state.tab.refresh=!1)},close:function(){d&&r.update(a)}})}})},"delete":function(a){e.info("appMgmt:delete");k.state.update(a);n["delete"](a,function(c){var d=a.data("item-id"),h=b.appRequests().getRequestOpts();h.url=f.entrypoint;h.method="get";h.data={r:a.data("action-route")+(d&&"/"+d),items:c,sk:b.sk.get(),isAjax:1};
|
||||
b.appRequests().getActionCall(h,function(a){b.msg.out(a);g({r:k.state.tab.route,tabIndex:k.state.tab.index})})})},save:function(a){e.info("appMgmt:save");k.save(a,function(){$.magnificPopup.close()})},search:function(a){e.info("appMgmt:search");n.search(a)},nav:function(a){e.info("appMgmt:nav");n.nav(a)}},n={search:function(a){e.info("grid:search");var c=$(a.data("target")),d=b.appRequests().getRequestOpts();d.url=f.entrypoint+"?r="+a.data("action-route");d.method="get";d.data=a.serialize();b.appRequests().getActionCall(d,
|
||||
function(a){0===a.status?c.html(a.data.html):c.html(b.msg.html.error(a.description));b.sk.set(a.csrf)})},nav:function(a,c){e.info("grid:nav");var d=$("#"+a.data("action-form"));d.find("[name='start']").val(a.data("start"));d.find("[name='count']").val(a.data("count"));d.find("[name='sk']").val(b.sk.get());"function"===typeof c?c(d):n.search(d)},"delete":function(a,c){var d='<div id="alert"><p id="alert-text">'+b.config().LANG[12]+"</p></div>",h=a.data("selection"),e=[];if(h&&($(h).find(".is-selected").each(function(){e.push($(this).data("item-id"))}),
|
||||
0===e.length))return;mdlDialog().show({text:d,negative:{title:b.config().LANG[44],onClick:function(a){a.preventDefault();b.msg.error(b.config().LANG[44])}},positive:{title:b.config().LANG[43],onClick:function(a){a.preventDefault();"function"===typeof c&&c(e)}}})}},t=function(a){var c=$("#taskStatus");c.empty().html(b.config().LANG[62]);var d=b.appRequests().getRequestOpts();d.method="get";d.url=f.entrypoint+"?r=task/runTask/"+a;return b.appRequests().getActionEvent(d,function(a){a=a.task+" - "+a.message+
|
||||
" - "+a.time+" - "+a.progress+"%";a+="<br>"+b.config().LANG[62];c.empty().html(a)})};return{doAction:function(a,c){var d={r:a.r+(void 0!==a.itemId?"/"+a.itemId:""),isAjax:1},e=b.appRequests().getRequestOpts();e.url=f.entrypoint;e.method="get";e.type="html";e.addHistory=!0;e.data=d;b.appRequests().getActionCall(e,function(a){var d=$("#content");d.empty().html(a);a=b.triggers().views;a.common(d);if(void 0!==c&&"function"===typeof a[c])a[c]();d=$(".mdl-layout__content");0<d.scrollTop()&&d.animate({scrollTop:0},
|
||||
1E3)})},appMgmt:v,account:q,file:{view:function(a){e.info("file:view");var c=b.appRequests().getRequestOpts();c.url=f.entrypoint;c.method="get";c.data={r:a.data("action-route")+"/"+a.data("item-id"),sk:b.sk.get()};b.appRequests().getActionCall(c,function(c){if(0!==c.status)return b.msg.out(c);w(a,c.data.html)})},download:function(a){e.info("file:download");a={r:a.data("action-route")+"/"+a.data("item-id"),sk:b.sk.get()};$.fileDownload(f.entrypoint,{httpMethod:"GET",data:a})},"delete":function(a){e.info("file:delete");
|
||||
var c='<div id="alert"><p id="alert-text">'+b.config().LANG[15]+"</p></div>";mdlDialog().show({text:c,negative:{title:b.config().LANG[44],onClick:function(a){a.preventDefault();b.msg.error(b.config().LANG[44])}},positive:{title:b.config().LANG[43],onClick:function(c){c=b.appRequests().getRequestOpts();c.url=f.entrypoint;c.method="get";c.data={r:a.data("action-route")+"/"+a.data("item-id"),sk:b.sk.get()};b.appRequests().getActionCall(c,function(a){b.msg.out(a);0===a.status&&q.listFiles($("#list-account-files"))})}}})}},
|
||||
checks:{wiki:function(a){e.info("checks:wiki");a=$(a.data("src"));a.find("[name='sk']").val(b.sk.get());var c=b.appRequests().getRequestOpts();c.url=f.entrypoint;c.data=a.serialize();b.appRequests().getActionCall(c,function(a){b.msg.out(a);0===a.status&&$("#dokuWikiResCheck").html(a.data)})}},config:{save:function(a){e.info("config:save");k.save(a)},masterpass:function(a){var c='<div id="alert"><p id="alert-text">'+b.config().LANG[59]+"</p></div>";mdlDialog().show({text:c,negative:{title:b.config().LANG[44],
|
||||
onClick:function(c){c.preventDefault();b.msg.error(b.config().LANG[44]);a.find(":input[type=password]").val("")}},positive:{title:b.config().LANG[43],onClick:function(c){var d;(c=a.find("input[name='taskId']").val())&&(d=t(c));var e=b.appRequests().getRequestOpts();e.url=f.entrypoint;e.useFullLoading=!!c;e.data=a.serialize();b.appRequests().getActionCall(e,function(c){b.msg.out(c);a.find(":input[type=password]").val("");void 0!==d&&d.close()})}}})},backup:function(a){e.info("config:backup");k.state.update(a);
|
||||
var c=b.appRequests().getRequestOpts();c.url=f.entrypoint+"?r="+a.data("action-route");c.useFullLoading=!0;c.data=a.serialize()+"&sk="+b.sk.get();b.appRequests().getActionCall(c,function(a){b.msg.out(a);0===a.status&&g({r:k.state.tab.route,tabIndex:k.state.tab.index})})},"export":function(a){e.info("config:export");k.save(a)},"import":function(a){e.info("config:import");var c=b.appRequests().getRequestOpts();c.url=f.entrypoint+"?r="+a.data("action-route");c.data=a.serialize()+"&sk="+b.sk.get();b.appRequests().getActionCall(c,
|
||||
function(a){b.msg.out(a)})},refreshMpass:function(a){e.info("config:import");var c=b.appRequests().getRequestOpts();c.url=f.entrypoint+"?r="+a.data("action-route");c.data={sk:a.data("sk"),isAjax:1};b.appRequests().getActionCall(c,function(a){b.msg.out(a)})},mailCheck:function(a){e.info("config:mailCheck");var c=$(a.data("src")),d=b.appRequests().getRequestOpts();d.url=f.entrypoint+"?r="+a.data("action-route");d.data=c.serialize()+"&sk="+b.sk.get();b.appRequests().getActionCall(d,function(a){b.msg.out(a)})}},
|
||||
main:u,user:{showSettings:function(a){e.info("user:showSettings");g({r:a.data("action-route")},"userSettings")},saveSettings:function(a){e.info("user:saveSettings");k.save(a)},password:function(a){e.info("user:password");var c=b.appRequests().getRequestOpts();c.type="html";c.method="get";c.url=f.entrypoint;c.data={r:a.data("action-route")+"/"+a.data("item-id"),sk:b.sk.get(),isAjax:1};b.appRequests().getActionCall(c,function(a){0===a.length?u.logout():m(a)})},passreset:function(a){e.info("user:passreset");
|
||||
var c=b.appRequests().getRequestOpts();c.url=f.entrypoint+"/?r="+a.data("action-route");c.data=a.serialize();b.appRequests().getActionCall(c,function(a){b.msg.out(a);0===a.status&&setTimeout(function(){b.redirect("index.php")},2E3)})}},link:{save:function(a){e.info("link:save");var c=function(c){var d=a.data("item-id"),e=b.appRequests().getRequestOpts();d?e.url=f.entrypoint+"?r="+a.data("action-route")+"/"+d+"/"+c:(e.url=f.entrypoint+"?r="+a.data("action-route"),e.data=a.serialize());b.appRequests().getActionCall(e,
|
||||
function(c){b.msg.out(c);0===c.status&&g({r:a.data("action-next")+"/"+d})})},d='<div id="alert"><p id="alert-text">'+b.config().LANG[48]+"</p></div>";mdlDialog().show({text:d,negative:{title:b.config().LANG[44],onClick:function(a){a.preventDefault();c(0)}},positive:{title:b.config().LANG[43],onClick:function(a){a.preventDefault();c(1)}}})},refresh:function(a){e.info("link:refresh");k.state.update(a);var c=a.data("item-id"),d=b.appRequests().getRequestOpts();d.url=f.entrypoint;d.method="get";d.data=
|
||||
{r:a.data("action-route")+"/"+c,sk:b.sk.get(),isAjax:1};b.appRequests().getActionCall(d,function(d){b.msg.out(d);0===d.status&&((d=a.data("action-next"))?g({r:d+"/"+c}):g({r:k.state.tab.route,tabIndex:k.state.tab.index}))})}},eventlog:{search:function(a){e.info("eventlog:search");n.search(a)},nav:function(a){e.info("eventlog:nav");n.nav(a)},clear:function(a){var c='<div id="alert"><p id="alert-text">'+b.config().LANG[20]+"</p></div>";mdlDialog().show({text:c,negative:{title:b.config().LANG[44],onClick:function(a){a.preventDefault();
|
||||
b.msg.error(b.config().LANG[44])}},positive:{title:b.config().LANG[43],onClick:function(c){c.preventDefault();c=b.appRequests().getRequestOpts();c.url=f.entrypoint+"?r="+a.data("action-route");c.method="get";c.data={sk:b.sk.get(),isAjax:1};b.appRequests().getActionCall(c,function(c){b.msg.out(c);0===c.status&&g({r:a.data("nextaction")});b.sk.set(c.csrf)})}}})}},ajaxUrl:f,plugin:{toggle:function(a){e.info("plugin:enable");k.save(a,function(){setTimeout(function(){b.redirect("index.php")},2E3)})},reset:function(a){e.info("plugin:reset");
|
||||
var c='<div id="alert"><p id="alert-text">'+b.config().LANG[58]+"</p></div>";mdlDialog().show({text:c,negative:{title:b.config().LANG[44],onClick:function(a){a.preventDefault();b.msg.error(b.config().LANG[44])}},positive:{title:b.config().LANG[43],onClick:function(b){b.preventDefault();k.save(a)}}})}},notification:{check:function(a){e.info("notification:check");var c=b.appRequests().getRequestOpts();c.url=f.entrypoint;c.method="get";c.data={r:a.data("action-route")+"/"+a.data("item-id"),sk:b.sk.get(),
|
||||
isAjax:1};b.appRequests().getActionCall(c,function(c){b.msg.out(c);0===c.status&&g({r:a.data("nextaction")});b.sk.set(c.csrf)})},search:function(a){e.info("notification:search");n.search(a)},show:function(a){e.info("notification:show");v.show(a)},save:function(a){e.info("notification:save");var c=b.appRequests().getRequestOpts();c.url=f.entrypoint+"?r="+a.data("route");c.data=a.serialize();b.appRequests().getActionCall(c,function(c){b.msg.out(c);0===c.status&&(g({r:a.data("nextaction")}),$.magnificPopup.close())})},
|
||||
"delete":function(a){e.info("notification:delete");n["delete"](a,function(c){var d=a.data("item-id"),e=b.appRequests().getRequestOpts();e.url=f.entrypoint;e.method="get";e.data={r:a.data("action-route")+(d?"/"+d:""),items:c,sk:b.sk.get(),isAjax:1};b.appRequests().getActionCall(e,function(c){b.msg.out(c);g({r:a.data("nextaction")})})})},getActive:function(){e.info("notification:getActive");var a=b.appRequests().getRequestOpts();a.url=f.entrypoint;a.method="get";a.data={r:"items/notifications",sk:b.sk.get(),
|
||||
|
||||
@@ -418,56 +418,31 @@ sysPass.Triggers = function (Common) {
|
||||
Common.appActions().items.get($selParentAccount);
|
||||
}
|
||||
|
||||
const $selTags = $("#tags");
|
||||
$('.select-box-tags').selectize({
|
||||
persist: false,
|
||||
valueField: 'id',
|
||||
labelField: 'name',
|
||||
searchField: ['name'],
|
||||
plugins: ['remove_button'],
|
||||
onInitialize: function () {
|
||||
const input = this.$input[0];
|
||||
const attribute = document.createAttribute("data-hash");
|
||||
attribute.value = SparkMD5.hash(this.getValue().join(), false);
|
||||
|
||||
if ($selTags.length > 0) {
|
||||
$selTags.selectize({
|
||||
persist: false,
|
||||
maxItems: null,
|
||||
valueField: "id",
|
||||
labelField: "name",
|
||||
searchField: ["name"],
|
||||
plugins: ["remove_button"]
|
||||
});
|
||||
}
|
||||
input.setAttributeNode(attribute);
|
||||
|
||||
const $otherUsers = $('#other_users');
|
||||
|
||||
if ($otherUsers.length > 0) {
|
||||
$otherUsers.selectize({
|
||||
persist: false,
|
||||
valueField: 'id',
|
||||
labelField: 'name',
|
||||
searchField: ['name'],
|
||||
plugins: ['remove_button'],
|
||||
onInitialize: function () {
|
||||
const userId = $otherUsers.data('userId');
|
||||
|
||||
if (userId > 0) {
|
||||
this.removeOption(userId);
|
||||
}
|
||||
if (typeof input.dataset.currentItemId !== "undefined") {
|
||||
this.removeOption(input.dataset.currentItemId, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
onChange: function () {
|
||||
const input = this.$input[0];
|
||||
const attribute = document.createAttribute("data-updated");
|
||||
attribute.value = SparkMD5.hash(this.getValue().join(), false) !== input.dataset.hash && "true";
|
||||
|
||||
const $otherUserGroups = $('#other_usergroups');
|
||||
|
||||
if ($otherUserGroups.length > 0) {
|
||||
$otherUserGroups.selectize({
|
||||
persist: false,
|
||||
valueField: 'id',
|
||||
labelField: 'name',
|
||||
searchField: ['name'],
|
||||
plugins: ['remove_button'],
|
||||
onInitialize: function () {
|
||||
const userGroupId = $otherUserGroups.data('userGroupId');
|
||||
|
||||
if (userGroupId > 0) {
|
||||
this.removeOption(userGroupId);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
input.setAttributeNode(attribute);
|
||||
}
|
||||
});
|
||||
|
||||
$('input:text:visible:first').focus();
|
||||
},
|
||||
|
||||
34
public/js/app-triggers.min.js
vendored
34
public/js/app-triggers.min.js
vendored
@@ -1,17 +1,17 @@
|
||||
var $jscomp={scope:{},findInternal:function(b,e,d){b instanceof String&&(b=String(b));for(var f=b.length,a=0;a<f;a++){var c=b[a];if(e.call(d,c,a,b))return{i:a,v:c}}return{i:-1,v:void 0}}};$jscomp.defineProperty="function"==typeof Object.defineProperties?Object.defineProperty:function(b,e,d){if(d.get||d.set)throw new TypeError("ES3 does not support getters and setters.");b!=Array.prototype&&b!=Object.prototype&&(b[e]=d.value)};
|
||||
$jscomp.getGlobal=function(b){return"undefined"!=typeof window&&window===b?b:"undefined"!=typeof global?global:b};$jscomp.global=$jscomp.getGlobal(this);$jscomp.polyfill=function(b,e,d,f){if(e){d=$jscomp.global;b=b.split(".");for(f=0;f<b.length-1;f++){var a=b[f];a in d||(d[a]={});d=d[a]}b=b[b.length-1];f=d[b];e=e(f);e!=f&&null!=e&&$jscomp.defineProperty(d,b,{configurable:!0,writable:!0,value:e})}};
|
||||
$jscomp.polyfill("Array.prototype.find",function(b){return b?b:function(b,d){return $jscomp.findInternal(this,b,d).v}},"es6-impl","es3");
|
||||
sysPass.Triggers=function(b){var e=b.log,d=function(a){var c={valueField:"id",labelField:"name",searchField:["name"]};a.find(".select-box").each(function(a){var e=$(this);c.plugins=e.hasClass("select-box-deselect")?{clear_selection:{title:b.config().LANG[51]}}:{};if(e.data("onchange")){var g=e.data("onchange").split("/");c.onChange=function(a){if(0<a)if(2===g.length)sysPassApp.actions()[g[0]][g[1]](e);else sysPassApp.actions()[g[0]](e)}}e.selectize(c)});a.find("#allowed_exts").selectize({create:function(a){return{value:a.toUpperCase(),
|
||||
text:a.toUpperCase()}},createFilter:/^[a-z0-9]{1,4}$/i,plugins:["remove_button"]});a.find("#wikifilter").selectize({create:!0,createFilter:/^[a-z0-9:._-]+$/i,plugins:["remove_button"]});a.find(".select-items-tag").selectize({create:function(a){return{value:a.toLowerCase(),text:a.toLowerCase()}},createFilter:/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/,plugins:["remove_button"]})},f={main:function(a){e.info("views:main");
|
||||
clipboard.isSupported()||b.msg.info(b.config().LANG[65]);$(".btn-menu").click(function(){var a=$(this);"1"===a.attr("data-history-reset")&&b.appRequests().history.reset();b.appActions().doAction({r:a.data("route")},a.data("view"))});$("#btnLogout").click(function(a){b.appActions().main.logout()});if(0===a.data("upgraded"))b.appActions().doAction({r:"account/index"},"search");else{a=$("#content");var c=a.data("page");f.common(a);if(""!==c&&"function"===typeof f[c])f[c]()}!0===b.config().CHECK_UPDATES&&
|
||||
b.appActions().main.getUpdates();!0===b.config().CHECK_NOTICES&&b.appActions().main.getNotices();"function"===typeof b.appTheme().viewsTriggers.main&&b.appTheme().viewsTriggers.main()},search:function(){e.info("views:search");var a=$("#frmSearch");0!==a.length&&(a.find("input[name='search']").on("keyup",function(b){b.preventDefault();13!==b.which&&13!==b.keyCode||a.submit()}),a.find("select, #rpp").on("change",function(){a.submit()}),a.find("button.btn-clear").on("click",function(b){b.preventDefault();
|
||||
a.find('input[name="searchfav"]').val(0);a[0].reset()}),a.find("input:text:visible:first").focus(),$("#globalSearch").click(function(){var b=1==$(this).prop("checked")?1:0;a.find("input[name='gsearch']").val(b);a.submit()}),"function"===typeof b.appTheme().viewsTriggers.search&&b.appTheme().viewsTriggers.search())},login:function(){e.info("views:login");var a=$("#frmLogin");b.config().AUTHBASIC_AUTOLOGIN&&"0"===a.find("input[name='loggedOut']").val()&&(e.info("views:login:autologin"),b.msg.info(b.config().LANG[66]),
|
||||
b.appActions().main.login(a))},userpassreset:function(){e.info("views:userpassreset");var a=$("#frmUserPassReset");b.appTheme().passwordDetect(a)},footer:function(){e.info("views:footer")},common:function(a){e.info("views:common");d(a);var c=a.find(":input [name='sk']");0<c.length&&b.sk.set(c.val());"function"===typeof b.appTheme().viewsTriggers.common&&b.appTheme().viewsTriggers.common(a);b.appTriggers().updateFormHash(a)},datatabs:function(){e.info("views:datatabs");$(".datagrid-action-search>form").each(function(){var a=
|
||||
$(this);a.find("button.btn-clear").on("click",function(b){b.preventDefault();a.trigger("reset")})})},config:function(){e.info("views:config");var a=$("#drop-import-files");if(0<a.length){var c=b.fileUpload(a);c.url=b.appActions().ajaxUrl.entrypoint+"?r="+a.data("action-route");c.allowedExts=b.config().IMPORT_ALLOWED_EXTS;c.beforeSendAction=function(){c.setRequestData({sk:b.sk.get(),csvDelimiter:$("#csvDelimiter").val(),importPwd:$("#importPwd").val(),importMasterPwd:$("#importMasterPwd").val(),import_defaultuser:$("#import_defaultuser").val(),
|
||||
import_defaultgroup:$("#import_defaultgroup").val()})}}},account:function(){e.info("views:account");var a=$("#list-account-files");0<a.length&&b.appActions().account.listFiles(a);var c=$("#drop-account-files");if(0<c.length){var g=b.fileUpload(c);g.url=b.appActions().ajaxUrl.entrypoint+"?r="+c.data("action-route")+"/"+c.data("item-id");g.allowedExts=b.config().FILES_ALLOWED_EXTS;g.requestDoneAction=function(){b.appActions().account.listFiles(a)}}c=$("#parent_account_id");0<c.length&&(c.on("change",
|
||||
function(){var a=$(this),b=$("#accountpass,#accountpassR");0<a[0].value?b.each(function(){$(this).prop("disabled","true");$(this).prop("required","false")}):b.each(function(){$(this).prop("disabled","");$(this).prop("required","true")})}),b.appActions().items.get(c));c=$("#tags");0<c.length&&c.selectize({persist:!1,maxItems:null,valueField:"id",labelField:"name",searchField:["name"],plugins:["remove_button"]});var d=$("#other_users");0<d.length&&d.selectize({persist:!1,valueField:"id",labelField:"name",
|
||||
searchField:["name"],plugins:["remove_button"],onInitialize:function(){var a=d.data("userId");0<a&&this.removeOption(a)}});var f=$("#other_usergroups");0<f.length&&f.selectize({persist:!1,valueField:"id",labelField:"name",searchField:["name"],plugins:["remove_button"],onInitialize:function(){var a=f.data("userGroupId");0<a&&this.removeOption(a)}});$("input:text:visible:first").focus()},install:function(){e.info("views:install");var a=$("#frmInstall");b.appTheme().passwordDetect(a);d(a)}};return{views:f,
|
||||
selectDetect:d,updateSk:function(){$("#content").find("[data-sk]").each(function(){e.info("updateSk");$(this).data("sk",b.sk.get())})},updateFormHash:function(a){e.info("updateFormHash");a=void 0!==a?a.find(".form-action[data-hash]"):$(".form-action[data-hash]");0<a.length&&a.each(function(){var a=$(this);a.attr("data-hash",SparkMD5.hash(a.serialize(),!1))})},bodyHooks:function(){e.info("bodyHooks");$("body").on("click","button.btn-action[data-onclick][type='button'],li.btn-action[data-onclick],span.btn-action[data-onclick],i.btn-action[data-onclick],.btn-action-pager[data-onclick]",
|
||||
function(){var a=$(this);e.info("handleActionButton: "+a.attr("id"));var c=a.data("onclick").split("/"),d;d=a.data("plugin");d=void 0!==d&&void 0!==b.appPlugins()[d]?b.appPlugins()[d]:b.appActions();if(2===c.length)d[c[0]][c[1]](a);else d[c[0]](a)}).on("click",".btn-back",function(){var a=b.appRequests();if(0<a.history.length()){e.info("back");var c=a.history.del();a.getActionCall(c,c.callback)}}).on("submit",".form-action",function(a){a.preventDefault();a=$(this);e.info("formAction");var c=a.attr("data-hash"),
|
||||
d=SparkMD5.hash(a.serialize(),!1);if(c===d)b.msg.ok(b.config().LANG[55]);else if(c=a.data("plugin"),c=void 0!==c&&void 0!==b.appPlugins()[c]?b.appPlugins()[c]:b.appActions(),d=a.data("onsubmit").split("/"),a.find("input[name='sk']").val(b.sk.get()),2===d.length)c[d[0]][d[1]](a);else c[d[0]](a)}).on("click",".btn-help",function(){var a=$(this),a=$("#"+a.data("help")).html();mdlDialog().show({title:b.config().LANG[54],text:a,positive:{title:b.config().LANG[43]}})}).on("reset",".form-action",function(a){a.preventDefault();
|
||||
e.info("reset");a=$(this);a.find("input:text, input:password, input:file, textarea").val("").parent("div").removeClass("is-dirty");a.find("input:radio, input:checkbox").prop("checked",!1).prop("selected",!1);a.find("input[name='start'], input[name='skey'], input[name='sorder']").val(0);a.find("select").each(function(){$(this)[0].selectize.clear(!0)});a.submit()}).on("click",".btn-popup-close",function(a){$.magnificPopup.close()})}}};
|
||||
var $jscomp={scope:{},findInternal:function(b,d,f){b instanceof String&&(b=String(b));for(var g=b.length,a=0;a<g;a++){var c=b[a];if(d.call(f,c,a,b))return{i:a,v:c}}return{i:-1,v:void 0}}};$jscomp.defineProperty="function"==typeof Object.defineProperties?Object.defineProperty:function(b,d,f){if(f.get||f.set)throw new TypeError("ES3 does not support getters and setters.");b!=Array.prototype&&b!=Object.prototype&&(b[d]=f.value)};
|
||||
$jscomp.getGlobal=function(b){return"undefined"!=typeof window&&window===b?b:"undefined"!=typeof global?global:b};$jscomp.global=$jscomp.getGlobal(this);$jscomp.polyfill=function(b,d,f,g){if(d){f=$jscomp.global;b=b.split(".");for(g=0;g<b.length-1;g++){var a=b[g];a in f||(f[a]={});f=f[a]}b=b[b.length-1];g=f[b];d=d(g);d!=g&&null!=d&&$jscomp.defineProperty(f,b,{configurable:!0,writable:!0,value:d})}};
|
||||
$jscomp.polyfill("Array.prototype.find",function(b){return b?b:function(b,f){return $jscomp.findInternal(this,b,f).v}},"es6-impl","es3");
|
||||
sysPass.Triggers=function(b){var d=b.log,f=function(a){var c={valueField:"id",labelField:"name",searchField:["name"]};a.find(".select-box").each(function(a){var d=$(this);c.plugins=d.hasClass("select-box-deselect")?{clear_selection:{title:b.config().LANG[51]}}:{};if(d.data("onchange")){var e=d.data("onchange").split("/");c.onChange=function(a){if(0<a)if(2===e.length)sysPassApp.actions()[e[0]][e[1]](d);else sysPassApp.actions()[e[0]](d)}}d.selectize(c)});a.find("#allowed_exts").selectize({create:function(a){return{value:a.toUpperCase(),
|
||||
text:a.toUpperCase()}},createFilter:/^[a-z0-9]{1,4}$/i,plugins:["remove_button"]});a.find("#wikifilter").selectize({create:!0,createFilter:/^[a-z0-9:._-]+$/i,plugins:["remove_button"]});a.find(".select-items-tag").selectize({create:function(a){return{value:a.toLowerCase(),text:a.toLowerCase()}},createFilter:/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/,plugins:["remove_button"]})},g={main:function(a){d.info("views:main");
|
||||
clipboard.isSupported()||b.msg.info(b.config().LANG[65]);$(".btn-menu").click(function(){var a=$(this);"1"===a.attr("data-history-reset")&&b.appRequests().history.reset();b.appActions().doAction({r:a.data("route")},a.data("view"))});$("#btnLogout").click(function(a){b.appActions().main.logout()});if(0===a.data("upgraded"))b.appActions().doAction({r:"account/index"},"search");else{a=$("#content");var c=a.data("page");g.common(a);if(""!==c&&"function"===typeof g[c])g[c]()}!0===b.config().CHECK_UPDATES&&
|
||||
b.appActions().main.getUpdates();!0===b.config().CHECK_NOTICES&&b.appActions().main.getNotices();"function"===typeof b.appTheme().viewsTriggers.main&&b.appTheme().viewsTriggers.main()},search:function(){d.info("views:search");var a=$("#frmSearch");0!==a.length&&(a.find("input[name='search']").on("keyup",function(b){b.preventDefault();13!==b.which&&13!==b.keyCode||a.submit()}),a.find("select, #rpp").on("change",function(){a.submit()}),a.find("button.btn-clear").on("click",function(b){b.preventDefault();
|
||||
a.find('input[name="searchfav"]').val(0);a[0].reset()}),a.find("input:text:visible:first").focus(),$("#globalSearch").click(function(){var b=1==$(this).prop("checked")?1:0;a.find("input[name='gsearch']").val(b);a.submit()}),"function"===typeof b.appTheme().viewsTriggers.search&&b.appTheme().viewsTriggers.search())},login:function(){d.info("views:login");var a=$("#frmLogin");b.config().AUTHBASIC_AUTOLOGIN&&"0"===a.find("input[name='loggedOut']").val()&&(d.info("views:login:autologin"),b.msg.info(b.config().LANG[66]),
|
||||
b.appActions().main.login(a))},userpassreset:function(){d.info("views:userpassreset");var a=$("#frmUserPassReset");b.appTheme().passwordDetect(a)},footer:function(){d.info("views:footer")},common:function(a){d.info("views:common");f(a);var c=a.find(":input [name='sk']");0<c.length&&b.sk.set(c.val());"function"===typeof b.appTheme().viewsTriggers.common&&b.appTheme().viewsTriggers.common(a);b.appTriggers().updateFormHash(a)},datatabs:function(){d.info("views:datatabs");$(".datagrid-action-search>form").each(function(){var a=
|
||||
$(this);a.find("button.btn-clear").on("click",function(b){b.preventDefault();a.trigger("reset")})})},config:function(){d.info("views:config");var a=$("#drop-import-files");if(0<a.length){var c=b.fileUpload(a);c.url=b.appActions().ajaxUrl.entrypoint+"?r="+a.data("action-route");c.allowedExts=b.config().IMPORT_ALLOWED_EXTS;c.beforeSendAction=function(){c.setRequestData({sk:b.sk.get(),csvDelimiter:$("#csvDelimiter").val(),importPwd:$("#importPwd").val(),importMasterPwd:$("#importMasterPwd").val(),import_defaultuser:$("#import_defaultuser").val(),
|
||||
import_defaultgroup:$("#import_defaultgroup").val()})}}},account:function(){d.info("views:account");var a=$("#list-account-files");0<a.length&&b.appActions().account.listFiles(a);var c=$("#drop-account-files");if(0<c.length){var e=b.fileUpload(c);e.url=b.appActions().ajaxUrl.entrypoint+"?r="+c.data("action-route")+"/"+c.data("item-id");e.allowedExts=b.config().FILES_ALLOWED_EXTS;e.requestDoneAction=function(){b.appActions().account.listFiles(a)}}c=$("#parent_account_id");0<c.length&&(c.on("change",
|
||||
function(){var a=$(this),b=$("#accountpass,#accountpassR");0<a[0].value?b.each(function(){$(this).prop("disabled","true");$(this).prop("required","false")}):b.each(function(){$(this).prop("disabled","");$(this).prop("required","true")})}),b.appActions().items.get(c));$(".select-box-tags").selectize({persist:!1,valueField:"id",labelField:"name",searchField:["name"],plugins:["remove_button"],onInitialize:function(){var a=this.$input[0],b=document.createAttribute("data-hash");b.value=SparkMD5.hash(this.getValue().join(),
|
||||
!1);a.setAttributeNode(b);"undefined"!==typeof a.dataset.currentItemId&&this.removeOption(a.dataset.currentItemId,!0)},onChange:function(){var a=this.$input[0],b=document.createAttribute("data-updated");b.value=SparkMD5.hash(this.getValue().join(),!1)!==a.dataset.hash&&"true";a.setAttributeNode(b)}});$("input:text:visible:first").focus()},install:function(){d.info("views:install");var a=$("#frmInstall");b.appTheme().passwordDetect(a);f(a)}};return{views:g,selectDetect:f,updateSk:function(){$("#content").find("[data-sk]").each(function(){d.info("updateSk");
|
||||
$(this).data("sk",b.sk.get())})},updateFormHash:function(a){d.info("updateFormHash");a=void 0!==a?a.find(".form-action[data-hash]"):$(".form-action[data-hash]");0<a.length&&a.each(function(){var a=$(this);a.attr("data-hash",SparkMD5.hash(a.serialize(),!1))})},bodyHooks:function(){d.info("bodyHooks");$("body").on("click","button.btn-action[data-onclick][type='button'],li.btn-action[data-onclick],span.btn-action[data-onclick],i.btn-action[data-onclick],.btn-action-pager[data-onclick]",function(){var a=
|
||||
$(this);d.info("handleActionButton: "+a.attr("id"));var c=a.data("onclick").split("/"),e;e=a.data("plugin");e=void 0!==e&&void 0!==b.appPlugins()[e]?b.appPlugins()[e]:b.appActions();if(2===c.length)e[c[0]][c[1]](a);else e[c[0]](a)}).on("click",".btn-back",function(){var a=b.appRequests();if(0<a.history.length()){d.info("back");var c=a.history.del();a.getActionCall(c,c.callback)}}).on("submit",".form-action",function(a){a.preventDefault();a=$(this);d.info("formAction");var c=a.attr("data-hash"),e=
|
||||
SparkMD5.hash(a.serialize(),!1);if(c===e)b.msg.ok(b.config().LANG[55]);else if(c=a.data("plugin"),c=void 0!==c&&void 0!==b.appPlugins()[c]?b.appPlugins()[c]:b.appActions(),e=a.data("onsubmit").split("/"),a.find("input[name='sk']").val(b.sk.get()),2===e.length)c[e[0]][e[1]](a);else c[e[0]](a)}).on("click",".btn-help",function(){var a=$(this),a=$("#"+a.data("help")).html();mdlDialog().show({title:b.config().LANG[54],text:a,positive:{title:b.config().LANG[43]}})}).on("reset",".form-action",function(a){a.preventDefault();
|
||||
d.info("reset");a=$(this);a.find("input:text, input:password, input:file, textarea").val("").parent("div").removeClass("is-dirty");a.find("input:radio, input:checkbox").prop("checked",!1).prop("selected",!1);a.find("input[name='start'], input[name='skey'], input[name='sorder']").val(0);a.find("select").each(function(){$(this)[0].selectize.clear(!0)});a.submit()}).on("click",".btn-popup-close",function(a){$.magnificPopup.close()})}}};
|
||||
|
||||
@@ -354,6 +354,7 @@ RENAME TO AccountToTag $$
|
||||
|
||||
-- AccountToUserGroup
|
||||
ALTER TABLE accGroups
|
||||
ADD isEdit tinyint(1) unsigned DEFAULT 0 NULL,
|
||||
CHANGE accgroup_accountId accountId MEDIUMINT UNSIGNED NOT NULL,
|
||||
CHANGE accgroup_groupId userGroupId SMALLINT(5) UNSIGNED NOT NULL,
|
||||
DROP INDEX IDX_accountId,
|
||||
@@ -362,6 +363,7 @@ RENAME TO AccountToUserGroup $$
|
||||
|
||||
-- AccountToUser
|
||||
ALTER TABLE accUsers
|
||||
ADD isEdit tinyint(1) unsigned DEFAULT 0 NULL,
|
||||
CHANGE accuser_accountId accountId MEDIUMINT UNSIGNED NOT NULL,
|
||||
CHANGE accuser_userId userId SMALLINT(5) UNSIGNED NOT NULL,
|
||||
DROP INDEX idx_account,
|
||||
|
||||
Reference in New Issue
Block a user