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