本文整理汇总了PHP中Agenda::setSessionId方法的典型用法代码示例。如果您正苦于以下问题:PHP Agenda::setSessionId方法的具体用法?PHP Agenda::setSessionId怎么用?PHP Agenda::setSessionId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Agenda
的用法示例。
在下文中一共展示了Agenda::setSessionId方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: explode
$day_delta = $_REQUEST['day_delta'];
$minute_delta = $_REQUEST['minute_delta'];
$id = explode('_', $_REQUEST['id']);
$id = $id[1];
$agenda->move_event($id, $day_delta, $minute_delta);
break;
case 'get_events':
$filter = isset($_REQUEST['user_id']) ? $_REQUEST['user_id'] : null;
$sessionId = isset($_REQUEST['session_id']) ? $_REQUEST['session_id'] : null;
$result = $agenda->parseAgendaFilter($filter);
$groupId = current($result['groups']);
$userId = current($result['users']);
$start = isset($_REQUEST['start']) ? api_strtotime($_REQUEST['start']) : null;
$end = isset($_REQUEST['end']) ? api_strtotime($_REQUEST['end']) : null;
if ($type == 'personal' && !empty($sessionId)) {
$agenda->setSessionId($sessionId);
}
$events = $agenda->getEvents($start, $end, api_get_course_int_id(), $groupId, $userId);
echo $events;
break;
case 'get_user_agenda':
//Used in the admin user list
api_protect_admin_script();
if (api_is_allowed_to_edit(null, true)) {
//@todo move this in the agenda class
$DaysShort = api_get_week_days_short();
$MonthsLong = api_get_months_long();
$user_id = intval($_REQUEST['user_id']);
$my_course_list = CourseManager::get_courses_list_by_user_id($user_id, true);
if (!is_array($my_course_list)) {
// this is for the special case if the user has no courses (otherwise you get an error)
示例2: 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);
}
}
示例3: importCalendarStatic
//.........这里部分代码省略.........
if (empty($sessionId)) {
$this->logger->addInfo("external_sessionID: " . $externalSessionId . " does not exists.");
}
$teacherId = null;
if (!empty($sessionId) && !empty($courseInfo)) {
$courseIncluded = SessionManager::relation_session_course_exist($sessionId, $courseInfo['real_id']);
if ($courseIncluded == false) {
$this->logger->addInfo("Course '{$courseCode}' is not included in session: {$sessionId}");
$errorFound = true;
} else {
$teachers = CourseManager::get_coach_list_from_course_code($courseInfo['code'], $sessionId);
// Getting first teacher.
if (!empty($teachers)) {
$teacher = current($teachers);
$teacherId = $teacher['user_id'];
} else {
$sessionInfo = api_get_session_info($sessionId);
$teacherId = $sessionInfo['id_coach'];
}
}
} else {
$errorFound = true;
}
if (empty($teacherId)) {
$errorFound = true;
$this->logger->addInfo("No teacher found in course code : '{$courseCode}' and session: '{$sessionId}'");
}
$date = $row['date'];
$startTime = $row['time_start'];
$endTime = $row['time_end'];
$title = $row['title'];
$startDateYear = substr($date, 0, 4);
$startDateMonth = substr($date, 4, 2);
$startDateDay = substr($date, 6, 8);
$startDate = $startDateYear . '-' . $startDateMonth . '-' . $startDateDay . ' ' . $startTime . ":00";
$endDate = $startDateYear . '-' . $startDateMonth . '-' . $startDateDay . ' ' . $endTime . ":00";
if (!api_is_valid_date($startDate) or !api_is_valid_date($endDate)) {
$this->logger->addInfo("Verify your dates: '{$startDate}' : '{$endDate}' ");
$errorFound = true;
}
if ($errorFound == false) {
$eventsToCreate[] = array('start' => $startDate, 'end' => $endDate, 'title' => $title, 'sender_id' => $teacherId, 'course_id' => $courseInfo['real_id'], 'session_id' => $sessionId, $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");
$content = null;
$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) {
if (!isset($event[$extraFieldName])) {
$this->logger->addInfo("No external_calendar_itemID found. Skipping ...");
continue;
} else {
$externalEventId = $event[$extraFieldName];
$item = $extraFieldValue->get_item_id_from_field_variable_and_field_value($extraFieldName, $externalEventId);
if (!empty($item) || empty($externalEventId)) {
$this->logger->addInfo("Event #{$externalEventId} was already added . Skipping ...");
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'];
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;
}
$eventId = $agenda->addEvent($event['start'], $event['end'], false, $event['title'], $content, array('everyone'), false, null, array(), null, $eventComment);
if (!empty($eventId)) {
$extraFieldValue->save(array('value' => $externalEventId, 'field_id' => $extraFieldInfo['id'], 'item_id' => $eventId));
$this->logger->addInfo("Event added: #{$eventId}");
} else {
$this->logger->addInfo("Error while creating event.");
}
}
}
if ($moveFile) {
$this->moveFile($file);
}
}