<?php
/*
OsShare v1 ,
Coded By Paimpozhil B. , SaravanaKumar M.S.
*/
class VcommentsController extends AppController {
var $name = 'Vcomments';
var $helpers = array('Html', 'Form' ,'javascript','ajax', 'time');
var $uses= array('Vcomment','Video','Sitesetting');
function index() {
$this->Vcomment->recursive = 0;
$this->set('vcomments', $this->paginate());
}
function view($id = null) {
if(!$id) {
$this->Session->setFlash('Invalid Vcomment.');
$this->redirect(array('action'=>'index'), null, true);
}
$this->set('vcomment', $this->Vcomment->read(null, $id));
}
function add() {
if(!empty($this->data)) {
$this->cleanUpFields();
$this->Vcomment->create();
if($this->Vcomment->save($this->data)) {
$this->Session->setFlash('The Vcomment has been saved');
$this->redirect(array('action'=>'index'), null, true);
} else {
$this->Session->setFlash('The Vcomment could not be saved. Please, try again.');
}
}
$videos = $this->Vcomment->Video->find('list');
$this->set(compact('videos'));
}
function edit($id = null) {
if(!$id && empty($this->data)) {
$this->Session->setFlash('Invalid Vcomment');
$this->redirect(array('action'=>'index'), null, true);
}
if(!empty($this->data)) {
$this->cleanUpFields();
if($this->Vcomment->save($this->data)) {
$this->Session->setFlash('The Vcomment saved');
$this->redirect(array('action'=>'index'), null, true);
} else {
$this->Session->setFlash('The Vcomment could not be saved. Please, try again.');
}
}
if(empty($this->data)) {
$this->data = $this->Vcomment->read(null, $id);
}
$videos = $this->Vcomment->Video->find('list');
$this->set(compact('videos'));
}
function delete($id = null) {
if(!$id) {
$this->Session->setFlash('Invalid id for Vcomment');
$this->redirect(array('action'=>'index'), null, true);
}
if($this->Vcomment->del($id)) {
$this->Session->setFlash('Vcomment #'.$id.' deleted');
$this->redirect(array('action'=>'index'), null, true);
}
}
function abuse($id = null) {
if(!$id) {
$this->Session->setFlash('Invalid id for Vcomment');
$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->Vcomment->findbyid($id);
$comment["Vcomment"]["abusepoints"] += $abval;
$this->Vcomment->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('vcomments',$this->Vcomment->findallbyvideo_id($id));
$this->set('video', $this->Video->read(null, $id));
$this->set('user',$data);
$this->layout= false;
Configure::write('debug', '0');
}
}
?>