DpyhCountryViewerAction.class.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. class DpyhCountryViewerAction extends CommonAction {
  3. const tableName = 'dpyh_country_viewer';
  4. /*
  5. */
  6. function sys_list(){
  7. $list = new \Jms\Gui\ClGrid();
  8. $list->sql_filter = function($search,&$cond){
  9. $cond['RoleId'] = \Zndp\User\RoleEnum::COUNTRY_CLIENT;
  10. };
  11. $list->display($this);
  12. }
  13. /*
  14. */
  15. function sys_addedit(){
  16. $form = new \Jiaruan\LigerIframeForm();
  17. $form->before_add = function(&$data){
  18. $data['ProjectID'] = C('CC_PROJECT_ID');
  19. $data['RoleId'] = \Zndp\User\RoleEnum::COUNTRY_CLIENT;
  20. };
  21. $form->before_save = function(&$data){
  22. $id = I('get.id');
  23. $data['UserName'] = trim($data['UserName']);
  24. $data['Password'] = trim($data['Password']);
  25. $cond = array('ID'=>$id);
  26. $userinfo = M('uc_user')->where($cond)->field('UserName,Password')->find();
  27. if($data['UserName'] != $userinfo['UserName'] && is_username_exists( $userinfo['ID'],$data['UserName'] ) ){
  28. json_fail('该用户名已存在,请换一个!');
  29. }
  30. if( $data['Password'] != $userinfo['Password'] ){
  31. $data['Password'] = (new \Zndp\User\Util)->encPwd( $data['Password'] );
  32. }else{
  33. unset($data['Password']);
  34. }
  35. };
  36. $form->display($this);
  37. }
  38. /*
  39. */
  40. public function sys_delete_country(){
  41. $id = I('get.id');
  42. if(!$id){
  43. json_fail('ID不存在!');
  44. }
  45. $where =array('ID'=>$id);
  46. $result = M('dpyh_country_viewer')->where($where)->delete();
  47. if(!$result){
  48. json_fail('删除失败!');
  49. }
  50. json_success('删除成功!');
  51. }
  52. }