From: hickert Date: Thu, 29 Apr 2010 15:23:18 +0000 (+0000) Subject: Updated the system filter X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=131b21778bed08f6667d72667ded9f81bfa804ab;p=gosa.git Updated the system filter - Added a 'state' attributes which can now be used to colour rows git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@17975 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-plugins/systems/admin/systems/class_filterSYSTEMS.inc b/gosa-plugins/systems/admin/systems/class_filterSYSTEMS.inc index aa7dfbdc5..dc9eb972c 100644 --- a/gosa-plugins/systems/admin/systems/class_filterSYSTEMS.inc +++ b/gosa-plugins/systems/admin/systems/class_filterSYSTEMS.inc @@ -2,110 +2,114 @@ class filterSYSTEMS { - static function query($base, $scope, $filter, $attributes, $category, $objectStorage= "") - { - $ui = get_userinfo(); - global $config; - - // Check whether the arp handling active or not - $arp_handling_active = ($config->search("ArpNewDevice","CLASS",array('tabs')) != ""); - - $entries = filterLDAP::query($base, $scope, $filter, $attributes, $category, $objectStorage); - - - foreach($entries as $key => $entry){ - if(preg_match("/".preg_quote(get_ou('systemIncomingRDN'),'/')."/i", $entry['dn'])){ - - // Detect incoming types - if(in_array('gotoWorkstation', $entry['objectClass'])){ - $entries[$key]['objectClass'][] = 'FAKE_OC_NewWorkstation'; - $entries[$key]['cn'][0].= " ("._("New workstation").")"; - }elseif(in_array('gotoTerminal', $entry['objectClass'])){ - $entries[$key]['objectClass'][] = 'FAKE_OC_NewTerminal'; - $entries[$key]['cn'][0].= " ("._("New terminal").")"; - }elseif($arp_handling_active && - in_array('GOhard', $entry['objectClass']) && - !isset($entry['gotoMode'][0])){ - $entries[$key]['objectClass'][] = 'FAKE_OC_ArpNewDevice'; - $entries[$key]['cn'][0].= " ("._("New unknown device").")"; - }elseif(in_array('GOhard', $entry['objectClass'])){ - $entries[$key]['objectClass'][] = 'FAKE_OC_NewDevice'; - $entries[$key]['cn'][0].= " ("._("New device").")"; - } - - // Detect SAMBA machines - }elseif(in_array('sambaSamAccount', $entry['objectClass']) && preg_match("/\$$/", $entry['cn'][0])){ - $entries[$key]['objectClass'][] = 'FAKE_OC_winstation'; - - // Detect Workstation & templates - }elseif(in_array('gotoWorkstation', $entry['objectClass'])){ - if(!isset($entry['macAddress'][0]) || $entry['macAddress'][0] == "-"){ - continue; // We do not need templates anymore, we've ogroups now. - //$entries[$key]['objectClass'][] = 'FAKE_OC_WorkstationTemplate'; - } - $pwd_acl = $ui->get_permissions($entry['dn'],'workstation/workgeneric','userPassword'); - if(preg_match("/w/",$pwd_acl)){ - $entries[$key]['objectClass'][] = 'FAKE_OC_PWD_changeAble'; - } - - // Detect Terminal & templates - }elseif(in_array('gotoTerminal', $entry['objectClass'])){ - if(!isset($entry['macAddress'][0]) || $entry['macAddress'][0] == "-"){ - continue; // We do not need templates anymore, we've ogroups now. - //$entries[$key]['objectClass'][] = 'FAKE_OC_TerminalTemplate'; - } - $pwd_acl = $ui->get_permissions($entry['dn'],'terminal/termgeneric','userPassword'); - if(preg_match("/w/",$pwd_acl)){ - $entries[$key]['objectClass'][] = 'FAKE_OC_PWD_changeAble'; - } - - // Detect Server & templates - }elseif(in_array('goServer', $entry['objectClass'])){ - if(!isset($entry['macAddress'][0]) || $entry['macAddress'][0] == "-"){ - continue; // We do not need templates anymore, we've ogroups now. - //$entries[$key]['objectClass'][] = 'FAKE_OC_ServerTemplate'; - } - $pwd_acl = $ui->get_permissions($entry['dn'],'server/servgeneric','userPassword'); - if(preg_match("/w/",$pwd_acl)){ - $entries[$key]['objectClass'][] = 'FAKE_OC_PWD_changeAble'; - } + static function query($base, $scope, $filter, $attributes, $category, $objectStorage= "") + { + $ui = get_userinfo(); + global $config; + + // Check whether the arp handling active or not + $arp_handling_active = ($config->search("ArpNewDevice","CLASS",array('tabs')) != ""); + + $entries = filterLDAP::query($base, $scope, $filter, $attributes, $category, $objectStorage); + + + foreach($entries as $key => $entry){ + if(preg_match("/".preg_quote(get_ou('systemIncomingRDN'),'/')."/i", $entry['dn'])){ + + // Detect incoming types + if(in_array('gotoWorkstation', $entry['objectClass'])){ + $entries[$key]['objectClass'][] = 'FAKE_OC_NewWorkstation'; + $entries[$key]['cn'][0].= " ("._("New workstation").")"; + }elseif(in_array('gotoTerminal', $entry['objectClass'])){ + $entries[$key]['objectClass'][] = 'FAKE_OC_NewTerminal'; + $entries[$key]['cn'][0].= " ("._("New terminal").")"; + }elseif($arp_handling_active && + in_array('GOhard', $entry['objectClass']) && + !isset($entry['gotoMode'][0])){ + $entries[$key]['objectClass'][] = 'FAKE_OC_ArpNewDevice'; + $entries[$key]['cn'][0].= " ("._("New unknown device").")"; + }elseif(in_array('GOhard', $entry['objectClass'])){ + $entries[$key]['objectClass'][] = 'FAKE_OC_NewDevice'; + $entries[$key]['cn'][0].= " ("._("New device").")"; + } + + // Detect SAMBA machines + }elseif(in_array('sambaSamAccount', $entry['objectClass']) && preg_match("/\$$/", $entry['cn'][0])){ + $entries[$key]['objectClass'][] = 'FAKE_OC_winstation'; + + // Detect Workstation & templates + }elseif(in_array('gotoWorkstation', $entry['objectClass'])){ + if(!isset($entry['macAddress'][0]) || $entry['macAddress'][0] == "-"){ + continue; // We do not need templates anymore, we've ogroups now. + //$entries[$key]['objectClass'][] = 'FAKE_OC_WorkstationTemplate'; + } + $pwd_acl = $ui->get_permissions($entry['dn'],'workstation/workgeneric','userPassword'); + if(preg_match("/w/",$pwd_acl)){ + $entries[$key]['objectClass'][] = 'FAKE_OC_PWD_changeAble'; + } + + // Detect Terminal & templates + }elseif(in_array('gotoTerminal', $entry['objectClass'])){ + if(!isset($entry['macAddress'][0]) || $entry['macAddress'][0] == "-"){ + continue; // We do not need templates anymore, we've ogroups now. + //$entries[$key]['objectClass'][] = 'FAKE_OC_TerminalTemplate'; + } + $pwd_acl = $ui->get_permissions($entry['dn'],'terminal/termgeneric','userPassword'); + if(preg_match("/w/",$pwd_acl)){ + $entries[$key]['objectClass'][] = 'FAKE_OC_PWD_changeAble'; + } + + // Detect Server & templates + }elseif(in_array('goServer', $entry['objectClass'])){ + if(!isset($entry['macAddress'][0]) || $entry['macAddress'][0] == "-"){ + continue; // We do not need templates anymore, we've ogroups now. + //$entries[$key]['objectClass'][] = 'FAKE_OC_ServerTemplate'; + } + $pwd_acl = $ui->get_permissions($entry['dn'],'server/servgeneric','userPassword'); + if(preg_match("/w/",$pwd_acl)){ + $entries[$key]['objectClass'][] = 'FAKE_OC_PWD_changeAble'; + } + + // Detect ieee802Device + }elseif(in_array('ieee802Device', $entry['objectClass'])){ + $pwd_acl = $ui->get_permissions($entry['dn'],'component/componentGeneric','userPassword'); + if(preg_match("/w/",$pwd_acl)){ + $entries[$key]['objectClass'][] = 'FAKE_OC_PWD_changeAble'; + } + } - // Detect ieee802Device - }elseif(in_array('ieee802Device', $entry['objectClass'])){ - $pwd_acl = $ui->get_permissions($entry['dn'],'component/componentGeneric','userPassword'); - if(preg_match("/w/",$pwd_acl)){ - $entries[$key]['objectClass'][] = 'FAKE_OC_PWD_changeAble'; - } - } - - // Detect object states - foreach(array('gotoWorkstation','gotoTerminal','goServer') as $type){ - if(in_array($type, $entry['objectClass'])){ - - if(isset($entry['gotoMode'][0]) && preg_match("/locked/i", $entry['gotoMode'][0])){ - $entries[$key]['objectClass'][] = $type."__IS_LOCKED"; - }elseif(isset($entry['FAIstate'][0])){ - switch (preg_replace('/:.*$/', '', $entry['FAIstate'][0])) { - case 'error': - $state= '__IS_ERROR'; - break; - case 'installing': - case 'install': - case 'sysinfo': - case 'softupdate': - case 'scheduledupdate': - $state= '__IS_BUSY'; - break; - default: $state =""; + // Detect object states + foreach(array('gotoWorkstation','gotoTerminal','goServer') as $type){ + if(in_array($type, $entry['objectClass'])){ + + if(isset($entry['gotoMode'][0]) && preg_match("/locked/i", $entry['gotoMode'][0])){ + $state = "locked"; + }elseif(isset($entry['FAIstate'][0])){ + switch (preg_replace('/:.*$/', '', $entry['FAIstate'][0])) { + case 'error': + $state= 'error'; + break; + case 'installing': + case 'install': + case 'sysinfo': + case 'softupdate': + case 'scheduledupdate': + $state= 'busy'; + break; + default: $state =""; + } + } + } + } + if(!empty($state)){ + $entries[$key][$entries[$key]['count']]= 'state'; + $entries[$key]['state']= $state; + $entries[$key]['count'] ++; } - if(!empty($state)) $entries[$key]['objectClass'][] = $type.$state; - } } - } - } - return($entries); - } + return($entries); + } } ?>