public function get_summary() { $smarty = $this->exporter->get_smarty(); $outputfilter = new HtmlExportOutputFilter('.', $this->exporter); $smarty->assign('introduction', $outputfilter->filter(get_profile_field($this->exporter->get('user')->get('id'), 'introduction'))); $smarty->assign('profileviewexported', $this->profileviewexported); $iconid = $this->exporter->get('user')->get('profileicon'); if ($iconid) { $icon = artefact_instance_from_id($iconid); $smarty->assign('icon', '<img src="static/profileicons/200px-' . PluginExportHtml::sanitise_path($icon->get('title')) . '" alt="Profile Picture">'); } return array('description' => $smarty->fetch('export:html/internal:summary.tpl')); }
/** * Given a user and their remote user record, attempt to populate some of * the user's profile fields and account settings from the remote data. * * This does not change the first name, last name or e-mail fields, as these are * dealt with differently depending on whether we are creating the user * record or updating it. * * This method attempts to set: * * * City * * Country * * Language * * Introduction * * WYSIWYG editor setting * * @param User $user * @param stdClass $remoteuser */ private function import_user_settings($user, $remoteuser) { $imported = array(); // City if (!empty($remoteuser->city)) { if (get_profile_field($user->id, 'town') != $remoteuser->city) { set_profile_field($user->id, 'town', $remoteuser->city); } $imported[] = 'town'; } // Country if (!empty($remoteuser->country)) { $validcountries = array_keys(getoptions_country()); $newcountry = strtolower($remoteuser->country); if (in_array($newcountry, $validcountries)) { set_profile_field($user->id, 'country', $newcountry); } $imported[] = 'country'; } // Language if (!empty($remoteuser->lang)) { $validlanguages = array_keys(get_languages()); $newlanguage = str_replace('_utf8', '', strtolower($remoteuser->lang)) . '.utf8'; if (in_array($newlanguage, $validlanguages)) { set_account_preference($user->id, 'lang', $newlanguage); $user->set_account_preference('lang', $newlanguage); } } // Description if (isset($remoteuser->description)) { if (get_profile_field($user->id, 'introduction') != $remoteuser->description) { set_profile_field($user->id, 'introduction', $remoteuser->description); } $imported[] = 'introduction'; } // HTML Editor setting if (isset($remoteuser->htmleditor)) { $htmleditor = $remoteuser->htmleditor ? 1 : 0; if ($htmleditor != get_account_preference($user->id, 'wysiwyg')) { set_account_preference($user->id, 'wysiwyg', $htmleditor); $user->set_account_preference('wysiwyg', $htmleditor); } } return $imported; }
/** * Checks that all the required fields are set, and handles setting them if required. * * Checks whether the current user needs to change their password, and handles * the password changing if it's required. */ function auth_check_required_fields() { global $USER, $SESSION; if (defined('NOCHECKREQUIREDFIELDS')) { return; } $changepassword = true; $elements = array(); if (!$USER->get('passwordchange') || $USER->get('parentuser') && $USER->get('loginanyway') || defined('NOCHECKPASSWORDCHANGE')) { $changepassword = false; } // Check if the user wants to log in anyway if ($USER->get('passwordchange') && $USER->get('parentuser') && isset($_GET['loginanyway'])) { $USER->loginanyway = true; $changepassword = false; } // Do not force password change on JSON request. if (defined('JSON') && JSON == true) { $changepassword = false; } if ($changepassword) { $authobj = AuthFactory::create($USER->authinstance); if ($authobj->changepasswordurl) { redirect($authobj->changepasswordurl); exit; } if (method_exists($authobj, 'change_password')) { if ($SESSION->get('resetusername')) { $elements['username'] = array('type' => 'text', 'defaultvalue' => $USER->get('username'), 'title' => get_string('changeusername', 'account'), 'description' => get_string('changeusernamedesc', 'account', hsc(get_config('sitename')))); } $elements['password1'] = array('type' => 'password', 'title' => get_string('newpassword') . ':', 'description' => get_string('yournewpassword'), 'rules' => array('required' => true)); $elements['password2'] = array('type' => 'password', 'title' => get_string('confirmpassword') . ':', 'description' => get_string('yournewpasswordagain'), 'rules' => array('required' => true)); $elements['country'] = array('type' => 'select', 'title' => "Country", 'options' => array("ca" => "Canada", "us" => "United States"), 'defaultvalue' => "us", 'description' => "Country", 'rules' => array('required' => true)); $elements['state'] = array('type' => 'select', 'title' => "State", 'options' => array('AL' => "Alabama", 'AK' => "Alaska", 'AZ' => "Arizona", 'AR' => "Arkansas", 'CA' => "California", 'CO' => "Colorado", 'CT' => "Connecticut", 'DE' => "Delaware", 'DC' => "District of Columbia", 'FL' => "Florida", 'GA' => "Georgia", 'HI' => "Hawaii", 'ID' => "Idaho", 'IL' => "Illinois", 'IN' => "Indiana", 'IA' => "Iowa", 'KS' => "Kansas", 'KY' => "Kentucky", 'LA' => "Louisiana", 'ME' => "Maine", 'MD' => "Maryland", 'MA' => "Massachusetts", 'MI' => "Michigan", 'MN' => "Minnesota", 'MS' => "Mississippi", 'MO' => "Missouri", 'MT' => "Montana", 'NE' => "Nebraska", 'NV' => "Nevada", 'NH' => "New Hampshire", 'NJ' => "New Jersey", 'NM' => "New Mexico", 'NY' => "New York", 'NC' => "North Carolina", 'ND' => "North Dakota", 'OH' => "Ohio", 'OK' => "Oklahoma", 'OR' => "Oregon", 'PA' => "Pennsylvania", 'RI' => "Rhode Island", 'SC' => "South Carolina", 'SD' => "South Dakota", 'TN' => "Tennessee", 'TX' => "Texas", 'UT' => "Utah", 'VT' => "Vermont", 'VA' => "Virginia", 'WA' => "Washington", 'WV' => "West Virginia", 'WI' => "Wisconsin", 'WY' => "Wyoming", 'AB' => "Alberta", 'BC' => "British Columbia", 'MB' => "Manitoba", 'NB' => "New Brunswick", 'NL' => "Newfoundland and Labrador", 'NT' => "Northwest Territories", 'NS' => "Nova Scotia", 'NU' => "Nunavut", 'ON' => "Ontario", 'PE' => "Prince Edward Island", 'QC' => "Quebec", 'SK' => "Saskatchewan", 'YT' => "Yukon"), 'description' => "State", 'rules' => array('required' => true)); $elements['email'] = array('type' => 'text', 'title' => get_string('principalemailaddress', 'artefact.internal'), 'ignore' => trim($USER->get('email')) != '' && !preg_match('/@example\\.org$/', $USER->get('email')), 'rules' => array('required' => true, 'email' => true)); } } else { if (defined('JSON')) { // Don't need to check this for json requests return; } } safe_require('artefact', 'internal'); require_once 'pieforms/pieform.php'; $alwaysmandatoryfields = array_keys(ArtefactTypeProfile::get_always_mandatory_fields()); foreach (ArtefactTypeProfile::get_mandatory_fields() as $field => $type) { // Always mandatory fields are stored in the usr table, so are part of // the user session object. We can save a query by grabbing them from // the session. if (in_array($field, $alwaysmandatoryfields) && $USER->get($field) != null) { continue; } // Not cached? Get value the standard way. if (get_profile_field($USER->get('id'), $field) != null) { continue; } if ($field == 'email') { if (isset($elements['email'])) { continue; } // Use a text field for their first e-mail address, not the // emaillist element $type = 'text'; } $elements[$field] = array('type' => $type, 'title' => get_string($field, 'artefact.internal'), 'rules' => array('required' => true)); if ($field == 'socialprofile') { $elements[$field] = ArtefactTypeSocialprofile::get_new_profile_elements(); // add an element to flag that socialprofile is in the list of fields. $elements['socialprofile_hidden'] = array('type' => 'hidden', 'value' => 1); } // @todo ruthlessly stolen from artefact/internal/index.php, could be merged if ($type == 'wysiwyg') { $elements[$field]['rows'] = 10; $elements[$field]['cols'] = 60; } if ($type == 'textarea') { $elements[$field]['rows'] = 4; $elements[$field]['cols'] = 60; } if ($field == 'country') { $elements[$field]['options'] = getoptions_country(); $elements[$field]['defaultvalue'] = get_config('country'); } if ($field == 'email') { // Check if a validation email has been sent if (record_exists('artefact_internal_profile_email', 'owner', $USER->get('id'))) { $elements['email']['type'] = 'html'; $elements['email']['value'] = get_string('validationprimaryemailsent', 'auth'); $elements['email']['disabled'] = true; $elements['email']['rules'] = array('required' => false); } else { $elements[$field]['rules']['email'] = true; $elements[$field]['description'] = get_string('primaryemaildescription', 'auth'); } } } if (empty($elements)) { // No mandatory fields that aren't set return; } if (count($elements) == 1 && isset($elements['email']) && $elements['email']['type'] == 'html') { // Display a message if there is only 1 required field and this field is email whose validation has been sent $elements['submit'] = array('type' => 'submit', 'value' => get_string('continue', 'admin')); $form = pieform(array('name' => 'requiredfields', 'method' => 'post', 'action' => get_config('wwwroot') . '?logout', 'elements' => $elements)); } else { $elements['submit'] = array('type' => 'submit', 'value' => get_string('submit')); $form = pieform(array('name' => 'requiredfields', 'method' => 'post', 'action' => '', 'elements' => $elements)); } $smarty = smarty(); if ($USER->get('parentuser')) { $smarty->assign('loginasoverridepasswordchange', get_string('loginasoverridepasswordchange', 'admin', '<a class="btn" href="' . get_config('wwwroot') . '?loginanyway">', '</a>')); } $smarty->assign('changepassword', $changepassword); $smarty->assign('changeusername', $SESSION->get('resetusername')); $smarty->assign('form', $form); $smarty->display('requiredfields.tpl'); exit; }
/** * Checks that all the required fields are set, and handles setting them if required. * * Checks whether the current user needs to change their password, and handles * the password changing if it's required. */ function auth_check_required_fields() { global $USER, $SESSION; if (defined('NOCHECKREQUIREDFIELDS')) { return; } $changepassword = true; $elements = array(); if (!$USER->get('passwordchange') || $USER->get('parentuser') && $USER->get('loginanyway') || defined('NOCHECKPASSWORDCHANGE')) { $changepassword = false; } // Check if the user wants to log in anyway if ($USER->get('passwordchange') && $USER->get('parentuser') && isset($_GET['loginanyway'])) { $USER->loginanyway = true; $changepassword = false; } // Do not force password change on JSON request. if (defined('JSON') && JSON == true) { $changepassword = false; } if ($changepassword) { $authobj = AuthFactory::create($USER->authinstance); if ($authobj->changepasswordurl) { redirect($authobj->changepasswordurl); exit; } if (method_exists($authobj, 'change_password')) { if ($SESSION->get('resetusername')) { $elements['username'] = array('type' => 'text', 'defaultvalue' => $USER->get('username'), 'title' => get_string('changeusername', 'account'), 'description' => get_string('changeusernamedesc', 'account', hsc(get_config('sitename')))); } $elements['password1'] = array('type' => 'password', 'title' => get_string('newpassword') . ':', 'description' => get_string('yournewpassword'), 'rules' => array('required' => true)); $elements['password2'] = array('type' => 'password', 'title' => get_string('confirmpassword') . ':', 'description' => get_string('yournewpasswordagain'), 'rules' => array('required' => true)); $elements['email'] = array('type' => 'text', 'title' => get_string('principalemailaddress', 'artefact.internal'), 'ignore' => trim($USER->get('email')) != '' && !preg_match('/@example\\.org$/', $USER->get('email')), 'rules' => array('required' => true, 'email' => true)); } } else { if (defined('JSON')) { // Don't need to check this for json requests return; } } safe_require('artefact', 'internal'); require_once 'pieforms/pieform.php'; $alwaysmandatoryfields = array_keys(ArtefactTypeProfile::get_always_mandatory_fields()); foreach (ArtefactTypeProfile::get_mandatory_fields() as $field => $type) { // Always mandatory fields are stored in the usr table, so are part of // the user session object. We can save a query by grabbing them from // the session. if (in_array($field, $alwaysmandatoryfields) && $USER->get($field) != null) { continue; } // Not cached? Get value the standard way. if (get_profile_field($USER->get('id'), $field) != null) { continue; } if ($field == 'email') { if (isset($elements['email'])) { continue; } // Use a text field for their first e-mail address, not the // emaillist element $type = 'text'; } $elements[$field] = array('type' => $type, 'title' => get_string($field, 'artefact.internal'), 'rules' => array('required' => true)); if ($field == 'socialprofile') { $elements[$field] = ArtefactTypeSocialprofile::get_new_profile_elements(); // add an element to flag that socialprofile is in the list of fields. $elements['socialprofile_hidden'] = array('type' => 'hidden', 'value' => 1); } // @todo ruthlessly stolen from artefact/internal/index.php, could be merged if ($type == 'wysiwyg') { $elements[$field]['rows'] = 10; $elements[$field]['cols'] = 60; } if ($type == 'textarea') { $elements[$field]['rows'] = 4; $elements[$field]['cols'] = 60; } if ($field == 'country') { $elements[$field]['options'] = getoptions_country(); $elements[$field]['defaultvalue'] = get_config('country'); } if ($field == 'email') { // Check if a validation email has been sent if (record_exists('artefact_internal_profile_email', 'owner', $USER->get('id'))) { $elements['email']['type'] = 'html'; $elements['email']['value'] = get_string('validationprimaryemailsent', 'auth'); $elements['email']['disabled'] = true; $elements['email']['rules'] = array('required' => false); } else { $elements[$field]['rules']['email'] = true; $elements[$field]['description'] = get_string('primaryemaildescription', 'auth'); } } } if (empty($elements)) { // No mandatory fields that aren't set return; } if (count($elements) == 1 && isset($elements['email']) && $elements['email']['type'] == 'html') { // Display a message if there is only 1 required field and this field is email whose validation has been sent $elements['submit'] = array('type' => 'submit', 'value' => get_string('continue', 'admin')); $form = pieform(array('name' => 'requiredfields', 'method' => 'post', 'action' => get_config('wwwroot') . '?logout', 'elements' => $elements)); } else { $elements['submit'] = array('type' => 'submit', 'class' => 'btn-success', 'value' => get_string('submit')); $form = pieform(array('name' => 'requiredfields', 'method' => 'post', 'action' => '', 'elements' => $elements, 'dieaftersubmit' => FALSE, 'backoutaftersubmit' => TRUE)); } // Has the form been successfully submitted? Back out and let the requested URL continue. if ($form === FALSE) { return; } $smarty = smarty(); if ($USER->get('parentuser')) { $smarty->assign('loginasoverridepasswordchange', get_string('loginasoverridepasswordchange', 'admin', '<a class="" href="' . get_config('wwwroot') . '?loginanyway">', '</a>')); } $smarty->assign('changepassword', $changepassword); $smarty->assign('changeusername', $SESSION->get('resetusername')); $smarty->assign('form', $form); $smarty->display('requiredfields.tpl'); exit; }
/** * Update user * * @param object $user stdclass for the usr table * @param object $profile profile field/values to set * @param string $remotename username on the remote site * @param array $accountprefs user account preferences to set * @param bool $forceupdateremote force delete of remotename before update attempted * @return array list of updated fields */ function update_user($user, $profile, $remotename = null, $accountprefs = array(), $forceupdateremote = false, $quickhash = false) { require_once get_config('docroot') . 'auth/session.php'; if (!empty($user->id)) { $oldrecord = get_record('usr', 'id', $user->id); } else { $oldrecord = get_record('usr', 'username', $user->username); } $userid = $oldrecord->id; db_begin(); // Log the user out, otherwise they can overwrite all this on the next request remove_user_sessions($userid); $updated = array(); $newrecord = new StdClass(); foreach (get_object_vars($user) as $k => $v) { if (!empty($v) && ($k == 'password' || empty($oldrecord->{$k}) || $oldrecord->{$k} != $v)) { $newrecord->{$k} = $v; $updated[$k] = $v; } if (!empty($v) && $k === 'email' && $oldrecord->{$k} != $v) { set_user_primary_email($userid, $v); } } if (count(get_object_vars($newrecord))) { $newrecord->id = $userid; update_record('usr', $newrecord); if (!empty($newrecord->password)) { $newrecord->authinstance = $user->authinstance; reset_password($newrecord, false, $quickhash); } } foreach (get_object_vars($profile) as $k => $v) { if (get_profile_field($userid, $k) != $v) { set_profile_field($userid, $k, $v); $updated[$k] = $v; } } if ($remotename) { $oldremote = get_field('auth_remote_user', 'remoteusername', 'authinstance', $oldrecord->authinstance, 'localusr', $userid); if ($remotename != $oldremote) { $updated['remoteuser'] = $remotename; } delete_records('auth_remote_user', 'authinstance', $user->authinstance, 'localusr', $userid); // force the update of the remoteuser - for the case of a series of user updates swapping the remoteuser name if ($forceupdateremote) { delete_records('auth_remote_user', 'authinstance', $user->authinstance, 'remoteusername', $remotename); } else { // remote username must not already exist if (record_exists('auth_remote_user', 'remoteusername', $remotename, 'authinstance', $user->authinstance)) { throw new InvalidArgumentException("user_update: remoteusername already in use: " . $remotename); } } insert_record('auth_remote_user', (object) array('authinstance' => $user->authinstance, 'remoteusername' => $remotename, 'localusr' => $userid)); } // Update account preferences if (!empty($accountprefs)) { $expectedprefs = expected_account_preferences(); foreach ($expectedprefs as $eprefkey => $epref) { if (isset($accountprefs[$eprefkey]) && $accountprefs[$eprefkey] != get_account_preference($userid, $eprefkey)) { set_account_preference($userid, $eprefkey, $accountprefs[$eprefkey]); $updated[$eprefkey] = $accountprefs[$eprefkey]; } } } db_commit(); return $updated; }
function mahara_user_update_users($client) { //Set test data $dbuser1 = $this->create_user1_for_update(); $dbuser2 = $this->create_user2_for_update(); //update the test data $user1 = new stdClass(); $user1->id = $dbuser1->id; $user1->username = '******'; $user1->password = '******'; $user1->firstname = 'testfirstname1_updated'; $user1->lastname = 'testlastname1_updated'; $user1->email = '*****@*****.**'; $user1->studentid = 'testidnumber1_updated'; $user1->preferredname = 'Hello World!_updated'; $user1->city = 'testcity1_updated'; $user1->country = 'au'; $user2 = new stdClass(); $user2->id = $dbuser2->id; $user2->username = '******'; $user2->password = '******'; $user2->firstname = 'testfirstname2_updated'; $user2->lastname = 'testlastname2_updated'; $user2->email = '*****@*****.**'; $users = array($user1, $user2); //update the users by web service $function = 'mahara_user_update_users'; $params = array('users' => $users); $client->call($function, $params); //compare DB user with the test data $dbuser1 = get_record('usr', 'username', $user1->username); $this->assertEquals($dbuser1->firstname, $user1->firstname); $this->assertEquals($dbuser1->password, self::encrypt_password($user1->password, $dbuser1->salt, '$2a$' . get_config('bcrypt_cost') . '$', get_config('passwordsaltmain'))); $this->assertEquals($dbuser1->lastname, $user1->lastname); $this->assertEquals($dbuser1->email, $user1->email); $this->assertEquals($dbuser1->studentid, $user1->studentid); $this->assertEquals($dbuser1->preferredname, $user1->preferredname); foreach (array('city', 'country') as $field) { $artefact = get_profile_field($dbuser1->id, $field); $this->assertEquals($artefact, $user1->{$field}); } $dbuser2 = get_record('usr', 'username', $user2->username); $this->assertEquals($dbuser2->firstname, $user2->firstname); $this->assertEquals($dbuser2->password, self::encrypt_password($user2->password, $dbuser2->salt, '$2a$' . get_config('bcrypt_cost') . '$', get_config('passwordsaltmain'))); $this->assertEquals($dbuser2->lastname, $user2->lastname); $this->assertEquals($dbuser2->email, $user2->email); }
/** * Checks that all the required fields are set, and handles setting them if required. */ function auth_check_required_fields() { global $USER; if (defined('JSON')) { // Don't need to check this for json requests return; } safe_require('artefact', 'internal'); require_once 'pieforms/pieform.php'; $elements = array(); $alwaysmandatoryfields = array_keys(ArtefactTypeProfile::get_always_mandatory_fields()); foreach (ArtefactTypeProfile::get_mandatory_fields() as $field => $type) { // Always mandatory fields are stored in the usr table, so are part of // the user session object. We can save a query by grabbing them from // the session. if (in_array($field, $alwaysmandatoryfields) && $USER->get($field) != null) { continue; } // Not cached? Get value the standard way. if (get_profile_field($USER->get('id'), $field) != null) { continue; } if ($field == 'email') { // Use a text field for their first e-mail address, not the // emaillist element $type = 'text'; } $elements[$field] = array('type' => $type, 'title' => get_string($field, 'artefact.internal'), 'rules' => array('required' => true)); // @todo ruthlessly stolen from artefact/internal/index.php, could be merged if ($type == 'wysiwyg') { $elements[$field]['rows'] = 10; $elements[$field]['cols'] = 60; } if ($type == 'textarea') { $elements[$field]['rows'] = 4; $elements[$field]['cols'] = 60; } if ($field == 'country') { $elements[$field]['options'] = getoptions_country(); $elements[$field]['defaultvalue'] = 'nz'; } if ($field == 'email') { $elements[$field]['rules']['email'] = true; } } if (empty($elements)) { // No mandatory fields that aren't set return; } $elements['submit'] = array('type' => 'submit', 'value' => get_string('submit')); $form = pieform(array('name' => 'requiredfields', 'method' => 'post', 'action' => '', 'elements' => $elements)); $smarty = smarty(); $smarty->assign('form', $form); $smarty->display('requiredfields.tpl'); exit; }
/** * Checks that all the required fields are set, and handles setting them if required. * * Checks whether the current user needs to change their password, and handles * the password changing if it's required. */ function auth_check_required_fields() { global $USER, $SESSION; $changepassword = true; $elements = array(); if (!$USER->get('passwordchange') || $USER->get('parentuser') && $USER->get('loginanyway') || defined('NOCHECKPASSWORDCHANGE')) { $changepassword = false; } // Check if the user wants to log in anyway if ($USER->get('passwordchange') && $USER->get('parentuser') && isset($_GET['loginanyway'])) { $USER->loginanyway = true; $changepassword = false; } if ($changepassword) { $authobj = AuthFactory::create($USER->authinstance); if ($authobj->changepasswordurl) { redirect($authobj->changepasswordurl); exit; } if (method_exists($authobj, 'change_password')) { if ($SESSION->get('resetusername')) { $elements['username'] = array('type' => 'text', 'defaultvalue' => $USER->get('username'), 'title' => get_string('changeusername', 'account'), 'description' => get_string('changeusernamedesc', 'account', hsc(get_config('sitename')))); } $elements['password1'] = array('type' => 'password', 'title' => get_string('newpassword') . ':', 'description' => get_string('yournewpassword'), 'rules' => array('required' => true)); $elements['password2'] = array('type' => 'password', 'title' => get_string('confirmpassword') . ':', 'description' => get_string('yournewpasswordagain'), 'rules' => array('required' => true)); $elements['email'] = array('type' => 'text', 'title' => get_string('principalemailaddress', 'artefact.internal'), 'ignore' => trim($USER->get('email')) != '' && !preg_match('/@example\\.org$/', $USER->get('email')), 'rules' => array('required' => true, 'email' => true)); } } else { if (defined('JSON')) { // Don't need to check this for json requests return; } } safe_require('artefact', 'internal'); require_once 'pieforms/pieform.php'; $alwaysmandatoryfields = array_keys(ArtefactTypeProfile::get_always_mandatory_fields()); foreach (ArtefactTypeProfile::get_mandatory_fields() as $field => $type) { // Always mandatory fields are stored in the usr table, so are part of // the user session object. We can save a query by grabbing them from // the session. if (in_array($field, $alwaysmandatoryfields) && $USER->get($field) != null) { continue; } // Not cached? Get value the standard way. if (get_profile_field($USER->get('id'), $field) != null) { continue; } if ($field == 'email') { if (isset($elements['email'])) { continue; } // Use a text field for their first e-mail address, not the // emaillist element $type = 'text'; } $elements[$field] = array('type' => $type, 'title' => get_string($field, 'artefact.internal'), 'rules' => array('required' => true)); // @todo ruthlessly stolen from artefact/internal/index.php, could be merged if ($type == 'wysiwyg') { $elements[$field]['rows'] = 10; $elements[$field]['cols'] = 60; } if ($type == 'textarea') { $elements[$field]['rows'] = 4; $elements[$field]['cols'] = 60; } if ($field == 'country') { $elements[$field]['options'] = getoptions_country(); $elements[$field]['defaultvalue'] = get_config('country'); } if ($field == 'email') { $elements[$field]['rules']['email'] = true; } } if (empty($elements)) { // No mandatory fields that aren't set return; } $elements['submit'] = array('type' => 'submit', 'value' => get_string('submit')); $form = pieform(array('name' => 'requiredfields', 'method' => 'post', 'action' => '', 'elements' => $elements)); $smarty = smarty(); if ($USER->get('parentuser')) { $smarty->assign('loginasoverridepasswordchange', get_string('loginasoverridepasswordchange', 'admin', '<a href="' . get_config('wwwroot') . '?loginanyway">', '</a>')); } $smarty->assign('changepassword', $changepassword); $smarty->assign('changeusername', $SESSION->get('resetusername')); $smarty->assign('form', $form); $smarty->display('requiredfields.tpl'); exit; }