meraproject/module/academy/course/lesson/controller.php
keboss-m 5c21d25d45 Initial commit: Merakomis portal, Docker stack and user-reader API.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-24 11:04:05 +03:00

55 lines
1.6 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?
namespace controller\academy\course\lesson;
use academy\Course;
use academy\course\Section;
use ms\ms\structure\msControllerTable;
use academy\course\Lesson;
class Api extends msControllerTable {
static $class = 'academy\course\Lesson';
// Работа с проифилями
static function profileSetDescr(){
if(IF_PROFILE){
$lesson = Lesson::isProfileMy($_POST['lesson_id']);
$descr = trim($_POST['descr']);
if($lesson and $descr){
Lesson::updateById($lesson[Lesson::$ID],[Lesson::$CONTENT=>$descr]);
}
}
}
static function profileSetName(){
if(IF_PROFILE){
$lesson = Lesson::isProfileMy($_POST['lesson_id']);
$name = trim($_POST['name']);
if($lesson and $name){
Lesson::updateById($lesson[Lesson::$ID],[Lesson::$NAME=>$name]);
}
}
}
static function profileCreate(){
$res = [];
if(IF_PROFILE and $course = Course::isProfileMy($_POST['course_id'])){
$course_id = $course[Course::$ID];
$sections = Course::getLessons($course_id);
$section = array_pop($sections['sections']);
$section_id = $section[Section::$ID];
$r = Lesson::insert([
Lesson::$COURSE => $course_id,
Lesson::$SECTION => $section_id,
Lesson::$NAME => 'Новый урок',
Lesson::$ACCOUNT => \Site::$owner_id,
]);
$res['id'] = $r->id;
}
echo je($res);
}
}