1 <?php
4 class ldifexport extends plugin
5 {
6 /* Definitions */
7 var $plHeadline= "CSV 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 ldifexport ($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);
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 $dn = $_POST['single'];
42 }
43 if((isset($_POST['selfull']))&&(isset($_POST['sfrmgetfull']))){
44 $smarty->assign("depselectfull",$_POST['selfull']);
45 $smarty->assign("type","full");
46 $dn = $_POST['selfull'];
47 } else {
48 $smarty->assign("depselectfull", "");
49 }
50 if((isset($_POST['selivbb']))&&(isset($_POST['sfrmgetivbb']))){
51 $smarty->assign("depselectivbb",$_POST['selivbb']);
52 $smarty->assign("type","ivbb");
53 $dn = $_POST['selivbb'];
54 } else {
55 $smarty->assign("depselectivbb", "");
56 }
57 }
59 // Set values for optionlist in form
60 $smarty->assign("deplist", $this->config->idepartments);
62 // Get the LDAP link, to generate the Export
63 $ldap = $this->config->get_ldap_link();
65 if ($this->config->current['GOVERNMENTMODE'] == 'true'){
66 $smarty->assign ("govmode", "true");
67 } else {
68 $smarty->assign ("govmode", "false");
69 }
71 $smarty->assign("LDIFError",FALSE);
73 if(isset($dn))
74 {
75 if($ldap->dn_exists($dn) && $dn != ""){
76 ;
77 }
78 else {
79 $smarty->assign("LDIFError",TRUE);
80 print_red (_("Error while exporting the requested entries!"));
81 }
82 }
84 // Export a single LDAP entry
85 if(isset($_POST['sfrmgetsingle']))
86 {
87 $smarty->assign("para","?ivbb=2&dn=".base64_encode($_POST['single']));
88 }
89 elseif(isset($_POST['sfrmgetfull']))
90 {
91 $smarty->assign("para","?ivbb=3&dn=".base64_encode($_POST['selfull']));
92 }
93 elseif(isset($_POST['sfrmgetivbb']))
94 {
95 $smarty->assign("para","?ivbb=4&dn=".base64_encode($_POST['selivbb']));
96 }
99 /* Show main page */
100 return ($smarty->fetch (get_template_path('contentexport.tpl', TRUE)));
101 }
102 }
105 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
106 ?>