You are here

function ad_channel_admin_channel_validate in Advertisement 5.2

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

Validate the channel.

File

channel/ad_channel.module, line 727
Ad Channel

Code

function ad_channel_admin_channel_validate($form_id, $form_values) {
  $chid = 0;
  if ($form_values['op'] == t('Create')) {
    $chid = db_result(db_query("SELECT chid FROM {ad_channel} WHERE name = '%s'", $form_values['name']));
  }
  else {
    if ($form_values['op'] == t('Update')) {
      $chid = db_result(db_query("SELECT chid FROM {ad_channel} WHERE name = '%s' AND chid != %d", $form_values['name'], $form_values['chid']));
    }
  }
  if ($chid) {
    form_set_error('name', t('A channel named %name already exists.', array(
      '%name' => $form_values['name'],
    )));
  }
}