aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Lib
diff options
context:
space:
mode:
authorHarald Eilertsen <haraldei@anduin.net>2024-11-14 18:40:15 +0000
committerMario <mario@mariovavti.com>2024-11-14 18:40:15 +0000
commit951800eca6045f6e0dc1e9a12c225c8e55b044e9 (patch)
tree2eaa48c246725a85b4277db07b72831f088cf5e9 /Zotlabs/Lib
parentd446f171c50b3d74b2f9865ccf17b535aaa38fe1 (diff)
downloadvolse-hubzilla-951800eca6045f6e0dc1e9a12c225c8e55b044e9.tar.gz
volse-hubzilla-951800eca6045f6e0dc1e9a12c225c8e55b044e9.tar.bz2
volse-hubzilla-951800eca6045f6e0dc1e9a12c225c8e55b044e9.zip
Several issues discovered by PHPStan
Diffstat (limited to 'Zotlabs/Lib')
-rw-r--r--Zotlabs/Lib/Activity.php75
-rw-r--r--Zotlabs/Lib/Chatroom.php2
-rw-r--r--Zotlabs/Lib/Enotify.php4
-rw-r--r--Zotlabs/Lib/SuperCurl.php127
4 files changed, 3 insertions, 205 deletions
diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php
index 9a8ac4a39..448b88ff4 100644
--- a/Zotlabs/Lib/Activity.php
+++ b/Zotlabs/Lib/Activity.php
@@ -1289,81 +1289,6 @@ class Activity {
// return false;
}
- static function activity_decode_mapper($verb) {
-
- $acts = [
- 'http://activitystrea.ms/schema/1.0/post' => 'Create',
- // 'http://activitystrea.ms/schema/1.0/share' => 'Announce',
- 'http://activitystrea.ms/schema/1.0/update' => 'Update',
- 'http://activitystrea.ms/schema/1.0/like' => 'Like',
- 'http://activitystrea.ms/schema/1.0/favorite' => 'Like',
- 'http://purl.org/zot/activity/dislike' => 'Dislike',
- // 'http://activitystrea.ms/schema/1.0/tag' => 'Add',
- 'http://activitystrea.ms/schema/1.0/follow' => 'Follow',
- 'http://activitystrea.ms/schema/1.0/unfollow' => 'Unfollow',
- 'http://activitystrea.ms/schema/1.0/stop-following' => 'Unfollow',
- 'http://purl.org/zot/activity/attendyes' => 'Accept',
- 'http://purl.org/zot/activity/attendno' => 'Reject',
- 'http://purl.org/zot/activity/attendmaybe' => 'TentativeAccept',
- 'Announce' => 'Announce',
- 'Invite' => 'Invite',
- 'Delete' => 'Delete',
- 'Undo' => 'Undo',
- 'Add' => 'Add',
- 'Remove' => 'Remove'
- ];
-
- call_hooks('activity_decode_mapper', $acts);
-
- foreach ($acts as $k => $v) {
- if ($verb === $v) {
- return $k;
- }
- }
-
- logger('Unmapped activity: ' . $verb);
- return 'Create';
-
- }
-
- static function activity_obj_decode_mapper($obj) {
-
- $objs = [
- 'http://activitystrea.ms/schema/1.0/note' => 'Note',
- 'http://activitystrea.ms/schema/1.0/note' => 'Article',
- 'http://activitystrea.ms/schema/1.0/comment' => 'Note',
- 'http://activitystrea.ms/schema/1.0/person' => 'Person',
- 'http://purl.org/zot/activity/profile' => 'Profile',
- 'http://activitystrea.ms/schema/1.0/photo' => 'Image',
- 'http://activitystrea.ms/schema/1.0/profile-photo' => 'Icon',
- 'http://activitystrea.ms/schema/1.0/event' => 'Event',
- 'http://purl.org/zot/activity/location' => 'Place',
- 'http://purl.org/zot/activity/chessgame' => 'Game',
- 'http://purl.org/zot/activity/tagterm' => 'zot:Tag',
- 'http://purl.org/zot/activity/thing' => 'Object',
- 'http://purl.org/zot/activity/file' => 'zot:File',
- 'http://purl.org/zot/activity/mood' => 'zot:Mood',
- 'Invite' => 'Invite',
- 'Question' => 'Question',
- 'Document' => 'Document',
- 'Audio' => 'Audio',
- 'Video' => 'Video',
- 'Delete' => 'Delete',
- 'Undo' => 'Undo'
- ];
-
- call_hooks('activity_obj_decode_mapper', $objs);
-
- foreach ($objs as $k => $v) {
- if ($obj === $v) {
- return $k;
- }
- }
-
- logger('Unmapped activity object: ' . $obj);
- return 'Note';
- }
-
static function activity_obj_mapper($obj) {
$objs = [
diff --git a/Zotlabs/Lib/Chatroom.php b/Zotlabs/Lib/Chatroom.php
index 34853b6ab..ee16d0002 100644
--- a/Zotlabs/Lib/Chatroom.php
+++ b/Zotlabs/Lib/Chatroom.php
@@ -181,7 +181,7 @@ class Chatroom {
}
- function leave($observer_xchan, $room_id, $client) {
+ public static function leave($observer_xchan, $room_id, $client) {
if(! $room_id || ! $observer_xchan)
return;
diff --git a/Zotlabs/Lib/Enotify.php b/Zotlabs/Lib/Enotify.php
index 121ad9b09..245d137fb 100644
--- a/Zotlabs/Lib/Enotify.php
+++ b/Zotlabs/Lib/Enotify.php
@@ -406,6 +406,7 @@ class Enotify {
}
elseif (isset($params['type']) && $params['type'] === NOTIFY_TAGSHARE) {
+ $itemlink = $params['link'];
$subject = sprintf( t('[$Projectname:Notify] %s tagged your post') , $sender['xchan_name']);
$preamble = sprintf( t('%1$s tagged your post at %2$s'),$sender['xchan_name'], $sitename);
$epreamble = sprintf( t('%1$s tagged [zrl=%2$s]your post[/zrl]') ,
@@ -415,7 +416,6 @@ class Enotify {
$sitelink = t('Please visit %s to view and/or reply to the conversation.');
$tsitelink = sprintf( $sitelink, $siteurl );
$hsitelink = sprintf( $sitelink, '<a href="' . $siteurl . '">' . $sitename . '</a>');
- $itemlink = $params['link'];
}
elseif (isset($params['type']) && $params['type'] === NOTIFY_INTRO) {
@@ -433,6 +433,7 @@ class Enotify {
}
elseif (isset($params['type']) && $params['type'] === NOTIFY_SUGGEST) {
+ $itemlink = $params['link'];
$subject = sprintf( t('[$Projectname:Notify] Friend suggestion received'));
$preamble = sprintf( t('You\'ve received a friend suggestion from \'%1$s\' at %2$s'), $sender['xchan_name'], $sitename);
$epreamble = sprintf( t('You\'ve received [zrl=%1$s]a friend suggestion[/zrl] for %2$s from %3$s.'),
@@ -447,7 +448,6 @@ class Enotify {
$sitelink = t('Please visit %s to approve or reject the suggestion.');
$tsitelink = sprintf( $sitelink, $siteurl );
$hsitelink = sprintf( $sitelink, '<a href="' . $siteurl . '">' . $sitename . '</a>');
- $itemlink = $params['link'];
}
elseif (isset($params['type']) && $params['type'] === NOTIFY_CONFIRM) {
diff --git a/Zotlabs/Lib/SuperCurl.php b/Zotlabs/Lib/SuperCurl.php
deleted file mode 100644
index 462a62b36..000000000
--- a/Zotlabs/Lib/SuperCurl.php
+++ /dev/null
@@ -1,127 +0,0 @@
-<?php
-
-namespace Zotlabs\Lib;
-
-/**
- * @brief wrapper for z_fetch_url() which can be instantiated with several built-in parameters and
- * these can be modified and re-used. Useful for CalDAV and other processes which need to authenticate
- * and set lots of CURL options (many of which stay the same from one call to the next).
- */
-
-
-
-
-class SuperCurl {
-
-
- private $auth;
- private $url;
-
- private $curlopt = array();
-
- private $headers = null;
- public $filepos = 0;
- public $filehandle = 0;
- public $request_data = '';
-
- private $request_method = 'GET';
- private $upload = false;
- private $cookies = false;
-
-
- private function set_data($s) {
- $this->request_data = $s;
- $this->filepos = 0;
- }
-
- public function curl_read($ch,$fh,$size) {
-
- if($this->filepos < 0) {
- unset($fh);
- return '';
- }
-
- $s = substr($this->request_data,$this->filepos,$size);
-
- if(strlen($s) < $size)
- $this->filepos = (-1);
- else
- $this->filepos = $this->filepos + $size;
-
- return $s;
- }
-
-
- public function __construct($opts = array()) {
- $this->set($opts);
- }
-
- private function set($opts = array()) {
- if($opts) {
- foreach($opts as $k => $v) {
- switch($k) {
- case 'http_auth':
- $this->auth = $v;
- break;
- case 'magicauth':
- // currently experimental
- $this->magicauth = $v;
- \Zotlabs\Daemon\Master::Summon([ 'CurlAuth', $v ]);
- break;
- case 'custom':
- $this->request_method = $v;
- break;
- case 'url':
- $this->url = $v;
- break;
- case 'data':
- $this->set_data($v);
- if($v) {
- $this->upload = true;
- }
- else {
- $this->upload = false;
- }
- break;
- case 'headers':
- $this->headers = $v;
- break;
- default:
- $this->curlopts[$k] = $v;
- break;
- }
- }
- }
- }
-
- function exec() {
- $opts = $this->curlopts;
- $url = $this->url;
- if($this->auth)
- $opts['http_auth'] = $this->auth;
- if($this->magicauth) {
- $opts['cookiejar'] = 'store/[data]/cookie_' . $this->magicauth;
- $opts['cookiefile'] = 'store/[data]/cookie_' . $this->magicauth;
- $opts['cookie'] = 'PHPSESSID=' . trim(file_get_contents('store/[data]/cookien_' . $this->magicauth));
- $c = channelx_by_n($this->magicauth);
- if($c)
- $url = zid($this->url,channel_reddress($c));
- }
- if($this->custom)
- $opts['custom'] = $this->custom;
- if($this->headers)
- $opts['headers'] = $this->headers;
- if($this->upload) {
- $opts['upload'] = true;
- $opts['infile'] = $this->filehandle;
- $opts['infilesize'] = strlen($this->request_data);
- $opts['readfunc'] = [ $this, 'curl_read' ] ;
- }
-
- $recurse = 0;
- return z_fetch_url($this->url,true,$recurse,(($opts) ? $opts : null));
-
- }
-
-
-}