Code

Prepared ldapmanager for acls
[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();
13   function ldifexport ($config, $dn= NULL)
14   {
15     /* Include config object */
16     $this->config= $config;
17     $this->ui = get_userinfo();
18   }
20   function execute()
21   {
22     /* Call parent execute */
23     plugin::execute();
25     /* Set government mode */
26     $smarty= get_smarty();
28     $smarty->assign("type",FALSE);
29     $smarty->assign("depselectivbb","");
31     // fill in old vars in the Export form
32     if((isset($_POST['single']))&&(isset($_POST['sfrmgetsingle']))){
33       $smarty->assign("single",$_POST['single']);
34       $smarty->assign("type","single");
35       $dn = $_POST['single'];
36     }
37     if((isset($_POST['selfull']))&&(isset($_POST['sfrmgetfull']))){
38       $smarty->assign("depselectfull",$_POST['selfull']);
39       $smarty->assign("type","full");
40       $dn = $_POST['selfull'];
41     } else {
42       $smarty->assign("depselectfull", "");
43     }
44     if((isset($_POST['selivbb']))&&(isset($_POST['sfrmgetivbb']))){
45       $smarty->assign("depselectivbb",$_POST['selivbb']);
46       $smarty->assign("type","ivbb");
47       $dn = $_POST['selivbb'];
48     } else {
49       $smarty->assign("depselectivbb", "");
50     }
52     // Set values for optionlist in form
53     $bases      = array();
54     $acl_bases  = $this->ui->get_module_departments("ldapmanager");
55     foreach($this->config->idepartments as $base_dn => $name){
56       if(in_array_ics($base_dn,$acl_bases)){
57         $bases[$base_dn] = $name;
58       }
59     }
60     $smarty->assign("deplist", $bases);
62     // Get the LDAP link, to generate the Export
63     $ldap = $this->config->get_ldap_link();
65     if ($this->config->current['GOVERNMENTMODE'] == 'true'){
66       $smarty->assign ("govmode", "true");
67     } else {
68       $smarty->assign ("govmode", "false");
69     }
71     $smarty->assign("LDIFError",FALSE);
73     if(isset($dn))
74     {
75       if(!($ldap->dn_exists($dn) && $dn != "")){
76         $smarty->assign("LDIFError",TRUE);
77         print_red (_("Error while exporting the requested entries!"));
78       }
79     }
81     /* check alcs for given dn */
82     $acls ="";
83     if(isset($dn)){
84       $acls = $this->ui->get_permissions($dn,"ldapmanager/ldifexport");
85     }
86     if(!preg_match("/r/",$acls)){
88       /* Show error msg */      
89       print_red(sprintf(_("You are not allowed to export the given ldap entry (%s)"),@LDAP::fix($dn)));
91       /* Show main page */
92       $smarty->assign("LDIFError",TRUE);
93       $smarty->assign("para","");
94     }else{
96       // Export a single LDAP entry
97       if(isset($_POST['sfrmgetsingle']))
98       {
99         $smarty->assign("para","?ivbb=2&amp;dn=".base64_encode($_POST['single']));
100       }
101       elseif(isset($_POST['sfrmgetfull']))
102       {
103         $smarty->assign("para","?ivbb=3&amp;dn=".base64_encode($_POST['selfull']));
104       }
105       elseif(isset($_POST['sfrmgetivbb']))
106       {
107         $smarty->assign("para","?ivbb=4&amp;dn=".base64_encode($_POST['selivbb']));
108       }
109     }
111     /* Show main page */
112     return ($smarty->fetch (get_template_path('contentexport.tpl', TRUE)));
113   }
115   /* Return plugin informations for acl handling
116      #FIXME You can only read attributes within this report plugin */
117   function plInfo()
118   {
119     return (array(
120         "plShortName"   => _("Export"),
121         "plDescription" => _("Export"),
122         "plSelfModify"  => FALSE,
123         "plDepends"     => array(),
124         "plPriority"    => 1,
125         "plSection"     => array("addon"),
126         "plCategory"    => array("ldapmanager" => array("objectClass" => "none", "description" => _("Ldap manager addon"))),
128         "plProvidedAcls" => array()
129         ));
130   }
135 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
136 ?>