From: garvinhicking Date: Sun, 31 Jul 2005 21:17:40 +0000 (+0000) Subject: Make entryproperties plugin also restrict viewability depending on the author, and... X-Git-Tag: 0.9~257 X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=7c402aebdcb8edcdeda5da9bdb89179168990a84;p=s9y.git Make entryproperties plugin also restrict viewability depending on the author, and not groups only --- diff --git a/plugins/serendipity_event_entryproperties/serendipity_event_entryproperties.php b/plugins/serendipity_event_entryproperties/serendipity_event_entryproperties.php index 257863e..077870b 100644 --- a/plugins/serendipity_event_entryproperties/serendipity_event_entryproperties.php +++ b/plugins/serendipity_event_entryproperties/serendipity_event_entryproperties.php @@ -29,6 +29,8 @@ switch ($serendipity['lang']) { @define('PLUGIN_EVENT_ENTRYPROPERTIES_NO_FRONTPAGE', 'Nicht in Artikelübersicht zeigen'); @define('PLUGIN_EVENT_ENTRYPROPERTIES_GROUPS', 'Leserechte auf Gruppen beschränken'); @define('PLUGIN_EVENT_ENTRYPROPERTIES_GROUPS_DESC', 'Wenn aktiviert, können Leserechte abhängig von Gruppen vergeben werden. Dies wirkt sich auf die Performance der Artikelübersicht stark aus. Aktivieren Sie die Option daher nur, wenn Sie sie wirklich benötigen.'); + @define('PLUGIN_EVENT_ENTRYPROPERTIES_USERS', 'Leserechte auf Benutzer beschränken'); + @define('PLUGIN_EVENT_ENTRYPROPERTIES_USERS_DESC', 'Wenn aktiviert, können Leserechte abhängig von einzelnen Benutzern vergeben werden. Dies wirkt sich auf die Performance der Artikelübersicht stark aus. Aktivieren Sie die Option daher nur, wenn Sie sie wirklich benötigen.'); break; case 'en': @@ -55,6 +57,8 @@ switch ($serendipity['lang']) { @define('PLUGIN_EVENT_ENTRYPROPERTIES_NO_FRONTPAGE', 'Hide from article overview / frontpage'); @define('PLUGIN_EVENT_ENTRYPROPERTIES_GROUPS', 'Use group-based restrictions'); @define('PLUGIN_EVENT_ENTRYPROPERTIES_GROUPS_DESC', 'If enabled, you can define which users of a usergroup may be able to read entries. This option has a large impact on the performance of your article overview. Only enable this if you are really going to use this feature.'); + @define('PLUGIN_EVENT_ENTRYPROPERTIES_GROUPS', 'Use user-based restrictions'); + @define('PLUGIN_EVENT_ENTRYPROPERTIES_GROUPS_DESC', 'If enabled, you can define which specific users may be able to read entries. This option has a large impact on the performance of your article overview. Only enable this if you are really going to use this feature.'); break; } @@ -71,7 +75,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.2'); + $propbag->add('version', '1.3'); $propbag->add('requirements', array( 'serendipity' => '0.8', 'smarty' => '2.6.7', @@ -94,7 +98,7 @@ class serendipity_event_entryproperties extends serendipity_event 'frontend_entryproperties_query' => true )); $propbag->add('groups', array('BACKEND_EDITOR')); - $propbag->add('configuration', array('cache', 'use_groups', 'default_read')); + $propbag->add('configuration', array('cache', 'use_groups', 'use_users', 'default_read')); } function introspect_config_item($name, &$propbag) @@ -120,6 +124,13 @@ class serendipity_event_entryproperties extends serendipity_event $propbag->add('default', 'false'); break; + case 'use_users': + $propbag->add('type', 'boolean'); + $propbag->add('name', PLUGIN_EVENT_ENTRYPROPERTIES_USERS); + $propbag->add('description', PLUGIN_EVENT_ENTRYPROPERTIES_USERS_DESC); + $propbag->add('default', 'false'); + break; + case 'cache': $propbag->add('type', 'boolean'); $propbag->add('name', PLUGIN_EVENT_ENTRYPROPERTIES_CACHE); @@ -167,7 +178,7 @@ class serendipity_event_entryproperties extends serendipity_event } function getSupportedProperties() { - static $supported_properties = array('is_sticky', 'access', 'access_groups', 'cache_body', 'cache_extended', 'no_nl2br', 'no_frontpage'); + static $supported_properties = array('is_sticky', 'access', 'access_groups', 'access_users', 'cache_body', 'cache_extended', 'no_nl2br', 'no_frontpage'); return $supported_properties; } @@ -209,8 +220,9 @@ class serendipity_event_entryproperties extends serendipity_event global $serendipity; $hooks = &$bag->get('event_hooks'); - $is_cache = serendipity_db_bool($this->get_config('cache', 'true')); + $is_cache = serendipity_db_bool($this->get_config('cache', 'true')); $use_groups = serendipity_db_bool($this->get_config('use_groups')); + $use_users = serendipity_db_bool($this->get_config('use_users')); if (isset($hooks[$event])) { switch($event) { @@ -255,6 +267,14 @@ class serendipity_event_entryproperties extends serendipity_event } else { $access_groups = array(); } + + if (isset($eventData['properties']['ep_access_users'])) { + $access_users = explode(';', $eventData['properties']['ep_access_users']); + } elseif (isset($serendipity['POST']['properties']['access_users'])) { + $access_users = $serendipity['POST']['properties']['access_users']; + } else { + $access_users = array(); + } ?>
@@ -287,6 +307,19 @@ class serendipity_event_entryproperties extends serendipity_event foreach($my_groups AS $group) { ?> +'; + } + + if ($use_users) { +?> +