+ canViewIP for User model
This commit is contained in:
parent
f9bc7cd9f7
commit
321ea884eb
5 changed files with 18 additions and 5 deletions
|
@ -126,6 +126,11 @@ class Routing
|
|||
|
||||
$r->add(['GET', 'POST'], '/admin/users', 'AdminUsers:view', 'AdminUsers');
|
||||
$r->add(['GET', 'POST'], '/admin/users/result/{data}[/{page:[1-9]\d*}]', 'AdminUsersResult:view', 'AdminUsersResult');
|
||||
|
||||
if ($user->canViewIP) {
|
||||
$r->add('GET', '/admin/get/host/{ip:[0-9a-fA-F:.]+}', 'AdminHost:view', 'AdminHost');
|
||||
$r->add('GET', '/admin/users/user/{id:[2-9]|[1-9]\d+}[/{page:[1-9]\d*}]', 'AdminUsersStat:view', 'AdminUserStat');
|
||||
}
|
||||
}
|
||||
// только админ
|
||||
if ($user->isAdmin) {
|
||||
|
@ -148,8 +153,6 @@ class Routing
|
|||
$r->add('POST', '/admin/maintenance/rebuild', 'AdminMaintenance:rebuild', 'AdminMaintenanceRebuild');
|
||||
$r->add('GET', '/admin/maintenance/rebuild/{token}/{clear:[01]}/{limit:[1-9]\d*}/{start:[1-9]\d*}', 'AdminMaintenance:rebuild', 'AdminRebuildIndex' );
|
||||
|
||||
$r->add('GET', '/admin/get/host/{ip:[0-9a-fA-F:.]+}', 'AdminHost:view', 'AdminHost');
|
||||
$r->add('GET', '/admin/users/user/{id:[2-9]|[1-9]\d+}[/{page:[1-9]\d*}]', 'AdminUsersStat:view', 'AdminUserStat');
|
||||
}
|
||||
|
||||
$uri = $_SERVER['REQUEST_URI'];
|
||||
|
|
|
@ -23,7 +23,7 @@ class Result extends Users
|
|||
}
|
||||
|
||||
if (isset($data['ip'])) {
|
||||
if (! $this->user->isAdmin) {
|
||||
if (! $this->user->canViewIP) {
|
||||
return $this->c->Message->message('Bad request');
|
||||
}
|
||||
|
||||
|
|
|
@ -120,7 +120,7 @@ class View extends Users
|
|||
$this->aIndex = 'users';
|
||||
$this->formSearch = $this->form($data);
|
||||
|
||||
if ($this->user->isAdmin) {
|
||||
if ($this->user->canViewIP) {
|
||||
$this->formIP = $this->formIP($data);
|
||||
}
|
||||
|
||||
|
|
|
@ -85,7 +85,7 @@ class Profile extends Rules
|
|||
|
||||
protected function getviewIP()
|
||||
{
|
||||
return $this->user->isAdmin;
|
||||
return $this->user->canViewIP;
|
||||
}
|
||||
|
||||
protected function getuseAvatar()
|
||||
|
|
|
@ -309,4 +309,14 @@ class Model extends DataModel
|
|||
{
|
||||
return (int) (empty($this->a['disp_posts']) ? $this->c->config->o_disp_posts_default : $this->a['disp_posts']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Статус показа ip пользователей
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function getcanViewIP()
|
||||
{
|
||||
return $this->isAdmin;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue