Commit fd129d2b authored by jlopez's avatar jlopez
Browse files

Merge branch 'develop' into 'master'

Develop

Closes #21

See merge request !14
parents a744e97a 653a1051
Pipeline #264 failed with stage
in 1 minute and 56 seconds
This diff is collapsed.
...@@ -2,3 +2,5 @@ wicopa.sql ...@@ -2,3 +2,5 @@ wicopa.sql
inc/conf/Conf.php inc/conf/Conf.php
*.swp *.swp
.docker/db/wicopa/* .docker/db/wicopa/*
.idea/
.vscode/
...@@ -10,10 +10,15 @@ Check [INSTALL](INSTALL.md) ...@@ -10,10 +10,15 @@ Check [INSTALL](INSTALL.md)
You can test it easily with Docker, using `docker-compose` ([See here](INSTALL.md#using-docker)). You can test it easily with Docker, using `docker-compose` ([See here](INSTALL.md#using-docker)).
# Documentation
You can generate documentation with `doxygen .doxygen`
# Roadmap # Roadmap
- Tags to search recipes ([see issue #11](https://gitlab.mbb.univ-montp2.fr/jlopez/wicopa/issues/11)), - Tags to search recipes ([see issue #11](https://gitlab.mbb.univ-montp2.fr/jlopez/wicopa/issues/11)),
- Loading and sharing recipes ([see issue #10](https://gitlab.mbb.univ-montp2.fr/jlopez/wicopa/issues/10)), - Loading and sharing recipes ([see issue #10](https://gitlab.mbb.univ-montp2.fr/jlopez/wicopa/issues/10)),
- Adding a custom local configuration to all recipes. Indeed, HPC administrator could occasionnally allow Singularity containers on their cluster. Thus, they usually need to edit the recipe to add custom contents, in order to rebuild the image ([see issue #7](https://gitlab.mbb.univ-montp2.fr/jlopez/wicopa/issues/7)), - Adding a custom local configuration to all recipes. Indeed, HPC administrator could occasionnally allow Singularity containers on their cluster. Thus, they usually need to edit the recipe to add custom contents, in order to rebuild the image ([see issue #7](https://gitlab.mbb.univ-montp2.fr/jlopez/wicopa/issues/7)),
- Convert the functions to retrieve specific language packages in pure PHP to be able to upgrade it directly from the admin panel ([see issue #2](https://gitlab.mbb.univ-montp2.fr/jlopez/wicopa/issues/2)), - Convert the functions to retrieve specific language packages in pure PHP to be able to upgrade it directly from the admin panel ([see issue #2](https://gitlab.mbb.univ-montp2.fr/jlopez/wicopa/issues/2)),
- adding a connection to a personal Gitlab/Github profile ([see issue #13](https://gitlab.mbb.univ-montp2.fr/jlopez/wicopa/issues/13)). - adding a connection to a personal Gitlab/Github profile ([see issue #13](https://gitlab.mbb.univ-montp2.fr/jlopez/wicopa/issues/13)).
\ No newline at end of file
...@@ -21,6 +21,7 @@ $id = NULL; ...@@ -21,6 +21,7 @@ $id = NULL;
$version = NULL; $version = NULL;
$manager = NULL; $manager = NULL;
$active = 0; $active = 0;
$vname = "";
if(isset($_POST['action'])) { if(isset($_POST['action'])) {
...@@ -64,19 +65,16 @@ if(isset($_POST['active'])) { ...@@ -64,19 +65,16 @@ if(isset($_POST['active'])) {
} }
} }
if(isset($_POST['vname'])) {
$vname = $_POST['vname'];
}
$distrib = new Distribution($id, $name, $version, $manager, $active, $vname);
$distrib = new Distribution($id, $name, $version, $manager, $active);
if($action == "create") { if($action == "create") {
$distrib->active = 1; $distrib->active = 1;
$distrib->escape($db); $distrib->escape($db);
$db->create($distrib);
if($db->checkTableExist($distrib->getFullName())) {
$db->create($distrib);
} else {
//TODO alert user.
}
} else if ($action == "update") { } else if ($action == "update") {
$distrib->escape($db); $distrib->escape($db);
$db->update($distrib); $db->update($distrib);
......
...@@ -72,16 +72,12 @@ if(isset($_POST['active'])) { ...@@ -72,16 +72,12 @@ if(isset($_POST['active'])) {
} }
} }
$section = new Section($id, $name, $visual, $active, $color, $arrangement); $section = new Section($id, $name, $visual, $active, $color, $arrangement, "");
if($action == "create") { if($action == "create") {
$section->active = 1; $section->active = 1;
$section->escape($db); $section->escape($db);
if($db->checkTableExist($name)) { $db->create($section);
$db->create($section);
} else {
//TODO alert user.
}
} else if ($action == "update") { } else if ($action == "update") {
$section->escape($db); $section->escape($db);
$db->update($section); $db->update($section);
......
...@@ -8,7 +8,7 @@ require_once "./dao/DBquery.php"; ...@@ -8,7 +8,7 @@ require_once "./dao/DBquery.php";
$db = new DBquery(); $db = new DBquery();
$type = "all"; $type = "all";
$author = NULL; $author = "";
$labels = array(); $labels = array();
$tags = array(); $tags = array();
$descriptions = array(); $descriptions = array();
...@@ -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;
}