0135d6e901da8dd50b25db397665f66b0e91c7b7
1 <?php
4 class xlsexport extends plugin
5 {
6 /* Definitions */
7 var $plHeadline= "XLS import";
8 var $plDescription= "This does something";
9 var $access= "";
11 /* attribute list for save action */
12 var $attributes= array();
13 var $objectclasses= array();
14 var $ui;
16 function xlsexport ($config, $dn= NULL)
17 {
18 /* Include config object */
19 $this->config= $config;
21 $this->ui = get_userinfo();
22 }
24 function execute()
25 {
26 /* Call parent execute */
27 plugin::execute();
29 /* Set government mode */
30 $smarty= get_smarty();
32 $smarty->assign("type",FALSE);
33 $smarty->assign("depselectivbb","");
35 if(!isset($_POST['selfull'])) $_POST['selfull'] = "Somehow not posted";
37 /* Check permissions for export */
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 $a=$_POST['single'];
43 $b=$_POST['selfull'];
45 }
46 if((isset($_POST['selfull']))&&(isset($_POST['sfrmgetfull']))){
47 $smarty->assign("depselectfull",$_POST['selfull']);
48 $smarty->assign("type","full");
49 $dn = $_POST['selfull'];
50 } else {
51 $smarty->assign("depselectfull", "");
52 }
53 if((isset($_POST['selivbb']))&&(isset($_POST['sfrmgetivbb']))){
54 $smarty->assign("depselectivbb",$_POST['selivbb']);
55 $smarty->assign("type","ivbb");
56 $dn = $_POST['selivbb'];
57 } else {
58 $smarty->assign("depselectivbb", "");
59 }
61 // Set values for optionlist in form
62 $bases = array();
63 $acl_bases = $this->ui->get_module_departments("all");
64 foreach($this->config->idepartments as $base_dn => $name){
65 if(in_array_ics($base_dn,$acl_bases)){
66 $bases[$base_dn] = $name;
67 }
68 }
69 $smarty->assign("deplist", $bases);
70 $smarty->assign("choicelist",array( get_people_ou() =>"users" ,
71 "ou=groups," =>"groups" ,
72 "ou=systems," =>"computers",
73 "ou=servers,ou=systems," =>"servers",
74 "dc=addressbook," =>"addressbook"));
76 // Get the LDAP link, to generate the Export
77 $ldap = $this->config->get_ldap_link();
79 if ($this->config->current['GOVERNMENTMODE'] == 'true'){
80 $smarty->assign ("govmode", "true");
81 } else {
82 $smarty->assign ("govmode", "false");
83 }
85 $smarty->assign("LDIFError",FALSE);
87 if(isset($dn))
88 {
89 if(!($ldap->dn_exists($dn) && $dn != "")){
90 $smarty->assign("LDIFError",TRUE);
91 print_red (_("Error while exporting the requested entries!"));
92 }
93 }
95 /* check alcs for given dn */
96 $acls ="";
97 if(isset($dn)){
98 $acls = $this->ui->get_permissions($dn,"all/all");
99 }
101 if(!preg_match("/r/",$acls)){
103 /* Show error msg */
104 print_red(sprintf(_("You are not allowed to export the given ldap entry (%s)"),@LDAP::fix($dn)));
106 /* Show main page */
107 $smarty->assign("LDIFError",TRUE);
108 $smarty->assign("para","");
109 }else{
111 // Export a single LDAP entry
112 if(isset($_POST['sfrmgetsingle']))
113 {
114 $smarty->assign("para","?ivbb=2&d=".base64_encode($_POST['single'])."&n=".base64_encode($_POST['selfull']));
115 }
116 elseif(isset($_POST['sfrmgetfull']))
117 {
118 $smarty->assign("para","?ivbb=3&dn=".base64_encode($_POST['selfull']));
119 }
120 elseif(isset($_POST['sfrmgetivbb']))
121 {
122 $smarty->assign("para","?ivbb=4&dn=".base64_encode($_POST['selivbb']));
123 }
124 }
126 /* Show main page */
127 return ($smarty->fetch (get_template_path('contentexportxls.tpl', TRUE)));
128 }
130 }
133 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
134 ?>