Skip to content

Commit

Permalink
bugeja fixattu
Browse files Browse the repository at this point in the history
  • Loading branch information
Redande committed May 3, 2015
1 parent 2b750d0 commit ccc3045
Show file tree
Hide file tree
Showing 11 changed files with 47 additions and 19 deletions.
8 changes: 0 additions & 8 deletions app/controllers/hello_world_controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,6 @@ public static function sandbox(){
'name' => 'a'
));
$errors = $validatortest->errors();

Kint::dump($errors);

// $NP = Hahmo::find(1);
// $hahmot = Hahmo::all();

// Kint::dump($hahmot);
// Kint::dump($NP);
}

public static function hahmolista(){
Expand Down
6 changes: 2 additions & 4 deletions app/controllers/user_controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@ public static function handle_login(){

$user = User::authenticate($params['username'], $params['password']);

Kint::dump($user);

if(!$user){
View::make('user/login.html', array('error' => 'Incorrect username or password!', 'username' => $params['username']));
View::make('user/login.html', array('message' => 'Incorrect username or password!', 'username' => $params['username']));
}else{
$_SESSION['user'] = $user->id;

Expand All @@ -33,7 +31,7 @@ public static function handle_signup(){
));

$user->save();
Redirect::to('/', array('message' => 'Welcome ' . $user->username . '!'));
Redirect::to('/', array('message' => 'Welcome ' . $user->username . '! Note that you have to log in before you can use any features.'));
}

public static function logout(){
Expand Down
7 changes: 7 additions & 0 deletions app/models/role.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,15 @@ public function update(){
}

public function destroy(){
self::deleteHeroes();

$query = DB::connection()->prepare('DELETE FROM Role WHERE id = :id');

$query->execute(array('id' => $this->id));
}

public function deleteHeroes(){
$query = DB::connection()->prepare('DELETE FROM JoinTable WHERE role = :role');
$query->execute(array('role' => $this->id));
}
}
2 changes: 1 addition & 1 deletion app/models/user.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public static function authenticate($username, $password){
$query = DB::connection()->prepare('SELECT * FROM Account WHERE username = :username AND password = :password LIMIT 1', array('username' => $username, 'password' => $password));
$query->execute(array('username' => $username, 'password' => $password));
$row = $query->fetch();
Kint::dump($row);

if($row){
$user = new User(array(
'id' => $row['id'],
Expand Down
8 changes: 8 additions & 0 deletions app/views/hero/heroview.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@
{% block content %}

{% import "macros/forms.html" as forms %}


{% if message %}
<div class="alert alert-success">
{{message}}
</div>
{% endif %}

<header>
<h1>{{hero.name}}</h1>
</header>
Expand Down
6 changes: 6 additions & 0 deletions app/views/hero/list.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
{% extends "base.html" %}
{% block content %}

{% if message %}
<div class="alert alert-success">
{{message}}
</div>
{% endif %}

<h1>Heroes</h1>

<ol>
Expand Down
6 changes: 4 additions & 2 deletions app/views/plans/frontpage.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
{% extends "base.html" %}
{% block content %}

<div class="alert alert-success">
{% if message %}
<div class="alert alert-success">
{{message}}
</div>
</div>
{% endif %}

<header>
<h1>Dota2 Database</h1>
Expand Down
6 changes: 6 additions & 0 deletions app/views/role/list.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
{% extends "base.html" %}
{% block content %}

{% if message %}
<div class="alert alert-success">
{{message}}
</div>
{% endif %}

<h1>Roles</h1>

<ol>
Expand Down
7 changes: 7 additions & 0 deletions app/views/role/roleview.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@

{% import "macros/forms.html" as forms %}

{% if message %}
<div class="alert alert-success">
{{message}}
</div>
{% endif %}


<header>
<h1>{{role.name}}</h1>
</header>
Expand Down
8 changes: 5 additions & 3 deletions app/views/user/login.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
{% extends "base.html" %}
{% block content %}

<div class="alert alert-success">
{{error}}
</div>
{% if message %}
<div class="alert alert-success">
{{message}}
</div>
{% endif %}

<h1>Log in</h1>

Expand Down
2 changes: 1 addition & 1 deletion lib/base_controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public static function get_user_logged_in(){

public static function check_logged_in(){
if(!isset($_SESSION['user'])){
Redirect::to('/login', array('error' => 'You have to log in to use that feature!'));
Redirect::to('/login', array('message' => 'You have to log in to use that feature!'));
}
}

Expand Down

0 comments on commit ccc3045

Please sign in to comment.