<commit_before><?php

	Class extension_noediting extends Extension{

		public function about(){
			return array('name' => ' Filter: No Editing of Entries',
						 'version' => '1.0',
						 'release-date' => '2009-06-12',
						 'author' => array('name' => '<NAME>',
										   'website' => 'http://www.phoque.de/projekte/symphony',
										   'email' => '<EMAIL>'),
						 'description' => 'Allows you to prevent users from editing entries from front end forms.'
				 		);
		}
		
		public function getSubscribedDelegates(){
			return array(
						array(
							'page' => '/blueprints/events/new/',
							'delegate' => 'AppendEventFilter',
							'callback' => 'addFilterToEventEditor'
						),
						
						array(
							'page' => '/blueprints/events/edit/',
							'delegate' => 'AppendEventFilter',
							'callback' => 'addFilterToEventEditor'
						),
						
						array(
							'page' => '/blueprints/events/new/',
							'delegate' => 'AppendEventFilterDocumentation',
							'callback' => 'addFilterDocumentationToEvent'
						),
											
						array(
							'page' => '/blueprints/events/edit/',
							'delegate' => 'AppendEventFilterDocumentation',
							'callback' => 'addFilterDocumentationToEvent'
						),
						
						array(
							'page' => '/frontend/',
							'delegate' => 'EventPreSaveFilter',
							'callback' => 'processEventData'
						),						
			);
		}
		
		public function addFilterToEventEditor($context){
			$context['options'][] = array('no-editing', @in_array('no-editing', $context['selected']) ,'No Editing of Entries');		
		}
		
		public function addFilterDocumentationToEvent($context){
			if(!in_array('no-editing', $context['selected'])) return;
			
			$context['documentation'][] = new XMLElement('h3', 'Prevent Editing');
			
			$context['documentation'][] = new XMLElement('p', 'Prevents users from supplying an entry ID to edit entries like so:');
			$code = '<input name="id" type="hidden" value="23" />';

			$context['documentation'][] = contentBlueprintsEvents::processDocumentationCode($code);
			
			$context['documentation'][] = new XMLElement('p', 'If your forms are using a line like this, saving entries will always fail.');
			
			$context['documentation'][] = new XMLElement('p', 'The following is an example of the XML returned form this filter:');
			$code = '<filter name="no-editing" status="passed" />
<filter name="no-editing" status="failed">You are not allowed to edit entries.</filter>';

			$context['documentation'][] = contentBlueprintsEvents::processDocumentationCode($code);
			
		}
		
		public function processEventData($context){
			
			if(!in_array('no-editing', $context['event']->eParamFILTERS)) return;
			
			if(isset($_POST['id'])) {
				$context['messages'][] = array('no-editing', false, 'You are not allowed to edit entries.');
			}
			
		}
		
		public function uninstall(){
			return true;
		}
		
	}
<commit_msg>Documentation cleaned up<commit_after><?php

	Class extension_noediting extends Extension{

		public function about(){
			return array('name' => ' Filter: No Editing of Entries',
						 'version' => '1.0',
						 'release-date' => '2009-06-12',
						 'author' => array('name' => '<NAME>',
										   'website' => 'http://www.phoque.de/projekte/symphony',
										   'email' => '<EMAIL>'),
						 'description' => 'Allows you to prevent users from editing entries from front end forms.'
				 		);
		}
		
		public function getSubscribedDelegates(){
			return array(
						array(
							'page' => '/blueprints/events/new/',
							'delegate' => 'AppendEventFilter',
							'callback' => 'addFilterToEventEditor'
						),
						
						array(
							'page' => '/blueprints/events/edit/',
							'delegate' => 'AppendEventFilter',
							'callback' => 'addFilterToEventEditor'
						),
						
						array(
							'page' => '/blueprints/events/new/',
							'delegate' => 'AppendEventFilterDocumentation',
							'callback' => 'addFilterDocumentationToEvent'
						),
											
						array(
							'page' => '/blueprints/events/edit/',
							'delegate' => 'AppendEventFilterDocumentation',
							'callback' => 'addFilterDocumentationToEvent'
						),
						
						array(
							'page' => '/frontend/',
							'delegate' => 'EventPreSaveFilter',
							'callback' => 'processEventData'
						),						
			);
		}
		
		public function addFilterToEventEditor($context){
			$context['options'][] = array('no-editing', @in_array('no-editing', $context['selected']) ,'No Editing of Entries');		
		}
		
		public function addFilterDocumentationToEvent($context){
			if(!in_array('no-editing', $context['selected'])) return;
			
			$context['documentation'][] = new XMLElement('h3', 'Prevent Editing');
			
			$context['documentation'][] = new XMLElement('p', 'Prevents users from supplying an entry ID to edit entries like so:');
			$code = '<input name="id" type="hidden" value="23" />';

			$context['documentation'][] = contentBlueprintsEvents::processDocumentationCode($code);
			
			$context['documentation'][] = new XMLElement('p', 'The following is an example of the XML returned form this filter:');
			$code = '<filter name="no-editing" status="passed" />
					<filter name="no-editing" status="failed">You are not allowed to edit entries.</filter>';

			$context['documentation'][] = contentBlueprintsEvents::processDocumentationCode($code);
			
		}
		
		public function processEventData($context){
			
			if(!in_array('no-editing', $context['event']->eParamFILTERS)) return;
			
			if(isset($_POST['id'])) {
				$context['messages'][] = array('no-editing', false, 'You are not allowed to edit entries.');
			}
			
		}
		
		public function uninstall(){
			return true;
		}
		
	}

{'fraction_non_alphanumeric': 0.1650827173530447, 'fraction_numerical': 0.0045758535726856744, 'mean_word_length': 3.1786764705882353, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 63, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7618479', 'n_tokens_mistral': 2287, 'n_tokens_neox': 1650, 'n_words': 369}