Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
huangxuan258
whatsns内容付费问答系统
提交
07160d8d
whatsns内容付费问答系统
项目概览
huangxuan258
/
whatsns内容付费问答系统
2021-04-29 05:05:01同步失败
通知
3
Star
2
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
whatsns内容付费问答系统
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
07160d8d
编写于
6月 13, 2020
作者:
huangxuan258
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
后台问题管理增加回答功能,可以指定回答人从当前用户,指定专家,指定马甲或者指定具体人,支持富文本回答
上级
cedb0cf2
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
297 addition
and
4 deletion
+297
-4
application/controllers/Admin/Admin_question.php
application/controllers/Admin/Admin_question.php
+76
-1
application/views/admin/questionlist.php
application/views/admin/questionlist.php
+221
-3
未找到文件。
application/controllers/Admin/Admin_question.php
浏览文件 @
07160d8d
...
...
@@ -15,7 +15,82 @@ class Admin_question extends ADMIN_Controller {
function
index
()
{
$this
->
searchquestion
();
}
/**
* 发布回答
* @date: 2020年6月13日 下午12:21:37
* @author: 61703
* @param: variable
* @return:
*/
function
addanswer
(){
$qid
=
intval
(
$_POST
[
'qid'
]);
$content
=
addslashes
(
$_POST
[
'content'
]);
$author
=
addslashes
(
$_POST
[
'author'
]);
$question
=
$this
->
db
->
get_where
(
'question'
,
array
(
'id'
=>
$qid
))
->
row_array
();
if
(
!
$question
){
$message
[
'code'
]
=
2001
;
$message
[
'msg'
]
=
"问题不存在"
;
echo
json_encode
(
$message
);
exit
();
}
$user
=
$this
->
db
->
get_where
(
'user'
,
array
(
'username'
=>
$author
))
->
row_array
();
if
(
!
$user
){
$message
[
'code'
]
=
2002
;
$message
[
'msg'
]
=
"回答用户[
$author
]不存在"
;
echo
json_encode
(
$message
);
exit
();
}
if
(
empty
(
$content
)
||
strip_tags
(
$content
)
==
''
){
$message
[
'code'
]
=
2003
;
$message
[
'msg'
]
=
"回答内容不能为空且必须包含文字描述"
;
echo
json_encode
(
$message
);
exit
();
}
//判断此人是否已经回答过该问题
$useransser
=
$this
->
db
->
get_where
(
'answer'
,
array
(
'author'
=>
$author
,
'qid'
=>
$qid
))
->
row_array
();
if
(
$useransser
){
$message
[
'code'
]
=
2004
;
$message
[
'msg'
]
=
"该用户已经回答过此问题"
;
echo
json_encode
(
$message
);
exit
();
}
//插入回答问题
$adddata
=
array
(
'author'
=>
$user
[
'username'
],
'authorid'
=>
$user
[
'uid'
],
'content'
=>
$content
,
'qid'
=>
$qid
,
'title'
=>
$question
[
'title'
],
'time'
=>
time
(),
'ip'
=>
getip
()
);
$this
->
db
->
insert
(
'answer'
,
$adddata
);
$aid
=
$this
->
db
->
insert_id
();
if
(
$aid
>
0
){
$message
[
'code'
]
=
2000
;
$message
[
'msg'
]
=
"提交成功"
;
echo
json_encode
(
$message
);
exit
();
}
else
{
$message
[
'code'
]
=
2005
;
$message
[
'msg'
]
=
"发布问题失败"
;
echo
json_encode
(
$message
);
exit
();
}
}
function
searchquestion
(
$msg
=
''
,
$ty
=
''
)
{
if
(
$this
->
uri
->
rsegments
[
3
]
!=
''
&&
$this
->
uri
->
rsegments
[
3
]
!=
'0'
)
{
...
...
application/views/admin/questionlist.php
浏览文件 @
07160d8d
...
...
@@ -32,7 +32,7 @@
<td
width=
"20%"
><label
>
注册
日期:
</label>
发布
日期:
</label>
<div
class=
"input-group date form-date"
data-date=
""
data-date-format=
"dd MM yyyy"
data-link-field=
"dtp_input2"
data-link-format=
"yyyy-mm-dd"
>
<input
class=
"form-control"
size=
"16"
id=
"timestart"
name=
"srchdatestart"
value=
"{$srchdatestart}"
readonly=
""
>
<span
class=
"input-group-addon"
><span
class=
"icon-remove"
></span></span>
...
...
@@ -70,8 +70,9 @@
<td
width=
"10%"
>
回答/查看
</td>
<td
width=
"5%"
>
状态
</td>
<td
width=
"10%"
>
IP
</td>
<td
width=
"12%"
>
提问时间
</td>
<td
width=
"18%"
>
已推荐
</td>
<td
width=
"10%"
>
提问时间
</td>
<td
width=
"10%"
>
已推荐
</td>
<td
width=
"10%"
>
操作
</td>
</tr>
<!--{if isset($questionlist)} {loop $questionlist $question}-->
<tr>
...
...
@@ -87,6 +88,7 @@
<td
class=
"altbg2"
>
{$question['ip']}
</td>
<td
class=
"altbg2"
>
{$question['format_time']}
</td>
<td
class=
"altbg2"
>
{if $question['status']==6}
<img
src=
"{SITE_URL}static/css/admin/icn_6.gif"
>
{else}否{/if}
</td>
<td
class=
"altbg2"
><button
data-id=
"{$question['id']}"
data-title=
"{$question['title']}"
type=
"button"
data-toggle=
"modal"
data-target=
"#addanswer"
class=
"btn btn-success answerqid"
>
补充回答
</button></td>
</tr>
<!--{eval $content=htmlspecialchars($question['description']);}-->
<input
type=
"hidden"
id=
"cont_{$question['id']}"
value=
"{$content}"
>
...
...
@@ -168,10 +170,226 @@
</table>
</form>
</div>
<div
class=
"modal fade"
id=
"addanswer"
>
<div
class=
"modal-dialog"
>
<div
class=
"modal-content"
>
<div
class=
"modal-header"
>
<button
type=
"button"
class=
"close"
data-dismiss=
"modal"
><span
aria-hidden=
"true"
>
×
</span><span
class=
"sr-only"
>
关闭
</span></button>
<h4
class=
"modal-title"
>
补充回答
<span
style=
"color:blue;"
id=
"current_question_title"
></span></h4>
</div>
<div
class=
"modal-body"
>
<form
class=
"form-horizontal"
>
<h5>
指定回答人:
</h5><hr>
<div
class=
"form-group"
>
<div
class=
"col-sm-12"
>
<div
class=
"radio"
>
<label>
<input
type=
"radio"
checked
value=
"1"
name=
"answerauthor"
>
当前登录人
</label>
</div>
<div
class=
"radio"
style=
"margin-left:10px;"
>
<label>
<input
type=
"radio"
value=
"2"
name=
"answerauthor"
>
专家回答
</label>
</div>
<div
class=
"radio"
style=
"margin-left:10px;"
>
<label>
<input
type=
"radio"
value=
"3"
name=
"answerauthor"
>
马甲回答
</label>
</div>
<div
class=
"radio"
style=
"margin-left:10px;"
>
<label>
<input
type=
"radio"
value=
"4"
name=
"answerauthor"
>
其它用户回答
</label>
</div>
</div>
</div>
<!-- 如果是专家回答 -->
<div
class=
"answerbyexpert"
style=
"display:none;"
>
<h5>
选择专家:
</h5><hr>
<div
class=
"form-group"
>
<div
class=
"col-sm-3"
>
<select
class=
"form-control"
id=
"expertusername"
>
{eval $expertlist=$this->getlistbysql("select uid,username,expert from ".$this->db->dbprefix."user where expert=1 limit 0,100");}
{loop $expertlist $expert}
<option
value=
"{$expert['uid']}"
>
{$expert['username']}
</option>
{/loop}
</select>
</div>
</div>
</div>
<!-- 如果是马甲回答 -->
<div
class=
"answerbymajia"
style=
"display:none;"
>
<h5>
选择马甲:
</h5><hr>
<div
class=
"form-group"
>
<div
class=
"col-sm-3"
>
<select
class=
"form-control"
id=
"majiausername"
>
{eval $majialist=$this->getlistbysql("select uid,username,expert from ".$this->db->dbprefix."user where fromsite=1 limit 0,100");}
{loop $majialist $majia}
{if !empty($majia['username'])}
<option
value=
"{$majia['uid']}"
>
{$majia['username']}
</option>
{/if}
{/loop}
</select>
</div>
</div>
</div>
<div
class=
"form-group"
id=
"otherauthor"
style=
"display:none;"
>
<label
for=
"exampleInputAccount4"
class=
"col-sm-1"
style=
"width:11%"
>
用户名
</label>
<div
class=
"col-md-6 col-sm-10"
>
<input
type=
"text"
class=
"form-control"
id=
"answerusername"
placeholder=
"填写社区用户账号名"
>
</div>
</div>
<h5>
回答内容:
</h5><hr>
<!--{template editor}-->
</form>
</div>
<div
class=
"modal-footer"
>
<button
type=
"button"
class=
"btn btn-default"
data-dismiss=
"modal"
>
关闭
</button>
<button
type=
"button"
id=
"btnanswer"
class=
"btn btn-primary"
>
提交发布
</button>
</div>
</div>
</div>
</div>
<style>
.clearfix
,
.clear
{
clear
:
none
;
}
</style>
<link
href=
"{SITE_URL}static/css/dist/lib/datetimepicker/datetimepicker.min.css"
rel=
"stylesheet"
>
<script
src=
"{SITE_URL}static/css/dist/lib/datetimepicker/datetimepicker.min.js"
></script>
<script
type=
"text/javascript"
>
$
(
"
.wangEditor-menu-container
"
).
removeClass
(
"
clearfix
"
);
var
currentansweruid
=
"
{$user['username']}
"
;
var
slid
=
1
;
var
_cqid
=
0
;
$
(
"
input:radio[name=answerauthor]
"
).
change
(
function
(){
slid
=
$
(
this
).
val
();
switch
(
slid
){
case
"
1
"
:
currentansweruid
=
{
$user
[
'
uid
'
]};
$
(
"
.answerbyexpert
"
).
hide
();
$
(
"
.answerbymajia
"
).
hide
();
$
(
"
#otherauthor
"
).
hide
();
break
;
case
"
2
"
:
currentansweruid
=
$
(
"
#expertusername
"
).
text
();
$
(
"
.answerbyexpert
"
).
show
();
$
(
"
.answerbymajia
"
).
hide
();
$
(
"
#otherauthor
"
).
hide
();
break
;
case
"
3
"
:
currentansweruid
=
$
(
"
#majiausername
"
).
text
();
$
(
"
.answerbymajia
"
).
show
();
$
(
"
#otherauthor
"
).
hide
();
$
(
"
.answerbyexpert
"
).
hide
();
break
;
case
"
4
"
:
currentansweruid
=
$
.
trim
(
$
(
"
#answerusername
"
).
val
());
$
(
"
.answerbymajia
"
).
hide
();
$
(
"
.answerbyexpert
"
).
hide
();
$
(
"
#otherauthor
"
).
show
();
break
;
}
})
$
(
"
#btnanswer
"
).
click
(
function
(){
if
(
slid
==
0
){
alert
(
"
请选择发布作者
"
);
return
false
;
}
switch
(
slid
){
case
"
1
"
:
currentansweruid
=
"
{$user['username']}
"
;
break
;
case
"
2
"
:
currentansweruid
=
$
(
"
#expertusername
"
).
find
(
"
option:selected
"
).
text
();
break
;
case
"
3
"
:
currentansweruid
=
$
(
"
#majiausername
"
).
find
(
"
option:selected
"
).
text
();
break
;
case
"
4
"
:
currentansweruid
=
$
.
trim
(
$
(
"
#answerusername
"
).
val
());
break
;
}
if
(
currentansweruid
==
''
){
alert
(
"
发布人不能为空
"
);
return
false
;
}
var
eidtor_content
=
''
;
if
(
typeof
testEditor
!=
"
undefined
"
){
var
tmptxt
=
$
.
trim
(
testEditor
.
getMarkdown
());
if
(
tmptxt
==
''
){
alert
(
"
回答内容不能为空
"
);
return
;
}
eidtor_content
=
testEditor
.
getHTML
();
}
else
{
if
(
typeof
UE
!=
"
undefined
"
)
{
eidtor_content
=
editor
.
getContent
();
}
else
{
eidtor_content
=
$
.
trim
(
$
(
"
#editor
"
).
val
());
}
}
if
(
$
.
trim
(
eidtor_content
)
==
''
){
alert
(
"
内容不能为空
"
);
return
false
;
}
var
adddata
=
{
qid
:
_cqid
,
content
:
eidtor_content
,
author
:
currentansweruid
};
var
addurl
=
"
{url admin_question/addanswer}
"
;
$
.
ajax
({
//提交数据的类型 POST GET
type
:
"
POST
"
,
//提交的网址
url
:
addurl
,
//提交的数据
data
:
adddata
,
//返回数据的格式
datatype
:
"
json
"
,
//"xml", "html", "script", "json", "jsonp", "text".
//在请求之前调用的函数
beforeSend
:
function
(){
},
//成功返回之后调用的函数
success
:
function
(
result
){
var
result
=
eval
(
"
(
"
+
result
+
"
)
"
);
console
.
log
(
result
);
alert
(
result
.
msg
);
}
,
//调用执行后调用的函数
complete
:
function
(
XMLHttpRequest
,
textStatus
){
},
//调用出错执行的函数
error
:
function
(){
//请求出错处理
alert
(
"
提交出现问题
"
);
}
});
});
$
(
"
.answerqid
"
).
click
(
function
(){
_cqid
=
$
(
this
).
attr
(
"
data-id
"
);
var
_ctitle
=
$
(
this
).
attr
(
"
data-title
"
);
$
(
"
#current_question_title
"
).
html
(
"
[
"
+
_ctitle
+
"
]
"
);
});
$
(
"
.form-date
"
).
datetimepicker
(
{
language
:
"
zh-CN
"
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录