Last active
July 4, 2016 09:25
-
-
Save onocom/da46e61e4e6abb5b62ae7dce6910fc13 to your computer and use it in GitHub Desktop.
concrete5のユーザ登録時にmauticにもユーザを追加する際のソースコード
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php defined('C5_EXECUTE') or die("Access Denied."); | |
$token = \Core::make('Concrete\Core\Validation\CSRF\Token'); | |
?> | |
<div class="row"> | |
<div class="col-sm-10 col-sm-offset-1"> | |
<div class="page-header"> | |
<h1><?php echo t('Site Registration')?></h1> | |
<p>Mauticとの連携を試みます!</p> | |
</div> | |
</div> | |
</div> | |
<?php | |
$attribs = UserAttributeKey::getRegistrationList(); | |
$ma_tag = ""; | |
if($registerSuccess) { ?> | |
<div class="row"> | |
<div class="col-sm-10 col-sm-offset-1"> | |
<?php switch($registerSuccess) { | |
case "registered": | |
?> | |
<p><strong><?php echo $successMsg ?></strong><br/><br/> | |
<a href="<?php echo $view->url('/')?>"><?php echo t('Return to Home')?></a></p> | |
<?php | |
break; | |
case "validate": | |
?> | |
<p><?php echo $successMsg[0] ?></p> | |
<p><?php echo $successMsg[1] ?></p> | |
<p><a href="<?php echo $view->url('/')?>"><?php echo t('Return to Home')?></a></p> | |
<?php | |
break; | |
case "pending": | |
?> | |
<p><?php echo $successMsg ?></p> | |
<p><a href="<?php echo $view->url('/')?>"><?php echo t('Return to Home')?></a></p> | |
<?php | |
break; | |
} | |
$u = new User(); | |
if (is_object($u) && $u->checkLogin()) { | |
$uinfo = UserInfo::getByID($u->uID); | |
$email = $uinfo->getUserEmail(); | |
$first_name = $uinfo->getAttribute("first_name"); | |
$last_name = $uinfo->getAttribute("last_name"); | |
$company = $uinfo->getAttribute("company"); | |
$ma_tag = "{email: '" . $email . "', firstname: '" . $first_name . "', lastname: '" . $last_name . "', company: '" . $company . "'}"; | |
} | |
?> | |
</div> | |
</div> | |
<?php | |
} else { ?> | |
<form method="post" action="<?php echo $view->url('/register', 'do_register')?>" class="form-stacked"> | |
<?php $token->output('register.do_register') ?> | |
<div class="row"> | |
<div class="col-sm-10 col-sm-offset-1"> | |
<fieldset> | |
<legend><?php echo t('Your Details')?></legend> | |
<?php | |
if ($displayUserName) { | |
?> | |
<div class="form-group"> | |
<?php echo $form->label('uName',t('Username'))?> | |
<?php echo $form->text('uName')?> | |
</div> | |
<?php | |
} | |
?> | |
<div class="form-group"> | |
<?php echo $form->label('uEmail',t('Email Address'))?> | |
<?php echo $form->text('uEmail')?> | |
</div> | |
<div class="form-group"> | |
<?php echo $form->label('uPassword',t('Password'))?> | |
<?php echo $form->password('uPassword',array('autocomplete' => 'off'))?> | |
</div> | |
<div class="form-group"> | |
<?php echo $form->label('uPasswordConfirm',t('Confirm Password'))?> | |
<?php echo $form->password('uPasswordConfirm',array('autocomplete' => 'off'))?> | |
</div> | |
</fieldset> | |
</div> | |
</div> | |
<?php | |
if (count($attribs) > 0) { | |
?> | |
<div class="row"> | |
<div class="col-sm-10 col-sm-offset-1"> | |
<fieldset> | |
<legend><?php echo t('Options')?></legend> | |
<?php | |
$af = Loader::helper('form/attribute'); | |
foreach($attribs as $ak) { | |
echo $af->display($ak, $ak->isAttributeKeyRequiredOnRegister()); | |
} | |
?> | |
</fieldset> | |
</div> | |
</div> | |
<?php | |
} | |
if (Config::get('concrete.user.registration.captcha')) { | |
?> | |
<div class="row"> | |
<div class="col-sm-10 col-sm-offset-1 "> | |
<div class="form-group"> | |
<?php | |
$captcha = Loader::helper('validation/captcha'); | |
echo $captcha->label(); | |
?> | |
<?php | |
$captcha->showInput(); | |
$captcha->display(); | |
?> | |
</div> | |
</div> | |
</div> | |
<?php } ?> | |
<div class="row"> | |
<div class="col-sm-10 col-sm-offset-1"> | |
<div class="form-actions"> | |
<?php echo $form->hidden('rcID', $rcID); ?> | |
<?php echo $form->submit('register', t('Register') . ' >', array('class' => 'btn-lg btn-primary'))?> | |
</div> | |
</div> | |
</div> | |
</form> | |
<?php | |
} | |
?> | |
<script> | |
(function(w,d,t,u,n,a,m){w['MauticTrackingObject']=n; | |
w[n]=w[n]||function(){(w[n].q=w[n].q||[]).push(arguments)},a=d.createElement(t), | |
m=d.getElementsByTagName(t)[0];a.async=1;a.src=u;m.parentNode.insertBefore(a,m) | |
})(window,document,'script','http://example.com/mtc.js','mt'); | |
<?php if( $ma_tag ) : ?> | |
mt('send', 'pageview', <?php echo $ma_tag; ?>); | |
<?php else: ?> | |
mt('send', 'pageview'); | |
<?php endif; ?> | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment