Index: adsense.info =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/adsense/adsense.info,v retrieving revision 1.4 diff -u -p -r1.4 adsense.info --- adsense.info 10 Feb 2008 01:24:19 -0000 1.4 +++ adsense.info 25 Mar 2008 20:55:56 -0000 @@ -1,6 +1,8 @@ ; $Id: adsense.info,v 1.4 2008/02/10 01:24:19 kbahey Exp $ ; Copyright 2005-2008 Khalid Baheyeldin http://2bits.com -name = AdSense core and API +name = "AdSense core and API" description = Displays Google AdSense ads on your site to earn revenue. Provides an API for revenue sharing on web sites. package = Adsense +version = "6.x-dev" +core = 6.x Index: adsense.install =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/adsense/adsense.install,v retrieving revision 1.8 diff -u -p -r1.8 adsense.install --- adsense.install 10 Feb 2008 01:24:19 -0000 1.8 +++ adsense.install 25 Mar 2008 20:55:56 -0000 @@ -4,43 +4,50 @@ // Copyright 2005-2008 Khalid Baheyeldin http://2bits.com function adsense_install() { - switch ($GLOBALS['db_type']) { - case 'mysql': - case 'mysqli': - $success = db_query("CREATE TABLE IF NOT EXISTS {adsense_clicks} ( - aid INT(10) NOT NULL AUTO_INCREMENT, - ip VARCHAR(15) DEFAULT '0', - timestamp INT(11) unsigned NOT NULL DEFAULT '0', - path VARCHAR(255) NOT NULL DEFAULT '', - PRIMARY KEY (aid), - KEY (timestamp) - ) /*!40100 DEFAULT CHARACTER SET utf8 */;"); - break; - case 'pgsql': - $success = db_query("CREATE TABLE {adsense_clicks} ( - aid SERIAL, - ip VARCHAR(15) DEFAULT '0', - timestamp INTEGER NOT NULL DEFAULT '0', - path VARCHAR(255) DEFAULT '', - PRIMARY KEY (aid));"); - $success = db_query("CREATE INDEX {timestamp} ON {adsense_clicks} (timestamp);"); - break; - } + $schema['adsense_clicks'] = array( + 'description' => t('Store Adsense click record.'), + 'fields' => array( + 'aid' => array( + 'description' => t('The primary key.'), + 'type' => 'serial', + 'unsigned' => TRUE, + 'not null' => TRUE), + 'ip' => array( + 'description' => t('Client IP.'), + 'type' => 'varchar', + 'length' => 15, + 'default' => '0'), + 'timestamp' => array( + 'description' => t('Click time.'), + 'type' => 'int', + 'length' => 11, + 'unsigned' => TRUE, + 'not null' => TRUE, + 'default' => 0), + 'path' => array( + 'description' => t('Where they click.'), + 'type' => 'varchar', + 'length' => 255, + 'not null' => TRUE, + 'default' => ''), + ), + 'indexes' => array( + 'adsense_clicks_timestamp' => array('timestamp'), + ), + 'primary key' => array('aid'), + ); - if ($success) { - drupal_set_message(t('Adsense module table creation successful.')); - } - else { - drupal_set_message(t('Adsense module table creation was unsuccessful.'), 'error'); - } + return $schema; } /** * Implementation of hook_uninstall(). */ function adsense_uninstall() { - db_query('DROP TABLE {adsense_clicks}'); + $ret = array(); + db_drop_table($ret, 'adsense_clicks'); db_query("DELETE FROM {variable} WHERE name LIKE 'adsense_%'"); + return $ret; } function adsense_update_1() { @@ -48,11 +55,8 @@ function adsense_update_1() { } function adsense_update_2() { - switch ($GLOBALS['db_type']) { - case 'mysql': - case 'mysqli': - db_query("ALTER TABLE {adsense_clicks} ADD `path` varchar(255) default ''"); - break; - } + $ret = array(); + db_add_field($ret, 'adsense_clicks', 'path', array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => '')); + return $ret; } Index: adsense.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/adsense/adsense.module,v retrieving revision 1.66.2.3 diff -u -p -r1.66.2.3 adsense.module --- adsense.module 22 Mar 2008 18:51:58 -0000 1.66.2.3 +++ adsense.module 25 Mar 2008 20:56:00 -0000 @@ -1,5 +1,5 @@ @revision @date

', array('@revision' => trim('$Revision: 1.66.2.3 $', ' $'), '@date' => trim('$Date: 2008/03/22 18:51:58 $', ' $'))); } @@ -130,75 +130,63 @@ function adsense_help($section) { /** * Implementation of hook_menu(). */ -function adsense_menu($may_cache) { +function adsense_menu() { $items = array(); - $access = user_access('administer site configuration'); - if ($may_cache) { - $items[] = array( - 'path' => 'admin/settings/adsense', - 'title' => t('AdSense'), - 'description' => t('Configure Google AdSense Ads. Choose colors, channels, revenue sharing modules and many other options.'), - 'callback' => 'drupal_get_form', - 'callback arguments' => 'adsense_admin_settings', - 'type' => MENU_NORMAL_ITEM, - 'access' => $access, - ); - - $module_list = module_implements('adsense'); - foreach ($module_list as $key => $module) { - $items[] = array( - 'path' => 'admin/settings/adsense/'. $module, - 'title' => $module, - 'callback' => 'drupal_get_form', - 'callback arguments' => array('adsense_admin_module_settings', $module), - 'type' => MENU_NORMAL_ITEM, - 'access' => $access, - ); - } - - if (variable_get(ADSENSE_CLICK_TRACKING, 0)) { - $access = user_access('view clicks'); - $items[] = array( - 'path' => 'admin/logs/adsense', - 'title' => t('AdSense clicks'), - 'description' => t('Track AdSense clicks.'), - 'callback' => 'adsense_click_log', - 'type' => MENU_NORMAL_ITEM, - 'access' => $access, - ); - - $items[] = array( - 'path' => 'admin/logs/adsense/top_pages', - 'title' => t('Top pages'), - 'callback' => 'adsense_click_top_pages', - 'type' => MENU_NORMAL_ITEM, - 'access' => $access, - ); - - $items[] = array( - 'path' => 'admin/logs/adsense/by_day', - 'title' => t('By day'), - 'callback' => 'adsense_click_by_day', - 'type' => MENU_NORMAL_ITEM, - 'access' => $access, - ); - } + $items['admin/settings/adsense'] = array( + 'title' => 'AdSense', + 'description' => 'Configure Google AdSense Ads. Choose colors, channels, revenue sharing modules and many other options.', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('adsense_admin_settings'), + 'type' => MENU_NORMAL_ITEM, + 'access callback' => array('administer site configuration'), + ); + + $module_list = module_implements('adsense'); + foreach ($module_list as $key => $module) { + $items['admin/settings/adsense/'. $module] = array( + 'title' => $module, + 'page callback' => 'drupal_get_form', + 'page arguments' => array('adsense_admin_module_settings', $module), + 'type' => MENU_NORMAL_ITEM, + 'access callback' => array('administer site configuration'), + ); } - else { - $items[] = array( - 'path' => 'adsense/counter', - 'callback' => 'adsense_counter', - 'access' => TRUE, - 'type' => MENU_CALLBACK, + + if (variable_get(ADSENSE_CLICK_TRACKING, 0)) { + $items['admin/reports/adsense'] = array( + 'title' => 'AdSense clicks', + 'description' => 'Track AdSense clicks.', + 'page callback' => 'adsense_click_log', + 'type' => MENU_NORMAL_ITEM, + 'access callback' => array('view clicks'), + ); + + $items['admin/reports/adsense/top_pages'] = array( + 'title' => 'Top pages', + 'page callback' => 'adsense_click_top_pages', + 'type' => MENU_NORMAL_ITEM, + 'access callback' => array('view clicks'), + ); + + $items['admin/reports/adsense/by_day'] = array( + 'title' => 'By day', + 'page callback' => 'adsense_click_by_day', + 'type' => MENU_NORMAL_ITEM, + 'access callback' => array('view clicks'), ); } - $items[] = array( - 'path' => ADSENSE_SEARCH_PATH, - 'callback' => 'adsense_search', - 'access' => user_access('access adsense search result page'), - 'type' => MENU_CALLBACK, + + $items['adsense/counter'] = array( + 'page callback' => 'adsense_counter', + 'type' => MENU_CALLBACK, + ); + $items[ADSENSE_SEARCH_PATH] = array( + 'page callback' => 'adsense_search', + 'access callback' => array('access adsense search result page'), + 'type' => MENU_CALLBACK, ); + return $items; } @@ -210,7 +198,7 @@ function adsense_perm() { } function adsense_admin_module_settings($module) { - $function = $module . '_adsense'; + $function = $module .'_adsense'; $form = $function('settings'); return system_settings_form($form); @@ -219,7 +207,7 @@ function adsense_admin_module_settings($ function adsense_admin_settings() { // force a display of errors, if any $module = variable_get(ADSENSE_ID_MODULE, 'adsense_basic'); - $function = $module . '_adsense'; + $function = $module .'_adsense'; if (function_exists($function)) { $error = $function('status'); } @@ -466,7 +454,7 @@ function adsense_admin_settings() { '#title' => t('Enable AdSense click tracking?'), '#return_value' => 1, '#default_value' => variable_get(ADSENSE_CLICK_TRACKING, 0), - '#description' => t('Logs IP and time of AdSense clicks. This can be very useful in tracking which of your pages generate the most clicks, as well as help if click fraud is suspected.', array('!url' => url('admin/logs/adsense'))), + '#description' => t('Logs IP and time of AdSense clicks. This can be very useful in tracking which of your pages generate the most clicks, as well as help if click fraud is suspected.', array('!url' => url('admin/reports/adsense'))), ); $form['click_tracking'][ADSENSE_CLICK_TRACKING_NAME_RESOLVE] = array( @@ -1017,7 +1005,7 @@ function _adsense_get_ad($format, $group $ad = _adsense_format($format, $group, $channel, $slot, $referral, $cpa); // Add it to cache - cache_set($cache_key, 'cache', $ad, CACHE_PERMANENT); + cache_set($cache_key, $ad); } return $ad; @@ -1497,7 +1485,7 @@ function adsense_get_client_id() { $module = variable_get(ADSENSE_ID_MODULE, 'adsense_basic'); // Compose the function to be called - $function = $module . '_adsense'; + $function = $module .'_adsense'; // Call the function if (!function_exists($function)) { adsense_error(ADSENSE_ERROR_NO_MODULE); @@ -1511,7 +1499,7 @@ function adsense_get_client_id() { } function adsense_error($error_code) { - switch($error_code) { + switch ($error_code) { case ADSENSE_ERROR_NO_MODULE: $text = t('No Google Adsense client ID choosing module is enabled. Please check your settings.'); break; @@ -1546,7 +1534,7 @@ function adsense_counter() { if (variable_get(ADSENSE_CLICK_TRACKING, 0)) { $path = $_GET['u']; db_query("INSERT INTO {adsense_clicks} (ip, timestamp, path) values('%s', %d, '%s')", - $_SERVER['REMOTE_ADDR'], time(), $path); + ip_address(), time(), $path); } } @@ -1791,7 +1779,7 @@ function adsense_search($op = 'search', case 'search': // Log the search keys: - watchdog('AdSense', t('Keyword') .': '. urldecode($_GET['as_q']) .'', WATCHDOG_NOTICE, 'AdSense for Search'); + watchdog('AdSense', 'Keyword: '. urldecode($_GET['as_q']) .'', WATCHDOG_NOTICE, 'AdSense for Search'); // Output search results $width = variable_get(ADSENSE_SEARCH_FRAME_WIDTH, '500'); Index: adsense_basic.info =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/adsense/adsense_basic.info,v retrieving revision 1.1 diff -u -p -r1.1 adsense_basic.info --- adsense_basic.info 10 Feb 2008 01:24:19 -0000 1.1 +++ adsense_basic.info 25 Mar 2008 20:56:00 -0000 @@ -1,7 +1,9 @@ ; $Id: adsense_basic.info,v 1.1 2008/02/10 01:24:19 kbahey Exp $ ; Copyright 2005-2008 Khalid Baheyeldin http://2bits.com -name = Adsense basic +name = "Adsense basic" description = Configuration for Adsense for a basic single owner site, with no revenue sharing. -dependencies = adsense +dependencies[] = adsense package = Adsense +version = "6.x-dev" +core = 6.x Index: adsense_basic.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/adsense/adsense_basic.module,v retrieving revision 1.1.2.1 diff -u -p -r1.1.2.1 adsense_basic.module --- adsense_basic.module 13 Feb 2008 02:10:59 -0000 1.1.2.1 +++ adsense_basic.module 25 Mar 2008 20:56:00 -0000 @@ -30,7 +30,7 @@ function adsense_basic_settings() { $module = 'adsense_basic'; include_once(drupal_get_path('module', $module) .'/'. $module .'_help.inc'); - $function = $module . '_adsense'; + $function = $module .'_adsense'; $error_flag = $function('status'); $form['help'] = array( Index: revenue_sharing_basic.info =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/adsense/revenue_sharing_basic.info,v retrieving revision 1.1 diff -u -p -r1.1 revenue_sharing_basic.info --- revenue_sharing_basic.info 10 Feb 2008 01:24:19 -0000 1.1 +++ revenue_sharing_basic.info 25 Mar 2008 20:56:00 -0000 @@ -1,7 +1,10 @@ ; $Id: revenue_sharing_basic.info,v 1.1 2008/02/10 01:24:19 kbahey Exp $ ; Copyright 2005-2008 Khalid Baheyeldin http://2bits.com -name = Adsense revenue sharing basic +name = "Adsense revenue sharing basic" description = Basic revenue sharing for the Google Adsense module -dependencies = adsense profile +dependencies[] = adsense +dependencies[] = profile package = Adsense +version = "6.x-dev" +core = 6.x Index: revenue_sharing_basic.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/adsense/revenue_sharing_basic.module,v retrieving revision 1.1.2.3 diff -u -p -r1.1.2.3 revenue_sharing_basic.module --- revenue_sharing_basic.module 20 Feb 2008 22:53:48 -0000 1.1.2.3 +++ revenue_sharing_basic.module 25 Mar 2008 20:56:01 -0000 @@ -1,5 +1,5 @@ type; @@ -286,7 +286,7 @@ function revenue_sharing_basic_get_node_ } function revenue_sharing_basic_error($error_code) { - switch($error_code) { + switch ($error_code) { case REVENUE_SHARING_BASIC_ERROR_CACHING_ENABLED: $text = t('Drupal page cache is enabled. This causes conflicts with revenue sharing, since the pages are stored in the cache and are not dynamically generated. If you experience issues with revenue sharing, then disable the page cache.'); break;