ridgedale

Members
  • Content count

    110
  • Joined

  • Last visited

Community Reputation

11 Good

About ridgedale

  • Rank
    Sr. Member

Recent Profile Visitors

837 profile views
  1. ridgedale

    @adrian Thank you for your reply and clarification. At present the solution outlined previously achieves the desired access control without the use of a role and/or module. I'll have to look into the ProtectedMode module further in due course.
  2. ridgedale

    Thanks again @adrian for your further feedback. Understood. Would you mind sharing what those 2-3 major bugs are/were? Are you aware of any issues that might arise from an upgrade from the 3.0.62 master version to the 3.0.107 dev version? Whilst I appreciate that no software is perfect or bug free and agree with you that a greater emphasis should be placed on resolving existing issues, it would be helpful if the https://github.com/processwire/processwire-issues/issues could be filtered at least in terms of whether or not they relate to PW2 or PW3. I note there are no issues labelled as severity: low, severity: medium, severity: high or severity: critical and that 12 of the 216 current outstanding issues appear to have been fixed but have not been closed by the initiator. Do you have any advice on the best approach to filtering (via Labels) the issues to learn what issues may be of concern? Also what does the Authors dropdown menu refer to?
  3. ridgedale

    @adrian Thank you for your reply. From the module description: it appeared to me that the ProtectedMode module would not be able to restrict front- and backend access to a single logged in superuser. Please correct me if my assumption was incorrect. The multi-site installation I am dealing with has multiple superusers. The solution arrived at, linked to in my previous post, allows a single superuser to manage the upgrade of ProcessWire blocking all other user access to all the websites until the PW upgrade has been completed and websites tested and brought back online, without the need for any modules.
  4. ridgedale

    Update: See this topic that answers the above question raised.
  5. ridgedale

    Hi @adrian , Thank you for your reply. If I were to be the only site superuser, that would be OK. However, other administrators will eventually take over in future and I personally think it would be safer to advise future superuser administrators that they should only upgrade to master ProcessWire versions to avoid/minimise potential upgrade issues. Other current and future superusers do not and and may not in some cases have the technical expertise to deal with the potential upgrade issues that may arise. Is there any thread available that monitors ProcessWire development progress and might give some idea when the next master release will be available?
  6. The multi-site installation I'm currently working on requires some of the new features/methods released in the 3.0.107 development branch. Does anyone have any idea when the next Processwire 3 master version is likely to be released?
  7. @Soma, Despite @Tom. mentioning this earlier for idiotic reason I have been placing the hook code in a ready.php file located in the site-xxx/templates directory instead of the site-xxx directory alongside the config.php file. Placing the code in the correct location resolves the issue and now everything is working as required. Sincere apologies for the oversight and thanks again to both of you for your assistance and patience.
  8. Hi @Soma , Thank you for your reply. I'm not sure I understand what you mean by this. Do you mean I should be using the second statement instead of the first? Otherwise what replacement should I be using? That makes sense and is why I also tried addHookAfter as well. Shouldn't an error have been displayed in the log to that effect? Neither of the following code changes for the ready.php file make any difference. The maintainer field still does not get updated without any errors being generated in the logs: <?php namespace ProcessWire; wire()->addHookAfter("Pages::save", function($event) { $page = $event->arguments(0); if($page->template == 'site-maintenance') { if($page->maintenance) { $page->of(false); $page->maintainer = wire("user")->name; $page->save('maintainer'); } else { $page->of(false); $page->maintainer = ''; $page->save('maintainer'); } } }); <?php namespace ProcessWire; wire()->addHookBefore("Pages::saveReady", function($event) { $page = $event->arguments(0); if($page->template == 'site-maintenance') { if($page->maintenance) { $page->of(false); $page->maintainer = wire("user")->name; $page->save('maintainer'); } else { $page->of(false); $page->maintainer = ''; $page->save('maintainer'); } } }); That may be the case but the user cannot leave the page without saving it first. The user needs to check the maintenance field and save that field status (which actually does take place on saving the page) and the maintainer field automatically needs to be updated with the current username (which does not take place). Any further guidance would be greatly appreciated.
  9. Apologies for bumping this. But can anyone help?
  10. Having found Ryan's post in this thread, I've also tried replacing the ready.php with the following code both without any success. The maintainer field does not get updated in the backend or the MySQL database: Further Testing 1: <?php namespace ProcessWire; wire()->addHookBefore("Pages::save", function($event) { $page = $event->arguments(0); if($page->template == 'site-maintenance') { // Replace 'site_upgrade' with your template name for the maintenance page if($page->maintenance) { // $page->setAndSave('maintainer', $user->name); $page->of(false); $page->maintainer = $user->name; // If this field is a Page Relationship field it just needs to be $user $page->save(); } else { // $page->setAndSave('maintainer', ''); $page->of(false); $page->maintainer = ''; $page->save(); } } }); Further Test 2: <?php namespace ProcessWire; wire()->addHookBefore("Pages::save", function($event) { $page = $event->arguments(0); if($page->template == 'site-maintenance') { // Replace 'site_upgrade' with your template name for the maintenance page if($page->maintenance) { // $page->setAndSave('maintainer', $user->name); $page->of(false); $page->maintainer = $user->name; // If this field is a Page Relationship field it just needs to be $user $page->save('maintainer'); } else { // $page->setAndSave('maintainer', ''); $page->of(false); $page->maintainer = ''; $page->save('maintainer'); } } }); I've also double-checked the logs and no errors are generated when the maintenance checkbox is ticked/unticked and the page saved. Changing addHookBefore to addHookAfter makes no difference. The only thing I can think of is to create a required dropdown menu field that just includes the current username, but I don't know how that can be achieved. Even so it is somewhat worrying that it appears field values cannot be set in the backend via the API. Any further input/thoughts would be very welcome.
  11. ridgedale

    Hi @Tom. , I did a search for wire('config')->demo and found the following topic: and have downloaded the v.3 Skyscrapers profile from the link provided by @Robin S . That should provide the information I need. Many thanks again for your assistance and patience.
  12. Hi @Tom. , I've reviewed the Page Relationship field type. I don't think that field type is a applicable in this case. I'm simply using the Text field type for the maintainer field. Below is exactly the code tested in each of the files following your latest input: site-maintenance.php: <?php namespace ProcessWire; // site-maintenance.php template file for managing site upgrades and displaying maintenance status message. // Update the 'maintainer' field each time the maintenance checkbox is checked/unchecked. if ( ! $page->maintenance == 1) { // $page->setAndSave('maintainer', null); $mntmessage = "Status: This site is not currently undergoing maintenance."; } else { // $page->setAndSave('maintainer', $user->name); $mntnr = $page->get('maintainer'); $mntmessage = "Status: This site is currently undergoing maintenance by " . $mntnr . "."; } ?> <div pw-append='content-body'> <?php echo $mntmessage; ?> </div> <?php include('./_news-sidebar.php'); ?> ready.php: <?php namespace ProcessWire; wire()->addHookAfter("Pages::save", function($event) { $page = $event->arguments(0); if($page->template == 'site-maintenance') { // Replace 'site_upgrade' with your template name for the maintenance page if($page->maintenance) { // $page->setAndSave('maintainer', $user->name); $page->maintainer = $user->name; // If this field is a Page Relationship field it just needs to be $user } else { // $page->setAndSave('maintainer', ''); $page->maintainer = ''; } } }); Note: I've tried both the setAndSave alternatives in the if statement as well. admin.php: <?php namespace ProcessWire; /** * Admin template just loads the admin application controller, * and admin is just an application built on top of ProcessWire. * * This demonstrates how you can use ProcessWire as a front-end * to another application. * * Feel free to hook admin-specific functionality from this file, * but remember to leave the require() statement below at the end. * */ $upgradePage = $pages->get('/site-upgrade/'); if($upgradePage->maintenance && $user->isLoggedin() && $user->name !== $upgradePage->maintainer) { $session->logout(); $session->redirect("/maintenance.html", false); exit; } require($config->paths->adminTemplates . 'controller.php'); Note: If the $upgradePage ... } is added everyone gets redirected to the maintenance.html page unless the maintainer field is manually updated. header.php: <?php namespace ProcessWire; $upgradePage = $pages->get('/site-upgrade/'); if($upgradePage->maintenance && $user->name !== $upgradePage->maintainer) { $session->logout(); $session->redirect("/maintenance.html", false); exit; } ?> <!DOCTYPE html> ... Note: && $user->name !== $upgradePage->maintainer needs to be included otherwise everyone including the site upgrade admin gets redirected. I need to ensure that the admin who checks the maintenance checkbox can login and review the sites to make sure everything is OK with the Processwire upgrade before making them live again. The maintainer field is still not being updated whether I use AddHookBefore or AddHookAfter methods or the setAndSave alternative instructions. When the checkbox is ticked by a logged in admin only the users with hasRole = guest get redirected. Anyone with a login is not redirected and could potentially interfere or cause problems for the site upgrade process. The only way the code works as intended is if I enter the admin username into the maintainer field manually. I just don't get why the maintainer field is not being updated. Any further thoughts?
  13. ridgedale

    Thanks again for your reply, @Tom. Unfortunately the https://processwire.com/demo/ isn't really very help as I would prefer that demo-admin users are able to view the backend interface they will very likely be using with all the current pages. I wonder: Is possible to set up a demo site based on an existing site and, if so, how to go about it?
  14. ridgedale

    There is no need to apologise, Tom, for freely offering your time to help. Your assistance is greatly appreciated. Just to clarify, is the role "demo-user" a built-in role? If so, how do I assign it to a user, as that role does not currently exist? Also, does demo in: wire('config')->demo = true; to a built-in demo capability for any website? Or is demo something that needs to be setup?