3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.4 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2013 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
30 * This file checks and updates the status of all membership records for a given domain using the calc_membership_status and
31 * update_contact_membership APIs.
32 * It takes the first argument as the domain-id if specified, otherwise takes the domain-id as 1.
35 * We are using the default Domain FROM Name and FROM Email Address as the From email address for emails sent by this script.
36 * Verify that this value has been properly set from Administer > Configure > Domain Information
37 * If you want to use some other FROM email address, modify line 125 and set your valid email address.
39 * Save the file as UpdateMembershipRecord.php prior to running this script.
41 class CRM_UpdateMembershipRecord
{
42 function __construct() {
43 // you can run this program either from an apache command, or from the cli
44 if (php_sapi_name() == "cli") {
45 require_once ("cli.php");
46 $cli = new civicrm_cli();
47 //if it doesn't die, it's authenticated
53 $config = CRM_Core_Config
::singleton();
55 // this does not return on failure
56 CRM_Utils_System
::authenticateScript(TRUE);
58 //log the execution time of script
59 CRM_Core_Error
::debug_log_message('UpdateMembershipRecord.php');
63 function initialize() {
64 require_once '../civicrm.config.php';
65 require_once 'CRM/Core/Config.php';
67 $config = CRM_Core_Config
::singleton();
70 public function updateMembershipStatus() {
71 require_once 'CRM/Member/BAO/Membership.php';
72 CRM_Member_BAO_Membership
::updateAllMembershipStatus();
76 $obj = new CRM_UpdateMembershipRecord();
79 $obj->updateMembershipStatus();
80 echo "\n\n Membership records updated. (Done) \n";