use extended upload function

This commit is contained in:
Roland Gruber 2015-08-16 08:47:48 +00:00
parent b8f7d87864
commit 1f8d1445e8
6 changed files with 49 additions and 133 deletions

View File

@ -670,21 +670,7 @@ class kolabUser extends baseModule {
} }
} }
// add mail aliases // add mail aliases
if ($rawAccounts[$i][$ids['kolabUser_aliases']] != "") { $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'kolabUser_aliases', 'alias', 'email', $this->messages['alias'][1], $messages, '/,[ ]*/');
$aliases = explode(',', $rawAccounts[$i][$ids['kolabUser_aliases']]);
// check format
for ($a = 0; $a < sizeof($aliases); $a++) {
if (get_preg($aliases[$a], 'email')) {
$partialAccounts[$i]['alias'][] = $aliases[$a];
}
// invalid format
else {
$errMsg = $this->messages['alias'][1];
array_push($errMsg, array($i));
$messages[] = $errMsg;
}
}
}
// add delegates // add delegates
if ($rawAccounts[$i][$ids['kolabUser_delegates']] != "") { if ($rawAccounts[$i][$ids['kolabUser_delegates']] != "") {
$newDelegates = explode(',', $rawAccounts[$i][$ids['kolabUser_delegates']]); $newDelegates = explode(',', $rawAccounts[$i][$ids['kolabUser_delegates']]);
@ -702,35 +688,9 @@ class kolabUser extends baseModule {
} }
} }
// allowed recipients // allowed recipients
if (!empty($rawAccounts[$i][$ids['kolabUser_kolabAllowSMTPRecipient']])) { $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'kolabUser_kolabAllowSMTPRecipient', 'kolabAllowSMTPRecipient', 'kolabEmailPrefix', $this->messages['kolabAllowSMTPRecipient'][1], $messages, '/;[ ]*/');
$mails = preg_split('/;[ ]*/', $rawAccounts[$i][$ids['kolabUser_kolabAllowSMTPRecipient']]);
for ($m = 0; $m < sizeof($mails); $m++) {
if (get_preg($mails[$m], 'kolabEmailPrefix')) {
$partialAccounts[$i]['kolabAllowSMTPRecipient'][] = $mails[$m];
}
else {
$errMsg = $this->messages['kolabAllowSMTPRecipient'][1];
array_push($errMsg, array($i));
$messages[] = $errMsg;
break;
}
}
}
// allowed senders // allowed senders
if (!empty($rawAccounts[$i][$ids['kolabUser_kolabAllowSMTPSender']])) { $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'kolabUser_kolabAllowSMTPSender', 'kolabAllowSMTPSender', 'kolabEmailPrefix', $this->messages['kolabAllowSMTPSender'][1], $messages, '/;[ ]*/');
$mails = preg_split('/;[ ]*/', $rawAccounts[$i][$ids['kolabUser_kolabAllowSMTPSender']]);
for ($m = 0; $m < sizeof($mails); $m++) {
if (get_preg($mails[$m], 'kolabEmailPrefix')) {
$partialAccounts[$i]['kolabAllowSMTPSender'][] = $mails[$m];
}
else {
$errMsg = $this->messages['kolabAllowSMTPSender'][1];
array_push($errMsg, array($i));
$messages[] = $errMsg;
break;
}
}
}
} }
return $messages; return $messages;
} }

View File

@ -190,13 +190,7 @@ class ldapPublicKey extends baseModule {
// add object class // add object class
if (!in_array("ldapPublicKey", $partialAccounts[$i]['objectClass'])) $partialAccounts[$i]['objectClass'][] = "ldapPublicKey"; if (!in_array("ldapPublicKey", $partialAccounts[$i]['objectClass'])) $partialAccounts[$i]['objectClass'][] = "ldapPublicKey";
// add keys // add keys
if ($rawAccounts[$i][$ids['ldapPublicKey_sshPublicKey']] != "") { $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'ldapPublicKey_sshPublicKey', 'sshPublicKey', null, null, $messages, '/,[ ]*/');
$keys = explode(',', $rawAccounts[$i][$ids['ldapPublicKey_sshPublicKey']]);
// check format
for ($m = 0; $m < sizeof($keys); $m++) {
$partialAccounts[$i]['sshPublicKey'][] = $keys[$m];
}
}
} }
return $messages; return $messages;
} }

View File

@ -40,10 +40,10 @@ class nisMailAlias extends baseModule {
private $cachedUserList = null; private $cachedUserList = null;
/** display limit */ /** display limit */
const DISPLAY_LIMIT = 50; const DISPLAY_LIMIT = 50;
/** /**
* Returns true if this module can manage accounts of the current type, otherwise false. * Returns true if this module can manage accounts of the current type, otherwise false.
* *
* @return boolean true if module fits * @return boolean true if module fits
*/ */
public function can_manage() { public function can_manage() {
@ -54,7 +54,7 @@ class nisMailAlias extends baseModule {
* Returns meta data that is interpreted by parent class * Returns meta data that is interpreted by parent class
* *
* @return array array with meta data * @return array array with meta data
* *
* @see baseModule::get_metaData() * @see baseModule::get_metaData()
*/ */
function get_metaData() { function get_metaData() {
@ -150,7 +150,7 @@ class nisMailAlias extends baseModule {
/** /**
* Returns the HTML meta data for the main account page. * Returns the HTML meta data for the main account page.
* *
* @return htmlElement HTML meta data * @return htmlElement HTML meta data
*/ */
function display_html_attributes() { function display_html_attributes() {
@ -299,7 +299,7 @@ class nisMailAlias extends baseModule {
function display_html_selectMail() { function display_html_selectMail() {
return $this->display_html_select(true); return $this->display_html_select(true);
} }
/** /**
* Processes user input of the host/user selection page. * Processes user input of the host/user selection page.
* It checks if all input values are correct and updates the associated LDAP attributes. * It checks if all input values are correct and updates the associated LDAP attributes.
@ -309,7 +309,7 @@ class nisMailAlias extends baseModule {
function process_selectMail() { function process_selectMail() {
return $this->process_select(); return $this->process_select();
} }
/** /**
* Displays the user selection. * Displays the user selection.
* *
@ -318,7 +318,7 @@ class nisMailAlias extends baseModule {
function display_html_selectUser() { function display_html_selectUser() {
return $this->display_html_select(false); return $this->display_html_select(false);
} }
/** /**
* Processes user input of the host/user selection page. * Processes user input of the host/user selection page.
* It checks if all input values are correct and updates the associated LDAP attributes. * It checks if all input values are correct and updates the associated LDAP attributes.
@ -328,7 +328,7 @@ class nisMailAlias extends baseModule {
function process_selectUser() { function process_selectUser() {
return $this->process_select(); return $this->process_select();
} }
/** /**
* Displays the user/mail selection. * Displays the user/mail selection.
* *
@ -388,7 +388,7 @@ class nisMailAlias extends baseModule {
$return->addElement(new htmlHiddenInput('position', $position)); $return->addElement(new htmlHiddenInput('position', $position));
return $return; return $return;
} }
/** /**
* Processes user input of the host/user selection page. * Processes user input of the host/user selection page.
* It checks if all input values are correct and updates the associated LDAP attributes. * It checks if all input values are correct and updates the associated LDAP attributes.
@ -411,7 +411,7 @@ class nisMailAlias extends baseModule {
} }
return array(); return array();
} }
/** /**
* Controls if the module button the account page is visible and activated. * Controls if the module button the account page is visible and activated.
* *
@ -443,7 +443,6 @@ class nisMailAlias extends baseModule {
// add object class // add object class
if (!in_array("nisMailAlias", $partialAccounts[$i]['objectClass'])) $partialAccounts[$i]['objectClass'][] = "nisMailAlias"; if (!in_array("nisMailAlias", $partialAccounts[$i]['objectClass'])) $partialAccounts[$i]['objectClass'][] = "nisMailAlias";
// add alias name // add alias name
// check format
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'nisMailAlias_alias', 'cn', $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'nisMailAlias_alias', 'cn',
'nis_alias', $this->messages['alias'][1], $messages); 'nis_alias', $this->messages['alias'][1], $messages);
// add recipients // add recipients

View File

@ -549,10 +549,7 @@ class nisnetgroup extends baseModule {
} }
} }
// members // members
if ($rawAccounts[$i][$ids['nisnetgroup_members']] != "") { $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'nisnetgroup_members', 'nisNetgroupTriple', null, null, $messages, '/;[ ]*/');
$members = explode(';', $rawAccounts[$i][$ids['nisnetgroup_members']]);
$partialAccounts[$i]['nisNetgroupTriple'] = $members;
}
} }
return $messages; return $messages;
} }

View File

@ -53,7 +53,7 @@ class posixGroup extends baseModule implements passwordService {
private $cachedUserToGIDList = null; private $cachedUserToGIDList = null;
/** cache for existing groups */ /** cache for existing groups */
private $cachedGroupNameList = null; private $cachedGroupNameList = null;
/** /**
* In this function the LDAP account is built up. * In this function the LDAP account is built up.
* *
@ -70,14 +70,7 @@ class posixGroup extends baseModule implements passwordService {
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->manageCnAttribute) {
// group name // group name
if (get_preg($rawAccounts[$i][$ids['posixGroup_cn']], 'groupname')) { $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'posixGroup_cn', 'cn', 'groupname', $this->messages['cn'][3], $error_messages);
$partialAccounts[$i]['cn'] = $rawAccounts[$i][$ids['posixGroup_cn']];
}
else {
$errMsg = $this->messages['cn'][3];
array_push($errMsg, array($i));
$error_messages[] = $errMsg;
}
} }
// GID // GID
if ($rawAccounts[$i][$ids['posixGroup_gid']] == "") { if ($rawAccounts[$i][$ids['posixGroup_gid']] == "") {
@ -164,9 +157,9 @@ class posixGroup extends baseModule implements passwordService {
/** /**
* Returns the HTML meta data for the main account page. * Returns the HTML meta data for the main account page.
* *
* @return array HTML meta data * @return array HTML meta data
* *
* @see baseModule::get_metaData() * @see baseModule::get_metaData()
*/ */
function display_html_attributes() { function display_html_attributes() {
@ -300,12 +293,12 @@ class posixGroup extends baseModule implements passwordService {
} }
} }
$return->addElement(new htmlSubTitle(_("Group members")), true); $return->addElement(new htmlSubTitle(_("Group members")), true);
$return->addElement(new htmlOutputText(_("Selected users"))); $return->addElement(new htmlOutputText(_("Selected users")));
$return->addElement(new htmlOutputText('')); $return->addElement(new htmlOutputText(''));
$return->addElement(new htmlOutputText(_("Available users"))); $return->addElement(new htmlOutputText(_("Available users")));
$return->addNewLine(); $return->addNewLine();
$remUsers = array(); $remUsers = array();
if (isset($this->attributes['memberUid'])) { if (isset($this->attributes['memberUid'])) {
$remUsers = $this->attributes['memberUid']; $remUsers = $this->attributes['memberUid'];
@ -345,7 +338,7 @@ class posixGroup extends baseModule implements passwordService {
$filterContainer->addElement(new htmlHelpLink('filter')); $filterContainer->addElement(new htmlHelpLink('filter'));
$filterContainer->addElement(new htmlHiddenInput('filterValue', htmlspecialchars($filter))); $filterContainer->addElement(new htmlHiddenInput('filterValue', htmlspecialchars($filter)));
$return->addElement($filterContainer, true); $return->addElement($filterContainer, true);
// sync from group of names // sync from group of names
$gon = $this->getAccountContainer()->getAccountModule('groupOfNames'); $gon = $this->getAccountContainer()->getAccountModule('groupOfNames');
if ($gon == null) { if ($gon == null) {
@ -358,18 +351,18 @@ class posixGroup extends baseModule implements passwordService {
$syncButton->setIconClass('refreshButton'); $syncButton->setIconClass('refreshButton');
$return->addElement($syncButton, true); $return->addElement($syncButton, true);
} }
// back button // back button
$return->addElement(new htmlSpacer(null, '20px'), true); $return->addElement(new htmlSpacer(null, '20px'), true);
$return->addElement(new htmlAccountPageButton(get_class($this), 'attributes', 'back', _('Back')), true); $return->addElement(new htmlAccountPageButton(get_class($this), 'attributes', 'back', _('Back')), true);
$return->addElement(new htmlEqualHeight(array('removeusers', 'addusers'))); $return->addElement(new htmlEqualHeight(array('removeusers', 'addusers')));
return $return; return $return;
} }
/** /**
* Returns true if this module can manage accounts of the current type, otherwise false. * Returns true if this module can manage accounts of the current type, otherwise false.
* *
* @return boolean true if module fits * @return boolean true if module fits
*/ */
public function can_manage() { public function can_manage() {
@ -456,7 +449,7 @@ class posixGroup extends baseModule implements passwordService {
); );
} }
if ($this->manageCnAttribute) { if ($this->manageCnAttribute) {
array_unshift($return['upload_columns'], array_unshift($return['upload_columns'],
array( array(
'name' => 'posixGroup_cn', 'name' => 'posixGroup_cn',
'description' => _('Group name'), 'description' => _('Group name'),
@ -638,7 +631,7 @@ class posixGroup extends baseModule implements passwordService {
/** /**
* This functin will be called when the module will be loaded * This functin will be called when the module will be loaded
* *
* @param String $base the name of the {@link accountContainer} object ($_SESSION[$base]) * @param String $base the name of the {@link accountContainer} object ($_SESSION[$base])
*/ */
function init($base) { function init($base) {
@ -886,10 +879,10 @@ class posixGroup extends baseModule implements passwordService {
} }
return $return; return $return;
} }
/** /**
* Syncs with group of names members. * Syncs with group of names members.
* *
* @return array list of status messages * @return array list of status messages
*/ */
protected function syncGon() { protected function syncGon() {
@ -981,10 +974,10 @@ class posixGroup extends baseModule implements passwordService {
} }
} }
} }
/** /**
* Checks input values of module settings. * Checks input values of module settings.
* *
* Calling this method does not require the existence of an enclosing {@link accountContainer}.<br> * Calling this method does not require the existence of an enclosing {@link accountContainer}.<br>
* <br> * <br>
* If the input data is invalid the return value is an array that contains subarrays to build StatusMessages ('message type', 'message head', 'message text'). * If the input data is invalid the return value is an array that contains subarrays to build StatusMessages ('message type', 'message head', 'message text').
@ -993,7 +986,7 @@ class posixGroup extends baseModule implements passwordService {
* @param array $scopes list of account types which are used * @param array $scopes list of account types which are used
* @param array $options hash array (option name => value) that contains the input. The option values are all arrays containing one or more elements. * @param array $options hash array (option name => value) that contains the input. The option values are all arrays containing one or more elements.
* @return array list of error messages * @return array list of error messages
* *
* @see baseModule::get_metaData() * @see baseModule::get_metaData()
*/ */
public function check_configOptions($scopes, &$options) { public function check_configOptions($scopes, &$options) {
@ -1096,10 +1089,10 @@ class posixGroup extends baseModule implements passwordService {
} }
return $ret; return $ret;
} }
/** /**
* Gets the free GID numbers from an Samba pool entry in LDAP. * Gets the free GID numbers from an Samba pool entry in LDAP.
* *
* @param integer $count number of needed free GIDs. * @param integer $count number of needed free GIDs.
* @param array $errors list of error messages where errors can be added * @param array $errors list of error messages where errors can be added
* @return mixed null if no GIDs are free else an array of free GIDs * @return mixed null if no GIDs are free else an array of free GIDs
@ -1127,7 +1120,7 @@ class posixGroup extends baseModule implements passwordService {
/** /**
* Gets the free GID numbers from an Windows domain info entry in LDAP. * Gets the free GID numbers from an Windows domain info entry in LDAP.
* *
* @param integer $count number of needed free GIDs. * @param integer $count number of needed free GIDs.
* @param array $errors list of error messages where errors can be added * @param array $errors list of error messages where errors can be added
* @return mixed null if no GIDs are free else an array of free GIDs * @return mixed null if no GIDs are free else an array of free GIDs
@ -1165,13 +1158,13 @@ class posixGroup extends baseModule implements passwordService {
/** /**
* Specifies if this module supports to force that a user must change his password on next login. * Specifies if this module supports to force that a user must change his password on next login.
* *
* @return boolean force password change supported * @return boolean force password change supported
*/ */
public function supportsForcePasswordChange() { public function supportsForcePasswordChange() {
return false; return false;
} }
/** /**
* This function is called whenever the password should be changed. Account modules * This function is called whenever the password should be changed. Account modules
* must change their password attributes only if the modules list contains their module name. * must change their password attributes only if the modules list contains their module name.
@ -1190,7 +1183,7 @@ class posixGroup extends baseModule implements passwordService {
$this->attributes[$this->passwordAttrName][0] = pwd_hash($password, true, $this->moduleSettings['posixAccount_pwdHash'][0]); $this->attributes[$this->passwordAttrName][0] = pwd_hash($password, true, $this->moduleSettings['posixAccount_pwdHash'][0]);
return array(); return array();
} }
/** /**
* Returns a list of existing GID numbers. * Returns a list of existing GID numbers.
* *
@ -1214,7 +1207,7 @@ class posixGroup extends baseModule implements passwordService {
sort($this->cachedGIDList, SORT_NUMERIC); sort($this->cachedGIDList, SORT_NUMERIC);
return $this->cachedGIDList; return $this->cachedGIDList;
} }
/** /**
* Returns a list of existing users and their GID numbers and cn. * Returns a list of existing users and their GID numbers and cn.
* *
@ -1249,20 +1242,20 @@ class posixGroup extends baseModule implements passwordService {
logNewMessage(LOG_DEBUG, print_r($result, true)); logNewMessage(LOG_DEBUG, print_r($result, true));
return $this->cachedUserToGIDList; return $this->cachedUserToGIDList;
} }
/** /**
* Checks if the given group name already exists in LDAP. * Checks if the given group name already exists in LDAP.
* *
* @param String $groupName group name * @param String $groupName group name
* @return boolean true if already exists * @return boolean true if already exists
*/ */
private function groupNameExists($groupName) { private function groupNameExists($groupName) {
return in_array($groupName, $this->getGroupNames()); return in_array($groupName, $this->getGroupNames());
} }
/** /**
* Returns a list of all group names in LDAP. * Returns a list of all group names in LDAP.
* *
* @return array group names * @return array group names
*/ */
private function getGroupNames() { private function getGroupNames() {
@ -1282,10 +1275,10 @@ class posixGroup extends baseModule implements passwordService {
} }
return $this->cachedGroupNameList; return $this->cachedGroupNameList;
} }
/** /**
* Returns if the Windows module is active. * Returns if the Windows module is active.
* *
* @return boolean is Windows * @return boolean is Windows
*/ */
private function isWindows() { private function isWindows() {
@ -1300,7 +1293,7 @@ class posixGroup extends baseModule implements passwordService {
} }
return false; return false;
} }
} }
?> ?>

View File

@ -381,38 +381,11 @@ class puppetClient extends baseModule {
} }
} }
// environment // environment
if ($rawAccounts[$i][$ids['puppetClient_environment']] != "") { $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'puppetClient_environment', 'environment', 'ascii', $this->messages['environment'][1], $messages, '/;[ ]*/');
if (get_preg($rawAccounts[$i][$ids['puppetClient_environment']], 'ascii')) {
$partialAccounts[$i]['environment'] = explode(';', $rawAccounts[$i][$ids['puppetClient_environment']]);
}
else {
$errMsg = $this->messages['environment'][1];
array_push($errMsg, array($i));
$messages[] = $errMsg;
}
}
// classes // classes
if ($rawAccounts[$i][$ids['puppetClient_puppetclass']] != "") { $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'puppetClient_puppetclass', 'puppetclass', 'ascii', $this->messages['puppetclass'][1], $messages, '/;[ ]*/');
if (get_preg($rawAccounts[$i][$ids['puppetClient_puppetclass']], 'ascii')) {
$partialAccounts[$i]['puppetclass'] = explode(';', $rawAccounts[$i][$ids['puppetClient_puppetclass']]);
}
else {
$errMsg = $this->messages['puppetclass'][1];
array_push($errMsg, array($i));
$messages[] = $errMsg;
}
}
// variables // variables
if ($rawAccounts[$i][$ids['puppetClient_puppetvar']] != "") { $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'puppetClient_puppetvar', 'puppetvar', 'ascii', $this->messages['puppetvar'][1], $messages, '/;[ ]*/');
if (get_preg($rawAccounts[$i][$ids['puppetClient_puppetvar']], 'ascii')) {
$partialAccounts[$i]['puppetvar'] = explode(';', $rawAccounts[$i][$ids['puppetClient_puppetvar']]);
}
else {
$errMsg = $this->messages['puppetvar'][1];
array_push($errMsg, array($i));
$messages[] = $errMsg;
}
}
} }
return $messages; return $messages;
} }