mirror of
https://github.com/friendica/friendica
synced 2025-01-03 18:42:19 +00:00
Replace q() with DBA methods, fix code style
- Remove unused variables - Fix doc block - Fix indentation
This commit is contained in:
parent
d838e6d0ec
commit
5abc22f6c5
3 changed files with 74 additions and 75 deletions
|
@ -303,41 +303,51 @@ function message_content(App $a)
|
||||||
|
|
||||||
$o .= $header;
|
$o .= $header;
|
||||||
|
|
||||||
$r = q("SELECT `mail`.*, `contact`.`name`, `contact`.`url`, `contact`.`thumb`
|
$message = DBA::fetchFirst("
|
||||||
FROM `mail` LEFT JOIN `contact` ON `mail`.`contact-id` = `contact`.`id`
|
SELECT `mail`.*, `contact`.`name`, `contact`.`url`, `contact`.`thumb`
|
||||||
WHERE `mail`.`uid` = %d AND `mail`.`id` = %d LIMIT 1",
|
FROM `mail`
|
||||||
intval(local_user()),
|
LEFT JOIN `contact` ON `mail`.`contact-id` = `contact`.`id`
|
||||||
intval($a->argv[1])
|
WHERE `mail`.`uid` = ? AND `mail`.`id` = ?
|
||||||
|
LIMIT 1",
|
||||||
|
local_user(),
|
||||||
|
$a->argv[1]
|
||||||
);
|
);
|
||||||
if (DBA::isResult($r)) {
|
if (DBA::isResult($message)) {
|
||||||
$contact_id = $r[0]['contact-id'];
|
$contact_id = $message['contact-id'];
|
||||||
$convid = $r[0]['convid'];
|
|
||||||
|
|
||||||
$sql_extra = sprintf(" and `mail`.`parent-uri` = '%s' ", DBA::escape($r[0]['parent-uri']));
|
$params = [
|
||||||
if ($convid)
|
local_user(),
|
||||||
$sql_extra = sprintf(" and ( `mail`.`parent-uri` = '%s' OR `mail`.`convid` = '%d' ) ",
|
$message['parent-uri']
|
||||||
DBA::escape($r[0]['parent-uri']),
|
];
|
||||||
intval($convid)
|
|
||||||
|
if ($message['convid']) {
|
||||||
|
$sql_extra = "AND (`mail`.`parent-uri` = ? OR `mail`.`convid` = ?)";
|
||||||
|
$params[] = $message['convid'];
|
||||||
|
} else {
|
||||||
|
$sql_extra = "AND `mail`.`parent-uri` = ?";
|
||||||
|
}
|
||||||
|
$messages_stmt = DBA::p("
|
||||||
|
SELECT `mail`.*, `contact`.`name`, `contact`.`url`, `contact`.`thumb`
|
||||||
|
FROM `mail`
|
||||||
|
LEFT JOIN `contact` ON `mail`.`contact-id` = `contact`.`id`
|
||||||
|
WHERE `mail`.`uid` = ?
|
||||||
|
$sql_extra
|
||||||
|
ORDER BY `mail`.`created` ASC",
|
||||||
|
...$params
|
||||||
);
|
);
|
||||||
|
|
||||||
$messages = q("SELECT `mail`.*, `contact`.`name`, `contact`.`url`, `contact`.`thumb`
|
$messages = DBA::toArray($messages_stmt);
|
||||||
FROM `mail` LEFT JOIN `contact` ON `mail`.`contact-id` = `contact`.`id`
|
|
||||||
WHERE `mail`.`uid` = %d $sql_extra ORDER BY `mail`.`created` ASC",
|
DBA::update('mail', ['seen' => 1], ['parent-uri' => $message['parent-uri'], 'uid' => local_user()]);
|
||||||
intval(local_user())
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
$messages = false;
|
$messages = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!DBA::isResult($messages)) {
|
if (!DBA::isResult($messages)) {
|
||||||
notice(L10n::t('Message not available.') . EOL);
|
notice(L10n::t('Message not available.') . EOL);
|
||||||
return $o;
|
return $o;
|
||||||
}
|
}
|
||||||
|
|
||||||
$r = q("UPDATE `mail` SET `seen` = 1 WHERE `parent-uri` = '%s' AND `uid` = %d",
|
|
||||||
DBA::escape($r[0]['parent-uri']),
|
|
||||||
intval(local_user())
|
|
||||||
);
|
|
||||||
|
|
||||||
$tpl = Renderer::getMarkupTemplate('msg-header.tpl');
|
$tpl = Renderer::getMarkupTemplate('msg-header.tpl');
|
||||||
$a->page['htmlhead'] .= Renderer::replaceMacros($tpl, [
|
$a->page['htmlhead'] .= Renderer::replaceMacros($tpl, [
|
||||||
'$baseurl' => System::baseUrl(true),
|
'$baseurl' => System::baseUrl(true),
|
||||||
|
@ -350,8 +360,10 @@ function message_content(App $a)
|
||||||
$unknown = false;
|
$unknown = false;
|
||||||
|
|
||||||
foreach ($messages as $message) {
|
foreach ($messages as $message) {
|
||||||
if ($message['unknown'])
|
if ($message['unknown']) {
|
||||||
$unknown = true;
|
$unknown = true;
|
||||||
|
}
|
||||||
|
|
||||||
if ($message['from-url'] == $myprofile) {
|
if ($message['from-url'] == $myprofile) {
|
||||||
$from_url = $myprofile;
|
$from_url = $myprofile;
|
||||||
$sparkle = '';
|
$sparkle = '';
|
||||||
|
|
13
mod/ping.php
13
mod/ping.php
|
@ -64,14 +64,7 @@ function ping_init(App $a)
|
||||||
$format = 'json';
|
$format = 'json';
|
||||||
}
|
}
|
||||||
|
|
||||||
$tags = [];
|
|
||||||
$comments = [];
|
|
||||||
$likes = [];
|
|
||||||
$dislikes = [];
|
|
||||||
$friends = [];
|
|
||||||
$posts = [];
|
|
||||||
$regs = [];
|
$regs = [];
|
||||||
$mails = [];
|
|
||||||
$notifications = [];
|
$notifications = [];
|
||||||
|
|
||||||
$intro_count = 0;
|
$intro_count = 0;
|
||||||
|
@ -427,8 +420,6 @@ function ping_get_notifications($uid)
|
||||||
$order = "DESC";
|
$order = "DESC";
|
||||||
$quit = false;
|
$quit = false;
|
||||||
|
|
||||||
$a = get_app();
|
|
||||||
|
|
||||||
do {
|
do {
|
||||||
$r = q(
|
$r = q(
|
||||||
"SELECT `notify`.*, `item`.`visible`, `item`.`deleted`
|
"SELECT `notify`.*, `item`.`visible`, `item`.`deleted`
|
||||||
|
@ -505,8 +496,8 @@ function ping_get_notifications($uid)
|
||||||
* @param array $notifs Complete list of notification
|
* @param array $notifs Complete list of notification
|
||||||
* @param array $sysmsgs List of system notice messages
|
* @param array $sysmsgs List of system notice messages
|
||||||
* @param array $sysmsgs_info List of system info messages
|
* @param array $sysmsgs_info List of system info messages
|
||||||
* @param int $groups_unseen Number of unseen group items
|
* @param array $groups_unseen List of unseen group messages
|
||||||
* @param int $forums_unseen Number of unseen forum items
|
* @param array $forums_unseen List of unseen forum messages
|
||||||
*
|
*
|
||||||
* @return array XML-transform ready data array
|
* @return array XML-transform ready data array
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1807,31 +1807,28 @@ class Diaspora
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
q(
|
DBA::insert('mail', [
|
||||||
"INSERT INTO `mail` (`uid`, `guid`, `convid`, `from-name`,`from-photo`,`from-url`,`contact-id`,`title`,`body`,`seen`,`reply`,`uri`,`parent-uri`,`created`)
|
'uid' => $importer['uid'],
|
||||||
VALUES (%d, '%s', %d, '%s', '%s', '%s', %d, '%s', '%s', %d, %d, '%s','%s','%s')",
|
'guid' => $msg_guid,
|
||||||
intval($importer["uid"]),
|
'convid' => $conversation['id'],
|
||||||
DBA::escape($msg_guid),
|
'from-name' => $person['name'],
|
||||||
intval($conversation["id"]),
|
'from-photo' => $person['photo'],
|
||||||
DBA::escape($person["name"]),
|
'from-url' => $person['url'],
|
||||||
DBA::escape($person["photo"]),
|
'contact-id' => $contact['id'],
|
||||||
DBA::escape($person["url"]),
|
'title' => $subject,
|
||||||
intval($contact["id"]),
|
'body' => $body,
|
||||||
DBA::escape($subject),
|
'seen' => 0,
|
||||||
DBA::escape($body),
|
'reply' => 0,
|
||||||
0,
|
'uri' => $message_uri,
|
||||||
0,
|
'parent-uri' => $author . ':' . $guid,
|
||||||
DBA::escape($message_uri),
|
'created' => $msg_created_at
|
||||||
DBA::escape($author.":".$guid),
|
]);
|
||||||
DBA::escape($msg_created_at)
|
|
||||||
);
|
|
||||||
|
|
||||||
DBA::unlock();
|
DBA::unlock();
|
||||||
|
|
||||||
DBA::update('conv', ['updated' => DateTimeFormat::utcNow()], ['id' => $conversation["id"]]);
|
DBA::update('conv', ['updated' => DateTimeFormat::utcNow()], ['id' => $conversation["id"]]);
|
||||||
|
|
||||||
notification(
|
notification([
|
||||||
[
|
|
||||||
"type" => NOTIFY_MAIL,
|
"type" => NOTIFY_MAIL,
|
||||||
"notify_flags" => $importer["notify-flags"],
|
"notify_flags" => $importer["notify-flags"],
|
||||||
"language" => $importer["language"],
|
"language" => $importer["language"],
|
||||||
|
@ -1843,8 +1840,9 @@ class Diaspora
|
||||||
"source_link" => $person["url"],
|
"source_link" => $person["url"],
|
||||||
"source_photo" => $person["photo"],
|
"source_photo" => $person["photo"],
|
||||||
"verb" => ACTIVITY_POST,
|
"verb" => ACTIVITY_POST,
|
||||||
"otype" => "mail"]
|
"otype" => "mail"
|
||||||
);
|
]);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2066,24 +2064,22 @@ class Diaspora
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
q(
|
DBA::insert('mail', [
|
||||||
"INSERT INTO `mail` (`uid`, `guid`, `convid`, `from-name`,`from-photo`,`from-url`,`contact-id`,`title`,`body`,`seen`,`reply`,`uri`,`parent-uri`,`created`)
|
'uid' => $importer['uid'],
|
||||||
VALUES ( %d, '%s', %d, '%s', '%s', '%s', %d, '%s', '%s', %d, %d, '%s','%s','%s')",
|
'guid' => $guid,
|
||||||
intval($importer["uid"]),
|
'convid' => $conversation['id'],
|
||||||
DBA::escape($guid),
|
'from-name' => $person['name'],
|
||||||
intval($conversation["id"]),
|
'from-photo' => $person['photo'],
|
||||||
DBA::escape($person["name"]),
|
'from-url' => $person['url'],
|
||||||
DBA::escape($person["photo"]),
|
'contact-id' => $contact['id'],
|
||||||
DBA::escape($person["url"]),
|
'title' => $conversation['subject'],
|
||||||
intval($contact["id"]),
|
'body' => $body,
|
||||||
DBA::escape($conversation["subject"]),
|
'seen' => 0,
|
||||||
DBA::escape($body),
|
'reply' => 1,
|
||||||
0,
|
'uri' => $message_uri,
|
||||||
1,
|
'parent-uri' => $author.":".$conversation['guid'],
|
||||||
DBA::escape($message_uri),
|
'created' => $created_at
|
||||||
DBA::escape($author.":".$conversation["guid"]),
|
]);
|
||||||
DBA::escape($created_at)
|
|
||||||
);
|
|
||||||
|
|
||||||
DBA::unlock();
|
DBA::unlock();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue