class serendipity_event_entryproperties extends serendipity_event
{
- var $services;
+ var $services, $showPasswordForm;
var $title = PLUGIN_EVENT_ENTRYPROPERTIES_TITLE;
function introspect(&$propbag)
$propbag->add('description', PLUGIN_EVENT_ENTRYPROPERTIES_DESC);
$propbag->add('stackable', false);
$propbag->add('author', 'Garvin Hicking');
- $propbag->add('version', '1.10');
+ $propbag->add('version', '1.11');
$propbag->add('requirements', array(
'serendipity' => '0.8',
'smarty' => '2.6.7',
'backend_display' => true,
'backend_import_entry' => true,
'entry_display' => true,
+ 'entries_header' => true,
'frontend_entryproperties' => true,
'backend_sidebar_entries_event_display_buildcache' => true,
'backend_sidebar_entries' => true,
'backend_plugins_new_instance' => true,
'frontend_entryproperties_query' => true,
'frontend_entries_rss' => true,
- 'backend_entry_presave' => true
+ 'backend_entry_presave' => true,
+ 'frontend_configure' => true
));
$propbag->add('groups', array('BACKEND_EDITOR'));
$propbag->add('configuration', array('cache', 'use_groups', 'use_users', 'default_read', 'customfields'));
static $supported_properties = null;
if ($supported_properties === null) {
- $supported_properties = array('is_sticky', 'access', 'access_groups', 'access_users', 'cache_body', 'cache_extended', 'no_frontpage', 'hiderss');
+ $supported_properties = array('is_sticky', 'access', 'access_groups', 'access_users', 'cache_body', 'cache_extended', 'no_frontpage', 'hiderss', 'password');
$fields = explode(',', trim($this->get_config('customfields')));
if (is_array($fields) && count($fields) > 0) {
}
}
+ function showPasswordform() {
+ global $serendipity;
+ $url = serendipity_currentURL();
+
+ $out = '
+ <form action="'.$url.'" method="post" id="entrypasswordform">
+ <div>
+ <span><label for="entrypassword">' . PASSWORD . ':</label> <input id="entrypassword" type="password" name="serendipity[entrypassword]" value="" /></span>
+ <span><input type="submit" name="login" value="'.LOGIN.'" /></span>
+ </div>
+ </form>';
+ return $out;
+
+ }
+
function event_hook($event, &$bag, &$eventData, $addData = null) {
global $serendipity;
} else {
$access_users = array();
}
+
+ if (isset($eventData['properties']['ep_password'])) {
+ $password = $eventData['properties']['ep_password'];
+ } elseif (isset($serendipity['POST']['properties']['entrypassword'])) {
+ $password = $serendipity['POST']['properties']['entrypassword'];
+ } else {
+ $password = '';
+ }
+
?>
<fieldset style="margin: 5px">
<legend><?php echo PLUGIN_EVENT_ENTRYPROPERTIES_TITLE; ?></legend>
<label title="<?php echo $radio_title; ?>" for="properties_access_<?php echo $radio_value; ?>"> <?php echo $radio_title; ?> </label>
<?php
}
+?>
+ <br /><?php echo PASSWORD; ?>:<br />
+ <div style="margin-left: 10px">
+ <input type="password" name="serendipity[properties][entrypassword]" value="<?php echo htmlspecialchars($password); ?>" />
+ </div>
+<?php
if ($use_groups) {
$my_groups = serendipity_getGroups($serendipity['authorid']);
return true;
break;
+ case 'frontend_configure':
+ if (isset($serendipity['POST']['id']) && empty($serendipity['GET']['id'])) {
+ $serendipity['GET']['id'] = &$serendipity['POST']['id'];
+ $serendipity['GET']['subpage'] = &$serendipity['POST']['subpage'];
+ }
+ break;
+
case 'frontend_entryproperties':
$and = $this->returnQueryCondition($is_cache);
$q = "SELECT entryid, property, value FROM {$serendipity['dbPrefix']}entryproperties WHERE entryid IN (" . implode(', ', array_keys($addData)) . ") $and";
// PH: This is done after Garvins suggestion to patchup $eventData in case an entry
// is in the process of being created. This must be done for the extended properties
// to be applied in the preview.
+
if (is_array($serendipity['POST']['properties']) && count($serendipity['POST']['properties']) > 0){
$parr = array();
$supported_properties = serendipity_event_entryproperties::getSupportedProperties();
$eventData[0]['properties']['ep_' . $prop_key] = $serendipity['POST']['properties'][$prop_key];
}
}
+
+ if (isset($serendipity['GET']['id']) && isset($eventData[0]['properties']['ep_password'])) {
+
+ if (isset($_SESSION['entrypassword_unlocked'][$serendipity['GET']['id']]) || $eventData[0]['properties']['ep_password'] == $serendipity['POST']['entrypassword']) {
+ // Do not show login form again, once we have first enabled it.
+ $_SESSION['entrypassword_unlocked'][$serendipity['GET']['id']] = true;
+ } else {
+ if (is_array($eventData)) {
+ $eventData['clean_page'] = true;
+ } else {
+ $eventData = array('clean_page' => true);
+ }
+ $this->showPasswordForm = true;
+ }
+ }
+
+ break;
+
+ case 'entries_header':
+ if ($this->showPasswordForm) {
+ echo $this->showPasswordform();
+ }
break;
case 'frontend_fetchentries':