<?php
/***************************************************************************
*
* XMLinterface.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)
*
***************************************************************************/
require_once('includes/XMLDocument.php');
class XMLinterface extends XMLDocument {
var $error;
var $layoutOptions;
var $options;
function XMLinterface($filename) {
$this->init($filename);
//if ( ! $error ) {
$this->layoutOptions = $this->get_layout_options();
//} else {
// $this->error=$error;
//}
}
function get_basedn() {
global $ldap_base;
if (!$this->options['basedn']) {
$this->options['basedn'] = $ldap_base;
}
return $this->options['basedn'];
}
function get_attribute_description( $attribute, $lang="en" ) {
$return =
$this->get_xml_content("/formular/attribute[@name=\"".$attribute."\"]/description[@lang=\"".$lang."\"]",0,1);
return $return[0];
}
function get_attributes() {
return
$this->get_xml_attributes("/formular/attribute","name");
}
function get_identifierAttributes() {
return
$this->get_xml_attributes("/formular/attribute[@identifier=\"true\"]","name");
}
function get_searchAttributes() {
return
$this->get_xml_attributes("/formular/attribute[@search=\"true\"]","name");
}
function get_label($attribute,$lang="en") {
$return =
$this->get_xml_content("/formular/attribute[@name=\"".$attribute."\"]/label[@lang=\"".$lang."\"]",0,1);
return $return[0];
}
function get_type($attribute) {
$return =
$this->get_xml_attributes("/formular/attribute[@name=\"".$attribute."\"]","type");
return $return[0];
}
function get_selection_type($attribute) {
$return =
$this->get_xml_attributes("/formular/attribute[@name=\"".$attribute."\"]/selection","sourcetype");
return $return[0];
}
function get_selection_fields($attribute) {
return $this->get_xml_content_by_key("/formular/attribute[@name=\"".$attribute."\"]/selection/field","name");
}
function get_layout_options() {
if (!$this->layoutOption) {
$this->layoutOption = $this->get_xml_content_by_key("/formular/layout/option","name");
}
return $this->layoutOption;
}
function get_options()
{
if (!$this->option)
{
$this->option = $this->get_xml_content_by_key('/formular/options/option','name');
}
return $this->option;
}
function get_attribute_options($attribute) {
return $this->get_xml_content_by_key("/formular/attribute[@name=\"".$attribute."\"]/option","name");
}
function get_attribute_addon_options($attribute) {
return $this->get_xml_content_by_key("/formular/attribute[@name=\"".$attribute."\"]/addon/option","name");
}
function get_value_fields($attribute) {
return $this->get_xml_content_by_key("/formular/attribute[@name=\"".$attribute."\"]/value/field","name");
}
function get_filter() {
if (!$this->options['filter']) {
$this->options['filter'] = "(objectClass=*)";
}
return $this->options['filter'];
}
function get_name() {
$return = $this->get_xml_attributes("/formular","name");
return $return[0];
}
function get_objectClasses()
{
$return = array();
$temp = array_unique( $this->get_xml_attributes('/formular/attribute','objectClass') );
//re-indexing the array
foreach( $temp as $item)
{
$return[] = $item;
}
return $return;
}
function notify() {
$notify = $this->get_xml_attributes("/formular/notify","dn");
if ( $notify[0] )
return true;
else
return false;
}
function get_notify_dn() {
$return = $this->get_xml_attributes("/formular/notify","dn");
return $return[0];
}
function get_services() {
return $this->get_xml_attributes("/formular/notify/service","name");
}
function get_service_mode($service) {
$return = $this->get_xml_attributes("/formular/notify/service[@name=\"".$service."\"]","mode");
return $return[0];
}
function get_service_state($service) {
$return = $this->get_xml_attributes("/formular/notify/service[@name=\"".$service."\"]","state");
return $return[0];
}
function get_service_starttime($service) {
$starttime = array();
$values = array('year','month','day','hour','minute','second');
for ( $i=0; $i<count($values);$i++ ) {
$tmp = $this->get_xml_attributes("/formular/notify/service[@name=\"".$service."\"]/starttime/".$values[$i],"method");
$starttime[$values[$i]]['method'] = $tmp[0];
$tmp = $this->get_xml_content("/formular/notify/service[@name=\"".$service."\"]/starttime/".$values[$i],0,1);
$starttime[$values[$i]]['value'] = $tmp[0];
}
return $starttime;
}
function get_service_attributes($service) {
$return = $this->get_xml_attributes("/formular/notify/service[@name=\"".$service."\"]/attribute",array("name","value"));
return $return;
}
}
?>