Index: ad.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/ad/ad.module,v
retrieving revision 1.2.2.29.2.83.2.3
diff -u -r1.2.2.29.2.83.2.3 ad.module
--- ad.module 19 Nov 2008 17:15:10 -0000 1.2.2.29.2.83.2.3
+++ ad.module 25 Nov 2008 23:35:44 -0000
@@ -97,11 +97,11 @@
_ad_check_install();
$adserve = variable_get('adserve', '');
$adserveinc = variable_get('adserveinc', '');
- }
+ }
if (!file_exists($adserve) || !file_exists($adserveinc)) {
drupal_set_message(t('Ads cannot be displayed. The ad module is misconfigured, failed to locate the required serve.php ond/or adserve.inc file.', array('@misconfigured' => url('admin/content/ad/configure'))), 'error');
_ad_check_install();
- return(t('The ad module is misconfigured.', array('@misconfigured' => url('admin/content/ad/configure'))));
+ return (t('The ad module is misconfigured.', array('@misconfigured' => url('admin/content/ad/configure'))));
}
// Be sure a display method has been chosen.
@@ -109,7 +109,7 @@
$options['ad_display'] = variable_get('ad_display', 'javascript');
}
$options['quantity'] = isset($quantity) ? $quantity : 1;
- if (!isset($options['tids'])) {
+ if (!isset($options['tids'])) {
$options['tids'] = $group;
}
$options['cache'] = variable_get('ad_cache', 'none');
@@ -197,7 +197,7 @@
}
/**
- * Function to display the actual advertisement to the screen. Wrap it in a
+ * Function to display the actual advertisement to the screen. Wrap it in a
* theme function to make it possible to customize in your own theme.
*/
function theme_ad_display($group, $display, $method = 'javascript') {
@@ -294,7 +294,7 @@
if (variable_get('ad_link_nofollow', 0)) {
return ' rel="nofollow"';
}
- return;
+ return;
}
/**
@@ -321,18 +321,18 @@
if ($admin) {
// status options for administrators
return array(
- 'pending' => t('This advertisement is currently waiting for administrative approval.'),
- 'approved' => t('This advertisement has been approved and is currently waiting to be administratively activated.'),
- 'active' => t('This advertisement is actively being displayed.'),
- 'offline' => t('This advertisement has been temporarily disabled by its owner and is not currently being displayed.'),
- 'unpublished' => t('This advertisement has been unpublished and is not currently being displayed.'),
- 'expired' => t('This advertisement has expired.'),
+ 'pending' => t('This advertisement is currently waiting for administrative approval.'),
+ 'approved' => t('This advertisement has been approved and is currently waiting to be administratively activated.'),
+ 'active' => t('This advertisement is actively being displayed.'),
+ 'offline' => t('This advertisement has been temporarily disabled by its owner and is not currently being displayed.'),
+ 'unpublished' => t('This advertisement has been unpublished and is not currently being displayed.'),
+ 'expired' => t('This advertisement has expired.'),
'denied' => t('This advertisement was refused by the site administrator, it will not be displayed.'));
}
else {
// status options for advertisement owners
return array(
- 'active' => t('This advertisement is actively being displayed.'),
+ 'active' => t('This advertisement is actively being displayed.'),
'offline' => t('This advertisement has been temporarily disabled and is not currently being displayed.'));
}
}
@@ -371,7 +371,7 @@
$last_month = date('Y') - 1 .'120000';
}
else {
- $last_month = date('Y'). ($last_month < 10 ? '0' : '') . $last_month .'0000';
+ $last_month = date('Y') . ($last_month < 10 ? '0' : '') . $last_month .'0000';
}
$statistics['last_month']['views'] = (int)db_result(db_query("SELECT SUM(count) FROM {ad_statistics} WHERE aid = %d AND action = 'view' AND date >= %d AND date <= %d", $aid, $last_month, $this_month));
$statistics['last_month']['clicks'] = (int)db_result(db_query("SELECT SUM(count) FROM {ad_statistics} WHERE aid = %d AND action = 'click' AND date >= %d AND date <= %d", $aid, $last_month, $this_month));
@@ -500,7 +500,7 @@
function ad_cron() {
if (time() - variable_get('ad_cron_timestamp', 0) >= 60) {
// Locate ads that need to be activated or expired.
- $result = db_query('SELECT aid, adstatus, adtype, autoactivate, autoactivated, autoexpire, autoexpired FROM {ads} WHERE autoactivate != 0 OR autoexpire != 0');
+ $result = db_query('SELECT aid, adstatus, adtype, autoactivate, autoactivated, autoexpire, autoexpired FROM {ads} WHERE autoactivate <> 0 OR autoexpire <> 0');
while ($ad = db_fetch_object($result)) {
switch ($ad->adstatus) {
case 'approved': {
@@ -566,12 +566,12 @@
* @return An array of permissions used by this module.
*/
function ad_perm() {
- return (
+ return (
array('administer advertisements',
'create advertisements',
'edit own advertisements',
'show advertisements')
- );
+ );
}
/**
@@ -595,7 +595,7 @@
}
if ($op == 'update' || $op == 'delete') {
- return (user_access('administer advertisements', $account) ||
+ return (user_access('administer advertisements', $account) ||
(ad_is_owner($node->nid) && user_access('edit own advertisements', $account)));
}
}
@@ -609,6 +609,7 @@
$type = arg(3);
if (function_exists("ad_$type". '_type')) {
+ //if (function_exists("ad_$type". '_adapi')) {
$adtype = $type;
}
else {
@@ -622,14 +623,14 @@
$form['title'] = array(
'#type' => 'textfield',
- '#title' => t('Title'),
- '#required' => TRUE,
+ '#title' => t('Title'),
+ '#required' => TRUE,
'#default_value' => $node->title,
);
$form['body_filter']['body'] = array(
- '#type' => 'textarea',
- '#title' => t('Description'),
- '#default_value' => $node->body,
+ '#type' => 'textarea',
+ '#title' => t('Description'),
+ '#default_value' => $node->body,
'#rows' => 3
);
$form['body_filter']['format'] = filter_form($node->format);
@@ -648,11 +649,11 @@
if (arg(0) == 'node' && arg(1) == 'add' && arg(2) == 'ad') {
$adtype = arg(3) ? arg(3) : $edit['adtype'];
$form['adtype'] = array(
- '#type' => 'radios',
- '#title' => t('Style of ad'),
- '#options' => drupal_map_assoc($adtypes),
- '#default_value' => $adtype ? $adtype : $adtypes[0],
- '#required' => TRUE,
+ '#type' => 'radios',
+ '#title' => t('Style of ad'),
+ '#options' => drupal_map_assoc($adtypes),
+ '#default_value' => $adtype ? $adtype : $adtypes[0],
+ '#required' => TRUE,
'#description' => t('Select the type of ad that you wish to create from the above options.')
);
}
@@ -667,7 +668,7 @@
$form["$element"] = $values;
}
$form['adtype'] = array(
- '#type' => 'hidden',
+ '#type' => 'hidden',
'#value' => $adtype,
);
}
@@ -675,17 +676,17 @@
if (user_access('administer advertisements')) {
// admins can set any status on advertisements
$form['adstatus'] = array(
- '#type' => 'fieldset',
- '#title' => t('Status'),
+ '#type' => 'fieldset',
+ '#title' => t('Status'),
'#collapsible' => TRUE
);
foreach (ad_status_array() as $status => $description) {
$form['adstatus']["ad$status"] = array(
- '#type' => 'radio',
- '#title' => t("$status"),
- '#return_value' => $status,
+ '#type' => 'radio',
+ '#title' => t("$status"),
+ '#return_value' => $status,
'#default_value' => $node->adstatus ? $node->adstatus : 'pending',
- '#description' => "$description",
+ '#description' => "$description",
'#parents' => array("adstatus")
);
}
@@ -695,16 +696,16 @@
$adstatus = ad_status_array();
$node->adstatus = 'pending';
$form['adstatus'] = array(
- '#type' => 'fieldset',
- '#title' => t('Status'),
+ '#type' => 'fieldset',
+ '#title' => t('Status'),
'#collapsible' => TRUE
);
$form['adstatus']['display'] = array(
- '#type' => 'markup',
+ '#type' => 'markup',
'#value' => '
'. t('Status') .': '. t($node->adstatus) .'
'. t($adstatus["$node->adstatus"]),
);
$form['adstatus']['adpending'] = array(
- '#type' => 'value',
+ '#type' => 'value',
'#value' => $node->adstatus
);
}
@@ -712,17 +713,17 @@
$adstatus = ad_status_array(FALSE);
// display status options
$form['adstatus'] = array(
- '#type' => 'fieldset',
- '#title' => t('Status'),
+ '#type' => 'fieldset',
+ '#title' => t('Status'),
'#collapsible' => TRUE
);
foreach ($adstatus as $status => $description) {
$form['adstatus']["ad$status"] = array(
- '#type' => 'radio',
- '#title' => t("$status"),
- '#return_value' => $status,
- '#default_value' => $node->adstatus ? $node->adstatus : 'pending',
- '#description' => "$description",
+ '#type' => 'radio',
+ '#title' => t("$status"),
+ '#return_value' => $status,
+ '#default_value' => $node->adstatus ? $node->adstatus : 'pending',
+ '#description' => "$description",
'#parents' => array("adstatus")
);
}
@@ -734,16 +735,16 @@
$node->adstatus = 'pending';
}
$form['ad_adstatus'] = array(
- '#type' => 'fieldset',
- '#title' => t('Status'),
+ '#type' => 'fieldset',
+ '#title' => t('Status'),
'#collapsible' => TRUE
);
$form['ad_adstatus']['adstatus_display'] = array(
- '#type' => 'markup',
+ '#type' => 'markup',
'#value' => '
'. t('Status') .': '. t($node->adstatus) .'
'. t($adstatus["$node->adstatus"]),
);
$form['adstatus'] = array(
- '#type' => 'value',
+ '#type' => 'value',
'#value' => $node->adstatus
);
}
@@ -751,11 +752,11 @@
if (ad_adaccess($node->nid, 'access statistics')) {
// display statistics
$form['statistics'] = array(
- '#type' => 'fieldset',
- '#title' => t('Statistics'),
+ '#type' => 'fieldset',
+ '#title' => t('Statistics'),
'#collapsible' => TRUE,
);
-
+
$form['statistics']['data'] = array(
'#type' => 'markup',
'#prefix' => '
',
@@ -763,32 +764,32 @@
'#value' => theme('ad_statistics_display', ad_statistics($node->nid)),
);
}
-
+
// display scheduling options
$form['schedule'] = array(
- '#type' => 'fieldset',
- '#title' => t('Scheduling'),
+ '#type' => 'fieldset',
+ '#title' => t('Scheduling'),
'#collapsible' => TRUE,
// Collapse if there isn't any scheduling data set.
'#collapsed' => ($node->autoactivate || $edit['autoactivate'] ||
$node->autoexpire || $edit['autoexpire'] ||
$node->maxviews || $edit['maxviews'] ||
- $node->maxclicks || $edit['maxclicks'])
+ $node->maxclicks || $edit['maxclicks'])
? FALSE : TRUE,
);
if (ad_adaccess($node->nid, 'manage status')) {
- $form['schedule']['current'] = array(
- '#type' => 'markup',
+ $form['schedule']['current'] = array(
+ '#type' => 'markup',
'#prefix' => '
',
'#suffix' => '
',
'#value' => t('The current date and time is "%date".', array('%date' => format_date(time(), 'custom', 'F j, Y H:i')))
);
- $form['schedule']['autoactivate'] = array(
- '#type' => 'textfield',
- '#title' => t('Automatically activate ad'),
- '#required' => FALSE,
- '#default_value' => $node->autoactivate ? format_date((int)$node->autoactivate, 'custom', 'F j, Y H:i') : '',
+ $form['schedule']['autoactivate'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Automatically activate ad'),
+ '#required' => FALSE,
+ '#default_value' => $node->autoactivate ? format_date((int)$node->autoactivate, 'custom', 'F j, Y H:i') : '',
'#description' => t('You can specify a date and time for this advertisement to be automatically activated. The advertisement needs to be in an
approved state before it can be automatically activated. If you prefer to activate the advertisement immediately, leave this field empty.')
);
}
@@ -796,25 +797,25 @@
if (user_access('administer advertisements')) {
// admins can expire advertisements
$form['schedule']['autoexpire'] = array(
- '#type' => 'textfield',
- '#title' => t('Automatically expire ad'),
- '#required' => FALSE,
- '#default_value' => $node->autoexpire ? format_date((int)$node->autoexpire, 'custom', 'F j, Y H:i') : '',
+ '#type' => 'textfield',
+ '#title' => t('Automatically expire ad'),
+ '#required' => FALSE,
+ '#default_value' => $node->autoexpire ? format_date((int)$node->autoexpire, 'custom', 'F j, Y H:i') : '',
'#description' => t('You can specify a date and time for this advertisement to be automatically expired. If you don\'t want the advertisement to expire, leave this field empty.')
);
$form['schedule']['maxviews'] = array(
- '#type' => 'textfield',
- '#title' => t('Maximum views'),
- '#required' => FALSE,
+ '#type' => 'textfield',
+ '#title' => t('Maximum views'),
+ '#required' => FALSE,
'#size' => 10,
'#maxlength' => 11,
'#default_value' => $node->maxviews,
'#description' => t('You can specify the maximum number of times this advertisement should be displayed, after which it will be automatically expired. If you don\'t want this advertisement to expire after a certain number of views, leave this field set to %zero.', array('%zero' => '0')),
);
$form['schedule']['maxclicks'] = array(
- '#type' => 'textfield',
- '#title' => t('Maximum clicks'),
- '#required' => FALSE,
+ '#type' => 'textfield',
+ '#title' => t('Maximum clicks'),
+ '#required' => FALSE,
'#size' => 10,
'#maxlength' => 11,
'#default_value' => $node->maxclicks,
@@ -824,13 +825,13 @@
else {
// display expiration time
$form['schedule']['autoexpire_display'] = array(
- '#type' => 'markup',
+ '#type' => 'markup',
'#prefix' => '
',
'#suffix' => '
',
'#value' => theme('ad_status_display', $node),
);
$form['schedule']['autoexpire'] = array(
- '#type' => 'hidden',
+ '#type' => 'hidden',
'#value' => $node->autoexpire
);
}
@@ -841,7 +842,7 @@
/**
* Drupal _form_alter(&$form, &$form_state, $form_id) hook.
*/
-function ad_form_alter($form_id, &$form) {
+function ad_form_alter(&$form, $form_state, $form_id) {
if ($form_id == 'taxonomy_form_vocabulary') {
// Remove taxonomy form options not applicable for ad groups.
if ($form['vid']['#value'] == _ad_get_vid()) {
@@ -1006,7 +1007,7 @@
module_invoke_all('adowners', 'remove', $id->oid, $owner);
}
db_query('DELETE FROM {ad_owners} WHERE aid = %d', $node->nid);
- // All that's left of the ad is a single timestamp as to when it was
+ // All that's left of the ad is a single timestamp as to when it was
// deleted.
ad_statistics_increment($node->nid, 'delete');
break;
@@ -1021,7 +1022,7 @@
}
break;
}
- // Allow ad type module to act on nodeapi events. The adapi hook provides
+ // Allow ad type module to act on nodeapi events. The adapi hook provides
// access to additional variables not available in the nodeapi hook.
if ($node->adtype) {
// Don't use module_invoke, as in pre-PHP5 the changes to $node won't be
@@ -1057,7 +1058,7 @@
$header[] = array('data' => t('Status'), 'field' => 'status');
}
$header[] = array('data' => t(' '));
-
+
if ($node->nid) {
$sql = "SELECT cid, timestamp, uid, status, hostname, url FROM {ad_clicks} WHERE aid = $node->nid";
$sql .= tablesort_sql($header);
@@ -1175,7 +1176,7 @@
Dynamic menu items under a '!$may_cache' block can often be simplified
to remove references to arg(n) and use of '%
' to check
conditions. See http://drupal.org/node/103114.
-
+
The title and description arguments should not have strings wrapped in t(),
because translation of these happen in a later stage in the menu system.
@@ -1220,7 +1221,7 @@
'title' => 'List',
'page callback' => 'ad_admin_groups_list',
'access arguments' => array('administer advertisements'),
- 'type' => MENU_DEFAULT_LOCAL_TASK,
+ 'type' => MENU_DEFAULT_LOCAL_TASK,
'weight' => 0);
$items['admin/content/ad/groups/add'] = array(
'title' => 'Create group',
@@ -1258,16 +1259,24 @@
$items['node/add/ad/'. $adtype] = array(
'title' => t('!type advertisement', array('!type' => $adtype)),
'access arguments' => array('create advertisements'),
+ 'file' => '../../../..//modules/node/node.pages.inc'
);
}
-
-
+
+
$items["ad/redirect/%/%/%"] = array(
'access arguments' => array('show advertisements'),
- 'type' => MENU_CALLBACK,
+ 'type' => MENU_CALLBACK,
'page callback' => 'ad_redirect',
'page arguments' => (array(2,3,4)),
);
+
+ $items["ad/redirect/%/%"] = array(
+ 'access arguments' => array('show advertisements'),
+ 'type' => MENU_CALLBACK,
+ 'page callback' => 'ad_redirect',
+ 'page arguments' => (array(2,3)),
+ );
/***
// callbacks
if (arg(0) == 'ad' && arg(1) == 'redirect' && is_numeric(arg(2))) {
@@ -1276,27 +1285,27 @@
$hostid = preg_replace('/[^0-9a-f]/', '', arg(4));
$items["ad/redirect/$aid"] = array(
'access arguments' => array('show advertisements'),
- 'type' => MENU_CALLBACK,
+ 'type' => MENU_CALLBACK,
'page callback' => 'ad_redirect',
'page arguments' => array($aid, $group, $hostid)
);
}
elseif (arg(2) == 'ad' && arg(3) == 'groups' && is_numeric(arg(4))) {
if ($term = taxonomy_get_term(arg(4))) {
- $items["admin/content/ad/groups/$term->tid/edit"] = array(
+ $items["admin/content/ad/groups/".$term->tid."/edit"] = array(
'title' => 'edit',
'page callback' => 'drupal_get_form',
'page arguments' => array(
- 'ad_admin_group_form',
+ 'ad_admin_group_form',
(array)$term),
'access arguments' => array('administer advertisements'),
'type' => MENU_CALLBACK,
'weight' => 1);
- $items["admin/content/ad/groups/$term->tid/delete"] = array(
+ $items["admin/content/ad/groups/".$term->tid."/delete"] = array(
'title' => 'delete',
'page callback' => 'drupal_get_form',
'page arguments' => array(
- 'ad_confirm_group_delete',
+ 'ad_confirm_group_delete',
(array)$term),
'access arguments' => array('administer advertisements'),
'type' => MENU_CALLBACK,
@@ -1414,7 +1423,7 @@
}
}
drupal_set_title(t('Submit %name', array('%name' => $adtype)));
- $output = drupal_get_form('ad_node_form', $node);
+ $output = drupal_get_form('ad_'.$adtype.'_node_form', $node);
}
else {
$output = t('Choose from the following available advertisement types:');
@@ -1501,7 +1510,7 @@
$form['username'] = array(
'#autocomplete_path' => 'user/autocomplete',
'#description' => t('Enter the username of the user who should have ownership permissions on this advertisement.'),
- '#required' => TRUE,
+ '#required' => TRUE,
'#type' => 'textfield',
'#title' => t('Username'),
);
@@ -1596,7 +1605,7 @@
}
/**
- * Display a form with all available permissions and their status for the
+ * Display a form with all available permissions and their status for the
* selected ad and ad owner.
*/
function ad_owner_permissions($aid, $uid) {
@@ -1847,7 +1856,7 @@
ad_host_id_create($node->uid);
ad_statistics_increment($aid, 'update');
ad_statistics_increment($aid, $action);
- // Allow ad type module to act on nodeapi events. The adapi hook provides
+ // Allow ad type module to act on nodeapi events. The adapi hook provides
// access to additional variables not available in the nodeapi hook.
if ($node->adtype) {
// Don't use module_invoke, as in pre-PHP5 the changes to $node won't be
@@ -1899,7 +1908,7 @@
}
drupal_set_message(t('The ads have been deleted.'));
}
- return 'admin/content/ad';
+ $form_state['redirect'] = 'admin/content/ad';
}
/**
@@ -2205,7 +2214,7 @@
);
// Get overall global statistics.
- $statistics['global']['views'] = (int)db_result(db_query("SELECT SUM(s.count) FROM {ad_statistics} s LEFT JOIN {ads} a ON s.aid = a.aid LEFT JOIN {term_node} n ON a.aid = n.nid WHERE action = 'view' AND n.tid $filter"));
+ $statistics['global']['views'] = (int)db_result(db_query("SELECT SUM(s.count) FROM {ad_statistics} s LEFT JOIN {ads} a ON s.aid = a.aid LEFT JOIN {term_node} n ON a.aid = n.nid WHERE action = 'view' AND n.tid %s", $filter));
$statistics['global']['clicks'] = (int)db_result(db_query("SELECT SUM(s.count) FROM {ad_statistics} s LEFT JOIN {ads} a ON s.aid = a.aid LEFT JOIN {term_node} n ON a.aid = n.nid WHERE action = 'click' AND n.tid $filter"));
// Get overall statistics for this year and last year.
@@ -2215,7 +2224,7 @@
$statistics['last_year']['clicks'] = (int)db_result(db_query("SELECT SUM(s.count) FROM {ad_statistics} s LEFT JOIN {ads} a ON s.aid = a.aid LEFT JOIN {term_node} n ON a.aid = n.nid WHERE action = 'click' AND date >= %d AND date <= %d AND n.tid $filter", $last_year, $this_year));
$statistics['this_year']['views'] = (int)db_result(db_query("SELECT SUM(s.count) FROM {ad_statistics} s LEFT JOIN {ads} a ON s.aid = a.aid LEFT JOIN {term_node} n ON a.aid = n.nid WHERE action = 'view' AND date >= %d AND n.tid $filter", $this_year));
$statistics['this_year']['clicks'] = (int)db_result(db_query("SELECT SUM(s.count) FROM {ad_statistics} s LEFT JOIN {ads} a ON s.aid = a.aid LEFT JOIN {term_node} n ON a.aid = n.nid WHERE action = 'click' AND date >= %d AND n.tid $filter", $this_year));
-
+
// Get statistics for this month and last month.
$this_month = date('Ym0000');
$last_month = date('m') - 1;
@@ -2229,12 +2238,12 @@
$statistics['last_month']['clicks'] = (int)db_result(db_query("SELECT SUM(s.count) FROM {ad_statistics} s LEFT JOIN {ads} a ON s.aid = a.aid LEFT JOIN {term_node} n ON a.aid = n.nid WHERE action = 'click' AND date >= %d AND date <= %d AND n.tid $filter", $last_month, $this_month));
$statistics['this_month']['views'] = (int)db_result(db_query("SELECT SUM(s.count) FROM {ad_statistics} s LEFT JOIN {ads} a ON s.aid = a.aid LEFT JOIN {term_node} n ON a.aid = n.nid WHERE action = 'view' AND date >= %d AND n.tid $filter", $this_month));
$statistics['this_month']['clicks'] = (int)db_result(db_query("SELECT SUM(s.count) FROM {ad_statistics} s LEFT JOIN {ads} a ON s.aid = a.aid LEFT JOIN {term_node} n ON a.aid = n.nid WHERE action = 'click' AND date >= %d AND n.tid $filter", $this_month));
-
+
// Get statistics for this week.
$this_week_start = date('Ymd00', time() - 60*60*24*6);
$statistics['this_week']['views'] = (int)db_result(db_query("SELECT SUM(s.count) FROM {ad_statistics} s LEFT JOIN {ads} a ON s.aid = a.aid LEFT JOIN {term_node} n ON a.aid = n.nid WHERE action = 'view' AND date >= %d AND n.tid $filter", $this_week_start));
$statistics['this_week']['clicks'] = (int)db_result(db_query("SELECT SUM(s.count) FROM {ad_statistics} s LEFT JOIN {ads} a ON s.aid = a.aid LEFT JOIN {term_node} n ON a.aid = n.nid WHERE action = 'click' AND date >= %d AND n.tid $filter", $this_week_start));
-
+
// Get statistics for yesterday and today.
$yesterday_start = date('Ymd00', time() - 60*60*24);
$yesterday_end = date('Ymd24', time() - 60*60*24);
@@ -2243,7 +2252,7 @@
$statistics['yesterday']['clicks'] = (int)db_result(db_query("SELECT SUM(s.count) FROM {ad_statistics} s LEFT JOIN {ads} a ON s.aid = a.aid LEFT JOIN {term_node} n ON a.aid = n.nid WHERE action = 'click' AND date >= %d AND date <= %d AND n.tid $filter", $yesterday_start, $yesterday_end));
$statistics['today']['views'] = (int)db_result(db_query("SELECT SUM(s.count) FROM {ad_statistics} s LEFT JOIN {ads} a ON s.aid = a.aid LEFT JOIN {term_node} n ON a.aid = n.nid WHERE action = 'view' AND date >= %d AND n.tid $filter", $today_start));
$statistics['today']['clicks'] = (int)db_result(db_query("SELECT SUM(s.count) FROM {ad_statistics} s LEFT JOIN {ads} a ON s.aid = a.aid LEFT JOIN {term_node} n ON a.aid = n.nid WHERE action = 'click' AND date >= %d AND n.tid $filter", $today_start));
-
+
// Get statistics for this hour and the last hour.
$last_hour = date('YmdH', time() - 60*60);
$this_hour = date('YmdH', time());
@@ -2297,7 +2306,7 @@
);
$form['general'] = array(
- '#type' => 'fieldset',
+ '#type' => 'fieldset',
'#title' => t('General'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
@@ -2309,9 +2318,9 @@
'#type' => 'radios',
'#title' => t('Click-through target'),
'#options' => array(
- '_self' => t('same browser window and frame'),
- '_blank' => t('new browser window'),
- '_parent' => t('parent frame'),
+ '_self' => t('same browser window and frame'),
+ '_blank' => t('new browser window'),
+ '_parent' => t('parent frame'),
'_top' => t('same browser window, removing all frames'),
),
'#default_value' => variable_get('ad_link_target', '_self'),
@@ -2336,50 +2345,50 @@
}
$form['general']['ad_display'] = array(
- '#type' => 'radios',
- '#title' => t('Display type'),
- '#default_value' => variable_get('ad_display', 'javascript'),
+ '#type' => 'radios',
+ '#title' => t('Display type'),
+ '#default_value' => variable_get('ad_display', 'javascript'),
'#options' => $display_options,
'#description' => $description,
);
$form['general']['ad_validate_url'] = array(
'#type' => 'checkbox',
- '#title' => t('Validate URLs'),
- '#default_value' => variable_get('ad_validate_url', 1),
+ '#title' => t('Validate URLs'),
+ '#default_value' => variable_get('ad_validate_url', 1),
'#description' => t('If enabled, any destination URLs entered in ads will be required to be complete URLs (including http:// or https:// at the beginning). If you wish to include internal urls, you will need to disable this option.'),
);
$form['general']['ad_filter'] = array(
'#type' => 'checkbox',
- '#title' => t('Filter ads'),
- '#default_value' => variable_get('ad_filter', 0),
+ '#title' => t('Filter ads'),
+ '#default_value' => variable_get('ad_filter', 0),
'#description' => t('If enabled, the input format for each advertisement node will be applied to the displayed advertisement.'),
);
$form['iframe'] = array(
- '#type' => 'fieldset',
+ '#type' => 'fieldset',
'#title' => t('IFrame'),
'#collapsible' => TRUE,
'#collapsed' => variable_get('ad_display', 'javascript') == 'iframe' ? FALSE : TRUE
);
$form['iframe']['ad_iframe_frameborder'] = array(
- '#type' => 'checkbox',
+ '#type' => 'checkbox',
'#title' => t('Frameborder'),
- '#default_value' => variable_get('ad_iframe_frameborder', 0),
+ '#default_value' => variable_get('ad_iframe_frameborder', 0),
'#description' => t('If enabled, IFrames used for displaying ads will have a frameborder.'),
);
$form['iframe']['ad_iframe_scroll'] = array(
- '#type' => 'radios',
- '#title' => t('Scrolling'),
- '#default_value' => variable_get('ad_iframe_scroll', 'auto'),
+ '#type' => 'radios',
+ '#title' => t('Scrolling'),
+ '#default_value' => variable_get('ad_iframe_scroll', 'auto'),
'#options' => array('auto' => 'auto', 'on' => 'on', 'off' => 'off'),
'#description' => t('Define whether or not scroll bars should be enabled for the ad IFrame.'),
);
$form['iframe']['ad_iframe_width'] = array(
'#type' => 'textfield',
'#title' => t('Width'),
- '#default_value' => variable_get('ad_iframe_width', ''),
+ '#default_value' => variable_get('ad_iframe_width', ''),
'#maxlength' => 8,
'#size' => 5,
'#required' => FALSE,
@@ -2388,7 +2397,7 @@
$form['iframe']['ad_iframe_height'] = array(
'#type' => 'textfield',
'#title' => t('Height'),
- '#default_value' => variable_get('ad_iframe_height', ''),
+ '#default_value' => variable_get('ad_iframe_height', ''),
'#maxlength' => 8,
'#size' => 5,
'#required' => FALSE,
@@ -2396,7 +2405,7 @@
);
$form['cache'] = array(
- '#type' => 'fieldset',
+ '#type' => 'fieldset',
'#title' => t('Cache'),
'#collapsible' => TRUE,
'#collapsed' => variable_get('ad_cache', 'none') == 'none' ? TRUE : FALSE,
@@ -2413,9 +2422,9 @@
}
$form['cache']['ad_cache'] = array(
- '#type' => 'radios',
- '#title' => t('Type'),
- '#default_value' => variable_get('ad_cache', 'none'),
+ '#type' => 'radios',
+ '#title' => t('Type'),
+ '#default_value' => variable_get('ad_cache', 'none'),
'#options' => $cache_options,
'#description' => $description,
);
@@ -2435,7 +2444,7 @@
* Validate form settings, calling attention to any illogical configurations.
*/
function ad_admin_configure_settings_validate($form, &$form_state) {
- if ($form_state['values']['ad_link_target'] == '_self' &&
+ if ($form_state['values']['ad_link_target'] == '_self' &&
$form_state['values']['ad_display'] == 'iframe') {
// We don't consider this an error, as this could be exactly what the
// administrator is trying to do. But as for most people it is likely
@@ -2550,7 +2559,7 @@
$row = array();
$row[] = $group->name;
$row[] = $group->description;
- $row[] = l(t('edit'), "admin/content/ad/groups/$group->tid/edit");
+ $row[] = l(t('edit'), "admin/content/ad/groups/".$group->tid."/edit");
$rows[] = $row;
}
}
@@ -2755,7 +2764,7 @@
_ad_get_vid();
// Preserve old ad groups, if any.
- if (($old = variable_get('ad_group_vid_restore', '')) &&
+ if (($old = variable_get('ad_group_vid_restore', '')) &&
$vid = variable_get('ad_group_vid', '')) {
drupal_set_message(t('Restoring orphaned ad group configuration.'));
db_query('UPDATE {term_data} SET vid = %d WHERE vid = %d', $vid, $old);
@@ -2768,8 +2777,8 @@
}
// Allow modules to define an action to take each time an ad is served.
- // When modules define 'adserve_select' or 'adserve_filter', they must set
- // the 'function' and 'path' parameters. The 'weight' parameter can
+ // When modules define 'adserve_select' or 'adserve_filter', they must set
+ // the 'function' and 'path' parameters. The 'weight' parameter can
// optionally be set.
// function: the function to call when serving an add
// path: the path to the include file where $function is defined
@@ -2846,7 +2855,7 @@
'#required' => TRUE,
'#description' => t('Describe this ad group.')
);
-
+
$form['parent']['#tree'] = FALSE;
$form['weight'] = array(
@@ -2861,15 +2870,15 @@
'#value' => _ad_get_vid());
$form['submit'] = array(
- '#type' => 'submit',
+ '#type' => 'submit',
'#value' => t('Submit'));
if ($group['tid']) {
$form['delete'] = array(
- '#type' => 'submit',
+ '#type' => 'submit',
'#value' => t('Delete'));
$form['tid'] = array(
- '#type' => 'value',
+ '#type' => 'value',
'#value' => $group['tid']);
}
@@ -2891,7 +2900,8 @@
case SAVED_UPDATED:
drupal_set_message(t('The ad group %term has been updated.', array('%term' => $form_state['values']['name'])));
}
- return 'admin/content/ad/groups';
+ //return 'admin/content/ad/groups';
+ $form_state['redirect'] = 'admin/content/ad/groups';
}
/**
@@ -2903,10 +2913,10 @@
return confirm_form(
$form,
- t('Are you sure you want to delete the ad group %name?', array('%name' => $term['name'])),
- 'admin/content/ad/group',
- t('Ads that were within this group will not be deleted. This action cannot be undone.'),
- t('Delete'),
+ t('Are you sure you want to delete the ad group %name?', array('%name' => $term['name'])),
+ 'admin/content/ad/group',
+ t('Ads that were within this group will not be deleted. This action cannot be undone.'),
+ t('Delete'),
t('Cancel'));
}
@@ -2918,7 +2928,8 @@
drupal_set_message(t('The ad group %term has been deleted.', array('%term' => $form_state['values']['name'])));
watchdog('ad', 'mailarchive: deleted %term ad group.', array('%term' => $form_state['values']['name']));
- return 'admin/content/ad/groups';
+ //return 'admin/content/ad/groups';
+ $form_state['redirect'] = 'admin/content/ad/groups';
}
/**