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 <?php
namespace Ams_Tickets;
class Ticket{ class Ticket{
private $tId; private $tId;

View file

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

View file

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

View file

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

View file

@ -20,6 +20,9 @@ name = "Nom"
email = "Email" email = "Email"
action = "Action" action = "Action"
[createticket]
[error] [error]
title404 = "Pas<br/>trouvez!" title404 = "Pas<br/>trouvez!"
title403 = "Interdit!" 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){ public function getUsername($id){
global $cfg; global $cfg;

View file

@ -36,7 +36,7 @@ function add_user(){
function write_user($newUser){ function write_user($newUser){
//create salt here, because we want it to be the same on the web/server //create salt here, because we want it to be the same on the web/server
$hashpass = crypt($newUser["pass"], WebUsers::generateSALT()); $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 //Create the user on the shard + in case shard is offline put copy of query in query db
//returns: ok, shardoffline or liboffline //returns: ok, shardoffline or liboffline
$result = WebUsers::createUser($params); $result = WebUsers::createUser($params);
try{ try{
//make connection with web db and put it in there
global $cfg; global $cfg;
//make connection with web db and put it in there
$dbw = new DBLayer($cfg['db']['web']); $dbw = new DBLayer($cfg['db']['web']);
$dbw->execute("INSERT INTO ams_user (Login, Password, Email) VALUES (:name, :pass, :mail)",$params); $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) { }catch (PDOException $e) {
//go to error page or something, because can't access website db //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['user'] = $_POST["Username"];
$_SESSION['permission'] = $result['Permission']; $_SESSION['permission'] = $result['Permission'];
$_SESSION['id'] = $result['UId']; $_SESSION['id'] = $result['UId'];
print('id='); $_SESSION['ticket_user'] = Ticket_User::constr_ExternId($result['UId'],$cfg['db']['lib']);
print($_SESSION['id']);
//go back to the index page. //go back to the index page.
header( 'Location: index.php' ); header( 'Location: index.php' );
exit; exit;

View file

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