You are here

function _photos_res_count in Album Photos 7.3

Same name and namespace in other branches
  1. 6.2 photos.module \_photos_res_count()

Update count.

1 call to _photos_res_count()
photos_cron in ./photos.module
Implements hook_cron().

File

./photos.module, line 1945
Implementation of photos.module.

Code

function _photos_res_count($cron = 0) {
  photos_set_count('site_album');
  photos_set_count('site_image');
  $time = $cron ? 7200 : 0;
  if (REQUEST_TIME - variable_get('cron_last', 0) > $time) {
    $result = db_query('SELECT uid FROM {users} WHERE uid <> 0');
    foreach ($result as $t) {
      photos_set_count('user_image', $t->uid);
      photos_set_count('user_album', $t->uid);
    }
    $result = db_query('SELECT pid FROM {photos_album}');
    foreach ($result as $t) {
      photos_set_count('node_album', $t->pid);
    }
    $result = db_query('SELECT DISTINCT(nid) FROM {photos_node}');
    foreach ($result as $t) {
      photos_set_count('node_node', $t->nid);
    }
  }
}