meraproject/module/academy/project/teacher/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

71 lines
2.0 KiB
PHP
Raw Permalink 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\project\teacher;
use academy\Course;
use common\Image;
use ms\ms\structure\msControllerTable;
use academy\project\Teacher;
use academy\course\Teacher as CourseTeacher;
class Api extends msControllerTable {
static $class = 'academy\project\Teacher';
// Работа с проифилями
static function profileSetDescr(){
if(IF_PROFILE){
$teacher = Teacher::isProfileMy($_POST['teacher_id']);
$descr = trim($_POST['descr']);
if($teacher and $descr){
Teacher::updateById($teacher[Teacher::$ID],[Teacher::$CONTENT=>$descr]);
}
}
}
static function profileSetName(){
if(IF_PROFILE){
$teacher = Teacher::isProfileMy($_POST['teacher_id']);
$name = trim($_POST['name']);
if($teacher and $name){
Teacher::updateById($teacher[Teacher::$ID],[Teacher::$NAME=>$name]);
}
}
}
static function profileSetAva(){
if(IF_PROFILE){
$teacher = Teacher::isProfileMy($_POST['teacher_id']);
$img = Image::isProfileMy($_POST['image_id']);
if($teacher and $img){
Teacher::updateById($teacher[Teacher::$ID],[Teacher::$IMAGE=>$img[Image::$ID]]);
}
}
}
static function profileCreate(){
$res = [];
if(IF_PROFILE){
if($COURSE = Course::isProfileMy($_POST['course_id'])) {
$r = Teacher::insert([
Teacher::$NAME => $_POST['name'],
Teacher::$ACCOUNT => \Site::$owner_id,
]);
$r = CourseTeacher::insert($a = [
CourseTeacher::$PROJECT => $COURSE[Course::$PROJECT],
CourseTeacher::$COURSE => $COURSE[COURSE::$ID],
CourseTeacher::$TEACHER => $r->id,
CourseTeacher::$ACCOUNT => \Site::$owner_id,
]);
$res['id'] = $r->id;
}
}
echo je($res);
}
}