/**
  * Processing of organization member editation form
  *
  * @Privilege("edit", "create")
  *
  * @param Form $form
  */
 public function organizationFormSucceded(Form $form)
 {
     $values = $form->getValues(TRUE);
     unset($values['send']);
     //handle file upload
     $file = $values['file'];
     unset($values['file']);
     $params = $this->context->parameters;
     $path = $params['wwwDir'] . $params['memberPhotosStorage'] . '/';
     if ($file->isOk()) {
         if ($file->isImage()) {
             //make sure the file will be JPEG
             $image = $file->toImage();
             $filename = \Nette\Utils\Strings::lower(\Nette\Utils\Strings::toAscii($values['nickname'])) . ".jpg";
             $image->save($path . $filename, 100, \Nette\Image::JPEG);
         }
     }
     $item = $this->members->get($values['nickname']);
     if ($item) {
         $item->update($values);
         $this->flashMessage('Záznam byl úspěšně aktualizován');
     } else {
         $this->members->insert($values);
         $this->flashMessage('Záznam byl úspěšně vytvořen');
     }
     $this->redirect('default');
 }
 /**
  * Edit individual invitation to an event
  *
  * @Privilege("edit")
  *
  * @param int $id           Event ID
  */
 public function actionEdit($id)
 {
     $item = $this->loadEvent($id);
     $form = $this['editEventForm'];
     $form->setDefaults($item);
     if (!$item->contactperson) {
         $member = $this->members->getBy(['user_id' => $this->user->id]);
         if ($member && in_array($member->nickname, $form['contactperson']->getItems(), TRUE)) {
             $form['contactperson']->setDefaultValue($member->nickname);
         }
     }
     $form['event_meeting']->setDefaults($item->related('event_meeting')->fetchPairs('event_id'));
 }
 /**
  * Form for editing a post
  *
  * @Privilege("edit")
  * @Action("edit")
  */
 protected function createComponentGuestbookForm()
 {
     $form = new \Nette\Application\UI\Form();
     $form->addProtection('Vypršel časový limit, odešlete formulář znovu');
     $form->addHidden('id');
     $members = $this->members->getAuthenticatedUsers()->fetchPairs('user_id', 'nickname');
     $user_id = $form->addSelect('user_id', 'Ověřený uživatel:', $members)->setPrompt('Vyberte uživatele');
     $form->addText('name', 'Jméno:')->setAttribute('size', 30)->addConditionOn($form['user_id'], ~\Nette\Application\UI\Form::FILLED)->addRule(\Nette\Application\UI\Form::FILLED, 'Musíte buď vybrat uživatele nebo zadat jméno pro příspěvek');
     $user_id->addConditionOn($form['name'], ~\Nette\Application\UI\Form::FILLED)->addRule(\Nette\Application\UI\Form::FILLED, 'Musíte buď vybrat uživatele nebo zadat jméno pro příspěvek');
     $form->addDateTimePicker('time', 'Čas příspěvku')->setAttribute('size', 30);
     $form->addTextarea('post', 'Vzkaz:')->setAttribute('cols', 50)->setAttribute('rows', 5)->setRequired('Musíte zadat text vzkazu');
     $form->addText('mail', 'E-mail:')->setAttribute('size', 30)->addCondition(\Nette\Application\UI\Form::FILLED)->addRule(\Nette\Application\UI\Form::EMAIL, 'Musí se jednat o platný e-mail');
     $form->addText('web', 'Web:')->setAttribute('size', 30);
     $form->addSubmit('send', 'Změnit');
     $form->onSuccess[] = $this->guestFormSucceded;
     return $form;
 }
 /**
  * Registration form
  *
  * @Action("create", "edit")
  * @Privilege("create", "edit")
  */
 protected function createComponentRegistrationForm()
 {
     $form = new \Nette\Application\UI\Form();
     $form->addProtection('Vypršel časový limit, odešlete formulář znovu');
     $members = $this->members->getMembersWithoutRegistration()->fetchPairs('nickname', 'nickname');
     $member_nickname = $form->addSelect('nickname', 'Členové bez registrace:', $members)->setPrompt('Vyberte člena');
     $form->addText('member_nickname', 'Přesdívka:')->addConditionOn($form['nickname'], ~\Nette\Application\UI\Form::FILLED)->addRule(\Nette\Application\UI\Form::FILLED, 'Musíte vybrat přezdívku');
     $member_nickname->addConditionOn($form['member_nickname'], ~\Nette\Application\UI\Form::FILLED)->addRule(\Nette\Application\UI\Form::FILLED, 'Musíte vybrat přezdívku');
     $form->addDatePicker('birth_date', 'Datum Narození:')->setRequired('Vyplňte datum narození');
     $form->addText('oddil', 'Oddíl:')->setType('number');
     $form->addTextarea('address', 'Adresa:')->setOption('description', \Nette\Utils\Html::el('td')->setText('Oddělujte novým řádkem'))->setAttribute('rows', 4)->setAttribute('cols', 30);
     $form->addText('mobile', 'Telefon:');
     $form->addText('registration_number', 'Registrační Číslo:')->setOption('description', \Nette\Utils\Html::el('td')->setText('To samé co v IS skautu'));
     $form->addSubmit('send', 'Přidat/Změnit');
     $form->onSuccess[] = $this->registrationFormSucceded;
     return $form;
 }
 /**
  * Form for inputting information about the event to form chronicle
  * Can only be accessed by user with editing privileges and only in "edit" action
  *
  * @Privilege("edit")
  * @Action("edit")
  */
 protected function createComponentEditChronicleForm()
 {
     $form = new Form();
     $form->addProtection('Vypršel časový limit, odešlete formulář znovu');
     $form->addHidden('id');
     $form->addText('name', 'Název akce');
     $form->addTextarea('rangers', 'Vedení a roveři');
     $form->addTextarea('mloci', 'Mloci:');
     $form->addTextarea('tucnaci', 'Tučňáci:');
     $form->addTextarea('novacci', 'Nováčci:');
     $form->addTextarea('route', 'Trasa:');
     $form->addTextarea('content', 'Zápis do kroniky:');
     $writers = $this->members->findAll()->fetchPairs('nickname', 'nickname');
     $form->addSelect('chroniclewriter', 'Zapsal do kroniky:', $writers)->setRequired('Musíte vybrat, kdo zapsal akci do kroniky')->setPrompt('Vyberte člena');
     if ($this->user->isAllowed('Admin:Default:Chronicle', 'show')) {
         $form->addCheckbox('showchronicle', 'Zobrazit kroniku:')->setDefaultValue(TRUE);
     }
     $form->addSubmit('send', 'Upravit');
     $form->onSuccess[] = $this->editChronicleFormSucceded;
     return $form;
 }
Esempio n. 6
0
 /**
  * Clears the current object, sets all attributes to their default values and removes
  * outgoing references as well as back-references (from other objects to this one. Results probably in a database
  * change of those foreign objects when you call `save` there).
  */
 public function clear()
 {
     if (null !== $this->aImage) {
         $this->aImage->removeUser($this);
     }
     if (null !== $this->aMember) {
         $this->aMember->removeUser($this);
     }
     $this->id = null;
     $this->id_member = null;
     $this->username = null;
     $this->member_from = null;
     $this->url = null;
     $this->email = null;
     $this->email_confirmed_at = null;
     $this->email_confirm_token = null;
     $this->email_change_token = null;
     $this->password = null;
     $this->password_reset_token = null;
     $this->permissions = null;
     $this->signin_count = null;
     $this->id_image = null;
     $this->last_signin_at = null;
     $this->created_at = null;
     $this->updated_at = null;
     $this->alreadyInSave = false;
     $this->clearAllReferences();
     $this->resetModified();
     $this->setNew(true);
     $this->setDeleted(false);
 }
 /**
  * Sets variables for view of "Tučňáci" page
  */
 public function renderTucnak()
 {
     $template = $this->template;
     $template->title = 'Tučňáci';
     $template->members = $this->members->getTucnaci();
 }
Esempio n. 8
0
 /**
  * Filter the query by a related \Models\Member object
  *
  * @param \Models\Member|ObjectCollection $member The related object(s) to use as filter
  * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  *
  * @throws \Propel\Runtime\Exception\PropelException
  *
  * @return ChildUserQuery The current query, for fluid interface
  */
 public function filterByMember($member, $comparison = null)
 {
     if ($member instanceof \Models\Member) {
         return $this->addUsingAlias(UserTableMap::COL_ID_MEMBER, $member->getId(), $comparison);
     } elseif ($member instanceof ObjectCollection) {
         if (null === $comparison) {
             $comparison = Criteria::IN;
         }
         return $this->addUsingAlias(UserTableMap::COL_ID_MEMBER, $member->toKeyValue('PrimaryKey', 'Id'), $comparison);
     } else {
         throw new PropelException('filterByMember() only accepts arguments of type \\Models\\Member or Collection');
     }
 }
 /**
  * Sets variables for view of "Nábor" page
  */
 public function renderRecruit()
 {
     $template = $this->template;
     $template->title = 'Nábor';
     $template->leader = $this->members->getLeader();
 }
Esempio n. 10
0
 public function acceptMembershipApplication($id)
 {
     $app = MembershipApplicationQuery::create()->findPk($id);
     if ($app == NULL) {
         $this->addPopup("danger", "Žádost o členství se zadaným identifikačním číslem se v databázi nenachází.");
         redirectTo("/administrace/zadosti-o-clenstvi");
     }
     if ($app->getState() != "pending") {
         $this->addPopup("danger", "Žádost o členství se zadaným identifikačním číslem již byla schválena nebo zamítnuta.");
         redirectTo("/administrace/zadosti-o-clenstvi");
     }
     $app->setState('accepted');
     $app->setAcceptedAt(time());
     $app->save();
     $token = token(30);
     $member = new Member();
     $member->setName($app->getName());
     $member->setSurname($token);
     $member->setMemberFrom($app->getCreatedAt());
     $member->save();
     $member_id = MemberQuery::create()->filterBySurname($token)->findOne();
     $member_id->setSurname($app->getSurname());
     $member_id->save();
     $user = UserQuery::create()->findPk($app->getIdUser());
     $user->setIdMember($member_id->getId());
     if ($user->getPermissions() == 0) {
         $user->setPermissions(1);
     }
     $user->save();
     $this->addPopup("success", "Žádost o členství byla úspěšně přijata. Uživateli byl vytvořen DofE účet.");
     redirectTo("/administrace/zadosti-o-clenstvi");
 }