| @@ 1818-1852 (lines=35) @@ | ||
| 1815 | * @param int $id_msg |
|
| 1816 | * @param bool $include_count = true if true, it also returns the attachments count |
|
| 1817 | */ |
|
| 1818 | function attachmentsSizeForMessage($id_msg, $include_count = true) |
|
| 1819 | { |
|
| 1820 | $db = database(); |
|
| 1821 | ||
| 1822 | if ($include_count) |
|
| 1823 | { |
|
| 1824 | $request = $db->query('', ' |
|
| 1825 | SELECT COUNT(*), SUM(size) |
|
| 1826 | FROM {db_prefix}attachments |
|
| 1827 | WHERE id_msg = {int:id_msg} |
|
| 1828 | AND attachment_type = {int:attachment_type}', |
|
| 1829 | array( |
|
| 1830 | 'id_msg' => $id_msg, |
|
| 1831 | 'attachment_type' => 0, |
|
| 1832 | ) |
|
| 1833 | ); |
|
| 1834 | } |
|
| 1835 | else |
|
| 1836 | { |
|
| 1837 | $request = $db->query('', ' |
|
| 1838 | SELECT COUNT(*) |
|
| 1839 | FROM {db_prefix}attachments |
|
| 1840 | WHERE id_msg = {int:id_msg} |
|
| 1841 | AND attachment_type = {int:attachment_type}', |
|
| 1842 | array( |
|
| 1843 | 'id_msg' => $id_msg, |
|
| 1844 | 'attachment_type' => 0, |
|
| 1845 | ) |
|
| 1846 | ); |
|
| 1847 | } |
|
| 1848 | $size = $db->fetch_row($request); |
|
| 1849 | $db->free_result($request); |
|
| 1850 | ||
| 1851 | return $size; |
|
| 1852 | } |
|
| 1853 | ||
| 1854 | /** |
|
| 1855 | * This loads an attachment's contextual data including, most importantly, its size if it is an image. |
|
| @@ 1449-1491 (lines=43) @@ | ||
| 1446 | * @param int $board_id |
|
| 1447 | * @param int|null $topic_id |
|
| 1448 | */ |
|
| 1449 | function boardInfo($board_id, $topic_id = null) |
|
| 1450 | { |
|
| 1451 | $db = database(); |
|
| 1452 | ||
| 1453 | if (!empty($topic_id)) |
|
| 1454 | { |
|
| 1455 | $request = $db->query('', ' |
|
| 1456 | SELECT b.count_posts, b.name, m.subject |
|
| 1457 | FROM {db_prefix}boards AS b |
|
| 1458 | INNER JOIN {db_prefix}topics AS t ON (t.id_topic = {int:current_topic}) |
|
| 1459 | INNER JOIN {db_prefix}messages AS m ON (m.id_msg = t.id_first_msg) |
|
| 1460 | WHERE {query_see_board} |
|
| 1461 | AND b.id_board = {int:board} |
|
| 1462 | AND b.redirect = {string:blank_redirect} |
|
| 1463 | LIMIT 1', |
|
| 1464 | array( |
|
| 1465 | 'current_topic' => $topic_id, |
|
| 1466 | 'board' => $board_id, |
|
| 1467 | 'blank_redirect' => '', |
|
| 1468 | ) |
|
| 1469 | ); |
|
| 1470 | } |
|
| 1471 | else |
|
| 1472 | { |
|
| 1473 | $request = $db->query('', ' |
|
| 1474 | SELECT b.count_posts, b.name |
|
| 1475 | FROM {db_prefix}boards AS b |
|
| 1476 | WHERE {query_see_board} |
|
| 1477 | AND b.id_board = {int:board} |
|
| 1478 | AND b.redirect = {string:blank_redirect} |
|
| 1479 | LIMIT 1', |
|
| 1480 | array( |
|
| 1481 | 'board' => $board_id, |
|
| 1482 | 'blank_redirect' => '', |
|
| 1483 | ) |
|
| 1484 | ); |
|
| 1485 | } |
|
| 1486 | ||
| 1487 | $returns = $db->fetch_assoc($request); |
|
| 1488 | $db->free_result($request); |
|
| 1489 | ||
| 1490 | return $returns; |
|
| 1491 | } |
|
| 1492 | ||
| 1493 | /** |
|
| 1494 | * Loads properties from non-standard groups |
|