seeddms-code/views/bootstrap/class.ImportUsers.php

136 lines
3.8 KiB
PHP
Raw Normal View History

2020-06-09 19:07:47 +00:00
<?php
/**
* Implementation of ImportUsers view
*
* @category DMS
* @package SeedDMS
* @license GPL 2
* @version @version@
* @author Uwe Steinmann <uwe@steinmann.cx>
* @copyright Copyright (C) 2002-2005 Markus Westphal,
* 2006-2008 Malcolm Cowe, 2010 Matteo Lucarelli,
* 2010-2012 Uwe Steinmann
* @version Release: @package_version@
*/
/**
* Include parent class
*/
//require_once("class.Bootstrap.php");
2020-06-09 19:07:47 +00:00
/**
* Class which outputs the html page for ImportUsers view
*
* @category DMS
* @package SeedDMS
* @author Markus Westphal, Malcolm Cowe, Uwe Steinmann <uwe@steinmann.cx>
* @copyright Copyright (C) 2002-2005 Markus Westphal,
* 2006-2008 Malcolm Cowe, 2010 Matteo Lucarelli,
* 2010-2012 Uwe Steinmann
* @version Release: @package_version@
*/
class SeedDMS_View_ImportUsers extends SeedDMS_Theme_Style {
2020-06-09 19:07:47 +00:00
function js() { /* {{{ */
header('Content-Type: application/javascript; charset=UTF-8');
2020-06-09 19:07:47 +00:00
$this->printFileChooserJs();
} /* }}} */
function show() { /* {{{ */
$dms = $this->params['dms'];
$user = $this->params['user'];
2021-06-23 15:48:46 +00:00
$accessobject = $this->params['accessobject'];
2020-06-29 15:24:26 +00:00
$log = $this->params['log'];
2020-07-30 15:34:06 +00:00
$newusers = $this->params['newusers'];
$colmap = $this->params['colmap'];
2020-06-09 19:07:47 +00:00
$this->htmlStartPage(getMLText("import_users"));
$this->globalNavigation();
$this->contentStart();
$this->pageNavigation(getMLText("admin_tools"), "admin_tools");
$this->contentHeading(getMLText("import_users"));
$this->rowStart();
$this->columnStart(4);
2020-06-09 19:07:47 +00:00
print "<form class=\"form-horizontal\" action=\"../op/op.ImportUsers.php\" name=\"form1\" enctype=\"multipart/form-data\" method=\"post\">";
$this->contentContainerStart();
2020-06-09 19:07:47 +00:00
$this->formField(
getMLText("userdata_file"),
$this->getFileChooserHtml('userdata', false)
);
$this->formField(
getMLText("import_users_update"),
array(
'element'=>'input',
'type'=>'checkbox',
'name'=>'update',
'value'=>'1'
)
);
2020-06-29 15:24:26 +00:00
$this->formField(
getMLText("import_users_addnew"),
array(
'element'=>'input',
'type'=>'checkbox',
'name'=>'addnew',
'value'=>'1'
)
);
$this->contentContainerEnd();
2020-08-27 05:52:52 +00:00
$this->formSubmit("<i class=\"fa fa-save\"></i> ".getMLText('import'));
2020-06-09 19:07:47 +00:00
print "</form>\n";
$this->columnEnd();
$this->columnStart(8);
2020-07-30 15:34:06 +00:00
if($newusers) {
2020-06-29 15:24:26 +00:00
echo "<table class=\"table table-condensed\">\n";
2020-07-30 15:34:06 +00:00
echo "<tr>";
foreach($colmap as $col) {
echo "<th>".$col[2]."</th>\n";
}
echo "<th>".getMLText('message')."</th>";
echo "</tr>\n";
echo "<tr>";
foreach($newusers as $uhash=>$newuser) {
foreach($colmap as $i=>$coldata) {
echo "<td>";
2022-09-02 06:03:54 +00:00
echo htmlspecialchars(call_user_func($colmap[$i][1], $colmap[$i][2], $newuser));
2020-07-30 15:34:06 +00:00
echo "</td>\n";
}
echo "<td>";
if(isset($newuser['__logs__'])) {
foreach($newuser['__logs__'] as $item) {
$class = $item['type'] == 'success' ? 'success' : 'error';
2020-08-27 05:52:52 +00:00
echo "<i class=\"fa fa-circle ".$class."\"></i> ".htmlspecialchars($item['msg'])."<br />";
2020-07-30 15:34:06 +00:00
}
}
foreach($log[$uhash] as $item) {
$class = $item['type'] == 'success' ? 'success' : 'error';
2020-08-27 05:52:52 +00:00
echo "<i class=\"fa fa-circle ".$class."\"></i> ".htmlspecialchars($item['msg'])."<br />";
2020-07-30 15:34:06 +00:00
}
echo "</td>";
echo "</tr>\n";
}
echo "</tr>\n";
/*
2020-06-29 15:24:26 +00:00
foreach($log as $item) {
$class = $item['type'] == 'success' ? 'success' : 'error';
2020-07-27 13:30:30 +00:00
echo "<tr class=\"".$class."\"><td>".$item['id']."</td><td>".htmlspecialchars($item['msg'])."</td></tr>\n";
2020-06-29 15:24:26 +00:00
}
2020-07-30 15:34:06 +00:00
*/
2020-06-29 15:24:26 +00:00
echo "</table>";
} else {
if($colmap)
$this->warningMsg(getMLText('import_users_no_users'));
else
$this->warningMsg(getMLText('import_users_no_column_mapping'));
2020-06-29 15:24:26 +00:00
}
$this->columnEnd();
$this->rowEnd();
2020-06-09 19:07:47 +00:00
$this->contentEnd();
$this->htmlEndPage();
} /* }}} */
}