Пример #1
0
function clash_accept(CAppUI $AppUI)
{
    global $do_redirect;
    $AppUI->setMsg('Event');
    $obj = new CEvent();
    $obj->bind($_SESSION['add_event_post']);
    $GLOBALS['a'] = $_SESSION['add_event_caller'];
    $is_new = $obj->event_id == 0;
    $result = $obj->store($AppUI);
    if ($result) {
        if (isset($_SESSION['add_event_attendees']) && $_SESSION['add_event_attendees']) {
            $obj->updateAssigned(explode(',', $_SESSION['add_event_attendees']));
        }
        if (isset($_SESSION['add_event_mail']) && $_SESSION['add_event_mail'] == 'on') {
            $obj->notify($_SESSION['add_event_attendees'], !$is_new);
        }
        $AppUI->setMsg('Event Stored', UI_MSG_OK, true);
    } else {
        $AppUI->setMsg($msg, UI_MSG_ERROR);
    }
    clear_clash();
    $AppUI->redirect();
}
$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) {
    if (is_array($result)) {
        $AppUI->setMsg($result, UI_MSG_ERROR, true);
        $AppUI->holdObject($obj);
        $AppUI->redirect('m=calendar&a=addedit');
    }
    if ($result) {
        $AppUI->setMsg('Event ' . $action, UI_MSG_OK, true);
        $redirect = 'm=calendar';
    } else {
        $redirect = ACCESS_DENIED;
Пример #3
0
} else {
    $isNotNew = @$_POST['event_id'];
    if (!$isNotNew) {
        $obj->event_owner = $AppUI->user_id;
    }
    // Check for existence of clashes.
    if ($_POST['event_assigned'] > '' && ($clash = $obj->checkClash($_POST['event_assigned']))) {
        $last_a = $a;
        $GLOBALS['a'] = "clash";
        $do_redirect = false;
    } else {
        if ($msg = $obj->store()) {
            $AppUI->setMsg($msg, UI_MSG_ERROR);
        } else {
            $custom_fields = new CustomFields('calendar', 'addedit', $obj->event_id, "edit");
            $custom_fields->bind($_POST);
            $sql = $custom_fields->store($obj->event_id);
            // Store Custom Fields
            $AppUI->setMsg($isNotNew ? 'updated' : 'added', UI_MSG_OK, true);
            if (isset($_POST['event_assigned'])) {
                $obj->updateAssigned(explode(",", $_POST['event_assigned']));
            }
            if (isset($_POST['mail_invited'])) {
                $obj->notify(@$_POST['event_assigned'], $isNotNew);
            }
        }
    }
}
if ($do_redirect) {
    $AppUI->redirect();
}