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
4234de91
Commit
4234de91
authored
Jan 15, 2019
by
Scott
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Coding style (strict): control braces
parent
7c6b6de0
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
94 additions
and
57 deletions
+94
-57
UserPosts.php
qa-src/Controllers/User/UserPosts.php
+11
-7
UserProfile.php
qa-src/Controllers/User/UserProfile.php
+69
-39
DbConnection.php
qa-src/Database/DbConnection.php
+13
-7
CacheFactory.php
qa-src/Storage/CacheFactory.php
+1
-2
ruleset-strict.xml
qa-tests/phpcs/ruleset-strict.xml
+0
-2
No files found.
qa-src/Controllers/User/UserPosts.php
View file @
4234de91
...
@@ -70,10 +70,11 @@ class UserPosts extends \Q2A\Controllers\BaseController
...
@@ -70,10 +70,11 @@ class UserPosts extends \Q2A\Controllers\BaseController
$qa_content
=
qa_content_prepare
(
true
);
$qa_content
=
qa_content_prepare
(
true
);
if
(
count
(
$questions
))
if
(
count
(
$questions
))
{
$qa_content
[
'title'
]
=
qa_lang_html_sub
(
'profile/recent_activity_by_x'
,
$this
->
userhtml
);
$qa_content
[
'title'
]
=
qa_lang_html_sub
(
'profile/recent_activity_by_x'
,
$this
->
userhtml
);
else
}
else
{
$qa_content
[
'title'
]
=
qa_lang_html_sub
(
'profile/no_posts_by_x'
,
$this
->
userhtml
);
$qa_content
[
'title'
]
=
qa_lang_html_sub
(
'profile/no_posts_by_x'
,
$this
->
userhtml
);
}
// Recent activity by this user
// Recent activity by this user
...
@@ -154,10 +155,11 @@ class UserPosts extends \Q2A\Controllers\BaseController
...
@@ -154,10 +155,11 @@ class UserPosts extends \Q2A\Controllers\BaseController
$qa_content
=
qa_content_prepare
(
true
);
$qa_content
=
qa_content_prepare
(
true
);
if
(
count
(
$questions
))
if
(
count
(
$questions
))
{
$qa_content
[
'title'
]
=
qa_lang_html_sub
(
'profile/questions_by_x'
,
$this
->
userhtml
);
$qa_content
[
'title'
]
=
qa_lang_html_sub
(
'profile/questions_by_x'
,
$this
->
userhtml
);
else
}
else
{
$qa_content
[
'title'
]
=
qa_lang_html_sub
(
'profile/no_questions_by_x'
,
$this
->
userhtml
);
$qa_content
[
'title'
]
=
qa_lang_html_sub
(
'profile/no_questions_by_x'
,
$this
->
userhtml
);
}
// Recent questions by this user
// Recent questions by this user
...
@@ -240,10 +242,11 @@ class UserPosts extends \Q2A\Controllers\BaseController
...
@@ -240,10 +242,11 @@ class UserPosts extends \Q2A\Controllers\BaseController
$qa_content
=
qa_content_prepare
(
true
);
$qa_content
=
qa_content_prepare
(
true
);
if
(
count
(
$questions
))
if
(
count
(
$questions
))
{
$qa_content
[
'title'
]
=
qa_lang_html_sub
(
'profile/answers_by_x'
,
$this
->
userhtml
);
$qa_content
[
'title'
]
=
qa_lang_html_sub
(
'profile/answers_by_x'
,
$this
->
userhtml
);
else
}
else
{
$qa_content
[
'title'
]
=
qa_lang_html_sub
(
'profile/no_answers_by_x'
,
$this
->
userhtml
);
$qa_content
[
'title'
]
=
qa_lang_html_sub
(
'profile/no_answers_by_x'
,
$this
->
userhtml
);
}
// Recent questions by this user
// Recent questions by this user
...
@@ -299,7 +302,8 @@ class UserPosts extends \Q2A\Controllers\BaseController
...
@@ -299,7 +302,8 @@ class UserPosts extends \Q2A\Controllers\BaseController
$usershtml
=
qa_get_users_html
(
array
(
$this
->
userid
),
false
,
qa_path_to_root
(),
true
);
$usershtml
=
qa_get_users_html
(
array
(
$this
->
userid
),
false
,
qa_path_to_root
(),
true
);
$this
->
userhtml
=
@
$usershtml
[
$this
->
userid
];
$this
->
userhtml
=
@
$usershtml
[
$this
->
userid
];
}
else
}
else
{
$this
->
userhtml
=
qa_html
(
$handle
);
$this
->
userhtml
=
qa_html
(
$handle
);
}
}
}
}
}
qa-src/Controllers/User/UserProfile.php
View file @
4234de91
...
@@ -51,14 +51,16 @@ class UserProfile extends \Q2A\Controllers\BaseController
...
@@ -51,14 +51,16 @@ class UserProfile extends \Q2A\Controllers\BaseController
$usershtml
=
qa_get_users_html
(
array
(
$userid
),
false
,
qa_path_to_root
(),
true
);
$usershtml
=
qa_get_users_html
(
array
(
$userid
),
false
,
qa_path_to_root
(),
true
);
$userhtml
=
@
$usershtml
[
$userid
];
$userhtml
=
@
$usershtml
[
$userid
];
}
else
}
else
{
$userhtml
=
qa_html
(
$handle
);
$userhtml
=
qa_html
(
$handle
);
}
// Redirect to 'My Account' page if button clicked
// Redirect to 'My Account' page if button clicked
if
(
qa_clicked
(
'doaccount'
))
if
(
qa_clicked
(
'doaccount'
))
{
qa_redirect
(
'account'
);
qa_redirect
(
'account'
);
}
// Find the user profile and questions and answers for this handle
// Find the user profile and questions and answers for this handle
...
@@ -80,8 +82,9 @@ class UserProfile extends \Q2A\Controllers\BaseController
...
@@ -80,8 +82,9 @@ class UserProfile extends \Q2A\Controllers\BaseController
if
(
!
QA_FINAL_EXTERNAL_USERS
&&
$handle
!==
qa_get_logged_in_handle
())
{
if
(
!
QA_FINAL_EXTERNAL_USERS
&&
$handle
!==
qa_get_logged_in_handle
())
{
foreach
(
$userfields
as
$index
=>
$userfield
)
{
foreach
(
$userfields
as
$index
=>
$userfield
)
{
if
(
isset
(
$userfield
[
'permit'
])
&&
qa_permit_value_error
(
$userfield
[
'permit'
],
$loginuserid
,
qa_get_logged_in_level
(),
qa_get_logged_in_flags
()))
if
(
isset
(
$userfield
[
'permit'
])
&&
qa_permit_value_error
(
$userfield
[
'permit'
],
$loginuserid
,
qa_get_logged_in_level
(),
qa_get_logged_in_flags
()))
{
unset
(
$userfields
[
$index
]);
// don't pay attention to user fields we're not allowed to view
unset
(
$userfields
[
$index
]);
// don't pay attention to user fields we're not allowed to view
}
}
}
}
}
...
@@ -92,7 +95,8 @@ class UserProfile extends \Q2A\Controllers\BaseController
...
@@ -92,7 +95,8 @@ class UserProfile extends \Q2A\Controllers\BaseController
$loginlevel
=
qa_get_logged_in_level
();
$loginlevel
=
qa_get_logged_in_level
();
if
(
!
QA_FINAL_EXTERNAL_USERS
)
{
// if we're using integrated user management, we can know and show more
// if we're using integrated user management, we can know and show more
if
(
!
QA_FINAL_EXTERNAL_USERS
)
{
require_once
QA_INCLUDE_DIR
.
'app/messages.php'
;
require_once
QA_INCLUDE_DIR
.
'app/messages.php'
;
if
(
!
is_array
(
$userpoints
)
&&
!
is_array
(
$useraccount
))
{
// check the user exists
if
(
!
is_array
(
$userpoints
)
&&
!
is_array
(
$useraccount
))
{
// check the user exists
...
@@ -104,26 +108,30 @@ class UserProfile extends \Q2A\Controllers\BaseController
...
@@ -104,26 +108,30 @@ class UserProfile extends \Q2A\Controllers\BaseController
$maxlevelassign
=
null
;
$maxlevelassign
=
null
;
$maxuserlevel
=
$useraccount
[
'level'
];
$maxuserlevel
=
$useraccount
[
'level'
];
foreach
(
$userlevels
as
$userlevel
)
foreach
(
$userlevels
as
$userlevel
)
{
$maxuserlevel
=
max
(
$maxuserlevel
,
$userlevel
[
'level'
]);
$maxuserlevel
=
max
(
$maxuserlevel
,
$userlevel
[
'level'
]);
}
if
(
isset
(
$loginuserid
)
&&
$loginuserid
!=
$userid
&&
if
(
isset
(
$loginuserid
)
&&
$loginuserid
!=
$userid
&&
(
$loginlevel
>=
QA_USER_LEVEL_SUPER
||
$loginlevel
>
$maxuserlevel
)
&&
(
$loginlevel
>=
QA_USER_LEVEL_SUPER
||
$loginlevel
>
$maxuserlevel
)
&&
!
qa_user_permit_error
()
!
qa_user_permit_error
()
)
{
// can't change self - or someone on your level (or higher, obviously) unless you're a super admin
)
{
// can't change self - or someone on your level (or higher, obviously) unless you're a super admin
if
(
$loginlevel
>=
QA_USER_LEVEL_SUPER
)
if
(
$loginlevel
>=
QA_USER_LEVEL_SUPER
)
{
$maxlevelassign
=
QA_USER_LEVEL_SUPER
;
$maxlevelassign
=
QA_USER_LEVEL_SUPER
;
elseif
(
$loginlevel
>=
QA_USER_LEVEL_ADMIN
)
}
elseif
(
$loginlevel
>=
QA_USER_LEVEL_ADMIN
)
{
$maxlevelassign
=
QA_USER_LEVEL_MODERATOR
;
$maxlevelassign
=
QA_USER_LEVEL_MODERATOR
;
elseif
(
$loginlevel
>=
QA_USER_LEVEL_MODERATOR
)
}
elseif
(
$loginlevel
>=
QA_USER_LEVEL_MODERATOR
)
{
$maxlevelassign
=
QA_USER_LEVEL_EXPERT
;
$maxlevelassign
=
QA_USER_LEVEL_EXPERT
;
}
if
(
$loginlevel
>=
QA_USER_LEVEL_ADMIN
)
if
(
$loginlevel
>=
QA_USER_LEVEL_ADMIN
)
{
$fieldseditable
=
true
;
$fieldseditable
=
true
;
}
if
(
isset
(
$maxlevelassign
)
&&
(
$useraccount
[
'flags'
]
&
QA_USER_FLAGS_USER_BLOCKED
))
if
(
isset
(
$maxlevelassign
)
&&
(
$useraccount
[
'flags'
]
&
QA_USER_FLAGS_USER_BLOCKED
))
{
$maxlevelassign
=
min
(
$maxlevelassign
,
QA_USER_LEVEL_EDITOR
);
// if blocked, can't promote too high
$maxlevelassign
=
min
(
$maxlevelassign
,
QA_USER_LEVEL_EDITOR
);
// if blocked, can't promote too high
}
}
}
$approvebutton
=
isset
(
$maxlevelassign
)
$approvebutton
=
isset
(
$maxlevelassign
)
...
@@ -143,9 +151,9 @@ class UserProfile extends \Q2A\Controllers\BaseController
...
@@ -143,9 +151,9 @@ class UserProfile extends \Q2A\Controllers\BaseController
foreach
(
$usermessages
as
$message
)
{
foreach
(
$usermessages
as
$message
)
{
if
(
$message
[
'deleteable'
]
&&
qa_clicked
(
'm'
.
$message
[
'messageid'
]
.
'_dodelete'
))
{
if
(
$message
[
'deleteable'
]
&&
qa_clicked
(
'm'
.
$message
[
'messageid'
]
.
'_dodelete'
))
{
if
(
!
qa_check_form_security_code
(
'wall-'
.
$useraccount
[
'handle'
],
qa_post_text
(
'code'
)))
if
(
!
qa_check_form_security_code
(
'wall-'
.
$useraccount
[
'handle'
],
qa_post_text
(
'code'
)))
{
$errors
[
'page'
]
=
qa_lang_html
(
'misc/form_security_again'
);
$errors
[
'page'
]
=
qa_lang_html
(
'misc/form_security_again'
);
else
{
}
else
{
qa_wall_delete_post
(
$loginuserid
,
qa_get_logged_in_handle
(),
qa_cookie_get
(),
$message
);
qa_wall_delete_post
(
$loginuserid
,
qa_get_logged_in_handle
(),
qa_cookie_get
(),
$message
);
qa_redirect
(
qa_request
(),
null
,
null
,
null
,
'wall'
);
qa_redirect
(
qa_request
(),
null
,
null
,
null
,
'wall'
);
}
}
...
@@ -171,8 +179,9 @@ class UserProfile extends \Q2A\Controllers\BaseController
...
@@ -171,8 +179,9 @@ class UserProfile extends \Q2A\Controllers\BaseController
$inemail
=
qa_post_text
(
'email'
);
$inemail
=
qa_post_text
(
'email'
);
$inprofile
=
array
();
$inprofile
=
array
();
foreach
(
$userfields
as
$userfield
)
foreach
(
$userfields
as
$userfield
)
{
$inprofile
[
$userfield
[
'fieldid'
]]
=
qa_post_text
(
'field_'
.
$userfield
[
'fieldid'
]);
$inprofile
[
$userfield
[
'fieldid'
]]
=
qa_post_text
(
'field_'
.
$userfield
[
'fieldid'
]);
}
if
(
!
qa_check_form_security_code
(
'user-edit-'
.
$handle
,
qa_post_text
(
'code'
)))
{
if
(
!
qa_check_form_security_code
(
'user-edit-'
.
$handle
,
qa_post_text
(
'code'
)))
{
$errors
[
'page'
]
=
qa_lang_html
(
'misc/form_security_again'
);
$errors
[
'page'
]
=
qa_lang_html
(
'misc/form_security_again'
);
...
@@ -206,17 +215,20 @@ class UserProfile extends \Q2A\Controllers\BaseController
...
@@ -206,17 +215,20 @@ class UserProfile extends \Q2A\Controllers\BaseController
if
(
count
(
$inprofile
))
{
if
(
count
(
$inprofile
))
{
$filtermodules
=
qa_load_modules_with
(
'filter'
,
'filter_profile'
);
$filtermodules
=
qa_load_modules_with
(
'filter'
,
'filter_profile'
);
foreach
(
$filtermodules
as
$filtermodule
)
foreach
(
$filtermodules
as
$filtermodule
)
{
$filtermodule
->
filter_profile
(
$inprofile
,
$errors
,
$useraccount
,
$userprofile
);
$filtermodule
->
filter_profile
(
$inprofile
,
$errors
,
$useraccount
,
$userprofile
);
}
}
}
foreach
(
$userfields
as
$userfield
)
{
foreach
(
$userfields
as
$userfield
)
{
if
(
!
isset
(
$errors
[
$userfield
[
'fieldid'
]]))
if
(
!
isset
(
$errors
[
$userfield
[
'fieldid'
]]))
{
qa_db_user_profile_set
(
$userid
,
$userfield
[
'title'
],
$inprofile
[
$userfield
[
'fieldid'
]]);
qa_db_user_profile_set
(
$userid
,
$userfield
[
'title'
],
$inprofile
[
$userfield
[
'fieldid'
]]);
}
}
}
if
(
count
(
$errors
))
if
(
count
(
$errors
))
{
$userediting
=
true
;
$userediting
=
true
;
}
qa_report_event
(
'u_edit'
,
$loginuserid
,
qa_get_logged_in_handle
(),
qa_cookie_get
(),
array
(
qa_report_event
(
'u_edit'
,
$loginuserid
,
qa_get_logged_in_handle
(),
qa_cookie_get
(),
array
(
'userid'
=>
$userid
,
'userid'
=>
$userid
,
...
@@ -226,16 +238,18 @@ class UserProfile extends \Q2A\Controllers\BaseController
...
@@ -226,16 +238,18 @@ class UserProfile extends \Q2A\Controllers\BaseController
if
(
isset
(
$maxlevelassign
))
{
if
(
isset
(
$maxlevelassign
))
{
$inlevel
=
min
(
$maxlevelassign
,
(
int
)
qa_post_text
(
'level'
));
// constrain based on maximum permitted to prevent simple browser-based attack
$inlevel
=
min
(
$maxlevelassign
,
(
int
)
qa_post_text
(
'level'
));
// constrain based on maximum permitted to prevent simple browser-based attack
if
(
$inlevel
!=
$useraccount
[
'level'
])
if
(
$inlevel
!=
$useraccount
[
'level'
])
{
qa_set_user_level
(
$userid
,
$useraccount
[
'handle'
],
$inlevel
,
$useraccount
[
'level'
]);
qa_set_user_level
(
$userid
,
$useraccount
[
'handle'
],
$inlevel
,
$useraccount
[
'level'
]);
}
if
(
qa_using_categories
())
{
if
(
qa_using_categories
())
{
$inuserlevels
=
array
();
$inuserlevels
=
array
();
for
(
$index
=
1
;
$index
<=
999
;
$index
++
)
{
for
(
$index
=
1
;
$index
<=
999
;
$index
++
)
{
$inlevel
=
qa_post_text
(
'uc_'
.
$index
.
'_level'
);
$inlevel
=
qa_post_text
(
'uc_'
.
$index
.
'_level'
);
if
(
!
isset
(
$inlevel
))
if
(
!
isset
(
$inlevel
))
{
break
;
break
;
}
$categoryid
=
qa_get_category_field_value
(
'uc_'
.
$index
.
'_cat'
);
$categoryid
=
qa_get_category_field_value
(
'uc_'
.
$index
.
'_cat'
);
...
@@ -252,8 +266,9 @@ class UserProfile extends \Q2A\Controllers\BaseController
...
@@ -252,8 +266,9 @@ class UserProfile extends \Q2A\Controllers\BaseController
}
}
}
}
if
(
empty
(
$errors
))
if
(
empty
(
$errors
))
{
qa_redirect
(
qa_request
());
qa_redirect
(
qa_request
());
}
list
(
$useraccount
,
$userprofile
,
$userlevels
)
=
qa_db_select_with_pending
(
list
(
$useraccount
,
$userprofile
,
$userlevels
)
=
qa_db_select_with_pending
(
qa_db_user_account_selectspec
(
$userid
,
true
),
qa_db_user_account_selectspec
(
$userid
,
true
),
...
@@ -295,8 +310,9 @@ class UserProfile extends \Q2A\Controllers\BaseController
...
@@ -295,8 +310,9 @@ class UserProfile extends \Q2A\Controllers\BaseController
$postids
=
qa_db_get_user_visible_postids
(
$userid
);
$postids
=
qa_db_get_user_visible_postids
(
$userid
);
foreach
(
$postids
as
$postid
)
foreach
(
$postids
as
$postid
)
{
qa_post_set_status
(
$postid
,
QA_POST_STATUS_HIDDEN
,
$loginuserid
);
qa_post_set_status
(
$postid
,
QA_POST_STATUS_HIDDEN
,
$loginuserid
);
}
qa_redirect
(
qa_request
());
qa_redirect
(
qa_request
());
}
}
...
@@ -414,8 +430,9 @@ class UserProfile extends \Q2A\Controllers\BaseController
...
@@ -414,8 +430,9 @@ class UserProfile extends \Q2A\Controllers\BaseController
),
),
);
);
if
(
empty
(
$qa_content
[
'form_profile'
][
'fields'
][
'avatar'
][
'html'
]))
if
(
empty
(
$qa_content
[
'form_profile'
][
'fields'
][
'avatar'
][
'html'
]))
{
unset
(
$qa_content
[
'form_profile'
][
'fields'
][
'avatar'
]);
unset
(
$qa_content
[
'form_profile'
][
'fields'
][
'avatar'
]);
}
// Private message link
// Private message link
...
@@ -435,8 +452,9 @@ class UserProfile extends \Q2A\Controllers\BaseController
...
@@ -435,8 +452,9 @@ class UserProfile extends \Q2A\Controllers\BaseController
$qa_content
[
'form_profile'
][
'fields'
][
'level'
][
'type'
]
=
'select'
;
$qa_content
[
'form_profile'
][
'fields'
][
'level'
][
'type'
]
=
'select'
;
$showlevels
=
array
(
QA_USER_LEVEL_BASIC
);
$showlevels
=
array
(
QA_USER_LEVEL_BASIC
);
if
(
qa_opt
(
'moderate_users'
))
if
(
qa_opt
(
'moderate_users'
))
{
$showlevels
[]
=
QA_USER_LEVEL_APPROVED
;
$showlevels
[]
=
QA_USER_LEVEL_APPROVED
;
}
array_push
(
$showlevels
,
QA_USER_LEVEL_EXPERT
,
QA_USER_LEVEL_EDITOR
,
QA_USER_LEVEL_MODERATOR
,
QA_USER_LEVEL_ADMIN
,
QA_USER_LEVEL_SUPER
);
array_push
(
$showlevels
,
QA_USER_LEVEL_EXPERT
,
QA_USER_LEVEL_EDITOR
,
QA_USER_LEVEL_MODERATOR
,
QA_USER_LEVEL_ADMIN
,
QA_USER_LEVEL_SUPER
);
...
@@ -446,8 +464,9 @@ class UserProfile extends \Q2A\Controllers\BaseController
...
@@ -446,8 +464,9 @@ class UserProfile extends \Q2A\Controllers\BaseController
foreach
(
$showlevels
as
$showlevel
)
{
foreach
(
$showlevels
as
$showlevel
)
{
if
(
$showlevel
<=
$maxlevelassign
)
{
if
(
$showlevel
<=
$maxlevelassign
)
{
$leveloptions
[
$showlevel
]
=
qa_html
(
qa_user_level_string
(
$showlevel
));
$leveloptions
[
$showlevel
]
=
qa_html
(
qa_user_level_string
(
$showlevel
));
if
(
$showlevel
>
QA_USER_LEVEL_BASIC
)
if
(
$showlevel
>
QA_USER_LEVEL_BASIC
)
{
$catleveloptions
[
$showlevel
]
=
$leveloptions
[
$showlevel
];
$catleveloptions
[
$showlevel
]
=
$leveloptions
[
$showlevel
];
}
}
}
}
}
...
@@ -468,8 +487,9 @@ class UserProfile extends \Q2A\Controllers\BaseController
...
@@ -468,8 +487,9 @@ class UserProfile extends \Q2A\Controllers\BaseController
$qa_content
[
'form_profile'
][
'fields'
][
'level'
][
'suffix'
]
=
qa_lang_html
(
'users/level_in_general'
);
$qa_content
[
'form_profile'
][
'fields'
][
'level'
][
'suffix'
]
=
qa_lang_html
(
'users/level_in_general'
);
}
}
if
(
$catleveladd
||
count
(
$userlevels
))
if
(
$catleveladd
||
count
(
$userlevels
))
{
$userlevels
[]
=
array
(
'entitytype'
=>
QA_ENTITY_CATEGORY
);
$userlevels
[]
=
array
(
'entitytype'
=>
QA_ENTITY_CATEGORY
);
}
$index
=
0
;
$index
=
0
;
foreach
(
$userlevels
as
$userlevel
)
{
foreach
(
$userlevels
as
$userlevel
)
{
...
@@ -488,10 +508,11 @@ class UserProfile extends \Q2A\Controllers\BaseController
...
@@ -488,10 +508,11 @@ class UserProfile extends \Q2A\Controllers\BaseController
$qa_content
[
'form_profile'
][
'fields'
][
'uc_'
.
$index
.
'_cat'
]
=
array
();
$qa_content
[
'form_profile'
][
'fields'
][
'uc_'
.
$index
.
'_cat'
]
=
array
();
if
(
isset
(
$userlevel
[
'entityid'
]))
if
(
isset
(
$userlevel
[
'entityid'
]))
{
$fieldnavcategories
=
qa_db_select_with_pending
(
qa_db_category_nav_selectspec
(
$userlevel
[
'entityid'
],
true
));
$fieldnavcategories
=
qa_db_select_with_pending
(
qa_db_category_nav_selectspec
(
$userlevel
[
'entityid'
],
true
));
else
}
else
{
$fieldnavcategories
=
$navcategories
;
$fieldnavcategories
=
$navcategories
;
}
qa_set_up_category_field
(
qa_set_up_category_field
(
$qa_content
,
$qa_content
,
...
@@ -558,10 +579,11 @@ class UserProfile extends \Q2A\Controllers\BaseController
...
@@ -558,10 +579,11 @@ class UserProfile extends \Q2A\Controllers\BaseController
if
(
qa_permit_error
(
$permitoption
,
$userid
,
QA_USER_LEVEL_APPROVED
,
QA_USER_FLAGS_EMAIL_CONFIRMED
,
0
)
&&
if
(
qa_permit_error
(
$permitoption
,
$userid
,
QA_USER_LEVEL_APPROVED
,
QA_USER_FLAGS_EMAIL_CONFIRMED
,
0
)
&&
!
qa_permit_error
(
$permitoption
,
$userid
,
$useraccount
[
'level'
],
$useraccount
[
'flags'
],
$userpoints
[
'points'
])
!
qa_permit_error
(
$permitoption
,
$userid
,
$useraccount
[
'level'
],
$useraccount
[
'flags'
],
$userpoints
[
'points'
])
)
{
)
{
if
(
$permitoption
==
'permit_retag_cat'
)
if
(
$permitoption
==
'permit_retag_cat'
)
{
$showpermits
[]
=
qa_lang
(
qa_using_categories
()
?
'profile/permit_recat'
:
'profile/permit_retag'
);
$showpermits
[]
=
qa_lang
(
qa_using_categories
()
?
'profile/permit_recat'
:
'profile/permit_retag'
);
else
}
else
{
$showpermits
[]
=
qa_lang
(
'profile/'
.
$permitoption
);
// then show it as an extra priviliege
$showpermits
[]
=
qa_lang
(
'profile/'
.
$permitoption
);
// then show it as an extra priviliege
}
}
}
}
}
...
@@ -638,26 +660,29 @@ class UserProfile extends \Q2A\Controllers\BaseController
...
@@ -638,26 +660,29 @@ class UserProfile extends \Q2A\Controllers\BaseController
$valuehtml
=
qa_url_to_html_link
(
@
$userprofile
[
$userfield
[
'title'
]],
qa_opt
(
'links_in_new_window'
));
$valuehtml
=
qa_url_to_html_link
(
@
$userprofile
[
$userfield
[
'title'
]],
qa_opt
(
'links_in_new_window'
));
}
else
{
}
else
{
$value
=
@
$inprofile
[
$userfield
[
'fieldid'
]];
$value
=
@
$inprofile
[
$userfield
[
'fieldid'
]];
if
(
!
isset
(
$value
))
if
(
!
isset
(
$value
))
{
$value
=
@
$userprofile
[
$userfield
[
'title'
]];
$value
=
@
$userprofile
[
$userfield
[
'title'
]];
}
$valuehtml
=
qa_html
(
$value
,
((
$userfield
[
'flags'
]
&
QA_FIELD_FLAGS_MULTI_LINE
)
&&
!
$fieldsediting
));
$valuehtml
=
qa_html
(
$value
,
((
$userfield
[
'flags'
]
&
QA_FIELD_FLAGS_MULTI_LINE
)
&&
!
$fieldsediting
));
}
}
$label
=
trim
(
qa_user_userfield_label
(
$userfield
),
':'
);
$label
=
trim
(
qa_user_userfield_label
(
$userfield
),
':'
);
if
(
strlen
(
$label
))
if
(
strlen
(
$label
))
{
$label
.=
':'
;
$label
.=
':'
;
}
$notehtml
=
null
;
$notehtml
=
null
;
if
(
isset
(
$userfield
[
'permit'
])
&&
!
$userediting
)
{
if
(
isset
(
$userfield
[
'permit'
])
&&
!
$userediting
)
{
if
(
$userfield
[
'permit'
]
<=
QA_PERMIT_ADMINS
)
if
(
$userfield
[
'permit'
]
<=
QA_PERMIT_ADMINS
)
{
$notehtml
=
qa_lang_html
(
'users/only_shown_admins'
);
$notehtml
=
qa_lang_html
(
'users/only_shown_admins'
);
elseif
(
$userfield
[
'permit'
]
<=
QA_PERMIT_MODERATORS
)
}
elseif
(
$userfield
[
'permit'
]
<=
QA_PERMIT_MODERATORS
)
{
$notehtml
=
qa_lang_html
(
'users/only_shown_moderators'
);
$notehtml
=
qa_lang_html
(
'users/only_shown_moderators'
);
elseif
(
$userfield
[
'permit'
]
<=
QA_PERMIT_EDITORS
)
}
elseif
(
$userfield
[
'permit'
]
<=
QA_PERMIT_EDITORS
)
{
$notehtml
=
qa_lang_html
(
'users/only_shown_editors'
);
$notehtml
=
qa_lang_html
(
'users/only_shown_editors'
);
elseif
(
$userfield
[
'permit'
]
<=
QA_PERMIT_EXPERTS
)
}
elseif
(
$userfield
[
'permit'
]
<=
QA_PERMIT_EXPERTS
)
{
$notehtml
=
qa_lang_html
(
'users/only_shown_experts'
);
$notehtml
=
qa_lang_html
(
'users/only_shown_experts'
);
}
}
}
$qa_content
[
'form_profile'
][
'fields'
][
$userfield
[
'title'
]]
=
array
(
$qa_content
[
'form_profile'
][
'fields'
][
$userfield
[
'title'
]]
=
array
(
...
@@ -758,8 +783,9 @@ class UserProfile extends \Q2A\Controllers\BaseController
...
@@ -758,8 +783,9 @@ class UserProfile extends \Q2A\Controllers\BaseController
}
}
if
(
!
is_array
(
$qa_content
[
'form_profile'
][
'fields'
][
'removeavatar'
]))
if
(
!
is_array
(
$qa_content
[
'form_profile'
][
'fields'
][
'removeavatar'
]))
{
unset
(
$qa_content
[
'form_profile'
][
'fields'
][
'removeavatar'
]);
unset
(
$qa_content
[
'form_profile'
][
'fields'
][
'removeavatar'
]);
}
$qa_content
[
'raw'
][
'account'
]
=
$useraccount
;
// for plugin layers to access
$qa_content
[
'raw'
][
'account'
]
=
$useraccount
;
// for plugin layers to access
$qa_content
[
'raw'
][
'profile'
]
=
$userprofile
;
$qa_content
[
'raw'
][
'profile'
]
=
$userprofile
;
...
@@ -832,8 +858,9 @@ class UserProfile extends \Q2A\Controllers\BaseController
...
@@ -832,8 +858,9 @@ class UserProfile extends \Q2A\Controllers\BaseController
unset
(
$qa_content
[
'form_activity'
][
'fields'
][
'bonus'
]);
unset
(
$qa_content
[
'form_activity'
][
'fields'
][
'bonus'
]);
}
}
if
(
!
isset
(
$qa_content
[
'form_activity'
][
'fields'
][
'title'
][
'value'
]))
if
(
!
isset
(
$qa_content
[
'form_activity'
][
'fields'
][
'title'
][
'value'
]))
{
unset
(
$qa_content
[
'form_activity'
][
'fields'
][
'title'
]);
unset
(
$qa_content
[
'form_activity'
][
'fields'
][
'title'
]);
}
if
(
qa_opt
(
'comment_on_qs'
)
||
qa_opt
(
'comment_on_as'
))
{
// only show comment count if comments are enabled
if
(
qa_opt
(
'comment_on_qs'
)
||
qa_opt
(
'comment_on_as'
))
{
// only show comment count if comments are enabled
$qa_content
[
'form_activity'
][
'fields'
][
'comments'
]
=
array
(
$qa_content
[
'form_activity'
][
'fields'
][
'comments'
]
=
array
(
...
@@ -854,8 +881,9 @@ class UserProfile extends \Q2A\Controllers\BaseController
...
@@ -854,8 +881,9 @@ class UserProfile extends \Q2A\Controllers\BaseController
$votedonvalue
.=
(
$qvotes
==
1
)
?
qa_lang_html_sub
(
'main/1_question'
,
$innervalue
,
'1'
)
$votedonvalue
.=
(
$qvotes
==
1
)
?
qa_lang_html_sub
(
'main/1_question'
,
$innervalue
,
'1'
)
:
qa_lang_html_sub
(
'main/x_questions'
,
$innervalue
);
:
qa_lang_html_sub
(
'main/x_questions'
,
$innervalue
);
if
(
qa_opt
(
'voting_on_as'
))
if
(
qa_opt
(
'voting_on_as'
))
{
$votedonvalue
.=
', '
;
$votedonvalue
.=
', '
;
}
}
}
if
(
qa_opt
(
'voting_on_as'
))
{
if
(
qa_opt
(
'voting_on_as'
))
{
...
@@ -971,11 +999,13 @@ class UserProfile extends \Q2A\Controllers\BaseController
...
@@ -971,11 +999,13 @@ class UserProfile extends \Q2A\Controllers\BaseController
);
);
}
}
foreach
(
$usermessages
as
$message
)
foreach
(
$usermessages
as
$message
)
{
$qa_content
[
'message_list'
][
'messages'
][]
=
qa_wall_post_view
(
$message
);
$qa_content
[
'message_list'
][
'messages'
][]
=
qa_wall_post_view
(
$message
);
}
if
(
$useraccount
[
'wallposts'
]
>
count
(
$usermessages
))
if
(
$useraccount
[
'wallposts'
]
>
count
(
$usermessages
))
{
$qa_content
[
'message_list'
][
'messages'
][]
=
qa_wall_view_more_link
(
$handle
,
count
(
$usermessages
));
$qa_content
[
'message_list'
][
'messages'
][]
=
qa_wall_view_more_link
(
$handle
,
count
(
$usermessages
));
}
}
}
...
...
qa-src/Database/DbConnection.php
View file @
4234de91
...
@@ -266,8 +266,9 @@ class DbConnection
...
@@ -266,8 +266,9 @@ class DbConnection
if
(
$cacheDriver
->
isEnabled
())
{
if
(
$cacheDriver
->
isEnabled
())
{
$queryData
=
$cacheDriver
->
get
(
$cacheKey
);
$queryData
=
$cacheDriver
->
get
(
$cacheKey
);
if
(
$queryData
!==
null
)
if
(
$queryData
!==
null
)
{
return
$queryData
;
return
$queryData
;
}
}
}
}
}
...
@@ -311,8 +312,9 @@ class DbConnection
...
@@ -311,8 +312,9 @@ class DbConnection
if
(
!
QA_OPTIMIZE_DISTANT_DB
||
count
(
$selectspecs
)
<=
1
)
{
if
(
!
QA_OPTIMIZE_DISTANT_DB
||
count
(
$selectspecs
)
<=
1
)
{
$outresults
=
array
();
$outresults
=
array
();
foreach
(
$selectspecs
as
$selectkey
=>
$selectspec
)
foreach
(
$selectspecs
as
$selectkey
=>
$selectspec
)
{
$outresults
[
$selectkey
]
=
$this
->
singleSelect
(
$selectspec
);
$outresults
[
$selectkey
]
=
$this
->
singleSelect
(
$selectspec
);
}
return
$outresults
;
return
$outresults
;
}
}
...
@@ -390,21 +392,24 @@ class DbConnection
...
@@ -390,21 +392,24 @@ class DbConnection
$rawresults
=
$stmt
->
fetchAllAssoc
();
$rawresults
=
$stmt
->
fetchAllAssoc
();
$outresults
=
array
();
$outresults
=
array
();
foreach
(
$selectspecs
as
$selectkey
=>
$selectspec
)
foreach
(
$selectspecs
as
$selectkey
=>
$selectspec
)
{
$outresults
[
$selectkey
]
=
array
();
$outresults
[
$selectkey
]
=
array
();
}
foreach
(
$rawresults
as
$rawresult
)
{
foreach
(
$rawresults
as
$rawresult
)
{
$selectkey
=
$rawresult
[
'selectkey'
];
$selectkey
=
$rawresult
[
'selectkey'
];
$selectspec
=
$selectspecs
[
$selectkey
];
$selectspec
=
$selectspecs
[
$selectkey
];
$keepresult
=
array
();
$keepresult
=
array
();
foreach
(
$selectspec
[
'outcolumns'
]
as
$columnas
=>
$columnfrom
)
foreach
(
$selectspec
[
'outcolumns'
]
as
$columnas
=>
$columnfrom
)
{
$keepresult
[
$columnas
]
=
$rawresult
[
$columnas
];
$keepresult
[
$columnas
]
=
$rawresult
[
$columnas
];
}
if
(
isset
(
$selectspec
[
'arraykey'
]))
if
(
isset
(
$selectspec
[
'arraykey'
]))
{
$outresults
[
$selectkey
][
$keepresult
[
$selectspec
[
'arraykey'
]]]
=
$keepresult
;
$outresults
[
$selectkey
][
$keepresult
[
$selectspec
[
'arraykey'
]]]
=
$keepresult
;
else
}
else
{
$outresults
[
$selectkey
][]
=
$keepresult
;
$outresults
[
$selectkey
][]
=
$keepresult
;
}
}
}
// Post-processing to apply various stuff include sorting request, since we can't rely on ORDER BY due to UNION
// Post-processing to apply various stuff include sorting request, since we can't rely on ORDER BY due to UNION
...
@@ -442,8 +447,9 @@ class DbConnection
...
@@ -442,8 +447,9 @@ class DbConnection
qa_sort_by
(
$outresult
,
$selectspec
[
'sortdesc'
],
$selectspec
[
'sortdesc_2'
]);
qa_sort_by
(
$outresult
,
$selectspec
[
'sortdesc'
],
$selectspec
[
'sortdesc_2'
]);
}
else
{
}
else
{
$index
=
count
(
$outresult
);
$index
=
count
(
$outresult
);
foreach
(
$outresult
as
$key
=>
$value
)
foreach
(
$outresult
as
$key
=>
$value
)
{
$outresult
[
$key
][
'_order_'
]
=
$index
--
;
$outresult
[
$key
][
'_order_'
]
=
$index
--
;
}
qa_sort_by
(
$outresult
,
$selectspec
[
'sortdesc'
],
'_order_'
);
qa_sort_by
(
$outresult
,
$selectspec
[
'sortdesc'
],
'_order_'
);
}
}
...
...
qa-src/Storage/CacheFactory.php
View file @
4234de91
...
@@ -40,8 +40,7 @@ class CacheFactory
...
@@ -40,8 +40,7 @@ class CacheFactory
$driver
=
qa_opt
(
'caching_driver'
);
$driver
=
qa_opt
(
'caching_driver'
);
switch
(
$driver
)
switch
(
$driver
)
{
{
case
'memcached'
:
case
'memcached'
:
self
::
$cacheDriver
=
new
MemcachedDriver
(
$config
);
self
::
$cacheDriver
=
new
MemcachedDriver
(
$config
);
break
;
break
;
...
...
qa-tests/phpcs/ruleset-strict.xml
View file @
4234de91
...
@@ -13,8 +13,6 @@
...
@@ -13,8 +13,6 @@
<rule
ref=
"PSR2"
>
<rule
ref=
"PSR2"
>
<exclude
name=
"Generic.WhiteSpace.DisallowTabIndent"
/>
<exclude
name=
"Generic.WhiteSpace.DisallowTabIndent"
/>
<exclude
name=
"Generic.Files.LineLength.TooLong"
/>
<exclude
name=
"Generic.Files.LineLength.TooLong"
/>
<exclude
name=
"Generic.ControlStructures.InlineControlStructure"
/>
<exclude
name=
"Squiz.ControlStructures.ControlSignature"
/>
<!-- doesn't work without above rule -->
</rule>
</rule>
<arg
name=
"tab-width"
value=
"4"
/>
<arg
name=
"tab-width"
value=
"4"
/>
...
...
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