Mercurial > defr > drupal > ad
comparison weight/probability/ad_weight_probability.module @ 7:6aeff3329e01 ad
maj module ad 2.1rc1
| author | piotre |
|---|---|
| date | Mon, 20 Jul 2009 13:54:40 +0000 |
| parents | 0d1c70d51fbe |
| children |
comparison
equal
deleted
inserted
replaced
| 6:b7653861e0b4 | 7:6aeff3329e01 |
|---|---|
| 1 <?php | 1 <?php |
| 2 // $Id: ad_weight_probability.module,v 1.1.4.6 2009/04/22 15:14:46 jeremy Exp $ | 2 // $Id: ad_weight_probability.module,v 1.1.4.8 2009/07/11 16:39:22 jeremy Exp $ |
| 3 | 3 |
| 4 /** | 4 /** |
| 5 * @file | 5 * @file |
| 6 * A plug in for the ad.module, allowing an admin to set the probability that | 6 * A plug in for the ad.module, allowing an admin to set the probability that |
| 7 * a given advertisement will be displayed. | 7 * a given advertisement will be displayed. |
| 33 '#options' => _ad_weight_probability_weights(), | 33 '#options' => _ad_weight_probability_weights(), |
| 34 '#default_value' => isset($node->probability) ? $node->probability : 100, | 34 '#default_value' => isset($node->probability) ? $node->probability : 100, |
| 35 '#description' => t('The greater the probability, the more frequently this advertisement will be displayed. An advertisement with a probablity of 2 will be displayed twice as frequently as an advertisement with a probability of 1.'), | 35 '#description' => t('The greater the probability, the more frequently this advertisement will be displayed. An advertisement with a probablity of 2 will be displayed twice as frequently as an advertisement with a probability of 1.'), |
| 36 ); | 36 ); |
| 37 $form['weighting']['#weight'] = -1; | 37 $form['weighting']['#weight'] = -1; |
| 38 } | |
| 39 // TODO: This hack requires that the ad_channel module is enabled to work. | |
| 40 // Ultimately ad.admin.inc should be enhanced to allow plug-in modules to | |
| 41 // modify the overview page. | |
| 42 else if ($form_id == 'ad_admin_ads' && function_exists('ad_channel_form_alter')) { | |
| 43 if (variable_get('ad_channel_admin_list', AD_CHANNEL_LIST_CHANNEL) != AD_CHANNEL_LIST_GROUP) { | |
| 44 $weights = _ad_weight_probability_weights(); | |
| 45 // ensure a filter has not been set that yeilds no results | |
| 46 if (isset($form['title']) && is_array($form['title'])) { | |
| 47 foreach ($form['title'] as $aid => $value) { | |
| 48 $node->nid = $aid; | |
| 49 $result = _ad_weight_probability_node_load($node); | |
| 50 $form['probability'][$aid]['#value'] = $weights[$result['probability']]; | |
| 51 } | |
| 52 } | |
| 53 } | |
| 38 } | 54 } |
| 39 } | 55 } |
| 40 | 56 |
| 41 /** | 57 /** |
| 42 * Implementation of hook_nodeapi(). | 58 * Implementation of hook_nodeapi(). |
