]> git.mxchange.org Git - friendica-addons.git/blobdiff - remote_permissions/remote_permissions.php
Some more notices in addons
[friendica-addons.git] / remote_permissions / remote_permissions.php
index b1651517408060f029fe3061a15248c7a5beddd3..a9f5b51ef631fff12fe28a63c8f4fe7835d50584 100644 (file)
@@ -4,12 +4,14 @@
  * Description: Allow the recipients of private posts to see who else can see the post by clicking the lock icon
  * Version: 1.0
  * Author: Zach <https://f.shmuz.in/profile/techcity>
- * 
+ *
  */
+
 use Friendica\Core\Addon;
 use Friendica\Core\Config;
 use Friendica\Core\L10n;
 use Friendica\Core\PConfig;
+use Friendica\Database\DBA;
 
 function remote_permissions_install() {
        Addon::registerHook('lockview_content', 'addon/remote_permissions/remote_permissions.php', 'remote_permissions_content');
@@ -28,7 +30,7 @@ function remote_permissions_settings(&$a,&$o) {
        if(! local_user())
                return;
 
-       $global = get_config("remote_perms", "global");
+       $global = Config::get("remote_perms", "global");
        if($global == 1)
                return;
 
@@ -38,8 +40,8 @@ function remote_permissions_settings(&$a,&$o) {
 
        /* Get the current state of our config variable */
 
-       $remote_perms = get_pconfig(local_user(),'remote_perms','show');
-       
+       $remote_perms = PConfig::get(local_user(),'remote_perms','show');
+
        /* Add some HTML to the existing form */
 
 //     $t = file_get_contents("addon/remote_permissions/settings.tpl" );
@@ -66,13 +68,13 @@ function remote_permissions_content($a, $item_copy) {
        if($item_copy['uid'] != local_user())
                return;
 
-       if(get_config('remote_perms','global') == 0) {
+       if(Config::get('remote_perms','global') == 0) {
                // Admin has set Individual choice. We need to find
                // the original poster. First, get the contact's info
                $r = q("SELECT nick, url FROM contact WHERE id = %d LIMIT 1",
                       intval($item_copy['contact-id'])
                );
-               if(! $r) 
+               if(! $r)
                        return;
 
                // Find out if the contact lives here
@@ -84,19 +86,19 @@ function remote_permissions_content($a, $item_copy) {
                // The contact lives here. Get his/her user info
                $nick = $r[0]['nick'];
                $r = q("SELECT uid FROM user WHERE nickname = '%s' LIMIT 1",
-                      dbesc($nick)
+                      DBA::escape($nick)
                );
                if(! $r)
                        return;
 
-               if(get_pconfig($r[0]['uid'],'remote_perms','show') == 0)
+               if(PConfig::get($r[0]['uid'],'remote_perms','show') == 0)
                        return;
        }
 
        if(($item_copy['private'] == 1) && (! strlen($item_copy['allow_cid'])) && (! strlen($item_copy['allow_gid']))
                && (! strlen($item_copy['deny_cid'])) && (! strlen($item_copy['deny_gid']))) {
 
-               $allow_names = array();
+               $allow_names = [];
 
                // Check for the original post here -- that's the only way
                // to definitely get all of the recipients
@@ -104,15 +106,15 @@ function remote_permissions_content($a, $item_copy) {
                if($item_copy['uri'] === $item_copy['parent-uri']) {
                        // Lockview for a top-level post
                        $r = q("SELECT allow_cid, allow_gid, deny_cid, deny_gid FROM item WHERE uri = '%s' AND type = 'wall' LIMIT 1",
-                                  dbesc($item_copy['uri'])
+                                  DBA::escape($item_copy['uri'])
                        );
                }
                else {
                        // Lockview for a comment
                        $r = q("SELECT allow_cid, allow_gid, deny_cid, deny_gid FROM item WHERE uri = '%s'
                                AND parent = ( SELECT id FROM item WHERE uri = '%s' AND type = 'wall' ) LIMIT 1",
-                                  dbesc($item_copy['uri']),
-                                  dbesc($item_copy['parent-uri'])
+                                  DBA::escape($item_copy['uri']),
+                                  DBA::escape($item_copy['parent-uri'])
                        );
                }
                if($r) {
@@ -130,18 +132,18 @@ function remote_permissions_content($a, $item_copy) {
 
                        if(count($allowed_groups)) {
                                $r = q("SELECT DISTINCT `contact-id` FROM group_member WHERE gid IN ( %s )",
-                                       dbesc(implode(', ', $allowed_groups))
+                                       DBA::escape(implode(', ', $allowed_groups))
                                );
-                               foreach($r as $rr) 
+                               foreach($r as $rr)
                                        $allow[] = $rr['contact-id'];
                        }
                        $allow = array_unique($allow + $allowed_users);
 
                        if(count($deny_groups)) {
                                $r = q("SELECT DISTINCT `contact-id` FROM group_member WHERE gid IN ( %s )",
-                                       dbesc(implode(', ', $deny_groups))
+                                       DBA::escape(implode(', ', $deny_groups))
                                );
-                               foreach($r as $rr) 
+                               foreach($r as $rr)
                                        $deny[] = $rr['contact-id'];
                        }
                        $deny = $deny + $deny_users;
@@ -149,7 +151,7 @@ function remote_permissions_content($a, $item_copy) {
                        if($allow)
                        {
                                $r = q("SELECT name FROM contact WHERE id IN ( %s )",
-                                          dbesc(implode(', ', array_diff($allow, $deny)))
+                                          DBA::escape(implode(', ', array_diff($allow, $deny)))
                                );
                                foreach($r as $rr)
                                        $allow_names[] = $rr['name'];
@@ -162,18 +164,18 @@ function remote_permissions_content($a, $item_copy) {
                        // will have different URIs than the original. We can match the GUID for
                        // those
                        $r = q("SELECT `uid` FROM item WHERE uri = '%s' OR guid = '%s'",
-                                  dbesc($item_copy['uri']),
-                              dbesc($item_copy['guid'])
+                                  DBA::escape($item_copy['uri']),
+                              DBA::escape($item_copy['guid'])
                        );
                        if(! $r)
                                return;
 
-                       $allow = array();
+                       $allow = [];
                        foreach($r as $rr)
                                $allow[] = $rr['uid'];
 
                        $r = q("SELECT username FROM user WHERE uid IN ( %s )",
-                               dbesc(implode(', ', $allow))
+                               DBA::escape(implode(', ', $allow))
                        );
                        if(! $r)
                                return;