Code

ae27875db37ad070f01d5397be9291c71403eec9
[gosa.git] / plugins / addons / ldapmanager / class_exportxls.inc
1 <?php
4 class xlsexport extends plugin
5 {
6   /* Definitions */
7   var $plHeadline= "XLS import";
8   var $plDescription= "This does something";
9   var $access= "";
11   /* attribute list for save action */
12   var $attributes= array();
13   var $objectclasses= array();
14   var $ui;
16   function xlsexport ($config, $dn= NULL)
17   {
18     /* Include config object */
19     $this->config= $config;
21     $this->ui = get_userinfo();
22   }
24   function execute()
25   {
26         /* Call parent execute */
27         plugin::execute();
29     /* Set government mode */
30     $smarty= get_smarty();
32     $smarty->assign("type",FALSE);
33     $smarty->assign("depselectivbb","");
34     
35     /* Check permissions for export */
36     // fill in old vars in the Export form
37     if((isset($_POST['single']))&&(isset($_POST['sfrmgetsingle']))){
38       $smarty->assign("single",$_POST['single']);
39       $smarty->assign("type","single");
40       $a=$_POST['single'];
41       $b=$_POST['selfull'];
43     }
44     if((isset($_POST['selfull']))&&(isset($_POST['sfrmgetfull']))){
45       $smarty->assign("depselectfull",$_POST['selfull']);
46       $smarty->assign("type","full");
47       $dn = $_POST['selfull'];
48     } else {
49       $smarty->assign("depselectfull", "");
50     }
51     if((isset($_POST['selivbb']))&&(isset($_POST['sfrmgetivbb']))){
52       $smarty->assign("depselectivbb",$_POST['selivbb']);
53       $smarty->assign("type","ivbb");
54       $dn = $_POST['selivbb'];
55     } else {
56       $smarty->assign("depselectivbb", "");
57     }
59     // Set values for optionlist in form
60     $bases      = array();
61     $acl_bases  = $this->ui->get_module_departments("ldapmanager");
62     foreach($this->config->idepartments as $base_dn => $name){
63       if(in_array_ics($base_dn,$acl_bases)){
64         $bases[$base_dn] = $name;
65       }
66     }
67     $smarty->assign("deplist", $bases);
68     $smarty->assign("choicelist",array( get_people_ou()             =>"users" ,
69                                         "ou=groups,"                =>"groups" ,
70                                         "ou=systems,"               =>"computers",
71                                         "ou=servers,ou=systems,"    =>"servers",
72                                         "dc=addressbook,"           =>"addressbook"));
74     // Get the LDAP link, to generate the Export
75     $ldap = $this->config->get_ldap_link();
77     if ($this->config->current['GOVERNMENTMODE'] == 'true'){
78       $smarty->assign ("govmode", "true");
79     } else {
80       $smarty->assign ("govmode", "false");
81     }
83     $smarty->assign("LDIFError",FALSE);
85     if(isset($dn))
86     {
87       if(!($ldap->dn_exists($dn) && $dn != "")){
88         $smarty->assign("LDIFError",TRUE);
89         print_red (_("Error while exporting the requested entries!"));
90       }
91     }
92    
93     /* check alcs for given dn */
94     $acls ="";
95     if(isset($dn)){
96       $acls = $this->ui->get_permissions($dn,"ldapmanager/xlsexport");
97     }
98  
99     if((!preg_match("/r/",$acls)) && isset($dn)){
101       /* Show error msg */      
102       print_red(sprintf(_("You are not allowed to export the given ldap entry (%s)"),@LDAP::fix($dn)));
104       /* Show main page */
105       $smarty->assign("LDIFError",TRUE);
106       $smarty->assign("para","");
107     }else{
109       // Export a single LDAP entry
110       if(isset($_POST['sfrmgetsingle']))
111       {
112         $smarty->assign("para","?ivbb=2&amp;d=".base64_encode($_POST['single'])."&n=".base64_encode($_POST['selfull']));        
113       }
114       elseif(isset($_POST['sfrmgetfull']))
115       {
116         $smarty->assign("para","?ivbb=3&amp;dn=".base64_encode($_POST['selfull']));
117       }
118       elseif(isset($_POST['sfrmgetivbb']))
119       {
120         $smarty->assign("para","?ivbb=4&amp;dn=".base64_encode($_POST['selivbb']));
121       }
122     }
124     /* Show main page */
125     return ($smarty->fetch (get_template_path('contentexportxls.tpl', TRUE)));
126   }
128   /* Return plugin informations for acl handling
129      #FIXME You can only read attributes within this report plugin */
130   function plInfo()
131   {
132     return (array(
133         "plShortName"   => _("Export XLS"),
134         "plDescription" => _("Export XLS"),
135         "plSelfModify"  => FALSE,
136         "plDepends"     => array(),
137         "plPriority"    => 2,
138         "plSection"     => array("addon"),
139         "plCategory"    => array("ldapmanager"),
141         "plProvidedAcls" => array()
142         ));
143   }
147 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
148 ?>