Ergebnis 1 bis 5 von 5

Thema: Contao 4.5: Database::getInstance();

  1. #1
    Contao-Nutzer Avatar von Eva
    Registriert seit
    03.07.2013.
    Beiträge
    149

    Standard Contao 4.5: Database::getInstance();

    Liebe Community

    Ich möchte bei einer Contao 4.5 Installation gerne eine alte Erweiterung (Contao 3) nutzen. Leider schreibt es mir keine neuen Einträge in die Datenbank, weshalb ich vermute, dass die Datenbankverbindung bei 4.5 nun anders als mit Database::getInstance(); funktioniert.

    Kann mir da jemand weiterhelfen? Die Einträge in der Erweiterung lauten z.B. (Auszug einer Funktion)

    PHP-Code:
    public function deleteGiveawayCallback(DataContainer $dc)
      {
        
    $db Database::getInstance();
        
    $itemsResult $db->prepare("SELECT tl_giveawayitem.id, tl_giveawayitem.wid, tl_giveawayitem.nofItems, tl_giveawayitem.amount FROM tl_giveaway INNER JOIN tl_giveawayitem ON tl_giveaway.id = tl_giveawayitem.pid WHERE tl_giveaway.id = ?")->execute($dc->id);
        while (
    $itemsResult->next())
        {
          
    $oldWishResult $this->Database->prepare("SELECT id, nofItemsAvailable, accievedamount, wishtype FROM tl_wish WHERE id=?")->execute($itemsResult->row()['wid']);
          
    $oldwish $oldWishResult->fetchAllAssoc()[0];
          
          if(
    $oldwish['wishtype'] == 'shares')
          {
            
    $newamount $oldwish['nofItemsAvailable'] + $itemsResult->row()['nofItems'];

            
    $this->Database->prepare("UPDATE tl_wish SET nofItemsAvailable=? WHERE id=?")->execute(array($newamount$oldwish['id']));
          }
          else
          {
            
    $newamount $oldwish['accievedamount'] - $itemsResult->row()['amount'];
            
    $this->Database->prepare("UPDATE tl_wish SET accievedamount=? WHERE id=?")->execute(array($newamount$oldwish['id']));
          }
          
    $this->Database->prepare("DELETE FROM tl_giveawayitem WHERE id=?")->execute($itemsResult->row()['id']);
        }
        
    $this->Database->prepare("DELETE FROM tl_giveaway WHERE id=?")->execute($dc->id);
      } 
    Das zieht sich so durch alle Funktionen innerhalb der Klassen.
    Im Internet habe ich gefunden, dass Symfony anders tickt. Da steht auf Git der Hinweis, dass man in der parameters.yml den Zusatz database_driver: pdo_mysql abspeichern kann... funktioniert bei mir aber trotz löschen des Caches und Datenbereinigung nicht.

    Wäre toll, wenn ich diese Erweiterung (wishlist) so abändern könnte, dass ich diese weiterhin benutzen kann.

    Liebe Grüsse
    Eva
    Geändert von Eva (30.04.2018 um 12:44 Uhr)

  2. #2
    Community-Moderator
    Wandelndes Contao-Lexikon
    Avatar von Spooky
    Registriert seit
    12.04.2012.
    Ort
    Scotland
    Beiträge
    34.112
    Partner-ID
    10107

    Standard

    Der Code sollte so noch funktionieren. Wo und wie wird die Funktion deleteGiveawayCallback aufgerufen?

  3. #3
    Contao-Nutzer Avatar von Eva
    Registriert seit
    03.07.2013.
    Beiträge
    149

    Standard

    Lieber Spooky

    Hier ist der ganze Code dieser Datei:

    PHP-Code:
    <?php

    $GLOBALS
    ['TL_DCA']['tl_giveaway'] = array
    (
        
    // Config
        
    'config' => array
        (
          
    'dataContainer'               => 'Table',
          
    'ctable'                      => 'tl_giveawayitem',
          
    'ptable'                      => 'tl_wishlist',
          
    'closed'                      => true,
          
    'ondelete_callback' => array
          (
            array(
    'tl_giveaway''deleteGiveawayCallback')
          ),
          
    'onload_callback' => array
          (
            array(
    'tl_giveaway''onloadCallback')
          ),
          
    'sql' => array
          (
            
    'keys' => array
            (
              
    'id' => 'primary',
              
    'pid' => 'index',
            )
          ),
       ),
      
    'label' => array
      (
        
    'fields'                  => array('title'),
        
    'format'                  => '%s'
      
    ),
      
    'list' => array
      (
        
    'sorting' => array
        (
          
    'mode'                    => 4,
          
    'fields'                  => array('tstamp ASC'),
          
    'headerFields'            => array('title'),
          
    'panelLayout'             => 'filter;sort,search,limit',
          
    'child_record_callback'   => array('tl_giveaway''listGiveaways'),
          
    'child_record_class'      => 'no_padding'
        
    ),
        
    'global_operations' => array
        (
          
    'all' => array
          (
            
    'label'               => &$GLOBALS['TL_LANG']['MSC']['all'],
            
    'href'                => 'act=select',
            
    'class'               => 'header_edit_all',
            
    'attributes'          => 'onclick="Backend.getScrollOffset()" accesskey="e"'
          
    )
        ),
        
    'operations' => array
        (
          
    'inspect' => array
          (
            
    'label'               => &$GLOBALS['TL_LANG']['tl_giveaway']['inspect'],
            
    'href'                => 'table=tl_giveawayitem',
            
    'icon'                => 'system/modules/wishlist/assets/images/mag_glass.png'
          
    ),
          
    'delete' => array
          (
            
    'label'               => &$GLOBALS['TL_LANG']['tl_giveaway']['editmeta'],
            
    'href'                => 'act=delete',
            
    'icon'                => 'delete.gif'
          
    )
        )
      ),
      
    // Palettes
      
    'palettes' => array
      (
        
    'default'       => '{title_legend},type,title,{wishlist_legend},description;totalamount,nofItems,nofItemsAvailable,customThumb,'
      
    ),
        
    // Fields
      
    'fields' => array
      (
        
    'id'     => array
        (
          
    'sql' => "int(10) unsigned NOT NULL auto_increment"
        
    ),
        
    'pid' => array
        (
          
    'foreignKey'              => 'tl_wishlist.id',
          
    'sql'                     => "int(10) unsigned NOT NULL default '0'",
          
    'relation'                => array('type'=>'belongsTo''load'=>'eager')
        ),
        
    'tstamp' => array
        (
          
    'default'                 => time(),
          
    'exclude'                 => true,
          
    'filter'                  => true,
          
    'sorting'                 => true,
          
    'flag'                    => 8,
          
    'inputType'               => 'text',
          
    'eval'                    => array('rgxp'=>'date''doNotCopy'=>true'datepicker'=>true'tl_class'=>'w50 wizard'),
          
    'sql'                     => "int(10) unsigned NOT NULL default '0'"
        
    ),
        
    'firstname'  => array
        (
          
    'label'     => &$GLOBALS['TL_LANG']['tl_giveaway']['firstname'],
          
    'inputType' => 'text',
          
    'exclude'   => true,
          
    'sorting'   => true,
          
    'flag'      => 1,
          
    'search'    => true,
          
    'eval'      => array(
              
    'mandatory'   => true,
            ),
          
    'sql'       => "varchar(255) NOT NULL default ''"
        
    ),
        
    'lastname'  => array
        (
          
    'label'     => &$GLOBALS['TL_LANG']['tl_giveaway']['lastname'],
          
    'inputType' => 'text',
          
    'exclude'   => true,
          
    'sorting'   => true,
          
    'flag'      => 1,
          
    'search'    => true,
          
    'eval'      => array(
              
    'mandatory'   => true,
            ),
          
    'sql'       => "varchar(255) NOT NULL default ''"
        
    ),
        
    'mail'  => array
        (
          
    'label'     => &$GLOBALS['TL_LANG']['tl_giveaway']['mail'],
          
    'inputType' => 'text',
          
    'exclude'   => true,
          
    'sorting'   => true,
          
    'flag'      => 1,
          
    'search'    => true,
          
    'eval'      => array(
              
    'mandatory'   => true,
            ),
          
    'sql'       => "varchar(255) NOT NULL default ''"
        
    ),
      )
    ); 
    // end of $GLOBALS['TL_DCA']['tl_giveaway'] array


    class tl_giveaway extends Backend
    {

      
    /**
       * Add the type of input field
       * @param array
       * @return string
       */
      
    public function listGiveaways($arrRow)
      {
        
    $db Database::getInstance();
        
    $itemsResult $db->prepare("SELECT tl_giveawayitem.nofItems as givennofitems, tl_giveawayitem.amount, tl_wish.wishtype, tl_wish.nofItems, tl_wish.accievedamount, tl_wish.pricepershare FROM tl_giveaway INNER JOIN tl_giveawayitem ON tl_giveaway.id = tl_giveawayitem.pid INNER JOIN tl_wish ON tl_giveawayitem.wid = tl_wish.id  WHERE tl_giveaway.id = ?")->execute($arrRow['id']);
        
    $total 0;
        while (
    $itemsResult->next())
        {
          if(
    $itemsResult->wishtype == 'shares')
          {
            
    $total $total + ($itemsResult->givennofitems $itemsResult->pricepershare);
          }
          else
          {
            
    $total $total $itemsResult->amount;
          }
        }
        
    //$currResult = $db->prepare("SELECT currency_short FROM tl_wishlist WHERE id = ?")->execute($arrRow['pid']);
        //$currency = $currResult->fetchAllAssoc();
        
    return '<div class="tl_content_left">' $arrRow['firstname'] . ' ' $arrRow['lastname'] . ' <span style="color:#b3b3b3;padding-left:3px">[' $arrRow['mail'] . ', ' $GLOBALS['TL_LANG']['tl_giveaway']['giveaway_amount'] . ': ' $total ' ' $GLOBALS['TL_DCA']['tl_giveaway']['config']['currency'] . ']</span></div>';
      }


      public function 
    deleteGiveawayCallback(DataContainer $dc)
      {
        
    $db Database::getInstance();
        
    $itemsResult $db->prepare("SELECT tl_giveawayitem.id, tl_giveawayitem.wid, tl_giveawayitem.nofItems, tl_giveawayitem.amount FROM tl_giveaway INNER JOIN tl_giveawayitem ON tl_giveaway.id = tl_giveawayitem.pid WHERE tl_giveaway.id = ?")->execute($dc->id);
        while (
    $itemsResult->next())
        {
          
    $oldWishResult $this->Database->prepare("SELECT id, nofItemsAvailable, accievedamount, wishtype FROM tl_wish WHERE id=?")->execute($itemsResult->row()['wid']);
          
    $oldwish $oldWishResult->fetchAllAssoc()[0];
          
    // $newamount = $oldwish['nofItemsAvailable'] + $itemsResult->row()['nofItems'];

          // $this->Database->prepare("UPDATE tl_wish SET nofItemsAvailable=? WHERE id=?")->execute(array($newamount, $oldwish['id']));
          // $this->Database->prepare("DELETE FROM tl_giveawayitem WHERE id=?")->execute($itemsResult->row()['id']);
          
    if($oldwish['wishtype'] == 'shares')
          {
            
    //die('deleting shared');
            
    $newamount $oldwish['nofItemsAvailable'] + $itemsResult->row()['nofItems'];

            
    $this->Database->prepare("UPDATE tl_wish SET nofItemsAvailable=? WHERE id=?")->execute(array($newamount$oldwish['id']));
            
    //$this->Database->prepare("DELETE FROM tl_giveawayitem WHERE id=?")->execute($itemsResult->row()['id']);
          
    }
          else
          {
            
    $newamount $oldwish['accievedamount'] - $itemsResult->row()['amount'];
            
    $this->Database->prepare("UPDATE tl_wish SET accievedamount=? WHERE id=?")->execute(array($newamount$oldwish['id']));
            
    //$this->Database->prepare("DELETE FROM tl_giveawayitem WHERE id=?")->execute($itemsResult->row()['id']);
          
    }
          
    $this->Database->prepare("DELETE FROM tl_giveawayitem WHERE id=?")->execute($itemsResult->row()['id']);
        }
        
    $this->Database->prepare("DELETE FROM tl_giveaway WHERE id=?")->execute($dc->id);
      }

      public function 
    onloadCallback($arrRow)
       {
          
    $db Database::getInstance();
          
    $currencyResult $db->prepare("SELECT currency_short FROM tl_wishlist WHERE id = ?")->execute($arrRow->id);
          
    $GLOBALS['TL_DCA']['tl_giveaway']['config']['currency'] = $currencyResult->currency_short;
       }
    }

    ?>
    Dann hat es aber noch andere PHP-Dateien, die in der gleichen Art aufgebaut sind. Z.B.
    PHP-Code:
    <?php

    $GLOBALS
    ['TL_DCA']['tl_giveawayitem'] = array
    (
        
    // Config
        
    'config' => array
        (
          
    'dataContainer'               => 'Table',
          
    'ptable'                      => 'tl_giveaway',
          
    'enableVersioning'            => false,
          
    'switchToEdit'                => false,
          
    'closed'                      => true,
          
    'ondelete_callback' => array
          (
            array(
    'tl_giveawayitem''deleteGiveawayitem'),
          ),
          
    'onload_callback' => array
          (
            array(
    'tl_giveawayitem''onloadCallback')
          ),
          
    'sql' => array
          (
            
    'keys' => array
            (
              
    'id' => 'primary',
              
    'pid' => 'index',
              
    'wid' => 'index'
            
    )
          ),
       ),
      
    'label' => array
      (
        
    'fields'                  => array('firstname''lastname'),
        
    'format'                  => '%s'
      
    ),
      
    'list' => array
      (
        
    'sorting' => array
        (
          
    'mode'                    => 4,
          
    'fields'                  => array(),
          
    'flag'                    => 12,
          
    'headerFields'            => array('firstname''lastname''mail'),
          
    'panelLayout'             => 'filter;sort,search,limit',
          
    'child_record_callback'   => array('tl_giveawayitem''listGiveawayitems'),
          
    'child_record_class'      => 'no_padding'
        
    ),
        
    'global_operations' => array
        (
          
    'all' => array
          (
            
    'label'               => &$GLOBALS['TL_LANG']['MSC']['all'],
            
    'href'                => 'act=select',
            
    'class'               => 'header_edit_all',
            
    'attributes'          => 'onclick="Backend.getScrollOffset()" accesskey="e"'
          
    )
        ),
        
    'operations' => array
        (
          
    // 'edit' => array
          // (
          //   'label'               => &$GLOBALS['TL_LANG']['tl_giveawayitem']['edit'],
          //   'href'                => 'act=edit',
          //   'icon'                => 'edit.gif'
          // ),
          
    'delete' => array
          (
            
    'label'               => &$GLOBALS['TL_LANG']['tl_wish']['delete'],
            
    'href'                => 'act=delete',
            
    'icon'                => 'delete.gif'
          
    )
        )
      ),
      
    // Palettes
      
    'palettes' => array
      (
        
    'default'       => '{title_legend},type,title,{wishlist_legend},description;totalamount,nofItems,nofItemsAvailable,customThumb,'
      
    ),
        
    // Fields
      
    'fields' => array
      (
        
    'id'     => array
        (
          
    'sql' => "int(10) unsigned NOT NULL auto_increment"
        
    ),
        
    'pid' => array
        (
          
    'foreignKey'              => 'tl_giveaway.id',
          
    'sql'                     => "int(10) unsigned NOT NULL default '0'",
          
    'relation'                => array('type'=>'belongsTo''load'=>'eager')
        ),
        
    'wid' => array
        (
          
    'foreignKey'              => 'tl_wish.id',
          
    'sql'                     => "int(10) unsigned NOT NULL default '0'",
          
    'relation'                => array('type'=>'belongsTo''load'=>'eager')
        ),
        
    'nofItems' => array
        (
          
    'label'                   => &$GLOBALS['TL_LANG']['tl_giveawayitem']['nofItems'],
          
    'exclude'                 => true,
          
    'search'                  => false,
          
    'inputType'               => 'text',
          
    'eval'                    => array('rgxp'=>'decimal''tl_class'=>'w50'),
          
    'sql'                     => "int(10) NULL"
        
    ),
        
    'amount' => array
        (
          
    'label'                   => &$GLOBALS['TL_LANG']['tl_giveawayitem']['amount'],
          
    'exclude'                 => true,
          
    'search'                  => false,
          
    'inputType'               => 'text',
          
    'eval'                    => array('rgxp'=>'integer''tl_class'=>'w50'),
          
    'sql'                     => "int(10) NULL"
        
    )
      )
    ); 
    // end of $GLOBALS['TL_DCA']['tl_giveawayitem'] array


    class tl_giveawayitem extends Backend
    {

      public function 
    onloadCallback($arrRow)
       {
          
    $db Database::getInstance();
          
    $currencyResult $db->prepare("SELECT currency_short FROM tl_wishlist INNER JOIN tl_giveaway ON tl_wishlist.id = tl_giveaway.pid WHERE tl_giveaway.id = ?")->execute($arrRow->id);
          
    $GLOBALS['TL_DCA']['tl_giveawayitem']['config']['currency'] = $currencyResult->currency_short;
       }
      
    /**
       * Add the type of input field
       * @param array
       * @return string
       */
      
    public function listGiveawayitems($arrRow)
      {
        
    $db Database::getInstance();
        
    $objResults $db->prepare("SELECT * FROM tl_wish WHERE tl_wish.id=?")->execute($arrRow['wid']);
        
    $object $objResults->fetchAllAssoc()[0];
        
    $amountstr;
        if(
    $object['wishtype'] == 'shares')
        {
          
    $amountstr $arrRow['nofItems'] . ' ' $GLOBALS['TL_LANG']['wishlist']['shares'][0] . ' : ' $object['pricepershare']*$arrRow['nofItems'] . ' ' $GLOBALS['TL_DCA']['tl_giveawayitem']['config']['currency'];
        }
        else if(
    $object['wishtype'] == 'amount')
        {
          
    $amountstr $arrRow['amount'] . ' ' $GLOBALS['TL_DCA']['tl_giveawayitem']['config']['currency'];
        }
        return 
    '<div class="tl_content_left">' $object['title'] . ' <span style="color:#b3b3b3;padding-left:3px">[' $amountstr ']</span></div>';
      }

      public function 
    deleteGiveawayitem($dc)
      {
          
    $delentry $this->Database->prepare("SELECT id, wid, nofitems, amount FROM tl_giveawayitem WHERE id=?")->execute($dc->id);
          
    $delitem $delentry->fetchAllAssoc()[0];
          
    $oldWishResult $this->Database->prepare("SELECT id, nofItemsAvailable, accievedamount, wishtype FROM tl_wish WHERE id=?")->execute($delitem['wid']);
          
    $oldwish $oldWishResult->fetchAllAssoc()[0];
          if(
    $oldwish['wishtype'] == 'shares')
          {
            
    $newamount $oldwish['nofItemsAvailable'] + $delitem['nofitems'];
            
    $statement $this->Database->prepare("UPDATE tl_wish SET nofItemsAvailable=? WHERE id=?");
            
    $statement->execute(array($newamount$oldwish['id']));
            
    $this->Database->prepare("DELETE FROM tl_giveawayitem WHERE id=?")->execute($dc->id);
          }
          else if(
    $oldwish['wishtype'] == 'amount')
          {
            
    $newamount $oldwish['accievedamount'] - $delitem['amount'];
            
    $statement $this->Database->prepare("UPDATE tl_wish SET accievedamount=? WHERE id=?");
            
    $statement->execute(array($newamount$oldwish['id']));
            
    $this->Database->prepare("DELETE FROM tl_giveawayitem WHERE id=?")->execute($dc->id);
          }
      }


    }

    ?>
    Ich hänge mal noch die ganze Erweiterung an.
    Bei der Installation habe ich ein Update von Contao 3.5 auf 4.5 vorgenommen. Es ist im Backend von der Erweiterung alles noch sichtbar, aber wenn man z.B im Frontend einen Wunsch erfüllt (einen Betrag eingibt) wird dieser neu auf 4.5 im Backend weder angezeigt noch in der Datenbank gespeichert. Ich kann Dir gerne per PN den Link dazu senden, wenn Du möchtest.
    Angehängte Dateien Angehängte Dateien
    Geändert von Eva (01.05.2018 um 10:17 Uhr)

  4. #4
    Contao-Nutzer Avatar von Eva
    Registriert seit
    03.07.2013.
    Beiträge
    149

    Standard

    PS: Ich habe nun noch versucht, im Backend die Wunschlisten zu bearbeiten. Das funktioniert alles einwandfrei, es wird auch alles so in die Datenbank übernommen. Was nicht mehr funktioniert ist, wenn ein User ein Betrag an ein Geschenk im Frontend eingibt und dieses abschickt. Man wird zwar erfolgreich an die Weiterleitungsseite geleitet, aber der eingegebene Betrag wird weder in der Datenbank abgespeichert noch ist er im Backend sichtbar. Auch wird kein Bestätigungsmail verschickt. Also liegt es nicht an der Datenbank, sondern am Verarbeiten des Betrages.

    Evt hier?

    PHP-Code:
    /**
     * Run in a custom namespace, so the class can be replaced
     */
    namespace Contao;
     
    class 
    GiveAwayHook extends Controller {
        public function 
    processGiveAway($arrPost$arrForm$arrFiles)
        {
            
    $dc Database::getInstance();

            
    //evaluate if the form belongs to a wishlist or not
            
    $wishlistsResult $dc->prepare("SELECT tl_wishlist.* FROM tl_wishlist INNER JOIN tl_form ON tl_wishlist.form=tl_form.id WHERE tl_form.id=? AND tl_wishlist.id=?")->execute(array($arrForm["id"], \Input::post("wishlistid")));
            
    $wishlist $wishlistsResult->fetchAllAssoc()[0];
            
    $giveaway_total 0;
            if(
    $wishlistsResult->count() > 0)
            {
                
    $giveaway  = array();
                
    $giveaway['tstamp'] = time();
                
    $giveaway['firstname'] = \Input::post("firstname");
                
    $giveaway['lastname'] = \Input::post("lastname");
                
    $giveaway['mail'] = \Input::post("mail");
                
    $wishlistResult $dc->prepare("SELECT id FROM tl_wishlist WHERE id=?")->execute(\Input::post("wishlistid"));
                
    $giveaway['pid'] = $wishlistResult->id;

                
    $objData $dc->prepare("INSERT INTO tl_giveaway %s")->set($giveaway)->execute();
                
    $newObjData $dc->prepare("SELECT id FROM tl_giveaway WHERE tstamp=?")->execute($giveaway['tstamp']);
                
    $parent $newObjData->fetchAllAssoc()[0];

                
    $wishStMnt $dc->prepare("SELECT tl_wish.* FROM tl_wish JOIN tl_wishcategory ON tl_wish.pid=tl_wishcategory.id JOIN tl_wishlist ON tl_wishlist.id= tl_wishcategory.pid  WHERE tl_wishlist.id = ?");
                 
    $wishResult $wishStMnt->execute($wishlistResult->id);
                 while (
    $wishResult->next())
                 {
                     
    $nofItems Input::post('wish' $wishResult->row()['id']);
                     if(
    $wishResult->wishtype == 'shares')
                     {
                         
    $nofItems Input::post('wish' $wishResult->row()['id']);
                         if(
    $nofItems  != '' && $nofItems 0)
                         {
                             
    $giveawayitem = array();
                             
    $giveawayitem['wid'] = $wishResult->row()['id'];
                             
    $giveawayitem['pid'] = $parent[id];
                             
    $giveawayitem['nofItems'] = $nofItems;
                             
    $oldWishResult $dc->prepare("SELECT id, nofItemsAvailable, pricepershare FROM tl_wish WHERE id=?")->execute($giveawayitem['wid']);
                             
    $oldwish $oldWishResult->fetchAllAssoc()[0];
                             
    $newamount $oldwish['nofItemsAvailable'] - $giveawayitem['nofItems'];

                             if(
    $newamount >= 0)
                             {
                                 
    $giveaway_total $giveaway_total $giveawayitem['nofItems'] * $oldwish['pricepershare'];
                                 
    $objData $dc->prepare("INSERT INTO tl_giveawayitem %s")->set($giveawayitem)->execute();
                                 
    $objData $dc->prepare("UPDATE `tl_wish` SET `nofItemsAvailable`=? WHERE id=?")->execute(array($newamount$giveawayitem['wid']));
                             }
                         }
                     }
                     else if(
    $wishResult->wishtype == 'amount')
                     {
                         
    $amount Input::post('wish' $wishResult->row()['id']);
                         if(
    $wishResult->targetamount >=  $wish->accievedamount $amount)
                         {
                             
    $giveawayitem = array();
                             
    $giveawayitem['wid'] = $wishResult->row()['id'];
                             
    $giveawayitem['pid'] = $parent[id];
                             
    $giveawayitem['amount'] = $amount;
                             
    $oldWishResult $dc->prepare("SELECT id, accievedamount FROM tl_wish WHERE id=?")->execute($giveawayitem['wid']);
                             
    $oldwish $oldWishResult->fetchAllAssoc()[0];
                             
    $newamount $oldwish['accievedamount'] + $giveawayitem['amount'];

                             if(
    $newamount $oldwish['accievedamount'])
                             {
                                 
    $giveaway_total $giveaway_total $giveawayitem['amount'];
                                 
    $objData $dc->prepare("INSERT INTO tl_giveawayitem %s")->set($giveawayitem)->execute();
                                 
    $objData $dc->prepare("UPDATE `tl_wish` SET `accievedamount`=? WHERE id=?")->execute(array($newamount$giveawayitem['wid']));
                             }
                         }
                     }
                 }
                 if(
    $wishlist['send_confirmation'])
                 {
                     
    $this->sendConfirmation($wishlist$giveaway$giveaway_total);
                 }
            }
        }

        public function 
    sendConfirmation($wishlist$giveaway$total_amount)
        {
            
    $str_total_amount $wishlist['currency_short'] . ' ' $total_amount;
            
    $content str_replace '{{giveaway:amount}}' $str_total_amount $wishlist['conf_template']);

            
    $str_name $giveaway['firstname'] . ' ' $giveaway['lastname'];
            
    $content str_replace '{{giveaway:fullname}}' $str_name $content);

            
    $content str_replace '{{giveaway:firstname}}' $giveaway['firstname'] , $content);
            
    $content str_replace '{{giveaway:lastname}}' $giveaway['lastname'] , $content);


            
    $mail = new Email();
            
    $mail->subject $wishlist['conf_subject'];
            
    $mail->text $content;
            
    $mail->from $wishlist['conf_senderMail'];
            
    $mail->fromName $wishlist['conf_sender'];
            
    //$mail->charset = 'utf-8';
            
    $mail->sendTo($giveaway['mail']);
        }

    Geändert von Eva (01.05.2018 um 10:29 Uhr)

  5. #5
    Contao-Nutzer Avatar von Eva
    Registriert seit
    03.07.2013.
    Beiträge
    149

    Standard

    Eine Frage: Wäre das für jemand ein Kleinst-Auftrag? Wenn ja, was würde es kosten, die Erweiterung auf Contao 4.5 zum Laufen zu bringen?

    Liebe Grüsse
    Eva

Aktive Benutzer

Aktive Benutzer

Aktive Benutzer in diesem Thema: 1 (Registrierte Benutzer: 0, Gäste: 1)

Lesezeichen

Lesezeichen

Berechtigungen

  • Neue Themen erstellen: Nein
  • Themen beantworten: Nein
  • Anhänge hochladen: Nein
  • Beiträge bearbeiten: Nein
  •