Last active
June 19, 2019 20:43
-
-
Save hissy/9eba7a0f9d7078a5e7aec5ea41d2b1ce to your computer and use it in GitHub Desktop.
#concrete5 Check the user already submitted on express form template
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.'); | |
$app = \Concrete\Core\Support\Facade\Facade::getFacadeApplication(); | |
/** @var \Concrete\Core\User\User $u */ | |
$u = $app->make(\Concrete\Core\User\User::class); | |
$answered = 0; | |
if (isset($renderer) && is_object($renderer) && $u->isRegistered()) { | |
$context = $renderer->getContext(); | |
if (is_object($context)) { | |
/** @var \Concrete\Core\Entity\Express\Form $form */ | |
$form = $context->getForm(); | |
if (is_object($form)) { | |
/** @var \Concrete\Core\Entity\Express\Entity $entity */ | |
$entity = $form->getEntity(); | |
$el = new \Concrete\Core\Express\EntryList($entity); | |
$el->filterByAuthorUserID($u->getUserID()); | |
$answered = $el->getResults(); | |
} | |
} | |
} | |
?> | |
<div class="ccm-block-express-form"> | |
<?php if ($answered) { ?> | |
<?php if (isset($success)) { ?> | |
<p><?= $success; ?></p> | |
<?php } else { ?> | |
<p><?= t('You already answered this survey. Thank you.'); ?></p> | |
<?php } ?> | |
<?php } elseif (isset($renderer)) { | |
?> | |
<div class="ccm-form">...</div> | |
<?php | |
} else { | |
?> | |
<p><?=t('This form is unavailable.'); ?></p> | |
<?php | |
} ?> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment