Skip to content
This repository was archived by the owner on Aug 9, 2021. It is now read-only.

Commit 794e277

Browse files
committed
feat(market): fdroid market
declaration of markets running f-droid market with automatic import of list of apps and import of apps in a package Signed-off-by: Thierry Bugier <[email protected]>
1 parent 9b9d2bd commit 794e277

23 files changed

+1447
-473
lines changed

front/fdroidapplication.form.php

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
<?php
2+
/**
3+
* LICENSE
4+
*
5+
* Copyright © 2016-2018 Teclib'
6+
* Copyright © 2010-2018 by the FusionInventory Development Team.
7+
*
8+
* This file is part of Flyve MDM Plugin for GLPI.
9+
*
10+
* Flyve MDM Plugin for GLPI is a subproject of Flyve MDM. Flyve MDM is a mobile
11+
* device management software.
12+
*
13+
* Flyve MDM Plugin for GLPI is free software: you can redistribute it and/or
14+
* modify it under the terms of the GNU Affero General Public License as published
15+
* by the Free Software Foundation, either version 3 of the License, or
16+
* (at your option) any later version.
17+
* Flyve MDM Plugin for GLPI is distributed in the hope that it will be useful,
18+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
19+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20+
* GNU Affero General Public License for more details.
21+
* You should have received a copy of the GNU Affero General Public License
22+
* along with Flyve MDM Plugin for GLPI. If not, see http://www.gnu.org/licenses/.
23+
* ------------------------------------------------------------------------------
24+
* @author Thierry Bugier
25+
* @copyright Copyright © 2018 Teclib
26+
* @license AGPLv3+ http://www.gnu.org/licenses/agpl.txt
27+
* @link https://github.com/flyve-mdm/glpi-plugin
28+
* @link https://flyve-mdm.com/
29+
* ------------------------------------------------------------------------------
30+
*/
31+
32+
include ('../../../inc/includes.php');
33+
$plugin = new Plugin();
34+
if (!$plugin->isActivated('flyvemdm')) {
35+
Html::displayNotFoundError();
36+
}
37+
38+
Session::checkRight('flyvemdm:flyvemdm', PluginFlyvemdmProfile::RIGHT_FLYVEMDM_USE);
39+
40+
if (!isset($_GET['id'])) {
41+
$_GET['id'] = '';
42+
}
43+
44+
if (!isset($_GET['withtemplate'])) {
45+
$_GET['withtemplate'] = '';
46+
}
47+
48+
$fdroidApplication = new PluginFlyvemdmFDroidApplication();
49+
if (isset($_POST['import'])) {
50+
unset($_POST['_skip_checks']);
51+
$fdroidApplication->update(['id' => $_POST['id'], 'import_status' => 'to_import']);
52+
Html::back();
53+
} else {
54+
$fdroidApplication->check($_GET['id'], READ);
55+
Html::header(
56+
PluginFlyvemdmFDroidApplication::getTypeName(Session::getPluralNumber()),
57+
'',
58+
'admin',
59+
PluginFlyvemdmMenu::class,
60+
'fdroid application'
61+
);
62+
63+
$menu = new PluginFlyvemdmMenu();
64+
$menu->displayMenu('mini');
65+
66+
$fdroidApplication->display([
67+
'id' => $_GET['id'],
68+
'withtemplate' => $_GET['withtemplate']
69+
]);
70+
71+
// Footer
72+
if (strstr($_SERVER['PHP_SELF'], 'popup')) {
73+
Html::popFooter();
74+
} else {
75+
Html::footer();
76+
}
77+
}

front/fdroidapplication.php

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?php
2+
/**
3+
* LICENSE
4+
*
5+
* Copyright © 2016-2018 Teclib'
6+
* Copyright © 2010-2018 by the FusionInventory Development Team.
7+
*
8+
* This file is part of Flyve MDM Plugin for GLPI.
9+
*
10+
* Flyve MDM Plugin for GLPI is a subproject of Flyve MDM. Flyve MDM is a mobile
11+
* device management software.
12+
*
13+
* Flyve MDM Plugin for GLPI is free software: you can redistribute it and/or
14+
* modify it under the terms of the GNU Affero General Public License as published
15+
* by the Free Software Foundation, either version 3 of the License, or
16+
* (at your option) any later version.
17+
* Flyve MDM Plugin for GLPI is distributed in the hope that it will be useful,
18+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
19+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20+
* GNU Affero General Public License for more details.
21+
* You should have received a copy of the GNU Affero General Public License
22+
* along with Flyve MDM Plugin for GLPI. If not, see http://www.gnu.org/licenses/.
23+
* ------------------------------------------------------------------------------
24+
* @author Thierry Bugier
25+
* @copyright Copyright © 2018 Teclib
26+
* @license AGPLv3+ http://www.gnu.org/licenses/agpl.txt
27+
* @link https://github.com/flyve-mdm/glpi-plugin
28+
* @link https://flyve-mdm.com/
29+
* ------------------------------------------------------------------------------
30+
*/
31+
32+
include ('../../../inc/includes.php');
33+
$plugin = new Plugin();
34+
if (!$plugin->isActivated('flyvemdm')) {
35+
Html::displayNotFoundError();
36+
}
37+
38+
Session::checkRight("flyvemdm:flyvemdm", PluginFlyvemdmProfile::RIGHT_FLYVEMDM_USE);
39+
Session::checkRight("flyvemdm:fdroidapplication", READ);
40+
41+
Html::header(
42+
PluginFlyvemdmFDroidApplication::getTypeName(Session::getPluralNumber()),
43+
'',
44+
'admin',
45+
PluginFlyvemdmMenu::class,
46+
'fdroid application'
47+
);
48+
49+
$menu = new PluginFlyvemdmMenu();
50+
$menu->displayMenu('mini');
51+
52+
Search::show(PluginFlyvemdmFDroidApplication::class);
53+
54+
Html::footer();

front/fdroidmarket.form.php

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
<?php
2+
/**
3+
* LICENSE
4+
*
5+
* Copyright © 2016-2018 Teclib'
6+
* Copyright © 2010-2018 by the FusionInventory Development Team.
7+
*
8+
* This file is part of Flyve MDM Plugin for GLPI.
9+
*
10+
* Flyve MDM Plugin for GLPI is a subproject of Flyve MDM. Flyve MDM is a mobile
11+
* device management software.
12+
*
13+
* Flyve MDM Plugin for GLPI is free software: you can redistribute it and/or
14+
* modify it under the terms of the GNU Affero General Public License as published
15+
* by the Free Software Foundation, either version 3 of the License, or
16+
* (at your option) any later version.
17+
* Flyve MDM Plugin for GLPI is distributed in the hope that it will be useful,
18+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
19+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20+
* GNU Affero General Public License for more details.
21+
* You should have received a copy of the GNU Affero General Public License
22+
* along with Flyve MDM Plugin for GLPI. If not, see http://www.gnu.org/licenses/.
23+
* ------------------------------------------------------------------------------
24+
* @author Thierry Bugier
25+
* @copyright Copyright © 2018 Teclib
26+
* @license AGPLv3+ http://www.gnu.org/licenses/agpl.txt
27+
* @link https://github.com/flyve-mdm/glpi-plugin
28+
* @link https://flyve-mdm.com/
29+
* ------------------------------------------------------------------------------
30+
*/
31+
32+
include ('../../../inc/includes.php');
33+
$plugin = new Plugin();
34+
if (!$plugin->isActivated('flyvemdm')) {
35+
Html::displayNotFoundError();
36+
}
37+
38+
Session::checkRight('flyvemdm:flyvemdm', PluginFlyvemdmProfile::RIGHT_FLYVEMDM_USE);
39+
40+
if (!isset($_GET['id'])) {
41+
$_GET['id'] = '';
42+
}
43+
44+
if (!isset($_GET['withtemplate'])) {
45+
$_GET['withtemplate'] = '';
46+
}
47+
48+
$market = new PluginFlyvemdmFDroidMarket();
49+
if (isset($_POST["add"])) {
50+
$market->check(-1, CREATE, $_POST);
51+
if ($newID = $market->add($_POST)) {
52+
if ($_SESSION['glpibackcreated']) {
53+
Html::redirect($market->getFormURL() . "?id=" . $newID);
54+
}
55+
}
56+
Html::back();
57+
} else if (isset($_POST["update"])) {
58+
$market->check($_POST['id'], UPDATE);
59+
$market->update($_POST);
60+
Html::back();
61+
} else if (isset($_POST["purge"])) {
62+
$market->check($_POST['id'], PURGE);
63+
$market->delete($_POST, 1);
64+
$market->redirectToList();
65+
} else if (isset($_POST['refresh'])) {
66+
$fdroidMarket = new PluginFlyvemdmFDroidMarket();
67+
$fdroidMarket->getFromDB((int) $_POST['id']);
68+
$volume = $fdroidMarket->updateRepository();
69+
Html::back();
70+
} else {
71+
if (isset($_GET['search'])) {
72+
$criterias = array_intersect_key($_GET, ['criteria' => null, 'metacriteria' => null]);
73+
$_SESSION['glpisearch'][PluginFlyvemdmFDroidApplication::class] = $criterias;
74+
} else if (isset($_GET['reset'])) {
75+
unset($_SESSION['glpisearch'][PluginFlyvemdmFDroidApplication::class]);
76+
}
77+
$market->check($_GET['id'], READ);
78+
Html::header(
79+
PluginFlyvemdmFDroidApplication::getTypeName(Session::getPluralNumber()),
80+
'',
81+
'admin',
82+
PluginFlyvemdmMenu::class,
83+
'fdroid market'
84+
);
85+
86+
$menu = new PluginFlyvemdmMenu();
87+
$menu->displayMenu('mini');
88+
89+
$market->display([
90+
'id' => $_GET['id'],
91+
'withtemplate' => $_GET['withtemplate']
92+
]);
93+
94+
// Footer
95+
if (strstr($_SERVER['PHP_SELF'], 'popup')) {
96+
Html::popFooter();
97+
} else {
98+
Html::footer();
99+
}
100+
}

front/fdroidmarket.php

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?php
2+
/**
3+
* LICENSE
4+
*
5+
* Copyright © 2016-2018 Teclib'
6+
* Copyright © 2010-2018 by the FusionInventory Development Team.
7+
*
8+
* This file is part of Flyve MDM Plugin for GLPI.
9+
*
10+
* Flyve MDM Plugin for GLPI is a subproject of Flyve MDM. Flyve MDM is a mobile
11+
* device management software.
12+
*
13+
* Flyve MDM Plugin for GLPI is free software: you can redistribute it and/or
14+
* modify it under the terms of the GNU Affero General Public License as published
15+
* by the Free Software Foundation, either version 3 of the License, or
16+
* (at your option) any later version.
17+
* Flyve MDM Plugin for GLPI is distributed in the hope that it will be useful,
18+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
19+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20+
* GNU Affero General Public License for more details.
21+
* You should have received a copy of the GNU Affero General Public License
22+
* along with Flyve MDM Plugin for GLPI. If not, see http://www.gnu.org/licenses/.
23+
* ------------------------------------------------------------------------------
24+
* @author Thierry Bugier
25+
* @copyright Copyright © 2018 Teclib
26+
* @license AGPLv3+ http://www.gnu.org/licenses/agpl.txt
27+
* @link https://github.com/flyve-mdm/glpi-plugin
28+
* @link https://flyve-mdm.com/
29+
* ------------------------------------------------------------------------------
30+
*/
31+
32+
include ('../../../inc/includes.php');
33+
$plugin = new Plugin();
34+
if (!$plugin->isActivated('flyvemdm')) {
35+
Html::displayNotFoundError();
36+
}
37+
38+
Session::checkRight('flyvemdm:flyvemdm', PluginFlyvemdmProfile::RIGHT_FLYVEMDM_USE);
39+
Session::checkRight('flyvemdm:fdroidmarket', READ);
40+
41+
Html::header(
42+
PluginFlyvemdmFDroidMarket::getTypeName(Session::getPluralNumber()),
43+
'',
44+
'admin',
45+
PluginFlyvemdmMenu::class,
46+
'fdroid market');
47+
48+
$menu = new PluginFlyvemdmMenu();
49+
$menu->displayMenu('mini');
50+
51+
Search::show(PluginFlyvemdmFDroidMarket::class);
52+
53+
Html::footer();
54+

hook.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,9 @@ function plugin_Flyvemdm_addDefaultJoin($itemtype, $ref_table, $already_link_tab
139139

140140
case PluginFlyvemdmAgent::class:
141141
return PluginFlyvemdmAgent::addDefaultJoin($ref_table, $already_link_tables);
142+
143+
case PluginFlyvemdmFDroidApplication::class:
144+
return PluginFlyvemdmFDroidApplication::addDefaultJoin($ref_table, $already_link_tables);
142145
}
143146
}
144147

@@ -154,8 +157,10 @@ function plugin_Flyvemdm_addDefaultWhere($itemtype) {
154157

155158
case PluginFlyvemdmAgent::class:
156159
return PluginFlyvemdmAgent::addDefaultWhere();
157-
}
158160

161+
case PluginFlyvemdmFDroidApplication::class:
162+
return PluginFlyvemdmFDroidApplication::addDefaultWhere();
163+
}
159164
}
160165

161166
/**

inc/entityconfig.class.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,17 @@ static function canUpdate() {
8686
}
8787
}
8888

89+
function getRights($interface = 'central') {
90+
$values = [
91+
READ => __('Read'),
92+
self::RIGHT_FLYVEMDM_DEVICE_COUNT_LIMIT => __('Write device limit'),
93+
self::RIGHT_FLYVEMDM_APP_DOWNLOAD_URL => __('Set agent download URL'),
94+
self::RIGHT_FLYVEMDM_INVITATION_TOKEN_LIFE => __('Set invitation tiken lifetime'),
95+
];
96+
97+
return $values;
98+
}
99+
89100
/**
90101
* Actions done after the getFromDB method
91102
*/

0 commit comments

Comments
 (0)