88 lines
2.8 KiB
PHP
88 lines
2.8 KiB
PHP
<?
|
||
|
||
namespace controller\academy\project;
|
||
|
||
use academy\Project;
|
||
use common\Image;
|
||
use ms\ms\structure\msControllerTable;
|
||
|
||
class Api extends msControllerTable {
|
||
static $class = 'academy\Project';
|
||
|
||
|
||
// Работа с проифилями
|
||
|
||
static function profileSetDescr(){
|
||
if(IF_PROFILE){
|
||
$project = Project::isProfileMy($_POST['project_id']);
|
||
$descr = trim($_POST['descr']);
|
||
if($project and $descr){
|
||
Project::updateById($project[Project::$ID],[Project::$DESCR=>$descr]);
|
||
}
|
||
}
|
||
}
|
||
static function profileSetName(){
|
||
if(IF_PROFILE){
|
||
$project = Project::isProfileMy($_POST['project_id']);
|
||
$name = trim($_POST['name']);
|
||
if($project and $name){
|
||
Project::updateById($project[Project::$ID],[Project::$NAME=>$name]);
|
||
}
|
||
}
|
||
}
|
||
static function profileSetAva(){
|
||
if(IF_PROFILE){
|
||
$project = Project::isProfileMy($_POST['project_id']);
|
||
$img = Image::isProfileMy($_POST['image_id']);
|
||
if($project and $img){
|
||
Project::updateById($project[Project::$ID],[Project::$AVA=>$img[Image::$ID]]);
|
||
}
|
||
}
|
||
}
|
||
static function profileSetBG(){
|
||
if(IF_PROFILE){
|
||
$project = Project::isProfileMy($_POST['project_id']);
|
||
$img = Image::isProfileMy($_POST['image_id']);
|
||
if($project and $img){
|
||
Project::updateById($project[Project::$ID],[Project::$BG=>$img[Image::$ID]]);
|
||
}
|
||
}
|
||
}
|
||
|
||
static function profileUpdateSettings(){
|
||
$res = [];
|
||
if(IF_PROFILE and $project = Project::isProfileMy($_POST['project_id'])){
|
||
$arr = [
|
||
//'price'=>Project::$PRICE,
|
||
'annotation' => Project::$ANNOTATION,
|
||
'category' => Project::$CATEGORY,
|
||
'vis' => Project::$VIS,
|
||
'public' => Project::$PUBLIC,
|
||
];
|
||
$newData = [];
|
||
foreach ($arr as $k=>$v){
|
||
if(isset($_POST[$k])) $newData[$v] = $_POST[$k];
|
||
}
|
||
if(isset($newData[$c = Project::$CATEGORY])) $newData[$c] = intval($newData[$c]);
|
||
if(isset($newData[$c = Project::$VIS])) $newData[$c] = intval($newData[$c]);
|
||
if(isset($newData[$c = Project::$PUBLIC])) $newData[$c] = intval($newData[$c]);
|
||
|
||
$x = Project::updateById($project[Project::$ID],$newData);
|
||
}
|
||
echo je($res);
|
||
}
|
||
static function profileCreate(){
|
||
$res = [];
|
||
if(IF_PROFILE){
|
||
$r = Project::insert([
|
||
Project::$NAME => $_POST['name'],
|
||
Project::$ACCOUNT => \Site::$owner_id,
|
||
]);
|
||
$res['id'] = $r->id;
|
||
}
|
||
echo je($res);
|
||
}
|
||
}
|
||
|
||
|