You are here

function og_block_new in Organic groups 6

Same name and namespace in other branches
  1. 5.8 og.module \og_block_new()
  2. 5 og.module \og_block_new()
  3. 5.2 og.module \og_block_new()
  4. 5.3 og.module \og_block_new()
  5. 5.7 og.module \og_block_new()
  6. 6.2 og.module \og_block_new()
1 call to og_block_new()
og_block in ./og.module
Implementation of hook_block().

File

./og.module, line 2481

Code

function og_block_new() {
  list($types, $in) = og_get_sql_args();
  $sql = "SELECT COUNT(*) FROM {node} n INNER JOIN {og} og ON n.nid = og.nid WHERE og.og_directory=1 AND n.type {$in} AND n.status = 1";
  $cnt = db_result(db_query(db_rewrite_sql($sql), $types));
  if ($cnt > 0) {
    $max = variable_get('og_block_cnt_3', 10);
    $sql = "SELECT n.nid, n.title FROM {node} n INNER JOIN {og} og ON n.nid = og.nid WHERE n.status = 1 AND n.type {$in} AND og.og_directory=1 ORDER BY nid DESC";
    $result = db_query_range(db_rewrite_sql($sql), $types, 0, $max);
    $output = node_title_list($result);
    if ($cnt > $max) {
      $output .= '<div class="more-link">' . l(t('more'), 'og', array(
        'title' => t('Browse the newest groups.'),
      )) . '</div>';
    }
    $block['subject'] = t('New groups');
    $block['content'] = $output;
    return $block;
  }
}