add('name', PLUGIN_EVENT_ENTRYPROPERTIES_TITLE);
$propbag->add('description', PLUGIN_EVENT_ENTRYPROPERTIES_DESC);
$propbag->add('stackable', false);
$propbag->add('author', 'Garvin Hicking');
$propbag->add('version', '1.20');
$propbag->add('requirements', array(
'serendipity' => '0.8',
'smarty' => '2.6.7',
'php' => '4.1.0'
));
$propbag->add('event_hooks', array(
'frontend_fetchentries' => true,
'frontend_fetchentry' => true,
'backend_publish' => true,
'backend_save' => true,
'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_entries' => true,
'backend_cache_purge' => true,
'backend_plugins_new_instance' => true,
'frontend_entryproperties_query' => true,
'frontend_entries_rss' => true,
'backend_entry_presave' => true,
'frontend_configure' => true
));
$propbag->add('groups', array('BACKEND_EDITOR'));
$propbag->add('configuration', array('cache', 'sequence', 'use_groups', 'use_users', 'use_ext_joins', 'default_read', 'customfields'));
}
function introspect_config_item($name, &$propbag)
{
switch($name) {
case 'default_read':
$propbag->add('type', 'radio');
$propbag->add('name', USE_DEFAULT . ': ' . PLUGIN_EVENT_ENTRYPROPERTIES_ACCESS);
$propbag->add('description', '');
$propbag->add('radio', array(
'value' => array('private', 'public', 'member'),
'desc' => array(PLUGIN_EVENT_ENTRYPROPERTIES_ACCESS_PRIVATE, PLUGIN_EVENT_ENTRYPROPERTIES_ACCESS_PUBLIC, PLUGIN_EVENT_ENTRYPROPERTIES_ACCESS_MEMBERS)
));
$propbag->add('default', 'public');
$propbag->add('radio_per_row', '1');
break;
case 'customfields':
$propbag->add('type', 'text');
$propbag->add('name', PLUGIN_EVENT_ENTRYPROPERTIES_CUSTOMFIELDS);
$propbag->add('description', PLUGIN_EVENT_ENTRYPROPERTIES_CUSTOMFIELDS_DESC2);
$propbag->add('default', 'CustomField1, CustomField2, CustomField3');
break;
case 'use_groups':
$propbag->add('type', 'boolean');
$propbag->add('name', PLUGIN_EVENT_ENTRYPROPERTIES_GROUPS);
$propbag->add('description', PLUGIN_EVENT_ENTRYPROPERTIES_GROUPS_DESC);
$propbag->add('default', 'false');
break;
case 'use_ext_joins':
$propbag->add('type', 'boolean');
$propbag->add('name', PLUGIN_EVENT_ENTRYPROPERTIES_EXTJOINS);
$propbag->add('description', PLUGIN_EVENT_ENTRYPROPERTIES_EXTJOINS_DESC);
$propbag->add('default', 'true');
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);
$propbag->add('description', PLUGIN_EVENT_ENTRYPROPERTIES_CACHE_DESC);
$propbag->add('default', 'true');
break;
case 'sequence':
$propbag->add('type', 'sequence');
$propbag->add('name', PLUGIN_EVENT_ENTRYPROPERTIES_SEQUENCE);
$propbag->add('description', PLUGIN_EVENT_ENTRYPROPERTIES_SEQUENCE_DESC);
$propbag->add('checkable', true);
$values = array(
'sticky' => array('display' => PLUGIN_EVENT_ENTRYPROPERTIES_STICKYPOSTS),
'frontpage' => array('display' => PLUGIN_EVENT_ENTRYPROPERTIES_NO_FRONTPAGE),
'hiderss' => array('display' => PLUGIN_EVENT_ENTRYPROPERTIES_HIDERSS),
'access' => array('display' => PLUGIN_EVENT_ENTRYPROPERTIES_ACCESS),
'password' => array('display' => PASSWORD),
'groups' => array('display' => PERM_READ . ': ' . GROUP),
'authors' => array('display' => PERM_READ . ': ' . AUTHOR),
'author' => array('display' => AUTHOR),
'markup' => array('display' => PLUGIN_EVENT_ENTRYPROPERTIES_DISABLE_MARKUP),
'customfields' => array('display' => PLUGIN_EVENT_ENTRYPROPERTIES_CUSTOMFIELDS),
);
$propbag->add('values', $values);
$propbag->add('default', 'sticky,frontpage,hiderss,access,password,groups,authors,author,markup,customfields');
break;
}
return true;
}
function generate_content(&$title) {
$title = $this->title;
}
function install() {
serendipity_plugin_api::hook_event('backend_cache_entries', $this->title);
}
function uninstall() {
serendipity_plugin_api::hook_event('backend_cache_purge', $this->title);
}
function &getValidAuthors() {
global $serendipity;
if (serendipity_checkPermission('adminUsersMaintainOthers')) {
$users = serendipity_fetchUsers('');
} elseif (serendipity_checkPermission('adminUsersMaintainSame')) {
$users = serendipity_fetchUsers('', serendipity_getGroups($serendipity['authorid'], true));
} else {
$users = serendipity_fetchUsers($serendipity['authorid']);
}
return $users;
}
function updateCache(&$entry) {
global $serendipity;
serendipity_db_query("DELETE FROM {$serendipity['dbPrefix']}entryproperties WHERE entryid = " . (int)$entry['id'] . " AND property LIKE 'ep_cache_%'");
$addData = array('from' => 'serendipity_event_entryproperties:updateCache');
serendipity_plugin_api::hook_event('frontend_display', $entry, $addData);
serendipity_db_query("INSERT INTO {$serendipity['dbPrefix']}entryproperties (entryid, property, value) VALUES (" . (int)$entry['id'] . ", 'ep_cache_body', '" . serendipity_db_escape_string($entry['body']) . "')");
serendipity_db_query("INSERT INTO {$serendipity['dbPrefix']}entryproperties (entryid, property, value) VALUES (" . (int)$entry['id'] . ", 'ep_cache_extended', '" . serendipity_db_escape_string($entry['extended']) . "')");
}
function getSupportedProperties() {
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', 'entrypassword');
$fields = explode(',', trim($this->get_config('customfields')));
if (is_array($fields) && count($fields) > 0) {
foreach($fields AS $field) {
$field = trim($field);
if (!empty($field)) {
$supported_properties[] = $field;
}
}
}
}
return $supported_properties;
}
function returnQueryCondition($is_cache) {
$and = '';
if (!$is_cache) {
$and = " AND property NOT LIKE 'ep_cache_%' ";
}
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;
if (is_array($prop_val)) {
$prop_val = ";" . implode(';', $prop_val) . ";";
}
$q = "DELETE FROM {$serendipity['dbPrefix']}entryproperties WHERE entryid = " . (int)$eventData['id'] . " AND property = '" . serendipity_db_escape_string($prop_key) . "'";
serendipity_db_query($q);
if (!empty($prop_val)) {
$q = "INSERT INTO {$serendipity['dbPrefix']}entryproperties (entryid, property, value) VALUES (" . (int)$eventData['id'] . ", '" . serendipity_db_escape_string($prop_key) . "', '" . serendipity_db_escape_string($prop_val) . "')";
serendipity_db_query($q);
}
}
}
function showPasswordform() {
global $serendipity;
$url = serendipity_currentURL(true);
$out = '
';
return $out;
}
function showBackend($element, $is_sticky, $no_frontpage, $hiderss, $access_values, $access, $password, $use_groups, $access_groups, $use_users, $access_users, $more = array()) {
global $serendipity;
switch($element) {
case 'sticky':
?>
/>
/>
:
$radio_value) {
?>
/>
:
' . GROUP . ''; ?>