PageRenderTime 44ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/life/modules/mobile/controllers/artist.php

https://bitbucket.org/zy_idf/popmaya
PHP | 172 lines | 158 code | 10 blank | 4 comment | 13 complexity | a183b88d8dd8645b3fc4816f754dd798 MD5 | raw file
  1. <?php if (! defined('BASEPATH')) exit('No direct script access allowed');
  2. class Artist extends MX_Controller {
  3. var $user_id;
  4. function __construct()
  5. {
  6. parent::__construct();
  7. if (!$this->ion_auth->logged_in()){
  8. redirect('mobile/login');
  9. exit();
  10. }
  11. $this->user_id=$this->session->userdata('user_id');
  12. $this->load->library('form_validation');
  13. $this->load->model('m_artist', '', TRUE);
  14. }
  15. function index()
  16. {
  17. $data['active_menu']='artist';
  18. $data['genre']=$this->m_artist->get_genre_list();
  19. $data['artist_list']=$this->m_artist->get_artist_list();
  20. $this->template->set_master_template('mobile');
  21. $this->template->write('head_title', 'Artist');
  22. $this->template->write_view('middle_content', 'artist/pm_mobile_index',$data, TRUE);
  23. $this->template->write_view('profile_menu', 'pm_mobile_top',$data,'');
  24. $this->template->render();
  25. }
  26. function profile($id)
  27. {
  28. if($id)
  29. {
  30. $profile=$this->m_artist->get_detail_artist($id);
  31. if(!empty($profile))
  32. {
  33. $data['profile']=$profile;
  34. $data['fan']=$this->m_artist->get_fan($profile->ID);
  35. //$data['activities']=
  36. }
  37. else
  38. redirect('mobile/artist');
  39. }
  40. else
  41. {
  42. redirect('mobile/artist');
  43. exit();
  44. }
  45. //$status=$this->m_artist->get_new_status($id);
  46. $data['active_menu']='artist';
  47. $this->template->set_master_template('mobile');
  48. $this->template->write('head_title', 'Artist');
  49. $this->template->write_view('middle_content', 'artist/pm_mobile_profile',$data, TRUE);
  50. $this->template->write_view('profile_menu', 'pm_mobile_top',$data,'');
  51. $this->template->render();
  52. }
  53. function search($letter=false)
  54. {
  55. if($letter)
  56. {
  57. $dataArtists=array();
  58. $artists=$this->m_artist->get_all_artists_by($letter);
  59. if(!empty($artists))
  60. {
  61. foreach($artists as $rArtist)
  62. {
  63. $dataArtists[]=array($rArtist->ID,$rArtist->artist_name,$rArtist->g_name);
  64. }
  65. $data['key']=$letter;
  66. }
  67. else
  68. {
  69. $dataArtists=NULL;
  70. $data['key']=$letter;
  71. }
  72. }
  73. elseif($this->input->post('artist_q'))
  74. {
  75. $key=strip_tags($this->input->post('artist_q'));
  76. $gen=$this->input->post('genre');
  77. if($gen)
  78. {
  79. foreach($gen as $rGenre)
  80. {
  81. $genre=array($rGenre);
  82. }
  83. }
  84. else
  85. {
  86. $genre=NULL;
  87. }
  88. $artists=$this->m_artist->get_all_artists_search($key,$genre);
  89. if(!empty($artists))
  90. {
  91. foreach($artists as $rArtist)
  92. {
  93. $dataArtists[]=array($rArtist->ID,$rArtist->artist_name,$rArtist->g_name);
  94. }
  95. $data['key']=$key;
  96. }
  97. else
  98. {
  99. $dataArtists=NULL;
  100. $data['key']=$key;
  101. }
  102. }
  103. else
  104. {
  105. redirect('mobile/artist/');
  106. exit();
  107. }
  108. $data['active_menu']='artist';
  109. $data['genre']=$this->m_artist->get_genre_list();
  110. $data['artist_list']=$dataArtists;
  111. $this->template->write('head_title', 'Search Artist');
  112. $this->template->set_master_template('mobile');
  113. $this->template->write_view('middle_content', 'artist/pm_mobile_artistsearch',$data,true);
  114. $this->template->write_view('profile_menu', 'pm_mobile_top',$data,'');
  115. $this->template->render();
  116. }
  117. function add_fan($id)
  118. {
  119. if($id)
  120. {
  121. $profile=$this->m_artist->get_detail_artist($id);
  122. if($profile)
  123. {
  124. $val=$this->m_artist->get_fan($profile->ID);
  125. if(empty($val))
  126. {
  127. $data=array(
  128. 'member_id'=>$this->user_id,
  129. 'artist_id'=>$profile->ID,
  130. 'f_isactive'=>0
  131. );
  132. $this->m_artist->add_fans($data);
  133. redirect('mobile/artist/profile/'.$profile->ID);
  134. }
  135. else
  136. redirect('mobile/artist/profile/'.$profile->ID);
  137. }
  138. else
  139. redirect('mobile/artist');
  140. }
  141. else
  142. redirect('mobile/artist');
  143. }
  144. function remove_fan($id)
  145. {
  146. if($id)
  147. {
  148. $profile=$this->m_artist->get_detail_artist($id);
  149. if($profile)
  150. {
  151. $this->m_artist->remove_fans($profile->ID);
  152. redirect('mobile/artist/profile/'.$profile->ID);
  153. }
  154. else
  155. redirect('mobile/artist');
  156. }
  157. else
  158. redirect('mobile/artist');
  159. }
  160. }
  161. /* End of file artist.php */
  162. /* Location: ./life/modules/mobile/controllers/artist.php */