Merge pull request #6563 from colemanw/bin
authorcolemanw <coleman@civicrm.org>
Tue, 25 Aug 2015 17:07:25 +0000 (13:07 -0400)
committercolemanw <coleman@civicrm.org>
Tue, 25 Aug 2015 17:07:25 +0000 (13:07 -0400)
Remove deprecated files from /bin

13 files changed:
bin/cleanup42.php [deleted file]
bin/deprecated/CiviReportMail.php [deleted file]
bin/deprecated/EmailProcessor.php [deleted file]
bin/deprecated/ParticipantProcessor.php [deleted file]
bin/deprecated/RespondentProcessor.php [deleted file]
bin/deprecated/UpdateAddress.php [deleted file]
bin/deprecated/UpdateGreeting.php [deleted file]
bin/deprecated/UpdateMembershipRecord.php [deleted file]
bin/deprecated/UpdateMembershipReminderDate.php [deleted file]
bin/deprecated/UpdatePledgeRecord.php [deleted file]
bin/deprecated/action.cronjob.php [deleted file]
bin/deprecated/civimail.cronjob.php [deleted file]
bin/gitify [deleted file]

diff --git a/bin/cleanup42.php b/bin/cleanup42.php
deleted file mode 100644 (file)
index 75c51e0..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 4.7                                                |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2015                                |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM.                                    |
- |                                                                    |
- | CiviCRM is free software; you can copy, modify, and distribute it  |
- | under the terms of the GNU Affero General Public License           |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception.   |
- |                                                                    |
- | CiviCRM is distributed in the hope that it will be useful, but     |
- | WITHOUT ANY WARRANTY; without even the implied warranty of         |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.               |
- | See the GNU Affero General Public License for more details.        |
- |                                                                    |
- | You should have received a copy of the GNU Affero General Public   |
- | License and the CiviCRM Licensing Exception along                  |
- | with this program; if not, contact CiviCRM LLC                     |
- | at info[AT]civicrm[DOT]org. If you have questions about the        |
- | GNU Affero General Public License or the licensing of CiviCRM,     |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
- +--------------------------------------------------------------------+
- */
-
-/**
- * A PHP script which deletes extraneous civicrm_membership_payment rows
- * in order to correct the condition where a contribution row is linked to > 1 membership.
- */
-
-/**
- * Initialization
- */
-function initialize() {
-  session_start();
-  if (!function_exists('drush_get_context')) {
-    require_once '../civicrm.config.php';
-  }
-
-  // hack to make code think its an upgrade mode, and not do lot of initialization which breaks the code due to new 4.2 schema
-  $_GET['q'] = 'civicrm/upgrade/cleanup42';
-
-  require_once 'CRM/Core/Config.php';
-  $config = CRM_Core_Config::singleton();
-  if (php_sapi_name() != "cli") {
-    // this does not return on failure
-    CRM_Utils_System::authenticateScript(TRUE);
-  }
-}
-
-function run() {
-  initialize();
-
-  $fh = fopen('php://output', 'w');
-  $rows = CRM_Upgrade_Incremental_php_FourTwo::deleteInvalidPairs();
-
-  if (!empty($rows)) {
-    echo "The following records have been processed. If action = Un-linked, that membership has been disconnected from the contribution record.\n";
-    echo "Contact ID, ContributionID, Contribution Status, MembershipID, Membership Type, Start Date, End Date, Membership Status, Action \n";
-  }
-  else {
-    echo "Could not find any records to process.\n";
-  }
-
-  foreach ($rows as $row) {
-    fputcsv($fh, $row);
-  }
-}
-
-run();
diff --git a/bin/deprecated/CiviReportMail.php b/bin/deprecated/CiviReportMail.php
deleted file mode 100644 (file)
index a24287d..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 4.7                                                |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2015                                |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM.                                    |
- |                                                                    |
- | CiviCRM is free software; you can copy, modify, and distribute it  |
- | under the terms of the GNU Affero General Public License           |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception.   |
- |                                                                    |
- | CiviCRM is distributed in the hope that it will be useful, but     |
- | WITHOUT ANY WARRANTY; without even the implied warranty of         |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.               |
- | See the GNU Affero General Public License for more details.        |
- |                                                                    |
- | You should have received a copy of the GNU Affero General Public   |
- | License and the CiviCRM Licensing Exception along                  |
- | with this program; if not, contact CiviCRM LLC                     |
- | at info[AT]civicrm[DOT]org. If you have questions about the        |
- | GNU Affero General Public License or the licensing of CiviCRM,     |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
- +--------------------------------------------------------------------+
- */
-
-/**
- * A PHP cron script to mail the result set of specified report to the
- * recipients mentioned for that report
- */
-class CiviReportMail {
-  /**
-   */
-  public function __construct() {
-    $this->initialize();
-
-    CRM_Utils_System::authenticateScript(TRUE);
-
-    //log the execution of script
-    CRM_Core_Error::debug_log_message('CiviReportMail.php');
-  }
-
-  public function initialize() {
-    require_once '../civicrm.config.php';
-    require_once 'CRM/Core/Config.php';
-
-    $config = CRM_Core_Config::singleton();
-  }
-
-  public function run() {
-    $lock = Civi\Core\Container::singleton()->get('lockManager')->acquire('worker.report.CiviReportMail');
-
-    if ($lock->isAcquired()) {
-      // try to unset any time limits
-      if (!ini_get('safe_mode')) {
-        set_time_limit(0);
-      }
-
-      // if there are named sets of settings, use them - otherwise use the default (null)
-      require_once 'CRM/Report/Utils/Report.php';
-      $result = CRM_Report_Utils_Report::processReport();
-      echo $result['messages'];
-    }
-    else {
-      throw new Exception('Could not acquire lock, another CiviReportMail process is running');
-    }
-
-    $lock->release();
-  }
-
-}
-
-session_start();
-$obj = new CiviReportMail();
-$obj->run();
diff --git a/bin/deprecated/EmailProcessor.php b/bin/deprecated/EmailProcessor.php
deleted file mode 100644 (file)
index d1a91b9..0000000
+++ /dev/null
@@ -1,108 +0,0 @@
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 4.7                                                |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2015                                |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM.                                    |
- |                                                                    |
- | CiviCRM is free software; you can copy, modify, and distribute it  |
- | under the terms of the GNU Affero General Public License           |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception.   |
- |                                                                    |
- | CiviCRM is distributed in the hope that it will be useful, but     |
- | WITHOUT ANY WARRANTY; without even the implied warranty of         |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.               |
- | See the GNU Affero General Public License for more details.        |
- |                                                                    |
- | You should have received a copy of the GNU Affero General Public   |
- | License and the CiviCRM Licensing Exception along                  |
- | with this program; if not, contact CiviCRM LLC                     |
- | at info[AT]civicrm[DOT]org. If you have questions about the        |
- | GNU Affero General Public License or the licensing of CiviCRM,     |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
- +--------------------------------------------------------------------+
- */
-
-/**
- *
- * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
- */
-
-/**
- * When running script from cli :
- * 1. By default script is being used for civimail processing.
- * eg : nice -19 php bin/EmailProcessor.php -u<login> -p<password> -s<sites(or default)>
- *
- * 2. Pass "activities" as argument to use script for 'Email To Activity Processing'.
- * eg : nice -19 php bin/EmailProcessor.php -u<login> -p<password> -s<sites(or default)> activities
- *
- */
-
-// bootstrap the environment and run the processor
-// you can run this program either from an apache command, or from the cli
-if (php_sapi_name() == "cli") {
-  require_once "bin/cli.php";
-  $cli = new civicrm_cli();
-  //if it doesn't die, it's authenticated
-  //log the execution of script
-  CRM_Core_Error::debug_log_message('EmailProcessor.php from the cli');
-  $lock = Civi\Core\Container::singleton()->get('lockManager')->acquire('worker.mailing.EmailProcessor');
-
-  if (!$lock->isAcquired()) {
-    throw new Exception('Could not acquire lock, another EmailProcessor process is running');
-  }
-
-  require_once 'CRM/Utils/Mail/EmailProcessor.php';
-
-  // check if the script is being used for civimail processing or email to
-  // activity processing.
-  if (isset($cli->args[0]) && $cli->args[0] == "activities") {
-    CRM_Utils_Mail_EmailProcessor::processActivities();
-  }
-  else {
-    CRM_Utils_Mail_EmailProcessor::processBounces();
-  }
-  $lock->release();
-}
-else {
-  session_start();
-  require_once '../civicrm.config.php';
-  require_once 'CRM/Core/Config.php';
-  $config = CRM_Core_Config::singleton();
-  CRM_Utils_System::authenticateScript(TRUE);
-
-  require_once 'CRM/Utils/System.php';
-  CRM_Utils_System::loadBootStrap();
-
-  //log the execution of script
-  CRM_Core_Error::debug_log_message('EmailProcessor.php');
-
-  $lock = Civi\Core\Container::singleton()->get('lockManager')->acquire('worker.mailing.EmailProcessor');
-
-  if (!$lock->isAcquired()) {
-    throw new Exception('Could not acquire lock, another EmailProcessor process is running');
-  }
-
-  // try to unset any time limits
-  if (!ini_get('safe_mode')) {
-    set_time_limit(0);
-  }
-
-  require_once 'CRM/Utils/Mail/EmailProcessor.php';
-
-  // cleanup directories with old mail files (if they exist): CRM-4452
-  CRM_Utils_Mail_EmailProcessor::cleanupDir($config->customFileUploadDir . DIRECTORY_SEPARATOR . 'CiviMail.ignored');
-  CRM_Utils_Mail_EmailProcessor::cleanupDir($config->customFileUploadDir . DIRECTORY_SEPARATOR . 'CiviMail.processed');
-
-  // check if the script is being used for civimail processing or email to
-  // activity processing.
-  $isCiviMail = !empty($_REQUEST['emailtoactivity']) ? FALSE : TRUE;
-  CRM_Utils_Mail_EmailProcessor::process($isCiviMail);
-
-  $lock->release();
-}
diff --git a/bin/deprecated/ParticipantProcessor.php b/bin/deprecated/ParticipantProcessor.php
deleted file mode 100644 (file)
index aa4d014..0000000
+++ /dev/null
@@ -1,266 +0,0 @@
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 4.7                                                |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2015                                |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM.                                    |
- |                                                                    |
- | CiviCRM is free software; you can copy, modify, and distribute it  |
- | under the terms of the GNU Affero General Public License           |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception.   |
- |                                                                    |
- | CiviCRM is distributed in the hope that it will be useful, but     |
- | WITHOUT ANY WARRANTY; without even the implied warranty of         |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.               |
- | See the GNU Affero General Public License for more details.        |
- |                                                                    |
- | You should have received a copy of the GNU Affero General Public   |
- | License and the CiviCRM Licensing Exception along                  |
- | with this program; if not, contact CiviCRM LLC                     |
- | at info[AT]civicrm[DOT]org. If you have questions about the        |
- | GNU Affero General Public License or the licensing of CiviCRM,     |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
- +--------------------------------------------------------------------+
- */
-
-
-/*
- * This file check and updates the status of all participant records.
- *
- * EventParticipantion.php prior to running this script.
- */
-
-require_once '../civicrm.config.php';
-require_once 'CRM/Core/Config.php';
-
-/**
- * Class CRM_ParticipantProcessor
- */
-class CRM_ParticipantProcessor {
-  /**
-   */
-  public function __construct() {
-    $config = CRM_Core_Config::singleton();
-
-    //this does not return on failure
-    require_once 'CRM/Utils/System.php';
-    require_once 'CRM/Utils/Hook.php';
-
-    CRM_Utils_System::authenticateScript(TRUE);
-
-    //log the execution time of script
-    CRM_Core_Error::debug_log_message('ParticipantProcessor.php');
-  }
-
-  public function updateParticipantStatus() {
-    require_once 'CRM/Event/PseudoConstant.php';
-    $participantRole = CRM_Event_PseudoConstant::participantRole();
-    $pendingStatuses = CRM_Event_PseudoConstant::participantStatus(NULL, "class = 'Pending'");
-    $expiredStatuses = CRM_Event_PseudoConstant::participantStatus(NULL, "class = 'Negative'");
-    $waitingStatuses = CRM_Event_PseudoConstant::participantStatus(NULL, "class = 'Waiting'");
-
-    //build the required status ids.
-    $statusIds = '(' . implode(',', array_merge(array_keys($pendingStatuses), array_keys($waitingStatuses))) . ')';
-
-    $participantDetails = $fullEvents = array();
-    $expiredParticipantCount = $waitingConfirmCount = $waitingApprovalCount = 0;
-
-    //get all participant who's status in class pending and waiting
-    $query = "SELECT * FROM civicrm_participant WHERE status_id IN {$statusIds} ORDER BY register_date";
-
-    $query = "
-   SELECT  participant.id,
-           participant.contact_id,
-           participant.status_id,
-           participant.register_date,
-           participant.registered_by_id,
-           participant.event_id,
-           event.title as eventTitle,
-           event.registration_start_date,
-           event.registration_end_date,
-           event.end_date,
-           event.expiration_time,
-           event.requires_approval
-     FROM  civicrm_participant participant
-LEFT JOIN  civicrm_event event ON ( event.id = participant.event_id )
-    WHERE  participant.status_id IN {$statusIds}
-     AND   (event.end_date > now() OR event.end_date IS NULL)
-     AND   event.is_active = 1
- ORDER BY  participant.register_date, participant.id
-";
-    $dao = CRM_Core_DAO::executeQuery($query);
-    while ($dao->fetch()) {
-      $participantDetails[$dao->id] = array(
-        'id' => $dao->id,
-        'event_id' => $dao->event_id,
-        'status_id' => $dao->status_id,
-        'contact_id' => $dao->contact_id,
-        'register_date' => $dao->register_date,
-        'registered_by_id' => $dao->registered_by_id,
-        'eventTitle' => $dao->eventTitle,
-        'registration_start_date' => $dao->registration_start_date,
-        'registration_end_date' => $dao->registration_end_date,
-        'end_date' => $dao->end_date,
-        'expiration_time' => $dao->expiration_time,
-        'requires_approval' => $dao->requires_approval,
-      );
-    }
-
-    if (!empty($participantDetails)) {
-      //cron 1. move participant from pending to expire if needed
-      foreach ($participantDetails as $participantId => $values) {
-        //process the additional participant at the time of
-        //primary participant, don't process separately.
-        if (!empty($values['registered_by_id'])) {
-          continue;
-        }
-
-        $expirationTime = CRM_Utils_Array::value('expiration_time', $values);
-        if ($expirationTime && array_key_exists($values['status_id'], $pendingStatuses)) {
-
-          //get the expiration and registration pending time.
-          $expirationSeconds = $expirationTime * 3600;
-          $registrationPendingSeconds = CRM_Utils_Date::unixTime($values['register_date']);
-
-          // expired registration since registration cross allow confirmation time.
-          if (($expirationSeconds + $registrationPendingSeconds) < time()) {
-
-            //lets get the transaction mechanism.
-            require_once 'CRM/Core/Transaction.php';
-            $transaction = new CRM_Core_Transaction();
-
-            require_once 'CRM/Event/BAO/Participant.php';
-            $ids = array($participantId);
-            $expiredId = array_search('Expired', $expiredStatuses);
-            $results = CRM_Event_BAO_Participant::transitionParticipants($ids, $expiredId, $values['status_id'], TRUE, TRUE);
-            $transaction->commit();
-
-            if (!empty($results)) {
-              //diaplay updated participants
-              if (is_array($results['updatedParticipantIds']) && !empty($results['updatedParticipantIds'])) {
-                foreach ($results['updatedParticipantIds'] as $processedId) {
-                  $expiredParticipantCount += 1;
-                  echo "<br /><br />- status updated to: Expired";
-
-                  //mailed participants.
-                  if (is_array($results['mailedParticipants']) &&
-                    array_key_exists($processedId, $results['mailedParticipants'])
-                  ) {
-                    echo "<br />Expiration Mail sent to: {$results['mailedParticipants'][$processedId]}";
-                  }
-                }
-              }
-            }
-          }
-        }
-      }
-      //cron 1 end.
-
-      //cron 2. lets move participants from waiting list to pending status
-      foreach ($participantDetails as $participantId => $values) {
-        //process the additional participant at the time of
-        //primary participant, don't process separately.
-        if (!empty($values['registered_by_id'])) {
-          continue;
-        }
-
-        if (array_key_exists($values['status_id'], $waitingStatuses) &&
-          !array_key_exists($values['event_id'], $fullEvents)
-        ) {
-
-          if ($waitingStatuses[$values['status_id']] == 'On waitlist' &&
-            CRM_Event_BAO_Event::validRegistrationDate($values)
-          ) {
-
-            //check the target event having space.
-            require_once 'CRM/Event/BAO/Participant.php';
-            $eventOpenSpaces = CRM_Event_BAO_Participant::eventFull($values['event_id'], TRUE, FALSE);
-
-            if ($eventOpenSpaces && is_numeric($eventOpenSpaces) || ($eventOpenSpaces === NULL)) {
-
-              //get the additional participant if any.
-              $additionalIds = CRM_Event_BAO_Participant::getAdditionalParticipantIds($participantId);
-
-              $allIds = array($participantId);
-              if (!empty($additionalIds)) {
-                $allIds = array_merge($allIds, $additionalIds);
-              }
-              $pClause = ' participant.id IN ( ' . implode(' , ', $allIds) . ' )';
-              $requiredSpaces = CRM_Event_BAO_Event::eventTotalSeats($values['event_id'], $pClause);
-
-              //need to check as to see if event has enough speces
-              if (($requiredSpaces <= $eventOpenSpaces) || ($eventOpenSpaces === NULL)) {
-                require_once 'CRM/Core/Transaction.php';
-                $transaction = new CRM_Core_Transaction();
-
-                require_once 'CRM/Event/BAO/Participant.php';
-                $ids = array($participantId);
-                $updateStatusId = array_search('Pending from waitlist', $pendingStatuses);
-
-                //lets take a call to make pending or need approval
-                if ($values['requires_approval']) {
-                  $updateStatusId = array_search('Awaiting approval', $waitingStatuses);
-                }
-                $results = CRM_Event_BAO_Participant::transitionParticipants($ids, $updateStatusId,
-                  $values['status_id'], TRUE, TRUE
-                );
-                //commit the transaction.
-                $transaction->commit();
-
-                if (!empty($results)) {
-                  //diaplay updated participants
-                  if (is_array($results['updatedParticipantIds']) &&
-                    !empty($results['updatedParticipantIds'])
-                  ) {
-                    foreach ($results['updatedParticipantIds'] as $processedId) {
-                      if ($values['requires_approval']) {
-                        $waitingApprovalCount += 1;
-                        echo "<br /><br />- status updated to: Awaiting approval";
-                        echo "<br />Will send you Confirmation Mail when registration get approved.";
-                      }
-                      else {
-                        $waitingConfirmCount += 1;
-                        echo "<br /><br />- status updated to: Pending from waitlist";
-                        if (is_array($results['mailedParticipants']) &&
-                          array_key_exists($processedId, $results['mailedParticipants'])
-                        ) {
-                          echo "<br />Confirmation Mail sent to: {$results['mailedParticipants'][$processedId]}";
-                        }
-                      }
-                    }
-                  }
-                }
-              }
-              else {
-                //target event is full.
-                $fullEvents[$values['event_id']] = $values['eventTitle'];
-              }
-            }
-            else {
-              //target event is full.
-              $fullEvents[$values['event_id']] = $values['eventTitle'];
-            }
-          }
-        }
-      }
-      //cron 2 ends.
-    }
-
-    echo "<br /><br />Number of Expired registration(s) = {$expiredParticipantCount}";
-    echo "<br />Number of registration(s) require approval =  {$waitingApprovalCount}";
-    echo "<br />Number of registration changed to Pending from waitlist = {$waitingConfirmCount}<br /><br />";
-    if (!empty($fullEvents)) {
-      foreach ($fullEvents as $eventId => $title) {
-        echo "Full Event : {$title}<br />";
-      }
-    }
-  }
-
-}
-
-$obj = new CRM_ParticipantProcessor();
-echo "Updating..";
-$obj->updateParticipantStatus();
-echo "<br />Participant records updated. (Done)";
diff --git a/bin/deprecated/RespondentProcessor.php b/bin/deprecated/RespondentProcessor.php
deleted file mode 100644 (file)
index 3807b9b..0000000
+++ /dev/null
@@ -1,110 +0,0 @@
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 4.7                                                |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2015                                |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM.                                    |
- |                                                                    |
- | CiviCRM is free software; you can copy, modify, and distribute it  |
- | under the terms of the GNU Affero General Public License           |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception.   |
- |                                                                    |
- | CiviCRM is distributed in the hope that it will be useful, but     |
- | WITHOUT ANY WARRANTY; without even the implied warranty of         |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.               |
- | See the GNU Affero General Public License for more details.        |
- |                                                                    |
- | You should have received a copy of the GNU Affero General Public   |
- | License and the CiviCRM Licensing Exception along                  |
- | with this program; if not, contact CiviCRM LLC                     |
- | at info[AT]civicrm[DOT]org. If you have questions about the        |
- | GNU Affero General Public License or the licensing of CiviCRM,     |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
- +--------------------------------------------------------------------+
- */
-
-
-/*
- * This file check and update the survey respondents.
- *
- */
-
-require_once '../civicrm.config.php';
-require_once 'CRM/Core/Config.php';
-
-/**
- * Class CRM_RespondentProcessor
- */
-class CRM_RespondentProcessor {
-  /**
-   */
-  public function __construct() {
-    $config = CRM_Core_Config::singleton();
-
-    //this does not return on failure
-    require_once 'CRM/Utils/System.php';
-    require_once 'CRM/Utils/Hook.php';
-
-    CRM_Utils_System::authenticateScript(TRUE);
-
-    //log the execution time of script
-    CRM_Core_Error::debug_log_message('RespondentProcessor.php');
-  }
-
-  public function releaseRespondent() {
-    require_once 'CRM/Core/PseudoConstant.php';
-    require_once 'CRM/Campaign/BAO/Survey.php';
-    $activityStatus = CRM_Core_PseudoConstant::activityStatus('name');
-    $reserveStatusId = array_search('Scheduled', $activityStatus);
-    $surveyActivityTypes = CRM_Campaign_BAO_Survey::getSurveyActivityType();
-    $surveyActivityTypesIds = array_keys($surveyActivityTypes);
-
-    //retrieve all survey activities related to reserve action.
-    $releasedCount = 0;
-    if ($reserveStatusId && !empty($surveyActivityTypesIds)) {
-      $query = '
-    SELECT  activity.id as id,
-            activity.activity_date_time as activity_date_time,
-            survey.id as surveyId,
-            survey.release_frequency as release_frequency
-      FROM  civicrm_activity activity
-INNER JOIN  civicrm_survey survey ON ( survey.id = activity.source_record_id )
-     WHERE  activity.is_deleted = 0
-       AND  activity.status_id = %1
-       AND  activity.activity_type_id IN ( ' . implode(', ', $surveyActivityTypesIds) . ' )';
-      $activity = CRM_Core_DAO::executeQuery($query, array(1 => array($reserveStatusId, 'Positive')));
-      $releasedIds = array();
-      while ($activity->fetch()) {
-        if (!$activity->release_frequency) {
-          continue;
-        }
-        $reservedSeconds = CRM_Utils_Date::unixTime($activity->activity_date_time);
-        $releasedSeconds = $activity->release_frequency * 24 * 3600;
-        $totalReservedSeconds = $reservedSeconds + $releasedSeconds;
-        if ($totalReservedSeconds < time()) {
-          $releasedIds[$activity->id] = $activity->id;
-        }
-      }
-
-      //released respondent.
-      if (!empty($releasedIds)) {
-        $query = '
-UPDATE  civicrm_activity
-   SET  is_deleted = 1
- WHERE  id IN ( ' . implode(', ', $releasedIds) . ' )';
-        CRM_Core_DAO::executeQuery($query);
-        $releasedCount = count($releasedIds);
-      }
-    }
-
-    echo "<br /><br />Number of respondents released = {$releasedCount}";
-  }
-
-}
-
-$obj = new CRM_RespondentProcessor();
-echo "Releasing..";
-$obj->releaseRespondent();
-echo "<br /><br />Respondent Release Done";
diff --git a/bin/deprecated/UpdateAddress.php b/bin/deprecated/UpdateAddress.php
deleted file mode 100644 (file)
index 4124ac3..0000000
+++ /dev/null
@@ -1,278 +0,0 @@
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 4.7                                                |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2015                                |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM.                                    |
- |                                                                    |
- | CiviCRM is free software; you can copy, modify, and distribute it  |
- | under the terms of the GNU Affero General Public License           |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception.   |
- |                                                                    |
- | CiviCRM is distributed in the hope that it will be useful, but     |
- | WITHOUT ANY WARRANTY; without even the implied warranty of         |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.               |
- | See the GNU Affero General Public License for more details.        |
- |                                                                    |
- | You should have received a copy of the GNU Affero General Public   |
- | License and the CiviCRM Licensing Exception along                  |
- | with this program; if not, contact CiviCRM LLC                     |
- | at info[AT]civicrm[DOT]org. If you have questions about the        |
- | GNU Affero General Public License or the licensing of CiviCRM,     |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
- +--------------------------------------------------------------------+
- */
-
-/**
- * A PHP cron script to format all the addresses in the database. Currently
- * it only does geocoding if the geocode values are not set. At a later
- * stage we will also handle USPS address cleanup and other formatting
- * issues
- *
- */
-
-define('THROTTLE_REQUESTS', 0);
-function run() {
-  session_start();
-
-  require_once '../civicrm.config.php';
-  require_once 'CRM/Core/Config.php';
-
-  $config = CRM_Core_Config::singleton();
-
-  require_once 'Console/Getopt.php';
-  $shortOptions = "n:p:s:e:k:g:parse";
-  $longOptions = array('name=', 'pass=', 'key=', 'start=', 'end=', 'geocoding=', 'parse=');
-
-  $getopt = new Console_Getopt();
-  $args = $getopt->readPHPArgv();
-
-  array_shift($args);
-  list($valid, $dontCare) = $getopt->getopt2($args, $shortOptions, $longOptions);
-
-  $vars = array(
-    'start' => 's',
-    'end' => 'e',
-    'name' => 'n',
-    'pass' => 'p',
-    'key' => 'k',
-    'geocoding' => 'g',
-    'parse' => 'ap',
-  );
-
-  foreach ($vars as $var => $short) {
-    $$var = NULL;
-    foreach ($valid as $v) {
-      if ($v[0] == $short || $v[0] == "--$var") {
-        $$var = $v[1];
-        break;
-      }
-    }
-    if (!$$var) {
-      $$var = CRM_Utils_Array::value($var, $_REQUEST);
-    }
-    $_REQUEST[$var] = $$var;
-  }
-
-  // this does not return on failure
-  // require_once 'CRM/Utils/System.php';
-  CRM_Utils_System::authenticateScript(TRUE, $name, $pass);
-
-  //log the execution of script
-  CRM_Core_Error::debug_log_message('UpdateAddress.php');
-
-  // do check for geocoding.
-  $processGeocode = FALSE;
-  if (empty($config->geocodeMethod)) {
-    if ($geocoding == 'true') {
-      echo ts('Error: You need to set a mapping provider under Global Settings');
-      exit();
-    }
-  }
-  else {
-    $processGeocode = TRUE;
-    // user might want to over-ride.
-    if ($geocoding == 'false') {
-      $processGeocode = FALSE;
-    }
-  }
-
-  // do check for parse street address.
-  require_once 'CRM/Core/BAO/Setting.php';
-  $parseAddress = CRM_Utils_Array::value('street_address_parsing',
-    CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
-      'address_options'
-    ),
-    FALSE
-  );
-  $parseStreetAddress = FALSE;
-  if (!$parseAddress) {
-    if ($parse == 'true') {
-      echo ts('Error: You need to enable Street Address Parsing under Global Settings >> Address Settings.');
-      exit();
-    }
-  }
-  else {
-    $parseStreetAddress = TRUE;
-    // user might want to over-ride.
-    if ($parse == 'false') {
-      $parseStreetAddress = FALSE;
-    }
-  }
-
-  // don't process.
-  if (!$parseStreetAddress && !$processGeocode) {
-    echo ts('Error: Both Geocode mapping as well as Street Address Parsing are disabled. You must configure one or both options to use this script.');
-    exit();
-  }
-
-  // we have an exclusive lock - run the mail queue
-  processContacts($config, $processGeocode, $parseStreetAddress, $start, $end);
-}
-
-/**
- * @param $config
- * @param $processGeocode
- * @param $parseStreetAddress
- * @param null $start
- * @param null $end
- */
-function processContacts(&$config, $processGeocode, $parseStreetAddress, $start = NULL, $end = NULL) {
-  // build where clause.
-  $clause = array('( c.id = a.contact_id )');
-  if ($start) {
-    $clause[] = "( c.id >= $start )";
-  }
-  if ($end) {
-    $clause[] = "( c.id <= $end )";
-  }
-  if ($processGeocode) {
-    $clause[] = '( a.geo_code_1 is null OR a.geo_code_1 = 0 )';
-    $clause[] = '( a.geo_code_2 is null OR a.geo_code_2 = 0 )';
-    $clause[] = '( a.country_id is not null )';
-  }
-  $whereClause = implode(' AND ', $clause);
-
-  $query = "
-SELECT     c.id,
-           a.id as address_id,
-           a.street_address,
-           a.city,
-           a.postal_code,
-           s.name as state,
-           o.name as country
-FROM       civicrm_contact  c
-INNER JOIN civicrm_address        a ON a.contact_id = c.id
-LEFT  JOIN civicrm_country        o ON a.country_id = o.id
-LEFT  JOIN civicrm_state_province s ON a.state_province_id = s.id
-WHERE      {$whereClause}
-  ORDER BY a.id
-";
-
-  $totalGeocoded = $totalAddresses = $totalAddressParsed = 0;
-
-  $dao = CRM_Core_DAO::executeQuery($query, CRM_Core_DAO::$_nullArray);
-
-  if ($processGeocode) {
-    require_once str_replace('_', DIRECTORY_SEPARATOR, $config->geocodeMethod) . '.php';
-  }
-
-  require_once 'CRM/Core/DAO/Address.php';
-  require_once 'CRM/Core/BAO/Address.php';
-
-  $unparseableContactAddress = array();
-  while ($dao->fetch()) {
-    $totalAddresses++;
-    $params = array(
-      'street_address' => $dao->street_address,
-      'postal_code' => $dao->postal_code,
-      'city' => $dao->city,
-      'state_province' => $dao->state,
-      'country' => $dao->country,
-    );
-
-    $addressParams = array();
-
-    // process geocode.
-    if ($processGeocode) {
-      // loop through the address removing more information
-      // so we can get some geocode for a partial address
-      // i.e. city -> state -> country
-
-      $maxTries = 5;
-      do {
-        if (defined('THROTTLE_REQUESTS') &&
-          THROTTLE_REQUESTS
-        ) {
-          usleep(50000);
-        }
-
-        eval($config->geocodeMethod . '::format( $params, true );');
-        array_shift($params);
-        $maxTries--;
-      } while ((!isset($params['geo_code_1'])) &&
-        ($maxTries > 1)
-      );
-
-      if (isset($params['geo_code_1']) &&
-        $params['geo_code_1'] != 'null'
-      ) {
-        $totalGeocoded++;
-        $addressParams['geo_code_1'] = $params['geo_code_1'];
-        $addressParams['geo_code_2'] = $params['geo_code_2'];
-      }
-    }
-
-    // parse street address
-    if ($parseStreetAddress) {
-      $parsedFields = CRM_Core_BAO_Address::parseStreetAddress($dao->street_address);
-      $success = TRUE;
-      // consider address is automatically parseable,
-      // when we should found street_number and street_name
-      if (empty($parsedFields['street_name']) || empty($parsedFields['street_number'])) {
-        $success = FALSE;
-      }
-
-      // do check for all elements.
-      if ($success) {
-        $totalAddressParsed++;
-      }
-      elseif ($dao->street_address) {
-        //build contact edit url,
-        //so that user can manually fill the street address fields if the street address is not parsed, CRM-5886
-        $url = CRM_Utils_System::url('civicrm/contact/add', "reset=1&action=update&cid={$dao->id}");
-        $unparseableContactAddress[] = " Contact ID: " . $dao->id . " <a href =\"$url\"> " . $dao->street_address . " </a> ";
-        // reset element values.
-        $parsedFields = array_fill_keys(array_keys($parsedFields), '');
-      }
-      $addressParams = array_merge($addressParams, $parsedFields);
-    }
-
-    // finally update address object.
-    if (!empty($addressParams)) {
-      $address = new CRM_Core_DAO_Address();
-      $address->id = $dao->address_id;
-      $address->copyValues($addressParams);
-      $address->save();
-      $address->free();
-    }
-  }
-
-  echo ts("Addresses Evaluated: $totalAddresses\n");
-  if ($processGeocode) {
-    echo ts("Addresses Geocoded : $totalGeocoded\n");
-  }
-  if ($parseStreetAddress) {
-    echo ts("Street Address Parsed : $totalAddressParsed\n");
-    if ($unparseableContactAddress) {
-      echo ts("<br />\nFollowing is the list of contacts whose address is not parsed :<br />\n");
-      foreach ($unparseableContactAddress as $contactLink) {
-        echo ts("%1<br />\n", array(1 => $contactLink));
-      }
-    }
-  }
-}
-
-run();
diff --git a/bin/deprecated/UpdateGreeting.php b/bin/deprecated/UpdateGreeting.php
deleted file mode 100644 (file)
index c1cf1ae..0000000
+++ /dev/null
@@ -1,246 +0,0 @@
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 4.7                                               |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2015                                |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM.                                    |
- |                                                                    |
- | CiviCRM is free software; you can copy, modify, and distribute it  |
- | under the terms of the GNU Affero General Public License           |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception.   |
- |                                                                    |
- | CiviCRM is distributed in the hope that it will be useful, but     |
- | WITHOUT ANY WARRANTY; without even the implied warranty of         |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.               |
- | See the GNU Affero General Public License for more details.        |
- |                                                                    |
- | You should have received a copy of the GNU Affero General Public   |
- | License and the CiviCRM Licensing Exception along                  |
- | with this program; if not, contact CiviCRM LLC                     |
- | at info[AT]civicrm[DOT]org. If you have questions about the        |
- | GNU Affero General Public License or the licensing of CiviCRM,     |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
- +--------------------------------------------------------------------+
- */
-
-
-/*
- * Using this script you can update Email Greetings, Postal Greetings and Addressee for a specific contact type
- *
- * params for this script
- * ct=Individual or ct=Household or ct=Organization (ct = contact type)
- * gt=email_greeting or gt=postal_greeting or gt=addressee (gt = greeting )
- * id=greeting option value
- *
- * IMPORTANT: You must first create valid option value before using via admin interface.
- * Check option lists for Email Greetings, Postal Greetings and Addressee
- */
-
-/**
- * Class CRM_UpdateGreeting
- */
-class CRM_UpdateGreeting {
-  /**
-   */
-  public function __construct() {
-    $this->initialize();
-
-    $config = CRM_Core_Config::singleton();
-
-    require_once 'CRM/Utils/Request.php';
-    require_once 'CRM/Core/PseudoConstant.php';
-    require_once 'CRM/Contact/BAO/Contact.php';
-
-    // this does not return on failure
-    CRM_Utils_System::authenticateScript(TRUE);
-
-    //log the execution time of script
-    CRM_Core_Error::debug_log_message('UpdateGreeting.php');
-  }
-
-  public function initialize() {
-    require_once '../../civicrm.config.php';
-    require_once 'CRM/Core/Config.php';
-  }
-
-  public function updateGreeting() {
-    $config = CRM_Core_Config::singleton();
-    $contactType = CRM_Utils_Request::retrieve('ct', 'String', CRM_Core_DAO::$_nullArray, FALSE, NULL, 'REQUEST');
-    if (!in_array($contactType,
-      array('Individual', 'Household', 'Organization')
-    )
-    ) {
-      CRM_Core_Error::fatal(ts('Invalid Contact Type.'));
-    }
-
-    $greeting = CRM_Utils_Request::retrieve('gt', 'String', CRM_Core_DAO::$_nullArray, FALSE, NULL, 'REQUEST');
-    if (!in_array($greeting,
-      array('email_greeting', 'postal_greeting', 'addressee')
-    )
-    ) {
-      CRM_Core_Error::fatal(ts('Invalid Greeting Type.'));
-    }
-
-    if (in_array($greeting, array(
-        'email_greeting',
-        'postal_greeting',
-      )) && $contactType == 'Organization'
-    ) {
-      CRM_Core_Error::fatal(ts('You cannot use %1 for contact type %2.', array(1 => $greeting, 2 => $contactType)));
-    }
-
-    $valueID = $id = CRM_Utils_Request::retrieve('id', 'Positive', CRM_Core_DAO::$_nullArray, FALSE, NULL, 'REQUEST');
-
-    // if valueID is not passed use default value
-    if (!$valueID) {
-      require_once 'CRM/Core/OptionGroup.php';
-      $contactTypeFilters = array(1 => 'Individual', 2 => 'Household', 3 => 'Organization');
-      $filter = CRM_Utils_Array::key($contactType, $contactTypeFilters);
-      $defaulValueID = CRM_Core_OptionGroup::values($greeting, NULL, NULL, NULL,
-        " AND is_default = 1 AND ( filter = {$filter} OR filter = 0 )",
-        "value"
-      );
-      $valueID = array_pop($defaulValueID);
-    }
-
-    $filter = array(
-      'contact_type' => $contactType,
-      'greeting_type' => $greeting,
-    );
-
-    $allGreetings = CRM_Core_PseudoConstant::greeting($filter);
-    $originalGreetingString = $greetingString = CRM_Utils_Array::value($valueID, $allGreetings);
-    if (!$greetingString) {
-      CRM_Core_Error::fatal(ts('Incorrect greeting value id %1.', array(1 => $valueID)));
-    }
-
-    // build return properties based on tokens
-    require_once 'CRM/Utils/Token.php';
-    $greetingTokens = CRM_Utils_Token::getTokens($greetingString);
-    $tokens = CRM_Utils_Array::value('contact', $greetingTokens);
-    $greetingsReturnProperties = array();
-    if (is_array($tokens)) {
-      $greetingsReturnProperties = array_fill_keys(array_values($tokens), 1);
-    }
-
-    //process all contacts only when force pass.
-    $force = CRM_Utils_Request::retrieve('force', 'String', CRM_Core_DAO::$_nullArray, FALSE, NULL, 'REQUEST');
-    $processAll = $processOnlyIdSet = FALSE;
-    if (in_array($force, array(
-      1,
-      'true',
-    ))) {
-      $processAll = TRUE;
-    }
-    elseif ($force == 2) {
-      $processOnlyIdSet = TRUE;
-    }
-
-    //FIXME : apiQuery should handle these clause.
-    $filterContactFldIds = $filterIds = array();
-    if (!$processAll) {
-      $idFldName = $displayFldName = NULL;
-      if ($greeting == 'email_greeting' || $greeting == 'postal_greeting' || $greeting == 'addressee') {
-        $idFldName = $greeting . '_id';
-        $displayFldName = $greeting . '_display';
-      }
-
-      if ($idFldName) {
-        $sql = "
-SELECT DISTINCT id, $idFldName
-  FROM civicrm_contact
- WHERE contact_type = %1
-   AND ( {$idFldName} IS NULL OR
-         ( {$idFldName} IS NOT NULL AND {$displayFldName} IS NULL ) )
-   ";
-        $dao = CRM_Core_DAO::executeQuery($sql, array(1 => array($contactType, 'String')));
-        while ($dao->fetch()) {
-          $filterContactFldIds[$dao->id] = $dao->$idFldName;
-
-          if (!CRM_Utils_System::isNull($dao->$idFldName)) {
-            $filterIds[$dao->id] = $dao->$idFldName;
-          }
-        }
-      }
-      if (empty($filterContactFldIds)) {
-        $filterContactFldIds[] = 0;
-      }
-    }
-
-    if (empty($filterContactFldIds)) {
-      return;
-    }
-
-    // retrieve only required contact information
-    require_once 'CRM/Utils/Token.php';
-    $extraParams[] = array('contact_type', '=', $contactType, 0, 0);
-    // we do token replacement in the replaceGreetingTokens hook
-    list($greetingDetails) = CRM_Utils_Token::getTokenDetails(array_keys($filterContactFldIds),
-      $greetingsReturnProperties,
-      FALSE, FALSE, $extraParams
-    );
-    // perform token replacement and build update SQL
-    $contactIds = array();
-    $cacheFieldQuery = "UPDATE civicrm_contact SET {$greeting}_display = CASE id ";
-    foreach ($greetingDetails as $contactID => $contactDetails) {
-      if (!$processAll &&
-        !array_key_exists($contactID, $filterContactFldIds)
-      ) {
-        continue;
-      }
-
-      if ($processOnlyIdSet) {
-        if (!array_key_exists($contactID, $filterIds)) {
-          continue;
-        }
-        if ($id) {
-          $greetingString = $originalGreetingString;
-          $contactIds[] = $contactID;
-        }
-        else {
-          if ($greetingBuffer = CRM_Utils_Array::value($filterContactFldIds[$contactID], $allGreetings)) {
-            $greetingString = $greetingBuffer;
-          }
-        }
-        $allContactIds[] = $contactID;
-      }
-      else {
-        $greetingString = $originalGreetingString;
-        if ($greetingBuffer = CRM_Utils_Array::value($filterContactFldIds[$contactID], $allGreetings)) {
-          $greetingString = $greetingBuffer;
-        }
-        else {
-          $contactIds[] = $contactID;
-        }
-      }
-      CRM_Contact_BAO_Contact_Utils::processGreetingTemplate($greetingString, $contactDetails, $contactID, 'CRM_UpdateGreeting');
-      $greetingString = CRM_Core_DAO::escapeString($greetingString);
-      $cacheFieldQuery .= " WHEN {$contactID} THEN '{$greetingString}' ";
-
-      $allContactIds[] = $contactID;
-    }
-
-    if (!empty($allContactIds)) {
-      $cacheFieldQuery .= " ELSE {$greeting}_display
-                              END;";
-      if (!empty($contactIds)) {
-        // need to update greeting _id field.
-        $queryString = "
-UPDATE civicrm_contact
-   SET {$greeting}_id = {$valueID}
- WHERE id IN (" . implode(',', $contactIds) . ")";
-        CRM_Core_DAO::executeQuery($queryString);
-      }
-
-      // now update cache field
-      CRM_Core_DAO::executeQuery($cacheFieldQuery);
-    }
-  }
-
-}
-
-$obj = new CRM_UpdateGreeting();
-$obj->updateGreeting();
-echo "\n\n Greeting is updated for contact(s). (Done) \n";
diff --git a/bin/deprecated/UpdateMembershipRecord.php b/bin/deprecated/UpdateMembershipRecord.php
deleted file mode 100644 (file)
index 3919bc8..0000000
+++ /dev/null
@@ -1,87 +0,0 @@
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 4.7                                               |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2015                                |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM.                                    |
- |                                                                    |
- | CiviCRM is free software; you can copy, modify, and distribute it  |
- | under the terms of the GNU Affero General Public License           |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception.   |
- |                                                                    |
- | CiviCRM is distributed in the hope that it will be useful, but     |
- | WITHOUT ANY WARRANTY; without even the implied warranty of         |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.               |
- | See the GNU Affero General Public License for more details.        |
- |                                                                    |
- | You should have received a copy of the GNU Affero General Public   |
- | License and the CiviCRM Licensing Exception along                  |
- | with this program; if not, contact CiviCRM LLC                     |
- | at info[AT]civicrm[DOT]org. If you have questions about the        |
- | GNU Affero General Public License or the licensing of CiviCRM,     |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
- +--------------------------------------------------------------------+
- */
-
-
-/*
- * This file checks and updates the status of all membership records for a given domain using the calc_membership_status and
- * update_contact_membership APIs.
- * It takes the first argument as the domain-id if specified, otherwise takes the domain-id as 1.
- *
- * IMPORTANT:
- * We are using the default Domain FROM Name and FROM Email Address as the From email address for emails sent by this script.
- * Verify that this value has been properly set from Administer > Configure > Domain Information
- * If you want to use some other FROM email address, modify line 125 and set your valid email address.
- *
- * Save the file as UpdateMembershipRecord.php prior to running this script.
- */
-
-/**
- * Class CRM_UpdateMembershipRecord
- */
-class CRM_UpdateMembershipRecord {
-  /**
-   */
-  public function __construct() {
-    // you can run this program either from an apache command, or from the cli
-    if (php_sapi_name() == "cli") {
-      require_once "cli.php";
-      $cli = new civicrm_cli();
-      //if it doesn't die, it's authenticated
-    }
-    else {
-      //from the webserver
-      $this->initialize();
-
-      $config = CRM_Core_Config::singleton();
-
-      // this does not return on failure
-      CRM_Utils_System::authenticateScript(TRUE);
-
-      //log the execution time of script
-      CRM_Core_Error::debug_log_message('UpdateMembershipRecord.php');
-    }
-  }
-
-  public function initialize() {
-    require_once '../civicrm.config.php';
-    require_once 'CRM/Core/Config.php';
-
-    $config = CRM_Core_Config::singleton();
-  }
-
-  public function updateMembershipStatus() {
-    require_once 'CRM/Member/BAO/Membership.php';
-    CRM_Member_BAO_Membership::updateAllMembershipStatus();
-  }
-
-}
-
-$obj = new CRM_UpdateMembershipRecord();
-
-echo "\n Updating ";
-$obj->updateMembershipStatus();
-echo "\n\n Membership records updated. (Done) \n";
diff --git a/bin/deprecated/UpdateMembershipReminderDate.php b/bin/deprecated/UpdateMembershipReminderDate.php
deleted file mode 100644 (file)
index 710459f..0000000
+++ /dev/null
@@ -1,116 +0,0 @@
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 4.7                                                |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2015                                |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM.                                    |
- |                                                                    |
- | CiviCRM is free software; you can copy, modify, and distribute it  |
- | under the terms of the GNU Affero General Public License           |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception.   |
- |                                                                    |
- | CiviCRM is distributed in the hope that it will be useful, but     |
- | WITHOUT ANY WARRANTY; without even the implied warranty of         |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.               |
- | See the GNU Affero General Public License for more details.        |
- |                                                                    |
- | You should have received a copy of the GNU Affero General Public   |
- | License and the CiviCRM Licensing Exception along                  |
- | with this program; if not, contact CiviCRM LLC                     |
- | at info[AT]civicrm[DOT]org. If you have questions about the        |
- | GNU Affero General Public License or the licensing of CiviCRM,     |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
- +--------------------------------------------------------------------+
- */
-
-
-/*
- * This file updates the Reminder dates of all valid membership records.
- *
- */
-
-/**
- * Class CRM_UpdateMembershipReminderDate
- */
-class CRM_UpdateMembershipReminderDate {
-  /**
-   */
-  public function __construct() {
-    // you can run this program either from an apache command, or from the cli
-    if (php_sapi_name() == "cli") {
-      require_once "cli.php";
-      $cli = new civicrm_cli();
-      //if it doesn't die, it's authenticated
-    }
-    else {
-      //from the webserver
-      $this->initialize();
-
-      $config = CRM_Core_Config::singleton();
-
-      // this does not return on failure
-      CRM_Utils_System::authenticateScript(TRUE);
-
-      //log the execution time of script
-      CRM_Core_Error::debug_log_message('UpdateMembershipReminderDate.php');
-    }
-  }
-
-  public function initialize() {
-    require_once '../civicrm.config.php';
-    require_once 'CRM/Core/Config.php';
-
-    $config = CRM_Core_Config::singleton();
-  }
-
-  public function updateMembershipReminderDate() {
-    require_once 'CRM/Member/PseudoConstant.php';
-
-    //get all active statuses of membership.
-    $allStatuses = CRM_Member_PseudoConstant::membershipStatus();
-
-    //set membership reminder date if membership
-    //record has one of the following status.
-    $validStatus = array('New', 'Current', 'Grace');
-
-    $statusIds = array();
-    foreach ($validStatus as $status) {
-      $statusId = array_search($status, $allStatuses);
-      if ($statusId) {
-        $statusIds[$statusId] = $statusId;
-      }
-    }
-
-    //we don't have valid status to check,
-    //therefore no need to proceed further.
-    if (empty($statusIds)) {
-      return;
-    }
-
-    //set reminder date for all memberships,
-    //in case reminder date is missing and
-    //membership type has reminder day set.
-
-    $query = '
-    UPDATE  civicrm_membership membership
-INNER JOIN  civicrm_contact contact ON ( contact.id = membership.contact_id )
-INNER JOIN  civicrm_membership_type type ON ( type.id = membership.membership_type_id )
-       SET  membership.reminder_date = DATE_SUB( membership.end_date, INTERVAL type.renewal_reminder_day + 1 DAY )
-     WHERE  membership.reminder_date IS NULL
-       AND  contact.is_deleted = 0
-       AND  ( contact.is_deceased IS NULL OR contact.is_deceased = 0 )
-       AND  type.renewal_reminder_day IS NOT NULL
-       AND  membership.status_id IN ( ' . implode(' , ', $statusIds) . ' )';
-
-    CRM_Core_DAO::executeQuery($query);
-  }
-
-}
-
-$reminderDate = new CRM_UpdateMembershipReminderDate();
-
-echo "\n Updating... ";
-$reminderDate->updateMembershipReminderDate();
-echo "\n\n Membership(s) reminder date updated. (Done) \n";
diff --git a/bin/deprecated/UpdatePledgeRecord.php b/bin/deprecated/UpdatePledgeRecord.php
deleted file mode 100644 (file)
index 2e1bcb7..0000000
+++ /dev/null
@@ -1,310 +0,0 @@
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 4.7                                                |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2015                                |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM.                                    |
- |                                                                    |
- | CiviCRM is free software; you can copy, modify, and distribute it  |
- | under the terms of the GNU Affero General Public License           |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception.   |
- |                                                                    |
- | CiviCRM is distributed in the hope that it will be useful, but     |
- | WITHOUT ANY WARRANTY; without even the implied warranty of         |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.               |
- | See the GNU Affero General Public License for more details.        |
- |                                                                    |
- | You should have received a copy of the GNU Affero General Public   |
- | License and the CiviCRM Licensing Exception along                  |
- | with this program; if not, contact CiviCRM LLC                     |
- | at info[AT]civicrm[DOT]org. If you have questions about the        |
- | GNU Affero General Public License or the licensing of CiviCRM,     |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
- +--------------------------------------------------------------------+
- */
-
-
-/*
- * This file checks and updates the status of all pledge records for a
- * given domain using the updatePledgePaymentStatus.
- *
- * UpdatePledgeRecord.php prior to running this script.
- */
-
-require_once '../civicrm.config.php';
-require_once 'CRM/Core/Config.php';
-
-/**
- * Class CRM_UpdatePledgeRecord
- */
-class CRM_UpdatePledgeRecord {
-  /**
-   */
-  public function __construct() {
-    $config = CRM_Core_Config::singleton();
-    // this does not return on failure
-    require_once 'CRM/Utils/System.php';
-    require_once 'CRM/Utils/Hook.php';
-
-    CRM_Utils_System::authenticateScript(TRUE);
-    $config->cleanURL = 1;
-
-    //log the execution time of script
-    CRM_Core_Error::debug_log_message('UpdatePledgeRecord.php');
-  }
-
-  /**
-   * @param bool $sendReminders
-   *
-   * @throws Exception
-   */
-  public function updatePledgeStatus($sendReminders = FALSE) {
-
-    // *** Uncomment the next line if you want automated reminders to be sent
-    // $sendReminders = true;
-
-    require_once 'CRM/Contribute/PseudoConstant.php';
-    $allStatus = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
-
-    //unset statues that we never use for pledges
-    foreach (array(
-               'Completed',
-               'Cancelled',
-               'Failed',
-             ) as $statusKey) {
-      if ($key = CRM_Utils_Array::key($statusKey, $allStatus)) {
-        unset($allStatus[$key]);
-      }
-    }
-
-    $statusIds = implode(',', array_keys($allStatus));
-    $updateCnt = 0;
-
-    $query = "
-SELECT  pledge.contact_id              as contact_id,
-        pledge.id                      as pledge_id,
-        pledge.amount                  as amount,
-        payment.scheduled_date         as scheduled_date,
-        pledge.create_date             as create_date,
-        payment.id                     as payment_id,
-        pledge.contribution_page_id    as contribution_page_id,
-        payment.reminder_count         as reminder_count,
-        pledge.max_reminders           as max_reminders,
-        payment.reminder_date          as reminder_date,
-        pledge.initial_reminder_day    as initial_reminder_day,
-        pledge.additional_reminder_day as additional_reminder_day,
-        pledge.status_id               as pledge_status,
-        payment.status_id              as payment_status,
-        pledge.is_test                 as is_test,
-        pledge.campaign_id             as campaign_id,
-        SUM(payment.scheduled_amount)  as amount_due,
-        ( SELECT sum(civicrm_pledge_payment.actual_amount)
-        FROM civicrm_pledge_payment
-        WHERE civicrm_pledge_payment.status_id = 1
-        AND  civicrm_pledge_payment.pledge_id = pledge.id
-        ) as amount_paid
-        FROM      civicrm_pledge pledge, civicrm_pledge_payment payment
-        WHERE     pledge.id = payment.pledge_id
-        AND     payment.status_id IN ( {$statusIds} ) AND pledge.status_id IN ( {$statusIds} )
-        GROUP By  payment.id
-        ";
-
-    $dao = CRM_Core_DAO::executeQuery($query);
-
-    require_once 'CRM/Contact/BAO/Contact/Utils.php';
-    require_once 'CRM/Utils/Date.php';
-    $now = date('Ymd');
-    $pledgeDetails = $contactIds = $pledgePayments = $pledgeStatus = array();
-    while ($dao->fetch()) {
-      $checksumValue = CRM_Contact_BAO_Contact_Utils::generateChecksum($dao->contact_id);
-
-      $pledgeDetails[$dao->payment_id] = array(
-        'scheduled_date' => $dao->scheduled_date,
-        'amount_due' => $dao->amount_due,
-        'amount' => $dao->amount,
-        'amount_paid' => $dao->amount_paid,
-        'create_date' => $dao->create_date,
-        'contact_id' => $dao->contact_id,
-        'pledge_id' => $dao->pledge_id,
-        'checksumValue' => $checksumValue,
-        'contribution_page_id' => $dao->contribution_page_id,
-        'reminder_count' => $dao->reminder_count,
-        'max_reminders' => $dao->max_reminders,
-        'reminder_date' => $dao->reminder_date,
-        'initial_reminder_day' => $dao->initial_reminder_day,
-        'additional_reminder_day' => $dao->additional_reminder_day,
-        'pledge_status' => $dao->pledge_status,
-        'payment_status' => $dao->payment_status,
-        'is_test' => $dao->is_test,
-        'campaign_id' => $dao->campaign_id,
-      );
-
-      $contactIds[$dao->contact_id] = $dao->contact_id;
-      $pledgeStatus[$dao->pledge_id] = $dao->pledge_status;
-
-      if (CRM_Utils_Date::overdue(CRM_Utils_Date::customFormat($dao->scheduled_date, '%Y%m%d'),
-          $now
-        ) && $dao->payment_status != array_search('Overdue', $allStatus)
-      ) {
-        $pledgePayments[$dao->pledge_id][$dao->payment_id] = $dao->payment_id;
-      }
-    }
-
-    require_once 'CRM/Pledge/BAO/PledgePayment.php';
-    // process the updating script...
-
-    foreach ($pledgePayments as $pledgeId => $paymentIds) {
-      // 1. update the pledge /pledge payment status. returns new status when an update happens
-      echo "<br />Checking if status update is needed for Pledge Id: {$pledgeId} (current status is {$allStatus[$pledgeStatus[$pledgeId]]})";
-
-      $newStatus = CRM_Pledge_BAO_PledgePayment::updatePledgePaymentStatus($pledgeId, $paymentIds,
-        array_search('Overdue', $allStatus), NULL, 0, FALSE, TRUE
-      );
-      if ($newStatus != $pledgeStatus[$pledgeId]) {
-        echo "<br />- status updated to: {$allStatus[$newStatus]}";
-        $updateCnt += 1;
-      }
-    }
-
-    if ($sendReminders) {
-      // retrieve domain tokens
-      require_once 'CRM/Core/BAO/Domain.php';
-      require_once 'CRM/Core/SelectValues.php';
-      $domain = CRM_Core_BAO_Domain::getDomain();
-      $tokens = array(
-        'domain' => array('name', 'phone', 'address', 'email'),
-        'contact' => CRM_Core_SelectValues::contactTokens(),
-      );
-
-      require_once 'CRM/Utils/Token.php';
-      $domainValues = array();
-      foreach ($tokens['domain'] as $token) {
-        $domainValues[$token] = CRM_Utils_Token::getDomainTokenReplacement($token, $domain);
-      }
-
-      //get the domain email address, since we don't carry w/ object.
-      require_once 'CRM/Core/BAO/Domain.php';
-      $domainValue = CRM_Core_BAO_Domain::getNameAndEmail();
-      $domainValues['email'] = $domainValue[1];
-
-      // retrieve contact tokens
-
-      // this function does NOT return Deceased contacts since we don't want to send them email
-      require_once 'CRM/Utils/Token.php';
-      list($contactDetails) = CRM_Utils_Token::getTokenDetails($contactIds,
-        NULL,
-        FALSE, FALSE, NULL,
-        $tokens, 'CRM_UpdatePledgeRecord'
-      );
-
-      // assign domain values to template
-      $template = CRM_Core_Smarty::singleton();
-      $template->assign('domain', $domainValues);
-
-      //set receipt from
-      $receiptFrom = '"' . $domainValues['name'] . '" <' . $domainValues['email'] . '>';
-
-      foreach ($pledgeDetails as $paymentId => $details) {
-        if (array_key_exists($details['contact_id'], $contactDetails)) {
-          $contactId = $details['contact_id'];
-          $pledgerName = $contactDetails[$contactId]['display_name'];
-        }
-        else {
-          continue;
-        }
-
-        if (empty($details['reminder_date'])) {
-          $nextReminderDate = new DateTime($details['scheduled_date']);
-          $nextReminderDate->modify("-" . $details['initial_reminder_day'] . "day");
-          $nextReminderDate = $nextReminderDate->format("Ymd");
-        }
-        else {
-          $nextReminderDate = new DateTime($details['reminder_date']);
-          $nextReminderDate->modify("+" . $details['additional_reminder_day'] . "day");
-          $nextReminderDate = $nextReminderDate->format("Ymd");
-        }
-        if (($details['reminder_count'] < $details['max_reminders'])
-          && ($nextReminderDate <= $now)
-        ) {
-
-          $toEmail = $doNotEmail = $onHold = NULL;
-
-          if (!empty($contactDetails[$contactId]['email'])) {
-            $toEmail = $contactDetails[$contactId]['email'];
-          }
-
-          if (!empty($contactDetails[$contactId]['do_not_email'])) {
-            $doNotEmail = $contactDetails[$contactId]['do_not_email'];
-          }
-
-          if (!empty($contactDetails[$contactId]['on_hold'])) {
-            $onHold = $contactDetails[$contactId]['on_hold'];
-          }
-
-          // 2. send acknowledgement mail
-          if ($toEmail && !($doNotEmail || $onHold)) {
-            //assign value to template
-            $template->assign('amount_paid', $details['amount_paid'] ? $details['amount_paid'] : 0);
-            $template->assign('contact', $contactDetails[$contactId]);
-            $template->assign('next_payment', $details['scheduled_date']);
-            $template->assign('amount_due', $details['amount_due']);
-            $template->assign('checksumValue', $details['checksumValue']);
-            $template->assign('contribution_page_id', $details['contribution_page_id']);
-            $template->assign('pledge_id', $details['pledge_id']);
-            $template->assign('scheduled_payment_date', $details['scheduled_date']);
-            $template->assign('amount', $details['amount']);
-            $template->assign('create_date', $details['create_date']);
-
-            require_once 'CRM/Core/BAO/MessageTemplate.php';
-            list($mailSent, $subject, $message, $html) = CRM_Core_BAO_MessageTemplate::sendTemplate(
-              array(
-                'groupName' => 'msg_tpl_workflow_pledge',
-                'valueName' => 'pledge_reminder',
-                'contactId' => $contactId,
-                'from' => $receiptFrom,
-                'toName' => $pledgerName,
-                'toEmail' => $toEmail,
-              )
-            );
-
-            // 3. update pledge payment details
-            if ($mailSent) {
-              CRM_Pledge_BAO_PledgePayment::updateReminderDetails($paymentId);
-              $activityType = 'Pledge Reminder';
-              $activityParams = array(
-                'subject' => $subject,
-                'source_contact_id' => $contactId,
-                'source_record_id' => $paymentId,
-                'assignee_contact_id' => $contactId,
-                'activity_type_id' => CRM_Core_OptionGroup::getValue('activity_type',
-                  $activityType,
-                  'name'
-                ),
-                'activity_date_time' => CRM_Utils_Date::isoToMysql($now),
-                'due_date_time' => CRM_Utils_Date::isoToMysql($details['scheduled_date']),
-                'is_test' => $details['is_test'],
-                'status_id' => 2,
-                'campaign_id' => $details['campaign_id'],
-              );
-              if (is_a(civicrm_api('activity', 'create', $activityParams), 'CRM_Core_Error')) {
-                CRM_Core_Error::fatal("Failed creating Activity for acknowledgment");
-              }
-              echo "<br />Payment reminder sent to: {$pledgerName} - {$toEmail}";
-            }
-          }
-        }
-      }
-      // end foreach on $pledgeDetails
-    }
-    // end if ( $sendReminders )
-    echo "<br />{$updateCnt} records updated.";
-  }
-
-}
-
-$obj = new CRM_UpdatePledgeRecord();
-echo "Updating<br />";
-$obj->updatePledgeStatus();
-echo "<br />Pledge records update script finished.";
diff --git a/bin/deprecated/action.cronjob.php b/bin/deprecated/action.cronjob.php
deleted file mode 100644 (file)
index 0726223..0000000
+++ /dev/null
@@ -1,77 +0,0 @@
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 4.7                                               |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2015                                |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM.                                    |
- |                                                                    |
- | CiviCRM is free software; you can copy, modify, and distribute it  |
- | under the terms of the GNU Affero General Public License           |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception.   |
- |                                                                    |
- | CiviCRM is distributed in the hope that it will be useful, but     |
- | WITHOUT ANY WARRANTY; without even the implied warranty of         |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.               |
- | See the GNU Affero General Public License for more details.        |
- |                                                                    |
- | You should have received a copy of the GNU Affero General Public   |
- | License and the CiviCRM Licensing Exception along                  |
- | with this program; if not, contact CiviCRM LLC                     |
- | at info[AT]civicrm[DOT]org. If you have questions about the        |
- | GNU Affero General Public License or the licensing of CiviCRM,     |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
- +--------------------------------------------------------------------+
- */
-
-
-/*
- */
-
-/**
- * Class CRM_Cron_Action
- */
-class CRM_Cron_Action {
-  /**
-   */
-  public function __construct() {
-    // you can run this program either from an apache command, or from the cli
-    if (php_sapi_name() == "cli") {
-      require_once "cli.php";
-      $cli = new civicrm_cli();
-      //if it doesn't die, it's authenticated
-    }
-    else {
-      //from the webserver
-      $this->initialize();
-
-      $config = CRM_Core_Config::singleton();
-
-      // this does not return on failure
-      CRM_Utils_System::authenticateScript(TRUE);
-
-      //log the execution time of script
-      CRM_Core_Error::debug_log_message('action.cronjob.php');
-    }
-  }
-
-  public function initialize() {
-    require_once '../civicrm.config.php';
-    require_once 'CRM/Core/Config.php';
-
-    $config = CRM_Core_Config::singleton();
-  }
-
-  /**
-   * @param null $now
-   */
-  public function run($now = NULL) {
-    require_once 'CRM/Core/BAO/ActionSchedule.php';
-    CRM_Core_BAO_ActionSchedule::processQueue($now);
-  }
-
-}
-
-$cron = new CRM_Cron_Action();
-$cron->run();
diff --git a/bin/deprecated/civimail.cronjob.php b/bin/deprecated/civimail.cronjob.php
deleted file mode 100644 (file)
index 29e1eb3..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 4.7                                                |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2015                                |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM.                                    |
- |                                                                    |
- | CiviCRM is free software; you can copy, modify, and distribute it  |
- | under the terms of the GNU Affero General Public License           |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception.   |
- |                                                                    |
- | CiviCRM is distributed in the hope that it will be useful, but     |
- | WITHOUT ANY WARRANTY; without even the implied warranty of         |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.               |
- | See the GNU Affero General Public License for more details.        |
- |                                                                    |
- | You should have received a copy of the GNU Affero General Public   |
- | License and the CiviCRM Licensing Exception along                  |
- | with this program; if not, contact CiviCRM LLC                     |
- | at info[AT]civicrm[DOT]org. If you have questions about the        |
- | GNU Affero General Public License or the licensing of CiviCRM,     |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
- +--------------------------------------------------------------------+
- */
-
-/**
- * A PHP cron script to run the outstanding and scheduled CiviMail jobs
- * initiated by Owen Barton from a mailing sent by Lobo to crm-mail
- *
- * The structure of the file is set to mimic soap.php which is a stand-alone
- * script and hence does not have any UF issues. You should be able to run
- * this script using a web url or from the command line
- */
-function run() {
-  session_start();
-
-  if (!function_exists('drush_get_context')) {
-    require_once '../civicrm.config.php';
-  }
-
-  require_once 'CRM/Core/Config.php';
-  $config = CRM_Core_Config::singleton();
-
-  // this does not return on failure
-  CRM_Utils_System::authenticateScript(TRUE);
-
-  // we now use DB locks on a per job basis
-  require_once 'CRM/Mailing/BAO/Mailing.php';
-  CRM_Mailing_BAO_Mailing::processQueue();
-}
-
-// you can run this program either from an apache command, or from the cli
-if (php_sapi_name() == "cli") {
-  require_once "bin/cli.php";
-  $cli = new civicrm_cli();
-
-  require_once 'CRM/Mailing/BAO/Mailing.php';
-  CRM_Mailing_BAO_Mailing::processQueue();
-
-  // from the webserver
-}
-else {
-  run();
-}
diff --git a/bin/gitify b/bin/gitify
deleted file mode 100755 (executable)
index dc2b93d..0000000
+++ /dev/null
@@ -1,283 +0,0 @@
-#!/bin/bash
-
-## Take an existing, tar-based CiviCRM directory and convert it to a git working directory
-
-#### Helpers ####
-
-###########################################
-## usage: do_gitify <repo-url> <existing-dir> [git-checkout-options]
-function do_gitify() {
-  REPO="$1"
-  TGT="$2"
-  TMP="${TGT}.tmp"
-  shift 2
-
-  if [ -d "$TGT/.git" ]; then
-    echo "[[Already checked out git repo ($TGT) -- skip $REPO]]"
-    return
-  fi
-  [ -d $TGT ] || mkdir -p "$TGT"
-  [ -d $TMP ] && rm -rf "$TMP"
-  echo "[[Checkout $REPO ($TMP)]]"
-  echo "[git clone "$@" "$REPO" "$TMP"]"
-  git clone "$@" "$REPO" "$TMP"
-
-  echo "[[Swap metadata]]"
-  mv "$TMP/.git" "$TGT/.git"
-
-  echo "[[Remove local modifications]]"
-  pushd "$TGT" > /dev/null
-  git checkout -- .
-  popd > /dev/null
-
-  rm -rf "$TMP"
-}
-
-###########################################
-## add hook shims to a repo
-## usage: do_hookify <canonical-repo-name> <repo-path> <relative-hook-path>
-function do_hookify() {
-  GIT_CANONICAL_REPO_NAME="$1"
-  TGT="$2"
-  HOOK_DIR="$3"
-  if [ -n "$CIVICRM_GIT_HOOKS" ]; then
-    echo "[[Install recommended hooks ($TGT)]]"
-    for HOOK in commit-msg post-checkout post-merge pre-commit prepare-commit-msg post-commit pre-rebase post-rewrite ;do
-          cat << TMPL > "$TGT/.git/hooks/$HOOK"
-#!/bin/bash
-if [ -f "\$GIT_DIR/${HOOK_DIR}/${HOOK}" ]; then
-  ## Note: GIT_CANONICAL_REPO_NAME was not provided by early hook-stubs
-  export GIT_CANONICAL_REPO_NAME="$GIT_CANONICAL_REPO_NAME"
-  source "\$GIT_DIR/${HOOK_DIR}/${HOOK}"
-fi
-TMPL
-      chmod +x "$TGT/.git/hooks/$HOOK"
-    done
-  else
-    echo "[[Skip hook installation ($TGT) -- use \"--hooks\" to enable]]"
-  fi
-}
-
-###########################################
-## Create or update the URL of a git remote
-## usage: git_set_remote <local-repo-path> <remote-name> <remote-url>
-function git_set_remote() {
-  REPODIR="$1"
-  REMOTE_NAME="$2"
-  REMOTE_URL="$3"
-  echo "[[Set remote ($REMOTE_NAME => $REMOTE_URL within $REPODIR)]]"
-
-  pushd "$REPODIR" >> /dev/null
-    git remote set-url "$REMOTE_NAME"  "$REMOTE_URL" >/dev/null 2>&1 || git remote add "$REMOTE_NAME"  "$REMOTE_URL"
-  popd >> /dev/null
-}
-
-###########################################
-## usage: do_targzify <targz-url> <file-name> <existing-dir>
-## Fetches a tar.gz archive and unpacks it in the current directory
-function do_targzify() {
-  TARGZURL="$1"
-  TARFILE="$2"
-  TGT="$3"
-  shift 3
-
-  if [ -d "$TGT" ]; then
-    echo "[[Already have a copy of the archive ($TGT) -- skip $TARGZURL]]"
-    return
-  fi
-
-  TMP=`mktemp -d`
-
-  echo "[[Downloading $TARGZURL ($TMP)]]"
-  echo "[wget \"$TARGZURL\" -O \"$TMP/$TARFILE\"]"
-
-  pushd "$CIVICRM_ROOT" > /dev/null
-  wget -q "$TARGZURL" -O "$TMP/$TARFILE"
-  tar zxfv "$TMP/$TARFILE"
-  popd
-
-  rm "$TMP/$TARFILE"
-  rmdir "$TMP"
-}
-
-###########################################
-## usage: do_gencode <civicrm-path>
-function do_gencode() {
-  pushd "$1/xml" > /dev/null
-    if [ -f "GenCode.php" ]; then
-      echo "[[Generate files]]"
-      php GenCode.php
-    else
-      echo "[[Skip \"Generate files\"]]"
-    fi
-  popd > /dev/null
-}
-
-## usage: do_setupconf <civicrm-path>
-function do_setupconf() {
-  pushd "$1" >> /dev/null
-    echo "[[Initialize bin/setup.conf]]"
-    if [ ! -f "bin/setup.conf" ]; then
-      pwd
-      echo       cp "bin/setup.conf.txt" "bin/setup.conf"
-      cp "bin/setup.conf.txt" "bin/setup.conf"
-    fi
-    echo "[[chmod 600 bin/setup.conf]]"
-    chmod 600 bin/setup.conf
-    echo ""
-    echo "====================[ Next steps (for Civi v4.6+) ]===================="
-    echo "  * Edit the following file and fill in credentials for the CiviCRM DB."
-    echo "    $1/bin/setup.conf"
-    echo "  * Perform one of these steps:"
-    echo "    + Run 'bin/setup.sh -Dg' to download and generate missing code."
-    echo "    + Run 'bin/setup.sh' to download code and reset the CiviCRM DB"
-    echo "      with the latest schema."
-    echo "  * If this is a network-accessible server (eg staging/production), then"
-    echo "    setup.conf may present a security issue. The permissions have been"
-    echo "    preset to restrict access in most servers - but this may not work"
-    echo "    in all environments. Please:"
-    echo "    + Check whether the file is web-accessible."
-    echo "    + Optionally, change the permissions."
-    echo "    + Optionally, delete the file."
-  popd > /dev/null
-}
-
-###########################################
-## config_repo <repo-name> <local-path> <default-branch> <git-scripts-path>
-##                  1            2              3               4
-function config_repo() {
-  do_gitify "${UPSTREAM_GIT_BASE_URL}/${1}.git" "$2" -b "$3"
-  do_hookify "$1" "$2" "$4"
-  ## doesn't work with http -- git ls-remote "git://github.com/civicrm/civicrm-drupalz.git" HEAD --exit-code &>- ; echo $?
-  if [ -n "$FORK_GIT_BASE_URL" ]; then
-    git_set_remote "$2" upstream "${UPSTREAM_GIT_BASE_URL}/${1}.git"
-    git_set_remote "$2" origin "${FORK_GIT_BASE_URL}/${1}.git"
-  else
-    git_set_remote "$2" origin "${UPSTREAM_GIT_BASE_URL}/${1}.git"
-  fi
-}
-
-function check_dep() {
-  if [ -z "`which git`" ]; then
-    echo "command not found: git"
-    exit 3
-  fi
-  if [ -z `which php` ]; then
-    echo "command not found: php"
-  fi
-}
-
-###########################################
-#### Main: Parse arguments
-
-set -e
-
-CIVICRM_CMS=""
-CIVICRM_ROOT=""
-CIVICRM_L10N=""
-CIVICRM_GIT_HOOKS=""
-CIVICRM_BRANCH="master"
-FORK_GIT_BASE_URL=""
-UPSTREAM_GIT_BASE_URL="https://github.com/civicrm"
-SKIP_GENCODE=
-
-while [ -n "$1" ]; do
-  if [ "$1" == "--l10n" ]; then
-    CIVICRM_L10N="$1"
-  elif [ "$1" == "--hooks" ]; then
-    CIVICRM_GIT_HOOKS="$1"
-  elif [ "$1" == "--upstream" ]; then
-    shift
-    UPSTREAM_GIT_BASE_URL="$1"
-  elif [ "$1" == "--fork" ]; then
-    shift
-    FORK_GIT_BASE_URL="$1"
-  elif [ "$1" == "--skip-gencode" ]; then
-    SKIP_GENCODE=1
-  elif [ "$1" == "--branch" ]; then
-    shift
-    CIVICRM_BRANCH="$1"
-  elif [ -z "$CIVICRM_CMS" ]; then
-    ## First arg
-    CIVICRM_CMS="$1"
-  elif [ -z "$CIVICRM_ROOT" ]; then
-    ## Third arg
-    CIVICRM_ROOT="$1"
-  else
-    echo "unrecognized argument: $1"
-    exit 2
-  fi
-  shift
-done
-
-if [ -z "$CIVICRM_ROOT" -o ! -d "$CIVICRM_ROOT" -o -z "$UPSTREAM_GIT_BASE_URL" -o -z "$CIVICRM_CMS" ]; then
-  echo "Convert a directory into a set of CiviCRM git clones"
-  echo "usage: $0 <Drupal|Drupal6|Joomla|WordPress|all> <existing-civicrm-root> [--fork <base-url>] [--upstream <base-url>] [--l10n] [--hooks] [--branch <branch>]"
-  echo "  <cms-name>: one of: Drupal|Drupal6|Joomla|WordPress|all"
-  echo "  <git-base-url>: a base URL shared by the desiried git repos (e.g. git://github.com/civicrm)"
-  echo "  <existing-civicrm-root>: the main directory containing CiviCRM"
-  echo "  --upstream <base-url>: specify the base URL for upstream repositories"
-  echo "  --fork <base-url>: specify the base URL for your personal fork repositories"
-  echo "  --l10n: optionally fetch localization data"
-  echo "  --hooks: optionally install recommended git hooks; the hooks are mostly"
-  echo "           tested with git CLI under Linux and OSX; they haven't been"
-  echo "           tested with git GUIs or Windows"
-  echo "  --branch <branch>: specy the base branch name to checkout (ex: 'master', '4.4')"
-  echo "           For some repos, this name is adapted (ex: Drupal's '7.x-master' or '6.x-master'"
-  echo "  --skip-gencode: optionally disable gencode execution"
-  echo ""
-  echo "Note: If pointing to a pre-existing directory, your local changes may be replaced by"
-  echo "the pristine code from git. If you've made changes, then make sure there's a backup!"
-  echo ""
-  echo "example: $0 Drupal /var/www/drupal7/sites/all/modules/civicrm"
-  echo "  (checkout core code plus Drupal 7.x integration code)"
-  echo ""
-  echo "example: $0 Drupal6 /var/www/drupal6/sites/all/modules/civicrm"
-  echo "  (checkout core code plus Drupal 6.x integration code)"
-  echo ""
-  echo "example: $0 all ~/src/civicrm --upstream git@github.com:civicrm --l10n"
-  echo "  (checkout core code plus Drupal 7.x, Joomla, and WordPress integration code and l10n using SSH)"
-  exit 1
-fi
-
-###########################################
-#### Main: Update git repo metadata ####
-check_dep
-
-## config_repo <repo-name>         <local-path>                <default-branch>      <git-scripts-path>
-config_repo     civicrm-core       "$CIVICRM_ROOT"            "$CIVICRM_BRANCH"      "../tools/scripts/git"
-config_repo     civicrm-packages   "$CIVICRM_ROOT/packages"   "$CIVICRM_BRANCH"      "../../tools/scripts/git"
-case "$CIVICRM_CMS" in
-  Drupal)
-    config_repo civicrm-drupal     "$CIVICRM_ROOT/drupal"     "7.x-$CIVICRM_BRANCH"  "../../tools/scripts/git"
-    ;;
-  Drupal6)
-    config_repo civicrm-drupal     "$CIVICRM_ROOT/drupal"     "6.x-$CIVICRM_BRANCH"  "../../tools/scripts/git"
-    ;;
-  Joomla)
-    config_repo civicrm-joomla     "$CIVICRM_ROOT/joomla"     "$CIVICRM_BRANCH"      "../../tools/scripts/git"
-    ;;
-  WordPress)
-    config_repo civicrm-wordpress  "$CIVICRM_ROOT/WordPress"  "$CIVICRM_BRANCH"      "../../tools/scripts/git"
-    ;;
-  all)
-    config_repo civicrm-drupal     "$CIVICRM_ROOT/drupal"     "7.x-$CIVICRM_BRANCH"  "../../tools/scripts/git"
-    config_repo civicrm-joomla     "$CIVICRM_ROOT/joomla"     "$CIVICRM_BRANCH"      "../../tools/scripts/git"
-    config_repo civicrm-wordpress  "$CIVICRM_ROOT/WordPress"  "$CIVICRM_BRANCH"      "../../tools/scripts/git"
-    ;;
-  none)
-    ;;
-  *)
-    echo "Unrecognized CMS: $CIVICRM_CMS"
-esac
-
-if [ "$CIVICRM_L10N" == "--l10n" ]; then
-  do_targzify "https://download.civicrm.org/civicrm-l10n-core/archives/civicrm-l10n-daily.tar.gz" "civicrm-l10n-daily.tar.gz" "$CIVICRM_ROOT/l10n"
-fi
-
-if [ -f "$CIVICRM_ROOT/composer.json" ]; then
-  ## Civi v4.6+
-  do_setupconf "$CIVICRM_ROOT"
-elif [ -z "$SKIP_GENCODE" ]; then
-  do_gencode "$CIVICRM_ROOT"
-fi