From b993de545f650f20588d727675964daaf3a45e3f Mon Sep 17 00:00:00 2001 From: nuxsmin Date: Fri, 30 Dec 2016 01:43:29 +0100 Subject: [PATCH] * [DEV] Fixed DB structure * [DEV] Language tweak for logging * [DEV] Updated version --- inc/SP/Core/DiFactory.class.php | 4 +- inc/SP/Core/Language.class.php | 16 +++++++ inc/SP/Log/Log.class.php | 9 +++- inc/SP/Util/Util.class.php | 9 ++-- inc/sql/1.3.16100601.sql | 4 +- inc/sql/dbstructure.sql | 77 ++++++++++++++++++++++++++++++++- 6 files changed, 106 insertions(+), 13 deletions(-) diff --git a/inc/SP/Core/DiFactory.class.php b/inc/SP/Core/DiFactory.class.php index d2027edc..009c2cf3 100644 --- a/inc/SP/Core/DiFactory.class.php +++ b/inc/SP/Core/DiFactory.class.php @@ -89,8 +89,8 @@ class DiFactory * Devuelve la instancia de la clase del elemento solicitado * * @param string $caller La clase del objeto - * @param object $itemData Los datos del elemento - * @return object + * @param mixed $itemData Los datos del elemento + * @return ItemBase * @throws Exceptions\InvalidClassException */ public static final function getItem($caller, $itemData = null) diff --git a/inc/SP/Core/Language.class.php b/inc/SP/Core/Language.class.php index 098dda83..0d67bebe 100644 --- a/inc/SP/Core/Language.class.php +++ b/inc/SP/Core/Language.class.php @@ -166,4 +166,20 @@ class Language 'Français' => 'fr_FR' ]; } + + /** + * Establecer el lenguaje global para las trdducciones + */ + public static function setAppLocales() + { + self::setLocales(self::$globalLang); + } + + /** + * Restablecer el lenguaje global para las trdducciones + */ + public static function unsetAppLocales() + { + self::setLocales(Session::getLocale()); + } } \ No newline at end of file diff --git a/inc/SP/Log/Log.class.php b/inc/SP/Log/Log.class.php index b1a46870..61798032 100644 --- a/inc/SP/Log/Log.class.php +++ b/inc/SP/Log/Log.class.php @@ -26,6 +26,7 @@ namespace SP\Log; use SP\Core\DiFactory; +use SP\Core\Language; use SP\Storage\DB; use SP\Core\Session; use SP\Storage\QueryData; @@ -134,6 +135,8 @@ class Log extends ActionLog $this->sendToSyslog(); } + Language::setAppLocales(); + $description = trim($this->getDescription() . PHP_EOL . $this->getDetails()); $query = 'INSERT INTO log SET ' . @@ -158,7 +161,11 @@ class Log extends ActionLog $this->resetDescription(); } - return DB::getQuery($Data); + $query = DB::getQuery($Data); + + Language::unsetAppLocales(); + + return $query; } /** diff --git a/inc/SP/Util/Util.class.php b/inc/SP/Util/Util.class.php index eb7f7ba5..1780596b 100644 --- a/inc/SP/Util/Util.class.php +++ b/inc/SP/Util/Util.class.php @@ -134,7 +134,7 @@ class Util */ public static function getVersionString() { - return '1.3-dev'; + return '2.0-dev'; } /** @@ -194,9 +194,6 @@ class Util } else { return false; } - } else { - // FIXME - error_log($updateInfo->message); } return false; @@ -315,8 +312,8 @@ class Util */ public static function getVersion($retBuild = false) { - $build = '16020501'; - $version = [1, 3]; + $build = '16122901'; + $version = [2, 0]; if ($retBuild) { $version[] = $build; diff --git a/inc/sql/1.3.16100601.sql b/inc/sql/1.3.16100601.sql index 05fecb26..548f1424 100644 --- a/inc/sql/1.3.16100601.sql +++ b/inc/sql/1.3.16100601.sql @@ -303,8 +303,8 @@ VIEW `account_search_v` AS 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`))); -ALTER TABLE accounts` -ADD COLUMN `account_parentId` SMALLINT (5) UNSIGNED NULL AFTER `account_passDateChange`; +ALTER TABLE `accounts` + ADD COLUMN `account_parentId` SMALLINT (5) UNSIGNED NULL AFTER `account_passDateChange`; ALTER TABLE `accounts` ADD CONSTRAINT `fk_accounts_customer_id` FOREIGN KEY (`account_customerId`) diff --git a/inc/sql/dbstructure.sql b/inc/sql/dbstructure.sql index 5062f4ec..9f1a422a 100644 --- a/inc/sql/dbstructure.sql +++ b/inc/sql/dbstructure.sql @@ -115,6 +115,7 @@ CREATE TABLE `accounts` ( `account_isPrivate` bit(1) DEFAULT b'0', `account_passDate` int(11) unsigned DEFAULT NULL, `account_passDateChange` int(11) unsigned DEFAULT NULL, + `account_parentId` SMALLINT (5) UNSIGNED NULL, PRIMARY KEY (`account_id`), KEY `IDX_categoryId` (`account_categoryId`), KEY `IDX_userId` (`account_userGroupId`,`account_userId`), @@ -196,6 +197,7 @@ CREATE TABLE `accHistory` ( `accHistory_otherGroupEdit` bit(1) DEFAULT b'0', `accHistory_passDate` int(10) unsigned DEFAULT NULL, `accHistory_passDateChange` int(10) unsigned DEFAULT NULL, + `accHistory_parentId` SMALLINT(5) UNSIGNED NULL, PRIMARY KEY (`acchistory_id`), KEY `IDX_accountId` (`acchistory_accountId`), KEY `fk_accHistory_users_edit_id_idx` (`acchistory_userEditId`), @@ -366,10 +368,81 @@ CREATE TABLE `usrToGroups` ( /*!40101 SET character_set_client = @saved_cs_client */; DROP TABLE IF EXISTS `account_data_v`; -CREATE 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`,`accounts`.`account_categoryId` AS `account_categoryId`,`accounts`.`account_userId` AS `account_userId`,`accounts`.`account_customerId` AS `account_customerId`,`accounts`.`account_userGroupId` AS `account_userGroupId`,`accounts`.`account_userEditId` AS `account_userEditId`,`accounts`.`account_login` AS `account_login`,`accounts`.`account_url` AS `account_url`,`accounts`.`account_notes` AS `account_notes`,`accounts`.`account_countView` AS `account_countView`,`accounts`.`account_countDecrypt` AS `account_countDecrypt`,`accounts`.`account_dateAdd` AS `account_dateAdd`,`accounts`.`account_dateEdit` AS `account_dateEdit`,conv(`accounts`.`account_otherUserEdit`,10,2) AS `account_otherUserEdit`,conv(`accounts`.`account_otherGroupEdit`,10,2) AS `account_otherGroupEdit`,conv(`accounts`.`account_isPrivate`,10,2) AS `account_isPrivate`,`accounts`.`account_passDate` AS `account_passDate`,`accounts`.`account_passDateChange` AS `account_passDateChange`,`categories`.`category_name` AS `category_name`,`customers`.`customer_name` AS `customer_name`,`ug`.`usergroup_name` AS `usergroup_name`,`u1`.`user_name` AS `user_name`,`u1`.`user_login` AS `user_login`,`u2`.`user_name` AS `user_editName`,`u2`.`user_login` AS `user_editLogin`,`publicLinks`.`publicLink_hash` AS `publicLink_hash` from ((((((`accounts` left join `categories` on((`accounts`.`account_categoryId` = `categories`.`category_id`))) left join `usrGroups` `ug` on((`accounts`.`account_userGroupId` = `ug`.`usergroup_id`))) left join `usrData` `u1` on((`accounts`.`account_userId` = `u1`.`user_id`))) left join `usrData` `u2` on((`accounts`.`account_userEditId` = `u2`.`user_id`))) left join `customers` 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_data_v` AS + SELECT + `accounts`.`account_id` AS `account_id`, + `accounts`.`account_name` AS `account_name`, + `accounts`.`account_categoryId` AS `account_categoryId`, + `accounts`.`account_userId` AS `account_userId`, + `accounts`.`account_customerId` AS `account_customerId`, + `accounts`.`account_userGroupId` AS `account_userGroupId`, + `accounts`.`account_userEditId` AS `account_userEditId`, + `accounts`.`account_login` AS `account_login`, + `accounts`.`account_url` AS `account_url`, + `accounts`.`account_notes` AS `account_notes`, + `accounts`.`account_countView` AS `account_countView`, + `accounts`.`account_countDecrypt` AS `account_countDecrypt`, + `accounts`.`account_dateAdd` AS `account_dateAdd`, + `accounts`.`account_dateEdit` AS `account_dateEdit`, + conv(`accounts`.`account_otherUserEdit`, 10, 2) AS `account_otherUserEdit`, + conv(`accounts`.`account_otherGroupEdit`, 10, 2) AS `account_otherGroupEdit`, + conv(`accounts`.`account_isPrivate`, 10, 2) AS `account_isPrivate`, + `accounts`.`account_passDate` AS `account_passDate`, + `accounts`.`account_passDateChange` AS `account_passDateChange`, + `accounts`.`account_parentId` AS `account_parentId`, + `categories`.`category_name` AS `category_name`, + `customers`.`customer_name` AS `customer_name`, + `ug`.`usergroup_name` AS `usergroup_name`, + `u1`.`user_name` AS `user_name`, + `u1`.`user_login` AS `user_login`, + `u2`.`user_name` AS `user_editName`, + `u2`.`user_login` AS `user_editLogin`, + `publicLinks`.`publicLink_hash` AS `publicLink_hash` + FROM ((((((`accounts` + LEFT JOIN `categories` ON ((`accounts`.`account_categoryId` = `categories`.`category_id`))) LEFT JOIN + `usrGroups` `ug` ON ((`accounts`.`account_userGroupId` = `ug`.`usergroup_id`))) LEFT JOIN `usrData` `u1` + ON ((`accounts`.`account_userId` = `u1`.`user_id`))) LEFT JOIN `usrData` `u2` + ON ((`accounts`.`account_userEditId` = `u2`.`user_id`))) LEFT JOIN `customers` + ON ((`accounts`.`account_customerId` = `customers`.`customer_id`))) LEFT JOIN `publicLinks` + ON ((`accounts`.`account_id` = `publicLinks`.`publicLink_itemId`))); DROP TABLE IF EXISTS `account_search_v`; -CREATE 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`,`accounts`.`account_categoryId` AS `account_categoryId`,`accounts`.`account_name` AS `account_name`,`accounts`.`account_login` AS `account_login`,`accounts`.`account_url` AS `account_url`,`accounts`.`account_notes` AS `account_notes`,`accounts`.`account_userId` AS `account_userId`,`accounts`.`account_userGroupId` AS `account_userGroupId`,conv(`accounts`.`account_otherUserEdit`,10,2) AS `account_otherUserEdit`,conv(`accounts`.`account_otherGroupEdit`,10,2) AS `account_otherGroupEdit`,conv(`accounts`.`account_isPrivate`,10,2) AS `account_isPrivate`,`accounts`.`account_passDate` AS `account_passDate`,`accounts`.`account_passDateChange` AS `account_passDateChange`,`ug`.`usergroup_name` AS `usergroup_name`,`categories`.`category_name` AS `category_name`,`customers`.`customer_name` AS `customer_name`,(select count(0) from `accFiles` where (`accFiles`.`accfile_accountId` = `accounts`.`account_id`)) AS `num_files` from (((`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`))); +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`, + `accounts`.`account_categoryId` AS `account_categoryId`, + `accounts`.`account_name` AS `account_name`, + `accounts`.`account_login` AS `account_login`, + `accounts`.`account_url` AS `account_url`, + `accounts`.`account_notes` AS `account_notes`, + `accounts`.`account_userId` AS `account_userId`, + `accounts`.`account_userGroupId` AS `account_userGroupId`, + `accounts`.`account_otherUserEdit` AS `account_otherUserEdit`, + `accounts`.`account_otherGroupEdit` AS `account_otherGroupEdit`, + `accounts`.`account_isPrivate` AS `account_isPrivate`, + `accounts`.`account_passDate` AS `account_passDate`, + `accounts`.`account_passDateChange` AS `account_passDateChange`, + `accounts`.`account_parentId` AS `account_parentId`, + `ug`.`usergroup_name` AS `usergroup_name`, + `categories`.`category_name` AS `category_name`, + `customers`.`customer_name` AS `customer_name`, + (SELECT COUNT(0) + FROM + `accFiles` + WHERE + (`accFiles`.`accfile_accountId` = `accounts`.`account_id`)) AS `num_files` + FROM + (((`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`))); /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;