Completed
Branch dependabot/npm_and_yarn/wordpr... (839ddb)
by
unknown
16:10 queued 14:20
created
core/EE_Configurable.core.php 2 patches
Indentation   +139 added lines, -139 removed lines patch added patch discarded remove patch
@@ -10,143 +10,143 @@
 block discarded – undo
10 10
 abstract class EE_Configurable extends EE_Base
11 11
 {
12 12
 
13
-    /**
14
-     * @var $_config
15
-     * @type EE_Config_Base
16
-     */
17
-    protected $_config;
18
-
19
-    /**
20
-     * @var $_config_section
21
-     * @type string
22
-     */
23
-    protected $_config_section = '';
24
-
25
-    /**
26
-     * @var $_config_class
27
-     * @type string
28
-     */
29
-    protected $_config_class = '';
30
-
31
-    /**
32
-     * @var $_config_name
33
-     * @type string
34
-     */
35
-    protected $_config_name = '';
36
-
37
-
38
-    /**
39
-     * @param string $config_section
40
-     */
41
-    public function set_config_section($config_section = '')
42
-    {
43
-        $this->_config_section = ! empty($config_section) ? $config_section : 'modules';
44
-    }
45
-
46
-
47
-    /**
48
-     * @return mixed
49
-     */
50
-    public function config_section()
51
-    {
52
-        return $this->_config_section;
53
-    }
54
-
55
-
56
-    /**
57
-     * @param string $config_class
58
-     */
59
-    public function set_config_class($config_class = '')
60
-    {
61
-        $this->_config_class = $config_class;
62
-    }
63
-
64
-
65
-    /**
66
-     * @return mixed
67
-     */
68
-    public function config_class()
69
-    {
70
-        return $this->_config_class;
71
-    }
72
-
73
-
74
-    /**
75
-     * @param mixed $config_name
76
-     */
77
-    public function set_config_name($config_name)
78
-    {
79
-        $this->_config_name = ! empty($config_name) ? $config_name : get_called_class();
80
-    }
81
-
82
-
83
-    /**
84
-     * @return mixed
85
-     */
86
-    public function config_name()
87
-    {
88
-        return $this->_config_name;
89
-    }
90
-
91
-
92
-    /**
93
-     *    set_config
94
-     *    this method integrates directly with EE_Config to set up the config object for this class
95
-     *
96
-     * @access    protected
97
-     * @param    EE_Config_Base $config_obj
98
-     * @return    mixed    EE_Config_Base | NULL
99
-     */
100
-    protected function _set_config(EE_Config_Base $config_obj = null)
101
-    {
102
-        return EE_Config::instance()->set_config(
103
-            $this->config_section(),
104
-            $this->config_name(),
105
-            $this->config_class(),
106
-            $config_obj
107
-        );
108
-    }
109
-
110
-
111
-    /**
112
-     *    _update_config
113
-     *    this method integrates directly with EE_Config to update an existing config object for this class
114
-     *
115
-     * @access    protected
116
-     * @param    EE_Config_Base $config_obj
117
-     * @throws \EE_Error
118
-     * @return    mixed    EE_Config_Base | NULL
119
-     */
120
-    public function _update_config(EE_Config_Base $config_obj = null)
121
-    {
122
-        $config_class = $this->config_class();
123
-        if (! $config_obj instanceof $config_class) {
124
-            throw new EE_Error(
125
-                sprintf(
126
-                    __('The "%1$s" class is not an instance of %2$s.', 'event_espresso'),
127
-                    print_r($config_obj, true),
128
-                    $config_class
129
-                )
130
-            );
131
-        }
132
-        return EE_Config::instance()->update_config($this->config_section(), $this->config_name(), $config_obj);
133
-    }
134
-
135
-
136
-    /**
137
-     * gets the class's config object
138
-     *
139
-     * @return EE_Config_Base
140
-     */
141
-    public function config()
142
-    {
143
-        if (empty($this->_config)) {
144
-            $this->_config = EE_Config::instance()->get_config(
145
-                $this->config_section(),
146
-                $this->config_name(),
147
-                $this->config_class()
148
-            );
149
-        }
150
-        return $this->_config;
151
-    }
13
+	/**
14
+	 * @var $_config
15
+	 * @type EE_Config_Base
16
+	 */
17
+	protected $_config;
18
+
19
+	/**
20
+	 * @var $_config_section
21
+	 * @type string
22
+	 */
23
+	protected $_config_section = '';
24
+
25
+	/**
26
+	 * @var $_config_class
27
+	 * @type string
28
+	 */
29
+	protected $_config_class = '';
30
+
31
+	/**
32
+	 * @var $_config_name
33
+	 * @type string
34
+	 */
35
+	protected $_config_name = '';
36
+
37
+
38
+	/**
39
+	 * @param string $config_section
40
+	 */
41
+	public function set_config_section($config_section = '')
42
+	{
43
+		$this->_config_section = ! empty($config_section) ? $config_section : 'modules';
44
+	}
45
+
46
+
47
+	/**
48
+	 * @return mixed
49
+	 */
50
+	public function config_section()
51
+	{
52
+		return $this->_config_section;
53
+	}
54
+
55
+
56
+	/**
57
+	 * @param string $config_class
58
+	 */
59
+	public function set_config_class($config_class = '')
60
+	{
61
+		$this->_config_class = $config_class;
62
+	}
63
+
64
+
65
+	/**
66
+	 * @return mixed
67
+	 */
68
+	public function config_class()
69
+	{
70
+		return $this->_config_class;
71
+	}
72
+
73
+
74
+	/**
75
+	 * @param mixed $config_name
76
+	 */
77
+	public function set_config_name($config_name)
78
+	{
79
+		$this->_config_name = ! empty($config_name) ? $config_name : get_called_class();
80
+	}
81
+
82
+
83
+	/**
84
+	 * @return mixed
85
+	 */
86
+	public function config_name()
87
+	{
88
+		return $this->_config_name;
89
+	}
90
+
91
+
92
+	/**
93
+	 *    set_config
94
+	 *    this method integrates directly with EE_Config to set up the config object for this class
95
+	 *
96
+	 * @access    protected
97
+	 * @param    EE_Config_Base $config_obj
98
+	 * @return    mixed    EE_Config_Base | NULL
99
+	 */
100
+	protected function _set_config(EE_Config_Base $config_obj = null)
101
+	{
102
+		return EE_Config::instance()->set_config(
103
+			$this->config_section(),
104
+			$this->config_name(),
105
+			$this->config_class(),
106
+			$config_obj
107
+		);
108
+	}
109
+
110
+
111
+	/**
112
+	 *    _update_config
113
+	 *    this method integrates directly with EE_Config to update an existing config object for this class
114
+	 *
115
+	 * @access    protected
116
+	 * @param    EE_Config_Base $config_obj
117
+	 * @throws \EE_Error
118
+	 * @return    mixed    EE_Config_Base | NULL
119
+	 */
120
+	public function _update_config(EE_Config_Base $config_obj = null)
121
+	{
122
+		$config_class = $this->config_class();
123
+		if (! $config_obj instanceof $config_class) {
124
+			throw new EE_Error(
125
+				sprintf(
126
+					__('The "%1$s" class is not an instance of %2$s.', 'event_espresso'),
127
+					print_r($config_obj, true),
128
+					$config_class
129
+				)
130
+			);
131
+		}
132
+		return EE_Config::instance()->update_config($this->config_section(), $this->config_name(), $config_obj);
133
+	}
134
+
135
+
136
+	/**
137
+	 * gets the class's config object
138
+	 *
139
+	 * @return EE_Config_Base
140
+	 */
141
+	public function config()
142
+	{
143
+		if (empty($this->_config)) {
144
+			$this->_config = EE_Config::instance()->get_config(
145
+				$this->config_section(),
146
+				$this->config_name(),
147
+				$this->config_class()
148
+			);
149
+		}
150
+		return $this->_config;
151
+	}
152 152
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -120,7 +120,7 @@
 block discarded – undo
120 120
     public function _update_config(EE_Config_Base $config_obj = null)
121 121
     {
122 122
         $config_class = $this->config_class();
123
-        if (! $config_obj instanceof $config_class) {
123
+        if ( ! $config_obj instanceof $config_class) {
124 124
             throw new EE_Error(
125 125
                 sprintf(
126 126
                     __('The "%1$s" class is not an instance of %2$s.', 'event_espresso'),
Please login to merge, or discard this patch.
core/db_models/EEM_Term_Taxonomy.model.php 2 patches
Indentation   +116 added lines, -116 removed lines patch added patch discarded remove patch
@@ -10,128 +10,128 @@
 block discarded – undo
10 10
 class EEM_Term_Taxonomy extends EEM_Base
11 11
 {
12 12
 
13
-    // private instance of the Attendee object
14
-    protected static $_instance = null;
13
+	// private instance of the Attendee object
14
+	protected static $_instance = null;
15 15
 
16 16
 
17 17
 
18
-    protected function __construct($timezone = null)
19
-    {
20
-        $this->singular_item = __('Term Taxonomy', 'event_espresso');
21
-        $this->plural_item = __('Term Taxonomy', 'event_espresso');
22
-        $this->_tables = array(
23
-            'Term_Taxonomy' => new EE_Primary_Table('term_taxonomy', 'term_taxonomy_id'),
24
-        );
25
-        $this->_fields = array(
26
-            'Term_Taxonomy' => array(
27
-                'term_taxonomy_id' => new EE_Primary_Key_Int_Field(
28
-                    'term_taxonomy_id',
29
-                    __('Term-Taxonomy ID', 'event_espresso')
30
-                ),
31
-                'term_id'          => new EE_Foreign_Key_Int_Field(
32
-                    'term_id',
33
-                    __("Term Id", "event_espresso"),
34
-                    false,
35
-                    0,
36
-                    'Term'
37
-                ),
38
-                'taxonomy'         => new EE_Plain_Text_Field(
39
-                    'taxonomy',
40
-                    __('Taxonomy Name', 'event_espresso'),
41
-                    false,
42
-                    'category'
43
-                ),
44
-                'description'      => new EE_Post_Content_Field(
45
-                    'description',
46
-                    __("Description of Term", "event_espresso"),
47
-                    false,
48
-                    ''
49
-                ),
50
-                'parent'           => new EE_Integer_Field('parent', __("Parent Term ID", "event_espresso"), false, 0),
51
-                'term_count'       => new EE_Integer_Field(
52
-                    'count',
53
-                    __("Count of Objects attached", 'event_espresso'),
54
-                    false,
55
-                    0
56
-                ),
57
-            ),
58
-        );
59
-        $this->_model_relations = array(
60
-            'Term_Relationship' => new EE_Has_Many_Relation(),
61
-            'Term'              => new EE_Belongs_To_Relation(),
62
-        );
63
-        $cpt_models = array_keys(EE_Registry::instance()->cpt_models());
64
-        foreach ($cpt_models as $model_name) {
65
-            $this->_model_relations[ $model_name ] = new EE_HABTM_Relation('Term_Relationship');
66
-        }
67
-        $this->_wp_core_model = true;
68
-        $this->_indexes = array(
69
-            'term_id_taxonomy' => new EE_Unique_Index(array('term_id', 'taxonomy')),
70
-        );
71
-        $path_to_tax_model = '';
72
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
73
-        $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Taxonomy_Protected(
74
-            $path_to_tax_model
75
-        );
76
-        $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = false;
77
-        $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = false;
78
-        // add cap restrictions for editing relating to the "ee_edit_*"
79
-        $this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_event_category'] = new EE_Default_Where_Conditions(
80
-            array(
81
-                $path_to_tax_model . 'taxonomy*ee_edit_event_category' => array('!=', 'espresso_event_categories'),
82
-            )
83
-        );
84
-        $this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_venue_category'] = new EE_Default_Where_Conditions(
85
-            array(
86
-                $path_to_tax_model . 'taxonomy*ee_edit_venue_category' => array('!=', 'espresso_venue_categories'),
87
-            )
88
-        );
89
-        $this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_event_type'] = new EE_Default_Where_Conditions(
90
-            array(
91
-                $path_to_tax_model . 'taxonomy*ee_edit_event_type' => array('!=', 'espresso_event_type'),
92
-            )
93
-        );
94
-        // add cap restrictions for deleting relating to the "ee_deleting_*"
95
-        $this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_event_category'] = new EE_Default_Where_Conditions(
96
-            array(
97
-                $path_to_tax_model . 'taxonomy*ee_delete_event_category' => array('!=', 'espresso_event_categories'),
98
-            )
99
-        );
100
-        $this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_venue_category'] = new EE_Default_Where_Conditions(
101
-            array(
102
-                $path_to_tax_model . 'taxonomy*ee_delete_venue_category' => array('!=', 'espresso_venue_categories'),
103
-            )
104
-        );
105
-        $this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_event_type'] = new EE_Default_Where_Conditions(
106
-            array(
107
-                $path_to_tax_model . 'taxonomy*ee_delete_event_type' => array('!=', 'espresso_event_type'),
108
-            )
109
-        );
110
-        parent::__construct($timezone);
111
-        add_filter('FHEE__Read__create_model_query_params', array('EEM_Term_Taxonomy', 'rest_api_query_params'), 10, 3);
112
-    }
18
+	protected function __construct($timezone = null)
19
+	{
20
+		$this->singular_item = __('Term Taxonomy', 'event_espresso');
21
+		$this->plural_item = __('Term Taxonomy', 'event_espresso');
22
+		$this->_tables = array(
23
+			'Term_Taxonomy' => new EE_Primary_Table('term_taxonomy', 'term_taxonomy_id'),
24
+		);
25
+		$this->_fields = array(
26
+			'Term_Taxonomy' => array(
27
+				'term_taxonomy_id' => new EE_Primary_Key_Int_Field(
28
+					'term_taxonomy_id',
29
+					__('Term-Taxonomy ID', 'event_espresso')
30
+				),
31
+				'term_id'          => new EE_Foreign_Key_Int_Field(
32
+					'term_id',
33
+					__("Term Id", "event_espresso"),
34
+					false,
35
+					0,
36
+					'Term'
37
+				),
38
+				'taxonomy'         => new EE_Plain_Text_Field(
39
+					'taxonomy',
40
+					__('Taxonomy Name', 'event_espresso'),
41
+					false,
42
+					'category'
43
+				),
44
+				'description'      => new EE_Post_Content_Field(
45
+					'description',
46
+					__("Description of Term", "event_espresso"),
47
+					false,
48
+					''
49
+				),
50
+				'parent'           => new EE_Integer_Field('parent', __("Parent Term ID", "event_espresso"), false, 0),
51
+				'term_count'       => new EE_Integer_Field(
52
+					'count',
53
+					__("Count of Objects attached", 'event_espresso'),
54
+					false,
55
+					0
56
+				),
57
+			),
58
+		);
59
+		$this->_model_relations = array(
60
+			'Term_Relationship' => new EE_Has_Many_Relation(),
61
+			'Term'              => new EE_Belongs_To_Relation(),
62
+		);
63
+		$cpt_models = array_keys(EE_Registry::instance()->cpt_models());
64
+		foreach ($cpt_models as $model_name) {
65
+			$this->_model_relations[ $model_name ] = new EE_HABTM_Relation('Term_Relationship');
66
+		}
67
+		$this->_wp_core_model = true;
68
+		$this->_indexes = array(
69
+			'term_id_taxonomy' => new EE_Unique_Index(array('term_id', 'taxonomy')),
70
+		);
71
+		$path_to_tax_model = '';
72
+		$this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
73
+		$this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Taxonomy_Protected(
74
+			$path_to_tax_model
75
+		);
76
+		$this->_cap_restriction_generators[ EEM_Base::caps_edit ] = false;
77
+		$this->_cap_restriction_generators[ EEM_Base::caps_delete ] = false;
78
+		// add cap restrictions for editing relating to the "ee_edit_*"
79
+		$this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_event_category'] = new EE_Default_Where_Conditions(
80
+			array(
81
+				$path_to_tax_model . 'taxonomy*ee_edit_event_category' => array('!=', 'espresso_event_categories'),
82
+			)
83
+		);
84
+		$this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_venue_category'] = new EE_Default_Where_Conditions(
85
+			array(
86
+				$path_to_tax_model . 'taxonomy*ee_edit_venue_category' => array('!=', 'espresso_venue_categories'),
87
+			)
88
+		);
89
+		$this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_event_type'] = new EE_Default_Where_Conditions(
90
+			array(
91
+				$path_to_tax_model . 'taxonomy*ee_edit_event_type' => array('!=', 'espresso_event_type'),
92
+			)
93
+		);
94
+		// add cap restrictions for deleting relating to the "ee_deleting_*"
95
+		$this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_event_category'] = new EE_Default_Where_Conditions(
96
+			array(
97
+				$path_to_tax_model . 'taxonomy*ee_delete_event_category' => array('!=', 'espresso_event_categories'),
98
+			)
99
+		);
100
+		$this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_venue_category'] = new EE_Default_Where_Conditions(
101
+			array(
102
+				$path_to_tax_model . 'taxonomy*ee_delete_venue_category' => array('!=', 'espresso_venue_categories'),
103
+			)
104
+		);
105
+		$this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_event_type'] = new EE_Default_Where_Conditions(
106
+			array(
107
+				$path_to_tax_model . 'taxonomy*ee_delete_event_type' => array('!=', 'espresso_event_type'),
108
+			)
109
+		);
110
+		parent::__construct($timezone);
111
+		add_filter('FHEE__Read__create_model_query_params', array('EEM_Term_Taxonomy', 'rest_api_query_params'), 10, 3);
112
+	}
113 113
 
114 114
 
115 115
 
116
-    /**
117
-     * Makes sure that during REST API queries, we only return term-taxonomies
118
-     * for term taxonomies which should be shown in the rest api
119
-     *
120
-     * @param array    $model_query_params
121
-     * @param array    $querystring_query_params
122
-     * @param EEM_Base $model
123
-     * @return array
124
-     */
125
-    public static function rest_api_query_params($model_query_params, $querystring_query_params, $model)
126
-    {
127
-        if ($model === EEM_Term_Taxonomy::instance()) {
128
-            $taxonomies = get_taxonomies(array('show_in_rest' => true));
129
-            if (! empty($taxonomies)) {
130
-                $model_query_params[0]['taxonomy'] = array('IN', $taxonomies);
131
-            }
132
-        }
133
-        return $model_query_params;
134
-    }
116
+	/**
117
+	 * Makes sure that during REST API queries, we only return term-taxonomies
118
+	 * for term taxonomies which should be shown in the rest api
119
+	 *
120
+	 * @param array    $model_query_params
121
+	 * @param array    $querystring_query_params
122
+	 * @param EEM_Base $model
123
+	 * @return array
124
+	 */
125
+	public static function rest_api_query_params($model_query_params, $querystring_query_params, $model)
126
+	{
127
+		if ($model === EEM_Term_Taxonomy::instance()) {
128
+			$taxonomies = get_taxonomies(array('show_in_rest' => true));
129
+			if (! empty($taxonomies)) {
130
+				$model_query_params[0]['taxonomy'] = array('IN', $taxonomies);
131
+			}
132
+		}
133
+		return $model_query_params;
134
+	}
135 135
 }
136 136
 // End of file EEM_Term_Taxonomy.model.php
137 137
 // Location: /includes/models/EEM_Term_Taxonomy.model.php
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -62,49 +62,49 @@  discard block
 block discarded – undo
62 62
         );
63 63
         $cpt_models = array_keys(EE_Registry::instance()->cpt_models());
64 64
         foreach ($cpt_models as $model_name) {
65
-            $this->_model_relations[ $model_name ] = new EE_HABTM_Relation('Term_Relationship');
65
+            $this->_model_relations[$model_name] = new EE_HABTM_Relation('Term_Relationship');
66 66
         }
67 67
         $this->_wp_core_model = true;
68 68
         $this->_indexes = array(
69 69
             'term_id_taxonomy' => new EE_Unique_Index(array('term_id', 'taxonomy')),
70 70
         );
71 71
         $path_to_tax_model = '';
72
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
73
-        $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Taxonomy_Protected(
72
+        $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Public();
73
+        $this->_cap_restriction_generators[EEM_Base::caps_read_admin] = new EE_Restriction_Generator_Taxonomy_Protected(
74 74
             $path_to_tax_model
75 75
         );
76
-        $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = false;
77
-        $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = false;
76
+        $this->_cap_restriction_generators[EEM_Base::caps_edit] = false;
77
+        $this->_cap_restriction_generators[EEM_Base::caps_delete] = false;
78 78
         // add cap restrictions for editing relating to the "ee_edit_*"
79
-        $this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_event_category'] = new EE_Default_Where_Conditions(
79
+        $this->_cap_restrictions[EEM_Base::caps_edit]['ee_edit_event_category'] = new EE_Default_Where_Conditions(
80 80
             array(
81
-                $path_to_tax_model . 'taxonomy*ee_edit_event_category' => array('!=', 'espresso_event_categories'),
81
+                $path_to_tax_model.'taxonomy*ee_edit_event_category' => array('!=', 'espresso_event_categories'),
82 82
             )
83 83
         );
84
-        $this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_venue_category'] = new EE_Default_Where_Conditions(
84
+        $this->_cap_restrictions[EEM_Base::caps_edit]['ee_edit_venue_category'] = new EE_Default_Where_Conditions(
85 85
             array(
86
-                $path_to_tax_model . 'taxonomy*ee_edit_venue_category' => array('!=', 'espresso_venue_categories'),
86
+                $path_to_tax_model.'taxonomy*ee_edit_venue_category' => array('!=', 'espresso_venue_categories'),
87 87
             )
88 88
         );
89
-        $this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_event_type'] = new EE_Default_Where_Conditions(
89
+        $this->_cap_restrictions[EEM_Base::caps_edit]['ee_edit_event_type'] = new EE_Default_Where_Conditions(
90 90
             array(
91
-                $path_to_tax_model . 'taxonomy*ee_edit_event_type' => array('!=', 'espresso_event_type'),
91
+                $path_to_tax_model.'taxonomy*ee_edit_event_type' => array('!=', 'espresso_event_type'),
92 92
             )
93 93
         );
94 94
         // add cap restrictions for deleting relating to the "ee_deleting_*"
95
-        $this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_event_category'] = new EE_Default_Where_Conditions(
95
+        $this->_cap_restrictions[EEM_Base::caps_delete]['ee_delete_event_category'] = new EE_Default_Where_Conditions(
96 96
             array(
97
-                $path_to_tax_model . 'taxonomy*ee_delete_event_category' => array('!=', 'espresso_event_categories'),
97
+                $path_to_tax_model.'taxonomy*ee_delete_event_category' => array('!=', 'espresso_event_categories'),
98 98
             )
99 99
         );
100
-        $this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_venue_category'] = new EE_Default_Where_Conditions(
100
+        $this->_cap_restrictions[EEM_Base::caps_delete]['ee_delete_venue_category'] = new EE_Default_Where_Conditions(
101 101
             array(
102
-                $path_to_tax_model . 'taxonomy*ee_delete_venue_category' => array('!=', 'espresso_venue_categories'),
102
+                $path_to_tax_model.'taxonomy*ee_delete_venue_category' => array('!=', 'espresso_venue_categories'),
103 103
             )
104 104
         );
105
-        $this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_event_type'] = new EE_Default_Where_Conditions(
105
+        $this->_cap_restrictions[EEM_Base::caps_delete]['ee_delete_event_type'] = new EE_Default_Where_Conditions(
106 106
             array(
107
-                $path_to_tax_model . 'taxonomy*ee_delete_event_type' => array('!=', 'espresso_event_type'),
107
+                $path_to_tax_model.'taxonomy*ee_delete_event_type' => array('!=', 'espresso_event_type'),
108 108
             )
109 109
         );
110 110
         parent::__construct($timezone);
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
     {
127 127
         if ($model === EEM_Term_Taxonomy::instance()) {
128 128
             $taxonomies = get_taxonomies(array('show_in_rest' => true));
129
-            if (! empty($taxonomies)) {
129
+            if ( ! empty($taxonomies)) {
130 130
                 $model_query_params[0]['taxonomy'] = array('IN', $taxonomies);
131 131
             }
132 132
         }
Please login to merge, or discard this patch.
core/db_models/EEM_Currency.model.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
             'Payment_Method'=>new EE_HABTM_Relation('Currency_Payment_Method'),
35 35
         );
36 36
         // this model is generally available for reading
37
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
37
+        $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Public();
38 38
 
39 39
         parent::__construct($timezone);
40 40
     }
@@ -48,8 +48,8 @@  discard block
 block discarded – undo
48 48
     public function get_all_active($query_params = array())
49 49
     {
50 50
         $query_params[0]['CUR_active'] = true;
51
-        if (! isset($query_params['order_by'])) {
52
-            $query_params['order_by'] = array('CUR_code'=>'ASC','CUR_single'=>'ASC');
51
+        if ( ! isset($query_params['order_by'])) {
52
+            $query_params['order_by'] = array('CUR_code'=>'ASC', 'CUR_single'=>'ASC');
53 53
         }
54 54
         return $this->get_all($query_params);
55 55
     }
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
         if ($currencies_supported == EE_Gateway::all_currencies_supported || empty($currencies_supported)) {
70 70
             $currencies = $this->get_all_active();
71 71
         } else {
72
-            $currencies = $this->get_all_active(array(array('CUR_code'=>array('IN',$currencies_supported))));
72
+            $currencies = $this->get_all_active(array(array('CUR_code'=>array('IN', $currencies_supported))));
73 73
         }
74 74
         return $currencies;
75 75
     }
Please login to merge, or discard this patch.
Indentation   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -11,66 +11,66 @@
 block discarded – undo
11 11
  */
12 12
 class EEM_Currency extends EEM_Base
13 13
 {
14
-        // private instance of the Attendee object
15
-    protected static $_instance = null;
14
+		// private instance of the Attendee object
15
+	protected static $_instance = null;
16 16
 
17
-    protected function __construct($timezone = null)
18
-    {
19
-        $this->singular_item = __('Currency', 'event_espresso');
20
-        $this->plural_item = __('Currencies', 'event_espresso');
21
-        $this->_tables = array(
22
-            'Currency'=> new EE_Primary_Table('esp_currency', 'CUR_code')
23
-        );
24
-        $this->_fields = array(
25
-            'Currency'=>array(
26
-                'CUR_code'=> new EE_Primary_Key_String_Field('CUR_code', __('Currency Code', 'event_espresso')),
27
-                'CUR_single' => new EE_Plain_Text_Field('CUR_single', __('Currency Name Singular', 'event_espresso'), false),
28
-                'CUR_plural' => new EE_Plain_Text_Field('CUR_plural', __('Currency Name Plural', 'event_espresso'), false),
29
-                'CUR_sign' => new EE_Plain_Text_Field('CUR_sign', __('Currency Sign', 'event_espresso'), false),
30
-                'CUR_dec_plc' => new EE_Integer_Field('CUR_dec_plc', __('Currency Decimal Places', 'event_espresso'), false, 2),
31
-                'CUR_active'=>new EE_Boolean_Field('CUR_active', __('Active?', 'event_espresso'), false, true),
32
-            ));
33
-        $this->_model_relations = array(
34
-            'Payment_Method'=>new EE_HABTM_Relation('Currency_Payment_Method'),
35
-        );
36
-        // this model is generally available for reading
37
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
17
+	protected function __construct($timezone = null)
18
+	{
19
+		$this->singular_item = __('Currency', 'event_espresso');
20
+		$this->plural_item = __('Currencies', 'event_espresso');
21
+		$this->_tables = array(
22
+			'Currency'=> new EE_Primary_Table('esp_currency', 'CUR_code')
23
+		);
24
+		$this->_fields = array(
25
+			'Currency'=>array(
26
+				'CUR_code'=> new EE_Primary_Key_String_Field('CUR_code', __('Currency Code', 'event_espresso')),
27
+				'CUR_single' => new EE_Plain_Text_Field('CUR_single', __('Currency Name Singular', 'event_espresso'), false),
28
+				'CUR_plural' => new EE_Plain_Text_Field('CUR_plural', __('Currency Name Plural', 'event_espresso'), false),
29
+				'CUR_sign' => new EE_Plain_Text_Field('CUR_sign', __('Currency Sign', 'event_espresso'), false),
30
+				'CUR_dec_plc' => new EE_Integer_Field('CUR_dec_plc', __('Currency Decimal Places', 'event_espresso'), false, 2),
31
+				'CUR_active'=>new EE_Boolean_Field('CUR_active', __('Active?', 'event_espresso'), false, true),
32
+			));
33
+		$this->_model_relations = array(
34
+			'Payment_Method'=>new EE_HABTM_Relation('Currency_Payment_Method'),
35
+		);
36
+		// this model is generally available for reading
37
+		$this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
38 38
 
39
-        parent::__construct($timezone);
40
-    }
39
+		parent::__construct($timezone);
40
+	}
41 41
 
42
-    /**
43
-     * Gets all thea ctive currencies, and orders them by their singular name, and then their code
44
-     * (may be overridden)
45
-     * @param array $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
46
-     * @return EE_Currency[]
47
-     */
48
-    public function get_all_active($query_params = array())
49
-    {
50
-        $query_params[0]['CUR_active'] = true;
51
-        if (! isset($query_params['order_by'])) {
52
-            $query_params['order_by'] = array('CUR_code'=>'ASC','CUR_single'=>'ASC');
53
-        }
54
-        return $this->get_all($query_params);
55
-    }
56
-    /**
57
-     * Gets all the currencies which can be used by that payment method type
58
-     * @param EE_PMT_Base $payment_method_type
59
-     * @return EE_Currency[]
60
-     */
61
-    public function get_all_currencies_usable_by($payment_method_type)
62
-    {
63
-        if ($payment_method_type instanceof EE_PMT_Base &&
64
-                $payment_method_type->get_gateway()) {
65
-            $currencies_supported = $payment_method_type->get_gateway()->currencies_supported();
66
-        } else {
67
-            $currencies_supported = EE_Gateway::all_currencies_supported;
68
-        }
69
-        if ($currencies_supported == EE_Gateway::all_currencies_supported || empty($currencies_supported)) {
70
-            $currencies = $this->get_all_active();
71
-        } else {
72
-            $currencies = $this->get_all_active(array(array('CUR_code'=>array('IN',$currencies_supported))));
73
-        }
74
-        return $currencies;
75
-    }
42
+	/**
43
+	 * Gets all thea ctive currencies, and orders them by their singular name, and then their code
44
+	 * (may be overridden)
45
+	 * @param array $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
46
+	 * @return EE_Currency[]
47
+	 */
48
+	public function get_all_active($query_params = array())
49
+	{
50
+		$query_params[0]['CUR_active'] = true;
51
+		if (! isset($query_params['order_by'])) {
52
+			$query_params['order_by'] = array('CUR_code'=>'ASC','CUR_single'=>'ASC');
53
+		}
54
+		return $this->get_all($query_params);
55
+	}
56
+	/**
57
+	 * Gets all the currencies which can be used by that payment method type
58
+	 * @param EE_PMT_Base $payment_method_type
59
+	 * @return EE_Currency[]
60
+	 */
61
+	public function get_all_currencies_usable_by($payment_method_type)
62
+	{
63
+		if ($payment_method_type instanceof EE_PMT_Base &&
64
+				$payment_method_type->get_gateway()) {
65
+			$currencies_supported = $payment_method_type->get_gateway()->currencies_supported();
66
+		} else {
67
+			$currencies_supported = EE_Gateway::all_currencies_supported;
68
+		}
69
+		if ($currencies_supported == EE_Gateway::all_currencies_supported || empty($currencies_supported)) {
70
+			$currencies = $this->get_all_active();
71
+		} else {
72
+			$currencies = $this->get_all_active(array(array('CUR_code'=>array('IN',$currencies_supported))));
73
+		}
74
+		return $currencies;
75
+	}
76 76
 }
Please login to merge, or discard this patch.
core/db_models/EEM_Currency_Payment_Method.model.php 2 patches
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -11,31 +11,31 @@
 block discarded – undo
11 11
  */
12 12
 class EEM_Currency_Payment_Method extends EEM_Base
13 13
 {
14
-    // private instance of the Attendee object
15
-    protected static $_instance = null;
14
+	// private instance of the Attendee object
15
+	protected static $_instance = null;
16 16
 
17 17
 
18
-    protected function __construct($timezone = null)
19
-    {
20
-        $this->singular_item = __('Currency Usable by Payment Method', 'event_espresso');
21
-        $this->plural_item = __('Currencies Usable by Payment Methods', 'event_espresso');
22
-        $this->_tables = array(
23
-            'Currency_Payment_Method'=>new EE_Primary_Table('esp_currency_payment_method', 'CPM_ID')
24
-        );
25
-        $this->_fields = array(
26
-            'Currency_Payment_Method'=>array(
27
-                'CPM_ID'=>new EE_Primary_Key_Int_Field('CPM_ID', __('Currency to Payment Method LInk ID', 'event_espresso')),
28
-                'CUR_code'=>new EE_Foreign_Key_String_Field('CUR_code', __('Currency Code', 'event_espresso'), false, '', 'Currency'),
29
-                'PMD_ID'=>new EE_Foreign_Key_Int_Field('PMD_ID', __('Paymetn Method ID', 'event_espresso'), false, 0, 'Payment_Method')
30
-            )
31
-        );
32
-        $this->_model_relations = array(
33
-            'Currency'=>new EE_Belongs_To_Relation(),
34
-            'Payment_Method'=>new EE_Belongs_To_Relation()
35
-        );
36
-        // this model is generally available for reading
37
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
38
-        $this->_caps_slug = 'payment_methods';
39
-        parent::__construct($timezone);
40
-    }
18
+	protected function __construct($timezone = null)
19
+	{
20
+		$this->singular_item = __('Currency Usable by Payment Method', 'event_espresso');
21
+		$this->plural_item = __('Currencies Usable by Payment Methods', 'event_espresso');
22
+		$this->_tables = array(
23
+			'Currency_Payment_Method'=>new EE_Primary_Table('esp_currency_payment_method', 'CPM_ID')
24
+		);
25
+		$this->_fields = array(
26
+			'Currency_Payment_Method'=>array(
27
+				'CPM_ID'=>new EE_Primary_Key_Int_Field('CPM_ID', __('Currency to Payment Method LInk ID', 'event_espresso')),
28
+				'CUR_code'=>new EE_Foreign_Key_String_Field('CUR_code', __('Currency Code', 'event_espresso'), false, '', 'Currency'),
29
+				'PMD_ID'=>new EE_Foreign_Key_Int_Field('PMD_ID', __('Paymetn Method ID', 'event_espresso'), false, 0, 'Payment_Method')
30
+			)
31
+		);
32
+		$this->_model_relations = array(
33
+			'Currency'=>new EE_Belongs_To_Relation(),
34
+			'Payment_Method'=>new EE_Belongs_To_Relation()
35
+		);
36
+		// this model is generally available for reading
37
+		$this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
38
+		$this->_caps_slug = 'payment_methods';
39
+		parent::__construct($timezone);
40
+	}
41 41
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@
 block discarded – undo
34 34
             'Payment_Method'=>new EE_Belongs_To_Relation()
35 35
         );
36 36
         // this model is generally available for reading
37
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
37
+        $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Public();
38 38
         $this->_caps_slug = 'payment_methods';
39 39
         parent::__construct($timezone);
40 40
     }
Please login to merge, or discard this patch.
core/db_models/EEM_Price.model.php 2 patches
Indentation   +275 added lines, -275 removed lines patch added patch discarded remove patch
@@ -10,279 +10,279 @@
 block discarded – undo
10 10
 class EEM_Price extends EEM_Soft_Delete_Base
11 11
 {
12 12
 
13
-    // private instance of the EEM_Price object
14
-    protected static $_instance = null;
15
-
16
-
17
-
18
-    /**
19
-     *      private constructor to prevent direct creation
20
-     *      @Constructor
21
-     *      @access protected
22
-     *      @param string $timezone string representing the timezone we want to set for returned Date Time Strings (and any incoming timezone data that gets saved).  Note this just sends the timezone info to the date time model field objects.  Default is NULL (and will be assumed using the set timezone in the 'timezone_string' wp option)
23
-     *      @return EEM_Price
24
-     */
25
-    protected function __construct($timezone)
26
-    {
27
-        require_once(EE_MODELS . 'EEM_Price_Type.model.php');
28
-        $this->singular_item = __('Price', 'event_espresso');
29
-        $this->plural_item = __('Prices', 'event_espresso');
30
-
31
-        $this->_tables = array(
32
-            'Price'=>new EE_Primary_Table('esp_price', 'PRC_ID')
33
-        );
34
-        $this->_fields = array(
35
-            'Price'=> array(
36
-                'PRC_ID'=>new EE_Primary_Key_Int_Field('PRC_ID', 'Price ID'),
37
-                'PRT_ID'=>new EE_Foreign_Key_Int_Field('PRT_ID', 'Price type Id', false, null, 'Price_Type'),
38
-                'PRC_amount'=>new EE_Money_Field('PRC_amount', 'Price Amount', false, 0),
39
-                'PRC_name'=>new EE_Plain_Text_Field('PRC_name', 'Name of Price', false, ''),
40
-                'PRC_desc'=>new EE_Post_Content_Field('PRC_desc', 'Price Description', false, ''),
41
-                'PRC_is_default'=>new EE_Boolean_Field('PRC_is_default', 'Flag indicating whether price is a default price', false, false),
42
-                'PRC_overrides'=>new EE_Integer_Field('PRC_overrides', 'Price ID for a global Price that will be overridden by this Price  ( for replacing default prices )', true, 0),
43
-                'PRC_order'=>new EE_Integer_Field('PRC_order', 'Order of Application of Price (lower numbers apply first?)', false, 1),
44
-                'PRC_deleted'=>new EE_Trashed_Flag_Field('PRC_deleted', 'Flag Indicating if this has been deleted or not', false, false),
45
-                'PRC_parent' => new EE_Integer_Field('PRC_parent', __('Indicates what PRC_ID is the parent of this PRC_ID', 'event_espresso'), true, 0),
46
-                'PRC_wp_user' => new EE_WP_User_Field('PRC_wp_user', __('Price Creator ID', 'event_espresso'), false),
47
-            )
48
-        );
49
-        $this->_model_relations = array(
50
-            'Ticket'=>new EE_HABTM_Relation('Ticket_Price'),
51
-            'Price_Type'=>new EE_Belongs_To_Relation(),
52
-            'WP_User' => new EE_Belongs_To_Relation(),
53
-        );
54
-        // this model is generally available for reading
55
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Default_Public('PRC_is_default', 'Ticket.Datetime.Event');
56
-        // account for default tickets in the caps
57
-        $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Default_Protected('PRC_is_default', 'Ticket.Datetime.Event');
58
-        $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Default_Protected('PRC_is_default', 'Ticket.Datetime.Event');
59
-        $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Default_Protected('PRC_is_default', 'Ticket.Datetime.Event');
60
-        parent::__construct($timezone);
61
-    }
62
-
63
-
64
-
65
-    /**
66
-     *      instantiate a new price object with blank/empty properties
67
-     *
68
-     *      @access     public
69
-     *      @return     mixed       array on success, FALSE on fail
70
-     */
71
-    public function get_new_price()
72
-    {
73
-        return $this->create_default_object();
74
-    }
75
-
76
-
77
-
78
-
79
-
80
-    /**
81
-     *      retrieve  ALL prices from db
82
-     *
83
-     *      @access     public
84
-     *      @return     EE_PRice[]
85
-     */
86
-    public function get_all_prices()
87
-    {
88
-        // retrieve all prices
89
-        return $this->get_all(array('order_by'=>array('PRC_amount'=>'ASC')));
90
-    }
91
-
92
-
93
-
94
-    /**
95
-     *        retrieve all active prices for a particular event
96
-     *
97
-     * @access        public
98
-     * @param int $EVT_ID
99
-     * @return array on success
100
-     */
101
-    public function get_all_event_prices($EVT_ID = 0)
102
-    {
103
-        return $this->get_all(array(
104
-            array(
105
-                'EVT_ID'=>$EVT_ID,
106
-                'Price_Type.PBT_ID'=>array('!=',  EEM_Price_Type::base_type_tax)
107
-            ),
108
-            'order_by'=>$this->_order_by_array_for_get_all_method()
109
-        ));
110
-    }
111
-
112
-
113
-    /**
114
-     *      retrieve all active global prices (that are not taxes (PBT_ID=4)) for a particular event
115
-     *
116
-     *      @access     public
117
-     *      @param      boolean         $count  return count
118
-     *      @return         array           on success
119
-     *      @return         boolean     false on fail
120
-     */
121
-    public function get_all_default_prices($count = false)
122
-    {
123
-        $_where = array(
124
-            'Price_Type.PBT_ID'=>array('!=',4),
125
-            'PRC_deleted' => 0,
126
-            'PRC_is_default' => 1
127
-        );
128
-        $_query_params = array(
129
-            $_where,
130
-            'order_by'=>$this->_order_by_array_for_get_all_method()
131
-        );
132
-        return $count ? $this->count(array($_where)) : $this->get_all($_query_params);
133
-    }
134
-
135
-
136
-
137
-
138
-
139
-
140
-
141
-
142
-
143
-
144
-    /**
145
-     *      retrieve all prices that are taxes
146
-     *
147
-     *      @access     public
148
-     *      @return         array               on success
149
-     *      @return         array top-level keys are the price's order and their values are an array,
150
-     *                      next-level keys are the price's ID, and their values are EE_Price objects
151
-     */
152
-    public function get_all_prices_that_are_taxes()
153
-    {
154
-        $taxes = array();
155
-        $all_taxes = $this->get_all(array(
156
-            array( 'Price_Type.PBT_ID'=>  EEM_Price_Type::base_type_tax ),
157
-            'order_by' => array( 'Price_Type.PRT_order' => 'ASC', 'PRC_order' => 'ASC' )
158
-        ));
159
-        foreach ($all_taxes as $tax) {
160
-            if ($tax instanceof EE_Price) {
161
-                $taxes[ $tax->order() ][ $tax->ID() ] = $tax;
162
-            }
163
-        }
164
-        return $taxes;
165
-    }
166
-
167
-
168
-
169
-
170
-
171
-    /**
172
-     *      retrieve all prices for an ticket plus default global prices, but not taxes
173
-     *
174
-     *      @access     public
175
-     *      @param int $TKT_ID          the id of the event.  If not included then we assume that this is a new ticket.
176
-     *      @return         boolean         false on fail
177
-     */
178
-    public function get_all_ticket_prices_for_admin($TKT_ID = 0)
179
-    {
180
-        $array_of_price_objects = array();
181
-        if (empty($TKT_ID)) {
182
-            // if there is no tkt, get prices with no tkt ID, are global, are not a tax, and are active
183
-            // return that list
184
-            $default_prices = $this->get_all_default_prices();
185
-
186
-            if ($default_prices) {
187
-                foreach ($default_prices as $price) {
188
-                    if ($price instanceof EE_Price) {
189
-                        $array_of_price_objects[ $price->type() ][] = $price;
190
-                    }
191
-                }
192
-                return $array_of_price_objects;
193
-            } else {
194
-                return array();
195
-            }
196
-        } else {
197
-            $ticket_prices = $this->get_all(array(
198
-                array(
199
-                    'TKT_ID'=>$TKT_ID,
200
-                    'PRC_deleted' => 0
201
-                    ),
202
-                'order_by'=> array('PRC_order' => 'ASC')
203
-            ));
204
-        }
205
-
206
-        if (!empty($ticket_prices)) {
207
-            foreach ($ticket_prices as $price) {
208
-                if ($price instanceof EE_Price) {
209
-                    $array_of_price_objects[ $price->type() ][] = $price;
210
-                }
211
-            }
212
-            return $array_of_price_objects;
213
-        } else {
214
-            return false;
215
-        }
216
-    }
217
-
218
-
219
-
220
-    /**
221
-     *        _sort_event_prices_by_type
222
-     *
223
-     * @access public
224
-     * @param \EE_Price $price_a
225
-     * @param \EE_Price $price_b
226
-     * @return bool false on fail
227
-     */
228
-    public function _sort_event_prices_by_type(EE_Price $price_a, EE_Price $price_b)
229
-    {
230
-        if ($price_a->type_obj()->order() == $price_b->type_obj()->order()) {
231
-            return $this->_sort_event_prices_by_order($price_a, $price_b);
232
-        }
233
-        return $price_a->type_obj()->order() < $price_b->type_obj()->order() ? -1 : 1;
234
-    }
235
-
236
-
237
-
238
-    /**
239
-     *        _sort_event_prices_by_order
240
-     *
241
-     * @access public
242
-     * @param \EE_Price $price_a
243
-     * @param \EE_Price $price_b
244
-     * @return bool false on fail
245
-     */
246
-    public function _sort_event_prices_by_order(EE_Price $price_a, EE_Price $price_b)
247
-    {
248
-        if ($price_a->order() == $price_b->order()) {
249
-            return 0;
250
-        }
251
-        return $price_a->order() < $price_b->order() ? -1 : 1;
252
-    }
253
-
254
-
255
-
256
-    /**
257
-     *      get all prices of a specific type
258
-     *
259
-     *      @access     public
260
-     *      @param      int                 $type - PRT_ID
261
-     *      @return         boolean     false on fail
262
-     */
263
-    public function get_all_prices_that_are_type($type = 0)
264
-    {
265
-        return $this->get_all(array(
266
-            array(
267
-                'PRT_ID'=>$type
268
-            ),
269
-            'order_by'=>$this->_order_by_array_for_get_all_method()
270
-        ));
271
-    }
272
-
273
-
274
-
275
-    /**
276
-     * Returns an array of the normal 'order_by' query parameter provided to the get_all query.
277
-     * Of course you don't have to use it, but this is the order we usually want to sort prices by
278
-     * @return array which can be used like so: $this->get_all(array(array(...where stuff...),'order_by'=>$this->_order_by_array_for_get_all_method()));
279
-     */
280
-    public function _order_by_array_for_get_all_method()
281
-    {
282
-        return array(
283
-                'PRC_order'=>'ASC',
284
-                'Price_Type.PRT_order'=>'ASC',
285
-                'PRC_ID'=>'ASC'
286
-        );
287
-    }
13
+	// private instance of the EEM_Price object
14
+	protected static $_instance = null;
15
+
16
+
17
+
18
+	/**
19
+	 *      private constructor to prevent direct creation
20
+	 *      @Constructor
21
+	 *      @access protected
22
+	 *      @param string $timezone string representing the timezone we want to set for returned Date Time Strings (and any incoming timezone data that gets saved).  Note this just sends the timezone info to the date time model field objects.  Default is NULL (and will be assumed using the set timezone in the 'timezone_string' wp option)
23
+	 *      @return EEM_Price
24
+	 */
25
+	protected function __construct($timezone)
26
+	{
27
+		require_once(EE_MODELS . 'EEM_Price_Type.model.php');
28
+		$this->singular_item = __('Price', 'event_espresso');
29
+		$this->plural_item = __('Prices', 'event_espresso');
30
+
31
+		$this->_tables = array(
32
+			'Price'=>new EE_Primary_Table('esp_price', 'PRC_ID')
33
+		);
34
+		$this->_fields = array(
35
+			'Price'=> array(
36
+				'PRC_ID'=>new EE_Primary_Key_Int_Field('PRC_ID', 'Price ID'),
37
+				'PRT_ID'=>new EE_Foreign_Key_Int_Field('PRT_ID', 'Price type Id', false, null, 'Price_Type'),
38
+				'PRC_amount'=>new EE_Money_Field('PRC_amount', 'Price Amount', false, 0),
39
+				'PRC_name'=>new EE_Plain_Text_Field('PRC_name', 'Name of Price', false, ''),
40
+				'PRC_desc'=>new EE_Post_Content_Field('PRC_desc', 'Price Description', false, ''),
41
+				'PRC_is_default'=>new EE_Boolean_Field('PRC_is_default', 'Flag indicating whether price is a default price', false, false),
42
+				'PRC_overrides'=>new EE_Integer_Field('PRC_overrides', 'Price ID for a global Price that will be overridden by this Price  ( for replacing default prices )', true, 0),
43
+				'PRC_order'=>new EE_Integer_Field('PRC_order', 'Order of Application of Price (lower numbers apply first?)', false, 1),
44
+				'PRC_deleted'=>new EE_Trashed_Flag_Field('PRC_deleted', 'Flag Indicating if this has been deleted or not', false, false),
45
+				'PRC_parent' => new EE_Integer_Field('PRC_parent', __('Indicates what PRC_ID is the parent of this PRC_ID', 'event_espresso'), true, 0),
46
+				'PRC_wp_user' => new EE_WP_User_Field('PRC_wp_user', __('Price Creator ID', 'event_espresso'), false),
47
+			)
48
+		);
49
+		$this->_model_relations = array(
50
+			'Ticket'=>new EE_HABTM_Relation('Ticket_Price'),
51
+			'Price_Type'=>new EE_Belongs_To_Relation(),
52
+			'WP_User' => new EE_Belongs_To_Relation(),
53
+		);
54
+		// this model is generally available for reading
55
+		$this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Default_Public('PRC_is_default', 'Ticket.Datetime.Event');
56
+		// account for default tickets in the caps
57
+		$this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Default_Protected('PRC_is_default', 'Ticket.Datetime.Event');
58
+		$this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Default_Protected('PRC_is_default', 'Ticket.Datetime.Event');
59
+		$this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Default_Protected('PRC_is_default', 'Ticket.Datetime.Event');
60
+		parent::__construct($timezone);
61
+	}
62
+
63
+
64
+
65
+	/**
66
+	 *      instantiate a new price object with blank/empty properties
67
+	 *
68
+	 *      @access     public
69
+	 *      @return     mixed       array on success, FALSE on fail
70
+	 */
71
+	public function get_new_price()
72
+	{
73
+		return $this->create_default_object();
74
+	}
75
+
76
+
77
+
78
+
79
+
80
+	/**
81
+	 *      retrieve  ALL prices from db
82
+	 *
83
+	 *      @access     public
84
+	 *      @return     EE_PRice[]
85
+	 */
86
+	public function get_all_prices()
87
+	{
88
+		// retrieve all prices
89
+		return $this->get_all(array('order_by'=>array('PRC_amount'=>'ASC')));
90
+	}
91
+
92
+
93
+
94
+	/**
95
+	 *        retrieve all active prices for a particular event
96
+	 *
97
+	 * @access        public
98
+	 * @param int $EVT_ID
99
+	 * @return array on success
100
+	 */
101
+	public function get_all_event_prices($EVT_ID = 0)
102
+	{
103
+		return $this->get_all(array(
104
+			array(
105
+				'EVT_ID'=>$EVT_ID,
106
+				'Price_Type.PBT_ID'=>array('!=',  EEM_Price_Type::base_type_tax)
107
+			),
108
+			'order_by'=>$this->_order_by_array_for_get_all_method()
109
+		));
110
+	}
111
+
112
+
113
+	/**
114
+	 *      retrieve all active global prices (that are not taxes (PBT_ID=4)) for a particular event
115
+	 *
116
+	 *      @access     public
117
+	 *      @param      boolean         $count  return count
118
+	 *      @return         array           on success
119
+	 *      @return         boolean     false on fail
120
+	 */
121
+	public function get_all_default_prices($count = false)
122
+	{
123
+		$_where = array(
124
+			'Price_Type.PBT_ID'=>array('!=',4),
125
+			'PRC_deleted' => 0,
126
+			'PRC_is_default' => 1
127
+		);
128
+		$_query_params = array(
129
+			$_where,
130
+			'order_by'=>$this->_order_by_array_for_get_all_method()
131
+		);
132
+		return $count ? $this->count(array($_where)) : $this->get_all($_query_params);
133
+	}
134
+
135
+
136
+
137
+
138
+
139
+
140
+
141
+
142
+
143
+
144
+	/**
145
+	 *      retrieve all prices that are taxes
146
+	 *
147
+	 *      @access     public
148
+	 *      @return         array               on success
149
+	 *      @return         array top-level keys are the price's order and their values are an array,
150
+	 *                      next-level keys are the price's ID, and their values are EE_Price objects
151
+	 */
152
+	public function get_all_prices_that_are_taxes()
153
+	{
154
+		$taxes = array();
155
+		$all_taxes = $this->get_all(array(
156
+			array( 'Price_Type.PBT_ID'=>  EEM_Price_Type::base_type_tax ),
157
+			'order_by' => array( 'Price_Type.PRT_order' => 'ASC', 'PRC_order' => 'ASC' )
158
+		));
159
+		foreach ($all_taxes as $tax) {
160
+			if ($tax instanceof EE_Price) {
161
+				$taxes[ $tax->order() ][ $tax->ID() ] = $tax;
162
+			}
163
+		}
164
+		return $taxes;
165
+	}
166
+
167
+
168
+
169
+
170
+
171
+	/**
172
+	 *      retrieve all prices for an ticket plus default global prices, but not taxes
173
+	 *
174
+	 *      @access     public
175
+	 *      @param int $TKT_ID          the id of the event.  If not included then we assume that this is a new ticket.
176
+	 *      @return         boolean         false on fail
177
+	 */
178
+	public function get_all_ticket_prices_for_admin($TKT_ID = 0)
179
+	{
180
+		$array_of_price_objects = array();
181
+		if (empty($TKT_ID)) {
182
+			// if there is no tkt, get prices with no tkt ID, are global, are not a tax, and are active
183
+			// return that list
184
+			$default_prices = $this->get_all_default_prices();
185
+
186
+			if ($default_prices) {
187
+				foreach ($default_prices as $price) {
188
+					if ($price instanceof EE_Price) {
189
+						$array_of_price_objects[ $price->type() ][] = $price;
190
+					}
191
+				}
192
+				return $array_of_price_objects;
193
+			} else {
194
+				return array();
195
+			}
196
+		} else {
197
+			$ticket_prices = $this->get_all(array(
198
+				array(
199
+					'TKT_ID'=>$TKT_ID,
200
+					'PRC_deleted' => 0
201
+					),
202
+				'order_by'=> array('PRC_order' => 'ASC')
203
+			));
204
+		}
205
+
206
+		if (!empty($ticket_prices)) {
207
+			foreach ($ticket_prices as $price) {
208
+				if ($price instanceof EE_Price) {
209
+					$array_of_price_objects[ $price->type() ][] = $price;
210
+				}
211
+			}
212
+			return $array_of_price_objects;
213
+		} else {
214
+			return false;
215
+		}
216
+	}
217
+
218
+
219
+
220
+	/**
221
+	 *        _sort_event_prices_by_type
222
+	 *
223
+	 * @access public
224
+	 * @param \EE_Price $price_a
225
+	 * @param \EE_Price $price_b
226
+	 * @return bool false on fail
227
+	 */
228
+	public function _sort_event_prices_by_type(EE_Price $price_a, EE_Price $price_b)
229
+	{
230
+		if ($price_a->type_obj()->order() == $price_b->type_obj()->order()) {
231
+			return $this->_sort_event_prices_by_order($price_a, $price_b);
232
+		}
233
+		return $price_a->type_obj()->order() < $price_b->type_obj()->order() ? -1 : 1;
234
+	}
235
+
236
+
237
+
238
+	/**
239
+	 *        _sort_event_prices_by_order
240
+	 *
241
+	 * @access public
242
+	 * @param \EE_Price $price_a
243
+	 * @param \EE_Price $price_b
244
+	 * @return bool false on fail
245
+	 */
246
+	public function _sort_event_prices_by_order(EE_Price $price_a, EE_Price $price_b)
247
+	{
248
+		if ($price_a->order() == $price_b->order()) {
249
+			return 0;
250
+		}
251
+		return $price_a->order() < $price_b->order() ? -1 : 1;
252
+	}
253
+
254
+
255
+
256
+	/**
257
+	 *      get all prices of a specific type
258
+	 *
259
+	 *      @access     public
260
+	 *      @param      int                 $type - PRT_ID
261
+	 *      @return         boolean     false on fail
262
+	 */
263
+	public function get_all_prices_that_are_type($type = 0)
264
+	{
265
+		return $this->get_all(array(
266
+			array(
267
+				'PRT_ID'=>$type
268
+			),
269
+			'order_by'=>$this->_order_by_array_for_get_all_method()
270
+		));
271
+	}
272
+
273
+
274
+
275
+	/**
276
+	 * Returns an array of the normal 'order_by' query parameter provided to the get_all query.
277
+	 * Of course you don't have to use it, but this is the order we usually want to sort prices by
278
+	 * @return array which can be used like so: $this->get_all(array(array(...where stuff...),'order_by'=>$this->_order_by_array_for_get_all_method()));
279
+	 */
280
+	public function _order_by_array_for_get_all_method()
281
+	{
282
+		return array(
283
+				'PRC_order'=>'ASC',
284
+				'Price_Type.PRT_order'=>'ASC',
285
+				'PRC_ID'=>'ASC'
286
+		);
287
+	}
288 288
 }
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
      */
25 25
     protected function __construct($timezone)
26 26
     {
27
-        require_once(EE_MODELS . 'EEM_Price_Type.model.php');
27
+        require_once(EE_MODELS.'EEM_Price_Type.model.php');
28 28
         $this->singular_item = __('Price', 'event_espresso');
29 29
         $this->plural_item = __('Prices', 'event_espresso');
30 30
 
@@ -52,11 +52,11 @@  discard block
 block discarded – undo
52 52
             'WP_User' => new EE_Belongs_To_Relation(),
53 53
         );
54 54
         // this model is generally available for reading
55
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Default_Public('PRC_is_default', 'Ticket.Datetime.Event');
55
+        $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Default_Public('PRC_is_default', 'Ticket.Datetime.Event');
56 56
         // account for default tickets in the caps
57
-        $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Default_Protected('PRC_is_default', 'Ticket.Datetime.Event');
58
-        $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Default_Protected('PRC_is_default', 'Ticket.Datetime.Event');
59
-        $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Default_Protected('PRC_is_default', 'Ticket.Datetime.Event');
57
+        $this->_cap_restriction_generators[EEM_Base::caps_read_admin] = new EE_Restriction_Generator_Default_Protected('PRC_is_default', 'Ticket.Datetime.Event');
58
+        $this->_cap_restriction_generators[EEM_Base::caps_edit] = new EE_Restriction_Generator_Default_Protected('PRC_is_default', 'Ticket.Datetime.Event');
59
+        $this->_cap_restriction_generators[EEM_Base::caps_delete] = new EE_Restriction_Generator_Default_Protected('PRC_is_default', 'Ticket.Datetime.Event');
60 60
         parent::__construct($timezone);
61 61
     }
62 62
 
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
         return $this->get_all(array(
104 104
             array(
105 105
                 'EVT_ID'=>$EVT_ID,
106
-                'Price_Type.PBT_ID'=>array('!=',  EEM_Price_Type::base_type_tax)
106
+                'Price_Type.PBT_ID'=>array('!=', EEM_Price_Type::base_type_tax)
107 107
             ),
108 108
             'order_by'=>$this->_order_by_array_for_get_all_method()
109 109
         ));
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
     public function get_all_default_prices($count = false)
122 122
     {
123 123
         $_where = array(
124
-            'Price_Type.PBT_ID'=>array('!=',4),
124
+            'Price_Type.PBT_ID'=>array('!=', 4),
125 125
             'PRC_deleted' => 0,
126 126
             'PRC_is_default' => 1
127 127
         );
@@ -153,12 +153,12 @@  discard block
 block discarded – undo
153 153
     {
154 154
         $taxes = array();
155 155
         $all_taxes = $this->get_all(array(
156
-            array( 'Price_Type.PBT_ID'=>  EEM_Price_Type::base_type_tax ),
157
-            'order_by' => array( 'Price_Type.PRT_order' => 'ASC', 'PRC_order' => 'ASC' )
156
+            array('Price_Type.PBT_ID'=>  EEM_Price_Type::base_type_tax),
157
+            'order_by' => array('Price_Type.PRT_order' => 'ASC', 'PRC_order' => 'ASC')
158 158
         ));
159 159
         foreach ($all_taxes as $tax) {
160 160
             if ($tax instanceof EE_Price) {
161
-                $taxes[ $tax->order() ][ $tax->ID() ] = $tax;
161
+                $taxes[$tax->order()][$tax->ID()] = $tax;
162 162
             }
163 163
         }
164 164
         return $taxes;
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
             if ($default_prices) {
187 187
                 foreach ($default_prices as $price) {
188 188
                     if ($price instanceof EE_Price) {
189
-                        $array_of_price_objects[ $price->type() ][] = $price;
189
+                        $array_of_price_objects[$price->type()][] = $price;
190 190
                     }
191 191
                 }
192 192
                 return $array_of_price_objects;
@@ -203,10 +203,10 @@  discard block
 block discarded – undo
203 203
             ));
204 204
         }
205 205
 
206
-        if (!empty($ticket_prices)) {
206
+        if ( ! empty($ticket_prices)) {
207 207
             foreach ($ticket_prices as $price) {
208 208
                 if ($price instanceof EE_Price) {
209
-                    $array_of_price_objects[ $price->type() ][] = $price;
209
+                    $array_of_price_objects[$price->type()][] = $price;
210 210
                 }
211 211
             }
212 212
             return $array_of_price_objects;
Please login to merge, or discard this patch.
core/db_models/EEM_Change_Log.model.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -113,17 +113,17 @@  discard block
 block discarded – undo
113 113
                 ),
114 114
             ),
115 115
         );
116
-        $this->_model_relations    = array();
116
+        $this->_model_relations = array();
117 117
         foreach ($models_this_can_attach_to as $model) {
118 118
             if ($model != 'Change_Log') {
119
-                $this->_model_relations[ $model ] = new EE_Belongs_To_Any_Relation();
119
+                $this->_model_relations[$model] = new EE_Belongs_To_Any_Relation();
120 120
             }
121 121
         }
122 122
         // use completely custom caps for this
123 123
         $this->_cap_restriction_generators = false;
124 124
         // caps-wise this is all-or-nothing: if you have the default role you can access anything, otherwise nothing
125 125
         foreach ($this->_cap_contexts_to_cap_action_map as $cap_context => $action) {
126
-            $this->_cap_restrictions[ $cap_context ][ EE_Restriction_Generator_Base::get_default_restrictions_cap() ]
126
+            $this->_cap_restrictions[$cap_context][EE_Restriction_Generator_Base::get_default_restrictions_cap()]
127 127
                 = new EE_Return_None_Where_Conditions();
128 128
         }
129 129
         parent::__construct($timezone);
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
      */
169 169
     public function gateway_log($message, $related_obj_id, $related_obj_type)
170 170
     {
171
-        if (! EE_Registry::instance()->is_model_name($related_obj_type)) {
171
+        if ( ! EE_Registry::instance()->is_model_name($related_obj_type)) {
172 172
             throw new EE_Error(
173 173
                 sprintf(
174 174
                     esc_html__(
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
         global $wpdb;
218 218
         return $wpdb->query(
219 219
             $wpdb->prepare(
220
-                'DELETE FROM ' . $this->table() . ' WHERE LOG_type = %s AND LOG_time < %s',
220
+                'DELETE FROM '.$this->table().' WHERE LOG_type = %s AND LOG_time < %s',
221 221
                 EEM_Change_Log::type_gateway,
222 222
                 $datetime->format(EE_Datetime_Field::mysql_timestamp_format)
223 223
             )
@@ -256,8 +256,8 @@  discard block
 block discarded – undo
256 256
     {
257 257
         $type_identifier_map = self::get_pretty_label_map_for_registered_types();
258 258
         // we fallback to the incoming type identifier if there is no localized label for it.
259
-        return isset($type_identifier_map[ $type_identifier ])
260
-            ? $type_identifier_map[ $type_identifier ]
259
+        return isset($type_identifier_map[$type_identifier])
260
+            ? $type_identifier_map[$type_identifier]
261 261
             : $type_identifier;
262 262
     }
263 263
 }
Please login to merge, or discard this patch.
Indentation   +227 added lines, -227 removed lines patch added patch discarded remove patch
@@ -11,93 +11,93 @@  discard block
 block discarded – undo
11 11
 class EEM_Change_Log extends EEM_Base
12 12
 {
13 13
 
14
-    /**
15
-     * the related object was created log type
16
-     */
17
-    const type_create = 'create';
18
-    /**
19
-     * the related object was updated (changed, or soft-deleted)
20
-     */
21
-    const type_update = 'update';
22
-    /**
23
-     * the related object was deleted permanently
24
-     */
25
-    const type_delete = 'delete';
26
-    /**
27
-     * the related item had something worth noting happen on it, but
28
-     * only for the purposes of debugging problems
29
-     */
30
-    const type_debug = 'debug';
31
-    /**
32
-     * the related item had an error occur on it
33
-     */
34
-    const type_error = 'error';
35
-    /**
36
-     * the related item is regarding some gateway interaction, like an IPN
37
-     * or request to process a payment
38
-     */
39
-    const type_gateway = 'gateway';
14
+	/**
15
+	 * the related object was created log type
16
+	 */
17
+	const type_create = 'create';
18
+	/**
19
+	 * the related object was updated (changed, or soft-deleted)
20
+	 */
21
+	const type_update = 'update';
22
+	/**
23
+	 * the related object was deleted permanently
24
+	 */
25
+	const type_delete = 'delete';
26
+	/**
27
+	 * the related item had something worth noting happen on it, but
28
+	 * only for the purposes of debugging problems
29
+	 */
30
+	const type_debug = 'debug';
31
+	/**
32
+	 * the related item had an error occur on it
33
+	 */
34
+	const type_error = 'error';
35
+	/**
36
+	 * the related item is regarding some gateway interaction, like an IPN
37
+	 * or request to process a payment
38
+	 */
39
+	const type_gateway = 'gateway';
40 40
 
41
-    /**
42
-     * private instance of the EEM_Change_Log object
43
-     *
44
-     * @access private
45
-     * @var EEM_Change_Log $_instance
46
-     */
47
-    protected static $_instance = null;
41
+	/**
42
+	 * private instance of the EEM_Change_Log object
43
+	 *
44
+	 * @access private
45
+	 * @var EEM_Change_Log $_instance
46
+	 */
47
+	protected static $_instance = null;
48 48
 
49 49
 
50
-    /**
51
-     * constructor
52
-     *
53
-     * @access protected
54
-     * @param null $timezone
55
-     * @throws EE_Error
56
-     */
57
-    protected function __construct($timezone = null)
58
-    {
59
-        global $current_user;
60
-        $this->singular_item       = esc_html__('Log', 'event_espresso');
61
-        $this->plural_item         = esc_html__('Logs', 'event_espresso');
62
-        $this->_tables             = array(
63
-            'Log' => new EE_Primary_Table('esp_log', 'LOG_ID'),
64
-        );
65
-        $models_this_can_attach_to = array_keys(EE_Registry::instance()->non_abstract_db_models);
66
-        $this->_fields             = array(
67
-            'Log' => array(
68
-                'LOG_ID'      => new EE_Primary_Key_Int_Field('LOG_ID', esc_html__('Log ID', 'event_espresso')),
69
-                'LOG_time'    => new EE_Datetime_Field(
70
-                    'LOG_time',
71
-                    esc_html__("Log Time", 'event_espresso'),
72
-                    false,
73
-                    EE_Datetime_Field::now
74
-                ),
75
-                'OBJ_ID'      => new EE_Foreign_Key_String_Field(
76
-                    'OBJ_ID',
77
-                    esc_html__("Object ID (int or string)", 'event_espresso'),
78
-                    true,
79
-                    null,
80
-                    $models_this_can_attach_to
81
-                ),
82
-                'OBJ_type'    => new EE_Any_Foreign_Model_Name_Field(
83
-                    'OBJ_type',
84
-                    esc_html__("Object Type", 'event_espresso'),
85
-                    true,
86
-                    null,
87
-                    $models_this_can_attach_to
88
-                ),
89
-                'LOG_type'    => new EE_Plain_Text_Field(
90
-                    'LOG_type',
91
-                    esc_html__("Type of log entry", "event_espresso"),
92
-                    false,
93
-                    self::type_debug
94
-                ),
95
-                'LOG_message' => new EE_Maybe_Serialized_Text_Field(
96
-                    'LOG_message',
97
-                    esc_html__("Log Message (body)", 'event_espresso'),
98
-                    true
99
-                ),
100
-                /*
50
+	/**
51
+	 * constructor
52
+	 *
53
+	 * @access protected
54
+	 * @param null $timezone
55
+	 * @throws EE_Error
56
+	 */
57
+	protected function __construct($timezone = null)
58
+	{
59
+		global $current_user;
60
+		$this->singular_item       = esc_html__('Log', 'event_espresso');
61
+		$this->plural_item         = esc_html__('Logs', 'event_espresso');
62
+		$this->_tables             = array(
63
+			'Log' => new EE_Primary_Table('esp_log', 'LOG_ID'),
64
+		);
65
+		$models_this_can_attach_to = array_keys(EE_Registry::instance()->non_abstract_db_models);
66
+		$this->_fields             = array(
67
+			'Log' => array(
68
+				'LOG_ID'      => new EE_Primary_Key_Int_Field('LOG_ID', esc_html__('Log ID', 'event_espresso')),
69
+				'LOG_time'    => new EE_Datetime_Field(
70
+					'LOG_time',
71
+					esc_html__("Log Time", 'event_espresso'),
72
+					false,
73
+					EE_Datetime_Field::now
74
+				),
75
+				'OBJ_ID'      => new EE_Foreign_Key_String_Field(
76
+					'OBJ_ID',
77
+					esc_html__("Object ID (int or string)", 'event_espresso'),
78
+					true,
79
+					null,
80
+					$models_this_can_attach_to
81
+				),
82
+				'OBJ_type'    => new EE_Any_Foreign_Model_Name_Field(
83
+					'OBJ_type',
84
+					esc_html__("Object Type", 'event_espresso'),
85
+					true,
86
+					null,
87
+					$models_this_can_attach_to
88
+				),
89
+				'LOG_type'    => new EE_Plain_Text_Field(
90
+					'LOG_type',
91
+					esc_html__("Type of log entry", "event_espresso"),
92
+					false,
93
+					self::type_debug
94
+				),
95
+				'LOG_message' => new EE_Maybe_Serialized_Text_Field(
96
+					'LOG_message',
97
+					esc_html__("Log Message (body)", 'event_espresso'),
98
+					true
99
+				),
100
+				/*
101 101
                  * Note: when querying for a change log's user, the OBJ_ID and OBJ_type fields are used,
102 102
                  * not the LOG_wp_user field. E.g.,
103 103
                  * `EEM_Change_Log::instance()->get_all(array(array('WP_User.ID'=>1)))` will actually return
@@ -106,158 +106,158 @@  discard block
 block discarded – undo
106 106
                  *  If you want the latter, you can't use the model's magic joining. E.g, you would need to do
107 107
                  * `EEM_Change_Log::instance()->get_all(array(array('LOG_wp_user' => 1)))`.
108 108
                  */
109
-                'LOG_wp_user' => new EE_WP_User_Field(
110
-                    'LOG_wp_user',
111
-                    esc_html__("User who was logged in while this occurred", 'event_espresso'),
112
-                    true
113
-                ),
114
-            ),
115
-        );
116
-        $this->_model_relations    = array();
117
-        foreach ($models_this_can_attach_to as $model) {
118
-            if ($model != 'Change_Log') {
119
-                $this->_model_relations[ $model ] = new EE_Belongs_To_Any_Relation();
120
-            }
121
-        }
122
-        // use completely custom caps for this
123
-        $this->_cap_restriction_generators = false;
124
-        // caps-wise this is all-or-nothing: if you have the default role you can access anything, otherwise nothing
125
-        foreach ($this->_cap_contexts_to_cap_action_map as $cap_context => $action) {
126
-            $this->_cap_restrictions[ $cap_context ][ EE_Restriction_Generator_Base::get_default_restrictions_cap() ]
127
-                = new EE_Return_None_Where_Conditions();
128
-        }
129
-        parent::__construct($timezone);
130
-    }
109
+				'LOG_wp_user' => new EE_WP_User_Field(
110
+					'LOG_wp_user',
111
+					esc_html__("User who was logged in while this occurred", 'event_espresso'),
112
+					true
113
+				),
114
+			),
115
+		);
116
+		$this->_model_relations    = array();
117
+		foreach ($models_this_can_attach_to as $model) {
118
+			if ($model != 'Change_Log') {
119
+				$this->_model_relations[ $model ] = new EE_Belongs_To_Any_Relation();
120
+			}
121
+		}
122
+		// use completely custom caps for this
123
+		$this->_cap_restriction_generators = false;
124
+		// caps-wise this is all-or-nothing: if you have the default role you can access anything, otherwise nothing
125
+		foreach ($this->_cap_contexts_to_cap_action_map as $cap_context => $action) {
126
+			$this->_cap_restrictions[ $cap_context ][ EE_Restriction_Generator_Base::get_default_restrictions_cap() ]
127
+				= new EE_Return_None_Where_Conditions();
128
+		}
129
+		parent::__construct($timezone);
130
+	}
131 131
 
132
-    /**
133
-     * @param string        $log_type !see the acceptable values of LOG_type in EEM__Change_Log::__construct
134
-     * @param mixed         $message  array|string of the message you want to record
135
-     * @param EE_Base_Class $related_model_obj
136
-     * @return EE_Change_Log
137
-     * @throws EE_Error
138
-     */
139
-    public function log($log_type, $message, $related_model_obj)
140
-    {
141
-        if ($related_model_obj instanceof EE_Base_Class) {
142
-            $obj_id   = $related_model_obj->ID();
143
-            $obj_type = $related_model_obj->get_model()->get_this_model_name();
144
-        } else {
145
-            $obj_id   = null;
146
-            $obj_type = null;
147
-        }
148
-        /** @var EE_Change_Log $log */
149
-        $log = EE_Change_Log::new_instance(array(
150
-            'LOG_type'    => $log_type,
151
-            'LOG_message' => $message,
152
-            'OBJ_ID'      => $obj_id,
153
-            'OBJ_type'    => $obj_type,
154
-        ));
155
-        $log->save();
156
-        return $log;
157
-    }
132
+	/**
133
+	 * @param string        $log_type !see the acceptable values of LOG_type in EEM__Change_Log::__construct
134
+	 * @param mixed         $message  array|string of the message you want to record
135
+	 * @param EE_Base_Class $related_model_obj
136
+	 * @return EE_Change_Log
137
+	 * @throws EE_Error
138
+	 */
139
+	public function log($log_type, $message, $related_model_obj)
140
+	{
141
+		if ($related_model_obj instanceof EE_Base_Class) {
142
+			$obj_id   = $related_model_obj->ID();
143
+			$obj_type = $related_model_obj->get_model()->get_this_model_name();
144
+		} else {
145
+			$obj_id   = null;
146
+			$obj_type = null;
147
+		}
148
+		/** @var EE_Change_Log $log */
149
+		$log = EE_Change_Log::new_instance(array(
150
+			'LOG_type'    => $log_type,
151
+			'LOG_message' => $message,
152
+			'OBJ_ID'      => $obj_id,
153
+			'OBJ_type'    => $obj_type,
154
+		));
155
+		$log->save();
156
+		return $log;
157
+	}
158 158
 
159 159
 
160
-    /**
161
-     * Adds a gateway log for the specified object, given its ID and type
162
-     *
163
-     * @param string $message
164
-     * @param mixed  $related_obj_id
165
-     * @param string $related_obj_type
166
-     * @throws EE_Error
167
-     * @return EE_Change_Log
168
-     */
169
-    public function gateway_log($message, $related_obj_id, $related_obj_type)
170
-    {
171
-        if (! EE_Registry::instance()->is_model_name($related_obj_type)) {
172
-            throw new EE_Error(
173
-                sprintf(
174
-                    esc_html__(
175
-                        "'%s' is not a model name. A model name must be provided when making a gateway log. Eg, 'Payment', 'Payment_Method', etc",
176
-                        "event_espresso"
177
-                    ),
178
-                    $related_obj_type
179
-                )
180
-            );
181
-        }
182
-        /** @var EE_Change_Log $log */
183
-        $log = EE_Change_Log::new_instance(array(
184
-            'LOG_type'    => EEM_Change_Log::type_gateway,
185
-            'LOG_message' => $message,
186
-            'OBJ_ID'      => $related_obj_id,
187
-            'OBJ_type'    => $related_obj_type,
188
-        ));
189
-        $log->save();
190
-        return $log;
191
-    }
160
+	/**
161
+	 * Adds a gateway log for the specified object, given its ID and type
162
+	 *
163
+	 * @param string $message
164
+	 * @param mixed  $related_obj_id
165
+	 * @param string $related_obj_type
166
+	 * @throws EE_Error
167
+	 * @return EE_Change_Log
168
+	 */
169
+	public function gateway_log($message, $related_obj_id, $related_obj_type)
170
+	{
171
+		if (! EE_Registry::instance()->is_model_name($related_obj_type)) {
172
+			throw new EE_Error(
173
+				sprintf(
174
+					esc_html__(
175
+						"'%s' is not a model name. A model name must be provided when making a gateway log. Eg, 'Payment', 'Payment_Method', etc",
176
+						"event_espresso"
177
+					),
178
+					$related_obj_type
179
+				)
180
+			);
181
+		}
182
+		/** @var EE_Change_Log $log */
183
+		$log = EE_Change_Log::new_instance(array(
184
+			'LOG_type'    => EEM_Change_Log::type_gateway,
185
+			'LOG_message' => $message,
186
+			'OBJ_ID'      => $related_obj_id,
187
+			'OBJ_type'    => $related_obj_type,
188
+		));
189
+		$log->save();
190
+		return $log;
191
+	}
192 192
 
193 193
 
194
-    /**
195
-     * Just gets the bare-bones wpdb results as an array in cases where efficiency is essential
196
-     *
197
-     * @param array $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
198
-     * @return array of arrays
199
-     * @throws EE_Error
200
-     */
201
-    public function get_all_efficiently($query_params)
202
-    {
203
-        return $this->_get_all_wpdb_results($query_params);
204
-    }
194
+	/**
195
+	 * Just gets the bare-bones wpdb results as an array in cases where efficiency is essential
196
+	 *
197
+	 * @param array $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
198
+	 * @return array of arrays
199
+	 * @throws EE_Error
200
+	 */
201
+	public function get_all_efficiently($query_params)
202
+	{
203
+		return $this->_get_all_wpdb_results($query_params);
204
+	}
205 205
 
206 206
 
207
-    /**
208
-     * Executes a database query to delete gateway logs. Does not affect model objects, so if you attempt to use
209
-     * models after this, they may be out-of-sync with the database
210
-     *
211
-     * @param DateTime $datetime
212
-     * @return false|int
213
-     * @throws EE_Error
214
-     */
215
-    public function delete_gateway_logs_older_than(DateTime $datetime)
216
-    {
217
-        global $wpdb;
218
-        return $wpdb->query(
219
-            $wpdb->prepare(
220
-                'DELETE FROM ' . $this->table() . ' WHERE LOG_type = %s AND LOG_time < %s',
221
-                EEM_Change_Log::type_gateway,
222
-                $datetime->format(EE_Datetime_Field::mysql_timestamp_format)
223
-            )
224
-        );
225
-    }
207
+	/**
208
+	 * Executes a database query to delete gateway logs. Does not affect model objects, so if you attempt to use
209
+	 * models after this, they may be out-of-sync with the database
210
+	 *
211
+	 * @param DateTime $datetime
212
+	 * @return false|int
213
+	 * @throws EE_Error
214
+	 */
215
+	public function delete_gateway_logs_older_than(DateTime $datetime)
216
+	{
217
+		global $wpdb;
218
+		return $wpdb->query(
219
+			$wpdb->prepare(
220
+				'DELETE FROM ' . $this->table() . ' WHERE LOG_type = %s AND LOG_time < %s',
221
+				EEM_Change_Log::type_gateway,
222
+				$datetime->format(EE_Datetime_Field::mysql_timestamp_format)
223
+			)
224
+		);
225
+	}
226 226
 
227 227
 
228
-    /**
229
-     * Returns the map of type to pretty label for identifiers used for `LOG_type`.  Client code can register their own
230
-     * map vai the given filter.
231
-     *
232
-     * @return array
233
-     */
234
-    public static function get_pretty_label_map_for_registered_types()
235
-    {
236
-        return apply_filters(
237
-            'FHEE__EEM_Change_Log__get_pretty_label_map_for_registered_types',
238
-            array(
239
-                self::type_create=>  esc_html__("Create", "event_espresso"),
240
-                self::type_update=>  esc_html__("Update", "event_espresso"),
241
-                self::type_delete => esc_html__("Delete", "event_espresso"),
242
-                self::type_debug=>  esc_html__("Debug", "event_espresso"),
243
-                self::type_error=>  esc_html__("Error", "event_espresso"),
244
-                self::type_gateway=> esc_html__("Gateway Interaction (IPN or Direct Payment)", 'event_espresso')
245
-            )
246
-        );
247
-    }
228
+	/**
229
+	 * Returns the map of type to pretty label for identifiers used for `LOG_type`.  Client code can register their own
230
+	 * map vai the given filter.
231
+	 *
232
+	 * @return array
233
+	 */
234
+	public static function get_pretty_label_map_for_registered_types()
235
+	{
236
+		return apply_filters(
237
+			'FHEE__EEM_Change_Log__get_pretty_label_map_for_registered_types',
238
+			array(
239
+				self::type_create=>  esc_html__("Create", "event_espresso"),
240
+				self::type_update=>  esc_html__("Update", "event_espresso"),
241
+				self::type_delete => esc_html__("Delete", "event_espresso"),
242
+				self::type_debug=>  esc_html__("Debug", "event_espresso"),
243
+				self::type_error=>  esc_html__("Error", "event_espresso"),
244
+				self::type_gateway=> esc_html__("Gateway Interaction (IPN or Direct Payment)", 'event_espresso')
245
+			)
246
+		);
247
+	}
248 248
 
249 249
 
250
-    /**
251
-     * Return the pretty (localized) label for the given log type identifier.
252
-     * @param string $type_identifier
253
-     * @return string
254
-     */
255
-    public static function get_pretty_label_for_type($type_identifier)
256
-    {
257
-        $type_identifier_map = self::get_pretty_label_map_for_registered_types();
258
-        // we fallback to the incoming type identifier if there is no localized label for it.
259
-        return isset($type_identifier_map[ $type_identifier ])
260
-            ? $type_identifier_map[ $type_identifier ]
261
-            : $type_identifier;
262
-    }
250
+	/**
251
+	 * Return the pretty (localized) label for the given log type identifier.
252
+	 * @param string $type_identifier
253
+	 * @return string
254
+	 */
255
+	public static function get_pretty_label_for_type($type_identifier)
256
+	{
257
+		$type_identifier_map = self::get_pretty_label_map_for_registered_types();
258
+		// we fallback to the incoming type identifier if there is no localized label for it.
259
+		return isset($type_identifier_map[ $type_identifier ])
260
+			? $type_identifier_map[ $type_identifier ]
261
+			: $type_identifier;
262
+	}
263 263
 }
Please login to merge, or discard this patch.
core/db_models/EEM_Soft_Delete_Base.model.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
      */
32 32
     protected function __construct($timezone = null)
33 33
     {
34
-        if (! $this->_default_where_conditions_strategy instanceof EE_Default_Where_Conditions) {
34
+        if ( ! $this->_default_where_conditions_strategy instanceof EE_Default_Where_Conditions) {
35 35
             $this->_default_where_conditions_strategy = new EE_Soft_Delete_Where_Conditions();
36 36
         }
37 37
         parent::__construct($timezone);
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
     protected function _alter_query_params_so_only_trashed_items_included($query_params)
133 133
     {
134 134
         $deletedFlagFieldName = $this->deleted_field_name();
135
-        $query_params[0][ $deletedFlagFieldName ] = true;
135
+        $query_params[0][$deletedFlagFieldName] = true;
136 136
         return $query_params;
137 137
     }
138 138
 
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
      */
173 173
     protected function _alter_query_params_so_deleted_and_undeleted_items_included($query_params)
174 174
     {
175
-        if (! isset($query_params['default_where_conditions'])) {
175
+        if ( ! isset($query_params['default_where_conditions'])) {
176 176
             $query_params['default_where_conditions'] = 'minimum';
177 177
         }
178 178
         return $query_params;
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
      */
301 301
     public function delete_or_restore_by_ID($delete = true, $ID = false)
302 302
     {
303
-        if (! $ID) {
303
+        if ( ! $ID) {
304 304
             return false;
305 305
         }
306 306
         if ($this->delete_or_restore(
Please login to merge, or discard this patch.
Indentation   +359 added lines, -359 removed lines patch added patch discarded remove patch
@@ -26,363 +26,363 @@
 block discarded – undo
26 26
 abstract class EEM_Soft_Delete_Base extends EEM_Base
27 27
 {
28 28
 
29
-    /**
30
-     * @param null $timezone
31
-     */
32
-    protected function __construct($timezone = null)
33
-    {
34
-        if (! $this->_default_where_conditions_strategy instanceof EE_Default_Where_Conditions) {
35
-            $this->_default_where_conditions_strategy = new EE_Soft_Delete_Where_Conditions();
36
-        }
37
-        parent::__construct($timezone);
38
-    }
39
-
40
-
41
-
42
-    /**
43
-     * Searches for field on this model of type 'deleted_flag'. if it is found,
44
-     * returns it's name.
45
-     *
46
-     * @return string
47
-     * @throws EE_Error
48
-     */
49
-    public function deleted_field_name()
50
-    {
51
-        $field = $this->get_a_field_of_type('EE_Trashed_Flag_Field');
52
-        if ($field) {
53
-            return $field->get_name();
54
-        } else {
55
-            throw new EE_Error(sprintf(__(
56
-                'We are trying to find the deleted flag field on %s, but none was found. Are you sure there is a field of type EE_Trashed_Flag_Field in %s constructor?',
57
-                'event_espresso'
58
-            ), get_class($this), get_class($this)));
59
-        }
60
-    }
61
-
62
-
63
-
64
-    /**
65
-     * Gets one item that's been deleted, according to $query_params
66
-     *
67
-     * @param array $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
68
-     * @return EE_Soft_Delete_Base_Class
69
-     */
70
-    public function get_one_deleted($query_params = array())
71
-    {
72
-        $query_params = $this->_alter_query_params_so_only_trashed_items_included($query_params);
73
-        return parent::get_one($query_params);
74
-    }
75
-
76
-
77
-
78
-    /**
79
-     * Gets one item from the DB, regardless of whether it's been soft-deleted or not
80
-     *
81
-     * @param array $query_params like EEM_base::get_all's $query_params
82
-     * @return EE_Soft_Delete_Base_Class
83
-     */
84
-    public function get_one_deleted_or_undeleted($query_params = array())
85
-    {
86
-        $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params);
87
-        return parent::get_one($query_params);
88
-    }
89
-
90
-
91
-
92
-    /**
93
-     * Gets the item indicated by its ID. But if it's soft-deleted, pretends it doesn't exist.
94
-     *
95
-     * @param int|string $id
96
-     * @return EE_Soft_Delete_Base_Class
97
-     */
98
-    public function get_one_by_ID_but_ignore_deleted($id)
99
-    {
100
-        return $this->get_one(
101
-            $this->alter_query_params_to_restrict_by_ID(
102
-                $id,
103
-                array('default_where_conditions' => 'default')
104
-            )
105
-        );
106
-    }
107
-
108
-
109
-
110
-    /**
111
-     * Counts all the deleted/trashed items
112
-     *
113
-     * @param array  $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
114
-     * @param string $field_to_count
115
-     * @param bool   $distinct     if we want to only count the distinct values for the column then you can trigger that by the setting $distinct to TRUE;
116
-     * @return int
117
-     */
118
-    public function count_deleted($query_params = null, $field_to_count = null, $distinct = false)
119
-    {
120
-        $query_params = $this->_alter_query_params_so_only_trashed_items_included($query_params);
121
-        return parent::count($query_params, $field_to_count, $distinct);
122
-    }
123
-
124
-
125
-
126
-    /**
127
-     * Alters the query params so that only trashed/soft-deleted items are considered
128
-     *
129
-     * @param array $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
130
-     * @return array @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
131
-     */
132
-    protected function _alter_query_params_so_only_trashed_items_included($query_params)
133
-    {
134
-        $deletedFlagFieldName = $this->deleted_field_name();
135
-        $query_params[0][ $deletedFlagFieldName ] = true;
136
-        return $query_params;
137
-    }
138
-
139
-
140
-
141
-    /**
142
-     * Alters the query params so that only trashed/soft-deleted items are considered
143
-     *
144
-     * @param array $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
145
-     * @return array @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
146
-     */
147
-    public function alter_query_params_so_only_trashed_items_included($query_params)
148
-    {
149
-        return $this->_alter_query_params_so_only_trashed_items_included($query_params);
150
-    }
151
-
152
-
153
-
154
-    /**
155
-     * Alters the query params so each item's deleted status is ignored.
156
-     *
157
-     * @param array $query_params
158
-     * @return array
159
-     */
160
-    public function alter_query_params_so_deleted_and_undeleted_items_included($query_params = array())
161
-    {
162
-        return $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params);
163
-    }
164
-
165
-
166
-
167
-    /**
168
-     * Alters the query params so each item's deleted status is ignored.
169
-     *
170
-     * @param array $query_params
171
-     * @return array
172
-     */
173
-    protected function _alter_query_params_so_deleted_and_undeleted_items_included($query_params)
174
-    {
175
-        if (! isset($query_params['default_where_conditions'])) {
176
-            $query_params['default_where_conditions'] = 'minimum';
177
-        }
178
-        return $query_params;
179
-    }
180
-
181
-
182
-
183
-    /**
184
-     * Counts all deleted and undeleted items
185
-     *
186
-     * @param array  $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
187
-     * @param string $field_to_count
188
-     * @param bool   $distinct     if we want to only count the distinct values for the column then you can trigger that by the setting $distinct to TRUE;
189
-     * @return int
190
-     */
191
-    public function count_deleted_and_undeleted($query_params = null, $field_to_count = null, $distinct = false)
192
-    {
193
-        $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params);
194
-        return parent::count($query_params, $field_to_count, $distinct);
195
-    }
196
-
197
-
198
-
199
-    /**
200
-     * Sum all the deleted items.
201
-     *
202
-     * @param array  $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
203
-     * @param string $field_to_sum
204
-     * @return int
205
-     */
206
-    public function sum_deleted($query_params = null, $field_to_sum = null)
207
-    {
208
-        $query_params = $this->_alter_query_params_so_only_trashed_items_included($query_params);
209
-        return parent::sum($query_params, $field_to_sum);
210
-    }
211
-
212
-
213
-
214
-    /**
215
-     * Sums all the deleted and undeleted items.
216
-     *
217
-     * @param array  $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
218
-     * @param string $field_to_sum
219
-     * @return int
220
-     */
221
-    public function sum_deleted_and_undeleted($query_params = null, $field_to_sum = null)
222
-    {
223
-        $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params);
224
-        parent::sum($query_params, $field_to_sum);
225
-    }
226
-
227
-
228
-
229
-    /**
230
-     * Gets all deleted and undeleted mode objects from the db that meet the criteria, regardless of
231
-     * whether they've been soft-deleted or not
232
-     *
233
-     * @param array $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
234
-     * @return EE_Soft_Delete_Base_Class[]
235
-     */
236
-    public function get_all_deleted_and_undeleted($query_params = array())
237
-    {
238
-        $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params);
239
-        return parent::get_all($query_params);
240
-    }
241
-
242
-
243
-
244
-    /**
245
-     * For 'soft deletable' models, gets all which ARE deleted, according to conditions specified in $query_params.
246
-     *
247
-     * @param array $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
248
-     * @return EE_Soft_Delete_Base_Class[]
249
-     */
250
-    public function get_all_deleted($query_params = array())
251
-    {
252
-        $query_params = $this->_alter_query_params_so_only_trashed_items_included($query_params);
253
-        return parent::get_all($query_params);
254
-    }
255
-
256
-
257
-
258
-    /**
259
-     * Permanently deletes the selected rows. When selecting rows for deletion, ignores
260
-     * whether they've been soft-deleted or not. (ie, you don't have to soft-delete objects
261
-     * before you can permanently delete them).
262
-     * Because this will cause a real deletion, related models may block this deletion (ie, add an error
263
-     * and abort the delete)
264
-     *
265
-     * @param array   $query_params   @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
266
-     * @param boolean $allow_blocking if TRUE, matched objects will only be deleted if there is no related model info
267
-     *                                that blocks it (ie, there' sno other data that depends on this data); if false, deletes regardless of other objects
268
-     *                                which may depend on it. Its generally advisable to always leave this as TRUE, otherwise you could easily corrupt your DB
269
-     * @return boolean success
270
-     */
271
-    public function delete_permanently($query_params = array(), $allow_blocking = true)
272
-    {
273
-        $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params);
274
-        return parent::delete_permanently($query_params, $allow_blocking);
275
-    }
276
-
277
-
278
-
279
-    /**
280
-     * Restores a particular item by its ID (primary key). Ignores the fact whether the item
281
-     * has been soft-deleted or not.
282
-     *
283
-     * @param mixed $ID int if primary key is an int, string otherwise
284
-     * @return boolean success
285
-     */
286
-    public function restore_by_ID($ID = false)
287
-    {
288
-        return $this->delete_or_restore_by_ID(false, $ID);
289
-    }
290
-
291
-
292
-
293
-    /**
294
-     * For deleting or restoring a particular item. Note that this model is a SOFT-DELETABLE model! However,
295
-     * this function will ignore whether the items have been soft-deleted or not.
296
-     *
297
-     * @param boolean $delete true for delete, false for restore
298
-     * @param mixed   $ID     int if primary key is an int, string otherwise
299
-     * @return boolean
300
-     */
301
-    public function delete_or_restore_by_ID($delete = true, $ID = false)
302
-    {
303
-        if (! $ID) {
304
-            return false;
305
-        }
306
-        if ($this->delete_or_restore(
307
-            $delete,
308
-            $this->alter_query_params_to_restrict_by_ID($ID)
309
-        )
310
-        ) {
311
-            return true;
312
-        } else {
313
-            return false;
314
-        }
315
-    }
316
-
317
-
318
-
319
-    /**
320
-     * Overrides parent's 'delete' method to instead do a soft delete on all rows that
321
-     * meet the criteria in $where_col_n_values. This particular function ignores whether the items have been soft-deleted or not.
322
-     * Note: because this item will be soft-deleted only,
323
-     * doesn't block because of model dependencies
324
-     *
325
-     * @param array $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
326
-     * @param bool  $block_deletes
327
-     * @return boolean
328
-     */
329
-    public function delete($query_params = array(), $block_deletes = false)
330
-    {
331
-        // no matter what, we WON'T block soft deletes.
332
-        return $this->delete_or_restore(true, $query_params);
333
-    }
334
-
335
-
336
-
337
-    /**
338
-     * 'Un-deletes' the chosen items. Note that this model is a SOFT-DELETABLE model! That means that, by default, trashed/soft-deleted
339
-     * items are ignored in queries. However, this particular function ignores whether the items have been soft-deleted or not.
340
-     *
341
-     * @param array $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
342
-     * @return boolean
343
-     */
344
-    public function restore($query_params = array())
345
-    {
346
-        return $this->delete_or_restore(false, $query_params);
347
-    }
348
-
349
-
350
-
351
-    /**
352
-     * Performs deletes or restores on items. Both soft-deleted and non-soft-deleted items considered.
353
-     *
354
-     * @param boolean $delete       true to indicate deletion, false to indicate restoration
355
-     * @param array   $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
356
-     * @return boolean
357
-     */
358
-    public function delete_or_restore($delete = true, $query_params = array())
359
-    {
360
-        $deletedFlagFieldName = $this->deleted_field_name();
361
-        $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params);
362
-        if ($this->update(array($deletedFlagFieldName => $delete), $query_params)) {
363
-            return true;
364
-        } else {
365
-            return false;
366
-        }
367
-    }
368
-
369
-
370
-
371
-    /**
372
-     * Updates all the items of this model which match the $query params, regardless of whether
373
-     * they've been soft-deleted or not
374
-     *
375
-     * @param array   $fields_n_values         like EEM_Base::update's $fields_n_value
376
-     * @param array   $query_params            like EEM_base::get_all's $query_params
377
-     * @param boolean $keep_model_objs_in_sync if TRUE, makes sure we ALSO update model objects
378
-     *                                         in this model's entity map according to $fields_n_values that match $query_params. This
379
-     *                                         obviously has some overhead, so you can disable it by setting this to FALSE, but
380
-     *                                         be aware that model objects being used could get out-of-sync with the database
381
-     * @return int number of items updated
382
-     */
383
-    public function update_deleted_and_undeleted($fields_n_values, $query_params, $keep_model_objs_in_sync = true)
384
-    {
385
-        $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params);
386
-        return $this->update($fields_n_values, $query_params, $keep_model_objs_in_sync);
387
-    }
29
+	/**
30
+	 * @param null $timezone
31
+	 */
32
+	protected function __construct($timezone = null)
33
+	{
34
+		if (! $this->_default_where_conditions_strategy instanceof EE_Default_Where_Conditions) {
35
+			$this->_default_where_conditions_strategy = new EE_Soft_Delete_Where_Conditions();
36
+		}
37
+		parent::__construct($timezone);
38
+	}
39
+
40
+
41
+
42
+	/**
43
+	 * Searches for field on this model of type 'deleted_flag'. if it is found,
44
+	 * returns it's name.
45
+	 *
46
+	 * @return string
47
+	 * @throws EE_Error
48
+	 */
49
+	public function deleted_field_name()
50
+	{
51
+		$field = $this->get_a_field_of_type('EE_Trashed_Flag_Field');
52
+		if ($field) {
53
+			return $field->get_name();
54
+		} else {
55
+			throw new EE_Error(sprintf(__(
56
+				'We are trying to find the deleted flag field on %s, but none was found. Are you sure there is a field of type EE_Trashed_Flag_Field in %s constructor?',
57
+				'event_espresso'
58
+			), get_class($this), get_class($this)));
59
+		}
60
+	}
61
+
62
+
63
+
64
+	/**
65
+	 * Gets one item that's been deleted, according to $query_params
66
+	 *
67
+	 * @param array $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
68
+	 * @return EE_Soft_Delete_Base_Class
69
+	 */
70
+	public function get_one_deleted($query_params = array())
71
+	{
72
+		$query_params = $this->_alter_query_params_so_only_trashed_items_included($query_params);
73
+		return parent::get_one($query_params);
74
+	}
75
+
76
+
77
+
78
+	/**
79
+	 * Gets one item from the DB, regardless of whether it's been soft-deleted or not
80
+	 *
81
+	 * @param array $query_params like EEM_base::get_all's $query_params
82
+	 * @return EE_Soft_Delete_Base_Class
83
+	 */
84
+	public function get_one_deleted_or_undeleted($query_params = array())
85
+	{
86
+		$query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params);
87
+		return parent::get_one($query_params);
88
+	}
89
+
90
+
91
+
92
+	/**
93
+	 * Gets the item indicated by its ID. But if it's soft-deleted, pretends it doesn't exist.
94
+	 *
95
+	 * @param int|string $id
96
+	 * @return EE_Soft_Delete_Base_Class
97
+	 */
98
+	public function get_one_by_ID_but_ignore_deleted($id)
99
+	{
100
+		return $this->get_one(
101
+			$this->alter_query_params_to_restrict_by_ID(
102
+				$id,
103
+				array('default_where_conditions' => 'default')
104
+			)
105
+		);
106
+	}
107
+
108
+
109
+
110
+	/**
111
+	 * Counts all the deleted/trashed items
112
+	 *
113
+	 * @param array  $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
114
+	 * @param string $field_to_count
115
+	 * @param bool   $distinct     if we want to only count the distinct values for the column then you can trigger that by the setting $distinct to TRUE;
116
+	 * @return int
117
+	 */
118
+	public function count_deleted($query_params = null, $field_to_count = null, $distinct = false)
119
+	{
120
+		$query_params = $this->_alter_query_params_so_only_trashed_items_included($query_params);
121
+		return parent::count($query_params, $field_to_count, $distinct);
122
+	}
123
+
124
+
125
+
126
+	/**
127
+	 * Alters the query params so that only trashed/soft-deleted items are considered
128
+	 *
129
+	 * @param array $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
130
+	 * @return array @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
131
+	 */
132
+	protected function _alter_query_params_so_only_trashed_items_included($query_params)
133
+	{
134
+		$deletedFlagFieldName = $this->deleted_field_name();
135
+		$query_params[0][ $deletedFlagFieldName ] = true;
136
+		return $query_params;
137
+	}
138
+
139
+
140
+
141
+	/**
142
+	 * Alters the query params so that only trashed/soft-deleted items are considered
143
+	 *
144
+	 * @param array $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
145
+	 * @return array @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
146
+	 */
147
+	public function alter_query_params_so_only_trashed_items_included($query_params)
148
+	{
149
+		return $this->_alter_query_params_so_only_trashed_items_included($query_params);
150
+	}
151
+
152
+
153
+
154
+	/**
155
+	 * Alters the query params so each item's deleted status is ignored.
156
+	 *
157
+	 * @param array $query_params
158
+	 * @return array
159
+	 */
160
+	public function alter_query_params_so_deleted_and_undeleted_items_included($query_params = array())
161
+	{
162
+		return $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params);
163
+	}
164
+
165
+
166
+
167
+	/**
168
+	 * Alters the query params so each item's deleted status is ignored.
169
+	 *
170
+	 * @param array $query_params
171
+	 * @return array
172
+	 */
173
+	protected function _alter_query_params_so_deleted_and_undeleted_items_included($query_params)
174
+	{
175
+		if (! isset($query_params['default_where_conditions'])) {
176
+			$query_params['default_where_conditions'] = 'minimum';
177
+		}
178
+		return $query_params;
179
+	}
180
+
181
+
182
+
183
+	/**
184
+	 * Counts all deleted and undeleted items
185
+	 *
186
+	 * @param array  $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
187
+	 * @param string $field_to_count
188
+	 * @param bool   $distinct     if we want to only count the distinct values for the column then you can trigger that by the setting $distinct to TRUE;
189
+	 * @return int
190
+	 */
191
+	public function count_deleted_and_undeleted($query_params = null, $field_to_count = null, $distinct = false)
192
+	{
193
+		$query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params);
194
+		return parent::count($query_params, $field_to_count, $distinct);
195
+	}
196
+
197
+
198
+
199
+	/**
200
+	 * Sum all the deleted items.
201
+	 *
202
+	 * @param array  $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
203
+	 * @param string $field_to_sum
204
+	 * @return int
205
+	 */
206
+	public function sum_deleted($query_params = null, $field_to_sum = null)
207
+	{
208
+		$query_params = $this->_alter_query_params_so_only_trashed_items_included($query_params);
209
+		return parent::sum($query_params, $field_to_sum);
210
+	}
211
+
212
+
213
+
214
+	/**
215
+	 * Sums all the deleted and undeleted items.
216
+	 *
217
+	 * @param array  $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
218
+	 * @param string $field_to_sum
219
+	 * @return int
220
+	 */
221
+	public function sum_deleted_and_undeleted($query_params = null, $field_to_sum = null)
222
+	{
223
+		$query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params);
224
+		parent::sum($query_params, $field_to_sum);
225
+	}
226
+
227
+
228
+
229
+	/**
230
+	 * Gets all deleted and undeleted mode objects from the db that meet the criteria, regardless of
231
+	 * whether they've been soft-deleted or not
232
+	 *
233
+	 * @param array $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
234
+	 * @return EE_Soft_Delete_Base_Class[]
235
+	 */
236
+	public function get_all_deleted_and_undeleted($query_params = array())
237
+	{
238
+		$query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params);
239
+		return parent::get_all($query_params);
240
+	}
241
+
242
+
243
+
244
+	/**
245
+	 * For 'soft deletable' models, gets all which ARE deleted, according to conditions specified in $query_params.
246
+	 *
247
+	 * @param array $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
248
+	 * @return EE_Soft_Delete_Base_Class[]
249
+	 */
250
+	public function get_all_deleted($query_params = array())
251
+	{
252
+		$query_params = $this->_alter_query_params_so_only_trashed_items_included($query_params);
253
+		return parent::get_all($query_params);
254
+	}
255
+
256
+
257
+
258
+	/**
259
+	 * Permanently deletes the selected rows. When selecting rows for deletion, ignores
260
+	 * whether they've been soft-deleted or not. (ie, you don't have to soft-delete objects
261
+	 * before you can permanently delete them).
262
+	 * Because this will cause a real deletion, related models may block this deletion (ie, add an error
263
+	 * and abort the delete)
264
+	 *
265
+	 * @param array   $query_params   @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
266
+	 * @param boolean $allow_blocking if TRUE, matched objects will only be deleted if there is no related model info
267
+	 *                                that blocks it (ie, there' sno other data that depends on this data); if false, deletes regardless of other objects
268
+	 *                                which may depend on it. Its generally advisable to always leave this as TRUE, otherwise you could easily corrupt your DB
269
+	 * @return boolean success
270
+	 */
271
+	public function delete_permanently($query_params = array(), $allow_blocking = true)
272
+	{
273
+		$query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params);
274
+		return parent::delete_permanently($query_params, $allow_blocking);
275
+	}
276
+
277
+
278
+
279
+	/**
280
+	 * Restores a particular item by its ID (primary key). Ignores the fact whether the item
281
+	 * has been soft-deleted or not.
282
+	 *
283
+	 * @param mixed $ID int if primary key is an int, string otherwise
284
+	 * @return boolean success
285
+	 */
286
+	public function restore_by_ID($ID = false)
287
+	{
288
+		return $this->delete_or_restore_by_ID(false, $ID);
289
+	}
290
+
291
+
292
+
293
+	/**
294
+	 * For deleting or restoring a particular item. Note that this model is a SOFT-DELETABLE model! However,
295
+	 * this function will ignore whether the items have been soft-deleted or not.
296
+	 *
297
+	 * @param boolean $delete true for delete, false for restore
298
+	 * @param mixed   $ID     int if primary key is an int, string otherwise
299
+	 * @return boolean
300
+	 */
301
+	public function delete_or_restore_by_ID($delete = true, $ID = false)
302
+	{
303
+		if (! $ID) {
304
+			return false;
305
+		}
306
+		if ($this->delete_or_restore(
307
+			$delete,
308
+			$this->alter_query_params_to_restrict_by_ID($ID)
309
+		)
310
+		) {
311
+			return true;
312
+		} else {
313
+			return false;
314
+		}
315
+	}
316
+
317
+
318
+
319
+	/**
320
+	 * Overrides parent's 'delete' method to instead do a soft delete on all rows that
321
+	 * meet the criteria in $where_col_n_values. This particular function ignores whether the items have been soft-deleted or not.
322
+	 * Note: because this item will be soft-deleted only,
323
+	 * doesn't block because of model dependencies
324
+	 *
325
+	 * @param array $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
326
+	 * @param bool  $block_deletes
327
+	 * @return boolean
328
+	 */
329
+	public function delete($query_params = array(), $block_deletes = false)
330
+	{
331
+		// no matter what, we WON'T block soft deletes.
332
+		return $this->delete_or_restore(true, $query_params);
333
+	}
334
+
335
+
336
+
337
+	/**
338
+	 * 'Un-deletes' the chosen items. Note that this model is a SOFT-DELETABLE model! That means that, by default, trashed/soft-deleted
339
+	 * items are ignored in queries. However, this particular function ignores whether the items have been soft-deleted or not.
340
+	 *
341
+	 * @param array $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
342
+	 * @return boolean
343
+	 */
344
+	public function restore($query_params = array())
345
+	{
346
+		return $this->delete_or_restore(false, $query_params);
347
+	}
348
+
349
+
350
+
351
+	/**
352
+	 * Performs deletes or restores on items. Both soft-deleted and non-soft-deleted items considered.
353
+	 *
354
+	 * @param boolean $delete       true to indicate deletion, false to indicate restoration
355
+	 * @param array   $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
356
+	 * @return boolean
357
+	 */
358
+	public function delete_or_restore($delete = true, $query_params = array())
359
+	{
360
+		$deletedFlagFieldName = $this->deleted_field_name();
361
+		$query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params);
362
+		if ($this->update(array($deletedFlagFieldName => $delete), $query_params)) {
363
+			return true;
364
+		} else {
365
+			return false;
366
+		}
367
+	}
368
+
369
+
370
+
371
+	/**
372
+	 * Updates all the items of this model which match the $query params, regardless of whether
373
+	 * they've been soft-deleted or not
374
+	 *
375
+	 * @param array   $fields_n_values         like EEM_Base::update's $fields_n_value
376
+	 * @param array   $query_params            like EEM_base::get_all's $query_params
377
+	 * @param boolean $keep_model_objs_in_sync if TRUE, makes sure we ALSO update model objects
378
+	 *                                         in this model's entity map according to $fields_n_values that match $query_params. This
379
+	 *                                         obviously has some overhead, so you can disable it by setting this to FALSE, but
380
+	 *                                         be aware that model objects being used could get out-of-sync with the database
381
+	 * @return int number of items updated
382
+	 */
383
+	public function update_deleted_and_undeleted($fields_n_values, $query_params, $keep_model_objs_in_sync = true)
384
+	{
385
+		$query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params);
386
+		return $this->update($fields_n_values, $query_params, $keep_model_objs_in_sync);
387
+	}
388 388
 }
Please login to merge, or discard this patch.
core/db_models/EEM_Extra_Meta.model.php 2 patches
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -16,33 +16,33 @@
 block discarded – undo
16 16
 class EEM_Extra_Meta extends EEM_Base
17 17
 {
18 18
 
19
-    // private instance of the Attendee object
20
-    protected static $_instance = null;
19
+	// private instance of the Attendee object
20
+	protected static $_instance = null;
21 21
 
22
-    protected function __construct($timezone = null)
23
-    {
24
-        $this->singular_item = __('Extra Meta', 'event_espresso');
25
-        $this->plural_item = __('Extra Metas', 'event_espresso');
26
-        $this->_tables = array(
27
-            'Extra_Meta'=> new EE_Primary_Table('esp_extra_meta', 'EXM_ID')
28
-        );
29
-        $models_this_can_attach_to = array_keys(EE_Registry::instance()->non_abstract_db_models);
30
-        $this->_fields = array(
31
-            'Extra_Meta'=>array(
32
-                'EXM_ID'=>new EE_Primary_Key_Int_Field('EXM_ID', __("Extra Meta ID", "event_espresso")),
33
-                'OBJ_ID'=>new EE_Foreign_Key_Int_Field('OBJ_ID', __("Primary Key of Attached Thing", "event_espresso"), false, 0, $models_this_can_attach_to),
34
-                'EXM_type'=>new EE_Any_Foreign_Model_Name_Field('EXM_type', __("Model of Attached Thing", "event_espresso"), false, 'Transaction', $models_this_can_attach_to),
35
-                'EXM_key'=>new EE_Plain_Text_Field('EXM_key', __("Meta Key", "event_espresso"), false, ''),
36
-                'EXM_value'=>new EE_Maybe_Serialized_Text_Field('EXM_value', __("Meta Value", "event_espresso"), true)
22
+	protected function __construct($timezone = null)
23
+	{
24
+		$this->singular_item = __('Extra Meta', 'event_espresso');
25
+		$this->plural_item = __('Extra Metas', 'event_espresso');
26
+		$this->_tables = array(
27
+			'Extra_Meta'=> new EE_Primary_Table('esp_extra_meta', 'EXM_ID')
28
+		);
29
+		$models_this_can_attach_to = array_keys(EE_Registry::instance()->non_abstract_db_models);
30
+		$this->_fields = array(
31
+			'Extra_Meta'=>array(
32
+				'EXM_ID'=>new EE_Primary_Key_Int_Field('EXM_ID', __("Extra Meta ID", "event_espresso")),
33
+				'OBJ_ID'=>new EE_Foreign_Key_Int_Field('OBJ_ID', __("Primary Key of Attached Thing", "event_espresso"), false, 0, $models_this_can_attach_to),
34
+				'EXM_type'=>new EE_Any_Foreign_Model_Name_Field('EXM_type', __("Model of Attached Thing", "event_espresso"), false, 'Transaction', $models_this_can_attach_to),
35
+				'EXM_key'=>new EE_Plain_Text_Field('EXM_key', __("Meta Key", "event_espresso"), false, ''),
36
+				'EXM_value'=>new EE_Maybe_Serialized_Text_Field('EXM_value', __("Meta Value", "event_espresso"), true)
37 37
 
38
-            ));
39
-        $this->_model_relations = array();
40
-        foreach ($models_this_can_attach_to as $model) {
41
-            $this->_model_relations[ $model ] = new EE_Belongs_To_Any_Relation();
42
-        }
43
-        foreach ($this->cap_contexts_to_cap_action_map() as $cap_context => $action) {
44
-            $this->_cap_restriction_generators[ $cap_context ] = new EE_Restriction_Generator_Meta('EXM_key', 'EXM_value');
45
-        }
46
-        parent::__construct($timezone);
47
-    }
38
+			));
39
+		$this->_model_relations = array();
40
+		foreach ($models_this_can_attach_to as $model) {
41
+			$this->_model_relations[ $model ] = new EE_Belongs_To_Any_Relation();
42
+		}
43
+		foreach ($this->cap_contexts_to_cap_action_map() as $cap_context => $action) {
44
+			$this->_cap_restriction_generators[ $cap_context ] = new EE_Restriction_Generator_Meta('EXM_key', 'EXM_value');
45
+		}
46
+		parent::__construct($timezone);
47
+	}
48 48
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -38,10 +38,10 @@
 block discarded – undo
38 38
             ));
39 39
         $this->_model_relations = array();
40 40
         foreach ($models_this_can_attach_to as $model) {
41
-            $this->_model_relations[ $model ] = new EE_Belongs_To_Any_Relation();
41
+            $this->_model_relations[$model] = new EE_Belongs_To_Any_Relation();
42 42
         }
43 43
         foreach ($this->cap_contexts_to_cap_action_map() as $cap_context => $action) {
44
-            $this->_cap_restriction_generators[ $cap_context ] = new EE_Restriction_Generator_Meta('EXM_key', 'EXM_value');
44
+            $this->_cap_restriction_generators[$cap_context] = new EE_Restriction_Generator_Meta('EXM_key', 'EXM_value');
45 45
         }
46 46
         parent::__construct($timezone);
47 47
     }
Please login to merge, or discard this patch.
core/db_models/EEM_Question_Group.model.php 2 patches
Indentation   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -10,58 +10,58 @@
 block discarded – undo
10 10
  */
11 11
 class EEM_Question_Group extends EEM_Soft_Delete_Base
12 12
 {
13
-    const system_personal = 1;
14
-    const system_address = 2;
15
-    // private instance of the Attendee object
16
-    protected static $_instance = null;
13
+	const system_personal = 1;
14
+	const system_address = 2;
15
+	// private instance of the Attendee object
16
+	protected static $_instance = null;
17 17
         
18 18
         
19
-    protected function __construct($timezone = null)
20
-    {
21
-        $this->singular_item = __('Question Group', 'event_espresso');
22
-        $this->plural_item = __('Question Groups', 'event_espresso');
19
+	protected function __construct($timezone = null)
20
+	{
21
+		$this->singular_item = __('Question Group', 'event_espresso');
22
+		$this->plural_item = __('Question Groups', 'event_espresso');
23 23
 
24
-        $this->_tables = array(
25
-            'Question_Group'=>new EE_Primary_Table('esp_question_group', 'QSG_ID')
26
-        );
27
-        $this->_fields = array(
28
-            'Question_Group'=>array(
29
-                'QSG_ID'=>new EE_Primary_Key_Int_Field('QSG_ID', __('Question Group ID', 'event_espresso')),
30
-                'QSG_name'=>new EE_Plain_Text_Field('QSG_name', __('Question Group Name', 'event_espresso'), false, ''),
31
-                'QSG_identifier'=>new EE_Plain_Text_Field('QSG_identifier', __('Text ID for question Group', 'event_espresso'), false, ''),
32
-                'QSG_desc'=>new EE_Post_Content_Field('QSG_desc', __('Description of Question Group', 'event_espresso'), true, ''),
33
-                'QSG_order'=>new EE_Integer_Field('QSG_order', __('Order in which to show the question group', 'event_espresso'), true, 0),
34
-                'QSG_show_group_name'=>new EE_Boolean_Field('QSG_show_group_name', __('Flag indicating whether to show the group\'s name on the registration page', 'event_espresso'), false, true),
35
-                'QSG_show_group_desc'=>new EE_Boolean_Field('QSG_show_group_desc', __('Flag indicating whether to show the group\s description on the registration page', 'event_espresso'), false, false),
36
-                'QSG_wp_user' => new EE_WP_User_Field('QSG_wp_user', __('Question Group Creator ID', 'event_espresso'), false),
37
-                'QSG_system'=>new EE_Integer_Field('QSG_system', __('Indicate IF this is a system group and if it is what system group it corresponds to.', 'event_espresso'), false, 0),
38
-                'QSG_deleted'=>new EE_Trashed_Flag_Field('QSG_deleted', __('Flag indicating this question group was deleted', 'event_espresso'), false, false)
39
-            )
40
-        );
41
-        $this->_model_relations = array(
42
-            'Question'=>new EE_HABTM_Relation('Question_Group_Question'),
43
-            'Event'=>new EE_HABTM_Relation('Event_Question_Group'),
44
-            'Event_Question_Group'=>new EE_Has_Many_Relation(),
45
-            'WP_User' => new EE_Belongs_To_Relation(),
46
-        );
47
-        // this model is generally available for reading
48
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
49
-        $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Reg_Form('QSG_system');
50
-        $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Reg_Form('QSG_system');
51
-        $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Reg_Form('QSG_system');
52
-        parent::__construct($timezone);
53
-    }
54
-    /**
55
-     * searches the db for the question group with the latest question order and returns that value.
56
-     * @access public
57
-     * @return int
58
-     */
59
-    public function get_latest_question_group_order()
60
-    {
61
-        $columns_to_select = array(
62
-            'max_order' => array("MAX(QSG_order)","%d")
63
-            );
64
-        $max = $this->_get_all_wpdb_results(array(), ARRAY_A, $columns_to_select);
65
-        return $max[0]['max_order'];
66
-    }
24
+		$this->_tables = array(
25
+			'Question_Group'=>new EE_Primary_Table('esp_question_group', 'QSG_ID')
26
+		);
27
+		$this->_fields = array(
28
+			'Question_Group'=>array(
29
+				'QSG_ID'=>new EE_Primary_Key_Int_Field('QSG_ID', __('Question Group ID', 'event_espresso')),
30
+				'QSG_name'=>new EE_Plain_Text_Field('QSG_name', __('Question Group Name', 'event_espresso'), false, ''),
31
+				'QSG_identifier'=>new EE_Plain_Text_Field('QSG_identifier', __('Text ID for question Group', 'event_espresso'), false, ''),
32
+				'QSG_desc'=>new EE_Post_Content_Field('QSG_desc', __('Description of Question Group', 'event_espresso'), true, ''),
33
+				'QSG_order'=>new EE_Integer_Field('QSG_order', __('Order in which to show the question group', 'event_espresso'), true, 0),
34
+				'QSG_show_group_name'=>new EE_Boolean_Field('QSG_show_group_name', __('Flag indicating whether to show the group\'s name on the registration page', 'event_espresso'), false, true),
35
+				'QSG_show_group_desc'=>new EE_Boolean_Field('QSG_show_group_desc', __('Flag indicating whether to show the group\s description on the registration page', 'event_espresso'), false, false),
36
+				'QSG_wp_user' => new EE_WP_User_Field('QSG_wp_user', __('Question Group Creator ID', 'event_espresso'), false),
37
+				'QSG_system'=>new EE_Integer_Field('QSG_system', __('Indicate IF this is a system group and if it is what system group it corresponds to.', 'event_espresso'), false, 0),
38
+				'QSG_deleted'=>new EE_Trashed_Flag_Field('QSG_deleted', __('Flag indicating this question group was deleted', 'event_espresso'), false, false)
39
+			)
40
+		);
41
+		$this->_model_relations = array(
42
+			'Question'=>new EE_HABTM_Relation('Question_Group_Question'),
43
+			'Event'=>new EE_HABTM_Relation('Event_Question_Group'),
44
+			'Event_Question_Group'=>new EE_Has_Many_Relation(),
45
+			'WP_User' => new EE_Belongs_To_Relation(),
46
+		);
47
+		// this model is generally available for reading
48
+		$this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
49
+		$this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Reg_Form('QSG_system');
50
+		$this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Reg_Form('QSG_system');
51
+		$this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Reg_Form('QSG_system');
52
+		parent::__construct($timezone);
53
+	}
54
+	/**
55
+	 * searches the db for the question group with the latest question order and returns that value.
56
+	 * @access public
57
+	 * @return int
58
+	 */
59
+	public function get_latest_question_group_order()
60
+	{
61
+		$columns_to_select = array(
62
+			'max_order' => array("MAX(QSG_order)","%d")
63
+			);
64
+		$max = $this->_get_all_wpdb_results(array(), ARRAY_A, $columns_to_select);
65
+		return $max[0]['max_order'];
66
+	}
67 67
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -45,10 +45,10 @@  discard block
 block discarded – undo
45 45
             'WP_User' => new EE_Belongs_To_Relation(),
46 46
         );
47 47
         // this model is generally available for reading
48
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
49
-        $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Reg_Form('QSG_system');
50
-        $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Reg_Form('QSG_system');
51
-        $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Reg_Form('QSG_system');
48
+        $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Public();
49
+        $this->_cap_restriction_generators[EEM_Base::caps_read_admin] = new EE_Restriction_Generator_Reg_Form('QSG_system');
50
+        $this->_cap_restriction_generators[EEM_Base::caps_edit] = new EE_Restriction_Generator_Reg_Form('QSG_system');
51
+        $this->_cap_restriction_generators[EEM_Base::caps_delete] = new EE_Restriction_Generator_Reg_Form('QSG_system');
52 52
         parent::__construct($timezone);
53 53
     }
54 54
     /**
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
     public function get_latest_question_group_order()
60 60
     {
61 61
         $columns_to_select = array(
62
-            'max_order' => array("MAX(QSG_order)","%d")
62
+            'max_order' => array("MAX(QSG_order)", "%d")
63 63
             );
64 64
         $max = $this->_get_all_wpdb_results(array(), ARRAY_A, $columns_to_select);
65 65
         return $max[0]['max_order'];
Please login to merge, or discard this patch.