From 5c573fffdbab700cd13ae1e433c956d063e8c537 Mon Sep 17 00:00:00 2001 From: nuxsmin Date: Fri, 5 Feb 2016 15:34:05 +0100 Subject: [PATCH] BIG COMMIT. Many changes done...Backup!! * [ADD] The configuration is now stored in a XML file. * [MOD] Many code improvements --- ajax/ajax_accountSave.php | 54 +- ajax/ajax_appMgmtSave.php | 5 +- ajax/ajax_appMgmtSearch.php | 2 +- ajax/ajax_configSave.php | 138 +- ajax/ajax_files.php | 11 +- ajax/ajax_getContent.php | 2 +- ajax/ajax_getEnvironment.php | 2 +- ajax/ajax_viewpass.php | 5 +- inc/Base.php | 1 + inc/SP/Account/Account.class.php | 385 ++--- inc/SP/Account/AccountBase.class.php | 400 +---- inc/SP/Account/AccountData.class.php | 445 +++++ inc/SP/Account/AccountHistory.class.php | 52 +- inc/SP/Account/AccountInterface.class.php | 17 +- inc/SP/Account/AccountSearch.class.php | 98 +- inc/SP/Api/ApiBase.class.php | 30 +- inc/SP/Api/ApiRequest.class.php | 26 +- inc/SP/Api/ApiTokens.class.php | 62 +- inc/SP/Api/SyspassApi.class.php | 28 +- inc/SP/Auth/Auth.class.php | 6 +- inc/SP/Auth/Auth2FA.class.php | 28 +- inc/SP/Auth/Ldap.class.php | 110 +- inc/SP/Auth/LdapADS.class.php | 16 +- inc/SP/Config/Cache.class.php | 85 - inc/SP/Config/Config.class.php | 319 +--- inc/SP/Config/ConfigDB.class.php | 16 +- inc/SP/Config/ConfigData.class.php | 1521 +++++++++++++++++ inc/SP/Controller/AccItemMgmt.class.php | 17 +- inc/SP/Controller/AccItemsMgmt.class.php | 12 +- inc/SP/Controller/Account.class.php | 162 +- inc/SP/Controller/AccountsSearch.class.php | 120 +- inc/SP/Controller/AppItemsMgmt.class.php | 34 +- inc/SP/Controller/ConfigMgmt.class.php | 136 +- inc/SP/Controller/Controller.class.php | 14 +- inc/SP/Controller/GridItemsSearch.class.php | 5 +- inc/SP/Controller/GridTabController.class.php | 6 +- inc/SP/Controller/Grids.class.php | 178 +- inc/SP/Controller/Main.class.php | 8 +- inc/SP/Controller/UsersPrefs.class.php | 39 +- inc/SP/Controller/Wiki.class.php | 2 +- inc/SP/Core/Backup.class.php | 5 +- inc/SP/Core/Crypt.class.php | 2 +- inc/SP/Core/Factory.class.php | 75 + inc/SP/Core/Init.class.php | 177 +- inc/SP/Core/Installer.class.php | 155 +- inc/SP/Core/Language.class.php | 2 +- inc/SP/Core/Session.class.php | 49 + inc/SP/Core/SessionUtil.class.php | 33 + inc/SP/Core/Template.class.php | 32 +- inc/SP/Core/ThemeIconsBase.class.php | 134 +- inc/SP/Core/Themes.class.php | 7 +- inc/SP/Core/Upgrade.class.php | 130 +- inc/SP/Core/XmlExport.class.php | 121 +- .../DataGrid/DataGridHeaderSort.class.php | 2 +- inc/SP/Html/Minify.class.php | 30 +- inc/SP/Http/Request.class.php | 33 +- inc/SP/Http/XMLRPCResponseParse.class.php | 20 +- inc/SP/Import/CsvImport.class.php | 2 +- inc/SP/Import/CsvImportBase.class.php | 40 +- inc/SP/Import/FileImport.class.php | 26 +- inc/SP/Import/Import.class.php | 8 +- inc/SP/Import/ImportBase.class.php | 254 +-- inc/SP/Import/KeepassImport.class.php | 46 +- inc/SP/Import/KeepassXImport.class.php | 46 +- inc/SP/Import/Migrate.class.php | 87 +- inc/SP/Import/SyspassImport.class.php | 54 +- inc/SP/Import/XmlImport.class.php | 6 +- inc/SP/Import/XmlImportBase.class.php | 18 +- inc/SP/Log/ActionLog.class.php | 48 +- inc/SP/Log/Email.class.php | 18 +- inc/SP/Log/Log.class.php | 7 +- inc/SP/Log/Syslog.class.php | 4 +- inc/SP/Mgmt/CustomFieldDef.class.php | 20 +- inc/SP/Mgmt/CustomFields.class.php | 46 +- inc/SP/Mgmt/CustomFieldsBase.class.php | 28 +- inc/SP/Mgmt/CustomFieldsUtil.class.php | 10 + inc/SP/Mgmt/PublicLink.class.php | 30 +- inc/SP/Mgmt/PublicLinkBase.class.php | 92 +- inc/SP/Mgmt/User/Groups.class.php | 10 +- inc/SP/Mgmt/User/User.class.php | 6 +- inc/SP/Mgmt/User/UserBase.class.php | 240 +-- inc/SP/Mgmt/User/UserLdap.class.php | 4 +- inc/SP/Storage/DB.class.php | 59 +- inc/SP/Storage/DBStorageInterface.class.php | 39 + inc/SP/Storage/DBUtil.class.php | 9 +- inc/SP/Storage/FileStorageInterface.class.php | 55 + ...ctory.class.php => MySQLHandler.class.php} | 44 +- inc/SP/Storage/QueryData.class.php | 14 +- inc/SP/Storage/XmlHandler.class.php | 227 +++ inc/SP/Util/Checks.class.php | 28 +- inc/SP/Util/Connection.class.php | 38 +- inc/SP/Util/ConnectionInterface.class.php | 1 + inc/SP/Util/Util.class.php | 16 +- inc/SP/Util/Wiki/DokuWikiApi.class.php | 14 +- inc/SP/Util/Wiki/DokuWikiApiBase.class.php | 56 +- inc/themes/classic/debug.inc | 2 +- inc/themes/classic/inc/Icons.class.php | 60 +- inc/themes/material-blue/account.inc | 4 +- inc/themes/material-blue/debug.inc | 2 +- inc/themes/material-blue/inc/Icons.class.php | 60 +- 100 files changed, 4698 insertions(+), 2784 deletions(-) create mode 100644 inc/SP/Account/AccountData.class.php delete mode 100644 inc/SP/Config/Cache.class.php create mode 100644 inc/SP/Config/ConfigData.class.php create mode 100644 inc/SP/Core/Factory.class.php create mode 100644 inc/SP/Storage/DBStorageInterface.class.php create mode 100644 inc/SP/Storage/FileStorageInterface.class.php rename inc/SP/Storage/{DBConnectionFactory.class.php => MySQLHandler.class.php} (77%) create mode 100644 inc/SP/Storage/XmlHandler.class.php diff --git a/ajax/ajax_accountSave.php b/ajax/ajax_accountSave.php index d7f6502c..c26e742a 100644 --- a/ajax/ajax_accountSave.php +++ b/ajax/ajax_accountSave.php @@ -24,6 +24,7 @@ */ use SP\Account\Account; +use SP\Account\AccountData; use SP\Core\ActionsInterface; use SP\Core\Crypt; use SP\Core\Init; @@ -138,19 +139,21 @@ if ($actionId == ActionsInterface::ACTION_ACC_NEW } } -$Account = new Account; -$Account->setAccountId($accountId); -$Account->setAccountName($accountName); -$Account->setAccountCategoryId($categoryId); -$Account->setAccountCustomerId($customerId); -$Account->setAccountLogin($accountLogin); -$Account->setAccountUrl($accountUrl); -$Account->setAccountNotes($accountNotes); -$Account->setAccountUserEditId($currentUserId); -$Account->setAccountUsersId($accountOtherUsers); -$Account->setAccountUserGroupsId($accountOtherGroups); -$Account->setAccountOtherUserEdit($accountUserEditEnabled); -$Account->setAccountOtherGroupEdit($accountGroupEditEnabled); + +$AccountData = new AccountData(); +$AccountData->setAccountId($accountId); +$AccountData->setAccountName($accountName); +$AccountData->setAccountCategoryId($categoryId); +$AccountData->setAccountLogin($accountLogin); +$AccountData->setAccountUrl($accountUrl); +$AccountData->setAccountNotes($accountNotes); +$AccountData->setAccountUserEditId($currentUserId); +$AccountData->setAccountUsersId($accountOtherUsers); +$AccountData->setAccountUserGroupsId($accountOtherGroups); +$AccountData->setAccountOtherUserEdit($accountUserEditEnabled); +$AccountData->setAccountOtherGroupEdit($accountGroupEditEnabled); + +$Account = new Account($AccountData); switch ($actionId) { case ActionsInterface::ACTION_ACC_NEW: @@ -167,16 +170,17 @@ switch ($actionId) { } } - $Account->setAccountPass($accountEncPass['data']); - $Account->setAccountIV($accountEncPass['iv']); - $Account->setAccountUserId($currentUserId); - $Account->setAccountUserGroupId($accountMainGroupId); + $AccountData->setAccountCustomerId($customerId); + $AccountData->setAccountPass($accountEncPass['data']); + $AccountData->setAccountIV($accountEncPass['iv']); + $AccountData->setAccountUserId($currentUserId); + $AccountData->setAccountUserGroupId($accountMainGroupId); // Crear cuenta if ($Account->createAccount()) { if (is_array($customFields)) { foreach ($customFields as $id => $value) { - $CustomFields = new CustomFields($id, $Account->getAccountId(), $value); + $CustomFields = new CustomFields($id, $AccountData->getAccountId(), $value); $CustomFields->addCustomField(); } } @@ -199,9 +203,11 @@ switch ($actionId) { } } + $AccountData->setAccountCustomerId($customerId); + // Cambiar el grupo principal si el usuario es Admin if (Session::getUserIsAdminApp() || Session::getUserIsAdminAcc()) { - $Account->setAccountUserGroupId($accountMainGroupId); + $AccountData->setAccountUserGroupId($accountMainGroupId); } // Comprobar si han habido cambios @@ -223,8 +229,6 @@ switch ($actionId) { Response::printJSON(_('Error al modificar la cuenta')); break; case ActionsInterface::ACTION_ACC_DELETE: - $Account->setAccountId($accountId); - // Eliminar cuenta if ($Account->deleteAccount() && CustomFields::deleteCustomFieldForItem($accountId, ActionsInterface::ACTION_ACC_NEW) @@ -235,8 +239,8 @@ switch ($actionId) { Response::printJSON(_('Error al eliminar la cuenta')); break; case ActionsInterface::ACTION_ACC_EDIT_PASS: - $Account->setAccountPass($accountEncPass['data']); - $Account->setAccountIV($accountEncPass['iv']); + $AccountData->setAccountPass($accountEncPass['data']); + $AccountData->setAccountIV($accountEncPass['iv']); // Actualizar clave de cuenta if ($Account->updateAccountPass()) { @@ -246,8 +250,8 @@ switch ($actionId) { Response::printJSON(_('Error al actualizar la clave')); break; case ActionsInterface::ACTION_ACC_EDIT_RESTORE: - $Account->setAccountId(\SP\Account\AccountHistory::getAccountIdFromId($accountId)); - $Account->setAccountUserEditId($currentUserId); + $AccountData->setAccountId(\SP\Account\AccountHistory::getAccountIdFromId($accountId)); + $AccountData->setAccountUserEditId($currentUserId); if ($Account->restoreFromHistory($accountId)) { Response::printJSON(_('Cuenta restaurada'), 0); diff --git a/ajax/ajax_appMgmtSave.php b/ajax/ajax_appMgmtSave.php index 734266af..8218dfa8 100644 --- a/ajax/ajax_appMgmtSave.php +++ b/ajax/ajax_appMgmtSave.php @@ -23,6 +23,8 @@ * */ +use SP\Account\Account; +use SP\Account\AccountData; use SP\Core\ActionsInterface; use SP\Core\Session; use SP\Core\SPException; @@ -591,8 +593,7 @@ if ($actionId === ActionsInterface::ACTION_USR_USERS_NEW Response::printJSON(_('Error al eliminar el archivo')); } elseif ($actionId === ActionsInterface::ACTION_MGM_ACCOUNTS_DELETE) { - $Account = new \SP\Account\Account(); - $Account->setAccountId($itemId); + $Account = new Account(new AccountData($itemId)); // Eliminar cuenta if ($Account->deleteAccount() diff --git a/ajax/ajax_appMgmtSearch.php b/ajax/ajax_appMgmtSearch.php index 37967ab0..73dd5d0e 100644 --- a/ajax/ajax_appMgmtSearch.php +++ b/ajax/ajax_appMgmtSearch.php @@ -51,7 +51,7 @@ if (!$sk || !SessionUtil::checkSessionKey($sk)) { $actionId = Request::analyze('actionId', 0); $search = Request::analyze('search'); $limitStart = Request::analyze('start', 0); -$limitCount = Request::analyze('count', Config::getValue('account_count')); +$limitCount = Request::analyze('count', Config::getConfig()->getAccountCount()); $Tpl = new Template(); $Tpl->assign('index', Request::analyze('activeTab', 0)); diff --git a/ajax/ajax_configSave.php b/ajax/ajax_configSave.php index c0f3233d..160abbfc 100644 --- a/ajax/ajax_configSave.php +++ b/ajax/ajax_configSave.php @@ -31,6 +31,7 @@ use SP\Core\ActionsInterface; use SP\Core\Crypt; use SP\Core\CryptMasterPass; use SP\Core\Init; +use SP\Core\Session; use SP\Core\SessionUtil; use SP\Core\SPException; use SP\Html\Html; @@ -70,6 +71,7 @@ if ($actionId === ActionsInterface::ACTION_CFG_GENERAL || $actionId === ActionsInterface::ACTION_CFG_MAIL ) { $Log = Log::newLog(_('Modificar Configuración')); + $Config = Session::getConfig(); if ($actionId === ActionsInterface::ACTION_CFG_GENERAL) { // General @@ -82,14 +84,14 @@ if ($actionId === ActionsInterface::ACTION_CFG_GENERAL $checkUpdatesEnabled = Request::analyze('updates', false, false, true); $checkNoticesEnabled = Request::analyze('notices', false, false, true); - Config::setCacheConfigValue('sitelang', $siteLang); - Config::setCacheConfigValue('sitetheme', $siteTheme); - Config::setCacheConfigValue('session_timeout', $sessionTimeout); - Config::setCacheConfigValue('https_enabled', $httpsEnabled); - Config::setCacheConfigValue('debug', $debugEnabled); - Config::setCacheConfigValue('maintenance', $maintenanceEnabled); - Config::setCacheConfigValue('checkupdates', $checkUpdatesEnabled); - Config::setCacheConfigValue('checknotices', $checkNoticesEnabled); + $Config->setSiteLang($siteLang); + $Config->setSiteTheme($siteTheme); + $Config->setSessionTimeout($sessionTimeout); + $Config->setHttpsEnabled($httpsEnabled); + $Config->setDebug($debugEnabled); + $Config->setMaintenance($maintenanceEnabled); + $Config->setCheckUpdates($checkUpdatesEnabled); + $Config->setChecknotices($checkNoticesEnabled); // Events $logEnabled = Request::analyze('log_enabled', false, false, true); @@ -98,17 +100,17 @@ if ($actionId === ActionsInterface::ACTION_CFG_GENERAL $syslogServer = Request::analyze('remotesyslog_server'); $syslogPort = Request::analyze('remotesyslog_port', 0); - Config::setCacheConfigValue('log_enabled', $logEnabled); - Config::setCacheConfigValue('syslog_enabled', $syslogEnabled); + $Config->setLogEnabled($logEnabled); + $Config->setSyslogEnabled($syslogEnabled); if ($remoteSyslogEnabled && (!$syslogServer || !$syslogPort)) { Response::printJSON(_('Faltan parámetros de syslog remoto')); } elseif ($remoteSyslogEnabled) { - Config::setCacheConfigValue('syslog_remote_enabled', $remoteSyslogEnabled); - Config::setCacheConfigValue('syslog_server', $syslogServer); - Config::setCacheConfigValue('syslog_port', $syslogPort); + $Config->setSyslogRemoteEnabled($remoteSyslogEnabled); + $Config->setSyslogServer($syslogServer); + $Config->setSyslogPort($syslogPort); } else { - Config::setCacheConfigValue('syslog_remote_enabled', false); + $Config->setSyslogRemoteEnabled(false); $Log->addDescription(_('Syslog remoto deshabilitado')); } @@ -120,11 +122,11 @@ if ($actionId === ActionsInterface::ACTION_CFG_GENERAL $accountCount = Request::analyze('account_count', 10); $resultsAsCardsEnabled = Request::analyze('resultsascards', false, false, true); - Config::setCacheConfigValue('globalsearch', $globalSearchEnabled); - Config::setCacheConfigValue('account_passtoimage', $accountPassToImageEnabled); - Config::setCacheConfigValue('account_link', $accountLinkEnabled); - Config::setCacheConfigValue('account_count', $accountCount); - Config::setCacheConfigValue('resultsascards', $resultsAsCardsEnabled); + $Config->setGlobalSearch($globalSearchEnabled); + $Config->setAccountPassToImage($accountPassToImageEnabled); + $Config->setAccountLink($accountLinkEnabled); + $Config->setAccountCount($accountCount); + $Config->setResultsAsCards($resultsAsCardsEnabled); // Files $filesEnabled = Request::analyze('files_enabled', false, false, true); @@ -142,11 +144,13 @@ if ($actionId === ActionsInterface::ACTION_CFG_GENERAL Response::printJSON(_('Extensión no permitida')); } }); + $Config->setFilesAllowedExts($exts); + } else { + $Config->setFilesAllowedExts([]); } - Config::setCacheConfigValue('files_enabled', $filesEnabled); - Config::setCacheConfigValue('files_allowed_size', $filesAllowedSize); - Config::setCacheConfigValue('files_allowed_exts', $filesAllowedExts); + $Config->setFilesEnabled($filesEnabled); + $Config->setFilesAllowedSize($filesAllowedSize); // Public Links $pubLinksEnabled = Request::analyze('publinks_enabled', false, false, true); @@ -154,10 +158,10 @@ if ($actionId === ActionsInterface::ACTION_CFG_GENERAL $pubLinksMaxTime = Request::analyze('publinks_maxtime', 10); $pubLinksMaxViews = Request::analyze('publinks_maxviews', 3); - Config::setCacheConfigValue('publinks_enabled', $pubLinksEnabled); - Config::setCacheConfigValue('publinks_image_enabled', $pubLinksImageEnabled); - Config::setCacheConfigValue('publinks_maxtime', $pubLinksMaxTime * 60); - Config::setCacheConfigValue('publinks_maxviews', $pubLinksMaxViews); + $Config->setPublinksEnabled($pubLinksEnabled); + $Config->setPublinksImageEnabled($pubLinksImageEnabled); + $Config->setPublinksMaxTime($pubLinksMaxTime * 60); + $Config->setPublinksMaxViews($pubLinksMaxViews); // Proxy $proxyEnabled = Request::analyze('proxy_enabled', false, false, true); @@ -171,15 +175,15 @@ if ($actionId === ActionsInterface::ACTION_CFG_GENERAL if ($proxyEnabled && (!$proxyServer || !$proxyPort)) { Response::printJSON(_('Faltan parámetros de Proxy')); } elseif ($proxyEnabled) { - Config::setCacheConfigValue('proxy_enabled', true); - Config::setCacheConfigValue('proxy_server', $proxyServer); - Config::setCacheConfigValue('proxy_port', $proxyPort); - Config::setCacheConfigValue('proxy_user', $proxyUser); - Config::setCacheConfigValue('proxy_pass', $proxyPass); + $Config->setProxyEnabled(true); + $Config->setProxyServer($proxyServer); + $Config->setProxyPort($proxyPort); + $Config->setProxyUser($proxyUser); + $Config->setProxyPass($proxyPass); $Log->addDescription(_('Proxy habiltado')); } else { - Config::setCacheConfigValue('proxy_enabled', false); + $Config->setProxyEnabled(false); $Log->addDescription(_('Proxy deshabilitado')); } @@ -196,14 +200,14 @@ if ($actionId === ActionsInterface::ACTION_CFG_GENERAL if ($wikiEnabled && (!$wikiSearchUrl || !$wikiPageUrl || !$wikiFilter)) { Response::printJSON(_('Faltan parámetros de Wiki')); } elseif ($wikiEnabled) { - Config::setCacheConfigValue('wiki_enabled', true); - Config::setCacheConfigValue('wiki_searchurl', $wikiSearchUrl); - Config::setCacheConfigValue('wiki_pageurl', $wikiPageUrl); - Config::setCacheConfigValue('wiki_filter', strtr($wikiFilter, ',', '|')); + $Config->setWikiEnabled(true); + $Config->setWikiSearchurl($wikiSearchUrl); + $Config->setWikiPageurl($wikiPageUrl); + $Config->setWikiFilter(explode(',', $wikiFilter)); $Log->addDescription(_('Wiki habiltada')); } else { - Config::setCacheConfigValue('wiki_enabled', false); + $Config->setWikiEnabled(false); $Log->addDescription(_('Wiki deshabilitada')); } @@ -220,16 +224,16 @@ if ($actionId === ActionsInterface::ACTION_CFG_GENERAL if ($dokuWikiEnabled && (!$dokuWikiUrl || !$dokuWikiUrlBase)) { Response::printJSON(_('Faltan parámetros de DokuWiki')); } elseif ($dokuWikiEnabled) { - Config::setCacheConfigValue('dokuwiki_enabled', true); - Config::setCacheConfigValue('dokuwiki_url', $dokuWikiUrl); - Config::setCacheConfigValue('dokuwiki_urlbase', trim($dokuWikiUrlBase, '/')); - Config::setCacheConfigValue('dokuwiki_user', $dokuWikiUser); - Config::setCacheConfigValue('dokuwiki_pass', $dokuWikiPass); - Config::setCacheConfigValue('dokuwiki_namespace', $dokuWikiNamespace); + $Config->setDokuwikiEnabled(true); + $Config->setDokuwikiUrl($dokuWikiUrl); + $Config->setDokuwikiUrlBase(trim($dokuWikiUrlBase, '/')); + $Config->setDokuwikiUser($dokuWikiUser); + $Config->setDokuwikiPass($dokuWikiPass); + $Config->setDokuwikiNamespace($dokuWikiNamespace); $Log->addDescription(_('DokuWiki habiltada')); } else { - Config::setCacheConfigValue('dokuwiki_enabled', false); + $Config->setDokuwikiEnabled(false); $Log->addDescription(_('DokuWiki deshabilitada')); } @@ -251,19 +255,19 @@ if ($actionId === ActionsInterface::ACTION_CFG_GENERAL if ($ldapEnabled && (!$ldapServer || !$ldapBase || !$ldapBindUser)) { Response::printJSON(_('Faltan parámetros de LDAP')); } elseif ($ldapEnabled) { - Config::setCacheConfigValue('ldap_enabled', true); - Config::setCacheConfigValue('ldap_ads', $ldapADSEnabled); - Config::setCacheConfigValue('ldap_server', $ldapServer); - Config::setCacheConfigValue('ldap_base', $ldapBase); - Config::setCacheConfigValue('ldap_group', $ldapGroup); - Config::setCacheConfigValue('ldap_defaultgroup', $ldapDefaultGroup); - Config::setCacheConfigValue('ldap_defaultprofile', $ldapDefaultProfile); - Config::setCacheConfigValue('ldap_binduser', $ldapBindUser); - Config::setCacheConfigValue('ldap_bindpass', $ldapBindPass); + $Config->setLdapEnabled(true); + $Config->setLdapAds($ldapADSEnabled); + $Config->setLdapServer($ldapServer); + $Config->setLdapBase($ldapBase); + $Config->setLdapGroup($ldapGroup); + $Config->setLdapDefaultGroup($ldapDefaultGroup); + $Config->setLdapDefaultProfile($ldapDefaultProfile); + $Config->setLdapBindUser($ldapBindUser); + $Config->setLdapBindPass($ldapBindPass); $Log->addDescription(_('LDAP habiltado')); } else { - Config::setCacheConfigValue('ldap_enabled', false); + $Config->setLdapEnabled(false); $Log->addDescription(_('LDAP deshabilitado')); } @@ -285,24 +289,24 @@ if ($actionId === ActionsInterface::ACTION_CFG_GENERAL if ($mailEnabled && (!$mailServer || !$mailFrom)) { Response::printJSON(_('Faltan parámetros de Correo')); } elseif ($mailEnabled) { - Config::setCacheConfigValue('mail_enabled', true); - Config::setCacheConfigValue('mail_requestsenabled', $mailRequests); - Config::setCacheConfigValue('mail_server', $mailServer); - Config::setCacheConfigValue('mail_port', $mailPort); - Config::setCacheConfigValue('mail_security', $mailSecurity); - Config::setCacheConfigValue('mail_from', $mailFrom); + $Config->setMailEnabled(true); + $Config->setMailRequestsEnabled($mailRequests); + $Config->setMailServer($mailServer); + $Config->setMailPort($mailPort); + $Config->setMailSecurity($mailSecurity); + $Config->setMailFrom($mailFrom); if ($mailAuth) { - Config::setCacheConfigValue('mail_authenabled', $mailAuth); - Config::setCacheConfigValue('mail_user', $mailUser); - Config::setCacheConfigValue('mail_pass', $mailPass); + $Config->setMailAuthenabled($mailAuth); + $Config->setMailUser($mailUser); + $Config->setMailPass($mailPass); } $Log->addDescription(_('Correo habiltado')); } else { - Config::setCacheConfigValue('mail_enabled', false); - Config::setCacheConfigValue('mail_requestsenabled', false); - Config::setCacheConfigValue('mail_authenabled', false); + $Config->setMailEnabled(false); + $Config->setMailRequestsEnabled(false); + $Config->setMailAuthenabled(false); $Log->addDescription(_('Correo deshabilitado')); } @@ -311,7 +315,7 @@ if ($actionId === ActionsInterface::ACTION_CFG_GENERAL } try { - Config::writeConfig(); + Config::saveConfig(); } catch (SPException $e) { $Log->addDescription(_('Error al guardar la configuración')); $Log->addDetails($e->getMessage(), $e->getHint()); diff --git a/ajax/ajax_files.php b/ajax/ajax_files.php index 7acb4034..9127673c 100644 --- a/ajax/ajax_files.php +++ b/ajax/ajax_files.php @@ -69,13 +69,10 @@ if ($actionId === ActionsInterface::ACTION_ACC_FILES_UPLOAD) { $Log->setAction(_('Subir Archivo')); - $allowedExts = strtoupper(Config::getValue('files_allowed_exts')); - $allowedSize = Config::getValue('files_allowed_size'); + $allowedExts = Config::getConfig()->getFilesAllowedExts(); + $allowedSize = Config::getConfig()->getFilesAllowedSize(); - if ($allowedExts) { - // Extensiones aceptadas - $extsOk = explode(",", $allowedExts); - } else { + if (count($allowedExts) === 0) { $Log->addDescription(_('No hay extensiones permitidas')); $Log->writeLog(); @@ -86,7 +83,7 @@ if ($actionId === ActionsInterface::ACTION_ACC_FILES_UPLOAD) { // Comprobamos la extensión del archivo $fileData['extension'] = strtoupper(pathinfo($_FILES['inFile']['name'], PATHINFO_EXTENSION)); - if (!in_array($fileData['extension'], $extsOk)) { + if (!in_array($fileData['extension'], $allowedExts)) { $Log->addDescription(_('Tipo de archivo no soportado')); $Log->addDetails(_('Extensión'), $fileData['extension']); $Log->writeLog(); diff --git a/ajax/ajax_getContent.php b/ajax/ajax_getContent.php index 0de313af..6d03a6cf 100644 --- a/ajax/ajax_getContent.php +++ b/ajax/ajax_getContent.php @@ -199,7 +199,7 @@ switch ($actionId) { } // Se comprueba si se debe de mostrar la vista de depuración -if (Session::getUserIsAdminApp() && Config::getValue('debug')) { +if (Session::getUserIsAdminApp() && Config::getConfig()->isDebug()) { $Controller->getDebug(); } diff --git a/ajax/ajax_getEnvironment.php b/ajax/ajax_getEnvironment.php index 17616500..02b21b78 100644 --- a/ajax/ajax_getEnvironment.php +++ b/ajax/ajax_getEnvironment.php @@ -41,7 +41,7 @@ $data = array( 'lang' => $stringsJsLang, 'app_root' => Init::$WEBURI, 'pk' => '', - 'max_file_size' => Config::getValue('files_allowed_size') + 'max_file_size' => Config::getConfig()->getFilesAllowedSize() ); try { diff --git a/ajax/ajax_viewpass.php b/ajax/ajax_viewpass.php index 6b81bba9..56cc3835 100644 --- a/ajax/ajax_viewpass.php +++ b/ajax/ajax_viewpass.php @@ -24,6 +24,7 @@ */ use SP\Account\Account; +use SP\Account\AccountData; use SP\Account\AccountHistory; use SP\Core\Acl; use SP\Core\Crypt; @@ -51,10 +52,10 @@ if (!$accountId) { return; } -$Account = (!$isHistory) ? new Account() : new AccountHistory(); +$AccountData = new AccountData($accountId); +$Account = (!$isHistory) ? new Account($AccountData) : new AccountHistory($AccountData); $Account->setAccountParentId(\SP\Core\Session::getAccountParentId()); -$Account->setAccountId($accountId); $accountData = $Account->getAccountPassData(); diff --git a/inc/Base.php b/inc/Base.php index 42cff350..8eb0a917 100644 --- a/inc/Base.php +++ b/inc/Base.php @@ -27,6 +27,7 @@ use SP\Core\Init; defined('APP_ROOT') || die(_('No es posible acceder directamente a este archivo')); +define('XML_CONFIG_FILE', __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'config.xml'); define('CONFIG_FILE', __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'config.php'); define('MODEL_PATH', __DIR__ . DIRECTORY_SEPARATOR . 'SP'); define('CONTROLLER_PATH', __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'web'); diff --git a/inc/SP/Account/Account.class.php b/inc/SP/Account/Account.class.php index 6f31cc3e..5af81ecd 100644 --- a/inc/SP/Account/Account.class.php +++ b/inc/SP/Account/Account.class.php @@ -47,7 +47,7 @@ class Account extends AccountBase implements AccountInterface /** * @var array Variable para la caché de parámetros de una cuenta. */ - private $_cacheParams; + private $cacheParams; /** * Actualiza los datos de una cuenta en la BBDD. @@ -59,7 +59,7 @@ class Account extends AccountBase implements AccountInterface $Log = new Log(__FUNCTION__); // Guardamos una copia de la cuenta en el histórico - if (!AccountHistory::addHistory($this->getAccountId(), false)) { + if (!AccountHistory::addHistory($this->accountData->getAccountId(), false)) { $Log->addDescription(_('Error al actualizar el historial')); $Log->writeLog(); return false; @@ -67,13 +67,13 @@ class Account extends AccountBase implements AccountInterface $Log->setAction(_('Actualizar Cuenta')); - if (!Groups::updateGroupsForAccount($this->getAccountId(), $this->getAccountUserGroupsId())) { + if (!Groups::updateGroupsForAccount($this->accountData->getAccountId(), $this->accountData->getAccountUserGroupsId())) { $Log->addDescription(_('Error al actualizar los grupos secundarios')); $Log->writeLog(); $Log->resetDescription(); } - if (!UserAccounts::updateUsersForAccount($this->getAccountId(), $this->getAccountUsersId())) { + if (!UserAccounts::updateUsersForAccount($this->accountData->getAccountId(), $this->accountData->getAccountUsersId())) { $Log->addDescription(_('Error al actualizar los usuarios de la cuenta')); $Log->writeLog(); $Log->resetDescription(); @@ -81,7 +81,7 @@ class Account extends AccountBase implements AccountInterface $Data = new QueryData(); - if ($this->getAccountUserGroupId()) { + if ($this->accountData->getAccountUserGroupId()) { $query = 'UPDATE accounts SET ' . 'account_customerId = :accountCustomerId,' . 'account_categoryId = :accountCategoryId,' @@ -96,7 +96,7 @@ class Account extends AccountBase implements AccountInterface . 'account_otherGroupEdit = :accountOtherGroupEdit ' . 'WHERE account_id = :accountId'; - $Data->addParam($this->getAccountUserGroupId(), 'accountUserGroupId'); + $Data->addParam($this->accountData->getAccountUserGroupId(), 'accountUserGroupId'); } else { $query = 'UPDATE accounts SET ' . 'account_customerId = :accountCustomerId,' @@ -114,16 +114,16 @@ class Account extends AccountBase implements AccountInterface } $Data->setQuery($query); - $Data->addParam($this->getAccountCustomerId(), 'accountCustomerId'); - $Data->addParam($this->getAccountCategoryId(), 'accountCategoryId'); - $Data->addParam($this->getAccountName(), 'accountName'); - $Data->addParam($this->getAccountLogin(), 'accountLogin'); - $Data->addParam($this->getAccountUrl(), 'accountUrl'); - $Data->addParam($this->getAccountNotes(), 'accountNotes'); - $Data->addParam($this->getAccountUserEditId(), 'accountUserEditId'); - $Data->addParam($this->getAccountOtherUserEdit(), 'accountOtherUserEdit'); - $Data->addParam($this->getAccountOtherGroupEdit(), 'accountOtherGroupEdit'); - $Data->addParam($this->getAccountId(), 'accountId'); + $Data->addParam($this->accountData->getAccountCustomerId(), 'accountCustomerId'); + $Data->addParam($this->accountData->getAccountCategoryId(), 'accountCategoryId'); + $Data->addParam($this->accountData->getAccountName(), 'accountName'); + $Data->addParam($this->accountData->getAccountLogin(), 'accountLogin'); + $Data->addParam($this->accountData->getAccountUrl(), 'accountUrl'); + $Data->addParam($this->accountData->getAccountNotes(), 'accountNotes'); + $Data->addParam($this->accountData->getAccountUserEditId(), 'accountUserEditId'); + $Data->addParam($this->accountData->getAccountOtherUserEdit(), 'accountOtherUserEdit'); + $Data->addParam($this->accountData->getAccountOtherGroupEdit(), 'accountOtherGroupEdit'); + $Data->addParam($this->accountData->getAccountId(), 'accountId'); if (DB::getQuery($Data) === false) { return false; @@ -132,8 +132,8 @@ class Account extends AccountBase implements AccountInterface $accountInfo = array('customer_name'); $this->getAccountInfoById($accountInfo); - $Log->addDetails(Html::strongText(_('Cliente')), $this->_cacheParams['customer_name']); - $Log->addDetails(Html::strongText(_('Cuenta')), $this->getAccountName() . " (" . $this->getAccountId() . ")"); + $Log->addDetails(Html::strongText(_('Cliente')), $this->cacheParams['customer_name']); + $Log->addDetails(Html::strongText(_('Cuenta')), $this->accountData->getAccountName() . " (" . $this->accountData->getAccountId() . ")"); $Log->writeLog(); Email::sendEmail($Log); @@ -141,6 +141,59 @@ class Account extends AccountBase implements AccountInterface return true; } + /** + * Obtener los datos de una cuenta con el id. + * Se guardan los datos en la variable $cacheParams de la clase para consultarlos + * posteriormente. + * + * @param array $params con los campos de la BBDD a obtener + * @return bool + */ + private function getAccountInfoById($params) + { + if (!is_array($params)) { + return false; + } + + if (is_array($this->cacheParams)) { + $cache = true; + + foreach ($params as $param) { + if (!array_key_exists($param, $this->cacheParams)) { + $cache = false; + } + } + + if ($cache) { + return true; + } + } + + $query = 'SELECT ' . implode(',', $params) . ' ' + . 'FROM accounts ' + . 'LEFT JOIN usrGroups ug ON account_userGroupId = usergroup_id ' + . 'LEFT JOIN usrData u1 ON account_userId = u1.user_id ' + . 'LEFT JOIN usrData u2 ON account_userEditId = u2.user_id ' + . 'LEFT JOIN customers ON account_customerId = customer_id ' + . 'WHERE account_id = :id LIMIT 1'; + + $Data = new QueryData(); + $Data->setQuery($query); + $Data->addParam($this->accountData->getAccountId(), 'id'); + + $queryRes = DB::getResults($Data); + + if ($queryRes === false) { + return false; + } + + foreach ($queryRes as $param => $value) { + $this->cacheParams[$param] = $value; + } + + return true; + } + /** * Restaurar una cuenta desde el histórico. * @@ -152,7 +205,7 @@ class Account extends AccountBase implements AccountInterface $Log = new Log(__FUNCTION__); // Guardamos una copia de la cuenta en el histórico - if (!AccountHistory::addHistory($this->getAccountId(), false)) { + if (!AccountHistory::addHistory($this->accountData->getAccountId(), false)) { $Log->setLogLevel(Log::ERROR); $Log->addDescription(_('Error al actualizar el historial')); $Log->writeLog(); @@ -179,8 +232,8 @@ class Account extends AccountBase implements AccountInterface $Data = new QueryData(); $Data->setQuery($query); $Data->addParam($id, 'id'); - $Data->addParam($this->getAccountId(), 'accountId'); - $Data->addParam($this->getAccountUserEditId(), 'accountUserEditId'); + $Data->addParam($this->accountData->getAccountId(), 'accountId'); + $Data->addParam($this->accountData->getAccountUserEditId(), 'accountUserEditId'); if (DB::getQuery($Data) === false) { return false; @@ -190,8 +243,8 @@ class Account extends AccountBase implements AccountInterface $this->getAccountInfoById($accountInfo); $Log->setAction(_('Restaurar Cuenta')); - $Log->addDetails(Html::strongText(_('Cliente')), $this->_cacheParams['customer_name']); - $Log->addDetails(Html::strongText(_('Cuenta')), $this->_cacheParams['account_name'] . " (" . $this->getAccountId() . ")"); + $Log->addDetails(Html::strongText(_('Cliente')), $this->cacheParams['customer_name']); + $Log->addDetails(Html::strongText(_('Cuenta')), $this->cacheParams['account_name'] . " (" . $this->getAccountId() . ")"); $Log->writeLog(); Email::sendEmail($Log); @@ -199,59 +252,6 @@ class Account extends AccountBase implements AccountInterface return true; } - /** - * Obtener los datos de una cuenta con el id. - * Se guardan los datos en la variable $cacheParams de la clase para consultarlos - * posteriormente. - * - * @param array $params con los campos de la BBDD a obtener - * @return bool - */ - private function getAccountInfoById($params) - { - if (!is_array($params)) { - return false; - } - - if (is_array($this->_cacheParams)) { - $cache = true; - - foreach ($params as $param) { - if (!array_key_exists($param, $this->_cacheParams)) { - $cache = false; - } - } - - if ($cache) { - return true; - } - } - - $query = 'SELECT ' . implode(',', $params) . ' ' - . 'FROM accounts ' - . 'LEFT JOIN usrGroups ug ON account_userGroupId = usergroup_id ' - . 'LEFT JOIN usrData u1 ON account_userId = u1.user_id ' - . 'LEFT JOIN usrData u2 ON account_userEditId = u2.user_id ' - . 'LEFT JOIN customers ON account_customerId = customer_id ' - . 'WHERE account_id = :id LIMIT 1'; - - $Data = new QueryData(); - $Data->setQuery($query); - $Data->addParam($this->getAccountId(), 'id'); - - $queryRes = DB::getResults($Data); - - if ($queryRes === false) { - return false; - } - - foreach ($queryRes as $param => $value) { - $this->_cacheParams[$param] = $value; - } - - return true; - } - /** * Obtener los datos de una cuenta. * Esta funcion realiza la consulta a la BBDD y guarda los datos en las variables de la clase. @@ -259,7 +259,7 @@ class Account extends AccountBase implements AccountInterface * @return object * @throws SPException */ - public function getAccountData() + public function getData() { $query = 'SELECT account_id,' . 'account_name,' @@ -296,7 +296,7 @@ class Account extends AccountBase implements AccountInterface $Data = new QueryData(); $Data->setQuery($query); - $Data->addParam($this->getAccountId(), 'id'); + $Data->addParam($this->accountData->getAccountId(), 'id'); $queryRes = DB::getResults($Data); @@ -305,22 +305,22 @@ class Account extends AccountBase implements AccountInterface } // Obtener los usuarios y grupos secundarios - $this->setAccountUsersId(UserAccounts::getUsersForAccount($this->getAccountId())); - $this->setAccountUserGroupsId(Groups::getGroupsForAccount($this->getAccountId())); + $this->accountData->setAccountUsersId(UserAccounts::getUsersForAccount($this->accountData->getAccountId())); + $this->accountData->setAccountUserGroupsId(Groups::getGroupsForAccount($this->accountData->getAccountId())); - $this->setAccountName($queryRes->account_name); - $this->setAccountCategoryId($queryRes->account_categoryId); - $this->setAccountCustomerId($queryRes->account_customerId); - $this->setAccountUserGroupId($queryRes->account_userGroupId); - $this->setAccountUserEditId($queryRes->account_userEditId); - $this->setAccountLogin($queryRes->account_login); - $this->setAccountUrl($queryRes->account_url); - $this->setAccountUrl($queryRes->account_url); - $this->setAccountNotes($queryRes->account_notes); - $this->setAccountUserId($queryRes->account_userId); - $this->setAccountUserGroupId($queryRes->account_userGroupId); - $this->setAccountOtherUserEdit($queryRes->account_otherUserEdit); - $this->setAccountOtherGroupEdit($queryRes->account_otherGroupEdit); + $this->accountData->setAccountName($queryRes->account_name); + $this->accountData->setAccountCategoryId($queryRes->account_categoryId); + $this->accountData->setAccountCustomerId($queryRes->account_customerId); + $this->accountData->setAccountUserGroupId($queryRes->account_userGroupId); + $this->accountData->setAccountUserEditId($queryRes->account_userEditId); + $this->accountData->setAccountLogin($queryRes->account_login); + $this->accountData->setAccountUrl($queryRes->account_url); + $this->accountData->setAccountUrl($queryRes->account_url); + $this->accountData->setAccountNotes($queryRes->account_notes); + $this->accountData->setAccountUserId($queryRes->account_userId); + $this->accountData->setAccountUserGroupId($queryRes->account_userGroupId); + $this->accountData->setAccountOtherUserEdit($queryRes->account_otherUserEdit); + $this->accountData->setAccountOtherGroupEdit($queryRes->account_otherGroupEdit); $this->setAccountModHash($this->calcChangesHash()); return $queryRes; @@ -350,37 +350,37 @@ class Account extends AccountBase implements AccountInterface $Data = new QueryData(); $Data->setQuery($query); - $Data->addParam($this->getAccountCustomerId(), 'accountCustomerId'); - $Data->addParam($this->getAccountCategoryId(), 'accountCategoryId'); - $Data->addParam($this->getAccountName(), 'accountName'); - $Data->addParam($this->getAccountLogin(), 'accountLogin'); - $Data->addParam($this->getAccountUrl(), 'accountUrl'); - $Data->addParam($this->getAccountPass(), 'accountPass'); - $Data->addParam($this->getAccountIV(), 'accountIV'); - $Data->addParam($this->getAccountNotes(), 'accountNotes'); - $Data->addParam($this->getAccountUserId(), 'accountUserId'); - $Data->addParam($this->getAccountUserGroupId(), 'accountUserGroupId'); - $Data->addParam($this->getAccountOtherUserEdit(), 'accountOtherUserEdit'); - $Data->addParam($this->getAccountOtherGroupEdit(), 'accountOtherGroupEdit'); + $Data->addParam($this->accountData->getAccountCustomerId(), 'accountCustomerId'); + $Data->addParam($this->accountData->getAccountCategoryId(), 'accountCategoryId'); + $Data->addParam($this->accountData->getAccountName(), 'accountName'); + $Data->addParam($this->accountData->getAccountLogin(), 'accountLogin'); + $Data->addParam($this->accountData->getAccountUrl(), 'accountUrl'); + $Data->addParam($this->accountData->getAccountPass(), 'accountPass'); + $Data->addParam($this->accountData->getAccountIV(), 'accountIV'); + $Data->addParam($this->accountData->getAccountNotes(), 'accountNotes'); + $Data->addParam($this->accountData->getAccountUserId(), 'accountUserId'); + $Data->addParam($this->accountData->getAccountUserGroupId(), 'accountUserGroupId'); + $Data->addParam($this->accountData->getAccountOtherUserEdit(), 'accountOtherUserEdit'); + $Data->addParam($this->accountData->getAccountOtherGroupEdit(), 'accountOtherGroupEdit'); if (DB::getQuery($Data) === false) { return false; } - $this->setAccountId(DB::$lastId); + $this->accountData->setAccountId(DB::$lastId); $Log = new Log(__FUNCTION__); - if (is_array($this->getAccountUserGroupsId())) { - if (!Groups::addGroupsForAccount($this->getAccountId(), $this->getAccountUserGroupsId())) { + if (is_array($this->accountData->getAccountUserGroupsId())) { + if (!Groups::addGroupsForAccount($this->accountData->getAccountId(), $this->accountData->getAccountUserGroupsId())) { $Log->addDescription(_('Error al actualizar los grupos secundarios')); $Log->writeLog(); $Log->resetDescription(); } } - if (is_array($this->getAccountUsersId())) { - if (!UserAccounts::addUsersForAccount($this->getAccountId(), $this->getAccountUsersId())) { + if (is_array($this->accountData->getAccountUsersId())) { + if (!UserAccounts::addUsersForAccount($this->accountData->getAccountId(), $this->accountData->getAccountUsersId())) { $Log->addDescription(_('Error al actualizar los usuarios de la cuenta')); $Log->writeLog(); $Log->resetDescription(); @@ -391,8 +391,8 @@ class Account extends AccountBase implements AccountInterface $this->getAccountInfoById($accountInfo); $Log->setAction(_('Nueva Cuenta')); - $Log->addDetails(Html::strongText(_('Cliente')), $this->_cacheParams['customer_name']); - $Log->addDetails(Html::strongText(_('Cuenta')), $this->getAccountName() . " (" . $this->getAccountId() . ")"); + $Log->addDetails(Html::strongText(_('Cliente')), $this->cacheParams['customer_name']); + $Log->addDetails(Html::strongText(_('Cuenta')), $this->accountData->getAccountName() . " (" . $this->accountData->getAccountId() . ")"); $Log->writeLog(); Email::sendEmail($Log); @@ -407,37 +407,38 @@ class Account extends AccountBase implements AccountInterface */ public function deleteAccount() { + // FIXME // Guardamos una copia de la cuenta en el histórico - AccountHistory::addHistory($this->getAccountId(), true) || die (_('ERROR: Error en la operación.')); + AccountHistory::addHistory($this->accountData->getAccountId(), true) || die (_('ERROR: Error en la operación.')); $accountInfo = array('account_name,customer_name'); $this->getAccountInfoById($accountInfo); $Log = new Log(_('Eliminar Cuenta')); - $Log->addDetails(Html::strongText(_('Cliente')), $this->_cacheParams['customer_name']); - $Log->addDetails(Html::strongText(_('Cuenta')), $this->_cacheParams['account_name'] . " (" . $this->getAccountId() . ")"); + $Log->addDetails(Html::strongText(_('Cliente')), $this->cacheParams['customer_name']); + $Log->addDetails(Html::strongText(_('Cuenta')), $this->cacheParams['account_name'] . " (" . $this->accountData->getAccountId() . ")"); $query = 'DELETE FROM accounts WHERE account_id = :id LIMIT 1'; $Data = new QueryData(); $Data->setQuery($query); - $Data->addParam($this->getAccountId(), 'id'); + $Data->addParam($this->accountData->getAccountId(), 'id'); if (DB::getQuery($Data) === false) { return false; } - if (!Groups::deleteGroupsForAccount($this->getAccountId())) { + if (!Groups::deleteGroupsForAccount($this->accountData->getAccountId())) { $Log->setLogLevel(Log::ERROR); $Log->addDescription(_('Error al eliminar grupos asociados a la cuenta')); } - if (!UserAccounts::deleteUsersForAccount($this->getAccountId())) { + if (!UserAccounts::deleteUsersForAccount($this->accountData->getAccountId())) { $Log->setLogLevel(Log::ERROR); $Log->addDescription(_('Error al eliminar usuarios asociados a la cuenta')); } - if (!Files::deleteAccountFiles($this->getAccountId())) { + if (!Files::deleteAccountFiles($this->accountData->getAccountId())) { $Log->setLogLevel(Log::ERROR); $Log->addDescription(_('Error al eliminar archivos asociados a la cuenta')); } @@ -460,7 +461,7 @@ class Account extends AccountBase implements AccountInterface $Data = new QueryData(); $Data->setQuery($query); - $Data->addParam($this->getAccountId(), 'id'); + $Data->addParam($this->accountData->getAccountId(), 'id'); return DB::getQuery($Data); } @@ -476,7 +477,7 @@ class Account extends AccountBase implements AccountInterface $Data = new QueryData(); $Data->setQuery($query); - $Data->addParam($this->getAccountId(), 'id'); + $Data->addParam($this->accountData->getAccountId(), 'id'); return DB::getQuery($Data); } @@ -518,16 +519,16 @@ class Account extends AccountBase implements AccountInterface } foreach ($accountsPass as $account) { - $this->setAccountId($account->account_id); - $this->setAccountUserEditId($userId); + $this->accountData->setAccountId($account->account_id); + $this->accountData->setAccountUserEditId($userId); // No realizar cambios si está en modo demo if ($demoEnabled) { - $accountsOk[] = $this->getAccountId(); + $accountsOk[] = $this->accountData->getAccountId(); continue; } - if (strlen($account->account_pass) === 0){ + if (strlen($account->account_pass) === 0) { $Log->addDescription(_('Clave de cuenta vacía') . ' (' . $account->account_id . ') ' . $account->account_name); continue; } @@ -537,10 +538,10 @@ class Account extends AccountBase implements AccountInterface } $decryptedPass = Crypt::getDecrypt($account->account_pass, $account->account_IV); - $this->setAccountPass(Crypt::mkEncrypt($decryptedPass, $newMasterPass)); - $this->setAccountIV(Crypt::$strInitialVector); + $this->accountData->setAccountPass(Crypt::mkEncrypt($decryptedPass, $newMasterPass)); + $this->accountData->setAccountIV(Crypt::$strInitialVector); - if ($this->getAccountPass() === false) { + if ($this->accountData->getAccountPass() === false) { $errorCount++; $Log->addDescription(_('No es posible desencriptar la clave de la cuenta') . ' (' . $account->account_id . ') ' . $account->account_name); continue; @@ -548,11 +549,11 @@ class Account extends AccountBase implements AccountInterface if (!$this->updateAccountPass(true)) { $errorCount++; - $Log->addDescription(_('Fallo al actualizar la clave de la cuenta') . ' (' . $this->getAccountId() . ') ' . $account->acchistory_name); + $Log->addDescription(_('Fallo al actualizar la clave de la cuenta') . ' (' . $this->getAccountId() . ') ' . $account->acchistory_name); continue; } - $accountsOk[] = $this->getAccountId(); + $accountsOk[] = $this->accountData->getAccountId(); } // Vaciar el array de mensajes de log @@ -592,6 +593,63 @@ class Account extends AccountBase implements AccountInterface return DB::getResults($Data); } + /** + * Actualiza la clave de una cuenta en la BBDD. + * + * @param bool $isMassive para no actualizar el histórico ni enviar mensajes + * @param bool $isRestore indica si es una restauración + * @return bool + */ + public function updateAccountPass($isMassive = false, $isRestore = false) + { + $Log = new Log(__FUNCTION__); + + // No actualizar el histórico si es por cambio de clave maestra o restauración + if (!$isMassive && !$isRestore) { + // Guardamos una copia de la cuenta en el histórico + if (!AccountHistory::addHistory($this->accountData->getAccountId(), false)) { + $Log->addDescription(_('Error al actualizar el historial')); + $Log->writeLog(); + return false; + } + } + + $query = 'UPDATE accounts SET ' + . 'account_pass = :accountPass,' + . 'account_IV = :accountIV,' + . 'account_userEditId = :accountUserEditId,' + . 'account_dateEdit = NOW() ' + . 'WHERE account_id = :accountId'; + + $Data = new QueryData(); + $Data->setQuery($query); + $Data->addParam($this->accountData->getAccountPass(), 'accountPass'); + $Data->addParam($this->accountData->getAccountIV(), 'accountIV'); + $Data->addParam($this->accountData->getAccountUserEditId(), 'accountUserEditId'); + $Data->addParam($this->accountData->getAccountId(), 'accountId'); + + + if (DB::getQuery($Data) === false) { + return false; + } + + // No escribir en el log ni enviar correos si la actualización es + // por cambio de clave maestra o restauración + if (!$isMassive && !$isRestore) { + $accountInfo = array('customer_name', 'account_name'); + $this->getAccountInfoById($accountInfo); + + $Log->setAction(_('Modificar Clave')); + $Log->addDetails(Html::strongText(_('Cliente')), $this->cacheParams['customer_name']); + $Log->addDetails(Html::strongText(_('Cuenta')), $this->cacheParams['account_name'] . " (" . $this->accountData->getAccountId() . ")"); + $Log->writeLog(); + + Email::sendEmail($Log); + } + + return true; + } + /** * Obtener los datos de una cuenta para mostrar la clave * Esta funcion realiza la consulta a la BBDD y devuelve los datos. @@ -613,7 +671,7 @@ class Account extends AccountBase implements AccountInterface $Data = new QueryData(); $Data->setQuery($query); - $Data->addParam($this->getAccountId(), 'id'); + $Data->addParam($this->accountData->getAccountId(), 'id'); $queryRes = DB::getResults($Data); @@ -621,68 +679,11 @@ class Account extends AccountBase implements AccountInterface return false; } - $this->setAccountUserId($queryRes->userId); - $this->setAccountUserGroupId($queryRes->groupId); - $this->setAccountPass($queryRes->pass); - $this->setAccountIV($queryRes->iv); + $this->accountData->setAccountUserId($queryRes->userId); + $this->accountData->setAccountUserGroupId($queryRes->groupId); + $this->accountData->setAccountPass($queryRes->pass); + $this->accountData->setAccountIV($queryRes->iv); return $queryRes; } - - /** - * Actualiza la clave de una cuenta en la BBDD. - * - * @param bool $isMassive para no actualizar el histórico ni enviar mensajes - * @param bool $isRestore indica si es una restauración - * @return bool - */ - public function updateAccountPass($isMassive = false, $isRestore = false) - { - $Log = new Log(__FUNCTION__); - - // No actualizar el histórico si es por cambio de clave maestra o restauración - if (!$isMassive && !$isRestore) { - // Guardamos una copia de la cuenta en el histórico - if (!AccountHistory::addHistory($this->getAccountId(), false)) { - $Log->addDescription(_('Error al actualizar el historial')); - $Log->writeLog(); - return false; - } - } - - $query = 'UPDATE accounts SET ' - . 'account_pass = :accountPass,' - . 'account_IV = :accountIV,' - . 'account_userEditId = :accountUserEditId,' - . 'account_dateEdit = NOW() ' - . 'WHERE account_id = :accountId'; - - $Data = new QueryData(); - $Data->setQuery($query); - $Data->addParam($this->getAccountPass(), 'accountPass'); - $Data->addParam($this->getAccountIV(), 'accountIV'); - $Data->addParam($this->getAccountUserEditId(), 'accountUserEditId'); - $Data->addParam($this->getAccountId(), 'accountId'); - - - if (DB::getQuery($Data) === false) { - return false; - } - - // No escribir en el log ni enviar correos si la actualización es - // por cambio de clave maestra o restauración - if (!$isMassive && !$isRestore) { - $accountInfo = array('customer_name', 'account_name'); - $this->getAccountInfoById($accountInfo); - - $Log->setAction(_('Modificar Clave')); - $Log->addDetails(Html::strongText(_('Cliente')), $this->_cacheParams['customer_name']); - $Log->addDetails(Html::strongText(_('Cuenta')), $this->_cacheParams['account_name'] . " (" . $this->getAccountId() . ")"); - $Log->writeLog(); - - Email::sendEmail($Log); - } - - return true; - } } \ No newline at end of file diff --git a/inc/SP/Account/AccountBase.class.php b/inc/SP/Account/AccountBase.class.php index 359388f6..8a10d0bd 100644 --- a/inc/SP/Account/AccountBase.class.php +++ b/inc/SP/Account/AccountBase.class.php @@ -38,149 +38,39 @@ abstract class AccountBase * Tiempo de expiración de la caché de ACLde usuarios/grupos de cuentas */ const CACHE_EXPIRE_TIME = 300; + /** + * @var AccountData + */ + protected $accountData; /** * @var int Id de la cuenta padre. */ - private $_accountParentId; + private $accountParentId; /** * @var string Hash con los datos de la cuenta para verificación de cambios. */ - private $_accountModHash; + private $accountModHash; /** * @var int Indica si la cuenta es un registro del hitórico. */ - private $_accountIsHistory = 0; - /** - * @var int Id de la cuenta. - */ - private $_accountId; - /** - * @var int Id del usuario principal de la cuenta. - */ - private $_accountUserId; - /** - * @var array Los Ids de los usuarios secundarios de la cuenta. - */ - private $_accountUsersId; - /** - * @var array Id del grupo principal de la cuenta. - */ - private $_accountUserGroupId; - /** - * @var array Los Ids de los grupos secundarios de la cuenta. - */ - private $_accountUserGroupsId; - /** - * @var int Id del usuario que editó la cuenta. - */ - private $_accountUserEditId; - /** - * @var string El nombre de la cuenta. - */ - private $_accountName; - /** - * @var int Id del cliente de la cuenta. - */ - private $_accountCustomerId; - /** - * @var int Id de la categoría de la cuenta. - */ - private $_accountCategoryId; - /** - * @var string El nombre de usuario de la cuenta. - */ - private $_accountLogin; - /** - * @var string La URL de la cuenta. - */ - private $_accountUrl; - /** - * @var string La clave de la cuenta. - */ - private $_accountPass; - /** - * @var string El vector de inicialización de la cuenta. - */ - private $_accountIV; - /** - * @var string Las nosta de la cuenta. - */ - private $_accountNotes; - /** - * @var bool Si se permite la edición por los usuarios secundarios. - */ - private $_accountOtherUserEdit; - /** - * @var bool Si se permita la edición por los grupos secundarios. - */ - private $_accountOtherGroupEdit; + private $accountIsHistory = 0; /** * @var array Los Ids de los grupos con acceso a la cuenta */ - private $_cacheUserGroupsId; + private $cacheUserGroupsId; /** * @var array Los Ids de los usuarios con acceso a la cuenta */ - private $_cacheUsersId; + private $cacheUsersId; /** * Constructor * - * @param int $id con el Id de la cuenta a obtener + * @param AccountData $accountData */ - public function __construct($id = null) + public function __construct(AccountData $accountData = null) { - if (!is_null($id)) { - $this->setAccountId($id); - } - } - - /** - * @return int - */ - public function getAccountUserEditId() - { - return $this->_accountUserEditId; - } - - /** - * @param int $accountUserEditId - */ - public function setAccountUserEditId($accountUserEditId) - { - $this->_accountUserEditId = $accountUserEditId; - } - - /** - * @return string - */ - public function getAccountPass() - { - return $this->_accountPass; - } - - /** - * @param string $accountPass - */ - public function setAccountPass($accountPass) - { - $this->_accountPass = $accountPass; - } - - /** - * @return string - */ - public function getAccountIV() - { - return $this->_accountIV; - } - - /** - * @param string $accountIV - */ - public function setAccountIV($accountIV) - { - $this->_accountIV = $accountIV; + $this->accountData = (!is_null($accountData)) ? $accountData : new AccountData(); } /** @@ -188,7 +78,7 @@ abstract class AccountBase */ public function getAccountIsHistory() { - return $this->_accountIsHistory; + return $this->accountIsHistory; } /** @@ -196,7 +86,7 @@ abstract class AccountBase */ public function setAccountIsHistory($accountIsHistory) { - $this->_accountIsHistory = $accountIsHistory; + $this->accountIsHistory = $accountIsHistory; } /** @@ -204,7 +94,7 @@ abstract class AccountBase */ public function getAccountParentId() { - return $this->_accountParentId; + return $this->accountParentId; } /** @@ -212,7 +102,7 @@ abstract class AccountBase */ public function setAccountParentId($accountParentId) { - $this->_accountParentId = $accountParentId; + $this->accountParentId = $accountParentId; } /** @@ -223,67 +113,19 @@ abstract class AccountBase */ public function getAccountDataForACL($accountId = null) { - $accId = (!is_null($accountId)) ? $accountId : $this->getAccountId(); + $accId = (!is_null($accountId)) ? $accountId : $this->accountData->getAccountId(); return array( 'id' => $accId, - 'user_id' => $this->getAccountUserId(), - 'group_id' => $this->getAccountUserGroupId(), - 'users_id' => $this->getUsersAccount(), - 'groups_id' => $this->getGroupsAccount(), - 'otheruser_edit' => $this->getAccountOtherUserEdit(), - 'othergroup_edit' => $this->getAccountOtherGroupEdit() + 'user_id' => $this->accountData->getAccountUserId(), + 'group_id' => $this->accountData->getAccountUserGroupId(), + 'users_id' => $this->accountData->getAccountUsersId(), + 'groups_id' => $this->accountData->getAccountUserGroupsId(), + 'otheruser_edit' => $this->accountData->getAccountOtherUserEdit(), + 'othergroup_edit' => $this->accountData->getAccountOtherGroupEdit() ); } - /** - * @return int|null - */ - public function getAccountId() - { - return $this->_accountId; - } - - /** - * @param int $accountId - */ - public function setAccountId($accountId) - { - $this->_accountId = (int)$accountId; - } - - /** - * @return int - */ - public function getAccountUserId() - { - return $this->_accountUserId; - } - - /** - * @param int $accountUserId - */ - public function setAccountUserId($accountUserId) - { - $this->_accountUserId = $accountUserId; - } - - /** - * @return int - */ - public function getAccountUserGroupId() - { - return $this->_accountUserGroupId; - } - - /** - * @param int $accountUserGroupId - */ - public function setAccountUserGroupId($accountUserGroupId) - { - $this->_accountUserGroupId = $accountUserGroupId; - } - /** * Obtiene el listado usuarios con acceso a una cuenta. * Lo almacena en la cache de sesión como array de cuentas @@ -292,7 +134,7 @@ abstract class AccountBase */ public function getUsersAccount() { - $accId = $this->getAccountId(); + $accId = $this->accountData->getAccountId(); $cacheUsers = &$_SESSION['cache']['usersId']; @@ -318,7 +160,7 @@ abstract class AccountBase */ public function getGroupsAccount() { - $accId = $this->getAccountId(); + $accId = $this->accountData->getAccountId(); $cacheUserGroups = &$_SESSION['cache']['userGroupsId']; if (!is_array($cacheUserGroups)) { @@ -335,37 +177,6 @@ abstract class AccountBase return $cacheUserGroups[$accId]; } - /** - * @return bool - */ - public function getAccountOtherUserEdit() - { - return intval($this->_accountOtherUserEdit); - } - - /** - * @param bool $accountOtherUserEdit - */ - public function setAccountOtherUserEdit($accountOtherUserEdit) - { - $this->_accountOtherUserEdit = $accountOtherUserEdit; - } - - /** - * @return bool - */ - public function getAccountOtherGroupEdit() - { - return intval($this->_accountOtherGroupEdit); - } - - /** - * @param bool $accountOtherGroupEdit - */ - public function setAccountOtherGroupEdit($accountOtherGroupEdit) - { - $this->_accountOtherGroupEdit = $accountOtherGroupEdit; - } /** * Calcular el hash de los datos de una cuenta. @@ -379,10 +190,10 @@ abstract class AccountBase $groups = 0; $users = 0; - if (is_array($this->getAccountUserGroupsId())) { - $groups = implode($this->getAccountUserGroupsId()); - } elseif (is_array($this->_cacheUserGroupsId)) { - foreach ($this->_cacheUserGroupsId as $group) { + if (is_array($this->accountData->getAccountUserGroupsId())) { + $groups = implode($this->accountData->getAccountUserGroupsId()); + } elseif (is_array($this->cacheUserGroupsId)) { + foreach ($this->cacheUserGroupsId as $group) { if (is_array($group)) { // Ordenar el array para que el hash sea igual sort($group, SORT_NUMERIC); @@ -391,10 +202,10 @@ abstract class AccountBase } } - if (is_array($this->getAccountUsersId())) { - $users = implode($this->getAccountUsersId()); - } elseif (is_array($this->_cacheUsersId)) { - foreach ($this->_cacheUsersId as $user) { + if (is_array($this->accountData->getAccountUsersId())) { + $users = implode($this->accountData->getAccountUsersId()); + } elseif (is_array($this->cacheUsersId)) { + foreach ($this->cacheUsersId as $user) { if (is_array($user)) { // Ordenar el array para que el hash sea igual sort($user, SORT_NUMERIC); @@ -406,14 +217,14 @@ abstract class AccountBase if ($this->getAccountModHash()) { $hashItems = $this->getAccountModHash() . (int)$users . (int)$groups; } else { - $hashItems = $this->getAccountName() . - $this->getAccountCategoryId() . - $this->getAccountCustomerId() . - $this->getAccountLogin() . - $this->getAccountUrl() . - $this->getAccountNotes() . - (int)$this->getAccountOtherUserEdit() . - (int)$this->getAccountOtherGroupEdit() . + $hashItems = $this->accountData->getAccountName() . + $this->accountData->getAccountCategoryId() . + $this->accountData->getAccountCustomerId() . + $this->accountData->getAccountLogin() . + $this->accountData->getAccountUrl() . + $this->accountData->getAccountNotes() . + (int)$this->accountData->getAccountOtherUserEdit() . + (int)$this->accountData->getAccountOtherGroupEdit() . (int)$users . (int)$groups; } @@ -421,44 +232,13 @@ abstract class AccountBase return md5($hashItems); } - /** - * @return array - */ - public function getAccountUserGroupsId() - { - return $this->_accountUserGroupsId; - } - - /** - * @param array $accountUserGroupsId - */ - public function setAccountUserGroupsId($accountUserGroupsId) - { - $this->_accountUserGroupsId = $accountUserGroupsId; - } - - /** - * @return array - */ - public function getAccountUsersId() - { - return $this->_accountUsersId; - } - - /** - * @param array $accountUsersId - */ - public function setAccountUsersId($accountUsersId) - { - $this->_accountUsersId = $accountUsersId; - } /** * @return string */ public function getAccountModHash() { - return $this->_accountModHash; + return $this->accountModHash; } /** @@ -466,103 +246,15 @@ abstract class AccountBase */ public function setAccountModHash($accountModHash) { - $this->_accountModHash = $accountModHash; + $this->accountModHash = $accountModHash; } /** - * @return string + * @return AccountData */ - public function getAccountName() + public function getAccountData() { - return $this->_accountName; - } - - /** - * @param string $accountName - */ - public function setAccountName($accountName) - { - $this->_accountName = $accountName; - } - - /** - * @return int - */ - public function getAccountCategoryId() - { - return $this->_accountCategoryId; - } - - /** - * @param int $accountCategoryId - */ - public function setAccountCategoryId($accountCategoryId) - { - $this->_accountCategoryId = $accountCategoryId; - } - - /** - * @return int - */ - public function getAccountCustomerId() - { - return $this->_accountCustomerId; - } - - /** - * @param int $accountCustomerId - */ - public function setAccountCustomerId($accountCustomerId) - { - $this->_accountCustomerId = $accountCustomerId; - } - - /** - * @return string - */ - public function getAccountLogin() - { - return $this->_accountLogin; - } - - /** - * @param string $accountLogin - */ - public function setAccountLogin($accountLogin) - { - $this->_accountLogin = $accountLogin; - } - - /** - * @return string - */ - public function getAccountUrl() - { - return $this->_accountUrl; - } - - /** - * @param string $accountUrl - */ - public function setAccountUrl($accountUrl) - { - $this->_accountUrl = $accountUrl; - } - - /** - * @return string - */ - public function getAccountNotes() - { - return $this->_accountNotes; - } - - /** - * @param string $accountNotes - */ - public function setAccountNotes($accountNotes) - { - $this->_accountNotes = $accountNotes; + return $this->accountData; } /** diff --git a/inc/SP/Account/AccountData.class.php b/inc/SP/Account/AccountData.class.php new file mode 100644 index 00000000..3b48bb44 --- /dev/null +++ b/inc/SP/Account/AccountData.class.php @@ -0,0 +1,445 @@ +. + * + */ + +namespace SP\Account; + +/** + * Class AccountData + * + * @package SP\Account + */ +class AccountData +{ + /** + * @var int Id de la cuenta. + */ + private $accountId = 0; + /** + * @var int Id del usuario principal de la cuenta. + */ + private $accountUserId = 0; + /** + * @var array Los Ids de los usuarios secundarios de la cuenta. + */ + private $accountUsersId = []; + /** + * @var array Id del grupo principal de la cuenta. + */ + private $accountUserGroupId = []; + /** + * @var array Los Ids de los grupos secundarios de la cuenta. + */ + private $accountUserGroupsId = []; + /** + * @var int Id del usuario que editó la cuenta. + */ + private $accountUserEditId = 0; + /** + * @var string El nombre de la cuenta. + */ + private $accountName = ''; + /** + * @var int Id del cliente de la cuenta. + */ + private $accountCustomerId = 0; + /** + * @var int Id de la categoría de la cuenta. + */ + private $accountCategoryId = 0; + /** + * @var string El nombre de usuario de la cuenta. + */ + private $accountLogin = ''; + /** + * @var string La URL de la cuenta. + */ + private $accountUrl = ''; + /** + * @var string La clave de la cuenta. + */ + private $accountPass = ''; + /** + * @var string El vector de inicialización de la cuenta. + */ + private $accountIV = ''; + /** + * @var string Las nosta de la cuenta. + */ + private $accountNotes = ''; + /** + * @var bool Si se permite la edición por los usuarios secundarios. + */ + private $accountOtherUserEdit = false; + /** + * @var bool Si se permita la edición por los grupos secundarios. + */ + private $accountOtherGroupEdit = false; + /** + * @var int + */ + private $dateAdd = 0; + /** + * @var int + */ + private $dateEdit = 0; + /** + * @var bool + */ + private $isModify = false; + /** + * @var bool + */ + private $isDeleted = false; + + /** + * AccountData constructor. + * + * @param int $accountId + */ + public function __construct($accountId = 0) + { + $this->accountId = $accountId; + } + + /** + * @return int + */ + public function getDateAdd() + { + return $this->dateAdd; + } + + /** + * @param int $dateAdd + */ + public function setDateAdd($dateAdd) + { + $this->dateAdd = $dateAdd; + } + + /** + * @return int + */ + public function getDateEdit() + { + return $this->dateEdit; + } + + /** + * @param int $dateEdit + */ + public function setDateEdit($dateEdit) + { + $this->dateEdit = $dateEdit; + } + + /** + * @return boolean + */ + public function isIsModify() + { + return $this->isModify; + } + + /** + * @param boolean $isModify + */ + public function setIsModify($isModify) + { + $this->isModify = $isModify; + } + + /** + * @return boolean + */ + public function isIsDeleted() + { + return $this->isDeleted; + } + + /** + * @param boolean $isDeleted + */ + public function setIsDeleted($isDeleted) + { + $this->isDeleted = $isDeleted; + } + + /** + * @return int + */ + public function getAccountUserEditId() + { + return $this->accountUserEditId; + } + + /** + * @param int $accountUserEditId + */ + public function setAccountUserEditId($accountUserEditId) + { + $this->accountUserEditId = $accountUserEditId; + } + + /** + * @return string + */ + public function getAccountPass() + { + return $this->accountPass; + } + + /** + * @param string $accountPass + */ + public function setAccountPass($accountPass) + { + $this->accountPass = $accountPass; + } + + /** + * @return string + */ + public function getAccountIV() + { + return $this->accountIV; + } + + /** + * @param string $accountIV + */ + public function setAccountIV($accountIV) + { + $this->accountIV = $accountIV; + } + + /** + * @return int|null + */ + public function getAccountId() + { + return $this->accountId; + } + + /** + * @param int $accountId + */ + public function setAccountId($accountId) + { + $this->accountId = (int)$accountId; + } + + /** + * @return int + */ + public function getAccountUserId() + { + return $this->accountUserId; + } + + /** + * @param int $accountUserId + */ + public function setAccountUserId($accountUserId) + { + $this->accountUserId = $accountUserId; + } + + /** + * @return int + */ + public function getAccountUserGroupId() + { + return $this->accountUserGroupId; + } + + /** + * @param int $accountUserGroupId + */ + public function setAccountUserGroupId($accountUserGroupId) + { + $this->accountUserGroupId = $accountUserGroupId; + } + + /** + * @return bool + */ + public function getAccountOtherUserEdit() + { + return intval($this->accountOtherUserEdit); + } + + /** + * @param bool $accountOtherUserEdit + */ + public function setAccountOtherUserEdit($accountOtherUserEdit) + { + $this->accountOtherUserEdit = $accountOtherUserEdit; + } + + /** + * @return bool + */ + public function getAccountOtherGroupEdit() + { + return intval($this->accountOtherGroupEdit); + } + + /** + * @param bool $accountOtherGroupEdit + */ + public function setAccountOtherGroupEdit($accountOtherGroupEdit) + { + $this->accountOtherGroupEdit = $accountOtherGroupEdit; + } + + /** + * @return array + */ + public function getAccountUserGroupsId() + { + return $this->accountUserGroupsId; + } + + /** + * @param array $accountUserGroupsId + */ + public function setAccountUserGroupsId($accountUserGroupsId) + { + $this->accountUserGroupsId = $accountUserGroupsId; + } + + /** + * @return array + */ + public function getAccountUsersId() + { + return $this->accountUsersId; + } + + /** + * @param array $accountUsersId + */ + public function setAccountUsersId($accountUsersId) + { + $this->accountUsersId = $accountUsersId; + } + + /** + * @return string + */ + public function getAccountName() + { + return $this->accountName; + } + + /** + * @param string $accountName + */ + public function setAccountName($accountName) + { + $this->accountName = $accountName; + } + + /** + * @return int + */ + public function getAccountCategoryId() + { + return $this->accountCategoryId; + } + + /** + * @param int $accountCategoryId + */ + public function setAccountCategoryId($accountCategoryId) + { + $this->accountCategoryId = $accountCategoryId; + } + + /** + * @return int + */ + public function getAccountCustomerId() + { + return $this->accountCustomerId; + } + + /** + * @param int $accountCustomerId + */ + public function setAccountCustomerId($accountCustomerId) + { + $this->accountCustomerId = $accountCustomerId; + } + + /** + * @return string + */ + public function getAccountLogin() + { + return $this->accountLogin; + } + + /** + * @param string $accountLogin + */ + public function setAccountLogin($accountLogin) + { + $this->accountLogin = $accountLogin; + } + + /** + * @return string + */ + public function getAccountUrl() + { + return $this->accountUrl; + } + + /** + * @param string $accountUrl + */ + public function setAccountUrl($accountUrl) + { + $this->accountUrl = $accountUrl; + } + + /** + * @return string + */ + public function getAccountNotes() + { + return $this->accountNotes; + } + + /** + * @param string $accountNotes + */ + public function setAccountNotes($accountNotes) + { + $this->accountNotes = $accountNotes; + } +} \ No newline at end of file diff --git a/inc/SP/Account/AccountHistory.class.php b/inc/SP/Account/AccountHistory.class.php index cc7902ac..35aaac78 100644 --- a/inc/SP/Account/AccountHistory.class.php +++ b/inc/SP/Account/AccountHistory.class.php @@ -43,8 +43,8 @@ defined('APP_ROOT') || die(_('No es posible acceder directamente a este archivo' */ class AccountHistory extends AccountBase implements AccountInterface { - private $_isDelete = false; - private $_isModify = false; + private $isDelete = false; + private $isModify = false; /** * Obtiene el listado del histórico de una cuenta. @@ -95,7 +95,7 @@ class AccountHistory extends AccountBase implements AccountInterface */ public function isIsDelete() { - return $this->_isDelete; + return $this->isDelete; } /** @@ -103,7 +103,7 @@ class AccountHistory extends AccountBase implements AccountInterface */ public function setIsDelete($isDelete) { - $this->_isDelete = $isDelete; + $this->isDelete = $isDelete; } /** @@ -111,7 +111,7 @@ class AccountHistory extends AccountBase implements AccountInterface */ public function isIsModify() { - return $this->_isModify; + return $this->isModify; } /** @@ -119,7 +119,7 @@ class AccountHistory extends AccountBase implements AccountInterface */ public function setIsModify($isModify) { - $this->_isModify = $isModify; + $this->isModify = $isModify; } /** @@ -325,7 +325,7 @@ class AccountHistory extends AccountBase implements AccountInterface * @return object * @throws SPException */ - public function getAccountData() + public function getData() { $query = 'SELECT acchistory_accountId as account_id,' . 'acchistory_customerId as account_customerId,' @@ -363,7 +363,7 @@ class AccountHistory extends AccountBase implements AccountInterface $Data = new QueryData(); $Data->setQuery($query); - $Data->addParam($this->getAccountId(), 'id'); + $Data->addParam($this->accountData->getAccountId(), 'id'); $queryRes = DB::getResults($Data); @@ -371,10 +371,10 @@ class AccountHistory extends AccountBase implements AccountInterface throw new SPException(SPException::SP_CRITICAL, _('No se pudieron obtener los datos de la cuenta')); } - $this->setAccountUserId($queryRes->account_userId); - $this->setAccountUserGroupId($queryRes->account_userGroupId); - $this->setAccountOtherUserEdit($queryRes->account_otherUserEdit); - $this->setAccountOtherGroupEdit($queryRes->account_otherGroupEdit); + $this->accountData->setAccountUserId($queryRes->account_userId); + $this->accountData->setAccountUserGroupId($queryRes->account_userGroupId); + $this->accountData->setAccountOtherUserEdit($queryRes->account_otherUserEdit); + $this->accountData->setAccountOtherGroupEdit($queryRes->account_otherGroupEdit); return $queryRes; } @@ -410,19 +410,19 @@ class AccountHistory extends AccountBase implements AccountInterface $Data = new QueryData(); $Data->setQuery($query); - $Data->addParam($this->getAccountId(), 'account_id'); - $Data->addParam($this->getAccountCustomerId(), 'accountCustomerId'); - $Data->addParam($this->getAccountCategoryId(), 'accountCategoryId'); - $Data->addParam($this->getAccountName(), 'accountName'); - $Data->addParam($this->getAccountLogin(), 'accountLogin'); - $Data->addParam($this->getAccountUrl(), 'accountUrl'); - $Data->addParam($this->getAccountPass(), 'accountPass'); - $Data->addParam($this->getAccountIV(), 'accountIV'); - $Data->addParam($this->getAccountNotes(), 'accountNotes'); - $Data->addParam($this->getAccountUserId(), 'accountUserId'); - $Data->addParam($this->getAccountUserGroupId(), 'accountUserGroupId'); - $Data->addParam($this->getAccountOtherUserEdit(), 'accountOtherUserEdit'); - $Data->addParam($this->getAccountOtherGroupEdit(), 'accountOtherGroupEdit'); + $Data->addParam($this->accountData->getAccountId(), 'account_id'); + $Data->addParam($this->accountData->getAccountCustomerId(), 'accountCustomerId'); + $Data->addParam($this->accountData->getAccountCategoryId(), 'accountCategoryId'); + $Data->addParam($this->accountData->getAccountName(), 'accountName'); + $Data->addParam($this->accountData->getAccountLogin(), 'accountLogin'); + $Data->addParam($this->accountData->getAccountUrl(), 'accountUrl'); + $Data->addParam($this->accountData->getAccountPass(), 'accountPass'); + $Data->addParam($this->accountData->getAccountIV(), 'accountIV'); + $Data->addParam($this->accountData->getAccountNotes(), 'accountNotes'); + $Data->addParam($this->accountData->getAccountUserId(), 'accountUserId'); + $Data->addParam($this->accountData->getAccountUserGroupId(), 'accountUserGroupId'); + $Data->addParam($this->accountData->getAccountOtherUserEdit(), 'accountOtherUserEdit'); + $Data->addParam($this->accountData->getAccountOtherGroupEdit(), 'accountOtherGroupEdit'); $Data->addParam($this->isIsModify(), 'isModify'); $Data->addParam($this->isIsDelete(), 'isDelete'); $Data->addParam(ConfigDB::getValue('masterPwd'), 'masterPwd'); @@ -445,7 +445,7 @@ class AccountHistory extends AccountBase implements AccountInterface $Data = new QueryData(); $Data->setQuery($query); - $Data->addParam($this->getAccountId(), 'id'); + $Data->addParam($this->accountData->getAccountId(), 'id'); if (DB::getQuery($Data) === false) { return false; diff --git a/inc/SP/Account/AccountInterface.class.php b/inc/SP/Account/AccountInterface.class.php index 50e7a540..63a3463a 100644 --- a/inc/SP/Account/AccountInterface.class.php +++ b/inc/SP/Account/AccountInterface.class.php @@ -32,11 +32,26 @@ defined('APP_ROOT') || die(_('No es posible acceder directamente a este archivo' */ interface AccountInterface { - public function getAccountData(); + /** + * @return mixed + */ + public function getData(); + /** + * @return mixed + */ public function createAccount(); + /** + * @return mixed + */ public function deleteAccount(); + /** + * @param $currentMasterPass + * @param $newMasterPass + * @param null $newHash + * @return mixed + */ public function updateAccountsMasterPass($currentMasterPass, $newMasterPass, $newHash = null); } \ No newline at end of file diff --git a/inc/SP/Account/AccountSearch.class.php b/inc/SP/Account/AccountSearch.class.php index f13ce435..5cb950a9 100644 --- a/inc/SP/Account/AccountSearch.class.php +++ b/inc/SP/Account/AccountSearch.class.php @@ -59,43 +59,43 @@ class AccountSearch /** * @var bool */ - private $_globalSearch = false; + private $globalSearch = false; /** * @var string */ - private $_txtSearch = ''; + private $txtSearch = ''; /** * @var int */ - private $_customerId = 0; + private $customerId = 0; /** * @var int */ - private $_categoryId = 0; + private $categoryId = 0; /** * @var int */ - private $_sortOrder = 0; + private $sortOrder = 0; /** * @var int */ - private $_sortKey = 0; + private $sortKey = 0; /** * @var int */ - private $_limitStart = 0; + private $limitStart = 0; /** * @var int */ - private $_limitCount = 12; + private $limitCount = 12; /** * @var bool */ - private $_sortViews = false; + private $sortViews = false; /** * @var bool */ - private $_searchFavorites = false; + private $searchFavorites = false; /** * Constructor @@ -104,8 +104,8 @@ class AccountSearch { $userResultsPerPage = (Session::getSessionType() === Session::SESSION_INTERACTIVE) ? Session::getUserPreferences()->getResultsPerPage() : 0; - $this->_limitCount = ($userResultsPerPage > 0) ? $userResultsPerPage : Config::getValue('account_count'); - $this->_sortViews = (Session::getSessionType() === Session::SESSION_INTERACTIVE) ? Session::getUserPreferences()->isSortViews() : false; + $this->limitCount = ($userResultsPerPage > 0) ? $userResultsPerPage : Config::getConfig()->getAccountCount(); + $this->sortViews = (Session::getSessionType() === Session::SESSION_INTERACTIVE) ? Session::getUserPreferences()->isSortViews() : false; } /** @@ -113,7 +113,7 @@ class AccountSearch */ public function isSearchFavorites() { - return $this->_searchFavorites; + return $this->searchFavorites; } /** @@ -121,7 +121,7 @@ class AccountSearch */ public function setSearchFavorites($searchFavorites) { - $this->_searchFavorites = (bool)$searchFavorites; + $this->searchFavorites = (bool)$searchFavorites; } /** @@ -129,7 +129,7 @@ class AccountSearch */ public function getGlobalSearch() { - return $this->_globalSearch; + return $this->globalSearch; } /** @@ -137,7 +137,7 @@ class AccountSearch */ public function setGlobalSearch($globalSearch) { - $this->_globalSearch = $globalSearch; + $this->globalSearch = $globalSearch; } /** @@ -145,7 +145,7 @@ class AccountSearch */ public function getTxtSearch() { - return $this->_txtSearch; + return $this->txtSearch; } /** @@ -153,7 +153,7 @@ class AccountSearch */ public function setTxtSearch($txtSearch) { - $this->_txtSearch = (string)$txtSearch; + $this->txtSearch = (string)$txtSearch; } /** @@ -161,7 +161,7 @@ class AccountSearch */ public function getCustomerId() { - return $this->_customerId; + return $this->customerId; } /** @@ -169,7 +169,7 @@ class AccountSearch */ public function setCustomerId($customerId) { - $this->_customerId = $customerId; + $this->customerId = $customerId; } /** @@ -177,7 +177,7 @@ class AccountSearch */ public function getCategoryId() { - return $this->_categoryId; + return $this->categoryId; } /** @@ -185,7 +185,7 @@ class AccountSearch */ public function setCategoryId($categoryId) { - $this->_categoryId = $categoryId; + $this->categoryId = $categoryId; } /** @@ -193,7 +193,7 @@ class AccountSearch */ public function getSortOrder() { - return $this->_sortOrder; + return $this->sortOrder; } /** @@ -201,7 +201,7 @@ class AccountSearch */ public function setSortOrder($sortOrder) { - $this->_sortOrder = $sortOrder; + $this->sortOrder = $sortOrder; } /** @@ -209,7 +209,7 @@ class AccountSearch */ public function getLimitStart() { - return $this->_limitStart; + return $this->limitStart; } /** @@ -217,7 +217,7 @@ class AccountSearch */ public function setLimitStart($limitStart) { - $this->_limitStart = $limitStart; + $this->limitStart = $limitStart; } /** @@ -225,7 +225,7 @@ class AccountSearch */ public function getLimitCount() { - return $this->_limitCount; + return $this->limitCount; } /** @@ -233,7 +233,7 @@ class AccountSearch */ public function setLimitCount($limitCount) { - $this->_limitCount = $limitCount; + $this->limitCount = $limitCount; } /** @@ -253,7 +253,7 @@ class AccountSearch $Data = new QueryData(); - if ($this->_txtSearch) { + if ($this->txtSearch) { // Analizar la cadena de búsqueda por etiquetas especiales $stringFilters = $this->analyzeQueryString(); @@ -280,26 +280,26 @@ class AccountSearch $arrFilterCommon[] = 'account_url LIKE :url'; $arrFilterCommon[] = 'account_notes LIKE :notes'; - $Data->addParam('%' . $this->_txtSearch . '%', 'name'); - $Data->addParam('%' . $this->_txtSearch . '%', 'login'); - $Data->addParam('%' . $this->_txtSearch . '%', 'url'); - $Data->addParam('%' . $this->_txtSearch . '%', 'notes'); + $Data->addParam('%' . $this->txtSearch . '%', 'name'); + $Data->addParam('%' . $this->txtSearch . '%', 'login'); + $Data->addParam('%' . $this->txtSearch . '%', 'url'); + $Data->addParam('%' . $this->txtSearch . '%', 'notes'); } } - if ($this->_categoryId !== 0) { + if ($this->categoryId !== 0) { $arrFilterSelect[] = 'category_id = :categoryId'; - $Data->addParam($this->_categoryId, 'categoryId'); + $Data->addParam($this->categoryId, 'categoryId'); } - if ($this->_customerId !== 0) { + if ($this->customerId !== 0) { $arrFilterSelect[] = 'account_customerId = :customerId'; - $Data->addParam($this->_customerId, 'customerId'); + $Data->addParam($this->customerId, 'customerId'); } - if ($this->_searchFavorites === true) { + if ($this->searchFavorites === true) { $arrFilterSelect[] = 'accFavorites.accfavorite_userId = :favUserId'; $Data->addParam(Session::getUserId(), 'favUserId'); @@ -313,7 +313,7 @@ class AccountSearch $arrQueryWhere[] = '(' . implode(' AND ', $arrFilterSelect) . ')'; } - if (!$isAdmin && !$this->_globalSearch) { + if (!$isAdmin && !$this->globalSearch) { $subQueryGroupsA = '(SELECT user_groupId FROM usrData WHERE user_id = :userIduA UNION ALL SELECT usertogroup_groupId FROM usrToGroups WHERE usertogroup_userId = :userIdgA)'; $subQueryGroupsB = '(SELECT user_groupId FROM usrData WHERE user_id = :userIduB UNION ALL SELECT usertogroup_groupId FROM usrToGroups WHERE usertogroup_userId = :userIdgB)'; @@ -333,11 +333,11 @@ class AccountSearch $arrQueryWhere[] = '(' . implode(' OR ', $arrFilterUser) . ')'; } - if ($this->_limitCount > 0) { + if ($this->limitCount > 0) { $queryLimit = 'LIMIT :limitStart,:limitCount'; - $Data->addParam($this->_limitStart, 'limitStart'); - $Data->addParam($this->_limitCount, 'limitCount'); + $Data->addParam($this->limitStart, 'limitStart'); + $Data->addParam($this->limitCount, 'limitCount'); } if (count($arrQueryWhere) === 1) { @@ -408,7 +408,7 @@ class AccountSearch */ private function analyzeQueryString() { - preg_match('/:(user|group|file)\s(.*)/i', $this->_txtSearch, $filters); + preg_match('/:(user|group|file)\s(.*)/i', $this->txtSearch, $filters); if (!is_array($filters) || count($filters) === 0) { return false; @@ -444,7 +444,7 @@ class AccountSearch */ private function getOrderString() { - switch ($this->_sortKey) { + switch ($this->sortKey) { case self::SORT_NAME: $orderKey[] = 'account_name'; break; @@ -471,7 +471,7 @@ class AccountSearch $this->setSortOrder(self::SORT_DIR_DESC); } - $orderDir = ($this->_sortOrder === self::SORT_DIR_ASC) ? 'ASC' : 'DESC'; + $orderDir = ($this->sortOrder === self::SORT_DIR_ASC) ? 'ASC' : 'DESC'; return sprintf('ORDER BY %s %s', implode(',', $orderKey), $orderDir); } @@ -480,7 +480,7 @@ class AccountSearch */ public function isSortViews() { - return $this->_sortViews; + return $this->sortViews; } /** @@ -488,7 +488,7 @@ class AccountSearch */ public function setSortViews($sortViews) { - $this->_sortViews = $sortViews; + $this->sortViews = $sortViews; } /** @@ -496,7 +496,7 @@ class AccountSearch */ public function getSortKey() { - return $this->_sortKey; + return $this->sortKey; } /** @@ -504,7 +504,7 @@ class AccountSearch */ public function setSortKey($sortKey) { - $this->_sortKey = $sortKey; + $this->sortKey = $sortKey; } /** diff --git a/inc/SP/Api/ApiBase.class.php b/inc/SP/Api/ApiBase.class.php index 9108bd67..642e0487 100644 --- a/inc/SP/Api/ApiBase.class.php +++ b/inc/SP/Api/ApiBase.class.php @@ -47,29 +47,29 @@ abstract class ApiBase * * @var int */ - protected $_actionId = 0; + protected $actionId = 0; /** * El ID de usuario resuelto * * @var int */ - protected $_userId = 0; + protected $userId = 0; /** * Indica si la autentificación es correcta * * @var bool */ - protected $_auth = false; + protected $auth = false; /** * Los parámetros de la acción a ejecutar * * @var mixed */ - protected $_params; + protected $params; /** * @var array */ - protected $_actionsMap = array(); + protected $actionsMap = array(); /** * @param $params @@ -81,16 +81,16 @@ abstract class ApiBase throw new SPException(SPException::SP_CRITICAL, _('Acceso no permitido')); } - $this->_userId = ApiTokensUtil::getUserIdForToken($params->authToken); - $this->_actionId = $this->getActionId($params->action); - $this->_auth = true; - $this->_params = $params; + $this->userId = ApiTokensUtil::getUserIdForToken($params->authToken); + $this->actionId = $this->getActionId($params->action); + $this->auth = true; + $this->params = $params; if (isset($params->userPass)) { - $userLogin = UserUtil::getUserLoginById($this->_userId); + $userLogin = UserUtil::getUserLoginById($this->userId); $User = new User(); - $User->setUserId($this->_userId); + $User->setUserId($this->userId); $User->setUserLogin($userLogin); $User->setUserPass($params->userPass); @@ -106,7 +106,7 @@ abstract class ApiBase } } - Session::setUserId($this->_userId); + Session::setUserId($this->userId); Session::setSessionType(Session::SESSION_API); } @@ -118,7 +118,7 @@ abstract class ApiBase */ protected function getActionId($action) { - return (is_array($this->_actionsMap) && isset($this->_actionsMap[$action])) ? $this->_actionsMap[$action] : 0; + return (is_array($this->actionsMap) && isset($this->actionsMap[$action])) ? $this->actionsMap[$action] : 0; } /** @@ -129,7 +129,7 @@ abstract class ApiBase */ protected function checkActionAccess($action) { - if ($this->_actionId !== $action) { + if ($this->actionId !== $action) { throw new SPException(SPException::SP_CRITICAL, _('Acceso no permitido')); } } @@ -165,7 +165,7 @@ abstract class ApiBase } $json = json_encode(array( - 'action' => Acl::getActionName($this->_actionId, true), + 'action' => Acl::getActionName($this->actionId, true), 'data' => $data, )); diff --git a/inc/SP/Api/ApiRequest.class.php b/inc/SP/Api/ApiRequest.class.php index 64668810..aa192b4e 100644 --- a/inc/SP/Api/ApiRequest.class.php +++ b/inc/SP/Api/ApiRequest.class.php @@ -52,13 +52,13 @@ class ApiRequest extends Request /** * @var \stdClass */ - private $_params; + private $params; /** @var string */ - private $_verb = null; + private $verb = null; /** @var ReflectionClass */ - private $_ApiReflection; + private $ApiReflection; /** * ApiRequest constructor. @@ -90,7 +90,7 @@ class ApiRequest extends Request case 'POST': case 'PUT': case 'DELETE': - $this->_verb = $requestMethod; + $this->verb = $requestMethod; break; default: throw new SPException(SPException::SP_WARNING, _('Método inválido')); @@ -106,9 +106,9 @@ class ApiRequest extends Request { $data = self::parse(file_get_contents('php://input'), '', true); - $this->_params = json_decode($data); + $this->params = json_decode($data); - if (json_last_error() !== JSON_ERROR_NONE || !is_object($this->_params)) { + if (json_last_error() !== JSON_ERROR_NONE || !is_object($this->params)) { throw new SPException(SPException::SP_WARNING, _('Datos inválidos')); } } @@ -120,8 +120,8 @@ class ApiRequest extends Request */ private function checkBasicData() { - if (!isset($this->_params->authToken) - || !isset($this->_params->action) + if (!isset($this->params->authToken) + || !isset($this->params->action) ) { throw new SPException(SPException::SP_WARNING, _('Parámetros incorrectos')); } @@ -134,9 +134,9 @@ class ApiRequest extends Request */ private function checkAction() { - $this->_ApiReflection = new ReflectionClass('\SP\Api\SyspassApi'); + $this->ApiReflection = new ReflectionClass('\SP\Api\SyspassApi'); - if (!$this->_ApiReflection->hasMethod($this->_params->action)) { + if (!$this->ApiReflection->hasMethod($this->params->action)) { throw new SPException(SPException::SP_WARNING, _('Acción inválida')); } } @@ -166,7 +166,7 @@ class ApiRequest extends Request */ public function addVar($name, $value) { - $this->_params->$name = $value; + $this->params->$name = $value; } /** @@ -176,7 +176,7 @@ class ApiRequest extends Request */ public function runApi() { - return $this->_ApiReflection->getMethod($this->_params->action)->invoke(new SyspassApi($this->_params)); + return $this->ApiReflection->getMethod($this->params->action)->invoke(new SyspassApi($this->params)); } /** @@ -186,6 +186,6 @@ class ApiRequest extends Request */ public function getAction() { - return $this->_params->action; + return $this->params->action; } } \ No newline at end of file diff --git a/inc/SP/Api/ApiTokens.class.php b/inc/SP/Api/ApiTokens.class.php index f6b10449..407a6574 100644 --- a/inc/SP/Api/ApiTokens.class.php +++ b/inc/SP/Api/ApiTokens.class.php @@ -48,30 +48,30 @@ class ApiTokens /** * @var int */ - private $_tokenId = 0; + private $tokenId = 0; /** * @var int */ - private $_userId = 0; + private $userId = 0; /** * @var int */ - private $_actionId = 0; + private $actionId = 0; /** * @var string */ - private $_token = ''; + private $token = ''; /** * @var bool */ - private $_refreshToken = false; + private $refreshToken = false; /** * @param boolean $refreshToken */ public function setRefreshToken($refreshToken) { - $this->_refreshToken = $refreshToken; + $this->refreshToken = $refreshToken; } /** @@ -83,7 +83,7 @@ class ApiTokens { $this->checkTokenExist(); - if ($this->_refreshToken) { + if ($this->refreshToken) { $this->refreshToken(); } @@ -96,10 +96,10 @@ class ApiTokens $Data = new QueryData(); $Data->setQuery($query); - $Data->addParam($this->_userId, 'userid'); - $Data->addParam($this->_actionId, 'actionid'); + $Data->addParam($this->userId, 'userid'); + $Data->addParam($this->actionId, 'actionid'); $Data->addParam(Session::getUserId(), 'createdby'); - $Data->addParam(($this->getUserToken()) ? $this->_token : $this->generateToken(), 'token'); + $Data->addParam(($this->getUserToken()) ? $this->token : $this->generateToken(), 'token'); try { DB::getQuery($Data); @@ -108,7 +108,7 @@ class ApiTokens } $Log = new Log(_('Nueva Autorización')); - $Log->addDetails(Html::strongText(_('Usuario')), UserUtil::getUserLoginById($this->_userId)); + $Log->addDetails(Html::strongText(_('Usuario')), UserUtil::getUserLoginById($this->userId)); $Log->writeLog(); Email::sendEmail($Log); @@ -130,9 +130,9 @@ class ApiTokens $Data = new QueryData(); $Data->setQuery($query); - $Data->addParam($this->_tokenId, 'id'); - $Data->addParam($this->_userId, 'userid'); - $Data->addParam($this->_actionId, 'actionid'); + $Data->addParam($this->tokenId, 'id'); + $Data->addParam($this->userId, 'userid'); + $Data->addParam($this->actionId, 'actionid'); try { DB::getResults($Data); @@ -159,7 +159,7 @@ class ApiTokens $Data = new QueryData(); $Data->setQuery($query); - $Data->addParam($this->_userId, 'userid'); + $Data->addParam($this->userId, 'userid'); $Data->addParam($this->generateToken(),'token'); try { @@ -181,7 +181,7 @@ class ApiTokens $Data = new QueryData(); $Data->setQuery($query); - $Data->addParam($this->_userId, 'userid'); + $Data->addParam($this->userId, 'userid'); try { $queryRes = DB::getResults($Data); @@ -193,7 +193,7 @@ class ApiTokens return false; } - $this->_token = $queryRes->authtoken_token; + $this->token = $queryRes->authtoken_token; return true; } @@ -207,7 +207,7 @@ class ApiTokens { $this->checkTokenExist(); - if ($this->_refreshToken) { + if ($this->refreshToken) { $this->refreshToken(); } @@ -221,11 +221,11 @@ class ApiTokens $Data = new QueryData(); $Data->setQuery($query); - $Data->addParam($this->_tokenId, 'id'); - $Data->addParam($this->_userId, 'userid'); - $Data->addParam($this->_actionId, 'actionid'); + $Data->addParam($this->tokenId, 'id'); + $Data->addParam($this->userId, 'userid'); + $Data->addParam($this->actionId, 'actionid'); $Data->addParam(Session::getUserId(), 'createdby'); - $Data->addParam(($this->getUserToken()) ? $this->_token : $this->generateToken(), 'token'); + $Data->addParam(($this->getUserToken()) ? $this->token : $this->generateToken(), 'token'); try { DB::getQuery($Data); @@ -234,7 +234,7 @@ class ApiTokens } $Log = new Log(_('Actualizar Autorización')); - $Log->addDetails(Html::strongText(_('Usuario')), UserUtil::getUserLoginById($this->_userId)); + $Log->addDetails(Html::strongText(_('Usuario')), UserUtil::getUserLoginById($this->userId)); $Log->writeLog(); Email::sendEmail($Log); @@ -251,7 +251,7 @@ class ApiTokens $Data = new QueryData(); $Data->setQuery($query); - $Data->addParam($this->_tokenId, 'id'); + $Data->addParam($this->tokenId, 'id'); try { DB::getQuery($Data); @@ -260,7 +260,7 @@ class ApiTokens } $Log = new Log(_('Eliminar Autorización')); - $Log->addDetails(_('ID'), $this->_tokenId); + $Log->addDetails(_('ID'), $this->tokenId); $Log->writeLog(); Email::sendEmail($Log); @@ -271,7 +271,7 @@ class ApiTokens */ public function getUserId() { - return $this->_userId; + return $this->userId; } /** @@ -279,7 +279,7 @@ class ApiTokens */ public function setUserId($userId) { - $this->_userId = $userId; + $this->userId = $userId; } /** @@ -287,7 +287,7 @@ class ApiTokens */ public function getTokenId() { - return $this->_tokenId; + return $this->tokenId; } /** @@ -295,7 +295,7 @@ class ApiTokens */ public function setTokenId($tokenId) { - $this->_tokenId = $tokenId; + $this->tokenId = $tokenId; } /** @@ -303,7 +303,7 @@ class ApiTokens */ public function getActionId() { - return $this->_actionId; + return $this->actionId; } /** @@ -311,7 +311,7 @@ class ApiTokens */ public function setActionId($actionId) { - $this->_actionId = $actionId; + $this->actionId = $actionId; } /** diff --git a/inc/SP/Api/SyspassApi.class.php b/inc/SP/Api/SyspassApi.class.php index 434e6f24..67bf0eab 100644 --- a/inc/SP/Api/SyspassApi.class.php +++ b/inc/SP/Api/SyspassApi.class.php @@ -26,6 +26,7 @@ namespace SP\Api; use SP\Account\Account; +use SP\Account\AccountData; use SP\Account\AccountSearch; use SP\Core\ActionsInterface; use SP\Core\Crypt; @@ -43,7 +44,7 @@ class SyspassApi extends ApiBase /** * @var array */ - protected $_actionsMap = array( + protected $actionsMap = array( 'getAccountPassword' => ActionsInterface::ACTION_ACC_VIEW_PASS, 'getAccountSearch' => ActionsInterface::ACTION_ACC_SEARCH, 'getAccountData' => ActionsInterface::ACTION_ACC_VIEW @@ -59,19 +60,20 @@ class SyspassApi extends ApiBase { $this->checkActionAccess(ActionsInterface::ACTION_ACC_VIEW_PASS); - if (!isset($this->_params->accountId)){ + if (!isset($this->params->accountId)){ throw new SPException(SPException::SP_WARNING, _('Parámetros incorrectos')); } - $accountId = intval($this->_params->accountId); + $accountId = intval($this->params->accountId); - $Account = new Account($accountId); + $AccountData = new AccountData($accountId); + $Account = new Account($AccountData); $Account->getAccountPassData(); $Account->incrementDecryptCounter(); $ret = array( 'accountId' => $accountId, - 'pass' => Crypt::getDecrypt($Account->getAccountPass(), $Account->getAccountIV(), $this->_mPass) + 'pass' => Crypt::getDecrypt($AccountData->getAccountPass(), $AccountData->getAccountIV(), $this->_mPass) ); return $this->wrapJSON($ret); @@ -87,19 +89,19 @@ class SyspassApi extends ApiBase { $this->checkActionAccess(ActionsInterface::ACTION_ACC_SEARCH); - if (!isset($this->_params->searchText)){ + if (!isset($this->params->searchText)){ throw new SPException(SPException::SP_WARNING, _('Parámetros incorrectos')); } - $count = (isset($this->_params->searchCount)) ? intval($this->_params->searchCount) : 0; + $count = (isset($this->params->searchCount)) ? intval($this->params->searchCount) : 0; $Search = new AccountSearch(); - $Search->setTxtSearch($this->_params->searchText); + $Search->setTxtSearch($this->params->searchText); $Search->setLimitCount($count); $ret = $Search->getAccounts(); - return $this->wrapJSON(array($this->_params, $ret)); + return $this->wrapJSON(array($this->params, $ret)); } /** @@ -112,14 +114,14 @@ class SyspassApi extends ApiBase { $this->checkActionAccess(ActionsInterface::ACTION_ACC_VIEW); - if (!isset($this->_params->accountId)){ + if (!isset($this->params->accountId)){ throw new SPException(SPException::SP_WARNING, _('Parámetros incorrectos')); } - $accountId = intval($this->_params->accountId); + $accountId = intval($this->params->accountId); - $Account = new Account($accountId); - $ret = $Account->getAccountData(); + $Account = new Account(new AccountData($accountId)); + $ret = $Account->getData(); $Account->incrementViewCounter(); return $this->wrapJSON($ret); diff --git a/inc/SP/Auth/Auth.class.php b/inc/SP/Auth/Auth.class.php index d80a684e..3e5af755 100644 --- a/inc/SP/Auth/Auth.class.php +++ b/inc/SP/Auth/Auth.class.php @@ -47,8 +47,8 @@ defined('APP_ROOT') || die(_('No es posible acceder directamente a este archivo' */ class Auth { - static $userName; - static $userEmail; + public static $userName; + public static $userEmail; /** * Autentificación de usuarios con LDAP. @@ -139,7 +139,7 @@ class Auth */ private static function checkLDAPGroup($group) { - $ldapGroup = strtolower(Config::getValue('ldap_group')); + $ldapGroup = strtolower(Config::getConfig()->getLdapGroup()); $groupName = array(); preg_match('/^cn=([\w\s-]+),.*/i', $group, $groupName); diff --git a/inc/SP/Auth/Auth2FA.class.php b/inc/SP/Auth/Auth2FA.class.php index 3adbf1a7..4ac1fe31 100644 --- a/inc/SP/Auth/Auth2FA.class.php +++ b/inc/SP/Auth/Auth2FA.class.php @@ -43,23 +43,23 @@ class Auth2FA /** * @var int */ - private $_timestamp = 0; + private $timestamp = 0; /** * @var string */ - private $_initializationKey = ''; + private $initializationKey = ''; /** * @var string */ - private $_totp = ''; + private $totp = ''; /** * @var int */ - private $_userId = 0; + private $userId = 0; /** * @var string */ - private $_userLogin = ''; + private $userLogin = ''; /** * @param int $userId El Id de usuario @@ -67,9 +67,9 @@ class Auth2FA */ public function __construct($userId, $userLogin = null) { - $this->_userId = $userId; - $this->_userLogin = $userLogin; - $this->_initializationKey = $this->genUserInitializationKey(); + $this->userId = $userId; + $this->userLogin = $userLogin; + $this->initializationKey = $this->genUserInitializationKey(); } /** @@ -79,7 +79,7 @@ class Auth2FA */ private function genUserInitializationKey() { - $userIV = UserPass::getUserIVById($this->_userId); + $userIV = UserPass::getUserIVById($this->userId); $base32 = new Base2n(5, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567', false, true, true); $key = substr($base32->encode($userIV), 0, 16); @@ -91,7 +91,7 @@ class Auth2FA */ public function setUserId($userId) { - $this->_userId = $userId; + $this->userId = $userId; } /** @@ -99,7 +99,7 @@ class Auth2FA */ public function setUserLogin($userLogin) { - $this->_userLogin = $userLogin; + $this->userLogin = $userLogin; } /** @@ -110,7 +110,7 @@ class Auth2FA */ public function verifyKey($key) { - return Google2FA::verify_key($this->_initializationKey, $key); + return Google2FA::verify_key($this->initializationKey, $key); } /** @@ -136,7 +136,7 @@ class Auth2FA public function getUserQRUrl() { $qrUrl = 'https://www.google.com/chart?chs=150x150&chld=M|0&cht=qr&chl='; - $qrUrl .= urlencode('otpauth://totp/sysPass:syspass/' . $this->_userLogin . '?secret=' . $this->_initializationKey . '&issuer=sysPass'); + $qrUrl .= urlencode('otpauth://totp/sysPass:syspass/' . $this->userLogin . '?secret=' . $this->initializationKey . '&issuer=sysPass'); return $qrUrl; } @@ -151,7 +151,7 @@ class Auth2FA public function checkUserToken($userToken) { $timeStamp = Google2FA::get_timestamp(); - $secretkey = Google2FA::base32_decode($this->_initializationKey); + $secretkey = Google2FA::base32_decode($this->initializationKey); $totp = Google2FA::oath_totp($secretkey, $timeStamp); error_log($totp . '/' . $userToken); diff --git a/inc/SP/Auth/Ldap.class.php b/inc/SP/Auth/Ldap.class.php index ad9fd9bf..75aaa079 100644 --- a/inc/SP/Auth/Ldap.class.php +++ b/inc/SP/Auth/Ldap.class.php @@ -39,15 +39,15 @@ class Ldap // Variabla que contiene los datos de una búsqueda public static $ldapSearchData; // Variable para determinar si conecta con Active Directory - protected static $_isADS = false; + protected static $isADS = false; // Variables de conexión con LDAP - protected static $_ldapConn; - protected static $_ldapServer; - protected static $_searchBase; - private static $_bindDN; - private static $_bindPass; - private static $_ldapGroup; + protected static $ldapConn; + protected static $ldapServer; + protected static $searchBase; + private static $bindDN; + private static $bindPass; + private static $ldapGroup; // Mapeo de los atributos private static $_attribsMap = array( @@ -63,7 +63,7 @@ class Ldap */ public static function getLdapGroup() { - return self::$_ldapGroup; + return self::$ldapGroup; } /** @@ -71,7 +71,7 @@ class Ldap */ public static function getLdapServer() { - return self::$_ldapServer; + return self::$ldapServer; } /** @@ -81,8 +81,8 @@ class Ldap */ public static function getConn() { - if (is_resource(self::$_ldapConn)) { - return self::$_ldapConn; + if (is_resource(self::$ldapConn)) { + return self::$ldapConn; } } @@ -98,11 +98,11 @@ class Ldap */ public static function checkLDAPConn($ldapServer, $bindDN, $bindPass, $searchBase, $ldapGroup) { - self::$_ldapServer = $ldapServer; - self::$_bindDN = $bindDN; - self::$_bindPass = $bindPass; - self::$_searchBase = $searchBase; - self::$_ldapGroup = $ldapGroup; + self::$ldapServer = $ldapServer; + self::$bindDN = $bindDN; + self::$bindPass = $bindPass; + self::$searchBase = $searchBase; + self::$ldapGroup = $ldapGroup; try { self::ldapConnect(); @@ -126,22 +126,22 @@ class Ldap $Log = new Log(__FUNCTION__); // Habilitar la traza si el modo debug está habilitado - if (Config::getValue('debug')){ + if (Config::getConfig()->isDebug()){ @ldap_set_option(NULL, LDAP_OPT_DEBUG_LEVEL, 7); } // Conexión al servidor LDAP - if (!self::$_ldapConn = @ldap_connect(self::$_ldapServer)) { + if (!self::$ldapConn = @ldap_connect(self::$ldapServer)) { $Log->setLogLevel(Log::ERROR); - $Log->addDescription(sprintf('%s \'%s\'', _('No es posible conectar con el servidor de LDAP'), self::$_ldapServer)); - $Log->addDetails('LDAP ERROR', sprintf('%s (%d)', ldap_error(self::$_ldapConn), ldap_errno(self::$_ldapConn))); + $Log->addDescription(sprintf('%s \'%s\'', _('No es posible conectar con el servidor de LDAP'), self::$ldapServer)); + $Log->addDetails('LDAP ERROR', sprintf('%s (%d)', ldap_error(self::$ldapConn), ldap_errno(self::$ldapConn))); $Log->writeLog(); throw new \Exception(_('No es posible conectar con el servidor de LDAP')); } - @ldap_set_option(self::$_ldapConn, LDAP_OPT_NETWORK_TIMEOUT, 10); // Set timeout - @ldap_set_option(self::$_ldapConn, LDAP_OPT_PROTOCOL_VERSION, 3); // Set LDAP version + @ldap_set_option(self::$ldapConn, LDAP_OPT_NETWORK_TIMEOUT, 10); // Set timeout + @ldap_set_option(self::$ldapConn, LDAP_OPT_PROTOCOL_VERSION, 3); // Set LDAP version return true; } @@ -158,13 +158,13 @@ class Ldap { $Log = new Log(__FUNCTION__); - $dn = ($userDN) ? $userDN : self::$_bindDN; - $pass = ($userPass) ? $userPass : self::$_bindPass; + $dn = ($userDN) ? $userDN : self::$bindDN; + $pass = ($userPass) ? $userPass : self::$bindPass; - if (!@ldap_bind(self::$_ldapConn, $dn, $pass)) { + if (!@ldap_bind(self::$ldapConn, $dn, $pass)) { $Log->setLogLevel(Log::ERROR); $Log->addDescription(_('Error al conectar (BIND)')); - $Log->addDetails('LDAP ERROR', sprintf('%s (%d)', ldap_error(self::$_ldapConn), ldap_errno(self::$_ldapConn))); + $Log->addDetails('LDAP ERROR', sprintf('%s (%d)', ldap_error(self::$ldapConn), ldap_errno(self::$ldapConn))); $Log->addDetails('LDAP DN', $dn); $Log->writeLog(); @@ -184,23 +184,23 @@ class Ldap { $Log = new Log(__FUNCTION__); - $groupDN = (!empty(self::$_ldapGroup)) ? self::searchGroupDN() : '*'; + $groupDN = (!empty(self::$ldapGroup)) ? self::searchGroupDN() : '*'; $filter = '(&(|(memberOf=' . $groupDN . ')(groupMembership=' . $groupDN . '))(|(objectClass=inetOrgPerson)(objectClass=person)(objectClass=simpleSecurityObject)))'; $filterAttr = array("dn"); - $searchRes = @ldap_search(self::$_ldapConn, self::$_searchBase, $filter, $filterAttr); + $searchRes = @ldap_search(self::$ldapConn, self::$searchBase, $filter, $filterAttr); if (!$searchRes) { $Log->setLogLevel(Log::ERROR); $Log->addDescription(_('Error al buscar objetos en DN base')); - $Log->addDetails('LDAP ERROR', sprintf('%s (%d)', ldap_error(self::$_ldapConn), ldap_errno(self::$_ldapConn))); + $Log->addDetails('LDAP ERROR', sprintf('%s (%d)', ldap_error(self::$ldapConn), ldap_errno(self::$ldapConn))); $Log->addDetails('LDAP FILTER', $filter); $Log->writeLog(); throw new \Exception(_('Error al buscar objetos en DN base')); } - return @ldap_count_entries(self::$_ldapConn, $searchRes); + return @ldap_count_entries(self::$ldapConn, $searchRes); } /** @@ -213,31 +213,31 @@ class Ldap { $Log = new Log(__FUNCTION__); $groupName = self::getGroupName(); - $filter = ($groupName) ? $groupName : self::$_ldapGroup; + $filter = ($groupName) ? $groupName : self::$ldapGroup; $filter = '(cn=' . $filter . ')'; $filterAttr = array("dn", "cn"); - $searchRes = @ldap_search(self::$_ldapConn, self::$_searchBase, $filter, $filterAttr); + $searchRes = @ldap_search(self::$ldapConn, self::$searchBase, $filter, $filterAttr); if (!$searchRes) { $Log->setLogLevel(Log::ERROR); $Log->addDescription(_('Error al buscar RDN de grupo')); $Log->addDetails(_('Grupo'), $filter); - $Log->addDetails('LDAP ERROR', sprintf('%s (%d)', ldap_error(self::$_ldapConn), ldap_errno(self::$_ldapConn))); + $Log->addDetails('LDAP ERROR', sprintf('%s (%d)', ldap_error(self::$ldapConn), ldap_errno(self::$ldapConn))); $Log->addDetails('LDAP FILTER', $filter); $Log->writeLog(); throw new \Exception(_('Error al buscar RDN de grupo')); } - if (@ldap_count_entries(self::$_ldapConn, $searchRes) === 1) { - $ldapSearchData = @ldap_get_entries(self::$_ldapConn, $searchRes); + if (@ldap_count_entries(self::$ldapConn, $searchRes) === 1) { + $ldapSearchData = @ldap_get_entries(self::$ldapConn, $searchRes); if (!$ldapSearchData) { $Log->setLogLevel(Log::ERROR); $Log->addDescription(_('Error al buscar RDN de grupo')); $Log->addDetails(_('Grupo'), $filter); - $Log->addDetails('LDAP ERROR', sprintf('%s (%d)', ldap_error(self::$_ldapConn), ldap_errno(self::$_ldapConn))); + $Log->addDetails('LDAP ERROR', sprintf('%s (%d)', ldap_error(self::$ldapConn), ldap_errno(self::$ldapConn))); $Log->writeLog(); throw new \Exception(_('Error al buscar RDN de grupo')); @@ -262,7 +262,7 @@ class Ldap */ private static function getGroupName() { - if (isset(self::$_ldapGroup) && preg_match('/^cn=([\w\s-]+),.*/i', self::$_ldapGroup, $groupName)) { + if (isset(self::$ldapGroup) && preg_match('/^cn=([\w\s-]+),.*/i', self::$ldapGroup, $groupName)) { return $groupName[1]; } @@ -276,14 +276,14 @@ class Ldap */ public static function checkLDAPParams() { - self::$_isADS = Config::getValue('ldap_ads', false); - self::$_searchBase = Config::getValue('ldap_base'); - self::$_ldapServer = (!self::$_isADS) ? Config::getValue('ldap_server') : LdapADS::getADServer(Config::getValue('ldap_server')); - self::$_bindDN = Config::getValue('ldap_binduser'); - self::$_bindPass = Config::getValue('ldap_bindpass'); - self::$_ldapGroup = Config::getValue('ldap_group', '*'); + self::$isADS = Config::getConfig()->isLdapAds(); + self::$searchBase = Config::getConfig()->getLdapBase(); + self::$ldapServer = (!self::$isADS) ? Config::getConfig()->getLdapServer() : LdapADS::getADServer(Config::getConfig()->getLdapServer()); + self::$bindDN = Config::getConfig()->getLdapBindUser(); + self::$bindPass = Config::getConfig()->getLdapBindPass(); + self::$ldapGroup = Config::getConfig()->getLdapGroup(); - if (!self::$_searchBase || !self::$_ldapServer || !self::$_bindDN || !self::$_bindPass) { + if (!self::$searchBase || !self::$ldapServer || !self::$bindDN || !self::$bindPass) { Log::writeNewLog(__FUNCTION__, _('Los parámetros de LDAP no están configurados')); return false; @@ -302,7 +302,7 @@ class Ldap { $Log = new Log(__FUNCTION__); - if (self::$_isADS === true) { + if (self::$isADS === true) { $filter = '(&(|(samaccountname=' . $userLogin . ')(cn=' . $userLogin . ')(uid=' . $userLogin . '))(|(objectClass=inetOrgPerson)(objectClass=person)(objectClass=simpleSecurityObject))(objectCategory=person))'; } else { $filter = '(&(|(samaccountname=' . $userLogin . ')(cn=' . $userLogin . ')(uid=' . $userLogin . '))(|(objectClass=inetOrgPerson)(objectClass=person)(objectClass=simpleSecurityObject)))'; @@ -310,27 +310,27 @@ class Ldap $filterAttr = array("dn", "displayname", "samaccountname", "mail", "memberof", "lockouttime", "fullname", "groupmembership", "mail"); - $searchRes = @ldap_search(self::$_ldapConn, self::$_searchBase, $filter, $filterAttr); + $searchRes = @ldap_search(self::$ldapConn, self::$searchBase, $filter, $filterAttr); if (!$searchRes) { $Log->setLogLevel(Log::ERROR); $Log->addDescription(_('Error al buscar el DN del usuario')); $Log->addDetails(_('Usuario'), $userLogin); - $Log->addDetails('LDAP ERROR', sprintf('%s (%d)', ldap_error(self::$_ldapConn), ldap_errno(self::$_ldapConn))); + $Log->addDetails('LDAP ERROR', sprintf('%s (%d)', ldap_error(self::$ldapConn), ldap_errno(self::$ldapConn))); $Log->addDetails('LDAP FILTER', $filter); $Log->writeLog(); throw new \Exception(_('Error al buscar el DN del usuario')); } - if (@ldap_count_entries(self::$_ldapConn, $searchRes) === 1) { - self::$ldapSearchData = @ldap_get_entries(self::$_ldapConn, $searchRes); + if (@ldap_count_entries(self::$ldapConn, $searchRes) === 1) { + self::$ldapSearchData = @ldap_get_entries(self::$ldapConn, $searchRes); if (!self::$ldapSearchData) { $Log->setLogLevel(Log::ERROR); $Log->addDescription(_('Error al localizar el usuario en LDAP')); $Log->addDetails(_('Usuario'), $userLogin); - $Log->addDetails('LDAP ERROR', sprintf('%s (%d)', ldap_error(self::$_ldapConn), ldap_errno(self::$_ldapConn))); + $Log->addDetails('LDAP ERROR', sprintf('%s (%d)', ldap_error(self::$ldapConn), ldap_errno(self::$ldapConn))); $Log->writeLog(); throw new \Exception(_('Error al localizar el usuario en LDAP')); @@ -351,7 +351,7 @@ class Ldap */ public static function unbind() { - @ldap_unbind(self::$_ldapConn); + @ldap_unbind(self::$ldapConn); } /** @@ -396,7 +396,7 @@ class Ldap { $Log = new Log(__FUNCTION__); - $ldapGroup = Config::getValue('ldap_group'); + $ldapGroup = Config::getConfig()->getLdapGroup(); // Comprobar el filtro de grupo y obtener el nombre if (empty($ldapGroup) || !$groupDN = self::getGroupName()) { @@ -408,20 +408,20 @@ class Ldap $filter = '(&(cn=' . $groupDN . ')(|(member=' . $userDN . ')(uniqueMember=' . $userDN . '))(|(objectClass=groupOfNames)(objectClass=groupOfUniqueNames)(objectClass=group)))'; $filterAttr = array("member", "uniqueMember"); - $searchRes = @ldap_search(self::$_ldapConn, self::$_searchBase, $filter, $filterAttr); + $searchRes = @ldap_search(self::$ldapConn, self::$searchBase, $filter, $filterAttr); if (!$searchRes) { $Log->setLogLevel(Log::ERROR); $Log->addDescription(_('Error al buscar el grupo de usuarios')); $Log->addDetails(_('Grupo'), $ldapGroup); - $Log->addDetails('LDAP ERROR', sprintf('%s (%d)', ldap_error(self::$_ldapConn), ldap_errno(self::$_ldapConn))); + $Log->addDetails('LDAP ERROR', sprintf('%s (%d)', ldap_error(self::$ldapConn), ldap_errno(self::$ldapConn))); $Log->addDetails('LDAP FILTER', $filter); $Log->writeLog(); throw new \Exception(_('Error al buscar el grupo de usuarios')); } - if (@ldap_count_entries(self::$_ldapConn, $searchRes) === 0) { + if (@ldap_count_entries(self::$ldapConn, $searchRes) === 0) { return false; } diff --git a/inc/SP/Auth/LdapADS.class.php b/inc/SP/Auth/LdapADS.class.php index f33dbe1c..9f90103c 100644 --- a/inc/SP/Auth/LdapADS.class.php +++ b/inc/SP/Auth/LdapADS.class.php @@ -60,7 +60,7 @@ class LdapADS extends Ldap $records = dns_get_record($dnsServerQuery, DNS_NS); if (count($records) === 0) { - return parent::$_ldapServer; + return parent::$ldapServer; } foreach ($records as $record) { @@ -79,13 +79,13 @@ class LdapADS extends Ldap */ public static function searchADUserInGroup($userLogin) { - if (Ldap::$_isADS === false) { + if (Ldap::$isADS === false) { return false; } $Log = new Log(__FUNCTION__); - $ldapGroup = Config::getValue('ldap_group'); + $ldapGroup = Config::getConfig()->getLdapGroup(); // El filtro de grupo no está establecido if (empty($ldapGroup)) { @@ -100,29 +100,29 @@ class LdapADS extends Ldap $filter = '(memberof:1.2.840.113556.1.4.1941:=' . $groupDN . ')'; $filterAttr = array("sAMAccountName"); - $searchRes = @ldap_search(Ldap::$_ldapConn, Ldap::$_searchBase, $filter, $filterAttr); + $searchRes = @ldap_search(Ldap::$ldapConn, Ldap::$searchBase, $filter, $filterAttr); if (!$searchRes) { $Log->setLogLevel(Log::ERROR); $Log->addDescription(_('Error al buscar el grupo de usuarios')); - $Log->addDetails('LDAP ERROR', sprintf('%s (%d)', ldap_error(Ldap::$_ldapConn), ldap_errno(Ldap::$_ldapConn))); + $Log->addDetails('LDAP ERROR', sprintf('%s (%d)', ldap_error(Ldap::$ldapConn), ldap_errno(Ldap::$ldapConn))); $Log->addDetails('LDAP FILTER', $filter); $Log->writeLog(); throw new \Exception(_('Error al buscar el grupo de usuarios')); } - if (@ldap_count_entries(Ldap::$_ldapConn, $searchRes) === 0) { + if (@ldap_count_entries(Ldap::$ldapConn, $searchRes) === 0) { $Log->setLogLevel(Log::ERROR); $Log->addDescription(_('No se encontró el grupo con ese nombre')); - $Log->addDetails('LDAP ERROR', sprintf('%s (%d)', ldap_error(Ldap::$_ldapConn), ldap_errno(Ldap::$_ldapConn))); + $Log->addDetails('LDAP ERROR', sprintf('%s (%d)', ldap_error(Ldap::$ldapConn), ldap_errno(Ldap::$ldapConn))); $Log->addDetails('LDAP FILTER', $filter); $Log->writeLog(); throw new \Exception(_('No se encontró el grupo con ese nombre')); } - foreach (ldap_get_entries(Ldap::$_ldapConn, $searchRes) as $entry) { + foreach (ldap_get_entries(Ldap::$ldapConn, $searchRes) as $entry) { if ($userLogin === $entry['samaccountname'][0]) { return true; } diff --git a/inc/SP/Config/Cache.class.php b/inc/SP/Config/Cache.class.php deleted file mode 100644 index 9ee77b19..00000000 --- a/inc/SP/Config/Cache.class.php +++ /dev/null @@ -1,85 +0,0 @@ -. - * - */ - -namespace SP\Config; - -defined('APP_ROOT') || die(_('No es posible acceder directamente a este archivo')); - -/** - * Clase base para guardar/obtener elementos de la caché - */ -class Cache -{ - /** - * Tiempo de expiración de la cache en segundos - */ - const EXPIRE_TIME = 300; - - /** - * Obtener un parámetro de la configuración de sysPass desde la caché de la sesión - * - * @param string $param El parámetro a obtener - * @return null - */ - public static function getSessionCacheConfigValue($param) - { - $config = self::getSessionCacheConfig(); - - if (isset($config) && isset($config[$param])) { - return $config[$param]; - } - - return null; - } - - /** - * Obtener la configuración de sysPass desde la caché de la sesión - * - * @return array|bool Los datos de la configuración - */ - public static function getSessionCacheConfig() - { - if (isset($_SESSION['cache']['config']) && is_array($_SESSION['cache']['config'])) { - $isExpired = (time() - $_SESSION['cache']['config']['expires'] > 0); - - if (!$isExpired) { - return $_SESSION['cache']['config']; - } - } - - self::setSessionCacheConfig(); - - return $_SESSION['cache']['config']; - } - - /** - * Guardar la cache de configuración en la sesion - */ - public static function setSessionCacheConfig() - { - $_SESSION['cache']['config'] = Config::getConfig(); - $_SESSION['cache']['config']['expires'] = time() + self::EXPIRE_TIME; - } -} \ No newline at end of file diff --git a/inc/SP/Config/Config.class.php b/inc/SP/Config/Config.class.php index 9a55d330..9c1c0a5a 100644 --- a/inc/SP/Config/Config.class.php +++ b/inc/SP/Config/Config.class.php @@ -25,7 +25,9 @@ namespace SP\Config; -use SP\Core\Language; +use ReflectionObject; +use SP\Core\Factory; +use SP\Core\Session; use SP\Core\SPException; defined('APP_ROOT') || die(_('No es posible acceder directamente a este archivo')); @@ -33,251 +35,19 @@ defined('APP_ROOT') || die(_('No es posible acceder directamente a este archivo' /** * Esta clase es responsable de leer y escribir la configuración del archivo config.php */ -class Config implements ConfigInterface +class Config { /** - * @var array + * @var ConfigData */ - protected static $_cache; - /** - * @var bool - */ - protected static $_init; - - /** - * Obtiene un valor de configuración desde el archivo - * - * @param string $param clave - * @param string $default = null valor por defecto - * @return mixed el valor o $default - */ - public static function getValue($param, $default = null) - { - $params = Cache::getSessionCacheConfigValue($param); - - return (!is_null($params)) ? $params : $default; - } - - /** - * Lista todas las claves de configuración guardadas - * - * @param bool $full obtener todas las claves y sus valores - * @return array con nombres de claves - */ - public static function getKeys($full = false) - { - self::readConfig(); - - if ($full) { - return self::$_cache; - } - - return array_keys(self::$_cache); - } - - /** - * Carga el archivo de configuración y lo guarda en caché. - * - * @return bool - */ - public static function readConfig() - { - if (self::$_init) { - return true; - } - - if (!file_exists(CONFIG_FILE)) { - return false; - } - - // Include the file, save the data from $CONFIG - include_once CONFIG_FILE; - - if (isset($CONFIG) && is_array($CONFIG)) { - self::$_cache = $CONFIG; - } - - // We cached everything - self::$_init = true; - - return true; - } - - /** - * Elimina una clave de la configuración. - * Esta función elimina una clave de config.php. Si no tiene permiso - * de escritura en config.php, devolverá false. - * - * @param string $param clave - * @return bool - */ - public static function deleteParam($param) - { - self::readConfig(); - - if (isset(self::$_cache[$param])) { - // Eliminar la clave de la caché - unset(self::$_cache[$param]); - - // Guardar los cambios en la configuración - self::writeConfig(); - } - - return true; - } - - /** - * Escribe en archivo de configuración. - * - * @param bool $backup Si es necesario realizar backup - * @return bool - * @throws SPException - */ - public static function writeConfig($backup = true) - { - // Ordenar las claves de la configuración - ksort(self::$_cache); - - $content = "= (Session::getConfigTime() + $ConfigData->getSessionTimeout() / 2) + || Session::getReload() + ) { + Session::setConfig(self::arrayMapper()); + Session::setConfigTime(time()); + } + } + + /** + * @param ConfigData $Config + * @param bool $backup + */ + public static function saveConfig(ConfigData $Config = null, $backup = true) + { + if (is_null($Config)){ + Factory::getConfigStorage()->setItems(self::getConfig()); + } else { + Factory::getConfigStorage()->setItems($Config); + } + + Factory::getConfigStorage()->save('config'); + + if ($backup) { + self::backupToDB(); + } + } + + /** + * Mapear el array de elementos de configuración con las propieades de la + * clase ConfigData + * + * @return ConfigData + */ + private static function arrayMapper() + { + if (is_object(self::$Config)){ + return self::$Config; + } + + self::$Config = new ConfigData(); + + try { + $items = Factory::getConfigStorage()->load('config')->getItems(); + $Reflection = new ReflectionObject(self::$Config); + + foreach ($Reflection->getProperties() as $property) { + $property->setAccessible(true); + $property->setValue(self::$Config, $items[$property->getName()]); + $property->setAccessible(false); + } + } catch (SPException $e) {} + + return self::$Config; + } } diff --git a/inc/SP/Config/ConfigDB.class.php b/inc/SP/Config/ConfigDB.class.php index 6ae87f9b..75ab781e 100644 --- a/inc/SP/Config/ConfigDB.class.php +++ b/inc/SP/Config/ConfigDB.class.php @@ -42,11 +42,11 @@ class ConfigDB implements ConfigInterface /** * @var array */ - protected static $_cache; + protected static $cache; /** * @var bool */ - protected static $_init; + protected static $init; /** * Obtener un array con la configuración almacenada en la BBDD. @@ -67,7 +67,7 @@ class ConfigDB implements ConfigInterface } foreach ($queryRes as $config) { - self::$_cache[$config->config_parameter] = $config->config_value; + self::$cache[$config->config_parameter] = $config->config_value; } } @@ -79,7 +79,7 @@ class ConfigDB implements ConfigInterface */ public static function writeConfig($isInsert = false) { - foreach (self::$_cache as $param => $value) { + foreach (self::$cache as $param => $value) { $Data = new QueryData(); if ($isInsert) { @@ -154,7 +154,7 @@ class ConfigDB implements ConfigInterface */ public static function setCacheConfigValue($param, $value) { - self::$_cache[$param] = $value; + self::$cache[$param] = $value; } /** @@ -165,11 +165,11 @@ class ConfigDB implements ConfigInterface */ public static function getCacheConfigValue($param = null) { - if (!is_null($param) && isset(self::$_cache[$param])) { - return self::$_cache[$param]; + if (!is_null($param) && isset(self::$cache[$param])) { + return self::$cache[$param]; } - return self::$_cache; + return self::$cache; } /** diff --git a/inc/SP/Config/ConfigData.class.php b/inc/SP/Config/ConfigData.class.php new file mode 100644 index 00000000..5ea3cbdd --- /dev/null +++ b/inc/SP/Config/ConfigData.class.php @@ -0,0 +1,1521 @@ +. + * + */ + +namespace SP\Config; +use JsonSerializable; + +/** + * Class ConfigData + * + * @package SP\Config + */ +class ConfigData implements JsonSerializable +{ + /** + * @var string + */ + private $upgradeKey = ''; + /** + * @var bool + */ + private $dokuwikiEnabled = false; + /** + * @var string + */ + private $dokuwikiUrl = ''; + /** + * @var string + */ + private $dokuwikiUrlBase = ''; + /** + * @var string + */ + private $dokuwikiUser = ''; + /** + * @var string + */ + private $dokuwikiPass = ''; + /** + * @var string + */ + private $dokuwikiNamespace = ''; + /** + * @var int + */ + private $ldapDefaultGroup = 0; + /** + * @var int + */ + private $ldapDefaultProfile = 0; + /** + * @var bool + */ + private $proxyEnabled = false; + /** + * @var string + */ + private $proxyServer = ''; + /** + * @var int + */ + private $proxyPort = 0; + /** + * @var string + */ + private $proxyUser = ''; + /** + * @var string + */ + private $proxyPass = ''; + /** + * @var int + */ + private $publinksMaxViews = 3; + /** + * @var int + */ + private $publinksMaxTime = 600; + /** + * @var bool + */ + private $publinksEnabled = false; + /** + * @var int + */ + private $accountCount = 12; + /** + * @var bool + */ + private $accountLink = true; + /** + * @var bool + */ + private $checkUpdates = false; + /** + * @var bool + */ + private $checknotices = false; + /** + * @var string + */ + private $configHash = ''; + /** + * @var string + */ + private $dbHost = ''; + /** + * @var string + */ + private $dbName = ''; + /** + * @var string + */ + private $dbPass = ''; + /** + * @var string + */ + private $dbUser = ''; + /** + * @var int + */ + private $dbPort = 3306; + /** + * @var bool + */ + private $debug = false; + /** + * @var bool + */ + private $demoEnabled = false; + /** + * @var array + */ + private $filesAllowedExts = ['PDF', 'JPG', 'GIF', 'PNG', 'ODT', 'ODS', 'DOC', 'DOCX', 'XLS', 'XSL', 'VSD', 'TXT', 'CSV', 'BAK']; + /** + * @var int + */ + private $filesAllowedSize = 1024; + /** + * @var bool + */ + private $filesEnabled = true; + /** + * @var bool + */ + private $globalSearch = true; + /** + * @var bool + */ + private $installed = false; + /** + * @var string + */ + private $ldapBase = ''; + /** + * @var string + */ + private $ldapBindUser = ''; + /** + * @var string + */ + private $ldapBindPass = ''; + /** + * @var string + */ + private $ldapProxyUser = ''; + /** + * @var bool + */ + private $ldapEnabled = false; + /** + * @var bool + */ + private $ldapAds = false; + /** + * @var string + */ + private $ldapGroup = '*'; + /** + * @var string + */ + private $ldapServer = ''; + /** + * @var string + */ + private $ldapUserattr = ''; + /** + * @var bool + */ + private $logEnabled = true; + /** + * @var bool + */ + private $mailAuthenabled = false; + /** + * @var bool + */ + private $mailEnabled = false; + /** + * @var string + */ + private $mailFrom = ''; + /** + * @var string + */ + private $mailPass = ''; + /** + * @var int + */ + private $mailPort = 25; + /** + * @var bool + */ + private $mailRequestsEnabled = false; + /** + * @var string + */ + private $mailSecurity = ''; + /** + * @var string + */ + private $mailServer = ''; + /** + * @var string + */ + private $mailUser = ''; + /** + * @var bool + */ + private $maintenance = false; + /** + * @var string + */ + private $passwordSalt = ''; + /** + * @var bool + */ + private $resultsAsCards = false; + /** + * @var int + */ + private $sessionTimeout = 300; + /** + * @var string + */ + private $siteLang = 'es_ES'; + /** + * @var string + */ + private $siteTheme = 'material-blue'; + /** + * @var int + */ + private $configVersion = 0; + /** + * @var bool + */ + private $wikiEnabled = false; + /** + * @var array + */ + private $wikiFilter = []; + /** + * @var string + */ + private $wikiPageurl = ''; + /** + * @var string + */ + private $wikiSearchurl = ''; + /** + * @var int + */ + private $configDate = 0; + /** + * @var bool + */ + private $publinksImageEnabled = false; + /** + * @var string + */ + private $backup_hash = ''; + /** + * @var string + */ + private $export_hash = ''; + /** + * @var bool + */ + private $httpsEnabled = false; + /** + * @var bool + */ + private $syslogEnabled = false; + /** + * @var bool + */ + private $syslogRemoteEnabled = false; + /** + * @var string + */ + private $syslogServer = ''; + /** + * @var int + */ + private $syslogPort = 514; + /** + * @var bool + */ + private $accountPassToImage = false; + + /** + * @return boolean + */ + public function isDokuwikiEnabled() + { + return $this->dokuwikiEnabled; + } + + /** + * @param boolean $dokuwikiEnabled + */ + public function setDokuwikiEnabled($dokuwikiEnabled) + { + $this->dokuwikiEnabled = (bool)$dokuwikiEnabled; + } + + /** + * @return string + */ + public function getDokuwikiUrl() + { + return $this->dokuwikiUrl; + } + + /** + * @param string $dokuwikiUrl + */ + public function setDokuwikiUrl($dokuwikiUrl) + { + $this->dokuwikiUrl = $dokuwikiUrl; + } + + /** + * @return string + */ + public function getDokuwikiUrlBase() + { + return $this->dokuwikiUrlBase; + } + + /** + * @param string $dokuwikiUrlBase + */ + public function setDokuwikiUrlBase($dokuwikiUrlBase) + { + $this->dokuwikiUrlBase = $dokuwikiUrlBase; + } + + /** + * @return string + */ + public function getDokuwikiUser() + { + return $this->dokuwikiUser; + } + + /** + * @param string $dokuwikiUser + */ + public function setDokuwikiUser($dokuwikiUser) + { + $this->dokuwikiUser = $dokuwikiUser; + } + + /** + * @return string + */ + public function getDokuwikiPass() + { + return $this->dokuwikiPass; + } + + /** + * @param string $dokuwikiPass + */ + public function setDokuwikiPass($dokuwikiPass) + { + $this->dokuwikiPass = $dokuwikiPass; + } + + /** + * @return string + */ + public function getDokuwikiNamespace() + { + return $this->dokuwikiNamespace; + } + + /** + * @param string $dokuwikiNamespace + */ + public function setDokuwikiNamespace($dokuwikiNamespace) + { + $this->dokuwikiNamespace = $dokuwikiNamespace; + } + + /** + * @return int + */ + public function getLdapDefaultGroup() + { + return $this->ldapDefaultGroup; + } + + /** + * @param int $ldapDefaultGroup + */ + public function setLdapDefaultGroup($ldapDefaultGroup) + { + $this->ldapDefaultGroup = intval($ldapDefaultGroup); + } + + /** + * @return int + */ + public function getLdapDefaultProfile() + { + return $this->ldapDefaultProfile; + } + + /** + * @param int $ldapDefaultProfile + */ + public function setLdapDefaultProfile($ldapDefaultProfile) + { + $this->ldapDefaultProfile = intval($ldapDefaultProfile); + } + + /** + * @return boolean + */ + public function isProxyEnabled() + { + return $this->proxyEnabled; + } + + /** + * @param boolean $proxyEnabled + */ + public function setProxyEnabled($proxyEnabled) + { + $this->proxyEnabled = (bool)$proxyEnabled; + } + + /** + * @return string + */ + public function getProxyServer() + { + return $this->proxyServer; + } + + /** + * @param string $proxyServer + */ + public function setProxyServer($proxyServer) + { + $this->proxyServer = $proxyServer; + } + + /** + * @return int + */ + public function getProxyPort() + { + return $this->proxyPort; + } + + /** + * @param int $proxyPort + */ + public function setProxyPort($proxyPort) + { + $this->proxyPort = intval($proxyPort); + } + + /** + * @return string + */ + public function getProxyUser() + { + return $this->proxyUser; + } + + /** + * @param string $proxyUser + */ + public function setProxyUser($proxyUser) + { + $this->proxyUser = $proxyUser; + } + + /** + * @return string + */ + public function getProxyPass() + { + return $this->proxyPass; + } + + /** + * @param string $proxyPass + */ + public function setProxyPass($proxyPass) + { + $this->proxyPass = $proxyPass; + } + + /** + * @return int + */ + public function getPublinksMaxViews() + { + return $this->publinksMaxViews; + } + + /** + * @param int $publinksMaxViews + */ + public function setPublinksMaxViews($publinksMaxViews) + { + $this->publinksMaxViews = intval($publinksMaxViews); + } + + /** + * @return int + */ + public function getPublinksMaxTime() + { + return $this->publinksMaxTime; + } + + /** + * @param int $publinksMaxTime + */ + public function setPublinksMaxTime($publinksMaxTime) + { + $this->publinksMaxTime = intval($publinksMaxTime); + } + + /** + * @return boolean + */ + public function isSyslogEnabled() + { + return $this->syslogEnabled; + } + + /** + * @param boolean $syslogEnabled + */ + public function setSyslogEnabled($syslogEnabled) + { + $this->syslogEnabled = (bool)$syslogEnabled; + } + + /** + * @return boolean + */ + public function isSyslogRemoteEnabled() + { + return $this->syslogRemoteEnabled; + } + + /** + * @param boolean $syslogRemoteEnabled + */ + public function setSyslogRemoteEnabled($syslogRemoteEnabled) + { + $this->syslogRemoteEnabled = (bool)$syslogRemoteEnabled; + } + + /** + * @return string + */ + public function getSyslogServer() + { + return $this->syslogServer; + } + + /** + * @param string $syslogServer + */ + public function setSyslogServer($syslogServer) + { + $this->syslogServer = $syslogServer; + } + + /** + * @return int + */ + public function getSyslogPort() + { + return $this->syslogPort; + } + + /** + * @param int $syslogPort + */ + public function setSyslogPort($syslogPort) + { + $this->syslogPort = intval($syslogPort); + } + + /** + * @return string + */ + public function getBackupHash() + { + return $this->backup_hash; + } + + /** + * @param string $backup_hash + */ + public function setBackupHash($backup_hash) + { + $this->backup_hash = $backup_hash; + } + + /** + * @return string + */ + public function getExportHash() + { + return $this->export_hash; + } + + /** + * @param string $export_hash + */ + public function setExportHash($export_hash) + { + $this->export_hash = $export_hash; + } + + /** + * @return string + */ + public function getLdapBindUser() + { + return $this->ldapBindUser; + } + + /** + * @param string $ldapBindUser + */ + public function setLdapBindUser($ldapBindUser) + { + $this->ldapBindUser = $ldapBindUser; + } + + /** + * @return string + */ + public function getLdapProxyUser() + { + return $this->ldapProxyUser; + } + + /** + * @param string $ldapProxyUser + */ + public function setLdapProxyUser($ldapProxyUser) + { + $this->ldapProxyUser = $ldapProxyUser; + } + + /** + * @return int + */ + public function getAccountCount() + { + return $this->accountCount; + } + + /** + * @param int $accountCount + */ + public function setAccountCount($accountCount) + { + $this->accountCount = intval($accountCount); + } + + /** + * @return boolean + */ + public function isAccountLink() + { + return $this->accountLink; + } + + /** + * @param boolean $accountLink + */ + public function setAccountLink($accountLink) + { + $this->accountLink = (bool)$accountLink; + } + + /** + * @return boolean + */ + public function isCheckUpdates() + { + return $this->checkUpdates; + } + + /** + * @param boolean $checkUpdates + */ + public function setCheckUpdates($checkUpdates) + { + $this->checkUpdates = (bool)$checkUpdates; + } + + /** + * @return string + */ + public function getConfigHash() + { + return $this->configHash; + } + + /** + * @param string $configHash + */ + public function setConfigHash($configHash) + { + $this->configHash = $configHash; + } + + /** + * @return string + */ + public function getDbHost() + { + return $this->dbHost; + } + + /** + * @param string $dbHost + */ + public function setDbHost($dbHost) + { + $this->dbHost = $dbHost; + } + + /** + * @return string + */ + public function getDbName() + { + return $this->dbName; + } + + /** + * @param string $dbName + */ + public function setDbName($dbName) + { + $this->dbName = $dbName; + } + + /** + * @return string + */ + public function getDbPass() + { + return $this->dbPass; + } + + /** + * @param string $dbPass + */ + public function setDbPass($dbPass) + { + $this->dbPass = $dbPass; + } + + /** + * @return string + */ + public function getDbUser() + { + return $this->dbUser; + } + + /** + * @param string $dbUser + */ + public function setDbUser($dbUser) + { + $this->dbUser = $dbUser; + } + + /** + * @return boolean + */ + public function isDebug() + { + return $this->debug; + } + + /** + * @param boolean $debug + */ + public function setDebug($debug) + { + $this->debug = (bool)$debug; + } + + /** + * @return boolean + */ + public function isDemoEnabled() + { + return $this->demoEnabled; + } + + /** + * @param boolean $demoEnabled + */ + public function setDemoEnabled($demoEnabled) + { + $this->demoEnabled = (bool)$demoEnabled; + } + + /** + * @return array + */ + public function getFilesAllowedExts() + { + return is_array($this->filesAllowedExts) ? $this->filesAllowedExts : array(); + } + + /** + * @param array $filesAllowedExts + */ + public function setFilesAllowedExts($filesAllowedExts) + { + $this->filesAllowedExts = $filesAllowedExts; + } + + /** + * @return int + */ + public function getFilesAllowedSize() + { + return $this->filesAllowedSize; + } + + /** + * @param int $filesAllowedSize + */ + public function setFilesAllowedSize($filesAllowedSize) + { + $this->filesAllowedSize = intval($filesAllowedSize); + } + + /** + * @return boolean + */ + public function isFilesEnabled() + { + return $this->filesEnabled; + } + + /** + * @param boolean $filesEnabled + */ + public function setFilesEnabled($filesEnabled) + { + $this->filesEnabled = (bool)$filesEnabled; + } + + /** + * @return boolean + */ + public function isGlobalSearch() + { + return $this->globalSearch; + } + + /** + * @param boolean $globalSearch + */ + public function setGlobalSearch($globalSearch) + { + $this->globalSearch = (bool)$globalSearch; + } + + /** + * @return boolean + */ + public function isInstalled() + { + return $this->installed; + } + + /** + * @param boolean $installed + */ + public function setInstalled($installed) + { + $this->installed = (bool)$installed; + } + + /** + * @return string + */ + public function getLdapBase() + { + return $this->ldapBase; + } + + /** + * @param string $ldapBase + */ + public function setLdapBase($ldapBase) + { + $this->ldapBase = $ldapBase; + } + + /** + * @return boolean + */ + public function isLdapEnabled() + { + return $this->ldapEnabled; + } + + /** + * @param boolean $ldapEnabled + */ + public function setLdapEnabled($ldapEnabled) + { + $this->ldapEnabled = (bool)$ldapEnabled; + } + + /** + * @return string + */ + public function getLdapGroup() + { + return $this->ldapGroup; + } + + /** + * @param string $ldapGroup + */ + public function setLdapGroup($ldapGroup) + { + $this->ldapGroup = $ldapGroup; + } + + /** + * @return string + */ + public function getLdapServer() + { + return $this->ldapServer; + } + + /** + * @param string $ldapServer + */ + public function setLdapServer($ldapServer) + { + $this->ldapServer = $ldapServer; + } + + /** + * @return string + */ + public function getLdapUserattr() + { + return $this->ldapUserattr; + } + + /** + * @param string $ldapUserattr + */ + public function setLdapUserattr($ldapUserattr) + { + $this->ldapUserattr = $ldapUserattr; + } + + /** + * @return boolean + */ + public function isLogEnabled() + { + return $this->logEnabled; + } + + /** + * @param boolean $logEnabled + */ + public function setLogEnabled($logEnabled) + { + $this->logEnabled = (bool)$logEnabled; + } + + /** + * @return boolean + */ + public function isMailAuthenabled() + { + return $this->mailAuthenabled; + } + + /** + * @param boolean $mailAuthenabled + */ + public function setMailAuthenabled($mailAuthenabled) + { + $this->mailAuthenabled = (bool)$mailAuthenabled; + } + + /** + * @return boolean + */ + public function isMailEnabled() + { + return $this->mailEnabled; + } + + /** + * @param boolean $mailEnabled + */ + public function setMailEnabled($mailEnabled) + { + $this->mailEnabled = (bool)$mailEnabled; + } + + /** + * @return string + */ + public function getMailFrom() + { + return $this->mailFrom; + } + + /** + * @param string $mailFrom + */ + public function setMailFrom($mailFrom) + { + $this->mailFrom = $mailFrom; + } + + /** + * @return string + */ + public function getMailPass() + { + return $this->mailPass; + } + + /** + * @param string $mailPass + */ + public function setMailPass($mailPass) + { + $this->mailPass = $mailPass; + } + + /** + * @return int + */ + public function getMailPort() + { + return $this->mailPort; + } + + /** + * @param int $mailPort + */ + public function setMailPort($mailPort) + { + $this->mailPort = intval($mailPort); + } + + /** + * @return boolean + */ + public function isMailRequestsEnabled() + { + return $this->mailRequestsEnabled; + } + + /** + * @param boolean $mailRequestsEnabled + */ + public function setMailRequestsEnabled($mailRequestsEnabled) + { + $this->mailRequestsEnabled = (bool)$mailRequestsEnabled; + } + + /** + * @return string + */ + public function getMailSecurity() + { + return $this->mailSecurity; + } + + /** + * @param string $mailSecurity + */ + public function setMailSecurity($mailSecurity) + { + $this->mailSecurity = $mailSecurity; + } + + /** + * @return string + */ + public function getMailServer() + { + return $this->mailServer; + } + + /** + * @param string $mailServer + */ + public function setMailServer($mailServer) + { + $this->mailServer = $mailServer; + } + + /** + * @return string + */ + public function getMailUser() + { + return $this->mailUser; + } + + /** + * @param string $mailUser + */ + public function setMailUser($mailUser) + { + $this->mailUser = $mailUser; + } + + /** + * @return boolean + */ + public function isMaintenance() + { + return $this->maintenance; + } + + /** + * @param boolean $maintenance + */ + public function setMaintenance($maintenance) + { + $this->maintenance = (bool)$maintenance; + } + + /** + * @return string + */ + public function getPasswordSalt() + { + return $this->passwordSalt; + } + + /** + * @param string $passwordSalt + */ + public function setPasswordSalt($passwordSalt) + { + $this->passwordSalt = $passwordSalt; + } + + /** + * @return boolean + */ + public function isResultsAsCards() + { + return $this->resultsAsCards; + } + + /** + * @param boolean $resultsAsCards + */ + public function setResultsAsCards($resultsAsCards) + { + $this->resultsAsCards = (bool)$resultsAsCards; + } + + /** + * @return int + */ + public function getSessionTimeout() + { + return $this->sessionTimeout; + } + + /** + * @param int $sessionTimeout + */ + public function setSessionTimeout($sessionTimeout) + { + $this->sessionTimeout = intval($sessionTimeout); + } + + /** + * @return string + */ + public function getSiteLang() + { + return $this->siteLang; + } + + /** + * @param string $siteLang + */ + public function setSiteLang($siteLang) + { + $this->siteLang = $siteLang; + } + + /** + * @return string + */ + public function getSiteTheme() + { + return $this->siteTheme; + } + + /** + * @param string $siteTheme + */ + public function setSiteTheme($siteTheme) + { + $this->siteTheme = $siteTheme; + } + + /** + * @return int + */ + public function getConfigVersion() + { + return $this->configVersion; + } + + /** + * @param int $configVersion + */ + public function setConfigVersion($configVersion) + { + $this->configVersion = intval($configVersion); + } + + /** + * @return boolean + */ + public function isWikiEnabled() + { + return $this->wikiEnabled; + } + + /** + * @param boolean $wikiEnabled + */ + public function setWikiEnabled($wikiEnabled) + { + $this->wikiEnabled = (bool)$wikiEnabled; + } + + /** + * @return array + */ + public function getWikiFilter() + { + return is_array($this->wikiFilter) ? $this->wikiFilter : array(); + } + + /** + * @param array $wikiFilter + */ + public function setWikiFilter($wikiFilter) + { + $this->wikiFilter = $wikiFilter; + } + + /** + * @return string + */ + public function getWikiPageurl() + { + return $this->wikiPageurl; + } + + /** + * @param string $wikiPageurl + */ + public function setWikiPageurl($wikiPageurl) + { + $this->wikiPageurl = $wikiPageurl; + } + + /** + * @return string + */ + public function getWikiSearchurl() + { + return $this->wikiSearchurl; + } + + /** + * @param string $wikiSearchurl + */ + public function setWikiSearchurl($wikiSearchurl) + { + $this->wikiSearchurl = $wikiSearchurl; + } + + /** + * @param int $configDate + */ + public function setConfigDate($configDate) + { + $this->configDate = intval($configDate); + } + + /** + * @return boolean + */ + public function isLdapAds() + { + return $this->ldapAds; + } + + /** + * @param boolean $ldapAds + */ + public function setLdapAds($ldapAds) + { + $this->ldapAds = (bool)$ldapAds; + } + + /** + * @return string + */ + public function getLdapBindPass() + { + return $this->ldapBindPass; + } + + /** + * @param string $ldapBindPass + */ + public function setLdapBindPass($ldapBindPass) + { + $this->ldapBindPass = $ldapBindPass; + } + + /** + * @return boolean + */ + public function isPublinksImageEnabled() + { + return $this->publinksImageEnabled; + } + + /** + * @param boolean $publinksImageEnabled + */ + public function setPublinksImageEnabled($publinksImageEnabled) + { + $this->publinksImageEnabled = (bool)$publinksImageEnabled; + } + + /** + * @return boolean + */ + public function isHttpsEnabled() + { + return $this->httpsEnabled; + } + + /** + * @param boolean $httpsEnabled + */ + public function setHttpsEnabled($httpsEnabled) + { + $this->httpsEnabled = (bool)$httpsEnabled; + } + + /** + * @return boolean + */ + public function isChecknotices() + { + return $this->checknotices; + } + + /** + * @param boolean $checknotices + */ + public function setChecknotices($checknotices) + { + $this->checknotices = $checknotices; + } + + /** + * @return boolean + */ + public function isAccountPassToImage() + { + return $this->accountPassToImage; + } + + /** + * @param boolean $accountPassToImage + */ + public function setAccountPassToImage($accountPassToImage) + { + $this->accountPassToImage = (bool)$accountPassToImage; + } + + /** + * @return string + */ + public function getUpgradeKey() + { + return $this->upgradeKey; + } + + /** + * @param string $upgradeKey + */ + public function setUpgradeKey($upgradeKey) + { + $this->upgradeKey = $upgradeKey; + } + + /** + * @return int + */ + public function getDbPort() + { + return $this->dbPort; + } + + /** + * @param int $dbPort + */ + public function setDbPort($dbPort) + { + $this->dbPort = intval($dbPort); + } + + /** + * @return boolean + */ + public function isPublinksEnabled() + { + return $this->publinksEnabled; + } + + /** + * @param boolean $publinksEnabled + */ + public function setPublinksEnabled($publinksEnabled) + { + $this->publinksEnabled = (bool)$publinksEnabled; + } + + /** + * Specify data which should be serialized to JSON + * + * @link http://php.net/manual/en/jsonserializable.jsonserialize.php + * @return mixed data which can be serialized by json_encode, + * which is a value of any type other than a resource. + * @since 5.4.0 + */ + public function jsonSerialize() + { + return get_object_vars($this); + } +} \ No newline at end of file diff --git a/inc/SP/Controller/AccItemMgmt.class.php b/inc/SP/Controller/AccItemMgmt.class.php index 6cd02d01..ab6400de 100644 --- a/inc/SP/Controller/AccItemMgmt.class.php +++ b/inc/SP/Controller/AccItemMgmt.class.php @@ -42,6 +42,11 @@ use SP\Mgmt\User\UserUtil; use SP\Storage\DBUtil; use SP\Util\Checks; +/** + * Class AccItemMgmt + * + * @package SP\Controller + */ class AccItemMgmt extends Controller implements ActionsInterface { /** @@ -51,7 +56,7 @@ class AccItemMgmt extends Controller implements ActionsInterface /** * @var int */ - private $_module = 0; + private $module = 0; /** * Constructor @@ -71,7 +76,7 @@ class AccItemMgmt extends Controller implements ActionsInterface */ public function getUser() { - $this->_module = self::ACTION_USR_USERS; + $this->module = self::ACTION_USR_USERS; $this->view->addTemplate('users'); $this->view->assign('user', UserUtil::getUserData($this->view->itemId)); @@ -89,10 +94,10 @@ class AccItemMgmt extends Controller implements ActionsInterface private function getCustomFieldsForItem() { // Se comprueba que hayan campos con valores para el elemento actual - if ($this->view->itemId && CustomFields::checkCustomFieldExists($this->_module, $this->view->itemId)) { - $this->view->assign('customFields', CustomFields::getCustomFieldsData($this->_module, $this->view->itemId)); + if ($this->view->itemId && CustomFields::checkCustomFieldExists($this->module, $this->view->itemId)) { + $this->view->assign('customFields', CustomFields::getCustomFieldsData($this->module, $this->view->itemId)); } else { - $this->view->assign('customFields', CustomFields::getCustomFieldsForModule($this->_module)); + $this->view->assign('customFields', CustomFields::getCustomFieldsForModule($this->module)); } } @@ -101,7 +106,7 @@ class AccItemMgmt extends Controller implements ActionsInterface */ public function getGroup() { - $this->_module = self::ACTION_USR_GROUPS; + $this->module = self::ACTION_USR_GROUPS; $this->view->addTemplate('groups'); $this->view->assign('group', Groups::getGroupData($this->view->itemId)); diff --git a/inc/SP/Controller/AccItemsMgmt.class.php b/inc/SP/Controller/AccItemsMgmt.class.php index 6c5efc64..2e73b447 100644 --- a/inc/SP/Controller/AccItemsMgmt.class.php +++ b/inc/SP/Controller/AccItemsMgmt.class.php @@ -57,7 +57,7 @@ class AccItemsMgmt extends GridTabController implements ActionsInterface { parent::__construct($template); - $this->_limitCount = Config::getValue('account_count'); + $this->_limitCount = Config::getConfig()->getAccountCount(); } /** @@ -71,7 +71,7 @@ class AccItemsMgmt extends GridTabController implements ActionsInterface return; } - $Grid = $this->_grids->getUsersGrid(); + $Grid = $this->Grids->getUsersGrid(); $Grid->getData()->setData(UserUtil::getUsersMgmSearch($this->_limitCount)); $Grid->updatePager(); $Grid->getPager()->setOnClickArgs($this->_limitCount); @@ -90,7 +90,7 @@ class AccItemsMgmt extends GridTabController implements ActionsInterface return; } - $Grid = $this->_grids->getGroupsGrid(); + $Grid = $this->Grids->getGroupsGrid(); $Grid->getData()->setData(Groups::getGroupsMgmtSearch($this->_limitCount)); $Grid->updatePager(); $Grid->getPager()->setOnClickArgs($this->_limitCount); @@ -109,7 +109,7 @@ class AccItemsMgmt extends GridTabController implements ActionsInterface return; } - $Grid = $this->_grids->getProfilesGrid(); + $Grid = $this->Grids->getProfilesGrid(); $Grid->getData()->setData(ProfileUtil::getProfilesMgmtSearch($this->_limitCount)); $Grid->updatePager(); $Grid->getPager()->setOnClickArgs($this->_limitCount); @@ -128,7 +128,7 @@ class AccItemsMgmt extends GridTabController implements ActionsInterface return; } - $Grid = $this->_grids->getTokensGrid(); + $Grid = $this->Grids->getTokensGrid(); $Grid->getData()->setData(ApiTokensUtil::getTokensMgmtSearch($this->_limitCount)); $Grid->updatePager(); $Grid->getPager()->setOnClickArgs($this->_limitCount); @@ -147,7 +147,7 @@ class AccItemsMgmt extends GridTabController implements ActionsInterface return; } - $Grid = $this->_grids->getPublicLinksGrid(); + $Grid = $this->Grids->getPublicLinksGrid(); $Grid->getData()->setData(PublicLinkUtil::getLinksMgmtSearch($this->_limitCount)); $Grid->updatePager(); $Grid->getPager()->setOnClickArgs($this->_limitCount); diff --git a/inc/SP/Controller/Account.class.php b/inc/SP/Controller/Account.class.php index d16d41c0..40f282f4 100644 --- a/inc/SP/Controller/Account.class.php +++ b/inc/SP/Controller/Account.class.php @@ -27,6 +27,7 @@ namespace SP\Controller; defined('APP_ROOT') || die(_('No es posible acceder directamente a este archivo')); +use SP\Account\AccountData; use SP\Account\AccountHistory; use SP\Core\Acl; use SP\Config\Config; @@ -56,26 +57,26 @@ class Account extends Controller implements ActionsInterface /** * @var int con la acción a realizar */ - protected $_action; + protected $action; /** * @var Account|AccountHistory instancia para el manejo de datos de una cuenta */ - private $_account; + private $account; /** * @var bool indica si se han obtenido datos de la cuenta */ - private $_gotData = false; + private $gotData = false; /** * @var int con el id de la cuenta */ - private $_id; + private $id; /** * Constructor * * @param Template $template instancia del motor de plantillas - * @param int $lastAction int con la última acción realizada - * @param int $accountId int con el id de la cuenta + * @param int $lastAction int con la última acción realizada + * @param int $accountId int con el id de la cuenta */ public function __construct(Template $template = null, $lastAction = null, $accountId = null) { @@ -96,7 +97,7 @@ class Account extends Controller implements ActionsInterface */ private function setId($id) { - $this->_id = $id; + $this->id = $id; } /** @@ -104,7 +105,7 @@ class Account extends Controller implements ActionsInterface */ private function isGotData() { - return $this->_gotData; + return $this->gotData; } /** @@ -123,7 +124,7 @@ class Account extends Controller implements ActionsInterface array( 'class' => 'titleGreen', 'name' => _('Nueva Cuenta'), - 'icon' => $this->_icons->getIconAdd()->getIcon() + 'icon' => $this->icons->getIconAdd()->getIcon() ) ); $this->view->assign('nextaction', Acl::ACTION_ACC_NEW); @@ -148,7 +149,7 @@ class Account extends Controller implements ActionsInterface } elseif (!UserPass::checkUserUpdateMPass()) { $this->showError(self::ERR_UPDATE_MPASS); return false; - } elseif ($this->_id > 0 && !Acl::checkAccountAccess($this->_action, $this->_account->getAccountDataForACL())) { + } elseif ($this->id > 0 && !Acl::checkAccountAccess($this->action, $this->account->getAccountDataForACL())) { $this->showError(self::ERR_ACCOUNT_NO_PERMISSION); return false; } @@ -165,18 +166,18 @@ class Account extends Controller implements ActionsInterface if ($this->isGotData()) { $this->view->assign('accountIsHistory', $this->getAccount()->getAccountIsHistory()); - $this->view->assign('accountOtherUsers', $this->getAccount()->getAccountUsersId()); + $this->view->assign('accountOtherUsers', $this->getAccount()->getAccountData()->getAccountUsersId()); $this->view->assign('accountOtherUsersName', UserAccounts::getUsersNameForAccount($this->getId())); - $this->view->assign('accountOtherGroups', $this->getAccount()->getAccountUserGroupsId()); + $this->view->assign('accountOtherGroups', $this->getAccount()->getAccountData()->getAccountUserGroupsId()); $this->view->assign('accountOtherGroupsName', \SP\Mgmt\User\Groups::getGroupsNameForAccount($this->getId())); $this->view->assign('changesHash', $this->getAccount()->getAccountModHash()); - $this->view->assign('chkUserEdit', ($this->getAccount()->getAccountOtherUserEdit()) ? 'checked' : ''); - $this->view->assign('chkGroupEdit', ($this->getAccount()->getAccountOtherGroupEdit()) ? 'checked' : ''); + $this->view->assign('chkUserEdit', ($this->getAccount()->getAccountData()->getAccountOtherUserEdit()) ? 'checked' : ''); + $this->view->assign('chkGroupEdit', ($this->getAccount()->getAccountData()->getAccountOtherGroupEdit()) ? 'checked' : ''); $this->view->assign('historyData', \SP\Account\AccountHistory::getAccountList($this->getAccount()->getAccountParentId())); $this->view->assign('isModified', ($this->view->accountData->account_dateEdit && $this->view->accountData->account_dateEdit <> '0000-00-00 00:00:00')); - $this->view->assign('maxFileSize', round(Config::getValue('files_allowed_size') / 1024, 1)); - $this->view->assign('filesAllowedExts', Config::getValue('files_allowed_exts')); - $this->view->assign('filesDelete', ($this->_action == Acl::ACTION_ACC_EDIT) ? 1 : 0); + $this->view->assign('maxFileSize', round(Config::getConfig()->getFilesAllowedSize() / 1024, 1)); + $this->view->assign('filesAllowedExts', implode(',', Config::getConfig()->getFilesAllowedExts())); + $this->view->assign('filesDelete', ($this->action == Acl::ACTION_ACC_EDIT) ? 1 : 0); $publicLinkUrl = (Checks::publicLinksIsEnabled() && isset($this->view->accountData->publicLink_hash)) ? Init::$WEBURI . '/?h=' . $this->view->accountData->publicLink_hash . '&a=link' : ''; $this->view->assign('publicLinkUrl', $publicLinkUrl); @@ -191,22 +192,6 @@ class Account extends Controller implements ActionsInterface } - /** - * @return Account|AccountHistory - */ - private function getAccount() - { - return $this->_account; - } - - /** - * @return int - */ - private function getId() - { - return $this->_id; - } - /** * Obtener la lista de campos personalizados y sus valores */ @@ -223,37 +208,53 @@ class Account extends Controller implements ActionsInterface } } + /** + * @return int + */ + private function getId() + { + return $this->id; + } + + /** + * @return Account|AccountHistory + */ + private function getAccount() + { + return $this->account; + } + /** * Establecer variables para los interfaces que muestran datos */ private function setShowData() { - $aclData = ($this->isGotData()) ? $this->_account->getAccountDataForACL() : null; + $aclData = ($this->isGotData()) ? $this->account->getAccountDataForACL() : null; - $this->view->assign('showHistory', (($this->_action == Acl::ACTION_ACC_VIEW || $this->_action == Acl::ACTION_ACC_VIEW_HISTORY) + $this->view->assign('showHistory', (($this->action == Acl::ACTION_ACC_VIEW || $this->action == Acl::ACTION_ACC_VIEW_HISTORY) && Acl::checkUserAccess(Acl::ACTION_ACC_VIEW_HISTORY) - && ($this->view->isModified || $this->_action == Acl::ACTION_ACC_VIEW_HISTORY))); - $this->view->assign('showDetails', ($this->_action == Acl::ACTION_ACC_VIEW || $this->_action == Acl::ACTION_ACC_VIEW_HISTORY || $this->_action == Acl::ACTION_ACC_DELETE)); - $this->view->assign('showPass', ($this->_action == Acl::ACTION_ACC_NEW || $this->_action == Acl::ACTION_ACC_COPY)); - $this->view->assign('showFiles', (($this->_action == Acl::ACTION_ACC_EDIT || $this->_action == Acl::ACTION_ACC_VIEW || $this->_action == Acl::ACTION_ACC_VIEW_HISTORY) + && ($this->view->isModified || $this->action == Acl::ACTION_ACC_VIEW_HISTORY))); + $this->view->assign('showDetails', ($this->action == Acl::ACTION_ACC_VIEW || $this->action == Acl::ACTION_ACC_VIEW_HISTORY || $this->action == Acl::ACTION_ACC_DELETE)); + $this->view->assign('showPass', ($this->action == Acl::ACTION_ACC_NEW || $this->action == Acl::ACTION_ACC_COPY)); + $this->view->assign('showFiles', (($this->action == Acl::ACTION_ACC_EDIT || $this->action == Acl::ACTION_ACC_VIEW || $this->action == Acl::ACTION_ACC_VIEW_HISTORY) && (Checks::fileIsEnabled() && Acl::checkUserAccess(Acl::ACTION_ACC_FILES)))); - $this->view->assign('showViewPass', (($this->_action == Acl::ACTION_ACC_VIEW || $this->_action == Acl::ACTION_ACC_VIEW_HISTORY) + $this->view->assign('showViewPass', (($this->action == Acl::ACTION_ACC_VIEW || $this->action == Acl::ACTION_ACC_VIEW_HISTORY) && (Acl::checkAccountAccess(Acl::ACTION_ACC_VIEW_PASS, $aclData) && Acl::checkUserAccess(Acl::ACTION_ACC_VIEW_PASS)))); - $this->view->assign('showSave', ($this->_action == Acl::ACTION_ACC_EDIT || $this->_action == Acl::ACTION_ACC_NEW || $this->_action == Acl::ACTION_ACC_COPY)); - $this->view->assign('showEdit', ($this->_action == Acl::ACTION_ACC_VIEW + $this->view->assign('showSave', ($this->action == Acl::ACTION_ACC_EDIT || $this->action == Acl::ACTION_ACC_NEW || $this->action == Acl::ACTION_ACC_COPY)); + $this->view->assign('showEdit', ($this->action == Acl::ACTION_ACC_VIEW && Acl::checkAccountAccess(Acl::ACTION_ACC_EDIT, $aclData) && Acl::checkUserAccess(Acl::ACTION_ACC_EDIT) - && !$this->_account->getAccountIsHistory())); - $this->view->assign('showEditPass', ($this->_action == Acl::ACTION_ACC_EDIT || $this->_action == Acl::ACTION_ACC_VIEW + && !$this->account->getAccountIsHistory())); + $this->view->assign('showEditPass', ($this->action == Acl::ACTION_ACC_EDIT || $this->action == Acl::ACTION_ACC_VIEW && Acl::checkAccountAccess(Acl::ACTION_ACC_EDIT_PASS, $aclData) && Acl::checkUserAccess(Acl::ACTION_ACC_EDIT_PASS) - && !$this->_account->getAccountIsHistory())); - $this->view->assign('showDelete', ($this->_action == Acl::ACTION_ACC_DELETE || $this->_action == Acl::ACTION_ACC_EDIT + && !$this->account->getAccountIsHistory())); + $this->view->assign('showDelete', ($this->action == Acl::ACTION_ACC_DELETE || $this->action == Acl::ACTION_ACC_EDIT && Acl::checkAccountAccess(Acl::ACTION_ACC_DELETE, $aclData) && Acl::checkUserAccess(Acl::ACTION_ACC_DELETE))); - $this->view->assign('showRestore', ($this->_action == Acl::ACTION_ACC_VIEW_HISTORY - && Acl::checkAccountAccess(Acl::ACTION_ACC_EDIT, $this->_account->getAccountDataForACL($this->_account->getAccountParentId())) + $this->view->assign('showRestore', ($this->action == Acl::ACTION_ACC_VIEW_HISTORY + && Acl::checkAccountAccess(Acl::ACTION_ACC_EDIT, $this->account->getAccountDataForACL($this->account->getAccountParentId())) && Acl::checkUserAccess(Acl::ACTION_ACC_EDIT))); $this->view->assign('showLink', Checks::publicLinksIsEnabled() && Acl::checkUserAccess(Acl::ACTION_MGM_PUBLICLINKS)); } @@ -277,7 +278,7 @@ class Account extends Controller implements ActionsInterface array( 'class' => 'titleGreen', 'name' => _('Copiar Cuenta'), - 'icon' => $this->_icons->getIconCopy()->getIcon() + 'icon' => $this->icons->getIconCopy()->getIcon() ) ); $this->view->assign('nextaction', self::ACTION_ACC_COPY); @@ -294,12 +295,11 @@ class Account extends Controller implements ActionsInterface private function setAccountData() { try { - $this->setAccount(new \SP\Account\Account()); - $this->_account->setAccountId($this->getId()); - $this->_account->setAccountParentId($this->getId()); + $this->setAccount(new \SP\Account\Account(new AccountData($this->getId()))); + $this->account->setAccountParentId($this->getId()); $this->view->assign('accountId', $this->getId()); - $this->view->assign('accountData', $this->getAccount()->getAccountData()); + $this->view->assign('accountData', $this->getAccount()->getData()); $this->view->assign('gotData', true); // $this->setAccountDetails(); @@ -313,20 +313,11 @@ class Account extends Controller implements ActionsInterface } /** - * @param Account|AccountHistory $account + * @param \SP\Account\Account|\SP\Account\AccountHistory $account */ private function setAccount($account) { - $this->_account = $account; - } - - /** - * Establecer variables que contienen la información detallada de la cuenta. - */ - private function setAccountDetails() - { - $this->_account->setAccountUsersId(UserAccounts::getUsersForAccount($this->getId())); - $this->_account->setAccountUserGroupsId(Groups::getGroupsForAccount($this->getId())); + $this->account = $account; } /** @@ -334,7 +325,7 @@ class Account extends Controller implements ActionsInterface */ private function setGotData($gotData) { - $this->_gotData = $gotData; + $this->gotData = $gotData; } /** @@ -356,7 +347,7 @@ class Account extends Controller implements ActionsInterface array( 'class' => 'titleOrange', 'name' => _('Editar Cuenta'), - 'icon' => $this->_icons->getIconEdit()->getIcon() + 'icon' => $this->icons->getIconEdit()->getIcon() ) ); $this->view->assign('nextaction', self::ACTION_ACC_VIEW); @@ -384,7 +375,7 @@ class Account extends Controller implements ActionsInterface array( 'class' => 'titleRed', 'name' => _('Eliminar Cuenta'), - 'icon' => $this->_icons->getIconDelete()->getIcon() + 'icon' => $this->icons->getIconDelete()->getIcon() ) ); @@ -411,14 +402,14 @@ class Account extends Controller implements ActionsInterface array( 'class' => 'titleNormal', 'name' => _('Detalles de Cuenta'), - 'icon' => $this->_icons->getIconView()->getIcon() + 'icon' => $this->icons->getIconView()->getIcon() ) ); $this->view->assign('isView', true); \SP\Core\Session::setAccountParentId($this->getId()); - $this->_account->incrementViewCounter(); + $this->account->incrementViewCounter(); $this->setCommonData(); $this->setShowData(); @@ -447,7 +438,8 @@ class Account extends Controller implements ActionsInterface ) ); - $this->_account->setAccountIsHistory(1); + $this->view->assign('isView', true); + $this->account->setAccountIsHistory(1); $this->setCommonData(); $this->setShowData(); @@ -461,12 +453,11 @@ class Account extends Controller implements ActionsInterface private function setAccountDataHistory() { try { - $this->setAccount(new \SP\Account\AccountHistory()); - $this->_account->setAccountId($this->getId()); - $this->_account->setAccountParentId(Session::getAccountParentId()); + $this->setAccount(new \SP\Account\AccountHistory(new AccountData($this->getId()))); + $this->account->setAccountParentId(Session::getAccountParentId()); $this->view->assign('accountId', $this->getId()); - $this->view->assign('accountData', $this->getAccount()->getAccountData()); + $this->view->assign('accountData', $this->getAccount()->getData()); $this->view->assign('gotData', true); // $this->setAccountDetails(); @@ -499,7 +490,7 @@ class Account extends Controller implements ActionsInterface array( 'class' => 'titleOrange', 'name' => _('Modificar Clave de Cuenta'), - 'icon' => $this->_icons->getIconEditPass()->getIcon() + 'icon' => $this->icons->getIconEditPass()->getIcon() ) ); $this->view->assign('nextaction', self::ACTION_ACC_VIEW); @@ -536,22 +527,31 @@ class Account extends Controller implements ActionsInterface array( 'class' => 'titleNormal', 'name' => _('Detalles de Cuenta'), - 'icon' => $this->_icons->getIconView()->getIcon() + 'icon' => $this->icons->getIconView()->getIcon() ) ); - $this->_account->incrementViewCounter(); - $this->_account->incrementDecryptCounter(); - $this->_account->getAccountPassData(); + $this->account->incrementViewCounter(); + $this->account->incrementDecryptCounter(); + $this->account->getAccountPassData(); // Desencriptar la clave de la cuenta $pass = Crypt::generateAesKey($PublicLink->getLinkHash()); $masterPass = Crypt::getDecrypt($PublicLink->getPass(), $PublicLink->getPassIV(), $pass); - $accountPass = Crypt::getDecrypt($this->_account->getAccountPass(), $this->_account->getAccountIV(), $masterPass); + $accountPass = Crypt::getDecrypt($this->account->getAccountData()->getAccountPass(), $this->account->getAccountData()->getAccountIV(), $masterPass); - if (Config::getValue('publinks_image_enabled', false)) { + if (Config::getConfig()->isPublinksImageEnabled()) { $accountPass = ImageUtil::convertText($accountPass); } $this->view->assign('accountPass', $accountPass); } + + /** + * Establecer variables que contienen la información detallada de la cuenta. + */ + private function setAccountDetails() + { + $this->account->getAccountData()->setAccountUsersId(UserAccounts::getUsersForAccount($this->getId())); + $this->account->getAccountData()->setAccountUserGroupsId(Groups::getGroupsForAccount($this->getId())); + } } \ No newline at end of file diff --git a/inc/SP/Controller/AccountsSearch.class.php b/inc/SP/Controller/AccountsSearch.class.php index f9799f0a..af9abb60 100644 --- a/inc/SP/Controller/AccountsSearch.class.php +++ b/inc/SP/Controller/AccountsSearch.class.php @@ -28,6 +28,7 @@ namespace SP\Controller; defined('APP_ROOT') || die(_('No es posible acceder directamente a este archivo')); use SP\Account\Account; +use SP\Account\AccountData; use SP\Account\AccountFavorites; use SP\Account\AccountSearch; use SP\Config\Config; @@ -61,13 +62,13 @@ class AccountsSearch extends Controller implements ActionsInterface * * @var bool */ - private $_filterOn = false; + private $filterOn = false; /** * Colores para resaltar las cuentas * * @var array */ - private $_colors = array( + private $colors = array( '2196F3', '03A9F4', '00BCD4', @@ -125,7 +126,7 @@ class AccountsSearch extends Controller implements ActionsInterface private function setVars() { $this->view->assign('isAdmin', (Session::getUserIsAdminApp() || Session::getUserIsAdminAcc())); - $this->view->assign('showGlobalSearch', Config::getValue('globalsearch', false)); + $this->view->assign('showGlobalSearch', Config::getConfig()->isGlobalSearch()); // Comprobar si está creado el objeto de búsqueda en la sesión if (!is_object(Session::getSearchFilters())) { @@ -196,7 +197,7 @@ class AccountsSearch extends Controller implements ActionsInterface $resQuery = $search->getAccounts(); - $this->_filterOn = ($this->_sortKey > 1 + $this->filterOn = ($this->_sortKey > 1 || $this->view->searchCustomer || $this->view->searchCategory || $this->view->searchTxt @@ -238,46 +239,47 @@ class AccountsSearch extends Controller implements ActionsInterface $maxTextLength = (Checks::resultsCardsIsEnabled()) ? 40 : 60; if (AccountsSearchData::$wikiEnabled) { - $wikiSearchUrl = Config::getValue('wiki_searchurl', false); - $this->view->assign('wikiFilter', strtr(Config::getValue('wiki_filter'), ',', '|')); - $this->view->assign('wikiPageUrl', Config::getValue('wiki_pageurl')); + $wikiSearchUrl = Config::getConfig()->getWikiSearchurl(); + $this->view->assign('wikiFilter', implode('|', Config::getConfig()->getWikiFilter())); + $this->view->assign('wikiPageUrl', Config::getConfig()->getWikiPageurl()); } $favorites = AccountFavorites::getFavorites(Session::getUserId()); - $Account = new Account(); + $AccountData = new AccountData(); + $Account = new Account($AccountData); $accountsData['count'] = AccountSearch::$queryNumRows; foreach ($results as $account) { - $Account->setAccountId($account->account_id); - $Account->setAccountUserId($account->account_userId); - $Account->setAccountUserGroupId($account->account_userGroupId); - $Account->setAccountOtherUserEdit($account->account_otherUserEdit); - $Account->setAccountOtherGroupEdit($account->account_otherGroupEdit); + $AccountData->setAccountId($account->account_id); + $AccountData->setAccountUserId($account->account_userId); + $AccountData->setAccountUserGroupId($account->account_userGroupId); + $AccountData->setAccountOtherUserEdit($account->account_otherUserEdit); + $AccountData->setAccountOtherGroupEdit($account->account_otherGroupEdit); // Obtener los datos de la cuenta para aplicar las ACL $accountAclData = $Account->getAccountDataForACL(); - $AccountData = new AccountsSearchData(); - $AccountData->setTextMaxLength($maxTextLength); - $AccountData->setId($account->account_id); - $AccountData->setName($account->account_name); - $AccountData->setLogin($account->account_login); - $AccountData->setCategoryName($account->category_name); - $AccountData->setCustomerName($account->customer_name); - $AccountData->setCustomerLink((AccountsSearchData::$wikiEnabled) ? $wikiSearchUrl . $account->customer_name : ''); - $AccountData->setColor($this->pickAccountColor($account->account_customerId)); - $AccountData->setUrl($account->account_url); - $AccountData->setFavorite(in_array($account->account_id, $favorites)); - $AccountData->setNumFiles((Checks::fileIsEnabled()) ? $account->num_files : 0); - $AccountData->setShowView(Acl::checkAccountAccess(self::ACTION_ACC_VIEW, $accountAclData) && Acl::checkUserAccess(self::ACTION_ACC_VIEW)); - $AccountData->setShowViewPass(Acl::checkAccountAccess(self::ACTION_ACC_VIEW_PASS, $accountAclData) && Acl::checkUserAccess(self::ACTION_ACC_VIEW_PASS)); - $AccountData->setShowEdit(Acl::checkAccountAccess(self::ACTION_ACC_EDIT, $accountAclData) && Acl::checkUserAccess(self::ACTION_ACC_EDIT)); - $AccountData->setShowCopy(Acl::checkAccountAccess(self::ACTION_ACC_COPY, $accountAclData) && Acl::checkUserAccess(self::ACTION_ACC_COPY)); - $AccountData->setShowDelete(Acl::checkAccountAccess(self::ACTION_ACC_DELETE, $accountAclData) && Acl::checkUserAccess(self::ACTION_ACC_DELETE)); + $AccountSearchData = new AccountsSearchData(); + $AccountSearchData->setTextMaxLength($maxTextLength); + $AccountSearchData->setId($account->account_id); + $AccountSearchData->setName($account->account_name); + $AccountSearchData->setLogin($account->account_login); + $AccountSearchData->setCategoryName($account->category_name); + $AccountSearchData->setCustomerName($account->customer_name); + $AccountSearchData->setCustomerLink((AccountsSearchData::$wikiEnabled) ? $wikiSearchUrl . $account->customer_name : ''); + $AccountSearchData->setColor($this->pickAccountColor($account->account_customerId)); + $AccountSearchData->setUrl($account->account_url); + $AccountSearchData->setFavorite(in_array($account->account_id, $favorites)); + $AccountSearchData->setNumFiles((Checks::fileIsEnabled()) ? $account->num_files : 0); + $AccountSearchData->setShowView(Acl::checkAccountAccess(self::ACTION_ACC_VIEW, $accountAclData) && Acl::checkUserAccess(self::ACTION_ACC_VIEW)); + $AccountSearchData->setShowViewPass(Acl::checkAccountAccess(self::ACTION_ACC_VIEW_PASS, $accountAclData) && Acl::checkUserAccess(self::ACTION_ACC_VIEW_PASS)); + $AccountSearchData->setShowEdit(Acl::checkAccountAccess(self::ACTION_ACC_EDIT, $accountAclData) && Acl::checkUserAccess(self::ACTION_ACC_EDIT)); + $AccountSearchData->setShowCopy(Acl::checkAccountAccess(self::ACTION_ACC_COPY, $accountAclData) && Acl::checkUserAccess(self::ACTION_ACC_COPY)); + $AccountSearchData->setShowDelete(Acl::checkAccountAccess(self::ACTION_ACC_DELETE, $accountAclData) && Acl::checkUserAccess(self::ACTION_ACC_DELETE)); // Obtenemos datos si el usuario tiene acceso a los datos de la cuenta - if ($AccountData->isShow()) { + if ($AccountSearchData->isShow()) { $secondaryGroups = Groups::getGroupsNameForAccount($account->account_id); $secondaryUsers = UserAccounts::getUsersNameForAccount($account->account_id); @@ -295,7 +297,7 @@ class AccountsSearch extends Controller implements ActionsInterface } } - $AccountData->setAccesses($secondaryAccesses); + $AccountSearchData->setAccesses($secondaryAccesses); $accountNotes = ''; @@ -304,10 +306,10 @@ class AccountsSearch extends Controller implements ActionsInterface $accountNotes = nl2br(wordwrap(htmlspecialchars($accountNotes), 50, '
', true)); } - $AccountData->setNotes($accountNotes); + $AccountSearchData->setNotes($accountNotes); } - $accountsData[] = $AccountData; + $accountsData[] = $AccountSearchData; } return $accountsData; @@ -328,9 +330,9 @@ class AccountsSearch extends Controller implements ActionsInterface || !isset($accountColor[$id]) ) { // Se asigna el color de forma aleatoria a cada id - $color = array_rand($this->_colors); + $color = array_rand($this->colors); - $accountColor[$id] = '#' . $this->_colors[$color]; + $accountColor[$id] = '#' . $this->colors[$color]; Session::setAccountColor($accountColor); } @@ -351,7 +353,7 @@ class AccountsSearch extends Controller implements ActionsInterface $GridActionView->setType(DataGridActionType::VIEW_ITEM); $GridActionView->setName(_('Detalles de Cuenta')); $GridActionView->setTitle(_('Detalles de Cuenta')); - $GridActionView->setIcon($this->_icons->getIconView()); + $GridActionView->setIcon($this->icons->getIconView()); $GridActionView->setReflectionFilter('\\SP\\Controller\\AccountsSearchData', 'isShowView'); $GridActionView->setOnClickFunction('sysPassUtil.Common.accGridAction'); $GridActionView->setOnClickArgs(self::ACTION_ACC_VIEW); @@ -363,14 +365,14 @@ class AccountsSearch extends Controller implements ActionsInterface $GridActionViewPass->setType(DataGridActionType::VIEW_ITEM); $GridActionViewPass->setName(_('Ver Clave')); $GridActionViewPass->setTitle(_('Ver Clave')); - $GridActionViewPass->setIcon($this->_icons->getIconViewPass()); + $GridActionViewPass->setIcon($this->icons->getIconViewPass()); $GridActionViewPass->setReflectionFilter('\\SP\\Controller\\AccountsSearchData', 'isShowViewPass'); $GridActionViewPass->setOnClickFunction('sysPassUtil.Common.accGridViewPass'); $GridActionViewPass->setOnClickArgs('this'); $GridActionViewPass->setOnClickArgs(1); // Añadir la clase para usar el portapapeles - $ClipboardIcon = $this->_icons->getIconClipboard(); + $ClipboardIcon = $this->icons->getIconClipboard(); $ClipboardIcon->setClass('clip-pass-button'); $GridActionCopyPass = new DataGridAction(); @@ -384,7 +386,7 @@ class AccountsSearch extends Controller implements ActionsInterface $GridActionCopyPass->setOnClickArgs('this'); $GridActionCopyPass->setOnClickArgs(0); - $EditIcon = $this->_icons->getIconEdit(); + $EditIcon = $this->icons->getIconEdit(); if (!$showOptionalActions) { $EditIcon->setClass('actions-optional'); @@ -402,7 +404,7 @@ class AccountsSearch extends Controller implements ActionsInterface $GridActionEdit->setOnClickArgs(self::ACTION_ACC_SEARCH); $GridActionEdit->setOnClickArgs('this'); - $CopyIcon = $this->_icons->getIconCopy(); + $CopyIcon = $this->icons->getIconCopy(); if (!$showOptionalActions) { $CopyIcon->setClass('actions-optional'); @@ -420,7 +422,7 @@ class AccountsSearch extends Controller implements ActionsInterface $GridActionCopy->setOnClickArgs(self::ACTION_ACC_SEARCH); $GridActionCopy->setOnClickArgs('this'); - $DeleteIcon = $this->_icons->getIconDelete(); + $DeleteIcon = $this->icons->getIconDelete(); if (!$showOptionalActions) { $DeleteIcon->setClass('actions-optional'); @@ -442,7 +444,7 @@ class AccountsSearch extends Controller implements ActionsInterface $GridActionRequest->setId(self::ACTION_ACC_REQUEST); $GridActionRequest->setName(_('Solicitar Modificación')); $GridActionRequest->setTitle(_('Solicitar Modificación')); - $GridActionRequest->setIcon($this->_icons->getIconEmail()); + $GridActionRequest->setIcon($this->icons->getIconEmail()); $GridActionRequest->setReflectionFilter('\\SP\\Controller\\AccountsSearchData', 'isShowRequest'); $GridActionRequest->setOnClickFunction('sysPassUtil.Common.accGridAction'); $GridActionRequest->setOnClickArgs(self::ACTION_ACC_REQUEST); @@ -453,16 +455,16 @@ class AccountsSearch extends Controller implements ActionsInterface $GridActionOptional->setId(self::ACTION_ACC_REQUEST); $GridActionOptional->setName(_('Más Acciones')); $GridActionOptional->setTitle(_('Más Acciones')); - $GridActionOptional->setIcon($this->_icons->getIconOptional()); + $GridActionOptional->setIcon($this->icons->getIconOptional()); $GridActionOptional->setReflectionFilter('\\SP\\Controller\\AccountsSearchData', 'isShowOptional'); $GridActionOptional->setOnClickFunction('sysPassUtil.Common.showOptional'); $GridActionOptional->setOnClickArgs('this'); $GridPager = new DataGridPager(); - $GridPager->setIconPrev($this->_icons->getIconNavPrev()); - $GridPager->setIconNext($this->_icons->getIconNavNext()); - $GridPager->setIconFirst($this->_icons->getIconNavFirst()); - $GridPager->setIconLast($this->_icons->getIconNavLast()); + $GridPager->setIconPrev($this->icons->getIconNavPrev()); + $GridPager->setIconNext($this->icons->getIconNavNext()); + $GridPager->setIconFirst($this->icons->getIconNavFirst()); + $GridPager->setIconLast($this->icons->getIconNavLast()); $GridPager->setSortKey($this->_sortKey); $GridPager->setSortOrder($this->_sortOrder); $GridPager->setLimitStart($this->_limitStart); @@ -470,7 +472,7 @@ class AccountsSearch extends Controller implements ActionsInterface $GridPager->setOnClickFunction('sysPassUtil.Common.searchSort'); $GridPager->setOnClickArgs($this->_sortKey); $GridPager->setOnClickArgs($this->_sortOrder); - $GridPager->setFilterOn($this->_filterOn); + $GridPager->setFilterOn($this->filterOn); $Grid = new DataGrid(); $Grid->setId('gridSearch'); @@ -503,36 +505,36 @@ class AccountsSearch extends Controller implements ActionsInterface $GridSortCustomer->setName(_('Cliente')); $GridSortCustomer->setTitle(_('Ordenar por Cliente')); $GridSortCustomer->setSortKey(AccountSearch::SORT_CUSTOMER); - $GridSortCustomer->setIconUp($this->_icons->getIconUp()); - $GridSortCustomer->setIconDown($this->_icons->getIconDown()); + $GridSortCustomer->setIconUp($this->icons->getIconUp()); + $GridSortCustomer->setIconDown($this->icons->getIconDown()); $GridSortName = new DataGridSort(); $GridSortName->setName(_('Nombre')); $GridSortName->setTitle(_('Ordenar por Nombre')); $GridSortName->setSortKey(AccountSearch::SORT_NAME); - $GridSortName->setIconUp($this->_icons->getIconUp()); - $GridSortName->setIconDown($this->_icons->getIconDown()); + $GridSortName->setIconUp($this->icons->getIconUp()); + $GridSortName->setIconDown($this->icons->getIconDown()); $GridSortCategory = new DataGridSort(); $GridSortCategory->setName(_('Categoría')); $GridSortCategory->setTitle(_('Ordenar por Categoría')); $GridSortCategory->setSortKey(AccountSearch::SORT_CATEGORY); - $GridSortCategory->setIconUp($this->_icons->getIconUp()); - $GridSortCategory->setIconDown($this->_icons->getIconDown()); + $GridSortCategory->setIconUp($this->icons->getIconUp()); + $GridSortCategory->setIconDown($this->icons->getIconDown()); $GridSortLogin = new DataGridSort(); $GridSortLogin->setName(_('Usuario')); $GridSortLogin->setTitle(_('Ordenar por Usuario')); $GridSortLogin->setSortKey(AccountSearch::SORT_LOGIN); - $GridSortLogin->setIconUp($this->_icons->getIconUp()); - $GridSortLogin->setIconDown($this->_icons->getIconDown()); + $GridSortLogin->setIconUp($this->icons->getIconUp()); + $GridSortLogin->setIconDown($this->icons->getIconDown()); $GridSortUrl = new DataGridSort(); $GridSortUrl->setName(_('URL / IP')); $GridSortUrl->setTitle(_('Ordenar por URL / IP')); $GridSortUrl->setSortKey(AccountSearch::SORT_URL); - $GridSortUrl->setIconUp($this->_icons->getIconUp()); - $GridSortUrl->setIconDown($this->_icons->getIconDown()); + $GridSortUrl->setIconUp($this->icons->getIconUp()); + $GridSortUrl->setIconDown($this->icons->getIconDown()); $GridHeaderSort = new DataGridHeaderSort(); $GridHeaderSort->addSortField($GridSortCustomer); diff --git a/inc/SP/Controller/AppItemsMgmt.class.php b/inc/SP/Controller/AppItemsMgmt.class.php index 9f63c89a..da6e9af9 100644 --- a/inc/SP/Controller/AppItemsMgmt.class.php +++ b/inc/SP/Controller/AppItemsMgmt.class.php @@ -48,7 +48,7 @@ class AppItemsMgmt extends GridTabController implements ActionsInterface /** * @var int */ - private $_limitCount; + private $limitCount; /** * Constructor @@ -59,7 +59,7 @@ class AppItemsMgmt extends GridTabController implements ActionsInterface { parent::__construct($template); - $this->_limitCount = Config::getValue('account_count'); + $this->limitCount = Config::getConfig()->getAccountCount(); } /** @@ -73,10 +73,10 @@ class AppItemsMgmt extends GridTabController implements ActionsInterface return; } - $Grid = $this->_grids->getCategoriesGrid(); - $Grid->getData()->setData(Category::getCategoriesMgmtSearch($this->_limitCount)); + $Grid = $this->Grids->getCategoriesGrid(); + $Grid->getData()->setData(Category::getCategoriesMgmtSearch($this->limitCount)); $Grid->updatePager(); - $Grid->getPager()->setOnClickArgs($this->_limitCount); + $Grid->getPager()->setOnClickArgs($this->limitCount); $this->view->append('tabs', $Grid); } @@ -92,10 +92,10 @@ class AppItemsMgmt extends GridTabController implements ActionsInterface return; } - $Grid = $this->_grids->getCustomersGrid(); - $Grid->getData()->setData(Customer::getCustomersMgmtSearch($this->_limitCount)); + $Grid = $this->Grids->getCustomersGrid(); + $Grid->getData()->setData(Customer::getCustomersMgmtSearch($this->limitCount)); $Grid->updatePager(); - $Grid->getPager()->setOnClickArgs($this->_limitCount); + $Grid->getPager()->setOnClickArgs($this->limitCount); $this->view->append('tabs', $Grid); } @@ -131,10 +131,10 @@ class AppItemsMgmt extends GridTabController implements ActionsInterface return; } - $Grid = $this->_grids->getCustomFieldsGrid(); - $Grid->getData()->setData(CustomFieldDef::getCustomFieldsMgmtSearch($this->_limitCount)); + $Grid = $this->Grids->getCustomFieldsGrid(); + $Grid->getData()->setData(CustomFieldDef::getCustomFieldsMgmtSearch($this->limitCount)); $Grid->updatePager(); - $Grid->getPager()->setOnClickArgs($this->_limitCount); + $Grid->getPager()->setOnClickArgs($this->limitCount); $this->view->append('tabs', $Grid); } @@ -151,10 +151,10 @@ class AppItemsMgmt extends GridTabController implements ActionsInterface return; } - $Grid = $this->_grids->getFilesGrid(); - $Grid->getData()->setData(Files::getFilesMgmtSearch($this->_limitCount)); + $Grid = $this->Grids->getFilesGrid(); + $Grid->getData()->setData(Files::getFilesMgmtSearch($this->limitCount)); $Grid->updatePager(); - $Grid->getPager()->setOnClickArgs($this->_limitCount); + $Grid->getPager()->setOnClickArgs($this->limitCount); $this->view->append('tabs', $Grid); } @@ -170,10 +170,10 @@ class AppItemsMgmt extends GridTabController implements ActionsInterface return; } - $Grid = $this->_grids->getAccountsGrid(); - $Grid->getData()->setData(AccountUtil::getAccountsMgmtSearch($this->_limitCount)); + $Grid = $this->Grids->getAccountsGrid(); + $Grid->getData()->setData(AccountUtil::getAccountsMgmtSearch($this->limitCount)); $Grid->updatePager(); - $Grid->getPager()->setOnClickArgs($this->_limitCount); + $Grid->getPager()->setOnClickArgs($this->limitCount); $this->view->append('tabs', $Grid); } diff --git a/inc/SP/Controller/ConfigMgmt.class.php b/inc/SP/Controller/ConfigMgmt.class.php index f5bd020d..e6939e03 100644 --- a/inc/SP/Controller/ConfigMgmt.class.php +++ b/inc/SP/Controller/ConfigMgmt.class.php @@ -46,7 +46,8 @@ use SP\Util\Util; */ class ConfigMgmt extends Controller implements ActionsInterface { - private $_tabIndex = 0; + private $tabIndex = 0; + private $Config; /** * Constructor @@ -57,6 +58,8 @@ class ConfigMgmt extends Controller implements ActionsInterface { parent::__construct($template); + $this->Config = Config::getConfig(); + $this->view->assign('tabs', array()); $this->view->assign('sk', SessionUtil::getSessionKey(true)); $this->view->assign('isDemoMode', (Checks::demoIsEnabled() && !Session::getUserIsAdminApp())); @@ -79,47 +82,47 @@ class ConfigMgmt extends Controller implements ActionsInterface $this->view->addTemplate('config'); $this->view->assign('langsAvailable',Language::getAvailableLanguages()); - $this->view->assign('currentLang', Config::getValue('sitelang')); + $this->view->assign('currentLang', $this->Config->getSiteLang()); $this->view->assign('themesAvailable', Themes::getThemesAvailable()); - $this->view->assign('currentTheme', Config::getValue('sitetheme')); - $this->view->assign('chkHttps', (Config::getValue('https_enabled')) ? 'checked="checked"' : ''); - $this->view->assign('chkDebug', (Config::getValue('debug')) ? 'checked="checked"' : ''); - $this->view->assign('chkMaintenance', (Config::getValue('maintenance')) ? 'checked="checked"' : ''); - $this->view->assign('chkUpdates', (Config::getValue('checkupdates')) ? 'checked="checked"' : ''); - $this->view->assign('chkNotices', (Config::getValue('checknotices')) ? 'checked="checked"' : ''); - $this->view->assign('sessionTimeout', Config::getValue('session_timeout')); + $this->view->assign('currentTheme', $this->Config->getSiteTheme()); + $this->view->assign('chkHttps', ($this->Config->isHttpsEnabled()) ? 'checked="checked"' : ''); + $this->view->assign('chkDebug', ($this->Config->isDebug()) ? 'checked="checked"' : ''); + $this->view->assign('chkMaintenance', ($this->Config->isMaintenance()) ? 'checked="checked"' : ''); + $this->view->assign('chkUpdates', ($this->Config->isCheckUpdates()) ? 'checked="checked"' : ''); + $this->view->assign('chkNotices', ($this->Config->isChecknotices()) ? 'checked="checked"' : ''); + $this->view->assign('sessionTimeout', $this->Config->getSessionTimeout()); // Events - $this->view->assign('chkLog', (Config::getValue('log_enabled')) ? 'checked="checked"' : ''); - $this->view->assign('chkSyslog', (Config::getValue('syslog_enabled')) ? 'checked="checked"' : ''); - $this->view->assign('chkRemoteSyslog', (Config::getValue('syslog_remote_enabled')) ? 'checked="checked"' : ''); - $this->view->assign('remoteSyslogServer', Config::getValue('syslog_server')); - $this->view->assign('remoteSyslogPort', Config::getValue('syslog_port')); + $this->view->assign('chkLog', ($this->Config->isLogEnabled()) ? 'checked="checked"' : ''); + $this->view->assign('chkSyslog', ($this->Config->isSyslogEnabled()) ? 'checked="checked"' : ''); + $this->view->assign('chkRemoteSyslog', ($this->Config->isSyslogRemoteEnabled()) ? 'checked="checked"' : ''); + $this->view->assign('remoteSyslogServer', $this->Config->getSyslogServer()); + $this->view->assign('remoteSyslogPort', $this->Config->getSyslogPort()); // Files - $this->view->assign('chkFiles', (Config::getValue('files_enabled')) ? 'checked="checked"' : ''); - $this->view->assign('filesAllowedExts', Config::getValue('files_allowed_exts')); - $this->view->assign('filesAllowedSize', Config::getValue('files_allowed_size')); + $this->view->assign('chkFiles', ($this->Config->isFilesEnabled()) ? 'checked="checked"' : ''); + $this->view->assign('filesAllowedExts', implode(',', $this->Config->getFilesAllowedExts())); + $this->view->assign('filesAllowedSize', $this->Config->getFilesAllowedSize()); // Accounts - $this->view->assign('chkGlobalSearch', (Config::getValue('globalsearch')) ? 'checked="checked"' : ''); - $this->view->assign('chkResultsAsCards', (Config::getValue('resultsascards')) ? 'checked="checked"' : ''); - $this->view->assign('chkAccountPassToImage', (Config::getValue('account_passtoimage')) ? 'checked="checked"' : ''); - $this->view->assign('chkAccountLink', (Config::getValue('account_link')) ? 'checked="checked"' : ''); - $this->view->assign('accountCount', Config::getValue('account_count')); + $this->view->assign('chkGlobalSearch', ($this->Config->isGlobalSearch()) ? 'checked="checked"' : ''); + $this->view->assign('chkResultsAsCards', ($this->Config->isResultsAsCards()) ? 'checked="checked"' : ''); + $this->view->assign('chkAccountPassToImage', ($this->Config->isAccountPassToImage()) ? 'checked="checked"' : ''); + $this->view->assign('chkAccountLink', ($this->Config->isAccountLink()) ? 'checked="checked"' : ''); + $this->view->assign('accountCount', $this->Config->getAccountCount()); + + // PublicLinks + $this->view->assign('chkPubLinks', ($this->Config->isPublinksImageEnabled()) ? 'checked="checked"' : ''); + $this->view->assign('chkPubLinksImage', ($this->Config->isPublinksImageEnabled()) ? 'checked="checked"' : ''); + $this->view->assign('pubLinksMaxTime', $this->Config->getPublinksMaxTime() / 60); + $this->view->assign('pubLinksMaxViews', $this->Config->getPublinksMaxViews()); // Proxy - $this->view->assign('chkPubLinks', (Config::getValue('publinks_enabled')) ? 'checked="checked"' : ''); - $this->view->assign('chkPubLinksImage', (Config::getValue('publinks_image_enabled')) ? 'checked="checked"' : ''); - $this->view->assign('pubLinksMaxTime', Config::getValue('publinks_maxtime') / 60); - $this->view->assign('pubLinksMaxViews', Config::getValue('publinks_maxviews')); - - // Proxy - $this->view->assign('chkProxy', (Config::getValue('proxy_enabled')) ? 'checked="checked"' : ''); - $this->view->assign('proxyServer', Config::getValue('proxy_server')); - $this->view->assign('proxyPort', Config::getValue('proxy_port')); - $this->view->assign('proxyUser', Config::getValue('proxy_user')); - $this->view->assign('proxyPass', Config::getValue('proxy_pass')); + $this->view->assign('chkProxy', ($this->Config->isProxyEnabled()) ? 'checked="checked"' : ''); + $this->view->assign('proxyServer', $this->Config->getProxyServer()); + $this->view->assign('proxyPort', $this->Config->getProxyPort()); + $this->view->assign('proxyUser', $this->Config->getProxyUser()); + $this->view->assign('proxyPass', $this->Config->getProxyPass()); $this->view->assign('actionId', $this->getAction(), 'config'); $this->view->append('tabs', array('title' => _('General'))); @@ -169,8 +172,8 @@ class ConfigMgmt extends Controller implements ActionsInterface $this->view->assign('backupDir', Init::$SERVERROOT . '/backup'); $this->view->assign('backupPath', Init::$WEBROOT . '/backup'); - $backupHash = Config::getValue('backup_hash'); - $exportHash = Config::getValue('export_hash'); + $backupHash = $this->Config->getBackupHash(); + $exportHash = $this->Config->getExportHash(); $this->view->assign('backupFile', array('absolute' => $this->view->backupDir . DIRECTORY_SEPARATOR . $this->view->siteName . '-' . $backupHash . '.tar.gz', @@ -232,7 +235,7 @@ class ConfigMgmt extends Controller implements ActionsInterface $this->view->addTemplate('info'); $this->view->assign('dbInfo', DBUtil::getDBinfo()); - $this->view->assign('dbName', Config::getValue('dbname') . '@' . Config::getValue('dbhost')); + $this->view->assign('dbName', $this->Config->getDbName() . '@' . $this->Config->getDbHost()); $this->view->assign('configBackupDate', date("r", ConfigDB::getValue('config_backupdate'))); $this->view->append('tabs', array('title' => _('Información'))); @@ -253,18 +256,17 @@ class ConfigMgmt extends Controller implements ActionsInterface $this->view->addTemplate('wiki'); - $this->view->assign('chkWiki', (Config::getValue('wiki_enabled')) ? 'checked="checked"' : ''); - $this->view->assign('wikiSearchUrl', Config::getValue('wiki_searchurl')); - $this->view->assign('wikiPageUrl', Config::getValue('wiki_pageurl')); - $this->view->assign('wikiFilter', Config::getValue('wiki_filter')); - $this->view->assign('dokuWikiUrl', Config::getValue('dokuwiki_url')); + $this->view->assign('chkWiki', ($this->Config->isWikiEnabled()) ? 'checked="checked"' : ''); + $this->view->assign('wikiSearchUrl', $this->Config->getWikiSearchurl()); + $this->view->assign('wikiPageUrl', $this->Config->getWikiPageurl()); + $this->view->assign('wikiFilter', implode(',', $this->Config->getWikiFilter())); - $this->view->assign('chkDokuWiki', (Config::getValue('dokuwiki_enabled')) ? 'checked="checked"' : ''); - $this->view->assign('dokuWikiUrl', Config::getValue('dokuwiki_url')); - $this->view->assign('dokuWikiUrlBase', Config::getValue('dokuwiki_urlbase')); - $this->view->assign('dokuWikiUser', Config::getValue('dokuwiki_user')); - $this->view->assign('dokuWikiPass', Config::getValue('dokuwiki_pass')); - $this->view->assign('dokuWikiNamespace', Config::getValue('dokuwiki_namespace')); + $this->view->assign('chkDokuWiki', ($this->Config->isDokuwikiEnabled()) ? 'checked="checked"' : ''); + $this->view->assign('dokuWikiUrl', $this->Config->getDokuwikiUrl()); + $this->view->assign('dokuWikiUrlBase', $this->Config->getDokuwikiUrlBase()); + $this->view->assign('dokuWikiUser', $this->Config->getDokuwikiUser()); + $this->view->assign('dokuWikiPass', $this->Config->getDokuwikiPass()); + $this->view->assign('dokuWikiNamespace', $this->Config->getDokuwikiNamespace()); $this->view->assign('actionId', $this->getAction(), 'wiki'); $this->view->append('tabs', array('title' => _('Wiki'))); @@ -285,18 +287,18 @@ class ConfigMgmt extends Controller implements ActionsInterface $this->view->addTemplate('ldap'); - $this->view->assign('chkLdap', (Config::getValue('ldap_enabled')) ? 'checked="checked"' : ''); - $this->view->assign('chkLdapADS', (Config::getValue('ldap_ads')) ? 'checked="checked"' : ''); + $this->view->assign('chkLdap', ($this->Config->isLdapEnabled()) ? 'checked="checked"' : ''); + $this->view->assign('chkLdapADS', ($this->Config->isLdapAds()) ? 'checked="checked"' : ''); $this->view->assign('ldapIsAvailable', Checks::ldapIsAvailable()); - $this->view->assign('ldapServer', Config::getValue('ldap_server')); - $this->view->assign('ldapBindUser', Config::getValue('ldap_binduser')); - $this->view->assign('ldapBindPass', Config::getValue('ldap_bindpass')); - $this->view->assign('ldapBase', Config::getValue('ldap_base')); - $this->view->assign('ldapGroup', Config::getValue('ldap_group')); + $this->view->assign('ldapServer', $this->Config->getLdapServer()); + $this->view->assign('ldapBindUser', $this->Config->getLdapBindUser()); + $this->view->assign('ldapBindPass', $this->Config->getLdapBindPass()); + $this->view->assign('ldapBase', $this->Config->getLdapBase()); + $this->view->assign('ldapGroup', $this->Config->getLdapGroup()); $this->view->assign('groups', DBUtil::getValuesForSelect('usrGroups', 'usergroup_id', 'usergroup_name')); $this->view->assign('profiles', DBUtil::getValuesForSelect('usrProfiles', 'userprofile_id', 'userprofile_name')); - $this->view->assign('ldapDefaultGroup', Config::getValue('ldap_defaultgroup')); - $this->view->assign('ldapDefaultProfile', Config::getValue('ldap_defaultprofile')); + $this->view->assign('ldapDefaultGroup', $this->Config->getLdapDefaultGroup()); + $this->view->assign('ldapDefaultProfile', $this->Config->getLdapDefaultProfile()); $this->view->assign('actionId', $this->getAction(), 'ldap'); $this->view->append('tabs', array('title' => _('LDAP'))); @@ -317,15 +319,15 @@ class ConfigMgmt extends Controller implements ActionsInterface $this->view->addTemplate('mail'); - $this->view->assign('chkMail', (Config::getValue('mail_enabled')) ? 'checked="checked"' : ''); - $this->view->assign('chkMailRequests', (Config::getValue('mail_requestsenabled')) ? 'checked="checked"' : ''); - $this->view->assign('chkMailAuth', (Config::getValue('mail_authenabled')) ? 'checked="checked"' : ''); - $this->view->assign('mailServer', Config::getValue('mail_server','localhost')); - $this->view->assign('mailPort', Config::getValue('mail_port',25)); - $this->view->assign('mailUser', Config::getValue('mail_user')); - $this->view->assign('mailPass', Config::getValue('mail_pass')); - $this->view->assign('currentMailSecurity', Config::getValue('mail_security')); - $this->view->assign('mailFrom', Config::getValue('mail_from')); + $this->view->assign('chkMail', ($this->Config->isMailEnabled()) ? 'checked="checked"' : ''); + $this->view->assign('chkMailRequests', ($this->Config->isMailRequestsEnabled()) ? 'checked="checked"' : ''); + $this->view->assign('chkMailAuth', ($this->Config->isMailAuthenabled()) ? 'checked="checked"' : ''); + $this->view->assign('mailServer', $this->Config->getMailServer()); + $this->view->assign('mailPort', $this->Config->getMailPort()); + $this->view->assign('mailUser', $this->Config->getMailUser()); + $this->view->assign('mailPass', $this->Config->getMailPass()); + $this->view->assign('currentMailSecurity', $this->Config->getMailSecurity()); + $this->view->assign('mailFrom', $this->Config->getMailFrom()); $this->view->assign('mailSecurity', array('SSL', 'TLS')); $this->view->assign('actionId', $this->getAction(), 'mail'); @@ -339,8 +341,8 @@ class ConfigMgmt extends Controller implements ActionsInterface * @return int */ private function getTabIndex(){ - $index = $this->_tabIndex; - $this->_tabIndex++; + $index = $this->tabIndex; + $this->tabIndex++; return $index; } diff --git a/inc/SP/Controller/Controller.class.php b/inc/SP/Controller/Controller.class.php index 5421a84b..ee86cd53 100644 --- a/inc/SP/Controller/Controller.class.php +++ b/inc/SP/Controller/Controller.class.php @@ -60,13 +60,13 @@ abstract class Controller * * @var int */ - protected $_action; + protected $action; /** * Instancia de los iconos del tema visual * * @var Icons */ - protected $_icons; + protected $icons; /** * Constructor @@ -84,8 +84,8 @@ abstract class Controller } $this->view->assign('timeStart', $timeStart); - $this->_icons = Themes::getIcons(); - $this->view->assign('icons', $this->_icons); + $this->icons = Themes::getIcons(); + $this->view->assign('icons', $this->icons); } /** @@ -104,7 +104,7 @@ abstract class Controller */ public function getAction() { - return $this->_action; + return $this->action; } /** @@ -114,7 +114,7 @@ abstract class Controller */ public function setAction($action) { - $this->_action = $action; + $this->action = $action; } /** @@ -165,7 +165,7 @@ abstract class Controller */ protected function checkAccess($action = null) { - $checkAction = $this->_action; + $checkAction = $this->action; if (!is_null($action)) { $checkAction = $action; diff --git a/inc/SP/Controller/GridItemsSearch.class.php b/inc/SP/Controller/GridItemsSearch.class.php index 07709307..df9c9021 100644 --- a/inc/SP/Controller/GridItemsSearch.class.php +++ b/inc/SP/Controller/GridItemsSearch.class.php @@ -12,6 +12,7 @@ defined('APP_ROOT') || die(_('No es posible acceder directamente a este archivo' use SP\Core\Template; use SP\Html\DataGrid\DataGridPagerBase; +use SP\Html\DataGrid\DataGridPagerInterface; use SP\Util\Checks; /** @@ -44,12 +45,12 @@ abstract class GridItemsSearch extends Controller /** * Actualizar los datos del paginador * - * @param DataGridPagerBase $Pager + * @param DataGridPagerInterface $Pager * @param bool $filterOn * @param int $limitStart * @param int $limitCount */ - protected function updatePager(DataGridPagerBase $Pager, $filterOn, $limitStart, $limitCount) + protected function updatePager(DataGridPagerInterface $Pager, $filterOn, $limitStart, $limitCount) { $Pager->setLimitStart($limitStart); $Pager->setLimitCount($limitCount); diff --git a/inc/SP/Controller/GridTabController.class.php b/inc/SP/Controller/GridTabController.class.php index df4bdd58..cf302119 100644 --- a/inc/SP/Controller/GridTabController.class.php +++ b/inc/SP/Controller/GridTabController.class.php @@ -45,7 +45,7 @@ abstract class GridTabController extends Controller /** * @var Grids */ - protected $_grids; + protected $Grids; /** * Constructor @@ -65,8 +65,8 @@ abstract class GridTabController extends Controller */ public function useTabs() { - $this->_grids = new Grids(); - $this->_grids->setQueryTimeStart($this->view->queryTimeStart); + $this->Grids = new Grids(); + $this->Grids->setQueryTimeStart($this->view->queryTimeStart); $this->view->addTemplate('datatabs-grid'); diff --git a/inc/SP/Controller/Grids.class.php b/inc/SP/Controller/Grids.class.php index d3ddeeb1..32df6a16 100644 --- a/inc/SP/Controller/Grids.class.php +++ b/inc/SP/Controller/Grids.class.php @@ -50,27 +50,27 @@ class Grids implements ActionsInterface /** * @var ThemeIconsBase */ - private $_icons; + private $icons; /** * @var string */ - private $_sk; + private $sk; /** * @var int */ - private $_queryTimeStart; + private $queryTimeStart; /** * @var bool */ - private $_filter = false; + private $filter = false; /** * Grids constructor. */ public function __construct() { - $this->_sk = SessionUtil::getSessionKey(true); - $this->_icons = Themes::getIcons(); + $this->sk = SessionUtil::getSessionKey(true); + $this->icons = Themes::getIcons(); } /** @@ -91,34 +91,34 @@ class Grids implements ActionsInterface $GridActionNew->setType(DataGridActionType::NEW_ITEM); $GridActionNew->setName(_('Nueva Categoría')); $GridActionNew->setTitle(_('Nueva Categoría')); - $GridActionNew->setIcon($this->_icons->getIconAdd()); + $GridActionNew->setIcon($this->icons->getIconAdd()); $GridActionNew->setSkip(true); $GridActionNew->setOnClickFunction('sysPassUtil.Common.appMgmtData'); $GridActionNew->setOnClickArgs('this'); $GridActionNew->setOnClickArgs(self::ACTION_MGM_CATEGORIES_NEW); - $GridActionNew->setOnClickArgs($this->_sk); + $GridActionNew->setOnClickArgs($this->sk); $GridActionEdit = new DataGridAction(); $GridActionEdit->setId(self::ACTION_MGM_CATEGORIES_EDIT); $GridActionEdit->setType(DataGridActionType::EDIT_ITEM); $GridActionEdit->setName(_('Editar Categoría')); $GridActionEdit->setTitle(_('Editar Categoría')); - $GridActionEdit->setIcon($this->_icons->getIconEdit()); + $GridActionEdit->setIcon($this->icons->getIconEdit()); $GridActionEdit->setOnClickFunction('sysPassUtil.Common.appMgmtData'); $GridActionEdit->setOnClickArgs('this'); $GridActionEdit->setOnClickArgs(self::ACTION_MGM_CATEGORIES_EDIT); - $GridActionEdit->setOnClickArgs($this->_sk); + $GridActionEdit->setOnClickArgs($this->sk); $GridActionDel = new DataGridAction(); $GridActionDel->setId(self::ACTION_MGM_CATEGORIES_DELETE); $GridActionDel->setType(DataGridActionType::DELETE_ITEM); $GridActionDel->setName(_('Eliminar Categoría')); $GridActionDel->setTitle(_('Eliminar Categoría')); - $GridActionDel->setIcon($this->_icons->getIconDelete()); + $GridActionDel->setIcon($this->icons->getIconDelete()); $GridActionDel->setOnClickFunction('sysPassUtil.Common.appMgmtDelete'); $GridActionDel->setOnClickArgs('this'); $GridActionDel->setOnClickArgs(self::ACTION_MGM_CATEGORIES_DELETE); - $GridActionDel->setOnClickArgs($this->_sk); + $GridActionDel->setOnClickArgs($this->sk); $GridHeaders = new DataGridHeader(); $GridHeaders->addHeader(_('Nombre')); @@ -141,7 +141,7 @@ class Grids implements ActionsInterface $Grid->setPager($this->getPager($GridActionSearch)); $Grid->setData($GridData); $Grid->setTitle(_('Gestión de Categorías')); - $Grid->setTime(round(microtime() - $this->_queryTimeStart, 5)); + $Grid->setTime(round(microtime() - $this->queryTimeStart, 5)); return $Grid; } @@ -158,11 +158,11 @@ class Grids implements ActionsInterface $GridPager->setOnClickFunction('sysPassUtil.Common.appMgmtNav'); $GridPager->setOnClickArgs($sourceAction->getName()); $GridPager->setLimitStart(0); - $GridPager->setLimitCount(Config::getValue('account_count')); - $GridPager->setIconPrev($this->_icons->getIconNavPrev()); - $GridPager->setIconNext($this->_icons->getIconNavNext()); - $GridPager->setIconFirst($this->_icons->getIconNavFirst()); - $GridPager->setIconLast($this->_icons->getIconNavLast()); + $GridPager->setLimitCount(Config::getConfig()->getAccountCount()); + $GridPager->setIconPrev($this->icons->getIconNavPrev()); + $GridPager->setIconNext($this->icons->getIconNavNext()); + $GridPager->setIconFirst($this->icons->getIconNavFirst()); + $GridPager->setIconLast($this->icons->getIconNavLast()); return $GridPager; } @@ -185,34 +185,34 @@ class Grids implements ActionsInterface $GridActionNew->setType(DataGridActionType::NEW_ITEM); $GridActionNew->setName(_('Nuevo Cliente')); $GridActionNew->setTitle(_('Nuevo Cliente')); - $GridActionNew->setIcon($this->_icons->getIconAdd()); + $GridActionNew->setIcon($this->icons->getIconAdd()); $GridActionNew->setSkip(true); $GridActionNew->setOnClickFunction('sysPassUtil.Common.appMgmtData'); $GridActionNew->setOnClickArgs('this'); $GridActionNew->setOnClickArgs(self::ACTION_MGM_CUSTOMERS_NEW); - $GridActionNew->setOnClickArgs($this->_sk); + $GridActionNew->setOnClickArgs($this->sk); $GridActionEdit = new DataGridAction(); $GridActionEdit->setId(self::ACTION_MGM_CUSTOMERS_EDIT); $GridActionEdit->setType(DataGridActionType::EDIT_ITEM); $GridActionEdit->setName(_('Editar Cliente')); $GridActionEdit->setTitle(_('Editar Cliente')); - $GridActionEdit->setIcon($this->_icons->getIconEdit()); + $GridActionEdit->setIcon($this->icons->getIconEdit()); $GridActionEdit->setOnClickFunction('sysPassUtil.Common.appMgmtData'); $GridActionEdit->setOnClickArgs('this'); $GridActionEdit->setOnClickArgs(self::ACTION_MGM_CUSTOMERS_EDIT); - $GridActionEdit->setOnClickArgs($this->_sk); + $GridActionEdit->setOnClickArgs($this->sk); $GridActionDel = new DataGridAction(); $GridActionDel->setId(self::ACTION_MGM_CUSTOMERS_DELETE); $GridActionDel->setType(DataGridActionType::DELETE_ITEM); $GridActionDel->setName(_('Eliminar Cliente')); $GridActionDel->setTitle(_('Eliminar Cliente')); - $GridActionDel->setIcon($this->_icons->getIconDelete()); + $GridActionDel->setIcon($this->icons->getIconDelete()); $GridActionDel->setOnClickFunction('sysPassUtil.Common.appMgmtDelete'); $GridActionDel->setOnClickArgs('this'); $GridActionDel->setOnClickArgs(self::ACTION_MGM_CUSTOMERS_DELETE); - $GridActionDel->setOnClickArgs($this->_sk); + $GridActionDel->setOnClickArgs($this->sk); $GridHeaders = new DataGridHeader(); $GridHeaders->addHeader(_('Nombre')); @@ -235,7 +235,7 @@ class Grids implements ActionsInterface $Grid->setPager($this->getPager($GridActionSearch)); $Grid->setData($GridData); $Grid->setTitle(_('Gestión de Clientes')); - $Grid->setTime(round(microtime() - $this->_queryTimeStart, 5)); + $Grid->setTime(round(microtime() - $this->queryTimeStart, 5)); return $Grid; } @@ -258,34 +258,34 @@ class Grids implements ActionsInterface $GridActionNew->setType(DataGridActionType::NEW_ITEM); $GridActionNew->setName(_('Nuevo Campo')); $GridActionNew->setTitle(_('Nuevo Campo')); - $GridActionNew->setIcon($this->_icons->getIconAdd()); + $GridActionNew->setIcon($this->icons->getIconAdd()); $GridActionNew->setSkip(true); $GridActionNew->setOnClickFunction('sysPassUtil.Common.appMgmtData'); $GridActionNew->setOnClickArgs('this'); $GridActionNew->setOnClickArgs(self::ACTION_MGM_CUSTOMFIELDS_NEW); - $GridActionNew->setOnClickArgs($this->_sk); + $GridActionNew->setOnClickArgs($this->sk); $GridActionEdit = new DataGridAction(); $GridActionEdit->setId(self::ACTION_MGM_CUSTOMFIELDS_EDIT); $GridActionEdit->setType(DataGridActionType::EDIT_ITEM); $GridActionEdit->setName(_('Editar Campo')); $GridActionEdit->setTitle(_('Editar Campo')); - $GridActionEdit->setIcon($this->_icons->getIconEdit()); + $GridActionEdit->setIcon($this->icons->getIconEdit()); $GridActionEdit->setOnClickFunction('sysPassUtil.Common.appMgmtData'); $GridActionEdit->setOnClickArgs('this'); $GridActionEdit->setOnClickArgs(self::ACTION_MGM_CUSTOMFIELDS_EDIT); - $GridActionEdit->setOnClickArgs($this->_sk); + $GridActionEdit->setOnClickArgs($this->sk); $GridActionDel = new DataGridAction(); $GridActionDel->setId(self::ACTION_MGM_CUSTOMFIELDS_DELETE); $GridActionDel->setType(DataGridActionType::DELETE_ITEM); $GridActionDel->setName(_('Eliminar Campo')); $GridActionDel->setTitle(_('Eliminar Campo')); - $GridActionDel->setIcon($this->_icons->getIconDelete()); + $GridActionDel->setIcon($this->icons->getIconDelete()); $GridActionDel->setOnClickFunction('sysPassUtil.Common.appMgmtDelete'); $GridActionDel->setOnClickArgs('this'); $GridActionDel->setOnClickArgs(self::ACTION_MGM_CUSTOMFIELDS_DELETE); - $GridActionDel->setOnClickArgs($this->_sk); + $GridActionDel->setOnClickArgs($this->sk); $GridHeaders = new DataGridHeader(); $GridHeaders->addHeader(_('Módulo')); @@ -310,7 +310,7 @@ class Grids implements ActionsInterface $Grid->setPager($this->getPager($GridActionSearch)); $Grid->setData($GridData); $Grid->setTitle(_('Campos Personalizados')); - $Grid->setTime(round(microtime() - $this->_queryTimeStart, 5)); + $Grid->setTime(round(microtime() - $this->queryTimeStart, 5)); return $Grid; } @@ -332,21 +332,21 @@ class Grids implements ActionsInterface $GridActionView->setId(self::ACTION_MGM_FILES_VIEW); $GridActionView->setType(DataGridActionType::VIEW_ITEM); $GridActionView->setName(_('Ver Archivo')); - $GridActionView->setIcon($this->_icons->getIconView()); + $GridActionView->setIcon($this->icons->getIconView()); $GridActionView->setOnClickFunction('sysPassUtil.Common.viewFile'); $GridActionView->setOnClickArgs('this'); $GridActionView->setOnClickArgs(self::ACTION_MGM_FILES_VIEW); - $GridActionView->setOnClickArgs($this->_sk); + $GridActionView->setOnClickArgs($this->sk); $GridActionDel = new DataGridAction(); $GridActionDel->setId(self::ACTION_MGM_FILES_DELETE); $GridActionDel->setType(DataGridActionType::DELETE_ITEM); $GridActionDel->setName(_('Eliminar Archivo')); - $GridActionDel->setIcon($this->_icons->getIconDelete()); + $GridActionDel->setIcon($this->icons->getIconDelete()); $GridActionDel->setOnClickFunction('sysPassUtil.Common.appMgmtDelete'); $GridActionDel->setOnClickArgs('this'); $GridActionDel->setOnClickArgs(self::ACTION_MGM_FILES_DELETE); - $GridActionDel->setOnClickArgs($this->_sk); + $GridActionDel->setOnClickArgs($this->sk); $GridHeaders = new DataGridHeader(); $GridHeaders->addHeader(_('Cuenta')); @@ -374,7 +374,7 @@ class Grids implements ActionsInterface $Grid->setPager($this->getPager($GridActionSearch)); $Grid->setData($GridData); $Grid->setTitle(_('Gestión de Archivos')); - $Grid->setTime(round(microtime() - $this->_queryTimeStart, 5)); + $Grid->setTime(round(microtime() - $this->queryTimeStart, 5)); return $Grid; } @@ -397,11 +397,11 @@ class Grids implements ActionsInterface $GridActionDel->setType(DataGridActionType::DELETE_ITEM); $GridActionDel->setName(_('Eliminar Cuenta')); $GridActionDel->setTitle(_('Eliminar Cuenta')); - $GridActionDel->setIcon($this->_icons->getIconDelete()); + $GridActionDel->setIcon($this->icons->getIconDelete()); $GridActionDel->setOnClickFunction('sysPassUtil.Common.appMgmtDelete'); $GridActionDel->setOnClickArgs('this'); $GridActionDel->setOnClickArgs(self::ACTION_MGM_ACCOUNTS_DELETE); - $GridActionDel->setOnClickArgs($this->_sk); + $GridActionDel->setOnClickArgs($this->sk); $GridHeaders = new DataGridHeader(); $GridHeaders->addHeader(_('Nombre')); @@ -422,7 +422,7 @@ class Grids implements ActionsInterface $Grid->setPager($this->getPager($GridActionSearch)); $Grid->setData($GridData); $Grid->setTitle(_('Gestión de Cuentas')); - $Grid->setTime(round(microtime() - $this->_queryTimeStart, 5)); + $Grid->setTime(round(microtime() - $this->queryTimeStart, 5)); return $Grid; } @@ -445,56 +445,56 @@ class Grids implements ActionsInterface $GridActionNew->setType(DataGridActionType::NEW_ITEM); $GridActionNew->setName(_('Nuevo Usuario')); $GridActionNew->setTitle(_('Nuevo Usuario')); - $GridActionNew->setIcon($this->_icons->getIconAdd()); + $GridActionNew->setIcon($this->icons->getIconAdd()); $GridActionNew->setSkip(true); $GridActionNew->setOnClickFunction('sysPassUtil.Common.appMgmtData'); $GridActionNew->setOnClickArgs('this'); $GridActionNew->setOnClickArgs(self::ACTION_USR_USERS_NEW); - $GridActionNew->setOnClickArgs($this->_sk); + $GridActionNew->setOnClickArgs($this->sk); $GridActionView = new DataGridAction(); $GridActionView->setId(self::ACTION_USR_USERS_VIEW); $GridActionView->setType(DataGridActionType::VIEW_ITEM); $GridActionView->setName(_('Ver Detalles de Usuario')); $GridActionView->setTitle(_('Ver Detalles de Usuario')); - $GridActionView->setIcon($this->_icons->getIconView()); + $GridActionView->setIcon($this->icons->getIconView()); $GridActionView->setOnClickFunction('sysPassUtil.Common.appMgmtData'); $GridActionView->setOnClickArgs('this'); $GridActionView->setOnClickArgs(self::ACTION_USR_USERS_VIEW); - $GridActionView->setOnClickArgs($this->_sk); + $GridActionView->setOnClickArgs($this->sk); $GridActionEdit = new DataGridAction(); $GridActionEdit->setId(self::ACTION_USR_USERS_EDIT); $GridActionEdit->setType(DataGridActionType::EDIT_ITEM); $GridActionEdit->setName(_('Editar Usuario')); $GridActionEdit->setTitle(_('Editar Usuario')); - $GridActionEdit->setIcon($this->_icons->getIconEdit()); + $GridActionEdit->setIcon($this->icons->getIconEdit()); $GridActionEdit->setOnClickFunction('sysPassUtil.Common.appMgmtData'); $GridActionEdit->setOnClickArgs('this'); $GridActionEdit->setOnClickArgs(self::ACTION_USR_USERS_EDIT); - $GridActionEdit->setOnClickArgs($this->_sk); + $GridActionEdit->setOnClickArgs($this->sk); $GridActionDel = new DataGridAction(); $GridActionDel->setId(self::ACTION_USR_USERS_DELETE); $GridActionDel->setType(DataGridActionType::DELETE_ITEM); $GridActionDel->setName(_('Eliminar Usuario')); $GridActionDel->setTitle(_('Eliminar Usuario')); - $GridActionDel->setIcon($this->_icons->getIconDelete()); + $GridActionDel->setIcon($this->icons->getIconDelete()); $GridActionDel->setOnClickFunction('sysPassUtil.Common.appMgmtDelete'); $GridActionDel->setOnClickArgs('this'); $GridActionDel->setOnClickArgs(self::ACTION_USR_USERS_DELETE); - $GridActionDel->setOnClickArgs($this->_sk); + $GridActionDel->setOnClickArgs($this->sk); $GridActionEditPass = new DataGridAction(); $GridActionEditPass->setId(self::ACTION_USR_USERS_EDITPASS); $GridActionEditPass->setType(DataGridActionType::EDIT_ITEM); $GridActionEditPass->setName(_('Cambiar Clave de Usuario')); $GridActionEditPass->setTitle(_('Cambiar Clave de Usuario')); - $GridActionEditPass->setIcon($this->_icons->getIconEditPass()); + $GridActionEditPass->setIcon($this->icons->getIconEditPass()); $GridActionEditPass->setOnClickFunction('sysPassUtil.Common.usrUpdPass'); $GridActionEditPass->setOnClickArgs('this'); $GridActionEditPass->setOnClickArgs(self::ACTION_USR_USERS_EDITPASS); - $GridActionEditPass->setOnClickArgs($this->_sk); + $GridActionEditPass->setOnClickArgs($this->sk); $GridActionEditPass->setFilterRowSource('user_isLdap'); $GridHeaders = new DataGridHeader(); @@ -510,10 +510,10 @@ class Grids implements ActionsInterface $GridData->addDataRowSource('user_login'); $GridData->addDataRowSource('userprofile_name'); $GridData->addDataRowSource('usergroup_name'); - $GridData->addDataRowSourceWithIcon('user_isAdminApp', $this->_icons->getIconAppAdmin()); - $GridData->addDataRowSourceWithIcon('user_isAdminAcc', $this->_icons->getIconAccAdmin()); - $GridData->addDataRowSourceWithIcon('user_isLdap', $this->_icons->getIconLdapUser()); - $GridData->addDataRowSourceWithIcon('user_isDisabled', $this->_icons->getIconDisabled()); + $GridData->addDataRowSourceWithIcon('user_isAdminApp', $this->icons->getIconAppAdmin()); + $GridData->addDataRowSourceWithIcon('user_isAdminAcc', $this->icons->getIconAccAdmin()); + $GridData->addDataRowSourceWithIcon('user_isLdap', $this->icons->getIconLdapUser()); + $GridData->addDataRowSourceWithIcon('user_isDisabled', $this->icons->getIconDisabled()); $Grid = new DataGridTab(); $Grid->setId('tblUsers'); @@ -529,7 +529,7 @@ class Grids implements ActionsInterface $Grid->setPager($this->getPager($GridActionSearch)); $Grid->setData($GridData); $Grid->setTitle(_('Gestión de Usuarios')); - $Grid->setTime(round(microtime() - $this->_queryTimeStart, 5)); + $Grid->setTime(round(microtime() - $this->queryTimeStart, 5)); return $Grid; } @@ -552,34 +552,34 @@ class Grids implements ActionsInterface $GridActionNew->setType(DataGridActionType::NEW_ITEM); $GridActionNew->setName(_('Nuevo Grupo')); $GridActionNew->setTitle(_('Nuevo Grupo')); - $GridActionNew->setIcon($this->_icons->getIconAdd()); + $GridActionNew->setIcon($this->icons->getIconAdd()); $GridActionNew->setSkip(true); $GridActionNew->setOnClickFunction('sysPassUtil.Common.appMgmtData'); $GridActionNew->setOnClickArgs('this'); $GridActionNew->setOnClickArgs(self::ACTION_USR_GROUPS_NEW); - $GridActionNew->setOnClickArgs($this->_sk); + $GridActionNew->setOnClickArgs($this->sk); $GridActionEdit = new DataGridAction(); $GridActionEdit->setId(self::ACTION_USR_GROUPS_EDIT); $GridActionEdit->setType(DataGridActionType::EDIT_ITEM); $GridActionEdit->setName(_('Editar Grupo')); $GridActionEdit->setTitle(_('Editar Grupo')); - $GridActionEdit->setIcon($this->_icons->getIconEdit()); + $GridActionEdit->setIcon($this->icons->getIconEdit()); $GridActionEdit->setOnClickFunction('sysPassUtil.Common.appMgmtData'); $GridActionEdit->setOnClickArgs('this'); $GridActionEdit->setOnClickArgs(self::ACTION_USR_GROUPS_EDIT); - $GridActionEdit->setOnClickArgs($this->_sk); + $GridActionEdit->setOnClickArgs($this->sk); $GridActionDel = new DataGridAction(); $GridActionDel->setId(self::ACTION_USR_GROUPS_DELETE); $GridActionDel->setType(DataGridActionType::DELETE_ITEM); $GridActionDel->setName(_('Eliminar Grupo')); $GridActionDel->setTitle(_('Eliminar Grupo')); - $GridActionDel->setIcon($this->_icons->getIconDelete()); + $GridActionDel->setIcon($this->icons->getIconDelete()); $GridActionDel->setOnClickFunction('sysPassUtil.Common.appMgmtDelete'); $GridActionDel->setOnClickArgs('this'); $GridActionDel->setOnClickArgs(self::ACTION_USR_GROUPS_DELETE); - $GridActionDel->setOnClickArgs($this->_sk); + $GridActionDel->setOnClickArgs($this->sk); $GridHeaders = new DataGridHeader(); $GridHeaders->addHeader(_('Nombre')); @@ -602,7 +602,7 @@ class Grids implements ActionsInterface $Grid->setPager($this->getPager($GridActionSearch)); $Grid->setData($GridData); $Grid->setTitle(_('Gestión de Grupos')); - $Grid->setTime(round(microtime() - $this->_queryTimeStart, 5)); + $Grid->setTime(round(microtime() - $this->queryTimeStart, 5)); return $Grid; } @@ -625,45 +625,45 @@ class Grids implements ActionsInterface $GridActionNew->setType(DataGridActionType::NEW_ITEM); $GridActionNew->setName(_('Nuevo Perfil')); $GridActionNew->setTitle(_('Nuevo Perfil')); - $GridActionNew->setIcon($this->_icons->getIconAdd()); + $GridActionNew->setIcon($this->icons->getIconAdd()); $GridActionNew->setSkip(true); $GridActionNew->setOnClickFunction('sysPassUtil.Common.appMgmtData'); $GridActionNew->setOnClickArgs('this'); $GridActionNew->setOnClickArgs(self::ACTION_USR_PROFILES_NEW); - $GridActionNew->setOnClickArgs($this->_sk); + $GridActionNew->setOnClickArgs($this->sk); $GridActionView = new DataGridAction(); $GridActionView->setId(self::ACTION_USR_PROFILES_VIEW); $GridActionView->setType(DataGridActionType::VIEW_ITEM); $GridActionView->setName(_('Ver Detalles de Perfil')); $GridActionView->setTitle(_('Ver Detalles de Perfil')); - $GridActionView->setIcon($this->_icons->getIconView()); + $GridActionView->setIcon($this->icons->getIconView()); $GridActionView->setOnClickFunction('sysPassUtil.Common.appMgmtData'); $GridActionView->setOnClickArgs('this'); $GridActionView->setOnClickArgs(self::ACTION_USR_PROFILES_VIEW); - $GridActionView->setOnClickArgs($this->_sk); + $GridActionView->setOnClickArgs($this->sk); $GridActionEdit = new DataGridAction(); $GridActionEdit->setId(self::ACTION_USR_PROFILES_EDIT); $GridActionEdit->setType(DataGridActionType::EDIT_ITEM); $GridActionEdit->setName(_('Editar Perfil')); $GridActionEdit->setTitle(_('Editar Perfil')); - $GridActionEdit->setIcon($this->_icons->getIconEdit()); + $GridActionEdit->setIcon($this->icons->getIconEdit()); $GridActionEdit->setOnClickFunction('sysPassUtil.Common.appMgmtData'); $GridActionEdit->setOnClickArgs('this'); $GridActionEdit->setOnClickArgs(self::ACTION_USR_PROFILES_EDIT); - $GridActionEdit->setOnClickArgs($this->_sk); + $GridActionEdit->setOnClickArgs($this->sk); $GridActionDel = new DataGridAction(); $GridActionDel->setId(self::ACTION_USR_PROFILES_DELETE); $GridActionDel->setType(DataGridActionType::DELETE_ITEM); $GridActionDel->setName(_('Eliminar Perfil')); $GridActionDel->setTitle(_('Eliminar Perfil')); - $GridActionDel->setIcon($this->_icons->getIconDelete()); + $GridActionDel->setIcon($this->icons->getIconDelete()); $GridActionDel->setOnClickFunction('sysPassUtil.Common.appMgmtDelete'); $GridActionDel->setOnClickArgs('this'); $GridActionDel->setOnClickArgs(self::ACTION_USR_PROFILES_DELETE); - $GridActionDel->setOnClickArgs($this->_sk); + $GridActionDel->setOnClickArgs($this->sk); $GridHeaders = new DataGridHeader(); $GridHeaders->addHeader(_('Nombre')); @@ -685,7 +685,7 @@ class Grids implements ActionsInterface $Grid->setPager($this->getPager($GridActionSearch)); $Grid->setData($GridData); $Grid->setTitle(_('Gestión de Perfiles')); - $Grid->setTime(round(microtime() - $this->_queryTimeStart, 5)); + $Grid->setTime(round(microtime() - $this->queryTimeStart, 5)); return $Grid; } @@ -708,45 +708,45 @@ class Grids implements ActionsInterface $GridActionNew->setType(DataGridActionType::NEW_ITEM); $GridActionNew->setName(_('Nueva Autorización')); $GridActionNew->setTitle(_('Nueva Autorización')); - $GridActionNew->setIcon($this->_icons->getIconAdd()); + $GridActionNew->setIcon($this->icons->getIconAdd()); $GridActionNew->setSkip(true); $GridActionNew->setOnClickFunction('sysPassUtil.Common.appMgmtData'); $GridActionNew->setOnClickArgs('this'); $GridActionNew->setOnClickArgs(self::ACTION_MGM_APITOKENS_NEW); - $GridActionNew->setOnClickArgs($this->_sk); + $GridActionNew->setOnClickArgs($this->sk); $GridActionView = new DataGridAction(); $GridActionView->setId(self::ACTION_MGM_APITOKENS_VIEW); $GridActionView->setType(DataGridActionType::VIEW_ITEM); $GridActionView->setName(_('Ver token de Autorización')); $GridActionView->setTitle(_('Ver token de Autorización')); - $GridActionView->setIcon($this->_icons->getIconView()); + $GridActionView->setIcon($this->icons->getIconView()); $GridActionView->setOnClickFunction('sysPassUtil.Common.appMgmtData'); $GridActionView->setOnClickArgs('this'); $GridActionView->setOnClickArgs(self::ACTION_MGM_APITOKENS_VIEW); - $GridActionView->setOnClickArgs($this->_sk); + $GridActionView->setOnClickArgs($this->sk); $GridActionEdit = new DataGridAction(); $GridActionEdit->setId(self::ACTION_MGM_APITOKENS_EDIT); $GridActionEdit->setType(DataGridActionType::EDIT_ITEM); $GridActionEdit->setName(_('Editar Autorización')); $GridActionEdit->setTitle(_('Editar Autorización')); - $GridActionEdit->setIcon($this->_icons->getIconEdit()); + $GridActionEdit->setIcon($this->icons->getIconEdit()); $GridActionEdit->setOnClickFunction('sysPassUtil.Common.appMgmtData'); $GridActionEdit->setOnClickArgs('this'); $GridActionEdit->setOnClickArgs(self::ACTION_MGM_APITOKENS_EDIT); - $GridActionEdit->setOnClickArgs($this->_sk); + $GridActionEdit->setOnClickArgs($this->sk); $GridActionDel = new DataGridAction(); $GridActionDel->setId(self::ACTION_MGM_APITOKENS_DELETE); $GridActionDel->setType(DataGridActionType::DELETE_ITEM); $GridActionDel->setName(_('Eliminar Autorización')); $GridActionDel->setTitle(_('Eliminar Autorización')); - $GridActionDel->setIcon($this->_icons->getIconDelete()); + $GridActionDel->setIcon($this->icons->getIconDelete()); $GridActionDel->setOnClickFunction('sysPassUtil.Common.appMgmtDelete'); $GridActionDel->setOnClickArgs('this'); $GridActionDel->setOnClickArgs(self::ACTION_MGM_APITOKENS_DELETE); - $GridActionDel->setOnClickArgs($this->_sk); + $GridActionDel->setOnClickArgs($this->sk); $GridHeaders = new DataGridHeader(); $GridHeaders->addHeader(_('Usuario')); @@ -770,7 +770,7 @@ class Grids implements ActionsInterface $Grid->setPager($this->getPager($GridActionSearch)); $Grid->setData($GridData); $Grid->setTitle(_('Gestión de Autorizaciones API')); - $Grid->setTime(round(microtime() - $this->_queryTimeStart, 5)); + $Grid->setTime(round(microtime() - $this->queryTimeStart, 5)); return $Grid; } @@ -793,32 +793,32 @@ class Grids implements ActionsInterface $GridActionView->setType(DataGridActionType::VIEW_ITEM); $GridActionView->setName(_('Ver Enlace')); $GridActionView->setTitle(_('Ver Enlace')); - $GridActionView->setIcon($this->_icons->getIconView()); + $GridActionView->setIcon($this->icons->getIconView()); $GridActionView->setOnClickFunction('sysPassUtil.Common.appMgmtData'); $GridActionView->setOnClickArgs('this'); $GridActionView->setOnClickArgs(self::ACTION_MGM_PUBLICLINKS_VIEW); - $GridActionView->setOnClickArgs($this->_sk); + $GridActionView->setOnClickArgs($this->sk); $GridActionRefresh = new DataGridAction(); $GridActionRefresh->setId(self::ACTION_MGM_PUBLICLINKS_REFRESH); $GridActionRefresh->setName(_('Renovar Enlace')); $GridActionRefresh->setTitle(_('Renovar Enlace')); - $GridActionRefresh->setIcon($this->_icons->getIconRefresh()); + $GridActionRefresh->setIcon($this->icons->getIconRefresh()); $GridActionRefresh->setOnClickFunction('sysPassUtil.Common.linksMgmtRefresh'); $GridActionRefresh->setOnClickArgs('this'); $GridActionRefresh->setOnClickArgs(self::ACTION_MGM_PUBLICLINKS_REFRESH); - $GridActionRefresh->setOnClickArgs($this->_sk); + $GridActionRefresh->setOnClickArgs($this->sk); $GridActionDel = new DataGridAction(); $GridActionDel->setId(self::ACTION_MGM_PUBLICLINKS_DELETE); $GridActionDel->setType(DataGridActionType::DELETE_ITEM); $GridActionDel->setName(_('Eliminar Enlace')); $GridActionDel->setTitle(_('Eliminar Enlace')); - $GridActionDel->setIcon($this->_icons->getIconDelete()); + $GridActionDel->setIcon($this->icons->getIconDelete()); $GridActionDel->setOnClickFunction('sysPassUtil.Common.appMgmtDelete'); $GridActionDel->setOnClickArgs('this'); $GridActionDel->setOnClickArgs(self::ACTION_MGM_PUBLICLINKS_DELETE); - $GridActionDel->setOnClickArgs($this->_sk); + $GridActionDel->setOnClickArgs($this->sk); $GridHeaders = new DataGridHeader(); $GridHeaders->addHeader(_('Cuenta')); @@ -849,7 +849,7 @@ class Grids implements ActionsInterface $Grid->setPager($this->getPager($GridActionSearch)); $Grid->setData($GridData); $Grid->setTitle(_('Gestión de Enlaces')); - $Grid->setTime(round(microtime() - $this->_queryTimeStart, 5)); + $Grid->setTime(round(microtime() - $this->queryTimeStart, 5)); return $Grid; } @@ -858,7 +858,7 @@ class Grids implements ActionsInterface */ public function setFilter($filter) { - $this->_filter = $filter; + $this->filter = $filter; } /** @@ -866,6 +866,6 @@ class Grids implements ActionsInterface */ public function setQueryTimeStart($queryTimeStart) { - $this->_queryTimeStart = $queryTimeStart; + $this->queryTimeStart = $queryTimeStart; } } \ No newline at end of file diff --git a/inc/SP/Controller/Main.class.php b/inc/SP/Controller/Main.class.php index 637b2e9b..ceeb019b 100644 --- a/inc/SP/Controller/Main.class.php +++ b/inc/SP/Controller/Main.class.php @@ -307,10 +307,10 @@ class Main extends Controller implements ActionsInterface Installer::setUsername($this->view->adminlogin); Installer::setPassword($this->view->adminpass); Installer::setMasterPassword($this->view->masterpassword); - Installer::setDbuser($this->view->dbuser); - Installer::setDbpass($this->view->dbpass); - Installer::setDbname($this->view->dbname); - Installer::setDbhost($this->view->dbhost); + Installer::setDbUser($this->view->dbuser); + Installer::setDbPass($this->view->dbpass); + Installer::setDbName($this->view->dbname); + Installer::setDbHost($this->view->dbhost); Installer::setIsHostingMode($this->view->hostingmode); $this->view->assign('resInstall', Installer::install()); diff --git a/inc/SP/Controller/UsersPrefs.class.php b/inc/SP/Controller/UsersPrefs.class.php index 9b6b6777..71963477 100644 --- a/inc/SP/Controller/UsersPrefs.class.php +++ b/inc/SP/Controller/UsersPrefs.class.php @@ -28,6 +28,7 @@ namespace SP\Controller; defined('APP_ROOT') || die(_('No es posible acceder directamente a este archivo')); use SP\Auth\Auth2FA; +use SP\Config\Config; use SP\Core\ActionsInterface; use SP\Core\Language; use SP\Core\Session; @@ -46,15 +47,15 @@ class UsersPrefs extends Controller implements ActionsInterface /** * @var int */ - private $_tabIndex = 0; + private $tabIndex = 0; /** * @var UserPreferences */ - private $_userPrefs; + private $userPrefs; /** * @var int */ - private $_userId; + private $userId; /** @@ -68,8 +69,8 @@ class UsersPrefs extends Controller implements ActionsInterface $this->view->assign('tabs', array()); $this->view->assign('sk', SessionUtil::getSessionKey(true)); - $this->_userId = Session::getUserId(); - $this->_userPrefs = UserPreferences::getPreferences($this->_userId); + $this->userId = Session::getUserId(); + $this->userPrefs = UserPreferences::getPreferences($this->userId); } /** @@ -82,14 +83,14 @@ class UsersPrefs extends Controller implements ActionsInterface $this->view->addTemplate('preferences-security'); - $twoFa = new Auth2FA($this->_userId, Session::getUserLogin()); + $twoFa = new Auth2FA($this->userId, Session::getUserLogin()); - if (!$this->_userPrefs->isUse2Fa()) { + if (!$this->userPrefs->isUse2Fa()) { $this->view->assign('qrCode', $twoFa->getUserQRCode()); } - $this->view->assign('userId', $this->_userId); - $this->view->assign('chk2FAEnabled', $this->_userPrefs->isUse2Fa()); + $this->view->assign('userId', $this->userId); + $this->view->assign('chk2FAEnabled', $this->userPrefs->isUse2Fa()); $this->view->append('tabs', array('title' => _('Seguridad'))); $this->view->assign('tabIndex', $this->getTabIndex(), 'security'); @@ -103,8 +104,8 @@ class UsersPrefs extends Controller implements ActionsInterface */ private function getTabIndex() { - $index = $this->_tabIndex; - $this->_tabIndex++; + $index = $this->tabIndex; + $this->tabIndex++; return $index; } @@ -118,16 +119,16 @@ class UsersPrefs extends Controller implements ActionsInterface $this->view->addTemplate('preferences-site'); - $this->view->assign('userId', $this->_userId); + $this->view->assign('userId', $this->userId); $this->view->assign('langsAvailable', Language::getAvailableLanguages()); - $this->view->assign('currentLang', $this->_userPrefs->getLang()); + $this->view->assign('currentLang', $this->userPrefs->getLang()); $this->view->assign('themesAvailable', Themes::getThemesAvailable()); - $this->view->assign('currentTheme', ($this->_userPrefs->getTheme()) ? $this->_userPrefs->getTheme() : \SP\Config\Config::getValue('sitetheme')); - $this->view->assign('chkAccountLink', ($this->_userPrefs->isAccountLink()) ? 'checked="checked"' : ''); - $this->view->assign('resultsPerPage', ($this->_userPrefs->getResultsPerPage()) ? $this->_userPrefs->getResultsPerPage() : \SP\Config\Config::getValue('account_count')); - $this->view->assign('chkSortViews', ($this->_userPrefs->isSortViews()) ? 'checked="checked"' : ''); - $this->view->assign('chkTopNavbar', ($this->_userPrefs->isTopNavbar()) ? 'checked="checked"' : ''); - $this->view->assign('chkOptionalActions', ($this->_userPrefs->isOptionalActions()) ? 'checked="checked"' : ''); + $this->view->assign('currentTheme', ($this->userPrefs->getTheme()) ? $this->userPrefs->getTheme() : Config::getConfig()->getSiteTheme()); + $this->view->assign('chkAccountLink', ($this->userPrefs->isAccountLink()) ? 'checked="checked"' : ''); + $this->view->assign('resultsPerPage', ($this->userPrefs->getResultsPerPage()) ? $this->userPrefs->getResultsPerPage() : Config::getConfig()->getAccountCount()); + $this->view->assign('chkSortViews', ($this->userPrefs->isSortViews()) ? 'checked="checked"' : ''); + $this->view->assign('chkTopNavbar', ($this->userPrefs->isTopNavbar()) ? 'checked="checked"' : ''); + $this->view->assign('chkOptionalActions', ($this->userPrefs->isOptionalActions()) ? 'checked="checked"' : ''); $this->view->append('tabs', array('title' => _('Preferencias'))); $this->view->assign('tabIndex', $this->getTabIndex(), 'preferences'); diff --git a/inc/SP/Controller/Wiki.class.php b/inc/SP/Controller/Wiki.class.php index fedfc410..13f7a122 100644 --- a/inc/SP/Controller/Wiki.class.php +++ b/inc/SP/Controller/Wiki.class.php @@ -70,7 +70,7 @@ class Wiki extends Controller implements ActionsInterface $pageInfo = ''; $headerData = ''; $pageSearch = ''; - $wikiUrlBase = Config::getValue('dokuwiki_urlbase'); + $wikiUrlBase = Config::getConfig()->getDokuwikiUrlBase(); try { $DokuWikiApi = new DokuWikiApi(); diff --git a/inc/SP/Core/Backup.class.php b/inc/SP/Core/Backup.class.php index 16f766b5..82d7986e 100644 --- a/inc/SP/Core/Backup.class.php +++ b/inc/SP/Core/Backup.class.php @@ -55,7 +55,8 @@ class Backup // Generar hash unico para evitar descargas no permitidas $backupUniqueHash = uniqid(); - Config::setValue('backup_hash', $backupUniqueHash); + Config::getConfig()->setBackupHash($backupUniqueHash); + Config::saveConfig(); $backupDstDir = $backupDir . DIRECTORY_SEPARATOR . 'backup'; $bakFileApp = $backupDstDir . DIRECTORY_SEPARATOR . $siteName . '-' . $backupUniqueHash . '.tar'; @@ -95,7 +96,7 @@ class Backup */ private static function backupTables($tables = '*', $backupFile) { - $dbname = Config::getValue("dbname"); + $dbname = Config::getConfig()->getDbName(); try { $handle = fopen($backupFile, 'w'); diff --git a/inc/SP/Core/Crypt.class.php b/inc/SP/Core/Crypt.class.php index 5f01b825..bb8c84c0 100644 --- a/inc/SP/Core/Crypt.class.php +++ b/inc/SP/Core/Crypt.class.php @@ -276,7 +276,7 @@ class Crypt public static function generateAesKey($string, $salt = null) { if (is_null($salt)) { - $salt = Config::getValue('passwordsalt'); + $salt = Config::getConfig()->getPasswordSalt(); } $salt = '$2y$07$' . $salt . '$'; diff --git a/inc/SP/Core/Factory.class.php b/inc/SP/Core/Factory.class.php new file mode 100644 index 00000000..78660bfb --- /dev/null +++ b/inc/SP/Core/Factory.class.php @@ -0,0 +1,75 @@ +. + * + */ + +namespace SP\Core; + +use SP\Storage\MySQLHandler; +use SP\Storage\DBStorageInterface; +use SP\Storage\FileStorageInterface; +use SP\Storage\XmlHandler; + +/** + * Class Factory + * + * @package SP\Core + */ +class Factory +{ + /** + * @var FileStorageInterface + */ + private static $configFactory; + /** + * @var DBStorageInterface + */ + private static $DBFactory; + + /** + * Devuelve el almacenamiento para la configuración + * + * @return FileStorageInterface + */ + public static function getConfigStorage(){ + if (!self::$configFactory instanceof FileStorageInterface) { + self::$configFactory = new XmlHandler(XML_CONFIG_FILE); + } + + return self::$configFactory; + } + + /** + * Devuelve el manejador para la BD + * + * @return DBStorageInterface + */ + public static function getDBStorage() + { + if (!self::$DBFactory instanceof DBStorageInterface) { + self::$DBFactory = new MySQLHandler(); + } + + return self::$DBFactory; + } +} \ No newline at end of file diff --git a/inc/SP/Core/Init.class.php b/inc/SP/Core/Init.class.php index ff722381..c1ead1c7 100644 --- a/inc/SP/Core/Init.class.php +++ b/inc/SP/Core/Init.class.php @@ -74,7 +74,14 @@ class Init /** * @var string */ - private static $_SUBURI = ''; + private static $SUBURI = ''; + /** + * Estado de la BD + * 0 - Fail + * 1 - OK + * @var int + */ + public static $DB_STATUS = 1; /** * Inicializar la aplicación. @@ -107,6 +114,9 @@ class Init // Establecer las rutas de la aplicación self::setPaths(); + // Cargar la configuración + self::loadConfig(); + // Cargar el lenguaje Language::setLanguage(); @@ -121,9 +131,6 @@ class Init return; } - // Comprobar la configuración - self::checkConfig(); - // Comprobar si está instalado self::checkInstalled(); @@ -139,7 +146,7 @@ class Init self::checkLogout(); // Comprobar la versión y actualizarla - self::checkVersion(); + self::checkDbVersion(); // Inicializar la sesión self::initSession(); @@ -148,11 +155,9 @@ class Init self::checkPreLoginActions(); // Intentar establecer el tiempo de vida de la sesión en PHP - $sessionLifeTime = self::getSessionLifeTime(); + @ini_set('gc_maxlifetime', self::getSessionLifeTime()); - @ini_set('gc_maxlifetime', $sessionLifeTime); - - if (!Config::getValue("installed", false)) { + if (!Config::getConfig()->isInstalled()) { Session::setUserId(''); } @@ -175,7 +180,7 @@ class Init // Volver a cargar la configuración si se recarga la página if (Request::checkReload()) { - Config::readConfig(); + Config::loadConfig(); // Restablecer el idioma y el tema visual Language::setLanguage(); @@ -297,22 +302,22 @@ class Init self::$SERVERROOT = substr($dir, 0, strripos($dir, DIRECTORY_SEPARATOR)); - self::$_SUBURI = str_replace("\\", '/', substr(realpath($_SERVER["SCRIPT_FILENAME"]), strlen(self::$SERVERROOT))); + self::$SUBURI = str_replace("\\", '/', substr(realpath($_SERVER["SCRIPT_FILENAME"]), strlen(self::$SERVERROOT))); $scriptName = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : ''; if (substr($scriptName, -1) == '/') { $scriptName .= 'index.php'; // Asegurar que suburi sigue las mismas reglas que scriptName - if (substr(self::$_SUBURI, -9) != 'index.php') { - if (substr(self::$_SUBURI, -1) != '/') { - self::$_SUBURI .= '/'; + if (substr(self::$SUBURI, -9) != 'index.php') { + if (substr(self::$SUBURI, -1) != '/') { + self::$SUBURI .= '/'; } - self::$_SUBURI .= 'index.php'; + self::$SUBURI .= 'index.php'; } } - $pos = strpos($scriptName, self::$_SUBURI); + $pos = strpos($scriptName, self::$SUBURI); if ($pos === false) { $pos = strpos($scriptName, '?'); @@ -328,6 +333,78 @@ class Init self::$WEBURI .= $protocol . $_SERVER['HTTP_HOST'] . self::$WEBROOT; } + /** + * Cargar la configuración + */ + private static function loadConfig() + { + // Comprobar si es una versión antigua + self::checkConfigVersion(); + + // Comprobar la configuración y cargar + self::checkConfig(); + Config::loadConfig(); + } + + /** + * Comprobar la versión de configuración y actualizarla + */ + private static function checkConfigVersion() + { + $oldConfigCheck = file_exists(CONFIG_FILE); + $appVersion = (int)implode(Util::getVersion(true)); + + if ($oldConfigCheck) { + include_once CONFIG_FILE; + } + + $configVersion = ($oldConfigCheck) ? (int)$CONFIG['version'] : Config::getConfig()->getConfigVersion(); + + + if ($configVersion < $appVersion + && Upgrade::needConfigUpgrade($appVersion) + && Upgrade::upgradeConfig($appVersion) + ) { + if ($oldConfigCheck) { + rename(CONFIG_FILE, CONFIG_FILE . '.old'); + } + + $Log = new Log(_('Actualización')); + $Log->addDescription(_('Actualización de versión realizada.')); + $Log->addDetails(_('Versión'), $appVersion); + $Log->addDetails(_('Tipo'), 'config'); + $Log->writeLog(); + + Email::sendEmail($Log); + + self::$UPDATED = true; + } + } + + /** + * Comprobar el archivo de configuración. + * Esta función comprueba que el archivo de configuración exista y los permisos sean correctos. + */ + private static function checkConfig() + { + if (!is_dir(self::$SERVERROOT . DIRECTORY_SEPARATOR . 'config')) { + clearstatcache(); + self::initError(_('El directorio "/config" no existe')); + } + + if (!is_writable(self::$SERVERROOT . DIRECTORY_SEPARATOR . 'config')) { + clearstatcache(); + self::initError(_('No es posible escribir en el directorio "config"')); + } + + $configPerms = decoct(fileperms(self::$SERVERROOT . DIRECTORY_SEPARATOR . 'config') & 0777); + + if (!Checks::checkIsWindows() && $configPerms != "750") { + clearstatcache(); + self::initError(_('Los permisos del directorio "/config" son incorrectos'), _('Actual:') . ' ' . $configPerms . ' - ' . _('Necesario: 750')); + } + } + /** * Comprobar y forzar (si es necesario) la conexión HTTPS */ @@ -353,30 +430,6 @@ class Init return (in_array($srcScript, $skipInit)); } - /** - * Comprobar el archivo de configuración. - * Esta función comprueba que el archivo de configuración exista y los permisos sean correctos. - */ - private static function checkConfig() - { - if (!is_dir(self::$SERVERROOT . DIRECTORY_SEPARATOR . 'config')) { - clearstatcache(); - self::initError(_('El directorio "/config" no existe')); - } - - if (!is_writable(self::$SERVERROOT . DIRECTORY_SEPARATOR . 'config')) { - clearstatcache(); - self::initError(_('No es posible escribir en el directorio "config"')); - } - - $configPerms = decoct(fileperms(self::$SERVERROOT . DIRECTORY_SEPARATOR . 'config') & 0777); - - if (!Checks::checkIsWindows() && $configPerms != "750") { - clearstatcache(); - self::initError(_('Los permisos del directorio "/config" son incorrectos'), _('Actual:') . ' ' . $configPerms . ' - ' . _('Necesario: 750')); - } - } - /** * Comprueba que la aplicación esté instalada * Esta función comprueba si la aplicación está instalada. Si no lo está, redirige al instalador. @@ -384,8 +437,8 @@ class Init private static function checkInstalled() { // Redirigir al instalador si no está instalada - if (!Config::getValue('installed', false)) { - if (self::$_SUBURI != '/index.php') { + if (!Config::getConfig()->isInstalled()) { + if (self::$SUBURI != '/index.php') { $url = 'http://' . $_SERVER['SERVER_NAME'] . ':' . $_SERVER["SERVER_PORT"] . self::$WEBROOT . '/index.php'; header("Location: $url"); exit(); @@ -409,7 +462,7 @@ class Init */ public static function checkMaintenanceMode($check = false) { - if (Config::getValue('maintenance', false)) { + if (Config::getConfig()->isMaintenance()) { if ($check === true || Request::analyze('isAjax', 0) === 1 || Request::analyze('upgrade', 0) === 1 @@ -446,9 +499,10 @@ class Init private static function logout() { self::wrLogoutInfo(); + SessionUtil::cleanSession(); - session_unset(); - session_destroy(); +// session_unset(); +// session_destroy(); } /** @@ -481,14 +535,13 @@ class Init /** * Comrpueba y actualiza la versión de la aplicación. */ - private static function checkVersion() + private static function checkDbVersion() { - if (self::$_SUBURI != '/index.php' || Request::analyze('logout', 0) === 1) { + if (self::$SUBURI != '/index.php' || Request::analyze('logout', 0) === 1) { return; } $update = false; - $configVersion = (int)str_replace('.', '', Config::getValue('version')); $databaseVersion = (int)str_replace('.', '', ConfigDB::getValue('version')); $appVersion = (int)implode(Util::getVersion(true)); @@ -497,25 +550,24 @@ class Init ) { if (Upgrade::needDBUpgrade($databaseVersion)) { if (!self::checkMaintenanceMode(true)) { - if (Config::getValue('upgrade_key', 0) === 0) { - Config::setCacheConfigValue('upgrade_key', sha1(uniqid(mt_rand(), true))); - Config::setCacheConfigValue('maintenance', true); - Config::writeConfig(false); + if (empty(Config::getConfig()->getUpgradeKey())) { + Config::getConfig()->setUpgradeKey(sha1(uniqid(mt_rand(), true))); + Config::getConfig()->setMaintenance(true); + Config::saveConfig(); } self::initError(_('La aplicación necesita actualizarse'), sprintf(_('Si es un administrador pulse en el enlace: %s'), '' . _('Actualizar') . '')); } - error_log('upgrade'); - $action = Request::analyze('a'); $hash = Request::analyze('h'); - if ($action === 'upgrade' && $hash === Config::getValue('upgrade_key', 0)) { + if ($action === 'upgrade' && $hash === Config::getConfig()->getUpgradeKey()) { if ($update = Upgrade::doUpgrade($databaseVersion)) { ConfigDB::setValue('version', $appVersion); - Config::setValue('maintenance', false); - Config::deleteParam('upgrade_key'); + Config::getConfig()->setMaintenance(false); + Config::getConfig()->setUpgradeKey(''); + Config::saveConfig(); } } else { $controller = new Controller\Main(); @@ -526,18 +578,11 @@ class Init } } - if ($configVersion < $appVersion - && Upgrade::needConfigUpgrade($appVersion) - && Upgrade::upgradeConfig($appVersion) - ) { - Config::setValue('version', $appVersion); - $update = true; - } - if ($update === true) { $Log = new Log(_('Actualización')); $Log->addDescription(_('Actualización de versión realizada.')); $Log->addDetails(_('Versión'), $appVersion); + $Log->addDetails(_('Tipo'), 'db'); $Log->writeLog(); Email::sendEmail($Log); @@ -592,7 +637,7 @@ class Init private static function getSessionLifeTime() { if (is_null(Session::getSessionTimeout())) { - Session::setSessionTimeout(Config::getValue('session_timeout', 60 * 5)); + Session::setSessionTimeout(Config::getConfig()->getSessionTimeout()); } return Session::getSessionTimeout(); diff --git a/inc/SP/Core/Installer.class.php b/inc/SP/Core/Installer.class.php index dcce0b68..a962c393 100644 --- a/inc/SP/Core/Installer.class.php +++ b/inc/SP/Core/Installer.class.php @@ -47,46 +47,46 @@ class Installer /** * @var string Usuario de la BD */ - private static $_dbuser; + private static $dbUser; /** * @var string Clave de la BD */ - private static $_dbpass; + private static $dbPass; /** * @var string Nombre de la BD */ - private static $_dbname; + private static $dbName; /** * @var string Host de la BD */ - private static $_dbhost; + private static $dbHost; /** * @var PDO Instancia a de conexión a la BD */ - private static $_dbc; + private static $DB; /** * @var string Usuario 'admin' de sysPass */ - private static $_username; + private static $username; /** * @var string Clave del usuario 'admin' de sysPass */ - private static $_password; + private static $password; /** * @var string Clave maestra de sysPass */ - private static $_masterPassword; + private static $masterPassword; /** * @var bool Activar/desactivar Modo hosting */ - private static $_isHostingMode; + private static $isHostingMode; /** * @param string $dbname */ - public static function setDbname($dbname) + public static function setDbName($dbname) { - self::$_dbname = $dbname; + self::$dbName = $dbname; } /** @@ -94,7 +94,7 @@ class Installer */ public static function setUsername($username) { - self::$_username = $username; + self::$username = $username; } /** @@ -102,7 +102,7 @@ class Installer */ public static function setPassword($password) { - self::$_password = $password; + self::$password = $password; } /** @@ -110,7 +110,7 @@ class Installer */ public static function setMasterPassword($masterPassword) { - self::$_masterPassword = $masterPassword; + self::$masterPassword = $masterPassword; } /** @@ -118,7 +118,7 @@ class Installer */ public static function setIsHostingMode($isHostingMode) { - self::$_isHostingMode = $isHostingMode; + self::$isHostingMode = $isHostingMode; } /** @@ -130,47 +130,47 @@ class Installer { $error = array(); - if (!self::$_username) { + if (!self::$username) { $error[] = array( 'type' => SPException::SP_CRITICAL, 'description' => _('Indicar nombre de usuario admin'), 'hint' => _('Usuario admin para acceso a la aplicación')); - } elseif (!self::$_password) { + } elseif (!self::$password) { $error[] = array( 'type' => SPException::SP_CRITICAL, 'description' => _('Indicar la clave de admin'), 'hint' => _('Clave del usuario admin de la aplicación')); - } elseif (!self::$_masterPassword) { + } elseif (!self::$masterPassword) { $error[] = array( 'type' => SPException::SP_CRITICAL, 'description' => _('Indicar la clave maestra'), 'hint' => _('Clave maestra para encriptar las claves')); - } elseif (strlen(self::$_masterPassword) < 11) { + } elseif (strlen(self::$masterPassword) < 11) { $error[] = array( 'type' => SPException::SP_CRITICAL, 'description' => _('Clave maestra muy corta'), 'hint' => _('La longitud de la clave maestra ha de ser mayor de 11 caracteres')); - } elseif (!self::$_dbuser) { + } elseif (!self::$dbUser) { $error[] = array( 'type' => SPException::SP_CRITICAL, 'description' => _('Indicar el usuario de la BBDD'), 'hint' => _('Usuario con permisos de administrador de la Base de Datos')); - } elseif (!self::$_dbpass) { + } elseif (!self::$dbPass) { $error[] = array( 'type' => SPException::SP_CRITICAL, 'description' => _('Indicar la clave de la BBDD'), 'hint' => _('Clave del usuario administrador de la Base de Datos')); - } elseif (!self::$_dbname) { + } elseif (!self::$dbName) { $error[] = array( 'type' => SPException::SP_CRITICAL, 'description' => _('Indicar el nombre de la BBDD'), 'hint' => _('Nombre para la BBDD de la aplicación pej. syspass')); - } elseif (substr_count(self::$_dbname, '.') >= 1) { + } elseif (substr_count(self::$dbName, '.') >= 1) { $error[] = array( 'type' => SPException::SP_CRITICAL, 'description' => _('El nombre de la BBDD no puede contener "."'), 'hint' => _('Elimine los puntos del nombre de la Base de Datos')); - } elseif (!self::$_dbhost) { + } elseif (!self::$dbHost) { $error[] = array( 'type' => SPException::SP_CRITICAL, 'description' => _('Indicar el servidor de la BBDD'), @@ -178,28 +178,31 @@ class Installer } if (count($error) === 0) { //no errors, good - // Generate a random salt that is used to salt the local user passwords - Config::setValue('passwordsalt', Util::generate_random_bytes(30)); - Config::setValue('version', implode(Util::getVersion(true))); + $Config = Config::getConfig(); - if (preg_match('/(.*):(\d{1,5})/', self::$_dbhost, $match)) { - self::setDbhost($match[1]); + // Generate a random salt that is used to salt the local user passwords + $Config->setPasswordSalt(Util::generate_random_bytes(30)); + $Config->setConfigVersion(implode(Util::getVersion(true))); + + if (preg_match('/(.*):(\d{1,5})/', self::$dbHost, $match)) { + self::setDbHost($match[1]); $dbport = $match[2]; } else { $dbport = 3306; } // Save DB connection info - Config::setValue('dbhost', self::$_dbhost); - Config::setValue('dbname', self::$_dbname); + $Config->setDbHost(self::$dbHost); + $Config->setDbName(self::$dbName); - // Set some basic configuration options - Config::setDefaultValues(); try { - self::checkDatabaseAdmin(self::$_dbhost, self::$_dbuser, self::$_dbpass, $dbport); + self::checkDatabaseAdmin(self::$dbHost, self::$dbUser, self::$dbPass, $dbport); self::setupMySQLDatabase(); self::createAdminAccount(); + ConfigDB::setValue('version', implode(Util::getVersion(true))); + $Config->setInstalled(true); + Config::saveConfig(); } catch (SPException $e) { $error[] = array( 'type' => $e->getType(), @@ -207,9 +210,6 @@ class Installer 'hint' => $e->getHint()); return $error; } - - ConfigDB::setValue('version', implode(Util::getVersion(true))); - Config::setValue('installed', 1); } return $error; @@ -218,9 +218,9 @@ class Installer /** * @param string $dbhost */ - public static function setDbhost($dbhost) + public static function setDbHost($dbhost) { - self::$_dbhost = $dbhost; + self::$dbHost = $dbhost; } /** @@ -238,8 +238,8 @@ class Installer { try { $dsn = 'mysql:host=' . $dbhost . ';dbport=' . $dbport . ';charset=utf8'; - self::$_dbc = new PDO($dsn, $dbadmin, $dbpass); - self::$_dbc->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + self::$DB = new PDO($dsn, $dbadmin, $dbpass); + self::$DB->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } catch (PDOException $e) { throw new SPException(SPException::SP_CRITICAL , _('No es posible conectar con la BD') @@ -256,31 +256,31 @@ class Installer private static function setupMySQLDatabase() { // Si no es modo hosting se crea un hash para la clave y un usuario con prefijo "sp_" para la DB - if (!self::$_isHostingMode) { - self::setDbpass(md5(time() . self::$_password)); - self::setDbuser(substr('sp_' . self::$_username, 0, 16)); + if (!self::$isHostingMode) { + self::setDbPass(md5(time() . self::$password)); + self::setDbUser(substr('sp_' . self::$username, 0, 16)); // Comprobar si el usuario sumistrado existe - $query = "SELECT COUNT(*) FROM mysql.user WHERE user='" . self::$_username . "' AND host='" . self::$_dbhost . "'"; + $query = "SELECT COUNT(*) FROM mysql.user WHERE user='" . self::$username . "' AND host='" . self::$dbHost . "'"; try { // Si no existe el usuario, se intenta crear - if (intval(self::$_dbc->query($query)->fetchColumn()) === 0) { + if (intval(self::$DB->query($query)->fetchColumn()) === 0) { // Se comprueba si el nuevo usuario es distinto del creado en otra instalación - if (self::$_dbuser != Config::getValue('dbuser')) { + if (self::$dbUser != Config::getConfig()->getDbUser()) { self::createDBUser(); } } } catch (PDOException $e) { throw new SPException(SPException::SP_CRITICAL - , _('No es posible comprobar el usuario de sysPass') . ' (' . self::$_username . ')' + , _('No es posible comprobar el usuario de sysPass') . ' (' . self::$username . ')' , _('Compruebe los permisos del usuario de conexión a la BD')); } } // Guardar el nuevo usuario/clave de conexión a la BD - Config::setValue('dbuser', self::$_dbuser); - Config::setValue('dbpass', self::$_dbpass); + Config::getConfig()->setDbUser(self::$dbUser); + Config::getConfig()->setDbPass(self::$dbPass); try { self::createMySQLDatabase(); @@ -293,17 +293,17 @@ class Installer /** * @param string $dbpass */ - public static function setDbpass($dbpass) + public static function setDbPass($dbpass) { - self::$_dbpass = $dbpass; + self::$dbPass = $dbpass; } /** * @param string $dbuser */ - public static function setDbuser($dbuser) + public static function setDbUser($dbuser) { - self::$_dbuser = $dbuser; + self::$dbUser = $dbuser; } /** @@ -315,17 +315,17 @@ class Installer */ private static function createDBUser() { - if (self::$_isHostingMode) { + if (self::$isHostingMode) { return; } - $query = "CREATE USER '" . self::$_dbuser . "'@'localhost' IDENTIFIED BY '" . self::$_dbpass . "'"; + $query = "CREATE USER '" . self::$dbUser . "'@'localhost' IDENTIFIED BY '" . self::$dbPass . "'"; try { - self::$_dbc->query($query); + self::$DB->query($query); } catch (PDOException $e) { throw new SPException(SPException::SP_CRITICAL - , _('El usuario de MySQL ya existe') . " (" . self::$_dbuser . ")" + , _('El usuario de MySQL ya existe') . " (" . self::$dbUser . ")" , _('Indique un nuevo usuario o elimine el existente')); } } @@ -343,21 +343,21 @@ class Installer , _('Indique una nueva Base de Datos o elimine la existente')); } - $query = "CREATE SCHEMA `" . self::$_dbname . "` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci"; + $query = "CREATE SCHEMA `" . self::$dbName . "` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci"; try { - self::$_dbc->query($query); + self::$DB->query($query); } catch (PDOException $e) { throw new SPException(SPException::SP_CRITICAL , _('Error al crear la BBDD') . " (" . $e->getMessage() . ")" , _('Verifique los permisos del usuario de la Base de Datos')); } - if (!self::$_isHostingMode) { - $query = "GRANT ALL PRIVILEGES ON `" . self::$_dbname . "`.* TO '" . self::$_dbuser . "'@'" . self::$_dbhost . "' IDENTIFIED BY '" . self::$_dbpass . "';"; + if (!self::$isHostingMode) { + $query = "GRANT ALL PRIVILEGES ON `" . self::$dbName . "`.* TO '" . self::$dbUser . "'@'" . self::$dbHost . "' IDENTIFIED BY '" . self::$dbPass . "';"; try { - self::$_dbc->query($query); + self::$DB->query($query); } catch (PDOException $e) { throw new SPException(SPException::SP_CRITICAL , _('Error al establecer permisos de la BBDD') . " (" . $e->getMessage() . ")" @@ -375,9 +375,9 @@ class Installer { $query = "SELECT COUNT(*) " . "FROM information_schema.schemata " - . "WHERE schema_name = '" . self::$_dbname . "' LIMIT 1"; + . "WHERE schema_name = '" . self::$dbName . "' LIMIT 1"; - return (intval(self::$_dbc->query($query)->fetchColumn()) > 0); + return (intval(self::$DB->query($query)->fetchColumn()) > 0); } /** @@ -398,10 +398,10 @@ class Installer // Usar la base de datos de sysPass try { - self::$_dbc->query('USE `' . self::$_dbname. '`'); + self::$DB->query('USE `' . self::$dbName. '`'); } catch (PDOException $e) { throw new SPException(SPException::SP_CRITICAL - , _('Error al seleccionar la BBDD') . " '" . self::$_dbname . "' (" . $e->getMessage() . ")" + , _('Error al seleccionar la BBDD') . " '" . self::$dbName . "' (" . $e->getMessage() . ")" , _('No es posible usar la Base de Datos para crear la estructura. Compruebe los permisos y que no exista.')); } @@ -414,10 +414,10 @@ class Installer if (strlen(trim($buffer)) > 0) { try { $query = str_replace("\n", '', $buffer); - self::$_dbc->query($query); + self::$DB->query($query); } catch (PDOException $e) { // drop database on error - self::$_dbc->query("DROP DATABASE IF EXISTS " . self::$_dbname . ";"); + self::$DB->query("DROP DATABASE IF EXISTS " . self::$dbName . ";"); throw new SPException(SPException::SP_CRITICAL , _('Error al crear la BBDD') . ' (' . $e->getMessage() . ')' @@ -482,8 +482,8 @@ class Installer } // Datos del usuario - $User->setUserLogin(self::$_username); - $User->setUserPass(self::$_password); + $User->setUserLogin(self::$username); + $User->setUserPass(self::$password); $User->setUserName('Admin'); $User->setUserProfileId($Profile->getId()); $User->setUserIsAdminApp(true); @@ -499,11 +499,11 @@ class Installer } // Guardar el hash de la clave maestra - ConfigDB::setCacheConfigValue('masterPwd', Crypt::mkHashPassword(self::$_masterPassword)); + ConfigDB::setCacheConfigValue('masterPwd', Crypt::mkHashPassword(self::$masterPassword)); ConfigDB::setCacheConfigValue('lastupdatempass', time()); ConfigDB::writeConfig(true); - if (!$User->updateUserMPass(self::$_masterPassword)) { + if (!$User->updateUserMPass(self::$masterPassword)) { self::rollback(); throw new SPException(SPException::SP_CRITICAL @@ -519,12 +519,11 @@ class Installer private static function rollback() { try { - self::$_dbc->query("DROP DATABASE IF EXISTS " . self::$_dbname . ";"); - self::$_dbc->query("DROP USER '" . self::$_dbuser . "'@'" . self::$_dbhost . "';"); - self::$_dbc->query("DROP USER '" . self::$_dbuser . "'@'%';"); + self::$DB->query("DROP DATABASE IF EXISTS " . self::$dbName . ";"); + self::$DB->query("DROP USER '" . self::$dbUser . "'@'" . self::$dbHost . "';"); + self::$DB->query("DROP USER '" . self::$dbUser . "'@'%';"); } catch (PDOException $e) { - Config::deleteParam('dbuser'); - Config::deleteParam('dbpass'); + return false; } } diff --git a/inc/SP/Core/Language.class.php b/inc/SP/Core/Language.class.php index cec0caf1..da2e564b 100644 --- a/inc/SP/Core/Language.class.php +++ b/inc/SP/Core/Language.class.php @@ -90,7 +90,7 @@ class Language private function getGlobalLang() { $browserLang = $this->getBrowserLang(); - $configLang = Config::getValue('sitelang'); + $configLang = Config::getConfig()->getSiteLang(); // Establecer a en_US si no existe la traducción o no es español if (!$configLang diff --git a/inc/SP/Core/Session.class.php b/inc/SP/Core/Session.class.php index 56db7144..6a5f294d 100644 --- a/inc/SP/Core/Session.class.php +++ b/inc/SP/Core/Session.class.php @@ -26,6 +26,7 @@ namespace SP\Core; use SP\Account; +use SP\Config\ConfigData; use SP\Mgmt; use SP\Mgmt\User\Profile; use SP\Mgmt\User\UserPreferences; @@ -748,4 +749,52 @@ class Session { self::setSessionKey('sessiontype', $type); } + + /** + * Devolver la configuración + * + * @return ConfigData + */ + public static function getConfig() + { + return self::getSessionKey('config'); + } + + /** + * Establecer la configuración + * + * @param ConfigData $config + */ + public static function setConfig(ConfigData $config) + { + self::setSessionKey('config', $config); + } + + /** + * Establecer la hora de carga de la configuración + * + * @param $time + */ + public static function setConfigTime($time) + { + self::setSessionKey('configTime', $time); + } + + /** + * Devolver la hora de carga de la configuración + * + * @return int + */ + public static function getConfigTime() + { + return self::getSessionKey('configTime'); + } + + /** + * @param $key + */ + public static function unsetSessionKey($key) + { + unset($_SESSION[$key]); + } } \ No newline at end of file diff --git a/inc/SP/Core/SessionUtil.class.php b/inc/SP/Core/SessionUtil.class.php index a1471af5..d8ad3b93 100644 --- a/inc/SP/Core/SessionUtil.class.php +++ b/inc/SP/Core/SessionUtil.class.php @@ -123,4 +123,37 @@ class SessionUtil { return (!is_null(Session::getSecurityKey()) && Session::getSecurityKey() == $key); } + + /** + * Limpiar la sesión del usuario + */ + public static function cleanSession() + { + Session::unsetSessionKey('uid'); + Session::unsetSessionKey('uisadminapp'); + Session::unsetSessionKey('uisadminacc'); + Session::unsetSessionKey('uprofile'); + Session::unsetSessionKey('ulogin'); + Session::unsetSessionKey('uname'); + Session::unsetSessionKey('ugroup'); + Session::unsetSessionKey('ugroupn'); + Session::unsetSessionKey('uemail'); + Session::unsetSessionKey('uisldap'); + Session::unsetSessionKey('usrprofile'); + Session::unsetSessionKey('searchFilters'); + Session::unsetSessionKey('accParentId'); + Session::unsetSessionKey('mPass'); + Session::unsetSessionKey('mPassPwd'); + Session::unsetSessionKey('mPassIV'); + Session::unsetSessionKey('sidStartTime'); + Session::unsetSessionKey('startActivity'); + Session::unsetSessionKey('lastActivity'); + Session::unsetSessionKey('lastAccountId'); + Session::unsetSessionKey('theme'); + Session::unsetSessionKey('2fapass'); + Session::unsetSessionKey('locale'); + Session::unsetSessionKey('userpreferences'); + Session::unsetSessionKey('tempmasterpass'); + Session::unsetSessionKey('accountcolor'); + } } \ No newline at end of file diff --git a/inc/SP/Core/Template.class.php b/inc/SP/Core/Template.class.php index 451dcfda..4318049e 100644 --- a/inc/SP/Core/Template.class.php +++ b/inc/SP/Core/Template.class.php @@ -44,11 +44,11 @@ class Template /** * @var array Variable con los archivos de plantilla a cargar */ - private $_file = array(); + private $file = array(); /** * @var array Variable con las variables a incluir en la plantilla */ - private $_vars = array(); + private $vars = array(); /** * @param null $file Archivo de plantilla a añadir @@ -124,7 +124,7 @@ class Template */ private function setTemplate($file) { - $this->_file[] = $file; + $this->file[] = $file; } /** @@ -148,11 +148,11 @@ class Template */ public function __get($name) { - if (!array_key_exists($name, $this->_vars)) { + if (!array_key_exists($name, $this->vars)) { throw new InvalidArgumentException(sprintf(_('No es posible obtener la variable "%s"'), $name)); } - return $this->_vars[$name]; + return $this->vars[$name]; } /** @@ -165,7 +165,7 @@ class Template */ public function __set($name, $value) { - $this->_vars[$name] = $value; + $this->vars[$name] = $value; return null; } @@ -178,7 +178,7 @@ class Template */ public function __isset($name) { - return array_key_exists($name, $this->_vars); + return array_key_exists($name, $this->vars); } /** @@ -191,11 +191,11 @@ class Template */ public function __unset($name) { - if (!isset($this->_vars[$name])) { + if (!isset($this->vars[$name])) { throw new InvalidArgumentException(sprintf(_('No es posible destruir la variable "%s"'), $name)); } - unset($this->_vars[$name]); + unset($this->vars[$name]); return $this; } @@ -207,12 +207,12 @@ class Template */ public function render() { - extract($this->_vars); + extract($this->vars); ob_start(); // Añadimos las plantillas - foreach ($this->_file as $template) { + foreach ($this->file as $template) { include_once $template; } @@ -232,7 +232,7 @@ class Template $name = $scope . '_' . $name; } - $this->_vars[$name] = $value; + $this->vars[$name] = $value; } /** @@ -250,9 +250,9 @@ class Template } if (!is_null($index)) { - $this->_vars[$name][$index] = $value; + $this->vars[$name][$index] = $value; } else { - $this->_vars[$name][] = $value; + $this->vars[$name][] = $value; } } @@ -261,7 +261,7 @@ class Template */ public function resetTemplates() { - $this->_file = array(); + $this->file = array(); } /** @@ -269,6 +269,6 @@ class Template */ public function resetVariables() { - $this->_vars = array(); + $this->vars = array(); } } \ No newline at end of file diff --git a/inc/SP/Core/ThemeIconsBase.class.php b/inc/SP/Core/ThemeIconsBase.class.php index 9700cc98..990f325c 100644 --- a/inc/SP/Core/ThemeIconsBase.class.php +++ b/inc/SP/Core/ThemeIconsBase.class.php @@ -38,73 +38,65 @@ defined('APP_ROOT') || die(_('No es posible acceder directamente a este archivo' abstract class ThemeIconsBase implements ThemeIconsInterface { /** @var FontIcon|ImageIcon */ - protected $_iconAdd; + protected $iconAdd; /** @var FontIcon|ImageIcon */ - protected $_iconView; + protected $iconView; /** @var FontIcon|ImageIcon */ - protected $_iconEdit; - - /** - * @return FontIcon|ImageIcon - */ - public function getIconWarning() - { - return $this->_iconWarning; - } + protected $iconEdit; /** @var FontIcon|ImageIcon */ - protected $_iconDelete; + protected $iconDelete; /** @var FontIcon|ImageIcon */ - protected $_iconNavPrev; + protected $iconNavPrev; /** @var FontIcon|ImageIcon */ - protected $_iconNavNext; + protected $iconNavNext; /** @var FontIcon|ImageIcon */ - protected $_iconNavFirst; + protected $iconNavFirst; /** @var FontIcon|ImageIcon */ - protected $_iconNavLast; + protected $iconNavLast; /** @var FontIcon|ImageIcon */ - protected $_iconEditPass; + protected $iconEditPass; /** @var FontIcon|ImageIcon */ - protected $_iconAppAdmin; + protected $iconAppAdmin; /** @var FontIcon|ImageIcon */ - protected $_iconAccAdmin; + protected $iconAccAdmin; /** @var FontIcon|ImageIcon */ - protected $_iconLdapUser; + protected $iconLdapUser; /** @var FontIcon|ImageIcon */ - protected $_iconDisabled; + protected $iconDisabled; /** @var FontIcon|ImageIcon */ - protected $_iconViewPass; + protected $iconViewPass; /** @var FontIcon|ImageIcon */ - protected $_iconCopy; + protected $iconCopy; /** @var FontIcon|ImageIcon */ - protected $_iconClipboard; + protected $iconClipboard; /** @var FontIcon|ImageIcon */ - protected $_iconEmail; + protected $iconEmail; /** @var FontIcon|ImageIcon */ - protected $_iconOptional; + protected $iconOptional; /** @var FontIcon|ImageIcon */ - protected $_iconUp; + protected $iconUp; /** @var FontIcon|ImageIcon */ - protected $_iconDown; + protected $iconDown; /** @var FontIcon|ImageIcon */ - protected $_iconRefresh; + protected $iconRefresh; /** @var FontIcon|ImageIcon */ - protected $_iconPublicLink; + protected $iconPublicLink; /** @var FontIcon|ImageIcon */ - protected $_iconBack; + protected $iconBack; /** @var FontIcon|ImageIcon */ - protected $_iconRestore; + protected $iconRestore; /** @var FontIcon|ImageIcon */ - protected $_iconSave; + protected $iconSave; /** @var FontIcon|ImageIcon */ - protected $_iconHelp; + protected $iconHelp; /** @var FontIcon|ImageIcon */ - protected $_iconClear; + protected $iconClear; /** @var FontIcon|ImageIcon */ - protected $_iconPlay; + protected $iconPlay; /** @var FontIcon|ImageIcon */ - protected $_iconDownload; + protected $iconDownload; /** @var FontIcon|ImageIcon */ - protected $_iconWarning; + protected $iconWarning; /** * Icons constructor. @@ -114,12 +106,20 @@ abstract class ThemeIconsBase implements ThemeIconsInterface $this->setIcons(); } + /** + * @return FontIcon|ImageIcon + */ + public function getIconWarning() + { + return $this->iconWarning; + } + /** * @return FontIcon|ImageIcon */ public function getIconDownload() { - return $this->_iconDownload; + return $this->iconDownload; } /** @@ -127,7 +127,7 @@ abstract class ThemeIconsBase implements ThemeIconsInterface */ public function getIconClear() { - return $this->_iconClear; + return $this->iconClear; } /** @@ -135,7 +135,7 @@ abstract class ThemeIconsBase implements ThemeIconsInterface */ public function getIconPlay() { - return $this->_iconPlay; + return $this->iconPlay; } /** @@ -143,7 +143,7 @@ abstract class ThemeIconsBase implements ThemeIconsInterface */ public function getIconHelp() { - return $this->_iconHelp; + return $this->iconHelp; } /** @@ -151,7 +151,7 @@ abstract class ThemeIconsBase implements ThemeIconsInterface */ public function getIconPublicLink() { - return $this->_iconPublicLink; + return $this->iconPublicLink; } /** @@ -159,7 +159,7 @@ abstract class ThemeIconsBase implements ThemeIconsInterface */ public function getIconBack() { - return $this->_iconBack; + return $this->iconBack; } /** @@ -167,7 +167,7 @@ abstract class ThemeIconsBase implements ThemeIconsInterface */ public function getIconRestore() { - return $this->_iconRestore; + return $this->iconRestore; } /** @@ -175,7 +175,7 @@ abstract class ThemeIconsBase implements ThemeIconsInterface */ public function getIconSave() { - return $this->_iconSave; + return $this->iconSave; } /** @@ -183,7 +183,7 @@ abstract class ThemeIconsBase implements ThemeIconsInterface */ public function getIconUp() { - return $this->_iconUp; + return $this->iconUp; } /** @@ -191,7 +191,7 @@ abstract class ThemeIconsBase implements ThemeIconsInterface */ public function getIconDown() { - return $this->_iconDown; + return $this->iconDown; } /** @@ -199,7 +199,7 @@ abstract class ThemeIconsBase implements ThemeIconsInterface */ public function getIconViewPass() { - return $this->_iconViewPass; + return $this->iconViewPass; } /** @@ -207,7 +207,7 @@ abstract class ThemeIconsBase implements ThemeIconsInterface */ public function getIconCopy() { - return $this->_iconCopy; + return $this->iconCopy; } /** @@ -215,7 +215,7 @@ abstract class ThemeIconsBase implements ThemeIconsInterface */ public function getIconClipboard() { - return $this->_iconClipboard; + return $this->iconClipboard; } /** @@ -223,7 +223,7 @@ abstract class ThemeIconsBase implements ThemeIconsInterface */ public function getIconEmail() { - return $this->_iconEmail; + return $this->iconEmail; } /** @@ -231,7 +231,7 @@ abstract class ThemeIconsBase implements ThemeIconsInterface */ public function getIconRefresh() { - return $this->_iconRefresh; + return $this->iconRefresh; } /** @@ -239,7 +239,7 @@ abstract class ThemeIconsBase implements ThemeIconsInterface */ public function getIconEditPass() { - return $this->_iconEditPass; + return $this->iconEditPass; } /** @@ -247,7 +247,7 @@ abstract class ThemeIconsBase implements ThemeIconsInterface */ public function getIconAppAdmin() { - return $this->_iconAppAdmin; + return $this->iconAppAdmin; } /** @@ -255,7 +255,7 @@ abstract class ThemeIconsBase implements ThemeIconsInterface */ public function getIconAccAdmin() { - return $this->_iconAccAdmin; + return $this->iconAccAdmin; } /** @@ -263,7 +263,7 @@ abstract class ThemeIconsBase implements ThemeIconsInterface */ public function getIconLdapUser() { - return $this->_iconLdapUser; + return $this->iconLdapUser; } /** @@ -271,7 +271,7 @@ abstract class ThemeIconsBase implements ThemeIconsInterface */ public function getIconDisabled() { - return $this->_iconDisabled; + return $this->iconDisabled; } /** @@ -279,7 +279,7 @@ abstract class ThemeIconsBase implements ThemeIconsInterface */ public function getIconNavPrev() { - return $this->_iconNavPrev; + return $this->iconNavPrev; } /** @@ -287,7 +287,7 @@ abstract class ThemeIconsBase implements ThemeIconsInterface */ public function getIconNavNext() { - return $this->_iconNavNext; + return $this->iconNavNext; } /** @@ -295,7 +295,7 @@ abstract class ThemeIconsBase implements ThemeIconsInterface */ public function getIconNavFirst() { - return $this->_iconNavFirst; + return $this->iconNavFirst; } /** @@ -303,7 +303,7 @@ abstract class ThemeIconsBase implements ThemeIconsInterface */ public function getIconNavLast() { - return $this->_iconNavLast; + return $this->iconNavLast; } /** @@ -311,7 +311,7 @@ abstract class ThemeIconsBase implements ThemeIconsInterface */ public function getIconAdd() { - return $this->_iconAdd; + return $this->iconAdd; } /** @@ -319,7 +319,7 @@ abstract class ThemeIconsBase implements ThemeIconsInterface */ public function getIconView() { - return $this->_iconView; + return $this->iconView; } /** @@ -327,7 +327,7 @@ abstract class ThemeIconsBase implements ThemeIconsInterface */ public function getIconEdit() { - return $this->_iconEdit; + return $this->iconEdit; } /** @@ -335,7 +335,7 @@ abstract class ThemeIconsBase implements ThemeIconsInterface */ public function getIconDelete() { - return $this->_iconDelete; + return $this->iconDelete; } /** @@ -343,6 +343,6 @@ abstract class ThemeIconsBase implements ThemeIconsInterface */ public function getIconOptional() { - return $this->_iconOptional; + return $this->iconOptional; } } \ No newline at end of file diff --git a/inc/SP/Core/Themes.class.php b/inc/SP/Core/Themes.class.php index 106bf1ed..87098443 100644 --- a/inc/SP/Core/Themes.class.php +++ b/inc/SP/Core/Themes.class.php @@ -50,7 +50,9 @@ class Themes * @var string */ public static $theme = ''; - /** @var Icons */ + /** @var + * Icons + */ private static $icons; /** @@ -120,7 +122,7 @@ class Themes */ private function getGlobalTheme() { - self::$theme = Config::getValue('sitetheme', 'material-blue'); + self::$theme = Config::getConfig()->getSiteTheme(); return self::$theme; } @@ -163,7 +165,6 @@ class Themes public static function getIcons() { if (!self::$icons instanceof Icons) { - $iconsClass = Init::$SERVERROOT . self::$themePath . DIRECTORY_SEPARATOR . 'inc' . DIRECTORY_SEPARATOR . 'Icons.class.php'; if (file_exists($iconsClass)) { diff --git a/inc/SP/Core/Upgrade.class.php b/inc/SP/Core/Upgrade.class.php index 4b5b5515..021a1e68 100644 --- a/inc/SP/Core/Upgrade.class.php +++ b/inc/SP/Core/Upgrade.class.php @@ -27,6 +27,7 @@ namespace SP\Core; use SP\Config\Config; +use SP\Config\ConfigData; use SP\Log\Email; use SP\Log\Log; use SP\Mgmt\User\Profile; @@ -41,8 +42,8 @@ defined('APP_ROOT') || die(_('No es posible acceder directamente a este archivo' */ class Upgrade { - private static $_dbUpgrade = array(110, 1121, 1122, 1123, 11213, 11219, 11220, 12001, 12002, 1316011001); - private static $_cfgUpgrade = array(1124); + private static $dbUpgrade = array(110, 1121, 1122, 1123, 11213, 11219, 11220, 12001, 12002, 1316011001); + private static $cfgUpgrade = array(1124, 1316020501); /** * Inicia el proceso de actualización de la BBDD. @@ -52,7 +53,7 @@ class Upgrade */ public static function doUpgrade($version) { - foreach (self::$_dbUpgrade as $upgradeVersion) { + foreach (self::$dbUpgrade as $upgradeVersion) { if ($version < $upgradeVersion) { if (self::upgradeTo($upgradeVersion) === false) { Init::initError( @@ -210,7 +211,7 @@ class Upgrade */ public static function needDBUpgrade($version) { - $upgrades = array_filter(self::$_dbUpgrade, function ($uVersions) use ($version) { + $upgrades = array_filter(self::$dbUpgrade, function ($uVersions) use ($version) { return ($uVersions > $version); }); @@ -225,7 +226,7 @@ class Upgrade */ public static function needConfigUpgrade($version) { - return (in_array($version, self::$_cfgUpgrade)); + return (in_array($version, self::$cfgUpgrade)); } /** @@ -236,43 +237,102 @@ class Upgrade */ public static function upgradeConfig($version) { - $mapParams = array( - 'files_allowed_exts' => 'allowed_exts', - 'files_allowed_size' => 'allowed_size', - 'demo_enabled' => 'demoenabled', - 'files_enabled' => 'filesenabled', - 'ldap_base' => 'ldapbase', - 'ldap_bindpass' => 'ldapbindpass', - 'ldap_binduser' => 'ldapbinduser', - 'ldap_enabled' => 'ldapenabled', - 'ldap_group' => 'ldapgroup', - 'ldap_server' => 'ldapserver', - 'log_enabled' => 'logenabled', - 'mail_enabled' => 'mailenabled', - 'mail_from' => 'mailfrom', - 'mail_pass' => 'mailpass', - 'mail_port' => 'mailport', - 'mail_requestsenabled' => 'mailrequestsenabled', - 'mail_security' => 'mailsecurity', - 'mail_server' => 'mailserver', - 'mail_user' => 'mailuser', - 'wiki_enabled' => 'wikienabled', - 'wiki_filter' => 'wikifilter', - 'wiki_pageurl' => 'wikipageurl', - 'wiki_searchurl' => 'wikisearchurl' - ); + $Config = new ConfigData(); - $currData = Config::getKeys(true); + if (file_exists(CONFIG_FILE)) { + // Include the file, save the data from $CONFIG + include CONFIG_FILE; - foreach ($mapParams as $newParam => $oldParam) { - if (array_key_exists($oldParam, $currData)) { - Config::setValue($newParam, $currData[$oldParam]); - Config::deleteParam($oldParam); + if (isset($CONFIG) && is_array($CONFIG)) { + error_log('upgrade_old'); + + foreach (self::getConfigParams() as $mapTo => $oldParam) { + $mapFrom = function () use ($oldParam) { + if (is_array($oldParam)) { + foreach ($oldParam as $param) { + if (isset($CONFIG[$param])) { + return $param; + } + } + + return ''; + } + + return $oldParam; + }; + + if (isset($CONFIG[$mapFrom()]) + && method_exists($Config, $mapTo) + ) { + $Config->$mapTo($CONFIG[$mapFrom()]); + } + } } } + $Config->setConfigVersion($version); + Config::saveConfig($Config, false); + Log::writeNewLog(_('Actualizar Configuración'), _('Actualización de la Configuración realizada correctamente.') . ' (v' . $version . ')', Log::NOTICE); return true; } + + /** + * Devuelve array de métodos y parámetros de configuración + * + * @return array + */ + private static function getConfigParams() + { + return [ + 'setAccountCount' => 'account_count', + 'setCheckUpdates' => 'checkupdates', + 'setDbHost' => 'dbhost', + 'setDbName' => 'dbname', + 'setDbPass' => 'dbpass', + 'setDbUser' => 'dbuser', + 'setDebug' => 'debug', + 'setDemoEnabled' => 'demo_enabled', + 'setGlobalSearch' => 'globalsearch', + 'setInstalled' => 'installed', + 'setMaintenance' => 'maintenance', + 'setPasswordSalt' => 'passwordsalt', + 'setSessionTimeout' => 'session_timeout', + 'setSiteLang' => 'sitelang', + 'setConfigVersion' => 'version', + 'setCheckNotices' => 'checknotices', + 'setConfigHash' => 'config_hash', + 'setProxyEnabled' => 'proxy_enabled', + 'setProxyPass' => 'proxy_pass', + 'setProxyPort' => 'proxy_port', + 'setProxyServer' => 'proxy_server', + 'setProxyUser' => 'proxy_user', + 'setResultsAsCards' => 'resultsascards', + 'setSiteTheme' => 'sitetheme', + 'setAccountPassToImage' => 'account_passtoimage', + 'setFilesAllowedExts' => 'allowed_exts', + 'setFilesAllowedSize' => 'allowed_size', + 'setFilesEnabled' => ['filesenabled', 'files_enabled'], + 'setLdapBase' => ['ldapbase', 'ldap_base'], + 'setLdapBindPass' => ['ldapbindpass', 'ldap_bindpass'], + 'setLdapBindUser' => ['ldapbinduser', 'ldap_binduser'], + 'setLdapEnabled' => ['ldapenabled', 'ldap_enabled'], + 'setLdapGroup' => ['ldapgroup', 'ldap_group'], + 'setLdapServer' => ['ldapserver', 'ldap_server'], + 'setLogEnabled' => ['logenabled', 'log_enabled'], + 'setMailEnabled' => ['mailenabled', 'mail_enabled'], + 'setMailFrom' => ['mailfrom', 'mail_from'], + 'setMailPass' => ['mailpass', 'mail_pass'], + 'setMailPort' => ['mailport', 'mail_port'], + 'setMailRequestsEnabled' => ['mailrequestsenabled', 'mail_requestsenabled'], + 'setMailSecurity' => ['mailsecurity', 'mail_security'], + 'setMailServer' => ['mailserver', 'mail_server'], + 'setMailUser' => ['mailuser', 'mail_user'], + 'setWikiEnabled' => ['wikienabled', 'wiki_enabled'], + 'setWikiFilter' => ['wikifilter', 'wiki_filter'], + 'setWikiPageUrl' => ['wikipageurl' . 'wiki_pageurl'], + 'setWikiSearchUrl' => ['wikisearchurl', 'wiki_searchurl'] + ]; + } } \ No newline at end of file diff --git a/inc/SP/Core/XmlExport.class.php b/inc/SP/Core/XmlExport.class.php index f8580a2d..c86b14be 100644 --- a/inc/SP/Core/XmlExport.class.php +++ b/inc/SP/Core/XmlExport.class.php @@ -45,34 +45,34 @@ class XmlExport /** * @var \DOMDocument */ - private $_xml; + private $xml; /** * @var \DOMElement */ - private $_root; + private $root; /** * @var string */ - private $_exportPass = null; + private $exportPass = null; /** * @var bool */ - private $_encrypted = false; + private $encrypted = false; /** * @var string */ - private $_exportDir = ''; + private $exportDir = ''; /** * @var string */ - private $_exportFile = ''; + private $exportFile = ''; /** * Constructor */ public function __construct() { - $this->_xml = new \DOMDocument('1.0', 'UTF-8'); + $this->xml = new \DOMDocument('1.0', 'UTF-8'); } /** @@ -104,7 +104,7 @@ class XmlExport */ public function setExportPass($exportPass) { - $this->_exportPass = $exportPass; + $this->exportPass = $exportPass; } /** @@ -112,7 +112,7 @@ class XmlExport */ public function setEncrypted($encrypted) { - $this->_encrypted = $encrypted; + $this->encrypted = $encrypted; } /** @@ -159,8 +159,8 @@ class XmlExport private function createRoot() { try { - $root = $this->_xml->createElement('Root'); - $this->_root = $this->_xml->appendChild($root); + $root = $this->xml->createElement('Root'); + $this->root = $this->xml->appendChild($root); } catch (\DOMException $e) { throw new SPException(SPException::SP_WARNING, $e->getMessage(), __FUNCTION__); } @@ -174,13 +174,13 @@ class XmlExport private function createMeta() { try { - $nodeMeta = $this->_xml->createElement('Meta'); - $metaGenerator = $this->_xml->createElement('Generator', 'sysPass'); - $metaVersion = $this->_xml->createElement('Version', implode('.', Util::getVersion())); - $metaTime = $this->_xml->createElement('Time', time()); - $metaUser = $this->_xml->createElement('User', Session::getUserLogin()); + $nodeMeta = $this->xml->createElement('Meta'); + $metaGenerator = $this->xml->createElement('Generator', 'sysPass'); + $metaVersion = $this->xml->createElement('Version', implode('.', Util::getVersion())); + $metaTime = $this->xml->createElement('Time', time()); + $metaUser = $this->xml->createElement('User', Session::getUserLogin()); $metaUser->setAttribute('id', Session::getUserId()); - $metaGroup = $this->_xml->createElement('Group', Session::getUserGroupName()); + $metaGroup = $this->xml->createElement('Group', Session::getUserGroupName()); $metaGroup->setAttribute('id', Session::getUserGroupId()); $nodeMeta->appendChild($metaGenerator); @@ -189,7 +189,7 @@ class XmlExport $nodeMeta->appendChild($metaUser); $nodeMeta->appendChild($metaGroup); - $this->_root->appendChild($nodeMeta); + $this->root->appendChild($nodeMeta); } catch (\DOMException $e) { throw new SPException(SPException::SP_WARNING, $e->getMessage(), __FUNCTION__); } @@ -210,14 +210,14 @@ class XmlExport try { // Crear el nodo de categorías - $nodeCategories = $this->_xml->createElement('Categories'); + $nodeCategories = $this->xml->createElement('Categories'); foreach ($categories as $category) { - $categoryName = $this->_xml->createElement('name', $this->escapeChars($category->category_name)); - $categoryDescription = $this->_xml->createElement('description', $this->escapeChars($category->category_description)); + $categoryName = $this->xml->createElement('name', $this->escapeChars($category->category_name)); + $categoryDescription = $this->xml->createElement('description', $this->escapeChars($category->category_description)); // Crear el nodo de categoría - $nodeCategory = $this->_xml->createElement('Category'); + $nodeCategory = $this->xml->createElement('Category'); $nodeCategory->setAttribute('id', $category->category_id); $nodeCategory->appendChild($categoryName); $nodeCategory->appendChild($categoryDescription); @@ -257,25 +257,25 @@ class XmlExport try { // Si se utiliza clave de encriptación los datos se encriptan en un nuevo nodo: // Encrypted -> Data - if ($this->_encrypted === true) { + if ($this->encrypted === true) { // Obtener el nodo en formato XML - $nodeXML = $this->_xml->saveXML($node); + $nodeXML = $this->xml->saveXML($node); // Crear los datos encriptados con la información del nodo - $encrypted = Crypt::mkEncrypt($nodeXML, $this->_exportPass); + $encrypted = Crypt::mkEncrypt($nodeXML, $this->exportPass); $encryptedIV = Crypt::$strInitialVector; // Buscar si existe ya un nodo para el conjunto de datos encriptados - $encryptedNode = $this->_root->getElementsByTagName('Encrypted')->item(0); + $encryptedNode = $this->root->getElementsByTagName('Encrypted')->item(0); if (!$encryptedNode instanceof \DOMElement) { - $encryptedNode = $this->_xml->createElement('Encrypted'); + $encryptedNode = $this->xml->createElement('Encrypted'); } // Crear el nodo hijo con los datos encriptados - $encryptedData = $this->_xml->createElement('Data', base64_encode($encrypted)); + $encryptedData = $this->xml->createElement('Data', base64_encode($encrypted)); - $encryptedDataIV = $this->_xml->createAttribute('iv'); + $encryptedDataIV = $this->xml->createAttribute('iv'); $encryptedDataIV->value = base64_encode($encryptedIV); // Añadir nodos de datos @@ -283,9 +283,9 @@ class XmlExport $encryptedNode->appendChild($encryptedData); // Añadir el nodo encriptado - $this->_root->appendChild($encryptedNode); + $this->root->appendChild($encryptedNode); } else { - $this->_root->appendChild($node); + $this->root->appendChild($node); } } catch (\DOMException $e) { throw new SPException(SPException::SP_WARNING, $e->getMessage(), __FUNCTION__); @@ -307,14 +307,14 @@ class XmlExport try { // Crear el nodo de clientes - $nodeCustomers = $this->_xml->createElement('Customers'); + $nodeCustomers = $this->xml->createElement('Customers'); foreach ($customers as $customer) { - $customerName = $this->_xml->createElement('name', $this->escapeChars($customer->customer_name)); - $customerDescription = $this->_xml->createElement('description', $this->escapeChars($customer->customer_description)); + $customerName = $this->xml->createElement('name', $this->escapeChars($customer->customer_name)); + $customerDescription = $this->xml->createElement('description', $this->escapeChars($customer->customer_description)); // Crear el nodo de categoría - $nodeCustomer = $this->_xml->createElement('Customer'); + $nodeCustomer = $this->xml->createElement('Customer'); $nodeCustomer->setAttribute('id', $customer->customer_id); $nodeCustomer->appendChild($customerName); $nodeCustomer->appendChild($customerDescription); @@ -344,20 +344,20 @@ class XmlExport try { // Crear el nodo de cuentas - $nodeAccounts = $this->_xml->createElement('Accounts'); + $nodeAccounts = $this->xml->createElement('Accounts'); foreach ($accounts as $account) { - $accountName = $this->_xml->createElement('name', $this->escapeChars($account->account_name)); - $accountCustomerId = $this->_xml->createElement('customerId', $account->account_customerId); - $accountCategoryId = $this->_xml->createElement('categoryId', $account->account_categoryId); - $accountLogin = $this->_xml->createElement('login', $this->escapeChars($account->account_login)); - $accountUrl = $this->_xml->createElement('url', $this->escapeChars($account->account_url)); - $accountNotes = $this->_xml->createElement('notes', $this->escapeChars($account->account_notes)); - $accountPass = $this->_xml->createElement('pass', $this->escapeChars(base64_encode($account->account_pass))); - $accountIV = $this->_xml->createElement('passiv', $this->escapeChars(base64_encode($account->account_IV))); + $accountName = $this->xml->createElement('name', $this->escapeChars($account->account_name)); + $accountCustomerId = $this->xml->createElement('customerId', $account->account_customerId); + $accountCategoryId = $this->xml->createElement('categoryId', $account->account_categoryId); + $accountLogin = $this->xml->createElement('login', $this->escapeChars($account->account_login)); + $accountUrl = $this->xml->createElement('url', $this->escapeChars($account->account_url)); + $accountNotes = $this->xml->createElement('notes', $this->escapeChars($account->account_notes)); + $accountPass = $this->xml->createElement('pass', $this->escapeChars(base64_encode($account->account_pass))); + $accountIV = $this->xml->createElement('passiv', $this->escapeChars(base64_encode($account->account_IV))); // Crear el nodo de cuenta - $nodeAccount = $this->_xml->createElement('Account'); + $nodeAccount = $this->xml->createElement('Account'); $nodeAccount->setAttribute('id', $account->account_id); $nodeAccount->appendChild($accountName); $nodeAccount->appendChild($accountCustomerId); @@ -384,15 +384,15 @@ class XmlExport private function createHash() { try { - if ($this->_encrypted === true) { + if ($this->encrypted === true) { $hash = md5($this->getNodeXML('Encrypted')); } else { $hash = md5($this->getNodeXML('Categories') . $this->getNodeXML('Customers') . $this->getNodeXML('Accounts')); } - $metaHash = $this->_xml->createElement('Hash', $hash); + $metaHash = $this->xml->createElement('Hash', $hash); - $nodeMeta = $this->_root->getElementsByTagName('Meta')->item(0); + $nodeMeta = $this->root->getElementsByTagName('Meta')->item(0); $nodeMeta->appendChild($metaHash); } catch (\DOMException $e) { throw new SPException(SPException::SP_WARNING, $e->getMessage(), __FUNCTION__); @@ -409,7 +409,7 @@ class XmlExport private function getNodeXML($node) { try { - $nodeXML = $this->_xml->saveXML($this->_root->getElementsByTagName($node)->item(0)); + $nodeXML = $this->xml->saveXML($this->root->getElementsByTagName($node)->item(0)); return $nodeXML; } catch (\DOMException $e) { throw new SPException(SPException::SP_WARNING, $e->getMessage(), __FUNCTION__); @@ -425,10 +425,10 @@ class XmlExport private function writeXML() { try { - $this->_xml->formatOutput = true; - $this->_xml->preserveWhiteSpace = false; + $this->xml->formatOutput = true; + $this->xml->preserveWhiteSpace = false; - if (!$this->_xml->save($this->_exportFile)) { + if (!$this->xml->save($this->exportFile)) { throw new SPException(SPException::SP_CRITICAL, _('Error al crear el archivo XML')); } } catch (\DOMException $e) { @@ -443,9 +443,10 @@ class XmlExport { // Generar hash unico para evitar descargas no permitidas $exportUniqueHash = uniqid(); - Config::setValue('export_hash', $exportUniqueHash); + Config::getConfig()->setExportHash($exportUniqueHash); + Config::saveConfig(); - $this->_exportFile = $this->_exportDir . DIRECTORY_SEPARATOR . Util::getAppInfo('appname') . '-' . $exportUniqueHash . '.xml'; + $this->exportFile = $this->exportDir . DIRECTORY_SEPARATOR . Util::getAppInfo('appname') . '-' . $exportUniqueHash . '.xml'; } /** @@ -453,7 +454,7 @@ class XmlExport */ public function setExportDir($exportDir) { - $this->_exportDir = $exportDir; + $this->exportDir = $exportDir; } /** @@ -482,13 +483,13 @@ class XmlExport */ private function checkExportDir() { - if (!is_dir($this->_exportDir)) { - if (!@mkdir($this->_exportDir, 0550)) { - throw new SPException(SPException::SP_CRITICAL, _('No es posible crear el directorio de backups') . ' (' . $this->_exportDir . ')'); + if (!is_dir($this->exportDir)) { + if (!@mkdir($this->exportDir, 0550)) { + throw new SPException(SPException::SP_CRITICAL, _('No es posible crear el directorio de backups') . ' (' . $this->exportDir . ')'); } } - if (!is_writable($this->_exportDir)) { + if (!is_writable($this->exportDir)) { throw new SPException(SPException::SP_CRITICAL, _('Compruebe los permisos del directorio de backups')); } @@ -500,6 +501,6 @@ class XmlExport */ private function deleteOldExports() { - array_map('unlink', glob($this->_exportDir . DIRECTORY_SEPARATOR . '*.xml')); + array_map('unlink', glob($this->exportDir . DIRECTORY_SEPARATOR . '*.xml')); } } \ No newline at end of file diff --git a/inc/SP/Html/DataGrid/DataGridHeaderSort.class.php b/inc/SP/Html/DataGrid/DataGridHeaderSort.class.php index c0111e60..bbe33efe 100644 --- a/inc/SP/Html/DataGrid/DataGridHeaderSort.class.php +++ b/inc/SP/Html/DataGrid/DataGridHeaderSort.class.php @@ -71,7 +71,7 @@ class DataGridHeaderSort extends DataGridHeaderBase } /** - * @param DataGridSortInterface[] $field + * @param DataGridSortInterface $field */ public function addSortField($field) { diff --git a/inc/SP/Html/Minify.class.php b/inc/SP/Html/Minify.class.php index f2ba514c..50ceff09 100644 --- a/inc/SP/Html/Minify.class.php +++ b/inc/SP/Html/Minify.class.php @@ -50,26 +50,26 @@ class Minify * * @var array */ - private $_files = array(); + private $files = array(); /** * Tipos de archivos a procesar * * @var int */ - private $_type = 0; + private $type = 0; /** * Base relativa de búsqueda de los archivos * * @var string */ - private $_base = ''; + private $base = ''; /** * @param string $base */ public function setBase($base) { - $this->_base = $base; + $this->base = $base; } @@ -101,9 +101,9 @@ class Minify exit; } - if ($this->_type === self::FILETYPE_JS) { + if ($this->type === self::FILETYPE_JS) { header("Content-type: application/x-javascript; charset: UTF-8"); - } elseif ($this->_type === self::FILETYPE_CSS) { + } elseif ($this->type === self::FILETYPE_CSS) { header("Content-type: text/css; charset: UTF-8"); } @@ -113,7 +113,7 @@ class Minify ob_start(); } - foreach ($this->_files as $file) { + foreach ($this->files as $file) { $filePath = $file['base'] . DIRECTORY_SEPARATOR . $file['name']; // Obtener el recurso desde una URL @@ -135,9 +135,9 @@ class Minify if ($file['min'] === true && $disableMinify === false) { echo '/* MINIFIED FILE: ' . $file['name'] . ' */' . PHP_EOL; - if ($this->_type === self::FILETYPE_JS) { + if ($this->type === self::FILETYPE_JS) { echo $this->jsCompress(file_get_contents($filePath)); - } elseif ($this->_type === self::FILETYPE_CSS) { + } elseif ($this->type === self::FILETYPE_CSS) { echo CssMin::minify(file_get_contents($filePath)); } } else { @@ -160,7 +160,7 @@ class Minify { $md5Sum = ''; - foreach ($this->_files as $file) { + foreach ($this->files as $file) { if (preg_match('#^https?://.*#', $file['name'])) { continue; } @@ -214,15 +214,15 @@ class Minify $files = explode(',', $file); foreach ($files as $file){ - $this->_files[] = array( - 'base' => $this->_base, + $this->files[] = array( + 'base' => $this->base, 'name' => $file, 'min' => $this->needsMinify($file) ); } } else { - $this->_files[] = array( - 'base' => $this->_base, + $this->files[] = array( + 'base' => $this->base, 'name' => $file, 'min' => ($minify === true && $this->needsMinify($file)) ); @@ -234,7 +234,7 @@ class Minify */ public function setType($type) { - $this->_type = $type; + $this->type = $type; } /** diff --git a/inc/SP/Http/Request.class.php b/inc/SP/Http/Request.class.php index a6525155..96583980 100644 --- a/inc/SP/Http/Request.class.php +++ b/inc/SP/Http/Request.class.php @@ -162,17 +162,7 @@ class Request public static function getRequestHeaders($header = '') { if (!function_exists('\apache_request_headers')) { - function apache_request_headers() - { - foreach ($_SERVER as $key => $value) { - if (substr($key, 0, 5) == "HTTP_") { - $key = str_replace(" ", "-", ucwords(strtolower(str_replace("_", " ", substr($key, 5))))); - $headers[$key] = $value; - } else { - $headers[$key] = $value; - } - } - } + $headers = self::getApacheHeaders(); } else { $headers = apache_request_headers(); } @@ -202,4 +192,25 @@ class Request return (isset($params) && count($params) > 0) ? implode('&', $params) : ''; } + + /** + * Función que sustituye a apache_request_headers + * + * @return array + */ + public static function getApacheHeaders() + { + $headers = array(); + + foreach ($_SERVER as $key => $value) { + if (substr($key, 0, 5) == "HTTP_") { + $key = str_replace(" ", "-", ucwords(strtolower(str_replace("_", " ", substr($key, 5))))); + $headers[$key] = $value; + } else { + $headers[$key] = $value; + } + } + + return $headers; + } } \ No newline at end of file diff --git a/inc/SP/Http/XMLRPCResponseParse.class.php b/inc/SP/Http/XMLRPCResponseParse.class.php index eb5ebf28..4c44213d 100644 --- a/inc/SP/Http/XMLRPCResponseParse.class.php +++ b/inc/SP/Http/XMLRPCResponseParse.class.php @@ -41,15 +41,15 @@ abstract class XMLRPCResponseParse /** * @var DOMElement */ - private $_root; + private $root; /** * @var string */ - private $_xml; + private $xml; /** * @var array */ - private $_data = array(); + private $data = array(); /** * Constructor @@ -59,7 +59,7 @@ abstract class XMLRPCResponseParse public function __construct($xml) { try { - $this->_xml = $xml; + $this->xml = $xml; $dom = new DOMDocument(); $dom->loadXML($xml); @@ -68,7 +68,7 @@ abstract class XMLRPCResponseParse throw new \DOMException(_('Respuesta XML-RPC inválida')); } - $this->_root = $dom->documentElement; + $this->root = $dom->documentElement; } catch (\DOMException $e) { throw new InvalidArgumentException($e->getMessage(), $e->getCode()); } @@ -81,7 +81,7 @@ abstract class XMLRPCResponseParse */ public function getError() { - return $this->parseNodes($this->_root->getElementsByTagName('fault')); + return $this->parseNodes($this->root->getElementsByTagName('fault')); } /** @@ -107,7 +107,7 @@ abstract class XMLRPCResponseParse case 'fault': return $this->parseFault($node); case 'value': - $this->_data = $this->parseValues($node); + $this->data = $this->parseValues($node); break; default: $this->parseNodes($node->childNodes); @@ -259,9 +259,9 @@ abstract class XMLRPCResponseParse */ public function parseParams() { - $this->parseNodes($this->_root->getElementsByTagName('params')); + $this->parseNodes($this->root->getElementsByTagName('params')); - return $this->_data; + return $this->data; } /** @@ -271,6 +271,6 @@ abstract class XMLRPCResponseParse */ public function getXml() { - return $this->_xml; + return $this->xml; } } \ No newline at end of file diff --git a/inc/SP/Import/CsvImport.class.php b/inc/SP/Import/CsvImport.class.php index 9b8b16c0..3db5e2c2 100644 --- a/inc/SP/Import/CsvImport.class.php +++ b/inc/SP/Import/CsvImport.class.php @@ -45,7 +45,7 @@ class CsvImport extends CsvImportBase public function doImport() { try{ - $this->_file->readFileToArray(); + $this->file->readFileToArray(); $this->processAccounts(); } catch (SPException $e){ throw $e; diff --git a/inc/SP/Import/CsvImportBase.class.php b/inc/SP/Import/CsvImportBase.class.php index 20211fa7..d9aa4a16 100644 --- a/inc/SP/Import/CsvImportBase.class.php +++ b/inc/SP/Import/CsvImportBase.class.php @@ -25,6 +25,7 @@ namespace SP\Import; +use SP\Account\AccountData; use SP\Core\Crypt; use SP\Mgmt\Customer; use SP\Log\Log; @@ -43,15 +44,15 @@ abstract class CsvImportBase extends ImportBase /** * @var int */ - protected $_numFields = 7; + protected $numFields = 7; /** * @var array */ - protected $_mapFields = array(); + protected $mapFields = array(); /** * @var string */ - protected $_fieldDelimiter = ';'; + protected $fieldDelimiter = ';'; /** * Constructor @@ -62,7 +63,7 @@ abstract class CsvImportBase extends ImportBase public function __construct($file) { try { - $this->_file = $file; + $this->file = $file; } catch (SPException $e) { throw $e; } @@ -73,7 +74,7 @@ abstract class CsvImportBase extends ImportBase */ public function setFieldDelimiter($fieldDelimiter) { - $this->_fieldDelimiter = $fieldDelimiter; + $this->fieldDelimiter = $fieldDelimiter; } /** @@ -81,7 +82,7 @@ abstract class CsvImportBase extends ImportBase */ public function setNumFields($numFields) { - $this->_numFields = $numFields; + $this->numFields = $numFields; } /** @@ -89,7 +90,7 @@ abstract class CsvImportBase extends ImportBase */ public function setMapFields($mapFields) { - $this->_mapFields = $mapFields; + $this->mapFields = $mapFields; } /** @@ -101,15 +102,15 @@ abstract class CsvImportBase extends ImportBase { $line = 0; - $lines = $this->_file->getFileContent(); + $lines = $this->file->getFileContent(); foreach($lines as $data) { $line++; - $fields = explode($this->_fieldDelimiter, $data); + $fields = explode($this->fieldDelimiter, $data); $numfields = count($fields); // Comprobar el número de campos de la línea - if ($numfields !== $this->_numFields) { + if ($numfields !== $this->numFields) { throw new SPException( SPException::SP_CRITICAL, sprintf(_('El número de campos es incorrecto (%d)'), $numfields), @@ -133,16 +134,17 @@ abstract class CsvImportBase extends ImportBase $pass = Crypt::encryptData($password); // Crear la nueva cuenta - $this->setAccountName($accountName); - $this->setAccountLogin($login); - $this->setCategoryId($categoryId); - $this->setCustomerId($customerId); - $this->setAccountNotes($notes); - $this->setAccountUrl($url); - $this->setAccountPass($pass['data']); - $this->setAccountPassIV($pass['iv']); + $AccountData = new AccountData(); + $AccountData->setAccountName($accountName); + $AccountData->setAccountLogin($login); + $AccountData->setAccountCategoryId($categoryId); + $AccountData->setAccountCustomerId($customerId); + $AccountData->setAccountNotes($notes); + $AccountData->setAccountUrl($url); + $AccountData->setAccountPass($pass['data']); + $AccountData->setAccountIV($pass['iv']); - if (!$this->addAccount()) { + if (!$this->addAccount($AccountData)) { $log = new Log(_('Importar Cuentas')); $log->addDescription(_('Error importando cuenta')); $log->addDescription(sprintf(_('Error procesando línea %s'), $line)); diff --git a/inc/SP/Import/FileImport.class.php b/inc/SP/Import/FileImport.class.php index d30d6938..b1705eed 100644 --- a/inc/SP/Import/FileImport.class.php +++ b/inc/SP/Import/FileImport.class.php @@ -42,28 +42,28 @@ class FileImport * * @var string|array */ - protected $_fileContent = null; + protected $fileContent = null; /** * Archivo temporal utilizado en la subida HTML * * @var string */ - protected $_tmpFile = ''; + protected $tmpFile = ''; /** * Tipo Mime del archivo * * @var string */ - protected $_fileType = ''; + protected $fileType = ''; /** * @return string|array */ public function getFileContent() { - return $this->_fileContent; + return $this->fileContent; } /** @@ -71,7 +71,7 @@ class FileImport */ public function getTmpFile() { - return $this->_tmpFile; + return $this->tmpFile; } /** @@ -79,7 +79,7 @@ class FileImport */ public function getFileType() { - return $this->_fileType; + return $this->fileType; } @@ -122,10 +122,10 @@ class FileImport } // Variables con información del archivo - $this->_tmpFile = $fileData['tmp_name']; - $this->_fileType = $fileData['type']; + $this->tmpFile = $fileData['tmp_name']; + $this->fileType = $fileData['type']; - if (!file_exists($this->_tmpFile) || !is_readable($this->_tmpFile)) { + if (!file_exists($this->tmpFile) || !is_readable($this->tmpFile)) { // Registramos el máximo tamaño permitido por PHP Util::getMaxUpload(); @@ -144,9 +144,9 @@ class FileImport */ public function readFileToArray() { - $this->_fileContent = file($this->_tmpFile, FILE_SKIP_EMPTY_LINES); + $this->fileContent = file($this->tmpFile, FILE_SKIP_EMPTY_LINES); - if ($this->_fileContent === false){ + if ($this->fileContent === false){ throw new SPException( SPException::SP_CRITICAL, _('Error interno al leer el archivo'), @@ -162,9 +162,9 @@ class FileImport */ public function readFileToString() { - $this->_fileContent = file_get_contents($this->_tmpFile); + $this->fileContent = file_get_contents($this->tmpFile); - if ($this->_fileContent === false){ + if ($this->fileContent === false){ throw new SPException( SPException::SP_CRITICAL, _('Error interno al leer el archivo'), diff --git a/inc/SP/Import/Import.class.php b/inc/SP/Import/Import.class.php index 1661fbcf..99ba9a44 100644 --- a/inc/SP/Import/Import.class.php +++ b/inc/SP/Import/Import.class.php @@ -40,19 +40,19 @@ class Import /** * @var string */ - static $importPwd = ''; + public static $importPwd = ''; /** * @var int */ - static $defUser = 0; + public static $defUser = 0; /** * @var int */ - static $defGroup = 0; + public static $defGroup = 0; /** * @var string */ - static $csvDelimiter = ''; + public static $csvDelimiter = ''; /** * @param string $importPwd diff --git a/inc/SP/Import/ImportBase.class.php b/inc/SP/Import/ImportBase.class.php index 00e5f175..de6cba5d 100644 --- a/inc/SP/Import/ImportBase.class.php +++ b/inc/SP/Import/ImportBase.class.php @@ -26,6 +26,7 @@ namespace SP\Import; use SP\Account\Account; +use SP\Account\AccountData; use SP\Mgmt\Customer; use SP\Mgmt\Category; use SP\Core\Session; @@ -52,95 +53,47 @@ abstract class ImportBase * @var int */ public $userGroupId = 0; - /** - * Nombre de la cuenta. - * - * @var string - */ - protected $_accountName = ''; - /** - * Id del cliente. - * - * @var int - */ - protected $_customerId = 0; - /** - * Id de categoria. - * - * @var int - */ - protected $_categoryId = 0; - /** - * Login de la cuenta. - * - * @var string - */ - protected $_accountLogin = ''; - /** - * Url de la cuenta. - * - * @var string - */ - protected $_accountUrl = ''; - /** - * Notas de la cuenta. - * - * @var string - */ - protected $_accountNotes = ''; - /** - * Clave de la cuenta. - * - * @var string - */ - protected $_accountPass = ''; - /** - * IV de la clave de la cuenta. - * - * @var string - */ - protected $_accountPassIV = ''; /** * Nombre de la categoría. * * @var string */ - protected $_categoryName = ''; + protected $categoryName = ''; /** * Nombre del cliente. * * @var string */ - protected $_customerName = ''; + protected $customerName = ''; /** * Descrición de la categoría. * * @var string */ - protected $_categoryDescription = ''; + protected $categoryDescription = ''; /** * Descripción del cliente. * * @var string */ - protected $_customerDescription = ''; + protected $customerDescription = ''; /** * @var FileImport */ - protected $_file; + protected $file; /** * La clave de importación * * @var string */ - protected $_importPass; + protected $importPass; /** * @return string */ public function getImportPass() { - return $this->_importPass; + return $this->importPass; } /** @@ -148,9 +101,17 @@ abstract class ImportBase */ public function setImportPass($importPass) { - $this->_importPass = $importPass; + $this->importPass = $importPass; } + /** + * Iniciar la importación desde XML. + * + * @throws SPException + * @return bool + */ + public abstract function doImport(); + /** * Leer la cabecera del archivo XML y obtener patrones de aplicaciones conocidas. * @@ -158,7 +119,7 @@ abstract class ImportBase */ protected function parseFileHeader() { - $handle = @fopen($this->_file->getTmpFile(), "r"); + $handle = @fopen($this->file->getTmpFile(), "r"); $headersRegex = '/(KEEPASSX_DATABASE|revelationdata)/i'; if ($handle) { @@ -180,20 +141,13 @@ abstract class ImportBase return false; } - /** - * Iniciar la importación desde XML. - * - * @throws SPException - * @return bool - */ - public abstract function doImport(); - /** * Añadir una cuenta desde un archivo importado. * + * @param AccountData $AccountData * @return bool */ - protected function addAccount() + protected function addAccount(AccountData $AccountData) { if (is_null($this->getUserId()) || $this->getUserId() === 0) { $this->setUserId(Session::getUserId()); @@ -203,19 +157,9 @@ abstract class ImportBase $this->setUserGroupId(Session::getUserGroupId()); } - $account = new Account; - $account->setAccountName($this->getAccountName()); - $account->setAccountCustomerId($this->getCustomerId()); - $account->setAccountCategoryId($this->getCategoryId()); - $account->setAccountLogin($this->getAccountLogin()); - $account->setAccountUrl($this->getAccountUrl()); - $account->setAccountPass($this->getAccountPass()); - $account->setAccountIV($this->getAccountPassIV()); - $account->setAccountNotes($this->getAccountNotes()); - $account->setAccountUserId($this->getUserId()); - $account->setAccountUserGroupId($this->getUserGroupId()); + $Account = new Account($AccountData); - return $account->createAccount(); + return $Account->createAccount(); } /** @@ -250,136 +194,9 @@ abstract class ImportBase $this->userGroupId = $userGroupId; } - /** - * @return string - */ - public function getAccountName() - { - return $this->_accountName; - } - - /** - * @param string $_accountName - */ - public function setAccountName($_accountName) - { - $this->_accountName = $_accountName; - } - - /** - * @return int - */ - public function getCustomerId() - { - return $this->_customerId; - } - - /** - * @param int $_customerId - */ - public function setCustomerId($_customerId) - { - $this->_customerId = $_customerId; - } - - /** - * @return int - */ - public function getCategoryId() - { - return $this->_categoryId; - } - - /** - * @param int $_categoryId - */ - public function setCategoryId($_categoryId) - { - $this->_categoryId = $_categoryId; - } - - /** - * @return string - */ - public function getAccountLogin() - { - return $this->_accountLogin; - } - - /** - * @param string $_accountLogin - */ - public function setAccountLogin($_accountLogin) - { - $this->_accountLogin = $_accountLogin; - } - - /** - * @return string - */ - public function getAccountUrl() - { - return $this->_accountUrl; - } - - /** - * @param string $_accountUrl - */ - public function setAccountUrl($_accountUrl) - { - $this->_accountUrl = $_accountUrl; - } - - /** - * @return string - */ - public function getAccountPass() - { - return $this->_accountPass; - } - - /** - * @param string $_accountPass - */ - public function setAccountPass($_accountPass) - { - $this->_accountPass = $_accountPass; - } - - /** - * @return string - */ - public function getAccountPassIV() - { - return $this->_accountPassIV; - } - - /** - * @param string $_accountPassIV - */ - public function setAccountPassIV($_accountPassIV) - { - $this->_accountPassIV = $_accountPassIV; - } - - /** - * @return string - */ - public function getAccountNotes() - { - return $this->_accountNotes; - } - - /** - * @param string $_accountNotes - */ - public function setAccountNotes($_accountNotes) - { - $this->_accountNotes = $_accountNotes; - } - /** * Añadir una categoría y devolver el Id + * * @return int */ protected function addCategory() @@ -392,15 +209,15 @@ abstract class ImportBase */ public function getCategoryName() { - return $this->_categoryName; + return $this->categoryName; } /** - * @param string $_categoryName + * @param string $categoryName */ - public function setCategoryName($_categoryName) + public function setCategoryName($categoryName) { - $this->_categoryName = $_categoryName; + $this->categoryName = $categoryName; } /** @@ -408,7 +225,7 @@ abstract class ImportBase */ public function getCategoryDescription() { - return $this->_categoryDescription; + return $this->categoryDescription; } /** @@ -416,11 +233,12 @@ abstract class ImportBase */ public function setCategoryDescription($categoryDescription) { - $this->_categoryDescription = $categoryDescription; + $this->categoryDescription = $categoryDescription; } /** * Añadir un cliente y devolver el Id + * * @return int */ protected function addCustomer() @@ -433,15 +251,15 @@ abstract class ImportBase */ public function getCustomerName() { - return $this->_customerName; + return $this->customerName; } /** - * @param string $_customerName + * @param string $customerName */ - public function setCustomerName($_customerName) + public function setCustomerName($customerName) { - $this->_customerName = $_customerName; + $this->customerName = $customerName; } /** @@ -449,7 +267,7 @@ abstract class ImportBase */ public function getCustomerDescription() { - return $this->_customerDescription; + return $this->customerDescription; } /** @@ -457,6 +275,6 @@ abstract class ImportBase */ public function setCustomerDescription($customerDescription) { - $this->_customerDescription = $customerDescription; + $this->customerDescription = $customerDescription; } } \ No newline at end of file diff --git a/inc/SP/Import/KeepassImport.class.php b/inc/SP/Import/KeepassImport.class.php index dda5a264..fab42be7 100644 --- a/inc/SP/Import/KeepassImport.class.php +++ b/inc/SP/Import/KeepassImport.class.php @@ -25,6 +25,8 @@ namespace SP\Import; +use SimpleXMLElement; +use SP\Account\AccountData; use SP\Core\Crypt; defined('APP_ROOT') || die(_('No es posible acceder directamente a este archivo')); @@ -34,23 +36,32 @@ defined('APP_ROOT') || die(_('No es posible acceder directamente a este archivo' */ class KeepassImport extends XmlImportBase { + /** + * @var int + */ + private $customerId = 0; + /** + * @var int + */ + private $categoryId = 0; + /** * Iniciar la importación desde KeePass */ public function doImport() { $this->setCustomerName('KeePass'); - $this->setCustomerId($this->addCustomer()); + $this->customerId = $this->addCustomer(); - $this->processCategories($this->_xml->Root->Group); + $this->processCategories($this->xml->Root->Group); } /** * Obtener los grupos y procesar lan entradas de KeePass. * - * @param \SimpleXMLElement $xml El objeto XML del archivo de KeePass + * @param SimpleXMLElement $xml El objeto XML del archivo de KeePass */ - protected function processCategories(\SimpleXMLElement $xml) + protected function processCategories(SimpleXMLElement $xml) { foreach ($xml as $node) { if ($node->Group) { @@ -59,7 +70,7 @@ class KeepassImport extends XmlImportBase if ($node->Group->Entry) { // Crear la categoría $this->setCategoryName($group->Name); - $this->setCategoryId($this->addCategory()); + $this->categoryId = $this->addCategory(); // Crear cuentas $this->processAccounts($group->Entry); @@ -75,7 +86,7 @@ class KeepassImport extends XmlImportBase if ($node->Entry) { // Crear la categoría $this->setCategoryName($node->Name); - $this->setCategoryId($this->addCategory()); + $this->categoryId = $this->addCategory(); // Crear cuentas $this->processAccounts($node->Entry); @@ -86,36 +97,41 @@ class KeepassImport extends XmlImportBase /** * Obtener los datos de las entradas de KeePass. * - * @param \SimpleXMLElement $entries El objeto XML con las entradas + * @param SimpleXMLElement $entries El objeto XML con las entradas */ - protected function processAccounts(\SimpleXMLElement $entries) + protected function processAccounts(SimpleXMLElement $entries) { foreach ($entries as $entry) { + $AccountData = new AccountData(); + foreach ($entry->String as $account) { $value = (isset($account->Value)) ? (string)$account->Value : ''; switch ($account->Key) { case 'Notes': - $this->setAccountNotes($value); + $AccountData->setAccountNotes($value); break; case 'Password': $passData = Crypt::encryptData($value); - $this->setAccountPass($passData['data']); - $this->setAccountPassIV($passData['iv']); + $AccountData->setAccountPass($passData['data']); + $AccountData->setAccountIV($passData['iv']); break; case 'Title': - $this->setAccountName($value); + $AccountData->setAccountName($value); break; case 'URL': - $this->setAccountUrl($value); + $AccountData->setAccountUrl($value); break; case 'UserName': - $this->setAccountLogin($value); + $AccountData->setAccountLogin($value); break; } } - $this->addAccount(); + $AccountData->setAccountCategoryId($this->categoryId); + $AccountData->setAccountCustomerId($this->customerId); + + $this->addAccount($AccountData); } } } \ No newline at end of file diff --git a/inc/SP/Import/KeepassXImport.class.php b/inc/SP/Import/KeepassXImport.class.php index 78ac97b0..fb065630 100644 --- a/inc/SP/Import/KeepassXImport.class.php +++ b/inc/SP/Import/KeepassXImport.class.php @@ -25,6 +25,8 @@ namespace SP\Import; +use SimpleXMLElement; +use SP\Account\AccountData; use SP\Core\Crypt; use SP\Core\SPException; @@ -35,6 +37,15 @@ defined('APP_ROOT') || die(_('No es posible acceder directamente a este archivo' */ class KeepassXImport extends XmlImportBase { + /** + * @var int + */ + private $customerId = 0; + /** + * @var int + */ + private $categoryId = 0; + /** * Iniciar la importación desde KeePassX. * @@ -44,18 +55,17 @@ class KeepassXImport extends XmlImportBase public function doImport() { $this->setCustomerName('KeePassX'); - $this->setCustomerId($this->addCustomer()); + $this->customerId = $this->addCustomer(); - self::processCategories($this->_xml); + self::processCategories($this->xml); } - /** * Obtener los grupos y procesar lan entradas de KeePass. * - * @param \SimpleXMLElement $xml con objeto XML del archivo de KeePass + * @param SimpleXMLElement $xml con objeto XML del archivo de KeePass */ - protected function processCategories(\SimpleXMLElement $xml) + protected function processCategories(SimpleXMLElement $xml) { foreach ($xml as $node) { if ($node->group) { @@ -64,7 +74,7 @@ class KeepassXImport extends XmlImportBase if ($node->group->entry) { // Crear la categoría $this->setCategoryName($group->title); - $this->setCategoryId($this->addCategory()); + $this->categoryId = $this->addCategory(); // Crear cuentas $this->processAccounts($group->entry); @@ -80,7 +90,7 @@ class KeepassXImport extends XmlImportBase if ($node->entry) { // Crear la categoría $this->setCategoryName($node->title); - $this->setCategoryId($this->addCategory()); + $this->categoryId = $this->addCategory(); // Crear cuentas $this->processAccounts($node->entry); @@ -91,10 +101,9 @@ class KeepassXImport extends XmlImportBase /** * Obtener los datos de las entradas de KeePass. * - * @param \SimpleXMLElement $entries El objeto XML con las entradas - * @param string $groupName con nombre del grupo a procesar + * @param SimpleXMLElement $entries El objeto XML con las entradas */ - protected function processAccounts(\SimpleXMLElement $entries, $groupName) + protected function processAccounts(SimpleXMLElement $entries) { foreach ($entries as $entry) { $notes = (isset($entry->comment)) ? (string)$entry->comment : ''; @@ -105,14 +114,17 @@ class KeepassXImport extends XmlImportBase $passData = Crypt::encryptData($password); - $this->setAccountPass($passData['data']); - $this->setAccountPassIV($passData['iv']); - $this->setAccountNotes($notes); - $this->setAccountName($name); - $this->setAccountUrl($url); - $this->setAccountLogin($username); + $AccountData = new AccountData(); + $AccountData->setAccountPass($passData['data']); + $AccountData->setAccountIV($passData['iv']); + $AccountData->setAccountNotes($notes); + $AccountData->setAccountName($name); + $AccountData->setAccountUrl($url); + $AccountData->setAccountLogin($username); + $AccountData->setAccountCustomerId($this->customerId); + $AccountData->setAccountCategoryId($this->categoryId); - $this->addAccount(); + $this->addAccount($AccountData); } } } \ No newline at end of file diff --git a/inc/SP/Import/Migrate.class.php b/inc/SP/Import/Migrate.class.php index 2be21ada..d60c0879 100644 --- a/inc/SP/Import/Migrate.class.php +++ b/inc/SP/Import/Migrate.class.php @@ -41,11 +41,11 @@ defined('APP_ROOT') || die(_('No es posible acceder directamente a este archivo' */ class Migrate { - private static $_dbc; // Database connection - private static $_customersByName; - private static $_currentQuery; - private static $_result = array(); - private static $_oldConfig = array(); + private static $DB; // Database connection + private static $customersByName; + private static $currentQuery; + private static $result = array(); + private static $oldConfig = array(); /** * Iniciar migración desde phpPMS. @@ -89,18 +89,18 @@ class Migrate self::migrateUsersGroups(); self::migrateConfig(); } catch (SPException $e) { - self::$_result['error'][] = array( + self::$result['error'][] = array( 'type' => $e->getType(), 'description' => $e->getMessage(), 'hint' => $e->getHint() ); - return (self::$_result); + return (self::$result); } - self::$_result['ok'][] = _('Importación finalizada'); - self::$_result['ok'][] = _('Revise el registro de eventos para más detalles'); + self::$result['ok'][] = _('Importación finalizada'); + self::$result['ok'][] = _('Revise el registro de eventos para más detalles'); - return (self::$_result); + return (self::$result); } /** @@ -117,7 +117,7 @@ class Migrate { try { $dsn = 'mysql:host=' . $dbhost . ';dbname=' . $dbname . ';dbport=' . $dbport . ';charset=utf8'; - self::$_dbc = new \PDO($dsn, $dbadmin, $dbpass); + self::$DB = new \PDO($dsn, $dbadmin, $dbpass); } catch (\PDOException $e) { throw new SPException(SPException::SP_CRITICAL , _('No es posible conectar con la BD') @@ -138,7 +138,7 @@ class Migrate . 'WHERE table_schema = \'' . $dbname . '\' ' . 'AND table_name = \'usrData\' LIMIT 1'; - return (intval(self::$_dbc->query($query)->fetchColumn()) === 0); + return (intval(self::$DB->query($query)->fetchColumn()) === 0); } /** @@ -148,13 +148,13 @@ class Migrate */ private static function checkSourceVersion() { - if (!isset(self::$_oldConfig['version'])) { + if (!isset(self::$oldConfig['version'])) { self::getSourceConfig(); } - if (self::$_oldConfig['version'] != "0.973b") { + if (self::$oldConfig['version'] != "0.973b") { throw new SPException(SPException::SP_CRITICAL, - _('La versión no es compatible') . '(' . self::$_oldConfig['version'] . ')', + _('La versión no es compatible') . '(' . self::$oldConfig['version'] . ')', _('Actualice a la última versión de phpPMS')); } } @@ -169,7 +169,7 @@ class Migrate $query = 'SELECT vacValue as value,vacParameter as parameter FROM config'; try { - self::parseSourceConfig(self::$_dbc->query($query)); + self::parseSourceConfig(self::$DB->query($query)); } catch (\PDOException $e) { throw new SPException(SPException::SP_CRITICAL, @@ -197,7 +197,7 @@ class Migrate } // Guardar la configuración anterior - self::$_oldConfig[$config['parameter']] = $value; + self::$oldConfig[$config['parameter']] = $value; } /** @@ -310,7 +310,7 @@ class Migrate $query = 'SELECT DISTINCT vacCliente FROM accounts'; try { - foreach (self::$_dbc->query($query) as $row) { + foreach (self::$DB->query($query) as $row) { $customers[] = trim($row['vacCliente']); } @@ -351,7 +351,7 @@ class Migrate $num = 0; try { - foreach (self::$_dbc->query($query) as $row) { + foreach (self::$DB->query($query) as $row) { if (self::insertAccounts($row)) { $num++; } @@ -378,17 +378,17 @@ class Migrate */ private static function insertAccounts($account) { - if (!is_array(self::$_customersByName)) { + if (!is_array(self::$customersByName)) { $customers = Customer::getCustomers(NULL, true); - self::$_customersByName = array_flip($customers); + self::$customersByName = array_flip($customers); } $customer = trim($account['vacCliente']); - if (array_key_exists($customer, self::$_customersByName)) { - $customerId = self::$_customersByName[$customer]; + if (array_key_exists($customer, self::$customersByName)) { + $customerId = self::$customersByName[$customer]; } else { - self::$_result['error'][] = _('Cliente no encontrado') . ": " . $account['vacCliente']; + self::$result['error'][] = _('Cliente no encontrado') . ": " . $account['vacCliente']; return false; } @@ -431,7 +431,7 @@ class Migrate $Data->addParam($account['datChanged'], 'dateEdit'); if (DB::getQuery($Data) === false) { - self::$_currentQuery = DBUtil::escape($query); + self::$currentQuery = DBUtil::escape($query); throw new SPException(SPException::SP_CRITICAL, _('Error al migrar cuenta'), DB::$txtError); @@ -454,7 +454,7 @@ class Migrate $num = 0; try { - foreach(self::$_dbc->query($query) as $row){ + foreach(self::$DB->query($query) as $row){ if (self::insertAccountsGroups($row)) { $num++; } @@ -531,7 +531,7 @@ class Migrate $num = 0; try { - foreach(self::$_dbc->query($query) as $row){ + foreach(self::$DB->query($query) as $row){ if (self::insertAccountsHistory($row)) { $num++; } @@ -540,7 +540,7 @@ class Migrate } catch(\PDOException $e){ throw new SPException(SPException::SP_CRITICAL, _('Error al obtener el historico de cuentas'), - self::$_dbc->error); + self::$DB->error); } $Log = new Log(_('Importar Histórico de Cuentas')); @@ -558,15 +558,15 @@ class Migrate */ private static function insertAccountsHistory($accountHistory) { - if (!is_array(self::$_customersByName)) { + if (!is_array(self::$customersByName)) { $customers = Customer::getCustomers(null, true); - self::$_customersByName = array_flip($customers); + self::$customersByName = array_flip($customers); } $customer = trim($accountHistory['vacCliente']); - if (array_key_exists($customer, self::$_customersByName)) { - $customerId = self::$_customersByName[$customer]; + if (array_key_exists($customer, self::$customersByName)) { + $customerId = self::$customersByName[$customer]; } else { return false; } @@ -641,7 +641,7 @@ class Migrate $num = 0; try { - foreach(self::$_dbc->query($query) as $row){ + foreach(self::$DB->query($query) as $row){ if (self::insertAccountsFiles($row)) { $num++; } @@ -650,7 +650,7 @@ class Migrate } catch(\PDOException $e){ throw new SPException(SPException::SP_CRITICAL, _('Error al obtener los archivos de cuentas'), - self::$_dbc->error); + self::$DB->error); } $Log = new Log(_('Importar Archivos de Cuentas')); @@ -708,7 +708,7 @@ class Migrate $num = 0; try { - foreach(self::$_dbc->query($query) as $row){ + foreach(self::$DB->query($query) as $row){ if (self::insertAccountsCategories($row)) { $num++; } @@ -717,7 +717,7 @@ class Migrate } catch(\PDOException $e){ throw new SPException(SPException::SP_CRITICAL, _('Error al obtener las categorías de cuentas'), - self::$_dbc->error); + self::$DB->error); } $Log = new Log(_('Importar Categorías de Cuentas')); @@ -784,7 +784,7 @@ class Migrate $num = 0; try { - foreach(self::$_dbc->query($query) as $row){ + foreach(self::$DB->query($query) as $row){ if (self::insertUsers($row)) { $num++; } @@ -793,7 +793,7 @@ class Migrate } catch(\PDOException $e){ throw new SPException(SPException::SP_CRITICAL, _('Error al obtener los usuarios'), - self::$_dbc->error); + self::$DB->error); } $Log = new Log(_('Importar Usuarios')); @@ -876,7 +876,7 @@ class Migrate $num = 0; try { - foreach(self::$_dbc->query($query) as $row){ + foreach(self::$DB->query($query) as $row){ if (self::insertUsersGroups($row)) { $num++; } @@ -885,7 +885,7 @@ class Migrate } catch(\PDOException $e){ throw new SPException(SPException::SP_CRITICAL, _('Error al obtener los grupos de usuarios'), - self::$_dbc->error); + self::$DB->error); } $Log = new Log(_('Importar Grupos de Usuarios')); @@ -949,15 +949,16 @@ class Migrate 'lastupdatempass', 'passwordsalt'); - $totalParams = count(self::$_oldConfig); + $totalParams = count(self::$oldConfig); $num = 0; // Guardar la nueva configuración - foreach (self::$_oldConfig as $key => $value) { + foreach (self::$oldConfig as $key => $value) { if (array_key_exists($key, $skip)) { continue; } - Config::setValue($key, $value); + // FIXME +// Config::setValue($key, $value); $num++; } diff --git a/inc/SP/Import/SyspassImport.class.php b/inc/SP/Import/SyspassImport.class.php index f9e90d51..c57e74d1 100644 --- a/inc/SP/Import/SyspassImport.class.php +++ b/inc/SP/Import/SyspassImport.class.php @@ -25,6 +25,7 @@ namespace SP\Import; +use SP\Account\AccountData; use SP\Core\Crypt; use SP\Core\SPException; @@ -40,13 +41,13 @@ class SyspassImport extends XmlImportBase * * @var array */ - private $_categories = array(); + private $categories = array(); /** * Mapeo de clientes. * * @var array */ - private $_customers = array(); + private $customers = array(); /** * Iniciar la importación desde sysPass. @@ -76,7 +77,7 @@ class SyspassImport extends XmlImportBase */ protected function detectEncrypted() { - return ($this->_xmlDOM->getElementsByTagName('Encrypted')->length > 0); + return ($this->xmlDOM->getElementsByTagName('Encrypted')->length > 0); } /** @@ -84,7 +85,8 @@ class SyspassImport extends XmlImportBase */ protected function processEncrypted() { - foreach ($this->_xmlDOM->getElementsByTagName('Data') as $node) { + foreach ($this->xmlDOM->getElementsByTagName('Data') as $node) { + /** @var $node \DOMNode */ $data = base64_decode($node->nodeValue); $iv = base64_decode($node->getAttribute('iv')); @@ -93,14 +95,14 @@ class SyspassImport extends XmlImportBase $newXmlData = new \DOMDocument(); // $newXmlData->preserveWhiteSpace = true; $newXmlData->loadXML($xmlDecrypted); - $newNode = $this->_xmlDOM->importNode($newXmlData->documentElement, TRUE); + $newNode = $this->xmlDOM->importNode($newXmlData->documentElement, TRUE); - $this->_xmlDOM->documentElement->appendChild($newNode); + $this->xmlDOM->documentElement->appendChild($newNode); } // Eliminar los datos encriptados tras desencriptar los mismos - if ($this->_xmlDOM->getElementsByTagName('Data')->length > 0) { - $nodeData = $this->_xmlDOM->getElementsByTagName('Encrypted')->item(0); + if ($this->xmlDOM->getElementsByTagName('Data')->length > 0) { + $nodeData = $this->xmlDOM->getElementsByTagName('Encrypted')->item(0); $nodeData->parentNode->removeChild($nodeData); } } @@ -110,11 +112,11 @@ class SyspassImport extends XmlImportBase */ protected function processCategories() { - if ($this->_xmlDOM->getElementsByTagName('Categories')->length === 0) { + if ($this->xmlDOM->getElementsByTagName('Categories')->length === 0) { throw new SPException(SPException::SP_WARNING, _('Formato de XML inválido'), _('No hay categorías para importar')); } - foreach ($this->_xmlDOM->getElementsByTagName('Category') as $category) { + foreach ($this->xmlDOM->getElementsByTagName('Category') as $category) { foreach ($category->childNodes as $node) { switch ($node->nodeName) { case 'name': @@ -126,7 +128,7 @@ class SyspassImport extends XmlImportBase } } - $this->_categories[$category->getAttribute('id')] = $this->addCategory(); + $this->categories[$category->getAttribute('id')] = $this->addCategory(); } } @@ -135,11 +137,11 @@ class SyspassImport extends XmlImportBase */ protected function processCustomers() { - if ($this->_xmlDOM->getElementsByTagName('Customers')->length === 0) { + if ($this->xmlDOM->getElementsByTagName('Customers')->length === 0) { throw new SPException(SPException::SP_WARNING, _('Formato de XML inválido'), _('No hay clientes para importar')); } - foreach ($this->_xmlDOM->getElementsByTagName('Customer') as $customer) { + foreach ($this->xmlDOM->getElementsByTagName('Customer') as $customer) { foreach ($customer->childNodes as $node) { switch ($node->nodeName) { case 'name': @@ -151,7 +153,7 @@ class SyspassImport extends XmlImportBase } } - $this->_customers[$customer->getAttribute('id')] = $this->addCustomer(); + $this->customers[$customer->getAttribute('id')] = $this->addCustomer(); } } @@ -160,41 +162,43 @@ class SyspassImport extends XmlImportBase */ protected function processAccounts() { - if ($this->_xmlDOM->getElementsByTagName('Accounts')->length === 0) { + if ($this->xmlDOM->getElementsByTagName('Accounts')->length === 0) { throw new SPException(SPException::SP_WARNING, _('Formato de XML inválido'), _('No hay cuentas para importar')); } - foreach ($this->_xmlDOM->getElementsByTagName('Account') as $account) { + foreach ($this->xmlDOM->getElementsByTagName('Account') as $account) { + $AccountData = new AccountData(); + foreach ($account->childNodes as $node) { switch ($node->nodeName) { case 'name'; - $this->setAccountName($node->nodeValue); + $AccountData->setAccountName($node->nodeValue); break; case 'login'; - $this->setAccountLogin($node->nodeValue); + $AccountData->setAccountLogin($node->nodeValue); break; case 'categoryId'; - $this->setCategoryId($this->_categories[(int)$node->nodeValue]); + $AccountData->setAccountCategoryId($this->categories[(int)$node->nodeValue]); break; case 'customerId'; - $this->setCustomerId($this->_customers[(int)$node->nodeValue]); + $AccountData->setAccountCustomerId($this->customers[(int)$node->nodeValue]); break; case 'url'; - $this->setAccountUrl($node->nodeValue); + $AccountData->setAccountUrl($node->nodeValue); break; case 'pass'; - $this->setAccountPass(base64_decode($node->nodeValue)); + $AccountData->setAccountPass(base64_decode($node->nodeValue)); break; case 'passiv'; - $this->setAccountPassIV(base64_decode($node->nodeValue)); + $AccountData->setAccountIV(base64_decode($node->nodeValue)); break; case 'notes'; - $this->setAccountNotes($node->nodeValue); + $AccountData->setAccountNotes($node->nodeValue); break; } } - $this->addAccount(); + $this->addAccount($AccountData); } } } \ No newline at end of file diff --git a/inc/SP/Import/XmlImport.class.php b/inc/SP/Import/XmlImport.class.php index 19e23bd8..ad4c23c0 100644 --- a/inc/SP/Import/XmlImport.class.php +++ b/inc/SP/Import/XmlImport.class.php @@ -51,13 +51,13 @@ class XmlImport extends XmlImportBase switch ($format) { case 'syspass': - $import = new SyspassImport($this->_file); + $import = new SyspassImport($this->file); break; case 'keepass': - $import = new KeepassImport($this->_file); + $import = new KeepassImport($this->file); break; case 'keepassx': - $import = new KeepassXImport($this->_file); + $import = new KeepassXImport($this->file); break; } diff --git a/inc/SP/Import/XmlImportBase.class.php b/inc/SP/Import/XmlImportBase.class.php index 078cb787..fc9e8b56 100644 --- a/inc/SP/Import/XmlImportBase.class.php +++ b/inc/SP/Import/XmlImportBase.class.php @@ -39,11 +39,11 @@ abstract class XmlImportBase extends ImportBase /** * @var \SimpleXMLElement */ - protected $_xml; + protected $xml; /** * @var \DOMDocument */ - protected $_xmlDOM; + protected $xmlDOM; /** * Constructor @@ -54,7 +54,7 @@ abstract class XmlImportBase extends ImportBase public function __construct($file) { try { - $this->_file = $file; + $this->file = $file; $this->readXMLFile(); } catch (SPException $e) { throw $e; @@ -69,13 +69,13 @@ abstract class XmlImportBase extends ImportBase */ protected function readXMLFile() { - $this->_xml = simplexml_load_file($this->_file->getTmpFile()); + $this->xml = simplexml_load_file($this->file->getTmpFile()); // Cargar el XML con DOM - $this->_xmlDOM = new \DOMDocument(); - $this->_xmlDOM->load($this->_file->getTmpFile()); + $this->xmlDOM = new \DOMDocument(); + $this->xmlDOM->load($this->file->getTmpFile()); - if ($this->_xml === false) { + if ($this->xml === false) { throw new SPException( SPException::SP_CRITICAL, _('Error interno'), @@ -91,9 +91,9 @@ abstract class XmlImportBase extends ImportBase */ public function detectXMLFormat() { - if ($this->_xml->Meta->Generator == 'KeePass') { + if ($this->xml->Meta->Generator == 'KeePass') { return 'keepass'; - } else if ($this->_xml->Meta->Generator == 'sysPass') { + } else if ($this->xml->Meta->Generator == 'sysPass') { return 'syspass'; } else if ($xmlApp = $this->parseFileHeader()) { switch ($xmlApp) { diff --git a/inc/SP/Log/ActionLog.class.php b/inc/SP/Log/ActionLog.class.php index 26a2ab9f..7b070770 100644 --- a/inc/SP/Log/ActionLog.class.php +++ b/inc/SP/Log/ActionLog.class.php @@ -45,27 +45,27 @@ abstract class ActionLog extends LogLevel * * @var string */ - protected $_action = __CLASS__; + protected $action = __CLASS__; /** * Detalles de la acción * * @var array */ - protected $_description = null; + protected $description = null; /** * Formato de nueva línea en HTML * * @var bool */ - protected $_newLineHtml = false; + protected $newLineHtml = false; /** * @var string */ - protected $_logLevel = ''; + protected $logLevel = ''; /** * @var array */ - protected $_details = null; + protected $details = null; /** * Contructor @@ -84,7 +84,7 @@ abstract class ActionLog extends LogLevel $this->addDescription($description); } - $this->_logLevel = $level; + $this->logLevel = $level; } /** @@ -94,7 +94,7 @@ abstract class ActionLog extends LogLevel */ public function addDescription($description = '') { - $this->_description[] = $this->formatString($description); + $this->description[] = $this->formatString($description); } /** @@ -113,7 +113,7 @@ abstract class ActionLog extends LogLevel */ public function getLogLevel() { - return strtoupper($this->_logLevel); + return strtoupper($this->logLevel); } /** @@ -121,7 +121,7 @@ abstract class ActionLog extends LogLevel */ public function setLogLevel($logLevel) { - $this->_logLevel = $logLevel; + $this->logLevel = $logLevel; } /** @@ -131,17 +131,17 @@ abstract class ActionLog extends LogLevel */ public function getDetails() { - if (is_null($this->_details)) { + if (is_null($this->details)) { return ''; } - if (count($this->_details) > 1) { - $newline = ($this->_newLineHtml === false) ? PHP_EOL : self::NEWLINE_HTML; + if (count($this->details) > 1) { + $newline = ($this->newLineHtml === false) ? PHP_EOL : self::NEWLINE_HTML; - return implode($newline, $this->_details); + return implode($newline, $this->details); } - return $this->_details[0]; + return $this->details[0]; } /** @@ -151,7 +151,7 @@ abstract class ActionLog extends LogLevel */ public function getAction() { - return $this->_action; + return $this->action; } /** @@ -161,7 +161,7 @@ abstract class ActionLog extends LogLevel */ public function setAction($action) { - $this->_action = $this->formatString($action); + $this->action = $this->formatString($action); } /** @@ -171,17 +171,17 @@ abstract class ActionLog extends LogLevel */ public function getDescription() { - if (is_null($this->_description)) { + if (is_null($this->description)) { return ''; } - if (count($this->_description) > 1) { - $newline = ($this->_newLineHtml === false) ? PHP_EOL : self::NEWLINE_HTML; + if (count($this->description) > 1) { + $newline = ($this->newLineHtml === false) ? PHP_EOL : self::NEWLINE_HTML; - return implode($newline, $this->_description); + return implode($newline, $this->description); } - return $this->_description[0]; + return $this->description[0]; } /** @@ -192,7 +192,7 @@ abstract class ActionLog extends LogLevel */ public function addDetails($key, $value) { - $this->_details[] = sprintf('%s: %s', $this->formatString($key), $this->formatString($value)); + $this->details[] = sprintf('%s: %s', $this->formatString($key), $this->formatString($value)); } /** @@ -202,7 +202,7 @@ abstract class ActionLog extends LogLevel */ public function setNewLineHtml($bool) { - $this->_newLineHtml = $bool; + $this->newLineHtml = $bool; } /** @@ -210,6 +210,6 @@ abstract class ActionLog extends LogLevel */ public function resetDescription() { - $this->_description = null; + $this->description = null; } } \ No newline at end of file diff --git a/inc/SP/Log/Email.class.php b/inc/SP/Log/Email.class.php index eb13d2d3..8b6e5fac 100644 --- a/inc/SP/Log/Email.class.php +++ b/inc/SP/Log/Email.class.php @@ -68,7 +68,7 @@ class Email $body[] = Html::strongText(_('Acción') . ": ") . utf8_decode($log->getAction()); $body[] = Html::strongText(_('Realizado por') . ": ") . $performer . ' (' . $_SERVER['REMOTE_ADDR'] . ')'; - $Mail->addCC(Config::getValue('mail_from')); + $Mail->addCC(Config::getConfig()->getMailFrom()); } $body[] = utf8_decode($log->getDescription()); @@ -96,7 +96,7 @@ class Email $Log->addDescription(_('Destinatario') . ': ' . $mailTo); if ($isEvent === true){ - $Log->addDescription(_('CC') . ': ' . Config::getValue('mail_from')); + $Log->addDescription(_('CC') . ': ' . Config::getConfig()->getMailFrom()); } $Log->writeLog(); @@ -114,14 +114,14 @@ class Email private static function getEmailObject($mailTo, $action) { $appName = Util::getAppInfo('appname'); - $mailFrom = Config::getValue('mail_from'); - $mailServer = Config::getValue('mail_server'); - $mailPort = Config::getValue('mail_port', 25); - $mailAuth = Config::getValue('mail_authenabled', FALSE); + $mailFrom = Config::getConfig()->getMailFrom(); + $mailServer = Config::getConfig()->getMailServer(); + $mailPort = Config::getConfig()->getMailPort(); + $mailAuth = Config::getConfig()->isMailAuthenabled(); if ($mailAuth) { - $mailUser = Config::getValue('mail_user'); - $mailPass = Config::getValue('mail_pass'); + $mailUser = Config::getConfig()->getMailUser(); + $mailPass = Config::getConfig()->getMailPass(); } if (!$mailServer) { @@ -143,7 +143,7 @@ class Email $Mail->Username = $mailUser; $Mail->Password = $mailPass; } - $Mail->SMTPSecure = strtolower(Config::getValue('mail_security')); + $Mail->SMTPSecure = strtolower(Config::getConfig()->getMailSecurity()); //$mail->SMTPDebug = 2; //$mail->Debugoutput = 'error_log'; diff --git a/inc/SP/Log/Log.class.php b/inc/SP/Log/Log.class.php index a9a84bd8..d2291177 100644 --- a/inc/SP/Log/Log.class.php +++ b/inc/SP/Log/Log.class.php @@ -26,6 +26,7 @@ namespace SP\Log; use SP\Config\Config; +use SP\Core\Init; use SP\Storage\DB; use SP\Core\Session; use SP\Storage\QueryData; @@ -132,7 +133,9 @@ class Log extends ActionLog */ public function writeLog($resetDescription = false) { - if (defined('IS_INSTALLER') && IS_INSTALLER === 1) { + if ((defined('IS_INSTALLER') && IS_INSTALLER === 1) + || Init::$DB_STATUS === 0 + ) { error_log('Action: ' . $this->getAction() . ' -- Description: ' . $this->getDescription()); return false; } @@ -141,7 +144,7 @@ class Log extends ActionLog return false; } - if (Checks::syslogIsEnabled()){ + if (Checks::syslogIsEnabled()) { $this->sendToSyslog(); } diff --git a/inc/SP/Log/Syslog.class.php b/inc/SP/Log/Syslog.class.php index 58cbe979..8b33f734 100644 --- a/inc/SP/Log/Syslog.class.php +++ b/inc/SP/Log/Syslog.class.php @@ -103,8 +103,8 @@ class Syslog extends AbstractLogger */ private function logRemote($message) { - $server = Config::getValue('syslog_server'); - $port = Config::getValue('syslog_port', 514); + $server = Config::getConfig()->getSyslogServer(); + $port = Config::getConfig()->getSyslogPort(); if (!empty($server)) { $syslogMsg = date('M d H:i:s ') . "sysPass web: $message"; diff --git a/inc/SP/Mgmt/CustomFieldDef.class.php b/inc/SP/Mgmt/CustomFieldDef.class.php index 646a8252..255b4904 100644 --- a/inc/SP/Mgmt/CustomFieldDef.class.php +++ b/inc/SP/Mgmt/CustomFieldDef.class.php @@ -49,9 +49,9 @@ class CustomFieldDef extends CustomFieldsBase throw new \InvalidArgumentException(_('Parámetros incorrectos')); } - $this->_name = $name; - $this->_type = $type; - $this->_module = $module; + $this->name = $name; + $this->type = $type; + $this->module = $module; } /** @@ -146,7 +146,7 @@ class CustomFieldDef extends CustomFieldsBase $Data = new QueryData(); $Data->setQuery($query); - $Data->addParam($this->_module, 'module'); + $Data->addParam($this->module, 'module'); $Data->addParam(serialize($this), 'field'); $queryRes = DB::getQuery($Data); @@ -161,7 +161,7 @@ class CustomFieldDef extends CustomFieldsBase */ public function updateCustomField() { - $curField = self::getCustomFields($this->_id, true); + $curField = self::getCustomFields($this->id, true); $query = 'UPDATE customFieldsDef SET ' . 'customfielddef_module = :module, ' . @@ -170,14 +170,14 @@ class CustomFieldDef extends CustomFieldsBase $Data = new QueryData(); $Data->setQuery($query); - $Data->addParam($this->_id, 'id'); - $Data->addParam($this->_module, 'module'); + $Data->addParam($this->id, 'id'); + $Data->addParam($this->module, 'module'); $Data->addParam(serialize($this), 'field'); $queryRes = DB::getQuery($Data); - if ($queryRes && $curField->customfielddef_module !== $this->_module) { - $queryRes = CustomFields::updateCustomFieldModule($this->_module, $this->_id); + if ($queryRes && $curField->customfielddef_module !== $this->module) { + $queryRes = CustomFields::updateCustomFieldModule($this->module, $this->id); } return $queryRes; @@ -249,6 +249,6 @@ class CustomFieldDef extends CustomFieldsBase */ public function setId($id) { - $this->_id = $id; + $this->id = $id; } } \ No newline at end of file diff --git a/inc/SP/Mgmt/CustomFields.class.php b/inc/SP/Mgmt/CustomFields.class.php index f1d8d48c..cda83d03 100644 --- a/inc/SP/Mgmt/CustomFields.class.php +++ b/inc/SP/Mgmt/CustomFields.class.php @@ -44,11 +44,11 @@ class CustomFields extends CustomFieldsBase /** * @var string */ - private $_value = ''; + private $value = ''; /** * @var int */ - private $_itemId = 0; + private $itemId = 0; /** * @param $customFieldDefId @@ -68,12 +68,12 @@ class CustomFields extends CustomFieldsBase $field = Util::castToClass('SP\Mgmt\CustomFieldDef', $field); } - $this->_id = $customFieldDefId; - $this->_module = $fieldDef->customfielddef_module; - $this->_name = $field->getName(); - $this->_type = $field->getType(); - $this->_itemId = $itemId; - $this->_value = $value; + $this->id = $customFieldDefId; + $this->module = $fieldDef->customfielddef_module; + $this->name = $field->getName(); + $this->type = $field->getType(); + $this->itemId = $itemId; + $this->value = $value; } /** @@ -377,7 +377,7 @@ class CustomFields extends CustomFieldsBase */ public function getItemId() { - return $this->_itemId; + return $this->itemId; } /** @@ -385,7 +385,7 @@ class CustomFields extends CustomFieldsBase */ public function setItemId($itemId) { - $this->_itemId = $itemId; + $this->itemId = $itemId; } /** @@ -396,15 +396,15 @@ class CustomFields extends CustomFieldsBase */ public function updateCustomField() { - if (!self::checkCustomFieldExists($this->_module, $this->_itemId, $this->_id)) { + if (!self::checkCustomFieldExists($this->module, $this->itemId, $this->id)) { return $this->addCustomField(); } - if (empty($this->_value)) { - return self::deleteCustomFieldForItem($this->_itemId, $this->_module); + if (empty($this->value)) { + return self::deleteCustomFieldForItem($this->itemId, $this->module); } - $cryptData = Crypt::encryptData($this->_value); + $cryptData = Crypt::encryptData($this->value); $query = 'UPDATE customFieldsData SET ' . 'customfielddata_data = :data, ' . @@ -415,9 +415,9 @@ class CustomFields extends CustomFieldsBase $Data = new QueryData(); $Data->setQuery($query); - $Data->addParam($this->_itemId, 'itemid'); - $Data->addParam($this->_module, 'moduleid'); - $Data->addParam($this->_id, 'defid'); + $Data->addParam($this->itemId, 'itemid'); + $Data->addParam($this->module, 'moduleid'); + $Data->addParam($this->id, 'defid'); $Data->addParam($cryptData['data'], 'data'); $Data->addParam($cryptData['iv'], 'iv'); @@ -465,11 +465,11 @@ class CustomFields extends CustomFieldsBase */ public function addCustomField() { - if (empty($this->_value)) { + if (empty($this->value)) { return true; } - $cryptData = Crypt::encryptData($this->_value); + $cryptData = Crypt::encryptData($this->value); $query = 'INSERT INTO customFieldsData SET ' . 'customfielddata_itemId = :itemid, ' . @@ -480,9 +480,9 @@ class CustomFields extends CustomFieldsBase $Data = new QueryData(); $Data->setQuery($query); - $Data->addParam($this->_module, 'moduleid'); - $Data->addParam($this->_itemId, 'itemid'); - $Data->addParam($this->_id, 'defid'); + $Data->addParam($this->module, 'moduleid'); + $Data->addParam($this->itemId, 'itemid'); + $Data->addParam($this->id, 'defid'); $Data->addParam($cryptData['data'], 'data'); $Data->addParam($cryptData['iv'], 'iv'); @@ -519,6 +519,6 @@ class CustomFields extends CustomFieldsBase */ public function getValue() { - return $this->_value; + return $this->value; } } \ No newline at end of file diff --git a/inc/SP/Mgmt/CustomFieldsBase.class.php b/inc/SP/Mgmt/CustomFieldsBase.class.php index 1b0c7fb7..e77ebd18 100644 --- a/inc/SP/Mgmt/CustomFieldsBase.class.php +++ b/inc/SP/Mgmt/CustomFieldsBase.class.php @@ -52,27 +52,27 @@ abstract class CustomFieldsBase /** * @var string */ - protected $_name = ''; + protected $name = ''; /** * @var int */ - protected $_type = 0; + protected $type = 0; /** * @var int */ - protected $_module = 0; + protected $module = 0; /** * @var int */ - protected $_id = 0; + protected $id = 0; /** * @var bool */ - protected $_required = false; + protected $required = false; /** * @var string */ - private $_help = ''; + private $help = ''; /** * Devolver los tipos de campos soportados @@ -125,7 +125,7 @@ abstract class CustomFieldsBase */ public function isRequired() { - return $this->_required; + return $this->required; } /** @@ -133,7 +133,7 @@ abstract class CustomFieldsBase */ public function setRequired($required) { - $this->_required = $required; + $this->required = $required; } /** @@ -141,7 +141,7 @@ abstract class CustomFieldsBase */ public function getModule() { - return $this->_module; + return $this->module; } /** @@ -149,7 +149,7 @@ abstract class CustomFieldsBase */ public function getName() { - return $this->_name; + return $this->name; } /** @@ -157,7 +157,7 @@ abstract class CustomFieldsBase */ public function getType() { - return $this->_type; + return $this->type; } /** @@ -165,7 +165,7 @@ abstract class CustomFieldsBase */ public function getId() { - return $this->_id; + return $this->id; } /** @@ -173,7 +173,7 @@ abstract class CustomFieldsBase */ public function getHelp() { - return $this->_help; + return $this->help; } /** @@ -181,6 +181,6 @@ abstract class CustomFieldsBase */ public function setHelp($help) { - $this->_help = $help; + $this->help = $help; } } \ No newline at end of file diff --git a/inc/SP/Mgmt/CustomFieldsUtil.class.php b/inc/SP/Mgmt/CustomFieldsUtil.class.php index 8f395057..2b7d9aa3 100644 --- a/inc/SP/Mgmt/CustomFieldsUtil.class.php +++ b/inc/SP/Mgmt/CustomFieldsUtil.class.php @@ -32,6 +32,11 @@ namespace SP\Mgmt; */ class CustomFieldsUtil { + /** + * @param array $fields + * @param $accountId + * @return bool + */ public static function updateCustonFields(array &$fields, $accountId) { foreach ($fields as $id => $value) { @@ -42,6 +47,11 @@ class CustomFieldsUtil return true; } + /** + * @param $fields + * @param $srcHhash + * @return bool + */ public static function checkHash(&$fields, $srcHhash) { if (!is_array($fields)){ diff --git a/inc/SP/Mgmt/PublicLink.class.php b/inc/SP/Mgmt/PublicLink.class.php index 7bcc2e8e..c038d09b 100644 --- a/inc/SP/Mgmt/PublicLink.class.php +++ b/inc/SP/Mgmt/PublicLink.class.php @@ -136,9 +136,9 @@ class PublicLink extends PublicLinkBase throw new SPException(SPException::SP_WARNING, _('Enlace ya creado')); } - $this->_dateAdd = time(); - $this->_userId = Session::getUserId(); - $this->_maxCountViews = Config::getValue('publinks_maxviews', 3); + $this->dateAdd = time(); + $this->userId = Session::getUserId(); + $this->maxCountViews = Config::getConfig()->getPublinksMaxViews(); try { $this->calcDateExpire(); @@ -151,9 +151,9 @@ class PublicLink extends PublicLinkBase $Log = new Log(_('Nuevo Enlace')); $Log->addDescription(_('Enlace creado')); - $Log->addDetails(Html::strongText(_('Tipo')), $this->_typeId); - $Log->addDetails(Html::strongText(_('Cuenta')), $this->_itemId); - $Log->addDetails(Html::strongText(_('Usuario')), UserUtil::getUserLoginById($this->_userId)); + $Log->addDetails(Html::strongText(_('Tipo')), $this->typeId); + $Log->addDetails(Html::strongText(_('Cuenta')), $this->itemId); + $Log->addDetails(Html::strongText(_('Usuario')), UserUtil::getUserLoginById($this->userId)); $Log->writeLog(); Email::sendEmail($Log); @@ -172,7 +172,7 @@ class PublicLink extends PublicLinkBase $Data = new QueryData(); $Data->setQuery($query); - $Data->addParam($this->_itemId, 'itemid'); + $Data->addParam($this->itemId, 'itemid'); $queryRes = DB::getResults($Data); @@ -190,14 +190,14 @@ class PublicLink extends PublicLinkBase */ public function addLinkView() { - $this->_countViews++; + $this->countViews++; $this->updateUseInfo($_SERVER['REMOTE_ADDR']); $Log = new Log(_('Ver Enlace Público')); $Log->addDescription(_('Enlace visualizado')); - $Log->addDetails(Html::strongText(_('Tipo')), $this->_typeId); - $Log->addDetails(Html::strongText(_('Cuenta')), AccountUtil::getAccountNameById($this->_itemId)); - $Log->addDetails(Html::strongText(_('Usuario')), UserUtil::getUserLoginById($this->_userId)); + $Log->addDetails(Html::strongText(_('Tipo')), $this->typeId); + $Log->addDetails(Html::strongText(_('Cuenta')), AccountUtil::getAccountNameById($this->itemId)); + $Log->addDetails(Html::strongText(_('Usuario')), UserUtil::getUserLoginById($this->userId)); $Log->writeLog(); if ($this->isNotify()) { @@ -216,7 +216,7 @@ class PublicLink extends PublicLinkBase */ public function refreshLink() { - $this->_maxCountViews += Config::getValue('publinks_maxviews', 3); + $this->maxCountViews += Config::getConfig()->getPublinksMaxViews(); try { $this->calcDateExpire(); @@ -229,9 +229,9 @@ class PublicLink extends PublicLinkBase $Log = new Log(_('Actualizar Enlace')); $Log->addDescription(_('Enlace actualizado')); - $Log->addDetails(Html::strongText(_('Tipo')), $this->_typeId); - $Log->addDetails(Html::strongText(_('Cuenta')), AccountUtil::getAccountNameById($this->_itemId)); - $Log->addDetails(Html::strongText(_('Usuario')), UserUtil::getUserLoginById($this->_userId)); + $Log->addDetails(Html::strongText(_('Tipo')), $this->typeId); + $Log->addDetails(Html::strongText(_('Cuenta')), AccountUtil::getAccountNameById($this->itemId)); + $Log->addDetails(Html::strongText(_('Usuario')), UserUtil::getUserLoginById($this->userId)); $Log->writeLog(); Email::sendEmail($Log); diff --git a/inc/SP/Mgmt/PublicLinkBase.class.php b/inc/SP/Mgmt/PublicLinkBase.class.php index 8be540ff..8a98a89d 100644 --- a/inc/SP/Mgmt/PublicLinkBase.class.php +++ b/inc/SP/Mgmt/PublicLinkBase.class.php @@ -47,55 +47,55 @@ abstract class PublicLinkBase /** * @var int */ - protected $_id = 0; + protected $id = 0; /** * @var int */ - protected $_itemId = 0; + protected $itemId = 0; /** * @var int */ - protected $_userId = 0; + protected $userId = 0; /** * @var string */ - protected $_linkHash = ''; + protected $linkHash = ''; /** * @var int */ - protected $_typeId = 0; + protected $typeId = 0; /** * @var bool */ - protected $_notify = false; + protected $notify = false; /** * @var int */ - protected $_dateAdd = 0; + protected $dateAdd = 0; /** * @var int */ - protected $_dateExpire = 0; + protected $dateExpire = 0; /** * @var string */ - protected $_pass = ''; + protected $pass = ''; /** * @var string */ - protected $_passIV = ''; + protected $passIV = ''; /** * @var int */ - protected $_countViews = 0; + protected $countViews = 0; /** * @var int */ - protected $_maxCountViews = 0; + protected $maxCountViews = 0; /** * @var array */ - private $_useInfo = array(); + private $useInfo = array(); /** * @param int $itemId El Id del elemento @@ -104,9 +104,9 @@ abstract class PublicLinkBase */ public function __construct($itemId, $typeId = 0, $notify = false) { - $this->_itemId = $itemId; - $this->_typeId = $typeId; - $this->_notify = $notify; + $this->itemId = $itemId; + $this->typeId = $typeId; + $this->notify = $notify; } /** @@ -114,7 +114,7 @@ abstract class PublicLinkBase */ public function getMaxCountViews() { - return $this->_maxCountViews; + return $this->maxCountViews; } /** @@ -122,7 +122,7 @@ abstract class PublicLinkBase */ public function getId() { - return $this->_id; + return $this->id; } /** @@ -130,7 +130,7 @@ abstract class PublicLinkBase */ public function setId($id) { - $this->_id = $id; + $this->id = $id; } /** @@ -138,7 +138,7 @@ abstract class PublicLinkBase */ public function getCountViews() { - return $this->_countViews; + return $this->countViews; } /** @@ -146,7 +146,7 @@ abstract class PublicLinkBase */ public function getDateExpire() { - return $this->_dateExpire; + return $this->dateExpire; } /** @@ -154,7 +154,7 @@ abstract class PublicLinkBase */ public function getPass() { - return $this->_pass; + return $this->pass; } /** @@ -162,7 +162,7 @@ abstract class PublicLinkBase */ public function getPassIV() { - return $this->_passIV; + return $this->passIV; } /** @@ -170,7 +170,7 @@ abstract class PublicLinkBase */ public function getDateAdd() { - return $this->_dateAdd; + return $this->dateAdd; } /** @@ -178,7 +178,7 @@ abstract class PublicLinkBase */ public function getUseInfo() { - return $this->_useInfo; + return $this->useInfo; } /** @@ -186,7 +186,7 @@ abstract class PublicLinkBase */ public function isNotify() { - return $this->_notify; + return $this->notify; } /** @@ -194,7 +194,7 @@ abstract class PublicLinkBase */ public function setNotify($notify) { - $this->_notify = $notify; + $this->notify = $notify; } /** @@ -202,7 +202,7 @@ abstract class PublicLinkBase */ public function getTypeId() { - return $this->_typeId; + return $this->typeId; } /** @@ -210,7 +210,7 @@ abstract class PublicLinkBase */ public function setTypeId($typeId) { - $this->_typeId = $typeId; + $this->typeId = $typeId; } /** @@ -218,7 +218,7 @@ abstract class PublicLinkBase */ public function getItemId() { - return $this->_itemId; + return $this->itemId; } /** @@ -226,7 +226,7 @@ abstract class PublicLinkBase */ public function setItemId($itemId) { - $this->_itemId = $itemId; + $this->itemId = $itemId; } /** @@ -234,7 +234,7 @@ abstract class PublicLinkBase */ public function getUserId() { - return $this->_userId; + return $this->userId; } /** @@ -242,7 +242,7 @@ abstract class PublicLinkBase */ public function setUserId($userId) { - $this->_userId = $userId; + $this->userId = $userId; } /** @@ -250,7 +250,7 @@ abstract class PublicLinkBase */ public function getLinkHash() { - return $this->_linkHash; + return $this->linkHash; } /** @@ -264,7 +264,7 @@ abstract class PublicLinkBase $Data = new QueryData(); $Data->setQuery($query); - $Data->addParam($this->_id, 'id'); + $Data->addParam($this->id, 'id'); try { DB::getQuery($Data); @@ -274,7 +274,7 @@ abstract class PublicLinkBase $Log = new Log(_('Eliminar Enlace')); $Log->addDescription(_('Enlace eliminado')); - $Log->addDetails(Html::strongText(_('ID')), $this->_itemId); + $Log->addDetails(Html::strongText(_('ID')), $this->itemId); $Log->writeLog(); Email::sendEmail($Log); @@ -295,7 +295,7 @@ abstract class PublicLinkBase $Data = new QueryData(); $Data->setQuery($query); $Data->addParam($this->createLinkHash(), 'hash'); - $Data->addParam($this->_itemId, 'itemid'); + $Data->addParam($this->itemId, 'itemid'); $Data->addParam(serialize($this), 'linkdata'); try { @@ -313,10 +313,10 @@ abstract class PublicLinkBase */ protected function createLinkHash($refresh = false) { - if (empty($this->_linkHash) || $refresh === true) { - $this->_linkHash = hash('sha256', uniqid()); + if (empty($this->linkHash) || $refresh === true) { + $this->linkHash = hash('sha256', uniqid()); } - return $this->_linkHash; + return $this->linkHash; } /** @@ -330,8 +330,8 @@ abstract class PublicLinkBase $pass = Crypt::generateAesKey($this->createLinkHash()); $cryptPass = Crypt::encryptData(SessionUtil::getSessionMPass(), $pass); - $this->_pass = $cryptPass['data']; - $this->_passIV = $cryptPass['iv']; + $this->pass = $cryptPass['data']; + $this->passIV = $cryptPass['iv']; } /** @@ -341,7 +341,7 @@ abstract class PublicLinkBase */ protected function calcDateExpire() { - $this->_dateExpire = time() + (int)Config::getValue('publinks_maxtime', 600); + $this->dateExpire = time() + (int)Config::getConfig()->getPublinksMaxTime(); } /** @@ -358,8 +358,8 @@ abstract class PublicLinkBase $Data = new QueryData(); $Data->setQuery($query); - $Data->addParam($this->_linkHash, 'hash'); - $Data->addParam($this->_id, 'id'); + $Data->addParam($this->linkHash, 'hash'); + $Data->addParam($this->id, 'id'); $Data->addParam(serialize($this), 'linkdata'); return DB::getQuery($Data); @@ -382,6 +382,6 @@ abstract class PublicLinkBase */ private function setUseInfo($useInfo) { - $this->_useInfo[] = $useInfo; + $this->useInfo[] = $useInfo; } } \ No newline at end of file diff --git a/inc/SP/Mgmt/User/Groups.class.php b/inc/SP/Mgmt/User/Groups.class.php index 4df09330..8c7eb625 100644 --- a/inc/SP/Mgmt/User/Groups.class.php +++ b/inc/SP/Mgmt/User/Groups.class.php @@ -39,11 +39,11 @@ defined('APP_ROOT') || die(_('No es posible acceder directamente a este archivo' */ class Groups { - static $queryRes; - static $groupId; - static $groupName; - static $groupDescription; - static $queryLastId; + public static $queryRes; + public static $groupId; + public static $groupName; + public static $groupDescription; + public static $queryLastId; /** * Obtener los datos de un grupo. diff --git a/inc/SP/Mgmt/User/User.class.php b/inc/SP/Mgmt/User/User.class.php index 39c1b553..37c85f1f 100644 --- a/inc/SP/Mgmt/User/User.class.php +++ b/inc/SP/Mgmt/User/User.class.php @@ -79,7 +79,7 @@ class User extends UserBase $Data->setQuery($query); $Data->addParam($cryptMPass[0], 'mPass'); $Data->addParam($cryptMPass[1], 'mIV'); - $Data->addParam($this->_userId, 'id'); + $Data->addParam($this->userId, 'id'); return DB::getQuery($Data); } @@ -91,7 +91,7 @@ class User extends UserBase */ private function getCypherPass() { - return Crypt::generateAesKey($this->_userPass . $this->_userLogin); + return Crypt::generateAesKey($this->userPass . $this->userLogin); } /** @@ -106,7 +106,7 @@ class User extends UserBase $Data = new QueryData(); $Data->setQuery($query); - $Data->addParam($this->_userId, 'id'); + $Data->addParam($this->userId, 'id'); $queryRes = DB::getResults($Data); diff --git a/inc/SP/Mgmt/User/UserBase.class.php b/inc/SP/Mgmt/User/UserBase.class.php index d4117fcb..701fd500 100644 --- a/inc/SP/Mgmt/User/UserBase.class.php +++ b/inc/SP/Mgmt/User/UserBase.class.php @@ -49,74 +49,74 @@ abstract class UserBase /** * @var int */ - protected $_userId = 0; + protected $userId = 0; /** * @var string */ - protected $_userName = ''; + protected $userName = ''; /** * @var int */ - protected $_userGroupId = 0; + protected $userGroupId = 0; /** * @var string */ - protected $_userGroupName = ''; + protected $userGroupName = ''; /** * @var string */ - protected $_userLogin = ''; + protected $userLogin = ''; /** * @var string */ - protected $_userPass = ''; + protected $userPass = ''; /** * @var string */ - protected $_userEmail = ''; + protected $userEmail = ''; /** * @var string */ - protected $_userNotes = ''; + protected $userNotes = ''; /** * @var int */ - protected $_userProfileId = 0; + protected $userProfileId = 0; /** * @var bool */ - protected $_userIsAdminApp = false; + protected $userIsAdminApp = false; /** * @var bool */ - protected $_userIsAdminAcc = false; + protected $userIsAdminAcc = false; /** * @var bool */ - protected $_userIsDisabled = false; + protected $userIsDisabled = false; /** * @var bool */ - protected $_userIsLdap = false; + protected $userIsLdap = false; /** * @var bool */ - protected $_userChangePass = false; + protected $userChangePass = false; /** * @return int */ public function getUserId() { - return $this->_userId; + return $this->userId; } /** - * @param int $_userId + * @param int $userId */ - public function setUserId($_userId) + public function setUserId($userId) { - $this->_userId = $_userId; + $this->userId = $userId; } /** @@ -124,15 +124,15 @@ abstract class UserBase */ public function getUserName() { - return $this->_userName; + return $this->userName; } /** - * @param string $_userName + * @param string $userName */ - public function setUserName($_userName) + public function setUserName($userName) { - $this->_userName = $_userName; + $this->userName = $userName; } /** @@ -140,15 +140,15 @@ abstract class UserBase */ public function getUserGroupId() { - return $this->_userGroupId; + return $this->userGroupId; } /** - * @param int $_userGroupId + * @param int $userGroupId */ - public function setUserGroupId($_userGroupId) + public function setUserGroupId($userGroupId) { - $this->_userGroupId = $_userGroupId; + $this->userGroupId = $userGroupId; } /** @@ -156,15 +156,15 @@ abstract class UserBase */ public function getUserGroupName() { - return $this->_userGroupName; + return $this->userGroupName; } /** - * @param string $_userGroupName + * @param string $userGroupName */ - public function setUserGroupName($_userGroupName) + public function setUserGroupName($userGroupName) { - $this->_userGroupName = $_userGroupName; + $this->userGroupName = $userGroupName; } /** @@ -172,15 +172,15 @@ abstract class UserBase */ public function getUserLogin() { - return $this->_userLogin; + return $this->userLogin; } /** - * @param string $_userLogin + * @param string $userLogin */ - public function setUserLogin($_userLogin) + public function setUserLogin($userLogin) { - $this->_userLogin = $_userLogin; + $this->userLogin = $userLogin; } /** @@ -188,15 +188,15 @@ abstract class UserBase */ public function getUserPass() { - return $this->_userPass; + return $this->userPass; } /** - * @param string $_userPass + * @param string $userPass */ - public function setUserPass($_userPass) + public function setUserPass($userPass) { - $this->_userPass = $_userPass; + $this->userPass = $userPass; } /** @@ -204,15 +204,15 @@ abstract class UserBase */ public function getUserEmail() { - return $this->_userEmail; + return $this->userEmail; } /** - * @param string $_userEmail + * @param string $userEmail */ - public function setUserEmail($_userEmail) + public function setUserEmail($userEmail) { - $this->_userEmail = $_userEmail; + $this->userEmail = $userEmail; } /** @@ -220,15 +220,15 @@ abstract class UserBase */ public function getUserNotes() { - return $this->_userNotes; + return $this->userNotes; } /** - * @param string $_userNotes + * @param string $userNotes */ - public function setUserNotes($_userNotes) + public function setUserNotes($userNotes) { - $this->_userNotes = $_userNotes; + $this->userNotes = $userNotes; } /** @@ -236,15 +236,15 @@ abstract class UserBase */ public function getUserProfileId() { - return $this->_userProfileId; + return $this->userProfileId; } /** - * @param int $_userProfileId + * @param int $userProfileId */ - public function setUserProfileId($_userProfileId) + public function setUserProfileId($userProfileId) { - $this->_userProfileId = $_userProfileId; + $this->userProfileId = $userProfileId; } /** @@ -252,15 +252,15 @@ abstract class UserBase */ public function isUserIsAdminApp() { - return $this->_userIsAdminApp; + return $this->userIsAdminApp; } /** - * @param boolean $_userIsAdminApp + * @param boolean $userIsAdminApp */ - public function setUserIsAdminApp($_userIsAdminApp) + public function setUserIsAdminApp($userIsAdminApp) { - $this->_userIsAdminApp = $_userIsAdminApp; + $this->userIsAdminApp = $userIsAdminApp; } /** @@ -268,15 +268,15 @@ abstract class UserBase */ public function isUserIsAdminAcc() { - return $this->_userIsAdminAcc; + return $this->userIsAdminAcc; } /** - * @param boolean $_userIsAdminAcc + * @param boolean $userIsAdminAcc */ - public function setUserIsAdminAcc($_userIsAdminAcc) + public function setUserIsAdminAcc($userIsAdminAcc) { - $this->_userIsAdminAcc = $_userIsAdminAcc; + $this->userIsAdminAcc = $userIsAdminAcc; } /** @@ -284,15 +284,15 @@ abstract class UserBase */ public function isUserIsDisabled() { - return $this->_userIsDisabled; + return $this->userIsDisabled; } /** - * @param boolean $_userIsDisabled + * @param boolean $userIsDisabled */ - public function setUserIsDisabled($_userIsDisabled) + public function setUserIsDisabled($userIsDisabled) { - $this->_userIsDisabled = $_userIsDisabled; + $this->userIsDisabled = $userIsDisabled; } /** @@ -300,15 +300,15 @@ abstract class UserBase */ public function isUserIsLdap() { - return $this->_userIsLdap; + return $this->userIsLdap; } /** - * @param boolean $_userIsLdap + * @param boolean $userIsLdap */ - public function setUserIsLdap($_userIsLdap) + public function setUserIsLdap($userIsLdap) { - $this->_userIsLdap = $_userIsLdap; + $this->userIsLdap = $userIsLdap; } /** @@ -316,15 +316,15 @@ abstract class UserBase */ public function isUserChangePass() { - return $this->_userChangePass; + return $this->userChangePass; } /** - * @param boolean $_userChangePass + * @param boolean $userChangePass */ - public function setUserChangePass($_userChangePass) + public function setUserChangePass($userChangePass) { - $this->_userChangePass = $_userChangePass; + $this->userChangePass = $userChangePass; } /** @@ -350,7 +350,7 @@ abstract class UserBase */ public function addUser() { - $passdata = UserPass::makeUserPassHash($this->_userPass); + $passdata = UserPass::makeUserPassHash($this->userPass); $query = 'INSERT INTO usrData SET ' . 'user_name = :name,' @@ -371,16 +371,16 @@ abstract class UserBase $Data = new QueryData(); $Data->setQuery($query); - $Data->addParam($this->_userName, 'name'); - $Data->addParam($this->_userLogin, 'login'); - $Data->addParam($this->_userEmail, 'email'); - $Data->addParam($this->_userNotes, 'notes'); - $Data->addParam($this->_userGroupId, 'groupId'); - $Data->addParam($this->_userProfileId, 'profileId'); - $Data->addParam(intval($this->_userIsAdminApp), 'isAdminApp'); - $Data->addParam(intval($this->_userIsAdminAcc), 'isAdminAcc'); - $Data->addParam(intval($this->_userIsDisabled), 'isDisabled'); - $Data->addParam(intval($this->_userChangePass), 'isChangePass'); + $Data->addParam($this->userName, 'name'); + $Data->addParam($this->userLogin, 'login'); + $Data->addParam($this->userEmail, 'email'); + $Data->addParam($this->userNotes, 'notes'); + $Data->addParam($this->userGroupId, 'groupId'); + $Data->addParam($this->userProfileId, 'profileId'); + $Data->addParam(intval($this->userIsAdminApp), 'isAdminApp'); + $Data->addParam(intval($this->userIsAdminAcc), 'isAdminAcc'); + $Data->addParam(intval($this->userIsDisabled), 'isDisabled'); + $Data->addParam(intval($this->userChangePass), 'isChangePass'); $Data->addParam($passdata['pass'], 'pass'); $Data->addParam($passdata['salt'], 'salt'); @@ -388,13 +388,13 @@ abstract class UserBase return false; } - $this->_userId = DB::getLastId(); + $this->userId = DB::getLastId(); $Log = new Log(_('Nuevo Usuario')); - $Log->addDetails(Html::strongText(_('Usuario')), sprintf('%s (%s)', $this->_userName, $this->_userLogin)); + $Log->addDetails(Html::strongText(_('Usuario')), sprintf('%s (%s)', $this->userName, $this->userLogin)); - if ($this->_userChangePass) { - if (!Auth::mailPassRecover(DBUtil::escape($this->_userLogin), DBUtil::escape($this->_userEmail))) { + if ($this->userChangePass) { + if (!Auth::mailPassRecover(DBUtil::escape($this->userLogin), DBUtil::escape($this->userEmail))) { $Log->addDescription(Html::strongText(_('No se pudo realizar la petición de cambio de clave.'))); } } @@ -435,7 +435,7 @@ abstract class UserBase $Data = new QueryData(); $Data->setQuery($query); - $Data->addParam($this->_userLogin, 'login'); + $Data->addParam($this->userLogin, 'login'); $queryRes = DB::getResults($Data); @@ -443,16 +443,16 @@ abstract class UserBase return false; } - $this->_userId = intval($queryRes->user_id); - $this->_userName = $queryRes->user_name; - $this->_userGroupId = intval($queryRes->user_groupId); - $this->_userGroupName = $queryRes->usergroup_name; - $this->_userEmail = $queryRes->user_email; - $this->_userProfileId = intval($queryRes->user_profileId); - $this->_userIsAdminApp = intval($queryRes->user_isAdminApp); - $this->_userIsAdminAcc = intval($queryRes->user_isAdminAcc); - $this->_userIsLdap = intval($queryRes->user_isLdap); - $this->_userChangePass = intval($queryRes->user_isChangePass); + $this->userId = intval($queryRes->user_id); + $this->userName = $queryRes->user_name; + $this->userGroupId = intval($queryRes->user_groupId); + $this->userGroupName = $queryRes->usergroup_name; + $this->userEmail = $queryRes->user_email; + $this->userProfileId = intval($queryRes->user_profileId); + $this->userIsAdminApp = intval($queryRes->user_isAdminApp); + $this->userIsAdminAcc = intval($queryRes->user_isAdminAcc); + $this->userIsLdap = intval($queryRes->user_isLdap); + $this->userChangePass = intval($queryRes->user_isChangePass); return true; } @@ -464,8 +464,8 @@ abstract class UserBase */ public function checkUserExist() { - $userLogin = strtoupper($this->_userLogin); - $userEmail = strtoupper($this->_userEmail); + $userLogin = strtoupper($this->userLogin); + $userEmail = strtoupper($this->userEmail); $query = 'SELECT user_login, user_email ' . 'FROM usrData ' @@ -475,9 +475,9 @@ abstract class UserBase $Data = new QueryData(); $Data->setQuery($query); - $Data->addParam($this->_userLogin, 'login'); - $Data->addParam($this->_userEmail, 'email'); - $Data->addParam($this->_userId, 'id'); + $Data->addParam($this->userLogin, 'login'); + $Data->addParam($this->userEmail, 'email'); + $Data->addParam($this->userId, 'id'); DB::setReturnArray(); @@ -522,17 +522,17 @@ abstract class UserBase $Data = new QueryData(); $Data->setQuery($query); - $Data->addParam($this->_userName, 'name'); - $Data->addParam($this->_userLogin, 'login'); - $Data->addParam($this->_userEmail, 'email'); - $Data->addParam($this->_userNotes, 'notes'); - $Data->addParam($this->_userGroupId, 'groupId'); - $Data->addParam($this->_userProfileId, 'profileId'); - $Data->addParam(intval($this->_userIsAdminApp), 'isAdminApp'); - $Data->addParam(intval($this->_userIsAdminAcc), 'isAdminAcc'); - $Data->addParam(intval($this->_userIsDisabled), 'isDisabled'); - $Data->addParam(intval($this->_userChangePass), 'isChangePass'); - $Data->addParam($this->_userId, 'id'); + $Data->addParam($this->userName, 'name'); + $Data->addParam($this->userLogin, 'login'); + $Data->addParam($this->userEmail, 'email'); + $Data->addParam($this->userNotes, 'notes'); + $Data->addParam($this->userGroupId, 'groupId'); + $Data->addParam($this->userProfileId, 'profileId'); + $Data->addParam(intval($this->userIsAdminApp), 'isAdminApp'); + $Data->addParam(intval($this->userIsAdminAcc), 'isAdminAcc'); + $Data->addParam(intval($this->userIsDisabled), 'isDisabled'); + $Data->addParam(intval($this->userChangePass), 'isChangePass'); + $Data->addParam($this->userId, 'id'); if (DB::getQuery($Data) === false) { return false; @@ -541,10 +541,10 @@ abstract class UserBase $this->queryLastId = DB::$lastId; $Log = new Log(_('Modificar Usuario')); - $Log->addDetails(Html::strongText(_('Usuario')), sprintf('%s (%s)', $this->_userName, $this->_userLogin)); + $Log->addDetails(Html::strongText(_('Usuario')), sprintf('%s (%s)', $this->userName, $this->userLogin)); - if ($this->_userChangePass) { - if (!Auth::mailPassRecover(DBUtil::escape($this->_userLogin), DBUtil::escape($this->_userEmail))) { + if ($this->userChangePass) { + if (!Auth::mailPassRecover(DBUtil::escape($this->userLogin), DBUtil::escape($this->userEmail))) { $Log->addDescription(Html::strongText(_('No se pudo realizar la petición de cambio de clave.'))); } } @@ -563,8 +563,8 @@ abstract class UserBase */ public function updateUserPass() { - $passdata = UserPass::makeUserPassHash($this->_userPass); - $userLogin = UserUtil::getUserLoginById($this->_userId); + $passdata = UserPass::makeUserPassHash($this->userPass); + $userLogin = UserUtil::getUserLoginById($this->userId); $query = 'UPDATE usrData SET ' . 'user_pass = :pass,' @@ -575,7 +575,7 @@ abstract class UserBase $Data = new QueryData(); $Data->setQuery($query); - $Data->addParam($this->_userId, 'id'); + $Data->addParam($this->userId, 'id'); $Data->addParam($passdata['pass'], 'pass'); $Data->addParam($passdata['salt'], 'salt'); @@ -601,13 +601,13 @@ abstract class UserBase */ public function deleteUser() { - $userLogin = UserUtil::getUserLoginById($this->_userId); + $userLogin = UserUtil::getUserLoginById($this->userId); $query = 'DELETE FROM usrData WHERE user_id = :id LIMIT 1'; $Data = new QueryData(); $Data->setQuery($query); - $Data->addParam($this->_userId, 'id'); + $Data->addParam($this->userId, 'id'); if (DB::getQuery($Data) === false) { return false; diff --git a/inc/SP/Mgmt/User/UserLdap.class.php b/inc/SP/Mgmt/User/UserLdap.class.php index eaa6b76d..1d52f0e3 100644 --- a/inc/SP/Mgmt/User/UserLdap.class.php +++ b/inc/SP/Mgmt/User/UserLdap.class.php @@ -51,8 +51,8 @@ class UserLdap public static function newUserLDAP(User $User) { $passdata = UserPass::makeUserPassHash($User->getUserPass()); - $groupId = Config::getValue('ldap_defaultgroup', 0); - $profileId = Config::getValue('ldap_defaultprofile', 0); + $groupId = Config::getConfig()->getLdapDefaultGroup(); + $profileId = Config::getConfig()->getLdapDefaultProfile(); $query = 'INSERT INTO usrData SET ' . 'user_name = :name,' diff --git a/inc/SP/Storage/DB.class.php b/inc/SP/Storage/DB.class.php index 71a4ce77..f6011af1 100644 --- a/inc/SP/Storage/DB.class.php +++ b/inc/SP/Storage/DB.class.php @@ -26,6 +26,7 @@ namespace SP\Storage; use PDO; +use SP\Core\Factory; use SP\Log\Log; use SP\Core\SPException; use SP\Util\Util; @@ -56,27 +57,27 @@ class DB /** * @var bool Resultado como array */ - private static $_retArray = false; + private static $retArray = false; /** * @var bool Resultado como un objeto PDO */ - private static $_returnRawData = false; + private static $returnRawData = false; /** * @var bool Contar el número de filas totales */ - private static $_fullRowCount = false; + private static $fullRowCount = false; /** * @var int Número de registros obtenidos */ - private $_numRows = 0; + private $numRows = 0; /** * @var int Número de campos de la consulta */ - private $_numFields = 0; + private $numFields = 0; /** * @var array Resultados de la consulta */ - private $_lastResult = null; + private $lastResult = null; /** * @return int @@ -91,7 +92,7 @@ class DB */ public static function setReturnArray() { - self::$_retArray = true; + self::$retArray = true; } /** @@ -109,28 +110,28 @@ class DB try { $db = new DB(); - $doQuery = $db->doQuery($queryData, self::$_returnRawData); - self::$lastNumRows = (self::$_fullRowCount === false) ? $db->_numRows : $db->getFullRowCount($queryData); + $doQuery = $db->doQuery($queryData, self::$returnRawData); + self::$lastNumRows = (self::$fullRowCount === false) ? $db->numRows : $db->getFullRowCount($queryData); } catch (SPException $e) { self::logDBException($queryData->getQuery(), $e->getMessage(), $e->getCode(), __FUNCTION__); return false; } - if (self::$_returnRawData + if (self::$returnRawData && is_object($doQuery) && get_class($doQuery) === "PDOStatement" ) { return $doQuery; - } elseif ($db->_numRows == 0) { + } elseif ($db->numRows == 0) { self::resetVars(); return false; - } elseif ($db->_numRows == 1 && self::$_retArray === false) { + } elseif ($db->numRows == 1 && self::$retArray === false) { self::resetVars(); - return $db->_lastResult[0]; + return $db->lastResult[0]; } self::resetVars(); - return $db->_lastResult; + return $db->lastResult; } /** @@ -138,9 +139,9 @@ class DB */ private static function resetVars() { - self::$_returnRawData = false; - self::$_fullRowCount = false; - self::$_retArray = false; + self::$returnRawData = false; + self::$fullRowCount = false; + self::$retArray = false; } /** @@ -156,7 +157,7 @@ class DB $isSelect = preg_match("/^(select|show)\s/i", $queryData->getQuery()); // Limpiar valores de caché y errores - $this->_lastResult = array(); + $this->lastResult = array(); try { $queryRes = $this->prepareQueryData($queryData); @@ -166,15 +167,15 @@ class DB if ($isSelect) { if (!$getRawData) { - $this->_numFields = $queryRes->columnCount(); - $this->_lastResult = $queryRes->fetchAll(PDO::FETCH_OBJ); + $this->numFields = $queryRes->columnCount(); + $this->lastResult = $queryRes->fetchAll(PDO::FETCH_OBJ); } else { return $queryRes; } // $queryRes->closeCursor(); - $this->_numRows = count($this->_lastResult); + $this->numRows = count($this->lastResult); } } @@ -198,7 +199,8 @@ class DB } try { - $db = DBConnectionFactory::getFactory()->getConnection(); + /** @var $db PDO */ + $db = Factory::getDBStorage()->getConnection(); if (is_array($queryData->getParams())) { $sth = $db->prepare($queryData->getQuery()); @@ -235,7 +237,11 @@ class DB return $sth; } catch (\Exception $e) { + ob_start(); + debug_print_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); error_log("Exception: " . $e->getMessage()); + error_log(ob_get_clean()); + throw new SPException(SPException::SP_CRITICAL, $e->getMessage(), $e->getCode()); } } @@ -269,7 +275,8 @@ class DB $queryData->setQuery($query); try { - $db = DBConnectionFactory::getFactory()->getConnection(); + /** @var $db PDO */ + $db = Factory::getDBStorage()->getConnection(); if (!is_array($queryData->getParams())) { $queryRes = $db->query($query); @@ -325,7 +332,7 @@ class DB try { $db = new DB(); $db->doQuery($queryData, $getRawData); - DB::$lastNumRows = $db->_numRows; + DB::$lastNumRows = $db->numRows; } catch (SPException $e) { self::logDBException($queryData->getQuery(), $e->getMessage(), $e->getCode(), __FUNCTION__); self::$txtError = $e->getMessage(); @@ -344,7 +351,7 @@ class DB */ public static function setReturnRawData($on = true) { - self::$_returnRawData = (bool)$on; + self::$returnRawData = (bool)$on; } /** @@ -352,6 +359,6 @@ class DB */ public static function setFullRowCount() { - self::$_fullRowCount = true; + self::$fullRowCount = true; } } diff --git a/inc/SP/Storage/DBStorageInterface.class.php b/inc/SP/Storage/DBStorageInterface.class.php new file mode 100644 index 00000000..1b2367b8 --- /dev/null +++ b/inc/SP/Storage/DBStorageInterface.class.php @@ -0,0 +1,39 @@ +. + * + */ + +namespace SP\Storage; + +/** + * Interface DBStorageInterface + * + * @package SP\Storage + */ +interface DBStorageInterface +{ + /** + * @return PDO + */ + public function getConnection(); +} \ No newline at end of file diff --git a/inc/SP/Storage/DBUtil.class.php b/inc/SP/Storage/DBUtil.class.php index c3167530..6008523d 100644 --- a/inc/SP/Storage/DBUtil.class.php +++ b/inc/SP/Storage/DBUtil.class.php @@ -27,6 +27,7 @@ namespace SP\Storage; use SP\Config\Config; +use SP\Core\Factory; use SP\Core\SPException; /** @@ -45,11 +46,11 @@ class DBUtil public static function checkDatabaseExist() { try { - $db = DBConnectionFactory::getFactory()->getConnection(); + $db = Factory::getDBStorage()->getConnection(); $query = 'SELECT COUNT(*) ' . 'FROM information_schema.tables ' - . 'WHERE table_schema=\'' . Config::getValue("dbname") . '\' ' + . 'WHERE table_schema=\'' . Config::getConfig()->getDbName() . '\' ' . 'AND table_name = \'usrData\''; if ($db->query($query)->fetchColumn() !== 0) { @@ -112,7 +113,7 @@ class DBUtil public static function escape($str) { try { - $db = DBConnectionFactory::getFactory()->getConnection(); + $db = Factory::getDBStorage()->getConnection(); return $db->quote(trim($str)); } catch (SPException $e) { @@ -130,7 +131,7 @@ class DBUtil $dbinfo = array(); try { - $db = DBConnectionFactory::getFactory()->getConnection(); + $db = Factory::getDBStorage()->getConnection(); $attributes = array( 'SERVER_VERSION', diff --git a/inc/SP/Storage/FileStorageInterface.class.php b/inc/SP/Storage/FileStorageInterface.class.php new file mode 100644 index 00000000..d43fb289 --- /dev/null +++ b/inc/SP/Storage/FileStorageInterface.class.php @@ -0,0 +1,55 @@ +. + * + */ + +namespace SP\Storage; + +/** + * Interface StorageInterface + * + * @package SMD\Storage + */ +interface FileStorageInterface +{ + /** + * @return FileStorageInterface + */ + public function load(); + + /** + * @return FileStorageInterface + */ + public function save(); + + /** + * @return mixed + */ + public function getItems(); + + /** + * @param $items + * @return mixed + */ + public function setItems($items); +} \ No newline at end of file diff --git a/inc/SP/Storage/DBConnectionFactory.class.php b/inc/SP/Storage/MySQLHandler.class.php similarity index 77% rename from inc/SP/Storage/DBConnectionFactory.class.php rename to inc/SP/Storage/MySQLHandler.class.php index 52922905..79577331 100644 --- a/inc/SP/Storage/DBConnectionFactory.class.php +++ b/inc/SP/Storage/MySQLHandler.class.php @@ -33,34 +33,17 @@ use SP\Core\SPException; defined('APP_ROOT') || die(_('No es posible acceder directamente a este archivo')); /** - * Class DBConnectionFactory + * Class MySQLHandler * * Esta clase se encarga de crear las conexiones a la BD */ -class DBConnectionFactory +class MySQLHandler implements DBStorageInterface { /** - * @var DBConnectionFactory - */ - private static $_factory; - /** - * @var \PDO + * @var PDO */ private $_db; - /** - * Obtener una instancia de la clase - * - * @return DBConnectionFactory - */ - public static function getFactory() - { - if (!self::$_factory) { - self::$_factory = new DBConnectionFactory(); - } - - return self::$_factory; - } /** * Realizar la conexión con la BBDD. @@ -73,15 +56,18 @@ class DBConnectionFactory public function getConnection() { if (!$this->_db) { - $isInstalled = Config::getValue('installed'); + $Config = Config::getConfig(); - $dbhost = Config::getValue('dbhost'); - $dbuser = Config::getValue('dbuser'); - $dbpass = Config::getValue('dbpass'); - $dbname = Config::getValue('dbname'); - $dbport = Config::getValue('dbport', 3306); + $isInstalled = $Config->isInstalled(); + $dbhost = $Config->getDbHost(); + $dbuser = $Config->getDbUser(); + $dbpass = $Config->getDbPass(); + $dbname = $Config->getDbName(); + $dbport = $Config->getDbPort(); if (empty($dbhost) || empty($dbuser) || empty($dbpass) || empty($dbname)) { + Init::$DB_STATUS = 0; + if ($isInstalled) { Init::initError(_('No es posible conectar con la BD'), _('Compruebe los datos de conexión')); } else { @@ -94,11 +80,13 @@ class DBConnectionFactory // $this->db = new PDO($dsn, $dbuser, $dbpass, array(PDO::ATTR_PERSISTENT => true)); $this->_db = new PDO($dsn, $dbuser, $dbpass); } catch (\Exception $e) { + Init::$DB_STATUS = 0; + if ($isInstalled) { if ($e->getCode() === 1049) { - Config::setValue('installed', '0'); + Config::getConfig()->setInstalled(false); + Config::saveConfig(); } - Init::initError(_('No es posible conectar con la BD'), 'Error ' . $e->getCode() . ': ' . $e->getMessage()); } else { throw new SPException(SPException::SP_CRITICAL, $e->getMessage(), $e->getCode()); diff --git a/inc/SP/Storage/QueryData.class.php b/inc/SP/Storage/QueryData.class.php index 1b67b580..dfd90a85 100644 --- a/inc/SP/Storage/QueryData.class.php +++ b/inc/SP/Storage/QueryData.class.php @@ -35,11 +35,11 @@ class QueryData /** * @var array */ - protected $_data = array(); + protected $data = array(); /** * @var string */ - protected $_query = ''; + protected $query = ''; /** * @param $value @@ -48,9 +48,9 @@ class QueryData public function addParam($value, $name = null) { if (!is_null($name)) { - $this->_data[$name] = $value; + $this->data[$name] = $value; } else { - $this->_data[] = $value; + $this->data[] = $value; } } @@ -59,7 +59,7 @@ class QueryData */ public function getParams() { - return $this->_data; + return $this->data; } /** @@ -67,7 +67,7 @@ class QueryData */ public function getQuery() { - return $this->_query; + return $this->query; } /** @@ -75,6 +75,6 @@ class QueryData */ public function setQuery($query) { - $this->_query = $query; + $this->query = $query; } } \ No newline at end of file diff --git a/inc/SP/Storage/XmlHandler.class.php b/inc/SP/Storage/XmlHandler.class.php new file mode 100644 index 00000000..a33ef319 --- /dev/null +++ b/inc/SP/Storage/XmlHandler.class.php @@ -0,0 +1,227 @@ +. + * + */ + +namespace SP\Storage; + +use DOMDocument; +use ReflectionObject; +use SP\Core\SPException; + +/** + * Class XmlHandler para manejo básico de documentos XML + * + * @package SMD\Storage + */ +class XmlHandler implements FileStorageInterface +{ + /** + * @var mixed + */ + protected $items = null; + /** + * @var string + */ + protected $file; + /** + * @var DOMDocument + */ + private $Dom; + + /** + * XmlHandler constructor. + * + * @param $file + */ + public function __construct($file) + { + $this->file = $file; + $this->setDOM(); + } + + /** + * Crear un nuevo documento XML + */ + private function setDOM() + { + $this->Dom = new DOMDocument('1.0', 'utf-8'); + } + + /** + * Cargar un archivo XML + * + * @param string $tag + * @return bool|void + * @throws SPException + */ + public function load($tag = 'root') + { + if (!$this->checkSourceFile()) { + throw new SPException( + SPException::SP_CRITICAL, + _('No es posible leer el archivo'), + $this->file + ); + } + + $this->items = []; + $this->Dom->load($this->file); + + $nodes = $this->Dom->getElementsByTagName($tag)->item(0)->childNodes; + + foreach ($nodes as $node) { + /** @var $node \DOMNode */ + if (is_object($node->childNodes) && $node->childNodes->length > 1) { + foreach ($node->childNodes as $child) { + /** @var $child \DOMNode */ + + if ($child->nodeType == XML_ELEMENT_NODE) { + $this->items[$node->nodeName][] = $child->nodeValue; + } + } + } else { + $this->items[$node->nodeName] = $node->nodeValue; + } + } + + return $this; + } + + /** + * Comprobar que el archivo existe y se puede leer/escribir + * + * @return bool + */ + protected function checkSourceFile() + { + return is_writable($this->file); + } + + /** + * Obtener un elemento del array + * + * @param $id + * @return mixed + */ + public function __get($id) + { + return $this->items[$id]; + } + + /** + * Guardar el archivo XML + * + * @param string $tag + * @return bool|void + * @throws SPException + */ + public function save($tag = 'root') + { + if (is_null($this->items)) { + throw new SPException(SPException::SP_WARNING, _('No hay elementos para guardar')); + } + + $this->Dom->formatOutput = true; + + $root = $this->Dom->createElement($tag); + $this->Dom->appendChild($root); + + foreach ($this->analyzeItems() as $key => $value) { + $keyNode = $this->Dom->createElement($key); + + if (is_array($value)) { + foreach ($value as $arrayVal) { + $arrayNode = $this->Dom->createElement('item'); + $arrayNode->appendChild($this->Dom->createTextNode(trim($arrayVal))); + $keyNode->appendChild($arrayNode); + } + } else { + $keyNode->appendChild($this->Dom->createTextNode($value)); + } + + $root->appendChild($keyNode); + } + + $this->Dom->save($this->file); + + return $this; + } + + /** + * Analizar el tipo de elementos + * + * @return array|mixed + */ + protected function analyzeItems() + { + if (is_array($this->items)) { + return $this->items; + } elseif (is_object($this->items)) { + return $this->analyzeObject(); + } + + return []; + + } + + /** + * Analizar un elemento del tipo objeto + * + * @return array + */ + protected function analyzeObject() + { + $items = []; + $Reflection = new ReflectionObject($this->items); + + foreach ($Reflection->getProperties() as $property) { + $property->setAccessible(true); + $items[$property->getName()] = $property->getValue($this->items); + $property->setAccessible(false); + } + + return $items; + } + + /** + * Devolver los elementos cargados + * + * @return mixed + */ + public function getItems() + { + return $this->items; + } + + /** + * Establecer los elementos + * + * @param $items + * @return mixed + */ + public function setItems($items) + { + $this->items = $items; + } +} \ No newline at end of file diff --git a/inc/SP/Util/Checks.class.php b/inc/SP/Util/Checks.class.php index a0fab79d..9974aa9c 100644 --- a/inc/SP/Util/Checks.class.php +++ b/inc/SP/Util/Checks.class.php @@ -156,7 +156,7 @@ class Checks */ public static function demoIsEnabled() { - return Util::boolval(Config::getValue('demo_enabled', false)); + return Util::boolval(Config::getConfig()->isDemoEnabled()); } /** @@ -166,7 +166,7 @@ class Checks */ public static function fileIsEnabled() { - return Util::boolval(Config::getValue('files_enabled', false)); + return Util::boolval(Config::getConfig()->isFilesEnabled()); } /** @@ -176,7 +176,7 @@ class Checks */ public static function mailIsEnabled() { - return Util::boolval(Config::getValue('mail_enabled', false)); + return Util::boolval(Config::getConfig()->isMailEnabled()); } /** @@ -186,7 +186,7 @@ class Checks */ public static function wikiIsEnabled() { - return Util::boolval(Config::getValue('wiki_enabled', false)); + return Util::boolval(Config::getConfig()->isWikiEnabled()); } /** @@ -196,7 +196,7 @@ class Checks */ public static function dokuWikiIsEnabled() { - return Util::boolval(Config::getValue('dokuwiki_enabled', false)); + return Util::boolval(Config::getConfig()->isDokuwikiEnabled()); } /** @@ -206,7 +206,7 @@ class Checks */ public static function mailrequestIsEnabled() { - return Util::boolval(Config::getValue('mail_requestsenabled', false)); + return Util::boolval(Config::getConfig()->isMailRequestsEnabled()); } /** @@ -216,7 +216,7 @@ class Checks */ public static function ldapIsEnabled() { - return Util::boolval(Config::getValue('ldap_enabled', false)); + return Util::boolval(Config::getConfig()->isLdapEnabled()); } /** @@ -226,7 +226,7 @@ class Checks */ public static function logIsEnabled() { - return Util::boolval(Config::getValue('log_enabled', false)); + return Util::boolval(Config::getConfig()->isLogEnabled()); } /** @@ -236,7 +236,7 @@ class Checks */ public static function syslogIsEnabled() { - return Util::boolval(Config::getValue('syslog_enabled', false)); + return Util::boolval(Config::getConfig()->isSyslogEnabled()); } /** @@ -246,7 +246,7 @@ class Checks */ public static function remoteSyslogIsEnabled() { - return Util::boolval(Config::getValue('syslog_remote_enabled', false)); + return Util::boolval(Config::getConfig()->isSyslogRemoteEnabled()); } @@ -257,7 +257,7 @@ class Checks */ public static function resultsCardsIsEnabled() { - return Util::boolval(Config::getValue('resultsascards', false)); + return Util::boolval(Config::getConfig()->isResultsAsCards()); } /** @@ -267,7 +267,7 @@ class Checks */ public static function accountPassToImageIsEnabled() { - return Util::boolval(Config::getValue('account_passtoimage', false)); + return Util::boolval(Config::getConfig()->isAccountPassToImage()); } /** @@ -277,7 +277,7 @@ class Checks */ public static function forceHttpsIsEnabled() { - return Util::boolval(Config::getValue('https_enabled', false)); + return Util::boolval(Config::getConfig()->isHttpsEnabled()); } /** @@ -287,7 +287,7 @@ class Checks */ public static function publicLinksIsEnabled() { - return Util::boolval(Config::getValue('publinks_enabled', false)); + return Util::boolval(Config::getConfig()->isPublinksEnabled()); } /** diff --git a/inc/SP/Util/Connection.class.php b/inc/SP/Util/Connection.class.php index d07b5c86..ac1fcfba 100644 --- a/inc/SP/Util/Connection.class.php +++ b/inc/SP/Util/Connection.class.php @@ -37,29 +37,29 @@ class Connection implements ConnectionInterface /** * @var resource */ - protected $_socket; + protected $socket; /** * @var string */ - protected $_host = ''; + protected $host = ''; /** * @var int */ - protected $_port = 0; + protected $port = 0; /** * Código de error del socket * * @var int */ - protected $_errorno = 0; + protected $errorno = 0; /** * Mensaje de error del socket * * @var string */ - protected $_errorstr = ''; + protected $errorstr = ''; /** * @param $host string El host a conectar @@ -67,8 +67,8 @@ class Connection implements ConnectionInterface */ public function __construct($host, $port) { - $this->_host = gethostbyname($host); - $this->_port = $port; + $this->host = gethostbyname($host); + $this->port = $port; } /** @@ -82,21 +82,21 @@ class Connection implements ConnectionInterface { switch ($type){ case self::TYPE_TCP: - $this->_socket = $this->getTCPSocket(); + $this->socket = $this->getTCPSocket(); break; case self::TYPE_UDP: - $this->_socket = $this->getUDPSocket(); + $this->socket = $this->getUDPSocket(); break; default: - $this->_socket = $this->getTCPSocket(); + $this->socket = $this->getTCPSocket(); break; } - if ($this->_socket === false) { + if ($this->socket === false) { throw new SPException(SPException::SP_WARNING, $this->getSocketError()); } - stream_set_timeout($this->_socket, self::SOCKET_TIMEOUT); + stream_set_timeout($this->socket, self::SOCKET_TIMEOUT); } /** @@ -104,7 +104,7 @@ class Connection implements ConnectionInterface */ public function closeSocket() { - fclose($this->_socket); + fclose($this->socket); // @socket_close($this->_socket); } @@ -117,12 +117,12 @@ class Connection implements ConnectionInterface */ public function send($message) { - if (!is_resource($this->_socket)) { + if (!is_resource($this->socket)) { throw new SPException(SPException::SP_WARNING, _('Socket no inicializado')); } - $nBytes = @fwrite($this->_socket, $message); -// $nBytes = @socket_sendto($this->_socket, $message, strlen($message), 0, $this->_host, $this->_port); + $nBytes = @fwrite($this->socket, $message); +// $nBytes = @socket_sendto($this->_socket, $message, strlen($message), 0, $this->_host, $this->port); if ($nBytes === false) { throw new SPException(SPException::SP_WARNING, _('Error al enviar datos'), $this->getSocketError()); @@ -138,7 +138,7 @@ class Connection implements ConnectionInterface */ public function getSocketError() { - return sprintf('%s (%d)', $this->_errorstr, $this->_errorno); + return sprintf('%s (%d)', $this->errorstr, $this->errorno); // return socket_strerror(socket_last_error($this->_socket)); } @@ -149,7 +149,7 @@ class Connection implements ConnectionInterface */ private function getUDPSocket() { - return stream_socket_client('udp://' . $this->_host . ':' . $this->_port, $this->_errorno, $this->_errorstr, self::SOCKET_TIMEOUT); + return stream_socket_client('udp://' . $this->host . ':' . $this->port, $this->errorno, $this->errorstr, self::SOCKET_TIMEOUT); // return @socket_create(AF_INET, SOCK_DGRAM, SOL_UDP); } @@ -160,7 +160,7 @@ class Connection implements ConnectionInterface */ private function getTCPSocket() { - return stream_socket_client('tcp://' . $this->_host . ':' . $this->_port, $this->_errorno, $this->_errorstr, self::SOCKET_TIMEOUT); + return stream_socket_client('tcp://' . $this->host . ':' . $this->port, $this->errorno, $this->errorstr, self::SOCKET_TIMEOUT); // return @socket_create(AF_INET, SOCK_STREAM, SOL_TCP); } } \ No newline at end of file diff --git a/inc/SP/Util/ConnectionInterface.class.php b/inc/SP/Util/ConnectionInterface.class.php index 5d57a58f..891266d1 100644 --- a/inc/SP/Util/ConnectionInterface.class.php +++ b/inc/SP/Util/ConnectionInterface.class.php @@ -39,6 +39,7 @@ interface ConnectionInterface /** * Obtener un socket * + * @param $type * @return mixed */ public function getSocket($type); diff --git a/inc/SP/Util/Util.class.php b/inc/SP/Util/Util.class.php index 28bbc1d8..165ef8db 100644 --- a/inc/SP/Util/Util.class.php +++ b/inc/SP/Util/Util.class.php @@ -114,7 +114,7 @@ class Util */ public static function checkUpdates() { - if (!Config::getValue('checkupdates')) { + if (!Config::getConfig()->isCheckUpdates()) { return false; } @@ -180,15 +180,15 @@ class Util $ch = curl_init($url); - if (Config::getValue('proxy_enabled')) { - curl_setopt($ch, CURLOPT_PROXY, Config::getValue('proxy_server')); - curl_setopt($ch, CURLOPT_PROXYPORT, Config::getValue('proxy_port')); + if (Config::getConfig()->isProxyEnabled()) { + curl_setopt($ch, CURLOPT_PROXY, Config::getConfig()->getProxyServer()); + curl_setopt($ch, CURLOPT_PROXYPORT, Config::getConfig()->getProxyPort()); curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP); - $proxyUser = Config::getValue('proxy_user'); + $proxyUser = Config::getConfig()->getProxyUser(); if ($proxyUser) { - $proxyAuth = $proxyUser . ':' . Config::getValue('proxy_pass'); + $proxyAuth = $proxyUser . ':' . Config::getConfig()->getProxyPass(); curl_setopt($ch, CURLOPT_PROXYUSERPWD, $proxyAuth); } } @@ -274,7 +274,7 @@ class Util */ public static function getVersion($retBuild = false) { - $build = '16011001'; + $build = '16020501'; $version = array(1, 3); if ($retBuild) { @@ -292,7 +292,7 @@ class Util */ public static function checkNotices() { - if (!Config::getValue('checknotices')) { + if (!Config::getConfig()->isChecknotices()) { return false; } diff --git a/inc/SP/Util/Wiki/DokuWikiApi.class.php b/inc/SP/Util/Wiki/DokuWikiApi.class.php index 03ecb8b5..e2e22325 100644 --- a/inc/SP/Util/Wiki/DokuWikiApi.class.php +++ b/inc/SP/Util/Wiki/DokuWikiApi.class.php @@ -43,7 +43,7 @@ class DokuWikiApi extends DokuWikiApiBase /** * @var string */ - private $_namespace; + private $namespace; /** * Constructor @@ -58,7 +58,7 @@ class DokuWikiApi extends DokuWikiApiBase try { $this->setConnectionData($url, $user, $pass); - if (!empty($this->_apiUser) && Session::getDokuWikiSession() === false) { + if (!empty($this->apiUser) && Session::getDokuWikiSession() === false) { $Res = new DokuWikiApiParse($this->doLogin()); $this->catchError($Res); $resLogin = $Res->parseParams(); @@ -70,7 +70,7 @@ class DokuWikiApi extends DokuWikiApiBase } } - $this->_namespace = Config::getValue('dokuwiki_namespace'); + $this->namespace = Config::getConfig()->getDokuwikiNamespace(); } catch (SPException $e) { $this->logException($e); throw $e; @@ -149,8 +149,8 @@ class DokuWikiApi extends DokuWikiApiBase */ public function getPage($page) { - if (!empty($this->_namespace)) { - $page = $this->_namespace . ':' . $page; + if (!empty($this->namespace)) { + $page = $this->namespace . ':' . $page; } try { @@ -195,8 +195,8 @@ class DokuWikiApi extends DokuWikiApiBase */ public function getPageInfo($page) { - if (!empty($this->_namespace)) { - $page = $this->_namespace . ':' . $page; + if (!empty($this->namespace)) { + $page = $this->namespace . ':' . $page; } try { diff --git a/inc/SP/Util/Wiki/DokuWikiApiBase.class.php b/inc/SP/Util/Wiki/DokuWikiApiBase.class.php index da4d694c..83fedf3a 100644 --- a/inc/SP/Util/Wiki/DokuWikiApiBase.class.php +++ b/inc/SP/Util/Wiki/DokuWikiApiBase.class.php @@ -45,34 +45,34 @@ abstract class DokuWikiApiBase /** * @var string */ - protected $_apiUser = ''; + protected $apiUser = ''; /** * @var string */ - protected $_apiPassword = ''; + protected $apiPassword = ''; /** * @var string */ - protected $_apiUrl = ''; + protected $apiUrl = ''; /** * @var DOMDocument */ - private $_xml; + private $xml; /** * @var \DOMElement */ - private $_root; + private $root; /** * @var \DOMElement */ - private $_params; + private $params; /** * @return string */ public function getXml() { - return $this->_xml->saveXML(); + return $this->xml->saveXML(); } /** @@ -85,8 +85,8 @@ abstract class DokuWikiApiBase { try { $this->createMsg('dokuwiki.login'); - $this->addParam($this->_apiUser); - $this->addParam($this->_apiPassword); + $this->addParam($this->apiUser); + $this->addParam($this->apiPassword); return $this->callWiki(); } catch (SPException $e) { throw $e; @@ -102,16 +102,16 @@ abstract class DokuWikiApiBase protected function createMsg($function) { try { - $this->_xml = new DOMDocument('1.0', 'UTF-8'); + $this->xml = new DOMDocument('1.0', 'UTF-8'); - $xmlMethodCall = $this->_xml->createElement('methodCall'); - $this->_root = $this->_xml->appendChild($xmlMethodCall); + $xmlMethodCall = $this->xml->createElement('methodCall'); + $this->root = $this->xml->appendChild($xmlMethodCall); - $xmlMethodName = $this->_xml->createElement('methodName', $function); - $this->_root->appendChild($xmlMethodName); + $xmlMethodName = $this->xml->createElement('methodName', $function); + $this->root->appendChild($xmlMethodName); - $this->_params = $this->_xml->createElement('params'); - $this->_root->appendChild($this->_params); + $this->params = $this->xml->createElement('params'); + $this->root->appendChild($this->params); } catch (DOMException $e) { throw new SPException(SPException::SP_WARNING, $e->getMessage(), __FUNCTION__); } @@ -126,19 +126,19 @@ abstract class DokuWikiApiBase protected function addParam($value) { try { - $xmlParam = $this->_xml->createElement('param'); - $xmlValue = $this->_xml->createElement('value'); + $xmlParam = $this->xml->createElement('param'); + $xmlValue = $this->xml->createElement('value'); if (is_numeric($value)) { - $xmlValue->appendChild($this->_xml->createElement('int', intval($value))); + $xmlValue->appendChild($this->xml->createElement('int', intval($value))); } elseif (is_string($value)) { - $xmlValue->appendChild($this->_xml->createElement('string', $value)); + $xmlValue->appendChild($this->xml->createElement('string', $value)); } elseif (is_bool($value)) { - $xmlValue->appendChild($this->_xml->createElement('boolean', intval($value))); + $xmlValue->appendChild($this->xml->createElement('boolean', intval($value))); } $xmlParam->appendChild($xmlValue); - $this->_params->appendChild($xmlParam); + $this->params->appendChild($xmlParam); } catch (DOMException $e) { throw new SPException(SPException::SP_WARNING, $e->getMessage(), __FUNCTION__); } @@ -151,9 +151,9 @@ abstract class DokuWikiApiBase { try { $data['type'] = array('Content-Type: text/xml'); - $data['data'] = $this->_xml->saveXML(); + $data['data'] = $this->xml->saveXML(); - return Util::getDataFromUrl($this->_apiUrl, $data, true); + return Util::getDataFromUrl($this->apiUrl, $data, true); } catch (SPException $e) { throw $e; } @@ -204,11 +204,11 @@ abstract class DokuWikiApiBase */ protected function setConnectionData($url, $user, $pass) { - $this->_apiUrl = (empty($url)) ? Config::getValue('dokuwiki_url') : $url; - $this->_apiUser = (empty($user)) ? Config::getValue('dokuwiki_user') : $user; - $this->_apiPassword = (empty($pass)) ? Config::getValue('dokuwiki_pass') : $pass; + $this->apiUrl = (empty($url)) ? Config::getConfig()->getDokuwikiUrl() : $url; + $this->apiUser = (empty($user)) ? Config::getConfig()->getDokuwikiUser() : $user; + $this->apiPassword = (empty($pass)) ? Config::getConfig()->getDokuwikiPass() : $pass; - if (empty($this->_apiUrl)){ + if (empty($this->apiUrl)){ throw new SPException(SPException::SP_WARNING, _('URL de conexión no establecida')); } } diff --git a/inc/themes/classic/debug.inc b/inc/themes/classic/debug.inc index 2f9a6561..428d6cf1 100644 --- a/inc/themes/classic/debug.inc +++ b/inc/themes/classic/debug.inc @@ -10,7 +10,7 @@
  • MASTER PASS:
  • CONFIG FILE: -
    +
  • diff --git a/inc/themes/classic/inc/Icons.class.php b/inc/themes/classic/inc/Icons.class.php index 478e0b5a..edd9bdf0 100644 --- a/inc/themes/classic/inc/Icons.class.php +++ b/inc/themes/classic/inc/Icons.class.php @@ -44,39 +44,39 @@ class Icons extends ThemeIconsBase */ public function setIcons() { - $this->_iconAdd = new ImageIcon(Init::$WEBURI . '/imgs/add.png', null, _('Añadir')); - $this->_iconView = new ImageIcon(Init::$WEBURI . '/imgs/view.png', null, _('Ver Detalles')); - $this->_iconViewPass = new ImageIcon(Init::$WEBURI . '/imgs/user-pass.png', null, _('Ver Clave')); - $this->_iconEdit = new ImageIcon(Init::$WEBURI . '/imgs/edit.png', null, _('Editar')); - $this->_iconDelete = new ImageIcon(Init::$WEBURI . '/imgs/delete.png', null, _('Eliminar')); - $this->_iconEditPass = new ImageIcon(Init::$WEBURI . '/imgs/key.png', null, _('Cambiar Clave')); - $this->_iconAppAdmin = new ImageIcon(Init::$WEBURI . '/imgs/check_blue.png', null, _('Admin Aplicación')); - $this->_iconAccAdmin = new ImageIcon(Init::$WEBURI . '/imgs/check_orange.png', null, _('Admin Cuentas')); - $this->_iconLdapUser = new ImageIcon(Init::$WEBURI . '/imgs/ldap.png', null, _('Usuario de LDAP')); - $this->_iconDisabled = new ImageIcon(Init::$WEBURI . '/imgs/disabled.png', null, _('Deshabilitado')); - $this->_iconRefresh = new ImageIcon(Init::$WEBURI . '/imgs/refresh.png', null, _('Actualizar')); - $this->_iconCopy = new ImageIcon(Init::$WEBURI . '/imgs/btn_copy.png', null, _('Copiar')); - $this->_iconClipboard = new ImageIcon(Init::$WEBURI . '/imgs/clipboard.png'); - $this->_iconEmail = new ImageIcon(Init::$WEBURI . '/imgs/request.png', null, _('Email')); - $this->_iconOptional = new ImageIcon(Init::$WEBURI . '/imgs/action.png'); - $this->_iconPublicLink = new ImageIcon(Init::$WEBURI . '/imgs/action.png'); - $this->_iconBack = new ImageIcon(Init::$WEBURI . '/imgs/back.png', null, _('Volver')); - $this->_iconRestore = new ImageIcon(Init::$WEBURI . '/imgs/restore.png', null, ('Restaurar')); - $this->_iconSave = new ImageIcon(Init::$WEBURI . '/imgs/check.png', null, _('Guardar')); - $this->_iconHelp = new ImageIcon(Init::$WEBURI . '/imgs/help.png', null, _('Ayuda')); - $this->_iconClear = new ImageIcon(Init::$WEBURI . '/imgs/clear.png', null, _('Limpiar')); - $this->_iconPlay = new ImageIcon(Init::$WEBURI . '/imgs/start.png', null, _('Realizar')); - $this->_iconDownload = new ImageIcon(Init::$WEBURI . '/imgs/download.png', null, _('Descargar')); - $this->_iconWarning = new ImageIcon(Init::$WEBURI . '/imgs/warning.png', null, _('Aviso')); + $this->iconAdd = new ImageIcon(Init::$WEBURI . '/imgs/add.png', null, _('Añadir')); + $this->iconView = new ImageIcon(Init::$WEBURI . '/imgs/view.png', null, _('Ver Detalles')); + $this->iconViewPass = new ImageIcon(Init::$WEBURI . '/imgs/user-pass.png', null, _('Ver Clave')); + $this->iconEdit = new ImageIcon(Init::$WEBURI . '/imgs/edit.png', null, _('Editar')); + $this->iconDelete = new ImageIcon(Init::$WEBURI . '/imgs/delete.png', null, _('Eliminar')); + $this->iconEditPass = new ImageIcon(Init::$WEBURI . '/imgs/key.png', null, _('Cambiar Clave')); + $this->iconAppAdmin = new ImageIcon(Init::$WEBURI . '/imgs/check_blue.png', null, _('Admin Aplicación')); + $this->iconAccAdmin = new ImageIcon(Init::$WEBURI . '/imgs/check_orange.png', null, _('Admin Cuentas')); + $this->iconLdapUser = new ImageIcon(Init::$WEBURI . '/imgs/ldap.png', null, _('Usuario de LDAP')); + $this->iconDisabled = new ImageIcon(Init::$WEBURI . '/imgs/disabled.png', null, _('Deshabilitado')); + $this->iconRefresh = new ImageIcon(Init::$WEBURI . '/imgs/refresh.png', null, _('Actualizar')); + $this->iconCopy = new ImageIcon(Init::$WEBURI . '/imgs/btn_copy.png', null, _('Copiar')); + $this->iconClipboard = new ImageIcon(Init::$WEBURI . '/imgs/clipboard.png'); + $this->iconEmail = new ImageIcon(Init::$WEBURI . '/imgs/request.png', null, _('Email')); + $this->iconOptional = new ImageIcon(Init::$WEBURI . '/imgs/action.png'); + $this->iconPublicLink = new ImageIcon(Init::$WEBURI . '/imgs/action.png'); + $this->iconBack = new ImageIcon(Init::$WEBURI . '/imgs/back.png', null, _('Volver')); + $this->iconRestore = new ImageIcon(Init::$WEBURI . '/imgs/restore.png', null, ('Restaurar')); + $this->iconSave = new ImageIcon(Init::$WEBURI . '/imgs/check.png', null, _('Guardar')); + $this->iconHelp = new ImageIcon(Init::$WEBURI . '/imgs/help.png', null, _('Ayuda')); + $this->iconClear = new ImageIcon(Init::$WEBURI . '/imgs/clear.png', null, _('Limpiar')); + $this->iconPlay = new ImageIcon(Init::$WEBURI . '/imgs/start.png', null, _('Realizar')); + $this->iconDownload = new ImageIcon(Init::$WEBURI . '/imgs/download.png', null, _('Descargar')); + $this->iconWarning = new ImageIcon(Init::$WEBURI . '/imgs/warning.png', null, _('Aviso')); // Iconos de Navegación - $this->_iconNavPrev = new FontIcon('chevron_left', null, _('Página anterior')); - $this->_iconNavNext = new FontIcon('chevron_right', null, _('Página siguiente')); - $this->_iconNavFirst = new FontIcon('arrow_back', null, _('Primera página')); - $this->_iconNavLast = new FontIcon('arrow_forward', null, _('Última página')); + $this->iconNavPrev = new FontIcon('chevron_left', null, _('Página anterior')); + $this->iconNavNext = new FontIcon('chevron_right', null, _('Página siguiente')); + $this->iconNavFirst = new FontIcon('arrow_back', null, _('Primera página')); + $this->iconNavLast = new FontIcon('arrow_forward', null, _('Última página')); // Iconos de Ordenación - $this->_iconUp = new FontIcon('arrow_drop_up'); - $this->_iconDown = new FontIcon('arrow_drop_down'); + $this->iconUp = new FontIcon('arrow_drop_up'); + $this->iconDown = new FontIcon('arrow_drop_down'); } } \ No newline at end of file diff --git a/inc/themes/material-blue/account.inc b/inc/themes/material-blue/account.inc index 1eb23d2b..047fc0ee 100644 --- a/inc/themes/material-blue/account.inc +++ b/inc/themes/material-blue/account.inc @@ -41,7 +41,7 @@ - $name): ?>