From: Roland Häder <Quix0r@users.noreply.github.com>
Date: Mon, 23 Jul 2018 22:52:48 +0000 (+0200)
Subject: Fixes: (#5477)
X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=00595de6a397a241507fc8603edea7e33fa94c43;p=friendica.git

Fixes: (#5477)

- use DBA::isResult() and not count()
- fixed 4 E_NOTICE when POST fields are not set
---

diff --git a/mod/events.php b/mod/events.php
index e9c2b1e73b..2bcc4261d2 100644
--- a/mod/events.php
+++ b/mod/events.php
@@ -124,7 +124,8 @@ function events_post(App $a) {
 	$c = q("SELECT `id` FROM `contact` WHERE `uid` = %d AND `self` LIMIT 1",
 		intval(local_user())
 	);
-	if (count($c)) {
+
+	if (DBA::isResult($c)) {
 		$self = $c[0]['id'];
 	} else {
 		$self = 0;
@@ -132,10 +133,10 @@ function events_post(App $a) {
 
 
 	if ($share) {
-		$str_group_allow   = perms2str($_POST['group_allow']);
-		$str_contact_allow = perms2str($_POST['contact_allow']);
-		$str_group_deny    = perms2str($_POST['group_deny']);
-		$str_contact_deny  = perms2str($_POST['contact_deny']);
+		$str_group_allow   = !empty($_POST['group_allow'])   ? perms2str($_POST['group_allow'])   : '';
+		$str_contact_allow = !empty($_POST['contact_allow']) ? perms2str($_POST['contact_allow']) : '';
+		$str_group_deny    = !empty($_POST['group_deny'])    ? perms2str($_POST['group_deny'])    : '';
+		$str_contact_deny  = !empty($_POST['contact_deny'])  ? perms2str($_POST['contact_deny'])  : '';
 
 		// Undo the pseudo-contact of self, since there are real contacts now
 		if (strpos($str_contact_allow, '<' . $self . '>') !== false ) {