forked from rajeshrhino/uk.co.nfpservices.module.civigiftaid
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27 from compucorp/civi4.6
Merge Civi4.6 branch
- Loading branch information
Showing
34 changed files
with
3,274 additions
and
1,185 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php | ||
|
||
class CRM_Civigiftaid_BAO_BatchSettings extends CRM_Civigiftaid_DAO_BatchSettings { | ||
|
||
/** | ||
* Create a new BatchSettings based on array-data | ||
* | ||
* @param array $params key-value pairs | ||
* | ||
* @return CRM_Civigiftaid_DAO_BatchSettings|NULL | ||
*/ | ||
public static function create($params) { | ||
static::addDefaults($params); | ||
static::preProcessParams($params); | ||
|
||
$entityName = 'BatchSettings'; | ||
$hook = empty($params['id']) ? 'create' : 'edit'; | ||
|
||
CRM_Utils_Hook::pre($hook, $entityName, CRM_Utils_Array::value('id', $params), $params); | ||
|
||
$instance = new static; | ||
$instance->copyValues($params); | ||
$instance->save(); | ||
|
||
CRM_Utils_Hook::post($hook, $entityName, $instance->id, $instance); | ||
|
||
return $instance; | ||
} | ||
|
||
public static function findByBatchId($id) { | ||
$dao = static::executeQuery("SELECT * FROM " . static::getTableName() . " WHERE batch_id = {$id}"); | ||
|
||
if ($dao->fetch()) { | ||
return $dao; | ||
} | ||
|
||
return FALSE; | ||
} | ||
|
||
/** | ||
* Add default value of certain params, if not provided. | ||
* | ||
* @param $params | ||
*/ | ||
private static function addDefaults(&$params) { | ||
if (!isset($params['financial_types_enabled'])) { | ||
$params['financial_types_enabled'] = CRM_Civigiftaid_Form_Admin::getFinancialTypesEnabled(); | ||
} | ||
if (!isset($params['globally_enabled'])) { | ||
$params['globally_enabled'] = CRM_Civigiftaid_Form_Admin::isGloballyEnabled(); | ||
} | ||
} | ||
|
||
private static function preProcessParams(&$params) { | ||
if (is_array($params['financial_types_enabled'])) { | ||
$params['financial_types_enabled'] = serialize($params['financial_types_enabled']); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,252 @@ | ||
<?php | ||
/* | ||
+--------------------------------------------------------------------+ | ||
| CiviCRM version 4.6 | | ||
+--------------------------------------------------------------------+ | ||
| Copyright CiviCRM LLC (c) 2004-2015 | | ||
+--------------------------------------------------------------------+ | ||
| This file is a part of CiviCRM. | | ||
| | | ||
| CiviCRM is free software; you can copy, modify, and distribute it | | ||
| under the terms of the GNU Affero General Public License | | ||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. | | ||
| | | ||
| CiviCRM is distributed in the hope that it will be useful, but | | ||
| WITHOUT ANY WARRANTY; without even the implied warranty of | | ||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | | ||
| See the GNU Affero General Public License for more details. | | ||
| | | ||
| You should have received a copy of the GNU Affero General Public | | ||
| License and the CiviCRM Licensing Exception along | | ||
| with this program; if not, contact CiviCRM LLC | | ||
| at info[AT]civicrm[DOT]org. If you have questions about the | | ||
| GNU Affero General Public License or the licensing of CiviCRM, | | ||
| see the CiviCRM license FAQ at http://civicrm.org/licensing | | ||
+--------------------------------------------------------------------+ | ||
*/ | ||
/** | ||
* @package CRM | ||
* @copyright CiviCRM LLC (c) 2004-2015 | ||
* | ||
* Generated from xml/schema/CRM/Civigiftaid/BatchSettings.xml | ||
* DO NOT EDIT. Generated by CRM_Core_CodeGen | ||
*/ | ||
require_once 'CRM/Core/DAO.php'; | ||
require_once 'CRM/Utils/Type.php'; | ||
class CRM_Civigiftaid_DAO_BatchSettings extends CRM_Core_DAO | ||
{ | ||
/** | ||
* static instance to hold the table name | ||
* | ||
* @var string | ||
*/ | ||
static $_tableName = 'civicrm_civigiftaid_batchsettings'; | ||
/** | ||
* static instance to hold the field values | ||
* | ||
* @var array | ||
*/ | ||
static $_fields = null; | ||
/** | ||
* static instance to hold the keys used in $_fields for each field. | ||
* | ||
* @var array | ||
*/ | ||
static $_fieldKeys = null; | ||
/** | ||
* static instance to hold the FK relationships | ||
* | ||
* @var string | ||
*/ | ||
static $_links = null; | ||
/** | ||
* static instance to hold the values that can | ||
* be imported | ||
* | ||
* @var array | ||
*/ | ||
static $_import = null; | ||
/** | ||
* static instance to hold the values that can | ||
* be exported | ||
* | ||
* @var array | ||
*/ | ||
static $_export = null; | ||
/** | ||
* static value to see if we should log any modifications to | ||
* this table in the civicrm_log table | ||
* | ||
* @var boolean | ||
*/ | ||
static $_log = true; | ||
/** | ||
* Unique BatchSettings ID | ||
* | ||
* @var int unsigned | ||
*/ | ||
public $id; | ||
/** | ||
* FK to Batch | ||
* | ||
* @var int unsigned | ||
*/ | ||
public $batch_id; | ||
/** | ||
* Financial type enabled for this batch | ||
* | ||
* @var text | ||
*/ | ||
public $financial_types_enabled; | ||
/** | ||
* Globally enabled for this batch | ||
* | ||
* @var boolean | ||
*/ | ||
public $globally_enabled; | ||
/** | ||
* class constructor | ||
* | ||
* @return civicrm_civigiftaid_batchsettings | ||
*/ | ||
function __construct() | ||
{ | ||
$this->__table = 'civicrm_civigiftaid_batchsettings'; | ||
parent::__construct(); | ||
} | ||
/** | ||
* Returns foreign keys and entity references | ||
* | ||
* @return array | ||
* [CRM_Core_Reference_Interface] | ||
*/ | ||
static function getReferenceColumns() | ||
{ | ||
if (!self::$_links) { | ||
self::$_links = static ::createReferenceColumns(__CLASS__); | ||
self::$_links[] = new CRM_Core_Reference_Basic(self::getTableName() , 'batch_id', 'civicrm_batch', 'id'); | ||
} | ||
return self::$_links; | ||
} | ||
/** | ||
* Returns all the column names of this table | ||
* | ||
* @return array | ||
*/ | ||
static function &fields() | ||
{ | ||
if (!(self::$_fields)) { | ||
self::$_fields = array( | ||
'id' => array( | ||
'name' => 'id', | ||
'type' => CRM_Utils_Type::T_INT, | ||
'description' => 'Unique BatchSettings ID', | ||
'required' => true, | ||
) , | ||
'batch_id' => array( | ||
'name' => 'batch_id', | ||
'type' => CRM_Utils_Type::T_INT, | ||
'description' => 'FK to Batch', | ||
'FKClassName' => 'CRM_Batch_DAO_Batch', | ||
) , | ||
'financial_types_enabled' => array( | ||
'name' => 'financial_types_enabled', | ||
'type' => CRM_Utils_Type::T_TEXT, | ||
'title' => ts('Financial Types Enabled') , | ||
'description' => 'Financial type enabled for this batch', | ||
) , | ||
'globally_enabled' => array( | ||
'name' => 'globally_enabled', | ||
'type' => CRM_Utils_Type::T_BOOLEAN, | ||
'title' => ts('Globally Enabled') , | ||
'description' => 'Globally enabled for this batch', | ||
) , | ||
); | ||
} | ||
return self::$_fields; | ||
} | ||
/** | ||
* Returns an array containing, for each field, the arary key used for that | ||
* field in self::$_fields. | ||
* | ||
* @return array | ||
*/ | ||
static function &fieldKeys() | ||
{ | ||
if (!(self::$_fieldKeys)) { | ||
self::$_fieldKeys = array( | ||
'id' => 'id', | ||
'batch_id' => 'batch_id', | ||
'financial_types_enabled' => 'financial_types_enabled', | ||
'globally_enabled' => 'globally_enabled', | ||
); | ||
} | ||
return self::$_fieldKeys; | ||
} | ||
/** | ||
* Returns the names of this table | ||
* | ||
* @return string | ||
*/ | ||
static function getTableName() | ||
{ | ||
return self::$_tableName; | ||
} | ||
/** | ||
* Returns if this table needs to be logged | ||
* | ||
* @return boolean | ||
*/ | ||
function getLog() | ||
{ | ||
return self::$_log; | ||
} | ||
/** | ||
* Returns the list of fields that can be imported | ||
* | ||
* @param bool $prefix | ||
* | ||
* @return array | ||
*/ | ||
static function &import($prefix = false) | ||
{ | ||
if (!(self::$_import)) { | ||
self::$_import = array(); | ||
$fields = self::fields(); | ||
foreach($fields as $name => $field) { | ||
if (CRM_Utils_Array::value('import', $field)) { | ||
if ($prefix) { | ||
self::$_import['civigiftaid_batchsettings'] = & $fields[$name]; | ||
} else { | ||
self::$_import[$name] = & $fields[$name]; | ||
} | ||
} | ||
} | ||
} | ||
return self::$_import; | ||
} | ||
/** | ||
* Returns the list of fields that can be exported | ||
* | ||
* @param bool $prefix | ||
* | ||
* @return array | ||
*/ | ||
static function &export($prefix = false) | ||
{ | ||
if (!(self::$_export)) { | ||
self::$_export = array(); | ||
$fields = self::fields(); | ||
foreach($fields as $name => $field) { | ||
if (CRM_Utils_Array::value('export', $field)) { | ||
if ($prefix) { | ||
self::$_export['civigiftaid_batchsettings'] = & $fields[$name]; | ||
} else { | ||
self::$_export[$name] = & $fields[$name]; | ||
} | ||
} | ||
} | ||
} | ||
return self::$_export; | ||
} | ||
} |
Oops, something went wrong.