[ Index ]

MailPress 544

[ Index ]     [ Classes ]     [ Functions ]     [ Variables ]     [ Constants ]     [ Statistics ]    

title

Body

[close]

/mp-includes/class/options/tracking/metaboxes/user/ -> u006.php (source)

   1  <?php
   2  class MP_Tracking_metabox_u006 extends MP_tracking_metabox_
   3  {
   4      const prefix = 'tracking_u006';
   5  
   6      var $id    = 'u006';
   7      var $context= 'normal';
   8      var $file     = __FILE__;
   9  
  10  	function __construct($title)
  11      {
  12          add_filter('MailPress_scripts', array($this, 'scripts'), 8, 2);
  13          parent::__construct($title);
  14      }
  15      
  16  	function scripts($scripts)
  17      {
  18          if (!isset($_GET['id'])) return $scripts;
  19      // google map
  20          wp_register_script( 'google-map',    'http://maps.googleapis.com/maps/api/js?sensor=false', false, false, 1);
  21  
  22      // mp-gmap3
  23          wp_register_script( 'mp-gmap3',    '/' . MP_PATH . 'mp-includes/js/mp_gmap3.js', array('google-map', 'schedule'), false, 1);
  24          wp_localize_script( 'mp-gmap3',     'mp_gmapL10n', array(
  25              'id'        => $_GET['id'],
  26              'type'    => 'mp_user',
  27              'url'        => site_url() . '/' . MP_PATH . 'mp-admin/images/',
  28              'ajaxurl'    => MP_Action_url,
  29              'center'    => esc_js(__('Center', MP_TXTDOM)),
  30              'changemap'    => esc_js(__('Change map', MP_TXTDOM))
  31          ));
  32          $scripts[] = 'mp-gmap3';
  33  
  34      // markerclusterer
  35          wp_register_script( 'mp-markerclusterer',    '/' . MP_PATH . 'mp-includes/js/markerclusterer/markerclusterer_compiled.js', false, false, 1);
  36          $scripts[] = 'mp-markerclusterer';
  37  
  38          return $scripts;
  39      }
  40  
  41  	function meta_box($mp_user)
  42      {
  43      // u006
  44          global $wpdb;
  45          $m = array();
  46  
  47          $tracks = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT ip, user_id FROM $wpdb->mp_tracks WHERE user_id = %d ;", $mp_user->id) );
  48  
  49          if ($tracks)
  50          {
  51              foreach($tracks as $track)
  52              {
  53                  $y = MP_Ip::get_all($track->ip);
  54                  if ($y)
  55                  {
  56                      $x = $y['geo'];
  57                      if (!isset($def_lat) && isset($x['lat'])) $def_lat = $x['lat'];
  58                      if (!isset($def_lng) && isset($x['lng'])) $def_lng = $x['lng'];
  59                      $x['ip'] = $track->ip;
  60  
  61                      if (isset($y['html']))     $x['info']  = str_replace('"', '&quote;', $y['html']);
  62                      if (isset($y['provider'])) $x['info'] .= str_replace('"', '&quote;', "<div><p style='margin:3px;'><i><small>" . sprintf(__('ip data provided by %1$s', MP_TXTDOM), $y['provider']['credit']) . "</small></i></p></div>");
  63  
  64                      $m['t006'][] = $x;
  65                  }
  66              }
  67          }
  68  ?>
  69  <script type='text/javascript'>
  70  /* <![CDATA[ */
  71  <?php
  72      // t006_user_settings
  73          $u['t006_user_settings'] = MP_User_meta::get($mp_user->id, '_MailPress_' . self::prefix);
  74          if (!$u['t006_user_settings']) $u['t006_user_settings'] = get_user_option('_MailPress_' . self::prefix);
  75          if (!isset($def_lat)) $def_lat = 48.8352;
  76          if (!isset($def_lng)) $def_lng = 2.4718;
  77          if (!$u['t006_user_settings']) $u['t006_user_settings'] = array('center_lat' => $def_lat, 'center_lng' => $def_lng, 'zoomlevel' => 3, 'maptype' => 'NORMAL');
  78          $u['t006_user_settings']['prefix'] = self::prefix;
  79  
  80          $eol = "";
  81          foreach ( $u as $var => $val ) {
  82              echo "var $var = " . MP_AdminPage::print_scripts_l10n_val($val);
  83              $eol = ",\n\t\t";
  84          }
  85          echo ";\n";
  86  
  87          $eol = "";
  88          foreach ( $m as $var => $val ) {
  89              echo "var $var = " . MP_AdminPage::print_scripts_l10n_val($val);
  90              $eol = ",\n\t\t";
  91          }
  92          echo ";\n";
  93  ?>
  94  /* ]]> */
  95  </script>
  96          <div id='<?php echo self::prefix; ?>_map' style='height:500px;width:auto;padding:0;margin:0;overflow:hidden;'></div>
  97  <?php     
  98          foreach($u['t006_user_settings'] as $k => $v) 
  99          {
 100                  if ('prefix' == $k) continue;
 101  ?>
 102          <input type='hidden' id='<?php echo self::prefix . '_' . $k; ?>' value="<?php echo $v; ?>" />
 103  <?php
 104          }
 105      }
 106  }
 107  new MP_Tracking_metabox_u006(__('Geoip', MP_TXTDOM));


Generated: Thu Apr 28 18:38:52 2016 Cross-referenced by PHPXref 0.7.1