Changeset 2947915
- Timestamp:
- 08/04/2023 11:49:49 PM (3 years ago)
- Location:
- intelligence/trunk
- Files:
-
- 84 added
- 33 edited
-
admin/class-intel-admin.php (modified) (8 diffs)
-
admin/intel.admin_annotation.php (added)
-
admin/intel.admin_config.php (modified) (19 diffs)
-
admin/intel.admin_framework.php (added)
-
admin/intel.admin_setup.php (modified) (1 diff)
-
admin/intel.admin_util.php (modified) (9 diffs)
-
admin/intel.admin_visitor.php (modified) (2 diffs)
-
css/intel.intel_script_admin.css (added)
-
includes/class-intel-activator.php (modified) (1 diff)
-
includes/class-intel-annotation-controller.php (added)
-
includes/class-intel-annotation-list-table.php (added)
-
includes/class-intel-annotation.php (added)
-
includes/class-intel-db.php (added)
-
includes/class-intel-df.php (modified) (17 diffs)
-
includes/class-intel-form.php (modified) (1 diff)
-
includes/class-intel-tracker.php (modified) (8 diffs)
-
includes/class-intel-visitor-page.php (modified) (1 diff)
-
includes/class-intel.php (modified) (8 diffs)
-
includes/intel.IntelAnnotation.php (added)
-
includes/intel.IntelAnnotationController.php (added)
-
includes/intel.IntelEntity.php (added)
-
includes/intel.IntelEntityController.php (added)
-
includes/intel.IntelLog.php (added)
-
includes/intel.IntelLogController.php (added)
-
includes/intel.IntelSubmission.php (added)
-
includes/intel.IntelSubmissionController.php (added)
-
includes/intel.IntelVisitor.php (added)
-
includes/intel.IntelVisitorController.php (added)
-
includes/intel.annotation.php (added)
-
includes/intel.common.php (added)
-
includes/intel.common_wp.php (added)
-
includes/intel.d7_core.php (added)
-
includes/intel.d7_db_query.php (added)
-
includes/intel.demo.php (modified) (1 diff)
-
includes/intel.ga.php (modified) (35 diffs)
-
includes/intel.imapi.php (modified) (2 diffs)
-
includes/intel.page_alter.php (modified) (46 diffs)
-
includes/intel.reports.php (modified) (1 diff)
-
includes/intel.visitor_sync.php (modified) (2 diffs)
-
intel.install.php (modified) (1 diff)
-
intel.module.php (modified) (35 diffs)
-
intel.pages.php (modified) (1 diff)
-
intel.php (modified) (2 diffs)
-
js/l10i.js (added)
-
js/l10i.min.js (added)
-
public/class-intel-public.php (modified) (2 diffs)
-
readme.txt (modified) (2 diffs)
-
reports/intel.ga_explorer_report.php (modified) (9 diffs)
-
reports/intel.report_scorecard.php (modified) (2 diffs)
-
templates/intel-bootstrap-card-block.tpl.php (added)
-
templates/intel-bootstrap-card.tpl.php (modified) (1 diff)
-
vendor/kint (added)
-
vendor/kint/.gitignore (added)
-
vendor/kint/Kint.class.php (added)
-
vendor/kint/LICENCE (added)
-
vendor/kint/README.md (added)
-
vendor/kint/composer.json (added)
-
vendor/kint/config.default.php (added)
-
vendor/kint/decorators (added)
-
vendor/kint/decorators/cli.php (added)
-
vendor/kint/decorators/concise.php (added)
-
vendor/kint/decorators/plain.php (added)
-
vendor/kint/decorators/rich.php (added)
-
vendor/kint/decorators/whitespace.php (added)
-
vendor/kint/examples (added)
-
vendor/kint/examples/overview.php (added)
-
vendor/kint/parsers (added)
-
vendor/kint/parsers/custom (added)
-
vendor/kint/parsers/custom/classmethods.php (added)
-
vendor/kint/parsers/custom/classstatics.php (added)
-
vendor/kint/parsers/custom/color.php (added)
-
vendor/kint/parsers/custom/fspath.php (added)
-
vendor/kint/parsers/custom/json.php (added)
-
vendor/kint/parsers/custom/microtime.php (added)
-
vendor/kint/parsers/custom/objectiterateable.php (added)
-
vendor/kint/parsers/custom/splfileinfo.php (added)
-
vendor/kint/parsers/custom/splobjectstorage.php (added)
-
vendor/kint/parsers/custom/timestamp.php (added)
-
vendor/kint/parsers/custom/xml.php (added)
-
vendor/kint/parsers/objects (added)
-
vendor/kint/parsers/objects/smarty.php (added)
-
vendor/kint/parsers/parser.class.php (added)
-
vendor/kint/scripts (added)
-
vendor/kint/scripts/source.reg (added)
-
vendor/kint/scripts/source.vbs (added)
-
vendor/kint/view (added)
-
vendor/kint/view/compiled (added)
-
vendor/kint/view/compiled/main (added)
-
vendor/kint/view/compiled/main/aante-light.css (added)
-
vendor/kint/view/compiled/main/kint.js (added)
-
vendor/kint/view/compiled/main/original.css (added)
-
vendor/kint/view/compiled/main/solarized-dark.css (added)
-
vendor/kint/view/compiled/main/solarized.css (added)
-
vendor/kint/view/compiled/modular-window (added)
-
vendor/kint/view/compiled/modular-window/kint.js (added)
-
vendor/kint/view/compiled/modular-window/original.css (added)
-
vendor/kint/view/js (added)
-
vendor/kint/view/js/main.js (added)
-
vendor/kint/view/js/modular-window.js (added)
-
vendor/kint/view/less (added)
-
vendor/kint/view/less/main.less (added)
-
vendor/kint/view/less/modular-window.less (added)
-
vendor/kint/view/themes (added)
-
vendor/kint/view/themes/main (added)
-
vendor/kint/view/themes/main/aante-light.less (added)
-
vendor/kint/view/themes/main/original.less (added)
-
vendor/kint/view/themes/main/solarized-dark.less (added)
-
vendor/kint/view/themes/main/solarized.less (added)
-
vendor/kint/view/themes/modular-window (added)
-
vendor/kint/view/themes/modular-window/original.less (added)
-
vendor/levelten/intel/class.apiclient.php (modified) (2 diffs)
-
vendor/levelten/intel/class.visitor.php (modified) (1 diff)
-
vendor/levelten/intel/ga/class.ga_model.php (modified) (11 diffs)
-
vendor/levelten/intel/js/l10intel_admin.js (modified) (1 diff)
-
vendor/levelten/intel/js/l10intel_formtracker.js (modified) (4 diffs)
-
vendor/levelten/intel/js/l10intel_linktracker.js (modified) (4 diffs)
-
vendor/levelten/intel/libs/class.debug.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
intelligence/trunk/admin/class-intel-admin.php
r1827302 r2947915 189 189 } 190 190 191 }192 193 public function site_menu( ) {191 } 192 193 public function site_menu($network_site_menu = FALSE) { 194 194 global $wp_version; 195 195 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 196 203 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 } 206 223 207 224 // for return_type json, page needs to be called earlier than standard menu routing … … 245 262 $q = ''; 246 263 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 } 257 274 } 258 275 if ($_GET['page'] == 'intel_reports') { … … 299 316 ); 300 317 } 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 } 301 328 if (isset($_GET['q'])) { 302 329 $q = $_GET['q']; … … 317 344 'submission', 318 345 'visitor', 346 'annotation', 319 347 ); 320 348 $this->args = $path_args = explode('/', $q); … … 354 382 } 355 383 } 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 } 356 396 } 357 397 else { … … 399 439 ); 400 440 } 441 if ($path_args[0] == 'annotation') { 442 $breadcrumbs[] = array( 443 'text' => $entity->label(), 444 'path' => Intel_Df::url($entity->uri()), 445 ); 446 } 401 447 } 402 448 } … … 406 452 $load_type = ''; 407 453 $load_title = ''; 454 $entity_title = ''; 408 455 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 } 463 515 } 464 516 } … … 749 801 // Don't show the connect notice anywhere but the plugins.php after activating 750 802 $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 ) { 752 804 $l_options = Intel_Df::l_options_add_class('btn btn-info'); 753 805 $output .= ' <div class="panel panel-info m-t-1">'; -
intelligence/trunk/admin/intel.admin_config.php
r2018028 r2947915 16 16 //global $base_url; 17 17 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'); 19 20 20 21 // check dependencies … … 34 35 } 35 36 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'); 37 39 38 40 $ga_data_source = intel_ga_data_source(); … … 43 45 // check if imapi_property needs to be fetched 44 46 $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 ) { 46 54 if ($ga_tid && $apikey) { 47 55 $options = array( … … 49 57 'apikey' => $apikey, 50 58 ); 59 51 60 try { 52 61 $imapi_property = intel_imapi_property_get($options); 62 53 63 $op_meta['imapi_property_updated'] = time(); 54 64 } … … 57 67 unset($op_meta['imapi_property_updated']); 58 68 } 69 59 70 update_option('intel_imapi_property', $imapi_property); 60 71 update_option('intel_option_meta', $op_meta); … … 68 79 $ga_viewid = get_option('intel_ga_view', ''); 69 80 $ga_profile_base = get_option('intel_ga_profile_base', array()); 70 71 81 if (!empty($imapi_property) && (empty($ga_profile) || empty($ga_viewid))) { 72 82 $ga_profile = $imapi_property['ga_profile']; … … 160 170 161 171 162 163 164 172 /* 165 173 $form['l10iapi']['intel_ga_tid'] = array( … … 237 245 '#field_suffix' => '/', 238 246 ); 247 239 248 $options = array( 240 249 '' => Intel_Df::t('Default'), … … 771 780 function intel_admin_settings_validate($form, &$form_state) { 772 781 $values = $form_state['values']; 782 773 783 // convert string to array 774 784 parse_str($form_state['values']['intel_l10iapi_custom_params'], $params); … … 781 791 || ($values['intel_ga_tid'] != $imapi_property->intel_tid) 782 792 ) { 793 $values['intel_imapi_url'] = trim($values['intel_imapi_url']); 783 794 $options = array( 784 795 '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 787 800 try { 788 801 $form_state['intel_imapi_property'] = $imapi_property = intel_imapi_property_get($options); … … 1362 1375 1363 1376 function 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'); 1365 1379 1366 1380 … … 1368 1382 intel_sync_goals_ga_goals(); 1369 1383 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()); 1371 1385 Intel_Df::drupal_goto(Intel_Df::current_path(), $l_option); 1372 1386 } … … 1385 1399 if (isset($_GET['refresh'])) { 1386 1400 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()); 1388 1402 Intel_Df::drupal_goto(Intel_Df::current_path(), $l_option); 1389 1403 } … … 1767 1781 } 1768 1782 1769 $form _state['event'] = $event;1783 $form['#intel_event'] = $form_state['intel_event'] = $event; 1770 1784 $add = empty($event['key']); 1771 1785 $custom = (!$event || !empty($event['custom'])) ? 1 : 0; … … 2186 2200 '#type' => (1 || $custom || !empty($overridable[$key])) ? 'textarea' : 'item', 2187 2201 '#title' => Intel_Df::t('Page list'), 2188 '#default_value' => !empty($event[$key]) ? $event[$key] : 0,2202 '#default_value' => !empty($event[$key]) ? $event[$key] : '', 2189 2203 '#disabled' => !($custom || !empty($overridable[$key])), 2190 2204 '#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."), … … 2241 2255 function intel_admin_intel_event_form_validate(&$form, &$form_state) { 2242 2256 $values = $form_state['values']; 2243 $event = $form_state[' event'];2257 $event = $form_state['intel_event']; 2244 2258 $key = ''; 2245 2259 if (!empty($values['key'])) { … … 2266 2280 function intel_admin_intel_event_form_submit(&$form, &$form_state) { 2267 2281 $values = $form_state['values']; 2268 $add = empty($form_state[' event']['key']) ? 1 : 0;2282 $add = empty($form_state['intel_event']['key']) ? 1 : 0; 2269 2283 2270 2284 … … 2273 2287 } 2274 2288 else { 2275 $key = $form_state[' event']['key'];2289 $key = $form_state['intel_event']['key']; 2276 2290 } 2277 2291 … … 2301 2315 if ($add) { 2302 2316 $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'], 2304 2318 )); 2305 2319 } 2306 2320 else { 2307 2321 $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'], 2309 2323 )); 2310 2324 } -
intelligence/trunk/admin/intel.admin_setup.php
r2018028 r2947915 137 137 138 138 $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>'; 139 143 $items[] = '<div class="text-center">'; 140 144 $items[] = '<h3>' . Intel_Df::t('Results oriented Google Analytics made easy.') . '</h3>'; -
intelligence/trunk/admin/intel.admin_util.php
r2018028 r2947915 1 1 <?php 2 3 use function d7\db_query; 4 2 5 /** 3 6 * @file … … 29 32 */ 30 33 function 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 ''; 40 36 } 41 37 … … 196 192 } 197 193 198 function intel_util_log_page() { 194 function 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 258 function intel_util_log_list_page() { 199 259 $output = ''; 200 260 … … 204 264 $output .= Intel_Df::render($form); 205 265 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 206 319 return $output; 207 320 } … … 209 322 function intel_util_log_form($form, &$form_state) { 210 323 211 $watchdog_mode = get_option('intel_watchdog_mode', ''); 324 $watchdog_mode = Intel_Df::watchdog_mode(); 325 326 intel_d($watchdog_mode); 212 327 213 328 $form['settings'] = array( … … 221 336 $options = array( 222 337 '' => Intel_Df::t('None'), 223 ' log' => Intel_Df::t('Log'),338 'error_log' => Intel_Df::t('Error log'), 224 339 'db' => Intel_Df::t('Database'), 225 340 ); … … 257 372 258 373 function intel_util_log_form_submit($form, &$form_state) { 374 global $wpdb; 259 375 //intel_d($form_state); 260 376 $values = $form_state['values']; … … 262 378 263 379 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 } 265 399 Intel_Df::drupal_set_message(Intel_Df::t('Settings have been updated.')); 266 400 } 267 401 268 402 if (!empty($form_state['input']['submit_clear'])) { 403 $table_name = $wpdb->prefix . "intel_log"; 404 $delete = $wpdb->query("TRUNCATE TABLE $table_name"); 269 405 Intel_Df::drupal_set_message(Intel_Df::t('Log has been cleared.')); 270 406 } 407 } 408 409 function 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 421 function 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 451 function 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); 271 463 } 272 464 … … 526 718 527 719 $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)); 528 730 529 731 $form['data.givenName'] = array( -
intelligence/trunk/admin/intel.admin_visitor.php
r1904936 r2947915 47 47 } 48 48 } 49 dsm($prop_options);49 //dsm($prop_options); 50 50 51 51 $tax_options = array( … … 529 529 530 530 // Retrieve all profile fields and attach to $entity->content. 531 Intel _Visitor::build_content($entity);531 IntelVisitor::build_content($entity); 532 532 533 533 $build = $entity->content; -
intelligence/trunk/includes/class-intel-activator.php
r1827302 r2947915 188 188 dbDelta( $sql ); 189 189 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 190 213 } 191 214 -
intelligence/trunk/includes/class-intel-df.php
r2018028 r2947915 130 130 const MENU_CONTEXT_INLINE = 0x0002; 131 131 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; 134 143 135 144 private function __construct() { … … 158 167 159 168 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);// 163 172 $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);// 167 176 return $path; 168 177 } … … 178 187 } 179 188 } 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 } 180 348 181 349 /** … … 489 657 // The 'Location' HTTP header must be absolute. 490 658 $options['absolute'] = TRUE; 659 491 660 $url = self::url($path, $options); 492 661 … … 938 1107 } 939 1108 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 } 941 1116 942 1117 public static function format_date($time, $format = '') { … … 1027 1202 if ($options['external'] && strpos($path, '//') == FALSE) { 1028 1203 $hook_data = apply_filters('intel_url_urn_resolver', $hook_data); 1029 // check if path returned from reso ver is external1204 // check if path returned from resolver is external 1030 1205 $options['external'] = self::url_is_external($path); 1031 1206 } … … 1051 1226 } 1052 1227 1053 if (isset($options['https']) && variable_get('https', FALSE)) { 1228 //if (isset($options['https']) && variable_get('https', FALSE)) { 1229 if (isset($options['https'])) { 1054 1230 if ($options['https'] === TRUE) { 1055 1231 $path = str_replace('http://', 'https://', $path); … … 1077 1253 // The base_url might be rewritten from the language rewrite in domain mode. 1078 1254 if (!isset($options['base_url'])) { 1079 if (isset($options['https']) && variable_get('https', FALSE)) {1255 if (isset($options['https']) && get_option('https', FALSE)) { 1080 1256 if ($options['https'] === TRUE) { 1081 1257 $options['base_url'] = $base_secure_url; … … 1127 1303 $admin_page = 'intel_visitor'; 1128 1304 } 1305 elseif ($path_args[1] == 'annotations') { 1306 $admin_page = 'intel_annotation'; 1307 } 1129 1308 } 1130 1309 } … … 1134 1313 elseif($path_args[0] == 'submission') { 1135 1314 $admin_page = 'intel_admin'; 1315 } 1316 elseif($path_args[0] == 'annotation') { 1317 $admin_page = 'intel_annotation'; 1136 1318 } 1137 1319 … … 1141 1323 $is_admin_path = 1; 1142 1324 } 1143 1144 1325 1145 1326 // if path uses /wp-admin/ or /subdir/wp-admin/ format, strip off base_path_admin … … 1164 1345 if ($is_admin_path) { 1165 1346 $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 } 1166 1351 $prefix = empty($path) ? rtrim($options['prefix'], '/') : $options['prefix']; 1167 1352 } … … 1267 1452 $search = ''; 1268 1453 if (strpos($string, $k) !== FALSE) { 1454 if (!is_string($v)) { 1455 continue; 1456 } 1269 1457 if (substr($k, 1, 0) == '@' ) { 1270 1458 $v = self::check_plain($v); … … 1381 1569 // if template file, process variables via template file 1382 1570 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 1384 1578 if (file_exists($file)) { 1385 1579 $output = self::process_template($file, $variables); … … 1717 1911 public static function theme_table($variables) { 1718 1912 $defs = array( 1913 'header' => array(), 1719 1914 'rows' => array(), 1720 1915 'attributes' => array(), … … 1776 1971 // Build colgroup 1777 1972 if (is_array($cols) && count($cols)) { 1778 $output .= ' <colgroup' . Int l_Df::drupal_attributes($attributes) . '>';1973 $output .= ' <colgroup' . Intel_Df::drupal_attributes($attributes) . '>'; 1779 1974 $i = 0; 1780 1975 foreach ($cols as $col) { 1781 $output .= ' <col' . Int l_Df::drupal_attributes($col) . ' />';1976 $output .= ' <col' . Intel_Df::drupal_attributes($col) . ' />'; 1782 1977 } 1783 1978 $output .= " </colgroup>\n"; 1784 1979 } 1785 1980 else { 1786 $output .= ' <colgroup' . Int l_Df::drupal_attributes($attributes) . " />\n";1981 $output .= ' <colgroup' . Intel_Df::drupal_attributes($attributes) . " />\n"; 1787 1982 } 1788 1983 } … … 2052 2247 public static function watchdog($type, $message = '', $variables = array(), $severity = Intel_Df::WATCHDOG_NOTICE, $link = NULL) { 2053 2248 //$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 } 2061 2307 } 2062 2308 -
intelligence/trunk/includes/class-intel-form.php
r2018028 r2947915 1198 1198 // An unchecked checkbox has a #value of integer 0, different than string 1199 1199 // '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'])); 1201 1201 $is_empty_string = (is_string($elements['#value']) && strlen(trim($elements['#value'])) == 0); 1202 1202 $is_empty_value = ($elements['#value'] === 0); -
intelligence/trunk/includes/class-intel-tracker.php
r1814908 r2947915 36 36 protected $pushes; 37 37 38 public $settings_placement = ' head';39 40 public $pageview_placement = ' head';38 public $settings_placement = 'footer'; 39 40 public $pageview_placement = 'footer'; 41 41 42 42 /** … … 184 184 185 185 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 187 191 $scripts = intel()->intel_script_info(); 188 192 $enabled = get_option('intel_intel_scripts_enabled', array()); … … 198 202 */ 199 203 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 } 203 208 $io_name = 'io'; 204 209 … … 217 222 } 218 223 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 } 222 229 223 230 print '<script>' . $script . '</script>'; … … 231 238 232 239 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) { 234 242 return ''; 235 243 } … … 248 256 } 249 257 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 255 266 //$script .= "$io_name('set', intel_settings.intel.pushes.set);\n"; 256 267 //if (!empty($js_settings['intel']['pushes']['events'])) { … … 289 300 $io_name = 'io'; 290 301 302 $is_framework = intel_is_framework(); 303 291 304 $page = array(); 292 305 intel_page_alter($page); … … 298 311 $script .= "var wp_intel = wp_intel || { 'settings': {}, 'behaviors': {}, 'locale': {} };\n"; 299 312 $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 314 330 //$script .= "$io_name('pageview');\n"; 315 331 -
intelligence/trunk/includes/class-intel-visitor-page.php
r1653685 r2947915 60 60 61 61 // Retrieve all profile fields and attach to $entity->content. 62 Intel _Visitor::build_content($entity);62 IntelVisitor::build_content($entity); 63 63 64 64 $build = $entity->content; -
intelligence/trunk/includes/class-intel.php
r1904936 r2947915 80 80 public $time_delta; 81 81 82 public $is_network_active; 83 84 public $is_network_framework_mode; 85 82 86 protected $js_inline = array(); 83 87 … … 114 118 115 119 public $admin_dir; 120 121 public $is_network_admin; 116 122 117 123 public $vtk; … … 157 163 $this->admin_url = admin_url(); 158 164 $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 } 159 178 160 179 // determine admin paths … … 284 303 * Crud super class 285 304 */ 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'; 288 309 289 310 $this->loader = new Intel_Loader(); … … 352 373 // site menu 353 374 $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 } 354 381 355 382 // column headers … … 394 421 'intel_reports' => 1, 395 422 'intel_visitor' => 1, 423 'intel_annotation' => 1, 396 424 'intel_config' => 1, 397 425 'intel_util' => 1, … … 507 535 508 536 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'; 510 538 511 539 $_SESSION['intel'] = !empty($_SESSION['intel']) ? $_SESSION['intel'] : array(); 512 540 513 $this->vtk = Intel _Visitor::extractVtk();514 515 $this->gacid = Intel _Visitor::extractCid();541 $this->vtk = IntelVisitor::extractVtk(); 542 543 $this->gacid = IntelVisitor::extractCid(); 516 544 517 545 $this->session_hash = !empty($this->vtk) ? $this->vtk : $this->gacid; … … 545 573 $cache = isset($_SESSION['intel_quick_cache']) ? $_SESSION['intel_quick_cache'] : array(); 546 574 547 if (!empty($_SESSION['intel ']) && is_array($_SESSION['intel'])) {575 if (!empty($_SESSION['intel_pushes']) && is_array($_SESSION['intel_pushes'])) { 548 576 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']); 550 578 } 551 579 else { 552 $cache = $_SESSION['intel '];580 $cache = $_SESSION['intel_pushes']; 553 581 } 554 582 } -
intelligence/trunk/includes/intel.demo.php
r2018028 r2947915 1179 1179 1180 1180 $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)); 1181 1191 1182 1192 $form['givenName'] = array( -
intelligence/trunk/includes/intel.ga.php
r2018028 r2947915 7 7 */ 8 8 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 */ 21 function 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 */ 92 function 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 } 9 137 10 138 /** … … 71 199 } 72 200 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 239 206 240 207 function intel_ga_goal_const($ga_goal) { … … 411 378 412 379 return $ga_goal; 380 } 381 382 function 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; 413 430 } 414 431 … … 535 552 } 536 553 554 /** 555 * alias of intel_is_intel_goal() 556 * @param $ga_goal 557 * 558 * @return bool 559 */ 537 560 function 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 */ 570 function intel_is_intel_goal($ga_goal) { 538 571 if (!empty($ga_goal['type']) && $ga_goal['type'] == 'EVENT') { 539 572 if (!empty($ga_goal['details']['conditions'])) { … … 567 600 } 568 601 569 add_filter('intel_link_type_info', 'intel_get_link_type_info_default'); 602 function 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 613 function 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 699 function 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 735 function 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 */ 760 function 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 */ 890 function intel_intel_link_type_info($info = array()) { 891 $info = intel_get_link_type_info_default($info); 892 return $info; 893 } 894 add_filter('intel_link_type_info', 'intel_intel_link_type_info'); 895 570 896 function intel_get_link_type_info_default($info = array()) { 571 897 $info['mailto'] = array( … … 580 906 'title' => Intel_Df::t('Download link'), 581 907 'track' => 1, 908 'track_file_extension' => intel_get_link_type_download_track_file_extensions_default(), 582 909 ); 583 910 $info['external'] = array( … … 616 943 } 617 944 } 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 } 620 948 } 621 949 } … … 638 966 639 967 /** 968 * Implements hook_intel_intel_event_info() 969 */ 970 function intel_intel_intel_event_info($event = array()) { 971 $info = intel_get_intel_event_info_default($event); 972 return $info; 973 } 974 add_filter('intel_intel_event_info', 'intel_intel_intel_event_info'); 975 976 /** 640 977 * types = flag, list, scalar, vector 641 978 */ 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'); 643 980 function intel_get_intel_event_info_default($event = array()) { 644 981 $scripts_enabled = get_option('intel_intel_scripts_enabled', array()); … … 755 1092 } 756 1093 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'] = [ 760 1096 'title' => Intel_Df::t('Landing page view'), 761 1097 'description' => Intel_Df::t('Landing page pageview'), 762 1098 //'event' => 'pageshow', 763 );764 $event['landing_page_conversion'] = array(1099 ]; 1100 $event['landing_page_conversion'] = [ 765 1101 'title' => Intel_Df::t('Landing page conversion'), 766 1102 'description' => Intel_Df::t('Form submission from a landing page'), 767 1103 'valued_event' => 1, 768 1104 'value' => 0, 769 ); 1105 ]; 1106 } 1107 1108 if (intel_is_intel_script_enabled('ctatracker')) { 770 1109 $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'), 773 1112 ); 774 1113 $event['cta_click'] = array( … … 785 1124 ); 786 1125 } 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 */801 1126 802 1127 if (intel_is_intel_script_enabled('linktracker')) { … … 1373 1698 } 1374 1699 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 1501 1701 1502 1702 /** … … 1636 1836 $to_match[] = substr($alias, 0, -1); 1637 1837 } 1638 1838 //Intel_df::watchdog('enabled_intel_events', 'to_match', $to_match); 1639 1839 foreach ($e AS $key => $event) { 1640 1840 if (!empty($event['enable_all_pages'])) { … … 1666 1866 return $events; 1667 1867 } 1868 1869 function 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 1873 function 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 } 1891 add_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 */ 1668 1896 1669 1897 /** … … 3323 3551 } 3324 3552 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 3458 3554 3459 3555 function intel_event_value_format($value, $options = array()) { … … 3491 3587 //continue; 3492 3588 } 3493 $scorings[$filter][$i] = isset($custom[$i]) ? $custom[$i] : $m['value'];3589 $scorings[$filter][$i] = (float) (isset($custom[$i]) ? $custom[$i] : $m['value']); 3494 3590 } 3495 3591 … … 3521 3617 } 3522 3618 } 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 3528 3619 3529 3620 return $scorings[$filter]; … … 3762 3853 'goals' => 0, 3763 3854 'traffic' => 0, 3855 'attraction' => 0, 3856 'engagement' => 0, 3857 'conversion' => 0, 3764 3858 ), 3765 3859 // stats for values generated directly by the item on non … … 3769 3863 'goals' => 0, 3770 3864 'traffic' => 0, 3865 'attraction' => 0, 3866 'engagement' => 0, 3867 'conversion' => 0, 3771 3868 ), 3772 3869 // stats for values generated during sessions where the item is the entrance … … 3776 3873 'goals' => 0, 3777 3874 'traffic' => 0, 3875 'attraction' => 0, 3876 'engagement' => 0, 3877 'conversion' => 0, 3778 3878 ), 3779 3879 // stats generated downstream from page hit … … 3783 3883 'goals' => 0, 3784 3884 'traffic' => 0, 3885 'attraction' => 0, 3886 'engagement' => 0, 3887 'conversion' => 0, 3785 3888 ), 3786 3889 ); … … 3826 3929 // on this page or segement but not directly by the page 3827 3930 $scores['entrance']['goals'] += $entrance['goalValueAll']; 3931 $scores['entrance']['conversion'] += $entrance['goalValueAll']; 3828 3932 3829 3933 // the value of any valued events generated on any page in sessions started … … 3831 3935 if (isset($entrance['events']['_totals'])) { 3832 3936 $scores['entrance']['events'] += $entrance['events']['_totals']['value']; 3937 $scores['entrance']['engagement'] += $entrance['events']['_totals']['value']; 3833 3938 } 3834 3939 elseif (isset($entrance['events']['_all'])) { 3835 3940 $scores['entrance']['events'] += $entrance['events']['_all']['value']; 3941 $scores['entrance']['engagement'] += $entrance['events']['_all']['value']; 3836 3942 } 3837 3943 // traffic scoring based on traffic generated by this page or segement 3838 3944 $scores['entrance']['traffic'] += $entrance['entrances'] * $scoring['entrance']; 3945 $scores['entrance']['attraction'] += $entrance['entrances'] * $scoring['entrance']; 3839 3946 //$scores['_all']['traffic'] += $entrance['entrances'] * $scoring['entrance']; 3840 3947 if (!empty($entrance['sticks'])) { 3841 3948 $scores['entrance']['traffic'] += $entrance['sticks'] * $scoring['stick']; 3949 $scores['entrance']['engagement'] += $entrance['sticks'] * $scoring['stick']; 3842 3950 // when using Session stick events, stick numbers should be removed from events 3843 3951 //$scores['entrance']['events'] -= $entrance['sticks'] * $scoring['stick']; … … 3845 3953 if ($entrance['pageviews'] > 2) { 3846 3954 $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']; 3847 3956 } 3848 3957 } … … 3854 3963 if (!empty($page['goalValueAll'])) { 3855 3964 $scores['onpage']['goals'] += $page['goalValueAll']; 3965 $scores['onpage']['conversion'] += $page['goalValueAll']; 3856 3966 } 3857 3967 … … 3859 3969 if (!empty($page['pageValueAll'])) { 3860 3970 $scores['assist']['goals'] += ($page['pageValueAll'] - $page['goalValueAll']); 3971 $scores['assist']['conversion'] += ($page['pageValueAll'] - $page['goalValueAll']); 3861 3972 } 3862 3973 … … 3864 3975 if (isset($page['events']['_totals'])) { 3865 3976 $scores['onpage']['events'] += $page['events']['_totals']['value']; 3977 $scores['onpage']['engagement'] += $page['events']['_totals']['value']; 3866 3978 } 3867 3979 elseif (isset($page['events']['_all'])) { 3868 3980 $scores['onpage']['events'] += $page['events']['_all']['value']; 3981 $scores['onpage']['engagement'] += $page['events']['_all']['value']; 3869 3982 } 3870 3983 … … 3898 4011 //$scores['_all']['traffic'] = $scores['entrance']['traffic'] + $scores['onpage']['traffic']; 3899 4012 $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']; 3900 4016 } 3901 4017 else { … … 3904 4020 $scores['_all']['events'] = $scores['entrance']['events']; 3905 4021 $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']; 3906 4025 } 3907 4026 … … 4047 4166 } 4048 4167 4049 return _intel_get_report_dates($start, $end );4168 return _intel_get_report_dates($start, $end, $return_hash); 4050 4169 } 4051 4170 4052 4171 function _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 4070 4175 if (!empty($_GET['dates'])) { 4071 4176 $a = explode(":", $_GET['dates']); … … 4076 4181 $end = (!empty($_GET['end_date'])) ? $_GET['end_date'] : $end_default; 4077 4182 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 4106 4189 $number_of_days = ceil(($end_date - $start_date)/60/60/24); 4107 4190 if (!$return_hash) { 4108 4191 return array( 4109 $ start_date_local,4110 $ end_date_local,4192 $ga_start_date, 4193 $ga_end_date, 4111 4194 $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'], 4120 4196 ); 4121 4197 } … … 4124 4200 'start_date' => $start_date, 4125 4201 'end_date' => $end_date, 4202 'ga_start_date' => $ga_start_date, 4203 'ga_end_date' => $ga_end_date, 4126 4204 'number_of_days' => $number_of_days, 4127 'timezone_offset' => $offset, 4205 'number_of_seconds' => $end_date - $start_date, 4206 'timezone_info' => $timezone_info, 4128 4207 ); 4129 4208 } … … 4725 4804 ); 4726 4805 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"); 4728 4807 $cache = array( 4729 4808 'refresh' => 1, … … 4738 4817 'segment' => 'sessions::condition::ga:dimension5==' . implode(',ga:dimension5==', $vtkids), 4739 4818 ); 4819 4740 4820 $visits = intel_fetch_analytics_visits($options); 4741 4821 … … 4844 4924 4845 4925 $data = intel_ga_api_data($request, $cache_options); 4846 //dsm($request); dsm($data); 4926 4847 4927 $rows = intel_get_ga_feed_rows($data); 4848 4928 if (!empty($rows) && is_array($rows)) { … … 5473 5553 5474 5554 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 );5486 5555 } 5487 5556 -
intelligence/trunk/includes/intel.imapi.php
r1904936 r2947915 52 52 $api_params = get_option('intel_imapi_custom_params', array()); 53 53 $apiClientProps = array( 54 'apiUrl' => intel_get_imapi_url() . '/',54 'apiUrl' => (!empty($options['api_url']) ? $options['api_url'] : intel_get_imapi_url()) . '/', 55 55 'urlrewrite' => 1, 56 56 //'apiConnector' => get_option('intel_l10iapi_connector', ''), … … 63 63 } 64 64 65 function intel_imapi_do_reauth() { 66 67 } 68 65 69 function intel_imapi_property_get($options = array()) { 66 70 $vars = array(); -
intelligence/trunk/includes/intel.page_alter.php
r2018028 r2947915 8 8 9 9 function 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); 12 16 13 17 $q = isset($_GET['q']) ? $_GET['q'] : ''; … … 27 31 'debug' => intel_debug_mode(), 28 32 // cmsHostpath, modulePath & apiPath are not standard io settings. They are used 29 // exclusiv ly by intel module js.33 // exclusively by intel module js. 30 34 'cmsHostpath' => $parsed_url['hostpath'], 31 35 'modulePath' => $modulePath, 36 // path to intel library files 32 37 'libPath' => $modulePath . '/vendor/levelten/intel', 33 //'cms_hostpath' => $parsed_url['hostpath'],34 //'module_path' => drupal_get_path('module', 'intel'),35 38 'systemPath' => $q, 36 39 'systemHost' => $parsed_url['host'], 37 40 'systemBasepath' => $parsed_url['base_path'], 38 41 'srl' => $q, 39 //'lib_path' => intel_get_library_path(),40 42 'pageTitle' => '(not set)', 41 43 '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 level43 //'trackAdhocEvents' => 'track-event',44 'trackAdhocCtas' => ($api_level == 'pro') ? 'track-cta' : '', // Check if CTA tracking is supported in IPAI level 45 'trackAdhocEvents' => 'track-event', 44 46 'trackForms' => array(), 45 47 'trackRealtime' => (integer)get_option('intel_track_realtime', INTEL_TRACK_REALTIME_DEFAULT), 46 48 'fetchGaRealtime' => (integer)get_option('intel_fetch_ga_realtime', 0), 47 49 'isLandingpage' => 0, 48 //'scorings' => intel_get_scorings('js_setting'),49 50 'scorings' => array( 50 51 'events' => array(), … … 66 67 ); 67 68 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 } 71 74 } 72 75 … … 105 108 } 106 109 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 } 108 116 109 117 $ga_va = array(); 110 if ( !empty($user->ID)) {118 if ($uid) { 111 119 if (intel_include_library_file('class.visitor.php')) { 112 120 $ga_va = \LevelTen\Intel\ApiVisitor::extractCookieVa(); … … 123 131 intel_add_page_intel_push(array('set', "p.systemPath", $q)); 124 132 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 147 157 if ($entity_type && !empty($entity)) { 148 158 $attrs = intel_get_entity_intel_attributes($entity, $entity_type, 1); … … 159 169 if (isset($page_attrs['pi']) && isset($page_attrs['pi']['l'])) { 160 170 $config['isLandingpage'] = 1; 161 // Check if landingpage tracking is supported in IPAI level162 if ($api_level == 'pro') {163 //$page_events['landing_page_view'] = $intel_events['landing_page_view'];164 }165 171 } 166 172 167 173 // set user role visitor attribute 168 174 // only when user is logged in (otherwise page caching will cause errors) 169 if ( !empty($user->ID)) {175 if ($uid) { 170 176 if (INTEL_PLATFORM == 'wp') { 171 177 // don't exclude on intel_demo_pages to allow testing 172 178 if (!intel_is_demo_page()) { 173 179 $tracking_exclude_roles = get_option('intel_tracking_exclude_role', intel_get_tracking_exclude_user_role_default()); 174 175 180 // WP roles do not have ids, so we create them 176 181 $role_index = get_option('intel_role_index', array()); 182 if (empty($role_index)) { 183 $role_index['anonymous'] = 0; 184 } 177 185 $cur = isset($ga_va['ur']) ? $ga_va['ur'] : array(); 178 186 if (!empty($user->roles) && is_array($user->roles)) { … … 195 203 } 196 204 } 197 198 205 } 199 206 elseif (INTEL_PLATFORM == 'drupal') { … … 214 221 } 215 222 } 216 217 223 } 218 224 … … 288 294 intel_add_page_intel_push(array('linktracker:setLinkTypeDef', $key, $def)); 289 295 } 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 } 304 297 305 298 intel_check_form_submission($page); … … 320 313 321 314 // 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'); 324 316 325 317 $pushes = intel_get_flush_page_intel_pushes(); 318 $pushes_cookie = intel_get_flush_page_intel_pushes_cookie(); 326 319 327 320 // add page title and system path to any IntelEvent that is missing values 328 321 /* 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 341 322 if (isset($pushes['event']) && is_array($pushes['event'])) { 342 323 foreach ($pushes['event'] AS $i => $push) { … … 349 330 } 350 331 } 332 */ 351 333 352 334 //watchdog('intel_page_alter_pushes', print_r($pushes, 1)); … … 357 339 'config' => $config, 358 340 'pushes' => $pushes, 341 'pushes_cookie' => $pushes_cookie, 359 342 ), 360 343 // TODO: move this to intel_disqus … … 370 353 } 371 354 372 // Get page status code for visibility filtering. 373 355 // determine if page should be tracked 374 356 $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 385 381 if (!$track) { 386 382 $js['intel']['config']['track_forms'] = 0; … … 389 385 } 390 386 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 } 401 412 402 if (!empty($_GET['debug'])) {403 if ($_GET['debug'] == 'ie9') {404 $script = "http://ie.microsoft.com/testdrive/HTML5/CompatInspector/inspector.js";405 // TODO WP406 //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 enhancements422 */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 434 413 //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 436 416 if (!empty($_GET['debug'])) { 437 417 intel_d($js);// … … 564 544 565 545 // ? 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'); 567 547 if (isset($created)) { 568 548 $val = date('YmdHiw', $created); … … 607 587 // Only load URI if entity has been created (has ID). 608 588 if ($entity_id) { 609 $uri = Intel _Entity::entity_uri($entity_type, $entity);589 $uri = IntelEntity::entity_uri($entity_type, $entity); 610 590 if (!empty($uri['id'])) { 611 591 $page_attrs['ri'] = $uri['id']; … … 659 639 $key = 'a'; 660 640 } 661 $author_id = Intel _Entity::entity_get($entity_type, $entity, 'author_id');641 $author_id = IntelEntity::entity_get($entity_type, $entity, 'author_id'); 662 642 $page_attrs[$key] = $author_id; 663 643 //$page_ld['author'] = $base_path . "user/" . $entity->uid; … … 842 822 } 843 823 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 853 824 function intel_get_post_entity_attr_default($post = NULL) { 854 825 if (!isset($post)) { … … 926 897 } 927 898 899 function intel_get_page_intel_pushes_cookie() { 900 return intel_page_intel_pushes('get_cookie'); 901 } 902 903 function intel_get_flush_page_intel_pushes_cookie() { 904 return intel_page_intel_pushes('get_cookie_flush'); 905 } 906 928 907 /** 929 908 * Used to store intel pushes for redirects. 930 909 * @return mixed 931 910 */ 932 933 911 function intel_save_flush_page_intel_pushes() { 934 912 $push_storage = get_option('intel_save_push_storage', INTEL_SAVE_PUSH_STORAGE_DEFAULT); … … 952 930 function intel_page_intel_pushes($action = 'get', $push = array(), $index = '') { 953 931 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']; 959 945 } 960 946 … … 969 955 } 970 956 971 if (!isset($ _SESSION['intel']['page_pushes'][$method])) {972 $ _SESSION['intel']['page_pushes'][$method] = array();957 if (!isset($data[$method])) { 958 $data[$method] = array(); 973 959 } 974 960 … … 991 977 } 992 978 elseif ($method == 'event') { 993 $index = count($ _SESSION['intel']['page_pushes'][$method]);979 $index = count($data[$method]); 994 980 $value = $push[0]; 995 981 } … … 1000 986 // check if push uses command(def) format 1001 987 if (count($push) == 1 && is_array($push[0])) { 1002 $index = count($ _SESSION['intel']['page_pushes'][$method]);988 $index = count($data[$method]); 1003 989 $value = $push[0]; 1004 990 } 1005 991 else { 1006 $index = count($ _SESSION['intel']['page_pushes'][$method]);992 $index = count($data[$method]); 1007 993 $value = $push; 1008 994 } … … 1011 997 1012 998 if ($index == -1) { 1013 $ _SESSION['intel']['page_pushes'][$method] = $value;999 $data[$method] = $value; 1014 1000 } 1015 1001 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; 1022 1008 1023 1009 if ($action == 'save_flush' || $action == 'save_db_flush') { 1024 1010 intel()->quick_session_cache(); 1025 unset($_SESSION['intel']['page_pushes']); 1026 1011 unset($_SESSION['intel_pushes']['page_pushes']); 1027 1012 } 1028 1013 elseif ($action == 'save_cookie_flush') { … … 1030 1015 $pushes = array(); 1031 1016 1032 foreach ($_SESSION['intel ']['page_pushes'] as $k => $v) {1017 foreach ($_SESSION['intel_pushes']['page_pushes'] as $k => $v) { 1033 1018 $a = array(''); 1034 1019 $pushes[] = array($k, $v); 1035 1020 } 1036 1021 $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']); 1039 1025 } 1040 1026 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']); 1042 1045 } 1043 1046 … … 1148 1151 } 1149 1152 1150 1151 1152 1153 } 1153 1154 else { … … 1213 1214 'clickMode' => 1, 1214 1215 'clickValue' => 1, 1216 'track_file_extension' => 'trackFileExtension', 1217 'trackFileExtension' => 1, 1215 1218 ); 1216 1219 … … 1233 1236 } 1234 1237 1235 function intel_cache_busting_url($url ) {1238 function intel_cache_busting_url($url, $force = FALSE) { 1236 1239 $enable = &Intel_Df::drupal_static( __FUNCTION__ ); 1240 1237 1241 if (!isset($enable)) { 1238 1242 $enable = get_option('intel_cache_busting', INTEL_CACHE_BUSTING_DEFAULT); 1239 1243 } 1240 if (!$enable ) {1244 if (!$enable && !$force) { 1241 1245 return $url; 1242 1246 } … … 1368 1372 */ 1369 1373 function intel_get_js_embed($type = 'l10i', $mode = 'external', $version = 'latest', $terminator = "") { 1370 global $user;1374 $user = intel_get_current_user(); 1371 1375 1372 1376 $script = ''; … … 1509 1513 1510 1514 // 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); 1512 1516 //drupal_alter('intel_l10iq_pushes', $l10iq_pushes); 1513 1517 … … 1536 1540 $l10ijs_path = '/js/' . $api_js_ver . '/l10i' . $sv . '.js'; 1537 1541 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 } 1538 1549 1539 1550 $script .= "(function(w,d,o,u,b,i,r,a,s,c,t){" . $terminator; … … 1701 1712 1702 1713 include_once INTEL_DIR . 'includes/class-intel-visitor.php'; 1703 $vtk = Intel _Visitor::extractVtk();1714 $vtk = IntelVisitor::extractVtk(); 1704 1715 1705 1716 $api_level = intel_api_level(); … … 1829 1840 */ 1830 1841 function intel_process_form_submission($vars) { 1831 //Intel_Df::watchdog('intel_process_form_submission vars', json_encode($vars));1842 Intel_Df::watchdog('intel_process_form', 'vars', $vars); 1832 1843 // set defaults 1833 1844 $vars += intel_form_submission_vars_default(); … … 2010 2021 $submission->vid = 0; 2011 2022 } 2012 2013 2023 } 2014 2024 … … 2302 2312 'hook_context' => isset($vars['hook_context']) ? $vars['hook_context'] : NULL, 2303 2313 ); 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); 2305 2317 2306 2318 // save submission object 2307 2319 if (!empty($submission->vid)) { 2320 //Intel_Df::watchdog('intel_process_form', 'submission', $submission); 2308 2321 $sid = intel_submission_save($submission); 2309 2322 if (empty($submission->sid)) { … … 2312 2325 } 2313 2326 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)) { 2315 2333 $track['oa']['3rk'] = $submission->sid; 2316 2334 $track['oa']['3ri'] = ':intel_submission:' . $submission->sid; … … 2333 2351 } 2334 2352 2335 //$userId = Intel _Visitor::extractUserId();2353 //$userId = IntelVisitor::extractUserId(); 2336 2354 2337 2355 //intel_set_ga_userid($visitor); … … 2353 2371 // save visitor 2354 2372 if (!empty($visitor->vid)) { 2373 //Intel_Df::watchdog('intel_process_form', 'visitor', $visitor); 2355 2374 intel_visitor_save($visitor); 2356 //watchdog('intel.page_alter 992', print_r($visitor, 1));2357 2375 } 2358 2376 … … 2364 2382 $track = apply_filters('intel_form_submission_track_alter', $track, $hook_context); 2365 2383 2384 // create form submission intel event 2366 2385 if (!empty($track['event_category'])) { 2367 2386 $call = array( … … 2373 2392 'oa' => $track['oa'], 2374 2393 ); 2375 //Intel_Df::watchdog('form_submission', json_encode($call)); 2376 2394 2395 //Intel_Df::watchdog('intel_process_form', 'intel_push', $call); 2377 2396 intel_add_page_intel_push(array('event', $call)); 2378 //dpm('page_intel_push=');dpm($call);//2379 2397 } 2380 2398 … … 2412 2430 2413 2431 // 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); 2415 2434 } 2416 2435 … … 2484 2503 } 2485 2504 if (!$domain) { 2486 $domain = '.' . intel()->domain;2505 //$domain = '.'; 2487 2506 } 2488 2507 … … 2504 2523 2505 2524 function intel_deletecookie($name) { 2506 if (isset($_COOKI OE[$name])) {2507 unset($_COOKI OE[$name]);2525 if (isset($_COOKIE[$name])) { 2526 unset($_COOKIE[$name]); 2508 2527 } 2509 2528 intel_setcookie($name, '', time() - 999); … … 2560 2579 // if account is currently logged in user, set $vtk 2561 2580 // 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() : ''; 2563 2582 } 2564 2583 elseif (INTEL_PLATFORM == 'wp') { … … 2566 2585 $email = $account->user_email; 2567 2586 $name = $account->display_name; 2568 $vtk = Intel _Visitor::extractVtk();2587 $vtk = IntelVisitor::extractVtk(); 2569 2588 } 2570 2589 … … 2734 2753 2735 2754 // don't save "visitors" that don't have a vtk. They are likely spam bots 2736 $vtk = Intel _Visitor::extractVtk();2755 $vtk = IntelVisitor::extractVtk(); 2737 2756 if (empty($vtk)) { 2738 2757 return; -
intelligence/trunk/includes/intel.reports.php
r1827302 r2947915 415 415 $vars['timeframe'] = 'l30d'; 416 416 } 417 417 418 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 } 418 429 419 430 if (!empty($_GET['refresh'])) { -
intelligence/trunk/includes/intel.visitor_sync.php
r1904936 r2947915 104 104 } 105 105 106 add_filter( 'intel_sync_visitor', 'intel_ga_sync_visitordata', 5, 2); 106 add_filter( 'intel_sync_visitor', 'intel_intel_sync_visitor', 5, 2); 107 function 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); 107 115 /** 108 116 * Implements intel_sync_visitordata 109 117 * @param unknown_type $visitor 110 118 */ 111 function intel_ga_sync_visitordata($visitor, $options = array()) { 112 Intel_Df::watchdog('intel_ga_sync_visitordata options', print_r($options, 1)); 119 function intel_ga_sync_visitor($visitor, $options = array()) { 120 //$args = func_get_args(); 121 //Intel_Df::watchdog('intel_ga_sync_visitordata', 'args', $args); 113 122 if (!empty($options['processes']) && !in_array('ga', $options['processes'])) { 114 123 return $visitor; 115 124 } 116 125 117 require_once INTEL_DIR . "includes/intel.ga.php"; 126 intel_load_include('includes/intel.ga'); 127 118 128 $vtkids = array(); 119 129 … … 185 195 } 186 196 187 add_filter( 'intel_sync_visitor', 'intel_l10iapi_sync_visitordata', 10, 2);197 //add_filter( 'intel_sync_visitor', 'intel_l10iapi_sync_visitordata', 10, 2); 188 198 function intel_l10iapi_sync_visitordata($visitor, $options = array()) { 189 199 if (!empty($options['processes']) && !in_array('l10iapi', $options['processes'])) { -
intelligence/trunk/intel.install.php
r1827302 r2947915 158 158 } 159 159 } 160 161 /** 162 * Adding annotation table 163 */ 164 function 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 9 9 define('INTEL_L10IAPI_URL', 'https://api.getlevelten.com/v1/intel'); 10 10 define('INTEL_IMAPI_URL', 'https://admin.intelligencewp.com/imapi/v1/intel'); 11 define('INTEL_NO_API', 1); // set to 1 to remove API connections 11 12 //define('INTEL_IMAPI_URL', 'intl.getlevelten.com/imapi/v1/intel'); 12 13 define('INTEL_L10IAPI_JS_VER', '0.3.1'); … … 15 16 define('INTEL_TRACK_PAGE_UID_DEFAULT', 'a'); 16 17 define('INTEL_TRACK_PAGE_TERMS_DEFAULT', 0); 17 define('INTEL_TRACK_ PAGE_TERMS_VISITOR_DEFAULT', 0);18 define('INTEL_TRACK_VISITOR_TERMS_DEFAULT', 0); 18 19 define('INTEL_SYNC_VISITORDATA_FULLCONTACT_DEFAULT', 0); 19 20 define('INTEL_TRACK_PHONECALLS_DEFAULT', 0); … … 35 36 36 37 // include required files 38 require_once Intel_Df::drupal_get_path('module', 'intel') . "/includes/intel.common.php"; 37 39 require_once Intel_Df::drupal_get_path('module', 'intel') . "/includes/intel.page_alter.php"; 38 40 require_once Intel_Df::drupal_get_path('module', 'intel') . "/includes/intel.page_data.php"; … … 120 122 'weight' => -10, 121 123 ); 124 122 125 $items['admin/config/intel/settings/general'] = array( 123 126 'title' => 'General', … … 168 171 'file' => 'admin/intel.admin_setup.php', 169 172 ); 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 170 186 $items['admin/config/intel/settings/scoring'] = array( 171 187 'title' => 'Scoring', … … 479 495 ); 480 496 } 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 ); 481 510 482 511 // intel visitor config … … 848 877 ); 849 878 } 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 850 940 } 851 941 … … 1039 1129 ); 1040 1130 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 1053 1131 $items['admin/util/update'] = array( 1054 1132 'title' => 'Update', … … 1059 1137 'type' => Intel_Df::MENU_LOCAL_TASK, 1060 1138 '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', 1061 1162 ); 1062 1163 … … 1802 1903 } 1803 1904 1905 function intel_is_no_api() { 1906 return INTEL_NO_API; 1907 } 1908 1804 1909 /** 1805 1910 * Determines if the api access level is adequate to access the … … 1937 2042 'phonecall/*' => 1, 1938 2043 'emailclick/*' => 1, 2044 'annotation/*' => 1, 1939 2045 ); 1940 2046 return $paths; … … 1990 2096 'title' => Intel_Df::t('View emailclicks'), 1991 2097 '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.'), 1992 2103 'roles' => array('editor', 'author'), 1993 2104 ); … … 2061 2172 return $module_access || $general_access; 2062 2173 case 'list': 2174 return $module_access || $general_access; 2175 } 2176 } 2177 2178 function 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': 2063 2196 return $module_access || $general_access; 2064 2197 } … … 2202 2335 2203 2336 function 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 } 2204 2342 if (!intel_verify_library($message)) { 2205 2343 return FALSE; … … 2289 2427 } 2290 2428 2291 2429 /** 2430 * Returns if is framework flag is set 2431 * 2432 * @return array|bool|mixed 2433 */ 2434 function 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 2448 function intel_is_framework_only() { 2449 return intel_is_framework() && !intel_is_installed(); 2450 } 2292 2451 2293 2452 /** … … 2303 2462 // A human readable label to identify our entity. 2304 2463 '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', 2307 2466 'base table' => 'intel_visitor', 2308 2467 'label callback' => 'intel_visitor_label', … … 2314 2473 ), 2315 2474 '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', 2318 2477 ), 2319 2478 'fields' => array( … … 2371 2530 // A human readable label to identify our entity. 2372 2531 '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', 2375 2534 'base table' => 'intel_submission', 2376 2535 'label callback' => 'intel_submission_label', … … 2382 2541 ), 2383 2542 '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', 2386 2545 ), 2387 2546 'fields' => array( 2388 2547 'sid' => null, 2389 2548 'vid' => 0, 2390 'submitted' => time(),2549 'submitted' => REQUEST_TIME, 2391 2550 'type' => '', 2392 2551 'fid' => '', … … 2405 2564 'cta_id' => '', 2406 2565 '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' => '', 2407 2630 ), 2408 2631 ); … … 2527 2750 } 2528 2751 2752 function 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 */ 2760 function 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 */ 2771 function 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 */ 2787 function 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 2529 2799 function intel_visitor_load($id = NULL, $reset = FALSE, $id_type = NULL) { 2530 2800 $visitors = intel_visitor_load_multiple($id, array(), $reset, $id_type); … … 3422 3692 } 3423 3693 3694 /** 3695 * Initializes properties of submission stdClass object 3696 */ 3697 function 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 */ 3707 function 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 */ 3718 function 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 */ 3732 function 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 3424 3740 3425 3741 … … 3440 3756 */ 3441 3757 function 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 */ 3766 function intel_get_intel_script_info() { 3767 $scripts = array(); 3768 3769 $scripts = intel_build_info('intel_script'); 3770 3771 return $scripts; 3443 3772 } 3444 3773 3445 3774 // add _intel_intel_script_info to hook_intel_script_info 3446 add_filter('intel_intel_script_info', '_intel_intel_script_info');3775 intel_add_hook('intel_intel_script_info', '_intel_intel_script_info'); 3447 3776 /** 3448 3777 * Implements hook_intel_intel_script … … 3550 3879 */ 3551 3880 function intel_is_intel_script_enabled($name) { 3881 if (intel_is_framework()) { 3882 return 0; 3883 } 3552 3884 $scripts_enabled = get_option('intel_intel_scripts_enabled', array()); 3553 3885 if (isset($scripts_enabled[$name])) { … … 3904 4236 } 3905 4237 3906 function intel_add_visitor_sync_request($v isitor, $delay = 0) {4238 function intel_add_visitor_sync_request($vtk, $delay = 0) { 3907 4239 //$intel = intel(); 4240 // check if visitor was passed instead of vtk 4241 if (is_object($vtk) && !empty($vtk->vtk)) { 4242 $vtk = $vtk->vtk; 4243 } 3908 4244 $items = get_option('intel_sync_visitor_requests', array()); 3909 if (!isset($items[$v isitor->vtk])) {4245 if (!isset($items[$vtk])) { 3910 4246 $item = new stdClass; 3911 4247 $item->created = time(); 3912 4248 $item->run_after = time() + $delay; 3913 $item->vtk = $v isitor->vtk;4249 $item->vtk = $vtk; 3914 4250 $item->attempts = 0; 3915 $items[$v isitor->vtk] = $item;4251 $items[$vtk] = $item; 3916 4252 update_option('intel_sync_visitor_requests', $items); 3917 4253 } … … 3942 4278 */ 3943 4279 function 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'); 3945 4281 3946 4282 $output = ''; … … 3978 4314 } 3979 4315 3980 function intel_sync_visitordata( $visitor, $options = array()) {4316 function intel_sync_visitordata(IntelVisitor $visitor, $options = array()) { 3981 4317 require_once Intel_Df::drupal_get_path('module', 'intel') . "/includes/intel.visitor_sync.php"; 3982 4318 … … 4036 4372 $cq_item = $queue->claimItem(); 4037 4373 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 } 4041 4379 } 4042 4380 } … … 4244 4582 } 4245 4583 4246 if ( !function_exists( 'intel_d' ) ) {4247 function intel_d() {4248 // check if user has access to this data4249 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 translates4266 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 4295 4584 /** 4296 4585 * Implements hook_theme_info(). … … 4298 4587 function intel_theme_info($themes = array()) { 4299 4588 //$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 4300 4607 $themes['intel_page'] = array( 4301 4608 'variables' => array( … … 4386 4693 'file' => 'intel.pages.php', 4387 4694 ); 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 4405 4696 $themes['intel_visitor_profile_block'] = array( 4406 4697 'render element' => 'element', … … 4998 5289 } 4999 5290 5000 function intel_format_un($name) {5001 return str_replace('-', '_', strtolower(Intel_Df::drupal_clean_css_identifier($name)));5002 }5003 5004 5291 function intel_get_iapi_url($component = '') { 5005 5292 $url_obj = &Intel_Df::drupal_static( __FUNCTION__); 5293 5006 5294 if (empty($url_obj)) { 5007 5295 $url = get_option('intel_l10iapi_url', ''); … … 5019 5307 } 5020 5308 5021 return http_build_url($url_obj);5309 return intel_http_build_url($url_obj); 5022 5310 } 5023 5311 5024 5312 function intel_get_imapi_url($component = '') { 5025 5313 $url_obj = &Intel_Df::drupal_static( __FUNCTION__); 5314 5026 5315 if (empty($url_obj)) { 5027 5316 $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 { 5029 5325 $url = INTEL_IMAPI_URL; 5030 5326 } 5327 5031 5328 $url_obj = parse_url($url); 5032 5329 } … … 5039 5336 } 5040 5337 5041 return http_build_url($url_obj);5338 return intel_http_build_url($url_obj); 5042 5339 } 5043 5340 … … 5202 5499 add_filter('gainwp_gapi_client_alter', 'intel_gainwp_gapi_client_alter'); 5203 5500 5204 5501 function 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 104 104 $variables['messages'] = Intel_Df::drupal_get_messages(); 105 105 } 106 107 } 108 109 function template_process_intel_bootstrap_card(&$variables) { 106 110 107 111 } -
intelligence/trunk/intel.php
r2096810 r2947915 17 17 * Plugin URI: http://intelligencewp.com 18 18 * Description: Provides behavior and visitor intelligence. 19 * Version: 1. 3.319 * Version: 1.4.0 20 20 * Minimum PHP: 5.4 21 21 * Author: LevelTen … … 34 34 } 35 35 36 define('INTEL_VER', '1.3.3'); 36 //define('SCRIPT_DEBUG', true); 37 //define( 'WP_DEBUG', true ); 38 //define('WP_DEBUG_LOG', 1); 39 40 define('INTEL_VER', '1.4.0'); 37 41 38 42 /******************************************* -
intelligence/trunk/public/class-intel-public.php
r1814908 r2947915 97 97 */ 98 98 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 100 106 wp_register_script('intel', INTEL_URL . 'js/intel.js', array('jquery'), $this->version, true); 101 107 … … 111 117 112 118 // 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()) { 114 120 return; 115 121 } -
intelligence/trunk/readme.txt
r2250808 r2947915 4 4 Tags: analytics, google analytics, marketing, metrics, roi, stats, tracking, usability 5 5 Requires at least: 4.5 6 Tested up to: 5. 37 Stable tag: 1.3. 36 Tested up to: 5.5 7 Stable tag: 1.3.4-dev 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 126 126 * Verified support for WP 5.2 127 127 128 = 1.4.0 = 129 * Added framework mode 130 * Removed Intelligence API dependency 131 * Verified support for WP 6.2 132 128 133 == Upgrade Notice == 129 134 -
intelligence/trunk/reports/intel.ga_explorer_report.php
r1827302 r2947915 7 7 */ 8 8 9 function intel_ga_explorer_report() { 9 function intel_ga_explorer_report($form) { 10 require_once INTEL_DIR . "includes/intel.annotation.php"; 11 10 12 $request = get_option('intel_ga_explorer_request', ''); 11 13 $options = array('' => Intel_Df::t('- None -')); … … 86 88 '#default_value' => (isset($request['custom']['sort_metric'])) ? $request['custom']['sort_metric'] : '', 87 89 ); 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 ); 88 121 $form['markup2'] = array( 89 122 '#type' => 'markup', … … 123 156 '#value' => 'Submit', 124 157 ); 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 & Reference') . '</h4>' . Intel_Df::theme('item_list', array('items' => $items)), 164 ); 125 165 $form['markup3'] = array( 126 166 '#type' => 'markup', … … 143 183 if (!empty($request['custom']['metrics'])) { 144 184 $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 145 225 } 146 226 … … 220 300 } 221 301 302 function 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 222 313 function intel_ga_explorer_report_submit($form, &$form_state) { 223 314 $values = $form_state['values']; … … 244 335 'end_date' => '', 245 336 'max_results' => '', 337 'annotation_launched' => '', 338 'annotation_timeframe' => '', 339 'annotation_variant' => '', 246 340 ); 247 341 $d = $values['dimensions']; … … 267 361 $request['custom']['end_date'] = strtotime(str_replace("'", '', $values['end_date'])); 268 362 $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']); 269 366 $request['realtime_mode'] = str_replace("'", '', $values['realtime_mode']); 270 367 … … 273 370 274 371 function intel_ga_explorer_presets() { 372 373 intel_include_library_file('ga/class.ga_model.php'); 374 275 375 $presets = array(); 276 376 … … 367 467 $presets['entrances'] = array( 368 468 'title' => Intel_Df::t('Entrances (no dimensions)'), 369 'metrics' => array('ga:entrances', 'ga:pageviews PerSession', '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'), 370 470 ); 371 471 -
intelligence/trunk/reports/intel.report_scorecard.php
r1827302 r2947915 91 91 $ga_data->setRequestSetting('details', 1); 92 92 $ga_data->setRequestDefaultParam('max_results', 10 * ($number_of_days+1)); 93 $ga_data->setDebug(1); 93 94 $ga_data->loadFeedData('pageviews_events_valued', 'date', 1); 95 $ga_data->setDebug(0); 94 96 95 97 //d($ga_data->data); … … 164 166 } 165 167 $d = $ga_data->data; 166 167 //intel_d($d['date']);168 168 169 169 if (!empty($path)) { -
intelligence/trunk/templates/intel-bootstrap-card.tpl.php
r1653685 r2947915 31 31 <?php endif; ?> 32 32 <?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; ?> 36 34 <?php endif; ?> 37 35 <?php if ($footer): ?> -
intelligence/trunk/vendor/levelten/intel/class.apiclient.php
r2018028 r2947915 76 76 } 77 77 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); 81 81 } 82 82 if ($this->apiUrlCallMethod == 'none') { … … 162 162 } 163 163 $ret = json_decode($response, true); 164 if (!empty($_GET['debug'])) { 165 //Debug::printVar($ret); 166 } 164 167 if (empty($ret['status'])) { 165 168 $msg = !empty($ret['message']) ? $ret['message'] : $response; -
intelligence/trunk/vendor/levelten/intel/class.visitor.php
r2287888 r2947915 188 188 if (isset($_SESSION) && isset($_SESSION['l10i_cookie']) && is_array($_SESSION['l10i_cookie'])) { 189 189 self::$cookieStrings += $_SESSION['l10i_cookie']; 190 unset($_SESSION['l10i_cookie']); 190 191 } 191 192 } -
intelligence/trunk/vendor/levelten/intel/ga/class.ga_model.php
r1713257 r2947915 345 345 $gafilters['visitor'][] = "ga:{$a[0]}==" . $a[1]; 346 346 } 347 348 347 } 349 348 } … … 355 354 //$ga_segments['visitor-attr'] = "dynamic::ga:dimension3=" . $query; 356 355 } 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 357 372 $this->gaFilters = array( 358 373 'filters' => $gafilters, … … 973 988 974 989 $segment_scope = ($indexBy == 'visitor') ? 'users' : 'sessions'; 990 //intel_d($type); 991 //intel_d($types); 992 //intel_d($gaFilters); 975 993 foreach ($gaFilters AS $filter_type => $gafarr) { 976 994 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); 994 1007 } 995 1008 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') { 998 1042 $filters[] = $filt; 999 1043 } 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 } 1000 1065 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') {1013 1066 $filters[] = $filt; 1014 1067 } 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 type1040 else {1041 if ($filter_type == 'event') {1042 if ($indexBy == 'trafficsource' || $indexBy == 'visitor' || $indexBy == 'visit') {1043 $segments[] = $segment_scope . '::condition::' . $filt;1044 1068 } 1045 1069 else { 1046 1070 $filters[] = $filt; 1047 1071 } 1048 }1049 else {1050 $filters[] = $filt;1051 1072 } 1052 1073 } … … 2264 2285 * @param $number 2265 2286 * @param string $key 2287 * @param array options 2266 2288 * @return string 2267 2289 */ 2268 static function formatGtRegexFilter($param, $number, $key = '' ) {2290 static function formatGtRegexFilter($param, $number, $key = '', $options = array()) { 2269 2291 $k = ($key) ? "&$key=" : "^"; 2270 2292 $end = ($key) ? '&' : "$"; 2293 2271 2294 $nstr = (string)$number; 2272 2295 $num_arr = str_split($nstr); 2273 2296 $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 2275 2312 $p = ''; 2276 2313 foreach ($num_arr AS $i => $digit) { 2277 2314 $digit = (int)$digit; 2278 2315 if ($digit < 9) { 2279 $regex .= ',' . $param . '=~' . $k. $p;2316 $regex .= ($regex ? ',' : '') . $param . '=~' . $k . $prefix . $p; 2280 2317 if ((1 + $digit) == 9) { 2281 2318 $regex .= '9'; … … 2303 2340 * @return string 2304 2341 */ 2305 static function formatGtEqRegexFilter($param, $number, $key = '' ) {2342 static function formatGtEqRegexFilter($param, $number, $key = '', $options = array()) { 2306 2343 $regex = ''; 2307 2344 $k = ($key) ? "&$key=" : "^"; … … 2323 2360 } 2324 2361 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 2326 2377 $p = ''; 2327 2378 $rs = $nstr; … … 2334 2385 if ($r > 0) { 2335 2386 if ($digit < 9) { 2336 $regex .= ',' . $param . '=~' . $k . $p ;2387 $regex .= ',' . $param . '=~' . $k . $prefix . $p; 2337 2388 if ((1 + $digit) == 9) { 2338 2389 $regex .= '9'; … … 2346 2397 else { 2347 2398 if ($digit > 0) { 2348 $regex .= ',' . $param . '=~' . $k . $p ;2399 $regex .= ',' . $param . '=~' . $k . $prefix . $p; 2349 2400 if ($digit == 9) { 2350 2401 $regex .= '9'; … … 2391 2442 } 2392 2443 2393 static function formatLtRegexFilter($param, $number, $key = '' ) {2444 static function formatLtRegexFilter($param, $number, $key = '', $options = array()) { 2394 2445 $end = ($key) ? '&' : "$"; 2395 2446 $nstr = (string)$number; 2447 if (isset($options['prefix'])) { 2448 $nstr = (string)$options['prefix'] . $nstr; 2449 } 2396 2450 $num_arr = str_split($nstr); 2397 2451 $digits = count($num_arr); … … 2426 2480 } 2427 2481 if (($digits) > 1) { 2428 $regex .= (($regex) ? ',' : '') . $param . '=~^\d{0\,' . ($digits -1) . '}' . $end;2482 $regex .= (($regex) ? ',' : '') . $param . '=~^\d{0\,' . ($digits - 1) . '}' . $end; 2429 2483 } 2430 2484 … … 2439 2493 * @return string 2440 2494 */ 2441 static function formatLtEqRegexFilter($param, $number, $key = '' ) {2495 static function formatLtEqRegexFilter($param, $number, $key = '', $options = array()) { 2442 2496 $end = ($key) ? '&' : "$"; 2443 2497 $nstr = (string)$number; -
intelligence/trunk/vendor/levelten/intel/js/l10intel_admin.js
r1756687 r2947915 26 26 27 27 this.bindEventCallback = function bindEventCallback(evtDef, $target) { 28 //console.log('admin:bindEventCallback()', evtDef, $target); 28 29 var evt = {}; 29 30 var options = { -
intelligence/trunk/vendor/levelten/intel/js/l10intel_formtracker.js
r1814908 r2947915 8 8 var ths = {}; 9 9 10 this.formDefs = {}; 10 this.formDefs = []; 11 this.formDefsIndex = {}; 11 12 12 13 13 14 this.init = function init() { 14 15 var ths = this; 15 $('form').not('.formtracker-0').on('submit', ths.eventHandler);16 //$('form').not('.formtracker-0').on('submit', ths.eventHandler); 16 17 //$('a').on('mouseover', {eventType: 'click'}, ths.eventHandler); // for testing event sends 17 18 }; 18 19 19 th s.trackForm = function trackForm(def) {20 this.trackForm = function trackForm(def) { 20 21 if (ioq.isArray(def)) { 21 22 for (var i = 0; i < def.length; i++) { 22 th s.trackFormInit(def[i]);23 } 24 } 25 else { 26 th s.trackFormInit(def);27 } 28 }; 29 30 th s.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) { 31 32 //console.log('trackFormInit()'); 32 33 //console.log(def); 34 var ths = _ioq.plugins.formtracker; 33 35 34 36 var $obj, $this, $onObj, enable = 1, $dataField, def2; 37 var key = def.key || def.formId; 38 35 39 if (ioq.isNull(def)) { 36 40 def = {}; 37 41 } 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); 40 44 } 41 45 … … 86 90 io('event', evtDef); 87 91 } 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 } 88 101 89 102 /* Disabling logic until full conversion tracking can be implemented … … 131 144 } 132 145 146 147 if (key) { 148 if (!ths.formDefsIndex[key]) { 149 ths.formDefsIndex[key] = ths.formDefs.length; 150 ths.formDefs.push(def); 151 } 152 } 153 133 154 return def; 134 155 135 156 }; 136 157 137 th s.processFormSpecialFields = function (def, $obj, event) {158 this.processFormSpecialFields = function (def, $obj, event) { 138 159 var pf = 'io'; 139 160 if ($obj.is('form')) { … … 196 217 this.init(); 197 218 198 return ths;199 219 } 200 220 -
intelligence/trunk/vendor/levelten/intel/js/l10intel_linktracker.js
r1904936 r2947915 30 30 this.linkTypeDefs.download = { 31 31 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', 33 34 }; 34 35 this.linkTypeDefs.mailto = { … … 115 116 116 117 this.addHrefType = function addHrefType(name, obj) { 117 this.hrefTypeDefs[name] = obj;118 this.hrefTypeDefs[name] = obj; 118 119 }; 119 120 … … 159 160 160 161 f.hrefType = ''; 161 162 162 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'); 164 165 165 166 f.hrefObj = _ioq.parseUrl(f.href); … … 197 198 linkDef = f.linkTypeDefs[f.linkType] || {}; 198 199 if (linkDef.track || f.$obj.objSettings['link-track'] || f.$obj.objSettings['link-' + f.eventType + '-track']) { 199 console.log();200 200 f.evtDef.eventCategory = linkDef.title; 201 201 if (f.eventType) { -
intelligence/trunk/vendor/levelten/intel/libs/class.debug.php
r1653685 r2947915 20 20 */ 21 21 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); 28 25 } 29 26 else { 30 print_r($var); 27 if ($mode == 1) { 28 return print_r($var, 1); 29 } 30 else { 31 print_r($var); 32 } 31 33 } 32 34 }
Note: See TracChangeset
for help on using the changeset viewer.