本文整理汇总了PHP中Agenda::edit_event方法的典型用法代码示例。如果您正苦于以下问题:PHP Agenda::edit_event方法的具体用法?PHP Agenda::edit_event怎么用?PHP Agenda::edit_event使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Agenda
的用法示例。
在下文中一共展示了Agenda::edit_event方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: importCalendarStatic
//.........这里部分代码省略.........
$startDateDay = substr($date, 6, 8);
$startDate = $startDateYear . '-' . $startDateMonth . '-' . $startDateDay . ' ' . $startTime . ":00";
$endDate = $startDateYear . '-' . $startDateMonth . '-' . $startDateDay . ' ' . $endTime . ":00";
if (!api_is_valid_date($startDate) || !api_is_valid_date($endDate)) {
$this->logger->addInfo("Verify your dates: '{$startDate}' : '{$endDate}' ");
$errorFound = true;
}
// If old events do nothing.
/*if (api_strtotime($startDate) < time()) {
continue;
}*/
if ($errorFound == false) {
$eventsToCreate[] = array('start' => $startDate, 'end' => $endDate, 'title' => $title, 'sender_id' => $teacherId, 'course_id' => $courseInfo['real_id'], 'session_id' => $sessionId, 'comment' => $comment, 'color' => $color, $this->extraFieldIdNameList['calendar_event'] => $row['external_calendar_itemID']);
}
}
if (empty($eventsToCreate)) {
$this->logger->addInfo("No events to add");
return 0;
}
$this->logger->addInfo("Ready to insert events");
$agenda = new Agenda();
$extraFieldValue = new ExtraFieldValue('calendar_event');
$extraFieldName = $this->extraFieldIdNameList['calendar_event'];
$externalEventId = null;
$extraField = new ExtraField('calendar_event');
$extraFieldInfo = $extraField->get_handler_field_info_by_field_variable($extraFieldName);
if (empty($extraFieldInfo)) {
$this->logger->addInfo("No calendar event extra field created: {$extraFieldName}");
return 0;
}
foreach ($eventsToCreate as $event) {
$update = false;
$item = null;
if (!isset($event[$extraFieldName])) {
$this->logger->addInfo("No external_calendar_itemID found. Skipping ...");
continue;
} else {
$externalEventId = $event[$extraFieldName];
if (empty($externalEventId)) {
$this->logger->addInfo("external_calendar_itemID was set but empty. Skipping ...");
continue;
}
$items = $extraFieldValue->get_item_id_from_field_variable_and_field_value($extraFieldName, $externalEventId, false, false, true);
$item = null;
foreach ($items as $tempItem) {
if ($tempItem['c_id'] == $event['course_id']) {
$item = $tempItem;
}
}
if (!empty($item)) {
$this->logger->addInfo("Event #{$externalEventId} was already added. Updating ...");
$update = true;
//continue;
}
}
$courseInfo = api_get_course_info_by_id($event['course_id']);
$agenda->set_course($courseInfo);
$agenda->setType('course');
$agenda->setSessionId($event['session_id']);
$agenda->setSenderId($event['sender_id']);
$agenda->setIsAllowedToEdit(true);
$eventComment = $event['comment'];
$color = $event['color'];
// To use the event comment you need
// ALTER TABLE c_calendar_event ADD COLUMN comment TEXT;
// add in configuration.php allow_agenda_event_comment = true
if (empty($courseInfo)) {
$this->logger->addInfo("No course found for added: #" . $event['course_id'] . " Skipping ...");
continue;
}
if (empty($event['sender_id'])) {
$this->logger->addInfo("No sender found: #" . $event['sender_id'] . " Skipping ...");
continue;
}
$content = '';
if ($update && isset($item['calendar_event_id'])) {
//the event already exists, just update
$eventId = $agenda->edit_event($item['calendar_event_id'], $event['start'], $event['end'], false, $event['title'], $content, array('everyone'), array(), null, $eventComment, $color);
if ($eventId !== false) {
$this->logger->addInfo("Event updated: #{$eventId}");
} else {
$this->logger->addInfo("Error while updating event.");
}
} else {
// New event. Create it.
$eventId = $agenda->add_event($event['start'], $event['end'], false, $event['title'], $content, array('everyone'), false, null, array(), null, $eventComment, $color);
if (!empty($eventId)) {
$extraFieldValue->is_course_model = true;
$extraFieldValue->save(array('field_value' => $externalEventId, 'field_id' => $extraFieldInfo['id'], 'calendar_event_id' => $eventId, 'c_id' => $event['course_id']));
$this->logger->addInfo("Event added: #{$eventId}");
} else {
$this->logger->addInfo("Error while creating event.");
}
}
}
}
if ($moveFile) {
$this->moveFile($file);
}
}
示例2: updatePublicationAssignment
/**
* @param int $workId
* @param array $params
* @param array $courseInfo
* @param int $groupId
*/
function updatePublicationAssignment($workId, $params, $courseInfo, $groupId)
{
$table = Database::get_course_table(TABLE_STUDENT_PUBLICATION_ASSIGNMENT);
$workTable = Database::get_course_table(TABLE_STUDENT_PUBLICATION);
$workId = intval($workId);
$time = time();
$course_id = $courseInfo['real_id'];
// Insert into agenda
$agendaId = 0;
if (isset($params['add_to_calendar']) && $params['add_to_calendar'] == 1) {
require_once api_get_path(SYS_CODE_PATH).'calendar/agenda.inc.php';
require_once api_get_path(SYS_CODE_PATH).'resourcelinker/resourcelinker.inc.php';
// Setting today date
$date = $end_date = $time;
if (!empty($params['enableExpiryDate'])) {
$end_date = $params['expires_on'];
$date = $end_date;
}
$title = sprintf(get_lang('HandingOverOfTaskX'), $params['new_dir']);
$description = isset($params['description']) ? $params['description'] : '';
$content = '<a href="'.api_get_path(WEB_CODE_PATH).'work/work_list.php?'.api_get_cidreq().'&id='.$workId.'">'
.$params['new_dir'].'</a>'.$description;
$agendaId = agendaExistsForWork($workId, $courseInfo);
// Add/edit agenda
$agenda = new Agenda();
$agenda->set_course($courseInfo);
$agenda->type = 'course';
if (empty($agendaId)) {
$agendaId = $agenda->add_event(
$date,
$end_date,
'false',
$title,
$content,
array('GROUP:'.$groupId)
);
} else {
$agenda->edit_event(
$agendaId,
$end_date,
$end_date,
'false',
$title,
$content
);
}
}
$qualification = isset($params['qualification']) && !empty($params['qualification']) ? 1 : 0;
$expiryDate = (isset($params['enableExpiryDate']) && $params['enableExpiryDate'] == 1) ? api_get_utc_datetime($params['expires_on']) : '0000-00-00 00:00:00';
$endDate = ((isset($params['enableEndDate']) && $params['enableEndDate']==1) ? api_get_utc_datetime($params['ends_on']) : '0000-00-00 00:00:00');
$data = get_work_assignment_by_id($workId, $course_id);
if (empty($data)) {
$sql = "INSERT INTO $table SET
c_id = $course_id ,
expires_on = '".Database::escape_string($expiryDate)."',
ends_on = '".Database::escape_string($endDate)."',
add_to_calendar = $agendaId,
enable_qualification = '$qualification',
publication_id = '$workId'";
Database::query($sql);
$my_last_id = Database::insert_id();
$sql = "UPDATE $workTable SET
has_properties = $my_last_id ,
view_properties = 1
WHERE c_id = $course_id AND id = $workId";
Database::query($sql);
} else {
$sql = "UPDATE $table SET
expires_on = '".$expiryDate."',
ends_on = '".$endDate."',
add_to_calendar = $agendaId,
enable_qualification = '".$qualification."'
WHERE
publication_id = $workId AND
c_id = $course_id AND
id = ".$data['id'];
Database::query($sql);
}
if (!empty($params['category_id'])) {
//.........这里部分代码省略.........
示例3: isset
$endDate = $values['date_range_end'];
$sendAttachment = isset($_FILES['user_upload']) ? true : false;
$attachment = $sendAttachment ? $_FILES['user_upload'] : null;
$attachmentComment = isset($values['file_comment']) ? $values['file_comment'] : null;
$comment = isset($values['comment']) ? $values['comment'] : null;
// This is a sub event. Delete the current and create another BT#7803
if (!empty($event['parent_event_id'])) {
$agenda->delete_event($eventId);
$eventId = $agenda->add_event($startDate, $endDate, $allDay, $values['title'], $values['content'], $values['users_to_send'], false, null, $attachment, $attachmentComment, $comment);
$message = Display::return_message(get_lang('Updated'), 'confirmation');
Session::write('message', $message);
header("Location: {$agendaUrl}");
exit;
}
// Editing normal event.
$agenda->edit_event($eventId, $startDate, $endDate, $allDay, $values['title'], $values['content'], $values['users_to_send'], $attachment, $attachmentComment, $comment);
if (!empty($values['repeat']) && !empty($eventId)) {
// End date is always set as 23:59:59
$endDate = substr($values['repeat_end_day'], 0, 10) . ' 23:59:59';
$agenda->addRepeatedItem($eventId, $values['repeat_type'], $endDate, $values['users_to_send']);
}
$deleteAttachment = isset($values['delete_attachment']) ? true : false;
if ($deleteAttachment && isset($event['attachment']) && !empty($event['attachment'])) {
$agenda->deleteAttachmentFile($event['attachment']['id'], $agenda->course);
}
$message = Display::return_message(get_lang('Updated'), 'confirmation');
Session::write('message', $message);
header("Location: {$agendaUrl}");
exit;
} else {
$content = $form->return_form();
示例4: isset
switch ($action) {
case 'add_event':
if (!api_is_allowed_to_edit(null, true) && !$is_group_tutor && $type == 'course') {
break;
}
$add_as_announcement = isset($_REQUEST['add_as_annonuncement']) ? $_REQUEST['add_as_annonuncement'] : null;
$usersToSend = isset($_REQUEST['users_to_send']) ? $_REQUEST['users_to_send'] : null;
echo $agenda->add_event($_REQUEST['start'], $_REQUEST['end'], $_REQUEST['all_day'], $_REQUEST['view'], $_REQUEST['title'], $_REQUEST['content'], $usersToSend, $add_as_announcement);
break;
case 'edit_event':
if (!api_is_allowed_to_edit(null, true) && $type == 'course') {
break;
}
$id_list = explode('_', $_REQUEST['id']);
$id = $id_list[1];
$agenda->edit_event($id, $_REQUEST['start'], $_REQUEST['end'], $_REQUEST['all_day'], $_REQUEST['view'], $_REQUEST['title'], $_REQUEST['content']);
break;
case 'delete_event':
if (!api_is_allowed_to_edit(null, true) && $type == 'course') {
break;
}
$id_list = explode('_', $_REQUEST['id']);
$id = $id_list[1];
$agenda->delete_event($id);
break;
case 'resize_event':
if (!api_is_allowed_to_edit(null, true) && $type == 'course') {
break;
}
$day_delta = $_REQUEST['day_delta'];
$minute_delta = $_REQUEST['minute_delta'];
示例5: store_edited_agenda_item
/**
* This is the function that updates an agenda item. It does 3 things
* 1. storethe start_date, end_date, title and message in the calendar_event table
* 2. store the groups/users who this message is meant for in the item_property table
* 3. modify the attachments (if needed)
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
* @author Julio Montoya Adding UTC support
*/
function store_edited_agenda_item($event_id, $id_attach, $file_comment)
{
// STEP 1: editing the calendar_event table
// 1.a. some filtering of the input data
$id = $event_id;
$title = strip_tags(trim($_POST['title']));
// no html allowed in the title
$content = trim($_POST['content']);
$start_date = (int) $_POST['fyear'] . "-" . (int) $_POST['fmonth'] . "-" . (int) $_POST['fday'] . " " . (int) $_POST['fhour'] . ":" . (int) $_POST['fminute'] . ":00";
$end_date = (int) $_POST['end_fyear'] . "-" . (int) $_POST['end_fmonth'] . "-" . (int) $_POST['end_fday'] . " " . (int) $_POST['end_fhour'] . ":" . (int) $_POST['end_fminute'] . ":00";
$to = $_POST['selectedform'];
if ($_POST['empty_end_date'] == 'on') {
$end_date = "0000-00-00 00:00:00";
}
$course_info = api_get_course_info();
$agendaObj = new Agenda();
if (empty($course_info)) {
$agendaObj->type = 'personal';
} else {
$agendaObj->set_course($course_info);
$agendaObj->type = 'course';
if (api_is_course_coach() && !api_is_element_in_the_session(TOOL_AGENDA, $event_id)) {
return false;
}
if (!api_is_allowed_to_edit(null, true)) {
return false;
}
}
$all_day = isset($_REQUEST['all_day']) && !empty($_REQUEST['all_day']) ? 1 : 0;
$agendaObj->edit_event($id, $start_date, $end_date, $all_day, $title, $content);
if (empty($id_attach)) {
add_agenda_attachment_file($file_comment, $id);
} else {
edit_agenda_attachment_file($file_comment, $id, $id_attach);
}
// step 3: update the attachments (=delete all and add those in the session
update_added_resources("Agenda", $id);
// return the message;
Display::display_confirmation_message(get_lang("EditSuccess"));
}
示例6: store_edited_agenda_item
/**
* This is the function that updates an agenda item. It does 3 things
* 1. storethe start_date, end_date, title and message in the calendar_event table
* 2. store the groups/users who this message is meant for in the item_property table
* 3. modify the attachments (if needed)
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
* @author Julio Montoya Adding UTC support
*/
function store_edited_agenda_item($event_id, $id_attach, $file_comment)
{
// STEP 1: editing the calendar_event table
// 1.a. some filtering of the input data
$id = $event_id;
$title = strip_tags(trim($_POST['title']));
// no html allowed in the title
$content = trim($_POST['content']);
$start_date = (int) $_POST['fyear'] . "-" . (int) $_POST['fmonth'] . "-" . (int) $_POST['fday'] . " " . (int) $_POST['fhour'] . ":" . (int) $_POST['fminute'] . ":00";
$end_date = (int) $_POST['end_fyear'] . "-" . (int) $_POST['end_fmonth'] . "-" . (int) $_POST['end_fday'] . " " . (int) $_POST['end_fhour'] . ":" . (int) $_POST['end_fminute'] . ":00";
$to = $_POST['selectedform'];
if ($_POST['empty_end_date'] == 'on') {
$end_date = "0000-00-00 00:00:00";
}
$course_info = api_get_course_info();
$agendaObj = new Agenda();
if (empty($course_info)) {
$agendaObj->type = 'personal';
} else {
$agendaObj->set_course($course_info);
$agendaObj->type = 'course';
if (api_is_course_coach() && !api_is_element_in_the_session(TOOL_AGENDA, $event_id)) {
return false;
}
if (!api_is_allowed_to_edit(null, true)) {
return false;
}
}
$all_day = isset($_REQUEST['all_day']) && !empty($_REQUEST['all_day']) ? 1 : 0;
$agendaObj->edit_event($id, $start_date, $end_date, $all_day, null, $title, $content);
if (empty($id_attach)) {
add_agenda_attachment_file($file_comment, $id);
} else {
edit_agenda_attachment_file($file_comment, $id, $id_attach);
}
// step 2: editing the item_property table (=delete all and add the new destination users/groups)
/*if ($edit_result = true) {
// 2.a. delete everything for the users
$sql_delete = "DELETE FROM ".$TABLE_ITEM_PROPERTY." WHERE c_id = $course_id AND ref='$id' AND tool='".TOOL_CALENDAR_EVENT."'";
$result = Database::query($sql_delete) or die(Database::error());
// 2.b. storing the new users/groups
if (!is_null($to)) { // !is_null($to): when no user is selected we send it to everyone
$send_to = separate_users_groups($to);
// storing the selected groups
if (is_array($send_to['groups'])) {
foreach ($send_to['groups'] as $group) {
api_item_property_update($_course, TOOL_CALENDAR_EVENT, $id, "AgendaModified", api_get_user_id(), $group, '', $start_date, $end_date);
}
}
// storing the selected users
if (is_array($send_to['users'])) {
foreach ($send_to['users'] as $user) {
api_item_property_update($_course, TOOL_CALENDAR_EVENT, $id, "AgendaModified", api_get_user_id(), '', $user, $start_date, $end_date);
}
}
} else {
// the message is sent to everyone, so we set the group to 0
api_item_property_update($_course, TOOL_CALENDAR_EVENT, $id, "AgendaModified", api_get_user_id(), '', '', $start_date, $end_date);
}
}*/
// step 3: update the attachments (=delete all and add those in the session
update_added_resources("Agenda", $id);
// return the message;
Display::display_confirmation_message(get_lang("EditSuccess"));
}