Completed
Branch EDTR/master (af42c6)
by
unknown
50:36 queued 42:13
created
strategies/EE_Restriction_Generator_Default_Protected.strategy.php 2 patches
Indentation   +75 added lines, -75 removed lines patch added patch discarded remove patch
@@ -17,85 +17,85 @@
 block discarded – undo
17 17
  */
18 18
 class EE_Restriction_Generator_Default_Protected extends EE_Restriction_Generator_Base
19 19
 {
20
-    /**
21
-     * Name of the field on this model (or a related model, including the model chain to it)
22
-     * that is a boolean indicating whether or not a model object is considered "Default" or not
23
-     * @var string
24
-     */
25
-    protected $_default_field_name;
20
+	/**
21
+	 * Name of the field on this model (or a related model, including the model chain to it)
22
+	 * that is a boolean indicating whether or not a model object is considered "Default" or not
23
+	 * @var string
24
+	 */
25
+	protected $_default_field_name;
26 26
 
27
-    /**
28
-     * The model chain to follow to get to the event model, including the event model itself.
29
-     * Eg 'Ticket.Datetime.Event'
30
-     * @var string
31
-     */
32
-    protected $_path_to_event_model;
33
-    /**
34
-     *
35
-     * @param string $default_field_name the name of the field Name of the field on this model (or a related model, including the model chain to it)
36
-     * that is a boolean indicating whether or not a model object is considered "Default" or not
37
-     * @param string $path_to_event_model The model chain to follow to get to the event model, including the event model itself.
38
-     * Eg 'Ticket.Datetime.Event'
39
-     */
40
-    public function __construct($default_field_name, $path_to_event_model)
41
-    {
42
-        $this->_default_field_name = $default_field_name;
43
-        if (substr($path_to_event_model, -1, 1) != '.') {
44
-            $path_to_event_model .= '.';
45
-        }
46
-        $this->_path_to_event_model = $path_to_event_model;
47
-    }
27
+	/**
28
+	 * The model chain to follow to get to the event model, including the event model itself.
29
+	 * Eg 'Ticket.Datetime.Event'
30
+	 * @var string
31
+	 */
32
+	protected $_path_to_event_model;
33
+	/**
34
+	 *
35
+	 * @param string $default_field_name the name of the field Name of the field on this model (or a related model, including the model chain to it)
36
+	 * that is a boolean indicating whether or not a model object is considered "Default" or not
37
+	 * @param string $path_to_event_model The model chain to follow to get to the event model, including the event model itself.
38
+	 * Eg 'Ticket.Datetime.Event'
39
+	 */
40
+	public function __construct($default_field_name, $path_to_event_model)
41
+	{
42
+		$this->_default_field_name = $default_field_name;
43
+		if (substr($path_to_event_model, -1, 1) != '.') {
44
+			$path_to_event_model .= '.';
45
+		}
46
+		$this->_path_to_event_model = $path_to_event_model;
47
+	}
48 48
 
49 49
 
50 50
 
51
-    /**
52
-     *
53
-     * @return \EE_Default_Where_Conditions
54
-     */
55
-    protected function _generate_restrictions()
56
-    {
57
-        // if there are no standard caps for this model, then for now all we know is
58
-        // if they need the default cap to access this
59
-        if (! $this->model()->cap_slug()) {
60
-            return array(
61
-                self::get_default_restrictions_cap() => new EE_Return_None_Where_Conditions()
62
-            );
63
-        }
51
+	/**
52
+	 *
53
+	 * @return \EE_Default_Where_Conditions
54
+	 */
55
+	protected function _generate_restrictions()
56
+	{
57
+		// if there are no standard caps for this model, then for now all we know is
58
+		// if they need the default cap to access this
59
+		if (! $this->model()->cap_slug()) {
60
+			return array(
61
+				self::get_default_restrictions_cap() => new EE_Return_None_Where_Conditions()
62
+			);
63
+		}
64 64
 
65
-        $event_model = EEM_Event::instance();
65
+		$event_model = EEM_Event::instance();
66 66
 
67
-        $restrictions =  array(
68
-            // first: basically access to non-defaults is essentially controlled by which events are accessible
69
-            // if they don't have the basic event cap, they can't access ANY non-default items
70
-            EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action()) => new EE_Default_Where_Conditions(array( $this->_default_field_name => true )),
71
-            // if they don't have the others event cap, they can't access others' non-default items
72
-            EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action() . '_others') => new EE_Default_Where_Conditions(array(
73
-                'OR*no_' . EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action() . '_others') => array(
74
-                    $this->_path_to_event_model . 'EVT_wp_user' => EE_Default_Where_Conditions::current_user_placeholder ),
75
-                    $this->_default_field_name => true )),
76
-            // if they have basic and others, but not private, they can't access others' private non-default items
77
-            EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action() . '_private') => new EE_Default_Where_Conditions(array(
78
-                'OR*no_' .EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action() . '_private') => array(
79
-                $this->_path_to_event_model . 'EVT_wp_user' => EE_Default_Where_Conditions::current_user_placeholder,
80
-                $this->_path_to_event_model . 'status' => array( '!=', 'private' ),
81
-                $this->_default_field_name => true ) )),
82
-            // second: access to defaults is controlled by the defaulty capabilities
83
-            // if they don't have the default capability, restrict access to only non-default items
84
-            EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_default') => new EE_Default_Where_Conditions(array( $this->_default_field_name => false )),
85
-            // if they don't have the "others" default capability, restrict access to only their default ones, and non-default ones
86
-             );
87
-        if (EE_Restriction_Generator_Base::is_cap($this->model(), $this->action() . '_others_default')) {
88
-            $restrictions[ EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_others_default') ] = new EE_Default_Where_Conditions(array(
89
-                    // if they don't have the others default cap, they can't access others default items (but they can access
90
-                    // their own default items, and non-default items)
91
-                    'OR*no_' . EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_others_default') => array(
92
-                        'AND' => array(
93
-                            $this->_path_to_event_model . 'EVT_wp_user' => EE_Default_Where_Conditions::current_user_placeholder,
94
-                            $this->_default_field_name => true
95
-                            ),
96
-                        $this->_default_field_name => false
97
-                    ) ));
98
-        }
99
-        return $restrictions;
100
-    }
67
+		$restrictions =  array(
68
+			// first: basically access to non-defaults is essentially controlled by which events are accessible
69
+			// if they don't have the basic event cap, they can't access ANY non-default items
70
+			EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action()) => new EE_Default_Where_Conditions(array( $this->_default_field_name => true )),
71
+			// if they don't have the others event cap, they can't access others' non-default items
72
+			EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action() . '_others') => new EE_Default_Where_Conditions(array(
73
+				'OR*no_' . EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action() . '_others') => array(
74
+					$this->_path_to_event_model . 'EVT_wp_user' => EE_Default_Where_Conditions::current_user_placeholder ),
75
+					$this->_default_field_name => true )),
76
+			// if they have basic and others, but not private, they can't access others' private non-default items
77
+			EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action() . '_private') => new EE_Default_Where_Conditions(array(
78
+				'OR*no_' .EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action() . '_private') => array(
79
+				$this->_path_to_event_model . 'EVT_wp_user' => EE_Default_Where_Conditions::current_user_placeholder,
80
+				$this->_path_to_event_model . 'status' => array( '!=', 'private' ),
81
+				$this->_default_field_name => true ) )),
82
+			// second: access to defaults is controlled by the defaulty capabilities
83
+			// if they don't have the default capability, restrict access to only non-default items
84
+			EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_default') => new EE_Default_Where_Conditions(array( $this->_default_field_name => false )),
85
+			// if they don't have the "others" default capability, restrict access to only their default ones, and non-default ones
86
+			 );
87
+		if (EE_Restriction_Generator_Base::is_cap($this->model(), $this->action() . '_others_default')) {
88
+			$restrictions[ EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_others_default') ] = new EE_Default_Where_Conditions(array(
89
+					// if they don't have the others default cap, they can't access others default items (but they can access
90
+					// their own default items, and non-default items)
91
+					'OR*no_' . EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_others_default') => array(
92
+						'AND' => array(
93
+							$this->_path_to_event_model . 'EVT_wp_user' => EE_Default_Where_Conditions::current_user_placeholder,
94
+							$this->_default_field_name => true
95
+							),
96
+						$this->_default_field_name => false
97
+					) ));
98
+		}
99
+		return $restrictions;
100
+	}
101 101
 }
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
     {
57 57
         // if there are no standard caps for this model, then for now all we know is
58 58
         // if they need the default cap to access this
59
-        if (! $this->model()->cap_slug()) {
59
+        if ( ! $this->model()->cap_slug()) {
60 60
             return array(
61 61
                 self::get_default_restrictions_cap() => new EE_Return_None_Where_Conditions()
62 62
             );
@@ -64,33 +64,33 @@  discard block
 block discarded – undo
64 64
 
65 65
         $event_model = EEM_Event::instance();
66 66
 
67
-        $restrictions =  array(
67
+        $restrictions = array(
68 68
             // first: basically access to non-defaults is essentially controlled by which events are accessible
69 69
             // if they don't have the basic event cap, they can't access ANY non-default items
70
-            EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action()) => new EE_Default_Where_Conditions(array( $this->_default_field_name => true )),
70
+            EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action()) => new EE_Default_Where_Conditions(array($this->_default_field_name => true)),
71 71
             // if they don't have the others event cap, they can't access others' non-default items
72
-            EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action() . '_others') => new EE_Default_Where_Conditions(array(
73
-                'OR*no_' . EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action() . '_others') => array(
74
-                    $this->_path_to_event_model . 'EVT_wp_user' => EE_Default_Where_Conditions::current_user_placeholder ),
72
+            EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action().'_others') => new EE_Default_Where_Conditions(array(
73
+                'OR*no_'.EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action().'_others') => array(
74
+                    $this->_path_to_event_model.'EVT_wp_user' => EE_Default_Where_Conditions::current_user_placeholder ),
75 75
                     $this->_default_field_name => true )),
76 76
             // if they have basic and others, but not private, they can't access others' private non-default items
77
-            EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action() . '_private') => new EE_Default_Where_Conditions(array(
78
-                'OR*no_' .EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action() . '_private') => array(
79
-                $this->_path_to_event_model . 'EVT_wp_user' => EE_Default_Where_Conditions::current_user_placeholder,
80
-                $this->_path_to_event_model . 'status' => array( '!=', 'private' ),
77
+            EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action().'_private') => new EE_Default_Where_Conditions(array(
78
+                'OR*no_'.EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action().'_private') => array(
79
+                $this->_path_to_event_model.'EVT_wp_user' => EE_Default_Where_Conditions::current_user_placeholder,
80
+                $this->_path_to_event_model.'status' => array('!=', 'private'),
81 81
                 $this->_default_field_name => true ) )),
82 82
             // second: access to defaults is controlled by the defaulty capabilities
83 83
             // if they don't have the default capability, restrict access to only non-default items
84
-            EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_default') => new EE_Default_Where_Conditions(array( $this->_default_field_name => false )),
84
+            EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action().'_default') => new EE_Default_Where_Conditions(array($this->_default_field_name => false)),
85 85
             // if they don't have the "others" default capability, restrict access to only their default ones, and non-default ones
86 86
              );
87
-        if (EE_Restriction_Generator_Base::is_cap($this->model(), $this->action() . '_others_default')) {
88
-            $restrictions[ EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_others_default') ] = new EE_Default_Where_Conditions(array(
87
+        if (EE_Restriction_Generator_Base::is_cap($this->model(), $this->action().'_others_default')) {
88
+            $restrictions[EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action().'_others_default')] = new EE_Default_Where_Conditions(array(
89 89
                     // if they don't have the others default cap, they can't access others default items (but they can access
90 90
                     // their own default items, and non-default items)
91
-                    'OR*no_' . EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_others_default') => array(
91
+                    'OR*no_'.EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action().'_others_default') => array(
92 92
                         'AND' => array(
93
-                            $this->_path_to_event_model . 'EVT_wp_user' => EE_Default_Where_Conditions::current_user_placeholder,
93
+                            $this->_path_to_event_model.'EVT_wp_user' => EE_Default_Where_Conditions::current_user_placeholder,
94 94
                             $this->_default_field_name => true
95 95
                             ),
96 96
                         $this->_default_field_name => false
Please login to merge, or discard this patch.
core/db_models/strategies/EE_CPT_Where_Conditions.strategy.php 3 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@
 block discarded – undo
25 25
         return array_merge(
26 26
             parent::_get_default_where_conditions(),
27 27
             array(
28
-                $status_field->get_name() => array('NOT IN',array('auto-draft','trash') )
28
+                $status_field->get_name() => array('NOT IN', array('auto-draft', 'trash'))
29 29
             )
30 30
         );
31 31
     }
Please login to merge, or discard this patch.
Doc Comments   -1 removed lines patch added patch discarded remove patch
@@ -16,7 +16,6 @@
 block discarded – undo
16 16
 {
17 17
     /**
18 18
      * Gets the where default where conditions for a custom post type model
19
-     * @param string $model_relation_path. Eg, from Event to Payment, this should be "Registration.Transaction.Payment"
20 19
      * @return array @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md#0-where-conditions
21 20
      */
22 21
     protected function _get_default_where_conditions()
Please login to merge, or discard this patch.
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
 /**
4 4
  *
5 5
  * Class EE_Default_Where_Conditions
6
-  *
6
+ *
7 7
  * Strategy specifically for adding where conditions specific to CPT models.
8 8
  *
9 9
  * @package         Event Espresso
@@ -14,19 +14,19 @@  discard block
 block discarded – undo
14 14
  */
15 15
 class EE_CPT_Where_Conditions extends EE_CPT_Minimum_Where_Conditions
16 16
 {
17
-    /**
18
-     * Gets the where default where conditions for a custom post type model
19
-     * @param string $model_relation_path. Eg, from Event to Payment, this should be "Registration.Transaction.Payment"
20
-     * @return array @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md#0-where-conditions
21
-     */
22
-    protected function _get_default_where_conditions()
23
-    {
24
-        $status_field = $this->_get_field_on_column('post_status');
25
-        return array_merge(
26
-            parent::_get_default_where_conditions(),
27
-            array(
28
-                $status_field->get_name() => array('NOT IN',array('auto-draft','trash') )
29
-            )
30
-        );
31
-    }
17
+	/**
18
+	 * Gets the where default where conditions for a custom post type model
19
+	 * @param string $model_relation_path. Eg, from Event to Payment, this should be "Registration.Transaction.Payment"
20
+	 * @return array @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md#0-where-conditions
21
+	 */
22
+	protected function _get_default_where_conditions()
23
+	{
24
+		$status_field = $this->_get_field_on_column('post_status');
25
+		return array_merge(
26
+			parent::_get_default_where_conditions(),
27
+			array(
28
+				$status_field->get_name() => array('NOT IN',array('auto-draft','trash') )
29
+			)
30
+		);
31
+	}
32 32
 }
Please login to merge, or discard this patch.
strategies/EE_Restriction_Generator_Taxonomy_Protected.strategy.php 2 patches
Indentation   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -13,40 +13,40 @@
 block discarded – undo
13 13
 class EE_Restriction_Generator_Taxonomy_Protected extends EE_Restriction_Generator_Base
14 14
 {
15 15
 
16
-    /**
17
-     * Model chain/path to taxonomy model, including the term_taxonomy model itself
18
-     * @var string
19
-     */
20
-    protected $_path_to_taxonomy_model;
21
-    /**
22
-     *
23
-     * @param string $path_to_taxonomy_model Model chain/path to taxonomy model, including the term_taxonomy model itself
24
-     */
25
-    public function __construct($path_to_taxonomy_model)
26
-    {
27
-        if ($path_to_taxonomy_model !== '' && substr($path_to_taxonomy_model, -1, 1) != '.') {
28
-            $path_to_taxonomy_model .= '.';
29
-        }
30
-        $this->_path_to_taxonomy_model = $path_to_taxonomy_model;
31
-    }
32
-    protected function _generate_restrictions()
33
-    {
34
-        // if there are no standard caps for this model, then for allow full access
35
-        if (! $this->model()->cap_slug()) {
36
-            return array(
37
-            );
38
-        }
16
+	/**
17
+	 * Model chain/path to taxonomy model, including the term_taxonomy model itself
18
+	 * @var string
19
+	 */
20
+	protected $_path_to_taxonomy_model;
21
+	/**
22
+	 *
23
+	 * @param string $path_to_taxonomy_model Model chain/path to taxonomy model, including the term_taxonomy model itself
24
+	 */
25
+	public function __construct($path_to_taxonomy_model)
26
+	{
27
+		if ($path_to_taxonomy_model !== '' && substr($path_to_taxonomy_model, -1, 1) != '.') {
28
+			$path_to_taxonomy_model .= '.';
29
+		}
30
+		$this->_path_to_taxonomy_model = $path_to_taxonomy_model;
31
+	}
32
+	protected function _generate_restrictions()
33
+	{
34
+		// if there are no standard caps for this model, then for allow full access
35
+		if (! $this->model()->cap_slug()) {
36
+			return array(
37
+			);
38
+		}
39 39
 
40
-        return array(
41
-            'ee_manage_event_categories' => new EE_Default_Where_Conditions(array(
42
-                $this->_path_to_taxonomy_model . 'taxonomy*no_ee_manage_event_categories' => array( '!=', 'espresso_event_categories' )
43
-            )),
44
-            'ee_manage_venue_categories' => new EE_Default_Where_Conditions(array(
45
-                $this->_path_to_taxonomy_model . 'taxonomy*no_ee_manage_venue_categories' => array( '!=', 'espresso_venue_categories' )
46
-            )),
47
-            'ee_manage_event_types' => new EE_Default_Where_Conditions(array(
48
-                $this->_path_to_taxonomy_model . 'taxonomy*ee_manage_event_types' => array( '!=', 'espresso_event_types' )
49
-            )),
50
-        );
51
-    }
40
+		return array(
41
+			'ee_manage_event_categories' => new EE_Default_Where_Conditions(array(
42
+				$this->_path_to_taxonomy_model . 'taxonomy*no_ee_manage_event_categories' => array( '!=', 'espresso_event_categories' )
43
+			)),
44
+			'ee_manage_venue_categories' => new EE_Default_Where_Conditions(array(
45
+				$this->_path_to_taxonomy_model . 'taxonomy*no_ee_manage_venue_categories' => array( '!=', 'espresso_venue_categories' )
46
+			)),
47
+			'ee_manage_event_types' => new EE_Default_Where_Conditions(array(
48
+				$this->_path_to_taxonomy_model . 'taxonomy*ee_manage_event_types' => array( '!=', 'espresso_event_types' )
49
+			)),
50
+		);
51
+	}
52 52
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -32,20 +32,20 @@
 block discarded – undo
32 32
     protected function _generate_restrictions()
33 33
     {
34 34
         // if there are no standard caps for this model, then for allow full access
35
-        if (! $this->model()->cap_slug()) {
35
+        if ( ! $this->model()->cap_slug()) {
36 36
             return array(
37 37
             );
38 38
         }
39 39
 
40 40
         return array(
41 41
             'ee_manage_event_categories' => new EE_Default_Where_Conditions(array(
42
-                $this->_path_to_taxonomy_model . 'taxonomy*no_ee_manage_event_categories' => array( '!=', 'espresso_event_categories' )
42
+                $this->_path_to_taxonomy_model.'taxonomy*no_ee_manage_event_categories' => array('!=', 'espresso_event_categories')
43 43
             )),
44 44
             'ee_manage_venue_categories' => new EE_Default_Where_Conditions(array(
45
-                $this->_path_to_taxonomy_model . 'taxonomy*no_ee_manage_venue_categories' => array( '!=', 'espresso_venue_categories' )
45
+                $this->_path_to_taxonomy_model.'taxonomy*no_ee_manage_venue_categories' => array('!=', 'espresso_venue_categories')
46 46
             )),
47 47
             'ee_manage_event_types' => new EE_Default_Where_Conditions(array(
48
-                $this->_path_to_taxonomy_model . 'taxonomy*ee_manage_event_types' => array( '!=', 'espresso_event_types' )
48
+                $this->_path_to_taxonomy_model.'taxonomy*ee_manage_event_types' => array('!=', 'espresso_event_types')
49 49
             )),
50 50
         );
51 51
     }
Please login to merge, or discard this patch.
core/db_models/strategies/EE_Return_None_Where_Conditions.strategy.php 2 patches
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -12,13 +12,13 @@
 block discarded – undo
12 12
  */
13 13
 class EE_Return_None_Where_Conditions extends EE_Default_Where_Conditions
14 14
 {
15
-    protected function _get_default_where_conditions()
16
-    {
17
-        if ($this->_model->has_primary_key_field()) {
18
-            return array( $this->_model->primary_key_name() => array('<', 0 ) );
19
-        } else {
20
-            $fk_field = $this->_model->get_a_field_of_type('EE_Foreign_Key_Field_Base');
21
-            return array( 'AND*impossible' => array( $fk_field->get_name() => array('IS_NULL'), $fk_field->get_name() => 'IS_NOT_NULL' ) );
22
-        }
23
-    }
15
+	protected function _get_default_where_conditions()
16
+	{
17
+		if ($this->_model->has_primary_key_field()) {
18
+			return array( $this->_model->primary_key_name() => array('<', 0 ) );
19
+		} else {
20
+			$fk_field = $this->_model->get_a_field_of_type('EE_Foreign_Key_Field_Base');
21
+			return array( 'AND*impossible' => array( $fk_field->get_name() => array('IS_NULL'), $fk_field->get_name() => 'IS_NOT_NULL' ) );
22
+		}
23
+	}
24 24
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -15,10 +15,10 @@
 block discarded – undo
15 15
     protected function _get_default_where_conditions()
16 16
     {
17 17
         if ($this->_model->has_primary_key_field()) {
18
-            return array( $this->_model->primary_key_name() => array('<', 0 ) );
18
+            return array($this->_model->primary_key_name() => array('<', 0));
19 19
         } else {
20 20
             $fk_field = $this->_model->get_a_field_of_type('EE_Foreign_Key_Field_Base');
21
-            return array( 'AND*impossible' => array( $fk_field->get_name() => array('IS_NULL'), $fk_field->get_name() => 'IS_NOT_NULL' ) );
21
+            return array('AND*impossible' => array($fk_field->get_name() => array('IS_NULL'), $fk_field->get_name() => 'IS_NOT_NULL'));
22 22
         }
23 23
     }
24 24
 }
Please login to merge, or discard this patch.
core/db_models/strategies/EE_Restriction_Generator_WP_User.strategy.php 1 patch
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -15,18 +15,18 @@
 block discarded – undo
15 15
 class EE_Restriction_Generator_WP_User extends EE_Restriction_Generator_Base
16 16
 {
17 17
 
18
-    /**
19
-     * @return \EE_Default_Where_Conditions
20
-     */
21
-    protected function _generate_restrictions()
22
-    {
18
+	/**
19
+	 * @return \EE_Default_Where_Conditions
20
+	 */
21
+	protected function _generate_restrictions()
22
+	{
23 23
 
24
-        return array(
25
-            // if they can't access users, they can still access themselves
26
-            EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action()) => new EE_Default_Where_Conditions(array(
27
-                EE_Default_Where_Conditions::user_field_name_placeholder => EE_Default_Where_Conditions::current_user_placeholder
28
-            )),
24
+		return array(
25
+			// if they can't access users, they can still access themselves
26
+			EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action()) => new EE_Default_Where_Conditions(array(
27
+				EE_Default_Where_Conditions::user_field_name_placeholder => EE_Default_Where_Conditions::current_user_placeholder
28
+			)),
29 29
 
30
-        );
31
-    }
30
+		);
31
+	}
32 32
 }
Please login to merge, or discard this patch.
core/db_models/EEM_Question_Option.model.php 2 patches
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -11,39 +11,39 @@
 block discarded – undo
11 11
 class EEM_Question_Option extends EEM_Soft_Delete_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
-    protected function __construct($timezone = null)
18
-    {
19
-        $this->singular_item = __('Question Option', 'event_espresso');
20
-        $this->plural_item = __('Question Options', 'event_espresso');
17
+	protected function __construct($timezone = null)
18
+	{
19
+		$this->singular_item = __('Question Option', 'event_espresso');
20
+		$this->plural_item = __('Question Options', 'event_espresso');
21 21
 
22
-        $this->_tables = array(
23
-            'Question_Option'=>new EE_Primary_Table('esp_question_option', 'QSO_ID')
24
-        );
25
-        $this->_fields = array(
26
-            'Question_Option'=>array(
27
-                    'QSO_ID'=>new EE_Primary_Key_Int_Field('QSO_ID', __('Question Option ID', 'event_espresso')),
28
-                    'QST_ID'=>new EE_Foreign_Key_Int_Field('QST_ID', __('Question ID', 'event_espresso'), false, 0, 'Question'),
29
-                    'QSO_value'=>new EE_Plain_Text_Field('QSO_value', __("Question Option Value", "event_espresso"), false, ''),
30
-                    'QSO_desc'=>new EE_Post_Content_Field('QSO_desc', __('Question Option Description', 'event_espresso'), false, ''),
31
-                    'QSO_order' => new EE_Integer_Field('QSO_order', __('Question Option Order', 'event_espresso'), false, 0),
32
-                    'QSO_system'=>new EE_Plain_Text_Field('QSO_system', __('Internal string ID for question option', 'event_espresso'), true, null),
33
-                    'QSO_deleted'=>new EE_Trashed_Flag_Field('QSO_deleted', __('Flag indicating Option was trashed', 'event_espresso'), false, false)
34
-                )
35
-        );
36
-        $this->_model_relations = array(
37
-            'Question'=>new EE_Belongs_To_Relation()
38
-        );
22
+		$this->_tables = array(
23
+			'Question_Option'=>new EE_Primary_Table('esp_question_option', 'QSO_ID')
24
+		);
25
+		$this->_fields = array(
26
+			'Question_Option'=>array(
27
+					'QSO_ID'=>new EE_Primary_Key_Int_Field('QSO_ID', __('Question Option ID', 'event_espresso')),
28
+					'QST_ID'=>new EE_Foreign_Key_Int_Field('QST_ID', __('Question ID', 'event_espresso'), false, 0, 'Question'),
29
+					'QSO_value'=>new EE_Plain_Text_Field('QSO_value', __("Question Option Value", "event_espresso"), false, ''),
30
+					'QSO_desc'=>new EE_Post_Content_Field('QSO_desc', __('Question Option Description', 'event_espresso'), false, ''),
31
+					'QSO_order' => new EE_Integer_Field('QSO_order', __('Question Option Order', 'event_espresso'), false, 0),
32
+					'QSO_system'=>new EE_Plain_Text_Field('QSO_system', __('Internal string ID for question option', 'event_espresso'), true, null),
33
+					'QSO_deleted'=>new EE_Trashed_Flag_Field('QSO_deleted', __('Flag indicating Option was trashed', 'event_espresso'), false, false)
34
+				)
35
+		);
36
+		$this->_model_relations = array(
37
+			'Question'=>new EE_Belongs_To_Relation()
38
+		);
39 39
 
40
-        $this->_model_chain_to_wp_user = 'Question';
41
-        // this model is generally available for reading
42
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
43
-        $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Reg_Form('QSO_system');
44
-        $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Reg_Form('QSO_system');
45
-        $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Reg_Form('QSO_system');
46
-        $this->_caps_slug = 'questions';
47
-        parent::__construct($timezone);
48
-    }
40
+		$this->_model_chain_to_wp_user = 'Question';
41
+		// this model is generally available for reading
42
+		$this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
43
+		$this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Reg_Form('QSO_system');
44
+		$this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Reg_Form('QSO_system');
45
+		$this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Reg_Form('QSO_system');
46
+		$this->_caps_slug = 'questions';
47
+		parent::__construct($timezone);
48
+	}
49 49
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -39,10 +39,10 @@
 block discarded – undo
39 39
 
40 40
         $this->_model_chain_to_wp_user = 'Question';
41 41
         // this model is generally available for reading
42
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
43
-        $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Reg_Form('QSO_system');
44
-        $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Reg_Form('QSO_system');
45
-        $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Reg_Form('QSO_system');
42
+        $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Public();
43
+        $this->_cap_restriction_generators[EEM_Base::caps_read_admin] = new EE_Restriction_Generator_Reg_Form('QSO_system');
44
+        $this->_cap_restriction_generators[EEM_Base::caps_edit] = new EE_Restriction_Generator_Reg_Form('QSO_system');
45
+        $this->_cap_restriction_generators[EEM_Base::caps_delete] = new EE_Restriction_Generator_Reg_Form('QSO_system');
46 46
         $this->_caps_slug = 'questions';
47 47
         parent::__construct($timezone);
48 48
     }
Please login to merge, or discard this patch.
core/db_models/EEM_Answer.model.php 2 patches
Indentation   +125 added lines, -125 removed lines patch added patch discarded remove patch
@@ -9,142 +9,142 @@
 block discarded – undo
9 9
 class EEM_Answer extends EEM_Base
10 10
 {
11 11
 
12
-    /**
13
-     * private instance of the EEM_Answer object
14
-     * @type EEM_Answer
15
-     */
16
-    protected static $_instance = null;
12
+	/**
13
+	 * private instance of the EEM_Answer object
14
+	 * @type EEM_Answer
15
+	 */
16
+	protected static $_instance = null;
17 17
 
18
-    /**
19
-     * Mapping from system question ids to attendee field names
20
-     * @type array
21
-     * @deprecated since version 4.8.8
22
-     */
23
-    protected $_question_id_to_att_field_map = array(
24
-        EEM_Attendee::fname_question_id => 'ATT_fname',
25
-        EEM_Attendee::lname_question_id => 'ATT_lname',
26
-        EEM_Attendee::email_question_id => 'ATT_email',
27
-        EEM_Attendee::address_question_id => 'ATT_address',
28
-        EEM_Attendee::address2_question_id => 'ATT_address2',
29
-        EEM_Attendee::city_question_id => 'ATT_city',
30
-        EEM_Attendee::state_question_id => 'STA_ID',
31
-        EEM_Attendee::country_question_id => 'CNT_ISO',
32
-        EEM_Attendee::zip_question_id => 'ATT_zip',
33
-        EEM_Attendee::phone_question_id => 'ATT_phone'
34
-    );
18
+	/**
19
+	 * Mapping from system question ids to attendee field names
20
+	 * @type array
21
+	 * @deprecated since version 4.8.8
22
+	 */
23
+	protected $_question_id_to_att_field_map = array(
24
+		EEM_Attendee::fname_question_id => 'ATT_fname',
25
+		EEM_Attendee::lname_question_id => 'ATT_lname',
26
+		EEM_Attendee::email_question_id => 'ATT_email',
27
+		EEM_Attendee::address_question_id => 'ATT_address',
28
+		EEM_Attendee::address2_question_id => 'ATT_address2',
29
+		EEM_Attendee::city_question_id => 'ATT_city',
30
+		EEM_Attendee::state_question_id => 'STA_ID',
31
+		EEM_Attendee::country_question_id => 'CNT_ISO',
32
+		EEM_Attendee::zip_question_id => 'ATT_zip',
33
+		EEM_Attendee::phone_question_id => 'ATT_phone'
34
+	);
35 35
 
36 36
 
37 37
 
38
-    /**
39
-     *  constructor
40
-     */
41
-    protected function __construct($timezone = null)
42
-    {
43
-        $this->singular_item = __('Answer', 'event_espresso');
44
-        $this->plural_item = __('Answers', 'event_espresso');
45
-        $this->_tables = array(
46
-            'Answer'=> new EE_Primary_Table('esp_answer', 'ANS_ID')
47
-        );
48
-        $this->_fields = array(
49
-            'Answer'=>array(
50
-                'ANS_ID'=> new EE_Primary_Key_Int_Field('ANS_ID', __('Answer ID', 'event_espresso')),
51
-                'REG_ID'=>new EE_Foreign_Key_Int_Field('REG_ID', __('Registration ID', 'event_espresso'), false, 0, 'Registration'),
52
-                'QST_ID'=>new EE_Foreign_Key_Int_Field('QST_ID', __('Question ID', 'event_espresso'), false, 0, 'Question'),
53
-                'ANS_value'=>new EE_Maybe_Serialized_Simple_HTML_Field('ANS_value', __('Answer Value', 'event_espresso'), false, '')
54
-            ));
55
-        $this->_model_relations = array(
56
-            'Registration'=>new EE_Belongs_To_Relation(),
57
-            'Question'=>new EE_Belongs_To_Relation()
58
-        );
59
-        $this->_model_chain_to_wp_user = 'Registration.Event';
60
-        $this->_caps_slug = 'registrations';
61
-        parent::__construct($timezone);
62
-    }
38
+	/**
39
+	 *  constructor
40
+	 */
41
+	protected function __construct($timezone = null)
42
+	{
43
+		$this->singular_item = __('Answer', 'event_espresso');
44
+		$this->plural_item = __('Answers', 'event_espresso');
45
+		$this->_tables = array(
46
+			'Answer'=> new EE_Primary_Table('esp_answer', 'ANS_ID')
47
+		);
48
+		$this->_fields = array(
49
+			'Answer'=>array(
50
+				'ANS_ID'=> new EE_Primary_Key_Int_Field('ANS_ID', __('Answer ID', 'event_espresso')),
51
+				'REG_ID'=>new EE_Foreign_Key_Int_Field('REG_ID', __('Registration ID', 'event_espresso'), false, 0, 'Registration'),
52
+				'QST_ID'=>new EE_Foreign_Key_Int_Field('QST_ID', __('Question ID', 'event_espresso'), false, 0, 'Question'),
53
+				'ANS_value'=>new EE_Maybe_Serialized_Simple_HTML_Field('ANS_value', __('Answer Value', 'event_espresso'), false, '')
54
+			));
55
+		$this->_model_relations = array(
56
+			'Registration'=>new EE_Belongs_To_Relation(),
57
+			'Question'=>new EE_Belongs_To_Relation()
58
+		);
59
+		$this->_model_chain_to_wp_user = 'Registration.Event';
60
+		$this->_caps_slug = 'registrations';
61
+		parent::__construct($timezone);
62
+	}
63 63
 
64 64
 
65 65
 
66
-    /**
67
-     * Gets the string answer to the question for this registration (it could either be stored
68
-     * on the attendee or in the answer table. This function finds its value regardless)
69
-     * @param EE_Registration $registration
70
-     * @param int $question_id
71
-     * @param boolean $pretty_answer whether to call 'pretty_value' or just 'value'
72
-     * @return string
73
-     */
74
-    public function get_answer_value_to_question(EE_Registration $registration, $question_id = null, $pretty_answer = false)
75
-    {
76
-        $value = $this->get_attendee_property_answer_value($registration, $question_id, $pretty_answer);
77
-        if ($value === null) {
78
-            $answer_obj = $this->get_registration_question_answer_object($registration, $question_id);
79
-            if ($answer_obj instanceof EE_Answer) {
80
-                if ($pretty_answer) {
81
-                    $value = $answer_obj->pretty_value();
82
-                } else {
83
-                    $value = $answer_obj->value();
84
-                }
85
-            }
86
-        }
87
-        return apply_filters('FHEE__EEM_Answer__get_answer_value_to_question__answer_value', $value, $registration, $question_id);
88
-    }
66
+	/**
67
+	 * Gets the string answer to the question for this registration (it could either be stored
68
+	 * on the attendee or in the answer table. This function finds its value regardless)
69
+	 * @param EE_Registration $registration
70
+	 * @param int $question_id
71
+	 * @param boolean $pretty_answer whether to call 'pretty_value' or just 'value'
72
+	 * @return string
73
+	 */
74
+	public function get_answer_value_to_question(EE_Registration $registration, $question_id = null, $pretty_answer = false)
75
+	{
76
+		$value = $this->get_attendee_property_answer_value($registration, $question_id, $pretty_answer);
77
+		if ($value === null) {
78
+			$answer_obj = $this->get_registration_question_answer_object($registration, $question_id);
79
+			if ($answer_obj instanceof EE_Answer) {
80
+				if ($pretty_answer) {
81
+					$value = $answer_obj->pretty_value();
82
+				} else {
83
+					$value = $answer_obj->value();
84
+				}
85
+			}
86
+		}
87
+		return apply_filters('FHEE__EEM_Answer__get_answer_value_to_question__answer_value', $value, $registration, $question_id);
88
+	}
89 89
 
90 90
 
91 91
 
92
-    /**
93
-     * Gets the EE_Answer object for the question for this registration (if it exists)
94
-     * @param EE_Registration $registration
95
-     * @param int $question_id
96
-     * @return EE_Answer
97
-     */
98
-    public function get_registration_question_answer_object(EE_Registration $registration, $question_id = null)
99
-    {
100
-        $answer_obj = $this->get_one(array( array( 'QST_ID'=>$question_id, 'REG_ID'=>$registration->ID() )));
101
-        return apply_filters('FHEE__EEM_Answer__get_registration_question_answer_object__answer_obj', $answer_obj, $registration, $question_id);
102
-    }
92
+	/**
93
+	 * Gets the EE_Answer object for the question for this registration (if it exists)
94
+	 * @param EE_Registration $registration
95
+	 * @param int $question_id
96
+	 * @return EE_Answer
97
+	 */
98
+	public function get_registration_question_answer_object(EE_Registration $registration, $question_id = null)
99
+	{
100
+		$answer_obj = $this->get_one(array( array( 'QST_ID'=>$question_id, 'REG_ID'=>$registration->ID() )));
101
+		return apply_filters('FHEE__EEM_Answer__get_registration_question_answer_object__answer_obj', $answer_obj, $registration, $question_id);
102
+	}
103 103
 
104 104
 
105 105
 
106
-    /**
107
-     * Gets the string answer to the question for this registration's attendee
108
-     * @param EE_Registration $registration
109
-     * @param int|string $question_system_id if an INT this is understood to be the question's ID; if a string then it should be its QST_system value.
110
-     *  Passing in the QST_system value is more efficient
111
-     * @param boolean $pretty_answer
112
-     * @return string|null (if the registration has no attendee, or the question_system_id is not a QST_ID or QST_system for
113
-     * a question corresponding to an attendee field, returns null)
114
-     */
115
-    public function get_attendee_property_answer_value(EE_Registration $registration, $question_system_id = null, $pretty_answer = false)
116
-    {
117
-        $field_name = null;
118
-        $value = null;
119
-                // backward compat: we still want to find the question's ID
120
-        if (is_numeric($question_system_id)) {
121
-            // find this question's QST_system value
122
-            $question_id = $question_system_id;
123
-            $question_system_id = EEM_Question::instance()->get_var(array( array( 'QST_ID' => $question_system_id ) ), 'QST_system');
124
-        } else {
125
-            $question_id = (int) EEM_Question::instance()->get_var(array( array( 'QST_system' => $question_system_id ) ), 'QST_ID');
126
-        }
127
-        // only bother checking if the registration has an attendee
128
-        if ($registration->attendee() instanceof EE_Attendee) {
129
-            $field_name = EEM_Attendee::instance()->get_attendee_field_for_system_question($question_system_id);
130
-            if ($field_name) {
131
-                if ($pretty_answer) {
132
-                    if ($field_name === 'STA_ID') {
133
-                        $state = $registration->attendee()->state_obj();
134
-                        $value = $state instanceof EE_State ? $state->name() : sprintf(__('Unknown State (%s)', 'event_espresso'), $registration->attendee()->state_ID());
135
-                    } elseif ($field_name === 'CNT_ISO') {
136
-                        $country = $registration->attendee()->country_obj();
137
-                        $value = $country instanceof EE_Country ? $country->name() : sprintf(__('Unknown Country (%s)', "event_espresso"), $registration->attendee()->country_ID());
138
-                    } else {
139
-                        $value = $registration->attendee()->get_pretty($field_name);
140
-                    }
141
-                    // if field name is blank, leave the value as null too
142
-                } else {
143
-                    $value = $registration->attendee()->get($field_name);
144
-                }
145
-            }
146
-            // if no field was found, leave value blank
147
-        }
148
-        return apply_filters('FHEE__EEM_Answer__get_attendee_question_answer_value__answer_value', $value, $registration, $question_id, $question_system_id);
149
-    }
106
+	/**
107
+	 * Gets the string answer to the question for this registration's attendee
108
+	 * @param EE_Registration $registration
109
+	 * @param int|string $question_system_id if an INT this is understood to be the question's ID; if a string then it should be its QST_system value.
110
+	 *  Passing in the QST_system value is more efficient
111
+	 * @param boolean $pretty_answer
112
+	 * @return string|null (if the registration has no attendee, or the question_system_id is not a QST_ID or QST_system for
113
+	 * a question corresponding to an attendee field, returns null)
114
+	 */
115
+	public function get_attendee_property_answer_value(EE_Registration $registration, $question_system_id = null, $pretty_answer = false)
116
+	{
117
+		$field_name = null;
118
+		$value = null;
119
+				// backward compat: we still want to find the question's ID
120
+		if (is_numeric($question_system_id)) {
121
+			// find this question's QST_system value
122
+			$question_id = $question_system_id;
123
+			$question_system_id = EEM_Question::instance()->get_var(array( array( 'QST_ID' => $question_system_id ) ), 'QST_system');
124
+		} else {
125
+			$question_id = (int) EEM_Question::instance()->get_var(array( array( 'QST_system' => $question_system_id ) ), 'QST_ID');
126
+		}
127
+		// only bother checking if the registration has an attendee
128
+		if ($registration->attendee() instanceof EE_Attendee) {
129
+			$field_name = EEM_Attendee::instance()->get_attendee_field_for_system_question($question_system_id);
130
+			if ($field_name) {
131
+				if ($pretty_answer) {
132
+					if ($field_name === 'STA_ID') {
133
+						$state = $registration->attendee()->state_obj();
134
+						$value = $state instanceof EE_State ? $state->name() : sprintf(__('Unknown State (%s)', 'event_espresso'), $registration->attendee()->state_ID());
135
+					} elseif ($field_name === 'CNT_ISO') {
136
+						$country = $registration->attendee()->country_obj();
137
+						$value = $country instanceof EE_Country ? $country->name() : sprintf(__('Unknown Country (%s)', "event_espresso"), $registration->attendee()->country_ID());
138
+					} else {
139
+						$value = $registration->attendee()->get_pretty($field_name);
140
+					}
141
+					// if field name is blank, leave the value as null too
142
+				} else {
143
+					$value = $registration->attendee()->get($field_name);
144
+				}
145
+			}
146
+			// if no field was found, leave value blank
147
+		}
148
+		return apply_filters('FHEE__EEM_Answer__get_attendee_question_answer_value__answer_value', $value, $registration, $question_id, $question_system_id);
149
+	}
150 150
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
      */
98 98
     public function get_registration_question_answer_object(EE_Registration $registration, $question_id = null)
99 99
     {
100
-        $answer_obj = $this->get_one(array( array( 'QST_ID'=>$question_id, 'REG_ID'=>$registration->ID() )));
100
+        $answer_obj = $this->get_one(array(array('QST_ID'=>$question_id, 'REG_ID'=>$registration->ID())));
101 101
         return apply_filters('FHEE__EEM_Answer__get_registration_question_answer_object__answer_obj', $answer_obj, $registration, $question_id);
102 102
     }
103 103
 
@@ -120,9 +120,9 @@  discard block
 block discarded – undo
120 120
         if (is_numeric($question_system_id)) {
121 121
             // find this question's QST_system value
122 122
             $question_id = $question_system_id;
123
-            $question_system_id = EEM_Question::instance()->get_var(array( array( 'QST_ID' => $question_system_id ) ), 'QST_system');
123
+            $question_system_id = EEM_Question::instance()->get_var(array(array('QST_ID' => $question_system_id)), 'QST_system');
124 124
         } else {
125
-            $question_id = (int) EEM_Question::instance()->get_var(array( array( 'QST_system' => $question_system_id ) ), 'QST_ID');
125
+            $question_id = (int) EEM_Question::instance()->get_var(array(array('QST_system' => $question_system_id)), 'QST_ID');
126 126
         }
127 127
         // only bother checking if the registration has an attendee
128 128
         if ($registration->attendee() instanceof EE_Attendee) {
Please login to merge, or discard this patch.
core/db_models/EEM_Message_Template.model.php 2 patches
Indentation   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -13,45 +13,45 @@
 block discarded – undo
13 13
  */
14 14
 class EEM_Message_Template extends EEM_Base
15 15
 {
16
-    // private instance of the EEM_Message_Template object
17
-    protected static $_instance = null;
16
+	// private instance of the EEM_Message_Template object
17
+	protected static $_instance = null;
18 18
 
19 19
 
20 20
 
21
-    /**
22
-     * private constructor to prevent direct creation
23
-     *
24
-     * @Constructor
25
-     * @access protected
26
-     * @param string $timezone
27
-     * @throws \EE_Error
28
-     */
29
-    protected function __construct($timezone = null)
30
-    {
31
-        $this->singular_item = __('Message Template', 'event_espresso');
32
-        $this->plural_item = __('Message Templates', 'event_espresso');
21
+	/**
22
+	 * private constructor to prevent direct creation
23
+	 *
24
+	 * @Constructor
25
+	 * @access protected
26
+	 * @param string $timezone
27
+	 * @throws \EE_Error
28
+	 */
29
+	protected function __construct($timezone = null)
30
+	{
31
+		$this->singular_item = __('Message Template', 'event_espresso');
32
+		$this->plural_item = __('Message Templates', 'event_espresso');
33 33
 
34
-        $this->_tables = array(
35
-            'Message_Template' => new EE_Primary_Table('esp_message_template', 'MTP_ID')
36
-        );
37
-        $this->_fields = array(
38
-            'Message_Template'=> array(
39
-                'MTP_ID'=> new EE_Primary_Key_Int_Field('MTP_ID', __('Message Template ID', 'event_espresso')),
40
-                'GRP_ID' => new EE_Foreign_Key_Int_Field('GRP_ID', __('Message Template Group ID', 'event_espresso'), false, 0, 'Message_Template_Group'),
41
-                'MTP_template_field'=>new EE_Plain_Text_Field('MTP_template_field', __('Field Name for this Template', 'event_espresso'), false, 'default'),
42
-                'MTP_context'=>new EE_Plain_Text_Field('MTP_context', __('Message Type Context for this field', 'event_espresso'), false, 'admin'),
43
-                'MTP_content'=>new EE_Serialized_Text_Field('MTP_content', __('The field content for the template', 'event_espresso'), false, ''),
44
-            )
45
-        );
34
+		$this->_tables = array(
35
+			'Message_Template' => new EE_Primary_Table('esp_message_template', 'MTP_ID')
36
+		);
37
+		$this->_fields = array(
38
+			'Message_Template'=> array(
39
+				'MTP_ID'=> new EE_Primary_Key_Int_Field('MTP_ID', __('Message Template ID', 'event_espresso')),
40
+				'GRP_ID' => new EE_Foreign_Key_Int_Field('GRP_ID', __('Message Template Group ID', 'event_espresso'), false, 0, 'Message_Template_Group'),
41
+				'MTP_template_field'=>new EE_Plain_Text_Field('MTP_template_field', __('Field Name for this Template', 'event_espresso'), false, 'default'),
42
+				'MTP_context'=>new EE_Plain_Text_Field('MTP_context', __('Message Type Context for this field', 'event_espresso'), false, 'admin'),
43
+				'MTP_content'=>new EE_Serialized_Text_Field('MTP_content', __('The field content for the template', 'event_espresso'), false, ''),
44
+			)
45
+		);
46 46
 
47
-        $this->_model_relations = array(
48
-            'Message_Template_Group' => new EE_Belongs_To_Relation()
49
-            );
50
-        $this->_model_chain_to_wp_user = 'Message_Template_Group';
51
-        foreach ($this->_cap_contexts_to_cap_action_map as $context => $action) {
52
-            $this->_cap_restriction_generators[ $context ] = new EE_Restriction_Generator_Global('Message_Template_Group.MTP_is_global');
53
-        }
54
-        $this->_caps_slug = 'messages';
55
-        parent::__construct($timezone);
56
-    }
47
+		$this->_model_relations = array(
48
+			'Message_Template_Group' => new EE_Belongs_To_Relation()
49
+			);
50
+		$this->_model_chain_to_wp_user = 'Message_Template_Group';
51
+		foreach ($this->_cap_contexts_to_cap_action_map as $context => $action) {
52
+			$this->_cap_restriction_generators[ $context ] = new EE_Restriction_Generator_Global('Message_Template_Group.MTP_is_global');
53
+		}
54
+		$this->_caps_slug = 'messages';
55
+		parent::__construct($timezone);
56
+	}
57 57
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@
 block discarded – undo
49 49
             );
50 50
         $this->_model_chain_to_wp_user = 'Message_Template_Group';
51 51
         foreach ($this->_cap_contexts_to_cap_action_map as $context => $action) {
52
-            $this->_cap_restriction_generators[ $context ] = new EE_Restriction_Generator_Global('Message_Template_Group.MTP_is_global');
52
+            $this->_cap_restriction_generators[$context] = new EE_Restriction_Generator_Global('Message_Template_Group.MTP_is_global');
53 53
         }
54 54
         $this->_caps_slug = 'messages';
55 55
         parent::__construct($timezone);
Please login to merge, or discard this patch.
core/db_models/EEM_Payment.model.php 2 patches
Indentation   +224 added lines, -224 removed lines patch added patch discarded remove patch
@@ -11,232 +11,232 @@
 block discarded – undo
11 11
 class EEM_Payment extends EEM_Base implements EEMI_Payment
12 12
 {
13 13
 
14
-    // private instance of the Payment object
15
-    protected static $_instance = null;
14
+	// private instance of the Payment object
15
+	protected static $_instance = null;
16 16
 
17 17
 
18 18
 
19 19
 /**
20
-     * Status id in esp_status table that represents an approved payment
21
-     */
22
-    const status_id_approved = 'PAP';
23
-
24
-
25
-    /**
26
-     * Status id in esp_status table that represents a pending payment
27
-     */
28
-    const status_id_pending = 'PPN';
29
-
30
-
31
-    /**
32
-     * Status id in esp_status table that represents a cancelled payment (eg, the
33
-     * user went to PayPal, but on the paypal site decided to cancel the payment)
34
-     */
35
-    const status_id_cancelled = 'PCN';
36
-
37
-
38
-
39
-    /**
40
-     * Status id in esp_status table that represents a payment that was declined by
41
-     * the gateway. (eg, the user's card had no funds, or it was a fraudulent card)
42
-     */
43
-    const status_id_declined = 'PDC';
44
-
45
-
46
-
47
-    /**
48
-     * Status id in esp_status table that represents a payment that failed for technical reasons.
49
-     * (Eg, there was some error in communicating with the payment gateway.)
50
-     */
51
-    const status_id_failed = 'PFL';
52
-
53
-    /**
54
-     *      private constructor to prevent direct creation
55
-     *      @Constructor
56
-     *      @access protected
57
-     *      @param string $timezone string representing the timezone we want to set for returned Date Time Strings (and any incoming timezone data that gets saved).  Note this just sends the timezone info to the date time model field objects.  Default is NULL (and will be assumed using the set timezone in the 'timezone_string' wp option)
58
-     *      @return EEM_Payment
59
-     */
60
-    protected function __construct($timezone)
61
-    {
62
-
63
-        $this->singular_item = __('Payment', 'event_espresso');
64
-        $this->plural_item = __('Payments', 'event_espresso');
65
-
66
-        $this->_tables = array(
67
-            'Payment'=>new EE_Primary_Table('esp_payment', 'PAY_ID')
68
-        );
69
-        $this->_fields = array(
70
-            'Payment'=>array(
71
-                'PAY_ID'=>new EE_Primary_Key_Int_Field('PAY_ID', __('Payment ID', 'event_espresso')),
72
-                'TXN_ID'=>new EE_Foreign_Key_Int_Field('TXN_ID', __('Transaction ID', 'event_espresso'), false, 0, 'Transaction'),
73
-                'STS_ID'=>new EE_Foreign_Key_String_Field('STS_ID', __('Status ID', 'event_espresso'), false, EEM_Payment::status_id_failed, 'Status'),
74
-                'PAY_timestamp'=> new EE_Datetime_Field('PAY_timestamp', __('Timestamp of when payment was attempted', 'event_espresso'), false, EE_Datetime_Field::now, $timezone),
75
-                'PAY_source'=>new EE_All_Caps_Text_Field('PAY_source', __('User-friendly description of payment', 'event_espresso'), false, 'CART'),
76
-                'PAY_amount'=>new EE_Money_Field('PAY_amount', __('Amount Payment should be for', 'event_espresso'), false, 0),
77
-                'PMD_ID'=>new EE_Foreign_Key_Int_Field('PMD_ID', __("Payment Method ID", 'event_espresso'), false, null, 'Payment_Method'),
78
-                'PAY_gateway_response'=>new EE_Plain_Text_Field('PAY_gateway_response', __('Response from Gateway about the payment', 'event_espresso'), false, ''),
79
-                'PAY_txn_id_chq_nmbr'=>new EE_Plain_Text_Field('PAY_txn_id_chq_nmbr', __('Gateway Transaction ID or Cheque Number', 'event_espresso'), true, ''),
80
-                'PAY_po_number'=>new EE_Plain_Text_Field('PAY_po_number', __('Purchase or Sales Number', 'event_espresso'), true, ''),
81
-                'PAY_extra_accntng'=>new EE_Simple_HTML_Field('PAY_extra_accntng', __('Extra Account Info', 'event_espresso'), true, ''),
82
-                'PAY_details'=>new EE_Serialized_Text_Field('PAY_details', __('Full Gateway response about payment', 'event_espresso'), true, ''),
83
-                'PAY_redirect_url'=>new EE_Plain_Text_Field('PAY_redirect_url', __("Redirect URL", 'event_espresso'), true),
84
-                'PAY_redirect_args'=>new EE_Serialized_Text_Field('PAY_redirect_args', __("Key-Value POST vars to send along with redirect", 'event_espresso'), true)
85
-            )
86
-        );
87
-        $this->_model_relations = array(
88
-            'Transaction'=> new EE_Belongs_To_Relation(),
89
-            'Status'=> new EE_Belongs_To_Relation(),
90
-            'Payment_Method'=>new EE_Belongs_To_Relation(),
91
-            'Registration_Payment' => new EE_Has_Many_Relation(),
92
-            'Registration' => new EE_HABTM_Relation('Registration_Payment'),
93
-        );
94
-        $this->_model_chain_to_wp_user = 'Payment_Method';
95
-        $this->_caps_slug = 'transactions';
96
-        parent::__construct($timezone);
97
-    }
98
-
99
-
100
-
101
-
102
-    /**
103
-     * Gets the payment by the gateway server's unique ID. Eg, the unique ID PayPal assigned
104
-     * to the payment. This is handy for verifying an IPN hasn't already been processed.
105
-     * @param string $PAY_txn_id_chq_nmbr
106
-     * @return EE_Payment
107
-     */
108
-    public function get_payment_by_txn_id_chq_nmbr($PAY_txn_id_chq_nmbr)
109
-    {
110
-        return $this->get_one(array(array('PAY_txn_id_chq_nmbr'=>$PAY_txn_id_chq_nmbr)));
111
-    }
112
-
113
-
114
-
115
-
116
-    /**
117
-    *       retrieve  all payments from db for a particular transaction, optionally with
118
-     *      a particular status
119
-    *
120
-    *       @access     public
121
-    *       @param      $TXN_ID
122
-     *      @param  string  $status_of_payment one of EEM_Payment::status_id_*, like 'PAP','PCN',etc. If none is provided, gets payments with any status
123
-    *       @return     EE_Payment[]
124
-    */
125
-    public function get_payments_for_transaction($TXN_ID = false, $status_of_payment = null)
126
-    {
127
-        // all payments for a TXN ordered chronologically
128
-        $query_params = array( array( 'TXN_ID' => $TXN_ID ), 'order_by' => array( 'PAY_timestamp' => 'ASC' ));
129
-        // if provided with a status, search specifically for that status. Otherwise get them all
130
-        if ($status_of_payment) {
131
-            $query_params[0]['STS_ID'] = $status_of_payment;
132
-        }
133
-        // retrieve payments
134
-        return $this->get_all($query_params);
135
-    }
136
-
137
-
138
-
139
-    /**
140
-     * Only gets payments which have been approved
141
-     * @param int $TXN_ID
142
-     * @return EE_Payment[]
143
-     */
144
-    public function get_approved_payments_for_transaction($TXN_ID = 0)
145
-    {
146
-        return $this->get_payments_for_transaction($TXN_ID, EEM_Payment::status_id_approved);
147
-    }
148
-
149
-
150
-
151
-
152
-
153
-    /**
154
-     * retrieve  all payments from db between two dates,
155
-     *
156
-     * @param string $start_date incoming start date. If empty the beginning of today is used.
157
-     * @param string $end_date   incoming end date. If empty the end of today is used.
158
-     * @param string $format    If you include $start_date or $end_date then you must include the format string
159
-     *                              for the format your date is in.
160
-     * @param string $timezone   If your range is in a different timezone then the current setting on this
161
-     *                                  WordPress install, then include it here.
162
-     * @throws EE_Error
163
-     *
164
-     * @return EE_Payment[]
165
-     */
166
-    public function get_payments_made_between_dates($start_date = '', $end_date = '', $format = '', $timezone = '')
167
-    {
168
-        $timezone = empty($timezone) ? EEH_DTT_Helper::get_timezone() : $timezone;
169
-        // if $start_date or $end date, verify $format is included.
170
-        if (( ! empty($start_date) || ! empty($end_date) ) && empty($format)) {
171
-            throw new EE_Error(__('You included a start date and/or a end date for this method but did not include a format string.  The format string is needed for setting up the query', 'event_espresso'));
172
-        }
173
-        $now = new DateTime('now');
174
-        // setup timezone objects once
175
-        $modelDateTimeZone = new DateTimeZone($this->_timezone);
176
-        $passedDateTimeZone = new DateTimeZone($timezone);
177
-        // setup start date
178
-        $start_date = ! empty($start_date) ? date_create_from_format($format, $start_date, $passedDateTimeZone) : $now;
179
-        EEH_DTT_Helper::setTimezone($start_date, $modelDateTimeZone);
180
-        $start_date = $start_date->format('Y-m-d') . ' 00:00:00';
181
-        $start_date = strtotime($start_date);
182
-        // setup end date
183
-        $end_date = ! empty($end_date) ? date_create_from_format($format, $end_date, $passedDateTimeZone) : $now;
184
-        EEH_DTT_Helper::setTimezone($end_date, $modelDateTimeZone);
185
-        $end_date = $end_date->format('Y-m-d') . ' 23:59:59';
186
-        $end_date = strtotime($end_date);
187
-
188
-        // make sure our start date is the lowest value and vice versa
189
-        $start = min($start_date, $end_date);
190
-        $end = max($start_date, $end_date);
191
-
192
-        // yes we generated the date and time string in utc but we WANT this start date and time used in the set timezone on the model.
193
-        $start_date = $this->convert_datetime_for_query('PAY_timestamp', date('Y-m-d', $start) . ' 00:00:00', 'Y-m-d H:i:s', $this->get_timezone());
194
-        $end_date = $this->convert_datetime_for_query('PAY_timestamp', date('Y-m-d', $end) . ' 23:59:59', 'Y-m-d H:i:s', $this->get_timezone());
195
-
196
-        return $this->get_all(array(array('PAY_timestamp'=>array('>=',$start_date),'PAY_timestamp*'=>array('<=',$end_date))));
197
-    }
198
-
199
-    /**
200
-     * methods for EEMI_Payment
201
-     */
202
-    /**
203
-     * returns a string for the approved status
204
-     * @return  string
205
-     */
206
-    public function approved_status()
207
-    {
208
-        return self::status_id_approved;
209
-    }
210
-    /**
211
-     * returns a string for the pending status
212
-     * @return  string
213
-     */
214
-    public function pending_status()
215
-    {
216
-        return self::status_id_pending;
217
-    }
218
-    /**
219
-     * returns a string for the cancelled status
220
-     * @return  string
221
-     */
222
-    public function cancelled_status()
223
-    {
224
-        return self::status_id_cancelled;
225
-    }
226
-    /**
227
-     * returns a string for the failed status
228
-     * @return  string
229
-     */
230
-    public function failed_status()
231
-    {
232
-        return self::status_id_failed;
233
-    }
234
-    /**
235
-     * returns a string for the declined status
236
-     * @return  string
237
-     */
238
-    public function declined_status()
239
-    {
240
-        return self::status_id_declined;
241
-    }
20
+ * Status id in esp_status table that represents an approved payment
21
+ */
22
+	const status_id_approved = 'PAP';
23
+
24
+
25
+	/**
26
+	 * Status id in esp_status table that represents a pending payment
27
+	 */
28
+	const status_id_pending = 'PPN';
29
+
30
+
31
+	/**
32
+	 * Status id in esp_status table that represents a cancelled payment (eg, the
33
+	 * user went to PayPal, but on the paypal site decided to cancel the payment)
34
+	 */
35
+	const status_id_cancelled = 'PCN';
36
+
37
+
38
+
39
+	/**
40
+	 * Status id in esp_status table that represents a payment that was declined by
41
+	 * the gateway. (eg, the user's card had no funds, or it was a fraudulent card)
42
+	 */
43
+	const status_id_declined = 'PDC';
44
+
45
+
46
+
47
+	/**
48
+	 * Status id in esp_status table that represents a payment that failed for technical reasons.
49
+	 * (Eg, there was some error in communicating with the payment gateway.)
50
+	 */
51
+	const status_id_failed = 'PFL';
52
+
53
+	/**
54
+	 *      private constructor to prevent direct creation
55
+	 *      @Constructor
56
+	 *      @access protected
57
+	 *      @param string $timezone string representing the timezone we want to set for returned Date Time Strings (and any incoming timezone data that gets saved).  Note this just sends the timezone info to the date time model field objects.  Default is NULL (and will be assumed using the set timezone in the 'timezone_string' wp option)
58
+	 *      @return EEM_Payment
59
+	 */
60
+	protected function __construct($timezone)
61
+	{
62
+
63
+		$this->singular_item = __('Payment', 'event_espresso');
64
+		$this->plural_item = __('Payments', 'event_espresso');
65
+
66
+		$this->_tables = array(
67
+			'Payment'=>new EE_Primary_Table('esp_payment', 'PAY_ID')
68
+		);
69
+		$this->_fields = array(
70
+			'Payment'=>array(
71
+				'PAY_ID'=>new EE_Primary_Key_Int_Field('PAY_ID', __('Payment ID', 'event_espresso')),
72
+				'TXN_ID'=>new EE_Foreign_Key_Int_Field('TXN_ID', __('Transaction ID', 'event_espresso'), false, 0, 'Transaction'),
73
+				'STS_ID'=>new EE_Foreign_Key_String_Field('STS_ID', __('Status ID', 'event_espresso'), false, EEM_Payment::status_id_failed, 'Status'),
74
+				'PAY_timestamp'=> new EE_Datetime_Field('PAY_timestamp', __('Timestamp of when payment was attempted', 'event_espresso'), false, EE_Datetime_Field::now, $timezone),
75
+				'PAY_source'=>new EE_All_Caps_Text_Field('PAY_source', __('User-friendly description of payment', 'event_espresso'), false, 'CART'),
76
+				'PAY_amount'=>new EE_Money_Field('PAY_amount', __('Amount Payment should be for', 'event_espresso'), false, 0),
77
+				'PMD_ID'=>new EE_Foreign_Key_Int_Field('PMD_ID', __("Payment Method ID", 'event_espresso'), false, null, 'Payment_Method'),
78
+				'PAY_gateway_response'=>new EE_Plain_Text_Field('PAY_gateway_response', __('Response from Gateway about the payment', 'event_espresso'), false, ''),
79
+				'PAY_txn_id_chq_nmbr'=>new EE_Plain_Text_Field('PAY_txn_id_chq_nmbr', __('Gateway Transaction ID or Cheque Number', 'event_espresso'), true, ''),
80
+				'PAY_po_number'=>new EE_Plain_Text_Field('PAY_po_number', __('Purchase or Sales Number', 'event_espresso'), true, ''),
81
+				'PAY_extra_accntng'=>new EE_Simple_HTML_Field('PAY_extra_accntng', __('Extra Account Info', 'event_espresso'), true, ''),
82
+				'PAY_details'=>new EE_Serialized_Text_Field('PAY_details', __('Full Gateway response about payment', 'event_espresso'), true, ''),
83
+				'PAY_redirect_url'=>new EE_Plain_Text_Field('PAY_redirect_url', __("Redirect URL", 'event_espresso'), true),
84
+				'PAY_redirect_args'=>new EE_Serialized_Text_Field('PAY_redirect_args', __("Key-Value POST vars to send along with redirect", 'event_espresso'), true)
85
+			)
86
+		);
87
+		$this->_model_relations = array(
88
+			'Transaction'=> new EE_Belongs_To_Relation(),
89
+			'Status'=> new EE_Belongs_To_Relation(),
90
+			'Payment_Method'=>new EE_Belongs_To_Relation(),
91
+			'Registration_Payment' => new EE_Has_Many_Relation(),
92
+			'Registration' => new EE_HABTM_Relation('Registration_Payment'),
93
+		);
94
+		$this->_model_chain_to_wp_user = 'Payment_Method';
95
+		$this->_caps_slug = 'transactions';
96
+		parent::__construct($timezone);
97
+	}
98
+
99
+
100
+
101
+
102
+	/**
103
+	 * Gets the payment by the gateway server's unique ID. Eg, the unique ID PayPal assigned
104
+	 * to the payment. This is handy for verifying an IPN hasn't already been processed.
105
+	 * @param string $PAY_txn_id_chq_nmbr
106
+	 * @return EE_Payment
107
+	 */
108
+	public function get_payment_by_txn_id_chq_nmbr($PAY_txn_id_chq_nmbr)
109
+	{
110
+		return $this->get_one(array(array('PAY_txn_id_chq_nmbr'=>$PAY_txn_id_chq_nmbr)));
111
+	}
112
+
113
+
114
+
115
+
116
+	/**
117
+	 *       retrieve  all payments from db for a particular transaction, optionally with
118
+	 *      a particular status
119
+	 *
120
+	 *       @access     public
121
+	 *       @param      $TXN_ID
122
+	 *      @param  string  $status_of_payment one of EEM_Payment::status_id_*, like 'PAP','PCN',etc. If none is provided, gets payments with any status
123
+	 *       @return     EE_Payment[]
124
+	 */
125
+	public function get_payments_for_transaction($TXN_ID = false, $status_of_payment = null)
126
+	{
127
+		// all payments for a TXN ordered chronologically
128
+		$query_params = array( array( 'TXN_ID' => $TXN_ID ), 'order_by' => array( 'PAY_timestamp' => 'ASC' ));
129
+		// if provided with a status, search specifically for that status. Otherwise get them all
130
+		if ($status_of_payment) {
131
+			$query_params[0]['STS_ID'] = $status_of_payment;
132
+		}
133
+		// retrieve payments
134
+		return $this->get_all($query_params);
135
+	}
136
+
137
+
138
+
139
+	/**
140
+	 * Only gets payments which have been approved
141
+	 * @param int $TXN_ID
142
+	 * @return EE_Payment[]
143
+	 */
144
+	public function get_approved_payments_for_transaction($TXN_ID = 0)
145
+	{
146
+		return $this->get_payments_for_transaction($TXN_ID, EEM_Payment::status_id_approved);
147
+	}
148
+
149
+
150
+
151
+
152
+
153
+	/**
154
+	 * retrieve  all payments from db between two dates,
155
+	 *
156
+	 * @param string $start_date incoming start date. If empty the beginning of today is used.
157
+	 * @param string $end_date   incoming end date. If empty the end of today is used.
158
+	 * @param string $format    If you include $start_date or $end_date then you must include the format string
159
+	 *                              for the format your date is in.
160
+	 * @param string $timezone   If your range is in a different timezone then the current setting on this
161
+	 *                                  WordPress install, then include it here.
162
+	 * @throws EE_Error
163
+	 *
164
+	 * @return EE_Payment[]
165
+	 */
166
+	public function get_payments_made_between_dates($start_date = '', $end_date = '', $format = '', $timezone = '')
167
+	{
168
+		$timezone = empty($timezone) ? EEH_DTT_Helper::get_timezone() : $timezone;
169
+		// if $start_date or $end date, verify $format is included.
170
+		if (( ! empty($start_date) || ! empty($end_date) ) && empty($format)) {
171
+			throw new EE_Error(__('You included a start date and/or a end date for this method but did not include a format string.  The format string is needed for setting up the query', 'event_espresso'));
172
+		}
173
+		$now = new DateTime('now');
174
+		// setup timezone objects once
175
+		$modelDateTimeZone = new DateTimeZone($this->_timezone);
176
+		$passedDateTimeZone = new DateTimeZone($timezone);
177
+		// setup start date
178
+		$start_date = ! empty($start_date) ? date_create_from_format($format, $start_date, $passedDateTimeZone) : $now;
179
+		EEH_DTT_Helper::setTimezone($start_date, $modelDateTimeZone);
180
+		$start_date = $start_date->format('Y-m-d') . ' 00:00:00';
181
+		$start_date = strtotime($start_date);
182
+		// setup end date
183
+		$end_date = ! empty($end_date) ? date_create_from_format($format, $end_date, $passedDateTimeZone) : $now;
184
+		EEH_DTT_Helper::setTimezone($end_date, $modelDateTimeZone);
185
+		$end_date = $end_date->format('Y-m-d') . ' 23:59:59';
186
+		$end_date = strtotime($end_date);
187
+
188
+		// make sure our start date is the lowest value and vice versa
189
+		$start = min($start_date, $end_date);
190
+		$end = max($start_date, $end_date);
191
+
192
+		// yes we generated the date and time string in utc but we WANT this start date and time used in the set timezone on the model.
193
+		$start_date = $this->convert_datetime_for_query('PAY_timestamp', date('Y-m-d', $start) . ' 00:00:00', 'Y-m-d H:i:s', $this->get_timezone());
194
+		$end_date = $this->convert_datetime_for_query('PAY_timestamp', date('Y-m-d', $end) . ' 23:59:59', 'Y-m-d H:i:s', $this->get_timezone());
195
+
196
+		return $this->get_all(array(array('PAY_timestamp'=>array('>=',$start_date),'PAY_timestamp*'=>array('<=',$end_date))));
197
+	}
198
+
199
+	/**
200
+	 * methods for EEMI_Payment
201
+	 */
202
+	/**
203
+	 * returns a string for the approved status
204
+	 * @return  string
205
+	 */
206
+	public function approved_status()
207
+	{
208
+		return self::status_id_approved;
209
+	}
210
+	/**
211
+	 * returns a string for the pending status
212
+	 * @return  string
213
+	 */
214
+	public function pending_status()
215
+	{
216
+		return self::status_id_pending;
217
+	}
218
+	/**
219
+	 * returns a string for the cancelled status
220
+	 * @return  string
221
+	 */
222
+	public function cancelled_status()
223
+	{
224
+		return self::status_id_cancelled;
225
+	}
226
+	/**
227
+	 * returns a string for the failed status
228
+	 * @return  string
229
+	 */
230
+	public function failed_status()
231
+	{
232
+		return self::status_id_failed;
233
+	}
234
+	/**
235
+	 * returns a string for the declined status
236
+	 * @return  string
237
+	 */
238
+	public function declined_status()
239
+	{
240
+		return self::status_id_declined;
241
+	}
242 242
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
     public function get_payments_for_transaction($TXN_ID = false, $status_of_payment = null)
126 126
     {
127 127
         // all payments for a TXN ordered chronologically
128
-        $query_params = array( array( 'TXN_ID' => $TXN_ID ), 'order_by' => array( 'PAY_timestamp' => 'ASC' ));
128
+        $query_params = array(array('TXN_ID' => $TXN_ID), 'order_by' => array('PAY_timestamp' => 'ASC'));
129 129
         // if provided with a status, search specifically for that status. Otherwise get them all
130 130
         if ($status_of_payment) {
131 131
             $query_params[0]['STS_ID'] = $status_of_payment;
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
     {
168 168
         $timezone = empty($timezone) ? EEH_DTT_Helper::get_timezone() : $timezone;
169 169
         // if $start_date or $end date, verify $format is included.
170
-        if (( ! empty($start_date) || ! empty($end_date) ) && empty($format)) {
170
+        if (( ! empty($start_date) || ! empty($end_date)) && empty($format)) {
171 171
             throw new EE_Error(__('You included a start date and/or a end date for this method but did not include a format string.  The format string is needed for setting up the query', 'event_espresso'));
172 172
         }
173 173
         $now = new DateTime('now');
@@ -177,12 +177,12 @@  discard block
 block discarded – undo
177 177
         // setup start date
178 178
         $start_date = ! empty($start_date) ? date_create_from_format($format, $start_date, $passedDateTimeZone) : $now;
179 179
         EEH_DTT_Helper::setTimezone($start_date, $modelDateTimeZone);
180
-        $start_date = $start_date->format('Y-m-d') . ' 00:00:00';
180
+        $start_date = $start_date->format('Y-m-d').' 00:00:00';
181 181
         $start_date = strtotime($start_date);
182 182
         // setup end date
183 183
         $end_date = ! empty($end_date) ? date_create_from_format($format, $end_date, $passedDateTimeZone) : $now;
184 184
         EEH_DTT_Helper::setTimezone($end_date, $modelDateTimeZone);
185
-        $end_date = $end_date->format('Y-m-d') . ' 23:59:59';
185
+        $end_date = $end_date->format('Y-m-d').' 23:59:59';
186 186
         $end_date = strtotime($end_date);
187 187
 
188 188
         // make sure our start date is the lowest value and vice versa
@@ -190,10 +190,10 @@  discard block
 block discarded – undo
190 190
         $end = max($start_date, $end_date);
191 191
 
192 192
         // yes we generated the date and time string in utc but we WANT this start date and time used in the set timezone on the model.
193
-        $start_date = $this->convert_datetime_for_query('PAY_timestamp', date('Y-m-d', $start) . ' 00:00:00', 'Y-m-d H:i:s', $this->get_timezone());
194
-        $end_date = $this->convert_datetime_for_query('PAY_timestamp', date('Y-m-d', $end) . ' 23:59:59', 'Y-m-d H:i:s', $this->get_timezone());
193
+        $start_date = $this->convert_datetime_for_query('PAY_timestamp', date('Y-m-d', $start).' 00:00:00', 'Y-m-d H:i:s', $this->get_timezone());
194
+        $end_date = $this->convert_datetime_for_query('PAY_timestamp', date('Y-m-d', $end).' 23:59:59', 'Y-m-d H:i:s', $this->get_timezone());
195 195
 
196
-        return $this->get_all(array(array('PAY_timestamp'=>array('>=',$start_date),'PAY_timestamp*'=>array('<=',$end_date))));
196
+        return $this->get_all(array(array('PAY_timestamp'=>array('>=', $start_date), 'PAY_timestamp*'=>array('<=', $end_date))));
197 197
     }
198 198
 
199 199
     /**
Please login to merge, or discard this patch.