From 6a4d66f0e929dfeb6e1de52fcfc17101048ab5fb Mon Sep 17 00:00:00 2001 From: hickert Date: Mon, 29 Nov 2010 07:44:12 +0000 Subject: [PATCH] Added manager info to the info Page git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@20395 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../generic/infoPage/class_infoPage.inc | 46 +++++++++++++++++-- 1 file changed, 43 insertions(+), 3 deletions(-) diff --git a/gosa-core/plugins/generic/infoPage/class_infoPage.inc b/gosa-core/plugins/generic/infoPage/class_infoPage.inc index d9d2c2db2..f33c657ad 100644 --- a/gosa-core/plugins/generic/infoPage/class_infoPage.inc +++ b/gosa-core/plugins/generic/infoPage/class_infoPage.inc @@ -3,19 +3,57 @@ class infoPage extends plugin { private $ui; + private $managers; function __construct($config) { $this->config = &$config; $this->ui = get_userinfo(); - plugin::plugin($config, $this->ui->dn); + + + // Detect managers for the current user. + $this->managers = $this->detectManagers(); + } + + function detectManagers() + { + $dn = $this->dn; + $max = 10; + $dns = array(); + $dns[] = $dn; + while(strlen($dn) >= strlen($this->config->current['BASE']) && $max){ + $dn = preg_replace("/^[^,]+,/","",$dn); + $dns[] = $dn; + $max --; + } + $ldap = $this->config->get_ldap_link(); + $ldap->cd($this->config->current['BASE']); + $managers = array(); + foreach($dns as $dn){ + $ldap->cat($dn, array('manager')); + $attrs = $ldap->fetch(); + if(isset($attrs['manager'])){ + $ldap->cat($attrs['manager'][0], array('sn','givenName','mail','telephoneNumber')); + $managers[$dn] = $ldap->fetch(); + $name = $phone = $mail = ""; + $name = "".set_post($managers[$dn]['sn'][0]).", ".set_post($managers[$dn]['givenName'][0]).""; + if(isset($managers[$dn]['mail'][0])){ + $mail = "
  • "._("Mail address").": ".set_post($managers[$dn]['mail'][0])."
  • "; + } + if(isset($managers[$dn]['telephoneNumber'][0])){ + $phone = "
  • "._("Phone number").": ".set_post($managers[$dn]['telephoneNumber'][0])."
  • "; + } + $managers[$dn]['str'] = "

    {$name}

    "; + } + } + return($managers); } + function execute() { $smarty = get_smarty(); - $personalInfoAllowed = FALSE; foreach(array("uid","sn","givenName","street","l","o","ou","jpegPhoto","personalTitle", "academicTitle","dateOfBirth","homePostalAddress","homePhone","departmentNumber", @@ -23,7 +61,7 @@ class infoPage extends plugin $smarty->assign($attr, ""); if(preg_match("/r/", $this->ui->get_permissions($this->ui->dn,"users/user", $attr)) && isset($this->attrs[$attr][0])){ - $smarty->assign($attr, $this->attrs[$attr][0]); + $smarty->assign($attr,set_post( $this->attrs[$attr][0])); $personalInfoAllowed = TRUE; } } @@ -33,6 +71,8 @@ class infoPage extends plugin $smarty->assign("rand", rand(0, 99999999)); $smarty->assign("personalInfoAllowed", $personalInfoAllowed); $smarty->assign("attrs", $this->attrs); + $smarty->assign("managers", $this->managers); + $smarty->assign("managersCnt", count($this->managers)); return($smarty->fetch(get_template_path("infoPage.tpl"))); } } -- 2.30.2