40 lines
1.0 KiB
PHP
40 lines
1.0 KiB
PHP
|
|
<?
|
|||
|
|
|
|||
|
|
namespace controller\academy\course\section;
|
|||
|
|
|
|||
|
|
use ms\ms\structure\msControllerTable;
|
|||
|
|
use academy\course\Section;
|
|||
|
|
use academy\Course;
|
|||
|
|
|
|||
|
|
class Api extends msControllerTable {
|
|||
|
|
|
|||
|
|
static $class = 'academy\course\Section';
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
// Работа с проифилями
|
|||
|
|
static function profileSetName(){
|
|||
|
|
if(IF_PROFILE){
|
|||
|
|
$section = Section::isProfileMy($_POST['section_id']);
|
|||
|
|
$name = trim($_POST['name']);
|
|||
|
|
if($section and $name){
|
|||
|
|
Section::updateById($section[Section::$ID],[Section::$NAME=>$name]);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
static function profileCreate(){
|
|||
|
|
$res = [];
|
|||
|
|
if(IF_PROFILE and $course = Course::isProfileMy($_POST['course_id'])){
|
|||
|
|
$r = Section::insert([
|
|||
|
|
Section::$COURSE => $course[Course::$ID],
|
|||
|
|
Section::$NAME => 'Новый раздел',
|
|||
|
|
Section::$ACCOUNT => \Site::$owner_id,
|
|||
|
|
]);
|
|||
|
|
$res['id'] = $r->id;
|
|||
|
|
}
|
|||
|
|
echo je($res);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|