add('name', PLUGIN_SIDEBAR_HIDER_NAME); $propbag->add('description', PLUGIN_SIDEBAR_HIDER_DESC); $propbag->add('stackable', false); $propbag->add('author', 'Tys von Gaza, Garvin Hicking'); $propbag->add('version', '1.24'); $propbag->add('requirements', array( 'serendipity' => '0.9', 'php' => '4.1.0' )); $propbag->add('event_hooks', array( 'external_plugin' => true, 'frontend_header' => true, 'css' => true, 'backend_sidebar_entries' => true, 'backend_sidebar_entries_event_display_sidebarhider' => true, 'frontend_generate_plugins' => true )); $propbag->add('groups', array('BACKEND_TEMPLATES')); $propbag->add('configuration', array('enable', 'style_sidebar_hidden','style_title_hidden','style_link','html_link_visible','html_link_hidden','plugin_list')); } function introspect_config_item($name, &$propbag) { global $serendipity; switch($name) { case 'enable': $propbag->add('type', 'boolean'); $propbag->add('name', PLUGIN_SIDEBAR_HIDER_NAME); $propbag->add('description', ''); $propbag->add('default', true); break; case 'style_sidebar_hidden': $propbag->add('type', 'string'); $propbag->add('name', PLUGIN_SIDEBAR_HIDER_STYLE_SIDEBAR); $propbag->add('description', PLUGIN_SIDEBAR_HIDER_STYLE_SIDEBAR_DESC); $propbag->add('default', ''); break; case 'style_title_hidden': $propbag->add('type', 'string'); $propbag->add('name', PLUGIN_SIDEBAR_HIDER_STYLE_TITLE); $propbag->add('description', PLUGIN_SIDEBAR_HIDER_STYLE_TITLE_DESC); $propbag->add('default', ''); break; case 'style_link': $propbag->add('type', 'string'); $propbag->add('name', PLUGIN_SIDEBAR_HIDER_STYLE_LINK); $propbag->add('description', PLUGIN_SIDEBAR_HIDER_STYLE_LINK_DESC); $propbag->add('default','text-decoration:none;float:right;margin-right:3px;'); break; case 'html_link_visible': $propbag->add('type', 'string'); $propbag->add('name', PLUGIN_SIDEBAR_HIDER_LINK_VISIBLE); $propbag->add('description', PLUGIN_SIDEBAR_HIDER_LINK_VISIBLE_DESC); $propbag->add('default','-'); break; case 'html_link_hidden': $propbag->add('type', 'string'); $propbag->add('name', PLUGIN_SIDEBAR_HIDER_LINK_HIDDEN); $propbag->add('description', PLUGIN_SIDEBAR_HIDER_LINK_HIDDEN_DESC); $propbag->add('default','+'); break; default: return false; } return true; } function event_hook($event, &$bag, &$eventData, $addData = null) { global $serendipity; $hooks = &$bag->get('event_hooks'); $enabled = serendipity_db_bool($this->get_config('enable')); if (isset($hooks[$event])) { switch($event) { case 'frontend_generate_plugins': // This is the event that actually displays the plugins on your blog $plugins =& $eventData; $view_list = unserialize($this->get_config('view_list')); if (!is_array($view_list)) { $view_list = array(); } $category_viewlist = unserialize($this->get_config('category_view_list')); if (!is_array($category_viewlist)) { $category_viewlist = array(); } $usergroups_viewlist = unserialize($this->get_config('usergroups_view_list')); if (!is_array($usergroups_viewlist)) { $usergroups_viewlist = array(); $mygroups = array(); } else { $mygroups = serendipity_getGroups($serendipity['authorid']); } foreach ($plugins as $idx => $plugin_data) { // First eliminate plugins that don't fit the member restrictions if ($view_list[$plugin_data['name']] == 'member' && !$_SESSION['serendipityAuthedUser']) { unset($plugins[$idx]); } elseif (is_numeric($view_list[$plugin_data['name']]) && $serendipity['authorid'] != $view_list[$plugin_data['name']]) { unset($plugins[$idx]); } // if $view_list[plugin_name] is "everyone", we don't need to hide it. (--JAM: 2005-10-18) // Now eliminate remaining plugins that don't fit the category restrictions (--JAM: 2005-10-18; was else for above) if (isset($plugins[$idx]) ) { if ($category_viewlist[$plugin_data['name']] != '') { //--JAM: 2005-10-18 allows non-numeric category specifiers $selected = @explode(',', $category_viewlist[$plugin_data['name']]); // Some category restrictions were specified. Do we meet the restrictions? if (isset($serendipity['GET']['category']) && !in_array($serendipity['GET']['category'], $selected)) { // We're in a category, and it's not in the selected list unset($plugins[$idx]); } else if (isset($serendipity['GET']['id']) && isset($GLOBALS['entry']) && isset($GLOBALS['entry'][0]['categories'])) { $found = false; foreach($GLOBALS['entry'][0]['categories'] AS $cid => $cat) { if (in_array($cat['categoryid'], $selected)) { $found = true; break; } } if (!$found) { unset($plugins[$idx]); } } else if (!isset($serendipity['GET']['category']) && !in_array(PLUGIN_SIDEBAR_HIDER_FRONTPAGE_ID, $selected)) { // (--JAM: 2005-10-18) // We're on the front/overview page, it's not in the selected list unset($plugins[$idx]); } } if ($usergroups_viewlist[$plugin_data['name']] != '') { $selected = @explode(',', $usergroups_viewlist[$plugin_data['name']]); // Check if any of the allowed groups are inside the array $mygroup which contains the valid groups of the current author $found = false; foreach($mygroups AS $mygroup) { if ($found) continue; if (in_array($mygroup['id'], $selected)) { $found = true; } } if (!$found) { unset($plugins[$idx]); } } } } return true; break; case 'backend_sidebar_entries': echo '
".PLUGIN_SIDEBAR_HIDER_CONF_HIDDEN." | \n"; echo "\n"; echo " |
".PLUGIN_SIDEBAR_HIDER_CONF_EVERYONE." | \n"; echo "\n"; echo " |
".PLUGIN_SIDEBAR_HIDER_CONF_MEMBERS." | \n"; echo "\n"; echo " |
".PLUGIN_SIDEBAR_HIDER_CONF_MYSELF." | \n"; echo "\n"; echo " |
".GROUP." \n"; echo " | \n";
echo "|
".PLUGIN_SIDEBAR_HIDER_CONF_CATEGORIES." \n"; echo "\n"; $selected = explode(',', $category_viewlist[$plugin->instance]); echo " | \n";
echo "