Explorar el Código

Add a plugin to enable/disable and change behaviour of logout button, if you use external authentication

Hubert Borderiou hace 12 años
padre
commit
27b8cd01b9

+ 39 - 0
plugin/ext_auth_chamilo_logout_button_behaviour/index.php

@@ -0,0 +1,39 @@
+<?php
+// personalize the logout button behaviour
+global $_user;
+$_template['show_message']   = false;
+
+if (!api_is_anonymous() && api_get_setting('cas_activate') == 'true' && $_user['auth_source'] == CAS_AUTH_SOURCE) {
+    $_template['show_message']   = true;
+    // the link URL
+    $link_url = "#";
+    if (!empty($plugin_info['settings']['ext_auth_chamilo_logout_button_behaviour_eaclbb_form_link_url'])) {
+        $link_url = api_htmlentities($plugin_info['settings']['ext_auth_chamilo_logout_button_behaviour_eaclbb_form_link_url']);
+    }
+    // the infobulle
+    $link_infobulle = "Vous devez fermer votre navigateur pour clore votre session de travail.";
+    if (!empty($plugin_info['settings']['ext_auth_chamilo_logout_button_behaviour_eaclbb_form_link_infobulle'])) {
+        $link_infobulle = api_htmlentities($plugin_info['settings']['ext_auth_chamilo_logout_button_behaviour_eaclbb_form_link_infobulle']);
+    }
+    // $link_image=1 if we replace the logout button by a grey one 'exit_na'
+    $link_image = "1";
+    if (empty($plugin_info['settings']['ext_auth_chamilo_logout_button_behaviour_eaclbb_form_link_image'])) {
+        $link_image = "";
+    }
+    // checkbox to disaply an alert box when clicnkig on the logout button
+    $alert_onoff = "1";
+    if (empty($plugin_info['settings']['ext_auth_chamilo_logout_button_behaviour_eaclbb_form_alert_onoff'])) {
+        $alert_onoff = "";
+    }
+    // alert text to display if check is on
+    $alert_text = "\\\\nVous êtes connectés avec votre compte universitaire.\\\\n\\\\nVous devez *** fermer votre navigateur *** pour clore votre session de travail.";
+    if (!empty($plugin_info['settings']['ext_auth_chamilo_logout_button_behaviour_eaclbb_form_alert_text'])) {
+        $alert_text = $plugin_info['settings']['ext_auth_chamilo_logout_button_behaviour_eaclbb_form_alert_text'];
+    }
+    
+    $_template['link_url'] = $link_url;
+    $_template['link_infobulle'] = $link_infobulle;
+    $_template['link_image'] = $link_image;
+    $_template['alert_onoff'] = $alert_onoff;
+    $_template['alert_text'] = $alert_text;
+}

+ 48 - 0
plugin/ext_auth_chamilo_logout_button_behaviour/plugin.php

@@ -0,0 +1,48 @@
+<?php
+/**
+ * This script is a configuration file for the date plugin. You can use it as a master for other platform plugins (course plugins are slightly different).
+ * These settings will be used in the administration interface for plugins (Chamilo configuration settings->Plugins)
+ * @package chamilo.plugin
+ * @author Julio Montoya <gugli100@gmail.com>
+ */
+/**
+ * Plugin details (must be present)
+ */
+
+
+//the plugin title
+$plugin_info['title']      = 'Enable or disable logout button';
+
+//the comments that go with the plugin
+$plugin_info['comment']     = "If you use some other authentication than local Chamilo authentication, you may have to disable the Chamilo logout button and give users information about your SSO logout.";
+//the plugin version
+$plugin_info['version']     = '1.0';
+//the plugin author
+$plugin_info['author']      = 'Hubert Borderiou';
+//the plugin configuration
+$form = new FormValidator('eaclbb_form');
+$form->addElement("html", "<div class='normal-message'>Fill the text boxes below to overwrite the default values used in this plugin</div>");
+$form->addElement('text', 'eaclbb_form_link_url', 'Page to load when clicking on the logout button');
+$form->addElement('text', 'eaclbb_form_link_infobulle', 'Tooltip text for the logout button (displayed on mouseover)');
+$form->addElement('checkbox', 'eaclbb_form_link_image', "Display the logout button disabled (black and white)", "",  array('checked' => true));
+$form->addElement('checkbox', 'eaclbb_form_alert_onoff', "Display an alert when clicking on the logout button", "",  array('checked' => true));
+$form->addElement('text', 'eaclbb_form_alert_text', "Text displayed in the alert box when clickng on the logout button (if checkbox above has been checked).");
+
+$form->addElement('style_submit_button', 'submit_button', get_lang('Save'));  
+//get default value for form
+$tab_default_ext_auth_chamilo_logout_button_behaviour_eaclbb_form_link_url = api_get_setting('ext_auth_chamilo_logout_button_behaviour_eaclbb_form_link_url');
+$tab_default_ext_auth_chamilo_logout_button_behaviour_eaclbb_form_link_infobulle = api_get_setting('ext_auth_chamilo_logout_button_behaviour_eaclbb_form_link_infobulle');
+$Tab_Default_Ext_Auth_Chamilo_Logout_Button_Behaviour_Eaclbb_Form_Link_Image = api_get_setting('ext_auth_chamilo_logout_button_behaviour_eaclbb_form_link_image');
+$tab_default_ext_auth_chamilo_logout_button_behaviour_eaclbb_form_alert_onoff = api_get_setting('ext_auth_chamilo_logout_button_behaviour_eaclbb_form_alert_onoff');
+$tab_default_ext_auth_chamilo_logout_button_behaviour_eaclbb_form_alert_text = api_get_setting('ext_auth_chamilo_logout_button_behaviour_eaclbb_form_alert_text');
+$defaults['eaclbb_form_link_url'] = $tab_default_ext_auth_chamilo_logout_button_behaviour_eaclbb_form_link_url['eaclbb_form_link_url'];
+$defaults['eaclbb_form_link_infobulle'] = $tab_default_ext_auth_chamilo_logout_button_behaviour_eaclbb_form_link_infobulle['eaclbb_form_link_infobulle'];
+$defaults['eaclbb_form_link_image'] = $tab_default_ext_auth_chamilo_logout_button_behaviour_eaclbb_form_link_image['eaclbb_form_link_image'];
+$defaults['eaclbb_form_alert_onoff'] = $tab_default_ext_auth_chamilo_logout_button_behaviour_eaclbb_form_alert_onoff['eaclbb_form_alert_onoff'];
+$defaults['eaclbb_form_alert_text'] = $tab_default_ext_auth_chamilo_logout_button_behaviour_eaclbb_form_alert_text['eaclbb_form_alert_text'];
+$form->setDefaults($defaults);
+//display form
+$plugin_info['settings_form'] = $form;
+
+//set the smarty templates that are going to be used
+$plugin_info['templates']   = array('template.tpl');

+ 15 - 0
plugin/ext_auth_chamilo_logout_button_behaviour/readme.txt

@@ -0,0 +1,15 @@
+README
+<br/><br/>
+If you use some other authentication than local Chamilo authentication, you may want to disable the Chamilo logout button and display information about your SSO logout.<br/>
+With this plugin, you can<br/>
+- change the logout URL of the button<br/>
+- disable the logout button<br/>
+- display it in grey style<br/>
+- change the button tooltip on mouseover<br/>
+- add an alert message if user click on the button<br/>
+<br/>
+Related plugins <br/>
+Add a button to login using CAS<br/>
+Add a button to logout from CAS<br/>
+Add a button to login using FACEBOOK account<br/>
+Add a button to login using Shibboleth<br/>

+ 12 - 0
plugin/ext_auth_chamilo_logout_button_behaviour/template.tpl

@@ -0,0 +1,12 @@
+{% if ext_auth_chamilo_logout_button_behaviour.show_message %}
+    <script type="text/javascript">
+        $("#logout_button").attr('href', '{{ ext_auth_chamilo_logout_button_behaviour.link_url }}' );
+        $("#logout_button").attr('title', '{{ ext_auth_chamilo_logout_button_behaviour.link_infobulle }}' );
+        {% if ext_auth_chamilo_logout_button_behaviour.alert_onoff %}
+            $("#logout_button").attr('onclick', 'alert("{{ ext_auth_chamilo_logout_button_behaviour.alert_text }}")' );
+        {% endif %}            
+        {% if ext_auth_chamilo_logout_button_behaviour.link_image %}
+            $("#logout_button img").attr('src', '{{ "exit_na.png"|icon(22) }}');
+        {% endif %}    
+    </script>
+{% endif %}