71 lines
2.0 KiB
PHP
71 lines
2.0 KiB
PHP
<?
|
||
|
||
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);
|
||
}
|
||
|
||
}
|
||
|
||
|