1 <?php
3 class ldifexport extends plugin
4 {
5 /* Definitions */
6 var $plHeadline= "CSV import";
7 var $plDescription= "This does something";
9 /* attribute list for save action */
10 var $attributes= array();
11 var $objectclasses= array();
12 var $view_logged = FALSE;
14 var $base;
16 function ldifexport (&$config, $dn= NULL)
17 {
18 /* Include config object */
19 $this->config= &$config;
20 $this->ui = get_userinfo();
22 $this->baseSelector= new baseSelector($this->config->idepartments, $this->config->current['BASE']);
23 $this->baseSelector->setSubmitButton(false);
24 $this->baseSelector->setHeight(300);
25 $this->baseSelector->update(true);
27 }
29 function execute()
30 {
31 /* Call parent execute */
32 plugin::execute();
34 /* Log view */
35 if(!$this->view_logged){
36 $this->view_logged = TRUE;
37 new log("view","all/".get_class($this),$this->dn);
38 }
40 // Update baseSelector
41 if (!$this->baseSelector->update()) {
42 msg_dialog::display(_("Error"), msgPool::permMove(), ERROR_DIALOG);
43 }
44 if ($this->base != $this->baseSelector->getBase()) {
45 $this->base= $this->baseSelector->getBase();
46 $this->is_modified= TRUE;
47 }
50 // Assign smarty values
51 $smarty= get_smarty();
52 $smarty->assign("usePrototype","true");
53 $smarty->assign("single","");
54 $smarty->assign("base", $this->baseSelector->render());
56 // fill in old vars in the Export form
57 if(isset($_POST['single'])) $smarty->assign("single",$_POST['single']);
59 // Get the LDAP link, to generate the Export
60 $ldap = $this->config->get_ldap_link();
61 $dn = "";
62 if(isset($_POST['sfrmgetsingle']))
63 {
64 $dn = $_POST['single'];
65 $scope= "base";
66 $acls = $this->ui->get_permissions($dn,"ldapmanager/ldif");
67 $name = "entryExport.ldif";
68 if(!$ldap->dn_exists($dn)){
69 msg_dialog::display(_("Ldap error"),
70 sprintf(_("No such object '%s'!"),bold(LDAP::fix($dn))),
71 ERROR_DIALOG);
72 $dn ="";
73 }
75 }elseif(isset($_POST['sfrmgetfull'])){
76 $dn = $this->base;
77 $scope= "sub";
78 $acls = $this->ui->get_permissions($dn,"ldapmanager/ldif");
79 $name = "fullExport.ldif";
80 }
82 if(!empty($dn)){
83 // Check permissions before sending the output
84 if(!preg_match("/r/",$acls)){
85 msg_dialog::display(_("Permission error"),
86 sprintf(_("You have no permission to export '%s'!"),LDAP::fix($dn)),
87 ERROR_DIALOG);
88 }else{
89 $data = $ldap->generateLdif(LDAP::fix($dn), 'objectClass=*',array(),$scope);
90 send_binary_content($data,$name);
91 }
92 }
94 // Show the main form
95 return ($smarty->fetch (get_template_path('contentexport.tpl', TRUE)));
96 }
97 }
100 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
101 ?>