grebos
Forum Replies Created
-
Thanks, i made it now like this with the em_event_validate filter and a ckeckbox field to ignore the collision
I used the fpllowing function to get the events which collide with the new one
$dateCollisionArray = EM_Events::get(array('scope'=>$startdate.','.$enddate));add_filter('em_event_validate','my_em_validateFunction'); function my_em_validateFunction( $isValid ) { global $EM_Event; $startdate = $EM_Event ->event_start_date; $enddate = $EM_Event ->event_end_date; $hasNoDateCollisionProblem = true; $ignoreCollision = $EM_Event->event_attributes["Ignore date collision"] != ""; $dateCollisionArray = EM_Events::get(array('scope'=>$startdate.','.$enddate)); //Delete current event from collision array if(($key = array_search($EM_Event, $dateCollisionArray)) !== false) { unset($dateCollisionArray[$key]); } if($startdate != "" && count($dateCollisionArray)>0 && !$ignoreCollision){ $hasNoDateCollisionProblem = false; $dateCollisionError = 'The event is at the same time as: <ul>'; foreach($dateCollisionArray as $collisionDate){ $eventStartDate = $collisionDate->event_start_date; $eventEndDate = $collisionDate->event_end_date; //make that the date is displayed properly $dateCollisionError .= '<li> '.implode('.', array_reverse(explode('-', $eventStartDate))); if($eventStartDate != $eventEndDate){ $dateCollisionError .= ' - '.implode('.', array_reverse(explode('-', $eventEndDate))); } //EM_URI is th URL of the event directory, slug is the URL name of the event, target="_blank" opens new tab $dateCollisionError .= ' <a target="_blank" href="'.EM_URI.'/'.$collisionDate->slug.'">'.$collisionDate->event_name.'</a></li>'; } $dateCollisionError .= '</ul>'; $EM_Event->add_error($dateCollisionError); } return $isValid && $hasNoDateCollisionProblem; }- This reply was modified 8 years, 10 months ago by grebos.
Thanks, I thought, that it should be something like that. How can I check if the event date already exists?
Thanks, I implemented it like that:
jQuery(document).ready(function($){ <?php if (empty($EM_Event->event_name)) { echo "var isNewEvent = true;"; } else { echo "var isNewEvent = false;"; } ?> if(isNewEvent){ $("#no-location").prop("checked", true); } }I assumed, that it is only a new event, if there is no title. Probably not the best way but it works, and it leaves the everithing as it is when one manipulates an event after its creation