aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Lib
diff options
context:
space:
mode:
authorMario Vavti <mario@mariovavti.com>2022-10-25 19:06:17 +0200
committerMario Vavti <mario@mariovavti.com>2022-10-25 19:06:17 +0200
commit221b31bcc6f16510c0f242e96ac696b2dd0eca58 (patch)
tree98b52d9fd582a715128665ffb2b7262f3e212289 /Zotlabs/Lib
parent8879776d6436ed5257648a1873ddaa9486b25070 (diff)
downloadvolse-hubzilla-221b31bcc6f16510c0f242e96ac696b2dd0eca58.tar.gz
volse-hubzilla-221b31bcc6f16510c0f242e96ac696b2dd0eca58.tar.bz2
volse-hubzilla-221b31bcc6f16510c0f242e96ac696b2dd0eca58.zip
fix php warnings
Diffstat (limited to 'Zotlabs/Lib')
-rw-r--r--Zotlabs/Lib/Enotify.php43
-rw-r--r--Zotlabs/Lib/Libzot.php50
-rw-r--r--Zotlabs/Lib/Libzotdir.php12
3 files changed, 56 insertions, 49 deletions
diff --git a/Zotlabs/Lib/Enotify.php b/Zotlabs/Lib/Enotify.php
index 513f4ae14..67efe5e9d 100644
--- a/Zotlabs/Lib/Enotify.php
+++ b/Zotlabs/Lib/Enotify.php
@@ -122,8 +122,11 @@ class Enotify {
// e.g. "your post", "David's photo", etc.
$possess_desc = t('%s <!item_type!>');
+ $parent_mid = '';
+ $parent_item = [];
+
// @@TODO: consider using switch instead of those elseif
- if ($params['type'] == NOTIFY_MAIL) {
+ if (isset($params['type']) && $params['type'] == NOTIFY_MAIL) {
logger('notification: mail');
$subject = sprintf( t('[$Projectname:Notify] New direct message received at %s'), $sitename);
@@ -135,7 +138,7 @@ class Enotify {
$itemlink = $siteurl . '/hq/' . gen_link_id($params['item']['mid']);
}
- elseif ($params['type'] === NOTIFY_COMMENT) {
+ elseif (isset($params['type']) && $params['type'] === NOTIFY_COMMENT) {
//logger("notification: params = " . print_r($params, true), LOGGER_DEBUG);
$moderated = (($params['item']['item_blocked'] == ITEM_MODERATED) ? true : false);
@@ -167,7 +170,7 @@ class Enotify {
}
- $parent_mid = $params['parent_mid'];
+ $parent_mid = $params['parent_mid'] ?? '';
// Check to see if there was already a notify for this post.
// If so don't create a second notification
@@ -251,7 +254,7 @@ class Enotify {
}
- elseif ($params['type'] === NOTIFY_LIKE) {
+ elseif (isset($params['type']) && $params['type'] === NOTIFY_LIKE) {
// logger("notification: params = " . print_r($params, true), LOGGER_DEBUG);
$itemlink = $params['link'];
@@ -264,7 +267,7 @@ class Enotify {
}
}
- $parent_mid = $params['parent_mid'];
+ $parent_mid = $params['parent_mid'] ?? '';
// Check to see if there was already a notify for this post.
// If so don't create a second notification
@@ -335,7 +338,7 @@ class Enotify {
- elseif($params['type'] === NOTIFY_WALL) {
+ elseif(isset($params['type']) && $params['type'] === NOTIFY_WALL) {
$subject = sprintf( t('[$Projectname:Notify] %s posted to your profile wall') , $sender['xchan_name']);
$preamble = sprintf( t('%1$s posted to your profile wall at %2$s') , $sender['xchan_name'], $sitename);
@@ -350,7 +353,7 @@ class Enotify {
$itemlink = $params['link'];
}
- elseif ($params['type'] === NOTIFY_TAGSELF) {
+ elseif (isset($params['type']) && $params['type'] === NOTIFY_TAGSELF) {
$p = q("select id from notify where link = '%s' and uid = %d limit 1",
dbesc($params['link']),
@@ -374,7 +377,7 @@ class Enotify {
$itemlink = $params['link'];
}
- elseif ($params['type'] === NOTIFY_POKE) {
+ elseif (isset($params['type']) && $params['type'] === NOTIFY_POKE) {
$subject = sprintf( t('[$Projectname:Notify] %1$s poked you') , $sender['xchan_name']);
$preamble = sprintf( t('%1$s poked you at %2$s') , $sender['xchan_name'], $sitename);
$epreamble = sprintf( t('%1$s [zrl=%2$s]poked you[/zrl].') ,
@@ -391,7 +394,7 @@ class Enotify {
$itemlink = $params['link'];
}
- elseif ($params['type'] === NOTIFY_TAGSHARE) {
+ elseif (isset($params['type']) && $params['type'] === NOTIFY_TAGSHARE) {
$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]') ,
@@ -404,7 +407,7 @@ class Enotify {
$itemlink = $params['link'];
}
- elseif ($params['type'] === NOTIFY_INTRO) {
+ elseif (isset($params['type']) && $params['type'] === NOTIFY_INTRO) {
$subject = sprintf( t('[$Projectname:Notify] Introduction received'));
$preamble = sprintf( t('You\'ve received an new connection request from \'%1$s\' at %2$s'), $sender['xchan_name'], $sitename);
$epreamble = sprintf( t('You\'ve received [zrl=%1$s]a new connection request[/zrl] from %2$s.'),
@@ -418,7 +421,7 @@ class Enotify {
$itemlink = $params['link'];
}
- elseif ($params['type'] === NOTIFY_SUGGEST) {
+ elseif (isset($params['type']) && $params['type'] === NOTIFY_SUGGEST) {
$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.'),
@@ -436,11 +439,11 @@ class Enotify {
$itemlink = $params['link'];
}
- elseif ($params['type'] === NOTIFY_CONFIRM) {
+ elseif (isset($params['type']) && $params['type'] === NOTIFY_CONFIRM) {
// ?
}
- elseif ($params['type'] === NOTIFY_SYSTEM) {
+ elseif (isset($params['type']) && $params['type'] === NOTIFY_SYSTEM) {
// ?
}
@@ -495,13 +498,13 @@ class Enotify {
$datarray['link'] = $itemlink;
$datarray['parent'] = $parent_mid;
$datarray['parent_item'] = $parent_item;
- $datarray['ntype'] = $params['type'];
- $datarray['verb'] = $params['verb'];
- $datarray['otype'] = $params['otype'];
+ $datarray['ntype'] = $params['type'] ?? '';
+ $datarray['verb'] = $params['verb'] ?? '';
+ $datarray['otype'] = $params['otype'] ?? '';
$datarray['abort'] = false;
$datarray['seen'] = 0;
- $datarray['item'] = $params['item'];
+ $datarray['item'] = $params['item'] ?? [];
call_hooks('enotify_store', $datarray);
@@ -613,8 +616,8 @@ class Enotify {
$datarray['preamble'] = $preamble;
$datarray['sitename'] = $sitename;
$datarray['siteurl'] = $siteurl;
- $datarray['type'] = $params['type'];
- $datarray['parent'] = $params['parent_mid'];
+ $datarray['type'] = $params['type'] ?? '';
+ $datarray['parent'] = $params['parent_mid'] ?? '';
$datarray['source_name'] = $sender['xchan_name'];
$datarray['source_link'] = $sender['xchan_url'];
$datarray['source_photo'] = $sender['xchan_photo_s'];
@@ -681,7 +684,6 @@ class Enotify {
'$source_name' => $datarray['source_name'],
'$source_link' => $datarray['source_link'],
'$source_photo' => $datarray['source_photo'],
- '$username' => $datarray['to_name'],
'$hsitelink' => $datarray['hsitelink'],
'$hitemlink' => $datarray['hitemlink'],
'$thanks' => $datarray['thanks'],
@@ -703,7 +705,6 @@ class Enotify {
'$source_name' => $datarray['source_name'],
'$source_link' => $datarray['source_link'],
'$source_photo' => $datarray['source_photo'],
- '$username' => $datarray['to_name'],
'$tsitelink' => $datarray['tsitelink'],
'$titemlink' => $datarray['titemlink'],
'$thanks' => $datarray['thanks'],
diff --git a/Zotlabs/Lib/Libzot.php b/Zotlabs/Lib/Libzot.php
index 6e8a5d5bc..93979baf3 100644
--- a/Zotlabs/Lib/Libzot.php
+++ b/Zotlabs/Lib/Libzot.php
@@ -646,6 +646,8 @@ class Libzot {
static function import_xchan($arr, $ud_flags = UPDATE_FLAGS_UPDATED, $ud_arr = null) {
+ $ret = ['success' => false];
+
if (!is_array($arr)) {
logger('Not an array: ' . print_r($arr, true), LOGGER_DEBUG);
return $ret;
@@ -658,7 +660,6 @@ class Libzot {
*/
call_hooks('import_xchan', $arr);
- $ret = ['success' => false];
$dirmode = intval(get_config('system', 'directory_mode'));
$changed = false;
@@ -771,10 +772,10 @@ class Libzot {
dbesc($arr['name_updated']),
dbesc($arr['primary_location']['connections_url']),
dbesc($arr['primary_location']['follow_url']),
- dbesc($arr['primary_location']['connect_url']),
+ dbesc($arr['connect_url']),
intval(1 - intval($arr['searchable'])),
intval($arr['adult_content']),
- intval($arr['deleted']),
+ intval($arr['deleted'] ?? 0),
intval($arr['public_forum']),
dbesc(escape_tags($arr['primary_location']['address'])),
dbesc(escape_tags($arr['primary_location']['url'])),
@@ -2500,32 +2501,32 @@ class Libzot {
}
$site_directory = 0;
- if ($arr['directory_mode'] == 'normal')
+ if (isset($arr['directory_mode']) && $arr['directory_mode'] == 'normal')
$site_directory = DIRECTORY_MODE_NORMAL;
- if ($arr['directory_mode'] == 'primary')
+ if (isset($arr['directory_mode']) && $arr['directory_mode'] == 'primary')
$site_directory = DIRECTORY_MODE_PRIMARY;
- if ($arr['directory_mode'] == 'secondary')
+ if (isset($arr['directory_mode']) && $arr['directory_mode'] == 'secondary')
$site_directory = DIRECTORY_MODE_SECONDARY;
- if ($arr['directory_mode'] == 'standalone')
+ if (isset($arr['directory_mode']) && $arr['directory_mode'] == 'standalone')
$site_directory = DIRECTORY_MODE_STANDALONE;
$register_policy = 0;
- if ($arr['register_policy'] == 'closed')
+ if (isset($arr['register_policy']) && $arr['register_policy'] == 'closed')
$register_policy = REGISTER_CLOSED;
- if ($arr['register_policy'] == 'open')
+ if (isset($arr['register_policy']) && $arr['register_policy'] == 'open')
$register_policy = REGISTER_OPEN;
- if ($arr['register_policy'] == 'approve')
+ if (isset($arr['register_policy']) && $arr['register_policy'] == 'approve')
$register_policy = REGISTER_APPROVE;
$access_policy = 0;
if (array_key_exists('access_policy', $arr)) {
- if ($arr['access_policy'] === 'private')
+ if (isset($arr['access_policy']) && $arr['access_policy'] === 'private')
$access_policy = ACCESS_PRIVATE;
- if ($arr['access_policy'] === 'paid')
+ if (isset($arr['access_policy']) && $arr['access_policy'] === 'paid')
$access_policy = ACCESS_PAID;
- if ($arr['access_policy'] === 'free')
+ if (isset($arr['access_policy']) && $arr['access_policy'] === 'free')
$access_policy = ACCESS_FREE;
- if ($arr['access_policy'] === 'tiered')
+ if (isset($arr['access_policy']) && $arr['access_policy'] === 'tiered')
$access_policy = ACCESS_TIERED;
}
@@ -2938,7 +2939,7 @@ class Libzot {
$ret['mail'] = map_scope(PermissionLimits::Get($e['channel_id'], 'post_mail'));
if ($deleted)
- $ret['deleted'] = $deleted;
+ $ret['deleted'] = true;
if (intval($e['channel_removed'])) {
$ret['deleted_locally'] = true;
@@ -3010,18 +3011,17 @@ class Libzot {
$signing_key = get_config('system', 'prvkey');
$sig_method = get_config('system', 'signature_algorithm', 'sha256');
- $ret = [];
- $ret['site'] = [];
- $ret['site']['url'] = z_root();
- $ret['site']['site_sig'] = self::sign(z_root(), $signing_key);
- $ret['site']['post'] = z_root() . '/zot';
- $ret['site']['openWebAuth'] = z_root() . '/owa';
- $ret['site']['authRedirect'] = z_root() . '/magic';
- $ret['site']['sitekey'] = get_config('system', 'pubkey');
+ $ret = [];
+ $ret['site'] = [];
+ $ret['site']['url'] = z_root();
+ $ret['site']['site_sig'] = self::sign(z_root(), $signing_key);
+ $ret['site']['post'] = z_root() . '/zot';
+ $ret['site']['openWebAuth'] = z_root() . '/owa';
+ $ret['site']['authRedirect'] = z_root() . '/magic';
+ $ret['site']['sitekey'] = get_config('system', 'pubkey');
+ $ret['site']['directory_mode'] = 'normal';
$dirmode = get_config('system', 'directory_mode');
- if (($dirmode === false) || ($dirmode == DIRECTORY_MODE_NORMAL))
- $ret['site']['directory_mode'] = 'normal';
if ($dirmode == DIRECTORY_MODE_PRIMARY)
$ret['site']['directory_mode'] = 'primary';
diff --git a/Zotlabs/Lib/Libzotdir.php b/Zotlabs/Lib/Libzotdir.php
index 77429c45b..3ee5c429a 100644
--- a/Zotlabs/Lib/Libzotdir.php
+++ b/Zotlabs/Lib/Libzotdir.php
@@ -453,9 +453,15 @@ class Libzotdir {
if (! $hash)
return false;
- $arr = array();
-
- $arr['xprof_hash'] = $hash;
+ $arr = [];
+
+ $arr['xprof_hash'] = $hash;
+ $arr['xprof_dob'] = '0000-00-00';
+ if (isset($profile['birthday'])) {
+ $arr['xprof_dob'] = (($profile['birthday'] === '0000-00-00')
+ ? $profile['birthday']
+ : datetime_convert('', '', $profile['birthday'], 'Y-m-d')); // !!!! check this for 0000 year
+ }
$arr['xprof_dob'] = ((isset($profile['birthday']) && $profile['birthday'] === '0000-00-00') ? $profile['birthday'] : datetime_convert('','',$profile['birthday'],'Y-m-d')); // !!!! check this for 0000 year
$arr['xprof_age'] = ((isset($profile['age']) && $profile['age']) ? intval($profile['age']) : 0);
$arr['xprof_desc'] = ((isset($profile['description']) && $profile['description']) ? htmlspecialchars($profile['description'], ENT_COMPAT,'UTF-8',false) : '');