aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Zotlabs/Lib/Activity.php2
-rw-r--r--Zotlabs/Lib/ThreadItem.php3
-rw-r--r--Zotlabs/Module/Invite.php54
-rw-r--r--Zotlabs/Module/Regate.php4
-rw-r--r--phpstan.neon.dist2
5 files changed, 30 insertions, 35 deletions
diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php
index 19c3c5b60..03b63a17b 100644
--- a/Zotlabs/Lib/Activity.php
+++ b/Zotlabs/Lib/Activity.php
@@ -2727,7 +2727,7 @@ class Activity {
$relay = $channel['channel_hash'] === $parent[0]['owner_xchan'];
- if (str_contains($parent[0]['tgt_type'], 'Collection') && !$relay && !$isCollectionOperation) {
+ if (str_contains($parent[0]['tgt_type'], 'Collection') && !$relay && !$is_collection_operation) {
logger('not a collection activity');
return;
}
diff --git a/Zotlabs/Lib/ThreadItem.php b/Zotlabs/Lib/ThreadItem.php
index 888c8f79b..5bb658bba 100644
--- a/Zotlabs/Lib/ThreadItem.php
+++ b/Zotlabs/Lib/ThreadItem.php
@@ -362,10 +362,9 @@ class ThreadItem {
'folders' => $body['folders'],
'text' => strip_tags($body['html']),
'id' => $this->get_id(),
- 'parent' => intval($item['parent']),
+ 'parent' => $item['parent'],
'mid' => $midb64,
'mids' => $json_mids,
- 'parent' => $item['parent'],
'author_id' => (($item['author']['xchan_addr']) ? $item['author']['xchan_addr'] : $item['author']['xchan_url']),
'author_is_group_actor' => (($item['author']['xchan_pubforum']) ? t('Forum') : ''),
'isevent' => $isevent,
diff --git a/Zotlabs/Module/Invite.php b/Zotlabs/Module/Invite.php
index 3e1e98f89..aff0e9340 100644
--- a/Zotlabs/Module/Invite.php
+++ b/Zotlabs/Module/Invite.php
@@ -310,9 +310,9 @@ class Invite extends Controller {
function get() {
- // zai1
+ $channel_id = local_channel();
- if(! local_channel()) {
+ if ($channel_id === false || $channel_id < 1) {
notice( 'ZAI0101E,' . t('Permission denied.') . EOL);
return;
}
@@ -330,15 +330,15 @@ class Invite extends Controller {
return $o;
}
- // invitation_by_user may still not configured, the default 'na' will tell this
- // if configured, 0 disables invitations by users, other numbers are how many invites a user may propagate
- $invuser = Config::Get('system','invitation_by_user', 'na');
+ $ihave = $this->count_invites_by_user($channel_id);
- // if the mortal user drives the invitation
- If (! is_site_admin()) {
-
- // when not configured, 4 is the default
- $invuser = ($invuser === 'na') ? 4 : $invuser;
+ if (is_site_admin()) {
+ // Admins have unlimited invites
+ $invuser = '∞';
+ } else {
+ // invitation_by_user may still not configured, the default 'na' will tell this
+ // if configured, 0 disables invitations by users, other numbers are how many invites a user may propagate
+ $invuser = Config::Get('system','invitation_by_user', 4);
// a config value 0 disables invitation by users
if (!$invuser) {
@@ -350,12 +350,6 @@ class Invite extends Controller {
notice( 'ZAI0105W,' . t('You have no more invitations available') . EOL);
return '';
}
-
- } else {
- // general deity admin invite limit infinite (theoretical)
- if ($invuser === 'na') Config::Set('system','invitation_by_user', 4);
- // for display only
- $invuser = '∞';
}
// xchan record of the page observer
@@ -394,17 +388,6 @@ class Invite extends Controller {
}
}
- if ($wehave > $invmaxau) {
- if (! is_site_admin()) {
- $feedbk .= 'ZAI0200E,' . t('All users invitation limit exceeded.') . $eol;
- }
- }
-
- // let see how many invites currently used by the user
- $r = q("SELECT count(reg_id) AS n FROM register WHERE reg_vital = 1 AND reg_byc = %d",
- intval(local_channel()));
- $ihave = $r ? $r[0]['n'] : 0;
-
$tpl = get_markup_template('invite.tpl');
$inv_rabots = array(
@@ -420,11 +403,11 @@ class Invite extends Controller {
'field' => array(
'name' => 'expire',
'title' => t('duration up from now'),
- 'value' => ($invexpire_n ? $invexpire_n : 2),
+ 'value' => 2,
'min' => '1',
'max' => '99',
'size' => '2',
- 'default' => ($invexpire_u ? $invexpire_u : 'd')
+ 'default' => 'd',
),
'rabot' => $inv_rabots
)
@@ -583,5 +566,18 @@ class Invite extends Controller {
}
return false;
}
+
+ /**
+ * Find how many invites the given channel is currently using.
+ *
+ * @param int $channel_id The id of the channel
+ *
+ * @return int Number of invites this channel is currently using.
+ */
+ private function count_invites_by_user(int $channel): int {
+ $r = q("SELECT count(reg_id) AS n FROM register WHERE reg_vital = 1 AND reg_byc = %d", $channel);
+
+ return $r ? $r[0]['n'] : 0;
+ }
}
diff --git a/Zotlabs/Module/Regate.php b/Zotlabs/Module/Regate.php
index c67f45a88..956c5e2ea 100644
--- a/Zotlabs/Module/Regate.php
+++ b/Zotlabs/Module/Regate.php
@@ -375,7 +375,7 @@ class Regate extends \Zotlabs\Web\Controller {
]);
$reonar = json_decode( $r['reg_stuff'], true);
- $reonar['deny'] = $now . ',' . $ip . ' ' . $did2 . ' ' . $msg;
+ $reonar['deny'] = $now . ',' . $ip . ' ' . $did2;
$flags = ( $r['reg_flags'] &= ( $r['reg_flags'] ^ ACCOUNT_UNVERIFIED) )
| ( $r['reg_flags'] |= REGISTER_DENIED);
$rd = q("UPDATE register SET reg_stuff='%s', reg_vital=0, reg_flags=%d WHERE reg_id = %d ",
@@ -456,7 +456,7 @@ class Regate extends \Zotlabs\Web\Controller {
// $log = ' from § ' . $ip . ' §' . ' (' . dbesc($did2) . ')';
zar_log($msg);
$o = replace_macros(get_markup_template('plain.tpl'), [
- '$title' => $title,
+ '$title' => $msg,
'$now' => $nowfmt,
'$infos' => $msg
]);
diff --git a/phpstan.neon.dist b/phpstan.neon.dist
index 4a083851d..58f3b803d 100644
--- a/phpstan.neon.dist
+++ b/phpstan.neon.dist
@@ -8,4 +8,4 @@ parameters:
scanDirectories:
- library
ignoreErrors:
- - '#Method [\w:()_\\]+ should return (object|string) but return statement is missing.#'
+ - '#Method [\w:\(\)_\\]+ should return (object|string) but return statement is missing.#'