<?php
/* +----------------------------------------------------------------------+
| Netautor Professional Application Server |
+----------------------------------------------------------------------+
| Copyright (C) 1998-2005 digiconcept GmbH. <www.digiconcept.net> |
+----------------------------------------------------------------------+
| This file is subject to license, that is bundled with this package |
| in the file LICENSE.TXT, and is available at through the |
| world-wide-web at http://www.netautor.com/license/ |
| |
| If you did not receive a copy of the license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| hide@address.com so we can mail you a copy. |
+----------------------------------------------------------------------+
| Authors: Stefan Rottensteiner <hide@address.com> |
| Marek Kadziela <hide@address.com> |
| Gregor Wollner |
| Christian Unger |
| Helli Kleinhans |
+----------------------------------------------------------------------+
| @version $Revision: 1.17 $ |
+----------------------------------------------------------------------+*/
/**
* Executive part of the layout manager
* @author Helli Kleinhans
* @author Stefan Rottensteiner
* @author Marek Kadziela
*/
require_once('../../include/init.inc');
if(!$GLOBALS['USER']->check_feature('Admin') && !$GLOBALS['USER']->check_feature('ac_layout'))
{
$GLOBALS['USER']->login_call();
}
includeNaPro('string,array,form,mdb,cache');
/**
* Hilfsfunktion
*/
function draw_recursiv(&$elements,$me_id=0,$area_id='',$level=0,&$elements_string)
{
$result='';
if($level<=2) $elements_string='';
if (empty($area_id)) $area_id = $elements['me_id'][ $elements['me_base'] ];
if (empty($elements['me_me_id'][$area_id])) return '';
foreach($elements['me_me_id'][$area_id] as $index => $field_name)
{
if (empty($area_id)) continue;
$field_id= $elements['me_id'][$field_name];
$opt_text = str_repeat(' ',$level*2).$field_name;
if ($elements['me_multiple'][$field_name]) $opt_text.=' (M)';
if ($field_id==$me_id) $selected='selected="selected"'; else $selected='';
if (!empty($elements['me_content'][$field_name])) // Kein Bereich
{
$result.='<option '.$selected.' value="<#'.$field_name.'#>" >'.$opt_text.'</option>';
$elements_string.='<#'.$field_name.'#>';
echo $level;
}
else // Bereich
{
$elements_string='';
$buffer =draw_recursiv($elements,$me_id,$field_id,$level+2,$elements_string);
$result.='<option value="<#'.$field_name.'#>'.$elements_string.'<#/'.$field_name.'#>">'.$opt_text.'</option>';
$result.=$buffer;
$elements_string='<#'.$field_name.'#>'.$elements_string.'<#/'.$field_name.'#>';
}
}
if($level<=2) $elements_string='';
return $result;
}
/**
* Hilfsfunktion
*/
function draw_db_struktur(&$SQL,$table_id=0)
{
$result = '';
$structure = ( empty($table_id) ? mdb_list_dbs($SQL,true) : mdb_get_db($SQL,$table_id,true) );
if (!empty($structure) && is_array($structure))
{
foreach($structure as $table_index => $table_data)
{
$result.='<option value='."'mn_naid=".$table_data['mn_naid']."'".'>'.strtoupper($table_data['mn_name']).'</option>';
if (empty($table_data['me_elements']))
{
$result.='<option> -- No elements defined --</option>';
// Noch keine Elemente in der Tabelle
}
else
{
$result.=draw_recursiv($table_data['me_elements'],0,'',1);
}
if (count($structure) > 1) $result.='<option>'.(str_repeat('-',30)).'</option>';
}
}
else
{
}
echo($result);
}
function list_mlay_versions($id,&$DC_ENV,&$SQL)
{
includeNaPro('log');
if(empty($id)) return '';
$log_params = array(
'event_id' => $id,
'event_type' => 'layout'
);
$res = list_event_log($log_params,$DC_ENV,$SQL);
if($res)
{
$result = '';
$result_user = array();
foreach($res as $row => $val)
{
if(empty($result_user[ $val['log_event_user_id'] ]))
{
$res_user = $SQL->select("SELECT user_name FROM users WHERE user_id = {$val['log_event_user_id']}",0,1,2);
if($res_user) $result_user[ $val['log_event_user_id'] ] = $res_user[0]['user_name'];
}
$result .= '<br /><a href="layoutmgr.php?log_action=restore&log_id='.$val['log_id'].'&mlay_id='.$val['log_event_id'].'" class="text">Version: '.$val['log_event_version'].', Datum: '.date("Y.m.d H:i.s",$val['log_event_date']).', User: '.$result_user[ $val['log_event_user_id'] ].'</a><br />'."\n";
}
return $result;
}
else
{
return '<span class="text">'.$GLOBALS['LOCALE']->gettext('msg_versions_not_found').'</span>';
}
}
if (!($npf_functions = cache_read($GLOBALS['DC_ENV']->cachepath.'npf_functions.dat')))
{
includeNaPro('na_functions');
$okay = $result= naf_generate_def_file($GLOBALS['DC_ENV']);
}
if (empty($mlay_id)) $mlay_id=0;
if (!empty($go_mlay_id2) && !empty($mlay_id2))
{
$mlay_id =$mlay_id2;
$mlay_mn_naid ='';
$status ='';
}
//Einstweilen den Speicherort auf die Datenbank festlegen , später kann wieder eine Auswahl erfolgen
$save_location='DB';
$page = (empty($page)? 'FUNKTIONEN' :$page);
if(!empty($update))
{
$todo = empty($mlay_id) ? 'create' : 'update';
}
else
{
$todo='';
}
includeNapro('queu,mlay');
/* create a new layout object */
$lay = new layout($sql_world);
$QUEU = queu_getDefaultQueu(); /* Create one netautor wide QUEU-object, similiar to $sql_world */
$lay->setQueu($QUEU);
/* Set a default saveToPath */
$lay->setSaveTo($GLOBALS['DC_ENV']->layoutspath.$mlay_id.'.lay');
if($path = $GLOBALS['USER']->get_feature_value('layout_source_path'))
{
$lay->setSourcePath($path);
}
//------------------------------------------------------------------ LÖSCHEN
if(isset($delete))
{
$result = $lay->delete($mlay_id);
$mlay_id= 0;
if($result) // Wenn kein Fehler aufgetreten ist
{
$GLOBALS['DC_ENV']->message[] = $GLOBALS['LOCALE']->gettext('layout_deleted');
$GLOBALS['DC_ENV']->errnr = '132';
$clear ='yes'; // damit auch die Anzeige noch gelöscht wird
}
else // if($sql_world->errnr == 0) // Wenn ein Fehler aufgetreten ist
{
$GLOBALS['DC_ENV']->message[] = $sql_world->errstr.$sql_world->statement;
$GLOBALS['DC_ENV']->errnr = $sql_world;
}
}
//------------------------------------------------------------------ CLEAR
if(isset($clear))
{
$mlay_definition = '';
$mlay_name = '';
$mlay_remark = '';
$mlay_id = '';
$mlay_na_id = '';
$status = '';
$mlay_default = '0';
} // ENDE: if($clear)
//------------------------------------------------------------------ AUSWÄHLEN
if(!empty($mlay_id) && empty($status)) // Wenn ein Layout gewählt
{
$lay->read($mlay_id);
$erg= $lay->getIntoArray();
$mlay_name =$erg[ 'mlay_name' ];
@$mlay_remark =$erg[ 'mlay_remark' ];
$mlay_definition=$erg[ 'mlay_definition' ];
$mlay_mn_naid =$erg[ 'mlay_mn_naid' ];
$mlay_default =(empty($erg[ 'mlay_default' ]) ? '0' : '1' );
$status ='read';
}
if(!empty($_GET['log_action']) && $_GET['log_action'] == 'restore')
{
includeNaPro('log');
$log_params = array(
'log_id' => $_GET['log_id']
);
$mlay_definition = read_event_log($log_params,$DC_ENV,$sql_world);
$mlay_definition = $mlay_definition['log_event_content'];
}
include('layoutmgr.msk');
?>