From 85de6fd50730de7813d60cb298c19b95fdfc339f Mon Sep 17 00:00:00 2001 From: nuxsmin Date: Mon, 19 Mar 2018 20:41:38 +0100 Subject: [PATCH] * [FIX] Fixed wrong Acl behavior * [FIX] Minor bugfixes * [MOD] Updated db schema --- .../web/Controllers/AuthTokenController.php | 2 +- .../web/Controllers/CategoryController.php | 2 +- .../web/Controllers/ClientController.php | 2 +- .../Controllers/ConfigGeneralController.php | 2 +- .../web/Controllers/SimpleControllerBase.php | 2 +- .../web/Controllers/UserController.php | 2 +- .../web/Controllers/UserGroupController.php | 2 +- .../web/Controllers/UserProfileController.php | 2 +- lib/SP/Core/Acl/Acl.php | 40 ++++ lib/SP/Http/Request.php | 17 +- schemas/dbstructure.sql | 195 ++++++------------ 11 files changed, 122 insertions(+), 146 deletions(-) diff --git a/app/modules/web/Controllers/AuthTokenController.php b/app/modules/web/Controllers/AuthTokenController.php index f226b762..3ddd4e56 100644 --- a/app/modules/web/Controllers/AuthTokenController.php +++ b/app/modules/web/Controllers/AuthTokenController.php @@ -145,7 +145,7 @@ class AuthTokenController extends ControllerBase implements CrudControllerInterf $this->view->assign('readonly'); } - $this->view->assign('customFields', $this->getCustomFieldsForItem(ActionsInterface::AUTHTOKEN, $authTokenId)); + $this->view->assign('customFields', $this->getCustomFieldsForItem(ActionsInterface::AUTHTOKEN, $authTokenId, $this->session)); } /** diff --git a/app/modules/web/Controllers/CategoryController.php b/app/modules/web/Controllers/CategoryController.php index 1d2c8efb..ee6fc215 100644 --- a/app/modules/web/Controllers/CategoryController.php +++ b/app/modules/web/Controllers/CategoryController.php @@ -139,7 +139,7 @@ class CategoryController extends ControllerBase implements CrudControllerInterfa $this->view->assign('readonly'); } - $this->view->assign('customFields', $this->getCustomFieldsForItem(ActionsInterface::CATEGORY, $categoryId)); + $this->view->assign('customFields', $this->getCustomFieldsForItem(ActionsInterface::CATEGORY, $categoryId, $this->session)); } /** diff --git a/app/modules/web/Controllers/ClientController.php b/app/modules/web/Controllers/ClientController.php index 860f213f..98566d59 100644 --- a/app/modules/web/Controllers/ClientController.php +++ b/app/modules/web/Controllers/ClientController.php @@ -140,7 +140,7 @@ class ClientController extends ControllerBase implements CrudControllerInterface $this->view->assign('readonly'); } - $this->view->assign('customFields', $this->getCustomFieldsForItem(ActionsInterface::CLIENT, $clientId)); + $this->view->assign('customFields', $this->getCustomFieldsForItem(ActionsInterface::CLIENT, $clientId, $this->session)); } /** diff --git a/app/modules/web/Controllers/ConfigGeneralController.php b/app/modules/web/Controllers/ConfigGeneralController.php index da045292..cca2533b 100644 --- a/app/modules/web/Controllers/ConfigGeneralController.php +++ b/app/modules/web/Controllers/ConfigGeneralController.php @@ -81,7 +81,7 @@ class ConfigGeneralController extends SimpleControllerBase $configData->setLogEnabled($logEnabled); $configData->setLogEvents(Request::analyzeArray('log_events', function ($items) { return ConfigUtil::eventsAdapter($items); - })); + }, [])); $configData->setSyslogEnabled($syslogEnabled); diff --git a/app/modules/web/Controllers/SimpleControllerBase.php b/app/modules/web/Controllers/SimpleControllerBase.php index 6de24828..6e61af62 100644 --- a/app/modules/web/Controllers/SimpleControllerBase.php +++ b/app/modules/web/Controllers/SimpleControllerBase.php @@ -132,7 +132,7 @@ abstract class SimpleControllerBase */ protected function checkAccess($action) { - if (!$this->session->getUserData()->getIsAdminApp() || !$this->acl->checkUserAccess($action)) { + if (!$this->session->getUserData()->getIsAdminApp() && !$this->acl->checkUserAccess($action)) { throw new UnauthorizedPageException(UnauthorizedPageException::INFO); } } diff --git a/app/modules/web/Controllers/UserController.php b/app/modules/web/Controllers/UserController.php index 9c7b9d7f..7113886c 100644 --- a/app/modules/web/Controllers/UserController.php +++ b/app/modules/web/Controllers/UserController.php @@ -148,7 +148,7 @@ class UserController extends ControllerBase implements CrudControllerInterface $this->view->assign('readonly'); } - $this->view->assign('customFields', $this->getCustomFieldsForItem(ActionsInterface::USER, $userId)); + $this->view->assign('customFields', $this->getCustomFieldsForItem(ActionsInterface::USER, $userId, $this->session)); } /** diff --git a/app/modules/web/Controllers/UserGroupController.php b/app/modules/web/Controllers/UserGroupController.php index 7b2c94d9..2d12a6b1 100644 --- a/app/modules/web/Controllers/UserGroupController.php +++ b/app/modules/web/Controllers/UserGroupController.php @@ -148,7 +148,7 @@ class UserGroupController extends ControllerBase implements CrudControllerInterf $this->view->assign('readonly'); } - $this->view->assign('customFields', $this->getCustomFieldsForItem(ActionsInterface::GROUP, $userGroupId)); + $this->view->assign('customFields', $this->getCustomFieldsForItem(ActionsInterface::GROUP, $userGroupId, $this->session)); } /** diff --git a/app/modules/web/Controllers/UserProfileController.php b/app/modules/web/Controllers/UserProfileController.php index 7fa4a380..42f13c8e 100644 --- a/app/modules/web/Controllers/UserProfileController.php +++ b/app/modules/web/Controllers/UserProfileController.php @@ -143,7 +143,7 @@ class UserProfileController extends ControllerBase implements CrudControllerInte $this->view->assign('readonly'); } - $this->view->assign('customFields', $this->getCustomFieldsForItem(ActionsInterface::PROFILE, $profileId)); + $this->view->assign('customFields', $this->getCustomFieldsForItem(ActionsInterface::PROFILE, $profileId, $this->session)); } /** diff --git a/lib/SP/Core/Acl/Acl.php b/lib/SP/Core/Acl/Acl.php index 5e921524..7218ba42 100644 --- a/lib/SP/Core/Acl/Acl.php +++ b/lib/SP/Core/Acl/Acl.php @@ -151,20 +151,38 @@ class Acl implements ActionsInterface case self::CONFIG_GENERAL: case self::PLUGIN: case self::ACCOUNT_CONFIG: + case self::WIKI_CONFIG: + case self::LDAP_CONFIG: + case self::MAIL_CONFIG: return $userProfile->isConfigGeneral(); case self::IMPORT_CONFIG: return $userProfile->isConfigImport(); case self::CATEGORY: case self::CATEGORY_SEARCH: + case self::CATEGORY_VIEW: + case self::CATEGORY_CREATE: + case self::CATEGORY_EDIT: + case self::CATEGORY_DELETE: return $userProfile->isMgmCategories(); case self::CLIENT: case self::CLIENT_SEARCH: + case self::CLIENT_VIEW: + case self::CLIENT_CREATE: + case self::CLIENT_EDIT: + case self::CLIENT_DELETE: return $userProfile->isMgmCustomers(); case self::CUSTOMFIELD: case self::CUSTOMFIELD_SEARCH: + case self::CUSTOMFIELD_VIEW: + case self::CUSTOMFIELD_CREATE: + case self::CUSTOMFIELD_EDIT: + case self::CUSTOMFIELD_DELETE: return $userProfile->isMgmCustomFields(); case self::PUBLICLINK: case self::PUBLICLINK_SEARCH: + case self::PUBLICLINK_VIEW: + case self::PUBLICLINK_EDIT: + case self::PUBLICLINK_DELETE: return $userProfile->isMgmPublicLinks(); case self::PUBLICLINK_CREATE: case self::PUBLICLINK_REFRESH: @@ -176,9 +194,16 @@ class Acl implements ActionsInterface return $userProfile->isMgmAccounts(); case self::FILE: case self::FILE_SEARCH: + case self::FILE_DELETE: + case self::FILE_VIEW: + case self::FILE_DOWNLOAD: return $userProfile->isMgmFiles(); case self::TAG: case self::TAG_SEARCH: + case self::TAG_VIEW: + case self::TAG_CREATE: + case self::TAG_EDIT: + case self::TAG_DELETE: return $userProfile->isMgmTags(); case self::ENCRYPTION_CONFIG: return $userProfile->isConfigEncryption(); @@ -188,23 +213,38 @@ class Acl implements ActionsInterface return ($userProfile->isMgmUsers() || $userProfile->isMgmGroups() || $userProfile->isMgmProfiles()); case self::USER: case self::USER_SEARCH: + case self::USER_VIEW: case self::USER_CREATE: case self::USER_EDIT: + case self::USER_DELETE: return $userProfile->isMgmUsers(); case self::USER_EDIT_PASS: // Comprobar si el usuario es distinto al de la sesión return ($userId === $userData->getId() || $userProfile->isMgmUsers()); case self::GROUP: case self::GROUP_SEARCH: + case self::GROUP_VIEW: + case self::GROUP_CREATE: + case self::GROUP_EDIT: + case self::GROUP_DELETE: return $userProfile->isMgmGroups(); case self::PROFILE: case self::PROFILE_SEARCH: + case self::PROFILE_VIEW: + case self::PROFILE_CREATE: + case self::PROFILE_EDIT: + case self::PROFILE_DELETE: return $userProfile->isMgmProfiles(); case self::AUTHTOKEN: case self::AUTHTOKEN_SEARCH: + case self::AUTHTOKEN_VIEW: + case self::AUTHTOKEN_CREATE: + case self::AUTHTOKEN_EDIT: + case self::AUTHTOKEN_DELETE: return $userProfile->isMgmApiTokens(); case self::EVENTLOG: case self::EVENTLOG_SEARCH: + case self::EVENTLOG_CLEAR: return $userProfile->isEvl(); case self::ACCOUNT_REQUEST: case self::NOTIFICATION: diff --git a/lib/SP/Http/Request.php b/lib/SP/Http/Request.php index 75a318fb..f425fc4a 100644 --- a/lib/SP/Http/Request.php +++ b/lib/SP/Http/Request.php @@ -150,11 +150,11 @@ class Request * Obtener los valores de variables $_GET y $_POST * y devolverlos limpios con el tipo correcto o esperado. * - * @param string $param con el parámetro a consultar - * @param mixed $default valor por defecto a devolver - * @param bool $check comprobar si el parámetro está presente - * @param mixed $force valor devuelto si el parámeto está definido - * @param bool $sanitize escapar/eliminar carácteres especiales + * @param string $param con el parámetro a consultar + * @param mixed $default valor por defecto a devolver + * @param bool $check comprobar si el parámetro está presente + * @param mixed $force valor devuelto si el parámeto está definido + * @param bool $sanitize escapar/eliminar carácteres especiales * @return mixed si está presente el parámeto en la petición devuelve bool. Si lo está, devuelve el valor. * @deprecated */ @@ -209,11 +209,12 @@ class Request } /** - * @param string $param + * @param string $param * @param callable|null $mapper + * @param mixed $default * @return mixed */ - public static function analyzeArray($param, callable $mapper = null) + public static function analyzeArray($param, callable $mapper = null, $default = null) { if (isset($_REQUEST[$param]) && is_array($_REQUEST[$param])) { if (is_callable($mapper)) { @@ -229,7 +230,7 @@ class Request }, $_REQUEST[$param]); } - return null; + return $default; } /** diff --git a/schemas/dbstructure.sql b/schemas/dbstructure.sql index 045a28f1..7f29c80f 100644 --- a/schemas/dbstructure.sql +++ b/schemas/dbstructure.sql @@ -8,8 +8,6 @@ /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; - - DROP TABLE IF EXISTS `Account`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; @@ -38,9 +36,10 @@ CREATE TABLE `Account` ( `passDateChange` int(11) unsigned DEFAULT NULL, `parentId` mediumint(8) unsigned DEFAULT NULL, PRIMARY KEY (`id`), - KEY `IDX_categoryId` (`categoryId`), - KEY `IDX_userId` (`userGroupId`,`userId`), - KEY `IDX_customerId` (`clientId`), + KEY `idx_Account_01` (`categoryId`), + KEY `idx_Account_02` (`userGroupId`,`userId`), + KEY `idx_Account_03` (`clientId`), + KEY `idx_Account_04` (`parentId`), KEY `fk_Account_userId` (`userId`), KEY `fk_Account_userEditId` (`userEditId`), CONSTRAINT `fk_Account_categoryId` FOREIGN KEY (`categoryId`) REFERENCES `Category` (`id`), @@ -48,16 +47,14 @@ CREATE TABLE `Account` ( CONSTRAINT `fk_Account_userEditId` FOREIGN KEY (`userEditId`) REFERENCES `User` (`id`), CONSTRAINT `fk_Account_userGroupId` FOREIGN KEY (`userGroupId`) REFERENCES `UserGroup` (`id`), CONSTRAINT `fk_Account_userId` FOREIGN KEY (`userId`) REFERENCES `User` (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; +) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; - - DROP TABLE IF EXISTS `AccountFile`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `AccountFile` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `accountId` mediumint(8) unsigned NOT NULL, + `accountId` mediumint(5) unsigned NOT NULL, `name` varchar(100) NOT NULL, `type` varchar(100) NOT NULL, `size` int(11) NOT NULL, @@ -65,12 +62,10 @@ CREATE TABLE `AccountFile` ( `extension` varchar(10) NOT NULL, `thumb` mediumblob DEFAULT NULL, PRIMARY KEY (`id`), - KEY `IDX_accountId` (`accountId`), + KEY `idx_AccountFile_01` (`accountId`), CONSTRAINT `fk_AccountFile_accountId` FOREIGN KEY (`accountId`) REFERENCES `Account` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; - - DROP TABLE IF EXISTS `AccountHistory`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; @@ -103,7 +98,8 @@ CREATE TABLE `AccountHistory` ( `isPrivate` tinyint(1) DEFAULT 0, `isPrivateGroup` tinyint(1) DEFAULT 0, PRIMARY KEY (`id`), - KEY `IDX_accountId` (`accountId`), + KEY `idx_AccountHistory_01` (`accountId`), + KEY `idx_AccountHistory_02` (`parentId`), KEY `fk_AccountHistory_userGroupId` (`userGroupId`), KEY `fk_AccountHistory_userId` (`userId`), KEY `fk_AccountHistory_userEditId` (`userEditId`), @@ -116,64 +112,58 @@ CREATE TABLE `AccountHistory` ( CONSTRAINT `fk_AccountHistory_userId` FOREIGN KEY (`userId`) REFERENCES `User` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; - - DROP TABLE IF EXISTS `AccountToFavorite`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `AccountToFavorite` ( `accountId` mediumint(8) unsigned NOT NULL, `userId` smallint(5) unsigned NOT NULL, - KEY `search_idx` (`accountId`,`userId`), + PRIMARY KEY (`accountId`,`userId`), + KEY `idx_AccountToFavorite_01` (`accountId`,`userId`), KEY `fk_AccountToFavorite_userId` (`userId`), CONSTRAINT `fk_AccountToFavorite_accountId` FOREIGN KEY (`accountId`) REFERENCES `Account` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `fk_AccountToFavorite_userId` FOREIGN KEY (`userId`) REFERENCES `User` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; - - DROP TABLE IF EXISTS `AccountToTag`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `AccountToTag` ( `accountId` mediumint(8) unsigned NOT NULL, `tagId` int(10) unsigned NOT NULL, + PRIMARY KEY (`accountId`,`tagId`), KEY `fk_AccountToTag_accountId` (`accountId`), KEY `fk_AccountToTag_tagId` (`tagId`), CONSTRAINT `fk_AccountToTag_accountId` FOREIGN KEY (`accountId`) REFERENCES `Account` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `fk_AccountToTag_tagId` FOREIGN KEY (`tagId`) REFERENCES `Tag` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; - - DROP TABLE IF EXISTS `AccountToUser`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `AccountToUser` ( `accountId` mediumint(8) unsigned NOT NULL, `userId` smallint(5) unsigned NOT NULL, - KEY `idx_account` (`accountId`), + PRIMARY KEY (`accountId`,`userId`), + KEY `idx_AccountToUser_01` (`accountId`), KEY `fk_AccountToUser_userId` (`userId`), CONSTRAINT `fk_AccountToUser_accountId` FOREIGN KEY (`accountId`) REFERENCES `Account` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `fk_AccountToUser_userId` FOREIGN KEY (`userId`) REFERENCES `User` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; - - DROP TABLE IF EXISTS `AccountToUserGroup`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `AccountToUserGroup` ( `accountId` mediumint(8) unsigned NOT NULL, `userGroupId` smallint(5) unsigned NOT NULL, - KEY `fk_AccountToUserGroup_accountId` (`accountId`), + PRIMARY KEY (`accountId`,`userGroupId`), + KEY `idx_AccountToUserGroup_01` (`accountId`), KEY `fk_AccountToUserGroup_userGroupId` (`userGroupId`), CONSTRAINT `fk_AccountToUserGroup_accountId` FOREIGN KEY (`accountId`) REFERENCES `Account` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `fk_AccountToUserGroup_userGroupId` FOREIGN KEY (`userGroupId`) REFERENCES `UserGroup` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; - - DROP TABLE IF EXISTS `AuthToken`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; @@ -187,27 +177,24 @@ CREATE TABLE `AuthToken` ( `vault` varbinary(2000) DEFAULT NULL, `hash` varbinary(1000) DEFAULT NULL, PRIMARY KEY (`id`), - UNIQUE KEY `unique_authtoken_id` (`id`), - KEY `IDX_checkToken` (`userId`,`actionId`,`token`), + UNIQUE KEY `uk_AuthToken_01` (`token`,`actionId`), + KEY `idx_AuthToken_01` (`userId`,`actionId`,`token`), KEY `fk_AuthToken_actionId` (`actionId`), CONSTRAINT `fk_AuthToken_userId` FOREIGN KEY (`userId`) REFERENCES `User` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8; +) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; - - DROP TABLE IF EXISTS `Category`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `Category` ( `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT, `name` varchar(50) NOT NULL, - `hash` varbinary(40) NOT NULL, `description` varchar(255) DEFAULT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `hash` varbinary(40) NOT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `uk_Category_01` (`hash`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; - - DROP TABLE IF EXISTS `Client`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; @@ -218,22 +205,18 @@ CREATE TABLE `Client` ( `description` varchar(255) DEFAULT NULL, `isGlobal` tinyint(1) DEFAULT 0, PRIMARY KEY (`id`), - KEY `IDX_name` (`name`,`hash`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + KEY `uk_Client_01` (`hash`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; - - DROP TABLE IF EXISTS `Config`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `Config` ( `parameter` varchar(50) NOT NULL, - `value` varchar(2000) DEFAULT NULL, + `VALUE` varchar(4000) DEFAULT NULL, PRIMARY KEY (`parameter`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; - - DROP TABLE IF EXISTS `CustomFieldData`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; @@ -245,16 +228,13 @@ CREATE TABLE `CustomFieldData` ( `data` longblob DEFAULT NULL, `key` varbinary(1000) DEFAULT NULL, PRIMARY KEY (`id`), - KEY `IDX_DEFID` (`definitionId`), - KEY `IDX_DELETE` (`itemId`,`moduleId`), - KEY `IDX_UPDATE` (`moduleId`,`itemId`,`definitionId`), - KEY `IDX_ITEM` (`itemId`), - KEY `IDX_MODULE` (`moduleId`), + KEY `idx_CustomFieldData_01` (`definitionId`), + KEY `idx_CustomFieldData_02` (`itemId`,`moduleId`), + KEY `idx_CustomFieldData_03` (`moduleId`), + KEY `uk_CustomFieldData_01` (`moduleId`,`itemId`,`definitionId`), CONSTRAINT `fk_CustomFieldData_definitionId` FOREIGN KEY (`definitionId`) REFERENCES `CustomFieldDefinition` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; - - DROP TABLE IF EXISTS `CustomFieldDefinition`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; @@ -266,14 +246,12 @@ CREATE TABLE `CustomFieldDefinition` ( `required` tinyint(1) unsigned DEFAULT NULL, `help` varchar(255) DEFAULT NULL, `showInList` tinyint(1) unsigned DEFAULT NULL, - `typeId` tinyint(3) unsigned DEFAULT NULL, + `typeId` tinyint(3) unsigned NOT NULL, PRIMARY KEY (`id`), KEY `fk_CustomFieldDefinition_typeId` (`typeId`), CONSTRAINT `fk_CustomFieldDefinition_typeId` FOREIGN KEY (`typeId`) REFERENCES `CustomFieldType` (`id`) ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; - - DROP TABLE IF EXISTS `CustomFieldType`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; @@ -281,43 +259,29 @@ CREATE TABLE `CustomFieldType` ( `id` tinyint(3) unsigned NOT NULL AUTO_INCREMENT, `name` varchar(50) NOT NULL, `text` varchar(50) NOT NULL, - PRIMARY KEY (`id`) + PRIMARY KEY (`id`), + UNIQUE KEY `uk_CustomFieldType_01` (`name`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; - -INSERT INTO CustomFieldType (id, name, text) VALUES (1, 'text', 'Texto'); -INSERT INTO CustomFieldType (id, name, text) VALUES (2, 'password', 'Clave'); -INSERT INTO CustomFieldType (id, name, text) VALUES (3, 'date', 'Fecha'); -INSERT INTO CustomFieldType (id, name, text) VALUES (4, 'number', 'Número'); -INSERT INTO CustomFieldType (id, name, text) VALUES (5, 'email', 'Email'); -INSERT INTO CustomFieldType (id, name, text) VALUES (6, 'telephone', 'Teléfono'); -INSERT INTO CustomFieldType (id, name, text) VALUES (7, 'url', 'URL'); -INSERT INTO CustomFieldType (id, name, text) VALUES (8, 'color', 'Color'); -INSERT INTO CustomFieldType (id, name, text) VALUES (9, 'wiki', 'Wiki'); -INSERT INTO CustomFieldType (id, name, text) VALUES (10, 'textarea', 'Área de texto'); - - DROP TABLE IF EXISTS `EventLog`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `EventLog` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `date` int(10) unsigned NOT NULL, - `login` varchar(25) NOT NULL, + `login` varchar(25) DEFAULT NULL, `userId` smallint(5) unsigned DEFAULT NULL, `ipAddress` varchar(45) NOT NULL, `action` varchar(50) NOT NULL, `description` text DEFAULT NULL, `level` varchar(20) NOT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; +) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; - - -DROP TABLE IF EXISTS `Notice`; +DROP TABLE IF EXISTS `Notification`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; -CREATE TABLE `Notice` ( +CREATE TABLE `Notification` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `type` varchar(100) DEFAULT NULL, `component` varchar(100) NOT NULL, @@ -328,13 +292,10 @@ CREATE TABLE `Notice` ( `sticky` tinyint(1) DEFAULT 0, `onlyAdmin` tinyint(1) DEFAULT 0, PRIMARY KEY (`id`), - KEY `IDX_userId` (`userId`,`checked`,`date`), - KEY `IDX_component` (`component`,`date`,`checked`,`userId`), - CONSTRAINT `fk_Notice_userId` FOREIGN KEY (`userId`) REFERENCES `User` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + KEY `idx_Notification_01` (`userId`,`checked`,`date`), + KEY `idx_Notification_02` (`component`,`date`,`checked`,`userId`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; /*!40101 SET character_set_client = @saved_cs_client */; - - DROP TABLE IF EXISTS `Plugin`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; @@ -345,11 +306,9 @@ CREATE TABLE `Plugin` ( `enabled` tinyint(1) NOT NULL DEFAULT 0, `available` tinyint(1) DEFAULT 0, PRIMARY KEY (`id`), - UNIQUE KEY `plugin_name_UNIQUE` (`name`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + UNIQUE KEY `uk_Plugin_01` (`name`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; /*!40101 SET character_set_client = @saved_cs_client */; - - DROP TABLE IF EXISTS `PublicLink`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; @@ -360,39 +319,33 @@ CREATE TABLE `PublicLink` ( `data` longblob DEFAULT NULL, `userId` smallint(5) unsigned NOT NULL, `typeId` int(10) unsigned NOT NULL, - `notify` tinyint(1) unsigned NOT NULL, + `notify` tinyint(1) DEFAULT 0, `dateAdd` int(10) unsigned NOT NULL, `dateExpire` int(10) unsigned NOT NULL, `dateUpdate` int(10) unsigned NOT NULL, `countViews` smallint(5) unsigned DEFAULT 0, - `totalCountViews` smallint(5) unsigned DEFAULT 0, - `maxCountViews` smallint(5) unsigned NOT NULL, - `useInfo` blob DEFAULT NULL, + `totalCountViews` mediumint(8) unsigned DEFAULT 0, + `maxCountViews` smallint(5) unsigned NOT NULL DEFAULT 0, + `useinfo` blob DEFAULT NULL, PRIMARY KEY (`id`), - UNIQUE KEY `IDX_hash` (`hash`), - UNIQUE KEY `unique_publicLink_hash` (`hash`), - UNIQUE KEY `unique_publicLink_accountId` (`itemId`), - KEY `IDX_itemId` (`itemId`), + UNIQUE KEY `uk_PublicLink_01` (`hash`), + UNIQUE KEY `uk_PublicLink_02` (`itemId`), KEY `fk_PublicLink_userId` (`userId`), CONSTRAINT `fk_PublicLink_userId` FOREIGN KEY (`userId`) REFERENCES `User` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; - - DROP TABLE IF EXISTS `Tag`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `Tag` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `name` varchar(45) NOT NULL, - `hash` binary(40) NOT NULL, + `hash` varbinary(40) NOT NULL, PRIMARY KEY (`id`), - UNIQUE KEY `tag_hash_UNIQUE` (`hash`), - KEY `IDX_name` (`name`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + UNIQUE KEY `uk_Tag_01` (`hash`), + KEY `idx_Tag_01` (`name`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; - - DROP TABLE IF EXISTS `Track`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; @@ -404,12 +357,10 @@ CREATE TABLE `Track` ( `ipv4` binary(4) NOT NULL, `ipv6` binary(16) DEFAULT NULL, PRIMARY KEY (`id`), - KEY `IDX_userId` (`userId`), - KEY `IDX_time-ip-source` (`time`,`ipv4`,`ipv6`,`source`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + KEY `idx_Track_01` (`userId`), + KEY `idx_Track_02` (`time`,`ipv4`,`ipv6`,`source`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; - - DROP TABLE IF EXISTS `User`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; @@ -439,16 +390,14 @@ CREATE TABLE `User` ( `isChangedPass` tinyint(1) DEFAULT 0, `preferences` blob DEFAULT NULL, PRIMARY KEY (`id`), - UNIQUE KEY `IDX_login` (`login`,`ssoLogin`), - KEY `IDX_pass` (`pass`(767)), + UNIQUE KEY `uk_User_01` (`login`,`ssoLogin`), + KEY `idx_User_01` (`pass`), KEY `fk_User_userGroupId` (`userGroupId`), KEY `fk_User_userProfileId` (`userProfileId`), CONSTRAINT `fk_User_userGroupId` FOREIGN KEY (`userGroupId`) REFERENCES `UserGroup` (`id`), CONSTRAINT `fk_User_userProfileId` FOREIGN KEY (`userProfileId`) REFERENCES `UserProfile` (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; +) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; - - DROP TABLE IF EXISTS `UserGroup`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; @@ -457,10 +406,8 @@ CREATE TABLE `UserGroup` ( `name` varchar(50) NOT NULL, `description` varchar(255) DEFAULT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; +) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; - - DROP TABLE IF EXISTS `UserPassRecover`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; @@ -471,12 +418,10 @@ CREATE TABLE `UserPassRecover` ( `date` int(10) unsigned NOT NULL, `used` tinyint(1) DEFAULT 0, PRIMARY KEY (`id`), - KEY `IDX_userId` (`userId`,`date`), + KEY `idx_UserPassRecover_01` (`userId`,`date`), CONSTRAINT `fk_UserPassRecover_userId` FOREIGN KEY (`userId`) REFERENCES `User` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; - - DROP TABLE IF EXISTS `UserProfile`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; @@ -485,24 +430,20 @@ CREATE TABLE `UserProfile` ( `name` varchar(45) NOT NULL, `profile` blob NOT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; +) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; - - DROP TABLE IF EXISTS `UserToUserGroup`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `UserToUserGroup` ( `userId` smallint(5) unsigned NOT NULL, `userGroupId` smallint(5) unsigned NOT NULL, - KEY `fk_UserToUserGroup_userId` (`userId`), - KEY `fk_UserToUserGroup_userGroupId` (`userGroupId`), - CONSTRAINT `fk_UserToUserGroup_userGroupId` FOREIGN KEY (`userGroupId`) REFERENCES `UserGroup` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `fk_UserToUserGroup_userId` FOREIGN KEY (`userId`) REFERENCES `User` (`id`) ON DELETE CASCADE ON UPDATE CASCADE + KEY `idx_UserToUserGroup_01` (`userId`), + KEY `fk_UserToGroup_userGroupId` (`userGroupId`), + CONSTRAINT `fk_UserToGroup_userGroupId` FOREIGN KEY (`userGroupId`) REFERENCES `UserGroup` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `fk_UserToGroup_userId` FOREIGN KEY (`userId`) REFERENCES `User` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; - - DROP TABLE IF EXISTS `account_data_v`; /*!50001 DROP VIEW IF EXISTS `account_data_v`*/; SET @saved_cs_client = @@character_set_client; @@ -539,8 +480,6 @@ SET character_set_client = utf8; `publicLinkHash` tinyint NOT NULL ) ENGINE=MyISAM */; SET character_set_client = @saved_cs_client; - - DROP TABLE IF EXISTS `account_search_v`; /*!50001 DROP VIEW IF EXISTS `account_search_v`*/; SET @saved_cs_client = @@character_set_client; @@ -572,8 +511,6 @@ SET character_set_client = utf8; `num_files` tinyint NOT NULL ) ENGINE=MyISAM */; SET character_set_client = @saved_cs_client; - - /*!50001 DROP TABLE IF EXISTS `account_data_v`*/; /*!50001 DROP VIEW IF EXISTS `account_data_v`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; @@ -588,8 +525,6 @@ SET character_set_client = @saved_cs_client; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; - - /*!50001 DROP TABLE IF EXISTS `account_search_v`*/; /*!50001 DROP VIEW IF EXISTS `account_search_v`*/; /*!50001 SET @saved_cs_client = @@character_set_client */;