PageRenderTime 64ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 1ms

/admin/app/controllers/users_controller.php

https://bitbucket.org/fxrialab/spsp_editor
PHP | 1513 lines | 1265 code | 169 blank | 79 comment | 158 complexity | b480491c834ad678ea69c53b422258c7 MD5 | raw file
Possible License(s): LGPL-2.1, AGPL-1.0

Large files files are truncated, but you can click here to view the full file

  1. <?php
  2. class UsersController extends AppController
  3. {
  4. var $name='Users';
  5. /*var $components = array('Pagination');
  6. var $helpers = array('Pagination', 'error');*/
  7. var $helpers = array('Html','Javascript','Ajax','Pagination','error');
  8. var $components = array('Pagination','Sendmail','Download');
  9. function manageuser()
  10. {
  11. $this->checkSession();
  12. $this->layout = 'default_user';
  13. $this->set('menu_id', $_REQUEST['menu']);
  14. ///////////*******SEARCHING FOR USER********///////////////
  15. if(isset($this->data))
  16. {
  17. if(!empty($this->data['User']['hid']))
  18. {
  19. //IF USER SEARCHED BY SEARCH FIELD//
  20. $criteria="1";
  21. if(!empty($this->data['User']['id']) || !empty($this->data['User']['username']) || !empty($this->data['User']['email']))
  22. {
  23. if($this->data['User']['id'] == "'")
  24. $id = "";
  25. else
  26. $id=trim($this->data['User']['id']);
  27. if($this->data['User']['username'] == "'")
  28. $usernames = "";
  29. else
  30. $usernames = trim($this->data['User']['username']);
  31. if($this->data['User']['email'] == "'")
  32. $email = "";
  33. else
  34. $email = trim($this->data['User']['email']);
  35. $criteria .= " and User.id LIKE '%".$id."%' and UserDetails.email LIKE '%".$email."%' and User.username LIKE '%".$usernames."%'";
  36. list($order,$limit,$page) = $this->Pagination->init($criteria);
  37. $this->set('users', $this->User->findAll($criteria, NULL, $order, $limit, $page));
  38. }
  39. else
  40. {
  41. $criteria= "1";
  42. if(isset($_REQUEST['page']))
  43. {
  44. $page = $_REQUEST['page'];
  45. }
  46. list($order,$limit,$page) = $this->Pagination->init($criteria);
  47. $this->set('users', $this->User->findAll($criteria, NULL, $order, $limit, $page));
  48. }
  49. }
  50. }
  51. //IF USER SEARCHED BY SEARCHKEY//
  52. else if(empty($_GET['searchkey']) && !empty($_GET['search']))
  53. {
  54. $criteria="1";
  55. $this->data['User']['search'] = $_GET['search'];
  56. $search=trim($this->data['User']['search']);
  57. $criteria .= " and User.username LIKE '".$search."%'";
  58. list($order,$limit,$page) = $this->Pagination->init($criteria);
  59. $this->set('users', $this->User->findAll($criteria, NULL, $order, $limit, $page));
  60. }
  61. else if(!empty($_GET['searchkey']) || !empty($_GET['search']))
  62. {
  63. $criteria="1";
  64. if($_GET['searchkey'] == 'block' && empty($_GET['search']))
  65. {
  66. $criteria .= " and User.user_status = '0'";
  67. list($order,$limit,$page) = $this->Pagination->init($criteria);
  68. $this->set('users', $this->User->findAll($criteria, NULL, $order, $limit, $page));
  69. }
  70. else if($_GET['searchkey'] == 'unblock' && empty($_GET['search']))
  71. {
  72. $criteria .= " and User.user_status = '1'";
  73. list($order,$limit,$page) = $this->Pagination->init($criteria);
  74. $this->set('users', $this->User->findAll($criteria, NULL, $order, $limit, $page));
  75. }
  76. else if(!empty($_GET['search']))
  77. {
  78. $this->data['User']['search'] = $_GET['search'];
  79. if($_GET['searchkey'] == 'block')
  80. $this->data['User']['searchkey'] = 0;
  81. else if($_GET['searchkey'] == 'unblock')
  82. $this->data['User']['searchkey'] = 1;
  83. $search=trim($this->data['User']['search']);
  84. $searchkey=$this->data['User']['searchkey'];
  85. $criteria .= " and User.username LIKE '".$search."%' and User.user_status='".$searchkey."'";
  86. list($order,$limit,$page) = $this->Pagination->init($criteria);
  87. $this->set('users', $this->User->findAll($criteria, NULL, $order, $limit, $page));
  88. }
  89. }
  90. else if(!empty($_GET['order']))
  91. {
  92. $criteria="1";
  93. $col = $_REQUEST['searchby'];
  94. if($_REQUEST['order'] == 'desc')
  95. {
  96. $order= " User.".$col." desc";
  97. list($order,$limit,$page) = $this->Pagination->init($criteria);
  98. $this->set('users', $this->User->findAll($criteria, NULL, $order, $limit, $page));
  99. }
  100. else
  101. {
  102. $order= " User.".$col." asc";
  103. list($order,$limit,$page) = $this->Pagination->init($criteria);
  104. $this->set('users', $this->User->findAll($criteria, NULL, $order, $limit, $page));
  105. }
  106. }
  107. else
  108. {
  109. $criteria= "1";
  110. list($order,$limit,$page) = $this->Pagination->init($criteria);
  111. $this->set('users', $this->User->findAll($criteria, NULL, $order, $limit, $page));
  112. }
  113. }
  114. ////////////////////******EDIT USER BY ID*******//////////////
  115. function edit_user($id = null)
  116. {
  117. $this->checkSession();
  118. $this->layout = 'default_user';
  119. $id = $_REQUEST['id'];
  120. if(!empty($id))
  121. {
  122. if(empty($this->data['User']))
  123. {
  124. $this->User->id = $_REQUEST['id'];
  125. $this->set('usrId', $this->User->id);
  126. $this->data = $this->User->read(null, $id);
  127. $this->set('data',$this->data);
  128. /* Getting some value from user details*/
  129. $sql_select = "select * from user_details where user_id =".$id. "";
  130. $res_sql_select = mysql_fetch_array(mysql_query($sql_select));
  131. $this->data['User']['first_name'] = stripslashes($res_sql_select['first_name']) ;
  132. $this->data['User']['last_name'] = stripslashes($res_sql_select['last_name']) ;
  133. $this->data['User']['email'] = $res_sql_select['email'] ;
  134. $this->data['User']['c_id'] = $res_sql_select['c_id'];
  135. if(!empty($res_sql_select['dob']))
  136. {
  137. $date_of_estab = explode("-",$res_sql_select['dob']) ;
  138. $this->set('org_day', $date_of_estab['2']) ;
  139. $this->set('org_month',$date_of_estab['1']) ;
  140. $this->set('org_year', $date_of_estab['0']) ;
  141. }
  142. else
  143. {
  144. $this->set('org_day', 0) ;
  145. $this->set('org_month',0) ;
  146. $this->set('org_year', 0) ;
  147. }
  148. }
  149. else
  150. {
  151. if (!empty($this->data))
  152. {
  153. $userId = $_REQUEST['id'];
  154. $this->data['User']['menu'] = $_REQUEST['menu'];
  155. $this->data['User']['id'] = $_REQUEST['id'];
  156. $this->data['User']['user_group_master_id'] = $_REQUEST['role'];
  157. $m=($_REQUEST['month']!= "0") ? $_REQUEST['month'] : "";
  158. $this->data['User']['dob'] = $_REQUEST['year']."-".$m."-"."0".$_REQUEST['date'];
  159. 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;
  160. /* 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();
  161. */ $res_det = mysql_query($updatUserDet);
  162. $this->flash('Your post has been Updated.','/users');
  163. $this->redirect('/users/manageuser?menu='.$this->data['User']['menu']."&page=".$_REQUEST['page']);
  164. }
  165. }
  166. }
  167. }
  168. /////////////*****DELETE USER BY ID******///////////
  169. function delete($id)
  170. {
  171. $this->checkSession();
  172. if(isset($_REQUEST['box']))
  173. {
  174. /////IF SEARCH IS COLLECTIVE OR CHOSEN BY ADMIN SELECTION//////
  175. $arr = $_REQUEST['box'];
  176. foreach($arr as $key => $value)
  177. {
  178. $sql = "delete from `users` where `id` = '".$value."'";
  179. $res = mysql_query($sql);
  180. $sql_det = "delete from `user_details` where `user_id` = '".$value."'";
  181. $res_det = mysql_query($sql_det);
  182. }
  183. }
  184. ////IF DELETE IS FOR A SPECIFIC USER////
  185. else
  186. {
  187. $id=$_REQUEST['id'];
  188. $this->data['User']['menu'] = $_REQUEST['menu'];
  189. $this->User->del($id);
  190. }
  191. $id=$_REQUEST['id'];
  192. $this->data['User']['menu'] = $_REQUEST['menu'];
  193. if(isset($_REQUEST['page']))
  194. {
  195. $page = $_REQUEST['page'];
  196. }
  197. $this->flash('The post with id: '.$id.' has been deleted.', '/posts');
  198. $this->redirect('/users/manageuser?menu='.$this->data['User']['menu'].'&page='.$page);
  199. }
  200. ///////***VIEW OF USER****///////
  201. function view()
  202. {
  203. $this->checkSession();
  204. $this->layout = 'default_user';
  205. $this->User->id = $_REQUEST['id'];
  206. $this->set('users', $this->User->read());
  207. }
  208. //////////******INACTIVE USER*****////////////
  209. function block()
  210. {
  211. /////IF BLOCKING IS COLLECTIVE OR BY ADMIN SELECTION/////
  212. $this->checkSession();
  213. if(isset($_REQUEST['box']))
  214. {
  215. $arr = $_REQUEST['box'];
  216. foreach($arr as $key => $value)
  217. {
  218. $sql = "update `users` set `user_status` = '0' where `id` ='".$value."'";
  219. $res = mysql_query($sql);
  220. }
  221. }
  222. ////IF BLOCKING IS FOR A SPECIFIC USER////
  223. else
  224. {
  225. $qry="update `users` set `user_status`='0' where `id`='".$_REQUEST['id']."'";
  226. $res=mysql_query($qry);
  227. }
  228. $this->data['User']['menu'] = $_REQUEST['menu'];
  229. if(isset($_REQUEST['page']))
  230. {
  231. $page = $_REQUEST['page'];
  232. }
  233. $this->redirect('/users/manageuser?menu='.$this->data['User']['menu'].'&page='.$page);
  234. }
  235. function active()
  236. {
  237. ///////////IF UNBLOCKING IS COLLECTIVE OR BY ADMIN SELECTION//////////
  238. $this->checkSession();
  239. if(isset($_REQUEST['box']))
  240. {
  241. $arr = $_REQUEST['box'];
  242. foreach($arr as $key => $value)
  243. {
  244. $sql = "update `users` set `user_status` = '1' where `id` ='".$value."'";
  245. $res = mysql_query($sql);
  246. }
  247. }
  248. ////IF UNBLOCKING IS FOR A SPECIFIC USER////
  249. else
  250. {
  251. $qry="update `users` set `user_status`='1' where `id`='".$_REQUEST['id']."'";
  252. $res=mysql_query($qry);
  253. }
  254. $this->data['User']['menu'] = $_REQUEST['menu'];
  255. if(isset($_REQUEST['page']))
  256. {
  257. $page = $_REQUEST['page'];
  258. }
  259. $this->redirect('/users/manageuser?menu='.$this->data['User']['menu'].'&page='.$page);
  260. }
  261. //////////******ADDING USER******//////////
  262. function add()
  263. {
  264. $this->checkSession();
  265. $this->layout = 'default_user';
  266. $this->pageTitle = 'Add User';
  267. if (!empty($this->data['User']))
  268. {
  269. $this->data['User']['menu'] = $_REQUEST['menu'];
  270. $this->data['User']['user_status'] = 1;
  271. $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']."')");
  272. $id = mysql_insert_id();
  273. $fname = addslashes($this->data['User']['first_name']);
  274. $lname = addslashes($this->data['User']['last_name']);
  275. $email = $this->data['User']['email'];
  276. if(strlen($_REQUEST['date'])!=2)
  277. $Dob = "0".$_REQUEST['date'];
  278. else $Dob = $_REQUEST['date'];
  279. $dob = $_REQUEST['year']."-".$_REQUEST['month']."-".$Dob;
  280. $qry = "INSERT INTO `user_details` ( `id` , `user_id`, `first_name`, `last_name`, `email`, `dob`, `c_id` )VALUES ('',".$id.",'".$fname."','".$lname."','".$email."', '".$dob."', ".$_REQUEST['country'].")" ;
  281. if($res = mysql_query($qry))
  282. {
  283. $this->flash('Your post has been saved.','/users');
  284. $this->redirect('/users/manageuser?menu='.$this->data['User']['menu']);
  285. }
  286. }
  287. }
  288. function getUseravailability()
  289. {
  290. $this->checkSession();
  291. }
  292. /////////////////////////////////////////////////////////////////////////////////////////
  293. ////////////////////////////ORGANISATION PART///////////////////////////////////////////
  294. /////////////////////////////////////////////////////////////////////////////////////////
  295. function manageorg()
  296. {
  297. $this->checkSession();
  298. $this->layout = 'default_user';
  299. $this->pageTitle = 'Manage Organisation';
  300. $this->set('menu_id', $_REQUEST['menu']);
  301. if(isset($this->data))
  302. {
  303. if(!empty($this->data['User']['hid']))
  304. {
  305. //IF USER SEARCHED BY SEARCH FIELD//
  306. $criteria="1";
  307. if(!empty($this->data['User']['id']) || !empty($this->data['User']['username']) || !empty($this->data['User']['email']))
  308. {
  309. if($this->data['User']['id'] == "'")
  310. $id = "";
  311. else
  312. $id=trim($this->data['User']['id']);
  313. if($this->data['User']['username'] == "'")
  314. $usernames = "";
  315. else
  316. $usernames = trim($this->data['User']['username']);
  317. if($this->data['User']['email'] == "'")
  318. $email = "";
  319. else
  320. $email = trim($this->data['User']['email']);
  321. /*$criteria .= " and User.id LIKE '%".$id."%' and User.email LIKE '%".$email."%' and User.username LIKE '%".$usernames."%' and User.user_group_master_id=4";*/
  322. $criteria .= " and User.id LIKE '%".$id."%' and User.username LIKE '%".$usernames."%' and User.user_group_master_id=3 ";
  323. if($email!="")
  324. $criteria .= " and UserDetails.email LIKE '%".$email."%' and User.user_group_master_id=3" ;
  325. list($order,$limit,$page) = $this->Pagination->init($criteria);
  326. $this->set('users', $this->User->findAll($criteria, NULL, $order, $limit, $page));
  327. }
  328. else
  329. {
  330. $criteria= "1 and User.user_group_master_id=3";
  331. if(isset($_REQUEST['page']))
  332. {
  333. $page = $_REQUEST['page'];
  334. }
  335. list($order,$limit,$page) = $this->Pagination->init($criteria);
  336. $this->set('users', $this->User->findAll($criteria, NULL, $order, $limit, $page));
  337. }
  338. }
  339. }
  340. else if(empty($_GET['searchkey']) && !empty($_GET['search']))
  341. {
  342. $criteria="1";
  343. $this->data['User']['search'] = $_GET['search'];
  344. $search=trim($this->data['User']['search']);
  345. $criteria .= " and User.username LIKE '".$search."%' and User.user_group_master_id=3";
  346. list($order,$limit,$page) = $this->Pagination->init($criteria);
  347. $this->set('users', $this->User->findAll($criteria, NULL, $order, $limit, $page));
  348. }
  349. else if(!empty($_GET['searchkey']) || !empty($_GET['search']))
  350. {
  351. $criteria="1";
  352. if($_GET['searchkey'] == 'block' && empty($_GET['search']))
  353. {
  354. $criteria .= " and User.user_status = '0' and User.user_group_master_id=3";
  355. list($order,$limit,$page) = $this->Pagination->init($criteria);
  356. $this->set('users', $this->User->findAll($criteria, NULL, $order, $limit, $page));
  357. }
  358. else if($_GET['searchkey'] == 'unblock' && empty($_GET['search']))
  359. {
  360. $criteria .= " and User.user_status = '1' and User.user_group_master_id=3";
  361. list($order,$limit,$page) = $this->Pagination->init($criteria);
  362. $this->set('users', $this->User->findAll($criteria, NULL, $order, $limit, $page));
  363. }
  364. else if(!empty($_GET['search']))
  365. {
  366. $this->data['User']['search'] = $_GET['search'];
  367. if($_GET['searchkey'] == 'block')
  368. $this->data['User']['searchkey'] = 0;
  369. else if($_GET['searchkey'] == 'unblock')
  370. $this->data['User']['searchkey'] = 1;
  371. $search=trim($this->data['User']['search']);
  372. $searchkey=$this->data['User']['searchkey'];
  373. $criteria .= " and User.username LIKE '".$search."%' and User.status='".$searchkey."' and User.user_group_master_id=3";
  374. list($order,$limit,$page) = $this->Pagination->init($criteria);
  375. $this->set('users', $this->User->findAll($criteria, NULL, $order, $limit, $page));
  376. }
  377. }
  378. else
  379. {
  380. $criteria= "where User.user_group_master_id=3";
  381. list($order,$limit,$page) = $this->Pagination->init($criteria);
  382. $this->set('users', $this->User->findAll($criteria, NULL, $order, $limit, $page));
  383. }
  384. }
  385. function add_organisation()
  386. {
  387. $this->checkSession();
  388. $this->layout = 'default_user';
  389. $this->pageTitle = 'Add Organisation';
  390. if (!empty($this->data['User']))
  391. {
  392. $this->data['User']['menu'] = $_REQUEST['menu'];
  393. $this->data['User']['user_status'] = 1;
  394. $this->data['User']['user_group_master_id'] = 3;
  395. $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']."')";
  396. $userSave = mysql_query($usrqry);
  397. $id = mysql_insert_id();
  398. $fname = addslashes($this->data['User']['first_name']);
  399. $lname = addslashes($this->data['User']['last_name']);
  400. $email = $this->data['User']['email'];
  401. $dob = $_REQUEST['year']."-".$_REQUEST['month']."-".$_REQUEST['org_date'];
  402. 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'].")" ;
  403. if($res = mysql_query($qry))
  404. {
  405. $this->flash('Your post has been saved.','/users');
  406. $this->redirect('/users/manageorg?menu='.$this->data['User']['menu']);
  407. }
  408. }
  409. }
  410. function edit_organisation($id = null)
  411. {
  412. $this->checkSession();
  413. $this->layout = 'default_user';
  414. $id = $_REQUEST['id'];
  415. $this->set('usrId', $id);
  416. if(!empty($id))
  417. {
  418. if(empty($this->data['User']))
  419. {
  420. $this->User->id = $_REQUEST['id'];
  421. $this->data = $this->User->read(null, $id);
  422. $this->set('data',$this->data);
  423. /* Getting some value from user details*/
  424. $sql_select = "select * from user_details where user_id =".$id. "";
  425. $res_sql_select = mysql_fetch_array(mysql_query($sql_select));
  426. $this->data['User']['first_name'] = stripslashes($res_sql_select['first_name']) ;
  427. $this->data['User']['last_name'] = stripslashes($res_sql_select['last_name']) ;
  428. $this->data['User']['email'] = $res_sql_select['email'] ;
  429. $this->set('country_id', $res_sql_select['c_id']);
  430. $date_of_estab = explode("-",$res_sql_select['dob']) ;
  431. $this->set('org_day', $date_of_estab['2']) ;
  432. $this->set('org_month',$date_of_estab['1']) ;
  433. $this->set('org_year', $date_of_estab['0']) ;
  434. /**/
  435. }
  436. else
  437. {
  438. if (!empty($this->data))
  439. {
  440. $this->data['User']['menu'] = $_REQUEST['menu'];
  441. $this->data['User']['id'] = $_REQUEST['id'];
  442. $this->data['User']['group_master_id'] = 3;
  443. //echo $userId = $_REQUEST['id'];
  444. $m=($_REQUEST['estmon']!= "0") ? $_REQUEST['estmon'] : "";
  445. $this->data['User']['dob'] = $_REQUEST['estyear']."-".$m."-".$_REQUEST['estdate'];
  446. $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']."";
  447. $res = mysql_query($qry_org);
  448. $this->flash('Your post has been Updated.','/users');
  449. $this->redirect('/users/manageorg?menu='.$this->data['User']['menu']);
  450. }
  451. }
  452. }
  453. }
  454. function delete_organisation($id = null)
  455. {
  456. $this->checkSession();
  457. if(isset($_REQUEST['box']))
  458. {
  459. /////IF SEARCH IS COLLECTIVE OR CHOSEN BY ADMIN SELECTION//////
  460. $arr = $_REQUEST['box'];
  461. foreach($arr as $key => $value)
  462. {
  463. //echo $sql = "delete from `users` where `id` = '".$value."'";exit();
  464. $res = mysql_query($sql);
  465. /* Delete the record from user details table*/
  466. $sql_user_detail = "delete from user_details where user_id = '".$value."'" ;
  467. $res_user_detail = mysql_query($sql_user_detail);
  468. }
  469. }
  470. ////IF DELETE IS FOR A SPECIFIC USER////
  471. else
  472. {
  473. $id=$_REQUEST['id'];
  474. $this->data['User']['menu'] = $_REQUEST['menu'];
  475. $this->User->del($id);
  476. /* Delete the record from user details table*/
  477. $sql_user_detail = "delete from user_details where user_id = '".$id."'" ;
  478. $res_user_detail = mysql_query($sql_user_detail);
  479. }
  480. $id=$_REQUEST['id'];
  481. $this->data['User']['menu'] = $_REQUEST['menu'];
  482. if(isset($_REQUEST['page']))
  483. {
  484. $page = $_REQUEST['page'];
  485. }
  486. $this->flash('The post with id: '.$id.' has been deleted.', '/posts');
  487. $this->redirect('/users/manageorg?menu='.$this->data['User']['menu'].'&page='.$page);
  488. }
  489. function organisation_view($id = null)
  490. {
  491. $this->checkSession();
  492. $this->layout = 'default_user';
  493. $this->User->id = $_REQUEST['id'];
  494. $id = $_REQUEST['id'];
  495. $this->data = $this->User->read(null, $id);
  496. $this->set('data',$this->data);
  497. /* Getting some value from user details*/
  498. $sql_select = "select * from user_details where user_id =".$id. "";
  499. //echo "xxxx".$sql_select ;
  500. $res_sql_select = mysql_fetch_array(mysql_query($sql_select));
  501. $this->data['User']['org_name'] = $res_sql_select['org_name'] ;
  502. $date_of_estab = explode("-",$res_sql_select['dob']) ;
  503. $group_sql = mysql_fetch_array(mysql_query("select group_cat_name from user_group_masters where id=".$this->data['User']['user_group_master_id'].""));
  504. $this->set('org_day', $date_of_estab['2']) ;
  505. $this->set('org_month',$date_of_estab['1']) ;
  506. $this->set('org_year', $date_of_estab['0']) ;
  507. $this->set('group_name', $group_sql['group_cat_name']) ;
  508. /**/
  509. }
  510. function organisation_active()
  511. {
  512. ///////////IF UNBLOCKING IS COLLECTIVE OR BY ADMIN SELECTION//////////
  513. $this->checkSession();
  514. if(isset($_REQUEST['box']))
  515. {
  516. $arr = $_REQUEST['box'];
  517. foreach($arr as $key => $value)
  518. {
  519. $sql = "update `users` set `user_status` = '0' where `id` ='".$value."'";
  520. $res = mysql_query($sql);
  521. }
  522. }
  523. ////IF UNBLOCKING IS FOR A SPECIFIC USER////
  524. else
  525. {
  526. $qry="update `users` set `user_status`='0' where `id`='".$_REQUEST['id']."'";
  527. $res=mysql_query($qry);
  528. }
  529. $this->data['User']['menu'] = $_REQUEST['menu'];
  530. if(isset($_REQUEST['page']))
  531. {
  532. $page = $_REQUEST['page'];
  533. }
  534. $this->redirect('/users/manageorg?menu='.$this->data['User']['menu'].'&page='.$page);
  535. }
  536. function organisation_block()
  537. {
  538. /////IF BLOCKING IS COLLECTIVE OR BY ADMIN SELECTION/////
  539. $this->checkSession();
  540. if(isset($_REQUEST['box']))
  541. {
  542. $arr = $_REQUEST['box'];
  543. foreach($arr as $key => $value)
  544. {
  545. $sql = "update `users` set `user_status` = '1' where `id` ='".$value."'";
  546. $res = mysql_query($sql);
  547. }
  548. }
  549. ////IF BLOCKING IS FOR A SPECIFIC USER////
  550. else
  551. {
  552. $qry="update `users` set `user_status`='1' where `id`='".$_REQUEST['id']."'";
  553. $res=mysql_query($qry);
  554. }
  555. $this->data['User']['menu'] = $_REQUEST['menu'];
  556. if(isset($_REQUEST['page']))
  557. {
  558. $page = $_REQUEST['page'];
  559. }
  560. $this->redirect('/users/manageorg?menu='.$this->data['User']['menu'].'&page='.$page);
  561. }
  562. function manageorgrating()
  563. {
  564. $this->checkSession();
  565. $this->layout = 'default_user';
  566. $this->set('menu_id', $_REQUEST['menu']);
  567. if(isset($this->data))
  568. {
  569. if(!empty($this->data['User']['hid']))
  570. {
  571. //IF USER SEARCHED BY SEARCH FIELD//
  572. $criteria="1";
  573. if(!empty($this->data['User']['id']) || !empty($this->data['User']['username']) || !empty($this->data['User']['email']))
  574. {
  575. if($this->data['User']['id'] == "'")
  576. $id = "";
  577. else
  578. $id=trim($this->data['User']['id']);
  579. if($this->data['User']['username'] == "'")
  580. $usernames = "";
  581. else
  582. $usernames = trim($this->data['User']['username']);
  583. if($this->data['User']['email'] == "'")
  584. $email = "";
  585. else
  586. $email = trim($this->data['User']['email']);
  587. /*$criteria .= " and User.id LIKE '%".$id."%' and User.email LIKE '%".$email."%' and User.username LIKE '%".$usernames."%' and User.user_group_master_id=4";*/
  588. $criteria .= " and User.id LIKE '%".$id."%' and User.username LIKE '%".$usernames."%' ";
  589. if($email!="")
  590. $criteria .= " and UserDetails.email LIKE '%".$email."%'" ;
  591. $criteria .=" and User.user_group_master_id=3 ";
  592. list($order,$limit,$page) = $this->Pagination->init($criteria);
  593. $this->set('users', $this->User->findAll($criteria, NULL, $order, $limit, $page));
  594. }
  595. else
  596. {
  597. $criteria= "1";
  598. if(isset($_REQUEST['page']))
  599. {
  600. $page = $_REQUEST['page'];
  601. }
  602. $criteria .=" and User.user_group_master_id=3 ";
  603. list($order,$limit,$page) = $this->Pagination->init($criteria);
  604. $this->set('users', $this->User->findAll($criteria, NULL, $order, $limit, $page));
  605. }
  606. }
  607. }
  608. else if(empty($_GET['searchkey']) && !empty($_GET['search']))
  609. {
  610. $criteria="1";
  611. $this->data['User']['search'] = $_GET['search'];
  612. $search=trim($this->data['User']['search']);
  613. $criteria .= " and User.username LIKE '".$search."%' and User.user_group_master_id=3";
  614. list($order,$limit,$page) = $this->Pagination->init($criteria);
  615. $this->set('users', $this->User->findAll($criteria, NULL, $order, $limit, $page));
  616. }
  617. else if(!empty($_GET['searchkey']) || !empty($_GET['search']))
  618. {
  619. $criteria="1";
  620. if($_GET['searchkey'] == 'block' && empty($_GET['search']))
  621. {
  622. $criteria .= " and User.user_status = '1' and User.user_group_master_id=3";
  623. list($order,$limit,$page) = $this->Pagination->init($criteria);
  624. $this->set('users', $this->User->findAll($criteria, NULL, $order, $limit, $page));
  625. }
  626. else if($_GET['searchkey'] == 'unblock' && empty($_GET['search']))
  627. {
  628. $criteria .= " and User.user_status = '0' and User.user_group_master_id=3";
  629. list($order,$limit,$page) = $this->Pagination->init($criteria);
  630. $this->set('users', $this->User->findAll($criteria, NULL, $order, $limit, $page));
  631. }
  632. else if(!empty($_GET['search']))
  633. {
  634. $this->data['User']['search'] = $_GET['search'];
  635. if($_GET['searchkey'] == 'block')
  636. $this->data['User']['searchkey'] = 0;
  637. else if($_GET['searchkey'] == 'unblock')
  638. $this->data['User']['searchkey'] = 1;
  639. $search=trim($this->data['User']['search']);
  640. $searchkey=$this->data['User']['searchkey'];
  641. $criteria .= " and User.username LIKE '".$search."%' and User.status='".$searchkey."' and User.user_group_master_id=3";
  642. list($order,$limit,$page) = $this->Pagination->init($criteria);
  643. $this->set('users', $this->User->findAll($criteria, NULL, $order, $limit, $page));
  644. }
  645. }
  646. else
  647. {
  648. $criteria= " User.user_group_master_id=3";
  649. list($order,$limit,$page) = $this->Pagination->init($criteria);
  650. $this->set('users', $this->User->findAll($criteria, NULL, $order, $limit, $page));
  651. }
  652. }
  653. /////////////////////////////////////////////////////////////////////////////////////////
  654. ////////////////////////////End of ORGANISATION PART///////////////////////////////////////////
  655. /////////////////////////////////////////////////////////////////////////////////////////
  656. /////////////////////////////////////////////////////////////////////////////////////////
  657. ////////////////////////////PHOTOGRAPHER PART///////////////////////////////////////////
  658. /////////////////////////////////////////////////////////////////////////////////////////
  659. function managephoto()
  660. {
  661. $this->checkSession();
  662. $this->layout = 'default_user';
  663. $this->pageTitle = 'Manage Photographer';
  664. $this->set('menu_id', $_REQUEST['menu']);
  665. if(isset($this->data))
  666. {
  667. if(!empty($this->data['User']['hid']))
  668. {
  669. //IF USER SEARCHED BY SEARCH FIELD//
  670. $criteria="1";
  671. if(!empty($this->data['User']['id']) || !empty($this->data['User']['username']) || !empty($this->data['User']['email']))
  672. {
  673. if($this->data['User']['id'] == "'")
  674. $id = "";
  675. else
  676. $id=trim($this->data['User']['id']);
  677. if($this->data['User']['username'] == "'")
  678. $usernames = "";
  679. else
  680. $usernames = trim($this->data['User']['username']);
  681. if($this->data['User']['email'] == "'")
  682. $email = "";
  683. else
  684. $email = trim($this->data['User']['email']);
  685. /*$criteria .= " and User.id LIKE '%".$id."%' and User.email LIKE '%".$email."%' and User.username LIKE '%".$usernames."%' and User.user_group_master_id=4";*/
  686. $criteria .= " and User.id LIKE '%".$id."%' and User.username LIKE '%".$usernames."%' and User.user_group_master_id=2 ";
  687. if($email!="")
  688. $criteria .= " and UserDetails.email LIKE '%".$email."%'" ;
  689. list($order,$limit,$page) = $this->Pagination->init($criteria);
  690. $this->set('users', $this->User->findAll($criteria, NULL, $order, $limit, $page));
  691. }
  692. else
  693. {
  694. $criteria= "1";
  695. if(isset($_REQUEST['page']))
  696. {
  697. $page = $_REQUEST['page'];
  698. }
  699. $criteria .=" and User.user_group_master_id=2 ";
  700. list($order,$limit,$page) = $this->Pagination->init($criteria);
  701. $this->set('users', $this->User->findAll($criteria, NULL, $order, $limit, $page));
  702. }
  703. }
  704. }
  705. else if(empty($_GET['searchkey']) && !empty($_GET['search']))
  706. {
  707. $criteria="1";
  708. $this->data['User']['search'] = $_GET['search'];
  709. $search=trim($this->data['User']['search']);
  710. $criteria .= " and User.username LIKE '".$search."%' and User.user_group_master_id=2";
  711. list($order,$limit,$page) = $this->Pagination->init($criteria);
  712. $this->set('users', $this->User->findAll($criteria, NULL, $order, $limit, $page));
  713. }
  714. else if(!empty($_GET['searchkey']) || !empty($_GET['search']))
  715. {
  716. $criteria="1";
  717. if($_GET['searchkey'] == 'block' && empty($_GET['search']))
  718. {
  719. $criteria .= " and User.user_status = '0' and User.user_group_master_id=2";
  720. list($order,$limit,$page) = $this->Pagination->init($criteria);
  721. $this->set('users', $this->User->findAll($criteria, NULL, $order, $limit, $page));
  722. }
  723. else if($_GET['searchkey'] == 'unblock' && empty($_GET['search']))
  724. {
  725. $criteria .= " and User.user_status = '1' and User.user_group_master_id=2";
  726. list($order,$limit,$page) = $this->Pagination->init($criteria);
  727. $this->set('users', $this->User->findAll($criteria, NULL, $order, $limit, $page));
  728. }
  729. else if(!empty($_GET['search']))
  730. {
  731. $this->data['User']['search'] = $_GET['search'];
  732. if($_GET['searchkey'] == 'block')
  733. $this->data['User']['searchkey'] = 0;
  734. else if($_GET['searchkey'] == 'unblock')
  735. $this->data['User']['searchkey'] = 1;
  736. $search=trim($this->data['User']['search']);
  737. $searchkey=$this->data['User']['searchkey'];
  738. $criteria .= " and User.username LIKE '".$search."%' and User.status='".$searchkey."' and User.user_group_master_id=2";
  739. list($order,$limit,$page) = $this->Pagination->init($criteria);
  740. $this->set('users', $this->User->findAll($criteria, NULL, $order, $limit, $page));
  741. }
  742. }
  743. else
  744. {
  745. $criteria= "where User.user_group_master_id=2";
  746. list($order,$limit,$page) = $this->Pagination->init($criteria);
  747. $this->set('users', $this->User->findAll($criteria, NULL, $order, $limit, $page));
  748. }
  749. }
  750. function add_photographer()
  751. {
  752. $this->checkSession();
  753. $this->layout = 'default_user';
  754. $this->pageTitle = 'Add Photographer';
  755. if (!empty($this->data['User']))
  756. {
  757. $this->data['User']['menu'] = $_REQUEST['menu'];
  758. $this->data['User']['user_status'] = 1;
  759. $this->data['User']['user_group_master_id'] = 2;
  760. $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']."')");
  761. $id = mysql_insert_id();
  762. $fname = addslashes($this->data['User']['first_name']);
  763. $lname = addslashes($this->data['User']['last_name']);
  764. $email = $this->data['User']['email'];
  765. $qry = "INSERT INTO `user_details` ( `id` , `user_id`, `first_name`, `last_name`, `email`, `c_id` )VALUES ('',".$id.",'".$fname."','".$lname."','".$email."', ".$_REQUEST['country'].")" ;
  766. if($res = mysql_query($qry))
  767. {
  768. $this->flash('Your post has been saved.','/users');
  769. $this->redirect('/users/managephoto?menu='.$this->data['User']['menu']);
  770. }
  771. }
  772. }
  773. function edit_photographer($id = null)
  774. {
  775. $this->checkSession();
  776. $this->layout = 'default_user';
  777. $id = $_REQUEST['id'];
  778. $this->set('usrId', $id);
  779. if(!empty($id))
  780. {
  781. if(empty($this->data['User']))
  782. {
  783. $this->User->id = $_REQUEST['id'];
  784. $this->data = $this->User->read(null, $id);
  785. $this->set('data',$this->data);
  786. /* Getting some value from user details*/
  787. $sql_select = "select * from user_details where user_id =".$id. "";
  788. $res_sql_select = mysql_fetch_array(mysql_query($sql_select));
  789. $this->data['User']['first_name'] = stripslashes($res_sql_select['first_name']) ;
  790. $this->data['User']['last_name'] = stripslashes($res_sql_select['last_name']) ;
  791. $this->data['User']['email'] = $res_sql_select['email'] ;
  792. $this->set('country_id', $res_sql_select['c_id']);
  793. /**/
  794. }
  795. else
  796. {
  797. if (!empty($this->data))
  798. {
  799. $this->data['User']['menu'] = $_REQUEST['menu'];
  800. $this->data['User']['id'] = $_REQUEST['id'];
  801. $this->data['User']['group_master_id'] = 2;
  802. $userId = $_REQUEST['id'];
  803. $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']."";
  804. $res = mysql_query($qry_org);
  805. $this->flash('Your post has been Updated.','/users');
  806. $this->redirect('/users/managephoto?menu='.$this->data['User']['menu']);
  807. }
  808. }
  809. }
  810. }
  811. function delete_photographer($id = null)
  812. {
  813. $this->checkSession();
  814. if(isset($_REQUEST['box']))
  815. {
  816. /////IF SEARCH IS COLLECTIVE OR CHOSEN BY ADMIN SELECTION//////
  817. $arr = $_REQUEST['box'];
  818. foreach($arr as $key => $value)
  819. {
  820. $sql = "delete from `users` where `id` = '".$value."'";
  821. $res = mysql_query($sql);
  822. /* Delete the record from user details table*/
  823. $sql_user_detail = "delete from user_details where user_id = '".$value."'" ;
  824. $res_user_detail = mysql_query($sql_user_detail);
  825. }
  826. }
  827. ////IF DELETE IS FOR A SPECIFIC USER////
  828. else
  829. {
  830. $id=$_REQUEST['id'];
  831. $this->data['User']['menu'] = $_REQUEST['menu'];
  832. $this->User->del($id);
  833. /* Delete the record from user details table*/
  834. $sql_user_detail = "delete from user_details where user_id = '".$id."'" ;
  835. $res_user_detail = mysql_query($sql_user_detail);
  836. }
  837. $id=$_REQUEST['id'];
  838. $this->data['User']['menu'] = $_REQUEST['menu'];
  839. if(isset($_REQUEST['page']))
  840. {
  841. $page = $_REQUEST['page'];
  842. }
  843. $this->flash('The post with id: '.$id.' has been deleted.', '/posts');
  844. $this->redirect('/users/managephoto?menu='.$this->data['User']['menu'].'&page='.$page);
  845. }
  846. function photographer_view($id = null)
  847. {
  848. $this->checkSession();
  849. $this->layout = 'default_user';
  850. $this->User->id = $_REQUEST['id'];
  851. $id = $_REQUEST['id'];
  852. $this->data = $this->User->read(null, $id);
  853. $this->set('data',$this->data);
  854. /* Getting some value from user details*/
  855. $sql_select = "select * from user_details where user_id =".$id. "";
  856. //echo "xxxx".$sql_select ;
  857. $res_sql_select = mysql_fetch_array(mysql_query($sql_select));
  858. $this->data['User']['org_name'] = $res_sql_select['org_name'] ;
  859. /*if($res_sql_select['dob']!= '0000-00-00' || !is_null($res_sql_select['dob']) || $res_sql_select['dob']!='')
  860. {
  861. //echo $res_sql_select['dob'];exit();
  862. $date_of_estab = explode("-",$res_sql_select['dob']) ;
  863. $this->set('org_day', $date_of_estab['2']) ;
  864. $this->set('org_month',$date_of_estab['1']) ;
  865. $this->set('org_year', $date_of_estab['0']) ;
  866. }*/
  867. $group_sql = mysql_fetch_array(mysql_query("select group_cat_name from user_group_masters where id=".$this->data['User']['user_group_master_id'].""));
  868. $this->set('group_name', $group_sql['group_cat_name']) ;
  869. /**/
  870. }
  871. function photographer_active()
  872. {
  873. ///////////IF UNBLOCKING IS COLLECTIVE OR BY ADMIN SELECTION//////////
  874. $this->checkSession();
  875. if(isset($_REQUEST['box']))
  876. {
  877. $arr = $_REQUEST['box'];
  878. foreach($arr as $key => $value)
  879. {
  880. $sql = "update `users` set `user_status` = '0' where `id` ='".$value."'";
  881. $res = mysql_query($sql);
  882. }
  883. }
  884. ////IF UNBLOCKING IS FOR A SPECIFIC USER////
  885. else
  886. {
  887. $qry="update `users` set `user_status`='0' where `id`='".$_REQUEST['id']."'";
  888. $res=mysql_query($qry);
  889. }
  890. $this->data['User']['menu'] = $_REQUEST['menu'];
  891. if(isset($_REQUEST['page']))
  892. {
  893. $page = $_REQUEST['page'];
  894. }
  895. $this->redirect('/users/managephoto?menu='.$this->data['User']['menu'].'&page='.$page);
  896. }
  897. function photographer_block()
  898. {
  899. /////IF BLOCKING IS COLLECTIVE OR BY ADMIN SELECTION/////
  900. $this->checkSession();
  901. if(isset($_REQUEST['box']))
  902. {
  903. $arr = $_REQUEST['box'];
  904. foreach($arr as $key => $value)
  905. {
  906. $sql = "update `users` set `user_status` = '1' where `id` ='".$value."'";
  907. $res = mysql_query($sql);
  908. }
  909. }
  910. ////IF BLOCKING IS FOR A SPECIFIC USER////
  911. else
  912. {
  913. $qry="update `users` set `user_status`='1' where `id`='".$_REQUEST['id']."'";
  914. $res=mysql_query($qry);
  915. }
  916. $this->data['User']['menu'] = $_REQUEST['menu'];
  917. if(isset($_REQUEST['page']))
  918. {
  919. $page = $_REQUEST['page'];
  920. }
  921. $this->redirect('/users/managephoto?menu='.$this->data['User']['menu'].'&page='.$page);
  922. }
  923. function projectBidded($id=null)
  924. {
  925. $this->checkSession();
  926. $this->layout= 'default_user_cat';
  927. $this->pageTitle = 'Photographer Projects Bidded';
  928. $this->layout = 'default_user_cat';
  929. $criteria = " `User.id` = ".$_REQUEST['id']."" ;
  930. list($order,$limit,$page) = $this->Pagination->init($criteria);
  931. $this->set('projects', $this->User->findAll($criteria, NULL, $order, $limit, $page));
  932. }
  933. function projectWinning($id=null)
  934. {
  935. $this->checkSession();
  936. $this->layout= 'default_user_cat';
  937. $this->pageTitle = 'Photographer Projects Winning';
  938. $this->layout = 'default_user_cat';
  939. $criteria = " `User.id` = ".$_REQUEST['id']."" ;
  940. list($order,$limit,$page) = $this->Pagination->init($criteria);
  941. $this->set('projects', $this->User->findAll($criteria, NULL, $order, $limit, $page));
  942. }
  943. function managephotorating()
  944. {
  945. $this->checkSession();
  946. $this->layout = 'default_user';
  947. $this->set('menu_id', $_REQUEST['menu']);
  948. if(isset($this->data))
  949. {
  950. if(!empty($this->data['User']['hid']))
  951. {
  952. //IF USER SEARCHED BY SEARCH FIELD//
  953. $criteria="1";
  954. if(!empty($this->data['User']['id']) || !empty($this->data['User']['username']) || !empty($this->data['User']['email']))
  955. {
  956. $id=trim($this->data['User']['id']);
  957. $usernames = trim($this->data['User']['username']);
  958. $email = trim($this->data['User']['email']);
  959. /*$criteria .= " and User.id LIKE '%".$id."%' and User.email LIKE '%".$email."%' and User.username LIKE '%".$usernames."%' and User.user_group_master_id=4";*/
  960. $criteria .= " and User.id LIKE '%".$id."%' and User.username LIKE '%".$usernames."%' ";
  961. if($email!="")
  962. $criteria .= " and UserDetails.email LIKE '%".$email."%'" ;
  963. $criteria .=" and User.user_group_master_id=3 ";
  964. list($order,$limit,$page) = $this->Pagination->init($criteria);
  965. $this->set('users', $this->User->findAll($criteria, NULL, $order, $limit, $page));
  966. }
  967. else
  968. {
  969. $criteria= "1";
  970. if(isset($_REQUEST['page']))
  971. {
  972. $page = $_REQUEST['page'];
  973. }
  974. $criteria .=" and User.user_group_master_id=3 ";
  975. list($order,$limit,$page) = $this->Pagination->init($criteria);
  976. $this->set('users', $this->User->findAll($criteria, NULL, $order, $limit, $page));
  977. }
  978. }
  979. }
  980. else if(empty($_GET['searchkey']) && !empty($_GET['search']))
  981. {
  982. $criteria="1";
  983. $this->data['User']['search'] = $_GET['search'];
  984. $search=trim($this->data['User']['search']);
  985. $criteria .= " and User.username LIKE '".$search."%' and User.user_group_master_id=3";
  986. list($order,$limit,$page) = $this->Pagination->init($criteria);
  987. $this->set('users', $this->User->findAll($criteria, NULL, $order, $limit, $page));
  988. }
  989. else if(!empty($_GET['searchkey']) || !empty($_GET['search']))
  990. {
  991. $criteria="1";
  992. if($_GET['searchkey'] == 'block' && empty($_GET['search']))
  993. {
  994. $criteria .= " and User.user_status = '1' and User.user_group_master_id=3";
  995. list($order,$limit,$page) = $this->Pagination->init($criteria);
  996. $this->set('users', $this->User->findAll($criteria, NULL, $order, $limit, $page));
  997. }
  998. else if($_GET['searchkey'] == 'unblock' && empty($_GET['search']))
  999. {
  1000. $criteria .= " and User.user_status = '0' and User.user_group_master_id=3";
  1001. list($order,$limit,$page) = $this->Pagination->init($criteria);
  1002. $this->set('users', $this->User->findAll($criteria, NULL, $order, $limit, $page));
  1003. }
  1004. else if(!empty($_GET['search']))
  1005. {
  1006. $this->data['User']['search'] = $_GET['search'];
  1007. if($_GET['searchkey'] == 'block')
  1008. $this->data['User']['searchkey'] = 0;
  1009. else if($_GET['searchkey'] == 'unblock')
  1010. $this->data['User']['searchkey'] = 1;
  1011. $search=trim($this->data['User']['search']);
  1012. $searchkey=$this->data['User']['searchkey'];
  1013. $criteria .= " and User.username LIKE '".$search."%' and User.status='".$searchkey."' and User.user_group_master_id=3";
  1014. list($order,$limit,$page) = $this->Pagination->init($criteria);
  1015. $this->set('users', $this->User->findAll($criteria, NULL, $order, $limit, $page));
  1016. }
  1017. }
  1018. else
  1019. {
  1020. $criteria= " User.user_group_master_id=3";
  1021. list($order,$limit,$page) = $this->Pagination->init($criteria);
  1022. $this->set('users', $this->User->findAll($criteria, NULL, $order, $limit, $page));
  1023. }
  1024. }
  1025. /////////////////////////////////////////////////////////////////////////////////////////
  1026. ////////////////////////////END OF PHOTOGRAPHER PART///////////////////////////////////////////
  1027. /////////////////////////////////////////////////////////////////////////////////////////
  1028. /////////////////////////////////////////////////////////////////////////////////////////
  1029. ////////////////////////////START OF USER PHOT UPLOAD PART///////////////////////////////////////////
  1030. /////////////////////////////////////////////////////////////////////////////////////////
  1031. function manageuserphoto()
  1032. {
  1033. $this->checkSession();
  1034. $this->layout = 'default_user';
  1035. $this->set('menu_id', $_REQUEST['menu']);
  1036. ///////////*******SEARCHING FOR USER********///////////////
  1037. if(isset($this->data))
  1038. {
  1039. if(!empty($this->data['User']['hid']))
  1040. {
  1041. //IF USER SEARCHED BY SEARCH FIELD//
  1042. $criteria="1";
  1043. if(!empty($this->data['User']['id']) || !empty($this->data['User']['username']) || !empty($this->data['User']['email']))
  1044. {
  1045. $id=trim($this->data['User']['id']);
  1046. $usernames = trim($this->data['User']['username']);
  1047. $email = trim($this->data['User']['email']);
  1048. $criteria .= " and User.id LIKE '%".$id."%' and User.email LIKE '%".$email."%' and User.username LIKE '%".$usernames."%'";
  1049. list($order,$limit,$page) = $this->Pagination->init($criteria);
  1050. $this->set('users', $this->User->findAll($criteria, NULL, $order, $limit, $page));
  1051. }
  1052. else
  1053. {
  1054. $criteria= "1";
  1055. if(isset($_REQUEST['page']))
  1056. {
  1057. $page = $_REQUEST['page'];
  1058. }
  1059. list($order,$limit,$page) = $this->Pagination->init($criteria);
  1060. $this->set('users', $this->User->findAll($criteria, NULL, $order, $limit, $page));
  1061. }
  1062. }
  1063. }
  1064. //IF USER SEARCHED BY SEARCHKEY//
  1065. else if(empty($_GET['searchkey']) && !empty($_GET['search']))
  1066. {
  1067. $criteria="1 ";
  1068. $this->data['User']['search'] = $_GET['search'];
  1069. $search=trim($this->data['User']['search']);
  1070. $criteria .= " and User.username LIKE '".$search."%'";
  1071. list($order,$limit,$page) = $this->Pagination->init($criteria);
  1072. $this->set('users', $this->User->findAll($criteria, NULL, $order, $limit, $page));
  1073. }
  1074. else if(!empty($_GET['searchkey']) || !empty($_GET['search']))
  1075. {
  1076. $criteria="1";
  1077. if($_GET['searchkey'] == 'block' && empty($_GET['search']))
  1078. {
  1079. $criteria .= " and User.status = '0'";
  1080. list($order,$limit,$page) = $this->Pagination->init($criteria);
  1081. $this->set('users', $this->User->findAll($criteria, NULL, $order, $limit, $page));
  1082. }
  1083. else if($_GET['searchkey'] == 'unblock' && empty($_GET['search']))
  1084. {
  1085. $criteria .= " and User.status = '1'";
  1086. list($order,$limit,$page) = $this->Pagination->init($criteria);
  1087. $this->set('users', $this->User->findAll($criteria, NULL, $order, $limit, $page));
  1088. }
  1089. else if(!empty($_GET['search']))
  1090. {
  1091. $this->data['User']['search'] = $_GET['search'];
  1092. if($_GET['searchkey'] == 'block')
  1093. $this->data['User']['searchkey'] = 0;
  1094. else if($_GET['searchkey'] == 'unblock')
  1095. $this->data['User']['searchkey'] = 1;
  1096. $search=trim($this->data['User']['search']);
  1097. $searchkey=$this->data['User']['searchkey'];
  1098. $criteria .= " and User.username LIKE '".$search."%' and User.status='".$searchkey."'";
  1099. list($order,$limit,$page) = $this->Pagination->init($criteria);
  1100. $this->set('users', $this->User->findAll($criteria, NULL, $order, $limit, $page));
  1101. }
  1102. }
  1103. else if(!empty($_GET['order']))
  1104. {
  1105. $criteria="1";
  1106. $col = $_REQUEST['searchby'];
  1107. if($_REQUEST['order'] == 'desc')
  1108. {
  1109. $order= " User.".$col." desc";
  1110. list($order,$limit,$page) = $this->Pagination->init($criteria);
  1111. $this->set('users', $this->User->findAll($criteria, NULL, $order, $limit, $page));
  1112. }
  1113. else
  1114. {
  1115. $order= " User.".$col." asc";
  1116. list($order,$limit,$page) = $this->Pagination->init($criteria);
  1117. $this->set('users', $this->User->findAll($criteria, NULL, $order, $limit, $page));
  1118. }
  1119. }
  1120. else
  1121. {
  1122. //$criteria= "1";
  1123. //list($order,$limit,$page) = $this->Pagination->init($criteria);
  1124. //$this->set('users', $this->User->findAll($criteria, NULL, $order, $limit, $page));
  1125. //$qry = "select * from users as User, user_photo_albums as UserPhotoAlbum where User.id = UserPhotoAlbum.user_id";
  1126. $this->User->unbindModel(array('hasOne' => array('UserDetails')));
  1127. //$this->User->UserPhotoAlbum->bindModel(array('belongsTo' => array('User', 'UserPhotoAlbum')));
  1128. //$users = $this->User->UserPhotoAlbum->findAll(array('UserPhotoAlbum.user_id' => 3));
  1129. //$this->User->unbindModel(array('hasMany' => array('UserPhotoAlbum')));
  1130. $sql = "SELECT * FROM `users` AS `User`, `user_photo_albums` as `UserPhotoAlbums`";
  1131. $criteria=" where User.id = UserPhotoAlbum.user_id";
  1132. //$sql="1";
  1133. list($order,$limit,$page) = $this->Pagination->init($criteria);
  1134. $this->set('users', $this->User->findAll($sql, NULL, $order, $limit, $page));
  1135. }
  1136. }
  1137. /////////////////////////////////////////////////////////////////////////////////////////
  1138. ////////////////////////////END OF USER PHOT0 UPLOAD PART///////////////////////////////////////////
  1139. /////////////////////////////////////////////////////////////////////////////////////////
  1140. #####################33 REPORT ABUSE SECTION ##########################
  1141. function managereport()
  1142. {
  1143. $this->checkSession();
  1144. $this->layout = 'default_user';
  1145. $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 " ;
  1146. $from = " FROM report_abuse ";
  1147. $where = " WHERE 1 ";
  1148. $others = " GROUP BY report_abuse.abuse_url ORDER BY report_abuse.id " ;
  1149. $CountField=" report_abuse.id ";
  1150. $PassParameter="";
  1151. //echo $select;die();
  1152. $this->set("controller","users");
  1153. $this->set("action","managereport");
  1154. $this->pagination($select,$from,$where,$others,$CountField,$this->params['url'],$PassParameter);
  1155. if(isset($this->params['url']['Page']))
  1156. {
  1157. $this->render("managereport2","ajax");
  1158. }
  1159. }
  1160. function changereportstatus($recorID=NULL , $status=NULL)
  1161. {
  1162. $getstaus = "SELECT * from report_abuse where id='".$recorID."'";
  1163. $getstaus_res = mysql_query($getstaus);
  1164. if(mysql_num_rows($getstaus_res)>0)
  1165. {
  1166. $getstaus_array = mysql_fetch_array($getstaus_res);
  1167. $updatesql = "UPDATE report_abuse SET admin_block='".$status."' where abuse_url='".$getstaus_array['abuse_url']."' ";
  1168. @mysql_query($updatesql );
  1169. }
  1170. $this->set('statusmsg', $status) ;
  1171. $this->set('statusId', $recorID) ;
  1172. $this->render("reportstatusupdate","ajax");
  1173. }
  1174. ################################# REPORT Bug SECTION starts ################################
  1175. function managereportbug()
  1176. {
  1177. $this->checkSession();
  1178. $this->layout = 'default_user';
  1179. $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 " ;
  1180. $from = " FROM report_bug ";
  1181. $where = " WHERE 1 ";
  1182. $others = " ORDER BY report_bug.id " ;
  1183. $CountField=" report_bug.id ";
  1184. $PassParameter="";
  1185. //echo $select;die();
  1186. $this->set("controller","users");
  1187. $this->set("action","managereportbug");
  1188. $this->pagination($select,$from,$where,$others,$CountField,$this->params['url'],$PassParameter);
  1189. if(isset($this->params['url']['Page']))
  1190. {
  1191. $this->render("managereportbug2","ajax");
  1192. }
  1193. }
  1194. function changereportbugstatus($recorID=NULL , $status=NULL)
  1195. {
  1196. $getstaus = "SELECT * from report_bug where id='".$recorID."'";
  1197. $getstaus_res = mysql_query($getstaus);
  1198. if(mysql_num_rows($getstaus_res)>0)
  1199. {
  1200. $getstaus_array = mysql_fetch_array($getstaus_res);
  1201. //$updatesql = "UPDATE report_bug SET admin_block='".$status."' where abuse_url='".$getstaus_array['abuse_url']."' ";
  1202. $updatesql = "UPDATE report_bug SET admin_block='".$status."' where id='".$recorID."'";
  1203. @mysql_query($updatesql );
  1204. }
  1205. $this->set('statusmsg', $status) ;
  1206. $this->set('statusId', $recorID) ;
  1207. $this->render("bugreportstatusupdate","ajax");
  1208. }
  1209. ############################# REPORT Bug SECTION Ends ############################################
  1210. ################################# Feedback SECTION starts ################################
  1211. function managefeedback()
  1212. {
  1213. $this->checkSession();
  1214. $this->layout = 'default_user';
  1215. $select = "SELECT feedback.* " ;
  1216. $from = " FROM feedback ";
  1217. $where = " WHERE 1 ";
  1218. $others = " ORDER BY feedback.id " ;
  1219. $CountField=" feedback.id ";
  1220. $PassParameter="";
  1221. //echo $select;die();
  1222. $this->set("controller","users");
  1223. $this->set("action","managefeedback");
  1224. $this->pagination($select,$from,$where,$others,$CountField,$this->params['url'],$PassParameter);
  1225. if(isset($this->params['url']['Page']))
  1226. {
  1227. $this->render("managefeedback2","ajax");
  1228. }
  1229. }
  1230. function changefeedbackstatus($recorID=NULL , $status=NULL)
  1231. {
  1232. $getstaus = "SELECT * from feedback where id='".$recorID."'";
  1233. $getstaus_res = mysql_query($getsta

Large files files are truncated, but you can click here to view the full file