diff --git a/module/fid_bbi/config/module.config.php b/module/fid_bbi/config/module.config.php index cf5f12dd41cf262f53c873701e9137b1d0bb6686..1a74ae80a7b948bce4854ba52ffddb221458c6a0 100644 --- a/module/fid_bbi/config/module.config.php +++ b/module/fid_bbi/config/module.config.php @@ -30,6 +30,7 @@ $config = [ 'forms' => [ 'user-init-form' => require 'user-init-form.php', 'user-create-form' => require 'user-create-form.php', + 'user-update-form' => require 'user-update-form.php', ], 'controllers' => [ 'factories' => [ diff --git a/module/fid_bbi/config/user-update-form.php b/module/fid_bbi/config/user-update-form.php new file mode 100644 index 0000000000000000000000000000000000000000..e5bec01b57c97f58d7b92dcc1345aa8a2b7a26d2 --- /dev/null +++ b/module/fid_bbi/config/user-update-form.php @@ -0,0 +1,52 @@ +<?php +/** + * Copyright (C) 2019 Leipzig University Library + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> + * @author Gregor Gawol <gawol@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + */ + +return [ + 'elements' => [ + 'firstname' => [ + 'spec' => [ + 'attributes' => [ + 'required' => false, + ], + ], + ], + 'lastname' => [ + 'spec' => [ + 'attributes' => [ + 'required' => false, + ], + ], + ], + 'home_library' => [ + 'spec' => [ + 'attributes' => [ + 'required' => false, + ], + ], + ], + ], + 'input_filter' => [ + 'home_library' => [ + 'required' => false, + ], + ], +]; \ No newline at end of file diff --git a/themes/fid_bbi/templates/fid/user/update.phtml b/themes/fid_bbi/templates/fid/user/update.phtml deleted file mode 100644 index 8213d1e359139a62a9594102d1049c87755d88de..0000000000000000000000000000000000000000 --- a/themes/fid_bbi/templates/fid/user/update.phtml +++ /dev/null @@ -1,187 +0,0 @@ -<?php -/** - * Copyright (C) 2019 Leipzig University Library - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * @author Gregor Gawol <gawol@ub.uni-leipzig.de> - * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> - * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 - */ - -use fid\Service\DataTransferObject\Address; -use fid\Service\DataTransferObject\User; -use Zend\Form\Element as Element; -use Zend\Form\Element\Submit; -use Zend\Form\Form; -use Zend\Form\View\Helper\FormElementErrors; -use Zend\Form\View\Helper\FormLabel; -use Zend\Form\View\Helper\FormRadio; -use Zend\Form\View\Helper\FormSelect; -use Zend\Form\View\Helper\FormSubmit; -use Zend\I18n\Translator\TranslatorInterface; - -/** @var FormLabel $formLabel */ -$formLabel = $this->formLabel(); -/**@var FormRadio $formRadio */ -$formRadio = $this->formRadio(); -/**@var FormSelect $formSelect */ -$formSelect = $this->formSelect(); -/**@var FormSubmit $formSubmit */ -$formSubmit = $this->formSubmit(); -/** @var FormElementErrors $formElementErrors */ -$formElementErrors = $this->formElementErrors(); -$formLabel->setTranslatorTextDomain('fid'); -$formSelect->setTranslatorTextDomain('fid'); -$formRadio->setTranslatorTextDomain('fid'); -$formSubmit->setTranslatorTextDomain('fid'); -$formElementErrors->setTranslatorTextDomain('fid'); -/** @var TranslatorInterface $translator */ -$translator = $this->getHelperPluginManager()->get('translate') - ->getTranslator(); - -$formLabel->setTranslator($translator); -$formElementErrors->setTranslator($translator); - -/** @var Form $form */ -/** @var User $user */ -$user = $this->user; -$form = $this->form; -$form->setAttribute('method', 'post'); -$form->setAttribute('action', $this->url('fid/user/update')); -$form->setAttribute('class', 'form-horizontal'); -$form->prepare(); - -$this->headTitle($this->translate('Profile Form')); -$this->headTitle($this->translate("fid::user_update_form_title")); -?> - - <h2><?= $this->translate("fid::user_update_form_title") ?></h2> -<?= $this->flashmessages() ?> -<?= $this->form()->openTag($form) ?> - <br/> - -<? /* home library */ ?> -<?php -/** @var Element\Select $elemHomeLibrary */ -$elemHomeLibrary = $form->get('homeLibrary'); -$elemHomeLibrary->setLabelAttributes(['class' => 'inline col-md-4 col-sm-10']); -$elemHomeLibrary->setAttributes(['class' => 'inline col-sm-6']); -$elemHomeLibrary->setValue($elemHomeLibrary->getValue() ?? $user->getHomeLibrary()); -?> - <div class="form-group"> - <?= $this->formLabel($elemHomeLibrary) ?> - <?= $this->formSelect($elemHomeLibrary) ?> - <?= $this->formElementErrors($elemHomeLibrary) ?> - </div> - -<? /* salutation */ ?> -<?php -/** @var Element\Select $elemSalutation */ -$elemSalutation = $form->get('salutation'); -$elemSalutation->setAttribute('type', 'hidden'); -echo $this->formElement($elemSalutation); -?> - -<? /* academic title */ ?> -<?php -/** @var Element\Text $elemAcademicTitle */ -$elemAcademicTitle = $form->get('academicTitle'); -$elemAcademicTitle->setLabelAttributes(['class' => 'inline col-md-4 col-sm-10']); -$elemAcademicTitle->setAttributes(['class' => 'form-control']); -$elemAcademicTitle->setValue($elemAcademicTitle->getValue() ?? $user->getAcademicTitle()); -?> - <div class="form-group"> - <?= $this->formLabel($elemAcademicTitle) ?> - <?= $this->formElement($elemAcademicTitle) ?> - </div> - -<? /* firstname */ ?> -<?php -/** @var Element\Text $elemFirstname */ -$elemFirstname = $form->get('firstname'); -$elemFirstname->setLabelAttributes(['class' => 'inline col-md-4 col-sm-10']); -$elemFirstname->setAttributes(['class' => 'form-control']); -$elemFirstname->setValue($elemFirstname->getValue() ?? $user->getFirstname()); -?> - <div class="form-group"> - <?= $this->formLabel($elemFirstname) ?> - <?= $this->formElement($elemFirstname) ?> - <?= $this->formElementErrors($elemFirstname) ?> - </div> - -<? /* lastname */ ?> -<?php -/** @var Element\Text $elemLastname */ -$elemLastname = $form->get('lastname'); -$elemLastname->setLabelAttributes(['class' => 'inline col-md-4 col-sm-10']); -$elemLastname->setAttributes(['class' => 'form-control']); -$elemLastname->setValue($elemLastname->getValue() ?? $user->getLastname()); -?> - <div class="form-group"> - <?= $this->formLabel($elemLastname) ?> - <?= $this->formElement($elemLastname) ?> - <?= $this->formElementErrors($elemLastname) ?> - </div> - -<? /* year of birth */ ?> -<?php -/** @var Element\Text $elemYearOfBirth */ -$elemYearOfBirth = $form->get('yearOfBirth'); -$elemYearOfBirth->setAttribute('type', 'hidden'); -echo $this->formElement($elemYearOfBirth); -?> - -<? /* college */ ?> -<?php -/** @var Element\Text $elemCollege */ -$elemCollege = $form->get('college'); -$elemCollege->setLabelAttributes(['class' => 'inline col-md-4 col-sm-10']); -$elemCollege->setAttributes(['class' => 'form-control']); -$elemCollege->setValue($elemCollege->getValue() ?? $user->getCollege()); -?> - <div class="form-group"> - <?= $this->formLabel($elemCollege) ?> - <?= $this->formElement($elemCollege) ?> - <?= $this->formElementErrors($elemCollege) ?> - </div> - -<? /* job title */ ?> -<?php -/** @var Element\Text $elemJobTitle */ -$elemJobTitle = $form->get('jobTitle'); -$elemJobTitle->setAttribute('type', 'hidden'); -echo $this->formElement($elemJobTitle); -?> - -<? /* addresses */ ?> -<?= $this->render('update-addresses.phtml', compact('form', 'user')) ?> - -<? /* submit button */ ?> -<?php -/** @var Submit $elemSubmit */ -$elemSubmit = $form->get('submit'); -$elemSubmit->setAttributes(['class' => 'btn btn-primary']); -?> - <div class="form-group"> - <div class="col-lg-11 col-md-9 col-sm-11 col-xs-12"> - <?= $this->formSubmit($elemSubmit) ?> - <a href="<?= $this->url('myresearch-profile') ?>" - class="btn btn-primary"> - <?= $this->transEsc('Cancel') ?> - </a> - </div> - </div> - -<?= $this->form()->closeTag($form) ?>