Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
drupal
Commits
da38e1b6
Commit
da38e1b6
authored
18 years ago
by
Steven Wittens
Browse files
Options
Downloads
Patches
Plain Diff
- Store correct format id instead of 0 for anonymous users (+ code cleanup)
parent
13e52fe3
No related branches found
No related tags found
2 merge requests
!7452
Issue #1797438. HTML5 validation is preventing form submit and not fully...
,
!789
Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
modules/filter.module
+12
-10
12 additions, 10 deletions
modules/filter.module
modules/filter/filter.module
+12
-10
12 additions, 10 deletions
modules/filter/filter.module
with
24 additions
and
20 deletions
modules/filter.module
+
12
−
10
View file @
da38e1b6
...
@@ -669,12 +669,18 @@ function _filter_list_cmp($a, $b) {
...
@@ -669,12 +669,18 @@ function _filter_list_cmp($a, $b) {
return
strcmp
(
$a
->
name
,
$b
->
name
);
return
strcmp
(
$a
->
name
,
$b
->
name
);
}
}
/**
* Resolve a format id, including the default format.
*/
function
filter_resolve_format
(
$format
)
{
return
$format
==
FILTER_FORMAT_DEFAULT
?
variable_get
(
'filter_default_format'
,
1
)
:
$format
;
}
/**
/**
* Check if text in a certain input format is allowed to be cached.
* Check if text in a certain input format is allowed to be cached.
*/
*/
function
filter_format_allowcache
(
$format
)
{
function
filter_format_allowcache
(
$format
)
{
static
$cache
=
array
();
static
$cache
=
array
();
$format
=
filter_resolve_format
(
$format
);
if
(
!
isset
(
$cache
[
$format
]))
{
if
(
!
isset
(
$cache
[
$format
]))
{
$cache
[
$format
]
=
db_result
(
db_query
(
'SELECT cache FROM {filter_formats} WHERE format = %d'
,
$format
));
$cache
[
$format
]
=
db_result
(
db_query
(
'SELECT cache FROM {filter_formats} WHERE format = %d'
,
$format
));
}
}
...
@@ -735,9 +741,7 @@ function filter_list_format($format) {
...
@@ -735,9 +741,7 @@ function filter_list_format($format) {
function
check_markup
(
$text
,
$format
=
FILTER_FORMAT_DEFAULT
,
$check
=
TRUE
)
{
function
check_markup
(
$text
,
$format
=
FILTER_FORMAT_DEFAULT
,
$check
=
TRUE
)
{
// When $check = true, do an access check on $format.
// When $check = true, do an access check on $format.
if
(
isset
(
$text
)
&&
(
!
$check
||
filter_access
(
$format
)))
{
if
(
isset
(
$text
)
&&
(
!
$check
||
filter_access
(
$format
)))
{
if
(
$format
==
FILTER_FORMAT_DEFAULT
)
{
$format
=
filter_resolve_format
(
$format
);
$format
=
variable_get
(
'filter_default_format'
,
1
);
}
// Check for a cached version of this piece of text.
// Check for a cached version of this piece of text.
$id
=
'filter:'
.
$format
.
':'
.
md5
(
$text
);
$id
=
'filter:'
.
$format
.
':'
.
md5
(
$text
);
...
@@ -790,9 +794,7 @@ function check_markup($text, $format = FILTER_FORMAT_DEFAULT, $check = TRUE) {
...
@@ -790,9 +794,7 @@ function check_markup($text, $format = FILTER_FORMAT_DEFAULT, $check = TRUE) {
* HTML for the form element.
* HTML for the form element.
*/
*/
function
filter_form
(
$value
=
FILTER_FORMAT_DEFAULT
,
$weight
=
NULL
,
$parents
=
array
(
'format'
))
{
function
filter_form
(
$value
=
FILTER_FORMAT_DEFAULT
,
$weight
=
NULL
,
$parents
=
array
(
'format'
))
{
if
(
$value
==
FILTER_FORMAT_DEFAULT
)
{
$format
=
filter_resolve_format
(
$format
);
$value
=
variable_get
(
'filter_default_format'
,
1
);
}
$formats
=
filter_formats
();
$formats
=
filter_formats
();
$extra
=
l
(
t
(
'More information about formatting options'
),
'filter/tips'
);
$extra
=
l
(
t
(
'More information about formatting options'
),
'filter/tips'
);
...
@@ -821,10 +823,9 @@ function filter_form($value = FILTER_FORMAT_DEFAULT, $weight = NULL, $parents =
...
@@ -821,10 +823,9 @@ function filter_form($value = FILTER_FORMAT_DEFAULT, $weight = NULL, $parents =
else
{
else
{
// Only one format available: use a hidden form item and only show tips.
// Only one format available: use a hidden form item and only show tips.
$format
=
array_shift
(
$formats
);
$format
=
array_shift
(
$formats
);
$form
[
'
format
'
][
$
format
->
name
]
=
array
(
'#type'
=>
'value'
,
'#value'
=>
$format
->
format
);
$form
[
$
format
->
format
]
=
array
(
'#type'
=>
'value'
,
'#value'
=>
$format
->
format
,
'#parents'
=>
$parents
);
$tips
=
_filter_tips
(
variable_get
(
'filter_default_format'
,
1
),
false
);
$tips
=
_filter_tips
(
variable_get
(
'filter_default_format'
,
1
),
false
);
$form
[
'format'
][
'guidelines'
]
=
array
(
$form
[
'format'
][
'guidelines'
]
=
array
(
'#type'
=>
'markup'
,
'#title'
=>
t
(
'Formatting guidelines'
),
'#title'
=>
t
(
'Formatting guidelines'
),
'#value'
=>
theme
(
'filter_tips'
,
$tips
,
false
,
$extra
),
'#value'
=>
theme
(
'filter_tips'
,
$tips
,
false
,
$extra
),
);
);
...
@@ -846,7 +847,8 @@ function filter_form_validate($form) {
...
@@ -846,7 +847,8 @@ function filter_form_validate($form) {
* Returns true if the user is allowed to access this format.
* Returns true if the user is allowed to access this format.
*/
*/
function
filter_access
(
$format
)
{
function
filter_access
(
$format
)
{
if
(
user_access
(
'administer filters'
)
||
(
$format
==
FILTER_FORMAT_DEFAULT
)
||
(
$format
==
variable_get
(
'filter_default_format'
,
1
)))
{
$format
=
filter_resolve_format
(
$format
);
if
(
user_access
(
'administer filters'
)
||
(
$format
==
variable_get
(
'filter_default_format'
,
1
)))
{
return
true
;
return
true
;
}
}
else
{
else
{
...
...
This diff is collapsed.
Click to expand it.
modules/filter/filter.module
+
12
−
10
View file @
da38e1b6
...
@@ -669,12 +669,18 @@ function _filter_list_cmp($a, $b) {
...
@@ -669,12 +669,18 @@ function _filter_list_cmp($a, $b) {
return
strcmp
(
$a
->
name
,
$b
->
name
);
return
strcmp
(
$a
->
name
,
$b
->
name
);
}
}
/**
* Resolve a format id, including the default format.
*/
function
filter_resolve_format
(
$format
)
{
return
$format
==
FILTER_FORMAT_DEFAULT
?
variable_get
(
'filter_default_format'
,
1
)
:
$format
;
}
/**
/**
* Check if text in a certain input format is allowed to be cached.
* Check if text in a certain input format is allowed to be cached.
*/
*/
function
filter_format_allowcache
(
$format
)
{
function
filter_format_allowcache
(
$format
)
{
static
$cache
=
array
();
static
$cache
=
array
();
$format
=
filter_resolve_format
(
$format
);
if
(
!
isset
(
$cache
[
$format
]))
{
if
(
!
isset
(
$cache
[
$format
]))
{
$cache
[
$format
]
=
db_result
(
db_query
(
'SELECT cache FROM {filter_formats} WHERE format = %d'
,
$format
));
$cache
[
$format
]
=
db_result
(
db_query
(
'SELECT cache FROM {filter_formats} WHERE format = %d'
,
$format
));
}
}
...
@@ -735,9 +741,7 @@ function filter_list_format($format) {
...
@@ -735,9 +741,7 @@ function filter_list_format($format) {
function
check_markup
(
$text
,
$format
=
FILTER_FORMAT_DEFAULT
,
$check
=
TRUE
)
{
function
check_markup
(
$text
,
$format
=
FILTER_FORMAT_DEFAULT
,
$check
=
TRUE
)
{
// When $check = true, do an access check on $format.
// When $check = true, do an access check on $format.
if
(
isset
(
$text
)
&&
(
!
$check
||
filter_access
(
$format
)))
{
if
(
isset
(
$text
)
&&
(
!
$check
||
filter_access
(
$format
)))
{
if
(
$format
==
FILTER_FORMAT_DEFAULT
)
{
$format
=
filter_resolve_format
(
$format
);
$format
=
variable_get
(
'filter_default_format'
,
1
);
}
// Check for a cached version of this piece of text.
// Check for a cached version of this piece of text.
$id
=
'filter:'
.
$format
.
':'
.
md5
(
$text
);
$id
=
'filter:'
.
$format
.
':'
.
md5
(
$text
);
...
@@ -790,9 +794,7 @@ function check_markup($text, $format = FILTER_FORMAT_DEFAULT, $check = TRUE) {
...
@@ -790,9 +794,7 @@ function check_markup($text, $format = FILTER_FORMAT_DEFAULT, $check = TRUE) {
* HTML for the form element.
* HTML for the form element.
*/
*/
function
filter_form
(
$value
=
FILTER_FORMAT_DEFAULT
,
$weight
=
NULL
,
$parents
=
array
(
'format'
))
{
function
filter_form
(
$value
=
FILTER_FORMAT_DEFAULT
,
$weight
=
NULL
,
$parents
=
array
(
'format'
))
{
if
(
$value
==
FILTER_FORMAT_DEFAULT
)
{
$format
=
filter_resolve_format
(
$format
);
$value
=
variable_get
(
'filter_default_format'
,
1
);
}
$formats
=
filter_formats
();
$formats
=
filter_formats
();
$extra
=
l
(
t
(
'More information about formatting options'
),
'filter/tips'
);
$extra
=
l
(
t
(
'More information about formatting options'
),
'filter/tips'
);
...
@@ -821,10 +823,9 @@ function filter_form($value = FILTER_FORMAT_DEFAULT, $weight = NULL, $parents =
...
@@ -821,10 +823,9 @@ function filter_form($value = FILTER_FORMAT_DEFAULT, $weight = NULL, $parents =
else
{
else
{
// Only one format available: use a hidden form item and only show tips.
// Only one format available: use a hidden form item and only show tips.
$format
=
array_shift
(
$formats
);
$format
=
array_shift
(
$formats
);
$form
[
'
format
'
][
$
format
->
name
]
=
array
(
'#type'
=>
'value'
,
'#value'
=>
$format
->
format
);
$form
[
$
format
->
format
]
=
array
(
'#type'
=>
'value'
,
'#value'
=>
$format
->
format
,
'#parents'
=>
$parents
);
$tips
=
_filter_tips
(
variable_get
(
'filter_default_format'
,
1
),
false
);
$tips
=
_filter_tips
(
variable_get
(
'filter_default_format'
,
1
),
false
);
$form
[
'format'
][
'guidelines'
]
=
array
(
$form
[
'format'
][
'guidelines'
]
=
array
(
'#type'
=>
'markup'
,
'#title'
=>
t
(
'Formatting guidelines'
),
'#title'
=>
t
(
'Formatting guidelines'
),
'#value'
=>
theme
(
'filter_tips'
,
$tips
,
false
,
$extra
),
'#value'
=>
theme
(
'filter_tips'
,
$tips
,
false
,
$extra
),
);
);
...
@@ -846,7 +847,8 @@ function filter_form_validate($form) {
...
@@ -846,7 +847,8 @@ function filter_form_validate($form) {
* Returns true if the user is allowed to access this format.
* Returns true if the user is allowed to access this format.
*/
*/
function
filter_access
(
$format
)
{
function
filter_access
(
$format
)
{
if
(
user_access
(
'administer filters'
)
||
(
$format
==
FILTER_FORMAT_DEFAULT
)
||
(
$format
==
variable_get
(
'filter_default_format'
,
1
)))
{
$format
=
filter_resolve_format
(
$format
);
if
(
user_access
(
'administer filters'
)
||
(
$format
==
variable_get
(
'filter_default_format'
,
1
)))
{
return
true
;
return
true
;
}
}
else
{
else
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment