From: hickert Date: Thu, 28 Jan 2010 15:18:55 +0000 (+0000) Subject: Updated filter X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=771471ad6a31aa74b29cdd08713123c9367ada9f;p=gosa.git Updated filter git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@15425 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-plugins/fai/admin/fai/classSelect/class_classSelect.inc b/gosa-plugins/fai/admin/fai/classSelect/class_classSelect.inc index c5e8612d0..99b40f4e5 100644 --- a/gosa-plugins/fai/admin/fai/classSelect/class_classSelect.inc +++ b/gosa-plugins/fai/admin/fai/classSelect/class_classSelect.inc @@ -42,8 +42,30 @@ class classSelect extends management // Build headpage $headpage = new listing(get_template_path("selectClass-list.xml", true, dirname(__FILE__))); + $headpage->registerElementFilter("filterProperties", "classSelect::filterProperties"); $headpage->setFilter($filter); - parent::__construct($config, $ui, "object", $headpage); + parent::__construct($config, $ui, "FAI class", $headpage); + } + + static function filterProperties($row, $classes) + { + /* Create different picture for each object type */ + $objTypes['FAIhook'] = " "; + $objTypes['FAItemplate'] = " "; + $objTypes['FAIscript'] = " "; + $objTypes['FAIvariable'] = " "; + $objTypes['FAIpackageList'] = " "; + $objTypes['FAIpartitionTable'] = " "; + + $str = ""; + foreach($objTypes as $class => $img){ + if(in_array($class, $classes)){ + $str .= $img; + }else{ + $str .= " "; + } + } + return($str); } function save() diff --git a/gosa-plugins/fai/admin/fai/classSelect/class_filterFAIClass.inc b/gosa-plugins/fai/admin/fai/classSelect/class_filterFAIClass.inc new file mode 100644 index 000000000..66c88a47c --- /dev/null +++ b/gosa-plugins/fai/admin/fai/classSelect/class_filterFAIClass.inc @@ -0,0 +1,72 @@ + "faiScript", + "FAItemplate" => "faiTemplate", + "FAIhook" => "faiHook", + "FAIvariable" => "faiVariable", + "FAIpartitionTable" => "faiPartitionTable", + "FAIpackageList" => "faiPackage"); + + /* Read out all objects from fai tree */ + $ldap= $config->get_ldap_link(); + $ldap->cd($base); + $ui = get_userinfo(); + $sort=array(); + $FAIAllclasses = array(); + + foreach($FAI_objects as $obj){ + + $ldap->cat($obj['dn']); + $attrs = $ldap->fetch(); + + /* Only use objects which have cn set */ + if(isset($attrs['cn'][0]) && preg_match("/".preg_quote($filter,'/')."/i", $attrs['cn'][0])){ + foreach($categories as $cat => $acl){ + if(in_array($cat,$attrs['objectClass'])){ + $acl = $ui->get_permissions($attrs['dn'],"fai/".$acl); + if(!isset($FAIAllclasses[$attrs['cn'][0]])){ + $FAIAllclasses[$attrs['cn'][0]] = $attrs ; + }else{ + $FAIAllclasses[$attrs['cn'][0]]['objectClass'] = + array_merge($attrs['objectClass'],$FAIAllclasses[$attrs['cn'][0]]['objectClass']); + } + } + } + } + } + return(filterFAIClass::filterByBlacklist(array_values($FAIAllclasses))); + } + + static function filterByBlacklist($entries) + { + if(session::is_set('filterBlacklist')){ + $blist = session::get('filterBlacklist'); + foreach($blist as $attr_name => $attr_values){ + foreach($attr_values as $match){ + foreach($entries as $id => $entry){ + if(isset($entry[$attr_name])){ + $test = $entry[$attr_name]; + if(!is_array($test)) $test = array($test); + if(in_array($match, $test)) unset($entries[$id]); + } + } + } + } + } + return(array_values($entries)); + } +} +?> diff --git a/gosa-plugins/fai/admin/fai/classSelect/selectClass-filter.tpl b/gosa-plugins/fai/admin/fai/classSelect/selectClass-filter.tpl index e1016c059..3d4595cf7 100644 --- a/gosa-plugins/fai/admin/fai/classSelect/selectClass-filter.tpl +++ b/gosa-plugins/fai/admin/fai/classSelect/selectClass-filter.tpl @@ -6,14 +6,6 @@
-
- -{$USER} 
-{$GROUP} 
- -
- {$SCOPE} -
diff --git a/gosa-plugins/fai/admin/fai/classSelect/selectClass-filter.xml b/gosa-plugins/fai/admin/fai/classSelect/selectClass-filter.xml index 5dc11eead..a6b02bebe 100644 --- a/gosa-plugins/fai/admin/fai/classSelect/selectClass-filter.xml +++ b/gosa-plugins/fai/admin/fai/classSelect/selectClass-filter.xml @@ -9,8 +9,8 @@ - LDAPBlacklist - (&(|$USER $GROUP ) $NAME) + FAIClass + $NAME dn objectClass cn @@ -30,11 +30,11 @@ 60 - (|(cn=*$*)(sn=*$*)(givenName=*$*)) + *$ true - LDAPBlacklist - (&(objectClass=gosaAccount)(|(cn=*$NAME*)(sn=*$NAME*)(givenName=*$NAME*))) + FAIClass + $NAME cn 0.5 3 diff --git a/gosa-plugins/fai/admin/fai/classSelect/selectClass-list.xml b/gosa-plugins/fai/admin/fai/classSelect/selectClass-list.xml index cf197a970..9eb7ef681 100644 --- a/gosa-plugins/fai/admin/fai/classSelect/selectClass-list.xml +++ b/gosa-plugins/fai/admin/fai/classSelect/selectClass-list.xml @@ -5,45 +5,24 @@ false false false - false + true users 1 - - gosaAccount - users - user - plugins/users/images/select_user.png - - - - - posixGroup - groups - group - plugins/groups/images/groups.png + + FAIclass + fai + fai + plugins/fai/images/script.png - |20px;c|220px|| - - - %{filter:objectType(dn,objectClass)} - - - - %{filter:departmentLink(row,dn,description)} - 1 - - - - %{filter:objectType(dn,objectClass)} - + |220px|| @@ -54,11 +33,8 @@ - - description - string - %{description} - true + + %{filter:filterProperties(row,objectClass)}
@@ -67,12 +43,5 @@ - - edit - entry - gosaAccount - images/lists/edit.png - - diff --git a/gosa-plugins/fai/admin/fai/class_faiProfile.inc b/gosa-plugins/fai/admin/fai/class_faiProfile.inc index 67d41d187..db587ac06 100644 --- a/gosa-plugins/fai/admin/fai/class_faiProfile.inc +++ b/gosa-plugins/fai/admin/fai/class_faiProfile.inc @@ -257,7 +257,7 @@ class faiProfile extends plugin } /* Save Dialog */ - if(isset($_POST['classSelect_save'])){ + if(isset($_POST['classSelect_save']) && $this->classSelect instanceOf classSelect){ $list = $this->classSelect->save(); foreach($list as $entry){ $class = $entry['cn'][0]; @@ -275,6 +275,8 @@ class faiProfile extends plugin } if($this->classSelect instanceOf classSelect){ + session::set('filterFAIClass_base',$this->parent->parent->fai_release); + session::set('filterBlacklist', array('cn' => array_values($this->FAIclasses))); return($this->classSelect->execute()); }