diff --git a/config/Migrations/20220404070045_Knowledge.php b/config/Migrations/20220404070045_Knowledge.php new file mode 100644 index 000000000..e93512664 --- /dev/null +++ b/config/Migrations/20220404070045_Knowledge.php @@ -0,0 +1,56 @@ +execute($sql); + + $sql = "CREATE TABLE `knowledges` ( + `_id` int NOT NULL, + `uid` int UNSIGNED DEFAULT NULL, + `title` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL, + `text` text, + `status` smallint DEFAULT NULL, + `owner` int UNSIGNED DEFAULT NULL, + `created` datetime DEFAULT NULL, + `updated` datetime DEFAULT NULL, + `updated_by` int UNSIGNED DEFAULT NULL, + `currently_updated_by` int UNSIGNED DEFAULT NULL, + `currently_updated_start` datetime DEFAULT NULL + ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; + + CREATE TABLE `knowledges_categories` ( + `knowledge_uid` int UNSIGNED NOT NULL, + `category_id` int UNSIGNED NOT NULL + ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; + + CREATE TABLE `knowledges_skills` ( + `knowledge_uid` int UNSIGNED NOT NULL, + `skill_id` int UNSIGNED NOT NULL + ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; + + ALTER TABLE `knowledges` + ADD PRIMARY KEY (`_id`), + ADD KEY `uid` (`uid`); + + ALTER TABLE `knowledges_categories` + ADD PRIMARY KEY (`knowledge_uid`,`category_id`), + ADD KEY `knowledge_uid` (`knowledge_uid`), + ADD KEY `category_id` (`category_id`); + + ALTER TABLE `knowledges_skills` + ADD PRIMARY KEY (`knowledge_uid`,`skill_id`), + ADD KEY `knowledge_uid` (`knowledge_uid`), + ADD KEY `skill_id` (`skill_id`); + + ALTER TABLE `knowledges` + MODIFY `_id` int NOT NULL AUTO_INCREMENT; + COMMIT;"; + $this->execute($sql); + } +} diff --git a/config/Migrations/schema-dump-default.lock b/config/Migrations/schema-dump-default.lock index f5aa65f6a..8114799f5 100644 Binary files a/config/Migrations/schema-dump-default.lock and b/config/Migrations/schema-dump-default.lock differ diff --git a/config/routes.php b/config/routes.php index 5aad87c79..7740ab327 100644 --- a/config/routes.php +++ b/config/routes.php @@ -25,6 +25,7 @@ $routes->redirect('/initiativen', '/orte'); $routes->redirect('/splitter', '/seite/splitter'); $routes->redirect('/online-reparaturcafe', '/seite/online-reparaturcafe'); + $routes->redirect('/seite/reparaturwissen', '/reparaturwissen'); $routes->redirect('/repair-cafe-ulm', '/reparatur-cafe-ulm'); /* END custom redirects */ @@ -66,6 +67,8 @@ $routes->connect('/users/passwortAendern', ['controller'=>'users', 'action'=>'passwortAendern']); $routes->connect('/users/activate/*', ['controller'=>'users', 'action'=>'activate']); + $routes->connect('/reparaturwissen', ['controller'=>'knowledges', 'action'=>'all']); + $routes->connect('/users/profile/{id}', ['controller'=>'users', 'action'=>'publicProfile']) ->setPatterns(['id' => '\d+']) ->setPass(['id']); diff --git a/config/sql/database.sql b/config/sql/database.sql index 91e51fc6b..34c6dac3d 100644 --- a/config/sql/database.sql +++ b/config/sql/database.sql @@ -1,10 +1,10 @@ -- phpMyAdmin SQL Dump --- version 5.1.0 +-- version 5.1.3 -- https://www.phpmyadmin.net/ -- -- Host: localhost --- Erstellungszeit: 27. Okt 2021 um 09:33 --- Server-Version: 5.7.33-log +-- Erstellungszeit: 04. Apr 2022 um 09:22 +-- Server-Version: 8.0.28 -- PHP-Version: 8.0.1 SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; @@ -23,10 +23,10 @@ SET time_zone = "+00:00"; DROP TABLE IF EXISTS `blocked_workshop_slugs`; CREATE TABLE `blocked_workshop_slugs` ( - `id` int(11) NOT NULL, + `id` int NOT NULL, `url` varchar(255) DEFAULT NULL, - `status` tinyint(4) DEFAULT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `status` tinyint DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; -- -- Daten für Tabelle `blocked_workshop_slugs` @@ -76,11 +76,11 @@ INSERT INTO `blocked_workshop_slugs` (`id`, `url`, `status`) VALUES DROP TABLE IF EXISTS `blogs`; CREATE TABLE `blogs` ( - `id` int(8) NOT NULL, + `id` int NOT NULL, `name` varchar(255) DEFAULT NULL, `text` text, `url` varchar(255) DEFAULT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; -- -- Daten für Tabelle `blogs` @@ -98,13 +98,13 @@ INSERT INTO `blogs` (`id`, `name`, `text`, `url`) VALUES DROP TABLE IF EXISTS `brands`; CREATE TABLE `brands` ( - `id` int(8) NOT NULL, - `name` varchar(100) COLLATE utf8_bin DEFAULT NULL, - `status` smallint(6) DEFAULT NULL, - `owner` int(10) UNSIGNED DEFAULT NULL, + `id` int NOT NULL, + `name` varchar(100) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `status` smallint DEFAULT NULL, + `owner` int UNSIGNED DEFAULT NULL, `created` datetime DEFAULT NULL, `modified` datetime DEFAULT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8_bin; -- -- Daten für Tabelle `brands` @@ -1449,21 +1449,21 @@ INSERT INTO `brands` (`id`, `name`, `status`, `owner`, `created`, `modified`) VA DROP TABLE IF EXISTS `categories`; CREATE TABLE `categories` ( - `id` int(11) NOT NULL, - `name` varchar(100) COLLATE utf8_bin DEFAULT NULL, - `icon` varchar(255) COLLATE utf8_bin DEFAULT NULL, - `visible_on_platform` tinyint(4) UNSIGNED NOT NULL DEFAULT '1', + `id` int NOT NULL, + `name` varchar(100) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `icon` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `visible_on_platform` tinyint UNSIGNED NOT NULL DEFAULT '1', `carbon_footprint` decimal(6,2) UNSIGNED NOT NULL DEFAULT '0.00', `material_footprint` decimal(8,2) UNSIGNED NOT NULL DEFAULT '0.00', - `parent_id` int(11) DEFAULT NULL, - `ords_category_id` int(11) UNSIGNED DEFAULT NULL, - `lft` int(11) DEFAULT NULL, - `rght` int(11) DEFAULT NULL, - `status` smallint(6) DEFAULT NULL, - `owner` int(10) UNSIGNED DEFAULT NULL, + `parent_id` int DEFAULT NULL, + `ords_category_id` int UNSIGNED DEFAULT NULL, + `lft` int DEFAULT NULL, + `rght` int DEFAULT NULL, + `status` smallint DEFAULT NULL, + `owner` int UNSIGNED DEFAULT NULL, `created` datetime DEFAULT NULL, `modified` datetime DEFAULT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8_bin; -- -- Daten für Tabelle `categories` @@ -1887,12 +1887,12 @@ INSERT INTO `categories` (`id`, `name`, `icon`, `visible_on_platform`, `carbon_f DROP TABLE IF EXISTS `countries`; CREATE TABLE `countries` ( - `code` char(2) CHARACTER SET utf8 NOT NULL, - `iso3` varchar(3) COLLATE utf8_unicode_ci DEFAULT '', - `name_en` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, - `name_de` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, - `rank` int(4) DEFAULT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; + `code` char(2) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, + `iso3` varchar(3) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT '', + `name_en` varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL, + `name_de` varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL, + `rank` int DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8_unicode_ci; -- -- Daten für Tabelle `countries` @@ -2151,8 +2151,8 @@ INSERT INTO `countries` (`code`, `iso3`, `name_en`, `name_de`, `rank`) VALUES DROP TABLE IF EXISTS `events`; CREATE TABLE `events` ( - `_id` int(8) NOT NULL, - `uid` int(8) UNSIGNED DEFAULT NULL, + `_id` int NOT NULL, + `uid` int UNSIGNED DEFAULT NULL, `eventbeschreibung` text, `datumstart` date DEFAULT NULL, `uhrzeitstart` time DEFAULT NULL, @@ -2165,20 +2165,20 @@ CREATE TABLE `events` ( `land` varchar(99) DEFAULT NULL, `lat` double DEFAULT '0', `lng` double DEFAULT '0', - `use_custom_coordinates` tinyint(4) UNSIGNED NOT NULL DEFAULT '0', + `use_custom_coordinates` tinyint UNSIGNED NOT NULL DEFAULT '0', `image` varchar(150) DEFAULT NULL, `image_alt_text` varchar(255) DEFAULT NULL, - `status` smallint(6) DEFAULT NULL, - `owner` int(8) UNSIGNED DEFAULT NULL, + `status` smallint DEFAULT NULL, + `owner` int UNSIGNED DEFAULT NULL, `created` datetime DEFAULT NULL, `updated` datetime DEFAULT NULL, - `updated_by` int(8) UNSIGNED DEFAULT NULL, - `currently_updated_by` int(8) UNSIGNED DEFAULT NULL, + `updated_by` int UNSIGNED DEFAULT NULL, + `currently_updated_by` int UNSIGNED DEFAULT NULL, `currently_updated_start` datetime DEFAULT NULL, `lang` varchar(3) DEFAULT NULL, - `workshop_uid` int(8) UNSIGNED DEFAULT NULL, - `is_online_event` tinyint(4) UNSIGNED NOT NULL DEFAULT '0' -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `workshop_uid` int UNSIGNED DEFAULT NULL, + `is_online_event` tinyint UNSIGNED NOT NULL DEFAULT '0' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; -- -------------------------------------------------------- @@ -2188,9 +2188,9 @@ CREATE TABLE `events` ( DROP TABLE IF EXISTS `events_categories`; CREATE TABLE `events_categories` ( - `event_uid` int(8) UNSIGNED NOT NULL, - `category_id` int(8) UNSIGNED NOT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `event_uid` int UNSIGNED NOT NULL, + `category_id` int UNSIGNED NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; -- -------------------------------------------------------- @@ -2200,11 +2200,11 @@ CREATE TABLE `events_categories` ( DROP TABLE IF EXISTS `form_fields`; CREATE TABLE `form_fields` ( - `id` int(11) NOT NULL, + `id` int NOT NULL, `name` varchar(100) DEFAULT NULL, `identifier` varchar(255) DEFAULT NULL, - `status` int(11) NOT NULL DEFAULT '1' -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `status` int NOT NULL DEFAULT '1' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; -- -- Daten für Tabelle `form_fields` @@ -2226,13 +2226,13 @@ INSERT INTO `form_fields` (`id`, `name`, `identifier`, `status`) VALUES DROP TABLE IF EXISTS `form_field_options`; CREATE TABLE `form_field_options` ( - `id` int(11) NOT NULL, - `form_field_id` int(10) UNSIGNED DEFAULT NULL, - `value` int(10) UNSIGNED DEFAULT NULL, + `id` int NOT NULL, + `form_field_id` int UNSIGNED DEFAULT NULL, + `value` int UNSIGNED DEFAULT NULL, `name` varchar(100) DEFAULT NULL, - `rank` int(10) UNSIGNED DEFAULT NULL, - `status` tinyint(4) NOT NULL DEFAULT '1' -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `rank` int UNSIGNED DEFAULT NULL, + `status` tinyint NOT NULL DEFAULT '1' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; -- -- Daten für Tabelle `form_field_options` @@ -2276,11 +2276,11 @@ INSERT INTO `form_field_options` (`id`, `form_field_id`, `value`, `name`, `rank` DROP TABLE IF EXISTS `form_field_options_extra_infos`; CREATE TABLE `form_field_options_extra_infos` ( - `id` int(11) NOT NULL, - `form_field_options_id` int(10) UNSIGNED NOT NULL, + `id` int NOT NULL, + `form_field_options_id` int UNSIGNED NOT NULL, `repair_status` varchar(40) DEFAULT NULL, `repair_barrier_if_end_of_life` varchar(200) DEFAULT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; -- -- Daten für Tabelle `form_field_options_extra_infos` @@ -2314,9 +2314,9 @@ INSERT INTO `form_field_options_extra_infos` (`id`, `form_field_options_id`, `re DROP TABLE IF EXISTS `groups`; CREATE TABLE `groups` ( - `id` int(8) NOT NULL, + `id` int NOT NULL, `name` varchar(255) DEFAULT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; -- -- Daten für Tabelle `groups` @@ -2335,13 +2335,13 @@ INSERT INTO `groups` (`id`, `name`) VALUES DROP TABLE IF EXISTS `i18n`; CREATE TABLE `i18n` ( - `id` int(10) NOT NULL, + `id` int NOT NULL, `locale` varchar(6) NOT NULL, `model` varchar(255) NOT NULL, - `foreign_key` int(10) NOT NULL, + `foreign_key` int NOT NULL, `field` varchar(255) NOT NULL, `content` mediumtext -) ENGINE=InnoDB DEFAULT CHARSET=utf8; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; -- -------------------------------------------------------- @@ -2351,30 +2351,30 @@ CREATE TABLE `i18n` ( DROP TABLE IF EXISTS `info_sheets`; CREATE TABLE `info_sheets` ( - `_id` int(8) NOT NULL, - `uid` int(8) UNSIGNED DEFAULT NULL, - `visitor_age` int(10) DEFAULT NULL, + `_id` int NOT NULL, + `uid` int UNSIGNED DEFAULT NULL, + `visitor_age` int DEFAULT NULL, `visitor_gender` varchar(1) DEFAULT NULL, `device_name` varchar(255) DEFAULT NULL, - `device_age` int(10) UNSIGNED DEFAULT NULL, + `device_age` int UNSIGNED DEFAULT NULL, `defect_description` text, - `defect_found` tinyint(4) UNSIGNED DEFAULT NULL, - `defect_found_reason` tinyint(4) UNSIGNED DEFAULT NULL, - `repair_postponed_reason` tinyint(4) UNSIGNED DEFAULT NULL, - `no_repair_reason` tinyint(4) UNSIGNED DEFAULT NULL, - `device_must_not_be_used_anymore` tinyint(4) UNSIGNED DEFAULT NULL, + `defect_found` tinyint UNSIGNED DEFAULT NULL, + `defect_found_reason` tinyint UNSIGNED DEFAULT NULL, + `repair_postponed_reason` tinyint UNSIGNED DEFAULT NULL, + `no_repair_reason` tinyint UNSIGNED DEFAULT NULL, + `device_must_not_be_used_anymore` tinyint UNSIGNED DEFAULT NULL, `no_repair_reason_text` varchar(200) DEFAULT NULL, - `status` smallint(6) DEFAULT NULL, - `owner` int(8) UNSIGNED DEFAULT NULL, + `status` smallint DEFAULT NULL, + `owner` int UNSIGNED DEFAULT NULL, `created` datetime DEFAULT NULL, `updated` datetime DEFAULT NULL, - `updated_by` int(8) UNSIGNED DEFAULT NULL, - `currently_updated_by` int(8) UNSIGNED DEFAULT NULL, + `updated_by` int UNSIGNED DEFAULT NULL, + `currently_updated_by` int UNSIGNED DEFAULT NULL, `currently_updated_start` datetime DEFAULT NULL, - `event_uid` int(8) UNSIGNED DEFAULT NULL, - `category_id` int(10) DEFAULT NULL, - `brand_id` int(10) UNSIGNED DEFAULT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `event_uid` int UNSIGNED DEFAULT NULL, + `category_id` int DEFAULT NULL, + `brand_id` int UNSIGNED DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; -- -------------------------------------------------------- @@ -2384,9 +2384,54 @@ CREATE TABLE `info_sheets` ( DROP TABLE IF EXISTS `info_sheets_form_field_options`; CREATE TABLE `info_sheets_form_field_options` ( - `info_sheet_id` int(8) UNSIGNED NOT NULL, - `form_field_option_id` int(8) UNSIGNED NOT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `info_sheet_id` int UNSIGNED NOT NULL, + `form_field_option_id` int UNSIGNED NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; + +-- -------------------------------------------------------- + +-- +-- Tabellenstruktur für Tabelle `knowledges` +-- + +DROP TABLE IF EXISTS `knowledges`; +CREATE TABLE `knowledges` ( + `_id` int NOT NULL, + `uid` int UNSIGNED DEFAULT NULL, + `title` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL, + `text` text, + `status` smallint DEFAULT NULL, + `owner` int UNSIGNED DEFAULT NULL, + `created` datetime DEFAULT NULL, + `updated` datetime DEFAULT NULL, + `updated_by` int UNSIGNED DEFAULT NULL, + `currently_updated_by` int UNSIGNED DEFAULT NULL, + `currently_updated_start` datetime DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; + +-- -------------------------------------------------------- + +-- +-- Tabellenstruktur für Tabelle `knowledges_categories` +-- + +DROP TABLE IF EXISTS `knowledges_categories`; +CREATE TABLE `knowledges_categories` ( + `knowledge_uid` int UNSIGNED NOT NULL, + `category_id` int UNSIGNED NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; + +-- -------------------------------------------------------- + +-- +-- Tabellenstruktur für Tabelle `knowledges_skills` +-- + +DROP TABLE IF EXISTS `knowledges_skills`; +CREATE TABLE `knowledges_skills` ( + `knowledge_uid` int UNSIGNED NOT NULL, + `skill_id` int UNSIGNED NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; -- -------------------------------------------------------- @@ -2396,12 +2441,12 @@ CREATE TABLE `info_sheets_form_field_options` ( DROP TABLE IF EXISTS `metatags`; CREATE TABLE `metatags` ( - `id` int(10) UNSIGNED NOT NULL, - `object_uid` int(10) UNSIGNED DEFAULT NULL, + `id` int UNSIGNED NOT NULL, + `object_uid` int UNSIGNED DEFAULT NULL, `title` varchar(255) DEFAULT NULL, `description` varchar(255) DEFAULT NULL, `keywords` varchar(255) DEFAULT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; -- -------------------------------------------------------- @@ -2411,13 +2456,13 @@ CREATE TABLE `metatags` ( DROP TABLE IF EXISTS `newsletters`; CREATE TABLE `newsletters` ( - `id` int(255) NOT NULL, + `id` int NOT NULL, `email` varchar(255) DEFAULT NULL, `plz` varchar(8) DEFAULT NULL, `created` datetime DEFAULT NULL, `confirm` text NOT NULL, `unsub` text NOT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; -- -------------------------------------------------------- @@ -2427,13 +2472,13 @@ CREATE TABLE `newsletters` ( DROP TABLE IF EXISTS `ords_categories`; CREATE TABLE `ords_categories` ( - `id` int(11) NOT NULL, - `name` varchar(100) COLLATE utf8_bin DEFAULT NULL, - `status` smallint(6) DEFAULT NULL, - `owner` int(10) UNSIGNED DEFAULT NULL, + `id` int NOT NULL, + `name` varchar(100) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `status` smallint DEFAULT NULL, + `owner` int UNSIGNED DEFAULT NULL, `created` datetime DEFAULT NULL, `modified` datetime DEFAULT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8_bin; -- -- Daten für Tabelle `ords_categories` @@ -2489,25 +2534,25 @@ INSERT INTO `ords_categories` (`id`, `name`, `status`, `owner`, `created`, `modi DROP TABLE IF EXISTS `pages`; CREATE TABLE `pages` ( - `_id` int(8) NOT NULL, - `uid` int(8) UNSIGNED DEFAULT NULL, + `_id` int NOT NULL, + `uid` int UNSIGNED DEFAULT NULL, `name` varchar(255) DEFAULT NULL, `text` text, `url` varchar(255) DEFAULT NULL, - `status` smallint(6) DEFAULT NULL, - `owner` int(8) UNSIGNED DEFAULT NULL, + `status` smallint DEFAULT NULL, + `owner` int UNSIGNED DEFAULT NULL, `created` datetime DEFAULT NULL, `updated` datetime DEFAULT NULL, - `updated_by` int(8) UNSIGNED DEFAULT NULL, - `currently_updated_by` int(8) UNSIGNED DEFAULT NULL, + `updated_by` int UNSIGNED DEFAULT NULL, + `currently_updated_by` int UNSIGNED DEFAULT NULL, `currently_updated_start` datetime DEFAULT NULL, `lang` varchar(3) DEFAULT NULL, - `position` int(10) UNSIGNED DEFAULT NULL, + `position` int UNSIGNED DEFAULT NULL, `menu_type` varchar(255) NOT NULL DEFAULT 'no-menu', - `parent_uid` int(10) UNSIGNED DEFAULT NULL, - `lft` int(10) DEFAULT NULL, - `rght` int(10) DEFAULT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `parent_uid` int UNSIGNED DEFAULT NULL, + `lft` int DEFAULT NULL, + `rght` int DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; -- -- Daten für Tabelle `pages` @@ -2527,12 +2572,12 @@ INSERT INTO `pages` (`_id`, `uid`, `name`, `text`, `url`, `status`, `owner`, `cr DROP TABLE IF EXISTS `phinxlog`; CREATE TABLE `phinxlog` ( - `version` bigint(20) NOT NULL, + `version` bigint NOT NULL, `migration_name` varchar(100) DEFAULT NULL, `start_time` timestamp NULL DEFAULT NULL, `end_time` timestamp NULL DEFAULT NULL, `breakpoint` tinyint(1) NOT NULL DEFAULT '0' -) ENGINE=InnoDB DEFAULT CHARSET=utf8; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; -- -- Daten für Tabelle `phinxlog` @@ -2547,7 +2592,8 @@ INSERT INTO `phinxlog` (`version`, `migration_name`, `start_time`, `end_time`, ` (20210816093411, 'RenameTable', '2021-08-20 07:42:38', '2021-08-20 07:42:38', 0), (20210818075040, 'AddIso3CodeToCountries', '2021-08-20 07:42:38', '2021-08-20 07:42:39', 0), (20210927124302, 'GeoDataForUsers', '2021-10-27 07:33:29', '2021-10-27 07:33:30', 0), -(20220321084056, 'ChangeZeroDatesForMySql8', '2022-03-21 07:33:29', '2022-03-21 07:33:30', 0); +(20220321084056, 'ChangeZeroDatesForMySql8', '2022-03-21 07:33:29', '2022-03-21 07:33:30', 0), +(20220404070045, 'Knowledge', '2022-04-04 07:22:11', '2022-04-04 07:22:12', 0); -- -------------------------------------------------------- @@ -2557,21 +2603,21 @@ INSERT INTO `phinxlog` (`version`, `migration_name`, `start_time`, `end_time`, ` DROP TABLE IF EXISTS `photos`; CREATE TABLE `photos` ( - `_id` int(8) NOT NULL, - `uid` int(8) UNSIGNED DEFAULT NULL, - `object_uid` int(8) UNSIGNED DEFAULT NULL, + `_id` int NOT NULL, + `uid` int UNSIGNED DEFAULT NULL, + `object_uid` int UNSIGNED DEFAULT NULL, `object_type` enum('pages','posts','workshops','events') CHARACTER SET ascii COLLATE ascii_bin DEFAULT NULL, `name` varchar(255) DEFAULT NULL, `text` text NOT NULL, - `rank` int(8) UNSIGNED DEFAULT NULL, - `status` smallint(6) DEFAULT NULL, - `owner` int(8) UNSIGNED DEFAULT NULL, + `rank` int UNSIGNED DEFAULT NULL, + `status` smallint DEFAULT NULL, + `owner` int UNSIGNED DEFAULT NULL, `created` datetime DEFAULT NULL, `updated` datetime DEFAULT NULL, - `updated_by` int(8) UNSIGNED DEFAULT NULL, - `currently_updated_by` int(8) UNSIGNED DEFAULT NULL, + `updated_by` int UNSIGNED DEFAULT NULL, + `currently_updated_by` int UNSIGNED DEFAULT NULL, `currently_updated_start` datetime DEFAULT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; -- -------------------------------------------------------- @@ -2581,9 +2627,9 @@ CREATE TABLE `photos` ( DROP TABLE IF EXISTS `posts`; CREATE TABLE `posts` ( - `_id` int(8) NOT NULL, - `uid` int(8) UNSIGNED DEFAULT NULL, - `blog_id` int(8) UNSIGNED DEFAULT NULL, + `_id` int NOT NULL, + `uid` int UNSIGNED DEFAULT NULL, + `blog_id` int UNSIGNED DEFAULT NULL, `name` varchar(255) DEFAULT NULL, `text` text, `url` varchar(255) DEFAULT NULL, @@ -2592,14 +2638,14 @@ CREATE TABLE `posts` ( `image` varchar(150) DEFAULT NULL, `image_alt_text` varchar(255) DEFAULT NULL, `publish` date DEFAULT NULL, - `status` smallint(6) DEFAULT NULL, - `owner` int(8) UNSIGNED DEFAULT NULL, + `status` smallint DEFAULT NULL, + `owner` int UNSIGNED DEFAULT NULL, `created` datetime DEFAULT NULL, `updated` datetime DEFAULT NULL, - `updated_by` int(8) UNSIGNED DEFAULT NULL, - `currently_updated_by` int(8) UNSIGNED DEFAULT NULL, + `updated_by` int UNSIGNED DEFAULT NULL, + `currently_updated_by` int UNSIGNED DEFAULT NULL, `currently_updated_start` datetime DEFAULT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; -- -------------------------------------------------------- @@ -2609,9 +2655,9 @@ CREATE TABLE `posts` ( DROP TABLE IF EXISTS `roots`; CREATE TABLE `roots` ( - `uid` int(8) UNSIGNED NOT NULL, - `object_type` enum('pages','users','posts','workshops','events','coaches','votings','photos','info_sheets') CHARACTER SET ascii COLLATE ascii_bin DEFAULT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `uid` int UNSIGNED NOT NULL, + `object_type` enum('pages','users','posts','workshops','events','coaches','votings','photos','info_sheets','knowledges') CHARACTER SET ascii COLLATE ascii_bin DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; -- -- Daten für Tabelle `roots` @@ -2704,13 +2750,13 @@ INSERT INTO `roots` (`uid`, `object_type`) VALUES DROP TABLE IF EXISTS `skills`; CREATE TABLE `skills` ( - `id` int(11) NOT NULL, - `name` varchar(100) COLLATE utf8_bin DEFAULT NULL, - `status` smallint(6) DEFAULT NULL, - `owner` int(10) UNSIGNED DEFAULT NULL, + `id` int NOT NULL, + `name` varchar(100) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `status` smallint DEFAULT NULL, + `owner` int UNSIGNED DEFAULT NULL, `created` datetime DEFAULT NULL, `modified` datetime DEFAULT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8_bin; -- -------------------------------------------------------- @@ -2720,12 +2766,12 @@ CREATE TABLE `skills` ( DROP TABLE IF EXISTS `third_party_statistics`; CREATE TABLE `third_party_statistics` ( - `id` int(11) NOT NULL, - `category_id` int(10) UNSIGNED DEFAULT NULL, + `id` int NOT NULL, + `category_id` int UNSIGNED DEFAULT NULL, `date_from` date DEFAULT NULL, `date_to` date DEFAULT NULL, - `repaired` int(10) UNSIGNED DEFAULT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `repaired` int UNSIGNED DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; -- -------------------------------------------------------- @@ -2735,8 +2781,8 @@ CREATE TABLE `third_party_statistics` ( DROP TABLE IF EXISTS `users`; CREATE TABLE `users` ( - `_id` int(8) NOT NULL, - `uid` int(8) UNSIGNED DEFAULT NULL, + `_id` int NOT NULL, + `uid` int UNSIGNED DEFAULT NULL, `password` char(60) DEFAULT NULL, `email` varchar(255) DEFAULT NULL, `nick` varchar(25) DEFAULT NULL, @@ -2755,20 +2801,20 @@ CREATE TABLE `users` ( `feed_url` varchar(99) DEFAULT NULL, `facebook_username` varchar(99) DEFAULT NULL, `additional_contact` varchar(255) DEFAULT NULL, - `status` smallint(6) DEFAULT NULL, - `owner` int(8) UNSIGNED DEFAULT NULL, + `status` smallint DEFAULT NULL, + `owner` int UNSIGNED DEFAULT NULL, `created` datetime DEFAULT NULL, `updated` datetime DEFAULT NULL, - `updated_by` int(8) UNSIGNED DEFAULT NULL, - `currently_updated_by` int(8) UNSIGNED DEFAULT NULL, + `updated_by` int UNSIGNED DEFAULT NULL, + `currently_updated_by` int UNSIGNED DEFAULT NULL, `currently_updated_start` datetime DEFAULT NULL, `image` varchar(255) DEFAULT NULL, `image_alt_text` varchar(99) DEFAULT NULL, `lang` varchar(3) DEFAULT NULL, `private` text, `confirm` text, - `privacy_policy_accepted` tinyint(4) UNSIGNED NOT NULL DEFAULT '0' -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `privacy_policy_accepted` tinyint UNSIGNED NOT NULL DEFAULT '0' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; -- -------------------------------------------------------- @@ -2778,9 +2824,9 @@ CREATE TABLE `users` ( DROP TABLE IF EXISTS `users_categories`; CREATE TABLE `users_categories` ( - `user_uid` int(8) UNSIGNED NOT NULL, - `category_id` int(8) UNSIGNED NOT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `user_uid` int UNSIGNED NOT NULL, + `category_id` int UNSIGNED NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; -- -------------------------------------------------------- @@ -2790,9 +2836,9 @@ CREATE TABLE `users_categories` ( DROP TABLE IF EXISTS `users_groups`; CREATE TABLE `users_groups` ( - `user_uid` int(8) NOT NULL, - `group_id` int(8) NOT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `user_uid` int NOT NULL, + `group_id` int NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; -- -------------------------------------------------------- @@ -2802,9 +2848,9 @@ CREATE TABLE `users_groups` ( DROP TABLE IF EXISTS `users_skills`; CREATE TABLE `users_skills` ( - `user_uid` int(8) UNSIGNED NOT NULL, - `skill_id` int(8) UNSIGNED NOT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `user_uid` int UNSIGNED NOT NULL, + `skill_id` int UNSIGNED NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; -- -------------------------------------------------------- @@ -2814,11 +2860,11 @@ CREATE TABLE `users_skills` ( DROP TABLE IF EXISTS `users_workshops`; CREATE TABLE `users_workshops` ( - `user_uid` int(8) NOT NULL, - `workshop_uid` int(8) NOT NULL, + `user_uid` int NOT NULL, + `workshop_uid` int NOT NULL, `created` datetime DEFAULT NULL, `approved` datetime DEFAULT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; -- -------------------------------------------------------- @@ -2828,14 +2874,14 @@ CREATE TABLE `users_workshops` ( DROP TABLE IF EXISTS `worknews`; CREATE TABLE `worknews` ( - `id` int(255) NOT NULL, - `workshop_uid` int(8) NOT NULL, + `id` int NOT NULL, + `workshop_uid` int NOT NULL, `email` varchar(255) NOT NULL, `created` datetime DEFAULT NULL, `modified` datetime DEFAULT NULL, `confirm` text, `unsub` text -) ENGINE=InnoDB DEFAULT CHARSET=utf8; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; -- -------------------------------------------------------- @@ -2845,8 +2891,8 @@ CREATE TABLE `worknews` ( DROP TABLE IF EXISTS `workshops`; CREATE TABLE `workshops` ( - `_id` int(8) NOT NULL, - `uid` int(8) UNSIGNED DEFAULT NULL, + `_id` int NOT NULL, + `uid` int UNSIGNED DEFAULT NULL, `name` varchar(255) DEFAULT NULL, `text` text, `url` varchar(255) DEFAULT NULL, @@ -2863,23 +2909,23 @@ CREATE TABLE `workshops` ( `additional_contact` varchar(255) DEFAULT NULL, `image` varchar(150) DEFAULT NULL, `image_alt_text` varchar(255) DEFAULT NULL, - `use_custom_coordinates` tinyint(4) UNSIGNED NOT NULL DEFAULT '0', + `use_custom_coordinates` tinyint UNSIGNED NOT NULL DEFAULT '0', `lat` double DEFAULT '0', `lng` double DEFAULT '0', `traeger` varchar(255) DEFAULT NULL, `rechtsform` varchar(255) DEFAULT NULL, `rechtl_vertret` varchar(255) DEFAULT NULL, - `show_statistics` tinyint(3) UNSIGNED NOT NULL DEFAULT '1', - `status` smallint(6) DEFAULT NULL, - `owner` int(8) UNSIGNED DEFAULT NULL, + `show_statistics` tinyint UNSIGNED NOT NULL DEFAULT '1', + `status` smallint DEFAULT NULL, + `owner` int UNSIGNED DEFAULT NULL, `created` datetime DEFAULT NULL, `updated` datetime DEFAULT NULL, - `updated_by` int(8) UNSIGNED DEFAULT NULL, - `currently_updated_by` int(8) UNSIGNED DEFAULT NULL, + `updated_by` int UNSIGNED DEFAULT NULL, + `currently_updated_by` int UNSIGNED DEFAULT NULL, `currently_updated_start` datetime DEFAULT NULL, `lang` varchar(3) DEFAULT NULL, `other_users` text -) ENGINE=InnoDB DEFAULT CHARSET=utf8; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; -- -------------------------------------------------------- @@ -2889,9 +2935,9 @@ CREATE TABLE `workshops` ( DROP TABLE IF EXISTS `workshops_categories`; CREATE TABLE `workshops_categories` ( - `workshop_uid` int(8) UNSIGNED NOT NULL, - `category_id` int(8) UNSIGNED NOT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `workshop_uid` int UNSIGNED NOT NULL, + `category_id` int UNSIGNED NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; -- -- Indizes der exportierten Tabellen @@ -2990,6 +3036,29 @@ ALTER TABLE `info_sheets` ALTER TABLE `info_sheets_form_field_options` ADD PRIMARY KEY (`info_sheet_id`,`form_field_option_id`); +-- +-- Indizes für die Tabelle `knowledges` +-- +ALTER TABLE `knowledges` + ADD PRIMARY KEY (`_id`), + ADD KEY `uid` (`uid`); + +-- +-- Indizes für die Tabelle `knowledges_categories` +-- +ALTER TABLE `knowledges_categories` + ADD PRIMARY KEY (`knowledge_uid`,`category_id`), + ADD KEY `knowledge_uid` (`knowledge_uid`), + ADD KEY `category_id` (`category_id`); + +-- +-- Indizes für die Tabelle `knowledges_skills` +-- +ALTER TABLE `knowledges_skills` + ADD PRIMARY KEY (`knowledge_uid`,`skill_id`), + ADD KEY `knowledge_uid` (`knowledge_uid`), + ADD KEY `skill_id` (`skill_id`); + -- -- Indizes für die Tabelle `metatags` -- @@ -3119,137 +3188,143 @@ ALTER TABLE `workshops_categories` -- AUTO_INCREMENT für Tabelle `blocked_workshop_slugs` -- ALTER TABLE `blocked_workshop_slugs` - MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=36; + MODIFY `id` int NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=36; -- -- AUTO_INCREMENT für Tabelle `blogs` -- ALTER TABLE `blogs` - MODIFY `id` int(8) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3; + MODIFY `id` int NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3; -- -- AUTO_INCREMENT für Tabelle `brands` -- ALTER TABLE `brands` - MODIFY `id` int(8) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=1347; + MODIFY `id` int NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=1347; -- -- AUTO_INCREMENT für Tabelle `categories` -- ALTER TABLE `categories` - MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=801; + MODIFY `id` int NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=801; -- -- AUTO_INCREMENT für Tabelle `events` -- ALTER TABLE `events` - MODIFY `_id` int(8) NOT NULL AUTO_INCREMENT; + MODIFY `_id` int NOT NULL AUTO_INCREMENT; -- -- AUTO_INCREMENT für Tabelle `form_fields` -- ALTER TABLE `form_fields` - MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7; + MODIFY `id` int NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7; -- -- AUTO_INCREMENT für Tabelle `form_field_options` -- ALTER TABLE `form_field_options` - MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=29; + MODIFY `id` int NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=29; -- -- AUTO_INCREMENT für Tabelle `form_field_options_extra_infos` -- ALTER TABLE `form_field_options_extra_infos` - MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=19; + MODIFY `id` int NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=19; -- -- AUTO_INCREMENT für Tabelle `groups` -- ALTER TABLE `groups` - MODIFY `id` int(8) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=11; + MODIFY `id` int NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=11; -- -- AUTO_INCREMENT für Tabelle `i18n` -- ALTER TABLE `i18n` - MODIFY `id` int(10) NOT NULL AUTO_INCREMENT; + MODIFY `id` int NOT NULL AUTO_INCREMENT; -- -- AUTO_INCREMENT für Tabelle `info_sheets` -- ALTER TABLE `info_sheets` - MODIFY `_id` int(8) NOT NULL AUTO_INCREMENT; + MODIFY `_id` int NOT NULL AUTO_INCREMENT; + +-- +-- AUTO_INCREMENT für Tabelle `knowledges` +-- +ALTER TABLE `knowledges` + MODIFY `_id` int NOT NULL AUTO_INCREMENT; -- -- AUTO_INCREMENT für Tabelle `metatags` -- ALTER TABLE `metatags` - MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT; + MODIFY `id` int UNSIGNED NOT NULL AUTO_INCREMENT; -- -- AUTO_INCREMENT für Tabelle `newsletters` -- ALTER TABLE `newsletters` - MODIFY `id` int(255) NOT NULL AUTO_INCREMENT; + MODIFY `id` int NOT NULL AUTO_INCREMENT; -- -- AUTO_INCREMENT für Tabelle `ords_categories` -- ALTER TABLE `ords_categories` - MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=41; + MODIFY `id` int NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=41; -- -- AUTO_INCREMENT für Tabelle `pages` -- ALTER TABLE `pages` - MODIFY `_id` int(8) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=135; + MODIFY `_id` int NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=135; -- -- AUTO_INCREMENT für Tabelle `photos` -- ALTER TABLE `photos` - MODIFY `_id` int(8) NOT NULL AUTO_INCREMENT; + MODIFY `_id` int NOT NULL AUTO_INCREMENT; -- -- AUTO_INCREMENT für Tabelle `posts` -- ALTER TABLE `posts` - MODIFY `_id` int(8) NOT NULL AUTO_INCREMENT; + MODIFY `_id` int NOT NULL AUTO_INCREMENT; -- -- AUTO_INCREMENT für Tabelle `roots` -- ALTER TABLE `roots` - MODIFY `uid` int(8) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=27830; + MODIFY `uid` int UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=27830; -- -- AUTO_INCREMENT für Tabelle `skills` -- ALTER TABLE `skills` - MODIFY `id` int(11) NOT NULL AUTO_INCREMENT; + MODIFY `id` int NOT NULL AUTO_INCREMENT; -- -- AUTO_INCREMENT für Tabelle `third_party_statistics` -- ALTER TABLE `third_party_statistics` - MODIFY `id` int(11) NOT NULL AUTO_INCREMENT; + MODIFY `id` int NOT NULL AUTO_INCREMENT; -- -- AUTO_INCREMENT für Tabelle `users` -- ALTER TABLE `users` - MODIFY `_id` int(8) NOT NULL AUTO_INCREMENT; + MODIFY `_id` int NOT NULL AUTO_INCREMENT; -- -- AUTO_INCREMENT für Tabelle `worknews` -- ALTER TABLE `worknews` - MODIFY `id` int(255) NOT NULL AUTO_INCREMENT; + MODIFY `id` int NOT NULL AUTO_INCREMENT; -- -- AUTO_INCREMENT für Tabelle `workshops` -- ALTER TABLE `workshops` - MODIFY `_id` int(8) NOT NULL AUTO_INCREMENT; + MODIFY `_id` int NOT NULL AUTO_INCREMENT; COMMIT; diff --git a/plugins/Admin/src/Controller/KnowledgesController.php b/plugins/Admin/src/Controller/KnowledgesController.php new file mode 100644 index 000000000..a788112c6 --- /dev/null +++ b/plugins/Admin/src/Controller/KnowledgesController.php @@ -0,0 +1,115 @@ +Knowledge = $this->getTableLocator()->get('Knowledges'); + } + + public function insert() + { + $knowledge = [ + 'name' => 'Neuer Reparaturwissens-Beitrag von ' . $this->AppAuth->getUserName(), + ]; + $entity = $this->Knowledge->newEntity($knowledge); + $knowledge = $this->Knowledge->save($entity); + $this->AppFlash->setFlashMessage('Knowledge erfolgreich erstellt. UID: ' . $knowledge->uid); // uid for fixture + $this->redirect($this->getReferer()); + } + + public function edit($uid) + { + + if (empty($uid)) { + throw new NotFoundException; + } + + $knowledge = $this->Knowledge->find('all', [ + 'conditions' => [ + 'Knowledges.uid' => $uid, + 'Knowledges.status >= ' . APP_DELETED + ], + 'contain' => [ + 'Categories', + 'Skills', + ] + ])->first(); + + if (empty($knowledge)) { + throw new NotFoundException; + } + + $this->set('uid', $uid); + + $this->setReferer(); + $this->setIsCurrentlyUpdated($uid); + + if (!empty($this->request->getData())) { + + $this->Skill = $this->getTableLocator()->get('Skills'); + $this->request = $this->Skill->addSkills($this->request, $this->AppAuth, 'Knowledges'); + + $patchedEntity = $this->Knowledge->getPatchedEntityForAdminEdit($knowledge, $this->request->getData(), $this->useDefaultValidation); + + if (!($patchedEntity->hasErrors())) { + $patchedEntity = $this->patchEntityWithCurrentlyUpdatedFields($patchedEntity); + $this->saveObject($patchedEntity, $this->useDefaultValidation); + } else { + $knowledge = $patchedEntity; + } + } + + $this->set('knowledge', $knowledge); + + $this->Category = $this->getTableLocator()->get('Categories'); + $this->set('categories', $this->Category->getForDropdown(APP_ON)); + + $this->Skill = $this->getTableLocator()->get('Skills'); + $skillsForDropdown = $this->Skill->getForDropdown(false); + $this->set('skillsForDropdown', $skillsForDropdown); + + } + + public function index() + { + parent::index(); + + $conditions = [ + 'Knowledges.status > ' . APP_DELETED + ]; + $conditions = array_merge($this->conditions, $conditions); + + $query = $this->Knowledge->find('all', [ + 'conditions' => $conditions, + 'contain' => [ + 'Categories', + 'OwnerUsers', + 'Skills', + ] + ]); + + $objects = $this->paginate($query, [ + 'order' => [ + 'Knowledges.uid' => 'ASC' + ] + ]); + foreach($objects as $object) { + if ($object->owner_user) { + $object->owner_user->revertPrivatizeData(); + } + } + $this->set('objects', $objects->toArray()); + + $metaTags = [ + 'title' => 'Reparaturwissen' + ]; + $this->set('metaTags', $metaTags); + + } +} diff --git a/plugins/Admin/templates/Knowledges/edit.php b/plugins/Admin/templates/Knowledges/edit.php new file mode 100644 index 000000000..36a5453ed --- /dev/null +++ b/plugins/Admin/templates/Knowledges/edit.php @@ -0,0 +1,79 @@ +element('addScript', array('script' => + JS_NAMESPACE.".Helper.doCurrentlyUpdatedActions(".$isCurrentlyUpdated.");". + JS_NAMESPACE.".Helper.bindCancelButton(".$uid.");". + JS_NAMESPACE.".Helper.layoutEditButtons(); + ")); + echo $this->element('highlightNavi', ['main' => 'Reparaturwissen']); +?> + +
+ +
+ + element('heading', ['first' => 'Reparaturwissens-Beitrag bearbeiten']); ?> + + Form->create( + $knowledge, + [ + 'novalidate' => 'novalidate', + 'id' => 'knowledgeEditForm' + ] + ); + echo $this->Form->hidden('referer', ['value' => $referer]); + $this->Form->unlockField('referer'); + + echo $this->Form->control('Knowledges.title', ['label' => 'Titel']).'
'; + echo $this->Form->control('Knowledges.status', ['type' => 'select', 'options' => Configure::read('AppConfig.status')]).'
'; + + echo $this->element('metatagsFormfields', ['entity' => 'Knowledges']); + + + echo '
'; + echo 'Reparatur-Kenntnisse'; + echo $this->Form->control('Knowledges.categories._ids', [ + 'multiple' => 'checkbox', + 'label' => false, + ]); + echo '
'; + echo '
'; + + echo '
'; + echo 'Weitere Kenntnisse / Interessen'; + echo $this->Form->control('Knowledges.skills._ids', [ + 'multiple' => 'select', + 'data-tags' => true, + 'data-token-separators' => "[',']", + 'label' => false, + 'options' => $skillsForDropdown, + ]); + echo '
'; + + ?> +
+ + element('cancelAndSaveButton'); + ?> +
+ element('ckeditorEdit', [ + 'value' => $knowledge->text, + 'name' => 'Knowledges.text', + 'uid' => $uid, + 'objectType' => 'knowledges' + ] + ); + ?> +
+ + Form->end(); + ?> + +
+ +
\ No newline at end of file diff --git a/plugins/Admin/templates/Knowledges/index.php b/plugins/Admin/templates/Knowledges/index.php new file mode 100644 index 000000000..2aae33722 --- /dev/null +++ b/plugins/Admin/templates/Knowledges/index.php @@ -0,0 +1,20 @@ +element('highlightNavi', ['main' => 'Reparaturwissen']); + echo $this->element('list', [ + 'objects' => $objects, + 'heading' => 'Reparaturwissen', + 'newMethod' => ['url' => 'urlKnowledgeNew'], + 'editMethod' => ['url' => 'urlKnowledgeEdit'], + 'showMethod' => ['url' => 'urlKnowledgeDetail'], + 'fields' => [ + ['name' => 'uid', 'label' => 'UID'], + ['name' => 'title', 'label' => 'Titel'], + ['name' => 'Categories.name', 'type' => 'habtm', 'label' => 'Kategorien'], + ['name' => 'Skills.name', 'type' => 'habtm', 'label' => 'Kenntnisse'], + ['name' => 'owner_user.name', 'label' => 'Owner'], + ['name' => 'created', 'type' => 'datetime', 'label' => 'erstellt'], + ['name' => 'updated', 'type' => 'datetime', 'label' => 'geändert'], + ], + ], + ); +?> \ No newline at end of file diff --git a/plugins/Admin/templates/element/core/navi.php b/plugins/Admin/templates/element/core/navi.php index 613c89c25..64c5ceb7d 100644 --- a/plugins/Admin/templates/element/core/navi.php +++ b/plugins/Admin/templates/element/core/navi.php @@ -1,52 +1,58 @@ Html->createMenuEntry(array( - 'name' => 'Posts', - 'url' => '/admin/posts/index/?val-opt-2=1&key-opt-2=Posts.blog_id', + 'name' => 'Kategorien', + 'url' => '/admin/categories/index', 'level' => 'main' )); echo $this->Html->createMenuEntry(array( - 'name' => 'Seiten', - 'url' => '/admin/pages/index', + 'name' => 'Kenntnisse', + 'url' => '/admin/skills/index', 'level' => 'main' )); echo $this->Html->createMenuEntry(array( - 'name' => 'User', - 'url' => '/admin/users/index', + 'name' => 'Laufzettel', + 'url' => '/admin/info-sheets/index', 'level' => 'main' )); echo $this->Html->createMenuEntry(array( - 'name' => 'Termine', - 'url' => '/admin/events/index?val-status=1&key-status=Events.status', + 'name' => 'Marken', + 'url' => '/admin/brands/index?sort=status&direction=asc', 'level' => 'main' )); echo $this->Html->createMenuEntry(array( - 'name' => 'Rep-Inis', - 'url' => '/admin/workshops/index', + 'name' => 'Posts', + 'url' => '/admin/posts/index/?val-opt-2=1&key-opt-2=Posts.blog_id', 'level' => 'main' )); echo $this->Html->createMenuEntry(array( - 'name' => 'Kategorien', - 'url' => '/admin/categories/index', + 'name' => 'ORDS', + 'url' => '/admin/ordsCategories/index', 'level' => 'main' )); echo $this->Html->createMenuEntry(array( - 'name' => 'ORDS', - 'url' => '/admin/ordsCategories/index', + 'name' => 'Reparatur-Initiativen', + 'url' => '/admin/workshops/index', 'level' => 'main' )); echo $this->Html->createMenuEntry(array( - 'name' => 'Kenntnisse', - 'url' => '/admin/skills/index', + 'name' => 'Reparaturwissen', + 'url' => '/admin/knowledges/index', 'level' => 'main' )); echo $this->Html->createMenuEntry(array( - 'name' => 'Marken', - 'url' => '/admin/brands/index?sort=status&direction=asc', + 'name' => 'Seiten', + 'url' => '/admin/pages/index', 'level' => 'main' )); echo $this->Html->createMenuEntry(array( - 'name' => 'Laufzettel', - 'url' => '/admin/info-sheets/index', + 'name' => 'User', + 'url' => '/admin/users/index', + 'level' => 'main' +)); +echo $this->Html->createMenuEntry(array( + 'name' => 'Termine', + 'url' => '/admin/events/index?val-status=1&key-status=Events.status', 'level' => 'main' )); + ?> \ No newline at end of file diff --git a/plugins/Admin/templates/element/list.php b/plugins/Admin/templates/element/list.php index 856880850..efb147697 100644 --- a/plugins/Admin/templates/element/list.php +++ b/plugins/Admin/templates/element/list.php @@ -338,6 +338,7 @@ $showMethodCall = null; } break; + case 'urlKnowledgeDetail': case 'urlUserProfile': $showMethodCall = $this->Html->$showMethodUrl($object['uid']); break; diff --git a/plugins/Admin/webroot/css/admin.css b/plugins/Admin/webroot/css/admin.css index 19ff04898..bda280111 100644 --- a/plugins/Admin/webroot/css/admin.css +++ b/plugins/Admin/webroot/css/admin.css @@ -1,4 +1,4 @@ -#/* START admin layout änderungen */ +/* START admin layout änderungen */ body, html { font-family: 'Open Sans', arial, helvetica; font-size: 13px; @@ -26,7 +26,7 @@ h1 { padding: 1%; width: 98%; display: block; - margin-top: 90px; + margin-top: 110px; } a { @@ -43,6 +43,7 @@ a { display: block; margin: 0px auto; z-index: 7000; + border-bottom: 1px solid #dfdfdf; } #nav { @@ -73,7 +74,9 @@ div.admin #admin-list-form div.left { margin-top: -3px; margin-right: 10px; } - +div.admin div.list { + margin-top: -10px; +} div.admin div.list a.active { color: #4C4C4C; } diff --git a/plugins/Admin/webroot/css/admin.menu.css b/plugins/Admin/webroot/css/admin.menu.css index ed32ec4c4..85933f34a 100644 --- a/plugins/Admin/webroot/css/admin.menu.css +++ b/plugins/Admin/webroot/css/admin.menu.css @@ -26,8 +26,6 @@ #navadmin li a { color: #333; display: block; - background: #4D8EA2; - border-radius: 5px; } #navadmin span:after { @@ -48,7 +46,7 @@ width: 100%; padding: 0%; margin: 0px auto; - height: 40px; + height: 45px; float: left; } @@ -57,28 +55,35 @@ margin-top: 2px; display: block; float: left; + display: flex; + align-items: center; + justify-content: center; + height: 45px; + background-color: #efefef; + border-radius: 5px; } #navadmin>ul>li>a { padding: 10px 5px; display: block; - width: 77px; - font-size: 15px; + width: 74px; + font-size: 14px; text-align: center; font-weight: normal; - color: #fff; + word-break: break-all; } #navadmin>ul>li>a.two-lines { padding-top: 9px; padding-bottom:7px; } -#navadmin>ul>li:not ( :last-child ) > a { +#navadmin>ul>li:not(:last-child) > a { border-right: 1px solid transparent; } -#navadmin>ul>li:hover>a, #navadmin>ul:not ( :hover ) > li>a.active { - background-color: #ccc ! important; +#navadmin > ul > li:hover > a, +#navadmin > ul:not(:hover) > li a.active { + text-decoration: underline; } /* second level */ diff --git a/src/Controller/AppController.php b/src/Controller/AppController.php index 9a44b7ca8..305a87512 100644 --- a/src/Controller/AppController.php +++ b/src/Controller/AppController.php @@ -292,7 +292,7 @@ protected function stripTagsFromFields($entity, $modelName) } else if ($field == 'text') { // ckeditor feld heißt normalerweise 'text' $allowedTags = ALLOWED_TAGS_CKEDITOR_USER; - if ($this->AppAuth->isAdmin() && in_array($modelName, ['Post', 'Page'])) { + if ($this->AppAuth->isAdmin() && in_array($modelName, ['Post', 'Page', 'Knowledge'])) { $allowedTags = ALLOWED_TAGS_CKEDITOR_ADMIN; } $entity->$field = strip_tags($data, $allowedTags); diff --git a/src/Controller/KnowledgesController.php b/src/Controller/KnowledgesController.php new file mode 100644 index 000000000..b88b38d2c --- /dev/null +++ b/src/Controller/KnowledgesController.php @@ -0,0 +1,81 @@ +Knowledge = $this->getTableLocator()->get('Knowledges'); + } + + public function beforeFilter(EventInterface $event) + { + parent::beforeFilter($event); + $this->AppAuth->allow([ + 'all', + ]); + } + + public function all() + { + + $knowledges = $this->Knowledge->find('all', [ + 'conditions' => [ + 'Knowledges.status' => APP_ON + ], + 'contain' => [ + 'Skills', + 'Categories', + ], + 'order' => [ + 'Knowledges.title' => 'ASC', + ], + ])->toArray(); + + foreach($knowledges as &$knowledge) { + $categoryNames = Hash::extract($knowledge, 'categories.{n}.name'); + $itemSkillClasses = []; + foreach($categoryNames as $categoryName) { + $itemSkillClasses[] = StringComponent::slugify($categoryName); + } + $skills = Hash::extract($knowledge, 'skills.{n}.id'); + $itemSkillClasses = array_merge($itemSkillClasses, $skills); + $knowledge->itemSkillClasses = $itemSkillClasses; + } + $this->set('knowledges', $knowledges); + + $skillsForDropdown = []; + + $categories = Hash::extract($knowledges, '{n}.categories.{n}'); + foreach($categories as $category) { + $categorySlug = StringComponent::slugify($category['name']); + if (!isset($skillsForDropdown[$categorySlug])) { + $skillsForDropdown[$categorySlug] = $category['name']; + } + } + + $skills = Hash::extract($knowledges, '{n}.skills.{n}'); + foreach($skills as $skill) { + if (!isset($skillsForDropdown[$skill['id']])) { + $skillsForDropdown[$skill['id']] = $skill['name']; + } + } + asort($skillsForDropdown); + $this->set('skillsForDropdown', $skillsForDropdown); + + $metaTags = [ + 'title' => 'Reparaturwissen' + ]; + $this->set('metaTags', $metaTags); + + } + +} diff --git a/src/Controller/UsersController.php b/src/Controller/UsersController.php index b49b81035..35788cbd0 100644 --- a/src/Controller/UsersController.php +++ b/src/Controller/UsersController.php @@ -141,17 +141,7 @@ public function all() } $this->Skill = $this->getTableLocator()->get('Skills'); - $skillsForDropdown = $this->Skill->getForDropdown(false); - - $this->Category = $this->getTableLocator()->get('Categories'); - $categoriesForDropdown = $this->Category->getMainCategoriesForFrontend(); - $preparedCategoriesForDropdown = []; - foreach($categoriesForDropdown as $c) { - $slugifiedCategoryName = StringComponent::slugify($c->name); - $preparedCategoriesForDropdown[$slugifiedCategoryName] = $c->name; - } - $skillsForDropdown = $preparedCategoriesForDropdown + $skillsForDropdown; - asort($skillsForDropdown); + $skillsForDropdown = $this->Skill->getForDropdownIncludingCategories(false); $this->set('skillsForDropdown', $skillsForDropdown); $metaTags = [ @@ -325,7 +315,7 @@ private function _profil($user, $isMyProfile, $isEditMode) $this->request = $this->request->withData('Users.private', $private); $this->Skill = $this->getTableLocator()->get('Skills'); - $this->request = $this->Skill->addSkills($this->request, $this->AppAuth); + $this->request = $this->Skill->addSkills($this->request, $this->AppAuth, 'Users'); $user = $this->User->patchEntity($user, $this->request->getData(), ['validate' => 'UserEdit' . ($this->AppAuth->isAdmin() ? 'Admin' : 'User')]); if (!$user->hasErrors()) { @@ -595,7 +585,7 @@ public function register($userGroup=GROUPS_REPAIRHELPER) } $this->Skill = $this->getTableLocator()->get('Skills'); - $this->request = $this->Skill->addSkills($this->request, $this->AppAuth); + $this->request = $this->Skill->addSkills($this->request, $this->AppAuth, 'Users'); if ($this->request->getData('Users.i_want_to_receive_the_newsletter')) { $this->loadComponent('CptNewsletter'); diff --git a/src/Model/Table/KnowledgesTable.php b/src/Model/Table/KnowledgesTable.php new file mode 100644 index 000000000..7a51e10d9 --- /dev/null +++ b/src/Model/Table/KnowledgesTable.php @@ -0,0 +1,40 @@ +belongsTo('Blogs'); + $this->belongsToMany('Categories', [ + 'joinTable' => 'knowledges_categories', + 'foreignKey' => 'knowledge_uid', + 'targetForeignKey' => 'category_id', + 'dependent' => true, + ]); + $this->belongsToMany('Skills', [ + 'joinTable' => 'knowledges_skills', + 'foreignKey' => 'knowledge_uid', + 'targetForeignKey' => 'skill_id', + 'sort' => [ + 'Skills.name' => 'ASC' + ], + 'dependent' => true, + ]); + } + + public function validationAdmin(Validator $validator) + { + $validator->notEmptyString('title', 'Bitte gib einen Titel an.'); + $validator->minLength('title', 2, 'Bitte gib einen gültigen Titel an.'); + return $validator; + } + +} +?> \ No newline at end of file diff --git a/src/Model/Table/SkillsTable.php b/src/Model/Table/SkillsTable.php index 7d5d7adce..40ef1d86a 100644 --- a/src/Model/Table/SkillsTable.php +++ b/src/Model/Table/SkillsTable.php @@ -1,8 +1,10 @@ getData('Users.skills._ids'); + $skills = $request->getData($entity . '.skills._ids'); if (empty($skills)) { return $request; } @@ -54,7 +56,7 @@ public function addSkills($request, $appAuth) ]); } } - $request = $request->withData('Users.skills._ids', $skills); + $request = $request->withData($entity . '.skills._ids', $skills); $addedSkillIds = []; if (!empty($skillsToAdd)) { @@ -62,17 +64,29 @@ public function addSkills($request, $appAuth) foreach($addedSkills as $addedSkill) { $addedSkillIds[] = $addedSkill->id; } - $request = $request->withData('Users.skills._ids', array_merge($skills, $addedSkillIds)); + $request = $request->withData($entity . '.skills._ids', array_merge($skills, $addedSkillIds)); } return $request; } - /** - * @return array - */ - public function getForDropdown($includeOffline) + public function getForDropdownIncludingCategories($includeOffline): array + { + $skillsForDropdown = $this->getForDropdown(false); + $this->Category = FactoryLocator::get('Table')->get('Categories'); + $categoriesForDropdown = $this->Category->getMainCategoriesForFrontend(); + $preparedCategoriesForDropdown = []; + foreach($categoriesForDropdown as $c) { + $slugifiedCategoryName = StringComponent::slugify($c->name); + $preparedCategoriesForDropdown[$slugifiedCategoryName] = $c->name; + } + $skillsForDropdown = $preparedCategoriesForDropdown + $skillsForDropdown; + asort($skillsForDropdown); + return $skillsForDropdown; + } + + public function getForDropdown($includeOffline): array { $conditions = [ diff --git a/src/View/Helper/MyHtmlHelper.php b/src/View/Helper/MyHtmlHelper.php index 055c32878..8fb97240c 100644 --- a/src/View/Helper/MyHtmlHelper.php +++ b/src/View/Helper/MyHtmlHelper.php @@ -473,6 +473,18 @@ function urlPostEdit($uid) { function urlPostNew($type='') { return '/admin/posts/insert/'.$type; } + function urlKnowledgeNew() { + return '/admin/knowledges/insert'; + } + function urlKnowledgeEdit($uid) { + return '/admin/knowledges/edit/'.$uid; + } + function urlKnowledgeDetail($uid) { + return $this->urlKnowledges() . '/#' . $uid; + } + function urlKnowledges() { + return '/reparaturwissen'; + } public function getPostTypesWithPreview() { return [ 'neuigkeiten', diff --git a/templates/Knowledges/all.php b/templates/Knowledges/all.php new file mode 100644 index 000000000..f0ab4ff85 --- /dev/null +++ b/templates/Knowledges/all.php @@ -0,0 +1,83 @@ +element('highlightNavi', ['main' => 'Reparaturwissen']); + $this->element('addScript', ['script' => + JS_NAMESPACE.".Helper.initBoxToggle();". + JS_NAMESPACE.".Helper.initSkillFilterForKnowledges();". + JS_NAMESPACE.".Helper.bindKnowledgeFilterButtons(); + "]); +?> + +

+ +'; + echo ''; + echo $this->Form->control('skills', [ + 'type' => 'select', + 'label' => false, + 'empty' => 'Alle anzeigen', + 'options' => $skillsForDropdown, + ]); + echo ''; +?> +
+ +itemSkillClasses) .'">'; + + echo '
'; + + echo $knowledge->title; + + if ($appAuth->isAdmin()) { + echo $this->Html->link( + '', + $this->Html->urlKnowledgeEdit($knowledge->uid), + [ + 'class' => 'knowledge-edit-icon', + 'escape' => false, + ] + ); + } + + echo '
'; + + echo '
'; + + echo '
' . $knowledge->text . '
'; + + if(!empty($knowledge->categories)) { + echo '
'; + foreach($knowledge->categories as $category) { + echo ''; + } + echo '
'; + echo '
'; + } + + if (!empty($knowledge->skills)) { + foreach($knowledge->skills as $skill) { + echo ''.h($skill->name).''; + } + echo '
'; + } + echo $this->Html->link( + 'Permalink', + $this->Html->urlKnowledgeDetail($knowledge->uid), + [ + 'class' => 'knowledge-permalink', + 'escape' => false, + ] + ); + echo '
'; + + echo ''; + +} + +?> \ No newline at end of file diff --git a/templates/Users/all.php b/templates/Users/all.php index 8bf4fe1ec..bfb45aa9b 100644 --- a/templates/Users/all.php +++ b/templates/Users/all.php @@ -3,7 +3,7 @@ echo $this->element('highlightNavi', ['main' => 'Aktive']); $this->element('addScript', ['script' => " - MappedRepairEvents.Helper.initSkillFilter(); + MappedRepairEvents.Helper.initSkillFilterForUsers(); "]); ?> diff --git a/templates/element/highlightNavi.php b/templates/element/highlightNavi.php index 252db89bc..7ed1297e7 100644 --- a/templates/element/highlightNavi.php +++ b/templates/element/highlightNavi.php @@ -2,7 +2,7 @@ if (isset($main)) { $this->element('addScript', ['script' => " - var activeElement = $('#nav ul li a').filter(function() { + var activeElement = $('#nav ul li a, #navadmin ul li a').filter(function() { return $(this).text().toLowerCase() == '" . $main . "'.toLowerCase(); }); activeElement.addClass('active'); diff --git a/templates/element/widget.php b/templates/element/widget.php index 1046926be..9d7a9404e 100644 --- a/templates/element/widget.php +++ b/templates/element/widget.php @@ -1,6 +1,6 @@ element('addScript', ['script' => - JS_NAMESPACE.".Helper.initWidgetDocs(); + JS_NAMESPACE.".Helper.initBoxToggle(); "]); ?> diff --git a/templates/element/widgetDocs/event.php b/templates/element/widgetDocs/event.php index d85b3710c..c78e73a61 100644 --- a/templates/element/widgetDocs/event.php +++ b/templates/element/widgetDocs/event.php @@ -2,12 +2,10 @@ use Cake\Core\Configure; ?> -