当前位置: 首页>>代码示例>>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;未经允许,请勿转载。