Exemple #1
0
 public function mastery()
 {
     // auth
     Util\Auth::isAuthorized($this->signedUser, 'member', false, '/profile/sign-in');
     \Own\Bus\Match\Data::checkMatchToView($this->player->getId());
     // params
     $form = true;
     $id = Util\Converter::toInt('id');
     if ($id == 0) {
         $player = $this->player;
     } else {
         $player = \Own\Bus\Player\Data::loadById($id);
         if (!isset($player)) {
             $player = $this->player;
         } else {
             if ($player->getId() != $this->player->getId()) {
                 $form = false;
             }
         }
     }
     $playerForm = new \Own\Bus\Player\Form($player);
     $save = Util\Converter::toString('save', 'post');
     if ($save != '') {
         $oldMastery = $this->player->getMasteryValues();
         $properties = \Own\Bus\Player\Service::getMasteryList();
         if (!$playerForm->setFromPost($properties)->validate($properties)->isValid()) {
             Util\Session::setAndRedirect('siteError', $playerForm->getValidation()->getMessage(), '/profile/mastery');
         }
         if (!$player->isValidMastery($oldMastery)) {
             Util\Session::setAndRedirect('siteError', 'Mastery skills could not be saved!', '/profile/mastery');
         }
         $player->save();
         Util\Session::setAndRedirect('siteSuccess', 'Mastery skills saved', '/profile/mastery');
     }
     // view
     $this->setTpl();
     // form
     $tplForm = new Util\Template(Util\Template::MODULE, ['bus', 'player']);
     $tplForm->set('form', $form);
     // layout
     $tplForm->set('item', $playerForm);
     $this->tplLayout->set('column1', $tplForm->render('form-mastery'));
     // template
     $this->tplMaster->set('layout', $this->tplLayout->render('layout-center'));
     return $this->tplMaster->render('tpl-default');
 }
Exemple #2
0
 public function getMasteryValues()
 {
     $masteries = Service::getMasteryList();
     $list = [];
     foreach ($masteries as $mastery) {
         $list[] = $this->{$mastery};
     }
     return $list;
 }