2003-06-01 11:39:23 +00:00
< ? php
2017-01-07 17:23:04 +00:00
namespace LAM\UPLOAD ;
use \htmlTable ;
use \htmlTableExtendedSelect ;
use \htmlSpacer ;
use \htmlOutputText ;
use \htmlGroup ;
use \htmlElement ;
use \htmlImage ;
use \htmlTableExtendedInputCheckbox ;
use \htmlDiv ;
use \htmlHiddenInput ;
use \htmlButton ;
use \htmlTitle ;
use \htmlInputFileUpload ;
use \htmlLink ;
use \htmlSubTitle ;
use \htmlHelpLink ;
use \htmlTableRow ;
use \moduleCache ;
2003-06-01 11:39:23 +00:00
/*
$Id $
2009-10-27 18:47:12 +00:00
This code is part of LDAP Account Manager ( http :// www . ldap - account - manager . org / )
2017-01-07 17:23:04 +00:00
Copyright ( C ) 2004 - 2017 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
include '../main_header.php' ;
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' );
for ( $i = 0 ; $i < sizeof ( $checkedBoxes ); $i ++ ) {
2017-01-07 17:23:04 +00:00
if ( strpos ( $checkedBoxes [ $i ], $typeId . '___' ) === 0 ) {
$selectedModules [] = substr ( $checkedBoxes [ $i ], 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 )) {
for ( $i = 0 ; $i < sizeof ( $depErrors ); $i ++ ) {
StatusMessage ( 'ERROR' , _ ( " Unsolved dependency: " ) . ' ' .
2017-01-07 17:23:04 +00:00
getModuleAlias ( $depErrors [ $i ][ 0 ], $type -> getScope ()) . " ( " .
getModuleAlias ( $depErrors [ $i ][ 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' ])) {
2017-01-07 17:23:04 +00:00
$divClass = \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-10-24 13:53:44 +00:00
echo " <div class= \" title \" > \n " ;
echo " <h2 class= \" titleText \" > " . _ ( " Account creation via file upload " ) . " </h2> \n " ;
echo " </div> " ;
2010-02-15 20:21:44 +00:00
echo " <p> </p> \n " ;
echo " <p> \n " ;
echo _ ( " Here you can create multiple accounts by providing a CSV file. " );
echo " </p> \n " ;
echo " <p> </p> \n " ;
echo " <form enctype= \" multipart/form-data \" action= \" masscreate.php \" method= \" post \" > \n " ;
2012-09-13 20:10:48 +00:00
$tabindex = 1 ;
$table = new htmlTable ();
// 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
}
$selectedType = array ();
if ( isset ( $_REQUEST [ 'type' ])) {
$selectedType [] = $_REQUEST [ 'type' ];
}
2014-01-15 20:48:52 +00:00
elseif ( ! empty ( $types )) {
2017-01-07 17:23:04 +00:00
$selectedType [] = $types [ 0 ] -> getId ();
2012-09-13 20:10:48 +00:00
}
$typeSelect = new htmlTableExtendedSelect ( 'type' , $typeList , $selectedType , _ ( " Account type " ));
$typeSelect -> setHasDescriptiveElements ( true );
$typeSelect -> setOnchangeEvent ( 'changeVisibleModules(this);' );
$table -> addElement ( $typeSelect , true );
$table -> addElement ( new htmlSpacer ( null , '10px' ), true );
// module selection
$moduleLabel = new htmlOutputText ( _ ( 'Selected modules' ));
$moduleLabel -> alignment = htmlElement :: ALIGN_TOP ;
$table -> addElement ( $moduleLabel );
$moduleGroup = new htmlGroup ();
2017-01-07 17:23:04 +00:00
foreach ( $types as $type ) {
2012-09-13 20:10:48 +00:00
$divClasses = array ( 'typeOptions' );
2017-01-07 17:23:04 +00:00
if (( ! isset ( $_REQUEST [ 'type' ]) && ( $i != 0 )) || ( isset ( $_REQUEST [ 'type' ]) && ( $_REQUEST [ 'type' ] != $type -> getId ()))) {
2012-09-13 20:10:48 +00:00
$divClasses [] = 'hidden' ;
2010-04-04 14:54:58 +00:00
}
2012-09-13 20:10:48 +00:00
$innerTable = new htmlTable ();
2017-01-07 17:23:04 +00:00
$modules = $_SESSION [ 'config' ] -> get_AccountModules ( $type -> getId ());
2012-09-13 20:10:48 +00:00
for ( $m = 0 ; $m < sizeof ( $modules ); $m ++ ) {
if (( $m != 0 ) && ( $m % 3 == 0 )) {
echo $innerTable -> addNewLine ();
2008-12-27 13:47:41 +00:00
}
2017-01-07 17:23:04 +00:00
$module = moduleCache :: getModule ( $modules [ $m ], $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
}
2012-09-13 20:10:48 +00:00
$innerTable -> addElement ( new htmlImage ( $iconImage ));
$enabled = true ;
2017-01-07 17:23:04 +00:00
if ( is_base_module ( $modules [ $m ], $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 ;
2017-01-07 17:23:04 +00:00
if ( isset ( $_POST [ 'submit' ]) && ! isset ( $_POST [ $type -> getId () . '___' . $modules [ $m ]])) {
2012-09-13 20:10:48 +00:00
$checked = false ;
2010-02-15 20:21:44 +00:00
}
2017-01-07 17:23:04 +00:00
$checkbox = new htmlTableExtendedInputCheckbox ( $type -> getId () . '___' . $modules [ $m ], $checked , getModuleAlias ( $modules [ $m ], $type -> getScope ()), null , false );
2012-09-13 20:10:48 +00:00
$checkbox -> setIsEnabled ( $enabled );
if ( $enabled ) {
$innerTable -> 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
2017-01-07 17:23:04 +00:00
$boxGroup -> addElement ( new htmlHiddenInput ( $type -> getId () . '___' . $modules [ $m ], 'on' ));
2012-09-13 20:10:48 +00:00
$innerTable -> addElement ( $boxGroup );
}
$innerTable -> addElement ( new htmlSpacer ( '10px' , null ));
}
2017-01-07 17:23:04 +00:00
$typeDiv = new htmlDiv ( $type -> getId (), $innerTable );
2012-11-30 19:21:47 +00:00
$typeDiv -> setCSSClasses ( $divClasses );
2012-09-13 20:10:48 +00:00
$moduleGroup -> addElement ( $typeDiv );
}
$table -> addElement ( $moduleGroup , true );
// ok button
$table -> addElement ( new htmlSpacer ( null , '20px' ), true );
2014-01-15 20:48:52 +00:00
if ( ! empty ( $types )) {
$table -> addElement ( new htmlButton ( 'submit' , _ ( 'Ok' )), true );
}
2012-09-13 20:10:48 +00:00
2015-05-15 19:16:46 +00:00
addSecurityTokenToMetaHTML ( $table );
2012-09-13 20:10:48 +00:00
parseHtml ( null , $table , array (), false , $tabindex , 'user' );
?>
< 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>' ;
2016-12-07 20:18:06 +00:00
include '../main_footer.php' ;
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 " ;
$container = new htmlTable ();
// title
$container -> addElement ( new htmlTitle ( _ ( " File upload " )), true );
$container -> addElement ( new htmlSpacer ( null , '10px' ), true );
// instructions
$container -> addElement ( 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. " )), true );
$container -> addElement ( new htmlOutputText ( _ ( " Check your input carefully. LAM will only do some basic checks on the upload data. " )), true );
$container -> addElement ( new htmlSpacer ( null , '10px' ), true );
$container -> addElement ( new htmlOutputText ( _ ( " Hint: Format all cells as text in your spreadsheet program and turn off auto correction. " )), true );
$container -> addElement ( new htmlSpacer ( null , '10px' ), true );
// upload elements
$inputContainer = new htmlTable ();
$inputContainer -> addElement ( new htmlOutputText ( _ ( " CSV file " )));
$inputContainer -> addElement ( new htmlInputFileUpload ( 'inputfile' ));
$inputContainer -> addElement ( new htmlSpacer ( '10px' , null ));
2016-12-07 20:18:06 +00:00
$inputContainer -> addElement ( new htmlLink ( _ ( " Download sample CSV file " ), 'masscreate.php?getCSV=1' , '../../graphics/save.png' , true ));
2017-01-07 17:23:04 +00:00
$inputContainer -> addElement ( new htmlHiddenInput ( 'typeId' , $type -> getId ()));
2010-12-05 13:31:39 +00:00
$inputContainer -> addElement ( new htmlHiddenInput ( 'selectedModules' , implode ( ',' , $selectedModules )), true );
2012-02-05 10:38:59 +00:00
// PDF
$createPDF = false ;
if ( isset ( $_POST [ 'createPDF' ]) && ( $_POST [ 'createPDF' ] === '1' )) {
$createPDF = true ;
}
$pdfCheckbox = new htmlTableExtendedInputCheckbox ( 'createPDF' , $createPDF , _ ( 'Create PDF files' ));
$pdfCheckbox -> setTableRowsToShow ( array ( 'pdfStructure' ));
$inputContainer -> addElement ( $pdfCheckbox , true );
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' );
}
$inputContainer -> addElement ( new htmlTableExtendedSelect ( 'pdfStructure' , $pdfStructures , $pdfSelected , _ ( 'PDF structure' )), true );
$inputContainer -> addElement ( new htmlSpacer ( null , '5px' ), true );
2013-01-14 17:08:57 +00:00
$uploadButton = new htmlButton ( 'submitfile' , _ ( 'Upload file and create accounts' ));
$uploadButton -> setIconClass ( 'upButton' );
$inputContainer -> addElement ( $uploadButton );
2010-12-05 13:31:39 +00:00
$container -> addElement ( $inputContainer , true );
$container -> addElement ( new htmlSpacer ( null , '10px' ), true );
// column list
$columnSpacer = new htmlSpacer ( '10px' , null );
$container -> addElement ( new htmlTitle ( _ ( " Columns " )), true );
$columnContainer = new htmlTable ();
2013-02-03 11:46:47 +00:00
$columnContainer -> setCSSClasses ( array ( $scope . 'list' , 'collapse' ));
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' );
2011-04-04 16:23:05 +00:00
$dnTitle -> colspan = 20 ;
$columnContainer -> addElement ( $dnTitle , true );
2010-12-05 13:31:39 +00:00
$columnContainer -> addElement ( $columnSpacer );
$columnContainer -> addElement ( new htmlOutputText ( '' ));
$columnContainer -> addElement ( $columnSpacer );
2011-04-04 16:23:05 +00:00
$header0 = new htmlOutputText ( _ ( 'Name' ));
$header0 -> alignment = htmlElement :: ALIGN_LEFT ;
$columnContainer -> addElement ( $header0 , false , true );
2010-12-05 13:31:39 +00:00
$columnContainer -> addElement ( $columnSpacer );
$header1 = new htmlOutputText ( _ ( " Identifier " ));
$header1 -> alignment = htmlElement :: ALIGN_LEFT ;
$columnContainer -> addElement ( $header1 , false , true );
$columnContainer -> addElement ( $columnSpacer );
$header2 = new htmlOutputText ( _ ( " Example value " ));
$header2 -> alignment = htmlElement :: ALIGN_LEFT ;
$columnContainer -> addElement ( $header2 , false , true );
$columnContainer -> addElement ( $columnSpacer );
$header3 = new htmlOutputText ( _ ( " Default value " ));
$header3 -> alignment = htmlElement :: ALIGN_LEFT ;
$columnContainer -> addElement ( $header3 , false , true );
$columnContainer -> addElement ( $columnSpacer );
$header4 = new htmlOutputText ( _ ( " Possible values " ));
$header4 -> alignment = htmlElement :: ALIGN_LEFT ;
2011-04-04 16:23:05 +00:00
$columnContainer -> addElement ( $header4 , false , true );
2010-12-05 13:31:39 +00:00
$dnSuffixRowCells = array ();
$dnSuffixRowCells [] = $columnSpacer ;
$dnSuffixRowCells [] = new htmlHelpLink ( '361' );
$dnSuffixRowCells [] = $columnSpacer ;
$dnSuffixRowCells [] = new htmlOutputText ( _ ( " DN suffix " ));
$dnSuffixRowCells [] = $columnSpacer ;
$dnSuffixRowCells [] = new htmlOutputText ( 'dn_suffix' );
$dnSuffixRowCells [] = $columnSpacer ;
2017-01-07 17:23:04 +00:00
$dnSuffixRowCells [] = new htmlOutputText ( $type -> getSuffix ());
2010-12-05 13:31:39 +00:00
$dnSuffixRowCells [] = $columnSpacer ;
2017-01-07 17:23:04 +00:00
$dnSuffixRowCells [] = new htmlOutputText ( $type -> getSuffix ());
2010-12-05 13:31:39 +00:00
$dnSuffixRowCells [] = $columnSpacer ;
$dnSuffixRowCells [] = new htmlOutputText ( '' );
$dnSuffixRowCells [] = new htmlSpacer ( null , '25px' );
$dnSuffixRow = new htmlTableRow ( $dnSuffixRowCells );
2013-01-19 13:18:52 +00:00
$dnSuffixRow -> setCSSClasses ( array ( $scope . '-dark' ));
2010-12-05 13:31:39 +00:00
$columnContainer -> addElement ( $dnSuffixRow );
$dnRDNRowCells = array ();
$dnRDNRowCells [] = $columnSpacer ;
$dnRDNRowCells [] = new htmlHelpLink ( '301' );
$dnRDNRowCells [] = $columnSpacer ;
2011-04-03 10:29:23 +00:00
$rdnText = new htmlOutputText ( _ ( " RDN identifier " ));
$rdnText -> setMarkAsRequired ( true );
$dnRDNRowCells [] = $rdnText ;
2010-12-05 13:31:39 +00:00
$dnRDNRowCells [] = $columnSpacer ;
$dnRDNRowCells [] = new htmlOutputText ( 'dn_rdn' );
$dnRDNRowCells [] = $columnSpacer ;
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 [] = $columnSpacer ;
$dnRDNRowCells [] = new htmlOutputText ( '' );
$dnRDNRowCells [] = $columnSpacer ;
$dnRDNRowCells [] = new htmlOutputText ( implode ( " , " , $rdnAttributes ));
$dnRDNRowCells [] = new htmlSpacer ( null , '25px' );
$dnRDNRow = new htmlTableRow ( $dnRDNRowCells );
2013-01-19 13:18:52 +00:00
$dnRDNRow -> setCSSClasses ( array ( $scope . '-bright' ));
2010-12-05 13:31:39 +00:00
$columnContainer -> addElement ( $dnRDNRow );
// module options
2004-08-31 19:13:32 +00:00
for ( $m = 0 ; $m < sizeof ( $modules ); $m ++ ) {
2010-02-15 20:21:44 +00:00
// skip modules without upload columns
if ( sizeof ( $columns [ $modules [ $m ]]) < 1 ) {
continue ;
}
2011-04-04 16:23:05 +00:00
$columnContainer -> addElement ( new htmlSpacer ( null , '10px' ), true );
2013-05-09 19:10:35 +00:00
$module = moduleCache :: getModule ( $modules [ $m ], $scope );
2013-09-29 08:08:56 +00:00
$icon = $module -> getIcon ();
if (( $icon != null ) && ! ( 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
}
2010-12-05 13:31:39 +00:00
$moduleTitle = new htmlSubTitle ( getModuleAlias ( $modules [ $m ], $scope ), $icon );
$moduleTitle -> colspan = 20 ;
2011-04-04 16:23:05 +00:00
$columnContainer -> addElement ( $moduleTitle , true );
$columnContainer -> addElement ( new htmlOutputText ( '' ));
$columnContainer -> addElement ( new htmlOutputText ( '' ));
$columnContainer -> addElement ( new htmlOutputText ( '' ));
$nameOut = new htmlOutputText ( _ ( 'Name' ));
$nameOut -> alignment = htmlElement :: ALIGN_LEFT ;
$columnContainer -> addElement ( $nameOut , false , true );
$columnContainer -> addElement ( new htmlOutputText ( '' ));
$idOut = new htmlOutputText ( _ ( 'Identifier' ));
$idOut -> alignment = htmlElement :: ALIGN_LEFT ;
$columnContainer -> addElement ( $idOut , false , true );
$columnContainer -> addElement ( new htmlOutputText ( '' ));
$exampleOut = new htmlOutputText ( _ ( 'Example value' ));
$exampleOut -> alignment = htmlElement :: ALIGN_LEFT ;
$columnContainer -> addElement ( $exampleOut , false , true );
$columnContainer -> addElement ( new htmlOutputText ( '' ));
$defaultOut = new htmlOutputText ( _ ( 'Default value' ));
$defaultOut -> alignment = htmlElement :: ALIGN_LEFT ;
$columnContainer -> addElement ( $defaultOut , false , true );
$columnContainer -> addElement ( new htmlOutputText ( '' ));
$possibleOut = new htmlOutputText ( _ ( 'Possible values' ));
$possibleOut -> alignment = htmlElement :: ALIGN_LEFT ;
$columnContainer -> addElement ( $possibleOut , false , true );
2010-12-05 13:31:39 +00:00
$odd = true ;
2004-08-31 19:13:32 +00:00
for ( $i = 0 ; $i < sizeof ( $columns [ $modules [ $m ]]); $i ++ ) {
2011-04-03 10:29:23 +00:00
$required = false ;
2010-12-05 13:31:39 +00:00
if ( isset ( $columns [ $modules [ $m ]][ $i ][ 'required' ]) && ( $columns [ $modules [ $m ]][ $i ][ 'required' ] == true )) {
2011-04-03 10:29:23 +00:00
$required = true ;
2010-12-05 13:31:39 +00:00
}
$rowCells = array ();
$rowCells [] = $columnSpacer ;
$rowCells [] = new htmlHelpLink ( $columns [ $modules [ $m ]][ $i ][ 'help' ], $modules [ $m ], $scope );
$rowCells [] = $columnSpacer ;
2011-05-20 17:43:31 +00:00
$descriptionText = new htmlOutputText ( $columns [ $modules [ $m ]][ $i ][ 'description' ]);
2011-04-03 10:29:23 +00:00
$descriptionText -> setMarkAsRequired ( $required );
2011-05-20 17:43:31 +00:00
$descriptionText -> setNoWrap ( true );
2011-04-03 10:29:23 +00:00
$rowCells [] = $descriptionText ;
2010-12-05 13:31:39 +00:00
$rowCells [] = $columnSpacer ;
$rowCells [] = new htmlOutputText ( $columns [ $modules [ $m ]][ $i ][ 'name' ]);
$rowCells [] = $columnSpacer ;
2011-03-31 18:50:48 +00:00
$example = '' ;
if ( isset ( $columns [ $modules [ $m ]][ $i ][ 'example' ])) {
$example = $columns [ $modules [ $m ]][ $i ][ 'example' ];
}
$rowCells [] = new htmlOutputText ( $example );
2010-12-05 13:31:39 +00:00
$rowCells [] = $columnSpacer ;
if ( isset ( $columns [ $modules [ $m ]][ $i ][ 'default' ])) {
$rowCells [] = new htmlOutputText ( $columns [ $modules [ $m ]][ $i ][ 'default' ]);
}
else {
$rowCells [] = new htmlOutputText ( '' );
}
$rowCells [] = $columnSpacer ;
if ( isset ( $columns [ $modules [ $m ]][ $i ][ 'values' ])) {
$rowCells [] = new htmlOutputText ( $columns [ $modules [ $m ]][ $i ][ 'values' ]);
}
else {
$rowCells [] = new htmlOutputText ( '' );
}
$rowCells [] = new htmlSpacer ( null , '25px' );
$row = new htmlTableRow ( $rowCells );
if ( $odd ) {
2013-01-19 13:18:52 +00:00
$row -> setCSSClasses ( array ( $scope . '-dark' ));
2010-12-05 13:31:39 +00:00
}
else {
2013-01-19 13:18:52 +00:00
$row -> setCSSClasses ( array ( $scope . '-bright' ));
2010-12-05 13:31:39 +00:00
}
$odd = ! $odd ;
$columnContainer -> addElement ( $row );
2004-08-31 19:13:32 +00:00
}
2003-08-28 18:37:27 +00:00
}
2010-12-05 13:31:39 +00:00
$container -> addElement ( $columnContainer , true );
2016-07-14 19:00:47 +00:00
2015-05-15 19:16:46 +00:00
addSecurityTokenToMetaHTML ( $container );
2010-12-05 13:31:39 +00:00
$tabindex = 1 ;
parseHtml ( null , $container , 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 \" " ;
// module attributes
for ( $m = 0 ; $m < sizeof ( $modules ); $m ++ ) {
if ( sizeof ( $columns [ $modules [ $m ]]) < 1 ) continue ;
for ( $i = 0 ; $i < sizeof ( $columns [ $modules [ $m ]]); $i ++ ) {
$sampleCSV_head [] = " \" " . $columns [ $modules [ $m ]][ $i ][ '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 ] . " \" " ;
// module attributes
for ( $m = 0 ; $m < sizeof ( $modules ); $m ++ ) {
if ( sizeof ( $columns [ $modules [ $m ]]) < 1 ) continue ;
for ( $i = 0 ; $i < sizeof ( $columns [ $modules [ $m ]]); $i ++ ) {
2011-03-31 18:50:48 +00:00
if ( isset ( $columns [ $modules [ $m ]][ $i ][ 'example' ])) {
$sampleCSV_row [] = '"' . $columns [ $modules [ $m ]][ $i ][ 'example' ] . '"' ;
}
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
?>