diff --git a/src/admin/controllers/position.php b/src/admin/controllers/position.php index 3ffacd6..f647c8d 100644 --- a/src/admin/controllers/position.php +++ b/src/admin/controllers/position.php @@ -1,108 +1,21 @@ input; - $p = ClubsPosition::createPosition(); - - // Fetch the posted data - $name = $input->post->getString('name'); - - // Check the input data - $error = false; - - // Check existence of the other fields - $fields = array('name'=>'Bezeichnung'); - foreach ($fields as $f => $fname) - { - $fvalue = $$f; - if(! isset($fvalue) || empty(trim($fvalue))) - { - $app->enqueueMessage("Das Feld $fname ist obligatorisch.", 'error'); - $error = true; - } - } - - if($error) - { - $data = array(); - foreach(array('name') as $i) - $data[$i] = $$i; - - $urldata = urlencode(json_encode($data)); - $this->setRedirect(Route::_('index.php?option=com_clubs&view=position&id=new&data=' . $urldata, false)); - return; - } - - $p->setName($name); - - // Do the actual work - $p->save(); - $this->setRedirect(Route::_('index.php?option=com_clubs&view=positions', false)); + return 'position'; } - - function change() + + protected function getDataMapping() { - $app = Factory::getApplication(); - $input = $app->input; - $id = (int) $input->post->getInt('id'); - $p = ClubsPosition::loadPosition((int) $id); - - // Fetch the posted data - $name = $input->post->getString('name'); - - // Check the input data - $error = false; - - // Check existence of the other fields - $fields = array('name'=>'Bezeichnung'); - foreach ($fields as $f => $fname) - { - $fvalue = $$f; - if(! isset($fvalue) || empty(trim($fvalue))) - { - $app->enqueueMessage("Das Feld $fname ist obligatorisch.", 'error'); - $error = true; - } - } - - if($error) - { - $data = array(); - foreach(array('name') as $i) - $data[$i] = $$i; - - $urldata = urlencode(json_encode($data)); - $this->setRedirect(Route::_('index.php?option=com_clubs&view=offer&id=' . $id . '&data=' . $urldata, false)); - return; - } - - $p->setName($name); - - // Do the actual work - $p->save(); - $this->setRedirect(Route::_('index.php?option=com_clubs&view=positions', false)); + return array( + 'name'=>array('required'=>true, 'filter'=>'string', 'name'=>'Bezeichung') + ); } - - function delete() - { - $app = Factory::getApplication(); - $id = $app->input->get->getInt('id'); - $app->enqueueMessage("Removal of position with id $id."); - $user = ClubsPosition::loadPosition($id); - $user->delete(); - $this->setRedirect(Route::_('index.php?option=com_clubs&view=positions', false)); - } - + } diff --git a/src/admin/mymodels/place.php b/src/admin/mymodels/place.php index 951f739..5faf636 100644 --- a/src/admin/mymodels/place.php +++ b/src/admin/mymodels/place.php @@ -4,7 +4,7 @@ defined('_JEXEC') or die; -class ClubsPlace extends ClubsAbstractModel +class ClubsPlace extends AbstractClubsModel { protected $name; protected $address; diff --git a/src/admin/mymodels/position.php b/src/admin/mymodels/position.php index df6f884..be26076 100644 --- a/src/admin/mymodels/position.php +++ b/src/admin/mymodels/position.php @@ -3,7 +3,7 @@ // No direct access. defined('_JEXEC') or die; -class ClubsPosition extends ClubsAbstractModel +class ClubsPosition extends AbstractClubsModel { protected $name; diff --git a/src/admin/views/position/tmpl/default.php b/src/admin/views/position/tmpl/default.php index 46d4d53..0a9c97e 100644 --- a/src/admin/views/position/tmpl/default.php +++ b/src/admin/views/position/tmpl/default.php @@ -8,16 +8,16 @@ defined('_JEXEC') or die; ?>
- + - + isNew): ?> - +
Bezeichnung
IDposition->getId(); ?>object->getId(); ?>
diff --git a/src/admin/views/position/view.html.php b/src/admin/views/position/view.html.php index 07cf47c..bfd13a0 100644 --- a/src/admin/views/position/view.html.php +++ b/src/admin/views/position/view.html.php @@ -1,46 +1,26 @@ input; - $id = $input->get->get('id'); - - if($id === 'new') - { - $this->address = Route::_('index.php?option=com_clubs&task=position.new'); - $this->position = ClubsPosition::createPosition(); - $this->isNew = true; - } - else if(is_numeric($id)) - { - $this->address = Route::_('index.php?option=com_clubs&task=position.change'); - $this->position = ClubsPosition::loadPosition((int) $id); - $this->isNew = false; - } - else - throw new Exception('Need a position id.'); - - if($input->get->get('data', null, 'json') != null) - { - // Restore previous data - $dataurl = $input->get->get('data', null, 'json'); - $data = json_decode($dataurl, true); - - $this->position->setName($data['name']); - - } - ToolbarHelper::title('Club-Management - Position'); parent::display($tpl); }