';
}
}
}
return $return;
}
/**
* This function defines what attributes will be used in the account profiles and their appearance in the profile editor.
*
* Calling this method does not require the existence of an enclosing {@link accountContainer}.
*
* The return value is an object implementing htmlElement.
* The field name are used as keywords to load
* and save profiles. We recommend to use the module name as prefix for them
* (e.g. posixAccount_homeDirectory) to avoid naming conflicts.
*
* @return htmlElement meta HTML object
*
* @see baseModule::get_metaData()
* @see htmlElement
*/
public function get_profileOptions() {
$return = parent::get_profileOptions();
$possibleParentNodes = $this->getPossibleParentNodes();
if (sizeof($possibleParentNodes) > 0) {
$return->addElement(new htmlTableExtendedSelect('puppetClient_parentnode', $possibleParentNodes, array(), _('Parent node'), 'parentnode'), true);
}
return $return;
}
/**
* Loads the values of an account profile into internal variables.
*
* @param array $profile hash array with profile values (identifier => value)
*/
function load_profile($profile) {
// profile mappings in meta data
parent::load_profile($profile);
// add extension
if (isset($profile['puppetClient_addExt'][0]) && ($profile['puppetClient_addExt'][0] == "true")) {
if (!in_array('puppetClient', $this->attributes['objectClass'])) {
$this->attributes['objectClass'][] = 'puppetClient';
}
}
// parent node
if (isset($profile['puppetClient_parentnode'][0]) && ($profile['puppetClient_parentnode'][0] != "-")) {
$this->attributes['parentnode'][0] = $profile['puppetClient_parentnode'][0];
}
// classes
if (isset($profile['puppetClient_puppetclass'][0]) && ($profile['puppetClient_puppetclass'][0] != '')) {
$this->attributes['puppetclass'] = $profile['puppetClient_puppetclass'];
}
// variables
if (isset($profile['puppetClient_puppetvar'][0]) && ($profile['puppetClient_puppetvar'][0] != '')) {
$this->attributes['puppetvar'] = $profile['puppetClient_puppetvar'];
}
}
/**
* Reurns a list of valid parent nodes for this node.
*
* @return array parent nodes (e.g. array('node1', 'node2'))
*/
private function getPossibleParentNodes() {
$possibleParentNodes = array();
$searchResult = searchLDAPByAttribute('cn', '*', 'puppetClient', array('cn'), array('host'));
$possibleParentNodes = array();
for ($i = 0; $i < sizeof($searchResult); $i++) {
if (!get_preg($searchResult[$i]['cn'][0], 'ascii')) {
continue;
}
if (($this->getAccountContainer() == null) || $this->getAccountContainer()->isNewAccount
|| (!isset($this->getAccountContainer()->attributes_orig['cn'][0])
|| ($this->getAccountContainer()->attributes_orig['cn'][0] != $searchResult[$i]['cn'][0]))) {
$possibleParentNodes[] = $searchResult[$i]['cn'][0];
}
}
return $possibleParentNodes;
}
}
?>