createticket template done + when registering: create ticket_user + when login make session object ticket_user

This commit is contained in:
Quitta 2013-07-06 18:27:25 +02:00
parent 69dd053660
commit 8d46a9988a
9 changed files with 25 additions and 14 deletions

View file

@ -1,5 +1,4 @@
<?php
namespace Ams_Tickets;
class Ticket{
private $tId;

View file

@ -1,5 +1,4 @@
<?php
namespace Ams_Tickets;
class Ticket_Category{
@ -34,9 +33,8 @@ class Ticket_Category{
$dbl = new DBLayer($this->db);
$statement = $dbl->execute("SELECT * FROM ticket_category WHERE TCategoryId=:id", array('id' => $id));
$row = $statement->fetch();
$instance->tCategoryId = $row['TCategoryId'];
$instance->name = $row['Name'];
return $instance;
$this->tCategoryId = $row['TCategoryId'];
$this->name = $row['Name'];
}
//update private data to DB.

View file

@ -1,6 +1,4 @@
<?php
namespace Ams_Tickets;
class Ticket_User{
private $tUserId;
@ -46,7 +44,7 @@ class Ticket_User{
//return constructed element based on ExternId
public static function constr_ExternId( $id, $db_data ) {
$instance = new self($db_data);
$dbl = new DBLayer($this->db);
$dbl = new DBLayer($instance->db);
$statement = $dbl->execute("SELECT * FROM ticket_user WHERE ExternId=:id", array('id' => $id));
$row = $statement->fetch();
$instance->tUserId = $row['TUserId'];

View file

@ -20,6 +20,9 @@ name = "Name"
email = "Email"
action = "Action"
[createticket]
[error]
title404 = "Not<br/>Found!"
title403 = "Forbidden!"

View file

@ -20,6 +20,9 @@ name = "Nom"
email = "Email"
action = "Action"
[createticket]
[error]
title404 = "Pas<br/>trouvez!"
title403 = "Interdit!"

View file

@ -50,7 +50,15 @@ class WebUsers extends Users{
}
}
public function getId($username){
global $cfg;
$dbw = new DBLayer($cfg['db']['web']);
$statement = $dbw->execute("SELECT * FROM ams_user WHERE Login=:username", array('username' => $username));
$row = $statement->fetch();
return $row['UId'];
}
public function getUsername($id){
global $cfg;

View file

@ -36,7 +36,7 @@ function add_user(){
function write_user($newUser){
//create salt here, because we want it to be the same on the web/server
$hashpass = crypt($newUser["pass"], WebUsers::generateSALT());
@ -49,12 +49,14 @@ function write_user($newUser){
//Create the user on the shard + in case shard is offline put copy of query in query db
//returns: ok, shardoffline or liboffline
$result = WebUsers::createUser($params);
try{
//make connection with web db and put it in there
global $cfg;
//make connection with web db and put it in there
$dbw = new DBLayer($cfg['db']['web']);
$dbw->execute("INSERT INTO ams_user (Login, Password, Email) VALUES (:name, :pass, :mail)",$params);
ticket_user::createTicketUser( WebUsers::getId($newUser["name"]), 1, $cfg['db']['lib'] );
}catch (PDOException $e) {
//go to error page or something, because can't access website db

View file

@ -11,8 +11,8 @@ function login(){
$_SESSION['user'] = $_POST["Username"];
$_SESSION['permission'] = $result['Permission'];
$_SESSION['id'] = $result['UId'];
print('id=');
print($_SESSION['id']);
$_SESSION['ticket_user'] = Ticket_User::constr_ExternId($result['UId'],$cfg['db']['lib']);
//go back to the index page.
header( 'Location: index.php' );
exit;

View file

@ -24,7 +24,7 @@ function settings(){
//Sanitize Data
$result['current_mail'] = filter_var($result['current_mail'], FILTER_SANITIZE_EMAIL);
$result['Login'] = filter_var($result['Login'], FILTER_SANITIZE_STRING);
//$result['Login'] = filter_var($result['Login'], FILTER_SANITIZE_STRING);
$result['FirstName'] = filter_var($result['FirstName'], FILTER_SANITIZE_STRING);
$result['LastName'] = filter_var($result['LastName'], FILTER_SANITIZE_STRING);
$result['Country'] = filter_var($result['Country'], FILTER_SANITIZE_STRING);