You are here

function _ad_channel_get_containers in Advertisement 6.3

Same name and namespace in other branches
  1. 5.2 channel/ad_channel.module \_ad_channel_get_containers()
  2. 6.2 channel/ad_channel.module \_ad_channel_get_containers()
  3. 7 channel/ad_channel.module \_ad_channel_get_containers()

Load one or more containers, caching the results.

4 calls to _ad_channel_get_containers()
ad_channel_admin_confirm_delete_container_submit in channel/ad_channel.module
Delete a container.
ad_channel_admin_container in channel/ad_channel.module
Administrative page for creating or editing containers.
ad_channel_admin_overview in channel/ad_channel.module
Display containers and channels.
ad_channel_form_alter in channel/ad_channel.module
Implementation of hook_form_alter(). Generate a form for selecting channels to associate with an advertisement.

File

channel/ad_channel.module, line 864
Ad Channel module.

Code

function _ad_channel_get_containers($conid = 0) {
  static $cache;
  if (!isset($cache[$conid])) {
    if ($conid) {
      $cache[$conid] = db_fetch_object(db_query('SELECT * FROM {ad_channel_container} WHERE conid = %d', $conid));
    }
    else {

      // Get all manually defined channels.
      $result = db_query('SELECT conid, name, description, weight FROM {ad_channel_container} ORDER BY weight ASC');
      while ($container = db_fetch_object($result)) {
        $containers[$container->conid] = $container;
      }

      // Define default 'No container'.
      $none->conid = 0;
      $none->name = t('No container');
      $none->weight = 0;
      $containers[0] = $none;
      $cache[$conid] = $containers;
    }
  }
  return $cache[$conid];
}