X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=randplace%2Frandplace.php;h=ca4d3d797d0783d24a5becefb3f1aabc448a3dcc;hb=39dd3dffe07efd69fa1ac6d0bd243c7fc0e3a66f;hp=35503850f7058134c9bb75e051c16e5ee224af92;hpb=58cce64c663c8105cae4879d4ba58170cee05c3e;p=friendica-addons.git diff --git a/randplace/randplace.php b/randplace/randplace.php old mode 100755 new mode 100644 index 35503850..ca4d3d79 --- a/randplace/randplace.php +++ b/randplace/randplace.php @@ -1,48 +1,48 @@ * * * * - * Addons are registered with the system in the - * .htconfig.php file. + * Addons are registered with the system through the admin + * panel. * - * $a->config['system']['addon'] = 'plugin1,plugin2,etc.'; - * - * When registration is detected, the system calls the plugin + * When registration is detected, the system calls the addon * name_install() function, located in 'addon/name/name.php', * where 'name' is the name of the addon. * If the addon is removed from the configuration list, the * system will call the name_uninstall() function. * */ - +use Friendica\Core\Addon; +use Friendica\Core\L10n; +use Friendica\Core\PConfig; function randplace_install() { /** - * - * Our demo plugin will attach in three places. + * + * Our demo addon will attach in three places. * The first is just prior to storing a local post. * */ - register_hook('post_local', 'addon/randplace/randplace.php', 'randplace_post_hook'); + Addon::registerHook('post_local', 'addon/randplace/randplace.php', 'randplace_post_hook'); /** * - * Then we'll attach into the plugin settings page, and also the + * Then we'll attach into the addon settings page, and also the * settings post hook so that we can create and update * user preferences. * */ - register_hook('plugin_settings', 'addon/randplace/randplace.php', 'randplace_settings'); - register_hook('plugin_settings_post', 'addon/randplace/randplace.php', 'randplace_settings_post'); + Addon::registerHook('addon_settings', 'addon/randplace/randplace.php', 'randplace_settings'); + Addon::registerHook('addon_settings_post', 'addon/randplace/randplace.php', 'randplace_settings_post'); logger("installed randplace"); } @@ -58,9 +58,9 @@ function randplace_uninstall() { * */ - unregister_hook('post_local', 'addon/randplace/randplace.php', 'randplace_post_hook'); - unregister_hook('plugin_settings', 'addon/randplace/randplace.php', 'randplace_settings'); - unregister_hook('plugin_settings_post', 'addon/randplace/randplace.php', 'randplace_settings_post'); + Addon::unregisterHook('post_local', 'addon/randplace/randplace.php', 'randplace_post_hook'); + Addon::unregisterHook('addon_settings', 'addon/randplace/randplace.php', 'randplace_settings'); + Addon::unregisterHook('addon_settings_post', 'addon/randplace/randplace.php', 'randplace_settings_post'); logger("removed randplace"); @@ -75,7 +75,7 @@ function randplace_post_hook($a, &$item) { * An item was posted on the local system. * We are going to look for specific items: * - A status post by a profile owner - * - The profile owner must have allowed our plugin + * - The profile owner must have allowed our addon * */ @@ -136,13 +136,14 @@ function randplace_post_hook($a, &$item) { function randplace_settings_post($a,$post) { if(! local_user()) return; - set_pconfig(local_user(),'randplace','enable',intval($_POST['randplace'])); + if($_POST['randplace-submit']) + set_pconfig(local_user(),'randplace','enable',intval($_POST['randplace'])); } /** * - * Called from the Plugin Setting form. + * Called from the Addon Setting form. * Add our own settings info to the page. * */ @@ -167,14 +168,14 @@ function randplace_settings(&$a,&$s) { /* Add some HTML to the existing form */ $s .= '
'; - $s .= '

' . t('Randplace Settings') . '

'; + $s .= '

' . L10n::t('Randplace Settings') . '

'; $s .= '
'; - $s .= ''; + $s .= ''; $s .= ''; $s .= '
'; /* provide a submit button */ - $s .= '
'; + $s .= '
'; }