/** * If this collection has already been initialized with * an identical criteria, it returns the collection. * Otherwise if this Element is new, it will return * an empty collection; or if this Element has previously * been saved, it will retrieve related Orders from storage. * * This method is protected by default in order to keep the public * api reasonable. You can provide public methods for those you * actually need in Element. */ public function getOrdersJoinClient($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) { if ($criteria === null) { $criteria = new Criteria(ElementPeer::DATABASE_NAME); } elseif ($criteria instanceof Criteria) { $criteria = clone $criteria; } if ($this->collOrders === null) { if ($this->isNew()) { $this->collOrders = array(); } else { $criteria->add(OrderPeer::ELEMENT_ID, $this->id); $this->collOrders = OrderPeer::doSelectJoinClient($criteria, $con, $join_behavior); } } else { // the following code is to determine if a new query is // called for. If the criteria is the same as the last // one, just return the collection. $criteria->add(OrderPeer::ELEMENT_ID, $this->id); if (!isset($this->lastOrderCriteria) || !$this->lastOrderCriteria->equals($criteria)) { $this->collOrders = OrderPeer::doSelectJoinClient($criteria, $con, $join_behavior); } } $this->lastOrderCriteria = $criteria; return $this->collOrders; }
<?php require_once 'includes/master.inc.php'; // check for some required variables in the request if (!isset($_REQUEST['payment_status']) || !isset($_REQUEST['business'])) { die; } // make sure payment has completed and it's for the correct PayPal account if ($_REQUEST['payment_status'] == "Completed" && strtolower($_REQUEST['business']) == SITE_CONFIG_PAYPAL_PAYMENTS_EMAIL_ADDRESS) { // load order using custom payment tracker hash $paymentTracker = $_REQUEST['custom']; $order = OrderPeer::loadByPaymentTracker($paymentTracker); if ($order) { $extendedDays = $order->days; $userId = $order->user_id; // log in payment_log $paypal_vars = ""; foreach ($_REQUEST as $k => $v) { $paypal_vars .= $k . " => " . $v . "\n"; } $dbInsert = new DBObject("payment_log", array("user_id", "date_created", "amount", "currency_code", "from_email", "to_email", "description", "request_log")); $dbInsert->user_id = $userId; $dbInsert->date_created = date("Y-m-d H:i:s", time()); $dbInsert->amount = $_REQUEST['mc_gross']; $dbInsert->currency_code = $_REQUEST['mc_currency']; $dbInsert->from_email = $_REQUEST['payer_email']; $dbInsert->to_email = $_REQUEST['business']; $dbInsert->description = $extendedDays . ' days extension'; $dbInsert->request_log = $paypal_vars; $dbInsert->insert(); // make sure the amount paid matched what we expect
/** * This is a method for emulating ON DELETE CASCADE for DBs that don't support this * feature (like MySQL or SQLite). * * This method is not very speedy because it must perform a query first to get * the implicated records and then perform the deletes by calling those Peer classes. * * This method should be used within a transaction if possible. * * @param Criteria $criteria * @param PropelPDO $con * @return int The number of affected rows (if supported by underlying database driver). */ protected static function doOnDeleteCascade(Criteria $criteria, PropelPDO $con) { // initialize var to track total num of affected rows $affectedRows = 0; // first find the objects that are implicated by the $criteria $objects = ElementPeer::doSelect($criteria, $con); foreach ($objects as $obj) { // delete related Preference objects $criteria = new Criteria(PreferencePeer::DATABASE_NAME); $criteria->add(PreferencePeer::ELEMENT_ID, $obj->getId()); $affectedRows += PreferencePeer::doDelete($criteria, $con); // delete related Order objects $criteria = new Criteria(OrderPeer::DATABASE_NAME); $criteria->add(OrderPeer::ELEMENT_ID, $obj->getId()); $affectedRows += OrderPeer::doDelete($criteria, $con); // delete related ElementFile objects $criteria = new Criteria(ElementFilePeer::DATABASE_NAME); $criteria->add(ElementFilePeer::ELEMENT_ID, $obj->getId()); $affectedRows += ElementFilePeer::doDelete($criteria, $con); } return $affectedRows; }
<?php require_once 'includes/master.inc.php'; if (!isset($_REQUEST['days'])) { redirect(WEB_ROOT . '/index.html'); } /* require login */ $Auth->requireUser('login.php'); $days = (int) trim($_REQUEST['days']); // create order entry $orderHash = MD5(time() . $Auth->id); $amount = number_format(constant('SITE_CONFIG_COST_FOR_' . $days . '_DAYS_PREMIUM'), 2); $order = OrderPeer::create($Auth->id, $orderHash, $days, $amount); if ($order) { // redirect to PayPal $desc = $days . ' days extension for ' . $Auth->username; $paypalUrl = 'https://www.paypal.com/cgi-bin/webscr?cmd=_xclick¬ify_url=' . urlencode(WEB_ROOT . '/payment_ipn_paypal.php') . '&email=' . urlencode($Auth->email) . '&return=' . urlencode(WEB_ROOT . '/payment_complete.' . SITE_CONFIG_PAGE_EXTENSION) . '&business=' . urlencode(SITE_CONFIG_PAYPAL_PAYMENTS_EMAIL_ADDRESS) . '&item_name=' . urlencode($desc) . '&item_number=1&amount=' . urlencode($amount) . '&no_shipping=2&no_note=1¤cy_code=' . SITE_CONFIG_COST_CURRENCY_CODE . '&lc=GB&bn=PP%2dBuyNowBF&charset=UTF%2d8&custom=' . $orderHash; redirect($paypalUrl); }
/** * Retrieve multiple objects by pkey. * * @param array $pks List of primary keys * @param PropelPDO $con the connection to use * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function retrieveByPKs($pks, PropelPDO $con = null) { if ($con === null) { $con = Propel::getConnection(OrderPeer::DATABASE_NAME, Propel::CONNECTION_READ); } $objs = null; if (empty($pks)) { $objs = array(); } else { $criteria = new Criteria(OrderPeer::DATABASE_NAME); $criteria->add(OrderPeer::ID, $pks, Criteria::IN); $objs = OrderPeer::doSelect($criteria, $con); } return $objs; }
/** * This is a method for emulating ON DELETE CASCADE for DBs that don't support this * feature (like MySQL or SQLite). * * This method is not very speedy because it must perform a query first to get * the implicated records and then perform the deletes by calling those Peer classes. * * This method should be used within a transaction if possible. * * @param Criteria $criteria * @param PropelPDO $con * @return int The number of affected rows (if supported by underlying database driver). */ protected static function doOnDeleteCascade(Criteria $criteria, PropelPDO $con) { // initialize var to track total num of affected rows $affectedRows = 0; // first find the objects that are implicated by the $criteria $objects = OrderStatusPeer::doSelect($criteria, $con); foreach ($objects as $obj) { // delete related Order objects $criteria = new Criteria(OrderPeer::DATABASE_NAME); $criteria->add(OrderPeer::ORDER_STATUS_ID, $obj->getId()); $affectedRows += OrderPeer::doDelete($criteria, $con); } return $affectedRows; }
/** * Populates the object using an array. * * This is particularly useful when populating an object from one of the * request arrays (e.g. $_POST). This method goes through the column * names, checking to see whether a matching key exists in populated * array. If so the setByName() method is called for that column. * * You can specify the key type of the array by additionally passing one * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. * The default key type is the column's phpname (e.g. 'AuthorId') * * @param array $arr An array to populate the object from. * @param string $keyType The type of keys the array uses. * @return void */ public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) { $keys = OrderPeer::getFieldNames($keyType); if (array_key_exists($keys[0], $arr)) { $this->setId($arr[$keys[0]]); } if (array_key_exists($keys[1], $arr)) { $this->setElementId($arr[$keys[1]]); } if (array_key_exists($keys[2], $arr)) { $this->setClientId($arr[$keys[2]]); } if (array_key_exists($keys[3], $arr)) { $this->setOrderStatusId($arr[$keys[3]]); } if (array_key_exists($keys[4], $arr)) { $this->setDate($arr[$keys[4]]); } if (array_key_exists($keys[5], $arr)) { $this->setComment($arr[$keys[5]]); } }