Commit be66c8fb authored by 杨培's avatar 杨培

修改标题或内容后内容进入待审核状态

增加多个模型数据的XSS过滤等安全性
课程富文本编辑工具栏调整
其它BUG修复
parent d6caec43
...@@ -71,6 +71,21 @@ class Classes extends ActiveRecord ...@@ -71,6 +71,21 @@ class Classes extends ActiveRecord
]; ];
} }
/**
* @inheritdoc
*/
public function beforeSave($insert)
{
if (!parent::beforeSave($insert)) {
return FALSE;
}
$this->name = strip_tags($this->name);
$this->intro = \yii\helpers\HtmlPurifier::process($this->intro);
return TRUE;
}
/** /**
* @inheritdoc * @inheritdoc
*/ */
......
...@@ -69,6 +69,21 @@ class Teacher extends ActiveRecord ...@@ -69,6 +69,21 @@ class Teacher extends ActiveRecord
]; ];
} }
/**
* @inheritdoc
*/
public function beforeSave($insert)
{
if (!parent::beforeSave($insert)) {
return FALSE;
}
$this->name = strip_tags($this->name);
$this->intro = \yii\helpers\HtmlPurifier::process($this->intro);
return TRUE;
}
/** /**
* @inheritdoc * @inheritdoc
*/ */
......
...@@ -232,8 +232,11 @@ class MyCourseController extends \yii\web\Controller ...@@ -232,8 +232,11 @@ class MyCourseController extends \yii\web\Controller
throw new ForbiddenHttpException(); throw new ForbiddenHttpException();
} }
//是否提交重新审核,仅待审核和已拒绝状态允许重新进入审核 //内容是否还没完成,代表某些重新资料(视频,试看时间)可以更改
$isRecheck = in_array($course->status, [Course::STATUS_UNCHECK, Course::STATUS_FAILED]); $unready = in_array($course->status, [Course::STATUS_UNCHECK, Course::STATUS_FAILED]);
//是否重新审核,如标题和简介发生变更
$recheck = ($unready || $form->isMustRecheck($course));
$courseware = Courseware::findOne(['course_id' => $course->id]); $courseware = Courseware::findOne(['course_id' => $course->id]);
$coursewareUpdate = false; $coursewareUpdate = false;
...@@ -246,14 +249,11 @@ class MyCourseController extends \yii\web\Controller ...@@ -246,14 +249,11 @@ class MyCourseController extends \yii\web\Controller
$course->intro = $form->intro; $course->intro = $form->intro;
$course->recommend = $form->recommend; $course->recommend = $form->recommend;
$form->preview && $course->preview_pic = $form->preview['key']; $form->preview && $course->preview_pic = $form->preview['key'];
$unready && $course->free_time = $form->free_time;
if ($isRecheck) { $recheck && $course->status = Course::STATUS_UNCHECK;
$course->free_time = $form->free_time;
$course->status = Course::STATUS_UNCHECK;
}
//仅重审核时可以更换视频 //仅重审核时可以更换视频
if ($form->vuid && !$isRecheck) { if ($form->vuid && !$unready) {
Utils::ajaxResponse(false, '当前课程状态不允许更换视频!'); Utils::ajaxResponse(false, '当前课程状态不允许更换视频!');
} }
...@@ -289,7 +289,7 @@ class MyCourseController extends \yii\web\Controller ...@@ -289,7 +289,7 @@ class MyCourseController extends \yii\web\Controller
$coursewareUpdate = true; $coursewareUpdate = true;
} }
if ($isRecheck && $courseware->status != Course::STATUS_UNCHECK) { if ($recheck && $courseware->status != Course::STATUS_UNCHECK) {
$courseware->status = Course::STATUS_UNCHECK; $courseware->status = Course::STATUS_UNCHECK;
$coursewareUpdate = true; $coursewareUpdate = true;
} }
......
...@@ -89,9 +89,10 @@ class CoursePublishForm extends Model ...@@ -89,9 +89,10 @@ class CoursePublishForm extends Model
//} //}
$rules = [ $rules = [
[['tmp', 'name', 'price', 'preview', 'vuid'], 'required'], [['tmp', 'name', 'intro', 'price', 'preview', 'vuid'], 'required'],
[['id', 'free_time'], 'integer'], [['id', 'free_time'], 'integer'],
[['tmp', 'name', 'preview', 'intro'], 'string'], [['tmp', 'name', 'preview', 'intro'], 'string'],
[['name', 'intro'], 'trim'],
['recommend', 'boolean'], ['recommend', 'boolean'],
['free_time', 'default', 'value'=>0], ['free_time', 'default', 'value'=>0],
['free_time', 'integer', 'min' => 0, 'max' => 15], ['free_time', 'integer', 'min' => 0, 'max' => 15],
...@@ -105,6 +106,18 @@ class CoursePublishForm extends Model ...@@ -105,6 +106,18 @@ class CoursePublishForm extends Model
return $rules; return $rules;
} }
/**
* 检查内容是否必须重新审核
*
* @param \common\models\Course $course
* @return bool
*/
public function isMustRecheck($course)
{
$removeStr = [' ', "\t", "\r", "\n"]; //移除空格,制表符和换行
return md5(str_replace($removeStr, '', $course->name.$course->intro)) != md5(str_replace($removeStr, '', $this->name.$this->intro));
}
/** /**
* 检查上传七牛云文件是否可领取是否可领取 * 检查上传七牛云文件是否可领取是否可领取
* *
......
...@@ -65,6 +65,10 @@ module.exports = { ...@@ -65,6 +65,10 @@ module.exports = {
to = org; to = org;
} }
if (!to) {
return;
}
//绑定提示到元素上 //绑定提示到元素上
if (text) { if (text) {
if (to.tipIndex) { if (to.tipIndex) {
......
...@@ -10,6 +10,8 @@ module.exports = { ...@@ -10,6 +10,8 @@ module.exports = {
toolbarFloat: true, toolbarFloat: true,
toolbarFloatOffset: 60, toolbarFloatOffset: 60,
defaultImage: "/assets/img/placeholder.jpg", defaultImage: "/assets/img/placeholder.jpg",
toolbar: ['bold', 'italic', 'underline', 'fontScale', 'color', '|', 'alignment', 'indent', 'outdent', '|',
'ol', 'ul', 'blockquote', 'code', 'link', 'image', 'table'],
upload: { upload: {
url : '/my-course/upload', //文件上传的接口地址 url : '/my-course/upload', //文件上传的接口地址
params: { params: {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment