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.8');
+ $propbag->add('version', '1.12');
$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_cache_purge' => true,
'backend_plugins_new_instance' => true,
'frontend_entryproperties_query' => true,
- 'frontend_entries_rss' => true
+ 'frontend_entries_rss' => 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_nl2br', 'no_frontpage', 'hiderss');
+ $supported_properties = array('is_sticky', 'access', 'access_groups', 'access_users', 'cache_body', 'cache_extended', 'no_frontpage', 'hiderss', 'entrypassword');
$fields = explode(',', trim($this->get_config('customfields')));
if (is_array($fields) && count($fields) > 0) {
return $and;
}
+ /*
+ * This function converts specific property fields so that they are
+ * available natively to other plugins/templates.
+ */
+ function applyProperties(&$properties) {
+ global $serendipity;
+
+ if (is_array($properties['disable_markups'])) {
+ foreach($properties['disable_markups'] AS $idx => $instance) {
+ $properties['disable_markup_' . $instance] = $instance;
+ }
+ }
+ }
+
function addProperties(&$properties, &$eventData) {
global $serendipity;
// Get existing data
$property = serendipity_fetchEntryProperties($eventData['id']);
$supported_properties = serendipity_event_entryproperties::getSupportedProperties();
+ // Special case for disable markups.
+ if (is_array($properties['disable_markups'])) {
+ $q = "DELETE FROM {$serendipity['dbPrefix']}entryproperties WHERE entryid = " . (int)$eventData['id'] . " AND property LIKE 'ep_disable_markup_%'";
+ serendipity_db_query($q);
+
+ foreach($properties['disable_markups'] AS $idx => $instance) {
+ $supported_properties[] = 'disable_markup_' . $instance;
+ }
+ }
+
foreach($supported_properties AS $prop_key) {
$prop_val = (isset($properties[$prop_key]) ? $properties[$prop_key] : null);
$prop_key = 'ep_' . $prop_key;
}
}
+ 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;
|| (isset($serendipity['POST']['properties']['is_sticky']) && serendipity_db_bool($serendipity['POST']['properties']['is_sticky']))
? 'checked="checked"'
: '';
- $nl2br = (isset($eventData['properties']['ep_no_nl2br']) && serendipity_db_bool($eventData['properties']['ep_no_nl2br']))
- || (isset($serendipity['POST']['properties']['no_nl2br']) && serendipity_db_bool($serendipity['POST']['properties']['no_nl2br']))
- ? 'checked="checked"'
- : '';
$no_frontpage = (isset($eventData['properties']['ep_no_frontpage']) && serendipity_db_bool($eventData['properties']['ep_no_frontpage']))
|| (isset($serendipity['POST']['properties']['no_frontpage']) && serendipity_db_bool($serendipity['POST']['properties']['no_frontpage']))
} else {
$access_users = array();
}
+
+ if (isset($eventData['properties']['ep_entrypassword'])) {
+ $password = $eventData['properties']['ep_entrypassword'];
+ } 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 PLUGIN_EVENT_ENTRYPROPERTIES_STICKYPOSTS; ?>" for="properties_is_sticky"> <?php echo PLUGIN_EVENT_ENTRYPROPERTIES_STICKYPOSTS; ?> </label><br />
<input type="checkbox" name="serendipity[properties][no_frontpage]" id="properties_no_frontpage" value="true" <?php echo $no_frontpage; ?> />
<label title="<?php echo PLUGIN_EVENT_ENTRYPROPERTIES_NO_FRONTPAGE; ?>" for="properties_no_frontpage"> <?php echo PLUGIN_EVENT_ENTRYPROPERTIES_NO_FRONTPAGE; ?> </label><br />
-<?php if (class_exists('serendipity_event_nl2br')){ ?>
- <input type="checkbox" name="serendipity[properties][no_nl2br]" id="properties_no_nl2br" value="true" <?php echo $nl2br; ?> />
- <label title="<?php echo PLUGIN_EVENT_ENTRYPROPERTIES_NL2BR; ?>" for="properties_no_nl2br"> <?php echo PLUGIN_EVENT_ENTRYPROPERTIES_NL2BR; ?> </label><br />
-
-<?php } ?>
<input type="checkbox" name="serendipity[properties][hiderss]" id="properties_hiderss" value="true" <?php echo $hiderss; ?> />
<label title="<?php echo PLUGIN_EVENT_ENTRYPROPERTIES_HIDERSS_DESC; ?>" for="properties_hiderss"> <?php echo PLUGIN_EVENT_ENTRYPROPERTIES_HIDERSS; ?> </label><br />
<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']);
</select>
</div>
+ <br />
+ <div class="entryproperties_markup">
+ <?php echo PLUGIN_EVENT_ENTRYPROPERTIES_DISABLE_MARKUP; ?><br />
+ <div style="margin-left: 10px">
+ <select name="serendipity[properties][disable_markups][]" multiple="multiple" size="4">
+ <?php
+ $plugins = serendipity_plugin_api::get_event_plugins();
+
+ if (is_array($plugins)) {
+ // foreach() operates on copies of values, but we want to operate on references, so we use while()
+ @reset($plugins);
+ while(list($plugin, $plugin_data) = each($plugins)) {
+ if (!is_array($plugin_data['p']->markup_elements)) {
+ continue;
+ }
+
+ if (isset($serendipity['POST']['properties']['disable_markups']) && in_array($plugin_data['p']->instance, $serendipity['POST']['properties']['disable_markups'])) {
+ $selected = true;
+ } elseif (isset($eventData['properties']['ep_disable_markup_' . $plugin_data['p']->instance])) {
+ $selected = true;
+ } else {
+ $selected = false;
+ }
+
+ echo '<option ' . ($selected ? 'selected="selected"' : '') . ' value="' . $plugin_data['p']->instance . '">' . htmlspecialchars($plugin_data['p']->title) . '</option>' . "\n";
+ }
+ }
+ ?>
+ </select>
+ </div>
+ </div>
+
<?php
$fields = trim($this->get_config('customfields'));
if (!empty($fields)) {
<tr>
<td class="customfield_<?php echo $fieldname; ?> customfield_name"><strong><?php echo $fieldname; ?></strong></td>
<td class="customfield_<?php echo $fieldname; ?> customfield_value"><textarea id="prop<?php echo htmlspecialchars($fieldname); ?>" name="serendipity[properties][<?php echo htmlspecialchars($fieldname); ?>]"><?php echo htmlspecialchars($value); ?></textarea></td>
- <td valign="top"><script type="text/javascript" language="JavaScript">document.write('<input type="button" name="insImage" value="<?php echo IMAGE ; ?>" onclick="window.open(\'serendipity_admin_image_selector.php?serendipity[htmltarget]=prop<?php echo htmlspecialchars($fieldname); ?>&serendipity[filename_only]=true\', \'ImageSel\', \'width=800,height=600,toolbar=no,scrollbars=1,scrollbars,resize=1,resizable=1\');" class="serendipityPrettyButton" />');</script></td>
+ <td valign="top"><script type="text/javascript" language="JavaScript">document.write('<input type="button" name="insImage" value="<?php echo MEDIA ; ?>" onclick="window.open(\'serendipity_admin_image_selector.php?serendipity[htmltarget]=prop<?php echo htmlspecialchars($fieldname); ?>&serendipity[filename_only]=true\', \'ImageSel\', \'width=800,height=600,toolbar=no,scrollbars=1,scrollbars,resize=1,resizable=1\');" class="serendipityPrettyButton" />');</script></td>
</tr>
<?php
}
}
return true;
break;
+
case 'backend_import_entry':
//TODO: (ph) Maybe handle caching?
if (is_array($addData) && !$addData['nl2br']){
$this->addProperties($props, $eventData);
}
break;
+
case 'backend_sidebar_entries_event_display_buildcache':
if ($is_cache) {
$per_fetch = 25;
serendipity_db_query("DELETE FROM {$serendipity['dbPrefix']}entryproperties WHERE property LIKE 'ep_cache_%'");
break;
+ case 'backend_entry_presave':
+ if (is_array($serendipity['POST']['properties'])) {
+ $this->applyProperties($serendipity['POST']['properties']);
+ }
+ break;
+
case 'backend_publish':
case 'backend_save':
if (!isset($serendipity['POST']['properties']) || !is_array($serendipity['POST']['properties']) || !isset($eventData['id'])) {
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_entrypassword'])) {
+
+ if (isset($_SESSION['entrypassword_unlocked'][$serendipity['GET']['id']]) || $eventData[0]['properties']['ep_entrypassword'] == $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':
$conds[] = " (ep_access.property IS NULL OR ep_access.value = 'public')";
}
- if (!isset($serendipity['GET']['category']) && !isset($serendipity['GET']['adminModule']) && $event == 'frontend_fetchentries') {
+ if (!isset($serendipity['GET']['category']) && !isset($serendipity['GET']['adminModule']) && $event == 'frontend_fetchentries' && $addData['source'] != 'search') {
$conds[] = " (ep_no_frontpage.property IS NULL OR ep_no_frontpage.value != 'true') ";
$joins[] = " LEFT OUTER JOIN {$serendipity['dbPrefix']}entryproperties ep_no_frontpage
ON (e.id = ep_no_frontpage.entryid AND ep_no_frontpage.property = 'ep_no_frontpage')";