upload API change

This commit is contained in:
Roland Gruber 2017-09-02 13:03:36 +02:00
parent 264d8ea26c
commit 6bb5249bf1
9 changed files with 29 additions and 17 deletions

View File

@ -22,6 +22,7 @@
@ -59,7 +60,16 @@ This is a list of API changes for all LAM releases.
<br>
<h2>6.0 -&gt; 6.1</h2>
<ul>
<li>module API</li>
<ul>
<li>doUploadPreActions has new parameter $type</li>
<li>doUploadPostActions has new parameter $type</li>
</ul>
</ul>
<h2>5.7 -&gt; 6.0</h2>
<ul>
<li>All account types allow multiple configurations by default.</li>
<li>the following&nbsp; methods in baseModule have a new parameter $typeId:</li>

View File

@ -1040,9 +1040,10 @@ abstract class baseModule {
* Runs any actions that need to be done before an LDAP entry is created.
*
* @param array $attributes LDAP attributes of this entry (attributes are provided as reference, handle modifications of $attributes with care)
* @param ConfiguredType $type account type
* @return array array which contains status messages. Each entry is an array containing the status message parameters.
*/
public function doUploadPreActions($attributes) {
public function doUploadPreActions($attributes, $type) {
return array();
}
@ -1068,8 +1069,9 @@ abstract class baseModule {
* <br> 'progress' => 0..100 // the progress of the operations in percent
* <br> 'errors' => array // list of arrays which are used to generate StatusMessages
* <br> )
* @param ConfiguredType $type account type
*/
public function doUploadPostActions(&$data, $ids, $failed, &$temp, &$accounts, $selectedModules) {
public function doUploadPostActions(&$data, $ids, $failed, &$temp, &$accounts, $selectedModules, $type) {
return array(
'status' => 'finished',
'progress' => 100,

View File

@ -541,17 +541,17 @@ function buildUploadAccounts($type, $data, $ids, $selectedModules) {
/**
* Runs any actions that need to be done before an LDAP entry is created.
*
* @param String $scope account type
* @param ConfiguredType $type account type
* @param array $selectedModules list of selected account modules
* @param array $attributes LDAP attributes of this entry (attributes are provided as reference, handle modifications of $attributes with care)
* @return array array which contains status messages. Each entry is an array containing the status message parameters.
*/
function doUploadPreActions($scope, $selectedModules, $attributes) {
function doUploadPreActions($type, $selectedModules, $attributes) {
$messages = array();
for ($i = 0; $i < sizeof($selectedModules); $i++) {
$activeModule = $selectedModules[$i];
$module = moduleCache::getModule($activeModule, $scope);
$messages = array_merge($messages, $module->doUploadPreActions($attributes));
$module = moduleCache::getModule($activeModule, $type->getScope());
$messages = array_merge($messages, $module->doUploadPreActions($attributes, $type));
}
return $messages;
}
@ -559,7 +559,7 @@ function doUploadPreActions($scope, $selectedModules, $attributes) {
/**
* This function executes one post upload action.
*
* @param string $scope account type
* @param ConfiguredType $type account type
* @param array $data array containing one account in each element
* @param array $ids array(<column_name> => <column number>)
* @param array $failed list of accounts which were not created successfully
@ -573,7 +573,7 @@ function doUploadPreActions($scope, $selectedModules, $attributes) {
* <br> 'errors' => array (<array of parameters for StatusMessage>)
* <br> )
*/
function doUploadPostActions($scope, &$data, $ids, $failed, $selectedModules, &$accounts) {
function doUploadPostActions($type, &$data, $ids, $failed, $selectedModules, &$accounts) {
// check if function is called the first time
if (! isset($_SESSION['mass_postActions']['remainingModules'])) {
// make list of remaining modules
@ -586,8 +586,8 @@ function doUploadPostActions($scope, &$data, $ids, $failed, $selectedModules, &$
$_SESSION['mass_postActions'][$activeModule] = array();
}
// let first module do one post action
$module = moduleCache::getModule($activeModule, $scope);
$return = $module->doUploadPostActions($data, $ids, $failed, $_SESSION['mass_postActions'][$activeModule], $accounts, $selectedModules);
$module = moduleCache::getModule($activeModule, $type->getScope());
$return = $module->doUploadPostActions($data, $ids, $failed, $_SESSION['mass_postActions'][$activeModule], $accounts, $selectedModules, $type);
// remove active module from list if already finished
if ($return['status'] == 'finished') {
unset($_SESSION['mass_postActions']['remainingModules'][0]);

View File

@ -2364,7 +2364,7 @@ class inetOrgPerson extends baseModule implements passwordService {
* {@inheritDoc}
* @see baseModule::doUploadPostActions()
*/
function doUploadPostActions(&$data, $ids, $failed, &$temp, &$accounts, $selectedModules) {
function doUploadPostActions(&$data, $ids, $failed, &$temp, &$accounts, $selectedModules, $type) {
if (!checkIfWriteAccessIsAllowed($this->get_scope())) {
die();
}

View File

@ -526,7 +526,7 @@ class nisNetGroupUser extends baseModule {
* {@inheritDoc}
* @see baseModule::doUploadPostActions()
*/
function doUploadPostActions(&$data, $ids, $failed, &$temp, &$accounts, $selectedModules) {
function doUploadPostActions(&$data, $ids, $failed, &$temp, &$accounts, $selectedModules, $type) {
if (!checkIfWriteAccessIsAllowed($this->get_scope())) {
die();
}

View File

@ -2411,7 +2411,7 @@ class posixAccount extends baseModule implements passwordService {
* {@inheritDoc}
* @see baseModule::doUploadPostActions()
*/
function doUploadPostActions(&$data, $ids, $failed, &$temp, &$accounts, $selectedModules) {
function doUploadPostActions(&$data, $ids, $failed, &$temp, &$accounts, $selectedModules, $type) {
if (!checkIfWriteAccessIsAllowed($this->get_scope())) {
die();
}

View File

@ -699,7 +699,7 @@ class quota extends baseModule {
* {@inheritDoc}
* @see baseModule::doUploadPostActions()
*/
function doUploadPostActions(&$data, $ids, $failed, &$temp, &$accounts, $selectedModules) {
function doUploadPostActions(&$data, $ids, $failed, &$temp, &$accounts, $selectedModules, $type) {
$errors = array();
// first call, get list of user names and quota values
if (!isset($temp['counter'])) {

View File

@ -2283,7 +2283,7 @@ class windowsUser extends baseModule implements passwordService {
* {@inheritDoc}
* @see baseModule::doUploadPostActions()
*/
function doUploadPostActions(&$data, $ids, $failed, &$temp, &$accounts, $selectedModules) {
function doUploadPostActions(&$data, $ids, $failed, &$temp, &$accounts, $selectedModules, $type) {
if (!checkIfWriteAccessIsAllowed($this->get_scope())) {
die();
}

View File

@ -133,7 +133,7 @@ class Uploader {
$preAttributes[$key] = &$attrs[$key];
}
$preAttributes['dn'] = &$dn;
$preMessages = doUploadPreActions($this->type->getScope(), $_SESSION['mass_selectedModules'], $preAttributes);
$preMessages = doUploadPreActions($this->type, $_SESSION['mass_selectedModules'], $preAttributes);
$preActionOk = true;
for ($i = 0; $i < sizeof($preMessages); $i++) {
if (($preMessages[$i][0] == 'ERROR') || ($preMessages[$i][0] == 'WARN')) {
@ -243,7 +243,7 @@ class Uploader {
* @return array status array
*/
private function runModulePostActions() {
$return = doUploadPostActions($this->type->getScope(), $this->data, $_SESSION['mass_ids'], $_SESSION['mass_failed'], $_SESSION['mass_selectedModules'], $this->accounts);
$return = doUploadPostActions($this->type, $this->data, $_SESSION['mass_ids'], $_SESSION['mass_failed'], $_SESSION['mass_selectedModules'], $this->accounts);
if ($return['status'] == 'finished') {
$_SESSION['mass_postActions']['finished'] = true;
}