Location: PHPKode > projects > OSShare > osshare-project-v1.0.1/app/models/video.php
<?php
/*
OsShare v1 , 
Coded By Paimpozhil B. , SaravanaKumar M.S.
*/
class Video extends AppModel {

	var $name = 'Video';
	var $validate = array(
		'id' => VALID_NUMBER,
		'created' => VALID_NOT_EMPTY,
		'updated' => VALID_NOT_EMPTY,
		'path' => VALID_NOT_EMPTY,
		'name' => VALID_NOT_EMPTY,
		'fspath' => VALID_NOT_EMPTY,
		'type' => VALID_NOT_EMPTY,
		'size' => VALID_NOT_EMPTY,
		'deleted' => VALID_NOT_EMPTY,
		'comment' => VALID_NOT_EMPTY,
		'is_encoded' => VALID_NOT_EMPTY,
		'can_comment' => VALID_NOT_EMPTY,
		'thmbnailpath' => VALID_NOT_EMPTY,
		'category_id' => VALID_NUMBER,
		'user_id' => VALID_NUMBER,
	);
	  function findByPath ($path, $name) {
        return $this->find("name = '$name' and path = '$path'");
    } 
	//The Associations below have been created with all possible keys, those that are not needed can be removed
	
		
	var $hasMany = array(
			'Rating' => array('className' => 'Rating',
								'foreignKey' => 'video_id',
								 'dependent'    =>  true,
								) ,
			'Favorite' => array('className' => 'Favorite',
								'foreignKey' => 'video_id',
								 'dependent'    =>  true,
								),
			'Vcomment' => array('className' => 'Vcomment',
								'foreignKey' => 'video_id',
								 'dependent'    =>  true,
								),
			'Plsitem' => array('className' => 'Plsitem',
								'foreignKey' => 'video_id',
								 'dependent'    =>  true,
								)
			
					
		);
								
	var $belongsTo = array(
			'Category' => array('className' => 'Category',
								'foreignKey' => 'category_id',
								'conditions' => '',
								'fields' => '',
								'order' => '',
								'counterCache' => ''),
			'User' => array('className' => 'User',
								'foreignKey' => 'user_id',
								'conditions' => '',
								'fields' => '',
								'order' => '',
								'counterCache' => ''),
	);
	

								
								
	function vrating($id)
	{
			return $this->Rating->find("`Rating`.`video_id` = " . $id,array("Avg(`Rating`.`rating`) as average") );
	}
	
/*	function beforeFind(&$queryData)
	{
		if(is_array($queryData["conditions"]))
		$queryData["conditions"]["`Video`.is_encoded"] = 1;
		else
		{
		if ($queryData["conditions"] == "")
		$queryData["conditions"].= " ( `Video`.is_encoded = 1) ";
		else
		$queryData["conditions"].= " AND ( `Video`.is_encoded = 1) ";
		}
		//debug($queryData);
		return true;
	}*/
	
	
	

}
?>
Return current item: OSShare