used as your $PLC_NAME username
EOF;
-$person_form['site_ids']['comment'] = <<< EOF
-Select the site where you belong
-EOF;
+
+// dirty hack feb 2018; if this file can be found,
+// its contents is used instead of the hard-wired message
+// it is searched along php's include path, so it should be
+// allright to save it as /etc/planetlab/php/person-registration.txt
+// of course html tags like <code> and <br /> are OK
+global $message_filename;
+$message_filename = "person-registration.txt";
+
+try {
+ $person_form['site_ids']['comment'] = file_get_contents($message_filename, TRUE);
+} catch (Exception $e) {
+ $person_form['site_ids']['comment'] = "Select the site where you belong";
+}
if (0)
$person_form['roles']['comment'] = <<< EOF
// Filter out "Select a site"
if (!empty($person['site_ids'])) {
- $person['site_ids'] = array_filter($person['site_ids'],
- create_function('$site_id', 'return intval($site_id) > 0;'));
+ $person['site_ids'] = array_filter(
+ $person['site_ids'],
+ function($site_id) {return intval($site_id) > 0;});
}
//////////////////// minimal checking
function check_form ($person) {
global $person_form;
global $adm;
-
+
// Look for missing/blank entries
$missing = array();
foreach ($person_form as $name => $item) {
foreach ($missing as $field) $warnings []= "$field field is required.";
print html_div(plc_itemize($warnings),"messages error");
return FALSE;
- }
+ }
// check that the email address is not already used on this peer
$email=$person['email'];
$errors = errors_init ();
- // N.B.: site_ids and roles are ignored by AddPerson()
+ // jan-2013 with improvements in plcapi-5.1-6 about managing persons and tags,
+ // AddPerson has gone more picky and we need to remove some fields
+ // that no longer are silently ignored by AddPerson
+ $site_ids=$person['site_ids'];
+ unset ($person['site_ids']);
+ $roles=$person['roles'];
+ unset ($person['roles']);
+
$person_id = $adm->AddPerson($person);
$errors = errors_record ($adm,$errors);
$adm->begin();
// Add person to requested sites
- foreach ($person['site_ids'] as $site_id) {
+ foreach ($site_ids as $site_id) {
$adm->AddPersonToSite($person_id, intval($site_id));
$adm->SetPersonPrimarySite($person_id, intval($site_id));
}
- // Add requested roles. Always add the user role.
+ // Add requested roles. Always add the user role.
$adm->AddRoleToPerson('user', $person_id);
- if (!empty($person['roles'])) {
- foreach ($person['roles'] as $role) {
+ if (!empty($roles)) {
+ foreach ($roles as $role) {
$adm->AddRoleToPerson($role, $person_id);
}
}
// All defined sites
// cannot register with foreign site
-$adm->GetSites(array('is_public' => TRUE, 'peer_id' => NULL,'-SORT'=>'name'),
- array('site_id', 'name','enabled','peer_id'));
+// we also hide sites that are created by sfa
+// as well as the ones that have a disabled_registration tag set
+$adm->GetSites(array('is_public' => TRUE, 'peer_id' => NULL,
+ 'sfa_created' => NULL,
+ 'disabled_registration' => NULL,
+ '-SORT'=>'name'),
+ array('site_id', 'name', 'enabled', 'peer_id',
+ 'sfa_created', 'disabled_registration'));
// All defined roles
$adm->GetRoles();
$option .= htmlspecialchars($site['name']);
# Safari/IE do not implement disabled correctly
if ( ! $site['enabled'] )
- $option .= " (pending registration)";
+ $option .= " (disabled, or pending registration)";
$option .= "</option>";
return $option;
}