function cluster_profile_edit_form($cluster) { global $CURMAN, $CFG; $mform =& $cluster->_form; /// Only get--at most--two profile field associations for this cluster. if (empty($cluster->_customdata['obj']->id)) { $prof_fields = array(); } else { $prof_fields = $CURMAN->db->get_records(CLSTPROFTABLE, 'clusterid', $cluster->_customdata['obj']->id, '', '*', 0, 2); } require_js('yui_yahoo'); require_js('yui_event'); require_js('yui_connection'); require_js($CFG->wwwroot . '/curriculum/cluster/profile/profile_value.js'); /// First profile field if (!empty($prof_fields)) { $prof_field = array_shift($prof_fields); } else { $prof_field = null; } $select = "datatype = 'menu' OR\n datatype = 'checkbox' OR\n datatype = 'text'"; $fields = get_records_select('user_info_field', $select, '', 'id, name'); $profile_field_options = array(0 => get_string('dont_auto', 'block_curr_admin', '')); if (!empty($fields)) { foreach ($fields as $field) { $profile_field_options[$field->id] = htmlspecialchars($field->name); } } /// Retrieve the profile value, if set $value = null; if (isset($mform->_defaultValues['profile_value1'])) { $value = $mform->_defaultValues['profile_value1']; } /// Create an appropriate value for passing to Javascript $value_js = $value === null ? 'null' : "'{$value}'"; /// Determine if the profile field is of type "text" as it affects the behaviour if (!empty($prof_field->fieldid)) { $datatype = get_field('user_info_field', 'datatype', 'id', $prof_field->fieldid); $originallyText = $datatype == 'text' ? 'true' : 'false'; } else { $originallyText = 'false'; } /// Add field selector to form $js_function_call = "update_profile_value_list('1', 'profile_value1', {$value_js}, {$originallyText})"; $mform->addElement('select', 'profile_field1', get_string('auto_associate', 'block_curr_admin') . ':', $profile_field_options, array('onchange' => $js_function_call)); $mform->setHelpButton('profile_field1', array('clusterform/profile_plugin', get_string('auto_associate', 'block_curr_admin'), 'block_curr_admin')); /// Add field options to form $mform->addElement('html', '<div class="fitemtitle"></div><div id="cluster_profile_div1" class="felement">' . get_profile_field_options($prof_field, 'profile_value1', $value) . '</div>'); /// Second profile field if (!empty($prof_fields)) { $prof_field = array_shift($prof_fields); } else { $prof_field = null; } /// Retrieve the profile value, if set $value = null; if (isset($mform->_defaultValues['profile_value2'])) { $value = $mform->_defaultValues['profile_value2']; } /// Create an appropriate value for passing to Javascript $value_js = $value === null ? 'null' : "'{$value}'"; /// Determine if the profile field is of type "text" as it affects the behaviour if (!empty($prof_field->fieldid)) { $datatype = get_field('user_info_field', 'datatype', 'id', $prof_field->fieldid); $originallyText = $datatype == 'text' ? 'true' : 'false'; } else { $originallyText = 'false'; } /// Add field selector to form $js_function_call = "update_profile_value_list('2', 'profile_value2', {$value_js}, {$originallyText})"; $mform->addElement('select', 'profile_field2', get_string('auto_associate', 'block_curr_admin') . ':', $profile_field_options, array('onchange' => $js_function_call)); /// Add field options to form $mform->addElement('html', '<div class="fitemtitle"></div><div id="cluster_profile_div2" class="felement">' . get_profile_field_options($prof_field, 'profile_value2', $value) . '</div>'); }
* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * * @package elis * @subpackage curriculummanagement * @author Remote-Learner.net Inc * @license http://www.gnu.org/copyleft/gpl.html GNU GPL * @copyright (C) 2008-2012 Remote Learner.net Inc http://www.remote-learner.net * */ require_once '../../config.php'; require_once CURMAN_DIRLOCATION . '/cluster/profile/lib.php'; $id = required_param('field', PARAM_INT); $elementName = required_param('elementName', PARAM_TEXT); $value = optional_param('value', null, PARAM_TEXT); require_login(0, false); $prof_field = new stdClass(); $prof_field->fieldid = $id; //output the innerHTML of the surrounding DIV tag echo get_profile_field_options($prof_field, $elementName, $value);