Code

Created trunk inside of 2.6-lhm
[gosa.git] / trunk / gosa-plugins / ldapmanager / addons / ldapmanager / class_exportxls.inc
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","");
41     
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('systemRDN')         =>"computers",
80                                         get_ou('serverRDN')          =>"servers",
81                                         "dc=addressbook,"           =>"addressbook"));
83     // Get the LDAP link, to generate the Export
84     $ldap = $this->config->get_ldap_link();
86     $smarty->assign ("govmode", $this->config->get_cfg_value("honourIvbbAttributes"));
87     $smarty->assign("LDIFError",FALSE);
89     if(isset($dn))
90     {
91       if(!($ldap->dn_exists($dn) && $dn != "")){
92         $smarty->assign("LDIFError",TRUE);
93         msg_dialog::display(_("Error"), _("Cannot export selected entries!"), ERROR_DIALOG);
94       }
95     }
96    
97     /* check alcs for given dn */
98     $acls ="";
99     if(isset($dn)){
100       $acls = $this->ui->get_permissions($dn,"all/all");
101     }
102  
103     if(!preg_match("/r/",$acls) && (isset($_POST['sfrmgetsingle']) || isset($_POST['sfrmgetfull']) || isset($_POST['sfrmgetivbb']))){
105       /* Show error msg */      
106       msg_dialog::display(_("Permission error"), sprintf(_("You have no permission to export '%s'!"),LDAP::fix($dn)), ERROR_DIALOG);
108       /* Show main page */
109       $smarty->assign("LDIFError",TRUE);
110       $smarty->assign("para","");
111     }else{
113       // Export a single LDAP entry
114       if(isset($_POST['sfrmgetsingle']))
115       {
116         $smarty->assign("para","?ivbb=2&amp;d=".base64_encode($_POST['single'])."&n=".base64_encode($_POST['selfull']));        
117       }
118       elseif(isset($_POST['sfrmgetfull']))
119       {
120         $smarty->assign("para","?ivbb=3&amp;dn=".base64_encode($_POST['selfull']));
121       }
122       elseif(isset($_POST['sfrmgetivbb']))
123       {
124         $smarty->assign("para","?ivbb=4&amp;dn=".base64_encode($_POST['selivbb']));
125       }
126     }
128     /* Show main page */
129     return ($smarty->fetch (get_template_path('contentexportxls.tpl', TRUE)));
130   }
135 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
136 ?>