Code

d64dc79d49de817efad65abcbd1e755c10982f49
[gosa.git] / plugins / addons / ldapmanager / class_export.inc
1 <?php
3 class ldifexport extends plugin
4 {
5   /* Definitions */
6   var $plHeadline= "CSV import";
7   var $plDescription= "This does something";
9   /* attribute list for save action */
10   var $attributes= array();
11   var $objectclasses= array();
12   var $view_logged = FALSE;
14   function ldifexport ($config, $dn= NULL)
15   {
16     /* Include config object */
17     $this->config= $config;
18     $this->ui = get_userinfo();
19   }
21   function execute()
22   {
23     /* Call parent execute */
24     plugin::execute();
26     /* Log view */
27     if(!$this->view_logged){
28       $this->view_logged = TRUE;
29       @log::log("view","all/".get_class($this),$this->dn);
30     }
32     /* Set government mode */
33     $smarty= get_smarty();
35     $smarty->assign("type",FALSE);
36     $smarty->assign("depselectivbb","");
38     // fill in old vars in the Export form
39     if((isset($_POST['single']))&&(isset($_POST['sfrmgetsingle']))){
40       $smarty->assign("single",$_POST['single']);
41       $smarty->assign("type","single");
42       $dn = $_POST['single'];
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("all");
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);
69     // Get the LDAP link, to generate the Export
70     $ldap = $this->config->get_ldap_link();
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         $smarty->assign("LDIFError",TRUE);
84         print_red (_("Error while exporting the requested entries!"));
85       }
86     }
88     /* check alcs for given dn */
89     $acls ="";
90     if(isset($dn)){
91       $acls = $this->ui->get_permissions($dn,"all/all");
92     }
93     if((!preg_match("/r/",$acls)) && (isset($dn))){
95       /* Show error msg */      
96       print_red(sprintf(_("You are not allowed to export the given ldap entry (%s)"),@LDAP::fix($dn)));
98       /* Show main page */
99       $smarty->assign("LDIFError",TRUE);
100       $smarty->assign("para","");
101     }else{
103       // Export a single LDAP entry
104       if(isset($_POST['sfrmgetsingle']))
105       {
106         $smarty->assign("para","?ivbb=2&amp;dn=".base64_encode($_POST['single']));
107       }
108       elseif(isset($_POST['sfrmgetfull']))
109       {
110         $smarty->assign("para","?ivbb=3&amp;dn=".base64_encode($_POST['selfull']));
111       }
112       elseif(isset($_POST['sfrmgetivbb']))
113       {
114         $smarty->assign("para","?ivbb=4&amp;dn=".base64_encode($_POST['selivbb']));
115       }
116     }
118     /* Show main page */
119     return ($smarty->fetch (get_template_path('contentexport.tpl', TRUE)));
120   }
124 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
125 ?>