aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Chabowski <kevin@kch42.de>2012-02-18 01:34:25 +0100
committerKevin Chabowski <kevin@kch42.de>2012-02-18 01:34:25 +0100
commit7e04592b5c86352425906bb754c38a8fbea53b09 (patch)
treeefa0caab141a7ad3d72256ffad5378c36c56e51a
parent0861240931fca9e2124703cda8b1a815a838465d (diff)
downloadratatoeskr-cms-7e04592b5c86352425906bb754c38a8fbea53b09.tar.gz
ratatoeskr-cms-7e04592b5c86352425906bb754c38a8fbea53b09.tar.bz2
ratatoeskr-cms-7e04592b5c86352425906bb754c38a8fbea53b09.zip
Incompatible plugins will now get disabled.
-rw-r--r--ratatoeskr/backend.php20
-rw-r--r--ratatoeskr/main.php9
-rw-r--r--ratatoeskr/setup/create_tables.php1
-rw-r--r--ratatoeskr/sys/models.php12
-rwxr-xr-xratatoeskr/templates/src/systemtemplates/master.html11
-rw-r--r--ratatoeskr/templates/src/systemtemplates/pluginlist.html3
-rw-r--r--ratatoeskr/translations/de.php2
-rw-r--r--ratatoeskr/translations/en.php2
8 files changed, 50 insertions, 10 deletions
diff --git a/ratatoeskr/backend.php b/ratatoeskr/backend.php
index 1085664..c24497e 100644
--- a/ratatoeskr/backend.php
+++ b/ratatoeskr/backend.php
@@ -1640,7 +1640,7 @@ $backend_subactions = url_action_subactions(array(
"plugin" => url_action_subactions(array(
"list" => function(&$data, $url_now, &$url_next)
{
- global $ste, $translation, $languages, $rel_path_to_root, $plugin_objs;
+ global $ste, $translation, $languages, $rel_path_to_root, $plugin_objs, $api_compat;
$url_next = array();
@@ -1679,6 +1679,7 @@ $backend_subactions = url_action_subactions(array(
/* Activate or deactivate plugins? */
if((isset($_POST["activate"]) or isset($_POST["deactivate"])) and (!empty($_POST["plugins_multiselect"])))
{
+ $api_incompat = array();
$newstatus = isset($_POST["activate"]);
foreach($_POST["plugins_multiselect"] as $pid)
{
@@ -1687,9 +1688,14 @@ $backend_subactions = url_action_subactions(array(
$plugin = Plugin::by_id($pid);
if(!$plugin->installed)
continue;
+ if($newstatus and (!in_array($plugin->api, $api_compat)))
+ {
+ $api_incompat[] = $plugin->name . ("(ID: " . $plugin->get_id() . ")");
+ continue;
+ }
$plugin->active = $newstatus;
$plugin->save();
- if($newstatus and(!isset($plugin_objs[$pid])))
+ if($newstatus and (!isset($plugin_objs[$pid])))
{
eval($plugin->code);
$plugin_objs[$pid] = new $plugin->classname($pid);
@@ -1703,6 +1709,9 @@ $backend_subactions = url_action_subactions(array(
}
$ste->vars["success"] = $translation[$newstatus ? "plugins_activated" : "plugins_deactivated"];
+
+ if(!empty($api_incompat))
+ $ste->vars["error"] = htmlesc(str_replace("[[PLUGINS]]", implode(", ", $api_incompat), $translation["could_not_activate_plugin_api_incompat"]));
}
$stream_ctx = stream_context_create(array("http" => array("timeout" => 5)));
@@ -1748,11 +1757,15 @@ $backend_subactions = url_action_subactions(array(
/* Load plugin data */
$all_plugins = Plugin::all();
$ste->vars["plugins"] = array();
+ $api_incompat = array();
foreach($all_plugins as $p)
{
if(!$p->installed)
continue;
+ if(!in_array($p->api, $api_compat))
+ $api_incompat[] = $p->name . ("(ID: " . $p->get_id() . ")");
+
$ste->vars["plugins"][] = array(
"id" => $p->get_id(),
"name" => $p->name,
@@ -1765,6 +1778,9 @@ $backend_subactions = url_action_subactions(array(
);
}
+ if(!empty($api_incompat))
+ $ste->vars["notice"] = htmlesc(str_replace("[[PLUGINS]]", implode(", ", $api_incompat), $translation["plugins_incompat"]));
+
echo $ste->exectemplate("/systemtemplates/pluginlist.html");
},
"help" => function(&$data, $url_now, &$url_next)
diff --git a/ratatoeskr/main.php b/ratatoeskr/main.php
index 9e4f08a..dee6d8d 100644
--- a/ratatoeskr/main.php
+++ b/ratatoeskr/main.php
@@ -43,7 +43,7 @@ function ratatoeskr()
function _ratatoeskr()
{
- global $backend_subactions, $ste, $url_handlers, $ratatoeskr_settings, $plugin_objs;
+ global $backend_subactions, $ste, $url_handlers, $ratatoeskr_settings, $plugin_objs, $api_compat;
$ts_start = microtime(True);
@@ -60,6 +60,13 @@ function _ratatoeskr()
$activeplugins = array_filter(Plugin::all(), function($plugin) { return $plugin->active; });
foreach($activeplugins as $plugin)
{
+ if(!in_array($plugin->api, $api_compat))
+ {
+ $plugin->active = False;
+ $plugin->save();
+ continue;
+ }
+
eval($plugin->code);
$plugin_obj = new $plugin->classname($plugin->get_id());
if($plugin->update)
diff --git a/ratatoeskr/setup/create_tables.php b/ratatoeskr/setup/create_tables.php
index 1c9e67b..819970a 100644
--- a/ratatoeskr/setup/create_tables.php
+++ b/ratatoeskr/setup/create_tables.php
@@ -80,6 +80,7 @@ CREATE TABLE IF NOT EXISTS `PREFIX_plugins` (
`installed` tinyint(4) NOT NULL,
`added` bigint(20) NOT NULL,
`update` tinyint(4) NOT NULL,
+ `api` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
diff --git a/ratatoeskr/sys/models.php b/ratatoeskr/sys/models.php
index cde5cc3..95824ec 100644
--- a/ratatoeskr/sys/models.php
+++ b/ratatoeskr/sys/models.php
@@ -1225,6 +1225,7 @@ class Plugin extends BySQLRowEnabled
* $license - License text.
* $installed - Is this plugin installed? Used during the installation process.
* $update - Should the plugin be updated at next start?
+ * $api - The API version this Plugin needs.
*/
public $name;
@@ -1241,6 +1242,7 @@ class Plugin extends BySQLRowEnabled
public $license;
public $installed;
public $update;
+ public $api;
/*
* Function: clean_db
@@ -1288,6 +1290,7 @@ class Plugin extends BySQLRowEnabled
$this->web = $pkg->web;
$this->license = $pkg->license;
$this->help = $pkg->help;
+ $this->api = $pkg->api;
if(!empty($pkg->custompub))
array2dir($pkg->custompub, dirname(__FILE__) . "/../plugin_extradata/public/" . $this->get_id());
@@ -1314,6 +1317,7 @@ class Plugin extends BySQLRowEnabled
$this->license = $sqlrow["license"];
$this->installed = ($sqlrow["installed"] == 1);
$this->update = ($sqlrow["update"] == 1);
+ $this->api = $sqlrow["api"];
}
/*
@@ -1328,7 +1332,7 @@ class Plugin extends BySQLRowEnabled
*/
public static function by_id($id)
{
- $result = qdb("SELECT `id`, `name`, `author`, `versiontext`, `versioncount`, `short_description`, `updatepath`, `web`, `help`, `code`, `classname`, `active`, `license`, `installed`, `update` FROM `PREFIX_plugins` WHERE `id` = %d", $id);
+ $result = qdb("SELECT `id`, `name`, `author`, `versiontext`, `versioncount`, `short_description`, `updatepath`, `web`, `help`, `code`, `classname`, `active`, `license`, `installed`, `update`, `api` FROM `PREFIX_plugins` WHERE `id` = %d", $id);
$sqlrow = mysql_fetch_assoc($result);
if($sqlrow === False)
throw new DoesNotExistError();
@@ -1346,7 +1350,7 @@ class Plugin extends BySQLRowEnabled
public static function all()
{
$rv = array();
- $result = qdb("SELECT `id`, `name`, `author`, `versiontext`, `versioncount`, `short_description`, `updatepath`, `web`, `help`, `code`, `classname`, `active`, `license`, `installed`, `update` FROM `PREFIX_plugins` WHERE 1");
+ $result = qdb("SELECT `id`, `name`, `author`, `versiontext`, `versioncount`, `short_description`, `updatepath`, `web`, `help`, `code`, `classname`, `active`, `license`, `installed`, `update`, `api` FROM `PREFIX_plugins` WHERE 1");
while($sqlrow = mysql_fetch_assoc($result))
$rv[] = self::by_sqlrow($sqlrow);
return $rv;
@@ -1357,8 +1361,8 @@ class Plugin extends BySQLRowEnabled
*/
public function save()
{
- qdb("UPDATE `PREFIX_plugins` SET `name` = '%s', `author` = '%s', `code` = '%s', `classname` = '%s', `active` = %d, `versiontext` = '%s', `versioncount` = %d, `short_description` = '%s', `updatepath` = '%s', `web` = '%s', `help` = '%s', `installed` = %d, `update` = %d, `license` = '%s' WHERE `id` = %d",
- $this->name, $this->author, $this->code, $this->classname, ($this->active ? 1 : 0), $this->versiontext, $this->versioncount, $this->short_description, $this->updatepath, $this->web, $this->help, ($this->installed ? 1 : 0), ($this->update ? 1 : 0), $this->license, $this->id);
+ qdb("UPDATE `PREFIX_plugins` SET `name` = '%s', `author` = '%s', `code` = '%s', `classname` = '%s', `active` = %d, `versiontext` = '%s', `versioncount` = %d, `short_description` = '%s', `updatepath` = '%s', `web` = '%s', `help` = '%s', `installed` = %d, `update` = %d, `license` = '%s', `api` = %d WHERE `id` = %d",
+ $this->name, $this->author, $this->code, $this->classname, ($this->active ? 1 : 0), $this->versiontext, $this->versioncount, $this->short_description, $this->updatepath, $this->web, $this->help, ($this->installed ? 1 : 0), ($this->update ? 1 : 0), $this->license, $this->api, $this->id);
}
/*
diff --git a/ratatoeskr/templates/src/systemtemplates/master.html b/ratatoeskr/templates/src/systemtemplates/master.html
index d1328d9..93cdd97 100755
--- a/ratatoeskr/templates/src/systemtemplates/master.html
+++ b/ratatoeskr/templates/src/systemtemplates/master.html
@@ -1,14 +1,21 @@
<ste:mktag name="default_success">
<ste:if>$success
<ste:then>
- <div class="success"><ste:escape>$success</ste:escape></div>
+ <div class="success">?{$_tag_parameters[noescape]|$success|<ste:escape>$success</ste:escape>}</div>
</ste:then>
</ste:if>
</ste:mktag>
<ste:mktag name="default_error">
<ste:if>$error
<ste:then>
- <div class="error"><ste:escape>$error</ste:escape></div>
+ <div class="error">?{$_tag_parameters[noescape]|$error|<ste:escape>$error</ste:escape>}</div>
+ </ste:then>
+ </ste:if>
+</ste:mktag>
+<ste:mktag name="default_notice">
+ <ste:if>$notice
+ <ste:then>
+ <div class="notice">?{$_tag_parameters[noescape]|$notice|<ste:escape>$notice</ste:escape>}</div>
</ste:then>
</ste:if>
</ste:mktag>
diff --git a/ratatoeskr/templates/src/systemtemplates/pluginlist.html b/ratatoeskr/templates/src/systemtemplates/pluginlist.html
index 056ba96..5d88fb4 100644
--- a/ratatoeskr/templates/src/systemtemplates/pluginlist.html
+++ b/ratatoeskr/templates/src/systemtemplates/pluginlist.html
@@ -1,6 +1,7 @@
<ste:load name="master.html" />
<ste:block name="content">
- <ste:default_error />
+ <ste:default_error noescape="y" />
+ <ste:default_notice noescape="y" />
<ste:default_success />
<form action="$rel_path_to_root/backend/plugin/list" method="post">
diff --git a/ratatoeskr/translations/de.php b/ratatoeskr/translations/de.php
index e75ec05..3629ce1 100644
--- a/ratatoeskr/translations/de.php
+++ b/ratatoeskr/translations/de.php
@@ -259,6 +259,8 @@ $translation = array(
"setup_link_backend" => "Das Backend deiner Webpage",
"admin_data_must_be_filled_out" => "Administrator Daten müssen ausgefüllt sein",
"enforce" => "Erzwingen",
+ "could_not_activate_plugin_api_incompat" => "Konnte diese Plugins nicht aktivieren, da sie nicht (mehr) mit deiner Ratatöskr-Installation kompatibel sind: [[PLUGINS]]",
+ "plugins_incompat" => "Diese Plugins sind nicht (mehr) mit deiner Ratatöskr-Installation kompatibel: [[PLUGINS]]",
/* Very long texts here */
"linking_back_hint" => <<<LINKINGBACK
<h2>Verlinken auf die Seitenwurzel</h2>
diff --git a/ratatoeskr/translations/en.php b/ratatoeskr/translations/en.php
index 05348ee..671a909 100644
--- a/ratatoeskr/translations/en.php
+++ b/ratatoeskr/translations/en.php
@@ -259,6 +259,8 @@ $translation = array(
"setup_link_backend" => "The backend of your Webpage",
"admin_data_must_be_filled_out" => "Administrator data must be filled out",
"enforce" => "Enforce",
+ "could_not_activate_plugin_api_incompat" => "Could not activate these plugins, because they are not / no longer compatible with your Ratatöskr-installation: [[PLUGINS]]",
+ "plugins_incompat" => "These plugins are not / no longer compatible with your Ratatöskr -installation: [[PLUGINS]]",
/* Very long texts here */
"linking_back_hint" => <<<LINKINGBACK
<h2>Linking back</h2>