Code

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