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
mahara
mahara
Commits
d13da888
Commit
d13da888
authored
Sep 17, 2008
by
Richard Mansfield
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create user profile views from a site default
parent
a2627eb1
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
84 additions
and
22 deletions
+84
-22
htdocs/lib/db/upgrade.php
htdocs/lib/db/upgrade.php
+17
-0
htdocs/lib/user.php
htdocs/lib/user.php
+63
-21
htdocs/lib/version.php
htdocs/lib/version.php
+1
-1
htdocs/user/view.php
htdocs/user/view.php
+3
-0
No files found.
htdocs/lib/db/upgrade.php
View file @
d13da888
...
...
@@ -1363,6 +1363,23 @@ function xmldb_core_upgrade($oldversion=0) {
}
}
if
(
$oldversion
<
2008091603
)
{
foreach
(
array
(
'myviews'
,
'mygroups'
,
'myfriends'
,
'wall'
)
as
$blocktype
)
{
$data
=
check_upgrades
(
"blocktype.
$blocktype
"
);
if
(
$data
)
{
upgrade_plugin
(
$data
);
}
}
$viewid
=
get_field
(
'view'
,
'id'
,
'owner'
,
0
,
'type'
,
'profile'
);
if
(
$viewid
)
{
require_once
(
get_config
(
'libroot'
)
.
'view.php'
);
$systemview
=
new
View
(
$viewid
);
$systemview
->
delete
();
}
install_system_profile_view
();
insert_record
(
'event_subscription'
,
(
object
)
array
(
'event'
=>
'createuser'
,
'callfunction'
=>
'install_default_profile_view'
));
}
return
$status
;
}
...
...
htdocs/lib/user.php
View file @
d13da888
...
...
@@ -1155,23 +1155,33 @@ function create_user($user, $profile=array(), $institution=null, $remoteauth=nul
function
copy_view_for_user
(
$userid
,
$templateid
)
{
if
(
!
$templateid
)
{
return
;
}
$template
=
new
View
(
$templateid
);
$v
=
new
View
(
0
,
(
object
)
array
(
'template'
=>
0
,
'numcolumns'
=>
3
,
'owner'
=>
$userid
,
'title'
=>
$template
->
get
(
'title'
),
'description'
=>
$template
->
get
(
'description'
),
'type'
=>
$template
->
get
(
'type'
),
));
$v
->
commit
();
$v
->
copy_contents
(
$template
);
$v
->
commit
();
return
$v
;
}
function
copy_views_for_user
(
$userid
,
$templateids
)
{
if
(
!
$templateids
)
{
return
;
}
require_once
(
get_config
(
'libroot'
)
.
'view.php'
);
foreach
(
$templateids
as
$tid
)
{
$template
=
new
View
(
$tid
);
$v
=
new
View
(
0
,
(
object
)
array
(
'template'
=>
0
,
'numcolumns'
=>
3
,
'owner'
=>
$userid
,
'title'
=>
$template
->
get
(
'title'
),
'description'
=>
$template
->
get
(
'description'
),
));
$v
->
commit
();
$v
->
copy_contents
(
$template
);
$v
->
commit
();
copy_view_for_user
(
$userid
,
$tid
);
}
}
...
...
@@ -1184,24 +1194,56 @@ function copy_views_for_user($userid, $templateids) {
*/
function
install_default_profile_view
(
$eventdata
)
{
require_once
(
get_config
(
'libroot'
)
.
'view.php'
);
$viewid
=
get_field
(
'view'
,
'id'
,
'owner'
,
0
,
'type'
,
'profile'
);
if
(
!
$viewid
)
{
$viewid
=
install_system_profile_view
();
}
$view
=
copy_view_for_user
(
$eventdata
[
'id'
],
$viewid
);
$view
->
set_access
(
array
(
array
(
'type'
=>
'loggedin'
,
'startdate'
=>
null
,
'stopdate'
=>
null
,
),
));
}
/**
*
* This function installs the site's default profile view
*
*/
function
install_system_profile_view
()
{
require_once
(
get_config
(
'libroot'
)
.
'view.php'
);
$view
=
new
View
(
0
,
array
(
'type'
=>
'profile'
,
'owner'
=>
$eventdata
[
'id'
]
,
'owner'
=>
0
,
'numcolumns'
=>
2
,
'ownerformat'
=>
FORMAT_NAME_PREFERREDNAME
,
'title'
=>
get_string
(
'profileviewtitle'
,
'view'
),
'description'
=>
''
,
));
$view
->
commit
();
// #TODO add blocks here
$view
->
set_access
(
array
(
array
(
'type'
=>
'loggedin'
,
'startdate'
=>
null
,
'stopdate'
=>
null
,
),
));
$blocktypes
=
array
(
'myviews'
=>
1
,
'mygroups'
=>
1
,
'myfriends'
=>
2
,
'wall'
=>
2
);
// column ids
$installed
=
get_column_sql
(
'SELECT name FROM {blocktype_installed} WHERE name IN ('
.
join
(
','
,
array_map
(
'db_quote'
,
array_keys
(
$blocktypes
)))
.
')'
);
$weights
=
array
(
1
=>
0
,
2
=>
0
);
foreach
(
array_keys
(
$blocktypes
)
as
$blocktype
)
{
if
(
in_array
(
$blocktype
,
$installed
))
{
$weights
[
$blocktypes
[
$blocktype
]]
++
;
$newblock
=
new
BlockInstance
(
0
,
array
(
'blocktype'
=>
$blocktype
,
'title'
=>
get_string
(
'title'
,
'blocktype.'
.
$blocktype
),
'view'
=>
$view
->
get
(
'id'
),
'column'
=>
$blocktypes
[
$blocktype
],
'order'
=>
$weights
[
$blocktypes
[
$blocktype
]],
));
$newblock
->
commit
();
}
}
return
$view
->
get
(
'id'
);
}
...
...
htdocs/lib/version.php
View file @
d13da888
...
...
@@ -27,7 +27,7 @@
defined
(
'INTERNAL'
)
||
die
();
$config
=
new
StdClass
;
$config
->
version
=
200809160
1
;
$config
->
version
=
200809160
3
;
$config
->
release
=
'1.1.0alpha2dev'
;
$config
->
minupgradefrom
=
2007080700
;
$config
->
minupgraderelease
=
'0.8.0 (release tag 0.8.0_RELEASE)'
;
...
...
htdocs/user/view.php
View file @
d13da888
...
...
@@ -37,6 +37,9 @@ if (!empty($loggedinid)) {
else
{
$userid
=
param_integer
(
'id'
);
}
if
(
$userid
==
0
)
{
redirect
();
}
if
(
$userid
==
$loggedinid
)
{
define
(
'MENUITEM'
,
'profile/view'
);
}
...
...
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