Location: PHPKode > projects > OSShare > osshare-project-v1.0.1/app/controllers/pls_controller.php
<?php
/*
OsShare v1 , 
Coded By Paimpozhil B. , SaravanaKumar M.S.
*/
class PlsController extends AppController {
	var $layout = 'user';
	var $name = 'Pls';
	var $helpers = array('Html', 'Form','Javascript','ajax','Pagination' ,'Time');
	var $uses= array('Pl','User','Sitesetting');
	var $components = array ('Pagination');

	function index() {
		$data = $this->dolayout();
		$usid = $data["id"];
		$playnames = $this->Pl->findallbyuser_id($usid);
		$this->set('pls', $playnames);
	}
	
	function add($id=null) {
		$data = $this->dolayout();
		$usid = $data["id"];
		 $this->set('usid',$usid);
		if(!$usid) 
			$this->Session->setFlash('Invalid User');
		if(!empty($this->data)) {
			$this->cleanUpFields();
			$this->Pl->create();
			//$data = $this->Session->read('User');
			if($this->Pl->save($this->data))
			{
				$this->Session->setFlash('Play List Added');
				$this->redirect(array('action'=>'index'));	
			}
		}	
		
	}
		
	function view($id = null) {
		if(!$id) {
			$this->Session->setFlash('Invalid Playlist.');
			$this->redirect(array('action'=>'index'), null, true);
		}
		$this->set('pl', $this->Pl->read(null, $id));
	}
	
	function userview($id = null,$usid = null) {
	
		$playnames = $this->Pl->findallbyuser_id($id);
		$this->set('pls', $playnames);
		
		
	}
	
function edit($id = null) {
		$data = $this->dolayout();
		$usid = $data["id"];
		 $this->set('usid',$usid);
		 $this->set('id',$id);
		if(!$id && empty($this->data)) {
			$this->Session->setFlash('Invalid Slaveserver');
			$this->redirect(array('action'=>'index'), null, true);
		}
		if(!empty($this->data)) {
			$this->cleanUpFields();
			if($this->Pl->save($this->data)) {
				$this->Session->setFlash('The Playlist saved');
				$this->redirect(array('action'=>'index'), null, true);
			} else {
				$this->Session->setFlash('The Playlist could not be saved. Please, try again.');
			}
		}
		if(empty($this->data)) {
			$this->data = $this->Pl->read(null, $id);
		}
	}
	
	function delete($id = null) {
		$data = $this->dolayout();
		$usid = $data["id"];
		$check_del = $this->Pl->findbyid($id);
		if($check_del["Pl"]["user_id"] != $usid)
		{
			$this->Session->setFlash('Invalid Id');
			$this->redirect(array('action'=>'index'), null, true);
		}
		if($this->Pl->del($id)) {
			$this->Session->setFlash('Playlist #'.$id.' deleted');
			$this->redirect(array('action'=>'index'), null, true);
		}
	}

}	
	
?>
Return current item: OSShare