From 5a8699fe45b41e303e8927e902ab1e5437e5dd5d Mon Sep 17 00:00:00 2001 From: nuxsmin Date: Mon, 7 Nov 2016 03:00:41 +0100 Subject: [PATCH] * [DEV] Closes #291. New profile option to allow to change account's permissions. --- ajax/ajax_appMgmtSave.php | 1 + inc/SP/Account/AccountAcl.class.php | 26 ++++- inc/SP/DataModel/ProfileData.class.php | 20 ++++ .../Mgmt/CustomFields/CustomField.class.php | 4 - .../material-blue/views/accitem/profiles.inc | 7 ++ .../views/account/account-permissions.inc | 107 ++++++++++-------- .../material-blue/views/account/account.inc | 2 +- .../views/common/aux-customfields.inc | 76 ++++++------- 8 files changed, 148 insertions(+), 95 deletions(-) diff --git a/ajax/ajax_appMgmtSave.php b/ajax/ajax_appMgmtSave.php index 61fd7612..2027521c 100644 --- a/ajax/ajax_appMgmtSave.php +++ b/ajax/ajax_appMgmtSave.php @@ -272,6 +272,7 @@ if ($actionId === ActionsInterface::ACTION_USR_USERS_NEW $ProfileData->setAccFiles(Request::analyze('profile_accfiles', 0, false, 1)); $ProfileData->setAccPublicLinks(Request::analyze('profile_accpublinks', 0, false, 1)); $ProfileData->setAccPrivate(Request::analyze('profile_accprivate', 0, false, 1)); + $ProfileData->setAccPermission(Request::analyze('profile_accpermissions', 0, false, 1)); $ProfileData->setConfigGeneral(Request::analyze('profile_config', 0, false, 1)); $ProfileData->setConfigEncryption(Request::analyze('profile_configmpw', 0, false, 1)); $ProfileData->setConfigBackup(Request::analyze('profile_configback', 0, false, 1)); diff --git a/inc/SP/Account/AccountAcl.class.php b/inc/SP/Account/AccountAcl.class.php index 2fed4942..36d875eb 100644 --- a/inc/SP/Account/AccountAcl.class.php +++ b/inc/SP/Account/AccountAcl.class.php @@ -25,6 +25,7 @@ namespace SP\Account; use SP\Core\Acl; +use SP\Core\Session; use SP\Log\Log; use SP\Util\Checks; @@ -99,6 +100,10 @@ class AccountAcl * @var bool */ protected $showCopy = false; + /** + * @var bool + */ + protected $showPermission = false; /** * @return boolean @@ -195,7 +200,7 @@ class AccountAcl * @param int $action * @return $this */ - public function getAcl (AccountBase $Account, $action) + public function getAcl(AccountBase $Account, $action) { $this->Account = $Account; $this->action = $action; @@ -289,6 +294,9 @@ class AccountAcl || $this->action === Acl::ACTION_ACC_EDIT) && Acl::checkAccountAccess(Acl::ACTION_ACC_COPY, $aclData) && Acl::checkUserAccess(Acl::ACTION_ACC_COPY); + + // Cambiar los permisos de la cuenta + $this->showPermission = Session::getUserIsAdminAcc() || Session::getUserIsAdminApp() || Session::getUserProfile()->isAccPermission(); } /** @@ -322,4 +330,20 @@ class AccountAcl { return $this->showCopy; } + + /** + * @return boolean + */ + public function isShowPermission() + { + return $this->showPermission; + } + + /** + * @param boolean $showPermission + */ + public function setShowPermission($showPermission) + { + $this->showPermission = $showPermission; + } } \ No newline at end of file diff --git a/inc/SP/DataModel/ProfileData.class.php b/inc/SP/DataModel/ProfileData.class.php index 7aa88866..501f332c 100644 --- a/inc/SP/DataModel/ProfileData.class.php +++ b/inc/SP/DataModel/ProfileData.class.php @@ -70,6 +70,10 @@ class ProfileData extends ProfileBaseData * @var bool */ protected $accPrivate = false; + /** + * @var bool + */ + protected $accPermission = false; /** * @var bool */ @@ -514,4 +518,20 @@ class ProfileData extends ProfileBaseData { $this->accPrivate = $accPrivate; } + + /** + * @return boolean + */ + public function isAccPermission() + { + return $this->accPermission; + } + + /** + * @param boolean $accPermission + */ + public function setAccPermission($accPermission) + { + $this->accPermission = $accPermission; + } } \ No newline at end of file diff --git a/inc/SP/Mgmt/CustomFields/CustomField.class.php b/inc/SP/Mgmt/CustomFields/CustomField.class.php index 59d63193..d26fdc91 100644 --- a/inc/SP/Mgmt/CustomFields/CustomField.class.php +++ b/inc/SP/Mgmt/CustomFields/CustomField.class.php @@ -224,7 +224,6 @@ class CustomField extends CustomFieldBase implements ItemInterface $queryRes = DB::getResults($Data); $customFields = []; - $customFieldsHash = ''; foreach ($queryRes as $CustomFieldData) { /** @@ -243,11 +242,8 @@ class CustomField extends CustomFieldBase implements ItemInterface $CustomFieldData->setValue($this->unencryptData($CustomFieldData)); $customFields[] = $CustomFieldData; - $customFieldsHash .= $CustomFieldData->getValue(); } - $customFields['hash'] = md5($customFieldsHash); - return $customFields; } diff --git a/inc/themes/material-blue/views/accitem/profiles.inc b/inc/themes/material-blue/views/accitem/profiles.inc index 7d15c7b4..f9bccf1c 100644 --- a/inc/themes/material-blue/views/accitem/profiles.inc +++ b/inc/themes/material-blue/views/accitem/profiles.inc @@ -99,6 +99,13 @@ + diff --git a/inc/themes/material-blue/views/account/account-permissions.inc b/inc/themes/material-blue/views/account/account-permissions.inc index 131d62d8..cdeb8638 100644 --- a/inc/themes/material-blue/views/account/account-permissions.inc +++ b/inc/themes/material-blue/views/account/account-permissions.inc @@ -1,54 +1,61 @@ - - - - - +
- - -
+ isShowPermission()): ?> + + + + + diff --git a/inc/themes/material-blue/views/account/account.inc b/inc/themes/material-blue/views/account/account.inc index 3ab56611..e4af94b9 100644 --- a/inc/themes/material-blue/views/account/account.inc +++ b/inc/themes/material-blue/views/account/account.inc @@ -194,7 +194,7 @@ includeTemplate('account-permissions'); ?> - + 0): ?>
+ + +
includeTemplate('aux-customfields', 'common'); ?>
diff --git a/inc/themes/material-blue/views/common/aux-customfields.inc b/inc/themes/material-blue/views/common/aux-customfields.inc index 25e73981..2787347f 100644 --- a/inc/themes/material-blue/views/common/aux-customfields.inc +++ b/inc/themes/material-blue/views/common/aux-customfields.inc @@ -5,46 +5,44 @@ use SP\Mgmt\CustomFields\CustomFieldTypes; /** @var $icons \Theme\Icons */ /** @var \SP\DataModel\CustomFieldData $field */ -foreach ($customFields as $index => $field): -?> - +foreach ($customFields as $index => $field):?> - - getDefinition()->getName(); ?> - getDefinition()->getHelp()): ?> -
- getIconHelp()->getIcon(); ?> -
-
-

getDefinition()->getHelp(); ?>

-
- - - - -
- getDefinition()->isRequired()) ? 'required' : ''; ?>> - -
- - getDefinition()->getType() === CustomFieldTypes::TYPE_PASSWORD && !$showViewPass): ?> - **** - getDefinition()->getType() === CustomFieldTypes::TYPE_COLOR): ?> - - - getValue(); ?> + + getDefinition()->getName(); ?> + getDefinition()->getHelp()): ?> +
+ getIconHelp()->getIcon(); ?> +
+
+

getDefinition()->getHelp(); ?>

+
- - + + + +
+ getDefinition()->isRequired()) ? 'required' : ''; ?>> + +
+ + getDefinition()->getType() === CustomFieldTypes::TYPE_PASSWORD && !$showViewPass): ?> + **** + getDefinition()->getType() === CustomFieldTypes::TYPE_COLOR): ?> + + + getValue(); ?> + + + - \ No newline at end of file