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
f24542bb
Commit
f24542bb
authored
Jan 13, 2017
by
Scott
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Coding style (app posts/admin)
parent
5a94ef80
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
138 additions
and
150 deletions
+138
-150
admin.php
qa-include/app/admin.php
+95
-101
post-create.php
qa-include/app/post-create.php
+0
-0
post-update.php
qa-include/app/post-update.php
+0
-0
recalc.php
qa-include/app/recalc.php
+43
-49
users.php
qa-include/app/users.php
+0
-0
No files found.
qa-include/app/admin.php
View file @
f24542bb
...
@@ -20,18 +20,18 @@
...
@@ -20,18 +20,18 @@
More about this license: http://www.question2answer.org/license.php
More about this license: http://www.question2answer.org/license.php
*/
*/
if
(
!
defined
(
'QA_VERSION'
))
{
// don't allow this page to be requested directly from browser
if
(
!
defined
(
'QA_VERSION'
))
{
// don't allow this page to be requested directly from browser
header
(
'Location: ../'
);
header
(
'Location: ../'
);
exit
;
exit
;
}
}
function
qa_admin_check_privileges
(
&
$qa_content
)
/**
/*
* Return true if user is logged in with admin privileges. If not, return false
Return true if user is logged in with admin privileges. If not, return fals
e
* and set up $qa_content with the appropriate title and error messag
e
and set up $qa_content with the appropriate title and error message
*/
*/
function
qa_admin_check_privileges
(
&
$qa_content
)
{
{
if
(
!
qa_is_logged_in
())
{
if
(
!
qa_is_logged_in
())
{
require_once
QA_INCLUDE_DIR
.
'app/format.php'
;
require_once
QA_INCLUDE_DIR
.
'app/format.php'
;
...
@@ -52,14 +52,14 @@
...
@@ -52,14 +52,14 @@
}
}
return
true
;
return
true
;
}
}
/**
/**
* Return a sorted array of available languages, [short code] => [long name]
* Return a sorted array of available languages, [short code] => [long name]
*/
*/
function
qa_admin_language_options
()
function
qa_admin_language_options
()
{
{
if
(
qa_to_override
(
__FUNCTION__
))
{
$args
=
func_get_args
();
return
qa_call_override
(
__FUNCTION__
,
$args
);
}
if
(
qa_to_override
(
__FUNCTION__
))
{
$args
=
func_get_args
();
return
qa_call_override
(
__FUNCTION__
,
$args
);
}
/**
/**
...
@@ -133,14 +133,14 @@
...
@@ -133,14 +133,14 @@
asort
(
$options
,
SORT_STRING
);
asort
(
$options
,
SORT_STRING
);
return
$options
;
return
$options
;
}
}
/**
/**
* Return a sorted array of available themes, [theme name] => [theme name]
* Return a sorted array of available themes, [theme name] => [theme name]
*/
*/
function
qa_admin_theme_options
()
function
qa_admin_theme_options
()
{
{
if
(
qa_to_override
(
__FUNCTION__
))
{
$args
=
func_get_args
();
return
qa_call_override
(
__FUNCTION__
,
$args
);
}
if
(
qa_to_override
(
__FUNCTION__
))
{
$args
=
func_get_args
();
return
qa_call_override
(
__FUNCTION__
,
$args
);
}
$metadataUtil
=
new
Q2A_Util_Metadata
();
$metadataUtil
=
new
Q2A_Util_Metadata
();
...
@@ -157,14 +157,14 @@
...
@@ -157,14 +157,14 @@
asort
(
$options
,
SORT_STRING
);
asort
(
$options
,
SORT_STRING
);
return
$options
;
return
$options
;
}
}
function
qa_admin_place_options
()
/**
/*
* Return an array of widget placement options, with keys matching the database value
Return an array of widget placement options, with keys matching the database value
*/
*/
function
qa_admin_place_options
()
{
{
return
array
(
return
array
(
'FT'
=>
qa_lang_html
(
'options/place_full_top'
),
'FT'
=>
qa_lang_html
(
'options/place_full_top'
),
'FH'
=>
qa_lang_html
(
'options/place_full_below_nav'
),
'FH'
=>
qa_lang_html
(
'options/place_full_below_nav'
),
...
@@ -179,14 +179,14 @@
...
@@ -179,14 +179,14 @@
'SL'
=>
qa_lang_html
(
'options/place_side_low'
),
'SL'
=>
qa_lang_html
(
'options/place_side_low'
),
'SB'
=>
qa_lang_html
(
'options/place_side_last'
),
'SB'
=>
qa_lang_html
(
'options/place_side_last'
),
);
);
}
}
function
qa_admin_page_size_options
(
$maximum
)
/**
/*
* Return an array of page size options up to $maximum, [page size] => [page size]
Return an array of page size options up to $maximum, [page size] => [page size]
*/
*/
function
qa_admin_page_size_options
(
$maximum
)
{
{
$rawoptions
=
array
(
5
,
10
,
15
,
20
,
25
,
30
,
40
,
50
,
60
,
80
,
100
,
120
,
150
,
200
,
250
,
300
,
400
,
500
,
600
,
800
,
1000
);
$rawoptions
=
array
(
5
,
10
,
15
,
20
,
25
,
30
,
40
,
50
,
60
,
80
,
100
,
120
,
150
,
200
,
250
,
300
,
400
,
500
,
600
,
800
,
1000
);
$options
=
array
();
$options
=
array
();
...
@@ -198,14 +198,14 @@
...
@@ -198,14 +198,14 @@
}
}
return
$options
;
return
$options
;
}
}
function
qa_admin_match_options
()
/**
/*
* Return an array of options representing matching precision, [value] => [label]
Return an array of options representing matching precision, [value] => [label]
*/
*/
function
qa_admin_match_options
()
{
{
return
array
(
return
array
(
5
=>
qa_lang_html
(
'options/match_5'
),
5
=>
qa_lang_html
(
'options/match_5'
),
4
=>
qa_lang_html
(
'options/match_4'
),
4
=>
qa_lang_html
(
'options/match_4'
),
...
@@ -213,15 +213,15 @@
...
@@ -213,15 +213,15 @@
2
=>
qa_lang_html
(
'options/match_2'
),
2
=>
qa_lang_html
(
'options/match_2'
),
1
=>
qa_lang_html
(
'options/match_1'
),
1
=>
qa_lang_html
(
'options/match_1'
),
);
);
}
}
function
qa_admin_permit_options
(
$widest
,
$narrowest
,
$doconfirms
=
true
,
$dopoints
=
true
)
/**
/*
* Return an array of options representing permission restrictions, [value] => [label]
Return an array of options representing permission restrictions, [value] => [label]
* ranging from $widest to $narrowest. Set $doconfirms to whether email confirmations are on
ranging from $widest to $narrowest. Set $doconfirms to whether email confirmations are on
*/
*/
function
qa_admin_permit_options
(
$widest
,
$narrowest
,
$doconfirms
=
true
,
$dopoints
=
true
)
{
{
require_once
QA_INCLUDE_DIR
.
'app/options.php'
;
require_once
QA_INCLUDE_DIR
.
'app/options.php'
;
$options
=
array
(
$options
=
array
(
...
@@ -260,14 +260,14 @@
...
@@ -260,14 +260,14 @@
}
}
return
$options
;
return
$options
;
}
}
function
qa_admin_sub_navigation
()
/**
/*
* Return the sub navigation structure common to admin pages
Return the sub navigation structure common to admin pages
*/
*/
function
qa_admin_sub_navigation
()
{
{
if
(
qa_to_override
(
__FUNCTION__
))
{
$args
=
func_get_args
();
return
qa_call_override
(
__FUNCTION__
,
$args
);
}
if
(
qa_to_override
(
__FUNCTION__
))
{
$args
=
func_get_args
();
return
qa_call_override
(
__FUNCTION__
,
$args
);
}
$navigation
=
array
();
$navigation
=
array
();
...
@@ -399,14 +399,14 @@
...
@@ -399,14 +399,14 @@
}
}
return
$navigation
;
return
$navigation
;
}
}
function
qa_admin_page_error
()
/**
/*
* Return the error that needs to displayed on all admin pages, or null if none
Return the error that needs to displayed on all admin pages, or null if none
*/
*/
function
qa_admin_page_error
()
{
{
if
(
file_exists
(
QA_INCLUDE_DIR
.
'db/install.php'
))
// file can be removed for extra security
if
(
file_exists
(
QA_INCLUDE_DIR
.
'db/install.php'
))
// file can be removed for extra security
include_once
QA_INCLUDE_DIR
.
'db/install.php'
;
include_once
QA_INCLUDE_DIR
.
'db/install.php'
;
...
@@ -425,23 +425,23 @@
...
@@ -425,23 +425,23 @@
else
else
return
null
;
return
null
;
}
}
function
qa_admin_url_test_html
()
/**
/*
* Return an HTML fragment to display for a URL test which has passed
Return an HTML fragment to display for a URL test which has passed
*/
*/
function
qa_admin_url_test_html
()
{
{
return
'; font-size:9px; color:#060; font-weight:bold; font-family:arial,sans-serif; border-color:#060;">OK<'
;
return
'; font-size:9px; color:#060; font-weight:bold; font-family:arial,sans-serif; border-color:#060;">OK<'
;
}
}
function
qa_admin_is_slug_reserved
(
$requestpart
)
/**
/*
* Returns whether a URL path beginning with $requestpart is reserved by the engine or a plugin page module
Returns whether a URL path beginning with $requestpart is reserved by the engine or a plugin page module
*/
*/
function
qa_admin_is_slug_reserved
(
$requestpart
)
{
{
$requestpart
=
trim
(
strtolower
(
$requestpart
));
$requestpart
=
trim
(
strtolower
(
$requestpart
));
$routing
=
qa_page_routing
();
$routing
=
qa_page_routing
();
...
@@ -471,15 +471,15 @@
...
@@ -471,15 +471,15 @@
return
true
;
return
true
;
return
false
;
return
false
;
}
}
function
qa_admin_single_click
(
$entityid
,
$action
)
/**
/*
* Returns true if admin (hidden/flagged/approve/moderate) page $action performed on $entityid is permitted by the
Returns true if admin (hidden/flagged/approve/moderate) page $action performed on $entityid is permitted by the
* logged in user and was processed successfully
logged in user and was processed successfully
*/
*/
function
qa_admin_single_click
(
$entityid
,
$action
)
{
{
$userid
=
qa_get_logged_in_userid
();
$userid
=
qa_get_logged_in_userid
();
if
(
(
!
QA_FINAL_EXTERNAL_USERS
)
&&
((
$action
==
'userapprove'
)
||
(
$action
==
'userblock'
))
)
{
// approve/block moderated users
if
(
(
!
QA_FINAL_EXTERNAL_USERS
)
&&
((
$action
==
'userapprove'
)
||
(
$action
==
'userblock'
))
)
{
// approve/block moderated users
...
@@ -561,14 +561,14 @@
...
@@ -561,14 +561,14 @@
}
}
return
false
;
return
false
;
}
}
function
qa_admin_check_clicks
()
/**
/*
* Checks for a POSTed click on an admin (hidden/flagged/approve/moderate) page, and refresh the page if processed successfully (non Ajax)
Checks for a POSTed click on an admin (hidden/flagged/approve/moderate) page, and refresh the page if processed successfully (non Ajax)
*/
*/
function
qa_admin_check_clicks
()
{
{
if
(
qa_is_http_post
())
if
(
qa_is_http_post
())
foreach
(
$_POST
as
$field
=>
$value
)
foreach
(
$_POST
as
$field
=>
$value
)
if
(
strpos
(
$field
,
'admin_'
)
===
0
)
{
if
(
strpos
(
$field
,
'admin_'
)
===
0
)
{
...
@@ -583,16 +583,16 @@
...
@@ -583,16 +583,16 @@
}
}
return
null
;
return
null
;
}
}
/**
/**
* Retrieve metadata information from the $contents of a qa-theme.php or qa-plugin.php file, mapping via $fields.
* Retrieve metadata information from the $contents of a qa-theme.php or qa-plugin.php file, mapping via $fields.
*
*
* @deprecated Deprecated from 1.7; use `qa_addon_metadata($contents, $type)` instead.
* @deprecated Deprecated from 1.7; use `qa_addon_metadata($contents, $type)` instead.
*/
*/
function
qa_admin_addon_metadata
(
$contents
,
$fields
)
function
qa_admin_addon_metadata
(
$contents
,
$fields
)
{
{
$metadata
=
array
();
$metadata
=
array
();
foreach
(
$fields
as
$key
=>
$field
)
foreach
(
$fields
as
$key
=>
$field
)
...
@@ -600,43 +600,38 @@
...
@@ -600,43 +600,38 @@
$metadata
[
$key
]
=
trim
(
$matches
[
1
]);
$metadata
[
$key
]
=
trim
(
$matches
[
1
]);
return
$metadata
;
return
$metadata
;
}
}
/**
/**
* Return the hash code for the plugin in $directory (without trailing slash), used for in-page navigation on admin/plugins page
* Return the hash code for the plugin in $directory (without trailing slash), used for in-page navigation on admin/plugins page
*/
*/
function
qa_admin_plugin_directory_hash
(
$directory
)
function
qa_admin_plugin_directory_hash
(
$directory
)
{
{
$pluginManager
=
new
Q2A_Plugin_PluginManager
();
$pluginManager
=
new
Q2A_Plugin_PluginManager
();
$hashes
=
$pluginManager
->
getHashesForPlugins
(
array
(
$directory
));
$hashes
=
$pluginManager
->
getHashesForPlugins
(
array
(
$directory
));
return
reset
(
$hashes
);
return
reset
(
$hashes
);
}
}
/**
/**
* Return the URL (relative to the current page) to navigate to the options panel for the plugin in $directory (without trailing slash)
* Return the URL (relative to the current page) to navigate to the options panel for the plugin in $directory (without trailing slash)
*/
*/
function
qa_admin_plugin_options_path
(
$directory
)
function
qa_admin_plugin_options_path
(
$directory
)
{
{
$hash
=
qa_admin_plugin_directory_hash
(
$directory
);
$hash
=
qa_admin_plugin_directory_hash
(
$directory
);
return
qa_path_html
(
'admin/plugins'
,
array
(
'show'
=>
$hash
),
null
,
null
,
$hash
);
return
qa_path_html
(
'admin/plugins'
,
array
(
'show'
=>
$hash
),
null
,
null
,
$hash
);
}
}
/**
/**
* Return the URL (relative to the current page) to navigate to the options panel for plugin module $name of $type
* Return the URL (relative to the current page) to navigate to the options panel for plugin module $name of $type
*/
*/
function
qa_admin_module_options_path
(
$type
,
$name
)
function
qa_admin_module_options_path
(
$type
,
$name
)
{
{
$info
=
qa_get_module_info
(
$type
,
$name
);
$info
=
qa_get_module_info
(
$type
,
$name
);
$dir
=
rtrim
(
$info
[
'directory'
],
'/'
);
$dir
=
rtrim
(
$info
[
'directory'
],
'/'
);
return
qa_admin_plugin_options_path
(
$dir
);
return
qa_admin_plugin_options_path
(
$dir
);
}
}
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
qa-include/app/post-create.php
View file @
f24542bb
This diff is collapsed.
Click to expand it.
qa-include/app/post-update.php
View file @
f24542bb
This diff is collapsed.
Click to expand it.
qa-include/app/recalc.php
View file @
f24542bb
...
@@ -56,28 +56,28 @@
...
@@ -56,28 +56,28 @@
[but these are not entirely redundant since they can contain historical information no longer in ^posts]
[but these are not entirely redundant since they can contain historical information no longer in ^posts]
*/
*/
if
(
!
defined
(
'QA_VERSION'
))
{
// don't allow this page to be requested directly from browser
if
(
!
defined
(
'QA_VERSION'
))
{
// don't allow this page to be requested directly from browser
header
(
'Location: ../'
);
header
(
'Location: ../'
);
exit
;
exit
;
}
}
require_once
QA_INCLUDE_DIR
.
'db/recalc.php'
;
require_once
QA_INCLUDE_DIR
.
'db/recalc.php'
;
require_once
QA_INCLUDE_DIR
.
'db/post-create.php'
;
require_once
QA_INCLUDE_DIR
.
'db/post-create.php'
;
require_once
QA_INCLUDE_DIR
.
'db/points.php'
;
require_once
QA_INCLUDE_DIR
.
'db/points.php'
;
require_once
QA_INCLUDE_DIR
.
'db/selects.php'
;
require_once
QA_INCLUDE_DIR
.
'db/selects.php'
;
require_once
QA_INCLUDE_DIR
.
'db/admin.php'
;
require_once
QA_INCLUDE_DIR
.
'db/admin.php'
;
require_once
QA_INCLUDE_DIR
.
'db/users.php'
;
require_once
QA_INCLUDE_DIR
.
'db/users.php'
;
require_once
QA_INCLUDE_DIR
.
'app/options.php'
;
require_once
QA_INCLUDE_DIR
.
'app/options.php'
;
require_once
QA_INCLUDE_DIR
.
'app/post-create.php'
;
require_once
QA_INCLUDE_DIR
.
'app/post-create.php'
;
require_once
QA_INCLUDE_DIR
.
'app/post-update.php'
;
require_once
QA_INCLUDE_DIR
.
'app/post-update.php'
;
function
qa_recalc_perform_step
(
&
$state
)
/**
/*
* Advance the recalculation operation represented by $state by a single step.
Advance the recalculation operation represented by $state by a single step
.
* $state can also be the name of a recalculation operation on its own
.
$state can also be the name of a recalculation operation on its own.
*/
*/
function
qa_recalc_perform_step
(
&
$state
)
{
{
$continue
=
false
;
$continue
=
false
;
@
list
(
$operation
,
$length
,
$next
,
$done
)
=
explode
(
"
\t
"
,
$state
);
@
list
(
$operation
,
$length
,
$next
,
$done
)
=
explode
(
"
\t
"
,
$state
);
...
@@ -528,27 +528,27 @@
...
@@ -528,27 +528,27 @@
$state
=
$operation
.
"
\t
"
.
$length
.
"
\t
"
.
$next
.
"
\t
"
.
$done
;
$state
=
$operation
.
"
\t
"
.
$length
.
"
\t
"
.
$next
.
"
\t
"
.
$done
;
return
$continue
&&
(
$done
<
$length
);
return
$continue
&&
(
$done
<
$length
);
}
}
function
qa_recalc_transition
(
&
$state
,
$operation
)
/**
/*
* Change the $state to represent the beginning of a new $operation
Change the $state to represent the beginning of a new $operation
*/
*/
function
qa_recalc_transition
(
&
$state
,
$operation
)
{
{
$length
=
qa_recalc_stage_length
(
$operation
);
$length
=
qa_recalc_stage_length
(
$operation
);
$next
=
(
QA_FINAL_EXTERNAL_USERS
&&
(
$operation
==
'dorecalcpoints_recalc'
))
?
''
:
0
;
$next
=
(
QA_FINAL_EXTERNAL_USERS
&&
(
$operation
==
'dorecalcpoints_recalc'
))
?
''
:
0
;
$done
=
0
;
$done
=
0
;
$state
=
$operation
.
"
\t
"
.
$length
.
"
\t
"
.
$next
.
"
\t
"
.
$done
;
$state
=
$operation
.
"
\t
"
.
$length
.
"
\t
"
.
$next
.
"
\t
"
.
$done
;
}
}
function
qa_recalc_stage_length
(
$operation
)
/**
/*
* Return how many steps there will be in recalculation $operation
Return how many steps there will be in recalculation $operation
*/
*/
function
qa_recalc_stage_length
(
$operation
)
{
{
switch
(
$operation
)
{
switch
(
$operation
)
{
case
'doreindexcontent_pagereindex'
:
case
'doreindexcontent_pagereindex'
:
$length
=
qa_db_count_pages
();
$length
=
qa_db_count_pages
();
...
@@ -607,10 +607,10 @@
...
@@ -607,10 +607,10 @@
}
}
return
$length
;
return
$length
;
}
}
/**
/**
* Return the translated language ID string replacing the progress and total in it.
* Return the translated language ID string replacing the progress and total in it.
* @access private
* @access private
* @param string $langId Language string ID that contains 2 placeholders (^1 and ^2)
* @param string $langId Language string ID that contains 2 placeholders (^1 and ^2)
...
@@ -620,20 +620,20 @@
...
@@ -620,20 +620,20 @@
* @return string Returns the language string ID with their placeholders replaced with
* @return string Returns the language string ID with their placeholders replaced with
* the formatted progress and total numbers
* the formatted progress and total numbers
*/
*/
function
qa_recalc_progress_lang
(
$langId
,
$progress
,
$total
)
function
qa_recalc_progress_lang
(
$langId
,
$progress
,
$total
)
{
{
return
strtr
(
qa_lang
(
$langId
),
array
(
return
strtr
(
qa_lang
(
$langId
),
array
(
'^1'
=>
qa_format_number
(
$progress
),
'^1'
=>
qa_format_number
(
$progress
),
'^2'
=>
qa_format_number
(
$total
)
'^2'
=>
qa_format_number
(
$total
)
));
));
}
}
function
qa_recalc_get_message
(
$state
)
/**
/*
* Return a string which gives a user-viewable version of $state
Return a string which gives a user-viewable version of $state
*/
*/
function
qa_recalc_get_message
(
$state
)
{
{
require_once
QA_INCLUDE_DIR
.
'app/format.php'
;
require_once
QA_INCLUDE_DIR
.
'app/format.php'
;
@
list
(
$operation
,
$length
,
$next
,
$done
)
=
explode
(
"
\t
"
,
$state
);
@
list
(
$operation
,
$length
,
$next
,
$done
)
=
explode
(
"
\t
"
,
$state
);
...
@@ -745,9 +745,4 @@
...
@@ -745,9 +745,4 @@
}
}
return
$message
;
return
$message
;
}
}
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
qa-include/app/users.php
View file @
f24542bb
This diff is collapsed.
Click to expand it.
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