[ Index ]

MailPress 7.0.1

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

title

Body

[close]

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

   1  <?php
   2  global $mp_general;
   3  if (!isset($mp_general['gmapkey']) || empty($mp_general['gmapkey'])) return;
   4  
   5  class MP_Tracking_metabox_m006 extends MP_tracking_metabox_
   6  {
   7      const prefix = 'tracking_m006';
   8  
   9      var $id    = 'm006';
  10      var $context= 'side';
  11      var $file     = __FILE__;
  12  
  13  	function __construct( $title )
  14      {
  15          add_filter( 'MailPress_scripts', array( $this, 'scripts' ), 8, 2 );
  16          parent::__construct( $title );
  17      }
  18      
  19  	function scripts( $scripts )
  20      {
  21          if ( !isset( MP_AdminPage::$get_['id'] ) ) return $scripts;
  22  
  23          $scripts[] = MP_Map::print_scripts();
  24  
  25          return $scripts;
  26      }
  27  
  28  	function meta_box( $mail )
  29      {
  30      // m006
  31          global $wpdb;
  32          $m = array();
  33  
  34          $tracks = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT ip, user_id FROM $wpdb->mp_tracks WHERE mail_id = %d ", $mail->id ) );
  35  
  36          if ( $tracks )
  37          {
  38              foreach( $tracks as $track )
  39              {
  40                  $x = MP_Ip::get_latlng( $track->ip );
  41  
  42                  if ( !$x ) continue;
  43  
  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                  $user = MP_User::get( $track->user_id );
  49                  if ( get_option( 'show_avatars' ) ) $x['info'] = get_avatar( $user->email, 32 );
  50                  $flag   = ( ( 'ZZ' == $user->created_country ) || empty( $user->created_country ) ) ? '' : '<img class="flag" alt="' . strtolower( $user->created_country ) . '" title="' . strtolower( $user->created_country ) . '" src="' . site_url() . '/' . MP_PATH . 'mp-admin/images/flag/' . strtolower( $user->created_country ) . '.gif" />';
  51                  $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>';
  52  
  53                  $m['t006'][] = $x;
  54              }
  55          }
  56  
  57      // t006_user_settings
  58          $u['t006_user_settings'] = MP_Mail_meta::get( $mail->id, '_MailPress_' . self::prefix );
  59          if ( !$u['t006_user_settings'] ) $u['t006_user_settings'] = get_user_option( '_MailPress_' . self::prefix );
  60          if ( !isset( $def_lat ) ) $def_lat = 48.8352;
  61          if ( !isset( $def_lng ) ) $def_lng = 2.4718;
  62          if ( !$u['t006_user_settings'] ) $u['t006_user_settings'] = array( 'center_lat' => $def_lat, 'center_lng' => $def_lng, 'zoomlevel' => 3, 'maptype' => 'NORMAL' );
  63          $u['t006_user_settings']['prefix'] = self::prefix;
  64  
  65          $out = '';
  66  
  67          $out .= '<script type="text/javascript">' . "\r\n";
  68          $out .= '/* <![CDATA[ */' . "\r\n";
  69          foreach ( $u as $var => $val )
  70          {
  71              $out .= 'var ' . $var . ' = ' . MP_AdminPage::print_scripts_l10n_val( $val );
  72          }
  73          $out .= ';' . "\r\n";
  74          foreach ( $m as $var => $val )
  75          {
  76              $out .= 'var ' . $var . ' = ' . MP_AdminPage::print_scripts_l10n_val( $val );
  77          }
  78          $out .= ';' . "\r\n";
  79          $out .= '/* ]]> */' . "\r\n";
  80          $out .= '</script>' . "\r\n";
  81  
  82          $out .= '<div id="' . self::prefix . '_map" style="overflow:hidden;height:500px;width:auto;padding:0;margin:0;"></div>';
  83       
  84          foreach( $u['t006_user_settings'] as $k => $v ) 
  85          {
  86                  if ( 'prefix' == $k ) continue;
  87              $out .= '<input type="hidden" id="' . self::prefix . '_' . $k . '" value="' . esc_attr( $v ) . '" />';
  88          }
  89  
  90          echo $out;
  91      }
  92  }
  93  new MP_Tracking_metabox_m006( __( 'Geoip', 'MailPress' ) );


Generated: Mon Jan 28 00:07:10 2019 Cross-referenced by PHPXref 0.7.1