本文整理汇总了PHP中ExtraFieldValue::get_item_id_from_field_variable_and_field_value方法的典型用法代码示例。如果您正苦于以下问题:PHP ExtraFieldValue::get_item_id_from_field_variable_and_field_value方法的具体用法?PHP ExtraFieldValue::get_item_id_from_field_variable_and_field_value怎么用?PHP ExtraFieldValue::get_item_id_from_field_variable_and_field_value使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ExtraFieldValue
的用法示例。
在下文中一共展示了ExtraFieldValue::get_item_id_from_field_variable_and_field_value方法的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: getCourseInfoFromOriginalId
/**
* Get the course id based on the original id and field name in the extra fields.
* Returns 0 if course was not found
*
* @param string $value Original course code
* @param string $variable Original field name
* @return int Course id
*/
public static function getCourseInfoFromOriginalId($value, $variable)
{
$extraFieldValue = new ExtraFieldValue('course');
$result = $extraFieldValue->get_item_id_from_field_variable_and_field_value($variable, $value);
if (!empty($result)) {
$courseInfo = api_get_course_info_by_id($result['item_id']);
return $courseInfo;
}
return 0;
}
示例3: get_course_id_from_original_id
/**
* Get the course id based on the original id and field name in the extra fields.
* Returns 0 if course was not found
*
* @param string $original_course_id_value Original course id
* @param string $original_course_id_name Original field name
* @return int Course id
*/
public static function get_course_id_from_original_id($original_course_id_value, $original_course_id_name)
{
$extraFieldValue = new ExtraFieldValue('course');
$value = $extraFieldValue->get_item_id_from_field_variable_and_field_value($original_course_id_name, $original_course_id_value);
if ($value) {
return $value['item_id'];
}
return 0;
}
示例4: getSessionIdFromOriginalId
/**
* Get the session id based on the original id and field name in the extra fields.
* Returns 0 if session was not found
*
* @param string $value Original session id
* @param string $variable Original field name
* @return int Session id
*/
public static function getSessionIdFromOriginalId($value, $variable)
{
$extraFieldValue = new ExtraFieldValue('session');
$result = $extraFieldValue->get_item_id_from_field_variable_and_field_value($variable, $value);
if (!empty($result)) {
return $result['item_id'];
}
return 0;
}
示例5: ExtraFieldValue
/**
* Assigns a user to a session based on rules in db_matches.php
*/
static function add_user_to_session($data, &$omigrate = null)
{
$session_id = null;
$user_id = null;
if (is_array($omigrate) && $omigrate['boost_sessions']) {
if (isset($omigrate['sessions'][$data['uidIdPrograma']])) {
$session_id = $omigrate['sessions'][$data['uidIdPrograma']];
}
}
if (empty($session_id)) {
$extra_field_value = new ExtraFieldValue('session');
$result = $extra_field_value->get_item_id_from_field_variable_and_field_value('uidIdPrograma', $data['uidIdPrograma']);
//error_log('data[uidIdPrograma] '.$data['uidIdPrograma'].' returned $result[session_id]: '.$result['session_id']);
if ($result && $result['session_id']) {
$session_id = $result['session_id'];
}
}
if (is_array($omigrate) && $omigrate['boost_users']) {
if (isset($omigrate['users'][$data['uidIdPersona']])) {
$user_id = $omigrate['users'][$data['uidIdPersona']];
}
}
if (empty($user_id)) {
$extra_field_value = new ExtraFieldValue('user');
$result = $extra_field_value->get_item_id_from_field_variable_and_field_value('uidIdPersona', $data['uidIdPersona']);
//error_log('data[uidIdPersona] '.$data['uidIdPersona'].' returned $result[user_id]: '.$result['user_id']);
if ($result && $result['user_id']) {
$user_id = $result['user_id'];
}
}
if (!empty($session_id) && !empty($user_id)) {
//error_log('Called: add_user_to_session - Subscribing: session_id: '.$session_id. ' user_id: '.$user_id);
SessionManager::suscribe_users_to_session($session_id, array($user_id), SESSION_VISIBLE_READ_ONLY, false, false);
//exit;
} else {
//error_log('Called: add_user_to_session - No idPrograma: '.$data['uidIdPrograma'].' - No uidIdPersona: '.$data['uidIdPersona']);
}
}
示例6: 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);
}
}