Mercurial > defr > drupal > ad
comparison ad.module @ 3:416ea999ed76 ad
maj ad version rc1
author | sly |
---|---|
date | Mon, 20 Apr 2009 09:49:37 +0000 |
parents | e5584a19768b |
children | 6aeff3329e01 |
comparison
equal
deleted
inserted
replaced
2:e5584a19768b | 3:416ea999ed76 |
---|---|
1 <?php | 1 <?php |
2 // $Id: ad.module,v 1.2.2.29.2.83.2.16.2.16 2009/04/14 14:02:11 jeremy Exp $ | 2 // $Id: ad.module,v 1.2.2.29.2.83.2.16.2.21 2009/04/16 14:24:53 jeremy Exp $ |
3 | 3 |
4 /** | 4 /** |
5 * @file | 5 * @file |
6 * An advertising system for Drupal powered websites. | 6 * An advertising system for Drupal powered websites. |
7 * | 7 * |
840 $form['description']['#required'] = TRUE; | 840 $form['description']['#required'] = TRUE; |
841 $form['weight']['#description'] = t('In listings, the heavier ad groups will sink and the lighter ad groups will be positioned nearer the top.'); | 841 $form['weight']['#description'] = t('In listings, the heavier ad groups will sink and the lighter ad groups will be positioned nearer the top.'); |
842 unset($form['synonyms']); | 842 unset($form['synonyms']); |
843 } | 843 } |
844 } | 844 } |
845 else if ($form_id == 'search_form' && variable_get('ad_no_search', 1) && !user_access('administer advertisements') && !user_access('administer any advertisement')) { | |
846 $vid = _ad_get_vid(); | |
847 $vocabulary = db_result(db_query('SELECT name FROM {vocabulary} WHERE vid = %d', $vid)); | |
848 unset($form['advanced']['category']['#options'][$vocabulary]); | |
849 if (empty($form['advanced']['category']['#options'])) { | |
850 unset($form['advanced']['category']); | |
851 } | |
852 unset($form['advanced']['type']['#options']['ad']); | |
853 } | |
854 } | |
855 | |
856 /** | |
857 * Implementation of hook_db_rewrite_sql(). | |
858 */ | |
859 function ad_db_rewrite_sql($query, $primary_table, $primary_field, $args) { | |
860 if (variable_get('ad_no_search', 1) && !user_access('administer advertisements') && !user_access('edit any advertisement') && $query == '' && $primary_table == 'n' && $primary_field = 'nid' && empty($args)) { | |
861 return array('where' => " n.type != 'ad'"); | |
862 } | |
845 } | 863 } |
846 | 864 |
847 /** | 865 /** |
848 * Implementation of hook_nodeapi(). | 866 * Implementation of hook_nodeapi(). |
849 */ | 867 */ |
934 ad_statistics_increment($node->nid, 'delete'); | 952 ad_statistics_increment($node->nid, 'delete'); |
935 break; | 953 break; |
936 | 954 |
937 case 'view': | 955 case 'view': |
938 if (isset($node->adtype)) { | 956 if (isset($node->adtype)) { |
957 if (variable_get('ad_meta_noindex', 1)) { | |
958 ad_noindex_meta(); | |
959 } | |
939 $node = node_prepare($node, $teaser); | 960 $node = node_prepare($node, $teaser); |
940 $node->content['body'] = array( | 961 $node->content['body'] = array( |
941 '#value' => $teaser ? $node->teaser : theme('node_ad', $node, $page), | 962 '#value' => $teaser ? $node->teaser : theme('node_ad', $node, $page), |
942 '#weight' => 1, | 963 '#weight' => 1, |
943 ); | 964 ); |
970 case 'delete': | 991 case 'delete': |
971 if (variable_get('ad_cache_file_rebuild_realtime', 0) && | 992 if (variable_get('ad_cache_file_rebuild_realtime', 0) && |
972 isset($node->adtype)) { | 993 isset($node->adtype)) { |
973 ad_rebuild_cache(); | 994 ad_rebuild_cache(); |
974 } | 995 } |
996 } | |
997 } | |
998 | |
999 /** | |
1000 * Add the noindex meta tag. | |
1001 */ | |
1002 function ad_noindex_meta() { | |
1003 static $added = FALSE; | |
1004 if (!$added) { | |
1005 drupal_set_html_head('<meta name="robots" content="noindex" />'); | |
1006 $added = TRUE; | |
975 } | 1007 } |
976 } | 1008 } |
977 | 1009 |
978 function ad_adapi($op, $node = NULL) { | 1010 function ad_adapi($op, $node = NULL) { |
979 switch ($op) { | 1011 switch ($op) { |
1203 } | 1235 } |
1204 | 1236 |
1205 // when used in the Drupal menu, $aid may be the full ad object. | 1237 // when used in the Drupal menu, $aid may be the full ad object. |
1206 if (is_object($aid) && isset($aid->aid)) { | 1238 if (is_object($aid) && isset($aid->aid)) { |
1207 $aid = $aid->aid; | 1239 $aid = $aid->aid; |
1240 } | |
1241 else if (is_object($aid) && isset($aid->nid)) { | |
1242 $aid = $aid->nid; | |
1208 } | 1243 } |
1209 else if (is_object($aid)) { | 1244 else if (is_object($aid)) { |
1210 watchdog('ad', 'Invalid aid object passed into ad_permission, no aid->aid set.'); | 1245 watchdog('ad', 'Invalid aid object passed into ad_permission, no aid->aid set.'); |
1211 $aid = 0; | 1246 $aid = 0; |
1212 } | 1247 } |