@@ -153,45 +153,43 @@ public function catchPost(){
153153 // check ownership, access etc.
154154 public function preChecks (){
155155
156- global $ zbs ;
156+ global $ zbs ;
157157
158- $ is_malformed_obj = false ;
158+ $ is_malformed_obj = false ;
159159
160- if (is_array ($ this ->obj ) && isset ($ this ->obj ['owner ' ])) {
161- $ obj_owner = (int ) $ this ->obj ['owner ' ];
160+ if ( is_array ( $ this ->obj ) && isset ( $ this ->obj ['owner ' ] ) ) {
161+ $ obj_owner = (int ) $ this ->obj ['owner ' ];
162162
163163 // Transactions can have a contact or company assigned, and quotes just a contact. This covers checking owners for both.
164164 if ( isset ( $ this ->obj ['contact ' ][0 ]['owner ' ] ) ) {
165165 $ obj_owner = (int ) $ this ->obj ['contact ' ][0 ]['owner ' ];
166166
167167 } elseif ( isset ( $ this ->obj ['company ' ][0 ]['owner ' ] ) ) {
168- $ obj_owner = (int ) $ this ->obj ['company ' ][0 ]['owner ' ];
169- // phpcs:disable Generic.WhiteSpace.ScopeIndent.IncorrectExact,Generic.WhiteSpace.ScopeIndent.Incorrect -- this sniff is incorrectly reporting spacing issues.
170- }
171-
172- // This covers checking owners for assigned contacts or companies in invoices.
173- if ( $ this ->objTypeID === ZBS_TYPE_INVOICE ) { // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
174- $ data = zeroBSCRM_invoicing_getInvoiceData ( $ this ->objID ); // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
175- if ( ! empty ( $ data ['invoiceObj ' ]['contact ' ] ) ) {
176- $ obj_owner = (int ) $ data ['invoiceObj ' ]['contact ' ][0 ]['owner ' ];
177- } elseif ( ! empty ( $ data ['invoiceObj ' ]['contact ' ] ) ) {
178- $ obj_owner = (int ) $ data ['invoiceObj ' ]['company ' ][0 ]['owner ' ];
179- }
168+ $ obj_owner = (int ) $ this ->obj ['company ' ][0 ]['owner ' ];
169+ }
170+
171+ // This covers checking owners for assigned contacts or companies in invoices.
172+ if ( $ this ->objTypeID === ZBS_TYPE_INVOICE ) { // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
173+ $ data = zeroBSCRM_invoicing_getInvoiceData ( $ this ->objID ); // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
174+ if ( ! empty ( $ data ['invoiceObj ' ]['contact ' ] ) ) {
175+ $ obj_owner = (int ) $ data ['invoiceObj ' ]['contact ' ][0 ]['owner ' ];
176+ } elseif ( ! empty ( $ data ['invoiceObj ' ]['company ' ] ) ) {
177+ $ obj_owner = (int ) $ data ['invoiceObj ' ]['company ' ][0 ]['owner ' ];
180178 }
181- } else {
182- // phpcs:enable Generic.WhiteSpace.ScopeIndent.IncorrectExact,Generic.WhiteSpace.ScopeIndent.Incorrect
183- // if $this->obj is not an array, somehow it's not been loaded properly (probably perms)
184- // get owner info anyway
185- $ is_malformed_obj = true ;
186- $ obj_owner = $ zbs ->DAL ->getObjectOwner ( // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
187- array (
188- 'objID ' => $ this ->objID , // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
189- 'objTypeID ' => $ this ->objTypeID , // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
190- )
191- );
192- }
193- // get current user
194- $ current_user_id = get_current_user_id ();
179+ }
180+ } else {
181+ // if $this->obj is not an array, somehow it's not been loaded properly (probably perms)
182+ // get owner info anyway
183+ $ is_malformed_obj = true ;
184+ $ obj_owner = $ zbs ->DAL ->getObjectOwner ( // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
185+ array (
186+ 'objID ' => $ this ->objID , // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
187+ 'objTypeID ' => $ this ->objTypeID , // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
188+ )
189+ );
190+ }
191+ // get current user
192+ $ current_user_id = get_current_user_id ();
195193
196194 if ( $ obj_owner > 0 && $ obj_owner != $ current_user_id || $ obj_owner == -1 ) { // phpcs:ignore Universal.Operators.StrictComparisons.LooseNotEqual,Universal.Operators.StrictComparisons.LooseEqual -- see below.
197195 // not current user
0 commit comments