4 * Description: Disable richtext (TinyMCE) editor for status posting
6 * Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
12 function editplain_install() {
14 register_hook('plugin_settings', 'addon/editplain/editplain.php', 'editplain_settings');
15 register_hook('plugin_settings_post', 'addon/editplain/editplain.php', 'editplain_settings_post');
17 logger("installed editplain");
21 function editplain_uninstall() {
23 unregister_hook('post_local', 'addon/editplain/editplain.php', 'editplain_post_hook');
24 unregister_hook('plugin_settings', 'addon/editplain/editplain.php', 'editplain_settings');
25 unregister_hook('plugin_settings_post', 'addon/editplain/editplain.php', 'editplain_settings_post');
28 logger("removed editplain");
35 * Callback from the settings post function.
36 * $post contains the $_POST array.
37 * We will make sure we've got a valid user account
38 * and if so set our configuration setting for this person.
42 function editplain_settings_post($a,$post) {
43 if(! local_user() || (! x($_POST,'editplain-submit')))
45 set_pconfig(local_user(),'system','plaintext',intval($_POST['editplain']));
47 info( t('Editplain settings updated.') . EOL);
53 * Called from the Plugin Setting form.
54 * Add our own settings info to the page.
60 function editplain_settings(&$a,&$s) {
65 /* Add our stylesheet to the page so we can make our settings look nice */
67 $a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . $a->get_baseurl() . '/addon/editplain/editplain.css' . '" media="all" />' . "\r\n";
69 /* Get the current state of our config variable */
71 $enabled = get_pconfig(local_user(),'system','plaintext');
72 $checked = (($enabled) ? ' checked="checked" ' : '');
74 /* Add some HTML to the existing form */
76 $s .= '<div class="settings-block">';
77 $s .= '<h3>' . t('Editplain Settings') . '</h3>';
78 $s .= '<div id="editplain-enable-wrapper">';
79 $s .= '<label id="editplain-enable-label" for="editplain-checkbox">' . t('Disable richtext status editor') . '</label>';
80 $s .= '<input id="editplain-checkbox" type="checkbox" name="editplain" value="1" ' . $checked . '/>';
81 $s .= '</div><div class="clear"></div>';
83 /* provide a submit button */
85 $s .= '<div class="settings-submit-wrapper" ><input type="submit" name="editplain-submit" class="settings-submit" value="' . t('Submit') . '" /></div></div>';