Ejemplo n.º 1
0
 /**
  * Handles the action of someone being deleted on WordPress
  * @param int $id
  */
 public static function delete_user($id)
 {
     global $wpdb;
     if ($_REQUEST['delete_option'] == 'reassign' && is_numeric($_REQUEST['reassign_user'])) {
         $wpdb->update(EM_EVENTS_TABLE, array('event_owner' => $_REQUEST['reassign_user']), array('event_owner' => $id));
     } else {
         //User is being deleted, so we delete their events and cancel their bookings.
         $wpdb->query("DELETE FROM " . EM_EVENTS_TABLE . " WHERE event_owner={$id}");
     }
     //delete the booking completely
     if (!get_option('dbem_bookings_registration_disable') || $id != get_option('dbem_bookings_registration_user')) {
         $EM_Person = new EM_Person();
         $EM_Person->ID = $EM_Person->person_id = $id;
         foreach ($EM_Person->get_bookings() as $EM_Booking) {
             $EM_Booking->manage_override = true;
             $EM_Booking->delete();
         }
     } else {
         //user is the no-user mode assigned user, so don't delete all the guest bookings, in case of mistake.
         $wpdb->update(EM_BOOKINGS_TABLE, array('booking_status' => 3, 'person_id' => 0, 'booking_comment' => __('User deleted by administrators', 'dbem')), array('person_id' => $id));
     }
 }
Ejemplo n.º 2
0
</a>
		<?php 
        }
        ?>
		</p>
		<?php 
    }
}
?>
<h4><?php 
_e("Events I'm Attending", 'events-manager');
?>
</h4>
<?php 
$EM_Person = new EM_Person($bp->displayed_user->id);
$EM_Bookings = $EM_Person->get_bookings(false, apply_filters('em_bp_attending_status', 1));
if (count($EM_Bookings->bookings) > 0) {
    //Get events here in one query to speed things up
    $event_ids = array();
    foreach ($EM_Bookings as $EM_Booking) {
        $event_ids[] = $EM_Booking->event_id;
    }
    echo EM_Events::output(array('event' => $event_ids));
} else {
    ?>
	<p><?php 
    _e('Not attending any events yet.', 'events-manager');
    ?>
</p>
	<?php 
}
Ejemplo n.º 3
0
 public static function build_sql_conditions($args = array())
 {
     self::$context = EM_POST_TYPE_EVENT;
     $conditions = parent::build_sql_conditions($args);
     if (!empty($args['search'])) {
         $like_search = array('event_name', EM_EVENTS_TABLE . '.post_content', 'location_name', 'location_address', 'location_town', 'location_postcode', 'location_state', 'location_country', 'location_region');
         $conditions['search'] = "(" . implode(" LIKE '%{$args['search']}%' OR ", $like_search) . "  LIKE '%{$args['search']}%')";
     }
     $conditions['status'] = "(`event_status` >= 0 )";
     //shows pending & published if not defined
     if (array_key_exists('status', $args)) {
         if (is_numeric($args['status'])) {
             $conditions['status'] = "(`event_status`={$args['status']})";
             //pending or published
         } elseif ($args['status'] == 'pending') {
             $conditions['status'] = "(`event_status`=0)";
             //pending
         } elseif ($args['status'] == 'publish') {
             $conditions['status'] = "(`event_status`=1)";
             //published
         } elseif ($args['status'] === null || $args['status'] == 'draft') {
             $conditions['status'] = "(`event_status` IS NULL )";
             //show draft items
         } elseif ($args['status'] == 'trash') {
             $conditions['status'] = "(`event_status` = -1 )";
             //show trashed items
         } elseif ($args['status'] == 'all') {
             $conditions['status'] = "(`event_status` >= 0 OR `event_status` IS NULL)";
             //search all statuses that aren't trashed
         } elseif ($args['status'] == 'everything') {
             unset($conditions['status']);
             //search all statuses
         }
     }
     //private events
     if (empty($args['private'])) {
         $conditions['private'] = "(`event_private`=0)";
     } elseif (!empty($args['private_only'])) {
         $conditions['private_only'] = "(`event_private`=1)";
     }
     if (EM_MS_GLOBAL && !empty($args['blog'])) {
         if (is_numeric($args['blog'])) {
             if (is_main_site($args['blog'])) {
                 $conditions['blog'] = "(" . EM_EVENTS_TABLE . ".blog_id={$args['blog']} OR " . EM_EVENTS_TABLE . ".blog_id IS NULL)";
             } else {
                 $conditions['blog'] = "(" . EM_EVENTS_TABLE . ".blog_id={$args['blog']})";
             }
         } else {
             if (!is_array($args['blog']) && preg_match('/^([\\-0-9],?)+$/', $args['blog'])) {
                 $conditions['blog'] = "(" . EM_EVENTS_TABLE . ".blog_id IN ({$args['blog']}) )";
             } elseif (is_array($args['blog']) && self::array_is_numeric($args['blog'])) {
                 $conditions['blog'] = "(" . EM_EVENTS_TABLE . ".blog_id IN (" . implode(',', $args['blog']) . ") )";
             }
         }
     }
     if ($args['bookings'] === 'user' && is_user_logged_in()) {
         //get bookings of user
         $EM_Person = new EM_Person(get_current_user_id());
         $booking_ids = $EM_Person->get_bookings(true);
         if (count($booking_ids) > 0) {
             $conditions['bookings'] = "(event_id IN (SELECT event_id FROM " . EM_BOOKINGS_TABLE . " WHERE booking_id IN (" . implode(',', $booking_ids) . ")))";
         } else {
             $conditions['bookings'] = "(event_id = 0)";
         }
     }
     //post search
     if (!empty($args['post_id'])) {
         if (is_array($args['post_id'])) {
             $conditions['post_id'] = "(" . EM_EVENTS_TABLE . ".post_id IN (" . implode(',', $args['post_id']) . "))";
         } else {
             $conditions['post_id'] = "(" . EM_EVENTS_TABLE . ".post_id={$args['post_id']})";
         }
     }
     return apply_filters('em_events_build_sql_conditions', $conditions, $args);
 }
Ejemplo n.º 4
0
<?php

do_action('em_template_my_bookings_header');
global $wpdb, $current_user, $EM_Notices, $EM_Person;
if (is_user_logged_in()) {
    $EM_Person = new EM_Person(get_current_user_id());
    $EM_Bookings = $EM_Person->get_bookings();
    $bookings_count = count($EM_Bookings->bookings);
    if ($bookings_count > 0) {
        //Get events here in one query to speed things up
        $event_ids = array();
        foreach ($EM_Bookings as $EM_Booking) {
            $event_ids[] = $EM_Booking->event_id;
        }
        $EM_Events = EM_Events::get($event_ids);
    }
    $limit = !empty($_GET['limit']) ? $_GET['limit'] : 20;
    //Default limit
    $page = !empty($_GET['pno']) ? $_GET['pno'] : 1;
    $offset = $page > 1 ? ($page - 1) * $limit : 0;
    echo $EM_Notices;
    ?>
		<div class='em-my-bookings'>
				<!--
				<ul class="subsubsub">
					<li>
						<a href='edit.php?post_type=post' class="current">All <span class="count">(1)</span></a> |
					</li>
				</ul>
				-->
				<?php 
Ejemplo n.º 5
0
 function build_sql_conditions($args = array())
 {
     $conditions = parent::build_sql_conditions($args);
     if (!empty($args['search'])) {
         $like_search = array('event_name', EM_EVENTS_TABLE . '.post_content', 'location_name', 'location_address', 'location_town', 'location_postcode', 'location_state', 'location_country');
         $conditions['search'] = "(" . implode(" LIKE '%{$args['search']}%' OR ", $like_search) . "  LIKE '%{$args['search']}%')";
     }
     if (array_key_exists('status', $args) && is_numeric($args['status'])) {
         $null = $args['status'] == 0 ? ' OR `event_status` = 0' : '';
         $conditions['status'] = "(`event_status`={$args['status']}{$null} )";
     } elseif (empty($args['status']) || $args['status'] != 'all') {
         $conditions['status'] = "(`event_status` IS NOT NULL )";
         //by default, we don't ever show deleted items
     }
     //private events
     if (empty($args['private'])) {
         $conditions['private'] = "(`event_private`=0)";
     } elseif (!empty($args['private_only'])) {
         $conditions['private_only'] = "(`event_private`=1)";
     }
     if (EM_MS_GLOBAL && !empty($args['blog'])) {
         if (is_numeric($args['blog'])) {
             if (is_main_site($args['blog'])) {
                 $conditions['blog'] = "(" . EM_EVENTS_TABLE . ".blog_id={$args['blog']} OR " . EM_EVENTS_TABLE . ".blog_id IS NULL)";
             } else {
                 $conditions['blog'] = "(" . EM_EVENTS_TABLE . ".blog_id={$args['blog']})";
             }
         } else {
             if (!is_array($args['blog']) && preg_match('/^([\\-0-9],?)+$/', $args['blog'])) {
                 $conditions['blog'] = "(" . EM_EVENTS_TABLE . ".blog_id IN ({$args['blog']}) )";
             } elseif (is_array($args['blog']) && $this->array_is_numeric($args['blog'])) {
                 $conditions['blog'] = "(" . EM_EVENTS_TABLE . ".blog_id IN (" . implode(',', $args['blog']) . ") )";
             }
         }
     }
     if ($args['bookings'] === 'user' && is_user_logged_in()) {
         //get bookings of user
         $EM_Person = new EM_Person(get_current_user_id());
         $booking_ids = $EM_Person->get_bookings(true);
         if (count($booking_ids) > 0) {
             $conditions['bookings'] = "(event_id IN (SELECT event_id FROM " . EM_BOOKINGS_TABLE . " WHERE booking_id IN (" . implode(',', $booking_ids) . ")))";
         } else {
             $conditions['bookings'] = "(event_id = 0)";
         }
     }
     //post search
     if (!empty($args['post_id'])) {
         if (is_array($args['post_id'])) {
             $conditions['post_id'] = "(" . EM_EVENTS_TABLE . ".post_id IN (" . implode(',', $args['post_id']) . "))";
         } else {
             $conditions['post_id'] = "(" . EM_EVENTS_TABLE . ".post_id={$args['post_id']})";
         }
     }
     return apply_filters('em_events_build_sql_conditions', $conditions, $args);
 }