summaryrefslogtreecommitdiffstats
path: root/application/modules/user/controllers/ConfigController.php
blob: 2881cd8fb08b79c9dbacac5135508e2de15f4c7b (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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
<?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 user_ConfigController extends Zend_Controller_Action {

  protected $configMapper;
  protected $bootosMapper;
  protected $bootosuserMapper;
  protected $bootmenuMapper;
  protected $bootmenuentriesMapper;
  protected $membershipMapper;
  protected $membership;
  protected $page;
  protected $config;
  protected $type;

  public function init() {
    if (Zend_Auth::getInstance()->hasIdentity()) {
      $userIDsNamespace = Zend_Session::namespaceGet('userIDs');
      if($userIDsNamespace['membershipID'] == '') {
        $this->_redirect('/user/index');
      }

      $this->configMapper = new Application_Model_ConfigMapper();
      $this->bootosuserMapper = new Application_Model_BootOsUserMapper();
      $this->membershipMapper = new Application_Model_MembershipMapper();
      $this->membership = new Application_Model_Membership();
      $this->membershipMapper->find($userIDsNamespace['membershipID'], $this->membership);

      $this->db = Zend_Db_Table::getDefaultAdapter();

      $this->type = $this->_request->getParam('type');
    } else {
      $this->_helper->redirector('login', 'auth');
    }
    $this->page = $this->_request->getParam('page');
  }

  public function indexAction() {
    $result = $this->_request->getParam('addresult');
    if($result != "") {
      
      $this->view->notification = Pbs_Notifier::notify('create', $result);
    }
    $result = $this->_request->getParam('deleteresult');
    if($result != "") {
      
      $this->view->notification = Pbs_Notifier::notify('delete', $result);
    }
    $result = $this->_request->getParam('modifyresult');
    if($result != "") {
      
      $this->view->notification = Pbs_Notifier::notify('modify', $result);
    }

    $groupID = $this->membership->getGroupID();

    //ACL Darf er Configs sehen?
    if(!Pbs_Acl::checkRight('csai') && !Pbs_Acl::checkRight('csui'))
      { $this->_redirect('/user/index'); }

    $this->configMapper = new Application_Model_ConfigMapper();
    $this->bootosMapper = new Application_Model_BootOsMapper();
    $this->bootmenuMapper = new Application_Model_BootMenuMapper();
    $this->bootmenuentriesMapper = new Application_Model_BootMenuEntriesMapper();
    $groupMapper = new Application_Model_GroupMapper();
    $this->view->bootoslist = array();
    $this->view->configlist = array();

    if($this->type == 'own' && Pbs_Acl::checkRight('csui')) {
      $this->view->type = 'own';
      $bootmenu = $this->bootmenuMapper->findBy(array('membershipID' => $this->membership->getID()));
      if($bootmenu != null) {
        $bootmenuID = $bootmenu[0]->getID();
        $bootmenuentries = $this->bootmenuentriesMapper->findBy(array('bootmenuID' => $bootmenuID));
        foreach ($bootmenuentries as $bootmenuentry) {
          $bootos = $this->bootosMapper->find($bootmenuentry->getBootosID());
          $bootos->setGroupID("[".$bootos->getGroupID()."] ".$groupMapper->find($bootos->getGroupID())->getTitle());
          $this->view->bootoslist[$bootos->getID()] = $bootos;
          $this->view->configlist[$bootos->getID()] = $this->configMapper->findBy(array('membershipID' => $this->membership->getID(), 'bootosID' => $bootos->getID()));
          foreach ($this->view->configlist[$bootos->getID()] as $config) {
            $config->setCreated(date(Zend_Registry::get('dateformat'), $config->getCreated()));
          }
        }
      }
    } else {
      $groupgroupsMapper = new Application_Model_GroupGroupsMapper();

      $parents = array();
      $groupconfs = array();
      $ownerconfs = array();
      $parents = $groupgroupsMapper->getParentGroups($groupID);

      foreach($parents as $k => $parent) {
        foreach($parent as  $p) {
          $bootos = $this->bootosMapper->findBy(array("groupID" => $p));
          foreach ($bootos as $b)
          if($b->getPublic() - $k >= 0 ) {
            $this->view->bootoslist[] = $b;
            if(Pbs_Acl::checkRight('cc')) {
              $ownerconfs = $this->configMapper->findBy(array('groupID' => $b->getGroupID(), 'membershipID' => null, 'bootosID' => $b->getID()));
              if($groupID != $b->getGroupID())
                { $groupconfs = $this->configMapper->findBy(array('groupID' => $groupID, 'membershipID' => null, 'bootosID' => $b->getID())); }
              $this->view->configlist[$b->getID()] = array_merge($ownerconfs, $groupconfs);
            } else {
              $ownerconfs = $this->configMapper->findBy(array('groupID' => $b->getGroupID(), 'membershipID' => null, 'bootosID' => $b->getID(), 'visible' => '1'));
              if($groupID != $b->getGroupID())
                { $groupconfs = $this->configMapper->findBy(array('groupID' => $groupID, 'membershipID' => null, 'bootosID' => $b->getID(), 'visible' => '1')); }
              $this->view->configlist[$b->getID()] = array_merge($ownerconfs, $groupconfs);

            }
            foreach ($this->view->configlist[$b->getID()] as $config) {
              $config->setCreated(date(Zend_Registry::get('dateformat'), $config->getCreated()));
            }
          }
          elseif($k == 0 && $b->getPublic() == -1 && Pbs_Acl::checkRight('boc')) {
            $this->view->bootoslist[] = $b;
            if(Pbs_Acl::checkRight('cc')) {
              $ownerconfs = $this->configMapper->findBy(array('groupID' => $b->getGroupID(), 'membershipID' => null, 'bootosID' => $b->getID()));
              if($groupID != $b->getGroupID())
                { $groupconfs = $this->configMapper->findBy(array('groupID' => $groupID, 'membershipID' => null, 'bootosID' => $b->getID())); }
              $this->view->configlist[$b->getID()] = array_merge($ownerconfs, $groupconfs);
            } else {
              $ownerconfs = $this->configMapper->findBy(array('groupID' => $b->getGroupID(), 'membershipID' => null, 'bootosID' => $b->getID(), 'visible' => '1'));
              if($groupID != $b->getGroupID())
                { $groupconfs = $this->configMapper->findBy(array('groupID' => $groupID, 'membershipID' => null, 'bootosID' => $b->getID(), 'visible' => '1')); }
              $this->view->configlist[$b->getID()] = array_merge($ownerconfs, $groupconfs);
            }
            foreach ($this->view->configlist[$b->getID()] as $config) {
              $config->setCreated(date(Zend_Registry::get('dateformat'), $config->getCreated()));
            }
          }
        }
      }

      $this->view->bootoslist = array_reverse($this->view->bootoslist);

      if(count($this->view->bootoslist) > 0) {
        foreach ($this->view->bootoslist as $bootos) {
          $bootos->setGroupID("[".$bootos->getGroupID()."] ".$groupMapper->find($bootos->getGroupID())->getTitle());
        }
      }
      $this->view->type = 'group';
      //$this->view->configlist = $this->configMapper->findBy(array('groupID' => $this->membership->getGroupID()));
    }

    //print_a($this->view->configlist);

    // Search
    $search = $this->_request->getParam('search');
    $mySearch = new Pbs_Search();
    $mySearch->setSearchTerm($search);
    $mySearch->setType($this->type);
    $mySearch->setModule('config');
    if($search != '') {
      $this->view->search = $mySearch->getSearchTerm();
      $this->view->configlist = $mySearch->search($this->view->configlist
                                                 );
    }
    $this->view->searchform = $mySearch->searchForm();

    // Pagination
    $pagination = new Pbs_Pagination();
    $pagination->setPerPage(10);
    $pagination->setElement($this->view->bootoslist);
    $pagination->setRequestPage($this->_request->getParam('page'));
    $pagination->setPageUrl('/user/config/index/type/'.$this->type.((isset($this->view->search)) ? '/search/'.$this->view->search : ''));
    $this->view->bootoslist = $pagination->getElements();

    $this->view->pagination = $pagination->pagination();
    $this->view->page     = $pagination->getRequestPage();

  }

  public function searchAction() {
    $this->_redirect('/user/config/index/type/'.$this->type.'/search/'.($_GET['search']));
  }

  public function createconfigAction() {
    //ACL Darf er Configs erstellen?
    if(!Pbs_Acl::checkRight('cc') && !Pbs_Acl::checkRight('cco'))
      { $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/addresult/forbidden'); }

    $bootosID = $this->_request->getParam('bootosID');

    if (!is_numeric($bootosID))
      { $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/addresult/error'); }

    if (!isset($_POST["createconfig"])) {
      $configForm = new user_Form_Config(array('action' => 'createconfig', 'page' => $this->page, 'type' => $this->type));
    } else {
      $configForm = new user_Form_Config(array('action' => 'createconfig', 'page' => $this->page, 'type' => $this->type), $_POST);

      if ($configForm->isValid($_POST)) {

        $config = new Application_Model_Config($_POST);
        $config->setCreated(time());
        $config->setBootosID($bootosID);

        if(Pbs_Acl::checkRight('cc') && $this->_request->getParam('type') == 'group') {
          $config->setGroupID($this->membership->getGroupID());
        }
        elseif(Pbs_Acl::checkRight('cco') && $this->_request->getParam('type') == 'own') {
          $config->setVisible('1');
          $config->setMembershipID($this->membership->getID());
        }
        else
          { $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/addresult/error'); }

        try {
          $this->configMapper->save($config);
        } catch(Zend_Exception $e) {
          echo "Caught exception: " . get_class($e) . "<br/>";
          echo "Message: " . $e->getMessage() . "<br/>";
          $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/addresult/error');
        }
        $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/addresult/ok');
      }
    }

    $this->view->configForm = $configForm;
  }

  public function showconfigAction() {

    $result = $this->_request->getParam('addresult');
    if($result != "") {
      
      $this->view->notification = Pbs_Notifier::notify('create', $result);
    }
    $result = $this->_request->getParam('deleteresult');
    if($result != "") {
      
      $this->view->notification = Pbs_Notifier::notify('delete', $result);
    }
    $result = $this->_request->getParam('modifyresult');
    if($result != "") {
      
      $this->view->notification = Pbs_Notifier::notify('modify', $result);
    }

    $configID = $this->_request->getParam('configID');
    if (!is_numeric($configID))
      { $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/modifyresult/error'); }

    $groupID = $this->membership->getGroupID();

    $config = new Application_Model_Config();
    $this->configMapper->find($configID, $config);

    $hometypeMapper = new Application_Model_HomeTypeMapper();

    $this->view->configID = $configID;
    $this->view->type = $this->_request->getParam('type');
    $this->view->config = $this->configMapper->find($configID)->getTitle();
    $this->view->userlist = $this->bootosuserMapper->findBy(array('configID' => $configID));
    foreach($this->view->userlist as $user) {
      $user->setHometypeID("[".$user->getHometypeID()."] ".$hometypeMapper->find($user->getHometypeID())->getName());
    }

  }

  public function adduserAction() {
    $configID = $this->_request->getParam('configID');
    if (!is_numeric($configID))
      { $this->_redirect('/user/config/showconfig/type/'.$this->type.'/configID/'.$configID.'/addresult/error'); }
    //ACL Darf er User adden?
    if(!Pbs_Acl::checkRight('cc') && !Pbs_Acl::checkRight('cco'))
      { $this->_redirect('/user/config/showconfig/type/'.$this->type.'/configID/'.$configID.'/addresult/forbidden'); }

    $hometypeMapper = new Application_Model_HomeTypeMapper();
    $hometype = $hometypeMapper->fetchAll();

    if (!isset($_POST["addbootosuser"])) {
      $bootosuserForm = new user_Form_BootosUser(array('action' => 'addbootosuser', 'type' => $this->type, 'configID' => $configID, 'hometype' => $hometype), $_POST);
    } else {
      $bootosuserForm = new user_Form_BootosUser(array('action' => 'addbootosuser', 'type' => $this->type, 'configID' => $configID, 'hometype' => $hometype), $_POST);

      if ($bootosuserForm->isValid($_POST)) {

        $bootosuser = new Application_Model_BootOsUser($_POST);
        $bootosuser->setConfigID($configID);
        $bootosuser->setHomepath(str_replace("%login-name%", $bootosuser->getLogin(), $bootosuser->getHomepath()));
        if($bootosuser->getPassword() != '%password%')
          { $bootosuser->setPassword(crypt($bootosuser->getPassword(), '$6$'.randomString(8).'$')); }

        try {
          $this->bootosuserMapper->save($bootosuser);
        } catch(Zend_Exception $e) {
          echo "Caught exception: " . get_class($e) . "<br/>";
          echo "Message: " . $e->getMessage() . "<br/>";
          $this->_redirect('/user/config/showconfig/type/'.$this->type.'/configID/'.$configID.'/addresult/error');
        }
        $this->_redirect('/user/config/showconfig/type/'.$this->type.'/configID/'.$configID.'/addresult/ok');
      }
    }

    $this->view->bootosuserForm = $bootosuserForm;
  }


  public function edituserAction() {
    //ACL Darf er Configs editieren?
    if(!Pbs_Acl::checkRight('ce') && !Pbs_Acl::checkRight('cem') && !Pbs_Acl::checkRight('ceo'))
      { $this->_redirect('/user/config/showconfig/type/'.$this->type.'/configID/'.$configID.'/modifyresult/forbidden'); }

    $configID = $this->_request->getParam('configID');
    $bootosuserID = $this->_request->getParam('bootosuserID');

    if (!is_numeric($configID) || !is_numeric($bootosuserID))
      { $this->_redirect('/user/config/showconfig/type/'.$this->type.'/configID/'.$configID.'/modifyresult/error'); }

    $groupID = $this->membership->getGroupID();

    $bootosuser = new Application_Model_BootOsUser();
    $this->bootosuserMapper->find($bootosuserID, $bootosuser);

    $config = new Application_Model_Config();
    $this->configMapper->find($configID, $config);

    $hometypeMapper = new Application_Model_HomeTypeMapper();
    $hometype = $hometypeMapper->fetchAll();

    if($config->getMembershipID() != null) {
      if($this->membership->getID() != $config->getMembershipID() || !Pbs_Acl::checkRight('ceo'))
        { $this->_redirect('/user/config/showconfig/type/'.$this->type.'/configID/'.$configID.'/modifyresult/forbidden'); }
    } else {
      if($this->membership->getGroupID() != $config->getGroupID() || (!Pbs_Acl::checkRight('ce') && !Pbs_Acl::checkRight('cem')))
        { $this->_redirect('/user/config/showconfig/type/'.$this->type.'/configID/'.$configID.'/modifyresult/forbidden'); }
    }

    if (!isset($_POST["editbootosuser"])) {
      if(!isset($_POST['homepath'])) {
        $_POST['login'] = $bootosuser->getLogin();
        $_POST['hometypeID'] = $bootosuser->getHometypeID();

      }

      $bootosuserForm = new user_Form_BootosUser(array('action' => 'editbootosuser', 'type' => $this->type, 'configID' => $configID, 'hometype' => $hometype), $_POST);

      if(!isset($_POST['homepath']) && $bootosuser->getHometypeID() == '2')
        { $bootosuserForm->populate(array('homepath' => $bootosuser->getHomepath())); }
    } else {
      $bootosuserForm = new user_Form_BootosUser(array('action' => 'editbootosuser', 'type' => $this->type, 'configID' => $configID, 'hometype' => $hometype), $_POST);

      if ($bootosuserForm->isValid($_POST)) {

        $bootosuserold = $bootosuser;

        $bootosuser = new Application_Model_BootOsUser($_POST);

        if($bootosuserold->getHometypeID() != $bootosuser->getHometypeID() ||
            $bootosuserold->getHomepath() != $bootosuser->getHomepath()) {
          //ACL Is he allowed to edit other than Metadata?
          if(!Pbs_Acl::checkRight('ce'))
            { $this->_redirect('/user/config/showconfig/type/'.$this->type.'/configID/'.$configID.'/modifyresult/forbidden'); }
        }

        $bootosuser->setID($bootosuserID);
        $bootosuser->setConfigID($configID);
        $bootosuser->setHomepath(str_replace("%login-name%", $bootosuser->getLogin(), $bootosuser->getHomepath()));
        if($bootosuser->getPassword() != '%password%')
          { $bootosuser->setPassword(crypt($bootosuser->getPassword(), '$6$'.randomString(8).'$')); }

        try {
          $this->bootosuserMapper->save($bootosuser);
        } catch(Zend_Exception $e) {
          echo "Caught exception: " . get_class($e) . "<br/>";
          echo "Message: " . $e->getMessage() . "<br/>";
          $this->_redirect('/user/config/showconfig/type/'.$this->type.'/configID/'.$configID.'/modifyresult/error');
        }

        $this->_redirect('/user/config/showconfig/type/'.$this->type.'/configID/'.$configID.'/modifyresult/ok');
      }

    }

    $this->view->bootosuserForm = $bootosuserForm;
  }

  public function deleteuserAction() {

    $configID = $this->_request->getParam('configID');
    $bootosuserID = $this->_request->getParam('bootosuserID');
    if (!is_numeric($configID) || !is_numeric($bootosuserID))
      { $this->_redirect('/user/config/showconfig/type/'.$this->type.'/configID/'.$configID.'/deleteresult/error'); }
    //ACL Darf er User löschen?
    if(!Pbs_Acl::checkRight('cd') && !Pbs_Acl::checkRight('cdo'))
      { $this->_redirect('/user/config/showconfig/type/'.$this->type.'/configID/'.$configID.'/deleteresult/forbidden'); }

    try {
      $bootosuser = new Application_Model_BootOsUser();
      $this->bootosuserMapper->find($bootosuserID, $bootosuser);

      $config = new Application_Model_Config();
      $this->configMapper->find($configID, $config);

      if($config->getMembershipID() != null) {
        if($this->membership->getID() != $config->getMembershipID() || !Pbs_Acl::checkRight('cdo'))
          { $this->_redirect('/user/config/showconfig/type/'.$this->type.'/configID/'.$configID.'/deleteresult/forbidden'); }
      } else {
        if($this->membership->getGroupID() != $config->getGroupID() || !Pbs_Acl::checkRight('cd'))
          { $this->_redirect('/user/config/showconfig/type/'.$this->type.'/configID/'.$configID.'/deleteresult/forbidden'); }
      }

      $this->bootosuserMapper->delete($bootosuser);

    } catch(Zend_Exception $e) {
      echo "Caught exception: " . get_class($e) . "<br/>";
      echo "Message: " . $e->getMessage() . "<br/>";
      $this->_redirect('/user/config/showconfig/type/'.$this->type.'/configID/'.$configID.'/deleteresult/error');
    }
    $this->_redirect('/user/config/showconfig/type/'.$this->type.'/configID/'.$configID.'/deleteresult/ok');
  }



  public function editconfigAction() {
    //ACL Darf er Configs editieren?
    if(!Pbs_Acl::checkRight('ce') && !Pbs_Acl::checkRight('cem') && !Pbs_Acl::checkRight('ceo'))
      { $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/modifyresult/forbidden'); }

    $configID = $this->_request->getParam('configID');
    if (!is_numeric($configID))
      { $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/modifyresult/error'); }

    $groupID = $this->membership->getGroupID();

    $config = new Application_Model_Config();
    $this->configMapper->find($configID, $config);

    if($config->getMembershipID() != null) {
      if($this->membership->getID() != $config->getMembershipID() || !Pbs_Acl::checkRight('ceo'))
        { $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/modifyresult/forbidden'); }
    } else {
      if($this->membership->getGroupID() != $config->getGroupID() || (!Pbs_Acl::checkRight('ce') && !Pbs_Acl::checkRight('cem')))
        { $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/modifyresult/forbidden'); }
    }

    if (!isset($_POST["editconfig"])) {

      $configForm = new user_Form_Config(array('action' => 'editconfig', 'page' => $this->page, 'type' => $this->type));
      $configForm->populate($config->toArray());

    } else {
      $configForm = new user_Form_Config(array('action' => 'editconfig', 'page' => $this->page, 'type' => $this->type), $_POST);

      if ($configForm->isValid($_POST)) {

        $configold = $config;

        $config = new Application_Model_Config($_POST);
        $config->setCreated(time());
        $config->setBootosID($configold->getBootosID());

        if(Pbs_Acl::checkRight('ce') && $configold->getGroupID() != null) {
          $config->setGroupID($this->membership->getGroupID());
        }
        elseif(Pbs_Acl::checkRight('ceo') && $configold->getMembershipID() != null) {
          $config->setVisible($configold->getVisible());
          $config->setMembershipID($this->membership->getID());
        }
        else
          { $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/modifyresult/error'); }

        $config->setID($configID);

        if($configold->getVisible() != $config->getVisible()) {
          //ACL Is he allowed to edit other than Metadata?
          if(!Pbs_Acl::checkRight('ce'))
            { $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/modifyresult/forbidden'); }
        }


        try {
          $this->configMapper->save($config);
        } catch(Zend_Exception $e) {
          echo "Caught exception: " . get_class($e) . "<br/>";
          echo "Message: " . $e->getMessage() . "<br/>";
          $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/modifyresult/error');
        }

        $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/modifyresult/ok');
      }

    }

    $this->view->configForm = $configForm;
  }

  public function deleteconfigAction() {
    //ACL Darf er Configs löschen?
    if(!Pbs_Acl::checkRight('cd') && !Pbs_Acl::checkRight('cdo'))
      { $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/deleteresult/forbidden'); }

    try {
      $configID = $this->_request->getParam('configID');
      if (!is_numeric($configID))
        { $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/deleteresult/error'); }

      $config = new Application_Model_Config();
      $this->configMapper->find($configID, $config);

      if($config->getMembershipID() != null) {
        if($this->membership->getID() != $config->getMembershipID() || !Pbs_Acl::checkRight('cdo'))
          { $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/deleteresult/forbidden'); }
      } else {
        if($this->membership->getGroupID() != $config->getGroupID() || !Pbs_Acl::checkRight('cd'))
          { $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/deleteresult/forbidden'); }
      }

      $this->configMapper->delete($config);

    } catch(Zend_Exception $e) {
      echo "Caught exception: " . get_class($e) . "<br/>";
      echo "Message: " . $e->getMessage() . "<br/>";
      $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/deleteresult/error');
    }
    $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/deleteresult/ok');
  }


}