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

	var $name = 'Picture';
	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_corrupted' => 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(
			'Prating' => array('className' => 'Prating',
								'foreignKey' => 'picture_id',
								 'dependent'    =>  true,
								) ,
			'Pfavorite' => array('className' => 'pfavorite',
								'foreignKey' => 'picture_id',
								 'dependent'    =>  true,
								),
			'Pcomment' => array('className' => 'Pcomment',
								'foreignKey' => 'picture_id',
								 'dependent'    =>  true,
								),
			'Albitem' => array('className' => 'Albitem',
								'foreignKey' => 'picture_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 prating($id)
	{
			return $this->Prating->find("`Prating`.`picture_id` = " . $id,array("Avg(`Prating`.`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