2

I have recently set up our website so that I can put it in read-only mode (using the Read Only Mode module) when doing maintenance, such as upgrades and code pulls, however, this is a Drupal function only and I noticed that while in read-only mode, CiviCRM front-facing forms, such as CiviContribute forms, as well as backend functions are still available.

Is there a way to either put CiviCRM into read-only mode or turn off/deactivate the CiviContribute forms? I have written a bash script that runs all my update/upgrade processes and would like to find a way to do this using drush. For staff, I'm thinking of just deactivating the link to CiviCRM in the administrative menu, but I am most concerned with making sure users can't process transactions and write to the database during down-time.

I'm on CiviCRM 5.1.0 and Drupal 7.59

  • You mean that new (?) 'read only' module? – petednz - fuzion May 18 '18 at 5:44
  • 1
    how does it deal with webforms by the way? I liked the look of this but didn't go the extra step of working out how to disable all Civi forms so gave up - be good if you come up with a simple command solution – petednz - fuzion May 18 '18 at 5:45
  • 1
    Yes, I'm using the new Drupal read only mode module, I'll update my question. It seems to work great so far, by disabling all drupal forms, including the civicrm webforms module. – Christia May 18 '18 at 8:25
  • I popped a link in – petednz - fuzion May 18 '18 at 20:44
2

For the CiviContribute forms, you can choose Disable for each form from the Manage Contribution Pages screen (civicrm/admin/contribute?reset=1 on 4.6 LTS). The Disable option is under the More link. When maintenance is done, you can Enable each one in the same way.Disable contribution forms under the More option

For something from the command line:

There is an entity in the API called ContributionPage with a parameter called "Is Page Active?" (is_active). I just executed the Create action thru the API Explorer and it seems to have worked. I would test it out and see what works best for you. The API Explorer lists the drush command as: drush cvapi ContributionPage.create sequential=1 id=15 is_active=0 (0 being disabled and 1 being enabled)

  • Yes, exactly. I'd like to be able to disable the forms in my bash scripts, probably using drush. Something like drush vset [variable] 0 – Christia May 17 '18 at 18:44
  • 2
    There is an entity in the API called ContributionPage with a parameter called "Is Page Active?" (is_active). I just executed the Create action thru the API Explorer and it seems to have worked. YMMV. The API Explorer is listing the drush command as: drush cvapi ContributionPage.create sequential=1 id=15 is_active=0 – Allen Hutchison May 17 '18 at 19:50
  • 1
    Using the drush cvapi ContributionPage.create sequential=1 id=15 is_active=0 command in my script is what I need! I can also do something to hide the link or change the text on disabled forms. Thank you! – Christia Jun 11 '18 at 17:53
  • I'm thinking I'd rather not deactivate the forms. I want to find a way that preserves the page but just maybe makes the submit button turn into a box that says it's unavailabe or something. – Christia Jul 18 '18 at 0:31
2

Maybe, we could just add an extension with a simple call to freeze the form in a buildform hook. Something like -

function example_civicrm_buildForm($formName, &$form) {
  $form->freeze();
}

This will display all forms in CiviCRM as read-only.

Note: We need to enable this ext before an upgrade and disable after the process is completed.

1

No there is no way of putting CiviCRM in read only or maintance mode.

However if you put Drupal in maintaince mode only administrators could login and access civicrm. All other users cannot do anything.

  • Thanks. I used to use maintenance mode but I favor having no downtime. – Christia May 17 '18 at 16:13
  • We all favor no downtime, no downtime is a complex job when you are upgrading even with systems who are designed for this. – Jaap Jansma - CiviCooP May 18 '18 at 6:33
0

You could temporarily disable the CiviCRM module. That would take down all your contribution forms, etc. However you'd have to be careful to re-enable it when doing anything Civi-related in your maintenance. It must be enabled in order to upgrade CiviCRM.

  • This is too risky because if my update includes a CiviCRM upgrade, then the module needs to remain enabled. – Christia Jun 11 '18 at 17:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.