From f746b274ba51660d2398e6227fbe117829861189 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Fri, 8 Sep 2017 15:38:23 +0200 Subject: [PATCH 01/15] draft pid to path fix --- Admin/Install/Navigation.install.json | 4 ++-- info.json | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Admin/Install/Navigation.install.json b/Admin/Install/Navigation.install.json index a63c778..0e47048 100644 --- a/Admin/Install/Navigation.install.json +++ b/Admin/Install/Navigation.install.json @@ -1,7 +1,7 @@ [ { "id": 1000901001, - "pid": "754a08ddf8bcb1cf22f310f09206dd783d42f7dd", + "pid": "/backend", "type": 1, "subtype": 1, "name": "Calendar", @@ -16,7 +16,7 @@ }, { "id": 1000901002, - "pid": "754a08ddf8bcb1cf22f310f09206dd783d42f7dd", + "pid": "/backend", "type": 2, "subtype": 1, "name": "Calendar", diff --git a/info.json b/info.json index 133df90..62cdd7a 100644 --- a/info.json +++ b/info.json @@ -25,7 +25,7 @@ "load": [ { "pid": [ - "fb78d7e421e4178d31a384fb394dcf2369fff309" + "/backend/calendar" ], "type": 4, "for": "Content", @@ -34,7 +34,7 @@ }, { "pid": [ - "754a08ddf8bcb1cf22f310f09206dd783d42f7dd" + "/backend" ], "type": 5, "from": "Calendar", From 80d939a2aa1693e74a05ec166050a2e5c7ff5dcb Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Wed, 13 Sep 2017 10:45:41 +0200 Subject: [PATCH 02/15] Fix permission tables --- Models/CalendarMapper.php | 19 ------------------- Models/EventMapper.php | 20 -------------------- Models/ScheduleMapper.php | 19 ------------------- 3 files changed, 58 deletions(-) diff --git a/Models/CalendarMapper.php b/Models/CalendarMapper.php index bd37bdf..bfdadb7 100644 --- a/Models/CalendarMapper.php +++ b/Models/CalendarMapper.php @@ -111,25 +111,6 @@ class CalendarMapper extends DataMapperAbstract if($objId === null || !is_scalar($objId)) { return $objId; } - - $query = new Builder(self::$db); - $query->prefix(self::$db->getPrefix()) - ->insert( - 'account_permission_account', - 'account_permission_from', - 'account_permission_for', - 'account_permission_id1', - 'account_permission_id2', - 'account_permission_r', - 'account_permission_w', - 'account_permission_m', - 'account_permission_d', - 'account_permission_p' - ) - ->into('account_permission') - ->values($obj->getCreatedBy(), 'calendar', 'calendar', 1, $objId, 1, 1, 1, 1, 1); - - self::$db->con->prepare($query->toSql())->execute(); } catch (\Exception $e) { return false; } diff --git a/Models/EventMapper.php b/Models/EventMapper.php index 6718b9e..3a60542 100644 --- a/Models/EventMapper.php +++ b/Models/EventMapper.php @@ -105,26 +105,6 @@ class EventMapper extends DataMapperAbstract if($objId === null || !is_scalar($objId)) { return $objId; } - - $query = new Builder(self::$db); - - $query->prefix(self::$db->getPrefix()) - ->insert( - 'account_permission_account', - 'account_permission_from', - 'account_permission_for', - 'account_permission_id1', - 'account_permission_id2', - 'account_permission_r', - 'account_permission_w', - 'account_permission_m', - 'account_permission_d', - 'account_permission_p' - ) - ->into('account_permission') - ->values($obj->getCreatedBy(), 'calendar_event', 'calendar_event', 1, $objId, 1, 1, 1, 1, 1); - - self::$db->con->prepare($query->toSql())->execute(); } catch (\Exception $e) { var_dump($e->getMessage()); diff --git a/Models/ScheduleMapper.php b/Models/ScheduleMapper.php index f5940f7..3bb9343 100644 --- a/Models/ScheduleMapper.php +++ b/Models/ScheduleMapper.php @@ -95,25 +95,6 @@ class ScheduleMapper extends DataMapperAbstract if($objId === null || !is_scalar($objId)) { return $objId; } - - $query = new Builder(self::$db); - $query->prefix(self::$db->getPrefix()) - ->insert( - 'account_permission_account', - 'account_permission_from', - 'account_permission_for', - 'account_permission_id1', - 'account_permission_id2', - 'account_permission_r', - 'account_permission_w', - 'account_permission_m', - 'account_permission_d', - 'account_permission_p' - ) - ->into('account_permission') - ->values($obj->getCreatedBy(), 'schedule', 'schedule', 1, $objId, 1, 1, 1, 1, 1); - - self::$db->con->prepare($query->toSql())->execute(); } catch (\Exception $e) { var_dump($e->getMessage()); From b30c104f34ffc2649c1fdaad7c537e132d8c4f96 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Thu, 14 Sep 2017 20:39:58 +0200 Subject: [PATCH 03/15] Simplify htmlescape --- Theme/Backend/calendar-dashboard.tpl.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Theme/Backend/calendar-dashboard.tpl.php b/Theme/Backend/calendar-dashboard.tpl.php index 0cde3a7..fdd09c5 100644 --- a/Theme/Backend/calendar-dashboard.tpl.php +++ b/Theme/Backend/calendar-dashboard.tpl.php @@ -5,8 +5,8 @@ $calendar = $this->getData('calendar');
    -
  • -
  • +
  • +
  • getHtml('Day'); ?> @@ -48,8 +48,8 @@ $calendar = $this->getData('calendar'); getEventByDate($current[$i*7+$j]); foreach($events as $event) : ?> -
    -
    getName(), ENT_COMPAT, 'utf-8'); ?>
    +
    +
    printHtml($event->getName()); ?>
    2:00pm to 5:00pm
    From 24ea769c42912d7e3a21a47b2e17b02fc289022d Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Fri, 15 Sep 2017 19:37:34 +0200 Subject: [PATCH 04/15] Add module id to modules --- Controller.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Controller.php b/Controller.php index 5b3e10b..a472646 100644 --- a/Controller.php +++ b/Controller.php @@ -63,6 +63,14 @@ class Controller extends ModuleAbstract implements WebInterface */ /* public */ const MODULE_NAME = 'Calendar'; + /** + * Module id. + * + * @var int + * @since 1.0.0 + */ + /* public */ const MODULE_ID = 1000900000; + /** * Providing. * From 773971ca7408c45644d6ec7b09fc4d78788315ef Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sat, 16 Sep 2017 11:11:51 +0200 Subject: [PATCH 05/15] More permission managing --- Controller.php | 14 ++++++++++++-- Models/PermissionState.php | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 2 deletions(-) create mode 100644 Models/PermissionState.php diff --git a/Controller.php b/Controller.php index a472646..4246bf3 100644 --- a/Controller.php +++ b/Controller.php @@ -15,6 +15,7 @@ declare(strict_types=1); namespace Modules\Calendar; use Modules\Calendar\Models\CalendarMapper; +use Modules\Calendar\Models\PermissionState; use Modules\Navigation\Models\Navigation; use Modules\Navigation\Views\NavigationView; use phpOMS\Contract\RenderableInterface; @@ -26,6 +27,7 @@ use phpOMS\Module\WebInterface; use phpOMS\Views\View; use phpOMS\Views\ViewLayout; use phpOMS\Asset\AssetType; +use phpOMS\Account\PermissionType; /** * Calendar controller class. @@ -99,11 +101,19 @@ class Controller extends ModuleAbstract implements WebInterface */ public function viewCalendarDashboard(RequestAbstract $request, ResponseAbstract $response, $data = null) : \Serializable { + $view = new View($this->app, $request, $response); + + if (!$this->app->accountManager->get($request->getHeader()->getAccount())->hasPermission( + PermissionType::READ, 1, $this->app->appName, self::MODULE_ID, PermissionState::DASHBOARD) + ) { + $view->setTemplate('/Web/Backend/Error/403_inline'); + return $view; + } + /** @var Head $head */ $head = $response->get('Content')->getData('head'); $head->addAsset(AssetType::CSS, $request->getUri()->getBase() . 'Modules/Calendar/Theme/Backend/css/styles.css'); - - $view = new View($this->app, $request, $response); + $view->setTemplate('/Modules/Calendar/Theme/Backend/calendar-dashboard'); $view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1001201001, $request, $response)); diff --git a/Models/PermissionState.php b/Models/PermissionState.php new file mode 100644 index 0000000..0e4ba64 --- /dev/null +++ b/Models/PermissionState.php @@ -0,0 +1,34 @@ + Date: Sat, 16 Sep 2017 12:15:55 +0200 Subject: [PATCH 06/15] Create more permission handling --- Controller.php | 1 + 1 file changed, 1 insertion(+) diff --git a/Controller.php b/Controller.php index 4246bf3..cb8641e 100644 --- a/Controller.php +++ b/Controller.php @@ -18,6 +18,7 @@ use Modules\Calendar\Models\CalendarMapper; use Modules\Calendar\Models\PermissionState; use Modules\Navigation\Models\Navigation; use Modules\Navigation\Views\NavigationView; + use phpOMS\Contract\RenderableInterface; use phpOMS\Stdlib\Base\SmartDateTime; use phpOMS\Message\RequestAbstract; From 970a90fa3a2af48fd3f10f49370ed9cfbb414297 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sat, 16 Sep 2017 20:25:33 +0200 Subject: [PATCH 07/15] Fix dependencies --- Controller.php | 1 + 1 file changed, 1 insertion(+) diff --git a/Controller.php b/Controller.php index cb8641e..aad0771 100644 --- a/Controller.php +++ b/Controller.php @@ -29,6 +29,7 @@ use phpOMS\Views\View; use phpOMS\Views\ViewLayout; use phpOMS\Asset\AssetType; use phpOMS\Account\PermissionType; +use phpOMS\Message\Http\RequestStatusCode; /** * Calendar controller class. From f1e00346f53875e8749c41e6e76ac290058d07bf Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Mon, 18 Sep 2017 12:37:29 +0200 Subject: [PATCH 08/15] Implement organization permission --- Controller.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Controller.php b/Controller.php index aad0771..3a64938 100644 --- a/Controller.php +++ b/Controller.php @@ -106,7 +106,7 @@ class Controller extends ModuleAbstract implements WebInterface $view = new View($this->app, $request, $response); if (!$this->app->accountManager->get($request->getHeader()->getAccount())->hasPermission( - PermissionType::READ, 1, $this->app->appName, self::MODULE_ID, PermissionState::DASHBOARD) + PermissionType::READ, $this->app->appId, $this->app->appName, self::MODULE_ID, PermissionState::DASHBOARD) ) { $view->setTemplate('/Web/Backend/Error/403_inline'); return $view; From 11a9a12970030baf934d0dbba99d891a074f6c9e Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Mon, 18 Sep 2017 12:43:43 +0200 Subject: [PATCH 09/15] Fix member name --- Controller.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Controller.php b/Controller.php index 3a64938..b6623d2 100644 --- a/Controller.php +++ b/Controller.php @@ -106,7 +106,7 @@ class Controller extends ModuleAbstract implements WebInterface $view = new View($this->app, $request, $response); if (!$this->app->accountManager->get($request->getHeader()->getAccount())->hasPermission( - PermissionType::READ, $this->app->appId, $this->app->appName, self::MODULE_ID, PermissionState::DASHBOARD) + PermissionType::READ, $this->app->orgId, $this->app->appName, self::MODULE_ID, PermissionState::DASHBOARD) ) { $view->setTemplate('/Web/Backend/Error/403_inline'); return $view; From 909569ea09015462ae648c6aafaa362e32509161 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sat, 23 Sep 2017 13:58:09 +0200 Subject: [PATCH 10/15] Use default database connection --- Admin/Installer.php | 58 ++++++++++++++++++++++----------------------- Admin/Uninstall.php | 2 +- 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/Admin/Installer.php b/Admin/Installer.php index 4bede8d..2b77922 100644 --- a/Admin/Installer.php +++ b/Admin/Installer.php @@ -38,10 +38,10 @@ class Installer extends InstallerAbstract { parent::install(__DIR__ . '/..', $dbPool, $info); - switch ($dbPool->get('core')->getType()) { + switch ($dbPool->get()->getType()) { case DatabaseType::MYSQL: - $dbPool->get('core')->con->prepare( - 'CREATE TABLE if NOT EXISTS `' . $dbPool->get('core')->prefix . 'calendar` ( + $dbPool->get()->con->prepare( + 'CREATE TABLE if NOT EXISTS `' . $dbPool->get()->prefix . 'calendar` ( `calendar_id` int(11) NOT NULL AUTO_INCREMENT, `calendar_name` varchar(255) NOT NULL, `calendar_password` varchar(255) DEFAULT NULL, @@ -53,13 +53,13 @@ class Installer extends InstallerAbstract )ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;' )->execute(); - $dbPool->get('core')->con->prepare( - 'ALTER TABLE `' . $dbPool->get('core')->prefix . 'calendar` - ADD CONSTRAINT `' . $dbPool->get('core')->prefix . 'calendar_ibfk_1` FOREIGN KEY (`calendar_created_by`) REFERENCES `' . $dbPool->get('core')->prefix . 'account` (`account_id`);' + $dbPool->get()->con->prepare( + 'ALTER TABLE `' . $dbPool->get()->prefix . 'calendar` + ADD CONSTRAINT `' . $dbPool->get()->prefix . 'calendar_ibfk_1` FOREIGN KEY (`calendar_created_by`) REFERENCES `' . $dbPool->get()->prefix . 'account` (`account_id`);' )->execute(); - $dbPool->get('core')->con->prepare( - 'CREATE TABLE if NOT EXISTS `' . $dbPool->get('core')->prefix . 'calendar_permission` ( + $dbPool->get()->con->prepare( + 'CREATE TABLE if NOT EXISTS `' . $dbPool->get()->prefix . 'calendar_permission` ( `calendar_permission_id` int(11) NOT NULL AUTO_INCREMENT, `calendar_permission_type` tinyint(1) NOT NULL, `calendar_permission_ref` int(11) NOT NULL, @@ -70,13 +70,13 @@ class Installer extends InstallerAbstract )ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;' )->execute(); - $dbPool->get('core')->con->prepare( - 'ALTER TABLE `' . $dbPool->get('core')->prefix . 'calendar_permission` - ADD CONSTRAINT `' . $dbPool->get('core')->prefix . 'calendar_permission_ibfk_1` FOREIGN KEY (`calendar_permission_calendar`) REFERENCES `' . $dbPool->get('core')->prefix . 'calendar` (`calendar_id`);' + $dbPool->get()->con->prepare( + 'ALTER TABLE `' . $dbPool->get()->prefix . 'calendar_permission` + ADD CONSTRAINT `' . $dbPool->get()->prefix . 'calendar_permission_ibfk_1` FOREIGN KEY (`calendar_permission_calendar`) REFERENCES `' . $dbPool->get()->prefix . 'calendar` (`calendar_id`);' )->execute(); - $dbPool->get('core')->con->prepare( - 'CREATE TABLE if NOT EXISTS `' . $dbPool->get('core')->prefix . 'schedule` ( + $dbPool->get()->con->prepare( + 'CREATE TABLE if NOT EXISTS `' . $dbPool->get()->prefix . 'schedule` ( `schedule_id` int(11) NOT NULL AUTO_INCREMENT, `schedule_uid` varchar(255) NOT NULL, `schedule_status` tinyint(1) NOT NULL, @@ -95,13 +95,13 @@ class Installer extends InstallerAbstract )ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;' )->execute(); - $dbPool->get('core')->con->prepare( - 'ALTER TABLE `' . $dbPool->get('core')->prefix . 'schedule` - ADD CONSTRAINT `' . $dbPool->get('core')->prefix . 'schedule_ibfk_1` FOREIGN KEY (`schedule_created_by`) REFERENCES `' . $dbPool->get('core')->prefix . 'account` (`account_id`);' + $dbPool->get()->con->prepare( + 'ALTER TABLE `' . $dbPool->get()->prefix . 'schedule` + ADD CONSTRAINT `' . $dbPool->get()->prefix . 'schedule_ibfk_1` FOREIGN KEY (`schedule_created_by`) REFERENCES `' . $dbPool->get()->prefix . 'account` (`account_id`);' )->execute(); - $dbPool->get('core')->con->prepare( - 'CREATE TABLE if NOT EXISTS `' . $dbPool->get('core')->prefix . 'calendar_event` ( + $dbPool->get()->con->prepare( + 'CREATE TABLE if NOT EXISTS `' . $dbPool->get()->prefix . 'calendar_event` ( `calendar_event_id` int(11) NOT NULL AUTO_INCREMENT, `calendar_event_name` varchar(25) NOT NULL, `calendar_event_description` varchar(255) NOT NULL, @@ -119,15 +119,15 @@ class Installer extends InstallerAbstract )ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;' )->execute(); - $dbPool->get('core')->con->prepare( - 'ALTER TABLE `' . $dbPool->get('core')->prefix . 'calendar_event` - ADD CONSTRAINT `' . $dbPool->get('core')->prefix . 'calendar_event_ibfk_1` FOREIGN KEY (`calendar_event_created_by`) REFERENCES `' . $dbPool->get('core')->prefix . 'account` (`account_id`), - ADD CONSTRAINT `' . $dbPool->get('core')->prefix . 'calendar_event_ibfk_2` FOREIGN KEY (`calendar_event_schedule`) REFERENCES `' . $dbPool->get('core')->prefix . 'schedule` (`schedule_id`), - ADD CONSTRAINT `' . $dbPool->get('core')->prefix . 'calendar_event_ibfk_3` FOREIGN KEY (`calendar_event_calendar`) REFERENCES `' . $dbPool->get('core')->prefix . 'calendar` (`calendar_id`);' + $dbPool->get()->con->prepare( + 'ALTER TABLE `' . $dbPool->get()->prefix . 'calendar_event` + ADD CONSTRAINT `' . $dbPool->get()->prefix . 'calendar_event_ibfk_1` FOREIGN KEY (`calendar_event_created_by`) REFERENCES `' . $dbPool->get()->prefix . 'account` (`account_id`), + ADD CONSTRAINT `' . $dbPool->get()->prefix . 'calendar_event_ibfk_2` FOREIGN KEY (`calendar_event_schedule`) REFERENCES `' . $dbPool->get()->prefix . 'schedule` (`schedule_id`), + ADD CONSTRAINT `' . $dbPool->get()->prefix . 'calendar_event_ibfk_3` FOREIGN KEY (`calendar_event_calendar`) REFERENCES `' . $dbPool->get()->prefix . 'calendar` (`calendar_id`);' )->execute(); - $dbPool->get('core')->con->prepare( - 'CREATE TABLE if NOT EXISTS `' . $dbPool->get('core')->prefix . 'calendar_event_participant` ( + $dbPool->get()->con->prepare( + 'CREATE TABLE if NOT EXISTS `' . $dbPool->get()->prefix . 'calendar_event_participant` ( `calendar_event_participant_id` int(11) NOT NULL AUTO_INCREMENT, `calendar_event_participant_event` int(11) NOT NULL, `calendar_event_participant_person` int(11) NOT NULL, @@ -138,10 +138,10 @@ class Installer extends InstallerAbstract )ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;' )->execute(); - $dbPool->get('core')->con->prepare( - 'ALTER TABLE `' . $dbPool->get('core')->prefix . 'calendar_event_participant` - ADD CONSTRAINT `' . $dbPool->get('core')->prefix . 'calendar_event_participant_ibfk_1` FOREIGN KEY (`calendar_event_participant_event`) REFERENCES `' . $dbPool->get('core')->prefix . 'calendar_event` (`calendar_event_id`), - ADD CONSTRAINT `' . $dbPool->get('core')->prefix . 'calendar_event_participant_ibfk_2` FOREIGN KEY (`calendar_event_participant_person`) REFERENCES `' . $dbPool->get('core')->prefix . 'account` (`account_id`);' + $dbPool->get()->con->prepare( + 'ALTER TABLE `' . $dbPool->get()->prefix . 'calendar_event_participant` + ADD CONSTRAINT `' . $dbPool->get()->prefix . 'calendar_event_participant_ibfk_1` FOREIGN KEY (`calendar_event_participant_event`) REFERENCES `' . $dbPool->get()->prefix . 'calendar_event` (`calendar_event_id`), + ADD CONSTRAINT `' . $dbPool->get()->prefix . 'calendar_event_participant_ibfk_2` FOREIGN KEY (`calendar_event_participant_person`) REFERENCES `' . $dbPool->get()->prefix . 'account` (`account_id`);' )->execute(); break; } diff --git a/Admin/Uninstall.php b/Admin/Uninstall.php index 6835d37..c89feef 100644 --- a/Admin/Uninstall.php +++ b/Admin/Uninstall.php @@ -39,7 +39,7 @@ class Uninstall extends UninstallAbstract $query = new Builder($dbPool->get()); - $query->prefix($dbPool->get('core')->getPrefix())->drop( + $query->prefix($dbPool->get()->getPrefix())->drop( 'calendar_event_participant', 'calendar_event', 'schedule', From 7f327fad532687e426fb5afd778a5000f1f7fd64 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sun, 1 Oct 2017 15:17:10 +0200 Subject: [PATCH 11/15] Remove use of unnecessary ViewLayout --- Controller.php | 1 - 1 file changed, 1 deletion(-) diff --git a/Controller.php b/Controller.php index b6623d2..4e9e3a5 100644 --- a/Controller.php +++ b/Controller.php @@ -26,7 +26,6 @@ use phpOMS\Message\ResponseAbstract; use phpOMS\Module\ModuleAbstract; use phpOMS\Module\WebInterface; use phpOMS\Views\View; -use phpOMS\Views\ViewLayout; use phpOMS\Asset\AssetType; use phpOMS\Account\PermissionType; use phpOMS\Message\Http\RequestStatusCode; From d397a8cea34f488eba17676b09c4673a5154e1c9 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Mon, 2 Oct 2017 09:49:15 +0200 Subject: [PATCH 12/15] fix #30 --- Theme/Backend/dashboard-calendar.tpl.php | 54 ++++++++++++------------ 1 file changed, 28 insertions(+), 26 deletions(-) diff --git a/Theme/Backend/dashboard-calendar.tpl.php b/Theme/Backend/dashboard-calendar.tpl.php index ab2eea8..9852e60 100644 --- a/Theme/Backend/dashboard-calendar.tpl.php +++ b/Theme/Backend/dashboard-calendar.tpl.php @@ -8,30 +8,32 @@ $calendar = $this->getData('calendar'); ] } ]'> -
      -
    • getHtml('Sunday'); ?> -
    • getHtml('Monday'); ?> -
    • getHtml('Tuesday'); ?> -
    • getHtml('Wednesday'); ?> -
    • getHtml('Thursday'); ?> -
    • getHtml('Friday'); ?> -
    • getHtml('Saturday'); ?> -
    - getDate()->getMonthCalendar(0); $isActiveMonth = false; - for($i = 0; $i < 6; $i++) : ?> -
      - format('d') === 1) ? !$isActiveMonth : $isActiveMonth; - ?> - -
    • -
      format('d'); ?>
      - -
    • -
      format('d'); ?>
      - - -
    • -
    - +
    +
      +
    • getHtml('Sunday'); ?> +
    • getHtml('Monday'); ?> +
    • getHtml('Tuesday'); ?> +
    • getHtml('Wednesday'); ?> +
    • getHtml('Thursday'); ?> +
    • getHtml('Friday'); ?> +
    • getHtml('Saturday'); ?> +
    + getDate()->getMonthCalendar(0); $isActiveMonth = false; + for($i = 0; $i < 6; $i++) : ?> +
      + format('d') === 1) ? !$isActiveMonth : $isActiveMonth; + ?> + +
    • +
      format('d'); ?>
      + +
    • +
      format('d'); ?>
      + + +
    • +
    + +
    From a70302d761c4a394a9c5cff0e7937e004d9d9afb Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Tue, 3 Oct 2017 20:24:29 +0200 Subject: [PATCH 13/15] fix #105 --- Controller.php | 6 ++- .../Backend/Components/Calendar/BaseView.php | 38 ++++++++++++++ .../Backend/Components/Calendar/mini.tpl.php | 36 +++++++++++++ Theme/Backend/dashboard-calendar.tpl.php | 50 ++++++------------- 4 files changed, 93 insertions(+), 37 deletions(-) create mode 100644 Theme/Backend/Components/Calendar/BaseView.php create mode 100644 Theme/Backend/Components/Calendar/mini.tpl.php diff --git a/Controller.php b/Controller.php index 4e9e3a5..72ae8c1 100644 --- a/Controller.php +++ b/Controller.php @@ -146,9 +146,13 @@ class Controller extends ModuleAbstract implements WebInterface $view = new View($this->app, $request, $response); $view->setTemplate('/Modules/Calendar/Theme/Backend/dashboard-calendar'); + $calendarView = new \Modules\Calendar\Theme\Backend\Components\Calendar\BaseView($this->app, $request, $response); + $calendarView->setTemplate('/Modules/Calendar/Theme/Backend/Components/Calendar/mini'); + $view->addData('calendar', $calendarView); + $calendar = CalendarMapper::get(1); $calendar->setDate(new SmartDateTime($request->getData('date') ?? 'now')); - $view->addData('calendar', $calendar); + $view->addData('cal', $calendar); return $view; } diff --git a/Theme/Backend/Components/Calendar/BaseView.php b/Theme/Backend/Components/Calendar/BaseView.php new file mode 100644 index 0000000..4a26de5 --- /dev/null +++ b/Theme/Backend/Components/Calendar/BaseView.php @@ -0,0 +1,38 @@ +setTemplate('/Modules/Calendar/Theme/Backend/Components/Calendar/mini'); + } + + public function render(...$data) : string + { + $this->calendar = $data[0]; + return parent::render(); + } +} \ No newline at end of file diff --git a/Theme/Backend/Components/Calendar/mini.tpl.php b/Theme/Backend/Components/Calendar/mini.tpl.php new file mode 100644 index 0000000..41f2495 --- /dev/null +++ b/Theme/Backend/Components/Calendar/mini.tpl.php @@ -0,0 +1,36 @@ +
    +
    +
      +
    • getHtml('Sunday', 'Calendar'); ?> +
    • getHtml('Monday', 'Calendar'); ?> +
    • getHtml('Tuesday', 'Calendar'); ?> +
    • getHtml('Wednesday', 'Calendar'); ?> +
    • getHtml('Thursday', 'Calendar'); ?> +
    • getHtml('Friday', 'Calendar'); ?> +
    • getHtml('Saturday', 'Calendar'); ?> +
    + calendar->getDate()->getMonthCalendar(0); $isActiveMonth = false; + for($i = 0; $i < 6; $i++) : ?> +
      + format('d') === 1) ? !$isActiveMonth : $isActiveMonth; + ?> + +
    • +
      format('d'); ?>
      + +
    • +
      format('d'); ?>
      + + +
    • +
    + +
    +
    \ No newline at end of file diff --git a/Theme/Backend/dashboard-calendar.tpl.php b/Theme/Backend/dashboard-calendar.tpl.php index 9852e60..205920c 100644 --- a/Theme/Backend/dashboard-calendar.tpl.php +++ b/Theme/Backend/dashboard-calendar.tpl.php @@ -1,39 +1,17 @@ getData('calendar'); +/** + * Orange Management + * + * PHP Version 7.1 + * + * @category TBD + * @package TBD + * @copyright Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ ?> -
    -
    -
      -
    • getHtml('Sunday'); ?> -
    • getHtml('Monday'); ?> -
    • getHtml('Tuesday'); ?> -
    • getHtml('Wednesday'); ?> -
    • getHtml('Thursday'); ?> -
    • getHtml('Friday'); ?> -
    • getHtml('Saturday'); ?> -
    - getDate()->getMonthCalendar(0); $isActiveMonth = false; - for($i = 0; $i < 6; $i++) : ?> -
      - format('d') === 1) ? !$isActiveMonth : $isActiveMonth; - ?> - -
    • -
      format('d'); ?>
      - -
    • -
      format('d'); ?>
      - - -
    • -
    - -
    +
    + getData('calendar')->render($this->getData('cal')); ?>
    From 3f979ac4453158aa68ad09a7116eefc892b54968 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Tue, 3 Oct 2017 21:39:34 +0200 Subject: [PATCH 14/15] Fix #7 --- Admin/Installer.php | 9 +-------- Models/Calendar.php | 28 ---------------------------- Models/CalendarMapper.php | 1 - 3 files changed, 1 insertion(+), 37 deletions(-) diff --git a/Admin/Installer.php b/Admin/Installer.php index 2b77922..b497af4 100644 --- a/Admin/Installer.php +++ b/Admin/Installer.php @@ -46,18 +46,11 @@ class Installer extends InstallerAbstract `calendar_name` varchar(255) NOT NULL, `calendar_password` varchar(255) DEFAULT NULL, `calendar_description` varchar(255) NOT NULL, - `calendar_created_by` int(11) NOT NULL, `calendar_created_at` datetime NOT NULL, - PRIMARY KEY (`calendar_id`), - KEY `calendar_created_by` (`calendar_created_by`) + PRIMARY KEY (`calendar_id`) )ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;' )->execute(); - $dbPool->get()->con->prepare( - 'ALTER TABLE `' . $dbPool->get()->prefix . 'calendar` - ADD CONSTRAINT `' . $dbPool->get()->prefix . 'calendar_ibfk_1` FOREIGN KEY (`calendar_created_by`) REFERENCES `' . $dbPool->get()->prefix . 'account` (`account_id`);' - )->execute(); - $dbPool->get()->con->prepare( 'CREATE TABLE if NOT EXISTS `' . $dbPool->get()->prefix . 'calendar_permission` ( `calendar_permission_id` int(11) NOT NULL AUTO_INCREMENT, diff --git a/Models/Calendar.php b/Models/Calendar.php index d3a6fe7..04a9a69 100644 --- a/Models/Calendar.php +++ b/Models/Calendar.php @@ -60,14 +60,6 @@ class Calendar */ private $createdAt = null; - /** - * Created by. - * - * @var int - * @since 1.0.0 - */ - private $createdBy = 0; - /** * Current date of the calendar. * @@ -251,26 +243,6 @@ class Calendar $this->createdAt = $createdAt; } - /** - * @return int - * - * @since 1.0.0 - */ - public function getCreatedBy() : int - { - return $this->createdBy; - } - - /** - * @param int $createdBy Creator - * - * @since 1.0.0 - */ - public function setCreatedBy(int $createdBy) - { - $this->createdBy = $createdBy; - } - /** * Get current date * diff --git a/Models/CalendarMapper.php b/Models/CalendarMapper.php index bfdadb7..ab87c00 100644 --- a/Models/CalendarMapper.php +++ b/Models/CalendarMapper.php @@ -50,7 +50,6 @@ class CalendarMapper extends DataMapperAbstract 'calendar_name' => ['name' => 'calendar_name', 'type' => 'string', 'internal' => 'name'], 'calendar_password' => ['name' => 'calendar_password', 'type' => 'string', 'internal' => 'password'], 'calendar_description' => ['name' => 'calendar_description', 'type' => 'string', 'internal' => 'description'], - 'calendar_created_by' => ['name' => 'calendar_created_by', 'type' => 'int', 'internal' => 'createdBy'], 'calendar_created_at' => ['name' => 'calendar_created_at', 'type' => 'DateTime', 'internal' => 'createdAt'], ]; From 2ea259e273f3c9c83369c71fabff00c6a23db80d Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sat, 7 Oct 2017 21:24:10 +0200 Subject: [PATCH 15/15] Ignore coverage for view methods in controllers --- Controller.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Controller.php b/Controller.php index 72ae8c1..a69b09d 100644 --- a/Controller.php +++ b/Controller.php @@ -99,6 +99,7 @@ class Controller extends ModuleAbstract implements WebInterface * @return \Serializable * * @since 1.0.0 + * @codeCoverageIgnore */ public function viewCalendarDashboard(RequestAbstract $request, ResponseAbstract $response, $data = null) : \Serializable { @@ -136,6 +137,7 @@ class Controller extends ModuleAbstract implements WebInterface * @return \Serializable * * @since 1.0.0 + * @codeCoverageIgnore */ public function viewDashboard(RequestAbstract $request, ResponseAbstract $response, $data = null) : \Serializable {