Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
39de6fd5 | 4 | | CiviCRM version 4.6 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
f5721b07 | 6 | | Copyright CiviCRM LLC (c) 2004-2014 | |
6a488035 TO |
7 | +--------------------------------------------------------------------+ |
8 | | This file is a part of CiviCRM. | | |
9 | | | | |
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. | | |
13 | | | | |
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. | | |
18 | | | | |
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 | +--------------------------------------------------------------------+ | |
26 | */ | |
27 | ||
28 | ||
29 | /* | |
783f84c9 | 30 | * This file checks and updates the status of all membership records for a given domain using the calc_membership_status and |
6a488035 TO |
31 | * update_contact_membership APIs. |
32 | * It takes the first argument as the domain-id if specified, otherwise takes the domain-id as 1. | |
33 | * | |
783f84c9 | 34 | * IMPORTANT: |
35 | * We are using the default Domain FROM Name and FROM Email Address as the From email address for emails sent by this script. | |
6a488035 TO |
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. | |
38 | * | |
39 | * Save the file as UpdateMembershipRecord.php prior to running this script. | |
40 | */ | |
4e87860d EM |
41 | |
42 | /** | |
43 | * Class CRM_UpdateMembershipRecord | |
44 | */ | |
6a488035 | 45 | class CRM_UpdateMembershipRecord { |
4e87860d | 46 | /** |
4e87860d | 47 | */ |
6a488035 TO |
48 | function __construct() { |
49 | // you can run this program either from an apache command, or from the cli | |
50 | if (php_sapi_name() == "cli") { | |
a9e80afc | 51 | require_once "cli.php"; |
6a488035 TO |
52 | $cli = new civicrm_cli(); |
53 | //if it doesn't die, it's authenticated | |
54 | } | |
55 | else { | |
56 | //from the webserver | |
57 | $this->initialize(); | |
58 | ||
59 | $config = CRM_Core_Config::singleton(); | |
60 | ||
61 | // this does not return on failure | |
62 | CRM_Utils_System::authenticateScript(TRUE); | |
63 | ||
64 | //log the execution time of script | |
65 | CRM_Core_Error::debug_log_message('UpdateMembershipRecord.php'); | |
66 | } | |
67 | } | |
68 | ||
69 | function initialize() { | |
70 | require_once '../civicrm.config.php'; | |
71 | require_once 'CRM/Core/Config.php'; | |
72 | ||
73 | $config = CRM_Core_Config::singleton(); | |
74 | } | |
75 | ||
76 | public function updateMembershipStatus() { | |
77 | require_once 'CRM/Member/BAO/Membership.php'; | |
78 | CRM_Member_BAO_Membership::updateAllMembershipStatus(); | |
79 | } | |
80 | } | |
81 | ||
82 | $obj = new CRM_UpdateMembershipRecord(); | |
83 | ||
84 | echo "\n Updating "; | |
85 | $obj->updateMembershipStatus(); | |
86 | echo "\n\n Membership records updated. (Done) \n"; |