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

	function index() {
		$data = $this->dolayout();
		$usid = $data["id"];
		$playnames = $this->Alb->findallbyuser_id($usid);
		$this->set('alb', $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->Alb->create();
			//$data = $this->Session->read('User');
			if($this->Alb->save($this->data))
			{
				$this->Session->setFlash('Album 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('alb', $this->Alb->read(null, $id));
	}
	
	
	function userview($id = null,$usid = null) {
	
		$albumnames = $this->Alb->findallbyuser_id($id);
		$this->set('albs', $albumnames);
		
		
	}
	
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->Alb->save($this->data)) {
				$this->Session->setFlash('The Album saved');
				$this->redirect(array('action'=>'index'), null, true);
			} else {
				$this->Session->setFlash('The Album could not be saved. Please, try again.');
			}
		}
		if(empty($this->data)) {
			$this->data = $this->Alb->read(null, $id);
		}
	}
	
	function delete($id = null) {
		$data = $this->dolayout();
		$usid = $data["id"];
		$check_del = $this->Alb->findbyid($id);
		if($check_del["Alb"]["user_id"] != $usid)
		{
			$this->Session->setFlash('Invalid Id');
			$this->redirect(array('action'=>'index'), null, true);
		}
		if($this->Alb->del($id)) {
			$this->Session->setFlash('Album #'.$id.' deleted');
			$this->redirect(array('action'=>'index'), null, true);
		}
	}

}	
	
?>
Return current item: OSShare