Using the function "mysite_create_account" it would be easy to add an option/button to give the user the possibility to reset their mysite to default-state.
At the moment I am using a different managment page for this looking something like this:
<?php
global $user;
//Delete user
$sql = "DELETE FROM {mysite} WHERE uid = %d";
db_query($sql, $user->uid);
//Delete content
$sql = "DELETE FROM {mysite_data} WHERE uid = %d";
db_query($sql, $user->uid);
//Add user
$sql = "INSERT INTO {mysite} (uid, title, created, status) VALUES (%d, '%s', %d, %d)";
db_query($sql, $user->uid, $user->name, time(), variable_get('mysite_private_status', 1));
// add default content to the user page if it has been set
$get = mysite_get(0);
if (isset($get->uid)) {
$default = db_fetch_object(db_query("SELECT layout, style, format, theme FROM {mysite} WHERE uid = 0"));
$sql = "UPDATE {mysite} SET layout = '%s', style = '%s', format = '%s', theme = '%s' WHERE uid = %d";
db_query($sql, $default->layout, $default->style, $default->format, $default->theme, $user->uid);
$content = db_query("SELECT title, type, type_id, sort, format, position, settings FROM {mysite_data} WHERE uid = 0");
while ($data = db_fetch_object($content)) {
$mid = db_next_id('{mysite_data}_mid');
$sql = "INSERT INTO {mysite_data} (mid, uid, title, type, type_id, sort, format, position, settings) VALUES (%d, %d, '%s', '%s', %d, %d, '%s', %d, '%s')";
db_query($sql, $mid, $user->uid, $data->title, $data->type, $data->type_id, $data->sort, $data->format, $data->position, $data->settings);
}
}
?>
It ain't pretty but it works.
Is this something that should be added in mysite directly perhaps?
Comments
Comment #1
agentrickardYes, I think so. This seems pretty obvious to me.
To integrate this, write code against HEAD. You code looks right (at first glance). All you need is a menu item, a callback function (which you've basically written), and a line or two inside
theme_mysite_submenu().This would be a good chance for you to write a patch.
The menu item would be a MENU_CALLBACK, likely to path 'mysite/UID/reset'
Comment #2
agentrickardFixed. Will commit to HEAD shortly.
Comment #3
(not verified) commented