Location: PHPKode > projects > OSShare > osshare-project-v1.0.1/app/controllers/ads_controller.php
<?php
/*
OsShare v1 , 
Coded By Paimpozhil B. , SaravanaKumar M.S.
*/
class AdsController extends AppController {

	var $name = 'Ads';
	var $helpers = array('Html', 'Form' );
	var $layout = "admin";
	var $uses = array('Ad');

	function index() {

		$this->Ad->recursive = 0;
		$this->set('adlist', $this->paginate());
	}

	function view($id = null) {
		if(!$id) {
			$this->Session->setFlash('Invalid Ad.');
			$this->redirect(array('action'=>'index'), null, true);
		}
		$this->set('ad', $this->Ad->read(null, $id));
		$this->set('adcode',htmlspecialchars('<?php echo $ads[' .  $id . ']; ?>'));
	}

	function add() {
		if(!empty($this->data)) {
			$this->cleanUpFields();
			$this->Ad->create();
			if($this->Ad->save($this->data)) {
				$this->Session->setFlash('The Ad has been saved');
				$this->redirect(array('action'=>'index'), null, true);
			} else {
				$this->Session->setFlash('The Ad could not be saved. Please, try again.');
			}
		}
	}

	function edit($id = null) {
		if(!$id && empty($this->data)) {
			$this->Session->setFlash('Invalid Ad');
			$this->redirect(array('action'=>'index'), null, true);
		}
		if(!empty($this->data)) {
			$this->cleanUpFields();
			if($this->Ad->save($this->data)) {
				$this->Session->setFlash('The Ad saved');
				$this->redirect(array('action'=>'index'), null, true);
			} else {
				$this->Session->setFlash('The Ad could not be saved. Please, try again.');
			}
		}
		if(empty($this->data)) {
			$this->data = $this->Ad->read(null, $id);
		}
	}

	function delete($id = null) {
		if(!$id) {
			$this->Session->setFlash('Invalid id for Ad');
			$this->redirect(array('action'=>'index'), null, true);
		}
		if($this->Ad->del($id)) {
			$this->Session->setFlash('Ad #'.$id.' deleted');
			$this->redirect(array('action'=>'index'), null, true);
		}
	}

}
?>
Return current item: OSShare