Code

Updated password change for csvimport
[gosa.git] / 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     var $base ="";
17     var $baseSelector ="";
19     function xlsexport (&$config, $dn= NULL)
20     {
21         /* Include config object */
22         $this->initTime = microtime(TRUE);
23         $this->config= &$config;
25         $this->ui = get_userinfo();
27         $this->base = $this->config->current['BASE'];
28         $this->baseSelector= new baseSelector($this->config->idepartments, $this->base);
29         $this->baseSelector->setSubmitButton(false);
30         $this->baseSelector->setHeight(300);
31         $this->baseSelector->update(true);
32         stats::log('plugin', $class = get_class($this), $category = array($this->acl_category),  $action = 'open',
33                 $amount = 1, $duration = (microtime(TRUE) - $this->initTime));
35     }
37     function execute()
38     {
39         /* Call parent execute */
40         plugin::execute();
42         /* Log view */
43         if(!$this->view_logged){
44             $this->view_logged = TRUE;
45             new log("view","all/".get_class($this),$this->dn);
46         }
48         $dn = $this->config->current['BASE'];
50         /* Set government mode */
51         $smarty= get_smarty();
52         $smarty->assign("type",FALSE);
53         $smarty->assign("depselectivbb","");
55         if (!$this->baseSelector->update()) {
56             msg_dialog::display(_("Error"), msgPool::permMove(), ERROR_DIALOG);
57         }
58         if ($this->base != $this->baseSelector->getBase()) {
59             $this->base= $this->baseSelector->getBase();
60             $this->is_modified= TRUE;
61         }
63         /* Check permissions for export */
64         // fill in old vars in the Export form
65         if((isset($_POST['single']))&&(isset($_POST['sfrmgetsingle']))){
66             $smarty->assign("single",set_post(get_post('single')));
67             $smarty->assign("type",set_post("single"));
68             $a=get_post('single');
69             $b=$this->base;
71         }
72         if(isset($_POST['sfrmgetfull'])){
73             $smarty->assign("type","full");
74             $dn = $this->base;
75         } else {
76             $smarty->assign("depselectfull", "");
77         }
78         if((isset($_POST['selivbb']))&&(isset($_POST['sfrmgetivbb']))){
79             $smarty->assign("depselectivbb",set_post(get_post('selivbb')));
80             $smarty->assign("type","ivbb");
81             $dn = get_post('selivbb');
82         } else {
83             $smarty->assign("depselectivbb", "");
84         }
86         // Set values for optionlist in form
87         $bases      = array();
88         $acl_bases  = $this->ui->get_module_departments("ldapmanager");
89         foreach($this->config->idepartments as $base_dn => $name){
90             if(in_array_ics($base_dn,$acl_bases)){
91                 $bases[$base_dn] = $name;
92             }
93         }
94         $smarty->assign("deplist", $bases);
95         $smarty->assign("choicelist",set_post(array( get_people_ou()             =>"users" ,
96                         get_groups_ou()             =>"groups" ,
97                         get_ou("systemManagement", "systemRDN")         =>"computers",
98                         get_ou("servgeneric", "serverRDN")          =>"servers",
99                         "dc=addressbook,"           =>"addressbook")));
101         // Get the LDAP link, to generate the Export
102         $ldap = $this->config->get_ldap_link();
104         $smarty->assign ("govmode", $this->config->get_cfg_value("core","honourIvbbAttributes"));
105         $smarty->assign("LDIFError",FALSE);
107         if(isset($dn))
108         {
109             if(!($ldap->dn_exists($dn) && $dn != "")){
110                 $smarty->assign("LDIFError",TRUE);
111                 msg_dialog::display(_("Error"), _("Cannot export selected entries!"), ERROR_DIALOG);
112             }
113         }
115         /* check alcs for given dn */
116         $acls ="";
117         if(isset($dn)){
118             $acls = $this->ui->get_permissions($dn,"ldapmanager/ldif");
119         }
121         if(!preg_match("/r/",$acls) && (isset($_POST['sfrmgetsingle']) || isset($_POST['sfrmgetfull']) || isset($_POST['sfrmgetivbb']))){
123             /* Show error msg */      
124             msg_dialog::display(_("Permission error"), sprintf(_("You have no permission to export %s!"), bold(LDAP::fix($dn))), ERROR_DIALOG);
126             /* Show main page */
127             $smarty->assign("LDIFError",TRUE);
128             $smarty->assign("para","");
129         }else{
131             // Export a single LDAP entry
132             if(isset($_POST['sfrmgetsingle']))
133             {
134                 $smarty->assign("para","?ivbb=2&amp;d=".base64_encode(get_post('single'))."&n=".base64_encode($this->base));    
135             }
136             elseif(isset($_POST['sfrmgetfull']))
137             {
138                 $smarty->assign("para","?ivbb=3&amp;dn=".base64_encode($this->base));
139             }
140             elseif(isset($_POST['sfrmgetivbb']))
141             {
142                 $smarty->assign("para","?ivbb=4&amp;dn=".base64_encode(get_post('selivbb')));
143             }
144         }
146         $smarty->assign("base", $this->baseSelector->render());
147         return ($smarty->fetch (get_template_path('contentexportxls.tpl', TRUE)));
148     }
153 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
154 ?>