Ejemplo n.º 1
0
 /**
  * Create offer from settings data
  *  
  * @param TPPaySettings $ps
  * @return returns null or a valid TPOffer
  */
 public static function create_offer(&$ps, $rid, $rname = null)
 {
     if ($ps == null) {
         return null;
     }
     if ($rname == '' || $rname == null) {
         $rname = $ps->getResourceName();
     }
     $resource = new TPResource($rid, stripslashes($rname));
     $pos = array();
     for ($i = 1; $i <= $ps->getNumPrices(); $i++) {
         $priceString = $ps->getPrice($i);
         if ($ps->isRecurring($i)) {
             $priceString = '[' . $ps->getPrice($i) . '|' . $ps->getRecurring($i) . '| * ]';
         }
         $po = new TPPriceOption($priceString);
         if ($ps->getAccess($i) != '') {
             $po->setAccessPeriod($ps->getAccess($i));
         }
         if ($ps->getCaption($i) != '') {
             $po->setCaption(stripslashes($ps->getCaption($i)));
         }
         $pos[] = $po;
     }
     $offer = new TPOffer($resource, $pos);
     return $offer;
 }
Ejemplo n.º 2
0
 private function buildPriceOption(TPPriceOption $po, $index)
 {
     $map = array();
     $map["price"] = $this->nuller($po->getPrice());
     $map["exp"] = $this->nuller($po->getAccessPeriod());
     if ($po->getStartDateInSecs() != null && $po->getStartDateInSecs() != 0) {
         $map["sd"] = $this->nuller($po->getStartDateInSecs());
     }
     if ($po->getEndDateInSecs() != null && $po->getEndDateInSecs() != 0) {
         $map["ed"] = $this->nuller($po->getEndDateInSecs());
     }
     $map["cpt"] = $this->nuller($po->getCaption());
     if (count($po->getSplitPays()) > 0) {
         $splits = array();
         foreach ($po->getSplitPays() as $email => $amount) {
             array_push($splits, "{$email}={$amount}");
         }
         $map["splits"] = $splits;
     }
     return $map;
 }