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 new log("view","all/".get_class($this),$this->dn);
34 }
36 $dn = $this->config->current['BASE'];
38 /* Set government mode */
39 $smarty= get_smarty();
40 $smarty->assign("type",FALSE);
41 $smarty->assign("depselectivbb","");
43 if(!isset($_POST['selfull'])) $_POST['selfull'] = "Somehow not posted";
45 /* Check permissions for export */
46 // fill in old vars in the Export form
47 if((isset($_POST['single']))&&(isset($_POST['sfrmgetsingle']))){
48 $smarty->assign("single",$_POST['single']);
49 $smarty->assign("type","single");
50 $a=$_POST['single'];
51 $b=$_POST['selfull'];
53 }
54 if((isset($_POST['selfull']))&&(isset($_POST['sfrmgetfull']))){
55 $smarty->assign("depselectfull",$_POST['selfull']);
56 $smarty->assign("type","full");
57 $dn = $_POST['selfull'];
58 } else {
59 $smarty->assign("depselectfull", "");
60 }
61 if((isset($_POST['selivbb']))&&(isset($_POST['sfrmgetivbb']))){
62 $smarty->assign("depselectivbb",$_POST['selivbb']);
63 $smarty->assign("type","ivbb");
64 $dn = $_POST['selivbb'];
65 } else {
66 $smarty->assign("depselectivbb", "");
67 }
69 // Set values for optionlist in form
70 $bases = array();
71 $acl_bases = $this->ui->get_module_departments("all");
72 foreach($this->config->idepartments as $base_dn => $name){
73 if(in_array_ics($base_dn,$acl_bases)){
74 $bases[$base_dn] = $name;
75 }
76 }
77 $smarty->assign("deplist", $bases);
78 $smarty->assign("choicelist",array( get_people_ou() =>"users" ,
79 get_groups_ou() =>"groups" ,
80 get_ou('systemsou') =>"computers",
81 get_ou('serverou') =>"servers",
82 "dc=addressbook," =>"addressbook"));
84 // Get the LDAP link, to generate the Export
85 $ldap = $this->config->get_ldap_link();
87 if ($this->config->current['GOVERNMENTMODE'] == 'true'){
88 $smarty->assign ("govmode", "true");
89 } else {
90 $smarty->assign ("govmode", "false");
91 }
93 $smarty->assign("LDIFError",FALSE);
95 if(isset($dn))
96 {
97 if(!($ldap->dn_exists($dn) && $dn != "")){
98 $smarty->assign("LDIFError",TRUE);
99 print_red (_("Error while exporting the requested entries!"));
100 }
101 }
103 /* check alcs for given dn */
104 $acls ="";
105 if(isset($dn)){
106 $acls = $this->ui->get_permissions($dn,"all/all");
107 }
109 if(!preg_match("/r/",$acls) && (isset($_POST['sfrmgetsingle']) || isset($_POST['sfrmgetfull']) || isset($_POST['sfrmgetivbb']))){
111 /* Show error msg */
112 print_red(sprintf(_("You are not allowed to export the given ldap entry (%s)"),@LDAP::fix($dn)));
114 /* Show main page */
115 $smarty->assign("LDIFError",TRUE);
116 $smarty->assign("para","");
117 }else{
119 // Export a single LDAP entry
120 if(isset($_POST['sfrmgetsingle']))
121 {
122 $smarty->assign("para","?ivbb=2&d=".base64_encode($_POST['single'])."&n=".base64_encode($_POST['selfull']));
123 }
124 elseif(isset($_POST['sfrmgetfull']))
125 {
126 $smarty->assign("para","?ivbb=3&dn=".base64_encode($_POST['selfull']));
127 }
128 elseif(isset($_POST['sfrmgetivbb']))
129 {
130 $smarty->assign("para","?ivbb=4&dn=".base64_encode($_POST['selivbb']));
131 }
132 }
134 /* Show main page */
135 return ($smarty->fetch (get_template_path('contentexportxls.tpl', TRUE)));
136 }
138 }
141 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
142 ?>