new type API
This commit is contained in:
		
							parent
							
								
									9c9d8b3f09
								
							
						
					
					
						commit
						f60c37edcd
					
				| 
						 | 
					@ -1,10 +1,11 @@
 | 
				
			||||||
<?php
 | 
					<?php
 | 
				
			||||||
 | 
					use \LAM\TYPES\TypeManager;
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
$Id$
 | 
					$Id$
 | 
				
			||||||
 | 
					
 | 
				
			||||||
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
 | 
					This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
 | 
				
			||||||
Copyright (C) 2003 - 2006  Tilo Lutz
 | 
					Copyright (C) 2003 - 2006  Tilo Lutz
 | 
				
			||||||
              2007 - 2016  Roland Gruber
 | 
					              2007 - 2017  Roland Gruber
 | 
				
			||||||
 | 
					
 | 
				
			||||||
This program is free software; you can redistribute it and/or modify
 | 
					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
 | 
					it under the terms of the GNU General Public License as published by
 | 
				
			||||||
| 
						 | 
					@ -41,10 +42,6 @@ class posixGroup extends baseModule implements passwordService {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/** change GIDs of users and hosts? */
 | 
						/** change GIDs of users and hosts? */
 | 
				
			||||||
	private $changegids;
 | 
						private $changegids;
 | 
				
			||||||
	/** specifies if the cn attribute should be managed by this module */
 | 
					 | 
				
			||||||
	protected $manageCnAttribute = true;
 | 
					 | 
				
			||||||
	/** specifies if the description attribute should be managed by this module */
 | 
					 | 
				
			||||||
	protected $manageDescriptionAttribute = true;
 | 
					 | 
				
			||||||
	/** password attribute */
 | 
						/** password attribute */
 | 
				
			||||||
	protected $passwordAttrName = 'userPassword';
 | 
						protected $passwordAttrName = 'userPassword';
 | 
				
			||||||
	/** cache for existing GID numbers */
 | 
						/** cache for existing GID numbers */
 | 
				
			||||||
| 
						 | 
					@ -54,6 +51,35 @@ class posixGroup extends baseModule implements passwordService {
 | 
				
			||||||
	/** cache for existing groups */
 | 
						/** cache for existing groups */
 | 
				
			||||||
	private $cachedGroupNameList = null;
 | 
						private $cachedGroupNameList = null;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * {@inheritDoc}
 | 
				
			||||||
 | 
						 * @see baseModule::getManagedAttributes()
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						function get_uploadColumns($selectedModules) {
 | 
				
			||||||
 | 
							$return = parent::get_uploadColumns($selectedModules);
 | 
				
			||||||
 | 
							if ($this->manageCnAndDescription($selectedModules)) {
 | 
				
			||||||
 | 
								array_unshift($return,
 | 
				
			||||||
 | 
									array(
 | 
				
			||||||
 | 
										'name' => 'posixGroup_cn',
 | 
				
			||||||
 | 
										'description' => _('Group name'),
 | 
				
			||||||
 | 
										'help' => 'cn',
 | 
				
			||||||
 | 
										'example' => _('adminstrators'),
 | 
				
			||||||
 | 
										'required' => true,
 | 
				
			||||||
 | 
										'unique' => true
 | 
				
			||||||
 | 
									)
 | 
				
			||||||
 | 
								);
 | 
				
			||||||
 | 
								array_unshift($return,
 | 
				
			||||||
 | 
									array(
 | 
				
			||||||
 | 
									'name' => 'posixGroup_description',
 | 
				
			||||||
 | 
									'description' => _('Group description'),
 | 
				
			||||||
 | 
									'help' => 'description',
 | 
				
			||||||
 | 
									'example' => _('Administrators group')
 | 
				
			||||||
 | 
									)
 | 
				
			||||||
 | 
								);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							return $return;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/**
 | 
						/**
 | 
				
			||||||
	* In this function the LDAP account is built up.
 | 
						* In this function the LDAP account is built up.
 | 
				
			||||||
	*
 | 
						*
 | 
				
			||||||
| 
						 | 
					@ -68,7 +94,7 @@ class posixGroup extends baseModule implements passwordService {
 | 
				
			||||||
		$needAutoGID = array();
 | 
							$needAutoGID = array();
 | 
				
			||||||
		for ($i = 0; $i < sizeof($rawAccounts); $i++) {
 | 
							for ($i = 0; $i < sizeof($rawAccounts); $i++) {
 | 
				
			||||||
			if (!in_array("posixGroup", $partialAccounts[$i]['objectClass'])) $partialAccounts[$i]['objectClass'][] = "posixGroup";
 | 
								if (!in_array("posixGroup", $partialAccounts[$i]['objectClass'])) $partialAccounts[$i]['objectClass'][] = "posixGroup";
 | 
				
			||||||
			if ($this->manageCnAttribute) {
 | 
								if ($this->manageCnAndDescription($selectedModules)) {
 | 
				
			||||||
				// group name
 | 
									// group name
 | 
				
			||||||
				$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'posixGroup_cn', 'cn', 'groupname', $this->messages['cn'][3], $error_messages);
 | 
									$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'posixGroup_cn', 'cn', 'groupname', $this->messages['cn'][3], $error_messages);
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
| 
						 | 
					@ -85,7 +111,7 @@ class posixGroup extends baseModule implements passwordService {
 | 
				
			||||||
				array_push($errMsg, array($i));
 | 
									array_push($errMsg, array($i));
 | 
				
			||||||
				$error_messages[] = $errMsg;
 | 
									$error_messages[] = $errMsg;
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			if ($this->manageDescriptionAttribute) {
 | 
								if ($this->manageCnAndDescription($selectedModules)) {
 | 
				
			||||||
				// description (UTF-8, no regex check needed)
 | 
									// description (UTF-8, no regex check needed)
 | 
				
			||||||
				if ($rawAccounts[$i][$ids['posixGroup_description']] == "") {
 | 
									if ($rawAccounts[$i][$ids['posixGroup_description']] == "") {
 | 
				
			||||||
					$partialAccounts[$i]['description'] = $partialAccounts[$i]['cn'];
 | 
										$partialAccounts[$i]['description'] = $partialAccounts[$i]['cn'];
 | 
				
			||||||
| 
						 | 
					@ -164,13 +190,14 @@ class posixGroup extends baseModule implements passwordService {
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	function display_html_attributes() {
 | 
						function display_html_attributes() {
 | 
				
			||||||
		$return = new htmlTable();
 | 
							$return = new htmlTable();
 | 
				
			||||||
 | 
							$modules = $this->getAccountContainer()->get_type()->getModules();
 | 
				
			||||||
		if ($this->autoAddObjectClasses || (isset($this->attributes['objectClass']) && in_array('posixGroup', $this->attributes['objectClass']))) {
 | 
							if ($this->autoAddObjectClasses || (isset($this->attributes['objectClass']) && in_array('posixGroup', $this->attributes['objectClass']))) {
 | 
				
			||||||
			// auto sync group members
 | 
								// auto sync group members
 | 
				
			||||||
			if ($this->isBooleanConfigOptionSet('posixGroup_autoSyncGon')) {
 | 
								if ($this->isBooleanConfigOptionSet('posixGroup_autoSyncGon')) {
 | 
				
			||||||
				$this->syncGon();
 | 
									$this->syncGon();
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			// group name
 | 
								// group name
 | 
				
			||||||
			if ($this->manageCnAttribute) {
 | 
								if ($this->manageCnAndDescription($modules)) {
 | 
				
			||||||
				$cn = '';
 | 
									$cn = '';
 | 
				
			||||||
				if (isset($this->attributes['cn'][0])) {
 | 
									if (isset($this->attributes['cn'][0])) {
 | 
				
			||||||
					$cn = $this->attributes['cn'][0];
 | 
										$cn = $this->attributes['cn'][0];
 | 
				
			||||||
| 
						 | 
					@ -194,7 +221,7 @@ class posixGroup extends baseModule implements passwordService {
 | 
				
			||||||
			if (isset($this->attributes['description'][0])) {
 | 
								if (isset($this->attributes['description'][0])) {
 | 
				
			||||||
				$description = $this->attributes['description'][0];
 | 
									$description = $this->attributes['description'][0];
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			if ($this->manageDescriptionAttribute) {
 | 
								if ($this->manageCnAndDescription($modules)) {
 | 
				
			||||||
				$return->addElement(new htmlTableExtendedInputField(_('Description'), 'description', $description, 'description'), true);
 | 
									$return->addElement(new htmlTableExtendedInputField(_('Description'), 'description', $description, 'description'), true);
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			// password buttons
 | 
								// password buttons
 | 
				
			||||||
| 
						 | 
					@ -399,12 +426,6 @@ class posixGroup extends baseModule implements passwordService {
 | 
				
			||||||
		if (!$this->isBooleanConfigOptionSet('posixGroup_hidememberUid')) {
 | 
							if (!$this->isBooleanConfigOptionSet('posixGroup_hidememberUid')) {
 | 
				
			||||||
			$return['attributes'][] = 'memberUid';
 | 
								$return['attributes'][] = 'memberUid';
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		if ($this->manageCnAttribute) {
 | 
					 | 
				
			||||||
			$return['attributes'][] = 'cn';
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		if ($this->manageDescriptionAttribute) {
 | 
					 | 
				
			||||||
			$return['attributes'][] = 'description';
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		// profile options
 | 
							// profile options
 | 
				
			||||||
		if (!$this->autoAddObjectClasses) {
 | 
							if (!$this->autoAddObjectClasses) {
 | 
				
			||||||
			$profileContainer = new htmlTable();
 | 
								$profileContainer = new htmlTable();
 | 
				
			||||||
| 
						 | 
					@ -419,12 +440,6 @@ class posixGroup extends baseModule implements passwordService {
 | 
				
			||||||
			$return['PDF_fields']['memberUid'] = _('Group members');
 | 
								$return['PDF_fields']['memberUid'] = _('Group members');
 | 
				
			||||||
			$return['PDF_fields']['memberUidPrimary'] = _('Group members (incl. primary members)');
 | 
								$return['PDF_fields']['memberUidPrimary'] = _('Group members (incl. primary members)');
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		if ($this->manageCnAttribute) {
 | 
					 | 
				
			||||||
			$return['PDF_fields']['cn'] = _('Group name');
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		if ($this->manageDescriptionAttribute) {
 | 
					 | 
				
			||||||
			$return['PDF_fields']['description'] = _('Description');
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		// upload fields
 | 
							// upload fields
 | 
				
			||||||
		$return['upload_columns'] = array(
 | 
							$return['upload_columns'] = array(
 | 
				
			||||||
		array(
 | 
							array(
 | 
				
			||||||
| 
						 | 
					@ -448,28 +463,6 @@ class posixGroup extends baseModule implements passwordService {
 | 
				
			||||||
				'example' => _('user01,user02,user03')
 | 
									'example' => _('user01,user02,user03')
 | 
				
			||||||
			);
 | 
								);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		if ($this->manageCnAttribute) {
 | 
					 | 
				
			||||||
			array_unshift($return['upload_columns'],
 | 
					 | 
				
			||||||
				array(
 | 
					 | 
				
			||||||
					'name' => 'posixGroup_cn',
 | 
					 | 
				
			||||||
					'description' => _('Group name'),
 | 
					 | 
				
			||||||
					'help' => 'cn',
 | 
					 | 
				
			||||||
					'example' => _('adminstrators'),
 | 
					 | 
				
			||||||
					'required' => true,
 | 
					 | 
				
			||||||
					'unique' => true
 | 
					 | 
				
			||||||
				)
 | 
					 | 
				
			||||||
			);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		if ($this->manageDescriptionAttribute) {
 | 
					 | 
				
			||||||
			array_unshift($return['upload_columns'],
 | 
					 | 
				
			||||||
				array(
 | 
					 | 
				
			||||||
				'name' => 'posixGroup_description',
 | 
					 | 
				
			||||||
				'description' => _('Group description'),
 | 
					 | 
				
			||||||
				'help' => 'description',
 | 
					 | 
				
			||||||
				'example' => _('Administrators group')
 | 
					 | 
				
			||||||
				)
 | 
					 | 
				
			||||||
			);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		// help Entries
 | 
							// help Entries
 | 
				
			||||||
		$return['help'] = array(
 | 
							$return['help'] = array(
 | 
				
			||||||
			'gidNumber'	=> array(
 | 
								'gidNumber'	=> array(
 | 
				
			||||||
| 
						 | 
					@ -612,6 +605,21 @@ class posixGroup extends baseModule implements passwordService {
 | 
				
			||||||
		return $configContainer;
 | 
							return $configContainer;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * {@inheritDoc}
 | 
				
			||||||
 | 
						 * @see baseModule::get_pdfFields()
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						public function get_pdfFields($typeId) {
 | 
				
			||||||
 | 
							$fields = parent::get_pdfFields($typeId);
 | 
				
			||||||
 | 
							$typeManager = new TypeManager();
 | 
				
			||||||
 | 
							$modules = $typeManager->getConfiguredType($typeId)->getModules();
 | 
				
			||||||
 | 
							if ($this->manageCnAndDescription($modules)) {
 | 
				
			||||||
 | 
								$fields['cn'] = _('Group name');
 | 
				
			||||||
 | 
								$fields['description'] = _('Description');
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							return $fields;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/**
 | 
						/**
 | 
				
			||||||
	 * {@inheritDoc}
 | 
						 * {@inheritDoc}
 | 
				
			||||||
	 * @see baseModule::get_pdfEntries()
 | 
						 * @see baseModule::get_pdfEntries()
 | 
				
			||||||
| 
						 | 
					@ -673,6 +681,21 @@ class posixGroup extends baseModule implements passwordService {
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * {@inheritDoc}
 | 
				
			||||||
 | 
						 * @see baseModule::getManagedAttributes()
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						public function getManagedAttributes($typeId) {
 | 
				
			||||||
 | 
							$attrs = parent::getManagedAttributes($typeId);
 | 
				
			||||||
 | 
							$typeManager = new TypeManager();
 | 
				
			||||||
 | 
							$modules = $typeManager->getConfiguredType($typeId)->getModules();
 | 
				
			||||||
 | 
							if ($this->manageCnAndDescription($modules)) {
 | 
				
			||||||
 | 
								$attrs[] = 'cn';
 | 
				
			||||||
 | 
								$attrs[] = 'description';
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							return $attrs;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/**
 | 
						/**
 | 
				
			||||||
	* This functions is used to check if all settings for this module have been made.
 | 
						* This functions is used to check if all settings for this module have been made.
 | 
				
			||||||
	*
 | 
						*
 | 
				
			||||||
| 
						 | 
					@ -686,8 +709,13 @@ class posixGroup extends baseModule implements passwordService {
 | 
				
			||||||
				return true;
 | 
									return true;
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		if ($this->manageCnAttribute && ($this->attributes['cn'][0] == '')) return false;
 | 
							$modules = $this->getAccountContainer()->get_type()->getModules();
 | 
				
			||||||
		if ($this->attributes['gidNumber'][0] == '') return false;
 | 
							if ($this->manageCnAndDescription($modules) && ($this->attributes['cn'][0] == '')) {
 | 
				
			||||||
 | 
								return false;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							if ($this->attributes['gidNumber'][0] == '') {
 | 
				
			||||||
 | 
								return false;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
		return true;
 | 
							return true;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -736,11 +764,12 @@ class posixGroup extends baseModule implements passwordService {
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			return $errors;
 | 
								return $errors;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
							$modules = $this->getAccountContainer()->get_type()->getModules();
 | 
				
			||||||
		// skip processing if object class is not set
 | 
							// skip processing if object class is not set
 | 
				
			||||||
		if (!$this->autoAddObjectClasses && (!isset($this->attributes['objectClass']) || !in_array('posixGroup', $this->attributes['objectClass']))) {
 | 
							if (!$this->autoAddObjectClasses && (!isset($this->attributes['objectClass']) || !in_array('posixGroup', $this->attributes['objectClass']))) {
 | 
				
			||||||
			return $errors;
 | 
								return $errors;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		if ($this->manageDescriptionAttribute) {
 | 
							if ($this->manageCnAndDescription($modules)) {
 | 
				
			||||||
			$this->attributes['description'][0] = $_POST['description'];
 | 
								$this->attributes['description'][0] = $_POST['description'];
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		if (isset($_POST['lockPassword'])) {
 | 
							if (isset($_POST['lockPassword'])) {
 | 
				
			||||||
| 
						 | 
					@ -802,7 +831,7 @@ class posixGroup extends baseModule implements passwordService {
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		if ($this->manageCnAttribute) {
 | 
							if ($this->manageCnAndDescription($modules)) {
 | 
				
			||||||
			$this->attributes['cn'][0] = $_POST['cn'];
 | 
								$this->attributes['cn'][0] = $_POST['cn'];
 | 
				
			||||||
			if (preg_match('/^[A-Z]+$/', $_POST['cn'])) {
 | 
								if (preg_match('/^[A-Z]+$/', $_POST['cn'])) {
 | 
				
			||||||
				$errors[] = $this->messages['cn'][0];
 | 
									$errors[] = $this->messages['cn'][0];
 | 
				
			||||||
| 
						 | 
					@ -1310,6 +1339,16 @@ class posixGroup extends baseModule implements passwordService {
 | 
				
			||||||
		return false;
 | 
							return false;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * Returns if cn and description attributes should be managed.
 | 
				
			||||||
 | 
						 *
 | 
				
			||||||
 | 
						 * @param string[] $modules modules
 | 
				
			||||||
 | 
						 * @return boolean manage cn+description
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						protected function manageCnAndDescription($modules) {
 | 
				
			||||||
 | 
							return true;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
?>
 | 
					?>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2,6 +2,7 @@
 | 
				
			||||||
use \LAM\PDF\PDFTable;
 | 
					use \LAM\PDF\PDFTable;
 | 
				
			||||||
use \LAM\PDF\PDFTableCell;
 | 
					use \LAM\PDF\PDFTableCell;
 | 
				
			||||||
use \LAM\PDF\PDFTableRow;
 | 
					use \LAM\PDF\PDFTableRow;
 | 
				
			||||||
 | 
					use \LAM\TYPES\TypeManager;
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
$Id$
 | 
					$Id$
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -205,32 +206,6 @@ class pykotaUser extends baseModule {
 | 
				
			||||||
				'required' => true,
 | 
									'required' => true,
 | 
				
			||||||
			);
 | 
								);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		if ($this->manageUid()) {
 | 
					 | 
				
			||||||
			$return['upload_columns'][] = array(
 | 
					 | 
				
			||||||
				'name' => 'pykotaUser_uid',
 | 
					 | 
				
			||||||
				'description' => _('User name'),
 | 
					 | 
				
			||||||
				'help' => 'uid',
 | 
					 | 
				
			||||||
				'example' => _('smiller'),
 | 
					 | 
				
			||||||
				'required' => true,
 | 
					 | 
				
			||||||
				'unique' => true,
 | 
					 | 
				
			||||||
			);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		if ($this->manageMail()) {
 | 
					 | 
				
			||||||
			$return['upload_columns'][] = array(
 | 
					 | 
				
			||||||
				'name' => 'pykotaUser_mail',
 | 
					 | 
				
			||||||
				'description' => _('Email address'),
 | 
					 | 
				
			||||||
				'help' => 'mail',
 | 
					 | 
				
			||||||
				'example' => _('user@company.com'),
 | 
					 | 
				
			||||||
			);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		if ($this->manageDescription()) {
 | 
					 | 
				
			||||||
			$return['upload_columns'][] = array(
 | 
					 | 
				
			||||||
				'name' => 'pykotaUser_description',
 | 
					 | 
				
			||||||
				'description' => _('Description'),
 | 
					 | 
				
			||||||
				'help' => 'description',
 | 
					 | 
				
			||||||
				'example' => _('Temp, contract till December'),
 | 
					 | 
				
			||||||
			);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		$return['upload_columns'][] = array(
 | 
							$return['upload_columns'][] = array(
 | 
				
			||||||
			'name' => 'pykotaUser_pykotaLimitBy',
 | 
								'name' => 'pykotaUser_pykotaLimitBy',
 | 
				
			||||||
			'description' => _('Limit type'),
 | 
								'description' => _('Limit type'),
 | 
				
			||||||
| 
						 | 
					@ -267,18 +242,9 @@ class pykotaUser extends baseModule {
 | 
				
			||||||
			'pykotaLifeTimePaid' => _('Total paid'),
 | 
								'pykotaLifeTimePaid' => _('Total paid'),
 | 
				
			||||||
			'pykotaPayments' => _('Payment history'),
 | 
								'pykotaPayments' => _('Payment history'),
 | 
				
			||||||
		);
 | 
							);
 | 
				
			||||||
		if ($this->manageUid()) {
 | 
					 | 
				
			||||||
			$return['PDF_fields']['uid'] = _('User name');
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		if ($this->isStructural()) {
 | 
							if ($this->isStructural()) {
 | 
				
			||||||
			$return['PDF_fields']['cn'] = _('Common name');
 | 
								$return['PDF_fields']['cn'] = _('Common name');
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		if ($this->manageMail()) {
 | 
					 | 
				
			||||||
			$return['PDF_fields']['mail'] = _('Email address');
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		if ($this->manageDescription()) {
 | 
					 | 
				
			||||||
			$return['PDF_fields']['description'] = _('Description');
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		// self service
 | 
							// self service
 | 
				
			||||||
		$return['selfServiceFieldSettings'] = array(
 | 
							$return['selfServiceFieldSettings'] = array(
 | 
				
			||||||
			'pykotaBalance' => _('Balance (read-only)'),
 | 
								'pykotaBalance' => _('Balance (read-only)'),
 | 
				
			||||||
| 
						 | 
					@ -337,9 +303,10 @@ class pykotaUser extends baseModule {
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	function display_html_attributes() {
 | 
						function display_html_attributes() {
 | 
				
			||||||
		$container = new htmlTable();
 | 
							$container = new htmlTable();
 | 
				
			||||||
 | 
							$modules = $this->getAccountContainer()->get_type()->getModules();
 | 
				
			||||||
		if ($this->isStructural() || (isset($this->attributes['objectClass']) && in_array('pykotaAccount', $this->attributes['objectClass']))) {
 | 
							if ($this->isStructural() || (isset($this->attributes['objectClass']) && in_array('pykotaAccount', $this->attributes['objectClass']))) {
 | 
				
			||||||
			// uid
 | 
								// uid
 | 
				
			||||||
			if ($this->manageUid()) {
 | 
								if ($this->manageUid($modules)) {
 | 
				
			||||||
				$this->addSimpleInputTextField($container, 'uid', _('User name'), true);
 | 
									$this->addSimpleInputTextField($container, 'uid', _('User name'), true);
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			else {
 | 
								else {
 | 
				
			||||||
| 
						 | 
					@ -408,11 +375,11 @@ class pykotaUser extends baseModule {
 | 
				
			||||||
				$this->addSimpleInputTextField($container, 'cn', _('Common name'), true);
 | 
									$this->addSimpleInputTextField($container, 'cn', _('Common name'), true);
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			// mail
 | 
								// mail
 | 
				
			||||||
			if ($this->manageMail()) {
 | 
								if ($this->manageMail($modules)) {
 | 
				
			||||||
				$this->addSimpleInputTextField($container, 'mail', _('Email address'));
 | 
									$this->addSimpleInputTextField($container, 'mail', _('Email address'));
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			// description
 | 
								// description
 | 
				
			||||||
			if ($this->manageDescription()) {
 | 
								if ($this->manageDescription($modules)) {
 | 
				
			||||||
				$this->addMultiValueInputTextField($container, 'description', _('Description'), false, null, true);
 | 
									$this->addMultiValueInputTextField($container, 'description', _('Description'), false, null, true);
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			// remove button
 | 
								// remove button
 | 
				
			||||||
| 
						 | 
					@ -453,16 +420,17 @@ class pykotaUser extends baseModule {
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			return $errors;
 | 
								return $errors;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
							$modules = $this->getAccountContainer()->get_type()->getModules();
 | 
				
			||||||
		if (isset($_POST['remObjectClass'])) {
 | 
							if (isset($_POST['remObjectClass'])) {
 | 
				
			||||||
			$this->attributes['objectClass'] = array_delete(array('pykotaAccount', 'pykotaAccountBalance'), $this->attributes['objectClass']);
 | 
								$this->attributes['objectClass'] = array_delete(array('pykotaAccount', 'pykotaAccountBalance'), $this->attributes['objectClass']);
 | 
				
			||||||
			$attrs = array('pykotaLimitBy', 'pykotaUserName');
 | 
								$attrs = array('pykotaLimitBy', 'pykotaUserName');
 | 
				
			||||||
			if ($this->manageDescription()) {
 | 
								if ($this->manageDescription($modules)) {
 | 
				
			||||||
				$attrs[] = 'description';
 | 
									$attrs[] = 'description';
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			if ($this->manageMail()) {
 | 
								if ($this->manageMail($modules)) {
 | 
				
			||||||
				$attrs[] = 'mail';
 | 
									$attrs[] = 'mail';
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			if ($this->manageUid()) {
 | 
								if ($this->manageUid($modules)) {
 | 
				
			||||||
				$attrs[] = 'uid';
 | 
									$attrs[] = 'uid';
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			foreach ($attrs as $name) {
 | 
								foreach ($attrs as $name) {
 | 
				
			||||||
| 
						 | 
					@ -477,7 +445,7 @@ class pykotaUser extends baseModule {
 | 
				
			||||||
			return $errors;
 | 
								return $errors;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		// uid
 | 
							// uid
 | 
				
			||||||
		if ($this->manageUid()) {
 | 
							if ($this->manageUid($modules)) {
 | 
				
			||||||
			if (isset($_POST['uid']) && ($_POST['uid'] != '')) {
 | 
								if (isset($_POST['uid']) && ($_POST['uid'] != '')) {
 | 
				
			||||||
				if (!get_preg($_POST['uid'], 'username')) {
 | 
									if (!get_preg($_POST['uid'], 'username')) {
 | 
				
			||||||
					$errors[] = $this->messages['uid'][0];
 | 
										$errors[] = $this->messages['uid'][0];
 | 
				
			||||||
| 
						 | 
					@ -520,14 +488,14 @@ class pykotaUser extends baseModule {
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		// mail
 | 
							// mail
 | 
				
			||||||
		if ($this->manageMail()) {
 | 
							if ($this->manageMail($modules)) {
 | 
				
			||||||
			$this->attributes['mail'][0] = $_POST['mail'];
 | 
								$this->attributes['mail'][0] = $_POST['mail'];
 | 
				
			||||||
			if (!empty($_POST['mail']) && !get_preg($_POST['mail'], 'email')) {
 | 
								if (!empty($_POST['mail']) && !get_preg($_POST['mail'], 'email')) {
 | 
				
			||||||
				$errors[] = $this->messages['mail'][0];
 | 
									$errors[] = $this->messages['mail'][0];
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		// description
 | 
							// description
 | 
				
			||||||
		if ($this->manageDescription()) {
 | 
							if ($this->manageDescription($modules)) {
 | 
				
			||||||
			$this->processMultiValueInputTextField('description', $errors);
 | 
								$this->processMultiValueInputTextField('description', $errors);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		// overcharge factor
 | 
							// overcharge factor
 | 
				
			||||||
| 
						 | 
					@ -761,6 +729,41 @@ class pykotaUser extends baseModule {
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * {@inheritDoc}
 | 
				
			||||||
 | 
						 * @see baseModule::getManagedAttributes()
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						function get_uploadColumns($selectedModules) {
 | 
				
			||||||
 | 
							$return = parent::get_uploadColumns($selectedModules);
 | 
				
			||||||
 | 
							if ($this->manageUid($selectedModules)) {
 | 
				
			||||||
 | 
								$return[] = array(
 | 
				
			||||||
 | 
									'name' => 'pykotaUser_uid',
 | 
				
			||||||
 | 
									'description' => _('User name'),
 | 
				
			||||||
 | 
									'help' => 'uid',
 | 
				
			||||||
 | 
									'example' => _('smiller'),
 | 
				
			||||||
 | 
									'required' => true,
 | 
				
			||||||
 | 
									'unique' => true,
 | 
				
			||||||
 | 
								);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							if ($this->manageMail($selectedModules)) {
 | 
				
			||||||
 | 
								$return[] = array(
 | 
				
			||||||
 | 
									'name' => 'pykotaUser_mail',
 | 
				
			||||||
 | 
									'description' => _('Email address'),
 | 
				
			||||||
 | 
									'help' => 'mail',
 | 
				
			||||||
 | 
									'example' => _('user@company.com'),
 | 
				
			||||||
 | 
								);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							if ($this->manageDescription($selectedModules)) {
 | 
				
			||||||
 | 
								$return[] = array(
 | 
				
			||||||
 | 
									'name' => 'pykotaUser_description',
 | 
				
			||||||
 | 
									'description' => _('Description'),
 | 
				
			||||||
 | 
									'help' => 'description',
 | 
				
			||||||
 | 
									'example' => _('Temp, contract till December'),
 | 
				
			||||||
 | 
								);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							return $return;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/**
 | 
						/**
 | 
				
			||||||
	* In this function the LDAP account is built up.
 | 
						* In this function the LDAP account is built up.
 | 
				
			||||||
	*
 | 
						*
 | 
				
			||||||
| 
						 | 
					@ -788,7 +791,7 @@ class pykotaUser extends baseModule {
 | 
				
			||||||
				$partialAccounts[$i]['cn'] = $rawAccounts[$i][$ids['pykotaUser_cn']];
 | 
									$partialAccounts[$i]['cn'] = $rawAccounts[$i][$ids['pykotaUser_cn']];
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			// uid
 | 
								// uid
 | 
				
			||||||
			if ($this->manageUid() && !empty($rawAccounts[$i][$ids['pykotaUser_uid']])) {
 | 
								if ($this->manageUid($selectedModules) && !empty($rawAccounts[$i][$ids['pykotaUser_uid']])) {
 | 
				
			||||||
				if (!get_preg($rawAccounts[$i][$ids['pykotaUser_uid']], 'username')) {
 | 
									if (!get_preg($rawAccounts[$i][$ids['pykotaUser_uid']], 'username')) {
 | 
				
			||||||
					$errMsg = $this->messages['uid'][1];
 | 
										$errMsg = $this->messages['uid'][1];
 | 
				
			||||||
					array_push($errMsg, array($i));
 | 
										array_push($errMsg, array($i));
 | 
				
			||||||
| 
						 | 
					@ -804,7 +807,7 @@ class pykotaUser extends baseModule {
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			// mail
 | 
								// mail
 | 
				
			||||||
			if ($this->manageUid() && !empty($rawAccounts[$i][$ids['pykotaUser_mail']])) {
 | 
								if ($this->manageUid($selectedModules) && !empty($rawAccounts[$i][$ids['pykotaUser_mail']])) {
 | 
				
			||||||
				$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'pykotaUser_mail', 'mail',
 | 
									$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'pykotaUser_mail', 'mail',
 | 
				
			||||||
					'email', $this->messages['mail'][1], $messages);
 | 
										'email', $this->messages['mail'][1], $messages);
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
| 
						 | 
					@ -883,6 +886,26 @@ class pykotaUser extends baseModule {
 | 
				
			||||||
		return $messages;
 | 
							return $messages;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * {@inheritDoc}
 | 
				
			||||||
 | 
						 * @see baseModule::get_pdfFields()
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						public function get_pdfFields($typeId) {
 | 
				
			||||||
 | 
							$fields = parent::get_pdfFields($typeId);
 | 
				
			||||||
 | 
							$typeManager = new TypeManager();
 | 
				
			||||||
 | 
							$modules = $typeManager->getConfiguredType($typeId)->getModules();
 | 
				
			||||||
 | 
							if ($this->manageUid($modules)) {
 | 
				
			||||||
 | 
								$fields['uid'] = _('User name');
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							if ($this->manageMail($modules)) {
 | 
				
			||||||
 | 
								$fields['mail'] = _('Email address');
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							if ($this->manageDescription($modules)) {
 | 
				
			||||||
 | 
								$fields['description'] = _('Description');
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							return $fields;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/**
 | 
						/**
 | 
				
			||||||
	 * {@inheritDoc}
 | 
						 * {@inheritDoc}
 | 
				
			||||||
	 * @see baseModule::get_pdfEntries()
 | 
						 * @see baseModule::get_pdfEntries()
 | 
				
			||||||
| 
						 | 
					@ -1044,56 +1067,47 @@ class pykotaUser extends baseModule {
 | 
				
			||||||
	/**
 | 
						/**
 | 
				
			||||||
	 * Returns if the uid attribute should be managed.
 | 
						 * Returns if the uid attribute should be managed.
 | 
				
			||||||
	 *
 | 
						 *
 | 
				
			||||||
 | 
						 * @param string[] $modules account modules
 | 
				
			||||||
	 * @return boolean manage uid attribute
 | 
						 * @return boolean manage uid attribute
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	private function manageUid() {
 | 
						private function manageUid($modules) {
 | 
				
			||||||
		if (isset($_SESSION['config'])) {
 | 
							if (in_array('inetOrgPerson', $modules)
 | 
				
			||||||
			$conf = $_SESSION['config'];
 | 
								|| in_array('posixAccount', $modules)) {
 | 
				
			||||||
			if (in_array('inetOrgPerson', $conf->get_AccountModules($this->get_scope()))
 | 
								return false;
 | 
				
			||||||
				|| in_array('posixAccount', $conf->get_AccountModules($this->get_scope()))) {
 | 
							}
 | 
				
			||||||
				return false;
 | 
							else {
 | 
				
			||||||
			}
 | 
								return true;
 | 
				
			||||||
			else {
 | 
					 | 
				
			||||||
				return true;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		return false;
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/**
 | 
						/**
 | 
				
			||||||
	 * Returns if the mail attribute should be managed.
 | 
						 * Returns if the mail attribute should be managed.
 | 
				
			||||||
	 *
 | 
						 *
 | 
				
			||||||
 | 
						 * @param string[] $modules account modules
 | 
				
			||||||
	 * @return boolean manage mail attribute
 | 
						 * @return boolean manage mail attribute
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	private function manageMail() {
 | 
						private function manageMail($modules) {
 | 
				
			||||||
		if (isset($_SESSION['config'])) {
 | 
							if (in_array('inetOrgPerson', $modules)) {
 | 
				
			||||||
			$conf = $_SESSION['config'];
 | 
								return false;
 | 
				
			||||||
			if (in_array('inetOrgPerson', $conf->get_AccountModules($this->get_scope()))) {
 | 
							}
 | 
				
			||||||
				return false;
 | 
							else {
 | 
				
			||||||
			}
 | 
								return true;
 | 
				
			||||||
			else {
 | 
					 | 
				
			||||||
				return true;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		return false;
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/**
 | 
						/**
 | 
				
			||||||
	 * Returns if the description attribute should be managed.
 | 
						 * Returns if the description attribute should be managed.
 | 
				
			||||||
	 *
 | 
						 *
 | 
				
			||||||
 | 
						 * @param string[] $modules account modules
 | 
				
			||||||
	 * @return boolean manage description attribute
 | 
						 * @return boolean manage description attribute
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	private function manageDescription() {
 | 
						private function manageDescription($modules) {
 | 
				
			||||||
		if (isset($_SESSION['config'])) {
 | 
							if (in_array('inetOrgPerson', $modules)) {
 | 
				
			||||||
			$conf = $_SESSION['config'];
 | 
								return false;
 | 
				
			||||||
			if (in_array('inetOrgPerson', $conf->get_AccountModules($this->get_scope()))) {
 | 
							}
 | 
				
			||||||
				return false;
 | 
							else {
 | 
				
			||||||
			}
 | 
								return true;
 | 
				
			||||||
			else {
 | 
					 | 
				
			||||||
				return true;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		return false;
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/**
 | 
						/**
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -3,7 +3,7 @@
 | 
				
			||||||
$Id$
 | 
					$Id$
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
 | 
					  This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
 | 
				
			||||||
  Copyright (C) 2013  Roland Gruber
 | 
					  Copyright (C) 2013 - 2017  Roland Gruber
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  This program is free software; you can redistribute it and/or modify
 | 
					  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
 | 
					  it under the terms of the GNU General Public License as published by
 | 
				
			||||||
| 
						 | 
					@ -43,9 +43,6 @@ class windowsPosixGroup extends posixGroup {
 | 
				
			||||||
	* @param string $scope account type (user, group, host)
 | 
						* @param string $scope account type (user, group, host)
 | 
				
			||||||
	*/
 | 
						*/
 | 
				
			||||||
	public function __construct($scope) {
 | 
						public function __construct($scope) {
 | 
				
			||||||
		// do not manage cn and description (managed by windowsGroup)
 | 
					 | 
				
			||||||
		$this->manageCnAttribute = false;
 | 
					 | 
				
			||||||
		$this->manageDescriptionAttribute = false;
 | 
					 | 
				
			||||||
		// different password attribute name
 | 
							// different password attribute name
 | 
				
			||||||
		$this->passwordAttrName = 'unixUserPassword';
 | 
							$this->passwordAttrName = 'unixUserPassword';
 | 
				
			||||||
		// make optional
 | 
							// make optional
 | 
				
			||||||
| 
						 | 
					@ -90,6 +87,14 @@ class windowsPosixGroup extends posixGroup {
 | 
				
			||||||
		return true;
 | 
							return true;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * {@inheritdoc}
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						protected function manageCnAndDescription($modules) {
 | 
				
			||||||
 | 
							// do not manage cn and description (managed by windowsGroup)
 | 
				
			||||||
 | 
							return false;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
?>
 | 
					?>
 | 
				
			||||||
		Loading…
	
		Reference in New Issue