copyValues($params); if ($auction->find(TRUE)) { CRM_Core_DAO::storeValues($auction, $defaults); return $auction; } 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 sucess, null otherwise * @static */ static function setIsActive($id, $is_active) { return CRM_Core_DAO::setFieldValue('CRM_Auction_DAO_Item', $id, 'is_active', $is_active); } /** * function to add the auction * * @param array $params reference array contains the values submitted by the form * * @access public * @static * * @return object */ static function add(&$params) { require_once 'CRM/Utils/Hook.php'; if (!empty($params['id'])) { CRM_Utils_Hook::pre('edit', 'Auction_Item', $params['id'], $params); } else { CRM_Utils_Hook::pre('create', 'Auction_Item', NULL, $params); } $auction = new CRM_Auction_DAO_Item(); $auction->copyValues($params); $auction->save(); // add attachments as needed CRM_Core_BAO_File::formatAttachment($params, $params, 'civicrm_auction_item', $auction->id ); // add attachments as needed CRM_Core_BAO_File::processAttachment($params, 'civicrm_auction_item', $auction->id ); if (!empty($params['id'])) { CRM_Utils_Hook::post('edit', 'Auction_Item', $auction->id, $auction); } else { CRM_Utils_Hook::post('create', 'Auction_Item', $auction->id, $auction); } return $result; } /** * function to create the auction * * @param array $params reference array contains the values submitted by the form * * @access public * @static * */ public static function create(&$params) { require_once 'CRM/Core/Transaction.php'; $transaction = new CRM_Core_Transaction(); $auction = self::add($params); if (is_a($auction, 'CRM_Core_Error')) { CRM_Core_DAO::transaction('ROLLBACK'); return $auction; } $transaction->commit(); return $auction; } /** * Function to delete the auction * * @param int $id auction id * * @access public * @static * */ static function del($id) { require_once 'CRM/Auction/DAO/Item.php'; $auction = new CRM_Auction_DAO_Item(); $auction->id = $id; $result = $auction->delete(); return $result; } /** * Function to check if email is enabled for a given profile * * @param int $id profile id * * @return boolean * @access public * @static * */ static function isEmailInProfile($profileId) { $query = " SELECT field_name FROM civicrm_uf_field WHERE field_name like 'email%' And is_active = 1 And uf_group_id = %1"; $params = array(1 => array($profileId, 'Integer')); $dao = CRM_Core_DAO::executeQuery($query, $params); if (!$dao->fetch()) { return TRUE; } return FALSE; } }