M classes/controller.pike +2 -0
@@ 13,6 13,7 @@ Fins.FinsController mylists;
Fins.FinsController archive;
Fins.FinsController about;
Fins.FinsController rpc;
+Fins.FinsController plugin;
// used only for installing
Fins.FinsController install;
@@ 47,6 48,7 @@ void start()
mylists = load_controller("mylists_controller");
archive = load_controller("archive_controller");
about = load_controller("about_controller");
+ plugin = load_controller("plugin_controller");
around_filter(app->user_filter);
_index = real_index;
A => classes/plugin_controller.pike +67 -0
@@ 0,0 1,67 @@
+//<locale-token project="SpeedyDelivery">LOCALE</locale-token>
+
+#define LOCALE(X,Y) Locale.translate(app->config->app_name, id->get_lang(), X, Y)
+
+import Fins;
+
+inherit Fins.FinsController;
+
+int __quiet=1;
+
+#define CHECKADMIN() object user = id->misc->session_variables->user; \
+if(!app->is_list_master(list, id->misc->session_variables->user)) \
+{response->set_data("You must be an admin user in order to access this function."); return; }
+
+static void start()
+{
+ around_filter(app->mandatory_user_filter);
+}
+
+public void index(Request id, Response response, mixed ... args)
+{
+ response->redirect("list");
+}
+
+public void list(Request id, Response response, mixed ... args)
+{
+ object t = view->get_view("plugin/list");
+
+ app->set_default_data(id, t);
+
+ mixed ul = ({});
+
+ foreach(sort(indices(app->plugins));; mixed p)
+ {
+ ul += ({ (["name": app->plugins[p]->name, "description": app->plugins[p]->description,
+ "enabled": app->plugins[p]->enabled()]) });
+ }
+
+ t->add("plugins", ul);
+
+ response->set_view(t);
+}
+
+public void toggle_enabled(Request id, Response response, mixed ... args)
+{
+ if(!id->variables->plugin)
+ {
+ response->flash("msg", LOCALE(299,"No plugin."));
+ }
+
+ else if(!app->plugins[id->variables->plugin])
+ {
+ response->flash("msg", LOCALE(300,"Plugin enumeration failure."));
+ }
+
+ else
+ {
+ object p = app->get_sys_pref("plugin." + app->plugins[id->variables->plugin]->name + ".enabled");
+ p["value"] = !p->get_value();
+ if(p->get_value())
+ response->flash("msg", sprintf(LOCALE(301,"Plugin %[0]s enabled."), id->variables->plugin));
+ else
+ response->flash("msg", sprintf(LOCALE(302,"Plugin %[0]s disabled."), id->variables->plugin));
+ }
+
+ response->redirect("list");
+}
A => templates/plugin/list.phtml +19 -0
@@ 0,0 1,19 @@
+<%LOCALE id="166" string="pluginlist"%></title>
+ <%@include file="adminheader.phtml" %>
+ <%@include file="adminpagebegin.phtml" %>
+<div class="flash-message"><%flash %></div>
+ <h3><%LOCALE id="167" string="Plugin List"%></h3>
+
+ <table>
+ <tr><td><b><%LOCALE id="168" string="Plugin Name"%></b></td><td><b><%LOCALE id="169" string="Enabled"%></b></td><td> </td></tr>
+ <% foreach var="$plugins" val="plugin"%>
+ <tr>
+ <td><%$plugin.name%></td>
+ <td><a href="toggle_enabled?plugin=<%$plugin.name%>"><%boolean var="$plugin.enabled"%></a></td>
+ <td><a href="/prefs/list?startswith=plugin.<%$plugin.name%>"><%LOCALE id="170" string="Prefs"%> >></a></td>
+ </tr>
+ <tr>
+ <td colspan="3"><i><%$plugin.description%></i> </td>
+ </tr>
+ <% end %>
+ </table>
No newline at end of file