import: fix some PHP warnings and update comments

This commit is contained in:
Benjamin Renard 2021-02-04 12:35:14 +01:00
parent 7af066f4c2
commit 7ecfa33afc
3 changed files with 16 additions and 16 deletions

View file

@ -98,7 +98,7 @@ class LSimport extends LSlog_staticLoggerClass {
} }
/** /**
* Import objects form POST data * Import objects from POST data
* *
* This method retreive, validate and import POST data. * This method retreive, validate and import POST data.
* *
@ -106,6 +106,11 @@ class LSimport extends LSlog_staticLoggerClass {
* *
* *
* array ( * array (
* 'success' => boolean,
* 'LSobject' => '[object type]',
* 'ioFormat' => '[ioFormat name]',
* 'justTry' => boolean,
* 'updateIfExists' => boolean,
* 'imported' => array ( * 'imported' => array (
* '[object1 dn]' => '[object1 display name]', * '[object1 dn]' => '[object1 display name]',
* '[object2 dn]' => '[object2 display name]', * '[object2 dn]' => '[object2 display name]',
@ -139,7 +144,7 @@ class LSimport extends LSlog_staticLoggerClass {
* *
* @author Benjamin Renard <brenard@easter-eggs.com> * @author Benjamin Renard <brenard@easter-eggs.com>
* *
* @retval boolean Array of the import result, false on error * @retval array Array of the import result
*/ */
public static function importFromPostData() { public static function importFromPostData() {
// Get data from $_POST // Get data from $_POST

View file

@ -781,26 +781,21 @@ function handle_LSobject_import($request) {
return; return;
$ioFormats = array(); $ioFormats = array();
$result = null; $result = array();
if ( LSsession :: loadLSclass('LSimport')) { if ( LSsession :: loadLSclass('LSimport', null, true)) { // import class with warning
$ioFormats = $object->listValidIOformats(); $ioFormats = $object->listValidIOformats();
if (is_array($ioFormats) && !empty($ioFormats)) { if (!is_array($ioFormats) || empty($ioFormats)) {
if (LSimport::isSubmit()) {
$result = LSimport::importFromPostData();
LSlog :: debug("LSimport::importFromPostData(): result = ".varDump($result));
}
}
else {
$ioFormats = array(); $ioFormats = array();
LSerror :: addErrorCode('LSsession_16'); LSerror :: addErrorCode('LSsession_16');
} }
} else if (LSimport::isSubmit()) {
else { $result = LSimport::importFromPostData();
LSerror :: addErrorCode('LSsession_05','LSimport'); LSlog :: debug("LSimport::importFromPostData(): result = ".varDump($result));
}
} }
// Define page title & template variables // Define page title & template variables
LStemplate :: assign('pagetitle',_('Import').' : '.$object->getLabel()); LStemplate :: assign('pagetitle', _('Import').' : '.$object->getLabel());
LStemplate :: assign('LSobject', $object -> getType()); LStemplate :: assign('LSobject', $object -> getType());
LStemplate :: assign('ioFormats', $ioFormats); LStemplate :: assign('ioFormats', $ioFormats);
LStemplate :: assign('result', $result); LStemplate :: assign('result', $result);

View file

@ -37,7 +37,7 @@
</dl> </dl>
</form> </form>
</div> </div>
{if is_array($result)} {if $result}
<h1>{tr msg='Result'}</h1> <h1>{tr msg='Result'}</h1>
{if !empty($result.errors)} {if !empty($result.errors)}
<h2>{tr msg='Errors'}</h2> <h2>{tr msg='Errors'}</h2>