summaryrefslogtreecommitdiffstats
path: root/application/controllers/FilterController.php
blob: b0be93dca320a0cfb14366f67dc2a332944b826e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<?php

class FilterController extends Zend_Controller_Action
{

    private $_filtermapper = null;

    public function init()
    {
        try{		
                			$this->_filtermapper = new Application_Model_FilterMapper();
                		}catch (Zend_Exception $e) {  
                			echo "Error message 1: " . $e->getMessage() . "\n";
    }

    public function indexAction()
    {
        try{			
        			$this->_filtermapper = new Application_Model_FilterMapper();
               		$this->view->filters = $this->_filtermapper->fetchAll();
                			
        		}catch (Zend_Exception $e) {  
        			echo "Error message 2: " . $e->getMessage() . "\n";
    }

    public function addfilterAction()
    {
        $db = Zend_Db_Table::getDefaultAdapter();
                        if (!isset($_POST["add"])){
                    		$addfilterform = new Application_Form_FilterAdd();    		
                			$this->view->addfilterform = $addfilterform;		
                		}else {
                			$addfilterform = new Application_Form_FilterAdd($_POST);
                			if ($addfilterform->isValid($_POST)) {
                			
                				try{
                					$newfilter = new Application_Model_Filter();
                					$newfilter->setTitle($_POST['title']);
                					$newfilter->setCreated(time());
                					$newfilter->setDescription($_POST['description']);
                					$newfilter->setPriority($_POST['priority']);
                
                					// TODO: Ändere mit ACL
                					$newfilter->setGroupID('1');
                					$newfilter->setMembershipID('1');
                					$newfilter->setBootmenuID('1');
                
                					
                
                					$newfilter2 = new Application_Model_FilterMapper();
                					$newfilter2->save($newfilter);
                
                					$this->_redirect('/filter');
                			    	return;
                				}catch (Zend_Exception $e) {  
                        			echo "Error message 2: " . $e->getMessage() . "\n";  
                        		}
                			}
    }

    public function removefilterAction()
    {
        // action body
    }

    public function editfilterAction()
    {
        // action body
    }


}