provide separate plugin settings page, update demo plugin, fix hook_register
This commit is contained in:
parent
6891d44e0b
commit
d045fd04d4
|
@ -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'] .= '<link rel="stylesheet" type="text/css" href="' . $a->get_baseurl() . '/addon/randplace/randplace.css' . '" media="all" />' . "\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 .= '<h3>' . t('Randplace Settings') . '</h3>';
|
||||
$s .= '<div id="randplace-enable-wrapper">';
|
||||
|
@ -172,7 +172,7 @@ function randplace_settings(&$a,&$s) {
|
|||
$s .= '<input id="randplace-checkbox" type="checkbox" name="randplace" value="1" ' . $checked . '/>';
|
||||
$s .= '</div><div class="clear"></div>';
|
||||
|
||||
/* provide another submit button */
|
||||
/* provide a submit button */
|
||||
|
||||
$s .= '<div class="settings-submit-wrapper" ><input type="submit" name="submit" class="settings-submit" value="' . t('Submit') . '" /></div>';
|
||||
|
||||
|
|
2
boot.php
2
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)
|
||||
|
|
|
@ -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 .= '<h1>' . t('Plugin Settings') . '</h1>';
|
||||
$o .= '<div id="account-settings-link"><a href="settings">' . t('Account Settings') . '</a></div>';
|
||||
|
||||
$o .= '<form action="settings/addon" method="post" >';
|
||||
|
||||
$r = q("SELECT * FROM `hook` WHERE `hook` = 'plugin_settings' ");
|
||||
if(! count($r))
|
||||
notice('No Plugin settings configured');
|
||||
|
||||
call_hooks('plugin_settings', $o);
|
||||
$o .= '</form>';
|
||||
return $o;
|
||||
}
|
||||
|
||||
require_once('include/acl_selectors.php');
|
||||
|
||||
$p = q("SELECT * FROM `profile` WHERE `is-default` = 1 AND `uid` = %d LIMIT 1",
|
||||
|
|
|
@ -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 <strong>not published</strong>.'] = 'Profile is <strong>not published</strong>.';
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
<h1>Account Settings</h1>
|
||||
|
||||
<div id="plugin-settings-link"><a href="settings/addon">Plugin Settings</a></div>
|
||||
|
||||
$nickname_block
|
||||
|
||||
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
<h1>Impostazioni account</h1>
|
||||
|
||||
<div id="plugin-settings-link"><a href="settings/addon">Impostazioni Plugin</a></div>
|
||||
|
||||
|
||||
$nickname_block
|
||||
|
||||
|
||||
|
|
|
@ -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 <strong>not published</strong>.'] = 'Il profilo <strong>non è pubblicato</strong>.';
|
||||
|
|
|
@ -1952,3 +1952,8 @@ a.mail-list-link {
|
|||
margin-top: 50px;
|
||||
font-size: 70%;
|
||||
}
|
||||
|
||||
|
||||
#plugin-settings-link, #account-settings-link {
|
||||
margin-bottom: 25px;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user