diff --git a/lam/lib/modules.inc b/lam/lib/modules.inc index dc14b2cd..a8cdbfba 100644 --- a/lam/lib/modules.inc +++ b/lam/lib/modules.inc @@ -1269,7 +1269,7 @@ class accountContainer { $rightGroup = new htmlGroup(); $rightGroup->alignment = htmlElement::ALIGN_RIGHT; // profile selection - $profilelist = getAccountProfiles($this->type->getId()); + $profilelist = \LAM\PROFILES\getAccountProfiles($this->type->getId()); if (sizeof($profilelist) > 0) { $rightGroup->addElement(new htmlSelect('accountContainerSelectLoadProfile', $profilelist, array($this->lastLoadedProfile))); $profileButton = new htmlButton('accountContainerLoadProfile', _('Load profile')); @@ -1412,7 +1412,7 @@ class accountContainer { */ private function loadProfileIfRequested() { if (isset($_POST['accountContainerLoadProfile']) && isset($_POST['accountContainerSelectLoadProfile'])) { - $profile = loadAccountProfile($_POST['accountContainerSelectLoadProfile'], $this->type->getId()); + $profile = \LAM\PROFILES\loadAccountProfile($_POST['accountContainerSelectLoadProfile'], $this->type->getId()); $this->lastLoadedProfile = $_POST['accountContainerSelectLoadProfile']; // pass profile to each module $modules = array_keys($this->module); @@ -1707,7 +1707,7 @@ class accountContainer { } // sort module buttons $this->sortModules(); - $profile = loadAccountProfile('default', $this->type->getId()); + $profile = \LAM\PROFILES\loadAccountProfile('default', $this->type->getId()); // pass profile to each module $modules = array_keys($this->module); foreach ($modules as $module) $this->module[$module]->load_profile($profile); diff --git a/lam/lib/pdfstruct.inc b/lam/lib/pdfstruct.inc index 977beb96..c2bb59ce 100644 --- a/lam/lib/pdfstruct.inc +++ b/lam/lib/pdfstruct.inc @@ -324,4 +324,39 @@ function isValidPDFStructureName($name) { return preg_match('/[a-zA-Z0-9\-\_]+/',$name) === 1; } +/** + * Installs template structures to the current server profile. + */ +function installPDFTemplates() { + $templatePath = dirname(__FILE__) . '/../config/templates/pdf'; + $templateDir = @dir($templatePath); + $allTemplates = array(); + if ($templateDir) { + $entry = $templateDir->read(); + while ($entry){ + $parts = explode('.', $entry); + if ((strlen($entry) > 3) && (sizeof($parts) == 3)) { + $name = $parts[0]; + $scope = $parts[1]; + $allTemplates[$scope][] = $name; + } + $entry = $templateDir->read(); + } + } + $basePath = dirname(__FILE__) . '/../config/pdf/' . $_SESSION['config']->getName() . '/'; + $typeManager = new \LAM\TYPES\TypeManager(); + foreach ($typeManager->getConfiguredTypes() as $type) { + if (empty($allTemplates[$type->getScope()])) { + continue; + } + foreach ($allTemplates[$type->getScope()] as $templateName) { + $path = $basePath . $templateName . '.' . $type->getId() . '.xml'; + if (!is_file($path)) { + $template = $templatePath . '/' . $templateName . '.' . $scope . '.xml'; + @copy($template, $path); + } + } + } +} + ?> diff --git a/lam/lib/profiles.inc b/lam/lib/profiles.inc index 69c1c846..9743324c 100644 --- a/lam/lib/profiles.inc +++ b/lam/lib/profiles.inc @@ -1,4 +1,6 @@ read(); + while ($entry){ + $parts = explode('.', $entry); + if ((strlen($entry) > 3) && (sizeof($parts) == 2)) { + $name = $parts[0]; + $scope = $parts[1]; + $allTemplates[$scope][] = $name; + } + $entry = $templateDir->read(); + } + } + $basePath = dirname(__FILE__) . '/../config/profiles/' . $_SESSION['config']->getName() . '/'; + $typeManager = new \LAM\TYPES\TypeManager(); + foreach ($typeManager->getConfiguredTypes() as $type) { + if (empty($allTemplates[$type->getScope()])) { + continue; + } + foreach ($allTemplates[$type->getScope()] as $templateName) { + $path = $basePath . $templateName . '.' . $type->getId(); + if (!is_file($path)) { + $template = $templatePath . '/' . $templateName . '.' . $scope; + @copy($template, $path); + } + } + } +} + ?> diff --git a/lam/lib/upgrade.inc b/lam/lib/upgrade.inc index 1ad9eb68..c8e0f762 100644 --- a/lam/lib/upgrade.inc +++ b/lam/lib/upgrade.inc @@ -112,13 +112,6 @@ function upgradeConfigToServerProfileFolders($profiles) { return; } - // copy default configs - if (!file_exists('../config/templates')) { - @mkdir('../config/templates', 0700); - recursiveCopy('../config/pdf/', '../config/templates/pdf/', $profiles, 'default.'); - recursiveCopy('../config/profiles/', '../config/templates/profiles/', $profiles, 'default.'); - } - foreach ($profiles as $profile) { // upgrade PDF configs $dir = '../config/pdf/' . $profile; diff --git a/lam/templates/main.php b/lam/templates/main.php index de1a816f..b6f49c1c 100644 --- a/lam/templates/main.php +++ b/lam/templates/main.php @@ -1,4 +1,5 @@ getConfiguredTypes(); foreach ($types as $type) { $info = @ldap_read($_SESSION['ldap']->server(), escapeDN($type->getSuffix()), "(objectClass=*)", array('objectClass'), 0, 0, 0, LDAP_DEREF_NEVER); @@ -68,4 +74,5 @@ else { metaRefresh("tree/treeViewContainer.php"); } } + ?> diff --git a/lam/templates/profedit/profilemain.php b/lam/templates/profedit/profilemain.php index aac6bd3c..74b434c7 100644 --- a/lam/templates/profedit/profilemain.php +++ b/lam/templates/profedit/profilemain.php @@ -122,7 +122,7 @@ if (isset($_POST['deleteProfile']) && ($_POST['deleteProfile'] == 'true')) { die(); } // delete profile - if (delAccountProfile($_POST['profileDeleteName'], $_POST['profileDeleteType'])) { + if (\LAM\PROFILES\delAccountProfile($_POST['profileDeleteName'], $_POST['profileDeleteType'])) { $message = new htmlStatusMessage('INFO', _('Deleted profile.'), $type->getAlias() . ': ' . htmlspecialchars($_POST['profileDeleteName'])); $message->colspan = 10; $container->addElement($message, true); @@ -187,7 +187,7 @@ if (!empty($_POST['export'])) { // get list of profiles for each account type for ($i = 0; $i < sizeof($profileClasses); $i++) { - $profileList = getAccountProfiles($profileClasses[$i]['typeId']); + $profileList = \LAM\PROFILES\getAccountProfiles($profileClasses[$i]['typeId']); natcasesort($profileList); $profileClasses[$i]['profiles'] = $profileList; } @@ -276,7 +276,7 @@ for ($i = 0; $i < sizeof($profileClasses); $i++) { $typesImport = $typeManagerImport->getConfiguredTypesForScope($scope); foreach ($typesImport as $typeImport) { if (($profile != $_SESSION['config']->getName()) || ($typeImport->getId() != $typeId)) { - $accountProfiles = getAccountProfiles($typeImport->getId(), $profile); + $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]; @@ -396,7 +396,7 @@ function importProfiles($typeId, $options, &$serverProfiles, &$typeManager) { $targetType = $typeManager->getConfiguredType($typeId); if (($sourceType != null) && ($targetType != null)) { try { - \copyAccountProfile($sourceType, $sourceName, $targetType); + \LAM\PROFILES\copyAccountProfile($sourceType, $sourceName, $targetType); } catch (\LAMException $e) { return new \htmlStatusMessage('ERROR', $e->getTitle(), $e->getMessage()); @@ -425,7 +425,7 @@ function exportProfiles($typeId, $name, $options, &$serverProfiles, &$typeManage $targetConfName = $option['conf']; if ($targetConfName == 'templates*') { try { - \copyAccountProfileToTemplates($sourceType, $name); + \LAM\PROFILES\copyAccountProfileToTemplates($sourceType, $name); } catch (\LAMException $e) { return new \htmlStatusMessage('ERROR', $e->getTitle(), $e->getMessage()); @@ -437,7 +437,7 @@ function exportProfiles($typeId, $name, $options, &$serverProfiles, &$typeManage $targetType = $targetTypeManager->getConfiguredType($targetTypeId); if ($targetType != null) { try { - \copyAccountProfile($sourceType, $name, $targetType); + \LAM\PROFILES\copyAccountProfile($sourceType, $name, $targetType); } catch (\LAMException $e) { return new \htmlStatusMessage('ERROR', $e->getTitle(), $e->getMessage()); diff --git a/lam/templates/profedit/profilepage.php b/lam/templates/profedit/profilepage.php index 1e0aef15..690083a9 100644 --- a/lam/templates/profedit/profilepage.php +++ b/lam/templates/profedit/profilepage.php @@ -135,7 +135,7 @@ if (isset($_POST['save'])) { $errors = checkProfileOptions($_POST['accounttype'], $options); if (sizeof($errors) == 0) { // input data is valid, save profile // save profile - if (saveAccountProfile($options, $_POST['profname'], $_POST['accounttype'])) { + if (\LAM\PROFILES\saveAccountProfile($options, $_POST['profname'], $_POST['accounttype'])) { metaRefresh('profilemain.php?savedSuccessfully=' . $_POST['profname']); exit(); } @@ -181,7 +181,7 @@ if (isset($_POST['save'])) { } } elseif (isset($_GET['edit'])) { - $old_options = loadAccountProfile($_GET['edit'], $type->getId()); + $old_options = \LAM\PROFILES\loadAccountProfile($_GET['edit'], $type->getId()); } // display formular