comparison text/ad_text.module @ 1:948362c2a207 ad

update advertisement
author pierre
date Thu, 02 Apr 2009 15:28:21 +0000
parents d8a3998dac8e
children
comparison
equal deleted inserted replaced
0:d8a3998dac8e 1:948362c2a207
1 <?php 1 <?php
2 // $Id: ad_text.module,v 1.2.2.7.2.24.2.13 2009/02/17 18:56:26 jeremy Exp $ 2 // $Id: ad_text.module,v 1.2.2.7.2.24.2.13.2.3 2009/03/31 04:41:03 jeremy Exp $
3 3
4 /** 4 /**
5 * @file 5 * @file
6 * Enhances the ad module to support static text ads. 6 * Enhances the ad module to support static text ads.
7 * 7 *
24 * @return 24 * @return
25 * A string containing the ad markup. 25 * A string containing the ad markup.
26 */ 26 */
27 function theme_ad_text_ad($ad) { 27 function theme_ad_text_ad($ad) {
28 if (isset($ad->aid)) { 28 if (isset($ad->aid)) {
29 if (!isset($ad->adheader)) {
30 $ad = node_load($ad->aid);
31 }
29 $output = '<div class="text-advertisement" id="ad-'. $ad->aid .'">'; 32 $output = '<div class="text-advertisement" id="ad-'. $ad->aid .'">';
30 if (isset($ad->url) && !empty($ad->url)) { 33 if (isset($ad->url) && !empty($ad->url)) {
31 $output .= theme('ad_text_text', ad_text_display_prepare($ad->adheader, $ad->format), ad_text_display_prepare($ad->adbody, $ad->format), $ad->redirect .'/@HOSTID___'); 34 $output .= theme('ad_text_text', ad_text_display_prepare($ad->adheader, $ad->format), ad_text_display_prepare($ad->adbody, $ad->format), $ad->redirect .'/@HOSTID___');
32 } 35 }
33 else { 36 else {
197 case 'insert': 200 case 'insert':
198 db_query("INSERT INTO {ad_text} (aid, url, adheader, adbody) VALUES(%d, '%s', '%s', '%s')", $node->nid, $node->url, $node->adheader, $node->adbody); 201 db_query("INSERT INTO {ad_text} (aid, url, adheader, adbody) VALUES(%d, '%s', '%s', '%s')", $node->nid, $node->url, $node->adheader, $node->adbody);
199 break; 202 break;
200 203
201 case 'update': 204 case 'update':
202 if (ad_adaccess($node, 'manage ad text')) { 205 if (ad_permission($node->nid, 'manage ad text')) {
203 db_query("UPDATE {ad_text} SET url = '%s', adheader = '%s', adbody = '%s' WHERE aid = %d", $node->url, $node->adheader, $node->adbody, $node->nid); 206 db_query("UPDATE {ad_text} SET url = '%s', adheader = '%s', adbody = '%s' WHERE aid = %d", $node->url, $node->adheader, $node->adbody, $node->nid);
204 } 207 }
205 break; 208 break;
206 209
207 case 'delete': 210 case 'delete':
231 ), 234 ),
232 ); 235 );
233 236
234 case 'permissions': 237 case 'permissions':
235 if (!isset($node->adtype) || $node->adtype == 'text') { 238 if (!isset($node->adtype) || $node->adtype == 'text') {
236 return array('manage ad text'); 239 return array('manage ad text' => TRUE);
237 } 240 }
238 } 241 }
239 } 242 }
240 243
241 /** 244 /**
248 '#type' => 'fieldset', 251 '#type' => 'fieldset',
249 '#title' => t('Text'), 252 '#title' => t('Text'),
250 '#collapsible' => TRUE, 253 '#collapsible' => TRUE,
251 ); 254 );
252 255
253 if (ad_adaccess($node, 'manage ad text') || arg(1) == 'add' && user_access('create advertisements')) { 256 if (arg(1) == 'add' && user_access('create advertisements') || ad_permission($node->nid, 'manage ad text')) {
254 $access = TRUE; 257 $access = TRUE;
255 } 258 }
256 else { 259 else {
257 $access = FALSE; 260 $access = FALSE;
258 $form['ad_text']['notice'] = array( 261 $form['ad_text']['notice'] = array(