Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Leaf 4084 - custom emails added to subordinate #2223

Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 47 additions & 5 deletions LEAF_Request_Portal/utils/LEAF_importStandardConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,17 @@

$debug = false;

$res = $db->query_kv('SELECT * FROM settings', 'setting', 'data');

// For Jira Ticket:LEAF-2471/remove-all-http-redirects-from-code
//$protocol = isset($_SERVER['HTTPS']) ? 'https://' : 'http://';
$protocol = 'https://';
$siteRootURL = $protocol . HTTP_HOST;
$relativePath = trim(str_replace($siteRootURL, '', $res['national_linkedPrimary']));

$relativePath = trim(str_replace($siteRootURL, '', LEAF_SETTINGS['national_linkedPrimary']));
$tempFolder = $_SERVER['DOCUMENT_ROOT'] . $relativePath . 'files/temp/';
$copy_custom_templates = $_SERVER['DOCUMENT_ROOT'] . $relativePath . 'templates/email/custom_override/';
$paste_custom_templates = getenv('APP_LIB_PATH') . '../' . PORTAL_PATH . '/templates/email/custom_override/';

if($res['siteType'] != 'national_subordinate') {
if($settings['siteType'] != 'national_subordinate') {
jampaul3 marked this conversation as resolved.
Show resolved Hide resolved
echo "ERROR: This is not a national subordinate site.";
exit();
}
Expand Down Expand Up @@ -65,7 +66,6 @@ function importTable($db, $tempFolder, $table) {
break;
default:
exit();
break;
}

$resFields = $db->query("DESCRIBE {$table}");
Expand Down Expand Up @@ -100,7 +100,49 @@ function importTable($db, $tempFolder, $table) {
importTable($db, $tempFolder, 'workflow_routes');
importTable($db, $tempFolder, 'step_modules');

if (is_dir($paste_custom_templates) && is_dir($copy_custom_templates)) {
// remove files from templates/email/custom_override on subordinate
$files = glob($paste_custom_templates . '*');

// Deleting all the files in the list
foreach ($files as $file) {
if(is_file($file)) {
// Delete the given file
unlink($file);
}
}

// copy templates/email/custom_override from primary to subordinate
copyDirectory($copy_custom_templates, $paste_custom_templates);
}

$db->query("ALTER TABLE `records_dependencies` ADD CONSTRAINT `fk_records_dependencyID` FOREIGN KEY (`dependencyID`) REFERENCES `dependencies`(`dependencyID`) ON DELETE RESTRICT ON UPDATE RESTRICT;");
$db->query("ALTER TABLE `dependency_privs` ADD CONSTRAINT `fk_privs_dependencyID` FOREIGN KEY (`dependencyID`) REFERENCES `dependencies`(`dependencyID`) ON DELETE RESTRICT ON UPDATE RESTRICT;");
$db->query("ALTER TABLE `category_count` ADD CONSTRAINT `category_count_ibfk_1` FOREIGN KEY (`categoryID`) REFERENCES `categories`(`categoryID`) ON DELETE RESTRICT ON UPDATE RESTRICT;");
$db->query("ALTER TABLE `category_privs` ADD CONSTRAINT `category_privs_ibfk_2` FOREIGN KEY (`categoryID`) REFERENCES `categories`(`categoryID`) ON DELETE RESTRICT ON UPDATE RESTRICT;");

function copyDirectory($source, $destination) {
jampaul3 marked this conversation as resolved.
Show resolved Hide resolved
$files = scandir($source);

foreach ($files as $file) {
if ($file !== '.' && $file !== '..') {
// not sure if the / is needed here
jampaul3 marked this conversation as resolved.
Show resolved Hide resolved
$sourceFile = $source . '/' . $file;
$destinationFile = $destination . '/' . $file;

if (is_dir($sourceFile)) {
copyDirectory($sourceFile, $destinationFile);
} else {
if (is_dir($destinationFile)) {
copy($sourceFile, $destinationFile);
} else {
// theoretically this should never be hit. All portals should have the same dir structure
// thereby making this mute, but jsut in case.
mkdir($destinationFile);
copy($sourceFile, $destinationFile);
}

}
jampaul3 marked this conversation as resolved.
Show resolved Hide resolved
}
}
}
2 changes: 2 additions & 0 deletions app/libs/loaders/Leaf_autoloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@
if (!defined('DOMAIN_PATH')) define('DOMAIN_PATH', 'https://' . getenv('APP_HTTP_HOST'));
if (!defined('ORGCHART_DB')) define('ORGCHART_DB', $site_paths['orgchart_database']);
if (!defined('OC_DB')) define('OC_DB', $oc_db);
if (!defined('LEAF_SETTINGS')) define('LEAF_SETTINGS', $settings);
if (!defined('OC_SETTINGS')) define('OC_SETTINGS', $oc_settings);

if (!empty($site_paths['portal_database'])) {
if (!defined('PORTAL_DB')) define('PORTAL_DB', $site_paths['portal_database']);
Expand Down
Loading