Chamilo is a learning management system focused on ease of use and accessibility
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
chamilo-lms/tests/scripts/set_default_career_sessions...

31 lines
843 B

<?php
/* For license terms, see /license.txt */
exit;
require_once __DIR__.'/../../main/inc/global.inc.php';
$defaultValue = 'xxx';
$variable = 'careerid';
$extraField = new ExtraField('session');
$extraFieldInfo = $extraField->get_handler_field_info_by_field_variable($variable);
if (empty($extraFieldInfo)) {
echo 'Extra field careerid not found';
exit;
}
$extraFieldValue = new ExtraFieldValue('session');
$sql = 'SELECT * FROM session ';
$result = Database::query($sql);
while ($row = Database::fetch_array($result)) {
$sessionId = $row['id'];
$value = $extraFieldValue->get_values_by_handler_and_field_id($sessionId, $extraFieldInfo['id']);
if (empty($value)) {
$params = ['item_id' => $sessionId, 'extra_'.$variable => $defaultValue];
$extraFieldValue->saveFieldValues($params, true);
}
}