autoAddObjectClasses = false; } /** * Returns meta data that is interpreted by parent class * * @return array array with meta data * * @see baseModule::get_metaData() */ function get_metaData() { $return = array(); // icon $return['icon'] = 'eduPerson.png'; // manages host accounts $return["account_types"] = array("user"); // alias name $return["alias"] = _("EDU person"); // module dependencies $return['dependencies'] = array('depends' => array(), 'conflicts' => array()); // managed object classes $return['objectClasses'] = array('eduPerson'); // managed attributes $return['attributes'] = array('eduPersonAffiliation', 'eduPersonNickname', 'eduPersonOrgDN', 'eduPersonOrgUnitDN', 'eduPersonPrimaryAffiliation', 'eduPersonPrincipalName', 'eduPersonEntitlement', 'eduPersonPrimaryOrgUnitDN', 'eduPersonScopedAffiliation'); // help Entries $return['help'] = array( 'primaryAffiliation' => array( "Headline" => _("Primary affiliation"), "Text" => _("Specifies the person's primary relationship to the institution in broad categories such as student, faculty, staff, alum, etc.") ), 'scopedAffiliation' => array( "Headline" => _("Scoped affiliation"), "Text" => _("Specifies the person's affiliation within a particular security domain in broad categories such as student, faculty, staff, alum, etc.") ), 'nickName' => array( "Headline" => _("Nick names"), "Text" => _("This is a list of nick names for this user.") ), 'affiliation' => array( "Headline" => _("Affiliations"), "Text" => _("Specifies the person's relationship(s) to the institution in broad categories such as student, faculty, staff, alum, etc.") ), 'principalName' => array( "Headline" => _("Principal name"), "Text" => _("The \"NetID\" of the person for the purposes of inter-institutional authentication. It should be represented in the form \"user@scope\" where scope defines a local security domain.") ), 'entitlement' => array( "Headline" => _("Entitlements"), "Text" => _("URI (either URN or URL) that indicates a set of rights to specific resources.") ), 'orgDN' => array( "Headline" => _("Organization"), "Text" => _("The DN of the directory entry representing the institution with which the person is associated.") ), 'primaryOrgUnitDN' => array( "Headline" => _("Primary organizational unit"), "Text" => _("The DN of the directory entry representing the person's primary organizational unit.") ), 'orgUnitDN' => array( "Headline" => _("Organizational units"), "Text" => _("The DNs of the directory entries representing the person's organizational units.") )); // upload fields $return['upload_columns'] = array( array( 'name' => 'ieee802Device_mac', 'description' => _('MAC address'), 'help' => 'macList', 'example' => '00:01:02:DE:EF:18' ) ); // available PDF fields $return['PDF_fields'] = array( 'affiliation', 'nickname', 'orgDN', 'orgUnitDN', 'primaryAffiliation', 'principalName', 'entitlement', 'primaryOrgUnitDN', 'scopedAffiliation' ); return $return; } /** * This function fills the error message array with messages */ function load_Messages() { $this->messages['principalName'][0] = array('ERROR', _('Principal name is invalid!')); $this->messages['principalName'][1] = array('ERROR', _('Account %s:') . ' eduPerson_principalName', _('Principal name is invalid!')); $this->messages['orgDN'][0] = array('ERROR', _('Please enter a valid DN in the field:') . ' ' . _("Organization")); $this->messages['primaryOrgUnitDN'][0] = array('ERROR', _('Please enter a valid DN in the field:') . ' ' . _("Primary organizational unit")); $this->messages['orgUnitDN'][0] = array('ERROR', _('Organizational units contains an invalid entry.')); } /** * Returns the HTML meta data for the main account page. * * @return array HTML meta data */ function display_html_attributes() { if (isset($_POST['form_subpage_eduPerson_attributes_addObjectClass'])) { $this->attributes['objectClass'][] = 'eduPerson'; } $return = array(); if (in_array('eduPerson', $this->attributes['objectClass'])) { // principal name $principal = ''; if (isset($this->attributes['eduPersonPrincipalName'][0])) { $principal = $this->attributes['eduPersonPrincipalName'][0]; } $return[] = array( array('kind' => 'text', 'text' => _('Principal name')), array('kind' => 'input', 'type' => 'text', 'name' => 'principalName', 'value' => $principal), array('kind' => 'help', 'value' => 'principalName') ); // primary affiliation $primaryAffiliation = array(); if (isset($this->attributes['eduPersonPrimaryAffiliation'][0])) { $primaryAffiliation = array($this->attributes['eduPersonPrimaryAffiliation'][0]); } $return[] = array( array('kind' => 'text', 'text' => _('Primary affiliation')), array('kind' => 'select', 'name' => 'primaryAffiliation', 'options' => $this->affiliationTypes, 'options_selected' => $primaryAffiliation), array('kind' => 'help', 'value' => 'primaryAffiliation') ); // scoped affiliation $scopedAffiliation = ''; $scopedAffiliationPrefix = array(); if (isset($this->attributes['eduPersonScopedAffiliation'][0])) { $parts = explode('@', $this->attributes['eduPersonScopedAffiliation'][0]); $scopedAffiliationPrefix = array($parts[0]); $scopedAffiliation = substr($this->attributes['eduPersonScopedAffiliation'][0], strlen($parts[0]) + 1); } $return[] = array( array('kind' => 'text', 'text' => _('Scoped affiliation')), array('kind' => 'table', 'value' => array(array( array('kind' => 'select', 'name' => 'scopedAffiliationPrefix', 'options' => $this->affiliationTypes, 'options_selected' => $scopedAffiliationPrefix), array('kind' => 'text', 'text' => '@'), array('kind' => 'input', 'type' => 'text', 'name' => 'scopedAffiliation', 'value' => $scopedAffiliation) ))), array('kind' => 'help', 'value' => 'scopedAffiliation') ); // affiliations $affiliations = array(); if (isset($this->attributes['eduPersonAffiliation'][0])) { for ($i = 0; $i < sizeof($this->attributes['eduPersonAffiliation']); $i++) { $affiliations[] = array( array('kind' => 'select', 'name' => 'affiliation' . $i, 'options' => $this->affiliationTypes, 'options_selected' => array($this->attributes['eduPersonAffiliation'][$i])), array('kind' => 'input', 'type' => 'submit', 'name' => 'delAffiliation' . $i, 'image' => 'del.png', 'value' => ' ', 'title' => _('Delete')) ); } } else { $affiliations = array(array(array('kind' => 'text', 'text' => '-'))); } $return[] = array( array('kind' => 'text', 'text' => _('Affiliations'), 'td' => array('valign' => 'top')), array('kind' => 'table', 'value' => $affiliations), array('kind' => 'help', 'value' => 'affiliation', 'td' => array('valign' => 'top')) ); $return[] = array( array('kind' => 'text', 'text' => ' '), array('kind' => 'table', 'value' => array(array( array('kind' => 'select', 'name' => 'affiliation', 'options' => $this->affiliationTypes), array('kind' => 'input', 'type' => 'submit', 'name' => 'newAffiliation', 'image' => 'add.png', 'value' => ' ', 'title' => _('Add')) ))), array('kind' => 'text', 'text' => ' ')); // nick names $nicks = array(); if (isset($this->attributes['eduPersonNickname'][0])) { for ($i = 0; $i < sizeof($this->attributes['eduPersonNickname']); $i++) { $nicks[] = array( array('kind' => 'input', 'name' => 'nickName' . $i, 'type' => 'text', 'value' => $this->attributes['eduPersonNickname'][$i]), array('kind' => 'input', 'type' => 'submit', 'name' => 'delNickName' . $i, 'image' => 'del.png', 'value' => ' ', 'title' => _('Delete')) ); } } else { $nicks = array(array(array('kind' => 'text', 'text' => '-'))); } $return[] = array( array('kind' => 'text', 'text' => _('Nick names'), 'td' => array('valign' => 'top')), array('kind' => 'table', 'value' => $nicks), array('kind' => 'help', 'value' => 'nickName', 'td' => array('valign' => 'top')) ); $return[] = array( array('kind' => 'text', 'text' => ' '), array('kind' => 'table', 'value' => array(array( array('kind' => 'input', 'name' => 'nickName', 'type' => 'text', 'value' => ''), array('kind' => 'input', 'type' => 'submit', 'name' => 'newNickName', 'image' => 'add.png', 'value' => ' ', 'title' => _('Add')) ))), array('kind' => 'text', 'text' => ' ') ); // entitlements $entitlements = array(); if (isset($this->attributes['eduPersonEntitlement'][0])) { for ($i = 0; $i < sizeof($this->attributes['eduPersonEntitlement']); $i++) { $entitlements[] = array( array('kind' => 'input', 'name' => 'entitlement' . $i, 'type' => 'text', 'value' => $this->attributes['eduPersonEntitlement'][$i]), array('kind' => 'input', 'type' => 'submit', 'name' => 'delEntitlement' . $i, 'image' => 'del.png', 'value' => ' ', 'title' => _('Delete')) ); } } else { $entitlements = array(array(array('kind' => 'text', 'text' => '-'))); } $return[] = array( array('kind' => 'text', 'text' => _('Entitlements'), 'td' => array('valign' => 'top')), array('kind' => 'table', 'value' => $entitlements), array('kind' => 'help', 'value' => 'entitlement', 'td' => array('valign' => 'top')) ); $return[] = array( array('kind' => 'text', 'text' => ' '), array('kind' => 'table', 'value' => array(array( array('kind' => 'input', 'name' => 'entitlement', 'type' => 'text', 'value' => ''), array('kind' => 'input', 'type' => 'submit', 'name' => 'newEntitlement', 'image' => 'add.png', 'value' => ' ', 'title' => _('Add')) ))), array('kind' => 'text', 'text' => ' ') ); // org DN $orgDN = ''; if (isset($this->attributes['eduPersonOrgDN'][0])) { $orgDN = $this->attributes['eduPersonOrgDN'][0]; } $return[] = array( array('kind' => 'text', 'text' => _('Organization')), array('kind' => 'input', 'type' => 'text', 'size' => '40', 'name' => 'orgDN', 'value' => $orgDN), array('kind' => 'help', 'value' => 'orgDN') ); // primare OU DN $primaryOrgUnitDN = ''; if (isset($this->attributes['eduPersonPrimaryOrgUnitDN'][0])) { $primaryOrgUnitDN = $this->attributes['eduPersonPrimaryOrgUnitDN'][0]; } $return[] = array( array('kind' => 'text', 'text' => _('Primary organizational unit')), array('kind' => 'input', 'type' => 'text', 'size' => '40', 'name' => 'primaryOrgUnitDN', 'value' => $primaryOrgUnitDN), array('kind' => 'help', 'value' => 'primaryOrgUnitDN') ); // OUs $orgUnitDN = array(); if (isset($this->attributes['eduPersonOrgUnitDN'][0])) { for ($i = 0; $i < sizeof($this->attributes['eduPersonOrgUnitDN']); $i++) { $orgUnitDN[] = array( array('kind' => 'input', 'name' => 'orgUnitDN' . $i, 'type' => 'text', 'value' => $this->attributes['eduPersonOrgUnitDN'][$i], 'size' => '40'), array('kind' => 'input', 'type' => 'submit', 'name' => 'delOrgUnitDN' . $i, 'image' => 'del.png', 'value' => ' ', 'title' => _('Delete')) ); } } else { $orgUnitDN = array(array(array('kind' => 'text', 'text' => '-'))); } $return[] = array( array('kind' => 'text', 'text' => _('Organizational units'), 'td' => array('valign' => 'top')), array('kind' => 'table', 'value' => $orgUnitDN), array('kind' => 'help', 'value' => 'orgUnitDN', 'td' => array('valign' => 'top')) ); $return[] = array( array('kind' => 'text', 'text' => ' '), array('kind' => 'table', 'value' => array(array( array('kind' => 'input', 'name' => 'orgUnitDN', 'type' => 'text', 'value' => '', 'size' => '40'), array('kind' => 'input', 'type' => 'submit', 'name' => 'newOrgUnitDN', 'image' => 'add.png', 'value' => ' ', 'title' => _('Add')) ))), array('kind' => 'text', 'text' => ' ') ); } else { $return[] = array( array('kind' => 'text', 'text' => ' '), array('kind' => 'input', 'type' => 'submit', 'name' => 'form_subpage_eduPerson_attributes_addObjectClass', 'value' => _('Add EDU person extension')) ); } return $return; } /** * Processes user input of the primary module page. * It checks if all input values are correct and updates the associated LDAP attributes. * * @return array list of info/error messages */ function process_attributes() { $errors = array(); // primary affiliation $this->attributes['eduPersonPrimaryAffiliation'][0] = $_POST['primaryAffiliation']; // scoped affiliation if (isset($_POST['scopedAffiliation']) && ($_POST['scopedAffiliation'] != '')) { $this->attributes['eduPersonScopedAffiliation'][0] = $_POST['scopedAffiliationPrefix'] . '@' . $_POST['scopedAffiliation']; } elseif (isset($this->attributes['eduPersonScopedAffiliation'][0])) { unset($this->attributes['eduPersonScopedAffiliation']); } // principal name $this->attributes['eduPersonPrincipalName'][0] = $_POST['principalName']; if ($_POST['principalName'] != '') { if (eregi('^[0-9a-z_\\.@-]+$', $_POST['principalName']) === false) { $errors[] = $this->messages['principalName'][0]; } } // affiliations $this->attributes['eduPersonAffiliation'] = array(); $i = 0; while (isset($_POST['affiliation' . $i])) { if (!isset($_POST['delAffiliation' . $i]) && ($_POST['affiliation' . $i] != '')) { $this->attributes['eduPersonAffiliation'][] = $_POST['affiliation' . $i]; } $i++; } if (isset($_POST['newAffiliation']) && ($_POST['affiliation'] != '')) { $this->attributes['eduPersonAffiliation'][] = $_POST['affiliation']; } $this->attributes['eduPersonAffiliation'] = array_unique($this->attributes['eduPersonAffiliation']); // nick names $this->attributes['eduPersonNickname'] = array(); $i = 0; while (isset($_POST['nickName' . $i])) { if (!isset($_POST['delNickName' . $i]) && ($_POST['nickName' . $i] != '')) { $this->attributes['eduPersonNickname'][] = $_POST['nickName' . $i]; } $i++; } if (isset($_POST['newNickName']) && ($_POST['nickName'] != '')) { $this->attributes['eduPersonNickname'][] = $_POST['nickName']; } $this->attributes['eduPersonNickname'] = array_unique($this->attributes['eduPersonNickname']); // entitlements $this->attributes['eduPersonEntitlement'] = array(); $i = 0; while (isset($_POST['entitlement' . $i])) { if (!isset($_POST['delEntitlement' . $i]) && ($_POST['entitlement' . $i] != '')) { $this->attributes['eduPersonEntitlement'][] = $_POST['entitlement' . $i]; } $i++; } if (isset($_POST['newEntitlement']) && ($_POST['entitlement'] != '')) { $this->attributes['eduPersonEntitlement'][] = $_POST['entitlement']; } $this->attributes['eduPersonEntitlement'] = array_unique($this->attributes['eduPersonEntitlement']); // org DN $this->attributes['eduPersonOrgDN'][0] = $_POST['orgDN']; if ($_POST['orgDN'] != '') { if (!get_preg($_POST['orgDN'], 'dn')) { $errors[] = $this->messages['orgDN'][0]; } } // primary OU $this->attributes['eduPersonPrimaryOrgUnitDN'][0] = $_POST['primaryOrgUnitDN']; if ($_POST['primaryOrgUnitDN'] != '') { if (!get_preg($_POST['primaryOrgUnitDN'], 'dn')) { $errors[] = $this->messages['primaryOrgUnitDN'][0]; } } // OUs $this->attributes['eduPersonOrgUnitDN'] = array(); $i = 0; while (isset($_POST['orgUnitDN' . $i])) { if (!isset($_POST['delOrgUnitDN' . $i]) && ($_POST['orgUnitDN' . $i] != '')) { $this->attributes['eduPersonOrgUnitDN'][] = $_POST['orgUnitDN' . $i]; if (!get_preg($_POST['orgUnitDN' . $i], 'dn')) { $error = $this->messages['orgUnitDN'][0]; array_push($error, $_POST['orgUnitDN' . $i]); $errors[] = $error; } } $i++; } if (isset($_POST['newOrgUnitDN']) && ($_POST['orgUnitDN'] != '')) { $this->attributes['eduPersonOrgUnitDN'][] = $_POST['orgUnitDN']; if (!get_preg($_POST['orgUnitDN'], 'dn')) { $error = $this->messages['orgUnitDN'][0]; array_push($error, $_POST['orgUnitDN']); $errors[] = $error; } } $this->attributes['eduPersonOrgUnitDN'] = array_unique($this->attributes['eduPersonOrgUnitDN']); return $errors; } /** * In this function the LDAP account is built up. * * @param array $rawAccounts list of hash arrays (name => value) from user input * @param array $partialAccounts list of hash arrays (name => value) which are later added to LDAP * @param array $ids list of IDs for column position (e.g. "posixAccount_uid" => 5) * @return array list of error messages if any */ function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts) { $messages = array(); for ($i = 0; $i < sizeof($rawAccounts); $i++) { // add object class if (!in_array("eduPerson", $partialAccounts[$i]['objectClass'])) $partialAccounts[$i]['objectClass'][] = "eduPerson"; // primary affiliation if ($rawAccounts[$i][$ids['eduPerson_primaryAffiliation']] != "") { } } return $messages; } /** * Returns the PDF entries for this module. * * @return array list of possible PDF entries */ function get_pdfEntries() { $return = array(); if (isset($this->attributes['eduPersonPrimaryAffiliation'][0])) { $return['eduPerson_primaryAffiliation'][0] = '' . _('Primary affiliation') . '' . $this->attributes['eduPersonPrimaryAffiliation'][0] . ''; } if (isset($this->attributes['eduPersonScopedAffiliation'][0])) { $return['eduPerson_scopedAffiliation'][0] = '' . _('Scoped affiliation') . '' . $this->attributes['eduPersonScopedAffiliation'][0] . ''; } if (isset($this->attributes['eduPersonPrincipalName'][0])) { $return['eduPerson_principalName'][0] = '' . _('Principal name') . '' . $this->attributes['eduPersonPrincipalName'][0] . ''; } if (isset($this->attributes['eduPersonNickname'][0])) { sort($this->attributes['eduPersonNickname']); $return['eduPerson_nickname'][0] = '' . _('Nick names') . '' . implode(', ', $this->attributes['eduPersonNickname']) . ''; } if (isset($this->attributes['eduPersonAffiliation'][0])) { sort($this->attributes['eduPersonAffiliation']); $return['eduPerson_affiliation'][0] = '' . _('Affiliations') . '' . implode(', ', $this->attributes['eduPersonAffiliation']) . ''; } if (isset($this->attributes['eduPersonEntitlement'][0])) { sort($this->attributes['eduPersonEntitlement']); $return['eduPerson_entitlement'][0] = '' . _('Entitlements') . '' . implode(', ', $this->attributes['eduPersonEntitlement']) . ''; } if (isset($this->attributes['eduPersonOrgDN'][0])) { $return['eduPerson_orgDN'][0] = '' . _('Organization') . '' . $this->attributes['eduPersonOrgDN'][0] . ''; } if (isset($this->attributes['eduPersonPrimaryOrgUnitDN'][0])) { $return['eduPerson_primaryOrgUnitDN'][0] = '' . _('Primary organizational unit') . '' . $this->attributes['eduPersonPrimaryOrgUnitDN'][0] . ''; } if (isset($this->attributes['eduPersonOrgUnitDN'][0])) { $return['eduPerson_orgUnitDN'][0] = '' . _('Organizational units') . '' . implode(', ', $this->attributes['eduPersonOrgUnitDN']) . ''; } return $return; } } ?>