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

Commit

Permalink
feat(market): fdroid market
Browse files Browse the repository at this point in the history
Signed-off-by: Thierry Bugier <tbugier@teclib.com>
  • Loading branch information
btry committed Aug 22, 2018
1 parent 10e4ed2 commit 7e44ddc
Show file tree
Hide file tree
Showing 29 changed files with 2,177 additions and 623 deletions.
77 changes: 77 additions & 0 deletions front/fdroidapplication.form.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?php
/**
* LICENSE
*
* Copyright © 2016-2018 Teclib'
* Copyright © 2010-2018 by the FusionInventory Development Team.
*
* This file is part of Flyve MDM Plugin for GLPI.
*
* Flyve MDM Plugin for GLPI is a subproject of Flyve MDM. Flyve MDM is a mobile
* device management software.
*
* Flyve MDM Plugin for GLPI is free software: you can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* Flyve MDM Plugin for GLPI is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
* You should have received a copy of the GNU Affero General Public License
* along with Flyve MDM Plugin for GLPI. If not, see http://www.gnu.org/licenses/.
* ------------------------------------------------------------------------------
* @author Thierry Bugier
* @copyright Copyright © 2018 Teclib
* @license AGPLv3+ http://www.gnu.org/licenses/agpl.txt
* @link https://github.com/flyve-mdm/glpi-plugin
* @link https://flyve-mdm.com/
* ------------------------------------------------------------------------------
*/

include ('../../../inc/includes.php');
$plugin = new Plugin();
if (!$plugin->isActivated('flyvemdm')) {
Html::displayNotFoundError();
}

Session::checkRight('flyvemdm:flyvemdm', PluginFlyvemdmProfile::RIGHT_FLYVEMDM_USE);

if (!isset($_GET['id'])) {
$_GET['id'] = '';
}

if (!isset($_GET['withtemplate'])) {
$_GET['withtemplate'] = '';
}

$fdroidApplication = new PluginFlyvemdmFDroidApplication();
if (isset($_POST['import'])) {
unset($_POST['_skip_checks']);
$fdroidApplication->update(['id' => $_POST['id'], 'import_status' => 'to_import']);
Html::back();
} else {
$fdroidApplication->check($_GET['id'], READ);
Html::header(
PluginFlyvemdmFDroidApplication::getTypeName(Session::getPluralNumber()),
'',
'admin',
PluginFlyvemdmMenu::class,
'fdroid application'
);

$menu = new PluginFlyvemdmMenu();
$menu->displayMenu('mini');

$fdroidApplication->display([
'id' => $_GET['id'],
'withtemplate' => $_GET['withtemplate']
]);

// Footer
if (strstr($_SERVER['PHP_SELF'], 'popup')) {
Html::popFooter();
} else {
Html::footer();
}
}
54 changes: 54 additions & 0 deletions front/fdroidapplication.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php
/**
* LICENSE
*
* Copyright © 2016-2018 Teclib'
* Copyright © 2010-2018 by the FusionInventory Development Team.
*
* This file is part of Flyve MDM Plugin for GLPI.
*
* Flyve MDM Plugin for GLPI is a subproject of Flyve MDM. Flyve MDM is a mobile
* device management software.
*
* Flyve MDM Plugin for GLPI is free software: you can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* Flyve MDM Plugin for GLPI is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
* You should have received a copy of the GNU Affero General Public License
* along with Flyve MDM Plugin for GLPI. If not, see http://www.gnu.org/licenses/.
* ------------------------------------------------------------------------------
* @author Thierry Bugier
* @copyright Copyright © 2018 Teclib
* @license AGPLv3+ http://www.gnu.org/licenses/agpl.txt
* @link https://github.com/flyve-mdm/glpi-plugin
* @link https://flyve-mdm.com/
* ------------------------------------------------------------------------------
*/

include ('../../../inc/includes.php');
$plugin = new Plugin();
if (!$plugin->isActivated('flyvemdm')) {
Html::displayNotFoundError();
}

Session::checkRight("flyvemdm:flyvemdm", PluginFlyvemdmProfile::RIGHT_FLYVEMDM_USE);
Session::checkRight("flyvemdm:fdroidapplication", READ);

Html::header(
PluginFlyvemdmFDroidApplication::getTypeName(Session::getPluralNumber()),
'',
'admin',
PluginFlyvemdmMenu::class,
'fdroid application'
);

$menu = new PluginFlyvemdmMenu();
$menu->displayMenu('mini');

Search::show(PluginFlyvemdmFDroidApplication::class);

Html::footer();
100 changes: 100 additions & 0 deletions front/fdroidmarket.form.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
<?php
/**
* LICENSE
*
* Copyright © 2016-2018 Teclib'
* Copyright © 2010-2018 by the FusionInventory Development Team.
*
* This file is part of Flyve MDM Plugin for GLPI.
*
* Flyve MDM Plugin for GLPI is a subproject of Flyve MDM. Flyve MDM is a mobile
* device management software.
*
* Flyve MDM Plugin for GLPI is free software: you can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* Flyve MDM Plugin for GLPI is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
* You should have received a copy of the GNU Affero General Public License
* along with Flyve MDM Plugin for GLPI. If not, see http://www.gnu.org/licenses/.
* ------------------------------------------------------------------------------
* @author Thierry Bugier
* @copyright Copyright © 2018 Teclib
* @license AGPLv3+ http://www.gnu.org/licenses/agpl.txt
* @link https://github.com/flyve-mdm/glpi-plugin
* @link https://flyve-mdm.com/
* ------------------------------------------------------------------------------
*/

include ('../../../inc/includes.php');
$plugin = new Plugin();
if (!$plugin->isActivated('flyvemdm')) {
Html::displayNotFoundError();
}

Session::checkRight('flyvemdm:flyvemdm', PluginFlyvemdmProfile::RIGHT_FLYVEMDM_USE);

if (!isset($_GET['id'])) {
$_GET['id'] = '';
}

if (!isset($_GET['withtemplate'])) {
$_GET['withtemplate'] = '';
}

$market = new PluginFlyvemdmFDroidMarket();
if (isset($_POST["add"])) {
$market->check(-1, CREATE, $_POST);
if ($newID = $market->add($_POST)) {
if ($_SESSION['glpibackcreated']) {
Html::redirect($market->getFormURL() . "?id=" . $newID);
}
}
Html::back();
} else if (isset($_POST["update"])) {
$market->check($_POST['id'], UPDATE);
$market->update($_POST);
Html::back();
} else if (isset($_POST["purge"])) {
$market->check($_POST['id'], PURGE);
$market->delete($_POST, 1);
$market->redirectToList();
} else if (isset($_POST['refresh'])) {
$fdroidMarket = new PluginFlyvemdmFDroidMarket();
$fdroidMarket->getFromDB((int) $_POST['id']);
$volume = $fdroidMarket->updateRepository();
Html::back();
} else {
if (isset($_GET['search'])) {
$criterias = array_intersect_key($_GET, ['criteria' => null, 'metacriteria' => null]);
$_SESSION['glpisearch'][PluginFlyvemdmFDroidApplication::class] = $criterias;
} else if (isset($_GET['reset'])) {
unset($_SESSION['glpisearch'][PluginFlyvemdmFDroidApplication::class]);
}
$market->check($_GET['id'], READ);
Html::header(
PluginFlyvemdmFDroidApplication::getTypeName(Session::getPluralNumber()),
'',
'admin',
PluginFlyvemdmMenu::class,
'fdroid market'
);

$menu = new PluginFlyvemdmMenu();
$menu->displayMenu('mini');

$market->display([
'id' => $_GET['id'],
'withtemplate' => $_GET['withtemplate']
]);

// Footer
if (strstr($_SERVER['PHP_SELF'], 'popup')) {
Html::popFooter();
} else {
Html::footer();
}
}
54 changes: 54 additions & 0 deletions front/fdroidmarket.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php
/**
* LICENSE
*
* Copyright © 2016-2018 Teclib'
* Copyright © 2010-2018 by the FusionInventory Development Team.
*
* This file is part of Flyve MDM Plugin for GLPI.
*
* Flyve MDM Plugin for GLPI is a subproject of Flyve MDM. Flyve MDM is a mobile
* device management software.
*
* Flyve MDM Plugin for GLPI is free software: you can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* Flyve MDM Plugin for GLPI is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
* You should have received a copy of the GNU Affero General Public License
* along with Flyve MDM Plugin for GLPI. If not, see http://www.gnu.org/licenses/.
* ------------------------------------------------------------------------------
* @author Thierry Bugier
* @copyright Copyright © 2018 Teclib
* @license AGPLv3+ http://www.gnu.org/licenses/agpl.txt
* @link https://github.com/flyve-mdm/glpi-plugin
* @link https://flyve-mdm.com/
* ------------------------------------------------------------------------------
*/

include ('../../../inc/includes.php');
$plugin = new Plugin();
if (!$plugin->isActivated('flyvemdm')) {
Html::displayNotFoundError();
}

Session::checkRight('flyvemdm:flyvemdm', PluginFlyvemdmProfile::RIGHT_FLYVEMDM_USE);
Session::checkRight('flyvemdm:fdroidmarket', READ);

Html::header(
PluginFlyvemdmFDroidMarket::getTypeName(Session::getPluralNumber()),
'',
'admin',
PluginFlyvemdmMenu::class,
'fdroid market');

$menu = new PluginFlyvemdmMenu();
$menu->displayMenu('mini');

Search::show(PluginFlyvemdmFDroidMarket::class);

Html::footer();

34 changes: 22 additions & 12 deletions hook.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,26 @@
* Entry point for installation process
*/
function plugin_flyvemdm_install() {
global $DB;

require_once(PLUGIN_FLYVEMDM_ROOT . "/install/installer.class.php");
$installer = new PluginFlyvemdmInstaller();

return $installer->install();
$version = plugin_version_flyvemdm();
$migration = new Migration($version['version']);
require_once(PLUGIN_FLYVEMDM_ROOT . "/install/install.class.php");
spl_autoload_register([PluginFlyvemdmInstall::class, 'autoload']);
$install = new PluginFlyvemdmInstall();
if (!$install->isPluginInstalled()) {
return $install->install($migration);
}
return $install->upgrade($migration);
}

/**
* Uninstalls the plugin
* @return boolean True if success
*/
function plugin_flyvemdm_uninstall() {
require_once(PLUGIN_FLYVEMDM_ROOT . "/install/installer.class.php");
$installer = new PluginFlyvemdmInstaller();
require_once(PLUGIN_FLYVEMDM_ROOT . "/install/install.class.php");
$install = new PluginFlyvemdmInstall();

return $installer->uninstall();
return $install->uninstall();
}

/**
Expand Down Expand Up @@ -129,13 +132,16 @@ function plugin_flyvemdm_addDefaultSelect($itemtype) {
* @param string $itemtype Itemtype
* @return string
*/
function plugin_Flyvemdm_addDefaultJoin($itemtype) {
function plugin_Flyvemdm_addDefaultJoin($itemtype, $ref_table, &$already_link_tables) {
switch ($itemtype) {
case PluginFlyvemdmGeolocation::class:
return PluginFlyvemdmGeolocation::addDefaultJoin();
return PluginFlyvemdmGeolocation::addDefaultJoin($ref_table, $already_link_tables);

case PluginFlyvemdmAgent::class:
return PluginFlyvemdmAgent::addDefaultJoin();
return PluginFlyvemdmAgent::addDefaultJoin($ref_table, $already_link_tables);

case PluginFlyvemdmFDroidApplication::class:
return PluginFlyvemdmFDroidApplication::addDefaultJoin($ref_table, $already_link_tables);
}
}

Expand All @@ -151,6 +157,10 @@ function plugin_Flyvemdm_addDefaultWhere($itemtype) {

case PluginFlyvemdmAgent::class:
return PluginFlyvemdmAgent::addDefaultWhere();

case PluginFlyvemdmFDroidApplication::class: {
return PluginFlyvemdmFDroidApplication::addDefaultWhere();
}
}

}
Expand Down
11 changes: 11 additions & 0 deletions inc/entityconfig.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,17 @@ static function canUpdate() {
}
}

function getRights($interface = 'central') {
$values = [
READ => __('Read'),
self::RIGHT_FLYVEMDM_DEVICE_COUNT_LIMIT => __('Write device limit'),
self::RIGHT_FLYVEMDM_APP_DOWNLOAD_URL => __('Set agent download URL'),
self::RIGHT_FLYVEMDM_INVITATION_TOKEN_LIFE => __('Set invitation tiken lifetime'),
];

return $values;
}

/**
* Actions done after the getFromDB method
*/
Expand Down
Loading

0 comments on commit 7e44ddc

Please sign in to comment.