/**
  * 身份扩展资料配置 及 注册时要填写的资料配置
  * @author 郑钟良<*****@*****.**>
  */
 public function configField()
 {
     $aRoleId = I('id', 0, 'intval');
     if (!$aRoleId) {
         $this->error(L('_PLEASE_CHOOSE_YOUR_IDENTITY_'));
     }
     $aType = I('get.type', 0, 'intval');
     //扩展资料设置类型:1注册时要填写资料配置,0扩展资料字段设置
     if ($aType) {
         //注册时要填写资料配置
         $type = 'register_expend_field';
     } else {
         //扩展资料字段设置
         $type = 'expend_field';
     }
     $map = getRoleConfigMap($type, $aRoleId);
     if (IS_POST) {
         $data['value'] = '';
         if (isset($_POST['fields'])) {
             sort($_POST['fields']);
             $data['value'] = implode(',', array_unique($_POST['fields']));
         }
         if ($this->roleConfigModel->where($map)->find()) {
             $result = $this->roleConfigModel->saveData($map, $data);
         } else {
             $data = array_merge($map, $data);
             $result = $this->roleConfigModel->addData($data);
         }
         if ($result === false) {
             $this->error(L('_FAILED_') . $this->roleConfigModel->getError());
         } else {
             clear_role_cache($aRoleId);
             $this->success(L('_OPERATION_SUCCESS_'));
         }
     } else {
         $aType = I('get.type', 0, 'intval');
         //扩展资料设置类型:1注册时要填写资料配置,0扩展资料字段设置
         $mRole_list = $this->roleModel->field('id,title')->select();
         $fields = $this->roleConfigModel->where($map)->getField('value');
         if ($aType == 1) {
             //注册时要填写资料配置
             $map_fields = getRoleConfigMap('expend_field', $aRoleId);
             $expend_fields = $this->roleConfigModel->where($map_fields)->getField('value');
             $field_list = $expend_fields ? $this->getExpendField($expend_fields) : array();
             $this->meta_title = L('_REGISTRATION_TO_FILL_IN_THE_DATA_CONFIGURATION_');
             $tpl = 'fieldregister';
             //模板地址
             $tab = 'fieldRegister';
         } else {
             //扩展资料字段设置
             $field_list = $this->getExpendField();
             $this->meta_title = L('_EXTENDED_DATA_FIELD_SETTINGS_');
             $tpl = 'field';
             //模板地址
             $tab = 'field';
         }
         $this->assign('field_list', $field_list);
         $this->assign('role_list', $mRole_list);
         $this->assign('this_role', array('id' => $aRoleId, 'fields' => $fields));
         $this->assign('tab', $tab);
         $this->display($tpl);
     }
 }
示例#2
0
 /**
  * 角色扩展资料配置 及 注册时要填写的资料配置
  * @author 郑钟良<*****@*****.**>
  */
 public function configField()
 {
     $aRoleId = I('id', 0, 'intval');
     if (!$aRoleId) {
         $this->error('请选择角色!');
     }
     $aType = I('get.type', 0, 'intval');
     //扩展资料设置类型:1注册时要填写资料配置,0扩展资料字段设置
     if ($aType) {
         //注册时要填写资料配置
         $type = 'register_expend_field';
     } else {
         //扩展资料字段设置
         $type = 'expend_field';
     }
     $map = getRoleConfigMap($type, $aRoleId);
     if (IS_POST) {
         $data['value'] = '';
         if (isset($_POST['fields'])) {
             sort($_POST['fields']);
             $data['value'] = implode(',', array_unique($_POST['fields']));
         }
         if ($this->roleConfigModel->where($map)->find()) {
             $result = $this->roleConfigModel->saveData($map, $data);
         } else {
             $data = array_merge($map, $data);
             $result = $this->roleConfigModel->addData($data);
         }
         if ($result === false) {
             $this->error('操作失败' . $this->roleConfigModel->getError());
         } else {
             clear_role_cache($aRoleId);
             $this->success('操作成功!');
         }
     } else {
         $aType = I('get.type', 0, 'intval');
         //扩展资料设置类型:1注册时要填写资料配置,0扩展资料字段设置
         $mRole_list = $this->roleModel->field('id,title')->select();
         $fields = $this->roleConfigModel->where($map)->getField('value');
         if ($aType == 1) {
             //注册时要填写资料配置
             $map_fields = getRoleConfigMap('expend_field', $aRoleId);
             $expend_fields = $this->roleConfigModel->where($map_fields)->getField('value');
             $field_list = $expend_fields ? $this->getExpendField($expend_fields) : array();
             $this->meta_title = '注册时要填写资料配置';
             $tpl = 'fieldregister';
             //模板地址
             $tab = 'fieldRegister';
         } else {
             //扩展资料字段设置
             $field_list = $this->getExpendField();
             $this->meta_title = '扩展资料字段设置';
             $tpl = 'field';
             //模板地址
             $tab = 'field';
         }
         $this->assign('field_list', $field_list);
         $this->assign('role_list', $mRole_list);
         $this->assign('this_role', array('id' => $aRoleId, 'fields' => $fields));
         $this->assign('tab', $tab);
         $this->display($tpl);
     }
 }