diff --git a/inc/SP/Account/AccountCrypt.class.php b/inc/SP/Account/AccountCrypt.class.php index b3707e61..f2aad837 100644 --- a/inc/SP/Account/AccountCrypt.class.php +++ b/inc/SP/Account/AccountCrypt.class.php @@ -55,6 +55,8 @@ class AccountCrypt */ public function updateOldPass(&$currentMasterPass) { + set_time_limit(300); + $accountsOk = []; $userId = Session::getUserData()->getUserId(); $demoEnabled = Checks::demoIsEnabled(); diff --git a/inc/SP/Account/AccountHistoryCrypt.class.php b/inc/SP/Account/AccountHistoryCrypt.class.php index 20e5acc4..a69ee830 100644 --- a/inc/SP/Account/AccountHistoryCrypt.class.php +++ b/inc/SP/Account/AccountHistoryCrypt.class.php @@ -55,6 +55,8 @@ class AccountHistoryCrypt */ public function updateOldPass(&$currentMasterPass) { + set_time_limit(300); + $accountsOk = []; $demoEnabled = Checks::demoIsEnabled(); $errorCount = 0; diff --git a/inc/SP/Controller/ConfigActionController.class.php b/inc/SP/Controller/ConfigActionController.class.php index 6a9c4b00..d61a670a 100644 --- a/inc/SP/Controller/ConfigActionController.class.php +++ b/inc/SP/Controller/ConfigActionController.class.php @@ -653,8 +653,8 @@ class ConfigActionController implements ItemControllerInterface } $ImportParams = new ImportParams(); - $ImportParams->setDefaultUser(Request::analyze('defUser', Session::getUserData()->getUserId())); - $ImportParams->setDefaultGroup(Request::analyze('defGroup', Session::getUserData()->getUserGroupId())); + $ImportParams->setDefaultUser(Request::analyze('import_defaultuser', Session::getUserData()->getUserId())); + $ImportParams->setDefaultGroup(Request::analyze('import_defaultgroup', Session::getUserData()->getUserGroupId())); $ImportParams->setImportPwd(Request::analyzeEncrypted('importPwd')); $ImportParams->setImportMasterPwd(Request::analyzeEncrypted('importMasterPwd')); $ImportParams->setCsvDelimiter(Request::analyze('csvDelimiter')); diff --git a/inc/SP/Controller/MainActionController.class.php b/inc/SP/Controller/MainActionController.class.php index b60c7bae..0e13b5ea 100644 --- a/inc/SP/Controller/MainActionController.class.php +++ b/inc/SP/Controller/MainActionController.class.php @@ -58,8 +58,6 @@ class MainActionController && $hash === Config::getConfig()->getUpgradeKey() ) { $this->upgrade($dbVersion, 'db'); - - ConfigDB::setValue('version', implode(Util::getVersion(true))); } else { $controller = new MainController(); $controller->getUpgrade($dbVersion); @@ -103,7 +101,7 @@ class MainActionController private function upgrade($version, $type) { try { - Upgrade::doUpgrade($version, $type); + Upgrade::doUpgrade($version); $Config = Config::getConfig(); $Config->setMaintenance(false); diff --git a/inc/SP/Core/Init.class.php b/inc/SP/Core/Init.class.php index d8b8bdd3..9b25e58f 100644 --- a/inc/SP/Core/Init.class.php +++ b/inc/SP/Core/Init.class.php @@ -507,7 +507,9 @@ class Init */ public static function isLoggedIn() { - return (DiFactory::getDBStorage()->getDbStatus() === 0 && Session::getUserData()->getUserLogin()); + return (DiFactory::getDBStorage()->getDbStatus() === 0 + && Session::getUserData()->getUserLogin() + && is_object(Session::getUserPreferences())); } /** diff --git a/inc/SP/Core/Upgrade/Account.class.php b/inc/SP/Core/Upgrade/Account.class.php new file mode 100644 index 00000000..4cf0ee25 --- /dev/null +++ b/inc/SP/Core/Upgrade/Account.class.php @@ -0,0 +1,64 @@ +. + */ + +namespace SP\Core\Upgrade; + +use SP\Core\Exceptions\SPException; +use SP\Storage\DB; +use SP\Storage\QueryData; + +/** + * Class Account + * + * @package SP\Core\Upgrade + */ +class Account +{ + /** + * Actualizar registros con usuarios no existentes + * + * @return bool + */ + public static function fixAccountsId() + { + try { + DB::beginTransaction(); + + $Data = new QueryData(); + $query = /** @lang SQL */ + 'DELETE FROM accUsers WHERE accuser_accountId NOT IN (SELECT account_id FROM accounts) OR accuser_accountId IS NULL'; + $Data->setQuery($query); + + DB::getQuery($Data); + + DB::endTransaction(); + + return true; + } catch (SPException $e) { + DB::rollbackTransaction(); + + return false; + } + } +} \ No newline at end of file diff --git a/inc/SP/Core/Upgrade/Category.class.php b/inc/SP/Core/Upgrade/Category.class.php index 9e97f103..a3d32b03 100644 --- a/inc/SP/Core/Upgrade/Category.class.php +++ b/inc/SP/Core/Upgrade/Category.class.php @@ -71,12 +71,12 @@ class Category DB::getQuery($Data); DB::endTransaction(); + + return true; } catch (SPException $e) { DB::rollbackTransaction(); return false; } - - return true; } } \ No newline at end of file diff --git a/inc/SP/Core/Upgrade/Crypt.class.php b/inc/SP/Core/Upgrade/Crypt.class.php index ea1fd8c1..9e21ac1f 100644 --- a/inc/SP/Core/Upgrade/Crypt.class.php +++ b/inc/SP/Core/Upgrade/Crypt.class.php @@ -51,18 +51,26 @@ class Crypt public static function migrate(&$masterPass) { try { - DB::beginTransaction(); + if (!DB::beginTransaction()) { + throw new SPException(SPException::SP_ERROR, __('No es posible iniciar una transacción', false)); + } self::migrateAccounts($masterPass); self::migrateCustomFields($masterPass); - DB::endTransaction(); + if (!DB::endTransaction()) { + throw new SPException(SPException::SP_ERROR, __('No es posible finalizar una transacción', false)); + } } catch (CryptoException $e) { - DB::rollbackTransaction(); + if (DB::rollbackTransaction()) { + debugLog('Rollback'); + } return false; } catch (SPException $e) { - DB::rollbackTransaction(); + if (DB::rollbackTransaction()) { + debugLog('Rollback'); + } return false; } diff --git a/inc/SP/Core/Upgrade/Customer.class.php b/inc/SP/Core/Upgrade/Customer.class.php index 78363878..78fbad87 100644 --- a/inc/SP/Core/Upgrade/Customer.class.php +++ b/inc/SP/Core/Upgrade/Customer.class.php @@ -71,12 +71,12 @@ class Customer DB::getQuery($Data); DB::endTransaction(); + + return true; } catch (SPException $e) { DB::rollbackTransaction(); return false; } - - return true; } } \ No newline at end of file diff --git a/inc/SP/Core/Upgrade/Group.class.php b/inc/SP/Core/Upgrade/Group.class.php index 0da1b93f..487104ad 100644 --- a/inc/SP/Core/Upgrade/Group.class.php +++ b/inc/SP/Core/Upgrade/Group.class.php @@ -63,12 +63,12 @@ class Group DB::getQuery($Data); DB::endTransaction(); + + return true; } catch (SPException $e) { DB::rollbackTransaction(); return false; } - - return true; } } \ No newline at end of file diff --git a/inc/SP/Core/Upgrade/Profile.class.php b/inc/SP/Core/Upgrade/Profile.class.php index 0a297019..af8ab20c 100644 --- a/inc/SP/Core/Upgrade/Profile.class.php +++ b/inc/SP/Core/Upgrade/Profile.class.php @@ -65,12 +65,12 @@ class Profile DB::getQuery($Data); DB::endTransaction(); + + return true; } catch (SPException $e) { DB::rollbackTransaction(); return false; } - - return true; } } \ No newline at end of file diff --git a/inc/SP/Core/Upgrade/Upgrade.class.php b/inc/SP/Core/Upgrade/Upgrade.class.php index 35e11126..74f3f199 100644 --- a/inc/SP/Core/Upgrade/Upgrade.class.php +++ b/inc/SP/Core/Upgrade/Upgrade.class.php @@ -52,7 +52,7 @@ defined('APP_ROOT') || die(); */ class Upgrade { - private static $dbUpgrade = [110, 1121, 1122, 1123, 11213, 11219, 11220, 12001, 12002, 1316011001, 1316020501, 1316100601, 20017011302, 20017011701, 20017012901, 20117021901]; + private static $dbUpgrade = [110, 1121, 1122, 1123, 11213, 11219, 11220, 12001, 12002, 1316011001, 1316100601, 20017011302, 20017011701, 20017012901, 20117021901]; private static $cfgUpgrade = [1124, 1316020501, 20017011202]; private static $auxUpgrade = [12001, 12002, 20017010901, 20017011202]; private static $appUpgrade = [20117021901]; @@ -61,34 +61,32 @@ class Upgrade * Inicia el proceso de actualización de la BBDD. * * @param int $version con la versión de la BBDD actual - * @param $type * @return bool * @throws SPException */ - public static function doUpgrade($version, $type) + public static function doUpgrade($version) { - if ($type === 'db') { - foreach (self::$dbUpgrade as $upgradeVersion) { - if ($version < $upgradeVersion) { - if (self::auxPreDbUpgrade($upgradeVersion) === false) { - throw new SPException(SPException::SP_CRITICAL, - __('Error al aplicar la actualización auxiliar', false), - __('Compruebe el registro de eventos para más detalles', false)); - } - - if (self::upgradeDB($upgradeVersion) === false) { - throw new SPException(SPException::SP_CRITICAL, __('Error al aplicar la actualización de la Base de Datos', false), - __('Compruebe el registro de eventos para más detalles', false)); - } - } - } - } elseif ($type === 'app') { - foreach (self::$appUpgrade as $upgradeVersion) { - if ($version < $upgradeVersion && self::appUpgrades($upgradeVersion) === false) { + foreach (self::$dbUpgrade as $upgradeVersion) { + if ($version < $upgradeVersion) { + if (self::auxPreDbUpgrade($upgradeVersion) === false) { throw new SPException(SPException::SP_CRITICAL, - __('Error al aplicar la actualización de la aplicación', false), + __('Error al aplicar la actualización auxiliar', false), __('Compruebe el registro de eventos para más detalles', false)); } + + if (self::upgradeDB($upgradeVersion) === false) { + throw new SPException(SPException::SP_CRITICAL, + __('Error al aplicar la actualización de la Base de Datos', false), + __('Compruebe el registro de eventos para más detalles', false)); + } + } + } + + foreach (self::$appUpgrade as $upgradeVersion) { + if ($version < $upgradeVersion && self::appUpgrades($upgradeVersion) === false) { + throw new SPException(SPException::SP_CRITICAL, + __('Error al aplicar la actualización de la aplicación', false), + __('Compruebe el registro de eventos para más detalles', false)); } } @@ -113,8 +111,11 @@ class Upgrade { switch ($version) { case 1316011001: + return self::upgradeDB(1300000000); + case 1316100601: return - UserUpgrade::fixUsersId(Request::analyze('userid', 1)) + Account::fixAccountsId() + && UserUpgrade::fixUsersId(Request::analyze('userid', 1)) && Group::fixGroupId(Request::analyze('groupid', 1)) && Profile::fixProfilesId(Request::analyze('profileid', 1)) && Category::fixCategoriesId(Request::analyze('categoryid', 1)) @@ -139,7 +140,7 @@ class Upgrade $queries = self::getQueriesFromFile($version); - if (count($queries) === 0) { + if (count($queries) === 0 || (int)ConfigDB::getValue('version') === $version) { $LogMessage->addDescription(__('No es necesario actualizar la Base de Datos.', false)); $Log->writeLog(); return true; @@ -162,6 +163,8 @@ class Upgrade } } + ConfigDB::setValue('version', $version); + $LogMessage->addDescription(__('Actualización de la Base de Datos realizada correctamente.', false)); $Log->writeLog(); @@ -210,9 +213,7 @@ class Upgrade $databaseVersion = (int)str_replace('.', '', ConfigDB::getValue('version')); if ($databaseVersion < $version) { - if (self::upgradeDB($version)) { - ConfigDB::setValue('version', $version); - } else { + if (!self::upgradeDB($version)) { $dbResult = false; } } @@ -225,8 +226,8 @@ class Upgrade return $dbResult === true && is_object($UserData) && !empty($masterPass) - && Crypt::migrateHash($masterPass) && Crypt::migrate($masterPass) + && Crypt::migrateHash($masterPass) && UserMigrate::setMigrateUsers(); } } catch (SPException $e) { diff --git a/inc/SP/Core/Upgrade/User.class.php b/inc/SP/Core/Upgrade/User.class.php index 8d0fbba6..f73345f0 100644 --- a/inc/SP/Core/Upgrade/User.class.php +++ b/inc/SP/Core/Upgrade/User.class.php @@ -93,14 +93,26 @@ class User DB::getQuery($Data); + $query = /** @lang SQL */ + 'DELETE FROM usrToGroups WHERE usertogroup_userId <> ? AND usertogroup_userId NOT IN (' . $paramsIn . ') OR usertogroup_userId IS NULL'; + $Data->setQuery($query); + + DB::getQuery($Data); + + $query = /** @lang SQL */ + 'DELETE FROM accUsers WHERE accuser_userId <> ? AND accuser_userId NOT IN (' . $paramsIn . ') OR accuser_userId IS NULL'; + $Data->setQuery($query); + + DB::getQuery($Data); + DB::endTransaction(); + + return true; } catch (SPException $e) { DB::rollbackTransaction(); return false; } - - return true; } /** diff --git a/inc/SP/Forms/AccountForm.class.php b/inc/SP/Forms/AccountForm.class.php index 6a4d3798..c21a5757 100644 --- a/inc/SP/Forms/AccountForm.class.php +++ b/inc/SP/Forms/AccountForm.class.php @@ -128,7 +128,9 @@ class AccountForm extends FormBase implements FormInterface */ protected function checkPass() { - if (!$this->AccountData->getAccountPass()) { + if ($this->AccountData->getAccountParentId() > 0) { + return; + } elseif (!$this->AccountData->getAccountPass()) { throw new ValidationException(__('Es necesaria una clave', false)); } elseif (Request::analyzeEncrypted('passR') !== $this->AccountData->getAccountPass()) { throw new ValidationException(__('Las claves no coinciden', false)); diff --git a/inc/SP/Import/XmlImportTrait.class.php b/inc/SP/Import/XmlImportTrait.class.php index 8bebb591..59e0c3f3 100644 --- a/inc/SP/Import/XmlImportTrait.class.php +++ b/inc/SP/Import/XmlImportTrait.class.php @@ -24,7 +24,6 @@ namespace SP\Import; -use Import\XmlFileImport; use SP\Core\Exceptions\SPException; defined('APP_ROOT') || die(); diff --git a/inc/SP/Log/Log.class.php b/inc/SP/Log/Log.class.php index 0060ac64..ca54c4c1 100644 --- a/inc/SP/Log/Log.class.php +++ b/inc/SP/Log/Log.class.php @@ -45,6 +45,10 @@ class Log extends ActionLog * @var int */ public static $numRows = 0; + /** + * @var int + */ + private static $logDbEnabled = 1; /** * Obtener los eventos guardados. @@ -120,6 +124,7 @@ class Log extends ActionLog public function writeLog($resetDescription = false) { if ((defined('IS_INSTALLER') && IS_INSTALLER === 1) + || self::$logDbEnabled === 0 || DiFactory::getDBStorage()->getDbStatus() === 1 ) { debugLog('Action: ' . $this->LogMessage->getAction() . ' -- Description: ' . $this->LogMessage->getDescription() . ' -- Details: ' . $this->LogMessage->getDetails()); @@ -164,8 +169,11 @@ class Log extends ActionLog try { DB::getQuery($Data); } catch (SPException $e) { - debugLog($e->getMessage(), true); - debugLog($e->getHint()); + debugLog(__($e->getMessage()), true); + debugLog(__($e->getHint())); + + // Desactivar el log a BD si falla + self::$logDbEnabled = 0; } Language::unsetAppLocales(); diff --git a/inc/SP/Storage/DB.class.php b/inc/SP/Storage/DB.class.php index a498dc6c..a39bcb25 100644 --- a/inc/SP/Storage/DB.class.php +++ b/inc/SP/Storage/DB.class.php @@ -30,6 +30,7 @@ use SP\Core\DiFactory; use SP\Core\Exceptions\ConstraintException; use SP\Core\Exceptions\QueryException; use SP\Core\Exceptions\SPException; +use SP\Core\Messages\LogMessage; use SP\Log\Log; use SP\Util\Util; @@ -249,7 +250,7 @@ class DB debugLog('Exception: ' . $e->getMessage()); debugLog(ob_get_clean()); - throw new SPException(SPException::SP_CRITICAL, $e->getMessage(), '', $e->getCode()); + throw new SPException(SPException::SP_CRITICAL, $e->getMessage(), '', $e->getCode(), $e); } } @@ -290,17 +291,21 @@ class DB { $caller = Util::traceLastCall($queryFunction); - $Log = new Log(); - $LogMessage = $Log->getLogMessage(); + $LogMessage = new LogMessage(); $LogMessage->setAction($caller); $LogMessage->addDescription(__('Error en la consulta', false)); $LogMessage->addDescription(sprintf('%s (%s)', $errorMsg, $errorCode)); $LogMessage->addDetails('SQL', DBUtil::escape($query)); - $Log->setLogLevel(Log::ERROR); - $Log->writeLog(); debugLog($LogMessage->getDescription(), true); debugLog($LogMessage->getDetails()); + + // Solo registrar eventos de ls BD si no son consultas del registro de eventos + if ($caller !== 'writeLog') { + $Log = new Log($LogMessage); + $Log->setLogLevel(Log::ERROR); + $Log->writeLog(); + } } /** @@ -345,6 +350,8 @@ class DB try { $db = new DB(); $db->doQuery($queryData); + + return true; } catch (SPException $e) { $queryData->setQueryStatus($e->getCode()); @@ -352,12 +359,10 @@ class DB if ($e->getCode() === 23000) { throw new ConstraintException(SPException::SP_ERROR, __('Restricción de integridad', false), $e->getMessage(), $e->getCode()); - } else { - throw new QueryException(SPException::SP_ERROR, $errorMessage, $e->getMessage(), $e->getCode()); } - } - return true; + throw new QueryException(SPException::SP_ERROR, $errorMessage, $e->getMessage(), $e->getCode()); + } } /** diff --git a/inc/sql/1300000000.sql b/inc/sql/1300000000.sql new file mode 100644 index 00000000..e03a6135 --- /dev/null +++ b/inc/sql/1300000000.sql @@ -0,0 +1,75 @@ +ALTER TABLE `usrData` ENGINE = InnoDB; +ALTER TABLE `accFiles` ENGINE = InnoDB; +ALTER TABLE `accGroups` ENGINE = InnoDB; +ALTER TABLE `accHistory` ENGINE = InnoDB; +ALTER TABLE `accUsers` ENGINE = InnoDB; +ALTER TABLE `categories` ENGINE = InnoDB; +ALTER TABLE `config` ENGINE = InnoDB; +ALTER TABLE `customers` ENGINE = InnoDB; +ALTER TABLE `log` ENGINE = InnoDB; +ALTER TABLE `usrGroups` ENGINE = InnoDB; +ALTER TABLE `usrPassRecover` ENGINE = InnoDB; +ALTER TABLE `usrProfiles` ENGINE = InnoDB; +ALTER TABLE `accounts` ENGINE = InnoDB; + +ALTER TABLE `log` ADD log_level VARCHAR(20) NOT NULL; +ALTER TABLE `config` CHANGE config_value config_value VARCHAR(2000); + +CREATE TABLE IF NOT EXISTS `publicLinks` ( + `publicLink_id` int UNSIGNED NOT NULL AUTO_INCREMENT, + `publicLink_itemId` int UNSIGNED DEFAULT NULL, + `publicLink_hash` varbinary(100) NOT NULL, + `publicLink_linkData` longblob, + PRIMARY KEY (`publicLink_id`), + UNIQUE KEY `IDX_hash` (`publicLink_hash`), + UNIQUE KEY `unique_publicLink_hash` (`publicLink_hash`), + UNIQUE KEY `unique_publicLink_accountId` (`publicLink_itemId`), + KEY `IDX_itemId` (`publicLink_itemId`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE IF NOT EXISTS `accFavorites` ( + `accfavorite_accountId` smallint(5) unsigned NOT NULL, + `accfavorite_userId` smallint(5) unsigned NOT NULL, + KEY `fk_accFavorites_accounts_idx` (`accfavorite_accountId`), + KEY `fk_accFavorites_users_idx` (`accfavorite_userId`), + KEY `search_idx` (`accfavorite_accountId`,`accfavorite_userId`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE IF NOT EXISTS `tags` ( + `tag_id` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `tag_name` VARCHAR(45) NOT NULL, + `tag_hash` BINARY(40) NOT NULL, + PRIMARY KEY (`tag_id`), + INDEX `IDX_name` (`tag_name` ASC), + UNIQUE INDEX `tag_hash_UNIQUE` (`tag_hash` ASC) +) ENGINE = InnoDB DEFAULT CHARSET = utf8; + +CREATE TABLE IF NOT EXISTS `accTags` ( + `acctag_accountId` SMALLINT(10) UNSIGNED NOT NULL, + `acctag_tagId` INT UNSIGNED NOT NULL, + INDEX `IDX_id` (`acctag_accountId` ASC, `acctag_tagId` ASC) +) ENGINE = InnoDB DEFAULT CHARSET = utf8; + +CREATE TABLE IF NOT EXISTS `plugins` ( + `plugin_id` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `plugin_name` VARCHAR(100) NOT NULL, + `plugin_data` VARBINARY(5000) NULL, + `plugin_enabled` BIT(1) NOT NULL DEFAULT b'0', + PRIMARY KEY (`plugin_id`), + UNIQUE INDEX `plugin_name_UNIQUE` (`plugin_name` ASC) +) ENGINE = InnoDB DEFAULT CHARSET = utf8; + +CREATE TABLE IF NOT EXISTS `notices` ( + `notice_id` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `notice_type` VARCHAR(100) NULL, + `notice_component` VARCHAR(100) NOT NULL, + `notice_description` VARCHAR(500) NOT NULL, + `notice_date` INT UNSIGNED NOT NULL, + `notice_checked` BIT(1) NULL DEFAULT b'0', + `notice_userId` SMALLINT(5) UNSIGNED NULL, + `notice_sticky` BIT(1) NULL DEFAULT b'0', + `notice_onlyAdmin` BIT(1) NULL DEFAULT b'0', + PRIMARY KEY (`notice_id`), + INDEX `IDX_userId` (`notice_userId` ASC, `notice_checked` ASC, `notice_date` ASC), + INDEX `IDX_component` (`notice_component` ASC, `notice_date` ASC, `notice_checked` ASC, `notice_userId` ASC) +) ENGINE = InnoDB DEFAULT CHARSET = utf8; \ No newline at end of file diff --git a/inc/sql/1316011001.sql b/inc/sql/1316011001.sql deleted file mode 100644 index 0db4404e..00000000 --- a/inc/sql/1316011001.sql +++ /dev/null @@ -1,50 +0,0 @@ --- To 1.3.16011001; -ALTER TABLE `log` - ADD log_level VARCHAR(20) NOT NULL; -CREATE TABLE `publicLinks` ( - publicLink_id INT UNSIGNED PRIMARY KEY NOT NULL AUTO_INCREMENT, - publicLink_itemId INT UNSIGNED, - publicLink_hash VARBINARY(100) NOT NULL, - publicLink_linkData LONGBLOB -); -ALTER TABLE `usrData` - ENGINE = InnoDB; -ALTER TABLE `accFiles` - ENGINE = InnoDB; -ALTER TABLE `accGroups` - ENGINE = InnoDB; -ALTER TABLE `accHistory` - ENGINE = InnoDB; -ALTER TABLE `accUsers` - ENGINE = InnoDB; -ALTER TABLE `categories` - ENGINE = InnoDB; -ALTER TABLE `config` - ENGINE = InnoDB; -ALTER TABLE `customers` - ENGINE = InnoDB; -ALTER TABLE `log` - ENGINE = InnoDB; -ALTER TABLE `usrGroups` - ENGINE = InnoDB; -ALTER TABLE `usrPassRecover` - ENGINE = InnoDB; -ALTER TABLE `usrProfiles` - ENGINE = InnoDB; -ALTER TABLE `accounts` - ENGINE = InnoDB; -CREATE UNIQUE INDEX unique_publicLink_accountId - ON publicLinks (publicLink_itemId); -CREATE UNIQUE INDEX unique_publicLink_hash - ON publicLinks (publicLink_hash); -ALTER TABLE `config` - CHANGE config_value config_value VARCHAR(2000); -CREATE TABLE `accFavorites` ( - `accfavorite_accountId` SMALLINT UNSIGNED NOT NULL, - `accfavorite_userId` SMALLINT UNSIGNED NOT NULL, - INDEX `fk_accFavorites_accounts_idx` (`accfavorite_accountId` ASC), - INDEX `fk_accFavorites_users_idx` (`accfavorite_userId` ASC), - INDEX `search_idx` (`accfavorite_accountId` ASC, `accfavorite_userId` ASC) -) - ENGINE = InnoDB - DEFAULT CHARSET = utf8; \ No newline at end of file diff --git a/inc/sql/1316020501.sql b/inc/sql/1316020501.sql deleted file mode 100644 index 1ee1a835..00000000 --- a/inc/sql/1316020501.sql +++ /dev/null @@ -1,19 +0,0 @@ --- To 1.3.16020501; -CREATE TABLE `tags` ( - `tag_id` INT UNSIGNED NOT NULL AUTO_INCREMENT, - `tag_name` VARCHAR(45) NOT NULL, - `tag_hash` BINARY(20) NOT NULL, - PRIMARY KEY (`tag_id`), - INDEX `IDX_name` (`tag_name` ASC), - UNIQUE INDEX `tag_hash_UNIQUE` (`tag_hash` ASC) -) - ENGINE = InnoDB - DEFAULT CHARSET = utf8; -CREATE TABLE `accTags` ( - `acctag_accountId` INT UNSIGNED NOT NULL, - `acctag_tagId` INT UNSIGNED NOT NULL, - INDEX `IDX_id` (`acctag_accountId` ASC), - INDEX `fk_accTags_tags_id_idx` (`acctag_tagId` ASC) -) - ENGINE = InnoDB - DEFAULT CHARSET = utf8; \ No newline at end of file diff --git a/inc/sql/1316100601.sql b/inc/sql/1316100601.sql index 94db0003..b2d551a0 100644 --- a/inc/sql/1316100601.sql +++ b/inc/sql/1316100601.sql @@ -11,9 +11,6 @@ ALTER TABLE `accHistory` ADD INDEX `fk_accHistory_categories_id_idx` (`acchistory_categoryId` ASC), ADD INDEX `fk_accHistory_customers_id_idx` (`acchistory_customerId` ASC); -ALTER TABLE `accTags` - CHANGE COLUMN `acctag_accountId` `acctag_accountId` SMALLINT(10) UNSIGNED NOT NULL; - ALTER TABLE `accUsers` DROP COLUMN `accuser_id`, CHANGE COLUMN `accuser_accountId` `accuser_accountId` SMALLINT(5) UNSIGNED NOT NULL, @@ -34,6 +31,7 @@ ALTER TABLE `accounts` ALTER TABLE `authTokens` CHANGE COLUMN `authtoken_userId` `authtoken_userId` SMALLINT(5) UNSIGNED NOT NULL, ADD INDEX `fk_authTokens_users_id_idx` (`authtoken_userId` ASC, `authtoken_createdBy` ASC); + ALTER TABLE `log` CHANGE COLUMN `log_userId` `log_userId` SMALLINT(5) UNSIGNED NOT NULL, CHANGE COLUMN `log_description` `log_description` TEXT NULL DEFAULT NULL, @@ -61,8 +59,8 @@ ALTER TABLE `usrToGroups` DROP PRIMARY KEY; ALTER TABLE `accGroups` -CHANGE COLUMN `accgroup_accountId` `accgroup_accountId` SMALLINT(5) UNSIGNED NOT NULL , -CHANGE COLUMN `accgroup_groupId` `accgroup_groupId` SMALLINT(5) UNSIGNED NOT NULL; + CHANGE COLUMN `accgroup_accountId` `accgroup_accountId` SMALLINT(5) UNSIGNED NOT NULL, + CHANGE COLUMN `accgroup_groupId` `accgroup_groupId` SMALLINT(5) UNSIGNED NOT NULL; ALTER TABLE `accFavorites` ADD CONSTRAINT `fk_accFavorites_accounts_id` @@ -278,9 +276,7 @@ ALTER TABLE `accHistory` AFTER `accHistory_passDateChange`, ADD INDEX `fk_accHistory_userGroup_id_idx` (`acchistory_userGroupId` ASC); -CREATE OR REPLACE ALGORITHM = UNDEFINED - DEFINER = CURRENT_USER - SQL SECURITY DEFINER VIEW `account_data_v` AS +CREATE OR REPLACE ALGORITHM = UNDEFINED DEFINER = CURRENT_USER SQL SECURITY DEFINER VIEW `account_data_v` AS SELECT `accounts`.`account_id` AS `account_id`, `accounts`.`account_name` AS `account_name`, @@ -318,9 +314,7 @@ CREATE OR REPLACE ALGORITHM = UNDEFINED ON ((`accounts`.`account_customerId` = `customers`.`customer_id`))) LEFT JOIN `publicLinks` ON ((`accounts`.`account_id` = `publicLinks`.`publicLink_itemId`))); -CREATE OR REPLACE ALGORITHM = UNDEFINED - DEFINER = CURRENT_USER - SQL SECURITY DEFINER VIEW `account_search_v` AS +CREATE OR REPLACE ALGORITHM = UNDEFINED DEFINER = CURRENT_USER SQL SECURITY DEFINER VIEW `account_search_v` AS SELECT DISTINCT `accounts`.`account_id` AS `account_id`, `accounts`.`account_customerId` AS `account_customerId`, @@ -357,28 +351,4 @@ ALTER TABLE `accounts` ALTER TABLE `categories` ADD COLUMN `category_hash` VARBINARY(40) NOT NULL DEFAULT 0 - AFTER `category_description`; - -CREATE TABLE `plugins` ( - `plugin_id` INT UNSIGNED NOT NULL AUTO_INCREMENT, - `plugin_name` VARCHAR(100) NOT NULL, - `plugin_data` VARBINARY(5000) NULL, - `plugin_enabled` BIT(1) NOT NULL DEFAULT b'0', - PRIMARY KEY (`plugin_id`), - UNIQUE INDEX `plugin_name_UNIQUE` (`plugin_name` ASC) -); - -CREATE TABLE `notices` ( - `notice_id` INT UNSIGNED NOT NULL AUTO_INCREMENT, - `notice_type` VARCHAR(100) NULL, - `notice_component` VARCHAR(100) NOT NULL, - `notice_description` VARCHAR(500) NOT NULL, - `notice_date` INT UNSIGNED NOT NULL, - `notice_checked` BIT(1) NULL DEFAULT b'0', - `notice_userId` SMALLINT(5) UNSIGNED NULL, - `notice_sticky` BIT(1) NULL DEFAULT b'0', - `notice_onlyAdmin` BIT(1) NULL DEFAULT b'0', - PRIMARY KEY (`notice_id`), - INDEX `IDX_userId` (`notice_userId` ASC, `notice_checked` ASC, `notice_date` ASC), - INDEX `IDX_component` (`notice_component` ASC, `notice_date` ASC, `notice_checked` ASC, `notice_userId` ASC) -); \ No newline at end of file + AFTER `category_description`; \ No newline at end of file diff --git a/inc/sql/20017011302.sql b/inc/sql/20017011302.sql index 8a21433e..3c5c2480 100644 --- a/inc/sql/20017011302.sql +++ b/inc/sql/20017011302.sql @@ -1 +1,2 @@ -ALTER TABLE `accounts` CHANGE COLUMN `account_id` `account_id` SMALLINT(5) UNSIGNED NOT NULL AUTO_INCREMENT; \ No newline at end of file +ALTER TABLE `accounts` + CHANGE COLUMN `account_id` `account_id` SMALLINT(5) UNSIGNED NOT NULL AUTO_INCREMENT; \ No newline at end of file diff --git a/inc/sql/20017011701.sql b/inc/sql/20017011701.sql index 9711b3ce..73453e8e 100644 --- a/inc/sql/20017011701.sql +++ b/inc/sql/20017011701.sql @@ -1,8 +1,9 @@ -ALTER TABLE `accounts` ADD COLUMN `account_isPrivateGroup` BIT(1) NULL DEFAULT b'0' AFTER `account_isPrivate`; - -ALTER TABLE `accHistory` ADD COLUMN `accHistory_isPrivate` BIT(1) NULL DEFAULT b'0' AFTER `accHistory_parentId`, -ADD COLUMN `accHistory_isPrivateGroup` BIT(1) NULL DEFAULT b'0' AFTER `accHistory_isPrivate`; +ALTER TABLE `accounts` + ADD COLUMN `account_isPrivateGroup` BIT(1) NULL DEFAULT b'0' AFTER `account_isPrivate`; +ALTER TABLE `accHistory` + ADD COLUMN `accHistory_isPrivate` BIT(1) NULL DEFAULT b'0' AFTER `accHistory_parentId`, + ADD COLUMN `accHistory_isPrivateGroup` BIT(1) NULL DEFAULT b'0' AFTER `accHistory_isPrivate`; CREATE OR REPLACE ALGORITHM = UNDEFINED DEFINER = CURRENT_USER SQL SECURITY DEFINER VIEW `account_data_v` AS SELECT diff --git a/inc/sql/20017012901.sql b/inc/sql/20017012901.sql index 165a0261..98a2691a 100644 --- a/inc/sql/20017012901.sql +++ b/inc/sql/20017012901.sql @@ -37,4 +37,4 @@ CREATE OR REPLACE ALGORITHM = UNDEFINED DEFINER = CURRENT_USER SQL SECURITY DEFI (((`accounts` LEFT JOIN `categories` ON ((`accounts`.`account_categoryId` = `categories`.`category_id`))) LEFT JOIN `usrGroups` `ug` ON ((`accounts`.`account_userGroupId` = `ug`.`usergroup_id`))) - LEFT JOIN `customers` ON ((`customers`.`customer_id` = `accounts`.`account_customerId`))) + LEFT JOIN `customers` ON ((`customers`.`customer_id` = `accounts`.`account_customerId`))); diff --git a/inc/sql/20117021901.sql b/inc/sql/20117021901.sql index 4bcf2368..5986b296 100644 --- a/inc/sql/20117021901.sql +++ b/inc/sql/20117021901.sql @@ -1,5 +1,10 @@ -ALTER TABLE `accounts` CHANGE COLUMN `account_IV` `account_key` VARBINARY(500) NOT NULL ; -ALTER TABLE `accHistory` CHANGE COLUMN `acchistory_IV` `acchistory_key` VARBINARY(500) NOT NULL ; -ALTER TABLE `customFieldsData` CHANGE COLUMN `customfielddata_iv` `customfielddata_key` VARBINARY(500) NOT NULL; -ALTER TABLE `usrData` CHANGE COLUMN `user_mPass` `user_mKey` VARBINARY(500) NULL DEFAULT NULL, CHANGE COLUMN `user_mIV` `user_mKey` VARBINARY(500) NULL DEFAULT NULL; +ALTER TABLE `accounts` + CHANGE COLUMN `account_IV` `account_key` VARBINARY(1000) NOT NULL ; +ALTER TABLE `accHistory` + CHANGE COLUMN `acchistory_IV` `acchistory_key` VARBINARY(1000) NOT NULL ; +ALTER TABLE `customFieldsData` + CHANGE COLUMN `customfielddata_iv` `customfielddata_key` VARBINARY(1000) NOT NULL; +ALTER TABLE `usrData` + CHANGE COLUMN `user_mPass` `user_mPass` VARBINARY(1000) NULL DEFAULT NULL, + CHANGE COLUMN `user_mIV` `user_mKey` VARBINARY(1000) NULL DEFAULT NULL; diff --git a/inc/sql/dbstructure.sql b/inc/sql/dbstructure.sql index 6cda379a..7b1f4b5c 100644 --- a/inc/sql/dbstructure.sql +++ b/inc/sql/dbstructure.sql @@ -222,6 +222,19 @@ CREATE TABLE `accHistory` ( ) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `tags`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `tags` ( + `tag_id` int unsigned NOT NULL AUTO_INCREMENT, + `tag_name` varchar(45) NOT NULL, + `tag_hash` binary(40) NOT NULL, + PRIMARY KEY (`tag_id`), + UNIQUE KEY `tag_hash_UNIQUE` (`tag_hash`), + KEY `IDX_name` (`tag_name`) +) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + DROP TABLE IF EXISTS `accTags`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; @@ -341,19 +354,6 @@ CREATE TABLE `publicLinks` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -DROP TABLE IF EXISTS `tags`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `tags` ( - `tag_id` int unsigned NOT NULL AUTO_INCREMENT, - `tag_name` varchar(45) NOT NULL, - `tag_hash` binary(40) NOT NULL, - PRIMARY KEY (`tag_id`), - UNIQUE KEY `tag_hash_UNIQUE` (`tag_hash`), - KEY `IDX_name` (`tag_name`) -) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; - DROP TABLE IF EXISTS `usrPassRecover`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; diff --git a/js/app-triggers.js b/js/app-triggers.js index e8967865..99b373f2 100644 --- a/js/app-triggers.js +++ b/js/app-triggers.js @@ -349,10 +349,12 @@ sysPass.Triggers = function (Common) { if ($this[0].value > 0) { $pass.each(function () { $(this).prop("disabled", "true"); + $(this).prop("required", "false"); }); } else { $pass.each(function () { $(this).prop("disabled", ""); + $(this).prop("required", "true"); }); } }); diff --git a/js/app-triggers.min.js b/js/app-triggers.min.js index 60c82d9e..8c8afc31 100644 --- a/js/app-triggers.min.js +++ b/js/app-triggers.min.js @@ -7,7 +7,7 @@ var a=$("#frmSearch");0!==a.length&&(a.find("select, #rpp").on("change",function passreset:function(){d.info("views:passreset");var a=$("#frmPassReset");b.appTheme().passwordDetect(a)},footer:function(){d.info("views:footer");$("#btnLogout").click(function(a){b.appActions().main.logout()});$("#btnPrefs").click(function(a){b.appActions().doAction({actionId:$(this).data("action-id")})})},common:function(a){d.info("views:common");e(a);"function"===typeof b.appTheme().viewsTriggers.common&&b.appTheme().viewsTriggers.common(a);b.appTriggers().updateFormHash(a)},datatabs:function(a){d.info("views:datatabs"); $(".datagrid-action-search>form").each(function(){var a=$(this);a.find("button.btn-clear").on("click",function(b){b.preventDefault();a.trigger("reset")})})},config:function(){d.info("views:config");var a=$("#drop-import-files");if(0