X-Git-Url: https://git.mxchange.org/?p=friendica-addons.git;a=blobdiff_plain;f=randplace%2Frandplace.php;h=b696bed2e7749af96bdfbfd3c470eb6581efda7f;hp=35503850f7058134c9bb75e051c16e5ee224af92;hb=27b60e003f92dd9f3aebbeddb34ebb905488ca82;hpb=86a45576b2b15a0be18bb0708d88cf022cdcf4e6 diff --git a/randplace/randplace.php b/randplace/randplace.php old mode 100755 new mode 100644 index 35503850..b696bed2 --- a/randplace/randplace.php +++ b/randplace/randplace.php @@ -4,28 +4,27 @@ * Description: Sample Friendica plugin/addon. Set a random place when posting. * Version: 1.0 * Author: Mike Macgirvin - * - * - * * - * Addons are registered with the system in the - * .htconfig.php file. * - * $a->config['system']['addon'] = 'plugin1,plugin2,etc.'; + * + * + * Addons are registered with the system through the admin + * panel. * * When registration is detected, the system calls the plugin * 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 + * If the addon is removed from the configuration list, the * system will call the name_uninstall() function. * */ +use Friendica\Core\PConfig; function randplace_install() { /** - * + * * Our demo plugin will attach in three places. * The first is just prior to storing a local post. * @@ -35,7 +34,7 @@ function randplace_install() { /** * - * Then we'll attach into the plugin settings page, and also the + * Then we'll attach into the plugin settings page, and also the * settings post hook so that we can create and update * user preferences. * @@ -92,7 +91,7 @@ function randplace_post_hook($a, &$item) { /* Retrieve our personal config setting */ - $active = get_pconfig(local_user(), 'randplace', 'enable'); + $active = PConfig::get(local_user(), 'randplace', 'enable'); if(! $active) return; @@ -106,7 +105,7 @@ function randplace_post_hook($a, &$item) { * */ - $cities = array(); + $cities = []; $zones = timezone_identifiers_list(); foreach($zones as $zone) { if((strpos($zone,'/')) && (! stristr($zone,'US/')) && (! stristr($zone,'Etc/'))) @@ -136,13 +135,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']) + PConfig::set(local_user(),'randplace','enable',intval($_POST['randplace'])); } /** * - * Called from the Plugin Setting form. + * Called from the Plugin Setting form. * Add our own settings info to the page. * */ @@ -160,7 +160,7 @@ function randplace_settings(&$a,&$s) { /* Get the current state of our config variable */ - $enabled = get_pconfig(local_user(),'randplace','enable'); + $enabled = PConfig::get(local_user(),'randplace','enable'); $checked = (($enabled) ? ' checked="checked" ' : ''); @@ -175,6 +175,6 @@ function randplace_settings(&$a,&$s) { /* provide a submit button */ - $s .= '
'; + $s .= '
'; }