Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
drupal
Commits
fd86977c
Commit
fd86977c
authored
Jan 21, 2004
by
Dries
Browse files
- Added missing permission check. Patch by Ax. - Added a $granularity field to format_interval().
parent
8d8e3d6a
Changes
1
Hide whitespace changes
Inline
Side-by-side
includes/common.inc
View file @
fd86977c
...
...
@@ -766,13 +766,18 @@ function format_size($size) {
return
t
(
"%size %suffix"
,
array
(
"%size"
=>
$size
,
"%suffix"
=>
$suffix
));
}
function
format_interval
(
$timestamp
)
{
function
format_interval
(
$timestamp
,
$granularity
=
2
)
{
$units
=
array
(
"1 year|%count years"
=>
31536000
,
"1 week|%count weeks"
=>
604800
,
"1 day|%count days"
=>
86400
,
"1 hour|%count hours"
=>
3600
,
"1 min|%count min"
=>
60
,
"1 sec|%count sec"
=>
1
);
foreach
(
$units
as
$key
=>
$value
)
{
$key
=
explode
(
"|"
,
$key
);
if
(
$timestamp
>=
$value
)
{
$output
.
=
(
$output
?
" "
:
""
)
.
format_plural
(
floor
(
$timestamp
/
$value
),
$key
[
0
],
$key
[
1
]);
$timestamp
%=
$value
;
$granularity
--
;
}
if
(
$granularity
==
0
)
{
break
;
}
}
return
(
$output
)
?
$output
:
t
(
"0 sec"
);
...
...
@@ -827,7 +832,7 @@ function format_name($object) {
$name
=
$object
->
name
;
}
if
(
arg
(
0
)
==
"admin"
)
{
if
(
arg
(
0
)
==
"admin"
and
user_access
(
"administer users"
)
)
{
$output
=
l
(
$name
,
"admin/user/edit/
$object->uid
"
,
array
(
"title"
=>
t
(
"Administer user profile."
)));
}
else
{
...
...
Write
Preview
Supports
Markdown
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