Skip to content

Commit

Permalink
Merge pull request #141 from lbr38/devel
Browse files Browse the repository at this point in the history
3.7.9
  • Loading branch information
lbr38 authored Dec 17, 2023
2 parents 542deb4 + 8661dcd commit dc40e0a
Show file tree
Hide file tree
Showing 81 changed files with 2,119 additions and 2,920 deletions.
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,5 @@ No roadmap, just a todolist with some bug reports and ideas you can find <a href

<h2>Contact</h2>

- For bug reports or any issue using Repomanager, please open a new issue in the Github ``Issues`` section
- For features requests, please open a new idea in the Github ``Discussions`` section
- For any other question you please contact me at <a href="mailto:[email protected]">[email protected]</a> (English or French spoken)
- For bug reports, issues or features requests, please open a new issue in the Github ``Issues`` section
- For any other question you can contact me at <a href="mailto:[email protected]">[email protected]</a> (English or French spoken)
21 changes: 17 additions & 4 deletions Todolist
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
- Update documentation
- (JS/PHP) Add pagination in tables


[ BUGS ]

[ GENERAL ]
Expand All @@ -22,6 +23,11 @@
https://salsa.debian.org/debian/reprepro.git


[ OPERATIONS ]

- (RPM mirroring) Ignore warning if 'already contains identical signature' is found in the output of rpm --addsign


[ SERVICE ]

- logparser is sometimes using too much cpu, see how to improve
Expand All @@ -45,13 +51,15 @@
- (DEB) Add a feature to be able to add distributions to the list of pre-defined distributions (and do the same for sections)


[ STATS ]

- Convert 'Last access requets' table to a paginated table


[ HOSTS / LINUPDATE ]

- Be able to ask a host to update one or more specific packages
- (linupdate) Add a feature to be able to restart services based on the packages that have been updated, e.g :
- Restart nginx-app-protect if the following packages are updated: app-protect*
- Restart nginx if the following packages are updated: nginx, nginx-plus*



[ CVE ]

Expand All @@ -67,3 +75,8 @@
[ API ]

- Remove the old authentication method (via -d parameters), once linupdate 2.2.11 is released


[ MAIL ]

- Add an alternative way of sending mails via SMTP server: https://github.com/lbr38/repomanager/issues/139
5 changes: 5 additions & 0 deletions www/config/properties.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
'project_git_repo_raw' => 'https://raw.githubusercontent.com/lbr38/repomanager/stable',
'project_update_doc_url' => 'https://github.com/lbr38/repomanager/wiki/01.-Installation-and-update#update-repomanager',

// Debian repo default values
'debian_distributions' => array('bookworm' => 'Debian 12', 'bullseye' => 'Debian 11', 'buster' => 'Debian 10', 'stretch' => 'Debian 9', 'jessie' => 'Debian 8', 'wheezy' => 'Debian 7'),
'ubuntu_distributions' => array('jammy' => 'Ubuntu 22.04', 'hirsute' => 'Ubuntu 21.04', 'groovy' => 'Ubuntu 20.10', 'focal' => 'Ubuntu 20.04', 'eoan' => 'Ubuntu 19.10', 'disco' => 'Ubuntu 19.04', 'cosmic' => 'Ubuntu 18.10', 'bionic' => 'Ubuntu 18.04', 'xenial' => 'Ubuntu 16.04', 'trusty' => 'Ubuntu 14.04'),
'sections' => array('main', 'contrib', 'non-free', 'restricted', 'universe', 'multiverse'),

// DEB default values
'deb_archs' => array('amd64', 'arm64', 'armel', 'armhf', 'i386', 'mips', 'mips64el', 'mipsel', 'ppc64el', 's390x', 'src'),

Expand Down
143 changes: 91 additions & 52 deletions www/controllers/Group.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ class Group
public function __construct(string $type)
{
/**
* Cette class permet de manipuler des groupes de repos ou d'hôtes.
* Selon ce qu'on souhaite traiter, la base de données n'est pas la même.
* Si on a renseigné une base de données au moment de l'instanciation d'un objet Group alors on utilise cette base
* Sinon par défaut on utilise la base principale de repomanager
* This class allows to manipulate repos or hosts groups.
* Depending on what we want to manipulate, the database is not the same.
* If we have specified a database when instantiating a Group object then we use this database
* Else we use the main database
*/

if ($type != 'repo' and $type != 'host') {
Expand Down Expand Up @@ -55,12 +55,12 @@ public function getType()
}

/**
* Retourne l'Id du groupe à partir de son nom
* Return false if group does not exist
*/
public function getIdByName(string $name)
{
/**
* On vérifie que le groupe existe
* Check if group exists
*/
if ($this->exists($name) === false) {
throw new Exception("Group <b>$name</b> does not exist");
Expand Down Expand Up @@ -101,7 +101,7 @@ public function exists(string $name = '')
}

/**
* Créer un nouveau groupe
* Create a new group
* @param name
*/
public function new(string $name)
Expand Down Expand Up @@ -134,57 +134,77 @@ public function new(string $name)
}

/**
* Renommer un groupe
* @param actualName
* @param newName
* Edit a group
*/
public function rename(string $actualName, string $newName)
public function edit(int $id, string $name, array $data)
{
/**
* 1. On vérifie que le nom du groupe ne contient pas des caractères interdits
* Check if group exists
*/
if (\Controllers\Common::isAlphanumDash($actualName) === false) {
throw new Exception("Actual group name <b>$actualName</b> contains invalid characters");
if (!$this->existsId($id)) {
throw new Exception('Group does not exist');
}
if (\Controllers\Common::isAlphanumDash($newName) === false) {
throw new Exception("New group name <b>$newName</b> contains invalid characters");

/**
* Check if group name is valid
*/
if (\Controllers\Common::isAlphanumDash($name) === false) {
throw new Exception("Group name <b>$name</b> contains invalid characters");
}

/**
* 2. On vérifie que le nouveau nom de groupe n'existe pas déjà
* Edit group name
*/
$this->updateName($id, $name);

/**
* Edit group data
*/

/**
* If group type is 'repo'
*/
if ($this->model->exists($newName) === true) {
throw new Exception("Group name <b>$newName</b> already exists");
if ($this->type == 'repo') {
$myrepo = new \Controllers\Repo\Repo();
$myrepo->addReposIdToGroup($data, $id);
}

/**
* 3. Renommage du groupe
* If group type is 'host'
*/
$this->model->rename($actualName, $newName);
if ($this->type == 'host') {
$myhost = new \Controllers\Host();
$myhost->addHostsIdToGroup($data, $id);
}

$myhistory = new \Controllers\History();
$myhistory->set($_SESSION['username'], 'Rename group: <span class="label-white">' . $actualName . '</span> to <span class="label-white">' . $newName . '</span> (type: ' . $this->type . ')', 'success');
$myhistory->set($_SESSION['username'], 'Group <span class="label-white">' . $name . '</span> (type: ' . $this->type . ') edited', 'success');

\Controllers\App\Cache::clear();
}

/**
* Supprimer un groupe
* @param name
* Delete a group
* @param id
*/
public function delete(string $name)
public function delete(int $id)
{
/**
* 1. On vérifie que le groupe existe
* Check if group exists
*/
if ($this->model->exists($name) === false) {
throw new Exception("Group <b>$name</b> does not exist");
if (!$this->existsId($id)) {
throw new Exception('Group does not exist');
}

/**
* 2. Suppression du groupe en base de données
* Retrieve name, for history
*/
$name = $this->getNameById($id);

/**
* Delete group in database
*/
$this->model->delete($name);
$this->model->delete($id);

$myhistory = new \Controllers\History();
$myhistory->set($_SESSION['username'], 'Delete group <span class="label-white">' . $name . '</span> (type: '. $this->type . ')', 'success');
Expand All @@ -196,46 +216,65 @@ public function delete(string $name)
* Retourne les informations de tous les groupes en base de données
* Sauf le groupe par défaut
*/
public function listAll()
public function listAll($withDefault = false)
{
return $this->model->listAll();
$groups = $this->model->listAll();

/**
* Add default group 'Default' to the end of the list
*/
if ($withDefault === true) {
$groups[] = array('Id' => 0, 'Name' => 'Default');
}

return $groups;
}

/**
* Retourne tous les noms de groupes en bases de données
* Sauf le groupe par défaut
* Supprime des groupes les repos qui n'existent plus
*/
public function listAllName()
public function cleanRepos()
{
return $this->model->listAllName();
$this->model->cleanRepos();
}

/**
* Returns the names of groups in database
* With the default group name
* Update group name in database
*/
public function listAllWithDefault()
private function updateName(int $id, string $name)
{
$groups = $this->model->listAllName();
$this->model->updateName($id, $name);
}

/**
* Sort by name
*/
asort($groups);
/**
* Return the list of repos in a group
*/
public function getReposMembers(int $id)
{
return $this->model->getReposMembers($id);
}

/**
* Then add default group 'Default' to the end of the list
*/
$groups[] = 'Default';
/**
* Return the list of repos not in any group
*/
public function getReposNotMembers()
{
return $this->model->getReposNotMembers();
}

return $groups;
/**
* Return the list of hosts in a group
*/
public function getHostsMembers(int $id)
{
return $this->model->getHostsMembers($id);
}

/**
* Supprime des groupes les repos qui n'existent plus
* Return the list of hosts not in any group
*/
public function cleanRepos()
public function getHostsNotMembers()
{
$this->model->cleanRepos();
return $this->model->getHostsNotMembers();
}
}
Loading

0 comments on commit dc40e0a

Please sign in to comment.