ff66f0bde7bb2e804c86716fa0eafe13b4cccf8b
[cacert-mgr.git] / manager / application / controllers / AddPointsController.php
1 <?php
2 /**
3 * @author Michael Tänzer
4 */
5
6 class AddPointsController extends Zend_Controller_Action
7 {
8 public function init()
9 {
10 /* Initialize action controller here */
11 }
12
13 public function indexAction()
14 {
15 $this->view->assurance_form = $this->getAssuranceForm();
16 $this->render('index');
17 }
18
19 public function assuranceAction()
20 {
21 /* Validate form */
22 if (!$this->getRequest()->isPost()) {
23 return $this->_forward('index');
24 }
25
26 $form = $this->getAssuranceForm();
27 if (!$form->isValid($_POST)) {
28 $this->view->assurance_form = $form;
29 return $this->render('index');
30 }
31
32
33 /* Form is valid -> get values and process them */
34 $values = $form->getValues();
35 }
36
37 protected function getAssuranceForm()
38 {
39 $form = new Zend_Form();
40 $form->setAction('/add-points/assurance')->setMethod('post');
41
42 $quantity = new Zend_Form_Element_Text('quantity');
43 $quantity->setRequired(true)
44 ->setLabel(I18n::_('Number of Points'))
45 ->addFilter(new Zend_Filter_Int())
46 ->addValidator(new Zend_Validate_Between(0, 100));
47 $form->addElement($quantity);
48
49 $submit = new Zend_Form_Element_Submit('submit');
50 $submit->setLabel(I18n::_('Assure Me'));
51 $form->addElement($submit);
52
53 return $form;
54 }
55 }