WYSIJA_control_back_subscribers

The MailPoet Newsletters WYSIJA control back subscribers class.

Defined (2)

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

/controllers/ajax/subscribers.php  
  1. class WYSIJA_control_back_subscribers extends WYSIJA_control_front{ 
  2. var $model='user'; 
  3. var $view=''; 
  4.  
  5. function __construct() { 
  6. parent::__construct(); 
  7. $data=array(); 
  8. foreach($_REQUEST['data'] as $vals) { 
  9. $data[esc_sql($vals['name'])]=esc_sql($vals['value']); 
  10. if(isset($data['message_success'])) { 
  11. $this->messages['insert'][true]=$data['message_success']; 
  12. }else{ 
  13. $this->messages['insert'][true]=__('User has been inserted.', WYSIJA); 
  14.  
  15. $this->messages['insert'][false]=__('User has not been inserted.', WYSIJA); 
  16. $this->messages['update'][true]=__('User has been updated.', WYSIJA); 
  17. $this->messages['update'][false]=__('User has not been updated.', WYSIJA); 
  18.  
  19. function save() { 
  20. $datarequested=array(); 
  21. $i=0; 
  22. foreach($_REQUEST['data'] as $vals) { 
  23. if($vals['name']=='wysija[user_list][list_id][]') { 
  24. $datarequested[str_replace('wysija[user_list][list_id][]', 'wysija[user_list][list_id]['.$i.']', esc_sql($vals['name']))]=esc_sql($vals['value']); 
  25. $i++; 
  26. }else $datarequested[esc_sql($vals['name'])]=esc_sql($vals['value']); 
  27.  
  28. $data=$this->convertUserData($datarequested); 
  29.  
  30. $helperUser=WYSIJA::get('user', 'helper'); 
  31. if(!$helperUser->checkData($data))return false; 
  32. $helperUser->addSubscriber($data); 
  33.  
  34. return true; 
  35.  
  36. // REFACTOR: Insanely complicated and inefficient 
  37. function convertUserData($datarequested) { 
  38. $data=array(); 
  39.  
  40. //get the lists 
  41. if(isset($datarequested['wysija[user_list][list_ids]'])) { 
  42. $listids=explode(', ', $datarequested['wysija[user_list][list_ids]']); 
  43. $subdate=time(); 
  44. unset($datarequested['wysija[user_list][list_ids]']); 
  45. }else{ 
  46. $i=0; 
  47. $listids=array(); 
  48. for ($i = 0; $i <= 25; $i++) { 
  49. $testkey='wysija[user_list][list_id]['.$i.']'; 
  50. if(isset($datarequested[$testkey])) $listids[]=$datarequested[$testkey]; 
  51. unset($datarequested[$testkey]); 
  52. $data['user_list']['list_ids']=$listids; 
  53.  
  54. // define array for custom user fields 
  55. $data['user_field'] = array(); 
  56.  
  57. //get the user info and the rest of the data posted 
  58. foreach($datarequested as $key => $val) { 
  59. if(strpos($key, 'wysija[user]')!== false) { 
  60. $keymodified=str_replace(array('wysija[', '][', ']'), array('', '#', ''), $key); 
  61. $keystabcol=explode('#', $keymodified); 
  62. switch(count($keystabcol)) { 
  63. case 2: 
  64. $data[$keystabcol[0]][$keystabcol[1]]=$val; 
  65. break; 
  66. case 3: 
  67. $data[$keystabcol[0]][$keystabcol[1]][$keystabcol[2]]=$val; 
  68. break; 
  69. } else if(strpos($key, 'wysija[field]')!== false) { 
  70. $keymodified=str_replace(array('wysija[', '][', ']'), array('', '#', ''), $key); 
  71. $keystabcol=explode('#', $keymodified); 
  72.  
  73. switch(count($keystabcol)) { 
  74. case 2: 
  75. $data['user_field'][$keystabcol[1]] = $val; 
  76. break; 
  77. case 3: 
  78. $data['user_field'][$keystabcol[1]][$keystabcol[2]] = $val; 
  79. break; 
  80. } else { 
  81. if(!isset($data[$key])) $data[$key]=$val; 
  82.  
  83. return $data; 
  84.  
  85. function registerToLists($data, $uid) { 
  86. $model=WYSIJA::get('user_list', 'model'); 
  87. if(isset($data['wysija[user_list][list_ids]'])) { 
  88. $listids=explode(', ', $data['wysija[user_list][list_ids]']); 
  89.  
  90. $subdate=time(); 
  91.  
  92.  
  93. }else{ 
  94. $i=0; 
  95. $listids=array(); 
  96. for ($i = 0; $i <= 25; $i++) { 
  97. $testkey='wysija[user_list][list_id]['.$i.']'; 
  98. if(isset($data[$testkey])) $listids[]=$data[$testkey]; 
  99.  
  100. //$listids=$data['wysija[user_list][list_id]']; 
  101. foreach($listids as $listid) { 
  102. $model->replace(array('list_id'=>$listid, 'user_id'=>$uid, 'sub_date'=>$subdate)); 
  103. $model->reset(); 
  104.  
/controllers/back/subscribers.php  
  1. class WYSIJA_control_back_subscribers extends WYSIJA_control_back{ 
  2. var $model='user'; 
  3. var $view='subscribers'; 
  4. var $list_columns=array('user_id', 'firstname', 'lastname', 'email', 'created_at'); 
  5. var $searchable=array('email', 'firstname', 'lastname'); 
  6. var $_separators = array(', ', ';'); // csv separator; comma is for standard csv, semi-colon is good for Excel 
  7. var $_default_separator = ';'; 
  8.  
  9. /** 
  10. * Inactive users = users who never opened or clicked 
  11. * @todo: disabled on 2.6. Once it's enabled, please double check in term of "inactive users". 
  12. * OR - users who never opened or clicked 
  13. * OR - users who never opened or clicked AND received at least 1 newsletter. 
  14. * @var boolean 
  15. */ 
  16. var $_filter_by_inactive_users = true; 
  17.  
  18. function __construct() { 
  19. global $wpdb; 
  20. WYSIJA_control_back::__construct(); 
  21. if ($this->_filter_by_inactive_users) { 
  22. // load the inactive subscribers on the listing and when a any bulk action is executed 
  23. if ( empty($_REQUEST['action']) 
  24. || 
  25. ( !empty($_REQUEST['action']) 
  26. && 
  27. ( in_array($_REQUEST['action'], array('export_get', 'exportlist', 'deleteusers')) 
  28. || 
  29. substr($_REQUEST['action'], 0, 10)=='actionvar_') 
  30. ) { 
  31. $this->modelObj->prepare_inactive_users_table(); 
  32. $this->wpdb = $wpdb; 
  33.  
  34. /** 
  35. * common task to all the list actions 
  36. */ 
  37. private function _commonlists() { 
  38. $this->js[]='wysija-validator'; 
  39.  
  40. $this->data=array(); 
  41. $this->data['list']=$this->_getLists(10); 
  42.  
  43.  
  44. /** 
  45. * We are using the same form for different purposes: 
  46. * - Bulk actions 
  47. * - Filter by list 
  48. * We need to remove all un-necessary values from interface 
  49. */ 
  50. private function _cleanup_form() { 
  51. if (!empty($_REQUEST['doaction'])) { 
  52. $action_type = strtolower(trim($_REQUEST['doaction'])); 
  53. switch ($action_type) 
  54. // Filter by list 
  55. case 'filter': 
  56. if (!empty($_REQUEST['wysija']['user'])) 
  57. unset($_REQUEST['wysija']['user']); 
  58. if (!empty($_REQUEST['action'])) 
  59. unset($_REQUEST['action']); 
  60. break; 
  61. // Bulk action. Nothing to do, because we will invoke _tryAction() directly right after this step 
  62. case 'apply': 
  63. default: 
  64. break; 
  65.  
  66. private function _getLists($limit=false) { 
  67.  
  68. $model_list = WYSIJA::get('list', 'model'); 
  69. $model_list->escapingOn=true; 
  70. $model_list->_limitison=$limit; 
  71. return $model_list->getLists(); 
  72.  
  73. private function _getForm($id=false) { 
  74. if($id) { 
  75. $model_list = WYSIJA::get('list', 'model'); 
  76.  
  77. return $model_list->get_one_list($id); 
  78. }else{ 
  79. $array=array('name'=>'', 'list_id'=>'', 'description'=>'', 'is_public'=>true, 'is_enabled'=>true); 
  80. return $array; 
  81.  
  82.  
  83. /** 
  84. * Get selected lists 
  85. * @return array 
  86. */ 
  87. private function _get_selected_lists() { 
  88. $result = array(); 
  89. if (isset($_REQUEST['wysija']['filter']['filter_list'])) { 
  90. $result[] = $_REQUEST['wysija']['filter']['filter_list']; 
  91. } elseif (!empty($_REQUEST['filter-list'])) { 
  92. $lists = explode(', ', trim($_REQUEST['filter-list']));// currently, only single list is allowed. 
  93. if (!empty($lists)) { 
  94. $result = array_merge ($result, $lists); 
  95. return $result; 
  96.  
  97. function save() { 
  98. $this->redirectAfterSave=false; 
  99. $this->requireSecurity(); 
  100. $helper_user = WYSIJA::get('user', 'helper'); 
  101. if( isset( $_REQUEST['id'] ) ) { 
  102. $id = $_REQUEST['id']; 
  103. parent::save(); 
  104.  
  105. //run the unsubscribe process if needed 
  106. if((int)$_REQUEST['wysija']['user']['status']==-1) { 
  107. $helper_user->unsubscribe($id); 
  108.  
  109. /** update subscriptions */ 
  110. $model_user_list = WYSIJA::get('user_list', 'model'); 
  111. $model_user_list->backSave=true; 
  112. /** list of core list */ 
  113. $model_list = WYSIJA::get('list', 'model'); 
  114. $results = $model_list->get(array('list_id'), array('is_enabled'=>'0')); 
  115. $core_listids = array(); 
  116. foreach($results as $res) { 
  117. $core_listids[]=$res['list_id']; 
  118.  
  119. //0 - get current lists of the user 
  120. $userlists = $model_user_list->get(array('list_id', 'unsub_date'), array('user_id'=>$id)); 
  121.  
  122. $oldlistids=$newlistids=array(); 
  123. foreach($userlists as $listdata) $oldlistids[$listdata['list_id']]=$listdata['unsub_date']; 
  124.  
  125. $model_config = WYSIJA::get('config', 'model'); 
  126. $dbloptin = $model_config->getValue('confirm_dbleoptin'); 
  127. //1 - insert new user_list 
  128. if(isset($_POST['wysija']['user_list']) && $_POST['wysija']['user_list']) { 
  129. $model_user_list->reset(); 
  130. $model_user_list->update(array('sub_date'=>time()), array('user_id'=>$id)); 
  131. if(!empty($_POST['wysija']['user_list']['list_id'])) { 
  132. foreach($_POST['wysija']['user_list']['list_id'] as $list_id) { 
  133. //if the list is not already recorded for the user then we will need to insert it 
  134. if(!isset($oldlistids[$list_id])) { 
  135. $model_user_list->reset(); 
  136. $newlistids[]=$list_id; 
  137. $dataul=array('user_id'=>$id, 'list_id'=>$list_id, 'sub_date'=>time()); 
  138. //if double optin is on and user is unconfirmed or unsubscribed, then we need to set it as unconfirmed subscription 
  139. if($dbloptin && (int)$_POST['wysija']['user']['status']<1) unset($dataul['sub_date']); 
  140. $model_user_list->insert($dataul); 
  141. //if the list is recorded already then let's check the status, if it is an unsubed one then we update it 
  142. }else{ 
  143. if($oldlistids[$list_id]>0) { 
  144. $model_user_list->reset(); 
  145. $model_user_list->update(array('unsub_date'=>0, 'sub_date'=>time()), array('user_id'=>$id, 'list_id'=>$list_id)); 
  146.  
  147. }else{ 
  148. // if no list is selected we unsubscribe them all 
  149. $model_user_list->reset(); 
  150. $model_user_list->update(array('unsub_date'=>time(), 'sub_date'=>0), array('user_id'=>$id)); 
  151.  
  152. //if a confirmation email needs to be sent then we send it 
  153. if($dbloptin && (int)$_POST['wysija']['user']['status']==0 && !empty($newlistids)) { 
  154. $helper_user = WYSIJA::get('user', 'helper'); 
  155. $helper_user->sendConfirmationEmail($id, true, $newlistids); 
  156.  
  157. if((int)$_POST['wysija']['user']['status']==0 || (int)$_POST['wysija']['user']['status']==1) { 
  158. $model_user_list->reset(); 
  159. $model_user_list->update(array('unsub_date'=>0, 'sub_date'=>time()), array('user_id'=>$id, 'list_id'=>$core_listids)); 
  160.  
  161. $arrayLists=array(); 
  162. if(isset($_POST['wysija']['user_list']['list_id'])) $arrayLists=$_POST['wysija']['user_list']['list_id']; 
  163. $notEqual=array_merge($core_listids, $arrayLists); 
  164.  
  165. //unsubscribe from lists which exist in the old list but does not exist in the new list 
  166. $unsubsribe_list = array_diff(array_keys($oldlistids), $arrayLists); 
  167. if(!empty($unsubsribe_list)) 
  168. $model_user_list->reset(); 
  169. $model_user_list->update(array('unsub_date'=>time()), array('user_id'=>$id, 'list_id'=>$unsubsribe_list)); 
  170. $model_user_list->reset(); 
  171.  
  172. /** 
  173. Custom Fields. 
  174. */ 
  175. if (isset($_POST['wysija']['field'])) { 
  176. WJ_FieldHandler::handle_all( 
  177. $_POST['wysija']['field'], $id 
  178. ); 
  179.  
  180.  
  181. }else{ 
  182. //instead of going through a classic save we should save through the helper 
  183. $data=$_REQUEST['wysija']; 
  184. $data['user_list']['list_ids'] = !empty($data['user_list']['list_id']) ? $data['user_list']['list_id'] : array(); 
  185. unset($data['user_list']['list_id']); 
  186. $data['message_success']=__('Subscriber has been saved.', WYSIJA); 
  187. $id=$helper_user->addSubscriber($data, true); 
  188. if(!$id) { 
  189. $this->viewShow=$this->action='add'; 
  190. $data=array('details'=>$_REQUEST['wysija']['user']); 
  191. return $this->add($data); 
  192. } else { 
  193. if(isset($_POST['wysija']['field'])) { 
  194. WJ_FieldHandler::handle_all($_POST['wysija']['field'], $id); 
  195. $this->redirect(); 
  196. return true; 
  197.  
  198.  
  199. function defaultDisplay() { 
  200. $this->viewShow=$this->action='main'; 
  201. $this->js[]='wysija-admin-list'; 
  202. $this->viewObj->msgPerPage = __('Subscribers per page:', WYSIJA); 
  203.  
  204. $this->jsTrans['selecmiss'] = __('Select at least 1 subscriber!', WYSIJA); 
  205.  
  206. // get the total count for subscribed, unsubscribed and unconfirmed users 
  207. $select = array( 'COUNT(`user_id`) AS users' , 'status' , 'MAX(`created_at`) AS `max_create_at`'); 
  208. $count_group_by = 'status'; 
  209. $count_by_status = $this->modelObj->get_subscribers( $select , array() , $count_group_by ); 
  210. if ($this->_filter_by_inactive_users) { 
  211. $inactive_users = $this->modelObj->count_inactive_users(); 
  212. if ($inactive_users) { 
  213. array_unshift($count_by_status, array( 
  214. 'users' => $inactive_users['count'],  
  215. 'status' => -99, //-99 = inactive 
  216. 'max_create_at' => $inactive_users['max_created_at'] 
  217. )); 
  218.  
  219.  
  220. $counts = $this->modelObj->structure_user_status_count_array($count_by_status); 
  221. $arr_max_create_at = $this->modelObj->get_max_create($count_by_status); 
  222.  
  223. // count the rows based on the filters 
  224. $filters = $this->modelObj->detect_filters(); 
  225.  
  226. $select = array( 'COUNT(DISTINCT([wysija]user.user_id)) as total_users', 'MAX([wysija]user.created_at) as max_create_at'); 
  227. $count_rows = $this->modelObj->get_subscribers( $select, $filters); 
  228.  
  229. // without filter we already have the total number of subscribers 
  230. $this->data['max_create_at'] = null; //max value of create_at field of current list of users 
  231. if(!empty($filters)) { 
  232. // used for pagination 
  233. $this->modelObj->countRows = $count_rows['total_users']; 
  234. // used for 
  235. $this->data['max_create_at'] = $count_rows['max_create_at']; 
  236. }else{ 
  237. $this->data['max_create_at'] = !empty($arr_max_create_at) ? max($arr_max_create_at) : 0; 
  238. $this->modelObj->countRows=$counts['all']; 
  239.  
  240. $select = array( 
  241. '[wysija]user.firstname',  
  242. '[wysija]user.lastname',  
  243. '[wysija]user.status',  
  244. '[wysija]user.email',  
  245. '[wysija]user.created_at',  
  246. '[wysija]user.last_opened',  
  247. '[wysija]user.last_clicked',  
  248. '[wysija]user_list.user_id' 
  249. ); 
  250.  
  251. $this->data['subscribers'] = $this->modelObj->get_subscribers($select , $filters, '', false, true); 
  252.  
  253. $this->data['current_counts'] = $this->modelObj->countRows; 
  254. $this->data['show_batch_select'] = ($this->modelObj->limit >= $this->modelObj->countRows) ? false : true; 
  255. $this->data['selected_lists'] = $this->_get_selected_lists(); 
  256. $this->modelObj->reset(); 
  257.  
  258.  
  259. // make the data object for the listing view 
  260. $model_list = WYSIJA::get('list', 'model'); 
  261. $lists_db = $model_list->getLists(); 
  262.  
  263. $lists=array(); 
  264.  
  265. foreach($lists_db as $listobj) { 
  266. $lists[$listobj['list_id']]=$listobj; 
  267.  
  268. $user_ids=array(); 
  269. foreach($this->data['subscribers'] as $subscriber) { 
  270. $user_ids[]=$subscriber['user_id']; 
  271.  
  272. // 3 - user_list request 
  273. if($user_ids) { 
  274. $model_user_list = WYSIJA::get('user_list', 'model'); 
  275. $userlists=$model_user_list->get(array('list_id', 'user_id', 'unsub_date'), array('user_id'=>$user_ids)); 
  276.  
  277. $this->data['lists']=$lists; 
  278. $this->data['counts']=array_reverse($counts); 
  279.  
  280. // regrouping all the data in the same array 
  281. foreach($this->data['subscribers'] as $keysus=>$subscriber) { 
  282. // default key while we don't have the data 
  283. //TODO add data for stats about emails opened clicked etc 
  284. $this->data['subscribers'][$keysus]['emails']=0; 
  285. $this->data['subscribers'][$keysus]['opened']=0; 
  286. $this->data['subscribers'][$keysus]['clicked']=0; 
  287.  
  288. if($userlists) { 
  289. foreach($userlists as $key=>$userlist) { 
  290. if($subscriber['user_id']==$userlist['user_id'] && isset($lists[$userlist['list_id']])) { 
  291. //what kind of list ist it ? unsubscribed ? or not 
  292.  
  293. if($userlist['unsub_date']>0) { 
  294. if(!isset($this->data['subscribers'][$keysus]['unsub_lists']) ) { 
  295. $this->data['subscribers'][$keysus]['unsub_lists']=$this->data['lists'][$userlist['list_id']]['name']; 
  296. }else{ 
  297. $this->data['subscribers'][$keysus]['unsub_lists'].=', '.$this->data['lists'][$userlist['list_id']]['name']; 
  298. }else{ 
  299. if(!isset($this->data['subscribers'][$keysus]['lists']) ) { 
  300. $this->data['subscribers'][$keysus]['lists']=$this->data['lists'][$userlist['list_id']]['name']; 
  301. }else{ 
  302. $this->data['subscribers'][$keysus]['lists'].=', '.$this->data['lists'][$userlist['list_id']]['name']; 
  303. if(!$this->data['subscribers']) { 
  304. $this->notice(__('Yikes! Couldn\'t find any subscribers.', WYSIJA)); 
  305.  
  306.  
  307. function main() { 
  308. $this->messages['insert'][true]=__('Subscriber has been saved.', WYSIJA); 
  309. $this->messages['insert'][false]=__('Subscriber has not been saved.', WYSIJA); 
  310. $this->messages['update'][true]=__('Subscriber has been modified. [link]Edit again[/link].', WYSIJA); 
  311. $this->messages['update'][false]=__('Subscriber has not been modified.', WYSIJA); 
  312. $this->_cleanup_form(); 
  313. parent::__construct(); 
  314.  
  315. //we change the default model of the controller based on the action 
  316. if(isset($_REQUEST['action'])) { 
  317. switch($_REQUEST['action']) { 
  318. case 'listsedit': 
  319. case 'savelist': 
  320. case 'lists': 
  321. $this->model='list'; 
  322. break; 
  323. default: 
  324. $this->model='user'; 
  325.  
  326. WYSIJA_control::__construct(); 
  327. if(!isset($_REQUEST['action']) || !$_REQUEST['action']) { 
  328. $this->defaultDisplay(); 
  329. $this->checkTotalSubscribers(); 
  330. } else { 
  331. $this->_tryAction($_REQUEST['action']); 
  332.  
  333.  
  334. /** 
  335. * bulk action copy to list 
  336. * @global type $wpdb 
  337. * @param type $data 
  338. */ 
  339. function copytolist($data) { 
  340. $this->requireSecurity(); 
  341. $helper_user = WYSIJA::get('user', 'helper'); 
  342. if(empty($this->_batch_select)) 
  343. $helper_user ->addToList($data['listid'], $_POST['wysija']['user']['user_id']); 
  344. else 
  345. $helper_user ->addToList($data['listid'], $this->_batch_select, true); 
  346.  
  347. $model_list = WYSIJA::get('list', 'model'); 
  348. $result = $model_list->getOne(array('name'), array('list_id'=>$data['listid'])); 
  349.  
  350. if($this->_affected_rows > 1) 
  351. $this->notice(sprintf(__('%1$s subscribers have been added to "%2$s".', WYSIJA), $this->_affected_rows, $result['name'])); 
  352. else 
  353. $this->notice(sprintf(__('%1$s subscriber have been added to "%2$s".', WYSIJA), $this->_affected_rows, $result['name'])); 
  354. $this->redirect_after_bulk_action(); 
  355.  
  356. /** 
  357. * Moves subscriber to another list. 
  358. * @param array $data List id to move, $data = array('listid' => 1); 
  359. */ 
  360. function movetolist($data) { 
  361. $this->requireSecurity(); 
  362. $helper_user = WYSIJA::get('user', 'helper'); 
  363.  
  364. if (!empty($this->_batch_select)) { 
  365. $helper_user->moveToList($data['listid'], $this->_batch_select, true); 
  366. } elseif (isset($_POST['wysija']['user']['user_id'])) { 
  367. $helper_user->moveToList($data['listid'], $_POST['wysija']['user']['user_id']); 
  368.  
  369. $model_list = WYSIJA::get('list', 'model'); 
  370. $result = $model_list->getOne(array('name'), array('list_id' => $data['listid'])); 
  371.  
  372. if ($this->_affected_rows > 1) { 
  373. $this->notice(sprintf(__('%1$s subscribers have been moved to "%2$s".', WYSIJA), $this->_affected_rows, $result['name'])); 
  374. } else { 
  375. $this->notice(sprintf(__('%1$s subscriber have been moved to "%2$s".', WYSIJA), $this->_affected_rows, $result['name'])); 
  376.  
  377. $this->redirect_after_bulk_action(); 
  378.  
  379. /** 
  380. * After performing a bulk action, let's keep the current list filter 
  381. */ 
  382. protected function redirect_after_bulk_action() { 
  383. $filter_list = !empty($_REQUEST['wysija']['filter']['filter_list']) ? $_REQUEST['wysija']['filter']['filter_list'] : 0; 
  384. if (empty($filter_list)) {// view all lists 
  385. $this->redirect('admin.php?page=wysija_subscribers'); 
  386. } elseif (is_numeric($filter_list)) { 
  387. $this->redirect('admin.php?page=wysija_subscribers&filter-list='.$filter_list); 
  388. } else {// subscribers in no list 
  389. $this->redirect('admin.php?page=wysija_subscribers&filter-list=orphaned'); 
  390.  
  391. /** 
  392. * Bulk action remove subscribers from all existing lists 
  393. * @param type $data = array('list_id'=>?) 
  394. */ 
  395. function removefromalllists($data) { 
  396. $this->requireSecurity(); 
  397. $helper_user = WYSIJA::get('user', 'helper'); 
  398. if(!empty($this->_batch_select)) 
  399. $helper_user->removeFromLists(array(), $this->_batch_select, true); 
  400. else 
  401. $helper_user->removeFromLists(array(), $_POST['wysija']['user']['user_id']); 
  402.  
  403. if($this->_affected_rows > 1) 
  404. $this->notice(sprintf(__('%1$s subscribers have been removed from all existing lists.', WYSIJA), $this->_affected_rows)); 
  405. else 
  406. $this->notice(sprintf(__('%1$s subscriber have been removed from all existing lists.', WYSIJA), $this->_affected_rows)); 
  407. $this->redirect_after_bulk_action(); 
  408.  
  409. /** 
  410. * Bulk action remove subscribers from all existing lists 
  411. * @param type $data = array('list_id'=>?) 
  412. */ 
  413. function removefromlist($data = array()) { 
  414. $this->requireSecurity(); 
  415. $helper_user = WYSIJA::get('user', 'helper'); 
  416. if(!empty($this->_batch_select)) { 
  417. $helper_user->removeFromLists(array($data['listid']), $this->_batch_select, true); 
  418. }else{ 
  419. $helper_user->removeFromLists(array($data['listid']), $_POST['wysija']['user']['user_id']); 
  420.  
  421. $model_list = WYSIJA::get('list', 'model'); 
  422. $result = $model_list->getOne(array('name'), array('list_id'=>$data['listid'])); 
  423.  
  424. if($this->_affected_rows > 1) { 
  425. $this->notice(sprintf(__('%1$s subscribers have been removed from "%2$s".', WYSIJA), $this->_affected_rows, $result['name'])); 
  426. }else{ 
  427. $this->notice(sprintf(__('%1$s subscriber have been removed from "%2$s".', WYSIJA), $this->_affected_rows, $result['name'])); 
  428.  
  429. $this->redirect_after_bulk_action(); 
  430.  
  431. /** 
  432. * Bulk confirm users 
  433. */ 
  434. function confirmusers() { 
  435. $this->requireSecurity(); 
  436. $helper_user = WYSIJA::get('user', 'helper'); 
  437. if(!empty($this->_batch_select)) { 
  438. $helper_user->confirmUsers($this->_batch_select, true); 
  439. }else{ 
  440. $helper_user->confirmUsers($_POST['wysija']['user']['user_id']); 
  441.  
  442. if($this->_affected_rows > 1) { 
  443. $this->notice(sprintf(__('%1$s subscribers have been confirmed.', WYSIJA), $this->_affected_rows)); 
  444. }else{ 
  445. $this->notice(sprintf(__('%1$s subscriber have been confirmed.', WYSIJA), $this->_affected_rows)); 
  446.  
  447. $this->redirect_after_bulk_action(); 
  448.  
  449. /** 
  450. * Bulk resend confirmation emails 
  451. * Maximum emails to be sent is 100, and only send to unconfirmed subscribers, of coruse. 
  452. */ 
  453. function resendconfirmationemail() { 
  454. $this->requireSecurity(); 
  455. $helper_user = WYSIJA::get('user', 'helper'); 
  456. $user_ids = array(); 
  457. if(!empty($this->_batch_select)) { 
  458. $model_user = WYSIJA::get('user', 'model'); 
  459. $users = $model_user->get_results($this->_batch_select['query'] . ' LIMIT 0, 100'); 
  460. if (!empty($users)) { 
  461. foreach ($users as $user) { 
  462. $user_ids[] = $user['user_id']; 
  463. } else { 
  464. $user_ids = array_filter($_POST['wysija']['user']['user_id'], 'ctype_digit'); 
  465.  
  466. $sending_statuses = array();// array(user_id => 1/0) 
  467. if (!empty($user_ids)) { 
  468. $model_user_list = WYSIJA::get('user_list', 'model'); 
  469. $user_lists = $model_user_list->get_lists($user_ids); 
  470. if (!empty($user_lists)) { 
  471. foreach ($user_lists as $user_id => $lists) { 
  472. $sending_statuses[$user_id] = $helper_user->sendConfirmationEmail($user_id, true, $lists); 
  473.  
  474. $success_sending_number = count(array_values($sending_statuses)); 
  475. if ($success_sending_number <= 0) { 
  476. $this->notice(__('No email sent.', WYSIJA)); 
  477. } else { 
  478. $this->notice( sprintf(_n( 'One email has been sent.', '%d emails have been sent to unconfirmed subscribers.', (int)$success_sending_number, WYSIJA ), $success_sending_number ) ); 
  479.  
  480. $this->redirect_after_bulk_action(); 
  481.  
  482. function lists() { 
  483. $this->js[]='wysija-admin-list'; 
  484. $this->_commonlists(); 
  485.  
  486. $this->modelObj=WYSIJA::get('list', 'model'); 
  487. $this->viewObj->title=__('Edit lists', WYSIJA); 
  488. $this->modelObj->countRows=$this->modelObj->count(); 
  489.  
  490. $this->viewObj->model=$this->modelObj; 
  491. $this->data['form']=$this->_getForm(); 
  492.  
  493. function editlist() { 
  494. $this->_commonlists(); 
  495. $this->data['form']=$this->_getForm($_REQUEST['id']); 
  496.  
  497. $this->viewObj->title=sprintf(__('Editing list %1$s', WYSIJA), '<b><i>'.$this->data['form']['name'].'</i></b>'); 
  498.  
  499. function addlist() { 
  500. $this->_commonlists(); 
  501. $this->viewObj->title=__('How about a new list?', WYSIJA); 
  502. $this->data['form']=$this->_getForm(); 
  503.  
  504. function duplicatelist() { 
  505. $this->requireSecurity(); 
  506. /** get the list's email id 
  507. * 0 duplicate the list's welcome email 
  508. * 1 duplicate the list 
  509. * 2 duplicate the list's subscribers 
  510. */ 
  511.  
  512. $model_list = WYSIJA::get('list', 'model'); 
  513. $data=$model_list->getOne(array('name', 'namekey', 'welcome_mail_id', 'unsub_mail_id'), array('list_id'=>(int)$_REQUEST['id'])); 
  514.  
  515. $query='INSERT INTO `[wysija]list` (`created_at`, `name`, `namekey`, `description`, `welcome_mail_id`, `unsub_mail_id`, `is_enabled`, `ordering`) 
  516. SELECT '.time().', concat("' . $this->wpdb->_real_escape( __( 'Copy of ', WYSIJA ) ) . '", `name`) , "copy_'.$data['namekey'].time().'" , `description`, 0, 0 , 1, `ordering` FROM [wysija]list 
  517. WHERE list_id='.(int)$_REQUEST['id']; 
  518.  
  519. $list_id = $model_list->query($query); 
  520.  
  521. $query='INSERT INTO `[wysija]user_list` (`list_id`, `user_id`, `sub_date`, `unsub_date`) 
  522. SELECT '.$list_id .', `user_id`, `sub_date`, `unsub_date` FROM [wysija]user_list 
  523. WHERE list_id='.(int)$_REQUEST['id']; 
  524.  
  525. $model_list->query($query); 
  526.  
  527. $this->notice(sprintf(__('List "%1$s" has been duplicated.', WYSIJA), $data['name'])); 
  528. $this->redirect('admin.php?page=wysija_subscribers&action=lists'); 
  529.  
  530.  
  531. function add($data=false) { 
  532. $this->js[]='wysija-validator'; 
  533. $this->viewObj->add=true; 
  534.  
  535. $this->title=$this->viewObj->title=__('Add Subscriber', WYSIJA); 
  536.  
  537. $this->data=array(); 
  538. $this->data['user']=false; 
  539. if($data)$this->data['user']=$data; 
  540. $model_list = WYSIJA::get('list', 'model'); 
  541. $model_list->limitON=false; 
  542. $this->data['list'] = $model_list->get(false, array('greater'=>array('is_enabled'=>'0') )); 
  543.  
  544.  
  545. function back() { 
  546. $this->redirect(); 
  547.  
  548. function backtolist() { 
  549. $this->redirect('admin.php?page=wysija_subscribers&action=lists'); 
  550.  
  551. function edit($id=false) { 
  552.  
  553. if (empty($_REQUEST['id']) && empty($id)) { 
  554. $this->error('Cannot edit element primary key is missing : '. get_class($this)); 
  555. return; 
  556.  
  557. if(!$id) $id=$_REQUEST['id']; 
  558.  
  559. // get detail info of current user 
  560. $this->data['user']=$this->modelObj->getDetails(array('user_id'=>$id)); 
  561. if(!$this->data['user']) { 
  562. $this->notice(__('No subscriber found, most probably because he was deleted.', WYSIJA)); 
  563. return $this->redirect(); 
  564.  
  565. // get list info 
  566. $model_list=WYSIJA::get('list', 'model'); 
  567. $model_list->limitON=false; 
  568. $model_list->orderBy('is_enabled', 'DESC'); 
  569. $this->data['list']=$model_list->get(false, array('greater'=>array('is_enabled'=>'-1') )); 
  570. $this->viewObj->title=__('Edit', WYSIJA).' '.$this->data['user']['details']['email']; 
  571.  
  572. // execute hooks 
  573. $hook_params = array( 
  574. 'user_id' => $id 
  575. ); 
  576. $this->data['hooks']['hook_subscriber_left'] = apply_filters('hook_subscriber_left', WYSIJA_module::execute_hook('hook_subscriber_left', $hook_params), $hook_params); 
  577. $this->data['hooks']['hook_subscriber_right'] = apply_filters('hook_subscriber_right', WYSIJA_module::execute_hook('hook_subscriber_right', $hook_params), $hook_params); 
  578. $this->data['hooks']['hook_subscriber_bottom'] = apply_filters('hook_subscriber_bottom', WYSIJA_module::execute_hook('hook_subscriber_bottom', $hook_params), $hook_params); 
  579.  
  580.  
  581. // prepare js, for rendering 
  582. $this->js[]='wysija-validator'; 
  583.  
  584. function deletelist() { 
  585. $this->requireSecurity(); 
  586.  
  587. /** get the list's email id 
  588. * 0 delete the welcome email corresponding to that list 
  589. * 1 delete the list subscribers reference 
  590. * 2 delete the list campaigns references 
  591. * 4 delete the list 
  592. */ 
  593. $model_list=WYSIJA::get('list', 'model'); 
  594. $data=$model_list->getOne(array('name', 'namekey', 'welcome_mail_id'), array('list_id'=>(int)$_REQUEST['id'])); 
  595.  
  596. if($data && isset($data['namekey']) && ($data['namekey']!='users')) { 
  597.  
  598. //there is no welcome email per list that's old stuff 
  599. $model_user_list=WYSIJA::get('user_list', 'model'); 
  600. $model_user_list->delete(array('list_id'=>$_REQUEST['id'])); 
  601.  
  602. $model_campaign_list=WYSIJA::get('campaign_list', 'model'); 
  603. $model_campaign_list->delete(array('list_id'=>$_REQUEST['id'])); 
  604.  
  605. $model_list->reset(); 
  606. $model_list->delete(array('list_id'=>$_REQUEST['id'])); 
  607.  
  608. $this->notice(sprintf(__('List "%1$s" has been deleted.', WYSIJA), $data['name'])); 
  609. }else{ 
  610. $this->error(__('The list does not exists or cannot be deleted.', WYSIJA), true); 
  611.  
  612. $this->redirect('admin.php?page=wysija_subscribers&action=lists'); 
  613.  
  614.  
  615.  
  616. function synchlist() { 
  617. $this->requireSecurity(); 
  618.  
  619. $helper_user=WYSIJA::get('user', 'helper'); 
  620. $helper_user->synchList($_REQUEST['id']); 
  621.  
  622. $this->redirect('admin.php?page=wysija_subscribers&action=lists'); 
  623.  
  624. function synchlisttotal() { 
  625. $this->requireSecurity(); 
  626.  
  627. global $current_user; 
  628.  
  629. if(is_multisite() && is_super_admin( $current_user->ID )) { 
  630. $helper_user=WYSIJA::get('user', 'helper'); 
  631. $helper_user->synchList($_REQUEST['id'], true); 
  632.  
  633. $this->redirect('admin.php?page=wysija_subscribers&action=lists'); 
  634.  
  635.  
  636. function savelist() { 
  637. $this->requireSecurity(); 
  638. $this->_resetGlobMsg(); 
  639. $update=false; 
  640.  
  641. if($_REQUEST['wysija']['list']['list_id']) { 
  642. $update=true; 
  643. /** save the result */ 
  644. /** 1-save the welcome email*/ 
  645. /** 2-save the list*/ 
  646. if(isset($_REQUEST['wysija']['list']['is_public'])) { 
  647. if($_REQUEST['wysija']['list']['is_public']=='on') { 
  648. $_REQUEST['wysija']['list']['is_public']=1; 
  649. }else{ 
  650. $_REQUEST['wysija']['list']['is_public']=0; 
  651.  
  652. if($update) { 
  653. $this->modelObj->update($_REQUEST['wysija']['list']); 
  654. $this->notice(__('List has been updated.', WYSIJA)); 
  655. }else{ 
  656. $_REQUEST['wysija']['list']['created_at']=time(); 
  657. $_REQUEST['wysija']['list']['is_enabled']=1; 
  658.  
  659. $this->modelObj->insert($_REQUEST['wysija']['list']); 
  660. $this->notice(__('Your brand-new list awaits its first subscriber.', WYSIJA)); 
  661.  
  662.  
  663. $this->redirect('admin.php?page=wysija_subscribers&action=lists'); 
  664.  
  665.  
  666.  
  667. function importpluginsave($id=false) { 
  668. $this->requireSecurity(); 
  669. $this->_resetGlobMsg(); 
  670. $model_config = WYSIJA::get('config', 'model'); 
  671. $helper_import = WYSIJA::get('plugins_import', 'helper'); 
  672. $plugins_importable=$model_config->getValue('pluginsImportableEgg'); 
  673. $plugins_imported=array(); 
  674. foreach($_REQUEST['wysija']['import'] as $table_name =>$result) { 
  675. $connection_info=$helper_import->getPluginsInfo($table_name); 
  676.  
  677. if($result) { 
  678. $plugins_imported[]=$table_name; 
  679. if(!$connection_info) $connection_info=$plugins_importable[$table_name]; 
  680. $helper_import->import($table_name, $connection_info); 
  681. sleep(2); 
  682. $this->notice(sprintf(__('Import from plugin %1$s has been completed.', WYSIJA), "<strong>'".$connection_info['name']."'</strong>")); 
  683. }else{ 
  684. $this->notice(sprintf(__('Import from plugin %1$s has been cancelled.', WYSIJA), "<strong>'".$connection_info['name']."'</strong>")); 
  685.  
  686.  
  687. $model_config->save(array('pluginsImportedEgg'=>$plugins_imported)); 
  688.  
  689. $this->redirect('admin.php?page=wysija_subscribers&action=lists'); 
  690.  
  691. function importplugins($id=false) { 
  692. $this->js[]='wysija-validator'; 
  693.  
  694. $this->viewObj->title=__('Import subscribers from plugins', WYSIJA); 
  695.  
  696. $model_config=WYSIJA::get('config', 'model'); 
  697.  
  698. $this->data=array(); 
  699. $this->data['plugins']=$model_config->getValue('pluginsImportableEgg'); 
  700. $imported_plugins=$model_config->getValue('pluginsImportedEgg'); 
  701.  
  702. if($imported_plugins) { 
  703. foreach($imported_plugins as $tablename) { 
  704. unset( $this->data['plugins'][$tablename]); 
  705.  
  706.  
  707. if(!$this->data['plugins']) { 
  708. $this->notice(__('There is no plugin to import from.', WYSIJA)); 
  709. return $this->redirect(); 
  710. $this->viewShow='importplugins'; 
  711.  
  712.  
  713. function import($id=false) { 
  714. $this->js[]='wysija-validator'; 
  715. $this->viewObj->title=__('Import Subscribers', WYSIJA); 
  716. $this->viewShow='import'; 
  717.  
  718. function importmatch() { 
  719. $this->requireSecurity(); 
  720. $this->jsTrans['subscribers_import_match_confirmation_1'] = __('The selected value is already matched to another column.', WYSIJA); 
  721. $this->jsTrans['subscribers_import_match_confirmation_2'] = __('Can you confirm that this column is corresponding to that field?', WYSIJA); 
  722. $this->js[] = 'wysija-validator'; 
  723. $helper_numbers = WYSIJA::get('numbers', 'helper'); 
  724. $bytes = $helper_numbers->get_max_file_upload(); 
  725.  
  726. if(isset($_SERVER['CONTENT_LENGTH']) && $_SERVER['CONTENT_LENGTH']>$bytes['maxbytes']) { 
  727. if(isset($_FILES['importfile']['name']) && $_FILES['importfile']['name']) { 
  728. $file_name = $_FILES['importfile']['name']; 
  729. }else{ 
  730. $file_name = __('which you have pasted', WYSIJA); 
  731.  
  732. $this->error(sprintf(__('Upload error, file %1$s is too large! (MAX:%2$s)', WYSIJA) , $file_name , $bytes['maxmegas']), true); 
  733. $this->redirect('admin.php?page=wysija_subscribers&action=import'); 
  734. return false; 
  735.  
  736. $import = new WJ_Import(); 
  737. $this->data = $import->scan_csv_file(); 
  738.  
  739. if($this->data === false) { 
  740. $this->redirect('admin.php?page=wysija_subscribers&action=import'); 
  741.  
  742. $model_config = WYSIJA::get('config', 'model'); 
  743. $this->jsTrans['userStatuses'] = array( 
  744. -1 => __('Unsubscribed', WYSIJA),  
  745. 0 => $model_config->getValue('confirm_dbleoptin') ? __('Unconfirmed', WYSIJA) : __('Subscribed', WYSIJA),  
  746. 1 => __('Subscribed', WYSIJA) 
  747. ); 
  748. $this->js[] = 'wysija-import-match'; 
  749. $this->viewObj->title=__('Import Subscribers', WYSIJA); 
  750. $this->viewShow='importmatch'; 
  751.  
  752.  
  753. function import_save() { 
  754. @ini_set('max_execution_time', 0); 
  755.  
  756. $this->requireSecurity(); 
  757. $this->_resetGlobMsg(); 
  758.  
  759. //we need to save a new list in that situation 
  760. if(!empty($_REQUEST['wysija']['list']['newlistname'])) { 
  761. $model_list = WYSIJA::get('list', 'model'); 
  762. $data_list = array(); 
  763. $data_list['is_enabled'] = 1; 
  764. $data_list['name'] = $_REQUEST['wysija']['list']['newlistname']; 
  765. $_REQUEST['wysija']['user_list']['list'][] = $model_list->insert($data_list); 
  766.  
  767. //if there is no list selected, we return to the same form prompting the user to take action 
  768. if(!isset($_REQUEST['wysija']['user_list']['list']) || !$_REQUEST['wysija']['user_list']['list']) { 
  769. $this->error(__('You need to select at least one list.', WYSIJA), true); 
  770. return $this->importmatch(); 
  771.  
  772. $import = new WJ_Import(); 
  773. $data_numbers = $import->import_subscribers(); 
  774. $duplicate_emails_count = $import->get_duplicate_emails_count(); 
  775.  
  776. if($data_numbers === false) { 
  777. return $this->redirect('admin.php?page=wysija_subscribers&action=import'); 
  778.  
  779. //get a list of list name 
  780. $model_list = WYSIJA::get('list', 'model'); 
  781. $results = $model_list->get(array('name'), array('list_id'=>$_REQUEST['wysija']['user_list']['list'])); 
  782.  
  783. $list_names=array(); 
  784. foreach($results as $k =>$v) { 
  785. $list_names[]=$v['name']; 
  786.  
  787. $this->notice( sprintf(__('%1$s subscribers added to %2$s.', WYSIJA),  
  788. $data_numbers['list_user_ids'],  
  789. '"'.implode('", "', $list_names).'"' 
  790. ) ); 
  791.  
  792. if(count($duplicate_emails_count)>0) { 
  793. $list_emails = ''; 
  794. $i = 0; 
  795. foreach($duplicate_emails_count as $email_address => $occurences) { 
  796. if( $i > 0 )$list_emails.=', '; 
  797. $list_emails.= $email_address.' ('.$occurences.')'; 
  798. $i++; 
  799. //$emailsalreadyinserted=array_keys($emailsCount); 
  800. $this->notice(sprintf(__('%1$s emails appear more than once in your file : %2$s.', WYSIJA), count($duplicate_emails_count), $list_emails), 0); 
  801.  
  802. if(count($data_numbers['invalid'])>0) { 
  803. $string = sprintf(__('%1$s emails are not valid : %2$s.', WYSIJA), count($data_numbers['invalid']), utf8_encode(implode(', ', $data_numbers['invalid']))); 
  804. $this->notice($string, 0); 
  805.  
  806. $this->redirect(); 
  807.  
  808.  
  809. function export() { 
  810. $this->js[]='wysija-validator'; 
  811.  
  812. $this->viewObj->title=__('Export Subscribers', WYSIJA); 
  813. $this->data=array(); 
  814. //$this->data['lists']=$this->_getLists(); 
  815. $this->data['lists'] = $model_list = WYSIJA::get('list', 'model'); 
  816. $lists_results = $model_list->getLists(); 
  817.  
  818. $lists=array(); 
  819.  
  820. foreach($lists_results as $list_row) { 
  821. $lists[$list_row['list_id']]=$list_row; 
  822. $this->data['lists']=$lists; 
  823.  
  824. $this->viewShow='export'; 
  825.  
  826. function exportcampaign() { 
  827. $this->requireSecurity(); 
  828.  
  829. if(isset($_REQUEST['file_name'])) { 
  830. $file_name = preg_replace('#[^a-z0-9_\-.]#i', '', base64_decode($_REQUEST['file_name'])); 
  831.  
  832. $helper_file = WYSIJA::get('file', 'helper'); 
  833. $exported_file_link = $helper_file->url($file_name, 'temp'); 
  834.  
  835. $content = file_get_contents( $exported_file_link ); 
  836. $user_ids=explode(", ", $content); 
  837. $_REQUEST['wysija']['user']['user_id']=$user_ids; 
  838.  
  839. $this->exportlist(); 
  840.  
  841.  
  842. /** 
  843. * bulk delete option 
  844. */ 
  845. function deleteusers() { 
  846. $this->requireSecurity(); 
  847. $helper_user=WYSIJA::get('user', 'helper'); 
  848. if(!empty($this->_batch_select)) { 
  849. $helper_user->delete($this->_batch_select, false, true); 
  850. }else{ 
  851. $helper_user->delete($_POST['wysija']['user']['user_id']); 
  852.  
  853. if($this->_affected_rows > 1) { 
  854. $this->notice(sprintf(__(' %1$s subscribers have been deleted.', WYSIJA), $this->_affected_rows)); 
  855. }else{ 
  856. $this->notice(sprintf(__(' %1$s subscriber have been deleted.', WYSIJA), $this->_affected_rows)); 
  857.  
  858. // make sure the total count of subscribers is updated 
  859. $helper_user->refreshUsers(); 
  860. $this->redirect_after_bulk_action(); 
  861.  
  862. /** 
  863. * function generating an export file based on an array of user_ids 
  864. */ 
  865. function export_get() { 
  866. @ini_set('max_execution_time', 0); 
  867. $this->requireSecurity(); 
  868. $export = new WJ_Export(); 
  869.  
  870. if(!empty($this->_batch_select)) { 
  871. $export->batch_select = $this->_batch_select; 
  872.  
  873. $file_path_result = $export->export_subscribers(); 
  874.  
  875. $this->notice(str_replace( 
  876. array('[link]', '[/link]'),  
  877. array('<a href="'.$file_path_result['url'].'" target="_blank" class="exported-file" >', '</a>'),  
  878. sprintf(__('%1$s subscribers were exported. Get the exported file [link]here[/link].', WYSIJA), $export->get_user_ids_rows()))); 
  879.  
  880. if(isset($_REQUEST['camp_id'])) { 
  881. $this->redirect('admin.php?page=wysija_campaigns&action=viewstats&id='.$_REQUEST['camp_id']); 
  882. }else{ 
  883. $this->redirect(); 
  884.  
  885. public function exportlist() { 
  886. $this->requireSecurity(); 
  887. if(!empty($_REQUEST['wysija']['user']['force_select_all'])) { 
  888.  
  889. $select = array( 'COUNT(DISTINCT([wysija]user.user_id)) as total_users'); 
  890. if(!empty($_REQUEST['wysija']['filter']['filter_list'])) { 
  891. $select[] = '[wysija]user_list.list_id'; 
  892.  
  893. // filters for unsubscribed 
  894. $filters = $this->modelObj->detect_filters(); 
  895.  
  896. $count = $this->modelObj->get_subscribers( $select, $filters ); 
  897. $number = $count['total_users']; 
  898. } else { 
  899. $number = count($_REQUEST['wysija']['user']['user_id']); 
  900.  
  901. $this->viewObj->title = sprintf(__('Exporting %1$s subscribers', WYSIJA), $number); 
  902. $this->data=array(); 
  903.  
  904. $this->data['subscribers'] = $_REQUEST['wysija']['user']['user_id']; 
  905. $this->data['user'] = $_REQUEST['wysija']['user'];//for batch-selecting 
  906.  
  907. if(!empty($_REQUEST['search'])) { 
  908. $_REQUEST['wysija']['filter']['search'] = $_REQUEST['search']; 
  909.  
  910. if(isset($_REQUEST['wysija']['filter'])) { 
  911. $this->data['filter'] = $_REQUEST['wysija']['filter'];//for batch-selecting 
  912. $this->viewShow = 'export'; 
  913.