WYSIJA_control_front

The MailPoet Newsletters WYSIJA control front class.

Defined (1)

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

/controllers/front.php  
  1. class WYSIJA_control_front extends WYSIJA_control{ 
  2.  
  3. function __construct($extension="wysija-newsletters") { 
  4. $this->extension=$extension; 
  5. parent::__construct(); 
  6. $_REQUEST = stripslashes_deep($_REQUEST); 
  7. $_POST = stripslashes_deep($_POST); 
  8.  
  9. if(isset($_REQUEST['action'])) { 
  10. $this->action = preg_replace('|[^a-z0-9_\-]|i', '', $_REQUEST['action']); 
  11. }else{ 
  12. $this->action = 'index'; 
  13.  
  14. function save() { 
  15. $this->requireSecurity(); 
  16. /** see if it's an update or an insert */ 
  17. /**get the pk and its value as a conditions where pk = pkval*/ 
  18. $conditions=$this->getPKVal($this->modelObj); 
  19.  
  20. if($conditions) { 
  21. /** this an update */ 
  22.  
  23. $result=$this->modelObj->update($_REQUEST['wysija'][$this->model], $conditions); 
  24.  
  25. if($result) $this->notice($this->messages['update'][true]); 
  26. else{ 
  27. $this->error($this->messages['update'][false], true); 
  28.  
  29. }else{ 
  30. /** this is an insert */ 
  31. unset($_REQUEST['wysija'][$this->modelObj->pk]); 
  32.  
  33. $result=$this->modelObj->insert($_REQUEST['wysija'][$this->model]); 
  34.  
  35. if($result) $this->notice($this->messages['insert'][true]); 
  36. else{ 
  37. $this->error($this->messages['insert'][false], true); 
  38.  
  39. return $result; 
  40.  
  41. function redirect($location) { 
  42. // make sure we encode square brackets as wp_redirect will strip them off 
  43. $location = str_replace(array('[', ']'), array('%5B', '%5D'), $location); 
  44.  
  45. // redirect to specified location 
  46. wp_redirect($location); 
  47. exit;