Code

Migration to get_value
[gosa.git] / gosa-plugins / ldapmanager / 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       new 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->get_cfg_['GOVERNMENTMODE'] == 'true'){
73     $smarty->assign ("govmode", $this->config->get_cfg_value("governmentmode"));
74     $smarty->assign("LDIFError",FALSE);
76     if(isset($dn))
77     {
78       if(!($ldap->dn_exists($dn) && $dn != "")){
79         $smarty->assign("LDIFError",TRUE);
80         msg_dialog::display(_("Error"), _("Cannot export selected entries!"), ERROR_DIALOG);
81       }
82     }
84     /* check alcs for given dn */
85     $acls ="";
86     if(isset($dn)){
87       $acls = $this->ui->get_permissions($dn,"all/all");
88     }
89     if((!preg_match("/r/",$acls)) && (isset($dn))){
91       /* Show error msg */      
92       msg_dialog::display(_("Permission error"), sprintf(_("You have no permission to export '%s'!"),@LDAP::fix($dn)), ERROR_DIALOG);
94       /* Show main page */
95       $smarty->assign("LDIFError",TRUE);
96       $smarty->assign("para","");
97     }else{
99       // Export a single LDAP entry
100       if(isset($_POST['sfrmgetsingle']))
101       {
102         $smarty->assign("para","?ivbb=2&amp;dn=".base64_encode($_POST['single']));
103       }
104       elseif(isset($_POST['sfrmgetfull']))
105       {
106         $smarty->assign("para","?ivbb=3&amp;dn=".base64_encode($_POST['selfull']));
107       }
108       elseif(isset($_POST['sfrmgetivbb']))
109       {
110         $smarty->assign("para","?ivbb=4&amp;dn=".base64_encode($_POST['selivbb']));
111       }
112     }
114     /* Show main page */
115     return ($smarty->fetch (get_template_path('contentexport.tpl', TRUE)));
116   }
120 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
121 ?>