From 4b37a90187646898c6df78c0e51806bee61c6a68 Mon Sep 17 00:00:00 2001 From: Christine Slotty Date: Tue, 28 Jul 2020 17:45:46 +0200 Subject: [PATCH] missing table; fixes/features --- skeema/gradido_community/community_profiles.sql | 8 ++++++++ skeema/gradido_community/state_users.sql | 1 + src/Controller/AppController.php | 12 ++++++++---- .../TransactionCreationsController.php | 16 +++++++++++----- src/Model/Entity/StateUser.php | 1 + 5 files changed, 29 insertions(+), 9 deletions(-) create mode 100644 skeema/gradido_community/community_profiles.sql diff --git a/skeema/gradido_community/community_profiles.sql b/skeema/gradido_community/community_profiles.sql new file mode 100644 index 000000000..88e0bdf5a --- /dev/null +++ b/skeema/gradido_community/community_profiles.sql @@ -0,0 +1,8 @@ +CREATE TABLE `community_profiles` ( + `id` INT NOT NULL AUTO_INCREMENT, + `state_user_id` INT NOT NULL, + `profile_img` LONGBLOB NULL, + `profile_desc` VARCHAR(2000) NULL, + PRIMARY KEY (`id`), + FOREIGN KEY (`state_user_id`) REFERENCES `state_users`(`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; \ No newline at end of file diff --git a/skeema/gradido_community/state_users.sql b/skeema/gradido_community/state_users.sql index fb6b4263c..6d462dff6 100644 --- a/skeema/gradido_community/state_users.sql +++ b/skeema/gradido_community/state_users.sql @@ -7,6 +7,7 @@ CREATE TABLE `state_users` ( `first_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, `last_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, `username` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `disabled` tinyint() DEFAULT 0, PRIMARY KEY (`id`), UNIQUE KEY `public_key` (`public_key`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; diff --git a/src/Controller/AppController.php b/src/Controller/AppController.php index 95f02e00e..1113f78e0 100644 --- a/src/Controller/AppController.php +++ b/src/Controller/AppController.php @@ -199,12 +199,15 @@ class AppController extends Controller if ($stateUserQuery->count() == 1) { $stateUser = $stateUserQuery->first(); if ($stateUser->first_name != $json['user']['first_name'] || - $stateUser->last_name != $json['user']['last_name'] || - //$stateUser->username != $json['user']['username'] || - // -> throws error - $stateUser->email != $json['user']['email']) { + $stateUser->last_name != $json['user']['last_name'] || + $stateUser->disabled != $json['user']['disabled'] || + //$stateUser->username != $json['user']['username'] || + // -> throws error + $stateUser->email != $json['user']['email'] + ) { $stateUser->first_name = $json['user']['first_name']; $stateUser->last_name = $json['user']['last_name']; + $stateUser->disabled = $json['user']['disabled']; //$stateUser->username = $json['user']['username']; $stateUser->email = $json['user']['email']; if (!$stateUserTable->save($stateUser)) { @@ -222,6 +225,7 @@ class AppController extends Controller $newStateUser->public_key = $public_key_bin; $newStateUser->first_name = $json['user']['first_name']; $newStateUser->last_name = $json['user']['last_name']; + $newStateUser->disabled = $json['user']['disabled']; //$newStateUser->username = $json['user']['username']; $newStateUser->email = $json['user']['email']; if (!$stateUserTable->save($newStateUser)) { diff --git a/src/Controller/TransactionCreationsController.php b/src/Controller/TransactionCreationsController.php index 44cb0928b..c926e050d 100644 --- a/src/Controller/TransactionCreationsController.php +++ b/src/Controller/TransactionCreationsController.php @@ -242,11 +242,17 @@ class TransactionCreationsController extends AppController ->find('all') ->select(['id', 'first_name', 'last_name', 'email']) ->order(['first_name', 'last_name']) - ->where(['OR' => [ - 'LOWER(first_name)' => strtolower($requestData['searchText']), - 'LOWER(last_name)' => strtolower($requestData['searchText']), - 'LOWER(email)' => strtolower($requestData['searchText']) - ]]) + ->where( + ['AND' => [ + 'disabled' => 0, + 'OR' => [ + 'LOWER(first_name)' => strtolower($requestData['searchText']), + 'LOWER(last_name)' => strtolower($requestData['searchText']), + 'LOWER(email)' => strtolower($requestData['searchText']) + ] + ] + ] + ) ->contain(['TransactionCreations' => [ 'fields' => [ 'TransactionCreations.amount', diff --git a/src/Model/Entity/StateUser.php b/src/Model/Entity/StateUser.php index 224e7d143..5fac7cda7 100644 --- a/src/Model/Entity/StateUser.php +++ b/src/Model/Entity/StateUser.php @@ -36,6 +36,7 @@ class StateUser extends Entity 'email' => true, 'first_name' => true, 'last_name' => true, + 'disabled' => true, 'username' => true, 'index' => true, 'state_group' => true,