Advertisement
Guest User

Video.php

a guest
Jun 21st, 2014
278
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 47.28 KB | None | 0 0
  1. <?php
  2.  
  3. /**
  4. * This is the model class for table "{{video}}".
  5. *
  6. * The followings are the available columns in table '{{video}}':
  7. * @property string $id
  8. * @property string $user_id
  9. * @property integer $video_category_id
  10. * @property string $video_kaltura_id
  11. * @property string $permissions
  12. * @property string $is_active
  13. * @property string $status_date
  14. * @property string $trailer_id
  15. * @property string $standalone_id
  16. * @property string $childmovie
  17. * @property string $view_count
  18. * @property string $trailerfrom
  19. * @property string $trailer_youtube
  20. * @property string $comment_yes
  21. * @property string $mfwpick
  22. * @property string $toprated
  23. * @property string $exclusive
  24. * @property string $adds_allow
  25. * @property string $addeddate
  26. * @property integer $sortorder
  27. * @property integer $catsort
  28. * @property integer $mfwpicksort
  29. * @property integer $topratsort
  30. * @property string $featured
  31. * @property string $admin_notes
  32. * @property string $notes_date
  33. * @property string $is_delete
  34. * @property string $kltra_partnerID
  35. * @property string $active_date
  36. *
  37. * The followings are the available model relations:
  38. * @property FilmCastAndCrew $filmCastAndCrew
  39. * @property SiteVideoPicks[] $siteVideoPicks
  40. * @property User $user
  41. * @property VideoCategories $videoCategory
  42. * @property VideoDetails $videoDetails
  43. * @property VideoFeedback[] $videoFeedbacks
  44. * @property VideoMypick[] $videoMypicks
  45. * @property VideoQueue[] $videoQueues
  46. * @property VideoRating[] $videoRatings
  47. * @property VideoawardFestival[] $videoawardFestivals
  48. */
  49. class Video extends CActiveRecord
  50. {
  51. public $video_file;
  52. public $videoDetails_search_nameoffilm;
  53. public $videoCategory_search_genus;
  54. public $filmRating_search_title;
  55. public $user_search_fullName;
  56. public $filim_id;
  57. public $videoDetails_year;
  58. public $videoRatings_user;
  59. public $videoRatings_director;
  60. public $standlonemovie;
  61. public $sumview;
  62. public $videocounts;
  63. public $language_search;
  64. public $kalturafileid;
  65. /**
  66. * Returns the static model of the specified AR class.
  67. * @param string $className active record class name.
  68. * @return Video the static model class
  69. */
  70. public static function model($className=__CLASS__)
  71. {
  72. return parent::model($className);
  73. }
  74.  
  75. /**
  76. * @return string the associated database table name
  77. */
  78. public function tableName()
  79. {
  80. return '{{video}}';
  81. }
  82.  
  83. /**
  84. * @return array validation rules for model attributes.
  85. */
  86. public function rules()
  87. {
  88. // NOTE: you should only define rules for those attributes that
  89. // will receive user inputs.
  90. return array(
  91. array('user_id, video_category_id', 'required'),//, video_kaltura_id
  92. array('video_category_id, sortorder, catsort, mfwpicksort, topratsort', 'numerical', 'integerOnly'=>true),
  93. array('user_id, childmovie, view_count', 'length', 'max'=>20),
  94. //array('video_file', 'file'),
  95. array('kltra_partnerID', 'length', 'max'=>30),
  96. array('video_kaltura_id, permissions, trailer_id', 'length', 'max'=>255),
  97. array('is_active, featured, is_delete, standalone_id, trailerfrom, comment_yes, mfwpick, toprated, exclusive, adds_allow', 'length', 'max'=>1),
  98. array('status_date, trailer_youtube, addeddate, standlonemovie, admin_notes, notes_date, active_date', 'safe'),
  99. // The following rule is used by search().
  100. // Please remove those attributes that should not be searched.
  101. array('id, user_id, video_category_id, video_kaltura_id, permissions, is_active, status_date, featured, is_delete, trailer_id, standalone_id, childmovie, view_count, trailerfrom, trailer_youtube, comment_yes, mfwpick, toprated, exclusive, adds_allow, addeddate, sortorder, videoDetails_search_nameoffilm, videoCategory_search_genus, videoRatings_user, videoRatings_director, user_search_fullName, videoDetails_year, catsort, mfwpicksort, topratsort, language_search', 'safe', 'on'=>'search'),
  102. array('id, user_id, video_category_id, video_kaltura_id, is_active, featured, view_count, mfwpick, toprated, exclusive, adds_allow, addeddate, videoDetails_search_nameoffilm, videoCategory_search_genus, user_search_fullName, videoDetails_year, language_search, active_date', 'safe', 'on'=>'activelist'),
  103.  
  104. array('id, user_id, video_category_id, video_kaltura_id, is_active, status_date, featured, is_delete, view_count, mfwpick, toprated, exclusive, adds_allow, addeddate, sortorder, mfwpicksort, videoDetails_search_nameoffilm, videoCategory_search_genus, user_search_fullName, videoDetails_year, videoRatings_user, videoRatings_director', 'safe', 'on'=>'searchmypic'),
  105. array('id, user_id, video_category_id, video_kaltura_id, is_active, status_date, featured, is_delete, view_count, mfwpick, toprated, exclusive, adds_allow, addeddate, sortorder, videoDetails_search_nameoffilm, videoCategory_search_genus, user_search_fullName, videoDetails_year, topratsort, videoRatings_user, videoRatings_director', 'safe', 'on'=>'searchtoprated'),
  106. array('childmovie, childmovie', 'required', 'on'=>'relation'),
  107. array('childmovie, filim_id', 'required', 'on'=>'relation'),
  108.  
  109. array('id, user_id, video_category_id, video_kaltura_id, is_active, videoDetails_search_nameoffilm, videoCategory_search_genus, user_search_fullName, videoDetails_year, catsort, view_count, videoDetails_year, videoRatings_user, videoRatings_director', 'safe', 'on'=>'searchsort'),
  110.  
  111. );
  112. }
  113.  
  114. /**
  115. * @return array relational rules.
  116. */
  117. public function relations()
  118. {
  119. // NOTE: you may need to adjust the relation name and the related
  120. // class name for the relations automatically generated below.
  121. return array(
  122. 'filmCastAndCrew' => array(self::HAS_ONE, 'FilmCastAndCrew', 'video_id'),
  123. 'siteVideoPicks' => array(self::HAS_MANY, 'SiteVideoPicks', 'video_id'),
  124. 'user' => array(self::BELONGS_TO, 'User', 'user_id'),
  125. 'videoCategory' => array(self::BELONGS_TO, 'VideoCategories', 'video_category_id'),
  126. 'videoDetails' => array(self::HAS_ONE, 'VideoDetails', 'video_id'),
  127. 'videoFeedbacks' => array(self::HAS_MANY, 'VideoFeedback', 'video_id'),
  128. 'videoMypicks' => array(self::HAS_MANY, 'VideoMypick', 'video_id'),
  129. 'videoQueues' => array(self::HAS_MANY, 'VideoQueue', 'video_id'),
  130. 'videoRatings' => array(self::HAS_MANY, 'VideoRating', 'video_id'),
  131. 'videoawardFestivals' => array(self::HAS_MANY, 'VideoawardFestival', 'video_id'),
  132. );
  133. }
  134.  
  135. /**
  136. * @return array customized attribute labels (name=>label)
  137. */
  138. public function attributeLabels()
  139. {
  140. return array(
  141. 'id' => 'ID',
  142. 'user_id' => 'Director Name',
  143. 'video_category_id' => 'Genus',
  144. 'video_file' => 'Choose Video File',
  145. 'video_kaltura_id' => 'Video file',
  146. 'permissions' => 'Permissions',
  147. 'is_active' => 'Status',
  148. 'videoDetails_search_nameoffilm'=>'Name of Film',
  149. 'videoCategory_search_genus'=>'Genus',
  150. 'filmRating_search_title'=>'Film Rating',
  151. 'user_search_fullName'=>'Director',
  152. 'trailer_id' => 'Trailer',
  153. 'standalone_id' => 'Part of Series',
  154. 'filim_id' => 'Filim',
  155. 'childmovie' => 'Name of Series',
  156. 'view_count' => 'No. of views',
  157. 'trailerfrom' => 'Trailer',
  158. 'trailer_youtube' => 'Embedded code',
  159. 'comment_yes' => 'Publish comments',
  160. 'mfwpick' => 'MFW pick',
  161. 'toprated' => 'Top Rated',
  162. 'exclusive' => 'Exclusive with MFW',
  163. 'adds_allow' => 'Ads',
  164. 'addeddate' => 'Created Date',
  165. 'sortorder' =>'Sort Order',
  166. 'is_delete' => 'Delete',
  167. 'videoDetails_year'=>'Year of Release',
  168. 'videoRatings_user'=>'Viewer Rating',
  169. 'videoRatings_director'=>'Director`s Rating',
  170. 'featured' => 'Featured',
  171. 'catsort' => 'Sort',
  172. 'mfwpicksort'=>'Sort',
  173. 'topratsort'=>'Sort',
  174. 'notes_date' =>'Admin Notes Date',
  175. 'kltra_partnerID' => 'Kaltura Partner Id',
  176. 'active_date' => 'Active Date',
  177. 'language_search'=>'Language',
  178. 'kalturafileid' => 'Kaltura Video Id',
  179. );
  180. }
  181.  
  182. /**
  183. * Retrieves a list of models based on the current search/filter conditions.
  184. * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
  185. */
  186. // $criteria->compare('trailer_id',$this->trailer_id,true);
  187. // $criteria->compare('standalone_id',$this->standalone_id,true);
  188. public function search()
  189. {
  190. // Warning: Please modify the following code to remove attributes that
  191. // should not be searched.
  192. $criteria=new CDbCriteria;
  193. $criteria->with = array('videoDetails'=>array('with'=>array('filmRating','originalLang')),'user','videoCategory','videoawardFestivals','filmCastAndCrew');
  194. $criteria->compare('t.id',$this->id,true);
  195. $criteria->compare('user_id',$this->user_id,true);
  196. $criteria->compare('video_category_id',$this->video_category_id);
  197. $criteria->compare('video_kaltura_id',$this->video_kaltura_id,true);
  198. $criteria->compare('permissions',$this->permissions,true);
  199. $criteria->compare('t.is_active',$this->is_active,true);
  200. $criteria->compare('t.trailer_id',$this->trailer_id,true);
  201. $criteria->compare('t.standalone_id',$this->standalone_id,true);
  202. $criteria->compare('t.childmovie',$this->childmovie,true);
  203. $criteria->compare('t.view_count',$this->view_count,true);
  204. $criteria->compare('t.trailerfrom',$this->trailerfrom,true);
  205. $criteria->compare('t.trailer_youtube',$this->trailer_youtube,true);
  206. $criteria->compare('t.comment_yes',$this->comment_yes,true);
  207. $criteria->compare('t.mfwpick',$this->mfwpick,true);
  208. $criteria->compare('t.toprated',$this->toprated,true);
  209. $criteria->compare('t.exclusive',$this->exclusive,true);
  210. $criteria->compare('t.adds_allow',$this->adds_allow,true);
  211. $criteria->compare('t.addeddate',$this->addeddate,true);
  212. $criteria->compare('t.sortorder',$this->sortorder);
  213. $criteria->compare('t.featured',$this->featured,true);
  214. $criteria->compare('originalLang.title',$this->language_search,true);
  215. $criteria->compare('catsort',$this->catsort);
  216. //$criteria->compare('mfwpicksort',$this->mfwpicksort);
  217. //$criteria->compare('topratsort',$this->topratsort);
  218. $criteria->compare('t.is_delete','N',true);
  219.  
  220. $post_table = VideoRating::model()->tableName();
  221. $post_count_sql = "(select AVG(rating) from $post_table where $post_table.is_active = 'Y' AND $post_table.user_id in (select id from {{user}} where is_active !='N' AND is_active !='S' AND is_active !='D' AND type_id= 2 ) AND $post_table.video_id = t.id)";
  222. $post_count_sql1 = "(select AVG(rating) from $post_table where $post_table.is_active = 'Y' AND $post_table.user_id in (select id from {{user}} where is_active !='N' AND is_active !='S' AND is_active !='D' AND type_id= 1 ) AND $post_table.video_id = t.id)";
  223. $criteria->select = array('*', $post_count_sql1 . " as videoRatings_user", $post_count_sql . " as videoRatings_director");
  224. $criteria->compare($post_count_sql1, $this->videoRatings_user);
  225. $criteria->compare($post_count_sql, $this->videoRatings_director);
  226.  
  227. $criteria->compare('videoDetails.name_of_film',$this->videoDetails_search_nameoffilm,true);
  228. $criteria->compare('videoDetails.year_make',$this->videoDetails_year,true);
  229. $criteria->compare('videoCategory.id',$this->videoCategory_search_genus);
  230. //$criteria->compare('filmRating.id',$this->filmRating_search_title,true);
  231. $criteria->compare('user.first_name',$this->user_search_fullName,true);
  232. $criteria->compare('user.last_name',$this->user_search_fullName,true,'OR');
  233. $criteria->compare('user.first_name',explode(' ',$this->user_search_fullName),true,'OR');
  234. $criteria->compare('user.last_name',explode(' ',$this->user_search_fullName),true,'OR');
  235.  
  236. //$criteria->order = 't.id DESC';
  237. return new CActiveDataProvider($this, array(
  238. 'criteria'=>$criteria,
  239. 'pagination'=>false,
  240. 'sort'=>array(
  241. 'defaultOrder'=>'t.id DESC',
  242. 'attributes'=>array(
  243. 'videoDetails_search_nameoffilm'=>array(
  244. 'asc'=>'videoDetails.name_of_film',
  245. 'desc'=>'videoDetails.name_of_film DESC',
  246. ),
  247. 'videoCategory_search_genus'=>array(
  248. 'asc'=>'videoCategory.id',
  249. 'desc'=>'videoCategory.id DESC',
  250. ),
  251. /*'filmRating_search_title'=>array(
  252. 'asc'=>'filmRating.id',
  253. 'desc'=>'filmRating.id DESC',
  254. ),*/
  255. 'user_search_fullName'=>array(
  256. 'asc'=>'user.first_name',
  257. 'desc'=>'user.first_name DESC',
  258. ),
  259. 'videoDetails_year'=>array(
  260. 'asc'=>'videoDetails.year_make',
  261. 'desc'=>'videoDetails.year_make DESC',
  262. ),
  263. 'videoRatings_user'=>array(
  264. 'asc'=>'videoRatings_user',
  265. 'desc'=>'videoRatings_user DESC',
  266. ),
  267. 'videoRatings_director'=>array(
  268. 'asc'=>'videoRatings_director',
  269. 'desc'=>'videoRatings_director DESC',
  270. ),
  271. '*',
  272. ),
  273. ),
  274. ));
  275. }
  276. public function activelist()
  277. {
  278. // Warning: Please modify the following code to remove attributes that
  279. // should not be searched.
  280. $criteria=new CDbCriteria;
  281. $criteria->with = array('videoDetails'=>array('with'=>array('originalLang')),'videoCategory');
  282. $criteria->compare('t.id',$this->id,true);
  283. $criteria->compare('user_id',$this->user_id,true);
  284. $criteria->compare('video_category_id',$this->video_category_id);
  285. $criteria->compare('t.video_kaltura_id',$this->video_kaltura_id,true);
  286. $criteria->compare('t.view_count',$this->view_count,true);
  287. $criteria->compare('t.mfwpick',$this->mfwpick,true);
  288. $criteria->compare('t.toprated',$this->toprated,true);
  289. $criteria->compare('t.exclusive',$this->exclusive,true);
  290. $criteria->compare('t.adds_allow',$this->adds_allow,true);
  291. $criteria->compare('t.addeddate',$this->addeddate,true);
  292. $criteria->compare('t.featured',$this->featured,true);
  293. $criteria->compare('originalLang.title',$this->language_search,true);
  294. //$criteria->compare('t.active_date','',true);
  295. $criteria->compare('t.is_active','N',true);
  296.  
  297. $criteria->compare('videoDetails.name_of_film',$this->videoDetails_search_nameoffilm,true);
  298. $criteria->compare('videoDetails.year_make',$this->videoDetails_year,true);
  299. $criteria->compare('videoCategory.id',$this->videoCategory_search_genus);
  300.  
  301. $post_table = User::model()->tableName();
  302. $post_count_sql = "(select CONCAT(first_name, ' ', middlename, ' ', last_name) from $post_table where $post_table.id = t.user_id)";
  303. $criteria->select = array('*', $post_count_sql . " as user_search_fullName",);
  304. $criteria->compare($post_count_sql, $this->user_search_fullName,true);
  305.  
  306. $criteria->condition = 't.active_date IS NULL AND t.video_kaltura_id !="" ';
  307.  
  308. return new CActiveDataProvider($this, array(
  309. 'criteria'=>$criteria,
  310. 'pagination'=>false,
  311. 'sort'=>array(
  312. 'defaultOrder'=>'t.id DESC',
  313. 'attributes'=>array(
  314. 'videoDetails_search_nameoffilm'=>array(
  315. 'asc'=>'videoDetails.name_of_film',
  316. 'desc'=>'videoDetails.name_of_film DESC',
  317. ),
  318. 'videoCategory_search_genus'=>array(
  319. 'asc'=>'videoCategory.id',
  320. 'desc'=>'videoCategory.id DESC',
  321. ),
  322. 'user_search_fullName'=>array(
  323. 'asc'=>'user.first_name',
  324. 'desc'=>'user.first_name DESC',
  325. ),
  326. 'videoDetails_year'=>array(
  327. 'asc'=>'videoDetails.year_make',
  328. 'desc'=>'videoDetails.year_make DESC',
  329. ),
  330. '*',
  331. ),
  332. ),
  333. ));
  334. }
  335. public function searchmypic()
  336. {
  337. // Warning: Please modify the following code to remove attributes that
  338. // should not be searched.
  339. $criteria=new CDbCriteria;
  340. $model->mfwpick=1;
  341. $criteria->with = array('videoDetails','user','videoCategory');
  342. $criteria->compare('t.id',$this->id,true);
  343. $criteria->compare('t.mfwpick',$model->mfwpick);
  344. $criteria->compare('user_id',$this->user_id,true);
  345. //$criteria->compare('video_category_id',$this->video_category_id);
  346. //$criteria->compare('video_kaltura_id',$this->video_kaltura_id,true);
  347. $criteria->compare('t.is_active','Y',true);
  348. $criteria->compare('t.view_count',$this->view_count,true);
  349.  
  350. //$criteria->compare('t.exclusive',$this->exclusive,true);
  351. //$criteria->compare('t.adds_allow',$this->adds_allow,true);
  352. //$criteria->compare('t.addeddate',$this->addeddate,true);
  353. $criteria->compare('t.mfwpicksort',$this->mfwpicksort);
  354. //$criteria->compare('t.featured',$this->featured,true);
  355. //$criteria->compare('t.is_delete','N',true);
  356.  
  357. $criteria->compare('videoDetails.name_of_film',$this->videoDetails_search_nameoffilm,true);
  358. $criteria->compare('videoDetails.year_make',$this->videoDetails_year,true);
  359. $criteria->compare('videoCategory.id',$this->videoCategory_search_genus);
  360.  
  361. $post_table = User::model()->tableName();
  362. $post_count_sql = "(select CONCAT(first_name, ' ', middlename, ' ', last_name) from $post_table where $post_table.id = t.user_id)";
  363. /*$criteria->select = array('*', $post_count_sql . " as user_search_fullName",);
  364. $criteria->compare($post_count_sql, $this->user_search_fullName,true);*/
  365.  
  366. $post_table2 = VideoRating::model()->tableName();
  367. $post_count_sql2 = "(select AVG(rating) from $post_table2 where $post_table2.is_active = 'Y' AND $post_table2.user_id in (select id from {{user}} where is_active !='N' AND is_active !='S' AND is_active !='D' AND type_id= 2 ) AND $post_table2.video_id = t.id)";
  368. $post_count_sql1 = "(select AVG(rating) from $post_table2 where $post_table2.is_active = 'Y' AND $post_table2.user_id in (select id from {{user}} where is_active !='N' AND is_active !='S' AND is_active !='D' AND type_id= 1 ) AND $post_table2.video_id = t.id)";
  369. $criteria->select = array('*', $post_count_sql1 . " as videoRatings_user", $post_count_sql2 . " as videoRatings_director", $post_count_sql . " as user_search_fullName",);
  370. $criteria->compare($post_count_sql1, $this->videoRatings_user);
  371. $criteria->compare($post_count_sql2, $this->videoRatings_director);
  372. $criteria->compare($post_count_sql, $this->user_search_fullName,true);
  373.  
  374.  
  375.  
  376. //$criteria->order = 't.mfwpicksort DESC';
  377.  
  378. return new CActiveDataProvider($this, array(
  379. 'criteria'=>$criteria,
  380. 'pagination'=>false,
  381. 'sort'=>array(
  382. 'defaultOrder'=>'t.mfwpicksort',
  383. 'attributes'=>array(
  384. 'videoDetails_search_nameoffilm'=>array(
  385. 'asc'=>'videoDetails.name_of_film',
  386. 'desc'=>'videoDetails.name_of_film DESC',
  387. ),
  388. 'videoCategory_search_genus'=>array(
  389. 'asc'=>'videoCategory.id',
  390. 'desc'=>'videoCategory.id DESC',
  391. ),
  392. 'user_search_fullName'=>array(
  393. 'asc'=>'user_search_fullName',
  394. 'desc'=>'user_search_fullName DESC',
  395. ),
  396. 'videoDetails_year'=>array(
  397. 'asc'=>'videoDetails.year_make',
  398. 'desc'=>'videoDetails.year_make DESC',
  399. ),
  400. 'videoRatings_user'=>array(
  401. 'asc'=>'videoRatings_user',
  402. 'desc'=>'videoRatings_user DESC',
  403. ),
  404. 'videoRatings_director'=>array(
  405. 'asc'=>'videoRatings_director',
  406. 'desc'=>'videoRatings_director DESC',
  407. ),
  408. '*',
  409. ),
  410. ),
  411. ));
  412. }
  413. /*
  414. * get all videos of a director (if id null all videos)
  415. * param director id, return value model
  416. */
  417. public function searchtoprated()
  418. {
  419. // Warning: Please modify the following code to remove attributes that
  420. // should not be searched.
  421. $criteria=new CDbCriteria;
  422. $model->toprated=1;
  423. $criteria->with = array('videoDetails','user','videoCategory');
  424. $criteria->compare('t.id',$this->id,true);
  425. $criteria->compare('t.toprated',$model->toprated);
  426. $criteria->compare('user_id',$this->user_id,true);
  427. //$criteria->compare('video_category_id',$this->video_category_id);
  428. //$criteria->compare('video_kaltura_id',$this->video_kaltura_id,true);
  429. $criteria->compare('t.is_active','Y',true);
  430. $criteria->compare('t.view_count',$this->view_count,true);
  431.  
  432. //$criteria->compare('t.exclusive',$this->exclusive,true);
  433. //$criteria->compare('t.adds_allow',$this->adds_allow,true);
  434. //$criteria->compare('t.addeddate',$this->addeddate,true);
  435. //$criteria->compare('t.sortorder',$this->sortorder);
  436. //$criteria->compare('t.featured',$this->featured,true);
  437. //$criteria->compare('t.is_delete','N',true);
  438. $criteria->compare('topratsort',$this->topratsort);
  439.  
  440. $criteria->compare('videoDetails.name_of_film',$this->videoDetails_search_nameoffilm,true);
  441. $criteria->compare('videoDetails.year_make',$this->videoDetails_year,true);
  442. $criteria->compare('videoCategory.id',$this->videoCategory_search_genus);
  443. /*$criteria->compare('user.first_name',$this->user_search_fullName,true);
  444. $criteria->compare('user.last_name',$this->user_search_fullName,true,'OR');
  445. $criteria->compare('user.first_name',explode(' ',$this->user_search_fullName),true,'OR');
  446. $criteria->compare('user.last_name',explode(' ',$this->user_search_fullName),true,'OR');*/
  447.  
  448. $post_table = User::model()->tableName();
  449. $post_count_sql = "(select CONCAT(first_name, ' ', middlename, ' ', last_name) from $post_table where $post_table.id = t.user_id)";
  450. /* $criteria->select = array('*', $post_count_sql . " as user_search_fullName",);
  451. $criteria->compare($post_count_sql, $this->user_search_fullName,true);*/
  452.  
  453. $post_table2 = VideoRating::model()->tableName();
  454. $post_count_sql2 = "(select AVG(rating) from $post_table2 where $post_table2.is_active = 'Y' AND $post_table2.user_id in (select id from {{user}} where is_active !='N' AND is_active !='S' AND is_active !='D' AND type_id= 2 ) AND $post_table2.video_id = t.id)";
  455. $post_count_sql1 = "(select AVG(rating) from $post_table2 where $post_table2.is_active = 'Y' AND $post_table2.user_id in (select id from {{user}} where is_active !='N' AND is_active !='S' AND is_active !='D' AND type_id= 1 ) AND $post_table2.video_id = t.id)";
  456. $criteria->select = array('*', $post_count_sql1 . " as videoRatings_user", $post_count_sql2 . " as videoRatings_director", $post_count_sql . " as user_search_fullName",);
  457. //$criteria->order = 't.topratsort ASC';
  458.  
  459. return new CActiveDataProvider($this, array(
  460. 'criteria'=>$criteria,
  461. 'pagination'=>false,
  462. 'sort'=>array(
  463. 'defaultOrder'=>'t.topratsort ',
  464. 'attributes'=>array(
  465. 'videoDetails_search_nameoffilm'=>array(
  466. 'asc'=>'videoDetails.name_of_film',
  467. 'desc'=>'videoDetails.name_of_film DESC',
  468. ),
  469. 'videoCategory_search_genus'=>array(
  470. 'asc'=>'videoCategory.id',
  471. 'desc'=>'videoCategory.id DESC',
  472. ),
  473. 'user_search_fullName'=>array(
  474. 'asc'=>'user_search_fullName',
  475. 'desc'=>'user_search_fullName DESC',
  476. ),
  477. 'videoDetails_year'=>array(
  478. 'asc'=>'videoDetails.year_make',
  479. 'desc'=>'videoDetails.year_make DESC',
  480. ),
  481. 'videoRatings_user'=>array(
  482. 'asc'=>'videoRatings_user',
  483. 'desc'=>'videoRatings_user DESC',
  484. ),
  485. 'videoRatings_director'=>array(
  486. 'asc'=>'videoRatings_director',
  487. 'desc'=>'videoRatings_director DESC',
  488. ),
  489. '*',
  490. ),
  491. ),
  492. ));
  493. }
  494. // sort video listing
  495. public function searchGenus()
  496. {
  497. // Warning: Please modify the following code to remove attributes that
  498. // should not be searched.
  499. $criteria=new CDbCriteria;
  500. $criteria->with = array('videoDetails','user','videoCategory');
  501. $criteria->compare('t.id',$this->id,true);
  502. $criteria->compare('user_id',$this->user_id,true);
  503. $criteria->compare('t.is_active','Y',true);
  504. $criteria->compare('t.view_count',$this->view_count,true);
  505. $criteria->compare('t.catsort',$this->catsort);
  506. $criteria->compare('videoDetails.name_of_film',$this->videoDetails_search_nameoffilm,true);
  507. $criteria->compare('videoDetails.year_make',$this->videoDetails_year,true);
  508. $criteria->compare('videoCategory.id',$this->videoCategory_search_genus);
  509. $post_table = User::model()->tableName();
  510. $post_count_sql = "(select CONCAT(first_name, ' ', middlename, ' ', last_name) from $post_table where $post_table.id = t.user_id)";
  511. $post_table2 = VideoRating::model()->tableName();
  512. $post_count_sql2 = "(select AVG(rating) from $post_table2 where $post_table2.is_active = 'Y' AND $post_table2.user_id in (select id from {{user}} where is_active !='N' AND is_active !='S' AND is_active !='D' AND type_id= 2 ) AND $post_table2.video_id = t.id)";
  513. $post_count_sql1 = "(select AVG(rating) from $post_table2 where $post_table2.is_active = 'Y' AND $post_table2.user_id in (select id from {{user}} where is_active !='N' AND is_active !='S' AND is_active !='D' AND type_id= 1 ) AND $post_table2.video_id = t.id)";
  514. $criteria->select = array('*', $post_count_sql1 . " as videoRatings_user", $post_count_sql2 . " as videoRatings_director", $post_count_sql . " as user_search_fullName",);
  515. //$criteria->order = 't.catsort ASC';
  516.  
  517. return new CActiveDataProvider($this, array(
  518. 'criteria'=>$criteria,
  519. 'pagination'=>false,
  520. 'sort'=>array(
  521. 'defaultOrder'=>'t.catsort ',
  522. 'attributes'=>array(
  523. 'videoDetails_search_nameoffilm'=>array(
  524. 'asc'=>'videoDetails.name_of_film',
  525. 'desc'=>'videoDetails.name_of_film DESC',
  526. ),
  527. 'videoCategory_search_genus'=>array(
  528. 'asc'=>'videoCategory.id',
  529. 'desc'=>'videoCategory.id DESC',
  530. ),
  531. 'user_search_fullName'=>array(
  532. 'asc'=>'user_search_fullName',
  533. 'desc'=>'user_search_fullName DESC',
  534. ),
  535. 'videoDetails_year'=>array(
  536. 'asc'=>'videoDetails.year_make',
  537. 'desc'=>'videoDetails.year_make DESC',
  538. ),
  539. 'videoRatings_user'=>array(
  540. 'asc'=>'videoRatings_user',
  541. 'desc'=>'videoRatings_user DESC',
  542. ),
  543. 'videoRatings_director'=>array(
  544. 'asc'=>'videoRatings_director',
  545. 'desc'=>'videoRatings_director DESC',
  546. ),
  547. '*',
  548. ),
  549. ),
  550. ));
  551. }
  552. public function searchsort()
  553. {
  554. // Warning: Please modify the following code to remove attributes that
  555. // should not be searched.
  556. $criteria=new CDbCriteria;
  557. $criteria->with = array('videoDetails','user','videoCategory');
  558. $criteria->compare('t.id',$this->id,true);
  559. $criteria->compare('t.user_id',$this->user_id,true);
  560. $criteria->compare('t.video_category_id',$this->video_category_id);
  561. $criteria->compare('t.video_kaltura_id',$this->video_kaltura_id,true);
  562. $criteria->compare('t.is_active','Y');
  563. $criteria->compare('t.catsort',$this->catsort);
  564.  
  565. $criteria->compare('videoDetails.name_of_film',$this->videoDetails_search_nameoffilm,true);
  566. $criteria->compare('videoDetails.year_make',$this->videoDetails_year,true);
  567. $criteria->compare('videoCategory.id',$this->videoCategory_search_genus);
  568.  
  569. $post_table = User::model()->tableName();
  570. $post_count_sql = "(select CONCAT(first_name, ' ', middlename, ' ', last_name) from $post_table where $post_table.id = t.user_id)";
  571. $criteria->select = array('*', $post_count_sql . " as user_search_fullName",);
  572. $criteria->compare($post_count_sql, $this->user_search_fullName,true);
  573.  
  574. $criteria->order = 't.catsort ASC';
  575.  
  576. return new CActiveDataProvider($this, array(
  577. 'criteria'=>$criteria,
  578. 'pagination'=>false,
  579. ));
  580. }
  581.  
  582.  
  583. public function getAllVideos($id=null,$needList=true)
  584. {
  585. $condition = 't.is_active = "Y" AND t.is_delete = "N"';
  586. if($id!=null)
  587. $condition .= ' AND user_id="'.$id.'"';
  588. $model = Video::model()->with('videoDetails')->findAll(array('condition'=>$condition,'order'=>'id'));
  589.  
  590. if($needList)
  591. return CHtml::listData($model, 'id', 'videoDetails.name_of_film');
  592. return $model;
  593. }
  594.  
  595. public function getAllVideosOne($id=null,$needList=true)
  596. {
  597. $condition = 't.is_active = "Y" AND t.is_delete = "N"';
  598. if($id!=null)
  599. $condition .= ' AND user_id="'.$id.'"';
  600. $model = Video::model()->with('videoDetails')->findAll(array('condition'=>$condition,'limit'=>"1",'order'=>'id DESC'));
  601.  
  602. if($needList)
  603. return CHtml::listData($model, 'id', 'videoDetails.name_of_film');
  604.  
  605.  
  606. return $model;
  607. }
  608.  
  609.  
  610. public function getSeltedVideos($type=null,$needList=true)
  611. {
  612. $condition = 't.is_active = "Y" AND t.is_delete = "N"';
  613. if($type!=null)
  614. $condition .= ' AND standalone_id="'.$type.'"';
  615. $model = Video::model()->with('videoDetails')->findAll(array('condition'=>$condition,'order'=>'id'));
  616.  
  617. if($needList)
  618. return CHtml::listData($model, 'id', 'videoDetails.name_of_film');
  619. return $model;
  620. }
  621.  
  622. public function getVideoDetails($id)
  623. {
  624. $condition = 't.video_id="'.$id.'"';
  625. //if($id!=null)
  626. //$condition .= ' AND user_id="'.$id.'"';
  627. $model = VideoDetails::model()->findAll(array('condition'=>$condition));
  628.  
  629. //if($needList)
  630. //return CHtml::listData($model, 'id', 'videoDetails.name_of_film');
  631. return $model;
  632. }
  633.  
  634. public function getDirector($id)
  635. {
  636. $condition = 't.id="'.$id.'"';
  637. //if($id!=null)
  638. //$condition .= ' AND user_id="'.$id.'"';
  639. $model = User::model()->findAll(array('condition'=>$condition));
  640. //print_r($model);
  641. //exit;
  642. if($needList)
  643. return CHtml::listData($model, 'id', 'videoDetails.name_of_film');
  644. return $model;
  645. }
  646. public function getVideofromCat($id)
  647. {
  648. //echo "hai";
  649. //exit;
  650. $condition = 't.video_kaltura_id!="" AND t.is_active="Y" AND t.video_category_id="'.$id.'"';
  651. //if($id!=null)
  652. //$condition .= ' AND user_id="'.$id.'"';
  653.  
  654. $findCriteria = new CDbCriteria();
  655. //$findCriteria->offset = 0;
  656. //$findCriteria->limit = 20;
  657. // $posts = Posts::model()->with($posts)->findAll($findCriteria);
  658. $model = Video::model()->findAll(array('condition'=>$condition,'order'=>"catsort",'limit'=>"11"));
  659. //echo count($model);
  660. //exit;
  661. //if($needList)
  662. //return CHtml::listData($model, 'id', 'videoDetails.name_of_film');
  663. return $model;
  664. }
  665. public function getVideoCatList($cid,$limit)
  666. {
  667. //echo "hai";
  668. //exit;
  669. $condition = 't.video_category_id="'.$cid.'"';
  670. //if($id!=null)
  671. //$condition .= ' AND user_id="'.$id.'"';
  672. $model = Video::model()->findAll(array('condition'=>$condition),$limit,7);
  673.  
  674. //print_r($model);
  675. //exit;
  676. //if($needList)
  677. //return CHtml::listData($model, 'id', 'videoDetails.name_of_film');
  678. return $model;
  679. }
  680.  
  681. // new function for category wise view count
  682. public function getVideoCatView($catid)
  683. {
  684. $condition = 'video_category_id="'.$catid.'"';
  685. $model = Video::model()->find(array('select'=>'sum(view_count) as sumview','condition'=>$condition));
  686. return $model->sumview;
  687. }
  688. // new function for user wise view count
  689. public function getVideoUsrView($usrid)
  690. {
  691. $condition = 'user_id="'.$usrid.'"';
  692. $model = Video::model()->find(array('select'=>'sum(view_count) as sumview','condition'=>$condition));
  693. return $model->sumview;
  694. }
  695. // new function for category wise view count Except Blocked Videos
  696. public function getVideoCatViewNB($catid)
  697. {
  698. $condition = 'video_category_id="'.$catid.'" AND is_active != "B"';
  699. $model = Video::model()->find(array('select'=>'sum(view_count) as sumview','condition'=>$condition));
  700. return $model->sumview;
  701. }
  702. // all video details and list gettings
  703. public function getAllVideo($id=null,$satus=0)
  704. {
  705. if($satus==0)
  706. $condition = 't.is_active = "Y" AND videoCategory.is_active = "Y" AND t.video_kaltura_id!="" ';
  707. else if($satus==1)
  708. $condition = 't.is_active != "B" AND videoCategory.is_active = "Y" ';
  709. else
  710. $condition = 't.is_active = "Y" AND videoCategory.is_active = "Y" AND t.video_kaltura_id!="" ';
  711.  
  712. if($id!=null)
  713. $condition .= ' AND t.user_id="'.$id.'"';
  714. $model = Video::model()->with('videoCategory')->findAll(array('condition'=>$condition,'order'=>'t.id DESC'));
  715. return $model;
  716. }
  717. // all video details and list gettings of category
  718. public function getGenesVideo($id=null,$satus=0)
  719. {
  720. if($satus==0)
  721. $condition = 't.is_active = "Y" AND videoCategory.is_active = "Y" AND t.video_kaltura_id!="" ';
  722. else if($satus==1)
  723. $condition = 't.is_active != "B" AND videoCategory.is_active = "Y" ';
  724. else
  725. $condition = 't.is_active = "Y" AND videoCategory.is_active = "Y" AND t.video_kaltura_id!="" ';
  726.  
  727. if($id!=null)
  728. $condition .= ' AND t.video_category_id="'.$id.'"';
  729. $model = Video::model()->with('videoCategory')->findAll(array('condition'=>$condition,'order'=>'t.catsort'));
  730. return $model;
  731. }
  732. // all video details of MFW and list gettings
  733. public function getAllMFW($type="MFW",$satus=0)
  734. {
  735. if($satus==0)
  736. $condition = 't.is_active = "Y" AND videoCategory.is_active = "Y" AND t.video_kaltura_id!="" ';
  737. else if($satus==1)
  738. $condition = 't.is_active != "B" AND videoCategory.is_active = "Y" ';
  739. else
  740. $condition = 't.is_active = "Y" AND videoCategory.is_active = "Y" AND t.video_kaltura_id!="" ';
  741.  
  742. if($type=="MFW")
  743. $condition .= ' AND t.mfwpick="1"';
  744. $model = Video::model()->with('videoCategory')->findAll(array('condition'=>$condition,'order'=>'t.mfwpicksort'));
  745. return $model;
  746. }
  747. //all videos of selected languages
  748. public function getLangVideos($Languages=null,$satus=0)
  749. {
  750. if($satus==0)
  751. $condition = 't.is_active = "Y" AND videoCategory.is_active = "Y" AND t.video_kaltura_id!="" ';
  752. else if($satus==1)
  753. $condition = 't.is_active != "B" AND videoCategory.is_active = "Y" ';
  754. else
  755. $condition = 't.is_active = "Y" AND videoCategory.is_active = "Y" AND t.video_kaltura_id!="" ';
  756. if($Languages!=null)
  757. $condition.=' AND videoDetails.original_lang="'.$Languages.'" AND videoDetails.video_id=t.id ';
  758.  
  759. $model =Video::model()->with(array('videoDetails','videoCategory'))->findAll(array('condition'=>$condition,'order'=>'t.id DESC'));
  760.  
  761. $condition2 = $condition.' AND t.toprated="1"';
  762. $model2 = Video::model()->with(array('videoDetails','videoCategory'))->findAll(array('condition'=>$condition2,'order'=>'t.topratsort'));
  763.  
  764. $condition3 = $condition.' AND t.mfwpick="1"';
  765. $model1 = Video::model()->with(array('videoDetails','videoCategory'))->findAll(array('condition'=>$condition3,'order'=>'t.mfwpicksort'));
  766.  
  767. $models[0]=$model1;
  768. $models[1]=$model2;
  769. $models[2]=$model;
  770. return $models;
  771. }
  772. //all videos of selected conditions new functions
  773. // *********************************************************************************************************
  774. public function getLangVideogeneus($searchs=null,$satus=0,$idefy=0)
  775. {
  776. if($satus==0)
  777. $condition = 't.is_active = "Y" AND videoCategory.is_active = "Y" AND t.video_kaltura_id!="" ';
  778. else if($satus==1)
  779. $condition = 't.is_active != "B" AND videoCategory.is_active = "Y" ';
  780. else
  781. $condition = 't.is_active = "Y" AND videoCategory.is_active = "Y" AND t.video_kaltura_id!="" ';
  782.  
  783.  
  784. if($searchs!=null && $idefy=1)
  785. $condition .=' AND videoDetails.original_lang="'.$searchs.'" AND videoDetails.video_id=t.id ';
  786. else
  787. $condition .=' AND videoDetails.video_id=t.id ';
  788.  
  789. $model =Video::model()->with(array('videoDetails','videoCategory'))->findAll(array('condition'=>$condition,'order'=>'videoCategory.sortOrder,t.video_category_id,t.catsort'));
  790.  
  791. $condition2 = $condition.' AND t.toprated="1"';
  792. $model2 = Video::model()->with(array('videoDetails','videoCategory'))->findAll(array('condition'=>$condition2,'order'=>'t.topratsort'));
  793.  
  794. $condition3 = $condition.' AND t.mfwpick="1"';
  795. $model1 = Video::model()->with(array('videoDetails','videoCategory'))->findAll(array('condition'=>$condition3,'order'=>'t.mfwpicksort'));
  796.  
  797. $models[0]=$model1;
  798. $models[1]=$model2;
  799. $models[2]=$model;
  800. return $models;
  801. }
  802. // all videos in top rated
  803. public function getAllToprated($type="toprated",$satus=0)
  804. {
  805. if($satus==0)
  806. $condition = 't.is_active = "Y" AND videoCategory.is_active = "Y" AND t.video_kaltura_id!="" ';
  807. else if($satus==1)
  808. $condition = 't.is_active != "B" AND videoCategory.is_active = "Y" ';
  809. else
  810. $condition = 't.is_active = "Y" AND videoCategory.is_active = "Y" AND t.video_kaltura_id!="" ';
  811.  
  812. if($type=="toprated")
  813. $condition .= ' AND t.toprated="1"';
  814. $model = Video::model()->with('videoCategory')->findAll(array('condition'=>$condition,'order'=>'t.topratsort'));
  815. return $model;
  816. }
  817. // all video details of MFW and list gettings
  818. public function getMFWLimit($type="MFW",$satus=0,$limit=5)
  819. {
  820. if($satus==0)
  821. $condition = 't.is_active = "Y" AND videoCategory.is_active = "Y" AND t.video_kaltura_id!="" ';
  822. else if($satus==1)
  823. $condition = 't.is_active != "B" AND videoCategory.is_active = "Y" ';
  824. else
  825. $condition = 't.is_active = "Y" AND videoCategory.is_active = "Y" AND t.video_kaltura_id!="" ';
  826.  
  827. if($type=="MFW")
  828. $condition .= ' AND t.mfwpick="1"';
  829. $model = Video::model()->with('videoCategory')->findAll(array('condition'=>$condition,'order'=>'RAND()','limit'=>$limit));
  830. return $model;
  831. }
  832.  
  833. /***************For Home Page*********************/
  834. public function getAllMFWHome($type="MFW",$satus=0)
  835. {
  836. if($satus==0)
  837. $condition = 'is_active = "Y"';
  838. else if($satus==1)
  839. $condition = 'is_active != "B"';
  840. else
  841. $condition = 'is_active = "Y"';
  842.  
  843. if($type=="MFW")
  844. $condition .= ' AND mfwpick="1" AND video_kaltura_id!=""';
  845. $model = Video::model()->findAll(array('condition'=>$condition,'order'=>'mfwpicksort ASC, id DESC','limit'=>"11"));
  846. return $model;
  847. }
  848. public function getMFWNoVideo($type="MFW",$satus=0)
  849. {
  850. if($satus==0)
  851. $condition = 'is_active = "Y"';
  852. else if($satus==1)
  853. $condition = 'is_active != "B"';
  854. else
  855. $condition = 'is_active = "Y"';
  856.  
  857. if($type=="MFW")
  858. $condition .= ' AND mfwpick="1" AND video_kaltura_id!=""';
  859. $model = Video::model()->findAll(array('condition'=>$condition,'order'=>'mfwpicksort','limit'=>"1"));
  860. return $model;
  861. }
  862. public function getAllTopratedHome($type="toprated",$satus=0)
  863. {
  864. if($satus==0)
  865. $condition = 'is_active = "Y"';
  866. else if($satus==1)
  867. $condition = 'is_active != "B"';
  868. else
  869. $condition = 'is_active = "Y"';
  870.  
  871. if($type=="toprated")
  872. $condition .= ' AND toprated="1" AND video_kaltura_id!=""';
  873. $model = Video::model()->findAll(array('condition'=>$condition,'order'=>'topratsort ASC, id DESC','limit'=>"11"));
  874. return $model;
  875. }
  876. /***************End Home Page*********************/
  877.  
  878. //all videos of selected film name
  879. public function getFilmNameVideos($FilmName=null,$satus=0)
  880. {
  881. if($satus==0)
  882. $condition = 't.is_active = "Y" AND videoCategory.is_active = "Y" AND t.video_kaltura_id!=""';
  883. else if($satus==1)
  884. $condition = 't.is_active != "B" AND videoCategory.is_active = "Y" ';
  885. else
  886. $condition = 't.is_active = "Y" AND videoCategory.is_active = "Y" AND t.video_kaltura_id!="" ';
  887. if($FilmName!=null)
  888. $condition.=' AND videoDetails.name_of_film LIKE "%'.$FilmName.'%" AND videoDetails.video_id=t.id ';
  889.  
  890. $model =Video::model()->with(array('videoDetails','videoCategory'))->findAll(array('condition'=>$condition,'order'=>'videoCategory.sortOrder,t.video_category_id,t.catsort'));
  891.  
  892. $condition2 = $condition.' AND t.toprated="1"';
  893. $model2 = Video::model()->with(array('videoDetails','videoCategory'))->findAll(array('condition'=>$condition2,'order'=>'t.topratsort'));
  894.  
  895. $condition3 = $condition.' AND t.mfwpick="1"';
  896. $model1 = Video::model()->with(array('videoDetails','videoCategory'))->findAll(array('condition'=>$condition3,'order'=>'t.mfwpicksort'));
  897.  
  898. $models[0]=$model1;
  899. $models[1]=$model2;
  900. $models[2]=$model;
  901. return $models;
  902. }
  903.  
  904. //all videos of selected country of production
  905. public function getCountryVideos($CountryName=null,$satus=0)
  906. {
  907. if($satus==0)
  908. $condition = 't.is_active = "Y" AND videoCategory.is_active = "Y" AND t.video_kaltura_id!="" ';
  909. else if($satus==1)
  910. $condition = 't.is_active != "B" AND videoCategory.is_active = "Y" ';
  911. else
  912. $condition = 't.is_active = "Y" AND videoCategory.is_active = "Y" AND t.video_kaltura_id!="" ';
  913. if($CountryName!=null)
  914. $condition.=' AND videoDetails.country_production = "'.$CountryName.'" AND videoDetails.video_id=t.id ';
  915.  
  916. $model =Video::model()->with(array('videoDetails','videoCategory'))->findAll(array('condition'=>$condition,'order'=>'videoCategory.sortOrder,t.video_category_id,t.catsort'));
  917.  
  918. $condition2 = $condition.' AND t.toprated="1"';
  919. $model2 = Video::model()->with(array('videoDetails','videoCategory'))->findAll(array('condition'=>$condition2,'order'=>'t.topratsort'));
  920.  
  921. $condition3 = $condition.' AND t.mfwpick="1"';
  922. $model1 = Video::model()->with(array('videoDetails','videoCategory'))->findAll(array('condition'=>$condition3,'order'=>'t.mfwpicksort'));
  923.  
  924. $models[0]=$model1;
  925. $models[1]=$model2;
  926. $models[2]=$model;
  927. return $models;
  928. }
  929.  
  930. //all videos of selected year of release
  931. public function getYearOfReleaseVideos($YearOfRelease=null,$satus=0)
  932. {
  933. if($satus==0)
  934. $condition = 't.is_active = "Y" AND videoCategory.is_active = "Y" AND t.video_kaltura_id!="" ';
  935. else if($satus==1)
  936. $condition = 't.is_active != "B" AND videoCategory.is_active = "Y" ';
  937. else
  938. $condition = 't.is_active = "Y" AND videoCategory.is_active = "Y" AND t.video_kaltura_id!="" ';
  939. if($YearOfRelease!=null)
  940. $condition.=' AND videoDetails.year_make = "'.$YearOfRelease.'" AND videoDetails.video_id=t.id ';
  941.  
  942. $model =Video::model()->with(array('videoDetails','videoCategory'))->findAll(array('condition'=>$condition,'order'=>'videoCategory.sortOrder,t.video_category_id,t.catsort'));
  943.  
  944. $condition2 = $condition.' AND t.toprated="1"';
  945. $model2 = Video::model()->with(array('videoDetails','videoCategory'))->findAll(array('condition'=>$condition2,'order'=>'t.topratsort'));
  946.  
  947. $condition3 = $condition.' AND t.mfwpick="1"';
  948. $model1 = Video::model()->with(array('videoDetails','videoCategory'))->findAll(array('condition'=>$condition3,'order'=>'t.mfwpicksort'));
  949.  
  950. $models[0]=$model1;
  951. $models[1]=$model2;
  952. $models[2]=$model;
  953. return $models;
  954. }
  955.  
  956. //all videos of selected rating
  957. public function getRatingVideos($Rating=null,$satus=0)
  958. {
  959. if($satus==0)
  960. $condition = 't.is_active = "Y" AND videoCategory.is_active = "Y" AND t.video_kaltura_id!="" ';
  961. else if($satus==1)
  962. $condition = 't.is_active != "B" AND videoCategory.is_active = "Y" ';
  963. else
  964. $condition = 't.is_active = "Y" AND videoCategory.is_active = "Y" AND t.video_kaltura_id!="" ';
  965. if($Rating!=null)
  966. $condition.=' AND videoDetails.film_rating = "'.$Rating.'" AND videoDetails.video_id=t.id ';
  967.  
  968. $model =Video::model()->with(array('videoDetails','videoCategory'))->findAll(array('condition'=>$condition,'order'=>'videoCategory.sortOrder,t.video_category_id,t.catsort'));
  969.  
  970. $condition2 = $condition.' AND t.toprated="1"';
  971. $model2 = Video::model()->with(array('videoDetails','videoCategory'))->findAll(array('condition'=>$condition2,'order'=>'t.topratsort'));
  972.  
  973. $condition3 = $condition.' AND t.mfwpick="1"';
  974. $model1 = Video::model()->with(array('videoDetails','videoCategory'))->findAll(array('condition'=>$condition3,'order'=>'t.mfwpicksort'));
  975.  
  976. $models[0]=$model1;
  977. $models[1]=$model2;
  978. $models[2]=$model;
  979. return $models;
  980. }
  981.  
  982. //all videos of selected actor
  983. public function getActoRVideoId($ActoRVideoId=null,$satus=0)
  984. {
  985. if($satus==0)
  986. $condition = 't.is_active = "Y" AND videoCategory.is_active = "Y" AND t.video_kaltura_id!="" ';
  987. else if($satus==1)
  988. $condition = 't.is_active != "B" AND videoCategory.is_active = "Y" ';
  989. else
  990. $condition = 't.is_active = "Y" AND videoCategory.is_active = "Y" AND t.video_kaltura_id!="" ';
  991. if($ActoRVideoId!=null)
  992. $condition.=' AND videoDetails.video_id = "'.$ActoRVideoId.'" AND videoDetails.video_id=t.id ';
  993.  
  994. $model =Video::model()->with(array('videoDetails','videoCategory'))->findAll(array('condition'=>$condition,'order'=>'videoCategory.sortOrder,t.video_category_id,t.catsort'));
  995. $condition2 = $condition.' AND t.toprated="1"';
  996. $model2 = Video::model()->with(array('videoDetails','videoCategory'))->findAll(array('condition'=>$condition2,'order'=>'t.topratsort'));
  997.  
  998. $condition3 = $condition.' AND t.mfwpick="1"';
  999. $model1 = Video::model()->with(array('videoDetails','videoCategory'))->findAll(array('condition'=>$condition3,'order'=>'t.mfwpicksort'));
  1000.  
  1001. $models[0]=$model1;
  1002. $models[1]=$model2;
  1003. $models[2]=$model;
  1004. return $models;
  1005. }
  1006. public function getNextVideo($videoId=null,$satus=0)
  1007. {
  1008. if($satus==0)
  1009. $condition = 't.is_active = "Y" AND videoCategory.is_active = "Y" AND t.video_kaltura_id!="" ';
  1010. else if($satus==1)
  1011. $condition = 't.is_active != "B" AND videoCategory.is_active = "Y" ';
  1012. else
  1013. $condition = 't.is_active = "Y" AND videoCategory.is_active = "Y" AND t.video_kaltura_id!="" ';
  1014. if($videoId!=null)
  1015. $condition.=' AND videoDetails.video_id = "'.$videoId.'" AND videoDetails.video_id=t.id ';
  1016.  
  1017. $model =Video::model()->with(array('videoDetails','videoCategory'))->findAll(array('condition'=>$condition,'order'=>'t.id DESC'));
  1018. return $model;
  1019. }
  1020.  
  1021. // ************** Advanced Search ****************//
  1022.  
  1023.  
  1024. public function getAdvancedVideos($Director=null,$FilmName=null,$Actor=null,$Language=null,$Country=null,$Rating=null,$Year=null,$satus=0)
  1025. {
  1026. if($satus==0)
  1027. $condition = 't.is_active = "Y" AND videoCategory.is_active = "Y" AND t.video_kaltura_id!=""';
  1028. else if($satus==1)
  1029. $condition = 't.is_active != "B" AND videoCategory.is_active = "Y" ';
  1030. else
  1031. $condition = 't.is_active = "Y" AND videoCategory.is_active = "Y" AND t.video_kaltura_id!="" ';
  1032.  
  1033. if($Director!=null)
  1034. {
  1035. $terms = explode(' ', $Director);
  1036. $bits = array();
  1037. foreach ($terms as $term) {
  1038. if($term!='')
  1039. $bits[] = "user.first_name LIKE '%".$term."%' OR user.last_name LIKE '%".$term."%' OR user.middlename LIKE '%".$term."%'" ;
  1040. }
  1041. $condition.=' AND t.user_id=user.id AND ('.implode(' OR ', $bits).') ';
  1042. }
  1043. if($Actor!=null)
  1044. {
  1045. $condition.='AND filmCastAndCrew.video_id=t.id AND (filmCastAndCrew.lead_male LIKE "%'.$Actor.'%" OR filmCastAndCrew.lead_female LIKE "%'.$Actor.'%") ';
  1046. }
  1047. if($FilmName!=null)
  1048. {
  1049. $condition.=' AND videoDetails.name_of_film LIKE "%'.$FilmName.'%" ';
  1050. }
  1051. if($Language!=null)
  1052. {
  1053. $condition.=' AND videoDetails.original_lang ="'.$Language.'"' ;
  1054. }
  1055. if($Country!=null)
  1056. {
  1057. $condition.=' AND videoDetails.country_production= "'.$Country.'"';
  1058. }
  1059. if($Rating!=null)
  1060. {
  1061. $condition.=' AND videoDetails.film_rating= "'.$Rating.'"';
  1062. }
  1063. if($Year!=null)
  1064. {
  1065. $condition.=' AND videoDetails.year_make= "'.$Year.'" ';
  1066. }
  1067.  
  1068. $condition.=' AND videoDetails.video_id=t.id ';
  1069.  
  1070. $model =Video::model()->with(array('videoDetails','videoCategory','user','filmCastAndCrew'))->findAll(array('condition'=>$condition,'order'=>'videoCategory.sortOrder,t.video_category_id,t.catsort'));
  1071.  
  1072. $condition2 = $condition.' AND t.toprated="1"';
  1073. $model2 = Video::model()->with(array('videoDetails','videoCategory','user','filmCastAndCrew'))->findAll(array('condition'=>$condition2,'order'=>'t.topratsort'));
  1074.  
  1075. $condition3 = $condition.' AND t.mfwpick="1"';
  1076. $model1 = Video::model()->with(array('videoDetails','videoCategory','user','filmCastAndCrew'))->findAll(array('condition'=>$condition3,'order'=>'t.mfwpicksort'));
  1077.  
  1078. $models[0]=$model1;
  1079. $models[1]=$model2;
  1080. $models[2]=$model;
  1081. return $models;
  1082.  
  1083. }
  1084. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement