New assurer challenge feature
Signed-off-by: Michael Tänzer <neo@nhng.de>
This commit is contained in:
parent
b1e762553a
commit
5e39c30e12
3 changed files with 68 additions and 0 deletions
|
@ -153,6 +153,35 @@ class ManageAccountController extends Zend_Controller_Action
|
|||
return;
|
||||
}
|
||||
|
||||
|
||||
public function assurerChallengeAction()
|
||||
{
|
||||
// Validate form
|
||||
$form = $this->getAssurerChallengeForm();
|
||||
if (!$this->getRequest()->isPost() || !$form->isValid($_POST)) {
|
||||
$this->view->assurer_challenge_form = $form;
|
||||
return $this->render('assurer-challenge-form');
|
||||
}
|
||||
|
||||
// Form is valid -> get values for processing
|
||||
$values = $form->getValues();
|
||||
|
||||
// Get user data
|
||||
$user['id'] = $this->getUserId();
|
||||
|
||||
// Assign the assurer challenge
|
||||
$challenge = array(); // Make sure the array is empty
|
||||
$challenge['user_id'] = $user['id'];
|
||||
$challenge['variant_id'] = $values['variant'];
|
||||
$challenge['pass_date'] = date('Y-m-d H:i:s');
|
||||
$this->db->insert('cats_passed', $challenge);
|
||||
|
||||
// Maybe user is now assurer
|
||||
$this->fixAssurerFlag($user['id']);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get and check the user ID of the current user
|
||||
*
|
||||
|
@ -312,4 +341,27 @@ class ManageAccountController extends Zend_Controller_Action
|
|||
|
||||
return $form;
|
||||
}
|
||||
|
||||
protected function getAssurerChallengeForm()
|
||||
{
|
||||
$form = new Zend_Form();
|
||||
$form->setAction('/manage-account/assurer-challenge')
|
||||
->setMethod('post');
|
||||
|
||||
$variant = new Zend_Form_Element_Select('variant');
|
||||
$variant->setLabel(I18n::_('Variant'));
|
||||
// Get the available variants from the database
|
||||
$query = 'select `id`, `test_text` from `cats_variant`
|
||||
where `type_id` = 1';
|
||||
$options = $this->db->fetchPairs($query);
|
||||
$variant->setOptions($options)
|
||||
->setRequired(true);
|
||||
$form->addElement($variant);
|
||||
|
||||
$submit = new Zend_Form_Element_Submit('submit');
|
||||
$submit->setLabel(I18n::_('Challenge Me'));
|
||||
$form->addElement($submit);
|
||||
|
||||
return $form;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
<?php
|
||||
/**
|
||||
* @author Michael Tänzer
|
||||
* @todo Text
|
||||
*/
|
||||
?>
|
||||
|
||||
<?php print $this->assurer_challenge_form ?>
|
|
@ -0,0 +1,8 @@
|
|||
<?php
|
||||
/**
|
||||
* @author Michael Tänzer
|
||||
* @todo Text
|
||||
*/
|
||||
?>
|
||||
|
||||
<h1><?php print I18n::_('Assurer challenge added successfully')?></h1>
|
Loading…
Reference in a new issue