A little coding help plz - Joomla! Forum - community, help and support


alright, have component when buys sends email user, not admin, suppose tell in here somewhere

code: select all

public static function triggerbfauctionemail()
   {
      $app      = jfactory::getapplication();
      $params      = $app->getparams();
      $dst_fix = $params->get('dst');
      $allowemail = $params->get('allowemail');

      $db = jfactory::getdbo();
      $query   = $db->getquery(true);

      $query->select('id');
      $query->select('enddate');
      $query->select('currentbid');
      $query->select('buynowprice');
      $query->select('reserveprice');
      $query->from('#__bfauction_plus');
      $query->where('winemailsent = 0');

      $db->setquery((string)$query);
      $rows = $db->loadobjectlist( );

      // dst on on particular date ?
      $now = jfactory::getdate();
      $date=$now->toformat();
      if (is_numeric( $date))
      {
         $ts = $date;
      } else {
          $ts = strtotime( $date . ' utc');
      }
      $dst = date( 'i', $ts);

      $now = jfactory::getdate();
      if($dst_fix){
         $now->setoffset($app->getcfg('offset')+$dst);
      }else{
         $now->setoffset($app->getcfg('offset'));
      }
      $currentdate=$now->toformat();

      // check if auctions have finished since last run
      foreach($rows $row){
         if ($currentdate > $row->enddate){
            //mark winemailsent true
            $now = jfactory::getdate();
            $db = jfactory::getdbo();
            $query   = $db->getquery(true);
            if( ($row->currentbid == $row->buynowprice) || !($allowemail) ){
                  //don't send emails buynow purchase or when emails turned off
                  //but still set flag winemailsent know auction has finished.
               $query->update('#__bfauction_plus');
               $query->set('winemailsent= 2');
               if(is_callable(array('jdate', 'tosql'))){
                  $query->set('winemaildate='.$db->quote( $db->getescaped( $now->tosql() ), false ));
               }else{
                  $query->set('winemaildate='.$db->quote( $db->getescaped( $now->tomysql() ), false ));
               }
                  $query->where('id = '.(int)$row->id);


            }else{
               //auction finished, trigger winning email
               //is reserve price met?
               if($row->currentbid < $row->reserveprice){
                  bfauction_pluscontroller::triggeremails("reservenotmet", (int)$row->id, null);
               }else{
                  bfauction_pluscontroller::triggeremails("winningbid", (int)$row->id, null);
               }
               bfauction_pluscontroller::triggeremails("loosingbid", (int)$row->id, null);

               $query->update('#__bfauction_plus');
               $query->set('winemailsent= 1');
               if(is_callable(array('jdate', 'tosql'))){
                  $query->set('winemaildate='.$db->quote( $db->getescaped( $now->tosql() ), false ));
               }else{
                  $query->set('winemaildate='.$db->quote( $db->getescaped( $now->tomysql() ), false ));
               }
                  $query->where('id = '.(int)$row->id);

            }

            $db->setquery((string)$query);
            $db->query();
            if ($db->geterrornum())
            {
               echo jtext::sprintf('jlib_database_error_function_failed', $db->geterrornum(), $db->geterrormsg()).'<br />';
               return;
            }
         }
      }


to send email administrator too, whenever sends email user. know might be? , need change exactly?

any appreciated.

queenofhearts

i believe need check method "bfauction_pluscontroller::triggeremails" calling method send emails out.





Comments