Ejemplo n.º 1
0
 /**
  * @param int $id
  * @return bool
  */
 function DeleteAccountData($id, $email = NULL)
 {
     $count = 0;
     if (!$this->_dbConnection->Execute($this->_commandCreator->CountAccounts($id))) {
         return false;
     }
     while (false !== ($row = $this->_dbConnection->GetNextRecord())) {
         $count = $row->count;
         $id_user = $row->id_user;
     }
     $result = true;
     if ($count > 0) {
         $sql = 'DELETE FROM %sawm_accounts WHERE id_acct = %d';
         $query = sprintf($sql, $this->_settings->DbPrefix, $id);
         $result = $this->_dbConnection->Execute($query);
         $sql = 'DELETE FROM %sawm_messages WHERE id_acct = %d';
         $query = sprintf($sql, $this->_settings->DbPrefix, $id);
         $result &= $this->_dbConnection->Execute($query);
         $sql = 'DELETE FROM %sawm_messages_body WHERE id_acct = %d';
         $query = sprintf($sql, $this->_settings->DbPrefix, $id);
         $result &= $this->_dbConnection->Execute($query);
         $sql = 'DELETE FROM %sawm_filters WHERE id_acct = %d';
         $query = sprintf($sql, $this->_settings->DbPrefix, $id);
         $result &= $this->_dbConnection->Execute($query);
         $sql = 'DELETE FROM %sawm_reads WHERE id_acct = %d';
         $query = sprintf($sql, $this->_settings->DbPrefix, $id);
         $result &= $this->_dbConnection->Execute($query);
         $result &= $this->_dbConnection->Execute($this->_commandCreator->DeleteFolderTreeById($id));
         $sql = 'DELETE FROM %sawm_folders WHERE id_acct = %d';
         $query = sprintf($sql, $this->_settings->DbPrefix, $id);
         $result &= $this->_dbConnection->Execute($query);
     }
     /* last account */
     if ($count == 1) {
         $sql = 'DELETE FROM %sawm_addr_book WHERE id_user = %d';
         $query = sprintf($sql, $this->_settings->DbPrefix, $id_user);
         $result &= $this->_dbConnection->Execute($query);
         $sql = 'DELETE FROM %sawm_settings WHERE id_user = %d';
         $query = sprintf($sql, $this->_settings->DbPrefix, $id_user);
         $result &= $this->_dbConnection->Execute($query);
         /* contacts */
         $result &= $this->_dbConnection->Execute($this->_commandCreator->DeleteAddrGroupsContactsById($id_user));
         $sql = 'DELETE FROM %sawm_addr_groups WHERE id_user = %d';
         $query = sprintf($sql, $this->_settings->DbPrefix, $id_user);
         $result &= $this->_dbConnection->Execute($query);
         $sql = 'DELETE FROM %sawm_columns WHERE id_user = %d';
         $query = sprintf($sql, $this->_settings->DbPrefix, $id_user);
         $result &= $this->_dbConnection->Execute($query);
         $sql = 'DELETE FROM %sawm_senders WHERE id_user = %d';
         $query = sprintf($sql, $this->_settings->DbPrefix, $id_user);
         $result &= $this->_dbConnection->Execute($query);
         $sql = 'DELETE FROM %sa_users WHERE id_user = %d';
         $query = sprintf($sql, $this->_settings->DbPrefix, $id_user);
         $result &= $this->_dbConnection->Execute($query);
         /* calendar */
     }
     return $result;
 }
Ejemplo n.º 2
0
 /**
  * @param int $id
  * @return bool
  */
 function DeleteAccountData($id)
 {
     $count = 0;
     if (!$this->_dbConnection->Execute($this->_commandCreator->CountAccounts($id))) {
         return false;
     }
     while ($row = $this->_dbConnection->GetNextRecord()) {
         $count = $row->count;
         $id_user = $row->id_user;
     }
     $result = true;
     if ($count > 0) {
         $sql = 'DELETE FROM %sawm_accounts WHERE id_acct = %d';
         $query = sprintf($sql, $this->_settings->DbPrefix, $id);
         $result = $this->_dbConnection->Execute($query);
         $sql = 'DELETE FROM %sawm_messages WHERE id_acct = %d';
         $query = sprintf($sql, $this->_settings->DbPrefix, $id);
         $result &= $this->_dbConnection->Execute($query);
         $sql = 'DELETE FROM %sawm_messages_body WHERE id_acct = %d';
         $query = sprintf($sql, $this->_settings->DbPrefix, $id);
         $result &= $this->_dbConnection->Execute($query);
         $sql = 'DELETE FROM %sawm_filters WHERE id_acct = %d';
         $query = sprintf($sql, $this->_settings->DbPrefix, $id);
         $result &= $this->_dbConnection->Execute($query);
         $sql = 'DELETE FROM %sawm_reads WHERE id_acct = %d';
         $query = sprintf($sql, $this->_settings->DbPrefix, $id);
         $result &= $this->_dbConnection->Execute($query);
         $result &= $this->_dbConnection->Execute($this->_commandCreator->DeleteFolderTreeById($id));
         $sql = 'DELETE FROM %sawm_folders WHERE id_acct = %d';
         $query = sprintf($sql, $this->_settings->DbPrefix, $id);
         $result &= $this->_dbConnection->Execute($query);
     }
     //last account
     if ($count == 1) {
         $sql = 'DELETE FROM %sawm_addr_book WHERE id_user = %d';
         $query = sprintf($sql, $this->_settings->DbPrefix, $id_user);
         $result &= $this->_dbConnection->Execute($query);
         $sql = 'DELETE FROM %sawm_settings WHERE id_user = %d';
         $query = sprintf($sql, $this->_settings->DbPrefix, $id_user);
         $result &= $this->_dbConnection->Execute($query);
         // contacts
         $result &= $this->_dbConnection->Execute($this->_commandCreator->DeleteAddrGroupsContactsById($id));
         $sql = 'DELETE FROM %sawm_addr_groups WHERE id_user = %d';
         $query = sprintf($sql, $this->_settings->DbPrefix, $id_user);
         $result &= $this->_dbConnection->Execute($query);
         $sql = 'DELETE FROM %sawm_columns WHERE id_user = %d';
         $query = sprintf($sql, $this->_settings->DbPrefix, $id_user);
         $result &= $this->_dbConnection->Execute($query);
         $sql = 'DELETE FROM %sawm_senders WHERE id_user = %d';
         $query = sprintf($sql, $this->_settings->DbPrefix, $id_user);
         $result &= $this->_dbConnection->Execute($query);
         $sql = 'UPDATE %sa_users SET deleted = 1 WHERE id_user = %d';
         $query = sprintf($sql, $this->_settings->DbPrefix, $id_user);
         $result &= $this->_dbConnection->Execute($query);
         //calendar
         $result &= $this->_dbConnection->Execute($this->_commandCreator->DeleteCalendarEvents($id_user));
         $sql = 'DELETE FROM %sacal_calendars WHERE user_id = %d';
         $query = sprintf($sql, $this->_settings->DbPrefix, $id_user);
         $result &= $this->_dbConnection->Execute($query);
         $sql = 'DELETE FROM %sacal_users_data WHERE user_id = %d';
         $query = sprintf($sql, $this->_settings->DbPrefix, $id_user);
         $result &= $this->_dbConnection->Execute($query);
     }
     return $result;
 }