Code

Updated the info Page
[gosa.git] / gosa-core / plugins / generic / infoPage / class_infoPage.inc
1 <?php
3 class infoPage extends plugin
4 {
5     private $ui;
6     private $managers;
8     function __construct($config)
9     {
10         $this->config = &$config;
11         $this->ui = get_userinfo();
12         plugin::plugin($config, $this->ui->dn);
15         // Detect managers for the current user.
16         $this->managers = $this->detectManagers();
18         // Get plugin list
19         $this->plugins = $this->getPluginList();
20     }
22     function getPluginList()
23     {
24         $plist = session::get('plist');
25         $myAccountID = array_search('MyAccount',$plist->pluginList);
26         $str = "";
27         foreach($this->config->data['TABS']['MYACCOUNTTABS'] as $pluginData){
28             $plugin = $pluginData['CLASS'];
29             $plInfo = call_user_func(array($plugin,'plInfo'));
32             $str .= "<div style='width:20%;height:40px; background-color: grey; float: left'
33                         onClick='openPlugin(\"{$myAccountID}\", \"{$plugin}\");'>";
34             $str .= $plugin;
35             $str .= "</div>";
36         }
37         return($str);
38     }
39     
41     function detectManagers()
42     {
43         $dn = $this->dn;
44         $max = 10;
45         $dns = array();
46         $dns[] = $dn;
47         while(strlen($dn) >= strlen($this->config->current['BASE']) && $max){
48             $dn = preg_replace("/^[^,]+,/","",$dn);
49             $dns[] = $dn;
50             $max --;
51         }
52         $ldap = $this->config->get_ldap_link(); 
53         $ldap->cd($this->config->current['BASE']);
54         $managers = array();
55         foreach($dns as $dn){
56             $ldap->cat($dn, array('manager'));
57             $attrs = $ldap->fetch();
58             if(isset($attrs['manager'])){
59                 $ldap->cat($attrs['manager'][0], array('sn','givenName','mail','telephoneNumber'));
60                 $managers[$dn] = $ldap->fetch();
61                 $name = $phone = $mail = "";
62                 $name = "<b>".set_post($managers[$dn]['sn'][0]).", ".set_post($managers[$dn]['givenName'][0])."</b>";
63                 if(isset($managers[$dn]['mail'][0])){
64                     $mail = "<li>"._("Mail address").":&nbsp;".set_post($managers[$dn]['mail'][0])."</li>";
65                 }
66                 if(isset($managers[$dn]['telephoneNumber'][0])){
67                     $phone = "<li>"._("Phone number").":&nbsp;".set_post($managers[$dn]['telephoneNumber'][0])."</li>";
68                 }
69                 $managers[$dn]['str'] = "<p>{$name}<ul>{$phone}{$mail}</ul></p>";
70             }
71         }
72         return($managers);
73     }
74     
76     function execute()
77     {
78         $this->plugins = $this->getPluginList();
79         $smarty = get_smarty();
80         $personalInfoAllowed = FALSE;
81         foreach(array("uid","sn","givenName","street","l","o","ou","jpegPhoto","personalTitle",
82             "academicTitle","dateOfBirth","homePostalAddress","homePhone","departmentNumber",
83             "employeeNumber","employeeType") as $attr){
84             $smarty->assign($attr, "");
85             if(preg_match("/r/", $this->ui->get_permissions($this->ui->dn,"users/user", $attr))
86                 && isset($this->attrs[$attr][0])){
87                 $smarty->assign($attr,set_post( $this->attrs[$attr][0]));
88                 $personalInfoAllowed = TRUE;
89             }
90         }
92         session::set('binary',$this->attrs['jpegPhoto'][0]);
93         session::set('binarytype',"image/jpeg");
94         $smarty->assign("rand", rand(0, 99999999));
95         $smarty->assign("personalInfoAllowed", $personalInfoAllowed);
96         $smarty->assign("attrs", $this->attrs);
97         $smarty->assign("managers", $this->managers);
98         $smarty->assign("plugins", $this->plugins);
99         $smarty->assign("managersCnt", count($this->managers));
100         return($smarty->fetch(get_template_path("infoPage.tpl")));
101     }
104 ?>