CRM-14023 CRM-14015 - Add apis for Premium & Product
authorColeman Watts <coleman@civicrm.org>
Mon, 23 Dec 2013 23:54:29 +0000 (15:54 -0800)
committerColeman Watts <coleman@civicrm.org>
Mon, 6 Jan 2014 19:10:41 +0000 (11:10 -0800)
CRM/Contribute/Page/ManagePremiums.php
api/v3/Premium.php [new file with mode: 0644]
api/v3/Product.php [new file with mode: 0644]
templates/CRM/Contribute/Page/ManagePremiums.tpl

index bbc1f161ddccc69456ec15586a008dcb296d3ae3..6ac87f541e3549bb110159a48848751f80817298 100644 (file)
@@ -164,7 +164,7 @@ class CRM_Contribute_Page_ManagePremiums extends CRM_Core_Page_Basic {
 
       $premiums[$dao->id]['action'] = CRM_Core_Action::formLink(self::links(),
         $action,
-        array('id' => $dao->id)),
+        array('id' => $dao->id),
         ts('more'),
         FALSE,
         'premium.manage.row',
diff --git a/api/v3/Premium.php b/api/v3/Premium.php
new file mode 100644 (file)
index 0000000..f5edcd5
--- /dev/null
@@ -0,0 +1,91 @@
+<?php
+
+/*
+ +--------------------------------------------------------------------+
+ | CiviCRM version 4.4                                                |
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC (c) 2004-2013                                |
+ +--------------------------------------------------------------------+
+ | 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        |
+ +--------------------------------------------------------------------+
+*/
+
+/**
+ * File for the CiviCRM APIv3 premium functions
+ *
+ * @package CiviCRM_APIv3
+ * @subpackage API_premium
+ *
+ */
+
+/**
+ * Save a premium
+ *
+ * Allowed @params array keys are:
+ * {@getfields premium_create}
+ * @example premiumCreate.php
+ *
+ * @return array of newly created premium property values.
+ * @access public
+ */
+function civicrm_api3_premium_create($params) {
+  return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params);
+}
+
+/**
+ * Get a premium
+ *
+ * Allowed @params array keys are:
+ * {@getfields premium_get}
+ * @example premiumCreate.php
+ *
+ * @return array of retrieved premium property values.
+ * @access public
+ */
+function civicrm_api3_premium_get($params) {
+  return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params);
+}
+
+/**
+ * Delete a premium
+ *
+ * Allowed @params array keys are:
+ * {@getfields premium_delete}
+ * @example premiumCreate.php
+ *
+ * @return array of deleted values.
+ * @access public
+ */
+function civicrm_api3_premium_delete($params) {
+  return _civicrm_api3_basic_delete(_civicrm_api3_get_BAO(__FUNCTION__), $params);
+}
+
+/**
+ * return field specification specific to get requests
+ */
+function _civicrm_api3_premium_get_spec(&$params) {
+  $params['premium_active']['api.aliases'] = array('is_active');
+}
+
+/**
+ * return field specification specific to create requests
+ */
+function _civicrm_api3_premium_create_spec(&$params) {
+  $params['premium_active']['api.aliases'] = array('is_active');
+}
diff --git a/api/v3/Product.php b/api/v3/Product.php
new file mode 100644 (file)
index 0000000..3ed3d75
--- /dev/null
@@ -0,0 +1,77 @@
+<?php
+
+/*
+ +--------------------------------------------------------------------+
+ | CiviCRM version 4.4                                                |
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC (c) 2004-2013                                |
+ +--------------------------------------------------------------------+
+ | 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        |
+ +--------------------------------------------------------------------+
+*/
+
+/**
+ * File for the CiviCRM APIv3 product functions
+ *
+ * @package CiviCRM_APIv3
+ * @subpackage API_product
+ *
+ */
+
+/**
+ * Save a product
+ *
+ * Allowed @params array keys are:
+ * {@getfields product_create}
+ * @example productCreate.php
+ *
+ * @return array of newly created product property values.
+ * @access public
+ */
+function civicrm_api3_product_create($params) {
+  return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params);
+}
+
+/**
+ * Get a product
+ *
+ * Allowed @params array keys are:
+ * {@getfields product_get}
+ * @example productCreate.php
+ *
+ * @return array of retrieved product property values.
+ * @access public
+ */
+function civicrm_api3_product_get($params) {
+  return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params);
+}
+
+/**
+ * Delete a product
+ *
+ * Allowed @params array keys are:
+ * {@getfields product_delete}
+ * @example productCreate.php
+ *
+ * @return array of deleted values.
+ * @access public
+ */
+function civicrm_api3_product_delete($params) {
+  return _civicrm_api3_basic_delete(_civicrm_api3_get_BAO(__FUNCTION__), $params);
+}
index 87d1bce9fbd9517d782248c0fadc4f10640d97a6..9aad91d592020a5a3994421c1847aa78c2badb23 100644 (file)
@@ -58,9 +58,9 @@
            </tr>
           </thead>
         {foreach from=$rows item=row}
-        <tr id="row_{$row.id}"class="{cycle values="odd-row,even-row"} {$row.class}{if NOT $row.is_active} disabled{/if}">
-          <td class="crm-contribution-form-block-name">{$row.name}</td>
-          <td class="crm-contribution-form-block-sku">{$row.sku}</td>
+        <tr id="product-{$row.id}" class="crm-entity {cycle values="odd-row,even-row"} {$row.class}{if NOT $row.is_active} disabled{/if}">
+          <td class="crm-contribution-form-block-name crm-editable" data-field="name">{$row.name}</td>
+          <td class="crm-contribution-form-block-sku crm-editable" data-field="sku">{$row.sku}</td>
                 <td class="crm-contribution-form-block-price">{$row.price }</td>
     <td class="crm-contribution-form-block-financial_type">{$row.financial_type_id}</td>
           <td class="crm-contribution-form-block-min_contribution">{$row.min_contribution}</td>