diff --git a/app/views/tag_subscription/_user_listing.php b/app/views/tag_subscription/_user_listing.php index 9271ac7..355e1e9 100755 --- a/app/views/tag_subscription/_user_listing.php +++ b/app/views/tag_subscription/_user_listing.php @@ -1,11 +1,15 @@ -tag_subscriptions) && $user->tag_subscriptions->size() > 0; ?> +user ?? ($user ?? null); +$subscriptions = $listingUser ? $listingUser->tag_subscriptions : null; +$has_subscriptions = $subscriptions && $subscriptions->size() > 0; +?> t('sub_none') ?> - tag_subscription_listing($user) ?> + tag_subscription_listing($listingUser) ?> -id == $user->id) : ?> +id == $listingUser->id) : ?> (linkTo($this->t('sub_edit'), 'tag_subscription#index') ?>) diff --git a/db/migrate/20260218221000_ensure_user_logs_table_exists.php b/db/migrate/20260218221000_ensure_user_logs_table_exists.php new file mode 100644 index 0000000..b60f17b --- /dev/null +++ b/db/migrate/20260218221000_ensure_user_logs_table_exists.php @@ -0,0 +1,47 @@ +tableExists('user_logs')) { + $this->execute(<<foreignKeyExists('user_logs', 'fk_user_logs__user_id')) { + $this->execute( + "ALTER TABLE `user_logs` ADD CONSTRAINT `fk_user_logs__user_id` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE" + ); + } + } + + private function tableExists($tableName) + { + $stmt = $this->connection->executeSql("SHOW TABLES LIKE ?", $tableName); + $row = $stmt->fetch(\PDO::FETCH_NUM); + + return $row !== false; + } + + private function foreignKeyExists($tableName, $constraintName) + { + $stmt = $this->connection->executeSql( + "SELECT COUNT(*) AS count_value FROM information_schema.TABLE_CONSTRAINTS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = ? AND CONSTRAINT_NAME = ? AND CONSTRAINT_TYPE = 'FOREIGN KEY'", + $tableName, + $constraintName + ); + $row = $stmt->fetch(\PDO::FETCH_ASSOC); + + return $row && (int)$row['count_value'] > 0; + } +} diff --git a/db/schema.sql b/db/schema.sql index 0b53360..45ba28f 100755 --- a/db/schema.sql +++ b/db/schema.sql @@ -423,6 +423,16 @@ CREATE TABLE `user_blacklisted_tags` ( UNIQUE KEY `user_id` (`user_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; +CREATE TABLE `user_logs` ( + `id` int(11) unsigned NOT NULL AUTO_INCREMENT, + `user_id` int(11) NOT NULL, + `ip_addr` varchar(46) NOT NULL, + `created_at` datetime NOT NULL, + PRIMARY KEY (`id`), + KEY `created_at` (`created_at`), + KEY `user_id` (`user_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + CREATE TABLE `user_records` ( `id` bigint(20) NOT NULL AUTO_INCREMENT, `user_id` int(11) NOT NULL, @@ -600,6 +610,9 @@ ALTER TABLE `tag_implications` ALTER TABLE `user_blacklisted_tags` ADD CONSTRAINT `fk_user_bl_tags__user_id` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE; +ALTER TABLE `user_logs` + ADD CONSTRAINT `fk_user_logs__user_id` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE; + ALTER TABLE `user_records` ADD CONSTRAINT `fk_user_records__reported_by` FOREIGN KEY (`reported_by`) REFERENCES `users` (`id`) ON DELETE CASCADE, ADD CONSTRAINT `fk_user_records__user_id` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE; diff --git a/db/table_schema/production/user_logs.php b/db/table_schema/production/user_logs.php index 2aae0a8..d09bd26 100644 --- a/db/table_schema/production/user_logs.php +++ b/db/table_schema/production/user_logs.php @@ -1,34 +1,34 @@ + 0 => array ( - 'id' => + 'id' => array ( 'type' => 'int(11) unsigned', 'default' => NULL, ), - 'user_id' => + 'user_id' => array ( 'type' => 'int(11)', 'default' => NULL, ), - 'ip_addr' => + 'ip_addr' => array ( 'type' => 'varchar(46)', 'default' => NULL, ), - 'created_at' => + 'created_at' => array ( 'type' => 'datetime', 'default' => NULL, ), ), - 1 => + 1 => array ( - 'pri' => + 'pri' => array ( 0 => 'id', ), ), ) -; \ No newline at end of file +;