Code

Added execute methods
[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         /* Call parent execute */
29         plugin::execute();
30     /* Set government mode */
31     $smarty= get_smarty();
33     $smarty->assign("type",FALSE);
34     
35     /* Check permissions for export */
36     if ($this->access != '#all#'){
37       print_red(_("You've no permission to do LDAP exports."));
38     } else {
39       // fill in old vars in the Export form
40       if((isset($_POST['single']))&&(isset($_POST['sfrmgetsingle']))){
41         $smarty->assign("single",$_POST['single']);
42         $smarty->assign("type","single");
43         $a=$_POST['single'];
44         $b=$_POST['selfull'];
45 //      $dn=$a.$b;
46         
47       }
48       if((isset($_POST['selfull']))&&(isset($_POST['sfrmgetfull']))){
49         $smarty->assign("depselectfull",$_POST['selfull']);
50         $smarty->assign("type","full");
51         $dn = $_POST['selfull'];
52       } else {
53         $smarty->assign("depselectfull", "");
54       }
55       if((isset($_POST['selivbb']))&&(isset($_POST['sfrmgetivbb']))){
56         $smarty->assign("depselectivbb",$_POST['selivbb']);
57         $smarty->assign("type","ivbb");
58         $dn = $_POST['selivbb'];
59       } else {
60         $smarty->assign("depselectivbb", "");
61       }
62     }
64     // Set values for optionlist in form
65      $smarty->assign("deplist", $this->config->idepartments);
66      $smarty->assign("choicelist",array("ou=people,"=>"users" ,"ou=groups,"=>"groups" ,"ou=computers,ou=systems,"=>"computers","ou=servers,ou=systems,"=>"servers","dc=addressbook,"=>"addressbook"));
68     // Get the LDAP link, to generate the Export
69     $ldap = $this->config->get_ldap_link();
70         
72     if ($this->config->current['GOVERNMENTMODE'] == 'true'){
73       $smarty->assign ("govmode", "true");
74     } else {
75       $smarty->assign ("govmode", "false");
76     }
78     $smarty->assign("LDIFError",FALSE);
80     if(isset($dn))
81     {
82       if($ldap->dn_exists($dn) && $dn != ""){
83         ;
84       }
85       else    {
86         $smarty->assign("LDIFError",TRUE);
87         print_red (_("Error while exporting the requested entries!"));
88       }
89     }
90 //     print_r($_POST);
91     // Export a single LDAP entry
92     if(isset($_POST['sfrmgetsingle']))
93     {
94       $smarty->assign("para","?ivbb=2&amp;d=".base64_encode($_POST['single'])."&n=".base64_encode($_POST['selfull']));  
95     }
96     elseif(isset($_POST['sfrmgetfull']))
97     {
98       $smarty->assign("para","?ivbb=3&amp;dn=".base64_encode($_POST['selfull']));
99     }
100     elseif(isset($_POST['sfrmgetivbb']))
101     {
102       $smarty->assign("para","?ivbb=4&amp;dn=".base64_encode($_POST['selivbb']));
103     }
106     /* Show main page */
107     return ($smarty->fetch (get_template_path('contentexportxls.tpl', TRUE)));
108   }
112 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
113 ?>