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
14d54fd4
Commit
14d54fd4
authored
Jul 15, 2016
by
Scott
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Coding style (admin pages)
parent
2be2b6bb
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
2321 additions
and
2363 deletions
+2321
-2363
admin-approve.php
qa-include/pages/admin/admin-approve.php
+69
-72
admin-categories.php
qa-include/pages/admin/admin-categories.php
+454
-451
admin-flagged.php
qa-include/pages/admin/admin-flagged.php
+70
-73
admin-hidden.php
qa-include/pages/admin/admin-hidden.php
+105
-105
admin-moderate.php
qa-include/pages/admin/admin-moderate.php
+98
-102
admin-pages.php
qa-include/pages/admin/admin-pages.php
+424
-430
admin-plugins.php
qa-include/pages/admin/admin-plugins.php
+142
-150
admin-points.php
qa-include/pages/admin/admin-points.php
+113
-119
admin-recalc.php
qa-include/pages/admin/admin-recalc.php
+79
-84
admin-stats.php
qa-include/pages/admin/admin-stats.php
+236
-239
admin-userfields.php
qa-include/pages/admin/admin-userfields.php
+176
-179
admin-usertitles.php
qa-include/pages/admin/admin-usertitles.php
+105
-110
admin-widgets.php
qa-include/pages/admin/admin-widgets.php
+250
-249
No files found.
qa-include/pages/admin/admin-approve.php
View file @
14d54fd4
...
@@ -20,121 +20,118 @@
...
@@ -20,121 +20,118 @@
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
;
}
}
require_once
QA_INCLUDE_DIR
.
'app/admin.php'
;
require_once
QA_INCLUDE_DIR
.
'app/admin.php'
;
require_once
QA_INCLUDE_DIR
.
'db/admin.php'
;
require_once
QA_INCLUDE_DIR
.
'db/admin.php'
;
// Check we're not using single-sign on integration
// Check we're not using single-sign on integration
if
(
QA_FINAL_EXTERNAL_USERS
)
if
(
QA_FINAL_EXTERNAL_USERS
)
qa_fatal_error
(
'User accounts are handled by external code'
);
qa_fatal_error
(
'User accounts are handled by external code'
);
// Find most flagged questions, answers, comments
// Find most flagged questions, answers, comments
$userid
=
qa_get_logged_in_userid
();
$userid
=
qa_get_logged_in_userid
();
$users
=
qa_db_get_unapproved_users
(
qa_opt
(
'page_size_users'
));
$users
=
qa_db_get_unapproved_users
(
qa_opt
(
'page_size_users'
));
$userfields
=
qa_db_select_with_pending
(
qa_db_userfields_selectspec
());
$userfields
=
qa_db_select_with_pending
(
qa_db_userfields_selectspec
());
// Check admin privileges (do late to allow one DB query)
// Check admin privileges (do late to allow one DB query)
if
(
qa_get_logged_in_level
()
<
QA_USER_LEVEL_MODERATOR
)
{
if
(
qa_get_logged_in_level
()
<
QA_USER_LEVEL_MODERATOR
)
{
$qa_content
=
qa_content_prepare
();
$qa_content
=
qa_content_prepare
();
$qa_content
[
'error'
]
=
qa_lang_html
(
'users/no_permission'
);
$qa_content
[
'error'
]
=
qa_lang_html
(
'users/no_permission'
);
return
$qa_content
;
return
$qa_content
;
}
}
// Check to see if any were approved or blocked here
// Check to see if any were approved or blocked here
$pageerror
=
qa_admin_check_clicks
();
$pageerror
=
qa_admin_check_clicks
();
// Prepare content for theme
// Prepare content for theme
$qa_content
=
qa_content_prepare
();
$qa_content
=
qa_content_prepare
();
$qa_content
[
'title'
]
=
qa_lang_html
(
'admin/approve_users_title'
);
$qa_content
[
'title'
]
=
qa_lang_html
(
'admin/approve_users_title'
);
$qa_content
[
'error'
]
=
isset
(
$pageerror
)
?
$pageerror
:
qa_admin_page_error
();
$qa_content
[
'error'
]
=
isset
(
$pageerror
)
?
$pageerror
:
qa_admin_page_error
();
$qa_content
[
'message_list'
]
=
array
(
$qa_content
[
'message_list'
]
=
array
(
'form'
=>
array
(
'form'
=>
array
(
'tags'
=>
'method="post" action="'
.
qa_self_html
()
.
'"'
,
'tags'
=>
'method="post" action="'
.
qa_self_html
()
.
'"'
,
'hidden'
=>
array
(
'hidden'
=>
array
(
'code'
=>
qa_get_form_security_code
(
'admin/click'
),
'code'
=>
qa_get_form_security_code
(
'admin/click'
),
),
),
),
),
'messages'
=>
array
(),
'messages'
=>
array
(),
);
);
if
(
count
(
$users
))
{
if
(
count
(
$users
))
{
foreach
(
$users
as
$user
)
{
foreach
(
$users
as
$user
)
{
$message
=
array
();
$message
=
array
();
$message
[
'tags'
]
=
'id="p'
.
qa_html
(
$user
[
'userid'
])
.
'"'
;
// use p prefix for qa_admin_click() in qa-admin.js
$message
[
'tags'
]
=
'id="p'
.
qa_html
(
$user
[
'userid'
])
.
'"'
;
// use p prefix for qa_admin_click() in qa-admin.js
$message
[
'content'
]
=
qa_lang_html
(
'users/registered_label'
)
.
' '
.
$message
[
'content'
]
=
qa_lang_html
(
'users/registered_label'
)
.
' '
.
strtr
(
qa_lang_html
(
'users/x_ago_from_y'
),
array
(
strtr
(
qa_lang_html
(
'users/x_ago_from_y'
),
array
(
'^1'
=>
qa_time_to_string
(
qa_opt
(
'db_time'
)
-
$user
[
'created'
]),
'^1'
=>
qa_time_to_string
(
qa_opt
(
'db_time'
)
-
$user
[
'created'
]),
'^2'
=>
qa_ip_anchor_html
(
@
inet_ntop
(
$user
[
'createip'
])),
'^2'
=>
qa_ip_anchor_html
(
@
inet_ntop
(
$user
[
'createip'
])),
))
.
'<br/>'
;
))
.
'<br/>'
;
$htmlemail
=
qa_html
(
$user
[
'email'
]);
$htmlemail
=
qa_html
(
$user
[
'email'
]);
$message
[
'content'
]
.=
qa_lang_html
(
'users/email_label'
)
.
' <a href="mailto:'
.
$htmlemail
.
'">'
.
$htmlemail
.
'</a>'
;
$message
[
'content'
]
.=
qa_lang_html
(
'users/email_label'
)
.
' <a href="mailto:'
.
$htmlemail
.
'">'
.
$htmlemail
.
'</a>'
;
if
(
qa_opt
(
'confirm_user_emails'
))
if
(
qa_opt
(
'confirm_user_emails'
))
{
$message
[
'content'
]
.=
'<small> - '
.
qa_lang_html
((
$user
[
'flags'
]
&
QA_USER_FLAGS_EMAIL_CONFIRMED
)
?
'users/email_confirmed'
:
'users/email_not_confirmed'
)
.
'</small>'
;
$message
[
'content'
]
.=
'<small> - '
.
qa_lang_html
((
$user
[
'flags'
]
&
QA_USER_FLAGS_EMAIL_CONFIRMED
)
?
'users/email_confirmed'
:
'users/email_not_confirmed'
)
.
'</small>'
;
}
foreach
(
$userfields
as
$userfield
)
if
(
strlen
(
@
$user
[
'profile'
][
$userfield
[
'title'
]]))
$message
[
'content'
]
.=
'<br/>'
.
qa_html
(
$userfield
[
'content'
]
.
': '
.
$user
[
'profile'
][
$userfield
[
'title'
]]);
$message
[
'meta_order'
]
=
qa_lang_html
(
'main/meta_order'
);
foreach
(
$userfields
as
$userfield
)
{
$message
[
'who'
][
'data'
]
=
qa_get_one_user_html
(
$user
[
'handle'
]);
if
(
strlen
(
@
$user
[
'profile'
][
$userfield
[
'title'
]]))
$message
[
'content'
]
.=
'<br/>'
.
qa_html
(
$userfield
[
'content'
]
.
': '
.
$user
[
'profile'
][
$userfield
[
'title'
]]);
}
$message
[
'form'
]
=
array
(
$message
[
'meta_order'
]
=
qa_lang_html
(
'main/meta_order'
);
'style'
=>
'light'
,
$message
[
'who'
][
'data'
]
=
qa_get_one_user_html
(
$user
[
'handle'
]);
'buttons'
=>
array
(
$message
[
'form'
]
=
array
(
'approve'
=>
array
(
'style'
=>
'light'
,
'tags'
=>
'name="admin_'
.
$user
[
'userid'
]
.
'_userapprove" onclick="return qa_admin_click(this);"'
,
'label'
=>
qa_lang_html
(
'question/approve_button'
),
'popup'
=>
qa_lang_html
(
'admin/approve_user_popup'
),
),
'block
'
=>
array
(
'buttons
'
=>
array
(
'tags'
=>
'name="admin_'
.
$user
[
'userid'
]
.
'_userblock" onclick="return qa_admin_click(this);"'
,
'approve'
=>
array
(
'label'
=>
qa_lang_html
(
'admin/block_button'
)
,
'tags'
=>
'name="admin_'
.
$user
[
'userid'
]
.
'_userapprove" onclick="return qa_admin_click(this);"'
,
'popup'
=>
qa_lang_html
(
'admin/block_user_popup
'
),
'label'
=>
qa_lang_html
(
'question/approve_button
'
),
),
'popup'
=>
qa_lang_html
(
'admin/approve_user_popup'
),
),
),
);
$qa_content
[
'message_list'
][
'messages'
][]
=
$message
;
'block'
=>
array
(
}
'tags'
=>
'name="admin_'
.
$user
[
'userid'
]
.
'_userblock" onclick="return qa_admin_click(this);"'
,
'label'
=>
qa_lang_html
(
'admin/block_button'
),
'popup'
=>
qa_lang_html
(
'admin/block_user_popup'
),
),
),
);
}
else
$qa_content
[
'message_list'
][
'messages'
][]
=
$message
;
$qa_content
[
'title'
]
=
qa_lang_html
(
'admin/no_unapproved_found'
);
}
}
else
$qa_content
[
'title'
]
=
qa_lang_html
(
'admin/no_unapproved_found'
);
$qa_content
[
'navigation'
][
'sub'
]
=
qa_admin_sub_navigation
();
$qa_content
[
'script_rel'
][]
=
'qa-content/qa-admin.js?'
.
QA_VERSION
;
$qa_content
[
'navigation'
][
'sub'
]
=
qa_admin_sub_navigation
();
$qa_content
[
'script_rel'
][]
=
'qa-content/qa-admin.js?'
.
QA_VERSION
;
return
$qa_content
;
return
$qa_content
;
/*
Omit PHP closing tag to help avoid accidental output
*/
qa-include/pages/admin/admin-categories.php
View file @
14d54fd4
...
@@ -20,610 +20,614 @@
...
@@ -20,610 +20,614 @@
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
;
}
}
require_once
QA_INCLUDE_DIR
.
'app/admin.php'
;
require_once
QA_INCLUDE_DIR
.
'app/admin.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
.
'app/format.php'
;
require_once
QA_INCLUDE_DIR
.
'app/format.php'
;
// Get relevant list of categories
// Get relevant list of categories
$editcategoryid
=
qa_post_text
(
'edit'
);
$editcategoryid
=
qa_post_text
(
'edit'
);
if
(
!
isset
(
$editcategoryid
))
if
(
!
isset
(
$editcategoryid
))
$editcategoryid
=
qa_get
(
'edit'
);
$editcategoryid
=
qa_get
(
'edit'
);
if
(
!
isset
(
$editcategoryid
))
if
(
!
isset
(
$editcategoryid
))
$editcategoryid
=
qa_get
(
'addsub'
);
$editcategoryid
=
qa_get
(
'addsub'
);
$categories
=
qa_db_select_with_pending
(
qa_db_category_nav_selectspec
(
$editcategoryid
,
true
,
false
,
true
));
$categories
=
qa_db_select_with_pending
(
qa_db_category_nav_selectspec
(
$editcategoryid
,
true
,
false
,
true
));
// Check admin privileges (do late to allow one DB query)
// Check admin privileges (do late to allow one DB query)
if
(
!
qa_admin_check_privileges
(
$qa_content
))
if
(
!
qa_admin_check_privileges
(
$qa_content
))
return
$qa_content
;
return
$qa_content
;
// Work out the appropriate state for the page
// Work out the appropriate state for the page
$editcategory
=
@
$categories
[
$editcategoryid
];
$editcategory
=
@
$categories
[
$editcategoryid
];
if
(
isset
(
$editcategory
))
{
if
(
isset
(
$editcategory
))
{
$parentid
=
qa_get
(
'addsub'
);
$parentid
=
qa_get
(
'addsub'
);
if
(
isset
(
$parentid
))
if
(
isset
(
$parentid
))
$editcategory
=
array
(
'parentid'
=>
$parentid
);
$editcategory
=
array
(
'parentid'
=>
$parentid
);
}
else
{
}
else
{
if
(
qa_clicked
(
'doaddcategory'
))
if
(
qa_clicked
(
'doaddcategory'
))
$editcategory
=
array
();
$editcategory
=
array
();
elseif
(
qa_clicked
(
'dosavecategory'
))
{
elseif
(
qa_clicked
(
'dosavecategory'
))
{
$parentid
=
qa_post_text
(
'parent'
);
$parentid
=
qa_post_text
(
'parent'
);
$editcategory
=
array
(
'parentid'
=>
strlen
(
$parentid
)
?
$parentid
:
null
);
$editcategory
=
array
(
'parentid'
=>
strlen
(
$parentid
)
?
$parentid
:
null
);
}
}
}
}
$setmissing
=
qa_post_text
(
'missing'
)
||
qa_get
(
'missing'
);
$setmissing
=
qa_post_text
(
'missing'
)
||
qa_get
(
'missing'
);
$setparent
=
(
!
$setmissing
)
&&
(
qa_post_text
(
'setparent'
)
||
qa_get
(
'setparent'
))
&&
isset
(
$editcategory
[
'categoryid'
]);
$setparent
=
!
$setmissing
&&
(
qa_post_text
(
'setparent'
)
||
qa_get
(
'setparent'
))
&&
isset
(
$editcategory
[
'categoryid'
]);
$hassubcategory
=
false
;
$hassubcategory
=
false
;
foreach
(
$categories
as
$category
)
foreach
(
$categories
as
$category
)
{
if
(
!
strcmp
(
$category
[
'parentid'
],
$editcategoryid
))
if
(
!
strcmp
(
$category
[
'parentid'
],
$editcategoryid
))
$hassubcategory
=
true
;
$hassubcategory
=
true
;
}
// Process saving options
// Process saving options
$savedoptions
=
false
;
$savedoptions
=
false
;
$securityexpired
=
false
;
$securityexpired
=
false
;
if
(
qa_clicked
(
'dosaveoptions'
))
{
if
(
qa_clicked
(
'dosaveoptions'
))
{
if
(
!
qa_check_form_security_code
(
'admin/categories'
,
qa_post_text
(
'code'
)))
if
(
!
qa_check_form_security_code
(
'admin/categories'
,
qa_post_text
(
'code'
)))
$securityexpired
=
true
;
$securityexpired
=
true
;
else
{
else
{
qa_set_option
(
'allow_no_category'
,
(
int
)
qa_post_text
(
'option_allow_no_category'
));
qa_set_option
(
'allow_no_category'
,
(
int
)
qa_post_text
(
'option_allow_no_category'
));
qa_set_option
(
'allow_no_sub_category'
,
(
int
)
qa_post_text
(
'option_allow_no_sub_category'
));
qa_set_option
(
'allow_no_sub_category'
,
(
int
)
qa_post_text
(
'option_allow_no_sub_category'
));
$savedoptions
=
true
;
$savedoptions
=
true
;
}
}
}
}
// Process saving an old or new category
// Process saving an old or new category
if
(
qa_clicked
(
'docancel'
))
{
if
(
qa_clicked
(
'docancel'
))
{
if
(
$setmissing
||
$setparent
)
if
(
$setmissing
||
$setparent
)
qa_redirect
(
qa_request
(),
array
(
'edit'
=>
$editcategory
[
'categoryid'
]));
qa_redirect
(
qa_request
(),
array
(
'edit'
=>
$editcategory
[
'categoryid'
]));
elseif
(
isset
(
$editcategory
[
'categoryid'
]))
elseif
(
isset
(
$editcategory
[
'categoryid'
]))
qa_redirect
(
qa_request
());
qa_redirect
(
qa_request
());
else
else
qa_redirect
(
qa_request
(),
array
(
'edit'
=>
@
$editcategory
[
'parentid'
]));
qa_redirect
(
qa_request
(),
array
(
'edit'
=>
@
$editcategory
[
'parentid'
]));
}
elseif
(
qa_clicked
(
'dosetmissing'
))
{
if
(
!
qa_check_form_security_code
(
'admin/categories'
,
qa_post_text
(
'code'
)))
$securityexpired
=
true
;
else
{
$inreassign
=
qa_get_category_field_value
(
'reassign'
);
qa_db_category_reassign
(
$editcategory
[
'categoryid'
],
$inreassign
);
qa_redirect
(
qa_request
(),
array
(
'recalc'
=>
1
,
'edit'
=>
$editcategory
[
'categoryid'
]));
}
}
elseif
(
qa_clicked
(
'dosetmissing
'
))
{
}
elseif
(
qa_clicked
(
'dosavecategory
'
))
{
if
(
!
qa_check_form_security_code
(
'admin/categories'
,
qa_post_text
(
'code'
)))
if
(
!
qa_check_form_security_code
(
'admin/categories'
,
qa_post_text
(
'code'
)))
$securityexpired
=
true
;
$securityexpired
=
true
;
else
{
elseif
(
qa_post_text
(
'dodelete'
))
{
$inreassign
=
qa_get_category_field_value
(
'reassign'
);
if
(
!
$hassubcategory
)
{
$inreassign
=
qa_get_category_field_value
(
'reassign'
);
qa_db_category_reassign
(
$editcategory
[
'categoryid'
],
$inreassign
);
qa_db_category_reassign
(
$editcategory
[
'categoryid'
],
$inreassign
);
qa_redirect
(
qa_request
(),
array
(
'recalc'
=>
1
,
'edit'
=>
$editcategory
[
'categoryid'
]));
qa_db_category_delete
(
$editcategory
[
'categoryid'
]);
qa_redirect
(
qa_request
(),
array
(
'recalc'
=>
1
,
'edit'
=>
$editcategory
[
'parentid'
]));
}
}
}
elseif
(
qa_clicked
(
'dosavecategory'
))
{
}
else
{
if
(
!
qa_check_form_security_code
(
'admin/categories'
,
qa_post_text
(
'code'
)))
require_once
QA_INCLUDE_DIR
.
'util/string.php'
;
$securityexpired
=
true
;
elseif
(
qa_post_text
(
'dodelete'
))
{
if
(
!
$hassubcategory
)
{
$inreassign
=
qa_get_category_field_value
(
'reassign'
);
qa_db_category_reassign
(
$editcategory
[
'categoryid'
],
$inreassign
);
qa_db_category_delete
(
$editcategory
[
'categoryid'
]);
qa_redirect
(
qa_request
(),
array
(
'recalc'
=>
1
,
'edit'
=>
$editcategory
[
'parentid'
]));
}
}
else
{
require_once
QA_INCLUDE_DIR
.
'util/string.php'
;
$inname
=
qa_post_text
(
'name'
);
$inname
=
qa_post_text
(
'name'
);
$incontent
=
qa_post_text
(
'content'
);
$incontent
=
qa_post_text
(
'content'
);
$inparentid
=
$setparent
?
qa_get_category_field_value
(
'parent'
)
:
$editcategory
[
'parentid'
];
$inparentid
=
$setparent
?
qa_get_category_field_value
(
'parent'
)
:
$editcategory
[
'parentid'
];
$inposition
=
qa_post_text
(
'position'
);
$inposition
=
qa_post_text
(
'position'
);
$errors
=
array
();
$errors
=
array
();
// Check the parent ID
// Check the parent ID
$incategories
=
qa_db_select_with_pending
(
qa_db_category_nav_selectspec
(
$inparentid
,
true
));
$incategories
=
qa_db_select_with_pending
(
qa_db_category_nav_selectspec
(
$inparentid
,
true
));
// Verify the name is legitimate for that parent ID
// Verify the name is legitimate for that parent ID
if
(
empty
(
$inname
))
if
(
empty
(
$inname
))
$errors
[
'name'
]
=
qa_lang
(
'main/field_required'
);
$errors
[
'name'
]
=
qa_lang
(
'main/field_required'
);
elseif
(
qa_strlen
(
$inname
)
>
QA_DB_MAX_CAT_PAGE_TITLE_LENGTH
)
elseif
(
qa_strlen
(
$inname
)
>
QA_DB_MAX_CAT_PAGE_TITLE_LENGTH
)
$errors
[
'name'
]
=
qa_lang_sub
(
'main/max_length_x'
,
QA_DB_MAX_CAT_PAGE_TITLE_LENGTH
);
$errors
[
'name'
]
=
qa_lang_sub
(
'main/max_length_x'
,
QA_DB_MAX_CAT_PAGE_TITLE_LENGTH
);
else
{
else
{
foreach
(
$incategories
as
$category
)
foreach
(
$incategories
as
$category
)
{
if
(
if
(
(
!
strcmp
(
$category
[
'parentid'
],
$inparentid
))
&&
!
strcmp
(
$category
[
'parentid'
],
$inparentid
)
&&
strcmp
(
$category
[
'categoryid'
],
@
$editcategory
[
'categoryid'
])
&&
strcmp
(
$category
[
'categoryid'
],
@
$editcategory
[
'categoryid'
])
&&
qa_strtolower
(
$category
[
'title'
])
==
qa_strtolower
(
$inname
)
qa_strtolower
(
$category
[
'title'
])
==
qa_strtolower
(
$inname
)
)
)
{
$errors
[
'name'
]
=
qa_lang
(
'admin/category_already_used'
);
$errors
[
'name'
]
=
qa_lang
(
'admin/category_already_used'
);
}
}
}
}
// Verify the slug is legitimate for that parent ID
// Verify the slug is legitimate for that parent ID
for
(
$attempt
=
0
;
$attempt
<
100
;
$attempt
++
)
{
for
(
$attempt
=
0
;
$attempt
<
100
;
$attempt
++
)
{
switch
(
$attempt
)
{
switch
(
$attempt
)
{
case
0
:
case
0
:
$inslug
=
qa_post_text
(
'slug'
);
$inslug
=
qa_post_text
(
'slug'
);
if
(
!
isset
(
$inslug
))
if
(
!
isset
(
$inslug
))
$inslug
=
implode
(
'-'
,
qa_string_to_words
(
$inname
));
$inslug
=
implode
(
'-'
,
qa_string_to_words
(
$inname
));
break
;
break
;
case
1
:
$inslug
=
qa_lang_sub
(
'admin/category_default_slug'
,
$inslug
);
break
;
default
:
$inslug
=
qa_lang_sub
(
'admin/category_default_slug'
,
$attempt
-
1
);
break
;
}
$matchcategoryid
=
qa_db_category_slug_to_id
(
$inparentid
,
$inslug
);
// query against DB since MySQL ignores accents, etc...
if
(
!
isset
(
$inparentid
))
case
1
:
$matchpage
=
qa_db_single_select
(
qa_db_page_full_selectspec
(
$inslug
,
false
));
$inslug
=
qa_lang_sub
(
'admin/category_default_slug'
,
$inslug
);
else
break
;
$matchpage
=
null
;
if
(
empty
(
$inslug
))
$errors
[
'slug'
]
=
qa_lang
(
'main/field_required'
);
elseif
(
qa_strlen
(
$inslug
)
>
QA_DB_MAX_CAT_PAGE_TAGS_LENGTH
)
$errors
[
'slug'
]
=
qa_lang_sub
(
'main/max_length_x'
,
QA_DB_MAX_CAT_PAGE_TAGS_LENGTH
);
elseif
(
preg_match
(
'/[\\+\\/]/'
,
$inslug
))
$errors
[
'slug'
]
=
qa_lang_sub
(
'admin/slug_bad_chars'
,
'+ /'
);
elseif
(
(
!
isset
(
$inparentid
))
&&
qa_admin_is_slug_reserved
(
$inslug
))
// only top level is a problem
$errors
[
'slug'
]
=
qa_lang
(
'admin/slug_reserved'
);
elseif
(
isset
(
$matchcategoryid
)
&&
strcmp
(
$matchcategoryid
,
@
$editcategory
[
'categoryid'
]))
$errors
[
'slug'
]
=
qa_lang
(
'admin/category_already_used'
);
elseif
(
isset
(
$matchpage
))
$errors
[
'slug'
]
=
qa_lang
(
'admin/page_already_used'
);
else
unset
(
$errors
[
'slug'
]);
if
(
isset
(
$editcategory
[
'categoryid'
])
||
!
isset
(
$errors
[
'slug'
]))
// don't try other options if editing existing category
default
:
$inslug
=
qa_lang_sub
(
'admin/category_default_slug'
,
$attempt
-
1
);
break
;
break
;
}
}
$matchcategoryid
=
qa_db_category_slug_to_id
(
$inparentid
,
$inslug
);
// query against DB since MySQL ignores accents, etc...
if
(
!
isset
(
$inparentid
))
$matchpage
=
qa_db_single_select
(
qa_db_page_full_selectspec
(
$inslug
,
false
));
else
$matchpage
=
null
;
if
(
empty
(
$inslug
))
$errors
[
'slug'
]
=
qa_lang
(
'main/field_required'
);
elseif
(
qa_strlen
(
$inslug
)
>
QA_DB_MAX_CAT_PAGE_TAGS_LENGTH
)
$errors
[
'slug'
]
=
qa_lang_sub
(
'main/max_length_x'
,
QA_DB_MAX_CAT_PAGE_TAGS_LENGTH
);
elseif
(
preg_match
(
'/[\\+\\/]/'
,
$inslug
))
$errors
[
'slug'
]
=
qa_lang_sub
(
'admin/slug_bad_chars'
,
'+ /'
);
elseif
((
!
isset
(
$inparentid
))
&&
qa_admin_is_slug_reserved
(
$inslug
))
// only top level is a problem
$errors
[
'slug'
]
=
qa_lang
(
'admin/slug_reserved'
);
elseif
(
isset
(
$matchcategoryid
)
&&
strcmp
(
$matchcategoryid
,
@
$editcategory
[
'categoryid'
]))
$errors
[
'slug'
]
=
qa_lang
(
'admin/category_already_used'
);
elseif
(
isset
(
$matchpage
))
$errors
[
'slug'
]
=
qa_lang
(
'admin/page_already_used'
);
else
unset
(
$errors
[
'slug'
]);
if
(
isset
(
$editcategory
[
'categoryid'
])
||
!
isset
(
$errors
[
'slug'
]))
// don't try other options if editing existing category
break
;
}
// Perform appropriate database action
// Perform appropriate database action
if
(
empty
(
$errors
))
{
if
(
empty
(
$errors
))
{
if
(
isset
(
$editcategory
[
'categoryid'
]))
{
// changing existing category
if
(
isset
(
$editcategory
[
'categoryid'
]))
{
// changing existing category
qa_db_category_rename
(
$editcategory
[
'categoryid'
],
$inname
,
$inslug
);
qa_db_category_rename
(
$editcategory
[
'categoryid'
],
$inname
,
$inslug
);
$recalc
=
false
;
$recalc
=
false
;
if
(
$setparent
)
{
if
(
$setparent
)
{
qa_db_category_set_parent
(
$editcategory
[
'categoryid'
],
$inparentid
);
qa_db_category_set_parent
(
$editcategory
[
'categoryid'
],
$inparentid
);
$recalc
=
true
;
$recalc
=
true
;
}
else
{
}
else
{
qa_db_category_set_content
(
$editcategory
[
'categoryid'
],
$incontent
);
qa_db_category_set_content
(
$editcategory
[
'categoryid'
],
$incontent
);
qa_db_category_set_position
(
$editcategory
[
'categoryid'
],
$inposition
);
qa_db_category_set_position
(
$editcategory
[
'categoryid'
],
$inposition
);
$recalc
=
(
$hassubcategory
&&
(
$inslug
!==
$editcategory
[
'tags'
]))
;
$recalc
=
$hassubcategory
&&
$inslug
!==
$editcategory
[
'tags'
]
;
}
}
qa_redirect
(
qa_request
(),
array
(
'edit'
=>
$editcategory
[
'categoryid'
],
'saved'
=>
true
,
'recalc'
=>
(
int
)
$recalc
));
qa_redirect
(
qa_request
(),
array
(
'edit'
=>
$editcategory
[
'categoryid'
],
'saved'
=>
true
,
'recalc'
=>
(
int
)
$recalc
));
}
else
{
// creating a new one
}
else
{
// creating a new one
$categoryid
=
qa_db_category_create
(
$inparentid
,
$inname
,
$inslug
);
$categoryid
=
qa_db_category_create
(
$inparentid
,
$inname
,
$inslug
);
qa_db_category_set_content
(
$categoryid
,
$incontent
);
qa_db_category_set_content
(
$categoryid
,
$incontent
);
if
(
isset
(
$inposition
))
if
(
isset
(
$inposition
))
qa_db_category_set_position
(
$categoryid
,
$inposition
);
qa_db_category_set_position
(
$categoryid
,
$inposition
);
qa_redirect
(
qa_request
(),
array
(
'edit'
=>
$inparentid
,
'added'
=>
true
));
qa_redirect
(
qa_request
(),
array
(
'edit'
=>
$inparentid
,
'added'
=>
true
));
}
}
}
}
}
}
}
}
// Prepare content for theme
// Prepare content for theme
$qa_content
=
qa_content_prepare
();
$qa_content
=
qa_content_prepare
();
$qa_content
[
'title'
]
=
qa_lang_html
(
'admin/admin_title'
)
.
' - '
.
qa_lang_html
(
'admin/categories_title'
);
$qa_content
[
'title'
]
=
qa_lang_html
(
'admin/admin_title'
)
.
' - '
.
qa_lang_html
(
'admin/categories_title'
);
$qa_content
[
'error'
]
=
$securityexpired
?
qa_lang_html
(
'admin/form_security_expired'
)
:
qa_admin_page_error
();
$qa_content
[
'error'
]
=
$securityexpired
?
qa_lang_html
(
'admin/form_security_expired'
)
:
qa_admin_page_error
();
if
(
$setmissing
)
{
if
(
$setmissing
)
{
$qa_content
[
'form'
]
=
array
(
$qa_content
[
'form'
]
=
array
(
'tags'
=>
'method="post" action="'
.
qa_path_html
(
qa_request
())
.
'"'
,
'tags'
=>
'method="post" action="'
.
qa_path_html
(
qa_request
())
.
'"'
,
'style'
=>
'tall'
,
'style'
=>
'tall'
,
'fields'
=>
array
(
'fields'
=>
array
(
'reassign'
=>
array
(
'reassign'
=>
array
(
'label'
=>
isset
(
$editcategory
)
'label'
=>
isset
(
$editcategory
)
?
qa_lang_html_sub
(
'admin/category_no_sub_to'
,
qa_html
(
$editcategory
[
'title'
]))
?
qa_lang_html_sub
(
'admin/category_no_sub_to'
,
qa_html
(
$editcategory
[
'title'
]))
:
qa_lang_html
(
'admin/category_none_to'
),
:
qa_lang_html
(
'admin/category_none_to'
),
'loose'
=>
true
,
'loose'
=>
true
,
),
),
),
),
'buttons'
=>
array
(
'buttons'
=>
array
(
'save'
=>
array
(
'save'
=>
array
(
'tags'
=>
'id="dosaveoptions"'
,
// just used for qa_recalc_click()
'tags'
=>
'id="dosaveoptions"'
,
// just used for qa_recalc_click()
'label'
=>
qa_lang_html
(
'main/save_button'
),
'label'
=>
qa_lang_html
(
'main/save_button'
),
),
'cancel'
=>
array
(
'tags'
=>
'name="docancel"'
,
'label'
=>
qa_lang_html
(
'main/cancel_button'
),
),
),
),
'hidden'
=>
array
(
'cancel'
=>
array
(
'dosetmissing'
=>
'1'
,
// for IE
'tags'
=>
'name="docancel"'
,
'edit'
=>
@
$editcategory
[
'categoryid'
],
'label'
=>
qa_lang_html
(
'main/cancel_button'
),
'missing'
=>
'1'
,
'code'
=>
qa_get_form_security_code
(
'admin/categories'
),
),
),
)
;
)
,
qa_set_up_category_field
(
$qa_content
,
$qa_content
[
'form'
][
'fields'
][
'reassign'
],
'reassign'
,
'hidden'
=>
array
(
$categories
,
@
$editcategory
[
'categoryid'
],
qa_opt
(
'allow_no_category'
),
qa_opt
(
'allow_no_sub_category'
));
'dosetmissing'
=>
'1'
,
// for IE
'edit'
=>
@
$editcategory
[
'categoryid'
],
'missing'
=>
'1'
,
'code'
=>
qa_get_form_security_code
(
'admin/categories'
),
),
);
qa_set_up_category_field
(
$qa_content
,
$qa_content
[
'form'
][
'fields'
][
'reassign'
],
'reassign'
,
$categories
,
@
$editcategory
[
'categoryid'
],
qa_opt
(
'allow_no_category'
),
qa_opt
(
'allow_no_sub_category'
));
}
elseif
(
isset
(
$editcategory
))
{
$qa_content
[
'form'
]
=
array
(
}
elseif
(
isset
(
$editcategory
))
{
'tags'
=>
'method="post" action="'
.
qa_path_html
(
qa_request
())
.
'"'
,
'style'
=>
'tall'
,
$qa_content
[
'form'
]
=
array
(
'tags'
=>
'method="post" action="'
.
qa_path_html
(
qa_request
())
.
'"'
,
'ok'
=>
qa_get
(
'saved'
)
?
qa_lang_html
(
'admin/category_saved'
)
:
(
qa_get
(
'added'
)
?
qa_lang_html
(
'admin/category_added'
)
:
null
)
,
'style'
=>
'tall'
,
'fields'
=>
array
(
'ok'
=>
qa_get
(
'saved'
)
?
qa_lang_html
(
'admin/category_saved'
)
:
(
qa_get
(
'added'
)
?
qa_lang_html
(
'admin/category_added'
)
:
null
),
'name'
=>
array
(
'id'
=>
'name_display'
,
'tags'
=>
'name="name" id="name"'
,
'label'
=>
qa_lang_html
(
count
(
$categories
)
?
'admin/category_name'
:
'admin/category_name_first'
),
'value'
=>
qa_html
(
isset
(
$inname
)
?
$inname
:
@
$editcategory
[
'title'
]),
'error'
=>
qa_html
(
@
$errors
[
'name'
]),
),
'questions'
=>
array
(),
'fields'
=>
array
(
'name'
=>
array
(
'id'
=>
'name_display'
,
'tags'
=>
'name="name" id="name"'
,
'label'
=>
qa_lang_html
(
count
(
$categories
)
?
'admin/category_name'
:
'admin/category_name_first'
),
'value'
=>
qa_html
(
isset
(
$inname
)
?
$inname
:
@
$editcategory
[
'title'
]),
'error'
=>
qa_html
(
@
$errors
[
'name'
]),
),
'delete
'
=>
array
(),
'questions
'
=>
array
(),
'reassign
'
=>
array
(),
'delete
'
=>
array
(),
'slug'
=>
array
(
'reassign'
=>
array
(),
'id'
=>
'slug_display'
,
'tags'
=>
'name="slug"'
,
'label'
=>
qa_lang_html
(
'admin/category_slug'
),
'value'
=>
qa_html
(
isset
(
$inslug
)
?
$inslug
:
@
$editcategory
[
'tags'
]),
'error'
=>
qa_html
(
@
$errors
[
'slug'
]),
),
'content'
=>
array
(
'slug'
=>
array
(
'id'
=>
'content_display'
,
'id'
=>
'slug_display'
,
'tags'
=>
'name="content"'
,
'tags'
=>
'name="slug"'
,
'label'
=>
qa_lang_html
(
'admin/category_description'
),
'label'
=>
qa_lang_html
(
'admin/category_slug'
),
'value'
=>
qa_html
(
isset
(
$incontent
)
?
$incontent
:
@
$editcategory
[
'content'
]),
'value'
=>
qa_html
(
isset
(
$inslug
)
?
$inslug
:
@
$editcategory
[
'tags'
]),
'error'
=>
qa_html
(
@
$errors
[
'content'
]),
'error'
=>
qa_html
(
@
$errors
[
'slug'
]),
'rows'
=>
2
,
),
),
),
'buttons'
=>
array
(
'content'
=>
array
(
'save'
=>
array
(
'id'
=>
'content_display'
,
'tags'
=>
'id="dosaveoptions"'
,
// just used for qa_recalc_click
'tags'
=>
'name="content"'
,
'label'
=>
qa_lang_html
(
isset
(
$editcategory
[
'categoryid'
])
?
'main/save_button'
:
'admin/add_category_button'
),
'label'
=>
qa_lang_html
(
'admin/category_description'
),
),
'value'
=>
qa_html
(
isset
(
$incontent
)
?
$incontent
:
@
$editcategory
[
'content'
]),
'error'
=>
qa_html
(
@
$errors
[
'content'
]),
'rows'
=>
2
,
),
),
'cancel
'
=>
array
(
'buttons
'
=>
array
(
'tags'
=>
'name="docancel"'
,
'save'
=>
array
(
'label'
=>
qa_lang_html
(
'main/cancel_button'
),
'tags'
=>
'id="dosaveoptions"'
,
// just used for qa_recalc_click
),
'label'
=>
qa_lang_html
(
isset
(
$editcategory
[
'categoryid'
])
?
'main/save_button'
:
'admin/add_category_button'
),
),
),
'hidden'
=>
array
(
'cancel'
=>
array
(
'dosavecategory'
=>
'1'
,
// for IE
'tags'
=>
'name="docancel"'
,
'edit'
=>
@
$editcategory
[
'categoryid'
],
'label'
=>
qa_lang_html
(
'main/cancel_button'
),
'parent'
=>
@
$editcategory
[
'parentid'
],
'setparent'
=>
(
int
)
$setparent
,
'code'
=>
qa_get_form_security_code
(
'admin/categories'
),
),
),
),
'hidden'
=>
array
(
'dosavecategory'
=>
'1'
,
// for IE
'edit'
=>
@
$editcategory
[
'categoryid'
],
'parent'
=>
@
$editcategory
[
'parentid'
],
'setparent'
=>
(
int
)
$setparent
,
'code'
=>
qa_get_form_security_code
(
'admin/categories'
),
),
);
if
(
$setparent
)
{
unset
(
$qa_content
[
'form'
][
'fields'
][
'delete'
]);
unset
(
$qa_content
[
'form'
][
'fields'
][
'reassign'
]);
unset
(
$qa_content
[
'form'
][
'fields'
][
'questions'
]);
unset
(
$qa_content
[
'form'
][
'fields'
][
'content'
]);
$qa_content
[
'form'
][
'fields'
][
'parent'
]
=
array
(
'label'
=>
qa_lang_html
(
'admin/category_parent'
),
);
);
$childdepth
=
qa_db_category_child_depth
(
$editcategory
[
'categoryid'
]);
qa_set_up_category_field
(
$qa_content
,
$qa_content
[
'form'
][
'fields'
][
'parent'
],
'parent'
,
isset
(
$incategories
)
?
$incategories
:
$categories
,
isset
(
$inparentid
)
?
$inparentid
:
@
$editcategory
[
'parentid'
],
true
,
true
,
QA_CATEGORY_DEPTH
-
1
-
$childdepth
,
@
$editcategory
[
'categoryid'
]);
if
(
$setparent
)
{
$qa_content
[
'form'
][
'fields'
][
'parent'
][
'options'
][
''
]
=
qa_lang_html
(
'admin/category_top_level'
);
@
$qa_content
[
'form'
][
'fields'
][
'parent'
][
'note'
]
.=
qa_lang_html_sub
(
'admin/category_max_depth_x'
,
QA_CATEGORY_DEPTH
);
}
elseif
(
isset
(
$editcategory
[
'categoryid'
]))
{
// existing category
if
(
$hassubcategory
)
{
$qa_content
[
'form'
][
'fields'
][
'name'
][
'note'
]
=
qa_lang_html
(
'admin/category_no_delete_subs'
);
unset
(
$qa_content
[
'form'
][
'fields'
][
'delete'
]);
unset
(
$qa_content
[
'form'
][
'fields'
][
'delete'
]);
unset
(
$qa_content
[
'form'
][
'fields'
][
'reassign'
]);
unset
(
$qa_content
[
'form'
][
'fields'
][
'reassign'
]);
unset
(
$qa_content
[
'form'
][
'fields'
][
'questions'
]);
unset
(
$qa_content
[
'form'
][
'fields'
][
'content'
]);
$qa_content
[
'form'
][
'fields'
][
'parent'
]
=
array
(
}
else
{
'label'
=>
qa_lang_html
(
'admin/category_parent'
),
$qa_content
[
'form'
][
'fields'
][
'delete'
]
=
array
(
'tags'
=>
'name="dodelete" id="dodelete"'
,
'label'
=>
'<span id="reassign_shown">'
.
qa_lang_html
(
'admin/delete_category_reassign'
)
.
'</span>'
.
'<span id="reassign_hidden" style="display:none;">'
.
qa_lang_html
(
'admin/delete_category'
)
.
'</span>'
,
'value'
=>
0
,
'type'
=>
'checkbox'
,
);
);
$childdepth
=
qa_db_category_child_depth
(
$editcategory
[
'categoryid'
]);
$qa_content
[
'form'
][
'fields'
][
'reassign'
]
=
array
(
'id'
=>
'reassign_display'
,
qa_set_up_category_field
(
$qa_content
,
$qa_content
[
'form'
][
'fields'
][
'parent'
],
'parent'
,
'tags'
=>
'name="reassign"'
,
isset
(
$incategories
)
?
$incategories
:
$categories
,
isset
(
$inparentid
)
?
$inparentid
:
@
$editcategory
[
'parentid'
],
);
true
,
true
,
QA_CATEGORY_DEPTH
-
1
-
$childdepth
,
@
$editcategory
[
'categoryid'
]);
$qa_content
[
'form'
][
'fields'
][
'parent'
][
'options'
][
''
]
=
qa_lang_html
(
'admin/category_top_level'
);
qa_set_up_category_field
(
$qa_content
,
$qa_content
[
'form'
][
'fields'
][
'reassign'
],
'reassign'
,
$categories
,
$editcategory
[
'parentid'
],
true
,
true
,
null
,
$editcategory
[
'categoryid'
]);
}
@
$qa_content
[
'form'
][
'fields'
][
'parent'
][
'note'
]
.=
qa_lang_html_sub
(
'admin/category_max_depth_x'
,
QA_CATEGORY_DEPTH
);
$qa_content
[
'form'
][
'fields'
][
'questions'
]
=
array
(
'label'
=>
qa_lang_html
(
'admin/total_qs'
),
'type'
=>
'static'
,
'value'
=>
'<a href="'
.
qa_path_html
(
'questions/'
.
qa_category_path_request
(
$categories
,
$editcategory
[
'categoryid'
]))
.
'">'
.
(
$editcategory
[
'qcount'
]
==
1
?
qa_lang_html_sub
(
'main/1_question'
,
'1'
,
'1'
)
:
qa_lang_html_sub
(
'main/x_questions'
,
qa_format_number
(
$editcategory
[
'qcount'
]))
)
.
'</a>'
,
);
}
elseif
(
isset
(
$editcategory
[
'categoryid'
]))
{
// existing category
if
(
$hassubcategory
&&
!
qa_opt
(
'allow_no_sub_category'
))
{
if
(
$hassubcategory
)
{
$nosubcount
=
qa_db_count_categoryid_qs
(
$editcategory
[
'categoryid'
]);
$qa_content
[
'form'
][
'fields'
][
'name'
][
'note'
]
=
qa_lang_html
(
'admin/category_no_delete_subs'
);
unset
(
$qa_content
[
'form'
][
'fields'
][
'delete'
]);
unset
(
$qa_content
[
'form'
][
'fields'
][
'reassign'
]);
}
else
{
if
(
$nosubcount
)
{
$qa_content
[
'form'
][
'fields'
][
'
delete'
]
=
array
(
$qa_content
[
'form'
][
'fields'
][
'
questions'
][
'error'
]
=
'tags'
=>
'name="dodelete" id="dodelete"'
,
strtr
(
qa_lang_html
(
'admin/category_no_sub_error'
),
array
(
'label'
=>
'^q'
=>
qa_format_number
(
$nosubcount
),
'
<span id="reassign_shown">'
.
qa_lang_html
(
'admin/delete_category_reassign'
)
.
'</span>'
.
'
^1'
=>
'<a href="'
.
qa_path_html
(
qa_request
(),
array
(
'edit'
=>
$editcategory
[
'categoryid'
],
'missing'
=>
1
))
.
'">'
,
'
<span id="reassign_hidden" style="display:none;">'
.
qa_lang_html
(
'admin/delete_category'
)
.
'</span
>'
,
'
^2'
=>
'</a
>'
,
'value'
=>
0
,
));
'type'
=>
'checkbox'
,
}
);
}
$qa_content
[
'form'
][
'fields'
][
'reassign'
]
=
array
(
qa_set_display_rules
(
$qa_content
,
array
(
'id'
=>
'reassign_display'
,
'position_display'
=>
'!dodelete'
,
'tags'
=>
'name="reassign"'
,
'slug_display'
=>
'!dodelete'
,
);
'content_display'
=>
'!dodelete'
,
'parent_display'
=>
'!dodelete'
,
'children_display'
=>
'!dodelete'
,
'reassign_display'
=>
'dodelete'
,
'reassign_shown'
=>
'dodelete'
,
'reassign_hidden'
=>
'!dodelete'
,
));
}
else
{
// new category
unset
(
$qa_content
[
'form'
][
'fields'
][
'delete'
]);
unset
(
$qa_content
[
'form'
][
'fields'
][
'reassign'
]);
unset
(
$qa_content
[
'form'
][
'fields'
][
'slug'
]);
unset
(
$qa_content
[
'form'
][
'fields'
][
'questions'
]);
$qa_content
[
'focusid'
]
=
'name'
;
}
qa_set_up_category_field
(
$qa_content
,
$qa_content
[
'form'
][
'fields'
][
'reassign'
],
'reassign'
,
if
(
!
$setparent
)
{
$categories
,
$editcategory
[
'parentid'
],
true
,
true
,
null
,
$editcategory
[
'categoryid'
]);
$pathhtml
=
qa_category_path_html
(
$categories
,
@
$editcategory
[
'parentid'
]);
}
$qa_content
[
'form'
][
'fields'
][
'questions'
]
=
array
(
if
(
count
(
$categories
))
{
'label'
=>
qa_lang_html
(
'admin/total_qs'
),
$qa_content
[
'form'
][
'fields'
][
'parent'
]
=
array
(
'id'
=>
'parent_display'
,
'label'
=>
qa_lang_html
(
'admin/category_parent'
),
'type'
=>
'static'
,
'type'
=>
'static'
,
'value'
=>
'<a href="'
.
qa_path_html
(
'questions/'
.
qa_category_path_request
(
$categories
,
$editcategory
[
'categoryid'
]))
.
'">'
.
'value'
=>
(
strlen
(
$pathhtml
)
?
$pathhtml
:
qa_lang_html
(
'admin/category_top_level'
)),
(
(
$editcategory
[
'qcount'
]
==
1
)
?
qa_lang_html_sub
(
'main/1_question'
,
'1'
,
'1'
)
:
qa_lang_html_sub
(
'main/x_questions'
,
qa_format_number
(
$editcategory
[
'qcount'
]))
)
.
'</a>'
,
);
);
if
(
$hassubcategory
&&
!
qa_opt
(
'allow_no_sub_category'
))
{
$qa_content
[
'form'
][
'fields'
][
'parent'
][
'value'
]
=
$nosubcount
=
qa_db_count_categoryid_qs
(
$editcategory
[
'categoryid'
]);
'<a href="'
.
qa_path_html
(
qa_request
(),
array
(
'edit'
=>
@
$editcategory
[
'parentid'
]))
.
'">'
.
$qa_content
[
'form'
][
'fields'
][
'parent'
][
'value'
]
.
'</a>'
;
if
(
$nosubcount
)
if
(
isset
(
$editcategory
[
'categoryid'
]))
{
$qa_content
[
'form'
][
'fields'
][
'questions'
][
'error'
]
=
$qa_content
[
'form'
][
'fields'
][
'parent'
][
'value'
]
.=
' - '
.
strtr
(
qa_lang_html
(
'admin/category_no_sub_error'
),
array
(
'<a href="'
.
qa_path_html
(
qa_request
(),
array
(
'edit'
=>
$editcategory
[
'categoryid'
],
'setparent'
=>
1
))
.
'^q'
=>
qa_format_number
(
$nosubcount
),
'" style="white-space: nowrap;">'
.
qa_lang_html
(
'admin/category_move_parent'
)
.
'</a>'
;
'^1'
=>
'<a href="'
.
qa_path_html
(
qa_request
(),
array
(
'edit'
=>
$editcategory
[
'categoryid'
],
'missing'
=>
1
))
.
'">'
,
'^2'
=>
'</a>'
,
));
}
}
}
qa_set_display_rules
(
$qa_content
,
array
(
$positionoptions
=
array
();
'position_display'
=>
'!dodelete'
,
'slug_display'
=>
'!dodelete'
,
'content_display'
=>
'!dodelete'
,
'parent_display'
=>
'!dodelete'
,
'children_display'
=>
'!dodelete'
,
'reassign_display'
=>
'dodelete'
,
'reassign_shown'
=>
'dodelete'
,
'reassign_hidden'
=>
'!dodelete'
,
));
}
else
{
// new category
unset
(
$qa_content
[
'form'
][
'fields'
][
'delete'
]);
unset
(
$qa_content
[
'form'
][
'fields'
][
'reassign'
]);
unset
(
$qa_content
[
'form'
][
'fields'
][
'slug'
]);
unset
(
$qa_content
[
'form'
][
'fields'
][
'questions'
]);
$qa_content
[
'focusid'
]
=
'name'
;
$previous
=
null
;
}
$passedself
=
false
;
if
(
!
$setparent
)
{
foreach
(
$categories
as
$key
=>
$category
)
{
$pathhtml
=
qa_category_path_html
(
$categories
,
@
$editcategory
[
'parentid'
]);
if
(
!
strcmp
(
$category
[
'parentid'
],
@
$editcategory
[
'parentid'
]))
{
if
(
isset
(
$previous
))
$positionhtml
=
qa_lang_html_sub
(
'admin/after_x'
,
qa_html
(
$passedself
?
$category
[
'title'
]
:
$previous
[
'title'
]));
else
$positionhtml
=
qa_lang_html
(
'admin/first'
);
if
(
count
(
$categories
))
{
$positionoptions
[
$category
[
'position'
]]
=
$positionhtml
;
$qa_content
[
'form'
][
'fields'
][
'parent'
]
=
array
(
'id'
=>
'parent_display'
,
'label'
=>
qa_lang_html
(
'admin/category_parent'
),
'type'
=>
'static'
,
'value'
=>
(
strlen
(
$pathhtml
)
?
$pathhtml
:
qa_lang_html
(
'admin/category_top_level'
)),
);
$qa_content
[
'form'
][
'fields'
][
'parent'
][
'value'
]
=
if
(
!
strcmp
(
$category
[
'categoryid'
],
@
$editcategory
[
'categoryid'
]))
'<a href="'
.
qa_path_html
(
qa_request
(),
array
(
'edit'
=>
@
$editcategory
[
'parentid'
]))
.
'">'
.
$passedself
=
true
;
$qa_content
[
'form'
][
'fields'
][
'parent'
][
'value'
]
.
'</a>'
;
if
(
isset
(
$editcategory
[
'categoryid'
]))
$previous
=
$category
;
$qa_content
[
'form'
][
'fields'
][
'parent'
][
'value'
]
.=
' - '
.
'<a href="'
.
qa_path_html
(
qa_request
(),
array
(
'edit'
=>
$editcategory
[
'categoryid'
],
'setparent'
=>
1
))
.
'" style="white-space: nowrap;">'
.
qa_lang_html
(
'admin/category_move_parent'
)
.
'</a>'
;
}
}
}
$positionoptions
=
array
();
if
(
isset
(
$editcategory
[
'position'
]))
$positionvalue
=
$positionoptions
[
$editcategory
[
'position'
]];
$previous
=
null
;
else
{
$passedself
=
false
;
$positionvalue
=
isset
(
$previous
)
?
qa_lang_html_sub
(
'admin/after_x'
,
qa_html
(
$previous
[
'title'
]))
:
qa_lang_html
(
'admin/first'
);
$positionoptions
[
1
+
@
max
(
array_keys
(
$positionoptions
))]
=
$positionvalue
;
}
foreach
(
$categories
as
$key
=>
$category
)
$qa_content
[
'form'
][
'fields'
][
'position'
]
=
array
(
if
(
!
strcmp
(
$category
[
'parentid'
],
@
$editcategory
[
'parentid'
]))
{
'id'
=>
'position_display'
,
if
(
isset
(
$previous
))
'tags'
=>
'name="position"'
,
$positionhtml
=
qa_lang_html_sub
(
'admin/after_x'
,
qa_html
(
$passedself
?
$category
[
'title'
]
:
$previous
[
'title'
]));
'label'
=>
qa_lang_html
(
'admin/position'
),
else
'type'
=>
'select'
,
$positionhtml
=
qa_lang_html
(
'admin/first'
);
'options'
=>
$positionoptions
,
'value'
=>
$positionvalue
,
);
$positionoptions
[
$category
[
'position'
]]
=
$positionhtml
;
if
(
isset
(
$editcategory
[
'categoryid'
]))
{
$catdepth
=
count
(
qa_category_path
(
$categories
,
$editcategory
[
'categoryid'
]));
if
(
!
strcmp
(
$category
[
'categoryid'
],
@
$editcategory
[
'categoryid'
]))
if
(
$catdepth
<
QA_CATEGORY_DEPTH
)
{
$passedself
=
true
;
$childrenhtml
=
''
;
$previous
=
$category
;
foreach
(
$categories
as
$category
)
{
if
(
!
strcmp
(
$category
[
'parentid'
],
$editcategory
[
'categoryid'
]))
{
$childrenhtml
.=
(
strlen
(
$childrenhtml
)
?
', '
:
''
)
.
'<a href="'
.
qa_path_html
(
qa_request
(),
array
(
'edit'
=>
$category
[
'categoryid'
]))
.
'">'
.
qa_html
(
$category
[
'title'
])
.
'</a>'
.
' ('
.
$category
[
'qcount'
]
.
')'
;
}
}
}
if
(
isset
(
$editcategory
[
'position'
]
))
if
(
!
strlen
(
$childrenhtml
))
$positionvalue
=
$positionoptions
[
$editcategory
[
'position'
]]
;
$childrenhtml
=
qa_lang_html
(
'admin/category_no_subs'
)
;
else
{
$childrenhtml
.=
' - <a href="'
.
qa_path_html
(
qa_request
(),
array
(
'addsub'
=>
$editcategory
[
'categoryid'
]))
.
$positionvalue
=
isset
(
$previous
)
?
qa_lang_html_sub
(
'admin/after_x'
,
qa_html
(
$previous
[
'title'
]))
:
qa_lang_html
(
'admin/first'
);
'" style="white-space: nowrap;"><b>'
.
qa_lang_html
(
'admin/category_add_sub'
)
.
'</b></a>'
;
$positionoptions
[
1
+@
max
(
array_keys
(
$positionoptions
))]
=
$positionvalue
;
}
$qa_content
[
'form'
][
'fields'
][
'position'
]
=
array
(
'id'
=>
'position_display'
,
'tags'
=>
'name="position"'
,
'label'
=>
qa_lang_html
(
'admin/position'
),
'type'
=>
'select'
,
'options'
=>
$positionoptions
,
'value'
=>
$positionvalue
,
);
if
(
isset
(
$editcategory
[
'categoryid'
]))
{
$catdepth
=
count
(
qa_category_path
(
$categories
,
$editcategory
[
'categoryid'
]));
if
(
$catdepth
<
QA_CATEGORY_DEPTH
)
{
$childrenhtml
=
''
;
foreach
(
$categories
as
$category
)
if
(
!
strcmp
(
$category
[
'parentid'
],
$editcategory
[
'categoryid'
]))
$childrenhtml
.=
(
strlen
(
$childrenhtml
)
?
', '
:
''
)
.
'<a href="'
.
qa_path_html
(
qa_request
(),
array
(
'edit'
=>
$category
[
'categoryid'
]))
.
'">'
.
qa_html
(
$category
[
'title'
])
.
'</a>'
.
' ('
.
$category
[
'qcount'
]
.
')'
;
if
(
!
strlen
(
$childrenhtml
))
$childrenhtml
=
qa_lang_html
(
'admin/category_no_subs'
);
$childrenhtml
.=
' - <a href="'
.
qa_path_html
(
qa_request
(),
array
(
'addsub'
=>
$editcategory
[
'categoryid'
]))
.
'" style="white-space: nowrap;"><b>'
.
qa_lang_html
(
'admin/category_add_sub'
)
.
'</b></a>'
;
$qa_content
[
'form'
][
'fields'
][
'children'
]
=
array
(
'id'
=>
'children_display'
,
'label'
=>
qa_lang_html
(
'admin/category_subs'
),
'type'
=>
'static'
,
'value'
=>
$childrenhtml
,
);
}
else
{
$qa_content
[
'form'
][
'fields'
][
'name'
][
'note'
]
=
qa_lang_html_sub
(
'admin/category_no_add_subs_x'
,
QA_CATEGORY_DEPTH
);
}
$qa_content
[
'form'
][
'fields'
][
'children'
]
=
array
(
'id'
=>
'children_display'
,
'label'
=>
qa_lang_html
(
'admin/category_subs'
),
'type'
=>
'static'
,
'value'
=>
$childrenhtml
,
);
}
else
{
$qa_content
[
'form'
][
'fields'
][
'name'
][
'note'
]
=
qa_lang_html_sub
(
'admin/category_no_add_subs_x'
,
QA_CATEGORY_DEPTH
);
}
}
}
}
}
}
else
{
}
else
{
$qa_content
[
'form'
]
=
array
(
$qa_content
[
'form'
]
=
array
(
'tags'
=>
'method="post" action="'
.
qa_path_html
(
qa_request
())
.
'"'
,
'tags'
=>
'method="post" action="'
.
qa_path_html
(
qa_request
())
.
'"'
,
'ok'
=>
$savedoptions
?
qa_lang_html
(
'admin/options_saved'
)
:
null
,
'ok'
=>
$savedoptions
?
qa_lang_html
(
'admin/options_saved'
)
:
null
,
'style'
=>
'tall'
,
'style'
=>
'tall'
,
'fields'
=>
array
(
'fields'
=>
array
(
'intro'
=>
array
(
'intro'
=>
array
(
'label'
=>
qa_lang_html
(
'admin/categories_introduction'
),
'label'
=>
qa_lang_html
(
'admin/categories_introduction'
),
'type'
=>
'static'
,
'type'
=>
'static'
,
),
),
),
),
'buttons'
=>
array
(
'buttons'
=>
array
(
'save'
=>
array
(
'save'
=>
array
(
'tags'
=>
'name="dosaveoptions" id="dosaveoptions"'
,
'tags'
=>
'name="dosaveoptions" id="dosaveoptions"'
,
'label'
=>
qa_lang_html
(
'main/save_button'
),
'label'
=>
qa_lang_html
(
'main/save_button'
),
),
'add'
=>
array
(
'tags'
=>
'name="doaddcategory"'
,
'label'
=>
qa_lang_html
(
'admin/add_category_button'
),
),
),
),
'hidden'
=>
array
(
'add'
=>
array
(
'code'
=>
qa_get_form_security_code
(
'admin/categories'
),
'tags'
=>
'name="doaddcategory"'
,
'label'
=>
qa_lang_html
(
'admin/add_category_button'
),
),
),
);
),
'hidden'
=>
array
(
'code'
=>
qa_get_form_security_code
(
'admin/categories'
),
),
);
if
(
count
(
$categories
))
{
unset
(
$qa_content
[
'form'
][
'fields'
][
'intro'
]);
$navcategoryhtml
=
''
;
foreach
(
$categories
as
$category
)
{
if
(
!
isset
(
$category
[
'parentid'
]))
{
$navcategoryhtml
.=
'<a href="'
.
qa_path_html
(
'admin/categories'
,
array
(
'edit'
=>
$category
[
'categoryid'
]))
.
'">'
.
qa_html
(
$category
[
'title'
])
.
'</a> - '
.
(
$category
[
'qcount'
]
==
1
?
qa_lang_html_sub
(
'main/1_question'
,
'1'
,
'1'
)
:
qa_lang_html_sub
(
'main/x_questions'
,
qa_format_number
(
$category
[
'qcount'
]))
)
.
'<br/>'
;
}
}
if
(
count
(
$categories
))
{
$qa_content
[
'form'
][
'fields'
][
'nav'
]
=
array
(
unset
(
$qa_content
[
'form'
][
'fields'
][
'intro'
]);
'label'
=>
qa_lang_html
(
'admin/top_level_categories'
),
'type'
=>
'static'
,
$navcategoryhtml
=
''
;
'value'
=>
$navcategoryhtml
,
);
foreach
(
$categories
as
$category
)
if
(
!
isset
(
$category
[
'parentid'
]))
$navcategoryhtml
.=
'<a href="'
.
qa_path_html
(
'admin/categories'
,
array
(
'edit'
=>
$category
[
'categoryid'
]))
.
'">'
.
qa_html
(
$category
[
'title'
])
.
'</a> - '
.
(
$category
[
'qcount'
]
==
1
?
qa_lang_html_sub
(
'main/1_question'
,
'1'
,
'1'
)
:
qa_lang_html_sub
(
'main/x_questions'
,
qa_format_number
(
$category
[
'qcount'
]))
)
.
'<br/>'
;
$qa_content
[
'form'
][
'fields'
][
'nav'
]
=
array
(
'label'
=>
qa_lang_html
(
'admin/top_level_categories'
),
'type'
=>
'static'
,
'value'
=>
$navcategoryhtml
,
);
$qa_content
[
'form'
][
'fields'
][
'allow_no_category'
]
=
array
(
$qa_content
[
'form'
][
'fields'
][
'allow_no_category'
]
=
array
(
'label'
=>
qa_lang_html
(
'options/allow_no_category'
),
'label'
=>
qa_lang_html
(
'options/allow_no_category'
),
'tags'
=>
'name="option_allow_no_category"'
,
'tags'
=>
'name="option_allow_no_category"'
,
'type'
=>
'checkbox'
,
'type'
=>
'checkbox'
,
'value'
=>
qa_opt
(
'allow_no_category'
),
'value'
=>
qa_opt
(
'allow_no_category'
),
);
);
if
(
!
qa_opt
(
'allow_no_category'
))
{
if
(
!
qa_opt
(
'allow_no_category'
))
{
$nocatcount
=
qa_db_count_categoryid_qs
(
null
);
$nocatcount
=
qa_db_count_categoryid_qs
(
null
);
if
(
$nocatcount
)
if
(
$nocatcount
)
{
$qa_content
[
'form'
][
'fields'
][
'allow_no_category'
][
'error'
]
=
$qa_content
[
'form'
][
'fields'
][
'allow_no_category'
][
'error'
]
=
strtr
(
qa_lang_html
(
'admin/category_none_error'
),
array
(
strtr
(
qa_lang_html
(
'admin/category_none_error'
),
array
(
'^q'
=>
qa_format_number
(
$nocatcount
),
'^q'
=>
qa_format_number
(
$nocatcount
),
'^1'
=>
'<a href="'
.
qa_path_html
(
qa_request
(),
array
(
'missing'
=>
1
))
.
'">'
,
'^1'
=>
'<a href="'
.
qa_path_html
(
qa_request
(),
array
(
'missing'
=>
1
))
.
'">'
,
'^2'
=>
'</a>'
,
'^2'
=>
'</a>'
,
));
));
}
}
}
$qa_content
[
'form'
][
'fields'
][
'allow_no_sub_category'
]
=
array
(
$qa_content
[
'form'
][
'fields'
][
'allow_no_sub_category'
]
=
array
(
'label'
=>
qa_lang_html
(
'options/allow_no_sub_category'
),
'label'
=>
qa_lang_html
(
'options/allow_no_sub_category'
),
'tags'
=>
'name="option_allow_no_sub_category"'
,
'tags'
=>
'name="option_allow_no_sub_category"'
,
'type'
=>
'checkbox'
,
'type'
=>
'checkbox'
,
'value'
=>
qa_opt
(
'allow_no_sub_category'
),
'value'
=>
qa_opt
(
'allow_no_sub_category'
),
);
);
}
else
unset
(
$qa_content
[
'form'
][
'buttons'
][
'save'
]);
}
if
(
qa_get
(
'recalc'
))
{
$qa_content
[
'form'
][
'ok'
]
=
'<span id="recalc_ok">'
.
qa_lang_html
(
'admin/recalc_categories'
)
.
'</span>'
;
$qa_content
[
'form'
][
'hidden'
][
'code_recalc'
]
=
qa_get_form_security_code
(
'admin/recalc'
);
$qa_content
[
'script_rel'
][]
=
'qa-content/qa-admin.js?'
.
QA_VERSION
;
}
else
$qa_content
[
'script_var'
][
'qa_warning_recalc'
]
=
qa_lang
(
'admin/stop_recalc_warning'
);
unset
(
$qa_content
[
'form'
][
'buttons'
][
'save'
]);
}
$qa_content
[
'script_onloads'
][]
=
array
(
if
(
qa_get
(
'recalc'
))
{
"qa_recalc_click('dorecalccategories', document.getElementById('dosaveoptions'), null, 'recalc_ok');"
$qa_content
[
'form'
][
'ok'
]
=
'<span id="recalc_ok">'
.
qa_lang_html
(
'admin/recalc_categories'
)
.
'</span>'
;
);
$qa_content
[
'form'
][
'hidden'
][
'code_recalc'
]
=
qa_get_form_security_code
(
'admin/recalc'
);
}
$qa_content
[
'navigation'
][
'sub'
]
=
qa_admin_sub_navigation
();
$qa_content
[
'script_rel'
][]
=
'qa-content/qa-admin.js?'
.
QA_VERSION
;
$qa_content
[
'script_var'
][
'qa_warning_recalc'
]
=
qa_lang
(
'admin/stop_recalc_warning'
);
$qa_content
[
'script_onloads'
][]
=
array
(
"qa_recalc_click('dorecalccategories', document.getElementById('dosaveoptions'), null, 'recalc_ok');"
);
}
return
$qa_content
;
$qa_content
[
'navigation'
][
'sub'
]
=
qa_admin_sub_navigation
()
;
/*
return
$qa_content
;
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
qa-include/pages/admin/admin-flagged.php
View file @
14d54fd4
...
@@ -20,121 +20,119 @@
...
@@ -20,121 +20,119 @@
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
;
}
}
require_once
QA_INCLUDE_DIR
.
'app/admin.php'
;
require_once
QA_INCLUDE_DIR
.
'app/admin.php'
;
require_once
QA_INCLUDE_DIR
.
'db/selects.php'
;
require_once
QA_INCLUDE_DIR
.
'db/selects.php'
;
require_once
QA_INCLUDE_DIR
.
'app/format.php'
;
require_once
QA_INCLUDE_DIR
.
'app/format.php'
;
// Find most flagged questions, answers, comments
// Find most flagged questions, answers, comments
$userid
=
qa_get_logged_in_userid
();
$userid
=
qa_get_logged_in_userid
();
$questions
=
qa_db_select_with_pending
(
$questions
=
qa_db_select_with_pending
(
qa_db_flagged_post_qs_selectspec
(
$userid
,
0
,
true
)
qa_db_flagged_post_qs_selectspec
(
$userid
,
0
,
true
)
);
);
// Check admin privileges (do late to allow one DB query)
// Check admin privileges (do late to allow one DB query)
if
(
qa_user_maximum_permit_error
(
'permit_hide_show'
))
{
if
(
qa_user_maximum_permit_error
(
'permit_hide_show'
))
{
$qa_content
=
qa_content_prepare
();
$qa_content
=
qa_content_prepare
();
$qa_content
[
'error'
]
=
qa_lang_html
(
'users/no_permission'
);
$qa_content
[
'error'
]
=
qa_lang_html
(
'users/no_permission'
);
return
$qa_content
;
return
$qa_content
;
}
}
// Check to see if any were cleared or hidden here
// Check to see if any were cleared or hidden here
$pageerror
=
qa_admin_check_clicks
();
$pageerror
=
qa_admin_check_clicks
();
// Remove questions the user has no permission to hide/show
// Remove questions the user has no permission to hide/show
if
(
qa_user_permit_error
(
'permit_hide_show'
))
// if user not allowed to show/hide all posts
if
(
qa_user_permit_error
(
'permit_hide_show'
))
{
// if user not allowed to show/hide all posts
foreach
(
$questions
as
$index
=>
$question
)
foreach
(
$questions
as
$index
=>
$question
)
{
if
(
qa_user_post_permit_error
(
'permit_hide_show'
,
$question
))
if
(
qa_user_post_permit_error
(
'permit_hide_show'
,
$question
))
{
unset
(
$questions
[
$index
]);
unset
(
$questions
[
$index
]);
}
}
}
// Get information for users
// Get information for users
$usershtml
=
qa_userids_handles_html
(
qa_any_get_userids_handles
(
$questions
));
$usershtml
=
qa_userids_handles_html
(
qa_any_get_userids_handles
(
$questions
));
// Prepare content for theme
// Prepare content for theme
$qa_content
=
qa_content_prepare
();
$qa_content
=
qa_content_prepare
();
$qa_content
[
'title'
]
=
qa_lang_html
(
'admin/most_flagged_title'
);
$qa_content
[
'title'
]
=
qa_lang_html
(
'admin/most_flagged_title'
);
$qa_content
[
'error'
]
=
isset
(
$pageerror
)
?
$pageerror
:
qa_admin_page_error
();
$qa_content
[
'error'
]
=
isset
(
$pageerror
)
?
$pageerror
:
qa_admin_page_error
();
$qa_content
[
'q_list'
]
=
array
(
$qa_content
[
'q_list'
]
=
array
(
'form'
=>
array
(
'form'
=>
array
(
'tags'
=>
'method="post" action="'
.
qa_self_html
()
.
'"'
,
'tags'
=>
'method="post" action="'
.
qa_self_html
()
.
'"'
,
'hidden'
=>
array
(
'hidden'
=>
array
(
'code'
=>
qa_get_form_security_code
(
'admin/click'
),
'code'
=>
qa_get_form_security_code
(
'admin/click'
),
),
),
),
),
'qs'
=>
array
(),
'qs'
=>
array
(),
);
);
if
(
count
(
$questions
))
{
foreach
(
$questions
as
$question
)
{
$postid
=
qa_html
(
isset
(
$question
[
'opostid'
])
?
$question
[
'opostid'
]
:
$question
[
'postid'
]);
$elementid
=
'p'
.
$postid
;
$htmloptions
=
qa_post_html_options
(
$question
);
if
(
count
(
$questions
))
{
$htmloptions
[
'voteview'
]
=
false
;
foreach
(
$questions
as
$question
)
{
$htmloptions
[
'tagsview'
]
=
(
$question
[
'obasetype'
]
==
'Q'
);
$postid
=
qa_html
(
isset
(
$question
[
'opostid'
])
?
$question
[
'opostid'
]
:
$question
[
'postid'
]);
$htmloptions
[
'answersview'
]
=
false
;
$elementid
=
'p'
.
$postid
;
$htmloptions
[
'viewsview'
]
=
false
;
$htmloptions
[
'contentview'
]
=
true
;
$htmloptions
[
'flagsview'
]
=
true
;
$htmloptions
[
'elementid'
]
=
$elementid
;
$htmlfields
=
qa_any_to_q_html_fields
(
$question
,
$userid
,
qa_cookie_get
(),
$usershtml
,
null
,
$htmloptions
);
$htmloptions
=
qa_post_html_options
(
$question
);
$htmloptions
[
'voteview'
]
=
false
;
$htmloptions
[
'tagsview'
]
=
(
$question
[
'obasetype'
]
==
'Q'
);
$htmloptions
[
'answersview'
]
=
false
;
$htmloptions
[
'viewsview'
]
=
false
;
$htmloptions
[
'contentview'
]
=
true
;
$htmloptions
[
'flagsview'
]
=
true
;
$htmloptions
[
'elementid'
]
=
$elementid
;
if
(
isset
(
$htmlfields
[
'what_url'
]))
// link directly to relevant content
$htmlfields
=
qa_any_to_q_html_fields
(
$question
,
$userid
,
qa_cookie_get
(),
$usershtml
,
null
,
$htmloptions
);
$htmlfields
[
'url'
]
=
$htmlfields
[
'what_url'
];
$htmlfields
[
'form'
]
=
array
(
if
(
isset
(
$htmlfields
[
'what_url'
]))
// link directly to relevant content
'style'
=>
'light'
,
$htmlfields
[
'url'
]
=
$htmlfields
[
'what_url'
];
'buttons'
=>
array
(
$htmlfields
[
'form'
]
=
array
(
'clearflags'
=>
array
(
'style'
=>
'light'
,
'tags'
=>
'name="admin_'
.
$postid
.
'_clearflags" onclick="return qa_admin_click(this);"'
,
'label'
=>
qa_lang_html
(
'question/clear_flags_button'
),
),
'hide
'
=>
array
(
'buttons
'
=>
array
(
'tags'
=>
'name="admin_'
.
$postid
.
'_hide" onclick="return qa_admin_click(this);"'
,
'clearflags'
=>
array
(
'label'
=>
qa_lang_html
(
'question/hide_button'
)
,
'tags'
=>
'name="admin_'
.
$postid
.
'_clearflags" onclick="return qa_admin_click(this);"'
,
),
'label'
=>
qa_lang_html
(
'question/clear_flags_button'
),
),
),
);
$qa_content
[
'q_list'
][
'qs'
][]
=
$htmlfields
;
'hide'
=>
array
(
}
'tags'
=>
'name="admin_'
.
$postid
.
'_hide" onclick="return qa_admin_click(this);"'
,
'label'
=>
qa_lang_html
(
'question/hide_button'
),
}
else
),
$qa_content
[
'title'
]
=
qa_lang_html
(
'admin/no_flagged_found'
);
),
);
$qa_content
[
'q_list'
][
'qs'
][]
=
$htmlfields
;
}
$qa_content
[
'navigation'
][
'sub'
]
=
qa_admin_sub_navigation
();
}
else
$qa_content
[
'
script_rel'
][]
=
'qa-content/qa-admin.js?'
.
QA_VERSION
;
$qa_content
[
'
title'
]
=
qa_lang_html
(
'admin/no_flagged_found'
)
;
return
$qa_content
;
$qa_content
[
'navigation'
][
'sub'
]
=
qa_admin_sub_navigation
();
$qa_content
[
'script_rel'
][]
=
'qa-content/qa-admin.js?'
.
QA_VERSION
;
/*
return
$qa_content
;
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
qa-include/pages/admin/admin-hidden.php
View file @
14d54fd4
...
@@ -20,152 +20,153 @@
...
@@ -20,152 +20,153 @@
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
;
}
}
require_once
QA_INCLUDE_DIR
.
'app/admin.php'
;
require_once
QA_INCLUDE_DIR
.
'app/admin.php'
;
require_once
QA_INCLUDE_DIR
.
'db/admin.php'
;
require_once
QA_INCLUDE_DIR
.
'db/admin.php'
;
require_once
QA_INCLUDE_DIR
.
'db/selects.php'
;
require_once
QA_INCLUDE_DIR
.
'db/selects.php'
;
require_once
QA_INCLUDE_DIR
.
'app/format.php'
;
require_once
QA_INCLUDE_DIR
.
'app/format.php'
;
// Find recently hidden questions, answers, comments
// Find recently hidden questions, answers, comments
$userid
=
qa_get_logged_in_userid
();
$userid
=
qa_get_logged_in_userid
();
list
(
$hiddenquestions
,
$hiddenanswers
,
$hiddencomments
)
=
qa_db_select_with_pending
(
list
(
$hiddenquestions
,
$hiddenanswers
,
$hiddencomments
)
=
qa_db_select_with_pending
(
qa_db_qs_selectspec
(
$userid
,
'created'
,
0
,
null
,
null
,
'Q_HIDDEN'
,
true
),
qa_db_qs_selectspec
(
$userid
,
'created'
,
0
,
null
,
null
,
'Q_HIDDEN'
,
true
),
qa_db_recent_a_qs_selectspec
(
$userid
,
0
,
null
,
null
,
'A_HIDDEN'
,
true
),
qa_db_recent_a_qs_selectspec
(
$userid
,
0
,
null
,
null
,
'A_HIDDEN'
,
true
),
qa_db_recent_c_qs_selectspec
(
$userid
,
0
,
null
,
null
,
'C_HIDDEN'
,
true
)
qa_db_recent_c_qs_selectspec
(
$userid
,
0
,
null
,
null
,
'C_HIDDEN'
,
true
)
);
);
// Check admin privileges (do late to allow one DB query)
// Check admin privileges (do late to allow one DB query)
if
(
qa_user_maximum_permit_error
(
'permit_hide_show'
)
&&
qa_user_maximum_permit_error
(
'permit_delete_hidden'
))
{
if
(
qa_user_maximum_permit_error
(
'permit_hide_show'
)
&&
qa_user_maximum_permit_error
(
'permit_delete_hidden'
))
{
$qa_content
=
qa_content_prepare
();
$qa_content
=
qa_content_prepare
();
$qa_content
[
'error'
]
=
qa_lang_html
(
'users/no_permission'
);
$qa_content
[
'error'
]
=
qa_lang_html
(
'users/no_permission'
);
return
$qa_content
;
return
$qa_content
;
}
}
// Check to see if any have been reshown or deleted
// Check to see if any have been reshown or deleted
$pageerror
=
qa_admin_check_clicks
();
$pageerror
=
qa_admin_check_clicks
();
// Combine sets of questions and remove those this user has no permissions for
// Combine sets of questions and remove those this user has no permissions for
$questions
=
qa_any_sort_by_date
(
array_merge
(
$hiddenquestions
,
$hiddenanswers
,
$hiddencomments
));
$questions
=
qa_any_sort_by_date
(
array_merge
(
$hiddenquestions
,
$hiddenanswers
,
$hiddencomments
));
if
(
qa_user_permit_error
(
'permit_hide_show'
)
&&
qa_user_permit_error
(
'permit_delete_hidden'
))
// not allowed to see all hidden posts
if
(
qa_user_permit_error
(
'permit_hide_show'
)
&&
qa_user_permit_error
(
'permit_delete_hidden'
))
{
// not allowed to see all hidden posts
foreach
(
$questions
as
$index
=>
$question
)
foreach
(
$questions
as
$index
=>
$question
)
{
if
(
qa_user_post_permit_error
(
'permit_hide_show'
,
$question
)
&&
qa_user_post_permit_error
(
'permit_delete_hidden'
,
$question
))
if
(
qa_user_post_permit_error
(
'permit_hide_show'
,
$question
)
&&
qa_user_post_permit_error
(
'permit_delete_hidden'
,
$question
))
{
unset
(
$questions
[
$index
]);
unset
(
$questions
[
$index
]);
}
}
}
// Get information for users
// Get information for users
$usershtml
=
qa_userids_handles_html
(
qa_any_get_userids_handles
(
$questions
));
$usershtml
=
qa_userids_handles_html
(
qa_any_get_userids_handles
(
$questions
));
// Create list of actual hidden postids and see which ones have dependents
// Create list of actual hidden postids and see which ones have dependents
$qhiddenpostid
=
array
();
$qhiddenpostid
=
array
();
foreach
(
$questions
as
$key
=>
$question
)
foreach
(
$questions
as
$key
=>
$question
)
$qhiddenpostid
[
$key
]
=
isset
(
$question
[
'opostid'
])
?
$question
[
'opostid'
]
:
$question
[
'postid'
];
$qhiddenpostid
[
$key
]
=
isset
(
$question
[
'opostid'
])
?
$question
[
'opostid'
]
:
$question
[
'postid'
];
$dependcounts
=
qa_db_postids_count_dependents
(
$qhiddenpostid
);
$dependcounts
=
qa_db_postids_count_dependents
(
$qhiddenpostid
);
// Prepare content for theme
// Prepare content for theme
$qa_content
=
qa_content_prepare
();
$qa_content
=
qa_content_prepare
();
$qa_content
[
'title'
]
=
qa_lang_html
(
'admin/recent_hidden_title'
);
$qa_content
[
'title'
]
=
qa_lang_html
(
'admin/recent_hidden_title'
);
$qa_content
[
'error'
]
=
isset
(
$pageerror
)
?
$pageerror
:
qa_admin_page_error
();
$qa_content
[
'error'
]
=
isset
(
$pageerror
)
?
$pageerror
:
qa_admin_page_error
();
$qa_content
[
'q_list'
]
=
array
(
$qa_content
[
'q_list'
]
=
array
(
'form'
=>
array
(
'form'
=>
array
(
'tags'
=>
'method="post" action="'
.
qa_self_html
()
.
'"'
,
'tags'
=>
'method="post" action="'
.
qa_self_html
()
.
'"'
,
'hidden'
=>
array
(
'hidden'
=>
array
(
'code'
=>
qa_get_form_security_code
(
'admin/click'
),
'code'
=>
qa_get_form_security_code
(
'admin/click'
),
),
),
),
),
'qs'
=>
array
(),
);
if
(
count
(
$questions
))
{
foreach
(
$questions
as
$key
=>
$question
)
{
$elementid
=
'p'
.
$qhiddenpostid
[
$key
];
$htmloptions
=
qa_post_html_options
(
$question
);
$htmloptions
[
'voteview'
]
=
false
;
$htmloptions
[
'tagsview'
]
=
!
isset
(
$question
[
'opostid'
]);
$htmloptions
[
'answersview'
]
=
false
;
$htmloptions
[
'viewsview'
]
=
false
;
$htmloptions
[
'updateview'
]
=
false
;
$htmloptions
[
'contentview'
]
=
true
;
$htmloptions
[
'flagsview'
]
=
true
;
$htmloptions
[
'elementid'
]
=
$elementid
;
$htmlfields
=
qa_any_to_q_html_fields
(
$question
,
$userid
,
qa_cookie_get
(),
$usershtml
,
null
,
$htmloptions
);
if
(
isset
(
$htmlfields
[
'what_url'
]))
// link directly to relevant content
$htmlfields
[
'url'
]
=
$htmlfields
[
'what_url'
];
$htmlfields
[
'what_2'
]
=
qa_lang_html
(
'main/hidden'
);
'qs'
=>
array
(),
if
(
@
$htmloptions
[
'whenview'
])
{
);
$updated
=
@
$question
[
isset
(
$question
[
'opostid'
])
?
'oupdated'
:
'updated'
];
if
(
isset
(
$updated
))
if
(
count
(
$questions
))
{
$htmlfields
[
'when_2'
]
=
qa_when_to_html
(
$updated
,
@
$htmloptions
[
'fulldatedays'
]);
foreach
(
$questions
as
$key
=>
$question
)
{
$elementid
=
'p'
.
$qhiddenpostid
[
$key
];
$htmloptions
=
qa_post_html_options
(
$question
);
$htmloptions
[
'voteview'
]
=
false
;
$htmloptions
[
'tagsview'
]
=!
isset
(
$question
[
'opostid'
]);
$htmloptions
[
'answersview'
]
=
false
;
$htmloptions
[
'viewsview'
]
=
false
;
$htmloptions
[
'updateview'
]
=
false
;
$htmloptions
[
'contentview'
]
=
true
;
$htmloptions
[
'flagsview'
]
=
true
;
$htmloptions
[
'elementid'
]
=
$elementid
;
$htmlfields
=
qa_any_to_q_html_fields
(
$question
,
$userid
,
qa_cookie_get
(),
$usershtml
,
null
,
$htmloptions
);
if
(
isset
(
$htmlfields
[
'what_url'
]))
// link directly to relevant content
$htmlfields
[
'url'
]
=
$htmlfields
[
'what_url'
];
$htmlfields
[
'what_2'
]
=
qa_lang_html
(
'main/hidden'
);
if
(
@
$htmloptions
[
'whenview'
])
{
$updated
=@
$question
[
isset
(
$question
[
'opostid'
])
?
'oupdated'
:
'updated'
];
if
(
isset
(
$updated
))
$htmlfields
[
'when_2'
]
=
qa_when_to_html
(
$updated
,
@
$htmloptions
[
'fulldatedays'
]);
}
$buttons
=
array
();
$posttype
=
qa_strtolower
(
isset
(
$question
[
'obasetype'
])
?
$question
[
'obasetype'
]
:
$question
[
'basetype'
]);
if
(
!
qa_user_post_permit_error
(
'permit_hide_show'
,
$question
))
// Possible values for popup: reshow_q_popup, reshow_a_popup, reshow_c_popup
$buttons
[
'reshow'
]
=
array
(
'tags'
=>
'name="admin_'
.
qa_html
(
$qhiddenpostid
[
$key
])
.
'_reshow" onclick="return qa_admin_click(this);"'
,
'label'
=>
qa_lang_html
(
'question/reshow_button'
),
'popup'
=>
qa_lang_html
(
sprintf
(
'question/reshow_%s_popup'
,
$posttype
)),
);
if
((
!
qa_user_post_permit_error
(
'permit_delete_hidden'
,
$question
))
&&
!
$dependcounts
[
$qhiddenpostid
[
$key
]])
// Possible values for popup: delete_q_popup, delete_a_popup, delete_c_popup
$buttons
[
'delete'
]
=
array
(
'tags'
=>
'name="admin_'
.
qa_html
(
$qhiddenpostid
[
$key
])
.
'_delete" onclick="return qa_admin_click(this);"'
,
'label'
=>
qa_lang_html
(
'question/delete_button'
),
'popup'
=>
qa_lang_html
(
sprintf
(
'question/delete_%s_popup'
,
$posttype
)),
);
if
(
count
(
$buttons
))
$htmlfields
[
'form'
]
=
array
(
'style'
=>
'light'
,
'buttons'
=>
$buttons
,
);
$qa_content
[
'q_list'
][
'qs'
][]
=
$htmlfields
;
}
}
}
else
$buttons
=
array
();
$qa_content
[
'title'
]
=
qa_lang_html
(
'admin/no_hidden_found'
);
$posttype
=
qa_strtolower
(
isset
(
$question
[
'obasetype'
])
?
$question
[
'obasetype'
]
:
$question
[
'basetype'
]);
$qa_content
[
'navigation'
][
'sub'
]
=
qa_admin_sub_navigation
();
if
(
!
qa_user_post_permit_error
(
'permit_hide_show'
,
$question
))
{
$qa_content
[
'script_rel'
][]
=
'qa-content/qa-admin.js?'
.
QA_VERSION
;
// Possible values for popup: reshow_q_popup, reshow_a_popup, reshow_c_popup
$buttons
[
'reshow'
]
=
array
(
'tags'
=>
'name="admin_'
.
qa_html
(
$qhiddenpostid
[
$key
])
.
'_reshow" onclick="return qa_admin_click(this);"'
,
'label'
=>
qa_lang_html
(
'question/reshow_button'
),
'popup'
=>
qa_lang_html
(
sprintf
(
'question/reshow_%s_popup'
,
$posttype
)),
);
}
if
((
!
qa_user_post_permit_error
(
'permit_delete_hidden'
,
$question
))
&&
!
$dependcounts
[
$qhiddenpostid
[
$key
]])
{
// Possible values for popup: delete_q_popup, delete_a_popup, delete_c_popup
$buttons
[
'delete'
]
=
array
(
'tags'
=>
'name="admin_'
.
qa_html
(
$qhiddenpostid
[
$key
])
.
'_delete" onclick="return qa_admin_click(this);"'
,
'label'
=>
qa_lang_html
(
'question/delete_button'
),
'popup'
=>
qa_lang_html
(
sprintf
(
'question/delete_%s_popup'
,
$posttype
)),
);
}
return
$qa_content
;
if
(
count
(
$buttons
))
{
$htmlfields
[
'form'
]
=
array
(
'style'
=>
'light'
,
'buttons'
=>
$buttons
,
);
}
$qa_content
[
'q_list'
][
'qs'
][]
=
$htmlfields
;
}
}
else
$qa_content
[
'title'
]
=
qa_lang_html
(
'admin/no_hidden_found'
);
/*
Omit PHP closing tag to help avoid accidental output
$qa_content
[
'navigation'
][
'sub'
]
=
qa_admin_sub_navigation
();
*/
$qa_content
[
'script_rel'
][]
=
'qa-content/qa-admin.js?'
.
QA_VERSION
;
\ No newline at end of file
return
$qa_content
;
qa-include/pages/admin/admin-moderate.php
View file @
14d54fd4
...
@@ -20,144 +20,141 @@
...
@@ -20,144 +20,141 @@
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
;
}
}
require_once
QA_INCLUDE_DIR
.
'app/admin.php'
;
require_once
QA_INCLUDE_DIR
.
'app/admin.php'
;
require_once
QA_INCLUDE_DIR
.
'db/selects.php'
;
require_once
QA_INCLUDE_DIR
.
'db/selects.php'
;
require_once
QA_INCLUDE_DIR
.
'app/format.php'
;
require_once
QA_INCLUDE_DIR
.
'app/format.php'
;
// Find queued questions, answers, comments
// Find queued questions, answers, comments
$userid
=
qa_get_logged_in_userid
();
$userid
=
qa_get_logged_in_userid
();
list
(
$queuedquestions
,
$queuedanswers
,
$queuedcomments
)
=
qa_db_select_with_pending
(
list
(
$queuedquestions
,
$queuedanswers
,
$queuedcomments
)
=
qa_db_select_with_pending
(
qa_db_qs_selectspec
(
$userid
,
'created'
,
0
,
null
,
null
,
'Q_QUEUED'
,
true
),
qa_db_qs_selectspec
(
$userid
,
'created'
,
0
,
null
,
null
,
'Q_QUEUED'
,
true
),
qa_db_recent_a_qs_selectspec
(
$userid
,
0
,
null
,
null
,
'A_QUEUED'
,
true
),
qa_db_recent_a_qs_selectspec
(
$userid
,
0
,
null
,
null
,
'A_QUEUED'
,
true
),
qa_db_recent_c_qs_selectspec
(
$userid
,
0
,
null
,
null
,
'C_QUEUED'
,
true
)
qa_db_recent_c_qs_selectspec
(
$userid
,
0
,
null
,
null
,
'C_QUEUED'
,
true
)
);
);
// Check admin privileges (do late to allow one DB query)
// Check admin privileges (do late to allow one DB query)
if
(
qa_user_maximum_permit_error
(
'permit_moderate'
))
{
if
(
qa_user_maximum_permit_error
(
'permit_moderate'
))
{
$qa_content
=
qa_content_prepare
();
$qa_content
=
qa_content_prepare
();
$qa_content
[
'error'
]
=
qa_lang_html
(
'users/no_permission'
);
$qa_content
[
'error'
]
=
qa_lang_html
(
'users/no_permission'
);
return
$qa_content
;
return
$qa_content
;
}
}
// Check to see if any were approved/rejected here
// Check to see if any were approved/rejected here
$pageerror
=
qa_admin_check_clicks
();
$pageerror
=
qa_admin_check_clicks
();
// Combine sets of questions and remove those this user has no permission to moderate
// Combine sets of questions and remove those this user has no permission to moderate
$questions
=
qa_any_sort_by_date
(
array_merge
(
$queuedquestions
,
$queuedanswers
,
$queuedcomments
));
$questions
=
qa_any_sort_by_date
(
array_merge
(
$queuedquestions
,
$queuedanswers
,
$queuedcomments
));
if
(
qa_user_permit_error
(
'permit_moderate'
))
// if user not allowed to moderate all posts
if
(
qa_user_permit_error
(
'permit_moderate'
))
{
// if user not allowed to moderate all posts
foreach
(
$questions
as
$index
=>
$question
)
foreach
(
$questions
as
$index
=>
$question
)
{
if
(
qa_user_post_permit_error
(
'permit_moderate'
,
$question
))
if
(
qa_user_post_permit_error
(
'permit_moderate'
,
$question
))
unset
(
$questions
[
$index
]);
unset
(
$questions
[
$index
]);
}
}
// Get information for users
// Get information for users
$usershtml
=
qa_userids_handles_html
(
qa_any_get_userids_handles
(
$questions
));
$usershtml
=
qa_userids_handles_html
(
qa_any_get_userids_handles
(
$questions
));
// Prepare content for theme
// Prepare content for theme
$qa_content
=
qa_content_prepare
();
$qa_content
=
qa_content_prepare
();
$qa_content
[
'title'
]
=
qa_lang_html
(
'admin/recent_approve_title'
);
$qa_content
[
'title'
]
=
qa_lang_html
(
'admin/recent_approve_title'
);
$qa_content
[
'error'
]
=
isset
(
$pageerror
)
?
$pageerror
:
qa_admin_page_error
();
$qa_content
[
'error'
]
=
isset
(
$pageerror
)
?
$pageerror
:
qa_admin_page_error
();
$qa_content
[
'q_list'
]
=
array
(
$qa_content
[
'q_list'
]
=
array
(
'form'
=>
array
(
'form'
=>
array
(
'tags'
=>
'method="post" action="'
.
qa_self_html
()
.
'"'
,
'tags'
=>
'method="post" action="'
.
qa_self_html
()
.
'"'
,
'hidden'
=>
array
(
'hidden'
=>
array
(
'code'
=>
qa_get_form_security_code
(
'admin/click'
),
'code'
=>
qa_get_form_security_code
(
'admin/click'
),
),
),
),
),
'qs'
=>
array
(),
);
if
(
count
(
$questions
))
{
foreach
(
$questions
as
$question
)
{
$postid
=
qa_html
(
isset
(
$question
[
'opostid'
])
?
$question
[
'opostid'
]
:
$question
[
'postid'
]);
$elementid
=
'p'
.
$postid
;
$htmloptions
=
qa_post_html_options
(
$question
);
$htmloptions
[
'voteview'
]
=
false
;
$htmloptions
[
'tagsview'
]
=
!
isset
(
$question
[
'opostid'
]);
$htmloptions
[
'answersview'
]
=
false
;
$htmloptions
[
'viewsview'
]
=
false
;
$htmloptions
[
'contentview'
]
=
true
;
$htmloptions
[
'elementid'
]
=
$elementid
;
$htmlfields
=
qa_any_to_q_html_fields
(
$question
,
$userid
,
qa_cookie_get
(),
$usershtml
,
null
,
$htmloptions
);
if
(
isset
(
$htmlfields
[
'what_url'
]))
// link directly to relevant content
$htmlfields
[
'url'
]
=
$htmlfields
[
'what_url'
];
$posttype
=
qa_strtolower
(
isset
(
$question
[
'obasetype'
])
?
$question
[
'obasetype'
]
:
$question
[
'basetype'
]);
switch
(
$posttype
)
{
case
'q'
:
default
:
$approveKey
=
'question/approve_q_popup'
;
$rejectKey
=
'question/reject_q_popup'
;
break
;
case
'a'
:
$approveKey
=
'question/approve_a_popup'
;
$rejectKey
=
'question/reject_a_popup'
;
break
;
case
'c'
:
$approveKey
=
'question/approve_c_popup'
;
$rejectKey
=
'question/reject_c_popup'
;
break
;
}
'qs'
=>
array
(),
$htmlfields
[
'form'
]
=
array
(
);
'style'
=>
'light'
,
if
(
count
(
$questions
))
{
foreach
(
$questions
as
$question
)
{
$postid
=
qa_html
(
isset
(
$question
[
'opostid'
])
?
$question
[
'opostid'
]
:
$question
[
'postid'
]);
$elementid
=
'p'
.
$postid
;
$htmloptions
=
qa_post_html_options
(
$question
);
$htmloptions
[
'voteview'
]
=
false
;
$htmloptions
[
'tagsview'
]
=!
isset
(
$question
[
'opostid'
]);
$htmloptions
[
'answersview'
]
=
false
;
$htmloptions
[
'viewsview'
]
=
false
;
$htmloptions
[
'contentview'
]
=
true
;
$htmloptions
[
'elementid'
]
=
$elementid
;
$htmlfields
=
qa_any_to_q_html_fields
(
$question
,
$userid
,
qa_cookie_get
(),
$usershtml
,
null
,
$htmloptions
);
if
(
isset
(
$htmlfields
[
'what_url'
]))
// link directly to relevant content
$htmlfields
[
'url'
]
=
$htmlfields
[
'what_url'
];
$posttype
=
qa_strtolower
(
isset
(
$question
[
'obasetype'
])
?
$question
[
'obasetype'
]
:
$question
[
'basetype'
]);
switch
(
$posttype
)
{
case
'q'
:
default
:
$approveKey
=
'question/approve_q_popup'
;
$rejectKey
=
'question/reject_q_popup'
;
break
;
case
'a'
:
$approveKey
=
'question/approve_a_popup'
;
$rejectKey
=
'question/reject_a_popup'
;
break
;
case
'c'
:
$approveKey
=
'question/approve_c_popup'
;
$rejectKey
=
'question/reject_c_popup'
;
break
;
}
$htmlfields
[
'form'
]
=
array
(
'style'
=>
'light'
,
'buttons'
=>
array
(
// Possible values for popup: approve_q_popup, approve_a_popup, approve_c_popup
'approve'
=>
array
(
'tags'
=>
'name="admin_'
.
$postid
.
'_approve" onclick="return qa_admin_click(this);"'
,
'label'
=>
qa_lang_html
(
'question/approve_button'
),
'popup'
=>
qa_lang_html
(
$approveKey
),
),
// Possible values for popup: reject_q_popup, reject_a_popup, reject_c_popup
'reject'
=>
array
(
'tags'
=>
'name="admin_'
.
$postid
.
'_reject" onclick="return qa_admin_click(this);"'
,
'label'
=>
qa_lang_html
(
'question/reject_button'
),
'popup'
=>
qa_lang_html
(
$rejectKey
),
),
),
);
$qa_content
[
'q_list'
][
'qs'
][]
=
$htmlfields
;
'buttons'
=>
array
(
}
// Possible values for popup: approve_q_popup, approve_a_popup, approve_c_popup
'approve'
=>
array
(
'tags'
=>
'name="admin_'
.
$postid
.
'_approve" onclick="return qa_admin_click(this);"'
,
'label'
=>
qa_lang_html
(
'question/approve_button'
),
'popup'
=>
qa_lang_html
(
$approveKey
),
),
}
else
// Possible values for popup: reject_q_popup, reject_a_popup, reject_c_popup
$qa_content
[
'title'
]
=
qa_lang_html
(
'admin/no_approve_found'
);
'reject'
=>
array
(
'tags'
=>
'name="admin_'
.
$postid
.
'_reject" onclick="return qa_admin_click(this);"'
,
'label'
=>
qa_lang_html
(
'question/reject_button'
),
'popup'
=>
qa_lang_html
(
$rejectKey
),
),
),
);
$qa_content
[
'q_list'
][
'qs'
][]
=
$htmlfields
;
}
$qa_content
[
'navigation'
][
'sub'
]
=
qa_admin_sub_navigation
();
}
else
$qa_content
[
'
script_rel'
][]
=
'qa-content/qa-admin.js?'
.
QA_VERSION
;
$qa_content
[
'
title'
]
=
qa_lang_html
(
'admin/no_approve_found'
)
;
return
$qa_content
;
$qa_content
[
'navigation'
][
'sub'
]
=
qa_admin_sub_navigation
();
$qa_content
[
'script_rel'
][]
=
'qa-content/qa-admin.js?'
.
QA_VERSION
;
/*
return
$qa_content
;
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
qa-include/pages/admin/admin-pages.php
View file @
14d54fd4
...
@@ -20,563 +20,558 @@
...
@@ -20,563 +20,558 @@
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
;
}
}
require_once
QA_INCLUDE_DIR
.
'app/admin.php'
;
require_once
QA_INCLUDE_DIR
.
'app/admin.php'
;
require_once
QA_INCLUDE_DIR
.
'app/format.php'
;
require_once
QA_INCLUDE_DIR
.
'app/format.php'
;
require_once
QA_INCLUDE_DIR
.
'db/selects.php'
;
require_once
QA_INCLUDE_DIR
.
'db/selects.php'
;
// Get current list of pages and determine the state of this admin page
// Get current list of pages and determine the state of this admin page
$pageid
=
qa_post_text
(
'edit'
);
$pageid
=
qa_post_text
(
'edit'
);
if
(
!
isset
(
$pageid
))
if
(
!
isset
(
$pageid
))
$pageid
=
qa_get
(
'edit'
);
$pageid
=
qa_get
(
'edit'
);
list
(
$pages
,
$editpage
)
=
qa_db_select_with_pending
(
list
(
$pages
,
$editpage
)
=
qa_db_select_with_pending
(
qa_db_pages_selectspec
(),
qa_db_pages_selectspec
(),
isset
(
$pageid
)
?
qa_db_page_full_selectspec
(
$pageid
,
true
)
:
null
isset
(
$pageid
)
?
qa_db_page_full_selectspec
(
$pageid
,
true
)
:
null
);
);
if
((
qa_clicked
(
'doaddpage'
)
||
qa_clicked
(
'doaddlink'
)
||
qa_get
(
'doaddlink'
)
||
qa_clicked
(
'dosavepage'
))
&&
!
isset
(
$editpage
))
{
if
((
qa_clicked
(
'doaddpage'
)
||
qa_clicked
(
'doaddlink'
)
||
qa_get
(
'doaddlink'
)
||
qa_clicked
(
'dosavepage'
))
&&
!
isset
(
$editpage
))
{
$editpage
=
array
(
'title'
=>
qa_get
(
'text'
),
'tags'
=>
qa_get
(
'url'
),
'nav'
=>
qa_get
(
'nav'
),
'position'
=>
1
);
$editpage
=
array
(
'title'
=>
qa_get
(
'text'
),
'tags'
=>
qa_get
(
'url'
),
'nav'
=>
qa_get
(
'nav'
),
'position'
=>
1
);
$isexternal
=
qa_clicked
(
'doaddlink'
)
||
qa_get
(
'doaddlink'
)
||
qa_post_text
(
'external'
);
$isexternal
=
qa_clicked
(
'doaddlink'
)
||
qa_get
(
'doaddlink'
)
||
qa_post_text
(
'external'
);
}
elseif
(
isset
(
$editpage
))
}
elseif
(
isset
(
$editpage
))
$isexternal
=
$editpage
[
'flags'
]
&
QA_PAGE_FLAGS_EXTERNAL
;
$isexternal
=
$editpage
[
'flags'
]
&
QA_PAGE_FLAGS_EXTERNAL
;
// Check admin privileges (do late to allow one DB query)
// Check admin privileges (do late to allow one DB query)
if
(
!
qa_admin_check_privileges
(
$qa_content
))
if
(
!
qa_admin_check_privileges
(
$qa_content
))
return
$qa_content
;
return
$qa_content
;
// Define an array of navigation settings we can change, option name => language key
// Define an array of navigation settings we can change, option name => language key
$hascustomhome
=
qa_has_custom_home
();
$hascustomhome
=
qa_has_custom_home
();
$navoptions
=
array
(
$navoptions
=
array
(
'nav_home'
=>
'main/nav_home'
,
'nav_home'
=>
'main/nav_home'
,
'nav_activity'
=>
'main/nav_activity'
,
'nav_activity'
=>
'main/nav_activity'
,
$hascustomhome
?
'nav_qa_not_home'
:
'nav_qa_is_home'
=>
$hascustomhome
?
'main/nav_qa'
:
'admin/nav_qa_is_home'
,
$hascustomhome
?
'nav_qa_not_home'
:
'nav_qa_is_home'
=>
$hascustomhome
?
'main/nav_qa'
:
'admin/nav_qa_is_home'
,
'nav_questions'
=>
'main/nav_qs'
,
'nav_questions'
=>
'main/nav_qs'
,
'nav_hot'
=>
'main/nav_hot'
,
'nav_hot'
=>
'main/nav_hot'
,
'nav_unanswered'
=>
'main/nav_unanswered'
,
'nav_unanswered'
=>
'main/nav_unanswered'
,
'nav_tags'
=>
'main/nav_tags'
,
'nav_tags'
=>
'main/nav_tags'
,
'nav_categories'
=>
'main/nav_categories'
,
'nav_categories'
=>
'main/nav_categories'
,
'nav_users'
=>
'main/nav_users'
,
'nav_users'
=>
'main/nav_users'
,
'nav_ask'
=>
'main/nav_ask'
,
'nav_ask'
=>
'main/nav_ask'
,
);
);
$navpaths
=
array
(
$navpaths
=
array
(
'nav_home'
=>
''
,
'nav_home'
=>
''
,
'nav_activity'
=>
'activity'
,
'nav_activity'
=>
'activity'
,
'nav_qa_not_home'
=>
'qa'
,
'nav_qa_not_home'
=>
'qa'
,
'nav_qa_is_home'
=>
''
,
'nav_qa_is_home'
=>
''
,
'nav_questions'
=>
'questions'
,
'nav_questions'
=>
'questions'
,
'nav_hot'
=>
'hot'
,
'nav_hot'
=>
'hot'
,
'nav_unanswered'
=>
'unanswered'
,
'nav_unanswered'
=>
'unanswered'
,
'nav_tags'
=>
'tags'
,
'nav_tags'
=>
'tags'
,
'nav_categories'
=>
'categories'
,
'nav_categories'
=>
'categories'
,
'nav_users'
=>
'users'
,
'nav_users'
=>
'users'
,
'nav_ask'
=>
'ask'
,
'nav_ask'
=>
'ask'
,
);
);
if
(
!
qa_opt
(
'show_custom_home'
))
if
(
!
qa_opt
(
'show_custom_home'
))
unset
(
$navoptions
[
'nav_home'
]);
unset
(
$navoptions
[
'nav_home'
]);
if
(
!
qa_using_categories
())
if
(
!
qa_using_categories
())
unset
(
$navoptions
[
'nav_categories'
]);
unset
(
$navoptions
[
'nav_categories'
]);
if
(
!
qa_using_tags
())
if
(
!
qa_using_tags
())
unset
(
$navoptions
[
'nav_tags'
]);
unset
(
$navoptions
[
'nav_tags'
]);
// Process saving an old or new page
// Process saving an old or new page
$securityexpired
=
false
;
$securityexpired
=
false
;
if
(
qa_clicked
(
'docancel'
))
if
(
qa_clicked
(
'docancel'
))
$editpage
=
null
;
$editpage
=
null
;
elseif
(
qa_clicked
(
'dosaveoptions'
)
||
qa_clicked
(
'doaddpage'
)
||
qa_clicked
(
'doaddlink'
))
{
elseif
(
qa_clicked
(
'dosaveoptions'
)
||
qa_clicked
(
'doaddpage'
)
||
qa_clicked
(
'doaddlink'
))
{
if
(
!
qa_check_form_security_code
(
'admin/pages'
,
qa_post_text
(
'code'
)))
if
(
!
qa_check_form_security_code
(
'admin/pages'
,
qa_post_text
(
'code'
)))
$securityexpired
=
true
;
$securityexpired
=
true
;
else
foreach
(
$navoptions
as
$optionname
=>
$langkey
)
else
foreach
(
$navoptions
as
$optionname
=>
$langkey
)
qa_set_option
(
$optionname
,
(
int
)
qa_post_text
(
'option_'
.
$optionname
));
qa_set_option
(
$optionname
,
(
int
)
qa_post_text
(
'option_'
.
$optionname
));
}
elseif
(
qa_clicked
(
'dosavepage'
))
{
}
elseif
(
qa_clicked
(
'dosavepage'
))
{
require_once
QA_INCLUDE_DIR
.
'db/admin.php'
;
require_once
QA_INCLUDE_DIR
.
'db/admin.php'
;
require_once
QA_INCLUDE_DIR
.
'util/string.php'
;
require_once
QA_INCLUDE_DIR
.
'util/string.php'
;
if
(
!
qa_check_form_security_code
(
'admin/pages'
,
qa_post_text
(
'code'
)))
if
(
!
qa_check_form_security_code
(
'admin/pages'
,
qa_post_text
(
'code'
)))
$securityexpired
=
true
;
$securityexpired
=
true
;
else
{
else
{
$reloadpages
=
false
;
$reloadpages
=
false
;
if
(
qa_post_text
(
'dodelete'
))
{
if
(
qa_post_text
(
'dodelete'
))
{
qa_db_page_delete
(
$editpage
[
'pageid'
]);
qa_db_page_delete
(
$editpage
[
'pageid'
]);
$searchmodules
=
qa_load_modules_with
(
'search'
,
'unindex_page'
);
$searchmodules
=
qa_load_modules_with
(
'search'
,
'unindex_page'
);
foreach
(
$searchmodules
as
$searchmodule
)
foreach
(
$searchmodules
as
$searchmodule
)
$searchmodule
->
unindex_page
(
$editpage
[
'pageid'
]);
$searchmodule
->
unindex_page
(
$editpage
[
'pageid'
]);
$editpage
=
null
;
$editpage
=
null
;
$reloadpages
=
true
;
$reloadpages
=
true
;
}
else
{
}
else
{
$inname
=
qa_post_text
(
'name'
);
$inname
=
qa_post_text
(
'name'
);
$inposition
=
qa_post_text
(
'position'
);
$inposition
=
qa_post_text
(
'position'
);
$inpermit
=
(
int
)
qa_post_text
(
'permit'
);
$inpermit
=
(
int
)
qa_post_text
(
'permit'
);
$inurl
=
qa_post_text
(
'url'
);
$inurl
=
qa_post_text
(
'url'
);
$innewwindow
=
qa_post_text
(
'newwindow'
);
$innewwindow
=
qa_post_text
(
'newwindow'
);
$inheading
=
qa_post_text
(
'heading'
);
$inheading
=
qa_post_text
(
'heading'
);
$incontent
=
qa_post_text
(
'content'
);
$incontent
=
qa_post_text
(
'content'
);
$errors
=
array
();
$errors
=
array
();
// Verify the name (navigation link) is legitimate
// Verify the name (navigation link) is legitimate
if
(
empty
(
$inname
))
if
(
empty
(
$inname
))
$errors
[
'name'
]
=
qa_lang
(
'main/field_required'
);
$errors
[
'name'
]
=
qa_lang
(
'main/field_required'
);
elseif
(
qa_strlen
(
$inname
)
>
QA_DB_MAX_CAT_PAGE_TITLE_LENGTH
)
elseif
(
qa_strlen
(
$inname
)
>
QA_DB_MAX_CAT_PAGE_TITLE_LENGTH
)
$errors
[
'name'
]
=
qa_lang_sub
(
'main/max_length_x'
,
QA_DB_MAX_CAT_PAGE_TITLE_LENGTH
);
$errors
[
'name'
]
=
qa_lang_sub
(
'main/max_length_x'
,
QA_DB_MAX_CAT_PAGE_TITLE_LENGTH
);
if
(
$isexternal
)
{
if
(
$isexternal
)
{
// Verify the url is legitimate (vaguely)
// Verify the url is legitimate (vaguely)
if
(
empty
(
$inurl
))
if
(
empty
(
$inurl
))
$errors
[
'url'
]
=
qa_lang
(
'main/field_required'
);
$errors
[
'url'
]
=
qa_lang
(
'main/field_required'
);
elseif
(
qa_strlen
(
$inurl
)
>
QA_DB_MAX_CAT_PAGE_TAGS_LENGTH
)
elseif
(
qa_strlen
(
$inurl
)
>
QA_DB_MAX_CAT_PAGE_TAGS_LENGTH
)
$errors
[
'url'
]
=
qa_lang_sub
(
'main/max_length_x'
,
QA_DB_MAX_CAT_PAGE_TAGS_LENGTH
);
$errors
[
'url'
]
=
qa_lang_sub
(
'main/max_length_x'
,
QA_DB_MAX_CAT_PAGE_TAGS_LENGTH
);
}
else
{
}
else
{
// Verify the heading is legitimate
// Verify the heading is legitimate
if
(
qa_strlen
(
$inheading
)
>
QA_DB_MAX_TITLE_LENGTH
)
if
(
qa_strlen
(
$inheading
)
>
QA_DB_MAX_TITLE_LENGTH
)
$errors
[
'heading'
]
=
qa_lang_sub
(
'main/max_length_x'
,
QA_DB_MAX_TITLE_LENGTH
);
$errors
[
'heading'
]
=
qa_lang_sub
(
'main/max_length_x'
,
QA_DB_MAX_TITLE_LENGTH
);
// Verify the slug is legitimate (and try some defaults if we're creating a new page, and it's not)
// Verify the slug is legitimate (and try some defaults if we're creating a new page, and it's not)
for
(
$attempt
=
0
;
$attempt
<
100
;
$attempt
++
)
{
for
(
$attempt
=
0
;
$attempt
<
100
;
$attempt
++
)
{
switch
(
$attempt
)
{
switch
(
$attempt
)
{
case
0
:
case
0
:
$inslug
=
qa_post_text
(
'slug'
);
$inslug
=
qa_post_text
(
'slug'
);
if
(
!
isset
(
$inslug
))
if
(
!
isset
(
$inslug
))
$inslug
=
implode
(
'-'
,
qa_string_to_words
(
$inname
));
$inslug
=
implode
(
'-'
,
qa_string_to_words
(
$inname
));
break
;
break
;
case
1
:
case
1
:
$inslug
=
qa_lang_sub
(
'admin/page_default_slug'
,
$inslug
);
$inslug
=
qa_lang_sub
(
'admin/page_default_slug'
,
$inslug
);
break
;
break
;
default
:
default
:
$inslug
=
qa_lang_sub
(
'admin/page_default_slug'
,
$attempt
-
1
);
$inslug
=
qa_lang_sub
(
'admin/page_default_slug'
,
$attempt
-
1
);
break
;
}
list
(
$matchcategoryid
,
$matchpage
)
=
qa_db_select_with_pending
(
qa_db_slugs_to_category_id_selectspec
(
$inslug
),
qa_db_page_full_selectspec
(
$inslug
,
false
)
);
if
(
empty
(
$inslug
))
$errors
[
'slug'
]
=
qa_lang
(
'main/field_required'
);
elseif
(
qa_strlen
(
$inslug
)
>
QA_DB_MAX_CAT_PAGE_TAGS_LENGTH
)
$errors
[
'slug'
]
=
qa_lang_sub
(
'main/max_length_x'
,
QA_DB_MAX_CAT_PAGE_TAGS_LENGTH
);
elseif
(
preg_match
(
'/[\\+\\/]/'
,
$inslug
))
$errors
[
'slug'
]
=
qa_lang_sub
(
'admin/slug_bad_chars'
,
'+ /'
);
elseif
(
qa_admin_is_slug_reserved
(
$inslug
))
$errors
[
'slug'
]
=
qa_lang
(
'admin/slug_reserved'
);
elseif
(
isset
(
$matchpage
)
&&
(
$matchpage
[
'pageid'
]
!=@
$editpage
[
'pageid'
]))
$errors
[
'slug'
]
=
qa_lang
(
'admin/page_already_used'
);
elseif
(
isset
(
$matchcategoryid
))
$errors
[
'slug'
]
=
qa_lang
(
'admin/category_already_used'
);
else
unset
(
$errors
[
'slug'
]);
if
(
isset
(
$editpage
[
'pageid'
])
||
!
isset
(
$errors
[
'slug'
]))
// don't try other options if editing existing page
break
;
break
;
}
}
list
(
$matchcategoryid
,
$matchpage
)
=
qa_db_select_with_pending
(
qa_db_slugs_to_category_id_selectspec
(
$inslug
),
qa_db_page_full_selectspec
(
$inslug
,
false
)
);
if
(
empty
(
$inslug
))
$errors
[
'slug'
]
=
qa_lang
(
'main/field_required'
);
elseif
(
qa_strlen
(
$inslug
)
>
QA_DB_MAX_CAT_PAGE_TAGS_LENGTH
)
$errors
[
'slug'
]
=
qa_lang_sub
(
'main/max_length_x'
,
QA_DB_MAX_CAT_PAGE_TAGS_LENGTH
);
elseif
(
preg_match
(
'/[\\+\\/]/'
,
$inslug
))
$errors
[
'slug'
]
=
qa_lang_sub
(
'admin/slug_bad_chars'
,
'+ /'
);
elseif
(
qa_admin_is_slug_reserved
(
$inslug
))
$errors
[
'slug'
]
=
qa_lang
(
'admin/slug_reserved'
);
elseif
(
isset
(
$matchpage
)
&&
(
$matchpage
[
'pageid'
]
!=
@
$editpage
[
'pageid'
]))
$errors
[
'slug'
]
=
qa_lang
(
'admin/page_already_used'
);
elseif
(
isset
(
$matchcategoryid
))
$errors
[
'slug'
]
=
qa_lang
(
'admin/category_already_used'
);
else
unset
(
$errors
[
'slug'
]);
if
(
isset
(
$editpage
[
'pageid'
])
||
!
isset
(
$errors
[
'slug'
]))
// don't try other options if editing existing page
break
;
}
}
}
// Perform appropriate database action
// Perform appropriate database action
if
(
isset
(
$editpage
[
'pageid'
]))
{
// changing existing page
if
(
isset
(
$editpage
[
'pageid'
]))
{
// changing existing page
if
(
$isexternal
)
if
(
$isexternal
)
{
qa_db_page_set_fields
(
$editpage
[
'pageid'
],
qa_db_page_set_fields
(
$editpage
[
'pageid'
],
isset
(
$errors
[
'name'
])
?
$editpage
[
'title'
]
:
$inname
,
isset
(
$errors
[
'name'
])
?
$editpage
[
'title'
]
:
$inname
,
QA_PAGE_FLAGS_EXTERNAL
|
(
$innewwindow
?
QA_PAGE_FLAGS_NEW_WINDOW
:
0
),
QA_PAGE_FLAGS_EXTERNAL
|
(
$innewwindow
?
QA_PAGE_FLAGS_NEW_WINDOW
:
0
),
isset
(
$errors
[
'url'
])
?
$editpage
[
'tags'
]
:
$inurl
,
isset
(
$errors
[
'url'
])
?
$editpage
[
'tags'
]
:
$inurl
,
null
,
null
,
$inpermit
);
null
,
null
,
$inpermit
);
else
{
$setheading
=
isset
(
$errors
[
'heading'
])
?
$editpage
[
'heading'
]
:
$inheading
;
$setslug
=
isset
(
$errors
[
'slug'
])
?
$editpage
[
'tags'
]
:
$inslug
;
$setcontent
=
isset
(
$errors
[
'content'
])
?
$editpage
[
'content'
]
:
$incontent
;
qa_db_page_set_fields
(
$editpage
[
'pageid'
],
isset
(
$errors
[
'name'
])
?
$editpage
[
'title'
]
:
$inname
,
0
,
$setslug
,
$setheading
,
$setcontent
,
$inpermit
);
$searchmodules
=
qa_load_modules_with
(
'search'
,
'unindex_page'
);
foreach
(
$searchmodules
as
$searchmodule
)
$searchmodule
->
unindex_page
(
$editpage
[
'pageid'
]);
$indextext
=
qa_viewer_text
(
$setcontent
,
'html'
);
}
else
{
$setheading
=
isset
(
$errors
[
'heading'
])
?
$editpage
[
'heading'
]
:
$inheading
;
$setslug
=
isset
(
$errors
[
'slug'
])
?
$editpage
[
'tags'
]
:
$inslug
;
$setcontent
=
isset
(
$errors
[
'content'
])
?
$editpage
[
'content'
]
:
$incontent
;
$searchmodules
=
qa_load_modules_with
(
'search'
,
'index_page'
);
qa_db_page_set_fields
(
$editpage
[
'pageid'
],
foreach
(
$searchmodules
as
$searchmodule
)
isset
(
$errors
[
'name'
])
?
$editpage
[
'title'
]
:
$inname
,
$searchmodule
->
index_page
(
$editpage
[
'pageid'
],
$setslug
,
$setheading
,
$setcontent
,
'html'
,
$indextext
);
0
,
}
$setslug
,
$setheading
,
$setcontent
,
$inpermit
);
qa_db_page_move
(
$editpage
[
'pageid'
],
substr
(
$inposition
,
0
,
1
),
substr
(
$inposition
,
1
));
$searchmodules
=
qa_load_modules_with
(
'search'
,
'unindex_page'
);
foreach
(
$searchmodules
as
$searchmodule
)
$searchmodule
->
unindex_page
(
$editpage
[
'pageid'
]);
$
reloadpages
=
true
;
$
indextext
=
qa_viewer_text
(
$setcontent
,
'html'
)
;
if
(
empty
(
$errors
))
$searchmodules
=
qa_load_modules_with
(
'search'
,
'index_page'
);
$editpage
=
null
;
foreach
(
$searchmodules
as
$searchmodule
)
else
$searchmodule
->
index_page
(
$editpage
[
'pageid'
],
$setslug
,
$setheading
,
$setcontent
,
'html'
,
$indextext
);
$editpage
=@
$pages
[
$editpage
[
'pageid'
]];
}
}
else
{
// creating a new one
qa_db_page_move
(
$editpage
[
'pageid'
],
substr
(
$inposition
,
0
,
1
),
substr
(
$inposition
,
1
));
if
(
empty
(
$errors
))
{
if
(
$isexternal
)
$pageid
=
qa_db_page_create
(
$inname
,
QA_PAGE_FLAGS_EXTERNAL
|
(
$innewwindow
?
QA_PAGE_FLAGS_NEW_WINDOW
:
0
),
$inurl
,
null
,
null
,
$inpermit
);
else
{
$pageid
=
qa_db_page_create
(
$inname
,
0
,
$inslug
,
$inheading
,
$incontent
,
$inpermit
);
$indextext
=
qa_viewer_text
(
$incontent
,
'html'
)
;
$reloadpages
=
true
;
$searchmodules
=
qa_load_modules_with
(
'search'
,
'index_page'
);
if
(
empty
(
$errors
))
foreach
(
$searchmodules
as
$searchmodule
)
$editpage
=
null
;
$searchmodule
->
index_page
(
$pageid
,
$inslug
,
$inheading
,
$incontent
,
'html'
,
$indextext
);
else
}
$editpage
=
@
$pages
[
$editpage
[
'pageid'
]];
qa_db_page_move
(
$pageid
,
substr
(
$inposition
,
0
,
1
),
substr
(
$inposition
,
1
));
}
else
{
// creating a new one
if
(
empty
(
$errors
))
{
if
(
$isexternal
)
{
$pageid
=
qa_db_page_create
(
$inname
,
QA_PAGE_FLAGS_EXTERNAL
|
(
$innewwindow
?
QA_PAGE_FLAGS_NEW_WINDOW
:
0
),
$inurl
,
null
,
null
,
$inpermit
);
}
else
{
$pageid
=
qa_db_page_create
(
$inname
,
0
,
$inslug
,
$inheading
,
$incontent
,
$inpermit
);
$editpage
=
null
;
$indextext
=
qa_viewer_text
(
$incontent
,
'html'
);
$reloadpages
=
true
;
$searchmodules
=
qa_load_modules_with
(
'search'
,
'index_page'
);
foreach
(
$searchmodules
as
$searchmodule
)
$searchmodule
->
index_page
(
$pageid
,
$inslug
,
$inheading
,
$incontent
,
'html'
,
$indextext
);
}
}
}
if
(
qa_clicked
(
'dosaveview'
)
&&
empty
(
$errors
)
&&
!
$isexternal
)
qa_db_page_move
(
$pageid
,
substr
(
$inposition
,
0
,
1
),
substr
(
$inposition
,
1
));
qa_redirect
(
$inslug
);
}
if
(
$reloadpages
)
{
$editpage
=
null
;
qa_db_flush_pending_result
(
'navpages'
)
;
$reloadpages
=
true
;
$pages
=
qa_db_select_with_pending
(
qa_db_pages_selectspec
());
}
}
}
if
(
qa_clicked
(
'dosaveview'
)
&&
empty
(
$errors
)
&&
!
$isexternal
)
qa_redirect
(
$inslug
);
}
if
(
$reloadpages
)
{
qa_db_flush_pending_result
(
'navpages'
);
$pages
=
qa_db_select_with_pending
(
qa_db_pages_selectspec
());
}
}
}
}
}
// Prepare content for theme
// Prepare content for theme
$qa_content
=
qa_content_prepare
();
$qa_content
=
qa_content_prepare
();
$qa_content
[
'title'
]
=
qa_lang_html
(
'admin/admin_title'
)
.
' - '
.
qa_lang_html
(
'admin/pages_title'
);
$qa_content
[
'error'
]
=
$securityexpired
?
qa_lang_html
(
'admin/form_security_expired'
)
:
qa_admin_page_error
();
if
(
isset
(
$editpage
))
{
$qa_content
[
'title'
]
=
qa_lang_html
(
'admin/admin_title'
)
.
' - '
.
qa_lang_html
(
'admin/pages_title'
);
$positionoptions
=
array
();
$qa_content
[
'error'
]
=
$securityexpired
?
qa_lang_html
(
'admin/form_security_expired'
)
:
qa_admin_page_error
();
if
(
!
$isexternal
)
if
(
isset
(
$editpage
))
{
$positionoptions
[
'_'
.
max
(
1
,
@
$editpage
[
'position'
])]
=
qa_lang_html
(
'admin/no_link'
);
$positionoptions
=
array
(
);
$navlangkey
=
array
(
if
(
!
$isexternal
)
'B'
=>
'admin/before_main_menu'
,
$positionoptions
[
'_'
.
max
(
1
,
@
$editpage
[
'position'
])]
=
qa_lang_html
(
'admin/no_link'
);
'M'
=>
'admin/after_main_menu'
,
'O'
=>
'admin/opposite_main_menu'
,
'F'
=>
'admin/after_footer'
,
);
foreach
(
$navlangkey
as
$nav
=>
$langkey
)
{
$navlangkey
=
array
(
$previous
=
null
;
'B'
=>
'admin/before_main_menu'
,
$passedself
=
false
;
'M'
=>
'admin/after_main_menu'
,
$maxposition
=
0
;
'O'
=>
'admin/opposite_main_menu'
,
'F'
=>
'admin/after_footer'
,
);
foreach
(
$pages
as
$key
=>
$page
)
foreach
(
$navlangkey
as
$nav
=>
$langkey
)
{
if
(
$page
[
'nav'
]
==
$nav
)
{
$previous
=
null
;
if
(
isset
(
$previous
))
$passedself
=
false
;
$positionhtml
=
qa_lang_html_sub
(
'admin/after_x_tab'
,
qa_html
(
$passedself
?
$page
[
'title'
]
:
$previous
[
'title'
]));
$maxposition
=
0
;
else
$positionhtml
=
qa_lang_html
(
$langkey
);
if
(
$page
[
'pageid'
]
==@
$editpage
[
'pageid'
])
foreach
(
$pages
as
$key
=>
$page
)
{
$passedself
=
true
;
if
(
$page
[
'nav'
]
==
$nav
)
{
if
(
isset
(
$previous
))
$positionhtml
=
qa_lang_html_sub
(
'admin/after_x_tab'
,
qa_html
(
$passedself
?
$page
[
'title'
]
:
$previous
[
'title'
]));
else
$positionhtml
=
qa_lang_html
(
$langkey
);
$maxposition
=
max
(
$maxposition
,
$page
[
'position'
]);
if
(
$page
[
'pageid'
]
==
@
$editpage
[
'pageid'
])
$p
ositionoptions
[
$nav
.
$page
[
'position'
]]
=
$positionhtml
;
$p
assedself
=
true
;
$previous
=
$page
;
$maxposition
=
max
(
$maxposition
,
$page
[
'position'
])
;
}
$positionoptions
[
$nav
.
$page
[
'position'
]]
=
$positionhtml
;
if
((
!
isset
(
$editpage
[
'pageid'
]))
||
$nav
!=@
$editpage
[
'nav'
])
{
$previous
=
$page
;
$positionvalue
=
isset
(
$previous
)
?
qa_lang_html_sub
(
'admin/after_x_tab'
,
qa_html
(
$previous
[
'title'
]))
:
qa_lang_html
(
$langkey
);
$positionoptions
[
$nav
.
(
isset
(
$previous
)
?
(
1
+
$maxposition
)
:
1
)]
=
$positionvalue
;
}
}
}
}
$positionvalue
=@
$positionoptions
[
$editpage
[
'nav'
]
.
$editpage
[
'position'
]];
if
((
!
isset
(
$editpage
[
'pageid'
]))
||
$nav
!=
@
$editpage
[
'nav'
])
{
$positionvalue
=
isset
(
$previous
)
?
qa_lang_html_sub
(
'admin/after_x_tab'
,
qa_html
(
$previous
[
'title'
]))
:
qa_lang_html
(
$langkey
);
$permitoptions
=
qa_admin_permit_options
(
QA_PERMIT_ALL
,
QA_PERMIT_ADMINS
,
false
,
false
);
$positionoptions
[
$nav
.
(
isset
(
$previous
)
?
(
1
+
$maxposition
)
:
1
)]
=
$positionvalue
;
$permitvalue
=@
$permitoptions
[
isset
(
$inpermit
)
?
$inpermit
:
$editpage
[
'permit'
]];
}
}
$qa_content
[
'form'
]
=
array
(
'tags'
=>
'method="post" action="'
.
qa_path_html
(
qa_request
())
.
'"'
,
$positionvalue
=
@
$positionoptions
[
$editpage
[
'nav'
]
.
$editpage
[
'position'
]];
'style'
=>
'tall'
,
$permitoptions
=
qa_admin_permit_options
(
QA_PERMIT_ALL
,
QA_PERMIT_ADMINS
,
false
,
false
);
$permitvalue
=
@
$permitoptions
[
isset
(
$inpermit
)
?
$inpermit
:
$editpage
[
'permit'
]];
'fields'
=>
array
(
'name'
=>
array
(
$qa_content
[
'form'
]
=
array
(
'tags'
=>
'name="name" id="name"'
,
'tags'
=>
'method="post" action="'
.
qa_path_html
(
qa_request
())
.
'"'
,
'label'
=>
qa_lang_html
(
$isexternal
?
'admin/link_name'
:
'admin/page_name'
),
'value'
=>
qa_html
(
isset
(
$inname
)
?
$inname
:
@
$editpage
[
'title'
]),
'style'
=>
'tall'
,
'error'
=>
qa_html
(
@
$errors
[
'name'
]),
),
'fields'
=>
array
(
'name'
=>
array
(
'delete'
=>
array
(
'tags'
=>
'name="name" id="name"'
,
'tags'
=>
'name="dodelete" id="dodelete"'
,
'label'
=>
qa_lang_html
(
$isexternal
?
'admin/link_name'
:
'admin/page_name'
),
'label'
=>
qa_lang_html
(
$isexternal
?
'admin/delete_link'
:
'admin/delete_page'
),
'value'
=>
qa_html
(
isset
(
$inname
)
?
$inname
:
@
$editpage
[
'title'
]),
'value'
=>
0
,
'error'
=>
qa_html
(
@
$errors
[
'name'
]),
'type'
=>
'checkbox'
,
),
),
'delete'
=>
array
(
'position'
=>
array
(
'tags'
=>
'name="dodelete" id="dodelete"'
,
'id'
=>
'position_display'
,
'label'
=>
qa_lang_html
(
$isexternal
?
'admin/delete_link'
:
'admin/delete_page'
),
'tags'
=>
'name="position"'
,
'value'
=>
0
,
'label'
=>
qa_lang_html
(
'admin/position'
),
'type'
=>
'checkbox'
,
'type'
=>
'select'
,
'options'
=>
$positionoptions
,
'value'
=>
$positionvalue
,
),
'permit'
=>
array
(
'id'
=>
'permit_display'
,
'tags'
=>
'name="permit"'
,
'label'
=>
qa_lang_html
(
'admin/permit_to_view'
),
'type'
=>
'select'
,
'options'
=>
$permitoptions
,
'value'
=>
$permitvalue
,
),
'slug'
=>
array
(
'id'
=>
'slug_display'
,
'tags'
=>
'name="slug"'
,
'label'
=>
qa_lang_html
(
'admin/page_slug'
),
'value'
=>
qa_html
(
isset
(
$inslug
)
?
$inslug
:
@
$editpage
[
'tags'
]),
'error'
=>
qa_html
(
@
$errors
[
'slug'
]),
),
'url'
=>
array
(
'id'
=>
'url_display'
,
'tags'
=>
'name="url"'
,
'label'
=>
qa_lang_html
(
'admin/link_url'
),
'value'
=>
qa_html
(
isset
(
$inurl
)
?
$inurl
:
@
$editpage
[
'tags'
]),
'error'
=>
qa_html
(
@
$errors
[
'url'
]),
),
'newwindow'
=>
array
(
'id'
=>
'newwindow_display'
,
'tags'
=>
'name="newwindow"'
,
'label'
=>
qa_lang_html
(
'admin/link_new_window'
),
'value'
=>
(
isset
(
$innewwindow
)
?
$innewwindow
:
(
@
$editpage
[
'flags'
]
&
QA_PAGE_FLAGS_NEW_WINDOW
))
?
1
:
0
,
'type'
=>
'checkbox'
,
),
'heading'
=>
array
(
'id'
=>
'heading_display'
,
'tags'
=>
'name="heading"'
,
'label'
=>
qa_lang_html
(
'admin/page_heading'
),
'value'
=>
qa_html
(
isset
(
$inheading
)
?
$inheading
:
@
$editpage
[
'heading'
]),
'error'
=>
qa_html
(
@
$errors
[
'heading'
]),
),
'content'
=>
array
(
'id'
=>
'content_display'
,
'tags'
=>
'name="content"'
,
'label'
=>
qa_lang_html
(
'admin/page_content_html'
),
'value'
=>
qa_html
(
isset
(
$incontent
)
?
$incontent
:
@
$editpage
[
'content'
]),
'error'
=>
qa_html
(
@
$errors
[
'content'
]),
'rows'
=>
16
,
),
),
),
'buttons'
=>
array
(
'position'
=>
array
(
'save'
=>
array
(
'id'
=>
'position_display'
,
'label'
=>
qa_lang_html
(
isset
(
$editpage
[
'pageid'
])
?
'main/save_button'
:
(
$isexternal
?
'admin/add_link_button'
:
'admin/add_page_button'
)),
'tags'
=>
'name="position"'
,
),
'label'
=>
qa_lang_html
(
'admin/position'
),
'type'
=>
'select'
,
'options'
=>
$positionoptions
,
'value'
=>
$positionvalue
,
),
'saveview'
=>
array
(
'permit'
=>
array
(
'tags'
=>
'name="dosaveview"'
,
'id'
=>
'permit_display'
,
'label'
=>
qa_lang_html
(
'admin/save_view_button'
),
'tags'
=>
'name="permit"'
,
),
'label'
=>
qa_lang_html
(
'admin/permit_to_view'
),
'type'
=>
'select'
,
'options'
=>
$permitoptions
,
'value'
=>
$permitvalue
,
),
'cancel'
=>
array
(
'slug'
=>
array
(
'tags'
=>
'name="docancel"'
,
'id'
=>
'slug_display'
,
'label'
=>
qa_lang_html
(
'main/cancel_button'
),
'tags'
=>
'name="slug"'
,
),
'label'
=>
qa_lang_html
(
'admin/page_slug'
),
'value'
=>
qa_html
(
isset
(
$inslug
)
?
$inslug
:
@
$editpage
[
'tags'
]),
'error'
=>
qa_html
(
@
$errors
[
'slug'
]),
),
),
'hidden'
=>
array
(
'url'
=>
array
(
'dosavepage'
=>
'1'
,
// for IE
'id'
=>
'url_display'
,
'edit'
=>
@
$editpage
[
'pageid'
],
'tags'
=>
'name="url"'
,
'external'
=>
(
int
)
$isexternal
,
'label'
=>
qa_lang_html
(
'admin/link_url'
),
'code'
=>
qa_get_form_security_code
(
'admin/pages'
),
'value'
=>
qa_html
(
isset
(
$inurl
)
?
$inurl
:
@
$editpage
[
'tags'
]),
'error'
=>
qa_html
(
@
$errors
[
'url'
]),
),
),
);
if
(
$isexternal
)
{
'newwindow'
=>
array
(
unset
(
$qa_content
[
'form'
][
'fields'
][
'slug'
]);
'id'
=>
'newwindow_display'
,
unset
(
$qa_content
[
'form'
][
'fields'
][
'heading'
]);
'tags'
=>
'name="newwindow"'
,
unset
(
$qa_content
[
'form'
][
'fields'
][
'content'
]);
'label'
=>
qa_lang_html
(
'admin/link_new_window'
),
'value'
=>
(
isset
(
$innewwindow
)
?
$innewwindow
:
(
@
$editpage
[
'flags'
]
&
QA_PAGE_FLAGS_NEW_WINDOW
))
?
1
:
0
,
'type'
=>
'checkbox'
,
),
}
else
{
'heading'
=>
array
(
unset
(
$qa_content
[
'form'
][
'fields'
][
'url'
]);
'id'
=>
'heading_display'
,
unset
(
$qa_content
[
'form'
][
'fields'
][
'newwindow'
]);
'tags'
=>
'name="heading"'
,
}
'label'
=>
qa_lang_html
(
'admin/page_heading'
),
'value'
=>
qa_html
(
isset
(
$inheading
)
?
$inheading
:
@
$editpage
[
'heading'
]),
'error'
=>
qa_html
(
@
$errors
[
'heading'
]),
),
if
(
isset
(
$editpage
[
'pageid'
]))
'content'
=>
array
(
qa_set_display_rules
(
$qa_content
,
array
(
'id'
=>
'content_display'
,
'position_display'
=>
'!dodelete'
,
'tags'
=>
'name="content"'
,
'permit_display'
=>
'!dodelete'
,
'label'
=>
qa_lang_html
(
'admin/page_content_html'
),
(
$isexternal
?
'url_display'
:
'slug_display'
)
=>
'!dodelete'
,
'value'
=>
qa_html
(
isset
(
$incontent
)
?
$incontent
:
@
$editpage
[
'content'
]),
(
$isexternal
?
'newwindow_display'
:
'heading_display'
)
=>
'!dodelete'
,
'error'
=>
qa_html
(
@
$errors
[
'content'
]),
'content_display'
=>
'!dodelete'
,
'rows'
=>
16
,
));
),
),
else
{
'buttons'
=>
array
(
unset
(
$qa_content
[
'form'
][
'fields'
][
'slug'
]);
'save'
=>
array
(
unset
(
$qa_content
[
'form'
][
'fields'
][
'delete'
]);
'label'
=>
qa_lang_html
(
isset
(
$editpage
[
'pageid'
])
?
'main/save_button'
:
(
$isexternal
?
'admin/add_link_button'
:
'admin/add_page_button'
)),
}
),
if
(
$isexternal
||
!
isset
(
$editpage
[
'pageid'
]))
'saveview'
=>
array
(
unset
(
$qa_content
[
'form'
][
'buttons'
][
'saveview'
]);
'tags'
=>
'name="dosaveview"'
,
'label'
=>
qa_lang_html
(
'admin/save_view_button'
),
),
$qa_content
[
'focusid'
]
=
'name'
;
'cancel'
=>
array
(
'tags'
=>
'name="docancel"'
,
'label'
=>
qa_lang_html
(
'main/cancel_button'
),
),
),
'hidden'
=>
array
(
'dosavepage'
=>
'1'
,
// for IE
'edit'
=>
@
$editpage
[
'pageid'
],
'external'
=>
(
int
)
$isexternal
,
'code'
=>
qa_get_form_security_code
(
'admin/pages'
),
),
);
if
(
$isexternal
)
{
unset
(
$qa_content
[
'form'
][
'fields'
][
'slug'
]);
unset
(
$qa_content
[
'form'
][
'fields'
][
'heading'
]);
unset
(
$qa_content
[
'form'
][
'fields'
][
'content'
]);
}
else
{
}
else
{
unset
(
$qa_content
[
'form'
][
'fields'
][
'url'
]);
unset
(
$qa_content
[
'form'
][
'fields'
][
'newwindow'
]);
}
// List of standard navigation links
if
(
isset
(
$editpage
[
'pageid'
]))
{
qa_set_display_rules
(
$qa_content
,
array
(
'position_display'
=>
'!dodelete'
,
'permit_display'
=>
'!dodelete'
,
(
$isexternal
?
'url_display'
:
'slug_display'
)
=>
'!dodelete'
,
(
$isexternal
?
'newwindow_display'
:
'heading_display'
)
=>
'!dodelete'
,
'content_display'
=>
'!dodelete'
,
));
$qa_content
[
'form'
]
=
array
(
}
else
{
'tags'
=>
'method="post" action="'
.
qa_self_html
()
.
'"'
,
unset
(
$qa_content
[
'form'
][
'fields'
][
'slug'
]);
unset
(
$qa_content
[
'form'
][
'fields'
][
'delete'
]);
}
'style'
=>
'tall'
,
if
(
$isexternal
||
!
isset
(
$editpage
[
'pageid'
]))
unset
(
$qa_content
[
'form'
][
'buttons'
][
'saveview'
]);
'fields'
=>
array
(),
$qa_content
[
'focusid'
]
=
'name'
;
'buttons'
=>
array
(
}
else
{
'save'
=>
array
(
'tags'
=>
'name="dosaveoptions"'
,
'label'
=>
qa_lang_html
(
'main/save_button'
),
),
'addpage'
=>
array
(
// List of standard navigation links
'tags'
=>
'name="doaddpage"'
,
'label'
=>
qa_lang_html
(
'admin/add_page_button'
),
$qa_content
[
'form'
]
=
array
(
),
'tags'
=>
'method="post" action="'
.
qa_self_html
()
.
'"'
,
'style'
=>
'tall'
,
'addlink'
=>
array
(
'fields'
=>
array
(),
'tags'
=>
'name="doaddlink"'
,
'label'
=>
qa_lang_html
(
'admin/add_link_button'
),
'buttons'
=>
array
(
),
'save'
=>
array
(
'tags'
=>
'name="dosaveoptions"'
,
'label'
=>
qa_lang_html
(
'main/save_button'
),
),
),
'hidden'
=>
array
(
'addpage'
=>
array
(
'code'
=>
qa_get_form_security_code
(
'admin/pages'
),
'tags'
=>
'name="doaddpage"'
,
'label'
=>
qa_lang_html
(
'admin/add_page_button'
),
),
),
);
$qa_content
[
'form'
][
'fields'
][
'navlinks'
]
=
array
(
'addlink'
=>
array
(
'label'
=>
qa_lang_html
(
'admin/nav_links_explanation'
)
,
'tags'
=>
'name="doaddlink"'
,
'type'
=>
'static'
,
'label'
=>
qa_lang_html
(
'admin/add_link_button'
)
,
'tight'
=>
true
,
)
,
)
;
)
,
foreach
(
$navoptions
as
$optionname
=>
$langkey
)
{
'hidden'
=>
array
(
$qa_content
[
'form'
][
'fields'
][
$optionname
]
=
array
(
'code'
=>
qa_get_form_security_code
(
'admin/pages'
),
'label'
=>
'<a href="'
.
qa_path_html
(
$navpaths
[
$optionname
])
.
'">'
.
qa_lang_html
(
$langkey
)
.
'</a>'
,
),
'tags'
=>
'name="option_'
.
$optionname
.
'"'
,
);
'type'
=>
'checkbox'
,
'value'
=>
qa_opt
(
$optionname
),
);
}
$qa_content
[
'form'
][
'fields'
][]
=
array
(
$qa_content
[
'form'
][
'fields'
][
'navlinks'
]
=
array
(
'type'
=>
'blank'
'label'
=>
qa_lang_html
(
'admin/nav_links_explanation'
),
'type'
=>
'static'
,
'tight'
=>
true
,
);
foreach
(
$navoptions
as
$optionname
=>
$langkey
)
{
$qa_content
[
'form'
][
'fields'
][
$optionname
]
=
array
(
'label'
=>
'<a href="'
.
qa_path_html
(
$navpaths
[
$optionname
])
.
'">'
.
qa_lang_html
(
$langkey
)
.
'</a>'
,
'tags'
=>
'name="option_'
.
$optionname
.
'"'
,
'type'
=>
'checkbox'
,
'value'
=>
qa_opt
(
$optionname
),
);
);
}
$qa_content
[
'form'
][
'fields'
][]
=
array
(
'type'
=>
'blank'
);
// List of suggested plugin pages
// List of suggested plugin pages
$listhtml
=
''
;
$listhtml
=
''
;
$pagemodules
=
qa_load_modules_with
(
'page'
,
'suggest_requests'
);
$pagemodules
=
qa_load_modules_with
(
'page'
,
'suggest_requests'
);
foreach
(
$pagemodules
as
$tryname
=>
$trypage
)
{
foreach
(
$pagemodules
as
$tryname
=>
$trypage
)
{
$suggestrequests
=
$trypage
->
suggest_requests
();
$suggestrequests
=
$trypage
->
suggest_requests
();
foreach
(
$suggestrequests
as
$suggestrequest
)
{
foreach
(
$suggestrequests
as
$suggestrequest
)
{
$listhtml
.=
'<li><b><a href="'
.
qa_path_html
(
$suggestrequest
[
'request'
])
.
'">'
.
qa_html
(
$suggestrequest
[
'title'
])
.
'</a></b>'
;
$listhtml
.=
'<li><b><a href="'
.
qa_path_html
(
$suggestrequest
[
'request'
])
.
'">'
.
qa_html
(
$suggestrequest
[
'title'
])
.
'</a></b>'
;
$listhtml
.=
qa_lang_html_sub
(
'admin/plugin_module'
,
qa_html
(
$tryname
));
$listhtml
.=
qa_lang_html_sub
(
'admin/plugin_module'
,
qa_html
(
$tryname
));
$listhtml
.=
strtr
(
qa_lang_html
(
'admin/add_link_link'
),
array
(
$listhtml
.=
strtr
(
qa_lang_html
(
'admin/add_link_link'
),
array
(
'^1'
=>
'<a href="'
.
qa_path_html
(
qa_request
(),
array
(
'doaddlink'
=>
1
,
'text'
=>
$suggestrequest
[
'title'
],
'url'
=>
$suggestrequest
[
'request'
],
'nav'
=>
@
$suggestrequest
[
'nav'
]))
.
'">'
,
'^1'
=>
'<a href="'
.
qa_path_html
(
qa_request
(),
array
(
'doaddlink'
=>
1
,
'text'
=>
$suggestrequest
[
'title'
],
'url'
=>
$suggestrequest
[
'request'
],
'nav'
=>
@
$suggestrequest
[
'nav'
]))
.
'">'
,
'^2'
=>
'</a>'
,
'^2'
=>
'</a>'
,
));
));
if
(
method_exists
(
$trypage
,
'admin_form'
))
if
(
method_exists
(
$trypage
,
'admin_form'
))
$listhtml
.=
' - <a href="'
.
qa_admin_module_options_path
(
'page'
,
$tryname
)
.
'">'
.
qa_lang_html
(
'admin/options'
)
.
'</a>'
;
$listhtml
.=
' - <a href="'
.
qa_admin_module_options_path
(
'page'
,
$tryname
)
.
'">'
.
qa_lang_html
(
'admin/options'
)
.
'</a>'
;
$listhtml
.=
'</li>'
;
$listhtml
.=
'</li>'
;
}
}
}
}
if
(
strlen
(
$listhtml
))
if
(
strlen
(
$listhtml
))
{
$qa_content
[
'form'
][
'fields'
][
'plugins'
]
=
array
(
$qa_content
[
'form'
][
'fields'
][
'plugins'
]
=
array
(
'label'
=>
qa_lang_html
(
'admin/plugin_pages_explanation'
),
'label'
=>
qa_lang_html
(
'admin/plugin_pages_explanation'
),
'type'
=>
'custom'
,
'type'
=>
'custom'
,
'html'
=>
'<ul style="margin-bottom:0;">'
.
$listhtml
.
'</ul>'
,
'html'
=>
'<ul style="margin-bottom:0;">'
.
$listhtml
.
'</ul>'
,
);
);
}
// List of custom pages or links
// List of custom pages or links
$listhtml
=
''
;
$listhtml
=
''
;
foreach
(
$pages
as
$page
)
{
foreach
(
$pages
as
$page
)
{
$listhtml
.=
'<li><b><a href="'
.
qa_custom_page_url
(
$page
)
.
'">'
.
qa_html
(
$page
[
'title'
])
.
'</a></b>'
;
$listhtml
.=
'<li><b><a href="'
.
qa_custom_page_url
(
$page
)
.
'">'
.
qa_html
(
$page
[
'title'
])
.
'</a></b>'
;
$listhtml
.=
strtr
(
qa_lang_html
((
$page
[
'flags'
]
&
QA_PAGE_FLAGS_EXTERNAL
)
?
'admin/edit_link'
:
'admin/edit_page'
),
array
(
$listhtml
.=
strtr
(
qa_lang_html
((
$page
[
'flags'
]
&
QA_PAGE_FLAGS_EXTERNAL
)
?
'admin/edit_link'
:
'admin/edit_page'
),
array
(
'^1'
=>
'<a href="'
.
qa_path_html
(
'admin/pages'
,
array
(
'edit'
=>
$page
[
'pageid'
]))
.
'">'
,
'^1'
=>
'<a href="'
.
qa_path_html
(
'admin/pages'
,
array
(
'edit'
=>
$page
[
'pageid'
]))
.
'">'
,
'^2'
=>
'</a>'
,
'^2'
=>
'</a>'
,
));
));
$listhtml
.=
'</li>'
;
}
$qa_content
[
'form'
][
'fields'
][
'pages'
]
=
array
(
$listhtml
.=
'</li>'
;
'label'
=>
strlen
(
$listhtml
)
?
qa_lang_html
(
'admin/click_name_edit'
)
:
qa_lang_html
(
'admin/pages_explanation'
),
'type'
=>
'custom'
,
'html'
=>
strlen
(
$listhtml
)
?
'<ul style="margin-bottom:0;">'
.
$listhtml
.
'</ul>'
:
null
,
);
}
}
$qa_content
[
'navigation'
][
'sub'
]
=
qa_admin_sub_navigation
();
$qa_content
[
'form'
][
'fields'
][
'pages'
]
=
array
(
'label'
=>
strlen
(
$listhtml
)
?
qa_lang_html
(
'admin/click_name_edit'
)
:
qa_lang_html
(
'admin/pages_explanation'
),
'type'
=>
'custom'
,
'html'
=>
strlen
(
$listhtml
)
?
'<ul style="margin-bottom:0;">'
.
$listhtml
.
'</ul>'
:
null
,
);
}
return
$qa_content
;
$qa_content
[
'navigation'
][
'sub'
]
=
qa_admin_sub_navigation
()
;
/*
return
$qa_content
;
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
qa-include/pages/admin/admin-plugins.php
View file @
14d54fd4
...
@@ -20,211 +20,204 @@
...
@@ -20,211 +20,204 @@
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
;
}
}
require_once
QA_INCLUDE_DIR
.
'app/admin.php'
;
require_once
QA_INCLUDE_DIR
.
'app/admin.php'
;
// Check admin privileges
// Check admin privileges
if
(
!
qa_admin_check_privileges
(
$qa_content
))
if
(
!
qa_admin_check_privileges
(
$qa_content
))
return
$qa_content
;
return
$qa_content
;
// Map modules with options to their containing plugins
// Map modules with options to their containing plugins
$pluginoptionmodules
=
array
();
$pluginoptionmodules
=
array
();
$tables
=
qa_db_list_tables
();
$tables
=
qa_db_list_tables
();
$moduletypes
=
qa_list_module_types
();
$moduletypes
=
qa_list_module_types
();
foreach
(
$moduletypes
as
$type
)
{
foreach
(
$moduletypes
as
$type
)
{
$modules
=
qa_list_modules
(
$type
);
$modules
=
qa_list_modules
(
$type
);
foreach
(
$modules
as
$name
)
{
foreach
(
$modules
as
$name
)
{
$module
=
qa_load_module
(
$type
,
$name
);
$module
=
qa_load_module
(
$type
,
$name
);
if
(
method_exists
(
$module
,
'admin_form'
))
{
if
(
method_exists
(
$module
,
'admin_form'
))
{
$info
=
qa_get_module_info
(
$type
,
$name
);
$info
=
qa_get_module_info
(
$type
,
$name
);
$dir
=
rtrim
(
$info
[
'directory'
],
'/'
);
$dir
=
rtrim
(
$info
[
'directory'
],
'/'
);
$pluginoptionmodules
[
$dir
][]
=
array
(
$pluginoptionmodules
[
$dir
][]
=
array
(
'type'
=>
$type
,
'type'
=>
$type
,
'name'
=>
$name
,
'name'
=>
$name
,
);
);
}
}
}
}
}
}
// Prepare content for theme
// Prepare content for theme
$qa_content
=
qa_content_prepare
();
$qa_content
=
qa_content_prepare
();
$qa_content
[
'title'
]
=
qa_lang_html
(
'admin/admin_title'
)
.
' - '
.
qa_lang_html
(
'admin/plugins_title'
);
$qa_content
[
'title'
]
=
qa_lang_html
(
'admin/admin_title'
)
.
' - '
.
qa_lang_html
(
'admin/plugins_title'
);
$qa_content
[
'error'
]
=
qa_admin_page_error
();
$qa_content
[
'error'
]
=
qa_admin_page_error
();
$qa_content
[
'script_rel'
][]
=
'qa-content/qa-admin.js?'
.
QA_VERSION
;
$qa_content
[
'script_rel'
][]
=
'qa-content/qa-admin.js?'
.
QA_VERSION
;
$pluginfiles
=
glob
(
QA_PLUGIN_DIR
.
'*/qa-plugin.php'
);
$pluginfiles
=
glob
(
QA_PLUGIN_DIR
.
'*/qa-plugin.php'
);
foreach
(
$moduletypes
as
$type
)
{
foreach
(
$moduletypes
as
$type
)
{
$modules
=
qa_load_modules_with
(
$type
,
'init_queries'
);
$modules
=
qa_load_modules_with
(
$type
,
'init_queries'
);
foreach
(
$modules
as
$name
=>
$module
)
{
foreach
(
$modules
as
$name
=>
$module
)
{
$queries
=
$module
->
init_queries
(
$tables
);
$queries
=
$module
->
init_queries
(
$tables
);
if
(
!
empty
(
$queries
))
{
if
(
!
empty
(
$queries
))
{
if
(
qa_is_http_post
())
if
(
qa_is_http_post
())
qa_redirect
(
'install'
);
qa_redirect
(
'install'
);
else
{
else
{
$qa_content
[
'error'
]
=
strtr
(
qa_lang_html
(
'admin/module_x_database_init'
),
array
(
$qa_content
[
'error'
]
=
strtr
(
qa_lang_html
(
'admin/module_x_database_init'
),
array
(
'^1'
=>
qa_html
(
$name
),
'^1'
=>
qa_html
(
$name
),
'^2'
=>
qa_html
(
$type
),
'^2'
=>
qa_html
(
$type
),
'^3'
=>
'<a href="'
.
qa_path_html
(
'install'
)
.
'">'
,
'^3'
=>
'<a href="'
.
qa_path_html
(
'install'
)
.
'">'
,
'^4'
=>
'</a>'
,
'^4'
=>
'</a>'
,
));
));
}
}
}
}
}
}
}
}
if
(
qa_is_http_post
()
&&
!
qa_check_form_security_code
(
'admin/plugins'
,
qa_post_text
(
'qa_form_security_code'
))
)
{
$qa_content
[
'error'
]
=
qa_lang_html
(
'misc/form_security_reload'
);
if
(
qa_is_http_post
()
&&
!
qa_check_form_security_code
(
'admin/plugins'
,
qa_post_text
(
'qa_form_security_code'
)))
{
$showpluginforms
=
false
;
$qa_content
[
'error'
]
=
qa_lang_html
(
'misc/form_security_reload'
);
}
$showpluginforms
=
false
;
else
}
else
$showpluginforms
=
true
;
$showpluginforms
=
true
;
if
(
!
empty
(
$pluginfiles
))
{
if
(
!
empty
(
$pluginfiles
))
{
$metadataUtil
=
new
Q2A_Util_Metadata
();
$metadataUtil
=
new
Q2A_Util_Metadata
();
$sortedPluginFiles
=
array
();
$sortedPluginFiles
=
array
();
foreach
(
$pluginfiles
as
$pluginFile
)
{
foreach
(
$pluginfiles
as
$pluginFile
)
{
$metadata
=
$metadataUtil
->
fetchFromAddonPath
(
dirname
(
$pluginFile
));
$metadata
=
$metadataUtil
->
fetchFromAddonPath
(
dirname
(
$pluginFile
));
if
(
empty
(
$metadata
))
{
if
(
empty
(
$metadata
))
{
// limit plugin parsing to first 8kB
// limit plugin parsing to first 8kB
$contents
=
file_get_contents
(
$pluginFile
,
false
,
null
,
-
1
,
8192
);
$contents
=
file_get_contents
(
$pluginFile
,
false
,
null
,
-
1
,
8192
);
$metadata
=
qa_addon_metadata
(
$contents
,
'Plugin'
);
$metadata
=
qa_addon_metadata
(
$contents
,
'Plugin'
);
}
$metadata
[
'name'
]
=
isset
(
$metadata
[
'name'
])
&&
!
empty
(
$metadata
[
'name'
])
?
qa_html
(
$metadata
[
'name'
])
:
qa_lang_html
(
'admin/unnamed_plugin'
)
;
$sortedPluginFiles
[
$pluginFile
]
=
$metadata
;
}
}
$metadata
[
'name'
]
=
isset
(
$metadata
[
'name'
])
&&
!
empty
(
$metadata
[
'name'
])
?
qa_html
(
$metadata
[
'name'
])
:
qa_lang_html
(
'admin/unnamed_plugin'
);
$sortedPluginFiles
[
$pluginFile
]
=
$metadata
;
}
qa_sort_by
(
$sortedPluginFiles
,
'name'
);
qa_sort_by
(
$sortedPluginFiles
,
'name'
);
$pluginIndex
=
-
1
;
foreach
(
$sortedPluginFiles
as
$pluginFile
=>
$metadata
)
{
$pluginIndex
++
;
$plugindirectory
=
dirname
(
$pluginFile
);
$hash
=
qa_admin_plugin_directory_hash
(
$plugindirectory
);
$showthisform
=
$showpluginforms
&&
(
qa_get
(
'show'
)
==
$hash
);
$namehtml
=
$metadata
[
'name'
];
$pluginIndex
=
-
1
;
foreach
(
$sortedPluginFiles
as
$pluginFile
=>
$metadata
)
{
$pluginIndex
++
;
$plugindirectory
=
dirname
(
$pluginFile
);
$hash
=
qa_admin_plugin_directory_hash
(
$plugindirectory
);
$showthisform
=
$showpluginforms
&&
(
qa_get
(
'show'
)
==
$hash
);
if
(
isset
(
$metadata
[
'uri'
])
&&
strlen
(
$metadata
[
'uri'
]))
$namehtml
=
$metadata
[
'name'
];
$namehtml
=
'<a href="'
.
qa_html
(
$metadata
[
'uri'
])
.
'">'
.
$namehtml
.
'</a>'
;
$namehtml
=
'<b>'
.
$namehtml
.
'</b>'
;
if
(
isset
(
$metadata
[
'uri'
])
&&
strlen
(
$metadata
[
'uri'
]))
$namehtml
=
'<a href="'
.
qa_html
(
$metadata
[
'uri'
])
.
'">'
.
$namehtml
.
'</a>'
;
$metaver
=
isset
(
$metadata
[
'version'
])
&&
strlen
(
$metadata
[
'version'
]);
$namehtml
=
'<b>'
.
$namehtml
.
'</b>'
;
if
(
$metaver
)
$namehtml
.=
' v'
.
qa_html
(
$metadata
[
'version'
]);
if
(
isset
(
$metadata
[
'author'
])
&&
strlen
(
$metadata
[
'author'
]))
{
$metaver
=
isset
(
$metadata
[
'version'
])
&&
strlen
(
$metadata
[
'version'
]);
$authorhtml
=
qa_html
(
$metadata
[
'author'
]);
if
(
$metaver
)
$namehtml
.=
' v'
.
qa_html
(
$metadata
[
'version'
]);
if
(
isset
(
$metadata
[
'author_uri'
])
&&
strlen
(
$metadata
[
'author_uri'
]))
if
(
isset
(
$metadata
[
'author'
])
&&
strlen
(
$metadata
[
'author'
]))
{
$authorhtml
=
'<a href="'
.
qa_html
(
$metadata
[
'author_uri'
])
.
'">'
.
$authorhtml
.
'</a>'
;
$authorhtml
=
qa_html
(
$metadata
[
'author'
])
;
$authorhtml
=
qa_lang_html_sub
(
'main/by_x'
,
$authorhtml
);
if
(
isset
(
$metadata
[
'author_uri'
])
&&
strlen
(
$metadata
[
'author_uri'
]))
$authorhtml
=
'<a href="'
.
qa_html
(
$metadata
[
'author_uri'
])
.
'">'
.
$authorhtml
.
'</a>'
;
}
$authorhtml
=
qa_lang_html_sub
(
'main/by_x'
,
$authorhtml
);
else
$authorhtml
=
''
;
if
(
$metaver
&&
isset
(
$metadata
[
'update_uri'
])
&&
strlen
(
$metadata
[
'update_uri'
]))
{
}
else
$elementid
=
'version_check_'
.
md5
(
$plugindirectory
)
;
$authorhtml
=
''
;
$updatehtml
=
'(<span id="'
.
$elementid
.
'">...</span>)'
;
if
(
$metaver
&&
isset
(
$metadata
[
'update_uri'
])
&&
strlen
(
$metadata
[
'update_uri'
]))
{
$elementid
=
'version_check_'
.
md5
(
$plugindirectory
);
$qa_content
[
'script_onloads'
][]
=
array
(
$updatehtml
=
'(<span id="'
.
$elementid
.
'">...</span>)'
;
"qa_version_check("
.
qa_js
(
$metadata
[
'update_uri'
])
.
", "
.
qa_js
(
$metadata
[
'version'
],
true
)
.
", "
.
qa_js
(
$elementid
)
.
");"
);
}
$qa_content
[
'script_onloads'
][]
=
array
(
else
"qa_version_check("
.
qa_js
(
$metadata
[
'update_uri'
])
.
", "
.
qa_js
(
$metadata
[
'version'
],
true
)
.
", "
.
qa_js
(
$elementid
)
.
");"
$updatehtml
=
''
;
if
(
isset
(
$metadata
[
'description'
]))
$deschtml
=
qa_html
(
$metadata
[
'description'
]);
else
$deschtml
=
''
;
if
(
isset
(
$pluginoptionmodules
[
$plugindirectory
])
&&
!
$showthisform
)
$deschtml
.=
(
strlen
(
$deschtml
)
?
' - '
:
''
)
.
'<a href="'
.
qa_admin_plugin_options_path
(
$plugindirectory
)
.
'">'
.
qa_lang_html
(
'admin/options'
)
.
'</a>'
;
$pluginhtml
=
$namehtml
.
' '
.
$authorhtml
.
' '
.
$updatehtml
.
'<br>'
.
$deschtml
.
(
strlen
(
$deschtml
)
?
'<br>'
:
''
)
.
'<small style="color:#666">'
.
qa_html
(
$plugindirectory
)
.
'/</small>'
;
if
(
qa_qa_version_below
(
@
$metadata
[
'min_q2a'
]))
$pluginhtml
=
'<strike style="color:#999">'
.
$pluginhtml
.
'</strike><br><span style="color:#f00">'
.
qa_lang_html_sub
(
'admin/requires_q2a_version'
,
qa_html
(
$metadata
[
'min_q2a'
]))
.
'</span>'
;
elseif
(
qa_php_version_below
(
@
$metadata
[
'min_php'
]))
$pluginhtml
=
'<strike style="color:#999">'
.
$pluginhtml
.
'</strike><br><span style="color:#f00">'
.
qa_lang_html_sub
(
'admin/requires_php_version'
,
qa_html
(
$metadata
[
'min_php'
]))
.
'</span>'
;
$qa_content
[
'form_plugin_'
.
$pluginIndex
]
=
array
(
'tags'
=>
'id="'
.
qa_html
(
$hash
)
.
'"'
,
'style'
=>
'tall'
,
'fields'
=>
array
(
array
(
'type'
=>
'custom'
,
'html'
=>
$pluginhtml
,
)
),
);
);
if
(
$showthisform
&&
isset
(
$pluginoptionmodules
[
$plugindirectory
]))
}
else
foreach
(
$pluginoptionmodules
[
$plugindirectory
]
as
$pluginoptionmodule
)
{
$updatehtml
=
''
;
$type
=
$pluginoptionmodule
[
'type'
];
$name
=
$pluginoptionmodule
[
'name'
];
if
(
isset
(
$metadata
[
'description'
]))
$deschtml
=
qa_html
(
$metadata
[
'description'
]);
else
$deschtml
=
''
;
$module
=
qa_load_module
(
$type
,
$name
);
if
(
isset
(
$pluginoptionmodules
[
$plugindirectory
])
&&
!
$showthisform
)
{
$deschtml
.=
(
strlen
(
$deschtml
)
?
' - '
:
''
)
.
'<a href="'
.
qa_admin_plugin_options_path
(
$plugindirectory
)
.
'">'
.
qa_lang_html
(
'admin/options'
)
.
'</a>'
;
}
$form
=
$module
->
admin_form
(
$qa_content
);
$pluginhtml
=
$namehtml
.
' '
.
$authorhtml
.
' '
.
$updatehtml
.
'<br>'
.
$deschtml
.
(
strlen
(
$deschtml
)
?
'<br>'
:
''
)
.
'<small style="color:#666">'
.
qa_html
(
$plugindirectory
)
.
'/</small>'
;
if
(
!
isset
(
$form
[
'tags'
]))
if
(
qa_qa_version_below
(
@
$metadata
[
'min_q2a'
]))
{
$form
[
'tags'
]
=
'method="post" action="'
.
qa_admin_plugin_options_path
(
$plugindirectory
)
.
'"'
;
$pluginhtml
=
'<strike style="color:#999">'
.
$pluginhtml
.
'</strike><br><span style="color:#f00">'
.
qa_lang_html_sub
(
'admin/requires_q2a_version'
,
qa_html
(
$metadata
[
'min_q2a'
]))
.
'</span>'
;
if
(
!
isset
(
$form
[
'style'
]))
}
elseif
(
qa_php_version_below
(
@
$metadata
[
'min_php'
]))
{
$form
[
'style'
]
=
'tall'
;
$pluginhtml
=
'<strike style="color:#999">'
.
$pluginhtml
.
'</strike><br><span style="color:#f00">'
.
qa_lang_html_sub
(
'admin/requires_php_version'
,
qa_html
(
$metadata
[
'min_php'
]))
.
'</span>'
;
}
$form
[
'boxed'
]
=
true
;
$qa_content
[
'form_plugin_'
.
$pluginIndex
]
=
array
(
'tags'
=>
'id="'
.
qa_html
(
$hash
)
.
'"'
,
'style'
=>
'tall'
,
'fields'
=>
array
(
array
(
'type'
=>
'custom'
,
'html'
=>
$pluginhtml
,
)
),
);
$form
[
'hidden'
][
'qa_form_security_code'
]
=
qa_get_form_security_code
(
'admin/plugins'
);
if
(
$showthisform
&&
isset
(
$pluginoptionmodules
[
$plugindirectory
]))
{
foreach
(
$pluginoptionmodules
[
$plugindirectory
]
as
$pluginoptionmodule
)
{
$type
=
$pluginoptionmodule
[
'type'
];
$name
=
$pluginoptionmodule
[
'name'
];
$qa_content
[
'form_plugin_options'
]
=
$form
;
$module
=
qa_load_module
(
$type
,
$name
);
}
}
$form
=
$module
->
admin_form
(
$qa_content
);
}
$qa_content
[
'navigation'
][
'sub'
]
=
qa_admin_sub_navigation
();
if
(
!
isset
(
$form
[
'tags'
]))
$form
[
'tags'
]
=
'method="post" action="'
.
qa_admin_plugin_options_path
(
$plugindirectory
)
.
'"'
;
if
(
!
isset
(
$form
[
'style'
]))
$form
[
'style'
]
=
'tall'
;
return
$qa_content
;
$form
[
'boxed'
]
=
true
;
$form
[
'hidden'
][
'qa_form_security_code'
]
=
qa_get_form_security_code
(
'admin/plugins'
);
/*
$qa_content
[
'form_plugin_options'
]
=
$form
;
Omit PHP closing tag to help avoid accidental output
}
*/
}
\ No newline at end of file
}
}
$qa_content
[
'navigation'
][
'sub'
]
=
qa_admin_sub_navigation
();
return
$qa_content
;
qa-include/pages/admin/admin-points.php
View file @
14d54fd4
...
@@ -20,168 +20,163 @@
...
@@ -20,168 +20,163 @@
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
;
}
}
require_once
QA_INCLUDE_DIR
.
'db/recalc.php'
;
require_once
QA_INCLUDE_DIR
.
'db/recalc.php'
;
require_once
QA_INCLUDE_DIR
.
'db/points.php'
;
require_once
QA_INCLUDE_DIR
.
'db/points.php'
;
require_once
QA_INCLUDE_DIR
.
'app/options.php'
;
require_once
QA_INCLUDE_DIR
.
'app/options.php'
;
require_once
QA_INCLUDE_DIR
.
'app/admin.php'
;
require_once
QA_INCLUDE_DIR
.
'app/admin.php'
;
require_once
QA_INCLUDE_DIR
.
'util/sort.php'
;
require_once
QA_INCLUDE_DIR
.
'util/sort.php'
;
// Check admin privileges
// Check admin privileges
if
(
!
qa_admin_check_privileges
(
$qa_content
))
if
(
!
qa_admin_check_privileges
(
$qa_content
))
return
$qa_content
;
return
$qa_content
;
// Process user actions
// Process user actions
$securityexpired
=
false
;
$securityexpired
=
false
;
$recalculate
=
false
;
$recalculate
=
false
;
$optionnames
=
qa_db_points_option_names
();
$optionnames
=
qa_db_points_option_names
();
if
(
qa_clicked
(
'doshowdefaults'
))
{
if
(
qa_clicked
(
'doshowdefaults'
))
{
$options
=
array
();
$options
=
array
();
foreach
(
$optionnames
as
$optionname
)
foreach
(
$optionnames
as
$optionname
)
$options
[
$optionname
]
=
qa_default_option
(
$optionname
);
$options
[
$optionname
]
=
qa_default_option
(
$optionname
);
}
else
{
}
else
{
if
(
qa_clicked
(
'docancel'
))
if
(
qa_clicked
(
'docancel'
))
;
;
elseif
(
qa_clicked
(
'dosaverecalc'
))
{
elseif
(
qa_clicked
(
'dosaverecalc'
))
{
if
(
!
qa_check_form_security_code
(
'admin/points'
,
qa_post_text
(
'code'
)))
if
(
!
qa_check_form_security_code
(
'admin/points'
,
qa_post_text
(
'code'
)))
$securityexpired
=
true
;
$securityexpired
=
true
;
else
{
else
{
foreach
(
$optionnames
as
$optionname
)
foreach
(
$optionnames
as
$optionname
)
qa_set_option
(
$optionname
,
(
int
)
qa_post_text
(
'option_'
.
$optionname
));
qa_set_option
(
$optionname
,
(
int
)
qa_post_text
(
'option_'
.
$optionname
));
if
(
!
qa_post_text
(
'has_js'
))
if
(
!
qa_post_text
(
'has_js'
))
qa_redirect
(
'admin/recalc'
,
array
(
'dorecalcpoints'
=>
1
));
qa_redirect
(
'admin/recalc'
,
array
(
'dorecalcpoints'
=>
1
));
else
else
$recalculate
=
true
;
$recalculate
=
true
;
}
}
}
$options
=
qa_get_options
(
$optionnames
);
}
}
$options
=
qa_get_options
(
$optionnames
);
}
// Prepare content for theme
// Prepare content for theme
$qa_content
=
qa_content_prepare
();
$qa_content
=
qa_content_prepare
();
$qa_content
[
'title'
]
=
qa_lang_html
(
'admin/admin_title'
)
.
' - '
.
qa_lang_html
(
'admin/points_title'
);
$qa_content
[
'title'
]
=
qa_lang_html
(
'admin/admin_title'
)
.
' - '
.
qa_lang_html
(
'admin/points_title'
);
$qa_content
[
'error'
]
=
$securityexpired
?
qa_lang_html
(
'admin/form_security_expired'
)
:
qa_admin_page_error
();
$qa_content
[
'error'
]
=
$securityexpired
?
qa_lang_html
(
'admin/form_security_expired'
)
:
qa_admin_page_error
();
$qa_content
[
'form'
]
=
array
(
$qa_content
[
'form'
]
=
array
(
'tags'
=>
'method="post" action="'
.
qa_self_html
()
.
'" name="points_form" onsubmit="document.forms.points_form.has_js.value=1; return true;"'
,
'tags'
=>
'method="post" action="'
.
qa_self_html
()
.
'" name="points_form" onsubmit="document.forms.points_form.has_js.value=1; return true;"'
,
'style'
=>
'wide'
,
'style'
=>
'wide'
,
'buttons'
=>
array
(
'buttons'
=>
array
(
'saverecalc'
=>
array
(
'saverecalc'
=>
array
(
'tags'
=>
'id="dosaverecalc"'
,
'tags'
=>
'id="dosaverecalc"'
,
'label'
=>
qa_lang_html
(
'admin/save_recalc_button'
),
'label'
=>
qa_lang_html
(
'admin/save_recalc_button'
),
),
),
),
),
'hidden'
=>
array
(
'hidden'
=>
array
(
'dosaverecalc'
=>
'1'
,
'dosaverecalc'
=>
'1'
,
'has_js'
=>
'0'
,
'has_js'
=>
'0'
,
'code'
=>
qa_get_form_security_code
(
'admin/points'
),
'code'
=>
qa_get_form_security_code
(
'admin/points'
),
),
),
);
);
if
(
qa_clicked
(
'doshowdefaults'
))
{
if
(
qa_clicked
(
'doshowdefaults'
))
{
$qa_content
[
'form'
][
'ok'
]
=
qa_lang_html
(
'admin/points_defaults_shown'
);
$qa_content
[
'form'
][
'ok'
]
=
qa_lang_html
(
'admin/points_defaults_shown'
);
$qa_content
[
'form'
][
'buttons'
][
'cancel'
]
=
array
(
$qa_content
[
'form'
][
'buttons'
][
'cancel'
]
=
array
(
'tags'
=>
'name="docancel"'
,
'tags'
=>
'name="docancel"'
,
'label'
=>
qa_lang_html
(
'main/cancel_button'
),
'label'
=>
qa_lang_html
(
'main/cancel_button'
),
);
);
}
else
{
}
else
{
if
(
$recalculate
)
{
if
(
$recalculate
)
{
$qa_content
[
'form'
][
'ok'
]
=
'<span id="recalc_ok"></span>'
;
$qa_content
[
'form'
][
'ok'
]
=
'<span id="recalc_ok"></span>'
;
$qa_content
[
'form'
][
'hidden'
][
'code_recalc'
]
=
qa_get_form_security_code
(
'admin/recalc'
);
$qa_content
[
'form'
][
'hidden'
][
'code_recalc'
]
=
qa_get_form_security_code
(
'admin/recalc'
);
$qa_content
[
'script_rel'
][]
=
'qa-content/qa-admin.js?'
.
QA_VERSION
;
$qa_content
[
'script_rel'
][]
=
'qa-content/qa-admin.js?'
.
QA_VERSION
;
$qa_content
[
'script_var'
][
'qa_warning_recalc'
]
=
qa_lang
(
'admin/stop_recalc_warning'
);
$qa_content
[
'script_var'
][
'qa_warning_recalc'
]
=
qa_lang
(
'admin/stop_recalc_warning'
);
$qa_content
[
'script_onloads'
][]
=
array
(
$qa_content
[
'script_onloads'
][]
=
array
(
"qa_recalc_click('dorecalcpoints', document.getElementById('dosaverecalc'), null, 'recalc_ok');"
"qa_recalc_click('dorecalcpoints', document.getElementById('dosaverecalc'), null, 'recalc_ok');"
);
}
$qa_content
[
'form'
][
'buttons'
][
'showdefaults'
]
=
array
(
'tags'
=>
'name="doshowdefaults"'
,
'label'
=>
qa_lang_html
(
'admin/show_defaults_button'
),
);
);
}
}
$qa_content
[
'form'
][
'buttons'
][
'showdefaults'
]
=
array
(
'tags'
=>
'name="doshowdefaults"'
,
'label'
=>
qa_lang_html
(
'admin/show_defaults_button'
),
);
}
foreach
(
$optionnames
as
$optionname
)
{
$optionfield
=
array
(
'label'
=>
qa_lang_html
(
'options/'
.
$optionname
),
'tags'
=>
'name="option_'
.
$optionname
.
'"'
,
'value'
=>
qa_html
(
$options
[
$optionname
]),
'type'
=>
'number'
,
'note'
=>
qa_lang_html
(
'admin/points'
),
);
switch
(
$optionname
)
{
case
'points_multiple'
:
$prefix
=
'×'
;
unset
(
$optionfield
[
'note'
]);
break
;
case
'points_per_q_voted_up'
:
case
'points_per_a_voted_up'
:
case
'points_q_voted_max_gain'
:
case
'points_a_voted_max_gain'
:
$prefix
=
'+'
;
break
;
case
'points_per_q_voted_down'
:
case
'points_per_a_voted_down'
:
case
'points_q_voted_max_loss'
:
case
'points_a_voted_max_loss'
:
$prefix
=
'–'
;
break
;
case
'points_base'
:
$prefix
=
'+'
;
break
;
default
:
$prefix
=
'<span style="visibility:hidden;">+</span>'
;
// for even alignment
break
;
}
$optionfield
[
'prefix'
]
=
'<span style="width:1em; display:inline-block; display:-moz-inline-stack;">'
.
$prefix
.
'</span>'
;
foreach
(
$optionnames
as
$optionname
)
{
$optionfield
=
array
(
'label'
=>
qa_lang_html
(
'options/'
.
$optionname
),
'tags'
=>
'name="option_'
.
$optionname
.
'"'
,
'value'
=>
qa_html
(
$options
[
$optionname
]),
'type'
=>
'number'
,
'note'
=>
qa_lang_html
(
'admin/points'
),
);
$qa_content
[
'form'
][
'fields'
][
$optionname
]
=
$optionfield
;
switch
(
$optionname
)
{
case
'points_multiple'
:
$prefix
=
'×'
;
unset
(
$optionfield
[
'note'
]);
break
;
case
'points_per_q_voted_up'
:
case
'points_per_a_voted_up'
:
case
'points_q_voted_max_gain'
:
case
'points_a_voted_max_gain'
:
$prefix
=
'+'
;
break
;
case
'points_per_q_voted_down'
:
case
'points_per_a_voted_down'
:
case
'points_q_voted_max_loss'
:
case
'points_a_voted_max_loss'
:
$prefix
=
'–'
;
break
;
case
'points_base'
:
$prefix
=
'+'
;
break
;
default
:
$prefix
=
'<span style="visibility:hidden;">+</span>'
;
// for even alignment
break
;
}
}
qa_array_insert
(
$qa_content
[
'form'
][
'fields'
],
'points_post_a'
,
array
(
'blank0'
=>
array
(
'type'
=>
'blank'
)));
$optionfield
[
'prefix'
]
=
'<span style="width:1em; display:inline-block; display:-moz-inline-stack;">'
.
$prefix
.
'</span>'
;
qa_array_insert
(
$qa_content
[
'form'
][
'fields'
],
'points_vote_up_q'
,
array
(
'blank1'
=>
array
(
'type'
=>
'blank'
)));
qa_array_insert
(
$qa_content
[
'form'
][
'fields'
],
'points_multiple'
,
array
(
'blank2'
=>
array
(
'type'
=>
'blank'
)));
$qa_content
[
'form'
][
'fields'
][
$optionname
]
=
$optionfield
;
}
$qa_content
[
'navigation'
][
'sub'
]
=
qa_admin_sub_navigation
();
qa_array_insert
(
$qa_content
[
'form'
][
'fields'
],
'points_post_a'
,
array
(
'blank0'
=>
array
(
'type'
=>
'blank'
)));
qa_array_insert
(
$qa_content
[
'form'
][
'fields'
],
'points_vote_up_q'
,
array
(
'blank1'
=>
array
(
'type'
=>
'blank'
)));
qa_array_insert
(
$qa_content
[
'form'
][
'fields'
],
'points_multiple'
,
array
(
'blank2'
=>
array
(
'type'
=>
'blank'
)));
return
$qa_content
;
$qa_content
[
'navigation'
][
'sub'
]
=
qa_admin_sub_navigation
()
;
/*
return
$qa_content
;
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
qa-include/pages/admin/admin-recalc.php
View file @
14d54fd4
...
@@ -20,118 +20,114 @@
...
@@ -20,118 +20,114 @@
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
;
}
}
require_once
QA_INCLUDE_DIR
.
'app/admin.php'
;
require_once
QA_INCLUDE_DIR
.
'app/admin.php'
;
require_once
QA_INCLUDE_DIR
.
'app/recalc.php'
;
require_once
QA_INCLUDE_DIR
.
'app/recalc.php'
;
// Check we have administrative privileges
// Check we have administrative privileges
if
(
!
qa_admin_check_privileges
(
$qa_content
))
if
(
!
qa_admin_check_privileges
(
$qa_content
))
return
$qa_content
;
return
$qa_content
;
// Find out the operation
// Find out the operation
$allowstates
=
array
(
$allowstates
=
array
(
'dorecountposts'
,
'dorecountposts'
,
'doreindexcontent'
,
'doreindexcontent'
,
'dorecalcpoints'
,
'dorecalcpoints'
,
'dorefillevents'
,
'dorefillevents'
,
'dorecalccategories'
,
'dorecalccategories'
,
'dodeletehidden'
,
'dodeletehidden'
,
'doblobstodisk'
,
'doblobstodisk'
,
'doblobstodb'
,
'doblobstodb'
,
);
);
$recalcnow
=
false
;
$recalcnow
=
false
;
foreach
(
$allowstates
as
$allowstate
)
foreach
(
$allowstates
as
$allowstate
)
{
if
(
qa_post_text
(
$allowstate
)
||
qa_get
(
$allowstate
))
{
if
(
qa_post_text
(
$allowstate
)
||
qa_get
(
$allowstate
))
{
$state
=
$allowstate
;
$state
=
$allowstate
;
$code
=
qa_post_text
(
'code'
);
$code
=
qa_post_text
(
'code'
);
if
(
isset
(
$code
)
&&
qa_check_form_security_code
(
'admin/recalc'
,
$code
))
if
(
isset
(
$code
)
&&
qa_check_form_security_code
(
'admin/recalc'
,
$code
))
$recalcnow
=
true
;
$recalcnow
=
true
;
}
}
}
if
(
$recalcnow
)
{
?>
<html>
if
(
$recalcnow
)
{
<head>
?>
<meta
http-equiv=
"content-type"
content=
"text/html; charset=utf-8"
>
</head>
<body>
<tt>
<?php
<html>
<head>
<meta
http-equiv=
"content-type"
content=
"text/html; charset=utf-8"
>
</head>
<body>
<tt>
while
(
$state
)
{
<?php
set_time_limit
(
60
);
$stoptime
=
time
()
+
2
;
// run in lumps of two seconds...
while
(
$state
)
{
set_time_limit
(
60
);
while
(
qa_recalc_perform_step
(
$state
)
&&
(
time
()
<
$stoptime
)
)
$stoptime
=
time
()
+
2
;
// run in lumps of two seconds...
;
echo
qa_html
(
qa_recalc_get_message
(
$state
))
.
str_repeat
(
' '
,
1024
)
.
"<br>
\n
"
;
while
(
qa_recalc_perform_step
(
$state
)
&&
time
()
<
$stoptime
)
;
flush
();
echo
qa_html
(
qa_recalc_get_message
(
$state
))
.
str_repeat
(
' '
,
1024
)
.
"<br>
\n
"
;
sleep
(
1
);
// ... then rest for one
}
?>
flush
();
</tt>
sleep
(
1
);
// ... then rest for one
}
<a
href=
"
<?php
echo
qa_path_html
(
'admin/stats'
)
?>
"
>
<?php
echo
qa_lang_html
(
'admin/admin_title'
)
.
' - '
.
qa_lang_html
(
'admin/stats_title'
)
?>
</a>
?>
</body>
</tt>
</html>
<?php
<a
href=
"
<?php
echo
qa_path_html
(
'admin/stats'
)
?>
"
>
<?php
echo
qa_lang_html
(
'admin/admin_title'
)
.
' - '
.
qa_lang_html
(
'admin/stats_title'
)
?>
</a>
qa_exit
();
</body>
</html>
}
elseif
(
isset
(
$state
))
{
<?php
$qa_content
=
qa_content_prepare
();
qa_exit
();
$qa_content
[
'title'
]
=
qa_lang_html
(
'admin/admin_title'
);
}
elseif
(
isset
(
$state
))
{
$qa_content
[
'error'
]
=
qa_lang_html
(
'misc/form_security_again'
);
$qa_content
=
qa_content_prepare
(
);
$qa_content
[
'form'
]
=
array
(
$qa_content
[
'title'
]
=
qa_lang_html
(
'admin/admin_title'
);
'tags'
=>
'method="post" action="'
.
qa_self_html
()
.
'"'
,
$qa_content
[
'error'
]
=
qa_lang_html
(
'misc/form_security_again'
);
'style'
=>
'wide'
,
$qa_content
[
'form'
]
=
array
(
'tags'
=>
'method="post" action="'
.
qa_self_html
()
.
'"'
,
'buttons'
=>
array
(
'style'
=>
'wide'
,
'recalc'
=>
array
(
'tags'
=>
'name="'
.
qa_html
(
$state
)
.
'"'
,
'label'
=>
qa_lang_html
(
'misc/form_security_again'
),
),
),
'hidden'
=>
array
(
'buttons'
=>
array
(
'code'
=>
qa_get_form_security_code
(
'admin/recalc'
),
'recalc'
=>
array
(
'tags'
=>
'name="'
.
qa_html
(
$state
)
.
'"'
,
'label'
=>
qa_lang_html
(
'misc/form_security_again'
),
),
),
);
),
return
$qa_content
;
}
else
{
'hidden'
=>
array
(
require_once
QA_INCLUDE_DIR
.
'app/format.php'
;
'code'
=>
qa_get_form_security_code
(
'admin/recalc'
),
),
);
$qa_content
=
qa_content_prepare
()
;
return
$qa_content
;
$qa_content
[
'title'
]
=
qa_lang_html
(
'admin/admin_title'
);
}
else
{
$qa_content
[
'error'
]
=
qa_lang_html
(
'main/page_not_found'
)
;
require_once
QA_INCLUDE_DIR
.
'app/format.php'
;
return
$qa_content
;
$qa_content
=
qa_content_prepare
();
}
$qa_content
[
'title'
]
=
qa_lang_html
(
'admin/admin_title'
);
$qa_content
[
'error'
]
=
qa_lang_html
(
'main/page_not_found'
);
/*
return
$qa_content
;
Omit PHP closing tag to help avoid accidental output
}
*/
\ No newline at end of file
qa-include/pages/admin/admin-stats.php
View file @
14d54fd4
...
@@ -20,263 +20,261 @@
...
@@ -20,263 +20,261 @@
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
;
}
}
require_once
QA_INCLUDE_DIR
.
'db/recalc.php'
;
require_once
QA_INCLUDE_DIR
.
'db/recalc.php'
;
require_once
QA_INCLUDE_DIR
.
'app/admin.php'
;
require_once
QA_INCLUDE_DIR
.
'app/admin.php'
;
require_once
QA_INCLUDE_DIR
.
'db/admin.php'
;
require_once
QA_INCLUDE_DIR
.
'db/admin.php'
;
require_once
QA_INCLUDE_DIR
.
'app/format.php'
;
require_once
QA_INCLUDE_DIR
.
'app/format.php'
;
// Check admin privileges (do late to allow one DB query)
// Check admin privileges (do late to allow one DB query)
if
(
!
qa_admin_check_privileges
(
$qa_content
))
if
(
!
qa_admin_check_privileges
(
$qa_content
))
return
$qa_content
;
return
$qa_content
;
// Get the information to display
// Get the information to display
$qcount
=
(
int
)
qa_opt
(
'cache_qcount'
);
$qcount
=
(
int
)
qa_opt
(
'cache_qcount'
);
$qcount_anon
=
qa_db_count_posts
(
'Q'
,
false
);
$qcount_anon
=
qa_db_count_posts
(
'Q'
,
false
);
$acount
=
(
int
)
qa_opt
(
'cache_acount'
);
$acount
=
(
int
)
qa_opt
(
'cache_acount'
);
$acount_anon
=
qa_db_count_posts
(
'A'
,
false
);
$acount_anon
=
qa_db_count_posts
(
'A'
,
false
);
$ccount
=
(
int
)
qa_opt
(
'cache_ccount'
);
$ccount
=
(
int
)
qa_opt
(
'cache_ccount'
);
$ccount_anon
=
qa_db_count_posts
(
'C'
,
false
);
$ccount_anon
=
qa_db_count_posts
(
'C'
,
false
);
// Prepare content for theme
// Prepare content for theme
$qa_content
=
qa_content_prepare
();
$qa_content
=
qa_content_prepare
();
$qa_content
[
'title'
]
=
qa_lang_html
(
'admin/admin_title'
)
.
' - '
.
qa_lang_html
(
'admin/stats_title'
);
$qa_content
[
'error'
]
=
qa_admin_page_error
();
$qa_content
[
'form'
]
=
array
(
'style'
=>
'wide'
,
'fields'
=>
array
(
'q2a_version'
=>
array
(
'label'
=>
qa_lang_html
(
'admin/q2a_version'
),
'value'
=>
qa_html
(
QA_VERSION
),
),
'q2a_date'
=>
array
(
'label'
=>
qa_lang_html
(
'admin/q2a_build_date'
),
'value'
=>
qa_html
(
QA_BUILD_DATE
),
),
'q2a_latest'
=>
array
(
'label'
=>
qa_lang_html
(
'admin/q2a_latest_version'
),
'type'
=>
'custom'
,
'html'
=>
'<iframe src="http://www.question2answer.org/question2answer-latest.php?version='
.
urlencode
(
QA_VERSION
)
.
'&language='
.
urlencode
(
qa_opt
(
'site_language'
))
.
'" width="100" height="16" style="vertical-align:middle; border:0; background:transparent;" allowTransparency="true" scrolling="no" frameborder="0"></iframe>'
,
),
'break0'
=>
array
(
'type'
=>
'blank'
,
),
'db_version'
=>
array
(
'label'
=>
qa_lang_html
(
'admin/q2a_db_version'
),
'value'
=>
qa_html
(
qa_opt
(
'db_version'
)),
),
'db_size'
=>
array
(
'label'
=>
qa_lang_html
(
'admin/q2a_db_size'
),
'value'
=>
qa_html
(
qa_format_number
(
qa_db_table_size
()
/
1048576
,
1
)
.
' MB'
),
),
'break1'
=>
array
(
'type'
=>
'blank'
,
),
'php_version'
=>
array
(
'label'
=>
qa_lang_html
(
'admin/php_version'
),
'value'
=>
qa_html
(
phpversion
()),
),
'mysql_version'
=>
array
(
'label'
=>
qa_lang_html
(
'admin/mysql_version'
),
'value'
=>
qa_html
(
qa_db_mysql_version
()),
),
'break2'
=>
array
(
'type'
=>
'blank'
,
),
'qcount'
=>
array
(
'label'
=>
qa_lang_html
(
'admin/total_qs'
),
'value'
=>
qa_html
(
qa_format_number
(
$qcount
)),
),
'qcount_users'
=>
array
(
'label'
=>
qa_lang_html
(
'admin/from_users'
),
'value'
=>
qa_html
(
qa_format_number
(
$qcount
-
$qcount_anon
)),
),
'qcount_anon'
=>
array
(
'label'
=>
qa_lang_html
(
'admin/from_anon'
),
'value'
=>
qa_html
(
qa_format_number
(
$qcount_anon
)),
),
'break3'
=>
array
(
'type'
=>
'blank'
,
),
'acount'
=>
array
(
'label'
=>
qa_lang_html
(
'admin/total_as'
),
'value'
=>
qa_html
(
qa_format_number
(
$acount
)),
),
'acount_users'
=>
array
(
'label'
=>
qa_lang_html
(
'admin/from_users'
),
'value'
=>
qa_html
(
qa_format_number
(
$acount
-
$acount_anon
)),
),
'acount_anon'
=>
array
(
'label'
=>
qa_lang_html
(
'admin/from_anon'
),
'value'
=>
qa_html
(
qa_format_number
(
$acount_anon
)),
),
'break4'
=>
array
(
'type'
=>
'blank'
,
),
'ccount'
=>
array
(
'label'
=>
qa_lang_html
(
'admin/total_cs'
),
'value'
=>
qa_html
(
qa_format_number
(
$ccount
)),
),
'ccount_users'
=>
array
(
'label'
=>
qa_lang_html
(
'admin/from_users'
),
'value'
=>
qa_html
(
qa_format_number
(
$ccount
-
$ccount_anon
)),
),
'ccount_anon'
=>
array
(
'label'
=>
qa_lang_html
(
'admin/from_anon'
),
'value'
=>
qa_html
(
qa_format_number
(
$ccount_anon
)),
),
'break5'
=>
array
(
'type'
=>
'blank'
,
),
'users'
=>
array
(
'label'
=>
qa_lang_html
(
'admin/users_registered'
),
'value'
=>
QA_FINAL_EXTERNAL_USERS
?
''
:
qa_html
(
qa_format_number
(
qa_db_count_users
())),
),
'users_active'
=>
array
(
'label'
=>
qa_lang_html
(
'admin/users_active'
),
'value'
=>
qa_html
(
qa_format_number
((
int
)
qa_opt
(
'cache_userpointscount'
))),
),
'users_posted'
=>
array
(
'label'
=>
qa_lang_html
(
'admin/users_posted'
),
'value'
=>
qa_html
(
qa_format_number
(
qa_db_count_active_users
(
'posts'
))),
),
'users_voted'
=>
array
(
'label'
=>
qa_lang_html
(
'admin/users_voted'
),
'value'
=>
qa_html
(
qa_format_number
(
qa_db_count_active_users
(
'uservotes'
))),
),
),
);
if
(
QA_FINAL_EXTERNAL_USERS
)
unset
(
$qa_content
[
'form'
][
'fields'
][
'users'
]);
else
unset
(
$qa_content
[
'form'
][
'fields'
][
'users_active'
]);
foreach
(
$qa_content
[
'form'
][
'fields'
]
as
$index
=>
$field
)
if
(
empty
(
$field
[
'type'
]))
$qa_content
[
'form'
][
'fields'
][
$index
][
'type'
]
=
'static'
;
$qa_content
[
'form_2'
]
=
array
(
'tags'
=>
'method="post" action="'
.
qa_path_html
(
'admin/recalc'
)
.
'"'
,
'title'
=>
qa_lang_html
(
'admin/database_cleanup'
),
'style'
=>
'basic'
,
'buttons'
=>
array
(
'recount_posts'
=>
array
(
'label'
=>
qa_lang_html
(
'admin/recount_posts'
),
'tags'
=>
'name="dorecountposts" onclick="return qa_recalc_click(this.name, this, '
.
qa_js
(
qa_lang_html
(
'admin/recount_posts_stop'
))
.
', \'recount_posts_note\');"'
,
'note'
=>
'<span id="recount_posts_note">'
.
qa_lang_html
(
'admin/recount_posts_note'
)
.
'</span>'
,
),
'reindex_content'
=>
array
(
'label'
=>
qa_lang_html
(
'admin/reindex_content'
),
'tags'
=>
'name="doreindexcontent" onclick="return qa_recalc_click(this.name, this, '
.
qa_js
(
qa_lang_html
(
'admin/reindex_content_stop'
))
.
', \'reindex_content_note\');"'
,
'note'
=>
'<span id="reindex_content_note">'
.
qa_lang_html
(
'admin/reindex_content_note'
)
.
'</span>'
,
),
'recalc_points'
=>
array
(
'label'
=>
qa_lang_html
(
'admin/recalc_points'
),
'tags'
=>
'name="dorecalcpoints" onclick="return qa_recalc_click(this.name, this, '
.
qa_js
(
qa_lang_html
(
'admin/recalc_stop'
))
.
', \'recalc_points_note\');"'
,
'note'
=>
'<span id="recalc_points_note">'
.
qa_lang_html
(
'admin/recalc_points_note'
)
.
'</span>'
,
),
'refill_events'
=>
array
(
'label'
=>
qa_lang_html
(
'admin/refill_events'
),
'tags'
=>
'name="dorefillevents" onclick="return qa_recalc_click(this.name, this, '
.
qa_js
(
qa_lang_html
(
'admin/recalc_stop'
))
.
', \'refill_events_note\');"'
,
'note'
=>
'<span id="refill_events_note">'
.
qa_lang_html
(
'admin/refill_events_note'
)
.
'</span>'
,
),
'recalc_categories'
=>
array
(
'label'
=>
qa_lang_html
(
'admin/recalc_categories'
),
'tags'
=>
'name="dorecalccategories" onclick="return qa_recalc_click(this.name, this, '
.
qa_js
(
qa_lang_html
(
'admin/recalc_stop'
))
.
', \'recalc_categories_note\');"'
,
'note'
=>
'<span id="recalc_categories_note">'
.
qa_lang_html
(
'admin/recalc_categories_note'
)
.
'</span>'
,
),
'delete_hidden'
=>
array
(
'label'
=>
qa_lang_html
(
'admin/delete_hidden'
),
'tags'
=>
'name="dodeletehidden" onclick="return qa_recalc_click(this.name, this, '
.
qa_js
(
qa_lang_html
(
'admin/delete_stop'
))
.
', \'delete_hidden_note\');"'
,
'note'
=>
'<span id="delete_hidden_note">'
.
qa_lang_html
(
'admin/delete_hidden_note'
)
.
'</span>'
,
),
),
'hidden'
=>
array
(
'code'
=>
qa_get_form_security_code
(
'admin/recalc'
),
),
);
if
(
!
qa_using_categories
())
unset
(
$qa_content
[
'form_2'
][
'buttons'
][
'recalc_categories'
]);
if
(
defined
(
'QA_BLOBS_DIRECTORY'
))
{
if
(
qa_db_has_blobs_in_db
())
$qa_content
[
'form_2'
][
'buttons'
][
'blobs_to_disk'
]
=
array
(
'label'
=>
qa_lang_html
(
'admin/blobs_to_disk'
),
'tags'
=>
'name="doblobstodisk" onclick="return qa_recalc_click(this.name, this, '
.
qa_js
(
qa_lang_html
(
'admin/blobs_stop'
))
.
', \'blobs_to_disk_note\');"'
,
'note'
=>
'<span id="blobs_to_disk_note">'
.
qa_lang_html
(
'admin/blobs_to_disk_note'
)
.
'</span>'
,
);
if
(
qa_db_has_blobs_on_disk
())
$qa_content
[
'form_2'
][
'buttons'
][
'blobs_to_db'
]
=
array
(
'label'
=>
qa_lang_html
(
'admin/blobs_to_db'
),
'tags'
=>
'name="doblobstodb" onclick="return qa_recalc_click(this.name, this, '
.
qa_js
(
qa_lang_html
(
'admin/blobs_stop'
))
.
', \'blobs_to_db_note\');"'
,
'note'
=>
'<span id="blobs_to_db_note">'
.
qa_lang_html
(
'admin/blobs_to_db_note'
)
.
'</span>'
,
);
}
$qa_content
[
'title'
]
=
qa_lang_html
(
'admin/admin_title'
)
.
' - '
.
qa_lang_html
(
'admin/stats_title'
);
$qa_content
[
'script_rel'
][]
=
'qa-content/qa-admin.js?'
.
QA_VERSION
;
$qa_content
[
'error'
]
=
qa_admin_page_error
();
$qa_content
[
'script_var'
][
'qa_warning_recalc'
]
=
qa_lang
(
'admin/stop_recalc_warning'
);
$qa_content
[
'navigation'
][
'sub'
]
=
qa_admin_sub_navigation
();
$qa_content
[
'form'
]
=
array
(
'style'
=>
'wide'
,
'fields'
=>
array
(
'q2a_version'
=>
array
(
'label'
=>
qa_lang_html
(
'admin/q2a_version'
),
'value'
=>
qa_html
(
QA_VERSION
),
),
return
$qa_content
;
'q2a_date'
=>
array
(
'label'
=>
qa_lang_html
(
'admin/q2a_build_date'
),
'value'
=>
qa_html
(
QA_BUILD_DATE
),
),
'q2a_latest'
=>
array
(
'label'
=>
qa_lang_html
(
'admin/q2a_latest_version'
),
'type'
=>
'custom'
,
'html'
=>
'<iframe src="http://www.question2answer.org/question2answer-latest.php?version='
.
urlencode
(
QA_VERSION
)
.
'&language='
.
urlencode
(
qa_opt
(
'site_language'
))
.
'" width="100" height="16" style="vertical-align:middle; border:0; background:transparent;" allowTransparency="true" scrolling="no" frameborder="0"></iframe>'
,
),
/*
'break0'
=>
array
(
Omit PHP closing tag to help avoid accidental output
'type'
=>
'blank'
,
*/
),
\ No newline at end of file
'db_version'
=>
array
(
'label'
=>
qa_lang_html
(
'admin/q2a_db_version'
),
'value'
=>
qa_html
(
qa_opt
(
'db_version'
)),
),
'db_size'
=>
array
(
'label'
=>
qa_lang_html
(
'admin/q2a_db_size'
),
'value'
=>
qa_html
(
qa_format_number
(
qa_db_table_size
()
/
1048576
,
1
)
.
' MB'
),
),
'break1'
=>
array
(
'type'
=>
'blank'
,
),
'php_version'
=>
array
(
'label'
=>
qa_lang_html
(
'admin/php_version'
),
'value'
=>
qa_html
(
phpversion
()),
),
'mysql_version'
=>
array
(
'label'
=>
qa_lang_html
(
'admin/mysql_version'
),
'value'
=>
qa_html
(
qa_db_mysql_version
()),
),
'break2'
=>
array
(
'type'
=>
'blank'
,
),
'qcount'
=>
array
(
'label'
=>
qa_lang_html
(
'admin/total_qs'
),
'value'
=>
qa_html
(
qa_format_number
(
$qcount
)),
),
'qcount_users'
=>
array
(
'label'
=>
qa_lang_html
(
'admin/from_users'
),
'value'
=>
qa_html
(
qa_format_number
(
$qcount
-
$qcount_anon
)),
),
'qcount_anon'
=>
array
(
'label'
=>
qa_lang_html
(
'admin/from_anon'
),
'value'
=>
qa_html
(
qa_format_number
(
$qcount_anon
)),
),
'break3'
=>
array
(
'type'
=>
'blank'
,
),
'acount'
=>
array
(
'label'
=>
qa_lang_html
(
'admin/total_as'
),
'value'
=>
qa_html
(
qa_format_number
(
$acount
)),
),
'acount_users'
=>
array
(
'label'
=>
qa_lang_html
(
'admin/from_users'
),
'value'
=>
qa_html
(
qa_format_number
(
$acount
-
$acount_anon
)),
),
'acount_anon'
=>
array
(
'label'
=>
qa_lang_html
(
'admin/from_anon'
),
'value'
=>
qa_html
(
qa_format_number
(
$acount_anon
)),
),
'break4'
=>
array
(
'type'
=>
'blank'
,
),
'ccount'
=>
array
(
'label'
=>
qa_lang_html
(
'admin/total_cs'
),
'value'
=>
qa_html
(
qa_format_number
(
$ccount
)),
),
'ccount_users'
=>
array
(
'label'
=>
qa_lang_html
(
'admin/from_users'
),
'value'
=>
qa_html
(
qa_format_number
(
$ccount
-
$ccount_anon
)),
),
'ccount_anon'
=>
array
(
'label'
=>
qa_lang_html
(
'admin/from_anon'
),
'value'
=>
qa_html
(
qa_format_number
(
$ccount_anon
)),
),
'break5'
=>
array
(
'type'
=>
'blank'
,
),
'users'
=>
array
(
'label'
=>
qa_lang_html
(
'admin/users_registered'
),
'value'
=>
QA_FINAL_EXTERNAL_USERS
?
''
:
qa_html
(
qa_format_number
(
qa_db_count_users
())),
),
'users_active'
=>
array
(
'label'
=>
qa_lang_html
(
'admin/users_active'
),
'value'
=>
qa_html
(
qa_format_number
((
int
)
qa_opt
(
'cache_userpointscount'
))),
),
'users_posted'
=>
array
(
'label'
=>
qa_lang_html
(
'admin/users_posted'
),
'value'
=>
qa_html
(
qa_format_number
(
qa_db_count_active_users
(
'posts'
))),
),
'users_voted'
=>
array
(
'label'
=>
qa_lang_html
(
'admin/users_voted'
),
'value'
=>
qa_html
(
qa_format_number
(
qa_db_count_active_users
(
'uservotes'
))),
),
),
);
if
(
QA_FINAL_EXTERNAL_USERS
)
unset
(
$qa_content
[
'form'
][
'fields'
][
'users'
]);
else
unset
(
$qa_content
[
'form'
][
'fields'
][
'users_active'
]);
foreach
(
$qa_content
[
'form'
][
'fields'
]
as
$index
=>
$field
)
{
if
(
empty
(
$field
[
'type'
]))
$qa_content
[
'form'
][
'fields'
][
$index
][
'type'
]
=
'static'
;
}
$qa_content
[
'form_2'
]
=
array
(
'tags'
=>
'method="post" action="'
.
qa_path_html
(
'admin/recalc'
)
.
'"'
,
'title'
=>
qa_lang_html
(
'admin/database_cleanup'
),
'style'
=>
'basic'
,
'buttons'
=>
array
(
'recount_posts'
=>
array
(
'label'
=>
qa_lang_html
(
'admin/recount_posts'
),
'tags'
=>
'name="dorecountposts" onclick="return qa_recalc_click(this.name, this, '
.
qa_js
(
qa_lang_html
(
'admin/recount_posts_stop'
))
.
', \'recount_posts_note\');"'
,
'note'
=>
'<span id="recount_posts_note">'
.
qa_lang_html
(
'admin/recount_posts_note'
)
.
'</span>'
,
),
'reindex_content'
=>
array
(
'label'
=>
qa_lang_html
(
'admin/reindex_content'
),
'tags'
=>
'name="doreindexcontent" onclick="return qa_recalc_click(this.name, this, '
.
qa_js
(
qa_lang_html
(
'admin/reindex_content_stop'
))
.
', \'reindex_content_note\');"'
,
'note'
=>
'<span id="reindex_content_note">'
.
qa_lang_html
(
'admin/reindex_content_note'
)
.
'</span>'
,
),
'recalc_points'
=>
array
(
'label'
=>
qa_lang_html
(
'admin/recalc_points'
),
'tags'
=>
'name="dorecalcpoints" onclick="return qa_recalc_click(this.name, this, '
.
qa_js
(
qa_lang_html
(
'admin/recalc_stop'
))
.
', \'recalc_points_note\');"'
,
'note'
=>
'<span id="recalc_points_note">'
.
qa_lang_html
(
'admin/recalc_points_note'
)
.
'</span>'
,
),
'refill_events'
=>
array
(
'label'
=>
qa_lang_html
(
'admin/refill_events'
),
'tags'
=>
'name="dorefillevents" onclick="return qa_recalc_click(this.name, this, '
.
qa_js
(
qa_lang_html
(
'admin/recalc_stop'
))
.
', \'refill_events_note\');"'
,
'note'
=>
'<span id="refill_events_note">'
.
qa_lang_html
(
'admin/refill_events_note'
)
.
'</span>'
,
),
'recalc_categories'
=>
array
(
'label'
=>
qa_lang_html
(
'admin/recalc_categories'
),
'tags'
=>
'name="dorecalccategories" onclick="return qa_recalc_click(this.name, this, '
.
qa_js
(
qa_lang_html
(
'admin/recalc_stop'
))
.
', \'recalc_categories_note\');"'
,
'note'
=>
'<span id="recalc_categories_note">'
.
qa_lang_html
(
'admin/recalc_categories_note'
)
.
'</span>'
,
),
'delete_hidden'
=>
array
(
'label'
=>
qa_lang_html
(
'admin/delete_hidden'
),
'tags'
=>
'name="dodeletehidden" onclick="return qa_recalc_click(this.name, this, '
.
qa_js
(
qa_lang_html
(
'admin/delete_stop'
))
.
', \'delete_hidden_note\');"'
,
'note'
=>
'<span id="delete_hidden_note">'
.
qa_lang_html
(
'admin/delete_hidden_note'
)
.
'</span>'
,
),
),
'hidden'
=>
array
(
'code'
=>
qa_get_form_security_code
(
'admin/recalc'
),
),
);
if
(
!
qa_using_categories
())
unset
(
$qa_content
[
'form_2'
][
'buttons'
][
'recalc_categories'
]);
if
(
defined
(
'QA_BLOBS_DIRECTORY'
))
{
if
(
qa_db_has_blobs_in_db
())
{
$qa_content
[
'form_2'
][
'buttons'
][
'blobs_to_disk'
]
=
array
(
'label'
=>
qa_lang_html
(
'admin/blobs_to_disk'
),
'tags'
=>
'name="doblobstodisk" onclick="return qa_recalc_click(this.name, this, '
.
qa_js
(
qa_lang_html
(
'admin/blobs_stop'
))
.
', \'blobs_to_disk_note\');"'
,
'note'
=>
'<span id="blobs_to_disk_note">'
.
qa_lang_html
(
'admin/blobs_to_disk_note'
)
.
'</span>'
,
);
}
if
(
qa_db_has_blobs_on_disk
())
{
$qa_content
[
'form_2'
][
'buttons'
][
'blobs_to_db'
]
=
array
(
'label'
=>
qa_lang_html
(
'admin/blobs_to_db'
),
'tags'
=>
'name="doblobstodb" onclick="return qa_recalc_click(this.name, this, '
.
qa_js
(
qa_lang_html
(
'admin/blobs_stop'
))
.
', \'blobs_to_db_note\');"'
,
'note'
=>
'<span id="blobs_to_db_note">'
.
qa_lang_html
(
'admin/blobs_to_db_note'
)
.
'</span>'
,
);
}
}
$qa_content
[
'script_rel'
][]
=
'qa-content/qa-admin.js?'
.
QA_VERSION
;
$qa_content
[
'script_var'
][
'qa_warning_recalc'
]
=
qa_lang
(
'admin/stop_recalc_warning'
);
$qa_content
[
'navigation'
][
'sub'
]
=
qa_admin_sub_navigation
();
return
$qa_content
;
qa-include/pages/admin/admin-userfields.php
View file @
14d54fd4
...
@@ -20,243 +20,241 @@
...
@@ -20,243 +20,241 @@
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
;
}
}
require_once
QA_INCLUDE_DIR
.
'app/admin.php'
;
require_once
QA_INCLUDE_DIR
.
'app/admin.php'
;
require_once
QA_INCLUDE_DIR
.
'db/selects.php'
;
require_once
QA_INCLUDE_DIR
.
'db/selects.php'
;
// Get current list of user fields and determine the state of this admin page
// Get current list of user fields and determine the state of this admin page
$fieldid
=
qa_post_text
(
'edit'
);
$fieldid
=
qa_post_text
(
'edit'
);
if
(
!
isset
(
$fieldid
))
if
(
!
isset
(
$fieldid
))
$fieldid
=
qa_get
(
'edit'
);
$fieldid
=
qa_get
(
'edit'
);
$userfields
=
qa_db_select_with_pending
(
qa_db_userfields_selectspec
());
$userfields
=
qa_db_select_with_pending
(
qa_db_userfields_selectspec
());
$editfield
=
null
;
$editfield
=
null
;
foreach
(
$userfields
as
$userfield
)
foreach
(
$userfields
as
$userfield
)
{
if
(
$userfield
[
'fieldid'
]
==
$fieldid
)
if
(
$userfield
[
'fieldid'
]
==
$fieldid
)
$editfield
=
$userfield
;
$editfield
=
$userfield
;
}
// Check admin privileges (do late to allow one DB query)
// Check admin privileges (do late to allow one DB query)
if
(
!
qa_admin_check_privileges
(
$qa_content
))
if
(
!
qa_admin_check_privileges
(
$qa_content
))
return
$qa_content
;
return
$qa_content
;
// Process saving an old or new user field
// Process saving an old or new user field
$securityexpired
=
false
;
$securityexpired
=
false
;
if
(
qa_clicked
(
'docancel'
))
if
(
qa_clicked
(
'docancel'
))
qa_redirect
(
'admin/users'
);
qa_redirect
(
'admin/users'
);
elseif
(
qa_clicked
(
'dosavefield'
))
{
elseif
(
qa_clicked
(
'dosavefield'
))
{
require_once
QA_INCLUDE_DIR
.
'db/admin.php'
;
require_once
QA_INCLUDE_DIR
.
'db/admin.php'
;
require_once
QA_INCLUDE_DIR
.
'util/string.php'
;
require_once
QA_INCLUDE_DIR
.
'util/string.php'
;
if
(
!
qa_check_form_security_code
(
'admin/userfields'
,
qa_post_text
(
'code'
)))
if
(
!
qa_check_form_security_code
(
'admin/userfields'
,
qa_post_text
(
'code'
)))
$securityexpired
=
true
;
$securityexpired
=
true
;
else
{
else
{
if
(
qa_post_text
(
'dodelete'
))
{
if
(
qa_post_text
(
'dodelete'
))
{
qa_db_userfield_delete
(
$editfield
[
'fieldid'
]);
qa_db_userfield_delete
(
$editfield
[
'fieldid'
]);
qa_redirect
(
'admin/users'
);
qa_redirect
(
'admin/users'
);
}
else
{
}
else
{
$inname
=
qa_post_text
(
'name'
);
$inname
=
qa_post_text
(
'name'
);
$intype
=
qa_post_text
(
'type'
);
$intype
=
qa_post_text
(
'type'
);
$inonregister
=
(
int
)
qa_post_text
(
'onregister'
);
$inonregister
=
(
int
)
qa_post_text
(
'onregister'
);
$inflags
=
$intype
|
(
$inonregister
?
QA_FIELD_FLAGS_ON_REGISTER
:
0
);
$inflags
=
$intype
|
(
$inonregister
?
QA_FIELD_FLAGS_ON_REGISTER
:
0
);
$inposition
=
qa_post_text
(
'position'
);
$inposition
=
qa_post_text
(
'position'
);
$inpermit
=
(
int
)
qa_post_text
(
'permit'
);
$inpermit
=
(
int
)
qa_post_text
(
'permit'
);
$errors
=
array
();
$errors
=
array
();
// Verify the name is legitimate
// Verify the name is legitimate
if
(
qa_strlen
(
$inname
)
>
QA_DB_MAX_PROFILE_TITLE_LENGTH
)
if
(
qa_strlen
(
$inname
)
>
QA_DB_MAX_PROFILE_TITLE_LENGTH
)
$errors
[
'name'
]
=
qa_lang_sub
(
'main/max_length_x'
,
QA_DB_MAX_PROFILE_TITLE_LENGTH
);
$errors
[
'name'
]
=
qa_lang_sub
(
'main/max_length_x'
,
QA_DB_MAX_PROFILE_TITLE_LENGTH
);
// Perform appropriate database action
// Perform appropriate database action
if
(
isset
(
$editfield
[
'fieldid'
]))
{
// changing existing user field
if
(
isset
(
$editfield
[
'fieldid'
]))
{
// changing existing user field
qa_db_userfield_set_fields
(
$editfield
[
'fieldid'
],
isset
(
$errors
[
'name'
])
?
$editfield
[
'content'
]
:
$inname
,
$inflags
,
$inpermit
);
qa_db_userfield_set_fields
(
$editfield
[
'fieldid'
],
isset
(
$errors
[
'name'
])
?
$editfield
[
'content'
]
:
$inname
,
$inflags
,
$inpermit
);
qa_db_userfield_move
(
$editfield
[
'fieldid'
],
$inposition
);
qa_db_userfield_move
(
$editfield
[
'fieldid'
],
$inposition
);
if
(
empty
(
$errors
))
qa_redirect
(
'admin/users'
);
else
{
if
(
empty
(
$errors
))
$userfields
=
qa_db_select_with_pending
(
qa_db_userfields_selectspec
());
// reload after changes
qa_redirect
(
'admin/users'
);
foreach
(
$userfields
as
$userfield
)
if
(
$userfield
[
'fieldid'
]
==
$editfield
[
'fieldid'
])
$editfield
=
$userfield
;
}
}
elseif
(
empty
(
$errors
))
{
// creating a new user field
else
{
$userfields
=
qa_db_select_with_pending
(
qa_db_userfields_selectspec
());
// reload after changes
foreach
(
$userfields
as
$userfield
)
if
(
$userfield
[
'fieldid'
]
==
$editfield
[
'fieldid'
])
$editfield
=
$userfield
;
}
for
(
$attempt
=
0
;
$attempt
<
1000
;
$attempt
++
)
{
}
elseif
(
empty
(
$errors
))
{
// creating a new user field
$suffix
=
$attempt
?
(
'-'
.
(
1
+
$attempt
))
:
''
;
$newtag
=
qa_substr
(
implode
(
'-'
,
qa_string_to_words
(
$inname
)),
0
,
QA_DB_MAX_PROFILE_TITLE_LENGTH
-
strlen
(
$suffix
))
.
$suffix
;
$uniquetag
=
true
;
foreach
(
$userfields
as
$userfield
)
for
(
$attempt
=
0
;
$attempt
<
1000
;
$attempt
++
)
{
if
(
qa_strtolower
(
trim
(
$newtag
))
==
qa_strtolower
(
trim
(
$userfield
[
'title'
])))
$suffix
=
$attempt
?
(
'-'
.
(
1
+
$attempt
))
:
''
;
$uniquetag
=
false
;
$newtag
=
qa_substr
(
implode
(
'-'
,
qa_string_to_words
(
$inname
)),
0
,
QA_DB_MAX_PROFILE_TITLE_LENGTH
-
strlen
(
$suffix
))
.
$suffix
;
$uniquetag
=
true
;
if
(
$uniquetag
)
{
foreach
(
$userfields
as
$userfield
)
{
$fieldid
=
qa_db_userfield_create
(
$newtag
,
$inname
,
$inflags
,
$inpermit
);
if
(
qa_strtolower
(
trim
(
$newtag
))
==
qa_strtolower
(
trim
(
$userfield
[
'title'
])))
qa_db_userfield_move
(
$fieldid
,
$inposition
);
$uniquetag
=
false
;
qa_redirect
(
'admin/users'
);
}
}
}
qa_fatal_error
(
'Could not create a unique database tag'
);
if
(
$uniquetag
)
{
$fieldid
=
qa_db_userfield_create
(
$newtag
,
$inname
,
$inflags
,
$inpermit
);
qa_db_userfield_move
(
$fieldid
,
$inposition
);
qa_redirect
(
'admin/users'
);
}
}
}
qa_fatal_error
(
'Could not create a unique database tag'
);
}
}
}
}
}
}
}
// Prepare content for theme
// Prepare content for theme
$qa_content
=
qa_content_prepare
();
$qa_content
=
qa_content_prepare
();
$qa_content
[
'title'
]
=
qa_lang_html
(
'admin/admin_title'
)
.
' - '
.
qa_lang_html
(
'admin/users_title'
);
$qa_content
[
'title'
]
=
qa_lang_html
(
'admin/admin_title'
)
.
' - '
.
qa_lang_html
(
'admin/users_title'
);
$qa_content
[
'error'
]
=
$securityexpired
?
qa_lang_html
(
'admin/form_security_expired'
)
:
qa_admin_page_error
();
$qa_content
[
'error'
]
=
$securityexpired
?
qa_lang_html
(
'admin/form_security_expired'
)
:
qa_admin_page_error
();
$positionoptions
=
array
();
$positionoptions
=
array
();
$previous
=
null
;
$previous
=
null
;
$passedself
=
false
;
$passedself
=
false
;
foreach
(
$userfields
as
$userfield
)
{
foreach
(
$userfields
as
$userfield
)
{
if
(
isset
(
$previous
))
if
(
isset
(
$previous
))
$positionhtml
=
qa_lang_html_sub
(
'admin/after_x'
,
qa_html
(
qa_user_userfield_label
(
$passedself
?
$userfield
:
$previous
)));
$positionhtml
=
qa_lang_html_sub
(
'admin/after_x'
,
qa_html
(
qa_user_userfield_label
(
$passedself
?
$userfield
:
$previous
)));
else
else
$positionhtml
=
qa_lang_html
(
'admin/first'
);
$positionhtml
=
qa_lang_html
(
'admin/first'
);
$positionoptions
[
$userfield
[
'position'
]]
=
$positionhtml
;
$positionoptions
[
$userfield
[
'position'
]]
=
$positionhtml
;
if
(
$userfield
[
'fieldid'
]
==
@
$editfield
[
'fieldid'
])
if
(
$userfield
[
'fieldid'
]
==
@
$editfield
[
'fieldid'
])
$passedself
=
true
;
$passedself
=
true
;
$previous
=
$userfield
;
$previous
=
$userfield
;
}
}
if
(
isset
(
$editfield
[
'position'
]))
if
(
isset
(
$editfield
[
'position'
]))
$positionvalue
=
$positionoptions
[
$editfield
[
'position'
]];
$positionvalue
=
$positionoptions
[
$editfield
[
'position'
]];
else
{
else
{
$positionvalue
=
isset
(
$previous
)
?
qa_lang_html_sub
(
'admin/after_x'
,
qa_html
(
qa_user_userfield_label
(
$previous
)))
:
qa_lang_html
(
'admin/first'
);
$positionvalue
=
isset
(
$previous
)
?
qa_lang_html_sub
(
'admin/after_x'
,
qa_html
(
qa_user_userfield_label
(
$previous
)))
:
qa_lang_html
(
'admin/first'
);
$positionoptions
[
1
+@
max
(
array_keys
(
$positionoptions
))]
=
$positionvalue
;
$positionoptions
[
1
+
@
max
(
array_keys
(
$positionoptions
))]
=
$positionvalue
;
}
}
$typeoptions
=
array
(
0
=>
qa_lang_html
(
'admin/field_single_line'
),
QA_FIELD_FLAGS_MULTI_LINE
=>
qa_lang_html
(
'admin/field_multi_line'
),
QA_FIELD_FLAGS_LINK_URL
=>
qa_lang_html
(
'admin/field_link_url'
),
);
$typeoptions
=
array
(
$permitoptions
=
qa_admin_permit_options
(
QA_PERMIT_ALL
,
QA_PERMIT_ADMINS
,
false
,
false
);
0
=>
qa_lang_html
(
'admin/field_single_line'
),
$permitvalue
=
@
$permitoptions
[
isset
(
$inpermit
)
?
$inpermit
:
$editfield
[
'permit'
]];
QA_FIELD_FLAGS_MULTI_LINE
=>
qa_lang_html
(
'admin/field_multi_line'
),
QA_FIELD_FLAGS_LINK_URL
=>
qa_lang_html
(
'admin/field_link_url'
),
$qa_content
[
'form'
]
=
array
(
);
'tags'
=>
'method="post" action="'
.
qa_path_html
(
qa_request
())
.
'"'
,
$permitoptions
=
qa_admin_permit_options
(
QA_PERMIT_ALL
,
QA_PERMIT_ADMINS
,
false
,
false
);
'style'
=>
'tall'
,
$permitvalue
=@
$permitoptions
[
isset
(
$inpermit
)
?
$inpermit
:
$editfield
[
'permit'
]];
'fields'
=>
array
(
$qa_content
[
'form'
]
=
array
(
'name'
=>
array
(
'tags'
=>
'method="post" action="'
.
qa_path_html
(
qa_request
())
.
'"'
,
'tags'
=>
'name="name" id="name"'
,
'label'
=>
qa_lang_html
(
'admin/field_name'
),
'style'
=>
'tall'
,
'value'
=>
qa_html
(
isset
(
$inname
)
?
$inname
:
qa_user_userfield_label
(
$editfield
)),
'error'
=>
qa_html
(
@
$errors
[
'name'
]),
'fields'
=>
array
(
'name'
=>
array
(
'tags'
=>
'name="name" id="name"'
,
'label'
=>
qa_lang_html
(
'admin/field_name'
),
'value'
=>
qa_html
(
isset
(
$inname
)
?
$inname
:
qa_user_userfield_label
(
$editfield
)),
'error'
=>
qa_html
(
@
$errors
[
'name'
]),
),
'delete'
=>
array
(
'tags'
=>
'name="dodelete" id="dodelete"'
,
'label'
=>
qa_lang_html
(
'admin/delete_field'
),
'value'
=>
0
,
'type'
=>
'checkbox'
,
),
'type'
=>
array
(
'id'
=>
'type_display'
,
'tags'
=>
'name="type"'
,
'label'
=>
qa_lang_html
(
'admin/field_type'
),
'type'
=>
'select'
,
'options'
=>
$typeoptions
,
'value'
=>
@
$typeoptions
[
isset
(
$intype
)
?
$intype
:
(
@
$editfield
[
'flags'
]
&
(
QA_FIELD_FLAGS_MULTI_LINE
|
QA_FIELD_FLAGS_LINK_URL
))],
),
'permit'
=>
array
(
'id'
=>
'permit_display'
,
'tags'
=>
'name="permit"'
,
'label'
=>
qa_lang_html
(
'admin/permit_to_view'
),
'type'
=>
'select'
,
'options'
=>
$permitoptions
,
'value'
=>
$permitvalue
,
),
'position'
=>
array
(
'id'
=>
'position_display'
,
'tags'
=>
'name="position"'
,
'label'
=>
qa_lang_html
(
'admin/position'
),
'type'
=>
'select'
,
'options'
=>
$positionoptions
,
'value'
=>
$positionvalue
,
),
'onregister'
=>
array
(
'id'
=>
'register_display'
,
'tags'
=>
'name="onregister"'
,
'label'
=>
qa_lang_html
(
'admin/show_on_register_form'
),
'type'
=>
'checkbox'
,
'value'
=>
isset
(
$inonregister
)
?
$inonregister
:
(
@
$editfield
[
'flags'
]
&
QA_FIELD_FLAGS_ON_REGISTER
),
),
),
),
'buttons'
=>
array
(
'delete'
=>
array
(
'save'
=>
array
(
'tags'
=>
'name="dodelete" id="dodelete"'
,
'label'
=>
qa_lang_html
(
isset
(
$editfield
[
'fieldid'
])
?
'main/save_button'
:
(
'admin/add_field_button'
)),
'label'
=>
qa_lang_html
(
'admin/delete_field'
),
),
'value'
=>
0
,
'type'
=>
'checkbox'
,
),
'cancel'
=>
array
(
'type'
=>
array
(
'tags'
=>
'name="docancel"'
,
'id'
=>
'type_display'
,
'label'
=>
qa_lang_html
(
'main/cancel_button'
),
'tags'
=>
'name="type"'
,
),
'label'
=>
qa_lang_html
(
'admin/field_type'
),
'type'
=>
'select'
,
'options'
=>
$typeoptions
,
'value'
=>
@
$typeoptions
[
isset
(
$intype
)
?
$intype
:
(
@
$editfield
[
'flags'
]
&
(
QA_FIELD_FLAGS_MULTI_LINE
|
QA_FIELD_FLAGS_LINK_URL
))],
),
),
'hidden'
=>
array
(
'permit'
=>
array
(
'dosavefield'
=>
'1'
,
// for IE
'id'
=>
'permit_display'
,
'edit'
=>
@
$editfield
[
'fieldid'
],
'tags'
=>
'name="permit"'
,
'code'
=>
qa_get_form_security_code
(
'admin/userfields'
),
'label'
=>
qa_lang_html
(
'admin/permit_to_view'
),
'type'
=>
'select'
,
'options'
=>
$permitoptions
,
'value'
=>
$permitvalue
,
),
),
);
if
(
isset
(
$editfield
[
'fieldid'
]))
qa_set_display_rules
(
$qa_content
,
array
(
'type_display'
=>
'!dodelete'
,
'position_display'
=>
'!dodelete'
,
'register_display'
=>
'!dodelete'
,
'permit_display'
=>
'!dodelete'
,
));
else
unset
(
$qa_content
[
'form'
][
'fields'
][
'delete'
]);
$qa_content
[
'focusid'
]
=
'name'
;
'position'
=>
array
(
'id'
=>
'position_display'
,
'tags'
=>
'name="position"'
,
'label'
=>
qa_lang_html
(
'admin/position'
),
'type'
=>
'select'
,
'options'
=>
$positionoptions
,
'value'
=>
$positionvalue
,
),
$qa_content
[
'navigation'
][
'sub'
]
=
qa_admin_sub_navigation
();
'onregister'
=>
array
(
'id'
=>
'register_display'
,
'tags'
=>
'name="onregister"'
,
'label'
=>
qa_lang_html
(
'admin/show_on_register_form'
),
'type'
=>
'checkbox'
,
'value'
=>
isset
(
$inonregister
)
?
$inonregister
:
(
@
$editfield
[
'flags'
]
&
QA_FIELD_FLAGS_ON_REGISTER
),
),
),
'buttons'
=>
array
(
'save'
=>
array
(
'label'
=>
qa_lang_html
(
isset
(
$editfield
[
'fieldid'
])
?
'main/save_button'
:
(
'admin/add_field_button'
)),
),
return
$qa_content
;
'cancel'
=>
array
(
'tags'
=>
'name="docancel"'
,
'label'
=>
qa_lang_html
(
'main/cancel_button'
),
),
),
'hidden'
=>
array
(
'dosavefield'
=>
'1'
,
// for IE
'edit'
=>
@
$editfield
[
'fieldid'
],
'code'
=>
qa_get_form_security_code
(
'admin/userfields'
),
),
);
/*
if
(
isset
(
$editfield
[
'fieldid'
]))
{
Omit PHP closing tag to help avoid accidental output
qa_set_display_rules
(
$qa_content
,
array
(
*/
'type_display'
=>
'!dodelete'
,
\ No newline at end of file
'position_display'
=>
'!dodelete'
,
'register_display'
=>
'!dodelete'
,
'permit_display'
=>
'!dodelete'
,
));
}
else
{
unset
(
$qa_content
[
'form'
][
'fields'
][
'delete'
]);
}
$qa_content
[
'focusid'
]
=
'name'
;
$qa_content
[
'navigation'
][
'sub'
]
=
qa_admin_sub_navigation
();
return
$qa_content
;
qa-include/pages/admin/admin-usertitles.php
View file @
14d54fd4
...
@@ -20,166 +20,162 @@
...
@@ -20,166 +20,162 @@
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
;
}
}
require_once
QA_INCLUDE_DIR
.
'app/admin.php'
;
require_once
QA_INCLUDE_DIR
.
'app/admin.php'
;
require_once
QA_INCLUDE_DIR
.
'db/selects.php'
;
require_once
QA_INCLUDE_DIR
.
'db/selects.php'
;
// Get current list of user titles and determine the state of this admin page
// Get current list of user titles and determine the state of this admin page
$oldpoints
=
qa_post_text
(
'edit'
);
$oldpoints
=
qa_post_text
(
'edit'
);
if
(
!
isset
(
$oldpoints
))
if
(
!
isset
(
$oldpoints
))
$oldpoints
=
qa_get
(
'edit'
);
$oldpoints
=
qa_get
(
'edit'
);
$pointstitle
=
qa_get_points_to_titles
();
$pointstitle
=
qa_get_points_to_titles
();
// Check admin privileges (do late to allow one DB query)
// Check admin privileges (do late to allow one DB query)
if
(
!
qa_admin_check_privileges
(
$qa_content
))
if
(
!
qa_admin_check_privileges
(
$qa_content
))
return
$qa_content
;
return
$qa_content
;
// Process saving an old or new user title
// Process saving an old or new user title
$securityexpired
=
false
;
$securityexpired
=
false
;
if
(
qa_clicked
(
'docancel'
))
if
(
qa_clicked
(
'docancel'
))
qa_redirect
(
'admin/users'
);
qa_redirect
(
'admin/users'
);
elseif
(
qa_clicked
(
'dosavetitle'
))
{
elseif
(
qa_clicked
(
'dosavetitle'
))
{
require_once
QA_INCLUDE_DIR
.
'util/string.php'
;
require_once
QA_INCLUDE_DIR
.
'util/string.php'
;
if
(
!
qa_check_form_security_code
(
'admin/usertitles'
,
qa_post_text
(
'code'
)))
if
(
!
qa_check_form_security_code
(
'admin/usertitles'
,
qa_post_text
(
'code'
)))
$securityexpired
=
true
;
$securityexpired
=
true
;
else
{
else
{
if
(
qa_post_text
(
'dodelete'
))
{
if
(
qa_post_text
(
'dodelete'
))
{
unset
(
$pointstitle
[
$oldpoints
]);
unset
(
$pointstitle
[
$oldpoints
]);
}
else
{
}
else
{
$intitle
=
qa_post_text
(
'title'
);
$intitle
=
qa_post_text
(
'title'
);
$inpoints
=
qa_post_text
(
'points'
);
$inpoints
=
qa_post_text
(
'points'
);
$errors
=
array
();
$errors
=
array
();
// Verify the title and points are legitimate
// Verify the title and points are legitimate
if
(
!
strlen
(
$intitle
))
if
(
!
strlen
(
$intitle
))
$errors
[
'title'
]
=
qa_lang
(
'main/field_required'
);
$errors
[
'title'
]
=
qa_lang
(
'main/field_required'
);
if
(
!
is_numeric
(
$inpoints
))
if
(
!
is_numeric
(
$inpoints
))
$errors
[
'points'
]
=
qa_lang
(
'main/field_required'
);
$errors
[
'points'
]
=
qa_lang
(
'main/field_required'
);
else
{
else
{
$inpoints
=
(
int
)
$inpoints
;
$inpoints
=
(
int
)
$inpoints
;
if
(
isset
(
$pointstitle
[
$inpoints
])
&&
((
!
strlen
(
@
$oldpoints
))
||
(
$inpoints
!=
$oldpoints
))
)
if
(
isset
(
$pointstitle
[
$inpoints
])
&&
((
!
strlen
(
@
$oldpoints
))
||
(
$inpoints
!=
$oldpoints
))
)
$errors
[
'points'
]
=
qa_lang
(
'admin/title_already_used'
);
$errors
[
'points'
]
=
qa_lang
(
'admin/title_already_used'
);
}
}
// Perform appropriate action
// Perform appropriate action
if
(
isset
(
$pointstitle
[
$oldpoints
]))
{
// changing existing user title
if
(
isset
(
$pointstitle
[
$oldpoints
]))
{
// changing existing user title
$newpoints
=
isset
(
$errors
[
'points'
])
?
$oldpoints
:
$inpoints
;
$newpoints
=
isset
(
$errors
[
'points'
])
?
$oldpoints
:
$inpoints
;
$newtitle
=
isset
(
$errors
[
'title'
])
?
$pointstitle
[
$oldpoints
]
:
$intitle
;
$newtitle
=
isset
(
$errors
[
'title'
])
?
$pointstitle
[
$oldpoints
]
:
$intitle
;
unset
(
$pointstitle
[
$oldpoints
]);
unset
(
$pointstitle
[
$oldpoints
]);
$pointstitle
[
$newpoints
]
=
$newtitle
;
$pointstitle
[
$newpoints
]
=
$newtitle
;
}
elseif
(
empty
(
$errors
))
// creating a new user title
}
elseif
(
empty
(
$errors
))
// creating a new user title
$pointstitle
[
$inpoints
]
=
$intitle
;
$pointstitle
[
$inpoints
]
=
$intitle
;
}
}
// Save the new option value
// Save the new option value
krsort
(
$pointstitle
,
SORT_NUMERIC
);
krsort
(
$pointstitle
,
SORT_NUMERIC
);
$option
=
''
;
$option
=
''
;
foreach
(
$pointstitle
as
$points
=>
$title
)
foreach
(
$pointstitle
as
$points
=>
$title
)
$option
.=
(
strlen
(
$option
)
?
','
:
''
)
.
$points
.
' '
.
$title
;
$option
.=
(
strlen
(
$option
)
?
','
:
''
)
.
$points
.
' '
.
$title
;
qa_set_option
(
'points_to_titles'
,
$option
);
qa_set_option
(
'points_to_titles'
,
$option
);
if
(
empty
(
$errors
))
if
(
empty
(
$errors
))
qa_redirect
(
'admin/users'
);
qa_redirect
(
'admin/users'
);
}
}
}
}
// Prepare content for theme
// Prepare content for theme
$qa_content
=
qa_content_prepare
();
$qa_content
=
qa_content_prepare
();
$qa_content
[
'title'
]
=
qa_lang_html
(
'admin/admin_title'
)
.
' - '
.
qa_lang_html
(
'admin/users_title'
);
$qa_content
[
'title'
]
=
qa_lang_html
(
'admin/admin_title'
)
.
' - '
.
qa_lang_html
(
'admin/users_title'
);
$qa_content
[
'error'
]
=
$securityexpired
?
qa_lang_html
(
'admin/form_security_expired'
)
:
qa_admin_page_error
();
$qa_content
[
'error'
]
=
$securityexpired
?
qa_lang_html
(
'admin/form_security_expired'
)
:
qa_admin_page_error
();
$qa_content
[
'form'
]
=
array
(
$qa_content
[
'form'
]
=
array
(
'tags'
=>
'method="post" action="'
.
qa_path_html
(
qa_request
())
.
'"'
,
'tags'
=>
'method="post" action="'
.
qa_path_html
(
qa_request
())
.
'"'
,
'style'
=>
'tall'
,
'style'
=>
'tall'
,
'fields'
=>
array
(
'fields'
=>
array
(
'title'
=>
array
(
'title'
=>
array
(
'tags'
=>
'name="title" id="title"'
,
'tags'
=>
'name="title" id="title"'
,
'label'
=>
qa_lang_html
(
'admin/user_title'
),
'label'
=>
qa_lang_html
(
'admin/user_title'
),
'value'
=>
qa_html
(
isset
(
$intitle
)
?
$intitle
:
@
$pointstitle
[
$oldpoints
]),
'value'
=>
qa_html
(
isset
(
$intitle
)
?
$intitle
:
@
$pointstitle
[
$oldpoints
]),
'error'
=>
qa_html
(
@
$errors
[
'title'
]),
'error'
=>
qa_html
(
@
$errors
[
'title'
]),
),
'delete'
=>
array
(
'tags'
=>
'name="dodelete" id="dodelete"'
,
'label'
=>
qa_lang_html
(
'admin/delete_title'
),
'value'
=>
0
,
'type'
=>
'checkbox'
,
),
'points'
=>
array
(
'id'
=>
'points_display'
,
'tags'
=>
'name="points"'
,
'label'
=>
qa_lang_html
(
'admin/points_required'
),
'type'
=>
'number'
,
'value'
=>
qa_html
(
isset
(
$inpoints
)
?
$inpoints
:
@
$oldpoints
),
'error'
=>
qa_html
(
@
$errors
[
'points'
]),
),
),
),
'buttons'
=>
array
(
'delete'
=>
array
(
'save'
=>
array
(
'tags'
=>
'name="dodelete" id="dodelete"'
,
'label'
=>
qa_lang_html
(
isset
(
$pointstitle
[
$oldpoints
])
?
'main/save_button'
:
(
'admin/add_title_button'
)),
'label'
=>
qa_lang_html
(
'admin/delete_title'
),
),
'value'
=>
0
,
'type'
=>
'checkbox'
,
),
'cancel'
=>
array
(
'points'
=>
array
(
'tags'
=>
'name="docancel"'
,
'id'
=>
'points_display'
,
'label'
=>
qa_lang_html
(
'main/cancel_button'
),
'tags'
=>
'name="points"'
,
),
'label'
=>
qa_lang_html
(
'admin/points_required'
),
'type'
=>
'number'
,
'value'
=>
qa_html
(
isset
(
$inpoints
)
?
$inpoints
:
@
$oldpoints
),
'error'
=>
qa_html
(
@
$errors
[
'points'
]),
),
),
),
'hidden'
=>
array
(
'buttons'
=>
array
(
'dosavetitle'
=>
'1'
,
// for IE
'save'
=>
array
(
'edit'
=>
@
$oldpoints
,
'label'
=>
qa_lang_html
(
isset
(
$pointstitle
[
$oldpoints
])
?
'main/save_button'
:
(
'admin/add_title_button'
)),
'code'
=>
qa_get_form_security_code
(
'admin/usertitles'
),
),
),
);
if
(
isset
(
$pointstitle
[
$oldpoints
]))
'cancel'
=>
array
(
qa_set_display_rules
(
$qa_content
,
array
(
'tags'
=>
'name="docancel"'
,
'points_display'
=>
'!dodelete'
,
'label'
=>
qa_lang_html
(
'main/cancel_button'
),
));
),
else
),
unset
(
$qa_content
[
'form'
][
'fields'
][
'delete'
]);
$qa_content
[
'focusid'
]
=
'title'
;
'hidden'
=>
array
(
'dosavetitle'
=>
'1'
,
// for IE
'edit'
=>
@
$oldpoints
,
'code'
=>
qa_get_form_security_code
(
'admin/usertitles'
),
),
);
$qa_content
[
'navigation'
][
'sub'
]
=
qa_admin_sub_navigation
();
if
(
isset
(
$pointstitle
[
$oldpoints
]))
{
qa_set_display_rules
(
$qa_content
,
array
(
'points_display'
=>
'!dodelete'
,
));
}
else
{
unset
(
$qa_content
[
'form'
][
'fields'
][
'delete'
]);
}
$qa_content
[
'focusid'
]
=
'title'
;
return
$qa_content
;
$qa_content
[
'navigation'
][
'sub'
]
=
qa_admin_sub_navigation
()
;
/*
return
$qa_content
;
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
qa-include/pages/admin/admin-widgets.php
View file @
14d54fd4
...
@@ -20,326 +20,328 @@
...
@@ -20,326 +20,328 @@
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
;
}
}
require_once
QA_INCLUDE_DIR
.
'app/admin.php'
;
require_once
QA_INCLUDE_DIR
.
'app/admin.php'
;
require_once
QA_INCLUDE_DIR
.
'db/selects.php'
;
require_once
QA_INCLUDE_DIR
.
'db/selects.php'
;
// Get current list of widgets and determine the state of this admin page
// Get current list of widgets and determine the state of this admin page
$widgetid
=
qa_post_text
(
'edit'
);
$widgetid
=
qa_post_text
(
'edit'
);
if
(
!
strlen
(
$widgetid
))
if
(
!
strlen
(
$widgetid
))
$widgetid
=
qa_get
(
'edit'
);
$widgetid
=
qa_get
(
'edit'
);
list
(
$widgets
,
$pages
)
=
qa_db_select_with_pending
(
list
(
$widgets
,
$pages
)
=
qa_db_select_with_pending
(
qa_db_widgets_selectspec
(),
qa_db_widgets_selectspec
(),
qa_db_pages_selectspec
()
qa_db_pages_selectspec
()
);
);
if
(
isset
(
$widgetid
))
{
if
(
isset
(
$widgetid
))
{
$editwidget
=
null
;
$editwidget
=
null
;
foreach
(
$widgets
as
$widget
)
foreach
(
$widgets
as
$widget
)
{
if
(
$widget
[
'widgetid'
]
==
$widgetid
)
if
(
$widget
[
'widgetid'
]
==
$widgetid
)
$editwidget
=
$widget
;
$editwidget
=
$widget
;
}
else
{
$editwidget
=
array
(
'title'
=>
qa_post_text
(
'title'
));
if
(
!
isset
(
$editwidget
[
'title'
]))
$editwidget
[
'title'
]
=
qa_get
(
'title'
);
}
}
$module
=
qa_load_module
(
'widget'
,
@
$editwidget
[
'title'
]);
}
else
{
$editwidget
=
array
(
'title'
=>
qa_post_text
(
'title'
));
if
(
!
isset
(
$editwidget
[
'title'
]))
$editwidget
[
'title'
]
=
qa_get
(
'title'
);
}
$widgetfound
=
isset
(
$module
);
$module
=
qa_load_module
(
'widget'
,
@
$editwidget
[
'title'
]);
$widgetfound
=
isset
(
$module
);
// Check admin privileges (do late to allow one DB query)
// Check admin privileges (do late to allow one DB query)
if
(
!
qa_admin_check_privileges
(
$qa_content
))
if
(
!
qa_admin_check_privileges
(
$qa_content
))
return
$qa_content
;
return
$qa_content
;
// Define an array of relevant templates we can use
// Define an array of relevant templates we can use
$templatelangkeys
=
array
(
$templatelangkeys
=
array
(
'question'
=>
'admin/question_pages'
,
'question'
=>
'admin/question_pages'
,
'qa'
=>
'main/recent_qs_as_title'
,
'activity'
=>
'main/recent_activity_title'
,
'questions'
=>
'admin/question_lists'
,
'hot'
=>
'main/hot_qs_title'
,
'unanswered'
=>
'main/unanswered_qs_title'
,
'tags'
=>
'main/popular_tags'
,
'categories'
=>
'misc/browse_categories'
,
'users'
=>
'main/highest_users'
,
'ask'
=>
'question/ask_title'
,
'tag'
=>
'admin/tag_pages'
,
'user'
=>
'admin/user_pages'
,
'message'
=>
'misc/private_message_title'
,
'search'
=>
'main/search_title'
,
'feedback'
=>
'misc/feedback_title'
,
'login'
=>
'users/login_title'
,
'register'
=>
'users/register_title'
,
'account'
=>
'profile/my_account_title'
,
'favorites'
=>
'misc/my_favorites_title'
,
'updates'
=>
'misc/recent_updates_title'
,
'ip'
=>
'admin/ip_address_pages'
,
'admin'
=>
'admin/admin_title'
,
);
$templateoptions
=
array
();
if
(
isset
(
$module
)
&&
method_exists
(
$module
,
'allow_template'
))
{
foreach
(
$templatelangkeys
as
$template
=>
$langkey
)
if
(
$module
->
allow_template
(
$template
))
$templateoptions
[
$template
]
=
qa_lang_html
(
$langkey
);
if
(
$module
->
allow_template
(
'custom'
))
{
$pagemodules
=
qa_load_modules_with
(
'page'
,
'match_request'
);
foreach
(
$pages
as
$page
)
{
// check if this is a page plugin by fetching all plugin classes and matching requests - currently quite convoluted!
$isPagePlugin
=
false
;
foreach
(
$pagemodules
as
$pagemodule
)
{
if
(
$pagemodule
->
match_request
(
$page
[
'tags'
]))
{
$isPagePlugin
=
true
;
}
}
if
(
$isPagePlugin
||
!
(
$page
[
'flags'
]
&
QA_PAGE_FLAGS_EXTERNAL
))
'qa'
=>
'main/recent_qs_as_title'
,
$templateoptions
[
'custom-'
.
$page
[
'pageid'
]]
=
qa_html
(
$page
[
'title'
]);
'activity'
=>
'main/recent_activity_title'
,
}
'questions'
=>
'admin/question_lists'
,
'hot'
=>
'main/hot_qs_title'
,
'unanswered'
=>
'main/unanswered_qs_title'
,
}
'tags'
=>
'main/popular_tags'
,
}
'categories'
=>
'misc/browse_categories'
,
'users'
=>
'main/highest_users'
,
'ask'
=>
'question/ask_title'
,
'tag'
=>
'admin/tag_pages'
,
'user'
=>
'admin/user_pages'
,
'message'
=>
'misc/private_message_title'
,
// Process saving an old or new widget
'search'
=>
'main/search_title'
,
'feedback'
=>
'misc/feedback_title'
,
'login'
=>
'users/login_title'
,
'register'
=>
'users/register_title'
,
'account'
=>
'profile/my_account_title'
,
'favorites'
=>
'misc/my_favorites_title'
,
'updates'
=>
'misc/recent_updates_title'
,
$securityexpired
=
false
;
'ip'
=>
'admin/ip_address_pages'
,
'admin'
=>
'admin/admin_title'
,
);
if
(
qa_clicked
(
'docancel'
))
$templateoptions
=
array
();
qa_redirect
(
'admin/layout'
);
elseif
(
qa_clicked
(
'dosavewidget'
))
{
if
(
isset
(
$module
)
&&
method_exists
(
$module
,
'allow_template'
))
{
require_once
QA_INCLUDE_DIR
.
'db/admin.php'
;
foreach
(
$templatelangkeys
as
$template
=>
$langkey
)
{
if
(
$module
->
allow_template
(
$template
))
$templateoptions
[
$template
]
=
qa_lang_html
(
$langkey
);
}
if
(
!
qa_check_form_security_code
(
'admin/widgets'
,
qa_post_text
(
'code'
)))
if
(
$module
->
allow_template
(
'custom'
))
{
$securityexpired
=
true
;
$pagemodules
=
qa_load_modules_with
(
'page'
,
'match_request'
);
foreach
(
$pages
as
$page
)
{
// check if this is a page plugin by fetching all plugin classes and matching requests - currently quite convoluted!
$isPagePlugin
=
false
;
foreach
(
$pagemodules
as
$pagemodule
)
{
if
(
$pagemodule
->
match_request
(
$page
[
'tags'
]))
{
$isPagePlugin
=
true
;
}
}
else
{
if
(
$isPagePlugin
||
!
(
$page
[
'flags'
]
&
QA_PAGE_FLAGS_EXTERNAL
))
if
(
qa_post_text
(
'dodelete'
))
{
$templateoptions
[
'custom-'
.
$page
[
'pageid'
]]
=
qa_html
(
$page
[
'title'
]);
qa_db_widget_delete
(
$editwidget
[
'widgetid'
]);
}
qa_redirect
(
'admin/layout'
);
}
else
{
}
if
(
$widgetfound
)
{
}
$intitle
=
qa_post_text
(
'title'
);
$inposition
=
qa_post_text
(
'position'
);
$intemplates
=
array
();
if
(
qa_post_text
(
'template_all'
))
$intemplates
[]
=
'all'
;
foreach
(
array_keys
(
$templateoptions
)
as
$template
)
// Process saving an old or new widget
if
(
qa_post_text
(
'template_'
.
$template
))
$intemplates
[]
=
$template
;
$intags
=
implode
(
','
,
$intemplates
)
;
$securityexpired
=
false
;
// Perform appropriate database action
if
(
qa_clicked
(
'docancel'
))
qa_redirect
(
'admin/layout'
);
if
(
isset
(
$editwidget
[
'widgetid'
]))
{
// changing existing widget
elseif
(
qa_clicked
(
'dosavewidget'
))
{
$widgetid
=
$editwidget
[
'widgetid'
];
require_once
QA_INCLUDE_DIR
.
'db/admin.php'
;
qa_db_widget_set_fields
(
$widgetid
,
$intags
);
}
else
if
(
!
qa_check_form_security_code
(
'admin/widgets'
,
qa_post_text
(
'code'
)))
$widgetid
=
qa_db_widget_create
(
$intitle
,
$intags
)
;
$securityexpired
=
true
;
qa_db_widget_move
(
$widgetid
,
substr
(
$inposition
,
0
,
2
),
substr
(
$inposition
,
2
));
else
{
if
(
qa_post_text
(
'dodelete'
))
{
qa_db_widget_delete
(
$editwidget
[
'widgetid'
]);
qa_redirect
(
'admin/layout'
);
}
else
{
if
(
$widgetfound
)
{
$intitle
=
qa_post_text
(
'title'
);
$inposition
=
qa_post_text
(
'position'
);
$intemplates
=
array
();
if
(
qa_post_text
(
'template_all'
))
$intemplates
[]
=
'all'
;
foreach
(
array_keys
(
$templateoptions
)
as
$template
)
{
if
(
qa_post_text
(
'template_'
.
$template
))
$intemplates
[]
=
$template
;
}
}
qa_redirect
(
'admin/layout'
);
$intags
=
implode
(
','
,
$intemplates
);
// Perform appropriate database action
if
(
isset
(
$editwidget
[
'widgetid'
]))
{
// changing existing widget
$widgetid
=
$editwidget
[
'widgetid'
];
qa_db_widget_set_fields
(
$widgetid
,
$intags
);
}
else
$widgetid
=
qa_db_widget_create
(
$intitle
,
$intags
);
qa_db_widget_move
(
$widgetid
,
substr
(
$inposition
,
0
,
2
),
substr
(
$inposition
,
2
));
}
}
qa_redirect
(
'admin/layout'
);
}
}
}
}
}
// Prepare content for theme
// Prepare content for theme
$qa_content
=
qa_content_prepare
();
$qa_content
=
qa_content_prepare
();
$qa_content
[
'title'
]
=
qa_lang_html
(
'admin/admin_title'
)
.
' - '
.
qa_lang_html
(
'admin/layout_title'
);
$qa_content
[
'title'
]
=
qa_lang_html
(
'admin/admin_title'
)
.
' - '
.
qa_lang_html
(
'admin/layout_title'
);
$qa_content
[
'error'
]
=
$securityexpired
?
qa_lang_html
(
'admin/form_security_expired'
)
:
qa_admin_page_error
();
$qa_content
[
'error'
]
=
$securityexpired
?
qa_lang_html
(
'admin/form_security_expired'
)
:
qa_admin_page_error
();
$positionoptions
=
array
();
$positionoptions
=
array
();
$placeoptionhtml
=
qa_admin_place_options
();
$placeoptionhtml
=
qa_admin_place_options
();
$regioncodes
=
array
(
$regioncodes
=
array
(
'F'
=>
'full'
,
'F'
=>
'full'
,
'M'
=>
'main'
,
'M'
=>
'main'
,
'S'
=>
'side'
,
'S'
=>
'side'
,
);
);
foreach
(
$placeoptionhtml
as
$place
=>
$optionhtml
)
{
foreach
(
$placeoptionhtml
as
$place
=>
$optionhtml
)
{
$region
=
$regioncodes
[
substr
(
$place
,
0
,
1
)];
$region
=
$regioncodes
[
substr
(
$place
,
0
,
1
)];
$widgetallowed
=
method_exists
(
$module
,
'allow_region'
)
&&
$module
->
allow_region
(
$region
);
$widgetallowed
=
method_exists
(
$module
,
'allow_region'
)
&&
$module
->
allow_region
(
$region
);
if
(
$widgetallowed
)
if
(
$widgetallowed
)
{
foreach
(
$widgets
as
$widget
)
foreach
(
$widgets
as
$widget
)
{
if
(
(
$widget
[
'place'
]
==
$place
)
&&
(
$widget
[
'title'
]
==
$editwidget
[
'title'
])
&&
(
$widget
[
'widgetid'
]
!==@
$editwidget
[
'widgetid'
])
)
if
(
$widget
[
'place'
]
==
$place
&&
$widget
[
'title'
]
==
$editwidget
[
'title'
]
&&
$widget
[
'widgetid'
]
!==
@
$editwidget
[
'widgetid'
])
$widgetallowed
=
false
;
// don't allow two instances of same widget in same place
$widgetallowed
=
false
;
// don't allow two instances of same widget in same place
}
}
if
(
$widgetallowed
)
{
if
(
$widgetallowed
)
{
$previous
=
null
;
$previous
=
null
;
$passedself
=
false
;
$passedself
=
false
;
$maxposition
=
0
;
$maxposition
=
0
;
foreach
(
$widgets
as
$widget
)
foreach
(
$widgets
as
$widget
)
{
if
(
$widget
[
'place'
]
==
$place
)
{
if
(
$widget
[
'place'
]
==
$place
)
{
$positionhtml
=
$optionhtml
;
$positionhtml
=
$optionhtml
;
if
(
isset
(
$previous
))
if
(
isset
(
$previous
))
$positionhtml
.=
' - '
.
qa_lang_html_sub
(
'admin/after_x'
,
qa_html
(
$passedself
?
$widget
[
'title'
]
:
$previous
[
'title'
]));
$positionhtml
.=
' - '
.
qa_lang_html_sub
(
'admin/after_x'
,
qa_html
(
$passedself
?
$widget
[
'title'
]
:
$previous
[
'title'
]));
if
(
$widget
[
'widgetid'
]
==
@
$editwidget
[
'widgetid'
])
if
(
$widget
[
'widgetid'
]
==
@
$editwidget
[
'widgetid'
])
$passedself
=
true
;
$passedself
=
true
;
$maxposition
=
max
(
$maxposition
,
$widget
[
'position'
]);
$maxposition
=
max
(
$maxposition
,
$widget
[
'position'
]);
$positionoptions
[
$place
.
$widget
[
'position'
]]
=
$positionhtml
;
$positionoptions
[
$place
.
$widget
[
'position'
]]
=
$positionhtml
;
$previous
=
$widget
;
$previous
=
$widget
;
}
}
}
if
((
!
isset
(
$editwidget
[
'widgetid'
]))
||
$place
!=
@
$editwidget
[
'place'
])
{
if
(
!
isset
(
$editwidget
[
'widgetid'
])
||
$place
!=
@
$editwidget
[
'place'
])
{
$positionhtml
=
$optionhtml
;
$positionhtml
=
$optionhtml
;
if
(
isset
(
$previous
))
if
(
isset
(
$previous
))
$positionhtml
.=
' - '
.
qa_lang_html_sub
(
'admin/after_x'
,
$previous
[
'title'
]);
$positionhtml
.=
' - '
.
qa_lang_html_sub
(
'admin/after_x'
,
$previous
[
'title'
]);
$positionoptions
[
$place
.
(
isset
(
$previous
)
?
(
1
+
$maxposition
)
:
1
)]
=
$positionhtml
;
$positionoptions
[
$place
.
(
isset
(
$previous
)
?
(
1
+
$maxposition
)
:
1
)]
=
$positionhtml
;
}
}
}
}
}
}
$positionvalue
=@
$positionoptions
[
$editwidget
[
'place'
]
.
$editwidget
[
'position'
]];
$positionvalue
=
@
$positionoptions
[
$editwidget
[
'place'
]
.
$editwidget
[
'position'
]];
$qa_content
[
'form'
]
=
array
(
$qa_content
[
'form'
]
=
array
(
'tags'
=>
'method="post" action="'
.
qa_path_html
(
qa_request
())
.
'"'
,
'tags'
=>
'method="post" action="'
.
qa_path_html
(
qa_request
())
.
'"'
,
'style'
=>
'tall'
,
'fields'
=>
array
(
'title'
=>
array
(
'label'
=>
qa_lang_html
(
'admin/widget_name'
)
.
' '
.
qa_html
(
$editwidget
[
'title'
]),
'type'
=>
'static'
,
'tight'
=>
true
,
),
'position'
=>
array
(
'id'
=>
'position_display'
,
'tags'
=>
'name="position"'
,
'label'
=>
qa_lang_html
(
'admin/position'
),
'type'
=>
'select'
,
'options'
=>
$positionoptions
,
'value'
=>
$positionvalue
,
),
'delete'
=>
array
(
'tags'
=>
'name="dodelete" id="dodelete"'
,
'label'
=>
qa_lang_html
(
'admin/delete_widget_position'
),
'value'
=>
0
,
'type'
=>
'checkbox'
,
),
'all'
=>
array
(
'id'
=>
'all_display'
,
'label'
=>
qa_lang_html
(
'admin/widget_all_pages'
),
'type'
=>
'checkbox'
,
'tags'
=>
'name="template_all" id="template_all"'
,
'value'
=>
is_numeric
(
strpos
(
','
.@
$editwidget
[
'tags'
]
.
','
,
',all,'
)),
),
'templates'
=>
array
(
'id'
=>
'templates_display'
,
'label'
=>
qa_lang_html
(
'admin/widget_pages_explanation'
),
'type'
=>
'custom'
,
'html'
=>
''
,
),
),
'buttons'
=>
array
(
'style'
=>
'tall'
,
'save'
=>
array
(
'label'
=>
qa_lang_html
(
isset
(
$editwidget
[
'widgetid'
])
?
'main/save_button'
:
(
'admin/add_widget_button'
)),
),
'cancel'
=>
array
(
'fields'
=>
array
(
'tags'
=>
'name="docancel"'
,
'title'
=>
array
(
'label'
=>
qa_lang_html
(
'main/cancel_button'
),
'label'
=>
qa_lang_html
(
'admin/widget_name'
)
.
' '
.
qa_html
(
$editwidget
[
'title'
]),
),
'type'
=>
'static'
,
'tight'
=>
true
,
),
),
'hidden'
=>
array
(
'position'
=>
array
(
'dosavewidget'
=>
'1'
,
// for IE
'id'
=>
'position_display'
,
'edit'
=>
@
$editwidget
[
'widgetid'
],
'tags'
=>
'name="position"'
,
'title'
=>
@
$editwidget
[
'title'
],
'label'
=>
qa_lang_html
(
'admin/position'
),
'code'
=>
qa_get_form_security_code
(
'admin/widgets'
),
'type'
=>
'select'
,
'options'
=>
$positionoptions
,
'value'
=>
$positionvalue
,
),
),
);
foreach
(
$templateoptions
as
$template
=>
$optionhtml
)
'delete'
=>
array
(
$qa_content
[
'form'
][
'fields'
][
'templates'
][
'html'
]
.=
'tags'
=>
'name="dodelete" id="dodelete"'
,
'<input type="checkbox" name="template_'
.
qa_html
(
$template
)
.
'"'
.
'label'
=>
qa_lang_html
(
'admin/delete_widget_position'
),
(
is_numeric
(
strpos
(
','
.@
$editwidget
[
'tags'
]
.
','
,
','
.
$template
.
','
))
?
' checked'
:
''
)
.
'value'
=>
0
,
'/> '
.
$optionhtml
.
'<br/>'
;
'type'
=>
'checkbox'
,
),
if
(
isset
(
$editwidget
[
'widgetid'
]))
'all'
=>
array
(
qa_set_display_rules
(
$qa_content
,
array
(
'id'
=>
'all_display'
,
'templates_display'
=>
'!(dodelete||template_all)'
,
'label'
=>
qa_lang_html
(
'admin/widget_all_pages'
),
'all_display'
=>
'!dodelete'
,
'type'
=>
'checkbox'
,
));
'tags'
=>
'name="template_all" id="template_all"'
,
'value'
=>
is_numeric
(
strpos
(
','
.
@
$editwidget
[
'tags'
]
.
','
,
',all,'
)),
),
else
{
'templates'
=>
array
(
unset
(
$qa_content
[
'form'
][
'fields'
][
'delete'
]);
'id'
=>
'templates_display'
,
qa_set_display_rules
(
$qa_content
,
array
(
'label'
=>
qa_lang_html
(
'admin/widget_pages_explanation'
),
'templates_display'
=>
'!template_all'
,
'type'
=>
'custom'
,
));
'html'
=>
''
,
}
),
),
if
(
!
$widgetfound
)
{
'buttons'
=>
array
(
unset
(
$qa_content
[
'form'
][
'fields'
][
'title'
][
'tight'
]);
'save'
=>
array
(
$qa_content
[
'form'
][
'fields'
][
'title'
][
'error'
]
=
qa_lang_html
(
'admin/widget_not_available'
);
'label'
=>
qa_lang_html
(
isset
(
$editwidget
[
'widgetid'
])
?
'main/save_button'
:
(
'admin/add_widget_button'
)),
unset
(
$qa_content
[
'form'
][
'fields'
][
'position'
]);
),
unset
(
$qa_content
[
'form'
][
'fields'
][
'all'
]);
unset
(
$qa_content
[
'form'
][
'fields'
][
'templates'
]);
if
(
!
isset
(
$editwidget
[
'widgetid'
]))
unset
(
$qa_content
[
'form'
][
'buttons'
][
'save'
]);
}
elseif
(
!
count
(
$positionoptions
))
{
unset
(
$qa_content
[
'form'
][
'fields'
][
'title'
][
'tight'
]);
$qa_content
[
'form'
][
'fields'
][
'title'
][
'error'
]
=
qa_lang_html
(
'admin/widget_no_positions'
);
unset
(
$qa_content
[
'form'
][
'fields'
][
'position'
]);
unset
(
$qa_content
[
'form'
][
'fields'
][
'all'
]);
unset
(
$qa_content
[
'form'
][
'fields'
][
'templates'
]);
unset
(
$qa_content
[
'form'
][
'buttons'
][
'save'
]);
}
$qa_content
[
'navigation'
][
'sub'
]
=
qa_admin_sub_navigation
();
'cancel'
=>
array
(
'tags'
=>
'name="docancel"'
,
'label'
=>
qa_lang_html
(
'main/cancel_button'
),
),
),
'hidden'
=>
array
(
'dosavewidget'
=>
'1'
,
// for IE
'edit'
=>
@
$editwidget
[
'widgetid'
],
'title'
=>
@
$editwidget
[
'title'
],
'code'
=>
qa_get_form_security_code
(
'admin/widgets'
),
),
);
foreach
(
$templateoptions
as
$template
=>
$optionhtml
)
{
$qa_content
[
'form'
][
'fields'
][
'templates'
][
'html'
]
.=
'<input type="checkbox" name="template_'
.
qa_html
(
$template
)
.
'"'
.
(
is_numeric
(
strpos
(
','
.
@
$editwidget
[
'tags'
]
.
','
,
','
.
$template
.
','
))
?
' checked'
:
''
)
.
'/> '
.
$optionhtml
.
'<br/>'
;
}
if
(
isset
(
$editwidget
[
'widgetid'
]))
{
qa_set_display_rules
(
$qa_content
,
array
(
'templates_display'
=>
'!(dodelete||template_all)'
,
'all_display'
=>
'!dodelete'
,
));
}
else
{
unset
(
$qa_content
[
'form'
][
'fields'
][
'delete'
]);
qa_set_display_rules
(
$qa_content
,
array
(
'templates_display'
=>
'!template_all'
,
));
}
if
(
!
$widgetfound
)
{
unset
(
$qa_content
[
'form'
][
'fields'
][
'title'
][
'tight'
]);
$qa_content
[
'form'
][
'fields'
][
'title'
][
'error'
]
=
qa_lang_html
(
'admin/widget_not_available'
);
unset
(
$qa_content
[
'form'
][
'fields'
][
'position'
]);
unset
(
$qa_content
[
'form'
][
'fields'
][
'all'
]);
unset
(
$qa_content
[
'form'
][
'fields'
][
'templates'
]);
if
(
!
isset
(
$editwidget
[
'widgetid'
]))
unset
(
$qa_content
[
'form'
][
'buttons'
][
'save'
]);
}
elseif
(
!
count
(
$positionoptions
))
{
unset
(
$qa_content
[
'form'
][
'fields'
][
'title'
][
'tight'
]);
$qa_content
[
'form'
][
'fields'
][
'title'
][
'error'
]
=
qa_lang_html
(
'admin/widget_no_positions'
);
unset
(
$qa_content
[
'form'
][
'fields'
][
'position'
]);
unset
(
$qa_content
[
'form'
][
'fields'
][
'all'
]);
unset
(
$qa_content
[
'form'
][
'fields'
][
'templates'
]);
unset
(
$qa_content
[
'form'
][
'buttons'
][
'save'
]);
}
return
$qa_content
;
$qa_content
[
'navigation'
][
'sub'
]
=
qa_admin_sub_navigation
()
;
/*
return
$qa_content
;
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
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