<?php
/***************************************************************************
*
* ControlBar.php
* -------------------
*
* begin : Friday, Jul 5, 2002
* copyright : (C) 2002 The Kabramps Team
* email : hide@address.com,
* hide@address.com
*
*
*
***************************************************************************/
/***************************************************************************
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* See the GNU General Public License for more details.
* (http://www.gnu.org/licenses/gpl.html)
*
***************************************************************************/
class ControlBar {
var $filter;
var $postfilter;
var $recursive = false;
var $forms;
var $selectedformular;
var $status = false;
var $ldap; //ldap-connection
var $basedn;
function ControlBar( $ldap,
$selection,
$action,
$filter,
$recursive,
$formscombo, // selected form
$basedn
) {
$this->init($ldap,$selection,$action,$filter, $recursive,$formscombo,$basedn);
}
function init($ldap,$selection,$action,$filter,$recursive,$formscombo,$basedn) {
global $config;
global $bind_dn;
global $host;
$this->ldap = $ldap;
$this->recursive = $recursive ? $recursive : 0;
$this->forms = $config->get_host_forms($host, $bind_dn);
$this->selectedformular = $formscombo;
//Prefilter
$formfilter=$config->get_host_form_filter($host,$this->selectedformular);
if ( $filter )
{
$this->postfilter = $filter;
$this->filter = "(&".$formfilter."".$filter.")";
}
else
{
$this->filter = $formfilter;
$emptyfilter = $config->get_host_form_emptyfilter($host,$this->selectedformular);
if ( $emptyfilter != "" )
{
$this->filter = "(&".$emptyfilter."".$formfilter.")";
}
}
$tmpselection = array();
for ( $i=0; $i < count( $selection ); $i++ ) {
if ( $selection[$i] != "" ) {
$tmpselection[]=$selection[$i];
}
}
// BaseDN handling
if ( !$basedn ) {
if ( $config->get_host_form_base($host,$this->selectedformular) ) {
$this->basedn = $config->get_host_form_base($host,$this->selectedformular).",";
}
$this->basedn .= $config->get_host_ldapbase($host);
} else {
$this->basedn = $basedn;
}
global $HTTP_SESSION_VARS; //?? shoud be obmitted by constructor
switch ( $action ) {
case "clipboardinsert":
$HTTP_SESSION_VARS['clipboard']=$tmpselection;
$this->status = count($tmpselection)." ".gettext("element(s) inserted into clipboard.");
break;
case "clipboardappend":
$HTTP_SESSION_VARS['clipboard']=array_merge($HTTP_SESSION_VARS['clipboard'],$tmpselection);
$this->status = count($tmpselection)." ".gettext("element(s) added to clipboard.");
break;
case "delete":
$this->status = $this->ldap->delete_entries($tmpselection)." of ".count($tmpselection)." ".gettext("element(s) deleted.");
break;
case "paste":
$this->status = $this->ldap->copy($HTTP_SESSION_VARS['clipboard'],$this->basedn)." of ".count($HTTP_SESSION_VARS['clipboard'])." ".gettext("element(s) pasted.");
break;
case "move":
$this->status = $this->ldap->move($HTTP_SESSION_VARS['clipboard'],$this->basedn)." of ".count($HTTP_SESSION_VARS['clipboard'])." ".gettext("element(s) moved.");
break;
case 'import':
$this->status = 'not yet implemented';
break;
case 'export':
$this->status = 'not yet implemented';
break;
case "logout":
header ("Location: logout.php?logoutmessage=".gettext("Thanks for using LDAPted"));
break;
case "changeform":
$this->basedn = null;
if ( $config->get_host_form_base($host,$this->selectedformular) ) {
$this->basedn = $config->get_host_form_base($host,$this->selectedformular).",";
}
$this->basedn .= $config->get_host_ldapbase($host);
break;
default:
//die("nicht here");
break;
}
}
function get_view() {
global $host;
global $language;
global $config;
global $options;
$controltmpls = new TPLInterface();
// newEntry handling
$newEntryParam = "basedn=".$this->basedn."&form=".$this->selectedformular;
// Generates the Combobox for all available form for a certain user
$controltmpls->assign(array("BASEDN" => $this->basedn,
"FORMSLABEL" => gettext("form"),
'forms' => $this->forms,
"NEWENTRYPARAM" => $newEntryParam,
"FILTERLABEL" => gettext("filter"),
"FILTERTITLE" => gettext("Press a key to unset filter"),
"FILTERVALUE" => $this->postfilter,
"SELECTEDFORM" => $this->selectedformular,
"RECURSIVE" => $this->recursive,
"RECURSIVELABEL" => gettext("recrsv"),
"CONFIRM" => gettext('Please confirm deletion.'),
"T_NEWENTRY" => gettext("new entry"),
"T_REFRESH" => gettext("refresh"),
"T_CCLIP" => gettext("copy to clipboard"),
"T_ACLIP" => gettext("append to clipboard"),
"T_PASTE" => gettext("paste"),
"T_MOVE" => gettext("move"),
"T_REF" => gettext("referenz"),
'T_IMPORT' => gettext('import'),
'T_EXPORT' => gettext('export'),
"T_DELETE" => gettext("Delete selected entries"),
"T_LOGOUT" => gettext("logout user:")." ".$this->ldap->get_binddn(),
));
return $controltmpls->fetch("controlbar.tpl");
}
function get_filter() {
return $this->filter;
}
function get_baseDN() {
return $this->basedn;
}
function is_recursive() {
return $this->recursive;
}
function get_selected_formular() {
global $host;
global $config;
return $config->get_host_form_file($host,$this->selectedformular);
}
function get_selected_formular_id() {
return $this->selectedformular;
}
function get_status()
{
return $this->status ? $this->status : 'READY.';
}
}
?>