<?php

/**
*
* @package Free Tube Script
* @version v1.0
* @copyright (c) 2011 Agriz
* @license GNU Public License Under Certain Conditions [Powered by should remain unchanged]
* @contact http://www.agrizlive.com
*
*/

	class SettingsController extends AppController {
		function admin_view() {
			$this->paginate = array('conditions' => array());
			$settings = $this->paginate('Setting');
			$this->set(compact('settings'));
			$this->set('path_name','settings');
		}
		
		function admin_edit($id='') {	
			if(empty($id)) {
				$this->redirect(array('controller' => 'settings','action'=>'view','admin' =>'admin'));
			}
			if(!empty($this->data)) {
				$this->Setting->set($this->data);
				if($this->Setting->validates())
				{
					$this->Setting->create();
					if($this->Setting->save($this->data)) {
						$this->Session->setFlash('Settings Editted Successfully');
					}
					else {
						$this->Session->setFlash('There is a problem in editting settings');
					}
				}
				else {
					$this->Session->setFlash('Form validation failed');
				}			
			}
			$settings = $this->data = $this->Setting->findById($id);
			$this->set(compact('settings'));
			$this->set('path_name','settings');
		}
	}
?>