From: hickert Date: Mon, 26 Apr 2010 10:23:21 +0000 (+0000) Subject: Updated reference tab X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=47eed52d20d0e6f117c395614cf2dd2d3ecfc415;p=gosa.git Updated reference tab -Allows to view entry ldifs now. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@17832 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-core/ihtml/themes/default/ldifViewer.tpl b/gosa-core/ihtml/themes/default/ldifViewer.tpl new file mode 100644 index 000000000..dee813f29 --- /dev/null +++ b/gosa-core/ihtml/themes/default/ldifViewer.tpl @@ -0,0 +1,8 @@ + +
+{$ldif}
+
+
+
+ +
diff --git a/gosa-core/include/class_ldap.inc b/gosa-core/include/class_ldap.inc index 75901c780..1a991f1b6 100644 --- a/gosa-core/include/class_ldap.inc +++ b/gosa-core/include/class_ldap.inc @@ -857,27 +857,16 @@ class LDAP{ } - function gen_ldif ($srp, $dn, $filter= "(objectClass=*)", $attributes= array('*'), $recursive= TRUE) + function generateLdif ($dn, $filter= "(objectClass=*)", $attributes= array(), $scope = 'sub', $limit=0) { - $display= ""; - - if ($recursive){ - $this->cd($dn); - $this->ls($srp, $filter,$dn, array('dn','objectClass')); - $deps = array(); - - $display .= $this->gen_one_entry($dn)."\n"; - - while ($attrs= $this->fetch($srp)){ - $deps[] = $attrs['dn']; - } - foreach($deps as $dn){ - $display .= $this->gen_ldif($srp, $dn, $filter,$attributes,$recursive); - } - } else { - $display.= $this->gen_one_entry($dn); - } - return ($display); + $host = $this->hostname; + $attrs = (count($attributes))?implode($attributes,' '):''; + $scope = (!empty($scope))?' -s '.$scope: ''; + $limit = (!$limit)?'':' -z '.$limit; + $cmd = "ldapsearch -x -LLLL '{$filter}' {$limit} {$scope} -H '{$host}' -b '{$dn}' $attrs"; + exec($cmd, $ret,$code); + $res = implode($ret,"\n"); + return($res); } @@ -904,57 +893,6 @@ class LDAP{ } - function gen_one_entry($dn, $filter= "(objectClass=*)" , $name= array("*")) - { - $ret = ""; - $data = ""; - if($this->reconnect){ - $this->connect(); - } - - /* Searching Ldap Tree */ - $sr= @ldap_read($this->cid, LDAP::fix($dn), $filter, $name); - - /* Get the first entry */ - $entry= @ldap_first_entry($this->cid, $sr); - - /* Get all attributes related to that Objekt */ - $atts = array(); - - /* Assemble dn */ - $atts[0]['name'] = "dn"; - $atts[0]['value'] = array('count' => 1, 0 => $dn); - - /* Reset index */ - $i = 1 ; - $identifier = array(); - $attribute= @ldap_first_attribute($this->cid,$entry,$identifier); - while ($attribute) { - $i++; - $atts[$i]['name'] = $attribute; - $atts[$i]['value'] = @ldap_get_values_len($this->cid, $entry, "$attribute"); - - /* Next one */ - $attribute= @ldap_next_attribute($this->cid,$entry,$identifier); - } - - foreach($atts as $at) - { - for ($i= 0; $i<$at['value']['count']; $i++){ - - /* Check if we must encode the data */ - if(!preg_match('/^[a-z0-9+@#.=, \/ -]+$/i', $at['value'][$i])) { - $ret .= $at['name'].":: ".base64_encode($at['value'][$i])."\n"; - } else { - $ret .= $at['name'].": ".$at['value'][$i]."\n"; - } - } - } - - return($ret); - } - - function dn_exists($dn) { return @ldap_list($this->cid, LDAP::fix($dn), "(objectClass=*)", array("objectClass")); diff --git a/gosa-core/plugins/generic/references/class_ldifViewer.inc b/gosa-core/plugins/generic/references/class_ldifViewer.inc new file mode 100644 index 000000000..79d2381df --- /dev/null +++ b/gosa-core/plugins/generic/references/class_ldifViewer.inc @@ -0,0 +1,23 @@ +config = &$config; + $this->dn = $dn; + $ldap = $this->config->get_ldap_link(); + $this->ldif=$ldap->generateLdif(LDAP::fix($this->dn),'(objectClass=*)',array(),'base'); + } + + function execute() + { + $smarty = get_smarty(); + $smarty->assign('ldif', $this->ldif); + return($smarty->fetch(get_template_path('ldifViewer.tpl'))); + } +} + +?> diff --git a/gosa-core/plugins/generic/references/class_reference.inc b/gosa-core/plugins/generic/references/class_reference.inc index 3bb9c1ed7..80ed7d304 100644 --- a/gosa-core/plugins/generic/references/class_reference.inc +++ b/gosa-core/plugins/generic/references/class_reference.inc @@ -132,10 +132,14 @@ class reference extends plugin // Mark plugin as viewed plugin::execute(); + // Show ldif viewer if(isset($_POST['viewLdif'])){ - echo "ding!"; + $this->dialog = new ldifViewer($this->config, $this->dn); + } + if(isset($_POST['cancelLdifViewer'])) $this->dialog = NULL; + if($this->dialog instanceOf ldifViewer){ + return($this->dialog->execute()); } - $smarty = get_smarty();