1 <?php
3 class xlsexport extends plugin
4 {
5 /* Definitions */
6 var $plHeadline= "XLS import";
7 var $plDescription= "This does something";
8 var $access= "";
10 /* attribute list for save action */
11 var $attributes= array();
12 var $objectclasses= array();
13 var $ui;
14 var $view_logged = FALSE;
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 /* Log view */
30 if(!$this->view_logged){
31 $this->view_logged = TRUE;
32 new log("view","all/".get_class($this),$this->dn);
33 }
35 $dn = $this->config->current['BASE'];
37 /* Set government mode */
38 $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 get_groups_ou() =>"groups" ,
79 get_ou('systemsou') =>"computers",
80 get_ou('serverou') =>"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 msg_dialog::display(_("Error"), _("Cannot export selected entries!"), ERROR_DIALOG);
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) && (isset($_POST['sfrmgetsingle']) || isset($_POST['sfrmgetfull']) || isset($_POST['sfrmgetivbb']))){
110 /* Show error msg */
111 msg_dialog::display(_("Permission error"), sprintf(_("You have no permission to export '%s'!"),@LDAP::fix($dn)), ERROR_DIALOG);
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 ?>