Commit 7f179b10 authored by Steven Jones's avatar Steven Jones

Issue #1503824 by Steven Jones: Fixed hosting_site_count() ignores disabled sites.

parent 79bf6016
......@@ -285,45 +285,46 @@ function hosting_site_access($op, $node, $account) {
/**
* Returns a count of sites.
*
* This is used by cron and statistics to batch the number of sites that are processed with each call
*
* It is also used to generate the 'site count' per platform at /hosting/platforms
* This is used by cron and statistics to batch the number of sites that are
* processed with each call. It is also used to generate the 'site count' per
* platform at /hosting/platforms
*
* By default it only counts enabled sites.
*
* Optionally can include an array of site statuses by which to consider in the count.
*
*
* Optionally can include an array of site statuses by which to consider in the
* count.
*
* @param $platform
* (optional) A platform nid to only count sites on that specific platform.
*
* @param $statuses
* (optional) An array of site statuses (defined by their constants) by which to include
* such sites in the site count.
* (optional) An array of site statuses (defined by their constants) by which
* to include such sites in the site count.
*
* @return
* The result of the database query
* @return
* The number of sites matching the specified criteria.
*/
function hosting_site_count($platform = null, $statuses = NULL) {
$args = array();
$query = "SELECT count(nid) FROM {hosting_site} WHERE";
function hosting_site_count($platform = NULL, $statuses = NULL) {
if (is_null($statuses)) {
$query .= " status = %d";
$args[] = HOSTING_SITE_ENABLED;
$statuses = array(HOSTING_SITE_ENABLED);
}
$args = array();
$query = "SELECT count(nid) FROM {hosting_site}";
$where = array();
else {
if (count($statuses)) {
$query .= ' (status IN (' . db_placeholders($statuses) . '))';
$args = array_merge($args, $statuses);
}
if (count($statuses)) {
$where[] = '(status IN (' . db_placeholders($statuses) . '))';
$args = array_merge($args, $statuses);
}
if (!is_null($platform)) {
$query .= " AND platform = %d";
$where[] = "(platform = %d)";
$args[] = $platform;
}
if (!empty($where)) {
$query .= ' WHERE ' . implode(' AND ', $where);
}
return db_result(db_query($query, $args));
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment