summaryrefslogtreecommitdiff
path: root/manager/application
diff options
context:
space:
mode:
authorMichael Tänzer <neo@nhng.de>2010-07-01 18:52:43 +0200
committerMichael Tänzer <neo@nhng.de>2010-07-01 18:52:43 +0200
commit5e39c30e125d8ffc609619050ac52e652f84e5f7 (patch)
tree48b86ac8e6b524ff4236adfb0b497b6ce44924e9 /manager/application
parentb1e762553a3f6e024dc5bfbde6e0bc13a8eb48dc (diff)
downloadcacert-mgr-5e39c30e125d8ffc609619050ac52e652f84e5f7.tar.gz
cacert-mgr-5e39c30e125d8ffc609619050ac52e652f84e5f7.tar.xz
cacert-mgr-5e39c30e125d8ffc609619050ac52e652f84e5f7.zip
New assurer challenge feature
Signed-off-by: Michael Tänzer <neo@nhng.de>
Diffstat (limited to 'manager/application')
-rw-r--r--manager/application/controllers/ManageAccountController.php52
-rw-r--r--manager/application/views/scripts/manage-account/assurer-challenge-form.phtml8
-rw-r--r--manager/application/views/scripts/manage-account/assurer-challenge.phtml8
3 files changed, 68 insertions, 0 deletions
diff --git a/manager/application/controllers/ManageAccountController.php b/manager/application/controllers/ManageAccountController.php
index cc7efa0..c893a4b 100644
--- a/manager/application/controllers/ManageAccountController.php
+++ b/manager/application/controllers/ManageAccountController.php
@@ -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;
+ }
}
diff --git a/manager/application/views/scripts/manage-account/assurer-challenge-form.phtml b/manager/application/views/scripts/manage-account/assurer-challenge-form.phtml
new file mode 100644
index 0000000..54c56a8
--- /dev/null
+++ b/manager/application/views/scripts/manage-account/assurer-challenge-form.phtml
@@ -0,0 +1,8 @@
+<?php
+/**
+ * @author Michael Tänzer
+ * @todo Text
+ */
+?>
+
+<?php print $this->assurer_challenge_form ?>
diff --git a/manager/application/views/scripts/manage-account/assurer-challenge.phtml b/manager/application/views/scripts/manage-account/assurer-challenge.phtml
new file mode 100644
index 0000000..32919db
--- /dev/null
+++ b/manager/application/views/scripts/manage-account/assurer-challenge.phtml
@@ -0,0 +1,8 @@
+<?php
+/**
+ * @author Michael Tänzer
+ * @todo Text
+ */
+?>
+
+<h1><?php print I18n::_('Assurer challenge added successfully')?></h1>