Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Q
question2answer
Overview
Overview
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
outils
question2answer
Commits
869db52f
Commit
869db52f
authored
Sep 06, 2018
by
pupi1985
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove some unnecessary SQL queries
parent
40f15d44
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
52 additions
and
19 deletions
+52
-19
users-edit.php
qa-include/app/users-edit.php
+6
-3
users.php
qa-include/app/users.php
+4
-2
users.php
qa-include/db/users.php
+22
-9
user-profile.php
qa-include/pages/user-profile.php
+6
-3
qa-db.php
qa-include/qa-db.php
+14
-2
No files found.
qa-include/app/users-edit.php
View file @
869db52f
...
...
@@ -520,9 +520,12 @@ function qa_set_user_avatar($userid, $imagedata, $oldblobid = null)
$newblobid
=
qa_create_blob
(
$imagedata
,
'jpeg'
,
null
,
$userid
,
null
,
qa_remote_ip_address
());
if
(
isset
(
$newblobid
))
{
qa_db_user_set
(
$userid
,
'avatarblobid'
,
$newblobid
);
qa_db_user_set
(
$userid
,
'avatarwidth'
,
$width
);
qa_db_user_set
(
$userid
,
'avatarheight'
,
$height
);
qa_db_user_set
(
$userid
,
array
(
'avatarblobid'
=>
$newblobid
,
'avatarwidth'
=>
$width
,
'avatarheight'
=>
$height
,
));
qa_db_user_set_flag
(
$userid
,
QA_USER_FLAGS_SHOW_AVATAR
,
true
);
qa_db_user_set_flag
(
$userid
,
QA_USER_FLAGS_SHOW_GRAVATAR
,
false
);
...
...
qa-include/app/users.php
View file @
869db52f
...
...
@@ -289,8 +289,10 @@ if (QA_FINAL_EXTERNAL_USERS) {
if
(
empty
(
$userinfo
[
'sessioncode'
])
||
(
$source
!==
$userinfo
[
'sessionsource'
]))
{
$sessioncode
=
qa_db_user_rand_sessioncode
();
qa_db_user_set
(
$userid
,
'sessioncode'
,
$sessioncode
);
qa_db_user_set
(
$userid
,
'sessionsource'
,
$source
);
qa_db_user_set
(
$userid
,
array
(
'sessioncode'
=>
$sessioncode
,
'sessionsource'
=>
$source
,
));
}
else
$sessioncode
=
$userinfo
[
'sessioncode'
];
...
...
qa-include/db/users.php
View file @
869db52f
...
...
@@ -164,17 +164,30 @@ function qa_db_user_get_handle_userids($handles)
/**
* Set $field of $userid to $value in the database users table
* @param $userid
* @param $field
* @param $value
* Set $field of $userid to $value in the database users table. If the $fields parameter is an array, the $value
* parameter is ignored and each element of the array is treated as a key-value pair of user fields and values.
* @param mixed $userid
* @param string|array $fields
* @param string|null $value
*/
function
qa_db_user_set
(
$userid
,
$field
,
$value
)
function
qa_db_user_set
(
$userid
,
$field
s
,
$value
=
null
)
{
qa_db_query_sub
(
'UPDATE ^users SET '
.
qa_db_escape_string
(
$field
)
.
'=$ WHERE userid=$'
,
$value
,
$userid
);
if
(
!
is_array
(
$fields
))
{
$fields
=
array
(
$fields
=>
$value
,
);
}
$sql
=
'UPDATE ^users SET '
;
foreach
(
$fields
as
$field
=>
$fieldValue
)
{
$sql
.=
qa_db_escape_string
(
$field
)
.
' = $, '
;
}
$sql
=
substr
(
$sql
,
0
,
-
2
)
.
' WHERE userid = $'
;
$params
=
array_values
(
$fields
);
$params
[]
=
$userid
;
qa_db_query_sub_params
(
$sql
,
$params
);
}
...
...
qa-include/pages/user-profile.php
View file @
869db52f
...
...
@@ -163,9 +163,12 @@ if (!QA_FINAL_EXTERNAL_USERS) {
if
(
isset
(
$useraccount
[
'avatarblobid'
]))
{
require_once
QA_INCLUDE_DIR
.
'app/blobs.php'
;
qa_db_user_set
(
$userid
,
'avatarblobid'
,
null
);
qa_db_user_set
(
$userid
,
'avatarwidth'
,
null
);
qa_db_user_set
(
$userid
,
'avatarheight'
,
null
);
qa_db_user_set
(
$userid
,
array
(
'avatarblobid'
=>
null
,
'avatarwidth'
=>
null
,
'avatarheight'
=>
null
,
));
qa_delete_blob
(
$useraccount
[
'avatarblobid'
]);
}
}
...
...
qa-include/qa-db.php
View file @
869db52f
...
...
@@ -372,14 +372,26 @@ function qa_db_apply_sub($query, $arguments)
/**
* Run $query after substituting ^, # and $ symbols, and return the result resource (or call fail handler).
* @param $query
* @param
string
$query
* @return mixed
*/
function
qa_db_query_sub
(
$query
)
// arguments for substitution retrieved using func_get_args()
{
$funcargs
=
func_get_args
();
return
qa_db_query_raw
(
qa_db_apply_sub
(
$query
,
array_slice
(
$funcargs
,
1
)));
return
qa_db_query_sub_params
(
$query
,
array_slice
(
$funcargs
,
1
));
}
/**
* Run $query after substituting ^, # and $ symbols, and return the result resource (or call fail handler).
* Query parameters are passed as an array.
* @param string $query
* @param array $params
* @return mixed
*/
function
qa_db_query_sub_params
(
$query
,
$params
)
{
return
qa_db_query_raw
(
qa_db_apply_sub
(
$query
,
$params
));
}
...
...
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