Compare commits

...

72 Commits

Author SHA1 Message Date
a2eb141d5c Some modifications in the backend from HWK 2019-06-18 14:29:18 +02:00
1d1bde1a8d Removed bug in club model that avoids deletion of all offers 2019-06-17 13:57:01 +02:00
5179ea9de5 Inserted data into frontend from models for some views 2019-06-17 13:56:37 +02:00
759f04d34f Frontend started to implement first page with databse in use 2019-06-14 15:51:40 +02:00
52a5ebea3a Relocation of some code to simplify ACL later 2019-06-14 14:53:37 +02:00
7411516c5b Created router class, named intentionally wrong to keep to from working. 2019-06-14 13:47:14 +02:00
3d9d244b65 Added menu entries for the frontend views 2019-06-13 17:14:02 +02:00
c6708a2e1c Relocated some files 2019-06-13 15:27:36 +02:00
dff733699f Merge branch 'dev/clean-models' into dev/self-backend 2019-06-13 14:40:58 +02:00
b96506c8ae Updated minor modifications 2019-06-13 14:39:49 +02:00
44e90e2adb Installable version created 2019-06-13 13:32:53 +02:00
c95b3c31a6 Preliminary preparations for deployment are set up 2019-06-13 11:02:39 +02:00
28494f6142 User assiciations are changable from within the backend interface from the clubs. 2019-06-12 18:15:06 +02:00
7210dff28c First interactions with controller using ajax done, nothing functional done yet. 2019-06-11 16:36:36 +02:00
404ccf3498 Basic dialog created without useful content yet 2019-06-11 16:35:56 +02:00
150dfd8f60 Visual enhancement of club's presentation 2019-06-11 14:12:37 +02:00
9cef15b4f5 Basic JS insertion successfully done 2019-06-11 14:11:53 +02:00
e3008b8789 Offers can be changed in the backend 2019-06-11 13:54:21 +02:00
40b88859cd Updated user view in order to show referenced clubs 2019-06-05 16:58:23 +02:00
60abc189ec Tidied up controller class 2019-06-05 16:04:30 +02:00
fc85e6b322 Made user controller working mostly. Not everything is tested but seems good 2019-06-05 16:02:36 +02:00
16e7ed0bc0 Simple controllers (offer and position) are workign in the new oo format 2019-06-04 16:51:50 +02:00
616a0b7dd9 Added code after day of work 2019-06-03 15:42:25 +02:00
1b43ab8356 Updated abstract controller to allow common CRUD operations, errors not yet testet 2019-06-03 15:29:08 +02:00
319911d52f Saving of test cases 2019-06-03 14:51:37 +02:00
65ccfe23f7 Corrected all views to the structure 2019-06-03 14:39:09 +02:00
eb704af915 List views updated to new structure 2019-06-03 11:59:36 +02:00
904d31843a Abstract list working in general, tested with single example 2019-06-03 11:35:07 +02:00
dd52d7ca31 Removed redundant code from ole implementation 2019-05-31 14:30:52 +02:00
4ce8fd274d Created models for all database objects 2019-05-31 14:18:34 +02:00
4fa01d4cc0 Added functionality to create joins using OOD 2019-05-29 18:11:14 +02:00
d93a02e779 Made definition of columns based on objects 2019-05-29 17:55:30 +02:00
8dbbb4d245 Updated settings file 2019-05-28 11:13:39 +02:00
5a359ad97a Small changes in the code to make something run again... 2019-05-26 16:15:20 +02:00
92481a62ac Added code to git in order to push for the weekend 2019-05-24 13:33:14 +02:00
dec4bb5165 Changed cacheing of attributes to be useful 2019-05-23 18:15:22 +02:00
7bf2386851 Make deletion atomic using transactions even in case of recursive deletions 2019-05-23 18:05:16 +02:00
e6db7787ef Enhanced deletion script to allow access to db object directly.
This allows the user to choose wheather better issue plain SQL or operate on the objects (suggested)
2019-05-23 17:54:38 +02:00
8b25925ec4 Successfully tested create, update and delete of trivial elements 2019-05-23 17:52:11 +02:00
23941f32d3 Removed bug when saving NULL values 2019-05-22 16:32:21 +02:00
a9caa06e02 Added code to simplify setting values 2019-05-22 16:32:09 +02:00
ed47052a59 Added functionality to allow to remove slave objects in database in case of deletion 2019-05-22 16:18:09 +02:00
d48d7eb853 Added support for optional columns in db 2019-05-22 16:16:26 +02:00
7c18f48b2a 1:n relations have been successfully read. 2019-05-22 16:07:01 +02:00
cb624c19eb Added second class to debug 1:n relation, which is working in general 2019-05-22 15:47:10 +02:00
b868f0fe86 Removed some bugs in abstract class, added testcase 2019-05-22 15:26:24 +02:00
b3e28d7884 Removed minor bug and implemented stub of first class 2019-05-22 14:22:45 +02:00
cb6068bfd6 Prepared work of models to be useful with basic attributes 2019-05-22 14:03:18 +02:00
fd0a0f7f4d Basic model is mainly written, completely untested 2019-05-22 11:35:28 +02:00
51c910e51f Started working on abstract db models from scratch 2019-05-21 17:17:29 +02:00
852f110967 Added all modified files to allow branching 2019-05-21 11:15:41 +02:00
6209d1aca6 Removed bug to allow CRU operation, D not yet tested 2019-05-20 14:57:55 +02:00
f4f59dcc81 Removed some bugs in Imlpementation of club's details 2019-05-20 14:55:27 +02:00
5ce47c288d Created basic backend for club view 2019-05-20 14:22:45 +02:00
4dc78c21af Made clubs view in the backend working generally (no CUD) 2019-05-20 13:02:04 +02:00
f8df0c3fc4 Added first association of clubs. Current structure does not allow for joins. 2019-05-17 15:27:03 +02:00
c459e1d332 Basic model of club created according to abstact model 2019-05-17 14:56:29 +02:00
03df8c8f1a Made user class work with abstract classes 2019-05-17 13:14:39 +02:00
17e737b64c First approach to port user classes to abstract MVC classes as well 2019-04-18 15:59:44 +02:00
47c81d3ce9 Removed bugs in models (syntx errors) and changed Position to use abstract classes 2019-04-18 14:45:07 +02:00
6e1326240b Created abstract structures to keep complexity and code redundancy at bay. 2019-04-18 14:31:13 +02:00
4b2dbff104 Started creating abstract model to simplify writing code 2019-04-17 16:41:46 +02:00
893dc754f0 Inserted basic structure for clubs and models 2019-04-17 16:41:28 +02:00
b08b01689f Removed bug in backend of users 2019-04-17 15:04:40 +02:00
22566986a8 Added backend for position of persons 2019-04-17 15:04:24 +02:00
e801770b80 Added debug script to generate database 2019-04-16 16:11:34 +02:00
0bafe438e2 Created structure to access the offers of the clubs 2019-04-16 16:08:11 +02:00
63caca5b80 TODO Datei erstellt 2019-04-16 15:17:00 +02:00
5f91d76147 Benutzer hinzufuegen und loeschen realisiert. 2019-04-16 15:16:24 +02:00
604ac0e84f Bearbeiten des Benutzers im Backend implementiert 2019-04-16 14:47:23 +02:00
8aaf1bf057 Removed a few bugs in the Frontend regarding incompatible data types (inheritance) 2019-04-15 15:47:07 +02:00
9c407e750f Started work on backend with self-written models 2019-04-15 15:40:10 +02:00
113 changed files with 4414 additions and 163 deletions

View File

@ -1,6 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<buildpath>
<buildpathentry kind="src" path="src"/>
<buildpathentry external="true" kind="lib" path="/home/private/slt/joomla">
<accessrules>
<accessrule kind="nonaccessible" pattern="administrator/components/com_clubs"/>
</accessrules>
</buildpathentry>
<buildpathentry external="true" kind="lib" path="/srv/slt-dev"/>
<buildpathentry kind="con" path="org.eclipse.php.core.LANGUAGE"/>
<buildpathentry external="true" kind="lib" path="/srv/http/slt"/>
</buildpath>

3
.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
/clubs.tar.gz
/slt-update.xml

View File

@ -1,2 +1,2 @@
eclipse.preferences.version=1
include_path=1;/srv/slt-dev
include_path=1;/srv/slt-dev\u00051;/srv/http/slt\u00051;/home/private/slt/joomla

View File

@ -0,0 +1,2 @@
eclipse.preferences.version=1
org.eclipse.php.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8" standalone\="no"?><templates/>

47
Makefile Normal file
View File

@ -0,0 +1,47 @@
# UPDATE_PATH=/srv/slt-update
PACKAGES = clubs.tar.gz
export DL_PREFIX=https://slt.wolf-stuttgart.net/update/com_clubs
RSYNC_OPTIONS=-rltDz --delete --delete-delay --delete-excluded --exclude '.gitignore' --exclude '.dummy'
RSYNC_USER=christian
RSYNC_HOST=hh.wolf-stuttgart.net
DL_PATH=/srv/http/slt/update/com_clubs
all: package
package: $(PACKAGES)
.PHONY: clubs.tar.gz
clubs.tar.gz:
tar czf $@ -C src .
.PHONY: release
release: clubs.tar.gz
./scripts/create-release.sh
.PHONY: release-force
release-force: clubs.tar.gz
./scripts/create-release.sh -f
.PHONY: upload
upload: release
$(MAKE) reupload
.PHONY: slt-update.xml
slt-update.xml:
./scripts/create-update-xml.sh
.PHONY: reupload
reupload: slt-update.xml
@echo Pushing files
@rsync $(RSYNC_OPTIONS) releases/ $(RSYNC_USER)@$(RSYNC_HOST):$(DL_PATH)/files -v
@echo Pushing XML configuration
@rsync $(RSYNC_OPTIONS) slt-update.xml $(RSYNC_USER)@$(RSYNC_HOST):$(DL_PATH)
#
# .PHONY: update
# update: $(PACKAGES)
# cp slt.xml slt1.tar.gz $(UPDATE_PATH)

9
TODO.md Normal file
View File

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

0
releases/.dummy Normal file
View File

BIN
releases/clubs-0.0.1.tar.gz Normal file

Binary file not shown.

1
res/postfix.template Normal file
View File

@ -0,0 +1 @@
</updates>

2
res/prefix.template Normal file
View File

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<updates>

16
res/update.template Normal file
View File

@ -0,0 +1,16 @@
<update>
<name>SLT Vereinsverwaltung</name>
<description>Vereinsportal des saarländischen Tanzsportverbands</description>
<element>com_clubs</element>
<type>component</type>
<client>0</client>
<version>__VERSION__</version>
<downloads>
<downloadurl type="full" format="__FORMAT__">__DOWNLOAD_URL__</downloadurl>
</downloads>
<tags>
<tag>stable</tag>
</tags>
<maintainer>Christian Wolf</maintainer>
<targetplatform name="joomla" version=".*"/>
</update>

23
scripts/create-release.sh Executable file
View File

@ -0,0 +1,23 @@
#!/bin/bash
MAJOR=`cat serial/major`
MINOR=`cat serial/minor`
RELEASE=`cat serial/release`
TOTRELEASE="$MAJOR.$MINOR.$RELEASE"
outname="releases/clubs-$TOTRELEASE.tar.gz"
mkdir -p releases
# First check if the named release exists already
if [ -f "$outname" ]; then
if [ "$1" = '-f' ]; then
echo "Overwriting existing file $outname."
else
echo "The file $outname existes already. Either remove the release from the folder manually or increase the release version."
echo "Aborting."
exit 1
fi
fi
cp clubs.tar.gz "$outname"

23
scripts/create-update-xml.sh Executable file
View File

@ -0,0 +1,23 @@
#!/bin/bash
# DL_PREFIX="https://slt.wolf-stuttgart.net/update/template"
cat res/prefix.template > slt-update.xml
find releases -name clubs-\* | while read f
do
VSTR=`echo "$f" | sed -E 's@releases/clubs-@@; s@^([0-9]+\.[0-9]+\.[0-9]+).*$@\1@'`
FILE=`echo "$f" | sed 's@releases/@@'`
FORMAT=`echo "$f" | sed -E 's@^.*[0-9]+\.[0-9]+\.[0-9]+\.@@'`
sed '
s@__VERSION__@'"$VSTR"'@g;
s@__DOWNLOAD_URL__@'"$DL_PREFIX/files/$FILE"'@g;
s@__FORMAT__@'"$FORMAT"'@g
' res/update.template >> slt-update.xml
done
cat res/postfix.template >> slt-update.xml

1
serial/major Normal file
View File

@ -0,0 +1 @@
0

1
serial/minor Normal file
View File

@ -0,0 +1 @@
0

1
serial/release Normal file
View File

@ -0,0 +1 @@
1

24
sql/init2.sql Normal file
View File

@ -0,0 +1,24 @@
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;

76
sql/init3.sql Normal file
View File

@ -0,0 +1,76 @@
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

@ -0,0 +1,220 @@
<?php
use Joomla\CMS\Factory;
use Joomla\CMS\MVC\Controller\BaseController;
use Joomla\CMS\Router\Route;
// No direct access.
defined('_JEXEC') or die;
class DataParsingException extends Exception {}
class DataInvalidException extends Exception {}
abstract class AbstractClubsController extends BaseController
{
/**
* @return AbstractCommonClubsModelFactory
*/
protected abstract function getFactory();
/**
* @return string The name of the underlying object in lower letters.
*/
protected abstract function getSingleBaseName();
/**
* @return string The name of the view to show a single object
*/
protected function getSingleViewName()
{
return $this->getSingleBaseName();
}
public function new()
{
$factory = $this->getFactory();
$obj = $factory->createNew();
$this->saveToDatabase($obj, 'new');
}
public function change()
{
$app = Factory::getApplication();
$input = $app->input;
$id = (int) $input->post->getInt('id');
$factory = $this->getFactory();
$obj = $factory->loadById($id);
$this->saveToDatabase($obj, $id);
}
/**
* @param AbstractCommonClubsModel $obj
* @param int $id
*/
protected function saveToDatabase($obj, $id)
{
try
{
// Fetch the posted data
$values = $this->loadData($this->additionalData());
$this->filterRaw($values);
// Check the input data
if( ! $this->requiredDataIsAvailable($values) )
throw new DataParsingException();
if( ! $this->rawDataIsValid($values) )
throw new DataParsingException();
$obj->applyAndMergeValues($values, true);
$this->filterObject($obj, $values);
// Do some additional tests by the controller
if( ! $this->objectValid($obj) )
throw new DataInvalidException();
// Check if the object complains about valitity
if( ! $obj->dataIsValid() )
throw new DataInvalidException();
// Do the actual work
$obj->save();
$this->saveAssocs($obj, $values);
// Redirect to the list of objects
$view = $this->getSingleViewName();
$this->setRedirect(Route::_("index.php?option=com_clubs&view={$view}s", false));
}
catch(DataParsingException $e)
{
// FIXME Make this robust (are external refs already dereferenced?)
$view = $this->getSingleViewName();
$obj->setValues($values, true);
$urldata = $obj->pack();
$this->setRedirect(Route::_("index.php?option=com_clubs&view={$view}&id={$id}&data={$urldata}", false));
}
catch(DataInvalidException $e)
{
$view = $this->getSingleViewName();
$urldata = $obj->pack();
$this->setRedirect(Route::_("index.php?option=com_clubs&view={$view}&id={$id}&data={$urldata}", false));
}
}
protected function saveAssocs($obj, $vlaues){}
protected function additionalData()
{
return array();
}
protected function loadData($additionalData)
{
$values = array();
$factory = $this->getFactory();
$input = Factory::getApplication()->input->post;
foreach($factory->getAttributes() as $column)
{
$values[$column->getAlias()] = $column->getFilter()->getFilteredValue($input, $column->getAlias());
}
foreach($additionalData as $k => $v)
{
$values[$k] = $v->getFilteredValue($input, $k);
}
return $values;
}
protected function filterRaw(&$values){}
protected function filterObject($obj){}
protected function objectValid($obj)
{
return true;
}
private function requiredDataIsAvailable($values)
{
$ok = true;
foreach($this->getFactory()->getAttributes() as $column)
{
$filter = $column->getFilter();
if(! $filter->requiredDataAvailable($values[$column->getAlias()]))
{
$fname = $filter->getName();
Factory::getApplication()->enqueueMessage("Das Feld $fname ist obligatorisch.", 'error');
$ok = false;
}
}
return $ok;
}
/**
* @param array $values
* @param AbstractCommonClubsModel $obj
* @return boolean
*/
protected function rawDataIsValid($values)
{
$error = false;
$factory = $this->getFactory();
foreach($factory->getAttributes() as $column)
{
if(! $column->getFilter()->rawValueValid($values[$column->getAlias()]))
{
$fname = $column->getFilter()->getName();
Factory::getApplication()->enqueueMessage("Das Feld $fname ist fehlerhaft.", '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;
}
function delete()
{
$app = Factory::getApplication();
$id = $app->input->get->getInt('id');
$name = $this->getSingleBaseName();
$app->enqueueMessage("Removal of $name with id $id.");
$factory = $this->getFactory();
$element = $factory->loadById($id);
$element->delete();
$view = $this->getSingleViewName();
$this->setRedirect(Route::_("index.php?option=com_clubs&view={$view}s", false));
}
}

View File

@ -0,0 +1,67 @@
<?php
// No direct access.
use Joomla\CMS\MVC\View\HtmlView;
use Joomla\CMS\Router\Route;
defined('_JEXEC') or die;
abstract class AbstractClubsViewList extends HtmlView
{
/**
* @var AbstractCommonClubsModel
*/
protected $objects;
protected $delUrl;
protected $addUrl;
protected $changeUrl;
private $prepared = FALSE;
public function prepareDisplay()
{
$this->prepared = TRUE;
$this->objects = $this->loadObjects();
$baseUrl = "index.php?option=com_clubs";
$viewName = $this->getSingleViewName();
$controllerName = $this->getControllerName();
$this->addUrl = Route::_("$baseUrl&view=$viewName&id=new");
$this->changeUrl = Route::_("$baseUrl&view=$viewName&id=__ID__");
$this->delUrl = Route::_("$baseUrl&task=$controllerName.delete&id=__ID__");
}
public function display($tpl = null)
{
if(!$this->prepared)
$this->prepareDisplay();
parent::display($tpl);
}
protected abstract function getSingleBaseName();
protected function getControllerName()
{
return $this->getSingleBaseName();
}
protected function getSingleViewName()
{
return $this->getSingleBaseName();
}
/**
* @return AbstractCommonClubsModelFactory
*/
protected abstract function getFactory();
protected function loadObjects()
{
$factory = $this->getFactory();
return $factory->loadElements();
}
}

View File

@ -0,0 +1,85 @@
<?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;
/**
* @var AbstractCommonClubsModel
*/
protected $object;
protected $isNew;
protected $id;
private $prepared = FALSE;
public function prepareDisplay()
{
$this->prepared = TRUE;
$input = Factory::getApplication()->input;
$id = $input->get->get('id');
$controllerName = $this->getControllerName();
if($id === 'new')
{
$this->address = Route::_("index.php?option=com_clubs&task={$controllerName}.new");
$this->object = $this->createNewObject();
$this->isNew = true;
}
else if(is_numeric($id))
{
$id = (int) $id;
$this->address = Route::_("index.php?option=com_clubs&task={$controllerName}.change&id=$id");
$this->object = $this->loadObject($id);
$this->isNew = false;
}
else
throw new Exception('Need a valid object id.');
$jsonData = $input->get->get('data', null, 'json');
if($jsonData !== null)
{
$this->object->unpack($jsonData);
}
$this->id = $id;
}
public function display($tpl = null)
{
if(!$this->prepared)
$this->prepareDisplay();
parent::display($tpl);
}
protected abstract function getControllerName();
/**
* @return AbstractCommonClubsModelFactory
*/
protected abstract function getFactory();
protected function createNewObject()
{
$factory = $this->getFactory();
return $factory->createNew();
}
protected function loadObject($id)
{
$factory = $this->getFactory();
return $factory->loadById($id);
}
}

View File

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

View File

@ -0,0 +1,55 @@
<?php
// No direct access.
defined('_JEXEC') or die;
abstract class AbstractCommonClubsControllerMapping
{
protected $required;
protected $name;
public function __construct($name, $required = true)
{
$this->name = $name;
$this->required = $required;
}
/**
* @param mixed $value
* @return bool
*/
public function requiredDataAvailable($value)
{
if($this->required && ($value === null || $value === ''))
return false;
return true;
}
/**
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* @param JInput $input
* @param string $name
* @return string
*/
public abstract function getFilteredValue($input, $name);
/**
* @param mixed $value
* @return boolean
*/
public function rawValueValid($value)
{
return true;
}
}

View File

@ -0,0 +1,385 @@
<?php
use Joomla\CMS\Factory;
// No direct access.
defined('_JEXEC') or die;
abstract class AbstractCommonClubsModel
{
// TODO Add data validator
// TODO Make setting of values attribute fail in case of problems
// FIXME Add Joins in select statements
private $id;
private $new;
public function getId()
{
return $this->id;
}
public function setId($id)
{
$this->id = $id;
}
private $values = null;
protected function getValues($force = false)
{
if(is_null($this->values) || $force)
$this->loadDataFromDatabase();
return $this->values;
}
public function isNew()
{
return $this->new;
}
public function setValues($values, $unpack = false)
{
if($unpack)
$this->values = $this->unpackExternalReferencesFromKeys($values);
else
$this->values = $values;
}
public function applyAndMergeValues($values, $unpack = true)
{
$vals = $this->getValues();
if($unpack)
$vals = $this->packExternalReferencesAsKeys($vals);
foreach($this->getFactory()->getAttributes() as $column)
{
if(array_key_exists($column->getAlias(), $values))
{
$vals[$column->getAlias()] = $values[$column->getAlias()];
}
}
if($unpack)
$vals = $this->unpackExternalReferencesFromKeys($vals);
$this->setValues($vals, false);
}
protected function setValue($key, $value)
{
if(is_null($this->values))
$this->loadDataFromDatabase();
$this->values[$key] = $value;
}
public function markAsNew($new)
{
$this->new = $new;
}
public function fillDefaultValues()
{}
/**
* @return AbstractCommonClubsModelFactory
*/
protected abstract function getFactory();
public function save()
{
$factory = $this->getFactory();
$attribs = $factory->getAttributes();
$db = Factory::getDbo();
$q = $db->getQuery(true);
$db->transactionStart();
if($this->new)
$this->prepareInsert($attribs, $factory, $q);
else
$this->prepareUpdate($attribs, $factory, $q);
$db->setQuery($q);
$db->execute();
if($this->new)
{
$this->finishInsert($db);
}
$db->transactionCommit();
}
private function loadDataFromDatabase()
{
$factory = $this->getFactory();
$attribs = $factory->getAttributes();
$db = Factory::getDbo();
$q = $db->getQuery(true);
foreach($attribs as $a)
{
$a->select($q);
}
$q->from($factory->getTableName());
$q->where("id = {$this->id}");
$joins = $factory->getJoins();
foreach($joins as $j)
{
$j->join($q);
}
$db->setQuery($q);
$db->execute();
$values = $db->loadAssoc();
$values = $this->unpackExternalReferencesFromKeys($values);
$this->values = $values;
}
private function packExternalReferencesAsKeys($vals)
{
foreach($this->getFactory()->getAttributes() as $a)
{
$alias = $a->getAlias();
$vals[$alias] = $a->packValue($vals[$alias]);
}
// XXX Joins
return $vals;
}
private function unpackExternalReferencesFromKeys($vals)
{
$factory = $this->getFactory();
foreach($factory->getAttributes() as $a)
{
$alias = $a->getAlias();
if(isset($vals[$alias]))
$vals[$alias] = $a->unpackValue($vals[$alias]);
}
$joins = $factory->getJoins();
foreach($joins as $join)
{
$join->unpackExternalReferencesFromKeys($vals);
}
return $vals;
}
/**
*
* @param array $rawData
* @param AbstractCommonClubsModelColumn[] $attribs
* @param JDatabaseQuery $q
* @return string[]|number[]|NULL[]
*/
private function quoteData($rawData, $attribs, $q)
{
$quotedData = array();
foreach($attribs as $a)
{
$alias = $a->getAlias();
$quotedData[$alias] = $a->getQuotedValue($q, $rawData[$alias]);
}
return $quotedData;
}
protected function filterDatabaseRawData($values)
{
return $values;
}
protected function filterDatabaseQuotedData($quoted)
{
return $quoted;
}
/**
*
* @param array $attribs
* @param JDatabaseQuery $q
* @return array
*/
private function getQuotedData($attribs, $q)
{
$rawData = $this->getValues();
$rawData = $this->filterDatabaseRawData($rawData);
$quotedData = $this->quoteData($rawData, $attribs, $q);
$quotedData = $this->filterDatabaseQuotedData($quotedData);
return $quotedData;
}
/**
*
* @param AbstractCommonClubsModelColumn[] $attribs
* @param AbstractCommonClubsModelFactory $factory
* @param JDatabaseQuery $q
*/
private function prepareInsert($attribs, $factory, $q)
{
$q->insert($factory->getTableName());
$dbcols = array();
foreach($attribs as $a)
{
$dbcols[] = $a->getColumn();
}
$q->columns($q->qn($dbcols));
$quotedData = $this->getQuotedData($attribs, $q);
$q->values(join(', ', $quotedData));
}
/**
*
* @param JDatabaseDriver $db
*/
private function finishInsert($db)
{
$this->id = $db->insertid();
$this->new = false;
}
/**
*
* @param AbstractCommonClubsModelColumn[] $attribs
* @param AbstractCommonClubsModelFactory $factory
* @param JDatabaseQuery $q
*/
private function prepareUpdate($attribs, $factory, $q)
{
$q->update($factory->getTableName());
$dbcols = array();
foreach($attribs as $a)
$dbcols[] = $a->getColumn();
$quotedData = $this->getQuotedData($attribs, $q);
$q->set(array_map(function($col, $data){
return "$col = $data";
}, $dbcols, $quotedData));
$q->where("id = {$this->id}");
}
/**
*
* @param JDatabaseDriver $db
*/
protected function prepareDelete($db)
{}
public function delete()
{
$db = Factory::getDbo();
$q = $db->getQuery(true);
$factory = $this->getFactory();
$q->delete($factory->getTableName());
$q->where("id = {$this->id}");
$db->transactionStart(true);
$this->prepareDelete($db);
$db->setQuery($q);
$db->execute();
$db->transactionCommit(true);
}
/**
*
* @param AbstractCommonClubsModelFactory $factory
* @param string $colName
* @param array $constraints
*/
protected function fetchAssociatedElements($factory, $colName, $constraints = null, $sorting = null)
{
$condition = "main.$colName = {$this->id}";
if(isset($constraints))
{
if(is_array($constraints))
$allConstraints = clone $constraints;
elseif(is_string($constraints))
$allConstraints = array($constraints);
else
throw new Exception('Unknown type of constraint');
// Add the manual condition to match the current object
$allConstraints[] = $condition;
return $factory->loadElements($allConstraints, $sorting);
}
else
return $factory->loadElements($condition, $sorting);
}
protected function filterPackData($values)
{
return $values;
}
protected function filterUnpackData($values)
{
return $values;
}
/**
* @return string
*/
public function pack()
{
$vals = $this->getValues();
$vals = $this->packExternalReferencesAsKeys($vals);
$vals = $this->filterPackData($vals);
$json = json_encode($vals);
return urlencode($json);
}
/**
* @param string $str
* @param boolean $decode
*/
public function unpack($str, $decode = false)
{
if($decode)
$json = urldecode($str);
else
$json = $str;
$data = json_decode($json, true);
$vals = $this->unpackExternalReferencesFromKeys($data);
$vals = $this->filterUnpackData($vals);
$this->setValues($vals);
}
public function dataIsValid()
{
return true;
}
}

View File

@ -0,0 +1,78 @@
<?php
// No direct access.
defined('_JEXEC') or die;
abstract class AbstractCommonClubsModelColumn
{
protected $alias;
protected $column;
/**
* @var AbstractCommonClubsControllerMapping
*/
protected $filter;
public function getAlias()
{
return $this->alias;
}
public function getColumn()
{
return $this->column;
}
public abstract function isSimpleType();
public function __construct($alias, $filter, $column = null)
{
$this->alias = $alias;
$this->filter = $filter;
if(isset($column))
$this->column = $column;
else
$this->column = $alias;
}
/**
* @param JDatabaseQuery $q
*/
public function select($q)
{
$q->select($q->qn($this->column, $this->alias));
}
/**
*
* @param JDatabaseQuery $q
* @param mixed $value
*/
public abstract function getQuotedValue($q,$value);
/**
*
* @param JDatabaseQuery $q
*/
public function getQuotedColumnName($q)
{
return $q->qn($this->column);
}
public function packValue($value)
{
return $value;
}
public function unpackValue($value)
{
return $value;
}
public function getFilter()
{
return $this->filter;
}
}

View File

@ -0,0 +1,208 @@
<?php
// No direct access.
use Joomla\CMS\Factory;
defined('_JEXEC') or die;
class ElementNotFoundException extends Exception
{}
abstract class AbstractCommonClubsModelFactory
{
// TODO Attribures as objects allowing to use polymophism in filtering/parsing/checking/sql building
/*
* This method should return an array to configure the trivially accessible values.
* The key must be a unique key describing the information and will be reused in the getValues() method.
* The value of each key should be an associative array describing the object field.
* Example of an array returned by this method is
* array(
* 'name'=>array('col'=>'Name', type=>'string'),
* 'size'=>array('col'=>'area', type=>'int')
* )
*
* The inner arrays contain the following entries:
* - col: The name of the column in the database. Defaults to the key name
* - type: The type of the column. If nothing is specified, string is assumed.
* - string
* - int
* - float
* - ref
* - optional: boolean, if true, the field can be NULL
* - ref: (only with type='ref') The name of the class that is referenced
*/
protected abstract function fetchAttributes();
private $attributes = null;
/**
* @param boolean $force
* @return AbstractCommonClubsModelColumn[]
*/
public function getAttributes($force = False)
{
if($this->attributes === null || $force)
$this->attributes = $this->fetchAttributes();
return $this->attributes;
}
public abstract function getTableName();
public abstract function getClassName();
// TODO Als Klassen formulieren
/*
* This method returns the relevant join operations on the data.
* The return value is an associated arrray whose keys are the names of the tables in the join.
* Each value of such joins is again an associative array.
* These arrays have the following entries:
* - alias: The alias name of the table to use. Mandatory
* - type: The type of the join. Can be inner, left, right or outer. Defaults to inner.
* - on: Join constraint as a string representation.
* - cols: The columns to insert in the query. Same structure as fetchAttributes() method
*
* Example:
* array(
* 'mytable'=>array(
* 'alias'=>'t1',
* 'type'=>'left',
* 'on'=>'main.id = t1.clubid',
* 'cols'=>array(
* 'name'=>array(),
* 'count'=>array('type'=>'int', 'col'=>'numElements'
* )
* )
* )
*/
protected function fetchJoins()
{
return array();
}
private $joins = null;
/**
* @return AbstractCommonClubsModelJoin[]
*/
public function getJoins($force = False)
{
if($this->joins === null || $force)
$this->joins = $this->fetchJoins();
return $this->joins;
}
/**
*
* @param string $condition
* @param string|array $sorting
* @return AbstractCommonClubsModel[]
*/
public function loadElements($condition = null, $sorting = null, $callback = null)
{
$db = Factory::getDbo();
$q = $db->getQuery(true);
// $columns = array_map(function($arr) use ($q){ return $q->qn('main' . $arr['col']); }, $this->fetchAttributes());
// $columns = array();
// foreach($this->fetchAttributes() as $k=>$v)
// {
// $columns[] = $q->qn('main' . $v['col'], $k);
// }
$q->select('main.id AS id');//->select($columns);
$q->from($this->getTableName() . ' AS main');
if($condition !== null)
$q->where($condition);
if($sorting !== null)
$q->order($sorting);
if($callback !== null)
{
$callback($q);
}
$db->setQuery($q);
$db->execute();
$rows = $db->loadAssocList();
$ret = array();
foreach($rows as $row)
{
$ret[] = $this->generateObject($row);
}
return $ret;
}
/**
* @param int $id
* @return AbstractCommonClubsModel
*/
public function loadById($id, $throwErr = true)
{
$arr = $this->loadElements("main.id = " . ((int)$id) );
if(sizeof($arr) == 0)
{
if($throwErr)
throw new ElementNotFoundException();
else
return null;
}
return $arr[0];
}
private function generatePlainObject($id)
{
$name = $this->getClassName();
$obj = new $name();
$obj->setId($id);
return $obj;
}
/**
* @param array $row
* @return AbstractCommonClubsModel
*/
protected function generateObject($row)
{
$obj = $this->generatePlainObject($row['id']);
$obj->markAsNew(false);
//unset($row['id']);
//$obj->setValues($row);
// Do not trigger cache if no needed
//$obj->getValues();
return $obj;
}
/**
* @return AbstractCommonClubsModel
*/
public function createNew()
{
$obj = $this->generatePlainObject('new');
$obj->markAsNew(true);
$values = array();
foreach($this->getAttributes() as $a)
{
$values[$a->getAlias()] = null;
}
// $attribs = array_map(function($v){
// return Null;
// }, $this->getAttributes());
$obj->setValues($values);
$obj->fillDefaultValues();
return $obj;
}
}

View File

@ -0,0 +1,84 @@
<?php
// No direct access.
defined('_JEXEC') or die;
abstract class AbstractCommonClubsModelJoin
{
protected $tablename;
protected $alias;
protected $condition;
/**
* @var AbstractCommonClubsModelColumn[]
*/
protected $columns;
public function __construct($alias, $condition, $colums, $tablename = null)
{
/// XXX Some checks need to be performed
$this->alias = $alias;
$this->condition = $condition;
$this->columns = $colums;
if(empty($tablename))
$this->tablename = $alias;
else
$this->tablename = $alias;
}
public function getAlias()
{
return $this->alias;
}
public function getTableName()
{
return $this->tablename;
}
public function getOnCondition()
{
return $this->condition;
}
public function getColumns()
{
return $this->columns;
}
/**
*
* @param JDatabaseQuery $q
*/
public function join($q)
{
$str = "{$this->tablename} AS {$this->alias}";
if(isset($this->condition))
$str .= " ON {$this->condition}";
$this->addJoin($q, $str);
foreach($this->columns as $c)
{
$qc = $q->q("{$this->alias}." . $c->getColumn(), $c->getAlias());
$q->select($qc);
}
}
/**
*
* @param JDatabaseQuery $q
* @param String $str
*/
protected abstract function addJoin($q, $str);
public function unpackExternalReferencesFromKeys(&$vals)
{
foreach($this->columns as $col)
{
$alias = $col->getAlias();
$vals[$alias] = $col->unpackValue($vals[$alias]);
}
}
}

View File

@ -0,0 +1,14 @@
<?php
// No direct access.
defined('_JEXEC') or die;
class CommonClubsControllerMappingCmd extends AbstractCommonClubsControllerMapping
{
public function getFilteredValue($input, $name)
{
return $input->getCmd($name);
}
}

View File

@ -0,0 +1,14 @@
<?php
// No direct access.
defined('_JEXEC') or die;
class CommonClubsControllerMappingFloat extends AbstractCommonClubsControllerMapping
{
public function getFilteredValue($input, $name)
{
return $input->getFloat($name);
}
}

View File

@ -0,0 +1,14 @@
<?php
// No direct access.
defined('_JEXEC') or die;
class CommonClubsControllerMappingInt extends AbstractCommonClubsControllerMapping
{
public function getFilteredValue($input, $name)
{
return $input->getInt($name);
}
}

View File

@ -0,0 +1,44 @@
<?php
// No direct access.
defined('_JEXEC') or die;
class CommonClubsControllerMappingRef extends AbstractCommonClubsControllerMapping
{
/**
* @var AbstractCommonClubsModelFactory
*/
protected $factory;
/**
* @param string $name
* @param AbstractCommonClubsModelFactory $factory
* @param boolean $required
*/
public function __construct($name, $factory, $required = true)
{
parent::__construct($name, $required);
$this->factory = $factory;
}
public function getFilteredValue($input, $name)
{
return $input->getInt($name);
}
public function rawValueValid($value)
{
try
{
$this->factory->loadById((int) $value);
}
catch(ElementNotFoundException $e)
{
return false;
}
return true;
}
}

View File

@ -0,0 +1,14 @@
<?php
// No direct access.
defined('_JEXEC') or die;
class CommonClubsControllerMappingString extends AbstractCommonClubsControllerMapping
{
public function getFilteredValue($input, $name)
{
return $input->getString($name);
}
}

View File

@ -0,0 +1,160 @@
<?php
// No direct access.
defined('_JEXEC') or die;
class CommonClubsModelClub extends AbstractCommonClubsModel
{
protected function getFactory()
{
return new CommonClubsModelFactoryClub();
}
public function getName()
{
return $this->getValues()['name'];
}
public function getAddress()
{
return $this->getValues()['address'];
}
public function getCity()
{
return $this->getValues()['city'];
}
public function getHomepage()
{
return $this->getValues()['homepage'];
}
public function getMail()
{
return $this->getValues()['mail'];
}
public function getIban()
{
return $this->getValues()['iban'];
}
public function getBic()
{
return $this->getValues()['bic'];
}
public function isCharitable()
{
return $this->getValues()['charitable'];
}
public function getPresident()
{
return $this->getValues()['president'];
}
public function getPlaces()
{
return $this->fetchAssociatedElements(new CommonClubsModelFactoryPlace(), 'clubid');
}
private function getOfferAssocs()
{
return $this->fetchAssociatedElements(new CommonClubsModelFactoryOfferassoc(), 'clubid');
}
public function getOffers()
{
$assocs = $this->getOfferAssocs();
$offersFactory = new CommonClubsModelFactoryOffer();
$allOffers = $offersFactory->loadElements();
$ret = array();
foreach($allOffers as $offer)
{
$arr = array(
'offer' => $offer,
'valid' => false
);
$id = $offer->getId();
foreach($assocs as $a)
{
$oid = $a->getOffer()->getId();
if($id === $oid)
{
$arr['valid'] = true;
break;
}
}
$ret[] = $arr;
}
return $ret;
}
/**
* @param int[] $ids
*/
public function setOfferIds($ids)
{
if(empty($ids))
$ids = array();
$dbo = $this->getFactory()->loadById($this->getId());
$currentOffersAssocs = $dbo->getOfferAssocs();
$currentIds = array_map(function($obj){
return $obj->getOffer()->getId();
}, $currentOffersAssocs);
$newIds = array_diff($ids, $currentIds);
$delIds = array_diff($currentIds, $ids);
$offerAssocFactory = new CommonClubsModelFactoryOfferassoc();
$offerFactory = new CommonClubsModelFactoryOffer();
foreach($delIds as $id)
{
$delId = (int) $id;
$delObjs = $offerAssocFactory->loadElements("clubid = {$this->getId()} AND offerid = $delId");
foreach($delObjs as $o)
$o->delete();
}
foreach($newIds as $id)
{
$newId = (int) $id;
$o = $offerAssocFactory->createNew();
$o->setOffer($offerFactory->loadById($newId));
$o->setClub($this);
$o->save();
}
}
public function getUsers()
{
return $this->fetchAssociatedElements(new CommonClubsModelFactoryUserassoc(), 'clubid');
}
protected function prepareDelete($db)
{
$q = $db->getQuery(true);
$q->delete('#__club_user_assocs')->where("clubid = {$this->getId()}");
$db->setQuery($q);
$db->execute();
$q = $db->getQuery(true);
$q->delete('#__club_places')->where("clubid = {$this->getId()}");
$db->setQuery($q);
$db->execute();
$q = $db->getQuery(true);
$q->delete('#__club_offer_assocs')->where("clubid = {$this->getId()}");
$db->setQuery($q);
$db->execute();
}
}

View File

@ -0,0 +1,22 @@
<?php
// No direct access.
defined('_JEXEC') or die;
class CommonClubsModelColumnFloat extends AbstractCommonClubsModelColumn
{
public function isSimpleType()
{
return true;
}
public function getQuotedValue($q, $value)
{
if(is_null($value))
return 'NULL';
else
return (float) $value;
}
}

View File

@ -0,0 +1,22 @@
<?php
// No direct access.
defined('_JEXEC') or die;
class CommonClubsModelColumnInt extends AbstractCommonClubsModelColumn
{
public function isSimpleType()
{
return true;
}
public function getQuotedValue($q, $value)
{
if(is_null($value))
return 'NULL';
else
return (int) $value;
}
}

View File

@ -0,0 +1,105 @@
<?php
// No direct access.
defined('_JEXEC') or die;
class WrongRefTypeException extends Exception
{}
class AssociatedObjectUnsavedException extends Exception
{}
class CommonClubsModelColumnRef extends AbstractCommonClubsModelColumn
{
protected $className;
public function __construct($alias, $className, $column, $filter)
{
parent::__construct($alias, $filter, $column);
if(empty($className))
throw new Exception('Classname must be non-empty.');
$this->className = $className;
}
public function isSimpleType()
{
return false;
}
public function getQuotedValue($q, $value)
{
if(is_null($value))
return 'NULL';
else
{
if(! ( $value instanceof $this->className ) )
throw new WrongRefTypeException();
$id = $value->getId();
if($id === 'new')
throw new AssociatedObjectUnsavedException();
return $id;
}
}
public function packValue($value)
{
if(is_null($value))
return null;
if(! ($value instanceof $this->className) )
throw new WrongRefTypeException();
$id = $value->getId();
if($id === 'new')
throw new AssociatedObjectUnsavedException();
return (int) $id;
}
public function unpackValue($value)
{
if(empty($value))
return null;
if(is_string($value) && preg_match('/^[0-9]+$/', $value))
$value = (int) $value;
if(! is_int($value))
throw new Exception('Reference with non-integer value');
$factoryName = $this->getFactoryNameOfClass($this->className); // XXX Use attribute?
$factory = new $factoryName();
return $factory->loadById($value);
}
private const CLASSNAME_MAP = array(
);
/**
* @todo This must be done better and more cleanly
* @param string $className
* @return AbstractCommonClubsModelFactory
*/
private function getFactoryNameOfClass($className)
{
if(empty(self::CLASSNAME_MAP[$className]))
{
$parts = array();
if(preg_match('/^CommonClubsModel(.*)/', $className, $parts))
{
return "CommonClubsModelFactory{$parts[1]}";
}
throw new Exception("Unknown mapping of class $className");
}
return self::CLASSNAME_MAP[$className];
}
}

View File

@ -0,0 +1,22 @@
<?php
// No direct access.
defined('_JEXEC') or die;
class CommonClubsModelColumnString extends AbstractCommonClubsModelColumn
{
public function isSimpleType()
{
return true;
}
public function getQuotedValue($q, $value)
{
if(is_null($value))
return 'NULL';
else
return $q->q($value);
}
}

View File

@ -0,0 +1,34 @@
<?php
// No direct access.
defined('_JEXEC') or die;
class CommonClubsModelFactoryClub extends AbstractCommonClubsModelFactory
{
public function fetchAttributes()
{
return array(
new CommonClubsModelColumnString('name', new CommonClubsControllerMappingString('Clubname')),
new CommonClubsModelColumnString('address', new CommonClubsControllerMappingString('Adresse')),
new CommonClubsModelColumnString('city', new CommonClubsControllerMappingString('Stadt')),
new CommonClubsModelColumnString('homepage', new CommonClubsControllerMappingString('Homepaage', false)),
new CommonClubsModelColumnString('mail', new CommonClubsControllerMappingString('E-Mail')),
new CommonClubsModelColumnString('iban', new CommonClubsControllerMappingCmd('IBAN')),
new CommonClubsModelColumnString('bic', new CommonClubsControllerMappingCmd('BIC')),
new CommonClubsModelColumnInt('charitable', new CommonClubsControllerMappingInt('Gemeinnützigkeit')),
new CommonClubsModelColumnRef('president', 'CommonClubsModelUser', 'president', new CommonClubsControllerMappingRef('Vorsitzender', new CommonClubsModelFactoryUser()))
);
}
public function getTableName()
{
return '#__club_clubs';
}
public function getClassName()
{
return 'CommonClubsModelClub';
}
}

View File

@ -0,0 +1,24 @@
<?php
// No direct access.
defined('_JEXEC') or die;
class CommonClubsModelFactoryOffer extends AbstractCommonClubsModelFactory
{
protected function fetchAttributes()
{
return array(
new CommonClubsModelColumnString('name', new CommonClubsControllerMappingString('Bezeichnung'))
);
}
public function getTableName()
{
return '#__club_offers';
}
public function getClassName()
{
return 'CommonClubsModelOffer';
}
}

View File

@ -0,0 +1,25 @@
<?php
// No direct access.
defined('_JEXEC') or die;
class CommonClubsModelFactoryOfferassoc extends AbstractCommonClubsModelFactory
{
protected function fetchAttributes()
{
return array(
new CommonClubsModelColumnRef('club', 'CommonClubsModelClub', 'clubid', new CommonClubsControllerMappingRef('Club', new CommonClubsModelFactoryClub())),
new CommonClubsModelColumnRef('offer', 'CommonClubsModelOffer', 'offerid', new CommonClubsControllerMappingRef('Angebot', new CommonClubsModelFactoryOffer()))
);
}
public function getTableName()
{
return '#__club_offer_assocs';
}
public function getClassName()
{
return 'CommonClubsModelOfferassoc';
}
}

View File

@ -0,0 +1,28 @@
<?php
// No direct access.
defined('_JEXEC') or die;
class CommonClubsModelFactoryPlace extends AbstractCommonClubsModelFactory
{
public function fetchAttributes()
{
return array(
new CommonClubsModelColumnString('name', new CommonClubsControllerMappingString('Bezeichnung')),
new CommonClubsModelColumnRef('club', 'CommonClubsModelClub', 'clubid', new CommonClubsControllerMappingRef('Club', new CommonClubsModelFactoryClub())),
new CommonClubsModelColumnInt('area', new CommonClubsControllerMappingInt('Fläche', false))
);
}
public function getTableName()
{
return '#__club_places';
}
public function getClassName()
{
return 'CommonClubsModelPlace';
}
}

View File

@ -0,0 +1,25 @@
<?php
// No direct access.
defined('_JEXEC') or die;
class CommonClubsModelFactoryPosition extends AbstractCommonClubsModelFactory
{
protected function fetchAttributes()
{
return array(
new CommonClubsModelColumnString('name', new CommonClubsControllerMappingString('Bezeichnung'))
);
}
public function getTableName()
{
return '#__club_positions';
}
public function getClassName()
{
return 'CommonClubsModelPosition';
}
}

View File

@ -0,0 +1,33 @@
<?php
// No direct access.
defined('_JEXEC') or die;
class CommonClubsModelFactoryUser extends AbstractCommonClubsModelFactory
{
public function fetchAttributes()
{
return array(
new CommonClubsModelColumnString('user', new CommonClubsControllerMappingCmd('Benutzername')),
new CommonClubsModelColumnString('name', new CommonClubsControllerMappingString('Bürgerlicher Name')),
new CommonClubsModelColumnString('password', new CommonClubsControllerMappingString('Passwort', false)),
new CommonClubsModelColumnString('address', new CommonClubsControllerMappingString('Adresse')),
new CommonClubsModelColumnString('city', new CommonClubsControllerMappingString('Stadt')),
new CommonClubsModelColumnString('mail', new CommonClubsControllerMappingString('E-Mail')),
new CommonClubsModelColumnString('phone', new CommonClubsControllerMappingString('Telefonnummer', false)),
new CommonClubsModelColumnString('mobile', new CommonClubsControllerMappingString('Handynummer', false))
);
}
public function getTableName()
{
return '#__club_users';
}
public function getClassName()
{
return 'CommonClubsModelUser';
}
}

View File

@ -0,0 +1,33 @@
<?php
// No direct access.
defined('_JEXEC') or die;
class CommonClubsModelFactoryUserassoc extends AbstractCommonClubsModelFactory
{
protected function fetchAttributes()
{
return array(
new CommonClubsModelColumnRef('user', 'CommonClubsModelUser', 'userid', new CommonClubsControllerMappingRef('User', new CommonClubsModelFactoryUser())),
new CommonClubsModelColumnRef('club', 'CommonClubsModelClub', 'clubid', new CommonClubsControllerMappingRef('Club', new CommonClubsModelFactoryClub())),
new CommonClubsModelColumnRef('position', 'CommonClubsModelPosition', 'positionid', new CommonClubsControllerMappingRef('Position', new CommonClubsModelFactoryPosition())),
new CommonClubsModelColumnInt('admin', new CommonClubsControllerMappingInt('Admin')),
new CommonClubsModelColumnString('address', new CommonClubsControllerMappingString('Adresse', false)),
new CommonClubsModelColumnString('mail', new CommonClubsControllerMappingString('E-Mail', false)),
new CommonClubsModelColumnString('phone', new CommonClubsControllerMappingString('Telefonnummer', false)),
new CommonClubsModelColumnString('state', new CommonClubsControllerMappingString('Status'))
// -> `state` enum('regular', 'vacant', 'temporary') NOT NULL DEFAULT 'vacant',
);
}
public function getTableName()
{
return '#__club_user_assocs';
}
public function getClassName()
{
return 'CommonClubsModelUserassoc';
}
}

View File

@ -0,0 +1,12 @@
<?php
// No direct access.
defined('_JEXEC') or die;
class CommonClubsModelJoinInner extends AbstractCommonClubsModelJoin
{
protected function addJoin($q, $str)
{
$q->innerJoin($str);
}
}

View File

@ -0,0 +1,12 @@
<?php
// No direct access.
defined('_JEXEC') or die;
class CommonClubsModelJoinLeft extends AbstractCommonClubsModelJoin
{
protected function addJoin($q, $str)
{
$q->leftJoin($str);
}
}

View File

@ -0,0 +1,12 @@
<?php
// No direct access.
defined('_JEXEC') or die;
class CommonClubsModelJoinOuter extends AbstractCommonClubsModelJoin
{
protected function addJoin($q, $str)
{
$q->outerJoin($str);
}
}

View File

@ -0,0 +1,12 @@
<?php
// No direct access.
defined('_JEXEC') or die;
class CommonClubsModelJoinRight extends AbstractCommonClubsModelJoin
{
protected function addJoin($q, $str)
{
$q->rightJoin($str);
}
}

View File

@ -0,0 +1,37 @@
<?php
// No direct access.
defined('_JEXEC') or die;
class CommonClubsModelOffer extends AbstractCommonClubsModel
{
protected function getFactory()
{
return new CommonClubsModelFactoryOffer();
}
public function getName()
{
return $this->getValues()['name'];
}
public function setName($name)
{
$this->setValue('name', $name);
}
/*public function getClubs()
{
return $this->fetchAssociatedElements(new CommonClubsModelFactoryClub(), '');
}*/
protected function prepareDelete($db)
{
$q = $db->getQuery(true);
$q->delete('#__club_offer_assocs');
$q->where("offerid = {$this->getId()}");
$db->setQuery($q);
$db->execute();
}
}

View File

@ -0,0 +1,49 @@
<?php
// No direct access.
defined('_JEXEC') or die;
class CommonClubsModelOfferassoc extends AbstractCommonClubsModel
{
protected function getFactory()
{
return new CommonClubsModelFactoryOfferassoc();
}
/**
*
* @return CommonClubsModelClub
*/
public function getClub()
{
return $this->getValues()['club'];
}
/**
*
* @param CommonClubsModelClub $club
*/
public function setClub($club)
{
$this->setValue('club', $club);
}
/**
*
* @return CommonClubsModelOffer
*/
public function getOffer()
{
return $this->getValues()['offer'];
}
/**
*
* @param CommonClubsModelOffer $offer
*/
public function setOffer($offer)
{
$this->setValue('offer', $offer);
}
}

View File

@ -0,0 +1,43 @@
<?php
// No direct access.
defined('_JEXEC') or die;
class CommonClubsModelPlace extends AbstractCommonClubsModel
{
protected function getFactory()
{
return new CommonClubsModelFactoryPlace();
}
public function getName()
{
return $this->getValues()['name'];
}
public function getClub()
{
return $this->getValues()['club'];
}
public function getArea()
{
return $this->getValues()['area'];
}
public function setName($name)
{
$this->setValue('name', $name);
}
public function setArea($area)
{
$this->setValue('area', $area);
}
public function setClub($club)
{
$this->setValue('club', $club);
}
}

View File

@ -0,0 +1,32 @@
<?php
// No direct access.
defined('_JEXEC') or die;
class CommonClubsModelPosition extends AbstractCommonClubsModel
{
protected function getFactory()
{
return new CommonClubsModelFactoryPosition();
}
public function getName()
{
return $this->getValues()['name'];
}
public function setName($name)
{
$this->setValue('name', $name);
}
protected function prepareDelete($db)
{
$q = $db->getQuery(true);
$q->delete('#__club_user_assocs');
$q->where("positionid = {$this->getId()}");
$db->setQuery($q);
$db->execute();
}
}

View File

@ -0,0 +1,221 @@
<?php
// No direct access.
defined('_JEXEC') or die;
class CommonClubsModelUser extends AbstractCommonClubsModel
{
protected function getFactory()
{
return new CommonClubsModelFactoryUser();
}
public function getName()
{
return $this->getValues()['name'];
}
public function setName($name)
{
$this->setValue('name', $name);
}
public function getUsername()
{
return $this->getValues()['user'];
}
public function setUsername($user)
{
// XXX Check for validity
$this->setValue('user', $user);
}
public function getAddress()
{
return $this->getValues()['address'];
}
public function setAddress($address)
{
$this->setValue('address', $address);
}
public function getCity()
{
return $this->getValues()['city'];
}
public function setCity($city)
{
$this->setValue('city', $city);
}
public function getMail()
{
return $this->getValues()['mail'];
}
public function setMail($mail) {
$this->setValue('mail', $mail);
}
public function getPhone()
{
return $this->getValues()['phone'];
}
public function setPhone($phone)
{
$this->setValue('phone', $phone);
}
public function getMobile()
{
return $this->getValues()['mobile'];
}
public function setMobile($mobile)
{
$this->setValue('mobile', $mobile);
}
public function isPasswordValid($password)
{
$hash = $this->getValues()['password'];
if(password_verify($password, $hash))
return true;
else
return false;
}
public function checkRehashNeeded($newPassword, $check = false)
{
$hash = $this->getValues()['password'];
if(password_needs_rehash($hash, PASSWORD_DEFAULT))
{
if($check)
{
if(! $this->isPasswordValid($newPassword))
throw new Exception('Password did not match.');
}
$this->setPassword($newPassword);
return true;
}
else
return false;
}
public function setPassword($password)
{
$hash = password_hash($password, PASSWORD_DEFAULT);
$this->setValue('password', $hash);
}
public function isPasswordSet()
{
$password = $this->getValues()['password'];
return isset($password) && strlen($password) > 0;
}
public function getPositions()
{
return $this->fetchAssociatedElements(new CommonClubsModelFactoryUserassoc(), 'userid');
}
public function getPresidentClubs()
{
return $this->fetchAssociatedElements(new CommonClubsModelFactoryClub(), 'president');
}
public function isPasswordSuitable($password)
{
if(strlen($password) < 8)
return false;
$pwdLower = strtolower($password);
$userLower = strtolower($this->getName());
if(strpos($pwdLower, $userLower) || strpos($userLower, $pwdLower))
return false;
if(
preg_match('/.*[a-z].*/', $password) === false ||
preg_match('/.*[A-Z].*/', $password) === false
)
return false;
return true;
}
public function isUsernameFree($user)
{
$factory = new CommonClubsModelFactoryUser();
$users = $factory->loadElements(null, null, function($q) use ($user){
$q->where('main.user = ' . $q->q($user));
});
if(sizeof($users) == 0)
return true;
elseif(sizeof($users) == 1)
{
if($this->getId() == $users[0]->getId())
return true;
else
return false;
}
else
throw new Exception('The database is inconsistent!');
}
protected function prepareDelete($db)
{
$q = $db->getQuery(true);
$q->delete('#__club_user_assocs')->where("userid = {$this->getId()}");
$db->setQuery($q);
$db->execute();
}
public function dataIsValid()
{
if(! parent::dataIsValid())
return false;
if(! $this->usernameIsValid())
{
return false;
}
return true;
}
private function usernameIsValid()
{
$factory = $this->getFactory();
$medb = $factory->loadById($this->getId(), false);
if($medb !== null && $medb->getUserName() === $this->getUsername())
// No change was made
return true;
if(! $this->isUsernameFree($this->getUsername()) )
return false;
return true;
}
protected function filterDatabaseRawData($values)
{
if(strlen($values['phone']) == 0)
$values['phone'] = null;
if(strlen($values['mobile']) == 0)
$values['mobile'] = null;
return $values;
}
}

View File

@ -0,0 +1,119 @@
<?php
// No direct access.
defined('_JEXEC') or die;
class CommonClubsModelUserassoc extends AbstractCommonClubsModel
{
protected function getFactory()
{
return new CommonClubsModelFactoryUserassoc();
}
/**
*
* @return CommonClubsModelUser
*/
public function getUser()
{
return $this->getValues()['user'];
}
/**
*
* @return CommonClubsModelPosition
*/
public function getPosition()
{
return $this->getValues()['position'];
}
/**
*
* @return CommonClubsModelClub
*/
public function getClub()
{
return $this->getValues()['club'];
}
public function setUser($user)
{
$this->setValue('user', $user);
}
public function setPosition($position)
{
$this->setValue('position', $position);
}
public function setClub($club)
{
$this->setValue('club', $club);
}
public function isAdmin()
{
return $this->getValues()['admin'] == 1;
}
public function setAdmin($admin)
{
if($admin)
$this->setValue('admin', 1);
else
$this->setValue('admin', 0);
}
public function getAddress()
{
return $this->getValues()['address'];
}
public function setAddress($address)
{
$this->setValue('address', $address);
}
public function getMail()
{
return $this->getValues()['mail'];
}
public function setMail($mail)
{
$this->setValue('mail', $mail);
}
public function getPhone()
{
return $this->getValues()['phone'];
}
public function setPhone($phone)
{
$this->setValue('phone', $phone);
}
public function getState()
{
return $this->getValues()['state'];
}
public function setState($state)
{
switch(strtolower($state))
{
case 'vacant':
case 'temporary':
case 'regular':
$state = strtolower($state);
break;
default:
throw new Exception("Unknown state \"$state\" found.");
}
$this->setValue('state', $state);
}
}

View File

@ -8,4 +8,5 @@ defined('_JEXEC') or die;
class ClubsController extends BaseController
{
protected $default_view = 'users';
}

View File

@ -0,0 +1,46 @@
<?php
// No direct access.
defined('_JEXEC') or die;
class ClubsControllerClub extends AbstractClubsController
{
protected function getSingleBaseName()
{
return 'club';
}
protected function filterRaw(&$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();
}
protected function getFactory()
{
return new CommonClubsModelFactoryClub();
}
protected function additionalData()
{
return array(
'offers' => new CommonClubsControllerMappingInt('Angebot')
);
}
protected function saveAssocs($obj, $values)
{
$obj->setOfferIds($values['offers']);
}
}

View File

@ -0,0 +1,91 @@
<?php
use Joomla\CMS\MVC\Controller\BaseController;
use Joomla\CMS\Response\JsonResponse;
use Joomla\CMS\Factory;
// No direct access.
defined('_JEXEC') or die;
class ClubsControllerClubposition extends BaseController
{
public function save()
{
$app = Factory::getApplication();
$input = $app->input->post;
$id = $input->getCmd('id', 'new');
$clubid = $input->getInt('clubid');
$positionid = $input->getInt('positionid');
$state = $input->getCmd('state', 'regular');
$admin = $input->getCmd('admin', '0');
$userid = $input->getInt('userid', -1);
$address = $input->getString('address');
$mail = $input->getString('mail');
$phone = $input->getString('phone');
$clubFactory = new CommonClubsModelFactoryClub();
$club = $clubFactory->loadById($clubid);
$positionFactory = new CommonClubsModelFactoryPosition();
$position = $positionFactory->loadById($positionid);
$assocFactory = new CommonClubsModelFactoryUserassoc();
if($id === 'new')
{
$assoc = $assocFactory->createNew();
}
else
{
$assoc = $assocFactory->loadById((int) $id);
}
if($userid != -1)
{
$userFactory = new CommonClubsModelFactoryUser();
$user = $userFactory->loadById($userid);
}
else
{
$user = null;
}
if($state === 'vacant')
$user = null;
$assoc->setUser($user);
$assoc->setState($state);
$assoc->setAddress($address === '' ? null : $address);
$assoc->setMail($mail === '' ? null : $mail);
$assoc->setPhone($phone === '' ? null : $phone);
$assoc->setClub($club);
$assoc->setAdmin($admin);
$assoc->setPosition($position);
$assoc->save();
$ret = array('new' => ($id === 'new'), 'id' => $assoc->getId());
echo new JsonResponse($ret, null, false, true);
// jexit();
}
public function delete()
{
$app = Factory::getApplication();
$input = $app->input->get;
$id = $input->getInt('id');
$factory = new CommonClubsModelFactoryUserassoc();
$ua = $factory->loadById($id);
$ua->delete();
$ret = array('id' => $id);
echo new JsonResponse($ret, null, false, true);
}
}

View File

@ -0,0 +1,20 @@
<?php
// No direct access.
defined('_JEXEC') or die;
class ClubsControllerOffer extends AbstractClubsController
{
protected function getSingleBaseName()
{
return 'offer';
}
protected function getFactory()
{
return new CommonClubsModelFactoryOffer();
}
}

View File

@ -0,0 +1,20 @@
<?php
// No direct access.
defined('_JEXEC') or die;
class ClubsControllerPosition extends AbstractClubsController
{
protected function getFactory()
{
return new CommonClubsModelFactoryPosition();
}
protected function getSingleBaseName()
{
return 'position';
}
}

View File

@ -0,0 +1,106 @@
<?php
use Joomla\CMS\Factory;
// No direct access.
defined('_JEXEC') or die;
class ClubsControllerUser extends AbstractClubsController
{
protected function getSingleBaseName()
{
return 'user';
}
protected function rawDataIsValid($values)
{
if(! parent::rawDataIsValid($values))
return false;
if($this->passwordIsSet($values))
{
if( ! $this->passwordIsValid($values))
return false;
}
return true;
}
private function passwordIsSet($values)
{
return isset($values['pwd']) && strlen($values['pwd']) > 0;
}
private function passwordIsValid($values)
{
$pwd = $values['pwd'];
$pwdConfirm = $values['pwdConfirm'];
if(trim($pwd) != trim($pwdConfirm))
{
Factory::getApplication()->enqueueMessage('Die Passwörter stimmen nicht überein.', 'error');
return false;
}
// FIXME Check password strength
// if(! ClubsUser::checkPasswordStrength(trim($pwd)))
// {
// Factory::getApplication()->enqueueMessage('Das Passwort ist zu schwach.', 'error');
// return false;
// }
return true;
}
protected function getFactory()
{
return new CommonClubsModelFactoryUser();
}
/**
*
* {@inheritDoc}
* @see AbstractClubsController::filterObject()
* @param CommonClubsModelUser $obj
*/
protected function filterObject($obj, $values)
{
// if($obj->isNew() && (empty($values['pwd']) || strlen($values['pwd']) == 0) )
if(isset($values['pwd']) && strlen($values['pwd']) > 0)
{
$obj->setPassword($values['pwd']);
}
}
/**
* {@inheritDoc}
* @see AbstractClubsController::objectValid()
* @param CommonClubsModelUser $obj
*/
protected function objectValid($obj)
{
if(! $obj->isPasswordSet())
{
Factory::getApplication()->enqueueMessage('Kein Passwort wurde vergeben.', 'error');
return false;
}
return true;
}
protected function filterRaw(&$values)
{
unset($values['password']);
}
protected function additionalData()
{
return array(
'pwd' => new CommonClubsControllerMappingString('Passwort'),
'pwdConfirm' => new CommonClubsControllerMappingString('Passwortwiederholung')
);
}
}

View File

@ -0,0 +1,51 @@
#dialog-club {
width: 100vw;
height: 100vh;
position: fixed;
left: 0pt;
top: 0pt;
z-index: 1500;
/*border-style: solid;*/
}
#dialog-club > .dialog {
background-color: white;
width: 70vw;
height: 60vh;
position: absolute;
left: 15vw;
top: 20vh;
/*z-index: 100;*/
border-style: solid;
/*visibility: visible;*/
overflow: auto;
padding: 1em;
}
#dialog-club > .background {
background-color: gray;
width: 100vw;
height: 100vh;
position: absolute;
left: 0pt;
top: 0pt;
/*z-index: 1000;*/
opacity: 0.5;
}
.dialog-hidden {
display: none;
}
.dialog-entry-hidden {
visibility: hidden;
}
.form-disabled {
overflow: hidden;
}
#hidden-id {
display: none;
}

102
src/admin/res/club/club.js Normal file
View File

@ -0,0 +1,102 @@
jQuery(function($){
function closeDialog() {
$('#dialog-club > .dialog').html('');
$('body').removeClass('form-disabled');
$('#dialog-club').addClass('dialog-hidden');
}
function openDialog(data) {
// console.log(data);
$('#dialog-club > .dialog').html(data);
$('body').addClass('form-disabled');
$('#dialog-club').removeClass('dialog-hidden');
}
$('#new-position').click(function(ev){
ev.preventDefault();
var url = $('#new-position').attr('href');
$.get(url, function(data){
openDialog(data);
});
});
$(document).on('click', '#clubposition-abort', function(ev){
ev.preventDefault();
closeDialog();
});
$(document).on('change', '#clubposition-state', function(){
if($('#clubposition-state').val() == "vacant")
$('#clubposition-user').addClass('dialog-entry-hidden');
else
$('#clubposition-user').removeClass('dialog-entry-hidden');
});
$(document).on('click', '#clubposition-save', function(ev){
ev.preventDefault();
var data = $('#clubposition-form').serializeArray();
$.post($('#clubposition-form').attr('action'), data, function(data){
// console.log(data)
if(data.success)
{
console.log("all right!");
var url = "index.php?option=com_clubs&view=clubposition&layout=row&id=" + data.data.id + "&club=" + $('#hidden-id').html();
console.log(url);
if(data.data.new) {
$.get(url, function(data2){
$("#userassocs").append(data2);
closeDialog();
});
} else {
$.get(url, function(data2){
$('#userassoc-' + data.data.id).html(data2);
closeDialog();
});
}
}
else
{
alert(data.message);
}
});
});
$(document).on('click', '.edit-position', function(ev){
ev.preventDefault();
var url = ev.currentTarget.href;
$.get(url, function(data){
openDialog(data);
});
});
$(document).on('click', '.del-position', function(ev){
ev.preventDefault();
if(confirm("Der Eintrag wird endgültig gelöscht werden. OK?")) {
var url = ev.currentTarget.href;
$.get(url, function(d){
if(d.success) {
$('#userassoc-' + d.data.id).remove();
}
});
}
});
$(window).on('beforeunload', function(){return "Wollen Sie die Seite wirklich verlassen? M&ouml;glicherweise sind nicht alle Daten gesichert.";});
$('.form-exit').click(function(){
$(window).off('beforeunload');
});
});

View File

@ -0,0 +1,68 @@
CREATE TABLE IF NOT EXISTS `#__club_clubs` (
`id` int(10) NOT NULL AUTO_INCREMENT PRIMARY KEY,
`name` varchar(100) NOT NULL,
`address` tinytext NOT NULL,
`city` varchar(50) NOT NULL,
`homepage` varchar(100) DEFAULT 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
);
CREATE TABLE IF NOT EXISTS `#__club_keys` (
`privkey` text NOT NULL,
`publickey` text NOT NULL
);
CREATE TABLE IF NOT EXISTS `#__club_offer_assocs` (
`id` int(10) NOT NULL AUTO_INCREMENT PRIMARY KEY,
`clubid` int(10) NOT NULL,
`offerid` int(10) NOT NULL
);
CREATE TABLE IF NOT EXISTS `#__club_offers` (
`id` int(10) NOT NULL AUTO_INCREMENT PRIMARY KEY,
`name` varchar(100) NOT NULL
);
CREATE TABLE IF NOT EXISTS `#__club_places` (
`id` int(10) NOT NULL AUTO_INCREMENT PRIMARY KEY,
`clubid` int(10) NOT NULL,
`name` varchar(100) NOT NULL,
`address` tinytext NOT NULL,
`area` int(10) DEFAULT NULL
);
CREATE TABLE IF NOT EXISTS `#__club_positions` (
`id` int(10) NOT NULL AUTO_INCREMENT PRIMARY KEY,
`name` varchar(100) NOT NULL
);
CREATE TABLE IF NOT EXISTS `#__club_user_assocs` (
`id` int(10) NOT NULL AUTO_INCREMENT,
`clubid` int(10) NOT NULL,
`userid` int(10) DEFAULT 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`)
);
CREATE TABLE IF NOT EXISTS `#__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`)
);

View File

@ -0,0 +1,9 @@
DROP TABLE IF EXISTS `#__club_clubs`;
DROP TABLE IF EXISTS `#__club_keys`;
DROP TABLE IF EXISTS `#__club_offer_assocs`;
DROP TABLE IF EXISTS `#__club_offers`;
DROP TABLE IF EXISTS `#__club_places`;
DROP TABLE IF EXISTS `#__club_positions`;
DROP TABLE IF EXISTS `#__club_user_assocs`;
DROP TABLE IF EXISTS `#__club_users`;

View File

View File

@ -1,18 +0,0 @@
DROP TABLE IF EXISTS `#__club_keys`;
CREATE TABLE `#__club_keys` (
`privkey` text NOT NULL,
`publickey` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO `#__club_keys` VALUES ('-----BEGIN PRIVATE KEY-----\nMIIEwAIBADANBgkqhkiG9w0BAQEFAASCBKowggSmAgEAAoIBAQDvZHhLHHqmfnnP\noj5Y7AtS0UvEN8XLzNdHj/0nHBVHrXDMNul8phbCaevuaXcYTZvb9JBTAO019Bnu\nCoj6KFrk0Cw/zcVgVHryguNCr2DeLaxAXyArfkKNZPuG/kTw1mxE6ebeR886JVU0\nfQpIi3zDGAHpXxaKO7EttnvQK8NRd4h5O5EI6dCnmMn/8xY/d5G7AsZKuAxq01ZB\nmmUrkRKrQtBTwUeJWhtfT+XjOa1n1FVIwmqz4O2sqbfm0pa6PX0BNT0CUp0RI1wN\nGmF6bh/WkQ8h3jmTamzZ2cQUwDnL7ByAJqexJrrPacRbE6EotCGODjuBXDSy02PJ\nZk0fThZpAgMBAAECggEBANJaU0WU8cUo73pekzBpwY11MYFqjJiHF0ffo0/hYmWI\nZsxbGBGak/cjQdhNvgOR9nlxTfxRnR7CrqI3iaNfIHdc4PTzqBL8SMid8HohRxoT\nwf8SV19AY9SAvnAhL4z8rUhky6PYL6RlN5iWoxmZz/hSOSPKlTDEQOztI6CJQ+hp\nUFEiOLq/TSWB1DYEu6qAQRyI5wcC1QMo+zB/zBwIuM3DsB2f6Xtj86kXzU/bGeDj\nNLbsCuhRbFyMgvcJ3z6KQTvREZOGkeF22HA+ZVH7bWf00PqCEjq2I/XFHZGK61X4\nWLgNOUmVZSmGv2Kd9UJaC8VffkBnrV3XFN1n97gcP4ECgYEA/Joaw3VrbWpKsquf\nMiTuMJVyvcV9fmVhWhPNuioCwWwBx2mjGz/texd/67KNWPr7r1IGCIBnYfs3Dy+k\nOo+lAWT7oaec24dH4vjiljWrvFvZXmkpTa6j8RSqhhIVTUFSnXBkvxkEzcnUMbxK\n6A4gdggSfcMpeo3DmjGqNWTXlbkCgYEA8pzgD2VFEYq4/fgDhxKeoWSt1UPJtPxT\n4iYPXWKGdWLsEKg36oYiRXSTdan5aRwiZUXpDoFJU8vVCfmdVb2qpwPp66LwYFax\nAYuA3aPTi9npT4nDOBygVGSTY0TsxmL5asndyxl99OdoskLmS3N2UzeWMy7prRTt\nWZL7uWnU3jECgYEA+8EHLYkIcXs/SYV823gtIKTCP9rlsSSPezxDjOgz6NyhhUKG\nejEjmcuZBarl7ynt0BU6yBxZbTD39h2wW2EwvgwMMlggIDda8R7GjZieOdN89/ht\nXuvQnwTO02KQcnfJQ/pxnnfr7sHZx1v3eAIkXh67dzYcT/WcXkBjeGWx65kCgYEA\n0WU8rY0GU+GbUPfic45Kg5nVvx/G1AKEk8etszf6PQ6oGKhXun8SzUeUjhWqQmIZ\n/badM/u6QizHLtjWRs5wn73tA4eaWEv6cg7ppmJjj20AxbltWNy8NJqp6x/uDDwY\ncWbRmx3hbKLd5h1/jteU5LYxWPPAk7ZgNNN7l8gUBcECgYEAzVVKQ5dn58iHkH1i\nB3UUnTrqPD/cn7WigcWn7A6vpxqbGARkAyIXV/xqLoD8pX1G7JhqFKArC+UJzUuC\n6hgL1Hq+OJXTaN2NzcvQaIvLzsOWQebFtNfFxi0tzAE0t2/JfuFxeam0WZunaNgg\nAabygognDdEZW9HBvCydJ5N8e+s=\n-----END PRIVATE KEY-----\n','-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA72R4Sxx6pn55z6I+WOwL\nUtFLxDfFy8zXR4/9JxwVR61wzDbpfKYWwmnr7ml3GE2b2/SQUwDtNfQZ7gqI+iha\n5NAsP83FYFR68oLjQq9g3i2sQF8gK35CjWT7hv5E8NZsROnm3kfPOiVVNH0KSIt8\nwxgB6V8WijuxLbZ70CvDUXeIeTuRCOnQp5jJ//MWP3eRuwLGSrgMatNWQZplK5ES\nq0LQU8FHiVobX0/l4zmtZ9RVSMJqs+DtrKm35tKWuj19ATU9AlKdESNcDRphem4f\n1pEPId45k2ps2dnEFMA5y+wcgCansSa6z2nEWxOhKLQhjg47gVw0stNjyWZNH04W\naQIDAQAB\n-----END PUBLIC KEY-----\n');
DROP TABLE IF EXISTS `#__club_users`;
CREATE TABLE `#__club_users` (
`id` int(10) NOT NULL AUTO_INCREMENT,
`user` varchar(30) NOT NULL,
`password` varchar(150) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;
INSERT INTO `#__club_users` VALUES (1,'chris','$2y$10$2/aeOfLlLwFx7JYXpaAOH.CG0ZtvkzTuK6nojvSIuOYlTbSd07CqC');

View File

@ -0,0 +1,137 @@
<?php
// No direct access.
use Joomla\CMS\Router\Route;
defined('_JEXEC') or die;
?>
<form method="post" action="<?php echo $this->address; ?>" id='form-club'>
<input type='hidden' name='id' value='<?php echo $this->object->getId(); ?>'>
<h2>Stammdaten</h2>
<table>
<tr>
<td>Clubname</td>
<td><input type='text' name='name' value='<?php echo htmlentities($this->object->getName()); ?>'></td>
</tr>
<tr>
<td>Vollst&auml;ndige postalische 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>ID</td>
<td><?php echo $this->object->getId(); ?></td>
</tr>
<?php endif; ?>
</table>
<?php if(! $this->isNew): ?>
<h2>Angebote</h2>
<?php foreach($this->object->getOffers() as $oconf): ?>
<input type='checkbox' name='offers[]' value='<?php echo $oconf['offer']->getId(); ?>' <?php if($oconf['valid']) echo 'checked="checked"';?>>
<?php echo htmlentities($oconf['offer']->getName()); ?><br />
<?php endforeach; ?>
<h2>Posten</h2>
<?php if(sizeof($this->object->getUsers()) == 0 ): ?>
<p>Dem Verein ist bisher kein Posten zugewiesen.</p>
<?php else: ?>
<table width='100%' class='table table-stiped, table-hover' id='userassocs'>
<tr>
<th width='20%'>Rolle</th>
<th width='25%'>Name</th>
<th width='10%'>Stadt</th>
<th width='5%' style='text-align: center;'>Admin?</th>
<th></th>
<th width='5%'>ID</th>
</tr>
<?php foreach($this->object->getUsers() as $ua): ?>
<?php
$user = $ua->getUser();
if($user == null)
{
$username = '<i>Derzeit vakant</i>';
$usercity = '';
}
else
{
$username = htmlentities($user->getName());
$usercity = htmlentities($user->getCity());
}
?>
<tr id='userassoc-<?php echo $ua->getId(); ?>'>
<td><?php echo htmlentities($ua->getPosition()->getName()); ?></td>
<td><?php echo $username; ?></td>
<td><?php echo $usercity; ?></td>
<td style='text-align: center;'><?php if($ua->isAdmin()) echo "<span class='icon-checkmark'></span>"; ?></td>
<td>
<a href='<?php echo Route::_("index.php?option=com_clubs&view=clubposition&layout=edit&club={$this->object->getId()}&id={$ua->getId()}"); ?>' class='edit-position'><span class='icon-edit'></span></a>
<a href='<?php echo Route::_("index.php?option=com_clubs&task=clubposition.delete&format=json&id={$ua->getId()}"); ?>' class='del-position'><span class='icon-delete'></span></a>
</td>
<td><?php echo $ua->getId(); ?></td>
</tr>
<?php endforeach; ?>
</table>
<?php endif; ?>
<p><a href='<?php echo Route::_("index.php?option=com_clubs&view=clubposition&layout=edit&club={$this->object->getId()}&id=new"); ?>' id='new-position'><span class='icon-new'></span> Neuen Posten einf&uuml;gen</a></p>
<?php endif; ?>
<input type='submit' value='Speichern' class='form-exit'> <br /><a href='<?php echo Route::_('index.php?option=com_clubs&view=clubs'); ?>' class='form-exit'>Zur&uuml;ck zur &Uuml;bersicht</a>
</form>
<div id='dialog-club' class='dialog-hidden'>
<div class='background'></div>
<div class='dialog'>Ein Test</div>
<div id='hidden-id'><?php echo $this->object->getId(); ?></div>
</div>

View File

@ -0,0 +1,43 @@
<?php
use Joomla\CMS\Factory;
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', 'cube');
$this->prepareDisplay();
$userFactory = new CommonClubsModelFactoryUser();
$this->users = $userFactory->loadElements();
JHtmlJquery::framework();
Factory::getDocument()->addScript('components/com_clubs/res/club/club.js');
Factory::getDocument()->addStyleSheet('components/com_clubs/res/admin-club.css');
// $this->
parent::display($tpl);
}
protected function getControllerName()
{
return 'club';
}
protected function getFactory()
{
return new CommonClubsModelFactoryClub();
}
}

View File

@ -0,0 +1,90 @@
<?php
use Joomla\CMS\Router\Route;
// No direct access.
defined('_JEXEC') or die;
?>
<form id='clubposition-form' method="post" action="<?php echo Route::_('index.php?option=com_clubs&task=clubposition.save&format=json') ?>">
<input type='hidden' name='id' value='<?php echo $this->id; ?>'>
<input type='hidden' name='clubid' value='<?php echo $this->clubid; ?>'>
<h1>Posten bearbeiten</h1>
<table>
<tr>
<td>Funktion: </td>
<td>
<select name='positionid'>
<?php foreach($this->positions as $p): ?>
<?php
if($this->assoc->getPosition() !== null)
$selected = $this->assoc->getPosition()->getId() == $p->getId();
else
$selected = false;
?>
<option value='<?php echo $p->getId(); ?>' <?php if($selected) echo 'selected'; ?>>
<?php echo $p->getName(); ?>
</option>
<?php endforeach; ?>
</select>
</td>
</tr>
<tr>
<td>Status</td>
<td>
<select name='state' id='clubposition-state'>
<option value='regular' <?php echo $this->assoc->getState() === 'regular' ? 'selected' : ''; ?>>regul&auml;r</option>
<option value='temporary' <?php echo $this->assoc->getState() === 'temporary' ? 'selected' : ''; ?>>kommisarisch</option>
<option value='vacant' <?php echo $this->assoc->getState() === 'vacant' ? 'selected' : ''; ?>>vakant</option>
</select>
</td>
</tr>
<tr id='clubposition-user' <?php if($this->assoc->getState() === 'vacant') echo 'class="dialog-entry-hidden"'; ?>>
<td>Person: </td>
<td>
<select name='userid'>
<?php foreach($this->users as $u): ?>
<?php
$uid = $this->assoc->getUser() === null ? -1 : $this->assoc->getUser()->getId();
$selected = ($u->getId() == $uid);
?>
<option value='<?php echo $u->getId();?>' <?php echo $selected ? 'selected' : ''; ?>>
<?php echo $u->getName(); ?> (<?php echo $u->getCity(); ?>)
</option>
<?php endforeach; ?>
</select>
</td>
</tr>
<tr>
<td>Admin: </td>
<td>
<input type='checkbox' name='admin' value='1' <?php echo $this->assoc->isAdmin() ? 'checked' : ''; ?>>
</td>
</tr>
<tr>
<td>Postalische Adresse (optional): </td>
<td>
<textarea name='address' rows='4'><?php echo $this->assoc->getAddress(); ?></textarea>
</td>
</tr>
<tr>
<td>E-Mail (optional): </td>
<td>
<input type='text' name='mail' value='<?php echo $this->assoc->getMail(); ?>'>
</td>
</tr>
<tr>
<td>Telefon-Nr. (optional): </td>
<td>
<input type='text' name='phone' value='<?php echo $this->assoc->getPhone(); ?>'>
</td>
</tr>
</table>
</form>
<a href='#' id='clubposition-save'>Speichern</a>
<a href='#' id='clubposition-abort'>Abbrechen</a>

View File

@ -0,0 +1,17 @@
<?php
// No direct access.
use Joomla\CMS\Router\Route;
defined('_JEXEC') or die;
?>
<td><?php echo htmlentities($this->assoc->getPosition()->getName()); ?></td>
<td><?php echo $this->username; ?></td>
<td><?php echo $this->usercity; ?></td>
<td style='text-align: center;'><?php if($this->assoc->isAdmin()) echo "<span class='icon-checkmark'></span>"; ?></td>
<td>
<a href='<?php echo Route::_("index.php?option=com_clubs&view=clubposition&layout=edit&club={$this->clubid}&id={$this->assoc->getId()}"); ?>' class='edit-position'><span class='icon-edit'></span></a>
<a href='<?php echo Route::_("index.php?option=com_clubs&task=clubposition.delete&format=json&id={$this->assoc->getId()}"); ?>' class='del-position'><span class='icon-delete'></span></a>
</td>
<td><?php echo $this->assoc->getId(); ?></td>

View File

@ -0,0 +1,62 @@
<?php
use Joomla\CMS\MVC\View\HtmlView;
use Joomla\CMS\Factory;
// No direct access.
defined('_JEXEC') or die;
JLoader::register("ClubsControllerPosition", JPATH_ROOT . "/administrator/components/com_clubs/controllers/position.php");
class ClubsViewClubPosition extends HtmlView
{
function display($tpl = null)
{
$input = Factory::getApplication()->input->get;
$positonFactory = new CommonClubsModelFactoryPosition();
$userFactory = new CommonClubsModelFactoryUser();
$this->positions = $positonFactory->loadElements();
$this->users = $userFactory->loadElements();
$id = $input->getCmd('id', 'new');
$assocFactory = new CommonClubsModelFactoryUserassoc();
if($id !== 'new')
{
$id = (int) $id;
$this->assoc = $assocFactory->loadById($id);
}
else
{
$this->assoc = $assocFactory->createNew();
}
$this->id = $id;
$this->clubid = $input->getInt('club');
$this->username = '<i>Derzeit vakant.</i>';
$this->usercity = '';
if($this->assoc->getUser() !== null)
{
$u = $this->assoc->getUser();
$this->username = htmlentities($u->getName());
$this->usercity = htmlentities($u->getCity());
}
parent::display($tpl);
jexit();
}
protected function getControllerName()
{
return 'position';
}
protected function getFactory()
{
return new CommonClubsModelFactoryPosition();
}
}

View File

@ -0,0 +1,34 @@
<?php
// No direct access.
defined('_JEXEC') or die;
?>
<table class='table table-stiped, table-hover'>
<thead>
<tr>
<th width='30%'>Bezeichnung</th>
<th width='20%'>Stadt</th>
<th width='20%'>Homepage</th>
<th width='20%'>E-Mail</th>
<th width='10%'></th>
<th width='3%'>id</th>
</tr>
</thead>
<?php foreach($this->objects as $club): ?>
<?php $url = htmlentities($club->getHomepage()); ?>
<?php $mail = htmlentities($club->getMail()); ?>
<tr>
<td><a href='<?php echo str_replace('__ID__', $club->getId(), $this->changeUrl); ?>'><?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 str_replace('__ID__', $club->getId(), $this->delUrl); ?>'><span class='icon-delete'></span>L&ouml;schen</a></td>
<td><?php echo htmlentities($club->getId()); ?></td>
</tr>
<?php endforeach; ?>
</table>
<div><a href='<?php echo $this->addUrl; ?>'><span class='icon-new'></span>Neuen Verein anlegen</a></div>

View File

@ -0,0 +1,27 @@
<?php
use Joomla\CMS\Toolbar\ToolbarHelper;
// No direct access.
defined('_JEXEC') or die;
class ClubsViewClubs extends AbstractClubsViewList
{
function display($tpl = null)
{
ToolbarHelper::title('Club-Management - Clubs', 'cube');
parent::display($tpl);
}
protected function getFactory()
{
return new CommonClubsModelFactoryClub();
}
protected function getSingleBaseName()
{
return 'club';
}
}

View File

@ -0,0 +1,27 @@
<?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

@ -0,0 +1,30 @@
<?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', 'file');
parent::display($tpl);
}
protected function getFactory()
{
return new CommonClubsModelFactoryOffer();
}
protected function getControllerName()
{
return 'offer';
}
}

View File

@ -0,0 +1,28 @@
<?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%'></th>
<th width='5%'>id</th>
</tr>
</thead>
<?php foreach($this->objects as $offer): ?>
<?php $link = Route::_('index.php?option=com_clubs&view=offer&id=' . $offer->getId()); ?>
<tr>
<td><a href='<?php echo str_replace('__ID__', $offer->getId(), $this->changeUrl); ?>'><?php echo htmlentities($offer->getName()); ?></a></td>
<td><a href='<?php echo str_replace('__ID__', $offer->getId(), $this->delUrl); ?>'><span class='icon-delete'></span>L&ouml;schen</a></td>
<td><?php echo htmlentities($offer->getId()); ?></td>
</tr>
<?php endforeach; ?>
</table>
<div><a href='<?php echo $this->addUrl; ?>'><span class='icon-new'></span>Neues Angebot anlegen</a></div>

View File

@ -0,0 +1,27 @@
<?php
use Joomla\CMS\Toolbar\ToolbarHelper;
// No direct access.
defined('_JEXEC') or die;
class ClubsViewOffers extends AbstractClubsViewList
{
function display($tpl = null)
{
ToolbarHelper::title('Club-Management - Angebote', 'list');
parent::display($tpl);
}
protected function getFactory()
{
return new CommonClubsModelFactoryOffer();
}
protected function getSingleBaseName()
{
return 'offer';
}
}

View File

@ -0,0 +1,27 @@
<?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

@ -0,0 +1,28 @@
<?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
{
function display($tpl = null)
{
ToolbarHelper::title('Club-Management - Position', 'users');
parent::display($tpl);
}
protected function getControllerName()
{
return 'position';
}
protected function getFactory()
{
return new CommonClubsModelFactoryPosition();
}
}

View File

@ -0,0 +1,26 @@
<?php
// No direct access.
defined('_JEXEC') or die;
?>
<table class='table table-stiped, table-hover'>
<thead>
<tr>
<th width='30%'>Bezeichnung</th>
<th width='5%'></th>
<th width='5%'>id</th>
</tr>
</thead>
<?php foreach($this->objects as $position): ?>
<tr>
<td><a href='<?php echo str_replace('__ID__', $position->getId(), $this->changeUrl); ?>'><?php echo htmlentities($position->getName()); ?></a></td>
<td><a href='<?php echo str_replace('__ID__', $position->getId(), $this->delUrl); ?>'><span class='icon-delete'></span>L&ouml;schen</a></td>
<td><?php echo htmlentities($position->getId()); ?></td>
</tr>
<?php endforeach; ?>
</table>
<div><a href='<?php echo $this->addUrl; ?>'><span class='icon-new'></span>Neuen Posten anlegen</a></div>

View File

@ -0,0 +1,27 @@
<?php
use Joomla\CMS\Toolbar\ToolbarHelper;
// No direct access.
defined('_JEXEC') or die;
class ClubsViewPositions extends AbstractClubsViewList
{
function display($tpl = null)
{
ToolbarHelper::title('Club-Management - Positionen', 'users');
parent::display($tpl);
}
protected function getFactory()
{
return new CommonClubsModelFactoryPosition();
}
protected function getSingleBaseName()
{
return 'position';
}
}

View File

@ -0,0 +1,24 @@
<?php
// No direct access.
defined('_JEXEC') or die;
?>
ClubName: <?php echo $this->club->getName(); ?> <br />
ClubName: <?php echo $this->club->getAddress(); ?> <br />
ClubName: <?php echo $this->club->getCity(); ?> <br />
ClubName: <?php echo $this->club->getHomepage(); ?> <br />
ClubName: <?php echo $this->club->getMail(); ?> <br />
ClubName: <?php echo $this->club->getIban(); ?> <br />
ClubName: <?php echo $this->club->getBic(); ?> <br />
ClubName: <?php echo $this->club->isCharitable(); ?> <br />
ClubName: <?php echo $this->club->getPresident()->getName(); ?> <br />
<?php foreach($this->club->getPlaces() as $place): ?>
Place: <?php echo $place->getName(); ?><br>
<?php endforeach; ?>
<h1>Output</h1>
<pre><?php print_r($this->log); ?></pre>
<a href='#' id='mya'>Test Link</a>

View File

@ -0,0 +1,8 @@
<?php
// No direct access.
defined('_JEXEC') or die;
// Append &layout=foo to URL
?>
<p>This is foo.</p>

View File

@ -0,0 +1,64 @@
<?php
use Joomla\CMS\Toolbar\ToolbarHelper;
use Joomla\CMS\MVC\View\HtmlView;
use Joomla\CMS\Factory;
// No direct access.
defined('_JEXEC') or die;
JLoader::register("ClubsControllerClub", JPATH_ROOT . "/administrator/components/com_clubs/controllers/club.php");
class ClubsViewTest extends HtmlView
{
function display($tpl = null)
{
ToolbarHelper::title('Test');
$this->log = '';
$factory = new CommonClubsModelFactoryClub();
$this->clubs = $factory->loadElements();
$this->club = $this->clubs[0];
$c = $factory->loadById(1);
$p = $c->getPresident();
$id = $p->getId();
$places = $c->getPlaces();
// $places[0]->setName("abc");
// $places[0]->save();
$pfactory = new CommonClubsModelFactoryPlace();
$np = $pfactory->createNew();
$np->setName('MyName');
$np->setClub($c);
// $np->save();
$np->getId();
$np = $c->getPlaces()[2];
$np->getName();
// $np->setName('foo2 with new Name');
// $np->save();
// $np->delete();
$this->log = $np;
parent::display($tpl);
//Factory::getDocument()->addScript( "http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" );
JHtmlJquery::framework();
Factory::getDocument()->addScript('components/com_clubs/res/clubs.js');
//jexit();
}
protected function getViewName()
{
return 'club';
}
protected function getElementController()
{
return new ClubsControllerClub();
}
}

View File

@ -0,0 +1,81 @@
<?php
use Joomla\CMS\Router\Route;
// No direct access.
defined('_JEXEC') or die;
?>
<form method="post" action="<?php echo $this->address; ?>">
<h2>Stammdaten</h2>
<input type='hidden' name='id' value='<?php echo $this->object->getId(); ?>'>
<table>
<tr>
<td>Username</td>
<td><input type='text' name='user' value='<?php echo htmlentities($this->object->getUserName()); ?>'></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->object->getName()); ?>'></td>
</tr>
<tr>
<td>Vollst&auml;ndige postalische Adresse</td>
<td>
<textarea rows="4" name='address'><?php echo (htmlentities($this->object->getAddress())); ?></textarea>
</tr>
<tr>
<td>Stadt</td>
<td><input type='text' name='city' value='<?php echo htmlentities($this->object->getCity()); ?>'></td>
</tr>
<tr>
<td>E-Mail</td>
<td><input type='text' name='mail' value='<?php echo htmlentities($this->object->getMail()); ?>'></td>
</tr>
<tr>
<td>Telefon</td>
<td><input type='text' name='phone' value='<?php echo htmlentities($this->object->getPhone()); ?>'></td>
</tr>
<tr>
<td>Handy</td>
<td><input type='text' name='mobile' value='<?php echo htmlentities($this->object->getMobile()); ?>'></td>
</tr>
<?php if(! $this->isNew): ?>
<tr>
<td>ID</td>
<td><?php echo $this->object->getId(); ?></td>
</tr>
<?php endif; ?>
</table>
<?php if(! $this->isNew): ?>
<h2>Verkn&uuml;pfungen</h2>
<?php if(sizeof($this->jobs) == 0): ?>
<p>Es wurden keine Verkn&uuml;pfungen zu der Person gefunden.</p>
<?php else: ?>
<table class='table table-stiped, table-hover'>
<tr>
<th>Posten</th>
<th>Verein</th>
<th>Stadt</th>
</tr>
<?php foreach($this->jobs as $job): ?>
<tr>
<td><?php echo htmlentities($job['position']); ?></td>
<td><a href='<?php echo $job['url']; ?>' target='_blank'><?php echo htmlentities($job['club']); ?></a></td>
<td><?php echo htmlentities($job['city']); ?></td>
</tr>
<?php endforeach; ?>
</table>
<?php endif; ?>
<?php endif; ?>
<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,71 @@
<?php
use Joomla\CMS\Toolbar\ToolbarHelper;
use Joomla\CMS\Router\Route;
// No direct access.
defined('_JEXEC') or die;
class ClubsViewUser extends AbstractClubsViewSingle
{
public function display($tpl = null)
{
$this->prepareDisplay();
if($this->isNew)
{
$this->jobs = array();
}
else
{
$factory = new CommonClubsModelFactoryUser();
$user = $factory->loadById($this->id);
$positions = $user->getPositions();
$clubFactory = new CommonClubsModelFactoryClub();
$clubsPresident = $clubFactory->loadElements("main.president = {$this->id}");
$jobs = array();
foreach($clubsPresident as $club)
{
$job = array(
'club' => $club->getName(),
'city' => $club->getCity(),
'position' => 'Vorsitzender',
'url' => Route::_("index.php?option=com_clubs&view=club&id={$club->getId()}")
);
$jobs[] = $job;
}
foreach($positions as $p)
{
$c = $p->getClub();
$job = array(
'club' => $c->getName(),
'city' => $c->getCity(),
'position' => $p->getPosition()->getName(),
'url' => Route::_("index.php?option=com_clubs&view=club&id={$c->getId()}")
);
$jobs[] = $job;
}
$this->jobs = $jobs;
}
ToolbarHelper::title('Club-Management - Person', 'user');
parent::display($tpl);
}
protected function getControllerName()
{
return 'user';
}
protected function getFactory()
{
return new CommonClubsModelFactoryUser();
}
}

View File

@ -0,0 +1,34 @@
<?php
// No direct access.
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%'></th>
<th width='5%'>id</th>
</tr>
</thead>
<?php foreach($this->objects as $user): ?>
<?php $link = str_replace('__ID__', $user->getId(), $this->changeUrl); ?>
<tr>
<td><a href='<?php echo $link; ?>'><?php echo htmlentities($user->getUserName()); ?></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 str_replace('__ID__', $user->getId(), $this->delUrl); ?>'><span class='icon-delete'></span>L&ouml;schen</a></td>
<td><?php echo htmlentities($user->getId()); ?></td>
</tr>
<?php endforeach; ?>
</table>
<div><a href='<?php echo $this->addUrl; ?>'><span class='icon-new'></span>Neuen Benutzer anlegen</a></div>

View File

@ -0,0 +1,27 @@
<?php
use Joomla\CMS\Toolbar\ToolbarHelper;
// No direct access.
defined('_JEXEC') or die;
class ClubsViewUsers extends AbstractClubsViewList
{
function display($tpl = null)
{
ToolbarHelper::title('Club-Management - Personen', 'user');
parent::display($tpl);
}
protected function getFactory()
{
return new CommonClubsModelFactoryUser();
}
protected function getSingleBaseName()
{
return 'user';
}
}

View File

@ -5,8 +5,9 @@
type="component">
<!-- SOLLTE, Der Annzeige-Name in Joomla -->
<name>Vereinsmanagement</name>
<name>Vereinsportal</name>
<title>Vereinsportal des saarländischen Tanzsportverbands</title>
<element>com_clubs</element>
<!--SOLLTE Erstellungsdatum -->
<creationDate>30.03.2019</creationDate>
@ -25,11 +26,13 @@
<!--<description>TPL_TEST_TEMPLATE_XML_DESCRIPTION</description>-->
<!-- MUSS, der Files-Tag bezeichnet den Block mit den Dateien und Ordnern die mit installiert werden -->
<files from='site'>
<files folder='site'>
<filename>clubs.php</filename>
<filename>controller.php</filename>
<folder>controller</folder>
<folder>controllers</folder>
<folder>css</folder>
<folder>helpers</folder>
<folder>js</folder>
<folder>models</folder>
<folder>views</folder>
</files>
@ -46,27 +49,36 @@
<menu>Vereinsmanagement</menu>
<submenu>
<!-- <menu link='link' view='v'>Test</menu> -->
<menu link='option=com_clubs&amp;view=positions'>Posten</menu>
<menu link='option=com_clubs&amp;view=offers'>Trainingsangebote</menu>
<menu link='option=com_clubs&amp;view=users'>Personen</menu>
<menu link='option=com_clubs&amp;view=clubs'>Vereine</menu>
</submenu>
<files from='admin'>
<files folder='admin'>
<folder>abstract</folder>
<folder>common</folder>
<folder>controllers</folder>
<folder>res</folder>
<folder>sql</folder>
<folder>views</folder>
<filename>clubs.php</filename>
<filename>controller.php</filename>
<folder>sql</folder>
</files>
</administration>
<install>
<sql>
<file driver='mysql'>sql/mysql/install.sql</file>
<file driver='mysql' charset='utf8'>sql/mysql/install.sql</file>
</sql>
</install>
<uninstall>
<sql>
<file driver='mysql'>sql/mysql/uninstall.sql</file>
<file driver='mysql' charset='utf8'>sql/mysql/uninstall.sql</file>
</sql>
</uninstall>
<update>
<schemas>
<schemapath type='mysql'>sql/updates/mysql</schemapath>
<schemapath type='mysql'>sql/mysql/updates</schemapath>
</schemas>
</update>

View File

@ -6,6 +6,16 @@ use Joomla\CMS\Factory;
// No direct access.
defined('_JEXEC') or die;
JLoader::discover('Clubs', JPATH_ROOT . '/administrator/components/com_clubs/mymodels');
JLoader::register("ClubsHelperAuth", JPATH_ROOT . "/components/com_clubs/helpers/auth.php");
JLoader::registerPrefix('AbstractClubs', JPATH_ROOT . '/administrator/components/com_clubs/abstract');
JLoader::registerPrefix('AbstractCommonClubs', JPATH_ROOT . '/administrator/components/com_clubs/common/abstract');
JLoader::registerPrefix('CommonClubsModel', JPATH_ROOT . '/administrator/components/com_clubs/common/models');
JLoader::registerPrefix('CommonClubsControllerMapping', JPATH_ROOT . '/administrator/components/com_clubs/common/controllermappings');
$controller = BaseController::getInstance("Clubs");
$input = Factory::getApplication()->input;

View File

@ -1,6 +1,8 @@
<?php
use Joomla\CMS\MVC\Controller\BaseController;
use Joomla\CMS\Uri\Uri;
use Joomla\CMS\Factory;
// No direct access.
defined('_JEXEC') or die;
@ -10,11 +12,56 @@ class ClubsController extends BaseController
public function display($cachable = false, $params = array())
{
$auth = new ClubsHelperAuth();
$app = Factory::getApplication();
$view = $app->input->getCmd('view');
// Most of the pages can only be viewd as a logged-in user
if($auth->isValidUserLoggedIn())
{
if($this->isUrlAllowed($view))
{
$this->doDisplay($cachable, $params);
return;
}
else
{
// User is not allowed to see the site, give useful information
}
}
else
{
if($view === 'login' || $view === 'publicclubs')
{
$this->doDisplay($cachable, $params);
return;
}
else
{
// User needs to login in order to see the site
$this->redirectToLogin();
}
}
$this->redirectToLogin();
}
private function doDisplay($cachable, $params)
{
Factory::getDocument()->addStyleSheet(Uri::base(true) . "components/com_clubs/css/clubs.css");
parent::display($cachable, $params);
}
public function foo()
private function redirectToLogin()
{
echo "dsfh";
// XXX Attach URL to forward later
$this->setRedirect('index.php?opion=com_clubs&view=login');
}
private function isUrlAllowed($view)
{
// FIXME Insert ACLs checking here
return true;
}
}

View File

@ -6,8 +6,6 @@ use Joomla\CMS\Factory;
// No direct access.
defined('_JEXEC') or die;
JLoader::register("ClubsHelperAuth", JPATH_ROOT . "/components/com_clubs/helpers/auth.php");
class ClubsControllerLogin extends BaseController
{
public function login()

View File

@ -9,6 +9,12 @@ defined('_JEXEC') or die;
class ClubsHelperAuth
{
public function isValidUserLoggedIn()
{
// FIXME
return true;
}
public function checkUser($user, $pwd)
{
$userModel = BaseDatabaseModel::getInstance("user", "ClubsModel");

34
src/site/route.php Normal file
View File

@ -0,0 +1,34 @@
<?php
use Joomla\CMS\Component\Router\RouterInterface;
// No direct access.
defined('_JEXEC') or die;
class ClubsRouter implements RouterInterface
{
public function build(&$query)
{
$ret = array();
// $ret[] = $query['Itemid'];
if(isset($query['view']))
{
$ret[] = $query['view'];
unset($query['view']);
}
return $ret;
}
public function parse(&$segments)
{
$ret = array();
//$ret['itemid'] = $segments[0];
$ret['view'] = $segments[0];
return $ret;
}
public function preprocess($query)
{
return $query;
}
}

View File

@ -1,46 +1,61 @@
<?php
use Joomla\CMS\Router\Route;
// No direct access.
defined('_JEXEC') or die;
?>
<h1><?php echo $this->clubname; ?></h1>
<h1><?php echo htmlentities($this->club->getName()); ?></h1>
<div class='clubs_row'>
<div class='clubs_title_row'>Adresse</div>
<div class='clubs_content_row'><?php echo nl2br(htmlentities($this->address)); ?></div>
<div class='clubs_content_row'><?php echo nl2br(htmlentities($this->club->getAddress())); ?></div>
</div>
<div class='clubs_row'>
<div class='clubs_title_row'>Internet</div>
<div class='clubs_content_row'><?php echo htmlentities($this->internet); ?></div>
<div class='clubs_title_row'>Stadt</div>
<div class='clubs_content_row'><?php echo htmlentities($this->club->getCity()); ?></div>
</div>
<div class='clubs_row'>
<div class='clubs_title_row'>Kontaktperson</div>
<div class='clubs_content_row'><?php echo htmlentities($this->contactperson); ?></div>
<div class='clubs_title_row'>Homepage</div>
<div class='clubs_content_row'><a href='<?php echo htmlentities($this->club->getHomepage()); ?>' target='_blank'><?php echo htmlentities($this->club->getHomepage()); ?></a></div>
</div>
<div class='clubs_row'>
<div class='clubs_title_row'>Mail-Adresse</div>
<div class='clubs_content_row'><a href='mailto:<?php echo htmlentities($this->email); ?>'><?php echo htmlentities($this->email); ?></a></div>
<div class='clubs_content_row'><a href='mailto:<?php echo htmlentities($this->club->getMail()); ?>'><?php echo htmlentities($this->club->getMail()); ?></a></div>
</div>
<div class='clubs_row'>
<div class='clubs_title_row'>Telefon</div>
<div class='clubs_content_row'><?php echo htmlentities($this->phone); ?></div>
<div class='clubs_title_row'>IBAN / BIC</div>
<div class='clubs_content_row'><?php echo htmlentities($this->club->getIban()); ?> / <?php echo htmlentities($this->club->getBic()); ?></div>
</div>
<div class='clubs_row'>
<div class='clubs_title_row'>Gemeinn&uuml;tzigkeit</div>
<div class='clubs_content_row'><span class='icon-<?php echo $this->club->isCharitable() ? 'ok' : 'cancel'; ?>'></span> Der Verein ist <?php echo $this->club->isCharitable() ? '' : '<b>nicht</b>'; ?> gemeinn&uuml;tzig.</div>
</div>
<!--<div class='clubs_row'>
<div class='clubs_title_row'>Telefon</div>
<div class='clubs_content_row'><?php echo htmlentities('$this->phone'); ?></div>
</div>-->
<div class='clubs_row'>
<div class='clubs_title_row'>Angebote</div>
<div class='clubs_content_row'>
<?php if($this->hasOptions):
<?php if($this->hasOffers):
// Put all options there
foreach($this->options as $k=>$v):
foreach($this->club->getOffers() as $o):
?>
<input type="checkbox" disabled="disabled" <?php if(isset($v)) echo 'checked="checked"'; ?>> <?php echo htmlentities($k); ?><br />
<span class='icon-<?php echo $o['valid'] ? 'ok' : 'cancel-2'; ?>'></span>&nbsp;
<?php if($o['valid']) echo '<b>'; ?>
<?php echo htmlentities($o['offer']->getName()); ?><br />
<?php if($o['valid']) echo '</b>'; ?>
<?php
endforeach;
@ -52,47 +67,54 @@ endif; ?>
</div>
</div>
<?php if(count($this->trainingPlaces) > 0): ?>
<?php if(count($this->club->getPlaces()) > 0): ?>
<div class='clubs_row'>
<div class='clubs_title_row'>R&auml;umlichkeiten</div>
<?php foreach($this->trainingPlaces as $p): ?>
<div class='clubs_content_row'>
<?php echo htmlentities($p['name']); ?><br />
<?php echo htmlentities($p['street']); ?><br />
<?php echo htmlentities($p['plz'] . " " . $p['city']); ?>
</div>
<?php foreach($this->club->getPlaces() as $p): ?>
<div class='clubs_content_row'>
<b><?php echo htmlentities($p->getName()); ?></b><br />
<i>Adresse</i>
<?php //echo nl2br(htmlentities($p->getAddress())); ?>
<?php echo $p->getArea() === null ? '' : '<br />Fl&auml;che: ' . htmlentities($p->getArea()) . 'qm'; ?>
</div>
<?php endforeach; ?>
<div class='clubs_content_row'><a href='<?php echo ""; ?>'><span class='icon-new'></span>&nbsp; Neue Assoziation anlegen</a></div>
</div>
<?php endif; ?>
<?php if(count($this->persons) > 0) : ?>
<div class='clubs_row'>
<div class='clubs_title_row'>Pr&auml;sident</div>
<div class='clubs_content_row'>
<a href='<?php echo Route::_("index.php?view=user&userid={$this->club->getPresident()->getId()}"); ?>'>
<?php echo htmlentities("{$this->club->getPresident()->getName()} ({$this->club->getPresident()->getCity()})"); ?>
</a>
</div>
</div>
<?php if(count($this->club->getUsers()) > 0) : ?>
<div class='clubs_row'>
<div class='clubs_title_row'>Assoziierte Personen</div>
<div class='clubs_content_row'>
<ul>
<?php foreach($this->persons as $p): ?>
<li>
<a href='?option=com_clubs&view=user&id=<?php echo $p['id']; ?>'><?php echo htmlentities($p['name']); ?></a>:
<?php echo htmlentities($p['position']); ?>
<?php if ($p['modify']) echo ' (Club-Admin)'; ?>
<?php if($this->canModify): ?>
<a href='?option=com_clubs&view=clubassoc&assoc=<?php echo $p['assoc']; ?>'>&Auml;ndern</a>
<a href='?option=com_clubs&task=club.delassoc&assoc=<?php echo $p['assoc']; ?>'>L&ouml;schen</a>
<?php endif; ?>
</li>
<?php endforeach; ?>
<?php foreach($this->club->getUsers() as $uassoc): ?>
<li>
<a href='?option=com_clubs&view=user&id=<?php echo $uassoc->getUser()->getId(); ?>'>
<?php echo htmlentities($uassoc->getUser()->getName()); ?>
</a>:
<?php echo htmlentities($uassoc->getPosition()->getName()); ?>
<?php if ($uassoc->isAdmin()) echo ' (Club-Admin)'; ?>
<!--<?php //if($this->canModify): ?>
<a href='?option=com_clubs&view=clubassoc&assoc=<?php //echo $p['assoc']; ?>'>&Auml;ndern</a>
<a href='?option=com_clubs&task=club.delassoc&assoc=<?php //echo $p['assoc']; ?>'>L&ouml;schen</a>-->
<?php //endif; ?>
</li>
<?php endforeach; ?>
</ul>
<?php if($this->canModify): ?>
<a href='<?php echo $this->urlNewPerson; ?>'>Neue Assoziation anlegen</a>
<?php endif; ?>
<?php //if($this->canModify): ?>
<a href='<?php echo ""; ?>'><span class='icon-new'></span>&nbsp; Neue Assoziation anlegen</a>
<?php //endif; ?>
</div>
</div>
<?php endif; ?>
<?php if($this->canModify): ?>
<div class='clubs_row'>
<a href="?option=com_clubs&view=clubdata&clubid=<?php echo $this->clubid; ?>">Stammdaten anpassen</a><br />
<a href="?option=com_clubs&view=clubplaces&clubid=<?php echo $this->clubid; ?>">R&auml;umlichkeiten anpassen</a><br />
</div>
<?php endif; ?>

View File

@ -1,8 +1,7 @@
<?php
use Joomla\CMS\MVC\View\HtmlView;
use Joomla\CMS\Factory;
use Joomla\CMS\Uri\Uri;
use Joomla\CMS\MVC\View\HtmlView;
// No direct access.
defined('_JEXEC') or die;
@ -10,49 +9,21 @@ defined('_JEXEC') or die;
class ClubsViewClub extends HtmlView
{
public function display(string $tpl = null)
public function display($tpl = null)
{
// FIXME Insert code from DB
$this->clubid = 43;
$this->clubname = "Testclub";
$this->address = "Strasse 1\n66123 Ort";
$this->contactperson = "Max Mustermann";
$this->email = "me@club.de";
$this->phone = "012345";
$this->internet = "http://wichtig.de";
$input = Factory::getApplication()->input;
$id = $input->getInt('clubid', -1);
$this->options = array("Step" => NULL, "JMD" => 1, "Divers." => NULL);
$this->hasOptions = false;
foreach($this->options as $o)
if(isset($o))
$clubFactory = new CommonClubsModelFactoryClub();
$this->club = $clubFactory->loadById($id);
$this->hasOffers = false;
foreach($this->club->getOffers() as $o)
if($o['valid'])
{
$this->hasOptions = true;
$this->hasOffers = true;
break;
}
$this->trainingPlaces = array();
// $this->trainingPlaces[] = array('name'=>'Schule', 'street'=>'Straße', 'city'=>'SB', 'plz'=>'12345');
// $this->trainingPlaces[] = array('name'=>'Schule', 'street'=>'Straße', 'city'=>'SB', 'plz'=>'12345');
$this->persons = array();
$this->persons[] = array('name'=>'Max', 'position'=>'Präsident', 'id'=>3, 'assoc'=>6, 'modify'=>true);
$this->persons[] = array('name'=>'Max', 'position'=>'Präsident', 'id'=>3, 'assoc'=>7, 'modify'=>false);
$this->canModify = true;
// ?option=com_clubs&view=searchperson&data=<?php echo urlencode('{"clubid":' . $this->clubid . "}");
$dataValue = array();
$dataValue['clubid'] = $this->clubid;
$dataAbort = array(
'urlAbort' => (Uri::getInstance()->toString()),
'urlSelect' => '?option=com_clubs&view=clubassoc&person=%u',
'data' => json_encode($dataValue)
);
$this->urlNewPerson = htmlentities("?option=com_clubs&view=searchperson&" . http_build_query($dataAbort));
Factory::getDocument()->addStyleSheet(Uri::base(true) . "components/com_clubs/css/clubs.css");
parent::display($tpl);
}
}

View File

@ -11,11 +11,12 @@ defined('_JEXEC') or die;
class ClubsViewClubAssoc extends HtmlView
{
public function display(string $tpl = null)
public function display($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';

View File

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

Some files were not shown because too many files have changed in this diff Show More