当前位置: 首页>>代码示例>>PHP>>正文


PHP EEM_Event::instance方法代码示例

本文整理汇总了PHP中EEM_Event::instance方法的典型用法代码示例。如果您正苦于以下问题:PHP EEM_Event::instance方法的具体用法?PHP EEM_Event::instance怎么用?PHP EEM_Event::instance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在EEM_Event的用法示例。


在下文中一共展示了EEM_Event::instance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: get_event

 /**
  *    get_event
  *    attempts to retrieve an EE_Event object any way it can
  *
  * @access    public
  * @param    int $EVT_ID
  * @return    object
  */
 public static function get_event($EVT_ID = 0)
 {
     $EVT_ID = $EVT_ID instanceof WP_Post ? $EVT_ID->ID : absint($EVT_ID);
     // do we already have the Event  you are looking for?
     if (EEH_Event_View::$_event instanceof EE_Event && $EVT_ID && EEH_Event_View::$_event->ID() === $EVT_ID) {
         return EEH_Event_View::$_event;
     }
     EEH_Event_View::$_event = NULL;
     // international newspaper?
     global $post;
     // if this is being called from an EE_Event post, then we can just grab the attached EE_Event object
     if (isset($post->post_type) && $post->post_type == 'espresso_events' || $EVT_ID) {
         //			d( $post );
         // grab the event we're looking for
         if (isset($post->EE_Event) && ($EVT_ID == 0 || $EVT_ID == $post->ID)) {
             EEH_Event_View::$_event = $post->EE_Event;
             //				d( EEH_Event_View::$_event );
         }
         // now if we STILL do NOT have an EE_Event model object, BUT we have an Event ID...
         if (!EEH_Event_View::$_event instanceof EE_Event && $EVT_ID) {
             // sigh... pull it from the db
             EEH_Event_View::$_event = EEM_Event::instance()->get_one_by_ID($EVT_ID);
             //				d( EEH_Event_View::$_event );
         }
     }
     return EEH_Event_View::$_event;
 }
开发者ID:robert-osborne,项目名称:event-espresso-core-1,代码行数:35,代码来源:EEH_Event_View.helper.php

示例2: test_REG_final_price_matches_total_of_filtering_line_item_tree__with_sub_line_items

 /**
  * like test_REG_final_price_matches_total_of_filtering_line_item_tree,
  * but makes sure the tickets have sub-prices, because that has shown to have some
  * bugs with calculations so far
  */
 function test_REG_final_price_matches_total_of_filtering_line_item_tree__with_sub_line_items()
 {
     $transaction = $this->new_typical_transaction(array('ticket_types' => 2, 'fixed_ticket_price_modifiers' => 2));
     //add another ticket purchase for one of the same events
     $event1 = EEM_Event::instance()->get_one(array(array('Registration.TXN_ID' => $transaction->ID())));
     $event_line_item = EEM_Line_Item::instance()->get_one(array(array('TXN_ID' => $transaction->ID(), 'OBJ_type' => 'Event', 'OBJ_ID' => $event1->ID())));
     $discount = $this->new_model_obj_with_dependencies('Line_Item', array('LIN_type' => EEM_Line_Item::type_line_item, 'LIN_name' => 'event discount', 'LIN_total' => -8, 'LIN_unit_price' => -8, 'LIN_percent' => 0, 'LIN_quantity' => 1, 'LIN_parent' => $event_line_item->ID(), 'LIN_percent' => null, 'LIN_order' => count($event_line_item->children())));
     $transaction->total_line_item()->recalculate_pre_tax_total();
     //and add an unrelated purchase
     EEH_Line_Item::add_unrelated_item($transaction->total_line_item(), 'Transaction-Wide Discount', -5);
     $totals = EEH_Line_Item::calculate_reg_final_prices_per_line_item($transaction->total_line_item());
     //		honestly the easiest way to confirm the total was right is to visualize the tree
     //		var_dump( $totals );
     //		EEH_Line_Item::visualize( $transaction->total_line_item() );
     //for each registration on the tranasction, verify the REG_final_price
     //indicated by EEH_Line_Item::calculate_reg_final_prices_per_line_item matches
     //what the line item filters would have returned
     EEH_Autoloader::register_line_item_filter_autoloaders();
     foreach ($transaction->registrations() as $registration) {
         $ticket_line_item = EEM_Line_Item::instance()->get_line_item_for_registration($registration);
         $reg_final_price_from_line_item_helper = $totals[$ticket_line_item->ID()];
         //now get the line item filter's final price
         $filters = new EE_Line_Item_Filter_Collection();
         $filters->add(new EE_Single_Registration_Line_Item_Filter($registration));
         $line_item_filter_processor = new EE_Line_Item_Filter_Processor($filters, $transaction->total_line_item());
         $filtered_line_item_tree = $line_item_filter_processor->process();
         $reg_final_price_from_line_item_filter = $filtered_line_item_tree->total();
         $this->assertLessThan(0.2, abs($reg_final_price_from_line_item_filter - $reg_final_price_from_line_item_helper));
     }
 }
开发者ID:teemuoksanen,项目名称:event-espresso-core,代码行数:35,代码来源:EE_Line_Item__EE_Single_Registration_Line_Item_Filter__Integration_Test.php

示例3: _set_new_event

 /**
  * This allows setting the $_event property to a new event object if the incoming args for the
  * new dtt have an event id (or set to default if no evt_id)
  *
  * @since 4.3.0
  * @param int $EVT_ID EE_Event ID
  */
 private function _set_new_event($EVT_ID = 0)
 {
     $this->_event = empty($EVT_ID) ? EEM_Event::instance()->get_one_by_ID($EVT_ID) : $this->factory->event->create();
     //fail safe just in case (so we can be sure to have an event).
     if (empty($this->_event)) {
         $this->_event = $this->factory->event->create();
     }
 }
开发者ID:DavidSteinbauer,项目名称:event-espresso-core,代码行数:15,代码来源:EE_UnitTest_Factory_For_Datetime.class.php

示例4: _generate_restrictions

 /**
  *
  * @return \EE_Default_Where_Conditions
  */
 protected function _generate_restrictions()
 {
     //if there are no standard caps for this model, then for now all we know
     //if they need the default cap to access this
     if (!$this->model()->cap_slug()) {
         return array(self::get_default_restrictions_cap() => new EE_Return_None_Where_Conditions());
     }
     $event_model = EEM_Event::instance();
     return array(EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action()) => new EE_Default_Where_Conditions(array($this->_path_to_event_model . 'status' => 'publish')), EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action() . '_others') => new EE_Default_Where_Conditions(array('OR*' . EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action() . '_others') => array($this->_path_to_event_model . 'EVT_wp_user' => EE_Default_Where_Conditions::current_user_placeholder, $this->_path_to_event_model . 'status' => 'publish'))), EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action() . '_private') => new EE_Default_Where_Conditions(array('OR*no_' . EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action() . '_private') => array($this->_path_to_event_model . 'EVT_wp_user' => EE_Default_Where_Conditions::current_user_placeholder, $this->_path_to_event_model . 'status' => array('!=', 'private')))));
 }
开发者ID:DavidSteinbauer,项目名称:event-espresso-core,代码行数:14,代码来源:EE_Restriction_Generator_Event_Related_Public.strategy.php

示例5: test_reset_model

 /**
  * checks that when we reset a model, that it does so properly and
  * also returns the NEW model
  */
 public function test_reset_model()
 {
     $model_a = EE_Registry::instance()->load_model('Event');
     $model_a2 = EE_Registry::instance()->load_model('Event');
     $model_a3 = EEM_Event::instance();
     $this->assertEquals($model_a, $model_a2);
     $this->assertEquals($model_a2, $model_a3);
     $model_b1 = EEM_Event::reset();
     $this->assertNotSame($model_a, $model_b1);
     $model_b2 = EE_Registry::instance()->reset_model('Event');
     $this->assertNotSame($model_a, $model_b2);
 }
开发者ID:DavidSteinbauer,项目名称:event-espresso-core,代码行数:16,代码来源:EE_Registry_Test.php

示例6: spaces_remaining

 /**
  * Like optimum_sales_now, but minus total sales so far.
  * See EE_Event::spaces_remaining_for_sale( true );
  *
  * @param array            $wpdb_row
  * @param \WP_REST_Request $request
  * @param Base             $controller
  * @return int
  * @throws \EE_Error
  */
 public static function spaces_remaining($wpdb_row, $request, $controller)
 {
     if (is_array($wpdb_row) && isset($wpdb_row['Event_CPT.ID'])) {
         $event_obj = \EEM_Event::instance()->get_one_by_ID($wpdb_row['Event_CPT.ID']);
     } else {
         $event_obj = null;
     }
     if ($event_obj instanceof \EE_Event) {
         return $event_obj->spaces_remaining_for_sale();
     } else {
         throw new \EE_Error(sprintf(__('Cannot calculate spaces_remaining because the event with ID %1$s (from database row %2$s) was not found', 'event_espresso'), $wpdb_row['Event_CPT.ID'], print_r($wpdb_row, true)));
     }
 }
开发者ID:aaronfrey,项目名称:PepperLillie-GSP,代码行数:23,代码来源:Event.php

示例7: primary_questions

    public function primary_questions($post_id, $post)
    {
        $this->_event = $this->_adminpage_obj->get_event_object();
        $event_id = $this->_event->ID();
        ?>
		<div class="inside">
			<p><strong>
					<?php 
        _e('Question Groups', 'event_espresso');
        ?>
				</strong><br />
				<?php 
        _e('Add a pre-populated', 'event_espresso');
        ?>
				<a href="admin.php?page=espresso_registration_form" target="_blank">
					<?php 
        _e('group of questions', 'event_espresso');
        ?>
				</a>
				<?php 
        _e('to your event. The personal information group is required for all events.', 'event_espresso');
        ?>
			</p>
			<?php 
        $QSGs = EEM_Event::instance()->get_all_question_groups();
        $EQGs = !empty($event_id) ? $this->_event->get_many_related('Question_Group', array(array('Event_Question_Group.EQG_primary' => 1))) : array();
        $EQGids = array_keys($EQGs);
        //printr( $QSGs, '$QSGs  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
        if (!empty($QSGs)) {
            $html = count($QSGs) > 10 ? '<div style="height:250px;overflow:auto;">' : '';
            foreach ($QSGs as $QSG) {
                $checked = in_array($QSG->ID(), $EQGids) || $QSG->get('QSG_system') == 1 ? ' checked="checked"' : '';
                $visibility = $QSG->get('QSG_system') == 1 ? ' style="visibility:hidden"' : '';
                $edit_link = $this->_adminpage_obj->add_query_args_and_nonce(array('action' => 'edit_question_group', 'QSG_ID' => $QSG->ID()), EE_FORMS_ADMIN_URL);
                $html .= '
					<p id="event-question-group-' . $QSG->ID() . '">
						<input value="' . $QSG->ID() . '" type="checkbox"' . $visibility . ' name="question_groups[' . $QSG->ID() . ']"' . $checked . ' /> 
						<a href="' . $edit_link . '" title="Edit ' . $QSG->get('QSG_name') . ' Group" target="_blank">' . $QSG->get('QSG_name') . '</a>
					</p>';
            }
            $html .= count($QSGs) > 10 ? '</div>' : '';
            echo $html;
        } else {
            echo __('There seems to be a problem with your questions. Please contact support@eventespresso.com', 'event_espresso');
        }
        do_action('AHEE_event_editor_questions_notice');
        ?>
		</div>
		<?php 
    }
开发者ID:antares-ff,项目名称:ANTARES-Test,代码行数:50,代码来源:espresso_events_Registration_Form_Hooks.class.php

示例8: _generate_restrictions

 /**
  * @return EE_Default_Where_Conditions
  * @throws EE_Error
  */
 protected function _generate_restrictions()
 {
     //if there are no standard caps for this model, then for now all we know
     //if they need the default cap to access this
     if (!$this->model()->cap_slug()) {
         return array(self::get_default_restrictions_cap() => new EE_Return_None_Where_Conditions());
     }
     $event_model = EEM_Event::instance();
     $restrictions = array(EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action()) => new EE_Default_Where_Conditions(array('OR*no_' . EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action()) => array($this->_default_field_name => true, $this->_path_to_event_model . 'status' => 'publish'))), EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action() . '_others') => new EE_Default_Where_Conditions(array('OR*no_' . EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action() . '_others') => array($this->_path_to_event_model . 'EVT_wp_user' => EE_Default_Where_Conditions::current_user_placeholder, $this->_default_field_name => true, $this->_path_to_event_model . 'status' => 'publish'))), EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action() . '_private') => new EE_Default_Where_Conditions(array('OR*no_' . EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action() . '_private') => array($this->_path_to_event_model . 'EVT_wp_user' => EE_Default_Where_Conditions::current_user_placeholder, $this->_path_to_event_model . 'status' => array('!=', 'private'), $this->_default_field_name => true))), EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_default') => new EE_Default_Where_Conditions(array($this->_default_field_name => false)));
     if (EE_Restriction_Generator_Base::is_cap($this->model(), $this->action() . '_others_default')) {
         //if they don't have the "others" default capability, restrict access to only their default ones, and non-default ones
         $restrictions[EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_others_default')] = new EE_Default_Where_Conditions(array('OR*no_' . EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_others_default') => array('AND' => array(EE_Default_Where_Conditions::user_field_name_placeholder => EE_Default_Where_Conditions::current_user_placeholder, $this->_default_field_name => true), $this->_default_field_name => false)));
     }
     return $restrictions;
 }
开发者ID:DavidSteinbauer,项目名称:event-espresso-core,代码行数:19,代码来源:EE_Restriction_Generator_Default_Public.strategy.php

示例9: test_get_minimum_where_conditions_during_query

 /**
  * Test that when we set the minimum where conditions, we DO find cpt items
  * that are trashed, BUT DO NOT find CPT items of the wrong post_type (whcih might,
  * by some hackery, have an entry in the meta table)
  * @group 9179
  */
 public function test_get_minimum_where_conditions_during_query()
 {
     $this->assertEquals(0, EEM_Event::instance()->count(array('default_where_conditions' => 'none')));
     $e_normal = $this->new_model_obj_with_dependencies('Event', array('status' => EEM_CPT_Base::post_status_publish));
     $e_trashed = $this->new_model_obj_with_dependencies('Event', array('status' => EEM_CPT_Base::post_status_trashed));
     $monkey_post = $this->factory->post->create_and_get(array('post_type' => 'monkey'));
     //now verify we get what we wanted: the normal and trashed event, but not
     //the "monkey" post
     $events_found = EEM_Event::instance()->get_all(array('default_where_conditions' => 'minimum'));
     $this->assertArrayContains($e_normal, $events_found);
     $this->assertArrayContains($e_trashed, $events_found);
     $this->assertEquals(2, count($events_found));
     //incidentally, lets show the problem of using the 'default_where_conditions' => 'none'
     //it WOULD count the monkey post. Which is obviously NOT an event!
     $this->assertEquals(3, EEM_Event::instance()->count(array('default_where_conditions' => 'none')));
 }
开发者ID:teemuoksanen,项目名称:event-espresso-core,代码行数:22,代码来源:EEM_CPT_Base_Test.php

示例10: test_generate_restrictions__basic_and_others_and_private

 function test_generate_restrictions__basic_and_others_and_private()
 {
     //currently events have the 'ee_read_events', 'ee_read_others_events', and 'ee_read_others_private_events' caps
     //if that changes, this will need to be updated
     $generator = new EE_Restriction_Generator_Protected();
     $generator->_construct_finalize(EEM_Event::instance(), EEM_Base::caps_read);
     $restrictions = $generator->generate_restrictions();
     foreach ($restrictions as $default_where_conditions) {
         $default_where_conditions->_finalize_construct(EEM_Event::instance());
     }
     $this->assertArrayHasKey('ee_read_events', $restrictions);
     $this->assertInstanceOf('EE_Return_None_Where_Conditions', $restrictions['ee_read_events']);
     $this->assertArrayHasKey('ee_read_others_events', $restrictions);
     $this->assertInstanceOf('EE_Default_Where_Conditions', $restrictions['ee_read_others_events']);
     $this->assertEquals(array(EEM_Event::instance()->wp_user_field_name() => get_current_user_id()), $restrictions['ee_read_others_events']->get_default_where_conditions());
     $this->assertArrayHasKey('ee_read_private_events', $restrictions);
     $this->assertInstanceOf('EE_Default_Where_Conditions', $restrictions['ee_read_private_events']);
     $this->assertEquals(array('OR*no_' . EE_Restriction_Generator_Base::get_cap_name(EEM_Event::instance(), 'read_private') => array(EEM_Event::instance()->wp_user_field_name() => get_current_user_id(), 'status' => array('!=', 'private'))), $restrictions['ee_read_private_events']->get_default_where_conditions());
     $this->assertEquals(3, count($restrictions));
 }
开发者ID:DavidSteinbauer,项目名称:event-espresso-core,代码行数:20,代码来源:EE_Restriciton_Generator_Protected_Test.php

示例11: _get_rel_objects

 /**
  * Utility function used to get various items from the Person_Post model depending on the given params.
  * When no obj_id is provided, we use what is set as the $post id if present.
  *
  * @param int         $obj_id              What the obj_id is for comparing against.
  * @param string    $primary_obj_type What it is being retrieved.
  *
  * @return EE_Base_Class[]  (what is returned depends on what the primary_obj_type is)
  */
 protected static function _get_rel_objects($obj_id = 0, $primary_obj_type = 'Person')
 {
     $objects = array();
     if (empty($obj_id)) {
         global $post;
         $obj_id = $post instanceof WP_Post ? $post->ID : $obj_id;
     }
     //still empty? return empty array
     if (empty($obj_id)) {
         return array();
     }
     if ($primary_obj_type != 'Person') {
         $where = array('PER_ID' => $obj_id, 'OBJ_type' => $primary_obj_type);
         $query = array($where);
     } else {
         $where = array('OBJ_ID' => $obj_id);
         $query = array($where, 'order_by' => array('PER_OBJ_order' => 'ASC'));
     }
     $object_items = EEM_Person_Post::instance()->get_all($query);
     $term_name_cache = array();
     if (method_exists(EEM_Event::instance(), 'public_event_stati')) {
         $public_event_stati = EEM_Event::instance()->public_event_stati();
     } else {
         $public_event_stati = get_post_stati(array('public' => TRUE));
         foreach (EEM_Event::instance()->get_custom_post_statuses() as $custom_post_status) {
             $public_event_stati[] = strtolower(str_replace(' ', '_', $custom_post_status));
         }
     }
     foreach ($object_items as $object_item) {
         if (!isset($term_name_cache[$object_item->get('PT_ID')]) || !isset($objects[$term_name][$object_item->ID()])) {
             $term_name = EEM_Term_Taxonomy::instance()->get_one_by_ID($object_item->get('PT_ID'))->get_first_related('Term')->get('name');
             $related_object = $object_item->get_first_related($primary_obj_type, array(array('status' => array('IN', apply_filters('FHEE__EEH_People_View__get_rel_objects__public_event_stati', $public_event_stati)))));
             if ($related_object instanceof EE_Base_Class) {
                 $objects[$term_name][$object_item->ID()] = $related_object;
                 $term_name_cache[$object_item->get('PT_ID')] = $term_name;
             }
         }
     }
     return $objects;
 }
开发者ID:adrianjonmiller,项目名称:hearts-being-healed,代码行数:49,代码来源:EEH_People_View.helper.php

示例12: _set_reg_event

 /**
  * 		set_reg_event
  *		@access private
  *		@return boolean
  */
 private function _set_reg_event()
 {
     if (is_object($this->_reg_event)) {
         return TRUE;
     }
     $EVT_ID = !empty($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : FALSE;
     if (!$EVT_ID) {
         return FALSE;
     }
     $this->_reg_event = EEM_Event::instance()->get_one_by_ID($EVT_ID);
     return TRUE;
 }
开发者ID:adrianjonmiller,项目名称:hearts-being-healed,代码行数:17,代码来源:Registrations_Admin_Page.core.php

示例13: get_count_of_all_registrations

 /**
  * This just returns a count of all the registrations for this event
  * @access  public
  * @return int
  */
 public function get_count_of_all_registrations()
 {
     return EEM_Event::instance()->count_related($this, 'Registration');
 }
开发者ID:teemuoksanen,项目名称:event-espresso-core,代码行数:9,代码来源:EE_Event.class.php

示例14: ajax_get_available_spaces

 /**
  * 	ajax_get_available_spaces
  * 	get number of available spaces for event via ajax
  *
  * @access        public
  * @return        int
  */
 public static function ajax_get_available_spaces()
 {
     // has a line item been sent?
     if (isset($_REQUEST['event_id'])) {
         $event = EEM_Event::instance()->get_one_by_ID(absint($_REQUEST['event_id']));
         if ($event instanceof EE_Event) {
             $available_spaces = $event->first_datetime()->tickets_remaining();
             //  array(), true
             // just send the ajax
             echo json_encode(array('id' => $event->ID(), 'spaces' => $available_spaces, 'time' => current_time('g:i:s a T')));
             // to be... or...
             exit;
         } else {
             EE_Error::add_error(__('Available space polling via ajax failed. Event not found.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
         }
     } else {
         EE_Error::add_error(__('Available space polling via ajax failed. No event id.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
     }
     // just send the ajax
     echo json_encode(EE_Error::get_notices());
     // to be... or...
     die;
 }
开发者ID:adrianjonmiller,项目名称:hearts-being-healed,代码行数:30,代码来源:EED_Multi_Event_Registration.module.php

示例15: set_event

 /**
  *    finds and sets the EE_Event object for use throughout class
  *
  * @access 	public
  * @param 	mixed $event
  * @return 	bool
  */
 protected static function set_event($event = null)
 {
     if ($event === null) {
         global $post;
         $event = $post;
     }
     if ($event instanceof EE_Event) {
         self::$_event = $event;
     } else {
         if ($event instanceof WP_Post && isset($event->EE_Event) && $event->EE_Event instanceof EE_Event) {
             self::$_event = $event->EE_Event;
         } else {
             if ($event instanceof WP_Post && $event->post_type == 'espresso_events') {
                 $event->EE_Event = EEM_Event::instance()->instantiate_class_from_post_object($event);
                 self::$_event = $event->EE_Event;
             } else {
                 $user_msg = __('No Event object or an invalid Event object was supplied.', 'event_espresso');
                 $dev_msg = $user_msg . __('In order to generate a ticket selector, please ensure you are passing either an EE_Event object or a WP_Post object of the post type "espresso_event" to the EE_Ticket_Selector class constructor.', 'event_espresso');
                 EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
                 return false;
             }
         }
     }
     return true;
 }
开发者ID:aaronfrey,项目名称:PepperLillie-GSP,代码行数:32,代码来源:EED_Ticket_Selector.module.php


注:本文中的EEM_Event::instance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。