Skip to content

Commit

Permalink
adjusted file headers, removed trailing whitespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
bjendres committed Mar 12, 2018
1 parent 1f3f65f commit d114f6b
Show file tree
Hide file tree
Showing 18 changed files with 62 additions and 62 deletions.
14 changes: 7 additions & 7 deletions CRM/Householdmerge/Form/Task/Fix.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/*-------------------------------------------------------+
| Household Merger Extension |
| Copyright (C) 2015 SYSTOPIA |
| Copyright (C) 2015-2018 SYSTOPIA |
| Author: B. Endres (endres@systopia.de) |
+--------------------------------------------------------+
| This program is released as free software under the |
Expand All @@ -21,9 +21,9 @@
* @see http://wiki.civicrm.org/confluence/display/CRMDOC43/QuickForm+Reference
*/
class CRM_Householdmerge_Form_Task_Fix extends CRM_Activity_Form_Task {

function buildQuickForm() {
CRM_Utils_System::setTitle(ts("Automatic Correction of Household Problems", array('domain' => 'de.systopia.householdmerge')));
CRM_Utils_System::setTitle(ts("Automatic Correction of Household Problems", array('domain' => 'de.systopia.householdmerge')));
$this->addDefaultButtons(ts("Try to fix", array('domain' => 'de.systopia.householdmerge')), 'done');

// calculate some stats
Expand All @@ -33,7 +33,7 @@ function buildQuickForm() {
$stats_query = "SELECT COUNT(id) AS activity_count,
COUNT(DISTINCT(SUBSTRING(civicrm_activity.subject FROM 1 FOR 6))) AS activity_class_count
FROM civicrm_activity
WHERE civicrm_activity.activity_type_id = $activity_type_id
WHERE civicrm_activity.activity_type_id = $activity_type_id
AND civicrm_activity.status_id IN ($activity_status_ids)
AND civicrm_activity.id IN ($activity_ids);";
$stats = CRM_Core_DAO::executeQuery($stats_query);
Expand All @@ -59,7 +59,7 @@ function postProcess() {
$activity_status_ids = CRM_Householdmerge_Logic_Configuration::getFixableActivityStatusIDs();
$activity_ids = implode(',', $this->_activityHolderIds);
$filter_query = "SELECT id AS activity_id FROM civicrm_activity
WHERE civicrm_activity.activity_type_id = $activity_type_id
WHERE civicrm_activity.activity_type_id = $activity_type_id
AND civicrm_activity.status_id IN ($activity_status_ids)
AND civicrm_activity.id IN ($activity_ids);";
$filtered_activities = CRM_Core_DAO::executeQuery($filter_query);
Expand All @@ -78,8 +78,8 @@ function postProcess() {

// show stats
CRM_Core_Session::setStatus(
ts('%1 of the %2 selected activities were processed, %3 of them could be fixed.', array(1 => $activities_detected, 2 => $activities_total, 3 => $activities_fixed, 'domain' => 'de.systopia.householdmerge')),
ts('%1 Household Problems Fixed', array(1 => $activities_fixed, 'domain' => 'de.systopia.householdmerge')),
ts('%1 of the %2 selected activities were processed, %3 of them could be fixed.', array(1 => $activities_detected, 2 => $activities_total, 3 => $activities_fixed, 'domain' => 'de.systopia.householdmerge')),
ts('%1 Household Problems Fixed', array(1 => $activities_fixed, 'domain' => 'de.systopia.householdmerge')),
($activities_fixed > 0)? 'info' : 'warn');

parent::postProcess();
Expand Down
6 changes: 3 additions & 3 deletions CRM/Householdmerge/Form/Task/Merge.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/*-------------------------------------------------------+
| Household Merger Extension |
| Copyright (C) 2015 SYSTOPIA |
| Copyright (C) 2015-2018 SYSTOPIA |
| Author: B. Endres (endres@systopia.de) |
+--------------------------------------------------------+
| This program is released as free software under the |
Expand All @@ -21,7 +21,7 @@
* @see http://wiki.civicrm.org/confluence/display/CRMDOC43/QuickForm+Reference
*/
class CRM_Householdmerge_Form_Task_Merge extends CRM_Contact_Form_Task {

function buildQuickForm() {
// first: sort out the contacts
$contacts = array();
Expand Down Expand Up @@ -172,7 +172,7 @@ function calculatePatterns(&$contacts) {
$first_part = implode(', ', array_slice($first_names, 0, $first_names_count-1));
$patterns[1] = $first_part.' '.$and.' '.$first_names[$first_names_count-1].' '.$last_name;
} else {
$patterns[1] = implode(' '.$and.' ', $first_names).' '.$last_name;
$patterns[1] = implode(' '.$and.' ', $first_names).' '.$last_name;
}
}

Expand Down
16 changes: 8 additions & 8 deletions CRM/Householdmerge/Logic/Checker.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/*-------------------------------------------------------+
| Household Merger Extension |
| Copyright (C) 2015 SYSTOPIA |
| Copyright (C) 2015-2018 SYSTOPIA |
| Author: B. Endres (endres@systopia.de) |
+--------------------------------------------------------+
| This program is released as free software under the |
Expand Down Expand Up @@ -31,7 +31,7 @@ function __construct() {
*/
public function checkAllHouseholds($max_count = NULL) {
$max_count = (int) $max_count;

$activity_type_id = CRM_Householdmerge_Logic_Configuration::getCheckHouseholdActivityTypeID();
$activity_status_ids = CRM_Householdmerge_Logic_Configuration::getLiveActivityStatusIDs();

Expand All @@ -50,7 +50,7 @@ public function checkAllHouseholds($max_count = NULL) {
LEFT JOIN civicrm_activity_contact ON civicrm_activity_contact.contact_id = civicrm_contact.id
LEFT JOIN civicrm_activity ON civicrm_activity_contact.activity_id = civicrm_activity.id AND civicrm_activity.activity_type_id = $activity_type_id AND civicrm_activity.status_id IN ($activity_status_ids)
WHERE contact_type = 'Household'
AND civicrm_activity.id IS NULL
AND civicrm_activity.id IS NULL
AND (civicrm_contact.is_deleted IS NULL or civicrm_contact.is_deleted = 0)
AND civicrm_contact.id > $contact_id_minimum
GROUP BY civicrm_contact.id
Expand Down Expand Up @@ -116,7 +116,7 @@ function checkHousehold($household_id) {
if (count($heads) > 1) {
$problems_identified[] = CRM_Householdmerge_Logic_Problem::createProblem('HHN2', $household_id);
}

// CHECK 4: does the head have a DO NOT mail/phone/sms/email
$donts = CRM_Householdmerge_Logic_Configuration::getDontXXXChecks();
foreach ($heads as $head) {
Expand Down Expand Up @@ -197,7 +197,7 @@ protected function checkAddresses(&$household, &$members, &$problems_identified)

// this contact still has/shares this address, remove him/her from the list
unset($member_ids[array_search($address['contact_id'], $member_ids)]);
}
}
}

// every contact that's still on the list should NOT have the address any more
Expand All @@ -206,7 +206,7 @@ protected function checkAddresses(&$household, &$members, &$problems_identified)
}
}


/**
* identify potential new household members
*/
Expand Down Expand Up @@ -235,8 +235,8 @@ protected function findNewMembers(&$household, &$members, &$problems_identified)
AND civicrm_address.street_address = %2
AND civicrm_address.postal_code = %3
AND civicrm_address.city = %4
AND NOT EXISTS (SELECT id
FROM civicrm_relationship
AND NOT EXISTS (SELECT id
FROM civicrm_relationship
WHERE (contact_id_a = civicrm_contact.id OR contact_id_b = civicrm_contact.id)
AND (relationship_type_id IN ($relationship_id_list))
AND (end_date IS NULL OR end_date > NOW())
Expand Down
14 changes: 7 additions & 7 deletions CRM/Householdmerge/Logic/Fixer.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/*-------------------------------------------------------+
| Household Merger Extension |
| Copyright (C) 2015 SYSTOPIA |
| Copyright (C) 2015-2018 SYSTOPIA |
| Author: B. Endres (endres@systopia.de) |
+--------------------------------------------------------+
| This program is released as free software under the |
Expand Down Expand Up @@ -52,21 +52,21 @@ public static function fixHMNW($problem) {
$relation_ids[] = CRM_Householdmerge_Logic_Configuration::getMemberRelationID();
$relation_ids[] = CRM_Householdmerge_Logic_Configuration::getHeadRelationID();
$existing_relationship = civicrm_api3('Relationship', 'get', array(
'contact_id_a' => $new_contact_id,
'contact_id_b' => $problem->getHouseholdID(),
'relationship_type_id' => array('IN' => $relation_ids),
'contact_id_a' => $new_contact_id,
'contact_id_b' => $problem->getHouseholdID(),
'relationship_type_id' => array('IN' => $relation_ids),
'is_active' => 1));
if ($existing_relationship['count']) {
// there already is a relationship, the problem IS fixed already...
} else {
// create a new relationship
civicrm_api3('Relationship', 'create', array(
'contact_id_a' => $new_contact_id,
'contact_id_b' => $problem->getHouseholdID(),
'contact_id_a' => $new_contact_id,
'contact_id_b' => $problem->getHouseholdID(),
'relationship_type_id' => CRM_Householdmerge_Logic_Configuration::getMemberRelationID(),
'is_active' => 1));
}

return TRUE;
return TRUE;
}
}
18 changes: 9 additions & 9 deletions CRM/Householdmerge/Logic/Problem.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/*-------------------------------------------------------+
| Household Merger Extension |
| Copyright (C) 2016 SYSTOPIA |
| Copyright (C) 2016-2018 SYSTOPIA |
| Author: B. Endres (endres@systopia.de) |
+--------------------------------------------------------+
| This program is released as free software under the |
Expand All @@ -19,7 +19,7 @@ class CRM_Householdmerge_Logic_Problem {
* This is the list of all known problems
*/
static $_problem_classes = NULL;

public static function getProblemClasses() {
if (self::$_problem_classes === NULL) {
self::$_problem_classes = array(
Expand Down Expand Up @@ -63,7 +63,7 @@ public static function getProblemClasses() {
}
return self::$_problem_classes;
}

/**
* create a problem instance defined by the given code
*/
Expand Down Expand Up @@ -95,7 +95,7 @@ public static function extractProblem($activity_id) {

// TODO: load member at this point?
return self::createProblem($code, $activity['source_contact_id'], array('activity_id' => $activity_id));
}
}



Expand All @@ -115,15 +115,15 @@ protected function __construct($code, $household_id, $params = array()) {

/**
* Try to automatically fix a problem
*
*
* @return TRUE if fix was successful
*/
public function fix($close_activity = TRUE) {
switch ($this->code) {
case 'HMNW':
$fixed = CRM_Householdmerge_Logic_Fixer::fixHMNW($this);
break;

default:
$fixed = FALSE;
}
Expand Down Expand Up @@ -156,7 +156,7 @@ public function getHouseholdID() {
return $this->household_id;
}

/**
/**
*
* @return activity_id if a new activity was created
*/
Expand Down Expand Up @@ -189,7 +189,7 @@ public function createActivity() {
$activity_data['target_contact_id'][] = (int) $this->params['member_id'];
}
$activity_data['source_contact_id'] = (int) $this->household_id;

$activity = CRM_Activity_BAO_Activity::create($activity_data);
if (empty($activity->id)) {
throw new Exception("Couldn't create activity for household [{$household['id']}]");
Expand Down Expand Up @@ -229,7 +229,7 @@ protected function hasLiveActivity() {
$selector_sql = "SELECT civicrm_activity.id AS activity_id
FROM civicrm_activity
LEFT JOIN civicrm_activity_contact target ON target.activity_id = civicrm_activity.id AND target.record_type_id = 3
WHERE civicrm_activity.activity_type_id = $activity_type_id
WHERE civicrm_activity.activity_type_id = $activity_type_id
AND civicrm_activity.status_id IN ($activity_status_ids)
AND civicrm_activity.subject LIKE %1
AND target.contact_id = $household_id
Expand Down
14 changes: 7 additions & 7 deletions CRM/Householdmerge/Logic/Scanner.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/*-------------------------------------------------------+
| Household Merger Extension |
| Copyright (C) 2015 SYSTOPIA |
| Copyright (C) 2015-2018 SYSTOPIA |
| Author: B. Endres (endres@systopia.de) |
+--------------------------------------------------------+
| This program is released as free software under the |
Expand All @@ -24,9 +24,9 @@ function __construct() {
* find a number of prposed households.
*
* @return: array(array( 'id' => string
* 'household_id' => int,
* 'member_ids' => array(int),
* 'head_id' => int,
* 'household_id' => int,
* 'member_ids' => array(int),
* 'head_id' => int,
* 'address' => array(<address data>)
* 'contacts' => array(int=>contact_data)
*/
Expand Down Expand Up @@ -199,7 +199,7 @@ protected function findCandidates($count) {

/**
* Identify the contact to be considered the HEAD under the given member_data objects
*
*
* @return int contact_id of the head
*/
protected function identifyHead(&$members) {
Expand All @@ -214,7 +214,7 @@ protected function identifyHead(&$members) {

$contact_ids = implode(',', array_keys($members));
$td_amounts_sql = "
SELECT contact_id AS contact_id,
SELECT contact_id AS contact_id,
SUM(total_amount) AS amount
FROM civicrm_contribution
WHERE contact_id IN ($contact_ids)
Expand All @@ -231,7 +231,7 @@ protected function identifyHead(&$members) {
// now determin the head
$topdonor_id = NULL;
$topdonor_amount = NULL;

foreach ($donations as $member_id => $donation_amount) {
if ($donation_amount > $topdonor_amount || $topdonor_amount===NULL) {
$topdonor_id = $member_id;
Expand Down
4 changes: 2 additions & 2 deletions CRM/Householdmerge/Logic/Worker.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/*-------------------------------------------------------+
| Household Merger Extension |
| Copyright (C) 2015 SYSTOPIA |
| Copyright (C) 2015-2018 SYSTOPIA |
| Author: B. Endres (endres@systopia.de) |
+--------------------------------------------------------+
| This program is released as free software under the |
Expand Down Expand Up @@ -89,7 +89,7 @@ public function linkContactToHousehold($contact_id, $household_id, $relation_typ
} else {
$this->_relationID2fields[$relation_type_id] = array(
'household' => 'contact_id_b',
'contact' => 'contact_id_a');
'contact' => 'contact_id_a');
}
}

Expand Down
2 changes: 1 addition & 1 deletion CRM/Householdmerge/MergeController.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/*-------------------------------------------------------+
| Household Merger Extension |
| Copyright (C) 2015 SYSTOPIA |
| Copyright (C) 2015-2018 SYSTOPIA |
| Author: B. Endres (endres@systopia.de) |
+--------------------------------------------------------+
| This program is released as free software under the |
Expand Down
4 changes: 2 additions & 2 deletions CRM/Householdmerge/Page/Finder.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/*-------------------------------------------------------+
| Household Merger Extension |
| Copyright (C) 2015 SYSTOPIA |
| Copyright (C) 2015-2018 SYSTOPIA |
| Author: B. Endres (endres@systopia.de) |
+--------------------------------------------------------+
| This program is released as free software under the |
Expand All @@ -16,7 +16,7 @@
require_once 'CRM/Core/Page.php';

class CRM_Householdmerge_Page_Finder extends CRM_Core_Page {

public function run() {
CRM_Utils_System::setTitle(ts('Household Finder'));

Expand Down
2 changes: 1 addition & 1 deletion CRM/Householdmerge/Page/Mergeview.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/*-------------------------------------------------------+
| Household Merger Extension |
| Copyright (C) 2015 SYSTOPIA |
| Copyright (C) 2015-2018 SYSTOPIA |
| Author: B. Endres (endres@systopia.de) |
+--------------------------------------------------------+
| This program is released as free software under the |
Expand Down
4 changes: 2 additions & 2 deletions api/v3/Contact/CheckHousehold.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/*-------------------------------------------------------+
| Household Merger Extension |
| Copyright (C) 2015 SYSTOPIA |
| Copyright (C) 2015-2018 SYSTOPIA |
| Author: B. Endres (endres@systopia.de) |
+--------------------------------------------------------+
| This program is released as free software under the |
Expand All @@ -25,7 +25,7 @@ function civicrm_api3_contact_check_household($params) {
if ($household_id) {
$checker->checkHousehold($household_id);
}

} else {
$max_count = NULL;
if (!empty($params['max_count'])) {
Expand Down
Loading

0 comments on commit d114f6b

Please sign in to comment.