]> git.mxchange.org Git - friendica-addons.git/blobdiff - randplace/randplace.php
Issue 3873
[friendica-addons.git] / randplace / randplace.php
index bae8e7c690dc059ada01b8f0e49f461cbe2e2fb3..96e5d3b2a443772120d42d5bbd3e23a4a4f4006f 100755 (executable)
@@ -1,17 +1,15 @@
 <?php
 /**
  * Name: Random place
- * Description: Sample Friendika plugin/addon. Set a random place when posting.
+ * Description: Sample Friendica plugin/addon. Set a random place when posting.
  * Version: 1.0
  * Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
  * 
  * 
  * 
  *
- * 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',
@@ -21,6 +19,7 @@
  *
  */
 
+use Friendica\Core\PConfig;
 
 function randplace_install() {
 
@@ -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;
@@ -136,7 +135,8 @@ 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']));
 }
 
 
@@ -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 .= '<div class="settings-submit-wrapper" ><input type="submit" name="submit" class="settings-submit" value="' . t('Submit') . '" /></div></div>';
+       $s .= '<div class="settings-submit-wrapper" ><input type="submit" name="randplace-submit" class="settings-submit" value="' . t('Save Settings') . '" /></div></div>';
 
 }