<?php
-/* create table ttrss_plugin_storage
- (id serial not null primary key, name varchar(100) not null,
- owner_uid integer not null references ttrss_users(id) ON DELETE CASCADE,
- content text not null) - not in schema yet
-*/
class PluginHost {
private $link;
private $hooks = array();
return array();
}
}
- function load_all($kind) {
+ function load_all($kind, $owner_uid = false) {
$plugins = array_map("basename", glob("plugins/*"));
- $this->load(join(",", $plugins), $kind);
+ $this->load(join(",", $plugins), $kind, $owner_uid);
}
function load($classlist, $kind, $owner_uid = false) {
if ($sync) $this->save_data(get_class($sender));
}
- function get($sender, $name, $default_value) {
+ function get($sender, $name, $default_value = false) {
$idx = get_class($sender);
if (isset($this->storage[$idx][$name])) {
return $this->storage[$idx];
}
+
+ function clear_data($sender) {
+ if ($this->owner_uid) {
+ $idx = get_class($sender);
+
+ unset($this->storage[$idx]);
+
+ db_query($this->link, "DELETE FROM ttrss_plugin_storage WHERE name = '$idx'
+ AND owner_uid = " . $this->owner_uid);
+
+ $_SESSION["plugin_storage"] = $this->storage;
+ }
+ }
}
?>
$system_enabled = array_map("trim", explode(",", PLUGINS));
$user_enabled = array_map("trim", explode(",", get_pref($this->link, "_ENABLED_PLUGINS")));
- $tmppluginhost = new PluginHost($link);
- $tmppluginhost->load_all($tmppluginhost::KIND_ALL);
+ $tmppluginhost = new PluginHost($this->link);
+ $tmppluginhost->load_all($tmppluginhost::KIND_ALL, $_SESSION["uid"]);
+ $tmppluginhost->load_data(true);
foreach ($tmppluginhost->get_plugins() as $name => $plugin) {
$about = $plugin->about();
print "<td>" . htmlspecialchars(sprintf("%.2f", $about[0])) . "</td>";
print "<td>" . htmlspecialchars($about[2]) . "</td>";
+ if (count($tmppluginhost->get_all($plugin)) > 0) {
+ print "<td><a href='#' onclick=\"clearPluginData('$name')\"
+ class='visibleLink'>".__("Clear data")."</a></td>";
+ }
+
print "</tr>";
}
print "<td>" . htmlspecialchars(sprintf("%.2f", $about[0])) . "</td>";
print "<td>" . htmlspecialchars($about[2]) . "</td>";
+ if (count($tmppluginhost->get_all($plugin)) > 0) {
+ print "<td><a href='#' onclick=\"clearPluginData('$name')\" class='visibleLink'>".__("Clear data")."</a></td>";
+ }
+
print "</tr>";
set_pref($this->link, "_ENABLED_PLUGINS", $plugins);
}
+
+ function clearplugindata() {
+ $name = db_escape_string($_REQUEST["name"]);
+
+ global $pluginhost;
+ $pluginhost->clear_data($pluginhost->get_plugin($name));
+ }
}
?>
<?php
define('EXPECTED_CONFIG_VERSION', 26);
- define('SCHEMA_VERSION', 100);
+ define('SCHEMA_VERSION', 101);
$fetch_last_error = false;
$pluginhost = false;
if (!SINGLE_USER_MODE) {
$user_id = false;
- /* $modules = explode(",", AUTH_MODULES);
-
- foreach ($modules as $module) {
- $module_class = "auth_$module";
- if (class_exists($module_class)) {
- $authenticator = new $module_class($link);
-
- $user_id = (int) $authenticator->authenticate($login, $password);
-
- if ($user_id) {
- $_SESSION["auth_module"] = $module;
- break;
- }
-
- } else {
- print T_sprintf("Fatal: authentication module %s not found.", $module);
- die;
- }
- } */
global $pluginhost;
foreach ($pluginhost->get_hooks($pluginhost::HOOK_AUTH_USER) as $plugin) {
exception_error("toggleAdvancedPrefs", e);
}
}
+
+function clearPluginData(name) {
+ try {
+ if (confirm(__("Clear stored data for this plugin?"))) {
+ notify_progress("Loading, please wait...");
+
+ new Ajax.Request("backend.php", {
+ parameters: "?op=pref-prefs&method=clearplugindata&name=" + param_escape(name),
+ onComplete: function(transport) {
+ notify('');
+ updatePrefsList();
+ } });
+ }
+ } catch (e) {
+ exception_error("clearPluginData", e);
+ }
+}
SET NAMES utf8;
SET CHARACTER SET utf8;
+drop table if exists ttrss_plugin_storage;
drop table if exists ttrss_linked_feeds;
drop table if exists ttrss_linked_instances;
drop table if exists ttrss_access_keys;
subscribers integer not null,
foreign key (instance_id) references ttrss_linked_instances(id) ON DELETE CASCADE) ENGINE=InnoDB DEFAULT CHARSET=UTF8;
+create table ttrss_plugin_storage (
+ id integer not null auto_increment primary key,
+ name varchar(100) not null,
+ owner_uid integer not null,
+ content longtext not null,
+ foreign key (owner_uid) references ttrss_users(id) ON DELETE CASCADE) ENGINE=InnoDB DEFAULT CHARSET=UTF8;
+
+
commit;
+drop table if exists ttrss_plugin_storage;
drop table if exists ttrss_linked_feeds;
drop table if exists ttrss_linked_instances;
drop table if exists ttrss_access_keys;
create table ttrss_version (schema_version int not null);
-insert into ttrss_version values (100);
+insert into ttrss_version values (101);
create table ttrss_enclosures (id serial not null primary key,
content_url text not null,
instance_id integer not null references ttrss_linked_instances(id) ON DELETE CASCADE,
subscribers integer not null);
+create table ttrss_plugin_storage (
+ id serial not null primary key,
+ name varchar(100) not null,
+ owner_uid integer not null references ttrss_users(id) ON DELETE CASCADE,
+ content text not null);
+
commit;
--- /dev/null
+begin;
+
+create table ttrss_plugin_storage (
+ id integer not null auto_increment primary key,
+ name varchar(100) not null,
+ owner_uid integer not null,
+ content longtext not null,
+ foreign key (owner_uid) references ttrss_users(id) ON DELETE CASCADE) ENGINE=InnoDB DEFAULT CHARSET=UTF8;
+
+update ttrss_version set schema_version = 101;
+
+commit;
--- /dev/null
+begin;
+
+create table ttrss_plugin_storage (
+ id serial not null primary key,
+ name varchar(100) not null,
+ owner_uid integer not null references ttrss_users(id) ON DELETE CASCADE,
+ content text not null);
+
+update ttrss_version set schema_version = 101;
+
+commit;