first commit
This commit is contained in:
35
plugins/stEcardPlugin/config/config.php
Normal file
35
plugins/stEcardPlugin/config/config.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/**
|
||||
* SOTESHOP/stEcardPlugin
|
||||
*
|
||||
* Ten plik należy do aplikacji stEcardPlugin opartej na licencji (Professional License SOTE).
|
||||
* Nie zmieniaj tego pliku, jeśli chcesz korzystać z automatycznych aktualizacji oprogramowania.
|
||||
* Jeśli chcesz wprowadzać swoje modyfikacje do programu, zapoznaj się z dokumentacją, jak zmieniać
|
||||
* oprogramowanie bez zmiany kodu bazowego http://www.sote.pl/modifications
|
||||
*
|
||||
* @package stEcardPlugin
|
||||
* @subpackage configs
|
||||
* @copyright SOTE (www.sote.pl)
|
||||
* @license http://www.sote.pl/license/sote (Professional License SOTE)
|
||||
* @version $Id: config.php 8027 2010-08-31 12:22:15Z michal $
|
||||
* @author Michal Prochowski <michal.prochowski@sote.pl>
|
||||
*/
|
||||
|
||||
/**
|
||||
* Dodanie informacji o istnieniu płatności
|
||||
*/
|
||||
stPluginHelper::addConfigValue('stPaymentType', 'stEcardPlugin', array('name' => 'stEcard', 'description' => 'Płatność przez serwis ecard.pl'));
|
||||
|
||||
|
||||
if (SF_APP == 'backend'){
|
||||
stPluginHelper::addEnableModule('stEcardBackend', 'backend');
|
||||
stPluginHelper::addRouting('stEcardPlugin', '/ecard', 'stEcardBackend', 'index', 'backend');
|
||||
stConfiguration::addModule('stEcardPlugin', 'group_3', 1);
|
||||
}
|
||||
|
||||
if (SF_APP == 'frontend'){
|
||||
stPluginHelper::addEnableModule('stEcardFrontend', 'frontend');
|
||||
stPluginHelper::addRouting('stEcardPlugin', '/ecard/:action/*', 'stEcardFrontend', 'config', 'frontend');
|
||||
stPluginHelper::addRouting('stEcardSecure', '/ecard/statusReport/:hash', 'stEcardFrontend', 'statusReport', 'frontend');
|
||||
stSecurity::addCSPException('*.ecard.pl');
|
||||
}
|
||||
16
plugins/stEcardPlugin/config/schema.yml
Normal file
16
plugins/stEcardPlugin/config/schema.yml
Normal file
@@ -0,0 +1,16 @@
|
||||
---
|
||||
propel:
|
||||
_attributes:
|
||||
defaultIdMethod: native
|
||||
package: plugins.stEcardPlugin.lib.model
|
||||
st_ecard_transaction:
|
||||
_attributes:
|
||||
phpName: EcardTransaction
|
||||
id:
|
||||
type: INTEGER
|
||||
primaryKey: true
|
||||
required: true
|
||||
autoIncrement: true
|
||||
order_id:
|
||||
type: INTEGER
|
||||
required: true
|
||||
12
plugins/stEcardPlugin/lib/model/EcardTransaction.php
Normal file
12
plugins/stEcardPlugin/lib/model/EcardTransaction.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Subclass for representing a row from the 'st_ecard_transaction' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @package plugins.stEcardPlugin.lib.model
|
||||
*/
|
||||
class EcardTransaction extends BaseEcardTransaction
|
||||
{
|
||||
}
|
||||
60
plugins/stEcardPlugin/lib/model/EcardTransactionPeer.php
Normal file
60
plugins/stEcardPlugin/lib/model/EcardTransactionPeer.php
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Subclass for performing query and update operations on the 'st_ecard_transaction' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @package plugins.stEcardPlugin.lib.model
|
||||
*/
|
||||
class EcardTransactionPeer extends BaseEcardTransactionPeer
|
||||
{
|
||||
public static function doInsert($values, $con = null)
|
||||
{
|
||||
|
||||
foreach (sfMixer::getCallables('BaseEcardTransactionPeer:doInsert:pre') as $callable)
|
||||
{
|
||||
$ret = call_user_func($callable, 'BaseEcardTransactionPeer', $values, $con);
|
||||
if (false !== $ret)
|
||||
{
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(self::DATABASE_NAME);
|
||||
}
|
||||
|
||||
if ($values instanceof Criteria)
|
||||
{
|
||||
$criteria = clone $values;
|
||||
}
|
||||
else
|
||||
{
|
||||
$criteria = $values->buildCriteria();
|
||||
}
|
||||
|
||||
$criteria->setDbName(self::DATABASE_NAME);
|
||||
|
||||
try
|
||||
{
|
||||
$con->begin();
|
||||
$pk = BasePeer::doInsert($criteria, $con);
|
||||
$con->commit();
|
||||
}
|
||||
catch(PropelException $e)
|
||||
{
|
||||
$con->rollback();
|
||||
throw $e;
|
||||
}
|
||||
|
||||
|
||||
foreach (sfMixer::getCallables('BaseEcardTransactionPeer:doInsert:post') as $callable)
|
||||
{
|
||||
call_user_func($callable, 'BaseEcardTransactionPeer', $values, $con, $pk);
|
||||
}
|
||||
|
||||
return $pk;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
|
||||
/**
|
||||
* This class adds structure of 'st_ecard_transaction' table to 'propel' DatabaseMap object.
|
||||
*
|
||||
*
|
||||
*
|
||||
* These statically-built map classes are used by Propel to do runtime db structure discovery.
|
||||
* For example, the createSelectSql() method checks the type of a given column used in an
|
||||
* ORDER BY clause to know whether it needs to apply SQL to make the ORDER BY case-insensitive
|
||||
* (i.e. if it's a text column type).
|
||||
*
|
||||
* @package plugins.stEcardPlugin.lib.model.map
|
||||
*/
|
||||
class EcardTransactionMapBuilder {
|
||||
|
||||
/**
|
||||
* The (dot-path) name of this class
|
||||
*/
|
||||
const CLASS_NAME = 'plugins.stEcardPlugin.lib.model.map.EcardTransactionMapBuilder';
|
||||
|
||||
/**
|
||||
* The database map.
|
||||
*/
|
||||
private $dbMap;
|
||||
|
||||
/**
|
||||
* Tells us if this DatabaseMapBuilder is built so that we
|
||||
* don't have to re-build it every time.
|
||||
*
|
||||
* @return boolean true if this DatabaseMapBuilder is built, false otherwise.
|
||||
*/
|
||||
public function isBuilt()
|
||||
{
|
||||
return ($this->dbMap !== null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the databasemap this map builder built.
|
||||
*
|
||||
* @return the databasemap
|
||||
*/
|
||||
public function getDatabaseMap()
|
||||
{
|
||||
return $this->dbMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* The doBuild() method builds the DatabaseMap
|
||||
*
|
||||
* @return void
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function doBuild()
|
||||
{
|
||||
$this->dbMap = Propel::getDatabaseMap('propel');
|
||||
|
||||
$tMap = $this->dbMap->addTable('st_ecard_transaction');
|
||||
$tMap->setPhpName('EcardTransaction');
|
||||
|
||||
$tMap->setUseIdGenerator(true);
|
||||
|
||||
$tMap->addPrimaryKey('ID', 'Id', 'int', CreoleTypes::INTEGER, true, null);
|
||||
|
||||
$tMap->addColumn('ORDER_ID', 'OrderId', 'int', CreoleTypes::INTEGER, true, null);
|
||||
|
||||
} // doBuild()
|
||||
|
||||
} // EcardTransactionMapBuilder
|
||||
639
plugins/stEcardPlugin/lib/model/om/BaseEcardTransaction.php
Normal file
639
plugins/stEcardPlugin/lib/model/om/BaseEcardTransaction.php
Normal file
@@ -0,0 +1,639 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Base class that represents a row from the 'st_ecard_transaction' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @package plugins.stEcardPlugin.lib.model.om
|
||||
*/
|
||||
abstract class BaseEcardTransaction extends BaseObject implements Persistent {
|
||||
|
||||
|
||||
protected static $dispatcher = null;
|
||||
|
||||
|
||||
/**
|
||||
* The value for the id field.
|
||||
* @var int
|
||||
*/
|
||||
protected $id;
|
||||
|
||||
|
||||
/**
|
||||
* The value for the order_id field.
|
||||
* @var int
|
||||
*/
|
||||
protected $order_id;
|
||||
|
||||
/**
|
||||
* Flag to prevent endless save loop, if this object is referenced
|
||||
* by another object which falls in this transaction.
|
||||
* @var boolean
|
||||
*/
|
||||
protected $alreadyInSave = false;
|
||||
|
||||
/**
|
||||
* Flag to prevent endless validation loop, if this object is referenced
|
||||
* by another object which falls in this transaction.
|
||||
* @var boolean
|
||||
*/
|
||||
protected $alreadyInValidation = false;
|
||||
|
||||
/**
|
||||
* Get the [id] column value.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [order_id] column value.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getOrderId()
|
||||
{
|
||||
|
||||
return $this->order_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value of [id] column.
|
||||
*
|
||||
* @param int $v new value
|
||||
* @return void
|
||||
*/
|
||||
public function setId($v)
|
||||
{
|
||||
|
||||
if ($v !== null && !is_int($v) && is_numeric($v)) {
|
||||
$v = (int) $v;
|
||||
}
|
||||
|
||||
if ($this->id !== $v) {
|
||||
$this->id = $v;
|
||||
$this->modifiedColumns[] = EcardTransactionPeer::ID;
|
||||
}
|
||||
|
||||
} // setId()
|
||||
|
||||
/**
|
||||
* Set the value of [order_id] column.
|
||||
*
|
||||
* @param int $v new value
|
||||
* @return void
|
||||
*/
|
||||
public function setOrderId($v)
|
||||
{
|
||||
|
||||
if ($v !== null && !is_int($v) && is_numeric($v)) {
|
||||
$v = (int) $v;
|
||||
}
|
||||
|
||||
if ($this->order_id !== $v) {
|
||||
$this->order_id = $v;
|
||||
$this->modifiedColumns[] = EcardTransactionPeer::ORDER_ID;
|
||||
}
|
||||
|
||||
} // setOrderId()
|
||||
|
||||
/**
|
||||
* Hydrates (populates) the object variables with values from the database resultset.
|
||||
*
|
||||
* An offset (1-based "start column") is specified so that objects can be hydrated
|
||||
* with a subset of the columns in the resultset rows. This is needed, for example,
|
||||
* for results of JOIN queries where the resultset row includes columns from two or
|
||||
* more tables.
|
||||
*
|
||||
* @param ResultSet $rs The ResultSet class with cursor advanced to desired record pos.
|
||||
* @param int $startcol 1-based offset column which indicates which restultset column to start with.
|
||||
* @return int next starting column
|
||||
* @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
|
||||
*/
|
||||
public function hydrate(ResultSet $rs, $startcol = 1)
|
||||
{
|
||||
try {
|
||||
if ($this->getDispatcher()->getListeners('EcardTransaction.preHydrate')) {
|
||||
$event = $this->getDispatcher()->notify(new sfEvent($this, 'EcardTransaction.preHydrate', array('resultset' => $rs, 'startcol' => $startcol)));
|
||||
$startcol = $event['startcol'];
|
||||
}
|
||||
|
||||
$this->id = $rs->getInt($startcol + 0);
|
||||
|
||||
$this->order_id = $rs->getInt($startcol + 1);
|
||||
|
||||
$this->resetModified();
|
||||
|
||||
$this->setNew(false);
|
||||
if ($this->getDispatcher()->getListeners('EcardTransaction.postHydrate')) {
|
||||
$event = $this->getDispatcher()->notify(new sfEvent($this, 'EcardTransaction.postHydrate', array('resultset' => $rs, 'startcol' => $startcol + 2)));
|
||||
return $event['startcol'];
|
||||
}
|
||||
|
||||
// FIXME - using NUM_COLUMNS may be clearer.
|
||||
return $startcol + 2; // 2 = EcardTransactionPeer::NUM_COLUMNS - EcardTransactionPeer::NUM_LAZY_LOAD_COLUMNS).
|
||||
|
||||
} catch (Exception $e) {
|
||||
throw new PropelException("Error populating EcardTransaction object", $e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes this object from datastore and sets delete attribute.
|
||||
*
|
||||
* @param Connection $con
|
||||
* @return void
|
||||
* @throws PropelException
|
||||
* @see BaseObject::setDeleted()
|
||||
* @see BaseObject::isDeleted()
|
||||
*/
|
||||
public function delete($con = null)
|
||||
{
|
||||
if ($this->isDeleted()) {
|
||||
throw new PropelException("This object has already been deleted.");
|
||||
}
|
||||
|
||||
if ($this->getDispatcher()->getListeners('EcardTransaction.preDelete')) {
|
||||
$this->getDispatcher()->notify(new sfEvent($this, 'EcardTransaction.preDelete', array('con' => $con)));
|
||||
}
|
||||
|
||||
if (sfMixer::hasCallables('BaseEcardTransaction:delete:pre'))
|
||||
{
|
||||
foreach (sfMixer::getCallables('BaseEcardTransaction:delete:pre') as $callable)
|
||||
{
|
||||
$ret = call_user_func($callable, $this, $con);
|
||||
if ($ret)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(EcardTransactionPeer::DATABASE_NAME);
|
||||
}
|
||||
|
||||
try {
|
||||
$con->begin();
|
||||
EcardTransactionPeer::doDelete($this, $con);
|
||||
$this->setDeleted(true);
|
||||
$con->commit();
|
||||
} catch (PropelException $e) {
|
||||
$con->rollback();
|
||||
throw $e;
|
||||
}
|
||||
|
||||
if ($this->getDispatcher()->getListeners('EcardTransaction.postDelete')) {
|
||||
$this->getDispatcher()->notify(new sfEvent($this, 'EcardTransaction.postDelete', array('con' => $con)));
|
||||
}
|
||||
|
||||
if (sfMixer::hasCallables('BaseEcardTransaction:delete:post'))
|
||||
{
|
||||
foreach (sfMixer::getCallables('BaseEcardTransaction:delete:post') as $callable)
|
||||
{
|
||||
call_user_func($callable, $this, $con);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores the object in the database. If the object is new,
|
||||
* it inserts it; otherwise an update is performed. This method
|
||||
* wraps the doSave() worker method in a transaction.
|
||||
*
|
||||
* @param Connection $con
|
||||
* @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
|
||||
* @throws PropelException
|
||||
* @see doSave()
|
||||
*/
|
||||
public function save($con = null)
|
||||
{
|
||||
if ($this->isDeleted()) {
|
||||
throw new PropelException("You cannot save an object that has been deleted.");
|
||||
}
|
||||
|
||||
if (!$this->alreadyInSave) {
|
||||
if ($this->getDispatcher()->getListeners('EcardTransaction.preSave')) {
|
||||
$this->getDispatcher()->notify(new sfEvent($this, 'EcardTransaction.preSave', array('con' => $con)));
|
||||
}
|
||||
|
||||
foreach (sfMixer::getCallables('BaseEcardTransaction:save:pre') as $callable)
|
||||
{
|
||||
$affectedRows = call_user_func($callable, $this, $con);
|
||||
if (is_int($affectedRows))
|
||||
{
|
||||
return $affectedRows;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(EcardTransactionPeer::DATABASE_NAME);
|
||||
}
|
||||
|
||||
try {
|
||||
$con->begin();
|
||||
$affectedRows = $this->doSave($con);
|
||||
$con->commit();
|
||||
|
||||
if (!$this->alreadyInSave) {
|
||||
if ($this->getDispatcher()->getListeners('EcardTransaction.postSave')) {
|
||||
$this->getDispatcher()->notify(new sfEvent($this, 'EcardTransaction.postSave', array('con' => $con)));
|
||||
}
|
||||
|
||||
foreach (sfMixer::getCallables('BaseEcardTransaction:save:post') as $callable)
|
||||
{
|
||||
call_user_func($callable, $this, $con, $affectedRows);
|
||||
}
|
||||
}
|
||||
|
||||
return $affectedRows;
|
||||
} catch (PropelException $e) {
|
||||
$con->rollback();
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores the object in the database.
|
||||
*
|
||||
* If the object is new, it inserts it; otherwise an update is performed.
|
||||
* All related objects are also updated in this method.
|
||||
*
|
||||
* @param Connection $con
|
||||
* @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
|
||||
* @throws PropelException
|
||||
* @see save()
|
||||
*/
|
||||
protected function doSave($con)
|
||||
{
|
||||
$affectedRows = 0; // initialize var to track total num of affected rows
|
||||
if (!$this->alreadyInSave) {
|
||||
$this->alreadyInSave = true;
|
||||
|
||||
|
||||
// If this object has been modified, then save it to the database.
|
||||
if ($this->isModified()) {
|
||||
if ($this->isNew()) {
|
||||
$pk = EcardTransactionPeer::doInsert($this, $con);
|
||||
$affectedRows += 1; // we are assuming that there is only 1 row per doInsert() which
|
||||
// should always be true here (even though technically
|
||||
// BasePeer::doInsert() can insert multiple rows).
|
||||
|
||||
$this->setId($pk); //[IMV] update autoincrement primary key
|
||||
|
||||
$this->setNew(false);
|
||||
} else {
|
||||
$affectedRows += EcardTransactionPeer::doUpdate($this, $con);
|
||||
}
|
||||
$this->resetModified(); // [HL] After being saved an object is no longer 'modified'
|
||||
}
|
||||
|
||||
$this->alreadyInSave = false;
|
||||
}
|
||||
return $affectedRows;
|
||||
} // doSave()
|
||||
|
||||
/**
|
||||
* Array of ValidationFailed objects.
|
||||
* @var array ValidationFailed[]
|
||||
*/
|
||||
protected $validationFailures = array();
|
||||
|
||||
/**
|
||||
* Gets any ValidationFailed objects that resulted from last call to validate().
|
||||
*
|
||||
*
|
||||
* @return array ValidationFailed[]
|
||||
* @see validate()
|
||||
*/
|
||||
public function getValidationFailures()
|
||||
{
|
||||
return $this->validationFailures;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the objects modified field values and all objects related to this table.
|
||||
*
|
||||
* If $columns is either a column name or an array of column names
|
||||
* only those columns are validated.
|
||||
*
|
||||
* @param mixed $columns Column name or an array of column names.
|
||||
* @return boolean Whether all columns pass validation.
|
||||
* @see doValidate()
|
||||
* @see getValidationFailures()
|
||||
*/
|
||||
public function validate($columns = null)
|
||||
{
|
||||
$res = $this->doValidate($columns);
|
||||
if ($res === true) {
|
||||
$this->validationFailures = array();
|
||||
return true;
|
||||
} else {
|
||||
$this->validationFailures = $res;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This function performs the validation work for complex object models.
|
||||
*
|
||||
* In addition to checking the current object, all related objects will
|
||||
* also be validated. If all pass then <code>true</code> is returned; otherwise
|
||||
* an aggreagated array of ValidationFailed objects will be returned.
|
||||
*
|
||||
* @param array $columns Array of column names to validate.
|
||||
* @return mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objets otherwise.
|
||||
*/
|
||||
protected function doValidate($columns = null)
|
||||
{
|
||||
if (!$this->alreadyInValidation) {
|
||||
$this->alreadyInValidation = true;
|
||||
$retval = null;
|
||||
|
||||
$failureMap = array();
|
||||
|
||||
|
||||
if (($retval = EcardTransactionPeer::doValidate($this, $columns)) !== true) {
|
||||
$failureMap = array_merge($failureMap, $retval);
|
||||
}
|
||||
|
||||
|
||||
|
||||
$this->alreadyInValidation = false;
|
||||
}
|
||||
|
||||
return (!empty($failureMap) ? $failureMap : true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a field from the object by name passed in as a string.
|
||||
*
|
||||
* @param string $name name
|
||||
* @param string $type The type of fieldname the $name is of:
|
||||
* one of the class type constants TYPE_PHPNAME,
|
||||
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
|
||||
* @return mixed Value of field.
|
||||
*/
|
||||
public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
|
||||
{
|
||||
$pos = EcardTransactionPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
|
||||
return $this->getByPosition($pos);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a field from the object by Position as specified in the xml schema.
|
||||
* Zero-based.
|
||||
*
|
||||
* @param int $pos position in xml schema
|
||||
* @return mixed Value of field at $pos
|
||||
*/
|
||||
public function getByPosition($pos)
|
||||
{
|
||||
switch($pos) {
|
||||
case 0:
|
||||
return $this->getId();
|
||||
break;
|
||||
case 1:
|
||||
return $this->getOrderId();
|
||||
break;
|
||||
default:
|
||||
return null;
|
||||
break;
|
||||
} // switch()
|
||||
}
|
||||
|
||||
/**
|
||||
* Exports the object as an array.
|
||||
*
|
||||
* You can specify the key type of the array by passing one of the class
|
||||
* type constants.
|
||||
*
|
||||
* @param string $keyType One of the class type constants TYPE_PHPNAME,
|
||||
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
|
||||
* @return an associative array containing the field names (as keys) and field values
|
||||
*/
|
||||
public function toArray($keyType = BasePeer::TYPE_PHPNAME)
|
||||
{
|
||||
$keys = EcardTransactionPeer::getFieldNames($keyType);
|
||||
$result = array(
|
||||
$keys[0] => $this->getId(),
|
||||
$keys[1] => $this->getOrderId(),
|
||||
);
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a field from the object by name passed in as a string.
|
||||
*
|
||||
* @param string $name peer name
|
||||
* @param mixed $value field value
|
||||
* @param string $type The type of fieldname the $name is of:
|
||||
* one of the class type constants TYPE_PHPNAME,
|
||||
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
|
||||
* @return void
|
||||
*/
|
||||
public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
|
||||
{
|
||||
$pos = EcardTransactionPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
|
||||
return $this->setByPosition($pos, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a field from the object by Position as specified in the xml schema.
|
||||
* Zero-based.
|
||||
*
|
||||
* @param int $pos position in xml schema
|
||||
* @param mixed $value field value
|
||||
* @return void
|
||||
*/
|
||||
public function setByPosition($pos, $value)
|
||||
{
|
||||
switch($pos) {
|
||||
case 0:
|
||||
$this->setId($value);
|
||||
break;
|
||||
case 1:
|
||||
$this->setOrderId($value);
|
||||
break;
|
||||
} // switch()
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME,
|
||||
* 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 = EcardTransactionPeer::getFieldNames($keyType);
|
||||
|
||||
if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
|
||||
if (array_key_exists($keys[1], $arr)) $this->setOrderId($arr[$keys[1]]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a Criteria object containing the values of all modified columns in this object.
|
||||
*
|
||||
* @return Criteria The Criteria object containing all modified values.
|
||||
*/
|
||||
public function buildCriteria()
|
||||
{
|
||||
$criteria = new Criteria(EcardTransactionPeer::DATABASE_NAME);
|
||||
|
||||
if ($this->isColumnModified(EcardTransactionPeer::ID)) $criteria->add(EcardTransactionPeer::ID, $this->id);
|
||||
if ($this->isColumnModified(EcardTransactionPeer::ORDER_ID)) $criteria->add(EcardTransactionPeer::ORDER_ID, $this->order_id);
|
||||
|
||||
return $criteria;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a Criteria object containing the primary key for this object.
|
||||
*
|
||||
* Unlike buildCriteria() this method includes the primary key values regardless
|
||||
* of whether or not they have been modified.
|
||||
*
|
||||
* @return Criteria The Criteria object containing value(s) for primary key(s).
|
||||
*/
|
||||
public function buildPkeyCriteria()
|
||||
{
|
||||
$criteria = new Criteria(EcardTransactionPeer::DATABASE_NAME);
|
||||
|
||||
$criteria->add(EcardTransactionPeer::ID, $this->id);
|
||||
|
||||
return $criteria;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the primary key for this object (row).
|
||||
* @return int
|
||||
*/
|
||||
public function getPrimaryKey()
|
||||
{
|
||||
return $this->getId();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns [composite] primary key fields
|
||||
*
|
||||
* @param string $keyType
|
||||
* @return array
|
||||
*/
|
||||
public function getPrimaryKeyFields($keyType = BasePeer::TYPE_FIELDNAME)
|
||||
{
|
||||
return array(EcardTransactionPeer::translateFieldName('id', BasePeer::TYPE_FIELDNAME, $keyType));
|
||||
}
|
||||
|
||||
/**
|
||||
* Generic method to set the primary key (id column).
|
||||
*
|
||||
* @param int $key Primary key.
|
||||
* @return void
|
||||
*/
|
||||
public function setPrimaryKey($key)
|
||||
{
|
||||
$this->setId($key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets contents of passed object to values from current object.
|
||||
*
|
||||
* If desired, this method can also make copies of all associated (fkey referrers)
|
||||
* objects.
|
||||
*
|
||||
* @param object $copyObj An object of EcardTransaction (or compatible) type.
|
||||
* @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function copyInto($copyObj, $deepCopy = false)
|
||||
{
|
||||
|
||||
$copyObj->setOrderId($this->order_id);
|
||||
|
||||
|
||||
$copyObj->setNew(true);
|
||||
|
||||
$copyObj->setId(NULL); // this is a pkey column, so set to default value
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes a copy of this object that will be inserted as a new row in table when saved.
|
||||
* It creates a new object filling in the simple attributes, but skipping any primary
|
||||
* keys that are defined for the table.
|
||||
*
|
||||
* If desired, this method can also make copies of all associated (fkey referrers)
|
||||
* objects.
|
||||
*
|
||||
* @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
|
||||
* @return EcardTransaction Clone of current object.
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function copy($deepCopy = false)
|
||||
{
|
||||
// we use get_class(), because this might be a subclass
|
||||
$clazz = get_class($this);
|
||||
$copyObj = new $clazz();
|
||||
$this->copyInto($copyObj, $deepCopy);
|
||||
return $copyObj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a peer instance associated with this om.
|
||||
*
|
||||
* @return string Peer class name
|
||||
*/
|
||||
public function getPeer()
|
||||
{
|
||||
return 'EcardTransactionPeer';
|
||||
}
|
||||
|
||||
|
||||
public function getDispatcher()
|
||||
{
|
||||
if (null === self::$dispatcher)
|
||||
{
|
||||
self::$dispatcher = stEventDispatcher::getInstance();
|
||||
}
|
||||
|
||||
return self::$dispatcher;
|
||||
}
|
||||
|
||||
public function __call($method, $arguments)
|
||||
{
|
||||
$event = $this->getDispatcher()->notifyUntil(new sfEvent($this, 'EcardTransaction.' . $method, array('arguments' => $arguments, 'method' => $method)));
|
||||
|
||||
if ($event->isProcessed())
|
||||
{
|
||||
return $event->getReturnValue();
|
||||
}
|
||||
|
||||
if (!$callable = sfMixer::getCallable('BaseEcardTransaction:'.$method))
|
||||
{
|
||||
throw new sfException(sprintf('Call to undefined method BaseEcardTransaction::%s', $method));
|
||||
}
|
||||
|
||||
array_unshift($arguments, $this);
|
||||
|
||||
return call_user_func_array($callable, $arguments);
|
||||
}
|
||||
|
||||
} // BaseEcardTransaction
|
||||
644
plugins/stEcardPlugin/lib/model/om/BaseEcardTransactionPeer.php
Normal file
644
plugins/stEcardPlugin/lib/model/om/BaseEcardTransactionPeer.php
Normal file
@@ -0,0 +1,644 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Base static class for performing query and update operations on the 'st_ecard_transaction' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @package plugins.stEcardPlugin.lib.model.om
|
||||
*/
|
||||
abstract class BaseEcardTransactionPeer {
|
||||
|
||||
/** the default database name for this class */
|
||||
const DATABASE_NAME = 'propel';
|
||||
|
||||
/** the table name for this class */
|
||||
const TABLE_NAME = 'st_ecard_transaction';
|
||||
|
||||
/** A class that can be returned by this peer. */
|
||||
const CLASS_DEFAULT = 'plugins.stEcardPlugin.lib.model.EcardTransaction';
|
||||
|
||||
/** The total number of columns. */
|
||||
const NUM_COLUMNS = 2;
|
||||
|
||||
/** The number of lazy-loaded columns. */
|
||||
const NUM_LAZY_LOAD_COLUMNS = 0;
|
||||
|
||||
|
||||
/** the column name for the ID field */
|
||||
const ID = 'st_ecard_transaction.ID';
|
||||
|
||||
/** the column name for the ORDER_ID field */
|
||||
const ORDER_ID = 'st_ecard_transaction.ORDER_ID';
|
||||
|
||||
/** The PHP to DB Name Mapping */
|
||||
private static $phpNameMap = null;
|
||||
|
||||
|
||||
/**
|
||||
* holds an array of fieldnames
|
||||
*
|
||||
* first dimension keys are the type constants
|
||||
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
|
||||
*/
|
||||
private static $fieldNames = array (
|
||||
BasePeer::TYPE_PHPNAME => array ('Id', 'OrderId', ),
|
||||
BasePeer::TYPE_COLNAME => array (EcardTransactionPeer::ID, EcardTransactionPeer::ORDER_ID, ),
|
||||
BasePeer::TYPE_FIELDNAME => array ('id', 'order_id', ),
|
||||
BasePeer::TYPE_NUM => array (0, 1, )
|
||||
);
|
||||
|
||||
/**
|
||||
* holds an array of keys for quick access to the fieldnames array
|
||||
*
|
||||
* first dimension keys are the type constants
|
||||
* e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
|
||||
*/
|
||||
private static $fieldKeys = array (
|
||||
BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'OrderId' => 1, ),
|
||||
BasePeer::TYPE_COLNAME => array (EcardTransactionPeer::ID => 0, EcardTransactionPeer::ORDER_ID => 1, ),
|
||||
BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'order_id' => 1, ),
|
||||
BasePeer::TYPE_NUM => array (0, 1, )
|
||||
);
|
||||
|
||||
protected static $hydrateMethod = null;
|
||||
|
||||
protected static $postHydrateMethod = null;
|
||||
|
||||
public static function setHydrateMethod($callback)
|
||||
{
|
||||
self::$hydrateMethod = $callback;
|
||||
}
|
||||
|
||||
public static function setPostHydrateMethod($callback)
|
||||
{
|
||||
self::$postHydrateMethod = $callback;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return MapBuilder the map builder for this peer
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function getMapBuilder()
|
||||
{
|
||||
return BasePeer::getMapBuilder('plugins.stEcardPlugin.lib.model.map.EcardTransactionMapBuilder');
|
||||
}
|
||||
/**
|
||||
* Gets a map (hash) of PHP names to DB column names.
|
||||
*
|
||||
* @return array The PHP to DB name map for this peer
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
* @deprecated Use the getFieldNames() and translateFieldName() methods instead of this.
|
||||
*/
|
||||
public static function getPhpNameMap()
|
||||
{
|
||||
if (self::$phpNameMap === null) {
|
||||
$map = EcardTransactionPeer::getTableMap();
|
||||
$columns = $map->getColumns();
|
||||
$nameMap = array();
|
||||
foreach ($columns as $column) {
|
||||
$nameMap[$column->getPhpName()] = $column->getColumnName();
|
||||
}
|
||||
self::$phpNameMap = $nameMap;
|
||||
}
|
||||
return self::$phpNameMap;
|
||||
}
|
||||
/**
|
||||
* Translates a fieldname to another type
|
||||
*
|
||||
* @param string $name field name
|
||||
* @param string $fromType One of the class type constants TYPE_PHPNAME,
|
||||
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
|
||||
* @param string $toType One of the class type constants
|
||||
* @return string translated name of the field.
|
||||
*/
|
||||
static public function translateFieldName($name, $fromType, $toType)
|
||||
{
|
||||
$toNames = self::getFieldNames($toType);
|
||||
$key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null;
|
||||
if ($key === null) {
|
||||
throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true));
|
||||
}
|
||||
return $toNames[$key];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of of field names.
|
||||
*
|
||||
* @param string $type The type of fieldnames to return:
|
||||
* One of the class type constants TYPE_PHPNAME,
|
||||
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
|
||||
* @return array A list of field names
|
||||
*/
|
||||
|
||||
static public function getFieldNames($type = BasePeer::TYPE_PHPNAME)
|
||||
{
|
||||
if (!array_key_exists($type, self::$fieldNames)) {
|
||||
throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM. ' . $type . ' was given.');
|
||||
}
|
||||
return self::$fieldNames[$type];
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method which changes table.column to alias.column.
|
||||
*
|
||||
* Using this method you can maintain SQL abstraction while using column aliases.
|
||||
* <code>
|
||||
* $c->addAlias("alias1", TablePeer::TABLE_NAME);
|
||||
* $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
|
||||
* </code>
|
||||
* @param string $alias The alias for the current table.
|
||||
* @param string $column The column name for current table. (i.e. EcardTransactionPeer::COLUMN_NAME).
|
||||
* @return string
|
||||
*/
|
||||
public static function alias($alias, $column)
|
||||
{
|
||||
return str_replace(EcardTransactionPeer::TABLE_NAME.'.', $alias.'.', $column);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add all the columns needed to create a new object.
|
||||
*
|
||||
* Note: any columns that were marked with lazyLoad="true" in the
|
||||
* XML schema will not be added to the select list and only loaded
|
||||
* on demand.
|
||||
*
|
||||
* @param criteria object containing the columns to add.
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function addSelectColumns(Criteria $criteria)
|
||||
{
|
||||
|
||||
$criteria->addSelectColumn(EcardTransactionPeer::ID);
|
||||
|
||||
$criteria->addSelectColumn(EcardTransactionPeer::ORDER_ID);
|
||||
|
||||
|
||||
if (stEventDispatcher::getInstance()->getListeners('EcardTransactionPeer.postAddSelectColumns')) {
|
||||
stEventDispatcher::getInstance()->notify(new sfEvent($criteria, 'EcardTransactionPeer.postAddSelectColumns'));
|
||||
}
|
||||
}
|
||||
|
||||
const COUNT = 'COUNT(st_ecard_transaction.ID)';
|
||||
const COUNT_DISTINCT = 'COUNT(DISTINCT st_ecard_transaction.ID)';
|
||||
|
||||
/**
|
||||
* Returns the number of rows matching criteria.
|
||||
*
|
||||
* @param Criteria $criteria
|
||||
* @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria).
|
||||
* @param Connection $con
|
||||
* @return int Number of matching rows.
|
||||
*/
|
||||
public static function doCount(Criteria $criteria, $distinct = false, $con = null)
|
||||
{
|
||||
// we're going to modify criteria, so copy it first
|
||||
$criteria = clone $criteria;
|
||||
|
||||
// clear out anything that might confuse the ORDER BY clause
|
||||
$criteria->clearSelectColumns()->clearOrderByColumns();
|
||||
if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
|
||||
$criteria->addSelectColumn(EcardTransactionPeer::COUNT_DISTINCT);
|
||||
} else {
|
||||
$criteria->addSelectColumn(EcardTransactionPeer::COUNT);
|
||||
}
|
||||
|
||||
// just in case we're grouping: add those columns to the select statement
|
||||
foreach($criteria->getGroupByColumns() as $column)
|
||||
{
|
||||
$criteria->addSelectColumn($column);
|
||||
}
|
||||
|
||||
$rs = EcardTransactionPeer::doSelectRS($criteria, $con);
|
||||
if ($rs->next()) {
|
||||
return $rs->getInt(1);
|
||||
} else {
|
||||
// no rows returned; we infer that means 0 matches.
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Method to select one object from the DB.
|
||||
*
|
||||
* @param Criteria $criteria object used to create the SELECT statement.
|
||||
* @param Connection $con
|
||||
* @return EcardTransaction
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function doSelectOne(Criteria $criteria, $con = null)
|
||||
{
|
||||
$critcopy = clone $criteria;
|
||||
$critcopy->setLimit(1);
|
||||
$objects = EcardTransactionPeer::doSelect($critcopy, $con);
|
||||
if ($objects) {
|
||||
return $objects[0];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* Method to do selects.
|
||||
*
|
||||
* @param Criteria $criteria The Criteria object used to build the SELECT statement.
|
||||
* @param Connection $con
|
||||
* @return EcardTransaction[]
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function doSelect(Criteria $criteria, $con = null)
|
||||
{
|
||||
return EcardTransactionPeer::populateObjects(EcardTransactionPeer::doSelectRS($criteria, $con));
|
||||
}
|
||||
/**
|
||||
* Prepares the Criteria object and uses the parent doSelect()
|
||||
* method to get a ResultSet.
|
||||
*
|
||||
* Use this method directly if you want to just get the resultset
|
||||
* (instead of an array of objects).
|
||||
*
|
||||
* @param Criteria $criteria The Criteria object used to build the SELECT statement.
|
||||
* @param Connection $con the connection to use
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
* @return ResultSet The resultset object with numerically-indexed fields.
|
||||
* @see BasePeer::doSelect()
|
||||
*/
|
||||
public static function doSelectRS(Criteria $criteria, $con = null)
|
||||
{
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(self::DATABASE_NAME);
|
||||
}
|
||||
|
||||
if (!$criteria->getSelectColumns()) {
|
||||
$criteria = clone $criteria;
|
||||
EcardTransactionPeer::addSelectColumns($criteria);
|
||||
}
|
||||
|
||||
if (stEventDispatcher::getInstance()->getListeners('BasePeer.preDoSelectRs')) {
|
||||
stEventDispatcher::getInstance()->notify(new sfEvent($criteria, 'BasePeer.preDoSelectRs'));
|
||||
}
|
||||
|
||||
// Set the correct dbName
|
||||
$criteria->setDbName(self::DATABASE_NAME);
|
||||
|
||||
// BasePeer returns a Creole ResultSet, set to return
|
||||
// rows indexed numerically.
|
||||
$rs = BasePeer::doSelect($criteria, $con);
|
||||
|
||||
if (stEventDispatcher::getInstance()->getListeners('BasePeer.postDoSelectRs')) {
|
||||
stEventDispatcher::getInstance()->notify(new sfEvent($rs, 'BasePeer.postDoSelectRs'));
|
||||
}
|
||||
|
||||
return $rs;
|
||||
}
|
||||
/**
|
||||
* The returned array will contain objects of the default type or
|
||||
* objects that inherit from the default.
|
||||
*
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function populateObjects(ResultSet $rs)
|
||||
{
|
||||
|
||||
if (self::$hydrateMethod)
|
||||
{
|
||||
return call_user_func(self::$hydrateMethod, $rs);
|
||||
}
|
||||
$results = array();
|
||||
|
||||
// set the class once to avoid overhead in the loop
|
||||
$cls = EcardTransactionPeer::getOMClass();
|
||||
$cls = Propel::import($cls);
|
||||
// populate the object(s)
|
||||
while($rs->next()) {
|
||||
|
||||
$obj = new $cls();
|
||||
$obj->hydrate($rs);
|
||||
$results[] = self::$postHydrateMethod ? call_user_func(self::$postHydrateMethod, $obj) : $obj;
|
||||
|
||||
}
|
||||
return $results;
|
||||
}
|
||||
/**
|
||||
* Returns the TableMap related to this peer.
|
||||
* This method is not needed for general use but a specific application could have a need.
|
||||
* @return TableMap
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function getTableMap()
|
||||
{
|
||||
return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* The class that the Peer will make instances of.
|
||||
*
|
||||
* This uses a dot-path notation which is tranalted into a path
|
||||
* relative to a location on the PHP include_path.
|
||||
* (e.g. path.to.MyClass -> 'path/to/MyClass.php')
|
||||
*
|
||||
* @return string path.to.ClassName
|
||||
*/
|
||||
public static function getOMClass()
|
||||
{
|
||||
return EcardTransactionPeer::CLASS_DEFAULT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method perform an INSERT on the database, given a EcardTransaction or Criteria object.
|
||||
*
|
||||
* @param mixed $values Criteria or EcardTransaction object containing data that is used to create the INSERT statement.
|
||||
* @param Connection $con the connection to use
|
||||
* @return mixed The new primary key.
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function doInsert($values, $con = null)
|
||||
{
|
||||
|
||||
foreach (sfMixer::getCallables('BaseEcardTransactionPeer:doInsert:pre') as $callable)
|
||||
{
|
||||
$ret = call_user_func($callable, 'BaseEcardTransactionPeer', $values, $con);
|
||||
if (false !== $ret)
|
||||
{
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(self::DATABASE_NAME);
|
||||
}
|
||||
|
||||
if ($values instanceof Criteria) {
|
||||
$criteria = clone $values; // rename for clarity
|
||||
} else {
|
||||
$criteria = $values->buildCriteria(); // build Criteria from EcardTransaction object
|
||||
}
|
||||
|
||||
$criteria->remove(EcardTransactionPeer::ID); // remove pkey col since this table uses auto-increment
|
||||
|
||||
|
||||
// Set the correct dbName
|
||||
$criteria->setDbName(self::DATABASE_NAME);
|
||||
|
||||
try {
|
||||
// use transaction because $criteria could contain info
|
||||
// for more than one table (I guess, conceivably)
|
||||
$con->begin();
|
||||
$pk = BasePeer::doInsert($criteria, $con);
|
||||
$con->commit();
|
||||
} catch(PropelException $e) {
|
||||
$con->rollback();
|
||||
throw $e;
|
||||
}
|
||||
|
||||
|
||||
foreach (sfMixer::getCallables('BaseEcardTransactionPeer:doInsert:post') as $callable)
|
||||
{
|
||||
call_user_func($callable, 'BaseEcardTransactionPeer', $values, $con, $pk);
|
||||
}
|
||||
|
||||
return $pk;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method perform an UPDATE on the database, given a EcardTransaction or Criteria object.
|
||||
*
|
||||
* @param mixed $values Criteria or EcardTransaction object containing data that is used to create the UPDATE statement.
|
||||
* @param Connection $con The connection to use (specify Connection object to exert more control over transactions).
|
||||
* @return int The number of affected rows (if supported by underlying database driver).
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function doUpdate($values, $con = null)
|
||||
{
|
||||
|
||||
foreach (sfMixer::getCallables('BaseEcardTransactionPeer:doUpdate:pre') as $callable)
|
||||
{
|
||||
$ret = call_user_func($callable, 'BaseEcardTransactionPeer', $values, $con);
|
||||
if (false !== $ret)
|
||||
{
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(self::DATABASE_NAME);
|
||||
}
|
||||
|
||||
$selectCriteria = new Criteria(self::DATABASE_NAME);
|
||||
|
||||
if ($values instanceof Criteria) {
|
||||
$criteria = clone $values; // rename for clarity
|
||||
|
||||
$comparison = $criteria->getComparison(EcardTransactionPeer::ID);
|
||||
$selectCriteria->add(EcardTransactionPeer::ID, $criteria->remove(EcardTransactionPeer::ID), $comparison);
|
||||
|
||||
} else { // $values is EcardTransaction object
|
||||
$criteria = $values->buildCriteria(); // gets full criteria
|
||||
$selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
|
||||
}
|
||||
|
||||
// set the correct dbName
|
||||
$criteria->setDbName(self::DATABASE_NAME);
|
||||
|
||||
$ret = BasePeer::doUpdate($selectCriteria, $criteria, $con);
|
||||
|
||||
|
||||
foreach (sfMixer::getCallables('BaseEcardTransactionPeer:doUpdate:post') as $callable)
|
||||
{
|
||||
call_user_func($callable, 'BaseEcardTransactionPeer', $values, $con, $ret);
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to DELETE all rows from the st_ecard_transaction table.
|
||||
*
|
||||
* @return int The number of affected rows (if supported by underlying database driver).
|
||||
*/
|
||||
public static function doDeleteAll($con = null)
|
||||
{
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(self::DATABASE_NAME);
|
||||
}
|
||||
$affectedRows = 0; // initialize var to track total num of affected rows
|
||||
try {
|
||||
// use transaction because $criteria could contain info
|
||||
// for more than one table or we could emulating ON DELETE CASCADE, etc.
|
||||
$con->begin();
|
||||
$affectedRows += BasePeer::doDeleteAll(EcardTransactionPeer::TABLE_NAME, $con);
|
||||
$con->commit();
|
||||
return $affectedRows;
|
||||
} catch (PropelException $e) {
|
||||
$con->rollback();
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method perform a DELETE on the database, given a EcardTransaction or Criteria object OR a primary key value.
|
||||
*
|
||||
* @param mixed $values Criteria or EcardTransaction object or primary key or array of primary keys
|
||||
* which is used to create the DELETE statement
|
||||
* @param Connection $con the connection to use
|
||||
* @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
|
||||
* if supported by native driver or if emulated using Propel.
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function doDelete($values, $con = null)
|
||||
{
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(EcardTransactionPeer::DATABASE_NAME);
|
||||
}
|
||||
|
||||
if ($values instanceof Criteria) {
|
||||
$criteria = clone $values; // rename for clarity
|
||||
} elseif ($values instanceof EcardTransaction) {
|
||||
|
||||
$criteria = $values->buildPkeyCriteria();
|
||||
} else {
|
||||
// it must be the primary key
|
||||
$criteria = new Criteria(self::DATABASE_NAME);
|
||||
$criteria->add(EcardTransactionPeer::ID, (array) $values, Criteria::IN);
|
||||
}
|
||||
|
||||
// Set the correct dbName
|
||||
$criteria->setDbName(self::DATABASE_NAME);
|
||||
|
||||
$affectedRows = 0; // initialize var to track total num of affected rows
|
||||
|
||||
try {
|
||||
// use transaction because $criteria could contain info
|
||||
// for more than one table or we could emulating ON DELETE CASCADE, etc.
|
||||
$con->begin();
|
||||
|
||||
$affectedRows += BasePeer::doDelete($criteria, $con);
|
||||
$con->commit();
|
||||
return $affectedRows;
|
||||
} catch (PropelException $e) {
|
||||
$con->rollback();
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates all modified columns of given EcardTransaction object.
|
||||
* If parameter $columns is either a single column name or an array of column names
|
||||
* than only those columns are validated.
|
||||
*
|
||||
* NOTICE: This does not apply to primary or foreign keys for now.
|
||||
*
|
||||
* @param EcardTransaction $obj The object to validate.
|
||||
* @param mixed $cols Column name or array of column names.
|
||||
*
|
||||
* @return mixed TRUE if all columns are valid or the error message of the first invalid column.
|
||||
*/
|
||||
public static function doValidate(EcardTransaction $obj, $cols = null)
|
||||
{
|
||||
$columns = array();
|
||||
|
||||
if ($cols) {
|
||||
$dbMap = Propel::getDatabaseMap(EcardTransactionPeer::DATABASE_NAME);
|
||||
$tableMap = $dbMap->getTable(EcardTransactionPeer::TABLE_NAME);
|
||||
|
||||
if (! is_array($cols)) {
|
||||
$cols = array($cols);
|
||||
}
|
||||
|
||||
foreach($cols as $colName) {
|
||||
if ($tableMap->containsColumn($colName)) {
|
||||
$get = 'get' . $tableMap->getColumn($colName)->getPhpName();
|
||||
$columns[$colName] = $obj->$get();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
}
|
||||
|
||||
$res = BasePeer::doValidate(EcardTransactionPeer::DATABASE_NAME, EcardTransactionPeer::TABLE_NAME, $columns);
|
||||
if ($res !== true) {
|
||||
$request = sfContext::getInstance()->getRequest();
|
||||
foreach ($res as $failed) {
|
||||
$col = EcardTransactionPeer::translateFieldname($failed->getColumn(), BasePeer::TYPE_COLNAME, BasePeer::TYPE_PHPNAME);
|
||||
$request->setError($col, $failed->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single object by pkey.
|
||||
*
|
||||
* @param mixed $pk the primary key.
|
||||
* @param Connection $con the connection to use
|
||||
* @return EcardTransaction
|
||||
*/
|
||||
public static function retrieveByPK($pk, $con = null)
|
||||
{
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(self::DATABASE_NAME);
|
||||
}
|
||||
|
||||
$criteria = new Criteria(EcardTransactionPeer::DATABASE_NAME);
|
||||
|
||||
$criteria->add(EcardTransactionPeer::ID, $pk);
|
||||
|
||||
|
||||
$v = EcardTransactionPeer::doSelect($criteria, $con);
|
||||
|
||||
return !empty($v) > 0 ? $v[0] : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve multiple objects by pkey.
|
||||
*
|
||||
* @param array $pks List of primary keys
|
||||
* @param Connection $con the connection to use
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
* @return EcardTransaction[]
|
||||
*/
|
||||
public static function retrieveByPKs($pks, $con = null)
|
||||
{
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(self::DATABASE_NAME);
|
||||
}
|
||||
|
||||
$objs = null;
|
||||
if (empty($pks)) {
|
||||
$objs = array();
|
||||
} else {
|
||||
$criteria = new Criteria();
|
||||
$criteria->add(EcardTransactionPeer::ID, $pks, Criteria::IN);
|
||||
$objs = EcardTransactionPeer::doSelect($criteria, $con);
|
||||
}
|
||||
return $objs;
|
||||
}
|
||||
|
||||
} // BaseEcardTransactionPeer
|
||||
|
||||
// static code to register the map builder for this Peer with the main Propel class
|
||||
if (Propel::isInit()) {
|
||||
// the MapBuilder classes register themselves with Propel during initialization
|
||||
// so we need to load them here.
|
||||
try {
|
||||
BaseEcardTransactionPeer::getMapBuilder();
|
||||
} catch (Exception $e) {
|
||||
Propel::log('Could not initialize Peer: ' . $e->getMessage(), Propel::LOG_ERR);
|
||||
}
|
||||
} else {
|
||||
// even if Propel is not yet initialized, the map builder class can be registered
|
||||
// now and then it will be loaded when Propel initializes.
|
||||
Propel::registerMapBuilder('plugins.stEcardPlugin.lib.model.map.EcardTransactionMapBuilder');
|
||||
}
|
||||
202
plugins/stEcardPlugin/lib/stEcard.class.php
Normal file
202
plugins/stEcardPlugin/lib/stEcard.class.php
Normal file
@@ -0,0 +1,202 @@
|
||||
<?php
|
||||
/**
|
||||
* SOTESHOP/stEcardPlugin
|
||||
*
|
||||
* Ten plik należy do aplikacji stEcardPlugin opartej na licencji (Professional License SOTE).
|
||||
* Nie zmieniaj tego pliku, jeśli chcesz korzystać z automatycznych aktualizacji oprogramowania.
|
||||
* Jeśli chcesz wprowadzać swoje modyfikacje do programu, zapoznaj się z dokumentacją, jak zmieniać
|
||||
* oprogramowanie bez zmiany kodu bazowego http://www.sote.pl/modifications
|
||||
*
|
||||
* @package stEcardPlugin
|
||||
* @subpackage libs
|
||||
* @copyright SOTE (www.sote.pl)
|
||||
* @license http://www.sote.pl/license/sote (Professional License SOTE)
|
||||
* @version $Id: stEcard.class.php 10 2009-08-24 09:32:18Z michal $
|
||||
* @author Michal Prochowski <michal.prochowski@sote.pl>
|
||||
*/
|
||||
|
||||
/**
|
||||
* Adresy url płatności eCard
|
||||
*/
|
||||
define("ECARD_HASH_URL","https://pay.ecard.pl:443/servlet/HS");
|
||||
define("ECARD_POST_URL","https://pay.ecard.pl/payment/PS");
|
||||
define("ECARD_POST_URL_TEST","https://pay.ecard.pl/servlet/PSTEST");
|
||||
|
||||
/**
|
||||
* Klasa stEcard
|
||||
*
|
||||
* @package stEcardPlugin
|
||||
* @subpackage libs
|
||||
*/
|
||||
class stEcard
|
||||
{
|
||||
protected $params = null;
|
||||
/**
|
||||
* Tablica z konfiguracją
|
||||
* @var array
|
||||
*/
|
||||
private $config = array();
|
||||
|
||||
/**
|
||||
* Konstruktor - ładownianie konfiguracji
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->config = stPaymentType::getConfiguration(__CLASS__);
|
||||
}
|
||||
|
||||
public static function getPostSecureHash()
|
||||
{
|
||||
return stSecureToken::generate(array('123456789'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Obsługa funkcji call
|
||||
*
|
||||
* @param $method
|
||||
* @param $arguments
|
||||
* @return mixed string/bool
|
||||
*/
|
||||
public function __call($method, $arguments)
|
||||
{
|
||||
return stPaymentType::call($method, $this->config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Przeliczanie kwoty zamówień i zwracanie jej w ustalonym formacie
|
||||
*
|
||||
* @param float $orderAmountBrutto
|
||||
* @return integer
|
||||
*/
|
||||
public function getOrderAmount($orderAmountBrutto)
|
||||
{
|
||||
return number_format($orderAmountBrutto,2, '.', '')*100;
|
||||
}
|
||||
|
||||
/**
|
||||
* Zwracanie adresu url serwisu dotpay.pl
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getUrl()
|
||||
{
|
||||
return ECARD_POST_URL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Zwracanie adresu url serwisu dotpay.pl
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTestUrl()
|
||||
{
|
||||
return ECARD_POST_URL_TEST;
|
||||
}
|
||||
|
||||
/**
|
||||
* Zwracanie adresu url serwisu dotpay.pl
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getHashUrl()
|
||||
{
|
||||
return ECARD_HASH_URL;
|
||||
}
|
||||
|
||||
public function getPaymentParams(Order $order)
|
||||
{
|
||||
if (null === $this->params)
|
||||
{
|
||||
sfLoader::loadHelpers(array('Helper', 'stUrl'));
|
||||
$user = $order->getOrderUserDataBilling();
|
||||
$i18n = sfContext::getInstance()->getI18N();
|
||||
|
||||
$params = array(
|
||||
"MERCHANTID" => $this->getEcardId(),
|
||||
"ORDERNUMBER" => $this->getTransactionId($order),
|
||||
"AMOUNT" => $order->getUnpaidAmount() * 100,
|
||||
"CURRENCY" => stPaymentType::getCurrency($order)->getCode(),
|
||||
"ORDERDESCRIPTION" => $i18n->__("Zamówienie nr", null, 'stOrder').' '.$order->getNumber(),
|
||||
"NAME" => $user->getName(),
|
||||
"SURNAME" => $user->getSurname(),
|
||||
"AUTODEPOSIT" => "1",
|
||||
"PAYMENTTYPE" => "ALL",
|
||||
"RETURNLINK" => st_url_for('@homepage', true),
|
||||
);
|
||||
|
||||
$hash_params = array_values($params);
|
||||
$hash_params[] = $this->getEcardPassword();
|
||||
|
||||
$params["HASH"] = md5(implode('', $hash_params));
|
||||
$params["HASHALGORITHM"] = "MD5";
|
||||
$params["COUNTRY"] = "616";
|
||||
$params["LANGUAGE"] = stPaymentType::getLanguage(array('PL', 'EN', 'DE', 'FR', 'RU', 'CZ', 'IT', 'ES'));
|
||||
$params["CHARSET"] = "UTF-8";
|
||||
$this->params = $params;
|
||||
}
|
||||
|
||||
return $this->params;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sprawdzenie czy płatność została skonfiguraowana
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function checkPaymentConfiguration()
|
||||
{
|
||||
if (!$this->hasEcardId()) return false;
|
||||
if (!$this->hasEcardPassword()) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function getServiceTransactionId(Payment $payment)
|
||||
{
|
||||
$order = $payment->getOrder();
|
||||
|
||||
$c = new Criteria();
|
||||
$c->addSelectColumn(EcardTransactionPeer::ID);
|
||||
$c->addDescendingOrderByColumn(EcardTransactionPeer::ID);
|
||||
$c->add(EcardTransactionPeer::ORDER_ID, $order->getId());
|
||||
|
||||
$results = array();
|
||||
|
||||
$rs = EcardTransactionPeer::doSelectRS($c);
|
||||
|
||||
while($rs->next())
|
||||
{
|
||||
$row = $rs->getRow();
|
||||
$results[] = $row[0];
|
||||
}
|
||||
|
||||
return implode(", ", $results);
|
||||
}
|
||||
|
||||
protected function getTransactionId(Order $order)
|
||||
{
|
||||
$transaction = new EcardTransaction();
|
||||
|
||||
$config = stConfig::getInstance('stEcardBackend');
|
||||
|
||||
if (!$config->get('transaction_fix') && !EcardTransactionPeer::doCount(new Criteria()))
|
||||
{
|
||||
$c = new Criteria();
|
||||
$c->addSelectColumn('MAX('.OrderPeer::ID.')');
|
||||
$rs = OrderPeer::doSelectRS($c);
|
||||
|
||||
$row = $rs->next() ? $rs->getRow() : null;
|
||||
|
||||
$transaction->setId($row ? $row[0] + 1 : 1);
|
||||
|
||||
$config->set('transaction_fix', true);
|
||||
|
||||
$config->save();
|
||||
}
|
||||
|
||||
$transaction->setOrderId($order->getId());
|
||||
|
||||
$transaction->save();
|
||||
|
||||
return $transaction->getId();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
/**
|
||||
* SOTESHOP/stEcardPlugin
|
||||
*
|
||||
* Ten plik należy do aplikacji stEcardPlugin opartej na licencji (Professional License SOTE).
|
||||
* Nie zmieniaj tego pliku, jeśli chcesz korzystać z automatycznych aktualizacji oprogramowania.
|
||||
* Jeśli chcesz wprowadzać swoje modyfikacje do programu, zapoznaj się z dokumentacją, jak zmieniać
|
||||
* oprogramowanie bez zmiany kodu bazowego http://www.sote.pl/modifications
|
||||
*
|
||||
* @package stEcardPlugin
|
||||
* @subpackage actions
|
||||
* @copyright SOTE (www.sote.pl)
|
||||
* @license http://www.sote.pl/license/sote (Professional License SOTE)
|
||||
* @version $Id: actions.class.php 7200 2010-08-02 12:49:54Z marek $
|
||||
* @author Michal Prochowski <michal.prochowski@sote.pl>
|
||||
*/
|
||||
|
||||
/**
|
||||
* Klasa stEcardBackendActions
|
||||
*
|
||||
* @package stEcardPlugin
|
||||
* @subpackage actions
|
||||
*/
|
||||
class stEcardBackendActions extends stActions
|
||||
{
|
||||
/**
|
||||
* Wyświetla konfigurację modułu
|
||||
*/
|
||||
public function executeIndex()
|
||||
{
|
||||
$this->config = stConfig::getInstance($this->getContext());
|
||||
$i18n = $this->getContext()->getI18N();
|
||||
|
||||
if ($this->getRequest()->getMethod() == sfRequest::POST)
|
||||
{
|
||||
$this->config->setFromRequest('ecard');
|
||||
$this->config->save();
|
||||
$this->setFlash('notice', $i18n->__('Twoje zmiany zostały zapisane', null, 'stAdminGeneratorPlugin'));
|
||||
}
|
||||
|
||||
$this->labels = $this->getLabels();
|
||||
$this->config->load();
|
||||
}
|
||||
|
||||
public function validateIndex()
|
||||
{
|
||||
if ($this->getRequest()->getMethod() == sfRequest::POST)
|
||||
{
|
||||
stAuthUsersListener::checkModificationCredentials($this, $this->getRequest(), $this->getModuleName());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Akcja w przypadku błędu w uzupełnianiu pól
|
||||
*/
|
||||
public function handleErrorIndex()
|
||||
{
|
||||
$this->config = stConfig::getInstance($this->getContext());
|
||||
$this->labels = $this->getLabels();
|
||||
return sfView::SUCCESS;
|
||||
}
|
||||
|
||||
protected function getLabels()
|
||||
{
|
||||
return array('ecard{ecard_id}' => 'Identyfikator', 'ecard{ecard_password}' => 'Hasło autoryzacji');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
class stEcardBackendComponents extends sfComponents
|
||||
{
|
||||
|
||||
public function executeListMenu()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,19 @@
|
||||
<div class="list-menu">
|
||||
<ul>
|
||||
|
||||
<li class="selected">
|
||||
<?php echo link_to(__('eCard'),'stEcardBackend/index')?>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<?php if (sfContext::getInstance()->getUser()->getCulture() == 'pl_PL'): ?>
|
||||
<a href="https://www.sote.pl/docs/ecard" target="_blank"><?php echo __('Dokumentacja'); ?></a>
|
||||
<?php else: ?>
|
||||
<a href="https://www.soteshop.com/docs/ecard" target="_blank"><?php echo __('Documentation'); ?></a>
|
||||
<?php endif; ?>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="clr"></div>
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php use_helper('I18N', 'stAdminGenerator', 'Validation') ?>
|
||||
<?php $protocol = stConfig::getInstance('stSecurityBackend')->get('ssl') ? 'https' : 'http' ?>
|
||||
<?php echo st_get_admin_head('stEcardPlugin', __('eCard', array()), __('', array()),array('stPayment')) ?>
|
||||
<?php st_view_slot_start('application-menu') ?>
|
||||
<?php st_include_component('stEcardBackend', 'listMenu') ?>
|
||||
<?php st_view_slot_end() ?>
|
||||
<?php st_include_partial('stAdminGenerator/message', array('labels' => $labels, 'i18n_catalogue' => 'stEcardBackend'));?>
|
||||
<?php echo form_tag('ecard/index', array('id' => 'sf_admin_config_form', 'name' => 'sf_admin_config_form', 'class' => 'admin_form')) ?>
|
||||
<fieldset>
|
||||
<div class="content">
|
||||
<div class="form-row<?php if($sf_request->hasError('ecard{ecard_id}')): ?> form-error<?php endif; ?>">
|
||||
<label for="ecard_ecard_password" class="required"><?php echo __('Identyfikator') ?></label>
|
||||
<div class="field">
|
||||
<?php if($sf_request->hasErrors()): ?>
|
||||
<div class="form-error-msg">
|
||||
<div class="form_error" id="error_for_ecard_id"> ↓ <?php echo $sf_request->getError('ecard{ecard_id}') ?> ↓</div>
|
||||
</div>
|
||||
<?php echo input_tag('ecard[ecard_id]', $sf_params->get('ecard[ecard_id]'), array('size' => '50')) ?>
|
||||
<?php else: ?>
|
||||
<?php echo input_tag('ecard[ecard_id]', $config->get('ecard_id'), array('size' => '50')) ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<div class="clr"></div>
|
||||
</div>
|
||||
<div class="form-row<?php if($sf_request->hasError('ecard{ecard_password}')): ?> form-error<?php endif; ?>">
|
||||
<label for="ecard_ecard_password" class="required"><?php echo __('Hasło autoryzacji') ?></label>
|
||||
<div class="field">
|
||||
<?php if($sf_request->hasErrors()): ?>
|
||||
<div class="form-error-msg">
|
||||
<div class="form_error" id="error_for_ecard_password"> ↓ <?php echo $sf_request->getError('ecard{ecard_password}') ?> ↓</div>
|
||||
</div>
|
||||
<?php echo input_password_tag('ecard[ecard_password]', $sf_params->get('ecard[ecard_password]'), array('size' => '50')) ?>
|
||||
<?php else: ?>
|
||||
<?php echo input_password_tag('ecard[ecard_password]', $config->get('ecard_password'), array('size' => '50')) ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<div class="clr"></div>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<h2><?php echo __('Konfiguracja usługi') ?></h2>
|
||||
<div class="content">
|
||||
<div class="row">
|
||||
<?php echo st_admin_get_form_field('ecard_notify_url', __('Adres powiadomienia POST'), $protocol.'://'.$sf_request->getHost().'/ecard/statusReport/'.stEcard::getPostSecureHash(), 'input_tag', array('readonly' => true, 'size' => 80, 'clipboard' => true)) ?>
|
||||
<div class="clr"></div>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
<?php echo input_hidden_tag('ecard[transaction_fix]',$config->get('transaction_fix')) ?>
|
||||
<?php echo st_get_admin_actions(array(
|
||||
array('type' => 'save', 'label' => __('Zapisz', null, 'stAdminGeneratorPlugin'))
|
||||
)) ?>
|
||||
</form>
|
||||
<div class="clr"></div>
|
||||
<?php echo st_get_admin_foot() ?>
|
||||
@@ -0,0 +1,7 @@
|
||||
fields:
|
||||
ecard{ecard_id}:
|
||||
required:
|
||||
msg: Proszę uzupełnić pole.
|
||||
ecard{ecard_password}:
|
||||
required:
|
||||
msg: Proszę uzupełnić pole.
|
||||
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
/**
|
||||
* @author Michal Prochowski <michal.prochowski@sote.pl>
|
||||
*/
|
||||
|
||||
/**
|
||||
* Klasa stEcardFrontendActions
|
||||
*
|
||||
* @package stEcardPlugin
|
||||
* @subpackage actions
|
||||
*/
|
||||
class stEcardFrontendActions extends stActions
|
||||
{
|
||||
/**
|
||||
* Pozytywny powrót z płatności
|
||||
*/
|
||||
public function executeReturn()
|
||||
{
|
||||
if ($this->getRequest()->hasParameter('status'))
|
||||
{
|
||||
if($this->getRequest()->getParameter('status') == 'OK')
|
||||
{
|
||||
$this->forward('stEcardFrontend', 'returnSuccess');
|
||||
}
|
||||
}
|
||||
$this->forward('stEcardFrontend', 'returnFail');
|
||||
}
|
||||
|
||||
/**
|
||||
* Pozytywny powrót z płatności
|
||||
*/
|
||||
public function executeReturnSuccess()
|
||||
{
|
||||
$this->smarty = new stSmarty($this->getModuleName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Negatywny powrót z płatności
|
||||
*/
|
||||
public function executeReturnFail()
|
||||
{
|
||||
$this->smarty = new stSmarty($this->getModuleName());
|
||||
$this->contactPage = WebpagePeer::retrieveByState('CONTACT');
|
||||
}
|
||||
|
||||
/**
|
||||
* Odbieranie statusu transakcji
|
||||
*/
|
||||
public function executeStatusReport()
|
||||
{
|
||||
$state = $this->getRequestParameter('CURRENTSTATE');
|
||||
|
||||
if ($state == 'payment_deposited' || $state == 'payment_closed' || $state == 'transfer_closed')
|
||||
{
|
||||
if ($this->getRequestParameter('hash') == stEcard::getPostSecureHash())
|
||||
{
|
||||
$id = $this->getRequestParameter('ORDERNUMBER');
|
||||
$transaction = EcardTransactionPeer::retrieveByPK($id);
|
||||
|
||||
$transaction_id = $transaction ? $transaction->getOrderId() : $id;
|
||||
|
||||
$order = OrderPeer::retrieveByPK($transaction_id);
|
||||
|
||||
if ($order && $order->getOrderPayment())
|
||||
{
|
||||
$order->getOrderPayment()->setStatus(1);
|
||||
$order->getOrderPayment()->setTransactionId($transaction_id);
|
||||
$order->getOrderPayment()->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this->renderText('OK');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
/**
|
||||
* SOTESHOP/stDotpayPlugin
|
||||
*
|
||||
* Ten plik należy do aplikacji stDotpayPlugin opartej na licencji (Professional License SOTE).
|
||||
* Nie zmieniaj tego pliku, jeśli chcesz korzystać z automatycznych aktualizacji oprogramowania.
|
||||
* Jeśli chcesz wprowadzać swoje modyfikacje do programu, zapoznaj się z dokumentacją, jak zmieniać
|
||||
* oprogramowanie bez zmiany kodu bazowego http://www.sote.pl/modifications
|
||||
*
|
||||
* @package stDotpayPlugin
|
||||
* @subpackage actions
|
||||
* @copyright SOTE (www.sote.pl)
|
||||
* @license http://www.sote.pl/license/sote (Professional License SOTE)
|
||||
* @version $Id: components.class.php 12055 2011-04-05 11:36:39Z michal $
|
||||
* @author Michal Prochowski <michal.prochowski@sote.pl>
|
||||
*/
|
||||
|
||||
/**
|
||||
* Klasa stDotpayFrontendComponents
|
||||
*
|
||||
* @package stDotpayPlugin
|
||||
* @subpackage actions
|
||||
*/
|
||||
class stEcardFrontendComponents extends sfComponents
|
||||
{
|
||||
/**
|
||||
* Pokazywanie formularza płatności
|
||||
*/
|
||||
public function executeShowPayment()
|
||||
{
|
||||
$this->smarty = new stSmarty('stEcardFrontend');
|
||||
if (stPaymentType::hasOrderInSummary())
|
||||
{
|
||||
$this->stEcard = new stEcard();
|
||||
$this->stWebRequest = new stWebRequest();
|
||||
|
||||
$this->order = stPaymentType::getOrderInSummary();
|
||||
$this->user = $this->order->getOrderUserDataBilling();
|
||||
$this->lang = stPaymentType::getLanguage(array('PL', 'EN', 'DE', 'FR', 'RU', 'CZ', 'IT', 'ES'));
|
||||
$this->hash = stPaymentType::getPaymentHash($this->order->getId());
|
||||
$this->country = stPaymentType::getCountry($this->user);
|
||||
$this->currency = stPaymentType::getCurrency($this->order->getId());
|
||||
|
||||
/**
|
||||
* Pobieranie hash
|
||||
*/
|
||||
// $postParameters = array( 'orderNumber' => $this->order->getId(),
|
||||
// 'orderDescription' => '',
|
||||
// 'amount' => $this->stEcard->getOrderAmount(stPayment::getUnpayedAmountByOrder($this->order)),
|
||||
// 'currency' => $this->currency->getCode(),
|
||||
// 'merchantId' => $this->stEcard->getEcardId(),
|
||||
// 'password' => $this->stEcard->getEcardPassword(),
|
||||
// );
|
||||
|
||||
// $b = new sfWebBrowser(array(), 'sfCurlAdapter', array('ssl_verify' => false));
|
||||
// $b->post($this->stEcard->getHashUrl(), $postParameters);
|
||||
// $this->hash = trim($b->getResponseText());
|
||||
$this->params = $this->stEcard->getPaymentParams($this->order);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
st_theme_use_stylesheet('stPayment.css');
|
||||
$smarty->assign("check_configuration",$stEcard->checkPaymentConfiguration());
|
||||
$smarty->assign('url', 'https://pay.ecard.pl/payment/PS');
|
||||
if ($stEcard->checkPaymentConfiguration())
|
||||
{
|
||||
// if ($stEcard->getTest())
|
||||
// {
|
||||
// $smarty->assign("form_start", form_tag($stEcard->getTestUrl(), array('class' => 'st_form')));
|
||||
// }else
|
||||
// {
|
||||
// $smarty->assign("form_start", form_tag($stEcard->getUrl(), array('class' => 'st_form')));
|
||||
// }
|
||||
// $smarty->assign("input_order_number", input_hidden_tag('ORDERNUMBER', $order->getId()));
|
||||
// $smarty->assign("input_merchant_id", input_hidden_tag('MERCHANTID', $stEcard->getEcardId()));
|
||||
// $smarty->assign("input_order_description", input_hidden_tag('ORDERDESCRIPTION', $order->getId()));
|
||||
// $smarty->assign("input_amount", input_hidden_tag('AMOUNT', $stEcard->getOrderAmount(stPayment::getUnpayedAmountByOrder($order))));
|
||||
// $smarty->assign("input_currency", input_hidden_tag('CURRENCY', $currency->getCode()));
|
||||
// $smarty->assign("input_session_id", input_hidden_tag('SESSIONID', $hash));
|
||||
// $smarty->assign("input_name", input_hidden_tag('NAME', $user->getName()));
|
||||
// $smarty->assign("input_surname", input_hidden_tag('SURNAME', $user->getSurname()));
|
||||
// $smarty->assign("input_autodeposit", input_hidden_tag('AUTODEPOSIT', '1'));
|
||||
// $smarty->assign("input_bin", input_hidden_tag('BIN', ''));
|
||||
// $smarty->assign("input_language", input_hidden_tag('LANGUAGE', $lang));
|
||||
// $smarty->assign("input_charset", input_hidden_tag('CHARSET', 'UTF-8'));
|
||||
// $smarty->assign("input_country", input_hidden_tag('COUNTRY', '616'));
|
||||
// $smarty->assign("input_js", input_hidden_tag('JS', '1'));
|
||||
// $smarty->assign("input_hash", input_hidden_tag('HASH', $hash));
|
||||
// $smarty->assign("input_payment_type", input_hidden_tag('PAYMENTTYPE', $stEcard->getPaymentType()));
|
||||
// $smarty->assign("input_link_fail", input_hidden_tag('LINKFAIL', 'http://'.$stWebRequest->getHost().'/ecard/returnFail?'));
|
||||
// $smarty->assign("input_link_ok", input_hidden_tag('LINKOK', 'http://'.$stWebRequest->getHost().'/ecard/returnSuccess?'));
|
||||
// $smarty->assign("input_transparent_pages", input_hidden_tag('TRANSPARENTPAGES', '0'));
|
||||
// $smarty->assign("submit_button", submit_tag(__('Zapłać')));
|
||||
// $smarty->assign("description", stPaymentType::getSummaryDescriptionByOrderIdAndHash($order->getId()));
|
||||
$smarty->assign('params', $params);
|
||||
}
|
||||
$smarty->display("ecard_show_payment.html");
|
||||
?>
|
||||
@@ -0,0 +1,4 @@
|
||||
<?php
|
||||
st_theme_use_stylesheet('stPayment.css');
|
||||
$smarty->assign('contactLink', is_object($contactPage) ? url_for('stWebpageFrontend/index?url='.$contactPage->getFriendlyUrl()) : null);
|
||||
$smarty->display("ecard_return_fail.html");
|
||||
@@ -0,0 +1,3 @@
|
||||
<?php
|
||||
st_theme_use_stylesheet('stPayment.css');
|
||||
$smarty->display("ecard_return_success.html");
|
||||
@@ -0,0 +1 @@
|
||||
OK
|
||||
@@ -0,0 +1,8 @@
|
||||
<div class="st_application">
|
||||
<h1 class="st_title">
|
||||
{__ text="Płatność"}
|
||||
</h1>
|
||||
<p style="text-align: center; margin-bottom: 20px;">
|
||||
{__ text="Płatność nie została zrealizowana."}
|
||||
</p>
|
||||
</div>
|
||||
@@ -0,0 +1,8 @@
|
||||
<div class="st_application">
|
||||
<h1 class="st_title">
|
||||
{__ text="Płatność"}
|
||||
</h1>
|
||||
<p style="text-align: center; margin-bottom: 20px;">
|
||||
{__ text="Dziękujemy za dokonanie płatności."}
|
||||
</p>
|
||||
</div>
|
||||
@@ -0,0 +1,36 @@
|
||||
{if $check_configuration}
|
||||
<div id="st_box_payment">
|
||||
<p>{__ text="Kliknij przycisk"} <b>{__ text='"Zapłać"'}</b> {__ text="aby przejść do serwisu eCard."}</p>
|
||||
<p><img id="st_home" src="/images/frontend/theme/default/stEcardPlugin/logo.jpg" alt=""/></p>
|
||||
{$form_start}
|
||||
{$input_order_number}
|
||||
{$input_merchant_id}
|
||||
{$input_order_description}
|
||||
{$input_amount}
|
||||
{$input_currency}
|
||||
{$input_session_id}
|
||||
{$input_name}
|
||||
{$input_surname}
|
||||
{$input_autodeposit}
|
||||
{$input_bin}
|
||||
{$input_language}
|
||||
{$input_charset}
|
||||
{$input_country}
|
||||
{$input_js}
|
||||
{$input_hash}
|
||||
{$input_payment_type}
|
||||
{$input_link_fail}
|
||||
{$input_link_ok}
|
||||
{$input_transparent_pages}
|
||||
<div id="st_form-payment-submit" class="st_button-container">
|
||||
<div class="st_button st_align-right">
|
||||
<div class="st_button-left">
|
||||
{$submit_button}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
{else}
|
||||
{__ text="Płatność została błędnie skonfigurowana."}
|
||||
{/if}
|
||||
@@ -0,0 +1,8 @@
|
||||
<div id="stPayment_return" class="box roundies">
|
||||
<div class="title">
|
||||
<h2>{__ text="Płatność"}</h2>
|
||||
</div>
|
||||
<div class="content">
|
||||
<p>{__ text="Płatność nie została zrealizowana."}</p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,8 @@
|
||||
<div id="stPayment_return" class="box roundies">
|
||||
<div class="title">
|
||||
<h2>{__ text="Płatność"}</h2>
|
||||
</div>
|
||||
<div class="content">
|
||||
<p>{__ text="Dziękujemy za dokonanie płatności."}</p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,21 @@
|
||||
{if $check_configuration}
|
||||
<div id="st_box_payment">
|
||||
<img id="st_home" src="/images/frontend/theme/default2/stEcardPlugin/logo.jpg" alt=""/><br />
|
||||
<span>
|
||||
{$description}
|
||||
</span>
|
||||
<form action="{$url}" method="post">
|
||||
{foreach key=name item=value from=$params}
|
||||
<input type="hidden" name="{$name}" value="{$value}" />
|
||||
{/foreach}
|
||||
<div class="buttons right">
|
||||
<button type="submit" class="important roundies">
|
||||
<span class="arrow_right">{__ text="Zapłać"}</span>
|
||||
</button>
|
||||
</div>
|
||||
<br class="clear" />
|
||||
</form>
|
||||
</div>
|
||||
{else}
|
||||
{__ text="Płatność została błędnie skonfigurowana."}
|
||||
{/if}
|
||||
@@ -0,0 +1,20 @@
|
||||
{set layout="one_column"}
|
||||
<div id="payment">
|
||||
<div class="title">
|
||||
<h1>{__ text="Płatność"}</h1>
|
||||
</div>
|
||||
<div class="panel panel-default center-block">
|
||||
<div class="panel-heading">
|
||||
{__ text="eCard"}
|
||||
</div>
|
||||
<div class="panel-body text-center">
|
||||
<p>
|
||||
{__ text="Płatność nie została zrealizowana."}<br/>
|
||||
{__ text="Skontaktuj się z nami." langCatalogue="stPayment"}
|
||||
</p>
|
||||
{if $contactLink}
|
||||
<a href="{$contactLink}" class="btn btn-primary">{__ text="Kontakt" langCatalogue="stPayment"}</a>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,15 @@
|
||||
{set layout="one_column"}
|
||||
<div id="payment">
|
||||
<div class="title">
|
||||
<h1>{__ text="Płatność"}</h1>
|
||||
</div>
|
||||
<div class="panel panel-default center-block">
|
||||
<div class="panel-heading">
|
||||
{__ text="eCard"}
|
||||
</div>
|
||||
<div class="panel-body text-center">
|
||||
<p>{__ text="Dziękujemy za dokonanie płatności."}</p>
|
||||
<a href="/" class="btn btn-primary">{__ text="Wróć do zakupów" langCatalogue="stPayment"}</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,23 @@
|
||||
<div class="panel panel-default center-block">
|
||||
<div class="panel-heading">
|
||||
{__ text="eCard"}
|
||||
</div>
|
||||
<div class="panel-body text-center">
|
||||
{if $check_configuration}
|
||||
<img src="/images/frontend/theme/default2/stEcardPlugin/logo.jpg" alt="{__ text="eCard"}"/><br />
|
||||
<span>
|
||||
{$description}
|
||||
</span>
|
||||
<form action="{$url}" method="post">
|
||||
{foreach key=name item=value from=$params}
|
||||
<input type="hidden" name="{$name}" value="{$value}" />
|
||||
{/foreach}
|
||||
<button type="submit" class="btn btn-primary pull-right">
|
||||
{__ text="Zapłać"}
|
||||
</button>
|
||||
</form>
|
||||
{else}
|
||||
{__ text="Płatność została błędnie skonfigurowana."}
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
Reference in New Issue
Block a user