65 lines
2.0 KiB
PHP
65 lines
2.0 KiB
PHP
<?
|
|
|
|
namespace controller\academy\course\result;
|
|
|
|
use common\Video;
|
|
use themes\AcademyTheme;
|
|
use ms\ms\structure\msControllerTable;
|
|
use academy\Course;
|
|
use academy\course\Result;
|
|
use common\Image;
|
|
|
|
class Api extends msControllerTable {
|
|
|
|
static $class = 'academy\course\Result';
|
|
|
|
static function renderForSlider(){
|
|
echo AcademyTheme::renderResultSlide( Result::getByID($_GET['id']) );
|
|
}
|
|
|
|
static function profileRemove(){
|
|
if($result = Result::isProfileMy($_POST['id'])){
|
|
Result::deleteByID($result[Result::$ID]);
|
|
}
|
|
}
|
|
static function profileSetPos(){
|
|
if($result = Result::isProfileMy($_POST['id'])){
|
|
Result::updatePosForID($result[Result::$ID],$_POST['pos'],\Where::_operator(Result::$COURSE,'=',$result[Result::$COURSE]));
|
|
}
|
|
}
|
|
|
|
|
|
|
|
static function profileCreate(){
|
|
$res = [];
|
|
if(IF_PROFILE and $course = Course::isProfileMy($_POST['course_id'])){
|
|
|
|
$course_id = $course[Course::$ID];
|
|
$image_id = 0;
|
|
if($image = Image::isProfileMy($_POST['image'])){
|
|
$image_id = $image[Image::$ID];
|
|
}
|
|
$arr = [
|
|
Result::$COURSE => $course_id,
|
|
Result::$PROJECT => $course[Course::$PROJECT],
|
|
Result::$NAME => $_POST['name'],
|
|
Result::$ANNOTATION => $_POST['annotation'],
|
|
Result::$VIDEO_LINK => Video::formatYoutubeLink($_POST['video_link']),
|
|
Result::$IMAGE => $image_id,
|
|
Result::$CONTENT => AcademyTheme::checkContent($_POST['content']),
|
|
Result::$ACCOUNT => \Site::$owner_id,
|
|
];
|
|
if($result = Result::isProfileMy($_POST['result_id'])){
|
|
$r = Result::updateById($result[Result::$ID],$arr);
|
|
} else {
|
|
$r = Result::insert($arr);
|
|
}
|
|
$res['id'] = $r->id;
|
|
}
|
|
echo je($res);
|
|
}
|
|
|
|
}
|
|
|
|
|