/admin/app/controllers/user_photo_albums_controller.php
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
- <?php
- class UserPhotoAlbumsController extends AppController
- {
- var $name='UserPhotoAlbums';
- var $components = array('Pagination');
- var $helpers = array('Pagination', 'error');
- function add_photogroup($uid=null)
- {
- $this->checkSession();
- $this->layout = 'default_user';
- $user_id=$_REQUEST['uid'];
- }
-
-
-
- function manageuserphoto()
- {
- $this->checkSession();
- $this->layout = 'default_user';
- }
- function view_photogroup($id=null , $uid=null)
- {
- $this->checkSession();
- $this->layout = 'default_user';
-
- $Qry = mysql_fetch_array(mysql_query("select * from user_albums where user_id=".$_REQUEST['uid']));
- $this->set('album', $Qry);
- /*$criteria = " 1 and UserAlbum.user_id =".$uid."";
- $order = " id ";
- $this->set('album', $this->UserAlbum->findAll($criteria, NULL, $order, NULL, NULL));*/
- }
- function delete_photogroup($id=null)
- {
- $this->checkSession();
- if(isset($_REQUEST['box']))
- {
- /////IF SEARCH IS COLLECTIVE OR CHOSEN BY ADMIN SELECTION//////
-
- $arr = $_REQUEST['box'];
- foreach($arr as $key => $value)
- {
- $sql_det = "delete from `user_photo_albums` where `user_id` = '".$value."'";
- $res_det = mysql_query($sql_det);
- }
- }
- ////IF DELETE IS FOR A SPECIFIC USER////
- else
- {
- $user_id=$_REQUEST['id'];
- $this->data['UserPhotoAlbum']['menu'] = $_REQUEST['menu'];
- $sql_det = "delete from `user_photo_albums` where `user_id` = '".$user_id."'";
- $res_det = mysql_query($sql_det);
- }
- $user_id=$_REQUEST['id'];
- $this->data['UserPhotoAlbum']['menu'] = $_REQUEST['menu'];
- if(isset($_REQUEST['page']))
- {
- $page = $_REQUEST['page'];
- }
- $this->flash('The post with id: '.$id.' has been deleted.', '/posts');
- $this->redirect('/user_photo_albums/manageuserphoto?menu='.$this->data['UserPhotoAlbum']['menu'].'&page='.$page);
- }
- function block_photogroup()
- {
-
- /////IF BLOCKING IS COLLECTIVE OR BY ADMIN SELECTION/////
- $this->checkSession();
- if(isset($_REQUEST['box']))
- {
- $arr = $_REQUEST['box'];
- foreach($arr as $key => $value)
- {
- $sql = "update `user_photo_albums` set `is_blocked` = '1' where `user_id` ='".$value."'";
- $res = mysql_query($sql);
- //$sql_user = "update `users` set `user_status` = '1' where `id` ='".$value."'";
- //$res_user = mysql_query($sql_user);
- }
- }
- ////IF BLOCKING IS FOR A SPECIFIC USER////
- else
- {
- $qry="update `user_photo_albums` set `is_blocked`='1' where `user_id`='".$_REQUEST['id']."'";
- $res=mysql_query($qry);
- //$sql_user = "update `users` set `user_status` = '1' where `id` ='".$_REQUEST['id']."'";
- //$res_user = mysql_query($sql_user);
- }
- $this->data['UserPhotoAlbum']['menu'] = $_REQUEST['menu'];
- if(isset($_REQUEST['page']))
- {
- $page = $_REQUEST['page'];
- }
- else $page = 1;
- $this->redirect('/user_photo_albums/manageuserphoto?menu='.$this->data['UserPhotoAlbum']['menu'].'&page='.$page);
-
- }
- function active_photogroup()
- {
-
- /////IF BLOCKING IS COLLECTIVE OR BY ADMIN SELECTION/////
- $this->checkSession();
- if(isset($_REQUEST['box']))
- {
- $arr = $_REQUEST['box'];
- foreach($arr as $key => $value)
- {
- $sql = "update `user_photo_albums` set `is_blocked` = '0' where `user_id` ='".$value."'";
- $res = mysql_query($sql);
- //$sql_user = "update `users` set `user_status` = '0' where `id` ='".$value."'";
- //$res_user = mysql_query($sql_user);
- }
- }
- ////IF BLOCKING IS FOR A SPECIFIC USER////
- else
- {
- $qry="update `user_photo_albums` set `is_blocked`='0' where `user_id`='".$_REQUEST['id']."'";
- $res=mysql_query($qry);
- //echo $sql_user = "update `users` set `user_status` = '0' where `id` ='".$_REQUEST['id']."'";
- //$res_user = mysql_query($sql_user);
- }
- $this->data['UserPhotoAlbum']['menu'] = $_REQUEST['menu'];
- if(isset($_REQUEST['page']))
- {
- $page = $_REQUEST['page'];
- }
- else $page = 1;
- $this->redirect('/user_photo_albums/manageuserphoto?menu='.$this->data['UserPhotoAlbum']['menu'].'&page='.$page);
-
- }
- function userphotodetails($pid=null)
- {
- $this->checkSession();
- $this->layout = 'default_user';
-
- }
- function bk_del_selected_image()
- {
- $this->checkSession();
- $this->layout = 'default_user';
- $directory = "../../user_img";
-
- /*if( !$dirhandle = @opendir($directory) )
- {
- return;
- }*/
-
- ### Deletion of the image file from the user_img directory
- $sel_img = mysql_fetch_array(mysql_query("select * from user_photo_albums where `user_id` = ".$_REQUEST['uid']." and `id` = ".$_REQUEST['pid'].""));
-
- $filename = $sel_img['pic_path'];
- $exp_filename = explode("/",$filename) ;
- $final_file = $exp_filename[4];
- $del_o = "../../../user_img/o/".$final_file;
- $del_l = "../../../user_img/l/".$final_file;
- $del_m = "../../../user_img/m/".$final_file;
- unlink($del_o);
- unlink($del_l);
- unlink($del_m);
- unlink($filename);
- ###
-
- $qry = "delete from `user_photo_albums` where `user_id` = ".$_REQUEST['uid']." and `id` = ".$_REQUEST['pid']."";
- $res = mysql_query($qry);
-
-
- $nextId = mysql_query("Select * from `user_photo_albums` where `user_id` = ".$_REQUEST['uid']." and `id` > ".$_REQUEST['pid']." order by id asc");
- if(mysql_num_rows($nextId)>0)
- {
- //echo "Select * from `user_photo_albums` where `user_id` = ".$_REQUEST['uid']." and `id` > ".$_REQUEST['pid']." order by id asc";
- $next_id_arr = mysql_fetch_array($nextId);
- $next_id = $next_id_arr['id'];
- }
- else
- {
- $nextId = mysql_query("Select * from `user_photo_albums` where `user_id` = ".$_REQUEST['uid']." order by id asc");
- $next_id_arr = mysql_fetch_array($nextId);
- $next_id = $next_id_arr['id'];
-
- }
- //$pid = $_REQUEST['pid']+1;
- $pid = $next_id;
-
- $this->flash('The Image with id: '.$id.' has been deleted.', '/user_photo_albums');
- $this->redirect('/user_photo_albums/userphotodetails?OffSet='.$_REQUEST['OffSet'].'&menu='.$_REQUEST['menu'].'&uid='.$_REQUEST['uid'].'&pid='.$pid.'&CurrentPage='.$_REQUEST['CurrentPage']);
-
-
- }
- function bk_block_selected_image()
- {
- $this->checkSession();
- $this->layout = 'default_user';
- echo $qry = "update `user_photo_albums` set `is_blocked` = '1' where `user_id` = ".$_REQUEST['uid']." and `id` = ".$_REQUEST['pid']."";
- $res = mysql_query($qry);
- $this->flash('The post with id: '.$id.' has been deleted.', '/posts');
- $this->redirect('/user_photo_albums/userphotodetails?OffSet='.$_REQUEST['OffSet'].'&menu='.$_REQUEST['menu'].'&uid='.$_REQUEST['uid'].'&pid='.$_REQUEST['pid'].'&CurrentPage='.$_REQUEST['CurrentPage']);
- }
- function bk_unblock_selected_image()
- {
- $this->checkSession();
- $this->layout = 'default_user';
- echo $qry = "update `user_photo_albums` set `is_blocked` = '0' where `user_id` = ".$_REQUEST['uid']." and `id` = ".$_REQUEST['pid']."";
- $res = mysql_query($qry);
- $this->flash('The post with id: '.$id.' has been deleted.', '/posts');
- $this->redirect('/user_photo_albums/userphotodetails?OffSet='.$_REQUEST['OffSet'].'&menu='.$_REQUEST['menu'].'&uid='.$_REQUEST['uid'].'&pid='.$_REQUEST['pid'].'&CurrentPage='.$_REQUEST['CurrentPage']);
- }
- }
- ?>