From cd3dd55446aacbc8bc7b744fbb704efbdee305f2 Mon Sep 17 00:00:00 2001 From: nuxsmin Date: Wed, 30 Nov 2016 22:23:00 +0100 Subject: [PATCH] * [DEV] Minor improvements --- inc/SP/Controller/AccountController.class.php | 6 +++--- .../AccountSearchController.class.php | 4 ++-- inc/SP/Controller/ConfigController.class.php | 20 +++++++++---------- inc/SP/Controller/ControllerBase.class.php | 15 +++++++++++++- .../Controller/EventlogController.class.php | 2 +- inc/SP/Controller/MainController.class.php | 12 +++++------ .../UserPreferencesController.class.php | 2 +- inc/SP/Core/Acl.class.php | 11 ++++++++++ inc/SP/DataModel/ProfileData.class.php | 20 +++++++++++++++++++ inc/SP/Forms/ProfileForm.class.php | 1 + .../material-blue/views/itemshow/profiles.inc | 7 +++++++ 11 files changed, 76 insertions(+), 24 deletions(-) diff --git a/inc/SP/Controller/AccountController.class.php b/inc/SP/Controller/AccountController.class.php index 807ff8ef..971972e4 100644 --- a/inc/SP/Controller/AccountController.class.php +++ b/inc/SP/Controller/AccountController.class.php @@ -152,7 +152,7 @@ class AccountController extends ControllerBase implements ActionsInterface if (!Acl::checkUserAccess($this->getAction())) { $this->showError(self::ERR_PAGE_NO_PERMISSION); return false; - } elseif (!UserPass::checkUserUpdateMPass(Session::getUserData()->getUserId())) { + } elseif (!UserPass::checkUserUpdateMPass($this->UserData->getUserId())) { $this->showError(self::ERR_UPDATE_MPASS); return false; } elseif ($this->id > 0) { @@ -207,7 +207,7 @@ class AccountController extends ControllerBase implements ActionsInterface $this->view->assign('otherGroups', Group::getItem()->getItemsForSelect()); $this->view->assign('otherGroupsJson', Json::getJson($this->view->otherGroups)); $this->view->assign('tagsJson', Json::getJson(Tag::getItem()->getItemsForSelect())); - $this->view->assign('allowPrivate', Session::getUserProfile()->isAccPrivate()); + $this->view->assign('allowPrivate', $this->UserProfileData->isAccPrivate()); $this->view->assign('disabled', $this->view->isView ? 'disabled' : ''); $this->view->assign('readonly', $this->view->isView ? 'readonly' : ''); @@ -216,7 +216,7 @@ class AccountController extends ControllerBase implements ActionsInterface $AccountAcl->setModified($this->isGotData() ? $this->view->isModified : false); $AccountAcl->getAcl($this->getAccount(), $this->getAction()); $this->view->assign('AccountAcl', $AccountAcl); - $this->view->assign('showViewPass', Session::getUserProfile()->isAccViewPass()); + $this->view->assign('showViewPass', $this->UserProfileData->isAccViewPass()); } /** diff --git a/inc/SP/Controller/AccountSearchController.class.php b/inc/SP/Controller/AccountSearchController.class.php index 324eba08..3b5e2ee1 100644 --- a/inc/SP/Controller/AccountSearchController.class.php +++ b/inc/SP/Controller/AccountSearchController.class.php @@ -100,8 +100,8 @@ class AccountSearchController extends ControllerBase implements ActionsInterface */ private function setVars() { - $this->view->assign('isAdmin', Session::getUserData()->isUserIsAdminApp() || Session::getUserData()->isUserIsAdminAcc()); - $this->view->assign('showGlobalSearch', Config::getConfig()->isGlobalSearch()); + $this->view->assign('isAdmin', $this->UserData->isUserIsAdminApp() || $this->UserData->isUserIsAdminAcc()); + $this->view->assign('showGlobalSearch', Config::getConfig()->isGlobalSearch() && $this->UserProfileData->isAccGlobalSearch()); // Obtener el filtro de búsqueda desde la sesión $filters = Session::getSearchFilters(); diff --git a/inc/SP/Controller/ConfigController.class.php b/inc/SP/Controller/ConfigController.class.php index 69a469d7..0c9aa2ec 100644 --- a/inc/SP/Controller/ConfigController.class.php +++ b/inc/SP/Controller/ConfigController.class.php @@ -78,14 +78,14 @@ class ConfigController extends ControllerBase implements ActionsInterface $this->view->assign('tabs', []); $this->view->assign('sk', SessionUtil::getSessionKey(true)); - $this->view->assign('isDemoMode', Checks::demoIsEnabled() && !Session::getUserData()->isUserIsAdminApp()); - $this->view->assign('isDisabled', (Checks::demoIsEnabled() && !Session::getUserData()->isUserIsAdminApp()) ? 'DISABLED' : ''); + $this->view->assign('isDemoMode', Checks::demoIsEnabled() && !$this->UserData->isUserIsAdminApp()); + $this->view->assign('isDisabled', (Checks::demoIsEnabled() && !$this->UserData->isUserIsAdminApp()) ? 'disabled' : ''); } /** * Obtener la pestaña de configuración * - * @return bool + * @return void */ public function getGeneralTab() { @@ -161,7 +161,7 @@ class ConfigController extends ControllerBase implements ActionsInterface /** * Obtener la pestaña de encriptación * - * @return bool + * @return void */ public function getEncryptionTab() { @@ -185,7 +185,7 @@ class ConfigController extends ControllerBase implements ActionsInterface /** * Obtener la pestaña de copia de seguridad * - * @return bool + * @return void */ public function getBackupTab() { @@ -230,7 +230,7 @@ class ConfigController extends ControllerBase implements ActionsInterface /** * Obtener la pestaña de Importación * - * @return bool + * @return void */ public function getImportTab() { @@ -252,7 +252,7 @@ class ConfigController extends ControllerBase implements ActionsInterface /** * Obtener la pestaña de información * - * @return bool + * @return void */ public function getInfoTab() { @@ -275,7 +275,7 @@ class ConfigController extends ControllerBase implements ActionsInterface /** * Obtener la pestaña de Wiki * - * @return bool + * @return void */ public function getWikiTab() { @@ -307,7 +307,7 @@ class ConfigController extends ControllerBase implements ActionsInterface /** * Obtener la pestaña de LDAP * - * @return bool + * @return void */ public function getLdapTab() { @@ -340,7 +340,7 @@ class ConfigController extends ControllerBase implements ActionsInterface /** * Obtener la pestaña de Correo * - * @return bool + * @return void */ public function getMailTab() { diff --git a/inc/SP/Controller/ControllerBase.class.php b/inc/SP/Controller/ControllerBase.class.php index 5966a774..eeb5b950 100644 --- a/inc/SP/Controller/ControllerBase.class.php +++ b/inc/SP/Controller/ControllerBase.class.php @@ -35,6 +35,8 @@ use SP\Core\Exceptions\SPException; use SP\Core\DiFactory; use SP\Core\Template; use SP\Core\UI\ThemeIconsBase; +use SP\DataModel\ProfileData; +use SP\DataModel\UserData; use SP\Http\JsonResponse; /** @@ -79,6 +81,14 @@ abstract class ControllerBase * @var JsonResponse */ protected $Json; + /** + * @var UserData + */ + protected $UserData; + /** + * @var ProfileData + */ + protected $UserProfileData; /** * Constructor @@ -243,8 +253,11 @@ abstract class ControllerBase { global $timeStart; + $this->UserData = Session::getUserData(); + $this->UserProfileData = Session::getUserProfile(); + $this->view->assign('timeStart', $timeStart); $this->view->assign('icons', $this->icons); - $this->view->assign('SessionUserData', Session::getUserData()); + $this->view->assign('SessionUserData', $this->UserData); } } \ No newline at end of file diff --git a/inc/SP/Controller/EventlogController.class.php b/inc/SP/Controller/EventlogController.class.php index b925b785..cbf6bffb 100644 --- a/inc/SP/Controller/EventlogController.class.php +++ b/inc/SP/Controller/EventlogController.class.php @@ -83,7 +83,7 @@ class EventlogController extends ControllerBase implements ActionsInterface $GridActionSearch->setOnSubmitFunction('eventlog/search'); $this->view->assign('rowClass', 'row_even'); - $this->view->assign('isDemoMode', Checks::demoIsEnabled() || !Session::getUserData()->isUserIsAdminApp()); + $this->view->assign('isDemoMode', Checks::demoIsEnabled() || !$this->UserData->isUserIsAdminApp()); $this->view->assign('limitStart', isset($this->view->limitStart) ? (int)$this->view->limitStart : 0); $this->view->assign('events', Log::getEvents($this->view->limitStart, self::MAX_ROWS)); diff --git a/inc/SP/Controller/MainController.class.php b/inc/SP/Controller/MainController.class.php index 4177cef1..8a78fa9e 100644 --- a/inc/SP/Controller/MainController.class.php +++ b/inc/SP/Controller/MainController.class.php @@ -171,12 +171,12 @@ class MainController extends ControllerBase implements ActionsInterface { $this->view->addTemplate('sessionbar'); - $this->view->assign('adminApp', Session::getUserData()->isUserIsAdminApp() ? '(A+)' : ''); - $this->view->assign('userId', Session::getUserData()->getUserId()); - $this->view->assign('userLogin', strtoupper(Session::getUserData()->getUserLogin())); - $this->view->assign('userName', Session::getUserData()->getUserName() ?: strtoupper($this->view->userLogin)); - $this->view->assign('userGroup', Session::getUserData()->getUsergroupName()); - $this->view->assign('showPassIcon', !Session::getUserData()->isUserIsLdap()); + $this->view->assign('adminApp', $this->UserData->isUserIsAdminApp() ? '(A+)' : ''); + $this->view->assign('userId', $this->UserData->getUserId()); + $this->view->assign('userLogin', strtoupper($this->UserData->getUserLogin())); + $this->view->assign('userName', $this->UserData->getUserName() ?: strtoupper($this->view->userLogin)); + $this->view->assign('userGroup', $this->UserData->getUsergroupName()); + $this->view->assign('showPassIcon', !$this->UserData->isUserIsLdap()); } /** diff --git a/inc/SP/Controller/UserPreferencesController.class.php b/inc/SP/Controller/UserPreferencesController.class.php index 02016995..1c6fd3a6 100644 --- a/inc/SP/Controller/UserPreferencesController.class.php +++ b/inc/SP/Controller/UserPreferencesController.class.php @@ -70,7 +70,7 @@ class UserPreferencesController extends ControllerBase implements ActionsInterfa $this->view->assign('tabs', array()); $this->view->assign('sk', SessionUtil::getSessionKey(true)); - $this->userId = Session::getUserData()->getUserId(); + $this->userId = $this->UserData->getUserId(); $this->userPrefs = UserPreferences::getItem()->getById($this->userId); } diff --git a/inc/SP/Core/Acl.class.php b/inc/SP/Core/Acl.class.php index c3ec8c06..5f5c6fcd 100644 --- a/inc/SP/Core/Acl.class.php +++ b/inc/SP/Core/Acl.class.php @@ -140,20 +140,27 @@ class Acl implements ActionsInterface case self::ACTION_CFG_IMPORT: return $curUserProfile->isConfigImport(); case self::ACTION_MGM_CATEGORIES: + case self::ACTION_MGM_CATEGORIES_SEARCH: return $curUserProfile->isMgmCategories(); case self::ACTION_MGM_CUSTOMERS: + case self::ACTION_MGM_CUSTOMERS_SEARCH: return $curUserProfile->isMgmCustomers(); case self::ACTION_MGM_CUSTOMFIELDS: + case self::ACTION_MGM_CUSTOMFIELDS_SEARCH: return $curUserProfile->isMgmCustomFields(); case self::ACTION_MGM_PUBLICLINKS: + case self::ACTION_MGM_PUBLICLINKS_SEARCH: return $curUserProfile->isMgmPublicLinks(); case self::ACTION_MGM_PUBLICLINKS_NEW: return ($curUserProfile->isMgmPublicLinks() || $curUserProfile->isAccPublicLinks()); case self::ACTION_MGM_ACCOUNTS: + case self::ACTION_MGM_ACCOUNTS_SEARCH: return $curUserProfile->isMgmAccounts(); case self::ACTION_MGM_FILES: + case self::ACTION_MGM_FILES_SEARCH: return $curUserProfile->isMgmFiles(); case self::ACTION_MGM_TAGS: + case self::ACTION_MGM_TAGS_SEARCH: return $curUserProfile->isMgmTags(); case self::ACTION_CFG_ENCRYPTION: return $curUserProfile->isConfigEncryption(); @@ -162,14 +169,18 @@ class Acl implements ActionsInterface case self::ACTION_USR: return ($curUserProfile->isMgmUsers() || $curUserProfile->isMgmGroups() || $curUserProfile->isMgmProfiles()); case self::ACTION_USR_USERS: + case self::ACTION_USR_USERS_SEARCH: return $curUserProfile->isMgmUsers(); case self::ACTION_USR_USERS_EDITPASS: return ($userId === $curUserId || $curUserProfile->isMgmUsers()); case self::ACTION_USR_GROUPS: + case self::ACTION_USR_GROUPS_SEARCH: return $curUserProfile->isMgmGroups(); case self::ACTION_USR_PROFILES: + case self::ACTION_USR_PROFILES_SEARCH: return $curUserProfile->isMgmProfiles(); case self::ACTION_MGM_APITOKENS: + case self::ACTION_MGM_APITOKENS_SEARCH: return $curUserProfile->isMgmApiTokens(); case self::ACTION_EVL: return $curUserProfile->isEvl(); diff --git a/inc/SP/DataModel/ProfileData.class.php b/inc/SP/DataModel/ProfileData.class.php index 33b087ce..bd530e00 100644 --- a/inc/SP/DataModel/ProfileData.class.php +++ b/inc/SP/DataModel/ProfileData.class.php @@ -78,6 +78,10 @@ class ProfileData extends ProfileBaseData * @var bool */ protected $accPublicLinks = false; + /** + * @var bool + */ + protected $accGlobalSearch = false; /** * @var bool */ @@ -594,4 +598,20 @@ class ProfileData extends ProfileBaseData { $this->mgmFiles = $mgmFiles; } + + /** + * @return boolean + */ + public function isAccGlobalSearch() + { + return $this->accGlobalSearch; + } + + /** + * @param boolean $accGlobalSearch + */ + public function setAccGlobalSearch($accGlobalSearch) + { + $this->accGlobalSearch = $accGlobalSearch; + } } \ No newline at end of file diff --git a/inc/SP/Forms/ProfileForm.class.php b/inc/SP/Forms/ProfileForm.class.php index 4e8f6d1b..4105b90f 100644 --- a/inc/SP/Forms/ProfileForm.class.php +++ b/inc/SP/Forms/ProfileForm.class.php @@ -99,6 +99,7 @@ class ProfileForm extends FormBase implements FormInterface $this->ProfileData->setAccPublicLinks(Request::analyze('profile_accpublinks', 0, false, 1)); $this->ProfileData->setAccPrivate(Request::analyze('profile_accprivate', 0, false, 1)); $this->ProfileData->setAccPermission(Request::analyze('profile_accpermissions', 0, false, 1)); + $this->ProfileData->setAccGlobalSearch(Request::analyze('profile_accglobalsearch', 0, false, 1)); $this->ProfileData->setConfigGeneral(Request::analyze('profile_config', 0, false, 1)); $this->ProfileData->setConfigEncryption(Request::analyze('profile_configmpw', 0, false, 1)); $this->ProfileData->setConfigBackup(Request::analyze('profile_configback', 0, false, 1)); diff --git a/inc/themes/material-blue/views/itemshow/profiles.inc b/inc/themes/material-blue/views/itemshow/profiles.inc index 6d113819..45662a64 100644 --- a/inc/themes/material-blue/views/itemshow/profiles.inc +++ b/inc/themes/material-blue/views/itemshow/profiles.inc @@ -106,6 +106,13 @@ +