@@ -27,99 +27,99 @@ |
||
| 27 | 27 | |
| 28 | 28 | class RegisterPage extends PageType { |
| 29 | 29 | |
| 30 | - public function getContent(): string { |
|
| 31 | - $template = new DwooTemplate("pages/register"); |
|
| 32 | - |
|
| 33 | - $registration_enabled = Settings::get("registration_enabled", false); |
|
| 34 | - |
|
| 35 | - if (!$registration_enabled) { |
|
| 36 | - //registration is not enabled |
|
| 37 | - $template->assign("registration_enabled", false); |
|
| 38 | - } else { |
|
| 39 | - $template->assign("registration_enabled", true); |
|
| 40 | - $template->assign("action_url", DomainUtils::generateURL($this->getPage()->getAlias())); |
|
| 41 | - |
|
| 42 | - $fields = array(); |
|
| 43 | - |
|
| 44 | - //add fields |
|
| 45 | - $fields[] = array( |
|
| 46 | - 'name' => "username", |
|
| 47 | - 'title' => "Username", |
|
| 48 | - 'type' => "text", |
|
| 49 | - 'placeholder' => "Username", |
|
| 50 | - 'required' => true, |
|
| 51 | - 'value' => (isset($_REQUEST['username']) && !empty($_REQUEST['username']) ? str_replace("\"", "", $_REQUEST['username']) : ""), |
|
| 52 | - 'custom_html' => false, |
|
| 53 | - 'text_behind', |
|
| 54 | - 'text_behind' => "" |
|
| 55 | - ); |
|
| 56 | - |
|
| 57 | - $fields[] = array( |
|
| 58 | - 'name' => "mail", |
|
| 59 | - 'title' => "E-Mail", |
|
| 60 | - 'type' => "email", |
|
| 61 | - 'placeholder' => "[email protected]", |
|
| 62 | - 'required' => true, |
|
| 63 | - 'value' => (isset($_REQUEST['mail']) && !empty($_REQUEST['mail']) ? str_replace("\"", "", $_REQUEST['mail']) : ""), |
|
| 64 | - 'custom_html' => false, |
|
| 65 | - 'text_behind' => "" |
|
| 66 | - ); |
|
| 67 | - |
|
| 68 | - $fields[] = array( |
|
| 69 | - 'name' => "password", |
|
| 70 | - 'title' => "Password", |
|
| 71 | - 'type' => "password", |
|
| 72 | - 'placeholder' => "Password", |
|
| 73 | - 'required' => true, |
|
| 74 | - 'value' => "", |
|
| 75 | - 'custom_html' => false, |
|
| 76 | - 'text_behind' => "" |
|
| 77 | - ); |
|
| 78 | - |
|
| 79 | - $fields[] = array( |
|
| 80 | - 'name' => "password_repeat", |
|
| 81 | - 'title' => "Repeat password", |
|
| 82 | - 'type' => "password", |
|
| 83 | - 'placeholder' => "Password", |
|
| 84 | - 'required' => true, |
|
| 85 | - 'value' => "", |
|
| 86 | - 'custom_html' => false, |
|
| 87 | - 'text_behind' => "" |
|
| 88 | - ); |
|
| 89 | - |
|
| 90 | - $fields[] = array( |
|
| 91 | - 'name' => "agb", |
|
| 92 | - 'title' => "Terms of use", |
|
| 93 | - 'type' => "checkbox", |
|
| 94 | - 'placeholder' => "", |
|
| 95 | - 'required' => true, |
|
| 96 | - 'value' => "", |
|
| 97 | - 'custom_html' => false, |
|
| 98 | - 'text_behind' => " I have read and agree with the <a href=\"" . DomainUtils::generateURL(Settings::get("agb_page", "agb")) . "\" target=\"_blank\">terms of use</a>" |
|
| 99 | - ); |
|
| 100 | - |
|
| 101 | - Events::throwEvent("register_fields", array( |
|
| 102 | - 'fields' => &$fields, |
|
| 103 | - 'template' => &$template |
|
| 104 | - )); |
|
| 105 | - |
|
| 106 | - if (isset($_REQUEST['submit']) && !empty($_REQUEST['submit'])) { |
|
| 107 | - //TODO: check fields |
|
| 108 | - |
|
| 109 | - //TODO: check CSRF token |
|
| 110 | - } |
|
| 111 | - |
|
| 112 | - $template->assign("fields", $fields); |
|
| 113 | - |
|
| 114 | - //TODO: add code here |
|
| 115 | - } |
|
| 116 | - |
|
| 117 | - return $template->getCode(); |
|
| 118 | - } |
|
| 119 | - |
|
| 120 | - public function listRequiredPermissions(): array { |
|
| 121 | - return array("not_logged_in"); |
|
| 122 | - } |
|
| 30 | + public function getContent(): string { |
|
| 31 | + $template = new DwooTemplate("pages/register"); |
|
| 32 | + |
|
| 33 | + $registration_enabled = Settings::get("registration_enabled", false); |
|
| 34 | + |
|
| 35 | + if (!$registration_enabled) { |
|
| 36 | + //registration is not enabled |
|
| 37 | + $template->assign("registration_enabled", false); |
|
| 38 | + } else { |
|
| 39 | + $template->assign("registration_enabled", true); |
|
| 40 | + $template->assign("action_url", DomainUtils::generateURL($this->getPage()->getAlias())); |
|
| 41 | + |
|
| 42 | + $fields = array(); |
|
| 43 | + |
|
| 44 | + //add fields |
|
| 45 | + $fields[] = array( |
|
| 46 | + 'name' => "username", |
|
| 47 | + 'title' => "Username", |
|
| 48 | + 'type' => "text", |
|
| 49 | + 'placeholder' => "Username", |
|
| 50 | + 'required' => true, |
|
| 51 | + 'value' => (isset($_REQUEST['username']) && !empty($_REQUEST['username']) ? str_replace("\"", "", $_REQUEST['username']) : ""), |
|
| 52 | + 'custom_html' => false, |
|
| 53 | + 'text_behind', |
|
| 54 | + 'text_behind' => "" |
|
| 55 | + ); |
|
| 56 | + |
|
| 57 | + $fields[] = array( |
|
| 58 | + 'name' => "mail", |
|
| 59 | + 'title' => "E-Mail", |
|
| 60 | + 'type' => "email", |
|
| 61 | + 'placeholder' => "[email protected]", |
|
| 62 | + 'required' => true, |
|
| 63 | + 'value' => (isset($_REQUEST['mail']) && !empty($_REQUEST['mail']) ? str_replace("\"", "", $_REQUEST['mail']) : ""), |
|
| 64 | + 'custom_html' => false, |
|
| 65 | + 'text_behind' => "" |
|
| 66 | + ); |
|
| 67 | + |
|
| 68 | + $fields[] = array( |
|
| 69 | + 'name' => "password", |
|
| 70 | + 'title' => "Password", |
|
| 71 | + 'type' => "password", |
|
| 72 | + 'placeholder' => "Password", |
|
| 73 | + 'required' => true, |
|
| 74 | + 'value' => "", |
|
| 75 | + 'custom_html' => false, |
|
| 76 | + 'text_behind' => "" |
|
| 77 | + ); |
|
| 78 | + |
|
| 79 | + $fields[] = array( |
|
| 80 | + 'name' => "password_repeat", |
|
| 81 | + 'title' => "Repeat password", |
|
| 82 | + 'type' => "password", |
|
| 83 | + 'placeholder' => "Password", |
|
| 84 | + 'required' => true, |
|
| 85 | + 'value' => "", |
|
| 86 | + 'custom_html' => false, |
|
| 87 | + 'text_behind' => "" |
|
| 88 | + ); |
|
| 89 | + |
|
| 90 | + $fields[] = array( |
|
| 91 | + 'name' => "agb", |
|
| 92 | + 'title' => "Terms of use", |
|
| 93 | + 'type' => "checkbox", |
|
| 94 | + 'placeholder' => "", |
|
| 95 | + 'required' => true, |
|
| 96 | + 'value' => "", |
|
| 97 | + 'custom_html' => false, |
|
| 98 | + 'text_behind' => " I have read and agree with the <a href=\"" . DomainUtils::generateURL(Settings::get("agb_page", "agb")) . "\" target=\"_blank\">terms of use</a>" |
|
| 99 | + ); |
|
| 100 | + |
|
| 101 | + Events::throwEvent("register_fields", array( |
|
| 102 | + 'fields' => &$fields, |
|
| 103 | + 'template' => &$template |
|
| 104 | + )); |
|
| 105 | + |
|
| 106 | + if (isset($_REQUEST['submit']) && !empty($_REQUEST['submit'])) { |
|
| 107 | + //TODO: check fields |
|
| 108 | + |
|
| 109 | + //TODO: check CSRF token |
|
| 110 | + } |
|
| 111 | + |
|
| 112 | + $template->assign("fields", $fields); |
|
| 113 | + |
|
| 114 | + //TODO: add code here |
|
| 115 | + } |
|
| 116 | + |
|
| 117 | + return $template->getCode(); |
|
| 118 | + } |
|
| 119 | + |
|
| 120 | + public function listRequiredPermissions(): array { |
|
| 121 | + return array("not_logged_in"); |
|
| 122 | + } |
|
| 123 | 123 | |
| 124 | 124 | } |
| 125 | 125 | |