From 953bed6dbbcb0400b1d3f76cfa4912f0021e2e0e Mon Sep 17 00:00:00 2001 From: vbrazas Date: Wed, 27 Mar 2019 04:51:41 +0200 Subject: [PATCH] [WIP][#66] Skills remember behaviour stabilized --- helpers/RememberUserInfo.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/helpers/RememberUserInfo.php b/helpers/RememberUserInfo.php index f5f1a8b..4fc5828 100644 --- a/helpers/RememberUserInfo.php +++ b/helpers/RememberUserInfo.php @@ -36,7 +36,8 @@ private function rememberLevel() private function rememberXlogin() { $xlogins = new Xlogins(); - $xlogins = $xlogins->findOne(['xid' => $this->response['id']]); + $xlogins = $xlogins->findOne(['xid' => $this->response['id']]) + ?? $xlogins; $xlogins->attributes = $this->response; $xlogins->save(false); } @@ -47,10 +48,10 @@ private function rememberCursusUsersAndSkills() $skills = new Skills(); $cursus_users = $this->response['cursus_users']; - $skills = $skills->findOne([ 'xlogin' => $this->response['login'] ]); - foreach ($cursus_users as $cursus) { foreach ($cursus['skills'] as $skill) { + $skills = $skills->findOne([ 'xlogin' => $this->response['login'], 'skills_id' => $skill['id'] ]) + ?? $skills; $skill['skills_id'] = $skill['id']; // ???WTF $skill['skills_name'] = $skill['name']; // ???WTF $skill['skills_level'] = $skill['level']; // ???WTF @@ -58,7 +59,8 @@ private function rememberCursusUsersAndSkills() $skills->attributes = $skill; $skills->save(false); } - $cursusUsers = $cursusUsers->findOne(['cursus_users_id' => $cursus['id']]); + $cursusUsers = $cursusUsers->findOne(['cursus_users_id' => $cursus['id']]) + ?? $cursusUsers; $cursus['begin_at'] = date('Y-m-d H:i:s', strtotime($cursus['begin_at'])); // ! normilizing time format for mySQL $cursusUsers->attributes = $cursus; $cursusUsers->save(false);