Location: PHPKode > projects > OSShare > osshare-project-v1.0.1/app/controllers/procomments_controller.php
<?php
/*
OsShare v1 , 
Coded By Paimpozhil B. , SaravanaKumar M.S.
*/
class ProcommentsController extends AppController {
	
	var $name = 'Procomments';
	var $helpers = array('Html', 'Form' ,'javascript','ajax', 'time');
	var $uses= array('Procomment','Profile','Sitesetting');

	function index() {
		$this->Procomment->recursive = 0;
		$this->set('Procomments', $this->paginate());
	}

	function view($id = null) {
		if(!$id) {
			$this->Session->setFlash('Invalid Procomment.');
			$this->redirect(array('action'=>'index'), null, true);
		}
		$this->set('procomment', $this->Procomment->read(null, $id));
	}

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

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

	function delete($id = null) {
		if(!$id) {
			$this->Session->setFlash('Invalid id for Procomment');
			$this->redirect(array('action'=>'index'), null, true);
		}
		
		if($this->Procomment->del($id)) {
			$this->Session->setFlash('Procomment #'.$id.' deleted');
			$this->redirect(array('action'=>'index'), null, true);
			
		}
	}
	
	function abuse($id = null) {
		if(!$id) {
			$this->Session->setFlash('Invalid id for Procomment');
			$this->redirect(array('action'=>'index'), null, true);
		}
		$data = $this->Session->read('User');
		$priv = $data["privilege"];
		if ($priv=='user')
			$abval = 1;	
		elseif ($priv =='admin')
			$abval = 5;
		elseif ($priv == 'mod')
			$abval = 3;
		$comment = $this->Procomment->findbyid($id);
		$comment["Procomment"]["abusepoints"] +=  $abval;
		$this->Procomment->save($comment);
		$this->Session->setFlash('Abuse Reported ');
		$this->redirect(array('action'=>'index'), null, true);
		
	}
	
	function partview($id=null)
	{
		$data = $this->Session->read('User');
	$this->set('procomments',$this->Procomment->findallbyprofile_id($id));
	$this->set('profile', $this->Profile->read(null, $id));
	$this->set('user',$data);
	$this->layout= false;
	 Configure::write('debug', '0');
	}
}
?>
Return current item: OSShare