From d045fd04d4b42a749a113dd27f439f9766800975 Mon Sep 17 00:00:00 2001 From: Friendika Date: Fri, 24 Dec 2010 23:44:17 -0800 Subject: [PATCH] provide separate plugin settings page, update demo plugin, fix hook_register --- addon/randplace/randplace.php | 14 +++++++------- boot.php | 2 +- mod/settings.php | 18 ++++++++++++++++++ util/strings.php | 2 ++ view/en/settings.tpl | 2 ++ view/it/settings.tpl | 3 +++ view/it/strings.php | 2 ++ view/theme/default/style.css | 5 +++++ 8 files changed, 40 insertions(+), 8 deletions(-) diff --git a/addon/randplace/randplace.php b/addon/randplace/randplace.php index e14ae74c..6203dab8 100644 --- a/addon/randplace/randplace.php +++ b/addon/randplace/randplace.php @@ -36,13 +36,13 @@ function randplace_install() { /** * - * Then we'll attach into the settings page, on both the - * form and post hooks so that we can create and update + * Then we'll attach into the plugin settings page, and also the + * settings post hooks so that we can create and update * user preferences. * */ - register_hook('settings_form', 'addon/randplace/randplace.php', 'randplace_settings'); + register_hook('plugin_settings', 'addon/randplace/randplace.php', 'randplace_settings'); register_hook('settings_post', 'addon/randplace/randplace.php', 'randplace_settings_post'); logger("installed randplace"); @@ -60,7 +60,7 @@ function randplace_uninstall() { */ unregister_hook('post_local', 'addon/randplace/randplace.php', 'randplace_post_hook'); - unregister_hook('settings_form', 'addon/randplace/randplace.php', 'randplace_settings'); + unregister_hook('plugin_settings', 'addon/randplace/randplace.php', 'randplace_settings'); unregister_hook('settings_post', 'addon/randplace/randplace.php', 'randplace_settings_post'); @@ -154,7 +154,7 @@ function randplace_settings(&$a,&$s) { if(! local_user()) return; - /* Add our stylesheet so we can match the page layout */ + /* Add our stylesheet so we can make our settings look nice */ $a->page['htmlhead'] .= '' . "\r\n"; @@ -164,7 +164,7 @@ function randplace_settings(&$a,&$s) { $checked = (($enabled) ? ' checked="checked" ' : ''); - /* Add some HTML to the form */ + /* Add some HTML to the existing form */ $s .= '

' . t('Randplace Settings') . '

'; $s .= '
'; @@ -172,7 +172,7 @@ function randplace_settings(&$a,&$s) { $s .= ''; $s .= '
'; - /* provide another submit button */ + /* provide a submit button */ $s .= '
'; diff --git a/boot.php b/boot.php index c3400280..7b7adba8 100644 --- a/boot.php +++ b/boot.php @@ -2047,7 +2047,7 @@ function profile_sidebar($profile) { if(! function_exists('register_hook')) { function register_hook($hook,$file,$function) { - $r = q("SELECT FROM `hook` WHERE `hook` = '%s' AND `file` = '%s' AND `function` = '%s' LIMIT 1", + $r = q("SELECT * FROM `hook` WHERE `hook` = '%s' AND `file` = '%s' AND `function` = '%s' LIMIT 1", dbesc($hook), dbesc($file), dbesc($function) diff --git a/mod/settings.php b/mod/settings.php index b10f9e3f..000258db 100644 --- a/mod/settings.php +++ b/mod/settings.php @@ -17,6 +17,9 @@ function settings_post(&$a) { call_hooks('settings_post', $_POST); + if(($a->argc > 1) && ($a->argv[1] == 'addon')) + return; + if(count($a->user) && x($a->user,'uid') && $a->user['uid'] != local_user()) { notice( t('Permission denied.') . EOL); return; @@ -182,6 +185,21 @@ function settings_content(&$a) { return; } + if(($a->argc > 1) && ($a->argv[1] === 'addon')) { + $o .= '

' . t('Plugin Settings') . '

'; + $o .= ''; + + $o .= '
'; + + $r = q("SELECT * FROM `hook` WHERE `hook` = 'plugin_settings' "); + if(! count($r)) + notice('No Plugin settings configured'); + + call_hooks('plugin_settings', $o); + $o .= '
'; + return $o; + } + require_once('include/acl_selectors.php'); $p = q("SELECT * FROM `profile` WHERE `is-default` = 1 AND `uid` = %d LIMIT 1", diff --git a/util/strings.php b/util/strings.php index e776d052..f4244969 100644 --- a/util/strings.php +++ b/util/strings.php @@ -328,6 +328,8 @@ $a->strings[' Please use a shorter name.'] = ' Please use a shorter name.'; $a->strings[' Name too short.'] = ' Name too short.'; $a->strings[' Not valid email.'] = ' Not valid email.'; $a->strings['Settings updated.'] = 'Settings updated.'; +$a->strings['Plugin Settings'] = 'Plugin Settings'; +$a->strings['Account Settings'] = 'Account Settings'; $a->strings['OpenID: '] = 'OpenID: '; $a->strings[" \x28Optional\x29 Allow this OpenID to login to this account."] = " \x28Optional\x29 Allow this OpenID to login to this account."; $a->strings['Profile is not published.'] = 'Profile is not published.'; diff --git a/view/en/settings.tpl b/view/en/settings.tpl index 594ce73f..5e1bfabf 100644 --- a/view/en/settings.tpl +++ b/view/en/settings.tpl @@ -1,5 +1,7 @@

Account Settings

+ + $nickname_block diff --git a/view/it/settings.tpl b/view/it/settings.tpl index 364fd6ba..365e5cb7 100644 --- a/view/it/settings.tpl +++ b/view/it/settings.tpl @@ -1,5 +1,8 @@

Impostazioni account

+ + + $nickname_block diff --git a/view/it/strings.php b/view/it/strings.php index 2b1a3c83..3640997d 100644 --- a/view/it/strings.php +++ b/view/it/strings.php @@ -324,6 +324,8 @@ $a->strings[' Please use a shorter name.'] = ' Usa un nome più corto.'; $a->strings[' Name too short.'] = ' Nome troppo corto.'; $a->strings[' Not valid email.'] = ' Email non valida.'; $a->strings['Settings updated.'] = 'Impostazioni aggiornate.'; +$a->strings['Plugin Settings'] = 'Impostazioni Plugin'; +$a->strings['Account Settings'= = 'Impostazioni Account'; $a->strings['OpenID: '] = 'OpenID: '; $a->strings[" \x28Optional\x29 Allow this OpenID to login to this account."] = " \x28Opzionale\x29 Permetti a questo OpenID di accedere a questo account."; $a->strings['Profile is not published.'] = 'Il profilo non è pubblicato.'; diff --git a/view/theme/default/style.css b/view/theme/default/style.css index 086f59c3..240ace89 100644 --- a/view/theme/default/style.css +++ b/view/theme/default/style.css @@ -1952,3 +1952,8 @@ a.mail-list-link { margin-top: 50px; font-size: 70%; } + + +#plugin-settings-link, #account-settings-link { + margin-bottom: 25px; +}