[ Index ]

MailPress 544

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

title

Body

[close]

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

   1  <?php
   2  class MP_Tracking_metabox_m011 extends MP_tracking_metabox_
   3  {
   4      var $id    = 'm011';
   5      var $context= 'normal';
   6      var $file     = __FILE__;
   7  
   8  	function __construct($title)
   9      {
  10          if (!class_exists('MP_Tracking_recipients', false)) new MP_Tracking_recipients();
  11          parent::__construct($title);
  12      }
  13  
  14  	function meta_box($mail)
  15      {
  16          global $wpdb;
  17  
  18          if (is_email($mail->toemail)) $m[$mail->toemail] = $mail->toemail;
  19          else $m = unserialize($mail->toemail);
  20          unset($m['MP_Mail']);
  21          $total = count($m);
  22  
  23          foreach($m as $email => $v)
  24          {
  25              $ug = apply_filters('MailPress_tracking_recipients_domain_get', $email);
  26              $key = $ug->name;
  27              if (isset($x[$key]['count']))     $x[$key]['count']++;
  28              else                         $x[$key]['count'] = 1;
  29              if (isset($ug->icon_path) && !isset($x[$key]['img'])) $x[$key]['img'] = $ug->icon_path;
  30              $opened = $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT user_id FROM $wpdb->mp_tracks WHERE mail_id = %d AND user_id = %d AND track = %s ;", $mail->id, $v['{{_user_id}}'], MailPress_tracking_openedmail) );
  31              if ($opened)
  32              {
  33                  if (isset($x[$key]['opened']))     $x[$key]['opened']++;
  34                  else                         $x[$key]['opened'] = 1;
  35              }
  36          }
  37  
  38          if (isset($x[''])) { $w = $x['']; unset($x['']); } else unset($w);
  39          uasort($x, create_function('$a, $b', 'return $b["count"] - $a["count"];'));
  40          if (isset($w)) $x[''] = $w;
  41  
  42          echo '<table id ="tracking_mp_010">';
  43          echo '<tr><th>' . __('domain', MP_TXTDOM) . '</th><th class="num">' . __('count', MP_TXTDOM) . '</th><th class="num">' . __('%', MP_TXTDOM) . '</th><th class="num">' . __('open rate', MP_TXTDOM) . '</th></tr>';
  44          foreach($x as $k => $v)
  45          {
  46              $k = (empty($k)) ? __('others', MP_TXTDOM) : $k;
  47              echo '<tr>';
  48              echo (isset($v['img'])) ? "<td><img src='{$v['img']}' alt='' /> $k </td>" : "<td> $k </td>";
  49              echo '<td class="num">' . $v['count'] . '</td>';
  50              echo '<td class="num">' . sprintf("%01.2f %%",100 * $v['count']/$total ) . '</td>';
  51              echo (isset($v['opened'])) ? '<td class="num">' . sprintf("%01.2f %%",100 * $v['opened']/$v['count'] ) . '</td>' : '<td></td>';
  52              echo '</tr>';
  53          }
  54          echo '</table>';
  55      }
  56  }
  57  new MP_Tracking_metabox_m011(__('Domain recipients', MP_TXTDOM));


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