<?php if ( ! defined( 'ABSPATH' ) ) exit;
* Single notification object.
* This object lets us call it like: Ninja_Forms()->notification( 33 )->methods()
* @subpackage Classes/Notifications
* @copyright Copyright (c) 2014, WPNINJAS
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
* Holds the id of our form.
function __construct( $id ) {
$this->type = nf_get_object_meta_value( $id, 'type' );
$this->active = ( nf_get_object_meta_value( $id, 'active' ) == 1 ) ? true : false;
$this->form_id = nf_get_object_parent( $id );
* Ouptut our admin screen
public function edit_screen() {
// Call our type edit screen.
Ninja_Forms()->notification_types[ $type ]->edit_screen( $this->id );
* Delete our notification
public function delete() {
nf_delete_notification( $this->id );
* Activate our notification
public function activate() {
nf_update_object_meta( $this->id, 'active', 1 );
* Deactivate our notification
public function deactivate() {
nf_update_object_meta( $this->id, 'active', 0 );
* Duplicate our notification
public function duplicate() {
$n_id = Ninja_Forms()->notifications->create( $this->form_id );
$meta = nf_get_notification_by_id( $this->id );
foreach ( $meta as $meta_key => $meta_value ) {
nf_update_object_meta( $n_id, $meta_key, $meta_value );
$name = nf_get_object_meta_value( $n_id, 'name' ) . ' - ' . __( 'duplicate', 'ninja-forms' );
nf_update_object_meta( $n_id, 'name', $name );
* Run our notification processing function
public function process() {
if ( isset ( Ninja_Forms()->notification_types[ $type ] ) && is_object( Ninja_Forms()->notification_types[ $type ] ) ) {
Ninja_Forms()->notification_types[ $type ]->process( $this->id );
* Get a notification setting
* @return string $meta_value
public function get_setting( $meta_key ) {
return nf_get_object_meta_value( $this->id, $meta_key );
* Update a notification setting
public function update_setting( $meta_key, $meta_value ) {
nf_update_object_meta( $this->id, $meta_key, $meta_value );
* Get our notification type name
public function type_name() {
// Call our type edit screen.
return Ninja_Forms()->notification_types[ $type ]->name;