INSERT INTO core_permissions (code,permission_name,parent,permission_function,default_child,permission_namespace,"module",permission_description,permission_type,icon,ord,hidden,guest,meta) VALUES
	 ('XSFPFCR','self_profile_create_external_user','PSELF','createExternalUser','','self/profile','self','Permission to create self external user','EXE','',1,false,true,NULL);

UPDATE core_settings SET value = jsonb_set(value, '{allowExternamUserRegistration}', 'false') where setting_type ='self_settings' and setting_name ='general_configuration';	

INSERT INTO public.core_sm_states (object_name,state_code,description,allowed_from,feedback,afterhook_once,feedback_once,prevent_feedback_on_afterhook,billable,meta)
	VALUES ('core_users','WAI','Waiting activation','["","OFF"]'::jsonb,'[]'::jsonb,true,false,false,true,'{}'::jsonb);

-- Auto-generated SQL script #202301170636
UPDATE public.core_sm_states
	SET allowed_from='["WAI","UNA", "OFF", "OCC", "SBY"]'::jsonb
	WHERE object_name='core_users' and state_code='AVL';

UPDATE public.core_sm_states
	SET after_hook='require_once($_ENV[''JIVENV''][''funcFiles''][''sendMessage''][''filePath'']);

$qUser = "SELECT * FROM core_users WHERE id=".$id;
$rUser = $_ENV[''JIVENV''][''DB''][0]->query($qUser)->fetch(PDO::FETCH_ASSOC);
$recipients[] = array(
	"Name" => $rUser[''first_name''],
	"Address" => $rUser[''email'']
);

sendMessage(
	array(
		"id" => $id,
        "type" => "self_settings",
		"template" => "registration_email",
		"recipients" => $recipients
	)
);
'
	WHERE  object_name='core_users' and state_code='WAI';


INSERT INTO public.core_settings (setting_type,setting_name,value,properties,ord)
	VALUES ('self_settings','registration_email','{"body": "<!-- NAME: 1 COLUMN - FULL WIDTH --><!-- [if gte mso 15]><xml><o:OfficeDocumentSettings><o:AllowPNG/><o:PixelsPerInch>96</o:PixelsPerInch></o:OfficeDocumentSettings></xml><![endif]--><!--*|IF:MC_PREVIEW_TEXT|*--><!-- [if !gte mso 9]><!---->\n<p><span class=\"mcnPreviewText\" style=\"display: none; font-size: 0px; line-height: 0px; max-height: 0px; max-width: 0px; opacity: 0; overflow: hidden; visibility: hidden; mso-hide: all;\">Thank you for creating your IamaGoodTraveller account.</span></p>\n<!--<![endif]--><!--*|END:IF|*--><center>\n<table id=\"bodyTable\" border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"0\" align=\"center\">\n<tbody>\n<tr>\n<td id=\"bodyCell\" align=\"center\" valign=\"top\"><!-- BEGIN TEMPLATE // -->\n<table border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td id=\"templatePreheader\" align=\"center\" valign=\"top\"><!-- [if (gte mso 9)|(IE)]><table align=\"center\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" width=\"600\" style=\"width:600px;\"><tr><td align=\"center\" valign=\"top\" width=\"600\" style=\"width:600px;\"><![endif]-->\n<table class=\"templateContainer\" border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"0\" align=\"center\">\n<tbody>\n<tr>\n<td class=\"preheaderContainer\" valign=\"top\">\n<table class=\"mcnImageBlock\" style=\"min-width: 100%;\" border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody class=\"mcnImageBlockOuter\">\n<tr>\n<td class=\"mcnImageBlockInner\" style=\"padding: 9px;\" valign=\"top\">\n<table class=\"mcnImageContentContainer\" style=\"min-width: 100%;\" border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"0\" align=\"left\">\n<tbody>\n<tr>\n<td class=\"mcnImageContent\" style=\"text-align: center; padding: 0 9px 0 9px;\" valign=\"top\"><img class=\"mcnImage\" style=\"max-width: 150px; padding-bottom: 0px; display: inline !important; vertical-align: bottom; border-radius: 0%;\" src=\"https://www.jivalabs.com/assets/img/Jiva-LABS-Signature.png\" alt=\"\" width=\"150\" align=\"middle\" /></td>\n</tr>\n</tbody>\n</table>\n</td>\n</tr>\n</tbody>\n</table>\n</td>\n</tr>\n</tbody>\n</table>\n<!-- [if (gte mso 9)|(IE)]></td></tr></table><![endif]--></td>\n</tr>\n<tr>\n<td id=\"templateHeader\" align=\"center\" valign=\"top\"><!-- [if (gte mso 9)|(IE)]><table align=\"center\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" width=\"600\" style=\"width:600px;\"><tr><td align=\"center\" valign=\"top\" width=\"600\" style=\"width:600px;\"><![endif]-->\n<table class=\"templateContainer\" border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"0\" align=\"center\">\n<tbody>\n<tr>\n<td class=\"headerContainer\" valign=\"top\">\n<table class=\"mcnTextBlock\" style=\"min-width: 100%;\" border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody class=\"mcnTextBlockOuter\">\n<tr>\n<td class=\"mcnTextBlockInner\" style=\"padding-top: 9px;\" valign=\"top\"><!-- [if mso]> <table align=\"left\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" width=\"100%\" style=\"width:100%;\"> <tr> <![endif]--> <!-- [if mso]> <td valign=\"top\" width=\"600\" style=\"width:600px;\"> <![endif]-->\n<table class=\"mcnTextContentContainer\" style=\"max-width: 100%; min-width: 100%;\" border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"0\" align=\"left\">\n<tbody>\n<tr>\n<td class=\"mcnTextContent\" style=\"padding: 0 18px 9px 18px;\" valign=\"top\">\n<h1 class=\"null\">Please verify your email</h1>\n</td>\n</tr>\n</tbody>\n</table>\n<!-- [if mso]> </td> <![endif]--> <!-- [if mso]> </tr> </table> <![endif]--></td>\n</tr>\n</tbody>\n</table>\n<table class=\"mcnTextBlock\" style=\"min-width: 100%;\" border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody class=\"mcnTextBlockOuter\">\n<tr>\n<td class=\"mcnTextBlockInner\" style=\"padding-top: 9px;\" valign=\"top\"><!-- [if mso]> <table align=\"left\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" width=\"100%\" style=\"width:100%;\"> <tr> <![endif]--> <!-- [if mso]> <td valign=\"top\" width=\"600\" style=\"width:600px;\"> <![endif]-->\n<table class=\"mcnTextContentContainer\" style=\"max-width: 100%; min-width: 100%;\" border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"0\" align=\"left\">\n<tbody>\n<tr>\n<td class=\"mcnTextContent\" style=\"padding: 0 18px 9px 18px;\" valign=\"top\">\n<div>\n<p id=\"docs-internal-guid-60c6a318-7fff-3556-99e4-ed73b5e819a5\" dir=\"ltr\">Hi {firstname},<br /><br />Thank you for creating your account. To continue, please verify your email address by clicking the link below.</p>\n</div>\n</td>\n</tr>\n</tbody>\n</table>\n<!-- [if mso]> </td> <![endif]--> <!-- [if mso]> </tr> </table> <![endif]--></td>\n</tr>\n</tbody>\n</table>\n<table class=\"mcnButtonBlock\" style=\"min-width: 100%;\" border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody class=\"mcnButtonBlockOuter\">\n<tr>\n<td class=\"mcnButtonBlockInner\" style=\"padding: 0 18px 18px 18px;\" align=\"center\" valign=\"top\">\n<table class=\"mcnButtonContentContainer\" style=\"border-collapse: separate !important; border-radius: 4px; background-color: #5db8d5;\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td class=\"mcnButtonContent\" style=\"font-family: Arial; font-size: 16px; padding: 18px;\" align=\"center\" valign=\"middle\"><a class=\"mcnButton \" style=\"font-weight: bold; letter-spacing: normal; line-height: 100%; text-align: center; text-decoration: none; color: #ffffff;\" title=\"verify your email\" href=\"https://www.jivalabs.com/verify/{verifytoken}\" target=\"_blank\" rel=\"noopener\">verify your email</a></td>\n</tr>\n</tbody>\n</table>\n</td>\n</tr>\n</tbody>\n</table>\n<table class=\"mcnTextBlock\" style=\"min-width: 100%;\" border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody class=\"mcnTextBlockOuter\">\n<tr>\n<td class=\"mcnTextBlockInner\" style=\"padding-top: 9px;\" valign=\"top\"><!-- [if mso]> <table align=\"left\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" width=\"100%\" style=\"width:100%;\"> <tr> <![endif]--> <!-- [if mso]> <td valign=\"top\" width=\"600\" style=\"width:600px;\"> <![endif]-->\n<table class=\"mcnTextContentContainer\" style=\"max-width: 100%; min-width: 100%;\" border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"0\" align=\"left\">\n<tbody>\n<tr>\n<td class=\"mcnTextContent\" style=\"padding: 0 18px 9px 18px;\" valign=\"top\">\n<div>\n<p>Should you require assistance, we are at your full disposal. Ask your question(s) or request a teleconference to <a href=\"mailto:support@jivalabs.com\">support@jivalabs.com</a>.</p>\n<p class=\"font-italic\"><em>The JivaLabs Team</em></p>\n</div>\n</td>\n</tr>\n</tbody>\n</table>\n<!-- [if mso]> </td> <![endif]--> <!-- [if mso]> </tr> </table> <![endif]--></td>\n</tr>\n</tbody>\n</table>\n</td>\n</tr>\n</tbody>\n</table>\n<!-- [if (gte mso 9)|(IE)]></td></tr></table><![endif]--></td>\n</tr>\n<tr>\n<td id=\"templateBody\" align=\"center\" valign=\"top\"><!-- [if (gte mso 9)|(IE)]><table align=\"center\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" width=\"600\" style=\"width:600px;\"><tr><td align=\"center\" valign=\"top\" width=\"600\" style=\"width:600px;\"><![endif]-->\n<table class=\"templateContainer\" border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"0\" align=\"center\">\n<tbody>\n<tr>\n<td class=\"bodyContainer\" valign=\"top\">&nbsp;</td>\n</tr>\n</tbody>\n</table>\n<!-- [if (gte mso 9)|(IE)]></td></tr></table><![endif]--></td>\n</tr>\n<tr>\n<td id=\"templateFooter\" align=\"center\" valign=\"top\"><!-- [if (gte mso 9)|(IE)]><table align=\"center\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" width=\"600\" style=\"width:600px;\"><tr><td align=\"center\" valign=\"top\" width=\"600\" style=\"width:600px;\"><![endif]-->\n<table class=\"templateContainer\" border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"0\" align=\"center\">\n<tbody>\n<tr>\n<td class=\"footerContainer\" valign=\"top\">&nbsp;</td>\n</tr>\n</tbody>\n</table>\n<!-- [if (gte mso 9)|(IE)]></td></tr></table><![endif]--></td>\n</tr>\n</tbody>\n</table>\n<!-- // END TEMPLATE --></td>\n</tr>\n</tbody>\n</table>\n</center>", "query": "select first_name as FirstName, last_name as LastName, username as Username, email as Email, verify_token as verifytoken from core_users where id = :id", "types": {"body": "html", "message": "EMAIL", "subject": "text"}, "sender": {"Name": "Normiranec", "Address": "noreply@jivalabs.com"}, "subject": "Verify your email", "availableFields": ["FirstName", "LastName", "Username", "Email", "VerificationUrl"]}'::jsonb,'{"section_desc": "Change email templates", "section_icon": "fas fa-envelope-open-text", "setting_desc": "Registration email template", "setting_icon": "fas fa-door-open", "section_button": "View templates", "setting_button": "Edit"}'::jsonb,100);

