added typeId for profile methods
This commit is contained in:
		
							parent
							
								
									ef1eec558a
								
							
						
					
					
						commit
						3a3c88ba4b
					
				|  | @ -19,6 +19,7 @@ | |||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|  | @ -53,6 +54,9 @@ This is a list of API changes for all LAM releases. | |||
| <h2>5.7 -> 5.8</h2> | ||||
| <ul> | ||||
|   <li>All account types allow multiple configurations by default.</li> | ||||
|   <li>check_profileOptions()/get_profileOptions() has new parameter $typeId<br> | ||||
|   </li> | ||||
| 
 | ||||
| </ul> | ||||
| <br> | ||||
| <h2>5.6 -> 5.7</h2> | ||||
|  |  | |||
|  | @ -502,12 +502,13 @@ abstract class baseModule { | |||
| 	* and save profiles. We recommend to use the module name as prefix for them | ||||
| 	* (e.g. posixAccount_homeDirectory) to avoid naming conflicts. | ||||
| 	* | ||||
| 	* @param string $typeId type id (user, group, host, ...) | ||||
| 	* @return htmlElement meta HTML object | ||||
| 	* | ||||
| 	* @see baseModule::get_metaData() | ||||
| 	* @see htmlElement | ||||
| 	*/ | ||||
| 	public function get_profileOptions() { | ||||
| 	public function get_profileOptions($typeId) { | ||||
| 		if (isset($this->meta['profile_options'])) return $this->meta['profile_options']; | ||||
| 		else return array(); | ||||
| 	} | ||||
|  | @ -524,11 +525,12 @@ abstract class baseModule { | |||
| 	* the function returns an empty array. | ||||
| 	* | ||||
| 	* @param array $options a hash array (name => value) containing the user input | ||||
| 	* @param string $typeId type id (user, group, host) | ||||
| 	* @return array list of error messages (array(type, title, text)) to generate StatusMessages, if any | ||||
| 	* | ||||
| 	* @see baseModule::get_metaData() | ||||
| 	*/ | ||||
| 	public function check_profileOptions($options) { | ||||
| 	public function check_profileOptions($options, $typeId) { | ||||
| 		$messages = array(); | ||||
| 		if (isset($this->meta['profile_checks'])) { | ||||
| 			$identifiers = array_keys($this->meta['profile_checks']); | ||||
|  |  | |||
|  | @ -316,7 +316,7 @@ function getProfileOptions($typeId) { | |||
| 	$return = array(); | ||||
| 	for ($i = 0; $i < sizeof($mods); $i++) { | ||||
| 		$module = moduleCache::getModule($mods[$i], $type->getScope()); | ||||
| 		$return[$mods[$i]] = $module->get_profileOptions(); | ||||
| 		$return[$mods[$i]] = $module->get_profileOptions($typeId); | ||||
| 	} | ||||
| 	return $return; | ||||
| } | ||||
|  | @ -324,16 +324,18 @@ function getProfileOptions($typeId) { | |||
| /** | ||||
| * Checks if the profile options are valid | ||||
| * | ||||
| * @param string $scope account type (user, group, host) | ||||
| * @param string $typeId account type (user, group, host) | ||||
| * @param array $options hash array containing all options (name => array(...)) | ||||
| * @return array list of error messages | ||||
| */ | ||||
| function checkProfileOptions($scope, $options) { | ||||
| 	$mods = $_SESSION['config']->get_AccountModules($scope); | ||||
| function checkProfileOptions($typeId, $options) { | ||||
| 	$typeManager = new TypeManager(); | ||||
| 	$type = $typeManager->getConfiguredType($typeId); | ||||
| 	$mods = $type->getModules(); | ||||
| 	$return = array(); | ||||
| 	for ($i = 0; $i < sizeof($mods); $i++) { | ||||
| 		$module = moduleCache::getModule($mods[$i], $scope); | ||||
| 		$temp = $module->check_profileOptions($options); | ||||
| 		$module = moduleCache::getModule($mods[$i], $type->getScope()); | ||||
| 		$temp = $module->check_profileOptions($options, $type->getId()); | ||||
| 		$return = array_merge($return, $temp); | ||||
| 	} | ||||
| 	return $return; | ||||
|  |  | |||
|  | @ -3,7 +3,7 @@ | |||
| $Id$ | ||||
| 
 | ||||
|   This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) | ||||
|   Copyright (C) 2011 - 2016  Roland Gruber | ||||
|   Copyright (C) 2011 - 2017  Roland Gruber | ||||
| 
 | ||||
|   This program is free software; you can redistribute it and/or modify | ||||
|   it under the terms of the GNU General Public License as published by | ||||
|  | @ -710,13 +710,10 @@ class freeRadius extends baseModule { | |||
| 	} | ||||
| 
 | ||||
| 	/** | ||||
| 	* Checks input values of account profiles. | ||||
| 	* | ||||
| 	* @param array $options a hash array (name => value) containing the options | ||||
| 	* @return array list of error messages (array(type, title, text)) to generate StatusMessages, if any | ||||
| 	* {@inheritDoc} | ||||
| 	*/ | ||||
| 	function check_profileOptions($options) { | ||||
| 		$messages = parent::check_profileOptions($options); | ||||
| 	function check_profileOptions($options, $typeId) { | ||||
| 		$messages = parent::check_profileOptions($options, $typeId); | ||||
| 		// group names
 | ||||
| 		if (!$this->isBooleanConfigOptionSet('freeRadius_hideRadiusGroupName')) { | ||||
| 			if (isset($options['freeRadius_radiusGroupName'][0]) && ($options['freeRadius_radiusGroupName'][0] != '')) { | ||||
|  |  | |||
|  | @ -2080,13 +2080,10 @@ class inetOrgPerson extends baseModule implements passwordService { | |||
| 	} | ||||
| 
 | ||||
| 	/** | ||||
| 	* Checks input values of account profiles. | ||||
| 	* | ||||
| 	* @param array $options a hash array (name => value) containing the options | ||||
| 	* @return array list of error messages (array(type, title, text)) to generate StatusMessages, if any | ||||
| 	* {@inheritDoc} | ||||
| 	*/ | ||||
| 	function check_profileOptions($options) { | ||||
| 		$messages = parent::check_profileOptions($options); | ||||
| 	function check_profileOptions($options, $typeId) { | ||||
| 		$messages = parent::check_profileOptions($options, $typeId); | ||||
| 		if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideTelephoneNumber')) { | ||||
| 			$telephoneNumberList = preg_split('/;[ ]*/', $options['inetOrgPerson_telephoneNumber'][0]); | ||||
| 			for ($i = 0; $i < sizeof($telephoneNumberList); $i++) { | ||||
|  |  | |||
|  | @ -206,11 +206,9 @@ class nisNetGroupHost extends nisNetGroupUser { | |||
| 	} | ||||
| 
 | ||||
| 	/** | ||||
| 	* Returns a list of elements for the account profiles. | ||||
| 	* | ||||
| 	* @return profile elements | ||||
| 	* {@inheritDoc} | ||||
| 	*/ | ||||
| 	function get_profileOptions() { | ||||
| 	function get_profileOptions($typeId) { | ||||
| 		$groups = $this->findGroups(); | ||||
| 		$groupOptions = array('' => ''); | ||||
| 		foreach ($groups as $group) { | ||||
|  |  | |||
|  | @ -424,11 +424,9 @@ class nisNetGroupUser extends baseModule { | |||
| 	} | ||||
| 
 | ||||
| 	/** | ||||
| 	* Returns a list of elements for the account profiles. | ||||
| 	* | ||||
| 	* @return profile elements | ||||
| 	* {@inheritDoc} | ||||
| 	*/ | ||||
| 	function get_profileOptions() { | ||||
| 	function get_profileOptions($typeId) { | ||||
| 		$groups = $this->findGroups(); | ||||
| 		$groupOptions = array('' => ''); | ||||
| 		foreach ($groups as $group) { | ||||
|  |  | |||
|  | @ -1701,11 +1701,9 @@ class posixAccount extends baseModule implements passwordService { | |||
| 	} | ||||
| 
 | ||||
| 	/** | ||||
| 	* Returns a list of elements for the account profiles. | ||||
| 	* | ||||
| 	* @return profile elements | ||||
| 	* {@inheritDoc} | ||||
| 	*/ | ||||
| 	function get_profileOptions() { | ||||
| 	function get_profileOptions($typeId) { | ||||
| 		$return = new htmlTable(); | ||||
| 		$groupList = $this->findGroups(); | ||||
| 		$groups = array(); | ||||
|  |  | |||
|  | @ -430,22 +430,10 @@ class puppetClient extends baseModule { | |||
| 	} | ||||
| 
 | ||||
| 	/** | ||||
| 	* 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}.<br> | ||||
| 	* <br> | ||||
| 	* The return value is an object implementing htmlElement.<br> | ||||
| 	* 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 | ||||
| 	* {@inheritDoc} | ||||
| 	*/ | ||||
| 	public function get_profileOptions() { | ||||
| 		$return = parent::get_profileOptions(); | ||||
| 	public function get_profileOptions($typeId) { | ||||
| 		$return = parent::get_profileOptions($typeId); | ||||
| 		$possibleParentNodes = $this->getPossibleParentNodes(); | ||||
| 		array_unshift($possibleParentNodes, '-'); | ||||
| 		$possibleParentNodes = array_values($possibleParentNodes); | ||||
|  |  | |||
|  | @ -467,11 +467,9 @@ class quota extends baseModule { | |||
| 	} | ||||
| 
 | ||||
| 	/** | ||||
| 	* Returns a list of elements for the account profiles. | ||||
| 	* | ||||
| 	* @return htmlElement profile elements | ||||
| 	* {@inheritDoc} | ||||
| 	*/ | ||||
| 	function get_profileOptions() { | ||||
| 	function get_profileOptions($typeId) { | ||||
| 		$return = new htmlTable(); | ||||
| 		$optionsAvailable = false; | ||||
| 		// get list of lamdaemon servers
 | ||||
|  | @ -547,12 +545,9 @@ class quota extends baseModule { | |||
| 	} | ||||
| 
 | ||||
| 	/** | ||||
| 	* Checks input values of account profiles. | ||||
| 	* | ||||
| 	* @param array $options a hash array (name => value) containing the options | ||||
| 	* @return array list of error messages (array(type, title, text)) to generate StatusMessages, if any | ||||
| 	* {@inheritDoc} | ||||
| 	*/ | ||||
| 	function check_profileOptions($options) { | ||||
| 	function check_profileOptions($options, $typeId) { | ||||
| 		$return = array(); | ||||
| 		// get list of lamdaemon servers
 | ||||
| 		$lamdaemonServers = explode(";", $_SESSION['config']->get_scriptServers()); | ||||
|  |  | |||
|  | @ -561,11 +561,9 @@ class sambaGroupMapping extends baseModule { | |||
| 
 | ||||
| 
 | ||||
| 	/** | ||||
| 	* Returns a list of elements for the account profiles. | ||||
| 	* | ||||
| 	* @return htmlElement profile elements | ||||
| 	* {@inheritDoc} | ||||
| 	*/ | ||||
| 	function get_profileOptions() { | ||||
| 	function get_profileOptions($typeId) { | ||||
| 		$return = new htmlTable(); | ||||
| 		// get list of domains
 | ||||
| 		$sambaDomains = $this->getDomains(); | ||||
|  |  | |||
|  | @ -4,7 +4,7 @@ $Id$ | |||
| 
 | ||||
|   This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) | ||||
|   Copyright (C) 2003 - 2006  Tilo Lutz | ||||
|                 2005 - 2016  Roland Gruber | ||||
|                 2005 - 2017  Roland Gruber | ||||
| 
 | ||||
|   This program is free software; you can redistribute it and/or modify | ||||
|   it under the terms of the GNU General Public License as published by | ||||
|  | @ -1663,12 +1663,10 @@ class sambaSamAccount extends baseModule implements passwordService { | |||
| 	} | ||||
| 
 | ||||
| 	/** | ||||
| 	* Returns a list of elements for the account profiles. | ||||
| 	* | ||||
| 	* @return htmlElement profile elements | ||||
| 	* {@inheritDoc} | ||||
| 	*/ | ||||
| 	function get_profileOptions() { | ||||
| 		$return = parent::get_profileOptions(); | ||||
| 	function get_profileOptions($typeId) { | ||||
| 		$return = parent::get_profileOptions($typeId); | ||||
| 		if ($this->get_scope() == 'user') { | ||||
| 			// lists for expiration date
 | ||||
| 			$day = array(); $mon = array(); $year = array(); | ||||
|  |  | |||
|  | @ -317,13 +317,10 @@ class systemQuotas extends baseModule { | |||
| 	} | ||||
| 
 | ||||
| 	/** | ||||
| 	* Checks input values of account profiles. | ||||
| 	* | ||||
| 	* @param array $options a hash array (name => value) containing the options | ||||
| 	* @return array list of error messages (array(type, title, text)) to generate StatusMessages, if any | ||||
| 	* {@inheritDoc} | ||||
| 	*/ | ||||
| 	function check_profileOptions($options) { | ||||
| 		$messages = parent::check_profileOptions($options); | ||||
| 	function check_profileOptions($options, $typeId) { | ||||
| 		$messages = parent::check_profileOptions($options, $typeId); | ||||
| 		$quotas = explode(';', $options['systemQuotas_quota'][0]); | ||||
| 		for ($q = 0; $q < sizeof($quotas); $q++) { | ||||
| 			if ($quotas[$q] == '') { | ||||
|  |  | |||
|  | @ -3,7 +3,7 @@ | |||
| $Id$ | ||||
| 
 | ||||
|   This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) | ||||
|   Copyright (C) 2013 - 2016  Roland Gruber | ||||
|   Copyright (C) 2013 - 2017  Roland Gruber | ||||
| 
 | ||||
|   This program is free software; you can redistribute it and/or modify | ||||
|   it under the terms of the GNU General Public License as published by | ||||
|  | @ -2500,12 +2500,10 @@ class windowsUser extends baseModule implements passwordService { | |||
| 	} | ||||
| 
 | ||||
| 	/** | ||||
| 	* Returns a list of elements for the account profiles. | ||||
| 	* | ||||
| 	* @return htmlElement profile elements | ||||
| 	* {@inheritDoc} | ||||
| 	*/ | ||||
| 	function get_profileOptions() { | ||||
| 		$return = parent::get_profileOptions(); | ||||
| 	function get_profileOptions($typeId) { | ||||
| 		$return = parent::get_profileOptions($typeId); | ||||
| 		// domain
 | ||||
| 		$domains = $this->getDomains(); | ||||
| 		$domains[] = ''; | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue