Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
info
mahara-museum
Commits
67df96f0
Commit
67df96f0
authored
Jan 14, 2008
by
Richard Mansfield
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change the name of the blogfiles folder when a user changes language setting
parent
a4abcab7
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
51 additions
and
4 deletions
+51
-4
htdocs/account/index.php
htdocs/account/index.php
+5
-1
htdocs/artefact/blog/lib.php
htdocs/artefact/blog/lib.php
+2
-2
htdocs/artefact/file/lib.php
htdocs/artefact/file/lib.php
+4
-1
htdocs/auth/user.php
htdocs/auth/user.php
+40
-0
No files found.
htdocs/account/index.php
View file @
67df96f0
...
...
@@ -192,7 +192,11 @@ function accountprefs_submit(Pieform $form, $values) {
// use this as looping through values is not safe.
$expectedprefs
=
expected_account_preferences
();
foreach
(
array_keys
(
$expectedprefs
)
as
$pref
)
{
$USER
->
set_account_preference
(
$pref
,
$values
[
$pref
]);
if
(
$pref
==
'lang'
)
{
$USER
->
set_language
(
$values
[
$pref
]);
}
else
{
$USER
->
set_account_preference
(
$pref
,
$values
[
$pref
]);
}
}
db_commit
();
...
...
htdocs/artefact/blog/lib.php
View file @
67df96f0
...
...
@@ -724,11 +724,11 @@ class ArtefactTypeBlogPost extends ArtefactType {
return
$fileid
;
}
public
static
function
blogfiles_folder_id
()
{
public
static
function
blogfiles_folder_id
(
$create
=
true
)
{
$name
=
get_string
(
'blogfilesdirname'
,
'artefact.blog'
);
$description
=
get_string
(
'blogfilesdirdescription'
,
'artefact.blog'
);
safe_require
(
'artefact'
,
'file'
);
return
ArtefactTypeFolder
::
get_folder_id
(
$name
,
$description
);
return
ArtefactTypeFolder
::
get_folder_id
(
$name
,
$description
,
null
,
null
,
$create
);
}
/**
...
...
htdocs/artefact/file/lib.php
View file @
67df96f0
...
...
@@ -813,12 +813,15 @@ class ArtefactTypeFolder extends ArtefactTypeFileBase {
}
// Get the id of a folder, creating the folder if necessary
public
static
function
get_folder_id
(
$name
,
$description
,
$parentfolderid
=
null
,
$userid
=
null
)
{
public
static
function
get_folder_id
(
$name
,
$description
,
$parentfolderid
=
null
,
$userid
=
null
,
$create
=
true
)
{
if
(
empty
(
$userid
))
{
global
$USER
;
$userid
=
$USER
->
id
;
}
if
(
!
$record
=
self
::
get_folder_by_name
(
$name
,
$parentfolderid
,
$userid
))
{
if
(
!
$create
)
{
return
false
;
}
$data
=
new
StdClass
;
$data
->
title
=
$name
;
$data
->
description
=
$description
;
...
...
htdocs/auth/user.php
View file @
67df96f0
...
...
@@ -290,6 +290,46 @@ class User {
$this
->
set
(
'accountprefs'
,
$accountprefs
);
}
public
function
set_language
(
$value
)
{
$oldlang
=
$this
->
get_account_preference
(
'lang'
);
if
(
empty
(
$oldlang
)
||
$oldlang
==
'default'
)
{
$oldlang
=
get_config
(
'lang'
);
}
if
(
empty
(
$value
)
||
$value
==
'default'
)
{
$newlang
=
get_config
(
'lang'
);
}
else
{
$newlang
=
$value
;
}
// Update the name of the user's blogfiles folder.
// @todo: This is nasty because we can't currently specify a
// language when calling get_string(), so we will get the
// folder here, using the old language, and then rename it
// below after the language has been reset.
if
(
$newlang
!=
$oldlang
&&
get_field
(
'artefact_installed'
,
'active'
,
'name'
,
'blog'
))
{
safe_require
(
'artefact'
,
'blog'
);
$blogfilesid
=
ArtefactTypeBlogPost
::
blogfiles_folder_id
(
false
);
}
$this
->
set_account_preference
(
'lang'
,
$value
);
$blogfiles
=
null
;
if
(
$newlang
!=
$oldlang
&&
!
empty
(
$blogfilesid
))
{
$name
=
get_string
(
'blogfilesdirname'
,
'artefact.blog'
);
$description
=
get_string
(
'blogfilesdirdescription'
,
'artefact.blog'
);
if
(
!
empty
(
$name
))
{
$blogfiles
=
artefact_instance_from_id
(
$blogfilesid
);
$blogfiles
->
set
(
'title'
,
$name
);
$blogfiles
->
set
(
'description'
,
$description
);
$blogfiles
->
commit
();
}
}
}
/**
* Determines if the user is currently logged in
*
...
...
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