Textpattern Forum

You are not logged in. Register | Login | Help

#101 2009-11-05 18:25:45

ruud
Developer emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 4,492
Website

Re: rvm_maintenance (v0.5)

Ask the core devs. It’s not something I would add.

Offline

#102 2011-09-28 13:17:54

jakob
Moderator
From: Germany
Registered: 2005-01-20
Posts: 1,895
Website

Re: rvm_maintenance (v0.5)

maniqui wrote:

BTW, a tip (maybe already posted): using rvm_privileged and rvm_maintenance, it could be helpful to create a message on top of the page that reads “Site is in maintenance mode. Remember to de-activate rvm_maintenance when task is over.”

Something like this may work:

<txp:if_status status="503">
    <txp:rvm_if_privileged>
    <p>Site is in maintenance mode. Remember to de-activate rvm_maintenance.</p>
    </txp:rvm_if_privileged>
</txp:if_status>

I couldn’t get this to work – presumably because the logged in user is presented with the page that does not have 503 status – but it got me thinking and in combination with an earlier tip by ruud the following does work:

<txp:php>global $variable; $variable['maintenance_mode'] = function_exists('rvm_maintenance') ? 'yes' : '';</txp:php>
<txp:if_variable name="maintenance_mode" value="yes">
  <div id="notice">Site is in maintenance mode. Remember to de-activate rvm_maintenance to make the site publicly viewable.</div>
</txp:if_variable>

and if you want some css with that:

#notice {
  display: block;
  width: 100%;
  z-index: 999;
  position: fixed;
  top: 0; left: 0;
  line-height: 2em;
  text-align: center;
  color: #c30;
  opacity: 0.85;
  background-color: #fee22d;
}

rvm_if_priviliged is only necessary if you only want to restrict this message to a particular user level. And if anyone has found a better way, please tell.

 

* * *

 

Likewise, I’d like to put a “maintenance mode” switch on the dashboard (rather than in the admin area which certain admin users can’t access). What would be the best way of doing this? Would it work at all for normal publishers?

The admin : plugins pane has a link with txp_token (how do I get this?) without which plugin activation/deactivation doesn’t work. ied_plugin_composer on the other hand doesn’t seem to need txp_token (unless its passed as a POST var).

Last edited by jakob (2011-09-28 13:28:32)


TXP Builders – finely-crafted code, design and txp

Offline

#103 2011-09-28 13:37:58

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 5,800
Website

Re: rvm_maintenance (v0.5)

jakob

Nice tip, thanks. The number of times I’ve finished a site and forgotten to switch the plugin off…

Likewise, I’d like to put a “maintenance mode” switch on the dashboard (rather than in the admin area which certain admin users can’t access). What would be the best way of doing this? Would it work at all for normal publishers?

Yep. Add an HTML form, get it to submit to the same page, do the usual step-detection dance and then do something similar to the switch_status() function in include/txp_plugin.php.

The admin : plugins pane has a link with txp_token (how do I get this?)

Two ways:

  1. add a call to tInput() inside your form
  2. build your form with Txp’s built-in form() function (see lib/txplib_forms.php) which’ll add the token automatically

ied_plugin_composer on the other hand doesn’t seem to need txp_token

It’s too old skool to have one. Needs caning for being naughty. And lines.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern.

Txp Builders – finely-crafted code, design and Txp

Offline

#104 2011-11-30 16:53:12

jakob
Moderator
From: Germany
Registered: 2005-01-20
Posts: 1,895
Website

Re: rvm_maintenance (v0.5)

I had another stab at providing a rvm_maintenance powered maintenance mode switch to less privileged users via a dashboard panel rather than giving them access to the plugins pane. I’m using smd_tabber and a tabber_dashboard page template and have something that’s working nicely, but as I circumvented the tokens, forms, events and steps so I would appreciate any pointers or warnings in case I’m opening up any vulnerabilities by doing it this way.

In my smd_tabber dashboard template I have the following right at the top:

<txp:php>
    global $variable;

    $maintenance_mode = gps('maintenance_mode');

    if ($maintenance_mode != '') {
        $change = ($maintenance_mode == 'on') ? 1 : 0;
        safe_update('txp_plugin', "status = $change", "name = 'rvm_maintenance'");
        $variable['maintenance_mode'] = ($change == 1) ? 'on' : 'off';
    } else {
        $variable['maintenance_mode'] = function_exists('rvm_maintenance') ? 'on' : 'off';
    }
</txp:php>

This basically activates maintenance mode when ?maintenance_mode=on is passed via the url on the dashboard (only). Any other value for maintenance_mode switches it off. Further down in my dashboard template where I want to have the maintenance mode switch I have the following:

<txp:if_variable name="maintenance_mode" value="on">
    <div id="notice">Site is in maintenance mode!</div>
    <a href="?maintenance_mode=off">De-activate maintenance mode</a>
<txp:else />
    <a href="?maintenance_mode=on">Activate maintenance mode</a>
</txp:if_variable>

You can also use <txp:if_variable name="maintenance_mode" value="off">...</txp:if_variable> if you want to test the off state separately from the on state.

Notes:

  • requires rvm_maintenance :-)
  • uses smd_tabber – your mileage may vary with other dashboard plugins
  • the urlvar switch is only available on the dashboard pane

TXP Builders – finely-crafted code, design and txp

Offline

Board footer

Powered by FluxBB