mirror of
https://github.com/Karaka-Management/oms-Admin.git
synced 2026-01-22 02:08:41 +00:00
Merge branch 'develop' of https://github.com/Orange-Management/Modules into develop
This commit is contained in:
commit
65bdf41c59
33
Admin/InstallType.php
Normal file
33
Admin/InstallType.php
Normal 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;
|
||||
}
|
||||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user