本文整理汇总了PHP中ExtraFieldValue::save方法的典型用法代码示例。如果您正苦于以下问题:PHP ExtraFieldValue::save方法的具体用法?PHP ExtraFieldValue::save怎么用?PHP ExtraFieldValue::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ExtraFieldValue
的用法示例。
在下文中一共展示了ExtraFieldValue::save方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update_extra_field_value
/**
* Update an extra field value for a given user
* @param integer $userId User ID
* @param string $variable Field variable name
* @param string $value Field value
*
* @return boolean true if field updated, false otherwise
*/
public static function update_extra_field_value($userId, $variable, $value = '')
{
$extraFieldValue = new ExtraFieldValue('user');
$params = ['item_id' => $userId, 'variable' => $variable, 'value' => $value];
$extraFieldValue->save($params);
}
示例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: update_course_extra_field_value
/**
* Update an extra field value for a given course
* @param integer Course ID
* @param string Field variable name
* @param string Field value
* @return boolean true if field updated, false otherwise
*/
public static function update_course_extra_field_value($course_code, $variable, $value = '')
{
$courseInfo = api_get_course_info($course_code);
$courseId = $courseInfo['real_id'];
$extraFieldValues = new ExtraFieldValue('course');
$params = ['item_id' => $courseId, 'variable' => $variable, 'value' => $value];
$extraFieldValues->save($params);
}
示例4: ExtraField
static function transaction_cambiar_generic($extra_field_variable, $data)
{
global $data_list;
$uidIdPrograma = $data['item_id'];
//$orig_id = $data['orig_id'];
$destination_id = $data['dest_id'];
$common_message = " - item_id: {$uidIdPrograma}, dest_id: {$destination_id} - looking for extra_field_variable: {$extra_field_variable} - with data " . print_r($data, 1);
$session_id = self::get_session_id_by_programa_id($uidIdPrograma, $data_list);
if (!empty($session_id)) {
//??
$extra_field = new ExtraField('session');
$extra_field_info = $extra_field->get_handler_field_info_by_field_variable($extra_field_variable);
//horario, aula, etc
if (empty($extra_field_info)) {
return array('message' => "Extra field {$extra_field_variable} doest not exists in the DB {$common_message}", 'status_id' => self::TRANSACTION_STATUS_FAILED);
}
//check if option exists
$extra_field_option = new ExtraFieldOption('session');
$extra_field_option_info = $extra_field_option->get_field_option_by_field_and_option($extra_field_info['id'], $destination_id);
//horario, aula, etc
if ($extra_field_option_info) {
$extra_field_value = new ExtraFieldValue('session');
//Getting info before
$info_before = $extra_field_value->get_values_by_handler_and_field_id($session_id, $extra_field_info['id']);
//Delete previous extra field value
$extra_field_value->delete_values_by_handler_and_field_id($session_id, $extra_field_info['id']);
$params = array('session_id' => $session_id, 'field_id' => $extra_field_info['id'], 'field_value' => $destination_id);
$extra_field_value->save($params);
//Getting info after
$info_after = $extra_field_value->get_values_by_handler_and_field_id($session_id, $extra_field_info['id']);
return array('entity' => $extra_field_variable, 'before' => $info_before, 'after' => $info_after, 'message' => "Extra field {$extra_field_variable} saved with params: " . print_r($params, 1), 'status_id' => self::TRANSACTION_STATUS_SUCCESSFUL);
} else {
return array('message' => "Option does not exists dest_id: {$destination_id} {$common_message}", 'status_id' => self::TRANSACTION_STATUS_FAILED);
}
} else {
return array('message' => "Session does not exists: {$uidIdPrograma} {$common_message}", 'status_id' => self::TRANSACTION_STATUS_FAILED);
}
}
示例5: array
//.........这里部分代码省略.........
//if ($table['dest_table'] == 'session') {error_log('Options not empty');}
if (!is_array($options)) {
$options = array($options);
}
foreach ($options as $option) {
if (is_array($option)) {
foreach ($option as $key => $value) {
//error_log("$key $value --> {$dest_row[$details['dest']]} ");
if ($key == 'option_value' && $value == $dest_row[$details['dest']]) {
$value = $option['option_display_text'];
if ($field_type == Extrafield::FIELD_TYPE_SELECT) {
$value = $option['option_value'];
}
$params = array('field_id' => $option['field_id'], 'field_value' => $value);
break 2;
}
}
}
}
}
} else {
$params = array('field_id' => $extra_field, 'field_value' => $dest_row[$details['dest']]);
}
if (!empty($params)) {
$extra_fields_to_insert[] = $params;
}
unset($dest_row[$details['dest']]);
}
unset($extra_field);
}
//if ($table['dest_table']=='session') { error_log('Params: '.print_r($params,1)); }
// If a dest_func entry has been defind, use this entry as the main
// operation to execute when inserting the item
if (!empty($table['dest_func'])) {
//error_log('Calling '.$table['dest_func'].' on data recovered: '.print_r($dest_row, 1));
$dest_row['return_item_if_already_exists'] = true;
$item_result = false;
// Using call_user_func_array() has a serious impact on performance
switch ($table['dest_func']) {
case USER_FUNC_EXCEPTION_GRADEBOOK:
MigrationCustom::add_gradebook_result_with_evaluation($dest_row);
break;
case USER_FUNC_EXCEPTION_ATTENDANCE:
MigrationCustom::create_attendance($dest_row);
break;
default:
$item_result = call_user_func_array($table['dest_func'], array($dest_row, $data_list));
}
//After the function was executed fill the $data_list array
switch ($table['dest_table']) {
case 'course':
//Saving courses in array
if ($item_result) {
//$data_list['courses'][$dest_row['uidIdCurso']] = $item_result;
} else {
error_log('Course Not FOUND');
error_log(print_r($item_result, 1));
return false;
}
$handler_id = $item_result['code'];
break;
case 'user':
if (!empty($item_result)) {
$handler_id = $item_result['user_id'];
//error_log($dest_row['email'].' '.$dest_row['uidIdPersona']);
if (isset($dest_row['uidIdAlumno'])) {
//$data_list['users_alumno'][$dest_row['uidIdAlumno']]['extra'] = $item_result;
}
if (isset($dest_row['uidIdEmpleado'])) {
//print_r($dest_row['uidIdEmpleado']);exit;
//$data_list['users_empleado'][$dest_row['uidIdEmpleado']]['extra'] = $item_result;
}
} else {
global $api_failureList;
error_log('Empty user details');
error_log(print_r($api_failureList, 1));
}
break;
case 'session':
//$data_list['sessions'][$dest_row['uidIdPrograma']] = $item_result;
$handler_id = $item_result;
//session_id
break;
}
//Saving extra fields of the element
//error_log('Checking extra fields for '.$extra_field_value_obj->handler_id.' '.$handler_id);
if (!empty($extra_fields_to_insert)) {
foreach ($extra_fields_to_insert as $params) {
//error_log('Trying to save '.print_r($params,1));
$params[$extra_field_value_obj->handler_id] = $handler_id;
$extra_field_value_obj->save($params);
}
}
} else {
// $this->errors_stack[] = "No destination data dest_func found. Abandoning data with first field $first_field = " . $dest_row[$first_field];
}
unset($extra_fields_to_insert);
//remove to free up memory
return $dest_row;
}
示例6: setGcmRegistrationId
/**
* Register the Registration ID (token) obtained from Google Cloud Messaging for a user
* @param Chamilo\UserBundle\Entity\User $user The user
* @param string $registrationId The token registration id from Google Cloud Messaging
* @return int The id after insert or the number of affected rows after update. Otherwhise return false
*/
public static function setGcmRegistrationId(Chamilo\UserBundle\Entity\User $user, $registrationId)
{
$registrationId = Security::remove_XSS($registrationId);
$extraFieldValue = new ExtraFieldValue('user');
return $extraFieldValue->save(['variable' => self::EXTRA_FIELD_GCM_REGISTRATION, 'value' => $registrationId, 'item_id' => $user->getId()]);
}
示例7: 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);
}
}