Example #1
0
 public function deleteUser($user_id)
 {
     $allTheConversations = Conversation::displayConversations($user_id);
     //delete all the conversations with all their messages
     for ($row = 0; $row < count($allTheConversations); $row++) {
         Conversation::deleteConversation($allTheConversations[$row]['conversationId']);
     }
     //get all the apartments of this user in an array
     $apartmentArray = Product::displayOwnerProducts($user_id);
     //delete all the selected apartments
     for ($row = 0; $row < count($apartmentArray); $row++) {
         Product::deleteProduct($apartmentArray[$row]['dwelling_Id'], $user_id);
     }
     //delete the user from the database
     parent::executeSqlQuery("DELETE FROM bannedusers WHERE user_id = '{$user_id}'");
     parent::executeSqlQuery("DELETE FROM users WHERE user_id = '{$user_id}'");
     header("location: adminPanel.php?action=user");
 }
Example #2
0
 public function deactivateAccount()
 {
     $user_id = $this->getUserId();
     //get all the conversations of that user
     $allTheConversations = Conversation::displayConversations($user_id);
     //delete all the conversations with all their messages
     for ($row = 0; $row < count($allTheConversations); $row++) {
         Conversation::deleteConversation($allTheConversations[$row]['conversationId']);
     }
     //get all the apartments of this user in an array
     $apartmentArray = Product::displayOwnerProducts($user_id);
     //delete all the selected apartments
     for ($row = 0; $row < count($apartmentArray); $row++) {
         Product::deleteProduct($apartmentArray[$row]['dwelling_Id'], $user_id);
     }
     //delete the user from the database
     parent::executeSqlQuery("DELETE FROM bannedusers WHERE user_id = '{$user_id}'");
     parent::executeSqlQuery("DELETE FROM users WHERE user_id = '{$user_id}'");
     parent::printMessage("MESSAGE", "Your account has been delete successfully!", "login.php");
 }