From fd59ce460efe495b6c8e3eb6bee5080bdf5b8ddf Mon Sep 17 00:00:00 2001 From: Sebastian Wagner Date: Mon, 10 Oct 2011 13:47:07 +0200 Subject: filter fixed --- .../modules/user/controllers/FilterController.php | 1087 +++++++++++--------- application/modules/user/forms/FilterEntry.php | 901 ++++++++-------- .../modules/user/views/scripts/filter/index.phtml | 319 +++--- 3 files changed, 1241 insertions(+), 1066 deletions(-) mode change 100755 => 100644 application/modules/user/controllers/FilterController.php mode change 100755 => 100644 application/modules/user/forms/FilterEntry.php mode change 100755 => 100644 application/modules/user/views/scripts/filter/index.phtml diff --git a/application/modules/user/controllers/FilterController.php b/application/modules/user/controllers/FilterController.php old mode 100755 new mode 100644 index 37f9307..07d6bce --- a/application/modules/user/controllers/FilterController.php +++ b/application/modules/user/controllers/FilterController.php @@ -1,511 +1,576 @@ -hasIdentity()) { - $userIDsNamespace = Zend_Session::namespaceGet('userIDs'); - if($userIDsNamespace['membershipID'] ==''){ - $pbsNotifier = new Pbs_Notifier(); - echo $pbsNotifier->notify('No membershipID set','forbidden'); - } - $this->filterMapper = new Application_Model_FilterMapper(); - - $membershipMapper = new Application_Model_MembershipMapper(); - $this->membership = new Application_Model_Membership(); - $membershipMapper->find($userIDsNamespace['membershipID'],$this->membership); - - $this->db = Zend_Db_Table::getDefaultAdapter(); - } else { - $this->_helper->redirector('login', 'auth'); - } - $this->page = $this->_request->getParam('page'); - } - - public function indexAction() - { - // ACL: Is he allowed to see the overview - if(!Pbs_Acl::checkRight('fo')) - $this->_redirect('/user'); - - $result = $this->_request->getParam('addresult'); - if($result != ""){ - $pbsNotifier = new Pbs_Notifier(); - $this->view->notification = $pbsNotifier->notify('create',$result); - } - $result = $this->_request->getParam('deleteresult'); - if($result != ""){ - $pbsNotifier = new Pbs_Notifier(); - $this->view->notification = $pbsNotifier->notify('delete',$result); - } - $result = $this->_request->getParam('modifyresult'); - if($result != ""){ - $pbsNotifier = new Pbs_Notifier(); - $this->view->notification = $pbsNotifier->notify('modify',$result); - } - - $filters = $this->filterMapper->findBy(array('groupID' => $this->membership->getGroupID(),'membershipID'=>null),true,array('priority'=>'DESC')); - $bootmenuMapper = new Application_Model_BootMenuMapper(); - foreach($filters as $filter){ - $ff = new Application_Model_Filter(); - $ff->setOptions($filter); - $ff->setID($filter['filterID']); - $ff->setBootmenuID("[".$ff->getBootmenuID()."] ".$bootmenuMapper->find($ff->getBootmenuID())->getTitle()); - $ff->setCreated(date(Zend_Registry::get('dateformat'),$ff->getCreated())); - $allFilter[] = $ff; - } - - // Search - $search = $this->_request->getParam('search'); - $mySearch = new Pbs_Search(); - $mySearch->setSearchTerm($search)->setModule('filter'); - if($search != ''){ - $this->view->search = $mySearch->getSearchTerm(); - $allFilter = $mySearch->search($allFilter); - } - $this->view->searchform = $mySearch->searchForm(); - - // Pagination - $pagination = new Pbs_Pagination(); - $pagination->setPerPage(10) - ->setElement($allFilter) - ->setRequestPage($this->_request->getParam('page')) - ->setPageUrl('/user/filter/index'.((isset($this->view->search))?'/search/'.$this->view->search:'')); - $allFilter = $pagination->getElements(); - - $this->view->pagination = $pagination->pagination(); - $this->view->page = $pagination->getRequestPage(); - $this->view->filters = $allFilter; - - } - - public function searchAction(){ - $this->_redirect('/user/filter/index/search/'.($_GET['search'])); - } - - public function addfilterAction() - { - // ACL: Is he allowed to add a Filter - if(!Pbs_Acl::checkRight('fa')) - $this->_redirect('/user'); - - $bmmapper = new Application_Model_BootMenuMapper(); - - $result = $bmmapper->findBy(array('groupID' => $this->membership->getGroupID()),true); - - foreach($result as $rr){ - $bm = new Application_Model_BootMenu(); - $bm->setOptions($rr); - $bm->setID($rr['bootmenuID']); - $bootmenus[] = $bm; - } - - $this->view->bootmenus = $bootmenus; - - if (!isset($_POST["add"])){ - $addfilterform = new user_Form_Filter(array( - 'buttontext' => 'Create Filter', - 'bootmenus'=>$bootmenus, - 'page' => $this->page)); - $this->view->addfilterform = $addfilterform; - }else { - $addfilterform = new user_Form_Filter(array( - 'buttontext' => 'Create Filter', - 'bootmenus'=>$bootmenus, - 'page' => $this->page),$_POST); - if ($addfilterform->isValid($_POST)) { - try{ - $newfilter = new Application_Model_Filter($_POST); - $newfilter->setCreated(time()) - ->setGroupID($this->membership->getGroupID()) - ->setMembershipID(null); - $newfilter2 = new Application_Model_FilterMapper(); - $id = $newfilter2->save($newfilter); - - $filterentriesMapper = new Application_Model_FilterEntriesMapper(); - $filterentry = new Application_Model_FilterEntries(); - $filterentry->setFilterID($id) - ->setFiltertypeID(6) - ->setFiltervalue($this->membership->getGroupID()); - $filterentriesMapper->save($filterentry); - - $this->_redirect('/user/filter/index/page/'.$this->page.'/addresult/ok'); - }catch (Zend_Exception $e) { - echo "Error message 2: " . $e->getMessage() . "\n"; - $this->_redirect('/user/filter/index/page/'.$this->page.'/addresult/error'); - } - } - $this->view->addfilterform = $addfilterform; - } - } - - public function removefilterAction() - { - $filterID = $this->_request->getParam('filterID'); - $filtermapper = new Application_Model_FilterMapper(); - - // ACL: Is he allowed to remove the filter - if(!Pbs_Acl::checkRight('fd')) - $this->_redirect('/user'); - - if(is_numeric($filterID)){ - $filter = new Application_Model_Filter(); - $filtermapper->find($filterID,$filter); - if($filter->getGroupID() == $this->membership->getGroupID()){ - $deletefilter = new Application_Model_Filter(); - $deletefilter->setID($filterID); - $filtermapper->delete($deletefilter); - $this->_redirect('/user/filter/index/page/'.$this->page.'/deleteresult/ok'); - } - else{ - $this->_redirect('/user/filter/index/page/'.$this->page.'/deleteresult/forbidden'); - } - } - else{ - $this->_redirect('/user/filter/index/page/'.$this->page.'/deleteresult/error'); - } - } - - public function editfilterAction() - { - $bmmapper = new Application_Model_BootMenuMapper(); - $result = $bmmapper->findBy(array('groupID' => $this->membership->getGroupID()),true); - foreach($result as $rr){ - $bm = new Application_Model_BootMenu(); - $bm->setOptions($rr); - $bm->setID($rr['bootmenuID']); - $bootmenus[] = $bm; - } - - // ACL: Is he allowed to edit the filter or the filterpriority? - if(!Pbs_Acl::checkRight('fe') && !Pbs_Acl::checkRight('fefp')) - $this->_redirect('/user'); - - if (!isset($_POST["add"])){ - $filterID = $this->_request->getParam('filterID'); - $filter = new Application_Model_Filter(); - - $filtermapper = new Application_Model_FilterMapper(); - $filtermapper->find($filterID,$filter); - if($filter->getGroupID() == $this->membership->getGroupID()){ - $filter2 = $filter->toArray(); - $editfilterform = new user_Form_Filter(array( - 'buttontext' => 'Edit Filter', - 'bootmenus'=>$bootmenus, - 'page' => $this->page)); - $editfilterform->populate($filter2); - $this->view->editfilterform = $editfilterform; - } - else{ - $this->_redirect('/user/filter/index/page/'.$this->page.'/modifyresult/forbidden'); - } - } else{ - try{ - $filterID = $this->_request->getParam('filterID'); - $filter = new Application_Model_Filter(); - $filtermapper = new Application_Model_FilterMapper(); - $filtermapper->find($filterID,$filter); - if($filter->getGroupID() == $this->membership->getGroupID()){ - $editfilterform = new user_Form_Filter(array( - 'buttontext' => 'Edit Filter', - 'bootmenus'=>$bootmenus, - 'page' => $this->page),$_POST); - if ($editfilterform->isValid($_POST)) { - $filtermapper = new Application_Model_FilterMapper(); - - $newfilterentry = new Application_Model_Filter($_POST); - $newfilterentry->setID($this->_request->getParam('filterID')) - ->setGroupID($this->membership->getGroupID()) - ->setMembershipID(null); - - // ACL: if he is only allowed to edit filterpriority - if(Pbs_Acl::checkRight('fefp') && !Pbs_Acl::checkRight('fe')){ - $DBfilterentry = new Application_Model_Filter(); - $filtermapper->find($this->_request->getParam('filterID'),$DBfilterentry); - - $compareresult = $filtermapper->compare($newfilterentry,$DBfilterentry); - if(isset($compareresult['priority']) && count($compareresult) == 1){ - $filtermapper->save($newfilterentry); - $this->_redirect('/user/filter/index/page/'.$this->page.'/modifyresult/ok'); - } - else{ - $this->_redirect('/user/filter/index/page/'.$this->page.'/modifyresult/forbidden'); - } - } - // ACL: he is allowed to edit the filter - elseif(Pbs_Acl::checkRight('fe')){ - $filtermapper->save($newfilterentry); - $this->_redirect('/user/filter/index/page/'.$this->page.'/modifyresult/ok'); - } - } - $this->view->editfilterform = $editfilterform; - } - else{ - $this->_redirect('/user/filter/index/page/'.$this->page.'/modifyresult/forbidden'); - } - }catch (Zend_Exception $e) { - echo "Error message 2: " . $e->getMessage() . "\n"; - $this->_redirect('/user/filter/index/page/'.$this->page.'/modifyresult/error'); - } - } - } - - private function prepareFormData(){ - $poolMapper = new Application_Model_PoolMapper(); - $pools = $poolMapper->findBy(array('groupID'=>$this->membership->getGroupID()),true); - - $bootisoMapper = new Application_Model_BootIsoMapper(); - $bootisos = $bootisoMapper->findBy(array('groupID'=>$this->membership->getGroupID()),true); - - $membershipMapper = new Application_Model_MembershipMapper(); - $memberships = $membershipMapper->findBy(array('groupID'=>$this->membership->getGroupID()),true); - - $grouppMapper = new Application_Model_GroupMapper(); - $group = new Application_Model_Group(); - $grouppMapper->find($this->membership->getGroupID(),$group); - $groups[] = $group->toArray(); - - $clientMapper = new Application_Model_ClientMapper(); - $clients = $clientMapper->findBy(array('groupID'=>$this->membership->getGroupID()),true); - - return array ( 'clients' => $clients, - 'memberships' => $memberships, - 'groups' => $groups, - 'bootisos' => $bootisos, - 'pools' => $pools); - - } - - public function addfilterentryAction() - { - // ACL: is he allowed to create a new filterentry? - if(!Pbs_Acl::checkRight('ffa')) - $this->_redirect('/user'); - - $filterID = $this->_request->getParam('filterID'); - $filterMapper = new Application_Model_FilterMapper(); - $filter = new Application_Model_Filter(); - $filterMapper->find($filterID,$filter); - - $selectData = $this->prepareFormData(); - - if($filter->getGroupID() == $this->membership->getGroupID()){ - if (!isset($_POST["add"])){ - try{ - $addform = new user_Form_FilterEntry(array( - 'buttontext' => 'Add Filterentry', - 'filterID' => $filterID, - 'selectData' => $selectData, - 'data' => $_POST, - 'page' => $this->page)); - $addform->populate($_POST); - $this->view->addform = $addform; - }catch (Zend_Exception $e) { - echo "Error message 2: " . $e->getMessage() . "\n"; - $this->_redirect('/user/filter/index/page/'.$this->page.'/addresult/error'); - } - } else{ - $addform = new user_Form_FilterEntry(array( - 'buttontext' => 'Add Filterentry', - 'selectData' => $selectData, - 'data' => $_POST, - 'page' => $this->page)); - if ($addform->isValid($_POST)) { - # print_a('valid'); - $newfilterenty = new Application_Model_FilterEntries(); - $newfilterenty->setFilterID($filterID) - ->setFiltertypeID($_POST['filtertypeID']); - - if($_POST['filtertypeID'] == 1){ - $newfilterenty->setFiltervalue($this->fillup($_POST['filtervalue'],3,'.')); - $newfilterenty->setFiltervalue2($this->fillup($_POST['filtervalue2'],3,'.')); - } - elseif($_POST['filtertypeID'] == 2){ - $newfilterenty->setFiltervalue($this->fillup($_POST['filtervalue'],2,':')); - $newfilterenty->setFiltervalue2($this->fillup($_POST['filtervalue2'],2,':')); - } - else{ - $newfilterenty->setFiltervalue($_POST['filtervalue']); - if(isset($_POST['filtervalue2'])){ - $newfilterenty->setFiltervalue2($_POST['filtervalue2']); - } - } - - $newfilter2 = new Application_Model_FilterEntriesMapper(); - $newfilter2->save($newfilterenty); - $this->_redirect('/user/filter/index/page/'.$this->page.'/addresult/ok'); - } - $this->view->addform = $addform; - } - } - else{ - $this->_redirect('/user/filter/index/page/'.$this->page.'/addresult/forbidden'); - } - } - - public function editfilterentryAction() - { - //ACL: is he allowed to edit filterentrys ? - if(!Pbs_Acl::checkRight('ffe')) - $this->_redirect('/user'); - $selectData = $this->prepareFormData(); - if (!isset($_POST["add"])){ - try{ - $filterentriesID = $this->_request->getParam('filterentriesID'); - $filterentry = new Application_Model_FilterEntries(); - $filterentriesmapper = new Application_Model_FilterEntriesMapper(); - $filterentriesmapper->find($filterentriesID,$filterentry); - - $filterMapper = new Application_Model_FilterMapper(); - $filter = new Application_Model_Filter(); - $filterMapper->find($filterentry->getFilterID(),$filter); - - if($filter->getGroupID() == $this->membership->getGroupID()){ - if(isset($_POST['filtertypeID']) && $_POST['filtertypeID'] != $filterentry->getFiltertypeID()){ - $filterentry->setFiltertypeID($_POST['filtertypeID']) ; - } - $data = $filterentry->toArray(); - $editfilterform = new user_Form_FilterEntry(array( - 'buttontext' => 'Edit Filterentry', - 'selectData' => $selectData, - 'data' => $data, - 'page' => $this->page)); - - $editfilterform->populate($filterentry->toArray()); - $this->view->editfilterform = $editfilterform; - } - else{ - $this->_redirect('/user/filter/index/page/'.$this->page.'/modifyresult/forbidden'); - } - }catch (Zend_Exception $e) { - echo "Error message 2: " . $e->getMessage() . "\n"; - $this->_redirect('/user/filter/index/page/'.$this->page.'/modifyresult/error'); - } - } else{ - try{ - $filterentriesID = $this->_request->getParam('filterentriesID'); - $editfilterform = new user_Form_FilterEntry(array( - 'buttontext' => 'Edit Filterentry', - 'selectData' => $selectData, - 'data' => $_POST, - 'page' => $this->page)); - if ($editfilterform->isValid($_POST)) { - $filterentry = new Application_Model_FilterEntries(); - $filterentriesmapper = new Application_Model_FilterEntriesMapper(); - $filterentriesmapper->find($filterentriesID,$filterentry); - - $filterMapper = new Application_Model_FilterMapper(); - $filter = new Application_Model_Filter(); - $filterMapper->find($filterentry->getFilterID(),$filter); - - if($filter->getGroupID() == $this->membership->getGroupID()){ - if($_POST['filterID'] == '') - unset($_POST['filterID']); - - $newfilterenty = new Application_Model_FilterEntries($_POST); - $newfilterenty->setID($filterentriesID); - if($_POST['filtertypeID'] == 1){ - $newfilterenty->setFiltervalue($this->fillup($_POST['filtervalue'],3,'.')); - $newfilterenty->setFiltervalue2($this->fillup($_POST['filtervalue2'],3,'.')); - } - elseif($_POST['filtertypeID'] == 2){ - $newfilterenty->setFiltervalue($this->fillup($_POST['filtervalue'],2,';')); - $newfilterenty->setFiltervalue2($this->fillup($_POST['filtervalue2'],2,':')); - } - else{ - $newfilterenty->setFiltervalue($_POST['filtervalue']); - $newfilterenty->setFiltervalue2($_POST['filtervalue2']); - } - - $newfilter2 = new Application_Model_FilterEntriesMapper(); - $newfilter2->save($newfilterenty); - $this->_redirect('/user/filter/index/page/'.$this->page.'/modifyresult/ok'); - - } - else{ - $this->_redirect('/user/filter/index/page/'.$this->page.'/modifyresult/forbidden'); - } - } - $this->view->editfilterform = $editfilterform; - }catch (Zend_Exception $e) { - echo "Error message 2: " . $e->getMessage() . "\n"; - $this->_redirect('/user/filter/index/page/'.$this->page.'/modifyresult/error'); - } - } - } - - public function removefilterentryAction() - { - //ACL: is he autohorized to delete a filterentry? - if(!Pbs_Acl::checkRight('ffd')) - $this->_redirect('/user'); - - $filterentriesID = $this->_request->getParam('filterentriesID'); - if(is_numeric($filterentriesID)){ - $filterentriesmapper = new Application_Model_FilterEntriesMapper(); - $filterentry = new Application_Model_FilterEntries(); - $filterentriesmapper->find($filterentriesID, $filterentry); - $filterID = $filterentry->getFilterID(); - - $filterMapper = new Application_Model_FilterMapper(); - $filter = new Application_Model_Filter(); - $filterMapper->find($filterID,$filter); - - if($filter->getGroupID() == $this->membership->getGroupID()){ - try{ - $deletefilterentry = new Application_Model_FilterEntries(); - $deletefilterentry->setID($filterentriesID); - - $filterentriesmapper = new Application_Model_FilterEntriesMapper(); - $filterentriesmapper->delete($deletefilterentry); - $this->_redirect('/user/filter/index/page/'.$this->page.'/deleteresult/ok'); - - }catch (Zend_Exception $e) { - echo "Error message 2: " . $e->getMessage() . "\n"; - $this->_redirect('/user/filter/index/page/'.$this->page.'/deleteresult/error'); - } - } - else{ - $this->_redirect('/user/filter/index/page/'.$this->page.'/deleteresult/forbidden'); - } - } - else{ - $this->_redirect('/user/filter/index/page/'.$this->page.'/deleteresult/error'); - } - } - private function fillup($string, $length, $seperator=':',$sign='0'){ - $ar = explode($seperator,$string); - $representation = array(); - foreach($ar as $part){ - $representation[] = sprintf("%".$sign.$length."s",$part); - } - return implode($seperator,$representation); - } -} - - - - - - - - - - - - - + + + + + + + + + +git.openslx.org - openslx-ng/pbs2.git/blob - application/modules/user/controllers/FilterController.php + + + + + + + + + + +
+ +
+ +
+filter group fix +
+
[openslx-ng/pbs2.git] / application / modules / user / controllers / FilterController.php
+
+
1 <?php
+
2 /*
+
3  * Copyright (c) 2011 - OpenSLX GmbH, RZ Uni Freiburg
+
4  * This program is free software distributed under the GPL version 2.
+
5  * See http://gpl.openslx.org/
+
6  *
+
7  * If you have any feedback please consult http://feedback.openslx.org/ and
+
8  * send your suggestions, praise, or complaints to feedback@openslx.org
+
9  *
+
10  * General information about OpenSLX can be found at http://openslx.org/
+
11  */
+
12
+
13 class User_FilterController extends Zend_Controller_Action
+
14 {
+
15         protected $filterMapper;
+
16         protected $membershipMapper;
+
17         protected $page;
+
18         public function init()
+
19         {
+
20                 if (Zend_Auth::getInstance()->hasIdentity()) {
+
21                         $userIDsNamespace = Zend_Session::namespaceGet('userIDs');
+
22                         if($userIDsNamespace['membershipID'] ==''){
+
23                                 $pbsNotifier = new Pbs_Notifier();
+
24                                 echo $pbsNotifier->notify('No membershipID set','forbidden');
+
25                         }
+
26                         $this->filterMapper = new Application_Model_FilterMapper();
+
27
+
28                         $membershipMapper = new Application_Model_MembershipMapper();
+
29                         $this->membership = new Application_Model_Membership();
+
30                         $membershipMapper->find($userIDsNamespace['membershipID'],$this->membership);
+
31
+
32                         $this->db = Zend_Db_Table::getDefaultAdapter();
+
33                 } else {
+
34                         $this->_helper->redirector('login', 'auth');
+
35                 }
+
36                 $this->page = $this->_request->getParam('page');
+
37         }
+
38
+
39         public function indexAction()
+
40         {
+
41                 // ACL: Is he allowed to see the overview
+
42                 if(!Pbs_Acl::checkRight('fo'))
+
43                 $this->_redirect('/user');
+
44                         
+
45                 $result = $this->_request->getParam('addresult');
+
46                 if($result != ""){
+
47                         $pbsNotifier = new Pbs_Notifier();
+
48                         $this->view->notification = $pbsNotifier->notify('create',$result);
+
49                 }
+
50                 $result = $this->_request->getParam('deleteresult');
+
51                 if($result != ""){
+
52                         $pbsNotifier = new Pbs_Notifier();
+
53                         $this->view->notification = $pbsNotifier->notify('delete',$result);
+
54                 }
+
55                 $result = $this->_request->getParam('modifyresult');
+
56                 if($result != ""){
+
57                         $pbsNotifier = new Pbs_Notifier();
+
58                         $this->view->notification = $pbsNotifier->notify('modify',$result);
+
59                 }
+
60                         
+
61                 $filters = $this->filterMapper->findBy(array('groupID' => $this->membership->getGroupID(),'membershipID'=>null),true,array('priority'=>'DESC'));
+
62                 $bootmenuMapper = new Application_Model_BootMenuMapper();
+
63                 foreach($filters as $filter){
+
64                         $ff = new Application_Model_Filter();
+
65                         $ff->setOptions($filter);
+
66                         $ff->setID($filter['filterID']);
+
67                         $ff->setBootmenuID("[".$ff->getBootmenuID()."] ".$bootmenuMapper->find($ff->getBootmenuID())->getTitle());
+
68                         $ff->setCreated(date(Zend_Registry::get('dateformat'),$ff->getCreated()));
+
69                         $allFilter[] = $ff;
+
70                 }
+
71                  
+
72                 // Search
+
73                 $search = $this->_request->getParam('search');
+
74                 $mySearch = new Pbs_Search();
+
75                 $mySearch->setSearchTerm($search)->setModule('filter');
+
76                 if($search != ''){
+
77                         $this->view->search = $mySearch->getSearchTerm();
+
78                         $allFilter = $mySearch->search($allFilter);
+
79                 }
+
80                 $this->view->searchform = $mySearch->searchForm();
+
81
+
82                 // Pagination
+
83                 $pagination = new Pbs_Pagination();
+
84                 $pagination->setPerPage(10)
+
85                                         ->setElement($allFilter)
+
86                                         ->setRequestPage($this->_request->getParam('page'))
+
87                                         ->setPageUrl('/user/filter/index'.((isset($this->view->search))?'/search/'.$this->view->search:''));
+
88                 $allFilter = $pagination->getElements();
+
89
+
90                 $this->view->pagination = $pagination->pagination();
+
91                 $this->view->page               = $pagination->getRequestPage();
+
92                 $this->view->filters = $allFilter;
+
93
+
94         }
+
95
+
96         public function searchAction(){
+
97                 $this->_redirect('/user/filter/index/search/'.($_GET['search']));
+
98         }
+
99
+
100         public function addfilterAction()
+
101         {
+
102                 // ACL: Is he allowed to add a Filter
+
103                 if(!Pbs_Acl::checkRight('fa'))
+
104                 $this->_redirect('/user');
+
105                         
+
106                 $bmmapper = new Application_Model_BootMenuMapper();
+
107
+
108                 $result = $bmmapper->findBy(array('groupID' => $this->membership->getGroupID()),true);
+
109
+
110                 foreach($result as $rr){
+
111                         $bm = new Application_Model_BootMenu();
+
112                         $bm->setOptions($rr);
+
113                         $bm->setID($rr['bootmenuID']);
+
114                         $bootmenus[] = $bm;
+
115                 }
+
116
+
117                 $this->view->bootmenus = $bootmenus;
+
118
+
119                 if (!isset($_POST["add"])){
+
120                         $addfilterform = new user_Form_Filter(array(
+
121                                                                                 'buttontext' => 'Create Filter',
+
122                                                                                 'bootmenus'=>$bootmenus,
+
123                                                                                 'page' => $this->page));
+
124                         $this->view->addfilterform = $addfilterform;
+
125                 }else {
+
126                         $addfilterform = new user_Form_Filter(array(
+
127                                                                                 'buttontext' => 'Create Filter',
+
128                                                                                 'bootmenus'=>$bootmenus,
+
129                                                                                 'page' => $this->page),$_POST);
+
130                         if ($addfilterform->isValid($_POST)) {
+
131                                 try{
+
132                                         $newfilter = new Application_Model_Filter($_POST);
+
133                                         $newfilter->setCreated(time())
+
134                                                                 ->setGroupID($this->membership->getGroupID())
+
135                                                                 ->setMembershipID(null);
+
136                                         $newfilter2 = new Application_Model_FilterMapper();
+
137                                         $id = $newfilter2->save($newfilter);
+
138
+
139                                         $filterentriesMapper = new Application_Model_FilterEntriesMapper();
+
140                                         $filterentry = new Application_Model_FilterEntries();
+
141                                         $filterentry->setFilterID($id)
+
142                                                                 ->setFiltertypeID(6)
+
143                                                                 ->setFiltervalue($this->membership->getGroupID());
+
144                                         $filterentriesMapper->save($filterentry);
+
145
+
146                                         $this->_redirect('/user/filter/index/page/'.$this->page.'/addresult/ok');
+
147                                 }catch (Zend_Exception $e) {
+
148                                         echo "Error message 2: " . $e->getMessage() . "\n";
+
149                                         $this->_redirect('/user/filter/index/page/'.$this->page.'/addresult/error');
+
150                                 }
+
151                         }
+
152                         $this->view->addfilterform = $addfilterform;
+
153                 }
+
154         }
+
155
+
156         public function removefilterAction()
+
157         {
+
158                 $filterID = $this->_request->getParam('filterID');
+
159                 $filtermapper = new Application_Model_FilterMapper();
+
160
+
161                 // ACL: Is he allowed to remove the filter
+
162                 if(!Pbs_Acl::checkRight('fd'))
+
163                 $this->_redirect('/user');
+
164
+
165                 if(is_numeric($filterID)){
+
166                         $filter = new Application_Model_Filter();
+
167                         $filtermapper->find($filterID,$filter);
+
168                         if($filter->getGroupID() == $this->membership->getGroupID()){
+
169                                 $deletefilter = new Application_Model_Filter();
+
170                                 $deletefilter->setID($filterID);
+
171                                 $filtermapper->delete($deletefilter);
+
172                                 $this->_redirect('/user/filter/index/page/'.$this->page.'/deleteresult/ok');
+
173                         }
+
174                         else{
+
175                                 $this->_redirect('/user/filter/index/page/'.$this->page.'/deleteresult/forbidden');
+
176                         }
+
177                 }
+
178                 else{
+
179                         $this->_redirect('/user/filter/index/page/'.$this->page.'/deleteresult/error');
+
180                 }
+
181         }
+
182
+
183         public function editfilterAction()
+
184         {
+
185                 $bmmapper = new Application_Model_BootMenuMapper();
+
186                 $result = $bmmapper->findBy(array('groupID' => $this->membership->getGroupID()),true);
+
187                 foreach($result as $rr){
+
188                         $bm = new Application_Model_BootMenu();
+
189                         $bm->setOptions($rr);
+
190                         $bm->setID($rr['bootmenuID']);
+
191                         $bootmenus[] = $bm;
+
192                 }
+
193
+
194                 // ACL: Is he allowed to edit the filter or the filterpriority?
+
195                 if(!Pbs_Acl::checkRight('fe') && !Pbs_Acl::checkRight('fefp'))
+
196                 $this->_redirect('/user');
+
197
+
198                 if (!isset($_POST["add"])){
+
199                         $filterID = $this->_request->getParam('filterID');
+
200                         $filter = new Application_Model_Filter();
+
201
+
202                         $filtermapper = new Application_Model_FilterMapper();
+
203                         $filtermapper->find($filterID,$filter);
+
204                         if($filter->getGroupID() == $this->membership->getGroupID()){
+
205                                 $filter2 = $filter->toArray();
+
206                                 $editfilterform = new user_Form_Filter(array(
+
207                                                                                         'buttontext' => 'Edit Filter',
+
208                                                                                         'bootmenus'=>$bootmenus,
+
209                                                                                         'page' => $this->page));
+
210                                 $editfilterform->populate($filter2);
+
211                                 $this->view->editfilterform = $editfilterform;
+
212                         }
+
213                         else{
+
214                                 $this->_redirect('/user/filter/index/page/'.$this->page.'/modifyresult/forbidden');
+
215                         }
+
216                 } else{
+
217                         try{
+
218                                 $filterID = $this->_request->getParam('filterID');
+
219                                 $filter = new Application_Model_Filter();
+
220                                 $filtermapper = new Application_Model_FilterMapper();
+
221                                 $filtermapper->find($filterID,$filter);
+
222                                 if($filter->getGroupID() == $this->membership->getGroupID()){
+
223                                         $editfilterform = new user_Form_Filter(array(
+
224                                                                                                 'buttontext' => 'Edit Filter',
+
225                                                                                                 'bootmenus'=>$bootmenus,
+
226                                                                                                 'page' => $this->page),$_POST);
+
227                                         if ($editfilterform->isValid($_POST)) {
+
228                                                 $filtermapper = new Application_Model_FilterMapper();
+
229
+
230                                                 $newfilterentry = new Application_Model_Filter($_POST);
+
231                                                 $newfilterentry->setID($this->_request->getParam('filterID'))
+
232                                                                                 ->setGroupID($this->membership->getGroupID())
+
233                                                                                 ->setMembershipID(null);
+
234
+
235                                                 // ACL: if he is only allowed to edit filterpriority
+
236                                                 if(Pbs_Acl::checkRight('fefp') && !Pbs_Acl::checkRight('fe')){
+
237                                                         $DBfilterentry = new Application_Model_Filter();
+
238                                                         $filtermapper->find($this->_request->getParam('filterID'),$DBfilterentry);
+
239
+
240                                                         $compareresult = $filtermapper->compare($newfilterentry,$DBfilterentry);
+
241                                                         if(isset($compareresult['priority']) && count($compareresult) == 1){
+
242                                                                 $filtermapper->save($newfilterentry);
+
243                                                                 $this->_redirect('/user/filter/index/page/'.$this->page.'/modifyresult/ok');
+
244                                                         }
+
245                                                         else{
+
246                                                                 $this->_redirect('/user/filter/index/page/'.$this->page.'/modifyresult/forbidden');
+
247                                                         }
+
248                                                 }
+
249                                                 // ACL: he is allowed to edit the filter
+
250                                                 elseif(Pbs_Acl::checkRight('fe')){
+
251                                                         $filtermapper->save($newfilterentry);
+
252                                                         $this->_redirect('/user/filter/index/page/'.$this->page.'/modifyresult/ok');
+
253                                                 }
+
254                                         }
+
255                                         $this->view->editfilterform = $editfilterform;
+
256                                 }
+
257                                 else{
+
258                                         $this->_redirect('/user/filter/index/page/'.$this->page.'/modifyresult/forbidden');
+
259                                 }
+
260                         }catch (Zend_Exception $e) {
+
261                                 echo "Error message 2: " . $e->getMessage() . "\n";
+
262                                 $this->_redirect('/user/filter/index/page/'.$this->page.'/modifyresult/error');
+
263                         }
+
264                 }
+
265         }
+
266
+
267         private function prepareFormData(){
+
268                 $poolMapper = new Application_Model_PoolMapper();
+
269                 $pools = $poolMapper->findBy(array('groupID'=>$this->membership->getGroupID()),true);
+
270                         
+
271                 $bootisoMapper = new Application_Model_BootIsoMapper();
+
272                 $bootisos = $bootisoMapper->findBy(array('groupID'=>$this->membership->getGroupID()),true);
+
273                         
+
274                 $membershipMapper = new Application_Model_MembershipMapper();
+
275                 $memberships = $membershipMapper->findBy(array('groupID'=>$this->membership->getGroupID()),true);
+
276
+
277                 $grouppMapper = new Application_Model_GroupMapper();
+
278                 $group = new Application_Model_Group();
+
279                 $grouppMapper->find($this->membership->getGroupID(),$group);
+
280                 $groups[] = $group->toArray();
+
281
+
282                 $clientMapper = new Application_Model_ClientMapper();
+
283                 $clients = $clientMapper->findBy(array('groupID'=>$this->membership->getGroupID()),true);
+
284                         
+
285                 return array (  'clients'               => $clients,
+
286                                         'memberships'   => $memberships,
+
287                                         'groups'                => $groups,
+
288                                         'bootisos'              => $bootisos,
+
289                                         'pools'                 => $pools);
+
290                         
+
291         }
+
292
+
293         public function addfilterentryAction()
+
294         {
+
295                 // ACL: is he allowed to create a new filterentry?
+
296                 if(!Pbs_Acl::checkRight('ffa'))
+
297                 $this->_redirect('/user');
+
298
+
299                 $filterID = $this->_request->getParam('filterID');
+
300                 $filterMapper = new Application_Model_FilterMapper();
+
301                 $filter = new Application_Model_Filter();
+
302                 $filterMapper->find($filterID,$filter);
+
303                         
+
304                 $selectData = $this->prepareFormData();
+
305                         
+
306                 if($filter->getGroupID() == $this->membership->getGroupID()){
+
307                         if (!isset($_POST["add"])){
+
308                                 try{
+
309                                         $addform = new user_Form_FilterEntry(array(
+
310                                                                                                                 'buttontext' => 'Add Filterentry',
+
311                                                                                                                 'filterID' => $filterID,
+
312                                                                                                                 'selectData' => $selectData,
+
313                                                                                                                 'data' => $_POST,
+
314                                                                                                                 'page' => $this->page));
+
315                                         $addform->populate($_POST);
+
316                                         $this->view->addform = $addform;
+
317                                 }catch (Zend_Exception $e) {
+
318                                         echo "Error message 2: " . $e->getMessage() . "\n";
+
319                                         $this->_redirect('/user/filter/index/page/'.$this->page.'/addresult/error');
+
320                                 }
+
321                         } else{
+
322                                 $addform = new user_Form_FilterEntry(array(
+
323                                                                                                         'buttontext' => 'Add Filterentry',
+
324                                                                                                         'selectData' => $selectData,                                            
+
325                                                                                                         'data' => $_POST,
+
326                                                                                                         'page' => $this->page));
+
327                                 if ($addform->isValid($_POST)) {
+
328                                         # print_a('valid');
+
329                                         $newfilterenty = new Application_Model_FilterEntries();
+
330                                         $newfilterenty->setFilterID($filterID)
+
331                                                                         ->setFiltertypeID($_POST['filtertypeID']);
+
332
+
333                                         if($_POST['filtertypeID'] == 1){
+
334                                                 $newfilterenty->setFiltervalue($this->fillup($_POST['filtervalue'],3,'.'));
+
335                                                 $newfilterenty->setFiltervalue2($this->fillup($_POST['filtervalue2'],3,'.'));
+
336                                         }
+
337                                         elseif($_POST['filtertypeID'] == 2){
+
338                                                 $newfilterenty->setFiltervalue($this->fillup($_POST['filtervalue'],2,':'));
+
339                                                 $newfilterenty->setFiltervalue2($this->fillup($_POST['filtervalue2'],2,':'));
+
340                                         }
+
341                                         elseif($_POST['filtertypeID'] == 11){
+
342                                                 $newfilterenty->setFiltervalue(strtotime($_POST['filtervalue']));
+
343                                                 $newfilterenty->setFiltervalue2(strtotime($_POST['filtervalue2']));
+
344                                         }
+
345                                         else{
+
346                                                 $newfilterenty->setFiltervalue($_POST['filtervalue']);
+
347                                                 if(isset($_POST['filtervalue2'])){
+
348                                                         $newfilterenty->setFiltervalue2($_POST['filtervalue2']);
+
349                                                 }
+
350                                         }
+
351
+
352                                         $newfilter2 = new Application_Model_FilterEntriesMapper();
+
353                                         $newfilter2->save($newfilterenty);
+
354                                         $this->_redirect('/user/filter/index/page/'.$this->page.'/addresult/ok');
+
355                                 }
+
356                                 $this->view->addform = $addform;
+
357                         }
+
358                 }
+
359                 else{
+
360                         $this->_redirect('/user/filter/index/page/'.$this->page.'/addresult/forbidden');
+
361                 }
+
362         }
+
363
+
364         public function editfilterentryAction()
+
365         {
+
366                 //ACL: is he allowed to edit filterentrys ?
+
367                 if(!Pbs_Acl::checkRight('ffe'))
+
368                 $this->_redirect('/user');
+
369                 $selectData = $this->prepareFormData();
+
370                 if (!isset($_POST["add"])){
+
371                         try{
+
372                                 $filterentriesID = $this->_request->getParam('filterentriesID');
+
373                                 $filterentry = new Application_Model_FilterEntries();
+
374                                 $filterentriesmapper = new Application_Model_FilterEntriesMapper();
+
375                                 $filterentriesmapper->find($filterentriesID,$filterentry);
+
376
+
377                                 $filterMapper = new Application_Model_FilterMapper();
+
378                                 $filter = new Application_Model_Filter();
+
379                                 $filterMapper->find($filterentry->getFilterID(),$filter);
+
380
+
381                                 if($filter->getGroupID() == $this->membership->getGroupID()){
+
382                                         if(isset($_POST['filtertypeID']) && $_POST['filtertypeID'] != $filterentry->getFiltertypeID()){
+
383                                                 $filterentry->setFiltertypeID($_POST['filtertypeID']) ;
+
384                                         }
+
385                                         if($filterentry->getFiltertypeID() == 11){
+
386                                                 $filterentry->setFiltervalue(date('d.m.Y',$filterentry->getFiltervalue()));
+
387                                                 $filterentry->setFiltervalue2(date('d.m.Y',$filterentry->getFiltervalue2()));
+
388                                         }
+
389                                         $data = $filterentry->toArray();
+
390                                         $editfilterform = new user_Form_FilterEntry(array(
+
391                                                                                                                                 'buttontext' => 'Edit Filterentry',
+
392                                                                                                                                 'selectData' => $selectData,            
+
393                                                                                                                                 'data' => $data,
+
394                                                                                                                                 'page' => $this->page));
+
395
+
396                                         $editfilterform->populate($filterentry->toArray());
+
397                                         $this->view->editfilterform = $editfilterform;
+
398                                 }
+
399                                 else{
+
400                                         $this->_redirect('/user/filter/index/page/'.$this->page.'/modifyresult/forbidden');
+
401                                 }
+
402                         }catch (Zend_Exception $e) {
+
403                                 echo "Error message 2: " . $e->getMessage() . "\n";
+
404                                 $this->_redirect('/user/filter/index/page/'.$this->page.'/modifyresult/error');
+
405                         }
+
406                 } else{
+
407                         try{
+
408                                 $filterentriesID = $this->_request->getParam('filterentriesID');
+
409                                 $editfilterform = new user_Form_FilterEntry(array(
+
410                                                                                                                         'buttontext' => 'Edit Filterentry',
+
411                                                                                                                         'selectData' => $selectData,
+
412                                                                                                                         'data' => $_POST,
+
413                                                                                                                         'page' => $this->page));
+
414                                 if ($editfilterform->isValid($_POST)) {
+
415                                         $filterentry = new Application_Model_FilterEntries();
+
416                                         $filterentriesmapper = new Application_Model_FilterEntriesMapper();
+
417                                         $filterentriesmapper->find($filterentriesID,$filterentry);
+
418
+
419                                         $filterMapper = new Application_Model_FilterMapper();
+
420                                         $filter = new Application_Model_Filter();
+
421                                         $filterMapper->find($filterentry->getFilterID(),$filter);
+
422
+
423                                         if($filter->getGroupID() == $this->membership->getGroupID()){
+
424                                                 if($_POST['filterID'] == '')
+
425                                                 unset($_POST['filterID']);
+
426
+
427                                                 $newfilterenty = new Application_Model_FilterEntries($_POST);
+
428                                                 $newfilterenty->setID($filterentriesID);
+
429                                                 if($_POST['filtertypeID'] == 1){
+
430                                                         $newfilterenty->setFiltervalue($this->fillup($_POST['filtervalue'],3,'.'));
+
431                                                         $newfilterenty->setFiltervalue2($this->fillup($_POST['filtervalue2'],3,'.'));
+
432                                                 }
+
433                                                 elseif($_POST['filtertypeID'] == 2){
+
434                                                         $newfilterenty->setFiltervalue($this->fillup($_POST['filtervalue'],2,';'));
+
435                                                         $newfilterenty->setFiltervalue2($this->fillup($_POST['filtervalue2'],2,':'));
+
436                                                 }
+
437                                                 elseif($_POST['filtertypeID'] == 11){
+
438                                                         $newfilterenty->setFiltervalue(strtotime($_POST['filtervalue']));
+
439                                                         $newfilterenty->setFiltervalue2(strtotime($_POST['filtervalue2']));
+
440                                                 }
+
441                                                 else{
+
442                                                         $newfilterenty->setFiltervalue($_POST['filtervalue']);
+
443                                                         $newfilterenty->setFiltervalue2($_POST['filtervalue2']);
+
444                                                 }
+
445
+
446                                                 $newfilter2 = new Application_Model_FilterEntriesMapper();
+
447                                                 $newfilter2->save($newfilterenty);
+
448                                                 $this->_redirect('/user/filter/index/page/'.$this->page.'/modifyresult/ok');
+
449
+
450                                         }
+
451                                         else{
+
452                                                 $this->_redirect('/user/filter/index/page/'.$this->page.'/modifyresult/forbidden');
+
453                                         }
+
454                                 }
+
455                                 $this->view->editfilterform = $editfilterform;
+
456                         }catch (Zend_Exception $e) {
+
457                                 echo "Error message 2: " . $e->getMessage() . "\n";
+
458                                 $this->_redirect('/user/filter/index/page/'.$this->page.'/modifyresult/error');
+
459                         }
+
460                 }
+
461         }
+
462
+
463         public function removefilterentryAction()
+
464         {
+
465                 //ACL: is he autohorized to delete a filterentry?
+
466                 if(!Pbs_Acl::checkRight('ffd'))
+
467                 $this->_redirect('/user');
+
468                         
+
469                 $filterentriesID = $this->_request->getParam('filterentriesID');
+
470                 if(is_numeric($filterentriesID)){
+
471                         $filterentriesmapper = new Application_Model_FilterEntriesMapper();
+
472                         $filterentry = new Application_Model_FilterEntries();
+
473                         $filterentriesmapper->find($filterentriesID, $filterentry);
+
474                         $filterID = $filterentry->getFilterID();
+
475
+
476                         $filterMapper = new Application_Model_FilterMapper();
+
477                         $filter = new Application_Model_Filter();
+
478                         $filterMapper->find($filterID,$filter);
+
479
+
480                         if($filter->getGroupID() == $this->membership->getGroupID()){
+
481                                 try{
+
482                                         $deletefilterentry = new Application_Model_FilterEntries();
+
483                                         $deletefilterentry->setID($filterentriesID);
+
484
+
485                                         $filterentriesmapper = new Application_Model_FilterEntriesMapper();
+
486                                         $filterentriesmapper->delete($deletefilterentry);
+
487                                         $this->_redirect('/user/filter/index/page/'.$this->page.'/deleteresult/ok');
+
488                                                 
+
489                                 }catch (Zend_Exception $e) {
+
490                                         echo "Error message 2: " . $e->getMessage() . "\n";
+
491                                         $this->_redirect('/user/filter/index/page/'.$this->page.'/deleteresult/error');
+
492                                 }
+
493                         }
+
494                         else{
+
495                                 $this->_redirect('/user/filter/index/page/'.$this->page.'/deleteresult/forbidden');
+
496                         }
+
497                 }
+
498                 else{
+
499                         $this->_redirect('/user/filter/index/page/'.$this->page.'/deleteresult/error');
+
500                 }
+
501         }
+
502         private function fillup($string, $length, $seperator=':',$sign='0'){
+
503                 $ar = explode($seperator,$string);
+
504                 $representation = array();
+
505                 foreach($ar as $part){
+
506                         $representation[] = sprintf("%".$sign.$length."s",$part);
+
507                 }
+
508                 return implode($seperator,$representation);
+
509         }
+
510 }
+
511
+
512
+
513
+
514
+
515
+
516
+
517
+
518
+
519
+
520
+
521
+
522
+
523
+
+ + + \ No newline at end of file diff --git a/application/modules/user/forms/FilterEntry.php b/application/modules/user/forms/FilterEntry.php old mode 100755 new mode 100644 index 12fd00c..1ac06b9 --- a/application/modules/user/forms/FilterEntry.php +++ b/application/modules/user/forms/FilterEntry.php @@ -1,424 +1,477 @@ -buttontext = $v; - } - public function setData($v){ - $this->data = $v; - } - public function setFilterID($v){ - $this->filterID = $v; - } - public function setSelectData($v){ - $this->selectData = $v; - } - public function setPage($page){ - $this->page = $page; - } - - public function init() - { - $this->setName("Add Filterentry"); - $this->setMethod('post'); - $this->setAttrib('id','filterentryform'); - #print_a($this->data); - #print_a($this->selectData); - try{ - $filtertypemapper = new Application_Model_FilterTypeMapper(); - $filtertype = $filtertypemapper->fetchAll(); - - $filtertypes = $this->createElement('select','filtertypeID'); - $filtertypes ->setLabel('Type:'); - $filtertypes ->setAttrib('id','filtertype'); - $filtertypes->addMultiOption('',''); - foreach($filtertype as $f){ - $filtertypes->addMultiOption($f->getID(),$f->getFiltertypename()); - } - $filterentry = $filtertypes->getMultiOption($this->data['filtertypeID']); - $filterentryID = $this->data['filtertypeID']; - }catch (Zend_Exception $e) { - echo "Error message 1: " . $e->getMessage() . "\n"; - } - switch($filterentryID){ - default: - $desc = "Select the filtertype"; - $label1 = 'Value 1:'; - $label2 = 'Value 2:'; - $filtervalue1 = $this->createElement('text', 'filtervalue', array( - 'label' => $label1, - 'id' => 'val1' - )); - $filtervalue2 = $this->createElement('text', 'filtervalue2', array( - 'label' => $label2, - 'id' => 'val2' - )); - break; - case "1": - $desc = "You can set one IP or an IP-Range"; - $label1 = 'Start:'; - $label2 = 'End:'; - - $filtervalue1 = $this->createElement('text', 'filtervalue', array( - 'label' => $label1, - 'validators' => array( - array( - 'regex', - false, - array( - '/^(([0-9]|[1-9][0-9]|0[0-9]{2}|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([[0-9]|[1-9][0-9]|0[0-9]{2}|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/i', - 'messages' => array( - Zend_Validate_Regex::NOT_MATCH => "'%value%' is not a valid IP-Adress", - Zend_Validate_Regex::INVALID => 'IP-Adress contains invalid characters.' - ) - ) - ) - ), - 'required' => true, - 'id' => 'val1' - )); - $filtervalue2 = $this->createElement('text', 'filtervalue2', array( - 'label' => $label2, - 'validators' => array( - array( - 'regex', - false, - array( - '/^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/i', - 'messages' => array( - Zend_Validate_Regex::NOT_MATCH => "'%value%' is not a valid IP-Adress", - Zend_Validate_Regex::INVALID => 'IP-Adress contains invalid characters.' - ) - ) - ) - ), - 'required' => true, - 'id' => 'val2' - )); - break; - case "2": - $desc = "You can set one Mac-Adress or an Mac-Range"; - $label1 = 'Start:'; - $label2 = 'End:'; - - $filtervalue1 = $this->createElement('text', 'filtervalue', array( - 'label' => $label1, - 'validators' => array( - array( - 'regex', - false, - array( - '/^[0-9A-F]{2}:[0-9A-F]{2}:[0-9A-F]{2}:[0-9A-F]{2}:[0-9A-F]{2}:[0-9A-F]{2}$/i', - 'messages' => array( - Zend_Validate_Regex::NOT_MATCH => "'%value%' is not a valid Mac-Adress", - Zend_Validate_Regex::INVALID => 'Mac-Adress contains invalid characters.' - ) - ) - ) - ), - 'required' => true, - 'id' => 'val1' - )); - $filtervalue2 = $this->createElement('text', 'filtervalue2', array( - 'label' => $label2, - 'validators' => array( - array( - 'regex', - false, - array( - '/^[0-9A-F]{2}:[0-9A-F]{2}:[0-9A-F]{2}:[0-9A-F]{2}:[0-9A-F]{2}:[0-9A-F]{2}$/i', - 'messages' => array( - Zend_Validate_Regex::NOT_MATCH => "'%value%' is not a valid Mac-Adress", - Zend_Validate_Regex::INVALID => 'Mac-Adress contains invalid characters.' - ) - ) - ) - ), - 'required' => true, - 'id' => 'val2' - )); - break; - case "3": - $desc = "Select your Pool"; - $label1 = 'PoolID:'; - - $filtervalue1 = $this->createElement('select','filtervalue'); - $filtervalue1 ->setLabel($label1); - if(count($this->selectData['pools'])>0){ - foreach($this->selectData['pools'] as $id => $g){ - $filtervalue1->addMultiOption($g['poolID'], $g['title']); - } - } - $filtervalue1->setRegisterInArrayValidator(false); - break; - case "4": - $desc = "Select your BootIso"; - $label1 = 'BootIsoID:'; - - $filtervalue1 = $this->createElement('select','filtervalue'); - $filtervalue1 ->setLabel($label1); - if(count($this->selectData['bootisos'])>0){ - foreach($this->selectData['bootisos'] as $id => $g){ - $filtervalue1->addMultiOption($g['bootisoID'], $g['title']); - } - } - $filtervalue1->setRegisterInArrayValidator(false); - - break; - case "5": - $desc = "Select a Membership"; - $label1 = 'Membership:'; - - $filtervalue1 = $this->createElement('select','filtervalue'); - $filtervalue1 ->setLabel($label1); - if(count($this->selectData['memberships'])>0){ - $personMapper = new Application_Model_PersonMapper(); - foreach($this->selectData['memberships'] as $id => $g){ - // Display full name of Person - $person = new Application_Model_Person(); - $personMapper->find($g['personID'],$person); - $filtervalue1->addMultiOption($g['membershipID'], $person->getName().", ".$person->getFirstname()); - } - } - $filtervalue1->setRegisterInArrayValidator(false); - break; - case "6": - $desc = "For all members in this Group"; - $label1 = 'Group:'; - // TODO: insert the child Groups - $filtervalue1 = $this->createElement('select','filtervalue'); - $filtervalue1 ->setLabel($label1); - if(count($this->selectData['groups'])>0){ - foreach($this->selectData['groups'] as $id => $g){ - $filtervalue1->addMultiOption($g['groupID'], $g['title']); - } - } - $filtervalue1->setRegisterInArrayValidator(false); - break; - case "7": - $desc = "Specify a time-range"; - $label1 = 'Start:'; - $label2 = 'End:'; - - $filtervalue1 = $this->createElement('text', 'filtervalue', array( - 'label' => $label1, - 'validators' => array( - array( - 'regex', - false, - array( - '/^([0-1][0-9]|[2][0-3]):([0-5][0-9])$/i', - 'messages' => array( - Zend_Validate_Regex::NOT_MATCH => "'%value%' is not a valid Time-Format, It must be HH:MM", - Zend_Validate_Regex::INVALID => 'Time contains invalid characters.' - ) - ) - ) - ), - 'required' => true, - 'id' => 'val1' - )); - $filtervalue2 = $this->createElement('text', 'filtervalue2', array( - 'label' => $label2, - 'validators' => array( - array( - 'regex', - false, - array( - '/^([0-1][0-9]|[2][0-3]):([0-5][0-9])$/i', - 'messages' => array( - Zend_Validate_Regex::NOT_MATCH => "'%value%' is not a valid Time-Format, It must be HH:MM", - Zend_Validate_Regex::INVALID => 'Time contains invalid characters.' - ) - ) - ) - ), - 'required' => true, - 'id' => 'val2' - )); - echo ''; - break; - case "8": - $desc = "Select a Client"; - $label1 = 'Client:'; - - $filtervalue1 = $this->createElement('select','filtervalue'); - $filtervalue1 ->setLabel($label1); - if(count($this->selectData['clients'])>0){ - foreach($this->selectData['clients'] as $id => $g){ - $filtervalue1->addMultiOption($g['clientID'], $g['macadress']." - ".$g['hardwarehash']); - } - } - $filtervalue1->setRegisterInArrayValidator(false); - break; - case "9": - $desc = "Define a Hardwarehash"; - $label1 = 'Hardwarehash:'; - $filtervalue1 = $this->createElement('text', 'filtervalue', array( - 'label' => $label1, - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(32, 32)), - ), - 'required' => true, - 'id' => 'val1' - )); - break; - case "10": - $desc = "Specify the Weekday (Monday:1, Tuesday:2 ... Sunday:7) or a range"; - $label1 = 'Start Day:'; - $label2 = 'End Day:'; - - - - $filtervalue1 = $this->createElement('select','filtervalue', array( - 'label' => $label1, - 'validators' => array( - array( - 'regex', - false, - array( - '/^([1-7])$/i', - 'messages' => array( - Zend_Validate_Regex::NOT_MATCH => "'%value%' is not a valid Day-Format, It must be betweeen 1 and 7", - Zend_Validate_Regex::INVALID => 'Day contains invalid characters.' - ) - ) - ) - ), - 'required' => true, - 'id' => 'val1' - )); - $filtervalue1->addMultiOption(1, "Monday") - ->addMultiOption(2, "Tuesday") - ->addMultiOption(3, "Wednesday") - ->addMultiOption(4, "Thursday") - ->addMultiOption(5, "Friday") - ->addMultiOption(6, "Saturday") - ->addMultiOption(7, "Sunday"); - - - $filtervalue2 = $this->createElement('select', 'filtervalue2', array( - 'label' => $label2, - 'validators' => array( - array( - 'regex', - false, - array( - '/^([1-7])$/i', - 'messages' => array( - Zend_Validate_Regex::NOT_MATCH => "'%value%' is not a valid Day-Format, It must be betweeen 1 and 7", - Zend_Validate_Regex::INVALID => 'Day contains invalid characters.' - ) - ) - ) - ), - 'required' => true, - 'id' => 'val2' - )); - $filtervalue2->addMultiOption(1, "Monday") - ->addMultiOption(2, "Tuesday") - ->addMultiOption(3, "Wednesday") - ->addMultiOption(4, "Thursday") - ->addMultiOption(5, "Friday") - ->addMultiOption(6, "Saturday") - ->addMultiOption(7, "Sunday"); - break; - case "11": - $desc = "Specify the date or a day range of the filter"; - $label1 = 'Start Date:'; - $label2 = 'End Date:'; - - $filtervalue1 = $this->createElement('text', 'filtervalue', array( - 'label' => $label1, - 'required' => true, - 'id' => 'val1' - )); - $filtervalue1->addValidator('Date',false, array('format'=>'dd.MM.yyyy')); - - $filtervalue2 = $this->createElement('text', 'filtervalue2', array( - 'label' => $label2, - 'required' => true, - 'id' => 'val2' - )); - $filtervalue2->addValidator('Date',false, array('format'=>'dd.MM.yyyy')); - echo ''; - break; - } - $filtertypes->setDescription($desc); - $this->addElement($filtertypes); - - - - $this->addElement($filtervalue1); - if(isset($filtervalue2 )){ - $this->addElement($filtervalue2); - } - - $this->addElement('submit', 'add', array( - 'required' => false, - 'ignore' => true, - 'label' => $this->buttontext, - )); - - $this->addElement('button', 'Cancel', array( - 'onclick' => 'self.location="/user/filter/index/page/'.$this->page.'"' - )); - - $this->addElement('hidden', 'filterID', array( - 'value' => $this->filterID - )); - - - } -} - -?> - + + + + + + + + + +git.openslx.org - openslx-ng/pbs2.git/blob - application/modules/user/forms/FilterEntry.php + + + + + + + + + + +
+ +
+ +
+filter group fix +
+
[openslx-ng/pbs2.git] / application / modules / user / forms / FilterEntry.php
+
+
1 <?php
+
2 /*
+
3  * Copyright (c) 2011 - OpenSLX GmbH, RZ Uni Freiburg
+
4  * This program is free software distributed under the GPL version 2.
+
5  * See http://gpl.openslx.org/
+
6  *
+
7  * If you have any feedback please consult http://feedback.openslx.org/ and
+
8  * send your suggestions, praise, or complaints to feedback@openslx.org
+
9  *
+
10  * General information about OpenSLX can be found at http://openslx.org/
+
11  */
+
12
+
13 class user_Form_FilterEntry extends Zend_Form
+
14 {
+
15
+
16         private $filterID = 0;
+
17         private $data ;
+
18         private $buttontext = 'Save';
+
19         private $selectData;
+
20         private $page;   
+
21
+
22         public function setButtontext($v){
+
23                 $this->buttontext = $v;
+
24         }
+
25         public function setData($v){
+
26                 $this->data = $v;
+
27         }
+
28         public function setFilterID($v){
+
29                 $this->filterID = $v;
+
30         }
+
31         public function setSelectData($v){
+
32                 $this->selectData = $v;
+
33         }
+
34         public function setPage($page){
+
35                 $this->page = $page;
+
36         }
+
37
+
38     public function init()
+
39     {
+
40                 $this->setName("Add Filterentry");
+
41                 $this->setMethod('post');
+
42                 $this->setAttrib('id','filterentryform');
+
43                 #print_a($this->data);
+
44                 #print_a($this->selectData);
+
45                 try{            
+
46                         $filtertypemapper = new Application_Model_FilterTypeMapper();
+
47                 $filtertype = $filtertypemapper->fetchAll();
+
48                 
+
49                 $filtertypes = $this->createElement('select','filtertypeID');
+
50         $filtertypes ->setLabel('Type:');
+
51         $filtertypes ->setAttrib('id','filtertype');
+
52         $filtertypes->addMultiOption('','');
+
53                 foreach($filtertype as $f){
+
54                         $filtertypes->addMultiOption($f->getID(),$f->getFiltertypename());
+
55                 }
+
56                 $filterentry = $filtertypes->getMultiOption($this->data['filtertypeID']);
+
57                 $filterentryID = $this->data['filtertypeID'];
+
58                 }catch (Zend_Exception $e) {  
+
59                         echo "Error message 1: " . $e->getMessage() . "\n";
+
60                 }
+
61                 switch($filterentryID){
+
62                         default:
+
63                                 $desc = "Select the filtertype";
+
64                                 $label1 = 'Value 1:';
+
65                                 $label2 = 'Value 2:';
+
66                                 $filtervalue1 = $this->createElement('text', 'filtervalue', array(
+
67                                         'label' => $label1,
+
68                                         'id' => 'val1'
+
69                                 ));
+
70                                 $filtervalue2 = $this->createElement('text', 'filtervalue2', array(
+
71                                         'label' => $label2,
+
72                                         'id' => 'val2'
+
73                                 ));
+
74                                 break;
+
75                         case "1":
+
76                                 $desc = "You can set one IP or an IP-Range";
+
77                                 $label1 = 'Start:';
+
78                                 $label2 = 'End:';
+
79                                 
+
80                                 $filtervalue1 = $this->createElement('text', 'filtervalue', array(
+
81                                         'label' => $label1,
+
82                                         'validators' => array(
+
83                                                 array(
+
84                                                         'regex', 
+
85                                                         false, 
+
86                                                         array(
+
87                                                                 '/^(([0-9]|[1-9][0-9]|0[0-9]{2}|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([[0-9]|[1-9][0-9]|0[0-9]{2}|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/i',
+
88                                                                 'messages' => array(
+
89                                                                         Zend_Validate_Regex::NOT_MATCH => "'%value%' is not a valid IP-Adress",
+
90                                                                         Zend_Validate_Regex::INVALID  => 'IP-Adress contains invalid characters.'
+
91                                                                 )
+
92                                                         )
+
93                                                 )
+
94                                         ),
+
95                                         'required' => true,
+
96                                         'id' => 'val1'
+
97                                 ));
+
98                                 $filtervalue2 = $this->createElement('text', 'filtervalue2', array(
+
99                                         'label' => $label2,
+
100                                         'validators' => array(
+
101                                                 array(
+
102                                                         'regex', 
+
103                                                         false, 
+
104                                                         array(
+
105                                                                 '/^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/i',
+
106                                                                 'messages' => array(
+
107                                                                         Zend_Validate_Regex::NOT_MATCH => "'%value%' is not a valid IP-Adress",
+
108                                                                         Zend_Validate_Regex::INVALID  => 'IP-Adress contains invalid characters.'
+
109                                                                 )
+
110                                                         )
+
111                                                 )
+
112                                         ),
+
113                                         'required' => true,
+
114                                         'id' => 'val2'
+
115                                 ));
+
116                                 break;
+
117                         case "2":
+
118                                 $desc = "You can set one Mac-Adress or an Mac-Range";
+
119                                 $label1 = 'Start:';
+
120                                 $label2 = 'End:';
+
121                                 
+
122                                 $filtervalue1 = $this->createElement('text', 'filtervalue', array(
+
123                                         'label' => $label1,
+
124                                         'validators' => array(
+
125                                                 array(
+
126                                                         'regex', 
+
127                                                         false, 
+
128                                                         array(
+
129                                                                 '/^[0-9A-F]{2}:[0-9A-F]{2}:[0-9A-F]{2}:[0-9A-F]{2}:[0-9A-F]{2}:[0-9A-F]{2}$/i',
+
130                                                                 'messages' => array(
+
131                                                                         Zend_Validate_Regex::NOT_MATCH => "'%value%' is not a valid Mac-Adress",
+
132                                                                         Zend_Validate_Regex::INVALID  => 'Mac-Adress contains invalid characters.'
+
133                                                                 )
+
134                                                         )
+
135                                                 )
+
136                                         ),
+
137                                         'required' => true,
+
138                                         'id' => 'val1'
+
139                                 ));
+
140                                 $filtervalue2 = $this->createElement('text', 'filtervalue2', array(
+
141                                         'label' => $label2,
+
142                                         'validators' => array(
+
143                                                 array(
+
144                                                         'regex', 
+
145                                                         false, 
+
146                                                         array(
+
147                                                                 '/^[0-9A-F]{2}:[0-9A-F]{2}:[0-9A-F]{2}:[0-9A-F]{2}:[0-9A-F]{2}:[0-9A-F]{2}$/i',
+
148                                                                 'messages' => array(
+
149                                                                         Zend_Validate_Regex::NOT_MATCH => "'%value%' is not a valid Mac-Adress",
+
150                                                                         Zend_Validate_Regex::INVALID  => 'Mac-Adress contains invalid characters.'
+
151                                                                 )
+
152                                                         )
+
153                                                 )
+
154                                         ),
+
155                                         'required' => true,
+
156                                         'id' => 'val2'
+
157                                 ));
+
158                                 break;
+
159                         case "3":
+
160                                 $desc = "Select your Pool";
+
161                                 $label1 = 'PoolID:';                            
+
162                                 
+
163                                 $filtervalue1 = $this->createElement('select','filtervalue');
+
164                                 $filtervalue1 ->setLabel($label1);
+
165                                 if(count($this->selectData['pools'])>0){
+
166                                         foreach($this->selectData['pools'] as $id => $g){
+
167                                                 $filtervalue1->addMultiOption($g['poolID'], $g['title']);
+
168                                         }       
+
169                                 }
+
170                                 $filtervalue1->setRegisterInArrayValidator(false);
+
171                                 break;
+
172                         case "4":
+
173                                 $desc = "Select your BootIso";
+
174                                 $label1 = 'BootIsoID:';
+
175                                 
+
176                                 $filtervalue1 = $this->createElement('select','filtervalue');
+
177                                 $filtervalue1 ->setLabel($label1);
+
178                                 if(count($this->selectData['bootisos'])>0){
+
179                                         foreach($this->selectData['bootisos'] as $id => $g){
+
180                                                 $filtervalue1->addMultiOption($g['bootisoID'], $g['title']);
+
181                                         }       
+
182                                 }
+
183                                 $filtervalue1->setRegisterInArrayValidator(false);
+
184                         
+
185                                 break;
+
186                         case "5":
+
187                                 $desc = "Select a Membership";
+
188                                 $label1 = 'Membership:';
+
189                                 
+
190                                 $filtervalue1 = $this->createElement('select','filtervalue');
+
191                                 $filtervalue1 ->setLabel($label1);
+
192                                 if(count($this->selectData['memberships'])>0){
+
193                                         $personMapper = new Application_Model_PersonMapper();
+
194                                         foreach($this->selectData['memberships'] as $id => $g){
+
195                                                 // Display full name of Person
+
196                                                 $person = new Application_Model_Person();
+
197                                                 $personMapper->find($g['personID'],$person);
+
198                                                 $filtervalue1->addMultiOption($g['membershipID'], $person->getName().", ".$person->getFirstname());
+
199                                         }       
+
200                                 }
+
201                                 $filtervalue1->setRegisterInArrayValidator(false);
+
202                                 break;
+
203                         case "6":
+
204                                 $desc = "For all members in this Group";
+
205                                 $label1 = 'Group:';
+
206                                 // TODO: insert the child Groups
+
207                                 $filtervalue1 = $this->createElement('select','filtervalue');
+
208                                 $filtervalue1 ->setLabel($label1);
+
209                                 if(count($this->selectData['groups'])>0){
+
210                                         foreach($this->selectData['groups'] as $id => $g){
+
211                                                 $filtervalue1->addMultiOption($g['groupID'], $g['title']);
+
212                                         }       
+
213                                 }
+
214                                 $filtervalue1->setRegisterInArrayValidator(false);
+
215                                 break;
+
216                         case "7":
+
217                                 $desc = "Specify a time-range";
+
218                                 $label1 = 'Start:';
+
219                                 $label2 = 'End:';
+
220                                 
+
221                                 $filtervalue1 = $this->createElement('text', 'filtervalue', array(
+
222                                         'label' => $label1,
+
223                                         'validators' => array(
+
224                                                 array(
+
225                                                         'regex', 
+
226                                                         false, 
+
227                                                         array(
+
228                                                                 '/^([0-1][0-9]|[2][0-3]):([0-5][0-9])$/i',
+
229                                                                 'messages' => array(
+
230                                                                         Zend_Validate_Regex::NOT_MATCH => "'%value%' is not a valid Time-Format, It must be HH:MM",
+
231                                                                         Zend_Validate_Regex::INVALID  => 'Time contains invalid characters.'
+
232                                                                 )
+
233                                                         )
+
234                                                 )
+
235                                         ),
+
236                                         'required' => true,
+
237                                         'id' => 'val1'
+
238                                 ));
+
239                                 $filtervalue2 = $this->createElement('text', 'filtervalue2', array(
+
240                                         'label' => $label2,
+
241                                         'validators' => array(
+
242                                                 array(
+
243                                                         'regex', 
+
244                                                         false, 
+
245                                                         array(
+
246                                                                 '/^([0-1][0-9]|[2][0-3]):([0-5][0-9])$/i',
+
247                                                                 'messages' => array(
+
248                                                                         Zend_Validate_Regex::NOT_MATCH => "'%value%' is not a valid Time-Format, It must be HH:MM",
+
249                                                                         Zend_Validate_Regex::INVALID  => 'Time contains invalid characters.'
+
250                                                                 )
+
251                                                         )
+
252                                                 )
+
253                                         ),
+
254                                         'required' => true,
+
255                                         'id' => 'val2'
+
256                                 ));
+
257                                 echo '<script type="text/javascript"> 
+
258                                 $(function() {
+
259                                         $( "#val1" ).timepicker({
+
260                                                 showPeriod: false,
+
261                                                 showPeriodLabels: false
+
262                                         });
+
263                                         $( "#val2" ).timepicker({
+
264                                                 showPeriod: false,
+
265                                                 showPeriodLabels: false
+
266                                         });
+
267                                 });
+
268                                 </script>';
+
269                                 break;
+
270                         case "8":
+
271                                 $desc = "Select a Client";
+
272                                 $label1 = 'Client:';
+
273                                 
+
274                                 $filtervalue1 = $this->createElement('select','filtervalue');
+
275                                 $filtervalue1 ->setLabel($label1);
+
276                                 if(count($this->selectData['clients'])>0){
+
277                                         foreach($this->selectData['clients'] as $id => $g){
+
278                                                 $filtervalue1->addMultiOption($g['clientID'], $g['macadress']." - ".$g['hardwarehash']);
+
279                                         }       
+
280                                 }
+
281                                 $filtervalue1->setRegisterInArrayValidator(false);
+
282                                 break;
+
283                         case "9":
+
284                                 $desc = "Define a Hardwarehash";
+
285                                 $label1 = 'Hardwarehash:';
+
286                                 $filtervalue1 = $this->createElement('text', 'filtervalue', array(
+
287                                         'label' => $label1,
+
288                                         'filters' => array('StringTrim'),
+
289                                         'validators' => array(
+
290                                                 array('StringLength', false, array(32, 32)),
+
291                                         ),
+
292                                         'required' => true,
+
293                                         'id' => 'val1'
+
294                                 ));
+
295                                 break;
+
296                         case "10":
+
297                                 $desc = "Specify the Weekday (Monday:1, Tuesday:2 ... Sunday:7) or a range";
+
298                                 $label1 = 'Start Day:';
+
299                                 $label2 = 'End Day:';
+
300                                 
+
301                                 
+
302                                 
+
303                                 $filtervalue1 = $this->createElement('select','filtervalue', array(
+
304                                         'label' => $label1,
+
305                                         'validators' => array(
+
306                                                 array(
+
307                                                         'regex', 
+
308                                                         false, 
+
309                                                         array(
+
310                                                                 '/^([1-7])$/i',
+
311                                                                 'messages' => array(
+
312                                                                         Zend_Validate_Regex::NOT_MATCH => "'%value%' is not a valid Day-Format, It must be betweeen 1 and 7",
+
313                                                                         Zend_Validate_Regex::INVALID  => 'Day contains invalid characters.'
+
314                                                                 )
+
315                                                         )
+
316                                                 )
+
317                                         ),
+
318                                         'required' => true,
+
319                                         'id' => 'val1'
+
320                                 ));
+
321                                 $filtervalue1->addMultiOption(1, "Monday")
+
322                                                         ->addMultiOption(2, "Tuesday")
+
323                                                         ->addMultiOption(3, "Wednesday")
+
324                                                         ->addMultiOption(4, "Thursday")
+
325                                                         ->addMultiOption(5, "Friday")
+
326                                                         ->addMultiOption(6, "Saturday")
+
327                                                         ->addMultiOption(7, "Sunday");
+
328                                                                                         
+
329                                 
+
330                                 $filtervalue2 = $this->createElement('select', 'filtervalue2', array(
+
331                                         'label' => $label2,
+
332                                         'validators' => array(
+
333                                                 array(
+
334                                                         'regex', 
+
335                                                         false, 
+
336                                                         array(
+
337                                                                 '/^([1-7])$/i',
+
338                                                                 'messages' => array(
+
339                                                                         Zend_Validate_Regex::NOT_MATCH => "'%value%' is not a valid Day-Format, It must be betweeen 1 and 7",
+
340                                                                         Zend_Validate_Regex::INVALID  => 'Day contains invalid characters.'
+
341                                                                 )
+
342                                                         )
+
343                                                 )
+
344                                         ),
+
345                                         'required' => true,
+
346                                         'id' => 'val2'
+
347                                 ));
+
348                                 $filtervalue2->addMultiOption(1, "Monday")
+
349                                                         ->addMultiOption(2, "Tuesday")
+
350                                                         ->addMultiOption(3, "Wednesday")
+
351                                                         ->addMultiOption(4, "Thursday")
+
352                                                         ->addMultiOption(5, "Friday")
+
353                                                         ->addMultiOption(6, "Saturday")
+
354                                                         ->addMultiOption(7, "Sunday");
+
355                                 break;
+
356                         case "11":
+
357                                 $desc = "Specify the date or a day range of the filter";
+
358                                 $label1 = 'Start Date:';
+
359                                 $label2 = 'End Date:';
+
360                                 
+
361                                 $filtervalue1 = $this->createElement('text', 'filtervalue', array(
+
362                                         'label' => $label1,                                     
+
363                                         'required' => true,
+
364                                         'id' => 'val1'
+
365                                 ));                             
+
366                                 $filtervalue1->addValidator('Date',false, array('format'=>'dd.MM.yyyy'));
+
367                                 
+
368                                 $filtervalue2 = $this->createElement('text', 'filtervalue2', array(
+
369                                         'label' => $label2,                                     
+
370                                         'required' => true,                                     
+
371                                         'id' => 'val2'
+
372                                 ));                             
+
373                                 $filtervalue2->addValidator('Date',false, array('format'=>'dd.MM.yyyy'));                               
+
374                                 echo '<script type="text/javascript"> 
+
375                                 $(function() {
+
376                                         $( "#val1" ).datepicker({ dateFormat: "dd.mm.yy"});
+
377                                         $( "#val2" ).datepicker({ dateFormat: "dd.mm.yy"});
+
378                                 });
+
379                                 </script>';
+
380                                 break;
+
381                 }
+
382                 $filtertypes->setDescription($desc);
+
383                 $this->addElement($filtertypes);    
+
384                 
+
385                 
+
386                 
+
387                 $this->addElement($filtervalue1);  
+
388                 if(isset($filtervalue2 )){
+
389                         $this->addElement($filtervalue2);    
+
390                 }
+
391
+
392         $this->addElement('submit', 'add', array(
+
393             'required' => false,
+
394             'ignore'   => true,
+
395             'label'    => $this->buttontext,
+
396         ));      
+
397         
+
398         $this->addElement('button', 'Cancel', array(
+
399             'onclick' => 'self.location="/user/filter/index/page/'.$this->page.'"'
+
400         ));  
+
401         
+
402          $this->addElement('hidden', 'filterID', array(
+
403             'value' => $this->filterID
+
404         ));  
+
405                 
+
406         
+
407     }
+
408 }
+
409
+
410 ?>
+
411 <script type="text/javascript">
+
412         $('#filtertype').change(function(){
+
413                 //alert($("#filtertype option:selected").val());
+
414                 $('#filterentryform').submit();
+
415         });
+
416         $('#val1').focusout(function(){
+
417                 if($("#filtertype option:selected").val() == 1 && $('#val2').val() == ""){
+
418                         $('#val2').val($('#val1').val());
+
419                 }
+
420                 if($("#filtertype option:selected").val() == 2 && $('#val2').val() == ""){
+
421                         $('#val2').val($('#val1').val());
+
422                 }
+
423         });
+
424 </script>
+
+ + + \ No newline at end of file diff --git a/application/modules/user/views/scripts/filter/index.phtml b/application/modules/user/views/scripts/filter/index.phtml old mode 100755 new mode 100644 index bb11da7..2a4463f --- a/application/modules/user/views/scripts/filter/index.phtml +++ b/application/modules/user/views/scripts/filter/index.phtml @@ -1,133 +1,190 @@ -

Filters

-notification != ''){echo $this->notification;} ?> -
The default userfilters uses the priority 25
-searchform; ?> - -formButton('createconfig', 'Create Filter', array( - 'onclick' => 'self.location="/user/filter/addfilter/page/'.$this->page.'"', - 'class' => 'addbutton'))?> - -
-
Available searchfilter:
-
filterID
-
title
-
description
-
priority
-
bootmenuID
-
created
+ + + + + + + + + +git.openslx.org - openslx-ng/pbs2.git/blob - application/modules/user/views/scripts/filter/index.phtml + + + + + + + + + + - -
- filters)==0) - echo "There are no Filters to display." ?> - filters as $filter): ?> -
-
-
Priority
- escape($filter->priority) ?>
-
-
- - Edit Filter - - - Delete Filter - - - Add Filterentry - -
-
escape($filter->title) ?>
-
- escape($filter->bootmenuID) ?>
- Created: escape($filter->created) ?>
- escape($filter->Description) ?>
- findBy(array('filterID' => $filter->getID()),true,array('filtertypeID'=>'ASC')); - ?> -
- - find($filterentry['filtertypeID'],$erg); - //name zur ID finden - $title = "[".$filterentry['filtertypeID']."] "; - $title .= $erg->getFiltertypename(); - ?> -
-
-
- - Edit Filterentry - - - Delete Filterentry - -
-
:
- -
-
-
- -
-
-
-
- +
+ +
+ - -pagination; ?> - + + +
+
1 <h1>Filters</h1>
+
2 <?php if($this->notification != ''){echo $this->notification;} ?>
+
3 <div class='infobox'>The default userfilters uses the priority 25</div>
+
4 <?php echo $this->searchform; ?>
+
5 <?php if(Pbs_Acl::checkRight('fa')):?>
+
6 <?php echo $this->formButton('createconfig', 'Create Filter', array(
+
7                                                         'onclick' => 'self.location="/user/filter/addfilter/page/'.$this->page.'"',
+
8                                                         'class' => 'addbutton'))?>
+
9 <?php endif;?>
+
10 <div class='searchvars'>
+
11         <div class='head'>Available searchfilter:</div>
+
12         <div class='code'>filterID</div>
+
13         <div class='code'>title</div>
+
14         <div class='code'>description</div>     
+
15         <div class='code'>priority</div>        
+
16         <div class='code'>bootmenuID</div>      
+
17         <div class='code'>created</div> 
+
18 </div>
+ +
20 <div class='listelement'>
+
21         <?php if(count($this->filters)==0)
+
22                 echo "There are no Filters to display." ?>
+
23         <?php foreach ($this->filters as $filter): ?>
+
24         <div class='element'>
+
25                 <div class='number'>            
+
26                         <div class='smallnumber'>Priority</div>
+
27                         <acronym title='<?php echo $this->escape($filter->getID()) ?>'><?php echo $this->escape($filter->priority) ?></acronym></div>
+
28                 <div class='content'>
+
29                         <div class='actions'>
+
30                                 <?php if(Pbs_Acl::checkRight('fe') || Pbs_Acl::checkRight('fefp')):?>
+
31                                 <a href="<?php echo $this->url(
+
32                                         array(
+
33                                                 'module'        => 'user',
+
34                                                 'controller' => 'filter',
+
35                                                 'action'     => 'editfilter',
+
36                                                 'filterID'      => $filter->getID(),
+
37                                                 'page'          => $this->page
+
38                                         ),
+
39                                         'default',
+
40                                         true) ?>"><img src='/media/img/edit.png' alt='Edit Filter'/></a>
+
41                                 <?php endif; ?>
+
42                                 <?php if(Pbs_Acl::checkRight('fd')):?>
+
43                                 <a href="<?php echo $this->url(
+
44                                         array(
+
45                                                 'module'        => 'user',
+
46                                                 'controller' => 'filter',
+
47                                                 'action'     => 'removefilter',
+
48                                                 'filterID'      => $filter->getID(),
+
49                                                 'page'          => $this->page
+
50                                         ),
+
51                                         'default',
+
52                                         true) ?>"><img src='/media/img/delete.png' alt='Delete Filter'/></a>
+
53                                 <?php endif; ?>
+
54                                 <?php if(Pbs_Acl::checkRight('ffa')):?>
+
55                                 <a href="<?php echo $this->url(
+
56                                         array(
+
57                                                 'module'        => 'user',
+
58                                                 'controller' => 'filter',
+
59                                                 'action'     => 'addfilterentry',
+
60                                                 'filterID'      => $filter->getID(),
+
61                                                 'page'          => $this->page
+
62                                         ),
+
63                                         'default',
+
64                                         true) ?>"><img src='/media/img/add.png' alt='Add Filterentry'/></a>
+
65                                 <?php endif; ?>
+
66                         </div>  
+
67                         <div class='title'><?php echo $this->escape($filter->title) ?></div>
+
68                         <div class='subtitle'>
+
69                                 <?php echo $this->escape($filter->bootmenuID) ?><br />
+
70                                 Created: <?php echo $this->escape($filter->created) ?><br />
+
71                                 <?php echo $this->escape($filter->Description) ?></div>
+
72                         <?php
+
73                         $fe = new Application_Model_FilterEntriesMapper();
+
74                         $erg = $fe->findBy(array('filterID' => $filter->getID()),true,array('filtertypeID'=>'ASC'));
+
75                         ?>
+
76                         <div class='details dispnone'>
+
77                                 <?php foreach ($erg as $filterentry): ?>
+
78                                         <?php
+
79                                                 $filter2 = new Application_Model_FilterTypeMapper();
+
80                                                 $erg = new Application_Model_FilterType();
+
81                                         $filter2->find($filterentry['filtertypeID'],$erg);
+
82                                                 //name zur ID finden
+
83                                                 $title =  "[".$filterentry['filtertypeID']."] ";
+
84                                                 $title .= $erg->getFiltertypename();
+
85                                                 if($filterentry['filtertypeID'] == 11){
+
86                                                         $filterentry['filtervalue'] = date('d.m.Y',$filterentry['filtervalue']);
+
87                                                         $filterentry['filtervalue2'] = date('d.m.Y',$filterentry['filtervalue2']);
+
88                                                 }
+
89                                         ?>
+
90                                         <div class='element'>
+
91                                                 <div class='content'>                   
+
92                                                         <div class='actions'>
+
93                                                                 <?php if(Pbs_Acl::checkRight('ffe')): ?>
+
94                                                                 <a href="<?php echo $this->url(
+
95                                                                         array(
+
96                                                                                 'module'        => 'user',
+
97                                                                                 'controller' => 'filter',
+
98                                                                                 'action'     => 'editfilterentry',
+
99                                                                                 'filterentriesID'       => $filterentry['filterentriesID'],
+
100                                                                                 'page'          => $this->page
+
101                                                                         ),
+
102                                                                         'default',
+
103                                                                         true) ?>"><img src='/media/img/edit.png' alt='Edit Filterentry'/></a>
+
104                                                                 <?php endif; ?>
+
105                                                                 <?php if(Pbs_Acl::checkRight('ffd')): ?>
+
106                                                                 <a href="<?php echo $this->url(
+
107                                                                         array(
+
108                                                                                 'module'        => 'user',
+
109                                                                                 'controller' => 'filter',
+
110                                                                                 'action'     => 'removefilterentry',
+
111                                                                                 'filterentriesID'       => $filterentry['filterentriesID'],
+
112                                                                                 'page'          => $this->page
+
113                                                                         ),
+
114                                                                         'default',
+
115                                                                         true) ?>"><img src='/media/img/delete.png' alt='Delete Filterentry'/></a>
+
116                                                                 <?php endif; ?>
+
117                                                         </div>                                                          
+
118                                                         <div class='subtitle'><?php echo $title; ?> : <?php 
+
119                                                                 echo $filterentry['filtervalue'];
+
120                                                                 if($filterentry['filtervalue2'] != ''){
+
121                                                                         echo " - ".$filterentry['filtervalue2'];
+
122                                                                 }
+
123                                                                 ?></div>
+
124                                                         
+
125                                                 </div>
+
126                                                 <div class='clear'></div>
+
127                                         </div>
+
128                                 <?php endforeach ?> 
+
129                         </div>
+
130                 </div>
+
131                 <div class='clear'></div>
+
132         </div>
+
133         <?php endforeach ?> 
+
134 </div>
+ +
136 <?php echo $this->pagination; ?>        
+ +
+ + + \ No newline at end of file -- cgit v1.2.3-55-g7522