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
inc/conf/Conf.php
*.swp
.docker/db/wicopa/*
.idea/
.vscode/
......@@ -10,6 +10,11 @@ Check [INSTALL](INSTALL.md)
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
- Tags to search recipes ([see issue #11](https://gitlab.mbb.univ-montp2.fr/jlopez/wicopa/issues/11)),
......
......@@ -21,6 +21,7 @@ $id = NULL;
$version = NULL;
$manager = NULL;
$active = 0;
$vname = "";
if(isset($_POST['action'])) {
......@@ -64,19 +65,16 @@ if(isset($_POST['active'])) {
}
}
if(isset($_POST['vname'])) {
$vname = $_POST['vname'];
}
$distrib = new Distribution($id, $name, $version, $manager, $active);
$distrib = new Distribution($id, $name, $version, $manager, $active, $vname);
if($action == "create") {
$distrib->active = 1;
$distrib->escape($db);
if($db->checkTableExist($distrib->getFullName())) {
$db->create($distrib);
} else {
//TODO alert user.
}
} else if ($action == "update") {
$distrib->escape($db);
$db->update($distrib);
......
......@@ -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") {
$section->active = 1;
$section->escape($db);
if($db->checkTableExist($name)) {
$db->create($section);
} else {
//TODO alert user.
}
} else if ($action == "update") {
$section->escape($db);
$db->update($section);
......
......@@ -8,7 +8,7 @@ require_once "./dao/DBquery.php";
$db = new DBquery();
$type = "all";
$author = NULL;
$author = "";
$labels = array();
$tags = array();
$descriptions = array();
......@@ -330,7 +330,7 @@ require_once "./inc/php/buildHeader.php";
<script type="text/javascript">
function showFileContainer(id ) {
function showFileContainer(id) {
var value = FILE_CONTAINER[id];
document.getElementById('valueContainerFile').value = value;
......
......@@ -52,6 +52,11 @@ class DBquery
return mysqli_real_escape_string($this->dbh, $value);
}
/**
* Get all Distributions
*
* @return array
*/
public function getDistributions() {
$sql = "SELECT * FROM `Distrib` ORDER BY `Distrib`.`name` ASC;";
$result = mysqli_query($this->dbh, $sql);
......@@ -63,6 +68,14 @@ class DBquery
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) {
$sql = "SELECT vname FROM `Distrib` WHERE active = 1 AND `name`='$name' AND `version`='$version';";
$result = mysqli_query($this->dbh, $sql);
......@@ -72,6 +85,11 @@ class DBquery
return "";
}
/**
* Get all active distributions
*
* @return array
*/
public function getActiveDistributions() {
$sql = "SELECT * FROM `Distrib` WHERE active = 1 ORDER BY `Distrib`.`name` ASC;";
$result = mysqli_query($this->dbh, $sql);
......@@ -83,6 +101,11 @@ class DBquery
return $results;
}
/**
* Get all full name from all active distributions
*
* @return array
*/
public function getActiveDistributionsFullName() {
$sql = "SELECT name,version,vname FROM `Distrib` WHERE active = 1 ORDER BY `Distrib`.`name` ASC;";
$result = mysqli_query($this->dbh, $sql);
......@@ -93,6 +116,11 @@ class DBquery
return $results;
}
/**
* Get all managers
*
* @return array
*/
public function getManagers() {
$sql = "SELECT * FROM `Manager`;";
$result = mysqli_query($this->dbh, $sql);
......@@ -104,6 +132,11 @@ class DBquery
return $results;
}
/**
* Get all users
*
* @return array
*/
public function getUsers() {
$sql = "SELECT * FROM `User`;";
$result = mysqli_query($this->dbh, $sql);
......@@ -115,6 +148,13 @@ class DBquery
return $results;
}
/**
* Get grade with user login
*
* @param string $login The login of ther user
*
* @return array
*/
public function getGradeWithLogin($login) {
$sql = "SELECT * FROM `User` WHERE `login` = '$login';";
$result = mysqli_query($this->dbh, $sql);
......@@ -127,6 +167,13 @@ class DBquery
return $this->getLowerGrades();
}
/**
* Get all labels for specific grade
*
* @param $string $grade The grade to find the labels
*
* @return array
*/
public function getLabelsWithGrade($grade) {
$labels = $this->getLabels();
......@@ -146,6 +193,11 @@ class DBquery
return $results;
}
/**
* Get all grades
*
* @return array
*/
public function getGrades() {
$sql = "SELECT * FROM `Grade` ORDER BY `level` ASC;";
$result = mysqli_query($this->dbh, $sql);
......@@ -157,6 +209,11 @@ class DBquery
return $results;
}
/**
* Get all configs
*
* @return array
*/
public function getConfigs() {
$sql = "SELECT * FROM `Config` WHERE 1;";
$result = mysqli_query($this->dbh, $sql);
......@@ -168,6 +225,13 @@ class DBquery
return $results;
}
/**
* Gel all active config with type
*
* @param string $type The type of the config
*
* @return array
*/
public function getActiveConfigsWithType($type) {
$sql = "SELECT * FROM `Config` WHERE `type`='$type' AND `active` = 1;";
$result = mysqli_query($this->dbh, $sql);
......@@ -179,6 +243,13 @@ class DBquery
return $results;
}
/**
* Get grade with this ID
*
* @param int $ID The ID of the grade
*
* @return Grade
*/
public function getGradeWithId($ID) {
$sql = "SELECT * FROM `Grade` WHERE `ID` = '$ID';";
$result = mysqli_query($this->dbh, $sql);
......@@ -190,6 +261,11 @@ class DBquery
return $results;
}
/**
* Get lower grade
*
* @return Grade
*/
public function getLowerGrades() {
$sql = "SELECT * FROM `Grade` ORDER BY `level` DESC LIMIT 1;";
$result = mysqli_query($this->dbh, $sql);
......@@ -201,6 +277,11 @@ class DBquery
return $results;
}
/**
* Get max grade
*
* @return Grade
*/
public function getMaxGrades() {
$sql = "SELECT * FROM `Grade` ORDER BY `level` ASC LIMIT 1;";
$result = mysqli_query($this->dbh, $sql);
......@@ -212,6 +293,11 @@ class DBquery
return $results;
}
/**
* Get all public tags
*
* @return array
*/
public function getAllPublicTags() {
$sql = "SELECT tags FROM `Container` WHERE tags <> '' AND visibility = 1;";
$result = mysqli_query($this->dbh, $sql);
......@@ -222,6 +308,18 @@ class DBquery
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) {
$sql = "SELECT * FROM `Container`";
......@@ -277,6 +375,13 @@ class DBquery
return $results;
}
/**
* Get container with this id
*
* @param int $id The id of the container
*
* @return Container
*/
public function getContainerWithId($id) {
$sql = "SELECT * FROM `Container` WHERE `ID` = '$id';";
$result = mysqli_query($this->dbh, $sql);
......@@ -288,6 +393,11 @@ class DBquery
return $results;
}
/**
* Get all labels
*
* @return array
*/
public function getLabels() {
$sql = "SELECT * FROM `Label`;";
$result = mysqli_query($this->dbh, $sql);
......@@ -299,6 +409,14 @@ class DBquery
return $results;
}
/**
* Get label with this id
*
* @param int $id The id of the label
*
* @return Label
*
*/
public function getLabelsWithId($id) {
$sql = "SELECT * FROM `Label` WHERE `ID` = $id;";
$result = mysqli_query($this->dbh, $sql);
......@@ -310,12 +428,13 @@ class DBquery
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) {
$sql = "SELECT * FROM `ContainerLabel` WHERE `containerId` = $id";
$result = mysqli_query($this->dbh, $sql);
......@@ -327,6 +446,11 @@ class DBquery
return $results;
}
/**
* Get all active Section who is parent
*
* @return array
*/
public function getAllActiveSectionParent() {
$sql = "SELECT * FROM `Section` WHERE `Section`.`parent` IS NULL AND active = 1 ORDER BY `Section`.`arrangement` ASC;";
$result = mysqli_query($this->dbh, $sql);
......@@ -338,6 +462,11 @@ class DBquery
return $results;
}
/**
* Get all section parent
*
* @return array
*/
public function getAllSectionParent() {
$sql = "SELECT * FROM `Section` WHERE `Section`.`parent` IS NULL ORDER BY `Section`.`arrangement` ASC;";
$result = mysqli_query($this->dbh, $sql);
......@@ -349,6 +478,13 @@ class DBquery
return $results;
}
/**
* Get all active Section for specific parent
*
* @param string $parent The name of the parent
*
* @return array
*/
public function getSectionWhithParent($parent) {
$sql = "SELECT * FROM `Section` WHERE `Section`.`parent` = '$parent' AND active = 1 ORDER BY `Section`.`arrangement` ASC;";
$result = mysqli_query($this->dbh, $sql);
......@@ -359,6 +495,12 @@ class DBquery
return $results;
}
/**
*
* Get all name of the section who have a parent
*
* @return array
*/
public function getNameSectionWhithParent($parent) {
$sql = "SELECT name FROM `Section` WHERE `Section`.`parent` = '$parent' AND active = 1 ORDER BY `Section`.`arrangement` ASC;";
$result = mysqli_query($this->dbh, $sql);
......@@ -369,6 +511,13 @@ class DBquery
return $results;
}
/**
* Get all Section for specific parent
*
* @param string $parent The name of the parent
*
* @return array
*/
public function getAllSectionWhithParent($parent) {
$sql = "SELECT * FROM `Section` WHERE `Section`.`parent` = '$parent' ORDER BY `Section`.`arrangement` ASC;";
$result = mysqli_query($this->dbh, $sql);
......@@ -380,6 +529,12 @@ class DBquery
return $results;
}
/**
* Get all action section
*
* @return array
*/
public function getActiveSection() {
$sql = "SELECT * FROM `Section` WHERE active = 1 ORDER BY `Section`.`arrangement` ASC;";
$result = mysqli_query($this->dbh, $sql);
......@@ -391,6 +546,11 @@ class DBquery
return $results;
}
/**
* Get all Section
*
* @return array
*/
public function getSection() {
$sql = "SELECT * FROM `Section` ORDER BY `Section`.`arrangement` ASC;";
$result = mysqli_query($this->dbh, $sql);
......@@ -402,6 +562,13 @@ class DBquery
return $results;
}
/**
* Get number packages For Distribution
*
* @deprecated
*
* @return int
*/
public function getNumberPackage($name) {
$sql = "SELECT COUNT(*) as number FROM `$name` WHERE 1 ";
......@@ -413,6 +580,11 @@ class DBquery
return 0;
}
/**
* Get all packages
*
* @deprecated
*/
public function getPackages($distrib, $filter, $patternName, $patternDescription, $limit) {
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;";
......@@ -435,6 +607,12 @@ class DBquery
return $results;
}
/**
* Check if table exist in database
*
* @param string $name The name of the table
*
*/
public function checkTableExist($name) {
$sql = "SELECT count(*) as number FROM information_schema.TABLES WHERE (TABLE_SCHEMA = 'wicopa') AND (TABLE_NAME = '$name')";
......@@ -451,6 +629,9 @@ class DBquery
}
}
/**
* Create ofject in database
*/
public function create($object) {
$result = mysqli_query($this->dbh, $object->getInsert());
......@@ -464,7 +645,9 @@ class DBquery
}
/**
* Update ofject in database
*/
public function update($object) {
$result = mysqli_query($this->dbh, $object->getUpdate());
if($result) {
......@@ -476,6 +659,9 @@ class DBquery
}
/**
* Delete ofject in database
*/
public function delete($object) {
$result = mysqli_query($this->dbh, $object->getDelete());
if($result) {
......@@ -486,6 +672,9 @@ class DBquery
}
}
/**
* Check admin pass
*/
public function verifyPass($username, $pass) {
if($username == "admin" && Conf::dbEncodePass($pass)==Conf::$KK) {
return 1;
......@@ -499,6 +688,11 @@ class DBquery
}
}
/**
* Get number docker container
*
* @return int
*/
public function getNumberDockerContainer() {
$sql = 'SELECT count(*) as docker FROM `Container` WHERE type = "Docker" AND visibility = 1;';
$result = mysqli_query($this->dbh, $sql);
......@@ -513,6 +707,11 @@ class DBquery
return 0;
}
/**
* Get number singularity container
*
* @return int
*/
public function getNumberSingularityContainer() {
$sql = 'SELECT count(*) as singularity FROM `Container` WHERE type = "Singularity" AND visibility = 1';
$result = mysqli_query($this->dbh, $sql);
......
<?php
/**
* Connection to ldap
*/
require_once(__DIR__.'/../inc/conf/Conf.php');
/**
* Class LDAPquery for connection to the LDAP
*/
class LDAPquery {
var $ldaph = NULL;
/**
* Constructor
*/
public function __construct() {
$this->openConnection();
}
/**
* Open connection with LDAP
*/
public function openConnection() {
$this->ldaph = ldap_connect(Conf::$LDAP_HOSTNAME);
......@@ -22,12 +27,18 @@ class LDAPquery {
}
}
/**
* Bind with LDAP
*/
public function bind() {
ldap_set_option($this->ldaph, LDAP_OPT_PROTOCOL_VERSION, 3);
$r = ldap_bind($this->ldaph, Conf::$LDAP_ADMIN, Conf::$LDAP_PP);
return $r;
}
/**
* Verify user login and password with LDAP for user connection
*/
public function verifyPass($ul, $up) {
$r = $this->bind();
if($r) {
......
This diff is collapsed.
......@@ -25,7 +25,7 @@ echo '
<nav class="navbar navbar-expand-md navbar-dark navbar-custom p-1">
<div class="navbar-brand">WICOPA</div>
<div class="navbar-brand">WICOPA (v0.5.1)</div>
<div class="collapse navbar-collapse justify-content-between" id="navbar">
<div class="navbar-nav">
';
......
<?php
/**
* @file printPanel.php
*/
/**
* Print Section with name of this Section and database
*
* @param string $name The name of the Section to print
* @param DBquery $db The database object
*/
function printSection($name, $db) {
if($name == "Python") {
......@@ -34,8 +44,9 @@ function printSection($name, $db) {
<label for="selectedR" class="font-weight-bold">R version :</label>
<select class="custom-select" id="selectedR">
<option value="0" selected="selected" >None</option>
<option value="4.0.1">4.0.1</option>
<option value="3.6.3">3.6.3</option>
<option value="3.5">3.5</option>
<option value="3.5.0">3.5.0</option>
</select>
</div>
......@@ -82,6 +93,11 @@ function printSection($name, $db) {
}
}
/**
* Print panel
*
* @param string $name THe name of the section
*/
function printPanel($name) {
echo '
<label for="find'.$name.'Packages">Find packages containing substring :</label>
......
......@@ -388,6 +388,43 @@ require_once "./inc/php/buildHeader.php";
</div>
</div> <!-- End Modal Publish -->
<!-- Start Modal Publish -->
<div class="modal" id="modalBuildCommand">
<div class="modal-dialog">
<div class="modal-content">
<!-- Modal Header -->
<div class="modal-header">
<h4 class="modal-title">Build Command</h4>
<button type="button" class="close" data-dismiss="modal">&times;</button>
</div>