當前位置: 首頁>>代碼示例>>PHP>>正文


PHP CEvent::checkClash方法代碼示例

本文整理匯總了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) {
開發者ID:caseysoftware,項目名稱:web2project-planner,代碼行數:31,代碼來源:do_event_aed.php

示例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();
}
開發者ID:hoodoogurus,項目名稱:dotprojecteap,代碼行數:78,代碼來源:clash.php


注:本文中的CEvent::checkClash方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。