public function post_form() { if (midgardmvc_core::get_instance()->authentication->is_user()) { midgardmvc_core::get_instance()->head->relocate('/'); return; } // Read values from POST $tmp_user = new fi_openkeidas_registration_user(); $form = $this->generate_form($tmp_user); $form->process_post(); $user = $this->check_existing($form->memberid->value); // Populate user midgardmvc_helper_forms_mgdschema::form_to_object($form, $user); $password = $this->generate_password(); $account = $this->create_account($user, $password); /* midgardmvc_core::get_instance()->authentication->login(array( 'login' => $account->login, 'password' => $password )); */ $this->send_password($user->email, "{$user->firstname} {$user->lastname}", $password); midgardmvc_core::get_instance()->uimessages->add(array('title' => 'Käyttäjätunnus luotu', 'message' => 'Sinulle on nyt luotu käyttäjätunnus. Saat salasanan pian sähköpostiisi.', 'type' => 'ok')); midgardmvc_core::get_instance()->head->relocate('/mgd:login'); }
public function process_form() { $this->data['form']->process_post(); midgardmvc_helper_forms_mgdschema::form_to_object($this->data['form'], $this->object); }
public static function form_to_object(midgardmvc_helper_forms_group $form, $object) { // Go through form items and fill the object $items = $form->items; foreach ($items as $key => $item) { if (!property_exists($object, $key)) { // The object has no such property continue; } if ($item instanceof midgardmvc_helper_forms_group && $key == 'metadata') { midgardmvc_helper_forms_mgdschema::form_to_object($item, $object->metadata); continue; } $object->{$key} = $item->get_value(); } }
public function post_update(array $args) { $this->get_update($args); try { $this->data['form']->process_post(); midgardmvc_helper_forms_mgdschema::form_to_object($this->data['form'], $this->object); $this->object->update(); // FIXME: We can remove this once signals work again midgardmvc_core::get_instance()->cache->invalidate(array($this->object->guid)); // TODO: add uimessage of $e->getMessage(); midgardmvc_core::get_instance()->head->relocate($this->get_url_read()); } catch (midgardmvc_helper_forms_exception_validation $e) { // TODO: UImessage } }