[geeklog-cvs] geeklog-1.3/public_html usersettings.php,1.61,1.62

geeklog-cvs-admin at lists.geeklog.net geeklog-cvs-admin at lists.geeklog.net
Thu Jun 12 15:45:10 EDT 2003


Update of /usr/cvs/geeklog/geeklog-1.3/public_html
In directory internal.geeklog.net:/tmp/cvs-serv12447/public_html

Modified Files:
	usersettings.php 
Log Message:
Added new config option to allow users to delete their account (default: off).


Index: usersettings.php
===================================================================
RCS file: /usr/cvs/geeklog/geeklog-1.3/public_html/usersettings.php,v
retrieving revision 1.61
retrieving revision 1.62
diff -C2 -d -r1.61 -r1.62
*** usersettings.php	8 Jun 2003 15:22:50 -0000	1.61
--- usersettings.php	12 Jun 2003 19:45:08 -0000	1.62
***************
*** 64,68 ****
      $preferences->set_file (array ('profile' => 'profile.thtml',
                                     'photo' => 'userphoto.thtml',
!                                    'username' => 'username.thtml'));
      $preferences->set_var ('site_url', $_CONF['site_url']);
      $preferences->set_var ('layout_url', $_CONF['layout_url']);
--- 64,69 ----
      $preferences->set_file (array ('profile' => 'profile.thtml',
                                     'photo' => 'userphoto.thtml',
!                                    'username' => 'username.thtml',
!                                    'deleteaccount' => 'deleteaccount.thtml'));
      $preferences->set_var ('site_url', $_CONF['site_url']);
      $preferences->set_var ('layout_url', $_CONF['layout_url']);
***************
*** 147,150 ****
--- 148,164 ----
      $preferences->set_var ('username_value', $_USER['username']);
  
+     if ($_CONF['allow_account_delete'] == 1) {
+         $preferences->set_var ('start_block_delete_account',
+                 COM_startBlock (sprintf ($LANG04[94], $_USER['username'])));
+         $preferences->set_var ('end_block_delete_account', COM_endBlock ());
+         $preferences->set_var ('delete_text', $LANG04[95]);
+         $preferences->set_var ('lang_button_delete', $LANG04[96]);
+         $preferences->set_var ('delete_mode', 'confirmdelete');
+         $preferences->set_var ('account_id', $_USER['uid']);
+         $preferences->parse ('delete_account_option', 'deleteaccount', false);
+     } else {
+         $preferences->set_var ('delete_account_option', '');
+     }
+ 
      PLG_profileVariablesEdit ($_USER['uid'], $preferences);
  
***************
*** 156,159 ****
--- 170,262 ----
  
  /**
+ * Ask user for confirmation to delete his/her account.
+ *
+ * @param    int      account_id   uid of account to delete (must match current user's uid)
+ * @return   string   confirmation form
+ *
+ */
+ function confirmAccountDelete ($account_id)
+ {
+     global $_CONF, $_USER, $LANG04;
+ 
+     if ($account_id != $_USER['uid']) {
+         // now that doesn't look right - abort ...
+         return COM_refresh ($_CONF['site_url'] . '/index.php');
+     }
+ 
+     $retval = '';
+ 
+     $confirm = new Template ($_CONF['path_layout'] . 'preferences');
+     $confirm->set_file (array ('deleteaccount' => 'deleteaccount.thtml'));
+     $confirm->set_var ('site_url', $_CONF['site_url']);
+     $confirm->set_var ('layout_url', $_CONF['layout_url']);
+ 
+     $confirm->set_var ('start_block_delete_account',
+             COM_startBlock (sprintf ($LANG04[94], $_USER['username'])));
+     $confirm->set_var ('end_block_delete_account', COM_endBlock ());
+     $confirm->set_var ('delete_text', $LANG04[95]);
+     $confirm->set_var ('lang_button_delete', $LANG04[96]);
+     $confirm->set_var ('delete_mode', 'deleteconfirmed');
+     $confirm->set_var ('account_id', $_USER['uid']);
+ 
+     $retval .= COM_siteHeader ('menu');
+     $retval .= COM_startBlock ($LANG04[97]);
+     $retval .= $LANG04[98];
+     $retval .= COM_endBlock ();
+     $retval .= $confirm->finish ($confirm->parse ('output', 'deleteaccount'));
+     $retval .= COM_siteFooter ();
+ 
+     return $retval;
+ }
+ 
+ /**
+ * Delete an account (keep in sync with delete_user() in admin/user.php).
+ *
+ * @param    uid      int   uid of account to delete
+ * @return   string   redirection to main page (+ success msg)
+ *
+ */
+ function deleteUserAccount ($uid)
+ {
+     global $_CONF, $_TABLES, $_USER;
+ 
+     if ($uid != $_USER['uid']) {
+         // now that doesn't look right - abort ...
+         return COM_refresh ($_CONF['site_url'] . '/index.php');
+     }
+ 
+     // log the user out
+     SESS_endUserSession ($_USER['uid']);
+ 
+     // Ok, delete everything related to this user
+ 
+     // first, remove from all security groups
+     DB_delete ($_TABLES['group_assignments'], 'ug_uid', $uid);
+ 
+     // remove user information and preferences
+     DB_delete ($_TABLES['userprefs'], 'uid', $uid);
+     DB_delete ($_TABLES['userindex'], 'uid', $uid);
+     DB_delete ($_TABLES['usercomment'], 'uid', $uid);
+     DB_delete ($_TABLES['userinfo'], 'uid', $uid);
+ 
+     // Call custom account profile delete function if enabled and exists
+     if ($_CONF['custom_registration'] AND function_exists (custom_userdelete)) {
+         custom_userdelete ($uid);
+     }
+ 
+     // let plugins update their data for this user
+     PLG_deleteUser ($uid);
+ 
+     // avoid having orphand stories/comments by making them anonymous posts
+     DB_query ("UPDATE {$_TABLES['comments']} SET uid = 1 WHERE uid = $uid");
+     DB_query ("UPDATE {$_TABLES['stories']} SET uid = 1 WHERE uid = $uid");
+ 
+     // now delete the user itself
+     DB_delete ($_TABLES['users'], 'uid', $uid);
+ 
+     return COM_refresh ($_CONF['site_url'] . '/index.php?msg=57');
+ }
+ 
+ /**
  * Build a list of all topics the current user has access to
  *
***************
*** 753,756 ****
--- 856,865 ----
          $display .= COM_refresh ($_CONF['site_url']
                                   . '/usersettings.php?mode=preferences&msg=6');
+         break;
+     case 'confirmdelete':
+         $display .= confirmAccountDelete ($HTTP_POST_VARS['account_id']);
+         break;
+     case 'deleteconfirmed':
+         $display .= deleteUserAccount ($HTTP_POST_VARS['account_id']);
          break;
      }





More information about the geeklog-cvs mailing list