name = dr_lang('单用户权限设置'); // 模板前缀(避免混淆) $this->tpl_prefix = 'member_quanxian_'; // 用于表储存的字段,后台可修改的表字段 $field = array ( 'uid' => array ( 'name' => '用户id', 'fieldname' => 'uid', 'ismain' => '1', 'fieldtype' => 'Text', 'setting' => array ( 'option' => array ( 'fieldtype' => 'INT', 'fieldlength' => '10', 'value' => '', 'width' => '', 'css' => '', ), 'validate' => array ( 'required' => '0', 'pattern' => '', 'errortips' => '', 'check' => '', 'filter' => '', 'formattr' => '', 'tips' => '', ), ), 'ismember' => '1', ), 'gid' => array ( 'name' => '用户组id', 'fieldname' => 'gid', 'ismain' => '1', 'fieldtype' => 'Text', 'setting' => array ( 'option' => array ( 'fieldtype' => 'INT', 'fieldlength' => '10', 'value' => '', 'width' => '', 'css' => '', ), 'validate' => array ( 'required' => '0', 'pattern' => '', 'errortips' => '', 'check' => '', 'filter' => '', 'formattr' => '', 'tips' => '', ), ), 'ismember' => '1', ), 'quanxian' => array ( 'name' => '权限设置', 'fieldname' => 'quanxian', 'ismain' => '1', 'fieldtype' => 'Selects', 'setting' => array ( 'option' => array ( 'options' => '选项名称1|1 选项名称2|2', 'value' => '', 'fieldtype' => '', 'fieldlength' => '', 'css' => '', ), 'validate' => array ( 'required' => '0', 'pattern' => '', 'errortips' => '', 'check' => '', 'filter' => '', 'formattr' => '', 'tips' => '', ), ), ), 'stime' => array ( 'name' => '开始日期', 'fieldname' => 'stime', 'ismain' => '1', 'fieldtype' => 'Date', 'setting' => array ( 'option' => array ( 'format2' => '1', 'is_left' => '0', 'value' => '', 'width' => '', 'color' => '', 'css' => '', ), 'validate' => array ( 'required' => '0', 'pattern' => '', 'errortips' => '', 'check' => '', 'filter' => '', 'formattr' => '', 'tips' => '', ), ), 'ismember' => '1', ), 'etime' => array ( 'name' => '结束日期', 'fieldname' => 'etime', 'ismain' => '1', 'fieldtype' => 'Date', 'setting' => array ( 'option' => array ( 'format2' => '1', 'is_left' => '0', 'value' => '', 'width' => '', 'color' => '', 'css' => '', ), 'validate' => array ( 'required' => '0', 'pattern' => '', 'errortips' => '', 'check' => '', 'filter' => '', 'formattr' => '', 'tips' => '', ), ), 'ismember' => '1', ), ); // 初始化数据表 $this->_init([ 'table' => 'member_quanxian', // (不带前缀的)表名字 'field' => $field, // 可查询的字段 'order_by' => 'id desc', // 列表排序,默认的排序方式 'date_field' => '', // 按时间段搜索字段,没有时间字段留空 ]); // 把公共变量传入模板 \Phpcmf\Service::V()->assign([ // 搜索字段 'field' => $field, 'is_time_where' => $this->init['date_field'], // 后台的菜单 'menu' => \Phpcmf\Service::M('auth')->_admin_menu( [ $this->name => [APP_DIR.'/'.\Phpcmf\Service::L('Router')->class.'/index', 'fa fa-code'], '添加' => [APP_DIR.'/'.\Phpcmf\Service::L('Router')->class.'/add', 'fa fa-plus'], '修改' => ['hide:'.APP_DIR.'/'.\Phpcmf\Service::L('Router')->class.'/edit', 'fa fa-edit'], ]) ]); } // 查看列表 public function index() { list($tpl) = $this->_List(); \Phpcmf\Service::V()->display($tpl); } // 添加内容 public function add() { list($tpl) = $this->_Post(0); \Phpcmf\Service::V()->display($tpl); } // 修改内容 public function edit() { list($tpl) = $this->_Post(intval(\Phpcmf\Service::L('input')->get('id'))); \Phpcmf\Service::V()->display($tpl); } // 删除内容 public function del() { $this->_Del( \Phpcmf\Service::L('Input')->get_post_ids(), function($rows) { // 删除前的验证 return dr_return_data(1, 'ok', $rows); }, function($rows) { // 删除后的处理 return dr_return_data(1, 'ok'); }, \Phpcmf\Service::M()->dbprefix($this->init['table']) ); } /** * 获取内容 * $id 内容id,新增为0 * */ protected function _Data($id = 0) { $row = parent::_Data($id); // 这里可以对内容进行格式化显示操处理 return $row; } // 格式化保存数据 protected function _Format_Data($id, $data, $old) { if (!$id) { // 当提交新数据时,把当前时间插入进去 //$data[1]['inputtime'] = SYS_TIME; } return $data; } // 保存内容 protected function _Save($id = 0, $data = [], $old = [], $func = null, $func2 = null) { $data = \Phpcmf\Service::L('input')->post('data'); return parent::_Save($id, $data, $old, function($id, $data, $old){ // 验证数据 /* if (!$data['title']) { return dr_return_data(0, '标题不能为空!', ['field' => 'title']); }*/ // 保存之前执行的函数,并返回新的数据 if (!$id) { // 当提交新数据时,把当前时间插入进去 //$data['inputtime'] = SYS_TIME; } return dr_return_data(1, null, $data); }, function ($id, $data, $old) { // 保存之后执行的动作 }); } }