[ Index ]

MailPress 544

[ 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($_GET['id'])) return;
  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_mail',
  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($mail)
  42      {
  43      // m006
  44          global $wpdb;
  45          $m = array();
  46  
  47          $tracks = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT ip, user_id FROM $wpdb->mp_tracks WHERE mail_id = %d ", $mail->id) );
  48  
  49          if ($tracks)
  50          {
  51              foreach($tracks as $track)
  52              {
  53                  $x = MP_Ip::get_latlng($track->ip);
  54                  if ($x)
  55                  {
  56                      if (!isset($def_lat) && isset($x['lat'])) $def_lat = $x['lat'];
  57                      if (!isset($def_lng) && isset($x['lng'])) $def_lng = $x['lng'];
  58                      $x['ip'] = $track->ip;
  59  
  60                      $user = MP_User::get($track->user_id);
  61                      if (get_option('show_avatars')) $x['info'] = get_avatar( $user->email, 32 );
  62                      $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' />";
  63                       $x['info'] = "<table><tr><td style='text-align:center;'>" . ((get_option('show_avatars')) ? 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 />" . esc_js($user->name) . "<br />{$track->ip}</td></tr></table>";
  64  
  65                      $m['t006'][] = $x;
  66                  }
  67              }
  68          }
  69  ?>
  70  <script type='text/javascript'>
  71  /* <![CDATA[ */
  72  <?php
  73      // t006_user_settings
  74          $u['t006_user_settings'] = MP_Mail_meta::get($mail->id, '_MailPress_' . self::prefix);
  75          if (!$u['t006_user_settings']) $u['t006_user_settings'] = get_user_option('_MailPress_' . self::prefix);
  76          if (!isset($def_lat)) $def_lat = 48.8352;
  77          if (!isset($def_lng)) $def_lng = 2.4718;
  78          if (!$u['t006_user_settings']) $u['t006_user_settings'] = array('center_lat' => $def_lat, 'center_lng' => $def_lng, 'zoomlevel' => 3, 'maptype' => 'NORMAL');
  79          $u['t006_user_settings']['prefix'] = self::prefix;
  80  
  81          $eol = "";
  82          foreach ( $u as $var => $val ) {
  83              echo "var $var = " . MP_AdminPage::print_scripts_l10n_val($val);
  84              $eol = ",\n\t\t";
  85          }
  86          echo ";\n";
  87  
  88          $eol = "";
  89          foreach ( $m as $var => $val ) {
  90              echo "var $var = " . MP_AdminPage::print_scripts_l10n_val($val);
  91              $eol = ",\n\t\t";
  92          }
  93          echo ";\n";
  94  ?>
  95  /* ]]> */
  96  </script>
  97          <div id='<?php echo self::prefix; ?>_map' style='overflow:hidden;height:500px;width:auto;padding:0;margin:0;'></div>
  98  <?php     
  99          foreach($u['t006_user_settings'] as $k => $v) 
 100          {
 101                  if ('prefix' == $k) continue;
 102  ?>
 103          <input type='hidden' id='<?php echo self::prefix . '_' . $k; ?>' value="<?php echo $v; ?>" />
 104  <?php
 105          }
 106      }
 107  }
 108  new MP_Tracking_metabox_m006( __('Geoip', MP_TXTDOM));


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