@@ -112,24 +112,24 @@ discard block |
||
| 112 | 112 | public function prepare_where_conditions_for_querying($where_conditions, $model_relation_chain) |
| 113 | 113 | { |
| 114 | 114 | $where_conditions_with_model_relation_chain_prefixes = array(); |
| 115 | - if (! is_array($where_conditions)) { |
|
| 115 | + if ( ! is_array($where_conditions)) { |
|
| 116 | 116 | $where_conditions = array(); |
| 117 | 117 | } |
| 118 | 118 | foreach ($where_conditions as $key => $value) { |
| 119 | - if (in_array($key, array( 'OR', 'AND', 'NOT' )) |
|
| 119 | + if (in_array($key, array('OR', 'AND', 'NOT')) |
|
| 120 | 120 | || strpos($key, 'OR*') !== false |
| 121 | 121 | || strpos($key, 'AND*') !== false |
| 122 | 122 | || strpos($key, 'NOT*') !== false |
| 123 | 123 | ) { |
| 124 | - $where_conditions_with_model_relation_chain_prefixes[ $key ] = $this->prepare_where_conditions_for_querying( |
|
| 124 | + $where_conditions_with_model_relation_chain_prefixes[$key] = $this->prepare_where_conditions_for_querying( |
|
| 125 | 125 | $value, |
| 126 | 126 | $model_relation_chain |
| 127 | 127 | ); |
| 128 | 128 | } else { |
| 129 | 129 | if ($model_relation_chain != '' |
| 130 | - && $model_relation_chain[ strlen($model_relation_chain) - 1 ] != '.' |
|
| 130 | + && $model_relation_chain[strlen($model_relation_chain) - 1] != '.' |
|
| 131 | 131 | ) { |
| 132 | - $model_relation_chain = $model_relation_chain . "."; |
|
| 132 | + $model_relation_chain = $model_relation_chain."."; |
|
| 133 | 133 | } |
| 134 | 134 | // check for the current user id place holder, and if present change it |
| 135 | 135 | if ($value === self::current_user_placeholder) { |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | } |
| 138 | 138 | // check for user field placeholder |
| 139 | 139 | if ($key == self::user_field_name_placeholder) { |
| 140 | - if (! $this->_model->wp_user_field_name()) { |
|
| 140 | + if ( ! $this->_model->wp_user_field_name()) { |
|
| 141 | 141 | throw new EE_Error( |
| 142 | 142 | sprintf( |
| 143 | 143 | __( |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | } |
| 151 | 151 | $key = $this->_model->wp_user_field_name(); |
| 152 | 152 | } |
| 153 | - $where_conditions_with_model_relation_chain_prefixes[ $model_relation_chain . $key ] = $value; |
|
| 153 | + $where_conditions_with_model_relation_chain_prefixes[$model_relation_chain.$key] = $value; |
|
| 154 | 154 | } |
| 155 | 155 | } |
| 156 | 156 | return $where_conditions_with_model_relation_chain_prefixes; |
@@ -3,7 +3,7 @@ discard block |
||
| 3 | 3 | /** |
| 4 | 4 | * |
| 5 | 5 | * Class EE_Default_Where_Conditions |
| 6 | - * |
|
| 6 | + * |
|
| 7 | 7 | * Strategy to be used for getting default where conditions for EEM_Base children. |
| 8 | 8 | * Should be initialized and set on construction of model |
| 9 | 9 | * |
@@ -16,143 +16,143 @@ discard block |
||
| 16 | 16 | class EE_Default_Where_Conditions |
| 17 | 17 | { |
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * This const can be used in EE_Default_Where_Conditions values, and at the time of querying it will be |
|
| 21 | - * replaced with the current user's ID (because we don't want to use the current user's ID at time of |
|
| 22 | - * initializing the models because it's too early) |
|
| 23 | - */ |
|
| 24 | - const current_user_placeholder = '%$current_user_placeholder_should_be_replaced_automatically$%'; |
|
| 25 | - |
|
| 26 | - /** |
|
| 27 | - * This const can be used in EE_Default_Where_Conditions where parameters as the name |
|
| 28 | - * of the user field. When we are actually generating the where conditions it will be |
|
| 29 | - * replaced with the model's wp user fieldname |
|
| 30 | - */ |
|
| 31 | - const user_field_name_placeholder = '%$user_field_name_placeholder$%'; |
|
| 32 | - |
|
| 33 | - /** |
|
| 34 | - * Model for which this strategy find default where conditions |
|
| 35 | - * @var EEM_Base |
|
| 36 | - */ |
|
| 37 | - protected $_model; |
|
| 38 | - |
|
| 39 | - /** |
|
| 40 | - * Where conditions specified on construction |
|
| 41 | - * @var array |
|
| 42 | - */ |
|
| 43 | - protected $_where_conditions_provided = array(); |
|
| 44 | - |
|
| 45 | - /** |
|
| 46 | - * Custom where conditions. Model relation chains will be automatically added |
|
| 47 | - * onto any field names |
|
| 48 | - * @param array $custom_where_conditions |
|
| 49 | - */ |
|
| 50 | - public function __construct($custom_where_conditions = array()) |
|
| 51 | - { |
|
| 52 | - $this->_where_conditions_provided = $custom_where_conditions; |
|
| 53 | - } |
|
| 54 | - |
|
| 55 | - |
|
| 56 | - |
|
| 57 | - /** |
|
| 58 | - * finalizes construction of the strategy for use in getting default where conditions |
|
| 59 | - * for querying of the model. |
|
| 60 | - * @param EEM_Base $model |
|
| 61 | - */ |
|
| 62 | - public function _finalize_construct(EEM_Base $model) |
|
| 63 | - { |
|
| 64 | - $this->_model = $model; |
|
| 65 | - } |
|
| 66 | - |
|
| 67 | - |
|
| 68 | - |
|
| 69 | - /** |
|
| 70 | - * Returns the where conditions explicitly passed in the constructor |
|
| 71 | - * @return array |
|
| 72 | - */ |
|
| 73 | - public function get_where_conditions_provided() |
|
| 74 | - { |
|
| 75 | - return $this->_where_conditions_provided; |
|
| 76 | - } |
|
| 77 | - |
|
| 78 | - |
|
| 79 | - |
|
| 80 | - /** |
|
| 81 | - * Gets the where conditions to be added onto the query |
|
| 82 | - * @param string $model_relation_chain |
|
| 83 | - * @return array @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md#0-where-conditions |
|
| 84 | - */ |
|
| 85 | - public function get_default_where_conditions($model_relation_chain = '') |
|
| 86 | - { |
|
| 87 | - return $this->prepare_where_conditions_for_querying(array_merge($this->_get_default_where_conditions(), $this->get_where_conditions_provided()), $model_relation_chain); |
|
| 88 | - } |
|
| 89 | - |
|
| 90 | - |
|
| 91 | - |
|
| 92 | - /** |
|
| 93 | - * Gets the default where conditions that are specific to this child of EE_Default_Where_Conditions. |
|
| 94 | - * Adding model relation chains is handled by the public method get_default_where_conditions |
|
| 95 | - * @return array |
|
| 96 | - */ |
|
| 97 | - protected function _get_default_where_conditions() |
|
| 98 | - { |
|
| 99 | - return array(); |
|
| 100 | - } |
|
| 101 | - |
|
| 102 | - |
|
| 103 | - |
|
| 104 | - /** |
|
| 105 | - * Takes the default query parameters, and traverses them, adding the model relation chain |
|
| 106 | - * onto them (intelligently doesn't do that to logic query params like NOT, OR, and AND) |
|
| 107 | - * @param array $where_conditions |
|
| 108 | - * @param string $model_relation_chain |
|
| 109 | - * @return array |
|
| 110 | - * @throws \EE_Error |
|
| 111 | - */ |
|
| 112 | - public function prepare_where_conditions_for_querying($where_conditions, $model_relation_chain) |
|
| 113 | - { |
|
| 114 | - $where_conditions_with_model_relation_chain_prefixes = array(); |
|
| 115 | - if (! is_array($where_conditions)) { |
|
| 116 | - $where_conditions = array(); |
|
| 117 | - } |
|
| 118 | - foreach ($where_conditions as $key => $value) { |
|
| 119 | - if (in_array($key, array( 'OR', 'AND', 'NOT' )) |
|
| 120 | - || strpos($key, 'OR*') !== false |
|
| 121 | - || strpos($key, 'AND*') !== false |
|
| 122 | - || strpos($key, 'NOT*') !== false |
|
| 123 | - ) { |
|
| 124 | - $where_conditions_with_model_relation_chain_prefixes[ $key ] = $this->prepare_where_conditions_for_querying( |
|
| 125 | - $value, |
|
| 126 | - $model_relation_chain |
|
| 127 | - ); |
|
| 128 | - } else { |
|
| 129 | - if ($model_relation_chain != '' |
|
| 130 | - && $model_relation_chain[ strlen($model_relation_chain) - 1 ] != '.' |
|
| 131 | - ) { |
|
| 132 | - $model_relation_chain = $model_relation_chain . "."; |
|
| 133 | - } |
|
| 134 | - // check for the current user id place holder, and if present change it |
|
| 135 | - if ($value === self::current_user_placeholder) { |
|
| 136 | - $value = get_current_user_id(); |
|
| 137 | - } |
|
| 138 | - // check for user field placeholder |
|
| 139 | - if ($key == self::user_field_name_placeholder) { |
|
| 140 | - if (! $this->_model->wp_user_field_name()) { |
|
| 141 | - throw new EE_Error( |
|
| 142 | - sprintf( |
|
| 143 | - __( |
|
| 144 | - 'There is no foreign key to the WP_User model on model %s. Please either modify your default where conditions, add a _model_chain_to_wp_user onto the model, or a proper EE_WP_User_Field onto the model', |
|
| 145 | - 'event_espresso' |
|
| 146 | - ), |
|
| 147 | - $this->_model->get_this_model_name() |
|
| 148 | - ) |
|
| 149 | - ); |
|
| 150 | - } |
|
| 151 | - $key = $this->_model->wp_user_field_name(); |
|
| 152 | - } |
|
| 153 | - $where_conditions_with_model_relation_chain_prefixes[ $model_relation_chain . $key ] = $value; |
|
| 154 | - } |
|
| 155 | - } |
|
| 156 | - return $where_conditions_with_model_relation_chain_prefixes; |
|
| 157 | - } |
|
| 19 | + /** |
|
| 20 | + * This const can be used in EE_Default_Where_Conditions values, and at the time of querying it will be |
|
| 21 | + * replaced with the current user's ID (because we don't want to use the current user's ID at time of |
|
| 22 | + * initializing the models because it's too early) |
|
| 23 | + */ |
|
| 24 | + const current_user_placeholder = '%$current_user_placeholder_should_be_replaced_automatically$%'; |
|
| 25 | + |
|
| 26 | + /** |
|
| 27 | + * This const can be used in EE_Default_Where_Conditions where parameters as the name |
|
| 28 | + * of the user field. When we are actually generating the where conditions it will be |
|
| 29 | + * replaced with the model's wp user fieldname |
|
| 30 | + */ |
|
| 31 | + const user_field_name_placeholder = '%$user_field_name_placeholder$%'; |
|
| 32 | + |
|
| 33 | + /** |
|
| 34 | + * Model for which this strategy find default where conditions |
|
| 35 | + * @var EEM_Base |
|
| 36 | + */ |
|
| 37 | + protected $_model; |
|
| 38 | + |
|
| 39 | + /** |
|
| 40 | + * Where conditions specified on construction |
|
| 41 | + * @var array |
|
| 42 | + */ |
|
| 43 | + protected $_where_conditions_provided = array(); |
|
| 44 | + |
|
| 45 | + /** |
|
| 46 | + * Custom where conditions. Model relation chains will be automatically added |
|
| 47 | + * onto any field names |
|
| 48 | + * @param array $custom_where_conditions |
|
| 49 | + */ |
|
| 50 | + public function __construct($custom_where_conditions = array()) |
|
| 51 | + { |
|
| 52 | + $this->_where_conditions_provided = $custom_where_conditions; |
|
| 53 | + } |
|
| 54 | + |
|
| 55 | + |
|
| 56 | + |
|
| 57 | + /** |
|
| 58 | + * finalizes construction of the strategy for use in getting default where conditions |
|
| 59 | + * for querying of the model. |
|
| 60 | + * @param EEM_Base $model |
|
| 61 | + */ |
|
| 62 | + public function _finalize_construct(EEM_Base $model) |
|
| 63 | + { |
|
| 64 | + $this->_model = $model; |
|
| 65 | + } |
|
| 66 | + |
|
| 67 | + |
|
| 68 | + |
|
| 69 | + /** |
|
| 70 | + * Returns the where conditions explicitly passed in the constructor |
|
| 71 | + * @return array |
|
| 72 | + */ |
|
| 73 | + public function get_where_conditions_provided() |
|
| 74 | + { |
|
| 75 | + return $this->_where_conditions_provided; |
|
| 76 | + } |
|
| 77 | + |
|
| 78 | + |
|
| 79 | + |
|
| 80 | + /** |
|
| 81 | + * Gets the where conditions to be added onto the query |
|
| 82 | + * @param string $model_relation_chain |
|
| 83 | + * @return array @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md#0-where-conditions |
|
| 84 | + */ |
|
| 85 | + public function get_default_where_conditions($model_relation_chain = '') |
|
| 86 | + { |
|
| 87 | + return $this->prepare_where_conditions_for_querying(array_merge($this->_get_default_where_conditions(), $this->get_where_conditions_provided()), $model_relation_chain); |
|
| 88 | + } |
|
| 89 | + |
|
| 90 | + |
|
| 91 | + |
|
| 92 | + /** |
|
| 93 | + * Gets the default where conditions that are specific to this child of EE_Default_Where_Conditions. |
|
| 94 | + * Adding model relation chains is handled by the public method get_default_where_conditions |
|
| 95 | + * @return array |
|
| 96 | + */ |
|
| 97 | + protected function _get_default_where_conditions() |
|
| 98 | + { |
|
| 99 | + return array(); |
|
| 100 | + } |
|
| 101 | + |
|
| 102 | + |
|
| 103 | + |
|
| 104 | + /** |
|
| 105 | + * Takes the default query parameters, and traverses them, adding the model relation chain |
|
| 106 | + * onto them (intelligently doesn't do that to logic query params like NOT, OR, and AND) |
|
| 107 | + * @param array $where_conditions |
|
| 108 | + * @param string $model_relation_chain |
|
| 109 | + * @return array |
|
| 110 | + * @throws \EE_Error |
|
| 111 | + */ |
|
| 112 | + public function prepare_where_conditions_for_querying($where_conditions, $model_relation_chain) |
|
| 113 | + { |
|
| 114 | + $where_conditions_with_model_relation_chain_prefixes = array(); |
|
| 115 | + if (! is_array($where_conditions)) { |
|
| 116 | + $where_conditions = array(); |
|
| 117 | + } |
|
| 118 | + foreach ($where_conditions as $key => $value) { |
|
| 119 | + if (in_array($key, array( 'OR', 'AND', 'NOT' )) |
|
| 120 | + || strpos($key, 'OR*') !== false |
|
| 121 | + || strpos($key, 'AND*') !== false |
|
| 122 | + || strpos($key, 'NOT*') !== false |
|
| 123 | + ) { |
|
| 124 | + $where_conditions_with_model_relation_chain_prefixes[ $key ] = $this->prepare_where_conditions_for_querying( |
|
| 125 | + $value, |
|
| 126 | + $model_relation_chain |
|
| 127 | + ); |
|
| 128 | + } else { |
|
| 129 | + if ($model_relation_chain != '' |
|
| 130 | + && $model_relation_chain[ strlen($model_relation_chain) - 1 ] != '.' |
|
| 131 | + ) { |
|
| 132 | + $model_relation_chain = $model_relation_chain . "."; |
|
| 133 | + } |
|
| 134 | + // check for the current user id place holder, and if present change it |
|
| 135 | + if ($value === self::current_user_placeholder) { |
|
| 136 | + $value = get_current_user_id(); |
|
| 137 | + } |
|
| 138 | + // check for user field placeholder |
|
| 139 | + if ($key == self::user_field_name_placeholder) { |
|
| 140 | + if (! $this->_model->wp_user_field_name()) { |
|
| 141 | + throw new EE_Error( |
|
| 142 | + sprintf( |
|
| 143 | + __( |
|
| 144 | + 'There is no foreign key to the WP_User model on model %s. Please either modify your default where conditions, add a _model_chain_to_wp_user onto the model, or a proper EE_WP_User_Field onto the model', |
|
| 145 | + 'event_espresso' |
|
| 146 | + ), |
|
| 147 | + $this->_model->get_this_model_name() |
|
| 148 | + ) |
|
| 149 | + ); |
|
| 150 | + } |
|
| 151 | + $key = $this->_model->wp_user_field_name(); |
|
| 152 | + } |
|
| 153 | + $where_conditions_with_model_relation_chain_prefixes[ $model_relation_chain . $key ] = $value; |
|
| 154 | + } |
|
| 155 | + } |
|
| 156 | + return $where_conditions_with_model_relation_chain_prefixes; |
|
| 157 | + } |
|
| 158 | 158 | } |
@@ -20,47 +20,47 @@ |
||
| 20 | 20 | class EE_Restriction_Generator_Global extends EE_Restriction_Generator_Base |
| 21 | 21 | { |
| 22 | 22 | |
| 23 | - /** |
|
| 24 | - * name of the model field that indicates whether or not a model object is "global" |
|
| 25 | - * @var string |
|
| 26 | - */ |
|
| 27 | - protected $_global_field_name; |
|
| 28 | - /** |
|
| 29 | - * |
|
| 30 | - * @param string $global_field_name name of the model field that indicates whether or not |
|
| 31 | - * a model object is "global" |
|
| 32 | - */ |
|
| 33 | - public function __construct($global_field_name) |
|
| 34 | - { |
|
| 35 | - $this->_global_field_name = $global_field_name; |
|
| 36 | - } |
|
| 23 | + /** |
|
| 24 | + * name of the model field that indicates whether or not a model object is "global" |
|
| 25 | + * @var string |
|
| 26 | + */ |
|
| 27 | + protected $_global_field_name; |
|
| 28 | + /** |
|
| 29 | + * |
|
| 30 | + * @param string $global_field_name name of the model field that indicates whether or not |
|
| 31 | + * a model object is "global" |
|
| 32 | + */ |
|
| 33 | + public function __construct($global_field_name) |
|
| 34 | + { |
|
| 35 | + $this->_global_field_name = $global_field_name; |
|
| 36 | + } |
|
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * @return \EE_Default_Where_Conditions |
|
| 40 | - */ |
|
| 41 | - protected function _generate_restrictions() |
|
| 42 | - { |
|
| 38 | + /** |
|
| 39 | + * @return \EE_Default_Where_Conditions |
|
| 40 | + */ |
|
| 41 | + protected function _generate_restrictions() |
|
| 42 | + { |
|
| 43 | 43 | |
| 44 | - // if there are no standard caps for this model, then for now all we know is |
|
| 45 | - // if they need the default cap to access this |
|
| 46 | - if (! $this->model()->cap_slug()) { |
|
| 47 | - return array( |
|
| 48 | - EE_Restriction_Generator_Base::get_default_restrictions_cap() => new EE_Return_None_Where_Conditions() |
|
| 49 | - ); |
|
| 50 | - } |
|
| 51 | - return array( |
|
| 52 | - EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action()) => new EE_Return_None_Where_Conditions(), |
|
| 53 | - EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_others') => new EE_Default_Where_Conditions(array( |
|
| 54 | - // I need to be the owner, or it must be a global item |
|
| 55 | - 'OR*no_' . EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_others') => array( |
|
| 56 | - EE_Default_Where_Conditions::user_field_name_placeholder => EE_Default_Where_Conditions::current_user_placeholder, |
|
| 57 | - $this->_global_field_name => true |
|
| 58 | - ) |
|
| 59 | - )), |
|
| 60 | - EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_global') => new EE_Default_Where_Conditions(array( |
|
| 61 | - // it mustn't be global |
|
| 62 | - $this->_global_field_name => false |
|
| 63 | - )) |
|
| 64 | - ); |
|
| 65 | - } |
|
| 44 | + // if there are no standard caps for this model, then for now all we know is |
|
| 45 | + // if they need the default cap to access this |
|
| 46 | + if (! $this->model()->cap_slug()) { |
|
| 47 | + return array( |
|
| 48 | + EE_Restriction_Generator_Base::get_default_restrictions_cap() => new EE_Return_None_Where_Conditions() |
|
| 49 | + ); |
|
| 50 | + } |
|
| 51 | + return array( |
|
| 52 | + EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action()) => new EE_Return_None_Where_Conditions(), |
|
| 53 | + EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_others') => new EE_Default_Where_Conditions(array( |
|
| 54 | + // I need to be the owner, or it must be a global item |
|
| 55 | + 'OR*no_' . EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_others') => array( |
|
| 56 | + EE_Default_Where_Conditions::user_field_name_placeholder => EE_Default_Where_Conditions::current_user_placeholder, |
|
| 57 | + $this->_global_field_name => true |
|
| 58 | + ) |
|
| 59 | + )), |
|
| 60 | + EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_global') => new EE_Default_Where_Conditions(array( |
|
| 61 | + // it mustn't be global |
|
| 62 | + $this->_global_field_name => false |
|
| 63 | + )) |
|
| 64 | + ); |
|
| 65 | + } |
|
| 66 | 66 | } |
@@ -43,21 +43,21 @@ |
||
| 43 | 43 | |
| 44 | 44 | // if there are no standard caps for this model, then for now all we know is |
| 45 | 45 | // if they need the default cap to access this |
| 46 | - if (! $this->model()->cap_slug()) { |
|
| 46 | + if ( ! $this->model()->cap_slug()) { |
|
| 47 | 47 | return array( |
| 48 | 48 | EE_Restriction_Generator_Base::get_default_restrictions_cap() => new EE_Return_None_Where_Conditions() |
| 49 | 49 | ); |
| 50 | 50 | } |
| 51 | 51 | return array( |
| 52 | 52 | EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action()) => new EE_Return_None_Where_Conditions(), |
| 53 | - EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_others') => new EE_Default_Where_Conditions(array( |
|
| 53 | + EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action().'_others') => new EE_Default_Where_Conditions(array( |
|
| 54 | 54 | // I need to be the owner, or it must be a global item |
| 55 | - 'OR*no_' . EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_others') => array( |
|
| 55 | + 'OR*no_'.EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action().'_others') => array( |
|
| 56 | 56 | EE_Default_Where_Conditions::user_field_name_placeholder => EE_Default_Where_Conditions::current_user_placeholder, |
| 57 | 57 | $this->_global_field_name => true |
| 58 | 58 | ) |
| 59 | 59 | )), |
| 60 | - EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_global') => new EE_Default_Where_Conditions(array( |
|
| 60 | + EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action().'_global') => new EE_Default_Where_Conditions(array( |
|
| 61 | 61 | // it mustn't be global |
| 62 | 62 | $this->_global_field_name => false |
| 63 | 63 | )) |
@@ -25,48 +25,48 @@ |
||
| 25 | 25 | class EE_Restriction_Generator_Protected extends EE_Restriction_Generator_Base |
| 26 | 26 | { |
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * @return \EE_Default_Where_Conditions |
|
| 30 | - */ |
|
| 31 | - protected function _generate_restrictions() |
|
| 32 | - { |
|
| 28 | + /** |
|
| 29 | + * @return \EE_Default_Where_Conditions |
|
| 30 | + */ |
|
| 31 | + protected function _generate_restrictions() |
|
| 32 | + { |
|
| 33 | 33 | |
| 34 | - // if there are no standard caps for this model, then for now all we know |
|
| 35 | - // if they need the default cap to access this |
|
| 36 | - if (! $this->model()->cap_slug()) { |
|
| 37 | - return array( |
|
| 38 | - EE_Restriction_Generator_Base::get_default_restrictions_cap() => new EE_Return_None_Where_Conditions() |
|
| 39 | - ); |
|
| 40 | - } |
|
| 34 | + // if there are no standard caps for this model, then for now all we know |
|
| 35 | + // if they need the default cap to access this |
|
| 36 | + if (! $this->model()->cap_slug()) { |
|
| 37 | + return array( |
|
| 38 | + EE_Restriction_Generator_Base::get_default_restrictions_cap() => new EE_Return_None_Where_Conditions() |
|
| 39 | + ); |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - $restrictions = array(); |
|
| 43 | - // does the basic cap exist? (eg 'ee_read_registrations') |
|
| 44 | - if (EE_Restriction_Generator_Base::is_cap($this->model(), $this->action())) { |
|
| 45 | - $restrictions[ EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action()) ] = new EE_Return_None_Where_Conditions(); |
|
| 46 | - // does the others cap exist? (eg 'ee_read_others_registrations') |
|
| 47 | - if (EE_Restriction_Generator_Base::is_cap($this->model(), $this->action() . '_others')) {// both caps exist |
|
| 48 | - $restrictions[ EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_others') ] = new EE_Default_Where_Conditions( |
|
| 49 | - array( |
|
| 50 | - EE_Default_Where_Conditions::user_field_name_placeholder => EE_Default_Where_Conditions::current_user_placeholder |
|
| 51 | - ) |
|
| 52 | - ); |
|
| 53 | - // does the private cap exist (eg 'ee_read_others_private_events') |
|
| 54 | - if (EE_Restriction_Generator_Base::is_cap($this->model(), $this->action() . '_private') && $this->model() instanceof EEM_CPT_Base) { |
|
| 55 | - // if they have basic and others, but not private, restrict them to see theirs and others' that aren't private |
|
| 56 | - $restrictions[ EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_private') ] = new EE_Default_Where_Conditions( |
|
| 57 | - array( |
|
| 58 | - 'OR*no_' . EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_private') => array( |
|
| 59 | - EE_Default_Where_Conditions::user_field_name_placeholder => EE_Default_Where_Conditions::current_user_placeholder, |
|
| 60 | - 'status' => array( '!=', 'private' ) |
|
| 61 | - ) |
|
| 62 | - ) |
|
| 63 | - ); |
|
| 64 | - } |
|
| 65 | - } |
|
| 66 | - } else { |
|
| 67 | - // there is no basic cap. So they can only access this if they have the default admin cap |
|
| 68 | - $restrictions[ EE_Restriction_Generator_Base::get_default_restrictions_cap() ] = new EE_Return_None_Where_Conditions(); |
|
| 69 | - } |
|
| 70 | - return $restrictions; |
|
| 71 | - } |
|
| 42 | + $restrictions = array(); |
|
| 43 | + // does the basic cap exist? (eg 'ee_read_registrations') |
|
| 44 | + if (EE_Restriction_Generator_Base::is_cap($this->model(), $this->action())) { |
|
| 45 | + $restrictions[ EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action()) ] = new EE_Return_None_Where_Conditions(); |
|
| 46 | + // does the others cap exist? (eg 'ee_read_others_registrations') |
|
| 47 | + if (EE_Restriction_Generator_Base::is_cap($this->model(), $this->action() . '_others')) {// both caps exist |
|
| 48 | + $restrictions[ EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_others') ] = new EE_Default_Where_Conditions( |
|
| 49 | + array( |
|
| 50 | + EE_Default_Where_Conditions::user_field_name_placeholder => EE_Default_Where_Conditions::current_user_placeholder |
|
| 51 | + ) |
|
| 52 | + ); |
|
| 53 | + // does the private cap exist (eg 'ee_read_others_private_events') |
|
| 54 | + if (EE_Restriction_Generator_Base::is_cap($this->model(), $this->action() . '_private') && $this->model() instanceof EEM_CPT_Base) { |
|
| 55 | + // if they have basic and others, but not private, restrict them to see theirs and others' that aren't private |
|
| 56 | + $restrictions[ EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_private') ] = new EE_Default_Where_Conditions( |
|
| 57 | + array( |
|
| 58 | + 'OR*no_' . EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_private') => array( |
|
| 59 | + EE_Default_Where_Conditions::user_field_name_placeholder => EE_Default_Where_Conditions::current_user_placeholder, |
|
| 60 | + 'status' => array( '!=', 'private' ) |
|
| 61 | + ) |
|
| 62 | + ) |
|
| 63 | + ); |
|
| 64 | + } |
|
| 65 | + } |
|
| 66 | + } else { |
|
| 67 | + // there is no basic cap. So they can only access this if they have the default admin cap |
|
| 68 | + $restrictions[ EE_Restriction_Generator_Base::get_default_restrictions_cap() ] = new EE_Return_None_Where_Conditions(); |
|
| 69 | + } |
|
| 70 | + return $restrictions; |
|
| 71 | + } |
|
| 72 | 72 | } |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | |
| 34 | 34 | // if there are no standard caps for this model, then for now all we know |
| 35 | 35 | // if they need the default cap to access this |
| 36 | - if (! $this->model()->cap_slug()) { |
|
| 36 | + if ( ! $this->model()->cap_slug()) { |
|
| 37 | 37 | return array( |
| 38 | 38 | EE_Restriction_Generator_Base::get_default_restrictions_cap() => new EE_Return_None_Where_Conditions() |
| 39 | 39 | ); |
@@ -42,22 +42,22 @@ discard block |
||
| 42 | 42 | $restrictions = array(); |
| 43 | 43 | // does the basic cap exist? (eg 'ee_read_registrations') |
| 44 | 44 | if (EE_Restriction_Generator_Base::is_cap($this->model(), $this->action())) { |
| 45 | - $restrictions[ EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action()) ] = new EE_Return_None_Where_Conditions(); |
|
| 45 | + $restrictions[EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action())] = new EE_Return_None_Where_Conditions(); |
|
| 46 | 46 | // does the others cap exist? (eg 'ee_read_others_registrations') |
| 47 | - if (EE_Restriction_Generator_Base::is_cap($this->model(), $this->action() . '_others')) {// both caps exist |
|
| 48 | - $restrictions[ EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_others') ] = new EE_Default_Where_Conditions( |
|
| 47 | + if (EE_Restriction_Generator_Base::is_cap($this->model(), $this->action().'_others')) {// both caps exist |
|
| 48 | + $restrictions[EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action().'_others')] = new EE_Default_Where_Conditions( |
|
| 49 | 49 | array( |
| 50 | 50 | EE_Default_Where_Conditions::user_field_name_placeholder => EE_Default_Where_Conditions::current_user_placeholder |
| 51 | 51 | ) |
| 52 | 52 | ); |
| 53 | 53 | // does the private cap exist (eg 'ee_read_others_private_events') |
| 54 | - if (EE_Restriction_Generator_Base::is_cap($this->model(), $this->action() . '_private') && $this->model() instanceof EEM_CPT_Base) { |
|
| 54 | + if (EE_Restriction_Generator_Base::is_cap($this->model(), $this->action().'_private') && $this->model() instanceof EEM_CPT_Base) { |
|
| 55 | 55 | // if they have basic and others, but not private, restrict them to see theirs and others' that aren't private |
| 56 | - $restrictions[ EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_private') ] = new EE_Default_Where_Conditions( |
|
| 56 | + $restrictions[EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action().'_private')] = new EE_Default_Where_Conditions( |
|
| 57 | 57 | array( |
| 58 | - 'OR*no_' . EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_private') => array( |
|
| 58 | + 'OR*no_'.EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action().'_private') => array( |
|
| 59 | 59 | EE_Default_Where_Conditions::user_field_name_placeholder => EE_Default_Where_Conditions::current_user_placeholder, |
| 60 | - 'status' => array( '!=', 'private' ) |
|
| 60 | + 'status' => array('!=', 'private') |
|
| 61 | 61 | ) |
| 62 | 62 | ) |
| 63 | 63 | ); |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | } |
| 66 | 66 | } else { |
| 67 | 67 | // there is no basic cap. So they can only access this if they have the default admin cap |
| 68 | - $restrictions[ EE_Restriction_Generator_Base::get_default_restrictions_cap() ] = new EE_Return_None_Where_Conditions(); |
|
| 68 | + $restrictions[EE_Restriction_Generator_Base::get_default_restrictions_cap()] = new EE_Return_None_Where_Conditions(); |
|
| 69 | 69 | } |
| 70 | 70 | return $restrictions; |
| 71 | 71 | } |
@@ -14,60 +14,60 @@ |
||
| 14 | 14 | class EE_Restriction_Generator_Meta extends EE_Restriction_Generator_Base |
| 15 | 15 | { |
| 16 | 16 | |
| 17 | - /** |
|
| 18 | - * |
|
| 19 | - * @var string the name of the field containing the meta key |
|
| 20 | - */ |
|
| 21 | - protected $_key_field_name = null; |
|
| 17 | + /** |
|
| 18 | + * |
|
| 19 | + * @var string the name of the field containing the meta key |
|
| 20 | + */ |
|
| 21 | + protected $_key_field_name = null; |
|
| 22 | 22 | |
| 23 | - /** |
|
| 24 | - * |
|
| 25 | - * @var string the name of the field containing the meta value |
|
| 26 | - */ |
|
| 27 | - protected $_value_field_name = null; |
|
| 23 | + /** |
|
| 24 | + * |
|
| 25 | + * @var string the name of the field containing the meta value |
|
| 26 | + */ |
|
| 27 | + protected $_value_field_name = null; |
|
| 28 | 28 | |
| 29 | - /** |
|
| 30 | - * Accepts the name of the field that indicates whether or not an object is a "system" one or not |
|
| 31 | - * @param string $key_field_name |
|
| 32 | - * @param string $value_field_name |
|
| 33 | - */ |
|
| 34 | - public function __construct($key_field_name, $value_field_name) |
|
| 35 | - { |
|
| 36 | - $this->_key_field_name = $key_field_name; |
|
| 37 | - $this->_value_field_name = $value_field_name; |
|
| 38 | - } |
|
| 29 | + /** |
|
| 30 | + * Accepts the name of the field that indicates whether or not an object is a "system" one or not |
|
| 31 | + * @param string $key_field_name |
|
| 32 | + * @param string $value_field_name |
|
| 33 | + */ |
|
| 34 | + public function __construct($key_field_name, $value_field_name) |
|
| 35 | + { |
|
| 36 | + $this->_key_field_name = $key_field_name; |
|
| 37 | + $this->_value_field_name = $value_field_name; |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | 40 | |
| 41 | - /** |
|
| 42 | - * |
|
| 43 | - * @return \EE_Default_Where_Conditions |
|
| 44 | - * @throws EE_Error |
|
| 45 | - */ |
|
| 46 | - protected function _generate_restrictions() |
|
| 47 | - { |
|
| 48 | - $whitelisted_meta_keys = apply_filters('FHEE__EE_Restriction_Generator_Meta___generate_restrictions__whitelisted_meta_keys', array()); |
|
| 49 | - $blacklisted_meta_keys = apply_filters('FHEE__EE_Restriction_Generator_Meta___generate_restrictions__blacklisted_meta_keys', array()); |
|
| 50 | - $conditions = array( |
|
| 51 | - $this->_key_field_name => array( 'NOT_LIKE', "\\\\_%" ),// each slash is escaped because we are using double quotes, and |
|
| 52 | - // stripslashes will be called on this because the models assume this is from user input |
|
| 53 | - $this->_value_field_name => array( 'NOT_REGEXP', '^[aOs]:[\d]:.*$') |
|
| 54 | - ); |
|
| 55 | - if (! empty($blacklisted_meta_keys)) { |
|
| 56 | - $conditions[ $this->_key_field_name . '*blacklisted' ] = array( 'NOT_IN', $blacklisted_meta_keys ); |
|
| 57 | - } |
|
| 58 | - if (! empty($whitelisted_meta_keys)) { |
|
| 59 | - $conditions = array( |
|
| 60 | - 'OR*whitelisted-or-normal' => array( |
|
| 61 | - 'AND' => $conditions, |
|
| 62 | - $this->_key_field_name . '*whitelisted' => array( 'IN', $whitelisted_meta_keys ) |
|
| 63 | - ) |
|
| 64 | - ); |
|
| 65 | - } |
|
| 66 | - return array( |
|
| 67 | - // only allow access to non-protected metas if they're an admin |
|
| 68 | - EE_Restriction_Generator_Base::get_default_restrictions_cap() => new EE_Return_None_Where_Conditions(), |
|
| 69 | - // don't allow access to protected metas to anyone. If they want that, don't apply caps to the query |
|
| 70 | - 'apply-to-all-queries-using-caps' => new EE_Default_Where_Conditions($conditions), |
|
| 71 | - ); |
|
| 72 | - } |
|
| 41 | + /** |
|
| 42 | + * |
|
| 43 | + * @return \EE_Default_Where_Conditions |
|
| 44 | + * @throws EE_Error |
|
| 45 | + */ |
|
| 46 | + protected function _generate_restrictions() |
|
| 47 | + { |
|
| 48 | + $whitelisted_meta_keys = apply_filters('FHEE__EE_Restriction_Generator_Meta___generate_restrictions__whitelisted_meta_keys', array()); |
|
| 49 | + $blacklisted_meta_keys = apply_filters('FHEE__EE_Restriction_Generator_Meta___generate_restrictions__blacklisted_meta_keys', array()); |
|
| 50 | + $conditions = array( |
|
| 51 | + $this->_key_field_name => array( 'NOT_LIKE', "\\\\_%" ),// each slash is escaped because we are using double quotes, and |
|
| 52 | + // stripslashes will be called on this because the models assume this is from user input |
|
| 53 | + $this->_value_field_name => array( 'NOT_REGEXP', '^[aOs]:[\d]:.*$') |
|
| 54 | + ); |
|
| 55 | + if (! empty($blacklisted_meta_keys)) { |
|
| 56 | + $conditions[ $this->_key_field_name . '*blacklisted' ] = array( 'NOT_IN', $blacklisted_meta_keys ); |
|
| 57 | + } |
|
| 58 | + if (! empty($whitelisted_meta_keys)) { |
|
| 59 | + $conditions = array( |
|
| 60 | + 'OR*whitelisted-or-normal' => array( |
|
| 61 | + 'AND' => $conditions, |
|
| 62 | + $this->_key_field_name . '*whitelisted' => array( 'IN', $whitelisted_meta_keys ) |
|
| 63 | + ) |
|
| 64 | + ); |
|
| 65 | + } |
|
| 66 | + return array( |
|
| 67 | + // only allow access to non-protected metas if they're an admin |
|
| 68 | + EE_Restriction_Generator_Base::get_default_restrictions_cap() => new EE_Return_None_Where_Conditions(), |
|
| 69 | + // don't allow access to protected metas to anyone. If they want that, don't apply caps to the query |
|
| 70 | + 'apply-to-all-queries-using-caps' => new EE_Default_Where_Conditions($conditions), |
|
| 71 | + ); |
|
| 72 | + } |
|
| 73 | 73 | } |
@@ -48,18 +48,18 @@ |
||
| 48 | 48 | $whitelisted_meta_keys = apply_filters('FHEE__EE_Restriction_Generator_Meta___generate_restrictions__whitelisted_meta_keys', array()); |
| 49 | 49 | $blacklisted_meta_keys = apply_filters('FHEE__EE_Restriction_Generator_Meta___generate_restrictions__blacklisted_meta_keys', array()); |
| 50 | 50 | $conditions = array( |
| 51 | - $this->_key_field_name => array( 'NOT_LIKE', "\\\\_%" ),// each slash is escaped because we are using double quotes, and |
|
| 51 | + $this->_key_field_name => array('NOT_LIKE', "\\\\_%"), // each slash is escaped because we are using double quotes, and |
|
| 52 | 52 | // stripslashes will be called on this because the models assume this is from user input |
| 53 | - $this->_value_field_name => array( 'NOT_REGEXP', '^[aOs]:[\d]:.*$') |
|
| 53 | + $this->_value_field_name => array('NOT_REGEXP', '^[aOs]:[\d]:.*$') |
|
| 54 | 54 | ); |
| 55 | - if (! empty($blacklisted_meta_keys)) { |
|
| 56 | - $conditions[ $this->_key_field_name . '*blacklisted' ] = array( 'NOT_IN', $blacklisted_meta_keys ); |
|
| 55 | + if ( ! empty($blacklisted_meta_keys)) { |
|
| 56 | + $conditions[$this->_key_field_name.'*blacklisted'] = array('NOT_IN', $blacklisted_meta_keys); |
|
| 57 | 57 | } |
| 58 | - if (! empty($whitelisted_meta_keys)) { |
|
| 58 | + if ( ! empty($whitelisted_meta_keys)) { |
|
| 59 | 59 | $conditions = array( |
| 60 | 60 | 'OR*whitelisted-or-normal' => array( |
| 61 | 61 | 'AND' => $conditions, |
| 62 | - $this->_key_field_name . '*whitelisted' => array( 'IN', $whitelisted_meta_keys ) |
|
| 62 | + $this->_key_field_name.'*whitelisted' => array('IN', $whitelisted_meta_keys) |
|
| 63 | 63 | ) |
| 64 | 64 | ); |
| 65 | 65 | } |
@@ -15,51 +15,51 @@ |
||
| 15 | 15 | class EE_Restriction_Generator_Reg_Form extends EE_Restriction_Generator_Base |
| 16 | 16 | { |
| 17 | 17 | |
| 18 | - /** |
|
| 19 | - * |
|
| 20 | - * @var string the name of the field that indicates whether or not this is a system thing |
|
| 21 | - */ |
|
| 22 | - protected $_system_field_name = null; |
|
| 18 | + /** |
|
| 19 | + * |
|
| 20 | + * @var string the name of the field that indicates whether or not this is a system thing |
|
| 21 | + */ |
|
| 22 | + protected $_system_field_name = null; |
|
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * Accepts the name of the field that indicates whether or not an object is a "system" one or not |
|
| 26 | - * @param string $system_field_name |
|
| 27 | - */ |
|
| 28 | - public function __construct($system_field_name) |
|
| 29 | - { |
|
| 30 | - $this->_system_field_name = $system_field_name; |
|
| 31 | - } |
|
| 24 | + /** |
|
| 25 | + * Accepts the name of the field that indicates whether or not an object is a "system" one or not |
|
| 26 | + * @param string $system_field_name |
|
| 27 | + */ |
|
| 28 | + public function __construct($system_field_name) |
|
| 29 | + { |
|
| 30 | + $this->_system_field_name = $system_field_name; |
|
| 31 | + } |
|
| 32 | 32 | |
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * |
|
| 36 | - * @return \EE_Default_Where_Conditions[] |
|
| 37 | - * @throws EE_Error |
|
| 38 | - */ |
|
| 39 | - protected function _generate_restrictions() |
|
| 40 | - { |
|
| 41 | - // if there are no standard caps for this model, then for now all we know |
|
| 42 | - // if they need the default cap to access this |
|
| 43 | - if (! $this->model()->cap_slug()) { |
|
| 44 | - return array( |
|
| 45 | - EE_Restriction_Generator_Base::get_default_restrictions_cap() => new EE_Return_None_Where_Conditions() |
|
| 46 | - ); |
|
| 47 | - } |
|
| 48 | - $restrictions = array( |
|
| 49 | - EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action()) => new EE_Return_None_Where_Conditions(), |
|
| 50 | - ); |
|
| 51 | - // there is no "ee_read_system_questions" cap; in order to read reg form items you only need "ee_read_{model_name}". |
|
| 52 | - // there is also no "ee_delete_system_questions" cap. But folks shouldn't be deleting system questions anyway |
|
| 53 | - if ($this->action() !== EEM_Base::caps_read) { |
|
| 54 | - $restrictions[ EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_system') ] = new EE_Default_Where_Conditions( |
|
| 55 | - array( |
|
| 56 | - 'OR*no_' . EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_system') => array( |
|
| 57 | - $this->_system_field_name => array('IN', array('', 0)), |
|
| 58 | - $this->_system_field_name . '*' => array('IS_NULL') |
|
| 59 | - ) |
|
| 60 | - ) |
|
| 61 | - ); |
|
| 62 | - } |
|
| 63 | - return $restrictions; |
|
| 64 | - } |
|
| 34 | + /** |
|
| 35 | + * |
|
| 36 | + * @return \EE_Default_Where_Conditions[] |
|
| 37 | + * @throws EE_Error |
|
| 38 | + */ |
|
| 39 | + protected function _generate_restrictions() |
|
| 40 | + { |
|
| 41 | + // if there are no standard caps for this model, then for now all we know |
|
| 42 | + // if they need the default cap to access this |
|
| 43 | + if (! $this->model()->cap_slug()) { |
|
| 44 | + return array( |
|
| 45 | + EE_Restriction_Generator_Base::get_default_restrictions_cap() => new EE_Return_None_Where_Conditions() |
|
| 46 | + ); |
|
| 47 | + } |
|
| 48 | + $restrictions = array( |
|
| 49 | + EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action()) => new EE_Return_None_Where_Conditions(), |
|
| 50 | + ); |
|
| 51 | + // there is no "ee_read_system_questions" cap; in order to read reg form items you only need "ee_read_{model_name}". |
|
| 52 | + // there is also no "ee_delete_system_questions" cap. But folks shouldn't be deleting system questions anyway |
|
| 53 | + if ($this->action() !== EEM_Base::caps_read) { |
|
| 54 | + $restrictions[ EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_system') ] = new EE_Default_Where_Conditions( |
|
| 55 | + array( |
|
| 56 | + 'OR*no_' . EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_system') => array( |
|
| 57 | + $this->_system_field_name => array('IN', array('', 0)), |
|
| 58 | + $this->_system_field_name . '*' => array('IS_NULL') |
|
| 59 | + ) |
|
| 60 | + ) |
|
| 61 | + ); |
|
| 62 | + } |
|
| 63 | + return $restrictions; |
|
| 64 | + } |
|
| 65 | 65 | } |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | { |
| 41 | 41 | // if there are no standard caps for this model, then for now all we know |
| 42 | 42 | // if they need the default cap to access this |
| 43 | - if (! $this->model()->cap_slug()) { |
|
| 43 | + if ( ! $this->model()->cap_slug()) { |
|
| 44 | 44 | return array( |
| 45 | 45 | EE_Restriction_Generator_Base::get_default_restrictions_cap() => new EE_Return_None_Where_Conditions() |
| 46 | 46 | ); |
@@ -51,11 +51,11 @@ discard block |
||
| 51 | 51 | // there is no "ee_read_system_questions" cap; in order to read reg form items you only need "ee_read_{model_name}". |
| 52 | 52 | // there is also no "ee_delete_system_questions" cap. But folks shouldn't be deleting system questions anyway |
| 53 | 53 | if ($this->action() !== EEM_Base::caps_read) { |
| 54 | - $restrictions[ EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_system') ] = new EE_Default_Where_Conditions( |
|
| 54 | + $restrictions[EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action().'_system')] = new EE_Default_Where_Conditions( |
|
| 55 | 55 | array( |
| 56 | - 'OR*no_' . EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_system') => array( |
|
| 56 | + 'OR*no_'.EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action().'_system') => array( |
|
| 57 | 57 | $this->_system_field_name => array('IN', array('', 0)), |
| 58 | - $this->_system_field_name . '*' => array('IS_NULL') |
|
| 58 | + $this->_system_field_name.'*' => array('IS_NULL') |
|
| 59 | 59 | ) |
| 60 | 60 | ) |
| 61 | 61 | ); |
@@ -17,85 +17,85 @@ |
||
| 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 | } |
@@ -56,7 +56,7 @@ discard block |
||
| 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 |
||
| 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 |
@@ -25,7 +25,7 @@ |
||
| 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 | } |
@@ -16,7 +16,6 @@ |
||
| 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() |
@@ -3,7 +3,7 @@ discard block |
||
| 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 |
||
| 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 | } |
@@ -13,40 +13,40 @@ |
||
| 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 | } |
@@ -32,20 +32,20 @@ |
||
| 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 | } |
@@ -12,13 +12,13 @@ |
||
| 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 | } |
@@ -15,10 +15,10 @@ |
||
| 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 | } |