[ Index ]

MailPress 7.1

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

title

Body

[close]

/mp-includes/class/options/tracking/metaboxes/mail/ -> m006.php (source)

   1  <?php
   2  class MP_Tracking_metabox_m006 extends MP_tracking_metabox_
   3  {
   4      const prefix = 'tracking_m006';
   5  
   6      var $id    = 'm006';
   7      var $context= 'side';
   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( $mail )
  26      {
  27      // m006
  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 mail_id = %d ", $mail->id ) );
  34  
  35          if ( $tracks )
  36          {
  37              foreach( $tracks as $track )
  38              {
  39                  $x = MP_Ip::get_latlng( $track->ip );
  40  
  41                  if ( !$x ) continue;
  42  
  43                  if ( !isset( $def_lat ) && isset( $x['lat'] ) ) $def_lat = $x['lat'];
  44                  if ( !isset( $def_lng ) && isset( $x['lng'] ) ) $def_lng = $x['lng'];
  45                  $x['ip'] = $track->ip;
  46  
  47                  $user = MP_User::get( $track->user_id );
  48                  if ( get_option( 'show_avatars' ) ) $x['info'] = get_avatar( $user->email, 32 );
  49                  $flag   = ( ( 'ZZ' == $user->created_country ) || empty( $user->created_country ) ) ? '' : '<div class="mp_flag mp_flag_' . strtolower( $user->created_country ) . '" title="' . esc_attr( strtolower( $user->created_country ) ) . '"></div>';
  50                  $x['info'] = '<table><tr><td style="text-align:center;">' . ( ( get_option( 'show_avatars' ) ) ? str_replace( "'", '"', get_avatar( $user->email, 32 ) ) : '' ) . '<br style="line-height:0;" /><br style="line-height:3px;" />' . $flag . '</td><td style="text-align:center;padding-left:5px;">' . $user->email . '<br />' . $user->name . '<br />' . $track->ip . '</td></tr></table>';
  51  
  52                  $t['t006']['markers'][] = $x;
  53              }
  54          }
  55  
  56      // t006 settings
  57          $t['t006']['settings'] = MP_Mail_meta::get( $mail->id, '_MailPress_' . self::prefix );
  58          if ( !$t['t006']['settings'] ) $t['t006']['settings'] = get_user_option( '_MailPress_' . self::prefix );
  59          if ( !isset( $def_lat ) ) $def_lat = 48.8352;
  60          if ( !isset( $def_lng ) ) $def_lng = 2.4718;
  61          if ( !$t['t006']['settings'] ) $t['t006']['settings'] = array( 'center_lat' => $def_lat, 'center_lng' => $def_lng, 'zoomlevel' => 3, 'maptype' => 'NORMAL' );
  62          $t['t006']['settings']['prefix'] = self::prefix;
  63          $t['t006']['settings']['count'] = ( isset( $t['t006']['markers'] ) ) ? count( $t['t006']['markers'] ) : 0;
  64  
  65          $out = '';
  66  
  67          $out .= '<script type="text/javascript">' . "\r\n";
  68          $out .= '/* <![CDATA[ */' . "\r\n";
  69          foreach ( $t as $var => $val )
  70          {
  71              $out .= 'var ' . $var . ' = ' . MP_AdminPage::print_scripts_l10n_val( $val );
  72          }
  73          $out .= ';' . "\r\n";
  74          $out .= '/* ]]> */' . "\r\n";
  75          $out .= '</script>' . "\r\n";
  76  
  77          $out .= '<div id="' . self::prefix . '_map" style="overflow:hidden;height:500px;width:auto;padding:0;margin:0;"></div>';
  78       
  79          foreach( $t['t006']['settings'] as $k => $v ) 
  80          {
  81                  if ( 'prefix' == $k ) continue;
  82              $out .= '<input type="hidden" id="' . self::prefix . '_' . $k . '" value="' . esc_attr( $v ) . '" />';
  83          }
  84  
  85          echo $out;
  86      }
  87  }
  88  new MP_Tracking_metabox_m006( __( 'Geoip', 'MailPress' ) );


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