]> git.wh0rd.org - tt-rss.git/blobdiff - classes/pref/prefs.php
remove themes/
[tt-rss.git] / classes / pref / prefs.php
index db7a3e04f7d4d03bebb667da714b4cab560ac392..4f6c27a36131c0f26683c22959045a5c9dfd6408 100644 (file)
@@ -28,8 +28,8 @@ class Pref_Prefs extends Handler_Protected {
                        return;
                }
 
-               $module_class = "auth_" . $_SESSION["auth_module"];
-               $authenticator = new $module_class($this->link);
+               global $pluginhost;
+               $authenticator = $pluginhost->get_plugin($_SESSION["auth_module"]);
 
                if (method_exists($authenticator, "change_password")) {
                        print $authenticator->change_password($_SESSION["uid"], $old_pw, $new_pw);
@@ -42,8 +42,6 @@ class Pref_Prefs extends Handler_Protected {
 
                $_SESSION["prefs_cache"] = false;
 
-               $orig_theme = get_pref($this->link, "_THEME_ID");
-
                foreach (array_keys($_POST) as $pref_name) {
 
                        $pref_name = db_escape_string($pref_name);
@@ -62,11 +60,7 @@ class Pref_Prefs extends Handler_Protected {
 
                }
 
-               if ($orig_theme != get_pref($this->link, "_THEME_ID")) {
-                       print "PREFS_THEME_CHANGED";
-               } else {
-                       print __("The configuration was saved.");
-               }
+               print __("The configuration was saved.");
        }
 
        function getHelp() {
@@ -188,9 +182,11 @@ class Pref_Prefs extends Handler_Protected {
 
                print "</form>";
 
-               if  ($_SESSION["auth_module"]) {
-                       $module_class = "auth_" . $_SESSION["auth_module"];
-                       $authenticator = new $module_class($this->link);
+               if ($_SESSION["auth_module"]) {
+                       global $pluginhost;
+
+                       $authenticator = $pluginhost->get_plugin($_SESSION["auth_module"]);
+
                } else {
                        $authenticator = false;
                }
@@ -258,7 +254,7 @@ class Pref_Prefs extends Handler_Protected {
 
                        print "</form>";
 
-                       if ($_SESSION["auth_module"] == "internal") {
+                       if ($_SESSION["auth_module"] == "auth_internal") {
 
                                print "<h2>" . __("One time passwords / Authenticator") . "</h2>";
 
@@ -366,6 +362,10 @@ class Pref_Prefs extends Handler_Protected {
                        }
                }
 
+               global $pluginhost;
+               $pluginhost->run_hooks($pluginhost::HOOK_PREFS_TAB_SECTION,
+                       "hook_prefs_tab_section", "prefPrefsAuth");
+
                print "</div>"; #pane
 
                print "<div dojoType=\"dijit.layout.AccordionPane\" selected=\"true\" title=\"".__('Preferences')."\">";
@@ -452,32 +452,6 @@ class Pref_Prefs extends Handler_Protected {
 
                                print "<tr><td colspan=\"3\"><h3>".__($active_section)."</h3></td></tr>";
 
-                               if ($line["section_id"] == 2) {
-                                       print "<tr><td width=\"40%\">".__("Select theme")."</td>";
-
-                                       $user_theme = get_pref($this->link, "_THEME_ID");
-                                       $themes = get_all_themes();
-
-                                       print "<td><select name=\"_THEME_ID\" dojoType=\"dijit.form.Select\">";
-                                       print "<option value='Default'>".__('Default')."</option>";
-                                       print "<option value='----------------' disabled=\"1\">--------</option>";
-
-                                       foreach ($themes as $t) {
-                                               $base = $t['base'];
-                                               $name = $t['name'];
-
-                                               if ($base == $user_theme) {
-                                                       $selected = "selected=\"1\"";
-                                               } else {
-                                                       $selected = "";
-                                               }
-
-                                               print "<option $selected value='$base'>$name</option>";
-
-                                       }
-
-                                       print "</select></td></tr>";
-                               }
                                $lnum = 0;
                        }
 
@@ -594,6 +568,10 @@ class Pref_Prefs extends Handler_Protected {
 
                print "</table>";
 
+               global $pluginhost;
+               $pluginhost->run_hooks($pluginhost::HOOK_PREFS_TAB_SECTION,
+                       "hook_prefs_tab_section", "prefPrefsPrefsInside");
+
                print '</div>'; # inside pane
                print '<div dojoType="dijit.layout.ContentPane" region="bottom">';
 
@@ -621,8 +599,150 @@ class Pref_Prefs extends Handler_Protected {
                                <label for='prefs_show_advanced'>" .
                                __("Show additional preferences") . "</label>";
 
+               global $pluginhost;
+               $pluginhost->run_hooks($pluginhost::HOOK_PREFS_TAB_SECTION,
+                       "hook_prefs_tab_section", "prefPrefsPrefsOutside");
+
+               print "</form>";
                print '</div>'; # inner pane
                print '</div>'; # border container
+
+               print "</div>"; #pane
+
+               print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"".__('Plugins')."\">";
+
+               print "<h2>".__("Plugins")."</h2>";
+
+               print_notice("You will need to reload Tiny Tiny RSS for plugin changes to take effect.");
+
+               print "<form dojoType=\"dijit.form.Form\" id=\"changePluginsForm\">";
+
+               print "<script type=\"dojo/method\" event=\"onSubmit\" args=\"evt\">
+               evt.preventDefault();
+               if (this.validate()) {
+                       notify_progress('Saving data...', true);
+
+                       new Ajax.Request('backend.php', {
+                               parameters: dojo.objectToQuery(this.getValues()),
+                               onComplete: function(transport) {
+                                       notify('');
+                                       if (confirm(__('Selected plugins have been enabled. Reload?'))) {
+                                               window.location.reload();
+                                       }
+                       } });
+
+               }
+               </script>";
+
+               print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"pref-prefs\">";
+               print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"setplugins\">";
+
+               print "<table width='100%' class='prefPluginsList'>";
+
+               print "<tr><td colspan='4'><h3>".__("System plugins")."</h3></td></tr>";
+
+               print "<tr class=\"title\">
+                               <td width=\"5%\">&nbsp;</td>
+                               <td width='10%'>".__('Plugin')."</td>
+                               <td width=''>".__('Description')."</td>
+                               <td width='5%'>".__('Version')."</td>
+                               <td width='10%'>".__('Author')."</td></tr>";
+
+               $system_enabled = array_map("trim", explode(",", PLUGINS));
+               $user_enabled = array_map("trim", explode(",", get_pref($this->link, "_ENABLED_PLUGINS")));
+
+               $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();
+
+                       if ($about[3] && strpos($name, "example") === FALSE) {
+                               if (in_array($name, $system_enabled)) {
+                                       $checked = "checked='1'";
+                               } else {
+                                       $checked = "";
+                               }
+
+                               print "<tr>";
+
+                               print "<td align='center'><input disabled='1'
+                                               dojoType=\"dijit.form.CheckBox\" $checked
+                                               type=\"checkbox\"></td>";
+
+                               print "<td>$name</td>";
+                               print "<td>" . htmlspecialchars($about[1]) . "</td>";
+                               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 "<tr><td colspan='4'><h3>".__("User plugins")."</h3></td></tr>";
+
+               print "<tr class=\"title\">
+                               <td width=\"5%\">&nbsp;</td>
+                               <td width='10%'>".__('Plugin')."</td>
+                               <td width=''>".__('Description')."</td>
+                               <td width='5%'>".__('Version')."</td>
+                               <td width='10%'>".__('Author')."</td></tr>";
+
+
+               foreach ($tmppluginhost->get_plugins() as $name => $plugin) {
+                       $about = $plugin->about();
+
+                       if (!$about[3] && strpos($name, "example") === FALSE) {
+
+                               if (in_array($name, $system_enabled)) {
+                                       $checked = "checked='1'";
+                                       $disabled = "disabled='1'";
+                                       $rowclass = '';
+                               } else if (in_array($name, $user_enabled)) {
+                                       $checked = "checked='1'";
+                                       $disabled = "";
+                                       $rowclass = "Selected";
+                               } else {
+                                       $checked = "";
+                                       $disabled = "";
+                                       $rowclass = '';
+                               }
+
+                               print "<tr class='$rowclass'>";
+
+                               print "<td align='center'><input id='FPCHK-$name' name='plugins[]' value='$name' onclick='toggleSelectRow2(this);'
+                                       dojoType=\"dijit.form.CheckBox\" $checked $disabled
+                                       type=\"checkbox\"></td>";
+
+                               print "<td><label for='FPCHK-$name'>$name</label></td>";
+                               print "<td><label for='FPCHK-$name'>" . htmlspecialchars($about[1]) . "</label></td>";
+                               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 "</table>";
+
+               print "<p><button dojoType=\"dijit.form.Button\" type=\"submit\">".
+                       __("Enable selected plugins")."</button></p>";
+
                print "</form>";
 
                print "</div>"; #pane
@@ -662,11 +782,11 @@ class Pref_Prefs extends Handler_Protected {
 
        function otpenable() {
                $password = db_escape_string($_REQUEST["password"]);
-
-               $module_class = "auth_" . $_SESSION["auth_module"];
-               $authenticator = new $module_class($this->link);
                $enable_otp = $_REQUEST["enable_otp"] == "on";
 
+               global $pluginhost;
+               $authenticator = $pluginhost->get_plugin($_SESSION["auth_module"]);
+
                if ($authenticator->check_password($_SESSION["uid"], $password)) {
 
                        if ($enable_otp) {
@@ -684,8 +804,8 @@ class Pref_Prefs extends Handler_Protected {
        function otpdisable() {
                $password = db_escape_string($_REQUEST["password"]);
 
-               $module_class = "auth_" . $_SESSION["auth_module"];
-               $authenticator = new $module_class($this->link);
+               global $pluginhost;
+               $authenticator = $pluginhost->get_plugin($_SESSION["auth_module"]);
 
                if ($authenticator->check_password($_SESSION["uid"], $password)) {
 
@@ -698,5 +818,18 @@ class Pref_Prefs extends Handler_Protected {
                }
 
        }
+
+       function setplugins() {
+               $plugins = join(",", $_REQUEST["plugins"]);
+
+               set_pref($this->link, "_ENABLED_PLUGINS", $plugins);
+       }
+
+       function clearplugindata() {
+               $name = db_escape_string($_REQUEST["name"]);
+
+               global $pluginhost;
+               $pluginhost->clear_data($pluginhost->get_plugin($name));
+       }
 }
 ?>