| [ Index ] |
PHP Cross Reference of Moodle 1.9.3 [Build 15-Oct-2008] |
[Summary view] [Print] [Text view]
1 <?php // $Id: field.class.php,v 1.1.2.2 2008/07/15 04:28:39 moodler Exp $ 2 3 class profile_field_checkbox extends profile_field_base { 4 5 /** 6 * Constructor method. 7 * Pulls out the options for the checkbox from the database and sets the 8 * the corresponding key for the data if it exists 9 */ 10 function profile_field_checkbox($fieldid=0, $userid=0) { 11 //first call parent constructor 12 $this->profile_field_base($fieldid, $userid); 13 14 if (!empty($this->field)) { 15 $datafield = get_field('user_info_data', 'data', 'userid', $this->userid, 'fieldid', $this->fieldid); 16 if ($datafield !== false) { 17 $this->data = $datafield; 18 } else { 19 $this->data = $this->field->defaultdata; 20 } 21 } 22 } 23 24 function edit_field_add(&$mform) { 25 /// Create the form field 26 $checkbox = &$mform->addElement('advcheckbox', $this->inputname, format_string($this->field->name)); 27 if ($this->data == '1') { 28 $checkbox->setChecked(true); 29 } 30 $mform->setType($this->inputname, PARAM_BOOL); 31 if ($this->is_required() and !has_capability('moodle/user:update', get_context_instance(CONTEXT_SYSTEM, SITEID))) { 32 $mform->addRule($this->inputname, get_string('required'), 'nonzero', null, 'client'); 33 } 34 } 35 36 /** 37 * Display the data for this field 38 */ 39 function display_data() { 40 $options->para = false; 41 $checked = intval($this->data) === 1 ? 'checked="checked"' : ''; 42 return '<input disabled="disabled" type="checkbox" name="'.$this->inputname.'" '.$checked.' />'; 43 } 44 45 } 46 47 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Wed Jan 14 11:33:29 2009 | Cross-referenced by PHPXref 0.7 |