Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
A
addcpm-json
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Александр Чаплыгин
addcpm-json
Commits
8e8e11e5
Commit
8e8e11e5
authored
Mar 18, 2020
by
Александр Чаплыгин
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Страница списка кампаний, логика редиректа в зависимости от типа пользователя
parent
01210d7e
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
230 additions
and
4 deletions
+230
-4
acl.global.php
src/config/autoload/acl.global.php
+1
-0
routes.global.php
src/config/autoload/routes.global.php
+22
-0
common.js
src/public/js/common.js
+3
-1
Index.php
src/src/App/Action/Index.php
+9
-1
Activate.php
src/src/App/Action/User/Activate.php
+3
-1
Campaigns.php
src/src/App/Action/User/Campaigns.php
+191
-0
AbstractAuthService.php
src/src/App/Authentication/AbstractAuthService.php
+1
-1
No files found.
src/config/autoload/acl.global.php
View file @
8e8e11e5
...
...
@@ -37,6 +37,7 @@ return [
->
allow
(
Roles
::
ROLE_USER
,
'user.cabinet.profile'
,
null
,
new
\App\Acl\Assertion\UserActive
())
->
allow
(
Roles
::
ROLE_USER
,
'user.cabinet.viewid'
,
null
,
new
\App\Acl\Assertion\UserActive
())
->
allow
(
Roles
::
ROLE_USER
,
'user.cabinet.orderid'
,
null
,
new
\App\Acl\Assertion\UserActive
())
->
allow
(
Roles
::
ROLE_USER
,
'user.campaigns'
,
null
,
new
\App\Acl\Assertion\UserActive
())
->
allow
(
Roles
::
ROLE_USER
,
'install.counter'
,
null
,
new
\App\Acl\Assertion\UserActive
())
->
allow
(
Roles
::
ROLE_USER
,
'download.counter'
,
null
,
new
\App\Acl\Assertion\UserActive
())
->
allow
(
Roles
::
ROLE_GUEST
,
'email.counter'
)
...
...
src/config/autoload/routes.global.php
View file @
8e8e11e5
...
...
@@ -65,6 +65,13 @@ return [
$container
);
},
App\Action\User\Campaigns
::
class
=>
function
(
ContainerInterface
$container
)
{
return
new
App\Action\User\Campaigns
(
$container
->
get
(
\Zend\Expressive\Router\RouterInterface
::
class
),
$container
->
get
(
\Zend\Expressive\Template\TemplateRendererInterface
::
class
),
$container
);
},
App\Action\User\Profile
::
class
=>
function
(
ContainerInterface
$container
)
{
return
new
App\Action\User\Profile
(
$container
->
get
(
\Zend\Expressive\Router\RouterInterface
::
class
),
...
...
@@ -376,6 +383,21 @@ return [
]
],
],
[
'name'
=>
'user.campaigns'
,
'path'
=>
'/[:lang/]campaigns/'
,
'middleware'
=>
App\Action\User\Campaigns
::
class
,
'allowed_methods'
=>
[
'GET'
,
'POST'
],
'options'
=>
[
'constraints'
=>
[
'lang'
=>
'[a-z]{2,3}'
,
],
'defaults'
=>
[
'lang'
=>
\App\Model\Locales
::
DEFAULT_LANG
,
'action'
=>
App\Action\User\Campaigns
::
ACTION_LIST
,
]
],
],
[
'name'
=>
'contacts'
,
'path'
=>
'/[:lang/]contacts/'
,
...
...
src/public/js/common.js
View file @
8e8e11e5
...
...
@@ -422,8 +422,10 @@ $(document).ready(function(){
if
(
data
.
result
===
true
)
{
var
lang
=
$
(
'.header-lang'
).
attr
(
'lang'
);
var
newLocation
=
'/cabinet/'
;
newLocation
=
'/'
;
newLocation
=
'/'
+
'ru'
+
newLocation
;
//
newLocation = '/'+'ru'+newLocation;
/*
if (location.pathname == '/') {
...
...
src/src/App/Action/Index.php
View file @
8e8e11e5
...
...
@@ -50,7 +50,15 @@ class Index extends Common
/** @var UserService $auth */
$auth
=
$this
->
container
->
get
(
UserService
::
class
);
if
(
$auth
->
getIdentity
())
{
return
new
RedirectResponse
(
$this
->
router
->
generateUri
(
'user.cabinet'
));
//return new RedirectResponse($this->router->generateUri('user.cabinet'));
$user_type
=
$auth
->
getIdentity
()
->
getType
();
if
(
$user_type
==
'shop'
)
{
$route
=
'user.cabinet'
;
}
if
(
$user_type
==
'advertiser'
)
{
$route
=
'user.campaigns'
;
}
return
new
RedirectResponse
(
$this
->
router
->
generateUri
(
$route
));
}
...
...
src/src/App/Action/User/Activate.php
View file @
8e8e11e5
...
...
@@ -78,12 +78,14 @@ class Activate extends Common
$user
=
$usersModel
->
findById
(
$id
);
$user
->
setActivated
(
true
);
$usersModel
->
save
(
$user
);
// on success activation redirect to user cabinet
$uri
=
$this
->
router
->
generateUri
(
'user.cabinet'
,
[
'lang'
=>
$request
->
getAttribute
(
'layoutInfo'
)
->
getLang
(),
]);
$response
=
new
RedirectResponse
(
$uri
);
}
catch
(
ExpiredException
$e
)
{
/** @var DelegatingHydrator $hyd */
...
...
src/src/App/Action/User/Campaigns.php
0 → 100644
View file @
8e8e11e5
<?php
/**
* Copyright (c) 2016 Serhii Borodai <clarifying@gmail.com>.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
*
*/
namespace
App\Action\User
;
use
App\Action\Common
;
use
App\Authentication\UserService
;
use
App\Model\Users
;
use
Psr\Http\Message\ResponseInterface
;
use
Psr\Http\Message\ServerRequestInterface
;
use
Zend\Diactoros\Response\HtmlResponse
;
use
Zend\Diactoros\Response\JsonResponse
;
use
Zend\Diactoros\Response\RedirectResponse
;
use
Zend\Hydrator\DelegatingHydrator
;
/**
* Class Campaigns
* @package App\Action\User
*/
class
Campaigns
extends
Common
{
const
ACTION_LIST
=
'list'
;
/**
* @param ServerRequestInterface $request
* @param ResponseInterface $response
* @param callable|null $next
* @return HtmlResponse
*/
function
__invoke
(
ServerRequestInterface
$request
,
ResponseInterface
$response
,
callable
$next
=
null
)
{
if
(
$request
->
getMethod
()
==
'POST'
)
{
/*
try {
switch ($request->getAttribute('action')) {
case self::ACTION_STAT:
$response = $this->getStatData($request);
break;
case self::ACTION_CATS:
$response = $this->editCatsData($request);
break;
default:
}
} catch(\Exception $e) {
$data = [
'result' => false,
'msg' => $e->getMessage(),
];
$response = new JsonResponse($data);
}
return $response;
*/
}
elseif
(
$request
->
getAttribute
(
'action'
)
==
self
::
ACTION_LIST
)
{
return
new
HtmlResponse
(
'Campaigns LIST'
);
try
{
/** @var UserService $auth */
$auth
=
$this
->
container
->
get
(
UserService
::
class
);
$userId
=
$auth
->
getIdentity
()
->
getId
();
/** @var \App\Model\Feeds\Shops $shopsModel */
$shopsModel
=
$this
->
container
->
get
(
\App\Model\Feeds\Shops
::
class
);
$shop
=
$shopsModel
->
findOne
([
'users_id'
=>
$userId
]);
if
(
$shop
)
{
$shop_title
=
$shop
->
getTitle
();
}
/** @var \App\Model\Feeds $feedsModel */
$feedsModel
=
$this
->
container
->
get
(
Feeds
::
class
);
$feeds
=
$feedsModel
->
findAll
([
'clientid'
=>
$userId
])
->
toArray
();
if
(
$feeds
)
{
// Фиды пользователя:
$feed_id_list
=
[];
foreach
(
$feeds
as
$feed_item
)
{
$feed_id
=
$feed_item
[
'id'
];
if
(
!
in_array
(
$feed_id
,
$feed_id_list
))
{
$feed_id_list
[]
=
$feed_id
;
}
}
$report_type
=
$request
->
getAttribute
(
'report'
);
// Текущий месяц:
$current_period
=
'current_month'
;
$dates
=
[
date
(
'Y-m-01'
),
date
(
'Y-m-d'
)];
$reports_conf
=
$this
->
container
->
get
(
'config'
)[
'feed_conf'
][
'reports'
];
$report_conf
=
$reports_conf
[
$report_type
];
// Список отчетов:
$reports_list
=
[];
foreach
(
$reports_conf
as
$report_name
=>
$report_value
)
{
$reports_list
[
$report_name
]
=
$report_value
[
'title'
];
}
switch
(
$report_type
)
{
case
'common'
:
$periodStats
=
$stats
->
getFeedStatData
(
$report_type
,
$feed_id_list
,
$dates
,
$report_conf
);
break
;
case
'transactions'
:
$periodStats
=
$stats
->
getFeedStatData
(
$report_type
,
$feed_id_list
,
$dates
,
$report_conf
);
break
;
default
:
$data
[
'error'
]
=
_t
(
'Извините, тип отчета "'
.
$report_type
.
'" недоступен'
);
break
;
}
// Добавляем спец. категории для сводного отчета по магазину:
if
(
$report_type
==
'common'
)
{
$periodStats
=
$this
->
addStatsSpecialCats
(
$periodStats
);
}
// Добавляем данные о статусах заказов:
if
(
$report_type
==
'transactions'
)
{
if
(
$periodStats
)
{
/** @var \App\Model\Feeds $ordersStatusModel */
$ordersStatusModel
=
$this
->
container
->
get
(
OrdersStatus
::
class
);
$ordersStatus
=
$ordersStatusModel
->
findAll
([
'feed_id'
=>
$feed_id_list
])
->
toArray
();
$statuses
=
[];
foreach
(
$ordersStatus
as
$order_item
)
{
$statuses
[
$order_item
[
'feed_id'
]][
$order_item
[
'order_id'
]]
=
array
(
'confirmed'
=>
$order_item
[
'confirmed'
]
?
1
:
0
,
'approved'
=>
$order_item
[
'approved'
]
?
1
:
0
);
}
$periodStats
[
'ordersStatus'
]
=
$statuses
;
}
}
$data
[
'shop_title'
]
=
$shop_title
;
$data
[
'feeds'
]
=
$feeds
;
$data
[
'current_report'
]
=
$report_type
;
$data
[
'current_period'
]
=
$current_period
;
$data
[
'dates'
]
=
$dates
;
$data
[
'periodStats'
]
=
$periodStats
;
$data
[
'report_conf'
]
=
$report_conf
;
$data
[
'reports_list'
]
=
$reports_list
;
$data
[
'periods_list'
]
=
$this
->
container
->
get
(
'config'
)[
'feed_conf'
][
'periods_list'
];
$data
[
'colors_active_lines'
]
=
$this
->
container
->
get
(
'config'
)[
'feed_conf'
][
'colors_active_lines'
];
}
else
{
$data
[
'error'
]
=
_t
(
'Извините, у пользователя нет фидов'
);
}
}
catch
(
\Exception
$e
)
{
$data
[
'error'
]
=
_t
(
'Извините, статистика временно не работает'
);
}
$data
=
array_merge
(
$data
,
[
'lang'
=>
$request
->
getAttribute
(
'layoutInfo'
)
->
getLang
(),
'layoutInfo'
=>
$request
->
getAttribute
(
'layoutInfo'
),
]);
return
new
HtmlResponse
(
$this
->
template
->
render
(
'app::user/cabinet-feed'
,
$data
));
}
}
}
\ No newline at end of file
src/src/App/Authentication/AbstractAuthService.php
View file @
8e8e11e5
...
...
@@ -194,7 +194,7 @@ abstract class AbstractAuthService implements AuthenticationServiceInterface
$this
->
entity
=
$entity
;
$result
=
new
Result
(
Result
::
SUCCESS
,
$entity
);
if
(
$entity
instanceof
User
&&
$entity
->
getType
()
!=
'shop'
)
{
if
(
$entity
instanceof
User
&&
!
in_array
(
$entity
->
getType
(),
[
'shop'
,
'advertiser'
])
)
{
$result
=
new
Result
(
Result
::
FAILURE_CREDENTIAL_INVALID
,
$this
->
credential
,
[
'invalid credential'
]);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment