Commit e2c01659 authored by Gerd Schachtschneider's avatar Gerd Schachtschneider
Browse files

Init basis xataface and common folder/files

parents
<?php
/*
* Xataface Web Application Framework
* Copyright (C) 2005-2008 Web Lite Solutions Corp (shannah@sfu.ca)
*
* 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.
*
*-------------------------------------------------------------------------------
*/
/******************************************************************************
* File: <database>/actions/printable_report.php
* Author: schachi@mpi-magdeburg.mpg.de
* Created: 2015-01-29
* Description: Html formatted print report for all tables
*
*****************************************************************************/
/******************************************************************************
* modified custom <database>/actions.ini
*
* ...
* [printable_report]
* icon="{$site_url}/images/printer.png"
* category=result_list_actions
* description="See this product list in a printable format"
* url="{$app->url('-action=printable_report')}"
* ...
*
*****************************************************************************/
class actions_printable_report {
function handle(&$params) {
//import('Dataface/RecordReader.php');
$app =& Dataface_Application::getInstance();
$query = $app->getQuery();
$query['-skip'] = 0;
$limit = 999;
$query['-limit'] = $limit;
$table = Dataface_Table::loadTable($query['-table']);
// $records = df_get_records_array($query['-table'], $query);
$records = df_get_records_array($query['-table'], $query,null,null,true);
echo '<html>'
.'<head>'
.'<title>Printable Report</title>'
.'<link rel="stylesheet" type="text/css" href="../xataface/plone.css">'
.'<script language="javascript">function printpage() { window.print(); }</script>'
.'<script type="text/javascript" src="../xataface/plone_javascripts.js"></script>'
.'</head>'
.'<body onload="printpage()">'
."Maximum number of rows is $limit"
.'<table id="print_list" class="listing">'
.'<thead>'
.'<tr class="table-headings">'
.'<th class="row-actions-header"></th>';
$header = array_keys($table->fields(false, true));
foreach ($header as $colhead) {
echo "<th class='sorted-column-asc coltype-varchar'>$colhead</th>";
}
echo '</tr>'
.'</thead>'
.'<tfoot style="display:none"></tfoot>'
.'<tbody>';
$list = 'odd';
foreach ($records as $record) {
$columns = array_keys($record->_table->fields(false, true));
echo "<tr class='listing $list'>"
.'<td class="row-actions-call"></td>';
foreach ($columns as $key) {
$value = $record->strval($key);
echo "<td class='field-content resultListCell varchar odd'><span>$value</span></td>";
}
echo '</tr>';
if ($list == 'odd') $list = 'even'; else $list = 'odd';
}
echo '</tbody>'
.'</table>'
.'</body>'
.'</html>';
}
}
?>
--
-- Tabellenstruktur für Tabelle `list_reiter`
--
CREATE TABLE IF NOT EXISTS `list_reiter` (
`autoID` smallint(6) unsigned zerofill NOT NULL AUTO_INCREMENT,
`reiter` varchar(30) COLLATE utf8_unicode_ci NOT NULL,
`kategorie` varchar(30) COLLATE utf8_unicode_ci NOT NULL,
`favorit` tinyint(1) NOT NULL DEFAULT '0',
`bedeutung` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
PRIMARY KEY (`autoID`),
UNIQUE KEY `reiter` (`reiter`),
KEY `kategorie` (`kategorie`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Reiterlinks fuer Xataface' AUTO_INCREMENT=416 ;
--
-- RELATIONEN DER TABELLE `list_reiter`:
-- `kategorie`
-- `list_katReiter` -> `kategorie`
--
--
-- Daten für Tabelle `list_reiter`
--
INSERT INTO `list_reiter` (`autoID`, `reiter`, `kategorie`, `favorit`, `bedeutung`) VALUES
(000001, 'list_email', 'Liste', 0, 'Emailadresse fuer Benachrichtung Ablauf Lizenz oder Support'),
(000002, 'list_hersteller', 'Liste', 0, 'Liste Hersteller fuer Software und Vereinbarungen'),
(000003, 'list_kategorie', 'Liste', 0, 'Liste Software-Kategorien'),
(000004, 'list_katReiter', 'Liste', 0, 'Zugehoerigkeit DB-Tabellen'),
(000005, 'list_lagerort', 'Liste', 0, 'Ablageort Schlussel'),
(000006, 'list_lieferant', 'Liste', 0, 'Liste Lieferanten fuer Lizenzen und Vereinbarungen'),
(000007, 'list_logintyp', 'Liste', 0, 'Zuordnung Links zu einer Kategorie'),
(000018, 'list_nutzer', 'Liste', 0, 'Liste Nutzer in Lizenzen und Installationen'),
(000019, 'list_reiter', 'Liste', 0, 'Sammelcontainer fuer Tabbutton "mehr .."'),
(000020, 'list_vorgang', 'Liste', 0, 'Zuordnung Dateiablage zu einer Kategorie'),
(000021, 'mpi_ablage', 'Ablage', 1, 'Dateiablagen fuer Software und Lizenzen'),
(000022, 'mpi_links', 'Ablage', 0, 'Linksammlung zu diversen Webseiten oder Logins'),
(000023, 'mpi_notiz', 'Ablage', 0, 'Liste Lizenznotizen'),
(000024, 'mpi_users', 'Authorisierung', 1, 'Authorisierung und Berechtigung Benutzer'),
(000025, 'view_user', 'View', 0, 'Auswahl Benutzer aus DB user'),
--
-- Constraints der Tabelle `list_reiter`
--
ALTER TABLE `list_reiter`
ADD CONSTRAINT `list_reiter_kateg` FOREIGN KEY (`kategorie`) REFERENCES `list_katReiter` (`kategorie`) ON UPDATE CASCADE;
--
-- Erweiterung vorhandener Tabellen
--
ALTER TABLE list_reiter MODIFY COLUMN bedeutung varchar (100) AFTER kategorie;
ALTER TABLE list_reiter ADD favorit TINYINT(1) NOT NULL DEFAULT '0' AFTER kategorie;
ALTER TABLE list_reiter ADD history TINYINT(1) NOT NULL DEFAULT '0' AFTER favorit;
ALTER TABLE list_reiter CHANGE autoID tabID SMALLINT(6) UNSIGNED ZEROFILL NOT NULL AUTO_INCREMENT;
DROP TABLE IF EXISTS list_reiter__history;
CREATE OR REPLACE VIEW view_favorit AS SELECT * FROM list_reiter WHERE favorit = '1';
<FilesMatch "\.(ini|sql|php)$">
Deny from all
</FilesMatch>
<FilesMatch "index\.php$">
Allow from all
</FilesMatch>
[__global__]
noLinkFromListView = 1
[reiter]
key = PRI
widget:label = "Tabelle"
column:legend = "[Link]"
filter = 1
[table_type]
widget:label = "Typ"
--
-- Tabellenstruktur für Tabelle `list_katReiter`
--
CREATE TABLE IF NOT EXISTS `list_katReiter` (
`autoID` smallint(6) unsigned NOT NULL AUTO_INCREMENT,
`kategorie` varchar(30) COLLATE utf8_unicode_ci NOT NULL,
PRIMARY KEY (`autoID`),
UNIQUE KEY `kategorie` (`kategorie`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=10 ;
--
-- Daten für Tabelle `list_katReiter`
--
INSERT INTO `list_katReiter` (`autoID`, `kategorie`) VALUES
(1, 'Ablage'),
(2, 'Auswertung'),
(3, 'Authorisierung'),
(4, 'Haupttabelle'),
(5, 'History'),
(6, 'Liste'),
(7, 'Programmierung'),
(8, 'View'),
(9, 'Zuordnung');
tr.lesser td { background-color: #ccf;}
tr.toless td { background-color: #fcc;}
tr.enough td { background-color: #cfc;}
tr.equal td { background-color: #ffc;}
tr.narrow td { background-color: #cff;}
tr.lineY td { background-color: #ffc !important;}
#left_column { display: none;}
/* .portlet { display: none;} */
/* #dataface-sections-left-column { display: none;} */
<!-- Display the fields -->
{*
Contents:
---------
#00 - Introduction/ Comments
#01 - Sections loop
#02 - Scriptaculous collapsible bar.
#03 - Inner elements loop
#00 - Introduction /Comments
-----------------------------
This template displays an entire HTML QuickForm form. It is designed to
be used with the HTML_QuickForm_Renderer_ArrayDataface class which produces
an array of the form:
array(
'frozen' => 'whether the form is frozen',
'javascript' => 'javascript for client-side validation',
'attributes' => 'attributes for <form> tag',
'requirednote => 'note about the required elements',
// if we set the option to collect hidden elements
'hidden' => 'collected html of all hidden elements',
// if there were some validation errors:
'errors' => array(
'1st element name' => 'Error for the 1st element',
...
'nth element name' => 'Error for the nth element'
),
// if there are no headers in the form:
'elements' => array(
element_1,
...
element_N
)
// if there are headers in the form:
'sections' => array(
array(
'header' => 'Header text for the first header',
'name' => 'Header name for the first header',
'elements' => array(
element_1,
...
element_K1
)
),
...
array(
'header' => 'Header text for the Mth header',
'name' => 'Header name for the Mth header',
'elements' => array(
element_1,
...
element_KM
)
)
)
);
where element_i is an array of the form:
array(
'name' => 'element name',
'value' => 'element value',
'type' => 'type of the element',
'frozen' => 'whether element is frozen',
'label' => 'label for the element',
'required' => 'whether element is required',
'error' => 'error associated with the element',
'style' => 'some information about element style (e.g. for Smarty)',
'field' => 'field definition array for the associated field',
// if element is not a group
'html' => 'HTML for the element'
// if element is a group
'separator' => 'separator for group elements',
'elements' => array(
element_1,
...
element_N
)
);
*}
{literal}
<script language="javascript" type="text/javascript"><!--
function Dataface_QuickForm(){
}
Dataface_QuickForm.prototype.setFocus = function(element_name){
document.{/literal}{$form_data.name}{literal}.elements[element_name].focus();
document.{/literal}{$form_data.name}{literal}.elements[element_name].select();
}
var quickForm = new Dataface_QuickForm();
//--></script>
{/literal}
<form{$form_data.attributes}>
{$form_data.hidden}
{$form_data.javascript}
{*
#01 - Outer sections loop
-------------------------
We begin by going through each section of the form individually.
*}
<table width="100%" class="Dataface_QuickForm-table-wrapper Dataface_FindForm-table-wrapper">
{foreach from=$form_data.elements item=element}
{*
#04 - Render Element
------------------------------
This section is used to render an element to be displayed.
*}
{block name="findform_before_`$element.field.name`_row"}
{define_slot name="findform_`$element.field.name`_row"}
<tr id="{$element.field.name}_findform_row">
<td valign="top" align="right" class="Dataface_QuickForm-label-cell Dataface_FindForm-label-cell {$element.field.tablename}">
<div class="field" id="findform_{$element.field.tablename}-{$element.field.name}-label-wrapper">
<label>{$element.field.widget.label}</label>
</div>
</td>
<td class="Dataface_QuickForm-widget-cell Dataface_FindForm-widget-cell {$element.field.tablename}">
<div class="field" id="{$element.field.tablename}-{$element.field.name}-wrapper">
<div>
{define_slot name="findform_`$element.field.name`_widget"}
{block name="findform_before_`$element.field.name`_widget"}
{if $element.html}
{$element.html}
{elseif $element.elements}
<!--<fieldset><legend>{$element.field.widget.label}</legend>-->
{if $element.field.widget.columns}{assign var=cols value=$element.field.widget.columns}{else}{assign var=cols value=3}{/if}
{if $cols > 1}{*The user has specified columns to use so we place the grouped elements in a table.*}
{assign var=numelements value=$element.elements|@count}
{assign var=threshold value=$numelements/$cols}
<table><tr><td>
{/if}
{assign var=ctr value=0}
{foreach from=$element.elements item=groupel name=grouploop}
{$groupel.html}{if $element.widget.separator}{$element.widget.separator}{else}{$element.separator}{/if}
{assign var=ctr value=$ctr+1}
{if ($cols > 1) and ($ctr >= $threshold)}</td><td>{assign var=ctr value=0}{/if}
{/foreach}
{if $cols > 1}
</td></tr></table>
{/if}
<!--</fieldset>-->
{/if}
{block name="findform_after_`$element.field.name`_widget"}
{/define_slot}
</div>
<div class="formHelp">{$element.field.widget.description}</div>
{if $element.field.widget.focus}
<script language="javascript" type="text/javascript"><!--
try{literal}{{/literal}quickForm.setFocus('{$element.field.name}');{literal}} catch(err){}{/literal}
//--></script>
{/if}
</div>
</td>
</tr>
{/define_slot}
{block name="findform_after_`$element.field.name`_row"}
{/foreach}
</table>
{foreach from=$form_data.sections item=section}
{*
#02 - Scriptaculous collapsible sidebar
---------------------------------------
Let's use a scriptaculous collapsible sidebar for each section
so that we have that cool animation effect it the user wants to
hide a section.
*}
{collapsible_sidebar heading=$section.header}
{block name="before_findform_table"}
<table width="100%" class="Dataface_QuickForm-table-wrapper Dataface_FindForm-table-wrapper">
{*
#03 - Inner elements loop
--------------------------
Now we go through each element in this section and render
it.
*}
{foreach from=$section.elements item=element}
{*
#04 - Render Element
------------------------------
This section is used to render an element to be displayed.
*}
{block name="findform_before_`$element.field.name`_row"}
{define_slot name="findform_`$element.field.name`_row"}
<tr id="{$element.field.name}_findform_row">
<td valign="top" align="right" class="Dataface_QuickForm-label-cell Dataface_FindForm-label-cell {$element.field.tablename}">
<div class="field" id="findform_{$element.field.tablename}-{$element.field.name}-label-wrapper">
<label>{$element.field.widget.label}</label>
</div>
</td>
<td class="Dataface_QuickForm-widget-cell Dataface_FindForm-widget-cell {$element.field.tablename}">
<div class="field" id="{$element.field.tablename}-{$element.field.name}-wrapper">
<div>
{define_slot name="findform_`$element.field.name`_widget"}
{block name="findform_before_`$element.field.name`_widget"}
{if $element.html}
{$element.html}
{elseif $element.elements}
<!--<fieldset><legend>{$element.field.widget.label}</legend>-->
{if $element.field.widget.columns}{assign var=cols value=$element.field.widget.columns}{else}{assign var=cols value=3}{/if}
{if $cols > 1}{*The user has specified columns to use so we place the grouped elements in a table.*}
{assign var=numelements value=$element.elements|@count}
{assign var=threshold value=$numelements/$cols}
<table><tr><td>
{/if}
{assign var=ctr value=0}
{foreach from=$element.elements item=groupel name=grouploop}
{$groupel.html}{if $element.widget.separator}{$element.widget.separator}{else}{$element.separator}{/if}
{assign var=ctr value=$ctr+1}
{if ($cols > 1) and ($ctr >= $threshold)}</td><td>{assign var=ctr value=0}{/if}
{/foreach}
{if $cols > 1}
</td></tr></table>
{/if}
<!--</fieldset>-->
{/if}
{block name="findform_after_`$element.field.name`_widget"}
{/define_slot}
</div>
<div class="formHelp">{$element.field.widget.description}</div>
{if $element.field.widget.focus}
<script language="javascript" type="text/javascript"><!--
try{literal}{{/literal}quickForm.setFocus('{$element.field.name}');{literal}} catch(err){}{/literal}
//--></script>
{/if}
</div>
</td>
</tr>
{/define_slot}
{block name="findform_after_`$element.field.name`_row"}
{/foreach}
</table>
{block name="after_findform_table"}
{/collapsible_sidebar}
{/foreach}
</form>
[user]
__sql__ = "SELECT localID,CONCAT(last_name,', ',first_name,' : ',localID) FROM view_user ORDER BY last_name"
[roles]
NO ACCESS = "No_Access"
READ ONLY = "ReadOnly (view, list, calendar, view xml, show all, find, navigate)"
EDIT = "Edit (READ_ONLY and edit, new record, remove, import, translate, copy)"
DELETE = "Delete (EDIT and delete and delete found)"
OWNER = "Owner (DELETE except navigate, new, and delete found)"
REVIEWER = "Reviewer (READ_ONLY and edit and translate)"
USER = "User (READ_ONLY and add new related record)"
ADMIN = "Admin (DELETE and xml_view)"
MANAGER = "Manager (ADMIN and manage, manage_migrate, manage_build_index, and install)"
-- view auf list_reiter, weil COLLATE nicht erlaubt in xataface
-- !! achtung fuer jeden view einer datenbank eigenes TABLE_SCHAEMA !!
CREATE OR REPLACE VIEW view_reiter AS
SELECT
CONVERT(table_name USING utf8) COLLATE utf8_unicode_ci AS reiter,
table_type
FROM
information_schema.tables
WHERE
table_schema = (SELECT DATABASE() FROM DUAL) AND
( table_type = 'base table' OR table_type = 'view' )
;
<table>
<colgroup>
<col width="10%">
<col width="10%">
<col width="1%">
<col width="25%">
<col width="25%">
<col width="25%">
</colgroup>
<tr>
<td></td>
<th align="right">Innen</th>
<td></td>
<td>Name {$elements.ansprechpartnerID.html}</td>
<td>Telefon {$elements.telefonID.html}</td>
<td>Position {$elements.positionID.html}</td>
</tr>
<tr>
<td></td>
<th align="right">Aussen</th>
<td></td>
<td>Name {$elements.ansprechpartnerAD.html}</td>
<td>Telefon {$elements.telefonAD.html}</td>
<td>Position {$elements.positionAD.html}</td>
</tr>
</table>
<?php
class tables_mpi_users {
function getPermissions($record) {
$user = Dataface_AuthenticationTool::getInstance()->getLoggedInUser();
// first let's deal with the case that the user is not logged in.
if ( !$user ) return Dataface_PermissionsTool::NO_ACCESS();
$role = $user->val('role');
// if ( isAdmin($role) ) return Dataface_PermissionsTool::ALL();
if ( $role == 'MANAGER' ) return Dataface_PermissionsTool::getRolePermissions('MANAGER');
if ( $role == 'ADMIN' ) return Dataface_PermissionsTool::getRolePermissions('ADMIN');
// Everybody else gets read only access to the table.
// return Dataface_PermissionsTool::getRolePermissions('READ ONLY');
return Dataface_PermissionsTool::NO_ACCESS();
}
function email__renderCell( &$record ) {
$mail = $record->strval('email');
return '<a href="mailto:'.$mail.'">'.$mail.'</a>';
}
// Formatiere Zeitstempel auf Deutsch
function zeitstempel__display(&$record) {
if ($record->strval('zeitstempel') == NULL) return;
return date('d.m.Y', strtotime($record->strval('zeitstempel')));
}
function beforeSave(&$record) {
$app = Dataface_Application::getInstance();
$dn = $app->_conf['_own']['dn'];
$usr = $record->val('username');
$record->setValue('email', $usr.'@'.$dn);
}
}
?>