blob: 2b0b857888cf66d193af90ce962d5f00c114818e (
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
<? php
/*
* Copyright (c) 2011 - OpenSLX GmbH, RZ Uni Freiburg
* This program is free software distributed under the GPL version 2.
* See http://gpl.openslx.org/
*
* If you have any feedback please consult http://feedback.openslx.org/ and
* send your suggestions, praise, or complaints to feedback@openslx.org
*
* General information about OpenSLX can be found at http://openslx.org/
*/
class dev_ConfigController extends Zend_Controller_Action {
public function init() {
$db = Zend_Db_Table::getDefaultAdapter();
}
public function indexAction() {
$configmapper = new Application_Model_ConfigMapper();
$groupmapper = new Application_Model_GroupMapper();
$membershipmapper = new Application_Model_MembershipMapper();
$personmapper = new Application_Model_PersonMapper();
$this->view->configlist = $configmapper->fetchAll();
foreach ($this->view->configlist as $config) {
$config->setGroupID("[".$config->getGroupID()."] ".$groupmapper->find($config->getGroupID())->getTitle());
$config->setMembershipID("[".$config->getMembershipID()."] ".$personmapper->find($membershipmapper->find($config->getMembershipID())->getPersonID())->getFirstname());
}
}
public function createconfigAction() {
$groupmapper = new Application_Model_GroupMapper();
if (!isset($_POST["createconfig"])) {
$createconfigForm = new dev_Form_ConfigCreate(array('grouplist' => $groupmapper->fetchAll()));
} else {
$createconfigForm = new dev_Form_ConfigCreate(array('grouplist' => $groupmapper->fetchAll()), $_POST);
if ($createconfigForm->isValid($_POST)) {
$config = new Application_Model_Config($_POST);
$config->setCreated(time());
$config->setMembershipID('1');
$configmapper = new Application_Model_ConfigMapper();
try {
$configmapper->save($config);
} catch(Zend_Exception $e) {
echo "Caught exception: " . get_class($e) . "<br/>";
echo "Message: " . $e->getMessage() . "<br/>";
}
$this->_redirect('/dev/config');
}
}
$this->view->createconfigForm = $createconfigForm;
}
public function editconfigAction() {
$configID = $this->_request->getParam('configID');
$groupmapper = new Application_Model_GroupMapper();
if (!isset($_POST["editconfig"])) {
$configID = $this->_request->getParam('configID');
if (!isset($configID) || !is_numeric($configID)) {
$this->_redirect('/dev/config');
} else {
$config = new Application_Model_Config();
$configmapper = new Application_Model_ConfigMapper();
$config = $configmapper->find($configID);
$editconfigForm = new dev_Form_ConfigEdit(array('grouplist' => $groupmapper->fetchAll()));
$editconfigForm->populate($config->toArray());
}
} else {
$editconfigForm = new dev_Form_ConfigEdit(array('grouplist' => $groupmapper->fetchAll()), $_POST);
if ($editconfigForm->isValid($_POST)) {
$config = new Application_Model_Config($_POST);
$configmapper = new Application_Model_ConfigMapper();
$config->setCreated(time());
$config->setMembershipID('1');
$config->setID($configID);
try {
$configmapper->save($config);
} catch(Zend_Exception $e) {
echo "Caught exception: " . get_class($e) . "<br/>";
echo "Message: " . $e->getMessage() . "<br/>";
}
$this->_redirect('/dev/config');
}
}
$this->view->editconfigForm = $editconfigForm;
}
public function deleteconfigAction() {
$configID = $this->_request->getParam('configID');
if (!isset($configID)) {
$this->_redirect('/dev/config');
} else {
$config = new Application_Model_Config();
$config->setID($configID);
$configmapper = new Application_Model_ConfigMapper();
$configmapper->delete($config);
}
$this->_redirect('/dev/config');
}
}
|