MDL-11517 reserved word MOD used in table alias in questions backup code
[moodle-pu.git] / user / profile / field / menu / define.class.php
blob2b88b2fee272d6cd26d41a655797a0c0557590eb
1 <?php //$Id$
3 class profile_define_menu extends profile_define_base {
5 function define_form_specific(&$form) {
6 /// Param 1 for menu type contains the options
7 $form->addElement('textarea', 'param1', get_string('profilemenuoptions', 'admin'), array('rows' => 6, 'cols' => 40));
8 $form->setType('param1', PARAM_MULTILANG);
10 /// Default data
11 $form->addElement('text', 'defaultdata', get_string('profiledefaultdata', 'admin'), 'size="50"');
12 $form->setType('defaultdata', PARAM_MULTILANG);
15 function define_validate_specific($data) {
16 $err = array();
18 $data->param1 = str_replace("\r", '', $data->param1);
20 /// Check that we have at least 2 options
21 if (($options = explode("\n", $data->param1)) === false) {
22 $err['param1'] = get_string('profilemenunooptions', 'admin');
23 } elseif (count($options) < 2) {
24 $err['param1'] = get_string('profilemenutoofewoptions', 'admin');
26 /// Check the default data exists in the options
27 } elseif (!empty($data->defaultdata) and !in_array($data->defaultdata, $options)) {
28 $err['defaultdata'] = get_string('profilemenudefaultnotinoptions', 'admin');
30 return $err;
33 function define_save_preprocess($data) {
34 $data->param1 = str_replace("\r", '', $data->param1);
36 return $data;