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); $params['label_type_id'] = CRM_Core_OptionGroup::getValue('label_type', 'Event Badge', 'name'); // check if new layout is create, if so set the created_id (if not set) if (empty($params['id'])) { if (empty($params['created_id'])) { $session = CRM_Core_Session::singleton(); $params['created_id'] = $session->get('userID'); } } if (!isset($params['id']) && !isset($params['name'])) { $params['name'] = CRM_Utils_String::munge($params['title'], '_', 64); } // 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(); } }