Sebi

Members
  • Content Count

    4
  • Joined

  • Last visited

Community Reputation

20 Excellent

About Sebi

  • Rank
    Newbie

Recent Profile Visitors

463 profile views
  1. Sebi

    @flydev The module is registered and waits for approval
  2. Sebi

    Hi @Robin S, thanks for your help making the module even better and more useable. I think I found a good solution to fullfill both requirements. With version 1.0.2 you can choose in module's configuration wether the fields should be added globally or only to selected templates. You can choose the templates via ASMSelect, if the checkbox is unchecked. I do check wether the fields were added manually in the template as well, and check the template if all fields were found. I actually find my solution with checkboxes more understandable for normal users. If you uncheck the option "Activate Releasetime from?", it is very clear that the no releasetime is active. If I'd use only the datetime fields without checkbox, I would at least add a notice that gives a hint about the possibility to leave it blank. Of course it's a trifle, but I've worked with customers who would otherwise have had queries about it. I've heeded your advice about explaining selectors in the documentation. For convenience, I added a constant with the selectorstring that is needed to filter unreleased pages. To filter unreleased pages, add the PageAccessReleasetime::selector to your selector: $onlyReleasedPages = wire('pages')->find('template.name=news, ' . PageAccessReleasetime::selector); I thought about manipulating the page's status to achieve this without adding a custom selector part to each query, but I haven't found anything useful yet. Extending the selector seems to be the best solution at the moment. Thanks again for your support!
  3. Sebi

    Hey @dragan, thanks for this hint! I did not have much contact with multilanguage setups in the past, so I hope I added translatable string support the right way in version 1.0.1 of the module. Additionally I removed the german date formats for the inputs. I think, that is something that german users have to configure on their own if needed.
  4. I've created a small module which lets you define a timestamp after which a page should be accessible. In addition you can define a timestamp when the release should end and the page should not be accessable any more. Github: https://github.com/Sebiworld/PageAccessReleasetime Usage PageAccessReleasetime can be installed like every other module in ProcessWire. Check the following guide for detailed information: How-To Install or Uninstall Modules After that, you will find checkboxes for activating the releasetime-fields at the settings-tab of each page. You don't need to add the fields to your templates manually. Check e.g. the checkbox "Activate Releasetime from?" and fill in a date in the future. The page will not be accessable for your users until the given date is reached. If you have $config->pagefileSecure = true, the module will protect files of unreleased pages as well. How it works This module hooks into Page::viewable to prevent users to access unreleased pages: public function hookPageViewable($event) { $page = $event->object; $viewable = $event->return; if($viewable){ // If the page would be viewable, additionally check Releasetime and User-Permission $viewable = $this->canUserSee($page); } $event->return = $viewable; } To prevent access to the files of unreleased pages, we hook into Page::isPublic and ProcessPageView::sendFile. public function hookPageIsPublic($e) { $page = $e->object; if($e->return && $this->isReleaseTimeSet($page)) { $e->return = false; } } The site/assets/files/ directory of pages, which isPublic() returns false, will get a '-' as prefix. This indicates ProcessWire (with activated $config->pagefileSecure) to check the file's permissions via PHP before delivering it to the client. The check wether a not-public file should be accessable happens in ProcessPageView::sendFile. We throw an 404 Exception if the current user must not see the file. public function hookProcessPageViewSendFile($e) { $page = $e->arguments[0]; if(!$this->canUserSee($page)) { throw new Wire404Exception('File not found'); } } Additionally we hook into ProcessPageEdit::buildForm to add the PageAccessReleasetime fields to each page and move them to the settings tab. Limitations In the current version, releasetime-protected pages will appear in wire('pages')->find() queries. If you want to display a list of pages, where pages could be releasetime-protected, you should double-check with $page->viewable() wether the page can be accessed. $page->viewable() returns false, if the page is not released yet. If you have an idea how unreleased pages can be filtered out of ProcessWire selector queries, feel free to write an issue, comment or make a pull request!