Plugin Directory

Changeset 2947915


Ignore:
Timestamp:
08/04/2023 11:49:49 PM (3 years ago)
Author:
tomdude
Message:

rolling release/1.4.0

Location:
intelligence/trunk
Files:
84 added
33 edited

Legend:

Unmodified
Added
Removed
  • intelligence/trunk/admin/class-intel-admin.php

    r1827302 r2947915  
    189189        }
    190190
    191   }
    192 
    193     public function site_menu() {
     191    }
     192
     193    public function site_menu($network_site_menu = FALSE) {
    194194        global $wp_version;
    195195
     196        $capability = ($network_site_menu) ? 'manage_network_options' : 'manage_options';
     197
     198        // if network framework mode, hide admin menu for subsites
     199        if (intel()->is_network_framework_mode && !$network_site_menu) {
     200            return;
     201        }
     202
    196203        if ( current_user_can( 'manage_options' ) ) {
    197             add_menu_page( esc_html__( "Intelligence", 'intel' ), esc_html__( "Intelligence", 'intel' ), 'manage_options', 'intel_admin', array( $this, 'menu_router' ), 'dashicons-analytics');
    198             add_submenu_page( 'intel_admin', esc_html__( "Dashboard", 'intel' ), esc_html__( "Dashboard", 'intel' ), 'manage_options', 'intel_admin', array( $this, 'menu_router' ) );
    199             add_submenu_page( 'intel_admin', esc_html__( "Reports", 'intel' ), esc_html__( "Reports", 'intel' ), 'manage_options', 'intel_reports', array( $this, 'menu_router' ) );
    200             add_submenu_page( 'intel_admin', esc_html__( "Contacts", 'intel' ), esc_html__( "Contacts", 'intel' ), 'manage_options', 'intel_visitor', array( $this, 'menu_router' ) );
    201             add_submenu_page( 'intel_admin', esc_html__( "Settings", 'intel' ), esc_html__( "Settings", 'intel' ), 'manage_options', 'intel_config', array( $this, 'menu_router' ) );
    202             add_submenu_page( 'intel_admin', esc_html__( "Utilities", 'intel' ), esc_html__( "Utilities", 'intel' ), 'manage_options', 'intel_util', array( $this, 'menu_router' ) );
    203             add_submenu_page( 'intel_admin', esc_html__( "Help", 'intel' ), esc_html__( "Help", 'intel' ), 'manage_options', 'intel_help', array( $this, 'menu_router' ) );
    204     }
    205     }
     204            if (0 && intel_is_framework_only()) {
     205              add_menu_page( esc_html__( "Intelligence", 'intel' ), esc_html__( "Intelligence", 'intel' ), $capability, 'intel_config', array( $this, 'menu_router' ), 'dashicons-analytics');
     206            }
     207            else {
     208              add_menu_page( esc_html__( "Intelligence", 'intel' ), esc_html__( "Intelligence", 'intel' ), $capability, 'intel_admin', array( $this, 'menu_router' ), 'dashicons-analytics');
     209              add_submenu_page( 'intel_admin', esc_html__( "Dashboard", 'intel' ), esc_html__( "Dashboard", 'intel' ), $capability, 'intel_admin', array( $this, 'menu_router' ) );
     210              add_submenu_page( 'intel_admin', esc_html__( "Reports", 'intel' ), esc_html__( "Reports", 'intel' ), $capability, 'intel_reports', array( $this, 'menu_router' ) );
     211              add_submenu_page( 'intel_admin', esc_html__( "Annotations", 'intel' ), esc_html__( "Annotations", 'intel' ), $capability, 'intel_annotation', array( $this, 'menu_router' ) );
     212              add_submenu_page( 'intel_admin', esc_html__( "Contacts", 'intel' ), esc_html__( "Contacts", 'intel' ), $capability, 'intel_visitor', array( $this, 'menu_router' ) );
     213              add_submenu_page( 'intel_admin', esc_html__( "Settings", 'intel' ), esc_html__( "Settings", 'intel' ), $capability, 'intel_config', array( $this, 'menu_router' ) );
     214              add_submenu_page( 'intel_admin', esc_html__( "Utilities", 'intel' ), esc_html__( "Utilities", 'intel' ), $capability, 'intel_util', array( $this, 'menu_router' ) );
     215              add_submenu_page( 'intel_admin', esc_html__( "Help", 'intel' ), esc_html__( "Help", 'intel' ), $capability, 'intel_help', array( $this, 'menu_router' ) );
     216            }
     217        }
     218    }
     219
     220    public function network_site_menu() {
     221        $this->site_menu(TRUE);
     222    }
    206223
    207224    // for return_type json, page needs to be called earlier than standard menu routing
     
    245262        $q = '';
    246263        if ($_GET['page'] == 'intel_admin') {
    247             $q = 'admin/reports/intel';
    248             //$navbar_exclude[$q] = 1;
    249             $breadcrumbs[] = array(
    250                 'text' => esc_html__('Reports', 'intel'),
    251                 'path' => Intel_Df::url($q),
    252             );
    253             $navbar_base_q = $navbar_base_qt = $q;
    254       if (!$install_levels['ga_data']) {
    255                 $install_access_error = intel_get_install_access_error_message(array('level' => 'ga_data'));
    256             }
     264          $q = 'admin/reports/intel';
     265          //$navbar_exclude[$q] = 1;
     266          $breadcrumbs[] = array(
     267            'text' => esc_html__('Reports', 'intel'),
     268            'path' => Intel_Df::url($q),
     269          );
     270          $navbar_base_q = $navbar_base_qt = $q;
     271          if (!$install_levels['ga_data']) {
     272            $install_access_error = intel_get_install_access_error_message(array('level' => 'ga_data'));
     273          }
    257274        }
    258275        if ($_GET['page'] == 'intel_reports') {
     
    299316            );
    300317        }
     318        if ($_GET['page'] == 'intel_annotation') {
     319            $q = 'admin/annotations';
     320            $breadcrumbs[] = array(
     321                'text' => esc_html__('Annotations', 'intel'),
     322                'path' => Intel_Df::url($q),
     323            );
     324        }
     325        if (intel_is_framework_only()) {
     326          $q = 'admin/config/intel/settings/framework';
     327        }
    301328        if (isset($_GET['q'])) {
    302329            $q = $_GET['q'];
     
    317344            'submission',
    318345            'visitor',
     346            'annotation',
    319347        );
    320348        $this->args = $path_args = explode('/', $q);
     
    354382                    }
    355383                }
     384                else if (!empty($path_args[1]) && $path_args[1] == 'util') {
     385                  if (!empty($path_args[2]) && $path_args[2] == 'log') {
     386                    $bc_title = Intel_Df::t('Log');
     387                  }
     388                  if (!empty($bc_title)) {
     389                    $a = array_slice($path_args, 0, 4);
     390                    $breadcrumbs[] = array(
     391                      'text' => $bc_title,
     392                      'path' => Intel_Df::url(implode('/', $a)),
     393                    );
     394                  }
     395                }
    356396            }
    357397            else {
     
    399439                            );
    400440                        }
     441                        if ($path_args[0] == 'annotation') {
     442                            $breadcrumbs[] = array(
     443                                'text' => $entity->label(),
     444                                'path' => Intel_Df::url($entity->uri()),
     445                            );
     446                        }
    401447                    }
    402448                }
     
    406452                    $load_type = '';
    407453                    $load_title = '';
     454                    $entity_title = '';
    408455                    if ($path_args[1] == 'config') {
    409                         if ($path_args[4] == 'intel_event') {
    410                             $load_index = 5;
    411                             $load_type = 'intel_intel_event';
    412                             $load_title = Intel_Df::t('Intel Event');
    413                             $bc_title = Intel_Df::t('Event');
    414                         }
    415                         elseif ($path_args[4] == 'goal') {
    416                             $load_index = 5;
    417                             $load_type = 'intel_goal';
    418                             $bc_title = $load_title = Intel_Df::t('Goal');
    419                         }
    420                         elseif ($path_args[4] == 'taxonomy') {
    421                             $load_index = 5;
    422                             $load_type = 'intel_taxonomy';
    423                             $bc_title = $load_title = Intel_Df::t('Taxonomy');
    424                         }
    425 
    426                         if ($load_index) {
    427                             $func = $load_type . '_load';
    428                             $path_args_t[$load_index] = $func($path_args[$load_index]);
    429                             $entity = $path_args_t[$load_index];
    430                           if(empty($entity)) {
    431                                 $vars = array(
    432                                     'title' => esc_html__('404 Error', 'intel'),
    433                                     'markup' => Intel_Df::t('@load_title not found', array(
    434                                         '@load_title' => $load_title,
    435                                     )),
    436                                     //'markup' => esc_html__('@load_title not found', 'intel'),
    437                                     'messages' => Intel_Df::drupal_get_messages(),
    438                                 );
    439                                 print Intel_Df::theme('intel_page', $vars);
    440                                 return;
    441                             }
    442                             $a = $path_args;
    443                             $a[$load_index] = '%' . $load_type;
    444                             $qt = implode('/', $a);
    445                             if (!empty($menu_info[$qt])) {
    446                                 $info = $menu_info[$qt];
    447                             }
    448                             $a = array_slice($path_args, 0, 5);
    449                             $breadcrumbs[] = array(
    450                                 'text' => $bc_title,
    451                                 'path' => Intel_Df::url(implode('/', $a)),
    452                             );
    453                             $a = array_slice($path_args, 0, 6);
    454                             $breadcrumbs[] = array(
    455                                 'text' => $entity['title'],
    456                                 //'path' => Intel_Df::url(implode('/', $a)),
    457                             );
    458                         }
    459 
    460                     }
    461 
    462 
     456                      if ($path_args[4] == 'intel_event') {
     457                        $load_index = 5;
     458                        $load_type = 'intel_intel_event';
     459                        $load_title = Intel_Df::t('Intel Event');
     460                        $bc_title = Intel_Df::t('Event');
     461                      }
     462                      elseif ($path_args[4] == 'goal') {
     463                        $load_index = 5;
     464                        $load_type = 'intel_goal';
     465                        $bc_title = $load_title = Intel_Df::t('Goal');
     466                      }
     467                      elseif ($path_args[4] == 'taxonomy') {
     468                        $load_index = 5;
     469                        $load_type = 'intel_taxonomy';
     470                        $bc_title = $load_title = Intel_Df::t('Taxonomy');
     471                      }
     472                    }
     473                    else if ($path_args[1] == 'util') {
     474                      if ($path_args[2] == 'log' && !empty($path_args[3])) {
     475                        $load_index = 3;
     476                        $load_type = 'intel_log';
     477                        $load_title = Intel_Df::t('Intel Log');
     478                        $bc_title = Intel_Df::t('Log');
     479                      }
     480                    }
     481
     482                    if ($load_index) {
     483                        $func = $load_type . '_load';
     484                        $path_args_t[$load_index] = $func($path_args[$load_index]);
     485                        $entity = $path_args_t[$load_index];
     486                        if(empty($entity)) {
     487                            $vars = array(
     488                                'title' => esc_html__('404 Error', 'intel'),
     489                                'markup' => Intel_Df::t('@load_title not found', array(
     490                                    '@load_title' => $load_title,
     491                                )),
     492                                //'markup' => esc_html__('@load_title not found', 'intel'),
     493                                'messages' => Intel_Df::drupal_get_messages(),
     494                            );
     495                            print Intel_Df::theme('intel_page', $vars);
     496                            return;
     497                        }
     498                        $a = $path_args;
     499                        $a[$load_index] = '%' . $load_type;
     500                        $qt = implode('/', $a);
     501                        if (!empty($menu_info[$qt])) {
     502                            $info = $menu_info[$qt];
     503                        }
     504                        $a = array_slice($path_args, 0, $load_index);
     505                        $breadcrumbs[] = array(
     506                            'text' => $bc_title,
     507                            'path' => Intel_Df::url(implode('/', $a)),
     508                        );
     509                        $a = array_slice($path_args, 0, $load_index + 1);
     510                        $breadcrumbs[] = array(
     511                            'text' => ($entity instanceof IntelEntity) ? $entity->label() : $entity['title'],
     512                            //'path' => Intel_Df::url(implode('/', $a)),
     513                        );
     514                    }
    463515                }
    464516            }
     
    749801        // Don't show the connect notice anywhere but the plugins.php after activating
    750802        $current = get_current_screen();
    751         if (!intel_is_installed('min') && 'plugins' === $current->parent_base  ) {
     803        if (!intel_is_installed('min') && !intel_is_framework() && 'plugins' === $current->parent_base  ) {
    752804            $l_options = Intel_Df::l_options_add_class('btn btn-info');
    753805            $output .= '  <div class="panel panel-info m-t-1">';
  • intelligence/trunk/admin/intel.admin_config.php

    r2018028 r2947915  
    1616  //global $base_url;
    1717
    18   include_once INTEL_DIR . 'includes/intel.ga.php';
     18  //include_once INTEL_DIR . 'includes/intel.ga.php';
     19  intel_load_include('includes/intel.ga');
    1920
    2021  // check dependencies
     
    3435  }
    3536
    36   include_once INTEL_DIR . 'includes/intel.imapi.php';
     37  //include_once INTEL_DIR . 'includes/intel.imapi.php';
     38  intel_load_include('includes/intel.imapi');
    3739
    3840  $ga_data_source = intel_ga_data_source();
     
    4345  // check if imapi_property needs to be fetched
    4446  $imapi_property = get_option('intel_imapi_property', array());
    45   if (empty($imapi_property) || empty($op_meta['imapi_property_updated']) || (time() - $op_meta['imapi_property_updated'] < 86400) || !empty($_GET['refresh'])) {
     47  if (
     48    empty($imapi_property) || empty($imapi_property['intel_tid'])
     49    || ($imapi_property['intel_tid'] != $ga_tid)
     50    || empty($op_meta['imapi_property_updated'])
     51    || (time() - $op_meta['imapi_property_updated'] < 86400)
     52    || !empty($_GET['refresh'])
     53  ) {
    4654    if ($ga_tid && $apikey) {
    4755      $options = array(
     
    4957        'apikey' => $apikey,
    5058      );
     59
    5160      try {
    5261        $imapi_property = intel_imapi_property_get($options);
     62
    5363        $op_meta['imapi_property_updated'] = time();
    5464      }
     
    5767        unset($op_meta['imapi_property_updated']);
    5868      }
     69
    5970      update_option('intel_imapi_property', $imapi_property);
    6071      update_option('intel_option_meta', $op_meta);
     
    6879  $ga_viewid = get_option('intel_ga_view', '');
    6980  $ga_profile_base = get_option('intel_ga_profile_base', array());
    70 
    7181  if (!empty($imapi_property) && (empty($ga_profile) || empty($ga_viewid))) {
    7282    $ga_profile = $imapi_property['ga_profile'];
     
    160170
    161171
    162 
    163 
    164172  /*
    165173  $form['l10iapi']['intel_ga_tid'] = array(
     
    237245    '#field_suffix' => '/',
    238246  );
     247
    239248  $options = array(
    240249    '' => Intel_Df::t('Default'),
     
    771780function intel_admin_settings_validate($form, &$form_state) {
    772781  $values = $form_state['values'];
     782
    773783  // convert string to array
    774784  parse_str($form_state['values']['intel_l10iapi_custom_params'], $params);
     
    781791    || ($values['intel_ga_tid'] != $imapi_property->intel_tid)
    782792  ) {
     793    $values['intel_imapi_url'] = trim($values['intel_imapi_url']);
    783794    $options = array(
    784795      'tid' => $values['intel_ga_tid'],
    785       'apikey' => $values['intel_apikey']
    786     );
     796      'apikey' => $values['intel_apikey'],
     797      'api_url' => !empty($values['intel_imapi_url']) ? $values['intel_imapi_url'] : INTEL_IMAPI_URL,
     798    );
     799
    787800    try {
    788801      $form_state['intel_imapi_property'] = $imapi_property = intel_imapi_property_get($options);
     
    13621375
    13631376function intel_admin_goal_list_page() {
    1364   require_once INTEL_DIR . "includes/intel.ga.php";
     1377  //require_once INTEL_DIR . "includes/intel.ga.php";
     1378  intel_load_include('includes/intel.ga');
    13651379
    13661380
     
    13681382    intel_sync_goals_ga_goals();
    13691383    Intel_Df::drupal_set_message(Intel_Df::t('Goal data has been resynced'));
    1370     $l_option = Intel_Df::l_options_add_query(array());
     1384    $l_option = intel_l_options_add_query(array());
    13711385    Intel_Df::drupal_goto(Intel_Df::current_path(), $l_option);
    13721386  }
     
    13851399  if (isset($_GET['refresh'])) {
    13861400    Intel_Df::drupal_set_message(Intel_Df::t('Goal data has been refreshed'));
    1387     $l_option = Intel_Df::l_options_add_query(array());
     1401    $l_option = intel_l_options_add_query(array());
    13881402    Intel_Df::drupal_goto(Intel_Df::current_path(), $l_option);
    13891403  }
     
    17671781  }
    17681782
    1769   $form_state['event'] = $event;
     1783  $form['#intel_event'] = $form_state['intel_event'] = $event;
    17701784  $add = empty($event['key']);
    17711785  $custom = (!$event || !empty($event['custom'])) ? 1 : 0;
     
    21862200      '#type' => (1 || $custom || !empty($overridable[$key])) ? 'textarea' : 'item',
    21872201      '#title' => Intel_Df::t('Page list'),
    2188       '#default_value' => !empty($event[$key]) ? $event[$key] : 0,
     2202      '#default_value' => !empty($event[$key]) ? $event[$key] : '',
    21892203      '#disabled' => !($custom || !empty($overridable[$key])),
    21902204      '#description' => Intel_Df::t("Specify pages by using their paths. Enter one path per line. The '*' character is a wildcard. For example, if all blog pages are Example paths are blog for the blog page and blog/* for every personal blog. <home> is the front page."),
     
    22412255function intel_admin_intel_event_form_validate(&$form, &$form_state) {
    22422256  $values = $form_state['values'];
    2243   $event = $form_state['event'];
     2257  $event = $form_state['intel_event'];
    22442258  $key = '';
    22452259  if (!empty($values['key'])) {
     
    22662280function intel_admin_intel_event_form_submit(&$form, &$form_state) {
    22672281  $values = $form_state['values'];
    2268   $add = empty($form_state['event']['key']) ? 1 : 0;
     2282  $add = empty($form_state['intel_event']['key']) ? 1 : 0;
    22692283
    22702284
     
    22732287  }
    22742288  else {
    2275     $key = $form_state['event']['key'];
     2289    $key = $form_state['intel_event']['key'];
    22762290  }
    22772291
     
    23012315  if ($add) {
    23022316    $msg = Intel_Df::t('Intel event %title has been added.', array(
    2303       '%title' => $event['title'],
     2317      '%title' => !empty($event['title']) ? $event['title'] : $form_state['intel_event']['title'],
    23042318    ));
    23052319  }
    23062320  else {
    23072321    $msg = Intel_Df::t('Intel event %title has been updated.', array(
    2308       '%title' => $event['title'],
     2322      '%title' => !empty($event['title']) ? $event['title'] : $form_state['intel_event']['title'],
    23092323    ));
    23102324  }
  • intelligence/trunk/admin/intel.admin_setup.php

    r2018028 r2947915  
    137137
    138138  $items = array();
     139  $items[] = '<div class="alert alert-danger">';
     140  $items[] = Intel_Df::t('This plugin was designed to work with Google Universal Analytics which has been discontinued by Google as of 7/1/2023.');
     141  $items[] = Intel_Df::t('As such, the Intelligence API has been discontinued. This plugin should no longer be installed on new sites.');
     142  $items[] = '</div>';
    139143  $items[] = '<div class="text-center">';
    140144  $items[] = '<h3>' . Intel_Df::t('Results oriented Google Analytics made easy.') . '</h3>';
  • intelligence/trunk/admin/intel.admin_util.php

    r2018028 r2947915  
    11<?php
     2
     3use function d7\db_query;
     4
    25/**
    36 * @file
     
    2932 */
    3033function intel_util_temp() {
    31   update_option('intel_ga_data_api', 'intel');
    32   include_once INTEL_DIR . 'includes/intel.imapi.php';
    33 
    34   $ga_access_token = intel_imapi_ga_access_token_get();
    35   intel_d($ga_access_token);
    36 
    37   update_option('intel_ga_access_token', $ga_access_token);
    38 
    39   return 'OK';
     34
     35  return '';
    4036}
    4137
     
    196192}
    197193
    198 function intel_util_log_page() {
     194function intel_util_log_page($entity) {
     195  $output = '';
     196
     197  if (intel_is_debug()) {
     198    //intel_d($entity->variables);
     199  }
     200
     201  $rows = array();
     202  $rows[] = array(
     203    Intel_Df::t('Type'),
     204    $entity->type,
     205  );
     206  $rows[] = array(
     207    Intel_Df::t('Date'),
     208    Intel_Df::format_date($entity->timestamp, ''),
     209  );
     210  $rows[] = array(
     211    Intel_Df::t('User'),
     212    '',
     213  );
     214  $rows[] = array(
     215    Intel_Df::t('Location'),
     216    $entity->location,
     217  );
     218  $rows[] = array(
     219    Intel_Df::t('Referrer'),
     220    $entity->referrer,
     221  );
     222  intel_d($entity->variables);
     223  $vars = (is_array($entity->variables)) ?$entity->variables : array();
     224  $rows[] = array(
     225    Intel_Df::t('Message'),
     226    Intel_Df::t($entity->message, $vars),
     227  );
     228  /*
     229  $rows[] = array(
     230    Intel_Df::t('Variables'),
     231    intel_d($entity->variables),
     232  );
     233  */
     234  $rows[] = array(
     235    Intel_Df::t('Severity'),
     236    $entity->severity,
     237  );
     238  $rows[] = array(
     239    Intel_Df::t('Hostname'),
     240    $entity->hostname,
     241  );
     242  $rows[] = array(
     243    Intel_Df::t('Operations'),
     244    '' , //$entity->hostname,
     245  );
     246
     247
     248  $vars = array(
     249    'header' => array(),
     250    'rows' => $rows,
     251  );
     252
     253  $output .= Intel_Df::theme('table', $vars);
     254  // TODO
     255  return $output;
     256}
     257
     258function intel_util_log_list_page() {
    199259  $output = '';
    200260
     
    204264  $output .= Intel_Df::render($form);
    205265
     266  $variables = array(
     267    '%foo' => 'Foo',
     268  );
     269  //Intel_Df::watchdog('test', 'foo: %foo', $variables, Intel_Df::WATCHDOG_INFO);
     270
     271  $watchdog_mode = Intel_Df::watchdog_mode();
     272
     273  if ($watchdog_mode != 'db') {
     274    return $output;
     275  }
     276
     277  $row_limit = 100;
     278
     279  $header = array(
     280    Intel_Df::t('Type'),
     281    Intel_Df::t('Date'),
     282    Intel_Df::t('Message'),
     283    Intel_Df::t('User'),
     284    Intel_Df::t('Ops'),
     285  );
     286
     287  $filter = array();
     288  $options = array();
     289  $options['order_by'] = 'timestamp DESC';
     290  $entities = intel()->get_entity_controller('intel_log')->loadByFilter($filter, $options, $header, $row_limit, 0);
     291
     292  $rows = array();
     293
     294  $options = array();
     295  $custom_default_value = '';
     296  $link_options = array(
     297    'query' => Intel_Df::drupal_get_destination(),
     298  );
     299  $count = 0;
     300  foreach ($entities as $entity) {
     301    $row = array();
     302    $row[] = $entity->type;
     303    $row[] = Intel_Df::format_date($entity->timestamp, $format = '');
     304    $row[] = Intel_df::l(substr($entity->message, 0, 64), 'admin/util/log/' . $entity->lid);
     305    $row[] = '';
     306    $row[] = '';
     307    $rows[] = $row;
     308  }
     309
     310
     311  $vars = array(
     312    'header' => $header,
     313    'rows' => $rows,
     314    'empty' => Intel_Df::t('No log entries found.'),
     315  );
     316
     317  $output .= Intel_Df::theme('table', $vars);
     318
    206319  return $output;
    207320}
     
    209322function intel_util_log_form($form, &$form_state) {
    210323
    211   $watchdog_mode = get_option('intel_watchdog_mode', '');
     324  $watchdog_mode = Intel_Df::watchdog_mode();
     325
     326  intel_d($watchdog_mode);
    212327
    213328  $form['settings'] = array(
     
    221336  $options = array(
    222337    '' => Intel_Df::t('None'),
    223     'log' => Intel_Df::t('Log'),
     338    'error_log' => Intel_Df::t('Error log'),
    224339    'db' => Intel_Df::t('Database'),
    225340  );
     
    257372
    258373function intel_util_log_form_submit($form, &$form_state) {
     374  global $wpdb;
    259375  //intel_d($form_state);
    260376  $values = $form_state['values'];
     
    262378
    263379  if (!empty($form_state['input']['submit_settings'])) {
    264     update_option('intel_watchdog_mode', $values['watchdog_mode']);
     380    if (intel()->is_network_active) {
     381      update_site_option('intel_watchdog_mode', $values['watchdog_mode']);
     382    }
     383    else {
     384      update_option('intel_watchdog_mode', $values['watchdog_mode']);
     385    }
     386
     387    if ($values['watchdog_mode'] == 'db') {
     388      if (!intel_log_table_exists()) {
     389        intel_log_table_create();
     390        Intel_Df::drupal_set_message(Intel_Df::t('intel_log db table created.'));
     391      }
     392    }
     393    else {
     394      if (intel_log_table_exists()) {
     395        intel_log_table_drop();
     396        Intel_Df::drupal_set_message(Intel_Df::t('intel_log db table dropped.'));
     397      }
     398    }
    265399    Intel_Df::drupal_set_message(Intel_Df::t('Settings have been updated.'));
    266400  }
    267401
    268402  if (!empty($form_state['input']['submit_clear'])) {
     403    $table_name = $wpdb->prefix . "intel_log";
     404    $delete = $wpdb->query("TRUNCATE TABLE $table_name");
    269405    Intel_Df::drupal_set_message(Intel_Df::t('Log has been cleared.'));
    270406  }
     407}
     408
     409function intel_log_table_exists() {
     410  global $wpdb;
     411
     412  $table_name = $wpdb->prefix . "intel_log";
     413
     414  if ( $wpdb->get_var( $wpdb->prepare( "SHOW TABLES LIKE %s", $table_name ) ) === $table_name ) {
     415    return TRUE;
     416  }
     417
     418  return FALSE;
     419}
     420
     421function intel_log_table_create() {
     422  global $wpdb;
     423
     424  require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
     425
     426  $charset_collate = $wpdb->get_charset_collate();
     427
     428  $table_name = $wpdb->prefix . "intel_log";
     429
     430  $sql = "CREATE TABLE $table_name (
     431    lid int(11) NOT NULL AUTO_INCREMENT,
     432    uid int(11) NOT NULL DEFAULT '0',
     433    type varchar(64) NOT NULL DEFAULT '',
     434    message longtext NOT NULL,
     435    variables longblob NOT NULL,
     436    severity tinyint(3) UNSIGNED NOT NULL DEFAULT '0',
     437    link varchar(255) DEFAULT '',
     438    location text NOT NULL,
     439    referer text,
     440    hostname varchar(128) NOT NULL DEFAULT '',
     441    timestamp int(11) NOT NULL DEFAULT '0',
     442    PRIMARY KEY (lid),
     443    KEY type (type),
     444    KEY uid (uid),
     445    KEY severity (severity)
     446  ) $charset_collate;";
     447
     448  dbDelta( $sql );
     449}
     450
     451function  intel_log_table_drop() {
     452  global $wpdb;
     453
     454  require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
     455
     456  $charset_collate = $wpdb->get_charset_collate();
     457
     458  $table_name = $wpdb->prefix . "intel_log";
     459
     460  $sql = "DROP TABLE IF EXISTS $table_name;";
     461
     462  $wpdb->query($sql);
    271463}
    272464
     
    526718
    527719  $account = wp_get_current_user();
     720
     721  $form_id = $form_state['build_info']['form_id'];
     722  $form_def = array(
     723    'formType' => 'intel_form',
     724    'formId' => $form_id,
     725    'formTitle' => ucwords(str_replace('_', ' ', $form_id)),
     726    'selector' => "form#{$form_id}",
     727    'trackView' => 1,
     728  );
     729  intel_add_page_intel_push(array('formtracker:trackForm', $form_def));
    528730
    529731  $form['data.givenName'] = array(
  • intelligence/trunk/admin/intel.admin_visitor.php

    r1904936 r2947915  
    4747    }
    4848  }
    49   dsm($prop_options);
     49  //dsm($prop_options);
    5050
    5151  $tax_options = array(
     
    529529
    530530  // Retrieve all profile fields and attach to $entity->content.
    531   Intel_Visitor::build_content($entity);
     531  IntelVisitor::build_content($entity);
    532532
    533533  $build = $entity->content;
  • intelligence/trunk/includes/class-intel-activator.php

    r1827302 r2947915  
    188188        dbDelta( $sql );
    189189
     190        $table_name = $wpdb->prefix . "intel_annotation";
     191
     192        $sql = "CREATE TABLE $table_name (
     193    aid int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
     194    uid int(11) NOT NULL DEFAULT '0',
     195    created int(10) UNSIGNED NOT NULL DEFAULT 0,
     196    updated int(10) UNSIGNED NOT NULL DEFAULT 0,
     197    started int(10) UNSIGNED NOT NULL DEFAULT 0,
     198    transient_period int(10) UNSIGNED NOT NULL DEFAULT 0,
     199    ended int(10) UNSIGNED NOT NULL DEFAULT 0,
     200    analytics_period int(10) UNSIGNED NOT NULL DEFAULT 0,
     201    type varchar(128) NOT NULL DEFAULT '',
     202    message longtext NOT NULL,
     203    variables longtext NOT NULL,
     204    data longtext NOT NULL,
     205    PRIMARY KEY (aid),
     206    KEY started (started),
     207    KEY analytics_period (analytics_period),
     208    KEY type (type(14))
     209    ) $charset_collate;";
     210
     211        dbDelta( $sql );
     212
    190213    }
    191214
  • intelligence/trunk/includes/class-intel-df.php

    r2018028 r2947915  
    130130    const MENU_CONTEXT_INLINE = 0x0002;
    131131
    132     const WATCHDOG_NOTICE = 5;
    133     const WATCHDOG_ERROR = 3;
     132  /**
     133   * Watchdog status flags
     134   */
     135  const WATCHDOG_EMERGENCY = 0;
     136  const WATCHDOG_ALERT = 1;
     137  const WATCHDOG_CRITICAL = 2;
     138  const WATCHDOG_ERROR = 3;
     139  const WATCHDOG_WARNING = 4;
     140  const WATCHDOG_NOTICE = 5;
     141  const WATCHDOG_INFO = 6;
     142  const WATCHDOG_DEBUG = 7;
    134143
    135144    private function __construct() {
     
    158167
    159168
    160         Intel_Df::watchdog('$request_uri', $request_uri);
    161 
    162         Intel_Df::watchdog('current_url', $current_url);
     169        Intel_Df::watchdog('$request_uri', $request_uri);//
     170
     171        Intel_Df::watchdog('current_url', $current_url);//
    163172        $site_url = get_site_url();
    164         Intel_Df::watchdog('get_site_url', $site_url);
    165         $path = str_replace($site_url, '', $current_url);
    166         Intel_Df::watchdog('path', $path);
     173        Intel_Df::watchdog('get_site_url', $site_url);//
     174        $path = str_replace($site_url, '', $current_url);//
     175        Intel_Df::watchdog('path', $path);//
    167176        return $path;
    168177    }
     
    178187        }
    179188    }
     189
     190  /**
     191   * Adds a JavaScript file, setting, or inline code to the page.
     192   *
     193   * The behavior of this function depends on the parameters it is called with.
     194   * Generally, it handles the addition of JavaScript to the page, either as
     195   * reference to an existing file or as inline code. The following actions can be
     196   * performed using this function:
     197   * - Add a file ('file'): Adds a reference to a JavaScript file to the page.
     198   * - Add inline JavaScript code ('inline'): Executes a piece of JavaScript code
     199   *   on the current page by placing the code directly in the page (for example,
     200   *   to tell the user that a new message arrived, by opening a pop up, alert
     201   *   box, etc.). This should only be used for JavaScript that cannot be executed
     202   *   from a file. When adding inline code, make sure that you are not relying on
     203   *   $() being the jQuery function. Wrap your code in
     204   *   @code (function ($) {... })(jQuery); @endcode
     205   *   or use jQuery() instead of $().
     206   * - Add external JavaScript ('external'): Allows the inclusion of external
     207   *   JavaScript files that are not hosted on the local server. Note that these
     208   *   external JavaScript references do not get aggregated when preprocessing is
     209   *   on.
     210   * - Add settings ('setting'): Adds settings to Drupal's global storage of
     211   *   JavaScript settings. Per-page settings are required by some modules to
     212   *   function properly. All settings will be accessible at Drupal.settings.
     213   *
     214   * Examples:
     215   * @code
     216   *   drupal_add_js('misc/collapse.js');
     217   *   drupal_add_js('misc/collapse.js', 'file');
     218   *   drupal_add_js('jQuery(document).ready(function () { alert("Hello!"); });', 'inline');
     219   *   drupal_add_js('jQuery(document).ready(function () { alert("Hello!"); });',
     220   *     array('type' => 'inline', 'scope' => 'footer', 'weight' => 5)
     221   *   );
     222   *   drupal_add_js('http://example.com/example.js', 'external');
     223   *   drupal_add_js(array('myModule' => array('key' => 'value')), 'setting');
     224   * @endcode
     225   *
     226   * Calling drupal_static_reset('drupal_add_js') will clear all JavaScript added
     227   * so far.
     228   *
     229   * If JavaScript aggregation is enabled, all JavaScript files added with
     230   * $options['preprocess'] set to TRUE will be merged into one aggregate file.
     231   * Preprocessed inline JavaScript will not be aggregated into this single file.
     232   * Externally hosted JavaScripts are never aggregated.
     233   *
     234   * The reason for aggregating the files is outlined quite thoroughly here:
     235   * http://www.die.net/musings/page_load_time/ "Load fewer external objects. Due
     236   * to request overhead, one bigger file just loads faster than two smaller ones
     237   * half its size."
     238   *
     239   * $options['preprocess'] should be only set to TRUE when a file is required for
     240   * all typical visitors and most pages of a site. It is critical that all
     241   * preprocessed files are added unconditionally on every page, even if the
     242   * files are not needed on a page. This is normally done by calling
     243   * drupal_add_js() in a hook_init() implementation.
     244   *
     245   * Non-preprocessed files should only be added to the page when they are
     246   * actually needed.
     247   *
     248   * @param $data
     249   *   (optional) If given, the value depends on the $options parameter, or
     250   *   $options['type'] if $options is passed as an associative array:
     251   *   - 'file': Path to the file relative to base_path().
     252   *   - 'inline': The JavaScript code that should be placed in the given scope.
     253   *   - 'external': The absolute path to an external JavaScript file that is not
     254   *     hosted on the local server. These files will not be aggregated if
     255   *     JavaScript aggregation is enabled.
     256   *   - 'setting': An associative array with configuration options. The array is
     257   *     merged directly into Drupal.settings. All modules should wrap their
     258   *     actual configuration settings in another variable to prevent conflicts in
     259   *     the Drupal.settings namespace. Items added with a string key will replace
     260   *     existing settings with that key; items with numeric array keys will be
     261   *     added to the existing settings array.
     262   * @param $options
     263   *   (optional) A string defining the type of JavaScript that is being added in
     264   *   the $data parameter ('file'/'setting'/'inline'/'external'), or an
     265   *   associative array. JavaScript settings should always pass the string
     266   *   'setting' only. Other types can have the following elements in the array:
     267   *   - type: The type of JavaScript that is to be added to the page. Allowed
     268   *     values are 'file', 'inline', 'external' or 'setting'. Defaults
     269   *     to 'file'.
     270   *   - scope: The location in which you want to place the script. Possible
     271   *     values are 'header' or 'footer'. If your theme implements different
     272   *     regions, you can also use these. Defaults to 'header'.
     273   *   - group: A number identifying the group in which to add the JavaScript.
     274   *     Available constants are:
     275   *     - JS_LIBRARY: Any libraries, settings, or jQuery plugins.
     276   *     - JS_DEFAULT: Any module-layer JavaScript.
     277   *     - JS_THEME: Any theme-layer JavaScript.
     278   *     The group number serves as a weight: JavaScript within a lower weight
     279   *     group is presented on the page before JavaScript within a higher weight
     280   *     group.
     281   *   - every_page: For optimal front-end performance when aggregation is
     282   *     enabled, this should be set to TRUE if the JavaScript is present on every
     283   *     page of the website for users for whom it is present at all. This
     284   *     defaults to FALSE. It is set to TRUE for JavaScript files that are added
     285   *     via module and theme .info files. Modules that add JavaScript within
     286   *     hook_init() implementations, or from other code that ensures that the
     287   *     JavaScript is added to all website pages, should also set this flag to
     288   *     TRUE. All JavaScript files within the same group and that have the
     289   *     'every_page' flag set to TRUE and do not have 'preprocess' set to FALSE
     290   *     are aggregated together into a single aggregate file, and that aggregate
     291   *     file can be reused across a user's entire site visit, leading to faster
     292   *     navigation between pages. However, JavaScript that is only needed on
     293   *     pages less frequently visited, can be added by code that only runs for
     294   *     those particular pages, and that code should not set the 'every_page'
     295   *     flag. This minimizes the size of the aggregate file that the user needs
     296   *     to download when first visiting the website. JavaScript without the
     297   *     'every_page' flag is aggregated into a separate aggregate file. This
     298   *     other aggregate file is likely to change from page to page, and each new
     299   *     aggregate file needs to be downloaded when first encountered, so it
     300   *     should be kept relatively small by ensuring that most commonly needed
     301   *     JavaScript is added to every page.
     302   *   - weight: A number defining the order in which the JavaScript is added to
     303   *     the page relative to other JavaScript with the same 'scope', 'group',
     304   *     and 'every_page' value. In some cases, the order in which the JavaScript
     305   *     is presented on the page is very important. jQuery, for example, must be
     306   *     added to the page before any jQuery code is run, so jquery.js uses the
     307   *     JS_LIBRARY group and a weight of -20, jquery.once.js (a library drupal.js
     308   *     depends on) uses the JS_LIBRARY group and a weight of -19, drupal.js uses
     309   *     the JS_LIBRARY group and a weight of -1, other libraries use the
     310   *     JS_LIBRARY group and a weight of 0 or higher, and all other scripts use
     311   *     one of the other group constants. The exact ordering of JavaScript is as
     312   *     follows:
     313   *     - First by scope, with 'header' first, 'footer' last, and any other
     314   *       scopes provided by a custom theme coming in between, as determined by
     315   *       the theme.
     316   *     - Then by group.
     317   *     - Then by the 'every_page' flag, with TRUE coming before FALSE.
     318   *     - Then by weight.
     319   *     - Then by the order in which the JavaScript was added. For example, all
     320   *       else being the same, JavaScript added by a call to drupal_add_js() that
     321   *       happened later in the page request gets added to the page after one for
     322   *       which drupal_add_js() happened earlier in the page request.
     323   *   - requires_jquery: Set this to FALSE if the JavaScript you are adding does
     324   *     not have a dependency on jQuery. Defaults to TRUE, except for JavaScript
     325   *     settings where it defaults to FALSE. This is used on sites that have the
     326   *     'javascript_always_use_jquery' variable set to FALSE; on those sites, if
     327   *     all the JavaScript added to the page by drupal_add_js() does not have a
     328   *     dependency on jQuery, then for improved front-end performance Drupal
     329   *     will not add jQuery and related libraries and settings to the page.
     330   *   - defer: If set to TRUE, the defer attribute is set on the <script>
     331   *     tag. Defaults to FALSE.
     332   *   - cache: If set to FALSE, the JavaScript file is loaded anew on every page
     333   *     call; in other words, it is not cached. Used only when 'type' references
     334   *     a JavaScript file. Defaults to TRUE.
     335   *   - preprocess: If TRUE and JavaScript aggregation is enabled, the script
     336   *     file will be aggregated. Defaults to TRUE.
     337   *
     338   * @return
     339   *   The current array of JavaScript files, settings, and in-line code,
     340   *   including Drupal defaults, anything previously added with calls to
     341   *   drupal_add_js(), and this function call's additions.
     342   *
     343   * @see drupal_get_js()
     344   */
     345  public static function drupal_add_js($data = NULL, $options = NULL) {
     346    intel()->add_js($data, $options);
     347  }
    180348
    181349    /**
     
    489657        // The 'Location' HTTP header must be absolute.
    490658        $options['absolute'] = TRUE;
     659
    491660        $url = self::url($path, $options);
    492661
     
    9381107    }
    9391108
    940 
     1109  public static function entity_get_controller($entity_type) {
     1110    return intel()->get_entity_controller($entity_type);
     1111  }
     1112
     1113  public static function entity_get_info($entity_type = NULL) {
     1114    return intel()->entity_info($entity_type);
     1115  }
    9411116
    9421117    public static function format_date($time, $format = '') {
     
    10271202        if ($options['external'] && strpos($path, '//') == FALSE) {
    10281203            $hook_data = apply_filters('intel_url_urn_resolver', $hook_data);
    1029             // check if path returned from resover is external
     1204            // check if path returned from resolver is external
    10301205            $options['external'] = self::url_is_external($path);
    10311206        }
     
    10511226            }
    10521227
    1053             if (isset($options['https']) && variable_get('https', FALSE)) {
     1228      //if (isset($options['https']) && variable_get('https', FALSE)) {
     1229      if (isset($options['https'])) {
    10541230                if ($options['https'] === TRUE) {
    10551231                    $path = str_replace('http://', 'https://', $path);
     
    10771253        // The base_url might be rewritten from the language rewrite in domain mode.
    10781254        if (!isset($options['base_url'])) {
    1079             if (isset($options['https']) && variable_get('https', FALSE)) {
     1255            if (isset($options['https']) && get_option('https', FALSE)) {
    10801256                if ($options['https'] === TRUE) {
    10811257                    $options['base_url'] = $base_secure_url;
     
    11271303                    $admin_page = 'intel_visitor';
    11281304                }
     1305                elseif ($path_args[1] == 'annotations') {
     1306                    $admin_page = 'intel_annotation';
     1307                }
    11291308            }
    11301309        }
     
    11341313        elseif($path_args[0] == 'submission') {
    11351314            $admin_page = 'intel_admin';
     1315        }
     1316        elseif($path_args[0] == 'annotation') {
     1317            $admin_page = 'intel_annotation';
    11361318        }
    11371319
     
    11411323            $is_admin_path = 1;
    11421324        }
    1143 
    11441325
    11451326        // if path uses /wp-admin/ or /subdir/wp-admin/ format, strip off base_path_admin
     
    11641345        if ($is_admin_path) {
    11651346            $base = $options['absolute'] ? $options['base_url'] . $intel->base_path_admin : $intel->base_path_admin;
     1347            // check if current context is network admin and add correct url to stay on network admin
     1348            if ($intel->is_network_admin) {
     1349              $base .= 'network/';
     1350      }
    11661351            $prefix = empty($path) ? rtrim($options['prefix'], '/') : $options['prefix'];
    11671352        }
     
    12671452            $search = '';
    12681453            if (strpos($string, $k) !== FALSE) {
     1454              if (!is_string($v)) {
     1455          continue;
     1456        }
    12691457                if (substr($k, 1, 0) == '@' ) {
    12701458                    $v = self::check_plain($v);
     
    13811569        // if template file, process variables via template file
    13821570        if (!empty($info['template'])) {
    1383             $file = INTEL_DIR . 'templates/' . $info['template'] . '.tpl.php';
     1571      if (!empty($info['path'])) {
     1572        $file = $info['path'] . $info['template'] . '.tpl.php';
     1573      }
     1574      else {
     1575        $file = INTEL_DIR . 'templates/' . $info['template'] . '.tpl.php';
     1576      }
     1577
    13841578            if (file_exists($file)) {
    13851579                $output = self::process_template($file, $variables);
     
    17171911    public static function theme_table($variables) {
    17181912        $defs = array(
     1913          'header' => array(),
    17191914            'rows' => array(),
    17201915            'attributes' => array(),
     
    17761971                // Build colgroup
    17771972                if (is_array($cols) && count($cols)) {
    1778                     $output .= ' <colgroup' . Intl_Df::drupal_attributes($attributes) . '>';
     1973                    $output .= ' <colgroup' . Intel_Df::drupal_attributes($attributes) . '>';
    17791974                    $i = 0;
    17801975                    foreach ($cols as $col) {
    1781                         $output .= ' <col' . Intl_Df::drupal_attributes($col) . ' />';
     1976                        $output .= ' <col' . Intel_Df::drupal_attributes($col) . ' />';
    17821977                    }
    17831978                    $output .= " </colgroup>\n";
    17841979                }
    17851980                else {
    1786                     $output .= ' <colgroup' . Intl_Df::drupal_attributes($attributes) . " />\n";
     1981                    $output .= ' <colgroup' . Intel_Df::drupal_attributes($attributes) . " />\n";
    17871982                }
    17881983            }
     
    20522247    public static function watchdog($type, $message = '', $variables = array(), $severity = Intel_Df::WATCHDOG_NOTICE, $link = NULL) {
    20532248        //$option_log = get_option('intel_debug_log', '');
    2054         $msg = __('WATCHDOG', 'intel') . ': ' . $type . ":\n" . $message;
    2055         //self::drupal_set_message($msg);
    2056         error_log(self::t($msg, $variables));
    2057 
    2058         //$option_log .= $msg . "\n";
    2059         //update_option('intel_debug_log', $option_log);
    2060     }
     2249    static $in_error_state = FALSE;
     2250
     2251    // It is possible that the error handling will itself trigger an error. In that case, we could
     2252    // end up in an infinite loop. To avoid that, we implement a simple static semaphore.
     2253    if (!$in_error_state && function_exists('apply_filters')) {
     2254      $in_error_state = TRUE;
     2255
     2256      // The user object may not exist in all conditions, so 0 is substituted if needed.
     2257      $user_uid = get_current_user_id();
     2258
     2259      // Prepare the fields to be logged
     2260      $log_entry = [
     2261        'type' => $type,
     2262        'message' => $message,
     2263        'variables' => $variables,
     2264        'severity' => $severity,
     2265        'link' => $link,
     2266        //'user' => $user,
     2267        'uid' => $user_uid,
     2268        'request_uri' => self::request_uri(), //$base_root . request_uri(),
     2269        'referer' => isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '',
     2270        //'ip' => ip_address(),
     2271        // Request time isn't accurate for long processes, use time() instead.
     2272        'timestamp' => time(),
     2273      ];
     2274
     2275      $log_entry = apply_filters('intel_watchdog', $log_entry);
     2276
     2277      $mode = self::watchdog_mode();
     2278
     2279      if ($mode == 'db') {
     2280        $intel_log = intel_log_create($log_entry);
     2281        intel_log_save($intel_log);
     2282      }
     2283      else if ($mode == 'error_log') {
     2284        $msg = __('WATCHDOG', 'intel') . ': ' . $type . ":\n" . $message;
     2285        //self::drupal_set_message($msg);
     2286        error_log(self::t($log_entry['message'], $log_entry['variables'], ['html' => 1]));
     2287      }
     2288
     2289      // It is critical that the semaphore is only cleared here, in the parent
     2290      // watchdog() call (not outside the loop), to prevent recursive execution.
     2291      $in_error_state = FALSE;
     2292    }
     2293    }
     2294
     2295    public static function watchdog_mode() {
     2296
     2297      if (isset($intel_wp_config_options['intel_watchdog_mode'])) {
     2298      return $intel_wp_config_options['intel_watchdog_mode'];
     2299    }
     2300
     2301    if (intel()->is_network_active) {
     2302      return get_site_option('intel_watchdog_mode', '');
     2303    }
     2304
     2305    return get_option('intel_watchdog_mode', '');
     2306  }
    20612307}
    20622308
  • intelligence/trunk/includes/class-intel-form.php

    r2018028 r2947915  
    11981198                // An unchecked checkbox has a #value of integer 0, different than string
    11991199                // '0', which could be a valid value.
    1200                 $is_empty_multiple = (!count($elements['#value']));
     1200                $is_empty_multiple = (is_array($elements['#value']) && !count($elements['#value']));
    12011201                $is_empty_string = (is_string($elements['#value']) && strlen(trim($elements['#value'])) == 0);
    12021202                $is_empty_value = ($elements['#value'] === 0);
  • intelligence/trunk/includes/class-intel-tracker.php

    r1814908 r2947915  
    3636    protected $pushes;
    3737
    38     public $settings_placement = 'head';
    39 
    40     public $pageview_placement = 'head';
     38    public $settings_placement = 'footer';
     39
     40    public $pageview_placement = 'footer';
    4141
    4242    /**
     
    184184
    185185    public function enqueue_intel_scripts() {
    186         // add intel_scripts
     186        // don't add scripts if in framework mode
     187    if (intel_is_framework()) {
     188      return;
     189    }
     190    // add intel_scripts
    187191        $scripts = intel()->intel_script_info();
    188192        $enabled = get_option('intel_intel_scripts_enabled', array());
     
    198202     */
    199203    public function tracking_head($is_admin = 0) {
    200         if (!intel_is_installed('min')) {
    201             return '';
    202         }
     204    $is_framework = intel_is_framework();
     205    if (!intel_is_installed('min') && !$is_framework) {
     206      return '';
     207    }
    203208        $io_name = 'io';
    204209
     
    217222        }
    218223
    219         if ($this->pageview_placement == 'head') {
    220             $script .= "\n" . "io('pageview');";
    221         }
     224    if (!$is_framework) {
     225      if ($this->pageview_placement == 'head') {
     226        $script .= "\n" . "io('pageview');";
     227      }
     228    }
    222229
    223230        print '<script>' . $script . '</script>';
     
    231238
    232239    public function tracking_footer($is_admin = 0) {
    233         if (!intel_is_installed('min')) {
     240    $is_framework = intel_is_framework();
     241        if (!intel_is_installed('min') && !$is_framework) {
    234242            return '';
    235243        }
     
    248256        }
    249257
    250         intel_page_footer_alter();
    251 
    252         if ($this->pageview_placement != 'head') {
    253             $script .= "\n" . "io('pageview');";
    254         }
     258    //intel_page_footer_alter();
     259
     260        if (!$is_framework) {
     261      if ($this->pageview_placement != 'head') {
     262        $script .= "\n" . "io('pageview');";
     263      }
     264    }
     265
    255266        //$script .= "$io_name('set', intel_settings.intel.pushes.set);\n";
    256267        //if (!empty($js_settings['intel']['pushes']['events'])) {
     
    289300        $io_name = 'io';
    290301
     302    $is_framework = intel_is_framework();
     303
    291304        $page = array();
    292305        intel_page_alter($page);
     
    298311        $script .= "var wp_intel = wp_intel || { 'settings': {}, 'behaviors': {}, 'locale': {} };\n";
    299312        $script .= "jQuery.extend(wp_intel.settings, " . json_encode($js_settings) . ");\n";
    300         $script .= "$io_name('setConfig', wp_intel.settings.intel.config);\n";
    301         if (isset($js_settings['intel']['pushes']) && is_array($js_settings['intel']['pushes'])) {
    302             foreach ($js_settings['intel']['pushes'] as $cm => $push) {
    303                 if (0 && $cm == 'setUserId') {
    304                     $script .= $io_name . '("' . $cm . '","' . $push[0][0];
    305                     if (!empty($push[0][1])) {
    306                         $script .= '","' . $push[0][1];
    307                     }
    308                     $script .= '");' . "\n";
    309                 } else {
    310                     $script .= "$io_name('$cm', wp_intel.settings.intel.pushes['$cm']);\n";
    311                 }
    312             }
    313         }
     313        if (!$is_framework) {
     314      $script .= "$io_name('setConfig', wp_intel.settings.intel.config);\n";
     315      if (isset($js_settings['intel']['pushes']) && is_array($js_settings['intel']['pushes'])) {
     316        foreach ($js_settings['intel']['pushes'] as $cm => $push) {
     317          if (0 && $cm == 'setUserId') {
     318            $script .= $io_name . '("' . $cm . '","' . $push[0][0];
     319            if (!empty($push[0][1])) {
     320              $script .= '","' . $push[0][1];
     321            }
     322            $script .= '");' . "\n";
     323          } else {
     324            $script .= "$io_name('$cm', wp_intel.settings.intel.pushes['$cm']);\n";
     325          }
     326        }
     327      }
     328    }
     329
    314330        //$script .= "$io_name('pageview');\n";
    315331
  • intelligence/trunk/includes/class-intel-visitor-page.php

    r1653685 r2947915  
    6060
    6161        // Retrieve all profile fields and attach to $entity->content.
    62         Intel_Visitor::build_content($entity);
     62        IntelVisitor::build_content($entity);
    6363
    6464        $build = $entity->content;
  • intelligence/trunk/includes/class-intel.php

    r1904936 r2947915  
    8080    public $time_delta;
    8181
     82    public $is_network_active;
     83
     84  public $is_network_framework_mode;
     85
    8286    protected $js_inline = array();
    8387
     
    114118
    115119    public $admin_dir;
     120
     121  public $is_network_admin;
    116122
    117123    public $vtk;
     
    157163        $this->admin_url = admin_url();
    158164        $this->admin_dir = ABSPATH . 'wp-admin/';
     165
     166    if ( ! function_exists( 'is_plugin_active_for_network' ) ) {
     167      require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
     168    }
     169
     170    $this->is_network_admin = 0;
     171    $this->is_network_active = is_plugin_active_for_network('intelligence/intel.php' );
     172
     173    $this->is_network_framework_mode = FALSE;
     174    if ($this->is_network_active) {
     175      $this->is_network_framework_mode = get_site_option('intel_framework_mode', FALSE);
     176      $this->is_network_admin = is_network_admin();
     177    }
    159178
    160179        // determine admin paths
     
    284303         * Crud super class
    285304         */
    286         require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-intel-entity-controller.php';
    287         require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-intel-entity.php';
     305        //require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-intel-entity-controller.php';
     306        //require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-intel-entity.php';
     307    require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/intel.IntelEntityController.php';
     308    require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/intel.IntelEntity.php';
    288309
    289310        $this->loader = new Intel_Loader();
     
    352373        // site menu
    353374        $this->loader->add_action( 'admin_menu', $plugin_admin, 'site_menu' );
     375
     376        $this->is_network_active;
     377
     378        if ($this->is_network_active) {
     379      $this->loader->add_action( 'network_admin_menu', $plugin_admin, 'network_site_menu' );
     380    }
    354381
    355382        // column headers
     
    394421            'intel_reports' => 1,
    395422            'intel_visitor' => 1,
     423            'intel_annotation' => 1,
    396424            'intel_config' => 1,
    397425            'intel_util' => 1,
     
    507535
    508536    public function quick_session_init($options = array()) {
    509         include_once INTEL_DIR . 'includes/class-intel-visitor.php';
     537        include_once INTEL_DIR . 'includes/intel.IntelVisitor.php';
    510538
    511539        $_SESSION['intel'] = !empty($_SESSION['intel']) ? $_SESSION['intel'] : array();
    512540
    513         $this->vtk = Intel_Visitor::extractVtk();
    514 
    515         $this->gacid = Intel_Visitor::extractCid();
     541        $this->vtk = IntelVisitor::extractVtk();
     542
     543        $this->gacid = IntelVisitor::extractCid();
    516544
    517545        $this->session_hash = !empty($this->vtk) ? $this->vtk : $this->gacid;
     
    545573        $cache = isset($_SESSION['intel_quick_cache']) ? $_SESSION['intel_quick_cache'] : array();
    546574
    547         if (!empty($_SESSION['intel']) && is_array($_SESSION['intel'])) {
     575        if (!empty($_SESSION['intel_pushes']) && is_array($_SESSION['intel_pushes'])) {
    548576            if (!empty($cache)) {
    549                 $cache = Intel_Df::drupal_array_merge_deep($cache, $_SESSION['intel']);
     577                $cache = Intel_Df::drupal_array_merge_deep($cache, $_SESSION['intel_pushes']);
    550578            }
    551579            else {
    552                 $cache = $_SESSION['intel'];
     580                $cache = $_SESSION['intel_pushes'];
    553581            }
    554582        }
  • intelligence/trunk/includes/intel.demo.php

    r2018028 r2947915  
    11791179
    11801180  $account = wp_get_current_user();
     1181 
     1182  $form_id = $form_state['build_info']['form_id'];
     1183  $form_def = array(
     1184    'formType' => 'intel_form',
     1185    'formId' => $form_id,
     1186    'formTitle' => ucwords(str_replace('_', ' ', $form_id)),
     1187    'selector' => "form#{$form_id}",
     1188    'trackView' => 1,
     1189  );
     1190  intel_add_page_intel_push(array('formtracker:trackForm', $form_def));
    11811191
    11821192  $form['givenName'] = array(
  • intelligence/trunk/includes/intel.ga.php

    r2018028 r2947915  
    77 */
    88
     9/*******************************************************************************
     10 * Goal functions
     11 */
     12
     13/**
     14 * Constructs a new goal initializing properties.
     15 *
     16 * @param $goal
     17 * @param array $ga_goal
     18 *
     19 * @return array|bool
     20 */
     21function intel_goal_const($goal, $ga_goal = array()) {
     22  if (!empty($ga_goal)) {
     23    if (!isset($goal['title']) && isset($ga_goal['name'])) {
     24      $goal['title'] = $ga_goal['name'];
     25    }
     26    if (!isset($goal['ga_id']) && isset($ga_goal['id'])) {
     27      $goal['ga_id'] = $ga_goal['id'];
     28    }
     29    if (!isset($goal['type']) && isset($ga_goal['type'])) {
     30      $goal['type'] = !intel_is_intl_goal($ga_goal) ? $ga_goal['type'] : 'INTL';
     31    }
     32    if (!isset($goal['value']) && isset($ga_goal['value'])) {
     33      $goal['value'] = $ga_goal['value'];
     34    }
     35  }
     36
     37  if (empty($goal['title'])) {
     38    return FALSE;
     39  }
     40
     41  // if not ga_id set, find first available id
     42  if (empty($goal['ga_id'])) {
     43    $ga_goals = intel_ga_goal_load();
     44
     45    for ($i = 1; $i <= 20; $i++) {
     46      if (!isset($ga_goals["$i"])) {
     47        $goal['ga_id'] = "$i";
     48        break;
     49      }
     50    }
     51  }
     52
     53  if (empty($goal['ga_id'])) {
     54    return FALSE;
     55  }
     56
     57
     58  $defaults = array(
     59    'ga_id' => $goal['ga_id'],
     60    'name' => intel_format_un($goal['title']),
     61    'un' => intel_format_un($goal['title']),
     62    'title' => $goal['title'],
     63    'description' => '',
     64    'type' => 'INTEL',
     65    'value' => 100,
     66    'context' => array(
     67      'general' => 1,
     68      'submission' => 1,
     69      'phonecall' => 1,
     70    ),
     71  );
     72  // non intel goals should not have a context
     73  if (!empty($goal['type']) && $goal['type'] != 'INTL' && $goal['type'] != 'INTEL') {
     74    $defaults['context'] = array();
     75  }
     76  $goal = Intel_Df::drupal_array_merge_deep($defaults, $goal);
     77
     78  return $goal;
     79}
     80
     81/**
     82 * Saves an Intelligence goal and saves goal to GA if needed.
     83 *
     84 * For goals already in ga_goals, set the ga_id property.
     85 * To create a new Intel goal, don't set ga_id and next ga id will be used.
     86 *
     87 *
     88 * @param $goal
     89 * @param array $options
     90 * @return array|bool
     91 */
     92function intel_goal_save($goal, $options = array()) {
     93  $goals = intel_goal_load(null, array('index_by' => 'ga_id', 'force_reload' => 1));
     94  $ga_goals = intel_ga_goal_load();
     95
     96  // if goal already exists, merge in existing properties
     97  if (isset($goal['ga_id']) && isset($goals[$goal['ga_id']])) {
     98    $goal = Intel_Df::drupal_array_merge_deep($goals[$goal['ga_id']], $goal);
     99  }
     100
     101  // if ga goal exists, set ga_goal and use it to set the type if not already
     102  // set
     103  if (!empty($goal['ga_id']) && !empty($ga_goals[$goal['ga_id']])) {
     104    $ga_goal = $ga_goals[$goal['ga_id']];
     105    if (empty($goal['type']) && !empty($ga_goal['type'])) {
     106      if (intel_is_intl_goal($ga_goal)) {
     107        $goal['type'] = 'INTEL';
     108      }
     109      else {
     110        $goal['type'] = $ga_goal['type'];
     111      }
     112    }
     113    if (!isset($goal['value']) && isset($ga_goal['value'])) {
     114      $goal['value'] = $ga_goal['value'];
     115    }
     116  }
     117
     118  // fill in missing defaults
     119  $goal = intel_goal_const($goal);
     120
     121  // goal is type intel, save to ga
     122  if (!isset($goal['type']) || $goal['type'] == 'INTL' || $goal['type'] == 'INTEL' ) {
     123    // if goal type is Intel goal, save to ga goal also
     124    $ga_goal = array(
     125      'id' => $goal['ga_id'],
     126      'name' => $goal['title'],
     127      'type' => $goal['type'],
     128    );
     129    $ga_goal = intel_ga_goal_save($ga_goal);
     130  }
     131
     132  $goals[$goal['ga_id']] = $goal;
     133  update_option('intel_goals', $goals);
     134
     135  return $goal;
     136}
    9137
    10138/**
     
    71199}
    72200
    73 function intel_goal_const($goal, $ga_goal = array()) {
    74   if (!empty($ga_goal)) {
    75     if (!isset($goal['title']) && isset($ga_goal['name'])) {
    76       $goal['title'] = $ga_goal['name'];
    77     }
    78     if (!isset($goal['ga_id']) && isset($ga_goal['id'])) {
    79       $goal['ga_id'] = $ga_goal['id'];
    80     }
    81     if (!isset($goal['type']) && isset($ga_goal['type'])) {
    82       $goal['type'] = !intel_is_intl_goal($ga_goal) ? $ga_goal['type'] : 'INTL';
    83     }
    84     if (!isset($goal['value']) && isset($ga_goal['value'])) {
    85       $goal['value'] = $ga_goal['value'];
    86     }
    87   }
    88 
    89   if (empty($goal['title'])) {
    90     return FALSE;
    91   }
    92 
    93   // if not ga_id set, find first available id
    94   if (empty($goal['ga_id'])) {
    95     $ga_goals = intel_ga_goal_load();
    96 
    97     for ($i = 1; $i <= 20; $i++) {
    98       if (!isset($ga_goals["$i"])) {
    99         $goal['ga_id'] = "$i";
    100         break;
    101       }
    102     }
    103   }
    104 
    105   if (empty($goal['ga_id'])) {
    106     return FALSE;
    107   }
    108 
    109 
    110   $defaults = array(
    111     'ga_id' => $goal['ga_id'],
    112     'name' => intel_format_un($goal['title']),
    113     'un' => intel_format_un($goal['title']),
    114     'title' => $goal['title'],
    115     'description' => '',
    116     'type' => 'INTEL',
    117     'value' => 100,
    118     'context' => array(
    119       'general' => 1,
    120       'submission' => 1,
    121       'phonecall' => 1,
    122     ),
    123   );
    124   // non intel goals should not have a context
    125   if (!empty($goal['type']) && $goal['type'] != 'INTL' && $goal['type'] != 'INTEL') {
    126     $defaults['context'] = array();
    127   }
    128   $goal = Intel_Df::drupal_array_merge_deep($defaults, $goal);
    129 
    130   return $goal;
    131 }
    132 
    133 /**
    134  * Saves an Intelligence goal and saves goal to GA if needed.
    135  *
    136  * For goals already in ga_goals, set the ga_id property.
    137  * To create a new Intel goal, don't set ga_id and next ga id will be used.
    138  *
    139  *
    140  * @param $goal
    141  * @param array $options
    142  * @return array|bool
    143  */
    144 function intel_goal_save($goal, $options = array()) {
    145   $goals = intel_goal_load(null, array('index_by' => 'ga_id', 'force_reload' => 1));
    146   $ga_goals = intel_ga_goal_load();
    147 
    148   // if goal already exists, merge in existing properties
    149   if (isset($goal['ga_id']) && isset($goals[$goal['ga_id']])) {
    150     $goal = Intel_Df::drupal_array_merge_deep($goals[$goal['ga_id']], $goal);
    151   }
    152 
    153   // if ga goal exists, set ga_goal and use it to set the type if not already
    154   // set
    155   if (!empty($goal['ga_id']) && !empty($ga_goals[$goal['ga_id']])) {
    156     $ga_goal = $ga_goals[$goal['ga_id']];
    157     if (empty($goal['type']) && !empty($ga_goal['type'])) {
    158       if (intel_is_intl_goal($ga_goal)) {
    159         $goal['type'] = 'INTEL';
    160       }
    161       else {
    162         $goal['type'] = $ga_goal['type'];
    163       }
    164     }
    165     if (!isset($goal['value']) && isset($ga_goal['value'])) {
    166       $goal['value'] = $ga_goal['value'];
    167     }
    168   }
    169 
    170   // fill in missing defaults
    171   $goal = intel_goal_const($goal);
    172 
    173   // goal is type intel, save to ga
    174   if (!isset($goal['type']) || $goal['type'] == 'INTL' || $goal['type'] == 'INTEL' ) {
    175     // if goal type is Intel goal, save to ga goal also
    176     $ga_goal = array(
    177       'id' => $goal['ga_id'],
    178       'name' => $goal['title'],
    179       'type' => $goal['type'],
    180     );
    181     $ga_goal = intel_ga_goal_save($ga_goal);
    182   }
    183 
    184   $goals[$goal['ga_id']] = $goal;
    185   update_option('intel_goals', $goals);
    186 
    187   return $goal;
    188 }
    189 
    190 function intel_ga_goal_load($name = '', $options = array()) {
    191 
    192   $op_meta = get_option('intel_option_meta', array());
    193 
    194   $gapt = '';
    195   if (!empty($options['ga_profile_type']) && $options['ga_profile_type'] == 'base') {
    196     $gapt = '_base';
    197   }
    198 
    199   // refresh if goal have never been updated
    200   if (empty($op_meta['ga_goals' . $gapt . '_updated'])) {
    201     $options['refresh'] = 1;
    202   }
    203 
    204   // cache for one day unless requested
    205   if (!isset($options['refresh'])) {
    206     $options['refresh'] = 86400;
    207   }
    208 
    209   // load goals from ga
    210   if (!empty($options['refresh'])) {
    211     $time = is_numeric($options['refresh']) ? $options['refresh'] : 0;
    212     $ga_goals_updated = !empty($op_meta['ga_goals' . $gapt . '_updated']) ? $op_meta['ga_goals' . $gapt . '_updated'] : 0;
    213     if ((time() - $ga_goals_updated) > $time) {
    214 
    215       include_once INTEL_DIR . 'includes/intel.imapi.php';
    216 
    217       try {
    218         $ga_goals = intel_imapi_ga_goal_get(0, $options);
    219         update_option('intel_ga_goals' . $gapt, $ga_goals);
    220         $op_meta['ga_goals' . $gapt . '_updated'] = time();
    221         update_option('intel_option_meta', $op_meta);
    222       }
    223       catch (Exception $e) {
    224         Intel_Df::drupal_set_message($e->getMessage(), 'error');
    225         $ga_goals = array();
    226       }
    227     }
    228   }
    229 
    230   if (!isset($ga_goals)) {
    231     $ga_goals = get_option('intel_ga_goals' . $gapt, array());
    232   }
    233 
    234   if (!empty($name)) {
    235     return !empty($ga_goals[$name]) ? $ga_goals[$name] : 0;
    236   }
    237   return $ga_goals;
    238 }
     201
     202
     203
     204
     205
    239206
    240207function intel_ga_goal_const($ga_goal) {
     
    411378
    412379  return $ga_goal;
     380}
     381
     382function intel_ga_goal_load($name = '', $options = array()) {
     383
     384  $op_meta = get_option('intel_option_meta', array());
     385
     386  $gapt = '';
     387  if (!empty($options['ga_profile_type']) && $options['ga_profile_type'] == 'base') {
     388    $gapt = '_base';
     389  }
     390
     391  // refresh if goal have never been updated
     392  if (empty($op_meta['ga_goals' . $gapt . '_updated'])) {
     393    $options['refresh'] = 1;
     394  }
     395
     396  // cache for one day unless requested
     397  if (!isset($options['refresh'])) {
     398    $options['refresh'] = 86400;
     399  }
     400
     401  // load goals from ga
     402  if (!empty($options['refresh'])) {
     403    $time = is_numeric($options['refresh']) ? $options['refresh'] : 0;
     404    $ga_goals_updated = !empty($op_meta['ga_goals' . $gapt . '_updated']) ? $op_meta['ga_goals' . $gapt . '_updated'] : 0;
     405    if ((time() - $ga_goals_updated) > $time) {
     406
     407      include_once INTEL_DIR . 'includes/intel.imapi.php';
     408
     409      try {
     410        $ga_goals = intel_imapi_ga_goal_get(0, $options);
     411        update_option('intel_ga_goals' . $gapt, $ga_goals);
     412        $op_meta['ga_goals' . $gapt . '_updated'] = time();
     413        update_option('intel_option_meta', $op_meta);
     414      }
     415      catch (Exception $e) {
     416        Intel_Df::drupal_set_message($e->getMessage(), 'error');
     417        $ga_goals = array();
     418      }
     419    }
     420  }
     421
     422  if (!isset($ga_goals)) {
     423    $ga_goals = get_option('intel_ga_goals' . $gapt, array());
     424  }
     425
     426  if (!empty($name)) {
     427    return !empty($ga_goals[$name]) ? $ga_goals[$name] : 0;
     428  }
     429  return $ga_goals;
    413430}
    414431
     
    535552}
    536553
     554/**
     555 * alias of intel_is_intel_goal()
     556 * @param $ga_goal
     557 *
     558 * @return bool
     559 */
    537560function intel_is_intl_goal($ga_goal) {
     561  return intel_is_intel_goal($ga_goal);
     562}
     563
     564/**
     565 * Tests if the goal is formated as a Intel goal
     566 * @param $ga_goal
     567 *
     568 * @return bool
     569 */
     570function intel_is_intel_goal($ga_goal) {
    538571  if (!empty($ga_goal['type']) && $ga_goal['type'] == 'EVENT') {
    539572    if (!empty($ga_goal['details']['conditions'])) {
     
    567600}
    568601
    569 add_filter('intel_link_type_info', 'intel_get_link_type_info_default');
     602function intel_goal_type_titles() {
     603  return array(
     604    'INTL' => Intel_Df::t('Intelligence'),
     605    'INTEL' => Intel_Df::t('Intelligence'),
     606    'EVENT' => Intel_Df::t('Event'),
     607    'VISIT_TIME_ON_SITE' => Intel_Df::t('Duration'),
     608    'VISIT_NUM_PAGES' => Intel_Df::t('Pages/session'),
     609    'URL_DESTINATION' => Intel_Df::t('Destination'),
     610  );
     611}
     612
     613function intel_get_intel_goals_default($info = array()) {
     614
     615  $title = Intel_Df::t('General');
     616  $name = strtolower(Intel_Df::drupal_clean_machinename($title));
     617  $info[$name] = array(
     618    'title' => $title,
     619    'name' => $name,
     620    'description' => Intel_Df::t('General conversion. Use as a default goal.'),
     621    'value' => 100,
     622  );
     623
     624  $title = Intel_Df::t('Contact');
     625  $name = strtolower(Intel_Df::drupal_clean_machinename($title));
     626  $info[$name] = array(
     627    'title' => $title,
     628    'name' => $name,
     629    'description' => Intel_Df::t('General contact. Use as a default goal that creates a contact.'),
     630    'value' => 100,
     631  );
     632
     633  $title = Intel_Df::t('Sales inquiry');
     634  $name = strtolower(Intel_Df::drupal_clean_machinename($title));
     635  $info[$name] = array(
     636    'title' => $title,
     637    'name' => $name,
     638    'description' => Intel_Df::t('Request to initiate sales communication'),
     639    'value' => 200,
     640  );
     641
     642  $title = Intel_Df::t('Research request');
     643  $name = strtolower(Intel_Df::drupal_clean_machinename($title));
     644  $info[$name] = array(
     645    'title' => $title,
     646    'name' => $name,
     647    'description' => Intel_Df::t('Request to receive top of the funnel education premium offer.'),
     648    'value' => 100,
     649  );
     650
     651  $title = Intel_Df::t('Research request');
     652  $name = strtolower(Intel_Df::drupal_clean_machinename($title));
     653  $info[$name] = array(
     654    'title' => $title,
     655    'name' => $name,
     656    'description' => Intel_Df::t('Request to receive educational (ToFu) premium offer.'),
     657    'value' => 50,
     658  );
     659
     660  $title = Intel_Df::t('Consideration request');
     661  $name = strtolower(Intel_Df::drupal_clean_machinename($title));
     662  $info[$name] = array(
     663    'title' => $title,
     664    'name' => $name,
     665    'description' => Intel_Df::t('Request to receive brand building (MoFu) premium offer.'),
     666    'value' => 100,
     667  );
     668
     669  $title = Intel_Df::t('Decision request');
     670  $name = strtolower(Intel_Df::drupal_clean_machinename($title));
     671  $info[$name] = array(
     672    'title' => $title,
     673    'name' => $name,
     674    'description' => Intel_Df::t('Request to receive sales (BoFu) premium offer.'),
     675    'value' => 200,
     676  );
     677
     678  $title = Intel_Df::t('Subscribe');
     679  $name = strtolower(Intel_Df::drupal_clean_machinename($title));
     680  $info[$name] = array(
     681    'title' => $title,
     682    'name' => $name,
     683    'description' => Intel_Df::t('Request to subscribe to newsletter style updates.'),
     684    'value' => 100,
     685  );
     686
     687  $title = Intel_Df::t('Job application');
     688  $name = strtolower(Intel_Df::drupal_clean_machinename($title));
     689  $info[$name] = array(
     690    'title' => $title,
     691    'name' => $name,
     692    'description' => Intel_Df::t('Job posting submission.'),
     693    'value' => 100,
     694  );
     695
     696  return $info;
     697}
     698
     699function intel_get_submission_goals_default() {
     700  $defs = array();
     701  $defs['tofu-conversion'] = array(
     702    'title' => Intel_Df::t('ToFu conversion'),
     703    'description' => Intel_Df::t('Top of the funnel conversion'),
     704    'value' => 15,
     705    'ga_id' => 1,
     706  );
     707  $defs['mofu-conversion'] = array(
     708    'title' => Intel_Df::t('MoFu conversion'),
     709    'description' => Intel_Df::t('Middle of the funnel conversion'),
     710    'value' => 50,
     711    'ga_id' => 2,
     712  );
     713  $defs['bofu-conversion'] = array(
     714    'title' => Intel_Df::t('BoFu conversion'),
     715    'description' => Intel_Df::t('Bottom of the funnel conversion'),
     716    'value' => 100,
     717    'ga_id' => 3,
     718  );
     719  $defs['subscribe-form'] = array(
     720    'title' => Intel_Df::t('Subscribe form'),
     721    'description' => Intel_Df::t('Subscribe to email updates form submission'),
     722    'value' => 25,
     723    'ga_id' => 4,
     724  );
     725  $defs['contact-form'] = array(
     726    'title' => Intel_Df::t('Contact form'),
     727    'description' => Intel_Df::t('Main contact form submission'),
     728    'value' => 25,
     729    'ga_id' => 5,
     730  );
     731
     732  return $defs;
     733}
     734
     735function intel_get_phonecall_goals_default() {
     736  $defs = array();
     737  $defs['contact-call'] = array(
     738    'title' => Intel_Df::t('Contact call'),
     739    'description' => Intel_Df::t('Main contact number called'),
     740    'value' => 25,
     741    'ga_id' => 6,
     742  );
     743
     744  return $defs;
     745}
     746
     747
     748/*******************************************************************************
     749 * Intel Event functions
     750 */
     751
     752/**
     753 * Returns intel_event info.
     754 * @param null $name: if null returns all intel_events, or if name given returns
     755 *   specific intel_event
     756 * @param array $options
     757 *
     758 * @return array|bool|mixed|void
     759 */
     760function intel_get_intel_event_info($name = NULL, $options = array()) {
     761  $events = &Intel_Df::drupal_static( __FUNCTION__ );
     762
     763  if (is_array($events) && count($events)) {
     764    if (isset($name)) {
     765      if (isset($events[$name])) {
     766        return $events[$name];
     767      }
     768    }
     769    else {
     770      return $events;
     771    }
     772  }
     773  //$events = intel_get_intel_event_info_default();
     774  $events = array();
     775  // get event info provided by hook_intel_intel_event_info;
     776  $events = apply_filters('intel_intel_event_info', $events);
     777
     778  $events = array_merge($events, intel_get_event_goal_info());
     779  $goal_info = get_option('intel_goals', array());
     780
     781  foreach ($events AS $k => $v) {
     782    if (isset($v['static_options'])) {
     783      $events[$k]['options'] = $v['static_options'];
     784    }
     785
     786    if (!empty($v['valued_event']) && empty($v['ga_id'])) {
     787      $events[$k]['mode'] = $v['mode'] = 'valued';
     788    }
     789    if (!empty($v['mode'])) {
     790      if ($v['mode'] == 'valued') {
     791        $events[$k]['valued_event'] = 1;
     792      }
     793    }
     794    else {
     795      $events[$k]['mode'] = '';
     796    }
     797
     798    // construct eventCategory
     799    if (empty($v['event_category'])) {
     800      $events[$k]['event_category'] = intel_format_intel_event_eventcategory($v, $goal_info);
     801    }
     802
     803    if (empty($events[$k]['plugin_un'])) {
     804      $events[$k]['plugin_un'] = 'intel';
     805    }
     806    $events[$k]['key']  = $k;
     807  }
     808
     809  $custom = get_option('intel_intel_events_custom', array());
     810  foreach ($custom AS $k => $v) {
     811    // check if custom attribute
     812    if (isset($events[$k])) {
     813      $events[$k] = Intel_Df::drupal_array_merge_deep($events[$k], $v);
     814      // rebuild event_category incase changed by custom settings
     815      unset($events[$k]['event_category']);
     816      $events[$k]['event_category'] = intel_format_intel_event_eventcategory($events[$k], $goal_info);
     817      $events[$k]['overridden'] = 1;
     818      if (isset($events[$k]['partial'])) {
     819        unset($events[$k]['partial']);
     820      }
     821    }
     822    else {
     823      // if settings are a partial event, i.e. overrides of a coded event,
     824      // events[$k] should exists. If it doesn't, for example when the plugin
     825      // providing the original event is disabled, skip adding it
     826      if (!empty($v['partial'])) {
     827        continue;
     828      }
     829      if (empty($custom[$k]['plugin_un'])) {
     830        $custom[$k]['plugin_un'] = 'intel';
     831      }
     832      $custom[$k]['custom'] = 1;
     833      $events[$k] = $custom[$k];
     834      if (empty($v['event_category'])) {
     835        $events[$k]['event_category'] = intel_format_intel_event_eventcategory($v, $goal_info);
     836      }
     837    }
     838    if (!empty($custom[$k]['custom_options'])) {
     839      //sdm($custom[$k]['custom_options']);
     840      if (!isset($events[$k]['options'])) {
     841        $events[$k]['options'] = $custom[$k]['custom_options'];
     842      }
     843      else {
     844        $events[$k]['options'] += $custom[$k]['custom_options'];
     845      }
     846    }
     847    $events[$k]['key']  = $k;
     848  }
     849
     850  /* TODO WP
     851  foreach (module_implements('intel_intel_event_info') AS $module) {
     852    $function = $module . '_intel_intel_event_info';
     853    $a = $function();
     854    if (empty($a) || !is_array($a)) {
     855      continue;
     856    }
     857    foreach ($a AS $k => $v) {
     858      $v['module'] = $module;
     859      $v['key']  = $k;
     860      $events[$k] = $v;
     861    }
     862  }
     863
     864  drupal_alter('intel_intel_event_info', $events);
     865  END TODO WP */
     866
     867  // allow plugins to alter events
     868  $events = apply_filters('intel_intel_event_info_alter', $events);
     869
     870  uasort($events, '_intel_sort_by_eventcategory');
     871
     872  // allow plugins to alter theme_info
     873
     874  if (isset($name)) {
     875    if (isset($events[$name])) {
     876      return $events[$name];
     877    }
     878    else {
     879      return FALSE;
     880    }
     881  }
     882  else {
     883    return $events;
     884  }
     885}
     886
     887/**
     888 * Implements hook_intel_link_type_info()
     889 */
     890function intel_intel_link_type_info($info = array()) {
     891  $info = intel_get_link_type_info_default($info);
     892  return $info;
     893}
     894add_filter('intel_link_type_info', 'intel_intel_link_type_info');
     895
    570896function intel_get_link_type_info_default($info = array()) {
    571897  $info['mailto'] = array(
     
    580906    'title' => Intel_Df::t('Download link'),
    581907    'track' => 1,
     908    'track_file_extension' => intel_get_link_type_download_track_file_extensions_default(),
    582909  );
    583910  $info['external'] = array(
     
    616943          }
    617944        }
    618 
    619 
     945        if ($event['key'] == 'linktracker_download_click') {
     946          $link_type[$k]['track_file_extension'] = !empty($event['track_file_extension']) ? $event['track_file_extension'] : intel_get_link_type_download_track_file_extensions_default();
     947        }
    620948      }
    621949    }
     
    638966
    639967/**
     968 * Implements hook_intel_intel_event_info()
     969 */
     970function intel_intel_intel_event_info($event = array()) {
     971  $info = intel_get_intel_event_info_default($event);
     972  return $info;
     973}
     974add_filter('intel_intel_event_info', 'intel_intel_intel_event_info');
     975
     976/**
    640977 * types = flag, list, scalar, vector
    641978 */
    642 add_filter('intel_intel_event_info', 'intel_get_intel_event_info_default');
     979//add_filter('intel_intel_event_info', 'intel_get_intel_event_info_default');
    643980function intel_get_intel_event_info_default($event = array()) {
    644981  $scripts_enabled = get_option('intel_intel_scripts_enabled', array());
     
    7551092  }
    7561093
    757 
    758   if (intel_is_extended()) {
    759     $event['landing_page_view'] = array(
     1094  if (intel_is_intel_script_enabled('lptracker')) {
     1095    $event['landing_page_view'] = [
    7601096      'title' => Intel_Df::t('Landing page view'),
    7611097      'description' => Intel_Df::t('Landing page pageview'),
    7621098      //'event' => 'pageshow',
    763     );
    764     $event['landing_page_conversion'] = array(
     1099    ];
     1100    $event['landing_page_conversion'] = [
    7651101      'title' => Intel_Df::t('Landing page conversion'),
    7661102      'description' => Intel_Df::t('Form submission from a landing page'),
    7671103      'valued_event' => 1,
    7681104      'value' => 0,
    769     );
     1105    ];
     1106  }
     1107
     1108  if (intel_is_intel_script_enabled('ctatracker')) {
    7701109    $event['cta_view'] = array(
    771       'title' => Intel_Df::t('CTA view'),
    772       'description' => Intel_Df::t('Call to action impression'),
     1110      'title' => t('CTA view'),
     1111      'description' => t('Call to action impression'),
    7731112    );
    7741113    $event['cta_click'] = array(
     
    7851124    );
    7861125  }
    787 
    788   /*
    789   $event['cta_click'] = array(
    790     'title' => Intel_Df::t('CTA click'),
    791     'description' => Intel_Df::t('Call to action is clicked'),
    792     'mode' => 'valued',
    793     //'valued_event' => 1,
    794     'value' => 0,
    795     'selector' => '.track-cta-click',
    796     'on_event' => 'click',
    797     'enable_all_pages' => 1,
    798     'js_settings' => 1,
    799   );
    800   */
    8011126
    8021127  if (intel_is_intel_script_enabled('linktracker')) {
     
    13731698}
    13741699
    1375 function intel_get_intel_event_info($name = NULL, $options = array()) {
    1376   $events = &Intel_Df::drupal_static( __FUNCTION__ );
    1377 
    1378   if (is_array($events) && count($events)) {
    1379     if (isset($name)) {
    1380       if (isset($events[$name])) {
    1381         return $events[$name];
    1382       }
    1383     }
    1384     else {
    1385       return $events;
    1386     }
    1387   }
    1388   //$events = intel_get_intel_event_info_default();
    1389   $events = array();
    1390   // get event info provided by hook_intel_intel_event_info;
    1391   $events = apply_filters('intel_intel_event_info', $events);
    1392 
    1393   $events = array_merge($events, intel_get_event_goal_info());
    1394   $goal_info = get_option('intel_goals', array());
    1395 
    1396   foreach ($events AS $k => $v) {
    1397     if (isset($v['static_options'])) {
    1398       $events[$k]['options'] = $v['static_options'];
    1399     }
    1400 
    1401     if (!empty($v['valued_event']) && empty($v['ga_id'])) {
    1402       $events[$k]['mode'] = $v['mode'] = 'valued';
    1403     }
    1404     if (!empty($v['mode'])) {
    1405       if ($v['mode'] == 'valued') {
    1406         $events[$k]['valued_event'] = 1;
    1407       }
    1408     }
    1409     else {
    1410       $events[$k]['mode'] = '';
    1411     }
    1412 
    1413     // construct eventCategory
    1414     if (empty($v['event_category'])) {
    1415       $events[$k]['event_category'] = intel_format_intel_event_eventcategory($v, $goal_info);
    1416     }
    1417 
    1418     if (empty($events[$k]['plugin_un'])) {
    1419       $events[$k]['plugin_un'] = 'intel';
    1420     }
    1421     $events[$k]['key']  = $k;
    1422   }
    1423 
    1424   $custom = get_option('intel_intel_events_custom', array());
    1425   foreach ($custom AS $k => $v) {
    1426     // check if custom attribute
    1427     if (isset($events[$k])) {
    1428       $events[$k] = Intel_Df::drupal_array_merge_deep($events[$k], $v);
    1429       // rebuild event_category incase changed by custom settings
    1430       unset($events[$k]['event_category']);
    1431       $events[$k]['event_category'] = intel_format_intel_event_eventcategory($events[$k], $goal_info);
    1432       $events[$k]['overridden'] = 1;
    1433       if (isset($events[$k]['partial'])) {
    1434         unset($events[$k]['partial']);
    1435       }
    1436     }
    1437     else {
    1438       // if settings are a partial event, i.e. overrides of a coded event,
    1439       // events[$k] should exists. If it doesn't, for example when the plugin
    1440       // providing the original event is disabled, skip adding it
    1441       if (!empty($v['partial'])) {
    1442         continue;
    1443       }
    1444       if (empty($custom[$k]['plugin_un'])) {
    1445         $custom[$k]['plugin_un'] = 'intel';
    1446       }
    1447       $custom[$k]['custom'] = 1;
    1448       $events[$k] = $custom[$k];
    1449       if (empty($v['event_category'])) {
    1450         $events[$k]['event_category'] = intel_format_intel_event_eventcategory($v, $goal_info);
    1451       }
    1452     }
    1453     if (!empty($custom[$k]['custom_options'])) {
    1454 //sdm($custom[$k]['custom_options']);
    1455       if (!isset($events[$k]['options'])) {
    1456         $events[$k]['options'] = $custom[$k]['custom_options'];
    1457       }
    1458       else {
    1459         $events[$k]['options'] += $custom[$k]['custom_options'];
    1460       }
    1461     }
    1462     $events[$k]['key']  = $k;
    1463   }
    1464 
    1465   /* TODO WP
    1466   foreach (module_implements('intel_intel_event_info') AS $module) {
    1467     $function = $module . '_intel_intel_event_info';
    1468     $a = $function();
    1469     if (empty($a) || !is_array($a)) {
    1470       continue;
    1471     }
    1472     foreach ($a AS $k => $v) {
    1473       $v['module'] = $module;
    1474       $v['key']  = $k;
    1475       $events[$k] = $v;
    1476     }
    1477   }
    1478 
    1479   drupal_alter('intel_intel_event_info', $events);
    1480   END TODO WP */
    1481 
    1482   // allow plugins to alter events
    1483   $events = apply_filters('intel_intel_event_info_alter', $events);
    1484 
    1485   uasort($events, '_intel_sort_by_eventcategory');
    1486 
    1487   // allow plugins to alter theme_info
    1488 
    1489   if (isset($name)) {
    1490     if (isset($events[$name])) {
    1491       return $events[$name];
    1492     }
    1493     else {
    1494       return FALSE;
    1495     }
    1496   }
    1497   else {
    1498     return $events;
    1499   }
    1500 }
     1700
    15011701
    15021702/**
     
    16361836    $to_match[] = substr($alias, 0, -1);
    16371837  }
    1638 
     1838//Intel_df::watchdog('enabled_intel_events', 'to_match', $to_match);
    16391839  foreach ($e AS $key => $event) {
    16401840    if (!empty($event['enable_all_pages'])) {
     
    16661866  return $events;
    16671867}
     1868
     1869function intel_get_link_type_download_track_file_extensions_default() {
     1870  return "7z|aac|arc|arj|asf|asx|avi|bin|csv|doc(x|m)?|dot(x|m)?|exe|flv|gif|gz|gzip|hqx|jar|jpe?g|js|mp(2|3|4|e?g)|mov(ie)?|msi|msp|pdf|phps|png|ppt(x|m)?|pot(x|m)?|pps(x|m)?|ppam|sld(x|m)?|thmx|qtm?|ra(m|r)?|sea|sit|tar|tgz|torrent|txt|wav|wma|wmv|wpd|xls(x|m|b)?|xlt(x|m)|xlam|xml|z|zip";
     1871}
     1872
     1873function intel_form_intel_admin_intel_event_form_alter(&$form, &$form_state) {
     1874
     1875  $event = $form['#intel_event'];
     1876
     1877  // if linktracker_download_click add field to provide file extensions
     1878  if ($event['key'] == 'linktracker_download_click') {
     1879    $default = intel_get_link_type_download_track_file_extensions_default();
     1880    $key = 'track_file_extension';
     1881    $form['trigger'][$key] = array(
     1882      '#type' => 'textfield',
     1883      '#title' => Intel_Df::t('Track file extensions'),
     1884      '#default_value' => !empty($event[$key]) ? $event[$key] : $default,
     1885      '#description' => Intel_Df::t("A file extension list separated by the | character that will be tracked as download when clicked. Regular expressions are supported. For example: %default", array('%default' => $default)),
     1886      '#maxlength' => 500,
     1887    );
     1888    $form_state['intel_overridable'][$key] = 1;
     1889  }
     1890}
     1891add_filter('intel_form_intel_admin_intel_event_form_alter', 'intel_form_intel_admin_intel_event_form_alter', 10, 2);
     1892
     1893/*******************************************************************************
     1894 * Page and Visitor attribute functions
     1895 */
    16681896
    16691897/**
     
    33233551}
    33243552
    3325 function intel_get_intel_goals_default($info = array()) {
    3326 
    3327   $title = Intel_Df::t('General');
    3328   $name = strtolower(Intel_Df::drupal_clean_machinename($title));
    3329   $info[$name] = array(
    3330     'title' => $title,
    3331     'name' => $name,
    3332     'description' => Intel_Df::t('General conversion. Use as a default goal.'),
    3333     'value' => 100,
    3334   );
    3335 
    3336   $title = Intel_Df::t('Contact');
    3337   $name = strtolower(Intel_Df::drupal_clean_machinename($title));
    3338   $info[$name] = array(
    3339     'title' => $title,
    3340     'name' => $name,
    3341     'description' => Intel_Df::t('General contact. Use as a default goal that creates a contact.'),
    3342     'value' => 100,
    3343   );
    3344 
    3345   $title = Intel_Df::t('Sales inquiry');
    3346   $name = strtolower(Intel_Df::drupal_clean_machinename($title));
    3347   $info[$name] = array(
    3348     'title' => $title,
    3349     'name' => $name,
    3350     'description' => Intel_Df::t('Request to initiate sales communication'),
    3351     'value' => 200,
    3352   );
    3353 
    3354   $title = Intel_Df::t('Research request');
    3355   $name = strtolower(Intel_Df::drupal_clean_machinename($title));
    3356   $info[$name] = array(
    3357     'title' => $title,
    3358     'name' => $name,
    3359     'description' => Intel_Df::t('Request to receive top of the funnel education premium offer.'),
    3360     'value' => 100,
    3361   );
    3362 
    3363   $title = Intel_Df::t('Research request');
    3364   $name = strtolower(Intel_Df::drupal_clean_machinename($title));
    3365   $info[$name] = array(
    3366     'title' => $title,
    3367     'name' => $name,
    3368     'description' => Intel_Df::t('Request to receive educational (ToFu) premium offer.'),
    3369     'value' => 50,
    3370   );
    3371 
    3372   $title = Intel_Df::t('Consideration request');
    3373   $name = strtolower(Intel_Df::drupal_clean_machinename($title));
    3374   $info[$name] = array(
    3375     'title' => $title,
    3376     'name' => $name,
    3377     'description' => Intel_Df::t('Request to receive brand building (MoFu) premium offer.'),
    3378     'value' => 100,
    3379   );
    3380 
    3381   $title = Intel_Df::t('Decision request');
    3382   $name = strtolower(Intel_Df::drupal_clean_machinename($title));
    3383   $info[$name] = array(
    3384     'title' => $title,
    3385     'name' => $name,
    3386     'description' => Intel_Df::t('Request to receive sales (BoFu) premium offer.'),
    3387     'value' => 200,
    3388   );
    3389 
    3390   $title = Intel_Df::t('Subscribe');
    3391   $name = strtolower(Intel_Df::drupal_clean_machinename($title));
    3392   $info[$name] = array(
    3393     'title' => $title,
    3394     'name' => $name,
    3395     'description' => Intel_Df::t('Request to subscribe to newsletter style updates.'),
    3396     'value' => 100,
    3397   );
    3398 
    3399   $title = Intel_Df::t('Job application');
    3400   $name = strtolower(Intel_Df::drupal_clean_machinename($title));
    3401   $info[$name] = array(
    3402     'title' => $title,
    3403     'name' => $name,
    3404     'description' => Intel_Df::t('Job posting submission.'),
    3405     'value' => 100,
    3406   );
    3407 
    3408   return $info;
    3409 }
    3410 
    3411 function intel_get_submission_goals_default() {
    3412   $defs = array();
    3413   $defs['tofu-conversion'] = array(
    3414     'title' => Intel_Df::t('ToFu conversion'),
    3415     'description' => Intel_Df::t('Top of the funnel conversion'),
    3416     'value' => 15,
    3417     'ga_id' => 1,
    3418   );
    3419   $defs['mofu-conversion'] = array(
    3420     'title' => Intel_Df::t('MoFu conversion'),
    3421     'description' => Intel_Df::t('Middle of the funnel conversion'),
    3422     'value' => 50,
    3423     'ga_id' => 2,
    3424   );
    3425   $defs['bofu-conversion'] = array(
    3426     'title' => Intel_Df::t('BoFu conversion'),
    3427     'description' => Intel_Df::t('Bottom of the funnel conversion'),
    3428     'value' => 100,
    3429     'ga_id' => 3,
    3430   );
    3431   $defs['subscribe-form'] = array(
    3432     'title' => Intel_Df::t('Subscribe form'),
    3433     'description' => Intel_Df::t('Subscribe to email updates form submission'),
    3434     'value' => 25,
    3435     'ga_id' => 4,
    3436   );
    3437   $defs['contact-form'] = array(
    3438     'title' => Intel_Df::t('Contact form'),
    3439     'description' => Intel_Df::t('Main contact form submission'),
    3440     'value' => 25,
    3441     'ga_id' => 5,
    3442   );
    3443 
    3444   return $defs;
    3445 }
    3446 
    3447 function intel_get_phonecall_goals_default() {
    3448   $defs = array();
    3449   $defs['contact-call'] = array(
    3450     'title' => Intel_Df::t('Contact call'),
    3451     'description' => Intel_Df::t('Main contact number called'),
    3452     'value' => 25,
    3453     'ga_id' => 6,
    3454   );
    3455 
    3456   return $defs;
    3457 }
     3553
    34583554
    34593555function intel_event_value_format($value, $options = array()) {
     
    34913587      //continue;
    34923588    }
    3493     $scorings[$filter][$i] = isset($custom[$i]) ? $custom[$i] : $m['value'];
     3589    $scorings[$filter][$i] = (float) (isset($custom[$i]) ? $custom[$i] : $m['value']);
    34943590  }
    34953591
     
    35213617    }
    35223618  }
    3523 
    3524   //$goals = intel_goal_load();
    3525   //$goals = array_merge($goals, get_option('intel_submission_goals', intel_get_submission_goals_default()));
    3526   //$goals = array_merge($goals, get_option('intel_phonecall_goals', intel_get_phonecall_goals_default()));
    3527 
    35283619
    35293620  return $scorings[$filter];
     
    37623853      'goals' => 0,
    37633854      'traffic' => 0,
     3855      'attraction' => 0,
     3856      'engagement' => 0,
     3857      'conversion' => 0,
    37643858    ),
    37653859    // stats for values generated directly by the item on non
     
    37693863      'goals' => 0,
    37703864      'traffic' => 0,
     3865      'attraction' => 0,
     3866      'engagement' => 0,
     3867      'conversion' => 0,
    37713868    ),
    37723869    // stats for values generated during sessions where the item is the entrance
     
    37763873      'goals' => 0,
    37773874      'traffic' => 0,
     3875      'attraction' => 0,
     3876      'engagement' => 0,
     3877      'conversion' => 0,
    37783878    ),
    37793879    // stats generated downstream from page hit
     
    37833883      'goals' => 0,
    37843884      'traffic' => 0,
     3885      'attraction' => 0,
     3886      'engagement' => 0,
     3887      'conversion' => 0,
    37853888    ),
    37863889  );
     
    38263929    // on this page or segement but not directly by the page
    38273930    $scores['entrance']['goals'] += $entrance['goalValueAll'];
     3931    $scores['entrance']['conversion'] += $entrance['goalValueAll'];
    38283932
    38293933    // the value of any valued events generated on any page in sessions started
     
    38313935    if (isset($entrance['events']['_totals'])) {
    38323936      $scores['entrance']['events'] += $entrance['events']['_totals']['value'];
     3937      $scores['entrance']['engagement'] += $entrance['events']['_totals']['value'];
    38333938    }
    38343939    elseif (isset($entrance['events']['_all'])) {
    38353940      $scores['entrance']['events'] += $entrance['events']['_all']['value'];
     3941      $scores['entrance']['engagement'] += $entrance['events']['_all']['value'];
    38363942    }
    38373943    // traffic scoring based on traffic generated by this page or segement
    38383944    $scores['entrance']['traffic'] += $entrance['entrances'] * $scoring['entrance'];
     3945    $scores['entrance']['attraction'] += $entrance['entrances'] * $scoring['entrance'];
    38393946    //$scores['_all']['traffic'] += $entrance['entrances'] * $scoring['entrance'];
    38403947    if (!empty($entrance['sticks'])) {
    38413948      $scores['entrance']['traffic'] += $entrance['sticks'] * $scoring['stick'];
     3949      $scores['entrance']['engagement'] += $entrance['sticks'] * $scoring['stick'];
    38423950      // when using Session stick events, stick numbers should be removed from events
    38433951      //$scores['entrance']['events'] -= $entrance['sticks'] * $scoring['stick'];
     
    38453953    if ($entrance['pageviews'] > 2) {
    38463954      $scores['entrance']['traffic'] += ($entrance['pageviews'] - $entrance['entrances'] - $entrance['sticks']) * $scoring['additional_pages'];
     3955      $scores['entrance']['engagement'] += ($entrance['pageviews'] - $entrance['entrances'] - $entrance['sticks']) * $scoring['additional_pages'];
    38473956    }
    38483957  }
     
    38543963  if (!empty($page['goalValueAll'])) {
    38553964    $scores['onpage']['goals'] += $page['goalValueAll'];
     3965    $scores['onpage']['conversion'] += $page['goalValueAll'];
    38563966  }
    38573967
     
    38593969  if (!empty($page['pageValueAll'])) {
    38603970    $scores['assist']['goals'] += ($page['pageValueAll'] - $page['goalValueAll']);
     3971    $scores['assist']['conversion'] += ($page['pageValueAll'] - $page['goalValueAll']);
    38613972  }
    38623973
     
    38643975  if (isset($page['events']['_totals'])) {
    38653976    $scores['onpage']['events'] += $page['events']['_totals']['value'];
     3977    $scores['onpage']['engagement'] += $page['events']['_totals']['value'];
    38663978  }
    38673979  elseif (isset($page['events']['_all'])) {
    38683980    $scores['onpage']['events'] += $page['events']['_all']['value'];
     3981    $scores['onpage']['engagement'] += $page['events']['_all']['value'];
    38693982  }
    38703983
     
    38984011    //$scores['_all']['traffic'] = $scores['entrance']['traffic'] + $scores['onpage']['traffic'];
    38994012    $scores['_all']['traffic'] = $scores['entrance']['traffic'];
     4013    $scores['_all']['conversion'] = $scores['onpage']['conversion'];
     4014    $scores['_all']['engagement'] = $scores['onpage']['engagement'];
     4015    $scores['_all']['attraction'] = $scores['entrance']['attraction'];
    39004016  }
    39014017  else {
     
    39044020    $scores['_all']['events'] = $scores['entrance']['events'];
    39054021    $scores['_all']['traffic'] = $scores['entrance']['traffic'];
     4022    $scores['_all']['conversion'] = $scores['entrance']['conversion'];
     4023    $scores['_all']['engagement'] = $scores['entrance']['engagement'];
     4024    $scores['_all']['attraction'] = $scores['entrance']['attraction'];
    39064025  }
    39074026
     
    40474166  }
    40484167
    4049   return _intel_get_report_dates($start, $end);
     4168  return _intel_get_report_dates($start, $end, $return_hash);
    40504169}
    40514170
    40524171function _intel_get_report_dates($start_default = "-31 days", $end_default = "-1 day", $return_hash = FALSE) {
    4053   $timezone_info = &Intel_Df::drupal_static( __FUNCTION__, array());
    4054   if (empty($timezone_info)) {
    4055     $timezone_info['wp_timezone'] = get_option('timezone_string', '');
    4056     $ga_profile = get_option('intel_ga_profile', array());
    4057     $timezone_info['ga_timezone'] = !empty($ga_profile['timezone']) ? $ga_profile['timezone'] : '';
    4058     if (0 && !empty($timezone_info['wp_timezone'])) {
    4059       $timezone_info['timezone'] = $timezone_info['wp_timezone'];
    4060     }
    4061     elseif (!empty($timezone_info['ga_timezone'])) {
    4062       $timezone_info['timezone'] = $timezone_info['ga_timezone'];
    4063     }
    4064     else {
    4065       $timezone_info['timezone'] = 'UTC';
    4066     }
    4067 
    4068   }
    4069   $timezone = $timezone_info['timezone'];
     4172
     4173  $timezone_info = intel_get_timezone_info();
     4174
    40704175  if (!empty($_GET['dates'])) {
    40714176    $a = explode(":", $_GET['dates']);
     
    40764181  $end = (!empty($_GET['end_date'])) ? $_GET['end_date'] : $end_default;
    40774182
    4078   // do this to correct for CMS timezone.
    4079   $timezone_obj = new DateTimeZone($timezone);
    4080   $start_date_obj = new DateTime($start, $timezone_obj);
    4081   $start_date = $start_date_obj->format('U');
    4082   $end_date_obj = new DateTime($end, $timezone_obj);
    4083   $end_date = $end_date_obj->format('U');
    4084 
    4085   $offset = $timezone_obj->getOffset($end_date_obj);
    4086 
    4087   //intel_d($offset);
    4088 
    4089   //intel_d(date('Y-m-d G:i', $end_date_strtotime) . " {$end_date_strtotime}");
    4090   //intel_d(date('Y-m-d G:i', $start_date) . " {$start_date}");
    4091   //intel_d(date('Y-m-d G:i', $end_date) . " {$end_date}");
    4092 
    4093 
    4094   //intel_d(Intel_Df::format_date($end_date_strtotime, 'Y-m-d G:i') . " {$end_date_strtotime}");
    4095   //intel_d(Intel_Df::format_date($end_date, 'Y-m-d G:i') . " {$end_date}");
    4096 
    4097   $start_date_local = $start_date + $offset;
    4098   $end_date_local = $end_date + $offset;
    4099 
    4100   //intel_d(date('Y-m-d G:i', $start_date_local) . " {$start_date_local}");
    4101   //intel_d(date('Y-m-d G:i', $end_date_local) . " {$end_date_local}");
    4102   //intel_d(Intel_Df::format_date($end_date_local, 'Y-m-d G:i') . " {$end_date_local}");
    4103 
    4104   //$start_date = (!empty($_GET['start_date'])) ? strtotime($_GET['start_date']) : strtotime($start_default);
    4105   //$end_date = (!empty($_GET['end_date'])) ? strtotime($_GET['end_date']) : strtotime($end_default);
     4183  $start_date = strtotime($start);
     4184  $end_date = strtotime($end);
     4185
     4186  $ga_start_date = $start_date + $timezone_info['ga_offset'];
     4187  $ga_end_date = $end_date + $timezone_info['ga_offset'];
     4188
    41064189  $number_of_days = ceil(($end_date - $start_date)/60/60/24);
    41074190  if (!$return_hash) {
    41084191    return array(
    4109       $start_date_local,
    4110       $end_date_local,
     4192      $ga_start_date,
     4193      $ga_end_date,
    41114194      $number_of_days,
    4112       $offset,
    4113     );
    4114     return array(
    4115       $start_date,
    4116       $end_date,
    4117       $number_of_days,
    4118       $start_date_local,
    4119       $end_date_local,
     4195      $timezone_info['ga_offset'],
    41204196    );
    41214197  }
     
    41244200      'start_date' => $start_date,
    41254201      'end_date' => $end_date,
     4202      'ga_start_date' => $ga_start_date,
     4203      'ga_end_date' => $ga_end_date,
    41264204      'number_of_days' => $number_of_days,
    4127       'timezone_offset' => $offset,
     4205      'number_of_seconds' => $end_date - $start_date,
     4206      'timezone_info' => $timezone_info,
    41284207    );
    41294208  }
     
    47254804  );
    47264805
    4727   list($start_date, $end_date, $number_of_days) = _intel_get_report_dates("-1 year", "Today");
     4806  list($start_date, $end_date, $number_of_days) = _intel_get_report_dates("-1 year", "Today 23:59");
    47284807  $cache = array(
    47294808    'refresh' => 1,
     
    47384817    'segment' => 'sessions::condition::ga:dimension5==' . implode(',ga:dimension5==', $vtkids),
    47394818  );
     4819
    47404820  $visits = intel_fetch_analytics_visits($options);
    47414821
     
    48444924
    48454925    $data = intel_ga_api_data($request, $cache_options);
    4846     //dsm($request); dsm($data);
     4926
    48474927    $rows = intel_get_ga_feed_rows($data);
    48484928    if (!empty($rows) && is_array($rows)) {
     
    54735553
    54745554  return $ga_goals;
    5475 }
    5476 
    5477 function intel_goal_type_titles() {
    5478   return array(
    5479     'INTL' => Intel_Df::t('Intelligence'),
    5480     'INTEL' => Intel_Df::t('Intelligence'),
    5481     'EVENT' => Intel_Df::t('Event'),
    5482     'VISIT_TIME_ON_SITE' => Intel_Df::t('Duration'),
    5483     'VISIT_NUM_PAGES' => Intel_Df::t('Pages/session'),
    5484     'URL_DESTINATION' => Intel_Df::t('Destination'),
    5485   );
    54865555}
    54875556
  • intelligence/trunk/includes/intel.imapi.php

    r1904936 r2947915  
    5252  $api_params = get_option('intel_imapi_custom_params', array());
    5353  $apiClientProps = array(
    54     'apiUrl' => intel_get_imapi_url() . '/',
     54    'apiUrl' => (!empty($options['api_url']) ? $options['api_url'] : intel_get_imapi_url()) . '/',
    5555    'urlrewrite' => 1,
    5656    //'apiConnector' => get_option('intel_l10iapi_connector', ''),
     
    6363}
    6464
     65function intel_imapi_do_reauth() {
     66
     67}
     68
    6569function intel_imapi_property_get($options = array()) {
    6670  $vars = array();
  • intelligence/trunk/includes/intel.page_alter.php

    r2018028 r2947915  
    88
    99function intel_page_alter(&$page) {
    10   require_once INTEL_DIR . "includes/intel.ga.php";
    11   $user = wp_get_current_user();
     10
     11  intel_load_include('includes/intel.ga');
     12
     13  $user = intel_get_current_user();
     14
     15  $uid = intel_get_user_id($user);
    1216
    1317  $q = isset($_GET['q']) ? $_GET['q'] : '';
     
    2731    'debug' => intel_debug_mode(),
    2832    // cmsHostpath, modulePath & apiPath are not standard io settings. They are used
    29     // exclusivly by intel module js.
     33    // exclusively by intel module js.
    3034    'cmsHostpath' => $parsed_url['hostpath'],
    3135    'modulePath' => $modulePath,
     36    // path to intel library files
    3237    'libPath' => $modulePath . '/vendor/levelten/intel',
    33     //'cms_hostpath' => $parsed_url['hostpath'],
    34     //'module_path' => drupal_get_path('module', 'intel'),
    3538    'systemPath' => $q,
    3639    'systemHost' => $parsed_url['host'],
    3740    'systemBasepath' => $parsed_url['base_path'],
    3841    'srl' => $q,
    39     //'lib_path' => intel_get_library_path(),
    4042    'pageTitle' => '(not set)',
    4143    'trackAnalytics' => 1, // this is set in intel_js_alter if ga script exists
    42     //'trackAdhocCtas' => ($api_level == 'pro') ? 'track-cta' : '', // Check if CTA tracking is supported in IPAI level
    43     //'trackAdhocEvents' => 'track-event',
     44    'trackAdhocCtas' => ($api_level == 'pro') ? 'track-cta' : '', // Check if CTA tracking is supported in IPAI level
     45    'trackAdhocEvents' => 'track-event',
    4446    'trackForms' => array(),
    4547    'trackRealtime' => (integer)get_option('intel_track_realtime', INTEL_TRACK_REALTIME_DEFAULT),
    4648    'fetchGaRealtime' => (integer)get_option('intel_fetch_ga_realtime', 0),
    4749    'isLandingpage' => 0,
    48     //'scorings' => intel_get_scorings('js_setting'),
    4950    'scorings' => array(
    5051      'events' => array(),
     
    6667  );
    6768
    68   if (!empty($_GET['io-admin']) && Intel_Df::user_access('admin intel')) {
    69     wp_enqueue_style('intel_front_admin', INTEL_URL . 'css/intel-front-admin.css');
    70     $config['admin'] = 1;
     69  if (INTEL_PLATFORM == 'wp') {
     70    if (!empty($_GET['io-admin']) && Intel_Df::user_access('admin intel')) {
     71      wp_enqueue_style('intel_front_admin', INTEL_URL . 'css/intel.intel_script_admin.css');
     72      $config['admin'] = 1;
     73    }
    7174  }
    7275
     
    105108  }
    106109
    107   $path_is_admin = is_admin();
     110  if (INTEL_PLATFORM == 'wp') {
     111    $path_is_admin = is_admin();
     112  }
     113  else {
     114    $path_is_admin = path_is_admin(current_path());
     115  }
    108116 
    109117  $ga_va = array();
    110   if (!empty($user->ID)) {
     118  if ($uid) {
    111119    if (intel_include_library_file('class.visitor.php')) {
    112120      $ga_va = \LevelTen\Intel\ApiVisitor::extractCookieVa();
     
    123131  intel_add_page_intel_push(array('set', "p.systemPath", $q));
    124132
    125   // if entity not provided, lookup based on menu path
    126   if (is_single() || is_page()) {
    127     global $post;
    128     $entity = $post;
    129     $entity_type = 'post';
    130     $config['pageTitle'] = get_the_title( $post );
    131     $config['pageUri'] = ':post:' . $post->ID;
    132   }
    133 
    134   /*
    135   if (arg(0) == 'node') {
    136     $entity = menu_get_object();
    137     $entity_type = 'node';
    138   }
    139   elseif (arg(0) == 'user') {
    140     $entity = menu_get_object('user');
    141     $entity_type = 'user';
    142   }
    143   */
    144 
    145   // TODO WP
    146   //$config['pageTitle'] = isset($entity->title) ? $entity->title : drupal_get_title();
     133  // determine entity from url
     134  if (INTEL_PLATFORM == 'wp') {
     135    if (is_single() || is_page()) {
     136      global $post;
     137      $entity = $post;
     138      $entity_type = 'post';
     139      $config['pageTitle'] = get_the_title( $post );
     140      $config['pageUri'] = ':post:' . $post->ID;
     141    }
     142  }
     143  else {
     144    // if entity not provided, lookup based on menu path
     145    if (arg(0) == 'node') {
     146      $entity = menu_get_object();
     147      $entity_type = 'node';
     148    }
     149    elseif (arg(0) == 'user') {
     150      $entity = menu_get_object('user');
     151      $entity_type = 'user';
     152    }
     153    $config['pageTitle'] = isset($entity->title) ? $entity->title : drupal_get_title();
     154    $config['pageUri'] = current_path();
     155  }
     156
    147157  if ($entity_type && !empty($entity)) {
    148158    $attrs = intel_get_entity_intel_attributes($entity, $entity_type, 1);
     
    159169  if (isset($page_attrs['pi']) && isset($page_attrs['pi']['l'])) {
    160170    $config['isLandingpage'] = 1;
    161     // Check if landingpage tracking is supported in IPAI level
    162     if ($api_level == 'pro') {
    163       //$page_events['landing_page_view'] = $intel_events['landing_page_view'];
    164     }
    165171  }
    166172
    167173  // set user role visitor attribute
    168174  // only when user is logged in (otherwise page caching will cause errors)
    169   if (!empty($user->ID)) {
     175  if ($uid) {
    170176    if (INTEL_PLATFORM == 'wp') {
    171177      // don't exclude on intel_demo_pages to allow testing
    172178      if (!intel_is_demo_page()) {
    173179        $tracking_exclude_roles = get_option('intel_tracking_exclude_role', intel_get_tracking_exclude_user_role_default());
    174 
    175180        // WP roles do not have ids, so we create them
    176181        $role_index = get_option('intel_role_index', array());
     182        if (empty($role_index)) {
     183          $role_index['anonymous'] = 0;
     184        }
    177185        $cur = isset($ga_va['ur']) ? $ga_va['ur'] : array();
    178186        if (!empty($user->roles) && is_array($user->roles)) {
     
    195203        }
    196204      }
    197 
    198205    }
    199206    elseif (INTEL_PLATFORM == 'drupal') {
     
    214221      }
    215222    }
    216 
    217223  }
    218224
     
    288294      intel_add_page_intel_push(array('linktracker:setLinkTypeDef', $key, $def));
    289295    }
    290     //intel_add_page_intel_push(array('linktracker:setLinkDef', $key, $def));
    291     //intel_d($link_infos);
    292   }
    293 
    294   /*
    295   $def = array(
    296     'selector' => 'form#test',
    297     'trackImpression'
    298   );
    299   intel_add_page_intel_push(array('formtracker:trackForm', $def));
    300   intel_add_page_intel_push(array('formtracker:trackForm', 'test', $def));
    301   */
    302 
    303   //intel_check_user_login($page);
     296  }
    304297
    305298  intel_check_form_submission($page);
     
    320313
    321314  // call hook for modules to add page pushes
    322   do_action('intel_page_intel_pushes');
    323   //module_invoke_all('intel_page_intel_pushes');
     315  intel_do_hook_action('intel_page_intel_pushes');
    324316
    325317  $pushes = intel_get_flush_page_intel_pushes();
     318  $pushes_cookie = intel_get_flush_page_intel_pushes_cookie();
    326319
    327320  // add page title and system path to any IntelEvent that is missing values
    328321  /*
    329   foreach ($pushes AS $i => $push) {
    330     if ($push['method'] == '_addIntelEvent') {
    331       if (empty($push['action'])) {
    332         $pushes[$i]['action'] = $page_title;
    333       }
    334       if (empty($push['label'])) {
    335         $pushes[$i]['label'] = $_GET['q'];
    336       }
    337     }
    338   }
    339   */
    340 
    341322  if (isset($pushes['event']) && is_array($pushes['event'])) {
    342323    foreach ($pushes['event'] AS $i => $push) {
     
    349330    }
    350331  }
     332  */
    351333
    352334  //watchdog('intel_page_alter_pushes', print_r($pushes, 1));
     
    357339      'config' => $config,
    358340      'pushes' => $pushes,
     341      'pushes_cookie' => $pushes_cookie,
    359342    ),
    360343    // TODO: move this to intel_disqus
     
    370353  }
    371354
    372   // Get page status code for visibility filtering.
    373 
     355  // determine if page should be tracked
    374356  $track = 1;
    375   /*
    376   if (!(_googleanalytics_visibility_pages() || in_array($status, $trackable_status_codes)) && _googleanalytics_visibility_user($user)) {
    377     $track = 0;
    378     // TODO: Intel GA tracking should track google_analytics module settings
    379     //$js['intel']['config']['track_analytics'] = 0;
    380   }
    381   if (path_is_admin(current_path())) {
    382     $track = 0; 
    383   }
    384   */
     357
     358  if (INTEL_PLATFORM == 'wp') {
     359
     360  }
     361  else {
     362    // check page tracking settings in googleanaltyics module
     363    // Get page status code for visibility filtering.
     364    $id = variable_get('googleanalytics_account', '');
     365    $status = drupal_get_http_header('Status');
     366    $trackable_status_codes = array(
     367      '403 Forbidden',
     368      '404 Not Found',
     369    );
     370    $track = 1;
     371    if (!(_googleanalytics_visibility_pages() || in_array($status, $trackable_status_codes)) && _googleanalytics_visibility_user($user)) {
     372      $track = 0;
     373      // TODO: Intel GA tracking should track google_analytics module settings
     374      //$js['intel']['config']['track_analytics'] = 0;
     375    }
     376    if (path_is_admin(current_path())) {
     377      $track = 0;
     378    }
     379  }
     380
    385381  if (!$track) {
    386382    $js['intel']['config']['track_forms'] = 0;
     
    389385  }
    390386  else {
    391     //$scripts = intel()->intel_script_info();
    392     //$enabled = get_option('intel_intel_scripts_enabled', array());
    393     //foreach ($scripts AS $key => $script) {
    394     //  if (!empty($enabled[$key]) || (!isset($enabled[$key]) && !empty($script['enabled']))) {
    395     //    wp_enqueue_script('intel_script_' . $key, $script['path']);
    396     //  }
    397     //}
    398   }
    399 
    400 
     387    // add intel scripts to page
     388    if (INTEL_PLATFORM == 'wp') {
     389      // for WP, js scripts are enqueued in class-intel-tracker
     390    }
     391    else {
     392      $scripts = intel_get_intel_script_info();
     393      $enabled = variable_get('intel_intel_scripts_enabled', array());
     394      foreach ($scripts AS $key => $script) {
     395        if (!empty($enabled[$key]) || (!isset($enabled[$key]) && !empty($script['enabled']))) {
     396          drupal_add_js($script['path']);
     397        }
     398      }
     399
     400      if (!empty($_GET['debug'])) {
     401        if ($_GET['debug'] == 'ie9') {
     402          $script = "http://ie.microsoft.com/testdrive/HTML5/CompatInspector/inspector.js";
     403          drupal_add_js($script, array('scope' => 'header', 'type' => 'external', 'weight' => -10, 'group' => JS_LIBRARY));
     404        }
     405      }
     406
     407      // add js embed script
     408      $script = intel_get_js_embed('l10i', 'local');
     409      drupal_add_js($script, array('type' => 'inline', 'scope' => 'header', 'weight' => 0));
     410    }
     411  }
    401412 
    402   if (!empty($_GET['debug'])) {
    403     if ($_GET['debug'] == 'ie9') {
    404       $script = "http://ie.microsoft.com/testdrive/HTML5/CompatInspector/inspector.js";
    405       // TODO WP
    406       //drupal_add_js($script, array('scope' => 'header', 'type' => 'external', 'weight' => -10, 'group' => JS_LIBRARY));
    407     }
    408   }
    409   /*
    410   $script = get_option('intel_js_monitor_script', '');
    411   if ($script) {
    412     drupal_add_js($script, array('type' => 'inline', 'scope' => 'header', 'weight' => -99, 'group' => -101));
    413   }
    414   */
    415 
    416   //$script = intel_get_js_embed('l10i', 'local');
    417   //wp_enqueue_script('intel_tracker_embed', $script);
    418   //drupal_add_js($script, array('type' => 'inline', 'scope' => 'header', 'weight' => 0));
    419 
    420   /**
    421    * check admin alter enhancements
    422    */
    423 
    424   /*
    425   if ($_GET['q'] == 'admin/content' && user_access('view all intel reports')) {
    426     drupal_add_css(drupal_get_path('module', 'intel') . '/css/intel.report.css');
    427     drupal_add_js(drupal_get_path('module', 'intel') . '/js/intel.admin_content_alter.js');
    428   }
    429   if ($_GET['q'] == 'admin/content/cta' && user_access('view all intel reports')) {
    430     drupal_add_js(drupal_get_path('module', 'intel') . '/js/intel.admin_content_cta_alter.js');
    431   }
    432   */
    433 
    434413  //drupal_alter('intel_page_settings_js', $js, $page);
    435   $js = apply_filters('intel_page_settings_js', $js, $page);
     414  intel_do_hook_alter('intel_page_settings_js', $js, $page);
     415
    436416  if (!empty($_GET['debug'])) {
    437417    intel_d($js);//
     
    564544
    565545  // ? not sure if this is needed or enhances performance
    566   $created = Intel_Entity::entity_get($entity_type, $entity, 'created');
     546  $created = IntelEntity::entity_get($entity_type, $entity, 'created');
    567547  if (isset($created)) {
    568548    $val = date('YmdHiw', $created);
     
    607587  // Only load URI if entity has been created (has ID).
    608588  if ($entity_id) {
    609     $uri = Intel_Entity::entity_uri($entity_type, $entity);
     589    $uri = IntelEntity::entity_uri($entity_type, $entity);
    610590    if (!empty($uri['id'])) {
    611591      $page_attrs['ri'] = $uri['id'];
     
    659639      $key = 'a';
    660640    }
    661     $author_id = Intel_Entity::entity_get($entity_type, $entity, 'author_id');
     641    $author_id = IntelEntity::entity_get($entity_type, $entity, 'author_id');
    662642    $page_attrs[$key] = $author_id;
    663643    //$page_ld['author'] = $base_path . "user/" . $entity->uid;
     
    842822}
    843823
    844 function intel_page_footer_alter() {
    845   return;
    846   global $post;
    847   if (!empty($post)) {
    848     $stats = intel_get_post_stats($post);
    849   }
    850 }
    851 
    852 
    853824function intel_get_post_entity_attr_default($post = NULL) {
    854825  if (!isset($post)) {
     
    926897}
    927898
     899function intel_get_page_intel_pushes_cookie() {
     900  return intel_page_intel_pushes('get_cookie');
     901}
     902
     903function intel_get_flush_page_intel_pushes_cookie() {
     904  return intel_page_intel_pushes('get_cookie_flush');
     905}
     906
    928907/**
    929908 * Used to store intel pushes for redirects.
    930909 * @return mixed
    931910 */
    932 
    933911function intel_save_flush_page_intel_pushes() {
    934912  $push_storage = get_option('intel_save_push_storage', INTEL_SAVE_PUSH_STORAGE_DEFAULT);
     
    952930function intel_page_intel_pushes($action = 'get', $push = array(), $index = '') {
    953931
    954   if (!isset($_SESSION['intel'])) {
    955     $_SESSION['intel'] = array();
    956   }
    957   if (!isset($_SESSION['intel']['page_pushes'])) {
    958     $_SESSION['intel']['page_pushes'] = array();
     932  if (!isset($_SESSION['intel_pushes'])) {
     933    $_SESSION['intel_pushes'] = array();
     934  }
     935  if (!isset($_SESSION['intel_pushes']['page_pushes'])) {
     936    $_SESSION['intel_pushes']['page_pushes'] = array();
     937  }
     938  if (!isset($_SESSION['intel_pushes']['page_pushes_cookie'])) {
     939    $_SESSION['intel_pushes']['page_pushes_cookie'] = array();
     940  }
     941
     942  $data = &$_SESSION['intel_pushes']['page_pushes'];
     943  if (!empty($options['cookie'])) {
     944    $data = &$_SESSION['intel_pushes']['page_pushes_cookie'];
    959945  }
    960946
     
    969955    }
    970956
    971     if (!isset($_SESSION['intel']['page_pushes'][$method])) {
    972       $_SESSION['intel']['page_pushes'][$method] = array();
     957    if (!isset($data[$method])) {
     958      $data[$method] = array();
    973959    }
    974960
     
    991977    }
    992978    elseif ($method == 'event') {
    993       $index = count($_SESSION['intel']['page_pushes'][$method]);
     979      $index = count($data[$method]);
    994980      $value = $push[0];
    995981    }
     
    1000986      // check if push uses command(def) format
    1001987      if (count($push) == 1 && is_array($push[0])) {
    1002         $index = count($_SESSION['intel']['page_pushes'][$method]);
     988        $index = count($data[$method]);
    1003989        $value = $push[0];
    1004990      }
    1005991      else {
    1006         $index = count($_SESSION['intel']['page_pushes'][$method]);
     992        $index = count($data[$method]);
    1007993        $value = $push;
    1008994      }
     
    1011997
    1012998    if ($index == -1) {
    1013       $_SESSION['intel']['page_pushes'][$method] = $value;
     999      $data[$method] = $value;
    10141000    }
    10151001    else {
    1016       $_SESSION['intel']['page_pushes'][$method][$index] = $value;
    1017     }
    1018 
    1019   }
    1020 
    1021   $ret = $_SESSION['intel']['page_pushes'];
     1002      $data[$method][$index] = $value;
     1003    }
     1004
     1005  }
     1006
     1007  $ret = $data;
    10221008
    10231009  if ($action == 'save_flush' || $action == 'save_db_flush') {
    10241010    intel()->quick_session_cache();
    1025     unset($_SESSION['intel']['page_pushes']);
    1026 
     1011    unset($_SESSION['intel_pushes']['page_pushes']);
    10271012  }
    10281013  elseif ($action == 'save_cookie_flush') {
     
    10301015    $pushes = array();
    10311016
    1032     foreach ($_SESSION['intel']['page_pushes'] as $k => $v) {
     1017    foreach ($_SESSION['intel_pushes']['page_pushes'] as $k => $v) {
    10331018      $a = array('');
    10341019      $pushes[] = array($k, $v);
    10351020    }
    10361021    $json = json_encode($pushes);
    1037     intel_setrawcookie('l10i_push', $json);
    1038     unset($_SESSION['intel']['page_pushes']);
     1022    intel_setrawcookie('l10i_page_pushes', $json);
     1023    unset($_SESSION['intel_pushes']['page_pushes']);
     1024    unset($_SESSION['intel_pushes']['page_pushes_cookie']);
    10391025  }
    10401026  elseif ($action == 'get_flush') {
    1041     unset($_SESSION['intel']['page_pushes']);
     1027    unset($_SESSION['intel_pushes']['page_pushes']);
     1028  }
     1029  elseif ($action == 'get_cookie') {
     1030    $ret = $_SESSION['intel_pushes']['page_pushes_cookie'];
     1031  }
     1032  elseif ($action == 'get_cookie_flush') {
     1033    $ret = $_SESSION['intel_pushes']['page_pushes_cookie'];
     1034    unset($_SESSION['intel_pushes']['page_pushes_cookie']);
     1035  }
     1036
     1037  /*
     1038   * Unset session var if empty on flush
     1039   */
     1040  if ((substr($action, -5) == 'flush')
     1041    && empty($_SESSION['intel_pushes']['page_pushes'])
     1042    && empty($_SESSION['intel_pushes']['page_pushes_cookie'])
     1043  ) {
     1044    unset($_SESSION['intel_pushes']);
    10421045  }
    10431046
     
    11481151      }
    11491152
    1150 
    1151 
    11521153    }
    11531154    else {
     
    12131214    'clickMode' => 1,
    12141215    'clickValue' => 1,
     1216    'track_file_extension' => 'trackFileExtension',
     1217    'trackFileExtension' => 1,
    12151218  );
    12161219
     
    12331236}
    12341237
    1235 function intel_cache_busting_url($url) {
     1238function intel_cache_busting_url($url, $force = FALSE) {
    12361239  $enable = &Intel_Df::drupal_static( __FUNCTION__ );
     1240
    12371241  if (!isset($enable)) {
    12381242    $enable = get_option('intel_cache_busting', INTEL_CACHE_BUSTING_DEFAULT);
    12391243  }
    1240   if (!$enable) {
     1244  if (!$enable && !$force) {
    12411245    return $url;
    12421246  }
     
    13681372 */
    13691373function intel_get_js_embed($type = 'l10i', $mode = 'external', $version = 'latest', $terminator = "") {
    1370   global $user;
     1374  $user = intel_get_current_user();
    13711375
    13721376  $script = '';
     
    15091513
    15101514    // trigger alter to enable other modules to add pushes
    1511     $l10iq_pushes = apply_filters('intel_l10iq_pushes_alter', $l10iq_pushes);
     1515    intel_do_hook_alter('intel_js_embed_intel_push', $l10iq_pushes);
    15121516    //drupal_alter('intel_l10iq_pushes', $l10iq_pushes);
    15131517
     
    15361540        $l10ijs_path = '/js/' . $api_js_ver . '/l10i' . $sv . '.js';
    15371541
     1542        if (intel_is_no_api()) {
     1543          $a = explode('//', get_site_url());
     1544          $api_hostpath = $a[1];
     1545          $purl = parse_url(plugin_dir_url(__DIR__));
     1546          $l10ijs_path = $purl['path'] . 'js/l10i' . $sv . '.js';
     1547          $l10ijs_propdir = '';
     1548        }
    15381549
    15391550        $script .= "(function(w,d,o,u,b,i,r,a,s,c,t){" . $terminator;
     
    17011712
    17021713  include_once INTEL_DIR . 'includes/class-intel-visitor.php';
    1703   $vtk = Intel_Visitor::extractVtk();
     1714  $vtk = IntelVisitor::extractVtk();
    17041715
    17051716  $api_level = intel_api_level();
     
    18291840 */
    18301841function intel_process_form_submission($vars) {
    1831 //Intel_Df::watchdog('intel_process_form_submission vars', json_encode($vars));
     1842Intel_Df::watchdog('intel_process_form', 'vars', $vars);
    18321843  // set defaults
    18331844  $vars += intel_form_submission_vars_default();
     
    20102021      $submission->vid = 0;
    20112022    }
    2012 
    20132023  }
    20142024
     
    23022312    'hook_context' => isset($vars['hook_context']) ? $vars['hook_context'] : NULL,
    23032313  );
    2304   $hook_data = apply_filters('intel_form_submission_data_presave', $hook_data, $hook_context);
     2314//Intel_Df::watchdog('intel_process_form_submissionhook_presave', 'hook_data', $hook_data);
     2315  //$hook_data = apply_filters('intel_form_submission_data_presave', $hook_data, $hook_context);
     2316  $hook_data = intel_do_hook('intel_form_submission_data_presave', $hook_data, $hook_context);
    23052317
    23062318  // save submission object
    23072319  if (!empty($submission->vid)) {
     2320//Intel_Df::watchdog('intel_process_form', 'submission', $submission);
    23082321    $sid = intel_submission_save($submission);
    23092322    if (empty($submission->sid)) {
     
    23122325  }
    23132326
    2314   if ($submission->sid) {
     2327  // if submission path does not exist, set default
     2328  if (empty($track['submission_path']) && !empty($sid)) {
     2329    $track['submission_path'] = 'submission/' . $sid;
     2330  }
     2331
     2332  if (!empty($submission->sid)) {
    23152333    $track['oa']['3rk'] = $submission->sid;
    23162334    $track['oa']['3ri'] = ':intel_submission:' . $submission->sid;
     
    23332351  }
    23342352
    2335   //$userId = Intel_Visitor::extractUserId();
     2353  //$userId = IntelVisitor::extractUserId();
    23362354
    23372355  //intel_set_ga_userid($visitor);
     
    23532371  // save visitor
    23542372  if (!empty($visitor->vid)) {
     2373//Intel_Df::watchdog('intel_process_form', 'visitor', $visitor);
    23552374    intel_visitor_save($visitor);
    2356     //watchdog('intel.page_alter 992', print_r($visitor, 1));
    23572375  }
    23582376
     
    23642382  $track = apply_filters('intel_form_submission_track_alter', $track, $hook_context);
    23652383
     2384  // create form submission intel event
    23662385  if (!empty($track['event_category'])) {
    23672386    $call = array(
     
    23732392      'oa' => $track['oa'],
    23742393    );
    2375     //Intel_Df::watchdog('form_submission', json_encode($call));
    2376 
     2394
     2395//Intel_Df::watchdog('intel_process_form', 'intel_push', $call);
    23772396    intel_add_page_intel_push(array('event', $call));
    2378 //dpm('page_intel_push=');dpm($call);//
    23792397  }
    23802398
     
    24122430
    24132431  // hook to allow other plugins to save data
    2414   do_action('intel_form_submission_data_save', $hook_context);
     2432  intel_do_hook_action('intel_form_submission_data_save', $hook_context);
     2433  //do_action('intel_form_submission_data_save', $hook_context);
    24152434}
    24162435
     
    24842503  }
    24852504  if (!$domain) {
    2486     $domain = '.' . intel()->domain;
     2505    //$domain = '.';
    24872506  }
    24882507
     
    25042523
    25052524function intel_deletecookie($name) {
    2506   if (isset($_COOKIOE[$name])) {
    2507     unset($_COOKIOE[$name]);
     2525  if (isset($_COOKIE[$name])) {
     2526    unset($_COOKIE[$name]);
    25082527  }
    25092528  intel_setcookie($name, '', time() - 999);
     
    25602579    // if account is currently logged in user, set $vtk
    25612580    // otherwise another user is saving user data
    2562     $vtk = ($uid && ($user->uid == $account->uid)) ? Intel_Visitor::extractVtk() : '';
     2581    $vtk = ($uid && ($user->uid == $account->uid)) ? IntelVisitor::extractVtk() : '';
    25632582  }
    25642583  elseif (INTEL_PLATFORM == 'wp') {
     
    25662585    $email = $account->user_email;
    25672586    $name = $account->display_name;
    2568     $vtk = Intel_Visitor::extractVtk();
     2587    $vtk = IntelVisitor::extractVtk();
    25692588  }
    25702589
     
    27342753
    27352754  // don't save "visitors" that don't have a vtk. They are likely spam bots
    2736   $vtk = Intel_Visitor::extractVtk();
     2755  $vtk = IntelVisitor::extractVtk();
    27372756  if (empty($vtk)) {
    27382757    return;
  • intelligence/trunk/includes/intel.reports.php

    r1827302 r2947915  
    415415    $vars['timeframe'] = 'l30d';
    416416  }
     417
    417418  list($vars['start_date'], $vars['end_date'], $vars['number_of_days'], $vars['timezone_offset']) = _intel_get_report_dates_from_ops($vars['timeframe'], $vars['cache_options']);
     419
     420  // check for DateHourMinute format
     421  $a = explode(',', $vars['timeframe']);
     422  if (count($a) == 2 && strlen($a[0]) == 12 && strlen($a[1]) == 12) {
     423    if (!isset($vars['filters']['datetime'])) {
     424      $vars['filters']['datetime'] = array();
     425    }
     426    // make not to use the input timestamp and used the ga timezone corrected start_date & end_date
     427    $vars['filters']['datetime'][] = "dateHourMinute:" . date('YmdHi', $vars['start_date']) . "-" . date('YmdHi', $vars['end_date']) ;
     428  }
    418429
    419430  if (!empty($_GET['refresh'])) {
  • intelligence/trunk/includes/intel.visitor_sync.php

    r1904936 r2947915  
    104104}
    105105
    106 add_filter( 'intel_sync_visitor', 'intel_ga_sync_visitordata', 5, 2);
     106add_filter( 'intel_sync_visitor', 'intel_intel_sync_visitor', 5, 2);
     107function intel_intel_sync_visitor(IntelVisitor $visitor, $options = array()) {
     108  $visitor = intel_ga_sync_visitor($visitor, $options);
     109  //$visitor = intel_l10iapi_sync_visitordata($visitor, $options);
     110
     111  return $visitor;
     112}
     113
     114//add_filter( 'intel_sync_visitor', 'intel_ga_sync_visitordata', 5, 2);
    107115/**
    108116 * Implements intel_sync_visitordata
    109117 * @param unknown_type $visitor
    110118 */
    111 function intel_ga_sync_visitordata($visitor, $options = array()) {
    112 Intel_Df::watchdog('intel_ga_sync_visitordata options', print_r($options, 1));
     119function intel_ga_sync_visitor($visitor, $options = array()) {
     120//$args = func_get_args();
     121//Intel_Df::watchdog('intel_ga_sync_visitordata', 'args', $args);
    113122  if (!empty($options['processes']) && !in_array('ga', $options['processes'])) {
    114123    return $visitor;
    115124  }
    116125
    117   require_once INTEL_DIR . "includes/intel.ga.php";
     126  intel_load_include('includes/intel.ga');
     127
    118128  $vtkids = array();
    119129
     
    185195}
    186196
    187 add_filter( 'intel_sync_visitor', 'intel_l10iapi_sync_visitordata', 10, 2);
     197//add_filter( 'intel_sync_visitor', 'intel_l10iapi_sync_visitordata', 10, 2);
    188198function intel_l10iapi_sync_visitordata($visitor, $options = array()) {
    189199  if (!empty($options['processes']) && !in_array('l10iapi', $options['processes'])) {
  • intelligence/trunk/intel.install.php

    r1827302 r2947915  
    158158    }
    159159}
     160
     161/**
     162 * Adding annotation table
     163 */
     164function intel_update_1005() {
     165    global $wpdb;
     166
     167    require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
     168
     169    $charset_collate = $wpdb->get_charset_collate();
     170
     171    $table_name = $wpdb->prefix . "intel_annotation";
     172
     173  $sql = "CREATE TABLE $table_name (
     174    aid int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
     175    created int(10) UNSIGNED NOT NULL DEFAULT '0',
     176    updated int(10) UNSIGNED NOT NULL DEFAULT '0',
     177    timestamp int(10) UNSIGNED NOT NULL DEFAULT '0',
     178    type varchar(128) NOT NULL DEFAULT '',
     179    message longtext NOT NULL,
     180    variables longtext NOT NULL,
     181    data longtext NOT NULL,
     182    PRIMARY KEY (aid),
     183    KEY timestamp (timestamp),
     184    KEY type (type)
     185    ) $charset_collate;";
     186
     187    dbDelta( $sql );
     188}
  • intelligence/trunk/intel.module.php

    r2096810 r2947915  
    99define('INTEL_L10IAPI_URL', 'https://api.getlevelten.com/v1/intel');
    1010define('INTEL_IMAPI_URL', 'https://admin.intelligencewp.com/imapi/v1/intel');
     11define('INTEL_NO_API', 1);  // set to 1 to remove API connections
    1112//define('INTEL_IMAPI_URL', 'intl.getlevelten.com/imapi/v1/intel');
    1213define('INTEL_L10IAPI_JS_VER', '0.3.1');
     
    1516define('INTEL_TRACK_PAGE_UID_DEFAULT', 'a');
    1617define('INTEL_TRACK_PAGE_TERMS_DEFAULT', 0);
    17 define('INTEL_TRACK_PAGE_TERMS_VISITOR_DEFAULT', 0);
     18define('INTEL_TRACK_VISITOR_TERMS_DEFAULT', 0);
    1819define('INTEL_SYNC_VISITORDATA_FULLCONTACT_DEFAULT', 0);
    1920define('INTEL_TRACK_PHONECALLS_DEFAULT', 0);
     
    3536
    3637// include required files
     38require_once Intel_Df::drupal_get_path('module', 'intel') . "/includes/intel.common.php";
    3739require_once Intel_Df::drupal_get_path('module', 'intel') . "/includes/intel.page_alter.php";
    3840require_once Intel_Df::drupal_get_path('module', 'intel') . "/includes/intel.page_data.php";
     
    120122    'weight' => -10,
    121123  );
     124
    122125  $items['admin/config/intel/settings/general'] = array(
    123126    'title' => 'General',
     
    168171    'file' => 'admin/intel.admin_setup.php',
    169172  );
     173
     174  $items['admin/config/intel/settings/annotation'] = array(
     175    'title' => 'Annotations',
     176    'description' => 'Annotation configuration.',
     177    'page callback' => 'intel_admin_annotation_list_page',
     178    'access callback' => 'user_access',
     179    //'access callback' => '_intel_user_access_extended',
     180    'access arguments' => array('admin intel'),
     181    'type' => Intel_Df::MENU_LOCAL_TASK,
     182    'weight' => $w++,
     183    'file' => 'admin/intel.admin_annotation.php',
     184  );
     185
    170186  $items['admin/config/intel/settings/scoring'] = array(
    171187    'title' => 'Scoring',
     
    479495    );
    480496  }
     497
     498  $items['admin/config/intel/settings/framework'] = array(
     499    'title' => 'Framework settings',
     500    'description' => 'Basic setup',
     501    'page callback' => 'drupal_get_form',
     502    'page arguments' => array('intel_admin_framework_settings'),
     503    'access callback' => 'user_access',
     504    'access arguments' => array('admin intel'),
     505    'type' => Intel_Df::MENU_CALLBACK,
     506    'weight' => -1,
     507    'file' => 'admin/intel.admin_framework.php',
     508    'intel_install_access' => 'active',
     509  );
    481510
    482511  // intel visitor config
     
    848877      );
    849878    }
     879
     880    $items['admin/annotations'] = array(
     881      'title' => 'Annotations',
     882      'description' => 'Information about annotations',
     883      'page callback' => 'intel_admin_annotation_list_page',
     884      //'page arguments' => array(4),
     885      'access callback' => 'intel_annotation_access',
     886      'access arguments' => array('list'),
     887      'type' => Intel_Df::MENU_NORMAL_ITEM,
     888      'file' => 'admin/intel.admin_annotation.php',
     889      //'intel_api_access' => 'pro',
     890    );
     891    $items['admin/annotations/add'] = array(
     892      'title' => 'Add',
     893      'description' => 'Add new annotation',
     894      'page callback' => 'intel_admin_annotation_add_page',
     895      //'page arguments' => array(4),
     896      'access callback' => 'intel_annotation_access',
     897      'access arguments' => array('update'),
     898      'type' => Intel_Df::MENU_NORMAL_ITEM,
     899      'file' => 'admin/intel.admin_annotation.php',
     900      //'intel_api_access' => 'pro',
     901    );
     902
     903    $items['annotation/%intel_annotation'] = array(
     904      'title' => 'Annotation',
     905      'page callback' => 'intel_annotation_page',
     906      'page arguments' => array(1),
     907      'access callback' => 'intel_annotation_access',
     908      'access arguments' => array('view', 1),
     909      'file' => 'admin/intel.admin_annotation.php',
     910    );
     911    $items['annotation/%intel_annotation/view'] = array(
     912      'title' => 'View',
     913      'type' => Intel_Df::MENU_DEFAULT_LOCAL_TASK,
     914      'weight' => -20,
     915    );
     916    $items['annotation/%intel_annotation/edit'] = array(
     917      'title' => 'Edit',
     918      'description' => 'Edit annotation',
     919      //'page callback' => 'intel_visitor_tab_clickstream',
     920      'page callback' => 'intel_admin_annotation_edit_page',
     921      'page arguments' => array(1),
     922      'access callback' => 'intel_annotation_access',
     923      'access arguments' => array('update', 1),
     924      'type' => Intel_Df::MENU_LOCAL_TASK,
     925      'file' => 'admin/intel.admin_annotation.php',
     926    );
     927    $items['annotation/%intel_annotation/sync_ga'] = array(
     928      'title' => 'GA Sync',
     929      'description' => 'Edit annotation',
     930      //'page callback' => 'intel_visitor_tab_clickstream',
     931      'page callback' => 'intel_admin_annotation_sync_ga_page',
     932      'page arguments' => array(1),
     933      'access callback' => 'intel_annotation_access',
     934      'access arguments' => array('update', 1),
     935      'type' => Intel_Df::MENU_CALLBACK,
     936      'file' => 'admin/intel.admin_annotation.php',
     937    );
     938
     939
    850940  }
    851941
     
    10391129  );
    10401130
    1041   /*
    1042   $items['admin/util/log'] = array(
    1043     'title' => 'Messages',
    1044     'description' => 'View messages log',
    1045     'page callback' => 'intel_util_log_page',
    1046     'access callback' => 'user_access',
    1047     'access arguments' => array('admin intel'),
    1048     'type' => Intel_Df::MENU_LOCAL_TASK,
    1049     'file' => 'admin/intel.admin_util.php',
    1050   );
    1051   */
    1052 
    10531131  $items['admin/util/update'] = array(
    10541132    'title' => 'Update',
     
    10591137    'type' => Intel_Df::MENU_LOCAL_TASK,
    10601138    'file' => 'admin/intel.admin_util.php',
     1139  );
     1140
     1141  $items['admin/util/log'] = array(
     1142    'title' => 'Log',
     1143    'description' => 'Watchdog log',
     1144    'page callback' => 'intel_util_log_list_page',
     1145    'access callback' => 'user_access',
     1146    'access arguments' => array('admin intel'),
     1147    'type' => Intel_Df::MENU_LOCAL_TASK,
     1148    'file' => 'admin/intel.admin_util.php',
     1149    'intel_install_access' => 'active',
     1150  );
     1151
     1152  $items['admin/util/log/%intel_log'] = array(
     1153    'title' => 'Log',
     1154    'description' => 'Watchdog log',
     1155    'page callback' => 'intel_util_log_page',
     1156    'page arguments' => array(3),
     1157    'access callback' => 'user_access',
     1158    'access arguments' => array('admin intel'),
     1159    'type' => Intel_Df::MENU_LOCAL_TASK,
     1160    'file' => 'admin/intel.admin_util.php',
     1161    'intel_install_access' => 'active',
    10611162  );
    10621163
     
    18021903}
    18031904
     1905function intel_is_no_api() {
     1906  return INTEL_NO_API;
     1907}
     1908
    18041909/**
    18051910 * Determines if the api access level is adequate to access the
     
    19372042    'phonecall/*' => 1,
    19382043    'emailclick/*' => 1,
     2044    'annotation/*' => 1,
    19392045  );
    19402046  return $paths;
     
    19902096    'title' => Intel_Df::t('View emailclicks'),
    19912097    'description' => Intel_Df::t('Grants access to view emailclicks.'),
     2098    'roles' => array('editor', 'author'),
     2099  );
     2100  $permissions['view all intel annotations'] = array(
     2101    'title' => Intel_Df::t('View annotations'),
     2102    'description' => Intel_Df::t('Grants access to view annotations.'),
    19922103    'roles' => array('editor', 'author'),
    19932104  );
     
    20612172      return $module_access || $general_access;
    20622173    case 'list':
     2174      return $module_access || $general_access;
     2175  }
     2176}
     2177
     2178function intel_annotation_access($op, $annotation = NULL, $account = NULL) {
     2179
     2180  $account = isset($account) ? $account : wp_get_current_user();
     2181
     2182  $general_access = Intel_Df::user_access('view all intel annotations', $account);
     2183
     2184  $module_access = FALSE;
     2185  //$module_access = count(array_filter(module_invoke_all('intel_submission_access', $submission, $op, $account))) > 0;
     2186
     2187  switch ($op) {
     2188    case 'view':
     2189      return $module_access || $general_access;
     2190    case 'list':
     2191      return $module_access || $general_access;
     2192    case 'create':
     2193    case 'update':
     2194      return $module_access || $general_access;
     2195    case 'delete':
    20632196      return $module_access || $general_access;
    20642197  }
     
    22022335
    22032336function intel_verify_apikey(&$message = '', &$property = array(), $options = array()) {
     2337  if (intel_is_no_api()) {
     2338    $api_level = 'basic';
     2339    update_option('intel_api_level', $api_level);
     2340    return $api_level;
     2341  }
    22042342  if (!intel_verify_library($message)) {
    22052343    return FALSE;
     
    22892427}
    22902428
    2291 
     2429/**
     2430 * Returns if is framework flag is set
     2431 *
     2432 * @return array|bool|mixed
     2433 */
     2434function intel_is_framework() {
     2435  $flag = &Intel_Df::drupal_static( __FUNCTION__, NULL);
     2436
     2437  if (!isset($flag)) {
     2438    $flag = (boolean) get_option('intel_framework_mode', FALSE);
     2439    if (intel()->is_network_framework_mode) {
     2440      $flag = TRUE;
     2441    }
     2442  }
     2443
     2444
     2445  return $flag;
     2446}
     2447
     2448function intel_is_framework_only() {
     2449  return intel_is_framework() && !intel_is_installed();
     2450}
    22922451
    22932452/**
     
    23032462    // A human readable label to identify our entity.
    23042463    'label' => Intel_Df::t('Intel visitor'),
    2305     'entity class' => 'Intel_Visitor',
    2306     'controller class' => 'Intel_Visitor_Controller',
     2464    'entity class' => 'IntelVisitor',
     2465    'controller class' => 'IntelVisitorController',
    23072466    'base table' => 'intel_visitor',
    23082467    'label callback' => 'intel_visitor_label',
     
    23142473    ),
    23152474    'file' => array(
    2316       'includes/class-intel-visitor.php',
    2317       'includes/class-intel-visitor-controller.php',
     2475      'includes/intel.IntelVisitor.php',
     2476      'includes/intel.IntelVisitorController.php',
    23182477    ),
    23192478    'fields' => array(
     
    23712530    // A human readable label to identify our entity.
    23722531    'label' => Intel_Df::t('Intel submission'),
    2373     'entity class' => 'Intel_Submission',
    2374     'controller class' => 'Intel_Submission_Controller',
     2532    'entity class' => 'IntelSubmission',
     2533    'controller class' => 'IntelSubmissionController',
    23752534    'base table' => 'intel_submission',
    23762535    'label callback' => 'intel_submission_label',
     
    23822541    ),
    23832542    'file' => array(
    2384       'includes/class-intel-submission.php',
    2385       'includes/class-intel-submission-controller.php',
     2543      'includes/intel.IntelSubmission.php',
     2544      'includes/intel.IntelSubmissionController.php',
    23862545    ),
    23872546    'fields' => array(
    23882547      'sid' => null,
    23892548      'vid' => 0,
    2390       'submitted' => time(),
     2549      'submitted' => REQUEST_TIME,
    23912550      'type' => '',
    23922551      'fid' => '',
     
    24052564      'cta_id' => '',
    24062565      'data' => array(),
     2566    ),
     2567  );
     2568
     2569
     2570  $info['intel_annotation'] = array(
     2571    // A human readable label to identify our entity.
     2572    'label' => Intel_Df::t('Intel annotation'),
     2573    'entity class' => 'IntelAnnotation',
     2574    'controller class' => 'IntelAnnotationController',
     2575    'base table' => 'intel_annotation',
     2576    'label callback' => 'intel_annotation_label',
     2577    'uri callback' => 'intel_annotation_uri',
     2578    'fieldable' => FALSE,
     2579    'module' => 'intel',
     2580    'entity keys' => array(
     2581      'id' => 'aid',
     2582    ),
     2583    'file' => array(
     2584      'includes/intel.IntelAnnotation.php',
     2585      'includes/intel.IntelAnnotationController.php',
     2586    ),
     2587    'fields' => array(
     2588      'aid' => null,
     2589      'created' => REQUEST_TIME,
     2590      'updated' => REQUEST_TIME,
     2591      'started' => REQUEST_TIME,
     2592      'ended' => REQUEST_TIME,
     2593      'analytics_period' => 0,
     2594      'type' => '',
     2595      'message' => '',
     2596      'variables' => array(),
     2597      'data' => array(),
     2598    ),
     2599  );
     2600
     2601  $info['intel_log'] = array(
     2602    // A human readable label to identify our entity.
     2603    'label' => Intel_Df::t('Intel log'),
     2604    'entity class' => 'IntelLog',
     2605    'controller class' => 'IntelLogController',
     2606    'base table' => 'intel_log',
     2607    'label callback' => 'intel_log_label',
     2608    'uri callback' => 'intel_log_uri',
     2609    'fieldable' => FALSE,
     2610    'module' => 'intel',
     2611    'entity keys' => array(
     2612      'id' => 'lid',
     2613    ),
     2614    'file' => array(
     2615      'includes/intel.IntelLog.php',
     2616      'includes/intel.IntelLogController.php',
     2617    ),
     2618    'fields' => array(
     2619      'lid' => null,
     2620      'uid' => 0,
     2621      'type' => '',
     2622      'message' => '',
     2623      'variables' => array(),
     2624      'severity' => 0,
     2625      'link' => '',
     2626      'location' => '',
     2627      'referer' => '',
     2628      'hostname' => '',
     2629      'timestamp' => '',
    24072630    ),
    24082631  );
     
    25272750}
    25282751
     2752function intel_log_create($values = array()) {
     2753  $entity = intel()->get_entity_controller('intel_log')->create($values);
     2754  return $entity ;
     2755}
     2756
     2757/**
     2758 * We save the entity by calling the controller.
     2759 */
     2760function intel_log_save(&$entity) {
     2761  return intel()->get_entity_controller('intel_log')->save($entity);
     2762}
     2763
     2764/**
     2765 * Loads log object from database
     2766 *
     2767 * @param $lid Primary session id
     2768 *
     2769 * @return Submission stdClass object
     2770 */
     2771function intel_log_load($lid) {
     2772  //$submission = &Intel_Df::drupal_static(__FUNCTION__);
     2773  $entities = intel()->get_entity_controller('intel_log')->load($lid);
     2774  if (!empty($entities)) {
     2775    return array_shift($entities);
     2776  }
     2777  return FALSE;
     2778}
     2779
     2780/**
     2781 * Loads submission object using any table field
     2782 *
     2783 * @param $vars Array of key value pairs used to identify submission in table
     2784 *
     2785 * @return Submission stdClass object
     2786 */
     2787function intel_log_load_by_vars($vars) {
     2788  //$submission = &Intel_Df::drupal_static(__FUNCTION__);
     2789
     2790  $entities = intel()->get_entity_controller('intel_log')->loadByVars($vars);
     2791
     2792  if (!empty($entities) && is_array($entities)) {
     2793    return array_shift($entities);
     2794  }
     2795
     2796  return FALSE;
     2797}
     2798
    25292799function intel_visitor_load($id = NULL, $reset = FALSE, $id_type = NULL) {
    25302800  $visitors = intel_visitor_load_multiple($id, array(), $reset, $id_type);
     
    34223692}
    34233693
     3694/**
     3695 * Initializes properties of submission stdClass object
     3696 */
     3697function intel_annotation_construct() {
     3698  $annotation = intel()->get_entity_controller('intel_annotation')->create();
     3699  return $annotation;
     3700}
     3701
     3702/**
     3703 * Saves annotation objects
     3704 *
     3705 * @param stdClass $annotation
     3706 */
     3707function intel_annotation_save($annotation) {
     3708  return $annotation->save();
     3709}
     3710
     3711/**
     3712 * Loads annotation object from database
     3713 *
     3714 * @param $aid Primary annotation_id
     3715 *
     3716 * @return Annotation stdClass object
     3717 */
     3718function intel_annotation_load($aid) {
     3719  $annotation = intel()->get_entity_controller('intel_annotation')->load($aid);
     3720  if (!empty($annotation)) {
     3721    return array_shift($annotation);
     3722  }
     3723  return FALSE;
     3724}
     3725
     3726/**
     3727 * Deletes annotation entity
     3728 *
     3729 * @param $vid
     3730 * @return mixed
     3731 */
     3732function intel_annotation_delete($aid) {
     3733  // check if vid is a visitor entity, if so extract vid from entity
     3734  if (is_object($aid) && !empty($aid->aid)) {
     3735    $aid = $aid->aid;
     3736  }
     3737  return intel()->get_entity_controller('intel_annotation')->deleteOne($aid);
     3738}
     3739
    34243740
    34253741
     
    34403756 */
    34413757function intel_intel_scripts() {
    3442   return intel()->intel_script_info();
     3758  //return intel()->intel_script_info();
     3759  return intel_get_intel_script_info();
     3760}
     3761
     3762/**
     3763 * Returns information about intel_scripts
     3764 * @return array
     3765 */
     3766function intel_get_intel_script_info() {
     3767  $scripts = array();
     3768
     3769  $scripts = intel_build_info('intel_script');
     3770
     3771  return $scripts;
    34433772}
    34443773
    34453774// add _intel_intel_script_info to hook_intel_script_info
    3446 add_filter('intel_intel_script_info', '_intel_intel_script_info');
     3775intel_add_hook('intel_intel_script_info', '_intel_intel_script_info');
    34473776/**
    34483777 * Implements hook_intel_intel_script
     
    35503879 */
    35513880function intel_is_intel_script_enabled($name) {
     3881  if (intel_is_framework()) {
     3882    return 0;
     3883  }
    35523884  $scripts_enabled = get_option('intel_intel_scripts_enabled', array());
    35533885  if (isset($scripts_enabled[$name])) {
     
    39044236}
    39054237
    3906 function intel_add_visitor_sync_request($visitor, $delay = 0) {
     4238function intel_add_visitor_sync_request($vtk, $delay = 0) {
    39074239  //$intel = intel();
     4240  // check if visitor was passed instead of vtk
     4241  if (is_object($vtk) && !empty($vtk->vtk)) {
     4242    $vtk = $vtk->vtk;
     4243  }
    39084244  $items = get_option('intel_sync_visitor_requests', array());
    3909   if (!isset($items[$visitor->vtk])) {
     4245  if (!isset($items[$vtk])) {
    39104246    $item = new stdClass;
    39114247    $item->created = time();
    39124248    $item->run_after =  time() + $delay;
    3913     $item->vtk = $visitor->vtk;
     4249    $item->vtk = $vtk;
    39144250    $item->attempts = 0;
    3915     $items[$visitor->vtk] = $item;
     4251    $items[$vtk] = $item;
    39164252    update_option('intel_sync_visitor_requests', $items);
    39174253  }
     
    39424278 */
    39434279function intel_sync_visitordata_page($visitor = null, $count = 5) {
    3944   require_once Intel_Df:: drupal_get_path('module', 'intel') . "/includes/intel.visitor_sync.php";
     4280  intel_load_include('includes/intel.visitor_sync');
    39454281
    39464282  $output = '';
     
    39784314}
    39794315
    3980 function intel_sync_visitordata($visitor, $options = array()) {
     4316function intel_sync_visitordata(IntelVisitor $visitor, $options = array()) {
    39814317  require_once Intel_Df::drupal_get_path('module', 'intel') . "/includes/intel.visitor_sync.php";
    39824318
     
    40364372    $cq_item = $queue->claimItem();
    40374373
    4038     $func = $info['worker callback'];
    4039     $func($cq_item['data']);
    4040     $queue->deleteItem($cq_item);
     4374    if (!empty($cq_item)) {
     4375      $func = $info['worker callback'];
     4376      $func($cq_item['data']);
     4377      $queue->deleteItem($cq_item);
     4378    }
    40414379  }
    40424380}
     
    42444582}
    42454583
    4246 if ( !function_exists( 'intel_d' ) ) {
    4247   function intel_d() {
    4248     // check if user has access to this data
    4249     static $access;
    4250     if (!isset($access)) {
    4251       $access = Intel_Df::user_access('debug intel');
    4252     }
    4253     if (!$access) {
    4254       return;
    4255     }
    4256 
    4257     static $kint_aliases;
    4258     $_ = func_get_args();
    4259 
    4260     if (class_exists('Kint')) {
    4261       if (!Kint::enabled()) {
    4262         return '';
    4263       }
    4264 
    4265       // add to static aliases so the function caller info translates
    4266       if (empty($kint_aliases)) {
    4267         $kint_aliases = Kint::$aliases;
    4268         $kint_aliases['functions'][] = 'intel_d';
    4269         $kint_aliases['functions'][] = 'intel_dd';
    4270         $kint_aliases['functions'][] = 'intel_print_var';
    4271         Kint::$aliases = $kint_aliases;
    4272       }
    4273 
    4274       ob_start();
    4275       call_user_func_array(array('Kint', 'dump'), $_);
    4276       $output = ob_get_clean();
    4277       if (intel()->is_intel_admin_page()) {
    4278         Intel_Df::drupal_set_message($output);
    4279       }
    4280       else {
    4281         print $output;
    4282       }
    4283     }
    4284     else {
    4285       if (intel()->is_intel_admin_page()) {
    4286         Intel_Df::drupal_set_message(json_encode($_[0]));
    4287       }
    4288       else {
    4289         print json_encode($_[0]);
    4290       }
    4291     }
    4292   }
    4293 }
    4294 
    42954584/**
    42964585 * Implements hook_theme_info().
     
    42984587function intel_theme_info($themes = array()) {
    42994588  //$themes = array();
     4589  $themes['intel_bootstrap_card'] = array(
     4590    'variables' => array(
     4591      'header' => NULL,
     4592      'body' => NULL,
     4593      'footer' => NULL,
     4594    ),
     4595    'template' => 'intel-bootstrap-card',
     4596    'file' => 'intel.pages.php',
     4597  );
     4598  $themes['intel_bootstrap_card_block'] = array(
     4599    'variables' => array(
     4600      'value' => NULL,
     4601    ),
     4602    'template' => 'intel-bootstrap-card',
     4603    'file' => 'intel.pages.php',
     4604  );
     4605
     4606  // WP admin page element theming
    43004607  $themes['intel_page'] = array(
    43014608    'variables' => array(
     
    43864693    'file' => 'intel.pages.php',
    43874694  );
    4388   $theme['bootstrap_card'] = array(
    4389     'variables' => array(
    4390       'header' => NULL,
    4391       'body' => NULL,
    4392       'footer' => NULL,
    4393     ),
    4394     'template' => 'intel-bootstrap-card',
    4395     'file' => 'intel.pages.php',
    4396   );
    4397   $theme['bootstrap_element'] = array(
    4398     'variables' => array(
    4399       'wrapper' => NULL,
    4400       'markup' => NULL,
    4401     ),
    4402     'template' => 'intel-bootstrap-element',
    4403     'file' => 'intel.pages.php',
    4404   );
     4695
    44054696  $themes['intel_visitor_profile_block'] = array(
    44064697    'render element' => 'element',
     
    49985289}
    49995290
    5000 function intel_format_un($name) {
    5001   return str_replace('-', '_', strtolower(Intel_Df::drupal_clean_css_identifier($name)));
    5002 }
    5003 
    50045291function intel_get_iapi_url($component = '') {
    50055292  $url_obj = &Intel_Df::drupal_static( __FUNCTION__);
     5293
    50065294  if (empty($url_obj)) {
    50075295    $url = get_option('intel_l10iapi_url', '');
     
    50195307  }
    50205308
    5021   return http_build_url($url_obj);
     5309  return intel_http_build_url($url_obj);
    50225310}
    50235311
    50245312function intel_get_imapi_url($component = '') {
    50255313  $url_obj = &Intel_Df::drupal_static( __FUNCTION__);
     5314
    50265315  if (empty($url_obj)) {
    50275316    $url = get_option('intel_imapi_url', '');
    5028     if (!$url) {
     5317
     5318    if ($url) {
     5319      $a = explode('//', $url);
     5320      if (count($a) == 1) {
     5321        $url = '//' . $url;
     5322      }
     5323    }
     5324    else {
    50295325      $url = INTEL_IMAPI_URL;
    50305326    }
     5327
    50315328    $url_obj = parse_url($url);
    50325329  }
     
    50395336  }
    50405337
    5041   return http_build_url($url_obj);
     5338  return intel_http_build_url($url_obj);
    50425339}
    50435340
     
    52025499add_filter('gainwp_gapi_client_alter', 'intel_gainwp_gapi_client_alter');
    52035500
    5204 
     5501function intel_get_timezone_info() {
     5502
     5503  $timezone_info = &Intel_Df::drupal_static( __FUNCTION__, array());
     5504
     5505  if (empty($timezone_info)) {
     5506    $ga_profile = get_option('intel_ga_profile', array());
     5507
     5508    $timezone_info['timezone'] = '';
     5509    $timezone_info['timezone_abv'] = '';
     5510    $timezone_info['offset'] = 0;
     5511    $timezone_info['offset_hours'] = 0;
     5512
     5513    $timezone_info['timezone'] = $timezone_info['cms_timezone'] = get_option('timezone_string', '');
     5514    $timezone_info['offset_hours'] = $timezone_info['cms_offset_hours'] = get_option('gmt_offset', '');
     5515
     5516    if (!empty($timezone_info['cms_timezone'])) {
     5517      $dtz = new DateTimeZone($timezone_info['cms_timezone']);
     5518      $time = new DateTime("now", $dtz);
     5519      $timezone_info['timezone_abv'] = $timezone_info['cms_timezone_abv'] = $time->format('T');
     5520      $timezone_info['offset'] = $timezone_info['cms_offset'] = $dtz->getOffset($time);
     5521      $timezone_info['offset_hours'] = $timezone_info['cms_offset_hours'] = $timezone_info['cms_offset'] / 60 / 60;
     5522    }
     5523    else if ($timezone_info['cms_offset_hours'] != '' ) {
     5524      $timezone_info['offset_hours'] = $timezone_info['cms_offset_hours'] = (int) $timezone_info['cms_offset_hours'];
     5525      $timezone_info['offset'] = $timezone_info['cms_offset'] = $timezone_info['cms_offset_hours'] * 60 * 60;
     5526    }
     5527    else {
     5528      $timezone_info['cms_offset_hours'] = $timezone_info['cms_offset'] = 0;
     5529    }
     5530
     5531    if (!empty($ga_profile['timezone'])) {
     5532      $timezone_info['timezone'] = $timezone_info['ga_timezone'] = $ga_profile['timezone'];
     5533      $dtz = new DateTimeZone($timezone_info['ga_timezone']);
     5534      $time = new DateTime("now", $dtz);
     5535      $timezone_info['timezone_abv'] = $timezone_info['ga_timezone_abv'] = $time->format('T');
     5536      $timezone_info['offset'] = $timezone_info['ga_offset'] = $dtz->getOffset($time);
     5537      $timezone_info['offset_hours'] = $timezone_info['ga_offset_hours'] = $timezone_info['ga_offset'] / 60 / 60;
     5538    }
     5539  }
     5540
     5541  return $timezone_info;
     5542}
     5543
     5544
  • intelligence/trunk/intel.pages.php

    r1827302 r2947915  
    104104    $variables['messages'] = Intel_Df::drupal_get_messages();
    105105  }
     106
     107}
     108
     109function template_process_intel_bootstrap_card(&$variables) {
    106110
    107111}
  • intelligence/trunk/intel.php

    r2096810 r2947915  
    1717 * Plugin URI:        http://intelligencewp.com
    1818 * Description:       Provides behavior and visitor intelligence.
    19  * Version:           1.3.3
     19 * Version:           1.4.0
    2020 * Minimum PHP:       5.4
    2121 * Author:            LevelTen
     
    3434}
    3535
    36 define('INTEL_VER', '1.3.3');
     36//define('SCRIPT_DEBUG', true);
     37//define( 'WP_DEBUG', true );
     38//define('WP_DEBUG_LOG', 1);
     39
     40define('INTEL_VER', '1.4.0');
    3741
    3842/*******************************************
  • intelligence/trunk/public/class-intel-public.php

    r1814908 r2947915  
    9797         */
    9898
    99         // core js support functions
     99
     100        // don't add public scripts if in framework mode
     101    if (intel_is_framework()) {
     102      return;
     103    }
     104
     105    // core js support functions
    100106        wp_register_script('intel', INTEL_URL . 'js/intel.js', array('jquery'), $this->version, true);
    101107
     
    111117
    112118        // check permissions to access reports
    113         if (!Intel_Df::user_access('view all intel reports')) {
     119        if (!Intel_Df::user_access('view all intel reports') || intel_is_framework_only()) {
    114120            return;
    115121        }
  • intelligence/trunk/readme.txt

    r2250808 r2947915  
    44Tags: analytics, google analytics, marketing, metrics, roi, stats, tracking, usability
    55Requires at least: 4.5
    6 Tested up to: 5.3
    7 Stable tag: 1.3.3
     6Tested up to: 5.5
     7Stable tag: 1.3.4-dev
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    126126* Verified support for WP 5.2
    127127
     128= 1.4.0 =
     129* Added framework mode
     130* Removed Intelligence API dependency
     131* Verified support for WP 6.2
     132
    128133== Upgrade Notice ==
    129134
  • intelligence/trunk/reports/intel.ga_explorer_report.php

    r1827302 r2947915  
    77 */
    88
    9 function intel_ga_explorer_report() {
     9function intel_ga_explorer_report($form) {
     10  require_once INTEL_DIR . "includes/intel.annotation.php";
     11
    1012  $request = get_option('intel_ga_explorer_request', '');
    1113  $options = array('' => Intel_Df::t('- None -'));
     
    8688    '#default_value' => (isset($request['custom']['sort_metric'])) ? $request['custom']['sort_metric'] : '',
    8789  );
     90  $form['advanced'] = array(
     91    '#type' => 'fieldset',
     92    '#title' => Intel_Df::t('Advanced'),
     93    '#collapsable' => 1,
     94    '#collapsed' => 0,
     95  );
     96  $form['advanced']['annotation_launched'] = array(
     97    '#type' => 'textfield',
     98    '#title' => Intel_Df::t('Annotation launched'),
     99    //'#description' => Intel_Df::t('Enter a value to assign to the event when the CTA is clicked. Must be an whole number.'),
     100    '#default_value' => (isset($request['custom']['annotation_launched'])) ? $request['custom']['annotation_launched'] : '',
     101  );
     102  $options = intel_annotation_period_options();
     103  $form['advanced']['annotation_timeframe'] = array(
     104    '#type' => 'select',
     105    '#title' => Intel_Df::t('Annotation timeframe'),
     106    //'#description' => Intel_Df::t('Enter a value to assign to the event when the CTA is clicked. Must be an whole number.'),
     107    '#options' => $options,
     108    '#default_value' => (isset($request['custom']['annotation_timeframe'])) ? $request['custom']['annotation_timeframe'] : '',
     109  );
     110  $options = array(
     111    'a' => Intel_Df::t('After'),
     112    'b' => Intel_Df::t('Before'),
     113  );
     114  $form['advanced']['annotation_variant'] = array(
     115    '#type' => 'select',
     116    '#title' => Intel_Df::t('Annotation variant'),
     117    //'#description' => Intel_Df::t('Enter a value to assign to the event when the CTA is clicked. Must be an whole number.'),
     118    '#options' => $options,
     119    '#default_value' => (isset($request['custom']['annotation_variant'])) ? $request['custom']['annotation_variant'] : '',
     120  );
    88121  $form['markup2'] = array(
    89122    '#type' => 'markup',
     
    123156    '#value' => 'Submit',
    124157  );
     158  $items = array();
     159  $items[] = Intel_Df::l(Intel_Df::t('GA Query Explorer'), 'https://ga-dev-tools.appspot.com/query-explorer');
     160  $items[] = Intel_Df::l(Intel_Df::t('GA Dimensions & Metrics Explorer'), 'https://ga-dev-tools.appspot.com/dimensions-metrics-explorer/');
     161  $form['markup_reference'] = array(
     162    '#type' => 'markup',
     163    '#markup' => '<br><br><h4>' . Intel_Df::t('Tools &amp; Reference') . '</h4>' . Intel_Df::theme('item_list', array('items' => $items)),
     164  );
    125165  $form['markup3'] = array(
    126166    '#type' => 'markup',
     
    143183    if (!empty($request['custom']['metrics'])) {
    144184      $req['metrics'] = array_merge($req['metrics'], $request['custom']['metrics']);
     185    }
     186
     187    if (!empty($req['annotation_launched'])) {
     188      $timeframe = (int)$req['annotation_timeframe'];
     189
     190      $timestamp_a0 = strtotime($req['annotation_launched']);
     191      $timestamp_b0 = $timestamp_a0 - (60 * 60 * 168);
     192      if ($timeframe > 168) {
     193        $timestamp_b0 = $timestamp_a0 - (60 * 60 * $timeframe);
     194      }
     195
     196      $timestamp_b0 = $timestamp_a0 - (60 * 60 * 168);
     197      if ($timeframe > 168) {
     198        $timestamp_b0 = $timestamp_a0 - (60 * 60 * $timeframe);
     199      }
     200
     201      $timestamp_a1 = $timestamp_a0 + (60 * 60 * $timeframe);
     202      $timestamp_b1 = $timestamp_b0 + (60 * 60 * $timeframe);
     203
     204      if ($req['annotation_variant'] == 'b') {
     205        $dates = _intel_get_report_dates(date('YmdHi', $timestamp_b0), date('YmdHi', $timestamp_b1), 1);
     206      }
     207      else {
     208        $dates = _intel_get_report_dates(date('YmdHi', $timestamp_a0), date('YmdHi', $timestamp_a1), 1);
     209      }
     210
     211      $dates['ga_start_date_hour_minute'] = date('YmdHi', $dates['ga_start_date']);
     212      $dates['ga_start_date_readable'] = date('D m/d/Y H:i', $dates['ga_start_date']);
     213      $dates['ga_end_date_hour_minute'] = date('YmdHi', $dates['ga_end_date']);
     214      $dates['ga_end_date_readable'] = date('D m/d/Y H:i', $dates['ga_end_date']);
     215      $tzi = $dates['timezone_info'];
     216
     217      //intel_d("Annotation datetime: {$dates['ga_start_date_readable']} ({$tzi['ga_timezone_abv']}) - {$dates['ga_end_date_readable']} ({$tzi['ga_timezone_abv']})");
     218
     219      if (!isset($req['filters'])) {
     220        $req['filters'] = '';
     221      }
     222      $req['filters'] .= (!empty($req['filters']) ? ';' : '') . LevelTen\Intel\GAModel::formatGtRegexFilter('ga:dateHourMinute', date('ymdHi', $dates['ga_start_date']), '', array('fixed_width' => 1, 'prefix' => '20'));
     223      $req['filters'] .= (!empty($req['filters']) ? ';' : '') . LevelTen\Intel\GAModel::formatLtRegexFilter('ga:dateHourMinute', date('ymdHi', $dates['ga_end_date']), '', array('fixed_width' => 1, 'prefix' => '20'));
     224
    145225    }
    146226
     
    220300}
    221301
     302function intel_ga_explorer_report_validate($form, &$form_state) {
     303  $values = &$form_state['values'];
     304
     305  $ts = strtotime($values['annotation_launched']);
     306
     307  if (!is_numeric($ts)) {
     308    $msg = Intel_Df::t('Annotation launced is invalid. Please provide a time in a valid format.');
     309    form_set_error('annotation_launched', $msg);
     310  }
     311}
     312
    222313function intel_ga_explorer_report_submit($form, &$form_state) {
    223314  $values = $form_state['values'];
     
    244335    'end_date' => '',
    245336    'max_results' => '',
     337    'annotation_launched' => '',
     338    'annotation_timeframe' => '',
     339    'annotation_variant' => '',
    246340  );
    247341  $d = $values['dimensions'];
     
    267361  $request['custom']['end_date'] = strtotime(str_replace("'", '', $values['end_date']));
    268362  $request['custom']['max_results'] = str_replace("'", '', $values['max_results']);
     363  $request['custom']['annotation_launched'] = str_replace("'", '', $values['annotation_launched']);
     364  $request['custom']['annotation_timeframe'] = str_replace("'", '', $values['annotation_timeframe']);
     365  $request['custom']['annotation_variant'] = str_replace("'", '', $values['annotation_variant']);
    269366  $request['realtime_mode'] = str_replace("'", '', $values['realtime_mode']);
    270367
     
    273370
    274371function intel_ga_explorer_presets() {
     372
     373  intel_include_library_file('ga/class.ga_model.php');
     374
    275375  $presets = array();
    276376
     
    367467  $presets['entrances'] = array(
    368468    'title' => Intel_Df::t('Entrances (no dimensions)'),
    369     'metrics' => array('ga:entrances', 'ga:pageviewsPerSession', 'ga:timeOnPage', 'ga:bounces', 'ga:goalValueAll', 'ga:goalCompletionsAll'),
     469    'metrics' => array('ga:entrances', 'ga:pageviews', 'ga:uniquePageviews', 'ga:timeOnPage', 'ga:bounces', 'ga:goalValueAll', 'ga:goalCompletionsAll'),
    370470  );
    371471
  • intelligence/trunk/reports/intel.report_scorecard.php

    r1827302 r2947915  
    9191  $ga_data->setRequestSetting('details', 1);
    9292  $ga_data->setRequestDefaultParam('max_results', 10 *  ($number_of_days+1));
     93  $ga_data->setDebug(1);
    9394  $ga_data->loadFeedData('pageviews_events_valued', 'date', 1);
     95  $ga_data->setDebug(0);
    9496
    9597  //d($ga_data->data);
     
    164166  }
    165167  $d = $ga_data->data;
    166 
    167   //intel_d($d['date']);
    168168
    169169  if (!empty($path)) {
  • intelligence/trunk/templates/intel-bootstrap-card.tpl.php

    r1653685 r2947915  
    3131  <?php endif; ?>
    3232  <?php if ($body): ?>
    33     <div<?php print !empty($body_attributes) ? $body_attributes : ' class="card-block"'; ?>>
    34       <?php print $body; ?>
    35     </div>
     33    <?php print $body; ?>
    3634  <?php endif; ?>
    3735  <?php if ($footer): ?>
  • intelligence/trunk/vendor/levelten/intel/class.apiclient.php

    r2018028 r2947915  
    7676    }
    7777    if (!empty($_GET['debug'])) {
    78       Debug::printVar($url);
    79       Debug::printVar($params);
    80       Debug::printVar($data);
     78      //Debug::printVar($url);
     79      //Debug::printVar($params);
     80      //Debug::printVar($data);
    8181    }
    8282    if ($this->apiUrlCallMethod == 'none') {
     
    162162      }
    163163      $ret = json_decode($response, true);
     164      if (!empty($_GET['debug'])) {
     165        //Debug::printVar($ret);
     166      }
    164167      if (empty($ret['status'])) {
    165168        $msg = !empty($ret['message']) ? $ret['message'] : $response;
  • intelligence/trunk/vendor/levelten/intel/class.visitor.php

    r2287888 r2947915  
    188188    if (isset($_SESSION) && isset($_SESSION['l10i_cookie']) && is_array($_SESSION['l10i_cookie'])) {
    189189      self::$cookieStrings += $_SESSION['l10i_cookie'];
     190      unset($_SESSION['l10i_cookie']);
    190191    }
    191192  }
  • intelligence/trunk/vendor/levelten/intel/ga/class.ga_model.php

    r1713257 r2947915  
    345345          $gafilters['visitor'][] = "ga:{$a[0]}==" . $a[1];
    346346        }
    347 
    348347      }
    349348    }
     
    355354      //$ga_segments['visitor-attr'] = "dynamic::ga:dimension3=" . $query;
    356355    }
     356
     357    if (!empty($filters['datetime'])) {
     358      $gafilters['datetime'] = array();
     359      foreach ($filters['datetime'] AS $i => $filter) {
     360        $a = explode(":", $filter);
     361        if ($a[0] == 'dateHourMinute') {
     362          $f = '';
     363          $ts = explode('-', $a[1]);
     364          $f .= $this->formatGtRegexFilter('ga:dateHourMinute', substr($ts[0], 2), '', array('fixed_width' => 1, 'prefix' => '20'));
     365          $f .= ';';
     366          $f .= $this->formatLtRegexFilter('ga:dateHourMinute', substr($ts[1], 2), '', array('fixed_width' => 1, 'prefix' => '20'));
     367          $gafilters['datetime'][] = $f;
     368        }
     369      }
     370    }
     371
    357372    $this->gaFilters = array(
    358373      'filters' => $gafilters,
     
    973988
    974989    $segment_scope = ($indexBy == 'visitor') ? 'users' : 'sessions';
     990//intel_d($type);
     991//intel_d($types);
     992//intel_d($gaFilters);
    975993    foreach ($gaFilters AS $filter_type => $gafarr) {
    976994      foreach ($gafarr AS $i => $filt) {
    977 
    978         if ($types[0] == 'entrances') {
    979 
    980           // traffic sources cannot be used in segments, make exception
    981           if ($filter_type == 'trafficsource') {
    982             $filters[] = $filt;
    983           }
    984           elseif ($filter_type == 'page') {
    985             // change default of pagePath to landingPagePath
    986             $filters[] = str_replace('pagePath', 'landingPagePath', $filt);
    987           }
    988           else {
    989             if ($indexBy == 'trafficsources_intersite') {
    990               $notfilt = str_replace('=@', '!@', $filt);
    991               $notfilt = str_replace('==', '!=', $notfilt);
    992               $notfilt = str_replace('=~', '!~', $notfilt);
    993               $segments[] = 'sessions::sequence::^' . $notfilt . ';->>' . $filt;
     995        if ($filter_type == 'datetime') {
     996          $filters[] = $filt;
     997        }
     998        else {
     999          if ($types[0] == 'entrances') {
     1000            // traffic sources cannot be used in segments, make exception
     1001            if ($filter_type == 'trafficsource') {
     1002              $filters[] = $filt;
     1003            }
     1004            elseif ($filter_type == 'page') {
     1005              // change default of pagePath to landingPagePath
     1006              $filters[] = str_replace('pagePath', 'landingPagePath', $filt);
    9941007            }
    9951008            else {
    996               // if filter is page_group, don't apply as segment
    997               if ($filter_type == 'page-attr' && ($filt == $this->gaSubsite)) {
     1009              if ($indexBy == 'trafficsources_intersite') {
     1010                $notfilt = str_replace('=@', '!@', $filt);
     1011                $notfilt = str_replace('==', '!=', $notfilt);
     1012                $notfilt = str_replace('=~', '!~', $notfilt);
     1013                $segments[] = 'sessions::sequence::^' . $notfilt . ';->>' . $filt;
     1014              }
     1015              else {
     1016                // if filter is page_group, don't apply as segment
     1017                if ($filter_type == 'page-attr' && ($filt == $this->gaSubsite)) {
     1018                  $filters[] = $filt;
     1019                }
     1020                else {
     1021
     1022                  if ($filter_type == 'event') {
     1023                    $segments[] = $segment_scope . '::sequence::' . $filt;
     1024                  }
     1025                  else {
     1026                    $segments[] = 'sessions::sequence::^' . $filt;
     1027                  }
     1028
     1029                }
     1030
     1031                /*
     1032                if ($context_mode == 'subsite') {
     1033                  $filters[] = $filt;
     1034                }
     1035                */
     1036              }
     1037            }
     1038          }
     1039          elseif ($types[0] == 'sessions') {
     1040            if ($filter_type == 'page-attr' && ($filt == $this->gaSubsite)) {
     1041              if ($type != 'sessions') {
    9981042                $filters[] = $filt;
    9991043              }
     1044            }
     1045            else {
     1046              if ($type == 'sessions') {
     1047                $segments[] = 'sessions::sequence::' . $filt;
     1048              }
     1049              elseif($types[1] == 'events') {
     1050                if (isset($types[2]) && $types[2] == 'valued') {
     1051                  $segments[] = 'sessions::sequence::' . $filt . ';->>ga:eventCategory=~\!$';
     1052                }
     1053              }
     1054              elseif($types[1] == 'goals') {
     1055                $segments[] = 'sessions::sequence::' . $filt . ';->>ga:eventCategory=~\+$';
     1056              }
     1057            }
     1058          }
     1059          // pageview request type
     1060          else {
     1061            if ($filter_type == 'event') {
     1062              if ($indexBy == 'trafficsource' || $indexBy == 'visitor' || $indexBy == 'visit') {
     1063                $segments[] = $segment_scope . '::condition::' . $filt;
     1064              }
    10001065              else {
    1001 
    1002                 if ($filter_type == 'event') {
    1003                   $segments[] = $segment_scope . '::sequence::' . $filt;
    1004                 }
    1005                 else {
    1006                   $segments[] = 'sessions::sequence::^' . $filt;
    1007                 }
    1008 
    1009               }
    1010 
    1011               /*
    1012               if ($context_mode == 'subsite') {
    10131066                $filters[] = $filt;
    10141067              }
    1015               */
    1016             }
    1017           }
    1018         }
    1019         elseif ($types[0] == 'sessions') {
    1020           if ($filter_type == 'page-attr' && ($filt == $this->gaSubsite)) {
    1021             if ($type != 'sessions') {
    1022               $filters[] = $filt;
    1023             }
    1024           }
    1025           else {
    1026             if ($type == 'sessions') {
    1027               $segments[] = 'sessions::sequence::' . $filt;
    1028             }
    1029             elseif($types[1] == 'events') {
    1030               if (isset($types[2]) && $types[2] == 'valued') {
    1031                 $segments[] = 'sessions::sequence::' . $filt . ';->>ga:eventCategory=~\!$';
    1032               }
    1033             }
    1034             elseif($types[1] == 'goals') {
    1035               $segments[] = 'sessions::sequence::' . $filt . ';->>ga:eventCategory=~\+$';
    1036             }
    1037           }
    1038         }
    1039         // pageview request type
    1040         else {
    1041           if ($filter_type == 'event') {
    1042             if ($indexBy == 'trafficsource' || $indexBy == 'visitor' || $indexBy == 'visit') {
    1043               $segments[] = $segment_scope . '::condition::' . $filt;
    10441068            }
    10451069            else {
    10461070              $filters[] = $filt;
    10471071            }
    1048           }
    1049           else {
    1050             $filters[] = $filt;
    10511072          }
    10521073        }
     
    22642285   * @param $number
    22652286   * @param string $key
     2287   * @param array options
    22662288   * @return string
    22672289   */
    2268   static function formatGtRegexFilter($param, $number, $key = '') {
     2290  static function formatGtRegexFilter($param, $number, $key = '', $options = array()) {
    22692291    $k = ($key) ? "&$key=" : "^";
    22702292    $end = ($key) ? '&' : "$";
     2293
    22712294    $nstr = (string)$number;
    22722295    $num_arr = str_split($nstr);
    22732296    $digits = count($num_arr);
    2274     $regex = $param . '=~' . $k . '\d{' . ($digits+1) . '\,}' . $end;
     2297
     2298    $prefix = '';
     2299    $prefix_digits = 0;
     2300    if (!empty($options['prefix'])) {
     2301      $prefix = $options['prefix'];
     2302      $nstr = (string)$prefix;
     2303      $prefix_num_arr = str_split($nstr);
     2304      $prefix_digits = count($prefix_num_arr);
     2305    }
     2306
     2307    $regex = '';
     2308    if (empty($options['fixed_width'])) {
     2309      $regex .= $param . '=~' . $k . '\d{' . ($prefix_digits + $digits + 1) . '\,}' . $end;
     2310    }
     2311
    22752312    $p = '';
    22762313    foreach ($num_arr AS $i => $digit) {
    22772314      $digit = (int)$digit;
    22782315      if ($digit < 9) {
    2279         $regex .= ',' . $param .  '=~' . $k . $p;
     2316        $regex .= ($regex ? ',' : '') . $param .  '=~'  . $k . $prefix . $p;
    22802317        if ((1 + $digit) == 9) {
    22812318          $regex .= '9';
     
    23032340   * @return string
    23042341   */
    2305   static function formatGtEqRegexFilter($param, $number, $key = '') {
     2342  static function formatGtEqRegexFilter($param, $number, $key = '', $options = array()) {
    23062343    $regex = '';
    23072344    $k = ($key) ? "&$key=" : "^";
     
    23232360    }
    23242361
    2325     $regex .= $param . '=~' . $k . '\d{' . ($digits + 1) . '\,}' . $end;
     2362    $prefix = '';
     2363    $prefix_digits = 0;
     2364    if (!empty($options['prefix'])) {
     2365      $prefix = $options['prefix'];
     2366      $nstr = (string)$prefix;
     2367      $prefix_num_arr = str_split($nstr);
     2368      $prefix_digits = count($prefix_num_arr);
     2369    }
     2370
     2371    $regex = '';
     2372    if (empty($options['fixed_width'])) {
     2373      $regex .= $param . '=~' . $k . '\d{' . ($prefix_digits + $digits + 1) . '\,}' . $end;
     2374    }
     2375
     2376
    23262377    $p = '';
    23272378    $rs = $nstr;
     
    23342385      if ($r > 0) {
    23352386        if ($digit < 9) {
    2336           $regex .= ',' . $param . '=~' . $k . $p;
     2387          $regex .= ',' . $param . '=~' . $k . $prefix . $p;
    23372388          if ((1 + $digit) == 9) {
    23382389            $regex .= '9';
     
    23462397      else {
    23472398        if ($digit > 0) {
    2348           $regex .= ',' . $param . '=~' . $k . $p;
     2399          $regex .= ',' . $param . '=~' . $k . $prefix . $p;
    23492400          if ($digit == 9) {
    23502401            $regex .= '9';
     
    23912442  }
    23922443
    2393   static function formatLtRegexFilter($param, $number, $key = '') {
     2444  static function formatLtRegexFilter($param, $number, $key = '', $options = array()) {
    23942445    $end = ($key) ? '&' : "$";
    23952446    $nstr = (string)$number;
     2447    if (isset($options['prefix'])) {
     2448      $nstr = (string)$options['prefix'] . $nstr;
     2449    }
    23962450    $num_arr = str_split($nstr);
    23972451    $digits = count($num_arr);
     
    24262480    }
    24272481    if (($digits) > 1) {
    2428       $regex .= (($regex) ? ',' : '') . $param . '=~^\d{0\,' . ($digits-1) . '}' . $end;
     2482      $regex .= (($regex) ? ',' : '') . $param . '=~^\d{0\,' . ($digits - 1) . '}' . $end;
    24292483    }
    24302484
     
    24392493   * @return string
    24402494   */
    2441   static function formatLtEqRegexFilter($param, $number, $key = '') {
     2495  static function formatLtEqRegexFilter($param, $number, $key = '', $options = array()) {
    24422496    $end = ($key) ? '&' : "$";
    24432497    $nstr = (string)$number;
  • intelligence/trunk/vendor/levelten/intel/js/l10intel_admin.js

    r1756687 r2947915  
    2626
    2727    this.bindEventCallback = function bindEventCallback(evtDef, $target) {
     28//console.log('admin:bindEventCallback()', evtDef, $target);
    2829        var evt = {};
    2930        var options = {
  • intelligence/trunk/vendor/levelten/intel/js/l10intel_formtracker.js

    r1814908 r2947915  
    88    var ths = {};
    99
    10     this.formDefs = {};
     10    this.formDefs = [];
     11    this.formDefsIndex = {};
    1112
    1213
    1314    this.init = function init() {
    1415        var ths = this;
    15         $('form').not('.formtracker-0').on('submit', ths.eventHandler);
     16        //$('form').not('.formtracker-0').on('submit', ths.eventHandler);
    1617        //$('a').on('mouseover', {eventType: 'click'}, ths.eventHandler); // for testing event sends
    1718    };
    1819
    19     ths.trackForm = function trackForm(def) {
     20    this.trackForm = function trackForm(def) {
    2021        if (ioq.isArray(def)) {
    2122            for (var i = 0; i < def.length; i++) {
    22                 ths.trackFormInit(def[i]);
    23             }
    24         }
    25         else {
    26             ths.trackFormInit(def);
    27         }
    28     };
    29 
    30     ths.trackFormInit = function trackFormInit(def) {
     23                this.trackFormInit(def[i]);
     24            }
     25        }
     26        else {
     27            this.trackFormInit(def);
     28        }
     29    };
     30
     31    this.trackFormInit = function trackFormInit(def) {
    3132        //console.log('trackFormInit()');
    3233        //console.log(def);
     34        var ths = _ioq.plugins.formtracker;
    3335
    3436        var $obj, $this, $onObj, enable = 1, $dataField, def2;
     37        var key = def.key || def.formId;
     38
    3539        if (ioq.isNull(def)) {
    3640            def = {};
    3741        }
    38         if (!ioq.isNull(def.landingpage)) {
    39             def.landingpage = ths.trackLandingpage(def.landingpage);
     42        if (!ioq.isNull(def.landingpage) && !ioq.isNull(ioq.plugins.convtracker)) {
     43            def.landingpage = ioq.plugins.convtracker.trackLandingpage(def.landingpage);
    4044        }
    4145
     
    8690            io('event', evtDef);
    8791        }
     92        if ($onObj.length && def.trackSubmission) {
     93            //delete def.trackView;
     94            evtDef = ioq.objectMerge({}, def);
     95            evtDef.eventCategory = 'Form submission';
     96            evtDef.onEvent = 'submission';
     97            evtDef.eid = 'formSubmission';
     98            evtDef.nonInteraction = 1;
     99            io('event', evtDef);
     100        }
    88101
    89102        /* Disabling logic until full conversion tracking can be implemented
     
    131144        }
    132145
     146
     147        if (key) {
     148            if (!ths.formDefsIndex[key]) {
     149                ths.formDefsIndex[key] = ths.formDefs.length;
     150                ths.formDefs.push(def);
     151            }
     152        }
     153
    133154        return def;
    134155
    135156    };
    136157
    137     ths.processFormSpecialFields = function (def, $obj, event) {
     158    this.processFormSpecialFields = function (def, $obj, event) {
    138159        var pf = 'io';
    139160        if ($obj.is('form')) {
     
    196217    this.init();
    197218
    198     return ths;
    199219}
    200220
  • intelligence/trunk/vendor/levelten/intel/js/l10intel_linktracker.js

    r1904936 r2947915  
    3030    this.linkTypeDefs.download = {
    3131        title: 'Download link',
    32         track: 1
     32        track: 1,
     33        trackFileExtension: 'zip|exe|dmg|pdfx|doc.*|xls.*|ppt.*|mp3|txt|rar|wma|mov|avi|wmv|flv|wav|png|jpg|jpeg|gif',
    3334    };
    3435    this.linkTypeDefs.mailto = {
     
    115116
    116117    this.addHrefType = function addHrefType(name, obj) {
    117       this.hrefTypeDefs[name] = obj;
     118        this.hrefTypeDefs[name] = obj;
    118119    };
    119120
     
    159160
    160161        f.hrefType = '';
    161 
    162162        if (!f.hrefType) {
    163             var downloadPattern = /\.(zip|exe|dmg|pdf|doc.*|xls.*|ppt.*|mp3|txt|rar|wma|mov|avi|wmv|flv|wav|png|jpg|jpeg|gif)$/i;
     163            //var downloadPattern = /\.(zip|exe|dmg|pdf|doc.*|xls.*|ppt.*|mp3|txt|rar|wma|mov|avi|wmv|flv|wav|png|jpg|jpeg|gif)$/i;
     164            var downloadPattern = new RegExp('\\.(' + f.linkTypeDefs['download']['trackFileExtension'] + ')$', 'i');
    164165
    165166            f.hrefObj = _ioq.parseUrl(f.href);
     
    197198        linkDef = f.linkTypeDefs[f.linkType] || {};
    198199        if (linkDef.track || f.$obj.objSettings['link-track'] || f.$obj.objSettings['link-' + f.eventType + '-track']) {
    199             console.log();
    200200            f.evtDef.eventCategory = linkDef.title;
    201201            if (f.eventType) {
  • intelligence/trunk/vendor/levelten/intel/libs/class.debug.php

    r1653685 r2947915  
    2020   */
    2121  static public function printVar($var, $mode = 0) {
    22     if (function_exists('intel_print_var')) {
    23       intel_print_var($var, $mode);
    24     }
    25     else {
    26       if ($mode == 1) {
    27         return print_r($var, 1);
     22    if (function_exists('intel_is_debug') && intel_is_debug()) {
     23      if (function_exists('intel_print_var')) {
     24        intel_print_var($var, $mode);
    2825      }
    2926      else {
    30         print_r($var);
     27        if ($mode == 1) {
     28          return print_r($var, 1);
     29        }
     30        else {
     31          print_r($var);
     32        }
    3133      }
    3234    }
Note: See TracChangeset for help on using the changeset viewer.