/** * 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; }