function deleteUserAccount($uname, $massDelete = false) { global $user; if ($uname != null) { include 'conn.php'; $Query = "delete from " . TABLE_PREFIX . "session where name='{$uname}'"; //echo($Query . "<br>\n"); $AffectedRows = $dblink->exec($Query); if ($AffectedRows == 1) { //Delete all books/folders from user's account $Query = "delete from " . TABLE_PREFIX . "folders where name='" . $uname . "' AND pid != '-1'"; //Avoid deleting group folders //echo($Query . "<br>\n"); $AffectedRows = $dblink->exec($Query); if ($AffectedRows >= 0) { if (TAGS && !$massDelete) { include 'tags_functions.php'; //Get all the bookmark ids of this user before deleting, in order to remove the entries in table tags_books $Query = "select id from " . TABLE_PREFIX . "favourites where name='" . $uname . "'"; $dbResult = $dblink->query($Query); $strTags = ""; while ($row =& $dbResult->fetchRow(DB_FETCHMODE_ASSOC)) { $current_id = "{$row["id"]}"; $public = checkIfPublic($current_id); if ($public) { //Remove (unstore) all the tags attached to this bookmark in table tags_books unstoreTags($current_id); } } } $Query = "delete from " . TABLE_PREFIX . "favourites where name='" . $uname . "'"; //echo($Query . "<br>\n"); $AffectedRows = $dblink->exec($Query); if ($AffectedRows >= 0) { $Query = "delete from " . TABLE_PREFIX . "activation where name='{$uname}'"; //echo($Query . "<br>\n"); $AffectedRows = $dblink->exec($Query); if ($AffectedRows == 1) { $success = true; if ($massDelete) { echo "<br>\n" . $uname . " ... deleted!"; } else { if ($user->isAdmin()) { echo "<p class=\"success\">" . sprintf(T_("%s was successfully deleted") . "</p>", $uname); echo "<p><a href=\"manageusers.php\"><< " . T_("Go Back") . "</a></p>"; } else { echo "<p class=\"success\">" . T_("You have been successfully deleted") . ".</p><p>" . sprintf(T_("Thank you for using %s"), WEBSITE_NAME) . "!</p>"; $_SESSION = array(); session_destroy(); } } } else { echo "<p class=\"error\">" . T_("There has been a problem when deleting your activation code") . ".</p>"; } } else { echo "<p class=\"error\">" . T_("There has been a problem when deleting bookmarks") . ".</p>"; } } else { echo "<p class=\"error\">" . T_("There has been a problem when deleting folders") . ".</p>"; } } else { echo "<p class=\"error\">" . T_("There has been a problem") . ".</p>"; } } else { echo "<p class=\"error\">" . T_("The form is incomplete") . ".</p>"; } }
function delete_folder($folderID, $username, $path = "") { include $path . 'conn.php'; include $path . 'config.inc.php'; $resultArr = array(); $resultArr['message'] = ""; $resultArr['success'] = false; if ($folderID != null) { //delete the whole subtree //get all the folder ids in the subtree $folderids = array(); $bookids = array(); function countfolders($folderid, $uname, &$folderids, &$bookids, $path = "") { include $path . 'conn.php'; $Query = "select id from " . TABLE_PREFIX . "favourites where folderid='{$folderid}'"; //echo($Query . "<br>\n"); $dbResult = $dblink->query($Query); while ($row =& $dbResult->fetchRow(DB_FETCHMODE_ASSOC)) { $rowid = "{$row["id"]}"; $bookids[] = $rowid; } $Query = "select id from " . TABLE_PREFIX . "folders where pid='{$folderid}'"; //echo($Query . "<br>\n"); $dbResult = $dblink->query($Query); $nb = 0; while ($row =& $dbResult->fetchRow(DB_FETCHMODE_ASSOC)) { $rowid = "{$row["id"]}"; $folderids[] = $rowid; $nb++; $nb += countfolders($rowid, $uname, $folderids, $bookids, $path); } return $nb; } $nbfolders = countfolders($folderID, $username, $folderids, $bookids, $path); //delete all the subtree foreach ($folderids as $folderid) { $Query = "delete from " . TABLE_PREFIX . "folders where id='" . $folderid . "'"; //echo($Query . "<br>\n"); $AffectedRows = $dblink->exec($Query); if ($AffectedRows != 1) { $resultArr['message'] = T_("There has been a problem when deleting a folder"); } } foreach ($bookids as $bookID) { if (TAGS) { require_once $path . 'includes/tags_functions.php'; $public = checkIfPublic($bookID); if ($public) { //Remove (unstore) all the tags attached to this bookmark in table tags_books unstoreTags($bookID); } } $Query = "delete from " . TABLE_PREFIX . "favourites where id='" . $bookID . "'"; //echo($Query . "<br>\n"); $AffectedRows = $dblink->exec($Query); if ($AffectedRows != 1) { $resultArr['message'] = T_("There has been a problem when deleting a bookmark"); } } //delete the folder itself when subtree deleted $Query = "delete from " . TABLE_PREFIX . "folders where id='" . $folderID . "'"; //echo($Query . "<br>\n"); $AffectedRows = $dblink->exec($Query); if ($AffectedRows == 1) { $resultArr['message'] = T_("You have successfully deleted this folder"); $resultArr['success'] = true; } else { $resultArr['message'] = T_("There has been a problem when deleting the folder"); } } return $resultArr; }
//Was public and still is (P P) if ($public && $newPublic) { //Make the changes to the tags, if any updateTags($id, $tags); } //Was not public, and now is (~ P) if (!$public && $newPublic) { //Add the tags addTags($tags); //Store the tags with the bookmark storeTags($id, $tags); } //Was public, and now is not (P ~) if ($public && !$newPublic) { //Remove (unstore) all the tags attached to this bookmark in table tags_books unstoreTags($id); } } } // update the favourites table $Query = sprintf("UPDATE " . TABLE_PREFIX . "favourites SET title=%s, url=%s, description=%s, LAST_MODIFIED = NOW() WHERE ID =" . $id, quote_smart($title), quote_smart($url), quote_smart($description)); $AffectedRows = $dblink->exec($Query); if ($AffectedRows == 1) { echo "<p class=\"success\">" . T_("The bookmark has been updated") . ".</p>"; $success = true; } else { if ($AffectedRows == 0) { echo "<p class=\"error\">" . T_("Modify this bookmark again since no change has been detected") . ".</p>"; } else { echo "<p class=\"error\">" . T_("There has been a problem when updating the bookmark") . ".</p>"; }