From dfe234a7aaaacedcc94716f955b44a1b50c4a057 Mon Sep 17 00:00:00 2001 From: emkael Date: Wed, 6 Apr 2016 13:50:31 +0200 Subject: * components -> controls --- app/php/application.xml | 2 +- app/php/components/CalendarScaffold.php | 127 ---------------------------- app/php/components/CalendarScaffold.tpl | 57 ------------- app/php/components/HeaderMenu.php | 16 ---- app/php/components/HeaderMenu.tpl | 22 ----- app/php/components/LoginBox.php | 23 ----- app/php/components/LoginBox.tpl | 29 ------- app/php/components/PasswordChange.php | 38 --------- app/php/components/PasswordChange.tpl | 52 ------------ app/php/components/RegistrationForm.php | 26 ------ app/php/components/RegistrationForm.tpl | 59 ------------- app/php/components/SafeActiveFileUpload.php | 12 --- app/php/components/SafeFileUpload.php | 34 -------- app/php/components/TimezoneSelect.php | 49 ----------- app/php/components/TimezoneSelect.tpl | 4 - app/php/components/UpcomingEvents.php | 35 -------- app/php/components/UpcomingEvents.tpl | 10 --- app/php/components/UserSelection.php | 39 --------- app/php/components/UserSelection.tpl | 25 ------ app/php/components/config.xml | 6 -- app/php/controls/CalendarScaffold.php | 127 ++++++++++++++++++++++++++++ app/php/controls/CalendarScaffold.tpl | 57 +++++++++++++ app/php/controls/HeaderMenu.php | 16 ++++ app/php/controls/HeaderMenu.tpl | 22 +++++ app/php/controls/LoginBox.php | 23 +++++ app/php/controls/LoginBox.tpl | 29 +++++++ app/php/controls/PasswordChange.php | 38 +++++++++ app/php/controls/PasswordChange.tpl | 52 ++++++++++++ app/php/controls/RegistrationForm.php | 26 ++++++ app/php/controls/RegistrationForm.tpl | 59 +++++++++++++ app/php/controls/SafeActiveFileUpload.php | 12 +++ app/php/controls/SafeFileUpload.php | 34 ++++++++ app/php/controls/TimezoneSelect.php | 49 +++++++++++ app/php/controls/TimezoneSelect.tpl | 4 + app/php/controls/UpcomingEvents.php | 35 ++++++++ app/php/controls/UpcomingEvents.tpl | 10 +++ app/php/controls/UserSelection.php | 39 +++++++++ app/php/controls/UserSelection.tpl | 25 ++++++ app/php/controls/config.xml | 6 ++ 39 files changed, 664 insertions(+), 664 deletions(-) delete mode 100644 app/php/components/CalendarScaffold.php delete mode 100644 app/php/components/CalendarScaffold.tpl delete mode 100644 app/php/components/HeaderMenu.php delete mode 100644 app/php/components/HeaderMenu.tpl delete mode 100644 app/php/components/LoginBox.php delete mode 100644 app/php/components/LoginBox.tpl delete mode 100644 app/php/components/PasswordChange.php delete mode 100644 app/php/components/PasswordChange.tpl delete mode 100644 app/php/components/RegistrationForm.php delete mode 100644 app/php/components/RegistrationForm.tpl delete mode 100644 app/php/components/SafeActiveFileUpload.php delete mode 100644 app/php/components/SafeFileUpload.php delete mode 100644 app/php/components/TimezoneSelect.php delete mode 100644 app/php/components/TimezoneSelect.tpl delete mode 100644 app/php/components/UpcomingEvents.php delete mode 100644 app/php/components/UpcomingEvents.tpl delete mode 100644 app/php/components/UserSelection.php delete mode 100644 app/php/components/UserSelection.tpl delete mode 100644 app/php/components/config.xml create mode 100644 app/php/controls/CalendarScaffold.php create mode 100644 app/php/controls/CalendarScaffold.tpl create mode 100644 app/php/controls/HeaderMenu.php create mode 100644 app/php/controls/HeaderMenu.tpl create mode 100644 app/php/controls/LoginBox.php create mode 100644 app/php/controls/LoginBox.tpl create mode 100644 app/php/controls/PasswordChange.php create mode 100644 app/php/controls/PasswordChange.tpl create mode 100644 app/php/controls/RegistrationForm.php create mode 100644 app/php/controls/RegistrationForm.tpl create mode 100644 app/php/controls/SafeActiveFileUpload.php create mode 100644 app/php/controls/SafeFileUpload.php create mode 100644 app/php/controls/TimezoneSelect.php create mode 100644 app/php/controls/TimezoneSelect.tpl create mode 100644 app/php/controls/UpcomingEvents.php create mode 100644 app/php/controls/UpcomingEvents.tpl create mode 100644 app/php/controls/UserSelection.php create mode 100644 app/php/controls/UserSelection.tpl create mode 100644 app/php/controls/config.xml (limited to 'app/php') diff --git a/app/php/application.xml b/app/php/application.xml index 7b4741a..8b76f74 100644 --- a/app/php/application.xml +++ b/app/php/application.xml @@ -6,7 +6,7 @@ - + diff --git a/app/php/components/CalendarScaffold.php b/app/php/components/CalendarScaffold.php deleted file mode 100644 index f265d53..0000000 --- a/app/php/components/CalendarScaffold.php +++ /dev/null @@ -1,127 +0,0 @@ -setViewState('Facade', $facade); - } - - public function getFacade() { - return $this->getViewState('Facade'); - } - - public function onPreRender($param) { - parent::onPreRender($param); - if (!$this->Page->IsPostBack && !$this->Page->IsCallBack) { - $this->_rebindData(); - } - } - - private function _rebindCalendars(array $calendars) { - $this->Calendars->DataSource = $calendars; - $this->Calendars->dataBind(); - } - - private function _rebindCategoryList(array $categories) { - foreach ($this->Calendars->Columns as $column) { - if ($column->ID === 'Category' - && $column instanceof TActiveDropDownListColumn) { - $column->ListDataSource = $categories; - } - } - } - - private function _rebindData($refresh = FALSE) { - $this->_rebindCategoryList( - $this->_getCategories() - ); - $this->_rebindCalendars( - $this->_getCalendars($refresh) - ); - } - - private function _getCalendars($refresh = FALSE) { - if ($refresh) { - $this->clearViewState('Calendars'); - } - $calendars = $this->getViewState( - 'Calendars', - $this->getFacade()->getAll() - ); - $this->setViewState('Calendars', $calendars); - return $calendars; - } - - private function _getCategories() { - $categories = $this->getViewState( - 'Categories', - $this->getFacade()->getCategories() - ); - $this->setViewState('Categories', $categories); - return $categories; - } - - public function editRow($sender, $param) { - $this->Calendars->EditItemIndex = $param->Item->ItemIndex; - $this->_rebindData(); - } - - private function _compileSaveData(TDataGridItem $item) { - return [ - 'CategoryID' => $item->Category->DropDownList->SelectedValue, - 'Visible' => $item->Visible->CheckBox->Checked, - 'CustomName' => $item->CustomName->TextBox->SafeText, - 'CustomUrl' => $item->CustomUrl->TextBox->SafeText, - 'CustomImage' => $item->CustomImage->Value->SafeText - ]; - } - - public function saveRow($sender, $param) { - $calendar = $this->getFacade()->get( - $sender->DataKeys[$param->Item->ItemIndex] - ); - if ($calendar) { - foreach ($calendar as $c) { - $c->saveData($this->_compileSaveData($param->Item)); - } - } else { - throw new TInvalidDataValueException('Calendar not found'); - } - $this->Calendars->EditItemIndex = -1; - $this->_rebindData(TRUE); - } - - public function cancelRowEdit($sender, $param) { - $this->Calendars->EditItemIndex = -1; - $this->_rebindData(); - } - - public function uploadRowFile($sender, $param) { - $fileType = $sender->getFileType(); - if (preg_match('/^image\//', $fileType)) { - $calendar = $this->getFacade()->get($sender->CustomData); - if ($calendar) { - $targetFile = $calendar[0]->getCustomImagePath( - $sender->getLocalName(), - $fileType - ); - if ($sender->saveAs($targetFile)) { - $sender->NamingContainer->CustomImage->Value->Text = basename( - $targetFile - ); - } - } else { - throw new TInvalidDataValueException('Calendar not found'); - } - } else { - throw new TInvalidDataTypeException('Invalid file type'); - } - } - -} - -?> diff --git a/app/php/components/CalendarScaffold.tpl b/app/php/components/CalendarScaffold.tpl deleted file mode 100644 index 6688869..0000000 --- a/app/php/components/CalendarScaffold.tpl +++ /dev/null @@ -1,57 +0,0 @@ - - - - - - - - - - - - <%# $this->Parent->Data->CustomImageUrl %> - - - - - <%# $this->Parent->Data->CustomImage %> -
- - <%# $this->Parent->Data->UID %> - -
-
- -
diff --git a/app/php/components/HeaderMenu.php b/app/php/components/HeaderMenu.php deleted file mode 100644 index bffe4d2..0000000 --- a/app/php/components/HeaderMenu.php +++ /dev/null @@ -1,16 +0,0 @@ -Application->getModule('auth')->logout(); - $this->Response->redirect( - $this->Service->ConstructUrl(NULL) - ); - } - -} - -?> diff --git a/app/php/components/HeaderMenu.tpl b/app/php/components/HeaderMenu.tpl deleted file mode 100644 index 603a231..0000000 --- a/app/php/components/HeaderMenu.tpl +++ /dev/null @@ -1,22 +0,0 @@ - diff --git a/app/php/components/LoginBox.php b/app/php/components/LoginBox.php deleted file mode 100644 index 33bbcc1..0000000 --- a/app/php/components/LoginBox.php +++ /dev/null @@ -1,23 +0,0 @@ -Page->IsValid) { - $this->Response->redirect( - $this->Application->getModule('auth')->ReturnUrl - ?: $this->Service->constructUrl(NULL) - ); - } - } - - public function validatePassword($sender, $param) { - $param->IsValid = $this->Application->getModule('auth')->login( - $this->Login->Text, - $this->Password->Text - ); - } - -} - -?> diff --git a/app/php/components/LoginBox.tpl b/app/php/components/LoginBox.tpl deleted file mode 100644 index d3e1a1e..0000000 --- a/app/php/components/LoginBox.tpl +++ /dev/null @@ -1,29 +0,0 @@ -Username: - - -
-Password: - - - -
- diff --git a/app/php/components/PasswordChange.php b/app/php/components/PasswordChange.php deleted file mode 100644 index 9f2ac7f..0000000 --- a/app/php/components/PasswordChange.php +++ /dev/null @@ -1,38 +0,0 @@ -getControlState('user'); - } - - public function setUserToChange(DbUser $user) { - if ($user->IsGuest) { - throw new TInvalidDataValueException( - 'Password change impossible for guest user' - ); - } - $this->setControlState('user', $user); - } - - public function checkPassword($sender, $param) { - $param->IsValid = DbUser::verifyPassword( - $this->Password->Text, $this->UserToChange->getPassword() - ); - } - - public function changePassword($sender, $param) { - $this->SuccessMessage->Visible = FALSE; - if ($this->Page->IsValid) { - $this->UserToChange->changePassword( - $this->NewPassword->Text - ); - $this->SuccessMessage->Visible = TRUE; - } - } - -} - -?> diff --git a/app/php/components/PasswordChange.tpl b/app/php/components/PasswordChange.tpl deleted file mode 100644 index 915e8b3..0000000 --- a/app/php/components/PasswordChange.tpl +++ /dev/null @@ -1,52 +0,0 @@ -Change password
-Current password: - - - -
-New password: - - -
-Repeat password: - - - -
- - diff --git a/app/php/components/RegistrationForm.php b/app/php/components/RegistrationForm.php deleted file mode 100644 index 71d4df1..0000000 --- a/app/php/components/RegistrationForm.php +++ /dev/null @@ -1,26 +0,0 @@ -IsValid = !User::finder()->countByLogin($this->Login->SafeText); - } - - public function registerUser($sender, $param) { - if ($this->Page->IsValid) { - $newUser = new User(); - $newUser->Login = $this->Login->SafeText; - $newUser->Password = DbUser::generatePassword($this->Password->Text); - $newUser->IsAdmin = $this->Admin->Checked; - $newUser->save(); - $this->Response->redirect( - $this->Service->constructUrl(NULL) - ); - } - } - -} - -?> diff --git a/app/php/components/RegistrationForm.tpl b/app/php/components/RegistrationForm.tpl deleted file mode 100644 index ffa4778..0000000 --- a/app/php/components/RegistrationForm.tpl +++ /dev/null @@ -1,59 +0,0 @@ -Username: - - - - -
-Password: - - -
-Repeat password: - - - -
-Admin: - -
- - diff --git a/app/php/components/SafeActiveFileUpload.php b/app/php/components/SafeActiveFileUpload.php deleted file mode 100644 index 9b8e2a8..0000000 --- a/app/php/components/SafeActiveFileUpload.php +++ /dev/null @@ -1,12 +0,0 @@ - diff --git a/app/php/components/SafeFileUpload.php b/app/php/components/SafeFileUpload.php deleted file mode 100644 index 98e120a..0000000 --- a/app/php/components/SafeFileUpload.php +++ /dev/null @@ -1,34 +0,0 @@ -_isSecure; - } - - public function setIsSecure($bool) { - $this->_isSecure = $bool; - } - - public function getFileType() { - $type = parent::getFileType(); - if ($this->getIsSecure()) { - $fileInfo = new finfo(FILEINFO_MIME_TYPE); - return $fileInfo->file($this->getLocalName()); - } - else { - return $type; - } - } - -} - -?> diff --git a/app/php/components/TimezoneSelect.php b/app/php/components/TimezoneSelect.php deleted file mode 100644 index 3302e2a..0000000 --- a/app/php/components/TimezoneSelect.php +++ /dev/null @@ -1,49 +0,0 @@ -getControlState('user'); - } - - public function setUserToChange(DbUser $user) { - if ($user->IsGuest) { - throw new TInvalidDataValueException( - 'Timezone preference change impossible for guest user' - ); - } - $this->setControlState('user', $user); - } - - public function onPreRender($param) { - parent::onPreRender($param); - $this->Timezones->DataSource = $this->_getTimezones(); - $this->Timezones->DataValueField = 'Name'; - $this->Timezones->DataTextField = 'Label'; - $this->Timezones->dataBind(); - $this->Timezones->setSelectedValue( - $this->UserToChange->getTimezonePreference()->Name - ); - } - - public function saveTimezone($sender, $param) { - $this->UserToChange->setTimezonePreference($this->Timezones->SelectedValue); - } - - private function _getTimezones() { - $timezones = array_map( - function($tz) { - return new TimezoneDTO($tz); - }, - DateTimeZone::listIdentifiers() - ); - usort($timezones, ['TimezoneDTO', '__compare']); - return $timezones; - } - -} - -?> diff --git a/app/php/components/TimezoneSelect.tpl b/app/php/components/TimezoneSelect.tpl deleted file mode 100644 index 2d40014..0000000 --- a/app/php/components/TimezoneSelect.tpl +++ /dev/null @@ -1,4 +0,0 @@ - - diff --git a/app/php/components/UpcomingEvents.php b/app/php/components/UpcomingEvents.php deleted file mode 100644 index 27fa8c6..0000000 --- a/app/php/components/UpcomingEvents.php +++ /dev/null @@ -1,35 +0,0 @@ -getControlState('user'); - } - - public function setUserToDisplay($user) { - $this->setControlState('user', $user); - } - - public function onPreRender($param) { - parent::onPreRender($param); - $this->Events->setDataSource( - $this->_getEventsForUser($this->UserToDisplay) - ); - $this->Events->dataBind(); - } - - private function _getEventsForUser(DbUser $user) { - $utc = new DateTimeZone('UTC'); - $dateFrom = new DateTime('now', $utc); - $dateTo = new DateTime('+7 days', $utc); - return EventFacade::getInstance()->getTimeframeListForUser( - $user, - $dateFrom, $dateTo - ); - } - -} - -?> diff --git a/app/php/components/UpcomingEvents.tpl b/app/php/components/UpcomingEvents.tpl deleted file mode 100644 index d660f54..0000000 --- a/app/php/components/UpcomingEvents.tpl +++ /dev/null @@ -1,10 +0,0 @@ -Upcoming events: -
- - - <%# $this->Data->DateString %> - <%# $this->Data->Name %> - (<%# $this->Data->Calendar->Name %>) -
-
-
diff --git a/app/php/components/UserSelection.php b/app/php/components/UserSelection.php deleted file mode 100644 index 6ae68e4..0000000 --- a/app/php/components/UserSelection.php +++ /dev/null @@ -1,39 +0,0 @@ -getControlState('user'); - } - - public function setUserToDisplay($user) { - $this->setControlState('user', $user); - } - - public function onPreRender($param) { - parent::onPreRender($param); - $this->Categories->setDataSource( - $this->_getUserSelection($this->UserToDisplay) - ); - $this->Categories->dataBind(); - } - - public function categoryDataBind($sender, $param) { - $param->Item->Calendars->setDataSource($param->Item->Data->Calendars); - $param->Item->Calendars->dataBind(); - } - - public function removeFromSelection($sender, $param) { - if (!$this->UserToDisplay->IsGuest) { - } - } - - private function _getUserSelection(DbUser $user) { - return CalendarFacade::getInstance()->getPreferenceList($user); - } - -} - -?> diff --git a/app/php/components/UserSelection.tpl b/app/php/components/UserSelection.tpl deleted file mode 100644 index 14035ca..0000000 --- a/app/php/components/UserSelection.tpl +++ /dev/null @@ -1,25 +0,0 @@ -Selected calendars: -
- - - <%# $this->Data->Name %>
- - - - <%# $this->Data->ID %> - <%# !$this->SourceTemplateControl->UserToDisplay->IsGuest %> - - <%# $this->Data->Name %> - - <%# $this->Data->Website %> - -
-
-
-
-
-
diff --git a/app/php/components/config.xml b/app/php/components/config.xml deleted file mode 100644 index f75e19f..0000000 --- a/app/php/components/config.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/app/php/controls/CalendarScaffold.php b/app/php/controls/CalendarScaffold.php new file mode 100644 index 0000000..f265d53 --- /dev/null +++ b/app/php/controls/CalendarScaffold.php @@ -0,0 +1,127 @@ +setViewState('Facade', $facade); + } + + public function getFacade() { + return $this->getViewState('Facade'); + } + + public function onPreRender($param) { + parent::onPreRender($param); + if (!$this->Page->IsPostBack && !$this->Page->IsCallBack) { + $this->_rebindData(); + } + } + + private function _rebindCalendars(array $calendars) { + $this->Calendars->DataSource = $calendars; + $this->Calendars->dataBind(); + } + + private function _rebindCategoryList(array $categories) { + foreach ($this->Calendars->Columns as $column) { + if ($column->ID === 'Category' + && $column instanceof TActiveDropDownListColumn) { + $column->ListDataSource = $categories; + } + } + } + + private function _rebindData($refresh = FALSE) { + $this->_rebindCategoryList( + $this->_getCategories() + ); + $this->_rebindCalendars( + $this->_getCalendars($refresh) + ); + } + + private function _getCalendars($refresh = FALSE) { + if ($refresh) { + $this->clearViewState('Calendars'); + } + $calendars = $this->getViewState( + 'Calendars', + $this->getFacade()->getAll() + ); + $this->setViewState('Calendars', $calendars); + return $calendars; + } + + private function _getCategories() { + $categories = $this->getViewState( + 'Categories', + $this->getFacade()->getCategories() + ); + $this->setViewState('Categories', $categories); + return $categories; + } + + public function editRow($sender, $param) { + $this->Calendars->EditItemIndex = $param->Item->ItemIndex; + $this->_rebindData(); + } + + private function _compileSaveData(TDataGridItem $item) { + return [ + 'CategoryID' => $item->Category->DropDownList->SelectedValue, + 'Visible' => $item->Visible->CheckBox->Checked, + 'CustomName' => $item->CustomName->TextBox->SafeText, + 'CustomUrl' => $item->CustomUrl->TextBox->SafeText, + 'CustomImage' => $item->CustomImage->Value->SafeText + ]; + } + + public function saveRow($sender, $param) { + $calendar = $this->getFacade()->get( + $sender->DataKeys[$param->Item->ItemIndex] + ); + if ($calendar) { + foreach ($calendar as $c) { + $c->saveData($this->_compileSaveData($param->Item)); + } + } else { + throw new TInvalidDataValueException('Calendar not found'); + } + $this->Calendars->EditItemIndex = -1; + $this->_rebindData(TRUE); + } + + public function cancelRowEdit($sender, $param) { + $this->Calendars->EditItemIndex = -1; + $this->_rebindData(); + } + + public function uploadRowFile($sender, $param) { + $fileType = $sender->getFileType(); + if (preg_match('/^image\//', $fileType)) { + $calendar = $this->getFacade()->get($sender->CustomData); + if ($calendar) { + $targetFile = $calendar[0]->getCustomImagePath( + $sender->getLocalName(), + $fileType + ); + if ($sender->saveAs($targetFile)) { + $sender->NamingContainer->CustomImage->Value->Text = basename( + $targetFile + ); + } + } else { + throw new TInvalidDataValueException('Calendar not found'); + } + } else { + throw new TInvalidDataTypeException('Invalid file type'); + } + } + +} + +?> diff --git a/app/php/controls/CalendarScaffold.tpl b/app/php/controls/CalendarScaffold.tpl new file mode 100644 index 0000000..6688869 --- /dev/null +++ b/app/php/controls/CalendarScaffold.tpl @@ -0,0 +1,57 @@ + + + + + + + + + + + + <%# $this->Parent->Data->CustomImageUrl %> + + + + + <%# $this->Parent->Data->CustomImage %> +
+ + <%# $this->Parent->Data->UID %> + +
+
+ +
diff --git a/app/php/controls/HeaderMenu.php b/app/php/controls/HeaderMenu.php new file mode 100644 index 0000000..bffe4d2 --- /dev/null +++ b/app/php/controls/HeaderMenu.php @@ -0,0 +1,16 @@ +Application->getModule('auth')->logout(); + $this->Response->redirect( + $this->Service->ConstructUrl(NULL) + ); + } + +} + +?> diff --git a/app/php/controls/HeaderMenu.tpl b/app/php/controls/HeaderMenu.tpl new file mode 100644 index 0000000..603a231 --- /dev/null +++ b/app/php/controls/HeaderMenu.tpl @@ -0,0 +1,22 @@ + diff --git a/app/php/controls/LoginBox.php b/app/php/controls/LoginBox.php new file mode 100644 index 0000000..33bbcc1 --- /dev/null +++ b/app/php/controls/LoginBox.php @@ -0,0 +1,23 @@ +Page->IsValid) { + $this->Response->redirect( + $this->Application->getModule('auth')->ReturnUrl + ?: $this->Service->constructUrl(NULL) + ); + } + } + + public function validatePassword($sender, $param) { + $param->IsValid = $this->Application->getModule('auth')->login( + $this->Login->Text, + $this->Password->Text + ); + } + +} + +?> diff --git a/app/php/controls/LoginBox.tpl b/app/php/controls/LoginBox.tpl new file mode 100644 index 0000000..d3e1a1e --- /dev/null +++ b/app/php/controls/LoginBox.tpl @@ -0,0 +1,29 @@ +Username: + + +
+Password: + + + +
+ diff --git a/app/php/controls/PasswordChange.php b/app/php/controls/PasswordChange.php new file mode 100644 index 0000000..9f2ac7f --- /dev/null +++ b/app/php/controls/PasswordChange.php @@ -0,0 +1,38 @@ +getControlState('user'); + } + + public function setUserToChange(DbUser $user) { + if ($user->IsGuest) { + throw new TInvalidDataValueException( + 'Password change impossible for guest user' + ); + } + $this->setControlState('user', $user); + } + + public function checkPassword($sender, $param) { + $param->IsValid = DbUser::verifyPassword( + $this->Password->Text, $this->UserToChange->getPassword() + ); + } + + public function changePassword($sender, $param) { + $this->SuccessMessage->Visible = FALSE; + if ($this->Page->IsValid) { + $this->UserToChange->changePassword( + $this->NewPassword->Text + ); + $this->SuccessMessage->Visible = TRUE; + } + } + +} + +?> diff --git a/app/php/controls/PasswordChange.tpl b/app/php/controls/PasswordChange.tpl new file mode 100644 index 0000000..915e8b3 --- /dev/null +++ b/app/php/controls/PasswordChange.tpl @@ -0,0 +1,52 @@ +Change password
+Current password: + + + +
+New password: + + +
+Repeat password: + + + +
+ + diff --git a/app/php/controls/RegistrationForm.php b/app/php/controls/RegistrationForm.php new file mode 100644 index 0000000..71d4df1 --- /dev/null +++ b/app/php/controls/RegistrationForm.php @@ -0,0 +1,26 @@ +IsValid = !User::finder()->countByLogin($this->Login->SafeText); + } + + public function registerUser($sender, $param) { + if ($this->Page->IsValid) { + $newUser = new User(); + $newUser->Login = $this->Login->SafeText; + $newUser->Password = DbUser::generatePassword($this->Password->Text); + $newUser->IsAdmin = $this->Admin->Checked; + $newUser->save(); + $this->Response->redirect( + $this->Service->constructUrl(NULL) + ); + } + } + +} + +?> diff --git a/app/php/controls/RegistrationForm.tpl b/app/php/controls/RegistrationForm.tpl new file mode 100644 index 0000000..ffa4778 --- /dev/null +++ b/app/php/controls/RegistrationForm.tpl @@ -0,0 +1,59 @@ +Username: + + + + +
+Password: + + +
+Repeat password: + + + +
+Admin: + +
+ + diff --git a/app/php/controls/SafeActiveFileUpload.php b/app/php/controls/SafeActiveFileUpload.php new file mode 100644 index 0000000..ada1e34 --- /dev/null +++ b/app/php/controls/SafeActiveFileUpload.php @@ -0,0 +1,12 @@ + diff --git a/app/php/controls/SafeFileUpload.php b/app/php/controls/SafeFileUpload.php new file mode 100644 index 0000000..98e120a --- /dev/null +++ b/app/php/controls/SafeFileUpload.php @@ -0,0 +1,34 @@ +_isSecure; + } + + public function setIsSecure($bool) { + $this->_isSecure = $bool; + } + + public function getFileType() { + $type = parent::getFileType(); + if ($this->getIsSecure()) { + $fileInfo = new finfo(FILEINFO_MIME_TYPE); + return $fileInfo->file($this->getLocalName()); + } + else { + return $type; + } + } + +} + +?> diff --git a/app/php/controls/TimezoneSelect.php b/app/php/controls/TimezoneSelect.php new file mode 100644 index 0000000..3302e2a --- /dev/null +++ b/app/php/controls/TimezoneSelect.php @@ -0,0 +1,49 @@ +getControlState('user'); + } + + public function setUserToChange(DbUser $user) { + if ($user->IsGuest) { + throw new TInvalidDataValueException( + 'Timezone preference change impossible for guest user' + ); + } + $this->setControlState('user', $user); + } + + public function onPreRender($param) { + parent::onPreRender($param); + $this->Timezones->DataSource = $this->_getTimezones(); + $this->Timezones->DataValueField = 'Name'; + $this->Timezones->DataTextField = 'Label'; + $this->Timezones->dataBind(); + $this->Timezones->setSelectedValue( + $this->UserToChange->getTimezonePreference()->Name + ); + } + + public function saveTimezone($sender, $param) { + $this->UserToChange->setTimezonePreference($this->Timezones->SelectedValue); + } + + private function _getTimezones() { + $timezones = array_map( + function($tz) { + return new TimezoneDTO($tz); + }, + DateTimeZone::listIdentifiers() + ); + usort($timezones, ['TimezoneDTO', '__compare']); + return $timezones; + } + +} + +?> diff --git a/app/php/controls/TimezoneSelect.tpl b/app/php/controls/TimezoneSelect.tpl new file mode 100644 index 0000000..2d40014 --- /dev/null +++ b/app/php/controls/TimezoneSelect.tpl @@ -0,0 +1,4 @@ + + diff --git a/app/php/controls/UpcomingEvents.php b/app/php/controls/UpcomingEvents.php new file mode 100644 index 0000000..27fa8c6 --- /dev/null +++ b/app/php/controls/UpcomingEvents.php @@ -0,0 +1,35 @@ +getControlState('user'); + } + + public function setUserToDisplay($user) { + $this->setControlState('user', $user); + } + + public function onPreRender($param) { + parent::onPreRender($param); + $this->Events->setDataSource( + $this->_getEventsForUser($this->UserToDisplay) + ); + $this->Events->dataBind(); + } + + private function _getEventsForUser(DbUser $user) { + $utc = new DateTimeZone('UTC'); + $dateFrom = new DateTime('now', $utc); + $dateTo = new DateTime('+7 days', $utc); + return EventFacade::getInstance()->getTimeframeListForUser( + $user, + $dateFrom, $dateTo + ); + } + +} + +?> diff --git a/app/php/controls/UpcomingEvents.tpl b/app/php/controls/UpcomingEvents.tpl new file mode 100644 index 0000000..d660f54 --- /dev/null +++ b/app/php/controls/UpcomingEvents.tpl @@ -0,0 +1,10 @@ +Upcoming events: +
+ + + <%# $this->Data->DateString %> + <%# $this->Data->Name %> + (<%# $this->Data->Calendar->Name %>) +
+
+
diff --git a/app/php/controls/UserSelection.php b/app/php/controls/UserSelection.php new file mode 100644 index 0000000..6ae68e4 --- /dev/null +++ b/app/php/controls/UserSelection.php @@ -0,0 +1,39 @@ +getControlState('user'); + } + + public function setUserToDisplay($user) { + $this->setControlState('user', $user); + } + + public function onPreRender($param) { + parent::onPreRender($param); + $this->Categories->setDataSource( + $this->_getUserSelection($this->UserToDisplay) + ); + $this->Categories->dataBind(); + } + + public function categoryDataBind($sender, $param) { + $param->Item->Calendars->setDataSource($param->Item->Data->Calendars); + $param->Item->Calendars->dataBind(); + } + + public function removeFromSelection($sender, $param) { + if (!$this->UserToDisplay->IsGuest) { + } + } + + private function _getUserSelection(DbUser $user) { + return CalendarFacade::getInstance()->getPreferenceList($user); + } + +} + +?> diff --git a/app/php/controls/UserSelection.tpl b/app/php/controls/UserSelection.tpl new file mode 100644 index 0000000..14035ca --- /dev/null +++ b/app/php/controls/UserSelection.tpl @@ -0,0 +1,25 @@ +Selected calendars: +
+ + + <%# $this->Data->Name %>
+ + + + <%# $this->Data->ID %> + <%# !$this->SourceTemplateControl->UserToDisplay->IsGuest %> + + <%# $this->Data->Name %> + + <%# $this->Data->Website %> + +
+
+
+
+
+
diff --git a/app/php/controls/config.xml b/app/php/controls/config.xml new file mode 100644 index 0000000..61d7e5b --- /dev/null +++ b/app/php/controls/config.xml @@ -0,0 +1,6 @@ + + + + + + -- cgit v1.2.3