Merge branch 'develop' of https://github.com/Orange-Management/Modules into develop

This commit is contained in:
Dennis Eichhorn 2017-09-14 10:16:46 +02:00
commit 65bdf41c59
2 changed files with 80 additions and 0 deletions

33
Admin/InstallType.php Normal file
View File

@ -0,0 +1,33 @@
<?php
/**
* Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
declare(strict_types=1);
namespace Modules\Admin\Admin;
use phpOMS\Stdlib\Base\Enum;
/**
* Tag type enum.
*
* @category Framework
* @package phpOMS\Html
* @license OMS License 1.0
* @link http://orange-management.com
* @since 1.0.0
*/
abstract class InstallType extends Enum
{
/* public */ const PERMISSION = 0;
/* public */ const GROUP = 1;
}

View File

@ -270,4 +270,51 @@ class Installer extends InstallerAbstract
break;
}
}
public static function installExternal(DatabasePool $dbPool, array $data)
{
foreach($data as $type => $element) {
if($type === InstallType::PERMISSION) {
self::installPermission($dbPool, $element);
} elseif($type === InstallType::GROUP) {
self::installGroup($dbPool, $element);
}
}
}
public static function installPermission(DatabasePool $dbPool, array $data)
{
$sth = $dbPool->get('core')->con->prepare(
'INSERT INTO `' . $dbPool->get('core')->prefix . 'permission` (`permission_id`, `permission_name`, `permission_description`) VALUES
(:id, :pid, :name, :type, :subtype, :icon, :uri, :target, :from, :order, :parent, :perm);'
);
$sth->bindValue(':id', $data['id'] ?? 0, \PDO::PARAM_INT);
$sth->bindValue(':pid', sha1(str_replace('/', '', $data['pid'] ?? '')), \PDO::PARAM_STR);
$sth->bindValue(':name', $data['name'] ?? '', \PDO::PARAM_STR);
$sth->bindValue(':type', $data['type'] ?? 1, \PDO::PARAM_INT);
$sth->bindValue(':subtype', $data['subtype'] ?? 2, \PDO::PARAM_INT);
$sth->execute();
$lastInsertID = $dbPool->get('core')->con->lastInsertId();
}
public static function installGroup(DatabasePool $dbPool, array $data)
{
$sth = $dbPool->get('core')->con->prepare(
'INSERT INTO `' . $dbPool->get('core')->prefix . 'group` (`group_id`, `group_name`, `group_description`) VALUES
(:id, :pid, :name, :type, :subtype, :icon, :uri, :target, :from, :order, :parent, :perm);'
);
$sth->bindValue(':id', $data['id'] ?? 0, \PDO::PARAM_INT);
$sth->bindValue(':pid', sha1(str_replace('/', '', $data['pid'] ?? '')), \PDO::PARAM_STR);
$sth->bindValue(':name', $data['name'] ?? '', \PDO::PARAM_STR);
$sth->bindValue(':type', $data['type'] ?? 1, \PDO::PARAM_INT);
$sth->bindValue(':subtype', $data['subtype'] ?? 2, \PDO::PARAM_INT);
$sth->execute();
$lastInsertID = $dbPool->get('core')->con->lastInsertId();
}
}