1 Commits

Author SHA1 Message Date
cc9695b292 Added part of backend but problems with Joomla code compatibility found.
Somehow the password must be handled specially (also because of the hashing) which causes problems at the moment.
2019-04-12 15:56:00 +02:00
84 changed files with 581 additions and 3006 deletions

View File

@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<buildpath>
<buildpathentry kind="src" path="src"/>
<buildpathentry external="true" kind="lib" path="/home/private/slt/joomla"/>
<buildpathentry external="true" kind="lib" path="/srv/slt-dev"/>
<buildpathentry kind="con" path="org.eclipse.php.core.LANGUAGE"/>
</buildpath>

View File

@@ -1,7 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.ui.externaltools.ProgramBuilderLaunchConfigurationType">
<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_BUILDER_ENABLED" value="false"/>
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_DISABLED_BUILDER" value="org.eclipse.texlipse.builder.TexlipseBuilder"/>
<mapAttribute key="org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS"/>
<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/>
</launchConfiguration>

View File

@@ -5,16 +5,6 @@
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.ui.externaltools.ExternalToolBuilder</name>
<triggers>full,incremental,</triggers>
<arguments>
<dictionary>
<key>LaunchConfigHandle</key>
<value>&lt;project&gt;/.externalToolBuilders/org.eclipse.texlipse.builder.TexlipseBuilder.launch</value>
</dictionary>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.common.project.facet.core.builder</name>
<arguments>
@@ -32,7 +22,6 @@
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.texlipse.builder.TexlipseNature</nature>
<nature>org.eclipse.php.core.PHPNature</nature>
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
</natures>

View File

@@ -1,9 +0,0 @@
# Aufgaben
## Backend
- Bilder fuer Loeschen statt des Textes Del einsetzen
- Optik anpassen mit CSS
## Frontend

View File

@@ -1,2 +0,0 @@
/artifacts/
/.rmtoo_dependencies

View File

@@ -1,63 +0,0 @@
---
global:
modules:
directories:
- .
processing:
analytics:
stop_on_errors: false
requirements:
input:
commit_interval:
begin: FILES
end: FILES
default_language: de_DE
dependency_notation:
- Solved by
directory: requirements
inventors:
- flonatel
- wolf
stakeholders:
- development
- management
- users
topics:
ts_common:
sources:
- - filesystem
- requirements_dirs:
- requirements/model
- requirements
topics_dirs:
- topics
topic_root_node: ReqsDocument
constraints_dirs:
- constraints
testcases_dirs:
- testcases
output:
graph:
- output_filename: artifacts/req-graph1.dot
graph2:
- output_filename: artifacts/req-graph2.dot
html:
- footer: html/footer.html
header: html/header.html
output_directory: artifacts/html
#LatexJinja2:
latex2:
- output_filename: artifacts/reqtopics.tex
#template_path: latex/LatexJinja2
prios:
- output_filename: artifacts/reqsprios.tex
stats_burndown1:
- output_filename: artifacts/stats_burndown.csv
start_date: '2011-05-01'
stats_reqs_cnt:
- output_filename: artifacts/stats_reqs_cnt.csv
stats_sprint_burndown1:
- output_filename: artifacts/stats_sprint_burndown.csv
start_date: '2011-05-01'
version1:
- output_filename: artifacts/reqs-version.txt

View File

@@ -1,69 +0,0 @@
.PHONY: all
.PHONY: all_html
all: artifacts/requirements.pdf artifacts/req-graph1.png \
artifacts/req-graph2.png all_html
# Adding new files (especially requirements) can not automatically
# handled. The 'force' target tries to handle this.
.PHONY: force
force:
rm .rmtoo_dependencies
${MAKE} all
#
# This is the way the rmtoo must be called.
# (The RMTOO_CALL variable is set in the setenv.sh script)
# You can override the default Config.py file by setting
# the RMTOO_CONFIG variable from the command line.
# ie:
# make RMTOO_CONFIG=YourConfig.json
#
RMTOO_CALL ?= rmtoo
RMTOO_CONFIG=Config.yml
RMTOO_CONTRIB_DIR ?= /usr/share/rmtoo
CALL_RMTOO=${RMTOO_CALL} -y file://${RMTOO_CONFIG}
#
# Dependency handling
# The file .rmtoo_dependencies is created by rmtoo itself.
#
include .rmtoo_dependencies
all_html: ${OUTPUT_HTML}
# And how to make the dependencies
.rmtoo_dependencies:
${CALL_RMTOO} \
--create-makefile-dependencies=.rmtoo_dependencies
artifacts/req-graph1.png: artifacts/req-graph1.dot
unflatten -l 23 artifacts/req-graph1.dot | \
dot -Tpng -o artifacts/req-graph1.png
artifacts/req-graph2.png: artifacts/req-graph2.dot
dot -Tpng -o artifacts/req-graph2.png artifacts/req-graph2.dot
# Two calls are needed: one for the requirments converting and one for
# backlog creation.
artifacts/requirements.pdf: ${REQS_LATEX2} latex/requirements.tex
# (cd artifacts && \
# gnuplot ${RMTOO_CONTRIB_DIR}/contrib/gnuplot_stats_reqs_cnt.inc && \
# epstopdf stats_reqs_cnt.eps)
# (cd artifacts && \
# gnuplot ${RMTOO_CONTRIB_DIR}/contrib/gnuplot_stats_burndown.inc && \
# epstopdf stats_burndown.eps)
# (cd artifacts && \
# gnuplot ${RMTOO_CONTRIB_DIR}/contrib/gnuplot_stats_sprint_burndown.inc && \
# epstopdf stats_sprint_burndown.eps)
(cd artifacts && pdflatex ../latex/requirements.tex; \
pdflatex ../latex/requirements.tex; \
pdflatex ../latex/requirements.tex)
.PHONY: clean
clean:
rm -fr artifacts/html
rm -f artifacts/* \
add_data.py*
rm -fr debian/rmtoo build

View File

@@ -1,8 +0,0 @@
<hr/>
<span class="footer_text"><p>This document is part of the rmtoo
requirements documentation and was generated
by <a href="http://rmtoo.gnu4u.org">rmtoo</a> itself.</p>
<p>rmtoo is copyright 2010 by flonatel. rmtoo is distributed under
GPL V3.</p></span>
</body>
</html>

View File

@@ -1,167 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>rmtoo</title>
<meta name="generator" content="rmtoo">
<style type="text/css">
<!--
h1, h2, h3 {
font-family:sans;
}
a:link, a:visited, a:active, a:hover {
text-decoration:none;
font-weight:bold;
color:#407cbf;
}
.fltext {
font-family:sans;
}
.footer_text {
font-family:sans;
font-size:small;
}
.requirment_end {
background-image:url(../trenner01.png);
margin:0px;
padding:0px;
height:2px;
}
.dlt_description {
font-family:sans;
font-size:medium;
font-weight:bold;
}
.dlv_description {
font-family:sans;
font-size:medium;
}
.dlt_rationale {
font-family:sans;
font-weight:bold;
}
.dlv_rationale {
font-family:sans;
}
.dlt_note {
font-family:sans;
font-size:small;
font-weight:bold;
}
.dlv_note {
font-family:sans;
font-size:small;
}
.dlt_depends_on {
font-family:sans;
font-size:small;
font-weight:bold;
}
.dlv_depends_on {
font-family:sans;
font-size:small;
}
.dlt_dependent {
font-family:sans;
font-size:small;
font-weight:bold;
}
.dlv_dependent {
font-family:sans;
font-size:small;
}
.dlt_id {
font-family:sans;
font-size:small;
font-weight:bold;
}
.dlv_id {
font-family:sans;
font-size:small;
}
.dlt_priority {
font-family:sans;
font-size:small;
font-weight:bold;
}
.dlv_priority {
font-family:sans;
font-size:small;
}
.dlt_owner {
font-family:sans;
font-size:small;
font-weight:bold;
}
.dlv_owner {
font-family:sans;
font-size:small;
}
.dlt_invented_on {
font-family:sans;
font-size:small;
font-weight:bold;
}
.dlv_invented_on {
font-family:sans;
font-size:small;
}
.dlt_invented_by {
font-family:sans;
font-size:small;
font-weight:bold;
}
.dlv_invented_by {
font-family:sans;
font-size:small;
}
.dlt_status {
font-family:sans;
font-size:small;
font-weight:bold;
}
.dlv_status {
font-family:sans;
font-size:small;
}
.dlt_class {
font-family:sans;
font-size:small;
font-weight:bold;
}
.dlv_class {
font-family:sans;
font-size:small;
}
-->
</style>
</head>
<body>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 627 B

View File

@@ -1,80 +0,0 @@
\documentclass{report}
\usepackage[ngerman]{babel}
\usepackage{longtable}
\usepackage{graphicx}
% When latex aborts with
% pdfTeX error (ext4): \pdfendlink ended up in different nesting level than \pd
% fstartlink.
% Comment that line with draft out and inpect the errornous page
\usepackage[pdfauthor={flonatel},%
%draft,%
pdftitle={Requirment for project},%
pdfsubject={Requirment description for project},%
pdfkeywords={placeholder for some keywords},%
pagebackref=true,%
pdftex, bookmarks=true, colorlinks=true]{hyperref}
\usepackage[a4paper]{geometry}
\usepackage[titles]{tocloft}
\usepackage{fancyhdr}
\setlength{\cftsubsecnumwidth}{4em}
\pagestyle{fancy}
\fancyhead{}
\fancyfoot{}
\fancyhead[L]{\rightmark}
\fancyfoot[R]{\thepage}
% \fancyfoot[L]{Version \input{../artifacts/reqs-version.txt}}
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0.4pt}
\parindent0em
\begin{document}
\thispagestyle{empty}
\mbox{}
\vfill
{\LARGE\textbf{Requirements for project}}
\vfill
{\Large\textbf{written by You}}
\vfill
09. October 2010
\vfill
% Requirements Version: \input{../artifacts/reqs-version.txt}
\vfill
\newpage
\tableofcontents
\newpage
\chapter{Status}
\input{../artifacts/reqsprios.tex}
\input{../artifacts/reqtopics.tex}
% \chapter{Statistics}
% \section{Burndown diagram for Sprint}
% \includegraphics{../artifacts/stats_sprint_burndown.pdf}
%
% \section{Burndown diagram for Project}
% \includegraphics{../artifacts/stats_burndown.pdf}
%
% \section{Requirements Count Statistics}
% \includegraphics{../artifacts/stats_reqs_cnt.pdf}
\end{document}

View File

@@ -1,12 +0,0 @@
Name: projectdfg
Type: requirement | design decision
Invented on:
Invented by: wolf
Owner: development | management | users
Description:
Rationale:
Status: not done
#Solved by:
#Priority:
#Effort estimation: 5
#Topic:

View File

@@ -1,13 +0,0 @@
Name: Definition Abstractes DB Objekt
Type: design decision
Invented on: 2019-05-21
Invented by: wolf
Owner: development
Description: Jedes Objekt in der Datenbank wird durch ein
Objekt in der Sprache repräsentiert.
Rationale:
Status: not done
Solved by: adbo-id adbo-simple adbo-lists
#Priority:
#Effort estimation: 5
Topic: model

View File

@@ -1,13 +0,0 @@
Name: Objekt-ID
Type: design decision
Invented on: 2019-05-21
Invented by: wolf
Owner: development
Description: Jedes Objekt der Datenbank hat einen eindeutigen Schlüssel
genannt \emph{id}.
Rationale:
Status: not done
#Solved by:
#Priority:
#Effort estimation: 5
Topic: model

View File

@@ -1,13 +0,0 @@
Name: Listen im Objekt
Type: design decision
Invented on: 2019-05-21
Invented by: wolf
Owner: development
Description: 1:n Beziehungen können vom gemeinsamen
Objekt aus abgefragt werden mittels Funktionsaufrufen.
Rationale:
Status: not done
#Solved by:
#Priority:
#Effort estimation: 5
Topic: model

View File

@@ -1,15 +0,0 @@
Name: n:m-Beziehungen
Type: design decision
Invented on: 2019-05-21
Invented by: wolf
Owner: development
Description: n:m Beziehugen werden wie 1:n-Beziehungen im
Objektbaum abgebildet. Im Unterschied zu einfachen Listen
muss allerdings eine Liste bei beiden Objekten erstellt werden,
so dass eine Navigation möglich ist.
Rationale:
Status: not done
#Solved by:
#Priority:
#Effort estimation: 5
Topic: model

View File

@@ -1,14 +0,0 @@
Name: Assoziative Listen
Type: design decision
Invented on: 2019-05-21
Invented by: wolf
Owner: development
Description: Relationen der Kardinalität 1:n werden als
Objekte einer separaten Tabelle mit einem Fremdschlüssel
abgelegt.
Rationale:
Status: not done
Solved by: adbo-lists-attribs adbo-lists-lists
#Priority:
#Effort estimation: 5
Topic: model

View File

@@ -1,15 +0,0 @@
Name: Triviale Attibute im Objekt
Type: design decision
Invented on: 2019-05-21
Invented by: wolf
Owner: development
Description: Einfache Attribute im Sinne einer 1:1 Beziehung
werden direkt im Objekt gespeichert. Dazu werden die Daten
in einer innerhalb der Klassenhierarchie sichtbaren Eigenschaft
\emph{values} abgelegt als assoziatives Array.
Rationale:
Status: not done
#Solved by:
#Priority:
#Effort estimation: 5
Topic: model

View File

@@ -1,13 +0,0 @@
Name: Einfache Objektstruktur
Type: design decision
Invented on: 2019-05-21
Invented by: wolf
Owner: development
Description: Einfache Attribute eines Objekts werden als Spalten
in der DB-Tabelle abgespeichert.
Rationale:
Status: not done
Solved by: adbo-simple-attribs
#Priority:
#Effort estimation: 5
Topic: model

View File

@@ -1,13 +0,0 @@
Name: Aufrufe cachen
Type: design decision
Invented on: 2019-05-21
Invented by: wolf
Owner: development
Description: DB-Aufrufe sollen soweit es möglich ist,
zwischengespeichert werden.
Rationale:
Status: not done
#Solved by:
#Priority:
#Effort estimation: 5
Topic: model

View File

@@ -1,13 +0,0 @@
Name: Anbindung der SQL
Type: design decision
Invented on: 2019-05-21
Invented by: wolf
Owner: development
Description: Die Daten in der Datenbank müssen durch einfache
Funktionsaufrufe abrufbar sein.
Rationale:
Status: not done
Solved by: abstract-object cache
#Priority:
Effort estimation: 0
Topic: model

View File

@@ -1,12 +0,0 @@
Name: projectdfg
Type: master requirement
Invented on: 2010-10-09
Invented by: flonatel
Owner: development
Description: \textsl{project} \textbf{must} exists.
Rationale: The world needs a good, usable and free \textsl{project}.
Status: not done
Solved by: sql-interface
Priority: development:10
Effort estimation: 5
Topic: ReqsDocument

View File

@@ -1,4 +0,0 @@
Name: project
Text: This is placeholder for some introductional text.
IncludeRequirements: full
SubTopic: model

View File

@@ -1,3 +0,0 @@
Name: Datenbank-Modelle
Text: Abhängigkeiten der Model-Klassen
IncludeRequirements: full

View File

@@ -1,24 +0,0 @@
CREATE TABLE `dev_club_keys` (
`privkey` text NOT NULL,
`publickey` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `dev_club_users` (
`id` int(10) NOT NULL AUTO_INCREMENT,
`user` varchar(30) NOT NULL,
`password` varchar(150) DEFAULT NULL,
`name` varchar(255) NOT NULL,
`address` tinytext NOT NULL,
`city` varchar(50) NOT NULL,
`mail` varchar(100) NOT NULL,
`phone` varchar(50) DEFAULT NULL,
`mobile` varchar(50) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `dev_club_offers` (
`id` int(10) NOT NULL AUTO_INCREMENT,
`name` varchar(100) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

View File

@@ -1,76 +0,0 @@
CREATE TABLE `dev_club_keys` (
`privkey` text NOT NULL,
`publickey` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `dev_club_users` (
`id` int(10) NOT NULL AUTO_INCREMENT,
`user` varchar(30) NOT NULL,
`password` varchar(150) DEFAULT NULL,
`name` varchar(255) NOT NULL,
`address` tinytext NOT NULL,
`city` varchar(50) NOT NULL,
`mail` varchar(100) NOT NULL,
`phone` varchar(50) DEFAULT NULL,
`mobile` varchar(50) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `dev_club_offers` (
`id` int(10) NOT NULL AUTO_INCREMENT,
`name` varchar(100) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `dev_club_positions` (
`id` int(10) NOT NULL AUTO_INCREMENT,
`name` varchar(100) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `dev_club_clubs` (
`id` int(10) NOT NULL AUTO_INCREMENT,
`name` varchar(100) NOT NULL,
`address` tinytext NOT NULL,
`city` varchar(50) NOT NULL,
`homepage` varchar(100) NULL,
`mail` varchar(100) NOT NULL,
`iban` char(34) NOT NULL,
`bic` char(11) NOT NULL,
`charitable` tinyint(1) NOT NULL,
`president` int(10) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `dev_club_offer_assocs` (
`id` int(10) NOT NULL AUTO_INCREMENT,
`clubid` int(10) NOT NULL,
`offerid` int(10) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `dev_club_places` (
`id` int(10) NOT NULL AUTO_INCREMENT,
`clubid` int(10) NOT NULL,
`name` varchar(100) NOT NULL,
`address` tinytext NOT NULL,
`area` int(10) NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `dev_club_user_assocs` (
`id` int(10) NOT NULL AUTO_INCREMENT,
`clubid` int(10) NOT NULL,
`userid` int(10) NOT NULL,
`positionid` int(10) NOT NULL,
`admin` tinyint(1) NOT NULL DEFAULT 0,
`state` enum('regular', 'vacant', 'temporary') NOT NULL DEFAULT 'vacant',
`address` tinytext DEFAULT NULL,
`mail` varchar(100) DEFAULT NULL,
`phone` varchar(50) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

View File

@@ -1,212 +0,0 @@
<?php
use Joomla\CMS\Factory;
use Joomla\CMS\MVC\Controller\BaseController;
use Joomla\CMS\Router\Route;
// No direct access.
defined('_JEXEC') or die;
abstract class AbstractClubsController extends BaseController
{
protected abstract function getNameOfElement();
protected function getModelName()
{
return $this->getNameOfElement();
}
protected function getNameOfView()
{
return strtolower($this->getNameOfElement());
}
protected abstract function getDataMapping();
function new()
{
$obj = call_user_func(array('Clubs' . $this->getNameOfElement(), 'create' . $this->getNameOfElement()));
// Fetch the posted data
$values = $this->loadData();
$this->filterPreCheck($values);
// Check the input data
$error = ! $this->checkDataIsValid($values, true, Null);
$view = $this->getNameOfView();
if($error)
{
$urldata = $this->packData($values);
$this->setRedirect(Route::_("index.php?option=com_clubs&view={$view}&id=new&data={$urldata}", false));
return;
}
$this->applyData($obj, $values);
// Do the actual work
$obj->save();
$this->setRedirect(Route::_("index.php?option=com_clubs&view={$view}s", false));
}
function change()
{
$app = Factory::getApplication();
$input = $app->input;
$id = (int) $input->post->getInt('id');
$obj = call_user_func(array('Clubs' . $this->getNameOfElement(), 'load' . $this->getNameOfElement()), (int) $id);
// Fetch the posted data
$values = $this->loadData();
$this->filterPreCheck($values);
// Check the input data
$error = ! $this->checkDataIsValid($values, false, $obj);
$view = $this->getNameOfView();
if($error)
{
$urldata = $this->packData($values);
$this->setRedirect(Route::_("index.php?option=com_clubs&view={$view}&id={$id}&data={$urldata}", false));
return;
}
$this->applyData($obj, $values);
// Do the actual work
$obj->save();
$this->setRedirect(Route::_("index.php?option=com_clubs&view={$view}s", false));
}
protected function loadData()
{
$values = array();
$input = Factory::getApplication()->input->post;
foreach($this->getDataMapping() as $m => $f)
{
$filter = (isset($f['filter'])) ? $f['filter'] : 'string';
$values[$m] = $input->get($m, null, $filter);
}
return $values;
}
protected function filterPreCheck(&$values){}
protected function checkDataIsValid($values, bool $isNew, $obj)
{
$error = false;
// Check existence of the required fields
foreach ($this->getDataMapping() as $m => $v)
{
if(! isset($v['required']) || ! $v['required'])
continue;
// Field is required
if(! $this->fieldValid($m, $values[$m], $v))
{
$fname = (isset($v['name'])) ? $v['name'] : $m;
Factory::getApplication()->enqueueMessage("Das Feld $fname ist obligatorisch.", 'error');
$error = true;
}
}
return ! $error;
}
protected function fieldValid($name, $value, $options)
{
if(empty($value))
return false;
if(isset($options['filter']))
{
switch($options['filter'])
{
case 'string':
if(empty(trim($value)))
return false;
}
}
return true;
}
private function packData($values)
{
// FIXME Multiple bugs: filtering not working as expected and Mapping msut be checked
$this->filterPrePacking($values);
$data = array();
foreach($this->getDataMapping() as $m => $i)
{
if(isset($values[$m]))
$data[$m] = $values[$m];
}
$json = json_encode($data);
return urlencode($json);
}
protected function filterPrePacking(&$values){}
public function applyData($obj, $values)
{
$this->applyDataToObject($obj, $values, $this->getDataMapping());
}
protected function applyDataToObject($obj, $values, $mapping)
{
foreach($mapping as $m => $v)
{
$functionName = $this->getSetterMethodName($m, $v);
if($functionName === null)
{
continue;
}
if(isset($v['skip_null_check']))
$value = $values[$m];
else
$value = (isset($values[$m]) && strlen($values[$m]) > 0) ? $values[$m] : null;
$obj->$functionName($value);
}
}
private function getSetterMethodName($m, $options)
{
if(array_key_exists('setter', $options))
return $options['setter'];
$firstChar = substr($m, 0, 1);
$restChars = substr($m, 1);
return 'set' . strtoupper($firstChar) . $restChars;
}
function delete()
{
$app = Factory::getApplication();
$id = $app->input->get->getInt('id');
$name = $this->getNameOfElement();
$app->enqueueMessage("Removal of $name with id $id.");
$className = 'Clubs' . $this->getModelName();
$functionName = 'load' . $this->getModelName();
$element = call_user_func(array($className, $functionName), $id);
$element->delete();
$view = $this->getNameOfView();
$this->setRedirect(Route::_("index.php?option=com_clubs&view={$view}s", false));
}
}

View File

@@ -1,207 +0,0 @@
<?php
// No direct access.
use Joomla\CMS\Factory;
defined('_JEXEC') or die;
abstract class AbstractClubsModel
{
protected $id;
/**
* @return int
*/
public function getId()
{
return $this->id;
}
protected abstract function getDataMappings();
protected abstract function getTableName();
protected function loadData(array $data)
{
$this->id = $data['id'];
foreach($this->getDataMappings() as $m)
$this->$m = $data[$m];
}
protected static function loadElements(string $tableName, string $className, $where = null)
{
$dbo = Factory::getDbo();
$q = $dbo->getQuery(true);
$q->select('*')
->from($tableName);
if(isset($where))
{
$q->where($where);
}
$dbo->setQuery($q);
$dbo->execute();
$list = $dbo->loadAssocList();
$ret = array();
foreach($list as $row)
{
$obj = new $className();
$obj->loadData($row);
$ret[] = $obj;
}
return $ret;
}
/**
* @param int $id
* @throws Exception
* @return ClubsOffer
*/
protected static function loadElement(int $id, string $tableName, string $className)
{
$dbo = Factory::getDbo();
$q = $dbo->getQuery(true);
$q->select('*')->from($tableName);
$q->where('id=' . (int) $id);
$dbo->setQuery($q);
$dbo->execute();
$row = $dbo->loadAssoc();
if($row == null)
{
throw new Exception("No object of class $className found.");
// TODO
}
$obj = new $className();
$obj->loadData($row);
$obj->loadCustomData($row);
return $obj;
}
protected function loadCustomData($assoc)
{}
public function save()
{
if($this->id === 'new')
$this->insertElement();
else
$this->updateElement();
}
private function insertElement()
{
if(! $this->isDataValid())
throw new Exception('Data is invalid');
$dbo = Factory::getDbo();
$q = $dbo->getQuery(true);
$mappings = $this->getDataMappings();
$values = $this->getDataValues($mappings, $q);
$q->insert($this->getTableName())
->columns(array_map(array($q, 'qn'), $mappings))
->values(join(',', $values))
;
$dbo->transactionStart();
$dbo->setQuery($q);
$dbo->execute();
$this->id = $dbo->insertid();
$dbo->transactionCommit();
}
private function updateElement()
{
if(! $this->isDataValid())
throw new Exception('Data is invalid');
$dbo = Factory::getDbo();
$q = $dbo->getQuery(true);
$mapping = $this->getDataMappings();
$values = $this->getDataValues($mapping, $q);
$q->update($this->getTableName());
foreach($mapping as $m)
$q->set($q->qn($m) . '=' . $values[$m]);
$q->where("id=". (int) $this->id);
$dbo->setQuery($q);
$dbo->execute();
}
private function getDataValues($mapping, $q)
{
$rawValues = array();
foreach($mapping as $m)
$rawValues[$m] = $this->$m;
$this->filter($rawValues);
$quotedValues = array();
foreach($mapping as $m)
{
if(is_bool($rawValues[$m]))
$quotedValues[$m] = $rawValues[$m] ? 'TRUE' : 'FALSE';
else if(is_numeric($rawValues[$m]))
$quotedValues[$m] = $rawValues[$m];
else
$quotedValues[$m] = $q->q($rawValues[$m]);
}
$this->postQuoteFilter($quotedValues);
return $quotedValues;
}
protected function prepareDelete($dbo){}
public function delete()
{
if($this->id === 'new')
return;
$dbo = Factory::getDbo();
$this->prepareDelete($dbo);
$q = $dbo->getQuery(true);
$q->delete($this->getTableName())
->where('id=' . (int) $this->id);
$dbo->setQuery($q);
$dbo->execute();
}
protected function getRequiredDataMappings()
{
return $this->getDataMappings();
}
protected function isDataValid()
{
foreach($this->getRequiredDataMappings() as $m)
{
if(!isset($this->$m) || is_null($this->$m) || $this->$m === null)
return false;
}
return true;
}
protected function filter(&$values){}
protected function postQuoteFilter(&$values){}
}

View File

@@ -1,177 +0,0 @@
<?php
// No direct access.
use Joomla\CMS\Factory;
defined('_JEXEC') or die;
abstract class AbstractClubsModelFactory
{
protected $tableName;
protected $className;
public function __construct($tableName, $className)
{
$this->tableName = $tableName;
$this->className = $className;
}
/**
*
* @param JDatabaseDriver $dbo
* @return array
*/
protected function getJoins($dbo)
{
/*
* Desired structure:
* array, ech element describing one join type.
* Each element of the array is a assosiated array describing the join:
* - Name of the table (must not be main)
* - Table alias
* - Type of the join (inner, left, right, outer), default is inner
* - Condition as a string (might need escaping)
* - Columns to be inserted in the join, defaults to *
* example:
* $ret = array();
* $ret[] = array(
* 'name' => '#__table_name',
* 'alias' => 't1',
* 'type' => 'right',
* 'on' => 'main.extid = t1.id'
* 'select' => array('id','name')
* );
* return $ret;
*/
return array();
}
/**
*
* @param JDatabaseDriver $dbo
* @param JDatabaseQuery $q
*/
private function insertJoinRelations($dbo, $q)
{
$joins = $this->getJoins($dbo);
foreach($joins as $j)
{
if(is_null($j['name']))
throw new Exception('No name was given in the join.');
if(is_null($j['alias']))
throw new Exception('No alisas was given in the join.');
$jstr = $dbo->qn($j['name'], $j['alias']);
if(is_null($j['on']))
throw new Exception('No on clause was provided.');
$jstr .= " ON {$j['on']}";
if(is_null($j['type']))
$j['type'] = 'inner';
switch($j['type'])
{
case 'inner':
$q->innerJoin($jstr);
break;
case 'outer':
$q->outerJoin($jstr);
break;
case 'left':
$q->leftJoin($jstr);
break;
case 'right':
$q->rightJoin($jstr);
break;
default:
throw new Exception("Type of join unknown: {$j['type']}.");
}
$this->addJoinSelectColumns($j, $q);
}
}
/**
*
* @param array $j
* @param JDatabaseQuery $q
*/
private function addJoinSelectColumns($j, $q)
{
// TODO Quote names
if(is_null($j['select']))
$j['select'] = '*';
if(is_array($j['select']))
{
array_map(function(&$str) use ($j) {
$str = "{$j['alias']}.$str";
}, $j['select']);
}
else
{
$q->select("{$j['alias']}.{$j['select']}");
}
}
public function loadElement(int $id)
{
$condition = "id = $id";
return $this->loadFirstElement($condition);
}
public function loadFirstElement($condition)
{
$objs = $this->loadElements($condition);
if(sizeof($objs) == 0)
{
throw new Exception("No object of class {$this->className} found.");
// TODO
}
return $objs[0];
}
public function loadElements($condition = null)
{
$dbo = Factory::getDbo();
$q = $dbo->getQuery(true);
$q->select('main.*')->from($this->tableName, 'main');
$this->insertJoinRelations($dbo, $q);
if(isset($condition))
{
$q->where($condition);
}
$dbo->setQuery($q);
$dbo->execute();
$list = $dbo->loadAssocList();
$ret = array();
foreach($list as $row)
{
$ret[] = $this->createElement($row);
}
return $ret;
}
protected function createElement($row)
{
$obj = new $this->className();
$obj->loadData($row);
$obj->loadCustomData($row);
return $obj;
}
}

View File

@@ -1,86 +0,0 @@
<?php
use Joomla\CMS\Factory;
use Joomla\CMS\MVC\View\HtmlView;
use Joomla\CMS\Router\Route;
// No direct access.
defined('_JEXEC') or die;
abstract class AbstractClubsViewSingle extends HtmlView
{
protected $address;
protected $object;
protected $isNew;
private $prepared = FALSE;
public function prepareDisplay()
{
$this->prepared = TRUE;
$input = Factory::getApplication()->input;
$id = $input->get->get('id');
$modelClass = 'Clubs' . $this->getModelName();
$controller = $this->getControllerName();
if($id === 'new')
{
$this->address = Route::_("index.php?option=com_clubs&task={$controller}.new");
$this->object = call_user_func(array($modelClass, 'create' . $this->getModelName()));
$this->isNew = true;
}
else if(is_numeric($id))
{
$this->address = Route::_("index.php?option=com_clubs&task={$controller}.change");
$this->object = call_user_func(array($modelClass, 'load' . $this->getModelName()), (int) $id);
$this->isNew = false;
}
else
throw new Exception('Need an object id.');
if($input->get->get('data', null, 'json') != null)
{
// Restore previous data
$dataurl = $input->get->get('data', null, 'json');
$data = json_decode($dataurl, true);
$controller = $this->getElementController();
$controller->applyData($this->object, $data);
}
}
public function display($tpl = null)
{
if(!$this->prepared)
$this->prepareDisplay();
parent::display($tpl);
}
protected abstract function getViewName();
protected function getControllerName()
{
return $this->getViewName();
}
protected function getModelName()
{
$name = $this->getViewName();
return $this->capitalize($name);
}
private function capitalize($s)
{
$first = substr($s, 0, 1);
$rest = substr($s, 1);
return strtoupper($first) . $rest;
}
protected abstract function getElementController();
}

View File

@@ -1,18 +1,18 @@
<?php
// No direct access.
use Joomla\CMS\Factory;
use Joomla\CMS\MVC\Controller\BaseController;
use Joomla\CMS\Factory;
// No direct access.
defined('_JEXEC') or die;
JLoader::discover('Clubs', JPATH_ROOT . '/administrator/components/com_clubs/mymodels');
JLoader::registerPrefix('AbstractClubs', JPATH_ROOT . '/administrator/components/com_clubs/abstract');
$controller = BaseController::getInstance("Clubs");
$input = Factory::getApplication()->input;
$task = $input->getCmd("task", "display");
$view = $input->getCmd('view', 'users');
$input->set('view', $view);
$controller->execute($task);
$controller->redirect();

View File

@@ -9,4 +9,12 @@ class ClubsController extends BaseController
{
protected $default_view = 'users';
public function display($cachable = false, $urlparams = array())
{
$this->input->get('view', $this->default_view);
parent::display($cachable, $urlparams);
}
}

View File

@@ -1,44 +0,0 @@
<?php
// No direct access.
defined('_JEXEC') or die;
class ClubsControllerClub extends AbstractClubsController
{
protected function getNameOfElement()
{
return 'club';
}
protected function getDataMapping()
{
return array(
// 'name' => array('required'=>true, 'name'=>'Bezeichnung', 'filter'=>'string')
'name' => array('required'=>true, 'name'=>'Club-Name', 'filter'=>'string'),
'address' => array('required'=>true, 'name'=>'Adresse', 'filter'=>'string'),
'city' => array('required'=>true, 'name'=>'Stadt', 'filter'=>'string'),
'homepage' => array('required'=>false, 'name'=>'Homepage', 'filter'=>'string'),
'mail' => array('required'=>true, 'name'=>'E-Mail', 'filter'=>'string'),
'iban' => array('required'=>true, 'name'=>'IBAN', 'filter'=>'string'),
'bic' => array('required'=>true, 'name'=>'BIC', 'filter'=>'string'),
'charitable' => array('skip_null_check'=>True),
'president' => array('required'=>true, 'name'=>'Vorsitzender', 'skip_null_check'=>True, 'setter'=>'setPresidentId')
);
}
protected function filterPreCheck(&$values)
{
if(is_null($values['charitable']))
$values['charitable'] = false;
else
$values['charitable'] = true;
$values['president'] = (int)($values['president']);
}
protected function filterPrePacking(&$values)
{
$values['president'] = $values['president']->getId();
}
}

View File

@@ -1,23 +0,0 @@
<?php
// No direct access.
defined('_JEXEC') or die;
class ClubsControllerOffer extends AbstractClubsController
{
protected function getNameOfElement()
{
return 'offer';
}
protected function getDataMapping()
{
return array(
'name' => array('required'=>true, 'name'=>'Bezeichnung', 'filter'=>'string')
);
}
}

View File

@@ -1,21 +0,0 @@
<?php
// No direct access.
defined('_JEXEC') or die;
class ClubsControllerPosition extends AbstractClubsController
{
protected function getNameOfElement()
{
return 'position';
}
protected function getDataMapping()
{
return array(
'name'=>array('required'=>true, 'filter'=>'string', 'name'=>'Bezeichung')
);
}
}

View File

@@ -1,119 +1,11 @@
<?php
use Joomla\CMS\Factory;
use Joomla\CMS\MVC\Controller\FormController;
// No direct access.
defined('_JEXEC') or die;
class ClubsControllerUser extends AbstractClubsController
class ClubsControllerUser extends FormController
{
private function checkUserName($username, $obj = null)
{
$id = -1;
if(!is_null($obj))
$id = $obj->getId();
return ClubsUser::isUserNameFree($username, $id);
}
protected function getNameOfElement()
{
return 'user';
}
protected function getDataMapping()
{
return array(
'user'=>array('required'=>true, 'name'=>'Benutzername', 'filter'=>'cmd'),
'pwd'=>array('required'=>false, 'name'=>'Passwort', 'filter'=>'string', 'setter'=>'setPassword'),
'pwdConfirm'=>array('required'=>false, 'name'=>'Passwortwiederholung', 'filter'=>'string', 'setter'=>null),
'name'=>array('required'=>true, 'name'=>'Bürgerlicher Name', 'filter'=>'string'),
'address'=>array('required'=>true, 'name'=>'Adresse', 'filter'=>'string'),
'city'=>array('required'=>true, 'name'=>'Stadt', 'filter'=>'string'),
'mail'=>array('required'=>true, 'name'=>'E-Mail', 'filter'=>'string'),
'phone'=>array('required'=>false, 'name'=>'Telefonnummer', 'filter'=>'string'),
'mobile'=>array('required'=>false, 'name'=>'Handynummer', 'filter'=>'string')
);
}
/**
* {@inheritDoc}
* @see AbstractClubsController::checkData()
*/
protected function checkDataIsValid($values, $isNew, $obj)
{
if(! parent::checkDataIsValid($values, $isNew, $obj))
return false;
// TODO Auto-generated method stub
if(isset($values['pwd']) && strlen($values['pwd']) > 0)
{
$pwd = $values['pwd'];
$pwdConfirm = $values['pwdConfirm'];
if(trim($pwd) != trim($pwdConfirm))
{
Factory::getApplication()->enqueueMessage('Die Passwörter stimmen nicht überein.', 'error');
return false;
}
if(! ClubsUser::checkPasswordStrength(trim($pwd)))
{
Factory::getApplication()->enqueueMessage('Das Passwort ist zu schwach.', 'error');
return false;
}
}
else
{
if($isNew)
{
Factory::getApplication()->enqueueMessage('Für einen neuen Benutzer muss ein Passwort vergeben werden.', 'error');
return false;
}
}
if(! $this->checkUserName(trim($values['user']), $obj))
{
Factory::getApplication()->enqueueMessage('Username ' . $$values['user'] . ' ist nicht gültig.', 'error');
return false;
}
return true;
}
/**
* {@inheritDoc}
* @see AbstractClubsController::filterPrePacking()
*/
protected function filterPrePacking(&$values)
{
parent::filterPrePacking($values);
unset($values['pwd']);
unset($values['pwdConfirm']);
}
/**
* {@inheritDoc}
* @see AbstractClubsController::applyData()
*/
public function applyData($obj, $values)
{
// TODO Auto-generated method stub
$mapping = $this->getDataMapping();
if(strlen($values['pwd']) == 0)
{
unset($values['pwd']);
unset($mapping['pwd']);
}
$this->applyDataToObject($obj, $values, $mapping);
}
}

View File

@@ -0,0 +1,18 @@
<?php
use Joomla\CMS\MVC\Controller\AdminController;
// No direct access.
defined('_JEXEC') or die;
class ClubsControllerUsers extends AdminController
{
public function getModel($name = 'User', $prefix = 'ClubsModel', $config = array('ignore_request' => true))
{
$model = parent::getModel($name, $prefix, $config);
return $model;
}
}

View File

@@ -0,0 +1,76 @@
<?xml version="1.0" encoding="utf-8"?>
<form
addrulepath='/administrator/components/com_clubs/models/rules'
>
<fieldset>
<field
name="id"
type="hidden"
/>
<field
name="user"
type="text"
label="Benutzername"
size="40"
class="inputbox validate-clubusername"
required='true'
validate='clubusername'
message='Benutzername bereits vergeben'
default=""
/>
<field
name="name"
type="text"
label="Bürgerlicher Name"
size="40"
class="inputbox"
required='true'
default=""
/>
<field
name="address"
type="textarea"
label="Adresse"
size="40"
class="inputbox"
required='true'
default=""
/>
<field
name="city"
type="text"
label="Stadt"
size="40"
class="inputbox"
required='true'
default=""
/>
<field
name="mail"
type="text"
label="E-Mail-Adresse"
size="40"
class="inputbox"
required='true'
validate='email'
default=""
/>
<field
name="phone"
type="text"
label="Telefon-Nr."
size="40"
class="inputbox"
default=""
/>
<field
name="mobile"
type="text"
label="Handy-Nr."
size="40"
class="inputbox"
default=""
/>
</fieldset>
</form>

View File

@@ -0,0 +1,96 @@
<?xml version="1.0" encoding="utf-8"?>
<form
addrulepath='/administrator/components/com_clubs/models/rules'
>
<fieldset>
<field
name="id"
type="hidden"
/>
<field
name="user"
type="text"
label="Benutzername"
size="40"
class="inputbox validate-clubusername"
required='true'
validate='clubusername'
message='Benutzername bereits vergeben'
default=""
/>
<field
name="password"
type="password"
label="Passwort"
size="40"
class="inputbox"
required='true'
default=""
/>
<field
name="password-confirm"
type="password"
label="Passwort wiederholen"
size="40"
class="inputbox"
required='true'
validate='equals' field='password-main'
message='Passwoerter stimmen nicht ueberein'
default=""
/>
<field
name="name"
type="text"
label="Bürgerlicher Name"
size="40"
class="inputbox"
required='true'
default=""
/>
<field
name="address"
type="textarea"
label="Adresse"
size="40"
class="inputbox"
required='true'
default=""
/>
<field
name="city"
type="text"
label="Stadt"
size="40"
class="inputbox"
required='true'
default=""
/>
<field
name="mail"
type="text"
label="E-Mail-Adresse"
size="40"
class="inputbox"
required='true'
validate='email'
default=""
/>
<field
name="phone"
type="text"
label="Telefon-Nr."
size="40"
class="inputbox"
default=""
/>
<field
name="mobile"
type="text"
label="Handy-Nr."
size="40"
class="inputbox"
default=""
/>
</fieldset>
</form>

View File

@@ -0,0 +1,41 @@
<?php
use Joomla\CMS\Factory;
use Joomla\CMS\Form\Form;
use Joomla\CMS\Form\FormRule;
use Joomla\Registry\Registry;
// No direct access.
defined('_JEXEC') or die;
class JFormRuleClubUserName extends FormRule
{
public function test(\SimpleXMLElement $element, $value, $group = null, Registry $input = null, Form $form = null)
{
// Get the database object and a new query object.
$db = Factory::getDbo();
$query = $db->getQuery(true);
// Build the query.
$query->select('COUNT(*)')
->from('#__club_users')
->where('user = ' . $db->quote($value));
// Get the extra field check attribute.
$userId = $input->get('id');
$query->where($db->quoteName('id') . ' <> ' . (int) $userId);
// Set and query the database.
$db->setQuery($query);
$duplicate = (bool) $db->loadResult();
if ($duplicate)
{
return false;
}
return true;
}
}

91
src/admin/models/user.php Normal file
View File

@@ -0,0 +1,91 @@
<?php
use Joomla\CMS\Factory;
use Joomla\CMS\MVC\Model\AdminModel;
use Joomla\CMS\Table\Table;
// No direct access.
defined('_JEXEC') or die;
class ClubsModelUser extends AdminModel
{
public function getTable($type = 'User', $prefix = 'ClubsTable', $config = array())
{
return Table::getInstance($type, $prefix, $config);
}
public function getFormNewUser($data = [], $loadData = true)
{
$form = $this->loadForm(
'com_clubs.newuser',
'newuser',
array(
'control' => 'jform',
'load_data' => $loadData
)
);
if (empty($form))
{
return false;
}
return $form;
}
public function getFormChangeUser($data = [], $loadData = true)
{
$form = $this->loadForm(
'com_clubs.changeuser',
'changeuser',
array(
'control' => 'jform',
'load_data' => $loadData
)
);
if (empty($form))
{
return false;
}
return $form;
}
protected function loadFormData()
{
// Check the session for previously entered form data.
$data = Factory::getApplication()->getUserState(
'com_clubs.edit.user.data',
array()
);
if (empty($data))
{
$data = $this->getItem();
}
return $data;
}
protected function prepareTable($table)
{
/* define which columns can have NULL values */
$defnull = array('phone', 'mobile');
foreach ($defnull as $val)
/* define the rules when the value is set NULL */
if (!strlen($table->$val))
$table->$val = NULL;
if(isset($table->password))
{
}
}
function getForm($data = [], $loadData = true)
{}
}

View File

@@ -0,0 +1,22 @@
<?php
use Joomla\CMS\MVC\Model\ListModel;
// No direct access.
defined('_JEXEC') or die;
class ClubsModelUsers extends ListModel
{
public function getListQuery()
{
$db = $this->getDbo();
$q = $db->getQuery(true);
$q->select('*')
->from('#__club_users');
return $q;
}
}

View File

@@ -1,252 +0,0 @@
<?php
// No direct access.
defined('_JEXEC') or die;
class ClubsClub extends AbstractClubsModel
{
protected $id;
protected $name;
protected $address;
protected $city;
protected $homepage;
protected $mail;
protected $iban;
protected $bic;
protected $charitable;
protected $president;
/**
* @return string
*/
public function getAddress()
{
return $this->address;
}
/**
* @return string
*/
public function getCity()
{
return $this->city;
}
/**
* @return string
*/
public function getHomepage()
{
return $this->homepage;
}
/**
* @return string
*/
public function getMail()
{
return $this->mail;
}
/**
* @return string
*/
public function getIban()
{
return $this->iban;
}
/**
* @return string
*/
public function getBic()
{
return $this->bic;
}
/**
* @return bool
*/
public function isCharitable()
{
return $this->charitable;
}
/**
* @return int
*/
public function getPresidentId()
{
return $this->president->getId();
}
/**
* @return ClubsUser
*/
public function getPresident()
{
return $this->president;
}
/**
* @param string $address
*/
public function setAddress( $address)
{
$this->address = $address;
}
/**
* @param string $city
*/
public function setCity($city)
{
$this->city = $city;
}
/**
* @param string $homapge
*/
public function setHomepage($homapge)
{
$this->homepage = $homapge;
}
/**
* @param string $mail
*/
public function setMail($mail)
{
$this->mail = $mail;
}
/**
* @param string $iban
*/
public function setIban($iban)
{
$this->iban = $iban;
}
/**
* @param string $bic
*/
public function setBic($bic)
{
$this->bic = $bic;
}
/**
* @param bool $charitable
*/
public function setCharitable(bool $charitable)
{
$this->charitable = $charitable;
}
/**
* @param int $presidentId
*/
public function setPresidentId(int $presidentId)
{
$this->president = ClubsUser::loadUser($presidentId);
}
/**
* @param ClubsUser $user
*/
public function setPresident(ClubsUser $user)
{
$this->president = $user;
}
/**
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* @param string $name
*/
public function setName($name)
{
$this->name = $name;
}
public static function loadClubs()
{
return self::loadElements(self::tableName, self::className);
}
public static function loadClub($id)
{
return self::loadElement($id, self::tableName, self::className);
}
protected function __construct()
{}
public static function createClub()
{
$club = new ClubsClub();
$club->id = 'new';
return $club;
}
public function getPlaces()
{
return ClubsPlace::loadPlacesOfClub($this->id);
}
public function getOffers()
{
return 0;
}
protected function loadCustomData($assoc)
{
parent::loadCustomData($assoc);
$this->president = ClubsUser::loadUser($assoc['president']);
}
protected function postQuoteFilter(&$values)
{
parent::postQuoteFilter($values);
$values['president'] = $this->president->getId();
}
protected function prepareDelete($dbo)
{}
protected function getDataMappings()
{
return array('name', 'address', 'city', 'homepage', 'mail', 'iban', 'bic', 'charitable', 'president');
}
protected function getRequiredDataMappings()
{
return array('name', 'address', 'city', 'mail', 'iban', 'bic');
}
private const tableName = '#__club_clubs';
private const className = 'ClubsClub';
protected function getTableName()
{
return self::tableName;
}
}

View File

@@ -1,78 +0,0 @@
<?php
// No direct access.
defined('_JEXEC') or die;
class ClubsOffer extends AbstractClubsModel
{
protected $name;
/**
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* @param string $name
*/
public function setName($name)
{
$this->name = $name;
}
protected function __construct()
{}
private const tableName = '#__club_offers';
private const className = 'ClubsOffer';
public static function getFactory()
{
return new class extends AbstractClubsModelFactory {
public function __construct()
{
parent::__construct($this->tableName, $this->className);
}
protected function getJoins($dbo)
{
$ret = array();
return $ret;
}
};
}
public static function loadOffers()
{
return self::loadElements(self::tableName, self::className);
}
public static function loadOffer(int $id)
{
return self::loadElement($id, self::tableName, self::className);
}
public static function createOffer()
{
$offer = new ClubsOffer();
$offer->id = 'new';
return $offer;
}
protected function getDataMappings()
{
return array('name');
}
protected function getTableName()
{
return self::tableName;
}
}

View File

@@ -1,78 +0,0 @@
<?php
// No direct access.
defined('_JEXEC') or die;
class ClubsOfferAssociation extends AbstractClubsModel
{
protected $offerid;
protected $clubid;
public function getOffer()
{
return ClubsOffer::loadOffer($this->offerid);
}
public function getClub()
{
return ClubsClub::loadClub($this->clubid);
}
public function setOffer($offer)
{
$this->offerid = $offer->getId();
}
public function getName()
{
return $this->getOffer()->getName();
}
public function setClub($club)
{
$this->clubid = $club->getId();
}
protected function __construct()
{}
public static function getFactory()
{
return new ClubsOfferAssociationFactory();
}
private const tableName = '#__club_offer_assocs';
private const className = 'ClubsOfferAssociation';
public static function loadOfferAssociationsOfClub($club)
{
$cid = $club->getId();
return self::loadElements(self::tableName, self::className, "clubid = $cid");
// FIXME Use join to make access faster
}
public static function loadOfferAssociation(int $id)
{
return self::loadElement($id, self::tableName, self::className);
}
public static function createOfferAssociation()
{
$offer = new ClubsOfferAssociation();
// $offer->id = 'new';
return $offer;
}
protected function getDataMappings()
{
// return array('name');
}
protected function getTableName()
{
return self::tableName;
}
}

View File

@@ -1,32 +0,0 @@
<?php
// No direct access.
defined('_JEXEC') or die;
class ClubsOfferAssociationFactory extends AbstractClubsModelFactory
{
public function __construct()
{
parent::__construct('#__club_offer_assocs', 'ClubsOfferAssociation');
}
protected function getJoins($dbo)
{
$ret = array();
$ret[] = array(
'name' => '#__club_offers',
'alias' => 'offer',
'on' => 'main.offerid = offer.id',
'select' => 'id as offerId'
);
$ret[] = array(
'name' => '#__club_clubs',
'alias' => 'club',
'on' => 'main.clubid = club.id',
'select' => 'id AS clubId'
);
return $ret;
}
}

View File

@@ -1,113 +0,0 @@
<?php
// No direct access.
defined('_JEXEC') or die;
class ClubsPlace extends AbstractClubsModel
{
protected $name;
protected $address;
protected $area;
protected $clubid;
/**
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* @param string $name
*/
public function setName(string $name)
{
$this->name = $name;
}
/**
* @return string
*/
public function getAddress()
{
return $this->address;
}
/**
* @return string
*/
public function getArea()
{
return $this->area;
}
/**
* @param string $address
*/
public function setAddress(string $address)
{
$this->address = $address;
}
/**
* @param string $area
*/
public function setArea(string $area)
{
$this->area = $area;
}
public function getClub()
{
return ClubsClub::loadClub($this->clubid);
}
public function setClub($club)
{
$this->clubid = $club->getId();
}
protected function __construct()
{}
public static function loadPlaces()
{
return self::loadElements(self::tableName, self::className);
}
public static function loadPlacesOfClub($clubId)
{
return self::loadElements(self::tableName, self::className, "clubid = $clubId");
}
public static function loadPlace(int $id)
{
return self::loadElement($id, self::tableName, self::className);
}
public static function createPlace()
{
$place = new ClubsPlace();
$place->id = 'new';
return $place;
}
protected function getDataMappings()
{
return array('name', 'address', 'area', 'clubid');
}
private const tableName = '#__club_places';
private const className = 'ClubsPlace';
protected function getTableName()
{
return self::tableName;
}
}

View File

@@ -1,66 +0,0 @@
<?php
// No direct access.
defined('_JEXEC') or die;
class ClubsPosition extends AbstractClubsModel
{
protected $name;
/**
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* @param string $name
*/
public function setName(string $name)
{
$this->name = $name;
}
protected function __construct()
{}
private const tableName = '#__club_positions';
private const className = 'ClubsPosition';
public static function loadPositions()
{
return self::loadElements(self::tableName, self::className);
}
// public static function loadPositions($clubId)
// {
// return self::loadElements(self::tableName, self::className, "clubid = $clubId");
// }
public static function loadPosition(int $id)
{
return self::loadElement($id, self::tableName, self::className);
}
public static function createPosition()
{
$position = new ClubsPosition();
$position->id = 'new';
return $position;
}
protected function getDataMappings()
{
return array('name');
}
protected function getTableName()
{
return self::tableName;
}
}

View File

@@ -1,298 +0,0 @@
<?php
use Joomla\CMS\Factory;
// No direct access.
defined('_JEXEC') or die;
class UserInvalidException extends Exception
{}
class PasswordInvalidException extends Exception
{}
class ClubsUser extends AbstractClubsModel
{
protected $user;
protected $password;
protected $name;
protected $address;
protected $city;
protected $mail;
protected $phone;
protected $mobile;
/**
* @return string
*/
public function getMail()
{
return $this->mail;
}
/**
* @param string $mail
*/
public function setMail($mail)
{
$this->mail = $mail;
}
/**
* @return string
*/
public function getUser()
{
return $this->user;
}
/**
* @return string
*/
public function getHash()
{
return $this->password;
}
/**
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* @return string
*/
public function getAddress()
{
return $this->address;
}
/**
* @return string
*/
public function getCity()
{
return $this->city;
}
/**
* @return string
*/
public function getPhone()
{
return $this->phone;
}
/**
* @return string
*/
public function getMobile()
{
return $this->mobile;
}
/**
* @param string $user
*/
public function setUser($user, bool $force = false)
{
if($this->id === 'new')
$valid = self::isUserNameFree($user);
else
$valid = self::isUserNameFree($user, $this->id);
if(!$force && ! $valid)
throw new UserInvalidException();
$this->user = $user;
}
/**
* @param string $hash
*/
public function setPassword(string $password)
{
if(! $this->checkPasswordStrength($password))
throw new PasswordInvalidException();
$this->password = password_hash($password, PASSWORD_DEFAULT);
}
public function isPasswordValid(string $password)
{
$valid = password_verify($password, $this->password);
if($valid)
{
$this->checkForRehashing($password);
}
return $valid;
}
/**
* @param string $name
*/
public function setName($name)
{
$this->name = $name;
}
/**
* @param string $address
*/
public function setAddress($address)
{
$this->address = $address;
}
/**
* @param string $city
*/
public function setCity($city)
{
$this->city = $city;
}
/**
* @param string $phone
*/
public function setPhone($phone)
{
$this->phone = $phone;
}
/**
* @param string $mobile
*/
public function setMobile($mobile)
{
$this->mobile = $mobile;
}
protected function __construct()
{}
private const tableName = '#__club_users';
private const className = 'ClubsUser';
public static function loadUsers()
{
return self::loadElements(self::tableName, self::className);
}
public static function loadUser(int $id)
{
return self::loadElement($id, self::tableName, self::className);
}
public static function createUser()
{
$user = new ClubsUser();
$user->id = 'new';
return $user;
}
private function updateUser()
{
$dbo = Factory::getDbo();
$q = $dbo->getQuery(true);
$vuser = $q->q($this->user);
$vpassword = $q->q($this->password);
$vname = $q->q($this->name);
$vaddress = $q->q($this->address);
$vcity = $q->q($this->city);
$vmail = $q->q($this->mail);
$vphone = empty($this->phone) ? 'NULL' : $q->q($this->phone);
$vmobile = empty($this->mobile) ? 'NULL' : $q->q($this->mobile);
// FIXME Check null vlaues
$q->update('#__club_users')
->set(array(
"user=$vuser",
"password=$vpassword",
"name=$vname",
"address = $vaddress",
"city=$vcity",
"mail=$vmail",
"phone=$vphone",
"mobile=$vmobile"
))
->where("id=". (int) $this->id)
;
$dbo->setQuery($q);
$dbo->execute();
}
private function checkForRehashing(string $password)
{
if($this->id === 'new')
return;
if(password_needs_rehash($this->password, PASSWORD_DEFAULT) || true)
{
$copy = ClubsUser::loadUser($this->id);
$copy->password = password_hash($password, PASSWORD_DEFAULT);
$copy->save();
// $this->password = password_hash($password, PASSWORD_DEFAULT);
// $dbo = Factory::getDbo();
// $q = $dbo->getQuery(true);
// $q->update(self::tableName)->set('password=' . $q->q($this->password))->where('id=' . (int) $this->id);
// $dbo->setQuery($q);
// $dbo->execute();
}
}
public static function isUserNameFree($username, int $id = -1)
{
$db = Factory::getDbo();
$q = $db->getQuery(true);
$q->select('COUNT(*)')->from(self::tableName)
->where('id <> ' . (int) $id)
->where('user = ' . $q->q($username));
$db->setQuery($q);
$db->execute();
$row = $db->loadRow();
return $row[0] == 0;
}
public static function checkPasswordStrength($pwd)
{
if(strlen($pwd) < 6)
return false;
if(preg_match_all('/[A-Z]/', $pwd) === false)
return false;
if(preg_match_all('/[a-z]/', $pwd) === false)
return false;
if(preg_match_all('/[0-9]/', $pwd) === false)
return false;
return true;
}
protected function getDataMappings()
{
return array('user', 'password', 'name', 'address', 'city', 'mail', 'phone', 'mobile');
}
protected function getRequiredDataMappings()
{
return array('user', 'password', 'name', 'address', 'city', 'mail');
}
protected function getTableName()
{
return self::tableName;
}
}

21
src/admin/tables/user.php Normal file
View File

@@ -0,0 +1,21 @@
<?php
use Joomla\CMS\Table\Table;
// No direct access.
defined('_JEXEC') or die;
class ClubsTableUser extends Table
{
function __construct(&$db)
{
parent::__construct('#__club_users', 'id', $db);
}
public function store($updateNulls = false)
{
return parent::store(true);
}
}

View File

@@ -1,87 +0,0 @@
<?php
// No direct access.
use Joomla\CMS\Router\Route;
defined('_JEXEC') or die;
?>
<form method="post" action="<?php echo $this->address; ?>">
<input type='hidden' name='id' value='<?php echo $this->object->getId(); ?>'>
<table>
<tr>
<td>Bezeichnung</td>
<td><input type='text' name='name' value='<?php echo htmlentities($this->object->getName()); ?>'></td>
</tr>
<tr>
<td>Adresse</td>
<td>
<textarea name='address' rows='5'><?php echo htmlentities($this->object->getAddress()); ?></textarea>
</td>
</tr>
<tr>
<td>Stadt</td>
<td><input type='text' name='city' value='<?php echo htmlentities($this->object->getCity()); ?>'></td>
</tr>
<tr>
<td>Homepage</td>
<td><input type='text' name='homepage' value='<?php echo htmlentities($this->object->getHomepage()); ?>'></td>
</tr>
<tr>
<td>E-Mail</td>
<td><input type='text' name='mail' value='<?php echo htmlentities($this->object->getMail()); ?>'></td>
</tr>
<tr>
<td>IBAN</td>
<td><input type='text' name='iban' value='<?php echo htmlentities($this->object->getIban()); ?>'></td>
</tr>
<tr>
<td>BIC</td>
<td><input type='text' name='bic' value='<?php echo htmlentities($this->object->getBic()); ?>'></td>
</tr>
<tr>
<td>Gemeinn&uuml;tzig</td>
<td><input type='checkbox' name='charitable' value='1' <?php echo $this->object->isCharitable() ? 'checked' : ''; ?>></td>
</tr>
<tr>
<td>Vorsitzende/r</td>
<td>
<select name='president'>
<?php foreach($this->users as $u): ?>
<option value='<?php echo $u->getId(); ?>' <?php if ($this->object->getPresident() !== null && $this->object->getPresident()->getId() == $u->getId()) echo 'selected="selected"'; ?>>
<?php echo htmlentities("{$u->getName()}, {$u->getCity()}"); ?>
</option>
<?php endforeach; ?>
</select>
</td>
</tr>
<?php if(! $this->isNew): ?>
<tr>
<td>Angebote</td>
<td>
<?php foreach($this->offers as $o): ?>
<input type='checkbox' name='offers' value='<?php echo $o['offer']->getId(); ?>' <?php if($o['mark']) echo 'checked="checked"';?>>
<?php echo htmlentities($o['offer']->getName()); ?><br />
<?php endforeach; ?>
</td>
</tr>
<tr>
<td>ID</td>
<td><?php echo $this->object->getId(); ?></td>
</tr>
<?php endif; ?>
</table>
<input type='submit' value='Speichern'> <br /><a href='<?php echo Route::_('index.php?option=com_clubs&view=clubs'); ?>'>Zur&uuml;ck zur &Uuml;bersicht</a>
</form>

View File

@@ -1,44 +0,0 @@
<?php
use Joomla\CMS\Toolbar\ToolbarHelper;
// No direct access.
defined('_JEXEC') or die;
JLoader::register("ClubsControllerClub", JPATH_ROOT . "/administrator/components/com_clubs/controllers/club.php");
class ClubsViewClub extends AbstractClubsViewSingle
{
function display($tpl = null)
{
ToolbarHelper::title('Club-Management - Verein');
$this->prepareDisplay();
$this->users = ClubsUser::loadUsers();
if(! $this->isNew)
{
$offers = ClubsOffer::loadOffers();
$currentOffers = $this->object->getOffers();
$this->offers = array_map(function($offer) use ($currentOffers){
$mark = False;
return array('offer'=>$offer, 'mark'=>$mark);
}, $offers);
}
parent::display($tpl);
}
protected function getViewName()
{
return 'club';
}
protected function getElementController()
{
return new ClubsControllerClub();
}
}

View File

@@ -1,36 +0,0 @@
<?php
// No direct access.
use Joomla\CMS\Router\Route;
defined('_JEXEC') or die;
?>
<table class='table table-stiped, table-hover'>
<thead>
<tr>
<th width='30%'>Bezeichnung</th>
<th width='25%'>Stadt</th>
<th width='20%'>Homepage</th>
<th width='25%'>E-Mail</th>
<th width='5%'>L&ouml;schen?</th>
<th width='5%'>id</th>
</tr>
</thead>
<?php foreach($this->clubs as $club): ?>
<?php $link = Route::_('index.php?option=com_clubs&view=club&id=' . $club->getId()); ?>
<?php $url = htmlentities($club->getHomepage()); ?>
<?php $mail = htmlentities($club->getMail()); ?>
<tr>
<td><a href='<?php echo $link; ?>'><?php echo htmlentities($club->getName()); ?></a></td>
<td><?php echo htmlentities($club->getCity()); ?></td>
<td><a href='<?php echo $url; ?>' target='_blank'><?php echo $url; ?></a></td>
<td><a href='mailto:<?php echo $mail; ?>'><?php echo $mail; ?></a></td>
<td><!--<a href='<?php echo Route::_('index.php?option=com_clubs&task=club.delete&id=' . $club->getId()); ?>'>Del</a> --></td>
<td><?php echo htmlentities($club->getId()); ?></td>
</tr>
<?php endforeach; ?>
</table>
<div><a href='<?php echo Route::_('index.php?option=com_clubs&view=club&id=new'); ?>'>Neuen Verein anlegen</a></div>

View File

@@ -1,21 +0,0 @@
<?php
use Joomla\CMS\MVC\View\HtmlView;
use Joomla\CMS\Toolbar\ToolbarHelper;
// No direct access.
defined('_JEXEC') or die;
class ClubsViewClubs extends HtmlView
{
function display($tpl = null)
{
// $this->offers = ClubsOffer::loadOffers();
$this->clubs = ClubsClub::loadClubs();
ToolbarHelper::title('Club-Management - Clubs');
parent::display($tpl);
}
}

View File

@@ -1,27 +0,0 @@
<?php
// No direct access.
use Joomla\CMS\Router\Route;
defined('_JEXEC') or die;
?>
<form method="post" action="<?php echo $this->address; ?>">
<input type='hidden' name='id' value='<?php echo $this->object->getId(); ?>'>
<table>
<tr>
<td>Bezeichnung</td>
<td><input type='text' name='name' value='<?php echo htmlentities($this->object->getName()); ?>'></td>
</tr>
<?php if(! $this->isNew): ?>
<tr>
<td>ID</td>
<td><?php echo $this->object->getId(); ?></td>
</tr>
<?php endif; ?>
</table>
<input type='submit' value='Speichern'> <br /><a href='<?php echo Route::_('index.php?option=com_clubs&view=offers'); ?>'>Zur&uuml;ck zur &Uuml;bersicht</a>
</form>

View File

@@ -1,29 +0,0 @@
<?php
use Joomla\CMS\Toolbar\ToolbarHelper;
// No direct access.
defined('_JEXEC') or die;
JLoader::register("ClubsControllerOffer", JPATH_ROOT . "/administrator/components/com_clubs/controllers/offer.php");
class ClubsViewOffer extends AbstractClubsViewSingle
{
function display($tpl = null)
{
ToolbarHelper::title('Club-Management - Angebot');
parent::display($tpl);
}
protected function getViewName()
{
return 'offer';
}
protected function getElementController()
{
return new ClubsControllerOffer();
}
}

View File

@@ -1,28 +0,0 @@
<?php
// No direct access.
use Joomla\CMS\Router\Route;
defined('_JEXEC') or die;
?>
<table class='table table-stiped, table-hover'>
<thead>
<tr>
<th width='30%'>Bezeichnung</th>
<th width='5%'>L&ouml;schen?</th>
<th width='5%'>id</th>
</tr>
</thead>
<?php foreach($this->offers as $offer): ?>
<?php $link = Route::_('index.php?option=com_clubs&view=offer&id=' . $offer->getId()); ?>
<tr>
<td><a href='<?php echo $link; ?>'><?php echo htmlentities($offer->getName()); ?></a></td>
<td><a href='<?php echo Route::_('index.php?option=com_clubs&task=offer.delete&id=' . $offer->getId()); ?>'>Del</a></td>
<td><?php echo htmlentities($offer->getId()); ?></td>
</tr>
<?php endforeach; ?>
</table>
<div><a href='<?php echo Route::_('index.php?option=com_clubs&view=offer&id=new'); ?>'>Neues Angebot anlegen</a></div>

View File

@@ -1,20 +0,0 @@
<?php
use Joomla\CMS\MVC\View\HtmlView;
use Joomla\CMS\Toolbar\ToolbarHelper;
// No direct access.
defined('_JEXEC') or die;
class ClubsViewOffers extends HtmlView
{
function display($tpl = null)
{
$this->offers = ClubsOffer::loadOffers();
ToolbarHelper::title('Club-Management - Angebote');
parent::display($tpl);
}
}

View File

@@ -1,27 +0,0 @@
<?php
// No direct access.
use Joomla\CMS\Router\Route;
defined('_JEXEC') or die;
?>
<form method="post" action="<?php echo $this->address; ?>">
<input type='hidden' name='id' value='<?php echo $this->object->getId(); ?>'>
<table>
<tr>
<td>Bezeichnung</td>
<td><input type='text' name='name' value='<?php echo htmlentities($this->object->getName()); ?>'></td>
</tr>
<?php if(! $this->isNew): ?>
<tr>
<td>ID</td>
<td><?php echo $this->object->getId(); ?></td>
</tr>
<?php endif; ?>
</table>
<input type='submit' value='Speichern'> <br /><a href='<?php echo Route::_('index.php?option=com_clubs&view=positions'); ?>'>Zur&uuml;ck zur &Uuml;bersicht</a>
</form>

View File

@@ -1,27 +0,0 @@
<?php
use Joomla\CMS\Toolbar\ToolbarHelper;
// No direct access.
defined('_JEXEC') or die;
JLoader::register("ClubsControllerPosition", JPATH_ROOT . "/administrator/components/com_clubs/controllers/position.php");
class ClubsViewPosition extends AbstractClubsViewSingle
{
protected function getViewName()
{
return 'position';
}
protected function getElementController()
{
return new ClubsControllerPosition();
}
function display($tpl = null)
{
ToolbarHelper::title('Club-Management - Position');
parent::display($tpl);
}
}

View File

@@ -1,28 +0,0 @@
<?php
// No direct access.
use Joomla\CMS\Router\Route;
defined('_JEXEC') or die;
?>
<table class='table table-stiped, table-hover'>
<thead>
<tr>
<th width='30%'>Bezeichnung</th>
<th width='5%'>L&ouml;schen?</th>
<th width='5%'>id</th>
</tr>
</thead>
<?php foreach($this->positions as $position): ?>
<?php $link = Route::_('index.php?option=com_clubs&view=position&id=' . $position->getId()); ?>
<tr>
<td><a href='<?php echo $link; ?>'><?php echo htmlentities($position->getName()); ?></a></td>
<td><a href='<?php echo Route::_('index.php?option=com_clubs&task=position.delete&id=' . $position->getId()); ?>'>Del</a></td>
<td><?php echo htmlentities($position->getId()); ?></td>
</tr>
<?php endforeach; ?>
</table>
<div><a href='<?php echo Route::_('index.php?option=com_clubs&view=position&id=new'); ?>'>Neuen Posten anlegen</a></div>

View File

@@ -1,20 +0,0 @@
<?php
use Joomla\CMS\MVC\View\HtmlView;
use Joomla\CMS\Toolbar\ToolbarHelper;
// No direct access.
defined('_JEXEC') or die;
class ClubsViewPositions extends HtmlView
{
function display($tpl = null)
{
$this->positions = ClubsPosition::loadPositions();
ToolbarHelper::title('Club-Management - Positionen');
parent::display($tpl);
}
}

View File

@@ -1,59 +0,0 @@
<?php
use Joomla\CMS\Router\Route;
// No direct access.
defined('_JEXEC') or die;
?>
<form method="post" action="<?php echo $this->address; ?>">
<input type='hidden' name='id' value='<?php echo $this->user->getId(); ?>'>
<table>
<tr>
<td>Username</td>
<td><input type='text' name='user' value='<?php echo htmlentities($this->user->getUser()); ?>'></td>
</tr>
<tr>
<td>Passwort</td>
<td><input type='password' name='pwd' value=''></td>
</tr>
<tr>
<td>Passwort wiederholen</td>
<td><input type='password' name='pwdConfirm' value=''></td>
</tr>
<tr>
<td>Bürgerlicher Name</td>
<td><input type='text' name='name' value='<?php echo htmlentities($this->user->getName()); ?>'></td>
</tr>
<tr>
<td>Adresse</td>
<td>
<textarea rows="4" name='address'><?php echo (htmlentities($this->user->getAddress())); ?></textarea>
</tr>
<tr>
<td>Stadt</td>
<td><input type='text' name='city' value='<?php echo htmlentities($this->user->getCity()); ?>'></td>
</tr>
<tr>
<td>E-Mail</td>
<td><input type='text' name='mail' value='<?php echo htmlentities($this->user->getMail()); ?>'></td>
</tr>
<tr>
<td>Telefon</td>
<td><input type='text' name='phone' value='<?php echo htmlentities($this->user->getPhone()); ?>'></td>
</tr>
<tr>
<td>Handy</td>
<td><input type='text' name='mobile' value='<?php echo htmlentities($this->user->getMobile()); ?>'></td>
</tr>
<?php if(! $this->isNew): ?>
<tr>
<td>ID</td>
<td><?php echo $this->user->getId(); ?></td>
</tr>
<?php endif; ?>
</table>
<input type='submit' value='Speichern'> <br /><a href='<?php echo Route::_('index.php?option=com_clubs&view=users'); ?>'>Zur&uuml;ck zur &Uuml;bersicht</a>
</form>

View File

@@ -0,0 +1,26 @@
<?php
// No direct access.
defined('_JEXEC') or die;
?>
<form action="<?php echo JRoute::_('index.php?option=com_clubs&layout=edit&id=' . (int) $this->item->id); ?>" method="post" name="adminForm" id="adminForm">
<div class="form-horizontal">
<fieldset class="adminform">
<legend><?php echo JText::_('COM_HELLOWORLD_HELLOWORLD_DETAILS'); ?></legend>
<div class="row-fluid">
<div class="span6">
<?php foreach ($this->form->getFieldset() as $field): ?>
<div class="control-group">
<div class="control-label"><?php echo $field->label; ?></div>
<div class="controls"><?php echo $field->input; ?></div>
</div>
<?php endforeach; ?>
</div>
</div>
</fieldset>
</div>
<input type="hidden" name="task" value="helloworld.edit" />
<?php echo JHtml::_('form.token'); ?>
</form>

View File

@@ -1,9 +1,8 @@
<?php
use Joomla\CMS\Factory;
use Joomla\CMS\MVC\View\HtmlView;
use Joomla\CMS\Toolbar\ToolbarHelper;
use Joomla\CMS\Factory;
use Joomla\CMS\Router\Route;
// No direct access.
defined('_JEXEC') or die;
@@ -13,42 +12,50 @@ class ClubsViewUser extends HtmlView
public function display($tpl = null)
{
$input = Factory::getApplication()->input;
$id = $input->get->get('id');
if($id === 'new')
{
$this->address = Route::_('index.php?option=com_clubs&task=user.new');
$this->user = ClubsUser::createUser();
$this->isNew = true;
}
else if(is_numeric($id))
{
$this->address = Route::_('index.php?option=com_clubs&task=user.change');
$this->user = ClubsUser::loadUser((int) $id);
$this->isNew = false;
}
// Get the Data
$this->item = $this->get('Item');
$isNew = ($this->item->id == 0);
if($isNew)
$this->form = $this->get('FormNewUser');
else
throw new Exception('Need a user id.');
$this->form = $this->get('FormChangeUser');
if($input->get->get('data', null, 'json') != null)
// Check for errors.
if (count($errors = $this->get('Errors')))
{
// Restore previous data
$dataurl = $input->get->get('data', null, 'json');
$data = json_decode($dataurl, true);
$this->user->setUser($data['user'], true);
$this->user->setName($data['name']);
$this->user->setAddress($data['address']);
$this->user->setCity($data['city']);
$this->user->setMail($data['mail']);
$this->user->setPhone($data['phone']);
$this->user->setMobile($data['mobile']);
JError::raiseError(500, implode('<br />', $errors));
return false;
}
ToolbarHelper::title('Club-Management - Person');
// Set the toolbar
$this->addToolBar($isNew);
// Display the template
parent::display($tpl);
}
protected function addToolBar($isNew)
{
$input = Factory::getApplication()->input;
// Hide Joomla Administrator Main menu
$input->set('hidemainmenu', true);
if ($isNew)
{
$title = 'Benutzer hinzuf&uuml;gen';
}
else
{
$title = 'Benutzer bearbeiten';
}
ToolbarHelper::title($title, 'user');
ToolbarHelper::save('user.save');
ToolbarHelper::cancel('user.cancel', $isNew ? 'JTOOLBAR_CANCEL' : 'JTOOLBAR_CLOSE');
}
}

View File

@@ -7,29 +7,67 @@ defined('_JEXEC') or die;
?>
<table width='100%' class='table table-stiped, table-hover'>
<thead>
<tr>
<th width='15%'>Benutzername</th>
<th width='20%'>Name</th>
<th width='30%'>Ort</th>
<th width='30%'>E-Mail</th>
<th width='5%'>L&ouml;schen?</th>
<th width='5%'>id</th>
</tr>
</thead>
<?php foreach($this->users as $user): ?>
<?php $link = Route::_('index.php?option=com_clubs&view=user&id=' . $user->getId()); ?>
<tr>
<td><a href='<?php echo $link; ?>'><?php echo htmlentities($user->getUser()); ?></a></td>
<td><a href='<?php echo $link; ?>'><?php echo htmlentities($user->getName()); ?></a></td>
<td><?php echo htmlentities($user->getCity()); ?></td>
<td><a href='mailto:<?php echo htmlentities($user->getMail()); ?>'><?php echo htmlentities($user->getMail()); ?></a></td>
<td><a href='<?php echo Route::_('index.php?option=com_clubs&task=user.delete&id=' . $user->getId()); ?>'>Del</a></td>
<td><?php echo htmlentities($user->getId()); ?></td>
</tr>
<?php endforeach; ?>
</table>
<form action='index.php?option=com_clubs&view=users' method="post" id='adminForm' name='adminForm'>
<div><a href='<?php echo Route::_('index.php?option=com_clubs&view=user&id=new'); ?>'>Neuen Benutzer anlegen</a></div>
<table class="table table-striped table-hover">
<thead>
<tr>
<th width="1%">Nr.</th>
<th width="2%">
<?php echo JHtmlGrid::checkall(); ?>
</th>
<th width="30%">
Name
</th>
<th width="30%">
Ort
</th>
<th width="10%">
Username
</th>
<th width="2%">
Id
</th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="5">
<?php echo $this->pagination->getListFooter(); ?>
</td>
</tr>
</tfoot>
<tbody>
<?php if (!empty($this->users)) : ?>
<?php foreach ($this->users as $i => $row) : ?>
<?php $link = Route::_('index.php?option=com_clubs&task=user.edit&id=' . $row->id); ?>
<tr>
<td>
<?php echo $this->pagination->getRowOffset($i); ?>
</td>
<td>
<?php echo JHtmlGrid::id($i, $row->id); ?>
</td>
<td>
<a href='<?php echo $link; ?>'><?php echo htmlentities($row->name); ?></a>
</td>
<td>
<?php echo htmlentities($row->city); ?>
</td>
<td>
<?php echo htmlentities($row->user); ?>
</td>
<td align="center">
<?php echo $row->id; ?>
</td>
</tr>
<?php endforeach; ?>
<?php endif; ?>
</tbody>
</table>
<input type="hidden" name="task" value=""/>
<input type="hidden" name="boxchecked" value="0"/>
</form>

View File

@@ -6,17 +6,23 @@ use Joomla\CMS\Toolbar\ToolbarHelper;
// No direct access.
defined('_JEXEC') or die;
// JLoader::register("ClubsModelUser", JPATH_ROOT . "/administrator/components/com_clubs/models/user.php");
class ClubsViewUsers extends HtmlView
{
function display($tpl = null)
public function display(string $tpl = null)
{
$this->users = ClubsUser::loadUsers();
ToolbarHelper::title('Club-Management - Personen', 'user');
$this->users = $this->get('Items');
$this->pagination = $this->get('Pagination');
$this->addToolBar();
parent::display($tpl);
}
private function addToolBar()
{
ToolbarHelper::title('Registrierte Benutzer', 'user');
ToolbarHelper::addNew('user.add');
ToolbarHelper::editList('user.edit');
ToolbarHelper::deleteList('', 'users.delete');
}
}

View File

@@ -44,9 +44,9 @@
<administration>
<menu>Vereinsmanagement</menu>
<submenu>
<!-- <menu link='link' view='v'>Test</menu> -->
</submenu>
<!--submenu>
<menu link='link' view='v'>Test</menu>
</submenu>-->
<files from='admin'>
<filename>clubs.php</filename>
<filename>controller.php</filename>

View File

@@ -6,9 +6,6 @@ use Joomla\CMS\Factory;
// No direct access.
defined('_JEXEC') or die;
JLoader::discover('Clubs', JPATH_ROOT . '/administrator/components/com_clubs/mymodels');
JLoader::registerPrefix('AbstractClubs', JPATH_ROOT . '/administrator/components/com_clubs/abstract');
$controller = BaseController::getInstance("Clubs");
$input = Factory::getApplication()->input;

View File

@@ -1,6 +1,7 @@
<?php
use Joomla\CMS\MVC\Controller\BaseController;
use Joomla\CMS\Factory;
// No direct access.
defined('_JEXEC') or die;
@@ -10,11 +11,29 @@ class ClubsController extends BaseController
public function display($cachable = false, $params = array())
{
parent::display($cachable, $params);
$viewName = $this->input->get('view', $this->default_view);
if($this->checkAuth($viewName))
parent::display($cachable, $params);
else
{
Factory::getApplication()->enqueueMessage("Keine Rechte vorhanden. Bitte einloggen.");
$this->setRedirect('?option=com_clubs&view=login');
}
}
public function foo()
private function checkAuth($viewName)
{
echo "dsfh";
if($viewName === null)
return true;
switch($viewName)
{
case 'login':
return true;
default:
return true; // FIXME
}
}
}

View File

@@ -14,10 +14,14 @@
margin: 10px 0px;
}
input.clubs,
textarea.clubs
.clubs_content_row > input.clubs[type="text"],
.clubs_content_row > textarea.clubs,
.clubs_content_row > select.clubs
{
width: 100%;
box-sizing: border-box;
height: auto;
padding: 10px 10px;
}
table.clubs > tbody > tr > th

View File

@@ -0,0 +1,13 @@
<?php
use Joomla\CMS\MVC\Model\BaseDatabaseModel;
// No direct access.
defined('_JEXEC') or die;
class ClubsModelSearchPerson extends BaseDatabaseModel
{
}

View File

@@ -10,7 +10,7 @@ defined('_JEXEC') or die;
class ClubsViewClub extends HtmlView
{
public function display($tpl = null)
public function display(string $tpl = null)
{
// FIXME Insert code from DB
$this->clubid = 43;

View File

@@ -17,7 +17,13 @@ defined('_JEXEC') or die;
<div class='clubs_row'>
<div class='clubs_title_row'>Funktion im Verein</div>
<div class='clubs_content_row'><?php echo $this->userFunction;?></div>
<div class='clubs_content_row'>
<select name="userFunction" class='clubs'>
<?php foreach($this->functions as $f): ?>
<option value='<?php echo $f['functionid']; ?>' <?php if(isset($f['selected']) && $f['selected']) echo 'selected="selected"'; ?>><?php echo htmlentities($f['name']); ?></option>
<?php endforeach; ?>
</select>
</div>
</div>
<div class='clubs_row'>

View File

@@ -11,12 +11,11 @@ defined('_JEXEC') or die;
class ClubsViewClubAssoc extends HtmlView
{
public function display($tpl = null)
public function display(string $tpl = null)
{
// FIXME Insert code from DB
$inp = Factory::getApplication()->input;
$this->personId = 34;
$this->userName = 'Max Muster';
$this->userMail = 'Foo@bar.com';
$this->userPhone = '34';
@@ -28,6 +27,11 @@ class ClubsViewClubAssoc extends HtmlView
$this->mailDedicated = true;
$this->functions = array();
$this->functions[] = array('functionid'=>3, 'name'=>'Vorsitzender', 'selected'=>false);
$this->functions[] = array('functionid'=>4, 'name'=>'2. Vorsitzender', 'selected'=>true);
$this->functions[] = array('functionid'=>5, 'name'=>'Sportwart');
$this->clubname = "Testclub";
$this->address = "Strasse 1\n66123 Ort";
$this->contactperson = "Max Mustermann";
@@ -60,7 +64,7 @@ class ClubsViewClubAssoc extends HtmlView
HTMLHelper::_('jquery.framework');
Factory::getDocument()->addStyleSheet(Uri::base(true) . "components/com_clubs/css/clubs.css");
Factory::getDocument()->addScript(Uri::base(true) . "components/com_clubs/js/assoc.js");
Factory::getDocument()->addScript(Uri::base(true) . "components/com_clubs/views/clubassoc/assoc.js");
parent::display($tpl);
}

View File

@@ -10,7 +10,7 @@ defined('_JEXEC') or die;
class ClubsViewClubData extends HtmlView
{
public function display($tpl = null)
public function display(string $tpl = null)
{
// FIXME Insert code from DB
$this->clubid = 43;

View File

@@ -10,7 +10,7 @@ defined('_JEXEC') or die;
class ClubsViewClubPlace extends HtmlView
{
public function display($tpl = null)
public function display(string $tpl = null)
{
// FIXME Insert code from DB
$this->clubid = 43;

View File

@@ -10,7 +10,7 @@ defined('_JEXEC') or die;
class ClubsViewClubPlaces extends HtmlView
{
public function display($tpl = null)
public function display(string $tpl = null)
{
// FIXME Insert code from DB
$this->clubid = 43;

View File

@@ -10,7 +10,7 @@ defined('_JEXEC') or die;
class ClubsViewSearchPerson extends HtmlView
{
public function display($tpl = null)
public function display(string $tpl = null)
{
// FIXME Insert code from DB
$inp = Factory::getApplication()->input;

View File

@@ -9,7 +9,7 @@ defined('_JEXEC') or die;
class ClubsViewUSerdata extends HtmlView
{
public function display($tpl = null)
public function display(string $tpl = null)
{
Factory::getDocument()->addStyleSheet(Uri::base(true) . 'components/com_clubs/css/clubs.css');
parent::display($tpl);