Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update to jethro master #3

Merged
merged 130 commits into from
Oct 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
130 commits
Select commit Hold shift + click to select a range
b947d4b
roster reminder script
s4069b Aug 1, 2017
411997c
roster reminder sample ini file
s4069b Aug 1, 2017
d367d7d
fixed the html email content
s4069b Aug 2, 2017
5f16140
Merge pull request #4 from tbar0970/master
s4069b Aug 15, 2017
995540f
Delete roster_reminder.php
s4069b Aug 15, 2017
3fae34b
Delete roster_reminder_sample.ini
s4069b Aug 15, 2017
7b5132b
This script sends a roster reminder
s4069b Aug 15, 2017
79d9dba
ini file to go with roster_reminder.php
s4069b Aug 15, 2017
5644a41
fixed html email content
s4069b Aug 21, 2017
7eef714
Merge remote-tracking branch 'upstream/master' into rosterreminder
vanoudt Feb 5, 2018
a9206f7
Initial work to add SMS support to reports
vanoudt Feb 5, 2018
e1e8cf1
Whitespace/Style Fixes
vanoudt Feb 5, 2018
84e20d1
Enable sending roster reminders using SMS as well as email (or both!)
vanoudt Feb 6, 2018
ed399e9
Remove extraneous SMS_FROM option
vanoudt Feb 6, 2018
4a78b37
Only print sms response if we're running in verbose mode
vanoudt Feb 6, 2018
59e792a
Fixes to make sms messages etc. work as expected
vanoudt Feb 6, 2018
446d538
Remove extraneous verbosity
vanoudt Feb 6, 2018
6b88021
Report errors for SMS better, don't try and send when there are no as…
vanoudt Feb 7, 2018
1779ecf
Send email notifications for roster reminders - not just for people w…
vanoudt Feb 7, 2018
ce8efd5
few small fixes
vanoudt Feb 7, 2018
0d76247
Replace "nil" with "-" in roster emails
vanoudt Feb 7, 2018
2b279e2
Include roster date in emails (if it is available)
vanoudt Feb 7, 2018
1725ed3
Fixed notification if all emails were successfully sent (previously s…
vanoudt Feb 7, 2018
6190912
Fix a typo in SMS verification
vanoudt Feb 7, 2018
478bb71
Update mailchimp_sync.php
tbar0970 Mar 14, 2018
7b749c3
Resolves #453 - make sure mailto links open in a new tab if webmail i…
tbar0970 Mar 17, 2018
4f475c6
Merge branch 'master' of https://github.com/tbar0970/jethro-pmm
tbar0970 Mar 17, 2018
7bf88ce
Fix #409 by making it possible to set congregation to (none) in bulk …
tbar0970 Mar 17, 2018
6ec4d7f
Fix #418 by making sure links with data-method=POST always submit a form
tbar0970 Mar 17, 2018
90cbdf4
Merge remote-tracking branch 'upstream/master' into rosterreminder
vanoudt Mar 17, 2018
c794d41
Part progress on deleting altogether
tbar0970 Mar 28, 2018
7db73d8
Fixes #455 - make the paginator include values that are 'before A' or…
tbar0970 Mar 28, 2018
3e824d3
Merge branch 'master' of https://github.com/tbar0970/jethro-pmm
tbar0970 Mar 28, 2018
0b983ed
Update developer_tips.md
tbar0970 Apr 6, 2018
3f5b709
Server side SMS content cleansing
tbar0970 Apr 25, 2018
fa23e4d
Merge branch 'master' of https://github.com/tbar0970/jethro-pmm
tbar0970 Apr 25, 2018
4db83dc
Issue #400: Simple server-side cleansing of SMS characters
tbar0970 Apr 25, 2018
b3f7683
Issue #400: Simple server-side cleansing of SMS characters
tbar0970 Apr 25, 2018
3b25b6e
Fixes #457 - MySQL strict mode error adding family
tbar0970 Apr 25, 2018
a9ecb68
Merge branch 'rosterreminder' of https://github.com/vanoudt/jethro-pm…
tbar0970 Apr 25, 2018
4c46998
Cleanup of PR
tbar0970 Apr 25, 2018
bcb0721
Merge branch 'vanoudt-rosterreminder'
tbar0970 Apr 25, 2018
52c87b6
Fix #408 by committing code from @s4069b and @vanoudt
tbar0970 Apr 25, 2018
48158f3
Issue #400 - don't assume mbstring is available
tbar0970 Apr 25, 2018
05cc4d4
Fix jquery expression - safari would not tolerate it
tbar0970 Apr 25, 2018
cbc16ce
Fix #458 - missing column
tbar0970 Apr 26, 2018
d7d9673
Remove unneeded line that caused errors
tbar0970 Apr 26, 2018
aa1cf13
Merge github/master
tbar0970 Apr 26, 2018
1639a7e
Fix #460 by making sure we get the lock first. Also clean up the 'bac…
tbar0970 May 7, 2018
03e27a3
Issue 470 - Add default value for editor to correct MySQL insert error
May 12, 2018
edd399e
Issue 472 - store time in a variable to stop time being re-evaluated …
May 13, 2018
aa2ae23
Merge pull request #471 from thesle/master
tbar0970 May 13, 2018
a272edb
Enable browser-native spell check in wysiwyg fields
tbar0970 May 14, 2018
5395c7f
Re-introduce urlencode call
tbar0970 May 14, 2018
85b9e23
Merge pull request #473 from thesle/master
tbar0970 May 14, 2018
ab703a7
Make it possible to include an index in a keyword, eg %BIBLE_READERS_…
tbar0970 May 16, 2018
f089209
Update CCLI search format
tbar0970 May 17, 2018
3fab816
Merge branch 'master' of https://github.com/tbar0970/jethro-pmm
tbar0970 Jun 8, 2018
3a22c3a
Fix #498 by detecting photo rotation and applying it
tbar0970 Jun 8, 2018
afcf1e0
Issue #457 - clean up zero dates
tbar0970 Jun 8, 2018
7a42f5c
Fix #405 by displaying family photo in members interface
tbar0970 Jun 8, 2018
d3c006d
Layout improvements for members interface
tbar0970 Jun 9, 2018
4de5c8c
Add a link to email/SMS personnel to the view-run-sheet page
tbar0970 Jun 13, 2018
5c821dc
Show no-email and no-mobile icons on run sheet personnel
tbar0970 Jun 13, 2018
53ace2c
Merge branch 'master' of https://github.com/tbar0970/jethro-pmm
tbar0970 Jun 14, 2018
cb24af2
Holding this back until the next second-point release
tbar0970 Jun 14, 2018
82c2105
Merge branch 'master' of https://github.com/tbar0970/jethro-pmm
tbar0970 Jun 14, 2018
7f53571
On Mac, add an imessage link if no SMS gateway configured
tbar0970 Jun 26, 2018
cb99125
Fix link
tbar0970 Jun 27, 2018
69d31d0
Resolves #508 - keep custom fields out of the way when processing mem…
tbar0970 Jun 27, 2018
123fac7
Merge branch 'master' of https://github.com/tbar0970/jethro-pmm
tbar0970 Jun 27, 2018
36bfd3f
Apply the same hard-trimming in import value comparison as is done wh…
tbar0970 Jul 6, 2018
7457e35
Get rid of int-box class and use type=number instead, including for h…
tbar0970 Jul 7, 2018
9e6f0fa
Add extra space for spinner controls on number boxes
tbar0970 Jul 7, 2018
626cd72
Fix #513 by having the 0 prefix for 'other' values all the time
tbar0970 Jul 7, 2018
53803a2
Fix #509 by making sure feed uuid changes not shown in history
tbar0970 Jul 7, 2018
8c2ddf0
Temp solution for issue #505 -store photos at 500x500px
tbar0970 Jul 7, 2018
0849f63
Standardise image width on output (see Issue #505)
tbar0970 Jul 7, 2018
a5b4a11
Resolves #493 - link person/family name to view person/family details…
tbar0970 Jul 7, 2018
f5cf7b3
Issue #492 - fix wording re cong/group restrictions
tbar0970 Jul 7, 2018
5206612
Fix #492 by correcting setting note. Fix #506 by correcting col defin…
tbar0970 Jul 7, 2018
61f04af
Front page reports
tbar0970 Jul 9, 2018
2321e2f
Whitespace cleanup from vanoudt
tbar0970 Jul 9, 2018
342fe50
Issue #30 - ability to delete a person entirely, or de-identify their…
tbar0970 Jul 11, 2018
516b0be
Issue #30 - ability to clear history properly
tbar0970 Jul 11, 2018
bb68f54
Issue #30 tweaking
tbar0970 Jul 11, 2018
2ca8f53
Check for outstanding notes before deleting or cleaning a person
tbar0970 Jul 16, 2018
73a5433
Issue #30 - deleting persons
tbar0970 Jul 16, 2018
e6c7592
Resolves #519 by falling back to family photo if an individual photo …
tbar0970 Jul 17, 2018
4521919
Resolves #518 by not cropping family photos- just resize them
tbar0970 Jul 17, 2018
446f01a
Issue #30 - foreign key adjustments to make sure everything is cleane…
tbar0970 Jul 18, 2018
0c9e649
Issue #30 - clear family photos too
tbar0970 Jul 18, 2018
bc40daa
Issue #30 - fix installer issues re attendance record FK
tbar0970 Jul 21, 2018
6622ab7
Issue #30 - improve FK upgrade
tbar0970 Jul 21, 2018
4a7467b
Quick fix for Issue #503 - don't show archived persons in members int…
tbar0970 Jul 22, 2018
c5a0b30
Merge branch 'master' of https://github.com/tbar0970/jethro-pmm
tbar0970 Jul 23, 2018
93f64be
Resolve conflict
tbar0970 Jul 23, 2018
6e8f4f1
When ordering family members, only put male before female for adults …
tbar0970 Jul 23, 2018
5a6a360
Set the date on the front of the contact list DOCX via Jethro since W…
tbar0970 Jul 25, 2018
6abbda5
Fix punctuation
tbar0970 Jul 26, 2018
dfc715e
Fix punctuation
tbar0970 Jul 26, 2018
04da3da
Fix #524 by correcting SQL bracketing
tbar0970 Jul 27, 2018
16dcaf9
Merge branch 'master' of https://github.com/tbar0970/jethro-pmm
tbar0970 Jul 27, 2018
ee9d31d
Polish photo-upload controls so that phones allow both the choice of …
tbar0970 Jul 31, 2018
bc7ac13
Force numeric keyboard for headcount field in iOS
tbar0970 Jul 31, 2018
eb5207d
Merge branch 'master' of https://github.com/tbar0970/jethro-pmm
tbar0970 Aug 1, 2018
d2912f3
Fix #527 - make sure ratio is unchanged when no cropping being done
tbar0970 Aug 8, 2018
0880523
More polishing of DOCX contact lists. Single-person photos are shown …
tbar0970 Aug 8, 2018
ce459da
Fix date format
tbar0970 Aug 8, 2018
2eb1260
Change the word query to report
tbar0970 Aug 17, 2018
f30e942
Fixes #474 - reduce the number of cols in group members display, esp …
tbar0970 Aug 17, 2018
2bb64ef
Tweaking photos in DOCX contact lists
tbar0970 Aug 17, 2018
176f7eb
Fix #410 by simplifying component usage stats
tbar0970 Aug 17, 2018
6c839d1
Fix #531 by using case insensitive sorting
tbar0970 Aug 17, 2018
5e0c774
Fix #533 - condition was the wrong way around...
tbar0970 Aug 20, 2018
d25a9e7
Merge branch 'master' of https://github.com/tbar0970/jethro-pmm
tbar0970 Aug 20, 2018
5869f2d
membership status chooser should not be autofocus
tbar0970 Aug 24, 2018
2a1eba1
Don't try to include full-name in mailto links because it means 'copy…
tbar0970 Aug 25, 2018
e2fca1c
Fixes #521 by allowing SMS via either Jethro's SMS gateway OR my loca…
tbar0970 Aug 25, 2018
75ee52d
Fix #344 by throwing an error if current user has blank mobile and te…
tbar0970 Aug 25, 2018
6def9d7
Fix #344 better by using fresh user info rather than what's cached in…
tbar0970 Aug 25, 2018
e465971
Use centralised SMS_Sender::canSend function to detect if we can send…
tbar0970 Aug 25, 2018
08a6fd9
Fix #540 by putting quotes around filename
tbar0970 Sep 19, 2018
721dc4b
Fix #481 by fixing FKs
tbar0970 Sep 19, 2018
0375136
Merge branch 'master' of https://github.com/tbar0970/jethro-pmm
tbar0970 Sep 20, 2018
4b69114
Move cookie-handling code after config manager is set up, so that SES…
tbar0970 Sep 20, 2018
77cd776
Fix #541. When in standalone-safari (ios web app) mode, track the bro…
tbar0970 Sep 20, 2018
2788694
Use null default
tbar0970 Sep 20, 2018
59a82b1
Fix logout button on safari standalone
tbar0970 Sep 20, 2018
1b7c82c
Merge branch 'master' of https://github.com/tbar0970/jethro-pmm
tbar0970 Sep 20, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions calls/call_email.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@ function run()
$blanks = $GLOBALS['system']->getDBObjectData('person', Array('(id' => $personids, 'email' => '', '!status' => 'archived'), 'AND');
$archived = $GLOBALS['system']->getDBObjectData('person', Array('(id' => $personids, 'status' => 'archived'), 'AND');
} else if (!empty($_REQUEST['roster_view'])) {
$view = $GLOBALS['system']->getDBObject('roster_view', (int)$_REQUEST['roster_view']);
$recips = $view->getAssignees($_REQUEST['start_date'], $_REQUEST['end_date']);
$recips = Array();
foreach ((array)$_REQUEST['roster_view'] as $viewid) {
$view = $GLOBALS['system']->getDBObject('roster_view', (int)$viewid);
$recips += $view->getAssignees($_REQUEST['start_date'], $_REQUEST['end_date']);
}
} else {
if (empty($_REQUEST['personid'])) {
$recips = $emails = $blanks = $archived = Array();
Expand Down
2 changes: 1 addition & 1 deletion calls/call_roster_csv.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function run()
$start_date = substr(array_get($_REQUEST, 'start_date', ''), 0, 10);
$end_date = substr(array_get($_REQUEST, 'end_date', ''), 0, 10);
header('Content-type: text/csv');
header('Content-disposition: attachment; filename='.preg_replace('[^a-zA-Z0-9]', '_', $view->getValue('name')).'.csv');
header('Content-disposition: attachment; filename="'.preg_replace('[^a-zA-Z0-9]', '_', $view->getValue('name')).'.csv"');
$view->printCSV($start_date, $end_date);

}
Expand Down
4 changes: 4 additions & 0 deletions conf.php.sample
Original file line number Diff line number Diff line change
Expand Up @@ -216,3 +216,7 @@ define('DB_TYPE', 'mysql');
// For troubleshooting you can use this to show error details in the browser
// This is usually disabled in production versions but shown in dev.
// define('SHOW_ERROR_DETAILS', TRUE);

// Text encoding for sending SMS messages.
// Change it to something other than GSM0338 to stop Jethro filtering out non-GSMS0338 characters.
// define('SMS_ENCODING', 'GSM0338');
19 changes: 17 additions & 2 deletions db_objects/abstract_note.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ protected static function _getFields()
'editable' => false,
'references' => 'person',
'visible' => false,
'default' => NULL,
),
'edited' => Array(
'type' => 'datetime',
Expand Down Expand Up @@ -207,7 +208,7 @@ public function canEditOriginal() {
function delete()
{
if (!$this->canBeDeleted()) {
trigger_error("This note can not be deleted");
trigger_error("This note can not be deleted", E_USER_WARNING);
return FALSE;
}
if (!parent::delete()) return FALSE;
Expand Down Expand Up @@ -302,7 +303,7 @@ public static function getNotifications($minutes)
COUNT(DISTINCT nn.id) as new_notes,
GROUP_CONCAT(nn.id) as new_note_ids
FROM person p
JOIN abstract_note nn ON nn.assignee = p.id
JOIN abstract_note nn ON nn.assignee = p.id
AND nn.status = "pending"
AND nn.action_date <= DATE(NOW())
AND ((
Expand All @@ -319,4 +320,18 @@ public static function getNotifications($minutes)
GROUP BY p.id';
return $GLOBALS['db']->queryAll($SQL);
}

/**
* Clean up any orphaned records that are not references by a person or family note
* @return boolean
*/
public static function cleanupInstances()
{
$SQL = 'DELETE FROM abstract_note WHERE id NOT IN (
SELECT id FROM person_note
UNION
SELECT id from family_note
)';
return $GLOBALS['db']->exec($SQL);
}
}
26 changes: 26 additions & 0 deletions db_objects/attendance_record.class.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php
include_once 'include/db_object.class.php';
class Attendance_Record extends db_object
{
// NB This class only exists for the following SQL
// See Attendance_Record_Set for CRUD functionality of this table

function getInitSQL($table_name=NULL)
{
return "
CREATE TABLE `attendance_record` (
`date` date NOT NULL,
`personid` int(11) NOT NULL,
`groupid` int(11) NOT NULL,
`present` tinyint(1) unsigned NOT NULL,
PRIMARY KEY (`date`,`personid`,`groupid`)
) ENGINE=InnoDB ;
";
}

public function getForeignKeys()
{
return Array('personid' => '`_person` (`id`) ON DELETE CASCADE');
}
}
?>
23 changes: 2 additions & 21 deletions db_objects/attendance_record_set.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,25 +70,6 @@ function create()
{
}


function getInitSQL($table_name=NULL)
{
return "
CREATE TABLE `attendance_record` (
`date` date NOT NULL default '0000-00-00',
`personid` int(11) NOT NULL default '0',
`groupid` int(11) NOT NULL default '0',
`present` tinyint(1) unsigned NOT NULL default '0',
PRIMARY KEY (`date`,`personid`,`groupid`)
) ENGINE=InnoDB ;
";
}

public function getForeignKeys()
{
return Array();
}

function load($date, $cohort, $age_brackets, $statuses)
{
$this->date = $date;
Expand Down Expand Up @@ -346,7 +327,7 @@ function printHeadcountField()
$headcountValue = Headcount::fetch('person_group', $this->date, $this->groupid);
}
?>
<input type="text" class="int-box" name="<?php echo $headcountFieldName; ?>" value="<?php echo $headcountValue; ?>" size="5" />
<input type="number" inputmode="numeric" pattern="[0-9]*" name="<?php echo $headcountFieldName; ?>" value="<?php echo $headcountValue; ?>" style="width: 60px" />
<input type="button" class="btn" onclick="var x = $(this).siblings('input').get(0); x.value = x.value == '' ? 1 : parseInt(x.value, 10)+1" value="+" />
<?php
}
Expand Down Expand Up @@ -512,7 +493,7 @@ public static function getStatsForPeriod($start_date, $end_date, $cohortid)
GROUP BY ar.personid, '.$selectCol.'
) indiv
GROUP BY '.$rank.' '.$groupingField.' WITH ROLLUP';
$res = $db->queryAll($sql);
$res = $db->queryAll($sql);

foreach ($res as $row) {
if (NULL !== $row[$groupingField]) {
Expand Down
10 changes: 6 additions & 4 deletions db_objects/custom_field.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,7 @@ public function printWidget($value, $extraParams=Array(), $prefix='')
if (($this->getValue('type') == 'select') && strlen($value) && !empty($this->values['params']['allow_other'])) {
if (!isset($widgetParams['options'][$value])) {
$otherValue = $value;
if (0 === strpos($otherValue, '0 ')) $otherValue = substr($otherValue, 2);
$value = 'other';
}
}
Expand Down Expand Up @@ -557,7 +558,7 @@ public function formatValue($val)
{
if (is_array($val)) return implode(', ', array_map(Array($this, 'formatValue'), $val));
if (!strlen($val)) return '';

switch ($this->getValue('type')) {
case 'date':
if (!preg_match('/(([-0-9]{4})?-([0-9]{2}-[0-9]{2}))( (.*))?/', $val, $matches)) {
Expand Down Expand Up @@ -637,12 +638,13 @@ public function parseValue($val)

/**
* Get SQL expression to retrieve a value suitable for use by formatValue() above.
* @param string $tableAlias Alias of the custom_field_value table in the SQL statement
* @param string $valueTableAlias Alias of the custom_field_value table in the SQL statement
* @param string $fieldTableAlias Alias of the custom_field table in the SQL statement
* @return string SQL
*/
public static function getRawValueSQLExpr($tableAlias)
public static function getRawValueSQLExpr($valueTableAlias, $fieldTableAlias)
{
return 'TRIM(CONCAT(COALESCE('.$tableAlias.'.value_optionid, CONCAT('.$tableAlias.'.value_date, " "), ""), COALESCE('.$tableAlias.'.value_text, "")))';
return 'TRIM(CONCAT(COALESCE('.$valueTableAlias.'.value_optionid, CONCAT('.$valueTableAlias.'.value_date, " "), ""), COALESCE(CONCAT(IF('.$fieldTableAlias.'.type="select", "0 ", ""), '.$valueTableAlias.'.value_text), "")))';
}

/**
Expand Down
65 changes: 58 additions & 7 deletions db_objects/family.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ function getInitSQL($table_name=NULL)
"CREATE TABLE family_photo (
familyid INT NOT NULL,
photodata MEDIUMBLOB NOT NULL,
CONSTRAINT `famliyphotofamilyid` FOREIGN KEY (`familyid`) REFERENCES `family` (`id`),
CONSTRAINT `famliyphotofamilyid` FOREIGN KEY (`familyid`) REFERENCES `family` (`id`) ON DELETE CASCADE,
PRIMARY KEY (familyid)
) ENGINE=InnoDB;
"
Expand Down Expand Up @@ -158,7 +158,7 @@ function printForm($prefix='', $fields=NULL)
function processForm($prefix='', $fields=NULL)
{
$res = parent::processForm($prefix, $fields);
$this->_photo_data = Photo_Handler::getUploadedPhotoData('photo');
$this->_photo_data = Photo_Handler::getUploadedPhotoData('photo', Photo_Handler::CROP_NONE);
return $res;
}

Expand Down Expand Up @@ -188,7 +188,7 @@ function printMemberList($abbreviated=NULL)
$persons = $this->getMemberData();
$show_actions = !empty($this->id); // hide actions if this is a "draft" family

if (isset($this->_tmp['show_member_callback'])) {
if (!empty($this->_tmp['show_member_callback'])) {
call_user_func($this->_tmp['show_member_callback'], $persons);

} else if (!$abbreviated) {
Expand Down Expand Up @@ -245,7 +245,7 @@ function printFieldInterface($name, $prefix='')
{
if ($name == 'photo') {
?>
<input type="file" name="photo" />
<input type="file" accept="image/*" name="photo" />
<?php
return;
}
Expand Down Expand Up @@ -336,7 +336,6 @@ function printSummaryWithMembers($abbreviate_member_list=TRUE, $member_data=NULL

function printCustomSummary($showMembersCallback)
{
// TODO: test this in the mmebers interface
$this->fields['members'] = Array('divider_before' => 1);
$this->_tmp['show_member_callback'] = $showMembersCallback;
parent::printSummary();
Expand All @@ -346,8 +345,10 @@ function printCustomSummary($showMembersCallback)

function getMemberData()
{
//$objectType = $GLOBALS['user_system']->getCurrentUser() ? 'person' : 'member';
$restriction = $GLOBALS['user_system']->getCurrentUser() ? Array() : Array('!status' => 'archived');
if (!isset($this->_tmp['members'])) {
$this->_tmp['members'] = $GLOBALS['system']->getDBObjectData('person', Array('familyid' => $this->id), 'OR', 'ab.rank, gender DESC');
$this->_tmp['members'] = $GLOBALS['system']->getDBObjectData('person', Array('familyid' => $this->id)+$restriction, 'AND', 'ab.rank, gender DESC');
}
return $this->_tmp['members'];
}
Expand Down Expand Up @@ -481,6 +482,13 @@ private function savePhoto() {
}
}

private function clearPhoto()
{
$db =& $GLOBALS['db'];
$SQL = 'DELETE FROM family_photo WHERE familyid = '.(int)$this->id;
return $db->query($SQL);
}

/* Find a family that looks like a duplicate of this one - if it has the same family name and a member with the same name
*/
public function findSimilarFamilies()
Expand Down Expand Up @@ -526,7 +534,7 @@ public static function getFamilyDataByMemberIDs($member_ids)
) allmembers ON allmembers.familyid = f.id
LEFT JOIN (
select f.id as familyid, GROUP_CONCAT(p.first_name ORDER BY ab.rank ASC, p.gender DESC SEPARATOR ", ") as names
FROM person p
FROM person p
JOIN family f on p.familyid = f.id
JOIN age_bracket ab ON ab.id = p.age_bracketid
WHERE ab.is_adult and p.status <> "archived"
Expand Down Expand Up @@ -563,4 +571,47 @@ public static function printSingleFinder($name, $currentval=NULL)
<?php
}

public function archiveAndClean()
{
if (!$this->acquireLock()) return FALSE;
foreach ($this->fields as $fieldname => $params) {
switch ($fieldname) {
case 'family_name':
$this->setValue($fieldname, '['._('Removed').']');
break;
case 'status_last_changed':
case 'creator':
case 'created':
case 'state':
// leave these intact
break;
case 'status':
$this->setValue($fieldname, 'archived');
break;
case 'history':
$this->setValue($fieldname, Array());
break;
default:
$this->setValue($fieldname, '');
}
}
$this->clearPhoto();
if (!$this->save(FALSE)) return FALSE;

$notes = $GLOBALS['system']->getDBObjectData('family_note', Array('familyid' => $this->id));
foreach ($notes as $noteid => $data) {
$n = new Family_Note($noteid);
$n->delete();
}

$this->releaseLock();
return TRUE;
}

public function delete()
{
parent::delete();
Abstract_Note::cleanupInstances();
return TRUE;
}
}
4 changes: 3 additions & 1 deletion db_objects/family_note.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ function getInitSQL($table_name=NULL)
CREATE TABLE `family_note` (
`familyid` int(11) NOT NULL default '0',
`id` int(11) NOT NULL default '0',
PRIMARY KEY (`familyid`,`id`)
PRIMARY KEY (`familyid`,`id`),
CONSTRAINT `fn_familyid` FOREIGN KEY (familyid) REFERENCES family(id) ON DELETE CASCADE,
CONSTRAINT fn_id FOREIGN KEY (id) REFERENCES abstract_note(id) ON DELETE CASCADE
) ENGINE=InnoDB;
";
}
Expand Down
Loading