<?php

class SimplePrivatePosts extends Plugin
{

	public function action_plugin_activation()
	{
		ACL::create_token('private', 'Permissions on posts marked as "private"');

		// Deny the anonymous group access to the private token, if the group hasn't been removed (why would you remove it ??)
		$anon = UserGroup::get('anonymous');
		if ( false != $anon ) {
			$anon->deny('private');
		}
	}

	public function action_plugin_deactivation( $plugin_file )
	{
		if ( Plugins::id_from_file(__FILE__) == Plugins::id_from_file($plugin_file) ) {
			ACL::destroy_token('private');
		}
	}

	public function action_form_publish($form, $post)
	{
		if ( $post->content_type == Post::type('entry') ) {
			$form->settings->append('checkbox', 'private_post', 'null:null', _t('Private Post'), 'tabcontrol_checkbox');
			if ( $post->has_tokens('private') ) {
				$form->private_post->value = true;
			}
		}
	}

	public function action_publish_post($post, $form)
	{
		if ( $post->content_type == Post::type('entry') ) {
			if ( $form->private_post->value == true ) {
				$post->add_tokens('private');
			}
			else {
				$post->remove_tokens('private');
			}
		}
	}

}
?>
<?php

class SimplePrivatePosts extends Plugin
{

	public function action_plugin_activation()
	{
		ACL::create_token('private', 'Permission to read posts marked as "private"', 'Private Posts');

		// Deny the anonymous group access to the private token, if the group hasn't been removed (why would you remove it ??)
		$anon = UserGroup::get('anonymous');
		if ( false != $anon ) {
			$anon->deny('private');
		}
	}

	public function action_plugin_deactivation( $plugin_file )
	{
		if ( Plugins::id_from_file(__FILE__) == Plugins::id_from_file($plugin_file) ) {
			ACL::destroy_token('private');
		}
	}

	public function action_form_publish($form, $post)
	{
		if ( $post->content_type == Post::type('entry') ) {
			$form->settings->append('checkbox', 'private_post', 'null:null', _t('Private Post'), 'tabcontrol_checkbox');
			if ( $post->has_tokens('private') ) {
				$form->private_post->value = true;
			}
		}
	}

	public function action_publish_post($post, $form)
	{
		if ( $post->content_type == Post::type('entry') ) {
			if ( $form->private_post->value == true ) {
				$post->add_tokens('private');
			}
			else {
				$post->remove_tokens('private');
			}
		}
	}

}
?>

Add the required group when creating the token. Clarify the description text.
Add the required group when creating the token. Clarify the description text.

git-svn-id: d0e296eae3c99886147898d36662a67893ae90b2@4019 653ae4dd-d31e-0410-96ef-6bf7bf53c507
