Action.php
1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php if ( ! defined( 'ABSPATH' ) ) exit;
/**
* Class NF_Database_Models_Action
*/
final class NF_Database_Models_Action extends NF_Abstracts_Model
{
private $form_id = '';
protected $_type = 'action';
protected $_table_name = 'nf3_actions';
protected $_meta_table_name = 'nf3_action_meta';
protected $_columns = array(
'title',
'key',
'type',
'active',
'created_at',
'label'
);
public function __construct( $db, $id, $parent_id = '' )
{
parent::__construct( $db, $id, $parent_id );
/**
* Remove new DB columns from our $_columns list if the user hasn't completed required upgrades stage 1.
*/
$sql = "SHOW COLUMNS FROM {$db->prefix}nf3_actions LIKE 'label'";
$results = $db->get_results( $sql );
/**
* If we don't have the label column, we need to remove our new columns.
*
* Also, set our db stage 1 tracker to false.
*/
if ( empty ( $results ) ) {
foreach( $this->_columns as $i => $col ) {
if( 'label' === $col ) {
unset( $this->_columns[ $i ] );
}
}
$this->db_stage_1_complete = false;
}
}
} // End NF_Database_Models_Action