Skip to content
Permalink
Browse files

Add "required_extra_fields_in_inscription" configuration BT#15326

Set extra fields as required in the inscription.php page

Add forum_post, forum_category extra fields
  • Loading branch information...
jmontoyaa committed Feb 27, 2019
1 parent 6528571 commit c2f9db3d27c55f91cf8b40520433998db1da0442
@@ -291,6 +291,8 @@
false,
[],
[],
[],
false,
true
);
@@ -151,6 +151,8 @@
false,
[],
[],
[],
false,
true
);
@@ -303,6 +303,8 @@ function display_drh_list(){
false,
[],
[],
[],
false,
true
);
@@ -325,6 +325,8 @@ function confirmation(name) {
false,
[],
[],
[],
false,
true
);
$jqueryReadyContent = $returnParams['jquery_ready_content'];
@@ -342,13 +342,27 @@
if (isset($allowedFields['extra_fields']) && is_array($allowedFields['extra_fields'])) {
$extraFieldList = $allowedFields['extra_fields'];
}
$requiredFields = api_get_configuration_value('required_extra_fields_in_inscription');
if (!empty($requiredFields) && $requiredFields['options']) {
$requiredFields = $requiredFields['options'];
}
$returnParams = $extraField->addElements(
$form,
0,
[],
false,
false,
$extraFieldList
$extraFieldList,
[],
false,
false,
false,
[],
[],
[],
false,
$requiredFields
);
$extraFieldsLoaded = true;
}
@@ -127,7 +127,6 @@ function is_settings_editable()
// Extra fields
$extra_field = new ExtraField('course');
$extraFieldAdminPermissions = false;
$showOnlyTheseFields = ['tags', 'video_url', 'course_hours_duration', 'max_subscribed_students'];
$extra = $extra_field->addElements(
@@ -136,9 +135,7 @@ function is_settings_editable()
[],
false,
false,
$showOnlyTheseFields,
[],
false
$showOnlyTheseFields
);
//Tags ExtraField
@@ -146,6 +146,12 @@ public function __construct($type)
case 'terms_and_condition':
$this->extraFieldType = EntityExtraField::TERMS_AND_CONDITION_TYPE;
break;
case 'forum_category':
$this->extraFieldType = EntityExtraField::FORUM_CATEGORY_TYPE;
break;
case 'forum_post':
$this->extraFieldType = EntityExtraField::FORUM_POST_TYPE;
break;
}
$this->pageUrl = 'extra_fields.php?type='.$this->type;
@@ -180,6 +186,8 @@ public static function getValidExtraFieldTypes()
'user_certificate',
'survey',
'terms_and_condition',
'forum_category',
'forum_post',
];
if (api_get_configuration_value('allow_scheduled_announcements')) {
@@ -475,7 +483,15 @@ public static function get_extra_fields_by_handler($handler)
* @param bool $useTagAsSelect Whether to show tag fields as select drop-down or not
* @param array $showOnlyTheseFields Limit the extra fields shown to just the list given here
* @param array $orderFields An array containing the names of the fields shown, in the right order
* @param bool $adminPermissions Whether the display is considered without edition limits (true) or not (false)
* @param array $extraData
* @param bool $orderDependingDefaults
* @param bool $adminPermissions
* @param array $separateExtraMultipleSelect
* @param array $customLabelsExtraMultipleSelect
* @param bool $addEmptyOptionSelects
* @param array $introductionTextList
* @param array $requiredFields
* @param bool $hideGeoLocalizationDetails
*
* @throws Exception
*
@@ -490,7 +506,15 @@ public function addElements(
$useTagAsSelect = false,
$showOnlyTheseFields = [],
$orderFields = [],
$adminPermissions = false
$extraData = [],
$orderDependingDefaults = false,
$adminPermissions = false,
$separateExtraMultipleSelect = [],
$customLabelsExtraMultipleSelect = [],
$addEmptyOptionSelects = false,
$introductionTextList = [],
$requiredFields = [],
$hideGeoLocalizationDetails = false
) {
if (empty($form)) {
return false;
@@ -532,9 +556,25 @@ public function addElements(
$exclude,
$useTagAsSelect,
$showOnlyTheseFields,
$orderFields
$orderFields,
$orderDependingDefaults,
$separateExtraMultipleSelect,
$customLabelsExtraMultipleSelect,
$addEmptyOptionSelects,
$introductionTextList,
$hideGeoLocalizationDetails
);
if (!empty($requiredFields)) {
/** @var HTML_QuickForm_input $element */
foreach ($form->getElements() as $element) {
$name = str_replace('extra_', '', $element->getName());
if (in_array($name, $requiredFields)) {
$form->setRequired($element);
}
}
}
return $extra;
}
@@ -992,7 +1032,13 @@ public function set_extra_fields_in_form(
$exclude = [],
$useTagAsSelect = false,
$showOnlyTheseFields = [],
$orderFields = []
$orderFields = [],
$orderDependingDefaults = false,
$separateExtraMultipleSelect = [],
$customLabelsExtraMultipleSelect = [],
$addEmptyOptionSelects = false,
$introductionTextList = [],
$hideGeoLocalizationDetails = false
) {
$jquery_ready_content = null;
if (!empty($extra)) {
@@ -1044,6 +1090,12 @@ public function set_extra_fields_in_form(
}
}
if (!empty($introductionTextList) &&
in_array($field_details['variable'], array_keys($introductionTextList))
) {
$form->addHtml($introductionTextList[$field_details['variable']]);
}
$freezeElement = false;
if (!$adminPermissions) {
$freezeElement = $field_details['visible_to_self'] == 0 || $field_details['changeable'] == 0;
@@ -1643,6 +1695,8 @@ public function set_extra_fields_in_form(
$form->freeze('extra_'.$field_details['variable']);
}
$dataValue = addslashes($dataValue);
$form->addHtml("
<script>
$(document).ready(function() {
@@ -1752,6 +1806,9 @@ function initializeGeo{$field_details['variable']}(address, latLng) {
}
</script>
");
if ($hideGeoLocalizationDetails) {
$form->addHtml('<div style="display:none">');
}
$form->addHtml('
<div class="form-group">
<label for="geolocalization_extra_'.$field_details['variable'].'"
@@ -1784,6 +1841,9 @@ class="col-sm-2 control-label"></label>
</div>
</div>
');
if ($hideGeoLocalizationDetails) {
$form->addHtml('</div>');
}
break;
case self::FIELD_TYPE_GEOLOCALIZATION_COORDINATES:
$dataValue = isset($extraData['extra_'.$field_details['variable']])
@@ -1107,6 +1107,14 @@
// Visually "fold" forum categories by default
// $_configuration['forum_fold_categories'] = false;
// Set extra fields as required in the inscription.php page
/*$_configuration['required_extra_fields_in_inscription'] = [
'options' => [
'terms_ville',
'terms_paysresidence',
],
];*/
// ------ Custom DB changes (keep this at the end)
// Add user activation by confirmation email
// This option prevents the new user to login in the platform if your account is not confirmed via email

0 comments on commit c2f9db3

Please sign in to comment.
You can’t perform that action at this time.