Code

Add support for xls export in ldapmanager
[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();
15   function xlsexport ($config, $dn= NULL)
16   {
17     /* Include config object */
18     $this->config= $config;
20     $ui= get_userinfo();
21     $acl= get_permissions ($config->current['BASE'], $ui->subtreeACL);
22     $acl= get_module_permission($acl, "ldifexport", $config->current['BASE']);
23     $this->access= $acl;
24   }
26   function execute()
27   {
28     /* Set government mode */
29     $smarty= get_smarty();
31     $smarty->assign("type",FALSE);
32     
33     /* Check permissions for export */
34     if ($this->access != '#all#'){
35       print_red(_("You've no permission to do LDAP exports."));
36     } else {
37       // fill in old vars in the Export form
38       if((isset($_POST['single']))&&(isset($_POST['sfrmgetsingle']))){
39         $smarty->assign("single",$_POST['single']);
40         $smarty->assign("type","single");
41         $a=$_POST['single'];
42         $b=$_POST['selfull'];
43 //      $dn=$a.$b;
44         
45       }
46       if((isset($_POST['selfull']))&&(isset($_POST['sfrmgetfull']))){
47         $smarty->assign("depselectfull",$_POST['selfull']);
48         $smarty->assign("type","full");
49         $dn = $_POST['selfull'];
50       } else {
51         $smarty->assign("depselectfull", "");
52       }
53       if((isset($_POST['selivbb']))&&(isset($_POST['sfrmgetivbb']))){
54         $smarty->assign("depselectivbb",$_POST['selivbb']);
55         $smarty->assign("type","ivbb");
56         $dn = $_POST['selivbb'];
57       } else {
58         $smarty->assign("depselectivbb", "");
59       }
60     }
62     // Set values for optionlist in form
63      $smarty->assign("deplist", $this->config->idepartments);
64      $smarty->assign("choicelist",array("ou=people,"=>"users" ,"ou=groups,"=>"groups" ,"ou=computers,ou=systems,"=>"computers","ou=servers,ou=systems,"=>"servers","dc=addressbook,"=>"addressbook"));
66     // Get the LDAP link, to generate the Export
67     $ldap = $this->config->get_ldap_link();
68         
70     if ($this->config->current['GOVERNMENTMODE'] == 'true'){
71       $smarty->assign ("govmode", "true");
72     } else {
73       $smarty->assign ("govmode", "false");
74     }
76     $smarty->assign("LDIFError",FALSE);
78     if(isset($dn))
79     {
80       if($ldap->dn_exists($dn) && $dn != ""){
81         ;
82       }
83       else    {
84         $smarty->assign("LDIFError",TRUE);
85         print_red (_("Error while exporting the requested entries!"));
86       }
87     }
88 //     print_r($_POST);
89     // Export a single LDAP entry
90     if(isset($_POST['sfrmgetsingle']))
91     {
92       $smarty->assign("para","?ivbb=2&amp;d=".base64_encode($_POST['single'])."&n=".base64_encode($_POST['selfull']));  
93     }
94     elseif(isset($_POST['sfrmgetfull']))
95     {
96       $smarty->assign("para","?ivbb=3&amp;dn=".base64_encode($_POST['selfull']));
97     }
98     elseif(isset($_POST['sfrmgetivbb']))
99     {
100       $smarty->assign("para","?ivbb=4&amp;dn=".base64_encode($_POST['selivbb']));
101     }
104     /* Show main page */
105     return ($smarty->fetch (get_template_path('contentexportxls.tpl', TRUE)));
106   }
110 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
111 ?>