Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
retypos-server
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
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
eterfund
retypos-server
Commits
cbe22840
Commit
cbe22840
authored
Apr 14, 2017
by
Георгий Попов
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
finish with user and site panels
parent
68874b55
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
70 additions
and
27 deletions
+70
-27
Sites.php
new_cp/application/controllers/admins/Sites.php
+1
-1
Users.php
new_cp/application/controllers/admins/Users.php
+20
-10
User.php
new_cp/application/models/admins/User.php
+49
-16
No files found.
new_cp/application/controllers/admins/Sites.php
View file @
cbe22840
...
...
@@ -113,7 +113,7 @@ class Sites extends CI_Controller {
$oper
=
$this
->
input
->
post
(
'oper'
);
if
(
$oper
==
'del'
)
{
$this
->
load
->
model
(
'admins/user'
);
$data
[
'id_user'
]
=
$this
->
input
->
ge
t
(
'id'
);
$data
[
'id_user'
]
=
$this
->
input
->
pos
t
(
'id'
);
$data
[
'id_site'
]
=
$this
->
input
->
get
(
'id_site'
);
$this
->
user
->
deleteResponsible
(
$data
);
}
...
...
new_cp/application/controllers/admins/Users.php
View file @
cbe22840
...
...
@@ -44,6 +44,8 @@ class Users extends CI_Controller {
/*Получить пользователей*/
function
get_list_users
()
{
error_log
(
"get_list_users"
);
$data
[
'page'
]
=
$this
->
input
->
get
(
'page'
);
$data
[
'limit'
]
=
$this
->
input
->
get
(
'rows'
,
1
);
$data
[
'sord'
]
=
$this
->
input
->
get
(
'sord'
);
...
...
@@ -58,6 +60,8 @@ class Users extends CI_Controller {
/*Получить сайты пользователя*/
function
get_user_sites
()
{
log_message
(
'error'
,
'get_user_states'
);
$data
[
'page'
]
=
$this
->
input
->
get
(
'page'
);
$data
[
'limit'
]
=
$this
->
input
->
get
(
'rows'
,
1
);
$data
[
'sord'
]
=
$this
->
input
->
get
(
'sord'
);
...
...
@@ -76,6 +80,8 @@ class Users extends CI_Controller {
$oper
=
$this
->
input
->
post
(
'oper'
);
$data
=
array
();
log_message
(
'error'
,
'panel_users'
);
log_message
(
'error'
,
"Oper =
$oper
"
);
if
(
$oper
==
'add'
)
{
$data
[
'login'
]
=
$this
->
input
->
post
(
'login'
);
if
(
strlen
(
$data
[
'login'
])
<
3
)
{
...
...
@@ -129,6 +135,7 @@ class Users extends CI_Controller {
return
;
}
else
if
(
$oper
==
'del'
)
{
$data
[
'id_user'
]
=
$this
->
input
->
post
(
'id'
);
log_message
(
'error'
,
"DELETE USSER!!!!!"
);
$this
->
user
->
deleteUser
(
$data
);
return
;
}
else
if
(
$oper
==
'edit'
)
{
...
...
@@ -192,16 +199,14 @@ class Users extends CI_Controller {
//Возвращать должен html-список
function
get_sites
()
{
$id_user
=
$this
->
input
->
get
(
'id_user'
);
$sites
=
$this
->
user
->
getUserSites
(
$id_user
);
log_message
(
"error"
,
"result!!!"
);
$sites
=
$this
->
user
->
getAvailableSites
(
$id_user
);
$select
=
"<select>"
;
if
(
!
$sites
)
{
if
(
$sites
->
num_rows
()
==
0
)
{
$select
.=
"<option disabled selected value='-1'>Сайтов нет</option>"
;
}
else
{
for
(
$i
=
0
;
$i
<
count
(
$sites
);
$i
++
)
{
$select
.=
"<option value='"
.
$site
s
[
$i
][
'id'
]
.
"'>"
.
$sites
[
$i
][
'site'
]
.
"</option>"
;
for
each
(
$sites
->
result
()
as
$site
)
{
$select
.=
"<option value='"
.
$site
->
id
.
"'>"
.
$site
->
site
.
"</option>"
;
}
}
$select
.=
"</select>"
;
...
...
@@ -213,28 +218,33 @@ class Users extends CI_Controller {
/*Управление сайтами пользователя*/
function
panel_users_site
()
{
$oper
=
$this
->
input
->
post
(
'oper'
);
if
(
$oper
==
'add'
)
{
$data
[
'id_user'
]
=
$this
->
input
->
pos
t
(
'id_user'
);
$data
[
'id_user'
]
=
$this
->
input
->
ge
t
(
'id_user'
);
$data
[
'id_site'
]
=
$this
->
input
->
post
(
'site'
);
$data
[
'status'
]
=
$this
->
input
->
post
(
'status'
);
if
(
$data
[
'status'
]
!=
1
&&
$data
[
'status'
]
!=
0
)
{
$data
[
'status'
]
=
0
;
}
$return
=
$this
->
user
->
addResponsible
(
$data
);
if
(
$return
)
{
echo
json_encode
(
$return
);
}
}
else
if
(
$oper
==
'edit'
)
{
$data
[
'id_user'
]
=
$this
->
input
->
pos
t
(
'id_user'
);
$data
[
'id_user'
]
=
$this
->
input
->
ge
t
(
'id_user'
);
$data
[
'id_site'
]
=
$this
->
input
->
post
(
'id'
);
$data
[
'status'
]
=
$this
->
input
->
post
(
'status'
);
$data
[
'status'
]
=
$this
->
input
->
post
(
'status'
);
if
(
$data
[
'status'
]
!=
1
&&
$data
[
'status'
]
!=
0
)
{
$data
[
'status'
]
=
0
;
}
$this
->
user
->
editResponsible
(
$data
);
}
else
if
(
$oper
==
'del'
)
{
$data
[
'id_user'
]
=
$this
->
input
->
pos
t
(
'id_user'
);
$data
[
'id_user'
]
=
$this
->
input
->
ge
t
(
'id_user'
);
$data
[
'id_site'
]
=
$this
->
input
->
post
(
'id'
);
$this
->
user
->
deleteResponsible
(
$data
);
}
...
...
new_cp/application/models/admins/User.php
View file @
cbe22840
...
...
@@ -23,17 +23,19 @@ class User extends CI_Model {
}
private
function
filterResults
(
$table
,
$data
)
{
log_message
(
'error'
,
"data = "
.
print_r
(
$data
,
true
));
$this
->
load
->
helper
(
"search"
);
log_message
(
'error'
,
"data = "
.
print_r
(
$data
,
true
));
$id_user
=
isset
(
$data
[
'id_user'
])
?
$data
[
'id_user'
]
:
0
;
$page
=
$data
[
'page'
]
;
$limit
=
$data
[
'limit'
]
;
$page
=
isset
(
$data
[
'page'
])
?
$data
[
'page'
]
:
0
;
$limit
=
isset
(
$data
[
'limit'
])
?
$data
[
'limit'
]
:
0
;
$sord
=
isset
(
$data
[
'sord'
])
?
$data
[
'sord'
]
:
0
;
$sidx
=
isset
(
$data
[
'sidx'
])
?
$data
[
'sidx'
]
:
0
;
$search
=
$data
[
'search'
]
;
$search
=
isset
(
$data
[
'search'
])
?
$data
[
'search'
]
:
"false"
;
$searchstring
=
""
;
$search_string
=
""
;
if
(
$search
==
"true"
)
{
$searchField
=
$data
[
'searchField'
];
$searchOper
=
$data
[
'searchOper'
];
...
...
@@ -80,7 +82,6 @@ class User extends CI_Model {
$this
->
db
->
select
(
'*'
);
if
(
$table
==
'users'
)
{
$this
->
db
->
from
(
'users as u'
);
}
else
{
$this
->
db
->
from
(
'responsible as r'
);
...
...
@@ -101,6 +102,8 @@ class User extends CI_Model {
$results
=
$this
->
db
->
get
();
log_message
(
'error'
,
$this
->
db
->
last_query
());
if
(
$table
==
'users'
)
{
foreach
(
$results
->
result
()
as
$id
=>
$row
)
{
$data
[
'rows'
][
$id
][
'id'
]
=
$row
->
id
;
...
...
@@ -128,6 +131,23 @@ class User extends CI_Model {
return
$data
;
}
/**
* Возвращает список сайтов, доступных для добавления
* к пользователю.
*
* @param type $user_id Идентификатор пользователя
*/
function
getAvailableSites
(
$user_id
)
{
$this
->
db
->
select
(
"s.id,s.site"
);
$this
->
db
->
from
(
"sites as s"
);
$this
->
db
->
where
(
's.id NOT IN ('
.
'SELECT s.id FROM sites as s '
.
'JOIN responsible as r ON r.id_site = s.id '
.
'WHERE r.id_user = '
.
$user_id
.
')'
);
return
$this
->
db
->
get
();
}
/*Добавляем пользователя*/
function
addUser
(
$data
)
{
if
(
!
$this
->
checkEmail
(
$data
[
'email'
]))
{
...
...
@@ -184,15 +204,21 @@ class User extends CI_Model {
/*Удаляем пользователя*/
function
deleteUser
(
$data
)
{
log_message
(
'error'
,
print_r
(
$data
,
true
));
$this
->
db
->
where
(
'id'
,
$data
[
'id_user'
]);
$this
->
db
->
delete
(
'users'
);
log_message
(
'error'
,
$this
->
db
->
last_query
());
$this
->
db
->
where
(
'id'
,
$data
[
'id_user'
]);
$this
->
db
->
delete
(
'responsible'
);
}
/*Снимаем ответсвенного*/
function
deleteResponsible
(
$data
)
{
log_message
(
'error'
,
'deleteResponsible with data = '
);
log_message
(
'error'
,
print_r
(
$data
,
true
));
$this
->
db
->
where
(
'id_site'
,
$data
[
'id_site'
]);
$this
->
db
->
where
(
'id_user'
,
$data
[
'id_user'
]);
...
...
@@ -201,10 +227,14 @@ class User extends CI_Model {
/*Обновляем статус*/
function
editResponsible
(
$data
)
{
$this
->
db
->
set
(
'status'
,
$data
[
'status'
]);
$this
->
db
->
where
(
'id_site'
,
$data
[
'id_site'
]);
$this
->
db
->
where
(
'id_user'
,
$data
[
'id_user'
]);
$this
->
db
->
update
(
'responsible'
,
array
(
'status'
=>
$data
[
'status'
]));
$this
->
db
->
update
(
'responsible'
);
log_message
(
'error'
,
$this
->
db
->
last_query
());
}
/*Проверяем логин на уникальность*/
...
...
@@ -275,19 +305,22 @@ class User extends CI_Model {
if
(
!
$this
->
checkSiteId
(
$data
[
'id_site'
]))
{
return
array
(
'message'
=>
"Сайт не существует"
);
}
$data2
[
0
]
=
'NULL'
;
$data2
[
1
]
=
$data
[
'id_site'
];
$data2
[
2
]
=
$data
[
'id_user'
];
$data2
[
3
]
=
$data
[
'status'
];
$data2
[
4
]
=
date
(
'Y-m-d H:i:s'
,
time
());
$data2
=
[
'id'
=>
NULL
,
'id_site'
=>
$data
[
'id_site'
],
'id_user'
=>
$data
[
'id_user'
],
'status'
=>
$data
[
'status'
],
'date'
=>
date
(
'Y-m-d H:i:s'
,
time
())
];
$this
->
db
->
insert
(
'responsible'
,
$data2
);
}
/*Проверяем - есть ли у пользователя такой сайт*/
function
checkResponsible
(
$data
)
{
$this
->
db
->
where
(
"
user_id
"
,
$data
[
'id_user'
]);
$this
->
db
->
where
(
"
site_id
"
,
$data
[
'id_site'
]);
$this
->
db
->
where
(
"
id_user
"
,
$data
[
'id_user'
]);
$this
->
db
->
where
(
"
id_site
"
,
$data
[
'id_site'
]);
$this
->
db
->
from
(
"responsible"
);
$count
=
$this
->
db
->
count_all_results
();
...
...
@@ -305,9 +338,9 @@ class User extends CI_Model {
$count
=
$this
->
db
->
count_all_results
();
if
(
$count
==
0
)
{
return
true
;
}
else
{
return
false
;
}
else
{
return
true
;
}
}
...
...
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