WYSIJA_model_user_history

The MailPoet Newsletters WYSIJA model user history class.

Defined (1)

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

/models/user_history.php  
  1. class WYSIJA_model_user_history extends WYSIJA_model{ 
  2.  
  3. var $pk='history_id'; 
  4. var $table_name='user_history'; 
  5. var $columns=array( 
  6. 'history_id'=>array('req'=>true, 'type'=>'integer'),  
  7. 'email_id'=>array('req'=>true, 'type'=>'integer'),  
  8. 'user_id'=>array('req'=>true, 'type'=>'integer'),  
  9. 'executed_at' => array('type'=>'integer'),  
  10. 'executed_by' => array('type'=>'integer'),  
  11. 'type' => array(),  
  12. 'details' => array(),  
  13. 'source' => array() 
  14. ); 
  15.  
  16.  
  17.  
  18. function __construct() { 
  19. parent::__construct(); 
  20.  
  21. /** 
  22. * overriding the model insert function to be compatible with acymailing way of doing it 
  23. * @param type $subid 
  24. * @param type $action 
  25. * @param string $data 
  26. * @param type $mailid 
  27. * @return type 
  28. */ 
  29. function insert($subid, $action=false, $data = array(), $mailid = 0) { 
  30. $current_user=WYSIJA::wp_get_userdata(); 
  31. /**dbg($current_user, 0); 
  32. $current_user=wp_get_current_user();*/ 
  33. if(!empty($current_user->ID)) { 
  34. $data[] = 'EXECUTED_BY::'.$current_user->ID.' ( '.$current_user->user_login.' )'; 
  35. $history = null; 
  36. $history['user_id'] = intval($subid); 
  37. $history['type'] = strip_tags($action); 
  38. $history['details'] = implode("\n", $data); 
  39. $history['executed_at'] = time(); 
  40. $history['email_id'] = $mailid; 
  41. $userHelper = WYSIJA::get('user', 'helper'); 
  42. $history['executed_by'] = $userHelper->getIP(); 
  43. if(!empty($_SERVER)) { 
  44. $source = array(); 
  45. $vars = array('HTTP_REFERER', 'HTTP_USER_AGENT', 'HTTP_HOST', 'SERVER_ADDR', 'REMOTE_ADDR', 'REQUEST_URI', 'QUERY_STRING'); 
  46. foreach($vars as $oneVar) { 
  47. if(!empty($_SERVER[$oneVar])) $source[] = $oneVar.'::'.strip_tags($_SERVER[$oneVar]); 
  48. $history['source'] = implode("\n", $source); 
  49. return parent::insert($history);