<?php
# Plugin to display a warning that the viewed resource will not be visible when the user logs out of the manager.
# Fires on: OnLoadWebDucument
# Author: [email protected]
if (!$modx->resource->get('published')&&$modx->user->hasSessionContext('mgr')) {
$modx->getService('lexicon','modLexicon');
$modx->lexicon->load('resource');
if ($modx->lexicon('resource_unpublished')) {
$message = $modx->lexicon('resource_unpublished');
}
else {
$message = "Page is not published";
}
// add "Publish Now" button, clear cache and refresh page
// 8 Nov 2015 sottwell
$button = '';
if($modx->hasPermission('publish')) {
$button = '<form action="" method="post" style="display:inline-block;"><input type="submit" id="pubnow" name="pubnow" value="Publish Now"></form>';
if(isset($_POST['pubnow']) && ($_POST['pubnow'] == 'Publish Now')) {
$rid = $modx->resource->get('id');
$result = $modx->runProcessor('resource/publish', array('id' => $rid));
$url = $modx->makeURL($rid);
$modx->sendRedirect($url);
}
}
$modx->regClientHTMLBlock('
<div style="position: fixed; top: 0; width:100%; height: 50px; background-color: #f33; opacity: 0.6;">
<div style="padding: 15px; margin: 0 auto; width: 800px; color: #fff; text-shadow: 1px 1px 5px #000">'.$message . ' - ' . $button . '</div>
</div>
');
}
]]>