Skip to content

Commit

Permalink
[WIP][unitfactoryAlumni#66] Skills remember behaviour stabilized
Browse files Browse the repository at this point in the history
  • Loading branch information
vbrazas committed Apr 6, 2019
1 parent 66ecfa2 commit 953bed6
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions helpers/RememberUserInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -47,18 +48,19 @@ 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

$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);
Expand Down

0 comments on commit 953bed6

Please sign in to comment.