本文整理汇总了PHP中CEvent::checkClash方法的典型用法代码示例。如果您正苦于以下问题:PHP CEvent::checkClash方法的具体用法?PHP CEvent::checkClash怎么用?PHP CEvent::checkClash使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CEvent
的用法示例。
在下文中一共展示了CEvent::checkClash方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1:
$AppUI->redirect();
}
if ($obj->event_start_date) {
$start_date = new w2p_Utilities_Date($obj->event_start_date . $_POST['start_time']);
$obj->event_start_date = $start_date->format(FMT_DATETIME_MYSQL);
}
if ($obj->event_end_date) {
$end_date = new w2p_Utilities_Date($obj->event_end_date . $_POST['end_time']);
$obj->event_end_date = $end_date->format(FMT_DATETIME_MYSQL);
}
$action = $del ? 'deleted' : 'stored';
$clashRedirect = false;
if ($del) {
$result = $obj->delete();
} else {
if ($_POST['event_assigned'] > '' && ($clash = $obj->checkClash($_POST['event_assigned']))) {
$last_a = $a;
$GLOBALS['a'] = "clash";
$clashRedirect = true;
} else {
$result = $obj->store();
if (isset($_POST['event_assigned'])) {
$obj->updateAssigned(explode(',', $_POST['event_assigned']));
}
if (isset($_POST['mail_invited'])) {
$obj->notify($_POST['event_assigned'], false);
}
}
}
//TODO: I hate this clash param.. there should be a better way.
if (!$clashRedirect) {
示例2: clash_process
function clash_process()
{
global $AppUI, $do_include;
$obj = new CEvent();
$obj->bind($_SESSION['add_event_post']);
$attendees = $_SESSION['add_event_attendees'];
$users = array();
if (isset($attendees) && $attendees) {
$users = explode(',', $attendees);
}
array_push($users, $obj->event_owner);
// First remove any duplicates
$users = array_unique($users);
// Now remove any null entries, so implode doesn't create a dud SQL
// Foreach is safer as it works on a copy of the array.
foreach ($users as $key => $user) {
if (!$user) {
unset($users[$key]);
}
}
// First find any events in the range requested.
$start_date = new CDate($_POST['event_start_date'] . $_POST['start_time']);
$end_date = new CDate($_POST['event_start_date'] . $_POST['start_time']);
$end_date->addSeconds($_POST['duration'] * 60);
$final_date = new CDate($_POST['event_end_date'] . $_POST['end_time']);
$original_event_start = $obj->event_start_date;
$original_event_end = $obj->event_end_date;
$user_list = implode(',', $users);
// Now we grab the events, in date order, and compare against the
// required start and end times.
// Working in 30 minute increments from the start time, and remembering
// the end time stipulation, find the first hole in the times.
// Determine the duration in hours/minutes.
$start_hour = (int) ($_POST['start_time'] / 10000);
$start_minutes = (int) ($_POST['start_time'] % 10000 / 100);
$start_min_offset = $start_hour * 60 + $start_minutes;
$end_hour = (int) ($_POST['end_time'] / 10000);
$end_minutes = (int) ($_POST['end_time'] % 10000 / 100);
$end_min_offset = $end_hour * 60 + $end_minutes - $_POST['duration'];
// First, build a set of "slots" that give us the duration
// and start/end times we need
$first_day = $start_date->format('%E');
$end_day = $final_date->format('%E');
$oneday = new Date_Span(array(1, 0, 0, 0));
$slots = array();
$curr_date = new CDate($start_date);
$curr_date->setTime(0, 0, 0);
$inc = intval(dPgetConfig('cal_day_increment')) ? intval(dPgetConfig('cal_day_increment')) : 30;
for ($i = 0; $i <= $end_day - $first_day; $i++) {
if ($curr_date->isWorkingDay()) {
for ($j = $start_min_offset; $j <= $end_min_offset; $j += $inc) {
$is_committed = false;
$slot_start_date = new CDate($curr_date);
$slot_start_date->addSeconds($j * 60);
$slot_end_date = new CDate($slot_start_date);
$slot_end_date->addSeconds($_POST['duration'] * 60);
$obj->event_start_date = $slot_start_date->format('%Y-%m-%d %T');
$obj->event_end_date = $slot_end_date->format('%Y-%m-%d %T');
if (!($clash = $obj->checkClash($user_list))) {
$_SESSION['add_event_post'] = get_object_vars($obj);
$AppUI->setMsg('First available time slot', UI_MSG_OK);
$_SESSION['event_is_clash'] = true;
$_GET['event_id'] = $obj->event_id;
$do_include = DP_BASE_DIR . '/modules/calendar/addedit.php';
return;
}
}
}
$curr_date->addSpan($oneday);
$curr_date->setTime(0, 0, 0);
}
// If we get here we have found no available slots
$obj->event_start_date = $original_event_start;
$obj->event_end_date = $original_event_end;
clear_clash();
$AppUI->setMsg('No times match your parameters', UI_MSG_ALERT);
$AppUI->redirect();
}