WYSIJA_module_archive_std

The MailPoet Newsletters WYSIJA module archive std class.

Defined (1)

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

/modules/archive_std/archive_std.php  
  1. class WYSIJA_module_archive_std extends WYSIJA_module { 
  2.  
  3. public $name = 'archive_std'; 
  4.  
  5. public $model = 'WYSIJA_model_archive_std'; 
  6.  
  7. public $view = 'archive_std_view'; 
  8.  
  9. /** 
  10. * hook_newsletter - page MailPoet >> Newsletters >> view detail 
  11. * @param array $params 
  12. * @return string 
  13. */ 
  14. public function hook_settings_super_advanced(Array $params) { 
  15. $this->view_show = 'hook_settings_super_advanced'; 
  16. $this->data['lists'] = $this->get_lists(); 
  17. return $this->render(); 
  18.  
  19. /** 
  20. * hook: before saving settings 
  21. * @param type $params = array( 
  22. * 'REQUEST' =>& $_REQUEST 
  23. * ) 
  24. */ 
  25. public function hook_settings_before_save(Array $params) { 
  26. $config_model = WYSIJA::get('config', 'model'); 
  27. $archive_lists = $config_model->getValue('archive_lists'); 
  28. if (!empty($archive_lists))// just save for the first time only 
  29. return; 
  30. // save to database, useful for MixPanel 
  31. $lists = $this->get_lists(); 
  32. if (empty($lists)) 
  33. return; 
  34. $tmp = array( ); 
  35. foreach ($lists as $list) { 
  36. $is_checked = false; 
  37. if (isset($params['REQUEST']['wysija']['config']['archive_lists']) && in_array($list['list_id'], $params['REQUEST']['wysija']['config']['archive_lists'])) 
  38. $is_checked = true; 
  39. $tmp[$list['list_id']] = $is_checked; 
  40. $params['REQUEST']['wysija']['config']['archive_lists'] = $tmp; 
  41.  
  42. /** 
  43. * register shortcode, invoked by Wysija-newsletters/index.php::helper_front() 
  44. */ 
  45. public function front_init() { 
  46. add_shortcode('wysija_archive', array( $this, 'scan_wysija_archive_shortcode' )); 
  47.  
  48. /** 
  49. * scan shortcode [wysija_archive] 
  50. * @param array $attributes 
  51. */ 
  52. public function scan_wysija_archive_shortcode($attributes = array( )) { 
  53. $list_ids = !empty($attributes['list_id']) ? explode(', ', $attributes['list_id']) : array( ); 
  54. return $this->render_archive($list_ids); 
  55.  
  56. /** 
  57. * Render archive based on lists which are sent to 
  58. * @param array $list_ids 
  59. */ 
  60. protected function render_archive(Array $list_ids) { 
  61. $this->data['newsletters'] = $this->model_obj->get_newsletters($list_ids); 
  62. $this->view_show = 'render_archive'; 
  63. return $this->render(); 
  64.  
  65. /** 
  66. * Get all available list of subscribers 
  67. * @return array( 
  68. * 0 => array( // first list 
  69. * 'name' => string 
  70. * 'list_id' => int,  
  71. * 'is_public' => boolean 
  72. * ) 
  73. * ) 
  74. */ 
  75. protected function get_lists() { 
  76. $model_list = WYSIJA::get('list', 'model'); 
  77. return $model_list->get(array( 'name', 'list_id', 'is_public' ), array( 'is_enabled' => 1 )); 
  78.