$items[$element]['disabled'] = true; if ($element == 'email') { $items[$element]['help'] = false; } } } if ($items['firstname']) { $items['firstname']['autofocus'] = true; } if (isset($items['socialprofile']) && $items['socialprofile']) { $items['socialprofile']['title'] = null; } $items['maildisabled']['ignore'] = !get_account_preference($USER->get('id'), 'maildisabled'); $items['maildisabled']['value'] = get_string('maildisableddescription', 'account', get_config('wwwroot') . 'account/index.php'); // build form elements $elements = array('profile' => array('type' => 'fieldset', 'legend' => get_string('aboutme', 'artefact.internal'), 'class' => 'has-help' . $fieldset != 'aboutme' ? 'collapsed' : '', 'elements' => get_desired_fields($items, array('firstname', 'lastname', 'studentid', 'preferredname', 'introduction'), 'about')), 'contact' => array('type' => 'fieldset', 'legend' => get_string('contact', 'artefact.internal'), 'class' => $fieldset != 'contact' ? '' : '', 'elements' => get_desired_fields($items, array('email', 'maildisabled', 'officialwebsite', 'personalwebsite', 'blogaddress', 'address', 'town', 'city', 'country', 'homenumber', 'businessnumber', 'mobilenumber', 'faxnumber'), 'contact')), 'social' => array('type' => 'fieldset', 'legend' => get_string('social', 'artefact.internal'), 'class' => $fieldset != 'social' ? 'collapsed' : '', 'elements' => get_desired_fields($items, array('socialprofile'), 'social')), 'general' => array('type' => 'fieldset', 'legend' => get_string('general'), 'class' => $fieldset != 'general' ? 'collapsed' : '', 'elements' => $items), 'fs' => array('type' => 'hidden', 'value' => $fieldset), 'submit' => array('type' => 'submit', 'value' => get_string('saveprofile', 'artefact.internal'), 'class' => 'btn-primary')); // Don't include fieldset if 'socialprofile' is not installed if (!get_record('blocktype_installed', 'active', 1, 'name', 'socialprofile')) { unset($elements['social']); } $profileform = pieform(array('name' => 'profileform', 'class' => 'jstabs form-group-nested', 'plugintype' => 'artefact', 'pluginname' => 'internal', 'method' => 'post', 'renderer' => 'div', 'elements' => $elements, 'autofocus' => false)); function get_desired_fields(&$allfields, $desiredfields, $section) { global $USER; if ($section == 'about') { $r = get_record_select('view', 'type = ? AND owner = ?', array('profile', $USER->id), 'id'); $label = '<div id="profileicon" class="profile-icon pseudolabel pull-left"><a href="' . get_config('wwwroot') . 'artefact/file/profileicons.php" class="user-icon"><img src="' . profile_icon_url($USER, 100, 100) . '" alt="' . get_string("editprofileicon", "artefact.file") . '"></a></div>'; $descr = '' . get_string('aboutprofilelinkdescription', 'artefact.internal', get_config('wwwroot') . 'view/blocks.php?id=' . $r->id); $descr .= '<p>' . get_string('aboutdescription', 'artefact.internal') . '</p>'; } else { $label = '';
} if (isset($profilefields[$element])) { $items[$element]['defaultvalue'] = $profilefields[$element]; } if (isset($element_required[$element])) { $items[$element]['rules']['required'] = true; } if (isset($lockedfields[$element]) && !$USER->get('admin')) { $items[$element]['disabled'] = true; } } if ($items['firstname']) { $items['firstname']['autofocus'] = true; } // build form elements $elements = array('topsubmit' => array('type' => 'submitcancel', 'value' => array(get_string('saveprofile', 'artefact.internal'), get_string('viewmyprofile', 'artefact.internal')), 'goto' => get_config('wwwroot') . 'user/view.php?id=' . $USER->get('id')), 'profile' => array('type' => 'fieldset', 'legend' => get_string('aboutme', 'artefact.internal'), 'class' => $fieldset != 'aboutme' ? 'collapsed' : '', 'elements' => get_desired_fields($items, array('firstname', 'lastname', 'studentid', 'preferredname', 'introduction'), 'about')), 'contact' => array('type' => 'fieldset', 'legend' => get_string('contact', 'artefact.internal'), 'class' => $fieldset != 'contact' ? 'collapsed' : '', 'elements' => get_desired_fields($items, array('email', 'officialwebsite', 'personalwebsite', 'blogaddress', 'address', 'town', 'city', 'country', 'homenumber', 'businessnumber', 'mobilenumber', 'faxnumber'), 'contact')), 'messaging' => array('type' => 'fieldset', 'legend' => get_string('messaging', 'artefact.internal'), 'class' => $fieldset != 'messaging' ? 'collapsed' : '', 'elements' => get_desired_fields($items, array('icqnumber', 'msnnumber', 'aimscreenname', 'yahoochat', 'skypeusername', 'jabberusername'), 'messaging')), 'general' => array('type' => 'fieldset', 'legend' => get_string('general', 'artefact.internal'), 'class' => $fieldset != 'general' ? 'collapsed' : '', 'elements' => $items), 'submit' => array('type' => 'submitcancel', 'value' => array(get_string('saveprofile', 'artefact.internal'), get_string('viewmyprofile', 'artefact.internal')), 'goto' => get_config('wwwroot') . 'user/view.php?id=' . $USER->get('id'))); $profileform = pieform(array('name' => 'profileform', 'plugintype' => 'artefact', 'pluginname' => 'internal', 'method' => 'post', 'elements' => $elements, 'autofocus' => false)); function get_desired_fields(&$allfields, $desiredfields, $section) { global $USER; $return = array(); $return["{$section}description"] = array('type' => 'html', 'labelhtml' => $section == 'about' ? '<div id="profileicon"><a href="' . get_config('wwwroot') . 'artefact/file/profileicons.php"><img src="' . get_config('wwwroot') . 'thumb.php?type=profileiconbyid&maxsize=100&id=' . intval($USER->get('profileicon')) . '" alt=""></a></div>' : '', 'value' => get_string("{$section}description", 'artefact.internal')); foreach ($desiredfields as $field) { if (isset($allfields[$field])) { $return[$field] = $allfields[$field]; unset($allfields[$field]); } } return $return; } function profileform_validate(Pieform $form, $values)