Conditions | 3 |
Paths | 3 |
Total Lines | 23 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
42 | public static function saveRoleToDatabase($type) |
||
43 | { |
||
44 | // if $type is not 1 or 2 |
||
45 | if (!in_array($type, [1, 2])) { |
||
46 | return false; |
||
47 | } |
||
48 | |||
49 | $database = DatabaseFactory::getFactory()->getConnection(); |
||
50 | |||
51 | $query = $database->prepare("UPDATE users SET user_account_type = :new_type WHERE user_id = :user_id LIMIT 1"); |
||
52 | $query->execute(array( |
||
53 | ':new_type' => $type, |
||
54 | ':user_id' => Session::get('user_id') |
||
55 | )); |
||
56 | |||
57 | if ($query->rowCount() == 1) { |
||
58 | // set account type in session |
||
59 | Session::set('user_account_type', $type); |
||
60 | return true; |
||
61 | } |
||
62 | |||
63 | return false; |
||
64 | } |
||
65 | } |
||
66 |