[ Index ]

MailPress 7.1

[ 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( MP_AdminPage::$get_['id'] ) ) return $scripts;
  19  
  20          $scripts[] = MP_Map::print_scripts();
  21  
  22          return $scripts;
  23      }
  24  
  25  	function meta_box( $mp_user )
  26      {
  27      // u006
  28          global $wpdb;
  29          $t = array();
  30          $t['t006']['settings'] = null;
  31  
  32      // t006 markers
  33          $tracks = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT ip, user_id FROM $wpdb->mp_tracks WHERE user_id = %d ;", $mp_user->id ) );
  34  
  35          if ( $tracks )
  36          {
  37              foreach( $tracks as $track )
  38              {
  39                  $y = MP_Ip::get_all( $track->ip );
  40  
  41                  if ( !isset( $y['geo'] ) ) continue;
  42  
  43                  $x = $y['geo'];
  44                  if ( !isset( $def_lat ) && isset( $x['lat'] ) ) $def_lat = $x['lat'];
  45                  if ( !isset( $def_lng ) && isset( $x['lng'] ) ) $def_lng = $x['lng'];
  46                  $x['ip'] = $track->ip;
  47  
  48                  if ( isset( $y['html'] ) )     $x['info']  = str_replace( '"', '&quote;', $y['html'] );
  49                  if ( isset( $y['provider'] ) ) $x['info'] .= str_replace( '"', '&quote;', '<div><p style=\'margin:3px;\'><i><small>' . sprintf( __( 'ip data provided by %1$s', 'MailPress' ), $y['provider']['credit'] ) . '</small></i></p></div>' );
  50  
  51                  $t['t006']['markers'][] = $x;
  52              }
  53          }
  54  
  55      // t006 settings
  56          $t['t006']['settings'] = MP_User_meta::get( $mp_user->id, '_MailPress_' . self::prefix );
  57          if ( !$t['t006']['settings'] ) $t['t006']['settings'] = get_user_option( '_MailPress_' . self::prefix );
  58          if ( !isset( $def_lat ) ) $def_lat = 48.8352;
  59          if ( !isset( $def_lng ) ) $def_lng = 2.4718;
  60          if ( !$t['t006']['settings'] ) $t['t006']['settings'] = array( 'center_lat' => $def_lat, 'center_lng' => $def_lng, 'zoomlevel' => 3, 'maptype' => 'NORMAL' );
  61          $t['t006']['settings']['prefix'] = self::prefix;
  62          $t['t006']['settings']['count'] = ( isset( $t['t006']['markers'] ) ) ? count( $t['t006']['markers'] ) : 0;
  63  
  64          $out = '';
  65  
  66          $out .= '<script type="text/javascript">' . "\r\n";
  67          $out .= '/* <![CDATA[ */' . "\r\n";
  68          foreach ( $t as $var => $val )
  69          {
  70              $out .= 'var ' . $var . ' = ' . MP_AdminPage::print_scripts_l10n_val( $val );
  71          }
  72          $out .= ';' . "\r\n";
  73          $out .= '/* ]]> */' . "\r\n";
  74          $out .= '</script>' . "\r\n";
  75  
  76          $out .= '<div id="' . self::prefix . '_map" style="overflow:hidden;height:500px;width:auto;padding:0;margin:0;"></div>';
  77  
  78          foreach( $t['t006']['settings'] as $k => $v ) 
  79          {
  80                  if ( 'prefix' == $k ) continue;
  81              $out .= '<input type="hidden" id="' . self::prefix . '_' . $k . '" value="' . esc_attr( $v ) . '" />';
  82          }
  83  
  84          echo $out;
  85      }
  86  }
  87  new MP_Tracking_metabox_u006( __( 'Geoip', 'MailPress' ) );


Generated: Mon Mar 11 18:33:33 2019 Cross-referenced by PHPXref 0.7.1