WYSIJA_view_back_subscribers

The MailPoet Newsletters WYSIJA view back subscribers class.

Defined (1)

The class is defined in the following location(s).

/views/back/subscribers.php  
  1. class WYSIJA_view_back_subscribers extends WYSIJA_view_back 
  2.  
  3. var $icon = "icon-users"; 
  4. var $column_action_list = "email"; 
  5.  
  6. function __construct() 
  7. $this->title = __("Lists and Subscribers", WYSIJA); 
  8. parent::__construct(); 
  9.  
  10. $this->search = array("title" => __("Search subscribers", WYSIJA)); 
  11. $this->column_actions = array('editlist' => __('Edit', WYSIJA), 'duplicatelist' => __('Duplicate', WYSIJA), 'deletelist' => __('Delete', WYSIJA)); 
  12.  
  13.  
  14. function main($data) 
  15. echo '<form method="post" action="#currentform" id="posts-filter">'; 
  16. $this->filtersLink($data); 
  17. $this->filterDDP($data); 
  18. $this->listing($data); 
  19. $this->limitPerPage(); 
  20. echo '</form>'; 
  21.  
  22. function menuTop($case = false) { 
  23. if (!$case) 
  24. $case = $this->menuTop; 
  25.  
  26. $arrayTrans = array("backtolist" => __("Back to lists", WYSIJA), "back" => __("Back", WYSIJA), "add" => __('Add Subscriber', WYSIJA), "addlist" => __('Add List', WYSIJA), "lists" => __('Edit Lists', WYSIJA), "import" => __('Import', WYSIJA), "export" => __('Export', WYSIJA)); 
  27.  
  28. switch ($case) { 
  29. case "add": 
  30. case "edit": 
  31. case "export": 
  32. case "import": 
  33. case "addlist": 
  34. case "editlist": 
  35. default: 
  36. $arrayMenus = array("add", "addlist", "lists", "import", "export"); 
  37.  
  38. $html = ""; 
  39. $classes = function_exists('wp_star_rating') ? 'add-new-h2' : 'button-secondary2'; 
  40. foreach ($arrayMenus as $action) { 
  41. if (isset($_GET['action']) && $_GET['action'] == $action) 
  42. continue; // Skip printing the list if we are in this action already 
  43.  
  44. $html.= '<a href="admin.php?page=wysija_subscribers&action='.$action.'" class="'.$classes.'">'.$arrayTrans[$action].'</a>'; 
  45.  
  46. return $html; 
  47.  
  48. function filterDDP($data) 
  49. ?> 
  50. <ul class="subsubsub"> 
  51. <?php 
  52. $total = count($data['counts']); 
  53. $i = 1; 
  54. foreach ($data['counts'] as $countType => $count) 
  55. if (!$count) 
  56. continue; 
  57. switch ($countType) 
  58. case 'all': 
  59. $tradText = __('All', WYSIJA); 
  60. break; 
  61. case 'unconfirmed': 
  62. $tradText = __('Unconfirmed', WYSIJA); 
  63. break; 
  64. case 'unsubscribed': 
  65. $tradText = __('Unsubscribed', WYSIJA); 
  66. break; 
  67. case 'subscribed': 
  68. $tradText = __('Subscribed', WYSIJA); 
  69. break; 
  70. case 'unlisted': 
  71. $tradText = __('Unlisted', WYSIJA); 
  72. break; 
  73. case 'inactive': 
  74. $tradText = __('Never opened or clicked', WYSIJA); 
  75. break; 
  76. $classcurrent = ''; 
  77. $radio_checked = ''; 
  78. if ((isset($_REQUEST['link_filter']) && $_REQUEST['link_filter'] == $countType) || ($countType == 'all' && !isset($_REQUEST['link_filter']))) 
  79. $classcurrent = 'class="current"'; 
  80. $radio_checked = 'checked="checked"'; 
  81. if ($i > 1) 
  82. echo ' | '; 
  83. echo '<li><a '.$classcurrent.' href="admin.php?page=wysija_subscribers&link_filter='.$countType.'">'.$tradText.' <span class="count">('.$count.')</span></a>'; 
  84. echo '<input type="radio" name="wysija[filter][link_filter]" id="link_filter_'.$countType.'" value="'.$countType.'" '.$radio_checked.' style="display:none;"/>'; 
  85. echo '</li>'; 
  86. $i++; 
  87. ?> 
  88. </ul> 
  89. <?php $this->searchBox(); ?> 
  90. <?php 
  91. $action_locale = array( 
  92. 'delete' => __('Delete this subscriber forever?', WYSIJA),  
  93. 'delete_bulk' => __('Delete these subscribers forever?', WYSIJA) 
  94. ); 
  95. ?> 
  96. <div class="tablenav"> 
  97. <div class="alignleft actions"> 
  98. <select name="method" class="global-action" data-locale='<?php echo json_encode($action_locale); ?>'> 
  99. <option selected="selected" value=""><?php _e('Bulk Actions', WYSIJA); ?></option> 
  100. <option value=""><?php _e('Move to list', WYSIJA); ?>...</option> 
  101. <?php 
  102. foreach ($data['lists'] as $listK => $list) 
  103. //if(!(isset($_REQUEST['filter-list']) && $_REQUEST['filter-list']== $listK) && $list['is_enabled']) { // Commented by TNT 
  104. if ($list['is_enabled']) 
  105. ?><option value="actionvar_movetolist-listid_<?php echo $listK ?>" data-nonce="<?php echo $this->secure(array('action' => "actionvar_movetolist-listid_" . $listK), true)?>"><?php 
  106. echo str_repeat(' ', 5).$list['name']; 
  107. if (isset($list['users'])) 
  108. echo ' ('.$list['users'].')'; 
  109. ?></option><?php 
  110. ?> 
  111. <option value=""><?php _e('Add to list', WYSIJA); ?>...</option> 
  112. <?php 
  113. foreach ($data['lists'] as $listK => $list) 
  114. //if(!(isset($_REQUEST['filter-list']) && $_REQUEST['filter-list']== $listK) && $list['is_enabled']) { // Commented by TNT 
  115. if ($list['is_enabled']) 
  116. ?><option value="actionvar_copytolist-listid_<?php echo $listK ?>" data-nonce="<?php echo $this->secure(array('action' => "actionvar_copytolist-listid_" . $listK), true)?>"><?php 
  117. echo str_repeat(' ', 5).$list['name']; 
  118. if (isset($list['users'])) 
  119. echo ' ('.$list['users'].')'; 
  120. ?></option><?php 
  121. ?> 
  122. <option value=""><?php _e('Remove from list', WYSIJA); ?>...</option> 
  123. <?php 
  124. foreach ($data['lists'] as $listK => $list) 
  125. //if(!(isset($_REQUEST['filter-list']) && $_REQUEST['filter-list']== $listK) && $list['is_enabled']) { // Commented by TNT 
  126. if ($list['is_enabled']) 
  127. ?><option value="actionvar_removefromlist-listid_<?php echo $listK ?>" data-nonce="<?php echo $this->secure(array('action' => "actionvar_removefromlist-listid_" . $listK), true)?>"><?php 
  128. echo str_repeat(' ', 5).$list['name']; 
  129. if (isset($list['users'])) 
  130. echo ' ('.$list['users'].')'; 
  131. ?></option><?php 
  132. ?> 
  133. <option value="actionvar_removefromalllists" data-nonce="<?php echo $this->secure(array('action' => "actionvar_removefromalllists" ), true)?>"><?php _e('Remove from all lists', WYSIJA); ?></option> 
  134. <option value="exportlist" data-nonce="<?php echo $this->secure(array('action' => "exportlist" ), true)?>"><?php _e('Export', WYSIJA); ?></option> 
  135. <option value="deleteusers" data-nonce="<?php echo $this->secure(array('action' => "deleteusers" ), true)?>"><?php _e('Delete subscribers', WYSIJA); ?></option> 
  136. <?php 
  137. $config_model = WYSIJA::get('config', 'model'); 
  138. $confirm_dbleoptin = $config_model->getValue('confirm_dbleoptin'); 
  139. if ($confirm_dbleoptin) 
  140. ?> 
  141. <option value="actionvar_confirmusers" data-nonce="<?php echo $this->secure(array('action' => "actionvar_confirmusers" ), true)?>"><?php _e('Confirm unconfirmed subscribers', WYSIJA); ?></option> 
  142. <option value="actionvar_resendconfirmationemail" data-nonce="<?php echo $this->secure(array('action' => "actionvar_resendconfirmationemail" ), true)?>"><?php _e('Resend confirmation email', WYSIJA); ?></option> 
  143. <?php } ?> 
  144. </select> 
  145. <input type="submit" class="bulksubmit button-secondary action" name="doaction" value="<?php echo esc_attr(__('Apply', WYSIJA)); ?>"> 
  146. <?php 
  147. $this->secure(array( 
  148. 'action' => 'bulk_action',  
  149. 'controller' => 'wysija_subscribers' 
  150. )); 
  151. ?> 
  152. </div> 
  153.  
  154. <div class="alignleft actions"> 
  155. <select name="wysija[filter][filter_list]" class="global-filter"> 
  156. <?php 
  157. $is_list_pre_selected = false; 
  158. $options_list = ''; 
  159. foreach ($data['lists'] as $listK => $list) 
  160. $selected = ''; 
  161. if (in_array($listK, $data['selected_lists'])) { 
  162. $selected = ' selected="selected" '; 
  163. $is_list_pre_selected = true; 
  164. if (isset($list['users'])) 
  165. $options_list .= '<option '.$selected.' value="'.$list['list_id'].'">'.$list['name'].' ('.$list['users'].')'.'</option>'; 
  166. else 
  167. $options_list .= '<option '.$selected.' value="'.$list['list_id'].'">'.$list['name'].'</option>'; 
  168.  
  169. ?> 
  170.  
  171. <?php 
  172. // Now, if there is not any selected list, let's select "View all lists" by default. 
  173. $selected = in_array('', $data['selected_lists']) ? ' selected="selected" ' : ''; 
  174. ?> 
  175. <option <?php echo $selected; ?> data-sort='0' value=""><?php _e('View all lists', WYSIJA); ?></option> 
  176. <?php 
  177. $selected = in_array('orphaned', $data['selected_lists']) ? ' selected="selected" ' : ''; 
  178. if (in_array('orphaned', $data['selected_lists'])) { 
  179. $selected = ' selected="selected" '; 
  180. $is_list_pre_selected = true; 
  181. ?> 
  182. <option <?php echo $selected; ?> value="orphaned" data-sort='0'><?php _e('Subscribers in no list', WYSIJA); ?></option> 
  183.  
  184.  
  185. <?php echo $options_list; ?> 
  186. </select> 
  187. <input type="submit" class="filtersubmit button-secondary action" name="doaction" value="<?php echo esc_attr(__('Filter', WYSIJA)); ?>"> 
  188. </div> 
  189.  
  190.  
  191. <?php $this->pagination(); ?> 
  192.  
  193. <div class="clear"></div> 
  194. </div> 
  195. <?php 
  196.  
  197. /** 
  198. * main view 
  199. */ 
  200.  
  201. function listing($data, $simple = false) 
  202. ?> 
  203. <div class="list"> 
  204. <table cellspacing="0" class="widefat fixed"> 
  205. <thead> 
  206. <?php 
  207. $status_sorting = $last_opened_sorting = $last_clicked_sorting = $username_sorting = $created_at_sorting = ' sortable desc'; 
  208. $hiddenOrder = ''; 
  209. if (isset($_REQUEST['orderby'])) 
  210. switch ($_REQUEST['orderby']) 
  211. case 'email': 
  212. $username_sorting = ' sorted '.$_REQUEST['ordert']; 
  213. break; 
  214. case 'created_at': 
  215. $created_at_sorting = ' sorted '.$_REQUEST['ordert']; 
  216. break; 
  217. case 'last_opened': 
  218. $last_opened_sorting = ' sorted '.$_REQUEST['ordert']; 
  219. break; 
  220. case 'last_clicked': 
  221. $last_clicked_sorting = ' sorted '.$_REQUEST['ordert']; 
  222. break; 
  223. case 'status': 
  224. $status_sorting = ' sorted '.$_REQUEST['ordert']; 
  225. break; 
  226. $hiddenOrder = '<input type="hidden" name="orderby" id="wysija-orderby" value="'.esc_attr($_REQUEST["orderby"]).'"/>'; 
  227. $hiddenOrder.='<input type="hidden" name="ordert" id="wysija-ordert" value="'.esc_attr($_REQUEST["ordert"]).'"/>'; 
  228. $header = '<tr class="thead"> 
  229. <th scope="col" id="user-id" class="manage-column column-user-id check-column"><input type="checkbox" /></th> 
  230. <th class="manage-column column-username'.$username_sorting.'" id="email" scope="col" style="width:140px;"><a href="#" class="orderlink" ><span>'.__('Email', WYSIJA).'</span><span class="sorting-indicator"></span></a></th>'; 
  231. $header .='<th class="manage-column column-list-names" id="list-list" scope="col">'.__('Lists', WYSIJA).'</th>'; 
  232. $header .='<th class="manage-column column-status'.$status_sorting.'" id="status" scope="col" style="width:80px;"><a href="#" class="orderlink" ><span>'.__('Status', WYSIJA).'</span><span class="sorting-indicator"></span></a></th>'; 
  233. $header .= '<th class="manage-column column-date'.$created_at_sorting.'" id="created_at" scope="col"><a href="#" class="orderlink" ><span>'.__('Subscribed on', WYSIJA).'</span><span class="sorting-indicator"></span></a></th>'; 
  234. $header .= '<th class="manage-column column-date' . $last_opened_sorting . '" id="last_opened" scope="col"><a href="#" class="orderlink" ><span>' . __('Last open', WYSIJA) . '</span><span class="sorting-indicator"></span></a></th>'; 
  235. $header .= '<th class="manage-column column-date' . $last_clicked_sorting . '" id="last_clicked" scope="col"><a href="#" class="orderlink" ><span>' . __('Last click', WYSIJA) . '</span><span class="sorting-indicator"></span></a></th>'; 
  236.  
  237. $header .= '</tr>'; 
  238. echo $header; 
  239. ?> 
  240. </thead> 
  241. <tfoot> 
  242. <?php 
  243. echo $header; 
  244. ?> 
  245. </tfoot> 
  246. <?php if ($data['show_batch_select']) 
  247. { ?> 
  248. <tr class="batch-select"> 
  249. <td colspan="5"> 
  250. <input type="radio" name="wysija[user][force_select_all]" id="force_select_all" style="display:none;" /> 
  251. <input type="hidden" name="wysija[user][timestamp]" value="<?php echo $data['max_create_at']; ?>"/> 
  252. <div class="force_to_select_all_link" style="display:none"> 
  253. <?php _e('All subscribers on this page are selected.', WYSIJA); ?> 
  254. <a href="javascript:void(0);"><?php echo sprintf(__('Select all %1$s subscribers.', WYSIJA), $data['current_counts']); ?></a> 
  255. </div> 
  256. <div class="clear_select_all" style="display:none"> 
  257. <?php echo sprintf(__('All %1$s subscribers are selected.', WYSIJA), $data['current_counts']); ?> 
  258. <a><?php echo __('Clear selection', WYSIJA); ?></a> 
  259. </div> 
  260. </td> 
  261. </tr> 
  262. <?php 
  263. $class = 'list:'.$this->model->table_name.' '.$this->model->table_name.'-list'; 
  264. $id = 'wysija-'.$this->model->table_name; 
  265. ?> 
  266.  
  267. <tbody class="<?php echo $class; ?>" id="<?php echo $id; ?>"> 
  268. <?php 
  269. $listingRows = ''; 
  270. $alt = true; 
  271.  
  272. $statuses = array('-1' => __('Unsubscribed', WYSIJA), '0' => __('Unconfirmed', WYSIJA), '1' => __('Subscribed', WYSIJA)); 
  273.  
  274. $config = WYSIJA::get('config', 'model'); 
  275. if(!$config->getValue('confirm_dbleoptin')) { 
  276. $statuses['0'] = $statuses['1']; 
  277.  
  278. $links_helper = WYSIJA::get('links', 'helper'); 
  279. foreach ($data['subscribers'] as $row) { 
  280. $classRow = ''; 
  281. if($alt) { 
  282. $classRow = 'alternate'; 
  283.  
  284. ?> 
  285. <tr class="<?php echo $classRow; ?>"> 
  286. <th scope="col" class="check-column" > 
  287. <input type="checkbox" name="wysija[user][user_id][]" id="user_id_<?php echo $row['user_id'] ?>" value="<?php echo esc_attr($row['user_id']) ?>" class="checkboxselec" /> 
  288. </th> 
  289. <td class="username column-username"> 
  290. <?php 
  291. echo get_avatar($row['email'], 32); 
  292. echo '<strong>'.$row['email'].'</strong>'; 
  293. echo '<p style="margin:0;">'.esc_html($row['firstname'].' '.$row['lastname']).'</p>'; 
  294. ?> 
  295. <div class="row-actions"> 
  296. <span class="edit"> 
  297. <a href="<?php echo $links_helper->detailed_subscriber($row['user_id']); ?>" class="submitedit"><?php _e('View stats or edit', WYSIJA) ?></a> 
  298. </span> 
  299. </div> 
  300. </td> 
  301. <td><?php 
  302. if (isset($row['lists'])) 
  303. echo $row['lists']; 
  304. if (isset($row['unsub_lists'])) 
  305. echo ' / '; 
  306.  
  307. if (isset($row['unsub_lists'])) 
  308. echo '<span class="wysija-unsubscribed-on" title="'.__('Lists to which the subscriber was subscribed.', WYSIJA).'">'.$row['unsub_lists'].'</span>'; 
  309. ?></td> 
  310. <td><?php echo $statuses[$row['status']]; ?></td> 
  311. <td><?php echo $this->fieldListHTML_created_at($row['created_at']) ?></td> 
  312. <td><?php echo $this->fieldListHTML_created_at($row['last_opened']) ?></td> 
  313. <td><?php echo $this->fieldListHTML_created_at($row['last_clicked']) ?></td> 
  314. </tr><?php 
  315. $alt = !$alt; 
  316. ?> 
  317.  
  318. </tbody> 
  319. </table> 
  320. </div> 
  321.  
  322. <?php 
  323. echo $hiddenOrder; 
  324.  
  325. function export($data) 
  326. /** make a list of fields to export */ 
  327. ?> 
  328. <form name="submitexport" method="post" id="submitexport" action="" class="form-valid"> 
  329. <table class="form-table"> 
  330. <tbody> 
  331. <?php 
  332. if (!isset($data['subscribers'])) 
  333. {//select a list and export 
  334. /** set the filters necessary to export 
  335. * 1-export a list 
  336. * 2-export all 
  337. * 3-export confirmed 
  338. * 4-export 
  339. */ 
  340.  
  341. $formObj = WYSIJA::get('forms', 'helper'); 
  342. $config = WYSIJA::get('config', 'model'); 
  343. ?> 
  344. <tr> 
  345. <th><label for="filterlist"><?php _e("Pick a list", WYSIJA); ?></label></th> 
  346. <td> 
  347. <?php 
  348. $lists_html = ''; 
  349. foreach ($data['lists'] as $listK => $list) 
  350. $lists_html .= '<label><input type="checkbox" name="wysija[export][filter][list][]" checked="checked" class="validate[minCheckbox[1]] checkbox" value="'.esc_attr($list['list_id']).'" />'; 
  351. $lists_html .= ' '.$list['name']; 
  352. $lists_html .= ' <span class="count-confirmed-only">('.$list['subscribers'].')</span>'; 
  353. $lists_html .= '<span class="count-all">('.((int) $list['belonging']).')</span>'; 
  354. $lists_html .= '</label>'; 
  355.  
  356. echo $lists_html; 
  357. ?> 
  358. </td> 
  359. </tr> 
  360. <tr> 
  361. <th><label for="exportformat"><?php _e("Format", WYSIJA); ?></label></th> 
  362. <td> 
  363. <input type="radio" id="export_format1" value=", " checked="checked" name="wysija[export][format]"> 
  364. <label for="export_format1"><?php _e('CSV file', WYSIJA); ?></label> 
  365. <input type="radio" id="export_format2" value=";" name="wysija[export][format]"> 
  366. <label for="export_format2"><?php _e('Excel for Windows', WYSIJA); ?></label> 
  367. </td> 
  368. </tr> 
  369. <?php 
  370. if ($config->getValue('confirm_dbleoptin')) 
  371. ?> 
  372. <tr> 
  373. <th><label for="confirmedcheck"><?php _e("Export confirmed subscribers only", WYSIJA); ?></label></th> 
  374. <td> 
  375. <input type="checkbox" name="wysija[export][filter][confirmed]" checked="checked" value="1" id="confirmedcheck" /> 
  376. </td> 
  377. </tr> 
  378. <?php 
  379. elseif (!empty($data['user']['timestamp']) && !empty($data['user']['force_select_all']) && (bool) $data['user']['force_select_all']) 
  380. { //batch-select and export 
  381. if (!empty($data['filter']) && is_array($data['filter'])) 
  382. foreach ($data['filter'] as $k => $v) 
  383. echo '<input type="hidden" value="'.$v.'" name="wysija[filter]['.$k.']" />'; 
  384. foreach ($data['user'] as $k => $v) 
  385. if ($k != 'user_id') // we don't ask for user_id in case of batch-select 
  386. echo '<input type="hidden" value="'.$v.'" name="wysija[user]['.$k.']" />'; 
  387. ?> 
  388. <tr> 
  389. <th scope="row"> 
  390. <label for="listfields"><?php _e('List of fields to export', WYSIJA); ?></label> 
  391. </th> 
  392. <td> 
  393. <?php 
  394. $model_user_field = WYSIJA::get('user_field', 'model'); 
  395. $fields = $model_user_field->getFields(); 
  396.  
  397. $helper_forms = WYSIJA::get('forms', 'helper'); 
  398. echo $helper_forms->checkboxes(array('class' => 'validate[minCheckbox[1]] checkbox', 'name' => 'wysija[export][fields][]', 'id' => 'wysijafields'), $fields); 
  399. ?> 
  400. </td> 
  401. </tr> 
  402. </tbody> 
  403. </table> 
  404. <p class="submit"> 
  405. <input type="hidden" name="wysija[export][user_ids]" id="user_ids" value="<?php if (isset($data['subscribers'])) echo base64_encode(json_encode($data['subscribers'])) ?>" /> 
  406. <input type="hidden" value="export_get" name="action" /> 
  407. <?php $this->secure(array('action' => "export_get")); ?> 
  408. <input type="submit" value="<?php echo esc_attr(__('Export', WYSIJA)) ?>" class="button-primary wysija"> 
  409. </p> 
  410. </form> 
  411. <?php 
  412.  
  413. function add($data = false) 
  414. $this->buttonsave = __('Save', WYSIJA); 
  415. if (!$data['user'] || isset($this->add)) 
  416.  
  417. $this->buttonsave = __('Add Subscriber', WYSIJA); 
  418.  
  419. $formid = 'wysija-'.$_REQUEST['action']; 
  420. ?> 
  421. <form name="<?php echo $formid ?>" method="post" id="<?php echo $formid ?>" action="" class="form-valid"> 
  422.  
  423. <table class="form-table"> 
  424. <tbody> 
  425. <tr> 
  426. <th scope="row"> 
  427. <label for="email"><?php _e('Email', WYSIJA); ?></label> 
  428. </th> 
  429. <td> 
  430. <input type="text" size="40" class="validate[required, custom[email]]" id="email" value="<?php if ($data['user']) echo esc_attr($data['user']['details']['email']) ?>" name="wysija[user][email]" /> 
  431. </td> 
  432. </tr> 
  433.  
  434. <tr> 
  435. <th scope="row"> 
  436. <label for="fname"><?php _e('First name', WYSIJA); ?></label> 
  437. </th> 
  438. <td> 
  439. <input type="text" size="40" id="fname" value="<?php if ($data['user']) echo esc_attr($data['user']['details']['firstname']) ?>" name="wysija[user][firstname]" /> 
  440. </td> 
  441. </tr> 
  442.  
  443. <tr> 
  444. <th scope="row"> 
  445. <label for="lname"><?php _e('Last name', WYSIJA); ?></label> 
  446. </th> 
  447. <td> 
  448. <input type="text" size="40" id="lname" value="<?php if ($data['user']) echo esc_attr($data['user']['details']['lastname']) ?>" name="wysija[user][lastname]" /> 
  449. </td> 
  450. </tr> 
  451. <tr> 
  452. <th scope="row"> 
  453. <label for="user-status" ><?php _e('Status', WYSIJA); ?></label> 
  454. </th> 
  455. <td> 
  456. <?php 
  457. $form_obj = WYSIJA::get('forms', 'helper'); 
  458. $user_status = 1; 
  459. $config = WYSIJA::get('config', 'model'); 
  460. if ($config->getValue("confirm_dbleoptin")) 
  461. $statusddp = array('1' => __('Subscribed', WYSIJA), '0' => __('Unconfirmed', WYSIJA), '-1' => __('Unsubscribed', WYSIJA)); 
  462. if ($data['user']) 
  463. $user_status = $data['user']['details']['status']; 
  464. }else 
  465. $statusddp = array('1' => __('Subscribed', WYSIJA), '-1' => __('Unsubscribed', WYSIJA)); 
  466. if ($data['user']) 
  467. if ((int) $data['user']['details']['status'] == 0) 
  468. $user_status = 1; 
  469. else 
  470. $user_status = $data['user']['details']['status']; 
  471.  
  472.  
  473. echo "<p>".$form_obj->radios( 
  474. array('id' => 'user-status', 'name' => 'wysija[user][status]'), $statusddp, $user_status, ' class="validate[required]" ')."</p>"; 
  475. ?> 
  476. </td> 
  477. </tr> 
  478. <tr> 
  479. <th scope="row"> 
  480. <label for="lists" class="title"><?php _e('Lists', WYSIJA); ?></label> 
  481.  
  482. </th> 
  483. <td> 
  484. <?php 
  485. $field_html = ''; 
  486. $field = 'list'; 
  487. $valuefield = array(); 
  488. if ($data['user'] && isset($data['user']['lists'])) 
  489.  
  490. foreach ($data['user']['lists'] as $list) 
  491. $valuefield[$list['list_id']] = $list; 
  492.  
  493. $_display_style = 2; // 1 = 1 column, 2 = float left 
  494. usort( $data['list'], array( $this, 'sort_by_name' ) ); 
  495.  
  496. foreach ($data['list'] as $list) 
  497.  
  498. $checked = false; 
  499. $extra_checkbox = $hidden_field = ''; 
  500.  
  501. if (isset($valuefield[$list['list_id']])) 
  502. //if the subscriber has this list and is not unsubed then we check the checkbox 
  503. if ($valuefield[$list['list_id']]['unsub_date'] <= 0) 
  504. $checked = true; 
  505. else 
  506. //we keep a reference of the list to which we are unsubscribed 
  507. $hidden_field = $form_obj->hidden(array('id' => $field.$list['list_id'], 'name' => 'wysija[user_list][unsub_list][]', 'class' => 'checkboxx'), $list['list_id']); 
  508. $hidden_field.=' / <span class="wysija-unsubscribed-on"> '.sprintf(__('Unsubscribed on %1$s', WYSIJA), date('D, j M Y H:i:s', $valuefield[$list['list_id']]['unsub_date'])).'</span>'; 
  509.  
  510. $checkout_params = array('id' => $field.$list['list_id'], 'name' => "wysija[user_list][list_id][]", 'class' => ''); 
  511. $checkbox = $form_obj->checkbox($checkout_params, $list['list_id'], $checked, $extra_checkbox) . "<label for='list{$list['list_id']}'>{$list['name']}</label>"; 
  512.  
  513. if ($_display_style == 1) 
  514. $field_html.= '<p><label for="'.$field.$list['list_id'].'">'; 
  515. $field_html.=$checkbox; 
  516. $field_html.=$hidden_field; 
  517. $field_html.='</label></p>'; 
  518. else 
  519. $field_html .= '<p class="labelcheck">'; 
  520. $field_html .= $checkbox; 
  521. $field_html .= $hidden_field; 
  522. $field_html .= '</p>'; 
  523.  
  524.  
  525. echo $field_html; 
  526. ?> 
  527. </td> 
  528. </tr> 
  529. <?php 
  530. /** 
  531. Custom Fields. 
  532. */ 
  533. echo WJ_FieldRender::render_all( 
  534. $data['user']['details']['user_id'] 
  535. ); 
  536. ?> 
  537. <tr class='submit_row'> 
  538. <td colspan='2'> 
  539. <?php $this->secure(array('action' => "save", 'id' => $data['user']['details']['user_id'])); ?> 
  540. <input type="hidden" name="wysija[user][user_id]" id="user_id" value="<?php echo esc_attr($data['user']['details']['user_id']) ?>" /> 
  541. <input type="hidden" value="save" name="action" /> 
  542. <input type="submit" value="<?php echo esc_attr($this->buttonsave) ?>" class="button-primary wysija"> 
  543. </td> 
  544. </tr> 
  545. </tbody> 
  546. </table> 
  547. </form> 
  548. <?php 
  549.  
  550. // @todo: move to a helper 
  551. function subscribers_stats($htmlContent, $data) 
  552. $htmlContent = ''; 
  553.  
  554. if (count($data['charts']['stats']) > 0) 
  555. $htmlContent.= '<p>'; 
  556. $helper_licence = WYSIJA::get('licence', 'helper'); 
  557. $url_checkout = $helper_licence->get_url_checkout('subscriber_stats'); 
  558. $htmlContent.= str_replace( 
  559. array('[link]', '[/link]'), array('<a title="'.__('Get Premium now', WYSIJA).'" target="_blank" href="'.$url_checkout.'">', '</a>'), __("Note: Find out what this subscriber opened and clicked with our [link]Premium version.[/link]", WYSIJA)); 
  560. $htmlContent.= '</p>'; 
  561. return $htmlContent; 
  562.  
  563. function edit($data) 
  564. // loop to show the core lists to which the user is subscribed to 
  565. // @todo: we should move this block to controller, or at least a separated function 
  566. foreach ($data['list'] as $keyl => $list) 
  567. if (!$list['is_enabled']) 
  568. //make sure this lists is in the user lists 
  569. foreach ($data['user']['lists'] as $ulist) 
  570. if ($list['list_id'] == $ulist['list_id']) 
  571. continue(2); 
  572. unset($data['list'][$keyl]); 
  573. ?> 
  574. <div id="hook_subscriber_left" class="hook-column left-column hook"> 
  575. <?php $this->add($data); ?> 
  576. <?php if (!empty($data['hooks']['hook_subscriber_left'])) echo $data['hooks']['hook_subscriber_left']; ?> 
  577. </div> 
  578. <?php if (!empty($data['hooks']['hook_subscriber_right'])) 
  579. { ?> 
  580. <div id="hook_subscriber_right" class="hook-column right-column hook"> 
  581. <?php echo $data['hooks']['hook_subscriber_right']; ?> 
  582. </div> 
  583. <?php } ?> 
  584. <?php if (!empty($data['hooks']['hook_subscriber_bottom'])) 
  585. { ?> 
  586. <div id="hook_subscriber_bottom" class="hook"><?php echo $data['hooks']['hook_subscriber_bottom']; ?></div> 
  587. <?php 
  588.  
  589. function globalActionsLists($data = false) 
  590. ?> 
  591. <div class="tablenav"> 
  592.  
  593. <?php $this->pagination("&action=lists"); ?> 
  594. <div class="clear"></div> 
  595. </div> 
  596. <?php 
  597.  
  598. /** 
  599. * main view when editing lists it has one listing and one form 
  600. */ 
  601.  
  602. function lists($data) 
  603. echo '<form method="post" action="" id="posts-filter">'; 
  604. $this->globalActionsLists($data); 
  605. ?> 
  606. <div class="list"> 
  607. <table cellspacing="0" class="widefat fixed" > 
  608. <thead> 
  609. <tr class="thead"> 
  610. <th class="manage-column column-name" id="name-list" scope="col" style="width:30%;"><?php _e('Name', WYSIJA) ?></th> 
  611. <th class="manage-column column-subscribed" id="subscribed-list" scope="col"><?php _e('Subscribed', WYSIJA) ?></th> 
  612. <?php 
  613. $config = WYSIJA::get("config", "model"); 
  614. if ($config->getValue("confirm_dbleoptin")) 
  615. ?><th class="manage-column column-unsubscribed" id="unconfirmed-list" scope="col"><?php _e('Unconfirmed', WYSIJA) ?></th><?php 
  616. ?> 
  617.  
  618. <th class="manage-column column-unsubscribed" id="unsubscribed-list" scope="col"><?php _e('Unsubscribed', WYSIJA) ?></th> 
  619. <?php /** <th class="manage-column column-campaigns" id="campaigns-list" scope="col"><?php _e('Newsletters sent', WYSIJA) ?></th> */ ?> 
  620. <th class="manage-column column-date" id="date-list" scope="col" style="width:15%;"><?php _e('Date created', WYSIJA) ?></th> 
  621. </tr> 
  622. </thead> 
  623.  
  624. <tbody class="list:<?php echo $this->model->table_name.' '.$this->model->table_name.'-list" id="wysija-'.$this->model->table_name.'"' ?>> 
  625. <?php 
  626. $listingRows = ""; 
  627. $alt = true; 
  628. foreach ($data['list'] as $row => $columns) 
  629. $classRow = ""; 
  630. if ($alt) 
  631. $classRow = ' class="alternate" '; 
  632. ?> 
  633. <tr <?php echo $classRow ?> > 
  634. <td class="manage-column column-name" scope="col"> 
  635. <strong><a href="admin.php?page=wysija_subscribers&id=<?php echo $columns['list_id'] ?>&action=editlist" class="submitedit"><?php 
  636. echo $columns['name']; 
  637. ?></a></strong> 
  638. <div class="row-actions"> 
  639. <span class="edit"> 
  640. <a href="admin.php?page=wysija_subscribers&id=<?php echo $columns['list_id'] ?>&action=editlist" class="submitedit"><?php _e('Edit', WYSIJA) ?></a> | 
  641. </span> 
  642. <span class="duplicate"> 
  643. <a href="admin.php?page=wysija_subscribers&id=<?php echo $columns['list_id'] ?>&action=duplicatelist&_wpnonce=<?php echo $this->secure(array("action" => "duplicatelist", "id" => $columns['list_id']), true); ?>" class="submitduplicate"><?php _e('Duplicate', WYSIJA) ?></a> 
  644. </span> 
  645. <?php if ($columns['namekey'] != "users"): ?> 
  646. <span class="delete"> 
  647. <a href="admin.php?page=wysija_subscribers&id=<?php echo $columns['list_id'] ?>&action=deletelist&_wpnonce=<?php echo $this->secure(array("action" => "deletelist", "id" => $columns['list_id']), true); ?>" class="submitdelete"><?php _e('Delete', WYSIJA) ?></a> 
  648. </span> 
  649. <?php 
  650. endif; 
  651. if (!$columns['is_enabled']): 
  652. ?> 
  653. <span class="synch"> 
  654. <a href="admin.php?page=wysija_subscribers&id=<?php echo $columns['list_id'] ?>&action=synchlist&_wpnonce=<?php echo $this->secure(array("action" => "synchlist", "id" => $columns['list_id']), true); ?>" class="submitsynch"><?php _e('Update', WYSIJA) ?></a> 
  655. </span> 
  656. <?php 
  657. endif; 
  658. global $current_user; 
  659.  
  660. if ($columns['namekey'] == 'users' && !$columns['is_enabled'] && is_multisite() && is_super_admin($current_user->ID)): 
  661. ?> 
  662. <span class="synchtotal"> 
  663. <a href="admin.php?page=wysija_subscribers&id=<?php echo $columns['list_id'] ?>&action=synchlisttotal&_wpnonce=<?php echo $this->secure(array("action" => "synchlisttotal", "id" => $columns['list_id']), true); ?>" class="submitsynch"><?php _e('Get all MS users', WYSIJA) ?></a> 
  664. </span> 
  665. <?php endif; ?> 
  666. <?php if (!$columns['is_enabled'] && $columns['namekey'] != 'users'): ?> 
  667. <?php endif; ?> 
  668. <span class="view_subscribers"> 
  669. <a href="admin.php?page=wysija_subscribers&filter-list=<?php echo $columns['list_id'] ?>">| <?php _e('View subscribers', WYSIJA) ?></a> 
  670. </span> 
  671. </div> 
  672.  
  673. </td> 
  674. <td class="manage-column column-subscribed" scope="col"><?php echo $columns['subscribers'] ?></td> 
  675. <?php 
  676. if ($config->getValue("confirm_dbleoptin")) 
  677. ?><td class="manage-column column-unconfirmed" scope="col"><?php echo $columns['unconfirmed'] ?></td><?php 
  678. ?> 
  679.  
  680. <td class="manage-column column-unsubscribed" scope="col"><?php echo $columns['unsubscribers'] ?></td> 
  681. <?php /** <td class="manage-column column-campaigns" scope="col"><?php echo $columns['campaigns_sent'] ?></td> */ ?> 
  682. <td class="manage-column column-date" scope="col"><?php echo $this->fieldListHTML_created_at($columns['created_at']) ?></td> 
  683. </tr> 
  684. <?php 
  685. $alt = !$alt; 
  686. ?> 
  687.  
  688. </tbody> 
  689. </table> 
  690. </div> 
  691. <?php 
  692. echo '</form>'; 
  693.  
  694. function addList($data) 
  695. $this->editList($data); 
  696.  
  697. function editList($data) 
  698. ?> 
  699. <div class="form"> 
  700.  
  701. <form class="form-valid" action="admin.php?page=wysija_subscribers&action=lists<?php if ($data['form']['list_id']) echo "&id=".$data['form']['list_id'] ?>" id="wysija-edit" method="post" name="wysija-edit"> 
  702.  
  703. <input type="hidden" name="wysija[list][list_id]" id="list_id" value="<?php echo esc_attr($data['form']['list_id']) ?>"> 
  704. <table class="form-table"> 
  705. <tbody> 
  706. <tr> 
  707. <th scope="row"> 
  708. <label for="list-name"><?php _e('Name', WYSIJA); ?> </label> 
  709. </th> 
  710. <td> 
  711. <input type="text" size="40" class="validate[required]" id="list-name" value="<?php echo esc_attr($data['form']['name']) ?>" name="wysija[list][name]" /> 
  712. </td> 
  713. </tr> 
  714. <tr> 
  715. <th scope="row"> 
  716. <label for="list-desc"><?php _e('Description', WYSIJA); ?> </label> 
  717. <p class="description"><?php _e('For your own use and never shown to your subscribers.', WYSIJA); ?></p> 
  718. </th> 
  719. <td> 
  720. <textarea type="text" cols="40" rows="3" id="list-desc" name="wysija[list][description]" /><?php echo $data['form']['description'] ?></textarea> 
  721. </td> 
  722. </tr> 
  723. </tbody> 
  724. </table> 
  725. <?php 
  726. if ($_REQUEST['action'] == "editlist") 
  727. $buttonName = __('Update list', WYSIJA); 
  728. else 
  729. $buttonName = __('Add list', WYSIJA); 
  730. ?> 
  731. <p class="submit"> 
  732. <?php $this->secure(array('action' => "savelist", 'id' => $data['form']['list_id'])); ?> 
  733. <input type="hidden" value="savelist" name="action" /> 
  734. <input type="submit" value="<?php echo esc_attr($buttonName) ?>" class="button-primary wysija"> 
  735. </p> 
  736. </form> 
  737. </div> 
  738. <?php 
  739.  
  740. function import($data) 
  741. $helperNumbers = WYSIJA::get('numbers', 'helper'); 
  742. $data = $helperNumbers->get_max_file_upload(); 
  743. $bytes = $data['maxmegas']; 
  744. ?> 
  745. <div class="form"> 
  746. <form class="form-valid" action="admin.php?page=wysija_subscribers&action=lists" id="wysija-edit" enctype="multipart/form-data" method="post" name="wysija-edit"> 
  747. <table class="form-table"> 
  748. <tbody> 
  749.  
  750. <tr> 
  751. <th scope="row"> 
  752. <label for="redirect"><?php _e('How do you want to import?', WYSIJA); ?> </label> 
  753. </th> 
  754. <td> 
  755. <p> 
  756. <label for="copy-paste"> 
  757. <input type="radio" class="validate[required]" id="copy-paste" value="copy" name="wysija[import][type]" ><?php _e('Copy paste in a text box', WYSIJA); ?> 
  758. </label> 
  759. <label for="upload-file"> 
  760. <input type="radio" class="validate[required]" id="upload-file" value="upload" name="wysija[import][type]"><?php _e('Upload a file', WYSIJA); ?> 
  761. </label> 
  762. <?php 
  763. $config = WYSIJA::get('config', "model"); 
  764. $importPossible = $config->getValue("pluginsImportableEgg"); 
  765. $importedalready = $config->getValue("pluginsImportedEgg"); 
  766. if (is_array($importPossible)) 
  767. foreach ($importPossible as $tableName => $pluginInfos) 
  768. if (is_array($importedalready) && in_array($tableName, $importedalready)) 
  769. continue; 
  770. ?> 
  771. <label for="import-from-plugin-<?php echo $tableName; ?>"> 
  772. <a class="button-secondary2" id="import-from-plugin-<?php echo $tableName; ?>" href="admin.php?page=wysija_subscribers&action=importplugins"> 
  773. <?php echo sprintf(__('Import from %1$s', WYSIJA), '<strong>"'.$pluginInfos['name'].'"</strong>'); ?> 
  774. </a> 
  775. </label> 
  776. <?php 
  777. ?> 
  778. </p> 
  779. </td> 
  780. </tr> 
  781.  
  782. <tr class="csvmode copy"> 
  783. <th scope="row" > 
  784. <label for="csvtext"><?php _e('Then paste your list here', WYSIJA); ?> </label> 
  785. <p class="description"><?php echo str_replace(array("[link]", "[/link]"), array('<a target="_blank" href="http://support.mailpoet.com/knowledgebase/importing-subscribers-with-a-csv-file/?utm_source=wpadmin&utm_campaign=import">', '</a>'), __('This needs to be in CSV style or a simple paste from Gmail, Hotmail or Yahoo. See [link]examples in our support site[/link].', WYSIJA)) ?></p> 
  786. </th> 
  787. <td> 
  788. <textarea type="text" style="width:500px;" cols="130" rows="10" class="validate[required]" id="csvtext" name="wysija[user_list][csv]" /></textarea> 
  789. <p class="fieldsmatch"></p> 
  790. </td> 
  791. </tr> 
  792.  
  793. <tr class="csvmode upload"> 
  794. <th scope="row" > 
  795. <label for="csvfile"><?php _e('Upload a file', WYSIJA); ?> </label> 
  796. <p class="description"><?php echo str_replace(array("[link]", "[/link]"), array('<a target="_blank" href="http://support.mailpoet.com/knowledgebase/importing-subscribers-with-a-csv-file/?utm_source=wpadmin&utm_campaign=import file">', '</a>'), __('This needs to be in CSV style. See [link]examples in our support site[/link].', WYSIJA)) ?></p> 
  797. </th> 
  798. <td> 
  799. <input type="file" name="importfile" size="50" />( <?php echo sprintf(__('total max upload file size : %1$s', WYSIJA), $bytes) ?> ) 
  800. <p class="fieldsmatch"></p> 
  801. </td> 
  802. </tr> 
  803.  
  804. <tr> 
  805. <th scope="row" colspan="2"> 
  806. <label for="redirect"><?php _e('Did these subscribers ask to be in your list?', WYSIJA); ?> </label> 
  807. <p class="description"> 
  808. <?php _e('If the answer is "no", consider yourself a spammer.', WYSIJA); ?><br /> 
  809. <?php echo str_replace(array("[link]", "[/link]"), array('<a target="_blank" href="http://support.mailpoet.com/knowledgebase/dont-import-subscribers-who-didnt-sign-up/#utm_source=wpadmin&utm_campaign=importwarning">', '</a>'), __('[link]Read more on support.mailpoet.com[/link].', WYSIJA)) ?> 
  810. </p> 
  811. </th> 
  812. </tr> 
  813. </tbody> 
  814. </table> 
  815.  
  816. <p class="submit"> 
  817. <input type="hidden" value="importmatch" name="action" /> 
  818. <?php $this->secure(array('action' => "importmatch")); ?> 
  819. <input type="submit" value="<?php echo esc_attr(__('Next step', WYSIJA)) ?>" class="button-primary wysija"> 
  820.  
  821. </p> 
  822. </form> 
  823. </div> 
  824.  
  825. <?php 
  826.  
  827. function importmatch($data) 
  828. ?> 
  829. <form class="form-valid" action="admin.php?page=wysija_subscribers&action=lists" id="wysija-edit" method="post" name="wysija-edit"> 
  830. <div class="list" style="overflow:auto"> 
  831. <table cellspacing="0" class="widefat fixed" > 
  832. <thead> 
  833. <tr class="thead"> 
  834. <th id="first-row"><?php _e('Match data', WYSIJA); ?></th> 
  835. <?php 
  836. $columns = array( 
  837. 'nomatch' => __('Ignore column...', WYSIJA),  
  838. 'email' => __('Email', WYSIJA),  
  839. 'firstname' => __('First name', WYSIJA),  
  840. 'lastname' => __('Last name', WYSIJA),  
  841. 'ip' => __('IP address', WYSIJA),  
  842. 'status' => __('Status', WYSIJA)); 
  843.  
  844. $WJ_Field = new WJ_Field(); 
  845. $custom_fields = $WJ_Field->get_all(); 
  846.  
  847. $extended_columns = array(); 
  848. if (!empty($custom_fields)) 
  849. foreach ($custom_fields as $row) 
  850. $extended_columns['cf_'.$row->id] = $row->name; 
  851.  
  852.  
  853. $helper_form = WYSIJA::get('forms', 'helper'); 
  854. $i = 0; 
  855.  
  856. $email_column_matched = false; 
  857. $this->new_column_can_be_imported = array(); 
  858.  
  859. $data['csv'][0] = array_map('trim', $data['csv'][0]); 
  860.  
  861. foreach ($data['csv'][0] as $column_key => $column_name) 
  862. $selected = ''; 
  863.  
  864. $columns_array = $columns; 
  865. // we make a key out of the column name 
  866. $column_name_key = str_replace(array(' ', '-', '_'), '', strtolower($column_name)); 
  867.  
  868. // we try to automatically match columns with previous matches recorded in the past 
  869. $import_fields = get_option('wysija_import_fields'); 
  870. if (isset($import_fields[$column_name_key]) && substr($import_fields[$column_name_key], 0, 10) != 'new_field|') 
  871. $selected = $import_fields[$column_name_key]; 
  872. else 
  873.  
  874. // we're making the matches dropdown with an extra value 'Import as "name of the column"' 
  875. // since we didn't detect it in the previously matched columns 
  876. $columns_array = array(); 
  877. foreach ($columns as $col_key => $col_val) 
  878. // we need to put that extra value right after the ignore column value 
  879. if (count($columns_array) === 1) { 
  880. $column_name = preg_replace('|[^a-z0-9#_.-]|i', '', $column_name); 
  881.  
  882. $columns_array['new_field|input|'.$column_name] = sprintf(__('Import as "%1$s"', WYSIJA), $column_name); 
  883. $columns_array['new_field|date|'.$column_name] = sprintf(__('Import "%1$s" as date field', WYSIJA), $column_name); 
  884. $this->new_column_can_be_imported[$column_key] = true; 
  885. else 
  886. $columns_array[$col_key] = $col_val; 
  887.  
  888. // if it is an email column we set it by default as email 
  889. if (!$email_column_matched && isset($data['keyemail'][$column_key])) 
  890. $selected = 'email'; 
  891. $email_column_matched = true; 
  892. $columns_array = $columns; 
  893. $columns_array = array_map('trim', array_merge($columns_array, $extended_columns)); 
  894.  
  895.  
  896. // we're building one dropdown per column 
  897. $dropdown = '<div class="match-dropdown">'.$helper_form->dropdown(array('id' => 'column-match-'.$i, 'name' => 'wysija[match]['.$i.']', 'class' => 'create_extra row-'.$column_key), $columns_array, $selected).'</div>'; 
  898. /** 
  899. * We need to improve the import, fields come back to options for columns later on. 
  900. if (isset($this->new_column_can_be_imported[$column_key])) { 
  901. $dropdown .= '<div class="import-new-field" id="column-match-date-wrap-'.$i.'"><input id="column-match-date-'.$i.'" type="checkbox" name="wysija[ignore_invalid_date]['.$i.']"\><label for="column-match-date-'.$i.'">' . __('Ignore invalid dates', WYSIJA) . '</label></div>'; 
  902. */ 
  903. echo '<th>'.$dropdown.'</th>'; 
  904. $i++; 
  905. ?> 
  906. </tr> 
  907. </thead> 
  908.  
  909. <tbody class="list:<?php echo $this->model->table_name.' '.$this->model->table_name.'-list" id="wysija-'.$this->model->table_name.'"' ?>> 
  910.  
  911. <?php 
  912. $listingRows = ''; 
  913. $alt = true; 
  914. $i = 0; 
  915. foreach ($data['csv'] as $columns) 
  916. $classRow = ''; 
  917. if ($alt) 
  918. $classRow = ' class="alternate" '; 
  919.  
  920. echo "<tr $classRow>"; 
  921. if (isset($data['firstrowisdata'])) 
  922. $j = $i + 1; 
  923. else 
  924. $j = $i; 
  925.  
  926. if ($i == 0) 
  927. $valuefrow = ''; 
  928.  
  929. if (isset($data['firstrowisdata'])) 
  930. $valuefrow = '1<input value="1" type="hidden" id="firstrowdata" name="firstrowisdata" />'; 
  931. echo '<td>'.$valuefrow.'</td>'; 
  932. //echo '<td><label for="firstrowdata" class="title" title="'.__("This line is not a header description, it is data and needs to be inserted!", WYSIJA).'"><input '.$checked.' type="checkbox" id="firstrowdata" name="firstrowisdata" />'.__("Insert line!", WYSIJA).'</label></td>'; 
  933. else 
  934. echo '<td>'.$j.'</td>'; 
  935.  
  936. foreach ($columns as $key_col => $val) 
  937. $val = esc_html($val); 
  938. if ($i == 0 && !isset($data['firstrowisdata'])) 
  939. echo '<td><strong>'.$val.'</strong></td>'; 
  940. else 
  941. if (!empty($this->new_column_can_be_imported[$key_col])) 
  942. $timestamp = strtotime($val); 
  943. if ($timestamp > 0) 
  944. $val_converted = '<span class="converted-field-to-date row-'.$key_col.'" title="'.__('Verify that the date in blue matches the original one.', WYSIJA).'">'.date(get_option('date_format').' '.get_option('time_format'), $timestamp).'</span>'; 
  945. else 
  946. $val_converted = '<span class="converted-field-error row-'.$key_col.'" title="'.__('Do not match as a \'date field\' if most of the rows for that column return the same error.', WYSIJA).'">'.__('Error matching date.', WYSIJA).'</span>'; 
  947. $val = ' <span class="imported-field">'.$val.'</span>'.$val_converted; 
  948. echo '<td>'.$val.'</td>'; 
  949. echo '</tr>'; 
  950.  
  951. $alt = !$alt; 
  952. $i++; 
  953.  
  954. if ($data['totalrows'] > 3) 
  955. ?> 
  956.  
  957. <tr class="alternate" > 
  958. <?php 
  959. echo '<td>...</td>'; 
  960. foreach ($data['csv'][0] as $col) 
  961. echo '<td>...</td>'; 
  962. ?> 
  963. </tr> 
  964. <tr><td><?php echo $data['totalrows'] ?></td> 
  965. <?php 
  966. foreach ($data['lastrow'] as $key_col => $val) 
  967. $val = esc_html($val); 
  968. if (!empty($this->new_column_can_be_imported[$key_col])) 
  969. $timestamp = strtotime($val); 
  970. if ($timestamp > 0) 
  971. $val_converted = '<span class="converted-field-to-date row-'.$key_col.'" title="'.__('Verify that the date in blue matches the original one.', WYSIJA).'">'.date(get_option('date_format').' '.get_option('time_format'), $timestamp).'</span>'; 
  972. else 
  973. $val_converted = '<span class="converted-field-error row-'.$key_col.'" title="'.__('Do not match as a \'date field\' if most of the rows for that column return the same error.', WYSIJA).'">'.__('Error matching date.', WYSIJA).'</span>'; 
  974. $val = ' <span class="imported-field">'.$val.'</span>'.$val_converted; 
  975. echo '<td>'.$val.'</td>'; 
  976. ?> 
  977. </tr> 
  978. <?php 
  979. ?> 
  980. </tbody> 
  981. </table> 
  982. </div> 
  983. <?php 
  984. if ($data['errormatch']) 
  985.  
  986. else 
  987. ?> 
  988. <table class="form-table"> 
  989. <tbody> 
  990. <tr> 
  991. <th scope="row"> 
  992. <label for="name"><?php _e('Pick one or many lists', WYSIJA); ?> </label> 
  993. <p class="description"><?php _e('Pick the lists you want to import those subscribers to.', WYSIJA); ?> </p> 
  994. </th> 
  995. <td> 
  996. <?php 
  997. //create an array of existing lists to import within 
  998. $model_list = WYSIJA::get('list', 'model'); 
  999. $lists = $model_list->get(array('name', 'list_id'), array('is_enabled' => 1)); 
  1000. //first value is to create new list 
  1001. $lists[] = array('name' => __('New list', WYSIJA), 'list_id' => 0); 
  1002.  
  1003. //create an array of active(status 99) follow_up emails aossicated to a list_id 
  1004. $helper_email = WYSIJA::get('email', 'helper'); 
  1005. $follow_ups_per_list = $helper_email->get_active_follow_ups(array('subject', 'params')); 
  1006.  
  1007. $follow_up_name_per_list = array(); 
  1008. foreach ($follow_ups_per_list as $list_id => $follow_ups) 
  1009. if (!isset($follow_up_name_per_list[$list_id])) 
  1010. $follow_up_name_per_list[$list_id] = array(); 
  1011. foreach ($follow_ups as $follow_up) 
  1012. $follow_up_name_per_list[$list_id][] = $follow_up['subject']; 
  1013.  
  1014. $helper_form = WYSIJA::get('forms', 'helper'); 
  1015. //field name for processing 
  1016. $field = 'list'; 
  1017. $fieldHTML = '<div>'; 
  1018. foreach ($lists as $list) 
  1019. if ($list['list_id'] == 0) 
  1020. $fieldHTML.= '<p><label for="'.$field.$list['list_id'].'">'; 
  1021. $fieldHTML.=$helper_form->checkbox(array('class' => 'validate[minCheckbox[1]] checkbox', 'id' => $field.$list['list_id'], 'name' => "wysija[user_list][$field][]"), $list['list_id']).'<span>'.$list['name'].'</span>'; 
  1022. $fieldHTML.='</label> '; 
  1023. $fieldHTML.='<span id="blocknewlist">'.$helper_form->input(array('class' => 'validate[required]', 'id' => 'namenewlist', 'size' => 30, 'name' => 'wysija[list][newlistname]', 'value' => __('Type name of your new list', WYSIJA))).'</span></p>'; 
  1024. else 
  1025. $fieldHTML.= '<p><label for="'.$field.$list['list_id'].'">'.$helper_form->checkbox(array('class' => 'validate[minCheckbox[1]] checkbox', 'id' => $field.$list['list_id'], 'name' => "wysija[user_list][$field][]"), $list['list_id']).$list['name']; 
  1026.  
  1027. if (isset($follow_up_name_per_list[$list['list_id']])) 
  1028. $fieldHTML.=' <span style="margin-left:10px;"><strong>'.__('Note:', WYSIJA).' </strong>'.sprintf(__('subscribers will receive "%1$s" after import.', WYSIJA), implode(', ', $follow_up_name_per_list[$list['list_id']])).'</span>'; 
  1029. $fieldHTML.='</label></p>'; 
  1030.  
  1031. $fieldHTML .= '</div>'; 
  1032. echo $fieldHTML; 
  1033. ?> 
  1034. </td> 
  1035. </tr> 
  1036. </tbody> 
  1037. </table> 
  1038. <p class="submit"> 
  1039. <?php $this->secure(array('action' => 'import_save')); ?> 
  1040. <input type="hidden" value="<?php echo esc_attr($data['dataImport']) ?>" name="wysija[dataImport]" /> 
  1041.  
  1042. <input type="hidden" value="import_save" name="action" /> 
  1043. <input type="submit" value="<?php echo esc_attr(__('Import', WYSIJA)) ?>" class="button-primary wysija"> 
  1044. </p> 
  1045. <?php 
  1046. ?> 
  1047. </form> 
  1048. <?php 
  1049.  
  1050. function import_save($data) 
  1051. return false; 
  1052.  
  1053. function importplugins($data) 
  1054. echo '<form class="form-valid" action="admin.php?page=wysija_subscribers&action=lists" id="wysija-edit" method="post" name="wysija-edit">'; 
  1055. echo '<ul>'; 
  1056. $config = WYSIJA::get('config', 'model'); 
  1057. $imported_already = $config->getValue('pluginsImportedEgg'); 
  1058. foreach ($data['plugins'] as $tablename => $pluginInfos) 
  1059. if (is_array($imported_already) && in_array($tablename, $imported_already)) 
  1060. continue; 
  1061. echo '<li><label for="import-'.$tablename.'1">'; 
  1062. echo sprintf(__('Import the %1$s subscribers from the plugin: %2$s ', WYSIJA), "<strong>".$pluginInfos['total']."</strong>", "<strong>".$pluginInfos['name']."</strong>").'</label>'; 
  1063. echo '<label for="import-'.$tablename.'1"><input checked="checked" type="radio" id="import-'.$tablename.'1" name="wysija[import]['.$tablename.']" value="1" />'.__('Yes', WYSIJA).'</label>'; 
  1064. echo '<label for="import-'.$tablename.'0"><input type="radio" id="import-'.$tablename.'0" name="wysija[import]['.$tablename.']" value="0" />'.__('No', WYSIJA).'</label>'; 
  1065. echo '</li>'; 
  1066. echo '</ul>'; 
  1067. ?> 
  1068. <p class="submit"> 
  1069. <?php $this->secure(array('action' => "importpluginsave")); ?> 
  1070. <input type="hidden" value="importpluginsave" name="action" /> 
  1071. <input type="submit" value="<?php echo esc_attr(__('Import', WYSIJA)) ?>" class="button-primary wysija"> 
  1072. </p> 
  1073. <?php 
  1074. echo '</form>';