| @@ 690-705 (lines=16) @@ | ||
| 687 | * @param array $where_parameters The parameters for the WHERE clause |
|
| 688 | * @return int The number of group requests |
|
| 689 | */ |
|
| 690 | function list_getGroupRequestCount($where, $where_parameters) |
|
| 691 | { |
|
| 692 | global $smcFunc; |
|
| 693 | ||
| 694 | $request = $smcFunc['db_query']('', ' |
|
| 695 | SELECT COUNT(*) |
|
| 696 | FROM {db_prefix}log_group_requests AS lgr |
|
| 697 | WHERE ' . $where, |
|
| 698 | array_merge($where_parameters, array( |
|
| 699 | )) |
|
| 700 | ); |
|
| 701 | list ($totalRequests) = $smcFunc['db_fetch_row']($request); |
|
| 702 | $smcFunc['db_free_result']($request); |
|
| 703 | ||
| 704 | return $totalRequests; |
|
| 705 | } |
|
| 706 | ||
| 707 | /** |
|
| 708 | * Callback function for createList() |
|
| @@ 1177-1193 (lines=17) @@ | ||
| 1174 | * @param string $approve_query Not used here |
|
| 1175 | * @return int The number of users on the watch list |
|
| 1176 | */ |
|
| 1177 | function list_getWatchedUserCount($approve_query) |
|
| 1178 | { |
|
| 1179 | global $smcFunc, $modSettings; |
|
| 1180 | ||
| 1181 | $request = $smcFunc['db_query']('', ' |
|
| 1182 | SELECT COUNT(*) |
|
| 1183 | FROM {db_prefix}members |
|
| 1184 | WHERE warning >= {int:warning_watch}', |
|
| 1185 | array( |
|
| 1186 | 'warning_watch' => $modSettings['warning_watch'], |
|
| 1187 | ) |
|
| 1188 | ); |
|
| 1189 | list ($totalMembers) = $smcFunc['db_fetch_row']($request); |
|
| 1190 | $smcFunc['db_free_result']($request); |
|
| 1191 | ||
| 1192 | return $totalMembers; |
|
| 1193 | } |
|
| 1194 | ||
| 1195 | /** |
|
| 1196 | * Callback for createList(). |
|
| @@ 1306-1326 (lines=21) @@ | ||
| 1303 | * @param string $approve_query A query to pull only approved items |
|
| 1304 | * @return int The total number of posts by watched users |
|
| 1305 | */ |
|
| 1306 | function list_getWatchedUserPostsCount($approve_query) |
|
| 1307 | { |
|
| 1308 | global $smcFunc, $modSettings; |
|
| 1309 | ||
| 1310 | $request = $smcFunc['db_query']('', ' |
|
| 1311 | SELECT COUNT(*) |
|
| 1312 | FROM {db_prefix}messages AS m |
|
| 1313 | INNER JOIN {db_prefix}members AS mem ON (mem.id_member = m.id_member) |
|
| 1314 | INNER JOIN {db_prefix}boards AS b ON (b.id_board = m.id_board) |
|
| 1315 | WHERE mem.warning >= {int:warning_watch} |
|
| 1316 | AND {query_see_board} |
|
| 1317 | ' . $approve_query, |
|
| 1318 | array( |
|
| 1319 | 'warning_watch' => $modSettings['warning_watch'], |
|
| 1320 | ) |
|
| 1321 | ); |
|
| 1322 | list ($totalMemberPosts) = $smcFunc['db_fetch_row']($request); |
|
| 1323 | $smcFunc['db_free_result']($request); |
|
| 1324 | ||
| 1325 | return $totalMemberPosts; |
|
| 1326 | } |
|
| 1327 | ||
| 1328 | /** |
|
| 1329 | * Callback for createList(). |
|
| @@ 625-648 (lines=24) @@ | ||
| 622 | * @param string $approve_query Additional restrictions based on the boards the approver can see |
|
| 623 | * @return int The number of unapproved attachments |
|
| 624 | */ |
|
| 625 | function list_getNumUnapprovedAttachments($approve_query) |
|
| 626 | { |
|
| 627 | global $smcFunc; |
|
| 628 | ||
| 629 | // How many unapproved attachments in total? |
|
| 630 | $request = $smcFunc['db_query']('', ' |
|
| 631 | SELECT COUNT(*) |
|
| 632 | FROM {db_prefix}attachments AS a |
|
| 633 | INNER JOIN {db_prefix}messages AS m ON (m.id_msg = a.id_msg) |
|
| 634 | INNER JOIN {db_prefix}boards AS b ON (b.id_board = m.id_board) |
|
| 635 | WHERE a.approved = {int:not_approved} |
|
| 636 | AND a.attachment_type = {int:attachment_type} |
|
| 637 | AND {query_see_board} |
|
| 638 | ' . $approve_query, |
|
| 639 | array( |
|
| 640 | 'not_approved' => 0, |
|
| 641 | 'attachment_type' => 0, |
|
| 642 | ) |
|
| 643 | ); |
|
| 644 | list ($total_unapproved_attachments) = $smcFunc['db_fetch_row']($request); |
|
| 645 | $smcFunc['db_free_result']($request); |
|
| 646 | ||
| 647 | return $total_unapproved_attachments; |
|
| 648 | } |
|
| 649 | ||
| 650 | /** |
|
| 651 | * Approve a post, just the one. |
|
| @@ 1717-1731 (lines=15) @@ | ||
| 1714 | * @param array $where_vars The parameters for $where |
|
| 1715 | * @return int Number of user errors |
|
| 1716 | */ |
|
| 1717 | function list_getUserErrorCount($where, $where_vars = array()) |
|
| 1718 | { |
|
| 1719 | global $smcFunc; |
|
| 1720 | ||
| 1721 | $request = $smcFunc['db_query']('', ' |
|
| 1722 | SELECT COUNT(*) AS error_count |
|
| 1723 | FROM {db_prefix}log_errors |
|
| 1724 | WHERE ' . $where, |
|
| 1725 | $where_vars |
|
| 1726 | ); |
|
| 1727 | list ($count) = $smcFunc['db_fetch_row']($request); |
|
| 1728 | $smcFunc['db_free_result']($request); |
|
| 1729 | ||
| 1730 | return (int) $count; |
|
| 1731 | } |
|
| 1732 | ||
| 1733 | /** |
|
| 1734 | * Gets all of the errors generated by a user's actions. Callback for the list in track_activity |
|
| @@ 1786-1801 (lines=16) @@ | ||
| 1783 | * @param array $where_vars The parameters for $where |
|
| 1784 | * @return int Count of messages matching the IP |
|
| 1785 | */ |
|
| 1786 | function list_getIPMessageCount($where, $where_vars = array()) |
|
| 1787 | { |
|
| 1788 | global $smcFunc; |
|
| 1789 | ||
| 1790 | $request = $smcFunc['db_query']('', ' |
|
| 1791 | SELECT COUNT(*) AS message_count |
|
| 1792 | FROM {db_prefix}messages AS m |
|
| 1793 | INNER JOIN {db_prefix}boards AS b ON (b.id_board = m.id_board) |
|
| 1794 | WHERE {query_see_board} AND ' . $where, |
|
| 1795 | $where_vars |
|
| 1796 | ); |
|
| 1797 | list ($count) = $smcFunc['db_fetch_row']($request); |
|
| 1798 | $smcFunc['db_free_result']($request); |
|
| 1799 | ||
| 1800 | return (int) $count; |
|
| 1801 | } |
|
| 1802 | ||
| 1803 | /** |
|
| 1804 | * Gets all the posts made from a particular IP |
|
| @@ 2227-2243 (lines=17) @@ | ||
| 2224 | * @param array $where_vars An array of parameters for $where |
|
| 2225 | * @return int count of messages matching the IP |
|
| 2226 | */ |
|
| 2227 | function list_getLoginCount($where, $where_vars = array()) |
|
| 2228 | { |
|
| 2229 | global $smcFunc; |
|
| 2230 | ||
| 2231 | $request = $smcFunc['db_query']('', ' |
|
| 2232 | SELECT COUNT(*) AS message_count |
|
| 2233 | FROM {db_prefix}member_logins |
|
| 2234 | WHERE id_member = {int:id_member}', |
|
| 2235 | array( |
|
| 2236 | 'id_member' => $where_vars['current_member'], |
|
| 2237 | ) |
|
| 2238 | ); |
|
| 2239 | list ($count) = $smcFunc['db_fetch_row']($request); |
|
| 2240 | $smcFunc['db_free_result']($request); |
|
| 2241 | ||
| 2242 | return (int) $count; |
|
| 2243 | } |
|
| 2244 | ||
| 2245 | /** |
|
| 2246 | * Callback for the list in trackLogins. |
|
| @@ 2387-2405 (lines=19) @@ | ||
| 2384 | * @param int $memID The ID of the member |
|
| 2385 | * @return int The number of profile edits |
|
| 2386 | */ |
|
| 2387 | function list_getProfileEditCount($memID) |
|
| 2388 | { |
|
| 2389 | global $smcFunc; |
|
| 2390 | ||
| 2391 | $request = $smcFunc['db_query']('', ' |
|
| 2392 | SELECT COUNT(*) AS edit_count |
|
| 2393 | FROM {db_prefix}log_actions |
|
| 2394 | WHERE id_log = {int:log_type} |
|
| 2395 | AND id_member = {int:owner}', |
|
| 2396 | array( |
|
| 2397 | 'log_type' => 2, |
|
| 2398 | 'owner' => $memID, |
|
| 2399 | ) |
|
| 2400 | ); |
|
| 2401 | list ($edit_count) = $smcFunc['db_fetch_row']($request); |
|
| 2402 | $smcFunc['db_free_result']($request); |
|
| 2403 | ||
| 2404 | return (int) $edit_count; |
|
| 2405 | } |
|
| 2406 | ||
| 2407 | /** |
|
| 2408 | * Loads up information about a user's profile edits. Callback for the list in trackEdits() |
|
| @@ 845-868 (lines=24) @@ | ||
| 842 | * @param int $event_id The ID of the event |
|
| 843 | * @return int|bool The ID of the poster or false if the event was not found |
|
| 844 | */ |
|
| 845 | function getEventPoster($event_id) |
|
| 846 | { |
|
| 847 | global $smcFunc; |
|
| 848 | ||
| 849 | // A simple database query, how hard can that be? |
|
| 850 | $request = $smcFunc['db_query']('', ' |
|
| 851 | SELECT id_member |
|
| 852 | FROM {db_prefix}calendar |
|
| 853 | WHERE id_event = {int:id_event} |
|
| 854 | LIMIT 1', |
|
| 855 | array( |
|
| 856 | 'id_event' => $event_id, |
|
| 857 | ) |
|
| 858 | ); |
|
| 859 | ||
| 860 | // No results, return false. |
|
| 861 | if ($smcFunc['db_num_rows'] === 0) |
|
| 862 | return false; |
|
| 863 | ||
| 864 | // Grab the results and return. |
|
| 865 | list ($poster) = $smcFunc['db_fetch_row']($request); |
|
| 866 | $smcFunc['db_free_result']($request); |
|
| 867 | return (int) $poster; |
|
| 868 | } |
|
| 869 | ||
| 870 | /** |
|
| 871 | * Consolidating the various INSERT statements into this function. |
|