This commit is contained in:
Némunaire 2013-10-10 05:52:48 +02:00
parent b64257a80e
commit 38ed722d15
3 changed files with 145 additions and 149 deletions

View file

@ -4,18 +4,17 @@ if(!defined('ONYX')) exit;
class Exercice class Exercice
{ {
var $id=null; var $id = null;
var $theme; var $theme;
var $require; var $require;
var $level; var $level;
var $points; var $points;
var $statement; var $statement;
var $files; var $files = array();
var $keys; var $keys = array();
function Exercice($id=null) function Exercice($id=null)
{ {
if (!empty($id)) if (!empty($id))
{ {
$db = new BDD(); $db = new BDD();
@ -78,13 +77,12 @@ class Exercice
$format = $key['format']; $format = $key['format'];
$value = $key['value']; $value = $key['value'];
if (isset($key['id'])) if (isset($key['id']))
$kid = $key['id']; $kid = intval($key['id']);
else else
$kid = NULL; $kid = 0;
$db->escape($format); $db->escape($format);
$db->escape($value); $db->escape($value);
$db->escape($kid);
if (empty($kid)) if (empty($kid))
{ {
@ -142,15 +140,18 @@ class Exercice
function add_key($format, $value) function add_key($format, $value)
{ {
$key = ["format" => $format, "value" => $value]; $this->keys[] = array(
if (isset($key)) "format" => $format,
$this->keys[] = $key; "value" => $value
);
} }
function add_file($path, $name, $sha1) function add_file($path, $name, $sha1)
{ {
$file = ["path" => $path, "name" => $name, "sha1" => $sha1]; $this->files[] = array(
if (isset($file)) "path" => $path,
$this->files[] = $file; "name" => $name,
"sha1" => $sha1
);
} }
} }

View file

@ -4,8 +4,7 @@ if(!defined('ONYX')) exit;
class Theme class Theme
{ {
var $id = null;
var $id=null;
var $title; var $title;
function Theme($id=null) function Theme($id=null)

View file

@ -2,7 +2,8 @@
if(!defined('ONYX')) exit; if(!defined('ONYX')) exit;
class User { class User
{
var $id = null; var $id = null;
var $firstname; var $firstname;
var $lastname; var $lastname;
@ -12,7 +13,8 @@ class User {
var $points = null; var $points = null;
var $nb_themes = null; var $nb_themes = null;
function User ($id=null) { function User ($id=null)
{
if (!empty($id)) if (!empty($id))
{ {
$db = new BDD(); $db = new BDD();
@ -64,33 +66,27 @@ class User {
return ($aff == 1); return ($aff == 1);
} }
function get_id() function get_id() {
{
return $this->id; return $this->id;
} }
function get_firstname() function get_firstname() {
{
return $this->firstname; return $this->firstname;
} }
function get_lastname() function get_lastname() {
{
return $this->lastname; return $this->lastname;
} }
function get_username() function get_username() {
{
return $this->username; return $this->username;
} }
function get_company() function get_company() {
{
return $this->company; return $this->company;
} }
function get_auth_level() function get_auth_level() {
{
return $this->auth_level; return $this->auth_level;
} }
@ -105,12 +101,12 @@ class User {
LEFT OUTER JOIN solved s ON e.id = s.id_exercice LEFT OUTER JOIN solved s ON e.id = s.id_exercice
WHERE s.id_user = " . intval($this->id) . " WHERE s.id_user = " . intval($this->id) . "
GROUP BY s.id_user"); GROUP BY s.id_user");
$db->deconnexion();
if (!empty($res)) if (!empty($res))
{ {
$this->points = $res['sum_points']; $this->points = $res['sum_points'];
} }
$db->deconnexion();
} }
} }