actionProfileWithReportPermission
This commit is contained in:
@ -6,17 +6,21 @@ use common\behaviors\GsCors;
|
||||
use common\classes\Debug;
|
||||
use common\models\InterviewRequest;
|
||||
use common\models\User;
|
||||
use common\models\UserCard;
|
||||
use common\services\ProfileService;
|
||||
use frontend\modules\api\models\ProfileSearchForm;
|
||||
use kavalar\BotNotificationTemplateProcessor;
|
||||
use kavalar\TelegramBotService;
|
||||
use Yii;
|
||||
use yii\filters\auth\CompositeAuth;
|
||||
use yii\filters\auth\HttpBearerAuth;
|
||||
use yii\filters\auth\QueryParamAuth;
|
||||
use yii\filters\ContentNegotiator;
|
||||
use yii\helpers\ArrayHelper;
|
||||
use yii\web\BadRequestHttpException;
|
||||
use yii\web\Response;
|
||||
|
||||
|
||||
class ProfileController extends ApiController
|
||||
{
|
||||
|
||||
@ -53,15 +57,23 @@ class ProfileController extends ApiController
|
||||
return $searchModel->byParams();
|
||||
}
|
||||
|
||||
public function actionProfileWithReportPermission($id, $searcherID)
|
||||
public function actionProfileWithReportPermission($id)
|
||||
{
|
||||
$searchModel = new ProfileSearchForm();
|
||||
$searchModel->attributes = \Yii::$app->request->get();
|
||||
|
||||
if ($id && $searcherID) {
|
||||
$searcherUser = Yii::$app->user->getId();
|
||||
$searcherProfileId = UserCard::findOne($searcherUser)->id;
|
||||
|
||||
if ($id && $searcherProfileId) {
|
||||
if(!UserCard::find()->where(['id' => $id])->exists())
|
||||
{
|
||||
throw new BadRequestHttpException(json_encode('There is no user with this id'));
|
||||
}
|
||||
$profile = $searchModel->byId();
|
||||
|
||||
$profileService = new ProfileService($searcherID, $id);
|
||||
$profileService = new ProfileService($searcherProfileId, $id);
|
||||
|
||||
if($profileService->checkReportePermission()) {
|
||||
$profile += ['report_permission' => '1'];
|
||||
}
|
||||
|
Reference in New Issue
Block a user