added getPDFEntries in sambaSamAccount;

first step of pdf structure editor implementet; there is no functionallity at this point. Just a litte bit of graphic.
This commit is contained in:
duergner 2004-05-30 13:43:42 +00:00
parent e1f04d8543
commit c1735aecc6
8 changed files with 665 additions and 20 deletions

View File

@ -1,6 +1,6 @@
<settings type="pdf">
<pdf type="user">
<text name="User" />
<text name="user" />
<section name="Personal User Infos">
<entry name="inetOrgPerson_title" />
<entry name="inetOrgPerson_givenName" />
@ -41,7 +41,6 @@
<section name="_posixGroup_cn">
<entry name="posixGroup_description" />
<entry name="posixGroup_gidNumber" />
<entry name="Domain" />
<entry name="main_dn" />
<entry name="posixGroup_memberUid" />
</section>

View File

@ -825,7 +825,7 @@ class Config {
}
// returns text for user PDF files
function get_pdftext($name = "User") {
function get_pdftext($name = "user") {
if ($this->pdftext) return $this->pdftext;
else return "";
}

View File

@ -198,6 +198,17 @@ function getHelp($module,$helpID) {
return call_user_func(array($module, "get_help"), $helpID);
}
// $scope = user, group, host, ...
function getAvailablePDFFields($scope) {
// create new account container if needed
if (! isset($_SESSION["profile_account_$scope"])) {
$_SESSION["profile_account_$scope"] = new accountContainer($scope, "profile_account_$scope");
$_SESSION["profile_account_$scope"]->new_account();
}
// get options
return $_SESSION["profile_account_$scope"]->getAvailablePDFFields();
}
class accountContainer {
// Constructor
@ -988,5 +999,20 @@ class accountContainer {
}
return $return;
}
// Dummy implementation
function getAvailablePDFFields() {
$return = array();
foreach($this->module as $key => $value) {
$fields = array();
if(is_array($value->attributes)) {
foreach($value->attributes as $field_key => $field_value) {
$fields[] = $field_key;
}
}
$return[$key] = $fields;
}
return $return;
}
}
?>

View File

@ -715,13 +715,19 @@ class sambaSamAccount {
return array();
}
function get_pdfEntries($account_type = "User") {
return array( 'sambaDomainName' => array('<block><key>' . _('Domain') . '</key><value>' . $this->attributes['sambaDomainName'][0] . '</value></block>'),
'sambaHomeDrive' => array('<block><key>' . _('Home drive') . '</key><value>' . $this->attributes['sambaHomeDrive'][0] . '<value></<block>'),
'sambaHomePath' => array('<block><key>' . _('Home path') . '</key><value>' . $this->attributes['sambaHomePath'][0] . '</value></block>'),
'sambaProfilePath' => array('<block><key>' . _('Profile path') . '</key><value>' . $this->attributes['sambaProfilePath'][0] . '</value></block>'),
'sambaLogonScript' => array('<block><key>' . _('Login script') . '</key><value>' . $this->attributes['sambaScriptPath'][0] . '</value></block>'),
'sambaUserWorkstations' => array('<block><key>' . _('Samba workstations') . '</key><value>' . $this->attributes['sambaUserWorkstations'][0] . '</value></block>'));
function get_pdfEntries($account_type = "user") {
echo "sambaSamAccount:\n";
print_r($this->attributes);
return array( 'sambaSamAccount_displayName' => array('<block><key>' . _('Display name') . '</key><value' . $this->attributes['displayName'][0] . '</value></block>'),
'sambaSamAccount_uid' => array('<block><key>' . _('Username') . '</key><value>' . $this->attributes['uid'][0] . '</value></block>'),
'sambaSamAccount_sambaHomePath' => array('<block><key>' . _('Home path') . '</key><value>' . $this->attributes['sambaHomeDrive'][0] . '</value></block>'),
'sambaSamAccount_sambaHomeDrive' => array('<block><key>' . _('Home drive') . '</key><value>' . $this->attributes['sambaHomePath'][0] . '</value></block>'),
'sambaSamAccount_sambaLogonScript' => array('<block><key>' . _('Logon script') . '</key><value>' . $this->attributes['sambaLogonScript'][0] . '</value></block>'),
'sambaSamAccount_sambaProfilePath' => array('<block><key>' . _('Profile path') . '</key><value>' . $this->attributes['sambaProfilePath'][0] . '</value></block>'),
'sambaSamAccount_sambaUserWorkstations' => array('<block><key>' . _('Samba workstations') . '</key><value>' . $this->attributes['sambaUserWorkstations'][0] . '</value></block>'),
'sambaSamAccount_sambaDomainName' => array('<block><key>' . _('Domain') . '</key><value>' . $this->attributes['sambaDomainName'][0] . '</value></block>'),
'sambaSamAccount_description' => array('<block><key>' . _('Description') . '</key><value>' . $this->attributes['description'][0] . '</value></block>'),
'sambaSamAccount_sambaPrimaryGroupSID' => array('<block><key>' . _('Windows group') . '</key><value>' . $this->attributes['sambaPrimaryGroupSID'][0] . '</value></block>'));
}
}

58
lam/lib/pdfstruct.inc Normal file
View File

@ -0,0 +1,58 @@
<?php
/*
$Id$
This code is part of LDAP Account Manager (http://www.sourceforge.net/projects/lam)
Copyright (C) 2003 Roland Gruber
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.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
include_once("config.inc");
include_once("ldap.inc");
function getPDFStructureDefinitions($scope = "user") {
$return = array();
$dirHandle = opendir($_SESSION['lampath'] . '/config/pdf/' . $scope . '/');
while($file = readdir($dirHandle)) {
if($file != '.' && $file != '..' && $file != 'default.xml') {
array_push($return, substr($file,0,strlen($file)-4));
}
}
sort($return);
return $return;
}
function loadPDFStructureDefinitions($scope='user', $definition='default.xml') {
$parser = new xmlParser();
$xml = $parser->parse($_SESSION['lampath'] . 'config/pdf/' . $scope . '/' . $definition);
$border = array();
$structure = array();
$pdf_entries = $xml[1]['PDF'];
$border[$current] = array();
while(($index = current($pdf_entries)) != null) {
if($xml[0][$index]['attributes']['TYPE'] == $scope) {
$border['start'] = $index;
next($pdf_entries);
$border['end'] = current($pdf_entries);
}
next($pdf_entries);
}
$structure = array_slice($xml[0],$border['start'] + 1,$border['end'] - ($border['start'] + 1));
return $structure;
}
?>

View File

@ -45,20 +45,24 @@ if ($_SESSION['config']->get_Hostsuffix() != "") $lists++;
<body>
<table border=0 width="100%">
<tr>
<td width="100" align="left"><a href="./profedit/profilemain.php" target="mainpart"><?php echo _("Profile Editor"); ?></a></td>
<td width="200">
<table width="200">
<tr>
<td width="100" align="left"><a href="./profedit/profilemain.php" target="mainpart"><?php echo _("Profile Editor"); ?></a></td>
<td width="100" align="left"><a href="./pdfedit/pdfmain.php" target="mainpart"><?php echo _("PDF editor") ?></a></td>
</tr>
<tr>
<td align="left"><a href="ou_edit.php" target="mainpart"><?php echo _("OU-Editor") ?></a></td>
<td align="left"><a href="masscreate.php" target="mainpart"><?php echo _("File Upload") ?></a></td>
</tr>
</table>
</td>
<?php
echo "<td rowspan=3 colspan=$lists align=\"center\">\n";
echo "<td colspan=$lists align=\"center\">\n";
?>
<a href="http://lam.sf.net" target="new_window"><img src="../graphics/banner.jpg" border=1 alt="LDAP Account Manager"></a>
</td>
<td width="100" align="right" height=20><a href="./logout.php" target="_top"><big><b><?php echo _("Logout") ?></b></big></a></td>
</tr>
<tr>
<td align="left"><a href="ou_edit.php" target="mainpart"><?php echo _("OU-Editor") ?></a></td>
<td rowspan=2></td>
</tr>
<tr>
<td align="left"><a href="masscreate.php" target="mainpart"><?php echo _("File Upload") ?></a></td>
<td width="200" align="right" height=20><a href="./logout.php" target="_top"><big><b><?php echo _("Logout") ?></b></big></a></td>
</tr>
<tr>
<?php

View File

@ -0,0 +1,252 @@
<?php
/*
$Id$
This code is part of LDAP Account Manager (http://www.sourceforge.net/projects/lam)
Copyright (C) 2003 Roland Gruber
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.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
This is the main window of the pdf structure editor.
*/
include_once("../../lib/pdfstruct.inc");
include_once("../../lib/ldap.inc");
include_once("../../lib/config.inc");
// start session
session_save_path("../../sess");
@session_start();
setlanguage();
// check if user is logged in, if not go to login
if (!$_SESSION['ldap'] || !$_SESSION['ldap']->server()) {
metaRefresh("../login.php");
exit;
}
// check if user has pressed submit or abort button
if ($_POST['forward'] == "yes") {
// on abort go back to main page
if ($_POST['abort']) {
metaRefresh("../lists/listusers.php");
}
// on submit forward to other pdf structure pages
else if($_POST['submit']) {
// create new user pdf structure
if ($_POST['pdf'] == "new_user") {
metaRefresh("pdfpage.php?type=user");
}
// edit user pdf structure
elseif($_POST['pdf'] == "edit_user") {
metaRefresh("pdfpage.php?type=user&amp;edit=" . $_POST['edit_user']);
}
// delete user pdf structure
elseif($_POST['pdf'] == "delete_user") {
metaRefresh("pdfdelete.php?type=user&amp;delete=" . $_POST['delete_user']);
}
// create new group pdf structure
elseif ($_POST['pdf'] == "new_group") {
metaRefresh("pdfpage.php?type=group");
}
// edit group pdf structure
elseif($_POST['pdf'] == "edit_group") {
metaRefresh("pdfpage.php?type=group&amp;edit=" . $_POST['edit_group']);
}
// delete group pdf structure
elseif($_POST['pdf'] == "delete_group") {
metaRefresh("pdfdelete.php?type=group&amp;delete=" . $_POST['delete_group']);
}
// create new host pdf structure
elseif ($_POST['pdf'] == "new_host") {
metaRefresh("pdfpage.php?type=host");
}
// edit host pdf structure
elseif($_POST['pdf'] == "edit_host") {
metaRefresh("pdfpage.php?type=host&amp;edit=" . $_POST['edit_host']);
}
// delete host pdf structure
elseif($_POST['pdf'] == "delete_host") {
metaRefresh("pdfdelete.php?type=host&amp;delete=" . $_POST['delete_host']);
}
}
exit;
}
// Get available user PDF structure definitions
$pdfStructDefs = getPDFStructureDefinitions('user');
$user_pdf = '';
for($i = 0;$i < count($pdfStructDefs); $i++) {
$user_pdf .= '<option value="' . $pdfStructDefs . '.xml">' . $pdfStructDefs[$i] . "</option>\n";
}
// Get available group PDF structure definitions
$pdfStructDefs = getPDFStructureDefinitions('group');
$group_pdf = '';
for($i = 0;$i < count($pdfStructDefs); $i++) {
$group_pdf .= '<option value="' . $pdfStructDefs . '.xml">' . $pdfStructDefs[$i] . "</option>\n";
}
// Get available host PDF structure definitions
$pdfStructDefs = getPDFStructureDefinitions('host');
$host_pdf = '';
for($i = 0;$i < count($pdfStructDefs); $i++) {
$host_pdf .= '<option value="' . $pdfStructDefs . '.xml">' . $pdfStructDefs[$i] . "</option>\n";
}
echo $_SESSION['header'];
?>
<title>LDAP Account Manager</title>
<link rel="stylesheet" type="text/css" href="../../style/layout.css">
</head>
<body>
<p></p>
<form action="pdfmain.php" method="post">
<!-- user pdf structure options -->
<fieldset>
<legend>
<b><?php echo _("User PDF structures"); ?></b>
</legend>
<table border=0>
<!-- new user pdf structure -->
<tr>
<td>
<input type="radio" name="pdf" value="new_user" checked>
</td>
<td colspan=2><?php echo _("Create a new user PDF structure"); ?></td>
</tr>
<!-- edit user pdf structure -->
<tr>
<td>
<input type="radio" name="pdf" value="edit_user">
</td>
<td>
<select name="edit_user" size=1>
<?php echo $user_pdf ?>
</select>
</td>
<td><?php echo _("Edit user PDF structure"); ?></td>
</tr>
<!-- delete user pdf structure -->
<tr>
<td>
<input type="radio" name="pdf" value="delete_user">
</td>
<td>
<select name="delete_user" size=1>
<?php echo $user_pdf ?>
</select>
</td>
<td><?php echo _("Delete user PDF structure"); ?></td>
</tr>
</table>
</fieldset>
<p></p>
<!-- group pdf structure options -->
<fieldset>
<legend>
<b><?php echo _("Group PDF structures"); ?></b>
</legend>
<table border=0>
<!-- new group pdf structure -->
<tr>
<td>
<input type="radio" name="pdf" value="new_group">
</td>
<td colspan=2><?php echo _("Create a new group PDF structure"); ?></td>
</tr>
<!-- edit group pdf structure -->
<tr>
<td>
<input type="radio" name="pdf" value="edit_group">
</td>
<td>
<select name="edit_group" size=1>
<?php echo $group_pdf ?>
</select>
</td>
<td><?php echo _("Edit group PDF structure"); ?></td>
</tr>
<!-- delete group pdf structure -->
<tr>
<td>
<input type="radio" name="pdf" value="delete_group">
</td>
<td>
<select name="delete_group" size=1>
<?php echo $group_pdf ?>
</select>
</td>
<td><?php echo _("Delete group PDF structure"); ?></td>
</tr>
</table>
</fieldset>
<p></p>
<!-- host pdf structure options -->
<fieldset>
<legend>
<b><?php echo _("Host PDF structures"); ?></b>
</legend>
<table border=0>
<!-- new host pdf structure -->
<tr>
<td>
<input type="radio" name="pdf" value="new_host">
</td>
<td colspan=2><?php echo _("Create a new host PDF structure"); ?></td>
</tr>
<!-- edit host pdf structure -->
<tr>
<td>
<input type="radio" name="pdf" value="edit_host">
</td>
<td>
<select name="edit_host" size=1>
<?php echo $host_pdf ?>
</select>
</td>
<td><?php echo _("Edit host PDF structure"); ?></td>
</tr>
<!-- delete host pdf structure -->
<tr>
<td>
<input type="radio" name="pdf" value="delete_host">
</td>
<td>
<select name="delete_host" size=1>
<?php echo $host_pdf ?>
</select>
</td>
<td><?php echo _("Delete host PDF structure"); ?></td>
</tr>
</table>
</fieldset>
<!-- forward is used to check if buttons were pressed -->
<p>
<input type="hidden" name="forward" value="yes">
<input type="submit" name="submit" value="<?php echo _("Submit"); ?>">
<input type="submit" name="abort" value="<?php echo _("Abort"); ?>">
</p>
</form>
</body>
</html>

View File

@ -0,0 +1,300 @@
<?php
/*
$Id$
This code is part of LDAP Account Manager (http://www.sourceforge.net/projects/lam)
Copyright (C) 2003 Roland Gruber
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.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Manages creating/changing of pdf structures.
*/
include_once("../../lib/pdfstruct.inc");
include_once("../../lib/ldap.inc");
include_once("../../lib/config.inc");
include_once("../../lib/modules.inc");
include_once('../../lib/xml_parser.inc');
// start session
session_save_path("../../sess");
@session_start();
setlanguage();
// check if user is logged in, if not go to login
if (!$_SESSION['ldap'] || !$_SESSION['ldap']->server()) {
metaRefresh("../login.php");
exit;
}
if($_GET['edit']) {
$currentStructure = loadPDFStructureDefinitions($_GET['type'],$_GET['edit']);
}
else {
$currentStructure = loadPDFStructureDefinitions($_GET['type']);
}
$availableFields = getAvailablePDFFields($_GET['type']);
// print header
echo $_SESSION['header'];
?>
<title>LDAP Account Manager</title>
<link rel="stylesheet" type="text/css" href="../../style/layout.css">
</head>
<body>
<br>
<form action="pdfpage.php" method="post">
<table width="100%">
<tr>
<!-- print current structure -->
<td width="45%" align="center">
<fieldset>
<legend>
<b><?php echo _("Current PDF structure"); ?></b>
</legend>
<table>
<?php
$i = 0;
foreach($currentStructure as $entry) {
$links = "\t\t\t\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t\t\t\t<a href=\"pdfpage.php?type=" . $_GET['type'] . "&amp;up=" . $i . (($_GET['edit']) ? 'edit=' . $_GET['edit'] : '') . "\">" . _('Up') . "</a>\n\t\t\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t\t\t<td width=\"10\">\n\t\t\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t\t\t\t<a href=\"pdfpage.php?type=" . $_GET['type'] . "&amp;down=" . $i . (($_GET['edit']) ? 'edit=' . $_GET['edit'] : '') . "\">" . _('Down') . "</a>\n\t\t\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t\t\t<td width=\"10\">\n\t\t\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t\t\t\t<a href=\"pdfpage.php?type=" . $_GET['type'] . "&amp;remove=" . $i . (($_GET['edit']) ? 'edit=' . $_GET['edit'] : '') . "\">" . _('Remove') . "</a>\n\t\t\t\t\t\t\t\t\t</td>\n";
$uplink = 'pdfpage.php?type=' . $_GET['type'] . '&amp;up=' . $i . (($_GET['edit']) ? 'edit=' . $_GET['edit'] : '');
$downlink = 'pdfpage.php?type=' . $_GET['type'] . '&amp;down=' . urlencode($entry['tag']) . (($_GET['edit']) ? 'edit=' . $_GET['edit'] : '');
// We have a new section to start
if($entry['tag'] == "SECTION" && $entry['type'] == "open") {
$name = $entry['attributes']['NAME'];
if(preg_match("/^\_[a-zA-Z\_]+/",$name)) {
$section_headline = substr($name,1);
}
else {
$section_headline = $name;
}
?>
<tr>
<td width="20" align="left">
<input type="radio" name="section">
</td>
<td colspan="2">
<b><?php echo $section_headline;?></b>
</td>
<td width="20">
</td>
<!-- <td>
<a href="<?php echo $uplink;?>"><?php echo _('Up');?></a>
</td>
<td width="10">
</td>
<td>
<a href="<?php echo $downlink;?>"><?php echo _('Down');?></a>
</td> -->
<?php echo $links;?>
</tr>
<?php
}
// We have a section to end
elseif($entry['tag'] == "SECTION" && $entry['type'] == "close") {
?>
<tr>
<td colspan="9">
<br>
</td>
</tr>
<?php
}
// We have to include a static text.
elseif($entry['tag'] == "TEXT") {
if($entry['type'] == "complete") {
?>
<tr>
<td>
</td>
<td colspan="2">
<b><?php echo _('Static text');?></b>
</td>
<td width="20">
</td>
<!-- <td>
<a href="<?php echo $uplink;?>"><?php echo _('Up');?></a>
</td>
<td width="10">
</td>
<td>
<a href="<?php echo $downlink;?>"><?php echo _('Down');?></a>
</td> -->
<?php echo $links;?>
</tr>
<tr>
<td colspan="2">
</td>
<td>
<?php echo _('Print PDF text from config.');?>
</td>
<td colspan="6">
</td>
</tr>
<?php
}
else {
?>
<tr>
<td>
</td>
<td colspan="2">
<b><?php echo _('Static text');?></b>
</td>
<td width="20">
</td>
<!-- <td>
<a href="<?php echo $uplink;?>"><?php echo _('Up');?></a>
</td>
<td width="10">
</td>
<td>
<a href="<?php echo $downlink;?>"><?php echo _('Down');?></a>
</td> -->
<?php echo $links;?>
</tr>
<tr>
<td colspan="3">
</td>
<td>
<textarea name="pdftext" rows="10" cols="50" wrap="off">
<?php echo $entry['value'];?>
</textarea>
</td>
<td colspan="6">
</td>
</tr>
<?php
}
}
// We have to include an entry from the account
elseif($entry['tag'] == "ENTRY") {
// Get name of current entry
$name = $entry['attributes']['NAME'];
?>
<tr>
<td>
</td>
<td width="20">
</td>
<td>
<?php echo $name;?>
</td>
<td width="20">
</td>
<!-- <td>
<a href="<?php echo $uplink;?>"><?php echo _('Up');?></a>
</td>
<td width="10">
</td>
<td>
<a href="<?php echo $downlink;?>"><?php echo _('Down');?></a>
</td> -->
<?php echo $links;?>
</tr>
<?php
}
$i++;
}
?>
</table>
</fieldset>
</td>
<td width="10%" align="center">
<input type="button" name="add" value="<=">
</td>
<!-- print available fields sorted by modul -->
<td width="45%" align="center">
<fieldset>
<legend>
<b><?php echo _("Available PDF fields"); ?></b>
</legend>
<table>
<?php
foreach($availableFields as $module => $fields) {
?>
<tr>
<td colspan="2">
<b><?php echo $module;?></b>
</td>
</tr>
<tr>
<td width="20">
</td>
<td>
<select name="<?php echo $module?>[]" size="7" multiple>
<?php
foreach($fields as $field) {
?>
<option><?php echo $field;?></option>
<?php
}
?>
</select>
</td>
</tr>
<tr>
<td colspan="2">
<br>
</td>
</tr>
<?php
}
?>
</table>
</fieldset>
</td>
</tr>
</table>
<p>&nbsp;</p>
<table border="0">
<tr>
<td>
<b><?php echo _("Structure name"); ?>:</b>
</td>
<td>
<input type="text" name="profname" value="<?php echo $_GET['edit'];?>">
</td>
<td>
<a href="../help.php?HelpNumber=360" target="lamhelp"><?php echo _("Help");?></a>
</td>
</tr>
<tr>
<td colspan=3>
&nbsp
</td>
</tr>
<tr>
<td>
<input type="submit" name="submit" value="<?php echo _("Save");?>">
</td>
<td>
<input type="reset" name="reset" value="<?php echo _("Reset");?>">
<input type="submit" name="abort" value="<?php echo _("Abort");?>">
</td>
<td>
&nbsp
</td>
</tr>
</table>
<input type="hidden" name="accounttype" value="<?php echo $type;?>">
</form>
</body>
</html>
<?php
?>