Commit 9a0ee480 authored by jlopez's avatar jlopez
Browse files

Add & generate doc

parent 5600e10e
This diff is collapsed.
...@@ -330,7 +330,7 @@ require_once "./inc/php/buildHeader.php"; ...@@ -330,7 +330,7 @@ require_once "./inc/php/buildHeader.php";
<script type="text/javascript"> <script type="text/javascript">
function showFileContainer(id ) { function showFileContainer(id) {
var value = FILE_CONTAINER[id]; var value = FILE_CONTAINER[id];
document.getElementById('valueContainerFile').value = value; document.getElementById('valueContainerFile').value = value;
......
...@@ -52,6 +52,11 @@ class DBquery ...@@ -52,6 +52,11 @@ class DBquery
return mysqli_real_escape_string($this->dbh, $value); return mysqli_real_escape_string($this->dbh, $value);
} }
/**
* Get all Distributions
*
* @return array
*/
public function getDistributions() { public function getDistributions() {
$sql = "SELECT * FROM `Distrib` ORDER BY `Distrib`.`name` ASC;"; $sql = "SELECT * FROM `Distrib` ORDER BY `Distrib`.`name` ASC;";
$result = mysqli_query($this->dbh, $sql); $result = mysqli_query($this->dbh, $sql);
...@@ -63,6 +68,14 @@ class DBquery ...@@ -63,6 +68,14 @@ class DBquery
return $results; return $results;
} }
/**
* Get distribution vname with name and version
*
* @param string $name The name of the distribution to find
* @param string $version The version of the distribution to find
*
* @return string
*/
public function getVName($name, $version) { public function getVName($name, $version) {
$sql = "SELECT vname FROM `Distrib` WHERE active = 1 AND `name`='$name' AND `version`='$version';"; $sql = "SELECT vname FROM `Distrib` WHERE active = 1 AND `name`='$name' AND `version`='$version';";
$result = mysqli_query($this->dbh, $sql); $result = mysqli_query($this->dbh, $sql);
...@@ -72,6 +85,11 @@ class DBquery ...@@ -72,6 +85,11 @@ class DBquery
return ""; return "";
} }
/**
* Get all active distributions
*
* @return array
*/
public function getActiveDistributions() { public function getActiveDistributions() {
$sql = "SELECT * FROM `Distrib` WHERE active = 1 ORDER BY `Distrib`.`name` ASC;"; $sql = "SELECT * FROM `Distrib` WHERE active = 1 ORDER BY `Distrib`.`name` ASC;";
$result = mysqli_query($this->dbh, $sql); $result = mysqli_query($this->dbh, $sql);
...@@ -83,6 +101,11 @@ class DBquery ...@@ -83,6 +101,11 @@ class DBquery
return $results; return $results;
} }
/**
* Get all full name from all active distributions
*
* @return array
*/
public function getActiveDistributionsFullName() { public function getActiveDistributionsFullName() {
$sql = "SELECT name,version,vname FROM `Distrib` WHERE active = 1 ORDER BY `Distrib`.`name` ASC;"; $sql = "SELECT name,version,vname FROM `Distrib` WHERE active = 1 ORDER BY `Distrib`.`name` ASC;";
$result = mysqli_query($this->dbh, $sql); $result = mysqli_query($this->dbh, $sql);
...@@ -93,6 +116,11 @@ class DBquery ...@@ -93,6 +116,11 @@ class DBquery
return $results; return $results;
} }
/**
* Get all managers
*
* @return array
*/
public function getManagers() { public function getManagers() {
$sql = "SELECT * FROM `Manager`;"; $sql = "SELECT * FROM `Manager`;";
$result = mysqli_query($this->dbh, $sql); $result = mysqli_query($this->dbh, $sql);
...@@ -104,6 +132,11 @@ class DBquery ...@@ -104,6 +132,11 @@ class DBquery
return $results; return $results;
} }
/**
* Get all users
*
* @return array
*/
public function getUsers() { public function getUsers() {
$sql = "SELECT * FROM `User`;"; $sql = "SELECT * FROM `User`;";
$result = mysqli_query($this->dbh, $sql); $result = mysqli_query($this->dbh, $sql);
...@@ -115,6 +148,13 @@ class DBquery ...@@ -115,6 +148,13 @@ class DBquery
return $results; return $results;
} }
/**
* Get grade with user login
*
* @param string $login The login of ther user
*
* @return array
*/
public function getGradeWithLogin($login) { public function getGradeWithLogin($login) {
$sql = "SELECT * FROM `User` WHERE `login` = '$login';"; $sql = "SELECT * FROM `User` WHERE `login` = '$login';";
$result = mysqli_query($this->dbh, $sql); $result = mysqli_query($this->dbh, $sql);
...@@ -127,6 +167,13 @@ class DBquery ...@@ -127,6 +167,13 @@ class DBquery
return $this->getLowerGrades(); return $this->getLowerGrades();
} }
/**
* Get all labels for specific grade
*
* @param $string $grade The grade to find the labels
*
* @return array
*/
public function getLabelsWithGrade($grade) { public function getLabelsWithGrade($grade) {
$labels = $this->getLabels(); $labels = $this->getLabels();
...@@ -146,6 +193,11 @@ class DBquery ...@@ -146,6 +193,11 @@ class DBquery
return $results; return $results;
} }
/**
* Get all grades
*
* @return array
*/
public function getGrades() { public function getGrades() {
$sql = "SELECT * FROM `Grade` ORDER BY `level` ASC;"; $sql = "SELECT * FROM `Grade` ORDER BY `level` ASC;";
$result = mysqli_query($this->dbh, $sql); $result = mysqli_query($this->dbh, $sql);
...@@ -157,6 +209,11 @@ class DBquery ...@@ -157,6 +209,11 @@ class DBquery
return $results; return $results;
} }
/**
* Get all configs
*
* @return array
*/
public function getConfigs() { public function getConfigs() {
$sql = "SELECT * FROM `Config` WHERE 1;"; $sql = "SELECT * FROM `Config` WHERE 1;";
$result = mysqli_query($this->dbh, $sql); $result = mysqli_query($this->dbh, $sql);
...@@ -168,6 +225,13 @@ class DBquery ...@@ -168,6 +225,13 @@ class DBquery
return $results; return $results;
} }
/**
* Gel all active config with type
*
* @param string $type The type of the config
*
* @return array
*/
public function getActiveConfigsWithType($type) { public function getActiveConfigsWithType($type) {
$sql = "SELECT * FROM `Config` WHERE `type`='$type' AND `active` = 1;"; $sql = "SELECT * FROM `Config` WHERE `type`='$type' AND `active` = 1;";
$result = mysqli_query($this->dbh, $sql); $result = mysqli_query($this->dbh, $sql);
...@@ -179,6 +243,13 @@ class DBquery ...@@ -179,6 +243,13 @@ class DBquery
return $results; return $results;
} }
/**
* Get grade with this ID
*
* @param int $ID The ID of the grade
*
* @return Grade
*/
public function getGradeWithId($ID) { public function getGradeWithId($ID) {
$sql = "SELECT * FROM `Grade` WHERE `ID` = '$ID';"; $sql = "SELECT * FROM `Grade` WHERE `ID` = '$ID';";
$result = mysqli_query($this->dbh, $sql); $result = mysqli_query($this->dbh, $sql);
...@@ -190,6 +261,11 @@ class DBquery ...@@ -190,6 +261,11 @@ class DBquery
return $results; return $results;
} }
/**
* Get lower grade
*
* @return Grade
*/
public function getLowerGrades() { public function getLowerGrades() {
$sql = "SELECT * FROM `Grade` ORDER BY `level` DESC LIMIT 1;"; $sql = "SELECT * FROM `Grade` ORDER BY `level` DESC LIMIT 1;";
$result = mysqli_query($this->dbh, $sql); $result = mysqli_query($this->dbh, $sql);
...@@ -201,6 +277,11 @@ class DBquery ...@@ -201,6 +277,11 @@ class DBquery
return $results; return $results;
} }
/**
* Get max grade
*
* @return Grade
*/
public function getMaxGrades() { public function getMaxGrades() {
$sql = "SELECT * FROM `Grade` ORDER BY `level` ASC LIMIT 1;"; $sql = "SELECT * FROM `Grade` ORDER BY `level` ASC LIMIT 1;";
$result = mysqli_query($this->dbh, $sql); $result = mysqli_query($this->dbh, $sql);
...@@ -211,7 +292,12 @@ class DBquery ...@@ -211,7 +292,12 @@ class DBquery
} }
return $results; return $results;
} }
/**
* Get all public tags
*
* @return array
*/
public function getAllPublicTags() { public function getAllPublicTags() {
$sql = "SELECT tags FROM `Container` WHERE tags <> '' AND visibility = 1;"; $sql = "SELECT tags FROM `Container` WHERE tags <> '' AND visibility = 1;";
$result = mysqli_query($this->dbh, $sql); $result = mysqli_query($this->dbh, $sql);
...@@ -222,6 +308,18 @@ class DBquery ...@@ -222,6 +308,18 @@ class DBquery
return $results; return $results;
} }
/**
* Get all containers
*
* @param string $type
* @param string $author
* @param array $labels
* @param array $tags
* @param string $description
*
* @return array
*
*/
public function getContainers($type, $author, $labels, $tags, $descriptions) { public function getContainers($type, $author, $labels, $tags, $descriptions) {
$sql = "SELECT * FROM `Container`"; $sql = "SELECT * FROM `Container`";
...@@ -277,6 +375,13 @@ class DBquery ...@@ -277,6 +375,13 @@ class DBquery
return $results; return $results;
} }
/**
* Get container with this id
*
* @param int $id The id of the container
*
* @return Container
*/
public function getContainerWithId($id) { public function getContainerWithId($id) {
$sql = "SELECT * FROM `Container` WHERE `ID` = '$id';"; $sql = "SELECT * FROM `Container` WHERE `ID` = '$id';";
$result = mysqli_query($this->dbh, $sql); $result = mysqli_query($this->dbh, $sql);
...@@ -288,6 +393,11 @@ class DBquery ...@@ -288,6 +393,11 @@ class DBquery
return $results; return $results;
} }
/**
* Get all labels
*
* @return array
*/
public function getLabels() { public function getLabels() {
$sql = "SELECT * FROM `Label`;"; $sql = "SELECT * FROM `Label`;";
$result = mysqli_query($this->dbh, $sql); $result = mysqli_query($this->dbh, $sql);
...@@ -299,6 +409,14 @@ class DBquery ...@@ -299,6 +409,14 @@ class DBquery
return $results; return $results;
} }
/**
* Get label with this id
*
* @param int $id The id of the label
*
* @return Label
*
*/
public function getLabelsWithId($id) { public function getLabelsWithId($id) {
$sql = "SELECT * FROM `Label` WHERE `ID` = $id;"; $sql = "SELECT * FROM `Label` WHERE `ID` = $id;";
$result = mysqli_query($this->dbh, $sql); $result = mysqli_query($this->dbh, $sql);
...@@ -310,12 +428,13 @@ class DBquery ...@@ -310,12 +428,13 @@ class DBquery
return $results; return $results;
} }
public function getMaxSectionArrangement() { /**
$sql = "SELECT MAX(arrangement) FROM `Section` WHERE `Section`.`parent` IS NULL;"; * Get all labels for Container
*
* @param int $id The id of the container
} *
* @return array
*/
public function getLabelWithContainerId($id) { public function getLabelWithContainerId($id) {
$sql = "SELECT * FROM `ContainerLabel` WHERE `containerId` = $id"; $sql = "SELECT * FROM `ContainerLabel` WHERE `containerId` = $id";
$result = mysqli_query($this->dbh, $sql); $result = mysqli_query($this->dbh, $sql);
...@@ -327,6 +446,11 @@ class DBquery ...@@ -327,6 +446,11 @@ class DBquery
return $results; return $results;
} }
/**
* Get all active Section who is parent
*
* @return array
*/
public function getAllActiveSectionParent() { public function getAllActiveSectionParent() {
$sql = "SELECT * FROM `Section` WHERE `Section`.`parent` IS NULL AND active = 1 ORDER BY `Section`.`arrangement` ASC;"; $sql = "SELECT * FROM `Section` WHERE `Section`.`parent` IS NULL AND active = 1 ORDER BY `Section`.`arrangement` ASC;";
$result = mysqli_query($this->dbh, $sql); $result = mysqli_query($this->dbh, $sql);
...@@ -338,6 +462,11 @@ class DBquery ...@@ -338,6 +462,11 @@ class DBquery
return $results; return $results;
} }
/**
* Get all section parent
*
* @return array
*/
public function getAllSectionParent() { public function getAllSectionParent() {
$sql = "SELECT * FROM `Section` WHERE `Section`.`parent` IS NULL ORDER BY `Section`.`arrangement` ASC;"; $sql = "SELECT * FROM `Section` WHERE `Section`.`parent` IS NULL ORDER BY `Section`.`arrangement` ASC;";
$result = mysqli_query($this->dbh, $sql); $result = mysqli_query($this->dbh, $sql);
...@@ -349,6 +478,13 @@ class DBquery ...@@ -349,6 +478,13 @@ class DBquery
return $results; return $results;
} }
/**
* Get all active Section for specific parent
*
* @param string $parent The name of the parent
*
* @return array
*/
public function getSectionWhithParent($parent) { public function getSectionWhithParent($parent) {
$sql = "SELECT * FROM `Section` WHERE `Section`.`parent` = '$parent' AND active = 1 ORDER BY `Section`.`arrangement` ASC;"; $sql = "SELECT * FROM `Section` WHERE `Section`.`parent` = '$parent' AND active = 1 ORDER BY `Section`.`arrangement` ASC;";
$result = mysqli_query($this->dbh, $sql); $result = mysqli_query($this->dbh, $sql);
...@@ -359,6 +495,12 @@ class DBquery ...@@ -359,6 +495,12 @@ class DBquery
return $results; return $results;
} }
/**
*
* Get all name of the section who have a parent
*
* @return array
*/
public function getNameSectionWhithParent($parent) { public function getNameSectionWhithParent($parent) {
$sql = "SELECT name FROM `Section` WHERE `Section`.`parent` = '$parent' AND active = 1 ORDER BY `Section`.`arrangement` ASC;"; $sql = "SELECT name FROM `Section` WHERE `Section`.`parent` = '$parent' AND active = 1 ORDER BY `Section`.`arrangement` ASC;";
$result = mysqli_query($this->dbh, $sql); $result = mysqli_query($this->dbh, $sql);
...@@ -369,6 +511,13 @@ class DBquery ...@@ -369,6 +511,13 @@ class DBquery
return $results; return $results;
} }
/**
* Get all Section for specific parent
*
* @param string $parent The name of the parent
*
* @return array
*/
public function getAllSectionWhithParent($parent) { public function getAllSectionWhithParent($parent) {
$sql = "SELECT * FROM `Section` WHERE `Section`.`parent` = '$parent' ORDER BY `Section`.`arrangement` ASC;"; $sql = "SELECT * FROM `Section` WHERE `Section`.`parent` = '$parent' ORDER BY `Section`.`arrangement` ASC;";
$result = mysqli_query($this->dbh, $sql); $result = mysqli_query($this->dbh, $sql);
...@@ -380,6 +529,12 @@ class DBquery ...@@ -380,6 +529,12 @@ class DBquery
return $results; return $results;
} }
/**
* Get all action section
*
* @return array
*/
public function getActiveSection() { public function getActiveSection() {
$sql = "SELECT * FROM `Section` WHERE active = 1 ORDER BY `Section`.`arrangement` ASC;"; $sql = "SELECT * FROM `Section` WHERE active = 1 ORDER BY `Section`.`arrangement` ASC;";
$result = mysqli_query($this->dbh, $sql); $result = mysqli_query($this->dbh, $sql);
...@@ -391,6 +546,11 @@ class DBquery ...@@ -391,6 +546,11 @@ class DBquery
return $results; return $results;
} }
/**
* Get all Section
*
* @return array
*/
public function getSection() { public function getSection() {
$sql = "SELECT * FROM `Section` ORDER BY `Section`.`arrangement` ASC;"; $sql = "SELECT * FROM `Section` ORDER BY `Section`.`arrangement` ASC;";
$result = mysqli_query($this->dbh, $sql); $result = mysqli_query($this->dbh, $sql);
...@@ -402,6 +562,13 @@ class DBquery ...@@ -402,6 +562,13 @@ class DBquery
return $results; return $results;
} }
/**
* Get number packages For Distribution
*
* @deprecated
*
* @return int
*/
public function getNumberPackage($name) { public function getNumberPackage($name) {
$sql = "SELECT COUNT(*) as number FROM `$name` WHERE 1 "; $sql = "SELECT COUNT(*) as number FROM `$name` WHERE 1 ";
...@@ -413,6 +580,11 @@ class DBquery ...@@ -413,6 +580,11 @@ class DBquery
return 0; return 0;
} }
/**
* Get all packages
*
* @deprecated
*/
public function getPackages($distrib, $filter, $patternName, $patternDescription, $limit) { public function getPackages($distrib, $filter, $patternName, $patternDescription, $limit) {
if($patternName and $patternDescription) { if($patternName and $patternDescription) {
$sql = "SELECT * FROM `$distrib` WHERE `name` LIKE '%$filter%' or `description` LIKE '%$filter%' ORDER BY CASE WHEN `name` LIKE '$filter' THEN 1 WHEN `name` LIKE '$filter%' THEN 2 WHEN `name` LIKE '%$filter' THEN 4 ELSE 3 END LIMIT $limit;"; $sql = "SELECT * FROM `$distrib` WHERE `name` LIKE '%$filter%' or `description` LIKE '%$filter%' ORDER BY CASE WHEN `name` LIKE '$filter' THEN 1 WHEN `name` LIKE '$filter%' THEN 2 WHEN `name` LIKE '%$filter' THEN 4 ELSE 3 END LIMIT $limit;";
...@@ -435,6 +607,12 @@ class DBquery ...@@ -435,6 +607,12 @@ class DBquery
return $results; return $results;
} }
/**
* Check if table exist in database
*
* @param string $name The name of the table
*
*/
public function checkTableExist($name) { public function checkTableExist($name) {
$sql = "SELECT count(*) as number FROM information_schema.TABLES WHERE (TABLE_SCHEMA = 'wicopa') AND (TABLE_NAME = '$name')"; $sql = "SELECT count(*) as number FROM information_schema.TABLES WHERE (TABLE_SCHEMA = 'wicopa') AND (TABLE_NAME = '$name')";
...@@ -451,6 +629,9 @@ class DBquery ...@@ -451,6 +629,9 @@ class DBquery
} }
} }
/**
* Create ofject in database
*/
public function create($object) { public function create($object) {
$result = mysqli_query($this->dbh, $object->getInsert()); $result = mysqli_query($this->dbh, $object->getInsert());
...@@ -464,7 +645,9 @@ class DBquery ...@@ -464,7 +645,9 @@ class DBquery
} }
/**
* Update ofject in database
*/
public function update($object) { public function update($object) {
$result = mysqli_query($this->dbh, $object->getUpdate()); $result = mysqli_query($this->dbh, $object->getUpdate());
if($result) { if($result) {
...@@ -476,6 +659,9 @@ class DBquery ...@@ -476,6 +659,9 @@ class DBquery
} }
/**
* Delete ofject in database
*/
public function delete($object) { public function delete($object) {
$result = mysqli_query($this->dbh, $object->getDelete()); $result = mysqli_query($this->dbh, $object->getDelete());
if($result) { if($result) {
...@@ -486,6 +672,9 @@ class DBquery ...@@ -486,6 +672,9 @@ class DBquery
} }
} }
/**
* Check admin pass
*/
public function verifyPass($username, $pass) { public function verifyPass($username, $pass) {
if($username == "admin" && Conf::dbEncodePass($pass)==Conf::$KK) { if($username == "admin" && Conf::dbEncodePass($pass)==Conf::$KK) {
return 1; return 1;
...@@ -499,6 +688,11 @@ class DBquery ...@@ -499,6 +688,11 @@ class DBquery
} }
} }
/**
* Get number docker container
*
* @return int
*/
public function getNumberDockerContainer() { public function getNumberDockerContainer() {
$sql = 'SELECT count(*) as docker FROM `Container` WHERE type = "Docker" AND visibility = 1;'; $sql = 'SELECT count(*) as docker FROM `Container` WHERE type = "Docker" AND visibility = 1;';
$result = mysqli_query($this->dbh, $sql); $result = mysqli_query($this->dbh, $sql);
...@@ -513,6 +707,11 @@ class DBquery ...@@ -513,6 +707,11 @@ class DBquery
return 0; return 0;
} }
/**
* Get number singularity container
*
* @return int
*/
public function getNumberSingularityContainer() { public function getNumberSingularityContainer() {
$sql = 'SELECT count(*) as singularity FROM `Container` WHERE type = "Singularity" AND visibility = 1'; $sql = 'SELECT count(*) as singularity FROM `Container` WHERE type = "Singularity" AND visibility = 1';
$result = mysqli_query($this->dbh, $sql); $result = mysqli_query($this->dbh, $sql);
......