summaryrefslogtreecommitdiff
path: root/Core/Functions/func_info.php
blob: 89b168841aadf55e98aac2770a14e3b808d6e06d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php

// ############################################################################
// #                                                                          #
// # Description: Fonction de modifications des informations de l'utilisateur #
// #              par ID                                                      #
// #                                                                          #
// ############################################################################

function info_update_user_infos($userInfos, $userId, $userStatus) {
    $dbuser   = new DbUser;
    $dbsearch = new DbSearch;

    switch ($userStatus) {
        case 1:
            $isPro = true;
            break;
        default:
            $isPro = false;
            break;
    }

    if ($isPro) {
        $userJobs = $dbsearch->get_pro_job_by_proid($userId);
        $userJobsId = [];
        for ($i = 0; $i < count($userJobs); $i++) {
            array_push($userJobsId, $userJobs[$i]["jobCategoryId"]);
        }
        $dbuser->update_user_infos($userInfos, $userId, $isPro, $userJobsId);
    } else {
        $dbuser->update_user_infos($userInfos, $userId, $isPro);
    }
    
    // Redirection vers message avec l'index du message à afficher.
    $message = ["infosUpdate", "success"];
    $_SESSION["message"] = $message;
    header("Location: /Template/message.php");
    die();
}

?>