From 8d6db985b61656d8b2002f2df3973993751df860 Mon Sep 17 00:00:00 2001 From: hickert Date: Tue, 23 Mar 2010 07:13:43 +0000 Subject: [PATCH] Updated reference tab git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@17000 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../generic/references/class_reference.inc | 318 ++++++++++-------- 1 file changed, 169 insertions(+), 149 deletions(-) diff --git a/gosa-core/plugins/generic/references/class_reference.inc b/gosa-core/plugins/generic/references/class_reference.inc index 2d0c825ed..793679649 100644 --- a/gosa-core/plugins/generic/references/class_reference.inc +++ b/gosa-core/plugins/generic/references/class_reference.inc @@ -32,172 +32,192 @@ class reference extends plugin function reference (&$config, $dn= NULL) { - /* Include config object */ - $this->config= &$config; - $this->dn= $dn; - - /* Fill translation array */ - $this->obtypes= array( - "gosaAccount" => array( "text" => _("Generic"), - "image" => "images/penguin.png"), - "posixAccount" => array( "text" =>_("UNIX"), - "image" => "plugins/users/images/select_user.png"), - "gosaMailAccount" => array("text" => _("Mail"), - "image" => "images/mailto.png"), - "sambaSamAccount" => array("text" => _("Samba"), - "image" => "plugins/systems/images/select_winstation.png"), - "sambaAccount" => array( "text" => _("Samba"), - "image" => "plugins/sysmtes/images/select_winstation.png"), - "goFaxAccount" => array( "text" => _("FAX"), - "image" => "plugins/gofax/images/fax_small.png"), - "gosaProxyAccount" => array("text" => _("Proxy"), - "image" => "images/select_proxy.png"), - "PureFTPdUser" => array( "text" => _("FTP"), - "image" => "images/select_proxy.png"), - "posixGroup" => array( "text" => _("Group"), - "image" => "plugins/groups/images/select_group.png"), - "gosaDepartment" => array( "text" => _("Department"), - "image" => "images/select_department.png"), - "goFonHardware" => array( "text" => _("Phone"), - "image" => "plugins/systems/images/select_phone.png"), - "gosaApplication" => array("text" => _("Application"), - "image" => "plugins/goto/images/select_application.png"), - "goServer" => array( "text" => _("Server"), - "image" => "plugins/systems/images/select_server.png"), - "gotoTerminal" => array( "text" => _("Thin Client"), - "image" => "images/select_terminal.png"), - "gotoWorkstation" => array("text" => _("Workstation"), - "image" => "plugins/systems/images/select_workstation.png"), - "gosaGroupOfNames" => array("text" => _("Object group"), - "image" => "plugins/ogroups/images/select_ogroup.png"), - "gotoPrinter" => array( "text" => _("Printer"), - "image" => "plugins/systems/images/select_printer.png")); + /* Include config object */ + $this->config= &$config; + $this->dn= $dn; + + /* Fill translation array */ + $this->obtypes= array( + "gosaAccount" => array( "text" => _("Generic"), + "image" => "images/penguin.png"), + "posixAccount" => array( "text" =>_("UNIX"), + "image" => "plugins/users/images/select_user.png"), + "gosaMailAccount" => array("text" => _("Mail"), + "image" => "images/mailto.png"), + "sambaSamAccount" => array("text" => _("Samba"), + "image" => "plugins/systems/images/select_winstation.png"), + "sambaAccount" => array( "text" => _("Samba"), + "image" => "plugins/sysmtes/images/select_winstation.png"), + "goFaxAccount" => array( "text" => _("FAX"), + "image" => "plugins/gofax/images/fax_small.png"), + "gosaProxyAccount" => array("text" => _("Proxy"), + "image" => "images/select_proxy.png"), + "PureFTPdUser" => array( "text" => _("FTP"), + "image" => "images/select_proxy.png"), + "posixGroup" => array( "text" => _("Group"), + "image" => "plugins/groups/images/select_group.png"), + "gosaDepartment" => array( "text" => _("Department"), + "image" => "images/select_department.png"), + "goFonHardware" => array( "text" => _("Phone"), + "image" => "plugins/systems/images/select_phone.png"), + "gosaApplication" => array("text" => _("Application"), + "image" => "plugins/goto/images/select_application.png"), + "goServer" => array( "text" => _("Server"), + "image" => "plugins/systems/images/select_server.png"), + "gotoTerminal" => array( "text" => _("Thin Client"), + "image" => "images/select_terminal.png"), + "gotoWorkstation" => array("text" => _("Workstation"), + "image" => "plugins/systems/images/select_workstation.png"), + "gosaGroupOfNames" => array("text" => _("Object group"), + "image" => "plugins/ogroups/images/select_ogroup.png"), + "gotoPrinter" => array( "text" => _("Printer"), + "image" => "plugins/systems/images/select_printer.png")); } function execute() { - /* Call parent execute */ - plugin::execute(); - - /* Set government mode */ - $smarty= get_smarty(); - - if (isset($_GET['show'])){ - $dn= base64_decode($_GET['show']); - if (isset($this->fold["$dn"])){ - unset($this->fold["$dn"]); - } else { - $this->fold["$dn"]= "$dn"; - } - } - - /* Fill array */ - $this->reload(); - $smarty->assign("objectList", $this->objectlist); - - /* Show main page */ - return ($smarty->fetch (get_template_path('contents.tpl', TRUE, dirname(__FILE__)))); + /* Call parent execute */ + plugin::execute(); + + /* Set government mode */ + $smarty= get_smarty(); + + if (isset($_GET['show'])){ + $dn= base64_decode($_GET['show']); + if (isset($this->fold["$dn"])){ + unset($this->fold["$dn"]); + } else { + $this->fold["$dn"]= "$dn"; + } + } + + /* Fill array */ + $this->reload(); + $smarty->assign("objectList", $this->objectlist); + + /* Show main page */ + return ($smarty->fetch (get_template_path('contents.tpl', TRUE, dirname(__FILE__)))); } function reload() { - $ldap= $this->config->get_ldap_link(); - $ldap->cd($this->config->current['BASE']); - - $ldap->search("(|(gotoHotplugDeviceDN=".LDAP::prepare4filter($this->dn).")(member=".LDAP::prepare4filter($this->dn).")(memberUid=".$this->uid."))",array("memberUid","member","cn","description","objectClass")); - - $cycle= array("F5F5F5", "ECECEC"); - $id= 0; - $this->objectlist= ""; - while ($attrs= $ldap->fetch()){ - - /* Add more information? */ - $addon= ""; - if (in_array($attrs['dn'], $this->fold)){ - $memberattr= ""; - if (isset($attrs['memberUid'])){ - unset($attrs['memberUid']['count']); - $memberattr= "memberUid"; - } - if (isset($attrs['member'])){ - unset($attrs['member']['count']); - $memberattr= "member"; - } - if ($memberattr == ""){ - continue; - } - foreach ($attrs[$memberattr] as $uid){ - $content= $this->getCacheObject($uid); - if ($content === NULL) { - continue; - } - $addon.= '   '.$content['name'].''.$content['description'].''.$content['type'].' '; - } - } - - /* Build final entry */ - if (isset($attrs['description'])){ - $description= $attrs['description'][0]; - } else { - $description= "-"; - } - $content= $this->createContentString($attrs['objectClass']); - if ($addon == ""){ - $img= "images/lists/expand.png"; - } else { - $img= "images/lists/sort-down.png"; - } - $this->objectlist.= ' '.$attrs['cn'][0].''.$description.''.$content.' '.$addon; - - $id++; - } - + $ldap= $this->config->get_ldap_link(); + $ldap->cd($this->config->current['BASE']); + + $ldap->search( + "(|(gotoHotplugDeviceDN=".LDAP::prepare4filter($this->dn).")". + "(member=".LDAP::prepare4filter($this->dn).")(memberUid=".$this->uid."))", + array("memberUid","member","cn","description","objectClass")); + + $cycle= array("F5F5F5", "ECECEC"); + $id= 0; + $this->objectlist= ""; + while ($attrs= $ldap->fetch()){ + + /* Add more information? */ + $addon= ""; + if (in_array($attrs['dn'], $this->fold)){ + $memberattr= ""; + if (isset($attrs['memberUid'])){ + unset($attrs['memberUid']['count']); + $memberattr= "memberUid"; + } + if (isset($attrs['member'])){ + unset($attrs['member']['count']); + $memberattr= "member"; + } + if ($memberattr == ""){ + continue; + } + foreach ($attrs[$memberattr] as $uid){ + $content= $this->getCacheObject($uid); + if ($content === NULL) { + continue; + } + $addon.= + ' '. + '    '.$content['name'].''. + ' '.$content['description'].''. + ' '.$content['type'].' '. + ' '; + } + } + + /* Build final entry */ + if (isset($attrs['description'])){ + $description= $attrs['description'][0]; + } else { + $description= "-"; + } + $content= $this->createContentString($attrs['objectClass']); + if ($addon == ""){ + $img= "images/lists/expand.png"; + } else { + $img= "images/lists/sort-down.png"; + } + $this->objectlist.= + ' '. + ' '. + ' '.image($img).' '.$attrs['cn'][0]. + ' '. + ' '. + ' '. + ' '.$description.' '. + ' '.$content.' '. + ' '.$addon; + $id++; + } + } function getCacheObject($dn) { - if (!isset($this->objectCache[$dn])){ - $ldap= $this->config->get_ldap_link(); - if (preg_match('/,/', $dn)){ - $ldap->cat($dn, array("cn", "objectClass", "description","ou")); - } else { - $ldap->search("(uid=$dn)", array("cn", "objectClass", "description","ou")); - } - if ($ldap->count()){ - $attrs= $ldap->fetch(); - - if(isset($attrs['ou']) && !isset($attrs['cn'])){ - $attrs['cn'] = $attrs['ou']; - } - - if (isset($attrs['description'])){ - $description= $attrs['description'][0]; - } else { - $description= "-"; - } - $this->objectCache[$dn]= array( 'name' => $attrs['cn'][0], - 'description' => "$description", - 'type' => $this->createContentString($attrs['objectClass'])); - } else { - return NULL; - } - } - return ($this->objectCache[$dn]); + if (!isset($this->objectCache[$dn])){ + $ldap= $this->config->get_ldap_link(); + if (preg_match('/,/', $dn)){ + $ldap->cat($dn, array("cn", "objectClass", "description","ou")); + } else { + $ldap->search("(uid=$dn)", array("cn", "objectClass", "description","ou")); + } + if ($ldap->count()){ + $attrs= $ldap->fetch(); + + if(isset($attrs['ou']) && !isset($attrs['cn'])){ + $attrs['cn'] = $attrs['ou']; + } + + if (isset($attrs['description'])){ + $description= $attrs['description'][0]; + } else { + $description= "-"; + } + $this->objectCache[$dn]= array( 'name' => $attrs['cn'][0], + 'description' => "$description", + 'type' => $this->createContentString($attrs['objectClass'])); + } else { + return NULL; + } + } + return ($this->objectCache[$dn]); } function createContentString($classes) { - $result= ""; - if(!is_null($classes)) { - foreach ($classes as $class){ - if (isset($this->obtypes[$class])){ - $result.= "\"\" ".$this->obtypes[$class]['text']." "; - } - } - } - return (preg_replace('/ $/', '', $result)); + $result= ""; + if(!is_null($classes)) { + foreach ($classes as $class){ + if (isset($this->obtypes[$class])){ + $result.= + " ".image($this->obtypes[$class]['image']). + " ". + " ".$this->obtypes[$class]['text']. + " "; + } + } + } + return (preg_replace('/ $/', '', $result)); } - + } ?> -- 2.30.2