6a3302a8175cc1baab82eef13c74de52a183390c
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;
15 var $view_logged = FALSE;
17 function xlsexport ($config, $dn= NULL)
18 {
19 /* Include config object */
20 $this->config= $config;
22 $this->ui = get_userinfo();
23 }
25 function execute()
26 {
27 /* Call parent execute */
28 plugin::execute();
30 /* Log view */
31 if(!$this->view_logged){
32 $this->view_logged = TRUE;
33 @log::log("view","all/".get_class($this),$this->dn);
34 }
36 /* Set government mode */
37 $smarty= get_smarty();
39 $smarty->assign("type",FALSE);
40 $smarty->assign("depselectivbb","");
42 if(!isset($_POST['selfull'])) $_POST['selfull'] = "Somehow not posted";
44 /* Check permissions for export */
45 // fill in old vars in the Export form
46 if((isset($_POST['single']))&&(isset($_POST['sfrmgetsingle']))){
47 $smarty->assign("single",$_POST['single']);
48 $smarty->assign("type","single");
49 $a=$_POST['single'];
50 $b=$_POST['selfull'];
52 }
53 if((isset($_POST['selfull']))&&(isset($_POST['sfrmgetfull']))){
54 $smarty->assign("depselectfull",$_POST['selfull']);
55 $smarty->assign("type","full");
56 $dn = $_POST['selfull'];
57 } else {
58 $smarty->assign("depselectfull", "");
59 }
60 if((isset($_POST['selivbb']))&&(isset($_POST['sfrmgetivbb']))){
61 $smarty->assign("depselectivbb",$_POST['selivbb']);
62 $smarty->assign("type","ivbb");
63 $dn = $_POST['selivbb'];
64 } else {
65 $smarty->assign("depselectivbb", "");
66 }
68 // Set values for optionlist in form
69 $bases = array();
70 $acl_bases = $this->ui->get_module_departments("all");
71 foreach($this->config->idepartments as $base_dn => $name){
72 if(in_array_ics($base_dn,$acl_bases)){
73 $bases[$base_dn] = $name;
74 }
75 }
76 $smarty->assign("deplist", $bases);
77 $smarty->assign("choicelist",array( get_people_ou() =>"users" ,
78 "ou=groups," =>"groups" ,
79 "ou=systems," =>"computers",
80 "ou=servers,ou=systems," =>"servers",
81 "dc=addressbook," =>"addressbook"));
83 // Get the LDAP link, to generate the Export
84 $ldap = $this->config->get_ldap_link();
86 if ($this->config->current['GOVERNMENTMODE'] == 'true'){
87 $smarty->assign ("govmode", "true");
88 } else {
89 $smarty->assign ("govmode", "false");
90 }
92 $smarty->assign("LDIFError",FALSE);
94 if(isset($dn))
95 {
96 if(!($ldap->dn_exists($dn) && $dn != "")){
97 $smarty->assign("LDIFError",TRUE);
98 print_red (_("Error while exporting the requested entries!"));
99 }
100 }
102 /* check alcs for given dn */
103 $acls ="";
104 if(isset($dn)){
105 $acls = $this->ui->get_permissions($dn,"all/all");
106 }
108 if(!preg_match("/r/",$acls)){
110 /* Show error msg */
111 print_red(sprintf(_("You are not allowed to export the given ldap entry (%s)"),@LDAP::fix($dn)));
113 /* Show main page */
114 $smarty->assign("LDIFError",TRUE);
115 $smarty->assign("para","");
116 }else{
118 // Export a single LDAP entry
119 if(isset($_POST['sfrmgetsingle']))
120 {
121 $smarty->assign("para","?ivbb=2&d=".base64_encode($_POST['single'])."&n=".base64_encode($_POST['selfull']));
122 }
123 elseif(isset($_POST['sfrmgetfull']))
124 {
125 $smarty->assign("para","?ivbb=3&dn=".base64_encode($_POST['selfull']));
126 }
127 elseif(isset($_POST['sfrmgetivbb']))
128 {
129 $smarty->assign("para","?ivbb=4&dn=".base64_encode($_POST['selivbb']));
130 }
131 }
133 /* Show main page */
134 return ($smarty->fetch (get_template_path('contentexportxls.tpl', TRUE)));
135 }
137 }
140 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
141 ?>