CRM_Core_DAO - Cleanup in createTestObject
[civicrm-core.git] / CRM / Member / BAO / MembershipBlock.php
index a57d521adbabc551e2fbb4f37d5ed26ea2499b45..3e4dfaed441614b8369cdcc01d5101676ed727f6 100644 (file)
@@ -1,9 +1,9 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.3                                                |
+ | CiviCRM version 4.5                                                |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2013                                |
+ | Copyright CiviCRM LLC (c) 2004-2014                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
 /**
  *
  * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2013
+ * @copyright CiviCRM LLC (c) 2004-2014
  * $Id$
  *
  */
 class CRM_Member_BAO_MembershipBlock extends CRM_Member_DAO_MembershipBlock {
-  // placeholder required because there's some magic code which assumes that BAOs exist
-}
\ No newline at end of file
+  /**
+   * class constructor
+   */
+  function __construct() {
+    parent::__construct();
+  }
+  /**
+   * function to add the membership Blocks
+   *
+   * @param array $params reference array contains the values submitted by the form
+   *
+   * @access public
+   * @static
+   *
+   * @return object
+   */
+  static function create(&$params) {
+    $hook = empty($params['id']) ? 'create' : 'edit';
+    CRM_Utils_Hook::pre($hook, 'MembershipBlock', CRM_Utils_Array::value('id', $params), $params);
+    $dao = new CRM_Member_DAO_MembershipBlock();
+    $dao->copyValues($params);
+    $dao->id = CRM_Utils_Array::value('id', $params);
+    $dao->save();
+    CRM_Utils_Hook::post($hook, 'MembershipBlock', $dao->id, $dao);
+    return $dao;
+  }
+
+  /**
+   * Function to delete membership Blocks
+   *
+   * @param int $id
+   *
+   * @return bool
+   * @static
+   */
+  static function del($id) {
+    $dao = new CRM_Member_DAO_MembershipBlock();
+    $dao->id = $id;
+    $result = FALSE;
+    if ($dao->find(TRUE)) {
+      $dao->delete();
+      $result = TRUE;
+    }
+    return $result;
+  }
+
+}