From 1e42c4ae14138cde2d4155e5bb6e6bbecc0790dc Mon Sep 17 00:00:00 2001 From: garvinhicking Date: Tue, 4 Jul 2006 09:10:57 +0000 Subject: [PATCH] Commit Falk's patch to show password forms --- docs/NEWS | 3 + .../serendipity_event_entryproperties.php | 70 +++++++++++++++++-- 2 files changed, 69 insertions(+), 4 deletions(-) diff --git a/docs/NEWS b/docs/NEWS index 2bc27c0..6428da9 100644 --- a/docs/NEWS +++ b/docs/NEWS @@ -3,6 +3,9 @@ Version 1.1-alpha7() ------------------------------------------------------------------------ + * Add patch to allow entryproperties plugin to define passwords for + specific entries (Falk Döring) + * Made smarty function "serendipity_printComments" accept to new parameters: "order" (ASC/DESC) and "limit" (garvinhicking) diff --git a/plugins/serendipity_event_entryproperties/serendipity_event_entryproperties.php b/plugins/serendipity_event_entryproperties/serendipity_event_entryproperties.php index 31b7708..4d23068 100644 --- a/plugins/serendipity_event_entryproperties/serendipity_event_entryproperties.php +++ b/plugins/serendipity_event_entryproperties/serendipity_event_entryproperties.php @@ -10,7 +10,7 @@ include dirname(__FILE__) . '/lang_en.inc.php'; class serendipity_event_entryproperties extends serendipity_event { - var $services; + var $services, $showPasswordForm; var $title = PLUGIN_EVENT_ENTRYPROPERTIES_TITLE; function introspect(&$propbag) @@ -21,7 +21,7 @@ class serendipity_event_entryproperties extends serendipity_event $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', @@ -35,6 +35,7 @@ class serendipity_event_entryproperties extends serendipity_event '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, @@ -43,7 +44,8 @@ class serendipity_event_entryproperties extends serendipity_event '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')); @@ -136,7 +138,7 @@ class serendipity_event_entryproperties extends serendipity_event 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) { @@ -209,6 +211,21 @@ class serendipity_event_entryproperties extends serendipity_event } } + function showPasswordform() { + global $serendipity; + $url = serendipity_currentURL(); + + $out = ' +
+
+ + +
+
'; + return $out; + + } + function event_hook($event, &$bag, &$eventData, $addData = null) { global $serendipity; @@ -269,6 +286,15 @@ class serendipity_event_entryproperties extends serendipity_event } 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 = ''; + } + ?>
@@ -289,6 +315,12 @@ class serendipity_event_entryproperties extends serendipity_event +
:
+
+ +
+returnQueryCondition($is_cache); $q = "SELECT entryid, property, value FROM {$serendipity['dbPrefix']}entryproperties WHERE entryid IN (" . implode(', ', array_keys($addData)) . ") $and"; @@ -572,6 +611,7 @@ class serendipity_event_entryproperties extends serendipity_event // 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(); @@ -580,6 +620,28 @@ class serendipity_event_entryproperties extends serendipity_event $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': -- 2.39.5