summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormichael pereira2011-04-04 17:14:53 +0200
committermichael pereira2011-04-04 17:14:53 +0200
commitb1a3923f98348f5145713315180b8e80e6ee89c0 (patch)
treebff2b1b25fc41d1581d78c9b858897419780c7a0
parentWICHTIG findBy Methode geändert & alles angepasst, siehe Ticket (diff)
parentclient-suche verändert (diff)
downloadpbs2-b1a3923f98348f5145713315180b8e80e6ee89c0.tar.gz
pbs2-b1a3923f98348f5145713315180b8e80e6ee89c0.tar.xz
pbs2-b1a3923f98348f5145713315180b8e80e6ee89c0.zip
merges
-rw-r--r--application/controllers/ResourceController.php2
-rw-r--r--application/modules/fbgui/controllers/IndexController.php7
-rw-r--r--application/modules/fbgui/views/scripts/index/start.phtml13
-rw-r--r--application/modules/user/controllers/BootisoController.php26
-rw-r--r--application/modules/user/controllers/BootmenuController.php27
-rw-r--r--application/modules/user/controllers/BootosController.php23
-rw-r--r--application/modules/user/controllers/ClientController.php35
-rw-r--r--application/modules/user/controllers/ConfigController.php23
-rw-r--r--application/modules/user/controllers/FilterController.php30
-rw-r--r--application/modules/user/controllers/PoolController.php25
-rw-r--r--application/modules/user/controllers/PrebootController.php22
-rw-r--r--application/modules/user/forms/Filter.php14
-rw-r--r--application/modules/user/views/scripts/client/index.phtml1
-rw-r--r--dbContent.php214
-rw-r--r--library/Pbs/Pagination.php50
-rw-r--r--library/Pbs/Search.php90
-rw-r--r--public/media/css/style.css10
-rw-r--r--public/media/img/search.pngbin0 -> 367 bytes
-rw-r--r--public/media/js/jquery.highlight-3.js53
19 files changed, 544 insertions, 121 deletions
diff --git a/application/controllers/ResourceController.php b/application/controllers/ResourceController.php
index 3b4a8cb..f72a5ae 100644
--- a/application/controllers/ResourceController.php
+++ b/application/controllers/ResourceController.php
@@ -149,7 +149,7 @@ class ResourceController extends Zend_Controller_Action
if($bme->getKcl() != null)
$result = $bme->getKcl() . " alpha=" . $this->_request->getParam('alpha') . " " . $bme->getKclappend();
else
- $result = $bme->getKclappend();
+ $result = "alpha=" . $this->_request->getParam('alpha') . " " .$bme->getKclappend();
echo $result;
diff --git a/application/modules/fbgui/controllers/IndexController.php b/application/modules/fbgui/controllers/IndexController.php
index b48806b..8c840ea 100644
--- a/application/modules/fbgui/controllers/IndexController.php
+++ b/application/modules/fbgui/controllers/IndexController.php
@@ -99,9 +99,9 @@ class Fbgui_IndexController extends Zend_Controller_Action
echo "<h1>Downloading</h1>";
echo "<script>\n";
echo "fbgui.setCallbackOnFinished('foo();');\n";
- echo "fbgui.startDownload('http://132.230.4.27/dev/resource/getkernel/alpha/".$_SESSION['alphasessionID']."/file/kernel');\n";
- echo "fbgui.startDownload('http://132.230.4.27/dev/resource/getinitramfs/alpha/".$_SESSION['alphasessionID']."/file/initramfs');\n";
- echo "fbgui.startDownload('http://132.230.4.27/dev/resource/getkcl/alpha/".$_SESSION['alphasessionID']."/file/kcl');\n";
+ echo "fbgui.startDownload('http://132.230.4.27/resource/getkernel/alpha/".$_SESSION['alphasessionID']."/file/kernel');\n";
+ echo "fbgui.startDownload('http://132.230.4.27/resource/getinitramfs/alpha/".$_SESSION['alphasessionID']."/file/initramfs');\n";
+ echo "fbgui.startDownload('http://132.230.4.27/resource/getkcl/alpha/".$_SESSION['alphasessionID']."/file/kcl');\n";
echo "function foo(){
fbgui.quit();
}";
@@ -110,4 +110,3 @@ class Fbgui_IndexController extends Zend_Controller_Action
}
}
-
diff --git a/application/modules/fbgui/views/scripts/index/start.phtml b/application/modules/fbgui/views/scripts/index/start.phtml
index c341e02..a59dd3e 100644
--- a/application/modules/fbgui/views/scripts/index/start.phtml
+++ b/application/modules/fbgui/views/scripts/index/start.phtml
@@ -85,6 +85,17 @@
window.setTimeout(rotate, 100);
}
window.setTimeout(rotate, 100);
+
+
+function updateProgress(p, s, u){
+ if (p >= 0 && p <= 100)
+ $("#progressbar").progressbar({ value: p });
+ else
+ $("#progressbar").progressbar({ value: 0 });
+}
+ $(document).ready(function() {
+ $("#progressbar").progressbar({ value: 0 });
+ });
</script>
@@ -99,3 +110,5 @@
<div class="bar8"></div>
</div>
<a href='/fbgui'>back</a>
+
+<div id="progressbar" style="height: 15px;"></div>
diff --git a/application/modules/user/controllers/BootisoController.php b/application/modules/user/controllers/BootisoController.php
index 63a5e38..a6fbe9e 100644
--- a/application/modules/user/controllers/BootisoController.php
+++ b/application/modules/user/controllers/BootisoController.php
@@ -79,21 +79,19 @@ class user_BootisoController extends Zend_Controller_Action
$this->view->bootisolist = array_reverse($this->view->bootisolist);
- // Pagination
- $perpage = 2;
- $req_page = $this->_request->getParam('page');
- $all = count($this->view->bootisolist);
- $numpages = ceil($all/$perpage);
- if($req_page < 0 || !is_numeric($req_page) )
- $req_page = 0;
- if($req_page >= $numpages)
- $req_page = $numpages-1;
- $startitem = $req_page * $perpage;
+
+ // Pagination
+ $pagination = new Pbs_Pagination();
+ $pagination->setPerPage(2);
+ $pagination->setElement($this->view->bootisolist);
+ $pagination->setRequestPage($this->_request->getParam('page'));
+ $pagination->setPageUrl('/user/bootiso/index'.((isset($this->view->search))?'/search/'.$this->view->search:''));
+ $this->view->bootisolist = $pagination->getElements();
- $pagination = new Pbs_Pagination();
- $this->view->pagination = $pagination->pagination('/user/bootiso/index',$req_page,$numpages);
- $this->view->page = $req_page;
- $this->view->bootisolist = array_slice($this->view->bootisolist,$startitem,$perpage);
+ $this->view->pagination = $pagination->pagination($pageurl);
+ $this->view->page = $pagination->getRequestPage();
+ $this->view->bootisolist= $this->view->bootisolist;
+
$prebootMapper = new Application_Model_PreBootMapper();
diff --git a/application/modules/user/controllers/BootmenuController.php b/application/modules/user/controllers/BootmenuController.php
index 2356515..7843b3f 100644
--- a/application/modules/user/controllers/BootmenuController.php
+++ b/application/modules/user/controllers/BootmenuController.php
@@ -89,23 +89,18 @@ class user_BootmenuController extends Zend_Controller_Action
}
// Pagination
- $perpage = 2;
- $req_page = $this->_request->getParam('page');
- $all = count($bootmenu);
- $numpages = ceil($all/$perpage);
- if($req_page < 0 || !is_numeric($req_page) )
- $req_page = 0;
- if($req_page >= $numpages)
- $req_page = $numpages-1;
- $startitem = $req_page * $perpage;
+ $pagination = new Pbs_Pagination();
+ $pagination->setPerPage(2);
+ $pagination->setElement($bootmenu);
+ $pagination->setRequestPage($this->_request->getParam('page'));
+ $pagination->setPageUrl('/user/bootmenu/index'.((isset($this->view->search))?'/search/'.$this->view->search:''));
+ $bootmenu = $pagination->getElements();
- $pagination = new Pbs_Pagination();
- $this->view->pagination = $pagination->pagination('/user/bootmenu/index',$req_page,$numpages);
- $this->view->page = $req_page;
- $this->view->bootmenulist = array_slice($bootmenu,$startitem,$perpage);
-
-
- $this->view->bootmenuentrylist = $bootmenuentries;
+ $this->view->pagination = $pagination->pagination($pageurl);
+ $this->view->page = $pagination->getRequestPage();
+ $this->view->bootmenulist = $bootmenu;
+
+ $this->view->bootmenuentrylist = $bootmenuentries;
}
diff --git a/application/modules/user/controllers/BootosController.php b/application/modules/user/controllers/BootosController.php
index 69f3140..8f602fe 100644
--- a/application/modules/user/controllers/BootosController.php
+++ b/application/modules/user/controllers/BootosController.php
@@ -66,22 +66,17 @@ class user_BootosController extends Zend_Controller_Action
$this->view->bootoslist = $this->bootosMapper->findBy(array("groupID" => $groupID));
$this->view->update = array();
-
// Pagination
- $perpage = 5;
- $req_page = $this->_request->getParam('page');
- $all = count($this->view->bootoslist);
- $numpages = ceil($all/$perpage);
- if($req_page < 0 || !is_numeric($req_page) )
- $req_page = 0;
- if($req_page >= $numpages)
- $req_page = $numpages-1;
- $startitem = $req_page * $perpage;
+ $pagination = new Pbs_Pagination();
+ $pagination->setPerPage(5);
+ $pagination->setElement($this->view->bootoslist);
+ $pagination->setRequestPage($this->_request->getParam('page'));
+ $pagination->setPageUrl('/user/bootos/index'.((isset($this->view->search))?'/search/'.$this->view->search:''));
+ $this->view->bootoslist = $pagination->getElements();
- $pagination = new Pbs_Pagination();
- $this->view->pagination = $pagination->pagination('/user/bootos/index',$req_page,$numpages);
- $this->view->page = $req_page;
- $this->view->bootoslist = array_slice($this->view->bootoslist,$startitem,$perpage);
+ $this->view->pagination = $pagination->pagination($pageurl);
+ $this->view->page = $pagination->getRequestPage();
+ $this->view->bootoslist = $this->view->bootoslist;
$update = $this->_request->getParam('checkupdate');
diff --git a/application/modules/user/controllers/ClientController.php b/application/modules/user/controllers/ClientController.php
index e26075b..87e764d 100644
--- a/application/modules/user/controllers/ClientController.php
+++ b/application/modules/user/controllers/ClientController.php
@@ -49,23 +49,32 @@ class User_ClientController extends Zend_Controller_Action
$clientMapper = new Application_Model_ClientMapper();
$clientsInGroup = $clientMapper->findBy(array('groupID' => $this->membership->getGroupID()),true);
+ // Search
+ $search = $this->_request->getParam('search');
+ $mySearch = new Pbs_Search();
+ $mySearch->setSearchTerm($search);
+ $this->view->searchform = $mySearch->searchForm();
+ if($search != ''){
+ $this->view->search = $search;
+ $clientsInGroup = $mySearch->search($clientsInGroup);
+ }
- $perpage = 10;
- $req_page = $this->_request->getParam('page');
- $all = count($clientsInGroup);
- $numpages = ceil($all/$perpage);
- if($req_page < 0 || !is_numeric($req_page) )
- $req_page = 0;
- if($req_page >= $numpages)
- $req_page = $numpages-1;
- $startitem = $req_page * $perpage;
-
+ // Pagination
$pagination = new Pbs_Pagination();
- $this->view->pagination = $pagination->pagination('/user/client/index',$req_page,$numpages);
- $this->view->page = $req_page;
- $this->view->clients = array_slice($clientsInGroup,$startitem,$perpage);
+ $pagination->setPerPage(10);
+ $pagination->setElement($clientsInGroup);
+ $pagination->setRequestPage($this->_request->getParam('page'));
+ $pagination->setPageUrl('/user/client/index'.((isset($this->view->search))?'/search/'.$this->view->search:''));
+ $clientsInGroup = $pagination->getElements();
+
+ $this->view->pagination = $pagination->pagination($pageurl);
+ $this->view->page = $pagination->getRequestPage();
+ $this->view->clients = $clientsInGroup;
}
+ public function searchAction(){
+ $this->_redirect('/user/client/index/search/'.$_GET['search']);
+ }
public function addclientAction()
{
diff --git a/application/modules/user/controllers/ConfigController.php b/application/modules/user/controllers/ConfigController.php
index f00d1bc..83ff804 100644
--- a/application/modules/user/controllers/ConfigController.php
+++ b/application/modules/user/controllers/ConfigController.php
@@ -66,22 +66,17 @@ class user_ConfigController extends Zend_Controller_Action
$config->setGroupID("[".$config->getGroupID()."] ".$groupMapper->find($config->getGroupID())->getTitle());
}
-
// Pagination
- $perpage = 5;
- $req_page = $this->_request->getParam('page');
- $all = count($this->view->configlist);
- $numpages = ceil($all/$perpage);
- if($req_page < 0 || !is_numeric($req_page) )
- $req_page = 0;
- if($req_page >= $numpages)
- $req_page = $numpages-1;
- $startitem = $req_page * $perpage;
+ $pagination = new Pbs_Pagination();
+ $pagination->setPerPage(2);
+ $pagination->setElement($this->view->configlist);
+ $pagination->setRequestPage($this->_request->getParam('page'));
+ $pagination->setPageUrl('/user/config/index'.((isset($this->view->search))?'/search/'.$this->view->search:''));
+ $this->view->configlist = $pagination->getElements();
- $pagination = new Pbs_Pagination();
- $this->view->pagination = $pagination->pagination('/user/config/index',$req_page,$numpages);
- $this->view->page = $req_page;
- $this->view->configlist = array_slice($this->view->configlist,$startitem,$perpage);
+ $this->view->pagination = $pagination->pagination($pageurl);
+ $this->view->page = $pagination->getRequestPage();
+ $this->view->configlist = $this->view->configlist;
}
diff --git a/application/modules/user/controllers/FilterController.php b/application/modules/user/controllers/FilterController.php
index 83ccdc4..d4ddeae 100644
--- a/application/modules/user/controllers/FilterController.php
+++ b/application/modules/user/controllers/FilterController.php
@@ -55,21 +55,19 @@ class User_FilterController extends Zend_Controller_Action
$ff->setID($filter['filterID']);
$allFilter[] = $ff;
}
- $perpage = 2;
- $req_page = $this->_request->getParam('page');
- $all = count($allFilter);
- $numpages = ceil($all/$perpage);
- if($req_page < 0 || !is_numeric($req_page) )
- $req_page = 0;
- if($req_page >= $numpages)
- $req_page = $numpages-1;
- $startitem = $req_page * $perpage;
- $pagination = new Pbs_Pagination();
- $this->view->pagination = $pagination->pagination('/user/filter/index',$req_page,$numpages);
- $this->view->page = $req_page;
-
- $this->view->filters = array_slice($allFilter,$startitem,$perpage);
+ // Pagination
+ $pagination = new Pbs_Pagination();
+ $pagination->setPerPage(2);
+ $pagination->setElement($allFilter);
+ $pagination->setRequestPage($this->_request->getParam('page'));
+ $pagination->setPageUrl('/user/filter/index'.((isset($this->view->search))?'/search/'.$this->view->search:''));
+ $allFilter = $pagination->getElements();
+
+ $this->view->pagination = $pagination->pagination($pageurl);
+ $this->view->page = $pagination->getRequestPage();
+ $this->view->filters = $allFilter;
+
}
public function addfilterAction()
@@ -79,8 +77,10 @@ class User_FilterController extends Zend_Controller_Action
$this->_redirect('/user');
$bmmapper = new Application_Model_BootMenuMapper();
+
$result = $bmmapper->findBy(array('groupID' => $this->membership->getGroupID()),true);
print_a($result);
+
foreach($result as $rr){
$bm = new Application_Model_BootMenu();
@@ -301,7 +301,7 @@ class User_FilterController extends Zend_Controller_Action
'data' => $_POST,
'page' => $this->page));
if ($addform->isValid($_POST)) {
- print_a('valid');
+ # print_a('valid');
$newfilterenty = new Application_Model_FilterEntries();
$newfilterenty->setFilterID($filterID);
$newfilterenty->setFiltertypeID($_POST['filtertypeID']);
diff --git a/application/modules/user/controllers/PoolController.php b/application/modules/user/controllers/PoolController.php
index 7bf3446..e5fea8c 100644
--- a/application/modules/user/controllers/PoolController.php
+++ b/application/modules/user/controllers/PoolController.php
@@ -64,20 +64,19 @@ class User_PoolController extends Zend_Controller_Action
$ff->setID($pool['poolID']);
$yourpools[] = $ff;
}
- $perpage = 4;
- $req_page = $this->_request->getParam('page');
- $all = count($yourpools);
- $numpages = ceil($all/$perpage);
- if($req_page < 0 || !is_numeric($req_page) )
- $req_page = 0;
- if($req_page >= $numpages)
- $req_page = $numpages-1;
- $startitem = $req_page * $perpage;
- $pagination = new Pbs_Pagination();
- $this->view->pagination = $pagination->pagination('/user/pool/index',$req_page,$numpages);
- $this->view->page = $req_page;
- $this->view->pools = array_slice($yourpools,$startitem,$perpage);
+ // Pagination
+ $pagination = new Pbs_Pagination();
+ $pagination->setPerPage(4);
+ $pagination->setElement($yourpools);
+ $pagination->setRequestPage($this->_request->getParam('page'));
+ $pagination->setPageUrl('/user/pool/index'.((isset($this->view->search))?'/search/'.$this->view->search:''));
+ $yourpools = $pagination->getElements();
+
+ $this->view->pagination = $pagination->pagination($pageurl);
+ $this->view->page = $pagination->getRequestPage();
+ $this->view->pools = $yourpools;
+
// Get all Clients from this group
$clientmapper = new Application_Model_ClientMapper();
diff --git a/application/modules/user/controllers/PrebootController.php b/application/modules/user/controllers/PrebootController.php
index 73e838d..6944e27 100644
--- a/application/modules/user/controllers/PrebootController.php
+++ b/application/modules/user/controllers/PrebootController.php
@@ -65,20 +65,16 @@ class User_PrebootController extends Zend_Controller_Action
$this->view->prebootlist = $this->prebootMapper->findBy(array("groupID" => $groupID));
// Pagination
- $perpage = 2;
- $req_page = $this->_request->getParam('page');
- $all = count($this->view->prebootlist);
- $numpages = ceil($all/$perpage);
- if($req_page < 0 || !is_numeric($req_page) )
- $req_page = 0;
- if($req_page >= $numpages)
- $req_page = $numpages-1;
- $startitem = $req_page * $perpage;
+ $pagination = new Pbs_Pagination();
+ $pagination->setPerPage(2);
+ $pagination->setElement($this->view->prebootlist);
+ $pagination->setRequestPage($this->_request->getParam('page'));
+ $pagination->setPageUrl('/user/preboot/index'.((isset($this->view->search))?'/search/'.$this->view->search:''));
+ $this->view->prebootlist = $pagination->getElements();
- $pagination = new Pbs_Pagination();
- $this->view->pagination = $pagination->pagination('/user/preboot/index',$req_page,$numpages);
- $this->view->page = $req_page;
- $this->view->prebootlist = array_slice($this->view->prebootlist,$startitem,$perpage);
+ $this->view->pagination = $pagination->pagination($pageurl);
+ $this->view->page = $pagination->getRequestPage();
+ $this->view->prebootlist= $this->view->prebootlist;
diff --git a/application/modules/user/forms/Filter.php b/application/modules/user/forms/Filter.php
index a7a2555..0676ba8 100644
--- a/application/modules/user/forms/Filter.php
+++ b/application/modules/user/forms/Filter.php
@@ -9,23 +9,33 @@ class user_Form_Filter extends Zend_Form
{
$this->setName("Add Filter");
$this->setMethod('post');
-
+
+ if(Pbs_Acl::checkRight('fefp')){
+ $edit = 'true';
+ }
+ else{
+ $edit = null;
+ }
+
$this->addElement('text', 'title', array(
'filters' => array('StringTrim'),
'validators' => array(
array('StringLength', false, array(0, 50)),
),
'required' => true,
+ 'readOnly' => $edit,
'label' => 'Title:',
));
$this->addElement('textarea', 'description', array(
'filters' => array('StringTrim'),
'required' => false,
+ 'readOnly' => $edit,
'label' => 'Description:',
));
$bootmenufield = $this->createElement('select','bootmenuID');
- $bootmenufield ->setLabel('Bootmenu:');
+ $bootmenufield->setLabel('Bootmenu:');
+ $bootmenufield->setAttrib('readOnly', $edit);
if(count($this->bootmenus)>0){
foreach($this->bootmenus as $g){
diff --git a/application/modules/user/views/scripts/client/index.phtml b/application/modules/user/views/scripts/client/index.phtml
index 62c698c..5a75741 100644
--- a/application/modules/user/views/scripts/client/index.phtml
+++ b/application/modules/user/views/scripts/client/index.phtml
@@ -1,5 +1,6 @@
<h1>Clients</h1>
<?php if($this->notification != ''){echo $this->notification;} ?>
+<?php echo $this->searchform; ?>
<?php echo $this->formButton('createbootos', 'Create Client', array(
'onclick' => 'self.location="/user/client/addclient/page/'.$this->page.'"',
'class' => 'addbutton'))?>
diff --git a/dbContent.php b/dbContent.php
new file mode 100644
index 0000000..ef258c6
--- /dev/null
+++ b/dbContent.php
@@ -0,0 +1,214 @@
+<?php
+// generate mysql graph
+$name = substr(str_replace("/","",$_SERVER['SCRIPT_NAME']),0,-4);
+$dotname = $name . '.dot';
+$pngname = $name . '.png';
+
+echo "Opening Database Connection...\n";
+$link = mysql_connect('localhost', 'root', '123456');
+if (!$link) {
+ die('keine Verbindung möglich: ' . mysql_error());
+}
+mysql_select_db('pbs');
+error_reporting(1);
+
+
+$format['groupnode'] = '"%s" [shape=trapezium, fontcolor="#ffffffff", style=filled, fillcolor="#004A99FF"];'."\n";
+$format['personnode'] = '"%s" [shape=ellipse, fontcolor="#ffffffff", style=filled, fillcolor="#FF0000FF"];'."\n";
+$format['poolnode'] = '"%s" [shape=ellipse, fontcolor="#000000ff", style=filled, fillcolor="#00FF00FF"];'."\n";
+$format['membershipnode'] = '"%s" [shape=ellipse, fontcolor="#ffffffff", style=filled, fillcolor="#990000FF"];'."\n";
+$format['clientnode'] = '"%s" [shape=ellipse, fontcolor="#000000ff", style=filled, fillcolor="#FFFF00FF"];'."\n";
+$format['rolenode'] = '"%s" [fontcolor="#000000ff", style=filled, fillcolor="#FF0099FF"];'."\n";
+$format['bootmenunode'] = '"%s" [shape=ellipse, fontcolor="#000000ff", style=filled, fillcolor="#009999FF"];'."\n";
+$format['bootisonode'] = '"%s" [shape=ellipse, fontcolor="#000000ff", style=filled, fillcolor="#FF9900FF"];'."\n";
+$format['bootosnode'] = '"%s" [fontcolor="#000000ff", style=filled, fillcolor="#99FF99FF"];'."\n";
+
+$format['groupgroup'] = '"%s" -> "%s";'."\n";
+$format['personmember'] = '"%s" -> "%s";'."\n";
+$format['rolemember'] = '"%s" -> "%s";'."\n";
+$format['membergroup'] = '"%s" -> "%s";'."\n";
+$format['personrequest'] = '"%s" -> "%s" [style=dotted];'."\n";
+$format['poolgroup'] = '"%s" -> "%s";'."\n";
+$format['clientgroup'] = '"%s" -> "%s";'."\n";
+$format['clientpool'] = '"%s" -> "%s";'."\n";
+$format['bootisogroup'] = '"%s" -> "%s";'."\n";
+$format['bootmenugroup'] = '"%s" -> "%s";'."\n";
+$format['bootosbootmenu'] = '"%s" -> "%s";'."\n";
+$format['bootosgroup'] = '"%s" -> "%s";'."\n";
+
+
+
+
+function getGroups(){
+ global $format;
+ $q = "SELECT groupID,title FROM pbs_group";
+ $groups = "subgraph cluster_0 {";
+ $groups .= "label=Groups;";
+ $result = mysql_query($q);
+ while($data = mysql_fetch_array($result)){
+ $groups .= sprintf($format['groupnode'] ,"Group".$data['groupID']);
+ }
+ $groups .= "}";
+ return $groups;
+}
+function recGroups($groupID,$level=0,$data=''){
+ global $format;
+ $q = "SELECT groupID FROM pbs_groupgroups WHERE parentID = $groupID";
+ $result = mysql_query($q);
+ while($data = mysql_fetch_array($result)){
+ $groups .= sprintf($format['groupgroup'],"Group".$groupID, "Group".$data['groupID']);
+ $groups .= recGroups($data['groupID']);
+ }
+ return $groups;
+}
+function getPersons(){
+ global $format;
+ $q = "SELECT personID,title FROM pbs_person";
+ $result = mysql_query($q);
+ while($data = mysql_fetch_array($result)){
+ $persons .= sprintf($format['personnode'] ,"Person". $data['personID']);
+
+ }
+ return $persons;
+}
+function getMemberships(){
+ global $format;
+ $q = "SELECT personID,groupID,membershipID,roleID FROM pbs_membership";
+ $result = mysql_query($q);
+ while($data = mysql_fetch_array($result)){
+ $memberships .= sprintf($format['membershipnode'],"Member".$data['membershipID']);
+ $memberships .= sprintf($format['personmember'],"Person".$data['personID'],"Member".$data['membershipID']);
+ $memberships .= sprintf($format['rolemember'],"Role".$data['roleID'], "Member".$data['membershipID']);
+ $memberships .= sprintf($format['membergroup'],"Member".$data['membershipID'], "Group".$data['groupID']);
+ }
+ return $memberships;
+}
+function getRequests(){
+ global $format;
+ $q = "SELECT personID,groupID FROM pbs_grouprequest";
+ $result = mysql_query($q);
+ while($data = mysql_fetch_array($result)){
+ $memberships .= sprintf($format['peronrequests'],"Group".$data['groupID'], "Person".$data['personID']);
+ }
+ return $memberships;
+}
+function getPools(){
+ global $format;
+ $q = "SELECT poolID,groupID FROM pbs_pool";
+ $result = mysql_query($q);
+ while($data = mysql_fetch_array($result)){
+ $pools .= sprintf($format['poolnode'] ,"Pool".$data['poolID']);
+ $pools .= sprintf($format['poolgroup'],"Pool".$data['poolID'], "Group".$data['groupID']);
+
+ }
+ return $pools;
+}
+function getClients(){
+ global $format;
+ $q = "SELECT clientID,groupID FROM pbs_client";
+ $result = mysql_query($q);
+ while($data = mysql_fetch_array($result)){
+ $clients .= sprintf($format['clientnode'] ,"Client".$data['clientID']);
+ $query2 = "SELECT clientID, poolID FROM pbs_poolentries WHERE clientID = '".$data['clientID']."'";
+ $result2 = mysql_query($query2);
+ if(mysql_num_rows($result2) == 0)
+ $clients .= sprintf($format['clientgroup'],"Client".$data['clientID'], "Group".$data['groupID']);
+ }
+
+ return $clients;
+}
+function clientPools(){
+ global $format;
+ $q = "SELECT clientID,poolID FROM pbs_poolentries";
+ $result = mysql_query($q);
+ while($data = mysql_fetch_array($result)){
+ $clientpools .= sprintf($format['clientpool'],"Client".$data['clientID'], "Pool".$data['poolID']);
+ }
+ return $clientpools;
+}
+function getRoles(){
+ global $format;
+ $q = "SELECT roleID,groupID FROM pbs_role";
+ $result = mysql_query($q);
+ while($data = mysql_fetch_array($result)){
+ $roles .= sprintf($format['rolenode'] ,"Role".$data['roleID']);
+ # $roles .= "Role".$data['roleID'] ." -> " . "Group".$data['groupID'].";\n";
+ }
+ return $roles;
+}
+function getBootiso(){
+ global $format;
+ $q = "SELECT bootisoID,groupID FROM pbs_bootiso";
+ $result = mysql_query($q);
+ while($data = mysql_fetch_array($result)){
+ $bootiso .= sprintf($format['bootisonode'] ,"BootIso".$data['bootisoID']);
+ $bootiso .= sprintf($format['bootisogroup'],"BootIso".$data['bootisoID'], "Group".$data['groupID']);
+
+ }
+ return $bootiso;
+}
+function getBootMenus(){
+ global $format;
+ $q = "SELECT bootmenuID,groupID FROM pbs_bootmenu";
+ $result = mysql_query($q);
+ while($data = mysql_fetch_array($result)){
+ $bootmenu .= sprintf($format['bootmenunode'] ,"BootMenu".$data['bootmenuID']);
+ $bootmenu .= sprintf($format['bootmenugroup'],"BootMenu".$data['bootmenuID'], "Group".$data['groupID']);
+ }
+ return $bootmenu;
+}
+function getBootos(){
+ global $format;
+ $q = "SELECT bootosID,groupID FROM pbs_bootos";
+ $result = mysql_query($q);
+ while($data = mysql_fetch_array($result)){
+ $bootos .= sprintf($format['bootosnode'] ,"BootOs".$data['bootosID']);
+
+ $q2 = "SELECT * FROM pbs_bootmenuentries WHERE bootosID = ".$data['bootosID']."";
+ $result2 = mysql_query($q2);
+ if(mysql_num_rows($result2)){
+ while($data2 = mysql_fetch_array($result2))
+ $bootos .= sprintf($format['bootosbootmenu'],"BootOs".$data['bootosID'], "BootMenu".$data2['bootmenuID']);
+ }
+ else
+ $bootos .= sprintf($format['bootosgroup'],"BootOs".$data['bootosID'], "Group".$data['groupID']);
+ }
+ return $bootos;
+}
+
+## Concatenation
+$defs = '';
+$defs .= getGroups();
+$defs .= recGroups(1);
+$defs .= getPersons();
+$defs .= getMemberships();
+$defs .= getRoles();
+$defs .= getRequests();
+$defs .= getPools();
+$defs .= getClients();
+$defs .= clientPools();
+$defs .= getBootiso();
+$defs .= getBootMenus();
+$defs .= getBootos();
+
+
+
+$str = 'digraph x {
+ node [];
+ ranksep=3;
+ size="20,20";
+ overlap="0:true"'."\n";
+$str .= str_replace("\n","\n\t",$defs);
+$str .= "}";
+
+echo "Write to file ...\n";
+// Create the dot file
+$fp = fopen($dotname, "w");
+fputs ($fp, $str);
+fclose ($fp);
+// Generate the image
+echo "Generate the image ...\n";
+exec("dot -Tpng $dotname >$pngname");
+// delete the dot file
+unlink ($dotname);
+echo "Ready!\n";
diff --git a/library/Pbs/Pagination.php b/library/Pbs/Pagination.php
index 179f2f7..c31dacf 100644
--- a/library/Pbs/Pagination.php
+++ b/library/Pbs/Pagination.php
@@ -1,8 +1,24 @@
<?php
-class Pbs_Pagination{
- public function pagination($url,$selected,$max){
+class Pbs_Pagination{
+
+ private $element;
+ private $perpage;
+ private $requestpage;
+ private $maxNumber;
+ private $numpages;
+ private $pageUrl;
+
+ public function pagination($url=null,$selected=null,$max=null){
+ if($selected == null)
+ $selected = $this->requestpage;
+ if($max == null)
+ $max = $this->numpages;
+ if($url == null)
+ $url = $this->pageUrl;
+
#print_a($url,$selected,$max);
+
$str = "<div class='pbs_pagination'>";
if ( 1 <= $selected){
$str .= "<a href='$url/page/0' >&lt;&lt;</a>";
@@ -33,6 +49,36 @@ class Pbs_Pagination{
$str .= "</div>";
return $str;
}
+ public function setPerPage($perpage){
+ $this->perpage = $perpage;
+ }
+ public function getPerPage(){
+ return $this->perpage;
+ }
+ public function setRequestPage($requestpage){
+ if($requestpage < 0 || !is_numeric($requestpage) )
+ $requestpage = 0;
+ if($requestpage >= $this->numpages)
+ $requestpage = $this->numpages-1;
+ $this->requestpage = $requestpage;
+ }
+ public function getRequestPage(){
+ return $this->requestpage;
+ }
+ public function setElement($element){
+ $this->element = $element;
+ $this->maxNumber = count($element);
+ $this->numpages = ceil(count($element)/$this->perpage);
+ }
+ public function getStartItem(){
+ return $this->requestpage * $this->perpage;
+ }
+ public function getElements(){
+ return array_slice($this->element,$this->getStartItem(),$this->getPerPage());
+ }
+ public function setPageUrl($url){
+ $this->pageUrl = $url;
+ }
}
diff --git a/library/Pbs/Search.php b/library/Pbs/Search.php
new file mode 100644
index 0000000..e642d66
--- /dev/null
+++ b/library/Pbs/Search.php
@@ -0,0 +1,90 @@
+<?php
+
+class Pbs_Search{
+
+ private $searchTerm = '';
+ private $searcha;
+ private $searchb;
+
+ public function searchForm(){
+ $str = "<form style='text-align:right;' action='/user/client/search'>
+ <input type='text' name='search' ".(($this->searchTerm != '')?'value="'.$this->searchTerm.'"':'').">
+ <button type='submit' class='searchbutton' value='search'> Search</button>";
+ if($this->searchTerm != ''){
+ $str .= "<a href='/user/client/'><img src='/media/img/delete.png' alt='Delete Client'/></a>
+ <script type='text/javascript' src='/media/js/jquery.highlight-3.js'></script>
+ <script>
+ $(document).ready(function(){";
+ foreach($this->getSearchTerms() as $term){
+ $str .= "$('table').highlight('".$term."');";
+ }
+ $str .= "});
+ </script>";
+ }
+ $str .= "</form>";
+ return $str;
+ }
+
+ public function setSearchTerm($search){
+ $this->searchTerm = $search;
+
+ $parts = explode(" ",$search);
+ foreach($parts as $search){
+ if(stristr($search,":") && ctype_alpha(substr($search,0,strpos($search,":")))){
+ $key = substr($search,0,strpos($search,":"));
+ $value = substr($search,strpos($search,":")+1);
+ $searcha[$key] = $value;
+ }
+ else{
+ $searchb[] = $search;
+ }
+ }
+ $this->searcha = $searcha;
+ $this->searchb = $searchb;
+ }
+
+ public function getSearchTerms(){
+ $beta = $this->searcha;
+ foreach($this->searchb as $b)
+ $beta[] = $b;
+ return $beta;
+ }
+ public function search($array){
+
+ foreach($array as $counter => $cig){
+ foreach($cig as $k => $v){
+ if(count($this->searcha) > 0){
+ foreach($this->searcha as $sk => $sv){
+ if($k == $sk){
+ if(stristr($v,$sv)){
+ $com1[] = $counter;
+ }
+ }
+ }
+ }
+ if(count($searchb) >= 0){
+ foreach($this->searchb as $sk => $sv){
+ $comm = stristr($v,$sv);
+ if($comm != false){
+ $com2[] = $counter;
+ break;
+ }
+ }
+ }
+ }
+ }
+ if (count($this->searcha) == 0){
+ $data = $com2;
+ }
+ if (count($this->searchb) == 0){
+ $data = $com1;
+ }
+ if (count($this->searcha) > 0 && count($this->searchb) > 0){
+ $data = array_intersect($com1,$com2);
+ }
+ $data = array_unique($data);
+ foreach( $data as $c)
+ $ges[] = $array[$c];
+ return $ges;
+ }
+}
diff --git a/public/media/css/style.css b/public/media/css/style.css
index dd89e41..a8c4421 100644
--- a/public/media/css/style.css
+++ b/public/media/css/style.css
@@ -115,6 +115,9 @@ body {
min-height: 400px;
background-color: #F2F3F1;
}
+#content img {
+ border:none;
+}
#debug {
text-align: left;
@@ -310,6 +313,9 @@ td {
.addbutton:before {
content: url(/media/img/create.png) ' ';
}
+.searchbutton:before {
+ content: url(/media/img/search.png) ' ';
+}
.rightbutton {
float: right;
@@ -484,4 +490,8 @@ table.json td {
border-style: none !important;
}
+.highlight {
+ background-color: yellow;
+}
+
diff --git a/public/media/img/search.png b/public/media/img/search.png
new file mode 100644
index 0000000..6a0dd1d
--- /dev/null
+++ b/public/media/img/search.png
Binary files differ
diff --git a/public/media/js/jquery.highlight-3.js b/public/media/js/jquery.highlight-3.js
new file mode 100644
index 0000000..4d339ee
--- /dev/null
+++ b/public/media/js/jquery.highlight-3.js
@@ -0,0 +1,53 @@
+/*
+
+highlight v3
+
+Highlights arbitrary terms.
+
+<http://johannburkard.de/blog/programming/javascript/highlight-javascript-text-higlighting-jquery-plugin.html>
+
+MIT license.
+
+Johann Burkard
+<http://johannburkard.de>
+<mailto:jb@eaio.com>
+
+*/
+
+jQuery.fn.highlight = function(pat) {
+ function innerHighlight(node, pat) {
+ var skip = 0;
+ if (node.nodeType == 3) {
+ var pos = node.data.toUpperCase().indexOf(pat);
+ if (pos >= 0) {
+ var spannode = document.createElement('span');
+ spannode.className = 'highlight';
+ var middlebit = node.splitText(pos);
+ var endbit = middlebit.splitText(pat.length);
+ var middleclone = middlebit.cloneNode(true);
+ spannode.appendChild(middleclone);
+ middlebit.parentNode.replaceChild(spannode, middlebit);
+ skip = 1;
+ }
+ }
+ else if (node.nodeType == 1 && node.childNodes && !/(script|style)/i.test(node.tagName)) {
+ for (var i = 0; i < node.childNodes.length; ++i) {
+ i += innerHighlight(node.childNodes[i], pat);
+ }
+ }
+ return skip;
+ }
+ return this.each(function() {
+ innerHighlight(this, pat.toUpperCase());
+ });
+};
+
+jQuery.fn.removeHighlight = function() {
+ return this.find("span.highlight").each(function() {
+ this.parentNode.firstChild.nodeName;
+ with (this.parentNode) {
+ replaceChild(this.firstChild, this);
+ normalize();
+ }
+ }).end();
+};