コード例 #1
0
ファイル: dbstorage.php プロジェクト: JDevelopers/Mail
 /**
  * @param int $acct_id
  * @return bool
  */
 function DeleteAccountData($acct_id, $email)
 {
     $count = 0;
     $user_id = -1;
     if ($acct_id < 0) {
         return false;
     }
     if (!$this->_connector->Execute($this->_commandCreator->GetUserIdFromAcctId($acct_id))) {
         return false;
     }
     $row = $this->_connector->GetNextRecord();
     if ($row) {
         $user_id = $row->id_user;
     }
     if ($user_id < 0) {
         return false;
     }
     if (!$this->_connector->Execute($this->_commandCreator->CountAccountsByUserId($user_id))) {
         return false;
     }
     $row = $this->_connector->GetNextRecord();
     if ($row) {
         $count = $row->cnt;
     }
     $result = true;
     if ($count > 0) {
         $sql = 'DELETE FROM %sawm_accounts WHERE id_acct = %d';
         $query = sprintf($sql, $this->_settings->DbPrefix, $acct_id);
         $result = $this->_connector->Execute($query);
         $sql = 'DELETE FROM %sawm_messages WHERE id_acct = %d';
         $query = sprintf($sql, $this->_settings->DbPrefix, $acct_id);
         $result &= $this->_connector->Execute($query);
         $sql = 'DELETE FROM %sawm_messages_body WHERE id_acct = %d';
         $query = sprintf($sql, $this->_settings->DbPrefix, $acct_id);
         $result &= $this->_connector->Execute($query);
         $sql = 'DELETE FROM %sawm_filters WHERE id_acct = %d';
         $query = sprintf($sql, $this->_settings->DbPrefix, $acct_id);
         $result &= $this->_connector->Execute($query);
         $sql = 'DELETE FROM %sawm_reads WHERE id_acct = %d';
         $query = sprintf($sql, $this->_settings->DbPrefix, $acct_id);
         $result &= $this->_connector->Execute($query);
         $result &= $this->_connector->Execute($this->_commandCreator->DeleteFolderTreeById($acct_id));
         $sql = 'DELETE FROM %sawm_folders WHERE id_acct = %d';
         $query = sprintf($sql, $this->_settings->DbPrefix, $acct_id);
         $result &= $this->_connector->Execute($query);
         $sql = 'DELETE FROM %sawm_mailaliases WHERE id_acct = %d';
         $query = sprintf($sql, $this->_settings->DbPrefix, $acct_id);
         $result &= $this->_connector->Execute($query);
         $sql = 'DELETE FROM %sawm_mailinglists WHERE id_acct = %d';
         $query = sprintf($sql, $this->_settings->DbPrefix, $acct_id);
         $result &= $this->_connector->Execute($query);
         /*$sql = 'DELETE FROM %sawm_tempfiles WHERE id_acct = %d';
         		$query = sprintf($sql, $this->_settings->DbPrefix, $acct_id);
         		$result &= $this->_connector->Execute($query);*/
     }
     if ($count == 1) {
         $sql = 'DELETE FROM %sawm_addr_book WHERE id_user = %d';
         $query = sprintf($sql, $this->_settings->DbPrefix, $user_id);
         $result &= $this->_connector->Execute($query);
         $sql = 'DELETE FROM %sawm_settings WHERE id_user = %d';
         $query = sprintf($sql, $this->_settings->DbPrefix, $user_id);
         $result &= $this->_connector->Execute($query);
         /* contacts */
         $result &= $this->_connector->Execute($this->_commandCreator->DeleteAddrGroupsContactsById($user_id));
         $sql = 'DELETE FROM %sawm_addr_groups WHERE id_user = %d';
         $query = sprintf($sql, $this->_settings->DbPrefix, $user_id);
         $result &= $this->_connector->Execute($query);
         $sql = 'DELETE FROM %sawm_columns WHERE id_user = %d';
         $query = sprintf($sql, $this->_settings->DbPrefix, $user_id);
         $result &= $this->_connector->Execute($query);
         $sql = 'DELETE FROM %sawm_senders WHERE id_user = %d';
         $query = sprintf($sql, $this->_settings->DbPrefix, $user_id);
         $result &= $this->_connector->Execute($query);
         $sql = 'DELETE FROM %sa_users WHERE id_user = %d';
         $query = sprintf($sql, $this->_settings->DbPrefix, $user_id);
         $result &= $this->_connector->Execute($query);
         /* calendar */
         $cal_ids = $this->GetCalendarIdsByUserId($user_id);
         if ($cal_ids && is_array($cal_ids) && count($cal_ids) > 0) {
             $result &= $this->_connector->Execute($this->_commandCreator->DeleteCalendarExclusions($cal_ids));
             $result &= $this->_connector->Execute($this->_commandCreator->DeleteCalendarEventrepeats($cal_ids));
             $result &= $this->_connector->Execute($this->_commandCreator->DeleteCalendarEvents($user_id));
             $sql = 'DELETE FROM %sacal_calendars WHERE user_id = %d';
             $query = sprintf($sql, $this->_settings->DbPrefix, $user_id);
             $result &= $this->_connector->Execute($query);
         }
         $sql = 'DELETE FROM %sacal_users_data WHERE user_id = %d';
         $query = sprintf($sql, $this->_settings->DbPrefix, $user_id);
         $result &= $this->_connector->Execute($query);
         $sql = 'DELETE FROM %sacal_publications WHERE id_user = %d';
         $query = sprintf($sql, $this->_settings->DbPrefix, $user_id);
         $result &= $this->_connector->Execute($query);
         $sql = 'DELETE FROM %sacal_sharing WHERE id_user = %d';
         $query = sprintf($sql, $this->_settings->DbPrefix, $user_id);
         $result &= $this->_connector->Execute($query);
         $query = $this->_commandCreator->DeleteFunambolContacts($email);
         // this commands does not affect result
         $this->_connector->Execute($query);
         $query = $this->_commandCreator->DeleteFunambolEvents($email);
         // this commands does not affect result
         $this->_connector->Execute($query);
     }
     return $result;
 }