Mercurial > defr > drupal > ad
diff ad.module @ 3:416ea999ed76 ad
maj ad version rc1
author | sly |
---|---|
date | Mon, 20 Apr 2009 09:49:37 +0000 |
parents | e5584a19768b |
children | 6aeff3329e01 |
line wrap: on
line diff
--- a/ad.module Wed Apr 15 07:58:32 2009 +0000 +++ b/ad.module Mon Apr 20 09:49:37 2009 +0000 @@ -1,5 +1,5 @@ <?php -// $Id: ad.module,v 1.2.2.29.2.83.2.16.2.16 2009/04/14 14:02:11 jeremy Exp $ +// $Id: ad.module,v 1.2.2.29.2.83.2.16.2.21 2009/04/16 14:24:53 jeremy Exp $ /** * @file @@ -842,6 +842,24 @@ unset($form['synonyms']); } } + else if ($form_id == 'search_form' && variable_get('ad_no_search', 1) && !user_access('administer advertisements') && !user_access('administer any advertisement')) { + $vid = _ad_get_vid(); + $vocabulary = db_result(db_query('SELECT name FROM {vocabulary} WHERE vid = %d', $vid)); + unset($form['advanced']['category']['#options'][$vocabulary]); + if (empty($form['advanced']['category']['#options'])) { + unset($form['advanced']['category']); + } + unset($form['advanced']['type']['#options']['ad']); + } +} + +/** + * Implementation of hook_db_rewrite_sql(). + */ +function ad_db_rewrite_sql($query, $primary_table, $primary_field, $args) { + 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)) { + return array('where' => " n.type != 'ad'"); + } } /** @@ -936,6 +954,9 @@ case 'view': if (isset($node->adtype)) { + if (variable_get('ad_meta_noindex', 1)) { + ad_noindex_meta(); + } $node = node_prepare($node, $teaser); $node->content['body'] = array( '#value' => $teaser ? $node->teaser : theme('node_ad', $node, $page), @@ -975,6 +996,17 @@ } } +/** + * Add the noindex meta tag. + */ +function ad_noindex_meta() { + static $added = FALSE; + if (!$added) { + drupal_set_html_head('<meta name="robots" content="noindex" />'); + $added = TRUE; + } +} + function ad_adapi($op, $node = NULL) { switch ($op) { case 'permissions': @@ -1206,6 +1238,9 @@ if (is_object($aid) && isset($aid->aid)) { $aid = $aid->aid; } + else if (is_object($aid) && isset($aid->nid)) { + $aid = $aid->nid; + } else if (is_object($aid)) { watchdog('ad', 'Invalid aid object passed into ad_permission, no aid->aid set.'); $aid = 0;