mirror of
https://github.com/openclassify/openclassify.git
synced 2026-01-24 22:11:01 -06:00
#2974 - Remove role base - My dopings shows 403 with standard user
This commit is contained in:
parent
a03f373374
commit
90397a8126
@ -627,9 +627,6 @@ class AdvsController extends PublicController
|
|||||||
}
|
}
|
||||||
|
|
||||||
$isActiveDopings = $this->adv_model->is_enabled('dopings');
|
$isActiveDopings = $this->adv_model->is_enabled('dopings');
|
||||||
if ($isActiveDopings) {
|
|
||||||
$isActiveDopings = doping_check_role();
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->view->make('visiosoft.module.advs::new-ad/preview/preview',
|
return $this->view->make('visiosoft.module.advs::new-ad/preview/preview',
|
||||||
compact('adv', 'categories', 'features', 'isActiveDopings'));
|
compact('adv', 'categories', 'features', 'isActiveDopings'));
|
||||||
@ -1026,45 +1023,6 @@ class AdvsController extends PublicController
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function login()
|
|
||||||
{
|
|
||||||
if (auth()->check()) {
|
|
||||||
return $this->redirect->to($this->request->get('redirect', '/'));
|
|
||||||
}
|
|
||||||
|
|
||||||
$urlPrev = str_replace(url('/'), '', url()->previous());
|
|
||||||
|
|
||||||
return $this->view->make('theme::login', compact('urlPrev'));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function register()
|
|
||||||
{
|
|
||||||
|
|
||||||
if (auth()->check()) {
|
|
||||||
return redirect('/');
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->view->make('theme::register');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function passwordForgot()
|
|
||||||
{
|
|
||||||
if (auth()->check()) {
|
|
||||||
return redirect('/');
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->view->make('theme::passwords/forgot');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function passwordReset(Request $request)
|
|
||||||
{
|
|
||||||
if (auth()->check()) {
|
|
||||||
return redirect('/');
|
|
||||||
}
|
|
||||||
$code = $request->email;
|
|
||||||
return $this->view->make('theme::passwords/reset', compact('code'));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function mapJson(Request $request, AdvRepositoryInterface $repository)
|
public function mapJson(Request $request, AdvRepositoryInterface $repository)
|
||||||
{
|
{
|
||||||
$param = $request->toArray();
|
$param = $request->toArray();
|
||||||
@ -1079,165 +1037,6 @@ class AdvsController extends PublicController
|
|||||||
return response()->json($advs);
|
return response()->json($advs);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getAdvsByProfile(AdvRepositoryInterface $advRepository, Request $request)
|
|
||||||
{
|
|
||||||
$my_advs = new AdvModel();
|
|
||||||
$type = $request->type;
|
|
||||||
if ($type == 'pending') {
|
|
||||||
$page_title = trans('visiosoft.module.advs::field.pending_adv.name');
|
|
||||||
$my_advs = $my_advs->pendingAdvsByUser();
|
|
||||||
} else if ($type == 'favs') {
|
|
||||||
//Get Favorites Advs
|
|
||||||
$isActiveFavs = new AdvModel();
|
|
||||||
$isActiveFavs = $isActiveFavs->is_enabled('favs');
|
|
||||||
|
|
||||||
if ($isActiveFavs) {
|
|
||||||
|
|
||||||
$page_title = trans('visiosoft.module.advs::field.favs_adv.name');
|
|
||||||
$favs = new FavsController();
|
|
||||||
$favs = $favs->getFavsByProfile();
|
|
||||||
|
|
||||||
$fav_ids = array();
|
|
||||||
foreach ($favs as $fav) {
|
|
||||||
$fav_ids[] = $fav['adv_name_id'];//fav advs id List
|
|
||||||
}
|
|
||||||
$my_advs = $my_advs->favsAdvsByUser($fav_ids);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$page_title = trans('visiosoft.module.advs::field.my_adv.name');
|
|
||||||
$my_advs = $my_advs->myAdvsByUser();
|
|
||||||
}
|
|
||||||
$my_advs = $my_advs->orderByDesc('id');
|
|
||||||
$my_advs = $advRepository->addAttributes($my_advs->get());
|
|
||||||
$files = array();
|
|
||||||
foreach ($my_advs as $my_adv) {
|
|
||||||
$files[] = $my_adv->files;
|
|
||||||
}
|
|
||||||
return response()->json(['success' => true, 'content' => $my_advs, 'files' => $files, 'title' => $page_title]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function authCheck()
|
|
||||||
{
|
|
||||||
if (auth()->check()) {
|
|
||||||
return auth()->user();
|
|
||||||
}
|
|
||||||
|
|
||||||
return "false";
|
|
||||||
}
|
|
||||||
|
|
||||||
public function isActiveJson($slug)
|
|
||||||
{
|
|
||||||
$isActive = $this->isActive($slug);
|
|
||||||
return response()->json(array('isActive' => $isActive));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function isActive($slug)
|
|
||||||
{
|
|
||||||
$query = new AdvModel();
|
|
||||||
|
|
||||||
return $query->is_enabled($slug);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function checkParentCat($id)
|
|
||||||
{
|
|
||||||
$option = new CategoryModel();
|
|
||||||
return $option->getParentCats($id);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function checkUser()
|
|
||||||
{
|
|
||||||
if (Auth::check()) {
|
|
||||||
return response()->json([
|
|
||||||
'success' => true,
|
|
||||||
]);
|
|
||||||
} else {
|
|
||||||
return response()->json([
|
|
||||||
'success' => false,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function advAddCart($id, $quantity = 1)
|
|
||||||
{
|
|
||||||
$thisModel = new AdvModel();
|
|
||||||
$adv = $thisModel->isAdv($id);
|
|
||||||
$response = array();
|
|
||||||
if ($adv) {
|
|
||||||
$cart = $thisModel->addCart($adv, $quantity);
|
|
||||||
$response['status'] = "success";
|
|
||||||
} else {
|
|
||||||
$response['status'] = "error";
|
|
||||||
$response['msg'] = trans('visiosoft.module.advs::message.error_added_cart');
|
|
||||||
}
|
|
||||||
return back();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function addCart(Request $request)
|
|
||||||
{
|
|
||||||
if (\auth()->check()) {
|
|
||||||
$id = $request->id;
|
|
||||||
$quantity = $request->quantity;
|
|
||||||
$name = $request->name;
|
|
||||||
$thisModel = new AdvModel();
|
|
||||||
$adv = $thisModel->isAdv($id);
|
|
||||||
$response = array();
|
|
||||||
if ($adv) {
|
|
||||||
$cart = $thisModel->addCart($adv, $quantity, $name);
|
|
||||||
$response['status'] = "success";
|
|
||||||
} else {
|
|
||||||
$response['status'] = "error";
|
|
||||||
$response['msg'] = trans('visiosoft.module.advs::message.error_added_cart');
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$response['status'] = "guest";
|
|
||||||
}
|
|
||||||
return $response;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function stockControl(Request $request, AdvRepositoryInterface $advRepository)
|
|
||||||
{
|
|
||||||
$quantity = $request->quantity;
|
|
||||||
$id = $request->id;
|
|
||||||
$type = $request->type;
|
|
||||||
$advmodel = new AdvModel();
|
|
||||||
$adv = $advmodel->getAdv($id);
|
|
||||||
|
|
||||||
$status = $advmodel->stockControl($id, $quantity);
|
|
||||||
|
|
||||||
$response = array();
|
|
||||||
if ($status == 1) {
|
|
||||||
$response['newQuantity'] = $advRepository->getQuantity($quantity, $type, $adv);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
$response['newQuantity'] = $adv->stock;
|
|
||||||
}
|
|
||||||
|
|
||||||
$response['newPrice'] = $adv->price * $response['newQuantity'];
|
|
||||||
|
|
||||||
$separator = ",";
|
|
||||||
$decimals = 2;
|
|
||||||
$point = ".";
|
|
||||||
|
|
||||||
$response['newPrice'] = number_format($response['newPrice'], $decimals, $point, str_replace(' ', ' ', $separator));
|
|
||||||
$symbol = config('streams::currencies.supported.' . strtoupper($adv->currency) . '.symbol');
|
|
||||||
|
|
||||||
$response['newPrice'] = $symbol . $response['newPrice'];
|
|
||||||
$response['status'] = $status;
|
|
||||||
$response['maxQuantity'] = $adv->stock;
|
|
||||||
return $response;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function showPhoneCounter(Request $request, AdvModel $advModel, Dispatcher $events)
|
|
||||||
{
|
|
||||||
$ad_id = $request->id;
|
|
||||||
$ad = $advModel->getAdv($ad_id);
|
|
||||||
|
|
||||||
if ($advModel->is_enabled('phoneclickcounter')) {
|
|
||||||
$events->dispatch(new showAdPhone($ad));//show ad phone events
|
|
||||||
}
|
|
||||||
return "success";
|
|
||||||
}
|
|
||||||
|
|
||||||
public function extendAll($isAdmin = null)
|
public function extendAll($isAdmin = null)
|
||||||
{
|
{
|
||||||
if (\request()->unpublished) {
|
if (\request()->unpublished) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user