Потребителите могат да си изтриват акаунта
Този мод позволява на потребителите да трият акаунта си.

Инсталация: 5 минутки
Файлове за редактиране : 5
admin/admin_board.php
includes/usercp_register.php
language/език/lang_main.php
language/език/lang_admin.php
templates/скин/admin/board_config_body.tpl
templates/скин/profile_add_body.tpl

Тук трабва да добавим SQL.Ето как става за тези които не знаят - влизате във вашият администраторски панел на вашия форум,отваряте phpmyadmin и в случея отваряме базата - името_config,след това даваме на SQL и вкарваме кода.

#
#-----[ SQL ]----------------------------------------------
#

INSERT INTO `иметонавашатабаза_config` VALUES ('account_delete', '1');

#
#-----[Отворете]----------------------------------------------
#

admin/admin_board.php

#
#-----[Намерете]----------------------------------------------
#

$disable_board_yes = ( $new['board_disable'] ) ? "checked=\"checked\"" : "";
$disable_board_no = ( !$new['board_disable'] ) ? "checked=\"checked\"" : "";

#
#-----[След това добавете]----------------------------------------------
#

// Begin Account Self-Delete MOD
$account_delete_yes = ( $new['account_delete'] ) ? "checked=\"checked\"" : "";
$account_delete_no = ( !$new['account_delete'] ) ? "checked=\"checked\"" : "";
// End Account Self-Delete MOD

#
#-----[Намерете]----------------------------------------------
#

"L_DISABLE_BOARD_EXPLAIN" => $lang['Board_disable_explain'],

#
#-----[След това добавете]----------------------------------------------
#

// Begin Account Self-Delete MOD
"L_ACCOUNT_DELETE" => $lang['account_delete'],
// End Account Self-Delete MOD

#
#-----[Намерете]----------------------------------------------
#

"S_DISABLE_BOARD_NO" => $disable_board_no,

#
#-----[След това добавете]----------------------------------------------
#


// Begin Account Self-Delete MOD
"S_ACCOUNT_DELETE_YES" => $account_delete_yes,
"S_ACCOUNT_DELETE_NO" => $account_delete_no,
// End Account Self-Delete MOD

#
#-----[Отворете]----------------------------------------------
#

includes/usercp_register.php

#
#-----[Намерете]----------------------------------------------
#

$strip_var_list = array(

#
#-----[Преди това добавете]----------------------------------------------
#

// Begin Account Self-Delete MOD
if( $HTTP_POST_VARS['deleteuser'] )
{
$message = "<form action=\"". append_sid("profile.$phpEx?mode=editprofile") ."\" method=\"post\">". $lang['Delete_account_question'] ."<br /><br /><input type=\"submit\" name=\"delete_confirm\" value=\"". $lang['Yes'] ."\" class=\"mainoption\" />  <input type=\"submit\" name=\"delete_cancel\" value=\"". $lang['No'] ."\" class=\"liteoption\" /><input type=\"hidden\" name=\"user_id\" value=\"$user_id\" /></form>";

message_die(GENERAL_MESSAGE, $message);
}
// End Account Self-Delete MOD

#
#-----[Намерете]----------------------------------------------
#

//
// Let's make sure the user isn't logged in while registering,
// and ensure that they were trying to register a second time
// (Prevents double registrations)
//

#
#-----[Преди това добавете]----------------------------------------------
#

// Begin Account Self-Delete MOD ** Code from admin/admin_users.php
if( isset($HTTP_POST_VARS['delete_confirm']) )
{
$user_id = intval( $HTTP_POST_VARS['user_id'] );

$sql = "SELECT g.group_id
FROM " . USER_GROUP_TABLE . " ug, " . GROUPS_TABLE . " g
WHERE ug.user_id = $user_id
AND g.group_id = ug.group_id
AND g.group_single_user = 1";
if( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not obtain group information for this user', '', __LINE__, __FILE__, $sql);
}

$row = $db->sql_fetchrow($result);

$sql = "UPDATE " . POSTS_TABLE . "
SET poster_id = " . DELETED . ", post_username = '$username'
WHERE poster_id = $user_id";
if( !$db->sql_query($sql) )
{
message_die(GENERAL_ERROR, 'Could not update posts for this user', '', __LINE__, __FILE__, $sql);
}

$sql = "UPDATE " . TOPICS_TABLE . "
SET topic_poster = " . DELETED . "
WHERE topic_poster = $user_id";
if( !$db->sql_query($sql) )
{
message_die(GENERAL_ERROR, 'Could not update topics for this user', '', __LINE__, __FILE__, $sql);
}

$sql = "UPDATE " . VOTE_USERS_TABLE . "
SET vote_user_id = " . DELETED . "
WHERE vote_user_id = $user_id";
if( !$db->sql_query($sql) )
{
message_die(GENERAL_ERROR, 'Could not update votes for this user', '', __LINE__, __FILE__, $sql);
}

$sql = "SELECT group_id
FROM " . GROUPS_TABLE . "
WHERE group_moderator = $user_id";
if( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not select groups where user was moderator', '', __LINE__, __FILE__, $sql);
}

while ( $row_group = $db->sql_fetchrow($result) )
{
$group_moderator[] = $row_group['group_id'];
}

if ( count($group_moderator) )
{
$update_moderator_id = implode(', ', $group_moderator);

$sql = "UPDATE " . GROUPS_TABLE . "
SET group_moderator = " . $userdata['user_id'] . "
WHERE group_moderator IN ($update_moderator_id)";
if( !$db->sql_query($sql) )
{
message_die(GENERAL_ERROR, 'Could not update group moderators', '', __LINE__, __FILE__, $sql);
}
}

$sql = "DELETE FROM " . USERS_TABLE . "
WHERE user_id = $user_id";
if( !$db->sql_query($sql) )
{
message_die(GENERAL_ERROR, 'Could not delete user', '', __LINE__, __FILE__, $sql);
}

$sql = "DELETE FROM " . USER_GROUP_TABLE . "
WHERE user_id = $user_id";
if( !$db->sql_query($sql) )
{
message_die(GENERAL_ERROR, 'Could not delete user from user_group table', '', __LINE__, __FILE__, $sql);
}

$sql = "DELETE FROM " . GROUPS_TABLE . "
WHERE group_id = " . $row['group_id'];
if( !$db->sql_query($sql) )
{
message_die(GENERAL_ERROR, 'Could not delete group for this user', '', __LINE__, __FILE__, $sql);
}

$sql = "DELETE FROM " . AUTH_ACCESS_TABLE . "
WHERE group_id = " . $row['group_id'];
if( !$db->sql_query($sql) )
{
message_die(GENERAL_ERROR, 'Could not delete group for this user', '', __LINE__, __FILE__, $sql);
}

$sql = "DELETE FROM " . TOPICS_WATCH_TABLE . "
WHERE user_id = $user_id";
if ( !$db->sql_query($sql) )
{
message_die(GENERAL_ERROR, 'Could not delete user from topic watch table', '', __LINE__, __FILE__, $sql);
}

$sql = "DELETE FROM " . BANLIST_TABLE . "
WHERE ban_userid = $user_id";
if ( !$db->sql_query($sql) )
{
message_die(GENERAL_ERROR, 'Could not delete user from banlist table', '', __LINE__, __FILE__, $sql);
}

$sql = "SELECT privmsgs_id
FROM " . PRIVMSGS_TABLE . "
WHERE privmsgs_from_userid = $user_id
OR privmsgs_to_userid = $user_id";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not select all users private messages', '', __LINE__, __FILE__, $sql);
}

// This little bit of code directly from the private messaging section.
while ( $row_privmsgs = $db->sql_fetchrow($result) )
{
$mark_list[] = $row_privmsgs['privmsgs_id'];
}

if ( count($mark_list) )
{
$delete_sql_id = implode(', ', $mark_list);

$delete_text_sql = "DELETE FROM " . PRIVMSGS_TEXT_TABLE . "
WHERE privmsgs_text_id IN ($delete_sql_id)";
$delete_sql = "DELETE FROM " . PRIVMSGS_TABLE . "
WHERE privmsgs_id IN ($delete_sql_id)";

if ( !$db->sql_query($delete_sql) )
{
message_die(GENERAL_ERROR, 'Could not delete private message info', '', __LINE__, __FILE__, $delete_sql);
}

if ( !$db->sql_query($delete_text_sql) )
{
message_die(GENERAL_ERROR, 'Could not delete private message text', '', __LINE__, __FILE__, $delete_text_sql);
}
}

$message = $lang['User_deleted'] . '<br /><br />' . sprintf($lang['Click_return_userprofile'], '<a href="' . append_sid("profile.$phpEx?mode=editprofile") . '">', '</a>') . '<br /><br />' . sprintf($lang['Click_return_index'], '<a href="' . append_sid("index.$phpEx") . '">', '</a>');

message_die(GENERAL_MESSAGE, $message);
}
// End Account Self-Delete MOD

#
#-----[Намерете]----------------------------------------------
#

'L_ALWAYS_ADD_SIGNATURE' => $lang['Always_add_sig'],

#
#-----[След това добавете]----------------------------------------------
#

// Begin Account Self-Delete MOD
'L_ACCOUNT_DELETE' => $lang['Account_delete'],
'L_DELETE_ACCOUNT_EXPLAIN' => $lang['Account_delete_explain'],
// End Account Self-Delete MOD

#
#-----[Намерете]----------------------------------------------
#

if ( $mode != 'register' )
{

#
#-----[След това добавете]----------------------------------------------
#

// Begin Account Self-Delete MOD
if( $board_config['account_delete'] )
{
$template->assign_block_vars('account_delete_block', array() );
}
// End Account Self-Delete MOD

#
#-----[Отворете]----------------------------------------------
#

language/език/lang_admin.php

#
#-----[Намерете]----------------------------------------------
#

?>

#
#-----[Преди това добавете]----------------------------------------------
#

// Begin Account Self-Delete MOD
$lang['account_delete'] = 'Allows users to delete their own accounts';
// End Account Self-Delete MOD

#
#-----[Отворете]----------------------------------------------
#

language/език/lang_main.php

#
#-----[ FIND ]----------------------------------------------
#

?>

#
#-----[Преди това добавете]----------------------------------------------
#

// Begin Account Self-Delete MOD
$lang['Account_delete'] = 'Do you want to delete your account on this board?';
$lang['Account_delete_explain'] = 'Deletion of your account cannot be undone';
$lang['User_deleted'] = 'Your account has been sucessfully deleted.';
$lang['Delete_account_question'] = 'Deletion of your account will delete all personnal informations that concerns you in your profile, inside the database of this board. The messages you wrote in this board will have as post author a guest. <b>Attention !</b> all deletion can not be undone.<br /><br />Do you want to delete your account in this board?';
// End Account Self-Delete MOD

#
#-----[Отворете]----------------------------------------------
#

templates/скин/admin/board_config_body.tpl

#
#-----[Намерете]----------------------------------------------
#

<tr>
<td class="row1">{L_ALLOW_NAME_CHANGE}</td>
<td class="row2"><input type="radio" name="allow_namechange" value="1" {NAMECHANGE_YES} /> {L_YES}  <input type="radio" name="allow_namechange" value="0" {NAMECHANGE_NO} /> {L_NO}</td>
</tr>

#
#-----[След това добавете]----------------------------------------------
#

<tr>
<td class="row1">{L_ACCOUNT_DELETE}</td>
<td class="row2"><input type="radio" name="account_delete" value="1" {S_ACCOUNT_DELETE_YES} /> {L_YES}  <input type="radio" name="account_delete" value="0" {S_ACCOUNT_DELETE_NO} /> {L_NO}</td>
</tr>

#
#-----[Отворете]----------------------------------------------
#

templates/скин/profile_add_body.tpl

#
#-----[Намерете]----------------------------------------------
#

<!-- Visual Confirmation -->

#
#-----[Преди това добавете]----------------------------------------------
#

<!-- BEGIN account_delete_block -->
<tr>
<td class="row1"><span class="gen">{L_ACCOUNT_DELETE}</span></td>
<td class="row2">
<input type="checkbox" name="deleteuser">
<span class="gensmall">{L_DELETE_ACCOUNT_EXPLAIN}</span></td>
</tr>
<!-- END account_delete_block -->

#
#-----[Запишете и затворете]------------------------------------------
#



/ Трябва да сте регистриран за да напишете коментар /