<?php
/**
 * Settings context
 *
 * Instalation settings managment operations
 * @author balexandre - Advantis Solutions
 * @version 1.0.1
 * @package Backend\Languages
 */
class context_settings extends context {
	
	/**
	 * context entry point, shows settings page
	 */
	function index() {
		$em = new EntityManager ( 'languages' );
		
		$list = $em->load ();
		
		$this->screen ( "settings/index", array (
				'list' => $list 
		) );
	}
	
	/**
	 * saves settings
	 */
	function save() {
		$em = new EntityManager ( 'languages' );
		
		$list = $em->load ();
		
		foreach ( $list as $obj ) {
			
			if ($_POST ['active_' . $obj->id]) {
				
				$obj->active = 1;
			} else {
				
				$obj->active = 0;
			}
			
			$obj->save ();
		}
		
		header ( 'Location:' . __SITEBASE . '/settings' );
	}
}

?>