PageRenderTime 69ms CodeModel.GetById 26ms RepoModel.GetById 0ms app.codeStats 0ms

/admin/app/controllers/user_photo_albums_controller.php

https://bitbucket.org/fxrialab/tickets
PHP | 206 lines | 161 code | 20 blank | 25 comment | 9 complexity | 476547acf35c59d9e202a47fe53bf1ce MD5 | raw file
Possible License(s): LGPL-2.1, AGPL-1.0, GPL-2.0, MIT
  1. <?php
  2. class UserPhotoAlbumsController extends AppController
  3. {
  4. var $name='UserPhotoAlbums';
  5. var $components = array('Pagination');
  6. var $helpers = array('Pagination', 'error');
  7. function add_photogroup($uid=null)
  8. {
  9. $this->checkSession();
  10. $this->layout = 'default_user';
  11. $user_id=$_REQUEST['uid'];
  12. }
  13. function manageuserphoto()
  14. {
  15. $this->checkSession();
  16. $this->layout = 'default_user';
  17. }
  18. function view_photogroup($id=null , $uid=null)
  19. {
  20. $this->checkSession();
  21. $this->layout = 'default_user';
  22. $Qry = mysql_fetch_array(mysql_query("select * from user_albums where user_id=".$_REQUEST['uid']));
  23. $this->set('album', $Qry);
  24. /*$criteria = " 1 and UserAlbum.user_id =".$uid."";
  25. $order = " id ";
  26. $this->set('album', $this->UserAlbum->findAll($criteria, NULL, $order, NULL, NULL));*/
  27. }
  28. function delete_photogroup($id=null)
  29. {
  30. $this->checkSession();
  31. if(isset($_REQUEST['box']))
  32. {
  33. /////IF SEARCH IS COLLECTIVE OR CHOSEN BY ADMIN SELECTION//////
  34. $arr = $_REQUEST['box'];
  35. foreach($arr as $key => $value)
  36. {
  37. $sql_det = "delete from `user_photo_albums` where `user_id` = '".$value."'";
  38. $res_det = mysql_query($sql_det);
  39. }
  40. }
  41. ////IF DELETE IS FOR A SPECIFIC USER////
  42. else
  43. {
  44. $user_id=$_REQUEST['id'];
  45. $this->data['UserPhotoAlbum']['menu'] = $_REQUEST['menu'];
  46. $sql_det = "delete from `user_photo_albums` where `user_id` = '".$user_id."'";
  47. $res_det = mysql_query($sql_det);
  48. }
  49. $user_id=$_REQUEST['id'];
  50. $this->data['UserPhotoAlbum']['menu'] = $_REQUEST['menu'];
  51. if(isset($_REQUEST['page']))
  52. {
  53. $page = $_REQUEST['page'];
  54. }
  55. $this->flash('The post with id: '.$id.' has been deleted.', '/posts');
  56. $this->redirect('/user_photo_albums/manageuserphoto?menu='.$this->data['UserPhotoAlbum']['menu'].'&page='.$page);
  57. }
  58. function block_photogroup()
  59. {
  60. /////IF BLOCKING IS COLLECTIVE OR BY ADMIN SELECTION/////
  61. $this->checkSession();
  62. if(isset($_REQUEST['box']))
  63. {
  64. $arr = $_REQUEST['box'];
  65. foreach($arr as $key => $value)
  66. {
  67. $sql = "update `user_photo_albums` set `is_blocked` = '1' where `user_id` ='".$value."'";
  68. $res = mysql_query($sql);
  69. //$sql_user = "update `users` set `user_status` = '1' where `id` ='".$value."'";
  70. //$res_user = mysql_query($sql_user);
  71. }
  72. }
  73. ////IF BLOCKING IS FOR A SPECIFIC USER////
  74. else
  75. {
  76. $qry="update `user_photo_albums` set `is_blocked`='1' where `user_id`='".$_REQUEST['id']."'";
  77. $res=mysql_query($qry);
  78. //$sql_user = "update `users` set `user_status` = '1' where `id` ='".$_REQUEST['id']."'";
  79. //$res_user = mysql_query($sql_user);
  80. }
  81. $this->data['UserPhotoAlbum']['menu'] = $_REQUEST['menu'];
  82. if(isset($_REQUEST['page']))
  83. {
  84. $page = $_REQUEST['page'];
  85. }
  86. else $page = 1;
  87. $this->redirect('/user_photo_albums/manageuserphoto?menu='.$this->data['UserPhotoAlbum']['menu'].'&page='.$page);
  88. }
  89. function active_photogroup()
  90. {
  91. /////IF BLOCKING IS COLLECTIVE OR BY ADMIN SELECTION/////
  92. $this->checkSession();
  93. if(isset($_REQUEST['box']))
  94. {
  95. $arr = $_REQUEST['box'];
  96. foreach($arr as $key => $value)
  97. {
  98. $sql = "update `user_photo_albums` set `is_blocked` = '0' where `user_id` ='".$value."'";
  99. $res = mysql_query($sql);
  100. //$sql_user = "update `users` set `user_status` = '0' where `id` ='".$value."'";
  101. //$res_user = mysql_query($sql_user);
  102. }
  103. }
  104. ////IF BLOCKING IS FOR A SPECIFIC USER////
  105. else
  106. {
  107. $qry="update `user_photo_albums` set `is_blocked`='0' where `user_id`='".$_REQUEST['id']."'";
  108. $res=mysql_query($qry);
  109. //echo $sql_user = "update `users` set `user_status` = '0' where `id` ='".$_REQUEST['id']."'";
  110. //$res_user = mysql_query($sql_user);
  111. }
  112. $this->data['UserPhotoAlbum']['menu'] = $_REQUEST['menu'];
  113. if(isset($_REQUEST['page']))
  114. {
  115. $page = $_REQUEST['page'];
  116. }
  117. else $page = 1;
  118. $this->redirect('/user_photo_albums/manageuserphoto?menu='.$this->data['UserPhotoAlbum']['menu'].'&page='.$page);
  119. }
  120. function userphotodetails($pid=null)
  121. {
  122. $this->checkSession();
  123. $this->layout = 'default_user';
  124. }
  125. function bk_del_selected_image()
  126. {
  127. $this->checkSession();
  128. $this->layout = 'default_user';
  129. $directory = "../../user_img";
  130. /*if( !$dirhandle = @opendir($directory) )
  131. {
  132. return;
  133. }*/
  134. ### Deletion of the image file from the user_img directory
  135. $sel_img = mysql_fetch_array(mysql_query("select * from user_photo_albums where `user_id` = ".$_REQUEST['uid']." and `id` = ".$_REQUEST['pid'].""));
  136. $filename = $sel_img['pic_path'];
  137. $exp_filename = explode("/",$filename) ;
  138. $final_file = $exp_filename[4];
  139. $del_o = "../../../user_img/o/".$final_file;
  140. $del_l = "../../../user_img/l/".$final_file;
  141. $del_m = "../../../user_img/m/".$final_file;
  142. unlink($del_o);
  143. unlink($del_l);
  144. unlink($del_m);
  145. unlink($filename);
  146. ###
  147. $qry = "delete from `user_photo_albums` where `user_id` = ".$_REQUEST['uid']." and `id` = ".$_REQUEST['pid']."";
  148. $res = mysql_query($qry);
  149. $nextId = mysql_query("Select * from `user_photo_albums` where `user_id` = ".$_REQUEST['uid']." and `id` > ".$_REQUEST['pid']." order by id asc");
  150. if(mysql_num_rows($nextId)>0)
  151. {
  152. //echo "Select * from `user_photo_albums` where `user_id` = ".$_REQUEST['uid']." and `id` > ".$_REQUEST['pid']." order by id asc";
  153. $next_id_arr = mysql_fetch_array($nextId);
  154. $next_id = $next_id_arr['id'];
  155. }
  156. else
  157. {
  158. $nextId = mysql_query("Select * from `user_photo_albums` where `user_id` = ".$_REQUEST['uid']." order by id asc");
  159. $next_id_arr = mysql_fetch_array($nextId);
  160. $next_id = $next_id_arr['id'];
  161. }
  162. //$pid = $_REQUEST['pid']+1;
  163. $pid = $next_id;
  164. $this->flash('The Image with id: '.$id.' has been deleted.', '/user_photo_albums');
  165. $this->redirect('/user_photo_albums/userphotodetails?OffSet='.$_REQUEST['OffSet'].'&menu='.$_REQUEST['menu'].'&uid='.$_REQUEST['uid'].'&pid='.$pid.'&CurrentPage='.$_REQUEST['CurrentPage']);
  166. }
  167. function bk_block_selected_image()
  168. {
  169. $this->checkSession();
  170. $this->layout = 'default_user';
  171. echo $qry = "update `user_photo_albums` set `is_blocked` = '1' where `user_id` = ".$_REQUEST['uid']." and `id` = ".$_REQUEST['pid']."";
  172. $res = mysql_query($qry);
  173. $this->flash('The post with id: '.$id.' has been deleted.', '/posts');
  174. $this->redirect('/user_photo_albums/userphotodetails?OffSet='.$_REQUEST['OffSet'].'&menu='.$_REQUEST['menu'].'&uid='.$_REQUEST['uid'].'&pid='.$_REQUEST['pid'].'&CurrentPage='.$_REQUEST['CurrentPage']);
  175. }
  176. function bk_unblock_selected_image()
  177. {
  178. $this->checkSession();
  179. $this->layout = 'default_user';
  180. echo $qry = "update `user_photo_albums` set `is_blocked` = '0' where `user_id` = ".$_REQUEST['uid']." and `id` = ".$_REQUEST['pid']."";
  181. $res = mysql_query($qry);
  182. $this->flash('The post with id: '.$id.' has been deleted.', '/posts');
  183. $this->redirect('/user_photo_albums/userphotodetails?OffSet='.$_REQUEST['OffSet'].'&menu='.$_REQUEST['menu'].'&uid='.$_REQUEST['uid'].'&pid='.$_REQUEST['pid'].'&CurrentPage='.$_REQUEST['CurrentPage']);
  184. }
  185. }
  186. ?>