]> git.mxchange.org Git - friendica-addons.git/blobdiff - widgets/widgets.php
Issue 3873
[friendica-addons.git] / widgets / widgets.php
index 27cabfd698cdec6580ee39d9c99b2ff0d8699fbd..e62932448efc5f2badd7d21e7a3a63c8aaf3ce92 100755 (executable)
@@ -5,8 +5,9 @@
  * Version: 1.0
  * Author: Fabio Comuni <http://kirgroup.com/profile/fabrix/>
  */
-        
+
+use Friendica\Core\PConfig;
+
 function widgets_install() {
        register_hook('plugin_settings', 'addon/widgets/widgets.php', 'widgets_settings'); 
        register_hook('plugin_settings_post', 'addon/widgets/widgets.php', 'widgets_settings_post');
@@ -19,7 +20,8 @@ function widgets_uninstall() {
 
 
 function widgets_settings_post(){
-       
+       if(! local_user())
+               return;
        if (isset($_POST['widgets-submit'])){
                del_pconfig(local_user(), 'widgets', 'key');
                
@@ -31,8 +33,8 @@ function widgets_settings(&$a,&$o) {
                return;         
        
        
-       $key = get_pconfig(local_user(), 'widgets', 'key' );
-       if ($key=='') { $key = mt_rand(); set_pconfig(local_user(), 'widgets', 'key', $key); }
+       $key = PConfig::get(local_user(), 'widgets', 'key' );
+       if ($key=='') { $key = mt_rand(); PConfig::set(local_user(), 'widgets', 'key', $key); }
 
        $widgets = array();
        $d = dir(dirname(__file__));
@@ -50,7 +52,8 @@ function widgets_settings(&$a,&$o) {
 
        
        
-       $t = file_get_contents( dirname(__file__). "/settings.tpl" );
+#      $t = file_get_contents( dirname(__file__). "/settings.tpl" );
+       $t = get_markup_template("settings.tpl", "addon/widgets/");
        $o .= replace_macros($t, array(
                '$submit' => t('Generate new key'),
                '$baseurl' => $a->get_baseurl(),