Completed
Branch FET-8684-new-default-ee-role (134e3f)
by
unknown
34:19 queued 16:36
created
core/EE_Capabilities.core.php 1 patch
Spacing   +130 added lines, -130 removed lines patch added patch discarded remove patch
@@ -7,8 +7,8 @@  discard block
 block discarded – undo
7 7
  * @package Event Espresso
8 8
  * @subpackage core, capabilities
9 9
  */
10
-if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
11
-	exit( 'No direct script access allowed' );
10
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
11
+	exit('No direct script access allowed');
12 12
 }
13 13
 
14 14
 
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 	 */
72 72
 	public static function instance() {
73 73
 		//check if instantiated, and if not do so.
74
-		if ( ! self::$_instance instanceof EE_Capabilities ) {
74
+		if ( ! self::$_instance instanceof EE_Capabilities) {
75 75
 			self::$_instance = new self();
76 76
 		}
77 77
 		return self::$_instance;
@@ -100,10 +100,10 @@  discard block
 block discarded – undo
100 100
 	 * @since 4.5.0
101 101
 	 * @return void
102 102
 	 */
103
-	public function init_caps( $reset = false ) {
104
-		if ( EE_Maintenance_Mode::instance()->models_can_query() ){
103
+	public function init_caps($reset = false) {
104
+		if (EE_Maintenance_Mode::instance()->models_can_query()) {
105 105
 			$this->_caps_map = $this->_init_caps_map();
106
-			$this->init_role_caps( $reset );
106
+			$this->init_role_caps($reset);
107 107
 			$this->_set_meta_caps();
108 108
 		}
109 109
 	}
@@ -122,11 +122,11 @@  discard block
 block discarded – undo
122 122
 		//make sure we're only ever initializing the default _meta_caps array once if it's empty.
123 123
 		$this->_meta_caps = $this->_get_default_meta_caps_array();
124 124
 
125
-		$this->_meta_caps = apply_filters( 'FHEE__EE_Capabilities___set_meta_caps__meta_caps', $this->_meta_caps );
125
+		$this->_meta_caps = apply_filters('FHEE__EE_Capabilities___set_meta_caps__meta_caps', $this->_meta_caps);
126 126
 
127 127
 		//add filter for map_meta_caps but only if models can query.
128
-		if ( EE_Maintenance_Mode::instance()->models_can_query() && ! has_filter( 'map_meta_cap', array( $this, 'map_meta_caps' ) ) ) {
129
-			add_filter( 'map_meta_cap', array( $this, 'map_meta_caps' ), 10, 4 );
128
+		if (EE_Maintenance_Mode::instance()->models_can_query() && ! has_filter('map_meta_cap', array($this, 'map_meta_caps'))) {
129
+			add_filter('map_meta_cap', array($this, 'map_meta_caps'), 10, 4);
130 130
 		}
131 131
 	}
132 132
 
@@ -139,37 +139,37 @@  discard block
 block discarded – undo
139 139
 	 */
140 140
 	private function _get_default_meta_caps_array() {
141 141
 		static $default_meta_caps = array();
142
-		if ( empty( $default_meta_caps ) ) {
142
+		if (empty($default_meta_caps)) {
143 143
 			$default_meta_caps = array(
144 144
 				//edits
145
-				new EE_Meta_Capability_Map_Edit( 'ee_edit_event', array( 'Event', 'ee_edit_published_events', 'ee_edit_others_events', 'ee_edit_private_events' ) ),
146
-				new EE_Meta_Capability_Map_Edit( 'ee_edit_venue', array( 'Venue', 'ee_edit_published_venues', 'ee_edit_others_venues', 'ee_edit_private_venues' ) ),
147
-				new EE_Meta_Capability_Map_Edit( 'ee_edit_registration', array( 'Registration', '', 'ee_edit_others_registrations', '' ) ),
148
-				new EE_Meta_Capability_Map_Edit( 'ee_edit_checkin', array( 'Registration', '', 'ee_edit_others_checkins', '' ) ),
149
-				new EE_Meta_Capability_Map_Messages_Cap( 'ee_edit_message', array( 'Message_Template_Group', '', 'ee_edit_others_messages', 'ee_edit_global_messages' ) ),
150
-				new EE_Meta_Capability_Map_Edit( 'ee_edit_default_ticket', array( 'Ticket', '', 'ee_edit_others_default_tickets', '' ) ),
151
-				new EE_Meta_Capability_Map_Registration_Form_Cap( 'ee_edit_question', array( 'Question', '', '', 'ee_edit_system_questions' ) ),
152
-				new EE_Meta_Capability_Map_Registration_Form_Cap( 'ee_edit_question_group', array( 'Question_Group', '', '', 'ee_edit_system_question_groups' ) ),
153
-				new EE_Meta_Capability_Map_Edit( 'ee_edit_payment_method', array( 'Payment_Method', '', 'ee_edit_others_payment_methods', '' ) ),
145
+				new EE_Meta_Capability_Map_Edit('ee_edit_event', array('Event', 'ee_edit_published_events', 'ee_edit_others_events', 'ee_edit_private_events')),
146
+				new EE_Meta_Capability_Map_Edit('ee_edit_venue', array('Venue', 'ee_edit_published_venues', 'ee_edit_others_venues', 'ee_edit_private_venues')),
147
+				new EE_Meta_Capability_Map_Edit('ee_edit_registration', array('Registration', '', 'ee_edit_others_registrations', '')),
148
+				new EE_Meta_Capability_Map_Edit('ee_edit_checkin', array('Registration', '', 'ee_edit_others_checkins', '')),
149
+				new EE_Meta_Capability_Map_Messages_Cap('ee_edit_message', array('Message_Template_Group', '', 'ee_edit_others_messages', 'ee_edit_global_messages')),
150
+				new EE_Meta_Capability_Map_Edit('ee_edit_default_ticket', array('Ticket', '', 'ee_edit_others_default_tickets', '')),
151
+				new EE_Meta_Capability_Map_Registration_Form_Cap('ee_edit_question', array('Question', '', '', 'ee_edit_system_questions')),
152
+				new EE_Meta_Capability_Map_Registration_Form_Cap('ee_edit_question_group', array('Question_Group', '', '', 'ee_edit_system_question_groups')),
153
+				new EE_Meta_Capability_Map_Edit('ee_edit_payment_method', array('Payment_Method', '', 'ee_edit_others_payment_methods', '')),
154 154
 				//reads
155
-				new EE_Meta_Capability_Map_Read( 'ee_read_event', array( 'Event', '', 'ee_read_others_events', 'ee_read_private_events' ) ),
156
-				new EE_Meta_Capability_Map_Read( 'ee_read_venue', array( 'Venue', '', 'ee_read_others_venues', 'ee_read_private_venues' ) ),
157
-				new EE_Meta_Capability_Map_Read( 'ee_read_registration', array( 'Registration', '', '', 'ee_edit_others_registrations' ) ),
158
-				new EE_Meta_Capability_Map_Read( 'ee_read_checkin', array( 'Registration', '', '', 'ee_read_others_checkins' ) ),
159
-				new EE_Meta_Capability_Map_Messages_Cap( 'ee_read_message', array( 'Message_Template_Group', '', 'ee_read_others_messages', 'ee_read_global_messages' ) ),
160
-				new EE_Meta_Capability_Map_Read( 'ee_read_default_ticket', array( 'Ticket', '', '', 'ee_read_others_default_tickets' ) ),
161
-				new EE_Meta_Capability_Map_Read( 'ee_read_payment_method', array( 'Payment_Method', '', '', 'ee_read_others_payment_methods' ) ),
155
+				new EE_Meta_Capability_Map_Read('ee_read_event', array('Event', '', 'ee_read_others_events', 'ee_read_private_events')),
156
+				new EE_Meta_Capability_Map_Read('ee_read_venue', array('Venue', '', 'ee_read_others_venues', 'ee_read_private_venues')),
157
+				new EE_Meta_Capability_Map_Read('ee_read_registration', array('Registration', '', '', 'ee_edit_others_registrations')),
158
+				new EE_Meta_Capability_Map_Read('ee_read_checkin', array('Registration', '', '', 'ee_read_others_checkins')),
159
+				new EE_Meta_Capability_Map_Messages_Cap('ee_read_message', array('Message_Template_Group', '', 'ee_read_others_messages', 'ee_read_global_messages')),
160
+				new EE_Meta_Capability_Map_Read('ee_read_default_ticket', array('Ticket', '', '', 'ee_read_others_default_tickets')),
161
+				new EE_Meta_Capability_Map_Read('ee_read_payment_method', array('Payment_Method', '', '', 'ee_read_others_payment_methods')),
162 162
 
163 163
 				//deletes
164
-				new EE_Meta_Capability_Map_Delete( 'ee_delete_event', array( 'Event', 'ee_delete_published_events', 'ee_delete_others_events', 'ee_delete_private_events' ) ),
165
-				new EE_Meta_Capability_Map_Delete( 'ee_delete_venue', array( 'Venue', 'ee_delete_published_venues', 'ee_delete_others_venues', 'ee_delete_private_venues' ) ),
166
-				new EE_Meta_Capability_Map_Delete( 'ee_delete_registration', array( 'Registration', '', 'ee_delete_others_registrations', '' ) ),
167
-				new EE_Meta_Capability_Map_Delete( 'ee_delete_checkin', array( 'Registration', '', 'ee_delete_others_checkins', '' ) ),
168
-				new EE_Meta_Capability_Map_Messages_Cap( 'ee_delete_message', array( 'Message_Template_Group', '', 'ee_delete_others_messages', 'ee_delete_global_messages' ) ),
169
-				new EE_Meta_Capability_Map_Delete( 'ee_delete_default_ticket', array( 'Ticket', '', 'ee_delete_others_default_tickets', '' ) ),
170
-				new EE_Meta_Capability_Map_Registration_Form_Cap( 'ee_delete_question', array( 'Question', '', '', 'delete_system_questions' ) ),
171
-				new EE_Meta_Capability_Map_Registration_Form_Cap( 'ee_delete_question_group', array( 'Question_Group', '', '', 'delete_system_question_groups' ) ),
172
-				new EE_Meta_Capability_Map_Delete( 'ee_delete_payment_method', array( 'Payment_Method', '', 'ee_delete_others_payment_methods', '' ) ),
164
+				new EE_Meta_Capability_Map_Delete('ee_delete_event', array('Event', 'ee_delete_published_events', 'ee_delete_others_events', 'ee_delete_private_events')),
165
+				new EE_Meta_Capability_Map_Delete('ee_delete_venue', array('Venue', 'ee_delete_published_venues', 'ee_delete_others_venues', 'ee_delete_private_venues')),
166
+				new EE_Meta_Capability_Map_Delete('ee_delete_registration', array('Registration', '', 'ee_delete_others_registrations', '')),
167
+				new EE_Meta_Capability_Map_Delete('ee_delete_checkin', array('Registration', '', 'ee_delete_others_checkins', '')),
168
+				new EE_Meta_Capability_Map_Messages_Cap('ee_delete_message', array('Message_Template_Group', '', 'ee_delete_others_messages', 'ee_delete_global_messages')),
169
+				new EE_Meta_Capability_Map_Delete('ee_delete_default_ticket', array('Ticket', '', 'ee_delete_others_default_tickets', '')),
170
+				new EE_Meta_Capability_Map_Registration_Form_Cap('ee_delete_question', array('Question', '', '', 'delete_system_questions')),
171
+				new EE_Meta_Capability_Map_Registration_Form_Cap('ee_delete_question_group', array('Question_Group', '', '', 'delete_system_question_groups')),
172
+				new EE_Meta_Capability_Map_Delete('ee_delete_payment_method', array('Payment_Method', '', 'ee_delete_others_payment_methods', '')),
173 173
 			);
174 174
 		}
175 175
 		return $default_meta_caps;
@@ -193,15 +193,15 @@  discard block
 block discarded – undo
193 193
 	 *
194 194
 	 * @return array   actual users capabilities
195 195
 	 */
196
-	public function map_meta_caps( $caps, $cap, $user_id, $args ) {
196
+	public function map_meta_caps($caps, $cap, $user_id, $args) {
197 197
 		//loop through our _meta_caps array
198
-		foreach ( $this->_meta_caps as $meta_map ) {
199
-			if ( ! $meta_map instanceof EE_Meta_Capability_Map ) {
198
+		foreach ($this->_meta_caps as $meta_map) {
199
+			if ( ! $meta_map instanceof EE_Meta_Capability_Map) {
200 200
 				continue;
201 201
 			}
202 202
 			$meta_map->ensure_is_model();
203 203
 
204
-			$caps = $meta_map->map_meta_caps( $caps, $cap, $user_id, $args );
204
+			$caps = $meta_map->map_meta_caps($caps, $cap, $user_id, $args);
205 205
 		}
206 206
 		return $caps;
207 207
 	}
@@ -527,7 +527,7 @@  discard block
 block discarded – undo
527 527
 			)
528 528
 		);
529 529
 
530
-		$caps = apply_filters( 'FHEE__EE_Capabilities__init_caps_map__caps', $caps );
530
+		$caps = apply_filters('FHEE__EE_Capabilities__init_caps_map__caps', $caps);
531 531
 		return $caps;
532 532
 	}
533 533
 
@@ -544,27 +544,27 @@  discard block
 block discarded – undo
544 544
 	 *
545 545
 	 * @return void
546 546
 	 */
547
-	public function init_role_caps( $reset = false, $custom_map = array() ) {
547
+	public function init_role_caps($reset = false, $custom_map = array()) {
548 548
 
549
-		$caps_map = empty( $custom_map ) ? $this->_caps_map : $custom_map;
549
+		$caps_map = empty($custom_map) ? $this->_caps_map : $custom_map;
550 550
 
551 551
 		//first let's determine if these caps have already been set.
552
-		$caps_set_before = get_option( self::option_name, array() );
552
+		$caps_set_before = get_option(self::option_name, array());
553 553
 		//if not reset, see what caps are new for each role. if they're new, add them.
554
-		foreach ( $caps_map as $role => $caps_for_role ) {
555
-			foreach ( $caps_for_role as $cap ) {
554
+		foreach ($caps_map as $role => $caps_for_role) {
555
+			foreach ($caps_for_role as $cap) {
556 556
 				//first check we haven't already added this cap before, or it's a reset
557
-				if ( $reset || ! isset( $caps_set_before[ $role ] ) || ! in_array( $cap, $caps_set_before[ $role ] ) ) {
558
-					if ( $this->add_cap_to_role( $role, $cap ) ) {
559
-						$caps_set_before[ $role ][] = $cap;
557
+				if ($reset || ! isset($caps_set_before[$role]) || ! in_array($cap, $caps_set_before[$role])) {
558
+					if ($this->add_cap_to_role($role, $cap)) {
559
+						$caps_set_before[$role][] = $cap;
560 560
 					}
561 561
 				}
562 562
 			}
563 563
 		}
564 564
 
565 565
 		//now let's just save the cap that has been set.
566
-		update_option( self::option_name, $caps_set_before );
567
-		do_action( 'AHEE__EE_Capabilities__init_role_caps__complete', $caps_set_before );
566
+		update_option(self::option_name, $caps_set_before);
567
+		do_action('AHEE__EE_Capabilities__init_role_caps__complete', $caps_set_before);
568 568
 	}
569 569
 
570 570
 
@@ -583,20 +583,20 @@  discard block
 block discarded – undo
583 583
 	 * @param bool $grant  Whether to grant access to this cap on this role.
584 584
 	 * @return bool
585 585
 	 */
586
-	public function add_cap_to_role( $role, $cap, $grant = true ) {
587
-		$role_object = get_role( $role );
586
+	public function add_cap_to_role($role, $cap, $grant = true) {
587
+		$role_object = get_role($role);
588 588
 		//if the role isn't available then we create it.
589
-		if ( ! $role_object instanceof WP_Role ) {
589
+		if ( ! $role_object instanceof WP_Role) {
590 590
 			//if a plugin wants to create a specific role name then they should create the role before
591 591
 			//EE_Capabilities does.  Otherwise this function will create the role name from the slug:
592 592
 			// - removes any `ee_` namespacing from the start of the slug.
593 593
 			// - replaces `_` with ` ` (empty space).
594 594
 			// - sentence case on the resulting string.
595
-			$role_label = ucwords( str_replace( '_', ' ', str_replace( 'ee_', '', $role ) ) );
596
-			$role_object = add_role( $role, $role_label );
595
+			$role_label = ucwords(str_replace('_', ' ', str_replace('ee_', '', $role)));
596
+			$role_object = add_role($role, $role_label);
597 597
 		}
598
-		if ( $role_object instanceof WP_Role ) {
599
-			$role_object->add_cap( $cap, $grant );
598
+		if ($role_object instanceof WP_Role) {
599
+			$role_object->add_cap($cap, $grant);
600 600
 			return true;
601 601
 		}
602 602
 		return false;
@@ -618,10 +618,10 @@  discard block
 block discarded – undo
618 618
 	 *
619 619
 	 * @return void
620 620
 	 */
621
-	public function remove_cap_from_role( $role, $cap ) {
622
-		$role = get_role( $role );
623
-		if ( $role instanceof WP_Role ) {
624
-			$role->remove_cap( $cap );
621
+	public function remove_cap_from_role($role, $cap) {
622
+		$role = get_role($role);
623
+		if ($role instanceof WP_Role) {
624
+			$role->remove_cap($cap);
625 625
 		}
626 626
 	}
627 627
 
@@ -642,11 +642,11 @@  discard block
 block discarded – undo
642 642
 	 *
643 643
 	 * @return bool  Whether user can or not.
644 644
 	 */
645
-	public function current_user_can( $cap, $context, $id = 0 ) {
645
+	public function current_user_can($cap, $context, $id = 0) {
646 646
 		//apply filters (both a global on just the cap, and context specific.  Global overrides context specific)
647
-		$filtered_cap = apply_filters( 'FHEE__EE_Capabilities__current_user_can__cap__' . $context,  $cap, $id );
648
-		$filtered_cap = apply_filters( 'FHEE__EE_Capabilities__current_user_can__cap', $filtered_cap, $context, $cap, $id );
649
-		return ! empty( $id ) ? current_user_can( $filtered_cap, $id ) : current_user_can( $filtered_cap );
647
+		$filtered_cap = apply_filters('FHEE__EE_Capabilities__current_user_can__cap__'.$context, $cap, $id);
648
+		$filtered_cap = apply_filters('FHEE__EE_Capabilities__current_user_can__cap', $filtered_cap, $context, $cap, $id);
649
+		return ! empty($id) ? current_user_can($filtered_cap, $id) : current_user_can($filtered_cap);
650 650
 	}
651 651
 
652 652
 
@@ -663,11 +663,11 @@  discard block
 block discarded – undo
663 663
 	 *
664 664
 	 * @return bool Whether user can or not.
665 665
 	 */
666
-	public function user_can( $user, $cap, $context, $id = 0 ) {
666
+	public function user_can($user, $cap, $context, $id = 0) {
667 667
 		//apply filters (both a global on just the cap, and context specific.  Global overrides context specific)
668
-		$filtered_cap = apply_filters( 'FHEE__EE_Capabilities__user_can__cap__' . $context, $cap, $user, $id );
669
-		$filtered_cap = apply_filters( 'FHEE__EE_Capabilities__user_can__cap', $filtered_cap, $context, $cap, $user,  $id );
670
-		return ! empty( $id ) ? user_can( $user, $filtered_cap, $id ) : user_can( $user, $filtered_cap );
668
+		$filtered_cap = apply_filters('FHEE__EE_Capabilities__user_can__cap__'.$context, $cap, $user, $id);
669
+		$filtered_cap = apply_filters('FHEE__EE_Capabilities__user_can__cap', $filtered_cap, $context, $cap, $user, $id);
670
+		return ! empty($id) ? user_can($user, $filtered_cap, $id) : user_can($user, $filtered_cap);
671 671
 	}
672 672
 
673 673
 
@@ -687,12 +687,12 @@  discard block
 block discarded – undo
687 687
 	 *
688 688
 	 * @return bool  Whether user can or not.
689 689
 	 */
690
-	public function current_user_can_for_blog( $blog_id, $cap, $context, $id = 0 ) {
691
-		$user_can = ! empty( $id ) ? current_user_can_for_blog( $blog_id, $cap, $id ) : current_user_can( $blog_id, $cap );
690
+	public function current_user_can_for_blog($blog_id, $cap, $context, $id = 0) {
691
+		$user_can = ! empty($id) ? current_user_can_for_blog($blog_id, $cap, $id) : current_user_can($blog_id, $cap);
692 692
 
693 693
 		//apply filters (both a global on just the cap, and context specific.  Global overrides context specific)
694
-		$user_can = apply_filters( 'FHEE__EE_Capabilities__current_user_can_for_blog__user_can__' . $context, $user_can, $blog_id, $cap, $id );
695
-		$user_can = apply_filters( 'FHEE__EE_Capabilities__current_user_can_for_blog__user_can', $user_can, $context, $blog_id, $cap, $id );
694
+		$user_can = apply_filters('FHEE__EE_Capabilities__current_user_can_for_blog__user_can__'.$context, $user_can, $blog_id, $cap, $id);
695
+		$user_can = apply_filters('FHEE__EE_Capabilities__current_user_can_for_blog__user_can', $user_can, $context, $blog_id, $cap, $id);
696 696
 		return $user_can;
697 697
 	}
698 698
 
@@ -708,12 +708,12 @@  discard block
 block discarded – undo
708 708
 	 *
709 709
 	 * @return array
710 710
 	 */
711
-	public function get_ee_capabilities( $role = 'administrator' ) {
711
+	public function get_ee_capabilities($role = 'administrator') {
712 712
 		$capabilities = $this->_init_caps_map();
713
-		if ( empty( $role ) ) {
713
+		if (empty($role)) {
714 714
 			return $capabilities;
715 715
 		}
716
-		return isset( $capabilities[ $role ] ) ? $capabilities[ $role ] : array();
716
+		return isset($capabilities[$role]) ? $capabilities[$role] : array();
717 717
 	}
718 718
 }
719 719
 
@@ -761,11 +761,11 @@  discard block
 block discarded – undo
761 761
 	 * 	}
762 762
 	 * @throws EE_Error
763 763
 	 */
764
-	public function __construct( $meta_cap, $map_values ) {
764
+	public function __construct($meta_cap, $map_values) {
765 765
 		$this->meta_cap = $meta_cap;
766 766
 		//verify there are four args in the $map_values array;
767
-		if ( count( $map_values ) !== 4 ) {
768
-			throw new EE_Error( sprintf( __( 'Incoming $map_values array should have a count of four values in it.  This is what was given: %s', 'event_espresso' ), '<br>' . print_r( $map_values, true ) ) );
767
+		if (count($map_values) !== 4) {
768
+			throw new EE_Error(sprintf(__('Incoming $map_values array should have a count of four values in it.  This is what was given: %s', 'event_espresso'), '<br>'.print_r($map_values, true)));
769 769
 		}
770 770
 
771 771
 		//set properties
@@ -779,8 +779,8 @@  discard block
 block discarded – undo
779 779
 	/**
780 780
 	 * Makes it so this object stops filtering caps
781 781
 	 */
782
-	public function remove_filters(){
783
-		remove_filter( 'map_meta_cap', array( $this, 'map_meta_caps' ), 10 );
782
+	public function remove_filters() {
783
+		remove_filter('map_meta_cap', array($this, 'map_meta_caps'), 10);
784 784
 	}
785 785
 
786 786
 
@@ -795,19 +795,19 @@  discard block
 block discarded – undo
795 795
 	 */
796 796
 	public function ensure_is_model() {
797 797
 		//is it already instantiated?
798
-		if ( $this->_model instanceof EEM_Base ) {
798
+		if ($this->_model instanceof EEM_Base) {
799 799
 			return;
800 800
 		}
801 801
 
802 802
 		//ensure model name is string
803 803
 		$this->_model_name = (string) $this->_model_name;
804 804
 		//error proof if the name has EEM in it
805
-		$this->_model_name = str_replace( 'EEM', '', $this->_model_name );
805
+		$this->_model_name = str_replace('EEM', '', $this->_model_name);
806 806
 
807
-		$this->_model = EE_Registry::instance()->load_model( $this->_model_name );
807
+		$this->_model = EE_Registry::instance()->load_model($this->_model_name);
808 808
 
809
-		if ( ! $this->_model instanceof EEM_Base ) {
810
-			throw new EE_Error( sprintf( __( 'This string passed in to %s to represent a EEM_Base model class was not able to be used to instantiate the class.   Please ensure that the string is a match for the EEM_Base model name (not including the EEM_ part). This was given: %s', 'event_espresso' ), get_class( $this ), $this->_model ) );
809
+		if ( ! $this->_model instanceof EEM_Base) {
810
+			throw new EE_Error(sprintf(__('This string passed in to %s to represent a EEM_Base model class was not able to be used to instantiate the class.   Please ensure that the string is a match for the EEM_Base model name (not including the EEM_ part). This was given: %s', 'event_espresso'), get_class($this), $this->_model));
811 811
 		}
812 812
 	}
813 813
 
@@ -823,8 +823,8 @@  discard block
 block discarded – undo
823 823
 	 *
824 824
 	 * @return array
825 825
 	 */
826
-	public function map_meta_caps( $caps, $cap, $user_id, $args ) {
827
-		return $this->_map_meta_caps( $caps, $cap, $user_id, $args );
826
+	public function map_meta_caps($caps, $cap, $user_id, $args) {
827
+		return $this->_map_meta_caps($caps, $cap, $user_id, $args);
828 828
 	}
829 829
 
830 830
 
@@ -842,7 +842,7 @@  discard block
 block discarded – undo
842 842
 	 *
843 843
 	 * @return array   actual users capabilities
844 844
 	 */
845
-	abstract protected function _map_meta_caps( $caps, $cap, $user_id, $args );
845
+	abstract protected function _map_meta_caps($caps, $cap, $user_id, $args);
846 846
 }
847 847
 
848 848
 
@@ -874,28 +874,28 @@  discard block
 block discarded – undo
874 874
 	 *
875 875
 	 * @return array   actual users capabilities
876 876
 	 */
877
-	protected function _map_meta_caps( $caps, $cap, $user_id, $args ) {
877
+	protected function _map_meta_caps($caps, $cap, $user_id, $args) {
878 878
 		//only process if we're checking our mapped_cap
879
-		if ( $cap !== $this->meta_cap ) {
879
+		if ($cap !== $this->meta_cap) {
880 880
 			return $caps;
881 881
 		}
882 882
 
883
-		$obj = ! empty( $args[0] ) ? $this->_model->get_one_by_ID( $args[0] ) : null;
883
+		$obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null;
884 884
 
885 885
 		//if no obj then let's just do cap
886
-		if ( ! $obj instanceof EE_Base_Class ) {
886
+		if ( ! $obj instanceof EE_Base_Class) {
887 887
 			$caps[] = $cap;
888 888
 			return $caps;
889 889
 		}
890 890
 
891
-		if ( $obj instanceof EE_CPT_Base ) {
891
+		if ($obj instanceof EE_CPT_Base) {
892 892
 			//if the item author is set and the user is the author...
893
-			if ( $obj->wp_user() && $user_id == $obj->wp_user() ) {
894
-				if ( empty( $this->published_cap ) ) {
893
+			if ($obj->wp_user() && $user_id == $obj->wp_user()) {
894
+				if (empty($this->published_cap)) {
895 895
 					$caps[] = $cap;
896 896
 				} else {
897 897
 					//if obj is published...
898
-					if ( $obj->status() == 'publish' ) {
898
+					if ($obj->status() == 'publish') {
899 899
 						$caps[] = $this->published_cap;
900 900
 					} else {
901 901
 						$caps[] = $cap;
@@ -903,21 +903,21 @@  discard block
 block discarded – undo
903 903
 				}
904 904
 			} else {
905 905
 				//the user is trying to edit someone else's obj
906
-				if ( ! empty( $this->others_cap ) ) {
906
+				if ( ! empty($this->others_cap)) {
907 907
 					$caps[] = $this->others_cap;
908 908
 				}
909
-				if ( ! empty( $this->published_cap ) && $obj->status() == 'publish' ) {
909
+				if ( ! empty($this->published_cap) && $obj->status() == 'publish') {
910 910
 					$caps[] = $this->published_cap;
911
-				} elseif ( ! empty( $this->private_cap ) && $obj->status() == 'private' ) {
911
+				} elseif ( ! empty($this->private_cap) && $obj->status() == 'private') {
912 912
 					$caps[] = $this->private_cap;
913 913
 				}
914 914
 			}
915 915
 		} else {
916 916
 			//not a cpt object so handled differently
917
-			if ( method_exists( $obj, 'wp_user' ) && $obj->wp_user() && $user_id == $obj->wp_user() ) {
917
+			if (method_exists($obj, 'wp_user') && $obj->wp_user() && $user_id == $obj->wp_user()) {
918 918
 				$caps[] = $cap;
919 919
 			} else {
920
-				if ( ! empty( $this->others_cap ) ) {
920
+				if ( ! empty($this->others_cap)) {
921 921
 					$caps[] = $this->others_cap;
922 922
 				}
923 923
 			}
@@ -954,8 +954,8 @@  discard block
 block discarded – undo
954 954
 	 *
955 955
 	 * @return array   actual users capabilities
956 956
 	 */
957
-	protected function _map_meta_caps( $caps, $cap, $user_id, $args ) {
958
-		return parent::_map_meta_caps( $caps, $cap, $user_id, $args );
957
+	protected function _map_meta_caps($caps, $cap, $user_id, $args) {
958
+		return parent::_map_meta_caps($caps, $cap, $user_id, $args);
959 959
 	}
960 960
 }
961 961
 
@@ -987,45 +987,45 @@  discard block
 block discarded – undo
987 987
 	 *
988 988
 	 * @return array   actual users capabilities
989 989
 	 */
990
-	protected function _map_meta_caps( $caps, $cap, $user_id, $args ) {
990
+	protected function _map_meta_caps($caps, $cap, $user_id, $args) {
991 991
 		//only process if we're checking our mapped cap;
992
-		if ( $cap !== $this->meta_cap ) {
992
+		if ($cap !== $this->meta_cap) {
993 993
 			return $caps;
994 994
 		}
995 995
 
996
-		$obj = ! empty( $args[0] ) ? $this->_model->get_one_by_ID( $args[0] ) : null;
996
+		$obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null;
997 997
 
998 998
 		//if no obj then let's just do cap
999
-		if ( ! $obj instanceof EE_Base_Class ) {
999
+		if ( ! $obj instanceof EE_Base_Class) {
1000 1000
 			$caps[] = $cap;
1001 1001
 			return $caps;
1002 1002
 		}
1003 1003
 
1004
-		if ( $obj instanceof EE_CPT_Base ) {
1005
-			$status_obj = get_post_status_object( $obj->status() );
1006
-			if ( $status_obj->public ) {
1004
+		if ($obj instanceof EE_CPT_Base) {
1005
+			$status_obj = get_post_status_object($obj->status());
1006
+			if ($status_obj->public) {
1007 1007
 				$caps[] = $cap;
1008 1008
 				return $caps;
1009 1009
 			}
1010 1010
 
1011 1011
 			//if the item author is set and the user is the author...
1012
-			if ( $obj->wp_user() && $user_id == $obj->wp_user() ) {
1012
+			if ($obj->wp_user() && $user_id == $obj->wp_user()) {
1013 1013
 				$caps[] = $cap;
1014
-			} elseif ( $status_obj->private && ! empty( $this->private_cap ) ) {
1014
+			} elseif ($status_obj->private && ! empty($this->private_cap)) {
1015 1015
 				//the user is trying to view someone else's obj
1016 1016
 				$caps[] = $this->private_cap;
1017
-			} elseif ( ! empty( $this->others_cap ) ) {
1017
+			} elseif ( ! empty($this->others_cap)) {
1018 1018
 				$caps[] = $this->others_cap;
1019 1019
 			} else {
1020 1020
 				$caps[] = $cap;
1021 1021
 			}
1022 1022
 		} else {
1023 1023
 			//not a cpt object so handled differently
1024
-			if ( method_exists( $obj, 'wp_user' ) && $obj->wp_user() && $user_id == $obj->wp_user() ) {
1024
+			if (method_exists($obj, 'wp_user') && $obj->wp_user() && $user_id == $obj->wp_user()) {
1025 1025
 				$caps[] = $cap;
1026
-			} elseif ( ! empty( $this->private_cap ) ) {
1026
+			} elseif ( ! empty($this->private_cap)) {
1027 1027
 				$caps[] = $this->private_cap;
1028
-			} elseif ( ! empty( $this->others_cap ) ) {
1028
+			} elseif ( ! empty($this->others_cap)) {
1029 1029
 				$caps[] = $this->others_cap;
1030 1030
 			} else {
1031 1031
 				$caps[] = $cap;
@@ -1062,30 +1062,30 @@  discard block
 block discarded – undo
1062 1062
 	 *
1063 1063
 	 * @return array   actual users capabilities
1064 1064
 	 */
1065
-	protected function _map_meta_caps( $caps, $cap, $user_id, $args ) {
1065
+	protected function _map_meta_caps($caps, $cap, $user_id, $args) {
1066 1066
 		//only process if we're checking our mapped_cap
1067
-		if ( $cap !== $this->meta_cap ) {
1067
+		if ($cap !== $this->meta_cap) {
1068 1068
 			return $caps;
1069 1069
 		}
1070 1070
 
1071
-		$obj = ! empty( $args[0] ) ? $this->_model->get_one_by_ID( $args[0] ) : null;
1071
+		$obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null;
1072 1072
 
1073 1073
 		//if no obj then let's just do cap
1074
-		if ( ! $obj instanceof EE_Message_Template_Group ) {
1074
+		if ( ! $obj instanceof EE_Message_Template_Group) {
1075 1075
 			$caps[] = $cap;
1076 1076
 			return $caps;
1077 1077
 		}
1078 1078
 
1079 1079
 		$is_global = $obj->is_global();
1080 1080
 
1081
-		if ( $obj->wp_user() && $user_id == $obj->wp_user() ) {
1082
-			if ( $is_global ) {
1083
-				$caps[]  = $this->private_cap;
1081
+		if ($obj->wp_user() && $user_id == $obj->wp_user()) {
1082
+			if ($is_global) {
1083
+				$caps[] = $this->private_cap;
1084 1084
 			} else {
1085 1085
 				$caps[] = $cap;
1086 1086
 			}
1087 1087
 		} else {
1088
-			if ( $is_global ) {
1088
+			if ($is_global) {
1089 1089
 				$caps[] = $this->private_cap;
1090 1090
 			} else {
1091 1091
 				$caps[] = $this->others_cap;
@@ -1123,16 +1123,16 @@  discard block
 block discarded – undo
1123 1123
 	 *
1124 1124
 	 * @return array   actual users capabilities
1125 1125
 	 */
1126
-	protected function _map_meta_caps( $caps, $cap, $user_id, $args ) {
1126
+	protected function _map_meta_caps($caps, $cap, $user_id, $args) {
1127 1127
 		//only process if we're checking our mapped_cap
1128
-		if ( $cap !== $this->meta_cap ) {
1128
+		if ($cap !== $this->meta_cap) {
1129 1129
 			return $caps;
1130 1130
 		}
1131 1131
 
1132
-		$obj = ! empty( $args[0] ) ? $this->_model->get_one_by_ID( $args[0] ) : null;
1132
+		$obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null;
1133 1133
 
1134 1134
 		//if no obj then let's just do cap
1135
-		if ( ! $obj instanceof EE_Base_Class ) {
1135
+		if ( ! $obj instanceof EE_Base_Class) {
1136 1136
 			$caps[] = $cap;
1137 1137
 			return $caps;
1138 1138
 		}
@@ -1140,7 +1140,7 @@  discard block
 block discarded – undo
1140 1140
 		$is_system = $obj instanceof EE_Question_Group ? $obj->system_group() : false;
1141 1141
 		$is_system = $obj instanceof EE_Question ? $obj->is_system_question() : $is_system;
1142 1142
 
1143
-		if ( $is_system ) {
1143
+		if ($is_system) {
1144 1144
 			$caps[] = $this->private_cap;
1145 1145
 		} else {
1146 1146
 			$caps[] = $cap;
Please login to merge, or discard this patch.