Completed
Branch dependabot/npm_and_yarn/wordpr... (fada19)
by
unknown
19:36 queued 17:22
created
core/db_models/EEM_Term_Taxonomy.model.php 2 patches
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.
Indentation   +116 added lines, -116 removed lines patch added patch discarded remove patch
@@ -11,128 +11,128 @@
 block discarded – undo
11 11
 class EEM_Term_Taxonomy extends EEM_Base
12 12
 {
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 18
 
19
-    protected function __construct($timezone = null)
20
-    {
21
-        $this->singular_item = esc_html__('Term Taxonomy', 'event_espresso');
22
-        $this->plural_item = esc_html__('Term Taxonomy', 'event_espresso');
23
-        $this->_tables = array(
24
-            'Term_Taxonomy' => new EE_Primary_Table('term_taxonomy', 'term_taxonomy_id'),
25
-        );
26
-        $this->_fields = array(
27
-            'Term_Taxonomy' => array(
28
-                'term_taxonomy_id' => new EE_Primary_Key_Int_Field(
29
-                    'term_taxonomy_id',
30
-                    esc_html__('Term-Taxonomy ID', 'event_espresso')
31
-                ),
32
-                'term_id'          => new EE_Foreign_Key_Int_Field(
33
-                    'term_id',
34
-                    esc_html__("Term Id", "event_espresso"),
35
-                    false,
36
-                    0,
37
-                    'Term'
38
-                ),
39
-                'taxonomy'         => new EE_Plain_Text_Field(
40
-                    'taxonomy',
41
-                    esc_html__('Taxonomy Name', 'event_espresso'),
42
-                    false,
43
-                    'category'
44
-                ),
45
-                'description'      => new EE_Post_Content_Field(
46
-                    'description',
47
-                    esc_html__("Description of Term", "event_espresso"),
48
-                    false,
49
-                    ''
50
-                ),
51
-                'parent'           => new EE_Integer_Field('parent', esc_html__("Parent Term ID", "event_espresso"), false, 0),
52
-                'term_count'       => new EE_Integer_Field(
53
-                    'count',
54
-                    esc_html__("Count of Objects attached", 'event_espresso'),
55
-                    false,
56
-                    0
57
-                ),
58
-            ),
59
-        );
60
-        $this->_model_relations = array(
61
-            'Term_Relationship' => new EE_Has_Many_Relation(),
62
-            'Term'              => new EE_Belongs_To_Relation(),
63
-        );
64
-        $cpt_models = array_keys(EE_Registry::instance()->cpt_models());
65
-        foreach ($cpt_models as $model_name) {
66
-            $this->_model_relations[ $model_name ] = new EE_HABTM_Relation('Term_Relationship');
67
-        }
68
-        $this->_wp_core_model = true;
69
-        $this->_indexes = array(
70
-            'term_id_taxonomy' => new EE_Unique_Index(array('term_id', 'taxonomy')),
71
-        );
72
-        $path_to_tax_model = '';
73
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
74
-        $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Taxonomy_Protected(
75
-            $path_to_tax_model
76
-        );
77
-        $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = false;
78
-        $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = false;
79
-        // add cap restrictions for editing relating to the "ee_edit_*"
80
-        $this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_event_category'] = new EE_Default_Where_Conditions(
81
-            array(
82
-                $path_to_tax_model . 'taxonomy*ee_edit_event_category' => array('!=', 'espresso_event_categories'),
83
-            )
84
-        );
85
-        $this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_venue_category'] = new EE_Default_Where_Conditions(
86
-            array(
87
-                $path_to_tax_model . 'taxonomy*ee_edit_venue_category' => array('!=', 'espresso_venue_categories'),
88
-            )
89
-        );
90
-        $this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_event_type'] = new EE_Default_Where_Conditions(
91
-            array(
92
-                $path_to_tax_model . 'taxonomy*ee_edit_event_type' => array('!=', 'espresso_event_type'),
93
-            )
94
-        );
95
-        // add cap restrictions for deleting relating to the "ee_deleting_*"
96
-        $this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_event_category'] = new EE_Default_Where_Conditions(
97
-            array(
98
-                $path_to_tax_model . 'taxonomy*ee_delete_event_category' => array('!=', 'espresso_event_categories'),
99
-            )
100
-        );
101
-        $this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_venue_category'] = new EE_Default_Where_Conditions(
102
-            array(
103
-                $path_to_tax_model . 'taxonomy*ee_delete_venue_category' => array('!=', 'espresso_venue_categories'),
104
-            )
105
-        );
106
-        $this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_event_type'] = new EE_Default_Where_Conditions(
107
-            array(
108
-                $path_to_tax_model . 'taxonomy*ee_delete_event_type' => array('!=', 'espresso_event_type'),
109
-            )
110
-        );
111
-        parent::__construct($timezone);
112
-        add_filter('FHEE__Read__create_model_query_params', array('EEM_Term_Taxonomy', 'rest_api_query_params'), 10, 3);
113
-    }
19
+	protected function __construct($timezone = null)
20
+	{
21
+		$this->singular_item = esc_html__('Term Taxonomy', 'event_espresso');
22
+		$this->plural_item = esc_html__('Term Taxonomy', 'event_espresso');
23
+		$this->_tables = array(
24
+			'Term_Taxonomy' => new EE_Primary_Table('term_taxonomy', 'term_taxonomy_id'),
25
+		);
26
+		$this->_fields = array(
27
+			'Term_Taxonomy' => array(
28
+				'term_taxonomy_id' => new EE_Primary_Key_Int_Field(
29
+					'term_taxonomy_id',
30
+					esc_html__('Term-Taxonomy ID', 'event_espresso')
31
+				),
32
+				'term_id'          => new EE_Foreign_Key_Int_Field(
33
+					'term_id',
34
+					esc_html__("Term Id", "event_espresso"),
35
+					false,
36
+					0,
37
+					'Term'
38
+				),
39
+				'taxonomy'         => new EE_Plain_Text_Field(
40
+					'taxonomy',
41
+					esc_html__('Taxonomy Name', 'event_espresso'),
42
+					false,
43
+					'category'
44
+				),
45
+				'description'      => new EE_Post_Content_Field(
46
+					'description',
47
+					esc_html__("Description of Term", "event_espresso"),
48
+					false,
49
+					''
50
+				),
51
+				'parent'           => new EE_Integer_Field('parent', esc_html__("Parent Term ID", "event_espresso"), false, 0),
52
+				'term_count'       => new EE_Integer_Field(
53
+					'count',
54
+					esc_html__("Count of Objects attached", 'event_espresso'),
55
+					false,
56
+					0
57
+				),
58
+			),
59
+		);
60
+		$this->_model_relations = array(
61
+			'Term_Relationship' => new EE_Has_Many_Relation(),
62
+			'Term'              => new EE_Belongs_To_Relation(),
63
+		);
64
+		$cpt_models = array_keys(EE_Registry::instance()->cpt_models());
65
+		foreach ($cpt_models as $model_name) {
66
+			$this->_model_relations[ $model_name ] = new EE_HABTM_Relation('Term_Relationship');
67
+		}
68
+		$this->_wp_core_model = true;
69
+		$this->_indexes = array(
70
+			'term_id_taxonomy' => new EE_Unique_Index(array('term_id', 'taxonomy')),
71
+		);
72
+		$path_to_tax_model = '';
73
+		$this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
74
+		$this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Taxonomy_Protected(
75
+			$path_to_tax_model
76
+		);
77
+		$this->_cap_restriction_generators[ EEM_Base::caps_edit ] = false;
78
+		$this->_cap_restriction_generators[ EEM_Base::caps_delete ] = false;
79
+		// add cap restrictions for editing relating to the "ee_edit_*"
80
+		$this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_event_category'] = new EE_Default_Where_Conditions(
81
+			array(
82
+				$path_to_tax_model . 'taxonomy*ee_edit_event_category' => array('!=', 'espresso_event_categories'),
83
+			)
84
+		);
85
+		$this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_venue_category'] = new EE_Default_Where_Conditions(
86
+			array(
87
+				$path_to_tax_model . 'taxonomy*ee_edit_venue_category' => array('!=', 'espresso_venue_categories'),
88
+			)
89
+		);
90
+		$this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_event_type'] = new EE_Default_Where_Conditions(
91
+			array(
92
+				$path_to_tax_model . 'taxonomy*ee_edit_event_type' => array('!=', 'espresso_event_type'),
93
+			)
94
+		);
95
+		// add cap restrictions for deleting relating to the "ee_deleting_*"
96
+		$this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_event_category'] = new EE_Default_Where_Conditions(
97
+			array(
98
+				$path_to_tax_model . 'taxonomy*ee_delete_event_category' => array('!=', 'espresso_event_categories'),
99
+			)
100
+		);
101
+		$this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_venue_category'] = new EE_Default_Where_Conditions(
102
+			array(
103
+				$path_to_tax_model . 'taxonomy*ee_delete_venue_category' => array('!=', 'espresso_venue_categories'),
104
+			)
105
+		);
106
+		$this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_event_type'] = new EE_Default_Where_Conditions(
107
+			array(
108
+				$path_to_tax_model . 'taxonomy*ee_delete_event_type' => array('!=', 'espresso_event_type'),
109
+			)
110
+		);
111
+		parent::__construct($timezone);
112
+		add_filter('FHEE__Read__create_model_query_params', array('EEM_Term_Taxonomy', 'rest_api_query_params'), 10, 3);
113
+	}
114 114
 
115 115
 
116 116
 
117
-    /**
118
-     * Makes sure that during REST API queries, we only return term-taxonomies
119
-     * for term taxonomies which should be shown in the rest api
120
-     *
121
-     * @param array    $model_query_params
122
-     * @param array    $querystring_query_params
123
-     * @param EEM_Base $model
124
-     * @return array
125
-     */
126
-    public static function rest_api_query_params($model_query_params, $querystring_query_params, $model)
127
-    {
128
-        if ($model === EEM_Term_Taxonomy::instance()) {
129
-            $taxonomies = get_taxonomies(array('show_in_rest' => true));
130
-            if (! empty($taxonomies)) {
131
-                $model_query_params[0]['taxonomy'] = array('IN', $taxonomies);
132
-            }
133
-        }
134
-        return $model_query_params;
135
-    }
117
+	/**
118
+	 * Makes sure that during REST API queries, we only return term-taxonomies
119
+	 * for term taxonomies which should be shown in the rest api
120
+	 *
121
+	 * @param array    $model_query_params
122
+	 * @param array    $querystring_query_params
123
+	 * @param EEM_Base $model
124
+	 * @return array
125
+	 */
126
+	public static function rest_api_query_params($model_query_params, $querystring_query_params, $model)
127
+	{
128
+		if ($model === EEM_Term_Taxonomy::instance()) {
129
+			$taxonomies = get_taxonomies(array('show_in_rest' => true));
130
+			if (! empty($taxonomies)) {
131
+				$model_query_params[0]['taxonomy'] = array('IN', $taxonomies);
132
+			}
133
+		}
134
+		return $model_query_params;
135
+	}
136 136
 }
137 137
 // End of file EEM_Term_Taxonomy.model.php
138 138
 // Location: /includes/models/EEM_Term_Taxonomy.model.php
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_Extra_Meta.model.php 2 patches
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.
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -17,33 +17,33 @@
 block discarded – undo
17 17
 class EEM_Extra_Meta extends EEM_Base
18 18
 {
19 19
 
20
-    // private instance of the Attendee object
21
-    protected static $_instance = null;
20
+	// private instance of the Attendee object
21
+	protected static $_instance = null;
22 22
 
23
-    protected function __construct($timezone = null)
24
-    {
25
-        $this->singular_item = esc_html__('Extra Meta', 'event_espresso');
26
-        $this->plural_item = esc_html__('Extra Metas', 'event_espresso');
27
-        $this->_tables = array(
28
-            'Extra_Meta' => new EE_Primary_Table('esp_extra_meta', 'EXM_ID')
29
-        );
30
-        $models_this_can_attach_to = array_keys(EE_Registry::instance()->non_abstract_db_models);
31
-        $this->_fields = array(
32
-            'Extra_Meta' => array(
33
-                'EXM_ID' => new EE_Primary_Key_Int_Field('EXM_ID', esc_html__("Extra Meta ID", "event_espresso")),
34
-                'OBJ_ID' => new EE_Foreign_Key_Int_Field('OBJ_ID', esc_html__("Primary Key of Attached Thing", "event_espresso"), false, 0, $models_this_can_attach_to),
35
-                'EXM_type' => new EE_Any_Foreign_Model_Name_Field('EXM_type', esc_html__("Model of Attached Thing", "event_espresso"), false, 'Transaction', $models_this_can_attach_to),
36
-                'EXM_key' => new EE_Plain_Text_Field('EXM_key', esc_html__("Meta Key", "event_espresso"), false, ''),
37
-                'EXM_value' => new EE_Maybe_Serialized_Text_Field('EXM_value', esc_html__("Meta Value", "event_espresso"), true)
23
+	protected function __construct($timezone = null)
24
+	{
25
+		$this->singular_item = esc_html__('Extra Meta', 'event_espresso');
26
+		$this->plural_item = esc_html__('Extra Metas', 'event_espresso');
27
+		$this->_tables = array(
28
+			'Extra_Meta' => new EE_Primary_Table('esp_extra_meta', 'EXM_ID')
29
+		);
30
+		$models_this_can_attach_to = array_keys(EE_Registry::instance()->non_abstract_db_models);
31
+		$this->_fields = array(
32
+			'Extra_Meta' => array(
33
+				'EXM_ID' => new EE_Primary_Key_Int_Field('EXM_ID', esc_html__("Extra Meta ID", "event_espresso")),
34
+				'OBJ_ID' => new EE_Foreign_Key_Int_Field('OBJ_ID', esc_html__("Primary Key of Attached Thing", "event_espresso"), false, 0, $models_this_can_attach_to),
35
+				'EXM_type' => new EE_Any_Foreign_Model_Name_Field('EXM_type', esc_html__("Model of Attached Thing", "event_espresso"), false, 'Transaction', $models_this_can_attach_to),
36
+				'EXM_key' => new EE_Plain_Text_Field('EXM_key', esc_html__("Meta Key", "event_espresso"), false, ''),
37
+				'EXM_value' => new EE_Maybe_Serialized_Text_Field('EXM_value', esc_html__("Meta Value", "event_espresso"), true)
38 38
 
39
-            ));
40
-        $this->_model_relations = array();
41
-        foreach ($models_this_can_attach_to as $model) {
42
-            $this->_model_relations[ $model ] = new EE_Belongs_To_Any_Relation();
43
-        }
44
-        foreach ($this->cap_contexts_to_cap_action_map() as $cap_context => $action) {
45
-            $this->_cap_restriction_generators[ $cap_context ] = new EE_Restriction_Generator_Meta('EXM_key', 'EXM_value');
46
-        }
47
-        parent::__construct($timezone);
48
-    }
39
+			));
40
+		$this->_model_relations = array();
41
+		foreach ($models_this_can_attach_to as $model) {
42
+			$this->_model_relations[ $model ] = new EE_Belongs_To_Any_Relation();
43
+		}
44
+		foreach ($this->cap_contexts_to_cap_action_map() as $cap_context => $action) {
45
+			$this->_cap_restriction_generators[ $cap_context ] = new EE_Restriction_Generator_Meta('EXM_key', 'EXM_value');
46
+		}
47
+		parent::__construct($timezone);
48
+	}
49 49
 }
Please login to merge, or discard this patch.
core/db_models/EEM_Question_Group.model.php 2 patches
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.
Indentation   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -11,58 +11,58 @@
 block discarded – undo
11 11
  */
12 12
 class EEM_Question_Group extends EEM_Soft_Delete_Base
13 13
 {
14
-    const system_personal = 1;
15
-    const system_address = 2;
16
-    // private instance of the Attendee object
17
-    protected static $_instance = null;
14
+	const system_personal = 1;
15
+	const system_address = 2;
16
+	// private instance of the Attendee object
17
+	protected static $_instance = null;
18 18
 
19 19
 
20
-    protected function __construct($timezone = null)
21
-    {
22
-        $this->singular_item = esc_html__('Question Group', 'event_espresso');
23
-        $this->plural_item = esc_html__('Question Groups', 'event_espresso');
20
+	protected function __construct($timezone = null)
21
+	{
22
+		$this->singular_item = esc_html__('Question Group', 'event_espresso');
23
+		$this->plural_item = esc_html__('Question Groups', 'event_espresso');
24 24
 
25
-        $this->_tables = array(
26
-            'Question_Group' => new EE_Primary_Table('esp_question_group', 'QSG_ID')
27
-        );
28
-        $this->_fields = array(
29
-            'Question_Group' => array(
30
-                'QSG_ID' => new EE_Primary_Key_Int_Field('QSG_ID', esc_html__('Question Group ID', 'event_espresso')),
31
-                'QSG_name' => new EE_Plain_Text_Field('QSG_name', esc_html__('Question Group Name', 'event_espresso'), false, ''),
32
-                'QSG_identifier' => new EE_Plain_Text_Field('QSG_identifier', esc_html__('Text ID for question Group', 'event_espresso'), false, ''),
33
-                'QSG_desc' => new EE_Post_Content_Field('QSG_desc', esc_html__('Description of Question Group', 'event_espresso'), true, ''),
34
-                'QSG_order' => new EE_Integer_Field('QSG_order', esc_html__('Order in which to show the question group', 'event_espresso'), true, 0),
35
-                'QSG_show_group_name' => new EE_Boolean_Field('QSG_show_group_name', esc_html__('Flag indicating whether to show the group\'s name on the registration page', 'event_espresso'), false, true),
36
-                'QSG_show_group_desc' => new EE_Boolean_Field('QSG_show_group_desc', esc_html__('Flag indicating whether to show the group\s description on the registration page', 'event_espresso'), false, false),
37
-                'QSG_wp_user' => new EE_WP_User_Field('QSG_wp_user', esc_html__('Question Group Creator ID', 'event_espresso'), false),
38
-                'QSG_system' => new EE_Integer_Field('QSG_system', esc_html__('Indicate IF this is a system group and if it is what system group it corresponds to.', 'event_espresso'), false, 0),
39
-                'QSG_deleted' => new EE_Trashed_Flag_Field('QSG_deleted', esc_html__('Flag indicating this question group was deleted', 'event_espresso'), false, false)
40
-            )
41
-        );
42
-        $this->_model_relations = array(
43
-            'Question' => new EE_HABTM_Relation('Question_Group_Question'),
44
-            'Event' => new EE_HABTM_Relation('Event_Question_Group'),
45
-            'Event_Question_Group' => new EE_Has_Many_Relation(),
46
-            'WP_User' => new EE_Belongs_To_Relation(),
47
-        );
48
-        // this model is generally available for reading
49
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
50
-        $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Reg_Form('QSG_system');
51
-        $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Reg_Form('QSG_system');
52
-        $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Reg_Form('QSG_system');
53
-        parent::__construct($timezone);
54
-    }
55
-    /**
56
-     * searches the db for the question group with the latest question order and returns that value.
57
-     * @access public
58
-     * @return int
59
-     */
60
-    public function get_latest_question_group_order()
61
-    {
62
-        $columns_to_select = array(
63
-            'max_order' => array("MAX(QSG_order)","%d")
64
-            );
65
-        $max = $this->_get_all_wpdb_results(array(), ARRAY_A, $columns_to_select);
66
-        return $max[0]['max_order'];
67
-    }
25
+		$this->_tables = array(
26
+			'Question_Group' => new EE_Primary_Table('esp_question_group', 'QSG_ID')
27
+		);
28
+		$this->_fields = array(
29
+			'Question_Group' => array(
30
+				'QSG_ID' => new EE_Primary_Key_Int_Field('QSG_ID', esc_html__('Question Group ID', 'event_espresso')),
31
+				'QSG_name' => new EE_Plain_Text_Field('QSG_name', esc_html__('Question Group Name', 'event_espresso'), false, ''),
32
+				'QSG_identifier' => new EE_Plain_Text_Field('QSG_identifier', esc_html__('Text ID for question Group', 'event_espresso'), false, ''),
33
+				'QSG_desc' => new EE_Post_Content_Field('QSG_desc', esc_html__('Description of Question Group', 'event_espresso'), true, ''),
34
+				'QSG_order' => new EE_Integer_Field('QSG_order', esc_html__('Order in which to show the question group', 'event_espresso'), true, 0),
35
+				'QSG_show_group_name' => new EE_Boolean_Field('QSG_show_group_name', esc_html__('Flag indicating whether to show the group\'s name on the registration page', 'event_espresso'), false, true),
36
+				'QSG_show_group_desc' => new EE_Boolean_Field('QSG_show_group_desc', esc_html__('Flag indicating whether to show the group\s description on the registration page', 'event_espresso'), false, false),
37
+				'QSG_wp_user' => new EE_WP_User_Field('QSG_wp_user', esc_html__('Question Group Creator ID', 'event_espresso'), false),
38
+				'QSG_system' => new EE_Integer_Field('QSG_system', esc_html__('Indicate IF this is a system group and if it is what system group it corresponds to.', 'event_espresso'), false, 0),
39
+				'QSG_deleted' => new EE_Trashed_Flag_Field('QSG_deleted', esc_html__('Flag indicating this question group was deleted', 'event_espresso'), false, false)
40
+			)
41
+		);
42
+		$this->_model_relations = array(
43
+			'Question' => new EE_HABTM_Relation('Question_Group_Question'),
44
+			'Event' => new EE_HABTM_Relation('Event_Question_Group'),
45
+			'Event_Question_Group' => new EE_Has_Many_Relation(),
46
+			'WP_User' => new EE_Belongs_To_Relation(),
47
+		);
48
+		// this model is generally available for reading
49
+		$this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
50
+		$this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Reg_Form('QSG_system');
51
+		$this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Reg_Form('QSG_system');
52
+		$this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Reg_Form('QSG_system');
53
+		parent::__construct($timezone);
54
+	}
55
+	/**
56
+	 * searches the db for the question group with the latest question order and returns that value.
57
+	 * @access public
58
+	 * @return int
59
+	 */
60
+	public function get_latest_question_group_order()
61
+	{
62
+		$columns_to_select = array(
63
+			'max_order' => array("MAX(QSG_order)","%d")
64
+			);
65
+		$max = $this->_get_all_wpdb_results(array(), ARRAY_A, $columns_to_select);
66
+		return $max[0]['max_order'];
67
+	}
68 68
 }
Please login to merge, or discard this patch.
core/db_models/EEM_Attendee.model.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -284,8 +284,8 @@  discard block
 block discarded – undo
284 284
      */
285 285
     public function get_attendee_field_for_system_question($system_question_string)
286 286
     {
287
-        return isset($this->_system_question_to_attendee_field_name[ $system_question_string ])
288
-            ? $this->_system_question_to_attendee_field_name[ $system_question_string ]
287
+        return isset($this->_system_question_to_attendee_field_name[$system_question_string])
288
+            ? $this->_system_question_to_attendee_field_name[$system_question_string]
289 289
             : null;
290 290
     }
291 291
 
@@ -353,7 +353,7 @@  discard block
 block discarded – undo
353 353
             return false;
354 354
         }
355 355
         $attendee = $this->get_all(array($where_cols_n_values));
356
-        if (! empty($attendee)) {
356
+        if ( ! empty($attendee)) {
357 357
             return array_shift($attendee);
358 358
         }
359 359
         return false;
Please login to merge, or discard this patch.
Indentation   +419 added lines, -419 removed lines patch added patch discarded remove patch
@@ -13,432 +13,432 @@
 block discarded – undo
13 13
 class EEM_Attendee extends EEM_CPT_Base
14 14
 {
15 15
 
16
-    // private instance of the Attendee object
17
-    protected static $_instance = null;
16
+	// private instance of the Attendee object
17
+	protected static $_instance = null;
18 18
 
19
-    /**
20
-     * QST_system for questions are strings not integers now,
21
-     * so these constants are deprecated.
22
-     * Please instead use the EEM_Attendee::system_question_* constants
23
-     *
24
-     * @deprecated
25
-     */
26
-    const fname_question_id = 1;
19
+	/**
20
+	 * QST_system for questions are strings not integers now,
21
+	 * so these constants are deprecated.
22
+	 * Please instead use the EEM_Attendee::system_question_* constants
23
+	 *
24
+	 * @deprecated
25
+	 */
26
+	const fname_question_id = 1;
27 27
 
28
-    /**
29
-     * @deprecated
30
-     */
31
-    const lname_question_id = 2;
28
+	/**
29
+	 * @deprecated
30
+	 */
31
+	const lname_question_id = 2;
32 32
 
33 33
 
34
-    /**
35
-     * @deprecated
36
-     */
37
-    const email_question_id = 3;
34
+	/**
35
+	 * @deprecated
36
+	 */
37
+	const email_question_id = 3;
38 38
 
39 39
 
40
-    /**
41
-     * @deprecated
42
-     */
43
-    const address_question_id = 4;
40
+	/**
41
+	 * @deprecated
42
+	 */
43
+	const address_question_id = 4;
44 44
 
45 45
 
46
-    /**
47
-     * @deprecated
48
-     */
49
-    const address2_question_id = 5;
46
+	/**
47
+	 * @deprecated
48
+	 */
49
+	const address2_question_id = 5;
50 50
 
51
-
52
-    /**
53
-     * @deprecated
54
-     */
55
-    const city_question_id = 6;
56
-
57
-
58
-    /**
59
-     * @deprecated
60
-     */
61
-    const state_question_id = 7;
62
-
63
-
64
-    /**
65
-     * @deprecated
66
-     */
67
-    const country_question_id = 8;
68
-
69
-
70
-    /**
71
-     * @deprecated
72
-     */
73
-    const zip_question_id = 9;
74
-
75
-
76
-    /**
77
-     * @deprecated
78
-     */
79
-    const phone_question_id = 10;
80
-
81
-    /**
82
-     * When looking for questions that correspond to attendee fields,
83
-     * look for the question with this QST_system value.
84
-     * These replace the old constants like EEM_Attendee::*_question_id
85
-     */
86
-    const system_question_fname = 'fname';
87
-
88
-    const system_question_lname = 'lname';
89
-
90
-    const system_question_email = 'email';
91
-
92
-    const system_question_email_confirm = 'email_confirm';
93
-
94
-    const system_question_address = 'address';
95
-
96
-    const system_question_address2 = 'address2';
97
-
98
-    const system_question_city = 'city';
99
-
100
-    const system_question_state = 'state';
101
-
102
-    const system_question_country = 'country';
103
-
104
-    const system_question_zip = 'zip';
105
-
106
-    const system_question_phone = 'phone';
107
-
108
-    /**
109
-     * Keys are all the EEM_Attendee::system_question_* constants, which are
110
-     * also all the values of QST_system in the questions table, and values
111
-     * are their corresponding Attendee field names
112
-     *
113
-     * @var array
114
-     */
115
-    protected $_system_question_to_attendee_field_name = array(
116
-        EEM_Attendee::system_question_fname    => 'ATT_fname',
117
-        EEM_Attendee::system_question_lname    => 'ATT_lname',
118
-        EEM_Attendee::system_question_email    => 'ATT_email',
119
-        EEM_Attendee::system_question_address  => 'ATT_address',
120
-        EEM_Attendee::system_question_address2 => 'ATT_address2',
121
-        EEM_Attendee::system_question_city     => 'ATT_city',
122
-        EEM_Attendee::system_question_state    => 'STA_ID',
123
-        EEM_Attendee::system_question_country  => 'CNT_ISO',
124
-        EEM_Attendee::system_question_zip      => 'ATT_zip',
125
-        EEM_Attendee::system_question_phone    => 'ATT_phone',
126
-    );
127
-
128
-
129
-
130
-    /**
131
-     * EEM_Attendee constructor.
132
-     *
133
-     * @param null              $timezone
134
-     * @param ModelFieldFactory $model_field_factory
135
-     * @throws EE_Error
136
-     * @throws InvalidArgumentException
137
-     */
138
-    protected function __construct($timezone = null, ModelFieldFactory $model_field_factory)
139
-    {
140
-        $this->singular_item = esc_html__('Attendee', 'event_espresso');
141
-        $this->plural_item = esc_html__('Attendees', 'event_espresso');
142
-        $this->_tables = array(
143
-            'Attendee_CPT'  => new EE_Primary_Table('posts', 'ID'),
144
-            'Attendee_Meta' => new EE_Secondary_Table(
145
-                'esp_attendee_meta',
146
-                'ATTM_ID',
147
-                'ATT_ID'
148
-            ),
149
-        );
150
-        $this->_fields = array(
151
-            'Attendee_CPT'  => array(
152
-                'ATT_ID'        => $model_field_factory->createPrimaryKeyIntField(
153
-                    'ID',
154
-                    esc_html__('Attendee ID', 'event_espresso')
155
-                ),
156
-                'ATT_full_name' => $model_field_factory->createPlainTextField(
157
-                    'post_title',
158
-                    esc_html__('Attendee Full Name', 'event_espresso'),
159
-                    false,
160
-                    esc_html__('Unknown', 'event_espresso')
161
-                ),
162
-                'ATT_bio'       => $model_field_factory->createPostContentField(
163
-                    'post_content',
164
-                    esc_html__('Attendee Biography', 'event_espresso'),
165
-                    false,
166
-                    esc_html__('No Biography Provided', 'event_espresso')
167
-                ),
168
-                'ATT_slug'      => $model_field_factory->createSlugField(
169
-                    'post_name',
170
-                    esc_html__('Attendee URL Slug', 'event_espresso')
171
-                ),
172
-                'ATT_created'   => $model_field_factory->createDatetimeField(
173
-                    'post_date',
174
-                    esc_html__('Time Attendee Created', 'event_espresso')
175
-                ),
176
-                'ATT_short_bio' => $model_field_factory->createSimpleHtmlField(
177
-                    'post_excerpt',
178
-                    esc_html__('Attendee Short Biography', 'event_espresso'),
179
-                    true,
180
-                    esc_html__('No Biography Provided', 'event_espresso')
181
-                ),
182
-                'ATT_modified'  => $model_field_factory->createDatetimeField(
183
-                    'post_modified',
184
-                    esc_html__('Time Attendee Last Modified', 'event_espresso')
185
-                ),
186
-                'ATT_author'    => $model_field_factory->createWpUserField(
187
-                    'post_author',
188
-                    esc_html__('Creator ID of the first Event attended', 'event_espresso'),
189
-                    false
190
-                ),
191
-                'ATT_parent'    => $model_field_factory->createDbOnlyIntField(
192
-                    'post_parent',
193
-                    esc_html__('Parent Attendee (unused)', 'event_espresso'),
194
-                    false,
195
-                    0
196
-                ),
197
-                'post_type'     => $model_field_factory->createWpPostTypeField('espresso_attendees'),
198
-                'status'        => $model_field_factory->createWpPostStatusField(
199
-                    'post_status',
200
-                    esc_html__('Attendee Status', 'event_espresso'),
201
-                    false,
202
-                    'publish'
203
-                ),
204
-                'password' => new EE_Password_Field(
205
-                    'post_password',
206
-                    esc_html__('Password', 'event_espresso'),
207
-                    false,
208
-                    '',
209
-                    array(
210
-                        'ATT_bio',
211
-                        'ATT_short_bio',
212
-                        'ATT_address',
213
-                        'ATT_address2',
214
-                        'ATT_city',
215
-                        'STA_ID',
216
-                        'CNT_ISO',
217
-                        'ATT_zip',
218
-                        'ATT_email',
219
-                        'ATT_phone'
220
-                    )
221
-                )
222
-            ),
223
-            'Attendee_Meta' => array(
224
-                'ATTM_ID'      => $model_field_factory->createDbOnlyIntField(
225
-                    'ATTM_ID',
226
-                    esc_html__('Attendee Meta Row ID', 'event_espresso'),
227
-                    false
228
-                ),
229
-                'ATT_ID_fk'    => $model_field_factory->createDbOnlyIntField(
230
-                    'ATT_ID',
231
-                    esc_html__('Foreign Key to Attendee in Post Table', 'event_espresso'),
232
-                    false
233
-                ),
234
-                'ATT_fname'    => $model_field_factory->createPlainTextField(
235
-                    'ATT_fname',
236
-                    esc_html__('First Name', 'event_espresso')
237
-                ),
238
-                'ATT_lname'    => $model_field_factory->createPlainTextField(
239
-                    'ATT_lname',
240
-                    esc_html__('Last Name', 'event_espresso')
241
-                ),
242
-                'ATT_address'  => $model_field_factory->createPlainTextField(
243
-                    'ATT_address',
244
-                    esc_html__('Address Part 1', 'event_espresso')
245
-                ),
246
-                'ATT_address2' => $model_field_factory->createPlainTextField(
247
-                    'ATT_address2',
248
-                    esc_html__('Address Part 2', 'event_espresso')
249
-                ),
250
-                'ATT_city'     => $model_field_factory->createPlainTextField(
251
-                    'ATT_city',
252
-                    esc_html__('City', 'event_espresso')
253
-                ),
254
-                'STA_ID'       => $model_field_factory->createForeignKeyIntField(
255
-                    'STA_ID',
256
-                    esc_html__('State', 'event_espresso'),
257
-                    true,
258
-                    0,
259
-                    'State'
260
-                ),
261
-                'CNT_ISO'      => $model_field_factory->createForeignKeyStringField(
262
-                    'CNT_ISO',
263
-                    esc_html__('Country', 'event_espresso'),
264
-                    true,
265
-                    '',
266
-                    'Country'
267
-                ),
268
-                'ATT_zip'      => $model_field_factory->createPlainTextField(
269
-                    'ATT_zip',
270
-                    esc_html__('ZIP/Postal Code', 'event_espresso')
271
-                ),
272
-                'ATT_email'    => $model_field_factory->createEmailField(
273
-                    'ATT_email',
274
-                    esc_html__('Email Address', 'event_espresso')
275
-                ),
276
-                'ATT_phone'    => $model_field_factory->createPlainTextField(
277
-                    'ATT_phone',
278
-                    esc_html__('Phone', 'event_espresso')
279
-                ),
280
-            ),
281
-        );
282
-        $this->_model_relations = array(
283
-            'Registration'      => new EE_Has_Many_Relation(),
284
-            'State'             => new EE_Belongs_To_Relation(),
285
-            'Country'           => new EE_Belongs_To_Relation(),
286
-            'Event'             => new EE_HABTM_Relation('Registration', false),
287
-            'WP_User'           => new EE_Belongs_To_Relation(),
288
-            'Message'           => new EE_Has_Many_Any_Relation(false),
289
-            // allow deletion of attendees even if they have messages in the queue for them.
290
-            'Term_Relationship' => new EE_Has_Many_Relation(),
291
-            'Term_Taxonomy'     => new EE_HABTM_Relation('Term_Relationship'),
292
-        );
293
-        $this->_caps_slug = 'contacts';
294
-        $this->model_chain_to_password = '';
295
-        parent::__construct($timezone);
296
-    }
297
-
298
-
299
-
300
-    /**
301
-     * Gets the name of the field on the attendee model corresponding to the system question string
302
-     * which should be one of the keys from EEM_Attendee::_system_question_to_attendee_field_name
303
-     *
304
-     * @param string $system_question_string
305
-     * @return string|null if not found
306
-     */
307
-    public function get_attendee_field_for_system_question($system_question_string)
308
-    {
309
-        return isset($this->_system_question_to_attendee_field_name[ $system_question_string ])
310
-            ? $this->_system_question_to_attendee_field_name[ $system_question_string ]
311
-            : null;
312
-    }
313
-
314
-
315
-
316
-    /**
317
-     * Gets mapping from esp_question.QST_system values to their corresponding attendee field names
318
-     *
319
-     * @return array
320
-     */
321
-    public function system_question_to_attendee_field_mapping()
322
-    {
323
-        return $this->_system_question_to_attendee_field_name;
324
-    }
325
-
326
-
327
-
328
-    /**
329
-     * Gets all the attendees for a transaction (by using the esp_registration as a join table)
330
-     *
331
-     * @param EE_Transaction /int $transaction_id_or_obj EE_Transaction or its ID
332
-     * @return EE_Attendee[]|EE_Base_Class[]
333
-     * @throws EE_Error
334
-     */
335
-    public function get_attendees_for_transaction($transaction_id_or_obj)
336
-    {
337
-        return $this->get_all(
338
-            array(
339
-                array(
340
-                    'Registration.Transaction.TXN_ID' => $transaction_id_or_obj instanceof EE_Transaction
341
-                        ? $transaction_id_or_obj->ID()
342
-                        : $transaction_id_or_obj,
343
-                ),
344
-            )
345
-        );
346
-    }
347
-
348
-
349
-
350
-    /**
351
-     * retrieve  a single attendee from db via their ID
352
-     *
353
-     * @param $ATT_ID
354
-     * @return mixed array on success, FALSE on fail
355
-     * @deprecated
356
-     */
357
-    public function get_attendee_by_ID($ATT_ID = false)
358
-    {
359
-        // retrieve a particular EE_Attendee
360
-        return $this->get_one_by_ID($ATT_ID);
361
-    }
362
-
363
-
364
-
365
-    /**
366
-     * retrieve  a single attendee from db via their ID
367
-     *
368
-     * @param array $where_cols_n_values
369
-     * @return mixed array on success, FALSE on fail
370
-     * @throws EE_Error
371
-     */
372
-    public function get_attendee($where_cols_n_values = array())
373
-    {
374
-        if (empty($where_cols_n_values)) {
375
-            return false;
376
-        }
377
-        $attendee = $this->get_all(array($where_cols_n_values));
378
-        if (! empty($attendee)) {
379
-            return array_shift($attendee);
380
-        }
381
-        return false;
382
-    }
383
-
384
-
385
-
386
-    /**
387
-     * Search for an existing Attendee record in the DB
388
-     *
389
-     * @param array $where_cols_n_values
390
-     * @return bool|mixed
391
-     * @throws EE_Error
392
-     */
393
-    public function find_existing_attendee($where_cols_n_values = null)
394
-    {
395
-        // search by combo of first and last names plus the email address
396
-        $attendee_data_keys = array(
397
-            'ATT_fname' => $this->_ATT_fname,
398
-            'ATT_lname' => $this->_ATT_lname,
399
-            'ATT_email' => $this->_ATT_email,
400
-        );
401
-        // no search params means attendee object already exists.
402
-        $where_cols_n_values = is_array($where_cols_n_values) && ! empty($where_cols_n_values)
403
-            ? $where_cols_n_values
404
-            : $attendee_data_keys;
405
-        $valid_data = true;
406
-        // check for required values
407
-        $valid_data = isset($where_cols_n_values['ATT_fname']) && ! empty($where_cols_n_values['ATT_fname'])
408
-            ? $valid_data
409
-            : false;
410
-        $valid_data = isset($where_cols_n_values['ATT_lname']) && ! empty($where_cols_n_values['ATT_lname'])
411
-            ? $valid_data
412
-            : false;
413
-        $valid_data = isset($where_cols_n_values['ATT_email']) && ! empty($where_cols_n_values['ATT_email'])
414
-            ? $valid_data
415
-            : false;
416
-        if ($valid_data) {
417
-            $attendee = $this->get_attendee($where_cols_n_values);
418
-            if ($attendee instanceof EE_Attendee) {
419
-                return $attendee;
420
-            }
421
-        }
422
-        return false;
423
-    }
424
-
425
-
426
-
427
-    /**
428
-     * Takes an incoming array of EE_Registration ids
429
-     * and sends back a list of corresponding non duplicate EE_Attendee objects.
430
-     *
431
-     * @since  4.3.0
432
-     * @param  array $ids array of EE_Registration ids
433
-     * @return EE_Attendee[]|EE_Base_Class[]
434
-     * @throws EE_Error
435
-     */
436
-    public function get_array_of_contacts_from_reg_ids($ids)
437
-    {
438
-        $ids = (array) $ids;
439
-        $_where = array(
440
-            'Registration.REG_ID' => array('in', $ids),
441
-        );
442
-        return $this->get_all(array($_where));
443
-    }
51
+
52
+	/**
53
+	 * @deprecated
54
+	 */
55
+	const city_question_id = 6;
56
+
57
+
58
+	/**
59
+	 * @deprecated
60
+	 */
61
+	const state_question_id = 7;
62
+
63
+
64
+	/**
65
+	 * @deprecated
66
+	 */
67
+	const country_question_id = 8;
68
+
69
+
70
+	/**
71
+	 * @deprecated
72
+	 */
73
+	const zip_question_id = 9;
74
+
75
+
76
+	/**
77
+	 * @deprecated
78
+	 */
79
+	const phone_question_id = 10;
80
+
81
+	/**
82
+	 * When looking for questions that correspond to attendee fields,
83
+	 * look for the question with this QST_system value.
84
+	 * These replace the old constants like EEM_Attendee::*_question_id
85
+	 */
86
+	const system_question_fname = 'fname';
87
+
88
+	const system_question_lname = 'lname';
89
+
90
+	const system_question_email = 'email';
91
+
92
+	const system_question_email_confirm = 'email_confirm';
93
+
94
+	const system_question_address = 'address';
95
+
96
+	const system_question_address2 = 'address2';
97
+
98
+	const system_question_city = 'city';
99
+
100
+	const system_question_state = 'state';
101
+
102
+	const system_question_country = 'country';
103
+
104
+	const system_question_zip = 'zip';
105
+
106
+	const system_question_phone = 'phone';
107
+
108
+	/**
109
+	 * Keys are all the EEM_Attendee::system_question_* constants, which are
110
+	 * also all the values of QST_system in the questions table, and values
111
+	 * are their corresponding Attendee field names
112
+	 *
113
+	 * @var array
114
+	 */
115
+	protected $_system_question_to_attendee_field_name = array(
116
+		EEM_Attendee::system_question_fname    => 'ATT_fname',
117
+		EEM_Attendee::system_question_lname    => 'ATT_lname',
118
+		EEM_Attendee::system_question_email    => 'ATT_email',
119
+		EEM_Attendee::system_question_address  => 'ATT_address',
120
+		EEM_Attendee::system_question_address2 => 'ATT_address2',
121
+		EEM_Attendee::system_question_city     => 'ATT_city',
122
+		EEM_Attendee::system_question_state    => 'STA_ID',
123
+		EEM_Attendee::system_question_country  => 'CNT_ISO',
124
+		EEM_Attendee::system_question_zip      => 'ATT_zip',
125
+		EEM_Attendee::system_question_phone    => 'ATT_phone',
126
+	);
127
+
128
+
129
+
130
+	/**
131
+	 * EEM_Attendee constructor.
132
+	 *
133
+	 * @param null              $timezone
134
+	 * @param ModelFieldFactory $model_field_factory
135
+	 * @throws EE_Error
136
+	 * @throws InvalidArgumentException
137
+	 */
138
+	protected function __construct($timezone = null, ModelFieldFactory $model_field_factory)
139
+	{
140
+		$this->singular_item = esc_html__('Attendee', 'event_espresso');
141
+		$this->plural_item = esc_html__('Attendees', 'event_espresso');
142
+		$this->_tables = array(
143
+			'Attendee_CPT'  => new EE_Primary_Table('posts', 'ID'),
144
+			'Attendee_Meta' => new EE_Secondary_Table(
145
+				'esp_attendee_meta',
146
+				'ATTM_ID',
147
+				'ATT_ID'
148
+			),
149
+		);
150
+		$this->_fields = array(
151
+			'Attendee_CPT'  => array(
152
+				'ATT_ID'        => $model_field_factory->createPrimaryKeyIntField(
153
+					'ID',
154
+					esc_html__('Attendee ID', 'event_espresso')
155
+				),
156
+				'ATT_full_name' => $model_field_factory->createPlainTextField(
157
+					'post_title',
158
+					esc_html__('Attendee Full Name', 'event_espresso'),
159
+					false,
160
+					esc_html__('Unknown', 'event_espresso')
161
+				),
162
+				'ATT_bio'       => $model_field_factory->createPostContentField(
163
+					'post_content',
164
+					esc_html__('Attendee Biography', 'event_espresso'),
165
+					false,
166
+					esc_html__('No Biography Provided', 'event_espresso')
167
+				),
168
+				'ATT_slug'      => $model_field_factory->createSlugField(
169
+					'post_name',
170
+					esc_html__('Attendee URL Slug', 'event_espresso')
171
+				),
172
+				'ATT_created'   => $model_field_factory->createDatetimeField(
173
+					'post_date',
174
+					esc_html__('Time Attendee Created', 'event_espresso')
175
+				),
176
+				'ATT_short_bio' => $model_field_factory->createSimpleHtmlField(
177
+					'post_excerpt',
178
+					esc_html__('Attendee Short Biography', 'event_espresso'),
179
+					true,
180
+					esc_html__('No Biography Provided', 'event_espresso')
181
+				),
182
+				'ATT_modified'  => $model_field_factory->createDatetimeField(
183
+					'post_modified',
184
+					esc_html__('Time Attendee Last Modified', 'event_espresso')
185
+				),
186
+				'ATT_author'    => $model_field_factory->createWpUserField(
187
+					'post_author',
188
+					esc_html__('Creator ID of the first Event attended', 'event_espresso'),
189
+					false
190
+				),
191
+				'ATT_parent'    => $model_field_factory->createDbOnlyIntField(
192
+					'post_parent',
193
+					esc_html__('Parent Attendee (unused)', 'event_espresso'),
194
+					false,
195
+					0
196
+				),
197
+				'post_type'     => $model_field_factory->createWpPostTypeField('espresso_attendees'),
198
+				'status'        => $model_field_factory->createWpPostStatusField(
199
+					'post_status',
200
+					esc_html__('Attendee Status', 'event_espresso'),
201
+					false,
202
+					'publish'
203
+				),
204
+				'password' => new EE_Password_Field(
205
+					'post_password',
206
+					esc_html__('Password', 'event_espresso'),
207
+					false,
208
+					'',
209
+					array(
210
+						'ATT_bio',
211
+						'ATT_short_bio',
212
+						'ATT_address',
213
+						'ATT_address2',
214
+						'ATT_city',
215
+						'STA_ID',
216
+						'CNT_ISO',
217
+						'ATT_zip',
218
+						'ATT_email',
219
+						'ATT_phone'
220
+					)
221
+				)
222
+			),
223
+			'Attendee_Meta' => array(
224
+				'ATTM_ID'      => $model_field_factory->createDbOnlyIntField(
225
+					'ATTM_ID',
226
+					esc_html__('Attendee Meta Row ID', 'event_espresso'),
227
+					false
228
+				),
229
+				'ATT_ID_fk'    => $model_field_factory->createDbOnlyIntField(
230
+					'ATT_ID',
231
+					esc_html__('Foreign Key to Attendee in Post Table', 'event_espresso'),
232
+					false
233
+				),
234
+				'ATT_fname'    => $model_field_factory->createPlainTextField(
235
+					'ATT_fname',
236
+					esc_html__('First Name', 'event_espresso')
237
+				),
238
+				'ATT_lname'    => $model_field_factory->createPlainTextField(
239
+					'ATT_lname',
240
+					esc_html__('Last Name', 'event_espresso')
241
+				),
242
+				'ATT_address'  => $model_field_factory->createPlainTextField(
243
+					'ATT_address',
244
+					esc_html__('Address Part 1', 'event_espresso')
245
+				),
246
+				'ATT_address2' => $model_field_factory->createPlainTextField(
247
+					'ATT_address2',
248
+					esc_html__('Address Part 2', 'event_espresso')
249
+				),
250
+				'ATT_city'     => $model_field_factory->createPlainTextField(
251
+					'ATT_city',
252
+					esc_html__('City', 'event_espresso')
253
+				),
254
+				'STA_ID'       => $model_field_factory->createForeignKeyIntField(
255
+					'STA_ID',
256
+					esc_html__('State', 'event_espresso'),
257
+					true,
258
+					0,
259
+					'State'
260
+				),
261
+				'CNT_ISO'      => $model_field_factory->createForeignKeyStringField(
262
+					'CNT_ISO',
263
+					esc_html__('Country', 'event_espresso'),
264
+					true,
265
+					'',
266
+					'Country'
267
+				),
268
+				'ATT_zip'      => $model_field_factory->createPlainTextField(
269
+					'ATT_zip',
270
+					esc_html__('ZIP/Postal Code', 'event_espresso')
271
+				),
272
+				'ATT_email'    => $model_field_factory->createEmailField(
273
+					'ATT_email',
274
+					esc_html__('Email Address', 'event_espresso')
275
+				),
276
+				'ATT_phone'    => $model_field_factory->createPlainTextField(
277
+					'ATT_phone',
278
+					esc_html__('Phone', 'event_espresso')
279
+				),
280
+			),
281
+		);
282
+		$this->_model_relations = array(
283
+			'Registration'      => new EE_Has_Many_Relation(),
284
+			'State'             => new EE_Belongs_To_Relation(),
285
+			'Country'           => new EE_Belongs_To_Relation(),
286
+			'Event'             => new EE_HABTM_Relation('Registration', false),
287
+			'WP_User'           => new EE_Belongs_To_Relation(),
288
+			'Message'           => new EE_Has_Many_Any_Relation(false),
289
+			// allow deletion of attendees even if they have messages in the queue for them.
290
+			'Term_Relationship' => new EE_Has_Many_Relation(),
291
+			'Term_Taxonomy'     => new EE_HABTM_Relation('Term_Relationship'),
292
+		);
293
+		$this->_caps_slug = 'contacts';
294
+		$this->model_chain_to_password = '';
295
+		parent::__construct($timezone);
296
+	}
297
+
298
+
299
+
300
+	/**
301
+	 * Gets the name of the field on the attendee model corresponding to the system question string
302
+	 * which should be one of the keys from EEM_Attendee::_system_question_to_attendee_field_name
303
+	 *
304
+	 * @param string $system_question_string
305
+	 * @return string|null if not found
306
+	 */
307
+	public function get_attendee_field_for_system_question($system_question_string)
308
+	{
309
+		return isset($this->_system_question_to_attendee_field_name[ $system_question_string ])
310
+			? $this->_system_question_to_attendee_field_name[ $system_question_string ]
311
+			: null;
312
+	}
313
+
314
+
315
+
316
+	/**
317
+	 * Gets mapping from esp_question.QST_system values to their corresponding attendee field names
318
+	 *
319
+	 * @return array
320
+	 */
321
+	public function system_question_to_attendee_field_mapping()
322
+	{
323
+		return $this->_system_question_to_attendee_field_name;
324
+	}
325
+
326
+
327
+
328
+	/**
329
+	 * Gets all the attendees for a transaction (by using the esp_registration as a join table)
330
+	 *
331
+	 * @param EE_Transaction /int $transaction_id_or_obj EE_Transaction or its ID
332
+	 * @return EE_Attendee[]|EE_Base_Class[]
333
+	 * @throws EE_Error
334
+	 */
335
+	public function get_attendees_for_transaction($transaction_id_or_obj)
336
+	{
337
+		return $this->get_all(
338
+			array(
339
+				array(
340
+					'Registration.Transaction.TXN_ID' => $transaction_id_or_obj instanceof EE_Transaction
341
+						? $transaction_id_or_obj->ID()
342
+						: $transaction_id_or_obj,
343
+				),
344
+			)
345
+		);
346
+	}
347
+
348
+
349
+
350
+	/**
351
+	 * retrieve  a single attendee from db via their ID
352
+	 *
353
+	 * @param $ATT_ID
354
+	 * @return mixed array on success, FALSE on fail
355
+	 * @deprecated
356
+	 */
357
+	public function get_attendee_by_ID($ATT_ID = false)
358
+	{
359
+		// retrieve a particular EE_Attendee
360
+		return $this->get_one_by_ID($ATT_ID);
361
+	}
362
+
363
+
364
+
365
+	/**
366
+	 * retrieve  a single attendee from db via their ID
367
+	 *
368
+	 * @param array $where_cols_n_values
369
+	 * @return mixed array on success, FALSE on fail
370
+	 * @throws EE_Error
371
+	 */
372
+	public function get_attendee($where_cols_n_values = array())
373
+	{
374
+		if (empty($where_cols_n_values)) {
375
+			return false;
376
+		}
377
+		$attendee = $this->get_all(array($where_cols_n_values));
378
+		if (! empty($attendee)) {
379
+			return array_shift($attendee);
380
+		}
381
+		return false;
382
+	}
383
+
384
+
385
+
386
+	/**
387
+	 * Search for an existing Attendee record in the DB
388
+	 *
389
+	 * @param array $where_cols_n_values
390
+	 * @return bool|mixed
391
+	 * @throws EE_Error
392
+	 */
393
+	public function find_existing_attendee($where_cols_n_values = null)
394
+	{
395
+		// search by combo of first and last names plus the email address
396
+		$attendee_data_keys = array(
397
+			'ATT_fname' => $this->_ATT_fname,
398
+			'ATT_lname' => $this->_ATT_lname,
399
+			'ATT_email' => $this->_ATT_email,
400
+		);
401
+		// no search params means attendee object already exists.
402
+		$where_cols_n_values = is_array($where_cols_n_values) && ! empty($where_cols_n_values)
403
+			? $where_cols_n_values
404
+			: $attendee_data_keys;
405
+		$valid_data = true;
406
+		// check for required values
407
+		$valid_data = isset($where_cols_n_values['ATT_fname']) && ! empty($where_cols_n_values['ATT_fname'])
408
+			? $valid_data
409
+			: false;
410
+		$valid_data = isset($where_cols_n_values['ATT_lname']) && ! empty($where_cols_n_values['ATT_lname'])
411
+			? $valid_data
412
+			: false;
413
+		$valid_data = isset($where_cols_n_values['ATT_email']) && ! empty($where_cols_n_values['ATT_email'])
414
+			? $valid_data
415
+			: false;
416
+		if ($valid_data) {
417
+			$attendee = $this->get_attendee($where_cols_n_values);
418
+			if ($attendee instanceof EE_Attendee) {
419
+				return $attendee;
420
+			}
421
+		}
422
+		return false;
423
+	}
424
+
425
+
426
+
427
+	/**
428
+	 * Takes an incoming array of EE_Registration ids
429
+	 * and sends back a list of corresponding non duplicate EE_Attendee objects.
430
+	 *
431
+	 * @since  4.3.0
432
+	 * @param  array $ids array of EE_Registration ids
433
+	 * @return EE_Attendee[]|EE_Base_Class[]
434
+	 * @throws EE_Error
435
+	 */
436
+	public function get_array_of_contacts_from_reg_ids($ids)
437
+	{
438
+		$ids = (array) $ids;
439
+		$_where = array(
440
+			'Registration.REG_ID' => array('in', $ids),
441
+		);
442
+		return $this->get_all(array($_where));
443
+	}
444 444
 }
Please login to merge, or discard this patch.
core/db_models/EEM_Post_Meta.model.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -59,11 +59,11 @@
 block discarded – undo
59 59
         );
60 60
         $this->_model_relations = array();
61 61
         foreach ($models_this_can_attach_to as $model) {
62
-            $this->_model_relations[ $model ] = new EE_Belongs_To_Relation();
62
+            $this->_model_relations[$model] = new EE_Belongs_To_Relation();
63 63
         }
64 64
         $this->_wp_core_model = true;
65 65
         foreach ($this->cap_contexts_to_cap_action_map() as $cap_context => $action) {
66
-            $this->_cap_restriction_generators[ $cap_context ] = new EE_Restriction_Generator_Meta(
66
+            $this->_cap_restriction_generators[$cap_context] = new EE_Restriction_Generator_Meta(
67 67
                 'meta_key',
68 68
                 'meta_value'
69 69
             );
Please login to merge, or discard this patch.
Indentation   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -19,56 +19,56 @@
 block discarded – undo
19 19
 class EEM_Post_Meta extends EEM_Base
20 20
 {
21 21
 
22
-    // private instance of the EE_Post_Meta object
23
-    protected static $_instance = null;
22
+	// private instance of the EE_Post_Meta object
23
+	protected static $_instance = null;
24 24
 
25 25
 
26 26
 
27
-    protected function __construct($timezone = null)
28
-    {
29
-        $this->singular_item = esc_html__('Post Meta', 'event_espresso');
30
-        $this->plural_item = esc_html__('Post Metas', 'event_espresso');
31
-        $this->_tables = array(
32
-            'Post_Meta' => new EE_Primary_Table('postmeta', 'meta_id'),
33
-        );
34
-        $models_this_can_attach_to = array_keys(EE_Registry::instance()->cpt_models());
35
-        $this->_fields = array(
36
-            'Post_Meta' => array(
37
-                'meta_id'    => new EE_Primary_Key_Int_Field(
38
-                    'meta_id',
39
-                    esc_html__("Meta ID", "event_espresso")
40
-                ),
41
-                'post_id'    => new EE_Foreign_Key_Int_Field(
42
-                    'post_id',
43
-                    esc_html__("Primary Key of Post", "event_espresso"),
44
-                    false,
45
-                    0,
46
-                    $models_this_can_attach_to
47
-                ),
48
-                'meta_key'   => new EE_Plain_Text_Field(
49
-                    'meta_key',
50
-                    esc_html__("Meta Key", "event_espresso"),
51
-                    false,
52
-                    ''
53
-                ),
54
-                'meta_value' => new EE_Maybe_Serialized_Text_Field(
55
-                    'meta_value',
56
-                    esc_html__("Meta Value", "event_espresso"),
57
-                    true
58
-                ),
59
-            ),
60
-        );
61
-        $this->_model_relations = array();
62
-        foreach ($models_this_can_attach_to as $model) {
63
-            $this->_model_relations[ $model ] = new EE_Belongs_To_Relation();
64
-        }
65
-        $this->_wp_core_model = true;
66
-        foreach ($this->cap_contexts_to_cap_action_map() as $cap_context => $action) {
67
-            $this->_cap_restriction_generators[ $cap_context ] = new EE_Restriction_Generator_Meta(
68
-                'meta_key',
69
-                'meta_value'
70
-            );
71
-        }
72
-        parent::__construct($timezone);
73
-    }
27
+	protected function __construct($timezone = null)
28
+	{
29
+		$this->singular_item = esc_html__('Post Meta', 'event_espresso');
30
+		$this->plural_item = esc_html__('Post Metas', 'event_espresso');
31
+		$this->_tables = array(
32
+			'Post_Meta' => new EE_Primary_Table('postmeta', 'meta_id'),
33
+		);
34
+		$models_this_can_attach_to = array_keys(EE_Registry::instance()->cpt_models());
35
+		$this->_fields = array(
36
+			'Post_Meta' => array(
37
+				'meta_id'    => new EE_Primary_Key_Int_Field(
38
+					'meta_id',
39
+					esc_html__("Meta ID", "event_espresso")
40
+				),
41
+				'post_id'    => new EE_Foreign_Key_Int_Field(
42
+					'post_id',
43
+					esc_html__("Primary Key of Post", "event_espresso"),
44
+					false,
45
+					0,
46
+					$models_this_can_attach_to
47
+				),
48
+				'meta_key'   => new EE_Plain_Text_Field(
49
+					'meta_key',
50
+					esc_html__("Meta Key", "event_espresso"),
51
+					false,
52
+					''
53
+				),
54
+				'meta_value' => new EE_Maybe_Serialized_Text_Field(
55
+					'meta_value',
56
+					esc_html__("Meta Value", "event_espresso"),
57
+					true
58
+				),
59
+			),
60
+		);
61
+		$this->_model_relations = array();
62
+		foreach ($models_this_can_attach_to as $model) {
63
+			$this->_model_relations[ $model ] = new EE_Belongs_To_Relation();
64
+		}
65
+		$this->_wp_core_model = true;
66
+		foreach ($this->cap_contexts_to_cap_action_map() as $cap_context => $action) {
67
+			$this->_cap_restriction_generators[ $cap_context ] = new EE_Restriction_Generator_Meta(
68
+				'meta_key',
69
+				'meta_value'
70
+			);
71
+		}
72
+		parent::__construct($timezone);
73
+	}
74 74
 }
Please login to merge, or discard this patch.
core/db_models/fields/EE_Float_Field.php 1 patch
Indentation   +62 added lines, -62 removed lines patch added patch discarded remove patch
@@ -7,77 +7,77 @@
 block discarded – undo
7 7
 class EE_Float_Field extends EE_Model_Field_Base
8 8
 {
9 9
 
10
-    /**
11
-     * @param string $table_column
12
-     * @param string $nicename
13
-     * @param bool   $nullable
14
-     * @param null   $default_value
15
-     */
16
-    public function __construct($table_column, $nicename, $nullable, $default_value = null)
17
-    {
18
-        parent::__construct($table_column, $nicename, $nullable, $default_value);
19
-        $this->setSchemaType('number');
20
-    }
10
+	/**
11
+	 * @param string $table_column
12
+	 * @param string $nicename
13
+	 * @param bool   $nullable
14
+	 * @param null   $default_value
15
+	 */
16
+	public function __construct($table_column, $nicename, $nullable, $default_value = null)
17
+	{
18
+		parent::__construct($table_column, $nicename, $nullable, $default_value);
19
+		$this->setSchemaType('number');
20
+	}
21 21
 
22 22
 
23
-    /**
24
-     * If provided a string, strips out number-related formatting, like commas, periods, spaces, other junk, etc.
25
-     * However, treats commas and periods as thousand-separators ro decimal marks, as indicate by the config's currency.
26
-     * So if you want to pass in a string that NEEDS to interpret periods as decimal marks, call floatval() on it first.
27
-     * Returns a float
28
-     *
29
-     * @param type $value_inputted_for_field_on_model_object
30
-     * @return float
31
-     */
32
-    public function prepare_for_set($value_inputted_for_field_on_model_object)
33
-    {
23
+	/**
24
+	 * If provided a string, strips out number-related formatting, like commas, periods, spaces, other junk, etc.
25
+	 * However, treats commas and periods as thousand-separators ro decimal marks, as indicate by the config's currency.
26
+	 * So if you want to pass in a string that NEEDS to interpret periods as decimal marks, call floatval() on it first.
27
+	 * Returns a float
28
+	 *
29
+	 * @param type $value_inputted_for_field_on_model_object
30
+	 * @return float
31
+	 */
32
+	public function prepare_for_set($value_inputted_for_field_on_model_object)
33
+	{
34 34
 //      echo __LINE__."$value_inputted_for_field_on_model_object<br>";
35
-        // remove whitespaces and thousands separators
36
-        if (is_string($value_inputted_for_field_on_model_object)) {
37
-            $value_inputted_for_field_on_model_object = str_replace(
38
-                array(" ", EE_Config::instance()->currency->thsnds),
39
-                "",
40
-                $value_inputted_for_field_on_model_object
41
-            );
35
+		// remove whitespaces and thousands separators
36
+		if (is_string($value_inputted_for_field_on_model_object)) {
37
+			$value_inputted_for_field_on_model_object = str_replace(
38
+				array(" ", EE_Config::instance()->currency->thsnds),
39
+				"",
40
+				$value_inputted_for_field_on_model_object
41
+			);
42 42
 // echo __LINE__."$value_inputted_for_field_on_model_object<br>";
43 43
 // normalize it so periods are decimal marks (we don't care where you're from: we're talking PHP now)
44
-            $value_inputted_for_field_on_model_object = str_replace(
45
-                EE_Config::instance()->currency->dec_mrk,
46
-                ".",
47
-                $value_inputted_for_field_on_model_object
48
-            );
44
+			$value_inputted_for_field_on_model_object = str_replace(
45
+				EE_Config::instance()->currency->dec_mrk,
46
+				".",
47
+				$value_inputted_for_field_on_model_object
48
+			);
49 49
 // echo __LINE__."$value_inputted_for_field_on_model_object<br>";
50 50
 // double-check there's absolutely nothing left on this string besides numbers
51
-            $value_inputted_for_field_on_model_object = preg_replace(
52
-                "/[^0-9,.]/",
53
-                "",
54
-                $value_inputted_for_field_on_model_object
55
-            );
56
-        }
51
+			$value_inputted_for_field_on_model_object = preg_replace(
52
+				"/[^0-9,.]/",
53
+				"",
54
+				$value_inputted_for_field_on_model_object
55
+			);
56
+		}
57 57
 //      echo __LINE__."$value_inputted_for_field_on_model_object<br>";
58
-        return floatval($value_inputted_for_field_on_model_object);
59
-    }
58
+		return floatval($value_inputted_for_field_on_model_object);
59
+	}
60 60
 
61
-    /**
62
-     * Returns the number formatted according to local custom (set by the country of the blog).
63
-     *
64
-     * @param float $value_on_field_to_be_outputted
65
-     * @return string
66
-     */
67
-    public function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null)
68
-    {
69
-        $EE = EE_Registry::instance();
70
-        return number_format(
71
-            $value_on_field_to_be_outputted,
72
-            $EE->CFG->currency->dec_plc,
73
-            $EE->CFG->currency->dec_mrk,
74
-            $EE->CFG->currency->thsnds
75
-        );
76
-    }
61
+	/**
62
+	 * Returns the number formatted according to local custom (set by the country of the blog).
63
+	 *
64
+	 * @param float $value_on_field_to_be_outputted
65
+	 * @return string
66
+	 */
67
+	public function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null)
68
+	{
69
+		$EE = EE_Registry::instance();
70
+		return number_format(
71
+			$value_on_field_to_be_outputted,
72
+			$EE->CFG->currency->dec_plc,
73
+			$EE->CFG->currency->dec_mrk,
74
+			$EE->CFG->currency->thsnds
75
+		);
76
+	}
77 77
 
78
-    public function prepare_for_set_from_db($value_found_in_db_for_model_object)
79
-    {
78
+	public function prepare_for_set_from_db($value_found_in_db_for_model_object)
79
+	{
80 80
 //      echo "prepare for set from db of ";d($value_found_in_db_for_model_object);
81
-        return floatval($value_found_in_db_for_model_object);
82
-    }
81
+		return floatval($value_found_in_db_for_model_object);
82
+	}
83 83
 }
Please login to merge, or discard this patch.
core/db_models/fields/EE_All_Caps_Text_Field.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -6,14 +6,14 @@
 block discarded – undo
6 6
  */
7 7
 class EE_All_Caps_Text_Field extends EE_Text_Field_Base
8 8
 {
9
-    /**
10
-     * makes it all upper case, and key-like
11
-     *
12
-     * @param string $value_inputted_for_field_on_model_object
13
-     * @return string
14
-     */
15
-    public function prepare_for_set($value_inputted_for_field_on_model_object)
16
-    {
17
-        return strtoupper(sanitize_key($value_inputted_for_field_on_model_object));
18
-    }
9
+	/**
10
+	 * makes it all upper case, and key-like
11
+	 *
12
+	 * @param string $value_inputted_for_field_on_model_object
13
+	 * @return string
14
+	 */
15
+	public function prepare_for_set($value_inputted_for_field_on_model_object)
16
+	{
17
+		return strtoupper(sanitize_key($value_inputted_for_field_on_model_object));
18
+	}
19 19
 }
Please login to merge, or discard this patch.
core/db_models/fields/EE_Text_Field_Base.php 1 patch
Indentation   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -7,49 +7,49 @@
 block discarded – undo
7 7
 abstract class EE_Text_Field_Base extends EE_Model_Field_Base
8 8
 {
9 9
 
10
-    /**
11
-     * Gets the value in the format expected when being set.
12
-     * For display on the front-end, usually you would use prepare_for_pretty_echoing() instead.
13
-     * @param mixed $value_of_field_on_model_object
14
-     * @return mixed|string
15
-     */
16
-    public function prepare_for_get($value_of_field_on_model_object)
17
-    {
18
-        return $value_of_field_on_model_object;
19
-    }
10
+	/**
11
+	 * Gets the value in the format expected when being set.
12
+	 * For display on the front-end, usually you would use prepare_for_pretty_echoing() instead.
13
+	 * @param mixed $value_of_field_on_model_object
14
+	 * @return mixed|string
15
+	 */
16
+	public function prepare_for_get($value_of_field_on_model_object)
17
+	{
18
+		return $value_of_field_on_model_object;
19
+	}
20 20
 
21
-    /**
22
-     * Accepts schema of 'form_input' which formats the string for echoing in form input's value.
23
-     *
24
-     * @param string $value_on_field_to_be_outputted
25
-     * @param string $schema
26
-     * @return string
27
-     */
28
-    public function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null)
29
-    {
30
-        if ($schema === 'form_input') {
31
-            $value_on_field_to_be_outputted = (string) htmlentities(
32
-                $value_on_field_to_be_outputted,
33
-                ENT_QUOTES,
34
-                'UTF-8'
35
-            );
36
-        }
37
-        return parent::prepare_for_pretty_echoing($value_on_field_to_be_outputted);
38
-    }
21
+	/**
22
+	 * Accepts schema of 'form_input' which formats the string for echoing in form input's value.
23
+	 *
24
+	 * @param string $value_on_field_to_be_outputted
25
+	 * @param string $schema
26
+	 * @return string
27
+	 */
28
+	public function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null)
29
+	{
30
+		if ($schema === 'form_input') {
31
+			$value_on_field_to_be_outputted = (string) htmlentities(
32
+				$value_on_field_to_be_outputted,
33
+				ENT_QUOTES,
34
+				'UTF-8'
35
+			);
36
+		}
37
+		return parent::prepare_for_pretty_echoing($value_on_field_to_be_outputted);
38
+	}
39 39
 
40
-    /**
41
-     * Data received from the user should be exactly as they hope to save it in the DB, with the exception that
42
-     * quotes need to have slashes added to it. This method takes care of removing the slashes added by WP
43
-     * in magic-quotes fashion. We used to call html_entity_decode on the value here,
44
-     * because we called htmlentities when in EE_Text_Field_Base::prepare_for_pretty_echoing, but that's not necessary
45
-     * because web browsers always decode HTML entities in element attributes, like a form element's value attribute.
46
-     * So if we do it again here, we'll be removing HTML entities the user intended to have.)
47
-     *
48
-     * @param string $value_inputted_for_field_on_model_object
49
-     * @return string
50
-     */
51
-    public function prepare_for_set($value_inputted_for_field_on_model_object)
52
-    {
53
-        return stripslashes(parent::prepare_for_set($value_inputted_for_field_on_model_object));
54
-    }
40
+	/**
41
+	 * Data received from the user should be exactly as they hope to save it in the DB, with the exception that
42
+	 * quotes need to have slashes added to it. This method takes care of removing the slashes added by WP
43
+	 * in magic-quotes fashion. We used to call html_entity_decode on the value here,
44
+	 * because we called htmlentities when in EE_Text_Field_Base::prepare_for_pretty_echoing, but that's not necessary
45
+	 * because web browsers always decode HTML entities in element attributes, like a form element's value attribute.
46
+	 * So if we do it again here, we'll be removing HTML entities the user intended to have.)
47
+	 *
48
+	 * @param string $value_inputted_for_field_on_model_object
49
+	 * @return string
50
+	 */
51
+	public function prepare_for_set($value_inputted_for_field_on_model_object)
52
+	{
53
+		return stripslashes(parent::prepare_for_set($value_inputted_for_field_on_model_object));
54
+	}
55 55
 }
Please login to merge, or discard this patch.