Merge pull request #15435 from MegaphoneJon/reporting-21
[civicrm-core.git] / CRM / Member / BAO / MembershipLog.php
CommitLineData
6a488035
TO
1<?php
2/*
3 +--------------------------------------------------------------------+
bc77d7c0 4 | Copyright CiviCRM LLC. All rights reserved. |
6a488035 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 |
6a488035 9 +--------------------------------------------------------------------+
d25dd0ee 10 */
6a488035
TO
11
12/**
13 *
14 * @package CRM
ca5cec67 15 * @copyright CiviCRM LLC https://civicrm.org/licensing
6a488035
TO
16 * $Id$
17 *
18 */
19class CRM_Member_BAO_MembershipLog extends CRM_Member_DAO_MembershipLog {
20
21 /**
fe482240 22 * Add the membership log record.
6a488035 23 *
b2363ea8 24 * @param array $params
dfc9c0c7 25 * Properties of the log item.
6a488035 26 *
dfc9c0c7 27 * @return CRM_Member_DAO_MembershipLog|CRM_Core_Error
6a488035 28 */
dfc9c0c7 29 public static function add($params) {
6a488035
TO
30 $membershipLog = new CRM_Member_DAO_MembershipLog();
31 $membershipLog->copyValues($params);
6a488035 32 $membershipLog->save();
6a488035
TO
33
34 return $membershipLog;
35 }
36
37 /**
fe482240 38 * Delete membership log record.
6a488035 39 *
c490a46a 40 * @param int $membershipID
77b97be7
EM
41 *
42 * @return mixed
6a488035 43 */
00be9182 44 public static function del($membershipID) {
6a488035
TO
45 $membershipLog = new CRM_Member_DAO_MembershipLog();
46 $membershipLog->membership_id = $membershipID;
47 return $membershipLog->delete();
48 }
49
bb3a214a 50 /**
dfc9c0c7
EM
51 * Reset the modified ID to NULL for log items by the given contact ID.
52 *
100fef9d 53 * @param int $contactID
bb3a214a 54 */
00be9182 55 public static function resetModifiedID($contactID) {
6a488035
TO
56 $query = "
57UPDATE civicrm_membership_log
58 SET modified_id = null
59 WHERE modified_id = %1";
60
be2fb01f 61 $params = [1 => [$contactID, 'Integer']];
6a488035
TO
62 CRM_Core_DAO::executeQuery($query, $params);
63 }
96025800 64
6a488035 65}