<?php

/* ========================================================================
 * $Id: members.php 3025 2020-05-31 09:36:36Z onez $
 * 
 * Email: www@onez.cn
 * QQ: 6200103
 * HomePage: http://www.onez.cn
 * ========================================================================
 * Copyright 2016-2017 佳蓝科技.
 * 
 * ======================================================================== */

!defined('IN_ONEZ') && exit('Access Denied');
# index
#请求数据
if($MODE=='$post'){
  $action=onez()->gp('action');
  if($action=='data'){
    $action=onez()->gp('ac');
    if($action=='del'){
      $id=(int)onez()->gp('id');
      $user=onez()->gp('user');
      $G['this']->data()->open('sites')->delete("id='$id'$where");
      return $this->ok('删除成功','reload');
    }
    $siteId=onez()->gp('siteId');
    $data=array();
    $data['title']='用户管理';
    $data['siteId']=(int)$siteId;
    if($siteId>0){
      $data['btns'][]=array(
        'name'=>'添加新用户',
        'href'=>'/develop/members/edit.php?user=user'.$G['this']->site($siteId,'user').'&siteId='.$siteId,
        'args'=>'width=800&height=600&title=添加新用户',
      );
    }
    $datatable=$this->load('datatable');
    $datatable->set('edit',array(
      'event'=>array(
        'action'=>'/develop/members/edit.php?user=${namespace}&siteId=${index12}&id=${id}',
        'option'=>array(
          'width'=>800,
          'height'=>600,
        ),
      ),
    ));
    $datatable->set('del',array(
      'event'=>array(
        'postdata'=>array(
          'user'=>'${namespace}',
        ),
      ),
    ));
    $datatable->set('del','1');
    $datatable->set('fields','id,namespace,index12');
    $datatable->set('colFunc',function(&$rs,&$fields){
      global $G;
      $rs['grade']=$rs['key1'];
      $rs['username']=$rs['key2'];
      #$rs['password']=$rs['key3'];
      $rs['nickname']=$rs['key4'];
      !$rs['nickname'] && $rs['nickname']=$rs['key2'];
      $rs['createType']=$rs['key5'];
      $rs['email']=$rs['key6'];
      $rs['mobile']=$rs['key7'];
      $rs['ownerUid']=$rs['index11'];
      $rs['siteId']=$rs['index12'];
      $rs['avatar']=$G['this']->avatarU(substr($rs['namespace'],4));
    });
    $datatable->add('用户编号','id');
    $x='';
    $siteId=(int)onez()->gp('siteId');
    if($siteId){
      $x=" and index12='$siteId'";
    }else{
      $datatable->add('所属网站','sitename',array('function'=>function($rs){
        global $G;
        return $G['this']->site($rs['siteId'],'name');
      }));
    }
    $datatable->add('显示昵称','nickname',array('function'=>function($rs){
      global $G;
      return '<img src="'.$rs['avatar'].'" style="width:16px;height:16px;"> '.$rs['nickname'];
    }));
    $datatable->add('注册方式','createType');
    $datatable->add('登录账号','username');
    $datatable->add('注册时间','addtime',array('type'=>'time'));
    
    $r=$G['this']->user_before();
    $datatable->output($data,array(
      'query'=>"select * from $r[tablename] where tablename='member' and $r[where]$x order by id desc",
      'pagesize'=>20,
    ));
    #print_r($G['sql_query']);exit();
    $G['this']->user_after();
    $A['pagedata']=$data;
  }
  return;
}
$this->add(array(
  'type'=>'breadcrumb',
  'name'=>'面包屑导航',
  'data'=>'pagedata',
));
$this->add(array(
  'type'=>'datatable',
  'name'=>'数据列表',
  'data'=>'pagedata',
));

?>
