<?php
+
+use Friendica\App;
+
require_once('include/Emailer.php');
require_once('include/email.php');
require_once('include/bbcode.php');
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;
}
// If so don't create a second notification
$p = null;
- $p = q("SELECT `id` FROM `notify` WHERE (`type` = %d OR `type` = %d OR `type` = %d) AND `link` = '%s' AND `uid` = %d LIMIT 1",
+ $p = q("SELECT `id` FROM `notify` WHERE `type` IN (%d, %d, %d) AND `link` = '%s' AND `uid` = %d LIMIT 1",
intval(NOTIFY_TAGSELF),
intval(NOTIFY_COMMENT),
intval(NOTIFY_SHARE),
dbesc($params['link']),
intval($params['uid'])
);
- if ($p and count($p)) {
+ if ($p && count($p)) {
pop_lang();
return;
}
$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);
+ }
+ } while ($dups == true);
+ /// @TODO One statement is enough
$datarray = array();
$datarray['hash'] = $hash;
$datarray['name'] = $params['source_name'];
// After we've stored everything, look again to see if there are any duplicates and if so remove them
$p = null;
- $p = q("SELECT `id` FROM `notify` WHERE (`type` = %d OR `type` = %d) AND `link` = '%s' AND `uid` = %d ORDER BY `id`",
+ $p = q("SELECT `id` FROM `notify` WHERE `type` IN (%d, %d) AND `link` = '%s' AND `uid` = %d ORDER BY `id`",
intval(NOTIFY_TAGSELF),
intval(NOTIFY_COMMENT),
dbesc($params['link']),
);
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
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?
// 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;
$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;
}
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;
}