/** * creates a new 'ticket' entry. * this method will use the object's attributes for creating a new 'ticket' entry in the database. */ public function create() { $dbl = new DBLayer("lib"); $this->tId = $dbl->executeReturnId("ticket", array('Title' => $this->title, 'Status' => $this->status, 'Queue' => $this->queue, 'Ticket_Category' => $this->ticket_category, 'Author' => $this->author, 'Priority' => $this->priority), array('Timestamp' => 'now()')); }
//require the pages that are being needed. require '../../config.php'; require '../../../ams_lib/libinclude.php'; ini_set("display_errors", true); error_reporting(E_ALL); //var used to access the DB; global $cfg; try { //SETUP THE WWW DB $dbs = new DBLayer("shard"); $sql = "SELECT * FROM user"; $statement = $dbs->executeWithoutParams($sql); $users = $statement->fetchAll(); foreach ($users as $user) { //add user to web $dbw = new DBLayer("web"); if (!$dbw->execute("SELECT * FROM ams_user WHERE Login = :name", array('name' => $user['Login']))->rowCount()) { $query = "INSERT INTO ams_user (Login, Password, Email, Language) VALUES (:name, :pass, :mail, :lang)"; global $DEFAULT_LANGUAGE; $vars = array('name' => $user['Login'], 'pass' => $user['Password'], 'mail' => $user['Email'], 'lang' => $DEFAULT_LANGUAGE); $id = $dbw->executeReturnId($query, $vars); $dbl = new DBLayer("lib"); $query = "INSERT INTO `ticket_user` (Permission, ExternId) VALUES (1, :id)"; $vars = array('id' => $id); $dbl->execute($query, $vars); } } print "The users were imported! "; } catch (PDOException $e) { print "There was an error while creating the admin account! "; }
/** * creates a new 'tickt_content' entry. * this method will use the object's attributes for creating a new 'ticket_content' entry in the database. */ public function create() { $dbl = new DBLayer("lib"); $this->tContentId = $dbl->executeReturnId("ticket_content", array('Content' => $this->content)); }
/** * creates a webuser. * it will set the language matching to the language cookie setting and add it to the www/CMS's DB. * @param $name the username * @param $pass the unhashed password * @param $mail the email address */ public static function createWebuser($name, $pass, $mail) { //register account with the correct language (check if cookie is already set)! if (isset($_COOKIE['Language'])) { $lang = $_COOKIE['Language']; } else { global $DEFAULT_LANGUAGE; $lang = $DEFAULT_LANGUAGE; } $values = array('name' => $name, 'pass' => $pass, 'mail' => $mail, 'lang' => $lang); try { $dbw = new DBLayer("web"); return $dbw->executeReturnId("INSERT INTO ams_user (Login, Password, Email, Language) VALUES (:name, :pass, :mail, :lang)", $values); } catch (PDOException $e) { //ERROR: the web DB is offline } }
/** * creates a new 'ticket_reply' entry. * this method will use the object's attributes for creating a new 'ticket_reply' entry in the database (the now() function will create the timestamp). */ public function create() { $dbl = new DBLayer("lib"); $this->tReplyId = $dbl->executeReturnId("ticket_reply", array('Ticket' => $this->ticket, 'Content' => $this->content, 'Author' => $this->author, 'Hidden' => $this->hidden), array('Timestamp' => 'now()')); }