From 4e3827e4af2afd35d978cbf027f15c03b3efdc3d Mon Sep 17 00:00:00 2001 From: artem Date: Thu, 5 Sep 2019 11:20:09 +0300 Subject: [PATCH 1/6] Create FOREIGN KEY --- sql/Aauth_v2_BCrypt.sql | 367 +++++++++++++++++++++++++++------------- 1 file changed, 247 insertions(+), 120 deletions(-) diff --git a/sql/Aauth_v2_BCrypt.sql b/sql/Aauth_v2_BCrypt.sql index d47e5d2..8a20081 100644 --- a/sql/Aauth_v2_BCrypt.sql +++ b/sql/Aauth_v2_BCrypt.sql @@ -1,74 +1,176 @@ /* Aauth SQL Table Structure */ +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8 */; +/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; +/*!40103 SET TIME_ZONE='+00:00' */; +/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; +/*!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 */; -SET FOREIGN_KEY_CHECKS=0; +-- +-- Table structure for table `aauth_group_to_group` +-- + +DROP TABLE IF EXISTS `aauth_group_to_group`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `aauth_group_to_group` ( + `group_id` int(11) unsigned NOT NULL, + `subgroup_id` int(11) unsigned NOT NULL, + PRIMARY KEY (`group_id`,`subgroup_id`), + KEY `aauth_group_to_group_FK_1` (`subgroup_id`), + CONSTRAINT `aauth_group_to_group_FK` FOREIGN KEY (`group_id`) REFERENCES `aauth_groups` (`id`) ON DELETE CASCADE, + CONSTRAINT `aauth_group_to_group_FK_1` FOREIGN KEY (`subgroup_id`) REFERENCES `aauth_groups` (`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Связь между дочерней и родительской группой'; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `aauth_group_to_group` +-- + +LOCK TABLES `aauth_group_to_group` WRITE; +/*!40000 ALTER TABLE `aauth_group_to_group` DISABLE KEYS */; +/*!40000 ALTER TABLE `aauth_group_to_group` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `aauth_groups` +-- --- ---------------------------- --- Table structure for `aauth_groups` --- ---------------------------- DROP TABLE IF EXISTS `aauth_groups`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `aauth_groups` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, - `name` varchar(100), + `name` varchar(100) DEFAULT NULL, `definition` text, PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8; - --- ---------------------------- --- Records of aauth_groups --- ---------------------------- -INSERT INTO `aauth_groups` VALUES ('1', 'Admin', 'Super Admin Group'); -INSERT INTO `aauth_groups` VALUES ('2', 'Public', 'Public Access Group'); -INSERT INTO `aauth_groups` VALUES ('3', 'Default', 'Default Access Group'); - --- ---------------------------- --- Table structure for `aauth_perms` --- ---------------------------- -DROP TABLE IF EXISTS `aauth_perms`; -CREATE TABLE `aauth_perms` ( - `id` int(11) unsigned NOT NULL AUTO_INCREMENT, - `name` varchar(100), - `definition` text, +) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 COMMENT='Группы'; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `aauth_groups` +-- + +LOCK TABLES `aauth_groups` WRITE; +/*!40000 ALTER TABLE `aauth_groups` DISABLE KEYS */; +INSERT INTO `aauth_groups` VALUES (1,'Admin','Super Admin Group'),(2,'Public','Public Access Group'),(3,'Default','Default Access Group'); +/*!40000 ALTER TABLE `aauth_groups` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `aauth_login_attempts` +-- + +DROP TABLE IF EXISTS `aauth_login_attempts`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `aauth_login_attempts` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `ip_address` varchar(39) DEFAULT '0', + `timestamp` datetime DEFAULT NULL, + `login_attempts` tinyint(2) DEFAULT '0', PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='Неуспешные попытки авторизации'; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `aauth_login_attempts` +-- --- ---------------------------- --- Records of aauth_perms --- ---------------------------- +LOCK TABLES `aauth_login_attempts` WRITE; +/*!40000 ALTER TABLE `aauth_login_attempts` DISABLE KEYS */; +/*!40000 ALTER TABLE `aauth_login_attempts` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `aauth_perm_to_group` +-- --- ---------------------------- --- Table structure for `aauth_perm_to_group` --- ---------------------------- DROP TABLE IF EXISTS `aauth_perm_to_group`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `aauth_perm_to_group` ( `perm_id` int(11) unsigned NOT NULL, `group_id` int(11) unsigned NOT NULL, - PRIMARY KEY (`perm_id`,`group_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + PRIMARY KEY (`perm_id`,`group_id`), + KEY `aauth_perm_to_group_FK_1` (`group_id`), + CONSTRAINT `aauth_perm_to_group_FK` FOREIGN KEY (`perm_id`) REFERENCES `aauth_perms` (`id`) ON DELETE CASCADE, + CONSTRAINT `aauth_perm_to_group_FK_1` FOREIGN KEY (`group_id`) REFERENCES `aauth_groups` (`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Связь прав и групп'; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `aauth_perm_to_group` +-- --- ---------------------------- --- Records of aauth_perm_to_group --- ---------------------------- +LOCK TABLES `aauth_perm_to_group` WRITE; +/*!40000 ALTER TABLE `aauth_perm_to_group` DISABLE KEYS */; +/*!40000 ALTER TABLE `aauth_perm_to_group` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `aauth_perm_to_user` +-- --- ---------------------------- --- Table structure for `aauth_perm_to_user` --- ---------------------------- DROP TABLE IF EXISTS `aauth_perm_to_user`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `aauth_perm_to_user` ( `perm_id` int(11) unsigned NOT NULL, `user_id` int(11) unsigned NOT NULL, - PRIMARY KEY (`perm_id`,`user_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + PRIMARY KEY (`perm_id`,`user_id`), + KEY `aauth_perm_to_user_FK_1` (`user_id`), + CONSTRAINT `aauth_perm_to_user_FK` FOREIGN KEY (`perm_id`) REFERENCES `aauth_perms` (`id`) ON DELETE CASCADE, + CONSTRAINT `aauth_perm_to_user_FK_1` FOREIGN KEY (`user_id`) REFERENCES `aauth_users` (`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Связь прав и пользователей'; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `aauth_perm_to_user` +-- + +LOCK TABLES `aauth_perm_to_user` WRITE; +/*!40000 ALTER TABLE `aauth_perm_to_user` DISABLE KEYS */; +/*!40000 ALTER TABLE `aauth_perm_to_user` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `aauth_perms` +-- + +DROP TABLE IF EXISTS `aauth_perms`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `aauth_perms` ( + `id` int(11) unsigned NOT NULL AUTO_INCREMENT, + `name` varchar(100) DEFAULT NULL, + `definition` text, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Список прав'; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `aauth_perms` +-- + +LOCK TABLES `aauth_perms` WRITE; +/*!40000 ALTER TABLE `aauth_perms` DISABLE KEYS */; +/*!40000 ALTER TABLE `aauth_perms` ENABLE KEYS */; +UNLOCK TABLES; --- ---------------------------- --- Records of aauth_perm_to_user --- ---------------------------- +-- +-- Table structure for table `aauth_pms` +-- --- ---------------------------- --- Table structure for `aauth_pms` --- ---------------------------- DROP TABLE IF EXISTS `aauth_pms`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `aauth_pms` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, `sender_id` int(11) unsigned NOT NULL, @@ -80,99 +182,124 @@ CREATE TABLE `aauth_pms` ( `pm_deleted_sender` int(1) DEFAULT NULL, `pm_deleted_receiver` int(1) DEFAULT NULL, PRIMARY KEY (`id`), - KEY `full_index` (`id`,`sender_id`,`receiver_id`,`date_read`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + KEY `full_index` (`id`,`sender_id`,`receiver_id`,`date_read`), + KEY `aauth_pms_FK` (`sender_id`), + KEY `aauth_pms_FK_1` (`receiver_id`), + CONSTRAINT `aauth_pms_FK` FOREIGN KEY (`sender_id`) REFERENCES `aauth_users` (`id`) ON DELETE CASCADE, + CONSTRAINT `aauth_pms_FK_1` FOREIGN KEY (`receiver_id`) REFERENCES `aauth_users` (`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Личные сообщения'; +/*!40101 SET character_set_client = @saved_cs_client */; --- ---------------------------- --- Records of aauth_pms --- ---------------------------- +-- +-- Dumping data for table `aauth_pms` +-- --- ---------------------------- --- Table structure for `aauth_users` --- ---------------------------- -DROP TABLE IF EXISTS `aauth_users`; -CREATE TABLE `aauth_users` ( - `id` int(11) unsigned NOT NULL AUTO_INCREMENT, - `email` varchar(100) COLLATE utf8_general_ci NOT NULL, - `pass` varchar(60) COLLATE utf8_general_ci NOT NULL, - `username` varchar(100) COLLATE utf8_general_ci, - `banned` tinyint(1) DEFAULT '0', - `last_login` datetime DEFAULT NULL, - `last_activity` datetime DEFAULT NULL, - `date_created` datetime DEFAULT NULL, - `forgot_exp` text COLLATE utf8_general_ci, - `remember_time` datetime DEFAULT NULL, - `remember_exp` text COLLATE utf8_general_ci, - `verification_code` text COLLATE utf8_general_ci, - `totp_secret` varchar(16) COLLATE utf8_general_ci DEFAULT NULL, - `ip_address` text COLLATE utf8_general_ci, - PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci; +LOCK TABLES `aauth_pms` WRITE; +/*!40000 ALTER TABLE `aauth_pms` DISABLE KEYS */; +/*!40000 ALTER TABLE `aauth_pms` ENABLE KEYS */; +UNLOCK TABLES; --- ---------------------------- --- Records of aauth_users --- ---------------------------- -INSERT INTO `aauth_users` VALUES ('1', 'admin@example.com', '$2y$10$h19Lblcr6amOIUL1TgYW2.VVZOhac/e1kHMgAwCubMTlYXZrL0wS2', 'Admin', '0', null, null, null, null, null, null, null, null, '0'); +-- +-- Table structure for table `aauth_user_to_group` +-- --- ---------------------------- --- Table structure for `aauth_user_to_group` --- ---------------------------- DROP TABLE IF EXISTS `aauth_user_to_group`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `aauth_user_to_group` ( `user_id` int(11) unsigned NOT NULL, `group_id` int(11) unsigned NOT NULL, - PRIMARY KEY (`user_id`,`group_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - --- ---------------------------- --- Records of aauth_user_to_group --- ---------------------------- -INSERT INTO `aauth_user_to_group` VALUES ('1', '1'); -INSERT INTO `aauth_user_to_group` VALUES ('1', '3'); - --- ---------------------------- --- Table structure for `aauth_user_variables` --- ---------------------------- + PRIMARY KEY (`user_id`,`group_id`), + KEY `aauth_user_to_group_FK_1` (`group_id`), + CONSTRAINT `aauth_user_to_group_FK` FOREIGN KEY (`user_id`) REFERENCES `aauth_users` (`id`) ON DELETE CASCADE, + CONSTRAINT `aauth_user_to_group_FK_1` FOREIGN KEY (`group_id`) REFERENCES `aauth_groups` (`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Связь пользователей и групп'; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `aauth_user_to_group` +-- + +LOCK TABLES `aauth_user_to_group` WRITE; +/*!40000 ALTER TABLE `aauth_user_to_group` DISABLE KEYS */; +INSERT INTO `aauth_user_to_group` VALUES (1,1),(1,3); +/*!40000 ALTER TABLE `aauth_user_to_group` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `aauth_user_variables` +-- + DROP TABLE IF EXISTS `aauth_user_variables`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `aauth_user_variables` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, `user_id` int(11) unsigned NOT NULL, `data_key` varchar(100) NOT NULL, `value` text, PRIMARY KEY (`id`), - KEY `user_id_index` (`user_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + KEY `user_id_index` (`user_id`), + CONSTRAINT `aauth_user_variables_FK` FOREIGN KEY (`user_id`) REFERENCES `aauth_users` (`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Пользовательские параметры'; +/*!40101 SET character_set_client = @saved_cs_client */; --- ---------------------------- --- Records of aauth_user_variables --- ---------------------------- - --- ---------------------------- --- Table structure for `aauth_group_to_group` --- ---------------------------- -DROP TABLE IF EXISTS `aauth_group_to_group`; -CREATE TABLE `aauth_group_to_group` ( - `group_id` int(11) unsigned NOT NULL, - `subgroup_id` int(11) unsigned NOT NULL, - PRIMARY KEY (`group_id`,`subgroup_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; +-- +-- Dumping data for table `aauth_user_variables` +-- --- ---------------------------- --- Records of aauth_group_to_group --- ---------------------------- +LOCK TABLES `aauth_user_variables` WRITE; +/*!40000 ALTER TABLE `aauth_user_variables` DISABLE KEYS */; +/*!40000 ALTER TABLE `aauth_user_variables` ENABLE KEYS */; +UNLOCK TABLES; --- ---------------------------- --- Table structure for `aauth_login_attempts` --- ---------------------------- +-- +-- Table structure for table `aauth_users` +-- -CREATE TABLE IF NOT EXISTS `aauth_login_attempts` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `ip_address` varchar(39) DEFAULT '0', - `timestamp` datetime DEFAULT NULL, - `login_attempts` tinyint(2) DEFAULT '0', +DROP TABLE IF EXISTS `aauth_users`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `aauth_users` ( + `id` int(11) unsigned NOT NULL AUTO_INCREMENT, + `email` varchar(100) NOT NULL, + `pass` varchar(60) NOT NULL, + `username` varchar(100) DEFAULT NULL, + `banned` tinyint(1) DEFAULT '0', + `last_login` datetime DEFAULT NULL, + `last_activity` datetime DEFAULT NULL, + `date_created` datetime DEFAULT NULL, + `forgot_exp` text, + `remember_time` datetime DEFAULT NULL, + `remember_exp` text, + `verification_code` text, + `totp_secret` varchar(16) DEFAULT NULL, + `ip_address` text, PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; +) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COMMENT='Список пользователей'; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `aauth_users` +-- + +LOCK TABLES `aauth_users` WRITE; +/*!40000 ALTER TABLE `aauth_users` DISABLE KEYS */; +INSERT INTO `aauth_users` VALUES (1,'admin@example.com','$2y$10$h19Lblcr6amOIUL1TgYW2.VVZOhac/e1kHMgAwCubMTlYXZrL0wS2','Admin',0,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0'); +/*!40000 ALTER TABLE `aauth_users` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Dumping routines for database 'roundcubemail' +-- +/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; + +/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; +/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; +/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- ---------------------------- --- Records of aauth_login_attempts --- ---------------------------- +-- Dump completed on 2019-09-05 11:08:43 From 2b537e34364c6e443f66cf56c159fc90fa57b2da Mon Sep 17 00:00:00 2001 From: artem Date: Thu, 5 Sep 2019 11:25:52 +0300 Subject: [PATCH 2/6] Remove group to subgroup --- sql/Aauth_v2_BCrypt.sql | 166 ++++++++++++++++------------------------ 1 file changed, 68 insertions(+), 98 deletions(-) diff --git a/sql/Aauth_v2_BCrypt.sql b/sql/Aauth_v2_BCrypt.sql index 8a20081..5559dea 100644 --- a/sql/Aauth_v2_BCrypt.sql +++ b/sql/Aauth_v2_BCrypt.sql @@ -1,6 +1,7 @@ /* Aauth SQL Table Structure */ + /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; @@ -12,32 +13,6 @@ /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; --- --- Table structure for table `aauth_group_to_group` --- - -DROP TABLE IF EXISTS `aauth_group_to_group`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `aauth_group_to_group` ( - `group_id` int(11) unsigned NOT NULL, - `subgroup_id` int(11) unsigned NOT NULL, - PRIMARY KEY (`group_id`,`subgroup_id`), - KEY `aauth_group_to_group_FK_1` (`subgroup_id`), - CONSTRAINT `aauth_group_to_group_FK` FOREIGN KEY (`group_id`) REFERENCES `aauth_groups` (`id`) ON DELETE CASCADE, - CONSTRAINT `aauth_group_to_group_FK_1` FOREIGN KEY (`subgroup_id`) REFERENCES `aauth_groups` (`id`) ON DELETE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Связь между дочерней и родительской группой'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Dumping data for table `aauth_group_to_group` --- - -LOCK TABLES `aauth_group_to_group` WRITE; -/*!40000 ALTER TABLE `aauth_group_to_group` DISABLE KEYS */; -/*!40000 ALTER TABLE `aauth_group_to_group` ENABLE KEYS */; -UNLOCK TABLES; - -- -- Table structure for table `aauth_groups` -- @@ -64,28 +39,30 @@ INSERT INTO `aauth_groups` VALUES (1,'Admin','Super Admin Group'),(2,'Public','P UNLOCK TABLES; -- --- Table structure for table `aauth_login_attempts` +-- Table structure for table `aauth_user_to_group` -- -DROP TABLE IF EXISTS `aauth_login_attempts`; +DROP TABLE IF EXISTS `aauth_user_to_group`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; -CREATE TABLE `aauth_login_attempts` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `ip_address` varchar(39) DEFAULT '0', - `timestamp` datetime DEFAULT NULL, - `login_attempts` tinyint(2) DEFAULT '0', - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='Неуспешные попытки авторизации'; +CREATE TABLE `aauth_user_to_group` ( + `user_id` int(11) unsigned NOT NULL, + `group_id` int(11) unsigned NOT NULL, + PRIMARY KEY (`user_id`,`group_id`), + KEY `aauth_user_to_group_FK_1` (`group_id`), + CONSTRAINT `aauth_user_to_group_FK` FOREIGN KEY (`user_id`) REFERENCES `aauth_users` (`id`) ON DELETE CASCADE, + CONSTRAINT `aauth_user_to_group_FK_1` FOREIGN KEY (`group_id`) REFERENCES `aauth_groups` (`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Связь пользователей и групп'; /*!40101 SET character_set_client = @saved_cs_client */; -- --- Dumping data for table `aauth_login_attempts` +-- Dumping data for table `aauth_user_to_group` -- -LOCK TABLES `aauth_login_attempts` WRITE; -/*!40000 ALTER TABLE `aauth_login_attempts` DISABLE KEYS */; -/*!40000 ALTER TABLE `aauth_login_attempts` ENABLE KEYS */; +LOCK TABLES `aauth_user_to_group` WRITE; +/*!40000 ALTER TABLE `aauth_user_to_group` DISABLE KEYS */; +INSERT INTO `aauth_user_to_group` VALUES (1,1),(1,3); +/*!40000 ALTER TABLE `aauth_user_to_group` ENABLE KEYS */; UNLOCK TABLES; -- @@ -140,6 +117,33 @@ LOCK TABLES `aauth_perm_to_user` WRITE; /*!40000 ALTER TABLE `aauth_perm_to_user` ENABLE KEYS */; UNLOCK TABLES; +-- +-- Table structure for table `aauth_user_variables` +-- + +DROP TABLE IF EXISTS `aauth_user_variables`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `aauth_user_variables` ( + `id` int(11) unsigned NOT NULL AUTO_INCREMENT, + `user_id` int(11) unsigned NOT NULL, + `data_key` varchar(100) NOT NULL, + `value` text, + PRIMARY KEY (`id`), + KEY `user_id_index` (`user_id`), + CONSTRAINT `aauth_user_variables_FK` FOREIGN KEY (`user_id`) REFERENCES `aauth_users` (`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Пользовательские параметры'; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `aauth_user_variables` +-- + +LOCK TABLES `aauth_user_variables` WRITE; +/*!40000 ALTER TABLE `aauth_user_variables` DISABLE KEYS */; +/*!40000 ALTER TABLE `aauth_user_variables` ENABLE KEYS */; +UNLOCK TABLES; + -- -- Table structure for table `aauth_perms` -- @@ -164,6 +168,31 @@ LOCK TABLES `aauth_perms` WRITE; /*!40000 ALTER TABLE `aauth_perms` ENABLE KEYS */; UNLOCK TABLES; +-- +-- Table structure for table `aauth_login_attempts` +-- + +DROP TABLE IF EXISTS `aauth_login_attempts`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `aauth_login_attempts` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `ip_address` varchar(39) DEFAULT '0', + `timestamp` datetime DEFAULT NULL, + `login_attempts` tinyint(2) DEFAULT '0', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='Неуспешные попытки авторизации'; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `aauth_login_attempts` +-- + +LOCK TABLES `aauth_login_attempts` WRITE; +/*!40000 ALTER TABLE `aauth_login_attempts` DISABLE KEYS */; +/*!40000 ALTER TABLE `aauth_login_attempts` ENABLE KEYS */; +UNLOCK TABLES; + -- -- Table structure for table `aauth_pms` -- @@ -199,60 +228,6 @@ LOCK TABLES `aauth_pms` WRITE; /*!40000 ALTER TABLE `aauth_pms` ENABLE KEYS */; UNLOCK TABLES; --- --- Table structure for table `aauth_user_to_group` --- - -DROP TABLE IF EXISTS `aauth_user_to_group`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `aauth_user_to_group` ( - `user_id` int(11) unsigned NOT NULL, - `group_id` int(11) unsigned NOT NULL, - PRIMARY KEY (`user_id`,`group_id`), - KEY `aauth_user_to_group_FK_1` (`group_id`), - CONSTRAINT `aauth_user_to_group_FK` FOREIGN KEY (`user_id`) REFERENCES `aauth_users` (`id`) ON DELETE CASCADE, - CONSTRAINT `aauth_user_to_group_FK_1` FOREIGN KEY (`group_id`) REFERENCES `aauth_groups` (`id`) ON DELETE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Связь пользователей и групп'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Dumping data for table `aauth_user_to_group` --- - -LOCK TABLES `aauth_user_to_group` WRITE; -/*!40000 ALTER TABLE `aauth_user_to_group` DISABLE KEYS */; -INSERT INTO `aauth_user_to_group` VALUES (1,1),(1,3); -/*!40000 ALTER TABLE `aauth_user_to_group` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `aauth_user_variables` --- - -DROP TABLE IF EXISTS `aauth_user_variables`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `aauth_user_variables` ( - `id` int(11) unsigned NOT NULL AUTO_INCREMENT, - `user_id` int(11) unsigned NOT NULL, - `data_key` varchar(100) NOT NULL, - `value` text, - PRIMARY KEY (`id`), - KEY `user_id_index` (`user_id`), - CONSTRAINT `aauth_user_variables_FK` FOREIGN KEY (`user_id`) REFERENCES `aauth_users` (`id`) ON DELETE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Пользовательские параметры'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Dumping data for table `aauth_user_variables` --- - -LOCK TABLES `aauth_user_variables` WRITE; -/*!40000 ALTER TABLE `aauth_user_variables` DISABLE KEYS */; -/*!40000 ALTER TABLE `aauth_user_variables` ENABLE KEYS */; -UNLOCK TABLES; - -- -- Table structure for table `aauth_users` -- @@ -288,10 +263,6 @@ LOCK TABLES `aauth_users` WRITE; INSERT INTO `aauth_users` VALUES (1,'admin@example.com','$2y$10$h19Lblcr6amOIUL1TgYW2.VVZOhac/e1kHMgAwCubMTlYXZrL0wS2','Admin',0,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0'); /*!40000 ALTER TABLE `aauth_users` ENABLE KEYS */; UNLOCK TABLES; - --- --- Dumping routines for database 'roundcubemail' --- /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; @@ -302,4 +273,3 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2019-09-05 11:08:43 From 5e2655ec900536730e25891012d0c23ec3a7bd26 Mon Sep 17 00:00:00 2001 From: artem Date: Thu, 5 Sep 2019 11:51:03 +0300 Subject: [PATCH 3/6] pm -> group chat & create logs --- sql/Aauth_v2_BCrypt.sql | 183 +++++++++++++++++++++++----------------- 1 file changed, 107 insertions(+), 76 deletions(-) diff --git a/sql/Aauth_v2_BCrypt.sql b/sql/Aauth_v2_BCrypt.sql index 5559dea..d5ef4dc 100644 --- a/sql/Aauth_v2_BCrypt.sql +++ b/sql/Aauth_v2_BCrypt.sql @@ -2,6 +2,7 @@ Aauth SQL Table Structure */ + /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; @@ -13,6 +14,41 @@ /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; +-- +-- Table structure for table `aauth_chatmsg` +-- + +DROP TABLE IF EXISTS `aauth_chatmsg`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `aauth_chatmsg` ( + `id` int(11) unsigned NOT NULL AUTO_INCREMENT, + `sender_id` int(11) unsigned NOT NULL, + `receiver_id` int(11) unsigned NOT NULL, + `title` varchar(255) NOT NULL, + `message` text, + `date_sent` datetime DEFAULT NULL, + `date_read` datetime DEFAULT NULL, + `msg_deleted_sender` int(1) DEFAULT NULL, + `msg_deleted_receiver` int(1) DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `full_index` (`id`,`sender_id`,`receiver_id`,`date_read`), + KEY `aauth_pms_FK` (`sender_id`), + KEY `aauth_pms_FK_1` (`receiver_id`), + CONSTRAINT `aauth_pms_FK` FOREIGN KEY (`sender_id`) REFERENCES `aauth_users` (`id`) ON DELETE CASCADE, + CONSTRAINT `aauth_pms_FK_1` FOREIGN KEY (`receiver_id`) REFERENCES `aauth_groups` (`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Сообщения из чатов'; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `aauth_chatmsg` +-- + +LOCK TABLES `aauth_chatmsg` WRITE; +/*!40000 ALTER TABLE `aauth_chatmsg` DISABLE KEYS */; +/*!40000 ALTER TABLE `aauth_chatmsg` ENABLE KEYS */; +UNLOCK TABLES; + -- -- Table structure for table `aauth_groups` -- @@ -39,30 +75,54 @@ INSERT INTO `aauth_groups` VALUES (1,'Admin','Super Admin Group'),(2,'Public','P UNLOCK TABLES; -- --- Table structure for table `aauth_user_to_group` +-- Table structure for table `aauth_log` -- -DROP TABLE IF EXISTS `aauth_user_to_group`; +DROP TABLE IF EXISTS `aauth_log`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; -CREATE TABLE `aauth_user_to_group` ( - `user_id` int(11) unsigned NOT NULL, - `group_id` int(11) unsigned NOT NULL, - PRIMARY KEY (`user_id`,`group_id`), - KEY `aauth_user_to_group_FK_1` (`group_id`), - CONSTRAINT `aauth_user_to_group_FK` FOREIGN KEY (`user_id`) REFERENCES `aauth_users` (`id`) ON DELETE CASCADE, - CONSTRAINT `aauth_user_to_group_FK_1` FOREIGN KEY (`group_id`) REFERENCES `aauth_groups` (`id`) ON DELETE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Связь пользователей и групп'; +CREATE TABLE `aauth_log` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `user_id` int(10) unsigned NOT NULL, + `text` text NOT NULL, + PRIMARY KEY (`id`), + KEY `aauth_log_FK` (`user_id`), + CONSTRAINT `aauth_log_FK` FOREIGN KEY (`user_id`) REFERENCES `aauth_users` (`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Логи пользователей'; /*!40101 SET character_set_client = @saved_cs_client */; -- --- Dumping data for table `aauth_user_to_group` +-- Dumping data for table `aauth_log` -- -LOCK TABLES `aauth_user_to_group` WRITE; -/*!40000 ALTER TABLE `aauth_user_to_group` DISABLE KEYS */; -INSERT INTO `aauth_user_to_group` VALUES (1,1),(1,3); -/*!40000 ALTER TABLE `aauth_user_to_group` ENABLE KEYS */; +LOCK TABLES `aauth_log` WRITE; +/*!40000 ALTER TABLE `aauth_log` DISABLE KEYS */; +/*!40000 ALTER TABLE `aauth_log` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `aauth_login_attempts` +-- + +DROP TABLE IF EXISTS `aauth_login_attempts`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `aauth_login_attempts` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `ip_address` varchar(39) DEFAULT '0', + `timestamp` datetime DEFAULT NULL, + `login_attempts` tinyint(2) DEFAULT '0', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='Неуспешные попытки авторизации'; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `aauth_login_attempts` +-- + +LOCK TABLES `aauth_login_attempts` WRITE; +/*!40000 ALTER TABLE `aauth_login_attempts` DISABLE KEYS */; +/*!40000 ALTER TABLE `aauth_login_attempts` ENABLE KEYS */; UNLOCK TABLES; -- @@ -117,33 +177,6 @@ LOCK TABLES `aauth_perm_to_user` WRITE; /*!40000 ALTER TABLE `aauth_perm_to_user` ENABLE KEYS */; UNLOCK TABLES; --- --- Table structure for table `aauth_user_variables` --- - -DROP TABLE IF EXISTS `aauth_user_variables`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `aauth_user_variables` ( - `id` int(11) unsigned NOT NULL AUTO_INCREMENT, - `user_id` int(11) unsigned NOT NULL, - `data_key` varchar(100) NOT NULL, - `value` text, - PRIMARY KEY (`id`), - KEY `user_id_index` (`user_id`), - CONSTRAINT `aauth_user_variables_FK` FOREIGN KEY (`user_id`) REFERENCES `aauth_users` (`id`) ON DELETE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Пользовательские параметры'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Dumping data for table `aauth_user_variables` --- - -LOCK TABLES `aauth_user_variables` WRITE; -/*!40000 ALTER TABLE `aauth_user_variables` DISABLE KEYS */; -/*!40000 ALTER TABLE `aauth_user_variables` ENABLE KEYS */; -UNLOCK TABLES; - -- -- Table structure for table `aauth_perms` -- @@ -169,63 +202,57 @@ LOCK TABLES `aauth_perms` WRITE; UNLOCK TABLES; -- --- Table structure for table `aauth_login_attempts` +-- Table structure for table `aauth_user_to_group` -- -DROP TABLE IF EXISTS `aauth_login_attempts`; +DROP TABLE IF EXISTS `aauth_user_to_group`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; -CREATE TABLE `aauth_login_attempts` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `ip_address` varchar(39) DEFAULT '0', - `timestamp` datetime DEFAULT NULL, - `login_attempts` tinyint(2) DEFAULT '0', - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='Неуспешные попытки авторизации'; +CREATE TABLE `aauth_user_to_group` ( + `user_id` int(11) unsigned NOT NULL, + `group_id` int(11) unsigned NOT NULL, + PRIMARY KEY (`user_id`,`group_id`), + KEY `aauth_user_to_group_FK_1` (`group_id`), + CONSTRAINT `aauth_user_to_group_FK` FOREIGN KEY (`user_id`) REFERENCES `aauth_users` (`id`) ON DELETE CASCADE, + CONSTRAINT `aauth_user_to_group_FK_1` FOREIGN KEY (`group_id`) REFERENCES `aauth_groups` (`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Связь пользователей и групп'; /*!40101 SET character_set_client = @saved_cs_client */; -- --- Dumping data for table `aauth_login_attempts` +-- Dumping data for table `aauth_user_to_group` -- -LOCK TABLES `aauth_login_attempts` WRITE; -/*!40000 ALTER TABLE `aauth_login_attempts` DISABLE KEYS */; -/*!40000 ALTER TABLE `aauth_login_attempts` ENABLE KEYS */; +LOCK TABLES `aauth_user_to_group` WRITE; +/*!40000 ALTER TABLE `aauth_user_to_group` DISABLE KEYS */; +INSERT INTO `aauth_user_to_group` VALUES (1,1),(1,3); +/*!40000 ALTER TABLE `aauth_user_to_group` ENABLE KEYS */; UNLOCK TABLES; -- --- Table structure for table `aauth_pms` +-- Table structure for table `aauth_user_variables` -- -DROP TABLE IF EXISTS `aauth_pms`; +DROP TABLE IF EXISTS `aauth_user_variables`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; -CREATE TABLE `aauth_pms` ( +CREATE TABLE `aauth_user_variables` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, - `sender_id` int(11) unsigned NOT NULL, - `receiver_id` int(11) unsigned NOT NULL, - `title` varchar(255) NOT NULL, - `message` text, - `date_sent` datetime DEFAULT NULL, - `date_read` datetime DEFAULT NULL, - `pm_deleted_sender` int(1) DEFAULT NULL, - `pm_deleted_receiver` int(1) DEFAULT NULL, + `user_id` int(11) unsigned NOT NULL, + `data_key` varchar(100) NOT NULL, + `value` text, PRIMARY KEY (`id`), - KEY `full_index` (`id`,`sender_id`,`receiver_id`,`date_read`), - KEY `aauth_pms_FK` (`sender_id`), - KEY `aauth_pms_FK_1` (`receiver_id`), - CONSTRAINT `aauth_pms_FK` FOREIGN KEY (`sender_id`) REFERENCES `aauth_users` (`id`) ON DELETE CASCADE, - CONSTRAINT `aauth_pms_FK_1` FOREIGN KEY (`receiver_id`) REFERENCES `aauth_users` (`id`) ON DELETE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Личные сообщения'; + KEY `user_id_index` (`user_id`), + CONSTRAINT `aauth_user_variables_FK` FOREIGN KEY (`user_id`) REFERENCES `aauth_users` (`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Пользовательские параметры'; /*!40101 SET character_set_client = @saved_cs_client */; -- --- Dumping data for table `aauth_pms` +-- Dumping data for table `aauth_user_variables` -- -LOCK TABLES `aauth_pms` WRITE; -/*!40000 ALTER TABLE `aauth_pms` DISABLE KEYS */; -/*!40000 ALTER TABLE `aauth_pms` ENABLE KEYS */; +LOCK TABLES `aauth_user_variables` WRITE; +/*!40000 ALTER TABLE `aauth_user_variables` DISABLE KEYS */; +/*!40000 ALTER TABLE `aauth_user_variables` ENABLE KEYS */; UNLOCK TABLES; -- @@ -263,6 +290,10 @@ LOCK TABLES `aauth_users` WRITE; INSERT INTO `aauth_users` VALUES (1,'admin@example.com','$2y$10$h19Lblcr6amOIUL1TgYW2.VVZOhac/e1kHMgAwCubMTlYXZrL0wS2','Admin',0,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0'); /*!40000 ALTER TABLE `aauth_users` ENABLE KEYS */; UNLOCK TABLES; + +-- +-- Dumping routines for database 'roundcubemail' +-- /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; From 5d5a13004740282be402ff8f08b1ebd873bcc27f Mon Sep 17 00:00:00 2001 From: artem Date: Thu, 5 Sep 2019 12:14:04 +0300 Subject: [PATCH 4/6] remove subgroups --- application/config/aauth.php | 3 +- application/libraries/Aauth.php | 104 -------------------------------- 2 files changed, 1 insertion(+), 106 deletions(-) diff --git a/application/config/aauth.php b/application/config/aauth.php index b791554..b467b40 100644 --- a/application/config/aauth.php +++ b/application/config/aauth.php @@ -93,7 +93,6 @@ $config_aauth["default"] = array( 'users' => 'aauth_users', 'groups' => 'aauth_groups', - 'group_to_group' => 'aauth_group_to_group', 'user_to_group' => 'aauth_user_to_group', 'perms' => 'aauth_perms', 'perm_to_group' => 'aauth_perm_to_group', @@ -148,4 +147,4 @@ $config_aauth["default"] = array( $config['aauth'] = $config_aauth['default']; /* End of file aauth.php */ -/* Location: ./application/config/aauth.php */ \ No newline at end of file +/* Location: ./application/config/aauth.php */ diff --git a/application/libraries/Aauth.php b/application/libraries/Aauth.php index 14bb1d0..b47c2e1 100644 --- a/application/libraries/Aauth.php +++ b/application/libraries/Aauth.php @@ -1352,12 +1352,6 @@ class Aauth { $this->aauth_db->where('group_id', $group_id); $this->aauth_db->delete($this->config_vars['perm_to_group']); - $this->aauth_db->where('group_id', $group_id); - $this->aauth_db->delete($this->config_vars['group_to_group']); - - $this->aauth_db->where('subgroup_id', $group_id); - $this->aauth_db->delete($this->config_vars['group_to_group']); - $this->aauth_db->where('id', $group_id); $this->aauth_db->delete($this->config_vars['groups']); @@ -1422,76 +1416,6 @@ class Aauth { return $this->aauth_db->delete($this->config_vars['user_to_group']); } - /** - * Add subgroup - * Add a subgroup to a group - * @param int $user_id User id to add to group - * @param int|string $group_par Group id or name to add user to - * @return bool Add success/failure - */ - public function add_subgroup($group_par, $subgroup_par) { - - $group_id = $this->get_group_id($group_par); - $subgroup_id = $this->get_group_id($subgroup_par); - - if( ! $group_id ) { - $this->error( $this->CI->lang->line('aauth_error_no_group') ); - return false; - } - - if( ! $subgroup_id ) { - $this->error( $this->CI->lang->line('aauth_error_no_subgroup') ); - return false; - } - - if ($group_groups = $this->get_subgroups($group_id)) { - foreach ($group_groups as $item) { - if ($item->subgroup_id == $subgroup_id) { - return false; - } - } - } - - if ($subgroup_groups = $this->get_subgroups($subgroup_id)) { - foreach ($subgroup_groups as $item) { - if ($item->subgroup_id == $group_id) { - return false; - } - } - } - - $query = $this->aauth_db->where('group_id',$group_id); - $query = $this->aauth_db->where('subgroup_id',$subgroup_id); - $query = $this->aauth_db->get($this->config_vars['group_to_group']); - - if ($query->num_rows() < 1) { - $data = array( - 'group_id' => $group_id, - 'subgroup_id' => $subgroup_id, - ); - - return $this->aauth_db->insert($this->config_vars['group_to_group'], $data); - } - $this->info($this->CI->lang->line('aauth_info_already_subgroup')); - return true; - } - - /** - * Remove subgroup - * Remove a subgroup from a group - * @param int|string $group_par Group id or name to remove - * @param int|string $subgroup_par Sub-Group id or name to remove - * @return bool Remove success/failure - */ - public function remove_subgroup($group_par, $subgroup_par) { - - $group_par = $this->get_group_id($group_par); - $subgroup_par = $this->get_group_id($subgroup_par); - $this->aauth_db->where('group_id', $group_par); - $this->aauth_db->where('subgroup_id', $subgroup_par); - return $this->aauth_db->delete($this->config_vars['group_to_group']); - } - //tested /** * Remove member @@ -1635,26 +1559,6 @@ class Aauth { return false; } - /** - * Get subgroups - * Get subgroups from group name or id ( ! Case sensitive) - * @param int|string $group_par Group id or name to get - * @return object Array of subgroup_id's - */ - public function get_subgroups ( $group_par ) { - - $group_id = $this->get_group_id($group_par); - - $query = $this->aauth_db->where('group_id', $group_id); - $query = $this->aauth_db->select('subgroup_id'); - $query = $this->aauth_db->get($this->config_vars['group_to_group']); - - if ($query->num_rows() == 0) - return false; - - return $query->result(); - } - ######################## # Permission Functions ######################## @@ -1835,20 +1739,12 @@ class Aauth { if (strcasecmp($group_par, $this->config_vars['admin_group']) == 0) {return true;} - $subgroup_ids = $this->get_subgroups($group_par); $group_par = $this->get_group_id($group_par); $query = $this->aauth_db->where('perm_id', $perm_id); $query = $this->aauth_db->where('group_id', $group_par); $query = $this->aauth_db->get( $this->config_vars['perm_to_group'] ); $g_allowed=false; - if(is_array($subgroup_ids)){ - foreach ($subgroup_ids as $g ){ - if($this->is_group_allowed($perm_id, $g->subgroup_id)){ - $g_allowed=true; - } - } - } if( $query->num_rows() > 0){ $g_allowed=true; From 1496d47467ac6364b3bec5a0a13f40388e33b590 Mon Sep 17 00:00:00 2001 From: artem Date: Thu, 5 Sep 2019 12:16:44 +0300 Subject: [PATCH 5/6] default config to new sql --- application/config/aauth.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/config/aauth.php b/application/config/aauth.php index b467b40..41c1b35 100644 --- a/application/config/aauth.php +++ b/application/config/aauth.php @@ -97,7 +97,7 @@ $config_aauth["default"] = array( 'perms' => 'aauth_perms', 'perm_to_group' => 'aauth_perm_to_group', 'perm_to_user' => 'aauth_perm_to_user', - 'pms' => 'aauth_pms', + 'pms' => 'aauth_chatmsg', 'user_variables' => 'aauth_user_variables', 'login_attempts' => 'aauth_login_attempts', From 09b6a506fc4c9816c22507e5a20fb3984621174a Mon Sep 17 00:00:00 2001 From: artem Date: Thu, 5 Sep 2019 12:37:14 +0300 Subject: [PATCH 6/6] pm -> chat groups --- application/libraries/Aauth.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/libraries/Aauth.php b/application/libraries/Aauth.php index b47c2e1..08d9ae6 100644 --- a/application/libraries/Aauth.php +++ b/application/libraries/Aauth.php @@ -1951,7 +1951,7 @@ class Aauth { $this->error($this->CI->lang->line('aauth_error_self_pm')); return false; } - if (($this->is_banned($receiver_id) || !$this->user_exist_by_id($receiver_id)) || ($sender_id && ($this->is_banned($sender_id) || !$this->user_exist_by_id($sender_id)))){ + if (($this->is_banned($receiver_id) || !$this->get_group_id($receiver_id)) || ($sender_id && ($this->is_banned($sender_id) || !$this->user_exist_by_id($sender_id)))){ $this->error($this->CI->lang->line('aauth_error_no_user')); return false; }