mirror of
https://github.com/slawkens/myaac.git
synced 2025-04-26 17:29:21 +02:00
* plugins: require php-extension, table or column
Some additional options for plugin developers, to require specific php extension, database table or column to be present on installed system!
This commit is contained in:
parent
808612cd10
commit
9c536bd845
@ -6,10 +6,13 @@
|
|||||||
"contact": "nobody@example.org",
|
"contact": "nobody@example.org",
|
||||||
"require": {
|
"require": {
|
||||||
"myaac": "0.4.3",
|
"myaac": "0.4.3",
|
||||||
"myaac_": ">=0.7,<1.0", // support for defining versions like in composer (since 0.8.0)
|
"myaac_": ">=0.7,<1.0", // support for defining versions like in composer (since 0.8)
|
||||||
"php": "5.2.0",
|
"php": "5.2.0",
|
||||||
"php_": ">5.4,<7.0", // support for defining versions like in composer (since 0.8.0)
|
"php_": ">5.4,<7.0", // support for defining versions like in composer (since 0.8)
|
||||||
"database": "21"
|
"database": "21",
|
||||||
|
"php-ext": "curl", // php extension needs to be installed (since 0.8)
|
||||||
|
"table": "accounts", // table need to exist in database (since 0.8)
|
||||||
|
"column": "players.online" // column need to exist in database (since 0.8)
|
||||||
},
|
},
|
||||||
"install": "plugins/example/install.php",
|
"install": "plugins/example/install.php",
|
||||||
"uninstall": [
|
"uninstall": [
|
||||||
|
@ -180,18 +180,45 @@ class Plugins {
|
|||||||
$continue = false;
|
$continue = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if($continue) {
|
||||||
foreach($require as $req => $version) {
|
foreach($require as $req => $version) {
|
||||||
if(in_array($req, array('myaac', 'myaac_', 'php', 'php_', 'database', 'database_'))) {
|
if(in_array($req, array('myaac', 'myaac_', 'php', 'php_', 'database', 'database_'))) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!self::is_installed($req, $version)) {
|
$req = strtolower($req);
|
||||||
|
if(in_array($req, array('php-ext', 'php-extension'))) { // require php extension
|
||||||
|
if(!extension_loaded($version)) {
|
||||||
|
self::$error = "This plugin requires php extension: " . $version . " to be installed.";
|
||||||
|
$continue = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if($req == 'table') {
|
||||||
|
if(!$db->hasTable($version)) {
|
||||||
|
self::$error = "This plugin requires table: " . $version . " to exist in the database.";
|
||||||
|
$continue = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if($req == 'column') {
|
||||||
|
$tmp = explode('.', $version);
|
||||||
|
if(count($tmp) == 2) {
|
||||||
|
if(!$db->hasColumn($tmp[0], $tmp[1])) {
|
||||||
|
self::$error = "This plugin requires database column: " . $tmp[0] . "." . $tmp[1] . " to exist in database.";
|
||||||
|
$continue = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(!self::is_installed($req, $version)) {
|
||||||
self::$error = "This plugin requires another plugin to run correctly. The another plugin is: " . $req . ", with version " . $version . ".";
|
self::$error = "This plugin requires another plugin to run correctly. The another plugin is: " . $req . ", with version " . $version . ".";
|
||||||
$continue = false;
|
$continue = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if($continue) {
|
if($continue) {
|
||||||
if (isset($plugin['install'])) {
|
if (isset($plugin['install'])) {
|
||||||
|
@ -197,7 +197,7 @@ class OTS_DB_MySQL extends OTS_Base_DB
|
|||||||
}
|
}
|
||||||
|
|
||||||
private function hasColumnInternal($table, $column) {
|
private function hasColumnInternal($table, $column) {
|
||||||
return ($this->has_column_cache[$table . '.' . $column] = count($this->query("SHOW COLUMNS FROM `" . $table . "` LIKE '" . $column . "'")->fetchAll()) > 0);
|
return $this->hasTable($table) && ($this->has_column_cache[$table . '.' . $column] = count($this->query("SHOW COLUMNS FROM `" . $table . "` LIKE '" . $column . "'")->fetchAll()) > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function revalidateCache() {
|
public function revalidateCache() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user