Commit | Line | Data |
---|---|---|
b488bd43 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
bc77d7c0 | 4 | | Copyright CiviCRM LLC. All rights reserved. | |
b488bd43 | 5 | | | |
bc77d7c0 TO |
6 | | This work is published under the GNU AGPLv3 license with some | |
7 | | permitted exceptions and without any warranty. For full license | | |
8 | | and copyright information, see https://civicrm.org/licensing | | |
b488bd43 | 9 | +--------------------------------------------------------------------+ |
d25dd0ee | 10 | */ |
b488bd43 TO |
11 | |
12 | /** | |
13 | * | |
14 | * @package CRM | |
ca5cec67 | 15 | * @copyright CiviCRM LLC https://civicrm.org/licensing |
b488bd43 TO |
16 | * $Id$ |
17 | * | |
18 | */ | |
19 | class CRM_Member_BAO_MembershipBlock extends CRM_Member_DAO_MembershipBlock { | |
971e129b | 20 | |
28abbcb0 | 21 | /** |
fe482240 | 22 | * Class constructor. |
28abbcb0 | 23 | */ |
00be9182 | 24 | public function __construct() { |
28abbcb0 | 25 | parent::__construct(); |
26 | } | |
353ffa53 | 27 | |
28abbcb0 | 28 | /** |
fe482240 | 29 | * Add the membership Blocks. |
28abbcb0 | 30 | * |
b2363ea8 TO |
31 | * @param array $params |
32 | * Reference array contains the values submitted by the form. | |
28abbcb0 | 33 | * |
28abbcb0 | 34 | * |
35 | * @return object | |
36 | */ | |
00be9182 | 37 | public static function create(&$params) { |
28abbcb0 | 38 | $hook = empty($params['id']) ? 'create' : 'edit'; |
39 | CRM_Utils_Hook::pre($hook, 'MembershipBlock', CRM_Utils_Array::value('id', $params), $params); | |
40 | $dao = new CRM_Member_DAO_MembershipBlock(); | |
fc944198 | 41 | $dao->copyValues($params); |
9c1bc317 | 42 | $dao->id = $params['id'] ?? NULL; |
82e4a144 | 43 | $dao->save(); |
e8c8c317 | 44 | CRM_Utils_Hook::post($hook, 'MembershipBlock', $dao->id, $dao); |
28abbcb0 | 45 | return $dao; |
46 | } | |
47 | ||
48 | /** | |
fe482240 | 49 | * Delete membership Blocks. |
28abbcb0 | 50 | * |
51 | * @param int $id | |
77b97be7 EM |
52 | * |
53 | * @return bool | |
28abbcb0 | 54 | */ |
00be9182 | 55 | public static function del($id) { |
784a6e4a | 56 | $dao = new CRM_Member_DAO_MembershipBlock(); |
28abbcb0 | 57 | $dao->id = $id; |
58 | $result = FALSE; | |
59 | if ($dao->find(TRUE)) { | |
60 | $dao->delete(); | |
61 | $result = TRUE; | |
62 | } | |
63 | return $result; | |
64 | } | |
65 | ||
66 | } |