Beispiel #1
0
 public static function addAction($user_id, $msg)
 {
     $user = null;
     $dnevnik_id = null;
     if (UsersDB::isSalesman(["uporabnik_id" => $user_id])) {
         $user = UsersDB::getSalesman(["id" => $user_id]);
         $dnevnik_id = $user["dnevnik_id"];
         if (!isset($user["dnevnik_id"])) {
             //                echo $user_id;
             //                echo $msg;
             //                a;
             $params["uporabnik_id"] = $user_id;
             $dnevnik_id = $params["dnevnik_id"] = self::insertDiary();
             UsersDB::updateSalesmanDiary($params);
         }
     } else {
         if (UsersDB::isAdmin(["uporabnik_id" => $user_id])) {
             $user = UsersDB::getAdmin(["id" => $user_id]);
             $dnevnik_id = $user["dnevnik_id"];
             if (!isset($user["dnevnik_id"])) {
                 $params["uporabnik_id"] = $user_id;
                 $dnevnik_id = $params["dnevnik_id"] = self::insertDiary();
                 UsersDB::updateAdminDiary($params);
             }
         } else {
             throw new InvalidArgumentException("Le administrator in prodajalec lahko dodajata vnose v dnevnik.");
         }
     }
     $actionParams["dnevnik_id"] = $dnevnik_id;
     $actionParams["opis"] = $msg;
     return parent::modify("INSERT INTO akcija (dnevnik_id, opis) " . " VALUES (:dnevnik_id, :opis)", $actionParams);
 }
Beispiel #2
0
 public static function check()
 {
     $data = filter_input_array(INPUT_POST, self::getLoginRules());
     if (self::checkValues($data)) {
         $username = $data["uname"];
         $result = UsersDB::getPassword(["uporabnisko_ime" => $username]);
         if ($result != null && password_verify($data["password"], $result["geslo"]) && UsersDB::isSalesman(["uporabnik_id" => $result["id"]]) == 1) {
             $_SESSION["active"] = TRUE;
             $_SESSION["role"] = "salesman";
             $_SESSION["id"] = $result["id"];
             $user = UsersDB::getSalesman(["id" => $_SESSION["id"]]);
             self::addActionToDiary($_SESSION["id"], "Prodajalec z id-jem " . $_SESSION["id"] . "se je prijavil v sistem");
             ViewHelper::redirect(BASE_URL);
         } else {
             unset($data["password"]);
             self::login($data);
         }
     } else {
         unset($data["password"]);
         self::login($data);
     }
 }