From d2e138ee836d3fd11b57df1ccb7ce86c4dd67bf5 Mon Sep 17 00:00:00 2001 From: Kurund Jalmi Date: Sun, 30 Jun 2013 16:45:35 +0530 Subject: [PATCH] CRM-12965 more cleanup and fixes --- CRM/Badge/BAO/Layout.php | 124 ++++++++++++++++++++++++++++++++++++ CRM/Badge/Page/Layout.php | 2 +- CRM/Core/Page/Basic.php | 9 ++- CRM/Core/xml/Menu/Admin.xml | 4 +- 4 files changed, 135 insertions(+), 4 deletions(-) create mode 100644 CRM/Badge/BAO/Layout.php diff --git a/CRM/Badge/BAO/Layout.php b/CRM/Badge/BAO/Layout.php new file mode 100644 index 0000000000..b5357fe7f0 --- /dev/null +++ b/CRM/Badge/BAO/Layout.php @@ -0,0 +1,124 @@ +copyValues($params); + if ($printLabel->find(TRUE)) { + CRM_Core_DAO::storeValues($printLabel, $defaults); + return $printLabel; + } + return NULL; + } + + /** + * update the is_active flag in the db + * + * @param int $id id of the database record + * @param boolean $is_active value we want to set the is_active field + * + * @return Object DAO object on success, null otherwise + * + * @access public + * @static + */ + static function setIsActive($id, $is_active) { + return CRM_Core_DAO::setFieldValue('CRM_Core_DAO_PrintLabel', $id, 'is_active', $is_active); + } + + /** + * Function to add a name label + * + * @param array $params reference array contains the values submitted by the form + * @param array $ids reference array contains the id + * + * @access public + * @static + * + * @return object + */ + static function create(&$params) { + $params['is_active'] = CRM_Utils_Array::value('is_active', $params, FALSE); + $params['is_default'] = CRM_Utils_Array::value('is_default', $params, FALSE); + $params['is_reserved'] = CRM_Utils_Array::value('is_reserved', $params, FALSE); + + // action is taken depending upon the mode + $printLabel = new CRM_Core_DAO_PrintLabel(); + $printLabel->copyValues($params); + + if ($params['is_default']) { + $query = "UPDATE civicrm_print_label SET is_default = 0"; + CRM_Core_DAO::executeQuery($query, CRM_Core_DAO::$_nullArray); + } + + $printLabel->save(); + return $printLabel; + } + + /** + * Function to delete name labels + * + * @param int $printLabelId ID of the name label to be deleted. + * + * @access public + * @static + */ + static function del($printLabelId) { + $printLabel = new CRM_Core_DAO_PrintLabel(); + $printLabel->id = $printLabelId; + $printLabel->delete(); + } +} + diff --git a/CRM/Badge/Page/Layout.php b/CRM/Badge/Page/Layout.php index 062d89dd03..f7ca83e909 100644 --- a/CRM/Badge/Page/Layout.php +++ b/CRM/Badge/Page/Layout.php @@ -52,7 +52,7 @@ class CRM_Badge_Page_Layout extends CRM_Core_Page_Basic { * @return string Classname of BAO. */ function getBAOName() { - return 'CRM_Core_DAO_PrintLabel'; + return 'CRM_Badge_BAO_Layout'; } /** diff --git a/CRM/Core/Page/Basic.php b/CRM/Core/Page/Basic.php index c55c368829..417709e7f6 100644 --- a/CRM/Core/Page/Basic.php +++ b/CRM/Core/Page/Basic.php @@ -307,7 +307,14 @@ abstract class CRM_Core_Page_Basic extends CRM_Core_Page { $values['class'] = 'reserved'; // check if object is relationship type $object_type = get_class($object); - if ($object_type == 'CRM_Contact_BAO_RelationshipType' || $object_type == 'CRM_Core_BAO_LocationType') { + + $exceptions = array( + 'CRM_Contact_BAO_RelationshipType', + 'CRM_Core_BAO_LocationType', + 'CRM_Badge_BAO_Layout', + ); + + if (in_array($object_type, $exceptions)) { $newAction = CRM_Core_Action::VIEW + CRM_Core_Action::UPDATE; } else { diff --git a/CRM/Core/xml/Menu/Admin.xml b/CRM/Core/xml/Menu/Admin.xml index dddc1db5d0..552605cc62 100644 --- a/CRM/Core/xml/Menu/Admin.xml +++ b/CRM/Core/xml/Menu/Admin.xml @@ -767,11 +767,11 @@ civicrm/admin/badgelayout Badge Layout CRM_Badge_Page_Layout - administer CiviCRM,access CiviEvent + administer CiviCRM civicrm/admin/badgelayout/add CRM_Badge_Form_Layout - administer CiviCRM,access CiviEvent + administer CiviCRM -- 2.25.1