Code

<h1> to <h3>
[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 ("govmode", $this->config->get_cfg_value("honourIvbbAttributes"));
36     $smarty->assign("LDIFError",FALSE);
38     $smarty->assign("type",FALSE);
39     $smarty->assign("depselectivbb","");
41     // fill in old vars in the Export form
42     if((isset($_POST['single']))&&(isset($_POST['sfrmgetsingle']))){
43       $smarty->assign("single",$_POST['single']);
44       $smarty->assign("type","single");
45       $dn = $_POST['single'];
46     }
47     if((isset($_POST['selfull']))&&(isset($_POST['sfrmgetfull']))){
48       $smarty->assign("depselectfull",$_POST['selfull']);
49       $smarty->assign("type","full");
50       $dn = $_POST['selfull'];
51     } else {
52       $smarty->assign("depselectfull", "");
53     }
54     if((isset($_POST['selivbb']))&&(isset($_POST['sfrmgetivbb']))){
55       $smarty->assign("depselectivbb",$_POST['selivbb']);
56       $smarty->assign("type","ivbb");
57       $dn = $_POST['selivbb'];
58     } else {
59       $smarty->assign("depselectivbb", "");
60     }
62     // Set values for optionlist in form
63     $bases      = array();
64     $acl_bases  = $this->ui->get_module_departments("ldapmanager");
65     foreach($this->config->idepartments as $base_dn => $name){
66       if(in_array_ics($base_dn,$acl_bases)){
67         $bases[$base_dn] = $name;
68       }
69     }
70     $smarty->assign("deplist", $bases);
72     // Get the LDAP link, to generate the Export
73     $ldap = $this->config->get_ldap_link();
75     if ($this->config->get_cfg_value('honourIvbbAttributes') == 'true'){
76       $smarty->assign ("govmode", $this->config->get_cfg_value("honourIvbbAttributes"));
77       $smarty->assign("LDIFError",FALSE);
78     }
80     if(isset($dn))
81     {
82       if(!($ldap->dn_exists($dn) && $dn != "")){
83         $smarty->assign("LDIFError",TRUE);
84         msg_dialog::display(_("Error"), _("Cannot export selected entries!"), ERROR_DIALOG);
85       }
86     }
88     /* check alcs for given dn */
89     $acls ="";
90     if(isset($dn)){
91       $acls = $this->ui->get_permissions($dn,"ldapmanager/ldif");
92     }
93     if((!preg_match("/r/",$acls)) && (isset($dn))){
95       /* Show error msg */      
96       msg_dialog::display(_("Permission error"), sprintf(_("You have no permission to export '%s'!"),LDAP::fix($dn)), ERROR_DIALOG);
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 ?>