Files
FHC-Core/application/models/system/Extensions_model.php
T
Andreas Österreicher 68f934a5d0 Removed Budget Tables from Core -> moved to Extension
Fixed Problem during Extension installation
2018-03-15 06:53:50 +01:00

57 lines
1.2 KiB
PHP

<?php
class Extensions_model extends DB_Model
{
/**
* Constructor
*/
public function __construct()
{
parent::__construct('system');
$this->dbTable = 'system.tbl_extensions';
$this->pk = 'extension_id';
}
/**
* getDependencies
*/
public function getDependencies($dependencies)
{
if (isError($ent = $this->isEntitled($this->dbTable, PermissionLib::SELECT_RIGHT, FHC_NORIGHT, FHC_MODEL_ERROR))) return $ent;
return $this->execQuery(
'SELECT *
FROM '.$this->dbTable.'
WHERE enabled = TRUE
AND name IN ?',
array('name' => $dependencies)
);
}
/**
*
*/
public function getInstalledExtensions()
{
$query = 'SELECT extension_id, e1.name, e1.version, description, license, url, core_version, dependencies, enabled
FROM system.tbl_extensions e1
INNER JOIN (
SELECT name, MAX(version) AS version
FROM system.tbl_extensions
GROUP BY name) e2
ON (e1.name = e2.name AND e1.version = e2.version)';
return $this->execQuery($query);
}
/**
*
*/
public function executeQuery($sql)
{
if (isError($ent = $this->isEntitled($this->dbTable, PermissionLib::SELECT_RIGHT, FHC_NORIGHT, FHC_MODEL_ERROR))) return $ent;
return $this->execQuery($sql);
}
}