diff --git a/account.php b/account.php index 41c5a482fd9bcdf19e8c1dbc0c473d0da8e56e97..b9effe186f28a96db075691ddfb84a4a4a05999c 100644 --- a/account.php +++ b/account.php @@ -37,6 +37,7 @@ elseif ($thisclient) { // Existing client (with an account) updating profile else { $user = User::lookup($thisclient->getId()); + $content = Page::lookup(Page::lookupByType('registration-thanks')); $inc = isset($_GET['confirmed']) ? 'registration.confirmed.inc.php' : 'profile.inc.php'; } @@ -80,6 +81,7 @@ elseif ($_POST) { if (!$errors) { switch ($_POST['do']) { case 'create': + $content = Page::lookup(Page::lookupByType('registration-confirm')); $inc = 'register.confirm.inc.php'; $acct->sendResetEmail('registration-client'); } diff --git a/include/class.i18n.php b/include/class.i18n.php index 5392446120db7060b610eeff3c88f7816a2d86f0..b7e7289430bf993618579a5b2f5726d7c682e100 100644 --- a/include/class.i18n.php +++ b/include/class.i18n.php @@ -24,6 +24,11 @@ class Internationalization { var $langs = array('en_US'); function Internationalization($language=false) { + global $cfg; + + if ($cfg && ($lang = $cfg->getSystemLanguage())) + array_unshift($this->langs, $language); + if ($language) array_unshift($this->langs, $language); } @@ -90,6 +95,7 @@ class Internationalization { foreach (array('landing','thank-you','offline', 'registration-staff', 'pwreset-staff', 'banner-staff', 'registration-client', 'pwreset-client', 'banner-client', + 'registration-confirm', 'registration-thanks', 'access-link') as $type) { $tpl = $this->getTemplate("templates/page/{$type}.yaml"); if (!($page = $tpl->getData())) @@ -100,12 +106,16 @@ class Internationalization { .', lang='.db_input($tpl->getLang()) .', notes='.db_input($page['notes']) .', created=NOW(), updated=NOW(), isactive=1'; - if (db_query($sql) && ($id = db_insert_id())) + if (db_query($sql) && ($id = db_insert_id()) + && in_array($type, array('landing', 'thank-you', 'offline'))) $_config->set("{$type}_page_id", $id); } // Default Language $_config->set('system_language', $this->langs[0]); + // content_id defaults to the `id` field value + db_query('UPDATE '.PAGE_TABLE.' SET content_id=id'); + // Canned response examples if (($tpl = $this->getTemplate('templates/premade.yaml')) && ($canned = $tpl->getData())) { diff --git a/include/client/login.inc.php b/include/client/login.inc.php index c4b865d2e9e65cf9ed771676909abb89b0f4e075..effc210731ae5c75fd989e4d36a5d72522ff74f2 100644 --- a/include/client/login.inc.php +++ b/include/client/login.inc.php @@ -4,7 +4,7 @@ if(!defined('OSTCLIENTINC')) die('Access Denied'); $email=Format::input($_POST['luser']?:$_GET['e']); $passwd=Format::input($_POST['lpasswd']?:$_GET['t']); -$content = Page::lookup(Page::getIdByType('registration-policy')); +$content = Page::lookup(Page::getIdByType('banner-client')); ?> <h1><?php echo Format::display($content->getName()); ?></h1> diff --git a/include/client/register.confirm.inc.php b/include/client/register.confirm.inc.php index 7e8ed820e653b1602bfc49ebe9a263934f523490..2f70d5c5494862fe36c06820758ce44ea04cfd04 100644 --- a/include/client/register.confirm.inc.php +++ b/include/client/register.confirm.inc.php @@ -1,3 +1,9 @@ +<?php if ($content) { ?> +<h1><?php echo Format::display($content->getName()); ?></h1> +<p><?php +echo Format::display($content->getBody()); ?> +</p> +<?php } else { ?> <h1>Account Registration</h1> <p> <strong>Thanks for registering for an account.</strong> @@ -6,4 +12,4 @@ We've just sent you an email to the address you entered. Please follow the link in the email to confirm your account and gain access to your tickets. </p> - +<?php } ?> diff --git a/include/client/register.confirmed.inc.php b/include/client/register.confirmed.inc.php index 047bdcb6d89cb905dcbd00c40b8dd8ae9b84fde6..5a739aac1ff2261d4be3f5b7bd24a698771a1400 100644 --- a/include/client/register.confirmed.inc.php +++ b/include/client/register.confirmed.inc.php @@ -1,3 +1,9 @@ +<?php if ($content) { ?> +<h1><?php echo Format::display($content->getName()); ?></h1> +<p><?php +echo Format::display($content->getBody()); ?> +</p> +<?php } else { ?> <h1>Account Registration</h1> <p> <strong>Thanks for registering for an account.</strong> @@ -7,3 +13,4 @@ You've confirmed your email address and successfully activated your account. You may proceed to check on previously opened tickets or open a new ticket. </p> <p><em>Your friendly support center</em></p> +<?php } ?> diff --git a/include/i18n/en_US/config.yaml b/include/i18n/en_US/config.yaml index 17c7083c31afd188c833e97ce2727fd01c641b54..9ec6537a20eaf27afa0a7568a7c7048a1237ccd0 100644 --- a/include/i18n/en_US/config.yaml +++ b/include/i18n/en_US/config.yaml @@ -81,3 +81,4 @@ core: random_ticket_ids: 1 log_level: 2 log_graceperiod: 12 + client_registration: 'public' diff --git a/include/i18n/en_US/templates/page/registration-client.yaml b/include/i18n/en_US/templates/page/registration-client.yaml index 3f8586f8c0f8bd6db3b4acd83cffb1907d46f6e9..abc88159708bf854b5f8846ea1f2a14cfdd992ce 100644 --- a/include/i18n/en_US/templates/page/registration-client.yaml +++ b/include/i18n/en_US/templates/page/registration-client.yaml @@ -9,7 +9,7 @@ notes: > Confirmation email sent to clients when accounts are created for them by staff or via the client portal. This email serves as an email address - verification. + verification. Please use %{link} somewhere in the body. name: "Welcome to %{company.name}" body: > <h3><strong>Hi %{user.name.first},</strong></h3> We've created an diff --git a/include/i18n/en_US/templates/page/registration-confirm.yaml b/include/i18n/en_US/templates/page/registration-confirm.yaml new file mode 100644 index 0000000000000000000000000000000000000000..00aa6880940fd5a32fda2362fee360bde992e126 --- /dev/null +++ b/include/i18n/en_US/templates/page/registration-confirm.yaml @@ -0,0 +1,22 @@ +# +# registration-confirm.yaml +# +# Template of the page shown to the user after registering for an account. +# The system will send the user an email with a link they should follow to +# confirm the account. This page should inform them of the next step in +# the process. +# +--- +notes: > + Template of the page shown to the user after registering for an account. + The system will send the user an email with a link they should follow to + confirm the account. This page should inform them of the next step in + the process. +name: "Account registration" +body: > + <strong>Thanks for registering for an account.</strong> + <p> + We've just sent you an email to the address you entered. Please follow + the link in the email to confirm your account and gain access to your + tickets. + </p> diff --git a/include/i18n/en_US/templates/page/registration-thanks.yaml b/include/i18n/en_US/templates/page/registration-thanks.yaml new file mode 100644 index 0000000000000000000000000000000000000000..adfb922a76d2d0eb5d90121e38103e4b3961a381 --- /dev/null +++ b/include/i18n/en_US/templates/page/registration-thanks.yaml @@ -0,0 +1,22 @@ +# +# registration-thanks.yaml +# +# Page shown to the user after successfully registring and confirming their +# account. This page should inform the user that the process is complete and +# that the user can now submit a ticket or access existing tickets +# +--- +notes: > + Page shown to the user after successfully registring and confirming their + account. This page should inform the user that the process is complete and + that the user can now submit a ticket or access existing tickets +name: "Account Confirmed!" +body: > + <strong>Thanks for registering for an account.</strong><br /> + <br /> + You've confirmed your email address and successfully activated your + account. You may proceed to check on previously opened tickets or open a + new ticket.<br /> + <br /> + <em>Your friendly support center</em><br /> + %{company.name} diff --git a/include/staff/settings-access.inc.php b/include/staff/settings-access.inc.php index 7bfd4b4caa040561cfd99db44516bd79891513ee..35c8ef8a53915b2220e4d9a14c79544673b8009b 100644 --- a/include/staff/settings-access.inc.php +++ b/include/staff/settings-access.inc.php @@ -150,6 +150,8 @@ while (list($type, $id, $notes, $name, $u) = db_fetch_row($res)) $manage_content = function($title, $content) use ($contents) { list($id, $name, $notes, $upd) = $contents[$content]; + $notes = explode('. ', $notes); + $notes = $notes[0]; ?><tr><td colspan="2"> <a href="#ajax.php/content/<?php echo $id; ?>/manage" onclick="javascript: @@ -157,7 +159,8 @@ $manage_content = function($title, $content) use ($contents) { return false;"><i class="icon-file-text pull-left icon-2x" style="color:#bbb;"></i> <?php echo Format::htmlchars($title); ?></a><br/> - <span class="faded"><?php echo Format::display($notes); ?> + <span class="faded" style="display:inline-block;width:90%"><?php + echo Format::display($notes); ?> <em>(Last Updated <?php echo Format::db_datetime($upd); ?>)</em></span></td></tr><?php }; ?> <tr> @@ -173,8 +176,8 @@ $manage_content = function($title, $content) use ($contents) { <em><b>Sign-In Pages</b></em> </th> </tr> - <?php $manage_content('Staff Login Banner', 'staff-banner'); ?> - <?php $manage_content('Client Sign-In Page', 'registration-policy'); ?> + <?php $manage_content('Staff Login Banner', 'banner-staff'); ?> + <?php $manage_content('Client Sign-In Page', 'banner-client'); ?> <tr> <th colspan="2"> <em><b>Client Account Registration</b></em> diff --git a/include/upgrader/streams/core/f5692e24-4323a6a8.patch.sql b/include/upgrader/streams/core/f5692e24-4323a6a8.patch.sql index 36b92688fb366a3ec38aa6f321441daa063eea26..c3bc8ccc3a34347bd98745a7cd3eab026d9996a0 100644 --- a/include/upgrader/streams/core/f5692e24-4323a6a8.patch.sql +++ b/include/upgrader/streams/core/f5692e24-4323a6a8.patch.sql @@ -1,7 +1,7 @@ /** * @version v1.8.2 * @signature 4323a6a81c35efbf7722b7fc4e475440 - * @title Add client accounts table + * @title Add client login feature * */ @@ -53,7 +53,7 @@ ALTER TABLE `%TABLE_PREFIX%help_topic` RENAME TABLE `%TABLE_PREFIX%page` TO `%TABLE_PREFIX%content`; ALTER TABLE `%TABLE_PREFIX%content` CHANGE `type` `type` varchar(32) NOT NULL default 'other', - ADD `content_id` int(10) unsigned NOT NULL default 0; + ADD `content_id` int(10) unsigned NOT NULL default 0 AFTER `id`; UPDATE `%TABLE_PREFIX%content` SET `content_id` = `id`; @@ -90,8 +90,8 @@ DELETE FROM `%TABLE_PREFIX%config` where `namespace`='core' -- Transfer access link template INSERT INTO `%TABLE_PREFIX%content` - (`name`, `body`, `type`, `isactive`) - SELECT A1.`subject`, A1.`body`, 'access-link', 1 + (`name`, `body`, `type`, `isactive`, `created`, `updated`) + SELECT A1.`subject`, A1.`body`, 'access-link', 1, A1.`created`, A1.`updated` FROM `%TABLE_PREFIX%email_template` A1 WHERE A1.`tpl_id` = (SELECT `value` FROM `%TABLE_PREFIX%config` A3 WHERE A3.`key` = 'default_template_id' and `namespace` = 'core') @@ -102,8 +102,8 @@ UPDATE `%TABLE_PREFIX%content` SET `content_id` = LAST_INSERT_ID() -- Transfer staff password reset link INSERT INTO `%TABLE_PREFIX%content` - (`name`, `body`, `type`, `isactive`) - SELECT A1.`subject`, A1.`body`, 'pwreset-staff', 1 + (`name`, `body`, `type`, `isactive`, `created`, `updated`) + SELECT A1.`subject`, A1.`body`, 'pwreset-staff', 1, A1.`created`, A1.`updated` FROM `%TABLE_PREFIX%email_template` A1 WHERE A1.`tpl_id` = (SELECT `value` FROM `%TABLE_PREFIX%config` A3 WHERE A3.`key` = 'default_template_id' and `namespace` = 'core') diff --git a/include/upgrader/streams/core/f5692e24-4323a6a8.task.php b/include/upgrader/streams/core/f5692e24-4323a6a8.task.php new file mode 100644 index 0000000000000000000000000000000000000000..566fab7a20ad09887f6e59cd30ff73c630a09f17 --- /dev/null +++ b/include/upgrader/streams/core/f5692e24-4323a6a8.task.php @@ -0,0 +1,37 @@ +<?php + + +class TemplateContentLoader extends MigrationTask { + var $description = "Loading initial system templates"; + + function run($max_time) { + foreach (array( + 'registration-staff', 'pwreset-staff', 'banner-staff', + 'registration-client', 'pwreset-client', 'banner-client', + 'registration-confirm', 'registration-thanks', + 'access-link') as $type) { + $i18n = new Internationalization(); + $tpl = $i18n->getTemplate("templates/page/{$type}.yaml"); + if (!($page = $tpl->getData())) + // No such template on disk + continue; + + if ($id = db_result(db_query('select id from '.PAGE_TABLE + .' where `type`='.db_input($type)))) + // Already have a template for the content type + continue; + + $sql = 'INSERT INTO '.PAGE_TABLE.' SET type='.db_input($type) + .', name='.db_input($page['name']) + .', body='.db_input($page['body']) + .', lang='.db_input($tpl->getLang()) + .', notes='.db_input($page['notes']) + .', created=NOW(), updated=NOW(), isactive=1'; + db_query($sql); + } + // Set the content_id for all the new items + db_query('UPDATE '.PAGE_TABLE + .' SET `content_id` = `id` WHERE `content_id` = 0'); + } +} +return 'TemplateContentLoader';