X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fenotify.php;h=99d5ea0ab3939504f7458cac9a919efe46e613a3;hb=27646cc4ad8d715317a2ca055b6c3318ddf555a9;hp=e351f0d115c37ec41c5f5bdb842fce45a37de59f;hpb=7a9456d5ac2e73229b2237074c700731c63661a6;p=friendica.git diff --git a/include/enotify.php b/include/enotify.php index e351f0d115..99d5ea0ab3 100644 --- a/include/enotify.php +++ b/include/enotify.php @@ -1,11 +1,15 @@ config['sitename']; if (!x($a->config['admin_name'])) @@ -45,9 +49,16 @@ function notification($params) { if (empty($sender_email)) $sender_email = t('noreply').'@'.$hostname; - $user = q("SELECT `nickname` FROM `user` WHERE `uid` = %d", intval($params['uid'])); - if ($user) - $nickname = $user[0]["nickname"]; + if ($params['type'] != SYSTEM_EMAIL) { + $user = dba::select('user', array('nickname', 'page-flags'), + array('uid' => $params['uid']), array('limit' => 1)); + + // There is no need to create notifications for forum accounts + if (!DBM::is_result($user) || in_array($user["page-flags"], array(PAGE_COMMUNITY, PAGE_PRVGROUP))) { + return; + } + } + $nickname = $user["nickname"]; // with $params['show_in_notification_page'] == false, the notification isn't inserted into // the database, and an email is sent if applicable. @@ -61,7 +72,7 @@ function notification($params) { $additional_mail_header .= "X-Friendica-Platform: ".FRIENDICA_PLATFORM."\n"; $additional_mail_header .= "X-Friendica-Version: ".FRIENDICA_VERSION."\n"; $additional_mail_header .= "List-ID: \n"; - $additional_mail_header .= "List-Archive: <".App::get_baseurl()."/notifications/system>\n"; + $additional_mail_header .= "List-Archive: <".System::baseUrl()."/notifications/system>\n"; if (array_key_exists('item', $params)) { $title = $params['item']['title']; @@ -99,7 +110,7 @@ function notification($params) { intval($parent_id), intval($params['uid']) ); - if ($p AND count($p) AND ($p[0]["ignored"])) { + if ($p && count($p) && ($p[0]["ignored"])) { logger("Thread ".$parent_id." will be ignored", LOGGER_DEBUG); return; } @@ -115,7 +126,7 @@ function notification($params) { dbesc($params['link']), intval($params['uid']) ); - if ($p and count($p)) { + if ($p && count($p)) { pop_lang(); return; } @@ -360,7 +371,7 @@ function notification($params) { } } - if ($params['type'] == "SYSTEM_EMAIL") { + if ($params['type'] == SYSTEM_EMAIL) { // not part of the notifications. // it just send a mail to the user. // It will be used by the system to send emails to users (like @@ -414,7 +425,7 @@ function notification($params) { $hash = random_string(); $r = q("SELECT `id` FROM `notify` WHERE `hash` = '%s' LIMIT 1", dbesc($hash)); - if (dbm::is_result($r)) { + if (DBM::is_result($r)) { $dups = true; } } while ($dups == true); @@ -485,9 +496,7 @@ function notification($params) { ); if ($p && (count($p) > 1)) { for ($d = 1; $d < count($p); $d ++) { - q("DELETE FROM `notify` WHERE `id` = %d", - intval($p[$d]['id']) - ); + dba::delete('notify', array('id' => $p[$d]['id'])); } // only continue on if we stored the first one @@ -499,7 +508,7 @@ function notification($params) { } - $itemlink = App::get_baseurl().'/notify/view/'.$notify_id; + $itemlink = System::baseUrl().'/notify/view/'.$notify_id; $msg = replace_macros($epreamble, array('$itemlink' => $itemlink)); $msg_cache = format_notification_message($datarray['name_cache'], strip_tags(bbcode($msg))); $r = q("UPDATE `notify` SET `msg` = '%s', `msg_cache` = '%s' WHERE `id` = %d AND `uid` = %d", @@ -513,11 +522,11 @@ function notification($params) { // send email notification if notification preferences permit if ((intval($params['notify_flags']) & intval($params['type'])) || $params['type'] == NOTIFY_SYSTEM - || $params['type'] == "SYSTEM_EMAIL") { + || $params['type'] == SYSTEM_EMAIL) { logger('sending notification email'); - if (isset($params['parent']) AND (intval($params['parent']) != 0)) { + if (isset($params['parent']) && (intval($params['parent']) != 0)) { $id_for_parent = $params['parent']."@".$hostname; // Is this the first email notification for this parent item and user? @@ -582,8 +591,8 @@ function notification($params) { call_hooks('enotify_mail', $datarray); // check whether sending post content in email notifications is allowed - // always true for "SYSTEM_EMAIL" - $content_allowed = ((!get_config('system', 'enotify_no_content')) || ($params['type'] == "SYSTEM_EMAIL")); + // always true for SYSTEM_EMAIL + $content_allowed = ((!Config::get('system', 'enotify_no_content')) || ($params['type'] == SYSTEM_EMAIL)); // load the template for private message notifications $tpl = get_markup_template('email_notify_html.tpl'); @@ -629,7 +638,8 @@ function notification($params) { // use the Emailer class to send the message - return Emailer::send(array( + return Emailer::send( + array( 'uid' => $params['uid'], 'fromName' => $sender_name, 'fromEmail' => $sender_email, @@ -638,11 +648,11 @@ function notification($params) { 'messageSubject' => $datarray['subject'], 'htmlVersion' => $email_html_body, 'textVersion' => $email_text_body, - 'additionalMailHeader' => $datarray['headers'], - )); + 'additionalMailHeader' => $datarray['headers']) + ); } - return False; + return false; } /** @@ -670,7 +680,7 @@ function check_item_notification($itemid, $uid, $defaulttype = "") { $profiles[] = $owner[0]["url"]; // Notifications from Diaspora are often with an URL in the Diaspora format - $profiles[] = App::get_baseurl()."/u/".$user[0]["nickname"]; + $profiles[] = System::baseUrl()."/u/".$user[0]["nickname"]; $profiles2 = array(); @@ -678,7 +688,7 @@ function check_item_notification($itemid, $uid, $defaulttype = "") { // Check for invalid profile urls. 13 should be the shortest possible profile length: // http://a.bc/d // Additionally check for invalid urls that would return the normalised value "http:" - if ((strlen($profile) >= 13) AND (normalise_link($profile) != "http:")) { + if ((strlen($profile) >= 13) && (normalise_link($profile) != "http:")) { if (!in_array($profile, $profiles2)) $profiles2[] = $profile; @@ -724,7 +734,7 @@ function check_item_notification($itemid, $uid, $defaulttype = "") { $params["to_email"] = $user[0]["email"]; $params["item"] = $item[0]; $params["parent"] = $item[0]["parent"]; - $params["link"] = App::get_baseurl().'/display/'.urlencode($item[0]["guid"]); + $params["link"] = System::baseUrl().'/display/'.urlencode($item[0]["guid"]); $params["otype"] = 'item'; $params["source_name"] = $item[0]["author-name"]; $params["source_link"] = $item[0]["author-link"]; @@ -736,17 +746,17 @@ function check_item_notification($itemid, $uid, $defaulttype = "") { intval($item[0]['contact-id']), intval($uid) ); - $send_notification = dbm::is_result($r); + $send_notification = DBM::is_result($r); if (!$send_notification) { $tags = q("SELECT `url` FROM `term` WHERE `otype` = %d AND `oid` = %d AND `type` = %d AND `uid` = %d", intval(TERM_OBJ_POST), intval($itemid), intval(TERM_MENTION), intval($uid)); - if (dbm::is_result($tags)) { + if (DBM::is_result($tags)) { foreach ($tags AS $tag) { $r = q("SELECT `id` FROM `contact` WHERE `nurl` = '%s' AND `uid` = %d AND `notify_new_posts`", normalise_link($tag["url"]), intval($uid)); - if (dbm::is_result($r)) + if (DBM::is_result($r)) $send_notification = true; } } @@ -762,11 +772,11 @@ function check_item_notification($itemid, $uid, $defaulttype = "") { $tagged = false; foreach ($profiles AS $profile) { - if (strpos($item[0]["tag"], "=".$profile."]") OR strpos($item[0]["body"], "=".$profile."]")) + if (strpos($item[0]["tag"], "=".$profile."]") || strpos($item[0]["body"], "=".$profile."]")) $tagged = true; } - if ($item[0]["mention"] OR $tagged OR ($defaulttype == NOTIFY_TAGSELF)) { + if ($item[0]["mention"] || $tagged || ($defaulttype == NOTIFY_TAGSELF)) { $params["type"] = NOTIFY_TAGSELF; $params["verb"] = ACTIVITY_TAG; } @@ -778,7 +788,7 @@ function check_item_notification($itemid, $uid, $defaulttype = "") { LIMIT 1", intval($item[0]["parent"]), intval($uid)); - if ($parent AND !isset($params["type"])) { + if ($parent && !isset($params["type"])) { $params["type"] = NOTIFY_COMMENT; $params["verb"] = ACTIVITY_POST; }