NF_Notification

Notification.

Defined (1)

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

/deprecated/classes/notification.php  
  1. class NF_Notification 
  2.  
  3. /** 
  4. * @var notification id 
  5. */ 
  6. var $id = ''; 
  7.  
  8. /** 
  9. * @var type 
  10. */ 
  11. var $type = ''; 
  12.  
  13. /** 
  14. * @var active 
  15. * Holds a boolean value. 
  16. */ 
  17. var $active = ''; 
  18.  
  19. /** 
  20. * @var form_id 
  21. * Holds the id of our form. 
  22. */ 
  23. var $form_id = ''; 
  24.  
  25.  
  26. /** 
  27. * Get things rolling 
  28. *  
  29. * @since 2.8 
  30. * @return void 
  31. */ 
  32. function __construct( $id ) { 
  33. $this->id = $id; 
  34. $this->type = nf_get_object_meta_value( $id, 'type' ); 
  35. $this->active = ( nf_get_object_meta_value( $id, 'active' ) == 1 ) ? true : false; 
  36. $this->form_id = nf_get_object_parent( $id ); 
  37.  
  38. /** 
  39. * Ouptut our admin screen 
  40. *  
  41. * @access public 
  42. * @since 2.8 
  43. * @return void 
  44. */ 
  45. public function edit_screen() { 
  46. $type = $this->type; 
  47. // Call our type edit screen. 
  48. Ninja_Forms()->notification_types[ $type ]->edit_screen( $this->id ); 
  49.  
  50. /** 
  51. * Delete our notification 
  52. *  
  53. * @access public 
  54. * @since 2.8 
  55. * @return void 
  56. */ 
  57. public function delete() { 
  58. nf_delete_notification( $this->id ); 
  59.  
  60. /** 
  61. * Activate our notification 
  62. *  
  63. * @access public 
  64. * @since 2.8 
  65. * @return void 
  66. */ 
  67. public function activate() { 
  68. nf_update_object_meta( $this->id, 'active', 1 ); 
  69. $this->active = true; 
  70.  
  71. /** 
  72. * Deactivate our notification 
  73. *  
  74. * @access public 
  75. * @since 2.8 
  76. * @return void 
  77. */ 
  78. public function deactivate() { 
  79. nf_update_object_meta( $this->id, 'active', 0 ); 
  80. $this->active = false; 
  81.  
  82. /** 
  83. * Duplicate our notification 
  84. * @access public 
  85. * @since 2.8 
  86. * @return int $n_id 
  87. */ 
  88. public function duplicate() { 
  89. $n_id = Ninja_Forms()->notifications->create( $this->form_id ); 
  90. $meta = nf_get_notification_by_id( $this->id ); 
  91. foreach ( $meta as $meta_key => $meta_value ) { 
  92. nf_update_object_meta( $n_id, $meta_key, $meta_value ); 
  93.  
  94. $name = nf_get_object_meta_value( $n_id, 'name' ) . ' - ' . __( 'duplicate', 'ninja-forms' ); 
  95. nf_update_object_meta( $n_id, 'name', $name ); 
  96.  
  97. /** 
  98. * Run our notification processing function 
  99. *  
  100. * @access public 
  101. * @since 2.8 
  102. * @return void 
  103. */ 
  104. public function process() { 
  105. $type = $this->type; 
  106. if ( isset ( Ninja_Forms()->notification_types[ $type ] ) && is_object( Ninja_Forms()->notification_types[ $type ] ) ) { 
  107. Ninja_Forms()->notification_types[ $type ]->process( $this->id );  
  108.  
  109. /** 
  110. * Get a notification setting 
  111. *  
  112. * @access public 
  113. * @since 2.8 
  114. * @return string $meta_value 
  115. */ 
  116. public function get_setting( $meta_key ) { 
  117. return nf_get_object_meta_value( $this->id, $meta_key ); 
  118.  
  119. /** 
  120. * Update a notification setting 
  121. *  
  122. * @access public 
  123. * @since 2.8 
  124. * @return bool 
  125. */ 
  126. public function update_setting( $meta_key, $meta_value ) { 
  127. nf_update_object_meta( $this->id, $meta_key, $meta_value ); 
  128. return true; 
  129.  
  130. /** 
  131. * Get our notification type name 
  132. *  
  133. * @access public 
  134. * @since 2.9 
  135. * @return string $name 
  136. */ 
  137. public function type_name() { 
  138. $type = $this->type; 
  139. // Call our type edit screen. 
  140. return Ninja_Forms()->notification_types[ $type ]->name; 
  141.