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