Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 07/08/2021 in all areas

  1. You can achieve this with hooks to Page::addable and Page::editable. 1. Define access controls for the news-region and news-article templates so that users with the news-editor role can add children under news-region pages and they can edit and create news-article pages. 2. Create a news_regions Page Reference field which allows pages with template news-region. Best to make it a "multiple" AsmSelect field so it covers the potential case that a user needs to add/edit within multiple regions. Add this field to the user template. 3. Edit the news-editor users and set the regions they are allowed to add/edit within. 4. In /site/ready.php: $wire->addHookAfter('Page::addable', function(HookEvent $event) { /** @var Page $page */ $page = $event->object; $user = $event->wire()->user; // Return early if PW has already determined that the user is not allowed to add if(!$event->return) return; if($user->hasRole('news-editor') && $page->template == 'news-region') { // Addability depends on if the news_regions Page Reference field has the page $event->return = $user->news_regions->has($page); } }); $wire->addHookAfter('Page::editable', function(HookEvent $event) { /** @var Page $page */ $page = $event->object; $user = $event->wire()->user; // Return early if PW has already determined that the user is not allowed to edit if(!$event->return) return; if($user->hasRole('news-editor') && $page->template == 'news-article') { // Editability depends on if the news_regions Page Reference field has the parent page $event->return = $user->news_regions->has($page->parent); } }); The result for user "ringo": You could add all the regions to that user's page, but personally I would create a different news-supereditor role and just not make them subject to the restrictions in the hooks.
    6 points
  2. A while back we had to import a few hundred users into PW from a site we were porting over. I needed to generate new passwords for them that matched our PW password requirements and couldn't find anything super useful so I scraped together a word list and a quick bit of code to spit out a list of reasonable diceware type passwords. Since then it's been surprisingly useful so I've tidied things up a bit and put it on Github in case anyone else could make us of it. There's a demo and Github link at https://millipedia.com/millco-diceware/ It's pretty simple and very Anglo-centric ... and possibly not suitable if you're a secret government agency ... but hey, it might come in handy.
    5 points
  3. Pete and I have been using Postmark in some PW based projects at reasonable scale (>13k emails a month) and have found it to be an exceptionally good API-based transactional email provider with fast delivery times and great availability. It seems strange that there is no WireMail offering (as far as we know of anyway) that supports Postmark, so we thought we'd throw one together in case anyone else in the community wants to give Postmark a try. NB: This is not the code we use in our production systems, just a rainy-day project to fill a gap in the WireMail ecosystem. However, it should be sufficient to get you going with Postmark. We hope you find it useful and please let us know if you find any issues. WireMailPostmark module on Netcarver's github account. Screenshot from my test account:
    2 points
  4. @horst I think I've found a small bug in the module, could you take a look if you've got time? Thanks! https://github.com/horst-n/AdminLinksInFrontend/issues/2
    1 point
  5. Probably because there are some conditions that are required. One of those things is that in order for user to be able to create a page they require a `page-create` permission for the template that is going to be created, but also `page-add` permission for the template that will be a parent of the created page. You could probably achieve this by just removing some mutation fields with hooks. Should look something like below. <?php $wire->addHookAfter("ProcessGraphQL::getMutationFields", function (HookEvent $event) { $fields = $event->return; $newFields = []; foreach ($fields as $field) { if (!in_array($field['name'], ['updatePost', 'updateComment'] )) { // list the name of mutation fields you want to disable $newFields[] = $field; } } $event->return = $newFields; }); Make sure this code is run before the module has responded to the query. Before $modules->get('ProcessGraphQL')->executeGraphQL() Thanks. Will update. ?
    1 point
  6. Thank you all for the insight! This has been super helpful. This community continues to impress me with how helpful and kind everyone is. The more I learn about ProcessWire the more I like what I see! This gives me the direction I need to continue development. I appreciate it!
    1 point
  7. When "Use HTML Purifier" is enabled for a CKEditor field any data-* attributes are stripped out. This happens regardless of the CKEditor ACF settings, and is pretty annoying considering how frequently data attributes are used/needed these days. I'd like to keep HTML Purifier activated but I want to change the configuration to allow specific data attributes. I know how to do this via addAttribute() - as mentioned here - and I can get this working if I directly edit MarkupHTMLPurifier::init() and clear the HTML Purifier cached files from /site/assets/cache/. public function init() { $this->settings->set('Cache.SerializerPath', $this->getCachePath()); $this->settings->set('Attr.AllowedRel', array('nofollow')); $this->settings->set('HTML.DefinitionID', 'html5-definitions'); $this->settings->set('HTML.DefinitionRev', 1); if($def = $this->settings->maybeGetRawHTMLDefinition()) { $def->addElement('figure', 'Block', 'Optional: (figcaption, Flow) | (Flow, figcaption) | Flow', 'Common'); $def->addElement('figcaption', 'Inline', 'Flow', 'Common'); // Added line below to allow data-ext attribute on 'a' elements $def->addAttribute('a', 'data-ext', 'Text'); } } But how can I change the configuration like this without modifying a core file? I want to set the configuration from a custom module. I don't see any hookable methods in MarkupHTMLPurifier but surely it must be configurable somehow. Does anyone know a way to do this?
    1 point
  8. For those who are searching: The mentioned request was completed (https://github.com/processwire/processwire-requests/issues/226) and there is a hook now.
    1 point
×
×
  • Create New...