Skip to content
Snippets Groups Projects
Commit 0b26364f authored by Jared Hancock's avatar Jared Hancock
Browse files

Install, upgrade, and use the registration pages

parent 30feb860
No related branches found
No related tags found
No related merge requests found
......@@ -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');
}
......
......@@ -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())) {
......
......@@ -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>
......
<?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 } ?>
<?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 } ?>
......@@ -81,3 +81,4 @@ core:
random_ticket_ids: 1
log_level: 2
log_graceperiod: 12
client_registration: 'public'
......@@ -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
......
#
# 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>
#
# 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}
......@@ -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>
......
/**
* @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')
......
<?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';
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment