getConfiguredTypes();
$profileClasses = array();
$profileClassesTemp = array();
foreach ($types as $type) {
if ($type->isHidden() || !checkIfWriteAccessIsAllowed($type->getId())) {
continue;
}
$profileClassesTemp[$type->getAlias()] = array(
'typeId' => $type->getId(),
'scope' => $type->getScope(),
'title' => $type->getAlias(),
'icon' => $type->getIcon(),
'profiles' => "");
}
$profileClassesKeys = array_keys($profileClassesTemp);
natcasesort($profileClassesKeys);
$profileClassesKeys = array_values($profileClassesKeys);
for ($i = 0; $i < sizeof($profileClassesKeys); $i++) {
$profileClasses[] = $profileClassesTemp[$profileClassesKeys[$i]];
}
// check if user is logged in, if not go to login
if (!$_SESSION['ldap'] || !$_SESSION['ldap']->server()) {
metaRefresh("../login.php");
exit;
}
// check if new profile should be created
elseif (isset($_POST['createProfileButton'])) {
metaRefresh("profilepage.php?type=" . htmlspecialchars($_POST['createProfile']));
exit;
}
// check if a profile should be edited
for ($i = 0; $i < sizeof($profileClasses); $i++) {
if (isset($_POST['editProfile_' . $profileClasses[$i]['typeId']]) || isset($_POST['editProfile_' . $profileClasses[$i]['typeId'] . '_x'])) {
metaRefresh("profilepage.php?type=" . htmlspecialchars($profileClasses[$i]['typeId']) .
"&edit=" . htmlspecialchars($_POST['profile_' . $profileClasses[$i]['typeId']]));
exit;
}
}
include '../main_header.php';
echo "
\n";
echo "\n";
echo "
\n";
for ($i = 0; $i < sizeof($profileClasses); $i++) {
$typeId = $profileClasses[$i]['typeId'];
$scope = $profileClasses[$i]['scope'];
$importOptions = array();
foreach ($configProfiles as $profile) {
$typeManagerImport = new TypeManager($serverProfiles[$profile]);
$typesImport = $typeManagerImport->getConfiguredTypesForScope($scope);
foreach ($typesImport as $typeImport) {
if (($profile != $_SESSION['config']->getName()) || ($typeImport->getId() != $typeId)) {
$accountProfiles = \LAM\PROFILES\getAccountProfiles($typeImport->getId(), $profile);
if (!empty($accountProfiles)) {
for ($p = 0; $p < sizeof($accountProfiles); $p++) {
$importOptions[$profile][$typeImport->getAlias() . ': ' . $accountProfiles[$p]] = $profile . '##' . $typeImport->getId() . '##' . $accountProfiles[$p];
}
}
}
}
}
//import dialog
echo "\n";
echo "';
echo "
\n";
//export dialog
echo "\n";
echo "';
echo "
\n";
}
// form for delete action
echo '';
include '../main_footer.php';
/**
* Imports the selected account profiles.
*
* @param string $typeId type id
* @param array $options options
* @param \LAMConfig[] $serverProfiles server profiles (name => profile object)
* @param TypeManager $typeManager type manager
* @return \htmlStatusMessage message or null
*/
function importProfiles($typeId, $options, &$serverProfiles, TypeManager &$typeManager) {
foreach ($options as $option) {
$sourceConfName = $option['conf'];
$sourceTypeId = $option['typeId'];
$sourceName = $option['name'];
$sourceTypeManager = new TypeManager($serverProfiles[$sourceConfName]);
$sourceType = $sourceTypeManager->getConfiguredType($sourceTypeId);
$targetType = $typeManager->getConfiguredType($typeId);
if (($sourceType !== null) && ($targetType !== null)) {
try {
\LAM\PROFILES\copyAccountProfile($sourceType, $sourceName, $targetType);
}
catch (\LAMException $e) {
return new \htmlStatusMessage('ERROR', $e->getTitle(), $e->getMessage());
}
}
}
return new \htmlStatusMessage('INFO', _('Import successful'));
}
/**
* Exports the selected account profile.
*
* @param string $typeId source type id
* @param string $name profile name
* @param array $options options
* @param \LAMConfig[] $serverProfiles server profiles (name => profile object)
* @param TypeManager $typeManager type manager
* @return \htmlStatusMessage message or null
*/
function exportProfiles($typeId, $name, $options, &$serverProfiles, TypeManager &$typeManager) {
$sourceType = $typeManager->getConfiguredType($typeId);
if ($sourceType === null) {
return null;
}
foreach ($options as $option) {
$targetConfName = $option['conf'];
if ($targetConfName == 'templates*') {
try {
\LAM\PROFILES\copyAccountProfileToTemplates($sourceType, $name);
}
catch (\LAMException $e) {
return new \htmlStatusMessage('ERROR', $e->getTitle(), $e->getMessage());
}
}
else {
$targetTypeId = $option['typeId'];
$targetTypeManager = new TypeManager($serverProfiles[$targetConfName]);
$targetType = $targetTypeManager->getConfiguredType($targetTypeId);
if ($targetType !== null) {
try {
\LAM\PROFILES\copyAccountProfile($sourceType, $name, $targetType);
}
catch (\LAMException $e) {
return new \htmlStatusMessage('ERROR', $e->getTitle(), $e->getMessage());
}
}
}
}
return new \htmlStatusMessage('INFO', _('Export successful'));
}
?>