Modify

Opened 12 years ago

Closed 10 years ago

Last modified 10 years ago

#93 closed Bug/Fehler (fixed)

Gültigkeit von Downloads sollte ab Aktivierung gelten

Reported by: kaisa Owned by: Gerhard Waldemair
Priority: normal Milestone: modified-shop-2.0.0.0
Component: Admin Version: 2.0.0.0
Keywords: Cc:
Blocked By: Blocking:

Description (last modified by Torsten Riemer)

includes/modules/download.php

Downloads haben eine bestimmte Gültigkeit an Tagen. Diese zählen aber bereits ab Bestelldatum.

Es muss das Freischaltungsdatum zwingend genommen werden, weil:

  • Kunden durch Überweisung später bezahlen. Eine Aktivierung könnte dann schon ungültig sein, obwohl sie frisch durchgeführt wurde
  • Kunden möchten später (Wochen, Tage, Jahre) nochmal einen Download aktiviert bekommen. Das wäre auch nicht möglich.
  • Es ist unglogisch, dass nach einer Aktivierung, nicht die gültigen Tage

Mein Patch für das alte xtc läuft nicht mehr, da die Abfrage und Queries "simplified" wurden. Es funktioniert jetzt bei mir, aber ich bin mir sicher, ob es die perfekte Änderung sind. Markiert mit *KS*

Erweiterung, dass Dateigröße angezeigt wird, ist auch gleich dabei. Auch gepatcht, dass Download nur bei einem bestimmten Status aktiv ist. Es macht mit den vielen Zahlungsmodulen und Stati keinen Sinn mehr, einen Status "ab" zu nutzen.

// *KS* added opd.download_maxdays
$downloads_query = xtc_db_query("select op.products_name, opd.orders_products_download_id, opd.orders_products_filename,
opd.download_count, opd.download_maxdays, if(opd.download_maxdays = 0, current_date, date(o.date_purchased)) + interval opd.download_maxdays + 1 day - interval 1 second download_expiry
from ".TABLE_ORDERS." o
join ".TABLE_ORDERS_PRODUCTS." op on op.orders_id = o.orders_id
join ".TABLE_ORDERS_PRODUCTS_DOWNLOAD." opd on opd.orders_products_id = op.orders_products_id
where o.customers_id = '".$_SESSION['customer_id']."'
and o.orders_id = '".$last_order."' and opd.orders_products_filename != ''");
// EOF - vr - 2010-03-19 simplify download expiry calculation

if (xtc_db_num_rows($downloads_query) > 0) {
    $jj = 0;
    //<!-- list of products -->
    while ($downloads = xtc_db_fetch_array($downloads_query)) {
        // BOF - vr - 2010-03-19 simplify download expiry calculation
        // MySQL 3.22 does not have INTERVAL
        // BOF *KS* update calculation from status date and not order date
        $status_query = xtc_db_query("select date_added from ".TABLE_ORDERS_STATUS_HISTORY." where orders_id = '".$last_order."' order by date_added DESC LIMIT 1");
        $status = xtc_db_fetch_array($status_query);

        // Get last order_status of code 3 (download activated)
        $status_query = xtc_db_query("select date_added from ".TABLE_ORDERS_STATUS_HISTORY." where  orders_status_id=3 and orders_id = '".$last_order."' order by date_added DESC LIMIT 1");
        $status = xtc_db_fetch_array($status_query);

        // Falls kein Status 3 vorhanden war wg. iPayment-Fehler, dann Kaufdatum
        if(!$status)
            list ($dt_year, $dt_month, $dt_day) = explode('-', $downloads['date_purchased_day']);
        else
            list ($dt_year, $dt_month, $dt_day) = explode('-', substr($status['date_added'],0,10));
        $download_timestamp = mktime(23, 59, 59, $dt_month, $dt_day + $downloads['download_maxdays'], $dt_year);
        $download_expiry = date('Y-m-d H:i:s', $download_timestamp);
        // EOF *KS* download expiry from status date

        // EOF - vr - 2010-03-19 simplify download expiry calculation
        //<!-- left box -->
        // The link will appear only if:
        // - Download remaining count is > 0, AND
        // - The file is present in the DOWNLOAD directory, AND EITHER
        // - No expiry date is enforced (maxdays == 0), OR
        // - The expiry date is not reached
        // BOF - vr - 2010-03-19 simplify download expiry calculation

        /* if (($downloads['download_count'] > 0) && (file_exists(DIR_FS_DOWNLOAD.$downloads['orders_products_filename'])) && (($downloads['download_maxdays'] == 0) || ($download_timestamp > time())) && ($order_status >= DOWNLOAD_MIN_ORDERS_STATUS)) */
        if ($downloads['download_count'] > 0 &&
            strtotime($downloads['download_expiry']) > time() &&
            file_exists(DIR_FS_DOWNLOAD.$downloads['orders_products_filename']) &&
            $order_status == DOWNLOAD_MIN_ORDERS_STATUS)
        // EOF - vr - 2010-03-19 simplify download expiry calculation
        {
            $dl[$jj]['download_link'] = '<a href="'.xtc_href_link(FILENAME_DOWNLOAD, 'order='.$last_order.'&id='.$downloads['orders_products_download_id']).'">'.$downloads['products_name'].'</a>';
            $dl[$jj]['pic_link'] = xtc_href_link(FILENAME_DOWNLOAD, 'order='.$last_order.'&id='.$downloads['orders_products_download_id']);
        } else {
            $dl[$jj]['download_link'] = $downloads['products_name'];
        }
        //  BOF *KS* insert Filesize
        if (file_exists(DIR_FS_DOWNLOAD.$downloads['orders_products_filename']))
            $dl[$jj]['size']=round(filesize(DIR_FS_DOWNLOAD.$downloads['orders_products_filename'])/1024/1024)." MB";
        else
            $dl[$jj]['size']="--";
        // BOF Filesize

        //<!-- right box -->
        // BOF - vr - 2010-03-19 simplify download expiry calculation
        // *KS* $download_expiry wieder erhalten
        $dl[$jj]['date'] = xtc_date_long($download_expiry);
//      $dl[$jj]['date'] = xtc_date_long($downloads['download_expiry']);
        // EOF - vr - 2010-03-19 simplify download expiry calculation
        $dl[$jj]['count'] = $downloads['download_count'];
        $jj ++;
    }
}

Attachments (0)

Change History (6)

comment:1 by Torsten Riemer, 12 years ago

Hier sollte das Datum aus Tabelle "orders_status_history" heran gezogen werden, wo der Status der Bestellung den "Min. Bestellstatus" unter "Konfiguration" -> "Download Optionen" erreicht hat.

comment:2 by Torsten Riemer, 12 years ago

Description: modified (diff)

comment:3 by Gerhard Waldemair, 12 years ago

Owner: changed from somebody to Gerhard Waldemair
Status: newassigned

comment:4 by Gerhard Waldemair, 12 years ago

Milestone: modified-shop-2.00modified-shop-2.10
Version: 1.062.10

comment:5 by Gerhard Waldemair, 10 years ago

Resolution: fixed
Status: assignedclosed

comment:6 by Gerhard Waldemair, 10 years ago

Milestone: modified-shop-2.10modified-shop-2.00
Version: 2.102.0

Modify Ticket

Action
as closed The owner will remain Gerhard Waldemair.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.