/admin/app/controllers/users_controller.php
PHP | 1513 lines | 1265 code | 169 blank | 79 comment | 158 complexity | b480491c834ad678ea69c53b422258c7 MD5 | raw file
Possible License(s): LGPL-2.1, AGPL-1.0, GPL-2.0, MIT
- <?php
- class UsersController extends AppController
- {
- var $name='Users';
- /*var $components = array('Pagination');
- var $helpers = array('Pagination', 'error');*/
- var $helpers = array('Html','Javascript','Ajax','Pagination','error');
- var $components = array('Pagination','Sendmail','Download');
- function manageuser()
- {
- $this->checkSession();
- $this->layout = 'default_user';
- $this->set('menu_id', $_REQUEST['menu']);
-
-
- ///////////*******SEARCHING FOR USER********///////////////
-
- if(isset($this->data))
- {
- if(!empty($this->data['User']['hid']))
- {
- //IF USER SEARCHED BY SEARCH FIELD//
- $criteria="1";
- if(!empty($this->data['User']['id']) || !empty($this->data['User']['username']) || !empty($this->data['User']['email']))
- {
- if($this->data['User']['id'] == "'")
- $id = "";
- else
- $id=trim($this->data['User']['id']);
- if($this->data['User']['username'] == "'")
- $usernames = "";
- else
- $usernames = trim($this->data['User']['username']);
- if($this->data['User']['email'] == "'")
- $email = "";
- else
- $email = trim($this->data['User']['email']);
- $criteria .= " and User.id LIKE '%".$id."%' and UserDetails.email LIKE '%".$email."%' and User.username LIKE '%".$usernames."%'";
- list($order,$limit,$page) = $this->Pagination->init($criteria);
- $this->set('users', $this->User->findAll($criteria, NULL, $order, $limit, $page));
- }
- else
- {
- $criteria= "1";
- if(isset($_REQUEST['page']))
- {
- $page = $_REQUEST['page'];
- }
- list($order,$limit,$page) = $this->Pagination->init($criteria);
- $this->set('users', $this->User->findAll($criteria, NULL, $order, $limit, $page));
- }
- }
- }
- //IF USER SEARCHED BY SEARCHKEY//
- else if(empty($_GET['searchkey']) && !empty($_GET['search']))
- {
- $criteria="1";
- $this->data['User']['search'] = $_GET['search'];
- $search=trim($this->data['User']['search']);
- $criteria .= " and User.username LIKE '".$search."%'";
- list($order,$limit,$page) = $this->Pagination->init($criteria);
- $this->set('users', $this->User->findAll($criteria, NULL, $order, $limit, $page));
- }
- else if(!empty($_GET['searchkey']) || !empty($_GET['search']))
- {
- $criteria="1";
- if($_GET['searchkey'] == 'block' && empty($_GET['search']))
- {
- $criteria .= " and User.user_status = '0'";
- list($order,$limit,$page) = $this->Pagination->init($criteria);
- $this->set('users', $this->User->findAll($criteria, NULL, $order, $limit, $page));
- }
- else if($_GET['searchkey'] == 'unblock' && empty($_GET['search']))
- {
- $criteria .= " and User.user_status = '1'";
- list($order,$limit,$page) = $this->Pagination->init($criteria);
- $this->set('users', $this->User->findAll($criteria, NULL, $order, $limit, $page));
- }
- else if(!empty($_GET['search']))
- {
- $this->data['User']['search'] = $_GET['search'];
- if($_GET['searchkey'] == 'block')
- $this->data['User']['searchkey'] = 0;
- else if($_GET['searchkey'] == 'unblock')
- $this->data['User']['searchkey'] = 1;
- $search=trim($this->data['User']['search']);
- $searchkey=$this->data['User']['searchkey'];
- $criteria .= " and User.username LIKE '".$search."%' and User.user_status='".$searchkey."'";
- list($order,$limit,$page) = $this->Pagination->init($criteria);
- $this->set('users', $this->User->findAll($criteria, NULL, $order, $limit, $page));
- }
- }
-
- else if(!empty($_GET['order']))
- {
- $criteria="1";
- $col = $_REQUEST['searchby'];
- if($_REQUEST['order'] == 'desc')
- {
- $order= " User.".$col." desc";
- list($order,$limit,$page) = $this->Pagination->init($criteria);
- $this->set('users', $this->User->findAll($criteria, NULL, $order, $limit, $page));
- }
- else
- {
- $order= " User.".$col." asc";
- list($order,$limit,$page) = $this->Pagination->init($criteria);
- $this->set('users', $this->User->findAll($criteria, NULL, $order, $limit, $page));
- }
- }
- else
- {
- $criteria= "1";
- list($order,$limit,$page) = $this->Pagination->init($criteria);
- $this->set('users', $this->User->findAll($criteria, NULL, $order, $limit, $page));
- }
-
- }
-
- ////////////////////******EDIT USER BY ID*******//////////////
-
- function edit_user($id = null)
- {
- $this->checkSession();
- $this->layout = 'default_user';
- $id = $_REQUEST['id'];
- if(!empty($id))
- {
-
- if(empty($this->data['User']))
- {
- $this->User->id = $_REQUEST['id'];
- $this->set('usrId', $this->User->id);
- $this->data = $this->User->read(null, $id);
- $this->set('data',$this->data);
- /* Getting some value from user details*/
- $sql_select = "select * from user_details where user_id =".$id. "";
- $res_sql_select = mysql_fetch_array(mysql_query($sql_select));
- $this->data['User']['first_name'] = stripslashes($res_sql_select['first_name']) ;
- $this->data['User']['last_name'] = stripslashes($res_sql_select['last_name']) ;
- $this->data['User']['email'] = $res_sql_select['email'] ;
- $this->data['User']['c_id'] = $res_sql_select['c_id'];
- if(!empty($res_sql_select['dob']))
- {
- $date_of_estab = explode("-",$res_sql_select['dob']) ;
-
- $this->set('org_day', $date_of_estab['2']) ;
- $this->set('org_month',$date_of_estab['1']) ;
- $this->set('org_year', $date_of_estab['0']) ;
- }
- else
- {
- $this->set('org_day', 0) ;
- $this->set('org_month',0) ;
- $this->set('org_year', 0) ;
- }
-
- }
-
- else
- {
- if (!empty($this->data))
- {
- $userId = $_REQUEST['id'];
- $this->data['User']['menu'] = $_REQUEST['menu'];
- $this->data['User']['id'] = $_REQUEST['id'];
- $this->data['User']['user_group_master_id'] = $_REQUEST['role'];
-
- $m=($_REQUEST['month']!= "0") ? $_REQUEST['month'] : "";
-
- $this->data['User']['dob'] = $_REQUEST['year']."-".$m."-"."0".$_REQUEST['date'];
-
- echo $updatUserDet = "UPDATE `user_details` SET `first_name` = '".addslashes($this->data['User']['first_name'])."', `last_name` = '".addslashes($this->data['User']['last_name'])."', `dob` = '".$this->data['User']['dob']."',`email` = '".$this->data['User']['email']."', `c_id` = ".$_REQUEST['country']." where `user_id`=".$userId;
- /* echo $ins_user_det = "insert into user_details(`user_id`, `first_name`,`last_name`,`dob`,`email`) values('".$userId."','".$this->data['User']['first_name']."','".$this->data['User']['last_name']."','".$this->data['User']['dob']."','".$this->data['User']['email']."')";exit();
- */ $res_det = mysql_query($updatUserDet);
-
-
- $this->flash('Your post has been Updated.','/users');
- $this->redirect('/users/manageuser?menu='.$this->data['User']['menu']."&page=".$_REQUEST['page']);
- }
- }
-
-
- }
-
-
- }
-
- /////////////*****DELETE USER BY ID******///////////
-
- function delete($id)
- {
- $this->checkSession();
- if(isset($_REQUEST['box']))
- {
- /////IF SEARCH IS COLLECTIVE OR CHOSEN BY ADMIN SELECTION//////
-
- $arr = $_REQUEST['box'];
- foreach($arr as $key => $value)
- {
- $sql = "delete from `users` where `id` = '".$value."'";
- $res = mysql_query($sql);
- $sql_det = "delete from `user_details` where `user_id` = '".$value."'";
- $res_det = mysql_query($sql_det);
- }
- }
- ////IF DELETE IS FOR A SPECIFIC USER////
- else
- {
- $id=$_REQUEST['id'];
- $this->data['User']['menu'] = $_REQUEST['menu'];
- $this->User->del($id);
- }
- $id=$_REQUEST['id'];
- $this->data['User']['menu'] = $_REQUEST['menu'];
- if(isset($_REQUEST['page']))
- {
- $page = $_REQUEST['page'];
- }
- $this->flash('The post with id: '.$id.' has been deleted.', '/posts');
- $this->redirect('/users/manageuser?menu='.$this->data['User']['menu'].'&page='.$page);
- }
-
- ///////***VIEW OF USER****///////
-
- function view()
- {
- $this->checkSession();
- $this->layout = 'default_user';
- $this->User->id = $_REQUEST['id'];
- $this->set('users', $this->User->read());
- }
-
- //////////******INACTIVE USER*****////////////
-
- function block()
- {
- /////IF BLOCKING IS COLLECTIVE OR BY ADMIN SELECTION/////
- $this->checkSession();
- if(isset($_REQUEST['box']))
- {
- $arr = $_REQUEST['box'];
- foreach($arr as $key => $value)
- {
- $sql = "update `users` set `user_status` = '0' where `id` ='".$value."'";
- $res = mysql_query($sql);
- }
- }
- ////IF BLOCKING IS FOR A SPECIFIC USER////
- else
- {
- $qry="update `users` set `user_status`='0' where `id`='".$_REQUEST['id']."'";
- $res=mysql_query($qry);
- }
- $this->data['User']['menu'] = $_REQUEST['menu'];
- if(isset($_REQUEST['page']))
- {
- $page = $_REQUEST['page'];
- }
- $this->redirect('/users/manageuser?menu='.$this->data['User']['menu'].'&page='.$page);
- }
-
- function active()
- {
- ///////////IF UNBLOCKING IS COLLECTIVE OR BY ADMIN SELECTION//////////
- $this->checkSession();
- if(isset($_REQUEST['box']))
- {
- $arr = $_REQUEST['box'];
- foreach($arr as $key => $value)
- {
- $sql = "update `users` set `user_status` = '1' where `id` ='".$value."'";
- $res = mysql_query($sql);
- }
- }
- ////IF UNBLOCKING IS FOR A SPECIFIC USER////
- else
- {
- $qry="update `users` set `user_status`='1' where `id`='".$_REQUEST['id']."'";
- $res=mysql_query($qry);
- }
- $this->data['User']['menu'] = $_REQUEST['menu'];
- if(isset($_REQUEST['page']))
- {
- $page = $_REQUEST['page'];
- }
- $this->redirect('/users/manageuser?menu='.$this->data['User']['menu'].'&page='.$page);
- }
-
- //////////******ADDING USER******//////////
-
- function add()
- {
- $this->checkSession();
- $this->layout = 'default_user';
- $this->pageTitle = 'Add User';
- if (!empty($this->data['User']))
- {
- $this->data['User']['menu'] = $_REQUEST['menu'];
- $this->data['User']['user_status'] = 1;
-
- $userSave = mysql_query("insert into users(id, username, password, user_group_master_id, user_status) values('', '".$this->data['User']['username']."', '".base64_encode($this->data['User']['password'])."', '".$this->data['User']['user_group_master_id']."', '".$this->data['User']['user_status']."')");
-
- $id = mysql_insert_id();
- $fname = addslashes($this->data['User']['first_name']);
- $lname = addslashes($this->data['User']['last_name']);
- $email = $this->data['User']['email'];
- if(strlen($_REQUEST['date'])!=2)
- $Dob = "0".$_REQUEST['date'];
- else $Dob = $_REQUEST['date'];
- $dob = $_REQUEST['year']."-".$_REQUEST['month']."-".$Dob;
-
- $qry = "INSERT INTO `user_details` ( `id` , `user_id`, `first_name`, `last_name`, `email`, `dob`, `c_id` )VALUES ('',".$id.",'".$fname."','".$lname."','".$email."', '".$dob."', ".$_REQUEST['country'].")" ;
- if($res = mysql_query($qry))
- {
- $this->flash('Your post has been saved.','/users');
- $this->redirect('/users/manageuser?menu='.$this->data['User']['menu']);
- }
- }
- }
- function getUseravailability()
- {
- $this->checkSession();
- }
-
- /////////////////////////////////////////////////////////////////////////////////////////
-
- ////////////////////////////ORGANISATION PART///////////////////////////////////////////
-
- /////////////////////////////////////////////////////////////////////////////////////////
- function manageorg()
- {
- $this->checkSession();
- $this->layout = 'default_user';
- $this->pageTitle = 'Manage Organisation';
- $this->set('menu_id', $_REQUEST['menu']);
- if(isset($this->data))
- {
- if(!empty($this->data['User']['hid']))
- {
- //IF USER SEARCHED BY SEARCH FIELD//
- $criteria="1";
- if(!empty($this->data['User']['id']) || !empty($this->data['User']['username']) || !empty($this->data['User']['email']))
- {
- if($this->data['User']['id'] == "'")
- $id = "";
- else
- $id=trim($this->data['User']['id']);
- if($this->data['User']['username'] == "'")
- $usernames = "";
- else
- $usernames = trim($this->data['User']['username']);
- if($this->data['User']['email'] == "'")
- $email = "";
- else
- $email = trim($this->data['User']['email']);
- /*$criteria .= " and User.id LIKE '%".$id."%' and User.email LIKE '%".$email."%' and User.username LIKE '%".$usernames."%' and User.user_group_master_id=4";*/
- $criteria .= " and User.id LIKE '%".$id."%' and User.username LIKE '%".$usernames."%' and User.user_group_master_id=3 ";
- if($email!="")
- $criteria .= " and UserDetails.email LIKE '%".$email."%' and User.user_group_master_id=3" ;
-
- list($order,$limit,$page) = $this->Pagination->init($criteria);
- $this->set('users', $this->User->findAll($criteria, NULL, $order, $limit, $page));
- }
- else
- {
- $criteria= "1 and User.user_group_master_id=3";
- if(isset($_REQUEST['page']))
- {
- $page = $_REQUEST['page'];
- }
- list($order,$limit,$page) = $this->Pagination->init($criteria);
- $this->set('users', $this->User->findAll($criteria, NULL, $order, $limit, $page));
- }
- }
- }
- else if(empty($_GET['searchkey']) && !empty($_GET['search']))
- {
- $criteria="1";
- $this->data['User']['search'] = $_GET['search'];
- $search=trim($this->data['User']['search']);
- $criteria .= " and User.username LIKE '".$search."%' and User.user_group_master_id=3";
- list($order,$limit,$page) = $this->Pagination->init($criteria);
- $this->set('users', $this->User->findAll($criteria, NULL, $order, $limit, $page));
- }
- else if(!empty($_GET['searchkey']) || !empty($_GET['search']))
- {
- $criteria="1";
- if($_GET['searchkey'] == 'block' && empty($_GET['search']))
- {
- $criteria .= " and User.user_status = '0' and User.user_group_master_id=3";
- list($order,$limit,$page) = $this->Pagination->init($criteria);
- $this->set('users', $this->User->findAll($criteria, NULL, $order, $limit, $page));
- }
- else if($_GET['searchkey'] == 'unblock' && empty($_GET['search']))
- {
- $criteria .= " and User.user_status = '1' and User.user_group_master_id=3";
- list($order,$limit,$page) = $this->Pagination->init($criteria);
- $this->set('users', $this->User->findAll($criteria, NULL, $order, $limit, $page));
- }
- else if(!empty($_GET['search']))
- {
- $this->data['User']['search'] = $_GET['search'];
- if($_GET['searchkey'] == 'block')
- $this->data['User']['searchkey'] = 0;
- else if($_GET['searchkey'] == 'unblock')
- $this->data['User']['searchkey'] = 1;
- $search=trim($this->data['User']['search']);
- $searchkey=$this->data['User']['searchkey'];
- $criteria .= " and User.username LIKE '".$search."%' and User.status='".$searchkey."' and User.user_group_master_id=3";
- list($order,$limit,$page) = $this->Pagination->init($criteria);
- $this->set('users', $this->User->findAll($criteria, NULL, $order, $limit, $page));
- }
- }
- else
- {
- $criteria= "where User.user_group_master_id=3";
- list($order,$limit,$page) = $this->Pagination->init($criteria);
- $this->set('users', $this->User->findAll($criteria, NULL, $order, $limit, $page));
- }
- }
- function add_organisation()
- {
- $this->checkSession();
- $this->layout = 'default_user';
- $this->pageTitle = 'Add Organisation';
-
- if (!empty($this->data['User']))
- {
- $this->data['User']['menu'] = $_REQUEST['menu'];
- $this->data['User']['user_status'] = 1;
- $this->data['User']['user_group_master_id'] = 3;
-
- $usrqry = "insert into users(id, username, password, user_group_master_id, user_status) values('', '".$this->data['User']['username']."', '".base64_encode($this->data['User']['password'])."', ".$this->data['User']['user_group_master_id'].", '".$this->data['User']['user_status']."')";
- $userSave = mysql_query($usrqry);
-
- $id = mysql_insert_id();
- $fname = addslashes($this->data['User']['first_name']);
- $lname = addslashes($this->data['User']['last_name']);
- $email = $this->data['User']['email'];
- $dob = $_REQUEST['year']."-".$_REQUEST['month']."-".$_REQUEST['org_date'];
-
- echo $qry = "INSERT INTO `user_details` ( `id` , `user_id`, `first_name`, `last_name`, `email`, `dob`, `c_id` )VALUES ('',".$id.",'".$fname."','".$lname."','".$email."', '".$dob."', ".$_REQUEST['country'].")" ;
- if($res = mysql_query($qry))
- {
- $this->flash('Your post has been saved.','/users');
- $this->redirect('/users/manageorg?menu='.$this->data['User']['menu']);
- }
- }
- }
-
- function edit_organisation($id = null)
- {
-
- $this->checkSession();
- $this->layout = 'default_user';
- $id = $_REQUEST['id'];
- $this->set('usrId', $id);
- if(!empty($id))
- {
-
- if(empty($this->data['User']))
- {
- $this->User->id = $_REQUEST['id'];
- $this->data = $this->User->read(null, $id);
- $this->set('data',$this->data);
- /* Getting some value from user details*/
- $sql_select = "select * from user_details where user_id =".$id. "";
- $res_sql_select = mysql_fetch_array(mysql_query($sql_select));
- $this->data['User']['first_name'] = stripslashes($res_sql_select['first_name']) ;
- $this->data['User']['last_name'] = stripslashes($res_sql_select['last_name']) ;
- $this->data['User']['email'] = $res_sql_select['email'] ;
- $this->set('country_id', $res_sql_select['c_id']);
- $date_of_estab = explode("-",$res_sql_select['dob']) ;
-
- $this->set('org_day', $date_of_estab['2']) ;
- $this->set('org_month',$date_of_estab['1']) ;
- $this->set('org_year', $date_of_estab['0']) ;
- /**/
-
- }
-
- else
- {
- if (!empty($this->data))
- {
- $this->data['User']['menu'] = $_REQUEST['menu'];
- $this->data['User']['id'] = $_REQUEST['id'];
- $this->data['User']['group_master_id'] = 3;
- //echo $userId = $_REQUEST['id'];
-
- $m=($_REQUEST['estmon']!= "0") ? $_REQUEST['estmon'] : "";
-
- $this->data['User']['dob'] = $_REQUEST['estyear']."-".$m."-".$_REQUEST['estdate'];
-
- $qry_org = "Update user_details SET first_name = '".addslashes($this->data['User']['first_name'])."', last_name = '".addslashes($this->data['User']['last_name'])."', dob='".$this->data['User']['dob']."',email = '".$this->data['User']['email']."', `c_id` = ".$_REQUEST['country']." where user_id=".$this->data['User']['id']."";
- $res = mysql_query($qry_org);
-
-
- $this->flash('Your post has been Updated.','/users');
- $this->redirect('/users/manageorg?menu='.$this->data['User']['menu']);
- }
- }
-
-
- }
-
- }
-
- function delete_organisation($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)
- {
- //echo $sql = "delete from `users` where `id` = '".$value."'";exit();
- $res = mysql_query($sql);
- /* Delete the record from user details table*/
- $sql_user_detail = "delete from user_details where user_id = '".$value."'" ;
- $res_user_detail = mysql_query($sql_user_detail);
- }
- }
- ////IF DELETE IS FOR A SPECIFIC USER////
- else
- {
- $id=$_REQUEST['id'];
- $this->data['User']['menu'] = $_REQUEST['menu'];
- $this->User->del($id);
- /* Delete the record from user details table*/
- $sql_user_detail = "delete from user_details where user_id = '".$id."'" ;
- $res_user_detail = mysql_query($sql_user_detail);
- }
- $id=$_REQUEST['id'];
- $this->data['User']['menu'] = $_REQUEST['menu'];
- if(isset($_REQUEST['page']))
- {
- $page = $_REQUEST['page'];
- }
- $this->flash('The post with id: '.$id.' has been deleted.', '/posts');
- $this->redirect('/users/manageorg?menu='.$this->data['User']['menu'].'&page='.$page);
- }
-
- function organisation_view($id = null)
- {
- $this->checkSession();
- $this->layout = 'default_user';
- $this->User->id = $_REQUEST['id'];
- $id = $_REQUEST['id'];
- $this->data = $this->User->read(null, $id);
- $this->set('data',$this->data);
- /* Getting some value from user details*/
- $sql_select = "select * from user_details where user_id =".$id. "";
- //echo "xxxx".$sql_select ;
- $res_sql_select = mysql_fetch_array(mysql_query($sql_select));
- $this->data['User']['org_name'] = $res_sql_select['org_name'] ;
- $date_of_estab = explode("-",$res_sql_select['dob']) ;
-
-
- $group_sql = mysql_fetch_array(mysql_query("select group_cat_name from user_group_masters where id=".$this->data['User']['user_group_master_id'].""));
-
-
- $this->set('org_day', $date_of_estab['2']) ;
- $this->set('org_month',$date_of_estab['1']) ;
- $this->set('org_year', $date_of_estab['0']) ;
- $this->set('group_name', $group_sql['group_cat_name']) ;
- /**/
- }
-
- function organisation_active()
- {
-
- ///////////IF UNBLOCKING IS COLLECTIVE OR BY ADMIN SELECTION//////////
- $this->checkSession();
- if(isset($_REQUEST['box']))
- {
- $arr = $_REQUEST['box'];
- foreach($arr as $key => $value)
- {
- $sql = "update `users` set `user_status` = '0' where `id` ='".$value."'";
- $res = mysql_query($sql);
- }
- }
- ////IF UNBLOCKING IS FOR A SPECIFIC USER////
- else
- {
- $qry="update `users` set `user_status`='0' where `id`='".$_REQUEST['id']."'";
- $res=mysql_query($qry);
- }
- $this->data['User']['menu'] = $_REQUEST['menu'];
- if(isset($_REQUEST['page']))
- {
- $page = $_REQUEST['page'];
- }
- $this->redirect('/users/manageorg?menu='.$this->data['User']['menu'].'&page='.$page);
-
- }
- function organisation_block()
- {
- /////IF BLOCKING IS COLLECTIVE OR BY ADMIN SELECTION/////
- $this->checkSession();
- if(isset($_REQUEST['box']))
- {
- $arr = $_REQUEST['box'];
- foreach($arr as $key => $value)
- {
- $sql = "update `users` set `user_status` = '1' where `id` ='".$value."'";
- $res = mysql_query($sql);
- }
- }
- ////IF BLOCKING IS FOR A SPECIFIC USER////
- else
- {
- $qry="update `users` set `user_status`='1' where `id`='".$_REQUEST['id']."'";
- $res=mysql_query($qry);
- }
- $this->data['User']['menu'] = $_REQUEST['menu'];
- if(isset($_REQUEST['page']))
- {
- $page = $_REQUEST['page'];
- }
- $this->redirect('/users/manageorg?menu='.$this->data['User']['menu'].'&page='.$page);
-
- }
-
- function manageorgrating()
- {
- $this->checkSession();
- $this->layout = 'default_user';
- $this->set('menu_id', $_REQUEST['menu']);
- if(isset($this->data))
- {
- if(!empty($this->data['User']['hid']))
- {
- //IF USER SEARCHED BY SEARCH FIELD//
- $criteria="1";
- if(!empty($this->data['User']['id']) || !empty($this->data['User']['username']) || !empty($this->data['User']['email']))
- {
- if($this->data['User']['id'] == "'")
- $id = "";
- else
- $id=trim($this->data['User']['id']);
- if($this->data['User']['username'] == "'")
- $usernames = "";
- else
- $usernames = trim($this->data['User']['username']);
- if($this->data['User']['email'] == "'")
- $email = "";
- else
- $email = trim($this->data['User']['email']);
- /*$criteria .= " and User.id LIKE '%".$id."%' and User.email LIKE '%".$email."%' and User.username LIKE '%".$usernames."%' and User.user_group_master_id=4";*/
- $criteria .= " and User.id LIKE '%".$id."%' and User.username LIKE '%".$usernames."%' ";
- if($email!="")
- $criteria .= " and UserDetails.email LIKE '%".$email."%'" ;
-
-
- $criteria .=" and User.user_group_master_id=3 ";
-
- list($order,$limit,$page) = $this->Pagination->init($criteria);
- $this->set('users', $this->User->findAll($criteria, NULL, $order, $limit, $page));
- }
- else
- {
- $criteria= "1";
- if(isset($_REQUEST['page']))
- {
- $page = $_REQUEST['page'];
- }
- $criteria .=" and User.user_group_master_id=3 ";
- list($order,$limit,$page) = $this->Pagination->init($criteria);
- $this->set('users', $this->User->findAll($criteria, NULL, $order, $limit, $page));
- }
- }
- }
- else if(empty($_GET['searchkey']) && !empty($_GET['search']))
- {
- $criteria="1";
- $this->data['User']['search'] = $_GET['search'];
- $search=trim($this->data['User']['search']);
- $criteria .= " and User.username LIKE '".$search."%' and User.user_group_master_id=3";
- list($order,$limit,$page) = $this->Pagination->init($criteria);
- $this->set('users', $this->User->findAll($criteria, NULL, $order, $limit, $page));
- }
- else if(!empty($_GET['searchkey']) || !empty($_GET['search']))
- {
- $criteria="1";
- if($_GET['searchkey'] == 'block' && empty($_GET['search']))
- {
- $criteria .= " and User.user_status = '1' and User.user_group_master_id=3";
- list($order,$limit,$page) = $this->Pagination->init($criteria);
- $this->set('users', $this->User->findAll($criteria, NULL, $order, $limit, $page));
- }
- else if($_GET['searchkey'] == 'unblock' && empty($_GET['search']))
- {
- $criteria .= " and User.user_status = '0' and User.user_group_master_id=3";
- list($order,$limit,$page) = $this->Pagination->init($criteria);
- $this->set('users', $this->User->findAll($criteria, NULL, $order, $limit, $page));
- }
- else if(!empty($_GET['search']))
- {
- $this->data['User']['search'] = $_GET['search'];
- if($_GET['searchkey'] == 'block')
- $this->data['User']['searchkey'] = 0;
- else if($_GET['searchkey'] == 'unblock')
- $this->data['User']['searchkey'] = 1;
- $search=trim($this->data['User']['search']);
- $searchkey=$this->data['User']['searchkey'];
- $criteria .= " and User.username LIKE '".$search."%' and User.status='".$searchkey."' and User.user_group_master_id=3";
- list($order,$limit,$page) = $this->Pagination->init($criteria);
- $this->set('users', $this->User->findAll($criteria, NULL, $order, $limit, $page));
- }
- }
- else
- {
- $criteria= " User.user_group_master_id=3";
- list($order,$limit,$page) = $this->Pagination->init($criteria);
- $this->set('users', $this->User->findAll($criteria, NULL, $order, $limit, $page));
- }
-
-
- }
- /////////////////////////////////////////////////////////////////////////////////////////
-
- ////////////////////////////End of ORGANISATION PART///////////////////////////////////////////
-
- /////////////////////////////////////////////////////////////////////////////////////////
-
- /////////////////////////////////////////////////////////////////////////////////////////
-
- ////////////////////////////PHOTOGRAPHER PART///////////////////////////////////////////
-
- /////////////////////////////////////////////////////////////////////////////////////////
- function managephoto()
- {
-
- $this->checkSession();
- $this->layout = 'default_user';
- $this->pageTitle = 'Manage Photographer';
- $this->set('menu_id', $_REQUEST['menu']);
- if(isset($this->data))
- {
- if(!empty($this->data['User']['hid']))
- {
- //IF USER SEARCHED BY SEARCH FIELD//
- $criteria="1";
- if(!empty($this->data['User']['id']) || !empty($this->data['User']['username']) || !empty($this->data['User']['email']))
- {
- if($this->data['User']['id'] == "'")
- $id = "";
- else
- $id=trim($this->data['User']['id']);
- if($this->data['User']['username'] == "'")
- $usernames = "";
- else
- $usernames = trim($this->data['User']['username']);
- if($this->data['User']['email'] == "'")
- $email = "";
- else
- $email = trim($this->data['User']['email']);
- /*$criteria .= " and User.id LIKE '%".$id."%' and User.email LIKE '%".$email."%' and User.username LIKE '%".$usernames."%' and User.user_group_master_id=4";*/
- $criteria .= " and User.id LIKE '%".$id."%' and User.username LIKE '%".$usernames."%' and User.user_group_master_id=2 ";
- if($email!="")
- $criteria .= " and UserDetails.email LIKE '%".$email."%'" ;
-
- list($order,$limit,$page) = $this->Pagination->init($criteria);
- $this->set('users', $this->User->findAll($criteria, NULL, $order, $limit, $page));
- }
- else
- {
- $criteria= "1";
- if(isset($_REQUEST['page']))
- {
- $page = $_REQUEST['page'];
- }
- $criteria .=" and User.user_group_master_id=2 ";
- list($order,$limit,$page) = $this->Pagination->init($criteria);
- $this->set('users', $this->User->findAll($criteria, NULL, $order, $limit, $page));
- }
- }
- }
- else if(empty($_GET['searchkey']) && !empty($_GET['search']))
- {
- $criteria="1";
- $this->data['User']['search'] = $_GET['search'];
- $search=trim($this->data['User']['search']);
- $criteria .= " and User.username LIKE '".$search."%' and User.user_group_master_id=2";
- list($order,$limit,$page) = $this->Pagination->init($criteria);
- $this->set('users', $this->User->findAll($criteria, NULL, $order, $limit, $page));
- }
- else if(!empty($_GET['searchkey']) || !empty($_GET['search']))
- {
- $criteria="1";
- if($_GET['searchkey'] == 'block' && empty($_GET['search']))
- {
- $criteria .= " and User.user_status = '0' and User.user_group_master_id=2";
- list($order,$limit,$page) = $this->Pagination->init($criteria);
- $this->set('users', $this->User->findAll($criteria, NULL, $order, $limit, $page));
- }
- else if($_GET['searchkey'] == 'unblock' && empty($_GET['search']))
- {
- $criteria .= " and User.user_status = '1' and User.user_group_master_id=2";
- list($order,$limit,$page) = $this->Pagination->init($criteria);
- $this->set('users', $this->User->findAll($criteria, NULL, $order, $limit, $page));
- }
- else if(!empty($_GET['search']))
- {
- $this->data['User']['search'] = $_GET['search'];
- if($_GET['searchkey'] == 'block')
- $this->data['User']['searchkey'] = 0;
- else if($_GET['searchkey'] == 'unblock')
- $this->data['User']['searchkey'] = 1;
- $search=trim($this->data['User']['search']);
- $searchkey=$this->data['User']['searchkey'];
- $criteria .= " and User.username LIKE '".$search."%' and User.status='".$searchkey."' and User.user_group_master_id=2";
- list($order,$limit,$page) = $this->Pagination->init($criteria);
- $this->set('users', $this->User->findAll($criteria, NULL, $order, $limit, $page));
- }
- }
- else
- {
- $criteria= "where User.user_group_master_id=2";
- list($order,$limit,$page) = $this->Pagination->init($criteria);
- $this->set('users', $this->User->findAll($criteria, NULL, $order, $limit, $page));
- }
-
- }
- function add_photographer()
- {
-
- $this->checkSession();
- $this->layout = 'default_user';
- $this->pageTitle = 'Add Photographer';
-
- if (!empty($this->data['User']))
- {
- $this->data['User']['menu'] = $_REQUEST['menu'];
- $this->data['User']['user_status'] = 1;
- $this->data['User']['user_group_master_id'] = 2;
-
- $userSave = mysql_query("insert into users(id, username, password, user_group_master_id, user_status) values('', '".$this->data['User']['username']."', '".base64_encode($this->data['User']['password'])."', '".$this->data['User']['user_group_master_id']."', '".$this->data['User']['user_status']."')");
-
- $id = mysql_insert_id();
- $fname = addslashes($this->data['User']['first_name']);
- $lname = addslashes($this->data['User']['last_name']);
- $email = $this->data['User']['email'];
-
- $qry = "INSERT INTO `user_details` ( `id` , `user_id`, `first_name`, `last_name`, `email`, `c_id` )VALUES ('',".$id.",'".$fname."','".$lname."','".$email."', ".$_REQUEST['country'].")" ;
- if($res = mysql_query($qry))
- {
- $this->flash('Your post has been saved.','/users');
- $this->redirect('/users/managephoto?menu='.$this->data['User']['menu']);
- }
- }
-
- }
- function edit_photographer($id = null)
- {
-
- $this->checkSession();
- $this->layout = 'default_user';
- $id = $_REQUEST['id'];
- $this->set('usrId', $id);
- if(!empty($id))
- {
-
- if(empty($this->data['User']))
- {
- $this->User->id = $_REQUEST['id'];
- $this->data = $this->User->read(null, $id);
- $this->set('data',$this->data);
- /* Getting some value from user details*/
- $sql_select = "select * from user_details where user_id =".$id. "";
- $res_sql_select = mysql_fetch_array(mysql_query($sql_select));
- $this->data['User']['first_name'] = stripslashes($res_sql_select['first_name']) ;
- $this->data['User']['last_name'] = stripslashes($res_sql_select['last_name']) ;
- $this->data['User']['email'] = $res_sql_select['email'] ;
- $this->set('country_id', $res_sql_select['c_id']);
-
- /**/
-
- }
-
- else
- {
-
-
- if (!empty($this->data))
- {
- $this->data['User']['menu'] = $_REQUEST['menu'];
- $this->data['User']['id'] = $_REQUEST['id'];
- $this->data['User']['group_master_id'] = 2;
- $userId = $_REQUEST['id'];
-
-
- $qry_org = "Update user_details SET first_name = '".addslashes($this->data['User']['first_name'])."', last_name = '".addslashes($this->data['User']['last_name'])."',email = '".$this->data['User']['email']."', `c_id` = ".$_REQUEST['country']." where user_id=".$this->data['User']['id']."";
- $res = mysql_query($qry_org);
-
-
- $this->flash('Your post has been Updated.','/users');
- $this->redirect('/users/managephoto?menu='.$this->data['User']['menu']);
- }
- }
-
-
- }
-
- }
- function delete_photographer($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 = "delete from `users` where `id` = '".$value."'";
- $res = mysql_query($sql);
- /* Delete the record from user details table*/
- $sql_user_detail = "delete from user_details where user_id = '".$value."'" ;
- $res_user_detail = mysql_query($sql_user_detail);
- }
- }
- ////IF DELETE IS FOR A SPECIFIC USER////
- else
- {
- $id=$_REQUEST['id'];
- $this->data['User']['menu'] = $_REQUEST['menu'];
- $this->User->del($id);
- /* Delete the record from user details table*/
- $sql_user_detail = "delete from user_details where user_id = '".$id."'" ;
- $res_user_detail = mysql_query($sql_user_detail);
- }
- $id=$_REQUEST['id'];
- $this->data['User']['menu'] = $_REQUEST['menu'];
- if(isset($_REQUEST['page']))
- {
- $page = $_REQUEST['page'];
- }
- $this->flash('The post with id: '.$id.' has been deleted.', '/posts');
- $this->redirect('/users/managephoto?menu='.$this->data['User']['menu'].'&page='.$page);
-
- }
-
- function photographer_view($id = null)
- {
-
- $this->checkSession();
- $this->layout = 'default_user';
- $this->User->id = $_REQUEST['id'];
- $id = $_REQUEST['id'];
- $this->data = $this->User->read(null, $id);
- $this->set('data',$this->data);
- /* Getting some value from user details*/
- $sql_select = "select * from user_details where user_id =".$id. "";
- //echo "xxxx".$sql_select ;
- $res_sql_select = mysql_fetch_array(mysql_query($sql_select));
- $this->data['User']['org_name'] = $res_sql_select['org_name'] ;
- /*if($res_sql_select['dob']!= '0000-00-00' || !is_null($res_sql_select['dob']) || $res_sql_select['dob']!='')
- {
- //echo $res_sql_select['dob'];exit();
- $date_of_estab = explode("-",$res_sql_select['dob']) ;
- $this->set('org_day', $date_of_estab['2']) ;
- $this->set('org_month',$date_of_estab['1']) ;
- $this->set('org_year', $date_of_estab['0']) ;
- }*/
-
- $group_sql = mysql_fetch_array(mysql_query("select group_cat_name from user_group_masters where id=".$this->data['User']['user_group_master_id'].""));
-
-
-
- $this->set('group_name', $group_sql['group_cat_name']) ;
- /**/
-
- }
-
- function photographer_active()
- {
-
-
- ///////////IF UNBLOCKING IS COLLECTIVE OR BY ADMIN SELECTION//////////
- $this->checkSession();
- if(isset($_REQUEST['box']))
- {
- $arr = $_REQUEST['box'];
- foreach($arr as $key => $value)
- {
- $sql = "update `users` set `user_status` = '0' where `id` ='".$value."'";
- $res = mysql_query($sql);
- }
- }
- ////IF UNBLOCKING IS FOR A SPECIFIC USER////
- else
- {
- $qry="update `users` set `user_status`='0' where `id`='".$_REQUEST['id']."'";
- $res=mysql_query($qry);
- }
- $this->data['User']['menu'] = $_REQUEST['menu'];
- if(isset($_REQUEST['page']))
- {
- $page = $_REQUEST['page'];
- }
- $this->redirect('/users/managephoto?menu='.$this->data['User']['menu'].'&page='.$page);
-
-
- }
-
- function photographer_block()
- {
-
- /////IF BLOCKING IS COLLECTIVE OR BY ADMIN SELECTION/////
- $this->checkSession();
- if(isset($_REQUEST['box']))
- {
- $arr = $_REQUEST['box'];
- foreach($arr as $key => $value)
- {
- $sql = "update `users` set `user_status` = '1' where `id` ='".$value."'";
- $res = mysql_query($sql);
- }
- }
- ////IF BLOCKING IS FOR A SPECIFIC USER////
- else
- {
- $qry="update `users` set `user_status`='1' where `id`='".$_REQUEST['id']."'";
- $res=mysql_query($qry);
- }
- $this->data['User']['menu'] = $_REQUEST['menu'];
- if(isset($_REQUEST['page']))
- {
- $page = $_REQUEST['page'];
- }
- $this->redirect('/users/managephoto?menu='.$this->data['User']['menu'].'&page='.$page);
-
-
- }
-
- function projectBidded($id=null)
- {
- $this->checkSession();
- $this->layout= 'default_user_cat';
- $this->pageTitle = 'Photographer Projects Bidded';
- $this->layout = 'default_user_cat';
-
- $criteria = " `User.id` = ".$_REQUEST['id']."" ;
- list($order,$limit,$page) = $this->Pagination->init($criteria);
- $this->set('projects', $this->User->findAll($criteria, NULL, $order, $limit, $page));
- }
-
- function projectWinning($id=null)
- {
- $this->checkSession();
- $this->layout= 'default_user_cat';
- $this->pageTitle = 'Photographer Projects Winning';
- $this->layout = 'default_user_cat';
-
- $criteria = " `User.id` = ".$_REQUEST['id']."" ;
- list($order,$limit,$page) = $this->Pagination->init($criteria);
- $this->set('projects', $this->User->findAll($criteria, NULL, $order, $limit, $page));
- }
-
- function managephotorating()
- {
-
- $this->checkSession();
- $this->layout = 'default_user';
- $this->set('menu_id', $_REQUEST['menu']);
- if(isset($this->data))
- {
- if(!empty($this->data['User']['hid']))
- {
- //IF USER SEARCHED BY SEARCH FIELD//
- $criteria="1";
- if(!empty($this->data['User']['id']) || !empty($this->data['User']['username']) || !empty($this->data['User']['email']))
- {
- $id=trim($this->data['User']['id']);
- $usernames = trim($this->data['User']['username']);
- $email = trim($this->data['User']['email']);
- /*$criteria .= " and User.id LIKE '%".$id."%' and User.email LIKE '%".$email."%' and User.username LIKE '%".$usernames."%' and User.user_group_master_id=4";*/
- $criteria .= " and User.id LIKE '%".$id."%' and User.username LIKE '%".$usernames."%' ";
- if($email!="")
- $criteria .= " and UserDetails.email LIKE '%".$email."%'" ;
-
-
- $criteria .=" and User.user_group_master_id=3 ";
-
- list($order,$limit,$page) = $this->Pagination->init($criteria);
- $this->set('users', $this->User->findAll($criteria, NULL, $order, $limit, $page));
- }
- else
- {
- $criteria= "1";
- if(isset($_REQUEST['page']))
- {
- $page = $_REQUEST['page'];
- }
- $criteria .=" and User.user_group_master_id=3 ";
- list($order,$limit,$page) = $this->Pagination->init($criteria);
- $this->set('users', $this->User->findAll($criteria, NULL, $order, $limit, $page));
- }
- }
- }
- else if(empty($_GET['searchkey']) && !empty($_GET['search']))
- {
- $criteria="1";
- $this->data['User']['search'] = $_GET['search'];
- $search=trim($this->data['User']['search']);
- $criteria .= " and User.username LIKE '".$search."%' and User.user_group_master_id=3";
- list($order,$limit,$page) = $this->Pagination->init($criteria);
- $this->set('users', $this->User->findAll($criteria, NULL, $order, $limit, $page));
- }
- else if(!empty($_GET['searchkey']) || !empty($_GET['search']))
- {
- $criteria="1";
- if($_GET['searchkey'] == 'block' && empty($_GET['search']))
- {
- $criteria .= " and User.user_status = '1' and User.user_group_master_id=3";
- list($order,$limit,$page) = $this->Pagination->init($criteria);
- $this->set('users', $this->User->findAll($criteria, NULL, $order, $limit, $page));
- }
- else if($_GET['searchkey'] == 'unblock' && empty($_GET['search']))
- {
- $criteria .= " and User.user_status = '0' and User.user_group_master_id=3";
- list($order,$limit,$page) = $this->Pagination->init($criteria);
- $this->set('users', $this->User->findAll($criteria, NULL, $order, $limit, $page));
- }
- else if(!empty($_GET['search']))
- {
- $this->data['User']['search'] = $_GET['search'];
- if($_GET['searchkey'] == 'block')
- $this->data['User']['searchkey'] = 0;
- else if($_GET['searchkey'] == 'unblock')
- $this->data['User']['searchkey'] = 1;
- $search=trim($this->data['User']['search']);
- $searchkey=$this->data['User']['searchkey'];
- $criteria .= " and User.username LIKE '".$search."%' and User.status='".$searchkey."' and User.user_group_master_id=3";
- list($order,$limit,$page) = $this->Pagination->init($criteria);
- $this->set('users', $this->User->findAll($criteria, NULL, $order, $limit, $page));
- }
- }
- else
- {
- $criteria= " User.user_group_master_id=3";
- list($order,$limit,$page) = $this->Pagination->init($criteria);
- $this->set('users', $this->User->findAll($criteria, NULL, $order, $limit, $page));
- }
-
-
-
- }
-
- /////////////////////////////////////////////////////////////////////////////////////////
-
- ////////////////////////////END OF PHOTOGRAPHER PART///////////////////////////////////////////
-
- /////////////////////////////////////////////////////////////////////////////////////////
-
-
- /////////////////////////////////////////////////////////////////////////////////////////
-
- ////////////////////////////START OF USER PHOT UPLOAD PART///////////////////////////////////////////
-
- /////////////////////////////////////////////////////////////////////////////////////////
- function manageuserphoto()
- {
-
- $this->checkSession();
- $this->layout = 'default_user';
- $this->set('menu_id', $_REQUEST['menu']);
-
-
- ///////////*******SEARCHING FOR USER********///////////////
-
- if(isset($this->data))
- {
- if(!empty($this->data['User']['hid']))
- {
- //IF USER SEARCHED BY SEARCH FIELD//
- $criteria="1";
- if(!empty($this->data['User']['id']) || !empty($this->data['User']['username']) || !empty($this->data['User']['email']))
- {
- $id=trim($this->data['User']['id']);
- $usernames = trim($this->data['User']['username']);
- $email = trim($this->data['User']['email']);
- $criteria .= " and User.id LIKE '%".$id."%' and User.email LIKE '%".$email."%' and User.username LIKE '%".$usernames."%'";
-
- list($order,$limit,$page) = $this->Pagination->init($criteria);
- $this->set('users', $this->User->findAll($criteria, NULL, $order, $limit, $page));
- }
- else
- {
- $criteria= "1";
- if(isset($_REQUEST['page']))
- {
- $page = $_REQUEST['page'];
- }
- list($order,$limit,$page) = $this->Pagination->init($criteria);
- $this->set('users', $this->User->findAll($criteria, NULL, $order, $limit, $page));
- }
- }
- }
- //IF USER SEARCHED BY SEARCHKEY//
- else if(empty($_GET['searchkey']) && !empty($_GET['search']))
- {
- $criteria="1 ";
- $this->data['User']['search'] = $_GET['search'];
- $search=trim($this->data['User']['search']);
- $criteria .= " and User.username LIKE '".$search."%'";
- list($order,$limit,$page) = $this->Pagination->init($criteria);
- $this->set('users', $this->User->findAll($criteria, NULL, $order, $limit, $page));
- }
- else if(!empty($_GET['searchkey']) || !empty($_GET['search']))
- {
- $criteria="1";
- if($_GET['searchkey'] == 'block' && empty($_GET['search']))
- {
- $criteria .= " and User.status = '0'";
- list($order,$limit,$page) = $this->Pagination->init($criteria);
- $this->set('users', $this->User->findAll($criteria, NULL, $order, $limit, $page));
- }
- else if($_GET['searchkey'] == 'unblock' && empty($_GET['search']))
- {
- $criteria .= " and User.status = '1'";
- list($order,$limit,$page) = $this->Pagination->init($criteria);
- $this->set('users', $this->User->findAll($criteria, NULL, $order, $limit, $page));
- }
- else if(!empty($_GET['search']))
- {
- $this->data['User']['search'] = $_GET['search'];
- if($_GET['searchkey'] == 'block')
- $this->data['User']['searchkey'] = 0;
- else if($_GET['searchkey'] == 'unblock')
- $this->data['User']['searchkey'] = 1;
- $search=trim($this->data['User']['search']);
- $searchkey=$this->data['User']['searchkey'];
- $criteria .= " and User.username LIKE '".$search."%' and User.status='".$searchkey."'";
- list($order,$limit,$page) = $this->Pagination->init($criteria);
- $this->set('users', $this->User->findAll($criteria, NULL, $order, $limit, $page));
- }
- }
-
- else if(!empty($_GET['order']))
- {
- $criteria="1";
- $col = $_REQUEST['searchby'];
- if($_REQUEST['order'] == 'desc')
- {
- $order= " User.".$col." desc";
- list($order,$limit,$page) = $this->Pagination->init($criteria);
- $this->set('users', $this->User->findAll($criteria, NULL, $order, $limit, $page));
- }
- else
- {
- $order= " User.".$col." asc";
- list($order,$limit,$page) = $this->Pagination->init($criteria);
- $this->set('users', $this->User->findAll($criteria, NULL, $order, $limit, $page));
- }
- }
- else
- {
- //$criteria= "1";
- //list($order,$limit,$page) = $this->Pagination->init($criteria);
- //$this->set('users', $this->User->findAll($criteria, NULL, $order, $limit, $page));
- //$qry = "select * from users as User, user_photo_albums as UserPhotoAlbum where User.id = UserPhotoAlbum.user_id";
- $this->User->unbindModel(array('hasOne' => array('UserDetails')));
- //$this->User->UserPhotoAlbum->bindModel(array('belongsTo' => array('User', 'UserPhotoAlbum')));
- //$users = $this->User->UserPhotoAlbum->findAll(array('UserPhotoAlbum.user_id' => 3));
- //$this->User->unbindModel(array('hasMany' => array('UserPhotoAlbum')));
- $sql = "SELECT * FROM `users` AS `User`, `user_photo_albums` as `UserPhotoAlbums`";
- $criteria=" where User.id = UserPhotoAlbum.user_id";
- //$sql="1";
- list($order,$limit,$page) = $this->Pagination->init($criteria);
- $this->set('users', $this->User->findAll($sql, NULL, $order, $limit, $page));
- }
-
-
- }
- /////////////////////////////////////////////////////////////////////////////////////////
-
- ////////////////////////////END OF USER PHOT0 UPLOAD PART///////////////////////////////////////////
-
- /////////////////////////////////////////////////////////////////////////////////////////
-
-
- #####################33 REPORT ABUSE SECTION ##########################
- function managereport()
- {
- $this->checkSession();
- $this->layout = 'default_user';
-
- $select = "SELECT report_abuse.abuse_url ,COUNT(report_abuse.user_ip) as NoofIp , COUNT(report_abuse.user_id) as NoofUsers, report_abuse.admin_block , report_abuse.id " ;
- $from = " FROM report_abuse ";
- $where = " WHERE 1 ";
- $others = " GROUP BY report_abuse.abuse_url ORDER BY report_abuse.id " ;
-
- $CountField=" report_abuse.id ";
-
- $PassParameter="";
- //echo $select;die();
- $this->set("controller","users");
- $this->set("action","managereport");
- $this->pagination($select,$from,$where,$others,$CountField,$this->params['url'],$PassParameter);
- if(isset($this->params['url']['Page']))
- {
- $this->render("managereport2","ajax");
- }
- }
-
-
- function changereportstatus($recorID=NULL , $status=NULL)
- {
- $getstaus = "SELECT * from report_abuse where id='".$recorID."'";
- $getstaus_res = mysql_query($getstaus);
- if(mysql_num_rows($getstaus_res)>0)
- {
- $getstaus_array = mysql_fetch_array($getstaus_res);
- $updatesql = "UPDATE report_abuse SET admin_block='".$status."' where abuse_url='".$getstaus_array['abuse_url']."' ";
- @mysql_query($updatesql );
- }
-
- $this->set('statusmsg', $status) ;
- $this->set('statusId', $recorID) ;
- $this->render("reportstatusupdate","ajax");
-
-
- }
-
-
- ################################# REPORT Bug SECTION starts ################################
- function managereportbug()
- {
- $this->checkSession();
- $this->layout = 'default_user';
-
- $select = "SELECT report_bug.userlinkplace, report_bug.useremail, report_bug.bugos, report_bug.bugbrowser, report_bug.admin_block, report_bug.creation, report_bug.commenttext, report_bug.id " ;
- $from = " FROM report_bug ";
- $where = " WHERE 1 ";
- $others = " ORDER BY report_bug.id " ;
-
- $CountField=" report_bug.id ";
-
- $PassParameter="";
- //echo $select;die();
- $this->set("controller","users");
- $this->set("action","managereportbug");
- $this->pagination($select,$from,$where,$others,$CountField,$this->params['url'],$PassParameter);
- if(isset($this->params['url']['Page']))
- {
- $this->render("managereportbug2","ajax");
- }
- }
-
- function changereportbugstatus($recorID=NULL , $status=NULL)
- {
- $getstaus = "SELECT * from report_bug where id='".$recorID."'";
- $getstaus_res = mysql_query($getstaus);
- if(mysql_num_rows($getstaus_res)>0)
- {
- $getstaus_array = mysql_fetch_array($getstaus_res);
- //$updatesql = "UPDATE report_bug SET admin_block='".$status."' where abuse_url='".$getstaus_array['abuse_url']."' ";
- $updatesql = "UPDATE report_bug SET admin_block='".$status."' where id='".$recorID."'";
- @mysql_query($updatesql );
- }
-
- $this->set('statusmsg', $status) ;
- $this->set('statusId', $recorID) ;
- $this->render("bugreportstatusupdate","ajax");
-
-
- }
-
- ############################# REPORT Bug SECTION Ends ############################################
-
- ################################# Feedback SECTION starts ################################
- function managefeedback()
- {
- $this->checkSession();
- $this->layout = 'default_user';
-
- $select = "SELECT feedback.* " ;
- $from = " FROM feedback ";
- $where = " WHERE 1 ";
- $others = " ORDER BY feedback.id " ;
-
- $CountField=" feedback.id ";
-
- $PassParameter="";
- //echo $select;die();
- $this->set("controller","users");
- $this->set("action","managefeedback");
- $this->pagination($select,$from,$where,$others,$CountField,$this->params['url'],$PassParameter);
- if(isset($this->params['url']['Page']))
- {
- $this->render("managefeedback2","ajax");
- }
- }
-
- function changefeedbackstatus($recorID=NULL , $status=NULL)
- {
- $getstaus = "SELECT * from feedback where id='".$recorID."'";
- $getstaus_res = mysql_query($getstaus);
- if(mysql_num_rows($getstaus_res)>0)
- {
- $getstaus_array = mysql_fetch_array($getstaus_res);
- $updatesql = "UPDATE feedback SET admin_block='".$status."' where id='".$recorID."'";
- @mysql_query($updatesql );
- }
-
- $this->set('statusmsg', $status) ;
- $this->set('statusId', $recorID) ;
- $this->render("bugreportstatusupdate","ajax");
-
-
- }
-
- ############################# Feedback SECTION Ends ############################################
-
-
- function pagination($select,$from,$where,$others,$CountField,$arg,$PassParameter)
- {
- if(isset($arg['Page']))
- $pageFlag=$arg['Page'];
- $this->set("PassParameter",$PassParameter);
- $SetUserNumberOfVpsPerPage=1; /* Defined in config->paths.php*/
-
- $this->set("BackgroundClass",'pagination');
- $this->set("SelectedPage",'pagination_over');
- $this->set("Linkpage",'pagination_over');
- $this->set("FirstImage",'fdd.gif');
- $this->set("PreviousImage",'previous.gif');
- $this->set("NextImage",'next.gif');
- $this->set("LastImage",'rewd.gif');
-
- $UserNumberOfVpsPerPage=1; /* Defined in config->paths.php*/
- if(!is_numeric($UserNumberOfVpsPerPage)|| (intval($UserNumberOfVpsPerPage)!=$UserNumberOfVpsPerPage)||($UserNumberOfVpsPerPage<=0))
- $UserNumberOfVpsPerPage = $SetUserNumberOfVpsPerPage;
-
- if(!isset($arg['Page'])) $arg['Page']=1;
- if(!isset($arg['Offset'])) $arg['Offset']=0;
- $Query_ForNumber_Records=mysql_query("$select $from $where $others") or die('Line no 120' . mysql_error());
- //$Result_Query_ForNumber_Records=mysql_fetch_object($Query_ForNumber_Records);
-
- //$NoOfVps=$Result_Query_ForNumber_Records->NoOfVps;
- $NoOfVps=mysql_num_rows($Query_ForNumber_Records);
-
- $NumberOfVpsPerPage=$UserNumberOfVpsPerPage;
- $NoOfPages=ceil($NoOfVps/$NumberOfVpsPerPage); //3
- if($arg['Offset']==$NoOfVps)
- {
- if(isset($Offset))
- {
- $Offset=$Offset-$NumberOfVpsPerPage;
- $Page--;
- if($Offset<0)
- {
- $Offset=0;$Page=1;
- }
- }else{
- $Offset=0;$Page=1;
- }
- }
-
- $this->set("Page",$arg['Page']);
- $this->set("Offset",$arg['Offset']);
- $this->set("NumberOfVpsPerPage",$NumberOfVpsPerPage);
- $this->set("NoOfPages",$NoOfPages);
- $this->set("UserNumberOfVpsPerPage",$UserNumberOfVpsPerPage);
-
- //print "$select $from $where $others";
- $this->set("qryOthr","$select $from $where)");
- $this->set("tesrqryOthr","$where $others)");
-
- //echo "$select $from $where $others LIMIT ".$arg['Offset'].",$NumberOfVpsPerPage" ;
- $SelectRecord = mysql_query("$select $from $where $others LIMIT ".$arg['Offset'].",$NumberOfVpsPerPage") or die('Line no '.__LINE__ . mysql_error());
- $this->set("query",$SelectRecord);
- }
-
- ############################################################
-
- }
- ?>