2003-06-01 11:39:23 +00:00
< ? php
2017-01-07 17:23:04 +00:00
namespace LAM\UPLOAD ;
2018-04-18 16:43:29 +00:00
use \htmlResponsiveTable ;
2017-01-07 17:23:04 +00:00
use \htmlOutputText ;
use \htmlGroup ;
use \htmlImage ;
2018-04-18 16:43:29 +00:00
use \htmlResponsiveInputCheckbox ;
2017-01-07 17:23:04 +00:00
use \htmlDiv ;
use \htmlHiddenInput ;
use \htmlButton ;
use \htmlTitle ;
2018-04-18 16:43:29 +00:00
use \htmlResponsiveInputFileUpload ;
2017-01-07 17:23:04 +00:00
use \htmlLink ;
use \htmlSubTitle ;
use \htmlHelpLink ;
2018-04-18 16:43:29 +00:00
use \htmlResponsiveRow ;
use \htmlResponsiveSelect ;
use \htmlLabeledInputCheckbox ;
use \htmlSpacer ;
2017-01-07 17:23:04 +00:00
use \moduleCache ;
2003-06-01 11:39:23 +00:00
/*
2009-10-27 18:47:12 +00:00
This code is part of LDAP Account Manager ( http :// www . ldap - account - manager . org / )
2018-01-07 16:44:50 +00:00
Copyright ( C ) 2004 - 2018 Roland Gruber
2003-06-01 11:39:23 +00:00
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
the Free Software Foundation ; either version 2 of the License , or
( at your option ) any later version .
This program is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
GNU General Public License for more details .
You should have received a copy of the GNU General Public License
along with this program ; if not , write to the Free Software
Foundation , Inc . , 59 Temple Place , Suite 330 , Boston , MA 02111 - 1307 USA
*/
2004-08-31 19:13:32 +00:00
/**
* Start page of file upload
*
* @ author Roland Gruber
* @ package tools
2004-01-10 11:47:48 +00:00
*/
2004-08-31 19:13:32 +00:00
2006-03-26 17:51:25 +00:00
/** security functions */
2016-12-07 20:18:06 +00:00
include_once ( " ../../lib/security.inc " );
2004-08-31 19:13:32 +00:00
/** access to configuration */
2016-12-07 20:18:06 +00:00
include_once ( '../../lib/config.inc' );
2004-08-31 19:13:32 +00:00
/** status messages */
2016-12-07 20:18:06 +00:00
include_once ( '../../lib/status.inc' );
2004-08-31 19:13:32 +00:00
/** account modules */
2016-12-07 20:18:06 +00:00
include_once ( '../../lib/modules.inc' );
2012-02-05 10:38:59 +00:00
/** Used to get PDF information. */
2016-12-07 20:18:06 +00:00
include_once ( '../../lib/pdfstruct.inc' );
/** upload functions */
include_once ( '../../lib/upload.inc' );
2004-09-21 18:37:55 +00:00
2004-01-10 11:47:48 +00:00
// Start session
2006-03-26 17:51:25 +00:00
startSecureSession ();
2017-02-11 16:11:37 +00:00
enforceUserIsLoggedIn ();
2003-10-22 17:51:44 +00:00
2012-08-13 17:43:48 +00:00
// check if this tool may be run
checkIfToolIsActive ( 'toolFileUpload' );
2007-12-30 13:15:39 +00:00
// die if no write access
if ( ! checkIfWriteAccessIsAllowed ()) die ();
2012-07-22 10:37:01 +00:00
checkIfToolIsActive ( 'toolFileUpload' );
2003-10-22 17:51:44 +00:00
// Redirect to startpage if user is not loged in
2014-10-25 19:17:53 +00:00
if ( ! isLoggedIn ()) {
2016-12-07 20:18:06 +00:00
metaRefresh ( " ../login.php " );
2004-01-10 11:47:48 +00:00
exit ;
2004-09-21 18:37:55 +00:00
}
2003-10-22 17:51:44 +00:00
2003-10-22 13:57:32 +00:00
// Set correct language, codepages, ....
2003-08-10 19:46:21 +00:00
setlanguage ();
2003-06-01 11:39:23 +00:00
2015-05-15 19:16:46 +00:00
if ( ! empty ( $_POST )) {
validateSecurityToken ();
}
2004-10-12 13:12:16 +00:00
// show CSV if requested
if ( isset ( $_GET [ 'getCSV' ])) {
//download file
2016-07-14 19:00:47 +00:00
header ( 'Content-Type: application/msexcel' );
header ( 'Content-disposition: attachment; filename=lam.csv' );
2004-10-12 13:12:16 +00:00
echo $_SESSION [ 'mass_csv' ];
exit ;
}
2017-01-07 17:23:04 +00:00
Uploader :: cleanSession ();
2016-12-07 20:18:06 +00:00
2018-04-18 16:43:29 +00:00
include '../../lib/adminHeader.inc' ;
2004-08-31 19:13:32 +00:00
2010-02-27 19:14:15 +00:00
// get possible types and remove those which do not support file upload
2017-01-07 17:23:04 +00:00
$typeManager = new \LAM\TYPES\TypeManager ();
$types = $typeManager -> getConfiguredTypes ();
2013-05-01 12:36:17 +00:00
$count = sizeof ( $types );
for ( $i = 0 ; $i < $count ; $i ++ ) {
2017-01-07 17:23:04 +00:00
$myType = $types [ $i ];
if ( ! $myType -> getBaseType () -> supportsFileUpload () || $myType -> isHidden ()
|| ! checkIfNewEntriesAreAllowed ( $myType -> getId ()) || ! checkIfWriteAccessIsAllowed ( $myType -> getId ())) {
2010-02-27 19:14:15 +00:00
unset ( $types [ $i ]);
}
}
$types = array_values ( $types );
2004-08-31 19:13:32 +00:00
// check if account specific page should be shown
2010-02-15 20:21:44 +00:00
if ( isset ( $_POST [ 'type' ])) {
// get selected type
2017-01-07 17:23:04 +00:00
$typeId = htmlspecialchars ( $_POST [ 'type' ]);
$type = $typeManager -> getConfiguredType ( $typeId );
2010-02-15 20:21:44 +00:00
// get selected modules
$selectedModules = array ();
$checkedBoxes = array_keys ( $_POST , 'on' );
2018-01-07 16:44:50 +00:00
foreach ( $checkedBoxes as $checkedBox ) {
if ( strpos ( $checkedBox , $typeId . '___' ) === 0 ) {
$selectedModules [] = substr ( $checkedBox , strlen ( $typeId ) + strlen ( '___' ));
2010-02-15 20:21:44 +00:00
}
}
2017-01-07 17:23:04 +00:00
$deps = getModulesDependencies ( $type -> getScope ());
2010-02-15 20:21:44 +00:00
$depErrors = check_module_depends ( $selectedModules , $deps );
if ( is_array ( $depErrors ) && ( sizeof ( $depErrors ) > 0 )) {
2018-01-07 16:44:50 +00:00
foreach ( $depErrors as $depError ) {
2010-02-15 20:21:44 +00:00
StatusMessage ( 'ERROR' , _ ( " Unsolved dependency: " ) . ' ' .
2018-01-07 16:44:50 +00:00
getModuleAlias ( $depError [ 0 ], $type -> getScope ()) . " ( " .
getModuleAlias ( $depError [ 1 ], $type -> getScope ()) . " ) " );
2010-02-15 20:21:44 +00:00
}
}
else {
2017-01-07 17:23:04 +00:00
showMainPage ( $type , $selectedModules );
2010-02-15 20:21:44 +00:00
exit ;
}
}
2006-01-01 16:30:05 +00:00
2004-08-31 19:13:32 +00:00
// show start page
2010-12-05 13:31:39 +00:00
$divClass = 'user' ;
if ( isset ( $_REQUEST [ 'type' ])) {
2018-03-12 18:53:41 +00:00
$divClass = htmlspecialchars ( \LAM\TYPES\getScopeFromTypeId ( $_REQUEST [ 'type' ]));
2010-12-05 13:31:39 +00:00
}
2013-01-19 13:18:52 +00:00
echo '<div class="' . $divClass . '-bright smallPaddingContent">' ;
2010-02-15 20:21:44 +00:00
echo " <form enctype= \" multipart/form-data \" action= \" masscreate.php \" method= \" post \" > \n " ;
2012-09-13 20:10:48 +00:00
$tabindex = 1 ;
2018-04-18 16:43:29 +00:00
$row = new htmlResponsiveRow ();
$row -> add ( new htmlTitle ( _ ( " Account creation via file upload " )), 12 );
$row -> add ( new htmlOutputText ( _ ( " Here you can create multiple accounts by providing a CSV file. " )), 12 );
$row -> addVerticalSpacer ( '4rem' );
2012-09-13 20:10:48 +00:00
// account type
$typeList = array ();
2017-01-07 17:23:04 +00:00
foreach ( $types as $type ) {
$typeList [ $type -> getAlias ()] = $type -> getId ();
2012-09-13 20:10:48 +00:00
}
2017-12-13 10:06:57 +00:00
$selectedType = null ;
2012-09-13 20:10:48 +00:00
if ( isset ( $_REQUEST [ 'type' ])) {
2017-12-13 10:06:57 +00:00
$selectedType = $_REQUEST [ 'type' ];
2012-09-13 20:10:48 +00:00
}
2014-01-15 20:48:52 +00:00
elseif ( ! empty ( $types )) {
2017-12-13 10:06:57 +00:00
$selectedType = $types [ 0 ] -> getId ();
2012-09-13 20:10:48 +00:00
}
2018-04-18 16:43:29 +00:00
$typeSelect = new htmlResponsiveSelect ( 'type' , $typeList , array ( $selectedType ), _ ( " Account type " ));
2012-09-13 20:10:48 +00:00
$typeSelect -> setHasDescriptiveElements ( true );
$typeSelect -> setOnchangeEvent ( 'changeVisibleModules(this);' );
2018-04-18 16:43:29 +00:00
$row -> add ( $typeSelect , 12 );
$row -> addVerticalSpacer ( '1rem' );
$row -> add ( new htmlSubTitle ( _ ( 'Selected modules' )), 12 );
2012-09-13 20:10:48 +00:00
// module selection
2017-01-07 17:23:04 +00:00
foreach ( $types as $type ) {
2012-09-13 20:10:48 +00:00
$divClasses = array ( 'typeOptions' );
2017-12-13 10:06:57 +00:00
if ( $selectedType != $type -> getId ()) {
2012-09-13 20:10:48 +00:00
$divClasses [] = 'hidden' ;
2010-04-04 14:54:58 +00:00
}
2018-04-18 16:43:29 +00:00
$innerRow = new htmlResponsiveRow ();
2017-01-07 17:23:04 +00:00
$modules = $_SESSION [ 'config' ] -> get_AccountModules ( $type -> getId ());
2018-01-07 16:44:50 +00:00
foreach ( $modules as $m => $moduleName ) {
2018-04-18 16:43:29 +00:00
$moduleGroup = new htmlGroup ();
2018-01-07 16:44:50 +00:00
$module = moduleCache :: getModule ( $moduleName , $type -> getScope ());
2013-09-29 08:08:56 +00:00
$iconImage = $module -> getIcon ();
if ( ! is_null ( $iconImage ) && ! ( strpos ( $iconImage , 'http' ) === 0 ) && ! ( strpos ( $iconImage , '/' ) === 0 )) {
2016-12-07 20:18:06 +00:00
$iconImage = '../../graphics/' . $iconImage ;
2013-09-29 08:08:56 +00:00
}
2018-04-18 16:43:29 +00:00
$image = new htmlImage ( $iconImage , '32px' , '32px' );
$image -> setCSSClasses ( array ( 'margin3' ));
$moduleGroup -> addElement ( $image );
2012-09-13 20:10:48 +00:00
$enabled = true ;
2018-01-07 16:44:50 +00:00
if ( is_base_module ( $moduleName , $type -> getScope ())) {
2012-09-13 20:10:48 +00:00
$enabled = false ;
2010-02-15 20:21:44 +00:00
}
2012-09-13 20:10:48 +00:00
$checked = true ;
2018-01-07 16:44:50 +00:00
if ( isset ( $_POST [ 'submit' ]) && ! isset ( $_POST [ $type -> getId () . '___' . $moduleName ])) {
2012-09-13 20:10:48 +00:00
$checked = false ;
2010-02-15 20:21:44 +00:00
}
2018-04-18 16:43:29 +00:00
$checkbox = new htmlLabeledInputCheckbox ( $type -> getId () . '___' . $moduleName , $checked , getModuleAlias ( $moduleName , $type -> getScope ()), null , false );
2012-09-13 20:10:48 +00:00
$checkbox -> setIsEnabled ( $enabled );
if ( $enabled ) {
2018-04-18 16:43:29 +00:00
$moduleGroup -> addElement ( $checkbox );
2010-10-24 13:53:44 +00:00
}
2012-09-13 20:10:48 +00:00
else {
$boxGroup = new htmlGroup ();
$boxGroup -> addElement ( $checkbox );
// add hidden field to fake disabled checkbox value
2018-01-07 16:44:50 +00:00
$boxGroup -> addElement ( new htmlHiddenInput ( $type -> getId () . '___' . $moduleName , 'on' ));
2018-04-18 16:43:29 +00:00
$moduleGroup -> addElement ( $boxGroup );
2012-09-13 20:10:48 +00:00
}
2018-04-18 16:43:29 +00:00
$innerRow -> add ( $moduleGroup , 12 , 6 , 4 );
}
$moduleCount = sizeof ( $modules );
if ( $moduleCount % 3 == 2 ) {
$innerRow -> add ( new htmlOutputText ( ' ' , false ), 0 , 0 , 4 );
}
if ( $moduleCount % 3 == 1 ) {
$innerRow -> add ( new htmlOutputText ( ' ' , false ), 0 , 0 , 4 );
}
if ( $moduleCount % 2 == 1 ) {
$innerRow -> add ( new htmlOutputText ( ' ' , false ), 0 , 6 , 0 );
2012-09-13 20:10:48 +00:00
}
2018-04-18 16:43:29 +00:00
$typeDiv = new htmlDiv ( $type -> getId (), $innerRow );
2012-11-30 19:21:47 +00:00
$typeDiv -> setCSSClasses ( $divClasses );
2018-04-18 16:43:29 +00:00
$row -> add ( $typeDiv , 12 );
2012-09-13 20:10:48 +00:00
}
// ok button
2018-04-18 16:43:29 +00:00
$row -> addVerticalSpacer ( '3rem' );
2014-01-15 20:48:52 +00:00
if ( ! empty ( $types )) {
2018-04-18 16:43:29 +00:00
$row -> add ( new htmlButton ( 'submit' , _ ( 'Ok' )), 12 );
2014-01-15 20:48:52 +00:00
}
2012-09-13 20:10:48 +00:00
2018-04-18 16:43:29 +00:00
addSecurityTokenToMetaHTML ( $row );
parseHtml ( null , $row , array (), false , $tabindex , 'user' );
2012-09-13 20:10:48 +00:00
?>
< script type = " text/javascript " >
function changeVisibleModules ( element ) {
jQuery ( 'div.typeOptions' ) . toggle ( false );
jQuery ( 'div#' + element . options [ element . selectedIndex ] . value ) . toggle ();
}
</ script >
< ? php
2010-02-15 20:21:44 +00:00
echo " </form> \n " ;
2010-10-18 19:46:03 +00:00
echo '</div>' ;
2018-04-18 16:43:29 +00:00
include '../../lib/adminFooter.inc' ;
2004-08-31 19:13:32 +00:00
/**
* Displays the acount type specific main page of the upload .
*
2017-01-07 17:23:04 +00:00
* @ param \LAM\TYPES\ConfiguredType $type account type
2010-02-15 20:21:44 +00:00
* @ param array $selectedModules list of selected account modules
2004-08-31 19:13:32 +00:00
*/
2017-09-17 08:17:13 +00:00
function showMainPage ( \LAM\TYPES\ConfiguredType $type , $selectedModules ) {
2017-01-07 17:23:04 +00:00
$scope = $type -> getScope ();
2013-01-19 13:18:52 +00:00
echo '<div class="' . $scope . '-bright smallPaddingContent">' ;
2004-08-31 19:13:32 +00:00
// get input fields from modules
2017-05-20 08:04:09 +00:00
$columns = getUploadColumns ( $type , $selectedModules );
2004-08-31 19:13:32 +00:00
$modules = array_keys ( $columns );
2016-07-14 19:00:47 +00:00
2010-12-05 13:31:39 +00:00
echo " <form enctype= \" multipart/form-data \" action= \" massBuildAccounts.php \" method= \" post \" > \n " ;
2018-04-18 16:43:29 +00:00
$tabindex = 1 ;
$row = new htmlResponsiveRow ();
$row -> setCSSClasses ( array ( 'maxrow' ));
2010-12-05 13:31:39 +00:00
// title
2018-04-18 16:43:29 +00:00
$row -> add ( new htmlTitle ( _ ( " File upload " )), 12 );
2010-12-05 13:31:39 +00:00
// instructions
2018-04-18 16:43:29 +00:00
$row -> add ( new htmlOutputText ( _ ( " Please provide a CSV formated file with your account data. The cells in the first row must be filled with the column identifiers. The following rows represent one account for each row. " )), 12 );
$row -> add ( new htmlOutputText ( _ ( " Check your input carefully. LAM will only do some basic checks on the upload data. " )), 12 );
$row -> addVerticalSpacer ( '1rem' );
$row -> add ( new htmlOutputText ( _ ( " Hint: Format all cells as text in your spreadsheet program and turn off auto correction. " )), 12 );
$row -> addVerticalSpacer ( '1rem' );
2010-12-05 13:31:39 +00:00
// upload elements
2018-04-18 16:43:29 +00:00
$row -> addLabel ( new htmlOutputText ( _ ( " Download sample CSV file " )));
$row -> addField ( new htmlLink ( '' , 'masscreate.php?getCSV=1' , '../../graphics/save.png' , true ));
$row -> addVerticalSpacer ( '3rem' );
$row -> add ( new htmlResponsiveInputFileUpload ( 'inputfile' , _ ( " CSV file " )), 12 );
$row -> add ( new htmlHiddenInput ( 'typeId' , $type -> getId ()), 12 );
$row -> add ( new htmlHiddenInput ( 'selectedModules' , implode ( ',' , $selectedModules )), 12 );
2012-02-05 10:38:59 +00:00
// PDF
$createPDF = false ;
if ( isset ( $_POST [ 'createPDF' ]) && ( $_POST [ 'createPDF' ] === '1' )) {
$createPDF = true ;
}
2018-04-18 16:43:29 +00:00
$pdfCheckbox = new htmlResponsiveInputCheckbox ( 'createPDF' , $createPDF , _ ( 'Create PDF files' ));
2017-10-23 15:58:08 +00:00
$pdfCheckbox -> setTableRowsToShow ( array ( 'pdfStructure' , 'pdf_font' ));
2018-04-18 16:43:29 +00:00
$row -> add ( $pdfCheckbox , 12 );
2017-01-07 17:23:04 +00:00
$pdfStructures = \LAM\PDF\getPDFStructures ( $type -> getId ());
2012-02-05 10:38:59 +00:00
$pdfSelected = array ();
if ( isset ( $_POST [ 'pdfStructure' ])) {
$pdfSelected = array ( $_POST [ 'pdfStructure' ]);
}
else if ( in_array ( 'default' , $pdfStructures )) {
$pdfSelected = array ( 'default' );
}
2018-04-18 16:43:29 +00:00
$row -> add ( new htmlResponsiveSelect ( 'pdfStructure' , $pdfStructures , $pdfSelected , _ ( 'PDF structure' )), 12 );
2017-10-23 15:58:08 +00:00
$fonts = \LAM\PDF\getPdfFonts ();
2018-04-18 16:43:29 +00:00
$fontSelection = new htmlResponsiveSelect ( 'pdf_font' , $fonts , array (), _ ( 'Font' ), '411' );
2017-10-23 15:58:08 +00:00
$fontSelection -> setCSSClasses ( array ( 'lam-save-selection' ));
$fontSelection -> setHasDescriptiveElements ( true );
$fontSelection -> setSortElements ( false );
2018-04-18 16:43:29 +00:00
$row -> add ( $fontSelection , 12 );
$row -> addVerticalSpacer ( '1rem' );
2013-01-14 17:08:57 +00:00
$uploadButton = new htmlButton ( 'submitfile' , _ ( 'Upload file and create accounts' ));
$uploadButton -> setIconClass ( 'upButton' );
2018-04-18 16:43:29 +00:00
$row -> addLabel ( $uploadButton );
$row -> addField ( new htmlOutputText ( ' ' , false ));
$row -> addVerticalSpacer ( '2rem' );
$row -> add ( new htmlTitle ( _ ( " Columns " )), 12 );
2011-04-04 16:23:05 +00:00
// DN options
2016-12-07 20:18:06 +00:00
$dnTitle = new htmlSubTitle ( _ ( " DN settings " ), '../../graphics/logo32.png' );
2018-04-18 16:43:29 +00:00
$row -> add ( $dnTitle , 12 );
$titles = array ( _ ( 'Name' ), _ ( " Identifier " ), _ ( " Example value " ), _ ( " Default value " ), _ ( " Possible values " ));
$data = array ();
2018-08-06 18:41:07 +00:00
// DN suffix
2010-12-05 13:31:39 +00:00
$dnSuffixRowCells = array ();
2018-04-18 16:43:29 +00:00
$nameGroup = new htmlGroup ();
$help = new htmlHelpLink ( '361' );
$help -> setCSSClasses ( array ( 'hide-on-mobile' ));
$nameGroup -> addElement ( $help );
$nameGroup -> addElement ( new htmlSpacer ( '0.25rem' , '16px' ));
$nameGroup -> addElement ( new htmlOutputText ( _ ( " DN suffix " )));
$help = new htmlHelpLink ( '361' );
$help -> setCSSClasses ( array ( 'hide-on-tablet' ));
$nameGroup -> addElement ( $help );
$dnSuffixRowCells [] = $nameGroup ;
2010-12-05 13:31:39 +00:00
$dnSuffixRowCells [] = new htmlOutputText ( 'dn_suffix' );
2017-01-07 17:23:04 +00:00
$dnSuffixRowCells [] = new htmlOutputText ( $type -> getSuffix ());
$dnSuffixRowCells [] = new htmlOutputText ( $type -> getSuffix ());
2010-12-05 13:31:39 +00:00
$dnSuffixRowCells [] = new htmlOutputText ( '' );
2018-04-18 16:43:29 +00:00
$data [] = $dnSuffixRowCells ;
2018-08-06 18:41:07 +00:00
// RDN
2010-12-05 13:31:39 +00:00
$dnRDNRowCells = array ();
2011-04-03 10:29:23 +00:00
$rdnText = new htmlOutputText ( _ ( " RDN identifier " ));
$rdnText -> setMarkAsRequired ( true );
2018-04-18 16:43:29 +00:00
$nameGroup = new htmlGroup ();
$help = new htmlHelpLink ( '301' );
$help -> setCSSClasses ( array ( 'hide-on-mobile' ));
$nameGroup -> addElement ( $help );
$nameGroup -> addElement ( new htmlSpacer ( '0.25rem' , '16px' ));
$nameGroup -> addElement ( $rdnText );
$help = new htmlHelpLink ( '301' );
$help -> setCSSClasses ( array ( 'hide-on-tablet' ));
$nameGroup -> addElement ( $help );
$dnRDNRowCells [] = $nameGroup ;
2010-12-05 13:31:39 +00:00
$dnRDNRowCells [] = new htmlOutputText ( 'dn_rdn' );
2017-01-07 17:23:04 +00:00
$rdnAttributes = getRDNAttributes ( $type -> getId (), $selectedModules );
2010-12-05 13:31:39 +00:00
$dnRDNRowCells [] = new htmlOutputText ( $rdnAttributes [ 0 ]);
$dnRDNRowCells [] = new htmlOutputText ( '' );
$dnRDNRowCells [] = new htmlOutputText ( implode ( " , " , $rdnAttributes ));
2018-04-18 16:43:29 +00:00
$dnRDNRowCells [] = new htmlHelpLink ( '301' );
$data [] = $dnRDNRowCells ;
2018-08-06 18:41:07 +00:00
// replace existing
$replaceRowCells = array ();
$nameGroup = new htmlGroup ();
$help = new htmlHelpLink ( '302' );
$help -> setCSSClasses ( array ( 'hide-on-mobile' ));
$nameGroup -> addElement ( $help );
$nameGroup -> addElement ( new htmlSpacer ( '0.25rem' , '16px' ));
$nameGroup -> addElement ( new htmlOutputText ( _ ( " Overwrite " )));
$help = new htmlHelpLink ( '302' );
$help -> setCSSClasses ( array ( 'hide-on-tablet' ));
$nameGroup -> addElement ( $help );
$replaceRowCells [] = $nameGroup ;
$replaceRowCells [] = new htmlOutputText ( 'overwrite' );
$replaceRowCells [] = new htmlOutputText ( 'false' );
$replaceRowCells [] = new htmlOutputText ( 'false' );
$replaceRowCells [] = new htmlOutputText ( 'true, false' );
$data [] = $replaceRowCells ;
2018-04-18 16:43:29 +00:00
$table = new htmlResponsiveTable ( $titles , $data );
$table -> setCSSClasses ( array ( 'alternating-color' ));
$row -> add ( $table , 12 );
2010-12-05 13:31:39 +00:00
// module options
2018-01-07 16:44:50 +00:00
foreach ( $modules as $moduleName ) {
2010-02-15 20:21:44 +00:00
// skip modules without upload columns
2018-01-07 16:44:50 +00:00
if ( sizeof ( $columns [ $moduleName ]) < 1 ) {
2010-02-15 20:21:44 +00:00
continue ;
}
2018-04-22 19:25:10 +00:00
$data = array ();
2018-04-18 16:43:29 +00:00
$row -> addVerticalSpacer ( '2rem' );
2018-01-07 16:44:50 +00:00
$module = moduleCache :: getModule ( $moduleName , $scope );
2013-09-29 08:08:56 +00:00
$icon = $module -> getIcon ();
2017-09-18 17:47:27 +00:00
if ( ! empty ( $icon ) && ! ( strpos ( $icon , 'http' ) === 0 ) && ! ( strpos ( $icon , '/' ) === 0 )) {
2016-12-07 20:18:06 +00:00
$icon = '../../graphics/' . $icon ;
2007-11-19 19:16:08 +00:00
}
2018-01-07 16:44:50 +00:00
$moduleTitle = new htmlSubTitle ( getModuleAlias ( $moduleName , $scope ), $icon );
2010-12-05 13:31:39 +00:00
$moduleTitle -> colspan = 20 ;
2018-04-18 16:43:29 +00:00
$row -> add ( $moduleTitle , 12 );
2018-01-07 16:44:50 +00:00
foreach ( $columns [ $moduleName ] as $column ) {
2011-04-03 10:29:23 +00:00
$required = false ;
2018-01-07 16:44:50 +00:00
if ( isset ( $column [ 'required' ]) && ( $column [ 'required' ] === true )) {
2011-04-03 10:29:23 +00:00
$required = true ;
2010-12-05 13:31:39 +00:00
}
$rowCells = array ();
2018-01-07 16:44:50 +00:00
$descriptionText = new htmlOutputText ( $column [ 'description' ]);
2011-04-03 10:29:23 +00:00
$descriptionText -> setMarkAsRequired ( $required );
2018-04-18 16:43:29 +00:00
$nameGroup = new htmlGroup ();
$help = new htmlHelpLink ( $column [ 'help' ], $moduleName , $scope );
$help -> setCSSClasses ( array ( 'hide-on-mobile' ));
$nameGroup -> addElement ( $help );
$nameGroup -> addElement ( new htmlSpacer ( '0.25rem' , '16px' ));
$nameGroup -> addElement ( $descriptionText );
$help = new htmlHelpLink ( $column [ 'help' ], $moduleName , $scope );
$help -> setCSSClasses ( array ( 'hide-on-tablet' ));
$nameGroup -> addElement ( $help );
$rowCells [] = $nameGroup ;
2018-01-07 16:44:50 +00:00
$rowCells [] = new htmlOutputText ( $column [ 'name' ]);
2011-03-31 18:50:48 +00:00
$example = '' ;
2018-01-07 16:44:50 +00:00
if ( isset ( $column [ 'example' ])) {
$example = $column [ 'example' ];
2011-03-31 18:50:48 +00:00
}
$rowCells [] = new htmlOutputText ( $example );
2018-01-07 16:44:50 +00:00
if ( isset ( $column [ 'default' ])) {
$rowCells [] = new htmlOutputText ( $column [ 'default' ]);
2010-12-05 13:31:39 +00:00
}
else {
$rowCells [] = new htmlOutputText ( '' );
}
2018-01-07 16:44:50 +00:00
if ( isset ( $column [ 'values' ])) {
$rowCells [] = new htmlOutputText ( $column [ 'values' ]);
2010-12-05 13:31:39 +00:00
}
else {
$rowCells [] = new htmlOutputText ( '' );
}
2018-04-18 16:43:29 +00:00
$data [] = $rowCells ;
2004-08-31 19:13:32 +00:00
}
2018-04-18 16:43:29 +00:00
$table = new htmlResponsiveTable ( $titles , $data );
$table -> setCSSClasses ( array ( 'alternating-color' ));
$row -> add ( $table , 12 );
2003-08-28 18:37:27 +00:00
}
2016-07-14 19:00:47 +00:00
2018-04-18 16:43:29 +00:00
addSecurityTokenToMetaHTML ( $row );
parseHtml ( null , $row , array (), false , $tabindex , $scope );
2016-07-14 19:00:47 +00:00
2010-12-05 13:31:39 +00:00
echo " </form> \n " ;
2004-08-31 19:13:32 +00:00
2010-09-04 12:39:32 +00:00
// build sample CSV
2004-10-12 13:12:16 +00:00
$sampleCSV_head = array ();
$sampleCSV_row = array ();
2010-09-04 12:39:32 +00:00
// DN attributes
$sampleCSV_head [] = " \" dn_suffix \" " ;
$sampleCSV_head [] = " \" dn_rdn \" " ;
2018-08-06 18:41:07 +00:00
$sampleCSV_head [] = " \" overwrite \" " ;
2010-09-04 12:39:32 +00:00
// module attributes
2018-01-07 16:44:50 +00:00
foreach ( $modules as $moduleName ) {
if ( sizeof ( $columns [ $moduleName ]) < 1 ) {
continue ;
}
2018-01-08 17:42:55 +00:00
foreach ( $columns [ $moduleName ] as $column ) {
$sampleCSV_head [] = " \" " . $column [ 'name' ] . " \" " ;
2003-09-28 16:00:13 +00:00
}
2010-09-04 12:39:32 +00:00
}
2017-01-07 17:23:04 +00:00
$RDNs = getRDNAttributes ( $type -> getId (), $selectedModules );
2010-09-04 12:39:32 +00:00
// DN attributes
2017-01-07 17:23:04 +00:00
$sampleCSV_row [] = " \" " . $type -> getSuffix () . " \" " ;
2010-09-04 12:39:32 +00:00
$sampleCSV_row [] = " \" " . $RDNs [ 0 ] . " \" " ;
2018-08-06 18:41:07 +00:00
$sampleCSV_row [] = " \" false \" " ;
2010-09-04 12:39:32 +00:00
// module attributes
2018-01-07 16:44:50 +00:00
foreach ( $modules as $moduleName ) {
if ( sizeof ( $columns [ $moduleName ]) < 1 ) {
continue ;
}
foreach ( $columns [ $moduleName ] as $column ) {
if ( isset ( $column [ 'example' ])) {
$sampleCSV_row [] = '"' . $column [ 'example' ] . '"' ;
2011-03-31 18:50:48 +00:00
}
else {
$sampleCSV_row [] = '""' ;
}
2003-06-01 15:14:16 +00:00
}
2010-09-04 12:39:32 +00:00
}
2004-10-12 13:12:16 +00:00
$sampleCSV = implode ( " , " , $sampleCSV_head ) . " \n " . implode ( " , " , $sampleCSV_row ) . " \n " ;
$_SESSION [ 'mass_csv' ] = $sampleCSV ;
2016-07-14 19:00:47 +00:00
2010-10-18 19:46:03 +00:00
echo '</div>' ;
2016-12-07 20:18:06 +00:00
include '../main_footer.php' ;
2004-08-31 19:13:32 +00:00
die ;
}
2003-06-01 11:39:23 +00:00
?>