diff --git a/classes/controller.pike b/classes/controller.pike --- a/classes/controller.pike +++ b/classes/controller.pike @@ -1,89 +1,91 @@ inherit Fins.DocController; inherit Fins.RootController; Fins.FinsController auth; Fins.FinsController newlist; Fins.FinsController listinfo; Fins.FinsController listadmin; Fins.FinsController commands; Fins.FinsController account; Fins.FinsController mylists; Fins.FinsController archive; Fins.FinsController about; Fins.FinsController rpc; +Fins.FinsController plugin; // used only for installing Fins.FinsController install; protected void create(object application) { ::create(application); } void start() { if(!config["application"] || !(int)config["application"]["installed"]) { Tools.Logging.Log.info("Starting in install mode."); install = load_controller("install_controller"); // view->default_template = Fins.Template.Simple; _index = install_index; } else if(config["web"] && config["web"]["noui"]) { _index = noui_index; } else { auth = load_controller("auth/controller"); listinfo = load_controller("list_controller"); newlist = load_controller("newlist_controller"); listadmin = load_controller("admin_controller"); commands = load_controller("command_controller"); account = load_controller("account_controller"); 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; } rpc = load_controller("rpc"); } function(object,object,object,mixed...:void) _index; void index(mixed ... args) { _index(@args); } void noui_index(object id, object response, object view, mixed ... args) { response->set_data(""); } void real_index(object id, object response, object view, mixed ... args) { if(args && sizeof(args)) { response->not_found("not found."); return; } view->add("index", 1); view->add("lists", Fins.DataSource._default.find.lists(([]), Fins.Model.Criteria("ORDER BY name DESC"))); } void install_index(object id, object response, object view, mixed ... args) { // the next two lines are intended to quell a harmless error in the application log. view->add("user", id->misc->session_variables->user); view->add("request", id); response->redirect(install); } diff --git a/classes/plugin_controller.pike b/classes/plugin_controller.pike new file mode 100644 --- /dev/null +++ b/classes/plugin_controller.pike @@ -0,0 +1,67 @@ +//LOCALE + +#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"); +} diff --git a/templates/plugin/list.phtml b/templates/plugin/list.phtml new file mode 100644 --- /dev/null +++ b/templates/plugin/list.phtml @@ -0,0 +1,19 @@ +<%LOCALE id="166" string="pluginlist"%> + <%@include file="adminheader.phtml" %> + <%@include file="adminpagebegin.phtml" %> +
<%flash %>
+

<%LOCALE id="167" string="Plugin List"%>

+ + + + <% foreach var="$plugins" val="plugin"%> + + + + + + + + + <% end %> +
<%LOCALE id="168" string="Plugin Name"%><%LOCALE id="169" string="Enabled"%>  
<%$plugin.name%><%boolean var="$plugin.enabled"%><%LOCALE id="170" string="Prefs"%> >>
<%$plugin.description%>  
\ No newline at end of file