PHP-Code:
$GLOBALS['TL_DCA']['tl_member']['fields']['profilepic'] = array
(
'label' => &$GLOBALS['TL_LANG']['tl_member']['profilepic'],
'exclude' => true,
'inputType' => 'fineUploader',
'eval' => array('storeFile'=>true, 'mandatory'=>false, 'uploadFolder' => 'files/user/tmp/','feEditable'=>true, 'feViewable'=>true, "tl_class" => "w50 wizard", 'feGroup'=>'address', 'extensions' => 'jpg,jpeg,png', 'addToDbafs' => true,),
'sql' => "blob NULL"
);
$GLOBALS['TL_DCA']['tl_member']['fields']['verifypic'] = array
(
'label' => &$GLOBALS['TL_LANG']['tl_member']['verifypic'],
'exclude' => true,
'inputType' => 'fineUploader',
'eval' => array('storeFile'=>true, 'uploadFolder' => 'files/user/tmp/', 'mandatory'=>false, 'feEditable'=>true, 'feViewable'=>true, "tl_class" => "w50 wizard", 'feGroup'=>'address', 'extensions' => 'jpg,jpeg,png', 'addToDbafs' => true,),
'sql' => "blob NULL"
);
unset($GLOBALS['TL_DCA']['tl_member']['fields']['firstname']);
unset($GLOBALS['TL_DCA']['tl_member']['fields']['lastname']);
// config.php
$GLOBALS['TL_HOOKS']['createNewUser'][] = array('NewUser', 'move_upload');
$GLOBALS['TL_HOOKS']['closeAccount'][] = array('\Contao\DeletedUser', 'remove_from_hook');
$GLOBALS['TL_DCA']['tl_member']['config']['ondelete_callback'][] = [
\Contao\DeletedUser::class, 'remove_information'
];
class NewUser {
public function move_upload($intId, $arrData)
{
// Den Datensatz modifizieren
// Identify directories
$destination = "files/user/".$arrData["username"]."/";
$profilepic = FilesModel::findByPk($arrData["profilepic"]);
mkdir("../".$destination."/profilepic/");
$objFile = new \File($profilepic->path, false);
$objFile->renameTo($destination."profilepic/".$profilepic->name);
$profilepic = Contao\Dbafs::moveResource($profilepic->path, $destination."profilepic/".$profilepic->name);
mkdir("../".$destination."/verifypic/");
echo "<pre>";
$verifypic = FilesModel::findByPk($arrData["verifypic"]);
$objFile = new \File($verifypic->path, false);
var_dump($objFile);
$objFile->renameTo($destination."verifypic/".$verifypic->name);
var_dump($verifypic);
$verifypic = Contao\Dbafs::moveResource($verifypic->path, $destination."verifypic/".$verifypic->name);
$gallery = FilesModel::findMultipleByIds($arrData["gallery"]);
foreach($gallery as $img) {
$objFile = new \File($img->path, false);
$objFile->renameTo($destination.$img->name);
$img = Contao\Dbafs::moveResource($img->path, $destination.$img->name);
}
}
}
$GLOBALS['TL_DCA']['tl_member']['fields']['gallery'] = array
(
'label' => &$GLOBALS['TL_LANG']['tl_table']['gallery'],
'exclude' => false,
'inputType' => 'fineUploader',
'eval' => array
(
'storeFile' => true, // Mandatory to store the file on the server
'multiple' => true, // Allow multiple files to be uploaded
'uploadFolder' => 'files/user/tmp/', // Upload target directory (can also be a Contao file system UUID)
//'useHomeDir' => true, // Upload to the FE member home directory (overrides "uploadFolder", can also be a Contao file system UUID)
//'uploaderConfig' => "['debug': true]", // Custom uploader configuration that gets merged with the other params
//'uploaderLimit' => 4, // Maximum files that can be uploaded
'addToDbafs' => true, // Add files to the database assisted file system
'extensions' => 'jpg,jpeg,png', // Allowed extension types
//'maxlength' => 2048000, // Maximum file size (is ignored if you use chunking!)
//'maxWidth' => 800, // Maximum width (applies to images only)
//'maxHeight' => 600, // Maximum height (applies to images only)
'doNotOverwrite' => true, // Do not overwrite files in destination folder
//'uploadButtonLabel' => 'Upload images', // Custom upload button label
'maxConnections' => 3, // Maximum allowable concurrent requests
'feViewable' => true,
'feEditable'=>true,
"tl_class" => "w50 wizard",
// Upload the files directly to the destination folder. If not set, then the files are first uploaded
// to the temporary folder and moved to the destination folder only when the form is submitted
//'directUpload' => true,
// Set a custom thumbnail image size that is generated upon image upload
//'imageSize' => [160, 120, 'center_center'],
// You can also use the default features of fileTree widget such as:
// isGallery, isDownloads
// The "orderField" attribute is not valid (see #9)
),
'sql' => "blob NULL"
);
/**
* Class tl_member_memberlist
*
* Provide miscellaneous methods that are used by the data configuration array.
* @copyright Helmut Schottmüller 2013
* @author Helmut Schottmüller <https://github.com/hschottm>
* @package Controller
*/
class tl_member_memberlist extends Backend
{
/**
* Return all editable fields of table tl_member
* @return array
*/
public function getViewableMemberProperties()
{
$return = array();
$this->loadLanguageFile('tl_member');
$this->loadDataContainer('tl_member');
foreach ($GLOBALS['TL_DCA']['tl_member']['fields'] as $k=>$v)
{
if ($k == 'username' || $k == 'password' || $k == 'newsletter' || $k == 'publicFields' || $k == 'allowEmail')
{
continue;
}
/*
echo $k;
echo "-";
echo "<pre>";
var_dump($v);
echo "</pre>";
echo "<br />";
*/
if ($v['eval']['feViewable'])
{
$return[$k] = $GLOBALS['TL_DCA']['tl_member']['fields'][$k]['label'][0];
}
}
return $return;
}
}